import{n as M}from"./index.browser-342e672c.js";import{d as B,an as N,r as g,o as S,b as n,a7 as T,a as P,N as j,c as u,g as V,f as i,w as a,u as r,Y as l,t as f,e as v,i as s,j as y}from"./index-e34071c2.js";import{E as $}from"./EditConfig-5e7973cb.js";import{V as k,a as I}from"./VCardText-2a290ffe.js";import{a as h,b as U,V as D}from"./VCard-0f63f60c.js";import{V as O}from"./VList-5a526902.js";import{s as z,y as H}from"./VListItem-6fb16d04.js";import{c as L}from"./VMenu-8ea0aa0a.js";import"./VExpansionPanels-a37be689.js";import"./VCheckboxBtn-43c6a5b9.js";import"./VForm-9598bded.js";import"./VTextField-df721147.js";import"./VVirtualScroll-8b839030.js";import"./VSpacer-b7ae4876.js";/* empty css              */import"./VDialog-57dacf99.js";import"./VAlert-cd8a958f.js";import"./_plugin-vue_export-helper-c27b6911.js";const R={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},Y=s("br",null,null,-1),q=["href"],F=s("br",null,null,-1),G=s("br",null,null,-1),J=s("br",null,null,-1),K={id:"auth",href:"",target:"_blank"},ce=B({__name:"AddProvider",props:{domain:{}},setup(C){const w=N(),m=g([]),_=M(11),d=g(!1),c=g(!1),p=C;S(()=>{const e=n.subscribe(T.AUTH_SESSION,t=>{if(t.object_id!==_)return;const o=t.data;c.value=!0,window.setTimeout(()=>{const b=document.getElementById("auth");b.setAttribute("href",o),b.click()},100)});P(e)}),j(()=>p.domain,async e=>{e&&(m.value=await n.getProviderConfigEntries(p.domain,void 0,void 0,{session_id:_}))},{immediate:!0});const A=async function(e){d.value=!0,n.saveProviderConfig(p.domain,e).then(()=>{w.push({name:"providersettings"})}).catch(t=>{alert(t)}).finally(()=>{d.value=!1,c.value=!1})},E=async function(e,t){d.value=!0;for(const o of m.value)o.value!==void 0&&t[o.key]==null&&(t[o.key]=o.value);t.session_id=_,n.getProviderConfigEntries(p.domain,void 0,e,t).then(o=>{m.value=o}).catch(o=>{alert(o)}).finally(()=>{d.value=!1,c.value=!1})};return(e,t)=>(u(),V("section",null,[i(I,null,{default:a(()=>[r(n).providerManifests[e.domain]?(u(),V("div",R,[i(k,null,{default:a(()=>[l(f(e.$t("settings.setup_provider",[r(n).providerManifests[e.domain].name])),1)]),_:1}),i(h,null,{default:a(()=>[l(f(r(n).providerManifests[e.domain].description),1)]),_:1}),Y,r(n).providerManifests[e.domain].codeowners.length?(u(),v(h,{key:0},{default:a(()=>[s("b",null,f(e.$t("settings.codeowners"))+": ",1),l(f(r(n).providerManifests[e.domain].codeowners.join(" / ")),1)]),_:1})):y("",!0),r(n).providerManifests[e.domain].documentation?(u(),v(h,{key:1},{default:a(()=>[s("b",null,f(e.$t("settings.need_help_setup_provider")),1),l("  "),s("a",{href:r(n).providerManifests[e.domain].documentation,target:"_blank"},f(e.$t("settings.check_docs")),9,q)]),_:1})):y("",!0)])):y("",!0),F,i(O),G,J,i($,{"config-entries":m.value,disabled:!1,onSubmit:A,onAction:E},null,8,["config-entries"])]),_:1}),i(L,{modelValue:d.value,"onUpdate:modelValue":t[0]||(t[0]=o=>d.value=o),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:a(()=>[c.value?(u(),v(D,{key:0,style:{"background-color":"white"}},{default:a(()=>[i(k,null,{default:a(()=>[l("Authenticating...")]),_:1}),i(h,null,{default:a(()=>[l("A new tab/popup should be opened where you can authenticate")]),_:1}),i(U,null,{default:a(()=>[s("a",K,[i(z,null,{default:a(()=>[l("Click here if the popup did not open")]),_:1})])]),_:1})]),_:1})):(u(),v(H,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{ce as default};
