veza/apps/web/dist_verification/assets/QueueView-C0ORvlAn.js

2 lines
8 KiB
JavaScript
Raw Normal View History

import{a as c,j as e}from"./vendor-react-yWUy5XPk.js";import{u as N,B as g,j as I,C as $,E as A}from"./index-CYK_b1Uz.js";import{I as _}from"./input-CGdBHtsQ.js";import{X as w,G as M,t as O,u as U,i as q,q as z,r as y,v as F,w as G}from"./vendor-icons-DJFb1Tiw.js";import{o as L,p as V}from"./playlistService-Ibr1CVA5.js";import"./vendor-CveO81sn.js";import"./vendor-security-DsrNJhpn.js";import"./vendor-router-BNNHboN9.js";import"./vendor-tanstack-kPY9uK0s.js";import"./vendor-http-Cz8wfb0q.js";import"./vendor-utils-DtoSyhX2.js";import"./vendor-motion-B3XPS3Jc.js";import"./vendor-i18n-CMcqpBLz.js";import"./features-DItyhINc.js";const B=({onClose:a,onSave:l})=>{const{addToast:m}=N(),[u,f]=c.useState(""),[o,x]=c.useState(!1),[h,i]=c.useState(!1),b=async()=>{if(!u){m("Please name your playlist","error");return}i(!0);try{await l(u,o),a()}catch(n){m(n instanceof Error?n.message:"Failed to save playlist","error")}finally{i(!1)}};return e.jsxs("div",{className:"fixed inset-0 z-[var(--sumi-z-modal)] flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-background/90 backdrop-blur-sm",onClick:a}),e.jsxs("div",{className:"relative w-full max-w-md bg-card border border-border rounded-xl shadow-2xl animate-scaleIn",children:[e.jsxs("div",{className:"p-4 border-b border-border bg-card flex justify-between items-center",children:[e.jsx("h3",{className:"font-bold text-foreground",children:"Save Queue as Playlist"}),e.jsx("button",{onClick:a,children:e.jsx(w,{className:"w-5 h-5 text-muted-foreground hover:text-foreground"})})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx(_,{label:"Playlist Name",value:u,onChange:n=>f(n.target.value),autoFocus:!0,placeholder:"My Queue Session"}),e.jsxs("div",{className:"flex items-center justify-between p-4 bg-card rounded border border-border cursor-pointer hover:border-border",onClick:()=>x(!o),children:[e.jsxs("div",{className:"flex items-center gap-4",children:[o?e.jsx(M,{className:"w-5 h-5 text-muted-foreground"}):e.jsx(O,{className:"w-5 h-5 text-warning"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-bold text-foreground",children:o?"Public Playlist":"Private Playlist"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:o?"Visible on your profile":"Only visible to you"})]})]}),e.jsx("div",{className:`w-10 h-5 rounded-full relative transition-colors ${o?"bg-primary":"bg-muted"}`,children:e.jsx("div",{className:`absolute top-1 w-3 h-3 bg-white rounded-full transition-all ${o?"left-6":"left-1"}`})})]})]}),e.jsxs("div",{className:"p-4 border-t border-border bg-card flex justify-end gap-4",children:[e.jsx(g,{variant:"ghost",onClick:a,children:"Cancel"}),e.jsx(g,{variant:"primary",onClick:b,disabled:h,loading:h,children:"Save Playlist"})]})]})]})},oe=()=>{const{queue:a,currentTrack:l,reorderQueue:m,removeFromQueue:u,clearQueue:f,playTrack:o,isPlaying:x,togglePlay:h,autoplay:i,toggleAutoplay:b}=I(),{addToast:n}=N(),[k,v]=c.useState(!1),[d,p]=c.useState(null),[S,j]=c.useState(null),P=(s,r)=>{p(r),s.dataTransfer.effectAllowed="move";const t=document.createElement("div");t.style.opacity="0",document.body.appendChild(t),s.dataTransfer.setDragImage(t,0,0),setTimeout(()=>document.body.removeChild(t),0)},C=(s,r)=>{s.preventDefault(),j(r),!(d===null||d===r)&&(m(d,r),p(r))},Q=()=>{p(null),j(null)},E=async(s,r)=>{const t=[...l?[l]:[],...a];if(t.length===0)throw n("Queue is empty","error"),new Error("Queue is empty");const T=await L({title:s,description:"",is_public:r});for(const D of t)await V(T.id,String(D.id));n(`Queue saved as "${s}"`,"success")};return e.jsxs("div",{className:"max-w-4xl mx-auto space-y-6 animate-fadeIn pb-20",children:[e.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-end border-b border-border/50 pb-6 gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-heading font-bold text-foreground mb-2",children:"PLAY QUEUE"}),e.jsxs("p",{className:"text-muted-foreground font-mono text-sm",children:[a.length," tracks upcoming"]})]}),e.jsxs("div",{className:"flex gap-4",children:[