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 D,y as u,D as C,n as r,A as i,G as a,S as l,J as m,B as s,z as g,K as V}from"./index-CiFFF7gT.js";import{E as I}from"./EditConfig-CefiVBf2.js";import{b as $,V as w,a as c}from"./VCardText-DAFrt-9i.js";import{e as j}from"./VMenu-pCNX3_Sk.js";import{V as z}from"./VList-ox5PnObc.js";import{a as U,V as O}from"./VCard-OVRwQRVf.js";import{v as G,C as H}from"./VListItem-De5QDDiQ.js";import"./VExpansionPanels-DHLfZtZd.js";import"./VCheckboxBtn-BFRXrpB8.js";import"./VAlert-DvGaZwBF.js";import"./VSwitch-VVilSN5z.js";import"./VTextField-BPDkDfKc.js";import"./VVirtualScroll-BganvpON.js";import"./VChip-BY-Tj5X5.js";import"./VSlider-DjU-EfGF.js";import"./VForm-BXN19_76.js";import"./VSpacer-ouclmOAP.js";/* empty css              */import"./VDialog-dHvRVqSU.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([]),y=M(11),d=b(!1),p=b(!1),v=h;_(()=>{const t=n.subscribe(N.AUTH_SESSION,e=>{if(e.object_id!==y)return;const o=e.data;p.value=!0,window.setTimeout(()=>{const k=document.getElementById("auth");k.setAttribute("href",o),k.click()},100)});P(t)}),D(()=>v.domain,async t=>{t&&(f.value=await n.getProviderConfigEntries(v.domain,void 0,void 0,{session_id:y}))},{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=y,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($,null,{default:i(()=>[a(n).providerManifests[t.domain]?(u(),C("div",J,[r(w,null,{default:i(()=>[l(m(t.$t("settings.setup_provider",[a(n).providerManifests[t.domain].name])),1)]),_:1}),r(c,null,{default:i(()=>[l(m(a(n).providerManifests[t.domain].description),1)]),_:1}),e[2]||(e[2]=s("br",null,null,-1)),a(n).providerManifests[t.domain].codeowners.length?(u(),g(c,{key:0},{default:i(()=>[s("b",null,m(t.$t("settings.codeowners"))+": ",1),l(m(a(n).providerManifests[t.domain].codeowners.join(" / ")),1)]),_:1})):V("",!0),a(n).providerManifests[t.domain].documentation?(u(),g(c,{key:1},{default:i(()=>[s("b",null,m(t.$t("settings.need_help_setup_provider")),1),e[1]||(e[1]=l("  ")),s("a",{href:a(n).getDocumentationAddress(a(n).providerManifests[t.domain].documentation),target:"_blank"},m(t.$t("settings.check_docs")),9,K)]),_:1})):V("",!0)])):V("",!0),e[3]||(e[3]=s("br",null,null,-1)),r(z),e[4]||(e[4]=s("br",null,null,-1)),e[5]||(e[5]=s("br",null,null,-1)),r(I,{"config-entries":f.value,disabled:!1,onSubmit:B,onAction:E},null,8,["config-entries"])]),_:1}),r(j,{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(c,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(()=>[s("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};
