import{n as I}from"./index.browser-OxPLOBIU.js";import{u as N}from"./vue-router-CDtPtBGv.js";import{c as o,E as P,d as S,K as b,_ as $}from"./index-HFEfURXv.js";import{E as x}from"./EditConfig-CBn2I0FC.js";import{a as w,s as L,F as j,_ as D,q as U,o as z,M as O}from"./vuetify-ffr1lJCG.js";import{d as q,r as _,o as F,a1 as K,w as R,b as h,e as u,I as y,H as a,B as i,E as d,f as c,_ as M,D as C,Z as k}from"./lucide-sS6c3snl.js";import{u as V}from"./vue-i18n-h4EBIvPF.js";import"./qrcode-Dq-byqKu.js";import"./marked-C0Rlrcoy.js";import"./color-BTziYnFN.js";import"./vueuse-B-HgI0gk.js";/* empty css            */import"./swiper-BtP4dEja.js";import"./index-Bhz7YNgq.js";import"./reka-ui-BdNfr-WI.js";const Z={class:"add-provider-details"},G={key:0},J={class:"header-content"},Q={class:"header-icon"},W={class:"header-info"},X={class:"header-title"},Y={class:"header-description"},ee=["innerHTML"],te=["innerHTML"],se={id:"auth",href:"",target:"_blank"},oe=q({__name:"AddProviderDetails",props:{domain:{}},setup(n){const A=N(),m=_([]),v=I(11),l=_(!1),f=_(!1),p=n;F(()=>{const s=o.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(s)}),R(()=>p.domain,async s=>{s&&(m.value=await o.getProviderConfigEntries(p.domain,void 0,void 0,{session_id:v}))},{immediate:!0});const E=async function(s){l.value=!0,o.saveProviderConfig(p.domain,s).then(()=>{A.push({name:"providersettings"})}).catch(e=>{alert(e)}).finally(()=>{l.value=!1,f.value=!1})},T=async function(s,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,o.getProviderConfigEntries(p.domain,void 0,s,e).then(t=>{m.value=t}).catch(t=>{alert(t)}).finally(()=>{l.value=!1,f.value=!1})},B=function(s){const e=[],{t}=V();for(const r of s)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(s){const{t:e}=V();return`**${e("settings.provider_credits")}**: `+s.join(" / ")};return(s,e)=>(u(),h("section",Z,[i(o).providerManifests[n.domain]?(u(),h("div",G,[a(w,{class:"header-card mb-4",elevation:"0"},{default:d(()=>[c("div",J,[c("div",Q,[a(S,{domain:n.domain,size:48},null,8,["domain"])]),c("div",W,[c("h2",X,M(s.$t("settings.setup_provider",[i(o).providerManifests[n.domain].name])),1),c("p",Y,M(i(o).providerManifests[n.domain].description),1),i(o).providerManifests[n.domain].codeowners.length?(u(),h("div",{key:0,class:"header-authors",innerHTML:i(b)(B(i(o).providerManifests[n.domain].codeowners))},null,8,ee)):y("",!0),i(o).providerManifests[n.domain].credits.length?(u(),h("div",{key:1,class:"header-authors",innerHTML:i(b)(H(i(o).providerManifests[n.domain].credits))},null,8,te)):y("",!0)])])]),_:1})])):y("",!0),a(x,{"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(),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(()=>[c("a",se,[a(U,null,{default:d(()=>[...e[3]||(e[3]=[k("Click here if the popup did not open",-1)])]),_:1})])]),_:1})]),_:1})):(u(),C(z,{key:1,indeterminate:"",size:"64",color:"primary"}))]),_:1},8,["modelValue"])]))}}),ye=$(oe,[["__scopeId","data-v-0a2b0962"]]);export{ye as default};
