import{y as $,ac as B,r as y,o as E,N as o,ap as N,b as T,w as j,A as s,H as V,q as r,D as d,z as i,S as f,Q as m,B as p,E as u,K as v}from"./index-9b822783.js";import{V as P,_ as U}from"./EditConfig.vue_vue_type_style_index_0_lang-b73c51be.js";import{n as x}from"./index.browser-342e672c.js";import{a as I,V as O}from"./VCardText-bc96863a.js";import{a as _}from"./VCard-0d72f9dd.js";import{k as h,x as A}from"./forwardRefs-af0663a3.js";import{V as D}from"./VTextField-7d804c49.js";import{f as z}from"./VMenu-8029677e.js";import"./VExpansionPanel-721f23c7.js";import"./VInput-c159036c.js";import"./VSlideGroup-d3ac8eca.js";import"./VForm-79d9662c.js";/* empty css              */import"./VDialog-a6f484ad.js";import"./VAlert-fddf489c.js";import"./VSelect-c39cc514.js";import"./VVirtualScroll-a3d1c1c9.js";const H={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},q=u("br",null,null,-1),F=["href"],K=u("br",null,null,-1),Q=u("br",null,null,-1),R=u("br",null,null,-1),de=$({__name:"EditProvider",props:{instanceId:{}},setup(k){const w=B(),e=y(),g=x(11),l=y(!1),C=k;E(()=>{const a=o.subscribe(N.AUTH_SESSION,t=>{if(t.object_id!==g)return;const n=t.data;window.open(n,"_blank").focus()});T(a)}),j(()=>C.instanceId,async a=>{a&&(e.value=await o.getProviderConfig(a))},{immediate:!0});const M=async function(a){l.value=!0,a.enabled=e.value.enabled,a.name=e.value.name||null,o.saveProviderConfig(e.value.domain,a,e.value.instance_id).then(()=>{l.value=!1,w.push({name:"providersettings"})}).catch(t=>{alert(t),l.value=!1})},S=async function(a,t){l.value=!0;for(const n of Object.values(e.value.values))n.value!==void 0&&t[n.key]==null&&(t[n.key]=n.value);t.session_id=g,o.getProviderConfigEntries(e.value.domain,e.value.instance_id,a,t).then(n=>{e.value.values={};for(const c of n)e.value.values[c.key]=c;l.value=!1}).catch(n=>{alert(n),l.value=!1})};return(a,t)=>(s(),V("section",null,[r(O,null,{default:d(()=>{var n,c;return[e.value&&i(o).providerManifests[e.value.domain]?(s(),V("div",H,[r(I,null,{default:d(()=>[f(m(a.$t("settings.setup_provider",[i(o).providerManifests[e.value.domain].name])),1)]),_:1}),r(_,null,{default:d(()=>[f(m(i(o).providerManifests[e.value.domain].description),1)]),_:1}),q,i(o).providerManifests[e.value.domain].codeowners.length?(s(),p(_,{key:0},{default:d(()=>[u("b",null,m(a.$t("settings.codeowners"))+": ",1),f(m(i(o).providerManifests[e.value.domain].codeowners.join(" / ")),1)]),_:1})):v("",!0),i(o).providerManifests[e.value.domain].documentation?(s(),p(_,{key:1},{default:d(()=>[u("b",null,m(a.$t("settings.need_help_setup_provider")),1),f("  "),u("a",{href:i(o).providerManifests[e.value.domain].documentation,target:"_blank"},m(a.$t("settings.check_docs")),9,F)]),_:1})):v("",!0),K,r(h),Q,R,"name"in e.value?(s(),p(D,{key:2,modelValue:e.value.name,"onUpdate:modelValue":t[0]||(t[0]=b=>e.value.name=b),placeholder:(n=e.value)==null?void 0:n.name,label:a.$t("settings.provider_name"),variant:"outlined",clearable:""},null,8,["modelValue","placeholder","label"])):v("",!0),"enabled"in e.value?(s(),p(P,{key:3,modelValue:e.value.enabled,"onUpdate:modelValue":t[1]||(t[1]=b=>e.value.enabled=b),label:a.$t("settings.enable_provider"),color:"primary",disabled:(c=i(o).providerManifests[e.value.domain])==null?void 0:c.builtin},null,8,["modelValue","label","disabled"])):v("",!0)])):v("",!0),r(h),e.value?(s(),p(U,{key:1,"config-entries":Object.values(e.value.values),disabled:!e.value.enabled,onSubmit:M,onAction:S},null,8,["config-entries","disabled"])):v("",!0)]}),_:1}),r(z,{modelValue:l.value,"onUpdate:modelValue":t[2]||(t[2]=n=>l.value=n),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:d(()=>[r(A,{indeterminate:"",size:"64",color:"primary"})]),_:1},8,["modelValue"])]))}});export{de as default};
