import{n as $}from"./index.browser-OxPLOBIU.js";import{u as I}from"./vue-router-D-D-f2lE.js";import{f as s,E as N,a0 as b,_ as P}from"./index-DkCrJWiT.js";import{E as S}from"./EditConfig-o1R25eFw.js";import{_ as x}from"./ProviderIcon.vue_vue_type_style_index_0_lang-hy1bGinH.js";import{a as w,p as L,F as j,T as D,m as U,k as z,Z as O}from"./vuetify-DEtiqX2e.js";import{d as F,o as R,r as _,a0 as Z,w as q,b as h,I as y,H as a,u as n,E as d,f as u,a1 as M,D as C,$ as k,e as c}from"./lucide-CCrbsyJI.js";import{u as V}from"./vue-i18n-krBRuO6q.js";import"./color-CcshWhNz.js";import"./qrcode-CCHMWIXh.js";import"./marked-i_gIkIP3.js";import"./vueuse-FEBxOGD_.js";/* empty css            */import"./swiper-YiD1SI-4.js";import"./index-DrRcO7PK.js";import"./reka-ui-CrWUNNju.js";import"./index-BBA2x4Zu.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"},Y={class:"header-description"},ee=["innerHTML"],te=["innerHTML"],oe={id:"auth",href:"",target:"_blank"},se=F({__name:"AddProviderDetails",props:{domain:{}},setup(i){const A=I(),m=_([]),v=$(11),l=_(!1),f=_(!1),p=i;R(()=>{const o=s.subscribe(N.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)});Z(o)}),q(()=>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",G,[n(s).providerManifests[i.domain]?(c(),h("div",J,[a(w,{class:"header-card mb-4",elevation:"0"},{default:d(()=>[u("div",K,[u("div",Q,[a(x,{domain:i.domain,size:48},null,8,["domain"])]),u("div",W,[u("h2",X,M(o.$t("settings.setup_provider",[n(s).providerManifests[i.domain].name])),1),u("p",Y,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(S,{"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(j,null,{default:d(()=>[...e[2]||(e[2]=[k("A new tab/popup should be opened where you can authenticate",-1)])]),_:1}),a(D,null,{default:d(()=>[u("a",oe,[a(U,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=P(se,[["__scopeId","data-v-0a2b0962"]]);export{be as default};
