2 lines
33 KiB
JavaScript
2 lines
33 KiB
JavaScript
|
|
import{a as m,j as e}from"./vendor-react-BHG7lGYR.js";import{t as ge,T as L,a as ye}from"./tracks-Bqg0pqgn.js";import{l as ve,n as we,q as V}from"./vendor-IYr-MHu4.js";import{a as Q,u as ne,g as Z,d as q,B as k,C as je,b as Ne,c as be,e as Ce,E as H,L as J,p as Ee,D as Te,f as $,s as U,y as ke}from"./index-BWcMVITa.js";import{T as Se,a as De,b as ee,c as se}from"./tabs-DP-eavm_.js";import{a as ie,u as oe,b as W}from"./vendor-tanstack-BzWBL1hV.js";import{D as Re,a as Ie,b as Oe,c as re,u as _e}from"./useIsRateLimited-HpmSVPdB.js";import{I as B}from"./input-BGBI2Wze.js";import{S as X}from"./Spinner-BIGPirtm.js";import{A as Ae}from"./avatar-B2y8ugWJ.js";import{C as Me}from"./confirmation-dialog-D8kbmfRa.js";import{aj as qe,aK as Pe,T as le,ar as Y,X as te,aL as Le,aM as G,l as Ve,C as ae,aN as F,aO as Qe,u as ze,v as Ke,aP as $e,aQ as Ue,aR as ce,aJ as We,ah as ue,O as Fe,D as He,g as Be,aG as Je,ab as Ge,a2 as Xe,a3 as Ye,aS as Ze,aT as es}from"./vendor-icons-DaGlTw4_.js";import{f as ss,d as rs}from"./vendor-utils-CgOSfOkx.js";import{L as ts}from"./label-N1Bsuay_.js";import{A as de,a as me}from"./alert-tey2YzVZ.js";import{d as as,u as ns}from"./vendor-router-D-s5vIeO.js";import"./dropdown-BYn_8IId.js";const is=ve()(we((r,a)=>({currentTrack:null,isPlaying:!1,currentTime:0,duration:0,volume:100,muted:!1,queue:[],currentIndex:-1,repeat:"off",shuffle:!1,play:s=>{if(!s){r({isPlaying:!0});return}const{queue:t}=a(),n=t.findIndex(o=>o.id===s.id);if(n>=0)r({currentTrack:s,currentIndex:n,isPlaying:!0,currentTime:0});else{const o=[...t,s];r({currentTrack:s,currentIndex:o.length-1,queue:o,isPlaying:!0,currentTime:0})}},pause:()=>{r({isPlaying:!1})},resume:()=>{r({isPlaying:!0})},stop:()=>{r({isPlaying:!1,currentTime:0})},next:()=>{const{queue:s,currentIndex:t,repeat:n,shuffle:o}=a();if(s.length===0)return;let c=t;if(o)c=Math.floor(Math.random()*s.length);else if(t<s.length-1)c=t+1;else if(n==="playlist")c=0;else return;c!==t&&c<s.length&&r({currentIndex:c,currentTrack:s[c],currentTime:0,isPlaying:!0})},previous:()=>{const{queue:s,currentIndex:t}=a();if(s.length===0||t<=0)return;const n=t-1;r({currentIndex:n,currentTrack:s[n],currentTime:0,isPlaying:!0})},seek:s=>{const{duration:t}=a(),n=Math.max(0,Math.min(s,t||0));r({currentTime:n})},setCurrentTime:s=>{const{duration:t}=a(),n=Math.max(0,Math.min(s,t||0));r({currentTime:n})},setDuration:s=>{r({duration:Math.max(0,s)})},setVolume:s=>{const t=Math.max(0,Math.min(100,s));r({volume:t})},toggleMute:()=>{r({muted:!a().muted})},toggleShuffle:()=>{r({shuffle:!a().shuffle})},setRepeat:s=>{r({repeat:s})},addToQueue:s=>{const{queue:t}=a(),n=[...t,...s];r({queue:n})},removeFromQueue:s=>{const{queue:t,currentIndex:n}=a();if(s<0||s>=t.length)return;const o=t.filter((l,g)=>g!==s);let c=n;if(s<n)c=n-1;else if(s===n)if(o.length>0){c=Math.min(c,o.length-1),r({queue:o,currentIndex:c,currentTrack:o[c]||null,isPlaying:o[c]?a().isPlaying:!1});return}else{c=-1,r({queue:o,currentIndex:c,currentTrack:null,isPlaying:!1});return}r({queue:o,currentIndex:c})},reorderQueue:(s,t)=>{const{queue:n,currentIndex:o}=a();if(s<0||s>=n.length||t<0||t>=n.length||s===t)return;const c=[...n],[l]=c.splice(s,1);c.splice(t,0,l);let g=o;s===o?g=t:s<o&&t>=o?g=o-1:s>o&&t<=o&&(g=o+1),r({queue:c,currentIndex:g})},clearQueue:()=>{r({queue:[],currentIndex:-1,currentTrack:null,isPlaying:!1,currentTime:0})}}),{name:"player-storage",partialize:r=>({volume:r.volume,muted:r.muted,repeat:r.repeat,shuffle:r.shuffle,queue:r.queue,currentIndex:r.currentIndex,currentTrack:r.currentTrack})}));class d extends Error{constructor(a,s,t=!1,n){super(a),this.code=s,this.retryable=t,this.originalError=n,this.name="CommentError"}}async function pe(r,a,s){try{return(await Q.post(`/tracks/${r}/comments`,{content:a,parent_id:s})).data.comment}catch(t){if(t instanceof V){if(t.response?.status===401)throw new d("Non autorisé: Veuillez vous connecter pour commenter","VALIDATION",!1,t);if(t.response?.status===404)throw new d("Track ou commentaire parent introuvable","VALIDATION",!1,t);if(t.response?.status===400){const o=t.response?.data?.error||"Données inva
|