import{l as S,I as $,r as g,o as N,O as l,af as T,b as B,w as E,q as i,y,j as r,x as d,A as s,K as p,N as m,v as f,L as u,M as v}from"./index-e9211ef1.js";import{V as I,_ as O}from"./EditConfig.vue_vue_type_style_index_0_lang-29ce80f7.js";import{n as P}from"./index.browser-7e542916.js";import{b as U,V as _,c as x}from"./VCard-138864fc.js";import{V as h}from"./VDivider-336c24cd.js";import{V as A}from"./VSelect-04a129eb.js";import{j as D}from"./VBtn-68784d55.js";import{c as q}from"./VMenu-bc0cce60.js";import"./VExpansionPanel-67038b00.js";import"./VDialog-5f240a62.js";import"./VListItem-230d1393.js";import"./VSpacer-bdf2f653.js";const z={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},F=u("br",null,null,-1),H=["href"],K=u("br",null,null,-1),L=u("br",null,null,-1),R=u("br",null,null,-1),oe=S({__name:"EditProvider",props:{instanceId:{}},setup(k){const w=k,C=$(),e=g(),V=P(11),o=g(!1);N(()=>{const a=l.subscribe(T.AUTH_SESSION,n=>{if(n.object_id!==V)return;const t=n.data;window.open(t,"_blank").focus()});B(a)}),E(()=>w.instanceId,async a=>{a&&(e.value=await l.getProviderConfig(a))},{immediate:!0});const M=async function(a){o.value=!0,a.enabled=e.value.enabled,a.name=e.value.name||null,l.saveProviderConfig(e.value.domain,a,e.value.instance_id).then(()=>{o.value=!1,C.push({name:"providersettings"})}).catch(n=>{alert(n),o.value=!1})},j=async function(a,n){o.value=!0;for(const t of Object.values(e.value.values))t.value!==void 0&&n[t.key]==null&&(n[t.key]=t.value);n.session_id=V,l.getProviderConfigEntries(e.value.domain,e.value.instance_id,a,n).then(t=>{e.value.values={};for(const c of t)e.value.values[c.key]=c;o.value=!1}).catch(t=>{alert(t),o.value=!1})};return(a,n)=>(i(),y("section",null,[r(x,null,{default:d(()=>{var t,c;return[e.value&&s(l).providerManifests[e.value.domain]?(i(),y("div",z,[r(U,null,{default:d(()=>[p(m(a.$t("settings.setup_provider",[s(l).providerManifests[e.value.domain].name])),1)]),_:1}),r(_,null,{default:d(()=>[p(m(s(l).providerManifests[e.value.domain].description),1)]),_:1}),F,s(l).providerManifests[e.value.domain].codeowners.length?(i(),f(_,{key:0},{default:d(()=>[u("b",null,m(a.$t("settings.codeowners"))+": ",1),p(m(s(l).providerManifests[e.value.domain].codeowners.join(" / ")),1)]),_:1})):v("",!0),s(l).providerManifests[e.value.domain].documentation?(i(),f(_,{key:1},{default:d(()=>[u("b",null,m(a.$t("settings.need_help_setup_provider")),1),p("  "),u("a",{href:s(l).providerManifests[e.value.domain].documentation,target:"_blank"},m(a.$t("settings.check_docs")),9,H)]),_:1})):v("",!0),K,r(h),L,R,"name"in e.value?(i(),f(A,{key:2,modelValue:e.value.name,"onUpdate:modelValue":n[0]||(n[0]=b=>e.value.name=b),placeholder:(t=e.value)==null?void 0:t.name,label:a.$t("settings.provider_name"),variant:"outlined",clearable:""},null,8,["modelValue","placeholder","label"])):v("",!0),"enabled"in e.value?(i(),f(I,{key:3,modelValue:e.value.enabled,"onUpdate:modelValue":n[1]||(n[1]=b=>e.value.enabled=b),label:a.$t("settings.enable_provider"),color:"primary",disabled:(c=s(l).providerManifests[e.value.domain])==null?void 0:c.builtin},null,8,["modelValue","label","disabled"])):v("",!0)])):v("",!0),r(h),e.value?(i(),f(O,{key:1,"config-entries":Object.values(e.value.values),disabled:!e.value.enabled,onSubmit:M,onAction:j},null,8,["config-entries","disabled"])):v("",!0)]}),_:1}),r(q,{modelValue:o.value,"onUpdate:modelValue":n[2]||(n[2]=t=>o.value=t),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:d(()=>[r(D,{indeterminate:"",size:"64",color:"primary"})]),_:1},8,["modelValue"])]))}});export{oe as default};
