import{n as M}from"./index.browser-OxPLOBIU.js";import{x as S,az as T,r as b,o as _,I as n,af as N,b as P,w as I,y as u,D as C,n as r,A as i,G as s,S as l,J as m,B as a,z as g,K as V}from"./index-CFvoaD7J.js";import{E as $}from"./EditConfig-Ct-cJfRC.js";import{b as j,V as w,a as y}from"./VCardText-CpOuj25H.js";import{e as z}from"./VMenu-9pSrU4Fo.js";import{V as D}from"./VList-fGk9SRdf.js";import{a as U,V as O}from"./VCard-DxLPF-Ra.js";import{v as G,C as H}from"./VListItem-CSPID7yq.js";import"./VExpansionPanels-BsT7TGi_.js";import"./VCheckboxBtn-CRgZyCzV.js";import"./VAlert-CIiIOQza.js";import"./VSwitch-Cbz5zuOr.js";import"./VTextField-DF4u_eMy.js";import"./VVirtualScroll-BDBVEoUv.js";import"./VChip-Ccz1-bmn.js";import"./VSlider-ka6goZbo.js";import"./VForm-B86dz_JX.js";import"./VSpacer-UYEiyhN7.js";/* empty css              */import"./VDialog-CdvGeqlS.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const J={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},K=["href"],L={id:"auth",href:"",target:"_blank"},fe=S({__name:"AddProvider",props:{domain:{}},setup(h){const A=T(),f=b([]),c=M(11),d=b(!1),p=b(!1),v=h;_(()=>{const t=n.subscribe(N.AUTH_SESSION,e=>{if(e.object_id!==c)return;const o=e.data;p.value=!0,window.setTimeout(()=>{const k=document.getElementById("auth");k.setAttribute("href",o),k.click()},100)});P(t)}),I(()=>v.domain,async t=>{t&&(f.value=await n.getProviderConfigEntries(v.domain,void 0,void 0,{session_id:c}))},{immediate:!0});const B=async function(t){d.value=!0,n.saveProviderConfig(v.domain,t).then(()=>{A.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{d.value=!1,p.value=!1})},E=async function(t,e){d.value=!0;for(const o of f.value)o.value!==void 0&&e[o.key]==null&&(e[o.key]=o.value);e.session_id=c,n.getProviderConfigEntries(v.domain,void 0,t,e).then(o=>{f.value=o}).catch(o=>{alert(o)}).finally(()=>{d.value=!1,p.value=!1})};return(t,e)=>(u(),C("section",null,[r(j,null,{default:i(()=>[s(n).providerManifests[t.domain]?(u(),C("div",J,[r(w,null,{default:i(()=>[l(m(t.$t("settings.setup_provider",[s(n).providerManifests[t.domain].name])),1)]),_:1}),r(y,null,{default:i(()=>[l(m(s(n).providerManifests[t.domain].description),1)]),_:1}),e[2]||(e[2]=a("br",null,null,-1)),s(n).providerManifests[t.domain].codeowners.length?(u(),g(y,{key:0},{default:i(()=>[a("b",null,m(t.$t("settings.codeowners"))+": ",1),l(m(s(n).providerManifests[t.domain].codeowners.join(" / ")),1)]),_:1})):V("",!0),s(n).providerManifests[t.domain].documentation?(u(),g(y,{key:1},{default:i(()=>[a("b",null,m(t.$t("settings.need_help_setup_provider")),1),e[1]||(e[1]=l("  ")),a("a",{href:s(n).providerManifests[t.domain].documentation,target:"_blank"},m(t.$t("settings.check_docs")),9,K)]),_:1})):V("",!0)])):V("",!0),e[3]||(e[3]=a("br",null,null,-1)),r(D),e[4]||(e[4]=a("br",null,null,-1)),e[5]||(e[5]=a("br",null,null,-1)),r($,{"config-entries":f.value,disabled:!1,onSubmit:B,onAction:E},null,8,["config-entries"])]),_:1}),r(z,{modelValue:d.value,"onUpdate:modelValue":e[0]||(e[0]=o=>d.value=o),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:i(()=>[p.value?(u(),g(O,{key:0,style:{"background-color":"white"}},{default:i(()=>[r(w,null,{default:i(()=>e[6]||(e[6]=[l("Authenticating...")])),_:1}),r(y,null,{default:i(()=>e[7]||(e[7]=[l("A new tab/popup should be opened where you can authenticate")])),_:1}),r(U,null,{default:i(()=>[a("a",L,[r(G,null,{default:i(()=>e[8]||(e[8]=[l("Click here if the popup did not open")])),_:1})])]),_:1})]),_:1})):(u(),g(H,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{fe as default};
