75 lines
84 KiB
JavaScript
75 lines
84 KiB
JavaScript
import{bJ as zt,c6 as Bt,D as _,b3 as Le,r as T,J as De,aC as N,o as Ae,bv as tt,aU as Ht,l as U,s as Pe,aa as Ut,d as pe,a0 as Se,bc as Ft,aJ as de,a1 as He,aI as Oe,bR as Ee,ag as yt,b2 as Gt,dJ as Vt,cp as it,dK as Xt,aL as Yt,a$ as Zt,cu as Re,b0 as nt,dL as qt,dH as Jt,c1 as Qt,cv as Kt,b7 as ei,cz as ti,aE as wt,c3 as ze,aQ as ii,b5 as ni,df as ri,I as Ct,H as St,e as xt,z as A,A as ee,a2 as si,dM as ai,af as $e,a3 as ie,B as y,G as le,C as ce,a8 as oi,K as re,bT as _t,T as fe,u as li,di as ui,dN as ci,dO as di,E as rt,U as hi,dP as pi}from"./8BTqhy_r.js";import{b as Ie,c as Pt,d as Ue,w as Ve,k as fi,m as kt,t as st,l as vi,s as mi}from"./BSEEMiHQ.js";import{_ as gi}from"./BV50BzEj.js";import{B as ve}from"./DoxGZixE.js";import{U as bi}from"./s2ImsFY5.js";import{B as yi}from"./DoPY-AXa.js";import{u as Mt}from"./CBtNNhyx.js";import{R as wi}from"./CDkr5NrI.js";import{E as Ci}from"./wSBxJKYo.js";import{_ as Si}from"./CZbrfgg8.js";import{_ as Ot}from"./DlAUqK2U.js";import{u as xi}from"./CfQT9Pjy.js";import"./-AolQXzQ.js";import"./C0BHimnr.js";import"./_Az1-nTT.js";import"./tleTI1QP.js";import"./DsmPMUiA.js";import"./DlyEv9Tr.js";import"./DUdyjZO3.js";import"./JAPrvaDs.js";import"./BC2cFiSj.js";import"./CxWRKjoC.js";import"./CJw-6cyn.js";import"./Bkgl3pgJ.js";var _i="[object Number]";function Pi(n){return typeof n=="number"||zt(n)&&Bt(n)==_i}var ki={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M724 218.3V141c0-6.7-7.7-10.4-12.9-6.3L260.3 486.8a31.86 31.86 0 000 50.3l450.8 352.1c5.3 4.1 12.9.4 12.9-6.3v-77.3c0-4.9-2.3-9.6-6.1-12.6l-360-281 360-281.1c3.8-3 6.1-7.7 6.1-12.6z"}}]},name:"left",theme:"outlined"};function at(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?Object(arguments[e]):{},i=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(i=i.concat(Object.getOwnPropertySymbols(t).filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),i.forEach(function(r){Mi(n,r,t[r])})}return n}function Mi(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var Xe=function(e,t){var i=at({},e,t.attrs);return _(Le,at({},i,{icon:ki}),null)};Xe.displayName="LeftOutlined";Xe.inheritAttrs=!1;function Oi(){const n=document.documentElement.clientWidth,e=window.innerHeight||document.documentElement.clientHeight;return{width:n,height:e}}function Et(n){const e=n.getBoundingClientRect(),t=document.documentElement;return{left:e.left+(window.pageXOffset||t.scrollLeft)-(t.clientLeft||document.body.clientLeft||0),top:e.top+(window.pageYOffset||t.scrollTop)-(t.clientTop||document.body.clientTop||0)}}function Ei(n){const e=T(null),t=De(N({},n)),i=T([]),r=s=>{e.value===null&&(i.value=[],e.value=tt(()=>{let o;i.value.forEach(a=>{o=N(N({},o),a)}),N(t,o),e.value=null})),i.value.push(s)};return Ae(()=>{e.value&&tt.cancel(e.value)}),[t,r]}function ot(n,e,t,i){const r=e+t,s=(t-i)/2;if(t>i){if(e>0)return{[n]:s};if(e<0&&r<i)return{[n]:-s}}else if(e<0||r>i)return{[n]:e<0?s:-s};return{}}function Ri(n,e,t,i){const{width:r,height:s}=Oi();let o=null;return n<=r&&e<=s?o={x:0,y:0}:(n>r||e>s)&&(o=N(N({},ot("x",t,n,r)),ot("y",i,e,s))),o}var Ti=function(n,e){var t={};for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(n);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(n,i[r])&&(t[i[r]]=n[i[r]]);return t};const lt=Symbol("previewGroupContext"),Ye={provide:n=>{Ut(lt,n)},inject:()=>Ht(lt,{isPreviewGroup:Pe(!1),previewUrls:U(()=>new Map),setPreviewUrls:()=>{},current:T(null),setCurrent:()=>{},setShowPreview:()=>{},setMousePosition:()=>{},registerImage:null,rootClassName:""})},Li=()=>({previewPrefixCls:String,preview:{type:[Boolean,Object],default:!0},icons:{type:Object,default:()=>({})}}),Rt=pe({compatConfig:{MODE:3},name:"PreviewGroup",inheritAttrs:!1,props:Li(),setup(n,e){let{slots:t}=e;const i=U(()=>{const g={visible:void 0,onVisibleChange:()=>{},getContainer:void 0,current:0};return typeof n.preview=="object"?Dt(n.preview,g):g}),r=De(new Map),s=T(),o=U(()=>i.value.visible),a=U(()=>i.value.getContainer),u=(g,k)=>{var M,B;(B=(M=i.value).onVisibleChange)===null||B===void 0||B.call(M,g,k)},[l,d]=Mt(!!o.value,{value:o,onChange:u}),p=T(null),f=U(()=>o.value!==void 0),v=U(()=>Array.from(r.keys())),h=U(()=>v.value[i.value.current]),w=U(()=>new Map(Array.from(r).filter(g=>{let[,{canPreview:k}]=g;return!!k}).map(g=>{let[k,{url:M}]=g;return[k,M]}))),x=function(g,k){let M=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;r.set(g,{url:k,canPreview:M})},E=g=>{s.value=g},L=g=>{p.value=g},j=function(g,k){let M=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;const B=()=>{r.delete(g)};return r.set(g,{url:k,canPreview:M}),B},P=g=>{g?.stopPropagation(),d(!1),L(null)};return Se(h,g=>{E(g)},{immediate:!0,flush:"post"}),Ft(()=>{l.value&&f.value&&E(h.value)},{flush:"post"}),Ye.provide({isPreviewGroup:Pe(!0),previewUrls:w,setPreviewUrls:x,current:s,setCurrent:E,setShowPreview:d,setMousePosition:L,registerImage:j}),()=>{const g=Ti(i.value,[]);return _(He,null,[t.default&&t.default(),_(Tt,de(de({},g),{},{"ria-hidden":!l.value,visible:l.value,prefixCls:n.previewPrefixCls,onClose:P,mousePosition:p.value,src:w.value.get(s.value),icons:n.icons,getContainer:a.value}),null)])}}}),_e={x:0,y:0},Di=N(N({},Xt()),{src:String,alt:String,rootClassName:String,icons:{type:Object,default:()=>({})}}),Tt=pe({compatConfig:{MODE:3},name:"Preview",inheritAttrs:!1,props:Di,emits:["close","afterClose"],setup(n,e){let{emit:t,attrs:i}=e;const{rotateLeft:r,rotateRight:s,zoomIn:o,zoomOut:a,close:u,left:l,right:d,flipX:p,flipY:f}=De(n.icons),v=Pe(1),h=Pe(0),w=De({x:1,y:1}),[x,E]=Ei(_e),L=()=>t("close"),j=Pe(),P=De({originX:0,originY:0,deltaX:0,deltaY:0}),g=Pe(!1),k=Ye.inject(),{previewUrls:M,current:B,isPreviewGroup:D,setCurrent:W}=k,G=U(()=>M.value.size),V=U(()=>Array.from(M.value.keys())),F=U(()=>V.value.indexOf(B.value)),$=U(()=>D.value?M.value.get(B.value):n.src),Y=U(()=>D.value&&G.value>1),se=Pe({wheelDirection:0}),ne=()=>{v.value=1,h.value=0,w.x=1,w.y=1,E(_e),t("afterClose")},I=R=>{R?v.value+=.5:v.value++,E(_e)},te=R=>{v.value>1&&(R?v.value-=.5:v.value--),E(_e)},K=()=>{h.value+=90},ae=()=>{h.value-=90},ge=()=>{w.x=-w.x},C=()=>{w.y=-w.y},O=R=>{R.preventDefault(),R.stopPropagation(),F.value>0&&W(V.value[F.value-1])},S=R=>{R.preventDefault(),R.stopPropagation(),F.value<G.value-1&&W(V.value[F.value+1])},H=Oe({[`${n.prefixCls}-moving`]:g.value}),Q=`${n.prefixCls}-operations-operation`,oe=`${n.prefixCls}-operations-icon`,c=[{icon:u,onClick:L,type:"close"},{icon:o,onClick:()=>I(),type:"zoomIn"},{icon:a,onClick:()=>te(),type:"zoomOut",disabled:U(()=>v.value===1)},{icon:s,onClick:K,type:"rotateRight"},{icon:r,onClick:ae,type:"rotateLeft"},{icon:p,onClick:ge,type:"flipX"},{icon:f,onClick:C,type:"flipY"}],b=()=>{if(n.visible&&g.value){const R=j.value.offsetWidth*v.value,q=j.value.offsetHeight*v.value,{left:he,top:xe}=Et(j.value),ye=h.value%180!==0;g.value=!1;const we=Ri(ye?q:R,ye?R:q,he,xe);we&&E(N({},we))}},z=R=>{R.button===0&&(R.preventDefault(),R.stopPropagation(),P.deltaX=R.pageX-x.x,P.deltaY=R.pageY-x.y,P.originX=x.x,P.originY=x.y,g.value=!0)},Z=R=>{n.visible&&g.value&&E({x:R.pageX-P.deltaX,y:R.pageY-P.deltaY})},m=R=>{if(!n.visible)return;R.preventDefault();const q=R.deltaY;se.value={wheelDirection:q}},X=R=>{!n.visible||!Y.value||(R.preventDefault(),R.keyCode===it.LEFT?F.value>0&&W(V.value[F.value-1]):R.keyCode===it.RIGHT&&F.value<G.value-1&&W(V.value[F.value+1]))},me=()=>{n.visible&&(v.value!==1&&(v.value=1),(x.x!==_e.x||x.y!==_e.y)&&E(_e))};let be=()=>{};return Ae(()=>{Se([()=>n.visible,g],()=>{be();let R,q;const he=Ee(window,"mouseup",b,!1),xe=Ee(window,"mousemove",Z,!1),ye=Ee(window,"wheel",m,{passive:!1}),we=Ee(window,"keydown",X,!1);try{window.top!==window.self&&(R=Ee(window.top,"mouseup",b,!1),q=Ee(window.top,"mousemove",Z,!1))}catch{}be=()=>{he.remove(),xe.remove(),ye.remove(),we.remove(),R&&R.remove(),q&&q.remove()}},{flush:"post",immediate:!0}),Se([se],()=>{const{wheelDirection:R}=se.value;R>0?te(!0):R<0&&I(!0)})}),yt(()=>{be()}),()=>{const{visible:R,prefixCls:q,rootClassName:he}=n;return _(Vt,de(de({},i),{},{transitionName:n.transitionName,maskTransitionName:n.maskTransitionName,closable:!1,keyboard:!0,prefixCls:q,onClose:L,afterClose:ne,visible:R,wrapClassName:H,rootClassName:he,getContainer:n.getContainer}),{default:()=>[_("div",{class:[`${n.prefixCls}-operations-wrapper`,he]},[_("ul",{class:`${n.prefixCls}-operations`},[c.map(xe=>{let{icon:ye,onClick:we,type:et,disabled:We}=xe;return _("li",{class:Oe(Q,{[`${n.prefixCls}-operations-operation-disabled`]:We&&We?.value}),onClick:we,key:et},[Gt(ye,{class:oe})])})])]),_("div",{class:`${n.prefixCls}-img-wrapper`,style:{transform:`translate3d(${x.x}px, ${x.y}px, 0)`}},[_("img",{onMousedown:z,onDblclick:me,ref:j,class:`${n.prefixCls}-img`,src:$.value,alt:n.alt,style:{transform:`scale3d(${w.x*v.value}, ${w.y*v.value}, 1) rotate(${h.value}deg)`}},null)]),Y.value&&_("div",{class:Oe(`${n.prefixCls}-switch-left`,{[`${n.prefixCls}-switch-left-disabled`]:F.value<=0}),onClick:O},[l]),Y.value&&_("div",{class:Oe(`${n.prefixCls}-switch-right`,{[`${n.prefixCls}-switch-right-disabled`]:F.value>=G.value-1}),onClick:S},[d])]})}}});var $i=function(n,e){var t={};for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&e.indexOf(i)<0&&(t[i]=n[i]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,i=Object.getOwnPropertySymbols(n);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(n,i[r])&&(t[i[r]]=n[i[r]]);return t};const Lt=()=>({src:String,wrapperClassName:String,wrapperStyle:{type:Object,default:void 0},rootClassName:String,prefixCls:String,previewPrefixCls:String,previewMask:{type:[Boolean,Function],default:void 0},placeholder:Yt.any,fallback:String,preview:{type:[Boolean,Object],default:!0},onClick:{type:Function},onError:{type:Function}}),Dt=(n,e)=>{const t=N({},n);return Object.keys(e).forEach(i=>{n[i]===void 0&&(t[i]=e[i])}),t};let Ii=0;const $t=pe({compatConfig:{MODE:3},name:"VcImage",inheritAttrs:!1,props:Lt(),emits:["click","error"],setup(n,e){let{attrs:t,slots:i,emit:r}=e;const s=U(()=>n.prefixCls),o=U(()=>`${s.value}-preview`),a=U(()=>{const I={visible:void 0,onVisibleChange:()=>{},getContainer:void 0};return typeof n.preview=="object"?Dt(n.preview,I):I}),u=U(()=>{var I;return(I=a.value.src)!==null&&I!==void 0?I:n.src}),l=U(()=>n.placeholder&&n.placeholder!==!0||i.placeholder),d=U(()=>a.value.visible),p=U(()=>a.value.getContainer),f=U(()=>d.value!==void 0),v=(I,te)=>{var K,ae;(ae=(K=a.value).onVisibleChange)===null||ae===void 0||ae.call(K,I,te)},[h,w]=Mt(!!d.value,{value:d,onChange:v}),x=T(l.value?"loading":"normal");Se(()=>n.src,()=>{x.value=l.value?"loading":"normal"});const E=T(null),L=U(()=>x.value==="error"),j=Ye.inject(),{isPreviewGroup:P,setCurrent:g,setShowPreview:k,setMousePosition:M,registerImage:B}=j,D=T(Ii++),W=U(()=>n.preview&&!L.value),G=()=>{x.value="normal"},V=I=>{x.value="error",r("error",I)},F=I=>{if(!f.value){const{left:te,top:K}=Et(I.target);P.value?(g(D.value),M({x:te,y:K})):E.value={x:te,y:K}}P.value?k(!0):w(!0),r("click",I)},$=()=>{w(!1),f.value||(E.value=null)},Y=T(null);Se(()=>Y,()=>{x.value==="loading"&&Y.value.complete&&(Y.value.naturalWidth||Y.value.naturalHeight)&&G()});let se=()=>{};Ae(()=>{Se([u,W],()=>{if(se(),!P.value)return()=>{};se=B(D.value,u.value,W.value),W.value||se()},{flush:"post",immediate:!0})}),yt(()=>{se()});const ne=I=>Pi(I)?I+"px":I;return()=>{const{prefixCls:I,wrapperClassName:te,fallback:K,src:ae,placeholder:ge,wrapperStyle:C,rootClassName:O}=n,{width:S,height:H,crossorigin:Q,decoding:oe,alt:c,sizes:b,srcset:z,usemap:Z,class:m,style:X}=t,me=a.value,{icons:be,maskClassName:R}=me,q=$i(me,["icons","maskClassName"]),he=Oe(I,te,O,{[`${I}-error`]:L.value}),xe=L.value&&K?K:u.value,ye={crossorigin:Q,decoding:oe,alt:c,sizes:b,srcset:z,usemap:Z,width:S,height:H,class:Oe(`${I}-img`,{[`${I}-img-placeholder`]:ge===!0},m),style:N({height:ne(H)},X)};return _(He,null,[_("div",{class:he,onClick:W.value?F:we=>{r("click",we)},style:N({width:ne(S),height:ne(H)},C)},[_("img",de(de(de({},ye),L.value&&K?{src:K}:{onLoad:G,onError:V,src:ae}),{},{ref:Y}),null),x.value==="loading"&&_("div",{"aria-hidden":"true",class:`${I}-placeholder`},[ge||i.placeholder&&i.placeholder()]),i.previewMask&&W.value&&_("div",{class:[`${I}-mask`,R]},[i.previewMask()])]),!P.value&&W.value&&_(Tt,de(de({},q),{},{"aria-hidden":!h.value,visible:h.value,prefixCls:o.value,onClose:$,mousePosition:E.value,src:xe,alt:c,getContainer:p.value,icons:be,rootClassName:O}),null)])}}});$t.PreviewGroup=Rt;var Ai={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"defs",attrs:{},children:[{tag:"style",attrs:{}}]},{tag:"path",attrs:{d:"M672 418H144c-17.7 0-32 14.3-32 32v414c0 17.7 14.3 32 32 32h528c17.7 0 32-14.3 32-32V450c0-17.7-14.3-32-32-32zm-44 402H188V494h440v326z"}},{tag:"path",attrs:{d:"M819.3 328.5c-78.8-100.7-196-153.6-314.6-154.2l-.2-64c0-6.5-7.6-10.1-12.6-6.1l-128 101c-4 3.1-3.9 9.1 0 12.3L492 318.6c5.1 4 12.7.4 12.6-6.1v-63.9c12.9.1 25.9.9 38.8 2.5 42.1 5.2 82.1 18.2 119 38.7 38.1 21.2 71.2 49.7 98.4 84.3 27.1 34.7 46.7 73.7 58.1 115.8a325.95 325.95 0 016.5 140.9h74.9c14.8-103.6-11.3-213-81-302.3z"}}]},name:"rotate-left",theme:"outlined"};function ut(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?Object(arguments[e]):{},i=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(i=i.concat(Object.getOwnPropertySymbols(t).filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),i.forEach(function(r){Ni(n,r,t[r])})}return n}function Ni(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var Ze=function(e,t){var i=ut({},e,t.attrs);return _(Le,ut({},i,{icon:Ai}),null)};Ze.displayName="RotateLeftOutlined";Ze.inheritAttrs=!1;var Wi={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"defs",attrs:{},children:[{tag:"style",attrs:{}}]},{tag:"path",attrs:{d:"M480.5 251.2c13-1.6 25.9-2.4 38.8-2.5v63.9c0 6.5 7.5 10.1 12.6 6.1L660 217.6c4-3.2 4-9.2 0-12.3l-128-101c-5.1-4-12.6-.4-12.6 6.1l-.2 64c-118.6.5-235.8 53.4-314.6 154.2A399.75 399.75 0 00123.5 631h74.9c-.9-5.3-1.7-10.7-2.4-16.1-5.1-42.1-2.1-84.1 8.9-124.8 11.4-42.2 31-81.1 58.1-115.8 27.2-34.7 60.3-63.2 98.4-84.3 37-20.6 76.9-33.6 119.1-38.8z"}},{tag:"path",attrs:{d:"M880 418H352c-17.7 0-32 14.3-32 32v414c0 17.7 14.3 32 32 32h528c17.7 0 32-14.3 32-32V450c0-17.7-14.3-32-32-32zm-44 402H396V494h440v326z"}}]},name:"rotate-right",theme:"outlined"};function ct(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?Object(arguments[e]):{},i=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(i=i.concat(Object.getOwnPropertySymbols(t).filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),i.forEach(function(r){ji(n,r,t[r])})}return n}function ji(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var qe=function(e,t){var i=ct({},e,t.attrs);return _(Le,ct({},i,{icon:Wi}),null)};qe.displayName="RotateRightOutlined";qe.inheritAttrs=!1;var zi={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M637 443H519V309c0-4.4-3.6-8-8-8h-60c-4.4 0-8 3.6-8 8v134H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h118v134c0 4.4 3.6 8 8 8h60c4.4 0 8-3.6 8-8V519h118c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"}}]},name:"zoom-in",theme:"outlined"};function dt(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?Object(arguments[e]):{},i=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(i=i.concat(Object.getOwnPropertySymbols(t).filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),i.forEach(function(r){Bi(n,r,t[r])})}return n}function Bi(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var Je=function(e,t){var i=dt({},e,t.attrs);return _(Le,dt({},i,{icon:zi}),null)};Je.displayName="ZoomInOutlined";Je.inheritAttrs=!1;var Hi={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M637 443H325c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h312c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8zm284 424L775 721c122.1-148.9 113.6-369.5-26-509-148-148.1-388.4-148.1-537 0-148.1 148.6-148.1 389 0 537 139.5 139.6 360.1 148.1 509 26l146 146c3.2 2.8 8.3 2.8 11 0l43-43c2.8-2.7 2.8-7.8 0-11zM696 696c-118.8 118.7-311.2 118.7-430 0-118.7-118.8-118.7-311.2 0-430 118.8-118.7 311.2-118.7 430 0 118.7 118.8 118.7 311.2 0 430z"}}]},name:"zoom-out",theme:"outlined"};function ht(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?Object(arguments[e]):{},i=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(i=i.concat(Object.getOwnPropertySymbols(t).filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),i.forEach(function(r){Ui(n,r,t[r])})}return n}function Ui(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var Qe=function(e,t){var i=ht({},e,t.attrs);return _(Le,ht({},i,{icon:Hi}),null)};Qe.displayName="ZoomOutOutlined";Qe.inheritAttrs=!1;var Fi={icon:{tag:"svg",attrs:{viewBox:"64 64 896 896",focusable:"false"},children:[{tag:"path",attrs:{d:"M847.9 592H152c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h605.2L612.9 851c-4.1 5.2-.4 13 6.3 13h72.5c4.9 0 9.5-2.2 12.6-6.1l168.8-214.1c16.5-21 1.6-51.8-25.2-51.8zM872 356H266.8l144.3-183c4.1-5.2.4-13-6.3-13h-72.5c-4.9 0-9.5 2.2-12.6 6.1L150.9 380.2c-16.5 21-1.6 51.8 25.1 51.8h696c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8z"}}]},name:"swap",theme:"outlined"};function pt(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?Object(arguments[e]):{},i=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(i=i.concat(Object.getOwnPropertySymbols(t).filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),i.forEach(function(r){Gi(n,r,t[r])})}return n}function Gi(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}var Be=function(e,t){var i=pt({},e,t.attrs);return _(Le,pt({},i,{icon:Fi}),null)};Be.displayName="SwapOutlined";Be.inheritAttrs=!1;const Ge=n=>({position:n||"absolute",inset:0}),Vi=n=>{const{iconCls:e,motionDurationSlow:t,paddingXXS:i,marginXXS:r,prefixCls:s}=n;return{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff",background:new Re("#000").setAlpha(.5).toRgbString(),cursor:"pointer",opacity:0,transition:`opacity ${t}`,[`.${s}-mask-info`]:N(N({},Kt),{padding:`0 ${i}px`,[e]:{marginInlineEnd:r,svg:{verticalAlign:"baseline"}}})}},Xi=n=>{const{previewCls:e,modalMaskBg:t,paddingSM:i,previewOperationColorDisabled:r,motionDurationSlow:s}=n,o=new Re(t).setAlpha(.1),a=o.clone().setAlpha(.2);return{[`${e}-operations`]:N(N({},ei(n)),{display:"flex",flexDirection:"row-reverse",alignItems:"center",color:n.previewOperationColor,listStyle:"none",background:o.toRgbString(),pointerEvents:"auto","&-operation":{marginInlineStart:i,padding:i,cursor:"pointer",transition:`all ${s}`,userSelect:"none","&:hover":{background:a.toRgbString()},"&-disabled":{color:r,pointerEvents:"none"},"&:last-of-type":{marginInlineStart:0}},"&-progress":{position:"absolute",left:{_skip_check_:!0,value:"50%"},transform:"translateX(-50%)"},"&-icon":{fontSize:n.previewOperationSize}})}},Yi=n=>{const{modalMaskBg:e,iconCls:t,previewOperationColorDisabled:i,previewCls:r,zIndexPopup:s,motionDurationSlow:o}=n,a=new Re(e).setAlpha(.1),u=a.clone().setAlpha(.2);return{[`${r}-switch-left, ${r}-switch-right`]:{position:"fixed",insetBlockStart:"50%",zIndex:s+1,display:"flex",alignItems:"center",justifyContent:"center",width:n.imagePreviewSwitchSize,height:n.imagePreviewSwitchSize,marginTop:-n.imagePreviewSwitchSize/2,color:n.previewOperationColor,background:a.toRgbString(),borderRadius:"50%",transform:"translateY(-50%)",cursor:"pointer",transition:`all ${o}`,pointerEvents:"auto",userSelect:"none","&:hover":{background:u.toRgbString()},"&-disabled":{"&, &:hover":{color:i,background:"transparent",cursor:"not-allowed",[`> ${t}`]:{cursor:"not-allowed"}}},[`> ${t}`]:{fontSize:n.previewOperationSize}},[`${r}-switch-left`]:{insetInlineStart:n.marginSM},[`${r}-switch-right`]:{insetInlineEnd:n.marginSM}}},Zi=n=>{const{motionEaseOut:e,previewCls:t,motionDurationSlow:i,componentCls:r}=n;return[{[`${r}-preview-root`]:{[t]:{height:"100%",textAlign:"center",pointerEvents:"none"},[`${t}-body`]:N(N({},Ge()),{overflow:"hidden"}),[`${t}-img`]:{maxWidth:"100%",maxHeight:"100%",verticalAlign:"middle",transform:"scale3d(1, 1, 1)",cursor:"grab",transition:`transform ${i} ${e} 0s`,userSelect:"none",pointerEvents:"auto","&-wrapper":N(N({},Ge()),{transition:`transform ${i} ${e} 0s`,display:"flex",justifyContent:"center",alignItems:"center","&::before":{display:"inline-block",width:1,height:"50%",marginInlineEnd:-1,content:'""'}})},[`${t}-moving`]:{[`${t}-preview-img`]:{cursor:"grabbing","&-wrapper":{transitionDuration:"0s"}}}}},{[`${r}-preview-root`]:{[`${t}-wrap`]:{zIndex:n.zIndexPopup}}},{[`${r}-preview-operations-wrapper`]:{position:"fixed",insetBlockStart:0,insetInlineEnd:0,zIndex:n.zIndexPopup+1,width:"100%"},"&":[Xi(n),Yi(n)]}]},qi=n=>{const{componentCls:e}=n;return{[e]:{position:"relative",display:"inline-block",[`${e}-img`]:{width:"100%",height:"auto",verticalAlign:"middle"},[`${e}-img-placeholder`]:{backgroundColor:n.colorBgContainerDisabled,backgroundImage:"url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMTQuNSAyLjVoLTEzQS41LjUgMCAwIDAgMSAzdjEwYS41LjUgMCAwIDAgLjUuNWgxM2EuNS41IDAgMCAwIC41LS41VjNhLjUuNSAwIDAgMC0uNS0uNXpNNS4yODEgNC43NWExIDEgMCAwIDEgMCAyIDEgMSAwIDAgMSAwLTJ6bTguMDMgNi44M2EuMTI3LjEyNyAwIDAgMS0uMDgxLjAzSDIuNzY5YS4xMjUuMTI1IDAgMCAxLS4wOTYtLjIwN2wyLjY2MS0zLjE1NmEuMTI2LjEyNiAwIDAgMSAuMTc3LS4wMTZsLjAxNi4wMTZMNy4wOCAxMC4wOWwyLjQ3LTIuOTNhLjEyNi4xMjYgMCAwIDEgLjE3Ny0uMDE2bC4wMTUuMDE2IDMuNTg4IDQuMjQ0YS4xMjcuMTI3IDAgMCAxLS4wMi4xNzV6IiBmaWxsPSIjOEM4QzhDIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz48L3N2Zz4=')",backgroundRepeat:"no-repeat",backgroundPosition:"center center",backgroundSize:"30%"},[`${e}-mask`]:N({},Vi(n)),[`${e}-mask:hover`]:{opacity:1},[`${e}-placeholder`]:N({},Ge())}}},Ji=n=>{const{previewCls:e}=n;return{[`${e}-root`]:Qt(n,"zoom"),"&":Jt(n,!0)}},It=Zt("Image",n=>{const e=`${n.componentCls}-preview`,t=nt(n,{previewCls:e,modalMaskBg:new Re("#000").setAlpha(.45).toRgbString(),imagePreviewSwitchSize:n.controlHeightLG});return[qi(t),Zi(t),qt(nt(t,{componentCls:e})),Ji(t)]},n=>({zIndexPopup:n.zIndexPopupBase+80,previewOperationColor:new Re(n.colorTextLightSolid).toRgbString(),previewOperationColorDisabled:new Re(n.colorTextLightSolid).setAlpha(.25).toRgbString(),previewOperationSize:n.fontSizeIcon*1.5})),At={rotateLeft:_(Ze,null,null),rotateRight:_(qe,null,null),zoomIn:_(Je,null,null),zoomOut:_(Qe,null,null),close:_(ti,null,null),left:_(Xe,null,null),right:_(wi,null,null),flipX:_(Be,null,null),flipY:_(Be,{rotate:90},null)},Qi=()=>({previewPrefixCls:String,preview:ii()}),Ki=pe({compatConfig:{MODE:3},name:"AImagePreviewGroup",inheritAttrs:!1,props:Qi(),setup(n,e){let{attrs:t,slots:i}=e;const{prefixCls:r,rootPrefixCls:s}=wt("image",n),o=U(()=>`${r.value}-preview`),[a,u]=It(r),l=U(()=>{const{preview:d}=n;if(d===!1)return d;const p=typeof d=="object"?d:{};return N(N({},p),{rootClassName:u.value,transitionName:ze(s.value,"zoom",p.transitionName),maskTransitionName:ze(s.value,"fade",p.maskTransitionName)})});return()=>a(_(Rt,de(de({},N(N({},t),n)),{},{preview:l.value,icons:At,previewPrefixCls:o.value}),i))}}),ke=pe({name:"AImage",inheritAttrs:!1,props:Lt(),setup(n,e){let{slots:t,attrs:i}=e;const{prefixCls:r,rootPrefixCls:s,configProvider:o}=wt("image",n),[a,u]=It(r),l=U(()=>{const{preview:d}=n;if(d===!1)return d;const p=typeof d=="object"?d:{};return N(N({icons:At},p),{transitionName:ze(s.value,"zoom",p.transitionName),maskTransitionName:ze(s.value,"fade",p.maskTransitionName)})});return()=>{var d,p;const f=((p=(d=o.locale)===null||d===void 0?void 0:d.value)===null||p===void 0?void 0:p.Image)||ni.Image,v=()=>_("div",{class:`${r.value}-mask-info`},[_(Ci,null,null),f?.preview]),{previewMask:h=t.previewMask||v}=n;return a(_($t,de(de({},N(N(N({},i),n),{prefixCls:r.value})),{},{preview:l.value,rootClassName:Oe(n.rootClassName,u.value)}),N(N({},t),{previewMask:typeof h=="function"?h:null})))}}});ke.PreviewGroup=Ki;ke.install=function(n){return n.component(ke.name,ke),n.component(ke.PreviewGroup.name,ke.PreviewGroup),n};const[en,tn]=Ue("skeleton-title"),nn={round:Boolean,titleWidth:Ie};var rn=pe({name:en,props:nn,setup(n){return()=>_("h3",{class:tn([{round:n.round}]),style:{width:Pt(n.titleWidth)}},null)}});const sn=Ve(rn);var an=sn;const[on,ln]=Ue("skeleton-avatar"),un={avatarSize:Ie,avatarShape:kt("round")};var cn=pe({name:on,props:un,setup(n){return()=>_("div",{class:ln([n.avatarShape]),style:fi(n.avatarSize)},null)}});const dn=Ve(cn);var hn=dn;const Ke="100%",pn={round:Boolean,rowWidth:{type:Ie,default:Ke}},[fn,vn]=Ue("skeleton-paragraph");var mn=pe({name:fn,props:pn,setup(n){return()=>_("div",{class:vn([{round:n.round}]),style:{width:n.rowWidth}},null)}});const gn=Ve(mn);var bn=gn;const[yn,ft]=Ue("skeleton"),wn="60%",Cn={row:vi(0),round:Boolean,title:Boolean,titleWidth:Ie,avatar:Boolean,avatarSize:Ie,avatarShape:kt("round"),loading:st,animate:st,rowWidth:{type:[Number,String,Array],default:Ke}};var Sn=pe({name:yn,inheritAttrs:!1,props:Cn,setup(n,{slots:e,attrs:t}){const i=()=>{if(n.avatar)return _(hn,{avatarShape:n.avatarShape,avatarSize:n.avatarSize},null)},r=()=>{if(n.title)return _(an,{round:n.round,titleWidth:n.titleWidth},null)},s=u=>{const{rowWidth:l}=n;return l===Ke&&u===+n.row-1?wn:Array.isArray(l)?l[u]:l},o=()=>Array(+n.row).fill("").map((u,l)=>_(bn,{key:l,round:n.round,rowWidth:Pt(s(l))},null)),a=()=>e.template?e.template():_(He,null,[i(),_("div",{class:ft("content")},[r(),o()])]);return()=>{var u;return n.loading?_("div",ri({class:ft({animate:n.animate,round:n.round})},t),[a()]):(u=e.default)==null?void 0:u.call(e)}}});const xn="data:image/svg+xml,%3csvg%20width='22'%20height='20'%20viewBox='0%200%2022%2020'%20fill='white'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M21.0031%201H1.00311L8.50311%208.5M21.0031%201L10.5031%2018.5L8.50311%208.5M21.0031%201L8.50311%208.5'%20stroke='%23733af9'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e";function ue(n,e,t,i){return new(t||(t=Promise))((function(r,s){function o(l){try{u(i.next(l))}catch(d){s(d)}}function a(l){try{u(i.throw(l))}catch(d){s(d)}}function u(l){var d;l.done?r(l.value):(d=l.value,d instanceof t?d:new t((function(p){p(d)}))).then(o,a)}u((i=i.apply(n,e||[])).next())}))}class Ne{constructor(){this.listeners={}}on(e,t,i){if(this.listeners[e]||(this.listeners[e]=new Set),i?.once){const r=(...s)=>{this.un(e,r),t(...s)};return this.listeners[e].add(r),()=>this.un(e,r)}return this.listeners[e].add(t),()=>this.un(e,t)}un(e,t){var i;(i=this.listeners[e])===null||i===void 0||i.delete(t)}once(e,t){return this.on(e,t,{once:!0})}unAll(){this.listeners={}}emit(e,...t){this.listeners[e]&&this.listeners[e].forEach((i=>i(...t)))}}const je={decode:function(n,e){return ue(this,void 0,void 0,(function*(){const t=new AudioContext({sampleRate:e});try{return yield t.decodeAudioData(n)}finally{t.close()}}))},createBuffer:function(n,e){if(!n||n.length===0)throw new Error("channelData must be a non-empty array");if(e<=0)throw new Error("duration must be greater than 0");if(typeof n[0]=="number"&&(n=[n]),!n[0]||n[0].length===0)throw new Error("channelData must contain non-empty channel arrays");(function(i){const r=i[0];if(r.some((s=>s>1||s<-1))){const s=r.length;let o=0;for(let a=0;a<s;a++){const u=Math.abs(r[a]);u>o&&(o=u)}for(const a of i)for(let u=0;u<s;u++)a[u]/=o}})(n);const t=n.map((i=>i instanceof Float32Array?i:Float32Array.from(i)));return{duration:e,length:t[0].length,sampleRate:t[0].length/e,numberOfChannels:t.length,getChannelData:i=>{const r=t[i];if(!r)throw new Error(`Channel ${i} not found`);return r},copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function Nt(n,e){const t=e.xmlns?document.createElementNS(e.xmlns,n):document.createElement(n);for(const[i,r]of Object.entries(e))if(i==="children"&&r)for(const[s,o]of Object.entries(r))o instanceof Node?t.appendChild(o):typeof o=="string"?t.appendChild(document.createTextNode(o)):t.appendChild(Nt(s,o));else i==="style"?Object.assign(t.style,r):i==="textContent"?t.textContent=r:t.setAttribute(i,r.toString());return t}function vt(n,e,t){const i=Nt(n,e||{});return t?.appendChild(i),i}var _n=Object.freeze({__proto__:null,createElement:vt,default:vt});const Pn={fetchBlob:function(n,e,t){return ue(this,void 0,void 0,(function*(){const i=yield fetch(n,t);if(i.status>=400)throw new Error(`Failed to fetch ${n}: ${i.status} (${i.statusText})`);return(function(r,s){ue(this,void 0,void 0,(function*(){if(!r.body||!r.headers)return;const o=r.body.getReader(),a=Number(r.headers.get("Content-Length"))||0;let u=0;const l=d=>{u+=d?.length||0;const p=Math.round(u/a*100);s(p)};try{for(;;){const d=yield o.read();if(d.done)break;l(d.value)}}catch(d){console.warn("Progress tracking error:",d)}}))})(i.clone(),e),i.blob()}))}};function J(n){let e=n;const t=new Set;return{get value(){return e},set(i){Object.is(e,i)||(e=i,t.forEach((r=>r(e))))},update(i){this.set(i(e))},subscribe:i=>(t.add(i),()=>t.delete(i))}}function Me(n,e){const t=J(n());return e.forEach((i=>i.subscribe((()=>{const r=n();Object.is(t.value,r)||t.set(r)})))),{get value(){return t.value},subscribe:i=>t.subscribe(i)}}function Ce(n,e){let t;const i=()=>{t&&(t(),t=void 0),t=n()},r=e.map((s=>s.subscribe(i)));return i(),()=>{t&&(t(),t=void 0),r.forEach((s=>s()))}}class kn extends Ne{get isPlayingSignal(){return this._isPlaying}get currentTimeSignal(){return this._currentTime}get durationSignal(){return this._duration}get volumeSignal(){return this._volume}get mutedSignal(){return this._muted}get playbackRateSignal(){return this._playbackRate}get seekingSignal(){return this._seeking}constructor(e){super(),this.isExternalMedia=!1,this.reactiveMediaEventCleanups=[],e.media?(this.media=e.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),this._isPlaying=J(!1),this._currentTime=J(0),this._duration=J(0),this._volume=J(this.media.volume),this._muted=J(this.media.muted),this._playbackRate=J(this.media.playbackRate||1),this._seeking=J(!1),this.setupReactiveMediaEvents(),e.mediaControls&&(this.media.controls=!0),e.autoplay&&(this.media.autoplay=!0),e.playbackRate!=null&&this.onMediaEvent("canplay",(()=>{e.playbackRate!=null&&(this.media.playbackRate=e.playbackRate)}),{once:!0})}setupReactiveMediaEvents(){this.reactiveMediaEventCleanups.push(this.onMediaEvent("play",(()=>{this._isPlaying.set(!0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("pause",(()=>{this._isPlaying.set(!1)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("ended",(()=>{this._isPlaying.set(!1)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("timeupdate",(()=>{this._currentTime.set(this.media.currentTime)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("durationchange",(()=>{this._duration.set(this.media.duration||0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("loadedmetadata",(()=>{this._duration.set(this.media.duration||0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeking",(()=>{this._seeking.set(!0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeked",(()=>{this._seeking.set(!1)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("volumechange",(()=>{this._volume.set(this.media.volume),this._muted.set(this.media.muted)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("ratechange",(()=>{this._playbackRate.set(this.media.playbackRate)})))}onMediaEvent(e,t,i){return this.media.addEventListener(e,t,i),()=>this.media.removeEventListener(e,t,i)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const e=this.getSrc();e.startsWith("blob:")&&URL.revokeObjectURL(e)}canPlayType(e){return this.media.canPlayType(e)!==""}setSrc(e,t){const i=this.getSrc();if(e&&i===e)return;this.revokeSrc();const r=t instanceof Blob&&(this.canPlayType(t.type)||!e)?URL.createObjectURL(t):e;if(i&&this.media.removeAttribute("src"),r||e)try{this.media.src=r}catch{this.media.src=e}}destroy(){this.reactiveMediaEventCleanups.forEach((e=>e())),this.reactiveMediaEventCleanups=[],this.isExternalMedia||(this.media.pause(),this.revokeSrc(),this.media.removeAttribute("src"),this.media.load(),this.media.remove())}setMediaElement(e){this.reactiveMediaEventCleanups.forEach((t=>t())),this.reactiveMediaEventCleanups=[],this.media=e,this.setupReactiveMediaEvents()}play(){return ue(this,void 0,void 0,(function*(){try{return yield this.media.play()}catch(e){if(e instanceof DOMException&&e.name==="AbortError")return;throw e}}))}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(e){this.media.currentTime=Math.max(0,Math.min(e,this.getDuration()))}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(e){this.media.volume=e}getMuted(){return this.media.muted}setMuted(e){this.media.muted=e}getPlaybackRate(){return this.media.playbackRate}isSeeking(){return this.media.seeking}setPlaybackRate(e,t){t!=null&&(this.media.preservesPitch=t),this.media.playbackRate=e}getMediaElement(){return this.media}setSinkId(e){return this.media.setSinkId(e)}}function Mn({maxTop:n,maxBottom:e,halfHeight:t,vScale:i,barMinHeight:r=0,barAlign:s}){let o=Math.round(n*t*i),a=o+Math.round(e*t*i)||1;return a<r&&(a=r,s||(o=a/2)),{topHeight:o,totalHeight:a}}function On({barAlign:n,halfHeight:e,topHeight:t,totalHeight:i,canvasHeight:r}){return n==="top"?0:n==="bottom"?r-i:e-t}function mt(n,e,t){const i=e-n.left,r=t-n.top;return[i/n.width,r/n.height]}function Wt(n){return!!(n.barWidth||n.barGap||n.barAlign)}function gt(n,e){if(!Wt(e))return n;const t=e.barWidth||.5,i=t+(e.barGap||t/2);return i===0?n:Math.floor(n/i)*i}function bt({scrollLeft:n,totalWidth:e,numCanvases:t}){if(e===0)return[0];const i=n/e,r=Math.floor(i*t);return[r-1,r,r+1]}function jt(n){const e=n._cleanup;typeof e=="function"&&e()}function En(n){const e=J({scrollLeft:n.scrollLeft,scrollWidth:n.scrollWidth,clientWidth:n.clientWidth}),t=Me((()=>(function(s){const{scrollLeft:o,scrollWidth:a,clientWidth:u}=s;if(a===0)return{startX:0,endX:1};const l=o/a,d=(o+u)/a;return{startX:Math.max(0,Math.min(1,l)),endX:Math.max(0,Math.min(1,d))}})(e.value)),[e]),i=Me((()=>(function(s){return{left:s.scrollLeft,right:s.scrollLeft+s.clientWidth}})(e.value)),[e]),r=()=>{e.set({scrollLeft:n.scrollLeft,scrollWidth:n.scrollWidth,clientWidth:n.clientWidth})};return n.addEventListener("scroll",r,{passive:!0}),{scrollData:e,percentages:t,bounds:i,cleanup:()=>{n.removeEventListener("scroll",r),jt(e)}}}class Rn extends Ne{constructor(e,t){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.subscriptions=[],this.unsubscribeOnScroll=[],this.dragStream=null,this.scrollStream=null,this.subscriptions=[],this.options=e;const i=this.parentFromOptionsContainer(e.container);this.parent=i;const[r,s]=this.initHtml();i.appendChild(r),this.container=r,this.scrollContainer=s.querySelector(".scroll"),this.wrapper=s.querySelector(".wrapper"),this.canvasWrapper=s.querySelector(".canvases"),this.progressWrapper=s.querySelector(".progress"),this.cursor=s.querySelector(".cursor"),t&&s.appendChild(t),this.initEvents()}parentFromOptionsContainer(e){let t;if(typeof e=="string"?t=document.querySelector(e):e instanceof HTMLElement&&(t=e),!t)throw new Error("Container not found");return t}initEvents(){this.wrapper.addEventListener("click",(t=>{const i=this.wrapper.getBoundingClientRect(),[r,s]=mt(i,t.clientX,t.clientY);this.emit("click",r,s)})),this.wrapper.addEventListener("dblclick",(t=>{const i=this.wrapper.getBoundingClientRect(),[r,s]=mt(i,t.clientX,t.clientY);this.emit("dblclick",r,s)})),this.options.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.scrollStream=En(this.scrollContainer);const e=Ce((()=>{const{startX:t,endX:i}=this.scrollStream.percentages.value,{left:r,right:s}=this.scrollStream.bounds.value;this.emit("scroll",t,i,r,s)}),[this.scrollStream.percentages,this.scrollStream.bounds]);if(this.subscriptions.push(e),typeof ResizeObserver=="function"){const t=this.createDelay(100);this.resizeObserver=new ResizeObserver((()=>{t().then((()=>this.onContainerResize())).catch((()=>{}))})),this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const e=this.parent.clientWidth;e===this.lastContainerWidth&&this.options.height!=="auto"||(this.lastContainerWidth=e,this.reRender(),this.emit("resize"))}initDrag(){if(this.dragStream)return;this.dragStream=(function(t,i={}){const{threshold:r=3,mouseButton:s=0,touchDelay:o=100}=i,a=J(null),u=new Map,l=matchMedia("(pointer: coarse)").matches;let d=()=>{};const p=f=>{if(f.button!==s||(u.set(f.pointerId,f),u.size>1))return;let v=f.clientX,h=f.clientY,w=!1;const x=Date.now(),E=t.getBoundingClientRect(),{left:L,top:j}=E,P=D=>{if(D.defaultPrevented||u.size>1||l&&Date.now()-x<o)return;const W=D.clientX,G=D.clientY,V=W-v,F=G-h;(w||Math.abs(V)>r||Math.abs(F)>r)&&(D.preventDefault(),D.stopPropagation(),w||(a.set({type:"start",x:v-L,y:h-j}),w=!0),a.set({type:"move",x:W-L,y:G-j,deltaX:V,deltaY:F}),v=W,h=G)},g=D=>{if(u.delete(D.pointerId),w){const W=D.clientX,G=D.clientY;a.set({type:"end",x:W-L,y:G-j})}d()},k=D=>{u.delete(D.pointerId),D.relatedTarget&&D.relatedTarget!==document.documentElement||g(D)},M=D=>{w&&(D.stopPropagation(),D.preventDefault())},B=D=>{D.defaultPrevented||u.size>1||w&&D.preventDefault()};document.addEventListener("pointermove",P),document.addEventListener("pointerup",g),document.addEventListener("pointerout",k),document.addEventListener("pointercancel",k),document.addEventListener("touchmove",B,{passive:!1}),document.addEventListener("click",M,{capture:!0}),d=()=>{document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",g),document.removeEventListener("pointerout",k),document.removeEventListener("pointercancel",k),document.removeEventListener("touchmove",B),setTimeout((()=>{document.removeEventListener("click",M,{capture:!0})}),10)}};return t.addEventListener("pointerdown",p),{signal:a,cleanup:()=>{d(),t.removeEventListener("pointerdown",p),u.clear(),jt(a)}}})(this.wrapper);const e=Ce((()=>{const t=this.dragStream.signal.value;if(!t)return;const i=this.wrapper.getBoundingClientRect().width,r=(s=t.x/i)<0?0:s>1?1:s;var s;t.type==="start"?(this.isDragging=!0,this.emit("dragstart",r)):t.type==="move"?this.emit("drag",r):t.type==="end"&&(this.isDragging=!1,this.emit("dragend",r))}),[this.dragStream.signal]);this.subscriptions.push(e)}initHtml(){const e=document.createElement("div"),t=e.attachShadow({mode:"open"}),i=this.options.cspNonce&&typeof this.options.cspNonce=="string"?this.options.cspNonce.replace(/"/g,""):"";return t.innerHTML=`
|
||
<style${i?` nonce="${i}"`:""}>
|
||
:host {
|
||
user-select: none;
|
||
min-width: 1px;
|
||
}
|
||
:host audio {
|
||
display: block;
|
||
width: 100%;
|
||
}
|
||
:host .scroll {
|
||
overflow-x: auto;
|
||
overflow-y: hidden;
|
||
width: 100%;
|
||
position: relative;
|
||
}
|
||
:host .noScrollbar {
|
||
scrollbar-color: transparent;
|
||
scrollbar-width: none;
|
||
}
|
||
:host .noScrollbar::-webkit-scrollbar {
|
||
display: none;
|
||
-webkit-appearance: none;
|
||
}
|
||
:host .wrapper {
|
||
position: relative;
|
||
overflow: visible;
|
||
z-index: 2;
|
||
}
|
||
:host .canvases {
|
||
min-height: ${this.getHeight(this.options.height,this.options.splitChannels)}px;
|
||
pointer-events: none;
|
||
}
|
||
:host .canvases > div {
|
||
position: relative;
|
||
}
|
||
:host canvas {
|
||
display: block;
|
||
position: absolute;
|
||
top: 0;
|
||
image-rendering: pixelated;
|
||
}
|
||
:host .progress {
|
||
pointer-events: none;
|
||
position: absolute;
|
||
z-index: 2;
|
||
top: 0;
|
||
left: 0;
|
||
width: 0;
|
||
height: 100%;
|
||
overflow: hidden;
|
||
}
|
||
:host .progress > div {
|
||
position: relative;
|
||
}
|
||
:host .cursor {
|
||
pointer-events: none;
|
||
position: absolute;
|
||
z-index: 5;
|
||
top: 0;
|
||
left: 0;
|
||
height: 100%;
|
||
border-radius: 2px;
|
||
}
|
||
</style>
|
||
|
||
<div class="scroll" part="scroll">
|
||
<div class="wrapper" part="wrapper">
|
||
<div class="canvases" part="canvases"></div>
|
||
<div class="progress" part="progress"></div>
|
||
<div class="cursor" part="cursor"></div>
|
||
</div>
|
||
</div>
|
||
`,[e,t]}setOptions(e){if(this.options.container!==e.container){const t=this.parentFromOptionsContainer(e.container);t.appendChild(this.container),this.parent=t}e.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.options=e,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth}getScroll(){return this.scrollContainer.scrollLeft}setScroll(e){this.scrollContainer.scrollLeft=e}setScrollPercentage(e){const{scrollWidth:t}=this.scrollContainer,i=t*e;this.setScroll(i)}destroy(){var e;this.subscriptions.forEach((t=>t())),this.container.remove(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),(e=this.unsubscribeOnScroll)===null||e===void 0||e.forEach((t=>t())),this.unsubscribeOnScroll=[],this.dragStream&&(this.dragStream.cleanup(),this.dragStream=null),this.scrollStream&&(this.scrollStream.cleanup(),this.scrollStream=null)}createDelay(e=10){let t,i;const r=()=>{t&&(clearTimeout(t),t=void 0),i&&(i(),i=void 0)};return this.timeouts.push(r),()=>new Promise(((s,o)=>{r(),i=o,t=setTimeout((()=>{t=void 0,i=void 0,s()}),e)}))}getHeight(e,t){var i;const r=((i=this.audioData)===null||i===void 0?void 0:i.numberOfChannels)||1;return(function({optionsHeight:s,optionsSplitChannels:o,parentHeight:a,numberOfChannels:u,defaultHeight:l=128}){if(s==null)return l;const d=Number(s);if(!isNaN(d))return d;if(s==="auto"){const p=a||l;return o?.every((f=>!f.overlay))?p/u:p}return l})({optionsHeight:e,optionsSplitChannels:t,parentHeight:this.parent.clientHeight,numberOfChannels:r,defaultHeight:128})}convertColorValues(e,t){return(function(i,r,s){if(!Array.isArray(i))return i||"";if(i.length===0)return"#999";if(i.length<2)return i[0]||"";const o=document.createElement("canvas"),a=o.getContext("2d"),u=s??o.height*r,l=a.createLinearGradient(0,0,0,u||r),d=1/(i.length-1);return i.forEach(((p,f)=>{l.addColorStop(f*d,p)})),l})(e,this.getPixelRatio(),t?.canvas.height)}getPixelRatio(){return e=window.devicePixelRatio,Math.max(1,e||1);var e}renderBarWaveform(e,t,i,r){const{width:s,height:o}=i.canvas,{halfHeight:a,barWidth:u,barRadius:l,barIndexScale:d,barSpacing:p,barMinHeight:f}=(function({width:h,height:w,length:x,options:E,pixelRatio:L}){const j=w/2,P=E.barWidth?E.barWidth*L:1,g=E.barGap?E.barGap*L:E.barWidth?P/2:0,k=P+g||1;return{halfHeight:j,barWidth:P,barGap:g,barRadius:E.barRadius||0,barMinHeight:E.barMinHeight?E.barMinHeight*L:0,barIndexScale:x>0?h/k/x:0,barSpacing:k}})({width:s,height:o,length:(e[0]||[]).length,options:t,pixelRatio:this.getPixelRatio()}),v=(function({channelData:h,barIndexScale:w,barSpacing:x,barWidth:E,halfHeight:L,vScale:j,canvasHeight:P,barAlign:g,barMinHeight:k}){const M=h[0]||[],B=h[1]||M,D=M.length,W=[];let G=0,V=0,F=0;for(let $=0;$<=D;$++){const Y=Math.round($*w);if(Y>G){const{topHeight:I,totalHeight:te}=Mn({maxTop:V,maxBottom:F,halfHeight:L,vScale:j,barMinHeight:k,barAlign:g}),K=On({barAlign:g,halfHeight:L,topHeight:I,totalHeight:te,canvasHeight:P});W.push({x:G*x,y:K,width:E,height:te}),G=Y,V=0,F=0}const se=Math.abs(M[$]||0),ne=Math.abs(B[$]||0);se>V&&(V=se),ne>F&&(F=ne)}return W})({channelData:e,barIndexScale:d,barSpacing:p,barWidth:u,halfHeight:a,vScale:r,canvasHeight:o,barAlign:t.barAlign,barMinHeight:f});i.beginPath();for(const h of v)l&&"roundRect"in i?i.roundRect(h.x,h.y,h.width,h.height,l):i.rect(h.x,h.y,h.width,h.height);i.fill(),i.closePath()}renderLineWaveform(e,t,i,r){const{width:s,height:o}=i.canvas,a=(function({channelData:u,width:l,height:d,vScale:p}){const f=d/2,v=u[0]||[];return[v,u[1]||v].map(((h,w)=>{const x=h.length,E=x?l/x:0,L=f,j=w===0?-1:1,P=[{x:0,y:L}];let g=0,k=0;for(let M=0;M<=x;M++){const B=Math.round(M*E);if(B>g){const W=L+(Math.round(k*f*p)||1)*j;P.push({x:g,y:W}),g=B,k=0}const D=Math.abs(h[M]||0);D>k&&(k=D)}return P.push({x:g,y:L}),P}))})({channelData:e,width:s,height:o,vScale:r});i.beginPath();for(const u of a)if(u.length){i.moveTo(u[0].x,u[0].y);for(let l=1;l<u.length;l++){const d=u[l];i.lineTo(d.x,d.y)}}i.fill(),i.closePath()}renderWaveform(e,t,i){if(i.fillStyle=this.convertColorValues(t.waveColor,i),t.renderFunction)return void t.renderFunction(e,i);const r=(function({channelData:s,barHeight:o,normalize:a,maxPeak:u}){var l;const d=o||1;if(!a)return d;const p=s[0];if(!p||p.length===0)return d;let f=u??0;if(!u)for(let v=0;v<p.length;v++){const h=(l=p[v])!==null&&l!==void 0?l:0,w=Math.abs(h);w>f&&(f=w)}return f?d/f:d})({channelData:e,barHeight:t.barHeight,normalize:t.normalize,maxPeak:t.maxPeak});Wt(t)?this.renderBarWaveform(e,t,i,r):this.renderLineWaveform(e,t,i,r)}renderSingleCanvas(e,t,i,r,s,o,a){const u=this.getPixelRatio(),l=document.createElement("canvas");l.width=Math.round(i*u),l.height=Math.round(r*u),l.style.width=`${i}px`,l.style.height=`${r}px`,l.style.left=`${Math.round(s)}px`,o.appendChild(l);const d=l.getContext("2d");if(t.renderFunction?(d.fillStyle=this.convertColorValues(t.waveColor,d),t.renderFunction(e,d)):this.renderWaveform(e,t,d),l.width>0&&l.height>0){const p=l.cloneNode(),f=p.getContext("2d");f.drawImage(l,0,0),f.globalCompositeOperation="source-in",f.fillStyle=this.convertColorValues(t.progressColor,f),f.fillRect(0,0,l.width,l.height),a.appendChild(p)}}renderMultiCanvas(e,t,i,r,s,o){const a=this.getPixelRatio(),{clientWidth:u}=this.scrollContainer,l=i/a,d=(function({clientWidth:h,totalWidth:w,options:x}){return gt(Math.min(8e3,h,w),x)})({clientWidth:u,totalWidth:l,options:t});let p={};if(d===0)return;const f=h=>{if(h<0||h>=v||p[h])return;p[h]=!0;const w=h*d;let x=Math.min(l-w,d);if(x=gt(x,t),x<=0)return;const E=(function({channelData:L,offset:j,clampedWidth:P,totalWidth:g}){return L.map((k=>{const M=Math.floor(j/g*k.length),B=Math.floor((j+P)/g*k.length);return k.slice(M,B)}))})({channelData:e,offset:w,clampedWidth:x,totalWidth:l});this.renderSingleCanvas(E,t,x,r,w,s,o)},v=Math.ceil(l/d);if(!this.isScrollable){for(let h=0;h<v;h++)f(h);return}if(bt({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:l,numCanvases:v}).forEach((h=>f(h))),v>1){const h=this.on("scroll",(()=>{const{scrollLeft:w}=this.scrollContainer;Object.keys(p).length>10&&(s.innerHTML="",o.innerHTML="",p={}),bt({scrollLeft:w,totalWidth:l,numCanvases:v}).forEach((x=>f(x)))}));this.unsubscribeOnScroll.push(h)}}renderChannel(e,t,i,r){var{overlay:s}=t,o=(function(d,p){var f={};for(var v in d)Object.prototype.hasOwnProperty.call(d,v)&&p.indexOf(v)<0&&(f[v]=d[v]);if(d!=null&&typeof Object.getOwnPropertySymbols=="function"){var h=0;for(v=Object.getOwnPropertySymbols(d);h<v.length;h++)p.indexOf(v[h])<0&&Object.prototype.propertyIsEnumerable.call(d,v[h])&&(f[v[h]]=d[v[h]])}return f})(t,["overlay"]);const a=document.createElement("div"),u=this.getHeight(o.height,o.splitChannels);a.style.height=`${u}px`,s&&r>0&&(a.style.marginTop=`-${u}px`),this.canvasWrapper.style.minHeight=`${u}px`,this.canvasWrapper.appendChild(a);const l=a.cloneNode();this.progressWrapper.appendChild(l),this.renderMultiCanvas(e,o,i,u,a,l)}render(e){return ue(this,void 0,void 0,(function*(){var t;this.timeouts.forEach((l=>l())),this.timeouts=[],this.canvasWrapper.innerHTML="",this.progressWrapper.innerHTML="",this.options.width!=null&&(this.scrollContainer.style.width=typeof this.options.width=="number"?`${this.options.width}px`:this.options.width);const i=this.getPixelRatio(),r=this.scrollContainer.clientWidth,{scrollWidth:s,isScrollable:o,useParentWidth:a,width:u}=(function({duration:l,minPxPerSec:d=0,parentWidth:p,fillParent:f,pixelRatio:v}){const h=Math.ceil(l*d),w=h>p,x=!!(f&&!w);return{scrollWidth:h,isScrollable:w,useParentWidth:x,width:(x?p:h)*v}})({duration:e.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:r,fillParent:this.options.fillParent,pixelRatio:i});if(this.isScrollable=o,this.wrapper.style.width=a?"100%":`${s}px`,this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden",this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar),this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`,this.cursor.style.width=`${this.options.cursorWidth}px`,this.audioData=e,this.emit("render"),this.options.splitChannels)for(let l=0;l<e.numberOfChannels;l++){const d=Object.assign(Object.assign({},this.options),(t=this.options.splitChannels)===null||t===void 0?void 0:t[l]);this.renderChannel([e.getChannelData(l)],d,u,l)}else{const l=[e.getChannelData(0)];e.numberOfChannels>1&&l.push(e.getChannelData(1)),this.renderChannel(l,this.options,u,0)}Promise.resolve().then((()=>this.emit("rendered")))}))}reRender(){if(this.unsubscribeOnScroll.forEach((i=>i())),this.unsubscribeOnScroll=[],!this.audioData)return;const{scrollWidth:e}=this.scrollContainer,{right:t}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),this.isScrollable&&e!==this.scrollContainer.scrollWidth){const{right:i}=this.progressWrapper.getBoundingClientRect(),r=(function(s){const o=2*s;return(o<0?Math.floor(o):Math.ceil(o))/2})(i-t);this.scrollContainer.scrollLeft+=r}}zoom(e){this.options.minPxPerSec=e,this.reRender()}scrollIntoView(e,t=!1){const{scrollLeft:i,scrollWidth:r,clientWidth:s}=this.scrollContainer,o=e*r,a=i,u=i+s,l=s/2;if(this.isDragging)o+30>u?this.scrollContainer.scrollLeft+=30:o-30<a&&(this.scrollContainer.scrollLeft-=30);else{(o<a||o>u)&&(this.scrollContainer.scrollLeft=o-(this.options.autoCenter?l:0));const d=o-i-l;t&&this.options.autoCenter&&d>0&&(this.scrollContainer.scrollLeft+=d)}}renderProgress(e,t){if(isNaN(e))return;const i=100*e;this.canvasWrapper.style.clipPath=`polygon(${i}% 0%, 100% 0%, 100% 100%, ${i}% 100%)`,this.progressWrapper.style.width=`${i}%`,this.cursor.style.left=`${i}%`,this.cursor.style.transform=this.options.cursorWidth?`translateX(-${e*this.options.cursorWidth}px)`:"",this.isScrollable&&this.options.autoScroll&&this.audioData&&this.audioData.duration>0&&this.scrollIntoView(e,t)}exportImage(e,t,i){return ue(this,void 0,void 0,(function*(){const r=this.canvasWrapper.querySelectorAll("canvas");if(!r.length)throw new Error("No waveform data");if(i==="dataURL"){const s=Array.from(r).map((o=>o.toDataURL(e,t)));return Promise.resolve(s)}return Promise.all(Array.from(r).map((s=>new Promise(((o,a)=>{s.toBlob((u=>{u?o(u):a(new Error("Could not export image"))}),e,t)})))))}))}}class Tn extends Ne{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;const e=()=>{this.isRunning&&(this.emit("tick"),this.animationFrameId=requestAnimationFrame(e))};e()}stop(){this.isRunning=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop()}}class Fe extends Ne{constructor(e=new AudioContext){super(),this.bufferNode=null,this.playStartTime=0,this.playedDuration=0,this._muted=!1,this._playbackRate=1,this._duration=void 0,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.seeking=!1,this.autoplay=!1,this.addEventListener=this.on,this.removeEventListener=this.un,this.audioContext=e,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return ue(this,void 0,void 0,(function*(){}))}get src(){return this.currentSrc}set src(e){if(this.currentSrc=e,this._duration=void 0,!e)return this.buffer=null,void this.emit("emptied");fetch(e).then((t=>{if(t.status>=400)throw new Error(`Failed to fetch ${e}: ${t.status} (${t.statusText})`);return t.arrayBuffer()})).then((t=>this.currentSrc!==e?null:this.audioContext.decodeAudioData(t))).then((t=>{this.currentSrc===e&&(this.buffer=t,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())})).catch((t=>{console.error("WebAudioPlayer load error:",t)}))}_play(){if(!this.paused)return;this.paused=!1,this.bufferNode&&(this.bufferNode.onended=null,this.bufferNode.disconnect()),this.bufferNode=this.audioContext.createBufferSource(),this.buffer&&(this.bufferNode.buffer=this.buffer),this.bufferNode.playbackRate.value=this._playbackRate,this.bufferNode.connect(this.gainNode);let e=this.playedDuration*this._playbackRate;(e>=this.duration||e<0)&&(e=0,this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,e),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{this.currentTime>=this.duration&&(this.pause(),this.emit("ended"))}}_pause(){var e;this.paused=!0,(e=this.bufferNode)===null||e===void 0||e.stop(),this.playedDuration+=this.audioContext.currentTime-this.playStartTime}play(){return ue(this,void 0,void 0,(function*(){this.paused&&(this._play(),this.emit("play"))}))}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(e){const t=e-this.currentTime,i=this.bufferNode;i?.stop(this.audioContext.currentTime+t),i?.addEventListener("ended",(()=>{i===this.bufferNode&&(this.bufferNode=null,this.pause())}),{once:!0})}setSinkId(e){return ue(this,void 0,void 0,(function*(){return this.audioContext.setSinkId(e)}))}get playbackRate(){return this._playbackRate}set playbackRate(e){this._playbackRate=e,this.bufferNode&&(this.bufferNode.playbackRate.value=e)}get currentTime(){return(this.paused?this.playedDuration:this.playedDuration+(this.audioContext.currentTime-this.playStartTime))*this._playbackRate}set currentTime(e){const t=!this.paused;t&&this._pause(),this.playedDuration=e/this._playbackRate,t&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var e,t;return(e=this._duration)!==null&&e!==void 0?e:((t=this.buffer)===null||t===void 0?void 0:t.duration)||0}set duration(e){this._duration=e}get volume(){return this.gainNode.gain.value}set volume(e){this.gainNode.gain.value=e,this.emit("volumechange")}get muted(){return this._muted}set muted(e){this._muted!==e&&(this._muted=e,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}canPlayType(e){return/^(audio|video)\//.test(e)}getGainNode(){return this.gainNode}getChannelData(){const e=[];if(!this.buffer)return e;const t=this.buffer.numberOfChannels;for(let i=0;i<t;i++)e.push(this.buffer.getChannelData(i));return e}removeAttribute(e){switch(e){case"src":this.src="";break;case"playbackRate":this.playbackRate=0;break;case"currentTime":this.currentTime=0;break;case"duration":this.duration=0;break;case"volume":this.volume=0;break;case"muted":this.muted=!1}}}const Ln={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class Te extends kn{static create(e){return new Te(e)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(e){const t=e.media||(e.backend==="WebAudio"?new Fe:void 0);super({media:t,mediaControls:e.mediaControls,autoplay:e.autoplay,playbackRate:e.audioRate}),this.plugins=[],this.decodedData=null,this.stopAtPosition=null,this.subscriptions=[],this.mediaSubscriptions=[],this.abortController=null,this.reactiveCleanups=[],this.options=Object.assign({},Ln,e);const{state:i,actions:r}=(function(a){var u,l,d,p,f,v;const h=(u=a?.currentTime)!==null&&u!==void 0?u:J(0),w=(l=a?.duration)!==null&&l!==void 0?l:J(0),x=(d=a?.isPlaying)!==null&&d!==void 0?d:J(!1),E=(p=a?.isSeeking)!==null&&p!==void 0?p:J(!1),L=(f=a?.volume)!==null&&f!==void 0?f:J(1),j=(v=a?.playbackRate)!==null&&v!==void 0?v:J(1),P=J(null),g=J(null),k=J(""),M=J(0),B=J(0),D=Me((()=>!x.value),[x]),W=Me((()=>P.value!==null),[P]),G=Me((()=>W.value&&w.value>0),[W,w]),V=Me((()=>h.value),[h]),F=Me((()=>w.value>0?h.value/w.value:0),[h,w]);return{state:{currentTime:h,duration:w,isPlaying:x,isPaused:D,isSeeking:E,volume:L,playbackRate:j,audioBuffer:P,peaks:g,url:k,zoom:M,scrollPosition:B,canPlay:W,isReady:G,progress:V,progressPercent:F},actions:{setCurrentTime:$=>{const Y=Math.max(0,Math.min(w.value||1/0,$));h.set(Y)},setDuration:$=>{w.set(Math.max(0,$))},setPlaying:$=>{x.set($)},setSeeking:$=>{E.set($)},setVolume:$=>{const Y=Math.max(0,Math.min(1,$));L.set(Y)},setPlaybackRate:$=>{const Y=Math.max(.1,Math.min(16,$));j.set(Y)},setAudioBuffer:$=>{P.set($),$&&w.set($.duration)},setPeaks:$=>{g.set($)},setUrl:$=>{k.set($)},setZoom:$=>{M.set(Math.max(0,$))},setScrollPosition:$=>{B.set(Math.max(0,$))}}}})({isPlaying:this.isPlayingSignal,currentTime:this.currentTimeSignal,duration:this.durationSignal,volume:this.volumeSignal,playbackRate:this.playbackRateSignal,isSeeking:this.seekingSignal});this.wavesurferState=i,this.wavesurferActions=r,this.timer=new Tn;const s=t?void 0:this.getMediaElement();this.renderer=new Rn(this.options,s),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initReactiveState(),this.initPlugins();const o=this.options.url||this.getSrc()||"";Promise.resolve().then((()=>{this.emit("init");const{peaks:a,duration:u}=this.options;(o||a&&u)&&this.load(o,a,u).catch((l=>{this.emit("error",l instanceof Error?l:new Error(String(l)))}))}))}updateProgress(e=this.getCurrentTime()){return this.renderer.renderProgress(e/this.getDuration(),this.isPlaying()),e}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",(()=>{if(!this.isSeeking()){const e=this.updateProgress();this.emit("timeupdate",e),this.emit("audioprocess",e),this.stopAtPosition!=null&&this.isPlaying()&&e>=this.stopAtPosition&&this.pause()}})))}initReactiveState(){this.reactiveCleanups.push((function(e,t){const i=[];i.push(Ce((()=>{const o=e.isPlaying.value;t.emit(o?"play":"pause")}),[e.isPlaying])),i.push(Ce((()=>{const o=e.currentTime.value;t.emit("timeupdate",o),e.isPlaying.value&&t.emit("audioprocess",o)}),[e.currentTime,e.isPlaying])),i.push(Ce((()=>{e.isSeeking.value&&t.emit("seeking",e.currentTime.value)}),[e.isSeeking,e.currentTime]));let r=!1;i.push(Ce((()=>{e.isReady.value&&!r&&(r=!0,t.emit("ready",e.duration.value))}),[e.isReady,e.duration]));let s=!1;return i.push(Ce((()=>{const o=e.isPlaying.value,a=e.currentTime.value,u=e.duration.value,l=u>0&&a>=u;s&&!o&&l&&t.emit("finish"),s=o&&l}),[e.isPlaying,e.currentTime,e.duration])),i.push(Ce((()=>{const o=e.zoom.value;o>0&&t.emit("zoom",o)}),[e.zoom])),()=>{i.forEach((o=>o()))}})(this.wavesurferState,{emit:this.emit.bind(this)}))}initPlayerEvents(){this.isPlaying()&&(this.emit("play"),this.timer.start()),this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",(()=>{const e=this.updateProgress();this.emit("timeupdate",e)})),this.onMediaEvent("play",(()=>{this.emit("play"),this.timer.start()})),this.onMediaEvent("pause",(()=>{this.emit("pause"),this.timer.stop(),this.stopAtPosition=null})),this.onMediaEvent("emptied",(()=>{this.timer.stop(),this.stopAtPosition=null})),this.onMediaEvent("ended",(()=>{this.emit("timeupdate",this.getDuration()),this.emit("finish"),this.stopAtPosition=null})),this.onMediaEvent("seeking",(()=>{this.emit("seeking",this.getCurrentTime())})),this.onMediaEvent("error",(()=>{var e;this.emit("error",(e=this.getMediaElement().error)!==null&&e!==void 0?e:new Error("Media error")),this.stopAtPosition=null})))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",((e,t)=>{this.options.interact&&(this.seekTo(e),this.emit("interaction",e*this.getDuration()),this.emit("click",e,t))})),this.renderer.on("dblclick",((e,t)=>{this.emit("dblclick",e,t)})),this.renderer.on("scroll",((e,t,i,r)=>{const s=this.getDuration();this.emit("scroll",e*s,t*s,i,r)})),this.renderer.on("render",(()=>{this.emit("redraw")})),this.renderer.on("rendered",(()=>{this.emit("redrawcomplete")})),this.renderer.on("dragstart",(e=>{this.emit("dragstart",e)})),this.renderer.on("dragend",(e=>{this.emit("dragend",e)})),this.renderer.on("resize",(()=>{this.emit("resize")})));{let e;const t=this.renderer.on("drag",(i=>{var r;if(!this.options.interact)return;this.renderer.renderProgress(i),clearTimeout(e);let s=0;const o=this.options.dragToSeek;this.isPlaying()?s=0:o===!0?s=200:o&&typeof o=="object"&&(s=(r=o.debounceTime)!==null&&r!==void 0?r:200),e=setTimeout((()=>{this.seekTo(i)}),s),this.emit("interaction",i*this.getDuration()),this.emit("drag",i)}));this.subscriptions.push((()=>{clearTimeout(e),t()}))}}initPlugins(){var e;!((e=this.options.plugins)===null||e===void 0)&&e.length&&this.options.plugins.forEach((t=>{this.registerPlugin(t)}))}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach((e=>e())),this.mediaSubscriptions=[]}setOptions(e){this.options=Object.assign({},this.options,e),e.duration&&!e.peaks&&(this.decodedData=je.createBuffer(this.exportPeaks(),e.duration)),e.peaks&&e.duration&&(this.decodedData=je.createBuffer(e.peaks,e.duration)),this.renderer.setOptions(this.options),e.audioRate&&this.setPlaybackRate(e.audioRate),e.mediaControls!=null&&(this.getMediaElement().controls=e.mediaControls)}registerPlugin(e){if(this.plugins.includes(e))return e;e._init(this),this.plugins.push(e);const t=e.once("destroy",(()=>{this.plugins=this.plugins.filter((i=>i!==e)),this.subscriptions=this.subscriptions.filter((i=>i!==t))}));return this.subscriptions.push(t),e}unregisterPlugin(e){this.plugins=this.plugins.filter((t=>t!==e)),e.destroy()}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(e){return this.renderer.setScroll(e)}setScrollTime(e){const t=e/this.getDuration();this.renderer.setScrollPercentage(t)}getActivePlugins(){return this.plugins}loadAudio(e,t,i,r){return ue(this,void 0,void 0,(function*(){var s;if(this.emit("load",e),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,this.stopAtPosition=null,(s=this.abortController)===null||s===void 0||s.abort(),this.abortController=null,!t&&!i){const a=this.options.fetchParams||{};window.AbortController&&!a.signal&&(this.abortController=new AbortController,a.signal=this.abortController.signal);const u=d=>this.emit("loading",d);t=yield Pn.fetchBlob(e,u,a);const l=this.options.blobMimeType;l&&(t=new Blob([t],{type:l}))}this.setSrc(e,t);const o=yield new Promise((a=>{const u=r||this.getDuration();u?a(u):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",(()=>a(this.getDuration())),{once:!0}))}));if(!e&&!t){const a=this.getMediaElement();a instanceof Fe&&(a.duration=o)}if(i)this.decodedData=je.createBuffer(i,o||0);else if(t){const a=yield t.arrayBuffer();this.decodedData=yield je.decode(a,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())}))}load(e,t,i){return ue(this,void 0,void 0,(function*(){try{return yield this.loadAudio(e,void 0,t,i)}catch(r){throw this.emit("error",r),r}}))}loadBlob(e,t,i){return ue(this,void 0,void 0,(function*(){try{return yield this.loadAudio("",e,t,i)}catch(r){throw this.emit("error",r),r}}))}zoom(e){if(!this.decodedData)throw new Error("No audio loaded");this.renderer.zoom(e),this.emit("zoom",e)}getDecodedData(){return this.decodedData}exportPeaks({channels:e=2,maxLength:t=8e3,precision:i=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const r=Math.min(e,this.decodedData.numberOfChannels),s=[];for(let o=0;o<r;o++){const a=this.decodedData.getChannelData(o),u=[],l=a.length/t;for(let d=0;d<t;d++){const p=a.slice(Math.floor(d*l),Math.ceil((d+1)*l));let f=0;for(let v=0;v<p.length;v++){const h=p[v];Math.abs(h)>Math.abs(f)&&(f=h)}u.push(Math.round(f*i)/i)}s.push(u)}return s}getDuration(){let e=super.getDuration()||0;return e!==0&&e!==1/0||!this.decodedData||(e=this.decodedData.duration),e}toggleInteraction(e){this.options.interact=e}setTime(e){this.stopAtPosition=null,super.setTime(e),this.updateProgress(e),this.emit("timeupdate",e)}seekTo(e){const t=this.getDuration()*e;this.setTime(t)}play(e,t){const i=Object.create(null,{play:{get:()=>super.play}});return ue(this,void 0,void 0,(function*(){e!=null&&this.setTime(e);const r=yield i.play.call(this);return t!=null&&(this.media instanceof Fe?this.media.stopAt(t):this.stopAtPosition=t),r}))}playPause(){return ue(this,void 0,void 0,(function*(){return this.isPlaying()?this.pause():this.play()}))}stop(){this.pause(),this.setTime(0)}skip(e){this.setTime(this.getCurrentTime()+e)}empty(){this.load("",[[0]],.001)}setMediaElement(e){this.unsubscribePlayerEvents(),super.setMediaElement(e),this.initPlayerEvents()}exportImage(){return ue(this,arguments,void 0,(function*(e="image/png",t=1,i="dataURL"){return this.renderer.exportImage(e,t,i)}))}destroy(){var e;this.emit("destroy"),(e=this.abortController)===null||e===void 0||e.abort(),this.plugins.forEach((t=>t.destroy())),this.subscriptions.forEach((t=>t())),this.unsubscribePlayerEvents(),this.reactiveCleanups.forEach((t=>t())),this.reactiveCleanups=[],this.timer.destroy(),this.renderer.destroy(),super.destroy()}}Te.BasePlugin=class extends Ne{constructor(n){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=n}onInit(){}_init(n){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=n,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach((n=>n())),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}},Te.dom=_n;const Dn=["dir"],$n={key:0,class:"file-container"},In={key:1,class:"file-container"},An={key:0,class:"flex items-center justify-center py-3"},Nn={key:1,class:"whatsapp-audio-player"},Wn={class:"flex items-center gap-3 !w-60vw"},jn=["onClick"],zn={class:"flex-1 flex flex-col gap-1 min-w-0 w-full"},Bn={class:"font-medium"},Hn={class:"flex items-center w-full flex-1"},Un={class:"flex justify-start gap-2 items-center w-full"},Fn={class:"waveform-container"},Gn={class:"font-medium"},Vn={key:2,class:"whatsapp-audio-player"},Xn=["onTimeupdate","onLoadedmetadata","onPlay","onPause","onEnded"],Yn={class:"flex items-center gap-3"},Zn=["onClick","disabled"],qn={class:"flex-1 flex flex-col gap-1 min-w-0"},Jn={class:"font-medium"},Qn={class:"flex-1"},Kn={class:"font-medium"},er=["onClick"],tr={key:2,class:"file-container"},ir=["href"],nr={class:"file-name"},rr=["dir"],sr={class:"time"},ar=pe({__name:"Conversation",props:{chatId:{}},setup(n,{expose:e}){const t=n,i=Ct(),r=U(()=>i.user),s=St(),o=T([]),a=T(null),u=T(new Map),l=T(new Map),d=T(new Map),p=T(new Map),f=T(new Map),v=T(new Map),h=T(new Map),w=T(new Map),x=T(new Map),E=T(new Map),L=async c=>{const b=u.value.get(c);if(!(!b||!c)&&!(b.src&&b.src.startsWith("blob:")))try{f.value.set(c,!0);const z=localStorage.getItem("auth-token");let Z="",m=c;(c.startsWith("http://")||c.startsWith("https://"))&&(m=new URL(c).pathname,Z=c),m.startsWith("/")||(m="/"+m,Z=`https://file.montifyshop.ir${m}`);const X=await fetch(Z,{method:"get",headers:{Authorization:`Bearer ${z}`}});if(!X.ok)throw new Error("خطا در دریافت فایل صوتی");const me=await X.blob();b.src=URL.createObjectURL(me),b.load(),f.value.set(c,!1)}catch(z){console.error("Error loading audio:",z),f.value.set(c,!1);try{b.src=ne(c),b.load()}catch(Z){console.error("Error loading audio from direct URL:",Z)}}},j=(c,b)=>{!c||!b||u.value.has(b)||u.value.set(b,c)},P=async c=>{const b=u.value.get(c);b&&((!b.src||!b.src.startsWith("blob:")&&!b.readyState)&&await L(c),b.paused?b.play():b.pause())},g=c=>p.value.get(c)||!1,k=c=>{if(v.value.get(c))return;const b=u.value.get(c);b&&l.value.set(c,b.currentTime)},M=c=>{const b=u.value.get(c);b&&d.value.set(c,b.duration)},B=(c,b)=>{p.value.set(c,b)},D=c=>l.value.get(c)||0,W=c=>d.value.get(c)||0,G=(c,b)=>{const z=u.value.get(c);z&&(z.currentTime=b,l.value.set(c,b))},V=c=>{if(!c||isNaN(c))return"0:00";const b=Math.floor(c/60),z=Math.floor(c%60);return`${b}:${z.toString().padStart(2,"0")}`},F=c=>{const b=ne(c),z=document.createElement("a");z.href=b,z.download=I(c),document.body.appendChild(z),z.click(),document.body.removeChild(z)},$=c=>{if(!c)return!1;const b=[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp"],z=c.toLowerCase();return b.some(Z=>z.includes(Z))},Y=c=>{if(!c)return!1;const b=[".mp3",".wav",".ogg",".m4a",".aac",".flac",".wma",".opus",".mp4",".mpeg",".m4v",".webm"],z=c.toLowerCase();return b.some(Z=>z.includes(Z))},se=c=>c?c.toLowerCase().includes(".webm"):!1,ne=c=>c?c.startsWith("http://")||c.startsWith("https://")?c:`https://file.montifyshop.ir/${c}`:"",I=c=>{if(!c)return"فایل";try{const Z=new URL(c).pathname.split("/").pop()||"فایل";return decodeURIComponent(Z)}catch{const b=c.split("/").pop()||"فایل";return decodeURIComponent(b)}},te=c=>new Date(c).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});async function K(){if(!t.chatId)return;const c=await ai(t.chatId,1,1e3);o.value=Array.isArray(c)?c:c?.data||[]}function ae(){a.value&&$e(()=>{const c=a.value;c.scrollTo({top:c.scrollHeight,behavior:"smooth"})})}Se(o,()=>{ae()}),e({request:K,scrollToBottom:ae});const ge=async(c,b,z)=>{if(!b||!c)return;const Z=h.value.get(c);Z&&Z.destroy();try{const m=localStorage.getItem("auth-token");let X=ne(c);const me=await fetch(X,{method:"get",headers:{Authorization:`Bearer ${m}`}});if(!me.ok)throw new Error("خطا در دریافت فایل صوتی");const be=await me.blob(),R=URL.createObjectURL(be),q=Te.create({container:b,height:50,normalize:!0,waveColor:z==i.user.id?"rgb(99,159,255)":"#94a3b8",progressColor:z==i.user.id?"#ffffff":"#2563eb",cursorColor:"#ef4444",barWidth:3,barGap:2,barRadius:4,interact:!0,dragToSeek:!0,fillParent:!0,autoCenter:!0});q.load(R),q.on("ready",()=>{const he=q.getDuration();d.value.set(c,he)}),q.on("timeupdate",he=>{x.value.set(c,he)}),q.on("play",()=>{E.value.set(c,!0)}),q.on("pause",()=>{E.value.set(c,!1)}),q.on("finish",()=>{E.value.set(c,!1),x.value.set(c,0)}),h.value.set(c,q)}catch(m){console.error("Error initializing waveform:",m)}},C=c=>{const b=h.value.get(c);b&&b.playPause()},O=(c,b)=>{!c||!b.file_url||w.value.has(b.file_url)||(w.value.set(b.file_url,c),$e(()=>{ge(b.file_url,c,b.sender_id)}))},S=c=>{if(!c||isNaN(c))return"0:00";const b=Math.floor(c/60),z=Math.floor(c%60);return`${b}:${z.toString().padStart(2,"0")}`},H=c=>x.value.get(c)||0,Q=c=>d.value.get(c)||0,oe=c=>E.value.get(c)||!1;return xt(()=>{h.value.forEach(c=>{c.destroy()}),h.value.clear(),w.value.clear()}),Ae(async()=>{await K()}),(c,b)=>{const z=ke,Z=Si;return A(),ee("div",{class:"chat-container",ref_key:"chatContainer",ref:a},[(A(!0),ee(He,null,si(o.value,m=>(A(),ee("div",{key:m.id,class:ie(["message",{sent:m.sender_id===r.value.id,received:m.sender_id!==r.value.id}])},[y("div",{class:"message-bubble",dir:re(s).isRTL?"rtl":"ltr"},[m.file_url&&$(m.file_url)?(A(),ee("div",$n,[_(z,{src:ne(m.file_url),preview:{src:ne(m.file_url)},class:"w-full max-w-xs rounded-lg max-h-80 message-image",alt:"پیوست",previewMask:!1},null,8,["src","preview"])])):m.file_url&&Y(m.file_url)?(A(),ee("div",In,[f.value.get(m.file_url)?(A(),ee("div",An,[y("span",{class:ie(["text-xs opacity-70 mr-2",m.sender_id===r.value.id?"text-white":"text-gray-600"])},"در حال بارگذاری...",2)])):se(m.file_url)?(A(),ee("div",Nn,[y("div",Wn,[y("button",{onClick:X=>C(m.file_url),class:ie(["flex-shrink-0 whatsapp-play-button",m.sender_id===r.value.id?"whatsapp-play-button-sent":"whatsapp-play-button-received"])},[oe(m.file_url)?(A(),le(ve,{key:1,icon:"vuesax-linear:pause",size:24,color:m.sender_id===r.value.id?"white":"#007aff"},null,8,["color"])):(A(),le(ve,{key:0,icon:"vuesax-linear:play",size:24,color:m.sender_id===r.value.id?"white":"#007aff"},null,8,["color"]))],10,jn),y("div",zn,[y("div",{class:ie(["flex items-center justify-between text-xs gap-2 w-full md:max-w-45%",m.sender_id===r.value.id?"text-white/90":"text-gray-700"])},[y("span",Bn,ce(S(H(m.file_url))),1),y("div",Hn,[y("div",Un,[y("div",Fn,[y("div",{ref_for:!0,ref:X=>m.file_url&&O(X,m),class:"w-27vw rounded-lg"},null,512)]),y("span",Gn,ce(S(Q(m.file_url))),1)])])],2)])])])):(A(),ee("div",Vn,[y("audio",{ref_for:!0,ref:X=>m.file_url&&j(X,m.file_url),onTimeupdate:X=>k(m.file_url),onLoadedmetadata:X=>M(m.file_url),onPlay:X=>B(m.file_url,!0),onPause:X=>B(m.file_url,!1),onEnded:X=>B(m.file_url,!1),preload:"none",class:"hidden"}," مرورگر شما از پخش فایل صوتی پشتیبانی نمیکند. ",40,Xn),y("div",Yn,[y("button",{onClick:X=>P(m.file_url),class:ie(["flex-shrink-0 whatsapp-play-button",m.sender_id===r.value.id?"whatsapp-play-button-sent":"whatsapp-play-button-received"]),disabled:f.value.get(m.file_url)},[g(m.file_url)?(A(),le(ve,{key:1,icon:"vuesax-linear:pause",size:24,color:m.sender_id===r.value.id?"white":"#007aff"},null,8,["color"])):(A(),le(ve,{key:0,icon:"vuesax-linear:play",size:24,color:m.sender_id===r.value.id?"white":"#007aff"},null,8,["color"]))],10,Zn),y("div",qn,[y("div",{class:ie(["flex items-center gap-2 text-xs",m.sender_id===r.value.id?"text-white/90":"text-gray-700"])},[y("span",Jn,ce(V(D(m.file_url))),1),y("div",Qn,[_(Z,{value:D(m.file_url)||0,max:W(m.file_url)||0,step:.1,onChange:X=>G(m.file_url,Array.isArray(X)?X[0]:X),tooltipOpen:!1,style:oi({direction:re(s).isRTL?"rtl":"ltr"}),class:"w-10"},null,8,["value","max","onChange","style"])]),y("span",Kn,ce(V(W(m.file_url))),1)],2)]),y("button",{onClick:_t(X=>F(m.file_url),["stop"]),class:ie(["flex-shrink-0 whatsapp-download-button",m.sender_id===r.value.id?"whatsapp-download-button-sent":"whatsapp-download-button-received"]),title:"دانلود فایل صوتی"},[_(ve,{icon:"vuesax-linear:import-2",size:20,color:m.sender_id===r.value.id?"white":"#007aff"},null,8,["color"])],10,er)])]))])):m.file_url?(A(),ee("div",tr,[y("a",{href:ne(m.file_url),target:"_blank",class:"file-link",download:""},[b[0]||(b[0]=y("span",{class:"file-icon"},"📎",-1)),y("span",nr,ce(I(m.file_url)),1)],8,ir)])):fe("",!0),m.text?(A(),ee("p",{key:3,dir:re(s).isRTL?"rtl":"ltr"},ce(m.text),9,rr)):fe("",!0),y("span",sr,ce(te(m.created_at)),1)],8,Dn)],2))),128))],512)}}}),or=Ot(ar,[["__scopeId","data-v-9e36a8c7"]]),lr={class:"sm:w-50vw sm:justify-self-center"},ur={class:"flex justify-between items-center w-full p4"},cr={class:"flex items-center gap-5"},dr={key:0,class:"flex gap-24px items-center"},hr={class:"font-semibold flex items-center"},pr={class:"flex font-200 text-xs items-center"},fr={dir:"ltr"},vr={dir:"ltr",class:"h-98vh pb-10 overflow-hidden"},mr={key:0,class:"relative"},gr=["src","alt"],br={key:1,class:"flex items-center gap-3 flex-1"},yr={class:"flex-1 whatsapp-audio-player"},wr={class:"flex items-center gap-3 w-full"},Cr={class:"flex-1 flex flex-col gap-1 min-w-0"},Sr={class:"flex items-center justify-between text-xs text-gray-700"},xr={class:"font-medium"},_r={class:"flex items-center gap-2"},Pr={class:"waveform-container"},kr={class:"font-medium"},Mr={key:2,class:"flex items-center gap-2 flex-1"},Or={class:"flex-1 text-sm truncate"},Er={class:"flex items-center gap-2 flex-1"},Rr={class:"text-sm"},Tr={class:"flex items-center gap-3"},Lr=["alt"],Dr=pe({__name:"index",setup(n){const e=li(),t=St(),i=Ct(),r=T(""),s=T(null),o=T(null),a=T(null),u=T(""),l=T(void 0),d=T(null),p=T(null),f=T(!1),v=T(0),h=T(!1),w=T(null),x=T([]),E=T(0),L=T(null),j=T(0),P=T(null);U(()=>t.sellerConfig?.store?.main&&i.user.id!==t.sellerConfig?.store?.id);const g=T(!1),k=T(!1),M=T(void 0);Ae(async()=>{try{if(g.value=!0,e.currentRoute.value.query?.id?.length){const C=await ui(e.currentRoute.value.query?.id);i.user.id===C?.user1_id?l.value=C?.user2:C.user1&&(l.value=C?.user1),M.value={chat_id:e.currentRoute.value.query.id}}else{const C=e.currentRoute.value.query?.user_id??t.sellerConfig?.store?.id,O=await ci(C,i.user.id);if(O?.length)M.value=O[0];else{const S=await di(C,i.user.id);M.value=S}i.user.id===M.value?.user1_id?l.value=M.value?.user2:M.value.user1&&(l.value=M.value?.user1)}}catch(C){console.log("e ===>",C)}finally{g.value=!1}}),xt(()=>{P.value&&(P.value.getTracks().forEach(C=>C.stop()),P.value=null),h.value&&w.value&&w.value.stop(),p.value&&(p.value.destroy(),p.value=null),u.value&&URL.revokeObjectURL(u.value),L.value&&clearInterval(L.value)});const B=async()=>{if(!(!r.value.length&&!a.value||!M.value?.chat_id||!s.value))try{k.value=!0;let C=null;if(a.value){const S=t.STORAGE_UPLOAD,H=typeof S=="string"?S:S?.value||"";if(console.log("STORAGE_UPLOAD:",t.STORAGE_UPLOAD,"endpointStr:",H),!H||H===""){console.error("خطا: endpoint آپلود فایل تنظیم نشده است. لطفاً تنظیمات را بررسی کنید."),k.value=!1;return}let Q;if(G(a.value)?Q=await xi(a.value,{endpoint:H}):Q=await W(a.value,H),Q.error||!Q.data?.fullPath){console.error("خطا در آپلود فایل:",Q.error),k.value=!1;return}C=Q.data.fullPath}const O=await pi(M.value.chat_id,r.value||"",C||null);await s.value.request(),s.value.scrollToBottom(),r.value="",ae()}catch(C){console.log("e ===>",C)}finally{k.value=!1}},D=()=>{o.value?.click()},W=async(C,O)=>{try{const S=new FormData;S.append("file",C);const H=await fetch(O,{method:"POST",body:S}),Q=await H.text();if(!H.ok)return{error:Q||`HTTP ${H.status}`};let oe;try{oe=JSON.parse(Q)}catch{oe={}}const c=oe?.path||oe?.fullPath;return c?{data:{fullPath:c},error:null}:{error:"No path returned"}}catch(S){return{error:S?.message||S}}},G=C=>C.type.startsWith("image/"),V=C=>C.type.startsWith("audio/"),F=async()=>{try{const C=await navigator.mediaDevices.getUserMedia({audio:!0}),O=new MediaRecorder(C),S=[];P.value=C,O.ondataavailable=H=>{H.data.size>0&&S.push(H.data)},O.onstop=async()=>{const H=new Blob(S,{type:"audio/webm"}),Q=new File([H],`recording-${Date.now()}.webm`,{type:"audio/webm"});a.value=Q,u.value=URL.createObjectURL(H),P.value&&(P.value.getTracks().forEach(oe=>oe.stop()),P.value=null),await $e(),await te(H)},w.value=O,x.value=S,h.value=!0,E.value=0,L.value=window.setInterval(()=>{E.value++},1e3),O.start()}catch(C){console.error("خطا در شروع ضبط صدا:",C),alert("دسترسی به میکروفون امکانپذیر نیست")}},$=()=>{w.value&&h.value&&(w.value.stop(),h.value=!1,L.value&&(clearInterval(L.value),L.value=null),P.value&&(P.value.getTracks().forEach(C=>C.stop()),P.value=null),p.value&&p.value.isPlaying()&&(p.value.pause(),f.value=!1))},Y=C=>{const O=Math.floor(C/60),S=C%60;return console.log("mins2",O,parseInt(S)),`${O}:${parseInt(S)}`},se=()=>{p.value&&p.value.playPause()},ne=()=>v.value||0,I=C=>{if(!C||isNaN(C))return"0:00";const O=Math.floor(C/60),S=Math.floor(C%60);return console.log("mins",O,S),`${O}:${S}`},te=async C=>{if(!d.value)return;p.value&&(p.value.destroy(),p.value=null);const O=URL.createObjectURL(C),S=Te.create({container:d.value,height:50,normalize:!0,waveColor:"#94a3b8",progressColor:"#2563eb",cursorColor:"#ef4444",barWidth:3,barGap:2,barRadius:4,interact:!0,dragToSeek:!0,fillParent:!0,autoCenter:!0});S.load(O),S.on("ready",()=>{j.value=S.getDuration()}),S.on("timeupdate",H=>{v.value=H}),S.on("play",()=>{f.value=!0}),S.on("pause",()=>{f.value=!1}),S.on("finish",()=>{f.value=!1,v.value=0}),p.value=S};Se(a,async C=>{if(C&&V(C)&&u.value){await $e();const O=await fetch(u.value).then(S=>S.blob());await te(O)}});const K=async C=>{const S=C.target.files?.[0];S&&(a.value=S,G(S)?u.value=URL.createObjectURL(S):V(S)&&(u.value=URL.createObjectURL(S),await $e(),await te(S)),o.value&&(o.value.value=""))},ae=()=>{u.value&&(URL.revokeObjectURL(u.value),u.value=""),a.value=null,j.value=0,p.value&&(p.value.destroy(),p.value=null),f.value=!1,h.value&&$()},ge=(C,O=20)=>{if(C.length<=O)return C;const S=C.split(".").pop();return`${C.substring(0,C.lastIndexOf(".")).substring(0,O-S.length-4)+"..."}.${S}`};return(C,O)=>{const S=Sn,H=mi,Q=gi;return A(),le(Q,null,{default:rt(()=>[y("div",lr,[y("div",{class:ie(["sticky top-0 w-inherit right-0 left-0 z-1000",re(t).isNightStore?"bg-black":"bg-white"])},[y("div",ur,[y("div",cr,[_(ve,{icon:re(t).isRTL?"vuesax-linear:arrow-right":"vuesax-linear:arrow-left",onClick:O[0]||(O[0]=oe=>re(e).back())},null,8,["icon"]),l.value?.id?(A(),ee("div",dr,[_(bi,{width:"40",src:l.value?.avatar,justShowProfile:""},null,8,["src"]),y("div",null,[y("div",hr,ce(l.value?.name),1),y("div",pr,ce(l.value?.username),1)])])):fe("",!0)]),O[2]||(O[2]=y("div",{class:"flex w-fit gap-4 h-1.3rem items-center"},null,-1))])],2),y("div",fr,[g.value?(A(),le(S,{key:0})):fe("",!0),g.value?(A(),le(S,{key:1})):fe("",!0),y("div",vr,[g.value?(A(),le(S,{key:0})):(A(),le(or,{key:1,ref_key:"conversation",ref:s,chatId:M.value?.chat_id},null,8,["chatId"]))]),y("div",{class:ie(["sticky bottom-0 w-inherit right-0 left-0 p-3",re(t).isNightStore?"bg-black":"bg-white"])},[y("div",{class:ie(["flex items-center gap-5 rounded-full px-2 relative",re(t).isNightStore?"bg-gray-700":"bg-gray-100"])},[a.value?(A(),ee("div",{key:0,class:ie(["fixed bottom-18 left-0 right-0 px-3",re(t).isNightStore?"bg-black":"bg-white"])},[y("div",{class:ie(["flex items-center gap-3 p-2 rounded-lg",re(t).isNightStore?"bg-gray-800":"bg-gray-200"])},[G(a.value)?(A(),ee("div",mr,[y("img",{src:u.value,alt:a.value.name,class:"w-16 h-16 object-cover rounded-lg"},null,8,gr),y("button",{onClick:ae,class:"absolute -top-1 -right-1 w-5 h-5 bg-red-500 text-white rounded-full flex items-center justify-center text-xs"}," × ")])):V(a.value)?(A(),ee("div",br,[y("div",yr,[y("div",wr,[y("button",{onClick:se,class:"flex-shrink-0 whatsapp-play-button whatsapp-play-button-received"},[f.value?(A(),le(ve,{key:1,icon:"vuesax-linear:pause",size:24,color:"#007aff"})):(A(),le(ve,{key:0,icon:"vuesax-linear:play",size:24,color:"#007aff"}))]),y("div",Cr,[y("div",Sr,[y("span",xr,ce(I(ne())),1),y("div",_r,[y("div",Pr,[y("div",{ref_key:"waveformContainer",ref:d,class:ie(["w-40 h-12 rounded-lg",re(t).isNightStore?"bg-gray-700":""])},null,2)]),y("span",kr,ce(Y(j.value)),1)])])]),y("button",{onClick:_t(ae,["stop"]),class:"flex-shrink-0 whatsapp-download-button whatsapp-download-button-received",title:"حذف فایل"},[_(ve,{icon:"vuesax-linear:trash",size:20,color:"#007aff"})])])])])):(A(),ee("div",Mr,[O[3]||(O[3]=y("span",{class:"text-2xl"},"📎",-1)),y("span",Or,ce(ge(a.value.name)),1),y("button",{onClick:ae,class:"text-red-500 text-lg"},"×")]))],2)],2)):fe("",!0),h.value?(A(),ee("div",{key:1,class:ie(["fixed bottom-18 left-0 right-0 px-3 pb-2",re(t).isNightStore?"bg-black":"bg-white"])},[y("div",{class:ie(["flex items-center gap-3 p-2 rounded-lg",re(t).isNightStore?"bg-gray-800":"bg-gray-200"])},[y("div",Er,[O[4]||(O[4]=y("div",{class:"w-3 h-3 bg-red-500 rounded-full animate-pulse"},null,-1)),y("span",Rr,ce(Y(E.value)),1)])],2)],2)):fe("",!0),y("div",{class:ie(["fixed bottom-0 w-inherit right--1 left--1 sm:absolute sm:w-full p-3",re(t).isNightStore?"bg-black":"bg-white"])},[y("div",{class:ie(["flex items-center gap-2 rounded-full px-2",re(t).isNightStore?"bg-gray-700":"bg-gray-100"])},[y("input",{ref_key:"fileInput",ref:o,type:"file",class:"hidden",onChange:K,accept:"image/*,audio/*,video/*,.pdf,.doc,.docx,.txt"},null,544),y("div",Tr,[!a.value&&!k.value&&!h.value?(A(),le(ve,{key:0,icon:"vuesax-linear:microphone-2",onClick:F,class:"cursor-pointer"})):fe("",!0),!a.value&&!k.value&&!h.value?(A(),le(ve,{key:1,icon:"vuesax-linear:add-circle",onClick:D,class:"cursor-pointer"})):fe("",!0),h.value?(A(),ee("button",{key:2,onClick:$,class:"w-8 h-8 rounded-full bg-red-500 flex items-center justify-center cursor-pointer"},O[5]||(O[5]=[y("div",{class:"w-3 h-3 bg-white rounded"},null,-1)]))):fe("",!0)]),_(yi,{value:r.value,"onUpdate:value":O[1]||(O[1]=oe=>r.value=oe),"place-holder":`${re(t).useString("message")}...`,class:"!rounded-full border-transparent !bg-transparent message-placeholder !py-3 flex-1",rows:1},null,8,["value","place-holder"]),_(hi,{name:"fade",mode:"out-in"},{default:rt(()=>[r.value.length||a.value?(A(),ee("div",{key:0,class:ie(["w-4rem h-2rem bg-#733af9 flex items-center rounded-full p-1 pt-2 text-white justify-center cursor-pointer",{"bg-gray-500":k.value}]),onClick:B},[k.value?(A(),le(H,{key:1,class:"!text-white",type:"spinner",size:"20px"})):(A(),ee("img",{key:0,src:xn,alt:re(t).appName?.value?.en||"",class:"h-full rtl:-scale-x-100"},null,8,Lr))],2)):fe("",!0)]),_:1})],2)],2)],2)],2)])])]),_:1})}}}),$r=Ot(Dr,[["__scopeId","data-v-39d83653"]]),ss=pe({__name:"detail_message",setup(n){return(e,t)=>(A(),le($r))}});export{ss as default};
|