import{n as B}from"./index.browser-OxPLOBIU.js";import{U as H,x as y,o as L,a6 as o,aY as N,b as S,w as I,a0 as C,X as d,F as i,Y as a,bG as P,bi as U,ab as k,E as l,a2 as s,W as c,b1 as V,as as p,ad as w,b2 as b,bC as h,cc as j,$ as D,bA as O,a9 as Y,bH as z,bt as F}from"./index-B-lUZalq.js";import{E as G}from"./EditConfig-CH-Rsyh7.js";import{a as R,b as W}from"./VBtn-BPJ1JKW-.js";import"./VForm-C-dO2GIE.js";import"./VInput-BWBQqjuk.js";import"./VExpansionPanels-CR_eBB13.js";import"./VAlert-QHTIcuEJ.js";import"./VSwitch-Bhk7qcAi.js";import"./VTextField-B-d5Pe9I.js";import"./VVirtualScroll-CceW16X7.js";import"./VSlider-BCIrn4it.js";import"./VDialog-CAgq0L03.js";import"./VSpacer-DDLrofv-.js";/* empty css              */import"./_plugin-vue_export-helper-DlAUqK2U.js";const X={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},q={id:"auth",href:"",target:"_blank"},de=H({__name:"AddProvider",props:{domain:{}},setup(M){const T=z(),m=y([]),g=B(11),u=y(!1),f=y(!1),v=M;L(()=>{const t=o.subscribe(N.AUTH_SESSION,e=>{if(e.object_id!==g)return;const n=e.data;f.value=!0,window.setTimeout(()=>{const r=document.getElementById("auth");r.setAttribute("href",n),r.click()},100)});S(t)}),I(()=>v.domain,async t=>{t&&(m.value=await o.getProviderConfigEntries(v.domain,void 0,void 0,{session_id:g}))},{immediate:!0});const A=async function(t){u.value=!0,o.saveProviderConfig(v.domain,t).then(()=>{T.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{u.value=!1,f.value=!1})},E=async function(t,e){u.value=!0;for(const n of m.value)n.value!==void 0&&e[n.key]==null&&(e[n.key]=n.value);e.session_id=g,o.getProviderConfigEntries(v.domain,void 0,t,e).then(n=>{m.value=n}).catch(n=>{alert(n)}).finally(()=>{u.value=!1,f.value=!1})},$=function(t){const e=[],{t:n}=F();for(const r of t)r.includes("@")?e.push(`[${r.replace("@","")}](https://github.com/${r.replace("@","")})`):e.push(r);return`**${n("settings.codeowners")}**: `+e.join(" / ")};return(t,e)=>(d(),C("section",null,[i(P,null,{default:a(()=>[s(o).providerManifests[t.domain]?(d(),C("div",X,[i(V,null,{default:a(()=>[p(w(t.$t("settings.setup_provider",[s(o).providerManifests[t.domain].name])),1)]),_:1}),i(b,{innerHTML:s(h)(s(o).providerManifests[t.domain].description)},null,8,["innerHTML"]),e[3]||(e[3]=l("br",null,null,-1)),s(o).providerManifests[t.domain].codeowners.length?(d(),c(b,{key:0,innerHTML:s(h)($(s(o).providerManifests[t.domain].codeowners))},null,8,["innerHTML"])):k("",!0),s(o).providerManifests[t.domain].documentation?(d(),c(b,{key:1},{default:a(()=>[l("b",null,w(t.$t("settings.need_help_setup_provider")),1),e[2]||(e[2]=p("  ",-1)),l("a",{onClick:e[0]||(e[0]=n=>s(j)(s(o).providerManifests[t.domain].documentation))},w(t.$t("settings.check_docs")),1)]),_:1})):k("",!0)])):k("",!0),e[4]||(e[4]=l("br",null,null,-1)),i(D),e[5]||(e[5]=l("br",null,null,-1)),e[6]||(e[6]=l("br",null,null,-1)),i(G,{"config-entries":m.value,disabled:!1,onSubmit:A,onAction:E},null,8,["config-entries"])]),_:1}),i(U,{modelValue:u.value,"onUpdate:modelValue":e[1]||(e[1]=n=>u.value=n),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:a(()=>[f.value?(d(),c(Y,{key:0,style:{"background-color":"white"}},{default:a(()=>[i(V,null,{default:a(()=>[...e[7]||(e[7]=[p("Authenticating...",-1)])]),_:1}),i(b,null,{default:a(()=>[...e[8]||(e[8]=[p("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),i(O,null,{default:a(()=>[l("a",q,[i(R,null,{default:a(()=>[...e[9]||(e[9]=[p("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(d(),c(W,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{de as default};
