import{d as _,r as d,o as C,h as f,C as h,w as M,i as g,_ as S,a as p,c as u,b as n,e as v,f as k,t as m,n as T,g as $,j as b}from"./index-b1308428.js";import N from"./TextButton-1d08b82b.js";import{b as y}from"./bluetooth_disabled-b2ae7768.js";const E="/assets/play-8bea5786.svg",I="/assets/pause-cc951caf.svg",w="/assets/skip_prev-e81c8432.svg",A="/assets/skip_next-1e2bfc6a.svg",P=_({setup(){let e;(a=>{a.PLAY="play",a.PAUSE="pause",a.NEXT="next",a.PREV="prev"})(e||(e={}));const o=new Map([["play",E],["pause",I],["prev",w],["next",A]]),s=d(g("mediaStore")),c=d(g("settingsStore")),t=d(g("websocket")),l=a=>{s.value.source&&t.value.send(JSON.stringify({type:"media",media:a}))},i=()=>{s.value.song&&(s.value.song.playing=!s.value.song.playing,l(s.value.song.playing?"play":"pause"))},r=a=>{(a==="next"||a==="prev")&&l(a)};return C(()=>f("control-icon",h.SECONDARY_LUMIN)),M(c,()=>{f("route-img",h.SECONDARY_LUMIN)},{deep:!0}),{iconMap:o,songStore:s,changeState:i,TrackActions:e,skipTrack:r}}});const R={key:0,class:"song-ctrl-btn",id:"control-container"},L=["src"],V=["src"],D=["src"];function O(e,o,s,c,t,l){return e.songStore&&e.songStore.song?(p(),u("div",R,[n("div",{class:"song-ctl-btn",id:"skip-prev-btn",onClick:o[0]||(o[0]=i=>e.skipTrack(e.TrackActions.PREV))},[n("img",{class:"control-icon",src:e.iconMap.get(e.TrackActions.PREV)},null,8,L)]),n("div",{class:"song-ctl-btn",id:"status-btn",onClick:o[1]||(o[1]=(...i)=>e.changeState&&e.changeState(...i))},[n("img",{class:"control-icon",src:e.songStore.song.playing?e.iconMap.get(e.TrackActions.PAUSE):e.iconMap.get(e.TrackActions.PLAY)},null,8,V)]),n("div",{class:"song-ctl-btn",id:"skip-next-btn",onClick:o[2]||(o[2]=i=>{e.skipTrack(e.TrackActions.NEXT)})},[n("img",{class:"control-icon",src:e.iconMap.get(e.TrackActions.NEXT)},null,8,D)])])):v("",!0)}const Y=S(P,[["render",O],["__scopeId","data-v-59c42e73"]]),X=_({components:{SongControl:Y},setup(){const e=d(g("mediaStore")),o=d(0),s=1e3;return setInterval(()=>{if(e.value.song&&e.value.song.duration&&e.value.song.position){const t=e.value.song.position/e.value.song.duration*100;o.value=t>100?100:t,e.value.song.playing&&(e.value.song.position+=s)}},s),{mediaStore:e,progress:o,formatTitleAlbum:t=>{const i=/((\(|\[|\{)(feat|prod|ft|with).*(\)|\]|\}))/gi;return t&&t.length>40?t.replace(i,""):t}}}});const U={key:0,id:"song-info-container"},j={id:"song-info"},B={id:"title"},F={key:0,id:"artist"},H={key:1,id:"album"},J={key:0,class:"progressbar"},W={id:"song-ctl"};function z(e,o,s,c,t,l){const i=k("SongControl");return e.mediaStore&&e.mediaStore.song?(p(),u("div",U,[n("div",j,[n("div",B,[n("span",null,m(e.formatTitleAlbum(e.mediaStore.song.title)),1)]),e.mediaStore.song.artist?(p(),u("div",F,[n("span",null,m(e.mediaStore.song.artist),1)])):v("",!0),e.mediaStore.song.album?(p(),u("div",H,[n("span",null,m(e.formatTitleAlbum(e.mediaStore.song.album)),1)])):v("",!0)]),e.mediaStore.song.duration&&e.mediaStore.song.position?(p(),u("div",J,[n("div",{class:"progressbar",id:"progress-inner",style:T({width:e.progress+"%"})},null,4)])):v("",!0),n("div",W,[$(i)])])):v("",!0)}const q=S(X,[["render",z],["__scopeId","data-v-e239c6ca"]]),G=_({components:{SongInfo:q,TextButton:N},setup(){const e=d(g("mediaStore")),o=d(g("bluetoothStore")),s=d(g("websocket"));let c;(r=>{r.POWER_ON="on-power",r.POWER_OFF="off-power",r.START_DISCOVERY="start-discovery",r.STOP_DISCOVERY="stop-discovery"})(c||(c={}));const t=new Map([["bluetooth-disabled",{message:"<p>Enable & connect bluetooth to start playing audio!</p>",icon:y}],["bluetooth-disconnected",{message:o.value.hostname?`<p>To connect, look for <span id=hostname>${o.value.hostname}</span> in your bluetooth settings</p>`:"<p>Connect a bluetooth device to start playing audio!</p>",icon:y}]]);return{mediaStore:e,bluetoothStore:o,getConnectedDevices:b,getNotConnectedMessage:()=>{if(e.value.source=="bluetooth"){if(!o.value.powered)return t.get("bluetooth-disabled");if(!(b(o.value.devices).length>0))return console.log(o.value.hostname),t.get("bluetooth-disconnected")}},BluetoothActions:c,bluetoothCommand:r=>{s.value.send(JSON.stringify({type:"bluetooth",bluetooth:r}))}}}});const K={key:0,id:"media-container"},Q={key:1,id:"no-media-container"},Z={id:"not-connected-container"},x={id:"not-connected-icon-container"},ee=["src"],oe=["innerHTML"];function ne(e,o,s,c,t,l){var r,a;const i=k("SongInfo");return e.mediaStore.source==="bluetooth"&&e.getConnectedDevices(e.bluetoothStore.devices).length>0||e.mediaStore.source==="files"?(p(),u("div",K,[$(i)])):(p(),u("div",Q,[n("div",Z,[n("div",x,[n("img",{class:"not-connected-icon",src:(r=e.getNotConnectedMessage())==null?void 0:r.icon},null,8,ee)]),n("div",{class:"not-connected-msg",innerHTML:(a=e.getNotConnectedMessage())==null?void 0:a.message},null,8,oe)])]))}const ie=S(G,[["render",ne],["__scopeId","data-v-857c9db2"]]);export{ie as default};
