import{n as S}from"./index.browser-OxPLOBIU.js";import{Q as $,x as y,o as H,a4 as o,aY as L,b as N,w as I,Z as V,B as i,U as a,bD as P,bg as U,S as d,a9 as k,W as l,a0 as s,R as c,b0 as C,ao as p,ab as w,b1 as b,bz as h,c9 as j,Y as D,bx as z,a7 as O,bE as R,br as Y}from"./index-DxANhO1k.js";import{E as Q}from"./EditConfig-B1gPkiKG.js";import{a as W,b as Z}from"./VBtn-BKDLm-Pz.js";import"./VForm-DhjhzafT.js";import"./VCheckboxBtn-CJJKU0Jh.js";import"./VExpansionPanels-DsZsRyUe.js";import"./VAlert-C_Jv1M-3.js";import"./VSwitch-DAueUTAw.js";import"./VTextField-Dsv55ZTU.js";import"./VVirtualScroll-HpbJdiAg.js";import"./VSlider-BFPT4-KU.js";import"./VDialog-1mEV66nR.js";import"./VSpacer-DFaVs3iZ.js";/* empty css              */import"./_plugin-vue_export-helper-DlAUqK2U.js";const q={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},x={id:"auth",href:"",target:"_blank"},de=$({__name:"AddProvider",props:{domain:{}},setup(M){const T=R(),m=y([]),g=S(11),u=y(!1),f=y(!1),v=M;H(()=>{const t=o.subscribe(L.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)});N(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})},B=function(t){const e=[],{t:n}=Y();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(),V("section",null,[i(P,null,{default:a(()=>[s(o).providerManifests[t.domain]?(d(),V("div",q,[i(C,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)(B(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("  ")),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(Q,{"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(O,{key:0,style:{"background-color":"white"}},{default:a(()=>[i(C,null,{default:a(()=>e[7]||(e[7]=[p("Authenticating...")])),_:1}),i(b,null,{default:a(()=>e[8]||(e[8]=[p("A new tab/popup should be opened where you can authenticate")])),_:1}),i(z,null,{default:a(()=>[l("a",x,[i(W,null,{default:a(()=>e[9]||(e[9]=[p("Click here if the popup did not open")])),_:1})])]),_:1})]),_:1})):(d(),c(Z,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{de as default};
