import{av as E,H as g,a3 as I,aL as l,b6 as S,a4 as P,J as N,aw as k,x as s,aB as r,bS as _,bs as j,ax as u,ay as v,aD as d,az as o,d as m,bb as w,bc as f,aI as c,bd as y,bP as H,cr as L,aQ as C,bM as O,K as U,aO as x,b3 as D,bG as z,aA as F}from"./index-C-Ivu3jU.js";import{E as G}from"./EditConfig-Y1ATbenl.js";import{n as J}from"./index.browser-OxPLOBIU.js";import{V as K}from"./VTextField-Bkx949P5.js";import{V as Q}from"./VSwitch-BQ2ltI05.js";import"./VForm-BYcBSxOg.js";import"./VInput-CnrZS6Kh.js";import"./VExpansionPanels-BevVHr3H.js";import"./VAlert-B3qbTkCR.js";import"./VSlider-B7gznk4l.js";import"./VSelect-JgdoZi1R.js";import"./VVirtualScroll-C_Lzj3jv.js";import"./VCheckboxBtn-BmKOjEU4.js";import"./VDialog-BZuFHdVP.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const R={key:0},q={id:"auth",href:"",target:"_blank"},me=E({__name:"EditProvider",props:{instanceId:{}},setup(h){const M=F(),a=g(),V=J(11),p=g(!1),b=g(!1),T=h;I(()=>{const n=l.subscribe(S.AUTH_SESSION,e=>{if(e.object_id!==V)return;const t=e.data;b.value=!0,window.setTimeout(()=>{const i=document.getElementById("auth");i.setAttribute("href",t),i.click()},100)});P(n)}),N(()=>T.instanceId,async n=>{n&&(a.value=await l.getProviderConfig(n))},{immediate:!0});const A=async function(n){p.value=!0,n.enabled=a.value.enabled,n.name=a.value.name||null,l.saveProviderConfig(a.value.domain,n,a.value.instance_id).then(()=>{M.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{p.value=!1,b.value=!1})},$=async function(n,e){p.value=!0;for(const t of Object.values(a.value.values))t.value!==void 0&&e[t.key]==null&&(e[t.key]=t.value);e.session_id=V,l.getProviderConfigEntries(a.value.domain,a.value.instance_id,n,e).then(t=>{a.value.values={};for(const i of t)a.value.values[i.key]=i}).catch(t=>{alert(t)}).finally(()=>{p.value=!1,b.value=!1})},B=function(n){const e=[],{t}=z();for(const i of n)i.includes("@")?e.push(`[${i.replace("@","")}](https://github.com/${i.replace("@","")})`):e.push(i);return`**${t("settings.codeowners")}**: `+e.join(" / ")};return(n,e)=>(u(),k("section",null,[s(_,null,{default:r(()=>[a.value&&o(l).providerManifests[a.value.domain]?(u(),k("div",R,[s(w,null,{default:r(()=>[f(c(n.$t("settings.setup_provider",[o(l).providerManifests[a.value.domain].name])),1)]),_:1}),s(y,{style:{"white-space":"normal"}},{default:r(()=>[f(c(o(l).providerManifests[a.value.domain].description),1)]),_:1}),e[5]||(e[5]=m("br",null,null,-1)),o(l).providerManifests[a.value.domain].codeowners.length?(u(),d(y,{key:0,innerHTML:o(H)(B(o(l).providerManifests[a.value.domain].codeowners))},null,8,["innerHTML"])):v("",!0),o(l).providerManifests[a.value.domain].documentation?(u(),d(y,{key:1},{default:r(()=>[m("b",null,c(n.$t("settings.need_help_setup_provider")),1),e[4]||(e[4]=f("  ",-1)),m("a",{onClick:e[0]||(e[0]=t=>o(L)(o(l).providerManifests[a.value.domain].documentation))},c(n.$t("settings.check_docs")),1)]),_:1})):v("",!0),e[6]||(e[6]=m("br",null,null,-1)),s(C),e[7]||(e[7]=m("br",null,null,-1)),e[8]||(e[8]=m("br",null,null,-1)),"name"in a.value?(u(),d(K,{key:2,modelValue:a.value.name,"onUpdate:modelValue":e[1]||(e[1]=t=>a.value.name=t),placeholder:o(l).getProvider(a.value.instance_id)?.name,label:n.$t("settings.provider_name"),variant:"outlined",clearable:""},null,8,["modelValue","placeholder","label"])):v("",!0),"enabled"in a.value?(u(),d(Q,{key:3,modelValue:a.value.enabled,"onUpdate:modelValue":e[2]||(e[2]=t=>a.value.enabled=t),label:n.$t("settings.enable_provider"),color:"primary",disabled:!o(l).providerManifests[a.value.domain]?.allow_disable},null,8,["modelValue","label","disabled"])):v("",!0)])):v("",!0),s(C),a.value?(u(),d(G,{key:1,"config-entries":Object.values(a.value.values),disabled:!a.value.enabled,onSubmit:A,onAction:$},null,8,["config-entries","disabled"])):v("",!0)]),_:1}),s(j,{modelValue:p.value,"onUpdate:modelValue":e[3]||(e[3]=t=>p.value=t),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:r(()=>[b.value?(u(),d(x,{key:0,style:{"background-color":"white"}},{default:r(()=>[s(w,null,{default:r(()=>[...e[9]||(e[9]=[f("Authenticating...",-1)])]),_:1}),s(y,null,{default:r(()=>[...e[10]||(e[10]=[f("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),s(O,null,{default:r(()=>[m("a",q,[s(U,null,{default:r(()=>[...e[11]||(e[11]=[f("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(u(),d(D,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{me as default};
