import{j as o,a$ as D,b1 as F,a_ as M}from"./27cbb885-9bc5-418d-9ec6-2b35bff547d0.BEgz5TI0.js";import{a as S}from"./ba0f904d-b7bd-4a7d-8bd1-47e39e655dbc.DiKAzxfG.js";import{u as W}from"./index.BTAcaJE0.js";import{p as G}from"../../index.js";import"./b813fac5-cbf4-4bdd-aa14-89e1842aae3c.C5hV1yqq.js";import"./1553a3d2-88ea-454c-b1d6-ad16e655d307.BU4QC3MU.js";import"./43178910-39de-4a44-8ec5-3a1260b397dc.B9ygI19o.js";import"./7dfaa908-1fad-4330-a684-d3c24caf3b25.DBPB70EQ.js";import"./3f5e89eb-0b99-4989-ba42-9f14a1e0c07d.l-wE_TeF.js";import"./04eec2b6-5979-4c64-9e60-6995690ff008.dCeXI94U.js";var O=function(f,v,t,c){function n(r){return r instanceof t?r:new t(function(a){a(r)})}return new(t||(t=Promise))(function(r,a){function l(i){try{e(c.next(i))}catch(m){a(m)}}function s(i){try{e(c.throw(i))}catch(m){a(m)}}function e(i){i.done?r(i.value):n(i.value).then(l,s)}e((c=c.apply(f,v||[])).next())})},P=function(f,v){var t={label:0,sent:function(){if(r[0]&1)throw r[1];return r[1]},trys:[],ops:[]},c,n,r,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(e){return function(i){return s([e,i])}}function s(e){if(c)throw new TypeError("Generator is already executing.");for(;a&&(a=0,e[0]&&(t=0)),t;)try{if(c=1,n&&(r=e[0]&2?n.return:e[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,e[1])).done)return r;switch(n=0,r&&(e=[e[0]&2,r.value]),e[0]){case 0:case 1:r=e;break;case 4:return t.label++,{value:e[1],done:!1};case 5:t.label++,n=e[1],e=[0];continue;case 7:e=t.ops.pop(),t.trys.pop();continue;default:if(r=t.trys,!(r=r.length>0&&r[r.length-1])&&(e[0]===6||e[0]===2)){t=0;continue}if(e[0]===3&&(!r||e[1]>r[0]&&e[1]<r[3])){t.label=e[1];break}if(e[0]===6&&t.label<r[1]){t.label=r[1],r=e;break}if(r&&t.label<r[2]){t.label=r[2],t.ops.push(e);break}r[2]&&t.ops.pop(),t.trys.pop();continue}e=v.call(f,t)}catch(i){e=[6,i],n=0}finally{c=r=0}if(e[0]&5)throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}};function Z(f){var v=this,t=f.id,c=W().getContainer,n=c(t)(),r=n.stopRecording,a=n.resumeRecording,l=n.pauseRecording,s=n.recordingStatus,e=n.stream,i=n.timer,m=n.finalizarRecording,C=S.useRef(null);S.useEffect(function(){if(e){var h=new AudioContext,d=h.createAnalyser();d.fftSize=512;var y=d.frequencyBinCount,R=new Uint8Array(y),z=h.createMediaStreamSource(e);z.connect(d);var b=C.current,u=b.getContext("2d");if(u){var w=b.width,g=b.height,T=12,N=getComputedStyle(document.documentElement),E=N.getPropertyValue("--audio-control-incoming").trim(),I=function(){return O(v,void 0,void 0,function(){var _,x,p,k,j;return P(this,function(q){for(d.getByteTimeDomainData(R),u.clearRect(0,0,w,g),u.lineWidth=2,u.strokeStyle=E,u.beginPath(),_=w*1/y,x=0,p=0;p<y;p++)k=(R[p]-128)/128,j=k*g/2*T+g/2,p===0?u.moveTo(x,j):u.lineTo(x,j),x+=_;return u.lineTo(w,g/2),u.stroke(),[2]})})},B=setInterval(function(){s!=="paused"&&I()},1e3);return function(){clearInterval(B),h.close()}}}},[e,s]);function A(){var h=Math.floor(i/60),d=i%60;return"".concat(h,":").concat(d<10?"0":"").concat(d)}return o.jsxs("div",{className:"flex gap-2 items-center w-fit p-2 border border-solid border-[var(--conversation-header-border)] m-auto mb-2 rounded-lg bg-[var(--background-default)]",children:[o.jsx("div",{className:"cursor-pointer pulse",onClick:r,children:o.jsx(D,{size:16})}),o.jsx("div",{className:"flex text-[var(--audio-progress-metadata)]",children:o.jsx("span",{children:A()})}),o.jsx("div",{children:o.jsx("canvas",{ref:C,width:112,height:"25"})}),s==="recording"&&o.jsx("div",{className:"cursor-pointer pulse text-red-500",onClick:l,children:o.jsx(F,{size:18})}),s==="paused"&&o.jsx("div",{className:"cursor-pointer pulse text-red-500",onClick:a,children:o.jsx(M,{size:18})}),s!=="paused"&&o.jsx("div",{className:"cursor-pointer pulse text-green-500",onClick:m,children:o.jsx(G,{size:18})})]})}export{Z as default};
