import{ay as B,J as c,aP as t,bb as L,a4 as M,i as N,br as g,cH as _,b2 as V,L as w,az as P,aA as s,o as p,aG as d,aB as u,E as o,aI as y,aD as r,bg as A,bh as v,aN as i,bi as f,cB as G,aU as D,bH as O,c3 as R,aE as q}from"./index-BRUnowC8.js";import{E as F}from"./EditConfig-DaKyuWVG.js";import{n as j}from"./index.browser-OxPLOBIU.js";import{V as H}from"./VSwitch-Dcs-7m3i.js";import"./VForm-CLH0WxMk.js";import"./VExpansionPanels-CpHWuHN2.js";import"./VDialog-Bh3mGVOy.js";import"./VAlert-DQxypmdN.js";import"./VSlider-BOibVdD7.js";import"./VSelect-B-WERBOu.js";import"./VVirtualScroll-htzu2YXu.js";import"./VCheckboxBtn-D390s4L9.js";import"./VSelectionControl-Co1cRcmS.js";const Y={key:0,style:{"margin-left":"-5px","margin-right":"-5px"}},ie=B({__name:"EditPlayer",props:{playerId:{}},setup(C){const S=q(),e=c(),I=j(11),E=c(!1),m=C,b=c(!1);(async()=>{if(m.playerId)try{b.value=(await t.getDSPConfig(m.playerId)).enabled}catch(a){console.error("Error fetching DSP config:",a)}})();const T=t.subscribe(L.PLAYER_DSP_CONFIG_UPDATED,a=>{b.value=a.data.enabled});M(T);const $=N(()=>{if(!e.value)return[];const a=Object.values(e.value.values),l=t.players[e.value.player_id];return l&&l.type!==g.GROUP?a.push({key:"dsp_settings",type:_.DSP_SETTINGS,label:"",default_value:b.value,required:!1,category:"audio"}):l&&l.type===g.GROUP&&l.supported_features.includes(V.MULTI_DEVICE_DSP)?a.push({key:"dsp_note_multi_device_group",type:_.LABEL,label:"You can configure the DSP for each player individually.",default_value:null,required:!1,category:"audio"}):l&&l.type===g.GROUP&&!l.supported_features.includes(V.MULTI_DEVICE_DSP)&&a.push({key:"dsp_note_multi_device_group_not_supported",type:_.LABEL,label:"This group type does not support DSP when playing to multiple devices.",default_value:null,required:!1,category:"audio"}),a});w(()=>m.playerId,async a=>{a&&(e.value=await t.getPlayerConfig(a))},{immediate:!0});const U=async function(a){delete a.dsp_settings,a.enabled=e.value.enabled,a.name=e.value.name||null,t.savePlayerConfig(m.playerId,a),S.push({name:"playersettings"})},h=async function(a,l){E.value=!0;for(const n of Object.values(e.value.values))n.value!==void 0&&l[n.key]==null&&(l[n.key]=n.value);l.session_id=I,t.getPlayerConfigEntries(e.value.player_id,a,l).then(n=>{e.value.values={};for(const k of n)e.value.values[k.key]=k}).catch(n=>{alert(n)}).finally(()=>{E.value=!1})};return(a,l)=>(s(),P("section",null,[p(R,null,{default:d(()=>[e.value&&r(t).getProviderManifest(e.value.provider).domain in r(t).providerManifests?(s(),P("div",Y,[p(A,null,{default:d(()=>[v(i(a.$t("settings.config_player",[e.value.name||r(t).players[e.value.player_id]?.name||e.value.default_name])),1)]),_:1}),p(f,null,{default:d(()=>[o("b",null,i(a.$t("settings.player_id"))+": ",1),v(i(e.value.player_id),1)]),_:1}),p(f,null,{default:d(()=>[o("b",null,i(a.$t("settings.player_provider"))+": ",1),v(i(r(t).getProviderManifest(e.value.provider)?.name)+" ",1),r(t).getProviderManifest(e.value.provider)?.documentation?(s(),P("a",{key:0,onClick:l[0]||(l[0]=n=>r(G)(r(t).getProviderManifest(e.value.provider)?.documentation))}," ["+i(a.$t("settings.check_docs"))+"]",1)):u("",!0)]),_:1}),r(t).players[e.value.player_id]?(s(),y(f,{key:0},{default:d(()=>[o("b",null,i(a.$t("settings.player_model"))+": ",1),v(i(r(t).players[e.value.player_id].device_info.manufacturer)+" / "+i(r(t).players[e.value.player_id].device_info.model),1)]),_:1})):u("",!0),r(t).players[e.value.player_id]?.device_info.ip_address?(s(),y(f,{key:1},{default:d(()=>[o("b",null,i(a.$t("settings.player_address"))+": ",1),v(i(r(t).players[e.value.player_id].device_info.ip_address),1)]),_:1})):u("",!0),r(t).players[e.value.player_id]?(s(),y(f,{key:2},{default:d(()=>[o("b",null,i(a.$t("settings.player_type_label"))+": ",1),v(i(a.$t(`player_type.${r(t).players[e.value.player_id].type}`)),1)]),_:1})):u("",!0),l[3]||(l[3]=o("br",null,null,-1)),p(D),l[4]||(l[4]=o("br",null,null,-1)),l[5]||(l[5]=o("br",null,null,-1)),"name"in e.value?(s(),y(O,{key:3,modelValue:e.value.name,"onUpdate:modelValue":l[1]||(l[1]=n=>e.value.name=n),placeholder:e.value?.name,label:a.$t("settings.player_name"),variant:"outlined",clearable:"",class:"configcolumnleft",style:{"margin-right":"25px"}},null,8,["modelValue","placeholder","label"])):u("",!0),"enabled"in e.value?(s(),y(H,{key:4,modelValue:e.value.enabled,"onUpdate:modelValue":l[2]||(l[2]=n=>e.value.enabled=n),label:a.$t("settings.enable_player"),color:"primary",disabled:r(t).getProviderManifest(e.value.provider)?.builtin},null,8,["modelValue","label","disabled"])):u("",!0)])):u("",!0),l[6]||(l[6]=o("br",null,null,-1)),p(D),e.value?(s(),y(F,{key:1,disabled:!e.value.enabled,"config-entries":$.value,onSubmit:U,onAction:h},null,8,["disabled","config-entries"])):u("",!0)]),_:1})]))}});export{ie as default};
