voiptime-components 1.21.151 → 1.21.152

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -71,4 +71,4 @@
71
71
  <div class="cursor" part="cursor"></div>
72
72
  </div>
73
73
  </div>
74
- `,[t,i]}setOptions(t){var i;if(this.options.container!==t.container){const n=this.parentFromOptionsContainer(t.container);n.appendChild(this.container),this.parent=n}t.dragToSeek===!0||typeof this.options.dragToSeek=="object"?this.initDrag():((i=this.dragStream)===null||i===void 0||i.cleanup(),this.dragStream=null),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth-this.containerInlinePadding}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:i}=this.scrollContainer,n=i*t;this.setScroll(n)}destroy(){var t;this.subscriptions.forEach(i=>i()),this.container.remove(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),(t=this.unsubscribeOnScroll)===null||t===void 0||t.forEach(i=>i()),this.unsubscribeOnScroll=[],this.dragStream&&(this.dragStream.cleanup(),this.dragStream=null),this.scrollStream&&(this.scrollStream.cleanup(),this.scrollStream=null)}createDelay(t=10){let i,n;const o=()=>{i&&(clearTimeout(i),i=void 0),n&&(n(),n=void 0)};return this.timeouts.push(o),()=>new Promise((s,r)=>{o(),n=r,i=setTimeout(()=>{i=void 0,n=void 0,s()},t)})}getHeight(t,i){var n;const o=((n=this.audioData)===null||n===void 0?void 0:n.numberOfChannels)||1;return function({optionsHeight:s,optionsSplitChannels:r,parentHeight:a,numberOfChannels:u,defaultHeight:d=128}){if(s==null)return d;const h=Number(s);if(!isNaN(h))return h;if(s==="auto"){const b=a||d;return r!=null&&r.every(Z=>!Z.overlay)?b/u:b}return d}({optionsHeight:t,optionsSplitChannels:i,parentHeight:this.parent.clientHeight,numberOfChannels:o,defaultHeight:128})}convertColorValues(t,i){return function(n,o,s){if(!Array.isArray(n))return n||"";if(n.length===0)return"#999";if(n.length<2)return n[0]||"";const r=document.createElement("canvas"),a=r.getContext("2d"),u=s??r.height*o,d=a.createLinearGradient(0,0,0,u||o),h=1/(n.length-1);return n.forEach((b,Z)=>{d.addColorStop(Z*h,b)}),d}(t,this.getPixelRatio(),i==null?void 0:i.canvas.height)}getPixelRatio(){return t=window.devicePixelRatio,Math.max(1,t||1);var t}renderBarWaveform(t,i,n,o){const{width:s,height:r}=n.canvas,{halfHeight:a,barWidth:u,barRadius:d,barIndexScale:h,barSpacing:b,barMinHeight:Z}=function({width:I,height:V,length:m,options:j,pixelRatio:X}){const Y=V/2,x=j.barWidth?j.barWidth*X:1,G=j.barGap?j.barGap*X:j.barWidth?x/2:0,L=x+G||1;return{halfHeight:Y,barWidth:x,barGap:G,barRadius:j.barRadius||0,barMinHeight:j.barMinHeight?j.barMinHeight*X:0,barIndexScale:m>0?I/L/m:0,barSpacing:L}}({width:s,height:r,length:(t[0]||[]).length,options:i,pixelRatio:this.getPixelRatio()}),y=function({channelData:I,barIndexScale:V,barSpacing:m,barWidth:j,halfHeight:X,vScale:Y,canvasHeight:x,barAlign:G,barMinHeight:L}){const p=I[0]||[],w=I[1]||p,W=p.length,S=[];let J=0,E=0,g=0;for(let f=0;f<=W;f++){const T=Math.round(f*V);if(T>J){const{topHeight:oe,totalHeight:N}=fL({maxTop:E,maxBottom:g,halfHeight:X,vScale:Y,barMinHeight:L,barAlign:G}),K=EL({barAlign:G,halfHeight:X,topHeight:oe,totalHeight:N,canvasHeight:x});S.push({x:J*m,y:K,width:j,height:N}),J=T,E=0,g=0}const U=Math.abs(p[f]||0),A=Math.abs(w[f]||0);U>E&&(E=U),A>g&&(g=A)}return S}({channelData:t,barIndexScale:h,barSpacing:b,barWidth:u,halfHeight:a,vScale:o,canvasHeight:r,barAlign:i.barAlign,barMinHeight:Z});n.beginPath();for(const I of y)d&&"roundRect"in n?n.roundRect(I.x,I.y,I.width,I.height,d):n.rect(I.x,I.y,I.width,I.height);n.fill(),n.closePath()}renderLineWaveform(t,i,n,o){const{width:s,height:r}=n.canvas,a=function({channelData:u,width:d,height:h,vScale:b}){const Z=h/2,y=u[0]||[];return[y,u[1]||y].map((I,V)=>{const m=I.length,j=m?d/m:0,X=Z,Y=V===0?-1:1,x=[{x:0,y:X}];let G=0,L=0;for(let p=0;p<=m;p++){const w=Math.round(p*j);if(w>G){const S=X+(Math.round(L*Z*b)||1)*Y;x.push({x:G,y:S}),G=w,L=0}const W=Math.abs(I[p]||0);W>L&&(L=W)}return x.push({x:G,y:X}),x})}({channelData:t,width:s,height:r,vScale:o});n.beginPath();for(const u of a)if(u.length){n.moveTo(u[0].x,u[0].y);for(let d=1;d<u.length;d++){const h=u[d];n.lineTo(h.x,h.y)}}n.fill(),n.closePath()}renderWaveform(t,i,n){if(n.fillStyle=this.convertColorValues(i.waveColor,n),i.renderFunction)return void i.renderFunction(t,n);const o=function({channelData:s,barHeight:r,normalize:a,maxPeak:u}){var d;const h=r||1;if(!a)return h;const b=s[0];if(!b||b.length===0)return h;let Z=u??0;if(!u)for(let y=0;y<b.length;y++){const I=(d=b[y])!==null&&d!==void 0?d:0,V=Math.abs(I);V>Z&&(Z=V)}return Z?h/Z:h}({channelData:t,barHeight:i.barHeight,normalize:i.normalize,maxPeak:i.maxPeak});nl(i)?this.renderBarWaveform(t,i,n,o):this.renderLineWaveform(t,i,n,o)}renderSingleCanvas(t,i,n,o,s,r,a){const u=this.getPixelRatio(),d=document.createElement("canvas");d.width=Math.round(n*u),d.height=Math.round(o*u),d.style.width=`${n}px`,d.style.height=`${o}px`,d.style.left=`${Math.round(s)}px`,r.appendChild(d);const h=d.getContext("2d");if(i.renderFunction?(h.fillStyle=this.convertColorValues(i.waveColor,h),i.renderFunction(t,h)):this.renderWaveform(t,i,h),d.width>0&&d.height>0){const b=d.cloneNode(),Z=b.getContext("2d");Z.drawImage(d,0,0),Z.globalCompositeOperation="source-in",Z.fillStyle=this.convertColorValues(i.progressColor,Z),Z.fillRect(0,0,d.width,d.height),a.appendChild(b)}}renderMultiCanvas(t,i,n,o,s,r){const a=this.getPixelRatio(),{clientWidth:u}=this.scrollContainer,d=n/a,h=function({clientWidth:I,totalWidth:V,options:m}){return ct(Math.min(8e3,I,V),m)}({clientWidth:u,totalWidth:d,options:i});let b={};if(h===0)return;const Z=I=>{if(I<0||I>=y||b[I])return;b[I]=!0;const V=I*h;let m=Math.min(d-V,h);if(m=ct(m,i),m<=0)return;const j=function({channelData:X,offset:Y,clampedWidth:x,totalWidth:G}){return X.map(L=>{const p=Math.floor(Y/G*L.length),w=Math.floor((Y+x)/G*L.length);return L.slice(p,w)})}({channelData:t,offset:V,clampedWidth:m,totalWidth:d});this.renderSingleCanvas(j,i,m,o,V,s,r)},y=Math.ceil(d/h);if(!this.isScrollable){for(let I=0;I<y;I++)Z(I);return}if(rt({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:d,numCanvases:y}).forEach(I=>Z(I)),y>1){const I=this.on("scroll",()=>{const{scrollLeft:V}=this.scrollContainer;Object.keys(b).length>10&&(s.innerHTML="",r.innerHTML="",b={}),rt({scrollLeft:V,totalWidth:d,numCanvases:y}).forEach(m=>Z(m))});this.unsubscribeOnScroll.push(I)}}renderChannel(t,i,n,o){var{overlay:s}=i,r=function(h,b){var Z={};for(var y in h)Object.prototype.hasOwnProperty.call(h,y)&&b.indexOf(y)<0&&(Z[y]=h[y]);if(h!=null&&typeof Object.getOwnPropertySymbols=="function"){var I=0;for(y=Object.getOwnPropertySymbols(h);I<y.length;I++)b.indexOf(y[I])<0&&Object.prototype.propertyIsEnumerable.call(h,y[I])&&(Z[y[I]]=h[y[I]])}return Z}(i,["overlay"]);const a=document.createElement("div"),u=this.getHeight(r.height,r.splitChannels);a.style.height=`${u}px`,s&&o>0&&(a.style.marginTop=`-${u}px`),this.canvasWrapper.style.minHeight=`${u}px`,this.canvasWrapper.appendChild(a);const d=a.cloneNode();this.progressWrapper.appendChild(d),this.renderMultiCanvas(t,r,n,u,a,d)}render(t){return Je(this,void 0,void 0,function*(){var i;this.timeouts.forEach(d=>d()),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 n=this.getPixelRatio(),o=this.scrollContainer.clientWidth-this.containerInlinePadding,{scrollWidth:s,isScrollable:r,useParentWidth:a,width:u}=function({duration:d,minPxPerSec:h=0,parentWidth:b,fillParent:Z,pixelRatio:y}){const I=Math.ceil(d*h),V=I>b,m=!!(Z&&!V);return{scrollWidth:I,isScrollable:V,useParentWidth:m,width:(m?b:I)*y}}({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:o,fillParent:this.options.fillParent,pixelRatio:n});if(this.isScrollable=r,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=t,this.emit("render"),this.options.splitChannels)for(let d=0;d<t.numberOfChannels;d++){const h=Object.assign(Object.assign({},this.options),(i=this.options.splitChannels)===null||i===void 0?void 0:i[d]);this.renderChannel([t.getChannelData(d)],h,u,d)}else{const d=[t.getChannelData(0)];t.numberOfChannels>1&&d.push(t.getChannelData(1)),this.renderChannel(d,this.options,u,0)}Promise.resolve().then(()=>this.emit("rendered"))})}reRender(){if(this.unsubscribeOnScroll.forEach(n=>n()),this.unsubscribeOnScroll=[],!this.audioData)return;const{scrollWidth:t}=this.scrollContainer,{right:i}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),!this.isScrollable&&this.scrollContainer.scrollLeft)this.scrollContainer.scrollLeft=0;else if(this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:n}=this.progressWrapper.getBoundingClientRect(),o=function(s){const r=2*s;return(r<0?Math.floor(r):Math.ceil(r))/2}(n-i);this.scrollContainer.scrollLeft+=o}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,i=!1){var n;const{scrollLeft:o,scrollWidth:s,clientWidth:r}=this.scrollContainer,a=t*s,u=o,d=o+r,h=r/2;if(this.isDragging)a+30>d?this.scrollContainer.scrollLeft+=30:a-30<u&&(this.scrollContainer.scrollLeft-=30);else{(a<u||a>d)&&(this.scrollContainer.scrollLeft=a-(this.options.autoCenter?h:0));const b=a-o-h;if(i&&this.options.autoCenter&&b>0){const Z=(n=this.audioData)===null||n===void 0?void 0:n.duration;if(Z===void 0||Z<=0)return void(this.scrollContainer.scrollLeft+=b);const y=s/Z;this.scrollContainer.scrollLeft+=y<=600?Math.min(b,10):b}}}renderProgress(t,i){if(isNaN(t))return;const n=100*t;this.canvasWrapper.style.clipPath=`polygon(${n}% 0%, 100% 0%, 100% 100%, ${n}% 100%)`,this.progressWrapper.style.width=`${n}%`,this.cursor.style.left=`${n}%`,this.cursor.style.transform=this.options.cursorWidth?`translateX(-${t*this.options.cursorWidth}px)`:"",this.isScrollable&&this.options.autoScroll&&this.audioData&&this.audioData.duration>0&&this.scrollIntoView(t,i)}exportImage(t,i,n){return Je(this,void 0,void 0,function*(){const o=this.canvasWrapper.querySelectorAll("canvas");if(!o.length)throw new Error("No waveform data");if(n==="dataURL"){const s=Array.from(o).map(r=>r.toDataURL(t,i));return Promise.resolve(s)}return Promise.all(Array.from(o).map(s=>new Promise((r,a)=>{s.toBlob(u=>{u?r(u):a(new Error("Could not export image"))},t,i)})))})}}class FL extends C1{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;const t=()=>{this.isRunning&&(this.emit("tick"),this.animationFrameId=requestAnimationFrame(t))};t()}stop(){this.isRunning=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop()}}class G1 extends C1{constructor(t){super(),this.bufferNode=null,this.playStartTime=0,this.playbackPosition=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,function(){const i=globalThis.navigator;if(i!=null&&i.audioSession)try{i.audioSession.type="playback"}catch(n){console.warn("Setting navigator.audioSession.type failed:",n)}}(),this.audioContext=t||new AudioContext,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return Je(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(t){if(this.currentSrc=t,this._duration=void 0,!t)return this.buffer=null,void this.emit("emptied");fetch(t).then(i=>{if(i.status>=400)throw new Error(`Failed to fetch ${t}: ${i.status} (${i.statusText})`);return i.arrayBuffer()}).then(i=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(i)).then(i=>{this.currentSrc===t&&(this.buffer=i,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())}).catch(i=>{console.error("WebAudioPlayer load error:",i)})}_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 t=this.playbackPosition;(t>=this.duration||t<0)&&(t=0,this.playbackPosition=0),this.bufferNode.start(this.audioContext.currentTime,t),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{!this.paused&&this.duration-this.currentTime<.01&&(this.pause(),this.emit("ended"))}}_pause(){var t;this.paused=!0,(t=this.bufferNode)===null||t===void 0||t.stop(),this.playbackPosition+=(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}play(){return Je(this,void 0,void 0,function*(){this.paused&&(this._play(),this.emit("play"))})}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){const i=t-this.currentTime,n=this.bufferNode;n==null||n.stop(this.audioContext.currentTime+i),n==null||n.addEventListener("ended",()=>{n===this.bufferNode&&(this.bufferNode=null,this.pause())},{once:!0})}setSinkId(t){return Je(this,void 0,void 0,function*(){return this.audioContext.setSinkId(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){const i=!this.paused;i&&this._pause(),this._playbackRate=t,i&&this._play(),this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return this.paused?this.playbackPosition:this.playbackPosition+(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}set currentTime(t){const i=!this.paused;i&&this._pause(),this.playbackPosition=t,i&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,i;return(t=this._duration)!==null&&t!==void 0?t:((i=this.buffer)===null||i===void 0?void 0:i.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t,this.emit("volumechange")}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const i=this.buffer.numberOfChannels;for(let n=0;n<i;n++)t.push(this.buffer.getChannelData(n));return t}removeAttribute(t){switch(t){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 jL={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class b1 extends vL{static create(t){return new b1(t)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(t){const i=t.media||(t.backend==="WebAudio"?new G1:void 0);super({media:i,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate}),this.plugins=[],this.decodedData=null,this.stopAtPosition=null,this.subscriptions=[],this.mediaSubscriptions=[],this.abortController=null,this.reactiveCleanups=[],this.options=Object.assign({},jL,t);const{state:n,actions:o}=function(a){var u,d,h,b,Z,y;const I=(u=a==null?void 0:a.currentTime)!==null&&u!==void 0?u:ge(0),V=(d=a==null?void 0:a.duration)!==null&&d!==void 0?d:ge(0),m=(h=a==null?void 0:a.isPlaying)!==null&&h!==void 0?h:ge(!1),j=(b=a==null?void 0:a.isSeeking)!==null&&b!==void 0?b:ge(!1),X=(Z=a==null?void 0:a.volume)!==null&&Z!==void 0?Z:ge(1),Y=(y=a==null?void 0:a.playbackRate)!==null&&y!==void 0?y:ge(1),x=ge(null),G=ge(null),L=ge(""),p=ge(0),w=ge(0),W=o1(()=>!m.value,[m]),S=o1(()=>x.value!==null,[x]),J=o1(()=>S.value&&V.value>0,[S,V]),E=o1(()=>I.value,[I]),g=o1(()=>V.value>0?I.value/V.value:0,[I,V]);return{state:{currentTime:I,duration:V,isPlaying:m,isPaused:W,isSeeking:j,volume:X,playbackRate:Y,audioBuffer:x,peaks:G,url:L,zoom:p,scrollPosition:w,canPlay:S,isReady:J,progress:E,progressPercent:g},actions:{setCurrentTime:f=>{const T=Math.max(0,Math.min(V.value||1/0,f));I.set(T)},setDuration:f=>{V.set(Math.max(0,f))},setPlaying:f=>{m.set(f)},setSeeking:f=>{j.set(f)},setVolume:f=>{const T=Math.max(0,Math.min(1,f));X.set(T)},setPlaybackRate:f=>{const T=Math.max(.1,Math.min(16,f));Y.set(T)},setAudioBuffer:f=>{x.set(f),f&&V.set(f.duration)},setPeaks:f=>{G.set(f)},setUrl:f=>{L.set(f)},setZoom:f=>{p.set(Math.max(0,f))},setScrollPosition:f=>{w.set(Math.max(0,f))}}}}({isPlaying:this.isPlayingSignal,currentTime:this.currentTimeSignal,duration:this.durationSignal,volume:this.volumeSignal,playbackRate:this.playbackRateSignal,isSeeking:this.seekingSignal});this.wavesurferState=n,this.wavesurferActions=o,this.timer=new FL;const s=i?void 0:this.getMediaElement();this.renderer=new KL(this.options,s),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initReactiveState(),this.initPlugins();const r=this.options.url||this.getSrc()||"";Promise.resolve().then(()=>{this.emit("init");const{peaks:a,duration:u}=this.options;(r||a&&u)&&this.load(r,a,u).catch(d=>{this.emit("error",d instanceof Error?d:new Error(String(d)))})})}updateProgress(t=this.getCurrentTime()){return this.renderer.renderProgress(t/this.getDuration(),this.isPlaying()),t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t),this.stopAtPosition!=null&&this.isPlaying()&&t>=this.stopAtPosition&&this.pause()}}))}initReactiveState(){this.reactiveCleanups.push(function(t,i){const n=[];n.push(t1(()=>{const r=t.isPlaying.value;i.emit(r?"play":"pause")},[t.isPlaying])),n.push(t1(()=>{const r=t.currentTime.value;i.emit("timeupdate",r),t.isPlaying.value&&i.emit("audioprocess",r)},[t.currentTime,t.isPlaying])),n.push(t1(()=>{t.isSeeking.value&&i.emit("seeking",t.currentTime.value)},[t.isSeeking,t.currentTime]));let o=!1;n.push(t1(()=>{t.isReady.value&&!o&&(o=!0,i.emit("ready",t.duration.value))},[t.isReady,t.duration]));let s=!1;return n.push(t1(()=>{const r=t.isPlaying.value,a=t.currentTime.value,u=t.duration.value,d=u>0&&a>=u;s&&!r&&d&&i.emit("finish"),s=r&&d},[t.isPlaying,t.currentTime,t.duration])),n.push(t1(()=>{const r=t.zoom.value;r>0&&i.emit("zoom",r)},[t.zoom])),()=>{n.forEach(r=>r())}}(this.wavesurferState,{emit:this.emit.bind(this)}))}initPlayerEvents(){this.isPlaying()&&(this.emit("play"),this.timer.start()),this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",()=>{const t=this.updateProgress();this.emit("timeupdate",t)}),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 t;this.emit("error",(t=this.getMediaElement().error)!==null&&t!==void 0?t:new Error("Media error")),this.stopAtPosition=null}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(t,i)=>{this.options.interact&&(this.seekTo(t),this.emit("interaction",t*this.getDuration()),this.emit("click",t,i))}),this.renderer.on("dblclick",(t,i)=>{this.emit("dblclick",t,i)}),this.renderer.on("scroll",(t,i,n,o)=>{const s=this.getDuration();this.emit("scroll",t*s,i*s,n,o)}),this.renderer.on("render",()=>{this.emit("redraw")}),this.renderer.on("rendered",()=>{this.emit("redrawcomplete")}),this.renderer.on("dragstart",t=>{this.emit("dragstart",t)}),this.renderer.on("dragend",t=>{this.emit("dragend",t)}),this.renderer.on("resize",()=>{this.emit("resize")}));{let t;const i=this.renderer.on("drag",n=>{var o;if(!this.options.interact)return;this.renderer.renderProgress(n),clearTimeout(t);let s=0;const r=this.options.dragToSeek;this.isPlaying()?s=0:r===!0?s=200:r&&typeof r=="object"&&(s=(o=r.debounceTime)!==null&&o!==void 0?o:200),t=setTimeout(()=>{this.seekTo(n)},s),this.emit("interaction",n*this.getDuration()),this.emit("drag",n)});this.subscriptions.push(()=>{clearTimeout(t),i()})}}initPlugins(){var t;!((t=this.options.plugins)===null||t===void 0)&&t.length&&this.options.plugins.forEach(i=>{this.registerPlugin(i)})}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach(t=>t()),this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t),t.duration&&!t.peaks&&(this.decodedData=S1.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=S1.createBuffer(t.peaks,t.duration)),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),t.mediaControls!=null&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){if(this.plugins.includes(t))return t;t._init(this),this.plugins.push(t);const i=t.once("destroy",()=>{this.plugins=this.plugins.filter(n=>n!==t),this.subscriptions=this.subscriptions.filter(n=>n!==i)});return this.subscriptions.push(i),t}unregisterPlugin(t){this.plugins=this.plugins.filter(i=>i!==t),t.destroy()}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const i=t/this.getDuration();this.renderer.setScrollPercentage(i)}getActivePlugins(){return this.plugins}loadAudio(t,i,n,o){return Je(this,void 0,void 0,function*(){var s;if(this.emit("load",t),!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,!i&&!n){const a=this.options.fetchParams||{};window.AbortController&&!a.signal&&(this.abortController=new AbortController,a.signal=this.abortController.signal);const u=h=>this.emit("loading",h);i=yield gL.fetchBlob(t,u,a);const d=this.options.blobMimeType;d&&(i=new Blob([i],{type:d}))}this.setSrc(t,i);const r=yield new Promise(a=>{const u=o||this.getDuration();u?a(u):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>a(this.getDuration()),{once:!0}))});if(!t&&!i){const a=this.getMediaElement();a instanceof G1&&(a.duration=r)}if(n)this.decodedData=S1.createBuffer(n,r||0);else if(i){const a=yield i.arrayBuffer();this.decodedData=yield S1.decode(a,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())})}load(t,i,n){return Je(this,void 0,void 0,function*(){try{return yield this.loadAudio(t,void 0,i,n)}catch(o){throw this.emit("error",o),o}})}loadBlob(t,i,n){return Je(this,void 0,void 0,function*(){try{return yield this.loadAudio("",t,i,n)}catch(o){throw this.emit("error",o),o}})}zoom(t){if(!this.decodedData)throw new Error("No audio loaded");this.renderer.zoom(t),this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:i=8e3,precision:n=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const o=Math.min(t,this.decodedData.numberOfChannels),s=[];for(let r=0;r<o;r++){const a=this.decodedData.getChannelData(r),u=[],d=a.length/i;for(let h=0;h<i;h++){const b=a.slice(Math.floor(h*d),Math.ceil((h+1)*d));let Z=0;for(let y=0;y<b.length;y++){const I=b[y];Math.abs(I)>Math.abs(Z)&&(Z=I)}u.push(Math.round(Z*n)/n)}s.push(u)}return s}getDuration(){let t=super.getDuration()||0;return t!==0&&t!==1/0||!this.decodedData||(t=this.decodedData.duration),t}toggleInteraction(t){this.options.interact=t}setTime(t){this.stopAtPosition=null,super.setTime(t),this.updateProgress(t),this.emit("timeupdate",t)}seekTo(t){const i=this.getDuration()*t;this.setTime(i)}play(t,i){const n=Object.create(null,{play:{get:()=>super.play}});return Je(this,void 0,void 0,function*(){t!=null&&this.setTime(t);const o=yield n.play.call(this);return i!=null&&(this.media instanceof G1?this.media.stopAt(i):this.stopAtPosition=i),o})}playPause(){return Je(this,void 0,void 0,function*(){return this.isPlaying()?this.pause():this.play()})}stop(){this.pause(),this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents(),super.setMediaElement(t),this.initPlayerEvents()}exportImage(){return Je(this,arguments,void 0,function*(t="image/png",i=1,n="dataURL"){return this.renderer.exportImage(t,i,n)})}destroy(){var t;this.emit("destroy"),(t=this.abortController)===null||t===void 0||t.abort(),this.plugins.forEach(i=>i.destroy()),this.subscriptions.forEach(i=>i()),this.unsubscribePlayerEvents(),this.reactiveCleanups.forEach(i=>i()),this.reactiveCleanups=[],this.timer.destroy(),this.renderer.destroy(),super.destroy()}}b1.BasePlugin=class extends C1{constructor(l){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=l}onInit(){}_init(l){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=l,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(l=>l()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}},b1.dom=xL;class RL{constructor(){this.listeners={}}on(t,i,n){if(this.listeners[t]||(this.listeners[t]=new Set),n==null?void 0:n.once){const o=(...s)=>{this.un(t,o),i(...s)};return this.listeners[t].add(o),()=>this.un(t,o)}return this.listeners[t].add(i),()=>this.un(t,i)}un(t,i){var n;(n=this.listeners[t])===null||n===void 0||n.delete(i)}once(t,i){return this.on(t,i,{once:!0})}unAll(){this.listeners={}}emit(t,...i){this.listeners[t]&&this.listeners[t].forEach(n=>n(...i))}}class UL extends RL{constructor(t){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=t}onInit(){}_init(t){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}}function cl(l,t){const i=t.xmlns?document.createElementNS(t.xmlns,l):document.createElement(l);for(const[n,o]of Object.entries(t))if(n==="children"&&o)for(const[s,r]of Object.entries(o))r instanceof Node?i.appendChild(r):typeof r=="string"?i.appendChild(document.createTextNode(r)):i.appendChild(cl(s,r));else n==="style"?Object.assign(i.style,o):n==="textContent"?i.textContent=o:i.setAttribute(n,o.toString());return i}function x1(l,t,i){return cl(l,t||{})}const zL={height:20,timeOffset:0,formatTimeCallback:l=>l/60>1?`${Math.floor(l/60)}:${`${(l=Math.round(l%60))<10?"0":""}${l}`}`:`${Math.round(1e3*l)/1e3}`};class O1 extends UL{constructor(t){super(t||{}),this.notchElements=new Map,this.currentTimeline=null,this.options=Object.assign({},zL,t),this.timelineWrapper=this.initTimelineWrapper()}static create(t){return new O1(t)}onInit(){var t;if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");let i=this.wavesurfer.getWrapper();if(this.options.container instanceof HTMLElement)i=this.options.container;else if(typeof this.options.container=="string"){const o=document.querySelector(this.options.container);if(!o)throw Error(`No Timeline container found matching ${this.options.container}`);i=o}this.options.insertPosition?(i.firstElementChild||i).insertAdjacentElement(this.options.insertPosition,this.timelineWrapper):i.appendChild(this.timelineWrapper);const n=this.wavesurfer.getState();this.subscriptions.push(function(o,s){let r;const a=()=>{r&&(r(),r=void 0),r=o()},u=s.map(d=>d.subscribe(a));return a(),()=>{r&&(r(),r=void 0),u.forEach(d=>d())}}(()=>{(n.duration.value>0||this.options.duration)&&this.initTimeline()},[n.duration])),this.subscriptions.push(this.wavesurfer.on("redraw",()=>this.initTimeline())),this.subscriptions.push(this.wavesurfer.on("scroll",(o,s,r,a)=>{this.currentTimeline&&this.updateVisibleNotches(r,a,this.currentTimeline)})),(!((t=this.wavesurfer)===null||t===void 0)&&t.getDuration()||this.options.duration)&&this.initTimeline()}destroy(){this.timelineWrapper.remove(),super.destroy()}initTimelineWrapper(){return x1("div",{part:"timeline-wrapper",style:{pointerEvents:"none"}})}defaultTimeInterval(t){return t>=25?1:5*t>=25?5:15*t>=25?15:60*Math.ceil(.5/t)}defaultPrimaryLabelInterval(t){return t>=25?10:5*t>=25?6:4}defaultSecondaryLabelInterval(t){return t>=25?5:2}virtualAppend(t,i,n){if(this.notchElements.set(n,{start:t,width:n.clientWidth,wasVisible:!1}),!this.wavesurfer)return;const o=this.wavesurfer.getScroll(),s=o+this.wavesurfer.getWidth(),r=this.notchElements.get(n),a=t>=o&&t+r.width<s;r.wasVisible=a,a&&i.appendChild(n)}updateVisibleNotches(t,i,n){this.notchElements.forEach((o,s)=>{const r=o.start>=t&&o.start+o.width<i;r!==o.wasVisible&&(o.wasVisible=r,r?n.appendChild(s):s.remove())})}initTimeline(){var t,i,n,o,s,r,a,u;this.notchElements.clear();const d=(n=(i=(t=this.wavesurfer)===null||t===void 0?void 0:t.getDuration())!==null&&i!==void 0?i:this.options.duration)!==null&&n!==void 0?n:0,h=(((o=this.wavesurfer)===null||o===void 0?void 0:o.getWrapper().scrollWidth)||this.timelineWrapper.scrollWidth)/d,b=(s=this.options.timeInterval)!==null&&s!==void 0?s:this.defaultTimeInterval(h),Z=(r=this.options.primaryLabelInterval)!==null&&r!==void 0?r:this.defaultPrimaryLabelInterval(h),y=this.options.primaryLabelSpacing,I=(a=this.options.secondaryLabelInterval)!==null&&a!==void 0?a:this.defaultSecondaryLabelInterval(h),V=this.options.secondaryLabelSpacing,m=this.options.insertPosition==="beforebegin",j=x1("div",{style:Object.assign({height:`${this.options.height}px`,overflow:"hidden",fontSize:this.options.height/2+"px",whiteSpace:"nowrap"},m?{position:"absolute",top:"0",left:"0",right:"0",zIndex:"2"}:{position:"relative"})});j.setAttribute("part","timeline"),typeof this.options.style=="string"?j.setAttribute("style",j.getAttribute("style")+this.options.style):typeof this.options.style=="object"&&Object.assign(j.style,this.options.style);const X=x1("div",{style:{width:"0",height:"50%",display:"flex",flexDirection:"column",justifyContent:m?"flex-start":"flex-end",top:m?"0":"auto",bottom:m?"auto":"0",overflow:"visible",borderLeft:"1px solid currentColor",opacity:`${(u=this.options.secondaryLabelOpacity)!==null&&u!==void 0?u:.25}`,position:"absolute",zIndex:"1"}});for(let Y=0,x=0;Y<d;Y+=b,x++){const G=X.cloneNode(),L=Math.round(100*Y)%Math.round(100*Z)==0||y&&x%y==0,p=Math.round(100*Y)%Math.round(100*I)==0||V&&x%V==0;(L||p)&&(G.style.height="100%",G.style.textIndent="3px",G.textContent=this.options.formatTimeCallback(Y),L&&(G.style.opacity="1"));const w=L?"primary":p?"secondary":"tick";G.setAttribute("part",`timeline-notch timeline-notch-${w}`);const W=(Y+this.options.timeOffset)*h;G.style.left=`${W}px`,this.virtualAppend(W,j,G)}this.timelineWrapper.innerHTML="",this.timelineWrapper.appendChild(j),this.currentTimeline=j,this.emit("ready")}}const Y1={WAVE_DEFAULT:"#D9D9D9",PROGRESS:"#F2994A"},OL={key:0,class:"vt-audio__empty"},DL={key:1},PL={class:"vt-audio__wave-area"},HL=["id"],BL={class:"vt-audio__controls"},_L=["disabled"],QL=["disabled"],AL=["disabled"],rl=e.defineComponent({__name:"VAudio",props:{recordUrl:{default:""},userA:{default:""},userB:{default:""},disabled:{type:Boolean,default:!1},type:{default:"default"}},emits:["timeUpdate","play","pause","ended","error"],setup(l,{expose:t,emit:i}){const{t:n}=Le(),o=l,s=i,r=e.computed(()=>!!(o.userA||o.userB)),a=e.ref(!1),u=e.computed(()=>o.disabled||a.value),d=e.ref(!1),h=e.ref(1),b=e.ref(`ws-${Math.random().toString(36).slice(2,9)}`),Z=e.ref(null),y=e.ref(null),I=e.ref(null),V=e.ref(null),m=e.ref(null),j=e.computed(()=>o.type==="channel-routed"),X=(T,U)=>{var q;const{width:A,height:oe}=U.canvas,N=(q=Z.value)==null?void 0:q.decodedData;if(!T.length&&!N){U.fillStyle=Y1.WAVE_DEFAULT,U.fillRect(0,oe/2,A,2);return}const K=r.value&&N&&N.numberOfChannels>=2?[N.getChannelData(0),N.getChannelData(1)]:[T[0]||new Float32Array(A).fill(0)];U.clearRect(0,0,A,oe);const z=20;K.forEach((ee,ne)=>{const ye=oe/K.length,re=ye-(r.value?z:0),se=ne*ye+(r.value?z:0)+re/2,be=ee.length/A;let Se=0;for(let he=0;he<ee.length;he+=100){const k=Math.abs(ee[he]??0);k>Se&&(Se=k)}Se===0&&(Se=1),U.fillStyle=Y1.WAVE_DEFAULT;for(let he=0;he<A;he+=2){const k=Math.floor(he*be),D=Math.min(Math.floor((he+2)*be),ee.length-1);let H=0;for(let Me=k;Me<=D;Me++){const Te=Math.abs(ee[Me]??0);Te>H&&(H=Te)}const Ze=H/Se,We=Math.max(Ze*re*.85,2);U.fillRect(he,se-We/2,1.5,We)}if(r.value){U.fillStyle="#999999",U.font="12px Inter, sans-serif",U.textAlign="right";const he=(ne===0?o.userA:o.userB)??"";U.fillText(he,A-10,ne*ye+z-5)}})},Y=()=>{var N;const T=(N=Z.value)==null?void 0:N.getMediaElement();if(!T)return;I.value=new(window.AudioContext||window.webkitAudioContext);const U=I.value.createMediaElementSource(T),A=I.value.createChannelSplitter(2),oe=I.value.createChannelMerger(2);V.value=I.value.createGain(),m.value=I.value.createGain(),V.value.gain.value=L.value,m.value.gain.value=p.value,U.connect(A),A.connect(V.value,0),A.connect(m.value,1),V.value.connect(oe,0,0),m.value.connect(oe,0,1),oe.connect(I.value.destination)},x=()=>{var T;(T=I.value)==null||T.close(),I.value=null,V.value=null,m.value=null},G=()=>{if(!o.recordUrl)return;a.value=!1;const T=b1.create({container:`#waveform-${b.value}`,waveColor:Y1.WAVE_DEFAULT,progressColor:Y1.PROGRESS,barWidth:2,height:j.value?36:r.value?100:50,plugins:j.value?[]:[O1.create({container:y.value,style:{fontSize:"10px",color:"#999"}})],renderFunction:(U,A)=>X(U,A)});Z.value=T,Z.value.on("play",()=>{d.value=!0,s("play")}),Z.value.on("pause",()=>{d.value=!1,s("pause")}),Z.value.on("timeupdate",U=>s("timeUpdate",U)),Z.value.on("finish",()=>{d.value=!1,s("ended")}),Z.value.on("error",()=>{a.value=!0,s("error")}),r.value&&Z.value.on("ready",()=>{Y(),S()}),Z.value.load(o.recordUrl)},L=e.ref(1),p=e.ref(1),w=T=>{const U=T===0?V.value:m.value,A=T===0?L:p;A.value=A.value?0:1,U&&(U.gain.value=A.value)},W={x:5,y:0,size:18},S=()=>{const T=document.querySelector(`#waveform-${b.value} canvas`);!T||!r.value||T.addEventListener("click",U=>{if(u.value)return;const A=T.getBoundingClientRect(),oe=U.clientX-A.left,N=U.clientY-A.top,K=A.height/2;[0,1].forEach(z=>{const q=z*K+W.y;oe>=W.x&&oe<=W.x+W.size&&N>=q&&N<=q+W.size&&(U.stopPropagation(),U.preventDefault(),w(z))})})},J=async()=>{if(!(!Z.value||u.value)){if(j.value){const T=Z.value.getMediaElement();if(!T||!I.value)return;I.value.state==="suspended"&&await I.value.resume(),T.paused?await T.play():T.pause();return}d.value?Z.value.pause():Z.value.play()}},E=T=>{var U;h.value=T,(U=Z.value)==null||U.setPlaybackRate(h.value)},g=(T,U)=>{if(T.startsWith("data:")){const oe=document.createElement("a");oe.href=T,oe.download=U,document.body.appendChild(oe),oe.click(),document.body.removeChild(oe)}else fetch(T).then(oe=>oe.blob()).then(oe=>{const N=document.createElement("a");N.href=URL.createObjectURL(oe),N.download=U,document.body.appendChild(N),N.click(),document.body.removeChild(N)}).catch(console.error)},f=()=>{if(o.disabled||!o.recordUrl)return;const T=o.recordUrl.indexOf("?"),U=o.recordUrl.substring(o.recordUrl.lastIndexOf("/")+1,T===-1?void 0:T);g(o.recordUrl,U)};return e.onMounted(()=>e.nextTick(G)),e.onBeforeUnmount(()=>{var T;(T=Z.value)==null||T.destroy(),x()}),e.watch(()=>o.recordUrl,()=>{var T;(T=Z.value)==null||T.destroy(),x(),e.nextTick(G)}),t({play:()=>{var T;return(T=Z.value)==null?void 0:T.play()},pause:()=>{var T;return(T=Z.value)==null?void 0:T.pause()},getCurrentTime:()=>{var T;return((T=Z.value)==null?void 0:T.getCurrentTime())||0}}),(T,U)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vt-audio",{"is-disabled":u.value,"is-channel-routed":j.value}])},[l.recordUrl?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["vt-audio__container",{"is-single-channel":!r.value,"is-channel-routed":j.value}])},[e.createElementVNode("div",PL,[e.createElementVNode("div",{id:`waveform-${b.value}`,class:"vt-audio__waveform"},null,8,HL),j.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"timelineContainer",ref:y,class:"vt-audio__timeline"},null,512))]),e.createElementVNode("div",BL,[j.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("button",{class:"vt-audio__btn",disabled:u.value,onClick:f},[e.createVNode(ue,{name:"import",width:"20",height:"20"})],8,_L),e.createVNode(n1,{trigger:"click",placement:"top",disabled:u.value,onCommand:E},{dropdown:e.withCtx(()=>[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList([1,1.5,2],A=>e.createVNode(s1,{key:A,command:A,class:e.normalizeClass({"is-active":h.value===A})},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(A)+"x ",1)]),_:2},1032,["command","class"])),64))]),default:e.withCtx(()=>[e.createElementVNode("button",{class:"vt-audio__speed-val",disabled:u.value},e.toDisplayString(h.value)+"x",9,QL)]),_:1},8,["disabled"])],64)),e.createElementVNode("button",{class:"vt-audio__btn vt-audio__btn--main",disabled:u.value,onClick:J},[d.value?e.renderSlot(T.$slots,"icon-pause",{key:0},()=>[e.createVNode(ue,{name:"pause",width:"24",height:"24"})]):e.renderSlot(T.$slots,"icon-play",{key:1},()=>[e.createVNode(ue,{name:"start",width:"24",height:"24"})])],8,AL)])],2)):(e.openBlock(),e.createElementBlock("div",OL,[e.renderSlot(T.$slots,"empty",{},()=>[j.value?(e.openBlock(),e.createElementBlock("span",DL,e.toDisplayString(e.unref(n)(e.unref(c).AUDIO_EMPTY)),1)):(e.openBlock(),e.createBlock(T1,{key:0,icon:"noSound",text:e.unref(n)(e.unref(c).AUDIO_EMPTY)},null,8,["text"]))])]))],2))}}),$L=new Set(["p","div","br","hr","h1","h2","h3","h4","h5","h6","blockquote","pre","code","ul","ol","li","b","strong","i","em","u","s","strike","del","sub","sup","font","span","a","img","table","thead","tbody","tfoot","tr","th","td","caption"]),qL=new Set(["style","class","href","target","rel","src","alt","width","height","face","size","color","colspan","rowspan"]),eW=new Set(["behavior","-moz-binding","filter"]),tW=/expression\s*\(|javascript\s*:|vbscript\s*:/i;function lW(l){const t=document.createElement("span");t.setAttribute("style",l);const i=t.style,n=[];for(let o=0;o<i.length;o++){const s=i[o],r=i.getPropertyValue(s);eW.has(s)||tW.test(r)||/url\s*\(/i.test(r)&&!/url\s*\(\s*['"]?data:image\//i.test(r)||n.push(`${s}:${r}`)}return n.join(";")}const iW=new Set(["https:","http:","ftp:","mailto:","tel:"]);function oW(l){const t=l.trim();if(t.startsWith("/")||t.startsWith(".")||t.startsWith("#"))return!0;try{const i=new URL(t);return iW.has(i.protocol)}catch{return!/^[a-z][a-z0-9+\-.]*:/i.test(t)}}function al(l){var s,r,a;if(l.nodeType===Node.COMMENT_NODE||l.nodeType===Node.PROCESSING_INSTRUCTION_NODE){(s=l.parentNode)==null||s.removeChild(l);return}if(l.nodeType!==Node.ELEMENT_NODE)return;const t=l,i=t.tagName.toLowerCase();if(!$L.has(i)){for(;t.firstChild;)(r=t.parentNode)==null||r.insertBefore(t.firstChild,t);(a=t.parentNode)==null||a.removeChild(t);return}const n=Array.from(t.attributes);for(const u of n){const d=u.name.toLowerCase();if(d.startsWith("on")){t.removeAttribute(u.name);continue}if(!qL.has(d)){t.removeAttribute(u.name);continue}if((d==="href"||d==="src")&&!oW(u.value)){t.removeAttribute(u.name);continue}if(d==="style"){const h=lW(u.value);h?t.setAttribute("style",h):t.removeAttribute("style");continue}}i==="a"&&t.getAttribute("target")==="_blank"&&t.setAttribute("rel","noopener noreferrer");const o=Array.from(t.childNodes);for(let u=o.length-1;u>=0;u--)al(o[u])}function a1(l){if(!l)return"";const t=new DOMParser().parseFromString(l,"text/html");t.head.innerHTML="";const i=Array.from(t.body.childNodes);for(let n=i.length-1;n>=0;n--)al(i[n]);return t.body.innerHTML}function at(l){const t=document.createElement("div");return t.innerHTML=l,t.textContent??t.innerText??""}function nW(l,t){function i(d,h){l.value&&(l.value.focus(),document.execCommand(d,!1,h??""),t())}function n(d){try{return document.queryCommandState(d)}catch{return!1}}function o(d){l.value&&(l.value.focus(),document.execCommand("formatBlock",!1,d),t())}function s(d){l.value&&(l.value.focus(),document.execCommand("fontName",!1,d),t())}function r(d){l.value&&(l.value.focus(),document.execCommand("foreColor",!1,d),t())}function a(d){l.value&&(l.value.focus(),document.execCommand("hiliteColor",!1,d),t())}function u(d){const h=window.getSelection();if(!h||h.rangeCount===0)return;let b=h.anchorNode;b.nodeType===Node.TEXT_NODE&&(b=b.parentElement);const Z=b.closest(".vt-editor__content > *");if(!Z)return;const y=parseInt(Z.style.marginLeft||"0",10),I=20,V=d==="indent"?y+I:Math.max(0,y-I);Z.style.marginLeft=V?`${V}px`:"",t()}return{exec:i,isActive:n,applyBlock:o,applyFont:s,applyForeColor:r,applyBackColor:a,handleIndent:u}}function sW(){let l=null;function t(){const s=window.getSelection();s&&s.rangeCount>0&&(l=s.getRangeAt(0).cloneRange())}function i(){if(!l)return;const s=window.getSelection();s&&(s.removeAllRanges(),s.addRange(l))}function n(){l=null}function o(){return l}return{saveSelection:t,restoreSelection:i,clearSavedRange:n,getSavedRange:o}}function cW(l,t){const{saveSelection:i,restoreSelection:n,clearSavedRange:o,getSavedRange:s}=sW(),r=e.ref({visible:!1,url:"",text:"",openInNewTab:!1});function a(){var j,X;i();const I=window.getSelection(),V=(I==null?void 0:I.toString())??"",m=(X=(j=I==null?void 0:I.anchorNode)==null?void 0:j.parentElement)==null?void 0:X.closest("a");r.value={visible:!0,url:(m==null?void 0:m.getAttribute("href"))??"",text:V,openInNewTab:(m==null?void 0:m.getAttribute("target"))==="_blank"}}function u(){n();const{url:I,text:V,openInNewTab:m}=r.value;if(!I){d();return}const j=document.createElement("a");j.href=I,j.textContent=V||I,m&&j.setAttribute("target","_blank"),j.setAttribute("rel","noopener noreferrer");const X=s(),Y=window.getSelection();Y&&Y.rangeCount>0&&X?(X.deleteContents(),X.insertNode(j)):l(j.outerHTML),d(),t()}function d(){r.value={visible:!1,url:"",text:"",openInNewTab:!1},o()}const h=e.ref({visible:!1,url:"",alt:""});function b(){i(),h.value={visible:!0,url:"",alt:""}}function Z(){n();const{url:I,alt:V}=h.value;if(!I){y();return}l(`<img src="${I}" alt="${V}" style="max-width:100%;" />`),y()}function y(){h.value={visible:!1,url:"",alt:""},o()}return{linkState:r,openLinkDialog:a,confirmLink:u,cancelLink:d,imageState:h,openImageDialog:b,confirmImage:Z,cancelImage:y}}const xe={undo:"undo",redo:"redo",bold:"textBold",italic:"textItalic",underline:"textUnderline",strikethrough:"textStrikethrough",subscript:"subscript",superscript:"superscript",orderedList:"orderedList",unorderedList:"unorderedList",indent:"indent",outdent:"outdent",alignLeft:"alignLeft",alignCenter:"alignCenter",alignRight:"alignRight",alignJustify:"alignJustify",link:"link",image:"image",blockquote:"blockquote",clearFormat:"clearFormat",html:"html"},rW=[{value:"p",label:"Paragraph"},{value:"h1",label:"Heading 1"},{value:"h2",label:"Heading 2"},{value:"h3",label:"Heading 3"},{value:"h4",label:"Heading 4"}],aW=[{value:"Arial",label:"Arial"},{value:"Times New Roman",label:"Times New Roman"},{value:"Courier New",label:"Courier New"},{value:"Georgia",label:"Georgia"},{value:"Verdana",label:"Verdana"}];function dW(l,t){const{t:i}=Le(),n=e.ref(0);function o(){n.value++}function s(u){var d;return n.value,((d=u.activeCheck)==null?void 0:d.call(u))??!1}function r(u){const d=[];return u.forEach((h,b)=>{switch(b>0&&d.push({type:"separator"}),h){case"history":d.push({type:"button",id:"undo",tooltip:i(c.EDITOR_UNDO),iconName:xe.undo,action:()=>t.exec("undo")},{type:"button",id:"redo",tooltip:i(c.EDITOR_REDO),iconName:xe.redo,action:()=>t.exec("redo")});break;case"format":d.push({type:"button",id:"bold",tooltip:i(c.EDITOR_BOLD),iconName:xe.bold,action:()=>t.exec("bold"),activeCheck:()=>t.isActive("bold")},{type:"button",id:"italic",tooltip:i(c.EDITOR_ITALIC),iconName:xe.italic,action:()=>t.exec("italic"),activeCheck:()=>t.isActive("italic")},{type:"button",id:"underline",tooltip:i(c.EDITOR_UNDERLINE),iconName:xe.underline,action:()=>t.exec("underline"),activeCheck:()=>t.isActive("underline")},{type:"button",id:"strikethrough",tooltip:i(c.EDITOR_STRIKETHROUGH),iconName:xe.strikethrough,action:()=>t.exec("strikethrough"),activeCheck:()=>t.isActive("strikeThrough")});break;case"script":d.push({type:"button",id:"subscript",tooltip:i(c.EDITOR_SUBSCRIPT),iconName:xe.subscript,action:()=>t.exec("subscript"),activeCheck:()=>t.isActive("subscript")},{type:"button",id:"superscript",tooltip:i(c.EDITOR_SUPERSCRIPT),iconName:xe.superscript,action:()=>t.exec("superscript"),activeCheck:()=>t.isActive("superscript")});break;case"heading":d.push({type:"select",id:"heading"});break;case"fontName":d.push({type:"select",id:"fontName"});break;case"foreColor":d.push({type:"select",id:"foreColor"});break;case"align":d.push({type:"button",id:"alignLeft",tooltip:i(c.EDITOR_ALIGN_LEFT),iconName:xe.alignLeft,action:()=>t.exec("justifyLeft"),activeCheck:()=>t.isActive("justifyLeft")},{type:"button",id:"alignCenter",tooltip:i(c.EDITOR_ALIGN_CENTER),iconName:xe.alignCenter,action:()=>t.exec("justifyCenter"),activeCheck:()=>t.isActive("justifyCenter")},{type:"button",id:"alignRight",tooltip:i(c.EDITOR_ALIGN_RIGHT),iconName:xe.alignRight,action:()=>t.exec("justifyRight"),activeCheck:()=>t.isActive("justifyRight")},{type:"button",id:"alignJustify",tooltip:i(c.EDITOR_ALIGN_JUSTIFY),iconName:xe.alignJustify,action:()=>t.exec("justifyFull"),activeCheck:()=>t.isActive("justifyFull")});break;case"list":d.push({type:"button",id:"orderedList",tooltip:i(c.EDITOR_ORDERED_LIST),iconName:xe.orderedList,action:()=>t.exec("insertOrderedList"),activeCheck:()=>t.isActive("insertOrderedList")},{type:"button",id:"unorderedList",tooltip:i(c.EDITOR_UNORDERED_LIST),iconName:xe.unorderedList,action:()=>t.exec("insertUnorderedList"),activeCheck:()=>t.isActive("insertUnorderedList")});break;case"indent":d.push({type:"button",id:"indent",tooltip:i(c.EDITOR_INDENT),iconName:xe.indent,action:()=>t.handleIndent("indent")},{type:"button",id:"outdent",tooltip:i(c.EDITOR_OUTDENT),iconName:xe.outdent,action:()=>t.handleIndent("outdent")});break;case"link":d.push({type:"button",id:"link",tooltip:i(c.EDITOR_INSERT_LINK),iconName:xe.link,action:t.openLinkDialog});break;case"image":d.push({type:"button",id:"image",tooltip:i(c.EDITOR_INSERT_IMAGE),iconName:xe.image,action:t.openImageDialog});break;case"blockquote":d.push({type:"button",id:"blockquote",tooltip:i(c.EDITOR_BLOCKQUOTE),iconName:xe.blockquote,action:()=>t.applyBlock("blockquote")});break;case"clear":d.push({type:"button",id:"clear",tooltip:i(c.EDITOR_CLEAR_FORMAT),iconName:xe.clearFormat,action:()=>t.exec("removeFormat")});break;case"html":d.push({type:"button",id:"html",tooltip:i(c.EDITOR_HTML_SOURCE),iconName:xe.html,action:t.toggleHtmlMode,activeCheck:t.isHtmlMode});break}}),d}return{toolbarItems:e.computed(()=>r(l())),selectionTick:n,onSelectionChange:o,getItemActive:s,HEADING_GROUPS:rW,FONT_GROUPS:aW}}const mW={key:0,class:"vt-editor__toolbar-wrapper"},uW={key:0,class:"vt-editor__toolbar-sep"},hW=["value"],IW=["value"],pW=["onClick"],ZW={class:"vt-editor__body"},bW=["contenteditable","data-placeholder"],CW={key:1,class:"vt-editor__error"},yW={class:"vt-editor__dialog-fields"},VW={class:"vt-editor__dialog-label"},SW={class:"vt-editor__dialog-label"},YW={class:"vt-editor__dialog-checkbox"},LW={class:"vt-modal__footer"},WW={class:"vt-editor__dialog-fields"},kW={class:"vt-editor__dialog-label"},MW={class:"vt-editor__dialog-label"},NW={class:"vt-modal__footer"},dl=e.defineComponent({__name:"VEditor",props:{modelValue:{},placeholder:{},toolbar:{default:()=>["history","format","heading","fontName","foreColor","align","list","indent","link","image","blockquote","clear","html"]},disabled:{type:Boolean,default:!1},required:{type:Boolean},errorMessage:{}},emits:["update:modelValue","input","change","focus","blur","validation"],setup(l,{expose:t,emit:i}){const{t:n}=Le(),o=l,s=i,r=e.ref(null),a=e.ref(null),u=e.ref(null),d=e.ref(!1),h=e.ref(!1),b=e.ref(""),Z=e.ref([]),y=e.ref(!0),I=e.ref(!1),V=e.ref(!1),m=e.ref("#000000"),j=e.ref("#ffffff");function X(Q){var v;const P=Q??((v=r.value)==null?void 0:v.innerHTML)??"",me=a1(P);s("update:modelValue",me),s("input",me)}const{exec:Y,isActive:x,applyBlock:G,applyFont:L,applyForeColor:p,applyBackColor:w,handleIndent:W}=nW(r,X);function S(){if(r.value)if(!h.value)b.value=r.value.innerHTML,h.value=!0,e.nextTick(()=>{var Q;return(Q=u.value)==null?void 0:Q.focus()});else{const Q=a1(b.value);h.value=!1,e.nextTick(()=>{r.value&&(r.value.innerHTML=Q,X(Q),r.value.focus())})}}function J(){const Q=a1(b.value);s("update:modelValue",Q),s("input",Q)}const{linkState:E,openLinkDialog:g,confirmLink:f,cancelLink:T,imageState:U,openImageDialog:A,confirmImage:oe,cancelImage:N}=cW(Q=>Y("insertHTML",Q),X),{toolbarItems:K,onSelectionChange:z,getItemActive:q,HEADING_GROUPS:ee,FONT_GROUPS:ne}=dW(()=>o.toolbar,{exec:Y,isActive:x,applyBlock:G,applyFont:L,handleIndent:W,openLinkDialog:g,openImageDialog:A,toggleHtmlMode:S,isHtmlMode:()=>h.value});function ye(Q){const P=Q.target.value;m.value=P,p(P)}function re(Q){const P=Q.target.value;j.value=P,w(P)}function se(){const Q=a.value;Q&&(I.value=Q.scrollLeft>2,V.value=Q.scrollLeft+Q.clientWidth<Q.scrollWidth-2)}function be(Q){const P=a.value;P&&(P.scrollBy({left:Q==="left"?-160:160,behavior:"smooth"}),setTimeout(se,250))}function Se(Q){const P=[];o.required&&!at(Q).trim()&&P.push(n(c.VALIDATION_REQUIRED)),Z.value=P,y.value=P.length===0,s("validation",{isValid:y.value,errors:P})}const he=e.computed(()=>o.errorMessage||Z.value[0]||""),k=e.computed(()=>!!he.value),D=e.computed(()=>["vt-editor",{"vt-editor--focused":d.value,"vt-editor--error":k.value,"vt-editor--disabled":o.disabled}]);function H(){X(),Se(o.modelValue??"")}function Ze(Q){d.value=!0,s("focus",Q)}function We(Q){d.value=!1,s("blur",Q),Se(o.modelValue??"")}function Me(Q){Q.key==="Tab"&&(Q.preventDefault(),Y("insertHTML","&nbsp;&nbsp;&nbsp;&nbsp;"))}e.watch(()=>o.modelValue,Q=>{!r.value||d.value||h.value||r.value.innerHTML!==Q&&(r.value.innerHTML=Q??"")}),e.onMounted(()=>{r.value&&o.modelValue&&(r.value.innerHTML=a1(o.modelValue)),document.addEventListener("selectionchange",z),e.nextTick(()=>{se();const Q=new ResizeObserver(se);a.value&&Q.observe(a.value)}),window.addEventListener("resize",se)}),e.onBeforeUnmount(()=>{document.removeEventListener("selectionchange",z),window.removeEventListener("resize",se)});function Te(){var Q;(Q=r.value)==null||Q.focus()}function Qe(){var Q;(Q=r.value)==null||Q.blur()}function Ke(){r.value&&(r.value.innerHTML=""),X(""),Z.value=[],y.value=!0,s("validation",{isValid:!0,errors:[]})}function Ae(){var Q;return((Q=r.value)==null?void 0:Q.innerHTML)??""}function Ue(){var Q;return at(((Q=r.value)==null?void 0:Q.innerHTML)??"")}function He(Q){const P=a1(Q);r.value&&(r.value.innerHTML=P),X(P)}function je(Q){var P;(P=r.value)==null||P.focus(),Y("insertHTML",a1(Q))}function ve(){return Se(o.modelValue??""),y.value}function qe(){Z.value=[],y.value=!0,s("validation",{isValid:!0,errors:[]})}function le(){return{isValid:y.value,errors:[...Z.value]}}function ce(){return r.value}return t({focus:Te,blur:Qe,clear:Ke,getHTML:Ae,getText:Ue,setHTML:He,insertHTML:je,validate:ve,clearValidation:qe,getValidationState:le,getEditorElement:ce}),(Q,P)=>{const me=e.resolveDirective("tooltip");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(D.value)},[!l.disabled&&e.unref(K).length?(e.openBlock(),e.createElementBlock("div",mW,[I.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"vt-editor__toolbar-scroll-btn vt-editor__toolbar-scroll-btn--left",type:"button",onClick:P[0]||(P[0]=v=>be("left")),onMousedown:P[1]||(P[1]=e.withModifiers(()=>{},["prevent"]))},[e.createVNode(ue,{name:"arrowLeft"})],32)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"toolbarRef",ref:a,class:"vt-editor__toolbar",onScroll:se},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(K),(v,_)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:_},[(v==null?void 0:v.type)==="separator"?(e.openBlock(),e.createElementBlock("span",uW)):(v==null?void 0:v.type)==="select"&&v.id==="heading"?(e.openBlock(),e.createBlock(n1,{key:1,"max-height":220,class:"vt-editor__toolbar-btn",placement:"bottom-start",trigger:"hover",onMousedown:P[3]||(P[3]=e.withModifiers(()=>{},["prevent"]))},{dropdown:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(ee),M=>(e.openBlock(),e.createBlock(s1,{key:M.value,onClick:$=>e.unref(G)(M.value),onMousedown:P[2]||(P[2]=e.withModifiers(()=>{},["prevent"]))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(M.label),1)]),_:2},1032,["onClick"]))),128))]),default:e.withCtx(()=>[e.withDirectives(e.createVNode(ue,{name:"tagType"},null,512),[[me,e.unref(n)(e.unref(c).EDITOR_HEADING)]])]),_:1})):(v==null?void 0:v.type)==="select"&&v.id==="fontName"?(e.openBlock(),e.createBlock(n1,{key:2,"max-height":220,class:"vt-editor__toolbar-btn",placement:"bottom-start",trigger:"hover",onMousedown:P[5]||(P[5]=e.withModifiers(()=>{},["prevent"]))},{dropdown:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(ne),M=>(e.openBlock(),e.createBlock(s1,{key:M.value,onClick:$=>e.unref(L)(M.value),onMousedown:P[4]||(P[4]=e.withModifiers(()=>{},["prevent"]))},{default:e.withCtx(()=>[e.createElementVNode("span",{style:e.normalizeStyle({fontFamily:M.value})},e.toDisplayString(M.label),5)]),_:2},1032,["onClick"]))),128))]),default:e.withCtx(()=>[e.withDirectives(e.createVNode(ue,{name:"fontName"},null,512),[[me,e.unref(n)(e.unref(c).EDITOR_FONT)]])]),_:1})):(v==null?void 0:v.type)==="select"&&v.id==="foreColor"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.withDirectives(e.createElementVNode("input",{value:m.value,class:"vt-editor__color-picker",type:"color",onInput:ye,onMousedown:P[6]||(P[6]=e.withModifiers(()=>{},["stop"]))},null,40,hW),[[me,e.unref(n)(e.unref(c).EDITOR_FORE_COLOR)]]),e.withDirectives(e.createElementVNode("input",{value:j.value,class:"vt-editor__color-picker vt-editor__color-picker--bg",type:"color",onInput:re,onMousedown:P[7]||(P[7]=e.withModifiers(()=>{},["stop"]))},null,40,IW),[[me,e.unref(n)(e.unref(c).EDITOR_BACK_COLOR)]])],64)):(v==null?void 0:v.type)==="button"?e.withDirectives((e.openBlock(),e.createElementBlock("button",{key:4,class:e.normalizeClass([{"vt-editor__toolbar-btn--active":e.unref(q)(v)},"vt-editor__toolbar-btn"]),type:"button",onClick:M=>{var $;return($=v==null?void 0:v.action)==null?void 0:$.call(v)},onMousedown:P[8]||(P[8]=e.withModifiers(()=>{},["prevent"]))},[v!=null&&v.iconName?(e.openBlock(),e.createBlock(ue,{key:0,name:v.iconName},null,8,["name"])):e.createCommentVNode("",!0)],42,pW)),[[me,v==null?void 0:v.tooltip]]):e.createCommentVNode("",!0)],64))),128))],544),V.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:"vt-editor__toolbar-scroll-btn vt-editor__toolbar-scroll-btn--right",type:"button",onClick:P[9]||(P[9]=v=>be("right")),onMousedown:P[10]||(P[10]=e.withModifiers(()=>{},["prevent"]))},[e.createVNode(ue,{name:"arrowRight"})],32)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",ZW,[e.withDirectives(e.createElementVNode("div",{ref_key:"editorRef",ref:r,contenteditable:!l.disabled,"data-placeholder":l.placeholder,class:"vt-editor__content",onBlur:We,onFocus:Ze,onInput:H,onKeydown:Me},null,40,bW),[[e.vShow,!h.value]]),h.value?e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{key:0,ref_key:"htmlSourceRef",ref:u,"onUpdate:modelValue":P[11]||(P[11]=v=>b.value=v),class:"vt-editor__html-source",onInput:J},null,544)),[[e.vModelText,b.value]]):e.createCommentVNode("",!0)]),he.value?(e.openBlock(),e.createElementBlock("div",CW,e.toDisplayString(he.value),1)):e.createCommentVNode("",!0),e.createVNode(Z1,{modelValue:e.unref(E).visible,"onUpdate:modelValue":P[19]||(P[19]=v=>e.unref(E).visible=v),"close-on-backdrop-click":!1,title:e.unref(n)(e.unref(c).EDITOR_LINK_TITLE),size:"small",onClose:e.unref(T)},{default:e.withCtx(()=>[e.createElementVNode("div",yW,[e.createElementVNode("label",VW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_LINK_URL)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[12]||(P[12]=v=>e.unref(E).url=v),class:"vt-editor__dialog-input",placeholder:"https://example.com",type:"url",onKeydown:[P[13]||(P[13]=e.withKeys((...v)=>e.unref(f)&&e.unref(f)(...v),["enter"])),P[14]||(P[14]=e.withKeys((...v)=>e.unref(T)&&e.unref(T)(...v),["esc"]))]},null,544),[[e.vModelText,e.unref(E).url]]),e.createElementVNode("label",SW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_LINK_TEXT)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[15]||(P[15]=v=>e.unref(E).text=v),class:"vt-editor__dialog-input",placeholder:"Link text",type:"text",onKeydown:[P[16]||(P[16]=e.withKeys((...v)=>e.unref(f)&&e.unref(f)(...v),["enter"])),P[17]||(P[17]=e.withKeys((...v)=>e.unref(T)&&e.unref(T)(...v),["esc"]))]},null,544),[[e.vModelText,e.unref(E).text]]),e.createElementVNode("label",YW,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[18]||(P[18]=v=>e.unref(E).openInNewTab=v),type:"checkbox"},null,512),[[e.vModelCheckbox,e.unref(E).openInNewTab]]),e.createTextVNode(" "+e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_LINK_NEW_TAB)),1)])]),e.createElementVNode("div",LW,[e.createVNode(Ge,{onClick:e.unref(T)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).BUTTON_CANCEL)),1)]),_:1},8,["onClick"]),e.createVNode(Ge,{type:"primary",onClick:e.unref(f)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_INSERT)),1)]),_:1},8,["onClick"])])]),_:1},8,["modelValue","title","onClose"]),e.createVNode(Z1,{modelValue:e.unref(U).visible,"onUpdate:modelValue":P[26]||(P[26]=v=>e.unref(U).visible=v),"close-on-backdrop-click":!1,title:e.unref(n)(e.unref(c).EDITOR_IMAGE_TITLE),size:"small",onClose:e.unref(N)},{default:e.withCtx(()=>[e.createElementVNode("div",WW,[e.createElementVNode("label",kW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_IMAGE_URL)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[20]||(P[20]=v=>e.unref(U).url=v),class:"vt-editor__dialog-input",placeholder:"https://example.com/image.png",type:"url",onKeydown:[P[21]||(P[21]=e.withKeys((...v)=>e.unref(oe)&&e.unref(oe)(...v),["enter"])),P[22]||(P[22]=e.withKeys((...v)=>e.unref(N)&&e.unref(N)(...v),["esc"]))]},null,544),[[e.vModelText,e.unref(U).url]]),e.createElementVNode("label",MW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_IMAGE_ALT)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[23]||(P[23]=v=>e.unref(U).alt=v),class:"vt-editor__dialog-input",placeholder:"Image description",type:"text",onKeydown:[P[24]||(P[24]=e.withKeys((...v)=>e.unref(oe)&&e.unref(oe)(...v),["enter"])),P[25]||(P[25]=e.withKeys((...v)=>e.unref(N)&&e.unref(N)(...v),["esc"]))]},null,544),[[e.vModelText,e.unref(U).alt]])]),e.createElementVNode("div",NW,[e.createVNode(Ge,{onClick:e.unref(N)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).BUTTON_CANCEL)),1)]),_:1},8,["onClick"]),e.createVNode(Ge,{type:"primary",onClick:e.unref(oe)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_INSERT)),1)]),_:1},8,["onClick"])])]),_:1},8,["modelValue","title","onClose"])],2)}}}),XW={class:"vt-badge"},D1=e.defineComponent({__name:"VBadge",props:{content:{default:void 0},max:{default:99},dot:{type:Boolean,default:!1},color:{default:"danger"},position:{default:"top-end"},offsetX:{default:0},offsetY:{default:0},bordered:{type:Boolean,default:!1},hidden:{type:Boolean,default:!1}},setup(l){const t=l,i=e.computed(()=>t.dot?!0:t.content===void 0||t.content===null||t.content===""?!1:typeof t.content=="number"?t.content>0:!0),n=e.computed(()=>i.value&&!t.hidden),o=e.computed(()=>typeof t.content=="number"?t.content>t.max?`${t.max}+`:String(t.content):t.content),s=e.computed(()=>{if(!t.offsetX&&!t.offsetY)return{};const r=t.position.startsWith("top"),a=t.position.endsWith("end"),u={};return t.offsetX&&(u[a?"right":"left"]=`${-t.offsetX}px`),t.offsetY&&(u[r?"top":"bottom"]=`${-t.offsetY}px`),u});return(r,a)=>(e.openBlock(),e.createElementBlock("span",XW,[e.renderSlot(r.$slots,"default"),e.createVNode(e.Transition,{name:"vt-badge__fade"},{default:e.withCtx(()=>[n.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["vt-badge__content",[`vt-badge__content--${l.position}`,`vt-badge__content--${l.color}`,{"vt-badge__content--dot":l.dot,"vt-badge__content--bordered":l.bordered}]]),style:e.normalizeStyle(s.value)},[l.dot?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(o.value),1)],64))],6)):e.createCommentVNode("",!0)]),_:1})]))}}),TW={class:"vt-app-bar__logo"},wW={key:0,class:"vt-app-bar__center"},GW={key:1,class:"vt-app-bar__actions"},ml=e.defineComponent({__name:"VAppBar",props:{sticky:{type:Boolean,default:!1}},setup(l){return(t,i)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vt-app-bar",{"vt-app-bar--sticky":l.sticky}])},[e.createElementVNode("div",TW,[e.renderSlot(t.$slots,"logo")]),t.$slots.center?(e.openBlock(),e.createElementBlock("div",wW,[e.renderSlot(t.$slots,"center")])):e.createCommentVNode("",!0),t.$slots.actions?(e.openBlock(),e.createElementBlock("div",GW,[e.renderSlot(t.$slots,"actions")])):e.createCommentVNode("",!0)],2))}}),xW={class:"vt-nav-rail"},gW={class:"vt-nav-rail__list"},vW=["data-placement","onClick"],fW={key:0,class:"vt-nav-rail__divider"},EW={key:0,class:"vt-nav-rail__footer"},ul=e.defineComponent({__name:"VNavRail",props:{items:{},modelValue:{default:null},placement:{default:"left"}},emits:["update:modelValue","select"],setup(l,{emit:t}){const i=t,n=o=>{o.disabled||(i("update:modelValue",o.key),i("select",o))};return(o,s)=>{const r=e.resolveDirective("tooltip");return e.openBlock(),e.createElementBlock("aside",xW,[e.createElementVNode("div",gW,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.items,(a,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:a.key},[e.withDirectives((e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vt-nav-rail__item",{"vt-nav-rail__item--selected":l.modelValue===a.key,"vt-nav-rail__item--disabled":a.disabled}]),"data-placement":l.placement,onClick:d=>n(a)},[a.badge?(e.openBlock(),e.createBlock(D1,{key:0,content:a.badge.content,position:a.badge.position},{default:e.withCtx(()=>[e.createVNode(ue,{name:a.icon,width:24,height:24},null,8,["name"])]),_:2},1032,["content","position"])):(e.openBlock(),e.createBlock(ue,{key:1,name:a.icon,width:24,height:24},null,8,["name"]))],10,vW)),[[r,a.label]]),u<l.items.length-1?(e.openBlock(),e.createElementBlock("span",fW)):e.createCommentVNode("",!0)],64))),128))]),o.$slots.footer?(e.openBlock(),e.createElementBlock("div",EW,[e.renderSlot(o.$slots,"footer")])):e.createCommentVNode("",!0)])}}}),dt=(l,t)=>{const i=document.createElement("div");i.className=`vt-tooltip vt-tooltip--${t}`,i.innerText=l,Object.assign(i.style,{position:"absolute",background:"rgba(0, 0, 0, 0.8)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"12px",lineHeight:"1.4",zIndex:"9999",pointerEvents:"none",visibility:"hidden",opacity:"0",transition:"opacity 0.2s ease, visibility 0.2s ease",maxWidth:"300px",wordWrap:"break-word",whiteSpace:"normal",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.2)"});const n=document.createElement("div");switch(n.className="vt-tooltip__arrow",Object.assign(n.style,{position:"absolute",width:"0",height:"0",borderStyle:"solid"}),t){case"top":Object.assign(n.style,{top:"100%",left:"50%",marginLeft:"-5px",borderWidth:"5px 5px 0 5px",borderColor:"rgba(0, 0, 0, 0.8) transparent transparent transparent"});break;case"bottom":Object.assign(n.style,{bottom:"100%",left:"50%",marginLeft:"-5px",borderWidth:"0 5px 5px 5px",borderColor:"transparent transparent rgba(0, 0, 0, 0.8) transparent"});break;case"left":Object.assign(n.style,{top:"50%",left:"100%",marginTop:"-5px",borderWidth:"5px 0 5px 5px",borderColor:"transparent transparent transparent rgba(0, 0, 0, 0.8)"});break;case"right":Object.assign(n.style,{top:"50%",right:"100%",marginTop:"-5px",borderWidth:"5px 5px 5px 0",borderColor:"transparent rgba(0, 0, 0, 0.8) transparent transparent"});break}return i.appendChild(n),i},J1=(l,t,i)=>{const n=t.getBoundingClientRect(),o=window.pageXOffset||document.documentElement.scrollLeft,s=window.pageYOffset||document.documentElement.scrollTop,r=window.innerWidth,a=window.innerHeight,u=8,d=Math.min(300,r-u*2);l.style.maxWidth=`${d}px`;const h=l.getBoundingClientRect();let b=0,Z=0;switch(i){case"top":b=n.top+s-h.height-8,Z=n.left+o+(n.width-h.width)/2;break;case"bottom":b=n.bottom+s+8,Z=n.left+o+(n.width-h.width)/2;break;case"left":b=n.top+s+(n.height-h.height)/2,Z=n.left+o-h.width-8;break;case"right":b=n.top+s+(n.height-h.height)/2,Z=n.right+o+8;break}Z<u?Z=u:Z+h.width>r-u&&(Z=r-h.width-u),b<s+u?i==="top"?b=n.bottom+s+8:b=s+u:b+h.height>s+a-u&&(i==="bottom"?b=n.top+s-h.height-8:b=s+a-h.height-u),l.style.top=`${b}px`,l.style.left=`${Z}px`},mt=(l,t,i)=>{l.parentElement||document.body.appendChild(l),l.style.visibility="visible",J1(l,t,i),requestAnimationFrame(()=>{l.style.opacity="1"})},ut=l=>{l.style.opacity="0",l.style.visibility="hidden"},ht=l=>l.scrollWidth>l.clientWidth||l.scrollHeight>l.clientHeight,It=l=>!!l.closest(".vt-table, table"),hl={mounted(l,t){var u;const i=(u=t.value)==null?void 0:u.trim();if(!i)return;const n=l.dataset.placement||"top",o=dt(i,n);l.__tooltipEl=o;const s=()=>{(It(l)?ht(l):!0)&&mt(o,l,n)},r=()=>{ut(o)},a=()=>{o.style.opacity==="1"&&J1(o,l,n)};l.__mouseenterHandler=s,l.__mouseleaveHandler=r,l.__scrollHandler=a,l.addEventListener("mouseenter",s),l.addEventListener("mouseleave",r),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a)},updated(l,t){var n;const i=(n=t.value)==null?void 0:n.trim();if(l.__tooltipEl)i?l.__tooltipEl.firstChild.textContent=i:(l.__tooltipEl.parentElement&&l.__tooltipEl.parentElement.removeChild(l.__tooltipEl),delete l.__tooltipEl);else if(i){const o=l.dataset.placement||"top",s=dt(i,o);l.__tooltipEl=s;const r=()=>{(It(l)?ht(l):!0)&&mt(s,l,o)},a=()=>{ut(s)},u=()=>{s.style.opacity==="1"&&J1(s,l,o)};l.__mouseenterHandler=r,l.__mouseleaveHandler=a,l.__scrollHandler=u,l.addEventListener("mouseenter",r),l.addEventListener("mouseleave",a),window.addEventListener("scroll",u,!0),window.addEventListener("resize",u)}},beforeUnmount(l){l.__tooltipEl&&l.__tooltipEl.parentElement&&(l.__tooltipEl.parentElement.removeChild(l.__tooltipEl),delete l.__tooltipEl),l.__mouseenterHandler&&(l.removeEventListener("mouseenter",l.__mouseenterHandler),delete l.__mouseenterHandler),l.__mouseleaveHandler&&(l.removeEventListener("mouseleave",l.__mouseleaveHandler),delete l.__mouseleaveHandler),l.__scrollHandler&&(window.removeEventListener("scroll",l.__scrollHandler,!0),window.removeEventListener("resize",l.__scrollHandler),delete l.__scrollHandler)}},Il={mounted(l,t){e.unref(t.value)&&pt(l)},updated(l,t){const i=e.unref(t.value),n=e.unref(t.oldValue);i!==n&&(i?pt(l):Zt(l))},unmounted(l){Zt(l)}};function pt(l){if(l._loaderEl)return;const t=document.createElement("div");t.className="vt-loader-base__overlay",t.innerHTML='<span class="vt-loader-base"></span>';const i=getComputedStyle(l).position;(i==="static"||!i)&&(l.style.position="relative"),l.appendChild(t),l._loaderEl=t}function Zt(l){const t=l._loaderEl;t&&(t.remove(),delete l._loaderEl)}const JW={class:"vt-message-container"},KW={class:"vt-message-icon"},FW={class:"vt-message-content"},jW={key:0,class:"vt-message-title"},RW=["innerHTML"],UW={key:1,class:"vt-message-text"},zW=["onClick"],OW=e.defineComponent({__name:"VMessage",setup(l,{expose:t}){const i=e.ref([]);let n=0;const o=a=>({success:"checkCircle",danger:"alertCircle",warning:"alertTriangle",primary:"infoCircle"})[a]||"infoCircle",s=a=>{const u=++n,d={id:u,message:a.message||"",title:a.title||"",type:a.type||"primary",showClose:a.showClose||!1,duration:a.duration!==void 0?a.duration:3e3,dangerouslyUseHTMLString:a.dangerouslyUseHTMLString||!1};return i.value.push(d),d.duration&&d.duration>0&&setTimeout(()=>{r(u)},d.duration),u},r=a=>{const u=i.value.findIndex(d=>d.id===a);u>-1&&i.value.splice(u,1)};return t({addMessage:s,removeMessage:r}),(a,u)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createElementVNode("div",JW,[e.createVNode(e.TransitionGroup,{name:"vt-message",tag:"div"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,d=>(e.openBlock(),e.createElementBlock("div",{key:d.id,class:e.normalizeClass(["vt-message-item",`vt-message-item--${d.type}`,{"vt-message-item--closable":d.showClose}])},[e.createElementVNode("div",KW,[e.createVNode(ue,{color:d.type==="primary"?"#00475A":"",name:o(d.type)},null,8,["color","name"])]),e.createElementVNode("div",FW,[d.title?(e.openBlock(),e.createElementBlock("div",jW,e.toDisplayString(d.title),1)):e.createCommentVNode("",!0),d.message?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[d.dangerouslyUseHTMLString?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vt-message-text",innerHTML:d.message},null,8,RW)):(e.openBlock(),e.createElementBlock("div",UW,e.toDisplayString(d.message),1))],64)):e.createCommentVNode("",!0)]),d.showClose?(e.openBlock(),e.createElementBlock("button",{key:0,class:"vt-message-close",type:"button",onClick:h=>r(d.id)},[e.createVNode(ue,{name:"close"})],8,zW)):e.createCommentVNode("",!0)],2))),128))]),_:1})])]))}});class DW{constructor(){this.messageInstance=null,this.app=null,this.container=null}call(t={}){return this.ensureInstance().addMessage({message:t.message||"",title:t.title||"",type:t.type||"primary",showClose:t.showClose||!1,duration:t.duration!==void 0?t.duration:3e3,dangerouslyUseHTMLString:t.dangerouslyUseHTMLString||!1})}success(t,i={}){return this.call({...i,message:t,type:"success"})}danger(t,i={}){return this.call({...i,message:t,type:"danger"})}warning(t,i={}){return this.call({...i,message:t,type:"warning"})}primary(t,i={}){return this.call({...i,message:t,type:"primary"})}close(t){this.messageInstance&&this.messageInstance.removeMessage(t)}closeAll(){this.messageInstance&&(this.messageInstance.messages=[]),this.container&&this.container.parentNode&&document.body.removeChild(this.container),this.app&&this.app.unmount(),this.messageInstance=null,this.app=null,this.container=null}getOpenMessagesCount(){return this.messageInstance?this.messageInstance.messages.length:0}ensureInstance(){return this.messageInstance?this.messageInstance:(this.container=document.createElement("div"),this.container.setAttribute("data-vt-message-container",""),document.body.appendChild(this.container),this.app=e.createApp(OW),this.messageInstance=this.app.mount(this.container),this.messageInstance)}}const ze=new DW,K1=Object.assign((l={})=>ze.call(l),{success:(l,t={})=>ze.success(l,t),danger:(l,t={})=>ze.danger(l,t),warning:(l,t={})=>ze.warning(l,t),primary:(l,t={})=>ze.primary(l,t),close:l=>{ze.close(l)},closeAll:()=>{ze.closeAll()}}),pl={install(l){l.config.globalProperties.$message=K1,l.provide("$message",K1),l.config.globalProperties.$messageStack={closeAll:()=>ze.closeAll(),getCount:()=>ze.getOpenMessagesCount(),closeById:t=>ze.close(t)}}},PW={sortable:!0,actionColumn:!1,showOverflowTooltip:!0,visible:!0,pinnedLeft:!1,pinnedRight:!1,manage:!1};function HW(l){bt(l)}const Zl={install(l,t={}){const{prefix:i="V",modal:n=!0,message:o=!0,locale:s=Pe.uk}=t;l.component(`${i}Button`,Ge),l.component(`${i}Icon`,ue),l.component(`${i}Loader`,p1),l.component(`${i}Modal`,Z1),l.component(`${i}Pagination`,yt),l.component(`${i}Checkbox`,De),l.component(`${i}Radiobox`,Vt),l.component(`${i}Table`,Yt),l.component(`${i}TableColumn`,Lt),l.component(`${i}Dropdown`,n1),l.component(`${i}DropdownItem`,s1),l.component(`${i}Input`,m1),l.component(`${i}Select`,N1),l.component(`${i}Option`,X1),l.component(`${i}DatePicker`,wt),l.component(`${i}TimePicker`,h1),l.component(`${i}Collapse`,Gt),l.component(`${i}CollapseItem`,xt),l.component(`${i}Tabs`,gt),l.component(`${i}TabItem`,vt),l.component(`${i}Upload`,Et),l.component(`${i}Sidebar`,Jt),l.component(`${i}Login`,Dt),l.component(`${i}LoginLogo`,Pt),l.component(`${i}LocaleSelect`,Wt),l.component(`${i}DynamicFilter`,Ht),l.component(`${i}Slider`,Bt),l.component(`${i}SliderMarkRange`,_t),l.component(`${i}Chart`,Qt),l.component(`${i}InfoBox`,At),l.component(`${i}TransferList`,$t),l.component(`${i}Avatar`,qt),l.component(`${i}AvatarUpload`,el),l.component(`${i}ImageFullscreen`,tl),l.component(`${i}Breadcrumb`,ll),l.component(`${i}BreadcrumbItem`,il),l.component(`${i}Audio`,rl),l.component(`${i}Empty`,T1),l.component(`${i}Editor`,dl),l.component(`${i}Badge`,D1),l.component(`${i}AppBar`,ml),l.component(`${i}NavRail`,ul),l.directive("tooltip",hl),l.directive("loader",Il),n&&l.use(St),o&&l.use(pl),l.use(Ep,{locale:s})}},BW=Zl.install;exports.DEFAULT_COLUMN_CONFIG=PW;exports.DEFAULT_FORMATS=kt;exports.DEFAULT_TIME_FORMATS=u1;exports.DropdownContextKey=R1;exports.FORMAT_TOKENS=Kb;exports.FileParser=I1;exports.FileValidator=i1;exports.LANGUAGES=Pe;exports.VAppBar=ml;exports.VAudio=rl;exports.VAvatar=qt;exports.VAvatarUpload=el;exports.VBadge=D1;exports.VBreadcrumb=ll;exports.VBreadcrumbItem=il;exports.VButton=Ge;exports.VChart=Qt;exports.VCheckbox=De;exports.VCollapse=Gt;exports.VCollapseItem=xt;exports.VColorPicker=WL;exports.VDatePicker=wt;exports.VDropdown=n1;exports.VDropdownItem=s1;exports.VDynamicFilter=Ht;exports.VEditor=dl;exports.VEmpty=T1;exports.VIcon=ue;exports.VImageFullscreen=tl;exports.VInfoBox=At;exports.VInput=m1;exports.VLoader=p1;exports.VLocaleSelect=Wt;exports.VLogin=Dt;exports.VLoginLogo=Pt;exports.VMessage=K1;exports.VMessagePlugin=pl;exports.VModal=Z1;exports.VModalPlugin=St;exports.VNavRail=ul;exports.VOption=X1;exports.VPagination=yt;exports.VRadiobox=Vt;exports.VSelect=N1;exports.VSidebar=Jt;exports.VSlider=Bt;exports.VSliderMarkRange=_t;exports.VTabItem=vt;exports.VTable=Yt;exports.VTableColumn=Lt;exports.VTabs=gt;exports.VTimePicker=h1;exports.VTimerDuration=ML;exports.VTransferList=$t;exports.VUpload=Et;exports.VtSelectContextKey=F1;exports.containUpperCaseLetter=Ut;exports.default=Zl;exports.email=Kt;exports.formatTime=Xt;exports.generateTimeOptions=L1;exports.install=BW;exports.isValidDate=g1;exports.isValidTimeString=W1;exports.loaderDirective=Il;exports.maxLength=JV;exports.maxNumber=FV;exports.messageManager=ze;exports.minLength=v1;exports.minNumber=KV;exports.mk=EV;exports.modalManager=_e;exports.noSpaces=z1;exports.numeric=jt;exports.parseTimeString=Tt;exports.pattern=RV;exports.phoneNumber=Rt;exports.required=k1;exports.sameAs=jV;exports.setLocale=HW;exports.tooltipDirective=hl;exports.uniqueAsync=UV;exports.url=Ft;exports.useValidate=Ot;exports.validateDateValue=Mt;exports.validateTimeValue=Nt;exports.withAsync=fV;exports.withMessage=vV;exports.withName=l1;exports.withParams=gV;
74
+ `,[t,i]}setOptions(t){var i;if(this.options.container!==t.container){const n=this.parentFromOptionsContainer(t.container);n.appendChild(this.container),this.parent=n}t.dragToSeek===!0||typeof this.options.dragToSeek=="object"?this.initDrag():((i=this.dragStream)===null||i===void 0||i.cleanup(),this.dragStream=null),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth-this.containerInlinePadding}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:i}=this.scrollContainer,n=i*t;this.setScroll(n)}destroy(){var t;this.subscriptions.forEach(i=>i()),this.container.remove(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),(t=this.unsubscribeOnScroll)===null||t===void 0||t.forEach(i=>i()),this.unsubscribeOnScroll=[],this.dragStream&&(this.dragStream.cleanup(),this.dragStream=null),this.scrollStream&&(this.scrollStream.cleanup(),this.scrollStream=null)}createDelay(t=10){let i,n;const o=()=>{i&&(clearTimeout(i),i=void 0),n&&(n(),n=void 0)};return this.timeouts.push(o),()=>new Promise((s,r)=>{o(),n=r,i=setTimeout(()=>{i=void 0,n=void 0,s()},t)})}getHeight(t,i){var n;const o=((n=this.audioData)===null||n===void 0?void 0:n.numberOfChannels)||1;return function({optionsHeight:s,optionsSplitChannels:r,parentHeight:a,numberOfChannels:u,defaultHeight:d=128}){if(s==null)return d;const h=Number(s);if(!isNaN(h))return h;if(s==="auto"){const b=a||d;return r!=null&&r.every(Z=>!Z.overlay)?b/u:b}return d}({optionsHeight:t,optionsSplitChannels:i,parentHeight:this.parent.clientHeight,numberOfChannels:o,defaultHeight:128})}convertColorValues(t,i){return function(n,o,s){if(!Array.isArray(n))return n||"";if(n.length===0)return"#999";if(n.length<2)return n[0]||"";const r=document.createElement("canvas"),a=r.getContext("2d"),u=s??r.height*o,d=a.createLinearGradient(0,0,0,u||o),h=1/(n.length-1);return n.forEach((b,Z)=>{d.addColorStop(Z*h,b)}),d}(t,this.getPixelRatio(),i==null?void 0:i.canvas.height)}getPixelRatio(){return t=window.devicePixelRatio,Math.max(1,t||1);var t}renderBarWaveform(t,i,n,o){const{width:s,height:r}=n.canvas,{halfHeight:a,barWidth:u,barRadius:d,barIndexScale:h,barSpacing:b,barMinHeight:Z}=function({width:I,height:V,length:m,options:j,pixelRatio:X}){const Y=V/2,x=j.barWidth?j.barWidth*X:1,G=j.barGap?j.barGap*X:j.barWidth?x/2:0,L=x+G||1;return{halfHeight:Y,barWidth:x,barGap:G,barRadius:j.barRadius||0,barMinHeight:j.barMinHeight?j.barMinHeight*X:0,barIndexScale:m>0?I/L/m:0,barSpacing:L}}({width:s,height:r,length:(t[0]||[]).length,options:i,pixelRatio:this.getPixelRatio()}),y=function({channelData:I,barIndexScale:V,barSpacing:m,barWidth:j,halfHeight:X,vScale:Y,canvasHeight:x,barAlign:G,barMinHeight:L}){const p=I[0]||[],w=I[1]||p,W=p.length,S=[];let J=0,E=0,g=0;for(let f=0;f<=W;f++){const T=Math.round(f*V);if(T>J){const{topHeight:oe,totalHeight:N}=fL({maxTop:E,maxBottom:g,halfHeight:X,vScale:Y,barMinHeight:L,barAlign:G}),K=EL({barAlign:G,halfHeight:X,topHeight:oe,totalHeight:N,canvasHeight:x});S.push({x:J*m,y:K,width:j,height:N}),J=T,E=0,g=0}const U=Math.abs(p[f]||0),A=Math.abs(w[f]||0);U>E&&(E=U),A>g&&(g=A)}return S}({channelData:t,barIndexScale:h,barSpacing:b,barWidth:u,halfHeight:a,vScale:o,canvasHeight:r,barAlign:i.barAlign,barMinHeight:Z});n.beginPath();for(const I of y)d&&"roundRect"in n?n.roundRect(I.x,I.y,I.width,I.height,d):n.rect(I.x,I.y,I.width,I.height);n.fill(),n.closePath()}renderLineWaveform(t,i,n,o){const{width:s,height:r}=n.canvas,a=function({channelData:u,width:d,height:h,vScale:b}){const Z=h/2,y=u[0]||[];return[y,u[1]||y].map((I,V)=>{const m=I.length,j=m?d/m:0,X=Z,Y=V===0?-1:1,x=[{x:0,y:X}];let G=0,L=0;for(let p=0;p<=m;p++){const w=Math.round(p*j);if(w>G){const S=X+(Math.round(L*Z*b)||1)*Y;x.push({x:G,y:S}),G=w,L=0}const W=Math.abs(I[p]||0);W>L&&(L=W)}return x.push({x:G,y:X}),x})}({channelData:t,width:s,height:r,vScale:o});n.beginPath();for(const u of a)if(u.length){n.moveTo(u[0].x,u[0].y);for(let d=1;d<u.length;d++){const h=u[d];n.lineTo(h.x,h.y)}}n.fill(),n.closePath()}renderWaveform(t,i,n){if(n.fillStyle=this.convertColorValues(i.waveColor,n),i.renderFunction)return void i.renderFunction(t,n);const o=function({channelData:s,barHeight:r,normalize:a,maxPeak:u}){var d;const h=r||1;if(!a)return h;const b=s[0];if(!b||b.length===0)return h;let Z=u??0;if(!u)for(let y=0;y<b.length;y++){const I=(d=b[y])!==null&&d!==void 0?d:0,V=Math.abs(I);V>Z&&(Z=V)}return Z?h/Z:h}({channelData:t,barHeight:i.barHeight,normalize:i.normalize,maxPeak:i.maxPeak});nl(i)?this.renderBarWaveform(t,i,n,o):this.renderLineWaveform(t,i,n,o)}renderSingleCanvas(t,i,n,o,s,r,a){const u=this.getPixelRatio(),d=document.createElement("canvas");d.width=Math.round(n*u),d.height=Math.round(o*u),d.style.width=`${n}px`,d.style.height=`${o}px`,d.style.left=`${Math.round(s)}px`,r.appendChild(d);const h=d.getContext("2d");if(i.renderFunction?(h.fillStyle=this.convertColorValues(i.waveColor,h),i.renderFunction(t,h)):this.renderWaveform(t,i,h),d.width>0&&d.height>0){const b=d.cloneNode(),Z=b.getContext("2d");Z.drawImage(d,0,0),Z.globalCompositeOperation="source-in",Z.fillStyle=this.convertColorValues(i.progressColor,Z),Z.fillRect(0,0,d.width,d.height),a.appendChild(b)}}renderMultiCanvas(t,i,n,o,s,r){const a=this.getPixelRatio(),{clientWidth:u}=this.scrollContainer,d=n/a,h=function({clientWidth:I,totalWidth:V,options:m}){return ct(Math.min(8e3,I,V),m)}({clientWidth:u,totalWidth:d,options:i});let b={};if(h===0)return;const Z=I=>{if(I<0||I>=y||b[I])return;b[I]=!0;const V=I*h;let m=Math.min(d-V,h);if(m=ct(m,i),m<=0)return;const j=function({channelData:X,offset:Y,clampedWidth:x,totalWidth:G}){return X.map(L=>{const p=Math.floor(Y/G*L.length),w=Math.floor((Y+x)/G*L.length);return L.slice(p,w)})}({channelData:t,offset:V,clampedWidth:m,totalWidth:d});this.renderSingleCanvas(j,i,m,o,V,s,r)},y=Math.ceil(d/h);if(!this.isScrollable){for(let I=0;I<y;I++)Z(I);return}if(rt({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:d,numCanvases:y}).forEach(I=>Z(I)),y>1){const I=this.on("scroll",()=>{const{scrollLeft:V}=this.scrollContainer;Object.keys(b).length>10&&(s.innerHTML="",r.innerHTML="",b={}),rt({scrollLeft:V,totalWidth:d,numCanvases:y}).forEach(m=>Z(m))});this.unsubscribeOnScroll.push(I)}}renderChannel(t,i,n,o){var{overlay:s}=i,r=function(h,b){var Z={};for(var y in h)Object.prototype.hasOwnProperty.call(h,y)&&b.indexOf(y)<0&&(Z[y]=h[y]);if(h!=null&&typeof Object.getOwnPropertySymbols=="function"){var I=0;for(y=Object.getOwnPropertySymbols(h);I<y.length;I++)b.indexOf(y[I])<0&&Object.prototype.propertyIsEnumerable.call(h,y[I])&&(Z[y[I]]=h[y[I]])}return Z}(i,["overlay"]);const a=document.createElement("div"),u=this.getHeight(r.height,r.splitChannels);a.style.height=`${u}px`,s&&o>0&&(a.style.marginTop=`-${u}px`),this.canvasWrapper.style.minHeight=`${u}px`,this.canvasWrapper.appendChild(a);const d=a.cloneNode();this.progressWrapper.appendChild(d),this.renderMultiCanvas(t,r,n,u,a,d)}render(t){return Je(this,void 0,void 0,function*(){var i;this.timeouts.forEach(d=>d()),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 n=this.getPixelRatio(),o=this.scrollContainer.clientWidth-this.containerInlinePadding,{scrollWidth:s,isScrollable:r,useParentWidth:a,width:u}=function({duration:d,minPxPerSec:h=0,parentWidth:b,fillParent:Z,pixelRatio:y}){const I=Math.ceil(d*h),V=I>b,m=!!(Z&&!V);return{scrollWidth:I,isScrollable:V,useParentWidth:m,width:(m?b:I)*y}}({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:o,fillParent:this.options.fillParent,pixelRatio:n});if(this.isScrollable=r,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=t,this.emit("render"),this.options.splitChannels)for(let d=0;d<t.numberOfChannels;d++){const h=Object.assign(Object.assign({},this.options),(i=this.options.splitChannels)===null||i===void 0?void 0:i[d]);this.renderChannel([t.getChannelData(d)],h,u,d)}else{const d=[t.getChannelData(0)];t.numberOfChannels>1&&d.push(t.getChannelData(1)),this.renderChannel(d,this.options,u,0)}Promise.resolve().then(()=>this.emit("rendered"))})}reRender(){if(this.unsubscribeOnScroll.forEach(n=>n()),this.unsubscribeOnScroll=[],!this.audioData)return;const{scrollWidth:t}=this.scrollContainer,{right:i}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),!this.isScrollable&&this.scrollContainer.scrollLeft)this.scrollContainer.scrollLeft=0;else if(this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:n}=this.progressWrapper.getBoundingClientRect(),o=function(s){const r=2*s;return(r<0?Math.floor(r):Math.ceil(r))/2}(n-i);this.scrollContainer.scrollLeft+=o}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,i=!1){var n;const{scrollLeft:o,scrollWidth:s,clientWidth:r}=this.scrollContainer,a=t*s,u=o,d=o+r,h=r/2;if(this.isDragging)a+30>d?this.scrollContainer.scrollLeft+=30:a-30<u&&(this.scrollContainer.scrollLeft-=30);else{(a<u||a>d)&&(this.scrollContainer.scrollLeft=a-(this.options.autoCenter?h:0));const b=a-o-h;if(i&&this.options.autoCenter&&b>0){const Z=(n=this.audioData)===null||n===void 0?void 0:n.duration;if(Z===void 0||Z<=0)return void(this.scrollContainer.scrollLeft+=b);const y=s/Z;this.scrollContainer.scrollLeft+=y<=600?Math.min(b,10):b}}}renderProgress(t,i){if(isNaN(t))return;const n=100*t;this.canvasWrapper.style.clipPath=`polygon(${n}% 0%, 100% 0%, 100% 100%, ${n}% 100%)`,this.progressWrapper.style.width=`${n}%`,this.cursor.style.left=`${n}%`,this.cursor.style.transform=this.options.cursorWidth?`translateX(-${t*this.options.cursorWidth}px)`:"",this.isScrollable&&this.options.autoScroll&&this.audioData&&this.audioData.duration>0&&this.scrollIntoView(t,i)}exportImage(t,i,n){return Je(this,void 0,void 0,function*(){const o=this.canvasWrapper.querySelectorAll("canvas");if(!o.length)throw new Error("No waveform data");if(n==="dataURL"){const s=Array.from(o).map(r=>r.toDataURL(t,i));return Promise.resolve(s)}return Promise.all(Array.from(o).map(s=>new Promise((r,a)=>{s.toBlob(u=>{u?r(u):a(new Error("Could not export image"))},t,i)})))})}}class FL extends C1{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;const t=()=>{this.isRunning&&(this.emit("tick"),this.animationFrameId=requestAnimationFrame(t))};t()}stop(){this.isRunning=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop()}}class G1 extends C1{constructor(t){super(),this.bufferNode=null,this.playStartTime=0,this.playbackPosition=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,function(){const i=globalThis.navigator;if(i!=null&&i.audioSession)try{i.audioSession.type="playback"}catch(n){console.warn("Setting navigator.audioSession.type failed:",n)}}(),this.audioContext=t||new AudioContext,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return Je(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(t){if(this.currentSrc=t,this._duration=void 0,!t)return this.buffer=null,void this.emit("emptied");fetch(t).then(i=>{if(i.status>=400)throw new Error(`Failed to fetch ${t}: ${i.status} (${i.statusText})`);return i.arrayBuffer()}).then(i=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(i)).then(i=>{this.currentSrc===t&&(this.buffer=i,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())}).catch(i=>{console.error("WebAudioPlayer load error:",i)})}_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 t=this.playbackPosition;(t>=this.duration||t<0)&&(t=0,this.playbackPosition=0),this.bufferNode.start(this.audioContext.currentTime,t),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{!this.paused&&this.duration-this.currentTime<.01&&(this.pause(),this.emit("ended"))}}_pause(){var t;this.paused=!0,(t=this.bufferNode)===null||t===void 0||t.stop(),this.playbackPosition+=(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}play(){return Je(this,void 0,void 0,function*(){this.paused&&(this._play(),this.emit("play"))})}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){const i=t-this.currentTime,n=this.bufferNode;n==null||n.stop(this.audioContext.currentTime+i),n==null||n.addEventListener("ended",()=>{n===this.bufferNode&&(this.bufferNode=null,this.pause())},{once:!0})}setSinkId(t){return Je(this,void 0,void 0,function*(){return this.audioContext.setSinkId(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){const i=!this.paused;i&&this._pause(),this._playbackRate=t,i&&this._play(),this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return this.paused?this.playbackPosition:this.playbackPosition+(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}set currentTime(t){const i=!this.paused;i&&this._pause(),this.playbackPosition=t,i&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,i;return(t=this._duration)!==null&&t!==void 0?t:((i=this.buffer)===null||i===void 0?void 0:i.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t,this.emit("volumechange")}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const i=this.buffer.numberOfChannels;for(let n=0;n<i;n++)t.push(this.buffer.getChannelData(n));return t}removeAttribute(t){switch(t){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 jL={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class b1 extends vL{static create(t){return new b1(t)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(t){const i=t.media||(t.backend==="WebAudio"?new G1:void 0);super({media:i,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate}),this.plugins=[],this.decodedData=null,this.stopAtPosition=null,this.subscriptions=[],this.mediaSubscriptions=[],this.abortController=null,this.reactiveCleanups=[],this.options=Object.assign({},jL,t);const{state:n,actions:o}=function(a){var u,d,h,b,Z,y;const I=(u=a==null?void 0:a.currentTime)!==null&&u!==void 0?u:ge(0),V=(d=a==null?void 0:a.duration)!==null&&d!==void 0?d:ge(0),m=(h=a==null?void 0:a.isPlaying)!==null&&h!==void 0?h:ge(!1),j=(b=a==null?void 0:a.isSeeking)!==null&&b!==void 0?b:ge(!1),X=(Z=a==null?void 0:a.volume)!==null&&Z!==void 0?Z:ge(1),Y=(y=a==null?void 0:a.playbackRate)!==null&&y!==void 0?y:ge(1),x=ge(null),G=ge(null),L=ge(""),p=ge(0),w=ge(0),W=o1(()=>!m.value,[m]),S=o1(()=>x.value!==null,[x]),J=o1(()=>S.value&&V.value>0,[S,V]),E=o1(()=>I.value,[I]),g=o1(()=>V.value>0?I.value/V.value:0,[I,V]);return{state:{currentTime:I,duration:V,isPlaying:m,isPaused:W,isSeeking:j,volume:X,playbackRate:Y,audioBuffer:x,peaks:G,url:L,zoom:p,scrollPosition:w,canPlay:S,isReady:J,progress:E,progressPercent:g},actions:{setCurrentTime:f=>{const T=Math.max(0,Math.min(V.value||1/0,f));I.set(T)},setDuration:f=>{V.set(Math.max(0,f))},setPlaying:f=>{m.set(f)},setSeeking:f=>{j.set(f)},setVolume:f=>{const T=Math.max(0,Math.min(1,f));X.set(T)},setPlaybackRate:f=>{const T=Math.max(.1,Math.min(16,f));Y.set(T)},setAudioBuffer:f=>{x.set(f),f&&V.set(f.duration)},setPeaks:f=>{G.set(f)},setUrl:f=>{L.set(f)},setZoom:f=>{p.set(Math.max(0,f))},setScrollPosition:f=>{w.set(Math.max(0,f))}}}}({isPlaying:this.isPlayingSignal,currentTime:this.currentTimeSignal,duration:this.durationSignal,volume:this.volumeSignal,playbackRate:this.playbackRateSignal,isSeeking:this.seekingSignal});this.wavesurferState=n,this.wavesurferActions=o,this.timer=new FL;const s=i?void 0:this.getMediaElement();this.renderer=new KL(this.options,s),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initReactiveState(),this.initPlugins();const r=this.options.url||this.getSrc()||"";Promise.resolve().then(()=>{this.emit("init");const{peaks:a,duration:u}=this.options;(r||a&&u)&&this.load(r,a,u).catch(d=>{this.emit("error",d instanceof Error?d:new Error(String(d)))})})}updateProgress(t=this.getCurrentTime()){return this.renderer.renderProgress(t/this.getDuration(),this.isPlaying()),t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t),this.stopAtPosition!=null&&this.isPlaying()&&t>=this.stopAtPosition&&this.pause()}}))}initReactiveState(){this.reactiveCleanups.push(function(t,i){const n=[];n.push(t1(()=>{const r=t.isPlaying.value;i.emit(r?"play":"pause")},[t.isPlaying])),n.push(t1(()=>{const r=t.currentTime.value;i.emit("timeupdate",r),t.isPlaying.value&&i.emit("audioprocess",r)},[t.currentTime,t.isPlaying])),n.push(t1(()=>{t.isSeeking.value&&i.emit("seeking",t.currentTime.value)},[t.isSeeking,t.currentTime]));let o=!1;n.push(t1(()=>{t.isReady.value&&!o&&(o=!0,i.emit("ready",t.duration.value))},[t.isReady,t.duration]));let s=!1;return n.push(t1(()=>{const r=t.isPlaying.value,a=t.currentTime.value,u=t.duration.value,d=u>0&&a>=u;s&&!r&&d&&i.emit("finish"),s=r&&d},[t.isPlaying,t.currentTime,t.duration])),n.push(t1(()=>{const r=t.zoom.value;r>0&&i.emit("zoom",r)},[t.zoom])),()=>{n.forEach(r=>r())}}(this.wavesurferState,{emit:this.emit.bind(this)}))}initPlayerEvents(){this.isPlaying()&&(this.emit("play"),this.timer.start()),this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",()=>{const t=this.updateProgress();this.emit("timeupdate",t)}),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 t;this.emit("error",(t=this.getMediaElement().error)!==null&&t!==void 0?t:new Error("Media error")),this.stopAtPosition=null}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(t,i)=>{this.options.interact&&(this.seekTo(t),this.emit("interaction",t*this.getDuration()),this.emit("click",t,i))}),this.renderer.on("dblclick",(t,i)=>{this.emit("dblclick",t,i)}),this.renderer.on("scroll",(t,i,n,o)=>{const s=this.getDuration();this.emit("scroll",t*s,i*s,n,o)}),this.renderer.on("render",()=>{this.emit("redraw")}),this.renderer.on("rendered",()=>{this.emit("redrawcomplete")}),this.renderer.on("dragstart",t=>{this.emit("dragstart",t)}),this.renderer.on("dragend",t=>{this.emit("dragend",t)}),this.renderer.on("resize",()=>{this.emit("resize")}));{let t;const i=this.renderer.on("drag",n=>{var o;if(!this.options.interact)return;this.renderer.renderProgress(n),clearTimeout(t);let s=0;const r=this.options.dragToSeek;this.isPlaying()?s=0:r===!0?s=200:r&&typeof r=="object"&&(s=(o=r.debounceTime)!==null&&o!==void 0?o:200),t=setTimeout(()=>{this.seekTo(n)},s),this.emit("interaction",n*this.getDuration()),this.emit("drag",n)});this.subscriptions.push(()=>{clearTimeout(t),i()})}}initPlugins(){var t;!((t=this.options.plugins)===null||t===void 0)&&t.length&&this.options.plugins.forEach(i=>{this.registerPlugin(i)})}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach(t=>t()),this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t),t.duration&&!t.peaks&&(this.decodedData=S1.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=S1.createBuffer(t.peaks,t.duration)),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),t.mediaControls!=null&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){if(this.plugins.includes(t))return t;t._init(this),this.plugins.push(t);const i=t.once("destroy",()=>{this.plugins=this.plugins.filter(n=>n!==t),this.subscriptions=this.subscriptions.filter(n=>n!==i)});return this.subscriptions.push(i),t}unregisterPlugin(t){this.plugins=this.plugins.filter(i=>i!==t),t.destroy()}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const i=t/this.getDuration();this.renderer.setScrollPercentage(i)}getActivePlugins(){return this.plugins}loadAudio(t,i,n,o){return Je(this,void 0,void 0,function*(){var s;if(this.emit("load",t),!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,!i&&!n){const a=this.options.fetchParams||{};window.AbortController&&!a.signal&&(this.abortController=new AbortController,a.signal=this.abortController.signal);const u=h=>this.emit("loading",h);i=yield gL.fetchBlob(t,u,a);const d=this.options.blobMimeType;d&&(i=new Blob([i],{type:d}))}this.setSrc(t,i);const r=yield new Promise(a=>{const u=o||this.getDuration();u?a(u):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>a(this.getDuration()),{once:!0}))});if(!t&&!i){const a=this.getMediaElement();a instanceof G1&&(a.duration=r)}if(n)this.decodedData=S1.createBuffer(n,r||0);else if(i){const a=yield i.arrayBuffer();this.decodedData=yield S1.decode(a,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())})}load(t,i,n){return Je(this,void 0,void 0,function*(){try{return yield this.loadAudio(t,void 0,i,n)}catch(o){throw this.emit("error",o),o}})}loadBlob(t,i,n){return Je(this,void 0,void 0,function*(){try{return yield this.loadAudio("",t,i,n)}catch(o){throw this.emit("error",o),o}})}zoom(t){if(!this.decodedData)throw new Error("No audio loaded");this.renderer.zoom(t),this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:i=8e3,precision:n=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const o=Math.min(t,this.decodedData.numberOfChannels),s=[];for(let r=0;r<o;r++){const a=this.decodedData.getChannelData(r),u=[],d=a.length/i;for(let h=0;h<i;h++){const b=a.slice(Math.floor(h*d),Math.ceil((h+1)*d));let Z=0;for(let y=0;y<b.length;y++){const I=b[y];Math.abs(I)>Math.abs(Z)&&(Z=I)}u.push(Math.round(Z*n)/n)}s.push(u)}return s}getDuration(){let t=super.getDuration()||0;return t!==0&&t!==1/0||!this.decodedData||(t=this.decodedData.duration),t}toggleInteraction(t){this.options.interact=t}setTime(t){this.stopAtPosition=null,super.setTime(t),this.updateProgress(t),this.emit("timeupdate",t)}seekTo(t){const i=this.getDuration()*t;this.setTime(i)}play(t,i){const n=Object.create(null,{play:{get:()=>super.play}});return Je(this,void 0,void 0,function*(){t!=null&&this.setTime(t);const o=yield n.play.call(this);return i!=null&&(this.media instanceof G1?this.media.stopAt(i):this.stopAtPosition=i),o})}playPause(){return Je(this,void 0,void 0,function*(){return this.isPlaying()?this.pause():this.play()})}stop(){this.pause(),this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents(),super.setMediaElement(t),this.initPlayerEvents()}exportImage(){return Je(this,arguments,void 0,function*(t="image/png",i=1,n="dataURL"){return this.renderer.exportImage(t,i,n)})}destroy(){var t;this.emit("destroy"),(t=this.abortController)===null||t===void 0||t.abort(),this.plugins.forEach(i=>i.destroy()),this.subscriptions.forEach(i=>i()),this.unsubscribePlayerEvents(),this.reactiveCleanups.forEach(i=>i()),this.reactiveCleanups=[],this.timer.destroy(),this.renderer.destroy(),super.destroy()}}b1.BasePlugin=class extends C1{constructor(l){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=l}onInit(){}_init(l){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=l,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(l=>l()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}},b1.dom=xL;class RL{constructor(){this.listeners={}}on(t,i,n){if(this.listeners[t]||(this.listeners[t]=new Set),n==null?void 0:n.once){const o=(...s)=>{this.un(t,o),i(...s)};return this.listeners[t].add(o),()=>this.un(t,o)}return this.listeners[t].add(i),()=>this.un(t,i)}un(t,i){var n;(n=this.listeners[t])===null||n===void 0||n.delete(i)}once(t,i){return this.on(t,i,{once:!0})}unAll(){this.listeners={}}emit(t,...i){this.listeners[t]&&this.listeners[t].forEach(n=>n(...i))}}class UL extends RL{constructor(t){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=t}onInit(){}_init(t){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}}function cl(l,t){const i=t.xmlns?document.createElementNS(t.xmlns,l):document.createElement(l);for(const[n,o]of Object.entries(t))if(n==="children"&&o)for(const[s,r]of Object.entries(o))r instanceof Node?i.appendChild(r):typeof r=="string"?i.appendChild(document.createTextNode(r)):i.appendChild(cl(s,r));else n==="style"?Object.assign(i.style,o):n==="textContent"?i.textContent=o:i.setAttribute(n,o.toString());return i}function x1(l,t,i){return cl(l,t||{})}const zL={height:20,timeOffset:0,formatTimeCallback:l=>l/60>1?`${Math.floor(l/60)}:${`${(l=Math.round(l%60))<10?"0":""}${l}`}`:`${Math.round(1e3*l)/1e3}`};class O1 extends UL{constructor(t){super(t||{}),this.notchElements=new Map,this.currentTimeline=null,this.options=Object.assign({},zL,t),this.timelineWrapper=this.initTimelineWrapper()}static create(t){return new O1(t)}onInit(){var t;if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");let i=this.wavesurfer.getWrapper();if(this.options.container instanceof HTMLElement)i=this.options.container;else if(typeof this.options.container=="string"){const o=document.querySelector(this.options.container);if(!o)throw Error(`No Timeline container found matching ${this.options.container}`);i=o}this.options.insertPosition?(i.firstElementChild||i).insertAdjacentElement(this.options.insertPosition,this.timelineWrapper):i.appendChild(this.timelineWrapper);const n=this.wavesurfer.getState();this.subscriptions.push(function(o,s){let r;const a=()=>{r&&(r(),r=void 0),r=o()},u=s.map(d=>d.subscribe(a));return a(),()=>{r&&(r(),r=void 0),u.forEach(d=>d())}}(()=>{(n.duration.value>0||this.options.duration)&&this.initTimeline()},[n.duration])),this.subscriptions.push(this.wavesurfer.on("redraw",()=>this.initTimeline())),this.subscriptions.push(this.wavesurfer.on("scroll",(o,s,r,a)=>{this.currentTimeline&&this.updateVisibleNotches(r,a,this.currentTimeline)})),(!((t=this.wavesurfer)===null||t===void 0)&&t.getDuration()||this.options.duration)&&this.initTimeline()}destroy(){this.timelineWrapper.remove(),super.destroy()}initTimelineWrapper(){return x1("div",{part:"timeline-wrapper",style:{pointerEvents:"none"}})}defaultTimeInterval(t){return t>=25?1:5*t>=25?5:15*t>=25?15:60*Math.ceil(.5/t)}defaultPrimaryLabelInterval(t){return t>=25?10:5*t>=25?6:4}defaultSecondaryLabelInterval(t){return t>=25?5:2}virtualAppend(t,i,n){if(this.notchElements.set(n,{start:t,width:n.clientWidth,wasVisible:!1}),!this.wavesurfer)return;const o=this.wavesurfer.getScroll(),s=o+this.wavesurfer.getWidth(),r=this.notchElements.get(n),a=t>=o&&t+r.width<s;r.wasVisible=a,a&&i.appendChild(n)}updateVisibleNotches(t,i,n){this.notchElements.forEach((o,s)=>{const r=o.start>=t&&o.start+o.width<i;r!==o.wasVisible&&(o.wasVisible=r,r?n.appendChild(s):s.remove())})}initTimeline(){var t,i,n,o,s,r,a,u;this.notchElements.clear();const d=(n=(i=(t=this.wavesurfer)===null||t===void 0?void 0:t.getDuration())!==null&&i!==void 0?i:this.options.duration)!==null&&n!==void 0?n:0,h=(((o=this.wavesurfer)===null||o===void 0?void 0:o.getWrapper().scrollWidth)||this.timelineWrapper.scrollWidth)/d,b=(s=this.options.timeInterval)!==null&&s!==void 0?s:this.defaultTimeInterval(h),Z=(r=this.options.primaryLabelInterval)!==null&&r!==void 0?r:this.defaultPrimaryLabelInterval(h),y=this.options.primaryLabelSpacing,I=(a=this.options.secondaryLabelInterval)!==null&&a!==void 0?a:this.defaultSecondaryLabelInterval(h),V=this.options.secondaryLabelSpacing,m=this.options.insertPosition==="beforebegin",j=x1("div",{style:Object.assign({height:`${this.options.height}px`,overflow:"hidden",fontSize:this.options.height/2+"px",whiteSpace:"nowrap"},m?{position:"absolute",top:"0",left:"0",right:"0",zIndex:"2"}:{position:"relative"})});j.setAttribute("part","timeline"),typeof this.options.style=="string"?j.setAttribute("style",j.getAttribute("style")+this.options.style):typeof this.options.style=="object"&&Object.assign(j.style,this.options.style);const X=x1("div",{style:{width:"0",height:"50%",display:"flex",flexDirection:"column",justifyContent:m?"flex-start":"flex-end",top:m?"0":"auto",bottom:m?"auto":"0",overflow:"visible",borderLeft:"1px solid currentColor",opacity:`${(u=this.options.secondaryLabelOpacity)!==null&&u!==void 0?u:.25}`,position:"absolute",zIndex:"1"}});for(let Y=0,x=0;Y<d;Y+=b,x++){const G=X.cloneNode(),L=Math.round(100*Y)%Math.round(100*Z)==0||y&&x%y==0,p=Math.round(100*Y)%Math.round(100*I)==0||V&&x%V==0;(L||p)&&(G.style.height="100%",G.style.textIndent="3px",G.textContent=this.options.formatTimeCallback(Y),L&&(G.style.opacity="1"));const w=L?"primary":p?"secondary":"tick";G.setAttribute("part",`timeline-notch timeline-notch-${w}`);const W=(Y+this.options.timeOffset)*h;G.style.left=`${W}px`,this.virtualAppend(W,j,G)}this.timelineWrapper.innerHTML="",this.timelineWrapper.appendChild(j),this.currentTimeline=j,this.emit("ready")}}const Y1={WAVE_DEFAULT:"#D9D9D9",PROGRESS:"#F2994A"},OL={key:0,class:"vt-audio__empty"},DL={key:1},PL={class:"vt-audio__wave-area"},HL=["id"],BL={class:"vt-audio__controls"},_L=["disabled"],QL=["disabled"],AL=["disabled"],rl=e.defineComponent({__name:"VAudio",props:{recordUrl:{default:""},userA:{default:""},userB:{default:""},disabled:{type:Boolean,default:!1},type:{default:"default"}},emits:["timeUpdate","play","pause","ended","error"],setup(l,{expose:t,emit:i}){const{t:n}=Le(),o=l,s=i,r=e.computed(()=>!!(o.userA||o.userB)),a=e.ref(!1),u=e.computed(()=>o.disabled||a.value),d=e.ref(!1),h=e.ref(1),b=e.ref(`ws-${Math.random().toString(36).slice(2,9)}`),Z=e.ref(null),y=e.ref(null),I=e.ref(null),V=e.ref(null),m=e.ref(null),j=e.computed(()=>o.type==="channel-routed"),X=(T,U)=>{var q;const{width:A,height:oe}=U.canvas,N=(q=Z.value)==null?void 0:q.decodedData;if(!T.length&&!N){U.fillStyle=Y1.WAVE_DEFAULT,U.fillRect(0,oe/2,A,2);return}const K=r.value&&N&&N.numberOfChannels>=2?[N.getChannelData(0),N.getChannelData(1)]:[T[0]||new Float32Array(A).fill(0)];U.clearRect(0,0,A,oe);const z=20;K.forEach((ee,ne)=>{const ye=oe/K.length,re=ye-(r.value?z:0),se=ne*ye+(r.value?z:0)+re/2,be=ee.length/A;let Se=0;for(let he=0;he<ee.length;he+=100){const k=Math.abs(ee[he]??0);k>Se&&(Se=k)}Se===0&&(Se=1),U.fillStyle=Y1.WAVE_DEFAULT;for(let he=0;he<A;he+=2){const k=Math.floor(he*be),D=Math.min(Math.floor((he+2)*be),ee.length-1);let H=0;for(let Me=k;Me<=D;Me++){const Te=Math.abs(ee[Me]??0);Te>H&&(H=Te)}const Ze=H/Se,We=Math.max(Ze*re*.85,2);U.fillRect(he,se-We/2,1.5,We)}if(r.value){U.fillStyle="#999999",U.font="12px Inter, sans-serif",U.textAlign="right";const he=(ne===0?o.userA:o.userB)??"";U.fillText(he,A-10,ne*ye+z-5)}})},Y=()=>{var N;const T=(N=Z.value)==null?void 0:N.getMediaElement();if(!T)return;I.value=new(window.AudioContext||window.webkitAudioContext);const U=I.value.createMediaElementSource(T),A=I.value.createChannelSplitter(2),oe=I.value.createChannelMerger(2);V.value=I.value.createGain(),m.value=I.value.createGain(),V.value.gain.value=L.value,m.value.gain.value=p.value,U.connect(A),A.connect(V.value,0),A.connect(m.value,1),V.value.connect(oe,0,0),m.value.connect(oe,0,1),oe.connect(I.value.destination)},x=()=>{var T;(T=I.value)==null||T.close(),I.value=null,V.value=null,m.value=null},G=()=>{if(!o.recordUrl)return;a.value=!1;const T=b1.create({container:`#waveform-${b.value}`,waveColor:Y1.WAVE_DEFAULT,progressColor:Y1.PROGRESS,barWidth:2,height:j.value?36:r.value?100:50,plugins:j.value?[]:[O1.create({container:y.value,style:{fontSize:"10px",color:"#999"}})],renderFunction:(U,A)=>X(U,A)});Z.value=T,Z.value.on("play",()=>{d.value=!0,s("play")}),Z.value.on("pause",()=>{d.value=!1,s("pause")}),Z.value.on("timeupdate",U=>s("timeUpdate",U)),Z.value.on("finish",()=>{d.value=!1,s("ended")}),Z.value.on("error",()=>{a.value=!0,s("error")}),(r.value||j.value)&&Z.value.on("ready",()=>{Y(),S()}),Z.value.load(o.recordUrl)},L=e.ref(1),p=e.ref(1),w=T=>{const U=T===0?V.value:m.value,A=T===0?L:p;A.value=A.value?0:1,U&&(U.gain.value=A.value)},W={x:5,y:0,size:18},S=()=>{const T=document.querySelector(`#waveform-${b.value} canvas`);!T||!r.value||T.addEventListener("click",U=>{if(u.value)return;const A=T.getBoundingClientRect(),oe=U.clientX-A.left,N=U.clientY-A.top,K=A.height/2;[0,1].forEach(z=>{const q=z*K+W.y;oe>=W.x&&oe<=W.x+W.size&&N>=q&&N<=q+W.size&&(U.stopPropagation(),U.preventDefault(),w(z))})})},J=async()=>{if(!(!Z.value||u.value)){if(j.value){const T=Z.value.getMediaElement();if(!T||!I.value)return;I.value.state==="suspended"&&await I.value.resume(),T.paused?await T.play():T.pause();return}d.value?Z.value.pause():Z.value.play()}},E=T=>{var U;h.value=T,(U=Z.value)==null||U.setPlaybackRate(h.value)},g=(T,U)=>{if(T.startsWith("data:")){const oe=document.createElement("a");oe.href=T,oe.download=U,document.body.appendChild(oe),oe.click(),document.body.removeChild(oe)}else fetch(T).then(oe=>oe.blob()).then(oe=>{const N=document.createElement("a");N.href=URL.createObjectURL(oe),N.download=U,document.body.appendChild(N),N.click(),document.body.removeChild(N)}).catch(console.error)},f=()=>{if(o.disabled||!o.recordUrl)return;const T=o.recordUrl.indexOf("?"),U=o.recordUrl.substring(o.recordUrl.lastIndexOf("/")+1,T===-1?void 0:T);g(o.recordUrl,U)};return e.onMounted(()=>e.nextTick(G)),e.onBeforeUnmount(()=>{var T;(T=Z.value)==null||T.destroy(),x()}),e.watch(()=>o.recordUrl,()=>{var T;(T=Z.value)==null||T.destroy(),x(),e.nextTick(G)}),t({play:()=>{var T;return(T=Z.value)==null?void 0:T.play()},pause:()=>{var T;return(T=Z.value)==null?void 0:T.pause()},getCurrentTime:()=>{var T;return((T=Z.value)==null?void 0:T.getCurrentTime())||0}}),(T,U)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vt-audio",{"is-disabled":u.value,"is-channel-routed":j.value}])},[l.recordUrl?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["vt-audio__container",{"is-single-channel":!r.value,"is-channel-routed":j.value}])},[e.createElementVNode("div",PL,[e.createElementVNode("div",{id:`waveform-${b.value}`,class:"vt-audio__waveform"},null,8,HL),j.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"timelineContainer",ref:y,class:"vt-audio__timeline"},null,512))]),e.createElementVNode("div",BL,[j.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("button",{class:"vt-audio__btn",disabled:u.value,onClick:f},[e.createVNode(ue,{name:"import",width:"20",height:"20"})],8,_L),e.createVNode(n1,{trigger:"click",placement:"top",disabled:u.value,onCommand:E},{dropdown:e.withCtx(()=>[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList([1,1.5,2],A=>e.createVNode(s1,{key:A,command:A,class:e.normalizeClass({"is-active":h.value===A})},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(A)+"x ",1)]),_:2},1032,["command","class"])),64))]),default:e.withCtx(()=>[e.createElementVNode("button",{class:"vt-audio__speed-val",disabled:u.value},e.toDisplayString(h.value)+"x",9,QL)]),_:1},8,["disabled"])],64)),e.createElementVNode("button",{class:"vt-audio__btn vt-audio__btn--main",disabled:u.value,onClick:J},[d.value?e.renderSlot(T.$slots,"icon-pause",{key:0},()=>[e.createVNode(ue,{name:"pause",width:"24",height:"24"})]):e.renderSlot(T.$slots,"icon-play",{key:1},()=>[e.createVNode(ue,{name:"start",width:"24",height:"24"})])],8,AL)])],2)):(e.openBlock(),e.createElementBlock("div",OL,[e.renderSlot(T.$slots,"empty",{},()=>[j.value?(e.openBlock(),e.createElementBlock("span",DL,e.toDisplayString(e.unref(n)(e.unref(c).AUDIO_EMPTY)),1)):(e.openBlock(),e.createBlock(T1,{key:0,icon:"noSound",text:e.unref(n)(e.unref(c).AUDIO_EMPTY)},null,8,["text"]))])]))],2))}}),$L=new Set(["p","div","br","hr","h1","h2","h3","h4","h5","h6","blockquote","pre","code","ul","ol","li","b","strong","i","em","u","s","strike","del","sub","sup","font","span","a","img","table","thead","tbody","tfoot","tr","th","td","caption"]),qL=new Set(["style","class","href","target","rel","src","alt","width","height","face","size","color","colspan","rowspan"]),eW=new Set(["behavior","-moz-binding","filter"]),tW=/expression\s*\(|javascript\s*:|vbscript\s*:/i;function lW(l){const t=document.createElement("span");t.setAttribute("style",l);const i=t.style,n=[];for(let o=0;o<i.length;o++){const s=i[o],r=i.getPropertyValue(s);eW.has(s)||tW.test(r)||/url\s*\(/i.test(r)&&!/url\s*\(\s*['"]?data:image\//i.test(r)||n.push(`${s}:${r}`)}return n.join(";")}const iW=new Set(["https:","http:","ftp:","mailto:","tel:"]);function oW(l){const t=l.trim();if(t.startsWith("/")||t.startsWith(".")||t.startsWith("#"))return!0;try{const i=new URL(t);return iW.has(i.protocol)}catch{return!/^[a-z][a-z0-9+\-.]*:/i.test(t)}}function al(l){var s,r,a;if(l.nodeType===Node.COMMENT_NODE||l.nodeType===Node.PROCESSING_INSTRUCTION_NODE){(s=l.parentNode)==null||s.removeChild(l);return}if(l.nodeType!==Node.ELEMENT_NODE)return;const t=l,i=t.tagName.toLowerCase();if(!$L.has(i)){for(;t.firstChild;)(r=t.parentNode)==null||r.insertBefore(t.firstChild,t);(a=t.parentNode)==null||a.removeChild(t);return}const n=Array.from(t.attributes);for(const u of n){const d=u.name.toLowerCase();if(d.startsWith("on")){t.removeAttribute(u.name);continue}if(!qL.has(d)){t.removeAttribute(u.name);continue}if((d==="href"||d==="src")&&!oW(u.value)){t.removeAttribute(u.name);continue}if(d==="style"){const h=lW(u.value);h?t.setAttribute("style",h):t.removeAttribute("style");continue}}i==="a"&&t.getAttribute("target")==="_blank"&&t.setAttribute("rel","noopener noreferrer");const o=Array.from(t.childNodes);for(let u=o.length-1;u>=0;u--)al(o[u])}function a1(l){if(!l)return"";const t=new DOMParser().parseFromString(l,"text/html");t.head.innerHTML="";const i=Array.from(t.body.childNodes);for(let n=i.length-1;n>=0;n--)al(i[n]);return t.body.innerHTML}function at(l){const t=document.createElement("div");return t.innerHTML=l,t.textContent??t.innerText??""}function nW(l,t){function i(d,h){l.value&&(l.value.focus(),document.execCommand(d,!1,h??""),t())}function n(d){try{return document.queryCommandState(d)}catch{return!1}}function o(d){l.value&&(l.value.focus(),document.execCommand("formatBlock",!1,d),t())}function s(d){l.value&&(l.value.focus(),document.execCommand("fontName",!1,d),t())}function r(d){l.value&&(l.value.focus(),document.execCommand("foreColor",!1,d),t())}function a(d){l.value&&(l.value.focus(),document.execCommand("hiliteColor",!1,d),t())}function u(d){const h=window.getSelection();if(!h||h.rangeCount===0)return;let b=h.anchorNode;b.nodeType===Node.TEXT_NODE&&(b=b.parentElement);const Z=b.closest(".vt-editor__content > *");if(!Z)return;const y=parseInt(Z.style.marginLeft||"0",10),I=20,V=d==="indent"?y+I:Math.max(0,y-I);Z.style.marginLeft=V?`${V}px`:"",t()}return{exec:i,isActive:n,applyBlock:o,applyFont:s,applyForeColor:r,applyBackColor:a,handleIndent:u}}function sW(){let l=null;function t(){const s=window.getSelection();s&&s.rangeCount>0&&(l=s.getRangeAt(0).cloneRange())}function i(){if(!l)return;const s=window.getSelection();s&&(s.removeAllRanges(),s.addRange(l))}function n(){l=null}function o(){return l}return{saveSelection:t,restoreSelection:i,clearSavedRange:n,getSavedRange:o}}function cW(l,t){const{saveSelection:i,restoreSelection:n,clearSavedRange:o,getSavedRange:s}=sW(),r=e.ref({visible:!1,url:"",text:"",openInNewTab:!1});function a(){var j,X;i();const I=window.getSelection(),V=(I==null?void 0:I.toString())??"",m=(X=(j=I==null?void 0:I.anchorNode)==null?void 0:j.parentElement)==null?void 0:X.closest("a");r.value={visible:!0,url:(m==null?void 0:m.getAttribute("href"))??"",text:V,openInNewTab:(m==null?void 0:m.getAttribute("target"))==="_blank"}}function u(){n();const{url:I,text:V,openInNewTab:m}=r.value;if(!I){d();return}const j=document.createElement("a");j.href=I,j.textContent=V||I,m&&j.setAttribute("target","_blank"),j.setAttribute("rel","noopener noreferrer");const X=s(),Y=window.getSelection();Y&&Y.rangeCount>0&&X?(X.deleteContents(),X.insertNode(j)):l(j.outerHTML),d(),t()}function d(){r.value={visible:!1,url:"",text:"",openInNewTab:!1},o()}const h=e.ref({visible:!1,url:"",alt:""});function b(){i(),h.value={visible:!0,url:"",alt:""}}function Z(){n();const{url:I,alt:V}=h.value;if(!I){y();return}l(`<img src="${I}" alt="${V}" style="max-width:100%;" />`),y()}function y(){h.value={visible:!1,url:"",alt:""},o()}return{linkState:r,openLinkDialog:a,confirmLink:u,cancelLink:d,imageState:h,openImageDialog:b,confirmImage:Z,cancelImage:y}}const xe={undo:"undo",redo:"redo",bold:"textBold",italic:"textItalic",underline:"textUnderline",strikethrough:"textStrikethrough",subscript:"subscript",superscript:"superscript",orderedList:"orderedList",unorderedList:"unorderedList",indent:"indent",outdent:"outdent",alignLeft:"alignLeft",alignCenter:"alignCenter",alignRight:"alignRight",alignJustify:"alignJustify",link:"link",image:"image",blockquote:"blockquote",clearFormat:"clearFormat",html:"html"},rW=[{value:"p",label:"Paragraph"},{value:"h1",label:"Heading 1"},{value:"h2",label:"Heading 2"},{value:"h3",label:"Heading 3"},{value:"h4",label:"Heading 4"}],aW=[{value:"Arial",label:"Arial"},{value:"Times New Roman",label:"Times New Roman"},{value:"Courier New",label:"Courier New"},{value:"Georgia",label:"Georgia"},{value:"Verdana",label:"Verdana"}];function dW(l,t){const{t:i}=Le(),n=e.ref(0);function o(){n.value++}function s(u){var d;return n.value,((d=u.activeCheck)==null?void 0:d.call(u))??!1}function r(u){const d=[];return u.forEach((h,b)=>{switch(b>0&&d.push({type:"separator"}),h){case"history":d.push({type:"button",id:"undo",tooltip:i(c.EDITOR_UNDO),iconName:xe.undo,action:()=>t.exec("undo")},{type:"button",id:"redo",tooltip:i(c.EDITOR_REDO),iconName:xe.redo,action:()=>t.exec("redo")});break;case"format":d.push({type:"button",id:"bold",tooltip:i(c.EDITOR_BOLD),iconName:xe.bold,action:()=>t.exec("bold"),activeCheck:()=>t.isActive("bold")},{type:"button",id:"italic",tooltip:i(c.EDITOR_ITALIC),iconName:xe.italic,action:()=>t.exec("italic"),activeCheck:()=>t.isActive("italic")},{type:"button",id:"underline",tooltip:i(c.EDITOR_UNDERLINE),iconName:xe.underline,action:()=>t.exec("underline"),activeCheck:()=>t.isActive("underline")},{type:"button",id:"strikethrough",tooltip:i(c.EDITOR_STRIKETHROUGH),iconName:xe.strikethrough,action:()=>t.exec("strikethrough"),activeCheck:()=>t.isActive("strikeThrough")});break;case"script":d.push({type:"button",id:"subscript",tooltip:i(c.EDITOR_SUBSCRIPT),iconName:xe.subscript,action:()=>t.exec("subscript"),activeCheck:()=>t.isActive("subscript")},{type:"button",id:"superscript",tooltip:i(c.EDITOR_SUPERSCRIPT),iconName:xe.superscript,action:()=>t.exec("superscript"),activeCheck:()=>t.isActive("superscript")});break;case"heading":d.push({type:"select",id:"heading"});break;case"fontName":d.push({type:"select",id:"fontName"});break;case"foreColor":d.push({type:"select",id:"foreColor"});break;case"align":d.push({type:"button",id:"alignLeft",tooltip:i(c.EDITOR_ALIGN_LEFT),iconName:xe.alignLeft,action:()=>t.exec("justifyLeft"),activeCheck:()=>t.isActive("justifyLeft")},{type:"button",id:"alignCenter",tooltip:i(c.EDITOR_ALIGN_CENTER),iconName:xe.alignCenter,action:()=>t.exec("justifyCenter"),activeCheck:()=>t.isActive("justifyCenter")},{type:"button",id:"alignRight",tooltip:i(c.EDITOR_ALIGN_RIGHT),iconName:xe.alignRight,action:()=>t.exec("justifyRight"),activeCheck:()=>t.isActive("justifyRight")},{type:"button",id:"alignJustify",tooltip:i(c.EDITOR_ALIGN_JUSTIFY),iconName:xe.alignJustify,action:()=>t.exec("justifyFull"),activeCheck:()=>t.isActive("justifyFull")});break;case"list":d.push({type:"button",id:"orderedList",tooltip:i(c.EDITOR_ORDERED_LIST),iconName:xe.orderedList,action:()=>t.exec("insertOrderedList"),activeCheck:()=>t.isActive("insertOrderedList")},{type:"button",id:"unorderedList",tooltip:i(c.EDITOR_UNORDERED_LIST),iconName:xe.unorderedList,action:()=>t.exec("insertUnorderedList"),activeCheck:()=>t.isActive("insertUnorderedList")});break;case"indent":d.push({type:"button",id:"indent",tooltip:i(c.EDITOR_INDENT),iconName:xe.indent,action:()=>t.handleIndent("indent")},{type:"button",id:"outdent",tooltip:i(c.EDITOR_OUTDENT),iconName:xe.outdent,action:()=>t.handleIndent("outdent")});break;case"link":d.push({type:"button",id:"link",tooltip:i(c.EDITOR_INSERT_LINK),iconName:xe.link,action:t.openLinkDialog});break;case"image":d.push({type:"button",id:"image",tooltip:i(c.EDITOR_INSERT_IMAGE),iconName:xe.image,action:t.openImageDialog});break;case"blockquote":d.push({type:"button",id:"blockquote",tooltip:i(c.EDITOR_BLOCKQUOTE),iconName:xe.blockquote,action:()=>t.applyBlock("blockquote")});break;case"clear":d.push({type:"button",id:"clear",tooltip:i(c.EDITOR_CLEAR_FORMAT),iconName:xe.clearFormat,action:()=>t.exec("removeFormat")});break;case"html":d.push({type:"button",id:"html",tooltip:i(c.EDITOR_HTML_SOURCE),iconName:xe.html,action:t.toggleHtmlMode,activeCheck:t.isHtmlMode});break}}),d}return{toolbarItems:e.computed(()=>r(l())),selectionTick:n,onSelectionChange:o,getItemActive:s,HEADING_GROUPS:rW,FONT_GROUPS:aW}}const mW={key:0,class:"vt-editor__toolbar-wrapper"},uW={key:0,class:"vt-editor__toolbar-sep"},hW=["value"],IW=["value"],pW=["onClick"],ZW={class:"vt-editor__body"},bW=["contenteditable","data-placeholder"],CW={key:1,class:"vt-editor__error"},yW={class:"vt-editor__dialog-fields"},VW={class:"vt-editor__dialog-label"},SW={class:"vt-editor__dialog-label"},YW={class:"vt-editor__dialog-checkbox"},LW={class:"vt-modal__footer"},WW={class:"vt-editor__dialog-fields"},kW={class:"vt-editor__dialog-label"},MW={class:"vt-editor__dialog-label"},NW={class:"vt-modal__footer"},dl=e.defineComponent({__name:"VEditor",props:{modelValue:{},placeholder:{},toolbar:{default:()=>["history","format","heading","fontName","foreColor","align","list","indent","link","image","blockquote","clear","html"]},disabled:{type:Boolean,default:!1},required:{type:Boolean},errorMessage:{}},emits:["update:modelValue","input","change","focus","blur","validation"],setup(l,{expose:t,emit:i}){const{t:n}=Le(),o=l,s=i,r=e.ref(null),a=e.ref(null),u=e.ref(null),d=e.ref(!1),h=e.ref(!1),b=e.ref(""),Z=e.ref([]),y=e.ref(!0),I=e.ref(!1),V=e.ref(!1),m=e.ref("#000000"),j=e.ref("#ffffff");function X(Q){var v;const P=Q??((v=r.value)==null?void 0:v.innerHTML)??"",me=a1(P);s("update:modelValue",me),s("input",me)}const{exec:Y,isActive:x,applyBlock:G,applyFont:L,applyForeColor:p,applyBackColor:w,handleIndent:W}=nW(r,X);function S(){if(r.value)if(!h.value)b.value=r.value.innerHTML,h.value=!0,e.nextTick(()=>{var Q;return(Q=u.value)==null?void 0:Q.focus()});else{const Q=a1(b.value);h.value=!1,e.nextTick(()=>{r.value&&(r.value.innerHTML=Q,X(Q),r.value.focus())})}}function J(){const Q=a1(b.value);s("update:modelValue",Q),s("input",Q)}const{linkState:E,openLinkDialog:g,confirmLink:f,cancelLink:T,imageState:U,openImageDialog:A,confirmImage:oe,cancelImage:N}=cW(Q=>Y("insertHTML",Q),X),{toolbarItems:K,onSelectionChange:z,getItemActive:q,HEADING_GROUPS:ee,FONT_GROUPS:ne}=dW(()=>o.toolbar,{exec:Y,isActive:x,applyBlock:G,applyFont:L,handleIndent:W,openLinkDialog:g,openImageDialog:A,toggleHtmlMode:S,isHtmlMode:()=>h.value});function ye(Q){const P=Q.target.value;m.value=P,p(P)}function re(Q){const P=Q.target.value;j.value=P,w(P)}function se(){const Q=a.value;Q&&(I.value=Q.scrollLeft>2,V.value=Q.scrollLeft+Q.clientWidth<Q.scrollWidth-2)}function be(Q){const P=a.value;P&&(P.scrollBy({left:Q==="left"?-160:160,behavior:"smooth"}),setTimeout(se,250))}function Se(Q){const P=[];o.required&&!at(Q).trim()&&P.push(n(c.VALIDATION_REQUIRED)),Z.value=P,y.value=P.length===0,s("validation",{isValid:y.value,errors:P})}const he=e.computed(()=>o.errorMessage||Z.value[0]||""),k=e.computed(()=>!!he.value),D=e.computed(()=>["vt-editor",{"vt-editor--focused":d.value,"vt-editor--error":k.value,"vt-editor--disabled":o.disabled}]);function H(){X(),Se(o.modelValue??"")}function Ze(Q){d.value=!0,s("focus",Q)}function We(Q){d.value=!1,s("blur",Q),Se(o.modelValue??"")}function Me(Q){Q.key==="Tab"&&(Q.preventDefault(),Y("insertHTML","&nbsp;&nbsp;&nbsp;&nbsp;"))}e.watch(()=>o.modelValue,Q=>{!r.value||d.value||h.value||r.value.innerHTML!==Q&&(r.value.innerHTML=Q??"")}),e.onMounted(()=>{r.value&&o.modelValue&&(r.value.innerHTML=a1(o.modelValue)),document.addEventListener("selectionchange",z),e.nextTick(()=>{se();const Q=new ResizeObserver(se);a.value&&Q.observe(a.value)}),window.addEventListener("resize",se)}),e.onBeforeUnmount(()=>{document.removeEventListener("selectionchange",z),window.removeEventListener("resize",se)});function Te(){var Q;(Q=r.value)==null||Q.focus()}function Qe(){var Q;(Q=r.value)==null||Q.blur()}function Ke(){r.value&&(r.value.innerHTML=""),X(""),Z.value=[],y.value=!0,s("validation",{isValid:!0,errors:[]})}function Ae(){var Q;return((Q=r.value)==null?void 0:Q.innerHTML)??""}function Ue(){var Q;return at(((Q=r.value)==null?void 0:Q.innerHTML)??"")}function He(Q){const P=a1(Q);r.value&&(r.value.innerHTML=P),X(P)}function je(Q){var P;(P=r.value)==null||P.focus(),Y("insertHTML",a1(Q))}function ve(){return Se(o.modelValue??""),y.value}function qe(){Z.value=[],y.value=!0,s("validation",{isValid:!0,errors:[]})}function le(){return{isValid:y.value,errors:[...Z.value]}}function ce(){return r.value}return t({focus:Te,blur:Qe,clear:Ke,getHTML:Ae,getText:Ue,setHTML:He,insertHTML:je,validate:ve,clearValidation:qe,getValidationState:le,getEditorElement:ce}),(Q,P)=>{const me=e.resolveDirective("tooltip");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(D.value)},[!l.disabled&&e.unref(K).length?(e.openBlock(),e.createElementBlock("div",mW,[I.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"vt-editor__toolbar-scroll-btn vt-editor__toolbar-scroll-btn--left",type:"button",onClick:P[0]||(P[0]=v=>be("left")),onMousedown:P[1]||(P[1]=e.withModifiers(()=>{},["prevent"]))},[e.createVNode(ue,{name:"arrowLeft"})],32)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"toolbarRef",ref:a,class:"vt-editor__toolbar",onScroll:se},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(K),(v,_)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:_},[(v==null?void 0:v.type)==="separator"?(e.openBlock(),e.createElementBlock("span",uW)):(v==null?void 0:v.type)==="select"&&v.id==="heading"?(e.openBlock(),e.createBlock(n1,{key:1,"max-height":220,class:"vt-editor__toolbar-btn",placement:"bottom-start",trigger:"hover",onMousedown:P[3]||(P[3]=e.withModifiers(()=>{},["prevent"]))},{dropdown:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(ee),M=>(e.openBlock(),e.createBlock(s1,{key:M.value,onClick:$=>e.unref(G)(M.value),onMousedown:P[2]||(P[2]=e.withModifiers(()=>{},["prevent"]))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(M.label),1)]),_:2},1032,["onClick"]))),128))]),default:e.withCtx(()=>[e.withDirectives(e.createVNode(ue,{name:"tagType"},null,512),[[me,e.unref(n)(e.unref(c).EDITOR_HEADING)]])]),_:1})):(v==null?void 0:v.type)==="select"&&v.id==="fontName"?(e.openBlock(),e.createBlock(n1,{key:2,"max-height":220,class:"vt-editor__toolbar-btn",placement:"bottom-start",trigger:"hover",onMousedown:P[5]||(P[5]=e.withModifiers(()=>{},["prevent"]))},{dropdown:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(ne),M=>(e.openBlock(),e.createBlock(s1,{key:M.value,onClick:$=>e.unref(L)(M.value),onMousedown:P[4]||(P[4]=e.withModifiers(()=>{},["prevent"]))},{default:e.withCtx(()=>[e.createElementVNode("span",{style:e.normalizeStyle({fontFamily:M.value})},e.toDisplayString(M.label),5)]),_:2},1032,["onClick"]))),128))]),default:e.withCtx(()=>[e.withDirectives(e.createVNode(ue,{name:"fontName"},null,512),[[me,e.unref(n)(e.unref(c).EDITOR_FONT)]])]),_:1})):(v==null?void 0:v.type)==="select"&&v.id==="foreColor"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.withDirectives(e.createElementVNode("input",{value:m.value,class:"vt-editor__color-picker",type:"color",onInput:ye,onMousedown:P[6]||(P[6]=e.withModifiers(()=>{},["stop"]))},null,40,hW),[[me,e.unref(n)(e.unref(c).EDITOR_FORE_COLOR)]]),e.withDirectives(e.createElementVNode("input",{value:j.value,class:"vt-editor__color-picker vt-editor__color-picker--bg",type:"color",onInput:re,onMousedown:P[7]||(P[7]=e.withModifiers(()=>{},["stop"]))},null,40,IW),[[me,e.unref(n)(e.unref(c).EDITOR_BACK_COLOR)]])],64)):(v==null?void 0:v.type)==="button"?e.withDirectives((e.openBlock(),e.createElementBlock("button",{key:4,class:e.normalizeClass([{"vt-editor__toolbar-btn--active":e.unref(q)(v)},"vt-editor__toolbar-btn"]),type:"button",onClick:M=>{var $;return($=v==null?void 0:v.action)==null?void 0:$.call(v)},onMousedown:P[8]||(P[8]=e.withModifiers(()=>{},["prevent"]))},[v!=null&&v.iconName?(e.openBlock(),e.createBlock(ue,{key:0,name:v.iconName},null,8,["name"])):e.createCommentVNode("",!0)],42,pW)),[[me,v==null?void 0:v.tooltip]]):e.createCommentVNode("",!0)],64))),128))],544),V.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:"vt-editor__toolbar-scroll-btn vt-editor__toolbar-scroll-btn--right",type:"button",onClick:P[9]||(P[9]=v=>be("right")),onMousedown:P[10]||(P[10]=e.withModifiers(()=>{},["prevent"]))},[e.createVNode(ue,{name:"arrowRight"})],32)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",ZW,[e.withDirectives(e.createElementVNode("div",{ref_key:"editorRef",ref:r,contenteditable:!l.disabled,"data-placeholder":l.placeholder,class:"vt-editor__content",onBlur:We,onFocus:Ze,onInput:H,onKeydown:Me},null,40,bW),[[e.vShow,!h.value]]),h.value?e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{key:0,ref_key:"htmlSourceRef",ref:u,"onUpdate:modelValue":P[11]||(P[11]=v=>b.value=v),class:"vt-editor__html-source",onInput:J},null,544)),[[e.vModelText,b.value]]):e.createCommentVNode("",!0)]),he.value?(e.openBlock(),e.createElementBlock("div",CW,e.toDisplayString(he.value),1)):e.createCommentVNode("",!0),e.createVNode(Z1,{modelValue:e.unref(E).visible,"onUpdate:modelValue":P[19]||(P[19]=v=>e.unref(E).visible=v),"close-on-backdrop-click":!1,title:e.unref(n)(e.unref(c).EDITOR_LINK_TITLE),size:"small",onClose:e.unref(T)},{default:e.withCtx(()=>[e.createElementVNode("div",yW,[e.createElementVNode("label",VW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_LINK_URL)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[12]||(P[12]=v=>e.unref(E).url=v),class:"vt-editor__dialog-input",placeholder:"https://example.com",type:"url",onKeydown:[P[13]||(P[13]=e.withKeys((...v)=>e.unref(f)&&e.unref(f)(...v),["enter"])),P[14]||(P[14]=e.withKeys((...v)=>e.unref(T)&&e.unref(T)(...v),["esc"]))]},null,544),[[e.vModelText,e.unref(E).url]]),e.createElementVNode("label",SW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_LINK_TEXT)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[15]||(P[15]=v=>e.unref(E).text=v),class:"vt-editor__dialog-input",placeholder:"Link text",type:"text",onKeydown:[P[16]||(P[16]=e.withKeys((...v)=>e.unref(f)&&e.unref(f)(...v),["enter"])),P[17]||(P[17]=e.withKeys((...v)=>e.unref(T)&&e.unref(T)(...v),["esc"]))]},null,544),[[e.vModelText,e.unref(E).text]]),e.createElementVNode("label",YW,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[18]||(P[18]=v=>e.unref(E).openInNewTab=v),type:"checkbox"},null,512),[[e.vModelCheckbox,e.unref(E).openInNewTab]]),e.createTextVNode(" "+e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_LINK_NEW_TAB)),1)])]),e.createElementVNode("div",LW,[e.createVNode(Ge,{onClick:e.unref(T)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).BUTTON_CANCEL)),1)]),_:1},8,["onClick"]),e.createVNode(Ge,{type:"primary",onClick:e.unref(f)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_INSERT)),1)]),_:1},8,["onClick"])])]),_:1},8,["modelValue","title","onClose"]),e.createVNode(Z1,{modelValue:e.unref(U).visible,"onUpdate:modelValue":P[26]||(P[26]=v=>e.unref(U).visible=v),"close-on-backdrop-click":!1,title:e.unref(n)(e.unref(c).EDITOR_IMAGE_TITLE),size:"small",onClose:e.unref(N)},{default:e.withCtx(()=>[e.createElementVNode("div",WW,[e.createElementVNode("label",kW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_IMAGE_URL)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[20]||(P[20]=v=>e.unref(U).url=v),class:"vt-editor__dialog-input",placeholder:"https://example.com/image.png",type:"url",onKeydown:[P[21]||(P[21]=e.withKeys((...v)=>e.unref(oe)&&e.unref(oe)(...v),["enter"])),P[22]||(P[22]=e.withKeys((...v)=>e.unref(N)&&e.unref(N)(...v),["esc"]))]},null,544),[[e.vModelText,e.unref(U).url]]),e.createElementVNode("label",MW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_IMAGE_ALT)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":P[23]||(P[23]=v=>e.unref(U).alt=v),class:"vt-editor__dialog-input",placeholder:"Image description",type:"text",onKeydown:[P[24]||(P[24]=e.withKeys((...v)=>e.unref(oe)&&e.unref(oe)(...v),["enter"])),P[25]||(P[25]=e.withKeys((...v)=>e.unref(N)&&e.unref(N)(...v),["esc"]))]},null,544),[[e.vModelText,e.unref(U).alt]])]),e.createElementVNode("div",NW,[e.createVNode(Ge,{onClick:e.unref(N)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).BUTTON_CANCEL)),1)]),_:1},8,["onClick"]),e.createVNode(Ge,{type:"primary",onClick:e.unref(oe)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_INSERT)),1)]),_:1},8,["onClick"])])]),_:1},8,["modelValue","title","onClose"])],2)}}}),XW={class:"vt-badge"},D1=e.defineComponent({__name:"VBadge",props:{content:{default:void 0},max:{default:99},dot:{type:Boolean,default:!1},color:{default:"danger"},position:{default:"top-end"},offsetX:{default:0},offsetY:{default:0},bordered:{type:Boolean,default:!1},hidden:{type:Boolean,default:!1}},setup(l){const t=l,i=e.computed(()=>t.dot?!0:t.content===void 0||t.content===null||t.content===""?!1:typeof t.content=="number"?t.content>0:!0),n=e.computed(()=>i.value&&!t.hidden),o=e.computed(()=>typeof t.content=="number"?t.content>t.max?`${t.max}+`:String(t.content):t.content),s=e.computed(()=>{if(!t.offsetX&&!t.offsetY)return{};const r=t.position.startsWith("top"),a=t.position.endsWith("end"),u={};return t.offsetX&&(u[a?"right":"left"]=`${-t.offsetX}px`),t.offsetY&&(u[r?"top":"bottom"]=`${-t.offsetY}px`),u});return(r,a)=>(e.openBlock(),e.createElementBlock("span",XW,[e.renderSlot(r.$slots,"default"),e.createVNode(e.Transition,{name:"vt-badge__fade"},{default:e.withCtx(()=>[n.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["vt-badge__content",[`vt-badge__content--${l.position}`,`vt-badge__content--${l.color}`,{"vt-badge__content--dot":l.dot,"vt-badge__content--bordered":l.bordered}]]),style:e.normalizeStyle(s.value)},[l.dot?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(o.value),1)],64))],6)):e.createCommentVNode("",!0)]),_:1})]))}}),TW={class:"vt-app-bar__logo"},wW={key:0,class:"vt-app-bar__center"},GW={key:1,class:"vt-app-bar__actions"},ml=e.defineComponent({__name:"VAppBar",props:{sticky:{type:Boolean,default:!1}},setup(l){return(t,i)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vt-app-bar",{"vt-app-bar--sticky":l.sticky}])},[e.createElementVNode("div",TW,[e.renderSlot(t.$slots,"logo")]),t.$slots.center?(e.openBlock(),e.createElementBlock("div",wW,[e.renderSlot(t.$slots,"center")])):e.createCommentVNode("",!0),t.$slots.actions?(e.openBlock(),e.createElementBlock("div",GW,[e.renderSlot(t.$slots,"actions")])):e.createCommentVNode("",!0)],2))}}),xW={class:"vt-nav-rail"},gW={class:"vt-nav-rail__list"},vW=["data-placement","onClick"],fW={key:0,class:"vt-nav-rail__divider"},EW={key:0,class:"vt-nav-rail__footer"},ul=e.defineComponent({__name:"VNavRail",props:{items:{},modelValue:{default:null},placement:{default:"left"}},emits:["update:modelValue","select"],setup(l,{emit:t}){const i=t,n=o=>{o.disabled||(i("update:modelValue",o.key),i("select",o))};return(o,s)=>{const r=e.resolveDirective("tooltip");return e.openBlock(),e.createElementBlock("aside",xW,[e.createElementVNode("div",gW,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.items,(a,u)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:a.key},[e.withDirectives((e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vt-nav-rail__item",{"vt-nav-rail__item--selected":l.modelValue===a.key,"vt-nav-rail__item--disabled":a.disabled}]),"data-placement":l.placement,onClick:d=>n(a)},[a.badge?(e.openBlock(),e.createBlock(D1,{key:0,content:a.badge.content,position:a.badge.position},{default:e.withCtx(()=>[e.createVNode(ue,{name:a.icon,width:24,height:24},null,8,["name"])]),_:2},1032,["content","position"])):(e.openBlock(),e.createBlock(ue,{key:1,name:a.icon,width:24,height:24},null,8,["name"]))],10,vW)),[[r,a.label]]),u<l.items.length-1?(e.openBlock(),e.createElementBlock("span",fW)):e.createCommentVNode("",!0)],64))),128))]),o.$slots.footer?(e.openBlock(),e.createElementBlock("div",EW,[e.renderSlot(o.$slots,"footer")])):e.createCommentVNode("",!0)])}}}),dt=(l,t)=>{const i=document.createElement("div");i.className=`vt-tooltip vt-tooltip--${t}`,i.innerText=l,Object.assign(i.style,{position:"absolute",background:"rgba(0, 0, 0, 0.8)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"12px",lineHeight:"1.4",zIndex:"9999",pointerEvents:"none",visibility:"hidden",opacity:"0",transition:"opacity 0.2s ease, visibility 0.2s ease",maxWidth:"300px",wordWrap:"break-word",whiteSpace:"normal",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.2)"});const n=document.createElement("div");switch(n.className="vt-tooltip__arrow",Object.assign(n.style,{position:"absolute",width:"0",height:"0",borderStyle:"solid"}),t){case"top":Object.assign(n.style,{top:"100%",left:"50%",marginLeft:"-5px",borderWidth:"5px 5px 0 5px",borderColor:"rgba(0, 0, 0, 0.8) transparent transparent transparent"});break;case"bottom":Object.assign(n.style,{bottom:"100%",left:"50%",marginLeft:"-5px",borderWidth:"0 5px 5px 5px",borderColor:"transparent transparent rgba(0, 0, 0, 0.8) transparent"});break;case"left":Object.assign(n.style,{top:"50%",left:"100%",marginTop:"-5px",borderWidth:"5px 0 5px 5px",borderColor:"transparent transparent transparent rgba(0, 0, 0, 0.8)"});break;case"right":Object.assign(n.style,{top:"50%",right:"100%",marginTop:"-5px",borderWidth:"5px 5px 5px 0",borderColor:"transparent rgba(0, 0, 0, 0.8) transparent transparent"});break}return i.appendChild(n),i},J1=(l,t,i)=>{const n=t.getBoundingClientRect(),o=window.pageXOffset||document.documentElement.scrollLeft,s=window.pageYOffset||document.documentElement.scrollTop,r=window.innerWidth,a=window.innerHeight,u=8,d=Math.min(300,r-u*2);l.style.maxWidth=`${d}px`;const h=l.getBoundingClientRect();let b=0,Z=0;switch(i){case"top":b=n.top+s-h.height-8,Z=n.left+o+(n.width-h.width)/2;break;case"bottom":b=n.bottom+s+8,Z=n.left+o+(n.width-h.width)/2;break;case"left":b=n.top+s+(n.height-h.height)/2,Z=n.left+o-h.width-8;break;case"right":b=n.top+s+(n.height-h.height)/2,Z=n.right+o+8;break}Z<u?Z=u:Z+h.width>r-u&&(Z=r-h.width-u),b<s+u?i==="top"?b=n.bottom+s+8:b=s+u:b+h.height>s+a-u&&(i==="bottom"?b=n.top+s-h.height-8:b=s+a-h.height-u),l.style.top=`${b}px`,l.style.left=`${Z}px`},mt=(l,t,i)=>{l.parentElement||document.body.appendChild(l),l.style.visibility="visible",J1(l,t,i),requestAnimationFrame(()=>{l.style.opacity="1"})},ut=l=>{l.style.opacity="0",l.style.visibility="hidden"},ht=l=>l.scrollWidth>l.clientWidth||l.scrollHeight>l.clientHeight,It=l=>!!l.closest(".vt-table, table"),hl={mounted(l,t){var u;const i=(u=t.value)==null?void 0:u.trim();if(!i)return;const n=l.dataset.placement||"top",o=dt(i,n);l.__tooltipEl=o;const s=()=>{(It(l)?ht(l):!0)&&mt(o,l,n)},r=()=>{ut(o)},a=()=>{o.style.opacity==="1"&&J1(o,l,n)};l.__mouseenterHandler=s,l.__mouseleaveHandler=r,l.__scrollHandler=a,l.addEventListener("mouseenter",s),l.addEventListener("mouseleave",r),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a)},updated(l,t){var n;const i=(n=t.value)==null?void 0:n.trim();if(l.__tooltipEl)i?l.__tooltipEl.firstChild.textContent=i:(l.__tooltipEl.parentElement&&l.__tooltipEl.parentElement.removeChild(l.__tooltipEl),delete l.__tooltipEl);else if(i){const o=l.dataset.placement||"top",s=dt(i,o);l.__tooltipEl=s;const r=()=>{(It(l)?ht(l):!0)&&mt(s,l,o)},a=()=>{ut(s)},u=()=>{s.style.opacity==="1"&&J1(s,l,o)};l.__mouseenterHandler=r,l.__mouseleaveHandler=a,l.__scrollHandler=u,l.addEventListener("mouseenter",r),l.addEventListener("mouseleave",a),window.addEventListener("scroll",u,!0),window.addEventListener("resize",u)}},beforeUnmount(l){l.__tooltipEl&&l.__tooltipEl.parentElement&&(l.__tooltipEl.parentElement.removeChild(l.__tooltipEl),delete l.__tooltipEl),l.__mouseenterHandler&&(l.removeEventListener("mouseenter",l.__mouseenterHandler),delete l.__mouseenterHandler),l.__mouseleaveHandler&&(l.removeEventListener("mouseleave",l.__mouseleaveHandler),delete l.__mouseleaveHandler),l.__scrollHandler&&(window.removeEventListener("scroll",l.__scrollHandler,!0),window.removeEventListener("resize",l.__scrollHandler),delete l.__scrollHandler)}},Il={mounted(l,t){e.unref(t.value)&&pt(l)},updated(l,t){const i=e.unref(t.value),n=e.unref(t.oldValue);i!==n&&(i?pt(l):Zt(l))},unmounted(l){Zt(l)}};function pt(l){if(l._loaderEl)return;const t=document.createElement("div");t.className="vt-loader-base__overlay",t.innerHTML='<span class="vt-loader-base"></span>';const i=getComputedStyle(l).position;(i==="static"||!i)&&(l.style.position="relative"),l.appendChild(t),l._loaderEl=t}function Zt(l){const t=l._loaderEl;t&&(t.remove(),delete l._loaderEl)}const JW={class:"vt-message-container"},KW={class:"vt-message-icon"},FW={class:"vt-message-content"},jW={key:0,class:"vt-message-title"},RW=["innerHTML"],UW={key:1,class:"vt-message-text"},zW=["onClick"],OW=e.defineComponent({__name:"VMessage",setup(l,{expose:t}){const i=e.ref([]);let n=0;const o=a=>({success:"checkCircle",danger:"alertCircle",warning:"alertTriangle",primary:"infoCircle"})[a]||"infoCircle",s=a=>{const u=++n,d={id:u,message:a.message||"",title:a.title||"",type:a.type||"primary",showClose:a.showClose||!1,duration:a.duration!==void 0?a.duration:3e3,dangerouslyUseHTMLString:a.dangerouslyUseHTMLString||!1};return i.value.push(d),d.duration&&d.duration>0&&setTimeout(()=>{r(u)},d.duration),u},r=a=>{const u=i.value.findIndex(d=>d.id===a);u>-1&&i.value.splice(u,1)};return t({addMessage:s,removeMessage:r}),(a,u)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createElementVNode("div",JW,[e.createVNode(e.TransitionGroup,{name:"vt-message",tag:"div"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,d=>(e.openBlock(),e.createElementBlock("div",{key:d.id,class:e.normalizeClass(["vt-message-item",`vt-message-item--${d.type}`,{"vt-message-item--closable":d.showClose}])},[e.createElementVNode("div",KW,[e.createVNode(ue,{color:d.type==="primary"?"#00475A":"",name:o(d.type)},null,8,["color","name"])]),e.createElementVNode("div",FW,[d.title?(e.openBlock(),e.createElementBlock("div",jW,e.toDisplayString(d.title),1)):e.createCommentVNode("",!0),d.message?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[d.dangerouslyUseHTMLString?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vt-message-text",innerHTML:d.message},null,8,RW)):(e.openBlock(),e.createElementBlock("div",UW,e.toDisplayString(d.message),1))],64)):e.createCommentVNode("",!0)]),d.showClose?(e.openBlock(),e.createElementBlock("button",{key:0,class:"vt-message-close",type:"button",onClick:h=>r(d.id)},[e.createVNode(ue,{name:"close"})],8,zW)):e.createCommentVNode("",!0)],2))),128))]),_:1})])]))}});class DW{constructor(){this.messageInstance=null,this.app=null,this.container=null}call(t={}){return this.ensureInstance().addMessage({message:t.message||"",title:t.title||"",type:t.type||"primary",showClose:t.showClose||!1,duration:t.duration!==void 0?t.duration:3e3,dangerouslyUseHTMLString:t.dangerouslyUseHTMLString||!1})}success(t,i={}){return this.call({...i,message:t,type:"success"})}danger(t,i={}){return this.call({...i,message:t,type:"danger"})}warning(t,i={}){return this.call({...i,message:t,type:"warning"})}primary(t,i={}){return this.call({...i,message:t,type:"primary"})}close(t){this.messageInstance&&this.messageInstance.removeMessage(t)}closeAll(){this.messageInstance&&(this.messageInstance.messages=[]),this.container&&this.container.parentNode&&document.body.removeChild(this.container),this.app&&this.app.unmount(),this.messageInstance=null,this.app=null,this.container=null}getOpenMessagesCount(){return this.messageInstance?this.messageInstance.messages.length:0}ensureInstance(){return this.messageInstance?this.messageInstance:(this.container=document.createElement("div"),this.container.setAttribute("data-vt-message-container",""),document.body.appendChild(this.container),this.app=e.createApp(OW),this.messageInstance=this.app.mount(this.container),this.messageInstance)}}const ze=new DW,K1=Object.assign((l={})=>ze.call(l),{success:(l,t={})=>ze.success(l,t),danger:(l,t={})=>ze.danger(l,t),warning:(l,t={})=>ze.warning(l,t),primary:(l,t={})=>ze.primary(l,t),close:l=>{ze.close(l)},closeAll:()=>{ze.closeAll()}}),pl={install(l){l.config.globalProperties.$message=K1,l.provide("$message",K1),l.config.globalProperties.$messageStack={closeAll:()=>ze.closeAll(),getCount:()=>ze.getOpenMessagesCount(),closeById:t=>ze.close(t)}}},PW={sortable:!0,actionColumn:!1,showOverflowTooltip:!0,visible:!0,pinnedLeft:!1,pinnedRight:!1,manage:!1};function HW(l){bt(l)}const Zl={install(l,t={}){const{prefix:i="V",modal:n=!0,message:o=!0,locale:s=Pe.uk}=t;l.component(`${i}Button`,Ge),l.component(`${i}Icon`,ue),l.component(`${i}Loader`,p1),l.component(`${i}Modal`,Z1),l.component(`${i}Pagination`,yt),l.component(`${i}Checkbox`,De),l.component(`${i}Radiobox`,Vt),l.component(`${i}Table`,Yt),l.component(`${i}TableColumn`,Lt),l.component(`${i}Dropdown`,n1),l.component(`${i}DropdownItem`,s1),l.component(`${i}Input`,m1),l.component(`${i}Select`,N1),l.component(`${i}Option`,X1),l.component(`${i}DatePicker`,wt),l.component(`${i}TimePicker`,h1),l.component(`${i}Collapse`,Gt),l.component(`${i}CollapseItem`,xt),l.component(`${i}Tabs`,gt),l.component(`${i}TabItem`,vt),l.component(`${i}Upload`,Et),l.component(`${i}Sidebar`,Jt),l.component(`${i}Login`,Dt),l.component(`${i}LoginLogo`,Pt),l.component(`${i}LocaleSelect`,Wt),l.component(`${i}DynamicFilter`,Ht),l.component(`${i}Slider`,Bt),l.component(`${i}SliderMarkRange`,_t),l.component(`${i}Chart`,Qt),l.component(`${i}InfoBox`,At),l.component(`${i}TransferList`,$t),l.component(`${i}Avatar`,qt),l.component(`${i}AvatarUpload`,el),l.component(`${i}ImageFullscreen`,tl),l.component(`${i}Breadcrumb`,ll),l.component(`${i}BreadcrumbItem`,il),l.component(`${i}Audio`,rl),l.component(`${i}Empty`,T1),l.component(`${i}Editor`,dl),l.component(`${i}Badge`,D1),l.component(`${i}AppBar`,ml),l.component(`${i}NavRail`,ul),l.directive("tooltip",hl),l.directive("loader",Il),n&&l.use(St),o&&l.use(pl),l.use(Ep,{locale:s})}},BW=Zl.install;exports.DEFAULT_COLUMN_CONFIG=PW;exports.DEFAULT_FORMATS=kt;exports.DEFAULT_TIME_FORMATS=u1;exports.DropdownContextKey=R1;exports.FORMAT_TOKENS=Kb;exports.FileParser=I1;exports.FileValidator=i1;exports.LANGUAGES=Pe;exports.VAppBar=ml;exports.VAudio=rl;exports.VAvatar=qt;exports.VAvatarUpload=el;exports.VBadge=D1;exports.VBreadcrumb=ll;exports.VBreadcrumbItem=il;exports.VButton=Ge;exports.VChart=Qt;exports.VCheckbox=De;exports.VCollapse=Gt;exports.VCollapseItem=xt;exports.VColorPicker=WL;exports.VDatePicker=wt;exports.VDropdown=n1;exports.VDropdownItem=s1;exports.VDynamicFilter=Ht;exports.VEditor=dl;exports.VEmpty=T1;exports.VIcon=ue;exports.VImageFullscreen=tl;exports.VInfoBox=At;exports.VInput=m1;exports.VLoader=p1;exports.VLocaleSelect=Wt;exports.VLogin=Dt;exports.VLoginLogo=Pt;exports.VMessage=K1;exports.VMessagePlugin=pl;exports.VModal=Z1;exports.VModalPlugin=St;exports.VNavRail=ul;exports.VOption=X1;exports.VPagination=yt;exports.VRadiobox=Vt;exports.VSelect=N1;exports.VSidebar=Jt;exports.VSlider=Bt;exports.VSliderMarkRange=_t;exports.VTabItem=vt;exports.VTable=Yt;exports.VTableColumn=Lt;exports.VTabs=gt;exports.VTimePicker=h1;exports.VTimerDuration=ML;exports.VTransferList=$t;exports.VUpload=Et;exports.VtSelectContextKey=F1;exports.containUpperCaseLetter=Ut;exports.default=Zl;exports.email=Kt;exports.formatTime=Xt;exports.generateTimeOptions=L1;exports.install=BW;exports.isValidDate=g1;exports.isValidTimeString=W1;exports.loaderDirective=Il;exports.maxLength=JV;exports.maxNumber=FV;exports.messageManager=ze;exports.minLength=v1;exports.minNumber=KV;exports.mk=EV;exports.modalManager=_e;exports.noSpaces=z1;exports.numeric=jt;exports.parseTimeString=Tt;exports.pattern=RV;exports.phoneNumber=Rt;exports.required=k1;exports.sameAs=jV;exports.setLocale=HW;exports.tooltipDirective=hl;exports.uniqueAsync=UV;exports.url=Ft;exports.useValidate=Ot;exports.validateDateValue=Mt;exports.validateTimeValue=Nt;exports.withAsync=fV;exports.withMessage=vV;exports.withName=l1;exports.withParams=gV;
package/dist/index.es.js CHANGED
@@ -17527,7 +17527,7 @@ const ie = {
17527
17527
  m.value = !1, c("ended");
17528
17528
  }), C.value.on("error", () => {
17529
17529
  u.value = !0, c("error");
17530
- }), r.value && C.value.on("ready", () => {
17530
+ }), (r.value || H.value) && C.value.on("ready", () => {
17531
17531
  V(), W();
17532
17532
  }), C.value.load(l.recordUrl);
17533
17533
  }, X = k(1), b = k(1), J = (g) => {
package/dist/index.umd.js CHANGED
@@ -71,4 +71,4 @@
71
71
  <div class="cursor" part="cursor"></div>
72
72
  </div>
73
73
  </div>
74
- `,[t,i]}setOptions(t){var i;if(this.options.container!==t.container){const n=this.parentFromOptionsContainer(t.container);n.appendChild(this.container),this.parent=n}t.dragToSeek===!0||typeof this.options.dragToSeek=="object"?this.initDrag():((i=this.dragStream)===null||i===void 0||i.cleanup(),this.dragStream=null),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth-this.containerInlinePadding}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:i}=this.scrollContainer,n=i*t;this.setScroll(n)}destroy(){var t;this.subscriptions.forEach(i=>i()),this.container.remove(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),(t=this.unsubscribeOnScroll)===null||t===void 0||t.forEach(i=>i()),this.unsubscribeOnScroll=[],this.dragStream&&(this.dragStream.cleanup(),this.dragStream=null),this.scrollStream&&(this.scrollStream.cleanup(),this.scrollStream=null)}createDelay(t=10){let i,n;const o=()=>{i&&(clearTimeout(i),i=void 0),n&&(n(),n=void 0)};return this.timeouts.push(o),()=>new Promise((s,r)=>{o(),n=r,i=setTimeout(()=>{i=void 0,n=void 0,s()},t)})}getHeight(t,i){var n;const o=((n=this.audioData)===null||n===void 0?void 0:n.numberOfChannels)||1;return function({optionsHeight:s,optionsSplitChannels:r,parentHeight:a,numberOfChannels:h,defaultHeight:d=128}){if(s==null)return d;const I=Number(s);if(!isNaN(I))return I;if(s==="auto"){const b=a||d;return r!=null&&r.every(u=>!u.overlay)?b/h:b}return d}({optionsHeight:t,optionsSplitChannels:i,parentHeight:this.parent.clientHeight,numberOfChannels:o,defaultHeight:128})}convertColorValues(t,i){return function(n,o,s){if(!Array.isArray(n))return n||"";if(n.length===0)return"#999";if(n.length<2)return n[0]||"";const r=document.createElement("canvas"),a=r.getContext("2d"),h=s??r.height*o,d=a.createLinearGradient(0,0,0,h||o),I=1/(n.length-1);return n.forEach((b,u)=>{d.addColorStop(u*I,b)}),d}(t,this.getPixelRatio(),i==null?void 0:i.canvas.height)}getPixelRatio(){return t=window.devicePixelRatio,Math.max(1,t||1);var t}renderBarWaveform(t,i,n,o){const{width:s,height:r}=n.canvas,{halfHeight:a,barWidth:h,barRadius:d,barIndexScale:I,barSpacing:b,barMinHeight:u}=function({width:p,height:V,length:m,options:R,pixelRatio:X}){const Y=V/2,x=R.barWidth?R.barWidth*X:1,G=R.barGap?R.barGap*X:R.barWidth?x/2:0,L=x+G||1;return{halfHeight:Y,barWidth:x,barGap:G,barRadius:R.barRadius||0,barMinHeight:R.barMinHeight?R.barMinHeight*X:0,barIndexScale:m>0?p/L/m:0,barSpacing:L}}({width:s,height:r,length:(t[0]||[]).length,options:i,pixelRatio:this.getPixelRatio()}),y=function({channelData:p,barIndexScale:V,barSpacing:m,barWidth:R,halfHeight:X,vScale:Y,canvasHeight:x,barAlign:G,barMinHeight:L}){const Z=p[0]||[],w=p[1]||Z,W=Z.length,S=[];let K=0,J=0,g=0;for(let E=0;E<=W;E++){const T=Math.round(E*V);if(T>K){const{topHeight:n1,totalHeight:N}=TL({maxTop:J,maxBottom:g,halfHeight:X,vScale:Y,barMinHeight:L,barAlign:G}),F=wL({barAlign:G,halfHeight:X,topHeight:n1,totalHeight:N,canvasHeight:x});S.push({x:K*m,y:F,width:R,height:N}),K=T,J=0,g=0}const z=Math.abs(Z[E]||0),A=Math.abs(w[E]||0);z>J&&(J=z),A>g&&(g=A)}return S}({channelData:t,barIndexScale:I,barSpacing:b,barWidth:h,halfHeight:a,vScale:o,canvasHeight:r,barAlign:i.barAlign,barMinHeight:u});n.beginPath();for(const p of y)d&&"roundRect"in n?n.roundRect(p.x,p.y,p.width,p.height,d):n.rect(p.x,p.y,p.width,p.height);n.fill(),n.closePath()}renderLineWaveform(t,i,n,o){const{width:s,height:r}=n.canvas,a=function({channelData:h,width:d,height:I,vScale:b}){const u=I/2,y=h[0]||[];return[y,h[1]||y].map((p,V)=>{const m=p.length,R=m?d/m:0,X=u,Y=V===0?-1:1,x=[{x:0,y:X}];let G=0,L=0;for(let Z=0;Z<=m;Z++){const w=Math.round(Z*R);if(w>G){const S=X+(Math.round(L*u*b)||1)*Y;x.push({x:G,y:S}),G=w,L=0}const W=Math.abs(p[Z]||0);W>L&&(L=W)}return x.push({x:G,y:X}),x})}({channelData:t,width:s,height:r,vScale:o});n.beginPath();for(const h of a)if(h.length){n.moveTo(h[0].x,h[0].y);for(let d=1;d<h.length;d++){const I=h[d];n.lineTo(I.x,I.y)}}n.fill(),n.closePath()}renderWaveform(t,i,n){if(n.fillStyle=this.convertColorValues(i.waveColor,n),i.renderFunction)return void i.renderFunction(t,n);const o=function({channelData:s,barHeight:r,normalize:a,maxPeak:h}){var d;const I=r||1;if(!a)return I;const b=s[0];if(!b||b.length===0)return I;let u=h??0;if(!h)for(let y=0;y<b.length;y++){const p=(d=b[y])!==null&&d!==void 0?d:0,V=Math.abs(p);V>u&&(u=V)}return u?I/u:I}({channelData:t,barHeight:i.barHeight,normalize:i.normalize,maxPeak:i.maxPeak});_t(i)?this.renderBarWaveform(t,i,n,o):this.renderLineWaveform(t,i,n,o)}renderSingleCanvas(t,i,n,o,s,r,a){const h=this.getPixelRatio(),d=document.createElement("canvas");d.width=Math.round(n*h),d.height=Math.round(o*h),d.style.width=`${n}px`,d.style.height=`${o}px`,d.style.left=`${Math.round(s)}px`,r.appendChild(d);const I=d.getContext("2d");if(i.renderFunction?(I.fillStyle=this.convertColorValues(i.waveColor,I),i.renderFunction(t,I)):this.renderWaveform(t,i,I),d.width>0&&d.height>0){const b=d.cloneNode(),u=b.getContext("2d");u.drawImage(d,0,0),u.globalCompositeOperation="source-in",u.fillStyle=this.convertColorValues(i.progressColor,u),u.fillRect(0,0,d.width,d.height),a.appendChild(b)}}renderMultiCanvas(t,i,n,o,s,r){const a=this.getPixelRatio(),{clientWidth:h}=this.scrollContainer,d=n/a,I=function({clientWidth:p,totalWidth:V,options:m}){return vt(Math.min(8e3,p,V),m)}({clientWidth:h,totalWidth:d,options:i});let b={};if(I===0)return;const u=p=>{if(p<0||p>=y||b[p])return;b[p]=!0;const V=p*I;let m=Math.min(d-V,I);if(m=vt(m,i),m<=0)return;const R=function({channelData:X,offset:Y,clampedWidth:x,totalWidth:G}){return X.map(L=>{const Z=Math.floor(Y/G*L.length),w=Math.floor((Y+x)/G*L.length);return L.slice(Z,w)})}({channelData:t,offset:V,clampedWidth:m,totalWidth:d});this.renderSingleCanvas(R,i,m,o,V,s,r)},y=Math.ceil(d/I);if(!this.isScrollable){for(let p=0;p<y;p++)u(p);return}if(Qt({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:d,numCanvases:y}).forEach(p=>u(p)),y>1){const p=this.on("scroll",()=>{const{scrollLeft:V}=this.scrollContainer;Object.keys(b).length>10&&(s.innerHTML="",r.innerHTML="",b={}),Qt({scrollLeft:V,totalWidth:d,numCanvases:y}).forEach(m=>u(m))});this.unsubscribeOnScroll.push(p)}}renderChannel(t,i,n,o){var{overlay:s}=i,r=function(I,b){var u={};for(var y in I)Object.prototype.hasOwnProperty.call(I,y)&&b.indexOf(y)<0&&(u[y]=I[y]);if(I!=null&&typeof Object.getOwnPropertySymbols=="function"){var p=0;for(y=Object.getOwnPropertySymbols(I);p<y.length;p++)b.indexOf(y[p])<0&&Object.prototype.propertyIsEnumerable.call(I,y[p])&&(u[y[p]]=I[y[p]])}return u}(i,["overlay"]);const a=document.createElement("div"),h=this.getHeight(r.height,r.splitChannels);a.style.height=`${h}px`,s&&o>0&&(a.style.marginTop=`-${h}px`),this.canvasWrapper.style.minHeight=`${h}px`,this.canvasWrapper.appendChild(a);const d=a.cloneNode();this.progressWrapper.appendChild(d),this.renderMultiCanvas(t,r,n,h,a,d)}render(t){return F1(this,void 0,void 0,function*(){var i;this.timeouts.forEach(d=>d()),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 n=this.getPixelRatio(),o=this.scrollContainer.clientWidth-this.containerInlinePadding,{scrollWidth:s,isScrollable:r,useParentWidth:a,width:h}=function({duration:d,minPxPerSec:I=0,parentWidth:b,fillParent:u,pixelRatio:y}){const p=Math.ceil(d*I),V=p>b,m=!!(u&&!V);return{scrollWidth:p,isScrollable:V,useParentWidth:m,width:(m?b:p)*y}}({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:o,fillParent:this.options.fillParent,pixelRatio:n});if(this.isScrollable=r,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=t,this.emit("render"),this.options.splitChannels)for(let d=0;d<t.numberOfChannels;d++){const I=Object.assign(Object.assign({},this.options),(i=this.options.splitChannels)===null||i===void 0?void 0:i[d]);this.renderChannel([t.getChannelData(d)],I,h,d)}else{const d=[t.getChannelData(0)];t.numberOfChannels>1&&d.push(t.getChannelData(1)),this.renderChannel(d,this.options,h,0)}Promise.resolve().then(()=>this.emit("rendered"))})}reRender(){if(this.unsubscribeOnScroll.forEach(n=>n()),this.unsubscribeOnScroll=[],!this.audioData)return;const{scrollWidth:t}=this.scrollContainer,{right:i}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),!this.isScrollable&&this.scrollContainer.scrollLeft)this.scrollContainer.scrollLeft=0;else if(this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:n}=this.progressWrapper.getBoundingClientRect(),o=function(s){const r=2*s;return(r<0?Math.floor(r):Math.ceil(r))/2}(n-i);this.scrollContainer.scrollLeft+=o}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,i=!1){var n;const{scrollLeft:o,scrollWidth:s,clientWidth:r}=this.scrollContainer,a=t*s,h=o,d=o+r,I=r/2;if(this.isDragging)a+30>d?this.scrollContainer.scrollLeft+=30:a-30<h&&(this.scrollContainer.scrollLeft-=30);else{(a<h||a>d)&&(this.scrollContainer.scrollLeft=a-(this.options.autoCenter?I:0));const b=a-o-I;if(i&&this.options.autoCenter&&b>0){const u=(n=this.audioData)===null||n===void 0?void 0:n.duration;if(u===void 0||u<=0)return void(this.scrollContainer.scrollLeft+=b);const y=s/u;this.scrollContainer.scrollLeft+=y<=600?Math.min(b,10):b}}}renderProgress(t,i){if(isNaN(t))return;const n=100*t;this.canvasWrapper.style.clipPath=`polygon(${n}% 0%, 100% 0%, 100% 100%, ${n}% 100%)`,this.progressWrapper.style.width=`${n}%`,this.cursor.style.left=`${n}%`,this.cursor.style.transform=this.options.cursorWidth?`translateX(-${t*this.options.cursorWidth}px)`:"",this.isScrollable&&this.options.autoScroll&&this.audioData&&this.audioData.duration>0&&this.scrollIntoView(t,i)}exportImage(t,i,n){return F1(this,void 0,void 0,function*(){const o=this.canvasWrapper.querySelectorAll("canvas");if(!o.length)throw new Error("No waveform data");if(n==="dataURL"){const s=Array.from(o).map(r=>r.toDataURL(t,i));return Promise.resolve(s)}return Promise.all(Array.from(o).map(s=>new Promise((r,a)=>{s.toBlob(h=>{h?r(h):a(new Error("Could not export image"))},t,i)})))})}}class gL extends Ce{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;const t=()=>{this.isRunning&&(this.emit("tick"),this.animationFrameId=requestAnimationFrame(t))};t()}stop(){this.isRunning=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop()}}class Ue extends Ce{constructor(t){super(),this.bufferNode=null,this.playStartTime=0,this.playbackPosition=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,function(){const i=globalThis.navigator;if(i!=null&&i.audioSession)try{i.audioSession.type="playback"}catch(n){console.warn("Setting navigator.audioSession.type failed:",n)}}(),this.audioContext=t||new AudioContext,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return F1(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(t){if(this.currentSrc=t,this._duration=void 0,!t)return this.buffer=null,void this.emit("emptied");fetch(t).then(i=>{if(i.status>=400)throw new Error(`Failed to fetch ${t}: ${i.status} (${i.statusText})`);return i.arrayBuffer()}).then(i=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(i)).then(i=>{this.currentSrc===t&&(this.buffer=i,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())}).catch(i=>{console.error("WebAudioPlayer load error:",i)})}_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 t=this.playbackPosition;(t>=this.duration||t<0)&&(t=0,this.playbackPosition=0),this.bufferNode.start(this.audioContext.currentTime,t),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{!this.paused&&this.duration-this.currentTime<.01&&(this.pause(),this.emit("ended"))}}_pause(){var t;this.paused=!0,(t=this.bufferNode)===null||t===void 0||t.stop(),this.playbackPosition+=(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}play(){return F1(this,void 0,void 0,function*(){this.paused&&(this._play(),this.emit("play"))})}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){const i=t-this.currentTime,n=this.bufferNode;n==null||n.stop(this.audioContext.currentTime+i),n==null||n.addEventListener("ended",()=>{n===this.bufferNode&&(this.bufferNode=null,this.pause())},{once:!0})}setSinkId(t){return F1(this,void 0,void 0,function*(){return this.audioContext.setSinkId(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){const i=!this.paused;i&&this._pause(),this._playbackRate=t,i&&this._play(),this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return this.paused?this.playbackPosition:this.playbackPosition+(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}set currentTime(t){const i=!this.paused;i&&this._pause(),this.playbackPosition=t,i&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,i;return(t=this._duration)!==null&&t!==void 0?t:((i=this.buffer)===null||i===void 0?void 0:i.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t,this.emit("volumechange")}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const i=this.buffer.numberOfChannels;for(let n=0;n<i;n++)t.push(this.buffer.getChannelData(n));return t}removeAttribute(t){switch(t){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 fL={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class ye extends XL{static create(t){return new ye(t)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(t){const i=t.media||(t.backend==="WebAudio"?new Ue:void 0);super({media:i,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate}),this.plugins=[],this.decodedData=null,this.stopAtPosition=null,this.subscriptions=[],this.mediaSubscriptions=[],this.abortController=null,this.reactiveCleanups=[],this.options=Object.assign({},fL,t);const{state:n,actions:o}=function(a){var h,d,I,b,u,y;const p=(h=a==null?void 0:a.currentTime)!==null&&h!==void 0?h:g1(0),V=(d=a==null?void 0:a.duration)!==null&&d!==void 0?d:g1(0),m=(I=a==null?void 0:a.isPlaying)!==null&&I!==void 0?I:g1(!1),R=(b=a==null?void 0:a.isSeeking)!==null&&b!==void 0?b:g1(!1),X=(u=a==null?void 0:a.volume)!==null&&u!==void 0?u:g1(1),Y=(y=a==null?void 0:a.playbackRate)!==null&&y!==void 0?y:g1(1),x=g1(null),G=g1(null),L=g1(""),Z=g1(0),w=g1(0),W=ce(()=>!m.value,[m]),S=ce(()=>x.value!==null,[x]),K=ce(()=>S.value&&V.value>0,[S,V]),J=ce(()=>p.value,[p]),g=ce(()=>V.value>0?p.value/V.value:0,[p,V]);return{state:{currentTime:p,duration:V,isPlaying:m,isPaused:W,isSeeking:R,volume:X,playbackRate:Y,audioBuffer:x,peaks:G,url:L,zoom:Z,scrollPosition:w,canPlay:S,isReady:K,progress:J,progressPercent:g},actions:{setCurrentTime:E=>{const T=Math.max(0,Math.min(V.value||1/0,E));p.set(T)},setDuration:E=>{V.set(Math.max(0,E))},setPlaying:E=>{m.set(E)},setSeeking:E=>{R.set(E)},setVolume:E=>{const T=Math.max(0,Math.min(1,E));X.set(T)},setPlaybackRate:E=>{const T=Math.max(.1,Math.min(16,E));Y.set(T)},setAudioBuffer:E=>{x.set(E),E&&V.set(E.duration)},setPeaks:E=>{G.set(E)},setUrl:E=>{L.set(E)},setZoom:E=>{Z.set(Math.max(0,E))},setScrollPosition:E=>{w.set(Math.max(0,E))}}}}({isPlaying:this.isPlayingSignal,currentTime:this.currentTimeSignal,duration:this.durationSignal,volume:this.volumeSignal,playbackRate:this.playbackRateSignal,isSeeking:this.seekingSignal});this.wavesurferState=n,this.wavesurferActions=o,this.timer=new gL;const s=i?void 0:this.getMediaElement();this.renderer=new xL(this.options,s),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initReactiveState(),this.initPlugins();const r=this.options.url||this.getSrc()||"";Promise.resolve().then(()=>{this.emit("init");const{peaks:a,duration:h}=this.options;(r||a&&h)&&this.load(r,a,h).catch(d=>{this.emit("error",d instanceof Error?d:new Error(String(d)))})})}updateProgress(t=this.getCurrentTime()){return this.renderer.renderProgress(t/this.getDuration(),this.isPlaying()),t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t),this.stopAtPosition!=null&&this.isPlaying()&&t>=this.stopAtPosition&&this.pause()}}))}initReactiveState(){this.reactiveCleanups.push(function(t,i){const n=[];n.push(te(()=>{const r=t.isPlaying.value;i.emit(r?"play":"pause")},[t.isPlaying])),n.push(te(()=>{const r=t.currentTime.value;i.emit("timeupdate",r),t.isPlaying.value&&i.emit("audioprocess",r)},[t.currentTime,t.isPlaying])),n.push(te(()=>{t.isSeeking.value&&i.emit("seeking",t.currentTime.value)},[t.isSeeking,t.currentTime]));let o=!1;n.push(te(()=>{t.isReady.value&&!o&&(o=!0,i.emit("ready",t.duration.value))},[t.isReady,t.duration]));let s=!1;return n.push(te(()=>{const r=t.isPlaying.value,a=t.currentTime.value,h=t.duration.value,d=h>0&&a>=h;s&&!r&&d&&i.emit("finish"),s=r&&d},[t.isPlaying,t.currentTime,t.duration])),n.push(te(()=>{const r=t.zoom.value;r>0&&i.emit("zoom",r)},[t.zoom])),()=>{n.forEach(r=>r())}}(this.wavesurferState,{emit:this.emit.bind(this)}))}initPlayerEvents(){this.isPlaying()&&(this.emit("play"),this.timer.start()),this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",()=>{const t=this.updateProgress();this.emit("timeupdate",t)}),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 t;this.emit("error",(t=this.getMediaElement().error)!==null&&t!==void 0?t:new Error("Media error")),this.stopAtPosition=null}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(t,i)=>{this.options.interact&&(this.seekTo(t),this.emit("interaction",t*this.getDuration()),this.emit("click",t,i))}),this.renderer.on("dblclick",(t,i)=>{this.emit("dblclick",t,i)}),this.renderer.on("scroll",(t,i,n,o)=>{const s=this.getDuration();this.emit("scroll",t*s,i*s,n,o)}),this.renderer.on("render",()=>{this.emit("redraw")}),this.renderer.on("rendered",()=>{this.emit("redrawcomplete")}),this.renderer.on("dragstart",t=>{this.emit("dragstart",t)}),this.renderer.on("dragend",t=>{this.emit("dragend",t)}),this.renderer.on("resize",()=>{this.emit("resize")}));{let t;const i=this.renderer.on("drag",n=>{var o;if(!this.options.interact)return;this.renderer.renderProgress(n),clearTimeout(t);let s=0;const r=this.options.dragToSeek;this.isPlaying()?s=0:r===!0?s=200:r&&typeof r=="object"&&(s=(o=r.debounceTime)!==null&&o!==void 0?o:200),t=setTimeout(()=>{this.seekTo(n)},s),this.emit("interaction",n*this.getDuration()),this.emit("drag",n)});this.subscriptions.push(()=>{clearTimeout(t),i()})}}initPlugins(){var t;!((t=this.options.plugins)===null||t===void 0)&&t.length&&this.options.plugins.forEach(i=>{this.registerPlugin(i)})}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach(t=>t()),this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t),t.duration&&!t.peaks&&(this.decodedData=Te.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=Te.createBuffer(t.peaks,t.duration)),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),t.mediaControls!=null&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){if(this.plugins.includes(t))return t;t._init(this),this.plugins.push(t);const i=t.once("destroy",()=>{this.plugins=this.plugins.filter(n=>n!==t),this.subscriptions=this.subscriptions.filter(n=>n!==i)});return this.subscriptions.push(i),t}unregisterPlugin(t){this.plugins=this.plugins.filter(i=>i!==t),t.destroy()}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const i=t/this.getDuration();this.renderer.setScrollPercentage(i)}getActivePlugins(){return this.plugins}loadAudio(t,i,n,o){return F1(this,void 0,void 0,function*(){var s;if(this.emit("load",t),!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,!i&&!n){const a=this.options.fetchParams||{};window.AbortController&&!a.signal&&(this.abortController=new AbortController,a.signal=this.abortController.signal);const h=I=>this.emit("loading",I);i=yield NL.fetchBlob(t,h,a);const d=this.options.blobMimeType;d&&(i=new Blob([i],{type:d}))}this.setSrc(t,i);const r=yield new Promise(a=>{const h=o||this.getDuration();h?a(h):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>a(this.getDuration()),{once:!0}))});if(!t&&!i){const a=this.getMediaElement();a instanceof Ue&&(a.duration=r)}if(n)this.decodedData=Te.createBuffer(n,r||0);else if(i){const a=yield i.arrayBuffer();this.decodedData=yield Te.decode(a,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())})}load(t,i,n){return F1(this,void 0,void 0,function*(){try{return yield this.loadAudio(t,void 0,i,n)}catch(o){throw this.emit("error",o),o}})}loadBlob(t,i,n){return F1(this,void 0,void 0,function*(){try{return yield this.loadAudio("",t,i,n)}catch(o){throw this.emit("error",o),o}})}zoom(t){if(!this.decodedData)throw new Error("No audio loaded");this.renderer.zoom(t),this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:i=8e3,precision:n=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const o=Math.min(t,this.decodedData.numberOfChannels),s=[];for(let r=0;r<o;r++){const a=this.decodedData.getChannelData(r),h=[],d=a.length/i;for(let I=0;I<i;I++){const b=a.slice(Math.floor(I*d),Math.ceil((I+1)*d));let u=0;for(let y=0;y<b.length;y++){const p=b[y];Math.abs(p)>Math.abs(u)&&(u=p)}h.push(Math.round(u*n)/n)}s.push(h)}return s}getDuration(){let t=super.getDuration()||0;return t!==0&&t!==1/0||!this.decodedData||(t=this.decodedData.duration),t}toggleInteraction(t){this.options.interact=t}setTime(t){this.stopAtPosition=null,super.setTime(t),this.updateProgress(t),this.emit("timeupdate",t)}seekTo(t){const i=this.getDuration()*t;this.setTime(i)}play(t,i){const n=Object.create(null,{play:{get:()=>super.play}});return F1(this,void 0,void 0,function*(){t!=null&&this.setTime(t);const o=yield n.play.call(this);return i!=null&&(this.media instanceof Ue?this.media.stopAt(i):this.stopAtPosition=i),o})}playPause(){return F1(this,void 0,void 0,function*(){return this.isPlaying()?this.pause():this.play()})}stop(){this.pause(),this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents(),super.setMediaElement(t),this.initPlayerEvents()}exportImage(){return F1(this,arguments,void 0,function*(t="image/png",i=1,n="dataURL"){return this.renderer.exportImage(t,i,n)})}destroy(){var t;this.emit("destroy"),(t=this.abortController)===null||t===void 0||t.abort(),this.plugins.forEach(i=>i.destroy()),this.subscriptions.forEach(i=>i()),this.unsubscribePlayerEvents(),this.reactiveCleanups.forEach(i=>i()),this.reactiveCleanups=[],this.timer.destroy(),this.renderer.destroy(),super.destroy()}}ye.BasePlugin=class extends Ce{constructor(l){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=l}onInit(){}_init(l){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=l,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(l=>l()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}},ye.dom=ML;class EL{constructor(){this.listeners={}}on(t,i,n){if(this.listeners[t]||(this.listeners[t]=new Set),n==null?void 0:n.once){const o=(...s)=>{this.un(t,o),i(...s)};return this.listeners[t].add(o),()=>this.un(t,o)}return this.listeners[t].add(i),()=>this.un(t,i)}un(t,i){var n;(n=this.listeners[t])===null||n===void 0||n.delete(i)}once(t,i){return this.on(t,i,{once:!0})}unAll(){this.listeners={}}emit(t,...i){this.listeners[t]&&this.listeners[t].forEach(n=>n(...i))}}class JL extends EL{constructor(t){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=t}onInit(){}_init(t){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}}function $t(l,t){const i=t.xmlns?document.createElementNS(t.xmlns,l):document.createElement(l);for(const[n,o]of Object.entries(t))if(n==="children"&&o)for(const[s,r]of Object.entries(o))r instanceof Node?i.appendChild(r):typeof r=="string"?i.appendChild(document.createTextNode(r)):i.appendChild($t(s,r));else n==="style"?Object.assign(i.style,o):n==="textContent"?i.textContent=o:i.setAttribute(n,o.toString());return i}function ze(l,t,i){return $t(l,t||{})}const KL={height:20,timeOffset:0,formatTimeCallback:l=>l/60>1?`${Math.floor(l/60)}:${`${(l=Math.round(l%60))<10?"0":""}${l}`}`:`${Math.round(1e3*l)/1e3}`};class Oe extends JL{constructor(t){super(t||{}),this.notchElements=new Map,this.currentTimeline=null,this.options=Object.assign({},KL,t),this.timelineWrapper=this.initTimelineWrapper()}static create(t){return new Oe(t)}onInit(){var t;if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");let i=this.wavesurfer.getWrapper();if(this.options.container instanceof HTMLElement)i=this.options.container;else if(typeof this.options.container=="string"){const o=document.querySelector(this.options.container);if(!o)throw Error(`No Timeline container found matching ${this.options.container}`);i=o}this.options.insertPosition?(i.firstElementChild||i).insertAdjacentElement(this.options.insertPosition,this.timelineWrapper):i.appendChild(this.timelineWrapper);const n=this.wavesurfer.getState();this.subscriptions.push(function(o,s){let r;const a=()=>{r&&(r(),r=void 0),r=o()},h=s.map(d=>d.subscribe(a));return a(),()=>{r&&(r(),r=void 0),h.forEach(d=>d())}}(()=>{(n.duration.value>0||this.options.duration)&&this.initTimeline()},[n.duration])),this.subscriptions.push(this.wavesurfer.on("redraw",()=>this.initTimeline())),this.subscriptions.push(this.wavesurfer.on("scroll",(o,s,r,a)=>{this.currentTimeline&&this.updateVisibleNotches(r,a,this.currentTimeline)})),(!((t=this.wavesurfer)===null||t===void 0)&&t.getDuration()||this.options.duration)&&this.initTimeline()}destroy(){this.timelineWrapper.remove(),super.destroy()}initTimelineWrapper(){return ze("div",{part:"timeline-wrapper",style:{pointerEvents:"none"}})}defaultTimeInterval(t){return t>=25?1:5*t>=25?5:15*t>=25?15:60*Math.ceil(.5/t)}defaultPrimaryLabelInterval(t){return t>=25?10:5*t>=25?6:4}defaultSecondaryLabelInterval(t){return t>=25?5:2}virtualAppend(t,i,n){if(this.notchElements.set(n,{start:t,width:n.clientWidth,wasVisible:!1}),!this.wavesurfer)return;const o=this.wavesurfer.getScroll(),s=o+this.wavesurfer.getWidth(),r=this.notchElements.get(n),a=t>=o&&t+r.width<s;r.wasVisible=a,a&&i.appendChild(n)}updateVisibleNotches(t,i,n){this.notchElements.forEach((o,s)=>{const r=o.start>=t&&o.start+o.width<i;r!==o.wasVisible&&(o.wasVisible=r,r?n.appendChild(s):s.remove())})}initTimeline(){var t,i,n,o,s,r,a,h;this.notchElements.clear();const d=(n=(i=(t=this.wavesurfer)===null||t===void 0?void 0:t.getDuration())!==null&&i!==void 0?i:this.options.duration)!==null&&n!==void 0?n:0,I=(((o=this.wavesurfer)===null||o===void 0?void 0:o.getWrapper().scrollWidth)||this.timelineWrapper.scrollWidth)/d,b=(s=this.options.timeInterval)!==null&&s!==void 0?s:this.defaultTimeInterval(I),u=(r=this.options.primaryLabelInterval)!==null&&r!==void 0?r:this.defaultPrimaryLabelInterval(I),y=this.options.primaryLabelSpacing,p=(a=this.options.secondaryLabelInterval)!==null&&a!==void 0?a:this.defaultSecondaryLabelInterval(I),V=this.options.secondaryLabelSpacing,m=this.options.insertPosition==="beforebegin",R=ze("div",{style:Object.assign({height:`${this.options.height}px`,overflow:"hidden",fontSize:this.options.height/2+"px",whiteSpace:"nowrap"},m?{position:"absolute",top:"0",left:"0",right:"0",zIndex:"2"}:{position:"relative"})});R.setAttribute("part","timeline"),typeof this.options.style=="string"?R.setAttribute("style",R.getAttribute("style")+this.options.style):typeof this.options.style=="object"&&Object.assign(R.style,this.options.style);const X=ze("div",{style:{width:"0",height:"50%",display:"flex",flexDirection:"column",justifyContent:m?"flex-start":"flex-end",top:m?"0":"auto",bottom:m?"auto":"0",overflow:"visible",borderLeft:"1px solid currentColor",opacity:`${(h=this.options.secondaryLabelOpacity)!==null&&h!==void 0?h:.25}`,position:"absolute",zIndex:"1"}});for(let Y=0,x=0;Y<d;Y+=b,x++){const G=X.cloneNode(),L=Math.round(100*Y)%Math.round(100*u)==0||y&&x%y==0,Z=Math.round(100*Y)%Math.round(100*p)==0||V&&x%V==0;(L||Z)&&(G.style.height="100%",G.style.textIndent="3px",G.textContent=this.options.formatTimeCallback(Y),L&&(G.style.opacity="1"));const w=L?"primary":Z?"secondary":"tick";G.setAttribute("part",`timeline-notch timeline-notch-${w}`);const W=(Y+this.options.timeOffset)*I;G.style.left=`${W}px`,this.virtualAppend(W,R,G)}this.timelineWrapper.innerHTML="",this.timelineWrapper.appendChild(R),this.currentTimeline=R,this.emit("ready")}}const we={WAVE_DEFAULT:"#D9D9D9",PROGRESS:"#F2994A"},FL={key:0,class:"vt-audio__empty"},jL={key:1},RL={class:"vt-audio__wave-area"},UL=["id"],zL={class:"vt-audio__controls"},OL=["disabled"],DL=["disabled"],PL=["disabled"],qt=e.defineComponent({__name:"VAudio",props:{recordUrl:{default:""},userA:{default:""},userB:{default:""},disabled:{type:Boolean,default:!1},type:{default:"default"}},emits:["timeUpdate","play","pause","ended","error"],setup(l,{expose:t,emit:i}){const{t:n}=W1(),o=l,s=i,r=e.computed(()=>!!(o.userA||o.userB)),a=e.ref(!1),h=e.computed(()=>o.disabled||a.value),d=e.ref(!1),I=e.ref(1),b=e.ref(`ws-${Math.random().toString(36).slice(2,9)}`),u=e.ref(null),y=e.ref(null),p=e.ref(null),V=e.ref(null),m=e.ref(null),R=e.computed(()=>o.type==="channel-routed"),X=(T,z)=>{var q;const{width:A,height:n1}=z.canvas,N=(q=u.value)==null?void 0:q.decodedData;if(!T.length&&!N){z.fillStyle=we.WAVE_DEFAULT,z.fillRect(0,n1/2,A,2);return}const F=r.value&&N&&N.numberOfChannels>=2?[N.getChannelData(0),N.getChannelData(1)]:[T[0]||new Float32Array(A).fill(0)];z.clearRect(0,0,A,n1);const O=20;F.forEach((e1,s1)=>{const V1=n1/F.length,a1=V1-(r.value?O:0),c1=s1*V1+(r.value?O:0)+a1/2,C1=e1.length/A;let Y1=0;for(let p1=0;p1<e1.length;p1+=100){const k=Math.abs(e1[p1]??0);k>Y1&&(Y1=k)}Y1===0&&(Y1=1),z.fillStyle=we.WAVE_DEFAULT;for(let p1=0;p1<A;p1+=2){const k=Math.floor(p1*C1),P=Math.min(Math.floor((p1+2)*C1),e1.length-1);let B=0;for(let N1=k;N1<=P;N1++){const w1=Math.abs(e1[N1]??0);w1>B&&(B=w1)}const b1=B/Y1,k1=Math.max(b1*a1*.85,2);z.fillRect(p1,c1-k1/2,1.5,k1)}if(r.value){z.fillStyle="#999999",z.font="12px Inter, sans-serif",z.textAlign="right";const p1=(s1===0?o.userA:o.userB)??"";z.fillText(p1,A-10,s1*V1+O-5)}})},Y=()=>{var N;const T=(N=u.value)==null?void 0:N.getMediaElement();if(!T)return;p.value=new(window.AudioContext||window.webkitAudioContext);const z=p.value.createMediaElementSource(T),A=p.value.createChannelSplitter(2),n1=p.value.createChannelMerger(2);V.value=p.value.createGain(),m.value=p.value.createGain(),V.value.gain.value=L.value,m.value.gain.value=Z.value,z.connect(A),A.connect(V.value,0),A.connect(m.value,1),V.value.connect(n1,0,0),m.value.connect(n1,0,1),n1.connect(p.value.destination)},x=()=>{var T;(T=p.value)==null||T.close(),p.value=null,V.value=null,m.value=null},G=()=>{if(!o.recordUrl)return;a.value=!1;const T=ye.create({container:`#waveform-${b.value}`,waveColor:we.WAVE_DEFAULT,progressColor:we.PROGRESS,barWidth:2,height:R.value?36:r.value?100:50,plugins:R.value?[]:[Oe.create({container:y.value,style:{fontSize:"10px",color:"#999"}})],renderFunction:(z,A)=>X(z,A)});u.value=T,u.value.on("play",()=>{d.value=!0,s("play")}),u.value.on("pause",()=>{d.value=!1,s("pause")}),u.value.on("timeupdate",z=>s("timeUpdate",z)),u.value.on("finish",()=>{d.value=!1,s("ended")}),u.value.on("error",()=>{a.value=!0,s("error")}),r.value&&u.value.on("ready",()=>{Y(),S()}),u.value.load(o.recordUrl)},L=e.ref(1),Z=e.ref(1),w=T=>{const z=T===0?V.value:m.value,A=T===0?L:Z;A.value=A.value?0:1,z&&(z.gain.value=A.value)},W={x:5,y:0,size:18},S=()=>{const T=document.querySelector(`#waveform-${b.value} canvas`);!T||!r.value||T.addEventListener("click",z=>{if(h.value)return;const A=T.getBoundingClientRect(),n1=z.clientX-A.left,N=z.clientY-A.top,F=A.height/2;[0,1].forEach(O=>{const q=O*F+W.y;n1>=W.x&&n1<=W.x+W.size&&N>=q&&N<=q+W.size&&(z.stopPropagation(),z.preventDefault(),w(O))})})},K=async()=>{if(!(!u.value||h.value)){if(R.value){const T=u.value.getMediaElement();if(!T||!p.value)return;p.value.state==="suspended"&&await p.value.resume(),T.paused?await T.play():T.pause();return}d.value?u.value.pause():u.value.play()}},J=T=>{var z;I.value=T,(z=u.value)==null||z.setPlaybackRate(I.value)},g=(T,z)=>{if(T.startsWith("data:")){const n1=document.createElement("a");n1.href=T,n1.download=z,document.body.appendChild(n1),n1.click(),document.body.removeChild(n1)}else fetch(T).then(n1=>n1.blob()).then(n1=>{const N=document.createElement("a");N.href=URL.createObjectURL(n1),N.download=z,document.body.appendChild(N),N.click(),document.body.removeChild(N)}).catch(console.error)},E=()=>{if(o.disabled||!o.recordUrl)return;const T=o.recordUrl.indexOf("?"),z=o.recordUrl.substring(o.recordUrl.lastIndexOf("/")+1,T===-1?void 0:T);g(o.recordUrl,z)};return e.onMounted(()=>e.nextTick(G)),e.onBeforeUnmount(()=>{var T;(T=u.value)==null||T.destroy(),x()}),e.watch(()=>o.recordUrl,()=>{var T;(T=u.value)==null||T.destroy(),x(),e.nextTick(G)}),t({play:()=>{var T;return(T=u.value)==null?void 0:T.play()},pause:()=>{var T;return(T=u.value)==null?void 0:T.pause()},getCurrentTime:()=>{var T;return((T=u.value)==null?void 0:T.getCurrentTime())||0}}),(T,z)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vt-audio",{"is-disabled":h.value,"is-channel-routed":R.value}])},[l.recordUrl?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["vt-audio__container",{"is-single-channel":!r.value,"is-channel-routed":R.value}])},[e.createElementVNode("div",RL,[e.createElementVNode("div",{id:`waveform-${b.value}`,class:"vt-audio__waveform"},null,8,UL),R.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"timelineContainer",ref:y,class:"vt-audio__timeline"},null,512))]),e.createElementVNode("div",zL,[R.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("button",{class:"vt-audio__btn",disabled:h.value,onClick:E},[e.createVNode(h1,{name:"import",width:"20",height:"20"})],8,OL),e.createVNode(oe,{trigger:"click",placement:"top",disabled:h.value,onCommand:J},{dropdown:e.withCtx(()=>[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList([1,1.5,2],A=>e.createVNode(ne,{key:A,command:A,class:e.normalizeClass({"is-active":I.value===A})},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(A)+"x ",1)]),_:2},1032,["command","class"])),64))]),default:e.withCtx(()=>[e.createElementVNode("button",{class:"vt-audio__speed-val",disabled:h.value},e.toDisplayString(I.value)+"x",9,DL)]),_:1},8,["disabled"])],64)),e.createElementVNode("button",{class:"vt-audio__btn vt-audio__btn--main",disabled:h.value,onClick:K},[d.value?e.renderSlot(T.$slots,"icon-pause",{key:0},()=>[e.createVNode(h1,{name:"pause",width:"24",height:"24"})]):e.renderSlot(T.$slots,"icon-play",{key:1},()=>[e.createVNode(h1,{name:"start",width:"24",height:"24"})])],8,PL)])],2)):(e.openBlock(),e.createElementBlock("div",FL,[e.renderSlot(T.$slots,"empty",{},()=>[R.value?(e.openBlock(),e.createElementBlock("span",jL,e.toDisplayString(e.unref(n)(e.unref(c).AUDIO_EMPTY)),1)):(e.openBlock(),e.createBlock(Le,{key:0,icon:"noSound",text:e.unref(n)(e.unref(c).AUDIO_EMPTY)},null,8,["text"]))])]))],2))}}),HL=new Set(["p","div","br","hr","h1","h2","h3","h4","h5","h6","blockquote","pre","code","ul","ol","li","b","strong","i","em","u","s","strike","del","sub","sup","font","span","a","img","table","thead","tbody","tfoot","tr","th","td","caption"]),BL=new Set(["style","class","href","target","rel","src","alt","width","height","face","size","color","colspan","rowspan"]),_L=new Set(["behavior","-moz-binding","filter"]),vL=/expression\s*\(|javascript\s*:|vbscript\s*:/i;function QL(l){const t=document.createElement("span");t.setAttribute("style",l);const i=t.style,n=[];for(let o=0;o<i.length;o++){const s=i[o],r=i.getPropertyValue(s);_L.has(s)||vL.test(r)||/url\s*\(/i.test(r)&&!/url\s*\(\s*['"]?data:image\//i.test(r)||n.push(`${s}:${r}`)}return n.join(";")}const AL=new Set(["https:","http:","ftp:","mailto:","tel:"]);function $L(l){const t=l.trim();if(t.startsWith("/")||t.startsWith(".")||t.startsWith("#"))return!0;try{const i=new URL(t);return AL.has(i.protocol)}catch{return!/^[a-z][a-z0-9+\-.]*:/i.test(t)}}function el(l){var s,r,a;if(l.nodeType===Node.COMMENT_NODE||l.nodeType===Node.PROCESSING_INSTRUCTION_NODE){(s=l.parentNode)==null||s.removeChild(l);return}if(l.nodeType!==Node.ELEMENT_NODE)return;const t=l,i=t.tagName.toLowerCase();if(!HL.has(i)){for(;t.firstChild;)(r=t.parentNode)==null||r.insertBefore(t.firstChild,t);(a=t.parentNode)==null||a.removeChild(t);return}const n=Array.from(t.attributes);for(const h of n){const d=h.name.toLowerCase();if(d.startsWith("on")){t.removeAttribute(h.name);continue}if(!BL.has(d)){t.removeAttribute(h.name);continue}if((d==="href"||d==="src")&&!$L(h.value)){t.removeAttribute(h.name);continue}if(d==="style"){const I=QL(h.value);I?t.setAttribute("style",I):t.removeAttribute("style");continue}}i==="a"&&t.getAttribute("target")==="_blank"&&t.setAttribute("rel","noopener noreferrer");const o=Array.from(t.childNodes);for(let h=o.length-1;h>=0;h--)el(o[h])}function de(l){if(!l)return"";const t=new DOMParser().parseFromString(l,"text/html");t.head.innerHTML="";const i=Array.from(t.body.childNodes);for(let n=i.length-1;n>=0;n--)el(i[n]);return t.body.innerHTML}function tl(l){const t=document.createElement("div");return t.innerHTML=l,t.textContent??t.innerText??""}function qL(l,t){function i(d,I){l.value&&(l.value.focus(),document.execCommand(d,!1,I??""),t())}function n(d){try{return document.queryCommandState(d)}catch{return!1}}function o(d){l.value&&(l.value.focus(),document.execCommand("formatBlock",!1,d),t())}function s(d){l.value&&(l.value.focus(),document.execCommand("fontName",!1,d),t())}function r(d){l.value&&(l.value.focus(),document.execCommand("foreColor",!1,d),t())}function a(d){l.value&&(l.value.focus(),document.execCommand("hiliteColor",!1,d),t())}function h(d){const I=window.getSelection();if(!I||I.rangeCount===0)return;let b=I.anchorNode;b.nodeType===Node.TEXT_NODE&&(b=b.parentElement);const u=b.closest(".vt-editor__content > *");if(!u)return;const y=parseInt(u.style.marginLeft||"0",10),p=20,V=d==="indent"?y+p:Math.max(0,y-p);u.style.marginLeft=V?`${V}px`:"",t()}return{exec:i,isActive:n,applyBlock:o,applyFont:s,applyForeColor:r,applyBackColor:a,handleIndent:h}}function eW(){let l=null;function t(){const s=window.getSelection();s&&s.rangeCount>0&&(l=s.getRangeAt(0).cloneRange())}function i(){if(!l)return;const s=window.getSelection();s&&(s.removeAllRanges(),s.addRange(l))}function n(){l=null}function o(){return l}return{saveSelection:t,restoreSelection:i,clearSavedRange:n,getSavedRange:o}}function tW(l,t){const{saveSelection:i,restoreSelection:n,clearSavedRange:o,getSavedRange:s}=eW(),r=e.ref({visible:!1,url:"",text:"",openInNewTab:!1});function a(){var R,X;i();const p=window.getSelection(),V=(p==null?void 0:p.toString())??"",m=(X=(R=p==null?void 0:p.anchorNode)==null?void 0:R.parentElement)==null?void 0:X.closest("a");r.value={visible:!0,url:(m==null?void 0:m.getAttribute("href"))??"",text:V,openInNewTab:(m==null?void 0:m.getAttribute("target"))==="_blank"}}function h(){n();const{url:p,text:V,openInNewTab:m}=r.value;if(!p){d();return}const R=document.createElement("a");R.href=p,R.textContent=V||p,m&&R.setAttribute("target","_blank"),R.setAttribute("rel","noopener noreferrer");const X=s(),Y=window.getSelection();Y&&Y.rangeCount>0&&X?(X.deleteContents(),X.insertNode(R)):l(R.outerHTML),d(),t()}function d(){r.value={visible:!1,url:"",text:"",openInNewTab:!1},o()}const I=e.ref({visible:!1,url:"",alt:""});function b(){i(),I.value={visible:!0,url:"",alt:""}}function u(){n();const{url:p,alt:V}=I.value;if(!p){y();return}l(`<img src="${p}" alt="${V}" style="max-width:100%;" />`),y()}function y(){I.value={visible:!1,url:"",alt:""},o()}return{linkState:r,openLinkDialog:a,confirmLink:h,cancelLink:d,imageState:I,openImageDialog:b,confirmImage:u,cancelImage:y}}const f1={undo:"undo",redo:"redo",bold:"textBold",italic:"textItalic",underline:"textUnderline",strikethrough:"textStrikethrough",subscript:"subscript",superscript:"superscript",orderedList:"orderedList",unorderedList:"unorderedList",indent:"indent",outdent:"outdent",alignLeft:"alignLeft",alignCenter:"alignCenter",alignRight:"alignRight",alignJustify:"alignJustify",link:"link",image:"image",blockquote:"blockquote",clearFormat:"clearFormat",html:"html"},lW=[{value:"p",label:"Paragraph"},{value:"h1",label:"Heading 1"},{value:"h2",label:"Heading 2"},{value:"h3",label:"Heading 3"},{value:"h4",label:"Heading 4"}],iW=[{value:"Arial",label:"Arial"},{value:"Times New Roman",label:"Times New Roman"},{value:"Courier New",label:"Courier New"},{value:"Georgia",label:"Georgia"},{value:"Verdana",label:"Verdana"}];function oW(l,t){const{t:i}=W1(),n=e.ref(0);function o(){n.value++}function s(h){var d;return n.value,((d=h.activeCheck)==null?void 0:d.call(h))??!1}function r(h){const d=[];return h.forEach((I,b)=>{switch(b>0&&d.push({type:"separator"}),I){case"history":d.push({type:"button",id:"undo",tooltip:i(c.EDITOR_UNDO),iconName:f1.undo,action:()=>t.exec("undo")},{type:"button",id:"redo",tooltip:i(c.EDITOR_REDO),iconName:f1.redo,action:()=>t.exec("redo")});break;case"format":d.push({type:"button",id:"bold",tooltip:i(c.EDITOR_BOLD),iconName:f1.bold,action:()=>t.exec("bold"),activeCheck:()=>t.isActive("bold")},{type:"button",id:"italic",tooltip:i(c.EDITOR_ITALIC),iconName:f1.italic,action:()=>t.exec("italic"),activeCheck:()=>t.isActive("italic")},{type:"button",id:"underline",tooltip:i(c.EDITOR_UNDERLINE),iconName:f1.underline,action:()=>t.exec("underline"),activeCheck:()=>t.isActive("underline")},{type:"button",id:"strikethrough",tooltip:i(c.EDITOR_STRIKETHROUGH),iconName:f1.strikethrough,action:()=>t.exec("strikethrough"),activeCheck:()=>t.isActive("strikeThrough")});break;case"script":d.push({type:"button",id:"subscript",tooltip:i(c.EDITOR_SUBSCRIPT),iconName:f1.subscript,action:()=>t.exec("subscript"),activeCheck:()=>t.isActive("subscript")},{type:"button",id:"superscript",tooltip:i(c.EDITOR_SUPERSCRIPT),iconName:f1.superscript,action:()=>t.exec("superscript"),activeCheck:()=>t.isActive("superscript")});break;case"heading":d.push({type:"select",id:"heading"});break;case"fontName":d.push({type:"select",id:"fontName"});break;case"foreColor":d.push({type:"select",id:"foreColor"});break;case"align":d.push({type:"button",id:"alignLeft",tooltip:i(c.EDITOR_ALIGN_LEFT),iconName:f1.alignLeft,action:()=>t.exec("justifyLeft"),activeCheck:()=>t.isActive("justifyLeft")},{type:"button",id:"alignCenter",tooltip:i(c.EDITOR_ALIGN_CENTER),iconName:f1.alignCenter,action:()=>t.exec("justifyCenter"),activeCheck:()=>t.isActive("justifyCenter")},{type:"button",id:"alignRight",tooltip:i(c.EDITOR_ALIGN_RIGHT),iconName:f1.alignRight,action:()=>t.exec("justifyRight"),activeCheck:()=>t.isActive("justifyRight")},{type:"button",id:"alignJustify",tooltip:i(c.EDITOR_ALIGN_JUSTIFY),iconName:f1.alignJustify,action:()=>t.exec("justifyFull"),activeCheck:()=>t.isActive("justifyFull")});break;case"list":d.push({type:"button",id:"orderedList",tooltip:i(c.EDITOR_ORDERED_LIST),iconName:f1.orderedList,action:()=>t.exec("insertOrderedList"),activeCheck:()=>t.isActive("insertOrderedList")},{type:"button",id:"unorderedList",tooltip:i(c.EDITOR_UNORDERED_LIST),iconName:f1.unorderedList,action:()=>t.exec("insertUnorderedList"),activeCheck:()=>t.isActive("insertUnorderedList")});break;case"indent":d.push({type:"button",id:"indent",tooltip:i(c.EDITOR_INDENT),iconName:f1.indent,action:()=>t.handleIndent("indent")},{type:"button",id:"outdent",tooltip:i(c.EDITOR_OUTDENT),iconName:f1.outdent,action:()=>t.handleIndent("outdent")});break;case"link":d.push({type:"button",id:"link",tooltip:i(c.EDITOR_INSERT_LINK),iconName:f1.link,action:t.openLinkDialog});break;case"image":d.push({type:"button",id:"image",tooltip:i(c.EDITOR_INSERT_IMAGE),iconName:f1.image,action:t.openImageDialog});break;case"blockquote":d.push({type:"button",id:"blockquote",tooltip:i(c.EDITOR_BLOCKQUOTE),iconName:f1.blockquote,action:()=>t.applyBlock("blockquote")});break;case"clear":d.push({type:"button",id:"clear",tooltip:i(c.EDITOR_CLEAR_FORMAT),iconName:f1.clearFormat,action:()=>t.exec("removeFormat")});break;case"html":d.push({type:"button",id:"html",tooltip:i(c.EDITOR_HTML_SOURCE),iconName:f1.html,action:t.toggleHtmlMode,activeCheck:t.isHtmlMode});break}}),d}return{toolbarItems:e.computed(()=>r(l())),selectionTick:n,onSelectionChange:o,getItemActive:s,HEADING_GROUPS:lW,FONT_GROUPS:iW}}const nW={key:0,class:"vt-editor__toolbar-wrapper"},sW={key:0,class:"vt-editor__toolbar-sep"},cW=["value"],rW=["value"],aW=["onClick"],dW={class:"vt-editor__body"},mW=["contenteditable","data-placeholder"],hW={key:1,class:"vt-editor__error"},IW={class:"vt-editor__dialog-fields"},pW={class:"vt-editor__dialog-label"},ZW={class:"vt-editor__dialog-label"},uW={class:"vt-editor__dialog-checkbox"},bW={class:"vt-modal__footer"},CW={class:"vt-editor__dialog-fields"},yW={class:"vt-editor__dialog-label"},VW={class:"vt-editor__dialog-label"},SW={class:"vt-modal__footer"},ll=e.defineComponent({__name:"VEditor",props:{modelValue:{},placeholder:{},toolbar:{default:()=>["history","format","heading","fontName","foreColor","align","list","indent","link","image","blockquote","clear","html"]},disabled:{type:Boolean,default:!1},required:{type:Boolean},errorMessage:{}},emits:["update:modelValue","input","change","focus","blur","validation"],setup(l,{expose:t,emit:i}){const{t:n}=W1(),o=l,s=i,r=e.ref(null),a=e.ref(null),h=e.ref(null),d=e.ref(!1),I=e.ref(!1),b=e.ref(""),u=e.ref([]),y=e.ref(!0),p=e.ref(!1),V=e.ref(!1),m=e.ref("#000000"),R=e.ref("#ffffff");function X(Q){var f;const H=Q??((f=r.value)==null?void 0:f.innerHTML)??"",I1=de(H);s("update:modelValue",I1),s("input",I1)}const{exec:Y,isActive:x,applyBlock:G,applyFont:L,applyForeColor:Z,applyBackColor:w,handleIndent:W}=qL(r,X);function S(){if(r.value)if(!I.value)b.value=r.value.innerHTML,I.value=!0,e.nextTick(()=>{var Q;return(Q=h.value)==null?void 0:Q.focus()});else{const Q=de(b.value);I.value=!1,e.nextTick(()=>{r.value&&(r.value.innerHTML=Q,X(Q),r.value.focus())})}}function K(){const Q=de(b.value);s("update:modelValue",Q),s("input",Q)}const{linkState:J,openLinkDialog:g,confirmLink:E,cancelLink:T,imageState:z,openImageDialog:A,confirmImage:n1,cancelImage:N}=tW(Q=>Y("insertHTML",Q),X),{toolbarItems:F,onSelectionChange:O,getItemActive:q,HEADING_GROUPS:e1,FONT_GROUPS:s1}=oW(()=>o.toolbar,{exec:Y,isActive:x,applyBlock:G,applyFont:L,handleIndent:W,openLinkDialog:g,openImageDialog:A,toggleHtmlMode:S,isHtmlMode:()=>I.value});function V1(Q){const H=Q.target.value;m.value=H,Z(H)}function a1(Q){const H=Q.target.value;R.value=H,w(H)}function c1(){const Q=a.value;Q&&(p.value=Q.scrollLeft>2,V.value=Q.scrollLeft+Q.clientWidth<Q.scrollWidth-2)}function C1(Q){const H=a.value;H&&(H.scrollBy({left:Q==="left"?-160:160,behavior:"smooth"}),setTimeout(c1,250))}function Y1(Q){const H=[];o.required&&!tl(Q).trim()&&H.push(n(c.VALIDATION_REQUIRED)),u.value=H,y.value=H.length===0,s("validation",{isValid:y.value,errors:H})}const p1=e.computed(()=>o.errorMessage||u.value[0]||""),k=e.computed(()=>!!p1.value),P=e.computed(()=>["vt-editor",{"vt-editor--focused":d.value,"vt-editor--error":k.value,"vt-editor--disabled":o.disabled}]);function B(){X(),Y1(o.modelValue??"")}function b1(Q){d.value=!0,s("focus",Q)}function k1(Q){d.value=!1,s("blur",Q),Y1(o.modelValue??"")}function N1(Q){Q.key==="Tab"&&(Q.preventDefault(),Y("insertHTML","&nbsp;&nbsp;&nbsp;&nbsp;"))}e.watch(()=>o.modelValue,Q=>{!r.value||d.value||I.value||r.value.innerHTML!==Q&&(r.value.innerHTML=Q??"")}),e.onMounted(()=>{r.value&&o.modelValue&&(r.value.innerHTML=de(o.modelValue)),document.addEventListener("selectionchange",O),e.nextTick(()=>{c1();const Q=new ResizeObserver(c1);a.value&&Q.observe(a.value)}),window.addEventListener("resize",c1)}),e.onBeforeUnmount(()=>{document.removeEventListener("selectionchange",O),window.removeEventListener("resize",c1)});function w1(){var Q;(Q=r.value)==null||Q.focus()}function A1(){var Q;(Q=r.value)==null||Q.blur()}function j1(){r.value&&(r.value.innerHTML=""),X(""),u.value=[],y.value=!0,s("validation",{isValid:!0,errors:[]})}function $1(){var Q;return((Q=r.value)==null?void 0:Q.innerHTML)??""}function B1(){var Q;return tl(((Q=r.value)==null?void 0:Q.innerHTML)??"")}function v1(Q){const H=de(Q);r.value&&(r.value.innerHTML=H),X(H)}function U1(Q){var H;(H=r.value)==null||H.focus(),Y("insertHTML",de(Q))}function E1(){return Y1(o.modelValue??""),y.value}function le(){u.value=[],y.value=!0,s("validation",{isValid:!0,errors:[]})}function i1(){return{isValid:y.value,errors:[...u.value]}}function r1(){return r.value}return t({focus:w1,blur:A1,clear:j1,getHTML:$1,getText:B1,setHTML:v1,insertHTML:U1,validate:E1,clearValidation:le,getValidationState:i1,getEditorElement:r1}),(Q,H)=>{const I1=e.resolveDirective("tooltip");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(P.value)},[!l.disabled&&e.unref(F).length?(e.openBlock(),e.createElementBlock("div",nW,[p.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"vt-editor__toolbar-scroll-btn vt-editor__toolbar-scroll-btn--left",type:"button",onClick:H[0]||(H[0]=f=>C1("left")),onMousedown:H[1]||(H[1]=e.withModifiers(()=>{},["prevent"]))},[e.createVNode(h1,{name:"arrowLeft"})],32)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"toolbarRef",ref:a,class:"vt-editor__toolbar",onScroll:c1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(F),(f,v)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:v},[(f==null?void 0:f.type)==="separator"?(e.openBlock(),e.createElementBlock("span",sW)):(f==null?void 0:f.type)==="select"&&f.id==="heading"?(e.openBlock(),e.createBlock(oe,{key:1,"max-height":220,class:"vt-editor__toolbar-btn",placement:"bottom-start",trigger:"hover",onMousedown:H[3]||(H[3]=e.withModifiers(()=>{},["prevent"]))},{dropdown:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(e1),M=>(e.openBlock(),e.createBlock(ne,{key:M.value,onClick:$=>e.unref(G)(M.value),onMousedown:H[2]||(H[2]=e.withModifiers(()=>{},["prevent"]))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(M.label),1)]),_:2},1032,["onClick"]))),128))]),default:e.withCtx(()=>[e.withDirectives(e.createVNode(h1,{name:"tagType"},null,512),[[I1,e.unref(n)(e.unref(c).EDITOR_HEADING)]])]),_:1})):(f==null?void 0:f.type)==="select"&&f.id==="fontName"?(e.openBlock(),e.createBlock(oe,{key:2,"max-height":220,class:"vt-editor__toolbar-btn",placement:"bottom-start",trigger:"hover",onMousedown:H[5]||(H[5]=e.withModifiers(()=>{},["prevent"]))},{dropdown:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s1),M=>(e.openBlock(),e.createBlock(ne,{key:M.value,onClick:$=>e.unref(L)(M.value),onMousedown:H[4]||(H[4]=e.withModifiers(()=>{},["prevent"]))},{default:e.withCtx(()=>[e.createElementVNode("span",{style:e.normalizeStyle({fontFamily:M.value})},e.toDisplayString(M.label),5)]),_:2},1032,["onClick"]))),128))]),default:e.withCtx(()=>[e.withDirectives(e.createVNode(h1,{name:"fontName"},null,512),[[I1,e.unref(n)(e.unref(c).EDITOR_FONT)]])]),_:1})):(f==null?void 0:f.type)==="select"&&f.id==="foreColor"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.withDirectives(e.createElementVNode("input",{value:m.value,class:"vt-editor__color-picker",type:"color",onInput:V1,onMousedown:H[6]||(H[6]=e.withModifiers(()=>{},["stop"]))},null,40,cW),[[I1,e.unref(n)(e.unref(c).EDITOR_FORE_COLOR)]]),e.withDirectives(e.createElementVNode("input",{value:R.value,class:"vt-editor__color-picker vt-editor__color-picker--bg",type:"color",onInput:a1,onMousedown:H[7]||(H[7]=e.withModifiers(()=>{},["stop"]))},null,40,rW),[[I1,e.unref(n)(e.unref(c).EDITOR_BACK_COLOR)]])],64)):(f==null?void 0:f.type)==="button"?e.withDirectives((e.openBlock(),e.createElementBlock("button",{key:4,class:e.normalizeClass([{"vt-editor__toolbar-btn--active":e.unref(q)(f)},"vt-editor__toolbar-btn"]),type:"button",onClick:M=>{var $;return($=f==null?void 0:f.action)==null?void 0:$.call(f)},onMousedown:H[8]||(H[8]=e.withModifiers(()=>{},["prevent"]))},[f!=null&&f.iconName?(e.openBlock(),e.createBlock(h1,{key:0,name:f.iconName},null,8,["name"])):e.createCommentVNode("",!0)],42,aW)),[[I1,f==null?void 0:f.tooltip]]):e.createCommentVNode("",!0)],64))),128))],544),V.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:"vt-editor__toolbar-scroll-btn vt-editor__toolbar-scroll-btn--right",type:"button",onClick:H[9]||(H[9]=f=>C1("right")),onMousedown:H[10]||(H[10]=e.withModifiers(()=>{},["prevent"]))},[e.createVNode(h1,{name:"arrowRight"})],32)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",dW,[e.withDirectives(e.createElementVNode("div",{ref_key:"editorRef",ref:r,contenteditable:!l.disabled,"data-placeholder":l.placeholder,class:"vt-editor__content",onBlur:k1,onFocus:b1,onInput:B,onKeydown:N1},null,40,mW),[[e.vShow,!I.value]]),I.value?e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{key:0,ref_key:"htmlSourceRef",ref:h,"onUpdate:modelValue":H[11]||(H[11]=f=>b.value=f),class:"vt-editor__html-source",onInput:K},null,544)),[[e.vModelText,b.value]]):e.createCommentVNode("",!0)]),p1.value?(e.openBlock(),e.createElementBlock("div",hW,e.toDisplayString(p1.value),1)):e.createCommentVNode("",!0),e.createVNode(pe,{modelValue:e.unref(J).visible,"onUpdate:modelValue":H[19]||(H[19]=f=>e.unref(J).visible=f),"close-on-backdrop-click":!1,title:e.unref(n)(e.unref(c).EDITOR_LINK_TITLE),size:"small",onClose:e.unref(T)},{default:e.withCtx(()=>[e.createElementVNode("div",IW,[e.createElementVNode("label",pW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_LINK_URL)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":H[12]||(H[12]=f=>e.unref(J).url=f),class:"vt-editor__dialog-input",placeholder:"https://example.com",type:"url",onKeydown:[H[13]||(H[13]=e.withKeys((...f)=>e.unref(E)&&e.unref(E)(...f),["enter"])),H[14]||(H[14]=e.withKeys((...f)=>e.unref(T)&&e.unref(T)(...f),["esc"]))]},null,544),[[e.vModelText,e.unref(J).url]]),e.createElementVNode("label",ZW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_LINK_TEXT)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":H[15]||(H[15]=f=>e.unref(J).text=f),class:"vt-editor__dialog-input",placeholder:"Link text",type:"text",onKeydown:[H[16]||(H[16]=e.withKeys((...f)=>e.unref(E)&&e.unref(E)(...f),["enter"])),H[17]||(H[17]=e.withKeys((...f)=>e.unref(T)&&e.unref(T)(...f),["esc"]))]},null,544),[[e.vModelText,e.unref(J).text]]),e.createElementVNode("label",uW,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":H[18]||(H[18]=f=>e.unref(J).openInNewTab=f),type:"checkbox"},null,512),[[e.vModelCheckbox,e.unref(J).openInNewTab]]),e.createTextVNode(" "+e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_LINK_NEW_TAB)),1)])]),e.createElementVNode("div",bW,[e.createVNode(x1,{onClick:e.unref(T)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).BUTTON_CANCEL)),1)]),_:1},8,["onClick"]),e.createVNode(x1,{type:"primary",onClick:e.unref(E)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_INSERT)),1)]),_:1},8,["onClick"])])]),_:1},8,["modelValue","title","onClose"]),e.createVNode(pe,{modelValue:e.unref(z).visible,"onUpdate:modelValue":H[26]||(H[26]=f=>e.unref(z).visible=f),"close-on-backdrop-click":!1,title:e.unref(n)(e.unref(c).EDITOR_IMAGE_TITLE),size:"small",onClose:e.unref(N)},{default:e.withCtx(()=>[e.createElementVNode("div",CW,[e.createElementVNode("label",yW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_IMAGE_URL)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":H[20]||(H[20]=f=>e.unref(z).url=f),class:"vt-editor__dialog-input",placeholder:"https://example.com/image.png",type:"url",onKeydown:[H[21]||(H[21]=e.withKeys((...f)=>e.unref(n1)&&e.unref(n1)(...f),["enter"])),H[22]||(H[22]=e.withKeys((...f)=>e.unref(N)&&e.unref(N)(...f),["esc"]))]},null,544),[[e.vModelText,e.unref(z).url]]),e.createElementVNode("label",VW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_IMAGE_ALT)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":H[23]||(H[23]=f=>e.unref(z).alt=f),class:"vt-editor__dialog-input",placeholder:"Image description",type:"text",onKeydown:[H[24]||(H[24]=e.withKeys((...f)=>e.unref(n1)&&e.unref(n1)(...f),["enter"])),H[25]||(H[25]=e.withKeys((...f)=>e.unref(N)&&e.unref(N)(...f),["esc"]))]},null,544),[[e.vModelText,e.unref(z).alt]])]),e.createElementVNode("div",SW,[e.createVNode(x1,{onClick:e.unref(N)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).BUTTON_CANCEL)),1)]),_:1},8,["onClick"]),e.createVNode(x1,{type:"primary",onClick:e.unref(n1)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_INSERT)),1)]),_:1},8,["onClick"])])]),_:1},8,["modelValue","title","onClose"])],2)}}}),YW={class:"vt-badge"},De=e.defineComponent({__name:"VBadge",props:{content:{default:void 0},max:{default:99},dot:{type:Boolean,default:!1},color:{default:"danger"},position:{default:"top-end"},offsetX:{default:0},offsetY:{default:0},bordered:{type:Boolean,default:!1},hidden:{type:Boolean,default:!1}},setup(l){const t=l,i=e.computed(()=>t.dot?!0:t.content===void 0||t.content===null||t.content===""?!1:typeof t.content=="number"?t.content>0:!0),n=e.computed(()=>i.value&&!t.hidden),o=e.computed(()=>typeof t.content=="number"?t.content>t.max?`${t.max}+`:String(t.content):t.content),s=e.computed(()=>{if(!t.offsetX&&!t.offsetY)return{};const r=t.position.startsWith("top"),a=t.position.endsWith("end"),h={};return t.offsetX&&(h[a?"right":"left"]=`${-t.offsetX}px`),t.offsetY&&(h[r?"top":"bottom"]=`${-t.offsetY}px`),h});return(r,a)=>(e.openBlock(),e.createElementBlock("span",YW,[e.renderSlot(r.$slots,"default"),e.createVNode(e.Transition,{name:"vt-badge__fade"},{default:e.withCtx(()=>[n.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["vt-badge__content",[`vt-badge__content--${l.position}`,`vt-badge__content--${l.color}`,{"vt-badge__content--dot":l.dot,"vt-badge__content--bordered":l.bordered}]]),style:e.normalizeStyle(s.value)},[l.dot?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(o.value),1)],64))],6)):e.createCommentVNode("",!0)]),_:1})]))}}),LW={class:"vt-app-bar__logo"},WW={key:0,class:"vt-app-bar__center"},kW={key:1,class:"vt-app-bar__actions"},il=e.defineComponent({__name:"VAppBar",props:{sticky:{type:Boolean,default:!1}},setup(l){return(t,i)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vt-app-bar",{"vt-app-bar--sticky":l.sticky}])},[e.createElementVNode("div",LW,[e.renderSlot(t.$slots,"logo")]),t.$slots.center?(e.openBlock(),e.createElementBlock("div",WW,[e.renderSlot(t.$slots,"center")])):e.createCommentVNode("",!0),t.$slots.actions?(e.openBlock(),e.createElementBlock("div",kW,[e.renderSlot(t.$slots,"actions")])):e.createCommentVNode("",!0)],2))}}),MW={class:"vt-nav-rail"},NW={class:"vt-nav-rail__list"},XW=["data-placement","onClick"],TW={key:0,class:"vt-nav-rail__divider"},wW={key:0,class:"vt-nav-rail__footer"},ol=e.defineComponent({__name:"VNavRail",props:{items:{},modelValue:{default:null},placement:{default:"left"}},emits:["update:modelValue","select"],setup(l,{emit:t}){const i=t,n=o=>{o.disabled||(i("update:modelValue",o.key),i("select",o))};return(o,s)=>{const r=e.resolveDirective("tooltip");return e.openBlock(),e.createElementBlock("aside",MW,[e.createElementVNode("div",NW,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.items,(a,h)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:a.key},[e.withDirectives((e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vt-nav-rail__item",{"vt-nav-rail__item--selected":l.modelValue===a.key,"vt-nav-rail__item--disabled":a.disabled}]),"data-placement":l.placement,onClick:d=>n(a)},[a.badge?(e.openBlock(),e.createBlock(De,{key:0,content:a.badge.content,position:a.badge.position},{default:e.withCtx(()=>[e.createVNode(h1,{name:a.icon,width:24,height:24},null,8,["name"])]),_:2},1032,["content","position"])):(e.openBlock(),e.createBlock(h1,{key:1,name:a.icon,width:24,height:24},null,8,["name"]))],10,XW)),[[r,a.label]]),h<l.items.length-1?(e.openBlock(),e.createElementBlock("span",TW)):e.createCommentVNode("",!0)],64))),128))]),o.$slots.footer?(e.openBlock(),e.createElementBlock("div",wW,[e.renderSlot(o.$slots,"footer")])):e.createCommentVNode("",!0)])}}}),nl=(l,t)=>{const i=document.createElement("div");i.className=`vt-tooltip vt-tooltip--${t}`,i.innerText=l,Object.assign(i.style,{position:"absolute",background:"rgba(0, 0, 0, 0.8)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"12px",lineHeight:"1.4",zIndex:"9999",pointerEvents:"none",visibility:"hidden",opacity:"0",transition:"opacity 0.2s ease, visibility 0.2s ease",maxWidth:"300px",wordWrap:"break-word",whiteSpace:"normal",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.2)"});const n=document.createElement("div");switch(n.className="vt-tooltip__arrow",Object.assign(n.style,{position:"absolute",width:"0",height:"0",borderStyle:"solid"}),t){case"top":Object.assign(n.style,{top:"100%",left:"50%",marginLeft:"-5px",borderWidth:"5px 5px 0 5px",borderColor:"rgba(0, 0, 0, 0.8) transparent transparent transparent"});break;case"bottom":Object.assign(n.style,{bottom:"100%",left:"50%",marginLeft:"-5px",borderWidth:"0 5px 5px 5px",borderColor:"transparent transparent rgba(0, 0, 0, 0.8) transparent"});break;case"left":Object.assign(n.style,{top:"50%",left:"100%",marginTop:"-5px",borderWidth:"5px 0 5px 5px",borderColor:"transparent transparent transparent rgba(0, 0, 0, 0.8)"});break;case"right":Object.assign(n.style,{top:"50%",right:"100%",marginTop:"-5px",borderWidth:"5px 5px 5px 0",borderColor:"transparent rgba(0, 0, 0, 0.8) transparent transparent"});break}return i.appendChild(n),i},Pe=(l,t,i)=>{const n=t.getBoundingClientRect(),o=window.pageXOffset||document.documentElement.scrollLeft,s=window.pageYOffset||document.documentElement.scrollTop,r=window.innerWidth,a=window.innerHeight,h=8,d=Math.min(300,r-h*2);l.style.maxWidth=`${d}px`;const I=l.getBoundingClientRect();let b=0,u=0;switch(i){case"top":b=n.top+s-I.height-8,u=n.left+o+(n.width-I.width)/2;break;case"bottom":b=n.bottom+s+8,u=n.left+o+(n.width-I.width)/2;break;case"left":b=n.top+s+(n.height-I.height)/2,u=n.left+o-I.width-8;break;case"right":b=n.top+s+(n.height-I.height)/2,u=n.right+o+8;break}u<h?u=h:u+I.width>r-h&&(u=r-I.width-h),b<s+h?i==="top"?b=n.bottom+s+8:b=s+h:b+I.height>s+a-h&&(i==="bottom"?b=n.top+s-I.height-8:b=s+a-I.height-h),l.style.top=`${b}px`,l.style.left=`${u}px`},sl=(l,t,i)=>{l.parentElement||document.body.appendChild(l),l.style.visibility="visible",Pe(l,t,i),requestAnimationFrame(()=>{l.style.opacity="1"})},cl=l=>{l.style.opacity="0",l.style.visibility="hidden"},rl=l=>l.scrollWidth>l.clientWidth||l.scrollHeight>l.clientHeight,al=l=>!!l.closest(".vt-table, table"),dl={mounted(l,t){var h;const i=(h=t.value)==null?void 0:h.trim();if(!i)return;const n=l.dataset.placement||"top",o=nl(i,n);l.__tooltipEl=o;const s=()=>{(al(l)?rl(l):!0)&&sl(o,l,n)},r=()=>{cl(o)},a=()=>{o.style.opacity==="1"&&Pe(o,l,n)};l.__mouseenterHandler=s,l.__mouseleaveHandler=r,l.__scrollHandler=a,l.addEventListener("mouseenter",s),l.addEventListener("mouseleave",r),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a)},updated(l,t){var n;const i=(n=t.value)==null?void 0:n.trim();if(l.__tooltipEl)i?l.__tooltipEl.firstChild.textContent=i:(l.__tooltipEl.parentElement&&l.__tooltipEl.parentElement.removeChild(l.__tooltipEl),delete l.__tooltipEl);else if(i){const o=l.dataset.placement||"top",s=nl(i,o);l.__tooltipEl=s;const r=()=>{(al(l)?rl(l):!0)&&sl(s,l,o)},a=()=>{cl(s)},h=()=>{s.style.opacity==="1"&&Pe(s,l,o)};l.__mouseenterHandler=r,l.__mouseleaveHandler=a,l.__scrollHandler=h,l.addEventListener("mouseenter",r),l.addEventListener("mouseleave",a),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h)}},beforeUnmount(l){l.__tooltipEl&&l.__tooltipEl.parentElement&&(l.__tooltipEl.parentElement.removeChild(l.__tooltipEl),delete l.__tooltipEl),l.__mouseenterHandler&&(l.removeEventListener("mouseenter",l.__mouseenterHandler),delete l.__mouseenterHandler),l.__mouseleaveHandler&&(l.removeEventListener("mouseleave",l.__mouseleaveHandler),delete l.__mouseleaveHandler),l.__scrollHandler&&(window.removeEventListener("scroll",l.__scrollHandler,!0),window.removeEventListener("resize",l.__scrollHandler),delete l.__scrollHandler)}},ml={mounted(l,t){e.unref(t.value)&&hl(l)},updated(l,t){const i=e.unref(t.value),n=e.unref(t.oldValue);i!==n&&(i?hl(l):Il(l))},unmounted(l){Il(l)}};function hl(l){if(l._loaderEl)return;const t=document.createElement("div");t.className="vt-loader-base__overlay",t.innerHTML='<span class="vt-loader-base"></span>';const i=getComputedStyle(l).position;(i==="static"||!i)&&(l.style.position="relative"),l.appendChild(t),l._loaderEl=t}function Il(l){const t=l._loaderEl;t&&(t.remove(),delete l._loaderEl)}const GW={class:"vt-message-container"},xW={class:"vt-message-icon"},gW={class:"vt-message-content"},fW={key:0,class:"vt-message-title"},EW=["innerHTML"],JW={key:1,class:"vt-message-text"},KW=["onClick"],FW=e.defineComponent({__name:"VMessage",setup(l,{expose:t}){const i=e.ref([]);let n=0;const o=a=>({success:"checkCircle",danger:"alertCircle",warning:"alertTriangle",primary:"infoCircle"})[a]||"infoCircle",s=a=>{const h=++n,d={id:h,message:a.message||"",title:a.title||"",type:a.type||"primary",showClose:a.showClose||!1,duration:a.duration!==void 0?a.duration:3e3,dangerouslyUseHTMLString:a.dangerouslyUseHTMLString||!1};return i.value.push(d),d.duration&&d.duration>0&&setTimeout(()=>{r(h)},d.duration),h},r=a=>{const h=i.value.findIndex(d=>d.id===a);h>-1&&i.value.splice(h,1)};return t({addMessage:s,removeMessage:r}),(a,h)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createElementVNode("div",GW,[e.createVNode(e.TransitionGroup,{name:"vt-message",tag:"div"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,d=>(e.openBlock(),e.createElementBlock("div",{key:d.id,class:e.normalizeClass(["vt-message-item",`vt-message-item--${d.type}`,{"vt-message-item--closable":d.showClose}])},[e.createElementVNode("div",xW,[e.createVNode(h1,{color:d.type==="primary"?"#00475A":"",name:o(d.type)},null,8,["color","name"])]),e.createElementVNode("div",gW,[d.title?(e.openBlock(),e.createElementBlock("div",fW,e.toDisplayString(d.title),1)):e.createCommentVNode("",!0),d.message?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[d.dangerouslyUseHTMLString?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vt-message-text",innerHTML:d.message},null,8,EW)):(e.openBlock(),e.createElementBlock("div",JW,e.toDisplayString(d.message),1))],64)):e.createCommentVNode("",!0)]),d.showClose?(e.openBlock(),e.createElementBlock("button",{key:0,class:"vt-message-close",type:"button",onClick:I=>r(d.id)},[e.createVNode(h1,{name:"close"})],8,KW)):e.createCommentVNode("",!0)],2))),128))]),_:1})])]))}});class jW{constructor(){this.messageInstance=null,this.app=null,this.container=null}call(t={}){return this.ensureInstance().addMessage({message:t.message||"",title:t.title||"",type:t.type||"primary",showClose:t.showClose||!1,duration:t.duration!==void 0?t.duration:3e3,dangerouslyUseHTMLString:t.dangerouslyUseHTMLString||!1})}success(t,i={}){return this.call({...i,message:t,type:"success"})}danger(t,i={}){return this.call({...i,message:t,type:"danger"})}warning(t,i={}){return this.call({...i,message:t,type:"warning"})}primary(t,i={}){return this.call({...i,message:t,type:"primary"})}close(t){this.messageInstance&&this.messageInstance.removeMessage(t)}closeAll(){this.messageInstance&&(this.messageInstance.messages=[]),this.container&&this.container.parentNode&&document.body.removeChild(this.container),this.app&&this.app.unmount(),this.messageInstance=null,this.app=null,this.container=null}getOpenMessagesCount(){return this.messageInstance?this.messageInstance.messages.length:0}ensureInstance(){return this.messageInstance?this.messageInstance:(this.container=document.createElement("div"),this.container.setAttribute("data-vt-message-container",""),document.body.appendChild(this.container),this.app=e.createApp(FW),this.messageInstance=this.app.mount(this.container),this.messageInstance)}}const H1=new jW,He=Object.assign((l={})=>H1.call(l),{success:(l,t={})=>H1.success(l,t),danger:(l,t={})=>H1.danger(l,t),warning:(l,t={})=>H1.warning(l,t),primary:(l,t={})=>H1.primary(l,t),close:l=>{H1.close(l)},closeAll:()=>{H1.closeAll()}}),pl={install(l){l.config.globalProperties.$message=He,l.provide("$message",He),l.config.globalProperties.$messageStack={closeAll:()=>H1.closeAll(),getCount:()=>H1.getOpenMessagesCount(),closeById:t=>H1.close(t)}}},RW={sortable:!0,actionColumn:!1,showOverflowTooltip:!0,visible:!0,pinnedLeft:!1,pinnedRight:!1,manage:!1};function UW(l){_e(l)}const Zl={install(l,t={}){const{prefix:i="V",modal:n=!0,message:o=!0,locale:s=D1.uk}=t;l.component(`${i}Button`,x1),l.component(`${i}Icon`,h1),l.component(`${i}Loader`,Ie),l.component(`${i}Modal`,pe),l.component(`${i}Pagination`,$e),l.component(`${i}Checkbox`,O1),l.component(`${i}Radiobox`,qe),l.component(`${i}Table`,it),l.component(`${i}TableColumn`,ot),l.component(`${i}Dropdown`,oe),l.component(`${i}DropdownItem`,ne),l.component(`${i}Input`,ae),l.component(`${i}Select`,Se),l.component(`${i}Option`,Ye),l.component(`${i}DatePicker`,It),l.component(`${i}TimePicker`,ue),l.component(`${i}Collapse`,pt),l.component(`${i}CollapseItem`,Zt),l.component(`${i}Tabs`,ut),l.component(`${i}TabItem`,bt),l.component(`${i}Upload`,Vt),l.component(`${i}Sidebar`,St),l.component(`${i}Login`,Tt),l.component(`${i}LoginLogo`,wt),l.component(`${i}LocaleSelect`,nt),l.component(`${i}DynamicFilter`,Gt),l.component(`${i}Slider`,xt),l.component(`${i}SliderMarkRange`,gt),l.component(`${i}Chart`,Et),l.component(`${i}InfoBox`,Jt),l.component(`${i}TransferList`,Kt),l.component(`${i}Avatar`,Ft),l.component(`${i}AvatarUpload`,Rt),l.component(`${i}ImageFullscreen`,zt),l.component(`${i}Breadcrumb`,Ot),l.component(`${i}BreadcrumbItem`,Dt),l.component(`${i}Audio`,qt),l.component(`${i}Empty`,Le),l.component(`${i}Editor`,ll),l.component(`${i}Badge`,De),l.component(`${i}AppBar`,il),l.component(`${i}NavRail`,ol),l.directive("tooltip",dl),l.directive("loader",ml),n&&l.use(lt),o&&l.use(pl),l.use(xZ,{locale:s})}},zW=Zl.install;l1.DEFAULT_COLUMN_CONFIG=RW,l1.DEFAULT_FORMATS=st,l1.DEFAULT_TIME_FORMATS=Ze,l1.DropdownContextKey=ge,l1.FORMAT_TOKENS=gb,l1.FileParser=be,l1.FileValidator=se,l1.LANGUAGES=D1,l1.VAppBar=il,l1.VAudio=qt,l1.VAvatar=Ft,l1.VAvatarUpload=Rt,l1.VBadge=De,l1.VBreadcrumb=Ot,l1.VBreadcrumbItem=Dt,l1.VButton=x1,l1.VChart=Et,l1.VCheckbox=O1,l1.VCollapse=pt,l1.VCollapseItem=Zt,l1.VColorPicker=CL,l1.VDatePicker=It,l1.VDropdown=oe,l1.VDropdownItem=ne,l1.VDynamicFilter=Gt,l1.VEditor=ll,l1.VEmpty=Le,l1.VIcon=h1,l1.VImageFullscreen=zt,l1.VInfoBox=Jt,l1.VInput=ae,l1.VLoader=Ie,l1.VLocaleSelect=nt,l1.VLogin=Tt,l1.VLoginLogo=wt,l1.VMessage=He,l1.VMessagePlugin=pl,l1.VModal=pe,l1.VModalPlugin=lt,l1.VNavRail=ol,l1.VOption=Ye,l1.VPagination=$e,l1.VRadiobox=qe,l1.VSelect=Se,l1.VSidebar=St,l1.VSlider=xt,l1.VSliderMarkRange=gt,l1.VTabItem=bt,l1.VTable=it,l1.VTableColumn=ot,l1.VTabs=ut,l1.VTimePicker=ue,l1.VTimerDuration=VL,l1.VTransferList=Kt,l1.VUpload=Vt,l1.VtSelectContextKey=Ge,l1.containUpperCaseLetter=Mt,l1.default=Zl,l1.email=Yt,l1.formatTime=mt,l1.generateTimeOptions=Me,l1.install=zW,l1.isValidDate=Je,l1.isValidTimeString=ke,l1.loaderDirective=ml,l1.maxLength=xV,l1.maxNumber=fV,l1.messageManager=H1,l1.minLength=Ke,l1.minNumber=gV,l1.mk=GV,l1.modalManager=_1,l1.noSpaces=Fe,l1.numeric=Wt,l1.parseTimeString=ht,l1.pattern=JV,l1.phoneNumber=kt,l1.required=Ne,l1.sameAs=EV,l1.setLocale=UW,l1.tooltipDirective=dl,l1.uniqueAsync=KV,l1.url=Lt,l1.useValidate=Xt,l1.validateDateValue=ct,l1.validateTimeValue=at,l1.withAsync=wV,l1.withMessage=TV,l1.withName=ee,l1.withParams=XV,Object.defineProperties(l1,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
74
+ `,[t,i]}setOptions(t){var i;if(this.options.container!==t.container){const n=this.parentFromOptionsContainer(t.container);n.appendChild(this.container),this.parent=n}t.dragToSeek===!0||typeof this.options.dragToSeek=="object"?this.initDrag():((i=this.dragStream)===null||i===void 0||i.cleanup(),this.dragStream=null),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth-this.containerInlinePadding}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:i}=this.scrollContainer,n=i*t;this.setScroll(n)}destroy(){var t;this.subscriptions.forEach(i=>i()),this.container.remove(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),(t=this.unsubscribeOnScroll)===null||t===void 0||t.forEach(i=>i()),this.unsubscribeOnScroll=[],this.dragStream&&(this.dragStream.cleanup(),this.dragStream=null),this.scrollStream&&(this.scrollStream.cleanup(),this.scrollStream=null)}createDelay(t=10){let i,n;const o=()=>{i&&(clearTimeout(i),i=void 0),n&&(n(),n=void 0)};return this.timeouts.push(o),()=>new Promise((s,r)=>{o(),n=r,i=setTimeout(()=>{i=void 0,n=void 0,s()},t)})}getHeight(t,i){var n;const o=((n=this.audioData)===null||n===void 0?void 0:n.numberOfChannels)||1;return function({optionsHeight:s,optionsSplitChannels:r,parentHeight:a,numberOfChannels:h,defaultHeight:d=128}){if(s==null)return d;const I=Number(s);if(!isNaN(I))return I;if(s==="auto"){const b=a||d;return r!=null&&r.every(u=>!u.overlay)?b/h:b}return d}({optionsHeight:t,optionsSplitChannels:i,parentHeight:this.parent.clientHeight,numberOfChannels:o,defaultHeight:128})}convertColorValues(t,i){return function(n,o,s){if(!Array.isArray(n))return n||"";if(n.length===0)return"#999";if(n.length<2)return n[0]||"";const r=document.createElement("canvas"),a=r.getContext("2d"),h=s??r.height*o,d=a.createLinearGradient(0,0,0,h||o),I=1/(n.length-1);return n.forEach((b,u)=>{d.addColorStop(u*I,b)}),d}(t,this.getPixelRatio(),i==null?void 0:i.canvas.height)}getPixelRatio(){return t=window.devicePixelRatio,Math.max(1,t||1);var t}renderBarWaveform(t,i,n,o){const{width:s,height:r}=n.canvas,{halfHeight:a,barWidth:h,barRadius:d,barIndexScale:I,barSpacing:b,barMinHeight:u}=function({width:p,height:V,length:m,options:R,pixelRatio:X}){const Y=V/2,x=R.barWidth?R.barWidth*X:1,G=R.barGap?R.barGap*X:R.barWidth?x/2:0,L=x+G||1;return{halfHeight:Y,barWidth:x,barGap:G,barRadius:R.barRadius||0,barMinHeight:R.barMinHeight?R.barMinHeight*X:0,barIndexScale:m>0?p/L/m:0,barSpacing:L}}({width:s,height:r,length:(t[0]||[]).length,options:i,pixelRatio:this.getPixelRatio()}),y=function({channelData:p,barIndexScale:V,barSpacing:m,barWidth:R,halfHeight:X,vScale:Y,canvasHeight:x,barAlign:G,barMinHeight:L}){const Z=p[0]||[],w=p[1]||Z,W=Z.length,S=[];let K=0,J=0,g=0;for(let E=0;E<=W;E++){const T=Math.round(E*V);if(T>K){const{topHeight:n1,totalHeight:N}=TL({maxTop:J,maxBottom:g,halfHeight:X,vScale:Y,barMinHeight:L,barAlign:G}),F=wL({barAlign:G,halfHeight:X,topHeight:n1,totalHeight:N,canvasHeight:x});S.push({x:K*m,y:F,width:R,height:N}),K=T,J=0,g=0}const z=Math.abs(Z[E]||0),A=Math.abs(w[E]||0);z>J&&(J=z),A>g&&(g=A)}return S}({channelData:t,barIndexScale:I,barSpacing:b,barWidth:h,halfHeight:a,vScale:o,canvasHeight:r,barAlign:i.barAlign,barMinHeight:u});n.beginPath();for(const p of y)d&&"roundRect"in n?n.roundRect(p.x,p.y,p.width,p.height,d):n.rect(p.x,p.y,p.width,p.height);n.fill(),n.closePath()}renderLineWaveform(t,i,n,o){const{width:s,height:r}=n.canvas,a=function({channelData:h,width:d,height:I,vScale:b}){const u=I/2,y=h[0]||[];return[y,h[1]||y].map((p,V)=>{const m=p.length,R=m?d/m:0,X=u,Y=V===0?-1:1,x=[{x:0,y:X}];let G=0,L=0;for(let Z=0;Z<=m;Z++){const w=Math.round(Z*R);if(w>G){const S=X+(Math.round(L*u*b)||1)*Y;x.push({x:G,y:S}),G=w,L=0}const W=Math.abs(p[Z]||0);W>L&&(L=W)}return x.push({x:G,y:X}),x})}({channelData:t,width:s,height:r,vScale:o});n.beginPath();for(const h of a)if(h.length){n.moveTo(h[0].x,h[0].y);for(let d=1;d<h.length;d++){const I=h[d];n.lineTo(I.x,I.y)}}n.fill(),n.closePath()}renderWaveform(t,i,n){if(n.fillStyle=this.convertColorValues(i.waveColor,n),i.renderFunction)return void i.renderFunction(t,n);const o=function({channelData:s,barHeight:r,normalize:a,maxPeak:h}){var d;const I=r||1;if(!a)return I;const b=s[0];if(!b||b.length===0)return I;let u=h??0;if(!h)for(let y=0;y<b.length;y++){const p=(d=b[y])!==null&&d!==void 0?d:0,V=Math.abs(p);V>u&&(u=V)}return u?I/u:I}({channelData:t,barHeight:i.barHeight,normalize:i.normalize,maxPeak:i.maxPeak});_t(i)?this.renderBarWaveform(t,i,n,o):this.renderLineWaveform(t,i,n,o)}renderSingleCanvas(t,i,n,o,s,r,a){const h=this.getPixelRatio(),d=document.createElement("canvas");d.width=Math.round(n*h),d.height=Math.round(o*h),d.style.width=`${n}px`,d.style.height=`${o}px`,d.style.left=`${Math.round(s)}px`,r.appendChild(d);const I=d.getContext("2d");if(i.renderFunction?(I.fillStyle=this.convertColorValues(i.waveColor,I),i.renderFunction(t,I)):this.renderWaveform(t,i,I),d.width>0&&d.height>0){const b=d.cloneNode(),u=b.getContext("2d");u.drawImage(d,0,0),u.globalCompositeOperation="source-in",u.fillStyle=this.convertColorValues(i.progressColor,u),u.fillRect(0,0,d.width,d.height),a.appendChild(b)}}renderMultiCanvas(t,i,n,o,s,r){const a=this.getPixelRatio(),{clientWidth:h}=this.scrollContainer,d=n/a,I=function({clientWidth:p,totalWidth:V,options:m}){return vt(Math.min(8e3,p,V),m)}({clientWidth:h,totalWidth:d,options:i});let b={};if(I===0)return;const u=p=>{if(p<0||p>=y||b[p])return;b[p]=!0;const V=p*I;let m=Math.min(d-V,I);if(m=vt(m,i),m<=0)return;const R=function({channelData:X,offset:Y,clampedWidth:x,totalWidth:G}){return X.map(L=>{const Z=Math.floor(Y/G*L.length),w=Math.floor((Y+x)/G*L.length);return L.slice(Z,w)})}({channelData:t,offset:V,clampedWidth:m,totalWidth:d});this.renderSingleCanvas(R,i,m,o,V,s,r)},y=Math.ceil(d/I);if(!this.isScrollable){for(let p=0;p<y;p++)u(p);return}if(Qt({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:d,numCanvases:y}).forEach(p=>u(p)),y>1){const p=this.on("scroll",()=>{const{scrollLeft:V}=this.scrollContainer;Object.keys(b).length>10&&(s.innerHTML="",r.innerHTML="",b={}),Qt({scrollLeft:V,totalWidth:d,numCanvases:y}).forEach(m=>u(m))});this.unsubscribeOnScroll.push(p)}}renderChannel(t,i,n,o){var{overlay:s}=i,r=function(I,b){var u={};for(var y in I)Object.prototype.hasOwnProperty.call(I,y)&&b.indexOf(y)<0&&(u[y]=I[y]);if(I!=null&&typeof Object.getOwnPropertySymbols=="function"){var p=0;for(y=Object.getOwnPropertySymbols(I);p<y.length;p++)b.indexOf(y[p])<0&&Object.prototype.propertyIsEnumerable.call(I,y[p])&&(u[y[p]]=I[y[p]])}return u}(i,["overlay"]);const a=document.createElement("div"),h=this.getHeight(r.height,r.splitChannels);a.style.height=`${h}px`,s&&o>0&&(a.style.marginTop=`-${h}px`),this.canvasWrapper.style.minHeight=`${h}px`,this.canvasWrapper.appendChild(a);const d=a.cloneNode();this.progressWrapper.appendChild(d),this.renderMultiCanvas(t,r,n,h,a,d)}render(t){return F1(this,void 0,void 0,function*(){var i;this.timeouts.forEach(d=>d()),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 n=this.getPixelRatio(),o=this.scrollContainer.clientWidth-this.containerInlinePadding,{scrollWidth:s,isScrollable:r,useParentWidth:a,width:h}=function({duration:d,minPxPerSec:I=0,parentWidth:b,fillParent:u,pixelRatio:y}){const p=Math.ceil(d*I),V=p>b,m=!!(u&&!V);return{scrollWidth:p,isScrollable:V,useParentWidth:m,width:(m?b:p)*y}}({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:o,fillParent:this.options.fillParent,pixelRatio:n});if(this.isScrollable=r,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=t,this.emit("render"),this.options.splitChannels)for(let d=0;d<t.numberOfChannels;d++){const I=Object.assign(Object.assign({},this.options),(i=this.options.splitChannels)===null||i===void 0?void 0:i[d]);this.renderChannel([t.getChannelData(d)],I,h,d)}else{const d=[t.getChannelData(0)];t.numberOfChannels>1&&d.push(t.getChannelData(1)),this.renderChannel(d,this.options,h,0)}Promise.resolve().then(()=>this.emit("rendered"))})}reRender(){if(this.unsubscribeOnScroll.forEach(n=>n()),this.unsubscribeOnScroll=[],!this.audioData)return;const{scrollWidth:t}=this.scrollContainer,{right:i}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),!this.isScrollable&&this.scrollContainer.scrollLeft)this.scrollContainer.scrollLeft=0;else if(this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:n}=this.progressWrapper.getBoundingClientRect(),o=function(s){const r=2*s;return(r<0?Math.floor(r):Math.ceil(r))/2}(n-i);this.scrollContainer.scrollLeft+=o}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,i=!1){var n;const{scrollLeft:o,scrollWidth:s,clientWidth:r}=this.scrollContainer,a=t*s,h=o,d=o+r,I=r/2;if(this.isDragging)a+30>d?this.scrollContainer.scrollLeft+=30:a-30<h&&(this.scrollContainer.scrollLeft-=30);else{(a<h||a>d)&&(this.scrollContainer.scrollLeft=a-(this.options.autoCenter?I:0));const b=a-o-I;if(i&&this.options.autoCenter&&b>0){const u=(n=this.audioData)===null||n===void 0?void 0:n.duration;if(u===void 0||u<=0)return void(this.scrollContainer.scrollLeft+=b);const y=s/u;this.scrollContainer.scrollLeft+=y<=600?Math.min(b,10):b}}}renderProgress(t,i){if(isNaN(t))return;const n=100*t;this.canvasWrapper.style.clipPath=`polygon(${n}% 0%, 100% 0%, 100% 100%, ${n}% 100%)`,this.progressWrapper.style.width=`${n}%`,this.cursor.style.left=`${n}%`,this.cursor.style.transform=this.options.cursorWidth?`translateX(-${t*this.options.cursorWidth}px)`:"",this.isScrollable&&this.options.autoScroll&&this.audioData&&this.audioData.duration>0&&this.scrollIntoView(t,i)}exportImage(t,i,n){return F1(this,void 0,void 0,function*(){const o=this.canvasWrapper.querySelectorAll("canvas");if(!o.length)throw new Error("No waveform data");if(n==="dataURL"){const s=Array.from(o).map(r=>r.toDataURL(t,i));return Promise.resolve(s)}return Promise.all(Array.from(o).map(s=>new Promise((r,a)=>{s.toBlob(h=>{h?r(h):a(new Error("Could not export image"))},t,i)})))})}}class gL extends Ce{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;const t=()=>{this.isRunning&&(this.emit("tick"),this.animationFrameId=requestAnimationFrame(t))};t()}stop(){this.isRunning=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop()}}class Ue extends Ce{constructor(t){super(),this.bufferNode=null,this.playStartTime=0,this.playbackPosition=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,function(){const i=globalThis.navigator;if(i!=null&&i.audioSession)try{i.audioSession.type="playback"}catch(n){console.warn("Setting navigator.audioSession.type failed:",n)}}(),this.audioContext=t||new AudioContext,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return F1(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(t){if(this.currentSrc=t,this._duration=void 0,!t)return this.buffer=null,void this.emit("emptied");fetch(t).then(i=>{if(i.status>=400)throw new Error(`Failed to fetch ${t}: ${i.status} (${i.statusText})`);return i.arrayBuffer()}).then(i=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(i)).then(i=>{this.currentSrc===t&&(this.buffer=i,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())}).catch(i=>{console.error("WebAudioPlayer load error:",i)})}_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 t=this.playbackPosition;(t>=this.duration||t<0)&&(t=0,this.playbackPosition=0),this.bufferNode.start(this.audioContext.currentTime,t),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{!this.paused&&this.duration-this.currentTime<.01&&(this.pause(),this.emit("ended"))}}_pause(){var t;this.paused=!0,(t=this.bufferNode)===null||t===void 0||t.stop(),this.playbackPosition+=(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}play(){return F1(this,void 0,void 0,function*(){this.paused&&(this._play(),this.emit("play"))})}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){const i=t-this.currentTime,n=this.bufferNode;n==null||n.stop(this.audioContext.currentTime+i),n==null||n.addEventListener("ended",()=>{n===this.bufferNode&&(this.bufferNode=null,this.pause())},{once:!0})}setSinkId(t){return F1(this,void 0,void 0,function*(){return this.audioContext.setSinkId(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){const i=!this.paused;i&&this._pause(),this._playbackRate=t,i&&this._play(),this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return this.paused?this.playbackPosition:this.playbackPosition+(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}set currentTime(t){const i=!this.paused;i&&this._pause(),this.playbackPosition=t,i&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,i;return(t=this._duration)!==null&&t!==void 0?t:((i=this.buffer)===null||i===void 0?void 0:i.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t,this.emit("volumechange")}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const i=this.buffer.numberOfChannels;for(let n=0;n<i;n++)t.push(this.buffer.getChannelData(n));return t}removeAttribute(t){switch(t){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 fL={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class ye extends XL{static create(t){return new ye(t)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(t){const i=t.media||(t.backend==="WebAudio"?new Ue:void 0);super({media:i,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate}),this.plugins=[],this.decodedData=null,this.stopAtPosition=null,this.subscriptions=[],this.mediaSubscriptions=[],this.abortController=null,this.reactiveCleanups=[],this.options=Object.assign({},fL,t);const{state:n,actions:o}=function(a){var h,d,I,b,u,y;const p=(h=a==null?void 0:a.currentTime)!==null&&h!==void 0?h:g1(0),V=(d=a==null?void 0:a.duration)!==null&&d!==void 0?d:g1(0),m=(I=a==null?void 0:a.isPlaying)!==null&&I!==void 0?I:g1(!1),R=(b=a==null?void 0:a.isSeeking)!==null&&b!==void 0?b:g1(!1),X=(u=a==null?void 0:a.volume)!==null&&u!==void 0?u:g1(1),Y=(y=a==null?void 0:a.playbackRate)!==null&&y!==void 0?y:g1(1),x=g1(null),G=g1(null),L=g1(""),Z=g1(0),w=g1(0),W=ce(()=>!m.value,[m]),S=ce(()=>x.value!==null,[x]),K=ce(()=>S.value&&V.value>0,[S,V]),J=ce(()=>p.value,[p]),g=ce(()=>V.value>0?p.value/V.value:0,[p,V]);return{state:{currentTime:p,duration:V,isPlaying:m,isPaused:W,isSeeking:R,volume:X,playbackRate:Y,audioBuffer:x,peaks:G,url:L,zoom:Z,scrollPosition:w,canPlay:S,isReady:K,progress:J,progressPercent:g},actions:{setCurrentTime:E=>{const T=Math.max(0,Math.min(V.value||1/0,E));p.set(T)},setDuration:E=>{V.set(Math.max(0,E))},setPlaying:E=>{m.set(E)},setSeeking:E=>{R.set(E)},setVolume:E=>{const T=Math.max(0,Math.min(1,E));X.set(T)},setPlaybackRate:E=>{const T=Math.max(.1,Math.min(16,E));Y.set(T)},setAudioBuffer:E=>{x.set(E),E&&V.set(E.duration)},setPeaks:E=>{G.set(E)},setUrl:E=>{L.set(E)},setZoom:E=>{Z.set(Math.max(0,E))},setScrollPosition:E=>{w.set(Math.max(0,E))}}}}({isPlaying:this.isPlayingSignal,currentTime:this.currentTimeSignal,duration:this.durationSignal,volume:this.volumeSignal,playbackRate:this.playbackRateSignal,isSeeking:this.seekingSignal});this.wavesurferState=n,this.wavesurferActions=o,this.timer=new gL;const s=i?void 0:this.getMediaElement();this.renderer=new xL(this.options,s),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initReactiveState(),this.initPlugins();const r=this.options.url||this.getSrc()||"";Promise.resolve().then(()=>{this.emit("init");const{peaks:a,duration:h}=this.options;(r||a&&h)&&this.load(r,a,h).catch(d=>{this.emit("error",d instanceof Error?d:new Error(String(d)))})})}updateProgress(t=this.getCurrentTime()){return this.renderer.renderProgress(t/this.getDuration(),this.isPlaying()),t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t),this.stopAtPosition!=null&&this.isPlaying()&&t>=this.stopAtPosition&&this.pause()}}))}initReactiveState(){this.reactiveCleanups.push(function(t,i){const n=[];n.push(te(()=>{const r=t.isPlaying.value;i.emit(r?"play":"pause")},[t.isPlaying])),n.push(te(()=>{const r=t.currentTime.value;i.emit("timeupdate",r),t.isPlaying.value&&i.emit("audioprocess",r)},[t.currentTime,t.isPlaying])),n.push(te(()=>{t.isSeeking.value&&i.emit("seeking",t.currentTime.value)},[t.isSeeking,t.currentTime]));let o=!1;n.push(te(()=>{t.isReady.value&&!o&&(o=!0,i.emit("ready",t.duration.value))},[t.isReady,t.duration]));let s=!1;return n.push(te(()=>{const r=t.isPlaying.value,a=t.currentTime.value,h=t.duration.value,d=h>0&&a>=h;s&&!r&&d&&i.emit("finish"),s=r&&d},[t.isPlaying,t.currentTime,t.duration])),n.push(te(()=>{const r=t.zoom.value;r>0&&i.emit("zoom",r)},[t.zoom])),()=>{n.forEach(r=>r())}}(this.wavesurferState,{emit:this.emit.bind(this)}))}initPlayerEvents(){this.isPlaying()&&(this.emit("play"),this.timer.start()),this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",()=>{const t=this.updateProgress();this.emit("timeupdate",t)}),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 t;this.emit("error",(t=this.getMediaElement().error)!==null&&t!==void 0?t:new Error("Media error")),this.stopAtPosition=null}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(t,i)=>{this.options.interact&&(this.seekTo(t),this.emit("interaction",t*this.getDuration()),this.emit("click",t,i))}),this.renderer.on("dblclick",(t,i)=>{this.emit("dblclick",t,i)}),this.renderer.on("scroll",(t,i,n,o)=>{const s=this.getDuration();this.emit("scroll",t*s,i*s,n,o)}),this.renderer.on("render",()=>{this.emit("redraw")}),this.renderer.on("rendered",()=>{this.emit("redrawcomplete")}),this.renderer.on("dragstart",t=>{this.emit("dragstart",t)}),this.renderer.on("dragend",t=>{this.emit("dragend",t)}),this.renderer.on("resize",()=>{this.emit("resize")}));{let t;const i=this.renderer.on("drag",n=>{var o;if(!this.options.interact)return;this.renderer.renderProgress(n),clearTimeout(t);let s=0;const r=this.options.dragToSeek;this.isPlaying()?s=0:r===!0?s=200:r&&typeof r=="object"&&(s=(o=r.debounceTime)!==null&&o!==void 0?o:200),t=setTimeout(()=>{this.seekTo(n)},s),this.emit("interaction",n*this.getDuration()),this.emit("drag",n)});this.subscriptions.push(()=>{clearTimeout(t),i()})}}initPlugins(){var t;!((t=this.options.plugins)===null||t===void 0)&&t.length&&this.options.plugins.forEach(i=>{this.registerPlugin(i)})}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach(t=>t()),this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t),t.duration&&!t.peaks&&(this.decodedData=Te.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=Te.createBuffer(t.peaks,t.duration)),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),t.mediaControls!=null&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){if(this.plugins.includes(t))return t;t._init(this),this.plugins.push(t);const i=t.once("destroy",()=>{this.plugins=this.plugins.filter(n=>n!==t),this.subscriptions=this.subscriptions.filter(n=>n!==i)});return this.subscriptions.push(i),t}unregisterPlugin(t){this.plugins=this.plugins.filter(i=>i!==t),t.destroy()}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const i=t/this.getDuration();this.renderer.setScrollPercentage(i)}getActivePlugins(){return this.plugins}loadAudio(t,i,n,o){return F1(this,void 0,void 0,function*(){var s;if(this.emit("load",t),!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,!i&&!n){const a=this.options.fetchParams||{};window.AbortController&&!a.signal&&(this.abortController=new AbortController,a.signal=this.abortController.signal);const h=I=>this.emit("loading",I);i=yield NL.fetchBlob(t,h,a);const d=this.options.blobMimeType;d&&(i=new Blob([i],{type:d}))}this.setSrc(t,i);const r=yield new Promise(a=>{const h=o||this.getDuration();h?a(h):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>a(this.getDuration()),{once:!0}))});if(!t&&!i){const a=this.getMediaElement();a instanceof Ue&&(a.duration=r)}if(n)this.decodedData=Te.createBuffer(n,r||0);else if(i){const a=yield i.arrayBuffer();this.decodedData=yield Te.decode(a,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())})}load(t,i,n){return F1(this,void 0,void 0,function*(){try{return yield this.loadAudio(t,void 0,i,n)}catch(o){throw this.emit("error",o),o}})}loadBlob(t,i,n){return F1(this,void 0,void 0,function*(){try{return yield this.loadAudio("",t,i,n)}catch(o){throw this.emit("error",o),o}})}zoom(t){if(!this.decodedData)throw new Error("No audio loaded");this.renderer.zoom(t),this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:i=8e3,precision:n=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const o=Math.min(t,this.decodedData.numberOfChannels),s=[];for(let r=0;r<o;r++){const a=this.decodedData.getChannelData(r),h=[],d=a.length/i;for(let I=0;I<i;I++){const b=a.slice(Math.floor(I*d),Math.ceil((I+1)*d));let u=0;for(let y=0;y<b.length;y++){const p=b[y];Math.abs(p)>Math.abs(u)&&(u=p)}h.push(Math.round(u*n)/n)}s.push(h)}return s}getDuration(){let t=super.getDuration()||0;return t!==0&&t!==1/0||!this.decodedData||(t=this.decodedData.duration),t}toggleInteraction(t){this.options.interact=t}setTime(t){this.stopAtPosition=null,super.setTime(t),this.updateProgress(t),this.emit("timeupdate",t)}seekTo(t){const i=this.getDuration()*t;this.setTime(i)}play(t,i){const n=Object.create(null,{play:{get:()=>super.play}});return F1(this,void 0,void 0,function*(){t!=null&&this.setTime(t);const o=yield n.play.call(this);return i!=null&&(this.media instanceof Ue?this.media.stopAt(i):this.stopAtPosition=i),o})}playPause(){return F1(this,void 0,void 0,function*(){return this.isPlaying()?this.pause():this.play()})}stop(){this.pause(),this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents(),super.setMediaElement(t),this.initPlayerEvents()}exportImage(){return F1(this,arguments,void 0,function*(t="image/png",i=1,n="dataURL"){return this.renderer.exportImage(t,i,n)})}destroy(){var t;this.emit("destroy"),(t=this.abortController)===null||t===void 0||t.abort(),this.plugins.forEach(i=>i.destroy()),this.subscriptions.forEach(i=>i()),this.unsubscribePlayerEvents(),this.reactiveCleanups.forEach(i=>i()),this.reactiveCleanups=[],this.timer.destroy(),this.renderer.destroy(),super.destroy()}}ye.BasePlugin=class extends Ce{constructor(l){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=l}onInit(){}_init(l){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=l,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(l=>l()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}},ye.dom=ML;class EL{constructor(){this.listeners={}}on(t,i,n){if(this.listeners[t]||(this.listeners[t]=new Set),n==null?void 0:n.once){const o=(...s)=>{this.un(t,o),i(...s)};return this.listeners[t].add(o),()=>this.un(t,o)}return this.listeners[t].add(i),()=>this.un(t,i)}un(t,i){var n;(n=this.listeners[t])===null||n===void 0||n.delete(i)}once(t,i){return this.on(t,i,{once:!0})}unAll(){this.listeners={}}emit(t,...i){this.listeners[t]&&this.listeners[t].forEach(n=>n(...i))}}class JL extends EL{constructor(t){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=t}onInit(){}_init(t){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}}function $t(l,t){const i=t.xmlns?document.createElementNS(t.xmlns,l):document.createElement(l);for(const[n,o]of Object.entries(t))if(n==="children"&&o)for(const[s,r]of Object.entries(o))r instanceof Node?i.appendChild(r):typeof r=="string"?i.appendChild(document.createTextNode(r)):i.appendChild($t(s,r));else n==="style"?Object.assign(i.style,o):n==="textContent"?i.textContent=o:i.setAttribute(n,o.toString());return i}function ze(l,t,i){return $t(l,t||{})}const KL={height:20,timeOffset:0,formatTimeCallback:l=>l/60>1?`${Math.floor(l/60)}:${`${(l=Math.round(l%60))<10?"0":""}${l}`}`:`${Math.round(1e3*l)/1e3}`};class Oe extends JL{constructor(t){super(t||{}),this.notchElements=new Map,this.currentTimeline=null,this.options=Object.assign({},KL,t),this.timelineWrapper=this.initTimelineWrapper()}static create(t){return new Oe(t)}onInit(){var t;if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");let i=this.wavesurfer.getWrapper();if(this.options.container instanceof HTMLElement)i=this.options.container;else if(typeof this.options.container=="string"){const o=document.querySelector(this.options.container);if(!o)throw Error(`No Timeline container found matching ${this.options.container}`);i=o}this.options.insertPosition?(i.firstElementChild||i).insertAdjacentElement(this.options.insertPosition,this.timelineWrapper):i.appendChild(this.timelineWrapper);const n=this.wavesurfer.getState();this.subscriptions.push(function(o,s){let r;const a=()=>{r&&(r(),r=void 0),r=o()},h=s.map(d=>d.subscribe(a));return a(),()=>{r&&(r(),r=void 0),h.forEach(d=>d())}}(()=>{(n.duration.value>0||this.options.duration)&&this.initTimeline()},[n.duration])),this.subscriptions.push(this.wavesurfer.on("redraw",()=>this.initTimeline())),this.subscriptions.push(this.wavesurfer.on("scroll",(o,s,r,a)=>{this.currentTimeline&&this.updateVisibleNotches(r,a,this.currentTimeline)})),(!((t=this.wavesurfer)===null||t===void 0)&&t.getDuration()||this.options.duration)&&this.initTimeline()}destroy(){this.timelineWrapper.remove(),super.destroy()}initTimelineWrapper(){return ze("div",{part:"timeline-wrapper",style:{pointerEvents:"none"}})}defaultTimeInterval(t){return t>=25?1:5*t>=25?5:15*t>=25?15:60*Math.ceil(.5/t)}defaultPrimaryLabelInterval(t){return t>=25?10:5*t>=25?6:4}defaultSecondaryLabelInterval(t){return t>=25?5:2}virtualAppend(t,i,n){if(this.notchElements.set(n,{start:t,width:n.clientWidth,wasVisible:!1}),!this.wavesurfer)return;const o=this.wavesurfer.getScroll(),s=o+this.wavesurfer.getWidth(),r=this.notchElements.get(n),a=t>=o&&t+r.width<s;r.wasVisible=a,a&&i.appendChild(n)}updateVisibleNotches(t,i,n){this.notchElements.forEach((o,s)=>{const r=o.start>=t&&o.start+o.width<i;r!==o.wasVisible&&(o.wasVisible=r,r?n.appendChild(s):s.remove())})}initTimeline(){var t,i,n,o,s,r,a,h;this.notchElements.clear();const d=(n=(i=(t=this.wavesurfer)===null||t===void 0?void 0:t.getDuration())!==null&&i!==void 0?i:this.options.duration)!==null&&n!==void 0?n:0,I=(((o=this.wavesurfer)===null||o===void 0?void 0:o.getWrapper().scrollWidth)||this.timelineWrapper.scrollWidth)/d,b=(s=this.options.timeInterval)!==null&&s!==void 0?s:this.defaultTimeInterval(I),u=(r=this.options.primaryLabelInterval)!==null&&r!==void 0?r:this.defaultPrimaryLabelInterval(I),y=this.options.primaryLabelSpacing,p=(a=this.options.secondaryLabelInterval)!==null&&a!==void 0?a:this.defaultSecondaryLabelInterval(I),V=this.options.secondaryLabelSpacing,m=this.options.insertPosition==="beforebegin",R=ze("div",{style:Object.assign({height:`${this.options.height}px`,overflow:"hidden",fontSize:this.options.height/2+"px",whiteSpace:"nowrap"},m?{position:"absolute",top:"0",left:"0",right:"0",zIndex:"2"}:{position:"relative"})});R.setAttribute("part","timeline"),typeof this.options.style=="string"?R.setAttribute("style",R.getAttribute("style")+this.options.style):typeof this.options.style=="object"&&Object.assign(R.style,this.options.style);const X=ze("div",{style:{width:"0",height:"50%",display:"flex",flexDirection:"column",justifyContent:m?"flex-start":"flex-end",top:m?"0":"auto",bottom:m?"auto":"0",overflow:"visible",borderLeft:"1px solid currentColor",opacity:`${(h=this.options.secondaryLabelOpacity)!==null&&h!==void 0?h:.25}`,position:"absolute",zIndex:"1"}});for(let Y=0,x=0;Y<d;Y+=b,x++){const G=X.cloneNode(),L=Math.round(100*Y)%Math.round(100*u)==0||y&&x%y==0,Z=Math.round(100*Y)%Math.round(100*p)==0||V&&x%V==0;(L||Z)&&(G.style.height="100%",G.style.textIndent="3px",G.textContent=this.options.formatTimeCallback(Y),L&&(G.style.opacity="1"));const w=L?"primary":Z?"secondary":"tick";G.setAttribute("part",`timeline-notch timeline-notch-${w}`);const W=(Y+this.options.timeOffset)*I;G.style.left=`${W}px`,this.virtualAppend(W,R,G)}this.timelineWrapper.innerHTML="",this.timelineWrapper.appendChild(R),this.currentTimeline=R,this.emit("ready")}}const we={WAVE_DEFAULT:"#D9D9D9",PROGRESS:"#F2994A"},FL={key:0,class:"vt-audio__empty"},jL={key:1},RL={class:"vt-audio__wave-area"},UL=["id"],zL={class:"vt-audio__controls"},OL=["disabled"],DL=["disabled"],PL=["disabled"],qt=e.defineComponent({__name:"VAudio",props:{recordUrl:{default:""},userA:{default:""},userB:{default:""},disabled:{type:Boolean,default:!1},type:{default:"default"}},emits:["timeUpdate","play","pause","ended","error"],setup(l,{expose:t,emit:i}){const{t:n}=W1(),o=l,s=i,r=e.computed(()=>!!(o.userA||o.userB)),a=e.ref(!1),h=e.computed(()=>o.disabled||a.value),d=e.ref(!1),I=e.ref(1),b=e.ref(`ws-${Math.random().toString(36).slice(2,9)}`),u=e.ref(null),y=e.ref(null),p=e.ref(null),V=e.ref(null),m=e.ref(null),R=e.computed(()=>o.type==="channel-routed"),X=(T,z)=>{var q;const{width:A,height:n1}=z.canvas,N=(q=u.value)==null?void 0:q.decodedData;if(!T.length&&!N){z.fillStyle=we.WAVE_DEFAULT,z.fillRect(0,n1/2,A,2);return}const F=r.value&&N&&N.numberOfChannels>=2?[N.getChannelData(0),N.getChannelData(1)]:[T[0]||new Float32Array(A).fill(0)];z.clearRect(0,0,A,n1);const O=20;F.forEach((e1,s1)=>{const V1=n1/F.length,a1=V1-(r.value?O:0),c1=s1*V1+(r.value?O:0)+a1/2,C1=e1.length/A;let Y1=0;for(let p1=0;p1<e1.length;p1+=100){const k=Math.abs(e1[p1]??0);k>Y1&&(Y1=k)}Y1===0&&(Y1=1),z.fillStyle=we.WAVE_DEFAULT;for(let p1=0;p1<A;p1+=2){const k=Math.floor(p1*C1),P=Math.min(Math.floor((p1+2)*C1),e1.length-1);let B=0;for(let N1=k;N1<=P;N1++){const w1=Math.abs(e1[N1]??0);w1>B&&(B=w1)}const b1=B/Y1,k1=Math.max(b1*a1*.85,2);z.fillRect(p1,c1-k1/2,1.5,k1)}if(r.value){z.fillStyle="#999999",z.font="12px Inter, sans-serif",z.textAlign="right";const p1=(s1===0?o.userA:o.userB)??"";z.fillText(p1,A-10,s1*V1+O-5)}})},Y=()=>{var N;const T=(N=u.value)==null?void 0:N.getMediaElement();if(!T)return;p.value=new(window.AudioContext||window.webkitAudioContext);const z=p.value.createMediaElementSource(T),A=p.value.createChannelSplitter(2),n1=p.value.createChannelMerger(2);V.value=p.value.createGain(),m.value=p.value.createGain(),V.value.gain.value=L.value,m.value.gain.value=Z.value,z.connect(A),A.connect(V.value,0),A.connect(m.value,1),V.value.connect(n1,0,0),m.value.connect(n1,0,1),n1.connect(p.value.destination)},x=()=>{var T;(T=p.value)==null||T.close(),p.value=null,V.value=null,m.value=null},G=()=>{if(!o.recordUrl)return;a.value=!1;const T=ye.create({container:`#waveform-${b.value}`,waveColor:we.WAVE_DEFAULT,progressColor:we.PROGRESS,barWidth:2,height:R.value?36:r.value?100:50,plugins:R.value?[]:[Oe.create({container:y.value,style:{fontSize:"10px",color:"#999"}})],renderFunction:(z,A)=>X(z,A)});u.value=T,u.value.on("play",()=>{d.value=!0,s("play")}),u.value.on("pause",()=>{d.value=!1,s("pause")}),u.value.on("timeupdate",z=>s("timeUpdate",z)),u.value.on("finish",()=>{d.value=!1,s("ended")}),u.value.on("error",()=>{a.value=!0,s("error")}),(r.value||R.value)&&u.value.on("ready",()=>{Y(),S()}),u.value.load(o.recordUrl)},L=e.ref(1),Z=e.ref(1),w=T=>{const z=T===0?V.value:m.value,A=T===0?L:Z;A.value=A.value?0:1,z&&(z.gain.value=A.value)},W={x:5,y:0,size:18},S=()=>{const T=document.querySelector(`#waveform-${b.value} canvas`);!T||!r.value||T.addEventListener("click",z=>{if(h.value)return;const A=T.getBoundingClientRect(),n1=z.clientX-A.left,N=z.clientY-A.top,F=A.height/2;[0,1].forEach(O=>{const q=O*F+W.y;n1>=W.x&&n1<=W.x+W.size&&N>=q&&N<=q+W.size&&(z.stopPropagation(),z.preventDefault(),w(O))})})},K=async()=>{if(!(!u.value||h.value)){if(R.value){const T=u.value.getMediaElement();if(!T||!p.value)return;p.value.state==="suspended"&&await p.value.resume(),T.paused?await T.play():T.pause();return}d.value?u.value.pause():u.value.play()}},J=T=>{var z;I.value=T,(z=u.value)==null||z.setPlaybackRate(I.value)},g=(T,z)=>{if(T.startsWith("data:")){const n1=document.createElement("a");n1.href=T,n1.download=z,document.body.appendChild(n1),n1.click(),document.body.removeChild(n1)}else fetch(T).then(n1=>n1.blob()).then(n1=>{const N=document.createElement("a");N.href=URL.createObjectURL(n1),N.download=z,document.body.appendChild(N),N.click(),document.body.removeChild(N)}).catch(console.error)},E=()=>{if(o.disabled||!o.recordUrl)return;const T=o.recordUrl.indexOf("?"),z=o.recordUrl.substring(o.recordUrl.lastIndexOf("/")+1,T===-1?void 0:T);g(o.recordUrl,z)};return e.onMounted(()=>e.nextTick(G)),e.onBeforeUnmount(()=>{var T;(T=u.value)==null||T.destroy(),x()}),e.watch(()=>o.recordUrl,()=>{var T;(T=u.value)==null||T.destroy(),x(),e.nextTick(G)}),t({play:()=>{var T;return(T=u.value)==null?void 0:T.play()},pause:()=>{var T;return(T=u.value)==null?void 0:T.pause()},getCurrentTime:()=>{var T;return((T=u.value)==null?void 0:T.getCurrentTime())||0}}),(T,z)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vt-audio",{"is-disabled":h.value,"is-channel-routed":R.value}])},[l.recordUrl?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["vt-audio__container",{"is-single-channel":!r.value,"is-channel-routed":R.value}])},[e.createElementVNode("div",RL,[e.createElementVNode("div",{id:`waveform-${b.value}`,class:"vt-audio__waveform"},null,8,UL),R.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"timelineContainer",ref:y,class:"vt-audio__timeline"},null,512))]),e.createElementVNode("div",zL,[R.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("button",{class:"vt-audio__btn",disabled:h.value,onClick:E},[e.createVNode(h1,{name:"import",width:"20",height:"20"})],8,OL),e.createVNode(oe,{trigger:"click",placement:"top",disabled:h.value,onCommand:J},{dropdown:e.withCtx(()=>[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList([1,1.5,2],A=>e.createVNode(ne,{key:A,command:A,class:e.normalizeClass({"is-active":I.value===A})},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(A)+"x ",1)]),_:2},1032,["command","class"])),64))]),default:e.withCtx(()=>[e.createElementVNode("button",{class:"vt-audio__speed-val",disabled:h.value},e.toDisplayString(I.value)+"x",9,DL)]),_:1},8,["disabled"])],64)),e.createElementVNode("button",{class:"vt-audio__btn vt-audio__btn--main",disabled:h.value,onClick:K},[d.value?e.renderSlot(T.$slots,"icon-pause",{key:0},()=>[e.createVNode(h1,{name:"pause",width:"24",height:"24"})]):e.renderSlot(T.$slots,"icon-play",{key:1},()=>[e.createVNode(h1,{name:"start",width:"24",height:"24"})])],8,PL)])],2)):(e.openBlock(),e.createElementBlock("div",FL,[e.renderSlot(T.$slots,"empty",{},()=>[R.value?(e.openBlock(),e.createElementBlock("span",jL,e.toDisplayString(e.unref(n)(e.unref(c).AUDIO_EMPTY)),1)):(e.openBlock(),e.createBlock(Le,{key:0,icon:"noSound",text:e.unref(n)(e.unref(c).AUDIO_EMPTY)},null,8,["text"]))])]))],2))}}),HL=new Set(["p","div","br","hr","h1","h2","h3","h4","h5","h6","blockquote","pre","code","ul","ol","li","b","strong","i","em","u","s","strike","del","sub","sup","font","span","a","img","table","thead","tbody","tfoot","tr","th","td","caption"]),BL=new Set(["style","class","href","target","rel","src","alt","width","height","face","size","color","colspan","rowspan"]),_L=new Set(["behavior","-moz-binding","filter"]),vL=/expression\s*\(|javascript\s*:|vbscript\s*:/i;function QL(l){const t=document.createElement("span");t.setAttribute("style",l);const i=t.style,n=[];for(let o=0;o<i.length;o++){const s=i[o],r=i.getPropertyValue(s);_L.has(s)||vL.test(r)||/url\s*\(/i.test(r)&&!/url\s*\(\s*['"]?data:image\//i.test(r)||n.push(`${s}:${r}`)}return n.join(";")}const AL=new Set(["https:","http:","ftp:","mailto:","tel:"]);function $L(l){const t=l.trim();if(t.startsWith("/")||t.startsWith(".")||t.startsWith("#"))return!0;try{const i=new URL(t);return AL.has(i.protocol)}catch{return!/^[a-z][a-z0-9+\-.]*:/i.test(t)}}function el(l){var s,r,a;if(l.nodeType===Node.COMMENT_NODE||l.nodeType===Node.PROCESSING_INSTRUCTION_NODE){(s=l.parentNode)==null||s.removeChild(l);return}if(l.nodeType!==Node.ELEMENT_NODE)return;const t=l,i=t.tagName.toLowerCase();if(!HL.has(i)){for(;t.firstChild;)(r=t.parentNode)==null||r.insertBefore(t.firstChild,t);(a=t.parentNode)==null||a.removeChild(t);return}const n=Array.from(t.attributes);for(const h of n){const d=h.name.toLowerCase();if(d.startsWith("on")){t.removeAttribute(h.name);continue}if(!BL.has(d)){t.removeAttribute(h.name);continue}if((d==="href"||d==="src")&&!$L(h.value)){t.removeAttribute(h.name);continue}if(d==="style"){const I=QL(h.value);I?t.setAttribute("style",I):t.removeAttribute("style");continue}}i==="a"&&t.getAttribute("target")==="_blank"&&t.setAttribute("rel","noopener noreferrer");const o=Array.from(t.childNodes);for(let h=o.length-1;h>=0;h--)el(o[h])}function de(l){if(!l)return"";const t=new DOMParser().parseFromString(l,"text/html");t.head.innerHTML="";const i=Array.from(t.body.childNodes);for(let n=i.length-1;n>=0;n--)el(i[n]);return t.body.innerHTML}function tl(l){const t=document.createElement("div");return t.innerHTML=l,t.textContent??t.innerText??""}function qL(l,t){function i(d,I){l.value&&(l.value.focus(),document.execCommand(d,!1,I??""),t())}function n(d){try{return document.queryCommandState(d)}catch{return!1}}function o(d){l.value&&(l.value.focus(),document.execCommand("formatBlock",!1,d),t())}function s(d){l.value&&(l.value.focus(),document.execCommand("fontName",!1,d),t())}function r(d){l.value&&(l.value.focus(),document.execCommand("foreColor",!1,d),t())}function a(d){l.value&&(l.value.focus(),document.execCommand("hiliteColor",!1,d),t())}function h(d){const I=window.getSelection();if(!I||I.rangeCount===0)return;let b=I.anchorNode;b.nodeType===Node.TEXT_NODE&&(b=b.parentElement);const u=b.closest(".vt-editor__content > *");if(!u)return;const y=parseInt(u.style.marginLeft||"0",10),p=20,V=d==="indent"?y+p:Math.max(0,y-p);u.style.marginLeft=V?`${V}px`:"",t()}return{exec:i,isActive:n,applyBlock:o,applyFont:s,applyForeColor:r,applyBackColor:a,handleIndent:h}}function eW(){let l=null;function t(){const s=window.getSelection();s&&s.rangeCount>0&&(l=s.getRangeAt(0).cloneRange())}function i(){if(!l)return;const s=window.getSelection();s&&(s.removeAllRanges(),s.addRange(l))}function n(){l=null}function o(){return l}return{saveSelection:t,restoreSelection:i,clearSavedRange:n,getSavedRange:o}}function tW(l,t){const{saveSelection:i,restoreSelection:n,clearSavedRange:o,getSavedRange:s}=eW(),r=e.ref({visible:!1,url:"",text:"",openInNewTab:!1});function a(){var R,X;i();const p=window.getSelection(),V=(p==null?void 0:p.toString())??"",m=(X=(R=p==null?void 0:p.anchorNode)==null?void 0:R.parentElement)==null?void 0:X.closest("a");r.value={visible:!0,url:(m==null?void 0:m.getAttribute("href"))??"",text:V,openInNewTab:(m==null?void 0:m.getAttribute("target"))==="_blank"}}function h(){n();const{url:p,text:V,openInNewTab:m}=r.value;if(!p){d();return}const R=document.createElement("a");R.href=p,R.textContent=V||p,m&&R.setAttribute("target","_blank"),R.setAttribute("rel","noopener noreferrer");const X=s(),Y=window.getSelection();Y&&Y.rangeCount>0&&X?(X.deleteContents(),X.insertNode(R)):l(R.outerHTML),d(),t()}function d(){r.value={visible:!1,url:"",text:"",openInNewTab:!1},o()}const I=e.ref({visible:!1,url:"",alt:""});function b(){i(),I.value={visible:!0,url:"",alt:""}}function u(){n();const{url:p,alt:V}=I.value;if(!p){y();return}l(`<img src="${p}" alt="${V}" style="max-width:100%;" />`),y()}function y(){I.value={visible:!1,url:"",alt:""},o()}return{linkState:r,openLinkDialog:a,confirmLink:h,cancelLink:d,imageState:I,openImageDialog:b,confirmImage:u,cancelImage:y}}const f1={undo:"undo",redo:"redo",bold:"textBold",italic:"textItalic",underline:"textUnderline",strikethrough:"textStrikethrough",subscript:"subscript",superscript:"superscript",orderedList:"orderedList",unorderedList:"unorderedList",indent:"indent",outdent:"outdent",alignLeft:"alignLeft",alignCenter:"alignCenter",alignRight:"alignRight",alignJustify:"alignJustify",link:"link",image:"image",blockquote:"blockquote",clearFormat:"clearFormat",html:"html"},lW=[{value:"p",label:"Paragraph"},{value:"h1",label:"Heading 1"},{value:"h2",label:"Heading 2"},{value:"h3",label:"Heading 3"},{value:"h4",label:"Heading 4"}],iW=[{value:"Arial",label:"Arial"},{value:"Times New Roman",label:"Times New Roman"},{value:"Courier New",label:"Courier New"},{value:"Georgia",label:"Georgia"},{value:"Verdana",label:"Verdana"}];function oW(l,t){const{t:i}=W1(),n=e.ref(0);function o(){n.value++}function s(h){var d;return n.value,((d=h.activeCheck)==null?void 0:d.call(h))??!1}function r(h){const d=[];return h.forEach((I,b)=>{switch(b>0&&d.push({type:"separator"}),I){case"history":d.push({type:"button",id:"undo",tooltip:i(c.EDITOR_UNDO),iconName:f1.undo,action:()=>t.exec("undo")},{type:"button",id:"redo",tooltip:i(c.EDITOR_REDO),iconName:f1.redo,action:()=>t.exec("redo")});break;case"format":d.push({type:"button",id:"bold",tooltip:i(c.EDITOR_BOLD),iconName:f1.bold,action:()=>t.exec("bold"),activeCheck:()=>t.isActive("bold")},{type:"button",id:"italic",tooltip:i(c.EDITOR_ITALIC),iconName:f1.italic,action:()=>t.exec("italic"),activeCheck:()=>t.isActive("italic")},{type:"button",id:"underline",tooltip:i(c.EDITOR_UNDERLINE),iconName:f1.underline,action:()=>t.exec("underline"),activeCheck:()=>t.isActive("underline")},{type:"button",id:"strikethrough",tooltip:i(c.EDITOR_STRIKETHROUGH),iconName:f1.strikethrough,action:()=>t.exec("strikethrough"),activeCheck:()=>t.isActive("strikeThrough")});break;case"script":d.push({type:"button",id:"subscript",tooltip:i(c.EDITOR_SUBSCRIPT),iconName:f1.subscript,action:()=>t.exec("subscript"),activeCheck:()=>t.isActive("subscript")},{type:"button",id:"superscript",tooltip:i(c.EDITOR_SUPERSCRIPT),iconName:f1.superscript,action:()=>t.exec("superscript"),activeCheck:()=>t.isActive("superscript")});break;case"heading":d.push({type:"select",id:"heading"});break;case"fontName":d.push({type:"select",id:"fontName"});break;case"foreColor":d.push({type:"select",id:"foreColor"});break;case"align":d.push({type:"button",id:"alignLeft",tooltip:i(c.EDITOR_ALIGN_LEFT),iconName:f1.alignLeft,action:()=>t.exec("justifyLeft"),activeCheck:()=>t.isActive("justifyLeft")},{type:"button",id:"alignCenter",tooltip:i(c.EDITOR_ALIGN_CENTER),iconName:f1.alignCenter,action:()=>t.exec("justifyCenter"),activeCheck:()=>t.isActive("justifyCenter")},{type:"button",id:"alignRight",tooltip:i(c.EDITOR_ALIGN_RIGHT),iconName:f1.alignRight,action:()=>t.exec("justifyRight"),activeCheck:()=>t.isActive("justifyRight")},{type:"button",id:"alignJustify",tooltip:i(c.EDITOR_ALIGN_JUSTIFY),iconName:f1.alignJustify,action:()=>t.exec("justifyFull"),activeCheck:()=>t.isActive("justifyFull")});break;case"list":d.push({type:"button",id:"orderedList",tooltip:i(c.EDITOR_ORDERED_LIST),iconName:f1.orderedList,action:()=>t.exec("insertOrderedList"),activeCheck:()=>t.isActive("insertOrderedList")},{type:"button",id:"unorderedList",tooltip:i(c.EDITOR_UNORDERED_LIST),iconName:f1.unorderedList,action:()=>t.exec("insertUnorderedList"),activeCheck:()=>t.isActive("insertUnorderedList")});break;case"indent":d.push({type:"button",id:"indent",tooltip:i(c.EDITOR_INDENT),iconName:f1.indent,action:()=>t.handleIndent("indent")},{type:"button",id:"outdent",tooltip:i(c.EDITOR_OUTDENT),iconName:f1.outdent,action:()=>t.handleIndent("outdent")});break;case"link":d.push({type:"button",id:"link",tooltip:i(c.EDITOR_INSERT_LINK),iconName:f1.link,action:t.openLinkDialog});break;case"image":d.push({type:"button",id:"image",tooltip:i(c.EDITOR_INSERT_IMAGE),iconName:f1.image,action:t.openImageDialog});break;case"blockquote":d.push({type:"button",id:"blockquote",tooltip:i(c.EDITOR_BLOCKQUOTE),iconName:f1.blockquote,action:()=>t.applyBlock("blockquote")});break;case"clear":d.push({type:"button",id:"clear",tooltip:i(c.EDITOR_CLEAR_FORMAT),iconName:f1.clearFormat,action:()=>t.exec("removeFormat")});break;case"html":d.push({type:"button",id:"html",tooltip:i(c.EDITOR_HTML_SOURCE),iconName:f1.html,action:t.toggleHtmlMode,activeCheck:t.isHtmlMode});break}}),d}return{toolbarItems:e.computed(()=>r(l())),selectionTick:n,onSelectionChange:o,getItemActive:s,HEADING_GROUPS:lW,FONT_GROUPS:iW}}const nW={key:0,class:"vt-editor__toolbar-wrapper"},sW={key:0,class:"vt-editor__toolbar-sep"},cW=["value"],rW=["value"],aW=["onClick"],dW={class:"vt-editor__body"},mW=["contenteditable","data-placeholder"],hW={key:1,class:"vt-editor__error"},IW={class:"vt-editor__dialog-fields"},pW={class:"vt-editor__dialog-label"},ZW={class:"vt-editor__dialog-label"},uW={class:"vt-editor__dialog-checkbox"},bW={class:"vt-modal__footer"},CW={class:"vt-editor__dialog-fields"},yW={class:"vt-editor__dialog-label"},VW={class:"vt-editor__dialog-label"},SW={class:"vt-modal__footer"},ll=e.defineComponent({__name:"VEditor",props:{modelValue:{},placeholder:{},toolbar:{default:()=>["history","format","heading","fontName","foreColor","align","list","indent","link","image","blockquote","clear","html"]},disabled:{type:Boolean,default:!1},required:{type:Boolean},errorMessage:{}},emits:["update:modelValue","input","change","focus","blur","validation"],setup(l,{expose:t,emit:i}){const{t:n}=W1(),o=l,s=i,r=e.ref(null),a=e.ref(null),h=e.ref(null),d=e.ref(!1),I=e.ref(!1),b=e.ref(""),u=e.ref([]),y=e.ref(!0),p=e.ref(!1),V=e.ref(!1),m=e.ref("#000000"),R=e.ref("#ffffff");function X(Q){var f;const H=Q??((f=r.value)==null?void 0:f.innerHTML)??"",I1=de(H);s("update:modelValue",I1),s("input",I1)}const{exec:Y,isActive:x,applyBlock:G,applyFont:L,applyForeColor:Z,applyBackColor:w,handleIndent:W}=qL(r,X);function S(){if(r.value)if(!I.value)b.value=r.value.innerHTML,I.value=!0,e.nextTick(()=>{var Q;return(Q=h.value)==null?void 0:Q.focus()});else{const Q=de(b.value);I.value=!1,e.nextTick(()=>{r.value&&(r.value.innerHTML=Q,X(Q),r.value.focus())})}}function K(){const Q=de(b.value);s("update:modelValue",Q),s("input",Q)}const{linkState:J,openLinkDialog:g,confirmLink:E,cancelLink:T,imageState:z,openImageDialog:A,confirmImage:n1,cancelImage:N}=tW(Q=>Y("insertHTML",Q),X),{toolbarItems:F,onSelectionChange:O,getItemActive:q,HEADING_GROUPS:e1,FONT_GROUPS:s1}=oW(()=>o.toolbar,{exec:Y,isActive:x,applyBlock:G,applyFont:L,handleIndent:W,openLinkDialog:g,openImageDialog:A,toggleHtmlMode:S,isHtmlMode:()=>I.value});function V1(Q){const H=Q.target.value;m.value=H,Z(H)}function a1(Q){const H=Q.target.value;R.value=H,w(H)}function c1(){const Q=a.value;Q&&(p.value=Q.scrollLeft>2,V.value=Q.scrollLeft+Q.clientWidth<Q.scrollWidth-2)}function C1(Q){const H=a.value;H&&(H.scrollBy({left:Q==="left"?-160:160,behavior:"smooth"}),setTimeout(c1,250))}function Y1(Q){const H=[];o.required&&!tl(Q).trim()&&H.push(n(c.VALIDATION_REQUIRED)),u.value=H,y.value=H.length===0,s("validation",{isValid:y.value,errors:H})}const p1=e.computed(()=>o.errorMessage||u.value[0]||""),k=e.computed(()=>!!p1.value),P=e.computed(()=>["vt-editor",{"vt-editor--focused":d.value,"vt-editor--error":k.value,"vt-editor--disabled":o.disabled}]);function B(){X(),Y1(o.modelValue??"")}function b1(Q){d.value=!0,s("focus",Q)}function k1(Q){d.value=!1,s("blur",Q),Y1(o.modelValue??"")}function N1(Q){Q.key==="Tab"&&(Q.preventDefault(),Y("insertHTML","&nbsp;&nbsp;&nbsp;&nbsp;"))}e.watch(()=>o.modelValue,Q=>{!r.value||d.value||I.value||r.value.innerHTML!==Q&&(r.value.innerHTML=Q??"")}),e.onMounted(()=>{r.value&&o.modelValue&&(r.value.innerHTML=de(o.modelValue)),document.addEventListener("selectionchange",O),e.nextTick(()=>{c1();const Q=new ResizeObserver(c1);a.value&&Q.observe(a.value)}),window.addEventListener("resize",c1)}),e.onBeforeUnmount(()=>{document.removeEventListener("selectionchange",O),window.removeEventListener("resize",c1)});function w1(){var Q;(Q=r.value)==null||Q.focus()}function A1(){var Q;(Q=r.value)==null||Q.blur()}function j1(){r.value&&(r.value.innerHTML=""),X(""),u.value=[],y.value=!0,s("validation",{isValid:!0,errors:[]})}function $1(){var Q;return((Q=r.value)==null?void 0:Q.innerHTML)??""}function B1(){var Q;return tl(((Q=r.value)==null?void 0:Q.innerHTML)??"")}function v1(Q){const H=de(Q);r.value&&(r.value.innerHTML=H),X(H)}function U1(Q){var H;(H=r.value)==null||H.focus(),Y("insertHTML",de(Q))}function E1(){return Y1(o.modelValue??""),y.value}function le(){u.value=[],y.value=!0,s("validation",{isValid:!0,errors:[]})}function i1(){return{isValid:y.value,errors:[...u.value]}}function r1(){return r.value}return t({focus:w1,blur:A1,clear:j1,getHTML:$1,getText:B1,setHTML:v1,insertHTML:U1,validate:E1,clearValidation:le,getValidationState:i1,getEditorElement:r1}),(Q,H)=>{const I1=e.resolveDirective("tooltip");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(P.value)},[!l.disabled&&e.unref(F).length?(e.openBlock(),e.createElementBlock("div",nW,[p.value?(e.openBlock(),e.createElementBlock("button",{key:0,class:"vt-editor__toolbar-scroll-btn vt-editor__toolbar-scroll-btn--left",type:"button",onClick:H[0]||(H[0]=f=>C1("left")),onMousedown:H[1]||(H[1]=e.withModifiers(()=>{},["prevent"]))},[e.createVNode(h1,{name:"arrowLeft"})],32)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"toolbarRef",ref:a,class:"vt-editor__toolbar",onScroll:c1},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(F),(f,v)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:v},[(f==null?void 0:f.type)==="separator"?(e.openBlock(),e.createElementBlock("span",sW)):(f==null?void 0:f.type)==="select"&&f.id==="heading"?(e.openBlock(),e.createBlock(oe,{key:1,"max-height":220,class:"vt-editor__toolbar-btn",placement:"bottom-start",trigger:"hover",onMousedown:H[3]||(H[3]=e.withModifiers(()=>{},["prevent"]))},{dropdown:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(e1),M=>(e.openBlock(),e.createBlock(ne,{key:M.value,onClick:$=>e.unref(G)(M.value),onMousedown:H[2]||(H[2]=e.withModifiers(()=>{},["prevent"]))},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(M.label),1)]),_:2},1032,["onClick"]))),128))]),default:e.withCtx(()=>[e.withDirectives(e.createVNode(h1,{name:"tagType"},null,512),[[I1,e.unref(n)(e.unref(c).EDITOR_HEADING)]])]),_:1})):(f==null?void 0:f.type)==="select"&&f.id==="fontName"?(e.openBlock(),e.createBlock(oe,{key:2,"max-height":220,class:"vt-editor__toolbar-btn",placement:"bottom-start",trigger:"hover",onMousedown:H[5]||(H[5]=e.withModifiers(()=>{},["prevent"]))},{dropdown:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(s1),M=>(e.openBlock(),e.createBlock(ne,{key:M.value,onClick:$=>e.unref(L)(M.value),onMousedown:H[4]||(H[4]=e.withModifiers(()=>{},["prevent"]))},{default:e.withCtx(()=>[e.createElementVNode("span",{style:e.normalizeStyle({fontFamily:M.value})},e.toDisplayString(M.label),5)]),_:2},1032,["onClick"]))),128))]),default:e.withCtx(()=>[e.withDirectives(e.createVNode(h1,{name:"fontName"},null,512),[[I1,e.unref(n)(e.unref(c).EDITOR_FONT)]])]),_:1})):(f==null?void 0:f.type)==="select"&&f.id==="foreColor"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:3},[e.withDirectives(e.createElementVNode("input",{value:m.value,class:"vt-editor__color-picker",type:"color",onInput:V1,onMousedown:H[6]||(H[6]=e.withModifiers(()=>{},["stop"]))},null,40,cW),[[I1,e.unref(n)(e.unref(c).EDITOR_FORE_COLOR)]]),e.withDirectives(e.createElementVNode("input",{value:R.value,class:"vt-editor__color-picker vt-editor__color-picker--bg",type:"color",onInput:a1,onMousedown:H[7]||(H[7]=e.withModifiers(()=>{},["stop"]))},null,40,rW),[[I1,e.unref(n)(e.unref(c).EDITOR_BACK_COLOR)]])],64)):(f==null?void 0:f.type)==="button"?e.withDirectives((e.openBlock(),e.createElementBlock("button",{key:4,class:e.normalizeClass([{"vt-editor__toolbar-btn--active":e.unref(q)(f)},"vt-editor__toolbar-btn"]),type:"button",onClick:M=>{var $;return($=f==null?void 0:f.action)==null?void 0:$.call(f)},onMousedown:H[8]||(H[8]=e.withModifiers(()=>{},["prevent"]))},[f!=null&&f.iconName?(e.openBlock(),e.createBlock(h1,{key:0,name:f.iconName},null,8,["name"])):e.createCommentVNode("",!0)],42,aW)),[[I1,f==null?void 0:f.tooltip]]):e.createCommentVNode("",!0)],64))),128))],544),V.value?(e.openBlock(),e.createElementBlock("button",{key:1,class:"vt-editor__toolbar-scroll-btn vt-editor__toolbar-scroll-btn--right",type:"button",onClick:H[9]||(H[9]=f=>C1("right")),onMousedown:H[10]||(H[10]=e.withModifiers(()=>{},["prevent"]))},[e.createVNode(h1,{name:"arrowRight"})],32)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createElementVNode("div",dW,[e.withDirectives(e.createElementVNode("div",{ref_key:"editorRef",ref:r,contenteditable:!l.disabled,"data-placeholder":l.placeholder,class:"vt-editor__content",onBlur:k1,onFocus:b1,onInput:B,onKeydown:N1},null,40,mW),[[e.vShow,!I.value]]),I.value?e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{key:0,ref_key:"htmlSourceRef",ref:h,"onUpdate:modelValue":H[11]||(H[11]=f=>b.value=f),class:"vt-editor__html-source",onInput:K},null,544)),[[e.vModelText,b.value]]):e.createCommentVNode("",!0)]),p1.value?(e.openBlock(),e.createElementBlock("div",hW,e.toDisplayString(p1.value),1)):e.createCommentVNode("",!0),e.createVNode(pe,{modelValue:e.unref(J).visible,"onUpdate:modelValue":H[19]||(H[19]=f=>e.unref(J).visible=f),"close-on-backdrop-click":!1,title:e.unref(n)(e.unref(c).EDITOR_LINK_TITLE),size:"small",onClose:e.unref(T)},{default:e.withCtx(()=>[e.createElementVNode("div",IW,[e.createElementVNode("label",pW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_LINK_URL)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":H[12]||(H[12]=f=>e.unref(J).url=f),class:"vt-editor__dialog-input",placeholder:"https://example.com",type:"url",onKeydown:[H[13]||(H[13]=e.withKeys((...f)=>e.unref(E)&&e.unref(E)(...f),["enter"])),H[14]||(H[14]=e.withKeys((...f)=>e.unref(T)&&e.unref(T)(...f),["esc"]))]},null,544),[[e.vModelText,e.unref(J).url]]),e.createElementVNode("label",ZW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_LINK_TEXT)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":H[15]||(H[15]=f=>e.unref(J).text=f),class:"vt-editor__dialog-input",placeholder:"Link text",type:"text",onKeydown:[H[16]||(H[16]=e.withKeys((...f)=>e.unref(E)&&e.unref(E)(...f),["enter"])),H[17]||(H[17]=e.withKeys((...f)=>e.unref(T)&&e.unref(T)(...f),["esc"]))]},null,544),[[e.vModelText,e.unref(J).text]]),e.createElementVNode("label",uW,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":H[18]||(H[18]=f=>e.unref(J).openInNewTab=f),type:"checkbox"},null,512),[[e.vModelCheckbox,e.unref(J).openInNewTab]]),e.createTextVNode(" "+e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_LINK_NEW_TAB)),1)])]),e.createElementVNode("div",bW,[e.createVNode(x1,{onClick:e.unref(T)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).BUTTON_CANCEL)),1)]),_:1},8,["onClick"]),e.createVNode(x1,{type:"primary",onClick:e.unref(E)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_INSERT)),1)]),_:1},8,["onClick"])])]),_:1},8,["modelValue","title","onClose"]),e.createVNode(pe,{modelValue:e.unref(z).visible,"onUpdate:modelValue":H[26]||(H[26]=f=>e.unref(z).visible=f),"close-on-backdrop-click":!1,title:e.unref(n)(e.unref(c).EDITOR_IMAGE_TITLE),size:"small",onClose:e.unref(N)},{default:e.withCtx(()=>[e.createElementVNode("div",CW,[e.createElementVNode("label",yW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_IMAGE_URL)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":H[20]||(H[20]=f=>e.unref(z).url=f),class:"vt-editor__dialog-input",placeholder:"https://example.com/image.png",type:"url",onKeydown:[H[21]||(H[21]=e.withKeys((...f)=>e.unref(n1)&&e.unref(n1)(...f),["enter"])),H[22]||(H[22]=e.withKeys((...f)=>e.unref(N)&&e.unref(N)(...f),["esc"]))]},null,544),[[e.vModelText,e.unref(z).url]]),e.createElementVNode("label",VW,e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_IMAGE_ALT)),1),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":H[23]||(H[23]=f=>e.unref(z).alt=f),class:"vt-editor__dialog-input",placeholder:"Image description",type:"text",onKeydown:[H[24]||(H[24]=e.withKeys((...f)=>e.unref(n1)&&e.unref(n1)(...f),["enter"])),H[25]||(H[25]=e.withKeys((...f)=>e.unref(N)&&e.unref(N)(...f),["esc"]))]},null,544),[[e.vModelText,e.unref(z).alt]])]),e.createElementVNode("div",SW,[e.createVNode(x1,{onClick:e.unref(N)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).BUTTON_CANCEL)),1)]),_:1},8,["onClick"]),e.createVNode(x1,{type:"primary",onClick:e.unref(n1)},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n)(e.unref(c).EDITOR_INSERT)),1)]),_:1},8,["onClick"])])]),_:1},8,["modelValue","title","onClose"])],2)}}}),YW={class:"vt-badge"},De=e.defineComponent({__name:"VBadge",props:{content:{default:void 0},max:{default:99},dot:{type:Boolean,default:!1},color:{default:"danger"},position:{default:"top-end"},offsetX:{default:0},offsetY:{default:0},bordered:{type:Boolean,default:!1},hidden:{type:Boolean,default:!1}},setup(l){const t=l,i=e.computed(()=>t.dot?!0:t.content===void 0||t.content===null||t.content===""?!1:typeof t.content=="number"?t.content>0:!0),n=e.computed(()=>i.value&&!t.hidden),o=e.computed(()=>typeof t.content=="number"?t.content>t.max?`${t.max}+`:String(t.content):t.content),s=e.computed(()=>{if(!t.offsetX&&!t.offsetY)return{};const r=t.position.startsWith("top"),a=t.position.endsWith("end"),h={};return t.offsetX&&(h[a?"right":"left"]=`${-t.offsetX}px`),t.offsetY&&(h[r?"top":"bottom"]=`${-t.offsetY}px`),h});return(r,a)=>(e.openBlock(),e.createElementBlock("span",YW,[e.renderSlot(r.$slots,"default"),e.createVNode(e.Transition,{name:"vt-badge__fade"},{default:e.withCtx(()=>[n.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["vt-badge__content",[`vt-badge__content--${l.position}`,`vt-badge__content--${l.color}`,{"vt-badge__content--dot":l.dot,"vt-badge__content--bordered":l.bordered}]]),style:e.normalizeStyle(s.value)},[l.dot?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(o.value),1)],64))],6)):e.createCommentVNode("",!0)]),_:1})]))}}),LW={class:"vt-app-bar__logo"},WW={key:0,class:"vt-app-bar__center"},kW={key:1,class:"vt-app-bar__actions"},il=e.defineComponent({__name:"VAppBar",props:{sticky:{type:Boolean,default:!1}},setup(l){return(t,i)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vt-app-bar",{"vt-app-bar--sticky":l.sticky}])},[e.createElementVNode("div",LW,[e.renderSlot(t.$slots,"logo")]),t.$slots.center?(e.openBlock(),e.createElementBlock("div",WW,[e.renderSlot(t.$slots,"center")])):e.createCommentVNode("",!0),t.$slots.actions?(e.openBlock(),e.createElementBlock("div",kW,[e.renderSlot(t.$slots,"actions")])):e.createCommentVNode("",!0)],2))}}),MW={class:"vt-nav-rail"},NW={class:"vt-nav-rail__list"},XW=["data-placement","onClick"],TW={key:0,class:"vt-nav-rail__divider"},wW={key:0,class:"vt-nav-rail__footer"},ol=e.defineComponent({__name:"VNavRail",props:{items:{},modelValue:{default:null},placement:{default:"left"}},emits:["update:modelValue","select"],setup(l,{emit:t}){const i=t,n=o=>{o.disabled||(i("update:modelValue",o.key),i("select",o))};return(o,s)=>{const r=e.resolveDirective("tooltip");return e.openBlock(),e.createElementBlock("aside",MW,[e.createElementVNode("div",NW,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.items,(a,h)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:a.key},[e.withDirectives((e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vt-nav-rail__item",{"vt-nav-rail__item--selected":l.modelValue===a.key,"vt-nav-rail__item--disabled":a.disabled}]),"data-placement":l.placement,onClick:d=>n(a)},[a.badge?(e.openBlock(),e.createBlock(De,{key:0,content:a.badge.content,position:a.badge.position},{default:e.withCtx(()=>[e.createVNode(h1,{name:a.icon,width:24,height:24},null,8,["name"])]),_:2},1032,["content","position"])):(e.openBlock(),e.createBlock(h1,{key:1,name:a.icon,width:24,height:24},null,8,["name"]))],10,XW)),[[r,a.label]]),h<l.items.length-1?(e.openBlock(),e.createElementBlock("span",TW)):e.createCommentVNode("",!0)],64))),128))]),o.$slots.footer?(e.openBlock(),e.createElementBlock("div",wW,[e.renderSlot(o.$slots,"footer")])):e.createCommentVNode("",!0)])}}}),nl=(l,t)=>{const i=document.createElement("div");i.className=`vt-tooltip vt-tooltip--${t}`,i.innerText=l,Object.assign(i.style,{position:"absolute",background:"rgba(0, 0, 0, 0.8)",color:"white",padding:"8px 12px",borderRadius:"4px",fontSize:"12px",lineHeight:"1.4",zIndex:"9999",pointerEvents:"none",visibility:"hidden",opacity:"0",transition:"opacity 0.2s ease, visibility 0.2s ease",maxWidth:"300px",wordWrap:"break-word",whiteSpace:"normal",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.2)"});const n=document.createElement("div");switch(n.className="vt-tooltip__arrow",Object.assign(n.style,{position:"absolute",width:"0",height:"0",borderStyle:"solid"}),t){case"top":Object.assign(n.style,{top:"100%",left:"50%",marginLeft:"-5px",borderWidth:"5px 5px 0 5px",borderColor:"rgba(0, 0, 0, 0.8) transparent transparent transparent"});break;case"bottom":Object.assign(n.style,{bottom:"100%",left:"50%",marginLeft:"-5px",borderWidth:"0 5px 5px 5px",borderColor:"transparent transparent rgba(0, 0, 0, 0.8) transparent"});break;case"left":Object.assign(n.style,{top:"50%",left:"100%",marginTop:"-5px",borderWidth:"5px 0 5px 5px",borderColor:"transparent transparent transparent rgba(0, 0, 0, 0.8)"});break;case"right":Object.assign(n.style,{top:"50%",right:"100%",marginTop:"-5px",borderWidth:"5px 5px 5px 0",borderColor:"transparent rgba(0, 0, 0, 0.8) transparent transparent"});break}return i.appendChild(n),i},Pe=(l,t,i)=>{const n=t.getBoundingClientRect(),o=window.pageXOffset||document.documentElement.scrollLeft,s=window.pageYOffset||document.documentElement.scrollTop,r=window.innerWidth,a=window.innerHeight,h=8,d=Math.min(300,r-h*2);l.style.maxWidth=`${d}px`;const I=l.getBoundingClientRect();let b=0,u=0;switch(i){case"top":b=n.top+s-I.height-8,u=n.left+o+(n.width-I.width)/2;break;case"bottom":b=n.bottom+s+8,u=n.left+o+(n.width-I.width)/2;break;case"left":b=n.top+s+(n.height-I.height)/2,u=n.left+o-I.width-8;break;case"right":b=n.top+s+(n.height-I.height)/2,u=n.right+o+8;break}u<h?u=h:u+I.width>r-h&&(u=r-I.width-h),b<s+h?i==="top"?b=n.bottom+s+8:b=s+h:b+I.height>s+a-h&&(i==="bottom"?b=n.top+s-I.height-8:b=s+a-I.height-h),l.style.top=`${b}px`,l.style.left=`${u}px`},sl=(l,t,i)=>{l.parentElement||document.body.appendChild(l),l.style.visibility="visible",Pe(l,t,i),requestAnimationFrame(()=>{l.style.opacity="1"})},cl=l=>{l.style.opacity="0",l.style.visibility="hidden"},rl=l=>l.scrollWidth>l.clientWidth||l.scrollHeight>l.clientHeight,al=l=>!!l.closest(".vt-table, table"),dl={mounted(l,t){var h;const i=(h=t.value)==null?void 0:h.trim();if(!i)return;const n=l.dataset.placement||"top",o=nl(i,n);l.__tooltipEl=o;const s=()=>{(al(l)?rl(l):!0)&&sl(o,l,n)},r=()=>{cl(o)},a=()=>{o.style.opacity==="1"&&Pe(o,l,n)};l.__mouseenterHandler=s,l.__mouseleaveHandler=r,l.__scrollHandler=a,l.addEventListener("mouseenter",s),l.addEventListener("mouseleave",r),window.addEventListener("scroll",a,!0),window.addEventListener("resize",a)},updated(l,t){var n;const i=(n=t.value)==null?void 0:n.trim();if(l.__tooltipEl)i?l.__tooltipEl.firstChild.textContent=i:(l.__tooltipEl.parentElement&&l.__tooltipEl.parentElement.removeChild(l.__tooltipEl),delete l.__tooltipEl);else if(i){const o=l.dataset.placement||"top",s=nl(i,o);l.__tooltipEl=s;const r=()=>{(al(l)?rl(l):!0)&&sl(s,l,o)},a=()=>{cl(s)},h=()=>{s.style.opacity==="1"&&Pe(s,l,o)};l.__mouseenterHandler=r,l.__mouseleaveHandler=a,l.__scrollHandler=h,l.addEventListener("mouseenter",r),l.addEventListener("mouseleave",a),window.addEventListener("scroll",h,!0),window.addEventListener("resize",h)}},beforeUnmount(l){l.__tooltipEl&&l.__tooltipEl.parentElement&&(l.__tooltipEl.parentElement.removeChild(l.__tooltipEl),delete l.__tooltipEl),l.__mouseenterHandler&&(l.removeEventListener("mouseenter",l.__mouseenterHandler),delete l.__mouseenterHandler),l.__mouseleaveHandler&&(l.removeEventListener("mouseleave",l.__mouseleaveHandler),delete l.__mouseleaveHandler),l.__scrollHandler&&(window.removeEventListener("scroll",l.__scrollHandler,!0),window.removeEventListener("resize",l.__scrollHandler),delete l.__scrollHandler)}},ml={mounted(l,t){e.unref(t.value)&&hl(l)},updated(l,t){const i=e.unref(t.value),n=e.unref(t.oldValue);i!==n&&(i?hl(l):Il(l))},unmounted(l){Il(l)}};function hl(l){if(l._loaderEl)return;const t=document.createElement("div");t.className="vt-loader-base__overlay",t.innerHTML='<span class="vt-loader-base"></span>';const i=getComputedStyle(l).position;(i==="static"||!i)&&(l.style.position="relative"),l.appendChild(t),l._loaderEl=t}function Il(l){const t=l._loaderEl;t&&(t.remove(),delete l._loaderEl)}const GW={class:"vt-message-container"},xW={class:"vt-message-icon"},gW={class:"vt-message-content"},fW={key:0,class:"vt-message-title"},EW=["innerHTML"],JW={key:1,class:"vt-message-text"},KW=["onClick"],FW=e.defineComponent({__name:"VMessage",setup(l,{expose:t}){const i=e.ref([]);let n=0;const o=a=>({success:"checkCircle",danger:"alertCircle",warning:"alertTriangle",primary:"infoCircle"})[a]||"infoCircle",s=a=>{const h=++n,d={id:h,message:a.message||"",title:a.title||"",type:a.type||"primary",showClose:a.showClose||!1,duration:a.duration!==void 0?a.duration:3e3,dangerouslyUseHTMLString:a.dangerouslyUseHTMLString||!1};return i.value.push(d),d.duration&&d.duration>0&&setTimeout(()=>{r(h)},d.duration),h},r=a=>{const h=i.value.findIndex(d=>d.id===a);h>-1&&i.value.splice(h,1)};return t({addMessage:s,removeMessage:r}),(a,h)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createElementVNode("div",GW,[e.createVNode(e.TransitionGroup,{name:"vt-message",tag:"div"},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,d=>(e.openBlock(),e.createElementBlock("div",{key:d.id,class:e.normalizeClass(["vt-message-item",`vt-message-item--${d.type}`,{"vt-message-item--closable":d.showClose}])},[e.createElementVNode("div",xW,[e.createVNode(h1,{color:d.type==="primary"?"#00475A":"",name:o(d.type)},null,8,["color","name"])]),e.createElementVNode("div",gW,[d.title?(e.openBlock(),e.createElementBlock("div",fW,e.toDisplayString(d.title),1)):e.createCommentVNode("",!0),d.message?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[d.dangerouslyUseHTMLString?(e.openBlock(),e.createElementBlock("div",{key:0,class:"vt-message-text",innerHTML:d.message},null,8,EW)):(e.openBlock(),e.createElementBlock("div",JW,e.toDisplayString(d.message),1))],64)):e.createCommentVNode("",!0)]),d.showClose?(e.openBlock(),e.createElementBlock("button",{key:0,class:"vt-message-close",type:"button",onClick:I=>r(d.id)},[e.createVNode(h1,{name:"close"})],8,KW)):e.createCommentVNode("",!0)],2))),128))]),_:1})])]))}});class jW{constructor(){this.messageInstance=null,this.app=null,this.container=null}call(t={}){return this.ensureInstance().addMessage({message:t.message||"",title:t.title||"",type:t.type||"primary",showClose:t.showClose||!1,duration:t.duration!==void 0?t.duration:3e3,dangerouslyUseHTMLString:t.dangerouslyUseHTMLString||!1})}success(t,i={}){return this.call({...i,message:t,type:"success"})}danger(t,i={}){return this.call({...i,message:t,type:"danger"})}warning(t,i={}){return this.call({...i,message:t,type:"warning"})}primary(t,i={}){return this.call({...i,message:t,type:"primary"})}close(t){this.messageInstance&&this.messageInstance.removeMessage(t)}closeAll(){this.messageInstance&&(this.messageInstance.messages=[]),this.container&&this.container.parentNode&&document.body.removeChild(this.container),this.app&&this.app.unmount(),this.messageInstance=null,this.app=null,this.container=null}getOpenMessagesCount(){return this.messageInstance?this.messageInstance.messages.length:0}ensureInstance(){return this.messageInstance?this.messageInstance:(this.container=document.createElement("div"),this.container.setAttribute("data-vt-message-container",""),document.body.appendChild(this.container),this.app=e.createApp(FW),this.messageInstance=this.app.mount(this.container),this.messageInstance)}}const H1=new jW,He=Object.assign((l={})=>H1.call(l),{success:(l,t={})=>H1.success(l,t),danger:(l,t={})=>H1.danger(l,t),warning:(l,t={})=>H1.warning(l,t),primary:(l,t={})=>H1.primary(l,t),close:l=>{H1.close(l)},closeAll:()=>{H1.closeAll()}}),pl={install(l){l.config.globalProperties.$message=He,l.provide("$message",He),l.config.globalProperties.$messageStack={closeAll:()=>H1.closeAll(),getCount:()=>H1.getOpenMessagesCount(),closeById:t=>H1.close(t)}}},RW={sortable:!0,actionColumn:!1,showOverflowTooltip:!0,visible:!0,pinnedLeft:!1,pinnedRight:!1,manage:!1};function UW(l){_e(l)}const Zl={install(l,t={}){const{prefix:i="V",modal:n=!0,message:o=!0,locale:s=D1.uk}=t;l.component(`${i}Button`,x1),l.component(`${i}Icon`,h1),l.component(`${i}Loader`,Ie),l.component(`${i}Modal`,pe),l.component(`${i}Pagination`,$e),l.component(`${i}Checkbox`,O1),l.component(`${i}Radiobox`,qe),l.component(`${i}Table`,it),l.component(`${i}TableColumn`,ot),l.component(`${i}Dropdown`,oe),l.component(`${i}DropdownItem`,ne),l.component(`${i}Input`,ae),l.component(`${i}Select`,Se),l.component(`${i}Option`,Ye),l.component(`${i}DatePicker`,It),l.component(`${i}TimePicker`,ue),l.component(`${i}Collapse`,pt),l.component(`${i}CollapseItem`,Zt),l.component(`${i}Tabs`,ut),l.component(`${i}TabItem`,bt),l.component(`${i}Upload`,Vt),l.component(`${i}Sidebar`,St),l.component(`${i}Login`,Tt),l.component(`${i}LoginLogo`,wt),l.component(`${i}LocaleSelect`,nt),l.component(`${i}DynamicFilter`,Gt),l.component(`${i}Slider`,xt),l.component(`${i}SliderMarkRange`,gt),l.component(`${i}Chart`,Et),l.component(`${i}InfoBox`,Jt),l.component(`${i}TransferList`,Kt),l.component(`${i}Avatar`,Ft),l.component(`${i}AvatarUpload`,Rt),l.component(`${i}ImageFullscreen`,zt),l.component(`${i}Breadcrumb`,Ot),l.component(`${i}BreadcrumbItem`,Dt),l.component(`${i}Audio`,qt),l.component(`${i}Empty`,Le),l.component(`${i}Editor`,ll),l.component(`${i}Badge`,De),l.component(`${i}AppBar`,il),l.component(`${i}NavRail`,ol),l.directive("tooltip",dl),l.directive("loader",ml),n&&l.use(lt),o&&l.use(pl),l.use(xZ,{locale:s})}},zW=Zl.install;l1.DEFAULT_COLUMN_CONFIG=RW,l1.DEFAULT_FORMATS=st,l1.DEFAULT_TIME_FORMATS=Ze,l1.DropdownContextKey=ge,l1.FORMAT_TOKENS=gb,l1.FileParser=be,l1.FileValidator=se,l1.LANGUAGES=D1,l1.VAppBar=il,l1.VAudio=qt,l1.VAvatar=Ft,l1.VAvatarUpload=Rt,l1.VBadge=De,l1.VBreadcrumb=Ot,l1.VBreadcrumbItem=Dt,l1.VButton=x1,l1.VChart=Et,l1.VCheckbox=O1,l1.VCollapse=pt,l1.VCollapseItem=Zt,l1.VColorPicker=CL,l1.VDatePicker=It,l1.VDropdown=oe,l1.VDropdownItem=ne,l1.VDynamicFilter=Gt,l1.VEditor=ll,l1.VEmpty=Le,l1.VIcon=h1,l1.VImageFullscreen=zt,l1.VInfoBox=Jt,l1.VInput=ae,l1.VLoader=Ie,l1.VLocaleSelect=nt,l1.VLogin=Tt,l1.VLoginLogo=wt,l1.VMessage=He,l1.VMessagePlugin=pl,l1.VModal=pe,l1.VModalPlugin=lt,l1.VNavRail=ol,l1.VOption=Ye,l1.VPagination=$e,l1.VRadiobox=qe,l1.VSelect=Se,l1.VSidebar=St,l1.VSlider=xt,l1.VSliderMarkRange=gt,l1.VTabItem=bt,l1.VTable=it,l1.VTableColumn=ot,l1.VTabs=ut,l1.VTimePicker=ue,l1.VTimerDuration=VL,l1.VTransferList=Kt,l1.VUpload=Vt,l1.VtSelectContextKey=Ge,l1.containUpperCaseLetter=Mt,l1.default=Zl,l1.email=Yt,l1.formatTime=mt,l1.generateTimeOptions=Me,l1.install=zW,l1.isValidDate=Je,l1.isValidTimeString=ke,l1.loaderDirective=ml,l1.maxLength=xV,l1.maxNumber=fV,l1.messageManager=H1,l1.minLength=Ke,l1.minNumber=gV,l1.mk=GV,l1.modalManager=_1,l1.noSpaces=Fe,l1.numeric=Wt,l1.parseTimeString=ht,l1.pattern=JV,l1.phoneNumber=kt,l1.required=Ne,l1.sameAs=EV,l1.setLocale=UW,l1.tooltipDirective=dl,l1.uniqueAsync=KV,l1.url=Lt,l1.useValidate=Xt,l1.validateDateValue=ct,l1.validateTimeValue=at,l1.withAsync=wV,l1.withMessage=TV,l1.withName=ee,l1.withParams=XV,Object.defineProperties(l1,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "1.21.151",
7
+ "version": "1.21.152",
8
8
  "type": "module",
9
9
  "main": "dist/index.umd.js",
10
10
  "module": "dist/index.es.js",