dsh-singinglab
Version:
A music player for DeepSeek Harness where 大肥鱼 sings: tell her a song, she learns it on your machine and plays it.
603 lines • 152 kB
JavaScript
window.__ModuleLoader__.load({id:"dsh-singinglab",factory:(require)=>{var module={exports:{}};var exports=module.exports;
"use strict";var nn=Object.create;var ct=Object.defineProperty;var sn=Object.getOwnPropertyDescriptor;var an=Object.getOwnPropertyNames;var rn=Object.getPrototypeOf,on=Object.prototype.hasOwnProperty;var ln=(e,n)=>{for(var t in n)ct(e,t,{get:n[t],enumerable:!0})},Tt=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of an(n))!on.call(e,i)&&i!==t&&ct(e,i,{get:()=>n[i],enumerable:!(s=sn(n,i))||s.enumerable});return e};var cn=(e,n,t)=>(t=e!=null?nn(rn(e)):{},Tt(n||!e||!e.__esModule?ct(t,"default",{value:e,enumerable:!0}):t,e)),dn=e=>Tt(ct({},"__esModule",{value:!0}),e);var Zn={};ln(Zn,{PANEL_ID:()=>ot,apply:()=>Yn,inject:()=>Wn});module.exports=dn(Zn);var Qt=require("react");var ke=require("react");var Ie="/api/dsh-singinglab";async function tt(e,n){let t=await fetch(`${Ie}/${e}`,{method:"POST",credentials:"same-origin",headers:{"content-type":"application/json"},body:JSON.stringify(n)}),s=await t.json();if(!s.ok)throw new Error(s.error??`HTTP ${t.status}`);return s}async function mt(e){let n=await fetch(`${Ie}/${e}`,{credentials:"same-origin"}),t=await n.json();if(!t.ok)throw new Error(t.error??`HTTP ${n.status}`);return t}var J={library:()=>mt("library").then(e=>e.songs),song:e=>mt(`song?id=${encodeURIComponent(e)}`).then(n=>n.song),audioUrl:e=>`${Ie}/audio?id=${encodeURIComponent(e)}`,coverUrl:e=>`${Ie}/cover?id=${encodeURIComponent(e)}`,search:e=>tt("search",{q:e}).then(n=>n.hits),learn:e=>tt("learn",e).then(n=>n.job),edit:async e=>{let n=await fetch(`${Ie}/edit?id=${encodeURIComponent(e)}`,{credentials:"same-origin"}),t=await n.json();if(!t.ok)throw Object.assign(new Error(t.error??`HTTP ${n.status}`),{relearn:!!t.relearn});return t},editSpecUrl:(e,n)=>`${Ie}/edit-spec?id=${encodeURIComponent(e)}&layer=${n}`,editAudioUrl:(e,n,t)=>`${Ie}/edit-audio?id=${encodeURIComponent(e)}&name=${n}&key=${t}`,editPhrase:(e,n,t,s,i)=>tt("edit-phrase",{id:e,start:n,end:t,f0:s,key:i}),editSave:(e,n,t,s)=>tt("edit-save",{id:e,f0:n,key:t,ops:s}),jobs:(e=0)=>mt(`jobs?after=${e}`),cancel:e=>tt("cancel",{id:e}),imgUrl:e=>`${Ie}/img?u=${encodeURIComponent(e)}`,assetUrl:e=>`${Ie}/asset?name=${encodeURIComponent(e)}`,scene:async e=>{let n=await fetch(`${Ie}/asset?name=scene-${e}.json`,{credentials:"same-origin"});if(!n.ok)throw new Error(`HTTP ${n.status}`);return n.json()}};var ft=(e,n,t)=>Math.min(t,Math.max(n,e));function pn(){try{let e=Number(localStorage.getItem("dsh-singinglab.volume"));return Number.isFinite(e)&&e>0?ft(e,0,1):.8}catch{return .8}}var ht=class{audio;ctx=null;analyser=null;bins=null;listeners=new Set;loadSeq=0;state={songs:[],queue:[],index:-1,current:null,loading:!1,playing:!1,duration:0,volume:pn(),shuffle:!1,repeat:"all",error:null,jobs:[],learnMissing:null,toast:null,studioAsk:0,editing:null,edited:null};jobTimer=0;seenDone=new Set;jobsLoaded=!1;lastCommand=-1;constructor(){this.audio=new Audio,this.audio.preload="auto",this.audio.volume=this.state.volume,this.audio.addEventListener("play",()=>this.set({playing:!0})),this.audio.addEventListener("pause",()=>this.set({playing:!1})),this.audio.addEventListener("durationchange",()=>this.set({duration:this.audio.duration||this.state.current?.durationSec||0})),this.audio.addEventListener("ended",()=>this.onEnded()),this.audio.addEventListener("error",()=>{this.state.current&&this.set({error:"\u8FD9\u9996\u653E\u4E0D\u51FA\u6765\uFF08\u97F3\u9891\u8BFB\u4E0D\u5230\uFF09",playing:!1})})}pollJobs=async()=>{clearTimeout(this.jobTimer);try{let{jobs:t,missing:s,commands:i}=await J.jobs(Math.max(0,this.lastCommand));for(let a of i)this.lastCommand>=0&&a.type==="play"&&(await this.refresh(),this.playSong(a.songId)),this.lastCommand>=0&&a.type==="edited"&&(this.reloadSong(a.songId),this.set({edited:{songId:a.songId,at:Date.now()}})),this.lastCommand=Math.max(this.lastCommand,a.id);this.lastCommand<0&&(this.lastCommand=0);let o=t.filter(a=>a.state==="done"&&!this.seenDone.has(a.id)),d=t.filter(a=>a.state==="failed"&&!this.seenDone.has(a.id));for(let a of[...o,...d])this.seenDone.add(a.id);if(this.set({jobs:t,learnMissing:s}),this.jobsLoaded){for(let a of d)this.notify(`\u300A${a.title}\u300B\u6CA1\u5B66\u6210\uFF1A${a.reason??""}`);if(o.length){await this.refresh();let a=o[o.length-1];a.autoplay?this.playLearned(a.id,a.title):this.notify(`\u5B66\u4F1A\u4E86\u300A${a.title}\u300B`,a.id)}}this.jobsLoaded=!0}catch{}let n=this.state.jobs.some(t=>t.state==="running"||t.state==="queued");this.jobTimer=window.setTimeout(this.pollJobs,n?1500:8e3)};notify(n,t){this.set({toast:{id:Date.now(),text:n,...t?{songId:t}:{}}})}playLearned(n,t){if(!this.state.playing){this.playSong(n),this.notify(`\u5B66\u4F1A\u4E86\u300A${t}\u300B\uFF0C\u5531\u7ED9\u4F60\u542C`);return}this.playNext(n),this.notify(`\u5B66\u4F1A\u4E86\u300A${t}\u300B\uFF0C\u8FD9\u9996\u653E\u5B8C\u5C31\u5531`,n)}playNext(n){let t=this.state.queue.filter(i=>i!==n),s=Math.max(0,t.indexOf(this.state.queue[this.state.index]));t.splice(s+1,0,n),this.set({queue:t,index:s})}async learn(n){try{await J.learn({...n,autoplay:!0}),this.notify(`\u5F00\u59CB\u5B66\u300A${n.title}\u300B`),this.pollJobs()}catch(t){let s=t.message;/还没准备好|还没有她的声音|还缺模型/.test(s)&&this.set({studioAsk:Date.now()}),this.notify(s)}}openStudio(){this.set({studioAsk:Date.now()})}openEditor(n){n&&this.audio.pause(),this.set({editing:n})}reloadSong(n){if(this.state.current?.id!==n)return;let t=this.audio.currentTime,s=!this.audio.paused;this.audio.src=`${J.audioUrl(n)}&v=${Date.now()}`,this.audio.addEventListener("loadedmetadata",()=>{this.audio.currentTime=t,s&&this.audio.play().catch(()=>{})},{once:!0})}async cancelJob(n){await J.cancel(n).catch(()=>{}),this.pollJobs()}startJobs(){this.jobTimer||this.pollJobs()}subscribe=n=>(this.listeners.add(n),()=>this.listeners.delete(n));getState=()=>this.state;set(n){this.state={...this.state,...n};for(let t of this.listeners)t()}get time(){return this.audio.currentTime||0}async refresh(){try{let n=await J.library();this.set({songs:n,error:null})}catch(n){this.set({error:`\u6B4C\u5E93\u8BFB\u4E0D\u51FA\u6765\uFF1A${n.message}`})}}energy(){if(!this.analyser||!this.bins||!this.state.playing)return 0;this.analyser.getByteFrequencyData(this.bins);let n=0,t=Math.min(12,this.bins.length);for(let s=1;s<t;s++)n+=this.bins[s];return n/((t-1)*255)}spectrum(n){if(!this.analyser||!this.bins||!this.state.playing){n.fill(0);return}this.analyser.getByteFrequencyData(this.bins);let t=Math.floor(this.bins.length*.7);for(let s=0;s<n.length;s++){let i=Math.floor(Math.pow(s/n.length,1.8)*t),o=Math.max(i+1,Math.floor(Math.pow((s+1)/n.length,1.8)*t)),d=0;for(let a=i;a<o;a++)d=Math.max(d,this.bins[a]);n[s]=d/255}}wire(){if(this.ctx){this.ctx.state==="suspended"&&this.ctx.resume();return}try{this.ctx=new AudioContext;let n=this.ctx.createMediaElementSource(this.audio);this.analyser=this.ctx.createAnalyser(),this.analyser.fftSize=1024,this.analyser.smoothingTimeConstant=.78,this.bins=new Uint8Array(this.analyser.frequencyBinCount),n.connect(this.analyser),this.analyser.connect(this.ctx.destination)}catch{this.ctx=null,this.analyser=null}}async playSong(n,t){let s=t??this.state.songs.map(o=>o.id),i=this.state.shuffle?Ct(s,n):s;this.set({queue:i,index:Math.max(0,i.indexOf(n))}),await this.load(n,!0)}async load(n,t){let s=++this.loadSeq;this.wire(),this.set({loading:!0,error:null}),this.audio.src=J.audioUrl(n),t&&this.audio.play().catch(()=>{});try{let i=await J.song(n);if(s!==this.loadSeq)return;this.set({current:i,loading:!1,duration:this.audio.duration||i.durationSec})}catch(i){if(s!==this.loadSeq)return;this.set({loading:!1,error:`\u8FD9\u9996\u8BFB\u4E0D\u51FA\u6765\uFF1A${i.message}`})}}jump(n){let t=this.state.queue.indexOf(n);if(t<0){this.playSong(n);return}this.set({index:t}),this.load(n,!0)}toggle(){if(!this.state.current){let n=this.state.songs[0];n&&this.playSong(n.id);return}this.wire(),this.audio.paused?this.audio.play().catch(()=>{}):this.audio.pause()}seek(n){let t=this.state.duration||this.audio.duration||0;this.audio.currentTime=ft(n,0,Math.max(0,t-.05))}step(n){let{queue:t,index:s}=this.state;if(!t.length)return;if(n===-1&&this.audio.currentTime>3){this.seek(0);return}let i=(s+n+t.length)%t.length;this.set({index:i}),this.load(t[i],!0)}setVolume(n){let t=ft(n,0,1);this.audio.volume=t;try{localStorage.setItem("dsh-singinglab.volume",String(t))}catch{}this.set({volume:t})}toggleShuffle(){let n=!this.state.shuffle,t=this.state.queue[this.state.index],s=this.state.songs.map(o=>o.id),i=t?n?Ct(s,t):s:this.state.queue;this.set({shuffle:n,queue:i,index:t?i.indexOf(t):this.state.index})}cycleRepeat(){let n=["all","one","off"];this.set({repeat:n[(n.indexOf(this.state.repeat)+1)%n.length]})}onEnded(){let{repeat:n,index:t,queue:s}=this.state;if(n==="one"){this.seek(0),this.audio.play().catch(()=>{});return}n==="off"&&t>=s.length-1||this.step(1)}};function Ct(e,n){let t=e.filter(s=>s!==n);for(let s=t.length-1;s>0;s--){let i=Math.floor(Math.random()*(s+1));[t[s],t[i]]=[t[i],t[s]]}return[n,...t]}var dt=null,V=()=>(dt||(dt=new ht,window.__singinglab=dt),dt);var je=require("react");var L=require("react/jsx-runtime"),un={play:(0,L.jsx)("path",{d:"M8 5.5v13a1 1 0 0 0 1.5.86l10.6-6.5a1 1 0 0 0 0-1.72L9.5 4.64A1 1 0 0 0 8 5.5Z",fill:"currentColor",stroke:"none"}),pause:(0,L.jsxs)("g",{fill:"currentColor",stroke:"none",children:[(0,L.jsx)("rect",{x:"6.5",y:"5",width:"4",height:"14",rx:"1.4"}),(0,L.jsx)("rect",{x:"13.5",y:"5",width:"4",height:"14",rx:"1.4"})]}),prev:(0,L.jsxs)("g",{fill:"currentColor",stroke:"none",children:[(0,L.jsx)("path",{d:"M18 6.2v11.6a.9.9 0 0 1-1.4.75L8.4 12.75a.9.9 0 0 1 0-1.5l8.2-5.8A.9.9 0 0 1 18 6.2Z"}),(0,L.jsx)("rect",{x:"5",y:"5.5",width:"2.6",height:"13",rx:"1.1"})]}),next:(0,L.jsxs)("g",{fill:"currentColor",stroke:"none",children:[(0,L.jsx)("path",{d:"M6 6.2v11.6a.9.9 0 0 0 1.4.75l8.2-5.8a.9.9 0 0 0 0-1.5l-8.2-5.8A.9.9 0 0 0 6 6.2Z"}),(0,L.jsx)("rect",{x:"16.4",y:"5.5",width:"2.6",height:"13",rx:"1.1"})]}),shuffle:(0,L.jsxs)("g",{children:[(0,L.jsx)("path",{d:"M3 7h3.2c2 0 3.2.9 4.3 2.6l3 4.8c1.1 1.7 2.3 2.6 4.3 2.6H21"}),(0,L.jsx)("path",{d:"M3 17h3.2c1.5 0 2.5-.5 3.4-1.5M14.4 8.5c.9-1 1.9-1.5 3.4-1.5H21"}),(0,L.jsx)("path",{d:"m18.5 4.5 2.5 2.5-2.5 2.5M18.5 14.5l2.5 2.5-2.5 2.5"})]}),repeat:(0,L.jsxs)("g",{children:[(0,L.jsx)("path",{d:"M4 11V9.5A3.5 3.5 0 0 1 7.5 6H19"}),(0,L.jsx)("path",{d:"m16 3 3 3-3 3"}),(0,L.jsx)("path",{d:"M20 13v1.5a3.5 3.5 0 0 1-3.5 3.5H5"}),(0,L.jsx)("path",{d:"m8 21-3-3 3-3"})]}),repeat1:(0,L.jsxs)("g",{children:[(0,L.jsx)("path",{d:"M4 11V9.5A3.5 3.5 0 0 1 7.5 6H19"}),(0,L.jsx)("path",{d:"m16 3 3 3-3 3"}),(0,L.jsx)("path",{d:"M20 13v1.5a3.5 3.5 0 0 1-3.5 3.5H5"}),(0,L.jsx)("path",{d:"m8 21-3-3 3-3"}),(0,L.jsx)("path",{d:"M11.2 10.4 12.6 9.6v5"})]}),volume:(0,L.jsxs)("g",{children:[(0,L.jsx)("path",{d:"M4 9.5v5h3.5L12 18.5v-13L7.5 9.5H4Z",fill:"currentColor",stroke:"none"}),(0,L.jsx)("path",{d:"M15.5 9a4.2 4.2 0 0 1 0 6M18 6.5a7.8 7.8 0 0 1 0 11"})]}),mute:(0,L.jsxs)("g",{children:[(0,L.jsx)("path",{d:"M4 9.5v5h3.5L12 18.5v-13L7.5 9.5H4Z",fill:"currentColor",stroke:"none"}),(0,L.jsx)("path",{d:"m16 9.5 5 5M21 9.5l-5 5"})]}),down:(0,L.jsx)("path",{d:"m6 9.5 6 6 6-6"}),search:(0,L.jsxs)("g",{children:[(0,L.jsx)("circle",{cx:"11",cy:"11",r:"6.5"}),(0,L.jsx)("path",{d:"m20 20-4.2-4.2"})]}),fish:(0,L.jsxs)("g",{children:[(0,L.jsx)("path",{d:"M3 12c2.6-4.2 6.2-6 10-6 3.4 0 6.2 2.4 8 6-1.8 3.6-4.6 6-8 6-3.8 0-7.4-1.8-10-6Z"}),(0,L.jsx)("path",{d:"M3 12 1 8.5M3 12l-2 3.5"}),(0,L.jsx)("circle",{cx:"16.2",cy:"10.6",r:"1",fill:"currentColor",stroke:"none"})]}),list:(0,L.jsxs)("g",{children:[(0,L.jsx)("path",{d:"M4 6.5h11M4 12h11M4 17.5h7"}),(0,L.jsx)("path",{d:"M17.5 14.5v-8l3.5 1"}),(0,L.jsx)("circle",{cx:"15.8",cy:"16.8",r:"2.2"})]}),close:(0,L.jsx)("path",{d:"M6 6l12 12M18 6 6 18"}),gear:(0,L.jsxs)("g",{children:[(0,L.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,L.jsx)("path",{d:"M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1Z"})]}),sun:(0,L.jsxs)("g",{children:[(0,L.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,L.jsx)("path",{d:"M12 3v2M12 19v2M3 12h2M19 12h2M5.6 5.6l1.4 1.4M17 17l1.4 1.4M5.6 18.4 7 17M17 7l1.4-1.4"})]}),moon:(0,L.jsx)("path",{d:"M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5Z"}),auto:(0,L.jsxs)("g",{children:[(0,L.jsx)("circle",{cx:"12",cy:"12",r:"8"}),(0,L.jsx)("path",{d:"M12 4a8 8 0 0 1 0 16Z",fill:"currentColor",stroke:"none"})]}),tune:(0,L.jsxs)("g",{children:[(0,L.jsx)("path",{d:"M4 7h9M17 7h3M4 17h3M11 17h9"}),(0,L.jsx)("circle",{cx:"15",cy:"7",r:"2.2"}),(0,L.jsx)("circle",{cx:"9",cy:"17",r:"2.2"}),(0,L.jsx)("path",{d:"M4 12h16",opacity:".45"})]}),note:(0,L.jsxs)("g",{children:[(0,L.jsx)("path",{d:"M9 18V6l10-2v12"}),(0,L.jsx)("circle",{cx:"6.5",cy:"18",r:"2.5"}),(0,L.jsx)("circle",{cx:"16.5",cy:"16",r:"2.5"})]})};function W({name:e,size:n=22}){return(0,L.jsx)("svg",{width:n,height:n,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:un[e]})}var K=require("react/jsx-runtime");function Rt(){let e=V(),n=(0,je.useSyncExternalStore)(e.subscribe,e.getState),[t,s]=(0,je.useState)(!1),i=n.jobs.find(a=>a.state==="running"),o=n.jobs.filter(a=>a.state==="queued"),d=n.jobs.filter(a=>a.state==="done"||a.state==="failed").slice(-6).reverse();return!i&&!o.length&&!t?d.length?(0,K.jsx)("button",{className:"sl-pill sl-pill-quiet",onClick:()=>s(!0),title:"\u5B66\u6B4C\u8BB0\u5F55",children:(0,K.jsx)(W,{name:"note",size:16})}):null:(0,K.jsxs)("div",{className:"sl-pill-wrap",children:[(0,K.jsxs)("button",{className:`sl-pill ${i?"is-busy":""}`,onClick:()=>s(a=>!a),children:[i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)("span",{className:"sl-pill-fish",children:(0,K.jsx)(W,{name:"fish",size:16})}),(0,K.jsxs)("span",{className:"sl-pill-text",children:["\u6B63\u5728\u5B66\u300A",i.title,"\u300B \xB7 ",i.label]}),(0,K.jsx)("span",{className:"sl-pill-bar",children:(0,K.jsx)("i",{style:{width:`${Math.round(i.progress*100)}%`}})}),(0,K.jsxs)("span",{className:"sl-pill-pct",children:[Math.round(i.progress*100),"%"]})]}):(0,K.jsx)("span",{className:"sl-pill-text",children:o.length?`${o.length} \u9996\u5728\u6392\u961F`:"\u5B66\u6B4C\u8BB0\u5F55"}),o.length&&i?(0,K.jsxs)("span",{className:"sl-pill-more",children:["+",o.length]}):null]}),t?(0,K.jsxs)("div",{className:"sl-learnlist",children:[(0,K.jsxs)("div",{className:"sl-learnlist-head",children:[(0,K.jsx)("span",{children:"\u5B66\u6B4C"}),(0,K.jsx)("button",{className:"sl-ctl sl-small",onClick:()=>s(!1),title:"\u6536\u8D77",children:(0,K.jsx)(W,{name:"close",size:16})})]}),[...i?[i]:[],...o,...d].map(a=>(0,K.jsx)(gn,{job:a},a.id)),!i&&!o.length&&!d.length?(0,K.jsx)("div",{className:"sl-learnlist-empty",children:"\u8FD8\u6CA1\u6709\u5B66\u8FC7\u6B4C"}):null]}):null]})}function gn({job:e}){let n=V();return(0,K.jsxs)("div",{className:`sl-job is-${e.state}`,children:[(0,K.jsx)("img",{className:"sl-job-cover",src:J.coverUrl(e.id),alt:"",onError:t=>{t.target.style.visibility="hidden"}}),(0,K.jsxs)("div",{className:"sl-job-text",children:[(0,K.jsx)("div",{className:"sl-job-title",children:e.title}),(0,K.jsx)("div",{className:"sl-job-sub",children:e.state==="running"?`${e.label} \xB7 ${Math.round(e.progress*100)}%`:e.state==="queued"?"\u6392\u961F\u4E2D":e.state==="done"?"\u5B66\u4F1A\u4E86":`\u6CA1\u5B66\u6210\uFF1A${e.reason??""}`}),e.state==="running"?(0,K.jsx)("div",{className:"sl-job-bar",children:(0,K.jsx)("i",{style:{width:`${Math.round(e.progress*100)}%`}})}):null]}),e.state==="done"?(0,K.jsx)("button",{className:"sl-ctl sl-small",title:"\u64AD\u653E",onClick:()=>{n.playSong(e.id)},children:(0,K.jsx)(W,{name:"play",size:16})}):e.state==="queued"||e.state==="running"?(0,K.jsx)("button",{className:"sl-ctl sl-small",title:"\u53D6\u6D88",onClick:()=>{n.cancelJob(e.id)},children:(0,K.jsx)(W,{name:"close",size:16})}):null]})}function At(){let e=V(),n=(0,je.useSyncExternalStore)(e.subscribe,()=>e.state.toast),[t,s]=(0,je.useState)(n);return(0,je.useEffect)(()=>{if(!n)return;s(n);let i=window.setTimeout(()=>s(null),5200);return()=>clearTimeout(i)},[n]),t?(0,K.jsxs)("div",{className:"sl-toast",children:[(0,K.jsx)(W,{name:"fish",size:16}),(0,K.jsx)("span",{children:t.text}),t.songId?(0,K.jsx)("button",{className:"sl-toast-btn",onClick:()=>{e.playSong(t.songId),s(null)},children:"\u73B0\u5728\u542C"}):null]},t.id):null}var fe=require("react");var g=require("react/jsx-runtime"),mn=new Intl.Collator("zh-Hans-CN",{sensitivity:"base",numeric:!0});function Pt({onOpenNow:e,heroImage:n}){let t=V(),s=(0,fe.useSyncExternalStore)(t.subscribe,t.getState),[i,o]=(0,fe.useState)(""),[d,a]=(0,fe.useState)("recent"),c=(0,fe.useDeferredValue)(i.trim().toLowerCase()),u=(0,fe.useMemo)(()=>{let z=c?s.songs.filter(E=>`${E.title} ${E.artist} ${E.who}`.toLowerCase().includes(c)):s.songs.slice();return d==="title"&&z.sort((E,F)=>mn.compare(E.title,F.title)),z},[s.songs,c,d]),r=s.current?.id??s.queue[s.index],[m,b]=(0,fe.useState)(null),[p,k]=(0,fe.useState)("mine"),[X,P]=(0,fe.useState)(null),y=async(z=i)=>{let E=z.trim();if(E&&(k("bili"),!(m?.q===E&&m.hits))){b({q:E,hits:null});try{b({q:E,hits:await J.search(E)})}catch(F){b({q:E,hits:[],error:F.message})}}},U=z=>{if(z.id===r){e(),s.playing||t.toggle();return}t.playSong(z.id,u.map(E=>E.id)),e()};return(0,g.jsxs)("div",{className:"sl-library",children:[(0,g.jsxs)("div",{className:"sl-lib-scroll",children:[(0,g.jsx)("section",{className:"sl-hero",style:n?{backgroundImage:`url(${n})`}:void 0,children:(0,g.jsxs)("div",{className:"sl-hero-text",children:[(0,g.jsxs)("div",{className:"sl-hero-kicker",children:[(0,g.jsx)(W,{name:"fish",size:16})," \u5927\u80A5\u9C7C\u7684\u5531\u7247\u67B6"]}),(0,g.jsx)("div",{className:"sl-hero-title",children:"\u4ECA\u5929\u60F3\u542C\u5979\u5531\u4EC0\u4E48\uFF1F"}),(0,g.jsxs)("div",{className:"sl-hero-sub",children:["\u5979\u5DF2\u7ECF\u5B66\u4F1A\u4E86 ",s.songs.length," \u9996\u6B4C"]}),(0,g.jsxs)("div",{className:"sl-hero-actions",children:[(0,g.jsxs)("button",{className:"sl-btn sl-btn-primary",onClick:()=>{s.current?(s.playing||t.toggle(),e()):u[0]&&U(u[0])},children:[(0,g.jsx)(W,{name:"play",size:18})," ",s.current?"\u7EE7\u7EED\u64AD\u653E":"\u5F00\u59CB\u64AD\u653E"]}),(0,g.jsxs)("button",{className:"sl-btn",onClick:()=>{let z=u[Math.floor(Math.random()*u.length)];z&&(s.shuffle||t.toggleShuffle(),t.playSong(z.id,u.map(E=>E.id)),e())},children:[(0,g.jsx)(W,{name:"shuffle",size:18})," \u968F\u673A\u64AD\u653E"]})]})]})}),(0,g.jsxs)("header",{className:"sl-lib-head",children:[(0,g.jsx)("div",{className:"sl-lib-title",children:"\u5168\u90E8\u6B4C\u66F2"}),(0,g.jsxs)("div",{className:"sl-lib-tools",children:[(0,g.jsxs)("button",{className:"sl-btn sl-studio-btn",onClick:()=>t.openStudio(),title:"\u5B66\u6B4C\u8BBE\u7F6E\uFF1A\u73AF\u5883\u3001\u5979\u7684\u58F0\u97F3\u3001\u914D\u65B9",children:[(0,g.jsx)(W,{name:"gear",size:16})," \u5B66\u6B4C\u8BBE\u7F6E",s.learnMissing?(0,g.jsx)("span",{className:"sl-badge"}):null]}),(0,g.jsxs)("label",{className:"sl-search",children:[(0,g.jsx)(W,{name:"search",size:18}),(0,g.jsx)("input",{value:i,onChange:z=>{o(z.target.value),k("mine")},onKeyDown:z=>{z.key==="Enter"&&y()},placeholder:"\u627E\u6B4C\uFF1A\u5979\u4F1A\u5531\u7684\uFF1B\u56DE\u8F66\u53BB B \u7AD9\u627E"})]}),(0,g.jsxs)("div",{className:"sl-seg",role:"tablist",children:[(0,g.jsx)("button",{className:d==="recent"?"is-on":"",onClick:()=>a("recent"),children:"\u6700\u8FD1\u5B66\u4F1A"}),(0,g.jsx)("button",{className:d==="title"?"is-on":"",onClick:()=>a("title"),children:"\u6309\u6B4C\u540D"})]})]})]}),s.error&&!s.songs.length?(0,g.jsx)("div",{className:"sl-empty",children:s.error}):null,!s.error&&!s.songs.length?(0,g.jsx)("div",{className:"sl-empty",children:"\u6B4C\u5E93\u8FD8\u662F\u7A7A\u7684"}):null,c?(0,g.jsxs)("div",{className:"sl-tabs",children:[(0,g.jsxs)("button",{className:p==="mine"?"is-on":"",onClick:()=>k("mine"),children:["\u5979\u4F1A\u5531\u7684 ",(0,g.jsx)("em",{children:u.length})]}),(0,g.jsxs)("button",{className:p==="bili"?"is-on":"",onClick:()=>{y()},children:["B \u7AD9\u4E0A\u7684\u300C",i.trim(),"\u300D",m?.q===i.trim()&&m.hits?(0,g.jsx)("em",{children:m.hits.length}):null]})]}):null,c&&p==="bili"&&m?(0,g.jsx)(hn,{result:m,onClose:()=>k("mine"),onPick:P}):(0,g.jsxs)(g.Fragment,{children:[c&&!u.length?(0,g.jsxs)("div",{className:"sl-bili-bar",children:[(0,g.jsxs)("span",{children:["\u5979\u8FD8\u4E0D\u4F1A\u5531\u300C",i.trim(),"\u300D"]}),(0,g.jsxs)("button",{className:"sl-btn sl-btn-primary",onClick:()=>{y()},children:[(0,g.jsx)(W,{name:"search",size:16})," \u53BB B \u7AD9\u627E\u6765\u8BA9\u5979\u5B66"]})]}):null,(0,g.jsx)("div",{className:"sl-grid",children:u.map(z=>(0,g.jsx)(bn,{song:z,active:z.id===r,playing:z.id===r&&s.playing,onPlay:()=>U(z)},z.id))})]}),(0,g.jsx)("div",{className:"sl-lib-pad"})]}),(0,g.jsx)(vn,{onOpen:e}),X?(0,g.jsx)(fn,{hit:X,onClose:()=>P(null)}):null]})}function fn({hit:e,onClose:n}){let t=V(),[s,i]=(0,fe.useState)(e.guess),[o,d]=(0,fe.useState)("");return(0,g.jsx)("div",{className:"sl-modal",onClick:n,children:(0,g.jsxs)("div",{className:"sl-modal-card",onClick:a=>a.stopPropagation(),children:[(0,g.jsx)("img",{className:"sl-modal-cover",src:J.imgUrl(e.cover),alt:""}),(0,g.jsx)("div",{className:"sl-modal-title",children:"\u8BA9\u5979\u5B66\u8FD9\u9996"}),(0,g.jsxs)("div",{className:"sl-modal-sub",children:[e.title," \xB7 ",e.up]}),(0,g.jsxs)("label",{className:"sl-field",children:[(0,g.jsx)("span",{children:"\u6B4C\u540D"}),(0,g.jsx)("input",{value:s,onChange:a=>i(a.target.value),placeholder:"\u5BF9\u6B4C\u8BCD\u8981\u7528\uFF0C\u5199\u51C6\u4E00\u70B9",autoFocus:!0})]}),(0,g.jsxs)("label",{className:"sl-field",children:[(0,g.jsx)("span",{children:"\u6B4C\u624B"}),(0,g.jsx)("input",{value:o,onChange:a=>d(a.target.value),placeholder:"\u53EF\u4EE5\u4E0D\u586B"})]}),(0,g.jsxs)("div",{className:"sl-modal-actions",children:[(0,g.jsx)("button",{className:"sl-btn",onClick:n,children:"\u7B97\u4E86"}),(0,g.jsx)("button",{className:"sl-btn sl-btn-primary",disabled:!s.trim(),onClick:()=>{t.learn({bvid:e.bvid,page:e.page,title:s.trim(),artist:o.trim()}),n()},children:"\u5F00\u59CB\u5B66\uFF08\u5B66\u4F1A\u4E86\u5C31\u5531\u7ED9\u4F60\u542C\uFF09"})]})]})})}function hn({result:e,onClose:n,onPick:t}){let s=V(),i=(0,fe.useSyncExternalStore)(s.subscribe,s.getState),o=new Set(i.songs.map(u=>u.id)),d=new Set(i.jobs.filter(u=>u.state==="queued"||u.state==="running").map(u=>u.id)),a=u=>`${Math.floor(u/60)}:${String(Math.floor(u%60)).padStart(2,"0")}`,c=u=>u>=1e4?`${(u/1e4).toFixed(u>=1e5?0:1)}\u4E07`:String(u);return(0,g.jsxs)("section",{className:"sl-bili",children:[(0,g.jsxs)("div",{className:"sl-bili-head",children:[(0,g.jsxs)("div",{className:"sl-lib-title",children:["B \u7AD9\u4E0A\u7684\u300C",e.q,"\u300D"]}),(0,g.jsx)("button",{className:"sl-ctl sl-small",onClick:n,title:"\u6536\u8D77",children:(0,g.jsx)(W,{name:"close",size:18})})]}),i.learnMissing?(0,g.jsxs)("div",{className:"sl-bili-warn",children:["\u5B66\u6B4C\u8FD8\u6CA1\u8BBE\u7F6E\u597D\uFF1A",i.learnMissing]}):null,e.hits===null?(0,g.jsx)("div",{className:"sl-empty",children:"\u5728 B \u7AD9\u627E\u2026\u2026"}):null,e.error?(0,g.jsx)("div",{className:"sl-empty",children:e.error}):null,e.hits&&!e.hits.length&&!e.error?(0,g.jsx)("div",{className:"sl-empty",children:"B \u7AD9\u4E0A\u4E5F\u6CA1\u641C\u5230"}):null,(0,g.jsx)("div",{className:"sl-grid",children:(e.hits??[]).map(u=>{let r=`${u.bvid}-p${u.page}`,m=o.has(r)?"learned":d.has(r)?"learning":"";return(0,g.jsxs)("div",{className:"sl-card-item sl-hit",children:[(0,g.jsxs)("div",{className:"sl-card-cover",children:[(0,g.jsx)("img",{src:J.imgUrl(u.cover),alt:"",loading:"lazy"}),(0,g.jsxs)("span",{className:"sl-card-tag",children:[a(u.durationSec),u.views?` \xB7 ${c(u.views)}\u64AD\u653E`:""]})]}),(0,g.jsx)("div",{className:"sl-card-title",title:u.title,children:u.title}),(0,g.jsx)("div",{className:"sl-card-sub",children:u.up}),m==="learned"?(0,g.jsxs)("button",{className:"sl-btn sl-hit-btn",onClick:()=>{s.playSong(r)},children:[(0,g.jsx)(W,{name:"play",size:15})," \u5979\u4F1A\u5531\uFF0C\u542C\u542C"]}):m==="learning"?(0,g.jsx)("button",{className:"sl-btn sl-hit-btn",disabled:!0,children:"\u6B63\u5728\u5B66\u2026\u2026"}):(0,g.jsxs)("button",{className:"sl-btn sl-btn-primary sl-hit-btn",onClick:()=>t(u),children:[(0,g.jsx)(W,{name:"note",size:15})," \u5B66\u8FD9\u9996"]})]},r)})})]})}function bn({song:e,active:n,playing:t,onPlay:s}){let[i,o]=(0,fe.useState)(!1);return(0,g.jsxs)("button",{className:`sl-card-item ${n?"is-active":""}`,onClick:s,title:`${e.title} \u2014 ${e.artist}`,children:[(0,g.jsxs)("div",{className:"sl-card-cover",children:[i?(0,g.jsx)("div",{className:"sl-card-blank",children:(0,g.jsx)(W,{name:"note",size:30})}):(0,g.jsx)("img",{src:J.coverUrl(e.id),alt:"",loading:"lazy",onError:()=>o(!0)}),(0,g.jsx)("span",{className:"sl-card-play",children:t?(0,g.jsx)(xn,{}):(0,g.jsx)(W,{name:"play",size:20})}),e.hasLyrics?null:(0,g.jsx)("span",{className:"sl-card-tag",children:"\u65E0\u6B4C\u8BCD"})]}),(0,g.jsx)("div",{className:"sl-card-title",children:e.title}),(0,g.jsx)("div",{className:"sl-card-sub",children:e.artist||e.who||" "})]})}function xn(){return(0,g.jsxs)("span",{className:"sl-eq",children:[(0,g.jsx)("i",{}),(0,g.jsx)("i",{}),(0,g.jsx)("i",{})]})}function vn({onOpen:e}){let n=V(),t=(0,fe.useSyncExternalStore)(n.subscribe,n.getState);return t.current?(0,g.jsxs)("div",{className:"sl-mini",onClick:e,children:[(0,g.jsx)("img",{className:"sl-mini-cover",src:J.coverUrl(t.current.id),alt:""}),(0,g.jsxs)("div",{className:"sl-mini-text",children:[(0,g.jsx)("div",{className:"sl-mini-title",children:t.current.title}),(0,g.jsx)("div",{className:"sl-mini-sub",children:t.current.artist})]}),(0,g.jsx)("button",{className:"sl-ctl",onClick:s=>{s.stopPropagation(),n.step(-1)},title:"\u4E0A\u4E00\u9996",children:(0,g.jsx)(W,{name:"prev"})}),(0,g.jsx)("button",{className:"sl-ctl sl-play sl-play-sm",onClick:s=>{s.stopPropagation(),n.toggle()},title:t.playing?"\u6682\u505C":"\u64AD\u653E",children:(0,g.jsx)(W,{name:t.playing?"pause":"play"})}),(0,g.jsx)("button",{className:"sl-ctl",onClick:s=>{s.stopPropagation(),n.step(1)},title:"\u4E0B\u4E00\u9996",children:(0,g.jsx)(W,{name:"next"})})]}):null}var Fe=require("react");var N=require("react/jsx-runtime"),bt="/api/dsh-singinglab",Ye=(e,n)=>fetch(`${bt}/${e}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n)}).then(t=>t.json()),Ze=e=>e>=1e9?`${(e/1e9).toFixed(1)} GB`:`${Math.max(1,Math.round(e/1e6))} MB`;function zt({open:e,onClose:n}){let[t,s]=(0,Fe.useState)(null),[i,o]=(0,Fe.useState)(!1),[d,a]=(0,Fe.useState)(""),c=(0,Fe.useRef)(0),u=async()=>{try{let p=await fetch(`${bt}/studio`).then(k=>k.json());p.ok&&s(p)}catch{}};if((0,Fe.useEffect)(()=>{if(!e)return;u();let p=()=>{u(),c.current=window.setTimeout(p,t?.preparing?1e3:2500)};return c.current=window.setTimeout(p,1e3),()=>clearTimeout(c.current)},[e,t?.preparing]),!e)return null;let r=t?.models.filter(p=>p.downloading)??[],m=(t?.needs??[]).reduce((p,k)=>p+(k.bytes??0),0),b=async p=>{if(!p?.length)return;let k=[...p].find(U=>/\.pth$/i.test(U.name)),X=[...p].find(U=>/\.index$/i.test(U.name));if(!k){a("\u8981\u4E00\u4E2A .pth \u6587\u4EF6\uFF08RVC \u58F0\u97F3\u6A21\u578B\uFF09\uFF0C.index \u53EF\u4EE5\u4E00\u8D77\u62D6\u8FDB\u6765");return}a(`\u6B63\u5728\u5BFC\u5165 ${k.name}\u2026\u2026`);let P=(U,z,E)=>fetch(`${bt}/voice?kind=${z}&name=${encodeURIComponent(U.name)}${E?`&id=${E}`:""}`,{method:"POST",body:U}).then(F=>F.json()),y=await P(k,"model");if(!y.ok){a(`\u5BFC\u5165\u5931\u8D25\uFF1A${y.error}`);return}X&&await P(X,"index",y.id),a(`\u5BFC\u5165\u597D\u4E86\uFF1A${k.name.replace(/\.pth$/i,"")}`),u()};return(0,N.jsx)("div",{className:"sl-modal sl-studio-wrap",onClick:n,children:(0,N.jsxs)("div",{className:"sl-studio",onClick:p=>p.stopPropagation(),children:[(0,N.jsxs)("div",{className:"sl-studio-head",children:[(0,N.jsxs)("div",{children:[(0,N.jsx)("div",{className:"sl-studio-title",children:"\u5B66\u6B4C\u8BBE\u7F6E"}),(0,N.jsx)("div",{className:"sl-studio-sub",children:t?t.mode==="manual"?"\u7528\u7684\u662F\u4F60\u81EA\u5DF1\u7684\u5B66\u6B4C\u73AF\u5883\uFF08\u624B\u52A8\u6A21\u5F0F\uFF09":t.ready?"\u4E00\u5207\u5C31\u7EEA\uFF0C\u53EF\u4EE5\u5B66\u6B4C\u4E86":"\u8FD8\u5DEE\u51E0\u6837\uFF0C\u4E00\u952E\u8865\u4E0A":"\u2026\u2026"})]}),(0,N.jsx)("button",{className:"sl-ctl sl-small",onClick:n,title:"\u5173\u4E0A",children:(0,N.jsx)(W,{name:"close",size:18})})]}),t&&t.mode==="recipe"?(0,N.jsxs)(N.Fragment,{children:[t.ready?null:(0,N.jsxs)("section",{className:"sl-studio-card sl-studio-main",children:[(0,N.jsx)("div",{className:"sl-studio-need",children:t.needs.map(p=>(0,N.jsxs)("div",{className:"sl-need",children:[(0,N.jsx)("span",{className:`sl-dot is-${p.kind}`}),p.name,p.bytes?(0,N.jsx)("em",{children:Ze(p.bytes)}):null]},p.kind+(p.id??"")))}),t.needs.some(p=>p.kind!=="voice")?(0,N.jsx)("button",{className:"sl-btn sl-btn-primary sl-big",disabled:t.preparing,onClick:()=>{Ye("prepare",{}),setTimeout(u,500)},children:t.preparing?"\u6B63\u5728\u51C6\u5907\u2026\u2026\uFF08\u53EF\u4EE5\u5173\u6389\u8FD9\u91CC\uFF0C\u540E\u53F0\u7EE7\u7EED\uFF09":`\u4E00\u952E\u51C6\u5907\uFF08\u7EA6 ${Ze(m)}\uFF0C\u88C5\u5728\u63D2\u4EF6\u81EA\u5DF1\u7684\u76EE\u5F55\u91CC\uFF09`}):null,t.prepareError?(0,N.jsxs)("div",{className:"sl-studio-err",children:["\u6CA1\u88C5\u6210\uFF1A",t.prepareError,"\u3002\u7F51\u7EDC\u4E0D\u597D\u65F6\u518D\u70B9\u4E00\u6B21\u4F1A\u63A5\u7740\u88C5\u3002"]}):null,t.preparing||t.env.steps.some(p=>p.state!=="pending")?(0,N.jsxs)("div",{className:"sl-steps",children:[t.env.steps.map(p=>(0,N.jsxs)("div",{className:`sl-step is-${p.state}`,children:[(0,N.jsx)("span",{className:"sl-step-dot"}),p.name,p.detail?(0,N.jsx)("span",{className:"sl-step-detail",children:p.detail}):null]},p.id)),r.map(p=>(0,N.jsxs)("div",{className:"sl-step is-running",children:[(0,N.jsx)("span",{className:"sl-step-dot"}),"\u4E0B\u8F7D ",p.name,(0,N.jsxs)("span",{className:"sl-step-detail",children:[Ze(p.downloading.done)," / ",Ze(p.downloading.total)]}),(0,N.jsx)("div",{className:"sl-job-bar",children:(0,N.jsx)("i",{style:{width:`${p.downloading.done/Math.max(1,p.downloading.total)*100}%`}})})]},p.id))]}):null,!t.mirror&&t.needs.some(p=>p.kind==="model")?(0,N.jsx)("div",{className:"sl-studio-hint",children:"\u56FD\u5185\u6A21\u578B\u955C\u50CF\u8FD8\u6CA1\u914D\u7F6E\uFF1A\u90E8\u5206\u6A21\u578B\u8981\u4ECE Hugging Face \u4E0B\uFF0C\u56FD\u5185\u7F51\u7EDC\u53EF\u80FD\u4E0B\u4E0D\u52A8\u3002\u5DF2\u7ECF\u6709\u8FD9\u4E9B\u6A21\u578B\u7684\u8BDD\uFF0C\u53EF\u4EE5\u5728\u300C\u9AD8\u7EA7 \u2192 \u4ECE\u7535\u8111\u91CC\u5DF2\u6709\u7684\u6587\u4EF6\u5BFC\u5165\u300D\u3002"}):null]}),(0,N.jsxs)("section",{className:"sl-studio-card",children:[(0,N.jsx)("div",{className:"sl-studio-h",children:"\u5979\u7684\u58F0\u97F3"}),t.voices.length?(0,N.jsx)("div",{className:"sl-voices",children:t.voices.map(p=>(0,N.jsxs)("button",{className:`sl-voice ${p.id===t.voice?"is-on":""}`,onClick:()=>{Ye("voice-use",{id:p.id}).then(u)},children:[(0,N.jsx)(W,{name:"fish",size:16})," ",p.name,p.index?"":(0,N.jsx)("em",{children:" \xB7 \u6CA1\u6709 .index"})]},p.id))}):(0,N.jsx)("div",{className:"sl-studio-sub",children:"\u5B66\u6B4C\u8981\u4E00\u4E2A RVC \u58F0\u97F3\u6A21\u578B\uFF08.pth\uFF0C\u6700\u597D\u5E26\u4E0A\u540C\u540D\u7684 .index\uFF09\u3002"}),(0,N.jsxs)("label",{className:"sl-drop",onDragOver:p=>p.preventDefault(),onDrop:p=>{p.preventDefault(),b(p.dataTransfer.files)},children:[(0,N.jsx)("input",{type:"file",multiple:!0,accept:".pth,.index",onChange:p=>{b(p.target.files)}}),"\u628A .pth\uFF08\u548C .index\uFF09\u62D6\u5230\u8FD9\u91CC\uFF0C\u6216\u8005\u70B9\u8FD9\u91CC\u9009\u6587\u4EF6"]}),d?(0,N.jsx)("div",{className:"sl-studio-sub",children:d}):null]}),(0,N.jsx)("button",{className:"sl-adv-toggle",onClick:()=>o(p=>!p),children:i?"\u6536\u8D77\u9AD8\u7EA7\u8BBE\u7F6E":"\u9AD8\u7EA7\u8BBE\u7F6E\uFF1A\u914D\u65B9\u3001\u6A21\u578B\u8D27\u67B6"}),i?(0,N.jsx)(yn,{s:t,reload:u}):null]}):null]})})}function yn({s:e,reload:n}){let[t,s]=(0,Fe.useState)(""),[i,o]=(0,Fe.useState)(""),d=e.recipe.use,a=c=>{Ye("recipe",{id:"custom",custom:{...d,...c}}).then(n)};return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)("section",{className:"sl-studio-card",children:[(0,N.jsx)("div",{className:"sl-studio-h",children:"\u914D\u65B9"}),(0,N.jsxs)("div",{className:"sl-seg sl-recipes",children:[e.recipes.map(c=>(0,N.jsx)("button",{className:e.recipe.id===c.id?"is-on":"",onClick:()=>{Ye("recipe",{id:c.id}).then(n)},title:c.note,children:c.name},c.id)),(0,N.jsx)("button",{className:e.recipe.id==="custom"?"is-on":"",onClick:()=>a({}),children:"\u81EA\u5B9A\u4E49"})]}),(0,N.jsx)("div",{className:"sl-studio-sub",children:e.recipes.find(c=>c.id===e.recipe.id)?.note??"\u6BCF\u4E00\u6B65\u81EA\u5DF1\u9009\u3002"}),(0,N.jsx)("div",{className:"sl-chain",children:e.steps.map((c,u)=>{let r=e.models.filter(b=>b.step===c.id),m=d[c.id];return(0,N.jsxs)("div",{className:"sl-link",children:[(0,N.jsx)("span",{className:"sl-link-n",children:u+1}),(0,N.jsxs)("span",{className:"sl-link-name",children:[c.name,c.patch?(0,N.jsx)("em",{className:"sl-patch",children:"\u8865\u4E01"}):null]}),(0,N.jsx)("span",{className:"sl-link-ctl",children:c.id==="pitch"?(0,N.jsxs)("label",{className:"sl-switch",children:[(0,N.jsx)("input",{type:"checkbox",checked:!!m,onChange:b=>a({pitch:b.target.checked})}),(0,N.jsx)("i",{})]}):c.id==="key"?(0,N.jsxs)("select",{value:typeof m=="number"?"fixed":String(m),onChange:b=>a({key:b.target.value==="fixed"?0:b.target.value}),children:[(0,N.jsx)("option",{value:"auto",children:"\u81EA\u52A8\u6311\u5979\u8212\u670D\u7684\u8C03"}),(0,N.jsx)("option",{value:"none",children:"\u4E0D\u79FB\u8C03"}),(0,N.jsx)("option",{value:"fixed",children:"\u81EA\u5DF1\u5B9A"})]}):r.length?(0,N.jsxs)("select",{value:m?String(m):"",onChange:b=>a({[c.id]:b.target.value||null}),children:[c.optional?(0,N.jsx)("option",{value:"",children:"\u5173\u6389"}):null,r.map(b=>(0,N.jsxs)("option",{value:b.id,children:[b.name,b.installed?"":`\uFF08\u8981\u4E0B ${Ze(b.bytes)}\uFF09`]},b.id))]}):(0,N.jsx)("span",{className:"sl-link-fixed",children:c.id==="convert"?"RVC":"\u2014"})}),c.why?(0,N.jsx)("span",{className:"sl-link-why",children:c.why}):null]},c.id)})})]}),(0,N.jsxs)("section",{className:"sl-studio-card",children:[(0,N.jsx)("div",{className:"sl-studio-h",children:"\u6A21\u578B\u8D27\u67B6"}),e.models.map(c=>(0,N.jsxs)("div",{className:"sl-shelf-row",children:[(0,N.jsxs)("div",{className:"sl-shelf-text",children:[(0,N.jsxs)("div",{className:"sl-shelf-name",children:[c.name," ",(0,N.jsx)("em",{children:Ze(c.bytes)})]}),(0,N.jsxs)("div",{className:"sl-shelf-note",children:[c.note," \xB7 ",c.license]}),c.error?(0,N.jsx)("div",{className:"sl-studio-err",children:c.error}):null]}),c.installed?(0,N.jsx)("span",{className:"sl-shelf-ok",children:"\u5DF2\u4E0B\u597D"}):c.downloading?(0,N.jsxs)("span",{className:"sl-shelf-ok",children:[Math.round(c.downloading.done/Math.max(1,c.downloading.total)*100),"%"]}):(0,N.jsx)("button",{className:"sl-btn",onClick:()=>{Ye("model",{id:c.id}).then(n)},children:"\u4E0B\u8F7D"})]},c.id)),(0,N.jsxs)("div",{className:"sl-import",children:[(0,N.jsx)("input",{value:t,onChange:c=>s(c.target.value),placeholder:"\u7535\u8111\u91CC\u5DF2\u7ECF\u6709\u8FD9\u4E9B\u6A21\u578B\uFF1F\u586B\u6587\u4EF6\u5939\u8DEF\u5F84\uFF0C\u6309\u6587\u4EF6\u540D\u548C\u6821\u9A8C\u81EA\u52A8\u8BA4"}),(0,N.jsx)("button",{className:"sl-btn",onClick:async()=>{o("\u5728\u627E\u2026\u2026");let c=await Ye("import",{dirs:[t]});o(c.ok?c.imported.length?`\u5BFC\u5165\u4E86 ${c.imported.length} \u4E2A`:"\u6CA1\u627E\u5230\u5BF9\u5F97\u4E0A\u7684\u6587\u4EF6":c.error),n()},children:"\u5BFC\u5165"})]}),i?(0,N.jsx)("div",{className:"sl-studio-sub",children:i}):null]})]})}var T=cn(require("react"),1);var wn=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],$e=e=>69+12*Math.log2(e/440),nt=e=>440*2**((e-69)/12),st=e=>`${wn[(Math.round(e)%12+12)%12]}${Math.floor(Math.round(e)/12)-1}`;var it=58,Qe=76,vt=e=>e.flatMap(n=>n.kind==="cut"?[{kind:"cut",a:n.a}]:n.kind==="join"?[{kind:"join",a:n.a,b:n.b}]:[]),xt=(e,n,t)=>{let s=[];for(let i=n;i<t;i++)e[i]>0&&s.push($e(e[i]));return s.sort((i,o)=>i-o),s.length?s[s.length>>1]:0};function yt(e,n=[],t=0){let s=kn(e);for(let i of n)if(i.kind==="cut"){let o=i.a-t;s=s.flatMap(d=>o-d.a>=2&&d.b-o>=2?[{a:d.a,b:o,midi:xt(e,d.a,o)},{a:o,b:d.b,midi:xt(e,o,d.b)}]:[d])}else{let o=i.a-t,d=i.b-t,a=s.filter(r=>r.a<d&&r.b>o);if(a.length<2)continue;let c=Math.min(...a.map(r=>r.a)),u=Math.max(...a.map(r=>r.b));s=[...s.filter(r=>!a.includes(r)),{a:c,b:u,midi:xt(e,c,u)}].sort((r,m)=>r.a-m.a)}return s}function kn(e){let n=[],t=-1,s=i=>{if(t>=0&&i-t>=4){let o=Array.from(e.subarray(t,i)).map($e).sort((d,a)=>d-a);n.push({a:t,b:i,midi:o[o.length>>1]})}};for(let i=0;i<=e.length;i++){if(!(i<e.length&&e[i]>0)){s(i),t=-1;continue}if(t<0){t=i;continue}Math.abs($e(e[i])-$e(e[i-1]))>.8&&(s(i),t=i)}return n}function $t(e,n,t){let s=Float32Array.from(n??e);for(let i=0;i<t.length;i++){let o=t[i];if(o.kind==="cut"||o.kind==="join")continue;let d=Math.max(0,o.a),a=Math.min(s.length,o.b);if(o.kind==="snap"||o.kind==="tune"){let c=o.kind==="snap"?1:o.center,u=o.kind==="snap"?0:o.flatten;for(let r of yt(s.subarray(d,a),vt(t.slice(0,i)),d)){let m=r.midi+(Math.round(r.midi)-r.midi)*c;for(let b=d+r.a;b<d+r.b;b++)s[b]>0&&(s[b]=nt(m+($e(s[b])-r.midi)*(1-u)))}continue}for(let c=d;c<a;c++)if(o.kind==="source")s[c]=o.source==="raw"?e[c]:(n??e)[c];else if(o.kind==="draw"){let u=o.hz[c-o.a];s[c]>0&&u>0&&(s[c]=u)}else s[c]>0&&(s[c]*=2**(o.semitones/12))}return s}var w=require("react/jsx-runtime"),Mn=36,Lt=96,oe=46,de=34,wt=e=>`${Math.floor(e/60)}:${(e%60).toFixed(1).padStart(4,"0")}`,Dt=e=>e===0?"\u539F\u8C03":e>0?`\u5347 ${e}`:`\u964D ${-e}`,Le=(e,n,t)=>Math.min(t,Math.max(n,e)),Sn=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.platform),We=Sn?"\u2318":"Ctrl";function It(e){let n=atob(e),t=new Uint8Array(n.length);for(let s=0;s<n.length;s++)t[s]=n.charCodeAt(s);return new Float32Array(t.buffer)}function Ft(e){let n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),t="";for(let s=0;s<n.length;s+=32768)t+=String.fromCharCode(...n.subarray(s,s+32768));return btoa(t)}var at={orig:["\u539F\u66F2","\u4ECE B \u7AD9\u53D6\u4E0B\u6765\u7684\u539F\u66F2"],inst:["\u4F34\u594F","\u7B2C 1 \u6B65\u5206\u51FA\u6765\u7684\u4F34\u594F"],vocals:["\u4EBA\u58F0","\u7B2C 1 \u6B65\u53BB\u6389\u4F34\u594F\uFF1A\u4E3B\u5531\u548C\u548C\u58F0\u90FD\u5728"],lead:["\u4E3B\u5531","\u7B2C 2 \u6B65\u53BB\u6389\u548C\u58F0\uFF0C\u53EA\u5269\u4E3B\u5531\uFF08\u8FD8\u5E26\u7740\u6DF7\u54CD\uFF09\u3002\u548C\u58F0\u6CA1\u62C6\u5E72\u51C0\u7684\u5730\u65B9\uFF0C\u9891\u8C31\u4E0A\u8FD8\u770B\u5F97\u5230\u7B2C\u4E8C\u6761\u7EBF"],back:["\u548C\u58F0","\u7B2C 2 \u6B65\u62C6\u51FA\u6765\u7684\u548C\u58F0"],dry:["\u5E72\u58F0","\u7B2C 3 \u6B65\u4E3B\u5531\u53BB\u6389\u6DF7\u54CD\uFF1A\u5979\u5C31\u662F\u7167\u7740\u8FD9\u4E00\u8F68\u5531\u7684"]},qt=[0,1,.32,.1,.04],kt=class{ctx=new AudioContext;nodes=[];buffers=new Map;held=null;startedAt=0;offset=0;end=0;playing=null;onEnd=null;run=0;watch(n){let t=++this.run;n.onended=()=>{t!==this.run||!this.playing||(this.stop(),this.onEnd?.())}}wave(){return this.ctx.createPeriodicWave(new Float32Array(qt),new Float32Array(qt.length))}async buffer(n){let t=this.buffers.get(n);if(t)return t;let s=await fetch(n,{credentials:"same-origin"});if(!s.ok)throw new Error(`\u53D6\u97F3\u9891\u5931\u8D25\uFF08${s.status}\uFF09`);let i=await this.ctx.decodeAudioData(await s.arrayBuffer());return n.includes("name=phrase")||this.buffers.set(n,i),i}stop(){this.run++;for(let n of this.nodes)try{n.stop()}catch{}this.nodes=[],this.playing=null}get time(){return this.playing?this.offset+(this.ctx.currentTime-this.startedAt):this.offset}playBuffer(n,t,s,i,o=1,d){let a=this.ctx.createBufferSource();a.buffer=n;let c=this.ctx.createGain();c.gain.value=o,a.connect(c).connect(this.ctx.destination);let u=this.ctx.currentTime+.05;a.start(u,Math.max(0,t-s)),this.nodes.push(a),this.startedAt=u,this.offset=t,this.end=Math.min(d??1/0,s+n.duration),d!==void 0&&d<s+n.duration&&a.stop(u+(d-t)),this.playing=i,i!=="synth"&&this.watch(a)}playSynth(n,t,s,i,o){this.stop();let d=this.ctx.currentTime+.05;o&&this.playBuffer(o,s,0,"synth",.55);let a=this.ctx.createOscillator();a.setPeriodicWave(this.wave());let c=this.ctx.createGain();c.gain.value=0,a.connect(c).connect(this.ctx.destination);let u=2**(t/12),r=Math.floor(s*100),m=Math.min(n.length,Math.ceil(i*100)),b=-1,p=!1;for(let k=r;k<m;k++){let X=d+(k-r)/100,P=n[k]>0;if(P){let y=n[k]*u;Math.abs(y-b)>.3&&(a.frequency.setValueAtTime(y,X),b=y)}P!==p&&(c.gain.setTargetAtTime(P?.22:0,X,.012),p=P)}c.gain.setTargetAtTime(0,d+(m-r)/100,.02),a.start(d),a.stop(d+(m-r)/100+.05),this.nodes.push(a),this.startedAt=d,this.offset=s,this.end=i,this.playing="synth",this.watch(a)}holdTone(n){this.releaseTone(),this.ctx.resume();let t=this.ctx.currentTime,s=this.ctx.createOscillator();s.setPeriodicWave(this.wave()),s.frequency.value=n;let i=this.ctx.createGain();i.gain.value=0,i.gain.setTargetAtTime(.2,t,.015),s.connect(i).connect(this.ctx.destination),s.start(t),this.held={osc:s,g:i}}moveTone(n){this.held?.osc.frequency.setTargetAtTime(n,this.ctx.currentTime,.012)}releaseTone(){if(!this.held)return;let n=this.ctx.currentTime;this.held.g.gain.setTargetAtTime(0,n,.03),this.held.osc.stop(n+.25),this.held=null}},Nn=[["\u7A7A\u683C","\u64AD\u653E / \u505C\uFF08\u505C\u4E86\u56DE\u5230\u5F00\u59CB\u7684\u5730\u65B9\uFF09"],["\u6EDA\u8F6E / Shift+\u6EDA\u8F6E","\u7AD6\u7740\u6EDA / \u6A2A\u7740\u6EDA\uFF08\u89E6\u63A7\u677F\u4E24\u6307\u968F\u4FBF\u63A8\uFF09"],[`${We}+\u6EDA\u8F6E / Alt+\u6EDA\u8F6E`,"\u6A2A\u5411\u7F29\u653E / \u7EB5\u5411\u7F29\u653E\uFF08\u89E6\u63A7\u677F\u634F\u5408\u4E5F\u884C\uFF09"],["\u4E2D\u952E\u62D6","\u5E73\u79FB"],["F","\u7F29\u653E\u5230\u9009\u4E2D\u7684\u4E00\u6BB5\uFF08\u6CA1\u9009\u4E2D\u5C31\u6574\u9996\uFF09"],["V / 1","\u9009\u62E9\u5DE5\u5177"],["B / 2","\u753B\u7B14\uFF1A\u753B\u97F3\u9AD8\u7EBF\uFF08Shift \u76F4\u7EBF\uFF0C\u53F3\u952E\u62D6\u64E6\u6389\uFF09"],["K / 3","\u526A\u5200\uFF1A\u70B9\u97F3\u7B26\u526A\u6210\u4E24\u4E2A\uFF0C\u53CC\u51FB\u526A\u53E3\u5408\u56DE\u53BB"],["J","\u9009\u4E2D\u7684\u51E0\u4E2A\u97F3\u7B26\u5408\u5E76\u6210\u4E00\u4E2A"],["L","\u5FAA\u73AF\u64AD\u653E\uFF08\u8FB9\u5FAA\u73AF\u8FB9\u6539\uFF0C\u4E0B\u4E00\u5708\u5C31\u662F\u6539\u8FC7\u7684\uFF09"],["\u70B9 / Shift+\u70B9 / \u62D6\u7A7A\u767D","\u9009\u97F3\u7B26 / \u52A0\u9009 / \u6846\u4E00\u6BB5"],[`${We}+A / Esc`,"\u5168\u9009 / \u53D6\u6D88\u9009\u62E9"],["\u62D6\u97F3\u7B26 / Alt+\u62D6","\u6309\u534A\u97F3\u6539 / \u4E0D\u5438\u9644"],["\u2191 \u2193 / Shift+\u2191 \u2193","\u9009\u4E2D\u7684\u5347\u964D\u534A\u97F3 / \u516B\u5EA6"],["\u53CC\u51FB\u97F3\u7B26","\u5BF9\u51C6\u6700\u8FD1\u7684\u534A\u97F3"],["Delete","\u9009\u4E2D\u7684\u6062\u590D\u6210\u81EA\u52A8\u4FEE\u7684"],[`${We}+Z / ${We}+Shift+Z`,"\u64A4\u9500 / \u91CD\u505A"]];function Ht({id:e,onClose:n}){let[t,s]=(0,T.useState)(null),[i,o]=(0,T.useState)(null),[d,a]=(0,T.useState)([]),[c,u]=(0,T.useState)([]),[r,m]=(0,T.useState)(0),[b,p]=(0,T.useState)("vocals"),k=(0,T.useRef)("vocals");k.current=b;let[X,P]=(0,T.useState)("weak"),[y,U]=(0,T.useState)(null),[z,E]=(0,T.useState)(null),[F,j]=(0,T.useState)(null),[H,Z]=(0,T.useState)("synth"),[v,R]=(0,T.useState)(!1),[$,C]=(0,T.useState)({ops:"[]",key:0}),[_,O]=(0,T.useState)("select"),[h,te]=(0,T.useState)(!1),se=(0,T.useRef)(!1);se.current=h;let ge=(0,T.useRef)(null),Ee=(0,T.useRef)(null),[ne,le]=(0,T.useState)(null),[Te,ce]=(0,T.useState)(!1),pe=(0,T.useRef)(null),Ae=(0,T.useRef)(0),qe=(0,T.useRef)(0),He=(0,T.useRef)(null);(0,T.useEffect)(()=>{window.getSelection()?.removeAllRanges();let x=!0;return J.edit(e).then(I=>{x&&(s(I),a(I.state.ops),m(I.state.key),C({ops:JSON.stringify(I.state.ops),key:I.state.key}))}).catch(I=>x&&o({text:I.message,relearn:!!I.relearn})),pe.current=new kt,()=>{x=!1,pe.current?.stop(),pe.current?.releaseTone(),pe.current?.ctx.close()}},[e]);let lt=(0,T.useRef)(!1),Je=(0,T.useMemo)(()=>r!==$.key||JSON.stringify(d)!==$.ops,[d,r,$]);lt.current=Je;let Ke=(0,T.useSyncExternalStore)(V().subscribe,()=>V().state.edited);(0,T.useEffect)(()=>{if(!(!Ke||Ke.songId!==e||!t)){if(lt.current){j("\u5927\u80A5\u9C7C\u521A\u6539\u4E86\u8FD9\u9996\uFF1B\u4F60\u8FD9\u8FB9\u8FD8\u6709\u6CA1\u4FDD\u5B58\u7684\u6539\u52A8\uFF0C\u4FDD\u5B58\u4F1A\u76D6\u6389\u5979\u7684");return}J.edit(e).then(x=>{s({...x,savedAt:Ke.at}),a(x.state.ops),u([]),m(x.state.key),C({ops:JSON.stringify(x.state.ops),key:x.state.key}),j("\u5927\u80A5\u9C7C\u521A\u6539\u4E86\u8FD9\u9996\uFF0C\u5DF2\u7ECF\u6362\u6210\u5979\u6539\u5B8C\u7684")}).catch(()=>{})}},[Ke?.at]);let Ve=(0,T.useMemo)(()=>t?It(t.raw):null,[t]),f=(0,T.useMemo)(()=>t?.plan?It(t.plan):null,[t]),D=ne&&y?{...y,kind:"tune",center:ne.center/100,flatten:ne.flatten/100}:null,l=(0,T.useMemo)(()=>Ve?$t(Ve,f,D?[...d,D]:d):null,[Ve,f,d,D?.a,D?.b,ne?.center,ne?.flatten]),M=(0,T.useMemo)(()=>l?yt(l,vt(d)):[],[l,d]),Y=(0,T.useMemo)(()=>y?M.filter(x=>x.a<y.b&&x.b>y.a):[],[M,y]);window.__singinglabEditor={notes:M,ops:d,sel:y,playing:v,loop:h};let B=(0,T.useCallback)(x=>{a(I=>[...I,x]),u([])},[]),G=(0,T.useCallback)(()=>{a(x=>x.length?(u(I=>[...I,x[x.length-1]]),x.slice(0,-1)):x)},[]),Q=(0,T.useCallback)(()=>{u(x=>x.length?(a(I=>[...I,x[x.length-1]]),x.slice(0,-1)):x)},[]),ie=(0,T.useCallback)(()=>{pe.current?.playing&&(Ae.current=qe.current),pe.current?.stop(),R(!1)},[]),Ce=(0,T.useCallback)(async(x,I,Me)=>{let re=pe.current;if(!re||!t||!l)return;re.stop(),re.ctx.resume(),Z(x),qe.current=I,Ae.current=I,ge.current={from:I,to:Me};let ve=Me??t.durationSec;try{if(x==="synth"){E("\u51C6\u5907\u4F34\u594F\u2026");let ye=await re.buffer(J.editAudioUrl(e,"accomp",r)).catch(()=>null);E(null),re.playSynth(l,r,I,ve,ye)}else if(x==="her"){let ye=Me!==void 0?I:Math.max(0,I-.5),Oe=Me!==void 0?Me:Math.min(t.durationSec,I+8),ze=Ee.current;if(!ze||ze.f0!==l||ze.key!==r||ze.a!==ye||ze.b!==Oe){E("\u5979\u5728\u5531\u8FD9\u4E00\u6BB5\u2026");let Et=await J.editPhrase(e,ye,Oe,Ft(l),r),tn=await re.buffer(`${J.editAudioUrl(e,"phrase",r)}&t=${Date.now()}`);E(null),j(`\u8FD9\u4E00\u6BB5\u6E32\u67D3\u7528\u4E86 ${Et.renderSec} \u79D2`),ze={f0:l,key:r,a:ye,b:Oe,buf:tn,start:Et.start},Ee.current=ze}qe.current=ze.start,re.playBuffer(ze.buf,ze.start,ze.start,"her")}else if(x==="stem"){let ye=k.current;E(`\u53D6${at[ye][0]}\u2026`);let Oe=await re.buffer(J.editAudioUrl(e,ye,0));E(null),re.playBuffer(Oe,I,0,"stem",1,Me)}else{E("\u53D6\u6B4C\u5E93\u91CC\u7684\u7248\u672C\u2026");let ye=await re.buffer(`${J.audioUrl(e)}&v=${t.savedAt??0}`);E(null),re.playBuffer(ye,I,0,"mix",1,Me)}R(!0)}catch(ye){E(null),j(ye.message)}},[t,l,e,r]),De=(0,T.useRef)(Ce);De.current=Ce;let Re=(0,T.useRef)(H);Re.current=H;let me=(0,T.useCallback)((x,I)=>{setTimeout(()=>{De.current(Re.current,x,I)},0)},[]);(0,T.useEffect)(()=>{let x=pe.current;if(x)return x.onEnd=()=>{Ae.current=qe.current;let I=ge.current;se.current&&I?De.current(Re.current,I.from,I.to):R(!1)},()=>{x.onEnd=null}},[t]);let _e=(0,T.useCallback)(()=>{pe.current?.playing?ie():De.current(Re.current,y?y.a/100:Ae.current,y?y.b/100:void 0)},[y,ie]),Be=(0,T.useCallback)(x=>{y&&B({...y,kind:"shift",semitones:x})},[y,B]),Ue=(0,T.useCallback)(()=>{y&&B({...y,kind:"source",source:"plan"})},[y,B]),Ge=(0,T.useCallback)(()=>{y&&Y.length>=2&&B({...y,kind:"join"})},[y,Y,B]);(0,T.useEffect)(()=>{let x=I=>{let Me=I.target;if(Me&&(Me.tagName==="INPUT"||Me.tagName==="TEXTAREA"||Me.isContentEditable)||!t)return;let re=I.ctrlKey||I.metaKey,ve=I.key.toLowerCase(),ye=!0;I.code==="Space"?_e():re&&ve==="z"&&!I.shiftKey?G():re&&(ve==="z"&&I.shiftKey||ve==="y")?Q():re&&ve==="a"?U({a:0,b:t.frames}):I.key==="Escape"?Te?ce(!1):ne?le(null):U(null):I.key==="ArrowUp"||I.key==="ArrowDown"?Be((I.key==="ArrowUp"?1:-1)*(I.shiftKey?12:1)):I.key==="Delete"||I.key==="Backspace"?Ue():!re&&(ve==="v"||ve==="1")?O("select"):!re&&(ve==="b"||ve==="2")?O("draw"):!re&&(ve==="k"||ve==="3")?O("cut"):!re&&ve==="j"?Ge():!re&&ve==="l"?te(Oe=>!Oe):!re&&ve==="f"?He.current?.fit(y):I.key==="?"||I.shiftKey&&I.code==="Slash"?ce(Oe=>!Oe):ye=!1,ye&&(I.preventDefault(),I.stopPropagation())};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[t,y,Te,ne,_e,G,Q,Be,Ue,Ge]);let S=()=>{Je&&!window.confirm("\u6539\u52A8\u8FD8\u6CA1\u4FDD\u5B58\uFF0C\u786E\u5B9A\u79BB\u5F00\u5417\uFF1F")||(ie(),n())},ae=async()=>{if(!(!l||!t)){ie(),E("\u5979\u6B63\u5728\u6309\u6539\u597D\u7684\u97F3\u9AD8\u91CD\u65B0\u5531\u6574\u9996\uFF0C\u5927\u7EA6 20 \u79D2\u2026");try{let x=await J.editSave(e,Ft(l),r,d);s({...t,savedAt:x.editedAt}),C({ops:JSON.stringify(d),key:r}),j(`\u4FDD\u5B58\u597D\u4E86\uFF08${x.sec} \u79D2\uFF09\uFF0C\u64AD\u653E\u5668\u91CC\u5DF2\u7ECF\u6362\u6210\u65B0\u7684`),V().reloadSong(e)}catch(x){j(`\u6CA1\u4FDD\u5B58\u6210\uFF1A${x.message}`)}E(null)}},ue=async()=>{try{let x=V().state.songs.find(I=>I.id===e);if(!x?.bvid)throw new Error("\u8FD9\u9996\u4E0D\u662F\u4ECE B \u7AD9\u5B66\u7684\uFF0C\u91CD\u5B66\u4E0D\u4E86");await J.learn({bvid:x.bvid,page:Number(/-p(\d+)$/.exec(e)?.[1]??1),title:x.title,artist:x.artist,autoplay:!1,relearn:!0}),o({text:"\u5728\u91CD\u5B66\u4E86\uFF083\u20134 \u5206\u949F\uFF09\uFF0C\u5B66\u5B8C\u518D\u6253\u5F00\u5C31\u80FD\u4FEE",relearn:!1})}catch(x){o({text:x.message,relearn:!1})}},xe=t?`${t.title}${t.artist?` \xB7 ${t.artist}`:""}`:"",Pe=_==="draw"?"\u6309\u4F4F\u753B\u97F3\u9AD8\u7EBF \xB7 Shift \u753B\u76F4\u7EBF \xB7 \u53F3\u952E\u62D6\u64E6\u6389":_==="cut"?"\u70B9\u97F3\u7B26\u526A\u6210\u4E24\u4E2A \xB7 \u53CC\u51FB\u526A\u53E3\u5408\u56DE\u53BB":"\u62D6\u97F3\u7B26\u6539\u97F3\u9AD8 \xB7 \u62D6\u7A7A\u767D\u5904\u6846\u4E00\u6BB5 \xB7 \u7A7A\u683C\u8BD5\u542C \xB7 ? \u770B\u5FEB\u6377\u952E";return(0,w.jsxs)("div",{className:"sl-editor",role:"dialog","aria-label":"\u4FEE\u97F3",onDragStart:x=>x.preventDefault(),children:[(0,w.jsxs)("header",{className:"sl-ed-top",children:[(0,w.jsx)("button",{className:"sl-ed-back",onClick:S,title:"\u56DE\u53BB",children:(0,w.jsx)(W,{name:"down",size:18})}),(0,w.jsxs)("div",{className:"sl-ed-title",children:[(0,w.jsx)("b",{children:"\u4FEE\u97F3"}),(0,w.jsx)("span",{children:xe}),Je?(0,w.jsx)("i",{title:"\u6709\u6539\u52A8\u8FD8\u6CA1\u4FDD\u5B58"}):null]}),t?(0,w.jsxs)("div",{className:"sl-ed-key",title:"\u6574\u9996\u5347\u964D\u51E0\u4E2A\u534A\u97F3\uFF08\u5979\u5531\u7684\u8C03\uFF09",children:[(0,w.jsx)("button",{onClick:()=>m(x=>x-1),children:"\u2212"}),(0,w.jsxs)("span",{children:[Dt(r),r===t.state.autoKey?(0,w.jsx)("em",{children:"\u81EA\u52A8\u9009\u7684"}):(0,w.jsxs)("em",{children:["\u81EA\u52A8\u9009\u7684\u662F",Dt(t.state.autoKey)]})]}),(0,w.jsx)("button",{onClick:()=>m(x=>x+1),children:"+"})]}):null,t?(0,w.jsx)("button",{className:"sl-ed-save",disabled:!!z||!Je,onClick:()=>{ae()},children:Je?"\u4FDD\u5B58\u8FD9\u9996":"\u5DF2\u4FDD\u5B58"}):null]}),i?(0,w.jsxs)("div",{className:"sl-ed-empty",children:[(0,w.jsx)("p",{children:i.text}),i.relearn?(0,w.jsx)("button",{className:"sl-btn sl-btn-primary",onClick:()=>{ue()},children:"\u91CD\u5B66\u4E00\u904D"}):null]}):!t||!l||!Ve?(0,w.jsx)("div",{className:"sl-ed-empty",children:(0,w.jsx)("p",{children:"\u6B63\u5728\u8BFB\u8FD9\u9996\u6B4C\u7684\u97F3\u9AD8\u2026"})}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("div",{className:"sl-ed-bar",children:[(0,w.jsxs)("div",{className:"sl-ed-seg",title:"\u5DE5\u5177",children:[(0,w.jsx)("button",{className:_==="select"?"is-on":"",onClick:()=>O("select"),title:"\u9009\u62E9\uFF08V\uFF09",children:"\u9009\u62E9"}),(0,w.jsx)("button",{className:_==="draw"?"is-on":"",onClick:()=>O("draw"),title:"\u753B\u7B14\uFF1A\u753B\u97F3\u9AD8\u7EBF\uFF08B\uFF09",children:"\u753B\u7B14"}),(0,w.jsx)("button",{className:_==="cut"?"is-on":"",onClick:()=>O("cut"),title:"\u526A\u5200\uFF1A\u70B9\u97F3\u7B26\u526A\u6210\u4E24\u4E2A\uFF0C\u53CC\u51FB\u526A\u53E3\u5408\u56DE\u53BB\uFF08K\uFF09",children:"\u526A\u5200"})]}),(0,w.jsxs)("div",{className:"sl-ed-seg",title:"\u5B66\u6B4C\u7684\u6BCF\u4E00\u6B65\u5206\u51FA\u6765\u7684\u8F68\uFF1A\u5E95\u4E0B\u7684\u9891\u8C31\u770B\u54EA\u4E00\u8F68\uFF1B\u8BD5\u542C\u9009\u300C\u542C\u8FD9\u4E00\u8F68\u300D\u5C31\u542C\u5B83",children:[t.layers.map(x=>(0,w.jsx)("button",{className:b===x?"is-on":"",title:at[x][1],onClick:()=>{p(x),X==="off"&&P("weak"),H==="stem"&&pe.current?.playing&&me(Ae.current,ge.current?.to)},children:at[x][0]},x)),(0,w.jsx)("button",{onClick:()=>P(x=>x==="strong"?"weak":x==="weak"?"off":"strong"),title:"\u9891\u8C31\u4EAE\u5EA6",children:X==="strong"?"\u4EAE":X==="weak"?"\u6697":"\u5173"})]}),(0,w.jsxs)("div",{className:"sl-ed-seg",title:"\u8BD5\u542C\uFF08\u7A7A\u683C\uFF1A\u64AD\u653E / \u505C\uFF09",children:[(0,w.jsx)("button",{className:h?"is-on":"",onClick:()=>te(x=>!x),title:"\u5FAA\u73AF\u64AD\u653E\u9009\u4E2D\u7684\u4E00\u6BB5\uFF08L\uFF09\uFF1A\u8FB9\u5FAA\u73AF\u8FB9\u6539\uFF0C\u4E0B\u4E00\u5708\u5C31\u662F\u6539\u8FC7\u7684",children:(0,w.jsx)(W,{name:"repeat",size:15})}),["synth","her","stem","mix"].map(x=>(0,w.jsx)("button",{className:H===x?"is-on":"",onClick:()=>Z(x),title:x==="synth"?"\u957F\u7B1B\u6309\u5979\u8981\u5531\u7684\u97F3\u9AD8\u5439\uFF0C\u914D\u79FB\u597D\u8C03\u7684\u4F34\u594F":x==="her"?"\u5979\u7684\u58F0\u97F3\u5531\u8FD9\u4E00\u6BB5\uFF08\u53EA\u6E32\u67D3\u8FD9\u4E00\u6BB5\uFF09":x==="stem"?`\u542C\u5E95\u4E0B\u9891\u8C31\u7684\u90A3\u4E00\u8F68\uFF08\u73B0\u5728\u662F${at[b][0]}\uFF09`:"\u6B4C\u5E93\u91CC\u73B0\u5728\u7684\u7248\u672C",children:x==="synth"?"\u4E50\u5668\u97F3":x==="her"?"\u5979\u7684\u58F0\u97F3":x==="stem"?`\u542C${at[b][0]}`:"\u6B4C\u5E93\u91CC\u7684\u7248\u672C"},x))]}),(0,w.jsxs)("div",{className:"sl-ed-seg",title:"\u7F29\u653E",children:[(0,w.jsx)("button",{onClick:()=>He.current?.zoom(1/1.5),title:`\u7F29\u5C0F\uFF08${We}+\u6EDA\u8F6E\uFF09`,children:"\u2212"}),(0,w.jsx)("button",{onClick:()=>He.current?.zoom(1.5),title:`\u653E\u5927\uFF08${We}+\u6EDA\u8F6E\uFF09`,children:"+"}),(0,w.jsx)("button",{onClick:()=>He.current?.fit(y),title:"\u7F29\u653E\u5230\u9009\u4E2D\u7684\u4E00\u6BB5\uFF0C\u6CA1\u9009\u4E2D\u5C31\u6574\u9996\uFF08F\uFF09",children:y?"\u770B\u9009\u4E2D":"\u770B\u6574\u9996"})]}),(0,w.jsx)("span",{className:"sl-ed-hint",children:z??F??Pe}),(0,w.jsx)("button",{className:"sl-ed-help",onClick:()=>ce(x=>!x),title:"\u5FEB\u6377\u952E\uFF08?\uFF09",children:"?"})]}),(0,w.jsx)(En,{data:t,raw:Ve,f0:l,keyShift:r,layer:b,glow:X,sel:y,onSel:x=>{U(x),x||le(null)},tool:_,onOp:B,playSoon:me,preview:pe,playing:v,onPlaying:R,notes:M,head:Ae,playFrom:qe,apiRef:He,id:e}),(0,w.jsxs)("footer",{className:"sl-ed-foot",children:[(0,w.jsx)("span",{className:"sl-ed-sel",children:y?`\u9009\u4E2D ${wt(y.a/100)} \u2013 ${wt(y.b/100)}`:"\u6CA1\u9009\u4E2D"}),ne&&y?(0,w.jsxs)("div",{className:"sl-ed-tune",children:[(0,w.jsxs)("label",{title:"\u6BCF\u4E2A\u97F3\u7684\u4E2D\u5FC3\u5F80\u6700\u8FD1\u7684\u534A\u97F3\u632A\u591A\u5C11",children:["\u5BF9\u51C6 ",(0,w.jsx)("input",{type:"range",min:0,max:100,value:ne.center,onChange:x=>le({...ne,center:Number(x.target.value)})})," ",(0,w.jsxs)("b",{children:[ne.center,"%"]})]}),(0,w.jsxs)("label",{title:"\u97F3\u91CC\u7684\u8D77\u4F0F\uFF08\u98A4\u97F3\u3001\u6F02\u79FB\uFF09\u538B\u5E73\u591A\u5C11\uFF1B\u538B\u592A\u591A\u4F1A\u50CF\u673A\u5668",children:["\u62C9\u76F4 ",(0,w.jsx)("input",{type:"range",min:0,max:100,value:ne.flatten,onChange:x=>le({...ne,flatten:Number(x.target.value)})})," ",(0,w.jsxs)("b",{children:[ne.flatten,"%"]})]}),(0,w.jsx)("button",{onClick:()=>me(y.a/100,y.b/100),children:"\u542C\u4E00\u4E0B"}),(0,w.jsx)("button",{className:"is-primary",onClick:()=>{B({...y,kind:"tune",center:ne.center/100,flatten:ne.flatten/100}),le(null)},children:"\u5E94\u7528"}),(0,w.jsx)("button",{onClick:()=>le(null),children:"\u53D6\u6D88"})]}):(0,w.jsxs)("div",{className:"sl-ed-actions",children:[(0,w.jsx)("button",{disabled:!y,onClick:()=>Be(12),title:"Shift+\u2191",children:"\u5347\u516B\u5EA6"}),(0,w.jsx)("button",{disabled:!y,onClick:()=>Be(-12),title:"Shift+\u2193",children:"\u964D\u516B\u5EA6"}),(0,w.jsx)("button",{disabled:!y,onClick:()=>Be(1),title:"\u2191",children:"\u5347\u534A\u97F3"}),(0,w.jsx)("button",{disabled:!y,onClick:()=>Be(-1),title:"\u2193",children:"\u964D\u534A\u97F3"}),(0,w.jsx)("button",{disabled:!y,onClick:()=>le({center:100,flatten:0}),title:"\u4E2D\u5FC3\u5BF9\u51C6\u534A\u97F3\u3001\u538B\u5E73\u8D77\u4F0F\uFF0C\u50CF Melodyne \u7684\u97F3\u9AD8\u6821\u6B63\uFF08\u53CC\u51FB\u97F3\u7B26 = \u5BF9\u51C6\u8FD9\u4E2A\u97F3\uFF09",children:"\u5BF9\u51C6 / \u62C9\u76F4\u2026"}),(0,w.jsx)("button",{disabled:Y.length<2,onClick:Ge,title:"\u9009\u4E2D\u7684\u51E0\u4E2A\u97F3\u7B26\u5E76\u6210\u4E00\u4E2A\uFF0C\u62D6\u3001\u5BF9\u51C6\u90FD\u5F53\u4E00\u4E2A\u97F3\uFF08J\uFF09",children:"\u5408\u5E76"}),(0,w.jsx)("button",{disabled:!y,onClick:Ue,title:"\u6062\u590D\u6210\u81EA\u52A8\u4FEE\u7684\uFF08Delete\uFF09",children:"\u6062\u590D\u81EA\u52A8"}),(0,w.jsx)("button",{disabled:!y,onClick:()=>y&&B({...y,kind:"source",source:"raw"}),title:"\u8FD9\u4E00\u6BB5\u7528\u539F\u6765\u6D4B\u5230\u7684\u97F3\uFF08\u4E0D\u8981\u81EA\u52A8\u4FEE\uFF09",children:"\u7528\u6D4B\u5230\u7684"}),(0,w.jsx)("span",{className:"sl-ed-gap"}),(0,w.jsx)("button",{disabled:!d.length,onClick:G,title:`${We}+Z`,children:"\u64A4\u9500"}),(0,w.jsx)("button",{disabled:!c.length,onClick:Q,title:`${We}+Shift+Z`,children:"\u91CD\u505A"})]})]}),Te?(0,w.jsx)("div",{className:"sl-ed-keys",onClick:()=>ce(!1),children:(0,w.jsxs)("div",{onClick:x=>x.stopPropagation(),children:[(0,w.jsx)("h3",{children:"\u5FEB\u6377\u952E"}),(0,w.jsx)("dl",{children:Nn.map(([x,I])=>(0,w.jsxs)(T.default.Fragment,{children:[(0,w.jsx)("dt",{children:x}),(0,w.jsx)("dd",{children:I})]},x))})]})}):null]})]})}var pt=(e,n)=>!!n&&e.a<n.b&&e.b>n.a;function En(e){let{id:n,data:t,raw:s,f0:i,keyShift:o,layer:d,glow:a,sel:c,onSel:u,tool:r,onOp:m,playSoon:b,preview:p,playing:k,onPlaying:X,head:P,playFrom:y,apiRef:U,notes:z}=e,E=(0,T.useRef)(null),F=(0,T.useRef)(null),[j,H]=(0,T.useState)({w:900,h:480}),Z=(0,T.useRef)({t0:0,pps:90,top:80,spx:14}),[,v]=(0,T.useState)(0),R=(0,T.useCallback)(()=>v(f=>f+1),[]),$=(0,T.useRef)(null),C=(0,T.useRef)(null),_=(0,T.useRef)(null),O=t.durationSec,h=Z.current,te=j.w,se=j.h;window.__singinglabRoll={view:h,keyw:oe,ruler:de};let ge=()=>(te-oe)/h.pps,Ee=()=>(se-de)/h.spx,ne=()=>{h.pps=Le(h.pps,Math.max(4,(te-oe)/(O+2)),800),h.spx=Le(h.spx,6,32),h.t0=Le(h.t0,0,Math.max(0,O-ge()*.5)),h.top=Le(h.top,Mn+Ee(),Lt)},le=f=>oe+(f-h.t0)*h.pps,Te=f=>h.t0+(f-oe)/h.pps,ce=f=>de+(h.top-f)*h.spx,pe=f=>h.top-(f-de)/h.spx;(0,T.useEffect)(()=>{let f=z.map(D=>D.midi).sort((D,l)=>D-l);if(f.length){let D=f[Math.floor(f.length*.05)],l=f[Math.floor(f.length*.95)];h.top=Math.round((D+l)/2+Ee()/2),h.t0=Math.max(0,z[0].a/100-1.5)}ne(),R()},[z.length>0,se]),U.current={fit(f){let D=f?f.a/100:0,l=f?f.b/100:O,M=(l-D)*.08+.2;h.pps=(te-oe)/(l-D+M*2),h.t0=D-M;let Y=z.filter(B=>f?pt(B,f):!0).map(B=>B.midi);if(Y.length){let B=Math.min(...Y),G=Math.max(...Y);h.spx=Le((se-de)/(G-B+8),6,32),h.top=G+4}ne(),R()},zoom(f){let D=h.t0+ge()/2;h.pps*=f,h.t0=D-ge()/2,ne(),R()}},(0,T.useEffect)(()=>{let f=new Image;f.onload=()=>{_.current=f,R()},f.src=J.editSpecUrl(n,d),_.current=null,R()},[n,d,R]),(0,T.useEffect)(()=>{let f=E.current;if(!f)return;let D=new ResizeObserver(()=>H({w:f.clientWidth,h:f.clientHeight}));return D.observe(f),()=>D.disconnect()},[]),(0,T.useEffect)(()=>{if(!k)return;let f=0,D=()=>{let l=p.current;if(!l?.playing){X(!1),R();return}P.current=l.time,!$.current&&(P.current>h.t0+ge()*.92||P.current<h.t0)&&(h.t0=P.current-ge()*.1,ne()),R(),f=requestAnimationFrame(D)};return f=requestAnimationFrame(D),()=>cancelAnimationFrame(f)},[k]),(0,T.useEffect)(()=>{let f=E.current;if(!f)return;let D=l=>{l.preventDefault();let M=f.getBoundingClientRect(),Y=l.clientX-M.left,B=l.clientY-M.top,G=l.deltaMode===1?16:l.deltaMode===2?400:1,Q=l.deltaX*G,ie=l.deltaY*G;if(l.ctrlKey||l.metaKey){let Ce=Te(Y);h.pps*=Math.exp(-ie*.0025),h.t0=Ce-(Y-oe)/h.pps}else if(l.altKey){let Ce=pe(B);h.spx*=Math.exp(-(ie||Q)*.0025),h.top=Ce+(B-de)/h.spx}else l.shiftKey?h.t0+=(Q||ie)/h.pps:(h.t0+=Q/h.pps,h.top-=ie/h.spx/3);ne(),R()};return f.addEventListener("wheel",D,{passive:!1}),()=>f.removeEventListener("wheel",D)});let Ae=(f,D)=>{let l=Te(f)*100,M=pe(D);return z.find(Y=>l>=Y.a&&l<=Y.b&&(Math.abs(Math.round(Y.midi)-M)<.55||Math.abs(Y.midi-M)<.6))??null};(0,T.useEffect)(()=>{let f=F.current;if(!f)return;let D=window.devicePixelRatio||1;(f.width!==Math.round(te*D)||f.height!==Math.round(se*D))&&(f.width=Math.round(te*D),f.height=Math.round(se*D));let l=f.getContext("2d");l.setTransform(D,0,0,D,0,0),l.fillStyle="#0c1222",l.fillRect(0,0,te,se);let M=Te(te),Y=Math.floor(pe(se)),B=Math.ceil(h.top);for(let S=Y;S<=B;S++){let ae=[1,3,6,8,10].includes((S%12+12)%12);l.fillStyle=ae?"#0a0f1d":"#0e1528",l.fillRect(oe,ce(S+.5),te-oe,h.spx),S%12===0&&(l.fillStyle="rgba(255,255,255,.08)",l.fillRect(oe,ce(S-.5),te-oe,1))}l.fillStyle="rgba(120,190,255,.12)",l.fillRect(oe,ce(Qe-o+.5),te-oe,(Qe-it+1)*h.spx),l.strokeStyle="rgba(140,205,255,.6)",l.setLineDash([4,4]),l.lineWidth=1;for(let S of[Qe+.5,it-.5])l.beginPath(),l.moveTo(oe,ce(S-o)),l.lineTo(te,ce(S-o)),l.stroke();l.setLineDash([]);let G=_.current;G&&a!=="off"&&(l.save(),l.globalAlpha=a==="strong"?.9:.42,l.imageSmoothingEnabled=!0,l.drawImage(G,h.t0*100,(Lt-h.top)*3-.5,(M-h.t0)*100,(h.top-pe(se))*3,oe,de,te-oe,se-de),l.restore());let Q=h.pps>160?.5:h.pps>60?1:h.pps>20?5:15;l.fillStyle="rgba(255,255,255,.035)";for(let S=Math.ceil(h.t0/Q)*Q;S<M;S+=Q)l.fillRect(le(S),de,1,se-de);c&&(l.fillStyle="rgba(140,200,255,.08)",l.fillRect(le(c.a/100),de,(c.b-c.a)/100*h.pps,se-de));let ie=$.current;ie?.kind==="erase"&&(l.fillStyle="rgba(255,200,120,.1)",l.fillRect(le(ie.a/100),de,(ie.b-ie.a+1)/100*h.pps,se-de));let Ce=Math.max(0,Math.floor(h.t0*100)-1),De=Math.min(i.length,Math.ceil(M*100)+1);l.strokeStyle="rgba(255,170,90,.85)",l.lineWidth=1.5,l.setLineDash([3,3]),l.beginPath();let Re=!1;for(let S=Ce;S<De;S++){if(!(s[S]>0&&i[S]>0&&Math.abs($e(s[S])-$e(i[S]))>1)){Re=!1;continue}let ue=le(S/100),xe=ce($e(s[S]));Re?l.lineTo(ue,xe):l.moveTo(ue,xe),Re=!0}l.stroke(),l.setLineDash([]);let me=ie?.kind==="note"?ie:null,_e=C.current?.note??null;l.font="600 10px system-ui, sans-serif",l.textBaseline="middle";for(let S of z){if(S.b/100<h.t0||S.a/100>M)continue;let ae=me&&pt(S,me.range)?me.d:0,ue=Math.round(S.midi+ae),xe=ue+o>Qe||ue+o<it,Pe=pt(S,c),x=le(S.a/100),I=Math.max(3,(S.b-S.a)/100*h.pps-1),Me=ce(ue)-h.spx*.46,re=h.spx*.92;l.fillStyle=xe?Pe?"rgba(255,120,145,.95)":"rgba(236,92,118,.72)":Pe?"rgba(96,168,255,.98)":"rgba(62,126,224,.72)",l.beginPath(),l.roundRect(x,Me,I,re,3),l.fill(),l.lineWidth=Pe||_e===S?1.6:1,l.strokeStyle=Pe?"#ffffff":_e===S?"rgba(220,236,255,.95)":xe?"rgba(255,170,185,.7)":"rgba(160,205,255,.6)",l.stroke(),I>30&&h.spx>=10&&(l.fillStyle="rgba(255,255,255,.95)",l.fillText(st(ue+o),x+4,ce(ue)+.5))}l.strokeStyle="#ffffff",l.lineWidth=1.6,l.beginPath(),Re=!1;for(let S=Ce;S<De;S++){if(!(i[S]>0)){Re=!1;continue}let ae=me&&S>=me.range.a&&S<me.range.b?me.d:0,ue=le(S/100),xe=ce($e(i[S])+ae);Re?l.lineTo(ue,xe):l.moveTo(ue,xe),Re=!0}l.stroke(),l.fillStyle="#0c1222";for(let S=1;S<z.length;S++){let ae=z[S];z[S-1].b!==ae.a||ae.a/100<h.t0||ae.a/100>M||l.fillRect(le(ae.a/100)-1,ce(Math.round(ae.midi))-h.spx*.5,2,h.spx)}if(r==="cut"&&C.current?.note&&!ie){let S=le(Math.round(Te(C.current.x)*100)/100),ae=C.current.note;l.strokeStyle="#ffd866",l.lineWidth=1.5,l.setLineDash([3,2]),l.beginPath(),l.moveTo(S,ce(Math.round(ae.midi))-h.spx*1.2),l.lineTo(S,ce(Math.round(ae.midi))+h.spx*1.2),l.stroke(),l.setLineDash([])}if(ie?.kind==="draw"&&ie.hz.size){l.strokeStyle="#ffd866",l.lineWidth=2.2,l.beginPath();let S=-2;for(let[ae,ue]of[...ie.hz.entries()].sort((xe,Pe)=>xe[0]-Pe[0])){let xe=le(ae/100),Pe=ce($e(ue));ae===S+1?l.lineTo(xe,Pe):l.moveTo(xe,Pe),S=ae}l.stroke()}l.fillStyle="#0a0e1a",l.fillRect(0,de,oe,se-de);let Be=C.current?Math.round(pe(C.current.y)):null;for(let S=Y;S<=B;S++){let ae=[1,3,6,8,10].includes((S%12+12)%12);l.fillStyle=S===Be?"#7fb8ff":ae?"#1b2236":"#d9e2f2",l.fillRect(0,ce(S+.5)+.5,ae?oe*.62:oe-1,h.spx-1),S%12===0&&h.spx>=8&&(l.fillStyle="#1b2236",l.font="10px system-ui, sans-serif",l.fillText(st(S),4,ce(S)))}l.fillStyle="#0a0e1a",l.fillRect(0,0,te,de),l.fillStyle="rgba(220,230,250,.55)",l.font="10px system-ui, sans-serif",l.textBaseline="top";let Ue=Q*(h.pps>60?5:2);for(let S=Math.ceil(h.t0/Q)*Q;S<M;S+=Q)l.fillRect(le(S),0,1,Math.abs(S/Ue-Math.round(S/Ue))<1e-6?8:4),Math.abs(S/Ue-Math.round(S/Ue))<1e-6&&l.fillText(wt(S).replace(/\.0$/,""),le(S)+3,1);l.font="12px system-ui, sans-serif",l.fillStyle="rgba(235,242,255,.85)";for(let S of t.lyrics)S.end<h.t0||S.start>M||l.fillText(S.text,Math.max(oe+2,le(S.start)),15);P.current>=h.t0&&P.current<=M&&(l.fillStyle="#7fd0ff",l.fillRect(le(P.current)-.75,0,1.5,se));let Ge=me?`${me.d>0?"+":""}${Number.isInteger(me.d)?me.d:me.d.toFixed(1)} \u534A\u97F3 \u2192 ${st(me.note.midi+me.d+o)}`:_e&&C.current&&!ie?(()=>{let S=Math.round((_e.midi-Math.round(_e.midi))*100);return`${st(_e.midi+o)}${S?` ${S>0?"\u504F\u9AD8":"\u504F\u4F4E"} ${Math.abs(S)} \u97F3\u5206`:" \u6B63\u597D"}`})():null;if(Ge&&C.current){l.font="600 12px system-ui, sans-serif";let S=l.measureText(Ge).width+14,ae=Le(C.current.x+14,oe,te-S-4),ue=Le(C.current.y-30,de+2,se-26);l.fillStyle="rgba(8,12,24,.88)",l.beginPath(),l.roundRect(ae,ue,S,22,6),l.fill(),l.fillStyle="#eaf2ff",l.textBaseline="middle",l.fillText(Ge,ae+7,ue+11)}});let qe=f=>{let D=F.current.getBoundingClientRect();return{px:f.clientX-D.left,py:f.clientY-D.top}},He=(f,D,l,M,Y)=>{let[B,G]=D<=M?[D,M]:[M,D];for(let Q=Math.max(0,B);Q<=Math.min(i.length-1,G);Q++){if(!(i[Q]>0))continue;let ie=B===G?Y:l+(Y-l)*((Q-D)/(M-D));f.hz.set(Q,nt(ie))}},lt=f=>{f.preventDefault();let{px:D,py:l}=qe(f);try{f.target.setPointerCapture(f.pointerId)}catch{}if(f.button===1){f.preventDefault(),$.current={kind:"pan",x0:D,y0:l,t0:h.t0,top:h.top};return}if(D<oe)return;if(l<de){P.current=Le(Te(D),0,O),$.current={kind:"scrub"},R();return}let M=Le(Math.round(Te(D)*100),0,i.length-1);if(r==="cut"){let B=Ae(D,l);B&&f.button===0&&M-B.a>=2&&B.b-M>=2&&(m({a:M,b:M+1,kind:"cut"}),u(null));return}if(r==="draw"){if(f.button===2){$.current={kind:"erase",a:M,b:M},R();return}let B=pe(l),G={kind:"draw",hz:new Map,last:{i:M,m:B},start:{i:M,m:B}};$.current=G,He(G,M,B,M,B),R();return}if(f.button!==0)return;let Y=Ae(D,l);if(Y){let B=pt(Y,c),G=f.shiftKey&&c?{a:Math.min(c.a,Y.a),b:Math.max(c.b,Y.b)}:B&&c?c:{a:Y.a,b:Y.b};u(G),$.current={kind:"note",note:Y,range:G,y0:l,d:0},p.current?.holdTone(nt(Y.midi+o))}else $.current={kind:"sel",a:M,x0:D,moved:!1,base:f.shiftKey?c:null};R()},Je=f=>{let{px:D,py:l}=qe(f);C.current={x:D,y:l,note:Ae(D,l)};let M=$.current,Y=F.current;if(!M){Y.style.cursor=D<oe||l<de?"default":r==="draw"?"crosshair":r==="cut"?C.current.note?"col-resize":"default":C.current.note?"ns-resize":"default",R();return}let B=Le(Math.round(Te(D)*100),0,i.length-1);if(M.kind==="pan")h.t0=M.t0-(D-M.x0)/h.pps,h.top=M.top+(l-M.y0)/h.spx,ne();else if(M.kind==="scrub")P.current=Le(Te(D),0,O);else if(M.kind==="note"){let G=(M.y0-l)/h.spx,Q=f.altKey?Math.round(G*10)/10:Math.round(G);Q!==M.d&&(M.d=Q,p.current?.moveTone(nt(M.note.midi+Q+o)))}else if(M.kind==="sel"){if(Math.abs(D-M.x0)>3&&(M.moved=!0),M.moved){let G={a:Math.min(M.a,B),b:Math.max(M.a,B)};u(M.base?{a:Math.min(M.base.a,G.a),b:Math.max(M.base.b,G.b)}:G)}}else if(M.kind==="draw"){let G=pe(l);f.shiftKey?(M.hz.clear(),He(M,M.start.i,M.start.m,B,G)):He(M,M.last.i,M.last.m,B,G),M.last={i:B,m:G}}else M.kind==="erase"&&(M.a=Math.min(M.a,B),M.b=Math.max(M.b,B));R()},Ke=()=>{let f=$.current;if($.current=null,!!f){if(f.kind==="note")p.current?.releaseTone(),f.d&&(m({...f.range,kind:"shift",semitones:f.d}),b(Math.max(0,f.range.a/100-.3),f.range.b/100+.3));else if(f.kind==="sel")f.moved||(u(f.base),f.base||(P.current=f.a/100));else if(f.kind==="draw"){if(f.hz.size){let D=[...f.hz.keys()],l=Math.min(...D),M=Math.max(...D)+1,Y=Array.from({length:M-l},(B,G)=>{let Q=0,ie=0;for(let Ce=-1;Ce<=1;Ce++){let De=f.hz.get(l+G+Ce);De&&(Q+=De,ie++)}return f.hz.has(l+G)&&ie?Math.round(Q/ie*10)/10:0});m({a:l,b:M,kind:"draw",hz:Y}),u({a:l,b:M}),b(Math.max(0,l/100-.3),M/100+.3)}}else f.kind==="erase"&&(m({a:f.a,b:f.b+1,kind:"source",source:"plan"}),u({a:f.a,b:f.b+1}));R()}};return(0,w.jsxs)("div",{className:"sl-ed-main",children:[(0,w.jsxs)("div",{className:"sl-ed-roll",ref:E,children:[(0,w.jsx)("canvas",{ref:F,style:{width:te,height:se},onPointerDown:lt,onPointerMove:Je,onPointerUp:Ke,onPointerCancel:Ke,onPointerLeave:()=>{C.current=null,R()},onDoubleClick:f=>{let{px:D,py:l}=qe(f);if(r==="cut"){let Y=Math.round(Te(D)*100),B=z.findIndex((G,Q)=>Q>0&&z[Q-1].b===G.a&&Math.abs(G.a-Y)<=Math.max(3,6/h.pps*100));B>0&&m({a:z[B-1].a,b:z[B].b,kind:"join"});return}if(r!=="select")return;let M=Ae(D,l);M&&(m({a:M.a,b:M.b,kind:"snap"}),u({a:M.a,b:M.b}),b(Math.max(0,M.a/100-.3),M.b/100+.3))},onContextMenu:f=>f.preventDefault(),onMouseDown:f=>{f.button===1&&f.preventDefault()}}),(0,w.jsxs)("div",{className:"sl-ed-legend",children:[(0,w.jsxs)("span",{children:[(0,w.jsx)("i",{className:"w"}),"\u5979\u8981\u5531\u7684\u97F3"]}),(0,w.jsxs)("span",{children:[(0,w.jsx)("i",{className:"o"}),"\u539F\u6765\u6D4B\u5230\u7684\uFF08\u88AB\u548C\u58F0\u5E26\u504F\u7684\u5730\u65B9\uFF09"]}),(0,w.jsxs)("span",{children:[(0,w.jsx)("i",{className:"b"}),"\u5979\u5531\u7740\u4E0D\u54D1\u7684\u97F3\u57DF"]}),(0,w.jsxs)("span",{children:[(0,w.jsx)("i",{className:"r"}),"\u51FA\u4E86\u97F3\u57DF\u7684\u97F3"]})]})]}),(0,w.jsx)(Tn,{notes:z,dur:O,view:h,span:ge(),head:P.current,sel:c,keyShift:o,onJump:f=>{h.t0=f-ge()/2,ne(),R()}})]})}function Tn({notes:e,dur:n,view:t,span:s,head:i,sel:o,keyShift:d,onJump:a}){let c=(0,T.useRef)(null),[u,r]=(0,T.useState)(800),m=40;(0,T.useEffect)(()=>{let P=c.current?.parentElement;if(!P)return;let y=new ResizeObserver(()=>r(P.clientWidth));return y.observe(P),()=>y.disconnect()},[]);let b=(0,T.useMemo)(()=>e.map(P=>P.midi),[e]),p=b.length?Math.min(...b)-1:48,k=b.length?Math.max(...b)+1:72;(0,T.useEffect)(()=>{let P=c.current;if(!P)return;let y=window.devicePixelRatio||1;P.width=Math.round(u*y),P.height=Math.round(m*y);let U=P.getContext("2d");U.setTransform(y,0,0,y,0,0),U.fillStyle="#0a0e1a",U.fillRect(0,0,u,m);let z=F=>F/n*u,E=F=>m-4-(F-p)/(k-p)*(m-8);o&&(U.fillStyle="rgba(140,200,255,.14)",U.fillRect(z(o.a/100),0,Math.max(2,z((o.b-o.a)/100)),m));for(let F of e){let j=Math.round(F.midi),H=j+d>Qe||j+d<it;U.fillStyle=H?"rgba(236,92,118,.85)":"rgba(110,170,255,.8)",U.fillRect(z(F.a/100),E(j)-1,Math.max(1,z((F.b-F.a)/100)),2)}U.strokeStyle="rgba(255,255,255,.7)",U.lineWidth=1,U.strokeRect(z(t.t0)+.5,.5,Math.max(4,z(s))-1,m-1),U.fillStyle="#7fd0ff",U.fillRect(z(i),0,1.5,m)});let X=P=>{let y=c.current.getBoundingClientRect();a((P.clientX-y.left)/y.width*n)};return(0,w.jsx)("div",{className:"sl-ed-overview",title:"\u6574\u9996\uFF1A\u70B9 / \u62D6 \u8DF3\u8FC7\u53BB",children:(0,w.jsx)("canvas",{ref:c,style:{width:u,height:m},onPointerDown:P=>{P.preventDefault();try{P.target.setPointerCapture(P.pointerId)}catch{}X(P)},onPointerMove:P=>{P.buttons&1&&X(P)}})})}var ee=require("react");var Se=require("react");var ut=require("react");var Ot=require("react/jsx-runtime");function _t({spec:e,p:n,w:t,h:s}){let i=(0,ut.useRef)(null),o=e.fx??[];return(0,ut.useEffect)(()=>{let d=i.current,a=d?.getContext("2d");if(!d||!a||!t||!s||!o.length)return;let c=Math.min(2,window.devicePixelRatio||1);d.width=Math.round(t*c),d.height=Math.round(s*c);let u=V(),r=e.width*n.scale,m=e.height*n.scale,b=H=>n.left+H*r,p=H=>n.top+H*m,k=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1,X=o.filter(H=>H.type==="rainfall").map(H=>{let Z=H.rects.map(C=>({x:b(C.x),y:p(C.y),w:C.w*r,h:C.h*m})),v=Z.reduce((C,_)=>C+_.w*_.h,0),R=Math.round(v/9e3*(H.density??1)),$=Array.from({length:R},()=>P(Z,!0));return{rects:Z,drops:$}});function P(H,Z){let v=H[Math.floor(Math.random()*H.length)];return{x:v.x+Math.random()*v.w,y:Z?v.y+Math.random()*v.h:v.y-20,len:8+Math.random()*16,v:700+Math.random()*500,a:.12+Math.random()*.22}}let y=o.filter(H=>H.type==="birds").map(H=>({f:H,birds:[],next:3+Math.random()*6})),U=0,z=performance.now(),E=0,F=0,j=H=>{if(U=requestAnimationFrame(j),document.hidden)return;let Z=Math.min(.1,(H-z)/1e3);z=H,k||(E+=Z),F+=(u.energy()-F)*Math.min(1,Z*6),a.setTransform(c,0,0,c,0,0),a.clearRect(0,0,t,s),a.globalCompositeOperation="lighter";for(let v of o)if(v.type==="glow"){let R=.92+.08*Math.sin(E*1.7)+.04*Math.sin(E*7.3)*Math.sin(E*.37),$=v.strength*R*(1+F*.35),C=v.r*r,_=a.createRadialGradient(b(v.x),p(v.y),0,b(v.x),p(v.y),C);_.addColorStop(0,`rgba(${v.color},${($*.55).toFixed(3)})`),_.addColorStop(.35,`rgba(${v.color},${($*.22).toFixed(3)})`),_.addColorStop(1,`rgba(${v.color},0)`),a.fillStyle=_,a.fillRect(b(v.x)-C,p(v.y)-C,C*2,C*2)}else if(v.type==="lighthouse"){let R=E/v.period*Math.PI*2,$=Math.sin(R),C=Math.max(0,Math.cos(R)),_=b(v.x),O=p(v.y),h=v.len*r*Math.abs($);if(h>2){let ge=m*.018,Ee=a.createLinearGradient(_,O,_+$*v.len*r,O);Ee.addColorStop(0,"rgba(255,236,190,0.55)"),Ee.addColorStop(.5,"rgba(255,236,190,0.16)"),Ee.addColorStop(1,"rgba(255,236,190,0)"),a.fillStyle=Ee,a.beginPath(),a.moveTo(_,O-2),a.lineTo(_+Math.sign($)*h,O-ge),a.lineTo(_+Math.sign($)*h,O+ge*.6),a.lineTo(_,O+2),a.closePath(),a.fill()}let te=m*(.012+C*.035),se=a.createRadialGradient(_,O,0,_,O,te);se.addColorStop(0,`rgba(255,244,214,${(.5+C*.5).toFixed(3)})`),se.addColorStop(1,"rgba(255,244,214,0)"),a.fillStyle=se,a.fillRect(_-te,O-te,te*2,te*2)}a.globalCompositeOperation="source-over",a.lineCap="round";for(let v of X){a.save(),a.beginPath();for(let R of v.rects)a.rect(R.x,R.y,R.w,R.h);a.clip(),a.lineWidth=1;for(let R=0;R<v.drops.length;R++){let $=v.drops[R];$.y+=$.v*Z,$.x-=$.v*Z*.08,v.rects.every(C=>$.y>C.y+C.h)&&(v.drops[R]=P(v.rects,!1)),a.strokeStyle=`rgba(200,220,255,${$.a.toFixed(3)})`,a.beginPath(),a.moveTo($.x,$.y),a.lineTo($.x+$.len*.08,$.y-$.len),a.stroke()}a.restore()}for(let v of y){let R=v.f.rect;if(v.next-=Z,v.next<=0&&!v.birds.length){let $=Math.random()<.5?1:-1,C=1+Math.floor(Math.random()*3),_=p(R.y+Math.random()*R.h);for(let O=0;O<C;O++)v.birds.push({x:$>0?b(R.x)-20-O*26:b(R.x+R.w)+20+O*26,y:_+(Math.random()-.5)*30,v:26+Math.random()*14,s:m*(.007+Math.random()*.004),ph:Math.random()*6,dir:$});v.next=v.f.every*(.7+Math.random()*.6)}a.strokeStyle="rgba(70,90,120,0.75)",a.lineWidth=1.4;for(let $=v.birds.length-1;$>=0;$--){let C=v.birds[$];C.x+=C.dir*C.v*Z,C.y+=Math.sin(E*.6+C.ph)*4*Z;let _=Math.sin(E*6+C.ph),O=C.s,h=O*(.35+.45*_);a.beginPath(),a.moveTo(C.x-O,C.y-h),a.quadraticCurveTo(C.x-O*.45,C.y-h*.2-O*.25,C.x,C.y),a.quadraticCurveTo(C.x+O*.45,C.y-h*.2-O*.25,C.x+O,C.y-h),a.stroke(),(C.x<b(R.x)-80||C.x>b(R.x+R.w)+80)&&v.birds.splice($,1)}}};return U=requestAnimationFrame(j),()=>cancelAnimationFrame(U)},[e,n,t,s]),o.length?(0,Ot.jsx)("canvas",{className:"sl-fx",ref:i}):null}var et=require("react");function Bt(e,n,t){let s=Math.max(n/e.width,t/e.height),i=e.width*s,o=e.height*s,d=(r,m,b)=>Math.min(b,Math.max(m,r)),a=n/2-e.focus[0]*i,c=t/2-e.focus[1]*o,u=e.keep;if(u){let r=u.x*i,m=u.w*i,b=u.y*o,p=u.h*o;a=m<=n?d(a,n-r-m,-r):n/2-(r+m/2),c=p<=t?d(c,t-b-p,-b):t/2-(b+p/2)}return{scale:s,left:d(a,n-i,0),top:d(c,t-o,0)}}function rt(e,n,t){return{left:t.left+e.x*n.width*t.scale,top:t.top+e.y*n.height*t.scale,width:e.w*n.width*t.scale,height:e.h*n.height*t.scale}}function gt(e,n){let t=0,s=e.length;for(;t<s;){let i=t+s>>1;e[i]<=n?t=i+1:s=i}return t}var St=require("react/jsx-runtime"),Cn=`
attribute vec2 aPos;
varying vec2 vUv;
void main() { vUv = vec2(aPos.x * 0.5 + 0.5, 0.5 - aPos.y * 0.5); gl_Position = vec4(aPos, 0.0, 1.0); }
`,Rn=`
precision highp float;
uniform sampler2D uImg;
uniform sampler2D uMask;
uniform sampler2D uBlur;
uniform float uT;
uniform float uEnergy;
uniform float uBeat;
uniform float uRain;
uniform float uHorizon;
uniform vec2 uRes;
varying vec2 vUv;
float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); }
vec2 hash2(vec2 p) { return fract(sin(vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)))) * 43758.5453); }
// \u73BB\u7483\u4E0A\u7684\u96E8\uFF1A\u8FD4\u56DE\u6298\u5C04\u504F\u79FB\uFF08xy\uFF09\u548C\u300C\u8FD9\u91CC\u662F\u6C34\u300D\u7684\u7A0B\u5EA6\uFF08z\uFF09
vec3 rain(vec2 uv, float t) {
float aspect = uRes.x / uRes.y;
vec2 p = vec2(uv.x * aspect, uv.y);
vec2 off = vec2(0.0);
float wet = 0.0;
// \u9759\u6B62\u7684\u5C0F\u6C34\u73E0
for (int layer = 0; layer < 2; layer++) {
float scale = layer == 0 ? 38.0 : 22.0;
vec2 g = p * scale;
vec2 id = floor(g);
vec2 f = fract(g) - 0.5;
vec2 h = hash2(id + float(layer) * 17.0);
vec2 c = (h - 0.5) * 0.7;
float r = (0.1 + 0.18 * hash(id + 3.1)) * (layer == 0 ? 0.8 : 1.0);
float life = step(0.35, hash(id + floor(t * 0.05 + h.x))); // \u6709\u7684\u683C\u5B50\u6CA1\u6709\u6C34\u73E0\uFF0C\u9694\u4E00\u9635\u6362\u4E00\u6279
vec2 d = f - c;
float inside = smoothstep(r, r * 0.6, length(d)) * life;
off += d * inside * 0.9 / scale;
wet = max(wet, inside);
}
// \u5F80\u4E0B\u6ED1\u7684\u96E8\u6EF4\uFF1A\u4E00\u5217\u4E00\u5217\uFF0C\u5404\u81EA\u901F\u5EA6\u4E0D\u540C\uFF0C\u540E\u9762\u62D6\u4E00\u6761\u6C34\u75D5
float cols = 26.0;
float cx = floor(p.x * cols);
float colSeed = hash(vec2(cx, 7.3));
float speed = 0.06 + 0.14 * colSeed;
float y = fract(uv.y * 1.0 - t * speed - colSeed * 10.0);
float x = fract(p.x * cols) - 0.5 - (sin(uv.y * 30.0 + colSeed * 50.0) * 0.12);
float head = smoothstep(0.045, 0.0, length(vec2(x * 0.9, (y - 0.06) * 3.2)));
float trail = smoothstep(0.06, 0.0, abs(x)) * smoothstep(0.06, 0.4, y) * smoothstep(1.0, 0.3, y) * 0.55;
float active = step(0.45, hash(vec2(cx, floor(t * speed + colSeed * 10.0))));
head *= active; trail *= active;
off += vec2(x * 0.02, -0.01) * head;
wet = max(wet, max(head, trail * 0.6));
return vec3(off, wet);
}
void main() {
vec2 uv = vUv;
vec4 m = texture2D(uMask, uv);
vec2 off = vec2(0.0);
vec3 add = vec3(0.0);
if (m.r > 0.002) {
float ph = uT * 0.85 + uv.y * 6.0 + uv.x * 3.0;
off.x += m.r * (sin(ph) * 0.0024 + sin(ph * 2.3 + 1.7) * 0.0009);
off.y += m.r * sin(ph * 0.7 + 0.5) * 0.0007;
}
if (m.g > 0.002) {
float depth = clamp((uv.y - uHorizon) / 0.3, 0.0, 1.0);
float k = mix(420.0, 90.0, depth);
float w1 = sin(uv.x * k * 0.55 + uT * 1.5 + sin(uv.y * k * 1.1 + uT * 0.6) * 1.4);
float w2 = sin(uv.x * k * 1.35 - uT * 2.2 + uv.y * k * 0.5);
float h = w1 * 0.6 + w2 * 0.4;
off += vec2(0.0011 * h, 0.0009 * w2) * m.g;
vec3 base = texture2D(uImg, uv + off).rgb;
float bright = dot(base, vec3(0.299, 0.587, 0.114));
// \u95EA\u5149\uFF1A\u7A00\u758F\u7684\u5706\u70B9\uFF0C\u53EA\u5728\u753B\u91CC\u672C\u6765\u5C31\u4EAE\u7684\u6C34\u9762\uFF08\u592A\u9633\u3001\u6708\u4EAE\u7167\u5230\u7684\u5730\u65B9\uFF09\uFF0C\u4E00\u95EA\u4E00\u95EA
vec2 gp = uv * uRes / vec2(7.0, 4.0);
vec2 cell = floor(gp);
vec2 f = fract(gp) - 0.5;
float n = hash(cell);
vec2 c = (hash2(cell) - 0.5) * 0.6;
float tw = 0.5 + 0.5 * sin(uT * (1.2 + n * 3.0) + n * 60.0);
float shape = exp(-dot(f - c, f - c) * 18.0);
float spark = pow(tw, 14.0) * step(0.74, n) * shape * smoothstep(0.48, 0.8, bright);
add += vec3(1.0, 0.98, 0.92) * spark * m.g * (1.1 + uEnergy * 1.6 + uBeat * 0.9);
add += vec3(0.05, 0.07, 0.09) * m.g * smoothstep(0.55, 1.0, h);
}
if (m.a > 0.002) {
off.x += m.a * sin(uv.y * 95.0 - uT * 2.6) * 0.0035;
off.y += m.a * 0.0018 * sin(uT * 1.2 + uv.x * 50.0);
}
vec3 color;
if (uRain > 0.5 && m.b > 0.01) {
vec3 r = rain(uv, uT);
vec3 sharp = texture2D(uImg, uv + off + r.xy).rgb;
vec3 fog = texture2D(uBlur, uv + off).rgb;
vec3 clear = texture2D(uImg, uv + off).rgb;
color = mix(clear, mix(mix(clear, fog, 0.6), sharp, r.z), m.b);
color += vec3(0.08, 0.1, 0.13) * r.z * m.b; // \u6C34\u73E0\u8FB9\u4E0A\u4E00\u70B9\u53CD\u5149
} else {
color = texture2D(uImg, uv + off).rgb;
}
gl_FragColor = vec4(color + add, 1.0);
}
`;function Mt(e){return new Promise((n,t)=>{let s=new Image;s.onload=()=>n(s),s.onerror=t,s.src=e})}function Ut({image:e,mask:n,blur:t,rain:s,horizon:i,style:o}){let d=(0,et.useRef)(null),[a,c]=(0,et.useState)(!1);return(0,et.useEffect)(()=>{let u=d.current;if(!u)return;let r=u.getContext("webgl",{antialias:!1,premultipliedAlpha:!1,preserveDrawingBuffer:!1});if(!r){c(!0);return}let m=0,b=!0,p=(E,F)=>{let j=r.createShader(E);if(r.shaderSource(j,F),r.compileShader(j),!r.getShaderParameter(j,r.COMPILE_STATUS))throw new Error(r.getShaderInfoLog(j)??"shader");return j},k;try{if(k=r.createProgram(),r.attachShader(k,p(r.VERTEX_SHADER,Cn)),r.attachShader(k,p(r.FRAGMENT_SHADER,Rn)),r.linkProgram(k),!r.getProgramParameter(k,r.LINK_STATUS))throw new Error(r.getProgramInfoLog(k)??"link")}catch(E){console.warn("[singinglab] \u52A8\u6001\u63D2\u753B\u7528\u4E0D\u4E86\uFF0C\u9000\u56DE\u9759\u6001\u56FE",E),c(!0);return}r.useProgram(k);let X=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,X),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),r.STATIC_DRAW);let P=r.getAttribLocation(k,"aPos");r.enableVertexAttribArray(P),r.vertexAttribPointer(P,2,r.FLOAT,!1,0,0);let y=E=>r.getUniformLocation(k,E),U=(E,F)=>{let j=r.createTexture();r.activeTexture(r.TEXTURE0+E),r.bindTexture(r.TEXTURE_2D,j),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texImage2D(r.TEXTURE_2D,0,r.RGBA,r.RGBA,r.UNSIGNED_BYTE,F),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE)},z=V();return Promise.all([Mt(e),Mt(n),t?Mt(t):Promise.resolve(null)]).then(([E,F,j])=>{if(!b)return;U(0,E),U(1,F),U(2,j??E),r.uniform1i(y("uImg"),0),r.uniform1i(y("uMask"),1),r.uniform1i(y("uBlur"),2),r.uniform1f(y("uRain"),s?1:0),r.uniform1f(y("uHorizon"),i),u.dataset.ready="1";let H=-1,Z=0,v=0,R=performance.now(),$=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1,C=_=>{if(m=requestAnimationFrame(C),document.hidden)return;let O=Math.min(.1,(_-R)/1e3);R=_;let h=Math.min(1.5,window.devicePixelRatio||1),te=Math.max(1,Math.round(u.clientWidth*h)),se=Math.max(1,Math.round(u.clientHeight*h));(u.width!==te||u.height!==se)&&(u.width=te,u.height=se),r.viewport(0,0,te,se);let ge=z.state.current;if(ge&&z.state.playing){let Ee=z.time,ne=gt(ge.downbeats,Ee)-1;ne!==H&&ne>=0&&Ee-ge.downbeats[ne]<.2&&(Z=1),H=ne}Z*=Math.exp(-O*3),v+=(z.energy()-v)*Math.min(1,O*8),r.uniform1f(y("uT"),$?0:_/1e3),r.uniform1f(y("uEnergy"),v),r.uniform1f(y("uBeat"),Z),r.uniform2f(y("uRes"),te,se),r.drawArrays(r.TRIANGLE_STRIP,0,4)};m=requestAnimationFrame(C)}).catch(()=>c(!0)),()=>{b=!1,cancelAnimationFrame(m),r.getExtension("WEBGL_lose_context")?.loseContext()}},[e,n,t,s,i]),a?(0,St.jsx)("img",{className:"sl-scene-img",src:e,alt:"",style:o,draggable:!1}):(0,St.jsx)("canvas",{className:"sl-scene-img sl-living",ref:d,style:o})}var Xe=require("react");var we=require("react/jsx-runtime"),An=5;function Pn(e){let n=[],t=0;return e.forEach((s,i)=>{let o=s.start;o-t>=An&&n.push({kind:"gap",start:t+(i===0?.5:.3),end:o-.25});let d=e[i+1]?.start??1/0,a=Math.max(s.end??o+2,o+.3);n.push({kind:"line",start:o,end:Math.min(a,d),line:s}),t=Math.min(a,d)}),n}function zn(e,n){let t=0,s=e.length;for(;t<s;){let i=t+s>>1;e[i].start<=n?t=i+1:s=i}return t-1}function jt({song:e,variant:n="stage"}){let t=`sl-lyrics is-${n}`,s=(0,Xe.useMemo)(()=>Pn(e?.lyrics??[]),[e]),i=(0,Xe.useRef)(null),o=(0,Xe.useRef)([]),d=(0,Xe.useRef)([]);return(0,Xe.useEffect)(()=>{let a=i.current;if(!a||!s.length)return;let c=V(),u=[],r=[],m=-2,b=0,p=0,k=0,X=()=>{u=o.current.map(E=>E?.offsetTop??0),r=o.current.map(E=>E?.offsetHeight??0),m=-2};X();let P=new ResizeObserver(X);P.observe(a);let y=(E,F)=>{let j=a.clientHeight*(n==="glass"?.4:.34),H=Math.max(0,E),Z=j-(u[H]??0)-(r[H]??0)/2+b;o.current.forEach((v,R)=>{if(!v)return;let $=R-H,C=Math.abs($),_=F||b?0:$>=0?Math.min($,8)*45:0;v.style.transitionDelay=`${_}ms`,v.style.transitionDuration=F?"0ms":"",v.style.transform=`translate3d(0, ${Z}px, 0) scale(${R===E?1:.94})`,v.style.opacity=String(R===E?1:C>7?0:Math.max(.16,.5-C*.06)),v.style.filter=R===E?"":b?"none":`blur(${Math.min(C*.7,3.2).toFixed(1)}px)`,v.classList.toggle("is-current",R===E),v.classList.toggle("is-past",R<E)})},U=E=>{E.preventDefault(),b-=E.deltaY,p=performance.now(),y(m,!0)};a.addEventListener("wheel",U,{passive:!1});let z=E=>{k=requestAnimationFrame(z);let F=c.time,j=zn(s,F);if(b&&E-p>2600&&(b=0,m=-2),j!==m){let $=m===-2||Math.abs(j-m)>3;m=j,y(j,$&&c.state.playing===!1)}let H=s[j];if(!H)return;if(H.kind==="gap"){let $=o.current[j],C=Math.min(1,Math.max(0,(F-H.start)/Math.max(.1,H.end-H.start)));$?.style.setProperty("--p",C.toFixed(3));return}let Z=d.current[j]??[],v=H.line,R=v.at&&v.at.length===Z.length?v.at:null;Z.forEach(($,C)=>{if(!$)return;let _;if(R){let O=R[C],h=R[C+1]??H.end;_=(F-O)/Math.max(.08,h-O)}else _=(F-H.start)/Math.max(.2,H.end-H.start);$.style.setProperty("--p",`${(Math.min(1,Math.max(0,_))*100).toFixed(1)}%`)})};return k=requestAnimationFrame(z),()=>{cancelAnimationFrame(k),P.disconnect(),a.removeEventListener("wheel",U)}},[s,n]),e?s.length?(o.current=[],d.current=[],(0,we.jsx)("div",{className:t,ref:i,children:(0,we.jsx)("div",{className:"sl-lyrics-track",children:s.map((a,c)=>{if(a.kind==="gap")return(0,we.jsxs)("div",{className:"sl-line sl-gap",ref:m=>{o.current[c]=m},children:[(0,we.jsx)("span",{}),(0,we.jsx)("span",{}),(0,we.jsx)("span",{})]},`g${c}`);let u=a.line,r=u.tokens&&u.tokens.length?u.tokens:[u.text];return d.current[c]=[],(0,we.jsx)("div",{className:"sl-line",ref:m=>{o.current[c]=m},onClick:()=>V().seek(u.start),children:r.map((m,b)=>(0,we.jsx)("span",{className:"sl-word",ref:p=>{(d.current[c]??=[])[b]=p},children:m},b))},`l${c}`)})})})):(0,we.jsx)("div",{className:`${t} sl-lyrics-empty`,children:(0,we.jsxs)("div",{className:"sl-nolyrics",children:[(0,we.jsx)("div",{className:"sl-nolyrics-title",children:e.title}),(0,we.jsx)("div",{className:"sl-nolyrics-sub",children:"\u8FD9\u9996\u8FD8\u6CA1\u6709\u6B4C\u8BCD\uFF0C\u5B89\u9759\u542C\u5979\u5531\u5427"})]})}):(0,we.jsx)("div",{className:`${t} sl-lyrics-empty`})}var he=require("react/jsx-runtime");function Wt({spec:e,song:n}){let t=(0,Se.useRef)(null),s=(0,Se.useRef)(null),[i,o]=(0,Se.useState)(null),[d,a]=(0,Se.useState)({w:0,h:0});(0,Se.useLayoutEffect)(()=>{let m=t.current;if(!m)return;let b=()=>{let k=m.clientWidth,X=m.clientHeight;a({w:k,h:X});let P=Bt(e,k*1.08,X*1.08);o({scale:P.scale,left:P.left-k*.04,top:P.top-X*.04})};b();let p=new ResizeObserver(b);return p.observe(m),()=>p.disconnect()},[e]),(0,Se.useEffect)(()=>{let m=t.current,b=s.current;if(!m||!b)return;let p=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1,k=0,X=0,P=0,y=0,U=0,z=F=>{let j=m.getBoundingClientRect();k=((F.clientX-j.left)/j.width-.5)*2,X=((F.clientY-j.top)/j.height-.5)*2};m.addEventListener("pointermove",z);let E=F=>{if(U=requestAnimationFrame(E),p)return;P+=(k-P)*.04,y+=(X-y)*.04;let H=1.004+.026*(.5-.5*Math.cos(F/9e3*Math.PI*2)),Z=14*Math.sin(F/13e3)-P*9,v=8*Math.sin(F/17e3+1.3)-y*6;b.style.transform=`translate3d(${Z.toFixed(2)}px, ${v.toFixed(2)}px, 0) scale(${H.toFixed(4)})`};return U=requestAnimationFrame(E),()=>{cancelAnimationFrame(U),m.removeEventListener("pointermove",z)}},[]);let c=i?{left:i.left,top:i.top,width:e.width*i.scale,height:e.height*i.scale}:null,u=i?rt(e.glass,e,i):null,r=i&&e.beam?{...rt(e.beam,e,i),angle:e.beam.angle}:null;return(0,he.jsx)("div",{className:"sl-scene",ref:t,children:(0,he.jsxs)("div",{className:"sl-scene-world",ref:s,children:[c&&e.mask?(0,he.jsx)(Ut,{image:J.assetUrl(e.image),mask:J.assetUrl(e.mask),blur:e.fog?J.assetUrl(e.fog):void 0,rain:!!e.rain,horizon:e.horizon??.5,style:c}):c?(0,he.jsx)("img",{className:"sl-scene-img",src:J.assetUrl(e.image),alt:"",style:c,draggable:!1}):null,r?(0,he.jsx)("div",{className:"sl-beam",style:{left:r.left,top:r.top,width:r.width,height:r.height},children:(0,he.jsx)("div",{className:"sl-beam-rays",style:{transform:`rotate(${r.angle}deg)`}})}):null,i?(0,he.jsx)($n,{spec:e,p:i,w:d.w,h:d.h}):null,i?(0,he.jsx)(_t,{spec:e,p:i,w:d.w,h:d.h}):null,i&&e.turntable?(0,he.jsx)(Ln,{spec:e,p:i}):null,u?(0,he.jsx)("div",{className:"sl-glass",style:u,children:(0,he.jsx)(jt,{song:n,variant:"glass"})}):null]})})}function $n({spec:e,p:n,w:t,h:s}){let i=(0,Se.useRef)(null);return(0,Se.useEffect)(()=>{let o=i.current,d=o?.getContext("2d");if(!o||!d||!t||!s)return;let a=Math.min(2,window.devicePixelRatio||1);o.width=Math.round(t*a),o.height=Math.round(s*a);let c=V(),u=e.beam?rt(e.beam,e,n):null,r=e.sea?rt(e.sea,e,n):null,m=u?Array.from({length:46},()=>({x:Math.random(),y:Math.random(),r:.6+Math.random()*1.8,vx:(Math.random()-.5)*.004,vy:-.002-Math.random()*.006,ph:Math.random()*6.28})):[],b=[],p=-1,k=0,X=0,P=performance.now(),y=U=>{if(X=requestAnimationFrame(y),document.hidden)return;let z=Math.min(.1,(U-P)/1e3);P=U;let E=c.state.current,F=c.time,j=c.state.playing;if(E&&j){let v=gt(E.downbeats,F)-1;v!==p&&v>=0&&F-E.downbeats[v]<.2&&(k=1),p=v}k*=Math.exp(-z*2.5);let H=c.energy(),Z=E?.sections.some(v=>v.kind==="chorus"&&F>=v.startSec&&F<v.endSec)??!1;if(d.setTransform(a,0,0,a,0,0),d.clearRect(0,0,t,s),u)for(let v of m){v.x+=v.vx*z*6,v.y+=v.vy*z*6,v.y<-.02&&(v.y=1.02,v.x=Math.random()),v.x<-.02?v.x=1.02:v.x>1.02&&(v.x=-.02);let R=.45+.55*Math.sin(U/900+v.ph);d.globalAlpha=Math.max(0,R)*(.55+k*.35),d.fillStyle="#fffaf0",d.beginPath(),d.arc(u.left+v.x*u.width,u.top+v.y*u.height,v.r,0,6.283),d.fill()}if(r){let v=(j?5:2)+H*14+(Z?6:0)+k*10;if(Math.random()<v*z){let R=Math.random();b.push({x:Math.random(),y:R,life:1,size:1.2+R*3.2})}for(let R=b.length-1;R>=0;R--){let $=b[R];if($.life-=z*1.6,$.life<=0){b.splice(R,1);continue}let C=Math.sin($.life*Math.PI),_=r.left+$.x*r.width,O=r.top+$.y*r.height;d.globalAlpha=C*.9,d.strokeStyle="#ffffff",d.lineWidth=1;let h=$.size*(1.5+C);d.beginPath(),d.moveTo(_-h,O),d.lineTo(_+h,O),d.moveTo(_,O-h*.6),d.lineTo(_,O+h*.6),d.stroke(),d.fillStyle="#ffffff",d.beginPath(),d.arc(_,O,$.size*.45,0,6.283),d.fill()}}d.globalAlpha=1};return X=requestAnimationFrame(y),()=>cancelAnimationFrame(X)},[e,n,t,s]),(0,he.jsx)("canvas",{className:"sl-sparkles",ref:i})}function Ln({spec:e,p:n}){let t=V(),s=(0,Se.useSyncExternalStore)(t.subscribe,()=>t.state.playing),i=e.turntable,o=i.r*e.width*n.scale,d=n.left+i.cx*e.width*n.scale,a=n.top+i.cy*e.height*n.scale;return(0,he.jsx)("div",{className:"sl-tt",style:{left:d-o,top:a-o,width:o*2,height:o*2,transform:`scaleY(${i.squash})`},children:(0,he.jsx)("div",{className:`sl-tt-disc ${s?"is-playing":""}`})})}var A=require("react/jsx-runtime"),Xt=4e3,Jt=e=>{(!Number.isFinite(e)||e<0)&&(e=0);let n=Math.floor(e/60),t=Math.floor(e%60);return`${n}:${String(t).padStart(2,"0")}`};function Kt({spec:e,onBack:n,theme:t,onTheme:s}){let i=V(),o=(0,ee.useSyncExternalStore)(i.subscribe,i.getState),d=o.current,a=d?.id??o.queue[o.index]??null,[c,u]=(0,ee.useState)(!1),r=Dn(o.playing&&!c);return(0,A.jsxs)("div",{className:`sl-now ${r?"is-idle":""} ${c?"is-list":""}`,children:[e?(0,A.jsx)(Wt,{spec:e,song:d}):(0,A.jsx)("div",{className:"sl-scene sl-scene-missing"}),(0,A.jsx)("button",{className:"sl-back",onClick:n,title:"\u56DE\u5230\u6B4C\u5E93",children:(0,A.jsx)(W,{name:"down"})}),(0,A.jsxs)("section",{className:`sl-card sl-card-${e?.card??"left"}`,children:[(0,A.jsxs)("div",{className:"sl-card-head",children:[(0,A.jsx)(In,{id:a}),(0,A.jsxs)("div",{className:"sl-card-meta",children:[(0,A.jsx)("div",{className:"sl-title",title:d?.title,children:d?.title??(o.loading?"\u2026\u2026":"\u8FD8\u6CA1\u653E\u6B4C")}),(0,A.jsxs)("div",{className:"sl-artist",children:[d?.artist||"\u672A\u77E5\u6B4C\u624B",d?.who?(0,A.jsxs)("span",{className:"sl-who",children:[" \xB7 ",d.who]}):null]}),(0,A.jsx)(Fn,{})]})]}),(0,A.jsx)(qn,{}),(0,A.jsx)(_n,{onList:()=>u(m=>!m),listOpen:c,theme:t,onTheme:s}),o.error?(0,A.jsx)("div",{className:"sl-error",children:o.error}):null]}),(0,A.jsx)(Hn,{open:c,side:e?.card==="left"?"left":"right",onClose:()=>u(!1)})]})}function Dn(e){let[n,t]=(0,ee.useState)(!1);return(0,ee.useEffect)(()=>{if(!e){t(!1);return}let s=window.setTimeout(()=>t(!0),Xt),i=()=>{t(!1),clearTimeout(s),s=window.setTimeout(()=>t(!0),Xt)};return window.addEventListener("pointermove",i),window.addEventListener("pointerdown",i),window.addEventListener("keydown",i),()=>{clearTimeout(s),window.removeEventListener("pointermove",i),window.removeEventListener("pointerdown",i),window.removeEventListener("keydown",i)}},[e]),n}function In({id:e}){let n=V(),t=(0,ee.useSyncExternalStore)(n.subscribe,()=>n.state.playing),[s,i]=(0,ee.useState)(!0);return(0,ee.useEffect)(()=>i(!0),[e]),(0,A.jsx)("div",{className:`sl-minidisc ${t?"is-playing":""}`,children:(0,A.jsx)("div",{className:"sl-minidisc-spin",children:(0,A.jsx)("div",{className:"sl-minidisc-label",children:e&&s?(0,A.jsx)("img",{src:J.coverUrl(e),alt:"",onError:()=>i(!1)}):(0,A.jsx)(W,{name:"fish",size:18})})})})}function Fn(){let e=(0,ee.useRef)(null);return(0,ee.useEffect)(()=>{let n=e.current,t=n?.getContext("2d");if(!n||!t)return;let s=V(),i=40,o=new Float32Array(i),d=new Float32Array(i),a=0,c=()=>{if(a=requestAnimationFrame(c),document.hidden)return;let u=Math.min(2,window.devicePixelRatio||1),r=n.clientWidth,m=n.clientHeight;n.width!==Math.round(r*u)&&(n.width=Math.round(r*u),n.height=Math.round(m*u)),t.setTransform(u,0,0,u,0,0),t.clearRect(0,0,r,m),s.spectrum(o);let b=r/i,p=t.createLinearGradient(0,0,r,0);p.addColorStop(0,"#5aa7ff"),p.addColorStop(1,"#8fd3ff"),t.fillStyle=p;for(let k=0;k<i;k++){d[k]+=(o[k]-d[k])*.35;let X=Math.pow(d[k],1.5),P=Math.max(2,X*m),y=k*b+b*.2;t.globalAlpha=.45+X*.55,t.beginPath(),t.roundRect(y,m-P,b*.6,P,b*.3),t.fill()}t.globalAlpha=1};return a=requestAnimationFrame(c),()=>cancelAnimationFrame(a)},[]),(0,A.jsx)("canvas",{className:"sl-spectrum",ref:e})}function qn(){let e=V(),n=(0,ee.useSyncExternalStore)(e.subscribe,()=>e.state.duration),t=(0,ee.useRef)(null),s=(0,ee.useRef)(null),i=(0,ee.useRef)(null),[o,d]=(0,ee.useState)(null),a=(0,ee.useRef)(null),c=p=>{a.current=p,d(p)};(0,ee.useEffect)(()=>{let p=0,k=()=>{p=requestAnimationFrame(k);let X=e.state.duration||0,P=a.current??e.time,y=X?Math.min(1,P/X):0;t.current&&(t.current.style.transform=`scaleX(${y})`),s.current&&(s.current.textContent=Jt(P))};return p=requestAnimationFrame(k),()=>cancelAnimationFrame(p)},[e]);let u=p=>{let k=i.current.getBoundingClientRect();return Math.min(1,Math.max(0,(p-k.left)/k.width))*(e.state.duration||0)};return(0,A.jsxs)("div",{className:"sl-progress",children:[(0,A.jsx)("div",{className:`sl-bar ${o!==null?"is-drag":""}`,ref:i,onPointerDown:p=>{c(u(p.clientX));try{p.currentTarget.setPointerCapture(p.pointerId)}catch{}},onPointerMove:p=>{a.current!==null&&c(u(p.clientX))},onPointerUp:p=>{a.current!==null&&(e.seek(u(p.clientX)),c(null))},onPointerCancel:()=>c(null),children:(0,A.jsx)("div",{className:"sl-bar-track",children:(0,A.jsx)("div",{className:"sl-bar-fill",ref:t})})}),(0,A.jsxs)("div",{className:"sl-times",children:[(0,A.jsx)("span",{ref:s,children:"0:00"}),(0,A.jsx)("span",{children:Jt(n)})]})]})}function Hn({open:e,side:n,onClose:t}){let s=V(),i=(0,ee.useSyncExternalStore)(s.subscribe,s.getState),[o,d]=(0,ee.useState)(""),a=(0,ee.useDeferredValue)(o.trim().toLowerCase()),c=(0,ee.useRef)(null),u=(0,ee.useMemo)(()=>new Map(i.songs.map(p=>[p.id,p])),[i.songs]),r=(0,ee.useMemo)(()=>a?i.songs.filter(k=>`${k.title} ${k.artist} ${k.who}`.toLowerCase().includes(a)):(i.queue.length?i.queue:i.songs.map(k=>k.id)).map(k=>u.get(k)).filter(k=>!!k),[a,i.queue,i.songs,u]),m=i.current?.id??i.queue[i.index];(0,ee.useEffect)(()=>{if(!e||a)return;c.current?.querySelector(".is-current")?.scrollIntoView({block:"center"})},[e,a]);let b=p=>{if(p===m){i.playing||s.toggle();return}a?s.playSong(p,r.map(k=>k.id)):s.jump(p)};return(0,A.jsxs)("aside",{className:`sl-drawer sl-drawer-${n} ${e?"is-open":""}`,"aria-hidden":!e,children:[(0,A.jsxs)("div",{className:"sl-drawer-head",children:[(0,A.jsx)("div",{className:"sl-drawer-title",children:a?`\u627E\u5230 ${r.length} \u9996`:`\u64AD\u653E\u5217\u8868 \xB7 ${r.length} \u9996`}),(0,A.jsx)("button",{className:"sl-ctl sl-small",onClick:t,title:"\u6536\u8D77",children:(0,A.jsx)(W,{name:"close",size:18})})]}),(0,A.jsxs)("label",{className:"sl-search sl-drawer-search",children:[(0,A.jsx)(W,{name:"search",size:16}),(0,A.jsx)("input",{value:o,onChange:p=>d(p.target.value),placeholder:"\u5728\u5168\u90E8\u6B4C\u91CC\u627E"})]}),(0,A.jsx)("div",{className:"sl-drawer-list",ref:c,children:r.map(p=>(0,A.jsxs)("button",{className:`sl-row ${p.id===m?"is-current":""}`,onClick:()=>b(p.id),children:[(0,A.jsx)("img",{className:"sl-row-cover",src:J.coverUrl(p.id),alt:"",loading:"lazy",onError:k=>{k.target.style.visibility="hidden"}}),(0,A.jsxs)("span",{className:"sl-row-text",children:[(0,A.jsx)("span",{className:"sl-row-title",children:p.title}),(0,A.jsx)("span",{className:"sl-row-sub",children:p.artist||p.who})]}),p.id===m?(0,A.jsx)("span",{className:"sl-row-eq",children:i.playing?(0,A.jsxs)("span",{className:"sl-eq",children:[(0,A.jsx)("i",{}),(0,A.jsx)("i",{}),(0,A.jsx)("i",{})]}):(0,A.jsx)(W,{name:"pause",size:14})}):null]},p.id))})]})}function _n({onList:e,listOpen:n,theme:t,onTheme:s}){let i=V(),o=(0,ee.useSyncExternalStore)(i.subscribe,i.getState);return(0,A.jsxs)("div",{className:"sl-controls",children:[(0,A.jsx)("button",{className:`sl-ctl sl-small ${o.shuffle?"is-on":""}`,onClick:()=>i.toggleShuffle(),title:"\u968F\u673A\u64AD\u653E",children:(0,A.jsx)(W,{name:"shuffle",size:19})}),(0,A.jsx)("button",{className:"sl-ctl",onClick:()=>i.step(-1),title:"\u4E0A\u4E00\u9996",children:(0,A.jsx)(W,{name:"prev"})}),(0,A.jsx)("button",{className:"sl-ctl sl-play",onClick:()=>i.toggle(),title:o.playing?"\u6682\u505C":"\u64AD\u653E",children:(0,A.jsx)(W,{name:o.playing?"pause":"play"})}),(0,A.jsx)("button",{className:"sl-ctl",onClick:()=>i.step(1),title:"\u4E0B\u4E00\u9996",children:(0,A.jsx)(W,{name:"next"})}),(0,A.jsx)("button",{className:`sl-ctl sl-small ${o.repeat!=="off"?"is-on":""}`,onClick:()=>i.cycleRepeat(),title:o.repeat==="one"?"\u5355\u66F2\u5FAA\u73AF":o.repeat==="all"?"\u5217\u8868\u5FAA\u73AF":"\u4E0D\u5FAA\u73AF",children:(0,A.jsx)(W,{name:o.repeat==="one"?"repeat1":"repeat",size:19})}),(0,A.jsx)(On,{}),(0,A.jsx)("button",{className:"sl-ctl sl-small",onClick:s,title:t==="auto"?"\u4E3B\u9898\uFF1A\u8DDF\u7740\u7CFB\u7EDF":t==="day"?"\u4E3B\u9898\uFF1A\u767D\u5929":"\u4E3B\u9898\uFF1A\u96E8\u591C",children:(0,A.jsx)(W,{name:t==="auto"?"auto":t==="day"?"sun":"moon",size:18})}),(0,A.jsx)("button",{className:`sl-ctl sl-small ${n?"is-on":""}`,onClick:e,title:"\u6B4C\u5355",children:(0,A.jsx)(W,{name:"list",size:19})}),(0,A.jsx)("button",{className:"sl-ctl sl-small",onClick:()=>o.current&&i.openEditor(o.current.id),disabled:!o.current,title:"\u4FEE\u97F3\uFF1A\u770B\u5979\u5531\u7684\u97F3\u9AD8\uFF0C\u6539\u97F3\u3001\u79FB\u8C03",children:(0,A.jsx)(W,{name:"tune",size:19})})]})}function On(){let e=V(),n=(0,ee.useSyncExternalStore)(e.subscribe,()=>e.state.volume);return(0,A.jsxs)("label",{className:"sl-volume",title:"\u97F3\u91CF",children:[(0,A.jsx)(W,{name:n===0?"mute":"volume",size:18}),(0,A.jsx)("input",{type:"range",min:0,max:1,step:.01,value:n,onChange:t=>e.setVolume(Number(t.target.value)),style:{"--v":`${n*100}%`}})]})}var Ne=require("react/jsx-runtime"),Nt=new Map;function Bn(e){let[n,t]=(0,ke.useState)(Nt.get(e)??null);return(0,ke.useEffect)(()=>{let s=Nt.get(e);if(s){t(s);return}let i=!0;return J.scene(e).then(o=>{Nt.set(e,o),i&&t(o)}).catch(()=>{}),()=>{i=!1}},[e]),n}function Un(){try{let e=localStorage.getItem("dsh-singinglab.theme");return e==="day"||e==="night"?e:"auto"}catch{return"auto"}}function jn(){let[e,n]=(0,ke.useState)(Un),t=typeof window<"u"?window.matchMedia?.("(prefers-color-scheme: dark)"):void 0,[s,i]=(0,ke.useState)(!!t?.matches);return(0,ke.useEffect)(()=>{if(!t)return;let d=()=>i(t.matches);return t.addEventListener("change",d),()=>t.removeEventListener("change",d)},[t]),[e==="auto"?s?"night":"day":e,e,()=>{let d=["auto","day","night"],a=d[(d.indexOf(e)+1)%d.length];n(a);try{localStorage.setItem("dsh-singinglab.theme",a)}catch{}}]}function Gt(){let e=V(),[n,t]=(0,ke.useState)(()=>e.state.current?"now":"library"),[s,i,o]=jn(),[d,a]=(0,ke.useState)(!1),c=(0,ke.useSyncExternalStore)(e.subscribe,()=>e.state.studioAsk),u=(0,ke.useSyncExternalStore)(e.subscribe,()=>e.state.editing);(0,ke.useEffect)(()=>{c&&a(!0)},[c]);let r=Bn(s);(0,ke.useEffect)(()=>{e.refresh(),e.startJobs()},[e]),(0,ke.useEffect)(()=>{let b=p=>{let k=p.target;k&&(k.tagName==="INPUT"||k.tagName==="TEXTAREA"||k.isContentEditable)||!document.querySelector(".sl-root")||document.querySelector(".sl-editor")||(p.code==="Space"?(p.preventDefault(),e.toggle()):p.code==="ArrowRight"&&n==="now"?e.seek(e.time+5):p.code==="ArrowLeft"&&n==="now"?e.seek(e.time-5):p.code==="Escape"&&n==="now"&&t("library"))};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[e,n]);let m=r?J.assetUrl(r.blurred??r.image):null;return(0,Ne.jsxs)("div",{className:`sl-root sl-view-${n} sl-theme-${s}`,children:[(0,Ne.jsx)("div",{className:"sl-libbg","aria-hidden":!0,style:m?{backgroundImage:`url(${m})`}:void 0}),(0,Ne.jsxs)("div",{className:"sl-views",children:[(0,Ne.jsx)("div",{className:"sl-pane sl-pane-lib","aria-hidden":n!=="library",children:(0,Ne.jsx)(Pt,{onOpenNow:()=>t("now"),heroImage:r?J.assetUrl(r.image):null})}),(0,Ne.jsx)("div",{className:"sl-pane sl-pane-now","aria-hidden":n!=="now",children:(0,Ne.jsx)(Kt,{spec:r,onBack:()=>t("library"),theme:i,onTheme:o})})]}),(0,Ne.jsx)("div",{className:"sl-overlay",children:(0,Ne.jsx)(Rt,{})}),(0,Ne.jsx)(At,{}),(0,Ne.jsx)(zt,{open:d,onClose:()=>a(!1)}),u?(0,Ne.jsx)(Ht,{id:u,onClose:()=>e.openEditor(null)},u):null]})}var Vt=`
.sl-root {
--ink: #1e3466;
--ink-2: rgba(30, 52, 102, .62);
--ink-3: rgba(30, 52, 102, .38);
--sky: #3d8bff;
--sky-2: #79c6ff;
--glass: rgba(255, 255, 255, .58);
--ease: cubic-bezier(.22, 1, .36, 1);
position: relative; height: 100%; width: 100%; overflow: hidden; overflow: clip; isolation: isolate;
color: var(--ink); background: #dcebfb;
font-family: "HarmonyOS Sans SC", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
-webkit-font-smoothing: antialiased; container-type: inline-size;
}
:where(.sl-root) button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
/* DSH \u5168\u5C40\u7ED9\u5706\u89D2\u7528\u4E86 superellipse\uFF08\u65B9\u5706\uFF09\uFF0C\u5531\u7247\u3001\u6309\u94AE\u8981\u6B63\u5706 */
.sl-root, .sl-root *, .sl-root *::before, .sl-root *::after { box-sizing: border-box; corner-shape: round; }
/* \u6B4C\u5E93\u9875\u7684\u80CC\u666F\uFF1A\u540C\u4E00\u5F20\u63D2\u753B\u7684\u6A21\u7CCA\u5C0F\u56FE\uFF0C\u8499\u4E00\u5C42\u767D */
.sl-libbg { position: absolute; inset: -4%; z-index: -1; background: #dcebfb center / cover no-repeat; }
.sl-libbg::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(246,250,255,.5), rgba(236,244,255,.72)); }
/* \u4E24\u4E2A\u89C6\u56FE\u53E0\u5728\u4E00\u8D77\uFF0C\u5207\u6362\u65F6\u6DE1\u5165\u6DE1\u51FA\u52A0\u4E00\u70B9\u4F4D\u79FB */
.sl-views { position: absolute; inset: 0; }
.sl-pane { position: absolute; inset: 0; transition: transform .8s var(--ease), opacity .6s var(--ease); }
.sl-view-library .sl-pane-now { transform: scale(1.03); opacity: 0; pointer-events: none; }
.sl-view-now .sl-pane-lib { transform: scale(.98); opacity: 0; pointer-events: none; }
/* \u2500\u2500 \u6B63\u5728\u64AD\u653E\uFF1A\u573A\u666F \u2500\u2500 */
.sl-now { position: absolute; inset: 0; overflow: hidden; }
.sl-scene { position: absolute; inset: 0; overflow: hidden; background: #cfe4fa; }
.sl-scene-world { position: absolute; inset: 0; transform-origin: 45% 55%; will-change: transform; }
.sl-scene-img { position: absolute; max-width: none; user-select: none; -webkit-user-drag: none; }
.sl-beam { position: absolute; pointer-events: none; overflow: hidden; mix-blend-mode: screen;
-webkit-mask-image: radial-gradient(90% 80% at 35% 0%, #000 15%, transparent 72%); mask-image: radial-gradient(90% 80% at 35% 0%, #000 15%, transparent 72%); }
.sl-beam-rays { position: absolute; inset: -60%; opacity: .55; animation: sl-rays 14s ease-in-out infinite alternate;
background:
repeating-linear-gradient(90deg, rgba(255,248,225,0) 0 46px, rgba(255,248,225,.32) 64px, rgba(255,248,225,0) 92px, rgba(255,248,225,0) 150px),
repeating-linear-gradient(90deg, rgba(255,255,245,0) 0 120px, rgba(255,255,245,.22) 150px, rgba(255,255,245,0) 190px, rgba(255,255,245,0) 260px); }
@keyframes sl-rays { 0% { opacity: .38; translate: -18px 0; } 100% { opacity: .62; translate: 18px 0; } }
.sl-sparkles, .sl-fx { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.sl-living { display: block; }
/* \u7A97\u53F0\u4E0A\u7684\u5531\u7247\uFF1A\u753B\u91CC\u7684\u5531\u7247\u4E0D\u76D6\u6389\uFF08\u5531\u81C2\u8FD8\u5728\uFF09\uFF0C\u53EA\u5728\u4E0A\u9762\u53E0\u4E00\u5C42\u8F6C\u7740\u7684\u53CD\u5149\u548C\u7EB9\u8DEF\uFF0C\u538B\u6241\u6210\u900F\u89C6\u7684\u692D\u5706 */
.sl-tt { position: absolute; pointer-events: none; }
.sl-tt-disc { position: absolute; inset: 0; border-radius: 50%; opacity: 0; transition: opacity 1.2s var(--ease); mix-blend-mode: screen;
-webkit-mask-image: radial-gradient(circle, transparent 0 27%, #000 29% 96%, transparent 99%); mask-image: radial-gradient(circle, transparent 0 27%, #000 29% 96%, transparent 99%);
background:
conic-gradient(from 0deg, rgba(255,255,255,0) 0deg, rgba(255,255,255,.38) 14deg, rgba(255,255,255,0) 36deg, rgba(255,255,255,0) 180deg, rgba(255,255,255,.26) 196deg, rgba(255,255,255,0) 220deg),
repeating-radial-gradient(circle, rgba(255,255,255,.07) 0 1px, rgba(0,0,0,0) 1px 3px);
animation: sl-spin 1.8s linear infinite; animation-play-state: paused; }
.sl-tt-disc.is-playing { opacity: .55; animation-play-state: running; }
.sl-tt-disc img { display: none; }
@keyframes sl-spin { to { transform: rotate(360deg); } }
/* \u7A97\u73BB\u7483\uFF1A\u6B4C\u8BCD\u6620\u5728\u4E0A\u9762 */
.sl-glass { position: absolute; container-type: size; pointer-events: auto;
-webkit-mask-image: linear-gradient(180deg, transparent 0, #000 12%, #000 78%, transparent 100%);
mask-image: linear-gradient(180deg, transparent 0, #000 12%, #000 78%, transparent 100%); }
/* \u2500\u2500 \u6B4C\u8BCD\uFF08\u901A\u7528\uFF09 \u2500\u2500 */
.sl-lyrics { position: absolute; inset: 0; overflow: hidden; }
.sl-lyrics-track { position: absolute; left: 0; right: 0; top: 0; }
.sl-line { padding: .3em .4em; margin-left: -.4em; border-radius: 12px; cursor: pointer; transform-origin: 0 50%;
font-weight: 800; line-height: 1.3; word-break: break-word;
transition-property: transform, opacity, filter; transition-duration: .8s, .55s, .55s; transition-timing-function: var(--ease); will-change: transform; }
.sl-word { white-space: pre-wrap; }
.sl-gap { display: flex; gap: .3em; align-items: center; height: 1.6em; }
.sl-gap span { width: .34em; height: .34em; border-radius: 50%; background: currentColor; opacity: .35; }
.sl-gap.is-current span { animation: sl-breathe 2.2s var(--ease) infinite; }
.sl-gap.is-current span:nth-child(1) { opacity: calc(.35 + .65 * clamp(0, var(--p, 0) * 3, 1)); }
.sl-gap.is-current span:nth-child(2) { opacity: calc(.35 + .65 * clamp(0, var(--p, 0) * 3 - 1, 1)); animation-delay: .15s; }
.sl-gap.is-current span:nth-child(3) { opacity: calc(.35 + .65 * clamp(0, var(--p, 0) * 3 - 2, 1)); animation-delay: .3s; }
@keyframes sl-breathe { 0%, 100% { transform: scale(.85); } 50% { transform: scale(1.15); } }
.sl-lyrics-empty { display: grid; place-items: center; }
/* \u73BB\u7483\u4E0A\u7684\u6B4C\u8BCD\uFF1A\u767D\u5B57\uFF0C\u5E26\u4E00\u70B9\u84DD\u8272\u7684\u5149\uFF0C\u50CF\u6620\u5728\u73BB\u7483\u4E0A */
.sl-lyrics.is-glass { color: #fff; }
/* \u5DE6\u53F3\u7559\u51FA\u5149\u6563\u5F00\u7684\u5730\u65B9\uFF0C\u4E0D\u7136\u8367\u5149\u4F1A\u88AB\u6846\u8FB9\u5207\u51FA\u4E00\u6761\u76F4\u7EBF */
.sl-lyrics.is-glass .sl-lyrics-track { padding: 0 22px 0 26px; }
.sl-lyrics.is-glass .sl-line { font-size: clamp(18px, 8.4cqw, 48px); font-weight: 750; letter-spacing: .02em;
text-shadow: 0 1px 2px rgba(18, 56, 120, .5), 0 0 6px rgba(90, 160, 240, .45); }
.sl-lyrics.is-glass .sl-line:hover { background: rgba(255,255,255,.08); }
/* \u5F53\u524D\u8FD9\u53E5\uFF1A\u8367\u5149\uFF08\u767D\u82AF + \u4E00\u5708\u84DD\u5149\uFF09\uFF0C\u6253\u62CD\u5B50\u65F6\u7531 --glow \u518D\u4EAE\u4E00\u70B9 */
.sl-lyrics.is-glass .sl-line.is-current { filter: drop-shadow(0 0 1.5px rgba(255,255,255,.95)) drop-shadow(0 0 5px rgba(150,210,255,.95)) drop-shadow(0 0 11px rgba(70,150,255,.7)); }
.sl-theme-night .sl-lyrics.is-glass .sl-line { text-shadow: 0 1px 2px rgba(0, 10, 30, .6), 0 0 6px rgba(120, 200, 255, .45); }
.sl-theme-night .sl-lyrics.is-glass .sl-line.is-current { filter: drop-shadow(0 0 1.5px rgba(255,255,255,.95)) drop-shadow(0 0 5px rgba(120,220,255,1)) drop-shadow(0 0 12px rgba(60,160,255,.75)); }
.sl-lyrics.is-glass .sl-line.is-current .sl-word { color: transparent; -webkit-background-clip: text; background-clip: text; text-shadow: none;
background-image: linear-gradient(90deg, #fff 0, #fff var(--p, 0%), rgba(255,255,255,.5) calc(var(--p, 0%) + 6%), rgba(255,255,255,.5) 100%); }
.sl-lyrics.is-glass .sl-gap span { background: #fff; box-shadow: 0 0 10px rgba(46,120,210,.5); }
.sl-nolyrics { text-align: left; max-width: 92%; color: #fff; text-shadow: 0 1px 2px rgba(18,56,120,.3), 0 0 18px rgba(46,120,210,.45); }
.sl-nolyrics-title { font-size: clamp(22px, 9cqw, 50px); font-weight: 800; line-height: 1.15; }
.sl-nolyrics-sub { margin-top: 10px; font-size: clamp(13px, 3.6cqw, 17px); opacity: .9; }
/* \u2500\u2500 \u64AD\u653E\u5361\u7247 \u2500\u2500 */
.sl-back { position: absolute; top: 16px; left: 18px; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; z-index: 3;
background: rgba(255,255,255,.5); color: var(--ink); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
box-shadow: 0 6px 18px -8px rgba(30,70,140,.5), inset 0 0 0 1px rgba(255,255,255,.7);
transition: opacity .8s var(--ease), background .2s; }
.sl-back:hover { background: rgba(255,255,255,.8); }
.sl-card { position: absolute; bottom: 4.5%; width: clamp(300px, 30cqw, 380px); z-index: 3; padding: 16px 18px 12px; border-radius: 26px;
background: var(--glass); backdrop-filter: blur(22px) saturate(1.5); -webkit-backdrop-filter: blur(22px) saturate(1.5);
box-shadow: 0 24px 60px -24px rgba(26, 72, 150, .5), inset 0 0 0 1px rgba(255,255,255,.75);
transition: opacity .9s var(--ease), transform .9s var(--ease); }
.sl-card-right { right: 3%; }
.sl-card-left { left: 3%; }
.sl-now.is-idle .sl-card { opacity: 0; transform: translateY(12px); pointer-events: none; }
.sl-now.is-idle .sl-back { opacity: 0; pointer-events: none; }
.sl-now.is-idle { cursor: none; }
.sl-card-head { display: flex; align-items: center; gap: 14px; }
.sl-card-meta { min-width: 0; flex: 1; }
.sl-title { font-size: 17px; font-weight: 750; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-artist { margin-top: 2px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-who { color: var(--ink-3); }
.sl-spectrum { display: block; width: 100%; height: 20px; margin-top: 6px; }
.sl-minidisc { position: relative; width: 74px; height: 74px; flex: none; border-radius: 50%;
box-shadow: 0 10px 22px -10px rgba(10, 30, 70, .6); }
.sl-minidisc-spin { position: absolute; inset: 0; border-radius: 50%; animation: sl-spin 8s linear infinite; animation-play-state: paused;
background:
repeating-radial-gradient(circle, rgba(255,255,255,.05) 0 1px, rgba(0,0,0,0) 1px 2.4px),
radial-gradient(circle, #23232a 0 38%, #101014 39%, #1b1b20 72%, #09090b 100%); }
.sl-minidisc.is-playing .sl-minidisc-spin { animation-play-state: running; }
.sl-minidisc-label { position: absolute; inset: 27%; border-radius: 50%; overflow: hidden; background: #cfe3fb; color: var(--sky);
display: grid; place-items: center; box-shadow: 0 0 0 2px rgba(0,0,0,.5); }
.sl-minidisc-label img { width: 100%; height: 100%; object-fit: cover; }
.sl-minidisc::after { content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
background: conic-gradient(from 200deg, rgba(255,255,255,0), rgba(255,255,255,.16) 25deg, rgba(255,255,255,0) 60deg, rgba(255,255,255,0) 180deg, rgba(255,255,255,.1) 210deg, rgba(255,255,255,0) 240deg); }
.sl-progress { margin-top: 12px; }
.sl-bar { height: 16px; display: flex; align-items: center; cursor: pointer; touch-action: none; }
.sl-bar-track { position: relative; width: 100%; height: 5px; border-radius: 99px; background: rgba(30,52,102,.13); overflow: hidden; transition: height .2s var(--ease); }
.sl-bar:hover .sl-bar-track, .sl-bar.is-drag .sl-bar-track { height: 8px; }
.sl-bar-fill { position: absolute; inset: 0; transform-origin: 0 50%; transform: scaleX(0); border-radius: 99px;
background: linear-gradient(90deg, var(--sky), var(--sky-2)); }
.sl-times { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.sl-controls { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.sl-ctl { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; color: var(--ink);
transition: transform .2s var(--ease), background .2s, color .2s; position: relative; }
.sl-ctl:hover { background: rgba(30,52,102,.07); }
.sl-ctl:active { transform: scale(.92); }
.sl-small { width: 34px; height: 34px; color: var(--ink-3); }
.sl-small.is-on { color: var(--sky); }
.sl-small.is-on::after { content: ''; position: absolute; bottom: 0; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--sky); }
.sl-play { width: 52px; height: 52px; color: #fff; background: linear-gradient(145deg, #4a9bff, #2f63c9);
box-shadow: 0 10px 22px -8px rgba(40, 100, 210, .7); }
.sl-play:hover { background: linear-gradient(145deg, #5aa7ff, #3770d6); transform: scale(1.04); }
.sl-play svg { width: 24px; height: 24px; }
.sl-volume { display: flex; align-items: center; gap: 6px; color: var(--ink-3); }
.sl-volume input { -webkit-appearance: none; appearance: none; width: 52px; height: 4px; border-radius: 99px; outline: none; cursor: pointer;
background: linear-gradient(90deg, var(--sky) var(--v), rgba(30,52,102,.15) var(--v)); }
.sl-volume input::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(20,50,110,.45); }
.sl-error { margin-top: 8px; font-size: 12.5px; color: #b4233a; background: rgba(255,220,225,.7); padding: 6px 10px; border-radius: 10px; }
/* \u6B4C\u5355\u62BD\u5C49 */
.sl-drawer { position: absolute; top: 16px; bottom: 16px; width: min(360px, calc(100% - 32px)); z-index: 4; display: flex; flex-direction: column;
border-radius: 26px; padding: 14px 10px 10px 14px; background: rgba(255,255,255,.66); backdrop-filter: blur(24px) saturate(1.5); -webkit-backdrop-filter: blur(24px) saturate(1.5);
box-shadow: 0 30px 70px -30px rgba(26,72,150,.6), inset 0 0 0 1px rgba(255,255,255,.8);
transition: transform .6s var(--ease), opacity .45s var(--ease); opacity: 0; pointer-events: none; }
.sl-drawer-right { right: 16px; transform: translateX(30px); }
.sl-drawer-left { left: 16px; transform: translateX(-30px); }
.sl-drawer.is-open { opacity: 1; transform: none; pointer-events: auto; }
.sl-now.is-list .sl-card { opacity: 0; pointer-events: none; transform: translateY(12px); }
.sl-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 8px 4px; }
.sl-drawer-title { font-size: 16px; font-weight: 800; }
.sl-drawer .sl-drawer-search { width: auto; margin: 0 4px 8px 0; height: 36px; }
.sl-drawer-list { flex: 1; overflow-y: auto; padding-right: 4px; scrollbar-width: thin; scrollbar-color: rgba(30,52,102,.25) transparent; }
.sl-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px; border-radius: 14px; text-align: left; transition: background .2s; }
.sl-row:hover { background: rgba(255,255,255,.7); }
.sl-row.is-current { background: rgba(61,139,255,.14); }
.sl-row-cover { width: 56px; height: 35px; border-radius: 8px; object-fit: cover; flex: none; background: rgba(30,52,102,.08); }
.sl-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sl-row-title { font-size: 13.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-row.is-current .sl-row-title { color: #2f6fe0; }
.sl-row-sub { font-size: 11.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-row-eq { color: var(--sky); flex: none; padding-right: 4px; }
/* \u5B66\u6B4C\uFF1A\u53F3\u4E0A\u89D2\u7684\u836F\u4E38\u3001\u5B66\u6B4C\u5217\u8868\u3001\u63D0\u793A\u6761\u3001B \u7AD9\u641C\u7D22\u7ED3\u679C\u3001\u786E\u8BA4\u6846 */
.sl-overlay { position: absolute; top: 16px; right: 18px; z-index: 6; display: flex; justify-content: flex-end; pointer-events: none; }
.sl-overlay > * { pointer-events: auto; }
/* \u64AD\u653E\u9875\uFF1A\u53F3\u8FB9\u662F\u6B4C\u5355\u62BD\u5C49\u548C\u63A7\u5236\u5361\u7247\uFF0C\u5B66\u6B4C\u7684\u836F\u4E38\u653E\u5230\u5DE6\u4E0A\u89D2\uFF0C\u6328\u7740\u8FD4\u56DE\u952E */
.sl-root.sl-view-now .sl-overlay { right: auto; left: 66px; justify-content: flex-start; }
.sl-root.sl-view-now .sl-learnlist { right: auto; left: 0; }
.sl-root:has(.sl-view-now) .sl-overlay, .sl-root.sl-view-now:has(.sl-now.is-idle) .sl-overlay { transition: opacity .8s; }
.sl-root.sl-view-now:has(.sl-now.is-idle) .sl-overlay { opacity: 0; pointer-events: none; }
.sl-pill-wrap { position: relative; }
.sl-pill { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px 0 8px; border-radius: 99px; font-size: 13px; font-weight: 600; color: var(--ink);
background: rgba(255,255,255,.72); backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
box-shadow: 0 10px 26px -14px rgba(26,72,150,.6), inset 0 0 0 1px rgba(255,255,255,.85); max-width: min(460px, 70vw); }
.sl-pill-quiet { width: 38px; padding: 0; justify-content: center; color: var(--ink-2); }
.sl-pill-fish { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #6cc0ff, #3a72de); flex: none; }
.sl-pill.is-busy .sl-pill-fish { animation: sl-swim 1.6s ease-in-out infinite; }
@keyframes sl-swim { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-2px) rotate(6deg); } }
.sl-pill-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sl-pill-bar { width: 64px; height: 5px; border-radius: 99px; background: rgba(30,52,102,.12); overflow: hidden; flex: none; }
.sl-pill-bar i, .sl-job-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--sky), var(--sky-2)); transition: width .8s var(--ease); }
.sl-pill-pct { font-variant-numeric: tabular-nums; color: var(--ink-2); flex: none; }
.sl-pill-more { font-size: 12px; color: var(--sky); flex: none; }
.sl-learnlist { position: absolute; right: 0; top: 46px; width: 340px; max-height: 60vh; overflow-y: auto; padding: 10px; border-radius: 22px;
background: rgba(255,255,255,.82); backdrop-filter: blur(22px) saturate(1.4); -webkit-backdrop-filter: blur(22px) saturate(1.4);
box-shadow: 0 24px 60px -24px rgba(26,72,150,.6), inset 0 0 0 1px rgba(255,255,255,.9); }
.sl-learnlist-head { display: flex; align-items: center; justify-content: space-between; font-weight: 800; padding: 2px 4px 6px 6px; }
.sl-learnlist-empty { padding: 16px; text-align: center; color: var(--ink-2); font-size: 13px; }
.sl-job { display: flex; align-items: center; gap: 10px; padding: 7px; border-radius: 14px; }
.sl-job.is-running { background: rgba(61,139,255,.1); }
.sl-job-cover { width: 52px; height: 33px; border-radius: 8px; object-fit: cover; flex: none; background: rgba(30,52,102,.08); }
.sl-job-text { flex: 1; min-width: 0; }
.sl-job-title { font-size: 13.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-job-sub { font-size: 11.5px; color: var(--ink-2); margin-top: 1px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sl-job.is-failed .sl-job-sub { color: #b4233a; }
.sl-job-bar { height: 4px; margin-top: 5px; border-radius: 99px; background: rgba(30,52,102,.12); overflow: hidden; }
.sl-toast { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 7; display: flex; align-items: center; gap: 10px;
padding: 10px 12px 10px 16px; border-radius: 99px; font-size: 14px; font-weight: 600; color: #fff; max-width: min(620px, calc(100% - 32px));
background: linear-gradient(145deg, rgba(74,155,255,.95), rgba(47,99,201,.95)); box-shadow: 0 18px 40px -16px rgba(30,80,180,.8);
animation: sl-toast-in .5s var(--ease); }
.sl-toast span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-toast-btn { flex: none; padding: 5px 12px; border-radius: 99px; background: rgba(255,255,255,.9) !important; color: #2f63c9 !important; font-size: 13px; font-weight: 700; }
@keyframes sl-toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
.sl-bili-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 16px; padding: 12px 12px 12px 18px;
border-radius: 20px; background: rgba(255,255,255,.6); box-shadow: inset 0 0 0 1px rgba(255,255,255,.8); font-size: 14px; color: var(--ink-2); }
.sl-bili { margin: 0 0 26px; padding: 16px 18px 20px; border-radius: 24px; background: rgba(255,255,255,.5); box-shadow: inset 0 0 0 1px rgba(255,255,255,.8); }
.sl-bili-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sl-bili-warn { font-size: 13px; color: #9a5b00; background: rgba(255,226,170,.6); padding: 8px 12px; border-radius: 12px; margin-bottom: 10px; }
.sl-hit .sl-card-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.35; height: 2.7em; }
.sl-hit-btn { margin-top: 8px; height: 34px; padding: 0 14px; font-size: 13px; }
.sl-btn[disabled] { opacity: .55; cursor: default; transform: none; }
.sl-modal { position: absolute; inset: 0; z-index: 8; display: grid; place-items: center; background: rgba(20,40,80,.25); backdrop-filter: blur(4px); }
.sl-modal-card { width: min(420px, calc(100% - 32px)); padding: 18px; border-radius: 26px; background: rgba(255,255,255,.92); box-shadow: 0 30px 80px -30px rgba(20,60,140,.7); }
.sl-modal-cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 16px; }
.sl-modal-title { margin-top: 12px; font-size: 18px; font-weight: 800; }
.sl-modal-sub { margin-top: 2px; font-size: 12.5px; color: var(--ink-2); }
.sl-field { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.sl-field span { width: 32px; flex: none; }
.sl-field input { flex: 1; height: 38px; padding: 0 12px; border-radius: 12px; border: 0; outline: none; font: inherit; font-size: 14px; color: var(--ink);
background: rgba(30,52,102,.06); box-shadow: inset 0 0 0 1px rgba(30,52,102,.08); }
.sl-field input:focus { box-shadow: inset 0 0 0 1.5px var(--sky); }
.sl-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
/* \u2500\u2500 \u96E8\u591C\u4E3B\u9898\uFF1A\u6DF1\u8272\u73BB\u7483\u3001\u6D45\u8272\u5B57 \u2500\u2500 */
.sl-root.sl-theme-night { --ink: #e9f1ff; --ink-2: rgba(222,234,255,.66); --ink-3: rgba(222,234,255,.4); --sky: #7cc4ff; --sky-2: #a8e0ff;
--glass: rgba(18, 26, 56, .55); background: #0b1226; }
.sl-theme-night .sl-libbg { background-color: #0b1226; }
.sl-theme-night .sl-libbg::after { background: linear-gradient(180deg, rgba(8,12,30,.55), rgba(8,12,30,.78)); }
.sl-theme-night .sl-lib-head { background: linear-gradient(180deg, rgba(10,16,38,.8), rgba(10,16,38,.3)); }
.sl-theme-night .sl-hero::before { background: linear-gradient(90deg, rgba(10,16,38,0) 30%, rgba(10,16,38,.55) 52%, rgba(10,16,38,.88) 72%); }
.sl-theme-night .sl-hero { box-shadow: 0 30px 60px -34px rgba(0,0,0,.8), inset 0 0 0 1px rgba(160,200,255,.18); }
.sl-theme-night .sl-hero-kicker, .sl-theme-night .sl-btn, .sl-theme-night .sl-search, .sl-theme-night .sl-seg, .sl-theme-night .sl-card-tag {
background: rgba(30, 42, 84, .7); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(160,200,255,.18); }
.sl-theme-night .sl-btn-primary { background: linear-gradient(145deg, #4a9bff, #2f63c9); color: #fff; }
.sl-theme-night .sl-seg button.is-on { background: #e9f1ff; color: #10162a; }
.sl-theme-night .sl-card-cover { box-shadow: 0 16px 30px -18px rgba(0,0,0,.8), 0 0 0 1px rgba(160,200,255,.14); }
.sl-theme-night .sl-card, .sl-theme-night .sl-drawer, .sl-theme-night .sl-mini, .sl-theme-night .sl-pill, .sl-theme-night .sl-learnlist,
.sl-theme-night .sl-back, .sl-theme-night .sl-bili, .sl-theme-night .sl-bili-bar, .sl-theme-night .sl-modal-card {
background: rgba(16, 24, 54, .62); box-shadow: 0 24px 60px -24px rgba(0,0,0,.75), inset 0 0 0 1px rgba(160,200,255,.16); color: var(--ink); }
.sl-theme-night .sl-ctl:hover, .sl-theme-night .sl-row:hover { background: rgba(160,200,255,.1); }
.sl-theme-night .sl-row.is-current { background: rgba(124,196,255,.16); }
.sl-theme-night .sl-row.is-current .sl-row-title { color: #9fd6ff; }
.sl-theme-night .sl-bar-track, .sl-theme-night .sl-pill-bar, .sl-theme-night .sl-job-bar { background: rgba(200,220,255,.16); }
.sl-theme-night .sl-field input { background: rgba(160,200,255,.08); color: var(--ink); }
.sl-theme-night .sl-minidisc-label { background: #1a2550; }
/* \u5B66\u6B4C\u8BBE\u7F6E */
.sl-studio-wrap { z-index: 9; }
.sl-studio { width: min(620px, calc(100% - 32px)); max-height: calc(100% - 48px); overflow-y: auto; padding: 20px; border-radius: 26px;
background: rgba(246,250,255,.94); box-shadow: 0 30px 80px -30px rgba(20,60,140,.7); scrollbar-width: thin; }
.sl-theme-night .sl-studio { background: rgba(16,24,54,.95); }
.sl-studio-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.sl-studio-title { font-size: 20px; font-weight: 800; }
.sl-studio-sub { font-size: 13px; color: var(--ink-2); margin-top: 4px; line-height: 1.5; }
.sl-studio-card { padding: 14px 16px; border-radius: 18px; background: rgba(255,255,255,.7); box-shadow: inset 0 0 0 1px rgba(30,52,102,.08); margin-top: 12px; }
.sl-theme-night .sl-studio-card { background: rgba(30,42,84,.55); box-shadow: inset 0 0 0 1px rgba(160,200,255,.14); }
.sl-studio-h { font-weight: 800; font-size: 15px; margin-bottom: 8px; }
.sl-need { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 3px 0; }
.sl-need em { margin-left: auto; font-style: normal; color: var(--ink-2); font-size: 12.5px; }
.sl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sky); flex: none; }
.sl-dot.is-voice { background: #f0a040; }
.sl-big { width: 100%; justify-content: center; height: 48px; font-size: 15px; margin-top: 12px; }
.sl-studio-err { margin-top: 8px; font-size: 12.5px; color: #b4233a; }
.sl-studio-hint { margin-top: 10px; font-size: 12.5px; color: #9a5b00; background: rgba(255,226,170,.5); padding: 8px 10px; border-radius: 10px; }
.sl-steps { margin-top: 12px; display: grid; gap: 6px; }
.sl-step { position: relative; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.sl-step-dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(30,52,102,.18); flex: none; }
.sl-step.is-done { color: var(--ink); } .sl-step.is-done .sl-step-dot { background: #3cb371; }
.sl-step.is-running { color: var(--ink); } .sl-step.is-running .sl-step-dot { background: var(--sky); animation: sl-breathe 1.2s ease-in-out infinite; }
.sl-step.is-failed { color: #b4233a; } .sl-step.is-failed .sl-step-dot { background: #e0485e; }
.sl-step-detail { color: var(--ink-3); font-size: 12px; }
.sl-step .sl-job-bar { flex-basis: 100%; margin-left: 18px; }
.sl-voices { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.sl-voice { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 99px; font-size: 13px; background: rgba(30,52,102,.06); }
.sl-voice.is-on { background: linear-gradient(145deg, #4a9bff, #2f63c9); color: #fff; }
.sl-voice em { font-style: normal; opacity: .7; }
.sl-drop { display: block; position: relative; padding: 18px; border-radius: 14px; text-align: center; font-size: 13px; color: var(--ink-2); cursor: pointer;
border: 1.5px dashed rgba(61,139,255,.45); background: rgba(61,139,255,.05); }
.sl-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.sl-adv-toggle { margin-top: 14px; font-size: 13px; color: var(--sky); }
.sl-recipes { display: inline-flex; margin-bottom: 4px; }
.sl-chain { display: grid; gap: 8px; margin-top: 10px; }
.sl-link { display: grid; grid-template-columns: 22px 120px 1fr; gap: 4px 10px; align-items: center; font-size: 13.5px; }
.sl-link-n { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 11.5px; background: rgba(61,139,255,.14); color: var(--sky); font-weight: 700; }
.sl-link-name { font-weight: 650; }
.sl-patch { font-style: normal; font-size: 11px; margin-left: 6px; padding: 1px 6px; border-radius: 99px; background: rgba(240,160,64,.18); color: #b26a00; }
.sl-link-ctl select { width: 100%; height: 32px; border-radius: 10px; border: 0; padding: 0 8px; font: inherit; font-size: 13px; color: var(--ink); background: rgba(30,52,102,.06); }
.sl-link-fixed { color: var(--ink-3); }
.sl-link-why { grid-column: 2 / 4; font-size: 12px; color: var(--ink-3); margin-top: -2px; }
.sl-switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.sl-switch input { opacity: 0; width: 0; height: 0; }
.sl-switch i { position: absolute; inset: 0; border-radius: 99px; background: rgba(30,52,102,.2); transition: background .2s; }
.sl-switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); }
.sl-switch input:checked + i { background: var(--sky); }
.sl-switch input:checked + i::after { transform: translateX(18px); }
.sl-shelf-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid rgba(30,52,102,.06); }
.sl-shelf-text { flex: 1; min-width: 0; }
.sl-shelf-name { font-weight: 650; font-size: 13.5px; }
.sl-shelf-name em { font-style: normal; font-weight: 400; color: var(--ink-3); font-size: 12px; }
.sl-shelf-note { font-size: 12px; color: var(--ink-2); }
.sl-shelf-ok { font-size: 12.5px; color: #3cb371; flex: none; }
.sl-import { display: flex; gap: 8px; margin-top: 10px; }
.sl-import input { flex: 1; height: 36px; border-radius: 10px; border: 0; padding: 0 10px; font: inherit; font-size: 13px; color: var(--ink); background: rgba(30,52,102,.06); }
.sl-studio-btn { position: relative; height: 36px; padding: 0 14px; font-size: 13px; }
.sl-badge { position: absolute; top: 4px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: #f0a040; }
/* \u641C\u7D22\u7684\u4E24\u9875\uFF1A\u5979\u4F1A\u5531\u7684 / B \u7AD9\u4E0A\u7684 */
.sl-tabs { display: flex; gap: 6px; margin: 2px 0 16px; }
.sl-tabs button { height: 36px; padding: 0 16px; border-radius: 99px; font-size: 14px; font-weight: 650; color: var(--ink-2);
background: rgba(255,255,255,.5); box-shadow: inset 0 0 0 1px rgba(30,52,102,.08); }
.sl-tabs button.is-on { background: var(--ink); color: #fff; box-shadow: none; }
.sl-theme-night .sl-tabs button { background: rgba(30,42,84,.6); }
.sl-theme-night .sl-tabs button.is-on { background: #e9f1ff; color: #10162a; }
.sl-tabs em { font-style: normal; opacity: .6; margin-left: 4px; font-weight: 500; }
/* \u2500\u2500 \u6B4C\u5E93 \u2500\u2500 */
.sl-library { position: absolute; inset: 0; }
.sl-lib-scroll { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; padding: 0 clamp(18px, 3.2cqw, 48px);
scrollbar-width: thin; scrollbar-color: rgba(30,52,102,.25) transparent; }
.sl-lib-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
padding: 14px clamp(18px, 3.2cqw, 48px) 14px; margin: 0 calc(-1 * clamp(18px, 3.2cqw, 48px));
background: linear-gradient(180deg, rgba(240,247,255,.78), rgba(240,247,255,.35)); backdrop-filter: blur(16px) saturate(1.3); -webkit-backdrop-filter: blur(16px) saturate(1.3);
-webkit-mask-image: linear-gradient(180deg, #000 78%, transparent); mask-image: linear-gradient(180deg, #000 78%, transparent); }
.sl-hero { position: relative; margin: 22px 0 6px; height: clamp(220px, 34cqw, 360px); border-radius: 28px; overflow: hidden;
background: #cfe4fa 26% 24% / cover no-repeat; box-shadow: 0 30px 60px -34px rgba(20,60,140,.7), inset 0 0 0 1px rgba(255,255,255,.7); }
.sl-hero::before { content: ''; position: absolute; inset: 0;
background: linear-gradient(90deg, rgba(240,247,255,0) 30%, rgba(240,247,255,.55) 52%, rgba(240,247,255,.88) 72%); }
.sl-hero-text { position: absolute; right: clamp(20px, 5cqw, 64px); top: 50%; transform: translateY(-50%); text-align: left; max-width: 46%; }
.sl-hero-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650; color: var(--sky);
background: rgba(255,255,255,.75); padding: 4px 10px; border-radius: 99px; }
.sl-hero-title { margin-top: 12px; font-size: clamp(22px, 3cqw, 38px); font-weight: 800; letter-spacing: .02em; line-height: 1.2; }
.sl-hero-sub { margin-top: 6px; font-size: 14px; color: var(--ink-2); }
.sl-hero-actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.sl-btn { display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 99px; font-size: 14px; font-weight: 650;
background: rgba(255,255,255,.8); color: var(--ink); box-shadow: 0 8px 20px -12px rgba(30,70,140,.6), inset 0 0 0 1px rgba(30,52,102,.08);
transition: transform .25s var(--ease), box-shadow .25s; }
.sl-btn:hover { transform: translateY(-1px); }
.sl-btn-primary { background: linear-gradient(145deg, #4a9bff, #2f63c9); color: #fff; box-shadow: 0 12px 24px -10px rgba(40,100,210,.75); }
.sl-lib-title { font-size: 19px; font-weight: 800; }
.sl-brand { display: flex; align-items: center; gap: 12px; }
.sl-brand-mark { width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; color: #fff;
background: linear-gradient(145deg, #6cc0ff, #3a72de); box-shadow: 0 10px 22px -10px rgba(40,100,210,.8); }
.sl-brand-name { font-size: 22px; font-weight: 800; letter-spacing: .02em; }
.sl-brand-sub { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.sl-lib-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sl-search { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px; border-radius: 99px; width: 240px;
background: rgba(255,255,255,.7); box-shadow: inset 0 0 0 1px rgba(30,52,102,.1), 0 6px 16px -10px rgba(30,70,140,.4); color: var(--ink-3); transition: box-shadow .2s; }
.sl-search:focus-within { box-shadow: inset 0 0 0 1.5px var(--sky), 0 6px 16px -10px rgba(30,70,140,.4); }
.sl-search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--ink); font: inherit; font-size: 14px; }
.sl-search input::placeholder { color: var(--ink-3); }
.sl-seg { display: flex; padding: 3px; border-radius: 99px; background: rgba(255,255,255,.55); box-shadow: inset 0 0 0 1px rgba(30,52,102,.08); }
.sl-seg button { padding: 6px 14px; border-radius: 99px; font-size: 13px; color: var(--ink-2); transition: background .2s, color .2s; }
.sl-seg button.is-on { background: var(--ink); color: #fff; font-weight: 600; }
.sl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 26px 20px; padding-top: 6px; }
.sl-card-item { text-align: left; display: block; min-width: 0; border-radius: 16px; transition: transform .35s var(--ease); }
.sl-card-item:hover { transform: translateY(-4px); }
.sl-card-cover { position: relative; aspect-ratio: 16 / 10; border-radius: 15px; overflow: hidden; background: rgba(255,255,255,.6);
box-shadow: 0 16px 30px -18px rgba(20,60,130,.6), 0 0 0 1px rgba(255,255,255,.8); }
.sl-card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s var(--ease); }
.sl-card-item:hover .sl-card-cover img { transform: scale(1.05); }
.sl-card-blank { width: 100%; height: 100%; display: grid; place-items: center; color: var(--sky);
background: linear-gradient(135deg, #e6f1ff, #cfe2fb); }
.sl-card-play { position: absolute; right: 10px; bottom: 10px; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
background: linear-gradient(145deg, #4a9bff, #2f63c9); color: #fff; box-shadow: 0 8px 20px -6px rgba(30,80,180,.7);
opacity: 0; transform: translateY(6px) scale(.9); transition: opacity .25s, transform .35s var(--ease); }
.sl-card-item:hover .sl-card-play, .sl-card-item.is-active .sl-card-play { opacity: 1; transform: none; }
.sl-card-tag { position: absolute; left: 8px; top: 8px; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: rgba(255,255,255,.78); color: var(--ink-2); }
.sl-card-item.is-active .sl-card-cover { box-shadow: 0 0 0 2.5px var(--sky), 0 16px 30px -18px rgba(20,60,130,.6); }
.sl-card-title { margin-top: 10px; font-size: 14.5px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-card-sub { margin-top: 3px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-eq { display: flex; align-items: flex-end; gap: 2px; height: 14px; }
.sl-eq i { width: 3px; border-radius: 2px; background: currentColor; animation: sl-eq 1s ease-in-out infinite; }
.sl-eq i:nth-child(2) { animation-delay: -.35s; }
.sl-eq i:nth-child(3) { animation-delay: -.7s; }
@keyframes sl-eq { 0%, 100% { height: 30%; } 50% { height: 100%; } }
.sl-empty { padding: 60px 0; text-align: center; color: var(--ink-2); }
.sl-lib-pad { height: 120px; }
.sl-mini { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 3; width: min(560px, calc(100% - 32px));
display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 8px; border-radius: 22px; cursor: pointer;
background: rgba(255,255,255,.72); backdrop-filter: blur(22px) saturate(1.4); -webkit-backdrop-filter: blur(22px) saturate(1.4);
box-shadow: 0 18px 40px -18px rgba(26,72,150,.55), inset 0 0 0 1px rgba(255,255,255,.85); }
.sl-mini-cover { width: 64px; height: 40px; border-radius: 10px; object-fit: cover; flex: none; }
.sl-mini-text { flex: 1; min-width: 0; }
.sl-mini-title { font-size: 14px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-mini-sub { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sl-play-sm { width: 42px; height: 42px; }
.sl-play-sm svg { width: 20px; height: 20px; }
@container (max-width: 760px) {
.sl-card { left: 16px; right: 16px; width: auto; bottom: 16px; }
.sl-volume { display: none; }
}
@media (prefers-reduced-motion: reduce) {
.sl-tt-disc, .sl-minidisc-spin, .sl-beam-rays { animation: none; }
.sl-line { transition-duration: 0s !important; }
}
/* \u5BF9\u8BDD\u91CC\u5531\u6B4C\u5DE5\u5177\u7684\u5361\u7247\uFF1A\u8DDF\u7740 DSH \u7684\u5B57\u8272\u8D70\uFF0C\u53EA\u7528\u900F\u660E\u5EA6\u5206\u5C42 */
.sl-toolcard { display: flex; align-items: flex-start; gap: 10px; margin: 4px 0; padding: 10px 12px; border-radius: 12px;
background: color-mix(in srgb, currentColor 4%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 10%, transparent);
font-size: 13px; line-height: 1.5; max-width: 560px; }
.sl-toolcard-icon { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
color: #3f7fe0; background: rgba(63,127,224,.12); }
.sl-toolcard.is-error .sl-toolcard-icon { color: #d0573f; background: rgba(208,87,63,.12); }
.sl-toolcard-body { flex: 1; min-width: 0; }
.sl-toolcard-title { font-weight: 600; }
.sl-toolcard-text { opacity: .7; white-space: pre-wrap; word-break: break-word; }
.sl-toolcard-more { all: unset; cursor: pointer; font-size: 12px; opacity: .55; }
.sl-toolcard-more:hover { opacity: .9; }
.sl-toolcard-go { all: unset; cursor: pointer; flex: none; align-self: center; padding: 5px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 600;
color: #fff; background: #3f7fe0; }
.sl-toolcard-go:hover { background: #336fce; }
.sl-toolcard-dots::after { content: '\u2026'; animation: sl-dots 1.2s steps(3) infinite; display: inline-block; width: 1em; overflow: hidden; vertical-align: bottom; }
@keyframes sl-dots { from { width: 0; } to { width: 1em; } }
/* \u2500\u2500 \u4FEE\u97F3\u9875\uFF1A\u6DF1\u8272\u7684\u5DE5\u4F5C\u53F0\uFF0C\u4E0D\u8DDF\u767D\u5929 / \u96E8\u591C\u4E3B\u9898\u8D70 \u2500\u2500 */
.sl-editor { position: absolute; inset: 0; z-index: 40; display: flex; flex-direction: column; background: #0a0f1d; color: #e6edf9; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; }
.sl-editor canvas { -webkit-user-drag: none; }
.sl-ed-top { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,.06); }
.sl-ed-back { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #cfd9ec; background: rgba(255,255,255,.06); }
.sl-ed-back svg { transform: rotate(90deg); }
.sl-ed-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1; }
.sl-ed-title b { font-size: 16px; font-weight: 700; letter-spacing: .02em; }
.sl-ed-title span { font-size: 14px; color: #9fb0cc; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sl-ed-key { display: flex; align-items: center; gap: 2px; padding: 3px; border-radius: 12px; background: rgba(255,255,255,.06); }
.sl-ed-key button { width: 30px; height: 30px; border-radius: 9px; font-size: 18px; color: #dbe6f7; }
.sl-ed-key button:hover { background: rgba(255,255,255,.08); }
.sl-ed-key span { min-width: 92px; text-align: center; font-size: 14px; font-weight: 650; }
.sl-ed-key em { display: block; font-style: normal; font-size: 10.5px; font-weight: 500; color: #7fa8d8; margin-top: -1px; }
.sl-ed-save { height: 34px; padding: 0 16px; border-radius: 10px; font-size: 14px; font-weight: 650; color: #fff; background: #3f7fe0; }
.sl-ed-save:disabled { opacity: .5; }
.sl-ed-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
.sl-ed-seg { display: flex; padding: 3px; gap: 2px; border-radius: 11px; background: rgba(255,255,255,.05); }
.sl-ed-seg button { height: 28px; padding: 0 11px; border-radius: 8px; font-size: 12.5px; color: #aebbd3; }
.sl-ed-seg button.is-on { background: rgba(127,190,255,.18); color: #fff; }
.sl-ed-hint { flex: 1 1 180px; min-width: 0; font-size: 12.5px; color: #8ea0bf; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } /* \u63D0\u793A\u957F\u77ED\u53D8\u4E86\u4E5F\u4E0D\u8BA9\u5DE5\u5177\u680F\u91CD\u65B0\u6362\u884C\uFF08\u753B\u5E03\u4E0D\u8DF3\uFF09 */
.sl-ed-main { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 6px; margin: 0 16px; }
.sl-ed-roll { position: relative; flex: 1; min-height: 0; border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
.sl-ed-overview { height: 40px; border-radius: 9px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); cursor: pointer; }
.sl-ed-overview canvas { display: block; touch-action: none; }
.sl-ed-title i { width: 7px; height: 7px; border-radius: 50%; background: #ffb454; align-self: center; flex: none; }
.sl-ed-help { width: 28px; height: 28px; border-radius: 50%; font-size: 13px; font-weight: 700; color: #cfd9ec; background: rgba(255,255,255,.07); }
.sl-ed-help:hover { background: rgba(255,255,255,.14); }
.sl-ed-gap { width: 10px; }
.sl-ed-tune { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: #cfd9ec; }
.sl-ed-tune label { display: flex; align-items: center; gap: 8px; }
.sl-ed-tune input[type=range] { width: 140px; accent-color: #5a9cf0; }
.sl-ed-tune b { min-width: 36px; font-weight: 650; font-variant-numeric: tabular-nums; }
.sl-ed-tune button { height: 30px; padding: 0 12px; border-radius: 9px; font-size: 12.5px; color: #dbe6f7; background: rgba(255,255,255,.07); }
.sl-ed-tune button.is-primary { color: #fff; background: #3f7fe0; }
.sl-ed-keys { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(4,7,16,.55); }
.sl-ed-keys > div { width: min(560px, calc(100% - 32px)); max-height: calc(100% - 64px); overflow: auto; padding: 20px 22px; border-radius: 14px; background: #121a2e; box-shadow: 0 20px 60px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.07); }
.sl-ed-keys h3 { margin: 0 0 12px; font-size: 15px; }
.sl-ed-keys dl { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: 13px; }
.sl-ed-keys dt { color: #9fc4ff; font-weight: 650; white-space: nowrap; }
.sl-ed-keys dd { margin: 0; color: #cfd9ec; }
.sl-ed-roll canvas { display: block; touch-action: none; }
.sl-ed-legend { position: absolute; right: 12px; bottom: 10px; display: flex; gap: 12px; padding: 6px 10px; border-radius: 9px; font-size: 11.5px; color: #b9c6dc; background: rgba(8,12,24,.72); pointer-events: none; }
.sl-ed-legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.sl-ed-legend i.w { background: #fff; }
.sl-ed-legend i.o { background: repeating-linear-gradient(90deg, #ffaa5a 0 3px, transparent 3px 6px); }
.sl-ed-legend i.b { height: 8px; background: rgba(120,190,255,.28); }
.sl-ed-legend i.r { height: 8px; background: rgba(255,120,140,.6); }
.sl-ed-foot { display: flex; align-items: center; gap: 14px; padding: 10px 16px 14px; flex-wrap: wrap; }
.sl-ed-sel { font-size: 12.5px; color: #9fb0cc; font-variant-numeric: tabular-nums; min-width: 150px; }
.sl-ed-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.sl-ed-actions button { height: 30px; padding: 0 12px; border-radius: 9px; font-size: 12.5px; color: #dbe6f7; background: rgba(255,255,255,.07); }
.sl-ed-actions button:hover:not(:disabled) { background: rgba(255,255,255,.12); }
.sl-ed-actions button:disabled { opacity: .35; }
.sl-ed-empty { flex: 1; display: grid; place-content: center; justify-items: center; gap: 14px; color: #b9c6dc; font-size: 14px; }
`;var be=require("react/jsx-runtime"),ot="dsh-singinglab",Wn=["slots","layout"];function en({size:e=18}){return(0,be.jsxs)("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[(0,be.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,be.jsx)("circle",{cx:"12",cy:"12",r:"2.6"}),(0,be.jsx)("path",{d:"M16.5 7.5a6.4 6.4 0 0 1 1.9 3.2"})]})}var Xn=["singinglab_status","singinglab_prepare","singinglab_import_voice","singinglab_search","singinglab_learn","singinglab_play","singinglab_pitch","singinglab_pitch_edit","singinglab_pitch_undo"],Yt=new Set(["singinglab_pitch","singinglab_pitch_edit","singinglab_pitch_undo"]);function Jn(e,n,t){let s=i=>String(n[i]??"").trim();switch(e){case"singinglab_search":return`${t?"\u627E\u4E86":"\u5728\u627E"}\u300C${s("query")}\u300D`;case"singinglab_learn":return`${t?"\u5B66":"\u51C6\u5907\u5B66"}\u300A${s("title")}\u300B`;case"singinglab_play":return`\u653E\u300A${s("song")}\u300B`;case"singinglab_pitch":return typeof n.start=="number"?`\u770B\u4E86\u300A${s("song")}\u300B${Zt(Number(n.start))}\u2013${Zt(Number(n.end))} \u7684\u97F3\u9AD8`:`${t?"\u770B\u4E86":"\u5728\u770B"}\u300A${s("song")}\u300B\u7684\u97F3\u9AD8`;case"singinglab_pitch_edit":return t?`\u6539\u4E86\u300A${s("song")}\u300B\u7684\u97F3\u9AD8`:`\u5728\u6539\u300A${s("song")}\u300B\u7684\u97F3\u9AD8\uFF0C\u6539\u5B8C\u91CD\u65B0\u5531\u6574\u9996\u2026`;case"singinglab_pitch_undo":return t?`\u64A4\u9500\u4E86\u300A${s("song")}\u300B\u7684\u4FEE\u97F3`:"\u5728\u64A4\u9500\u2026";case"singinglab_prepare":return t?"\u4E00\u952E\u51C6\u5907\u5B66\u6B4C":"\u5728\u51C6\u5907\u5B66\u6B4C\u2026";case"singinglab_import_voice":return t?"\u5BFC\u5165\u5979\u7684\u58F0\u97F3":"\u5728\u5BFC\u5165\u5979\u7684\u58F0\u97F3\u2026";default:return t?"\u770B\u4E86\u5531\u6B4C\u63D2\u4EF6\u7684\u72B6\u6001":"\u5728\u770B\u5531\u6B4C\u63D2\u4EF6\u2026"}}function Kn(e){try{return e?JSON.parse(e):{}}catch{return{}}}var Zt=e=>`${Math.floor(e/60)}:${String(Math.floor(e%60)).padStart(2,"0")}`,Gn=e=>/歌库 id:([\w.-]+)/.exec(e)?.[1]??null;function Vn(e,n){return function(s){let[i,o]=(0,Qt.useState)(!1),d=s.phase==="result",a=Kn(s.block.argsRaw??s.block.call?.argsRaw),c=d?(s.block.content??[]).filter(b=>b.type==="text").map(b=>b.text??"").join(`
`).trim():"",u=c.split(`
`),r=i?c:u[0]??"",m=Yt.has(s.toolName)?Gn(c):null;return(0,be.jsxs)("div",{className:`sl-toolcard${s.block.isError?" is-error":""}`,children:[(0,be.jsx)("span",{className:"sl-toolcard-icon",children:(0,be.jsx)(en,{size:16})}),(0,be.jsxs)("div",{className:"sl-toolcard-body",children:[(0,be.jsxs)("div",{className:"sl-toolcard-title",children:[Jn(s.toolName,a,d),d?null:(0,be.jsx)("span",{className:"sl-toolcard-dots"})]}),r?(0,be.jsx)("div",{className:"sl-toolcard-text",children:r}):null,u.length>1?(0,be.jsx)("button",{className:"sl-toolcard-more",onClick:()=>o(!i),children:i?"\u6536\u8D77":"\u8BE6\u7EC6"}):null]}),m?(0,be.jsx)("button",{className:"sl-toolcard-go",onClick:()=>n(m),children:"\u6253\u5F00\u4FEE\u97F3\u9875"}):Yt.has(s.toolName)?null:(0,be.jsx)("button",{className:"sl-toolcard-go",onClick:e,children:"\u53BB\u5531\u6B4C"})]})}}function Yn(e){e.effect(()=>{let t=document.createElement("style");return t.dataset.plugin="dsh-singinglab",t.textContent=Vt,document.head.append(t),()=>t.remove()},"dsh-singinglab styles"),e.slots.inject("main",()=>e.slots.register({name:"main",key:ot},Gt)),e.slots.inject("sidebar.panellist",()=>e.slots.register({name:"sidebar.panellist",id:ot,order:3,label:()=>"\u5531\u6B4C"},en));let n=Vn(()=>e.layout.selectPanel(ot),t=>{e.layout.selectPanel(ot),V().openEditor(t)});for(let t of Xn)e.slots.inject("tool.call.toolview",()=>e.slots.register({name:"tool.call.toolview",key:t},n));e.effect(()=>(V().startJobs(),()=>{}),"dsh-singinglab player")}
return module.exports;}});