import{x as I,aA as S,r as g,o as P,I as o,ah as _,b as N,w as j,y as u,D as w,n as r,A as s,G as i,S as f,J as y,B as m,z as p,aB as U,K as c,aV as H,af as L}from"./index-Dvn4b3kE.js";import{E as O}from"./EditConfig-GlgW_AZF.js";import{n as x}from"./index.browser-OxPLOBIU.js";import{b as D,V as C,a as V}from"./VCardText-CXkKR7ML.js";import{e as z}from"./VMenu-BxZEtUbH.js";import{V as h}from"./VList-BFxH2oe3.js";import{V as F}from"./VTextField-CNfw_aKz.js";import{V as G}from"./VSwitch-BjWr2FW1.js";import{a as J,V as K}from"./VCard-DDEjK8sh.js";import{v as R,C as q}from"./VListItem-XlHdRn90.js";import"./VExpansionPanels-CRDFiEUd.js";import"./VCheckboxBtn-B2R62I44.js";import"./VAlert-BKHMgC3s.js";import"./VSlider-D6_NZN0T.js";import"./VVirtualScroll-DezxvIhI.js";import"./VChip-BKGA7XXZ.js";import"./VForm-3D0lQdNE.js";import"./VSpacer-BpjLI35r.js";/* empty css              */import"./VDialog-CHkPjb9d.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const Q={key:0},W={id:"auth",href:"",target:"_blank"},Ve=I({__name:"EditProvider",props:{instanceId:{}},setup(A){const M=S(),t=g(),k=x(11),v=g(!1),b=g(!1),T=A;P(()=>{const a=o.subscribe(_.AUTH_SESSION,e=>{if(e.object_id!==k)return;const n=e.data;b.value=!0,window.setTimeout(()=>{const l=document.getElementById("auth");l.setAttribute("href",n),l.click()},100)});N(a)}),j(()=>T.instanceId,async a=>{a&&(t.value=await o.getProviderConfig(a))},{immediate:!0});const B=async function(a){v.value=!0,a.enabled=t.value.enabled,a.name=t.value.name||null,o.saveProviderConfig(t.value.domain,a,t.value.instance_id).then(()=>{M.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{v.value=!1,b.value=!1})},$=async function(a,e){v.value=!0;for(const n of Object.values(t.value.values))n.value!==void 0&&e[n.key]==null&&(e[n.key]=n.value);e.session_id=k,o.getProviderConfigEntries(t.value.domain,t.value.instance_id,a,e).then(n=>{t.value.values={};for(const l of n)t.value.values[l.key]=l}).catch(n=>{alert(n)}).finally(()=>{v.value=!1,b.value=!1})},E=function(a){const e=[],{t:n}=L();for(const l of a)l.includes("@")?e.push(`[${l.replace("@","")}](https://github.com/${l.replace("@","")})`):e.push(l);return`**${n("settings.codeowners")}**: `+e.join(" / ")};return(a,e)=>(u(),w("section",null,[r(D,null,{default:s(()=>{var n,l;return[t.value&&i(o).providerManifests[t.value.domain]?(u(),w("div",Q,[r(C,null,{default:s(()=>{var d;return[f(y(a.$t("settings.setup_provider",[t.value.name||((d=i(o).getProvider(t.value.instance_id))==null?void 0:d.name)])),1)]}),_:1}),r(V,{style:{"white-space":"normal"}},{default:s(()=>[f(y(i(o).providerManifests[t.value.domain].description),1)]),_:1}),e[5]||(e[5]=m("br",null,null,-1)),i(o).providerManifests[t.value.domain].codeowners.length?(u(),p(V,{key:0,innerHTML:i(U)(E(i(o).providerManifests[t.value.domain].codeowners))},null,8,["innerHTML"])):c("",!0),i(o).providerManifests[t.value.domain].documentation?(u(),p(V,{key:1},{default:s(()=>[m("b",null,y(a.$t("settings.need_help_setup_provider")),1),e[4]||(e[4]=f("  ")),m("a",{onClick:e[0]||(e[0]=d=>i(H)(i(o).providerManifests[t.value.domain].documentation))},y(a.$t("settings.check_docs")),1)]),_:1})):c("",!0),e[6]||(e[6]=m("br",null,null,-1)),r(h),e[7]||(e[7]=m("br",null,null,-1)),e[8]||(e[8]=m("br",null,null,-1)),"name"in t.value?(u(),p(F,{key:2,modelValue:t.value.name,"onUpdate:modelValue":e[1]||(e[1]=d=>t.value.name=d),placeholder:(n=i(o).getProvider(t.value.instance_id))==null?void 0:n.name,label:a.$t("settings.provider_name"),variant:"outlined",clearable:""},null,8,["modelValue","placeholder","label"])):c("",!0),"enabled"in t.value?(u(),p(G,{key:3,modelValue:t.value.enabled,"onUpdate:modelValue":e[2]||(e[2]=d=>t.value.enabled=d),label:a.$t("settings.enable_provider"),color:"primary",disabled:!((l=i(o).providerManifests[t.value.domain])!=null&&l.allow_disable)},null,8,["modelValue","label","disabled"])):c("",!0)])):c("",!0),r(h),t.value?(u(),p(O,{key:1,"config-entries":Object.values(t.value.values),disabled:!t.value.enabled,onSubmit:B,onAction:$},null,8,["config-entries","disabled"])):c("",!0)]}),_:1}),r(z,{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:s(()=>[b.value?(u(),p(K,{key:0,style:{"background-color":"white"}},{default:s(()=>[r(C,null,{default:s(()=>e[9]||(e[9]=[f("Authenticating...")])),_:1}),r(V,null,{default:s(()=>e[10]||(e[10]=[f("A new tab/popup should be opened where you can authenticate")])),_:1}),r(J,null,{default:s(()=>[m("a",W,[r(R,null,{default:s(()=>e[11]||(e[11]=[f("Click here if the popup did not open")])),_:1})])]),_:1})]),_:1})):(u(),p(q,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{Ve as default};
