import{n as B}from"./index.browser-OxPLOBIU.js";import{Q as $,x as y,o as S,a4 as o,aV as H,b as L,w as N,Z as w,B as i,U as a,bD as I,bg as P,S as d,a9 as k,W as l,a0 as s,R as c,a_ as C,ao as p,ab as V,a$ as g,bz as h,c9 as U,Y as j,bx as D,a7 as z,bE as O,br as R}from"./index-C8Wvo59W.js";import{E as Q}from"./EditConfig-C0Lx1-IM.js";import{a as W,b as Y}from"./VBtn-DmOE8ObX.js";import"./VForm-CPvteUGy.js";import"./VCheckboxBtn-DZffJlMk.js";import"./VExpansionPanels-BO9iQD3i.js";import"./VAlert-DjHMaeFy.js";import"./VSwitch-C763ACV_.js";import"./VTextField-h2jTOaQT.js";import"./VVirtualScroll-ZleTOGra.js";import"./VSlider-BbdIm9Mu.js";import"./VDialog-BKEcjOuu.js";import"./VSpacer-CRNj-rDk.js";/* empty css              */import"./_plugin-vue_export-helper-DlAUqK2U.js";const Z={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},q={id:"auth",href:"",target:"_blank"},de=$({__name:"AddProvider",props:{domain:{}},setup(M){const T=O(),m=y([]),b=B(11),u=y(!1),f=y(!1),v=M;S(()=>{const t=o.subscribe(H.AUTH_SESSION,e=>{if(e.object_id!==b)return;const n=e.data;f.value=!0,window.setTimeout(()=>{const r=document.getElementById("auth");r.setAttribute("href",n),r.click()},100)});L(t)}),N(()=>v.domain,async t=>{t&&(m.value=await o.getProviderConfigEntries(v.domain,void 0,void 0,{session_id:b}))},{immediate:!0});const _=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})},A=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=b,o.getProviderConfigEntries(v.domain,void 0,t,e).then(n=>{m.value=n}).catch(n=>{alert(n)}).finally(()=>{u.value=!1,f.value=!1})},E=function(t){const e=[],{t:n}=R();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(),w("section",null,[i(I,null,{default:a(()=>[s(o).providerManifests[t.domain]?(d(),w("div",Z,[i(C,null,{default:a(()=>[p(V(t.$t("settings.setup_provider",[s(o).providerManifests[t.domain].name])),1)]),_:1}),i(g,{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(g,{key:0,innerHTML:s(h)(E(s(o).providerManifests[t.domain].codeowners))},null,8,["innerHTML"])):k("",!0),s(o).providerManifests[t.domain].documentation?(d(),c(g,{key:1},{default:a(()=>[l("b",null,V(t.$t("settings.need_help_setup_provider")),1),e[2]||(e[2]=p("  ")),l("a",{onClick:e[0]||(e[0]=n=>s(U)(s(o).providerManifests[t.domain].documentation))},V(t.$t("settings.check_docs")),1)]),_:1,__:[2]})):k("",!0)])):k("",!0),e[4]||(e[4]=l("br",null,null,-1)),i(j),e[5]||(e[5]=l("br",null,null,-1)),e[6]||(e[6]=l("br",null,null,-1)),i(Q,{"config-entries":m.value,disabled:!1,onSubmit:_,onAction:A},null,8,["config-entries"])]),_:1,__:[4,5,6]}),i(P,{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(z,{key:0,style:{"background-color":"white"}},{default:a(()=>[i(C,null,{default:a(()=>e[7]||(e[7]=[p("Authenticating...")])),_:1,__:[7]}),i(g,null,{default:a(()=>e[8]||(e[8]=[p("A new tab/popup should be opened where you can authenticate")])),_:1,__:[8]}),i(D,null,{default:a(()=>[l("a",q,[i(W,null,{default:a(()=>e[9]||(e[9]=[p("Click here if the popup did not open")])),_:1,__:[9]})])]),_:1})]),_:1})):(d(),c(Y,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{de as default};
