import{n as S}from"./index.browser-OxPLOBIU.js";import{x as $,aA as H,r as b,o as I,I as o,ah as L,b as N,w as P,y as d,D as w,n as i,A as s,G as r,S as m,J as k,aB as C,B as l,z as c,K as V,aV as j,af as D}from"./index-Dvn4b3kE.js";import{E as U}from"./EditConfig-GlgW_AZF.js";import{b as z,V as h,a as g}from"./VCardText-CXkKR7ML.js";import{e as O}from"./VMenu-BxZEtUbH.js";import{V as G}from"./VList-BFxH2oe3.js";import{a as J,V as K}from"./VCard-DDEjK8sh.js";import{v as R,C as q}from"./VListItem-XlHdRn90.js";import"./VExpansionPanels-CRDFiEUd.js";import"./VCheckboxBtn-B2R62I44.js";import"./VAlert-BKHMgC3s.js";import"./VSwitch-BjWr2FW1.js";import"./VTextField-CNfw_aKz.js";import"./VVirtualScroll-DezxvIhI.js";import"./VChip-BKGA7XXZ.js";import"./VSlider-D6_NZN0T.js";import"./VForm-3D0lQdNE.js";import"./VSpacer-BpjLI35r.js";/* empty css              */import"./VDialog-CHkPjb9d.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const F={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},Q={id:"auth",href:"",target:"_blank"},ce=$({__name:"AddProvider",props:{domain:{}},setup(M){const A=H(),p=b([]),y=S(11),u=b(!1),f=b(!1),v=M;I(()=>{const t=o.subscribe(L.AUTH_SESSION,e=>{if(e.object_id!==y)return;const n=e.data;f.value=!0,window.setTimeout(()=>{const a=document.getElementById("auth");a.setAttribute("href",n),a.click()},100)});N(t)}),P(()=>v.domain,async t=>{t&&(p.value=await o.getProviderConfigEntries(v.domain,void 0,void 0,{session_id:y}))},{immediate:!0});const T=async function(t){u.value=!0,o.saveProviderConfig(v.domain,t).then(()=>{A.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=y,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}=D();for(const a of t)a.includes("@")?e.push(`[${a.replace("@","")}](https://github.com/${a.replace("@","")})`):e.push(a);return`**${n("settings.codeowners")}**: `+e.join(" / ")};return(t,e)=>(d(),w("section",null,[i(z,null,{default:s(()=>[r(o).providerManifests[t.domain]?(d(),w("div",F,[i(h,null,{default:s(()=>[m(k(t.$t("settings.setup_provider",[r(o).providerManifests[t.domain].name])),1)]),_:1}),i(g,{innerHTML:r(C)(r(o).providerManifests[t.domain].description)},null,8,["innerHTML"]),e[3]||(e[3]=l("br",null,null,-1)),r(o).providerManifests[t.domain].codeowners.length?(d(),c(g,{key:0,innerHTML:r(C)(E(r(o).providerManifests[t.domain].codeowners))},null,8,["innerHTML"])):V("",!0),r(o).providerManifests[t.domain].documentation?(d(),c(g,{key:1},{default:s(()=>[l("b",null,k(t.$t("settings.need_help_setup_provider")),1),e[2]||(e[2]=m("  ")),l("a",{onClick:e[0]||(e[0]=n=>r(j)(r(o).providerManifests[t.domain].documentation))},k(t.$t("settings.check_docs")),1)]),_:1})):V("",!0)])):V("",!0),e[4]||(e[4]=l("br",null,null,-1)),i(G),e[5]||(e[5]=l("br",null,null,-1)),e[6]||(e[6]=l("br",null,null,-1)),i(U,{"config-entries":p.value,disabled:!1,onSubmit:T,onAction:B},null,8,["config-entries"])]),_:1}),i(O,{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(K,{key:0,style:{"background-color":"white"}},{default:s(()=>[i(h,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(J,null,{default:s(()=>[l("a",Q,[i(R,null,{default:s(()=>e[9]||(e[9]=[m("Click here if the popup did not open")])),_:1})])]),_:1})]),_:1})):(d(),c(q,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{ce as default};
