import{l as $,a8 as j,r as g,o as B,J as l,ai as T,b as E,w as N,v as i,B as y,j as r,y as d,q as s,O as p,K as m,x as f,z as u,G as v}from"./index-e5db0b73.js";import{V as O,_ as P}from"./EditConfig.vue_vue_type_style_index_0_lang-0800e29c.js";import{n as U}from"./index.browser-7e542916.js";import{c as x,b as _,V as I}from"./VCard-c9b9f4e9.js";import{V as h,w as z}from"./VImg-7a057c50.js";import{V as A}from"./VTextField-46667b30.js";import{f as D}from"./VMenu-d9833a31.js";import"./VExpansionPanel-671eca9e.js";import"./VCheckboxBtn-46446b67.js";import"./VVirtualScroll-01555b84.js";import"./VDialog-cda0f95b.js";const q={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},F=u("br",null,null,-1),G=["href"],H=u("br",null,null,-1),J=u("br",null,null,-1),K=u("br",null,null,-1),le=$({__name:"EditProvider",props:{instanceId:{}},setup(k){const w=k,C=j(),e=g(),V=U(11),o=g(!1);B(()=>{const a=l.subscribe(T.AUTH_SESSION,n=>{if(n.object_id!==V)return;const t=n.data;window.open(t,"_blank").focus()});E(a)}),N(()=>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})},S=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(I,null,{default:d(()=>{var t,c;return[e.value&&s(l).providerManifests[e.value.domain]?(i(),y("div",q,[r(x,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,G)]),_:1})):v("",!0),H,r(h),J,K,"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(O,{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(P,{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(D,{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(z,{indeterminate:"",size:"64",color:"primary"})]),_:1},8,["modelValue"])]))}});export{le as default};
