import{U as B,x as g,o as I,a6 as l,aY as S,b as N,w as P,a0 as k,X as u,F as s,Y as r,bG as U,bi as _,ab as v,W as d,a2 as o,E as m,b1 as w,as as f,ad as c,b2 as y,bC as j,cc as H,$ as C,bA as L,a9 as O,bt as x,bH as D}from"./index-B-lUZalq.js";import{E as F}from"./EditConfig-CH-Rsyh7.js";import{n as Y}from"./index.browser-OxPLOBIU.js";import{V as z}from"./VTextField-B-d5Pe9I.js";import{V as G}from"./VSwitch-Bhk7qcAi.js";import{a as R,b as W}from"./VBtn-BPJ1JKW-.js";import"./VForm-C-dO2GIE.js";import"./VInput-BWBQqjuk.js";import"./VExpansionPanels-CR_eBB13.js";import"./VAlert-QHTIcuEJ.js";import"./VSlider-BCIrn4it.js";import"./VVirtualScroll-CceW16X7.js";import"./VDialog-CAgq0L03.js";import"./VSpacer-DDLrofv-.js";/* empty css              */import"./_plugin-vue_export-helper-DlAUqK2U.js";const X={key:0},q={id:"auth",href:"",target:"_blank"},pe=B({__name:"EditProvider",props:{instanceId:{}},setup(h){const M=D(),a=g(),V=Y(11),p=g(!1),b=g(!1),T=h;I(()=>{const n=l.subscribe(S.AUTH_SESSION,e=>{if(e.object_id!==V)return;const t=e.data;b.value=!0,window.setTimeout(()=>{const i=document.getElementById("auth");i.setAttribute("href",t),i.click()},100)});N(n)}),P(()=>T.instanceId,async n=>{n&&(a.value=await l.getProviderConfig(n))},{immediate:!0});const A=async function(n){p.value=!0,n.enabled=a.value.enabled,n.name=a.value.name||null,l.saveProviderConfig(a.value.domain,n,a.value.instance_id).then(()=>{M.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{p.value=!1,b.value=!1})},$=async function(n,e){p.value=!0;for(const t of Object.values(a.value.values))t.value!==void 0&&e[t.key]==null&&(e[t.key]=t.value);e.session_id=V,l.getProviderConfigEntries(a.value.domain,a.value.instance_id,n,e).then(t=>{a.value.values={};for(const i of t)a.value.values[i.key]=i}).catch(t=>{alert(t)}).finally(()=>{p.value=!1,b.value=!1})},E=function(n){const e=[],{t}=x();for(const i of n)i.includes("@")?e.push(`[${i.replace("@","")}](https://github.com/${i.replace("@","")})`):e.push(i);return`**${t("settings.codeowners")}**: `+e.join(" / ")};return(n,e)=>(u(),k("section",null,[s(U,null,{default:r(()=>[a.value&&o(l).providerManifests[a.value.domain]?(u(),k("div",X,[s(w,null,{default:r(()=>[f(c(n.$t("settings.setup_provider",[o(l).providerManifests[a.value.domain].name])),1)]),_:1}),s(y,{style:{"white-space":"normal"}},{default:r(()=>[f(c(o(l).providerManifests[a.value.domain].description),1)]),_:1}),e[5]||(e[5]=m("br",null,null,-1)),o(l).providerManifests[a.value.domain].codeowners.length?(u(),d(y,{key:0,innerHTML:o(j)(E(o(l).providerManifests[a.value.domain].codeowners))},null,8,["innerHTML"])):v("",!0),o(l).providerManifests[a.value.domain].documentation?(u(),d(y,{key:1},{default:r(()=>[m("b",null,c(n.$t("settings.need_help_setup_provider")),1),e[4]||(e[4]=f("  ",-1)),m("a",{onClick:e[0]||(e[0]=t=>o(H)(o(l).providerManifests[a.value.domain].documentation))},c(n.$t("settings.check_docs")),1)]),_:1})):v("",!0),e[6]||(e[6]=m("br",null,null,-1)),s(C),e[7]||(e[7]=m("br",null,null,-1)),e[8]||(e[8]=m("br",null,null,-1)),"name"in a.value?(u(),d(z,{key:2,modelValue:a.value.name,"onUpdate:modelValue":e[1]||(e[1]=t=>a.value.name=t),placeholder:o(l).getProvider(a.value.instance_id)?.name,label:n.$t("settings.provider_name"),variant:"outlined",clearable:""},null,8,["modelValue","placeholder","label"])):v("",!0),"enabled"in a.value?(u(),d(G,{key:3,modelValue:a.value.enabled,"onUpdate:modelValue":e[2]||(e[2]=t=>a.value.enabled=t),label:n.$t("settings.enable_provider"),color:"primary",disabled:!o(l).providerManifests[a.value.domain]?.allow_disable},null,8,["modelValue","label","disabled"])):v("",!0)])):v("",!0),s(C),a.value?(u(),d(F,{key:1,"config-entries":Object.values(a.value.values),disabled:!a.value.enabled,onSubmit:A,onAction:$},null,8,["config-entries","disabled"])):v("",!0)]),_:1}),s(_,{modelValue:p.value,"onUpdate:modelValue":e[3]||(e[3]=t=>p.value=t),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:r(()=>[b.value?(u(),d(O,{key:0,style:{"background-color":"white"}},{default:r(()=>[s(w,null,{default:r(()=>[...e[9]||(e[9]=[f("Authenticating...",-1)])]),_:1}),s(y,null,{default:r(()=>[...e[10]||(e[10]=[f("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),s(L,null,{default:r(()=>[m("a",q,[s(R,null,{default:r(()=>[...e[11]||(e[11]=[f("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(u(),d(W,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}});export{pe as default};
