import{n as w}from"./index.browser-342e672c.js";import{d as M,a1 as S,r as g,o as B,b as n,ah as E,a as N,I as P,c as f,h,f as s,w as l,u as a,m as c,t as d,e as y,g as r,j as v}from"./index-0ae84607.js";import{_ as T}from"./EditConfig.vue_vue_type_style_index_0_lang-991e1055.js";import{a as $,V as j}from"./VCardText-b1a0de89.js";import{a as _}from"./VCard-e96ab32b.js";import{a as A,t as I}from"./forwardRefs-d0d7c5bd.js";import{e as U}from"./VMenu-f26d3a19.js";import"./VExpansionPanel-4cf67b18.js";import"./VInput-00e20677.js";import"./VSlideGroup-18f8a11f.js";import"./VForm-272c3dd0.js";/* empty css              */import"./VDialog-2b5eada8.js";import"./VAlert-212471f5.js";import"./VTextField-4bf39c0d.js";import"./VSelect-2b6c5c22.js";import"./VVirtualScroll-06bbaaf5.js";const D={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},O=r("br",null,null,-1),z=["href"],H=r("br",null,null,-1),R=r("br",null,null,-1),q=r("br",null,null,-1),ae=M({__name:"AddProvider",props:{domain:{}},setup(b){const V=S(),u=g([]),p=w(11),i=g(!1),m=b;B(()=>{const e=n.subscribe(E.AUTH_SESSION,o=>{if(o.object_id!==p)return;const t=o.data;window.open(t,"_blank").focus()});N(e)}),P(()=>m.domain,async e=>{e&&(u.value=await n.getProviderConfigEntries(m.domain,void 0,void 0,{session_id:p}))},{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=p,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(j,null,{default:l(()=>[a(n).providerManifests[e.domain]?(f(),h("div",D,[s($,null,{default:l(()=>[c(d(e.$t("settings.setup_provider",[a(n).providerManifests[e.domain].name])),1)]),_:1}),s(_,null,{default:l(()=>[c(d(a(n).providerManifests[e.domain].description),1)]),_:1}),O,a(n).providerManifests[e.domain].codeowners.length?(f(),y(_,{key:0},{default:l(()=>[r("b",null,d(e.$t("settings.codeowners"))+": ",1),c(d(a(n).providerManifests[e.domain].codeowners.join(" / ")),1)]),_:1})):v("",!0),a(n).providerManifests[e.domain].documentation?(f(),y(_,{key:1},{default:l(()=>[r("b",null,d(e.$t("settings.need_help_setup_provider")),1),c("  "),r("a",{href:a(n).providerManifests[e.domain].documentation,target:"_blank"},d(e.$t("settings.check_docs")),9,z)]),_:1})):v("",!0)])):v("",!0),H,s(A),R,q,s(T,{"config-entries":u.value,disabled:!1,onSubmit:k,onAction:C},null,8,["config-entries"])]),_:1}),s(U,{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(I,{indeterminate:"",size:"64",color:"primary"})]),_:1},8,["modelValue"])]))}});export{ae as default};
