import{n as $}from"./index.browser-OxPLOBIU.js";import{u as I}from"./vue-router-BgJK_hRC.js";import{c as s,E as L,C as b,_ as N}from"./index-CxiRlsCY.js";import{E as P}from"./EditConfig-CHstsLqU.js";import{_ as S}from"./ProviderIcon.vue_vue_type_style_index_0_lang-C17dV9_V.js";import{a as w,q as x,D,Y as j,n as U,l as z,L as O}from"./vuetify-RelkxOq-.js";import{d as q,r as _,o as R,a0 as Y,w as F,b as h,e as u,I as y,H as a,u as n,E as d,f as c,a1 as C,D as M,$ as k}from"./lucide-C2DU1LFb.js";import{u as V}from"./vue-i18n-DySrp6mW.js";import"./qrcode-DSFhiIp2.js";import"./marked-C0Rlrcoy.js";import"./color-BTziYnFN.js";import"./vueuse-DIaEWNCo.js";/* empty css            */import"./swiper-Jy9GbtzK.js";import"./index-DV1JBmju.js";import"./utils-CDN07tui.js";import"./reka-ui-GpbaI08z.js";import"./index-B_jtOnfb.js";const G={class:"add-provider-details"},J={key:0},K={class:"header-content"},Q={class:"header-icon"},W={class:"header-info"},X={class:"header-title"},Z={class:"header-description"},ee=["innerHTML"],te=["innerHTML"],oe={id:"auth",href:"",target:"_blank"},se=q({__name:"AddProviderDetails",props:{domain:{}},setup(i){const A=I(),m=_([]),v=$(11),l=_(!1),f=_(!1),p=i;R(()=>{const o=s.subscribe(L.AUTH_SESSION,e=>{if(e.object_id!==v)return;const t=e.data;f.value=!0,window.setTimeout(()=>{const r=document.getElementById("auth");r.setAttribute("href",t),r.click()},100)});Y(o)}),F(()=>p.domain,async o=>{o&&(m.value=await s.getProviderConfigEntries(p.domain,void 0,void 0,{session_id:v}))},{immediate:!0});const E=async function(o){l.value=!0,s.saveProviderConfig(p.domain,o).then(()=>{A.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{l.value=!1,f.value=!1})},T=async function(o,e){l.value=!0;for(const t of m.value)t.value!==void 0&&e[t.key]==null&&(e[t.key]=t.value);e.session_id=v,s.getProviderConfigEntries(p.domain,void 0,o,e).then(t=>{m.value=t}).catch(t=>{alert(t)}).finally(()=>{l.value=!1,f.value=!1})},B=function(o){const e=[],{t}=V();for(const r of o)if(r.includes("@")){let g=r.replace("@","");g=="music-assistant"&&(g="the Music Assistant team"),e.push(`[${g}](https://github.com/${r.replace("@","")})`)}else e.push(r);return`**${t("settings.provider_codeowners")}**: `+e.join(" / ")},H=function(o){const{t:e}=V();return`**${e("settings.provider_credits")}**: `+o.join(" / ")};return(o,e)=>(u(),h("section",G,[n(s).providerManifests[i.domain]?(u(),h("div",J,[a(w,{class:"header-card mb-4",elevation:"0"},{default:d(()=>[c("div",K,[c("div",Q,[a(S,{domain:i.domain,size:48},null,8,["domain"])]),c("div",W,[c("h2",X,C(o.$t("settings.setup_provider",[n(s).providerManifests[i.domain].name])),1),c("p",Z,C(n(s).providerManifests[i.domain].description),1),n(s).providerManifests[i.domain].codeowners.length?(u(),h("div",{key:0,class:"header-authors",innerHTML:n(b)(B(n(s).providerManifests[i.domain].codeowners))},null,8,ee)):y("",!0),n(s).providerManifests[i.domain].credits.length?(u(),h("div",{key:1,class:"header-authors",innerHTML:n(b)(H(n(s).providerManifests[i.domain].credits))},null,8,te)):y("",!0)])])]),_:1})])):y("",!0),a(P,{"config-entries":m.value,disabled:!1,onSubmit:E,onAction:T},null,8,["config-entries"]),a(O,{modelValue:l.value,"onUpdate:modelValue":e[0]||(e[0]=t=>l.value=t),scrim:"true",persistent:"",style:{display:"flex","align-items":"center","justify-content":"center"}},{default:d(()=>[f.value?(u(),M(w,{key:0,style:{"background-color":"white"}},{default:d(()=>[a(x,null,{default:d(()=>[...e[1]||(e[1]=[k("Authenticating...",-1)])]),_:1}),a(D,null,{default:d(()=>[...e[2]||(e[2]=[k("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),a(j,null,{default:d(()=>[c("a",oe,[a(U,null,{default:d(()=>[...e[3]||(e[3]=[k("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(u(),M(z,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}}),we=N(se,[["__scopeId","data-v-0a2b0962"]]);export{we as default};
