import{n as w}from"./index.browser-342e672c.js";import{d as M,aj as E,r as _,o as N,b as n,a7 as S,a as j,N as B,c as f,g as h,f as s,w as l,u as r,Y as p,t as d,e as y,i as a,j as v}from"./index-103db515.js";import{E as P}from"./EditConfig-f05929af.js";import{V as T,a as $}from"./VCardText-1a59cac1.js";import{a as g}from"./VCard-d4f085fd.js";import{V as A}from"./VList-cac73f62.js";import{y as U}from"./VListItem-ab7a82e2.js";import{c as D}from"./VMenu-482e7fbc.js";import"./VExpansionPanels-dacf6c3c.js";import"./VCheckboxBtn-19bafbc9.js";import"./VForm-f2e1d3c9.js";import"./VTextField-73438668.js";import"./VVirtualScroll-b23fb9a8.js";import"./VSpacer-adcb10ea.js";/* empty css              */import"./VDialog-08f8879f.js";import"./VAlert-4165d2e6.js";import"./_plugin-vue_export-helper-c27b6911.js";const I={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},O=a("br",null,null,-1),z=["href"],H=a("br",null,null,-1),R=a("br",null,null,-1),Y=a("br",null,null,-1),ae=M({__name:"AddProvider",props:{domain:{}},setup(b){const V=E(),u=_([]),c=w(11),i=_(!1),m=b;N(()=>{const e=n.subscribe(S.AUTH_SESSION,o=>{if(o.object_id!==c)return;const t=o.data;window.open(t,"_blank").focus()});j(e)}),B(()=>m.domain,async e=>{e&&(u.value=await n.getProviderConfigEntries(m.domain,void 0,void 0,{session_id:c}))},{immediate:!0});const k=async function(e){i.value=!0,n.saveProviderConfig(m.domain,e).then(()=>{i.value=!1,V.push({name:"providersettings"})}).catch(o=>{alert(o),i.value=!1})},C=async function(e,o){i.value=!0;for(const t of u.value)t.value!==void 0&&o[t.key]==null&&(o[t.key]=t.value);o.session_id=c,n.getProviderConfigEntries(m.domain,void 0,e,o).then(t=>{u.value=t,i.value=!1}).catch(t=>{alert(t),i.value=!1})};return(e,o)=>(f(),h("section",null,[s($,null,{default:l(()=>[r(n).providerManifests[e.domain]?(f(),h("div",I,[s(T,null,{default:l(()=>[p(d(e.$t("settings.setup_provider",[r(n).providerManifests[e.domain].name])),1)]),_:1}),s(g,null,{default:l(()=>[p(d(r(n).providerManifests[e.domain].description),1)]),_:1}),O,r(n).providerManifests[e.domain].codeowners.length?(f(),y(g,{key:0},{default:l(()=>[a("b",null,d(e.$t("settings.codeowners"))+": ",1),p(d(r(n).providerManifests[e.domain].codeowners.join(" / ")),1)]),_:1})):v("",!0),r(n).providerManifests[e.domain].documentation?(f(),y(g,{key:1},{default:l(()=>[a("b",null,d(e.$t("settings.need_help_setup_provider")),1),p("  "),a("a",{href:r(n).providerManifests[e.domain].documentation,target:"_blank"},d(e.$t("settings.check_docs")),9,z)]),_:1})):v("",!0)])):v("",!0),H,s(A),R,Y,s(P,{"config-entries":u.value,disabled:!1,onSubmit:k,onAction:C},null,8,["config-entries"])]),_:1}),s(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:l(()=>[s(U,{indeterminate:"",size:"64",color:"primary"})]),_:1},8,["modelValue"])]))}});export{ae as default};
