import{n as I}from"./index.browser-OxPLOBIU.js";import{u as N}from"./vue-router-DNlH4vva.js";import{a as s,E as P,U as b,_ as S}from"./index-CKxLfxpS.js";import{E as $}from"./EditConfig-BHMP16MS.js";import{_ as x}from"./ProviderIcon.vue_vue_type_style_index_0_lang-DYXAnx83.js";import{a as w,p as L,I as U,U as j,m as D,k as z,a0 as O}from"./vuetify-C0IIhwYL.js";import{d as G,o as J,r as _,a3 as K,w as R,b as h,K as y,J as a,u as n,H as d,f as u,a4 as M,G as C,a2 as k,e as c}from"./lucide-UY9XeFdQ.js";import{u as V}from"./vue-i18n-DwYfJ_fn.js";import"./color-CcshWhNz.js";import"./qrcode-CJNXjF_3.js";import"./marked-D9eDbhZJ.js";import"./vueuse-Dj-fx4H6.js";/* empty css            */import"./swiper-DNx4mJDO.js";import"./index-CicoQvUc.js";import"./reka-ui-D1_Wa3oe.js";import"./index-Cp8C9wsI.js";const q={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=G({__name:"AddProviderDetails",props:{domain:{}},setup(i){const A=N(),m=_([]),v=I(11),l=_(!1),f=_(!1),p=i;J(()=>{const o=s.subscribe(P.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)});K(o)}),R(()=>p.domain,async o=>{o&&(m.value=await s.getProviderConfigEntries(p.domain,void 0,void 0,{session_id:v}))},{immediate:!0});const T=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})},E=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)=>(c(),h("section",q,[n(s).providerManifests[i.domain]?(c(),h("div",F,[a(w,{class:"header-card mb-4",elevation:"0"},{default:d(()=>[u("div",Q,[u("div",W,[a(x,{domain:i.domain,size:48},null,8,["domain"])]),u("div",X,[u("h2",Y,M(o.$t("settings.setup_provider",[n(s).providerManifests[i.domain].name])),1),u("p",Z,M(n(s).providerManifests[i.domain].description),1),n(s).providerManifests[i.domain].codeowners.length?(c(),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?(c(),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($,{"config-entries":m.value,disabled:!1,onSubmit:T,onAction:E},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?(c(),C(w,{key:0,style:{"background-color":"white"}},{default:d(()=>[a(L,null,{default:d(()=>[...e[1]||(e[1]=[k("Authenticating...",-1)])]),_:1}),a(U,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(()=>[u("a",oe,[a(D,null,{default:d(()=>[...e[3]||(e[3]=[k("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(c(),C(z,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}}),be=S(se,[["__scopeId","data-v-0a2b0962"]]);export{be as default};
