import{n as B}from"./index.browser-OxPLOBIU.js";import{aw as N,J as k,a3 as S,aN as o,b9 as $,a4 as x,L as H,ax as V,ay as f,o as a,aD as s,az as C,E as u,aB as i,aG as g,be as h,bf as m,aL as w,bg as b,b_ as M,cC as I,aS as P,c1 as D,bT as j,M as U,aQ as z,b6 as O,bv as G,aC as J,bL as Q}from"./index-BeguICWm.js";import{E as R}from"./EditConfig-BikzkWGK.js";import"./VForm-o34xemXk.js";import"./VExpansionPanels-B8yzmmSz.js";import"./VDialog-3N5CnNiB.js";import"./VAlert-Dkia6PbV.js";import"./VSwitch-DhgrqvI4.js";import"./VCheckboxBtn-HpD-UT_z.js";import"./VSlider-5AtOwDvY.js";import"./VSelect-Be4aEu8s.js";import"./VVirtualScroll-Vx_hX6dw.js";const q={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},F={id:"auth",href:"",target:"_blank"},se=N({__name:"AddProviderDetails",props:{domain:{}},setup(r){const T=J(),p=k([]),y=B(11),d=k(!1),c=k(!1),v=r;S(()=>{const n=o.subscribe($.AUTH_SESSION,e=>{if(e.object_id!==y)return;const t=e.data;c.value=!0,window.setTimeout(()=>{const l=document.getElementById("auth");l.setAttribute("href",t),l.click()},100)});x(n)}),H(()=>v.domain,async n=>{n&&(p.value=await o.getProviderConfigEntries(v.domain,void 0,void 0,{session_id:y}))},{immediate:!0});const A=async function(n){d.value=!0,o.saveProviderConfig(v.domain,n).then(()=>{T.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{d.value=!1,c.value=!1})},E=async function(n,e){d.value=!0;for(const t of p.value)t.value!==void 0&&e[t.key]==null&&(e[t.key]=t.value);e.session_id=y,o.getProviderConfigEntries(v.domain,void 0,n,e).then(t=>{p.value=t}).catch(t=>{alert(t)}).finally(()=>{d.value=!1,c.value=!1})},L=function(n){const e=[],{t}=Q();for(const l of n)l.includes("@")?e.push(`[${l.replace("@","")}](https://github.com/${l.replace("@","")})`):e.push(l);return`**${t("settings.codeowners")}**: `+e.join(" / ")};return(n,e)=>(f(),V("section",null,[a(D,null,{default:s(()=>[i(o).providerManifests[r.domain]?(f(),V("div",q,[a(h,null,{default:s(()=>[m(w(n.$t("settings.setup_provider",[i(o).providerManifests[r.domain].name])),1)]),_:1}),a(b,{innerHTML:i(M)(i(o).providerManifests[r.domain].description)},null,8,["innerHTML"]),e[3]||(e[3]=u("br",null,null,-1)),i(o).providerManifests[r.domain].codeowners.length?(f(),g(b,{key:0,innerHTML:i(M)(L(i(o).providerManifests[r.domain].codeowners))},null,8,["innerHTML"])):C("",!0),i(o).providerManifests[r.domain].documentation?(f(),g(b,{key:1},{default:s(()=>[u("b",null,w(n.$t("settings.need_help_setup_provider")),1),e[2]||(e[2]=m("  ",-1)),u("a",{onClick:e[0]||(e[0]=t=>i(I)(i(o).providerManifests[r.domain].documentation))},w(n.$t("settings.check_docs")),1)]),_:1})):C("",!0)])):C("",!0),e[4]||(e[4]=u("br",null,null,-1)),a(P),e[5]||(e[5]=u("br",null,null,-1)),e[6]||(e[6]=u("br",null,null,-1)),a(R,{"config-entries":p.value,disabled:!1,onSubmit:A,onAction:E},null,8,["config-entries"])]),_:1}),a(G,{modelValue:d.value,"onUpdate:modelValue":e[1]||(e[1]=t=>d.value=t),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:s(()=>[c.value?(f(),g(z,{key:0,style:{"background-color":"white"}},{default:s(()=>[a(h,null,{default:s(()=>[...e[7]||(e[7]=[m("Authenticating...",-1)])]),_:1}),a(b,null,{default:s(()=>[...e[8]||(e[8]=[m("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),a(j,null,{default:s(()=>[u("a",F,[a(U,null,{default:s(()=>[...e[9]||(e[9]=[m("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(f(),g(O,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{se as default};
