import{Q as E,x as V,o as I,a4 as o,aS as P,b as U,w as _,Z as w,B as s,U as r,bm as N,b3 as j,S as u,a9 as f,R as m,a0 as i,W as p,aU as C,al as b,aa as g,aV as y,bi as H,bT as L,Y as h,bg as O,a7 as x,aQ as D,bn as Q}from"./index-orrnp8a1.js";import{E as R}from"./EditConfig-B4rbu_aP.js";import{n as z}from"./index.browser-OxPLOBIU.js";import{V as F}from"./VTextField-DaF8PfrV.js";import{V as W}from"./VSwitch-Cg3DDPQB.js";import{a as Y,f as Z}from"./VBtn-BJolvyKt.js";import"./VForm-BDfEPrwE.js";import"./VCheckboxBtn-CICj8ZxL.js";import"./VExpansionPanels-CT7PNnnx.js";import"./VAlert-BhQ3L7Kc.js";import"./VSlider-G4xlE4rG.js";import"./VVirtualScroll-Q9Rc10mA.js";import"./VChip-DzIcRFdM.js";import"./VDialog-oxeMlk6d.js";import"./VSpacer-FMK5QbR9.js";/* empty css              */import"./_plugin-vue_export-helper-DlAUqK2U.js";const q={key:0},G={id:"auth",href:"",target:"_blank"},fe=E({__name:"EditProvider",props:{instanceId:{}},setup(T){const M=Q(),a=V(),k=z(11),v=V(!1),c=V(!1),A=T;I(()=>{const t=o.subscribe(P.AUTH_SESSION,e=>{if(e.object_id!==k)return;const n=e.data;c.value=!0,window.setTimeout(()=>{const l=document.getElementById("auth");l.setAttribute("href",n),l.click()},100)});U(t)}),_(()=>A.instanceId,async t=>{t&&(a.value=await o.getProviderConfig(t))},{immediate:!0});const S=async function(t){v.value=!0,t.enabled=a.value.enabled,t.name=a.value.name||null,o.saveProviderConfig(a.value.domain,t,a.value.instance_id).then(()=>{M.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{v.value=!1,c.value=!1})},$=async function(t,e){v.value=!0;for(const n of Object.values(a.value.values))n.value!==void 0&&e[n.key]==null&&(e[n.key]=n.value);e.session_id=k,o.getProviderConfigEntries(a.value.domain,a.value.instance_id,t,e).then(n=>{a.value.values={};for(const l of n)a.value.values[l.key]=l}).catch(n=>{alert(n)}).finally(()=>{v.value=!1,c.value=!1})},B=function(t){const e=[],{t:n}=D();for(const l of t)l.includes("@")?e.push(`[${l.replace("@","")}](https://github.com/${l.replace("@","")})`):e.push(l);return`**${n("settings.codeowners")}**: `+e.join(" / ")};return(t,e)=>(u(),w("section",null,[s(N,null,{default:r(()=>{var n,l;return[a.value&&i(o).providerManifests[a.value.domain]?(u(),w("div",q,[s(C,null,{default:r(()=>{var d;return[b(g(t.$t("settings.setup_provider",[a.value.name||((d=i(o).getProvider(a.value.instance_id))==null?void 0:d.name)])),1)]}),_:1}),s(y,{style:{"white-space":"normal"}},{default:r(()=>[b(g(i(o).providerManifests[a.value.domain].description),1)]),_:1}),e[5]||(e[5]=p("br",null,null,-1)),i(o).providerManifests[a.value.domain].codeowners.length?(u(),m(y,{key:0,innerHTML:i(H)(B(i(o).providerManifests[a.value.domain].codeowners))},null,8,["innerHTML"])):f("",!0),i(o).providerManifests[a.value.domain].documentation?(u(),m(y,{key:1},{default:r(()=>[p("b",null,g(t.$t("settings.need_help_setup_provider")),1),e[4]||(e[4]=b("  ")),p("a",{onClick:e[0]||(e[0]=d=>i(L)(i(o).providerManifests[a.value.domain].documentation))},g(t.$t("settings.check_docs")),1)]),_:1})):f("",!0),e[6]||(e[6]=p("br",null,null,-1)),s(h),e[7]||(e[7]=p("br",null,null,-1)),e[8]||(e[8]=p("br",null,null,-1)),"name"in a.value?(u(),m(F,{key:2,modelValue:a.value.name,"onUpdate:modelValue":e[1]||(e[1]=d=>a.value.name=d),placeholder:(n=i(o).getProvider(a.value.instance_id))==null?void 0:n.name,label:t.$t("settings.provider_name"),variant:"outlined",clearable:""},null,8,["modelValue","placeholder","label"])):f("",!0),"enabled"in a.value?(u(),m(W,{key:3,modelValue:a.value.enabled,"onUpdate:modelValue":e[2]||(e[2]=d=>a.value.enabled=d),label:t.$t("settings.enable_provider"),color:"primary",disabled:!((l=i(o).providerManifests[a.value.domain])!=null&&l.allow_disable)},null,8,["modelValue","label","disabled"])):f("",!0)])):f("",!0),s(h),a.value?(u(),m(R,{key:1,"config-entries":Object.values(a.value.values),disabled:!a.value.enabled,onSubmit:S,onAction:$},null,8,["config-entries","disabled"])):f("",!0)]}),_:1}),s(j,{modelValue:v.value,"onUpdate:modelValue":e[3]||(e[3]=n=>v.value=n),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:r(()=>[c.value?(u(),m(x,{key:0,style:{"background-color":"white"}},{default:r(()=>[s(C,null,{default:r(()=>e[9]||(e[9]=[b("Authenticating...")])),_:1}),s(y,null,{default:r(()=>e[10]||(e[10]=[b("A new tab/popup should be opened where you can authenticate")])),_:1}),s(O,null,{default:r(()=>[p("a",G,[s(Y,null,{default:r(()=>e[11]||(e[11]=[b("Click here if the popup did not open")])),_:1})])]),_:1})]),_:1})):(u(),m(Z,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{fe as default};
