import{n as w}from"./index.browser-342e672c.js";import{d as I,an as M,r as V,o as N,b as n,a7 as A,a as B,N as T,c as l,g as v,f as r,w as d,u as s,Y as m,t as u,e as _,i as a,j as g}from"./index-af8b7753.js";import{E as P}from"./EditConfig-bd97c6a7.js";import{V as O,a as j}from"./VCardText-b2843211.js";import{a as h}from"./VCard-4405819f.js";import{V as U}from"./VList-92308f1a.js";import{s as $,y as R}from"./VListItem-0186c915.js";import{c as D}from"./VMenu-cf6ae0bc.js";import"./VExpansionPanels-33f19bd0.js";import"./VCheckboxBtn-77b0c8cb.js";import"./VForm-c2b8a6db.js";import"./VTextField-be93763f.js";import"./VVirtualScroll-4c0c507a.js";import"./VSpacer-a83ddbc5.js";/* empty css              */import"./VDialog-0dc5f298.js";import"./VAlert-e27964fd.js";import"./_plugin-vue_export-helper-c27b6911.js";const H={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},z=a("br",null,null,-1),F=["href"],K=a("br",null,null,-1),L=a("br",null,null,-1),Y=a("br",null,null,-1),q={key:0},G={id:"auth",href:"",target:"_blank"},fe=I({__name:"AddProvider",props:{domain:{}},setup(k){const C=M(),f=V([]),p=w(11),i=V(!1),y=/iP(ad|hone|od).*Version\/[\d.]+.*Safari/i.test(navigator.userAgent),c=k;N(()=>{const e=n.subscribe(A.AUTH_SESSION,o=>{if(o.object_id!==p)return;const t=o.data;if(y){const b=document.getElementById("auth");b.setAttribute("href",t),b.click()}else window.open(t,"_blank").focus()});B(e)}),T(()=>c.domain,async e=>{e&&(f.value=await n.getProviderConfigEntries(c.domain,void 0,void 0,{session_id:p}))},{immediate:!0});const E=async function(e){i.value=!0,n.saveProviderConfig(c.domain,e).then(()=>{i.value=!1,C.push({name:"providersettings"})}).catch(o=>{alert(o),i.value=!1})},S=async function(e,o){i.value=!0;for(const t of f.value)t.value!==void 0&&o[t.key]==null&&(o[t.key]=t.value);o.session_id=p,n.getProviderConfigEntries(c.domain,void 0,e,o).then(t=>{f.value=t,i.value=!1}).catch(t=>{alert(t),i.value=!1})};return(e,o)=>(l(),v("section",null,[r(j,null,{default:d(()=>[s(n).providerManifests[e.domain]?(l(),v("div",H,[r(O,null,{default:d(()=>[m(u(e.$t("settings.setup_provider",[s(n).providerManifests[e.domain].name])),1)]),_:1}),r(h,null,{default:d(()=>[m(u(s(n).providerManifests[e.domain].description),1)]),_:1}),z,s(n).providerManifests[e.domain].codeowners.length?(l(),_(h,{key:0},{default:d(()=>[a("b",null,u(e.$t("settings.codeowners"))+": ",1),m(u(s(n).providerManifests[e.domain].codeowners.join(" / ")),1)]),_:1})):g("",!0),s(n).providerManifests[e.domain].documentation?(l(),_(h,{key:1},{default:d(()=>[a("b",null,u(e.$t("settings.need_help_setup_provider")),1),m("  "),a("a",{href:s(n).providerManifests[e.domain].documentation,target:"_blank"},u(e.$t("settings.check_docs")),9,F)]),_:1})):g("",!0)])):g("",!0),K,r(U),L,Y,r(P,{"config-entries":f.value,disabled:!1,onSubmit:E,onAction:S},null,8,["config-entries"])]),_:1}),r(D,{modelValue:i.value,"onUpdate:modelValue":o[0]||(o[0]=t=>i.value=t),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:d(()=>[s(y)?(l(),v("div",q,[a("a",G,[r($,null,{default:d(()=>[m("CLICK HERE TO CONTINUE...")]),_:1})])])):(l(),_(R,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{fe as default};
