PageSourceSearch

https://wavevisual.com/_next/static/chunks/7472.9543ec8dd038dfcf.js

js wavevisual.com collected 2026-10-04 13:33:48 UTC 40,121 bytes, 73 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7472],{58845:function(t,e,i){i.d(e,{Z:function(){return l}});class n{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),null==i?void 0:i.once){let i=()=>{this.un(t,i),this.un(t,e)};return this.on(t,i),i}return()=>this.un(t,e)}un(t,e){var i;null===(i=this.listeners[t])||void 0===i||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(t=>t(...e))}}class s extends n{constructor(t){super(),this.subscriptions=[],this.options=t}onInit(){}_init(t){this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t())}}function r(t,e,i,n,s=3,r=0){if(!t)return()=>{};let o=()=>{},a=a=>{if(a.button!==r)return;a.preventDefault(),a.stopPropagation();let l=a.clientX,h=a.clientY,d=!1,u=n=>{n.preventDefault(),n.stopPropagation();let r=n.clientX,o=n.clientY,a=r-l,u=o-h;if(d||Math.abs(a)>s||Math.abs(u)>s){let{left:n,top:s}=t.getBoundingClientRect();d||(null==i||i(l-n,h-s),d=!0),e(a,u,r-n,o-s),l=r,h=o}},c=()=>{d&&(null==n||n()),o()},p=t=>{t.relatedTarget&&t.relatedTarget!==document.documentElement||c()},m=t=>{d&&(t.stopPropagation(),t.preventDefault())},v=t=>{d&&t.preventDefault()};document.addEventListener("pointermove",u),document.addEventListener("pointerup",c),document.addEventListener("pointerout",p),document.addEventListener("pointercancel",p),document.addEventListener("touchmove",v,{passive:!1}),document.addEventListener("click",m,{capture:!0}),o=()=>{document.removeEventListener("pointermove",u),document.removeEventListener("pointerup",c),document.removeEventListener("pointerout",p),document.removeEventListener("pointercancel",p),document.removeEventListener("touchmove",v),setTimeout(()=>{document.removeEventListener("click",m,{capture:!0})},10)}};return t.addEventListener("pointerdown",a),()=>{o(),t.removeEventListener("pointerdown",a)}}function o(t,e,i){let n=function t(e,i){let n=i.xmlns?document.createElementNS(i.xmlns,e):document.createElement(e);for(let[e,s]of Object.entries(i))if("children"===e)for(let[e,s]of Object.entries(i))"string"==typeof s?n.appendChild(document.createTextNode(s)):n.appendChild(t(e,s));else"style"===e?Object.assign(n.style,s):"textContent"===e?n.textContent=s:n.setAttribute(e,s.toString());return n}(t,e||{});return null==i||i.appendChild(n),n}class a extends n{constructor(t,e,i=0){var n,s,r,o,a,l,h,d;super(),this.totalDuration=e,this.numberOfChannels=i,this.minLength=0,this.maxLength=1/0,this.contentEditable=!1,this.id=t.id||`region-${Math.random().toString(32).slice(2)}`,this.start=this.clampPosition(t.start),this.end=this.clampPosition(null!==(n=t.end)&&void 0!==n?n:t.start),this.drag=null===(s=t.drag)||void 0===s||s,this.resize=null===(r=t.resize)||void 0===r||r,this.color=null!==(o=t.color)&&void 0!==o?o:"rgba(0, 0, 0, 0.1)",this.minLength=null!==(a=t.minLength)&&void 0!==a?a:this.minLength,this.maxLength=null!==(l=t.maxLength)&&void 0!==l?l:this.maxLength,this.channelIdx=null!==(h=t.channelIdx)&&void 0!==h?h:-1,this.contentEditable=null!==(d=t.contentEditable)&&void 0!==d?d:this.contentEditable,this.element=this.initElement(),this.setContent(t.content),this.setPart(),this.renderPosition(),this.initMouseEvents()}clampPosition(t){return Math.max(0,Math.min(this.totalDuration,t))}setPart(){let t=this.start===this.end;this.element.setAttribute("part",`${t?"marker":"region"} ${this.id}`)}addResizeHandles(t){let e={position:"absolute",zIndex:"2",width:"6px",height:"100%",top:"0",cursor:"ew-resize",wordBreak:"keep-all"},i=o("div",{part:"region-handle region-handle-left",style:Object.assign(Object.assign({},e),{left:"0",borderLeft:"2px solid rgba(0, 0, 0, 0.5)",borderRadius:"2px 0 0 2px"})},t),n=o("div",{part:"region-handle region-handle-right",style:Object.assign(Object.assign({},e),{right:"0",borderRight:"2px solid rgba(0, 0, 0, 0.5)",borderRadius:"0 2px 2px 0"})},t);r(i,t=>this.onResize(t,"start"),()=>null,()=>this.onEndResizing(),1),r(n,t=>this.onResize(t,"end"),()=>null,()=>this.onEndResizing(),1)}removeResizeHandles(t){let e=t.querySelector('[part*="region-handle-left"]'),i=t.querySelector('[part*="region-handle-right"]');e&&t.removeChild(e),i&&t.removeChild(i)}initElement(){let t=this.start===this.end,e=0,i=100;this.channelIdx>=0&&this.channelIdx<this.numberOfChannels&&(e=(i=100/this.numberOfChannels)*this.channelIdx);let n=o("div",{style:{position:"absolute",top:`${e}%`,height:`${i}%`,backgroundColor:t?"none":this.color,borderLeft:t?"2px solid "+this.color:"none",borderRadius:"2px",boxSizing:"border-box",transition:"background-color 0.2s ease",cursor:this.drag?"grab":"default",pointerEvents:"all"}});return!t&&this.resize&&this.addResizeHandles(n),n}renderPosition(){let t=this.start/this.totalDuration,e=(this.totalDuration-this.end)/this.totalDuration;this.element.style.left=100*t+"%",this.element.style.right=100*e+"%"}toggleCursor(t){var e;this.drag&&(null===(e=this.element)||void 0===e?void 0:e.style)&&(this.element.style.cursor=t?"grabbing":"grab")}initMouseEvents(){let{element:t}=this;t&&(t.addEventListener("click",t=>
1this.emit("click",t)),t.addEventListener("mouseenter",t=>this.emit("over",t)),t.addEventListener("mouseleave",t=>this.emit("leave",t)),t.addEventListener("dblclick",t=>this.emit("dblclick",t)),t.addEventListener("pointerdown",()=>this.toggleCursor(!0)),t.addEventListener("pointerup",()=>this.toggleCursor(!1)),r(t,t=>this.onMove(t),()=>this.toggleCursor(!0),()=>{this.toggleCursor(!1),this.drag&&this.emit("update-end")}),this.contentEditable&&this.content&&(this.content.addEventListener("click",t=>this.onContentClick(t)),this.content.addEventListener("blur",()=>this.onContentBlur())))}_onUpdate(t,e){if(null==this.element||!this.element.parentElement)return;let{width:i}=this.element.parentElement.getBoundingClientRect(),n=t/i*this.totalDuration,s=e&&"start"!==e?this.start:this.start+n,r=e&&"end"!==e?this.end:this.end+n,o=r-s;s>=0&&r<=this.totalDuration&&s<=r&&o>=this.minLength&&o<=this.maxLength&&(this.start=s,this.end=r,this.renderPosition(),this.emit("update",e))}onMove(t){this.drag&&this._onUpdate(t)}onResize(t,e){this.resize&&this._onUpdate(t,e)}onEndResizing(){this.resize&&this.emit("update-end")}onContentClick(t){t.stopPropagation(),t.target.focus(),this.emit("click",t)}onContentBlur(){this.emit("update-end")}_setTotalDuration(t){this.totalDuration=t,this.renderPosition()}play(){this.emit("play")}setContent(t){var e;if(null===(e=this.content)||void 0===e||e.remove(),t){if("string"==typeof t){let e=this.start===this.end;this.content=o("div",{style:{padding:`0.2em ${e?.2:.4}em`,display:"inline-block"},textContent:t})}else this.content=t;this.contentEditable&&(this.content.contentEditable="true"),this.content.setAttribute("part","region-content"),this.element.appendChild(this.content)}else this.content=void 0}setOptions(t){var e,i;if(t.color&&(this.color=t.color,this.element.style.backgroundColor=this.color),void 0!==t.drag&&(this.drag=t.drag,this.element.style.cursor=this.drag?"grab":"default"),void 0!==t.start||void 0!==t.end){let n=this.start===this.end;this.start=this.clampPosition(null!==(e=t.start)&&void 0!==e?e:this.start),this.end=this.clampPosition(null!==(i=t.end)&&void 0!==i?i:n?this.start:this.end),this.renderPosition(),this.setPart()}if(t.content&&this.setContent(t.content),t.id&&(this.id=t.id,this.setPart()),void 0!==t.resize&&t.resize!==this.resize){let e=this.start===this.end;this.resize=t.resize,this.resize&&!e?this.addResizeHandles(this.element):this.removeResizeHandles(this.element)}}remove(){this.emit("remove"),this.element.remove(),this.element=null}}class l extends s{constructor(t){super(t),this.regions=[],this.regionsContainer=this.initRegionsContainer()}static create(t){return new l(t)}onInit(){if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");this.wavesurfer.getWrapper().appendChild(this.regionsContainer);let t=[];this.subscriptions.push(this.wavesurfer.on("timeupdate",e=>{let i=this.regions.filter(t=>t.start<=e&&(t.end===t.start?t.start+.05:t.end)>=e);i.forEach(e=>{t.includes(e)||this.emit("region-in",e)}),t.forEach(t=>{i.includes(t)||this.emit("region-out",t)}),t=i}))}initRegionsContainer(){return o("div",{style:{position:"absolute",top:"0",left:"0",width:"100%",height:"100%",zIndex:"3",pointerEvents:"none"}})}getRegions(){return this.regions}avoidOverlapping(t){if(!t.content)return;let e=t.content,i=e.getBoundingClientRect(),n=this.regions.map(e=>{if(e===t||!e.content)return 0;let n=e.content.getBoundingClientRect();return i.left<n.left+n.width&&n.left<i.left+i.width?n.height:0}).reduce((t,e)=>t+e,0);e.style.marginTop=`${n}px`}adjustScroll(t){var e,i;let n=null===(i=null===(e=this.wavesurfer)||void 0===e?void 0:e.getWrapper())||void 0===i?void 0:i.parentElement;if(!n)return;let{clientWidth:s,scrollWidth:r}=n;if(r<=s)return;let o=n.getBoundingClientRect(),a=t.element.getBoundingClientRect(),l=a.left-o.left,h=a.right-o.left;l<0?n.scrollLeft+=l:h>s&&(n.scrollLeft+=h-s)}saveRegion(t){this.regionsContainer.appendChild(t.element),this.avoidOverlapping(t),this.regions.push(t);let e=[t.on("update",e=>{e||this.adjustScroll(t)}),t.on("update-end",()=>{this.avoidOverlapping(t),this.emit("region-updated",t)}),t.on("play",()=>{var e,i;null===(e=this.wavesurfer)||void 0===e||e.play(),null===(i=this.wavesurfer)||void 0===i||i.setTime(t.start)}),t.on("click",e=>
1{this.emit("region-clicked",t,e)}),t.on("dblclick",e=>{this.emit("region-double-clicked",t,e)}),t.once("remove",()=>{e.forEach(t=>t()),this.regions=this.regions.filter(e=>e!==t),this.emit("region-removed",t)})];this.subscriptions.push(...e),this.emit("region-created",t)}addRegion(t){var e,i;if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");let n=this.wavesurfer.getDuration(),s=new a(t,n,null===(i=null===(e=this.wavesurfer)||void 0===e?void 0:e.getDecodedData())||void 0===i?void 0:i.numberOfChannels);return n?this.saveRegion(s):this.subscriptions.push(this.wavesurfer.once("ready",t=>{s._setTotalDuration(t),this.saveRegion(s)})),s}enableDragSelection(t,e=3){var i;let n=null===(i=this.wavesurfer)||void 0===i?void 0:i.getWrapper();if(!(n&&n instanceof HTMLElement))return()=>{};let s=null,o=0;return r(n,(t,e,i)=>{s&&s._onUpdate(t,i>o?"end":"start")},e=>{var i,n;if(o=e,!this.wavesurfer)return;let r=this.wavesurfer.getDuration(),l=null===(n=null===(i=this.wavesurfer)||void 0===i?void 0:i.getDecodedData())||void 0===n?void 0:n.numberOfChannels,{width:h}=this.wavesurfer.getWrapper().getBoundingClientRect();s=new a(Object.assign(Object.assign({},t),{start:e/h*r,end:(e+5)/h*r}),r,l),this.regionsContainer.appendChild(s.element)},()=>{s&&(this.saveRegion(s),s=null)},e)}clearRegions(){this.regions.forEach(t=>t.remove())}destroy(){this.clearRegions(),super.destroy(),this.regionsContainer.remove()}}},35078:function(t,e,i){i.d(e,{Z:function(){return a}});class n{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),null==i?void 0:i.once){let i=()=>{this.un(t,i),this.un(t,e)};return this.on(t,i),i}return()=>this.un(t,e)}un(t,e){var i;null===(i=this.listeners[t])||void 0===i||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(t=>t(...e))}}class s extends n{constructor(t){super(),this.subscriptions=[],this.options=t}onInit(){}_init(t){this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t())}}function r(t,e,i){let n=function t(e,i){let n=i.xmlns?document.createElementNS(i.xmlns,e):document.createElement(e);for(let[e,s]of Object.entries(i))if("children"===e)for(let[e,s]of Object.entries(i))"string"==typeof s?n.appendChild(document.createTextNode(s)):n.appendChild(t(e,s));else"style"===e?Object.assign(n.style,s):"textContent"===e?n.textContent=s:n.setAttribute(e,s.toString());return n}(t,e||{});return null==i||i.appendChild(n),n}let o={height:20,formatTimeCallback:t=>t/60>1?`${Math.floor(t/60)}:${(t=Math.round(t%60))<10?"0":""}${t}`:`${Math.round(1e3*t)/1e3}`};class a extends s{constructor(t){super(t||{}),this.options=Object.assign({},o,t),this.timelineWrapper=this.initTimelineWrapper()}static create(t){return new a(t)}onInit(){var t;if(!this.wavesurfer)throw Error("WaveSurfer is not initialized");let e=this.wavesurfer.getWrapper();if(this.options.container instanceof HTMLElement)e=this.options.container;else if("string"==typeof this.options.container){let t=document.querySelector(this.options.container);if(!t)throw Error(`No Timeline container found matching ${this.options.container}`);e=t}this.options.insertPosition?(e.firstElementChild||e).insertAdjacentElement(this.options.insertPosition,this.timelineWrapper):e.appendChild(this.timelineWrapper),this.subscriptions.push(this.wavesurfer.on("redraw",()=>this.initTimeline())),((null===(t=this.wavesurfer)||void 0===t?void 0:t.getDuration())||this.options.duration)&&this.initTimeline()}destroy(){this.timelineWrapper.remove(),super.destroy()}initTimelineWrapper(){return r("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}initTimeline(){var t,e,i,n,s,o,a;let l=null!==(i=null!==(e=null===(t=this.wavesurfer)||void 0===t?void 0:t.getDuration())&&void 0!==e?e:this.options.duration)&&void 0!==i?i:0,h=this.timelineWrapper.scrollWidth/l,d=null!==(n=this.options.timeInterval)&&void 0!==n?n:this.defaultTimeInterval(h),u=null!==(s=this.options.primaryLabelInterval)&&void 0!==s?s:this.defaultPrimaryLabelInterval(h),c=this.options.primaryLabelSpacing,p=null!==(o=this.options.secondaryLabelInterval)&&void 0!==o?o:this.defaultSecondaryLabelInterval(h),m=this.options.secondaryLabelSpacing,v="beforebegin"===this.options.insertPosition,g=r("div",{style:Object.assign({he
1ight:`${this.options.height}px`,overflow:"hidden",fontSize:this.options.height/2+"px",whiteSpace:"nowrap"},v?{position:"absolute",top:"0",left:"0",right:"0",zIndex:"2"}:{position:"relative"})});g.setAttribute("part","timeline"),"string"==typeof this.options.style?g.setAttribute("style",g.getAttribute("style")+this.options.style):"object"==typeof this.options.style&&Object.assign(g.style,this.options.style);let f=r("div",{style:{width:"0",height:"50%",display:"flex",flexDirection:"column",justifyContent:v?"flex-start":"flex-end",top:v?"0":"auto",bottom:v?"auto":"0",overflow:"visible",borderLeft:"1px solid currentColor",opacity:`${null!==(a=this.options.secondaryLabelOpacity)&&void 0!==a?a:.25}`,position:"absolute",zIndex:"1"}});for(let t=0,e=0;t<l;t+=d,e++){let i=f.cloneNode(),n=Math.round(100*t)/100%u==0||c&&e%c==0,s=Math.round(100*t)/100%p==0||m&&e%m==0;(n||s)&&(i.style.height="100%",i.style.textIndent="3px",i.textContent=this.options.formatTimeCallback(t),n&&(i.style.opacity="1"));let r=n?"primary":s?"secondary":"tick";i.setAttribute("part",`timeline-notch timeline-notch-${r}`),i.style.left=t*h+"px",g.appendChild(i)}this.timelineWrapper.innerHTML="",this.timelineWrapper.appendChild(g),this.emit("ready")}}},16442:function(t,e,i){function n(t,e,i,n){return new(i||(i=Promise))(function(s,r){function o(t){try{l(n.next(t))}catch(t){r(t)}}function a(t){try{l(n.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?s(t.value):((e=t.value)instanceof i?e:new i(function(t){t(e)})).then(o,a)}l((n=n.apply(t,e||[])).next())})}i.d(e,{Z:function(){return m}});class s{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),this.listeners[t].add(e),null==i?void 0:i.once){let i=()=>{this.un(t,i),this.un(t,e)};return this.on(t,i),i}return()=>this.un(t,e)}un(t,e){var i;null===(i=this.listeners[t])||void 0===i||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(t=>t(...e))}}let r={decode:function(t,e){return n(this,void 0,void 0,function*(){let i=new AudioContext({sampleRate:e});return i.decodeAudioData(t).finally(()=>i.close())})},createBuffer:function(t,e){return"number"==typeof t[0]&&(t=[t]),function(t){let e=t[0];if(e.some(t=>t>1||t<-1)){let i=e.length,n=0;for(let t=0;t<i;t++){let i=Math.abs(e[t]);i>n&&(n=i)}for(let e of t)for(let t=0;t<i;t++)e[t]/=n}}(t),{duration:e,length:t[0].length,sampleRate:t[0].length/e,numberOfChannels:t.length,getChannelData:e=>null==t?void 0:t[e],copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function o(t,e,i){let n=function t(e,i){let n=i.xmlns?document.createElementNS(i.xmlns,e):document.createElement(e);for(let[e,s]of Object.entries(i))if("children"===e)for(let[e,s]of Object.entries(i))"string"==typeof s?n.appendChild(document.createTextNode(s)):n.appendChild(t(e,s));else"style"===e?Object.assign(n.style,s):"textContent"===e?n.textContent=s:n.setAttribute(e,s.toString());return n}(t,e||{});return null==i||i.appendChild(n),n}var a=Object.freeze({__proto__:null,createElement:o,default:o});let l={fetchBlob:function(t,e,i){return n(this,void 0,void 0,function*(){let s=yield fetch(t,i);if(s.status>=400)throw Error(`Failed to fetch ${t}: ${s.status} (${s.statusText})`);return function(t,e){n(this,void 0,void 0,function*(){if(!t.body||!t.headers)return;let i=t.body.getReader(),s=Number(t.headers.get("Content-Length"))||0,r=0,o=t=>n(this,void 0,void 0,function*(){e(Math.round((r+=(null==t?void 0:t.length)||0)/s*100))}),a=()=>n(this,void 0,void 0,function*(){let t;try{t=yield i.read()}catch(t){return}t.done||(o(t.value),yield a())});a()})}(s.clone(),e),s.blob()})}};class h extends s{constructor(t){super(),this.isExternalMedia=!1,t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),t.mediaControls&&(this.media.controls=!0),t.autoplay&&(this.media.autoplay=!0),null!=t.playbackRate&&this.onceMediaEvent("canplay",()=>{null!=t.playbackRate&&(this.media.playbackRate=t.playbackRate)})}onMediaEvent(t,e,i){return this.media.addEventListener(t,e,i),()=>this.media.removeEventListener(t,e)}onceMediaEvent(t,e){return this.onMediaEvent(t,e,{once:!0})}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){let t=this.getSrc();t.startsWith("blob:")&&URL.revokeObjectURL(t)}canPlayType(t){return""!==this.media.canPlayType(t)}setSrc(t,e){if(this.getSrc()===t)return;this.revokeSrc();let i=e instanceof Blob&&this.canPlayType(e.type)?URL.createObjectURL(e):t;this.media.src=i}destroy(){this.media.pause(),this.isExternalMedia||(this.media.remove(),this.revokeSrc(),this.media.src="",this.media.load())}setMediaElement(t){this.media=t}play(){return n(this,void 0,void 0,function*(){if(this.media.src)return this.media.play()})}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=t}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(t){this.media.volume=t}getMuted(){return this.media.muted}setMuted(t){this.media.muted=t}getPlaybackRate(){return this.media.playbackRate}isSeeking(){return this.media.seeking}setPlaybackRate(t,e){null!=e&&(this.media.preservesPitch=e),this.media.playbackRate=t}getMediaElement(){return this.media}setSinkId(t){return this.media.setSinkId(t)}}class d extends s{constructor(t,e){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.options=t;let i=this.parentFromOptionsContainer(t.container);this.parent=i;let[n,s]=this.initHtml();i.appendChild(n),this.container=n,this.scrollContainer=s.querySelector(".scroll"),this.wrapper=s.querySelector(".wrapper"),this.canvasWrapper=s.querySelector(".canvases"),this.progressWrapper=s.querySelector(".progress"),this.cursor=s.querySelector(".cursor"),e&&s.appendChild(e),this.initEvents()}parentFromOptionsContainer(t){let e;if("string"==typeof t?e=document.querySelector(t):t instanceof HTMLElement&&(e=t),!e)throw Error("Container not found");return e}initEvents(){let t=t=>{let e=this.wrapper.getBoundingClientRect(),i=t.clientX-e.left,n=t.clientX-e.left;return[i/e.width,n/e.height]};this.wrapper.addEventListener("click",e=>{let[i,n]=t(e);
1this.emit("click",i,n)}),this.wrapper.addEventListener("dblclick",e=>{let[i,n]=t(e);this.emit("dblclick",i,n)}),this.options.dragToSeek&&this.initDrag(),this.scrollContainer.addEventListener("scroll",()=>{let{scrollLeft:t,scrollWidth:e,clientWidth:i}=this.scrollContainer;this.emit("scroll",t/e,(t+i)/e)});let e=this.createDelay(100);this.resizeObserver=new ResizeObserver(()=>{e().then(()=>this.onContainerResize()).catch(()=>{})}),this.resizeObserver.observe(this.scrollContainer)}onContainerResize(){let t=this.parent.clientWidth;t===this.lastContainerWidth&&"auto"!==this.options.height||(this.lastContainerWidth=t,this.reRender())}initDrag(){!function(t,e,i,n,s=3,r=0){if(!t)return()=>{};let o=()=>{};t.addEventListener("pointerdown",a=>{if(a.button!==r)return;a.preventDefault(),a.stopPropagation();let l=a.clientX,h=a.clientY,d=!1,u=n=>{n.preventDefault(),n.stopPropagation();let r=n.clientX,o=n.clientY,a=r-l,u=o-h;if(d||Math.abs(a)>s||Math.abs(u)>s){let{left:n,top:s}=t.getBoundingClientRect();d||(null==i||i(l-n,h-s),d=!0),e(a,u,r-n,o-s),l=r,h=o}},c=()=>{d&&(null==n||n()),o()},p=t=>{t.relatedTarget&&t.relatedTarget!==document.documentElement||c()},m=t=>{d&&(t.stopPropagation(),t.preventDefault())},v=t=>{d&&t.preventDefault()};document.addEventListener("pointermove",u),document.addEventListener("pointerup",c),document.addEventListener("pointerout",p),document.addEventListener("pointercancel",p),document.addEventListener("touchmove",v,{passive:!1}),document.addEventListener("click",m,{capture:!0}),o=()=>{document.removeEventListener("pointermove",u),document.removeEventListener("pointerup",c),document.removeEventListener("pointerout",p),document.removeEventListener("pointercancel",p),document.removeEventListener("touchmove",v),setTimeout(()=>{document.removeEventListener("click",m,{capture:!0})},10)}})}(this.wrapper,(t,e,i)=>{this.emit("drag",Math.max(0,Math.min(1,i/this.wrapper.getBoundingClientRect().width)))},()=>this.isDragging=!0,()=>this.isDragging=!1)}getHeight(t){return null==t?128:isNaN(Number(t))?"auto"===t&&this.parent.clientHeight||128:Number(t)}initHtml(){let t=document.createElement("div"),e=t.attachShadow({mode:"open"});return e.innerHTML=`
2      <style>
3        :host {
4          user-select: none;
5          min-width: 1px;
6        }
7        :host audio {
8          display: block;
9          width: 100%;
10        }
11        :host .scroll {
12          overflow-x: auto;
13          overflow-y: hidden;
14          width: 100%;
15          position: relative;
16        }
17        :host .noScrollbar {
18          scrollbar-color: transparent;
19          scrollbar-width: none;
20        }
21        :host .noScrollbar::-webkit-scrollbar {
22          display: none;
23          -webkit-appearance: none;
24        }
25        :host .wrapper {
26          position: relative;
27          overflow: visible;
28          z-index: 2;
29        }
30        :host .canvases {
31          min-height: ${this.getHeight(this.options.height)}px;
32        }
33        :host .canvases > div {
34          position: relative;
35        }
36        :host canvas {
37          display: block;
38          position: absolute;
39          top: 0;
40          image-rendering: pixelated;
41        }
42        :host .progress {
43          pointer-events: none;
44          position: absolute;
45          z-index: 2;
46          top: 0;
47          left: 0;
48          width: 0;
49          height: 100%;
50          overflow: hidden;
51        }
52        :host .progress > div {
53          position: relative;
54        }
55        :host .cursor {
56          pointer-events: none;
57          position: absolute;
58          z-index: 5;
59          top: 0;
60          left: 0;
61          height: 100%;
62          border-radius: 2px;
63        }
64      </style>
65
66      <div class="scroll" part="scroll">
67        <div class="wrapper" part="wrapper">
68          <div class="canvases"></div>
69          <div class="progress" part="progress"></div>
70          <div class="cursor" part="cursor"></div>
71        </div>
72      </div>
73    `,[t,e]}setOptions(t){if(this.options.container!==t.container){let e=this.parentFromOptionsContainer(t.container);e.appendChild(this.container),this.parent=e}t.dragToSeek&&!this.options.dragToSeek&&this.initDrag(),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getScroll(){return this.scrollContainer.scrollLeft}destroy(){var t;this.container.remove(),null===(t=this.resizeObserver)||void 0===t||t.disconnect()}createDelay(t=10){let e,i;let n=()=>{e&&clearTimeout(e),i&&i()};return this.timeouts.push(n),()=>new Promise((s,r)=>{n(),i=r,e=setTimeout(()=>{e=void 0,i=void 0,s()},t)})}convertColorValues(t){if(!Array.isArray(t))return t||"";if(t.length<2)return t[0]||"";let e=document.createElement("canvas"),i=e.getContext("2d"),n=e.height*(window.devicePixelRatio||1),s=i.createLinearGradient(0,0,0,n),r=1/(t.length-1);return t.forEach((t,e)=>{s.addColorStop(e*r,t)}),s}renderBarWaveform(t,e,i,n){let s=t[0],r=t[1]||t[0],o=s.length,{width:a,height:l}=i.canvas,h=l/2,d=window.devicePixelRatio||1,u=e.barWidth?e.barWidth*d:1,c=e.barGap?e.barGap*d:e.barWidth?u/2:0,p=e.barRadius||0,m=a/(u+c)/o,v=p&&"roundRect"in i?"roundRect":"rect";i.beginPath();let g=0,f=0,b=0;for(let t=0;t<=o;t++){let o=Math.round(t*m);if(o>g){let t=Math.round(f*h*n),s=t+Math.round(b*h*n)||1,r=h-t;"top"===e.barAlign?r=0:"bottom"===e.barAlign&&(r=l-s),i[v](g*(u+c),r,u,s,p),g=o,f=0,b=0}let a=Math.abs(s[t]||0),d=Math.abs(r[t]||0);a>f&&(f=a),d>b&&(b=d)}i.fill(),i.closePath()}renderLineWaveform(t,e,i,n){let s=e=>{let s=t[e]||t[0],r=s.length,{height:o}=i.canvas,a=o/2,l=i.canvas.width/r;i.moveTo(0,a);let h=0,d=0;for(let t=0;t<=r;t++){let r=Math.round(t*l);if(r>h){let t=a+(Math.round(d*a*n)||1)*(0===e?-1:1);i.lineTo(h,t),h=r,d=0}let o=Math.abs(s[t]||0);o>d&&(d=o)}i.lineTo(h,a)};i.beginPath(),s(0),s(1),i.fill(),i.closePath()}renderWaveform(t,e,i){if(i.fillStyle=this.convertColorValues(e.waveColor),e.renderFunction)return void e.renderFunction(t,i);let n=e.barHeight||1;if(e.normalize){let e=Array.from(t[0]).reduce((t,e)=>Math.max(t,Math.abs(e)),0);n=e?1/e:1}e.barWidth||e.barGap||e.barAlign?this.renderBarWaveform(t,e,i,n):this.renderLineWaveform(t,e,i,n)}renderSingleCanvas(t,e,i,n,s,r,o,a){let l=window.devicePixelRatio||1,h=document.createElement("canvas"),d=t[0].length;h.width=Math.round(i*(r-s)/d),h.height=n*l,h.style.width=`${Math.floor(h.width/l)}px`,h.style.height=`${n}px`,h.style.left=`${Math.floor(s*i/l/d)}px`,o.appendChild(h);let u=h.getContext("2d");if(this.renderWaveform(t.map(t=>t.slice(s,r)),e,u),h.width>0&&h.height>0){let t=h.cloneNode(),i=t.getContext("2d");i.drawImage(h,0,0),i.globalCompositeOperation="source-in",i.fillStyle=this.convertColorValues(e.progressColor),i.fillRect(0,0,h.width,h.height),a.appendChild(t)}}renderChannel(t,e,i){return n(this,void 0,void 0,function*(){let s=document.createElement("div"),r=this.getHeight(e.height);s.style.height=`${r}px`,this.canvasWrapper.style.minHeight=`${r}px`,this.canvasWrapper.appendChild(s);let o=s.cloneNode();this.progressWrapper.appendChild(o);let a=t[0].length,l=(n,l)=>{this.renderSingleCanvas(t,e,i,r,Math.max(0,n),Math.min(l,a),s,o)};if(!this.isScrollable)return void l(0,a);let{scrollLeft:h,scrollWidth:u,clientWidth:c}
73=this.scrollContainer,p=a/u,m=Math.min(d.MAX_CANVAS_WIDTH,c);if(e.barWidth||e.barGap){let t=e.barWidth||.5,i=t+(e.barGap||t/2);m%i!=0&&(m=Math.floor(m/i)*i)}let v=Math.floor(Math.abs(h)*p),g=Math.floor(v+m*p),f=g-v;f<=0||(l(v,g),yield Promise.all([n(this,void 0,void 0,function*(){if(0===v)return;let t=this.createDelay();for(let e=v;e>=0;e-=f)yield t(),l(Math.max(0,e-f),e)}),n(this,void 0,void 0,function*(){if(g===a)return;let t=this.createDelay();for(let e=g;e<a;e+=f)yield t(),l(e,Math.min(a,e+f))})]))})}render(t){return n(this,void 0,void 0,function*(){this.timeouts.forEach(t=>t()),this.timeouts=[],this.canvasWrapper.innerHTML="",this.progressWrapper.innerHTML="",null!=this.options.width&&(this.scrollContainer.style.width="number"==typeof this.options.width?`${this.options.width}px`:this.options.width);let e=window.devicePixelRatio||1,i=this.scrollContainer.clientWidth,n=Math.ceil(t.duration*(this.options.minPxPerSec||0));this.isScrollable=n>i;let s=this.options.fillParent&&!this.isScrollable,r=(s?i:n)*e;this.wrapper.style.width=s?"100%":`${n}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");try{if(this.options.splitChannels)yield Promise.all(Array.from({length:t.numberOfChannels}).map((e,i)=>{var n;let s=Object.assign(Object.assign({},this.options),null===(n=this.options.splitChannels)||void 0===n?void 0:n[i]);return this.renderChannel([t.getChannelData(i)],s,r)}));else{let e=[t.getChannelData(0)];t.numberOfChannels>1&&e.push(t.getChannelData(1)),yield this.renderChannel(e,this.options,r)}}catch(t){return}this.emit("rendered")})}
73reRender(){if(!this.audioData)return;let{scrollWidth:t}=this.scrollContainer,{right:e}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),this.isScrollable&&t!==this.scrollContainer.scrollWidth){let{right:t}=this.progressWrapper.getBoundingClientRect(),i=t-e;i*=2,i=(i<0?Math.floor(i):Math.ceil(i))/2,this.scrollContainer.scrollLeft+=i}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,e=!1){let{scrollLeft:i,scrollWidth:n,clientWidth:s}=this.scrollContainer,r=t*n,o=i+s,a=s/2;if(this.isDragging)r+30>o?this.scrollContainer.scrollLeft+=30:r-30<i&&(this.scrollContainer.scrollLeft-=30);else{(r<i||r>o)&&(this.scrollContainer.scrollLeft=r-(this.options.autoCenter?a:0));let t=r-i-a;e&&this.options.autoCenter&&t>0&&(this.scrollContainer.scrollLeft+=Math.min(t,10))}{let t=this.scrollContainer.scrollLeft;this.emit("scroll",t/n,(t+s)/n)}}renderProgress(t,e){if(isNaN(t))return;let i=100*t;this.canvasWrapper.style.clipPath=`polygon(${i}% 0, 100% 0, 100% 100%, ${i}% 100%)`,this.progressWrapper.style.width=`${i}%`,this.cursor.style.left=`${i}%`,this.cursor.style.transform=`translateX(-${100===Math.round(i)?this.options.cursorWidth:0}px)`,this.isScrollable&&this.options.autoScroll&&this.scrollIntoView(t,e)}exportImage(t,e,i){return n(this,void 0,void 0,function*(){let n=this.canvasWrapper.querySelectorAll("canvas");if(!n.length)throw Error("No waveform data");return"dataURL"===i?Promise.resolve(Array.from(n).map(i=>i.toDataURL(t,e))):Promise.all(Array.from(n).map(i=>new Promise((n,s)=>{i.toBlob(t=>{t?n(t):s(Error("Could not export image"))},t,e)})))})}}d.MAX_CANVAS_WIDTH=4e3;class u extends s{constructor(){super(...arguments),this.unsubscribe=()=>{}}start(){this.unsubscribe=this.on("tick",()=>{requestAnimationFrame(()=>{this.emit("tick")})}),this.emit("tick")}stop(){this.unsubscribe()}destroy(){this.unsubscribe()}}class c extends s{constructor(t=new AudioContext){super(),this.bufferNode=null,this.autoplay=!1,this.playStartTime=0,this.playedDuration=0,this._muted=!1,this._playbackRate=1,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.seeking=!1,this.addEventListener=this.on,this.removeEventListener=this.un,this.audioContext=t,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return n(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(t){if(this.currentSrc=t,!t)return this.buffer=null,void this.emit("emptied");fetch(t).then(e=>{if(e.status>=400)throw Error(`Failed to fetch ${t}: ${e.status} (${e.statusText})`);return e.arrayBuffer()}).then(e=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(e)).then(e=>{this.currentSrc===t&&(this.buffer=e,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())})}_play(){var t;if(!this.paused)return;this.paused=!1,null===(t=this.bufferNode)||void 0===t||t.disconnect(),this.bufferNode=this.audioContext.createBufferSource(),this.bufferNode.buffer=this.buffer,this.bufferNode.playbackRate.value=this._playbackRate,this.bufferNode.connect(this.gainNode);let e=this.playedDuration*this._playbackRate;e>=this.duration&&(e=0,this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,e),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{this.currentTime>=this.duration&&(this.pause(),this.emit("ended"))}}_pause(){var t;this.paused=!0,null===(t=this.bufferNode)||void 0===t||t.stop(),this.playedDuration+=this.audioContext.currentTime-this.playStartTime}play(){return n(this,void 0,void 0,function*(){this.paused&&(this._play(),this.emit("play"))})}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){var e,i;let n=t-this.currentTime;null===(e=this.bufferNode)||void 0===e||e.stop(this.audioContext.currentTime+n),null===(i=this.bufferNode)||void 0===i||i.addEventListener("ended",()=>{this.bufferNode=null,this.pause()},{once:!0})}setSinkId(t){return n(this,void 0,void 0,function*(){return this.audioContext.setSinkId(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return(this.paused?this.playedDuration:this.playedDuration+(this.audioContext.currentTime-this.playStartTime))*this._playbackRate}
73set currentTime(t){this.emit("seeking");let e=!this.paused;e&&this._pause(),this.playedDuration=t/this._playbackRate,e&&this._play(),this.emit("timeupdate")}get duration(){var t;return(null===(t=this.buffer)||void 0===t?void 0:t.duration)||0}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(){let t=[];if(!this.buffer)return t;let e=this.buffer.numberOfChannels;for(let i=0;i<e;i++)t.push(this.buffer.getChannelData(i));return t}}let p={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class m extends h{static create(t){return new m(t)}constructor(t){let e=t.media||("WebAudio"===t.backend?new c:void 0);super({media:e,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate}),this.plugins=[],this.decodedData=null,this.subscriptions=[],this.mediaSubscriptions=[],this.options=Object.assign({},p,t),this.timer=new u;let i=e?void 0:this.getMediaElement();this.renderer=new d(this.options,i),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initPlugins(),Promise.resolve().then(()=>{this.emit("init");let t=this.options.url||this.getSrc()||"";(t||this.options.peaks&&this.options.duration)&&this.load(t,this.options.peaks,this.options.duration)})}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()){let t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t)}}))}initPlayerEvents(){this.isPlaying()&&(this.emit("play"),this.timer.start()),this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",()=>{let 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.onMediaEvent("emptied",()=>{this.timer.stop()}),this.onMediaEvent("ended",()=>{this.emit("finish")}),this.onMediaEvent("seeking",()=>{this.emit("seeking",this.getCurrentTime())}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(t,e)=>{this.options.interact&&(this.seekTo(t),this.emit("interaction",t*this.getDuration()),this.emit("click",t,e))}),this.renderer.on("dblclick",(t,e)=>{this.emit("dblclick",t,e)}),this.renderer.on("scroll",(t,e)=>{let i=this.getDuration();this.emit("scroll",t*i,e*i)}),this.renderer.on("render",()=>{this.emit("redraw")}),this.renderer.on("rendered",()=>{this.emit("redrawcomplete")}
73));{let t;this.subscriptions.push(this.renderer.on("drag",e=>{this.options.interact&&(this.renderer.renderProgress(e),clearTimeout(t),t=setTimeout(()=>{this.seekTo(e)},this.isPlaying()?0:200),this.emit("interaction",e*this.getDuration()),this.emit("drag",e))}))}}initPlugins(){var t;(null===(t=this.options.plugins)||void 0===t?void 0:t.length)&&this.options.plugins.forEach(t=>{this.registerPlugin(t)})}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach(t=>t()),this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),null!=t.mediaControls&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){return t._init(this),this.plugins.push(t),this.subscriptions.push(t.once("destroy",()=>{this.plugins=this.plugins.filter(e=>e!==t)})),t}getWrapper(){return this.renderer.getWrapper()}getScroll(){return this.renderer.getScroll()}getActivePlugins(){return this.plugins}loadAudio(t,e,i,s){return n(this,void 0,void 0,function*(){this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,e||i||(e=yield l.fetchBlob(t,t=>this.emit("loading",t),this.options.fetchParams)),this.setSrc(t,e);let n=s||this.getDuration()||(yield new Promise(t=>{this.onceMediaEvent("loadedmetadata",()=>t(this.getDuration()))}));if(i)this.decodedData=r.createBuffer(i,n||0);else if(e){let t=yield e.arrayBuffer();this.decodedData=yield r.decode(t,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())})}load(t,e,i){return n(this,void 0,void 0,function*(){yield this.loadAudio(t,void 0,e,i)})}loadBlob(t,e,i){return n(this,void 0,void 0,function*(){yield this.loadAudio("blob",t,e,i)})}zoom(t){if(!this.decodedData)throw Error("No audio loaded");this.renderer.zoom(t),this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:e=8e3,precision:i=1e4}={}){if(!this.decodedData)throw Error("The audio has not been decoded yet");let n=Math.min(t,this.decodedData.numberOfChannels),s=[];for(let t=0;t<n;t++){let n=this.decodedData.getChannelData(t),r=[],o=Math.round(n.length/e);for(let t=0;t<e;t++){let e=n.slice(t*o,(t+1)*o),s=0;for(let t=0;t<e.length;t++){let i=e[t];Math.abs(i)>Math.abs(s)&&(s=i)}r.push(Math.round(s*i)/i)}s.push(r)}return s}getDuration(){let t=super.getDuration()||0;return(0===t||t===1/0)&&this.decodedData&&(t=this.decodedData.duration),t}toggleInteraction(t){this.options.interact=t}setTime(t){super.setTime(t),this.updateProgress(t)}seekTo(t){let e=this.getDuration()*t;this.setTime(e)}playPause(){return n(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(t="image/png",e=1,i="dataURL"){return n(this,void 0,void 0,function*(){return this.renderer.exportImage(t,e,i)})}destroy(){this.emit("destroy"),this.plugins.forEach(t=>t.destroy()),this.subscriptions.forEach(t=>t()),this.unsubscribePlayerEvents(),this.timer.destroy(),this.renderer.destroy(),super.destroy()}}m.BasePlugin=class extends s{constructor(t){super(),this.subscriptions=[],this.options=t}onInit(){}_init(t){this.wavesurfer=t,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(t=>t())}},m.dom=a}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.