import{d as M,an as N,r as h,o as P,b as o,a7 as T,a as B,N as O,c as i,g as b,f as u,w as m,u as l,Y as _,t as v,e as f,i as d,j as p}from"./index-af8b7753.js";import{V as j,E as A}from"./EditConfig-bd97c6a7.js";import{n as U}from"./index.browser-342e672c.js";import{V as $,a as R}from"./VCardText-b2843211.js";import{a as g}from"./VCard-4405819f.js";import{V as k}from"./VList-92308f1a.js";import{V as D}from"./VTextField-be93763f.js";import{s as F,y as H}from"./VListItem-0186c915.js";import{c as x}from"./VMenu-cf6ae0bc.js";import"./VExpansionPanels-33f19bd0.js";import"./VCheckboxBtn-77b0c8cb.js";import"./VForm-c2b8a6db.js";import"./VVirtualScroll-4c0c507a.js";import"./VSpacer-a83ddbc5.js";/* empty css              */import"./VDialog-0dc5f298.js";import"./VAlert-e27964fd.js";import"./_plugin-vue_export-helper-c27b6911.js";const z={key:0},K=d("br",null,null,-1),L=["href"],Y=d("br",null,null,-1),q=d("br",null,null,-1),G=d("br",null,null,-1),J={key:0},Q={id:"auth",href:"",target:"_blank"},pe=M({__name:"EditProvider",props:{instanceId:{}},setup(C){const w=N(),e=h(),y=U(11),s=h(!1),V=/iP(ad|hone|od).*Version\/[\d.]+.*Safari/i.test(navigator.userAgent),E=C;P(()=>{const a=o.subscribe(T.AUTH_SESSION,t=>{if(t.object_id!==y)return;const n=t.data;if(V){const r=document.getElementById("auth");r.setAttribute("href",n),r.click()}else window.open(n,"_blank").focus()});B(a)}),O(()=>E.instanceId,async a=>{a&&(e.value=await o.getProviderConfig(a))},{immediate:!0});const S=async function(a){s.value=!0,a.enabled=e.value.enabled,a.name=e.value.name||null,o.saveProviderConfig(e.value.domain,a,e.value.instance_id).then(()=>{s.value=!1,w.push({name:"providersettings"})}).catch(t=>{alert(t),s.value=!1})},I=async function(a,t){s.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=y,o.getProviderConfigEntries(e.value.domain,e.value.instance_id,a,t).then(n=>{e.value.values={};for(const r of n)e.value.values[r.key]=r;s.value=!1}).catch(n=>{alert(n),s.value=!1})};return(a,t)=>(i(),b("section",null,[u(R,null,{default:m(()=>{var n,r;return[e.value&&l(o).providerManifests[e.value.domain]?(i(),b("div",z,[u($,null,{default:m(()=>{var c;return[_(v(a.$t("settings.setup_provider",[e.value.name||((c=l(o).getProvider(e.value.instance_id))==null?void 0:c.name)])),1)]}),_:1}),u(g,{style:{"white-space":"normal"}},{default:m(()=>[_(v(l(o).providerManifests[e.value.domain].description),1)]),_:1}),K,l(o).providerManifests[e.value.domain].codeowners.length?(i(),f(g,{key:0},{default:m(()=>[d("b",null,v(a.$t("settings.codeowners"))+": ",1),_(v(l(o).providerManifests[e.value.domain].codeowners.join(" / ")),1)]),_:1})):p("",!0),l(o).providerManifests[e.value.domain].documentation?(i(),f(g,{key:1},{default:m(()=>[d("b",null,v(a.$t("settings.need_help_setup_provider")),1),_("  "),d("a",{href:l(o).providerManifests[e.value.domain].documentation,target:"_blank"},v(a.$t("settings.check_docs")),9,L)]),_:1})):p("",!0),Y,u(k),q,G,"name"in e.value?(i(),f(D,{key:2,modelValue:e.value.name,"onUpdate:modelValue":t[0]||(t[0]=c=>e.value.name=c),placeholder:(n=l(o).getProvider(e.value.instance_id))==null?void 0:n.name,label:a.$t("settings.provider_name"),variant:"outlined",clearable:""},null,8,["modelValue","placeholder","label"])):p("",!0),"enabled"in e.value?(i(),f(j,{key:3,modelValue:e.value.enabled,"onUpdate:modelValue":t[1]||(t[1]=c=>e.value.enabled=c),label:a.$t("settings.enable_provider"),color:"primary",disabled:!((r=l(o).providerManifests[e.value.domain])!=null&&r.allow_disable)},null,8,["modelValue","label","disabled"])):p("",!0)])):p("",!0),u(k),e.value?(i(),f(A,{key:1,"config-entries":Object.values(e.value.values),disabled:!e.value.enabled,onSubmit:S,onAction:I},null,8,["config-entries","disabled"])):p("",!0)]}),_:1}),u(x,{modelValue:s.value,"onUpdate:modelValue":t[2]||(t[2]=n=>s.value=n),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:m(()=>[l(V)?(i(),b("div",J,[d("a",Q,[u(F,null,{default:m(()=>[_("CLICK HERE TO CONTINUE...")]),_:1})])])):(i(),f(H,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{pe as default};
