"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1417],{81417:(e,t,r)=>{r.r(t),r.d(t,{default:()=>c});var l=r(23892),n=r(85848),s=r(66668);function u(e){let{samples:t,duration:r,currentTime:s,onSeek:u,height:a=80}=e,i=(0,n.useRef)(null),c=(0,n.useRef)(null),o=(0,n.useRef)(null),[d,f]=(0,n.useState)(800);return(0,n.useEffect)(()=>{if(!o.current)return;let e=()=>{o.current&&f(o.current.clientWidth)};e();let t=new ResizeObserver(e);return t.observe(o.current),()=>{t.disconnect()}},[]),(0,n.useEffect)(()=>{if(!i.current)return;let e=i.current,r=e.getContext("2d"),l=e.width,n=e.height;r.clearRect(0,0,l,n);let s=Math.floor(t.length/l);r.strokeStyle=getComputedStyle(e).getPropertyValue("--chart-default-fill").trim()||"#3b82f6",r.lineWidth=1.5,r.beginPath();for(let e=0;e<l;e++){let l=n/2*(1-(t[e*s]||0));0===e?r.moveTo(e,l):r.lineTo(e,l)}r.stroke(),r.strokeStyle="hsl(var(--border))",r.lineWidth=1,r.beginPath(),r.moveTo(0,n/2),r.lineTo(l,n/2),r.stroke()},[t,d]),(0,n.useEffect)(()=>{if(!c.current)return;let e=c.current,t=e.getContext("2d"),l=e.width,n=e.height;t.clearRect(0,0,l,n);let u=s/r*l;t.strokeStyle="red",t.lineWidth=2,t.beginPath(),t.moveTo(u,0),t.lineTo(u,n),t.stroke()},[r,s]),(0,l.jsx)("div",{className:"w-full",children:(0,l.jsxs)("div",{ref:o,className:"relative w-full cursor-pointer rounded overflow-hidden bg-muted/20 border border-border",style:{height:a},onClick:function(e){if(!i.current)return;let t=i.current.getBoundingClientRect(),l=(e.clientX-t.left)/t.width*r;u(Math.max(0,Math.min(r,l)))},children:[(0,l.jsx)("canvas",{ref:i,width:d,height:a,className:"absolute inset-0 w-full h-full"}),(0,l.jsx)("canvas",{ref:c,width:d,height:a,className:"absolute inset-0 w-full h-full pointer-events-none"})]})})}r(89116);var a=r(65102),i=r(70621);function c(e){let{audioUrl:t,autoPlay:r=!1,alt:c}=e,o=(0,n.useRef)(null),[d,f]=(0,n.useState)(0),{audioData:h,isLoading:m,error:x}=(0,i.s)(t),v=e=>{var t,r;(null==(r=o.current)||null==(t=r.audio)?void 0:t.current)&&(o.current.audio.current.currentTime=e)};return((0,n.useEffect)(()=>{var e,t;r&&h&&(null==(t=o.current)||null==(e=t.audio)?void 0:e.current)&&o.current.audio.current.play().catch(()=>{})},[r,h]),x)?(0,l.jsx)("div",{className:"p-4 w-full flex items-center justify-start h-[280px]",children:(0,l.jsxs)("div",{className:"flex flex-col items-start space-y-3 max-w-full overflow-hidden",children:[c&&(0,l.jsx)("span",{className:"text-sm font-medium text-foreground break-all line-clamp-2",children:c}),(0,l.jsx)("span",{className:"text-xs break-all line-clamp-3 text-left text-destructive",children:x.message})]})}):m||!h?(0,l.jsx)("div",{className:"p-4 w-full flex items-center justify-center h-[280px]",children:(0,l.jsxs)("div",{className:"flex flex-col items-center space-y-3",children:[(0,l.jsx)("div",{className:"w-12 h-12 border-4 border-muted-foreground border-t-transparent rounded-full animate-spin"}),(0,l.jsx)("span",{className:"text-sm text-muted-foreground",children:"Loading audio..."})]})}):(0,l.jsxs)("div",{className:"p-2 w-full space-y-2",children:[(0,l.jsx)(s.A,{ref:o,src:t,autoPlay:r,autoPlayAfterSrcChange:r,showJumpControls:!1,customAdditionalControls:[],layout:"horizontal-reverse",listenInterval:100,onListen:()=>{var e,t;(null==(t=o.current)||null==(e=t.audio)?void 0:e.current)&&f(o.current.audio.current.currentTime)}}),(0,l.jsx)(u,{samples:h.samples,duration:h.duration,currentTime:d,onSeek:v,height:50}),(0,l.jsx)(a.A,{samples:h.samples,duration:h.duration,currentTime:d,onSeek:v,height:120})]})}}}]);