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