@qumra/fanar 0.0.15 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{TONE_SOFT,TONE_SOLID,cn,useUIText}from"./chunk-N7CZXHOG.js";import{useCallback,useEffect,useRef,useState}from"react";var INITIAL={playing:false,time:0,duration:0,buffered:0,volume:1,muted:false,rate:1,waiting:false,ended:false};function useMedia(){const ref=useRef(null);const[state,setState]=useState(INITIAL);useEffect(()=>{const el=ref.current;if(!el)return;const patch=p=>setState(s=>({...s,...p}));const onTime=()=>{let end=0;const b=el.buffered;for(let i=0;i<b.length;i++){if(b.start(i)<=el.currentTime&&el.currentTime<=b.end(i))end=b.end(i)}patch({time:el.currentTime,buffered:end})};const onMeta=()=>patch({duration:Number.isFinite(el.duration)?el.duration:0,ended:false});const onPlay=()=>patch({playing:true,ended:false});const onPause=()=>patch({playing:false});const onEnded=()=>patch({playing:false,ended:true});const onWaiting=()=>patch({waiting:true});const onPlaying=()=>patch({waiting:false,playing:true});const onVolume=()=>patch({volume:el.volume,muted:el.muted});const onRate=()=>patch({rate:el.playbackRate});el.addEventListener("timeupdate",onTime);el.addEventListener("progress",onTime);el.addEventListener("loadedmetadata",onMeta);el.addEventListener("durationchange",onMeta);el.addEventListener("play",onPlay);el.addEventListener("pause",onPause);el.addEventListener("ended",onEnded);el.addEventListener("waiting",onWaiting);el.addEventListener("playing",onPlaying);el.addEventListener("volumechange",onVolume);el.addEventListener("ratechange",onRate);if(el.readyState>=1)onMeta();return()=>{el.removeEventListener("timeupdate",onTime);el.removeEventListener("progress",onTime);el.removeEventListener("loadedmetadata",onMeta);el.removeEventListener("durationchange",onMeta);el.removeEventListener("play",onPlay);el.removeEventListener("pause",onPause);el.removeEventListener("ended",onEnded);el.removeEventListener("waiting",onWaiting);el.removeEventListener("playing",onPlaying);el.removeEventListener("volumechange",onVolume);el.removeEventListener("ratechange",onRate)}},[]);useEffect(()=>{if(!state.playing)return;let raf=0;const tick=()=>{const el=ref.current;if(el)setState(s=>s.time===el.currentTime?s:{...s,time:el.currentTime});raf=requestAnimationFrame(tick)};raf=requestAnimationFrame(tick);return()=>cancelAnimationFrame(raf)},[state.playing]);const toggle=useCallback(()=>{const el=ref.current;if(!el)return;if(el.paused)void el.play();else el.pause()},[]);const seek=useCallback(to=>{const el=ref.current;if(!el)return;el.currentTime=Math.max(0,Math.min(to,el.duration||0))},[]);const skip=useCallback(by=>{const el=ref.current;if(el)seek(el.currentTime+by)},[seek]);const setVolume=useCallback(v=>{const el=ref.current;if(!el)return;el.volume=Math.max(0,Math.min(1,v));if(el.volume>0)el.muted=false},[]);const toggleMute=useCallback(()=>{const el=ref.current;if(el)el.muted=!el.muted},[]);const setRate=useCallback(r=>{const el=ref.current;if(el)el.playbackRate=r},[]);return{ref,state,toggle,seek,skip,setVolume,toggleMute,setRate}}function formatTime(seconds){if(!Number.isFinite(seconds)||seconds<0)return"0:00";const total=Math.floor(seconds);const s=total%60;const m=Math.floor(total/60)%60;const h=Math.floor(total/3600);const pad=n=>String(n).padStart(2,"0");return h>0?`${h}:${pad(m)}:${pad(s)}`:`${m}:${pad(s)}`}var RATES=[.5,.75,1,1.25,1.5,2];import{useCallback as useCallback2,useRef as useRef2,useState as useState2}from"react";import{jsx,jsxs}from"react/jsx-runtime";function Scrubber({time,duration,buffered,onSeek,chapters,label,size="md"}){const ui=useUIText();const bar=useRef2(null);const[hover,setHover]=useState2(null);const pct=duration>0?time/duration*100:0;const buf=duration>0?(buffered??0)/duration*100:0;const atPointer=useCallback2(clientX=>{const box=bar.current?.getBoundingClientRect();if(!box||duration<=0)return null;const ratio=Math.max(0,Math.min(1,(clientX-box.left)/box.width));return ratio*duration},[duration]);const h=size==="sm"?"h-1":"h-1.5";return jsxs("div",{dir:"ltr",className:"relative group/scrub w-full py-2 select-none",children:[hover!==null&&jsx("span",{"data-num":true,style:{insetInlineStart:`${hover/duration*100}%`},className:"absolute bottom-full mb-1 -translate-x-1/2 px-1.5 py-0.5 rounded-xs bg-night text-white text-micro font-bold pointer-events-none whitespace-nowrap",children:formatTime(hover)}),jsxs("div",{ref:bar,onMouseMove:e=>setHover(atPointer(e.clientX)),onMouseLeave:()=>setHover(null),className:cn("relative w-full rounded-full bg-white/25 overflow-visible",h),children:[jsx("span",{"aria-hidden":"true",style:{width:`${buf}%`},className:cn("absolute inset-y-0 start-0 rounded-full bg-white/30",h)}),jsx("span",{"aria-hidden":"true",style:{width:`${pct}%`},className:cn("absolute inset-y-0 start-0 rounded-full bg-brand",h)}),chapters?.map(c=>duration>0&&c.at>0&&c.at<duration?jsx("span",{title:c.title,"aria-hidden":"true",style:{insetInlineStart:`${c.at/duration*100}%`},className:"absolute inset-y-0 w-0.5 -translate-x-1/2 bg-night/50"},`${c.at}-${c.title}`):null),jsx("span",{"aria-hidden":"true",style:{insetInlineStart:`${pct}%`},className:"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 size-3 rounded-full bg-white shadow-raise scale-0 transition-transform group-hover/scrub:scale-100 group-focus-within/scrub:scale-100"}),jsx("input",{type:"range",min:0,max:duration||0,step:.1,value:time,"aria-label":label??ui.playbackPosition,"aria-valuetext":`${formatTime(time)} \u0645\u0646 ${formatTime(duration)}`,onChange:e=>onSeek(Number(e.target.value)),className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"})]})]})}import{useCallback as useCallback3,useEffect as useEffect2,useRef as useRef3,useState as useState3}from"react";import{Gauge,Loader2,Maximize,Minimize,Pause,PictureInPicture2,Play,RotateCcw,RotateCw,Volume2,VolumeX,X}from"lucide-react";import{jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";function CtrlButton({onClick,label,children,active}){return jsx2("button",{type:"button",onClick,"aria-label":label,title:label,className:cn("size-9 rounded-sm inline-flex items-center justify-center shrink-0 cursor-pointer transition-colors","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white",active?"bg-white/20 text-white":"text-white/80 hover:bg-white/15 hover:text-white"),children})}function SuggestionCard({item,wide}){return jsxs2("button",{type:"button",onClick:item.onSelect,className:cn("group/sug flex flex-col gap-1.5 text-start cursor-pointer shrink-0","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white rounded-sm",wide?"w-full":"w-40"),children:[jsxs2("span",{className:"relative block w-full aspect-video rounded-sm overflow-clip bg-white/10 border border-white/15 transition-colors group-hover/sug:border-brand-100",children:[item.poster&&jsx2("img",{src:item.poster,alt:"",loading:"lazy",className:"w-full h-full object-cover"}),typeof item.duration==="number"&&jsx2("span",{"data-num":true,className:"absolute bottom-1 end-1 px-1 py-px rounded-xs bg-black/75 text-white text-micro font-bold",children:formatTime(item.duration)})]}),jsx2("span",{className:"text-caption font-bold text-white/90 leading-snug line-clamp-2 group-hover/sug:text-white",children:item.title})]})}function VideoPlayer({src,poster,title,chapters,captions,suggestions,suggestAt=10,autoPlay,loop,className}){const ui=useUIText();const{ref,state,toggle,seek,skip,setVolume,toggleMute,setRate}=useMedia();const shell=useRef3(null);const[full,setFull]=useState3(false);const[rateOpen,setRateOpen]=useState3(false);const[idle,setIdle]=useState3(false);const[dismissed,setDismissed]=useState3(false);const idleTimer=useRef3(void 0);const wake=useCallback3(()=>{setIdle(false);clearTimeout(idleTimer.current);idleTimer.current=setTimeout(()=>setIdle(true),2500)},[]);useEffect2(()=>{if(!state.playing)clearTimeout(idleTimer.current)},[state.playing]);useEffect2(()=>()=>clearTimeout(idleTimer.current),[]);useEffect2(()=>{const onFs=()=>setFull(document.fullscreenElement===shell.current);document.addEventListener("fullscreenchange",onFs);return()=>document.removeEventListener("fullscreenchange",onFs)},[]);async function toggleFull(){if(document.fullscreenElement)await document.exitFullscreen();else await shell.current?.requestFullscreen()}async function togglePip(){const el=ref.current;if(!el)return;if(document.pictureInPictureElement)await document.exitPictureInPicture();else await el.requestPictureInPicture()}const onKey=e=>{const keys=[" ","k","ArrowRight","ArrowLeft","ArrowUp","ArrowDown","m","f","j","l"];if(!keys.includes(e.key))return;e.preventDefault();wake();const el=ref.current;if(!el)return;switch(e.key){case" ":case"k":toggle();break;case"ArrowRight":case"l":skip(e.key==="l"?10:5);break;case"ArrowLeft":case"j":skip(e.key==="j"?-10:-5);break;case"ArrowUp":setVolume(el.volume+.1);break;case"ArrowDown":setVolume(el.volume-.1);break;case"m":toggleMute();break;case"f":void toggleFull();break}};const showChrome=!state.playing||!idle||state.ended;const has=Boolean(suggestions?.length);const remaining=state.duration-state.time;const nearEnd=state.duration>0&&remaining<=suggestAt&&!state.ended;const showStrip=has&&nearEnd&&!dismissed;const showEndScreen=has&&state.ended;return jsxs2("div",{ref:shell,role:"group","aria-label":title??ui.videoPlayer,tabIndex:0,onKeyDown:onKey,onMouseMove:wake,onMouseLeave:()=>state.playing&&setIdle(true),className:cn("relative bg-night rounded-card overflow-clip group/player","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",full?"w-screen h-screen rounded-none":"w-full aspect-video",className),children:[jsx2("video",{ref,src,poster,autoPlay,loop,playsInline:true,onClick:toggle,className:"w-full h-full object-contain cursor-pointer bg-night",children:captions&&jsx2("track",{kind:"captions",src:captions,srcLang:"ar",label:ui.arabic,default:true})}),state.waiting&&jsx2("span",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:jsx2(Loader2,{size:40,className:"animate-spin text-white/90","aria-hidden":"true"})}),(!state.playing||state.ended)&&!state.waiting&&!showEndScreen&&jsx2("button",{type:"button",onClick:toggle,"aria-label":state.ended?"\u0634\u063A\u0651\u0644 \u0645\u0646 \u0627\u0644\u0623\u0648\u0644":"\u062A\u0634\u063A\u064A\u0644",className:"absolute inset-0 flex items-center justify-center cursor-pointer group/big",children:jsx2("span",{className:"size-16 rounded-full bg-brand text-white flex items-center justify-center shadow-pop transition-transform group-hover/big:scale-110",children:state.ended?jsx2(RotateCcw,{size:26,"aria-hidden":"true"}):jsx2(Play,{size:28,className:"ml-1 icon-fixed",fill:"currentColor","aria-hidden":"true"})})}),title&&jsx2("div",{className:cn("absolute inset-x-0 top-0 p-4 bg-gradient-to-b from-black/70 to-transparent transition-opacity duration-200 pointer-events-none",showChrome?"opacity-100":"opacity-0"),children:jsx2("span",{className:"text-body font-extrabold text-white [text-wrap:balance]",children:title})}),showStrip&&jsx2("div",{className:"absolute inset-x-0 bottom-20 px-3 animate-[fade-in_.2s_ease-out]",children:jsxs2("div",{className:"flex items-end gap-3 p-3 rounded-card bg-black/70 backdrop-blur-sm border border-white/10",children:[jsxs2("div",{className:"flex flex-col gap-2 min-w-0 flex-1",children:[jsxs2("span",{className:"flex items-center gap-2 text-caption font-extrabold text-white/90",children:["\u0634\u0648\u0641 \u0643\u0645\u0627\u0646",jsxs2("span",{"data-num":true,className:"text-micro font-bold text-brand-100",children:["\u0627\u0644\u0645\u0642\u0637\u0639 \u0628\u064A\u062E\u0644\u0635 \u062E\u0644\u0627\u0644 ",Math.max(0,Math.ceil(remaining))," \u062B"]})]}),jsx2("div",{className:"flex gap-2.5 overflow-x-auto pb-1",children:suggestions?.slice(0,4).map(s=>jsx2(SuggestionCard,{item:s},s.id))})]}),jsx2("button",{type:"button",onClick:()=>setDismissed(true),"aria-label":ui.hideSuggestions,className:"size-8 rounded-sm shrink-0 flex items-center justify-center text-white/60 hover:bg-white/15 hover:text-white cursor-pointer transition-colors",children:jsx2(X,{size:16,"aria-hidden":"true"})})]})}),showEndScreen&&jsxs2("div",{className:"absolute inset-0 bg-night/92 backdrop-blur-sm flex flex-col gap-4 p-5 overflow-y-auto animate-[fade-in_.22s_ease-out]",children:[jsxs2("div",{className:"flex items-center justify-between gap-3 shrink-0",children:[jsx2("span",{className:"text-body font-extrabold text-white",children:ui.seeMore}),jsxs2("button",{type:"button",onClick:toggle,className:"inline-flex items-center gap-2 h-9 px-3.5 rounded-sm bg-white/10 text-white text-ui font-bold cursor-pointer transition-colors hover:bg-white/20",children:[jsx2(RotateCcw,{size:15,"aria-hidden":"true"}),"\u0634\u063A\u0651\u0644 \u0645\u0646 \u0627\u0644\u0623\u0648\u0644"]})]}),jsx2("div",{className:"grid gap-3 [grid-template-columns:repeat(auto-fill,minmax(150px,1fr))]",children:suggestions?.map(s=>jsx2(SuggestionCard,{item:s,wide:true},s.id))})]}),jsxs2("div",{className:cn("absolute inset-x-0 bottom-0 px-3 pb-2 pt-8 bg-gradient-to-t from-black/80 to-transparent transition-opacity duration-200",showChrome?"opacity-100":"opacity-0 pointer-events-none"),children:[jsx2(Scrubber,{time:state.time,duration:state.duration,buffered:state.buffered,onSeek:seek,chapters}),jsxs2("div",{className:"flex items-center gap-1 flex-wrap",children:[jsx2(CtrlButton,{onClick:toggle,label:state.playing?"\u0625\u064A\u0642\u0627\u0641 \u0645\u0624\u0642\u062A":"\u062A\u0634\u063A\u064A\u0644",children:state.playing?jsx2(Pause,{size:18,fill:"currentColor"}):jsx2(Play,{size:18,fill:"currentColor"})}),jsx2(CtrlButton,{onClick:()=>skip(-10),label:ui.back10,children:jsx2(RotateCcw,{size:17})}),jsx2(CtrlButton,{onClick:()=>skip(10),label:ui.forward10,children:jsx2(RotateCw,{size:17})}),jsxs2("span",{className:"flex items-center group/vol",children:[jsx2(CtrlButton,{onClick:toggleMute,label:state.muted?"\u062A\u0634\u063A\u064A\u0644 \u0627\u0644\u0635\u0648\u062A":"\u0643\u062A\u0645",children:state.muted||state.volume===0?jsx2(VolumeX,{size:18}):jsx2(Volume2,{size:18})}),jsx2("span",{className:"h-9 flex items-center overflow-clip w-0 group-hover/vol:w-20 focus-within:w-20 transition-[width] duration-200",children:jsx2("input",{type:"range",min:0,max:1,step:.05,value:state.muted?0:state.volume,onChange:e=>setVolume(Number(e.target.value)),"aria-label":ui.volume,dir:"ltr",className:"w-20 accent-brand cursor-pointer"})})]}),jsxs2("span",{"data-num":true,className:"px-2 text-caption font-bold text-white/90 whitespace-nowrap",children:[formatTime(state.time)," / ",formatTime(state.duration)]}),jsx2("span",{className:"flex-1"}),jsxs2("span",{className:"relative flex",children:[jsx2(CtrlButton,{onClick:()=>setRateOpen(v=>!v),label:ui.playbackSpeed,active:rateOpen,children:jsxs2("span",{className:"flex items-center gap-1",children:[jsx2(Gauge,{size:17}),state.rate!==1&&jsxs2("span",{"data-num":true,className:"text-micro font-extrabold",children:[state.rate,"\xD7"]})]})}),rateOpen&&jsx2("div",{className:"absolute bottom-full end-0 mb-2 py-1 rounded-card bg-night border border-white/15 shadow-pop min-w-20",children:RATES.map(r=>jsx2("button",{type:"button",onClick:()=>{setRate(r);setRateOpen(false)},className:cn("w-full px-3 py-1.5 text-ui text-center cursor-pointer transition-colors",r===state.rate?"text-brand-100 font-extrabold":"text-white/80 hover:bg-white/10"),children:jsxs2("span",{"data-num":true,children:[r,"\xD7"]})},r))})]}),"pictureInPictureEnabled"in document&&jsx2(CtrlButton,{onClick:()=>void togglePip(),label:ui.pictureInPicture,children:jsx2(PictureInPicture2,{size:17})}),jsx2(CtrlButton,{onClick:()=>void toggleFull(),label:full?"\u062E\u0631\u0648\u062C \u0645\u0646 \u0645\u0644\u0621 \u0627\u0644\u0634\u0627\u0634\u0629":"\u0645\u0644\u0621 \u0627\u0644\u0634\u0627\u0634\u0629",children:full?jsx2(Minimize,{size:17}):jsx2(Maximize,{size:17})})]})]})]})}import{memo,useEffect as useEffect3,useImperativeHandle,useMemo,useRef as useRef4,useState as useState4}from"react";import{Gauge as Gauge2,Loader2 as Loader22,Pause as Pause2,Play as Play2,RotateCcw as RotateCcw2,RotateCw as RotateCw2,Volume2 as Volume22,VolumeX as VolumeX2}from"lucide-react";import{jsx as jsx3,jsxs as jsxs3}from"react/jsx-runtime";var PEAKS_CACHE=new Map;var ANALYSIS_BUCKETS=512;var BAR=3;var GAP=2;async function analyse(src,buckets){const cached=PEAKS_CACHE.get(src);if(cached!==void 0)return cached;try{const res=await fetch(src);const raw=await res.arrayBuffer();const Ctx2=window.AudioContext??window.webkitAudioContext;if(!Ctx2)throw new Error("\u0645\u0627\u0641\u064A\u0634 Web Audio");const ctx=new Ctx2;const buffer=await ctx.decodeAudioData(raw);const data=buffer.getChannelData(0);const per=Math.floor(data.length/buckets);const peaks=[];for(let i=0;i<buckets;i++){let max=0;for(let j=0;j<per;j++){const v=Math.abs(data[i*per+j]??0);if(v>max)max=v}peaks.push(max)}void ctx.close();const top=Math.max(...peaks,.01);const normalised=peaks.map(p=>p/top);PEAKS_CACHE.set(src,normalised);return normalised}catch{PEAKS_CACHE.set(src,null);return null}}var BarRow=memo(function BarRow2({peaks,color}){return jsx3("div",{"aria-hidden":"true",className:"absolute inset-0 flex items-center justify-between",style:{gap:GAP},children:peaks.map((p,i)=>jsx3("span",{style:{height:`${Math.max(8,p*100)}%`,width:BAR},className:cn("shrink-0 rounded-full",color)},i))})});function Waveform({peaks,time,duration,onSeek,bars,height=48}){const ui=useUIText();const box=useRef4(null);const[count,setCount]=useState4(bars??0);const[width,setWidth]=useState4(0);useEffect3(()=>{const el=box.current;if(!el)return;const measure=()=>{setWidth(el.clientWidth);if(!bars)setCount(Math.max(8,Math.floor(el.clientWidth/(BAR+GAP))))};measure();const ro=new ResizeObserver(measure);ro.observe(el);return()=>ro.disconnect()},[bars]);const shown=useMemo(()=>{if(count<=0)return[];const per=peaks.length/count;return Array.from({length:count},(_,i)=>{let max=0;for(let j=Math.floor(i*per);j<Math.floor((i+1)*per);j++){if(peaks[j]>max)max=peaks[j]}return max})},[peaks,count]);const played=duration>0?Math.min(1,time/duration):0;const grey=useMemo(()=>jsx3(BarRow,{peaks:shown,color:"bg-border/50"}),[shown]);const teal=useMemo(()=>jsx3(BarRow,{peaks:shown,color:"bg-brand"}),[shown]);return jsxs3("div",{dir:"ltr",className:"relative w-full",style:{height},children:[jsx3("div",{ref:box,className:"absolute inset-0",children:grey}),jsx3("div",{"aria-hidden":"true",className:"absolute inset-y-0 start-0 overflow-clip pointer-events-none",style:{width:`${played*100}%`},children:jsx3("div",{className:"relative h-full",style:{width:width||"100%"},children:teal})}),jsx3("input",{type:"range",min:0,max:duration||0,step:.1,value:time,"aria-label":ui.playbackPosition,"aria-valuetext":`${formatTime(time)} \u0645\u0646 ${formatTime(duration)}`,onChange:e=>onSeek(Number(e.target.value)),className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"})]})}function Btn({onClick,label,children,small}){return jsx3("button",{type:"button",onClick,"aria-label":label,title:label,className:cn("rounded-sm inline-flex items-center justify-center shrink-0 cursor-pointer transition-colors","text-muted hover:bg-hover hover:text-ink","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",small?"size-8":"size-9"),children})}function AudioPlayer({src,title,meta,cover,variant="card",bars,onLevel,mediaRef,className}){const ui=useUIText();const{ref,state,toggle,seek,skip,setVolume,toggleMute,setRate}=useMedia();const[peaks,setPeaks]=useState4(null);const[analysing,setAnalysing]=useState4(false);const[rateOpen,setRateOpen]=useState4(false);const alive=useRef4(true);useEffect3(()=>{alive.current=true;return()=>{alive.current=false}},[]);useEffect3(()=>{if(variant==="row")return;let live=true;void Promise.resolve().then(()=>live&&setAnalysing(true));void analyse(src,ANALYSIS_BUCKETS).then(p=>{live=false;if(!alive.current)return;setPeaks(p);setAnalysing(false)})},[src,variant]);useImperativeHandle(mediaRef,()=>ref.current,[ref]);useEffect3(()=>{if(!onLevel)return;if(!peaks||state.duration<=0||!state.playing){onLevel(0);return}const i=Math.min(peaks.length-1,Math.floor(state.time/state.duration*peaks.length));onLevel(peaks[i]??0)},[onLevel,peaks,state.time,state.duration,state.playing]);const PlayBtn=jsx3("button",{type:"button",onClick:toggle,"aria-label":state.playing?"\u0625\u064A\u0642\u0627\u0641 \u0645\u0624\u0642\u062A":"\u062A\u0634\u063A\u064A\u0644",className:cn("rounded-full bg-brand text-white flex items-center justify-center shrink-0 cursor-pointer transition-colors hover:bg-brand-hover","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",variant==="row"?"size-9":"size-11"),children:state.playing?jsx3(Pause2,{size:variant==="row"?16:18,fill:"currentColor","aria-hidden":"true"}):jsx3(Play2,{size:variant==="row"?16:18,className:"ml-0.5 icon-fixed",fill:"currentColor","aria-hidden":"true"})});const audio=jsx3("audio",{ref,src,preload:"metadata"});if(variant==="row"){return jsxs3("div",{className:cn("flex items-center gap-3 p-2.5 rounded-card border border-line bg-surface",className),children:[audio,PlayBtn,jsxs3("span",{className:"flex flex-col gap-1 flex-1 min-w-0",children:[title&&jsx3("span",{className:"text-ui font-bold text-ink truncate",children:title}),jsxs3("span",{dir:"ltr",className:"relative h-1 rounded-full bg-hover overflow-clip",children:[jsx3("span",{"aria-hidden":"true",style:{width:`${state.duration?state.time/state.duration*100:0}%`},className:"absolute inset-y-0 start-0 bg-brand rounded-full"}),jsx3("input",{type:"range",min:0,max:state.duration||0,step:.1,value:state.time,"aria-label":ui.playbackPosition,onChange:e=>seek(Number(e.target.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"})]})]}),jsxs3("span",{"data-num":true,className:"text-micro text-muted2 shrink-0",children:[formatTime(state.time)," / ",formatTime(state.duration)]})]})}return jsxs3("div",{className:cn("flex flex-col gap-3.5 p-4 rounded-card border border-line bg-surface",className),children:[audio,(title||cover)&&jsxs3("div",{className:"flex items-center gap-3",children:[cover&&jsx3("img",{src:cover,alt:"",className:"size-12 rounded-sm object-cover border border-line shrink-0"}),jsxs3("span",{className:"flex flex-col gap-0.5 min-w-0",children:[title&&jsx3("span",{className:"text-body font-extrabold text-ink truncate",children:title}),meta&&jsx3("span",{className:"text-caption text-muted truncate",children:meta})]})]}),jsx3("div",{className:"min-h-12 flex items-center",children:analysing?jsxs3("span",{className:"w-full flex items-center justify-center gap-2 text-caption text-muted2",children:[jsx3(Loader22,{size:14,className:"animate-spin","aria-hidden":"true"}),"\u0628\u064A\u062D\u0644\u0651\u0644 \u0627\u0644\u0645\u0648\u062C\u0629\u2026"]}):peaks?jsx3(Waveform,{peaks,time:state.time,duration:state.duration,onSeek:seek,bars}):jsxs3("span",{dir:"ltr",className:"relative w-full h-1.5 rounded-full bg-hover",children:[jsx3("span",{"aria-hidden":"true",style:{width:`${state.duration?state.time/state.duration*100:0}%`},className:"absolute inset-y-0 start-0 bg-brand rounded-full"}),jsx3("input",{type:"range",min:0,max:state.duration||0,step:.1,value:state.time,"aria-label":ui.playbackPosition,onChange:e=>seek(Number(e.target.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"})]})}),jsxs3("div",{className:"flex items-center gap-1 flex-wrap",children:[PlayBtn,jsx3(Btn,{onClick:()=>skip(-10),label:ui.back10,children:jsx3(RotateCcw2,{size:16})}),jsx3(Btn,{onClick:()=>skip(10),label:ui.forward10,children:jsx3(RotateCw2,{size:16})}),jsxs3("span",{className:"flex items-center group/vol",children:[jsx3(Btn,{onClick:toggleMute,label:state.muted?"\u062A\u0634\u063A\u064A\u0644 \u0627\u0644\u0635\u0648\u062A":"\u0643\u062A\u0645",children:state.muted||state.volume===0?jsx3(VolumeX2,{size:16}):jsx3(Volume22,{size:16})}),jsx3("span",{className:"h-9 flex items-center overflow-clip w-0 group-hover/vol:w-16 focus-within:w-16 transition-[width] duration-200",children:jsx3("input",{type:"range",min:0,max:1,step:.05,value:state.muted?0:state.volume,onChange:e=>setVolume(Number(e.target.value)),"aria-label":ui.volume,dir:"ltr",className:"w-16 accent-brand cursor-pointer"})})]}),jsxs3("span",{"data-num":true,className:"px-2 text-caption font-bold text-ink2 whitespace-nowrap",children:[formatTime(state.time)," / ",formatTime(state.duration)]}),jsx3("span",{className:"flex-1"}),jsxs3("span",{className:"relative flex",children:[jsx3(Btn,{onClick:()=>setRateOpen(v=>!v),label:ui.playbackSpeed,children:jsxs3("span",{className:"flex items-center gap-1",children:[jsx3(Gauge2,{size:16}),state.rate!==1&&jsxs3("span",{"data-num":true,className:"text-micro font-extrabold text-brand-ink",children:[state.rate,"\xD7"]})]})}),rateOpen&&jsx3("div",{className:"absolute bottom-full end-0 mb-2 py-1 rounded-card bg-surface border border-line shadow-panel min-w-20 z-20",children:RATES.map(r=>jsx3("button",{type:"button",onClick:()=>{setRate(r);setRateOpen(false)},className:cn("w-full px-3 py-1.5 text-ui text-center cursor-pointer transition-colors",r===state.rate?"bg-soft text-brand-ink font-extrabold":"text-ink2 hover:bg-hover"),children:jsxs3("span",{"data-num":true,children:[r,"\xD7"]})},r))})]})]})]})}import{useEffect as useEffect4,useRef as useRef5,useState as useState5}from"react";var SOURCES=new WeakMap;function useAudioLevel(ref,{bands=5,enabled=true}={}){const level=useRef5(0);const bandsRef=useRef5(Array.from({length:bands},()=>0));const[ready,setReady]=useState5(false);const[failed,setFailed]=useState5(false);useEffect4(()=>{const el=ref.current;if(!el||!enabled)return;let raf=0;let analyser=null;let dead=false;function connect(){if(dead||analyser)return;const media=ref.current;if(!media)return;try{let entry=SOURCES.get(media);if(!entry){const Ctx2=window.AudioContext??window.webkitAudioContext;if(!Ctx2)throw new Error("\u0645\u0627\u0641\u064A\u0634 Web Audio");const ctx=new Ctx2;const source=ctx.createMediaElementSource(media);source.connect(ctx.destination);entry={ctx,source};SOURCES.set(media,entry)}void entry.ctx.resume();analyser=entry.ctx.createAnalyser();analyser.fftSize=1024;analyser.smoothingTimeConstant=.75;entry.source.connect(analyser);setReady(true);loop()}catch{setFailed(true)}}const spectrum=new Uint8Array(512);const wave=new Uint8Array(1024);let peak=.02;function loop(){if(dead||!analyser)return;analyser.getByteFrequencyData(spectrum);analyser.getByteTimeDomainData(wave);let sum=0;for(let i=0;i<wave.length;i++){const v=(wave[i]-128)/128;sum+=v*v}const rms=Math.sqrt(sum/wave.length);peak=Math.max(rms,peak*.995);level.current=Math.min(1,rms/Math.max(peak,.015));const out=[];for(let b=0;b<bands;b++){const from=Math.floor(spectrum.length**(b/bands))-1;const to=Math.floor(spectrum.length**((b+1)/bands));let peak2=0;for(let i=Math.max(0,from);i<to;i++){if(spectrum[i]>peak2)peak2=spectrum[i]}out.push(peak2/255)}bandsRef.current=out;raf=requestAnimationFrame(loop)}el.addEventListener("play",connect);if(!el.paused)connect();return()=>{dead=true;cancelAnimationFrame(raf);el.removeEventListener("play",connect);analyser?.disconnect()}},[ref,bands,enabled]);return{level,bands:bandsRef,ready,failed}}import{createContext,useCallback as useCallback4,useContext,useEffect as useEffect7,useMemo as useMemo2,useRef as useRef8,useState as useState8}from"react";import{useEffect as useEffect5,useLayoutEffect,useRef as useRef6,useState as useState6}from"react";import{X as X2}from"lucide-react";import{jsx as jsx4,jsxs as jsxs4}from"react/jsx-runtime";var GAP2=10;var EDGE=12;var WIDTH=264;function CoachHintSurface({item,onClose}){const ui=useUIText();const anchors=useCoachAnchors();const box=useRef6(null);const[pos,setPos]=useState6(null);const anchorId=item.where?.anchor;const gone=anchorId!==void 0&&!anchors.get(anchorId);useLayoutEffect(()=>{if(!anchorId)return;const el=anchors.get(anchorId);if(!el)return;function place(){const target=anchors.get(anchorId);const self=box.current;if(!target||!self)return;const a=target.getBoundingClientRect();const h=self.offsetHeight;const below=a.bottom+GAP2;const above=window.innerHeight-a.top+GAP2;const flip=below+h>window.innerHeight-EDGE&&above>below;const left=Math.min(window.innerWidth-WIDTH-EDGE,Math.max(EDGE,a.left+a.width/2-WIDTH/2));setPos({top:flip?a.top-h-GAP2:a.bottom+GAP2,left,above:flip})}place();window.addEventListener("scroll",place,true);window.addEventListener("resize",place);return()=>{window.removeEventListener("scroll",place,true);window.removeEventListener("resize",place)}},[anchorId,anchors]);useEffect5(()=>{if(!anchorId)return;const el=anchors.get(anchorId);if(!el)return;const prev=el.style.boxShadow;el.style.boxShadow="0 0 0 3px var(--color-soft), 0 0 0 4px var(--color-brand)";el.style.borderRadius=el.style.borderRadius||"var(--radius-field)";return()=>{el.style.boxShadow=prev}},[anchorId,anchors]);useEffect5(()=>{if(gone)onClose()},[gone,onClose]);useEffect5(()=>{const onKey=e=>{if(e.key==="Escape")onClose()};document.addEventListener("keydown",onKey);return()=>document.removeEventListener("keydown",onKey)},[onClose]);if(gone)return null;return jsxs4("div",{ref:box,role:"status",style:{width:WIDTH,top:pos?.top??-9999,left:pos?.left??-9999},className:cn("fixed z-[80] rounded-card border border-line bg-surface shadow-pop p-3 flex flex-col gap-1.5","animate-qfade",pos?"opacity-100":"opacity-0"),children:[jsxs4("div",{className:"flex items-start gap-2",children:[jsxs4("span",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[item.title&&jsx4("span",{className:"text-ui font-extrabold text-ink",children:item.title}),jsx4("span",{className:"text-caption leading-[1.75] text-ink2 [text-wrap:pretty]",children:item.text})]}),jsx4("button",{type:"button","aria-label":ui.close,onClick:onClose,className:"size-6 -me-1 -mt-0.5 rounded-xs flex items-center justify-center text-muted hover:text-ink hover:bg-hover cursor-pointer transition-colors shrink-0",children:jsx4(X2,{size:13,"aria-hidden":"true"})})]}),jsx4("span",{"aria-hidden":"true",className:cn("absolute start-1/2 -ms-1.5 size-3 rotate-45 bg-surface border-line",pos?.above?"-bottom-1.5 border-e border-b":"-top-1.5 border-s border-t")})]})}import{useEffect as useEffect6,useRef as useRef7,useState as useState7}from"react";import{X as X3}from"lucide-react";import{Fragment,jsx as jsx5,jsxs as jsxs5}from"react/jsx-runtime";function CoachAudioSurface({item,onClose,orb,region}){const ui=useUIText();const box={top:0,bottom:0,insetInlineStart:0,insetInlineEnd:0,...region};const anchors=useCoachAnchors();const[time,setTime]=useState7(0);const wrap=useRef7(null);const level=useRef7(0);const active=item.lines.findIndex(l=>time>=l.start&&time<l.end);const line=active>=0?item.lines[active]:item.lines[0];useEffect6(()=>{const onKey=e=>{if(e.key==="Escape")onClose()};document.addEventListener("keydown",onKey);return()=>document.removeEventListener("keydown",onKey)},[onClose]);useEffect6(()=>{const el=wrap.current?.querySelector("audio");if(!el)return;const onTime=()=>setTime(el.currentTime);el.addEventListener("timeupdate",onTime);return()=>el.removeEventListener("timeupdate",onTime)},[]);useEffect6(()=>{const id=item.where?.anchor;if(!id)return;const el=anchors.get(id);if(!el)return;const prev=el.style.boxShadow;el.style.boxShadow="0 0 0 3px var(--color-soft), 0 0 0 4px var(--color-brand)";return()=>{el.style.boxShadow=prev}},[item,anchors]);useEffect6(()=>{if(!orb)return;let raf=0;let alive=true;let peaks=null;void(async()=>{try{const Ctx2=window.AudioContext??window.webkitAudioContext;if(!Ctx2)return;const raw=await(await fetch(item.src)).arrayBuffer();const ctx=new Ctx2;const buffer=await ctx.decodeAudioData(raw);void ctx.close();if(!alive)return;const data=buffer.getChannelData(0);const BUCKETS=600;const per=Math.floor(data.length/BUCKETS);const out=new Float32Array(BUCKETS);for(let i=0;i<BUCKETS;i++){let sum=0;for(let j=0;j<per;j++){const v=data[i*per+j];sum+=v*v}out[i]=Math.min(1,Math.sqrt(sum/per)*3.2)}peaks=out}catch{}})();const el=wrap.current?.querySelector("audio");const loop=()=>{if(peaks&&el&&el.duration>0){const i=Math.floor(el.currentTime/el.duration*peaks.length);level.current=peaks[Math.min(i,peaks.length-1)]??0}raf=requestAnimationFrame(loop)};loop();return()=>{alive=false;cancelAnimationFrame(raf)}},[item.src,orb]);return jsxs5(Fragment,{children:[jsx5("button",{type:"button","aria-label":ui.closeExplainer,onClick:onClose,style:box,className:"fixed z-[78] bg-night/25 backdrop-blur-[1.5px] cursor-pointer animate-qfade"}),jsxs5("div",{ref:wrap,style:box,className:"fixed z-[79] flex flex-col pointer-events-none",children:[orb&&jsx5("div",{"aria-hidden":"true",className:"flex-1 min-h-0 flex items-center justify-center animate-qfade",children:orb(level)}),jsx5("div",{className:"shrink-0 pointer-events-auto animate-tip-up",role:"region","aria-label":item.headline,children:jsx5("div",{className:"bg-surface border-t border-line shadow-sheet",children:jsxs5("div",{className:"mx-auto max-w-shell px-[22px] py-3 flex flex-col gap-2.5",children:[jsxs5("div",{className:"flex items-center gap-2.5",children:[jsx5("span",{"aria-live":"polite",className:"flex-1 min-w-0 text-ui font-bold leading-[1.7] text-ink [text-wrap:pretty]",children:line?.text}),jsx5("button",{type:"button","aria-label":ui.close,onClick:onClose,className:"size-8 rounded-sm flex items-center justify-center text-muted hover:text-ink hover:bg-hover cursor-pointer transition-colors shrink-0",children:jsx5(X3,{size:15,"aria-hidden":"true"})})]}),jsx5(AudioPlayer,{src:item.src,title:item.headline,meta:item.meta})]})})})]})]})}import{jsx as jsx6,jsxs as jsxs6}from"react/jsx-runtime";var Ctx=createContext(null);var AnchorCtx=createContext(null);function useCoachAnchors(){const ctx=useContext(AnchorCtx);if(!ctx)throw new Error("<Coach> \u0644\u0627\u0632\u0645 \u064A\u0643\u0648\u0646 \u062C\u0648\u0651\u0647 <CoachProvider>");return ctx}function readSeen(key){try{return JSON.parse(localStorage.getItem(key)??"[]")}catch{return[]}}function CoachProvider({items,path,orb,region,storageKey="qumra-coach-seen",disabled,children}){const[seenIds,setSeenIds]=useState8(()=>readSeen(storageKey));const[openId,setOpenId]=useState8(null);const[openPath,setOpenPath]=useState8(path);const shownId=openPath===path?openId:null;const anchors=useRef8(new Map);const anchorApi=useMemo2(()=>({set:(id,el)=>{if(el)anchors.current.set(id,el);else anchors.current.delete(id)},get:id=>anchors.current.get(id)??null}),[]);const markSeen=useCallback4(id=>{setSeenIds(prev=>{if(prev.includes(id))return prev;const next=[...prev,id];try{localStorage.setItem(storageKey,JSON.stringify(next))}catch{}return next})},[storageKey]);const close=useCallback4(()=>{setOpenId(id=>{if(id)markSeen(id);return null})},[markSeen]);useEffect7(()=>{if(disabled)return;const candidate=items.find(it=>(it.when??"enter")!=="manual"&&(it.where?.path===void 0||it.where.path===path)&&!seenIds.includes(it.id));if(!candidate)return;const when=candidate.when??"enter";const delay=when.startsWith("idle:")?Number(when.slice(5,-1))*1e3:0;const timer=setTimeout(()=>{setOpenId(candidate.id);setOpenPath(path)},delay);return()=>clearTimeout(timer)},[items,path,disabled]);const api=useMemo2(()=>({show:id=>{if(disabled||seenIds.includes(id))return;setOpenId(id);setOpenPath(path)},replay:id=>{setOpenId(id);setOpenPath(path)},close,current:items.find(it=>it.id===shownId)??null,seen:id=>seenIds.includes(id),reset:()=>{setSeenIds([]);try{localStorage.removeItem(storageKey)}catch{}}}),[items,shownId,path,seenIds,close,disabled,storageKey]);const current=api.current;return jsx6(AnchorCtx.Provider,{value:anchorApi,children:jsxs6(Ctx.Provider,{value:api,children:[children,current?.kind==="hint"&&jsx6(CoachHintSurface,{item:current,onClose:close}),current?.kind==="audio"&&jsx6(CoachAudioSurface,{item:current,onClose:close,orb,region})]})})}function useCoach(){const ctx=useContext(Ctx);if(!ctx)throw new Error("useCoach \u0644\u0627\u0632\u0645 \u064A\u062A\u0646\u0627\u062F\u0649 \u062C\u0648\u0651\u0647 <CoachProvider>");return ctx}function useCoachOptional(){return useContext(Ctx)}import{cloneElement,isValidElement,useEffect as useEffect8,useRef as useRef9}from"react";import{jsx as jsx7}from"react/jsx-runtime";function Coach({id,asChild,children}){const anchors=useCoachAnchors();const own=useRef9(null);useEffect8(()=>{if(asChild)return;const el=own.current?.firstElementChild??own.current;anchors.set(id,el);return()=>anchors.set(id,null)},[id,anchors,asChild]);if(asChild&&isValidElement(children)){return cloneElement(children,{ref:el=>anchors.set(id,el)})}return jsx7("span",{ref:own,className:"contents",children})}var coachSeconds=item=>item.lines[item.lines.length-1]?.end??0;import{Info}from"lucide-react";import{jsx as jsx8,jsxs as jsxs7}from"react/jsx-runtime";function Badge({children,tone="neutral",variant="soft",size="md",dot,icon,className}){return jsxs7("span",{className:cn("inline-flex items-center gap-1.5 rounded-full font-bold whitespace-nowrap",size==="sm"?"text-micro px-2 py-0.5":"text-caption px-2.5 py-1",variant==="solid"?TONE_SOLID[tone]:TONE_SOFT[tone],className),children:[dot&&jsx8("span",{"aria-hidden":"true",className:"size-1.5 rounded-full bg-current shrink-0"}),icon,children]})}function Counter({value,max=99}){if(value<=0)return null;return jsx8("span",{"data-num":true,dir:"ltr",className:"inline-flex items-center justify-center min-w-[18px] h-[18px] px-1.5 rounded-full bg-danger text-white text-micro font-extrabold leading-none",children:value>max?`${max}+`:value})}var AVATAR_SIZES={xs:"size-7 text-micro",sm:"size-9 text-ui",md:"size-11 text-body",lg:"size-14 text-h4"};function initials(name){return name.trim().split(/\s+/).slice(0,2).map(w=>w[0]).join("")}function Avatar({name,src,size="md",square,className}){const shape=square?"rounded-field":"rounded-full";if(src){return jsx8("img",{src,alt:name,loading:"lazy",className:cn("object-cover border border-line shrink-0",shape,AVATAR_SIZES[size],className)})}return jsx8("span",{role:"img","aria-label":name,className:cn("flex items-center justify-center font-extrabold bg-soft text-brand-ink shrink-0",shape,AVATAR_SIZES[size],className),children:initials(name)})}function StatCard({icon:Icon,tone="brand",label,value,hint,coachId,className}){const ui=useUIText();const coach=useCoachOptional();const explained=Boolean(coachId&&coach);const body=jsxs7("div",{className:cn("relative bg-surface border border-line rounded-card p-4 flex flex-col gap-2",className),children:[jsxs7("span",{className:"flex items-center gap-2.5",children:[Icon&&jsx8("span",{"aria-hidden":"true",className:cn("size-[30px] rounded-sm flex items-center justify-center shrink-0",TONE_SOFT[tone]),children:jsx8(Icon,{size:15,strokeWidth:2})}),jsx8("span",{className:"text-ui text-muted",children:label}),explained&&jsx8("button",{type:"button",onClick:()=>coach.replay(coachId),"aria-label":typeof label==="string"?`\u0645\u0627 \u0645\u0639\u0646\u0649 \xAB${label}\xBB\u061F`:"\u0645\u0627 \u0645\u0639\u0646\u0649 \u0647\u0630\u0627 \u0627\u0644\u0631\u0642\u0645\u061F",title:ui.whatIsThisNumber,className:cn("ms-auto -me-1 -mt-1 size-7 rounded-full shrink-0 flex items-center justify-center","text-brand cursor-pointer transition-colors","hover:bg-soft hover:text-brand-hover","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand"),children:jsx8(Info,{size:15,strokeWidth:2,"aria-hidden":"true"})})]}),jsx8("span",{"data-num":true,className:"text-h3 font-extrabold leading-none whitespace-nowrap",children:value}),hint&&jsx8("span",{className:"text-micro text-muted2",children:hint})]});return explained?jsx8(Coach,{id:coachId,children:body}):body}function Card({children,padded=true,className}){return jsx8("div",{className:cn("bg-surface border border-line rounded-card",padded?"p-5":"overflow-clip",className),children})}function CardHeader({title,description,action,coachId}){const ui=useUIText();const coach=useCoachOptional();const explained=Boolean(coachId&&coach);const head=jsxs7("div",{className:"flex items-start justify-between gap-4",children:[jsxs7("div",{className:"flex flex-col gap-1 min-w-0",children:[jsx8("h3",{className:"text-lead font-extrabold text-ink m-0",children:title}),description&&jsx8("p",{className:"text-ui text-muted m-0",children:description})]}),(action||explained)&&jsxs7("div",{className:"shrink-0 flex items-center gap-1.5",children:[action,explained&&jsx8("button",{type:"button",onClick:()=>coach.replay(coachId),"aria-label":typeof title==="string"?`\u0645\u0627 \u0645\u0639\u0646\u0649 \xAB${title}\xBB\u061F`:"\u0645\u0627 \u0647\u0630\u0627 \u0627\u0644\u0642\u0633\u0645\u061F",title:ui.explainToMe,className:cn("size-7 rounded-full shrink-0 flex items-center justify-center","text-brand cursor-pointer transition-colors","hover:bg-soft hover:text-brand-hover","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand"),children:jsx8(Info,{size:15,strokeWidth:2,"aria-hidden":"true"})})]})]});return explained?jsx8(Coach,{id:coachId,children:head}):head}function PageHeader({title,hint,actions}){return jsxs7("div",{className:"flex items-start justify-between gap-3.5 flex-wrap",children:[jsxs7("div",{className:"flex flex-col gap-1 min-w-0",children:[jsx8("h1",{className:"text-h3 font-black text-ink m-0 [text-wrap:balance]",children:title}),hint&&jsx8("p",{className:"text-ui text-muted m-0 [text-wrap:pretty]",children:hint})]}),actions&&jsx8("div",{className:"flex items-center gap-2.5 min-w-0 flex-wrap",children:actions})]})}function Progress({value,max=100,label,tone="brand",className}){const safe=Math.min(max,Math.max(0,value));const pct=safe/max*100;const fill={neutral:"bg-muted2",brand:"bg-brand",amber:"bg-amber",green:"bg-green-solid",red:"bg-danger",violet:"bg-violet-solid"};return jsxs7("div",{className:cn("flex flex-col gap-1.5",className),children:[label&&jsxs7("span",{className:"flex items-center justify-between gap-3 text-caption",children:[jsx8("span",{className:"text-ink2",children:label}),jsxs7("span",{"data-num":true,className:"text-muted font-bold",children:[Math.round(pct),"%"]})]}),jsx8("span",{role:"progressbar","aria-valuenow":safe,"aria-valuemin":0,"aria-valuemax":max,className:"h-1.5 rounded-full bg-hover overflow-clip block",children:jsx8("span",{className:cn("block h-full rounded-full transition-[width] duration-500",fill[tone]),style:{width:`${pct}%`}})})]})}function Skeleton({variant="text",width,className}){return jsx8("span",{"aria-hidden":"true",style:{width},className:cn("block bg-skeleton animate-skeleton",variant==="text"&&"h-3.5 rounded-xs w-full",variant==="block"&&"h-20 rounded-field w-full",variant==="circle"&&"size-10 rounded-full",className)})}export{useMedia,formatTime,Scrubber,VideoPlayer,AudioPlayer,useAudioLevel,CoachProvider,useCoach,useCoachOptional,Coach,coachSeconds,Badge,Counter,Avatar,StatCard,Card,CardHeader,PageHeader,Progress,Skeleton};
|
|
2
|
+
import{TONE_SOFT,TONE_SOLID,cn,useUIText}from"./chunk-N7CZXHOG.js";import{useCallback,useEffect,useRef,useState}from"react";var INITIAL={playing:false,time:0,duration:0,buffered:0,volume:1,muted:false,rate:1,waiting:false,ended:false};function useMedia(){const ref=useRef(null);const[state,setState]=useState(INITIAL);useEffect(()=>{const el=ref.current;if(!el)return;const patch=p=>setState(s=>({...s,...p}));const onTime=()=>{let end=0;const b=el.buffered;for(let i=0;i<b.length;i++){if(b.start(i)<=el.currentTime&&el.currentTime<=b.end(i))end=b.end(i)}patch({time:el.currentTime,buffered:end})};const onMeta=()=>patch({duration:Number.isFinite(el.duration)?el.duration:0,ended:false});const onPlay=()=>patch({playing:true,ended:false});const onPause=()=>patch({playing:false});const onEnded=()=>patch({playing:false,ended:true});const onWaiting=()=>patch({waiting:true});const onPlaying=()=>patch({waiting:false,playing:true});const onVolume=()=>patch({volume:el.volume,muted:el.muted});const onRate=()=>patch({rate:el.playbackRate});el.addEventListener("timeupdate",onTime);el.addEventListener("progress",onTime);el.addEventListener("loadedmetadata",onMeta);el.addEventListener("durationchange",onMeta);el.addEventListener("play",onPlay);el.addEventListener("pause",onPause);el.addEventListener("ended",onEnded);el.addEventListener("waiting",onWaiting);el.addEventListener("playing",onPlaying);el.addEventListener("volumechange",onVolume);el.addEventListener("ratechange",onRate);if(el.readyState>=1)onMeta();return()=>{el.removeEventListener("timeupdate",onTime);el.removeEventListener("progress",onTime);el.removeEventListener("loadedmetadata",onMeta);el.removeEventListener("durationchange",onMeta);el.removeEventListener("play",onPlay);el.removeEventListener("pause",onPause);el.removeEventListener("ended",onEnded);el.removeEventListener("waiting",onWaiting);el.removeEventListener("playing",onPlaying);el.removeEventListener("volumechange",onVolume);el.removeEventListener("ratechange",onRate)}},[]);useEffect(()=>{if(!state.playing)return;let raf=0;const tick=()=>{const el=ref.current;if(el)setState(s=>s.time===el.currentTime?s:{...s,time:el.currentTime});raf=requestAnimationFrame(tick)};raf=requestAnimationFrame(tick);return()=>cancelAnimationFrame(raf)},[state.playing]);const toggle=useCallback(()=>{const el=ref.current;if(!el)return;if(el.paused)void el.play();else el.pause()},[]);const seek=useCallback(to=>{const el=ref.current;if(!el)return;el.currentTime=Math.max(0,Math.min(to,el.duration||0))},[]);const skip=useCallback(by=>{const el=ref.current;if(el)seek(el.currentTime+by)},[seek]);const setVolume=useCallback(v=>{const el=ref.current;if(!el)return;el.volume=Math.max(0,Math.min(1,v));if(el.volume>0)el.muted=false},[]);const toggleMute=useCallback(()=>{const el=ref.current;if(el)el.muted=!el.muted},[]);const setRate=useCallback(r=>{const el=ref.current;if(el)el.playbackRate=r},[]);return{ref,state,toggle,seek,skip,setVolume,toggleMute,setRate}}function formatTime(seconds){if(!Number.isFinite(seconds)||seconds<0)return"0:00";const total=Math.floor(seconds);const s=total%60;const m=Math.floor(total/60)%60;const h=Math.floor(total/3600);const pad=n=>String(n).padStart(2,"0");return h>0?`${h}:${pad(m)}:${pad(s)}`:`${m}:${pad(s)}`}var RATES=[.5,.75,1,1.25,1.5,2];import{useCallback as useCallback2,useRef as useRef2,useState as useState2}from"react";import{jsx,jsxs}from"react/jsx-runtime";function Scrubber({time,duration,buffered,onSeek,chapters,label,size="md"}){const ui=useUIText();const bar=useRef2(null);const[hover,setHover]=useState2(null);const pct=duration>0?time/duration*100:0;const buf=duration>0?(buffered??0)/duration*100:0;const atPointer=useCallback2(clientX=>{const box=bar.current?.getBoundingClientRect();if(!box||duration<=0)return null;const ratio=Math.max(0,Math.min(1,(clientX-box.left)/box.width));return ratio*duration},[duration]);const h=size==="sm"?"h-1":"h-1.5";return jsxs("div",{dir:"ltr",className:"relative group/scrub w-full py-2 select-none",children:[hover!==null&&jsx("span",{"data-num":true,style:{insetInlineStart:`${hover/duration*100}%`},className:"absolute bottom-full mb-1 -translate-x-1/2 px-1.5 py-0.5 rounded-xs bg-night text-white text-micro font-bold pointer-events-none whitespace-nowrap",children:formatTime(hover)}),jsxs("div",{ref:bar,onMouseMove:e=>setHover(atPointer(e.clientX)),onMouseLeave:()=>setHover(null),className:cn("relative w-full rounded-full bg-white/25 overflow-visible",h),children:[jsx("span",{"aria-hidden":"true",style:{width:`${buf}%`},className:cn("absolute inset-y-0 start-0 rounded-full bg-white/30",h)}),jsx("span",{"aria-hidden":"true",style:{width:`${pct}%`},className:cn("absolute inset-y-0 start-0 rounded-full bg-brand",h)}),chapters?.map(c=>duration>0&&c.at>0&&c.at<duration?jsx("span",{title:c.title,"aria-hidden":"true",style:{insetInlineStart:`${c.at/duration*100}%`},className:"absolute inset-y-0 w-0.5 -translate-x-1/2 bg-night/50"},`${c.at}-${c.title}`):null),jsx("span",{"aria-hidden":"true",style:{insetInlineStart:`${pct}%`},className:"absolute top-1/2 -translate-y-1/2 -translate-x-1/2 size-3 rounded-full bg-white shadow-raise scale-0 transition-transform group-hover/scrub:scale-100 group-focus-within/scrub:scale-100"}),jsx("input",{type:"range",min:0,max:duration||0,step:.1,value:time,"aria-label":label??ui.playbackPosition,"aria-valuetext":`${formatTime(time)} \u0645\u0646 ${formatTime(duration)}`,onChange:e=>onSeek(Number(e.target.value)),className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"})]})]})}import{useCallback as useCallback3,useEffect as useEffect2,useRef as useRef3,useState as useState3}from"react";import{Gauge,Loader2,Maximize,Minimize,Pause,PictureInPicture2,Play,RotateCcw,RotateCw,Volume2,VolumeX,X}from"lucide-react";import{jsx as jsx2,jsxs as jsxs2}from"react/jsx-runtime";function CtrlButton({onClick,label,children,active}){return jsx2("button",{type:"button",onClick,"aria-label":label,title:label,className:cn("size-9 rounded-sm inline-flex items-center justify-center shrink-0 cursor-pointer transition-colors","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white",active?"bg-white/20 text-white":"text-white/80 hover:bg-white/15 hover:text-white"),children})}function SuggestionCard({item,wide}){return jsxs2("button",{type:"button",onClick:item.onSelect,className:cn("group/sug flex flex-col gap-1.5 text-start cursor-pointer shrink-0","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white rounded-sm",wide?"w-full":"w-40"),children:[jsxs2("span",{className:"relative block w-full aspect-video rounded-sm overflow-clip bg-white/10 border border-white/15 transition-colors group-hover/sug:border-brand-100",children:[item.poster&&jsx2("img",{src:item.poster,alt:"",loading:"lazy",className:"w-full h-full object-cover"}),typeof item.duration==="number"&&jsx2("span",{"data-num":true,className:"absolute bottom-1 end-1 px-1 py-px rounded-xs bg-black/75 text-white text-micro font-bold",children:formatTime(item.duration)})]}),jsx2("span",{className:"text-caption font-bold text-white/90 leading-snug line-clamp-2 group-hover/sug:text-white",children:item.title})]})}function VideoPlayer({src,poster,title,chapters,captions,suggestions,suggestAt=10,autoPlay,loop,className}){const ui=useUIText();const{ref,state,toggle,seek,skip,setVolume,toggleMute,setRate}=useMedia();const shell=useRef3(null);const[full,setFull]=useState3(false);const[rateOpen,setRateOpen]=useState3(false);const[idle,setIdle]=useState3(false);const[dismissed,setDismissed]=useState3(false);const idleTimer=useRef3(void 0);const wake=useCallback3(()=>{setIdle(false);clearTimeout(idleTimer.current);idleTimer.current=setTimeout(()=>setIdle(true),2500)},[]);useEffect2(()=>{if(!state.playing)clearTimeout(idleTimer.current)},[state.playing]);useEffect2(()=>()=>clearTimeout(idleTimer.current),[]);useEffect2(()=>{const onFs=()=>setFull(document.fullscreenElement===shell.current);document.addEventListener("fullscreenchange",onFs);return()=>document.removeEventListener("fullscreenchange",onFs)},[]);async function toggleFull(){if(document.fullscreenElement)await document.exitFullscreen();else await shell.current?.requestFullscreen()}async function togglePip(){const el=ref.current;if(!el)return;if(document.pictureInPictureElement)await document.exitPictureInPicture();else await el.requestPictureInPicture()}const onKey=e=>{const keys=[" ","k","ArrowRight","ArrowLeft","ArrowUp","ArrowDown","m","f","j","l"];if(!keys.includes(e.key))return;e.preventDefault();wake();const el=ref.current;if(!el)return;switch(e.key){case" ":case"k":toggle();break;case"ArrowRight":case"l":skip(e.key==="l"?10:5);break;case"ArrowLeft":case"j":skip(e.key==="j"?-10:-5);break;case"ArrowUp":setVolume(el.volume+.1);break;case"ArrowDown":setVolume(el.volume-.1);break;case"m":toggleMute();break;case"f":void toggleFull();break}};const showChrome=!state.playing||!idle||state.ended;const has=Boolean(suggestions?.length);const remaining=state.duration-state.time;const nearEnd=state.duration>0&&remaining<=suggestAt&&!state.ended;const showStrip=has&&nearEnd&&!dismissed;const showEndScreen=has&&state.ended;return jsxs2("div",{ref:shell,role:"group","aria-label":title??ui.videoPlayer,tabIndex:0,onKeyDown:onKey,onMouseMove:wake,onMouseLeave:()=>state.playing&&setIdle(true),className:cn("relative bg-night rounded-card overflow-clip group/player","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",full?"w-screen h-screen rounded-none":"w-full aspect-video",className),children:[jsx2("video",{ref,src,poster,autoPlay,loop,playsInline:true,onClick:toggle,className:"w-full h-full object-contain cursor-pointer bg-night",children:captions&&jsx2("track",{kind:"captions",src:captions,srcLang:"ar",label:ui.arabic,default:true})}),state.waiting&&jsx2("span",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:jsx2(Loader2,{size:40,className:"animate-spin text-white/90","aria-hidden":"true"})}),(!state.playing||state.ended)&&!state.waiting&&!showEndScreen&&jsx2("button",{type:"button",onClick:toggle,"aria-label":state.ended?"\u0634\u063A\u0651\u0644 \u0645\u0646 \u0627\u0644\u0623\u0648\u0644":"\u062A\u0634\u063A\u064A\u0644",className:"absolute inset-0 flex items-center justify-center cursor-pointer group/big",children:jsx2("span",{className:"size-16 rounded-full bg-brand text-white flex items-center justify-center shadow-pop transition-transform group-hover/big:scale-110",children:state.ended?jsx2(RotateCcw,{size:26,"aria-hidden":"true"}):jsx2(Play,{size:28,className:"ml-1 icon-fixed",fill:"currentColor","aria-hidden":"true"})})}),title&&jsx2("div",{className:cn("absolute inset-x-0 top-0 p-4 bg-gradient-to-b from-black/70 to-transparent transition-opacity duration-200 pointer-events-none",showChrome?"opacity-100":"opacity-0"),children:jsx2("span",{className:"text-body font-extrabold text-white [text-wrap:balance]",children:title})}),showStrip&&jsx2("div",{className:"absolute inset-x-0 bottom-20 px-3 animate-[fade-in_.2s_ease-out]",children:jsxs2("div",{className:"flex items-end gap-3 p-3 rounded-card bg-black/70 backdrop-blur-sm border border-white/10",children:[jsxs2("div",{className:"flex flex-col gap-2 min-w-0 flex-1",children:[jsxs2("span",{className:"flex items-center gap-2 text-caption font-extrabold text-white/90",children:["\u0634\u0648\u0641 \u0643\u0645\u0627\u0646",jsxs2("span",{"data-num":true,className:"text-micro font-bold text-brand-100",children:["\u0627\u0644\u0645\u0642\u0637\u0639 \u0628\u064A\u062E\u0644\u0635 \u062E\u0644\u0627\u0644 ",Math.max(0,Math.ceil(remaining))," \u062B"]})]}),jsx2("div",{className:"flex gap-2.5 overflow-x-auto pb-1",children:suggestions?.slice(0,4).map(s=>jsx2(SuggestionCard,{item:s},s.id))})]}),jsx2("button",{type:"button",onClick:()=>setDismissed(true),"aria-label":ui.hideSuggestions,className:"size-8 rounded-sm shrink-0 flex items-center justify-center text-white/60 hover:bg-white/15 hover:text-white cursor-pointer transition-colors",children:jsx2(X,{size:16,"aria-hidden":"true"})})]})}),showEndScreen&&jsxs2("div",{className:"absolute inset-0 bg-night/92 backdrop-blur-sm flex flex-col gap-4 p-5 overflow-y-auto animate-[fade-in_.22s_ease-out]",children:[jsxs2("div",{className:"flex items-center justify-between gap-3 shrink-0",children:[jsx2("span",{className:"text-body font-extrabold text-white",children:ui.seeMore}),jsxs2("button",{type:"button",onClick:toggle,className:"inline-flex items-center gap-2 h-9 px-3.5 rounded-sm bg-white/10 text-white text-ui font-bold cursor-pointer transition-colors hover:bg-white/20",children:[jsx2(RotateCcw,{size:15,"aria-hidden":"true"}),"\u0634\u063A\u0651\u0644 \u0645\u0646 \u0627\u0644\u0623\u0648\u0644"]})]}),jsx2("div",{className:"grid gap-3 [grid-template-columns:repeat(auto-fill,minmax(150px,1fr))]",children:suggestions?.map(s=>jsx2(SuggestionCard,{item:s,wide:true},s.id))})]}),jsxs2("div",{className:cn("absolute inset-x-0 bottom-0 px-3 pb-2 pt-8 bg-gradient-to-t from-black/80 to-transparent transition-opacity duration-200",showChrome?"opacity-100":"opacity-0 pointer-events-none"),children:[jsx2(Scrubber,{time:state.time,duration:state.duration,buffered:state.buffered,onSeek:seek,chapters}),jsxs2("div",{className:"flex items-center gap-1 flex-wrap",children:[jsx2(CtrlButton,{onClick:toggle,label:state.playing?"\u0625\u064A\u0642\u0627\u0641 \u0645\u0624\u0642\u062A":"\u062A\u0634\u063A\u064A\u0644",children:state.playing?jsx2(Pause,{size:18,fill:"currentColor"}):jsx2(Play,{size:18,fill:"currentColor"})}),jsx2(CtrlButton,{onClick:()=>skip(-10),label:ui.back10,children:jsx2(RotateCcw,{size:17})}),jsx2(CtrlButton,{onClick:()=>skip(10),label:ui.forward10,children:jsx2(RotateCw,{size:17})}),jsxs2("span",{className:"flex items-center group/vol",children:[jsx2(CtrlButton,{onClick:toggleMute,label:state.muted?"\u062A\u0634\u063A\u064A\u0644 \u0627\u0644\u0635\u0648\u062A":"\u0643\u062A\u0645",children:state.muted||state.volume===0?jsx2(VolumeX,{size:18}):jsx2(Volume2,{size:18})}),jsx2("span",{className:"h-9 flex items-center overflow-clip w-0 group-hover/vol:w-20 focus-within:w-20 transition-[width] duration-200",children:jsx2("input",{type:"range",min:0,max:1,step:.05,value:state.muted?0:state.volume,onChange:e=>setVolume(Number(e.target.value)),"aria-label":ui.volume,dir:"ltr",className:"w-20 accent-brand cursor-pointer"})})]}),jsxs2("span",{"data-num":true,className:"px-2 text-caption font-bold text-white/90 whitespace-nowrap",children:[formatTime(state.time)," / ",formatTime(state.duration)]}),jsx2("span",{className:"flex-1"}),jsxs2("span",{className:"relative flex",children:[jsx2(CtrlButton,{onClick:()=>setRateOpen(v=>!v),label:ui.playbackSpeed,active:rateOpen,children:jsxs2("span",{className:"flex items-center gap-1",children:[jsx2(Gauge,{size:17}),state.rate!==1&&jsxs2("span",{"data-num":true,className:"text-micro font-extrabold",children:[state.rate,"\xD7"]})]})}),rateOpen&&jsx2("div",{className:"absolute bottom-full end-0 mb-2 py-1 rounded-card bg-night border border-white/15 shadow-pop min-w-20",children:RATES.map(r=>jsx2("button",{type:"button",onClick:()=>{setRate(r);setRateOpen(false)},className:cn("w-full px-3 py-1.5 text-ui text-center cursor-pointer transition-colors",r===state.rate?"text-brand-100 font-extrabold":"text-white/80 hover:bg-white/10"),children:jsxs2("span",{"data-num":true,children:[r,"\xD7"]})},r))})]}),"pictureInPictureEnabled"in document&&jsx2(CtrlButton,{onClick:()=>void togglePip(),label:ui.pictureInPicture,children:jsx2(PictureInPicture2,{size:17})}),jsx2(CtrlButton,{onClick:()=>void toggleFull(),label:full?"\u062E\u0631\u0648\u062C \u0645\u0646 \u0645\u0644\u0621 \u0627\u0644\u0634\u0627\u0634\u0629":"\u0645\u0644\u0621 \u0627\u0644\u0634\u0627\u0634\u0629",children:full?jsx2(Minimize,{size:17}):jsx2(Maximize,{size:17})})]})]})]})}import{memo,useEffect as useEffect3,useImperativeHandle,useMemo,useRef as useRef4,useState as useState4}from"react";import{Gauge as Gauge2,Loader2 as Loader22,Pause as Pause2,Play as Play2,RotateCcw as RotateCcw2,RotateCw as RotateCw2,Volume2 as Volume22,VolumeX as VolumeX2}from"lucide-react";import{jsx as jsx3,jsxs as jsxs3}from"react/jsx-runtime";var PEAKS_CACHE=new Map;var ANALYSIS_BUCKETS=512;var BAR=3;var GAP=2;async function analyse(src,buckets){const cached=PEAKS_CACHE.get(src);if(cached!==void 0)return cached;try{const res=await fetch(src);const raw=await res.arrayBuffer();const Ctx2=window.AudioContext??window.webkitAudioContext;if(!Ctx2)throw new Error("\u0645\u0627\u0641\u064A\u0634 Web Audio");const ctx=new Ctx2;const buffer=await ctx.decodeAudioData(raw);const data=buffer.getChannelData(0);const per=Math.floor(data.length/buckets);const peaks=[];for(let i=0;i<buckets;i++){let max=0;for(let j=0;j<per;j++){const v=Math.abs(data[i*per+j]??0);if(v>max)max=v}peaks.push(max)}void ctx.close();const top=Math.max(...peaks,.01);const normalised=peaks.map(p=>p/top);PEAKS_CACHE.set(src,normalised);return normalised}catch{PEAKS_CACHE.set(src,null);return null}}var BarRow=memo(function BarRow2({peaks,color}){return jsx3("div",{"aria-hidden":"true",className:"absolute inset-0 flex items-center justify-between",style:{gap:GAP},children:peaks.map((p,i)=>jsx3("span",{style:{height:`${Math.max(8,p*100)}%`,width:BAR},className:cn("shrink-0 rounded-full",color)},i))})});function Waveform({peaks,time,duration,onSeek,bars,height=48}){const ui=useUIText();const box=useRef4(null);const[count,setCount]=useState4(bars??0);const[width,setWidth]=useState4(0);useEffect3(()=>{const el=box.current;if(!el)return;const measure=()=>{setWidth(el.clientWidth);if(!bars)setCount(Math.max(8,Math.floor(el.clientWidth/(BAR+GAP))))};measure();const ro=new ResizeObserver(measure);ro.observe(el);return()=>ro.disconnect()},[bars]);const shown=useMemo(()=>{if(count<=0)return[];const per=peaks.length/count;return Array.from({length:count},(_,i)=>{let max=0;for(let j=Math.floor(i*per);j<Math.floor((i+1)*per);j++){if(peaks[j]>max)max=peaks[j]}return max})},[peaks,count]);const played=duration>0?Math.min(1,time/duration):0;const grey=useMemo(()=>jsx3(BarRow,{peaks:shown,color:"bg-border/50"}),[shown]);const teal=useMemo(()=>jsx3(BarRow,{peaks:shown,color:"bg-brand"}),[shown]);return jsxs3("div",{dir:"ltr",className:"relative w-full",style:{height},children:[jsx3("div",{ref:box,className:"absolute inset-0",children:grey}),jsx3("div",{"aria-hidden":"true",className:"absolute inset-y-0 start-0 overflow-clip pointer-events-none",style:{width:`${played*100}%`},children:jsx3("div",{className:"relative h-full",style:{width:width||"100%"},children:teal})}),jsx3("input",{type:"range",min:0,max:duration||0,step:.1,value:time,"aria-label":ui.playbackPosition,"aria-valuetext":`${formatTime(time)} \u0645\u0646 ${formatTime(duration)}`,onChange:e=>onSeek(Number(e.target.value)),className:"absolute inset-0 w-full h-full opacity-0 cursor-pointer"})]})}function Btn({onClick,label,children,small}){return jsx3("button",{type:"button",onClick,"aria-label":label,title:label,className:cn("rounded-sm inline-flex items-center justify-center shrink-0 cursor-pointer transition-colors","text-muted hover:bg-hover hover:text-ink","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",small?"size-8":"size-9"),children})}function AudioPlayer({src,title,meta,cover,variant="card",bars,onLevel,mediaRef,className}){const ui=useUIText();const{ref,state,toggle,seek,skip,setVolume,toggleMute,setRate}=useMedia();const[peaks,setPeaks]=useState4(null);const[analysing,setAnalysing]=useState4(false);const[rateOpen,setRateOpen]=useState4(false);const alive=useRef4(true);useEffect3(()=>{alive.current=true;return()=>{alive.current=false}},[]);useEffect3(()=>{if(variant==="row")return;let live=true;void Promise.resolve().then(()=>live&&setAnalysing(true));void analyse(src,ANALYSIS_BUCKETS).then(p=>{live=false;if(!alive.current)return;setPeaks(p);setAnalysing(false)})},[src,variant]);useImperativeHandle(mediaRef,()=>ref.current,[ref]);useEffect3(()=>{if(!onLevel)return;if(!peaks||state.duration<=0||!state.playing){onLevel(0);return}const i=Math.min(peaks.length-1,Math.floor(state.time/state.duration*peaks.length));onLevel(peaks[i]??0)},[onLevel,peaks,state.time,state.duration,state.playing]);const PlayBtn=jsx3("button",{type:"button",onClick:toggle,"aria-label":state.playing?"\u0625\u064A\u0642\u0627\u0641 \u0645\u0624\u0642\u062A":"\u062A\u0634\u063A\u064A\u0644",className:cn("rounded-full bg-brand text-white flex items-center justify-center shrink-0 cursor-pointer transition-colors hover:bg-brand-hover","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand",variant==="row"?"size-9":"size-11"),children:state.playing?jsx3(Pause2,{size:variant==="row"?16:18,fill:"currentColor","aria-hidden":"true"}):jsx3(Play2,{size:variant==="row"?16:18,className:"ml-0.5 icon-fixed",fill:"currentColor","aria-hidden":"true"})});const audio=jsx3("audio",{ref,src,preload:"metadata"});if(variant==="row"){return jsxs3("div",{className:cn("flex items-center gap-3 p-2.5 rounded-card border border-line bg-surface",className),children:[audio,PlayBtn,jsxs3("span",{className:"flex flex-col gap-1 flex-1 min-w-0",children:[title&&jsx3("span",{className:"text-ui font-bold text-ink truncate",children:title}),jsxs3("span",{dir:"ltr",className:"relative h-1 rounded-full bg-hover overflow-clip",children:[jsx3("span",{"aria-hidden":"true",style:{width:`${state.duration?state.time/state.duration*100:0}%`},className:"absolute inset-y-0 start-0 bg-brand rounded-full"}),jsx3("input",{type:"range",min:0,max:state.duration||0,step:.1,value:state.time,"aria-label":ui.playbackPosition,onChange:e=>seek(Number(e.target.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"})]})]}),jsxs3("span",{"data-num":true,className:"text-micro text-muted2 shrink-0",children:[formatTime(state.time)," / ",formatTime(state.duration)]})]})}return jsxs3("div",{className:cn("flex flex-col gap-3.5 p-4 rounded-card border border-line bg-surface",className),children:[audio,(title||cover)&&jsxs3("div",{className:"flex items-center gap-3",children:[cover&&jsx3("img",{src:cover,alt:"",className:"size-12 rounded-sm object-cover border border-line shrink-0"}),jsxs3("span",{className:"flex flex-col gap-0.5 min-w-0",children:[title&&jsx3("span",{className:"text-body font-extrabold text-ink truncate",children:title}),meta&&jsx3("span",{className:"text-caption text-muted truncate",children:meta})]})]}),jsx3("div",{className:"min-h-12 flex items-center",children:analysing?jsxs3("span",{className:"w-full flex items-center justify-center gap-2 text-caption text-muted2",children:[jsx3(Loader22,{size:14,className:"animate-spin","aria-hidden":"true"}),"\u0628\u064A\u062D\u0644\u0651\u0644 \u0627\u0644\u0645\u0648\u062C\u0629\u2026"]}):peaks?jsx3(Waveform,{peaks,time:state.time,duration:state.duration,onSeek:seek,bars}):jsxs3("span",{dir:"ltr",className:"relative w-full h-1.5 rounded-full bg-hover",children:[jsx3("span",{"aria-hidden":"true",style:{width:`${state.duration?state.time/state.duration*100:0}%`},className:"absolute inset-y-0 start-0 bg-brand rounded-full"}),jsx3("input",{type:"range",min:0,max:state.duration||0,step:.1,value:state.time,"aria-label":ui.playbackPosition,onChange:e=>seek(Number(e.target.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"})]})}),jsxs3("div",{className:"flex items-center gap-1 flex-wrap",children:[PlayBtn,jsx3(Btn,{onClick:()=>skip(-10),label:ui.back10,children:jsx3(RotateCcw2,{size:16})}),jsx3(Btn,{onClick:()=>skip(10),label:ui.forward10,children:jsx3(RotateCw2,{size:16})}),jsxs3("span",{className:"flex items-center group/vol",children:[jsx3(Btn,{onClick:toggleMute,label:state.muted?"\u062A\u0634\u063A\u064A\u0644 \u0627\u0644\u0635\u0648\u062A":"\u0643\u062A\u0645",children:state.muted||state.volume===0?jsx3(VolumeX2,{size:16}):jsx3(Volume22,{size:16})}),jsx3("span",{className:"h-9 flex items-center overflow-clip w-0 group-hover/vol:w-16 focus-within:w-16 transition-[width] duration-200",children:jsx3("input",{type:"range",min:0,max:1,step:.05,value:state.muted?0:state.volume,onChange:e=>setVolume(Number(e.target.value)),"aria-label":ui.volume,dir:"ltr",className:"w-16 accent-brand cursor-pointer"})})]}),jsxs3("span",{"data-num":true,className:"px-2 text-caption font-bold text-ink2 whitespace-nowrap",children:[formatTime(state.time)," / ",formatTime(state.duration)]}),jsx3("span",{className:"flex-1"}),jsxs3("span",{className:"relative flex",children:[jsx3(Btn,{onClick:()=>setRateOpen(v=>!v),label:ui.playbackSpeed,children:jsxs3("span",{className:"flex items-center gap-1",children:[jsx3(Gauge2,{size:16}),state.rate!==1&&jsxs3("span",{"data-num":true,className:"text-micro font-extrabold text-brand-ink",children:[state.rate,"\xD7"]})]})}),rateOpen&&jsx3("div",{className:"absolute bottom-full end-0 mb-2 py-1 rounded-card bg-surface border border-line shadow-panel min-w-20 z-20",children:RATES.map(r=>jsx3("button",{type:"button",onClick:()=>{setRate(r);setRateOpen(false)},className:cn("w-full px-3 py-1.5 text-ui text-center cursor-pointer transition-colors",r===state.rate?"bg-soft text-brand-ink font-extrabold":"text-ink2 hover:bg-hover"),children:jsxs3("span",{"data-num":true,children:[r,"\xD7"]})},r))})]})]})]})}import{useEffect as useEffect4,useRef as useRef5,useState as useState5}from"react";var SOURCES=new WeakMap;function useAudioLevel(ref,{bands=5,enabled=true}={}){const level=useRef5(0);const bandsRef=useRef5(Array.from({length:bands},()=>0));const[ready,setReady]=useState5(false);const[failed,setFailed]=useState5(false);useEffect4(()=>{const el=ref.current;if(!el||!enabled)return;let raf=0;let analyser=null;let dead=false;function connect(){if(dead||analyser)return;const media=ref.current;if(!media)return;try{let entry=SOURCES.get(media);if(!entry){const Ctx2=window.AudioContext??window.webkitAudioContext;if(!Ctx2)throw new Error("\u0645\u0627\u0641\u064A\u0634 Web Audio");const ctx=new Ctx2;const source=ctx.createMediaElementSource(media);source.connect(ctx.destination);entry={ctx,source};SOURCES.set(media,entry)}void entry.ctx.resume();analyser=entry.ctx.createAnalyser();analyser.fftSize=1024;analyser.smoothingTimeConstant=.75;entry.source.connect(analyser);setReady(true);loop()}catch{setFailed(true)}}const spectrum=new Uint8Array(512);const wave=new Uint8Array(1024);let peak=.02;function loop(){if(dead||!analyser)return;analyser.getByteFrequencyData(spectrum);analyser.getByteTimeDomainData(wave);let sum=0;for(let i=0;i<wave.length;i++){const v=(wave[i]-128)/128;sum+=v*v}const rms=Math.sqrt(sum/wave.length);peak=Math.max(rms,peak*.995);level.current=Math.min(1,rms/Math.max(peak,.015));const out=[];for(let b=0;b<bands;b++){const from=Math.floor(spectrum.length**(b/bands))-1;const to=Math.floor(spectrum.length**((b+1)/bands));let peak2=0;for(let i=Math.max(0,from);i<to;i++){if(spectrum[i]>peak2)peak2=spectrum[i]}out.push(peak2/255)}bandsRef.current=out;raf=requestAnimationFrame(loop)}el.addEventListener("play",connect);if(!el.paused)connect();return()=>{dead=true;cancelAnimationFrame(raf);el.removeEventListener("play",connect);analyser?.disconnect()}},[ref,bands,enabled]);return{level,bands:bandsRef,ready,failed}}import{createContext,useCallback as useCallback4,useContext,useEffect as useEffect7,useMemo as useMemo2,useRef as useRef8,useState as useState8}from"react";import{useEffect as useEffect5,useLayoutEffect,useRef as useRef6,useState as useState6}from"react";import{X as X2}from"lucide-react";import{jsx as jsx4,jsxs as jsxs4}from"react/jsx-runtime";var GAP2=10;var EDGE=12;var WIDTH=264;function CoachHintSurface({item,onClose}){const ui=useUIText();const anchors=useCoachAnchors();const box=useRef6(null);const[pos,setPos]=useState6(null);const anchorId=item.where?.anchor;const gone=anchorId!==void 0&&!anchors.get(anchorId);useLayoutEffect(()=>{if(!anchorId)return;const el=anchors.get(anchorId);if(!el)return;function place(){const target=anchors.get(anchorId);const self=box.current;if(!target||!self)return;const a=target.getBoundingClientRect();const h=self.offsetHeight;const below=a.bottom+GAP2;const above=window.innerHeight-a.top+GAP2;const flip=below+h>window.innerHeight-EDGE&&above>below;const left=Math.min(window.innerWidth-WIDTH-EDGE,Math.max(EDGE,a.left+a.width/2-WIDTH/2));setPos({top:flip?a.top-h-GAP2:a.bottom+GAP2,left,above:flip})}place();window.addEventListener("scroll",place,true);window.addEventListener("resize",place);return()=>{window.removeEventListener("scroll",place,true);window.removeEventListener("resize",place)}},[anchorId,anchors]);useEffect5(()=>{if(!anchorId)return;const el=anchors.get(anchorId);if(!el)return;const prev=el.style.boxShadow;el.style.boxShadow="0 0 0 3px var(--color-soft), 0 0 0 4px var(--color-brand)";el.style.borderRadius=el.style.borderRadius||"var(--radius-field)";return()=>{el.style.boxShadow=prev}},[anchorId,anchors]);useEffect5(()=>{if(gone)onClose()},[gone,onClose]);useEffect5(()=>{const onKey=e=>{if(e.key==="Escape")onClose()};document.addEventListener("keydown",onKey);return()=>document.removeEventListener("keydown",onKey)},[onClose]);if(gone)return null;return jsxs4("div",{ref:box,role:"status",style:{width:WIDTH,top:pos?.top??-9999,left:pos?.left??-9999},className:cn("fixed z-[80] rounded-card border border-line bg-surface shadow-pop p-3 flex flex-col gap-1.5","animate-qfade",pos?"opacity-100":"opacity-0"),children:[jsxs4("div",{className:"flex items-start gap-2",children:[jsxs4("span",{className:"flex-1 min-w-0 flex flex-col gap-1",children:[item.title&&jsx4("span",{className:"text-ui font-extrabold text-ink",children:item.title}),jsx4("span",{className:"text-caption leading-[1.75] text-ink2 [text-wrap:pretty]",children:item.text})]}),jsx4("button",{type:"button","aria-label":ui.close,onClick:onClose,className:"size-6 -me-1 -mt-0.5 rounded-xs flex items-center justify-center text-muted hover:text-ink hover:bg-hover cursor-pointer transition-colors shrink-0",children:jsx4(X2,{size:13,"aria-hidden":"true"})})]}),jsx4("span",{"aria-hidden":"true",className:cn("absolute start-1/2 -ms-1.5 size-3 rotate-45 bg-surface border-line",pos?.above?"-bottom-1.5 border-e border-b":"-top-1.5 border-s border-t")})]})}import{useEffect as useEffect6,useRef as useRef7,useState as useState7}from"react";import{X as X3}from"lucide-react";import{Fragment,jsx as jsx5,jsxs as jsxs5}from"react/jsx-runtime";function CoachAudioSurface({item,onClose,orb,region}){const ui=useUIText();const box={top:0,bottom:0,insetInlineStart:0,insetInlineEnd:0,...region};const anchors=useCoachAnchors();const[time,setTime]=useState7(0);const wrap=useRef7(null);const level=useRef7(0);const active=item.lines.findIndex(l=>time>=l.start&&time<l.end);const line=active>=0?item.lines[active]:item.lines[0];useEffect6(()=>{const onKey=e=>{if(e.key==="Escape")onClose()};document.addEventListener("keydown",onKey);return()=>document.removeEventListener("keydown",onKey)},[onClose]);useEffect6(()=>{const el=wrap.current?.querySelector("audio");if(!el)return;const onTime=()=>setTime(el.currentTime);el.addEventListener("timeupdate",onTime);return()=>el.removeEventListener("timeupdate",onTime)},[]);useEffect6(()=>{const id=item.where?.anchor;if(!id)return;const el=anchors.get(id);if(!el)return;const prev=el.style.boxShadow;el.style.boxShadow="0 0 0 3px var(--color-soft), 0 0 0 4px var(--color-brand)";return()=>{el.style.boxShadow=prev}},[item,anchors]);useEffect6(()=>{if(!orb)return;let raf=0;let alive=true;let peaks=null;void(async()=>{try{const Ctx2=window.AudioContext??window.webkitAudioContext;if(!Ctx2)return;const raw=await(await fetch(item.src)).arrayBuffer();const ctx=new Ctx2;const buffer=await ctx.decodeAudioData(raw);void ctx.close();if(!alive)return;const data=buffer.getChannelData(0);const BUCKETS=600;const per=Math.floor(data.length/BUCKETS);const out=new Float32Array(BUCKETS);for(let i=0;i<BUCKETS;i++){let sum=0;for(let j=0;j<per;j++){const v=data[i*per+j];sum+=v*v}out[i]=Math.min(1,Math.sqrt(sum/per)*3.2)}peaks=out}catch{}})();const el=wrap.current?.querySelector("audio");const loop=()=>{if(peaks&&el&&el.duration>0){const i=Math.floor(el.currentTime/el.duration*peaks.length);level.current=peaks[Math.min(i,peaks.length-1)]??0}raf=requestAnimationFrame(loop)};loop();return()=>{alive=false;cancelAnimationFrame(raf)}},[item.src,orb]);return jsxs5(Fragment,{children:[jsx5("button",{type:"button","aria-label":ui.closeExplainer,onClick:onClose,style:box,className:"fixed z-[78] bg-night/25 backdrop-blur-[1.5px] cursor-pointer animate-qfade"}),jsxs5("div",{ref:wrap,style:box,className:"fixed z-[79] flex flex-col pointer-events-none",children:[orb&&jsx5("div",{"aria-hidden":"true",className:"flex-1 min-h-0 flex items-center justify-center animate-qfade",children:orb(level)}),jsx5("div",{className:"shrink-0 pointer-events-auto animate-tip-up",role:"region","aria-label":item.headline,children:jsx5("div",{className:"bg-surface border-t border-line shadow-sheet",children:jsxs5("div",{className:"mx-auto max-w-shell px-[22px] py-3 flex flex-col gap-2.5",children:[jsxs5("div",{className:"flex items-center gap-2.5",children:[jsx5("span",{"aria-live":"polite",className:"flex-1 min-w-0 text-ui font-bold leading-[1.7] text-ink [text-wrap:pretty]",children:line?.text}),jsx5("button",{type:"button","aria-label":ui.close,onClick:onClose,className:"size-8 rounded-sm flex items-center justify-center text-muted hover:text-ink hover:bg-hover cursor-pointer transition-colors shrink-0",children:jsx5(X3,{size:15,"aria-hidden":"true"})})]}),jsx5(AudioPlayer,{src:item.src,title:item.headline,meta:item.meta})]})})})]})]})}import{jsx as jsx6,jsxs as jsxs6}from"react/jsx-runtime";var Ctx=createContext(null);var AnchorCtx=createContext(null);function useCoachAnchors(){const ctx=useContext(AnchorCtx);if(!ctx)throw new Error("<Coach> \u0644\u0627\u0632\u0645 \u064A\u0643\u0648\u0646 \u062C\u0648\u0651\u0647 <CoachProvider>");return ctx}function readSeen(key){try{return JSON.parse(localStorage.getItem(key)??"[]")}catch{return[]}}function CoachProvider({items,path,orb,region,storageKey="qumra-coach-seen",disabled,children}){const[seenIds,setSeenIds]=useState8(()=>readSeen(storageKey));const[openId,setOpenId]=useState8(null);const[openPath,setOpenPath]=useState8(path);const shownId=openPath===path?openId:null;const anchors=useRef8(new Map);const anchorApi=useMemo2(()=>({set:(id,el)=>{if(el)anchors.current.set(id,el);else anchors.current.delete(id)},get:id=>anchors.current.get(id)??null}),[]);const markSeen=useCallback4(id=>{setSeenIds(prev=>{if(prev.includes(id))return prev;const next=[...prev,id];try{localStorage.setItem(storageKey,JSON.stringify(next))}catch{}return next})},[storageKey]);const close=useCallback4(()=>{setOpenId(id=>{if(id)markSeen(id);return null})},[markSeen]);useEffect7(()=>{if(disabled)return;const candidate=items.find(it=>(it.when??"enter")!=="manual"&&(it.where?.path===void 0||it.where.path===path)&&!seenIds.includes(it.id));if(!candidate)return;const when=candidate.when??"enter";const delay=when.startsWith("idle:")?Number(when.slice(5,-1))*1e3:0;const timer=setTimeout(()=>{setOpenId(candidate.id);setOpenPath(path)},delay);return()=>clearTimeout(timer)},[items,path,disabled]);const api=useMemo2(()=>({show:id=>{if(disabled||seenIds.includes(id))return;setOpenId(id);setOpenPath(path)},replay:id=>{setOpenId(id);setOpenPath(path)},close,current:items.find(it=>it.id===shownId)??null,seen:id=>seenIds.includes(id),reset:()=>{setSeenIds([]);try{localStorage.removeItem(storageKey)}catch{}}}),[items,shownId,path,seenIds,close,disabled,storageKey]);const current=api.current;return jsx6(AnchorCtx.Provider,{value:anchorApi,children:jsxs6(Ctx.Provider,{value:api,children:[children,current?.kind==="hint"&&jsx6(CoachHintSurface,{item:current,onClose:close}),current?.kind==="audio"&&jsx6(CoachAudioSurface,{item:current,onClose:close,orb,region})]})})}function useCoach(){const ctx=useContext(Ctx);if(!ctx)throw new Error("useCoach \u0644\u0627\u0632\u0645 \u064A\u062A\u0646\u0627\u062F\u0649 \u062C\u0648\u0651\u0647 <CoachProvider>");return ctx}function useCoachOptional(){return useContext(Ctx)}import{cloneElement,isValidElement,useEffect as useEffect8,useRef as useRef9}from"react";import{jsx as jsx7}from"react/jsx-runtime";function Coach({id,asChild,children}){const anchors=useCoachAnchors();const own=useRef9(null);useEffect8(()=>{if(asChild)return;const el=own.current?.firstElementChild??own.current;anchors.set(id,el);return()=>anchors.set(id,null)},[id,anchors,asChild]);if(asChild&&isValidElement(children)){return cloneElement(children,{ref:el=>anchors.set(id,el)})}return jsx7("span",{ref:own,className:"contents",children})}var coachSeconds=item=>item.lines[item.lines.length-1]?.end??0;import{Info}from"lucide-react";import{jsx as jsx8,jsxs as jsxs7}from"react/jsx-runtime";function Badge({children,tone="neutral",variant="soft",size="md",dot,icon,className}){return jsxs7("span",{className:cn("inline-flex items-center gap-1.5 rounded-full font-bold whitespace-nowrap",size==="sm"?"text-micro px-2 py-0.5":"text-caption px-2.5 py-1",variant==="solid"?TONE_SOLID[tone]:TONE_SOFT[tone],className),children:[dot&&jsx8("span",{"aria-hidden":"true",className:"size-1.5 rounded-full bg-current shrink-0"}),icon,children]})}function Counter({value,max=99}){if(value<=0)return null;return jsx8("span",{"data-num":true,dir:"ltr",className:"inline-flex items-center justify-center min-w-[18px] h-[18px] px-1.5 rounded-full bg-danger text-white text-micro font-extrabold leading-none",children:value>max?`${max}+`:value})}var AVATAR_SIZES={xs:"size-7 text-micro",sm:"size-9 text-ui",md:"size-11 text-body",lg:"size-14 text-h4"};function initials(name){return name.trim().split(/\s+/).slice(0,2).map(w=>w[0]).join("")}function Avatar({name,src,size="md",square,className}){const shape=square?"rounded-field":"rounded-full";if(src){return jsx8("img",{src,alt:name,loading:"lazy",className:cn("object-cover border border-line shrink-0",shape,AVATAR_SIZES[size],className)})}return jsx8("span",{role:"img","aria-label":name,className:cn("flex items-center justify-center font-extrabold bg-soft text-brand-ink shrink-0",shape,AVATAR_SIZES[size],className),children:initials(name)})}function StatCard({icon:Icon,tile=false,tone="brand",label,value,hint,coachId,className}){const ui=useUIText();const coach=useCoachOptional();const explained=Boolean(coachId&&coach);const body=jsxs7("div",{className:cn("relative bg-surface border border-line rounded-card p-4 flex flex-col gap-2",className),children:[jsxs7("span",{className:"flex items-center gap-2.5",children:[Icon&&(tile?jsx8(Icon,{size:30,"aria-hidden":"true"}):jsx8("span",{"aria-hidden":"true",className:cn("size-[30px] rounded-sm flex items-center justify-center shrink-0",TONE_SOFT[tone]),children:jsx8(Icon,{size:15,strokeWidth:2})})),jsx8("span",{className:"text-ui text-muted",children:label}),explained&&jsx8("button",{type:"button",onClick:()=>coach.replay(coachId),"aria-label":typeof label==="string"?`\u0645\u0627 \u0645\u0639\u0646\u0649 \xAB${label}\xBB\u061F`:"\u0645\u0627 \u0645\u0639\u0646\u0649 \u0647\u0630\u0627 \u0627\u0644\u0631\u0642\u0645\u061F",title:ui.whatIsThisNumber,className:cn("ms-auto -me-1 -mt-1 size-7 rounded-full shrink-0 flex items-center justify-center","text-brand cursor-pointer transition-colors","hover:bg-soft hover:text-brand-hover","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand"),children:jsx8(Info,{size:15,strokeWidth:2,"aria-hidden":"true"})})]}),jsx8("span",{"data-num":true,className:"text-h3 font-extrabold leading-none whitespace-nowrap",children:value}),hint&&jsx8("span",{className:"text-micro text-muted2",children:hint})]});return explained?jsx8(Coach,{id:coachId,children:body}):body}function Card({children,padded=true,className}){return jsx8("div",{className:cn("bg-surface border border-line rounded-card",padded?"p-5":"overflow-clip",className),children})}function CardHeader({title,description,action,coachId}){const ui=useUIText();const coach=useCoachOptional();const explained=Boolean(coachId&&coach);const head=jsxs7("div",{className:"flex items-start justify-between gap-4",children:[jsxs7("div",{className:"flex flex-col gap-1 min-w-0",children:[jsx8("h3",{className:"text-lead font-extrabold text-ink m-0",children:title}),description&&jsx8("p",{className:"text-ui text-muted m-0",children:description})]}),(action||explained)&&jsxs7("div",{className:"shrink-0 flex items-center gap-1.5",children:[action,explained&&jsx8("button",{type:"button",onClick:()=>coach.replay(coachId),"aria-label":typeof title==="string"?`\u0645\u0627 \u0645\u0639\u0646\u0649 \xAB${title}\xBB\u061F`:"\u0645\u0627 \u0647\u0630\u0627 \u0627\u0644\u0642\u0633\u0645\u061F",title:ui.explainToMe,className:cn("size-7 rounded-full shrink-0 flex items-center justify-center","text-brand cursor-pointer transition-colors","hover:bg-soft hover:text-brand-hover","focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-brand"),children:jsx8(Info,{size:15,strokeWidth:2,"aria-hidden":"true"})})]})]});return explained?jsx8(Coach,{id:coachId,children:head}):head}function PageHeader({title,hint,actions}){return jsxs7("div",{className:"flex items-start justify-between gap-3.5 flex-wrap",children:[jsxs7("div",{className:"flex flex-col gap-1 min-w-0",children:[jsx8("h1",{className:"text-h3 font-black text-ink m-0 [text-wrap:balance]",children:title}),hint&&jsx8("p",{className:"text-ui text-muted m-0 [text-wrap:pretty]",children:hint})]}),actions&&jsx8("div",{className:"flex items-center gap-2.5 min-w-0 flex-wrap",children:actions})]})}function Progress({value,max=100,label,tone="brand",className}){const safe=Math.min(max,Math.max(0,value));const pct=safe/max*100;const fill={neutral:"bg-muted2",brand:"bg-brand",amber:"bg-amber",green:"bg-green-solid",red:"bg-danger",violet:"bg-violet-solid"};return jsxs7("div",{className:cn("flex flex-col gap-1.5",className),children:[label&&jsxs7("span",{className:"flex items-center justify-between gap-3 text-caption",children:[jsx8("span",{className:"text-ink2",children:label}),jsxs7("span",{"data-num":true,className:"text-muted font-bold",children:[Math.round(pct),"%"]})]}),jsx8("span",{role:"progressbar","aria-valuenow":safe,"aria-valuemin":0,"aria-valuemax":max,className:"h-1.5 rounded-full bg-hover overflow-clip block",children:jsx8("span",{className:cn("block h-full rounded-full transition-[width] duration-500",fill[tone]),style:{width:`${pct}%`}})})]})}function Skeleton({variant="text",width,className}){return jsx8("span",{"aria-hidden":"true",style:{width},className:cn("block bg-skeleton animate-skeleton",variant==="text"&&"h-3.5 rounded-xs w-full",variant==="block"&&"h-20 rounded-field w-full",variant==="circle"&&"size-10 rounded-full",className)})}export{useMedia,formatTime,Scrubber,VideoPlayer,AudioPlayer,useAudioLevel,CoachProvider,useCoach,useCoachOptional,Coach,coachSeconds,Badge,Counter,Avatar,StatCard,Card,CardHeader,PageHeader,Progress,Skeleton};
|
package/dist/index.d.ts
CHANGED
|
@@ -2344,6 +2344,22 @@ interface StatCardProps {
|
|
|
2344
2344
|
size?: number;
|
|
2345
2345
|
strokeWidth?: number;
|
|
2346
2346
|
}>;
|
|
2347
|
+
/**
|
|
2348
|
+
* الأيقونة **ترسم سطحها بنفسها** — فلا مربّع تحتها.
|
|
2349
|
+
*
|
|
2350
|
+
* ── ⚠️ ولماذا خيارٌ لا استنتاج ─────────────────────────────────────
|
|
2351
|
+
* المربّع المصبوغ بالنغمة صحيحٌ لرمزٍ خطّيّ يرث `currentColor`: الخطّ
|
|
2352
|
+
* الرفيع على سطح الكرت باهت، والمربّع يمنحه سنداً ويحمل النغمة.
|
|
2353
|
+
*
|
|
2354
|
+
* وأيقونات الأطقم الملوّنة (`qumra-icons` مثلاً) مرسومة على شبكتها
|
|
2355
|
+
* بحوافّها وألوانها، فالمربّع تحتها **صندوقٌ داخل صندوق**، و`tone`
|
|
2356
|
+
* لا أثر لها عليها أصلاً لأنها ليست `currentColor`.
|
|
2357
|
+
*
|
|
2358
|
+
* والمكتبة لا تعرف مصدر الأيقونة — فالتمييز يأتي من المنادي.
|
|
2359
|
+
*
|
|
2360
|
+
* ⚠️ ومعها تصير `tone` بلا أثر في هذا الكرت: لا سطح تصبغه.
|
|
2361
|
+
*/
|
|
2362
|
+
tile?: boolean;
|
|
2347
2363
|
tone?: Tone;
|
|
2348
2364
|
label: ReactNode;
|
|
2349
2365
|
value: ReactNode;
|
|
@@ -2367,7 +2383,7 @@ interface StatCardProps {
|
|
|
2367
2383
|
* وده رقم بيهزّ الثقة في باقي الأرقام. لو محتاج مقارنة استخدم `hint`
|
|
2368
2384
|
* بجملة صريحة، أو `Delta` تحت لما يكون الأساس كبير كفاية.
|
|
2369
2385
|
*/
|
|
2370
|
-
declare function StatCard({ icon: Icon, tone, label, value, hint, coachId, className, }: StatCardProps): react.JSX.Element;
|
|
2386
|
+
declare function StatCard({ icon: Icon, tile, tone, label, value, hint, coachId, className, }: StatCardProps): react.JSX.Element;
|
|
2371
2387
|
declare function Card({ children, padded, className, }: {
|
|
2372
2388
|
children: ReactNode;
|
|
2373
2389
|
padded?: boolean;
|