import{n as S}from"./index.browser-OxPLOBIU.js";import{Q as $,x as y,o as H,a4 as o,aS as L,b as N,w as I,Z as w,B as i,U as s,bm as P,b3 as U,S as d,a9 as k,W as l,a0 as a,R as c,aU as C,al as m,aa as V,aV as g,bi as h,bT as j,Y as D,bg as O,a7 as Q,bn as R,aQ as z}from"./index-orrnp8a1.js";import{E as W}from"./EditConfig-B4rbu_aP.js";import{a as Y,f as Z}from"./VBtn-BJolvyKt.js";import"./VForm-BDfEPrwE.js";import"./VCheckboxBtn-CICj8ZxL.js";import"./VExpansionPanels-CT7PNnnx.js";import"./VAlert-BhQ3L7Kc.js";import"./VSwitch-Cg3DDPQB.js";import"./VTextField-DaF8PfrV.js";import"./VVirtualScroll-Q9Rc10mA.js";import"./VChip-DzIcRFdM.js";import"./VSlider-G4xlE4rG.js";import"./VDialog-oxeMlk6d.js";import"./VSpacer-FMK5QbR9.js";/* empty css              */import"./_plugin-vue_export-helper-DlAUqK2U.js";const q={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},F={id:"auth",href:"",target:"_blank"},me=$({__name:"AddProvider",props:{domain:{}},setup(M){const T=R(),p=y([]),b=S(11),u=y(!1),f=y(!1),v=M;H(()=>{const t=o.subscribe(L.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)});N(t)}),I(()=>v.domain,async t=>{t&&(p.value=await o.getProviderConfigEntries(v.domain,void 0,void 0,{session_id:b}))},{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})},B=async function(t,e){u.value=!0;for(const n of p.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=>{p.value=n}).catch(n=>{alert(n)}).finally(()=>{u.value=!1,f.value=!1})},E=function(t){const e=[],{t:n}=z();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(P,null,{default:s(()=>[a(o).providerManifests[t.domain]?(d(),w("div",q,[i(C,null,{default:s(()=>[m(V(t.$t("settings.setup_provider",[a(o).providerManifests[t.domain].name])),1)]),_:1}),i(g,{innerHTML:a(h)(a(o).providerManifests[t.domain].description)},null,8,["innerHTML"]),e[3]||(e[3]=l("br",null,null,-1)),a(o).providerManifests[t.domain].codeowners.length?(d(),c(g,{key:0,innerHTML:a(h)(E(a(o).providerManifests[t.domain].codeowners))},null,8,["innerHTML"])):k("",!0),a(o).providerManifests[t.domain].documentation?(d(),c(g,{key:1},{default:s(()=>[l("b",null,V(t.$t("settings.need_help_setup_provider")),1),e[2]||(e[2]=m("  ")),l("a",{onClick:e[0]||(e[0]=n=>a(j)(a(o).providerManifests[t.domain].documentation))},V(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(W,{"config-entries":p.value,disabled:!1,onSubmit:A,onAction:B},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:s(()=>[f.value?(d(),c(Q,{key:0,style:{"background-color":"white"}},{default:s(()=>[i(C,null,{default:s(()=>e[7]||(e[7]=[m("Authenticating...")])),_:1}),i(g,null,{default:s(()=>e[8]||(e[8]=[m("A new tab/popup should be opened where you can authenticate")])),_:1}),i(O,null,{default:s(()=>[l("a",F,[i(Y,null,{default:s(()=>e[9]||(e[9]=[m("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{me as default};
