ai12z 3.13.3 → 3.14.2
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/cjs/ai12z-bot.cjs.entry.js +107 -19
- package/dist/cjs/ai12z-chat-message.cjs.entry.js +17 -46
- package/dist/cjs/ai12z-knowledge-box.cjs.entry.js +14 -60
- package/dist/cjs/index.cjs.js +1 -0
- package/dist/cjs/styleSheetRegistry-7aecMygn.js +175 -0
- package/dist/collection/components/ai12z-bot/ai12z-bot.js +32 -13
- package/dist/collection/components/ai12z-knowledge-box/ai12z-knowledge-box.js +15 -61
- package/dist/collection/components/ai12z-knowledge-box/components/ai12z-chat-message.js +16 -46
- package/dist/collection/utils/liveagents/providers/salesforce.js +75 -6
- package/dist/collection/utils/styleSheetRegistry.js +169 -0
- package/dist/components/ai12z-bot.js +1 -1
- package/dist/components/ai12z-chat-message.js +1 -1
- package/dist/components/ai12z-chat.js +1 -1
- package/dist/components/ai12z-container.js +1 -1
- package/dist/components/ai12z-cta.js +1 -1
- package/dist/components/ai12z-form.js +1 -1
- package/dist/components/ai12z-inline-search.js +1 -1
- package/dist/components/ai12z-input-form.js +1 -1
- package/dist/components/ai12z-knowledge-box.js +1 -1
- package/dist/components/ai12z-search-panel.js +1 -1
- package/dist/components/audio-recorder.js +1 -1
- package/dist/components/dynamic-form.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/interaction-buttons.js +1 -1
- package/dist/components/item-list.js +1 -1
- package/dist/components/{p-DKxaam7U.js → p-3j2aDKYq.js} +1 -1
- package/dist/components/{p-BP8ig03d.js → p-AQ1MS6Ps.js} +1 -1
- package/dist/components/p-B9IJbo4G.js +1 -0
- package/dist/components/{p-DsZWeAcM.js → p-BWMhH2R1.js} +1 -1
- package/dist/components/{p-5UYwpNzl.js → p-BaXs0IIw.js} +1 -1
- package/dist/components/{p-Gr6Q2s96.js → p-Bnj1LjUJ.js} +1 -1
- package/dist/components/p-BwpiW24r.js +1 -0
- package/dist/components/{p-Bo3Ig8oX.js → p-BwqXbNCx.js} +1 -1
- package/dist/components/{p-D2nUK4Pa.js → p-COqFEHJ7.js} +1 -1
- package/dist/components/{p-DA32xa7d.js → p-Ci85xHWQ.js} +1 -1
- package/dist/components/{p-DUaZgAhA.js → p-CrfXJRIo.js} +1 -1
- package/dist/components/{p-DJ68HDol.js → p-DkRAkHLI.js} +2 -2
- package/dist/components/{p-ha1wIlZ-.js → p-Dubjoiw6.js} +1 -1
- package/dist/components/{p-C2wKkcYa.js → p-DvtUY5FW.js} +1 -1
- package/dist/components/{p-J--erGbY.js → p-dQEvevXk.js} +1 -1
- package/dist/{library/p-DAGa-uHD.js → components/p-g36mIk7k.js} +1 -1
- package/dist/components/p-m0Ed3g6I.js +1 -0
- package/dist/components/p-mBjDeFh_.js +1 -0
- package/dist/components/{p-q7YWDP9B.js → p-pOVc-eI8.js} +1 -1
- package/dist/components/{p-BCJzelr9.js → p-qwKoi5kn.js} +1 -1
- package/dist/components/{p-CKAp10SJ.js → p-xTOLReQF.js} +1 -1
- package/dist/components/privacy-modal.js +1 -1
- package/dist/components/search-results-page.js +1 -1
- package/dist/esm/ai12z-bot.entry.js +115 -27
- package/dist/esm/ai12z-category_2.entry.js +3 -3
- package/dist/esm/ai12z-chat-message.entry.js +17 -46
- package/dist/esm/ai12z-chat_2.entry.js +8 -8
- package/dist/esm/ai12z-container.entry.js +3 -3
- package/dist/esm/ai12z-cta.entry.js +4 -4
- package/dist/esm/ai12z-form.entry.js +2 -2
- package/dist/esm/ai12z-inline-search.entry.js +2 -2
- package/dist/esm/ai12z-knowledge-box.entry.js +18 -64
- package/dist/esm/ai12z-search-panel.entry.js +1 -1
- package/dist/esm/chat-avatar_6.entry.js +1 -1
- package/dist/esm/{ctaHelpers-BhM8KbEY.js → ctaHelpers-DrH6S5iU.js} +1 -1
- package/dist/esm/dynamic-form.entry.js +1 -1
- package/dist/esm/{index-BQKLwW-C.js → index-VWr-8RG8.js} +1 -1
- package/dist/esm/index.js +10 -9
- package/dist/esm/item-list.entry.js +2 -2
- package/dist/esm/{keyboard-shortcuts-Bd3LDe9j.js → keyboard-shortcuts-BhKv64FZ.js} +2 -2
- package/dist/esm/{parseHelper-9rP0JS7J.js → parseHelper-kOGOndOe.js} +1 -1
- package/dist/esm/{processCarouselData-Bf2pDFsV.js → processCarouselData-DX152a4X.js} +1 -1
- package/dist/esm/{reCaptchaHelpers-CUcgfdqX.js → reCaptchaHelpers-DUpCzUFb.js} +1 -1
- package/dist/esm/search-results-page.entry.js +4 -4
- package/dist/esm/{socket-service-B1OMbkCM.js → socket-service-D_h5x8Gr.js} +1 -1
- package/dist/esm/styleSheetRegistry-Bfi9VkqK.js +172 -0
- package/dist/esm/{surveyHelpers-CvrZlir1.js → surveyHelpers-D-00eWjv.js} +1 -1
- package/dist/esm/{utils-BTLjNTwP.js → utils-DK_Yhmpx.js} +1 -1
- package/dist/library/index.esm.js +1 -1
- package/dist/library/library.esm.js +1 -1
- package/dist/library/{p-cd764f70.entry.js → p-11c1f91d.entry.js} +1 -1
- package/dist/library/{p-806bfb3d.entry.js → p-1d382046.entry.js} +1 -1
- package/dist/library/{p-0641ba91.entry.js → p-252bb713.entry.js} +2 -2
- package/dist/library/p-25a678ca.entry.js +1 -0
- package/dist/library/p-53edf210.entry.js +1 -0
- package/dist/library/p-646a7eae.entry.js +1 -0
- package/dist/library/p-675d0243.entry.js +1 -0
- package/dist/library/{p-60d5d99f.entry.js → p-6ea05db1.entry.js} +1 -1
- package/dist/library/{p-7f0e306c.entry.js → p-7154a204.entry.js} +1 -1
- package/dist/library/{p-07f11cb8.entry.js → p-72a5eaf2.entry.js} +1 -1
- package/dist/library/{p-2d262192.entry.js → p-8f238b3f.entry.js} +1 -1
- package/dist/library/p-9cffb6fa.entry.js +1 -0
- package/dist/library/{p-y3Go1NSi.js → p-BCkDiHIY.js} +1 -1
- package/dist/{components/p-BhV62IFF.js → library/p-By1gJKXA.js} +1 -1
- package/dist/library/{p-Bbow4UZX.js → p-C0wNDqKO.js} +1 -1
- package/dist/library/p-C3yxqbFh.js +1 -0
- package/dist/library/p-CwZwG6gL.js +1 -0
- package/dist/library/{p-D5m1leH0.js → p-D1IPrgJe.js} +3 -3
- package/dist/library/{p-NAKC5NP9.js → p-KSKiM1sy.js} +1 -1
- package/dist/library/{p-C1eU4fpM.js → p-TJuczvVq.js} +1 -1
- package/dist/library/{p-CnadO0kA.js → p-ZyOWOLs5.js} +1 -1
- package/dist/library/{p-94bf0c7f.entry.js → p-cbfc9f73.entry.js} +1 -1
- package/dist/library/{p-014d5664.entry.js → p-d8506e43.entry.js} +1 -1
- package/dist/library/{p-BZ_koFpE.js → p-n8ydBHE4.js} +1 -1
- package/dist/types/components/ai12z-bot/ai12z-bot.d.ts +1 -0
- package/dist/types/components/ai12z-knowledge-box/ai12z-knowledge-box.d.ts +0 -3
- package/dist/types/components/ai12z-knowledge-box/components/ai12z-chat-message.d.ts +0 -2
- package/dist/types/utils/liveagents/providers/salesforce.d.ts +2 -0
- package/dist/types/utils/styleSheetRegistry.d.ts +40 -0
- package/package.json +2 -2
- package/dist/components/p-B3lv_O-6.js +0 -1
- package/dist/components/p-CLdlCTTp.js +0 -1
- package/dist/components/p-DT0Uarfg.js +0 -1
- package/dist/components/p-zVXADzTq.js +0 -1
- package/dist/library/p-29cd4edc.entry.js +0 -1
- package/dist/library/p-6f3727d3.entry.js +0 -1
- package/dist/library/p-83a71da9.entry.js +0 -1
- package/dist/library/p-DoBD_KPG.js +0 -1
- package/dist/library/p-d3a2acee.entry.js +0 -1
- package/dist/library/p-dc131a5c.entry.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as t,t as e,p as n,H as r,d as i,h as s}from"./p-ZGVz1_9H.js";import{L as o,d as a,M as c}from"./p-DUaZgAhA.js";import{q as h,t as l}from"./p-BCJzelr9.js";const u=(()=>{let t;return(...e)=>{t&&clearTimeout(t),t=setTimeout((()=>{t=0,(t=>{for(let e of t.keys()){const n=t.get(e).filter((t=>{const e=t.deref();return e&&(!("isConnected"in(n=e))||n.isConnected);var n}));t.set(e,n)}})(...e)}),2e3)}})(),d=t.forceUpdate,f=t.getRenderingRef,p=(t,e)=>{const n=t.indexOf(e);n>=0&&(t[n]=t[t.length-1],t.length--)},v="prod",w=t=>{const e=(t||"").toLowerCase();return e.includes("bot")?"bot":e.includes("cta")?"cta":e.includes("search")?"search":"unknown"},m=(()=>{const t=((t,e=(t,e)=>t!==e)=>{const n=()=>{return("function"==typeof(e=t)?e():e)??{};var e},r=n();let i=new Map(Object.entries(r));const s="undefined"!=typeof Proxy,o=s?null:{},a={dispose:[],get:[],set:[],reset:[]},c=new Map,h=()=>{i=new Map(Object.entries(n())),s||w(),a.reset.forEach((t=>t()))},l=t=>(a.get.forEach((e=>e(t))),i.get(t)),u=(t,n)=>{const r=i.get(t);e(n,r,t)&&(i.set(t,n),s||v(t),a.set.forEach((e=>e(t,n,r))))},d=s?new Proxy(r,{get:(t,e)=>l(e),ownKeys:()=>Array.from(i.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(t,e)=>i.has(e),set:(t,e,n)=>(u(e,n),!0)}):(w(),o),f=(t,e)=>(a[t].push(e),()=>{p(a[t],e)});function v(t){!s&&o&&(Object.prototype.hasOwnProperty.call(o,t)||Object.defineProperty(o,t,{configurable:!0,enumerable:!0,get:()=>l(t),set(e){u(t,e)}}))}function w(){if(s||!o)return;const t=new Set(i.keys());for(const e of Object.keys(o))t.has(e)||delete o[e];for(const e of t)v(e)}return{state:d,get:l,set:u,on:f,onChange:(t,e)=>{const r=(n,r)=>{n===t&&e(r)},i=()=>{const r=n();e(r[t])},s=f("set",r),o=f("reset",i);return c.set(e,{setHandler:r,resetHandler:i,propName:t}),()=>{s(),o(),c.delete(e)}},use:(...t)=>{const e=t.reduce(((t,e)=>(e.set&&t.push(f("set",e.set)),e.get&&t.push(f("get",e.get)),e.reset&&t.push(f("reset",e.reset)),e.dispose&&t.push(f("dispose",e.dispose)),t)),[]);return()=>e.forEach((t=>t()))},dispose:()=>{a.dispose.forEach((t=>t())),h()},reset:h,forceUpdate:t=>{const e=i.get(t);a.set.forEach((n=>n(t,e,e)))},removeListener:(t,e)=>{const n=c.get(e);n&&n.propName===t&&(p(a.set,n.setHandler),p(a.reset,n.resetHandler),c.delete(e))}}})({dataKey:"",dataMode:"prod",activeParentScope:"unknown",parentContexts:{bot:{dataKey:"",dataMode:v},cta:{dataKey:"",dataMode:v},search:{dataKey:"",dataMode:v},unknown:{dataKey:"",dataMode:v}}},void 0);return t.use((()=>{if("function"!=typeof f||"function"!=typeof d)return{};const t=d,e=f,n=new Map;return{dispose:()=>n.clear(),get:t=>{const r=e();r&&((t,e,n)=>{let r=t.get(e);r||(r=[],t.set(e,r)),r.some((t=>t.deref()===n))||r.push(new WeakRef(n))})(n,t,r)},set:e=>{const r=n.get(e);if(r){const i=r.filter((e=>{const n=e.deref();return!!n&&t(n)}));n.set(e,i)}u(n)},reset:()=>{n.forEach((e=>{e.forEach((e=>{const n=e.deref();n&&t(n)}))})),u(n)}}})()),t})(),y=(t,e,n)=>{const r=w(t),i={dataKey:e||"",dataMode:n||v};m.state.parentContexts=Object.assign(Object.assign({},m.state.parentContexts),{[r]:i}),m.state.dataKey=i.dataKey,m.state.dataMode=i.dataMode};function g(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function a(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;let b=class{constructor(){this.listeners={}}on(t,e,n){if(this.listeners[t]||(this.listeners[t]=new Set),null==n?void 0:n.once){const n=(...r)=>{this.un(t,n),e(...r)};return this.listeners[t].add(n),()=>this.un(t,n)}return this.listeners[t].add(e),()=>this.un(t,e)}un(t,e){var n;null===(n=this.listeners[t])||void 0===n||n.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)))}};const M={decode:function(t,e){return g(this,void 0,void 0,(function*(){const n=new AudioContext({sampleRate:e});try{return yield n.decodeAudioData(t)}finally{n.close()}}))},createBuffer:function(t,e){if(!t||0===t.length)throw new Error("channelData must be a non-empty array");if(e<=0)throw new Error("duration must be greater than 0");if("number"==typeof t[0]&&(t=[t]),!t[0]||0===t[0].length)throw new Error("channelData must contain non-empty channel arrays");!function(t){const e=t[0];if(e.some((t=>t>1||t<-1))){const n=e.length;let r=0;for(let t=0;t<n;t++){const n=Math.abs(e[t]);n>r&&(r=n)}for(const e of t)for(let t=0;t<n;t++)e[t]/=r}}(t);const n=t.map((t=>t instanceof Float32Array?t:Float32Array.from(t)));return{duration:e,length:n[0].length,sampleRate:n[0].length/e,numberOfChannels:n.length,getChannelData:t=>{const e=n[t];if(!e)throw new Error(`Channel ${t} not found`);return e},copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function k(t,e){const n=e.xmlns?document.createElementNS(e.xmlns,t):document.createElement(t);for(const[t,r]of Object.entries(e))if("children"===t&&r)for(const[t,e]of Object.entries(r))e instanceof Node?n.appendChild(e):n.appendChild("string"==typeof e?document.createTextNode(e):k(t,e));else"style"===t?Object.assign(n.style,r):"textContent"===t?n.textContent=r:n.setAttribute(t,r.toString());return n}function x(t,e,n){const r=k(t,e||{});return null==n||n.appendChild(r),r}var E=Object.freeze({__proto__:null,createElement:x,default:x});const C={fetchBlob:function(t,e,n){return g(this,void 0,void 0,(function*(){const r=yield fetch(t,n);if(r.status>=400)throw new Error(`Failed to fetch ${t}: ${r.status} (${r.statusText})`);return function(t,e){g(this,void 0,void 0,(function*(){if(!t.body||!t.headers)return;const n=t.body.getReader(),r=Number(t.headers.get("Content-Length"))||0;let i=0;const s=t=>{i+=(null==t?void 0:t.length)||0;const n=Math.round(i/r*100);e(n)};try{for(;;){const t=yield n.read();if(t.done)break;s(t.value)}}catch(n){console.warn("Progress tracking error:",n)}}))}(r.clone(),e),r.blob()}))}};function A(t){let e=t;const n=new Set;return{get value(){return e},set(t){Object.is(e,t)||(e=t,n.forEach((t=>t(e))))},update(t){this.set(t(e))},subscribe:t=>(n.add(t),()=>n.delete(t))}}function S(t,e){const n=A(t());return e.forEach((e=>e.subscribe((()=>{const e=t();Object.is(n.value,e)||n.set(e)})))),{get value(){return n.value},subscribe:t=>n.subscribe(t)}}function I(t,e){let n;const r=()=>{n&&(n(),n=void 0),n=t()},i=e.map((t=>t.subscribe(r)));return r(),()=>{n&&(n(),n=void 0),i.forEach((t=>t()))}}class T extends b{get isPlayingSignal(){return this._isPlaying}get currentTimeSignal(){return this._currentTime}get durationSignal(){return this._duration}get volumeSignal(){return this._volume}get mutedSignal(){return this._muted}get playbackRateSignal(){return this._playbackRate}get seekingSignal(){return this._seeking}constructor(t){super(),this.isExternalMedia=!1,this.reactiveMediaEventCleanups=[],t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),this._isPlaying=A(!1),this._currentTime=A(0),this._duration=A(0),this._volume=A(this.media.volume),this._muted=A(this.media.muted),this._playbackRate=A(this.media.playbackRate||1),this._seeking=A(!1),this.setupReactiveMediaEvents(),t.mediaControls&&(this.media.controls=!0),t.autoplay&&(this.media.autoplay=!0),null!=t.playbackRate&&this.onMediaEvent("canplay",(()=>{null!=t.playbackRate&&(this.media.playbackRate=t.playbackRate)}),{once:!0})}setupReactiveMediaEvents(){this.reactiveMediaEventCleanups.push(this.onMediaEvent("play",(()=>{this._isPlaying.set(!0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("pause",(()=>{this._isPlaying.set(!1)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("ended",(()=>{this._isPlaying.set(!1)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("timeupdate",(()=>{this._currentTime.set(this.media.currentTime)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("durationchange",(()=>{this._duration.set(this.media.duration||0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("loadedmetadata",(()=>{this._duration.set(this.media.duration||0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeking",(()=>{this._seeking.set(!0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeked",(()=>{this._seeking.set(!1)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("volumechange",(()=>{this._volume.set(this.media.volume),this._muted.set(this.media.muted)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("ratechange",(()=>{this._playbackRate.set(this.media.playbackRate)})))}onMediaEvent(t,e,n){return this.media.addEventListener(t,e,n),()=>this.media.removeEventListener(t,e,n)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const t=this.getSrc();t.startsWith("blob:")&&URL.revokeObjectURL(t)}canPlayType(t){return""!==this.media.canPlayType(t)}setSrc(t,e){const n=this.getSrc();if(t&&n===t)return;this.revokeSrc();const r=e instanceof Blob&&(this.canPlayType(e.type)||!t)?URL.createObjectURL(e):t;if(n&&this.media.removeAttribute("src"),r||t)try{this.media.src=r}catch(e){this.media.src=t}}destroy(){this.reactiveMediaEventCleanups.forEach((t=>t())),this.reactiveMediaEventCleanups=[],this.isExternalMedia||(this.media.pause(),this.revokeSrc(),this.media.removeAttribute("src"),this.media.load(),this.media.remove())}setMediaElement(t){this.reactiveMediaEventCleanups.forEach((t=>t())),this.reactiveMediaEventCleanups=[],this.media=t,this.setupReactiveMediaEvents()}play(){return g(this,void 0,void 0,(function*(){try{return yield this.media.play()}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)return;throw t}}))}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=Math.max(0,Math.min(t,this.getDuration()))}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)}}function R({maxTop:t,maxBottom:e,halfHeight:n,vScale:r,barMinHeight:i=0,barAlign:s}){let o=Math.round(t*n*r),a=o+Math.round(e*n*r)||1;return a<i&&(a=i,s||(o=a/2)),{topHeight:o,totalHeight:a}}function O({barAlign:t,halfHeight:e,topHeight:n,totalHeight:r,canvasHeight:i}){return"top"===t?0:"bottom"===t?i-r:e-n}function P(t,e,n){return[(e-t.left)/t.width,(n-t.top)/t.height]}function W(t){return Boolean(t.barWidth||t.barGap||t.barAlign)}function j(t,e){if(!W(e))return t;const n=e.barWidth||.5,r=n+(e.barGap||n/2);return 0===r?t:Math.floor(t/r)*r}function _({scrollLeft:t,totalWidth:e,numCanvases:n}){if(0===e)return[0];const r=Math.floor(t/e*n);return[r-1,r,r+1]}function U(t){const e=t._cleanup;"function"==typeof e&&e()}class N extends b{constructor(t,e){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.subscriptions=[],this.unsubscribeOnScroll=[],this.dragStream=null,this.scrollStream=null,this.subscriptions=[],this.options=t;const n=this.parentFromOptionsContainer(t.container);this.parent=n;const[r,i]=this.initHtml();n.appendChild(r),this.container=r,this.scrollContainer=i.querySelector(".scroll"),this.wrapper=i.querySelector(".wrapper"),this.canvasWrapper=i.querySelector(".canvases"),this.progressWrapper=i.querySelector(".progress"),this.cursor=i.querySelector(".cursor"),e&&i.appendChild(e),this.initEvents()}parentFromOptionsContainer(t){let e;if("string"==typeof t?e=document.querySelector(t):t instanceof HTMLElement&&(e=t),!e)throw new Error("Container not found");return e}initEvents(){this.wrapper.addEventListener("click",(t=>{const e=this.wrapper.getBoundingClientRect(),[n,r]=P(e,t.clientX,t.clientY);this.emit("click",n,r)})),this.wrapper.addEventListener("dblclick",(t=>{const e=this.wrapper.getBoundingClientRect(),[n,r]=P(e,t.clientX,t.clientY);this.emit("dblclick",n,r)})),!0!==this.options.dragToSeek&&"object"!=typeof this.options.dragToSeek||this.initDrag(),this.scrollStream=function(t){const e=A({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth}),n=S((()=>function(t){const{scrollLeft:e,scrollWidth:n,clientWidth:r}=t;if(0===n)return{startX:0,endX:1};const i=(e+r)/n;return{startX:Math.max(0,Math.min(1,e/n)),endX:Math.max(0,Math.min(1,i))}}(e.value)),[e]),r=S((()=>function(t){return{left:t.scrollLeft,right:t.scrollLeft+t.clientWidth}}(e.value)),[e]),i=()=>{e.set({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth})};return t.addEventListener("scroll",i,{passive:!0}),{scrollData:e,percentages:n,bounds:r,cleanup:()=>{t.removeEventListener("scroll",i),U(e)}}}(this.scrollContainer);const t=I((()=>{const{startX:t,endX:e}=this.scrollStream.percentages.value,{left:n,right:r}=this.scrollStream.bounds.value;this.emit("scroll",t,e,n,r)}),[this.scrollStream.percentages,this.scrollStream.bounds]);if(this.subscriptions.push(t),"function"==typeof ResizeObserver){const t=this.createDelay(100);this.resizeObserver=new ResizeObserver((()=>{t().then((()=>this.onContainerResize())).catch((()=>{}))})),this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const t=this.parent.clientWidth;t===this.lastContainerWidth&&"auto"!==this.options.height||(this.lastContainerWidth=t,this.reRender(),this.emit("resize"))}initDrag(){if(this.dragStream)return;this.dragStream=function(t,e={}){const{threshold:n=3,mouseButton:r=0,touchDelay:i=100}=e,s=A(null),o=new Map,a=matchMedia("(pointer: coarse)").matches;let c=()=>{};const h=e=>{if(e.button!==r)return;if(o.set(e.pointerId,e),o.size>1)return;let h=e.clientX,l=e.clientY,u=!1;const d=Date.now(),f=t.getBoundingClientRect(),{left:p,top:v}=f,w=t=>{if(t.defaultPrevented||o.size>1)return;if(a&&Date.now()-d<i)return;const e=t.clientX,r=t.clientY,c=e-h,f=r-l;(u||Math.abs(c)>n||Math.abs(f)>n)&&(t.preventDefault(),t.stopPropagation(),u||(s.set({type:"start",x:h-p,y:l-v}),u=!0),s.set({type:"move",x:e-p,y:r-v,deltaX:c,deltaY:f}),h=e,l=r)},m=t=>{o.delete(t.pointerId),u&&s.set({type:"end",x:t.clientX-p,y:t.clientY-v}),c()},y=t=>{o.delete(t.pointerId),t.relatedTarget&&t.relatedTarget!==document.documentElement||m(t)},g=t=>{u&&(t.stopPropagation(),t.preventDefault())},b=t=>{t.defaultPrevented||o.size>1||u&&t.preventDefault()};document.addEventListener("pointermove",w),document.addEventListener("pointerup",m),document.addEventListener("pointerout",y),document.addEventListener("pointercancel",y),document.addEventListener("touchmove",b,{passive:!1}),document.addEventListener("click",g,{capture:!0}),c=()=>{document.removeEventListener("pointermove",w),document.removeEventListener("pointerup",m),document.removeEventListener("pointerout",y),document.removeEventListener("pointercancel",y),document.removeEventListener("touchmove",b),setTimeout((()=>{document.removeEventListener("click",g,{capture:!0})}),10)}};return t.addEventListener("pointerdown",h),{signal:s,cleanup:()=>{c(),t.removeEventListener("pointerdown",h),o.clear(),U(s)}}}(this.wrapper);const t=I((()=>{const t=this.dragStream.signal.value;if(!t)return;const e=this.wrapper.getBoundingClientRect().width,n=(r=t.x/e)<0?0:r>1?1:r;var r;"start"===t.type?(this.isDragging=!0,this.emit("dragstart",n)):"move"===t.type?this.emit("drag",n):"end"===t.type&&(this.isDragging=!1,this.emit("dragend",n))}),[this.dragStream.signal]);this.subscriptions.push(t)}initHtml(){const t=document.createElement("div"),e=t.attachShadow({mode:"open"}),n=this.options.cspNonce&&"string"==typeof this.options.cspNonce?this.options.cspNonce.replace(/"/g,""):"";return e.innerHTML=`\n <style${n?` nonce="${n}"`:""}>\n :host {\n user-select: none;\n min-width: 1px;\n }\n :host audio {\n display: block;\n width: 100%;\n }\n :host .scroll {\n overflow-x: auto;\n overflow-y: hidden;\n width: 100%;\n position: relative;\n }\n :host .noScrollbar {\n scrollbar-color: transparent;\n scrollbar-width: none;\n }\n :host .noScrollbar::-webkit-scrollbar {\n display: none;\n -webkit-appearance: none;\n }\n :host .wrapper {\n position: relative;\n overflow: visible;\n z-index: 2;\n }\n :host .canvases {\n min-height: ${this.getHeight(this.options.height,this.options.splitChannels)}px;\n pointer-events: none;\n }\n :host .canvases > div {\n position: relative;\n }\n :host canvas {\n display: block;\n position: absolute;\n top: 0;\n image-rendering: pixelated;\n }\n :host .progress {\n pointer-events: none;\n position: absolute;\n z-index: 2;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n overflow: hidden;\n }\n :host .progress > div {\n position: relative;\n }\n :host .cursor {\n pointer-events: none;\n position: absolute;\n z-index: 5;\n top: 0;\n left: 0;\n height: 100%;\n border-radius: 2px;\n }\n </style>\n\n <div class="scroll" part="scroll">\n <div class="wrapper" part="wrapper">\n <div class="canvases" part="canvases"></div>\n <div class="progress" part="progress"></div>\n <div class="cursor" part="cursor"></div>\n </div>\n </div>\n `,[t,e]}setOptions(t){if(this.options.container!==t.container){const e=this.parentFromOptionsContainer(t.container);e.appendChild(this.container),this.parent=e}!0!==t.dragToSeek&&"object"!=typeof this.options.dragToSeek||this.initDrag(),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:e}=this.scrollContainer;this.setScroll(e*t)}destroy(){var t;this.subscriptions.forEach((t=>t())),this.container.remove(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),null===(t=this.unsubscribeOnScroll)||void 0===t||t.forEach((t=>t())),this.unsubscribeOnScroll=[],this.dragStream&&(this.dragStream.cleanup(),this.dragStream=null),this.scrollStream&&(this.scrollStream.cleanup(),this.scrollStream=null)}createDelay(t=10){let e,n;const r=()=>{e&&(clearTimeout(e),e=void 0),n&&(n(),n=void 0)};return this.timeouts.push(r),()=>new Promise(((i,s)=>{r(),n=s,e=setTimeout((()=>{e=void 0,n=void 0,i()}),t)}))}getHeight(t,e){var n;const r=(null===(n=this.audioData)||void 0===n?void 0:n.numberOfChannels)||1;return function({optionsHeight:t,optionsSplitChannels:e,parentHeight:n,numberOfChannels:r,defaultHeight:i=128}){if(null==t)return i;const s=Number(t);if(!isNaN(s))return s;if("auto"===t){const t=n||i;return(null==e?void 0:e.every((t=>!t.overlay)))?t/r:t}return i}({optionsHeight:t,optionsSplitChannels:e,parentHeight:this.parent.clientHeight,numberOfChannels:r,defaultHeight:128})}convertColorValues(t,e){return function(t,e,n){if(!Array.isArray(t))return t||"";if(0===t.length)return"#999";if(t.length<2)return t[0]||"";const r=document.createElement("canvas"),i=r.getContext("2d").createLinearGradient(0,0,0,(null!=n?n:r.height*e)||e),s=1/(t.length-1);return t.forEach(((t,e)=>{i.addColorStop(e*s,t)})),i}(t,this.getPixelRatio(),null==e?void 0:e.canvas.height)}getPixelRatio(){return t=window.devicePixelRatio,Math.max(1,t||1);var t}renderBarWaveform(t,e,n,r){const{width:i,height:s}=n.canvas,{halfHeight:o,barWidth:a,barRadius:c,barIndexScale:h,barSpacing:l,barMinHeight:u}=function({width:t,height:e,length:n,options:r,pixelRatio:i}){const s=r.barWidth?r.barWidth*i:1,o=r.barGap?r.barGap*i:r.barWidth?s/2:0,a=s+o||1;return{halfHeight:e/2,barWidth:s,barGap:o,barRadius:r.barRadius||0,barMinHeight:r.barMinHeight?r.barMinHeight*i:0,barIndexScale:n>0?t/a/n:0,barSpacing:a}}({width:i,height:s,length:(t[0]||[]).length,options:e,pixelRatio:this.getPixelRatio()}),d=function({channelData:t,barIndexScale:e,barSpacing:n,barWidth:r,halfHeight:i,vScale:s,canvasHeight:o,barAlign:a,barMinHeight:c}){const h=t[0]||[],l=t[1]||h,u=h.length,d=[];let f=0,p=0,v=0;for(let t=0;t<=u;t++){const u=Math.round(t*e);if(u>f){const{topHeight:t,totalHeight:e}=R({maxTop:p,maxBottom:v,halfHeight:i,vScale:s,barMinHeight:c,barAlign:a}),h=O({barAlign:a,halfHeight:i,topHeight:t,totalHeight:e,canvasHeight:o});d.push({x:f*n,y:h,width:r,height:e}),f=u,p=0,v=0}const w=Math.abs(h[t]||0),m=Math.abs(l[t]||0);w>p&&(p=w),m>v&&(v=m)}return d}({channelData:t,barIndexScale:h,barSpacing:l,barWidth:a,halfHeight:o,vScale:r,canvasHeight:s,barAlign:e.barAlign,barMinHeight:u});n.beginPath();for(const t of d)c&&"roundRect"in n?n.roundRect(t.x,t.y,t.width,t.height,c):n.rect(t.x,t.y,t.width,t.height);n.fill(),n.closePath()}renderLineWaveform(t,e,n,r){const{width:i,height:s}=n.canvas,o=function({channelData:t,width:e,height:n,vScale:r}){const i=n/2,s=t[0]||[];return[s,t[1]||s].map(((t,n)=>{const s=t.length,o=s?e/s:0,a=i,c=0===n?-1:1,h=[{x:0,y:a}];let l=0,u=0;for(let e=0;e<=s;e++){const n=Math.round(e*o);if(n>l){const t=a+(Math.round(u*i*r)||1)*c;h.push({x:l,y:t}),l=n,u=0}const s=Math.abs(t[e]||0);s>u&&(u=s)}return h.push({x:l,y:a}),h}))}({channelData:t,width:i,height:s,vScale:r});n.beginPath();for(const t of o)if(t.length){n.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++){const r=t[e];n.lineTo(r.x,r.y)}}n.fill(),n.closePath()}renderWaveform(t,e,n){if(n.fillStyle=this.convertColorValues(e.waveColor,n),e.renderFunction)return void e.renderFunction(t,n);const r=function({channelData:t,barHeight:e,normalize:n,maxPeak:r}){var i;const s=e||1;if(!n)return s;const o=t[0];if(!o||0===o.length)return s;let a=null!=r?r:0;if(!r)for(let t=0;t<o.length;t++){const e=null!==(i=o[t])&&void 0!==i?i:0,n=Math.abs(e);n>a&&(a=n)}return a?s/a:s}({channelData:t,barHeight:e.barHeight,normalize:e.normalize,maxPeak:e.maxPeak});W(e)?this.renderBarWaveform(t,e,n,r):this.renderLineWaveform(t,e,n,r)}renderSingleCanvas(t,e,n,r,i,s,o){const a=this.getPixelRatio(),c=document.createElement("canvas");c.width=Math.round(n*a),c.height=Math.round(r*a),c.style.width=`${n}px`,c.style.height=`${r}px`,c.style.left=`${Math.round(i)}px`,s.appendChild(c);const h=c.getContext("2d");if(e.renderFunction?(h.fillStyle=this.convertColorValues(e.waveColor,h),e.renderFunction(t,h)):this.renderWaveform(t,e,h),c.width>0&&c.height>0){const t=c.cloneNode(),n=t.getContext("2d");n.drawImage(c,0,0),n.globalCompositeOperation="source-in",n.fillStyle=this.convertColorValues(e.progressColor,n),n.fillRect(0,0,c.width,c.height),o.appendChild(t)}}renderMultiCanvas(t,e,n,r,i,s){const o=this.getPixelRatio(),{clientWidth:a}=this.scrollContainer,c=n/o,h=function({clientWidth:t,totalWidth:e,options:n}){return j(Math.min(8e3,t,e),n)}({clientWidth:a,totalWidth:c,options:e});let l={};if(0===h)return;const u=n=>{if(n<0||n>=d)return;if(l[n])return;l[n]=!0;const o=n*h;let a=Math.min(c-o,h);if(a=j(a,e),a<=0)return;const u=function({channelData:t,offset:e,clampedWidth:n,totalWidth:r}){return t.map((t=>{const i=Math.floor(e/r*t.length),s=Math.floor((e+n)/r*t.length);return t.slice(i,s)}))}({channelData:t,offset:o,clampedWidth:a,totalWidth:c});this.renderSingleCanvas(u,e,a,r,o,i,s)},d=Math.ceil(c/h);if(this.isScrollable){if(_({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:c,numCanvases:d}).forEach((t=>u(t))),d>1){const t=this.on("scroll",(()=>{const{scrollLeft:t}=this.scrollContainer;Object.keys(l).length>10&&(i.innerHTML="",s.innerHTML="",l={}),_({scrollLeft:t,totalWidth:c,numCanvases:d}).forEach((t=>u(t)))}));this.unsubscribeOnScroll.push(t)}}else for(let t=0;t<d;t++)u(t)}renderChannel(t,e,n,r){var{overlay:i}=e,s=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(e,["overlay"]);const o=document.createElement("div"),a=this.getHeight(s.height,s.splitChannels);o.style.height=`${a}px`,i&&r>0&&(o.style.marginTop=`-${a}px`),this.canvasWrapper.style.minHeight=`${a}px`,this.canvasWrapper.appendChild(o);const c=o.cloneNode();this.progressWrapper.appendChild(c),this.renderMultiCanvas(t,s,n,a,o,c)}render(t){return g(this,void 0,void 0,(function*(){var e;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);const n=this.getPixelRatio(),r=this.scrollContainer.clientWidth,{scrollWidth:i,isScrollable:s,useParentWidth:o,width:a}=function({duration:t,minPxPerSec:e=0,parentWidth:n,fillParent:r,pixelRatio:i}){const s=Math.ceil(t*e),o=s>n,a=Boolean(r&&!o);return{scrollWidth:s,isScrollable:o,useParentWidth:a,width:(a?n:s)*i}}({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:r,fillParent:this.options.fillParent,pixelRatio:n});if(this.isScrollable=s,this.wrapper.style.width=o?"100%":`${i}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 n=0;n<t.numberOfChannels;n++){const r=Object.assign(Object.assign({},this.options),null===(e=this.options.splitChannels)||void 0===e?void 0:e[n]);this.renderChannel([t.getChannelData(n)],r,a,n)}else{const e=[t.getChannelData(0)];t.numberOfChannels>1&&e.push(t.getChannelData(1)),this.renderChannel(e,this.options,a,0)}Promise.resolve().then((()=>this.emit("rendered")))}))}reRender(){if(this.unsubscribeOnScroll.forEach((t=>t())),this.unsubscribeOnScroll=[],!this.audioData)return;const{scrollWidth:t}=this.scrollContainer,{right:e}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:t}=this.progressWrapper.getBoundingClientRect(),n=function(t){const e=2*t;return(e<0?Math.floor(e):Math.ceil(e))/2}(t-e);this.scrollContainer.scrollLeft+=n}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,e=!1){const{scrollLeft:n,scrollWidth:r,clientWidth:i}=this.scrollContainer,s=t*r,o=n,a=n+i,c=i/2;if(this.isDragging){const t=30;s+t>a?this.scrollContainer.scrollLeft+=t:s-t<o&&(this.scrollContainer.scrollLeft-=t)}else{(s<o||s>a)&&(this.scrollContainer.scrollLeft=s-(this.options.autoCenter?c:0));const t=s-n-c;e&&this.options.autoCenter&&t>0&&(this.scrollContainer.scrollLeft+=t)}}renderProgress(t,e){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,e)}exportImage(t,e,n){return g(this,void 0,void 0,(function*(){const r=this.canvasWrapper.querySelectorAll("canvas");if(!r.length)throw new Error("No waveform data");if("dataURL"===n){const n=Array.from(r).map((n=>n.toDataURL(t,e)));return Promise.resolve(n)}return Promise.all(Array.from(r).map((n=>new Promise(((r,i)=>{n.toBlob((t=>{t?r(t):i(new Error("Could not export image"))}),t,e)})))))}))}}class V extends b{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,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop()}}class D extends b{constructor(t=new AudioContext){super(),this.bufferNode=null,this.playStartTime=0,this.playedDuration=0,this._muted=!1,this._playbackRate=1,this._duration=void 0,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.seeking=!1,this.autoplay=!1,this.addEventListener=this.on,this.removeEventListener=this.un,this.audioContext=t,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return g(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((e=>{if(e.status>=400)throw new 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())})).catch((t=>{console.error("WebAudioPlayer load error:",t)}))}_play(){if(!this.paused)return;this.paused=!1,this.bufferNode&&(this.bufferNode.onended=null,this.bufferNode.disconnect()),this.bufferNode=this.audioContext.createBufferSource(),this.buffer&&(this.bufferNode.buffer=this.buffer),this.bufferNode.playbackRate.value=this._playbackRate,this.bufferNode.connect(this.gainNode);let t=this.playedDuration*this._playbackRate;(t>=this.duration||t<0)&&(t=0,this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,t),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 g(this,void 0,void 0,(function*(){this.paused&&(this._play(),this.emit("play"))}))}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){const e=this.bufferNode;null==e||e.stop(this.audioContext.currentTime+(t-this.currentTime)),null==e||e.addEventListener("ended",(()=>{e===this.bufferNode&&(this.bufferNode=null,this.pause())}),{once:!0})}setSinkId(t){return g(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}set currentTime(t){const e=!this.paused;e&&this._pause(),this.playedDuration=t/this._playbackRate,e&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,e;return null!==(t=this._duration)&&void 0!==t?t:(null===(e=this.buffer)||void 0===e?void 0:e.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 e=this.buffer.numberOfChannels;for(let n=0;n<e;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 L={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class z extends T{static create(t){return new z(t)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(t){const e=t.media||("WebAudio"===t.backend?new D:void 0);super({media:e,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({},L,t);const{state:n,actions:r}=function(t){var e,n,r,i,s,o;const a=null!==(e=null==t?void 0:t.currentTime)&&void 0!==e?e:A(0),c=null!==(n=null==t?void 0:t.duration)&&void 0!==n?n:A(0),h=null!==(r=null==t?void 0:t.isPlaying)&&void 0!==r?r:A(!1),l=null!==(i=null==t?void 0:t.isSeeking)&&void 0!==i?i:A(!1),u=null!==(s=null==t?void 0:t.volume)&&void 0!==s?s:A(1),d=null!==(o=null==t?void 0:t.playbackRate)&&void 0!==o?o:A(1),f=A(null),p=A(null),v=A(""),w=A(0),m=A(0),y=S((()=>!h.value),[h]),g=S((()=>null!==f.value),[f]),b=S((()=>g.value&&c.value>0),[g,c]),M=S((()=>a.value),[a]),k=S((()=>c.value>0?a.value/c.value:0),[a,c]);return{state:{currentTime:a,duration:c,isPlaying:h,isPaused:y,isSeeking:l,volume:u,playbackRate:d,audioBuffer:f,peaks:p,url:v,zoom:w,scrollPosition:m,canPlay:g,isReady:b,progress:M,progressPercent:k},actions:{setCurrentTime:t=>{const e=Math.max(0,Math.min(c.value||1/0,t));a.set(e)},setDuration:t=>{c.set(Math.max(0,t))},setPlaying:t=>{h.set(t)},setSeeking:t=>{l.set(t)},setVolume:t=>{const e=Math.max(0,Math.min(1,t));u.set(e)},setPlaybackRate:t=>{const e=Math.max(.1,Math.min(16,t));d.set(e)},setAudioBuffer:t=>{f.set(t),t&&c.set(t.duration)},setPeaks:t=>{p.set(t)},setUrl:t=>{v.set(t)},setZoom:t=>{w.set(Math.max(0,t))},setScrollPosition:t=>{m.set(Math.max(0,t))}}}}({isPlaying:this.isPlayingSignal,currentTime:this.currentTimeSignal,duration:this.durationSignal,volume:this.volumeSignal,playbackRate:this.playbackRateSignal,isSeeking:this.seekingSignal});this.wavesurferState=n,this.wavesurferActions=r,this.timer=new V;const i=e?void 0:this.getMediaElement();this.renderer=new N(this.options,i),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initReactiveState(),this.initPlugins();const s=this.options.url||this.getSrc()||"";Promise.resolve().then((()=>{this.emit("init");const{peaks:t,duration:e}=this.options;(s||t&&e)&&this.load(s,t,e).catch((t=>{this.emit("error",t instanceof Error?t:new Error(String(t)))}))}))}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),null!=this.stopAtPosition&&this.isPlaying()&&t>=this.stopAtPosition&&this.pause()}})))}initReactiveState(){this.reactiveCleanups.push(function(t,e){const n=[];n.push(I((()=>{e.emit(t.isPlaying.value?"play":"pause")}),[t.isPlaying])),n.push(I((()=>{const n=t.currentTime.value;e.emit("timeupdate",n),t.isPlaying.value&&e.emit("audioprocess",n)}),[t.currentTime,t.isPlaying])),n.push(I((()=>{t.isSeeking.value&&e.emit("seeking",t.currentTime.value)}),[t.isSeeking,t.currentTime]));let r=!1;n.push(I((()=>{t.isReady.value&&!r&&(r=!0,e.emit("ready",t.duration.value))}),[t.isReady,t.duration]));let i=!1;return n.push(I((()=>{const n=t.isPlaying.value,r=t.duration.value,s=r>0&&t.currentTime.value>=r;i&&!n&&s&&e.emit("finish"),i=n&&s}),[t.isPlaying,t.currentTime,t.duration])),n.push(I((()=>{const n=t.zoom.value;n>0&&e.emit("zoom",n)}),[t.zoom])),()=>{n.forEach((t=>t()))}}(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",null!==(t=this.getMediaElement().error)&&void 0!==t?t:new Error("Media error")),this.stopAtPosition=null})))}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,n,r)=>{const i=this.getDuration();this.emit("scroll",t*i,e*i,n,r)})),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 e=this.renderer.on("drag",(e=>{var n;if(!this.options.interact)return;this.renderer.renderProgress(e),clearTimeout(t);let r=0;const i=this.options.dragToSeek;this.isPlaying()?r=0:!0===i?r=200:i&&"object"==typeof i&&(r=null!==(n=i.debounceTime)&&void 0!==n?n:200),t=setTimeout((()=>{this.seekTo(e)}),r),this.emit("interaction",e*this.getDuration()),this.emit("drag",e)}));this.subscriptions.push((()=>{clearTimeout(t),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),t.duration&&!t.peaks&&(this.decodedData=M.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=M.createBuffer(t.peaks,t.duration)),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),null!=t.mediaControls&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){if(this.plugins.includes(t))return t;t._init(this),this.plugins.push(t);const e=t.once("destroy",(()=>{this.plugins=this.plugins.filter((e=>e!==t)),this.subscriptions=this.subscriptions.filter((t=>t!==e))}));return this.subscriptions.push(e),t}unregisterPlugin(t){this.plugins=this.plugins.filter((e=>e!==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 e=t/this.getDuration();this.renderer.setScrollPercentage(e)}getActivePlugins(){return this.plugins}loadAudio(t,e,n,r){return g(this,void 0,void 0,(function*(){var i;if(this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,this.stopAtPosition=null,null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=null,!e&&!n){const n=this.options.fetchParams||{};window.AbortController&&!n.signal&&(this.abortController=new AbortController,n.signal=this.abortController.signal);const r=t=>this.emit("loading",t);e=yield C.fetchBlob(t,r,n);const i=this.options.blobMimeType;i&&(e=new Blob([e],{type:i}))}this.setSrc(t,e);const s=yield new Promise((t=>{const e=r||this.getDuration();e?t(e):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",(()=>t(this.getDuration())),{once:!0}))}));if(!t&&!e){const t=this.getMediaElement();t instanceof D&&(t.duration=s)}if(n)this.decodedData=M.createBuffer(n,s||0);else if(e){const t=yield e.arrayBuffer();this.decodedData=yield M.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,n){return g(this,void 0,void 0,(function*(){try{return yield this.loadAudio(t,void 0,e,n)}catch(t){throw this.emit("error",t),t}}))}loadBlob(t,e,n){return g(this,void 0,void 0,(function*(){try{return yield this.loadAudio("",t,e,n)}catch(t){throw this.emit("error",t),t}}))}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:e=8e3,precision:n=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const r=Math.min(t,this.decodedData.numberOfChannels),i=[];for(let t=0;t<r;t++){const r=this.decodedData.getChannelData(t),s=[],o=r.length/e;for(let t=0;t<e;t++){const e=r.slice(Math.floor(t*o),Math.ceil((t+1)*o));let i=0;for(let t=0;t<e.length;t++){const n=e[t];Math.abs(n)>Math.abs(i)&&(i=n)}s.push(Math.round(i*n)/n)}i.push(s)}return i}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){this.stopAtPosition=null,super.setTime(t),this.updateProgress(t),this.emit("timeupdate",t)}seekTo(t){const e=this.getDuration()*t;this.setTime(e)}play(t,e){const n=Object.create(null,{play:{get:()=>super.play}});return g(this,void 0,void 0,(function*(){null!=t&&this.setTime(t);const r=yield n.play.call(this);return null!=e&&(this.media instanceof D?this.media.stopAt(e):this.stopAtPosition=e),r}))}playPause(){return g(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 g(this,arguments,void 0,(function*(t="image/png",e=1,n="dataURL"){return this.renderer.exportImage(t,e,n)}))}destroy(){var t;this.emit("destroy"),null===(t=this.abortController)||void 0===t||t.abort(),this.plugins.forEach((t=>t.destroy())),this.subscriptions.forEach((t=>t())),this.unsubscribePlayerEvents(),this.reactiveCleanups.forEach((t=>t())),this.reactiveCleanups=[],this.timer.destroy(),this.renderer.destroy(),super.destroy()}}function B(t,e,n,r){return new(n||(n=Promise))((function(e,i){function s(t){try{a(r.next(t))}catch(t){i(t)}}function o(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(t){t(r)}))).then(s,o)}a((r=r.apply(t,[])).next())}))}z.BasePlugin=class extends b{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}},z.dom=E,"function"==typeof SuppressedError&&SuppressedError;class F{constructor(){this.listeners={}}on(t,e,n){if(this.listeners[t]||(this.listeners[t]=new Set),null==n?void 0:n.once){const n=(...r)=>{this.un(t,n),e(...r)};return this.listeners[t].add(n),()=>this.un(t,n)}return this.listeners[t].add(e),()=>this.un(t,e)}un(t,e){var n;null===(n=this.listeners[t])||void 0===n||n.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 H extends F{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}}class $ extends F{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,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop()}}const q=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class X extends H{constructor(t){var e,n,r,i,s,o;super(Object.assign(Object.assign({},t),{audioBitsPerSecond:null!==(e=t.audioBitsPerSecond)&&void 0!==e?e:128e3,scrollingWaveform:null!==(n=t.scrollingWaveform)&&void 0!==n&&n,scrollingWaveformWindow:null!==(r=t.scrollingWaveformWindow)&&void 0!==r?r:5,continuousWaveform:null!==(i=t.continuousWaveform)&&void 0!==i&&i,renderRecordedAudio:null===(s=t.renderRecordedAudio)||void 0===s||s,mediaRecorderTimeslice:null!==(o=t.mediaRecorderTimeslice)&&void 0!==o?o:void 0})),this.stream=null,this.mediaRecorder=null,this.dataWindow=null,this.isWaveformPaused=!1,this.lastStartTime=0,this.lastDuration=0,this.duration=0,this.micStream=null,this.recordedBlobUrl=null,this.timer=new $,this.subscriptions.push(this.timer.on("tick",(()=>{const t=performance.now()-this.lastStartTime;this.duration=this.isPaused()?this.duration:this.lastDuration+t,this.emit("record-progress",this.duration)})))}static create(t){return new X(t||{})}renderMicStream(t){var e;const n=new AudioContext,r=n.createMediaStreamSource(t),i=n.createAnalyser();r.connect(i),(this.options.continuousWaveform||this.options.scrollingWaveform)&&(i.fftSize=32);const s=i.frequencyBinCount,o=new Float32Array(s);let a=0;this.wavesurfer&&(null!==(e=this.originalOptions)&&void 0!==e||(this.originalOptions=Object.assign({},this.wavesurfer.options)),this.wavesurfer.options.interact=!1,this.options.scrollingWaveform&&(this.wavesurfer.options.cursorWidth=0,this.wavesurfer.options.normalize=!0,this.wavesurfer.options.maxPeak=1));const c=setInterval((()=>{var t,e,n,r;if(!this.isWaveformPaused){if(i.getFloatTimeDomainData(o),this.options.scrollingWaveform){const t=Math.floor(100*(this.options.scrollingWaveformWindow||0));let e=0;for(let t=0;t<s;t++){const n=Math.abs(o[t]);n>e&&(e=n)}this.dataWindow||(this.dataWindow=new Float32Array(t));const n=new Float32Array(t);if(this.dataWindow&&this.dataWindow.length>0){const e=this.dataWindow.slice(-(t-1));n.set(e,0)}n[t-1]=e,this.dataWindow=n}else if(this.options.continuousWaveform){if(!this.dataWindow){const n=this.options.continuousWaveformDuration?Math.round(100*this.options.continuousWaveformDuration):(null!==(e=null===(t=this.wavesurfer)||void 0===t?void 0:t.getWidth())&&void 0!==e?e:0)*window.devicePixelRatio;this.dataWindow=new Float32Array(n)}let n=0;for(let t=0;t<s;t++){const e=Math.abs(o[t]);e>n&&(n=e)}if(a+1>this.dataWindow.length){const t=new Float32Array(2*this.dataWindow.length);t.set(this.dataWindow,0),this.dataWindow=t}this.dataWindow[a]=n,a++}else this.dataWindow=o;if(this.wavesurfer){const t=(null!==(r=null===(n=this.dataWindow)||void 0===n?void 0:n.length)&&void 0!==r?r:0)/100;this.wavesurfer.load("",[this.dataWindow],this.options.scrollingWaveform?this.options.scrollingWaveformWindow:t).then((()=>{this.wavesurfer&&this.options.continuousWaveform&&(this.wavesurfer.setTime(this.getDuration()/1e3),this.wavesurfer.options.minPxPerSec||this.wavesurfer.setOptions({minPxPerSec:this.wavesurfer.getWidth()/this.wavesurfer.getDuration()}))})).catch((t=>{console.error("Error rendering real-time recording data:",t)}))}}}),10);return{onDestroy:()=>{clearInterval(c),null==r||r.disconnect(),null==n||n.close()},onEnd:()=>{this.isWaveformPaused=!0,this.stopMic()}}}startMic(t){return B(this,0,void 0,(function*(){let e;this.micStream&&this.stopMic();try{e=yield navigator.mediaDevices.getUserMedia({audio:null==t||t})}catch(e){throw new Error("Error accessing the microphone: "+e.message)}const n=this.renderMicStream(e);return this.micStream=n,this.unsubscribeDestroy=this.once("destroy",n.onDestroy),this.unsubscribeRecordEnd=this.once("record-end",n.onEnd),this.stream=e,e}))}stopMic(){var t,e,n;null===(t=this.micStream)||void 0===t||t.onDestroy(),null===(e=this.unsubscribeDestroy)||void 0===e||e.call(this),null===(n=this.unsubscribeRecordEnd)||void 0===n||n.call(this),this.micStream=null,this.unsubscribeDestroy=void 0,this.unsubscribeRecordEnd=void 0,this.stream&&(this.stream.getTracks().forEach((t=>t.stop())),this.stream=null,this.mediaRecorder=null)}startRecording(t){return B(this,0,void 0,(function*(){const e=this.stream||(yield this.startMic(t));this.dataWindow=null;const n=this.mediaRecorder||new MediaRecorder(e,{mimeType:this.options.mimeType||q.find((t=>MediaRecorder.isTypeSupported(t))),audioBitsPerSecond:this.options.audioBitsPerSecond});this.mediaRecorder=n,this.stopRecording();const r=[];n.ondataavailable=t=>{t.data.size>0&&r.push(t.data),this.emit("record-data-available",t.data)};const i=t=>{var e;const i=new Blob(r,{type:n.mimeType});this.emit(t,i),this.options.renderRecordedAudio&&(this.applyOriginalOptionsIfNeeded(),this.recordedBlobUrl&&URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=URL.createObjectURL(i),null===(e=this.wavesurfer)||void 0===e||e.load(this.recordedBlobUrl))};n.onpause=()=>i("record-pause"),n.onstop=()=>i("record-end"),n.start(this.options.mediaRecorderTimeslice),this.lastStartTime=performance.now(),this.lastDuration=0,this.duration=0,this.isWaveformPaused=!1,this.timer.start(),this.emit("record-start")}))}getDuration(){return this.duration}isRecording(){var t;return"recording"===(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}isPaused(){var t;return"paused"===(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}isActive(){var t;return"inactive"!==(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}stopRecording(){var t;this.isActive()&&(null===(t=this.mediaRecorder)||void 0===t||t.stop(),this.timer.stop())}pauseRecording(){var t,e;this.isRecording()&&(this.isWaveformPaused=!0,null===(t=this.mediaRecorder)||void 0===t||t.requestData(),null===(e=this.mediaRecorder)||void 0===e||e.pause(),this.timer.stop(),this.lastDuration=this.duration)}resumeRecording(){var t;this.isPaused()&&(this.isWaveformPaused=!1,null===(t=this.mediaRecorder)||void 0===t||t.resume(),this.timer.start(),this.lastStartTime=performance.now(),this.emit("record-resume"))}static getAvailableAudioDevices(){return B(this,0,void 0,(function*(){return navigator.mediaDevices.enumerateDevices().then((t=>t.filter((t=>"audioinput"===t.kind))))}))}destroy(){this.applyOriginalOptionsIfNeeded(),super.destroy(),this.stopRecording(),this.stopMic(),this.recordedBlobUrl&&(URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=null)}applyOriginalOptionsIfNeeded(){this.wavesurfer&&this.originalOptions&&(this.wavesurfer.setOptions(this.originalOptions),delete this.originalOptions)}}var Z,Y,K,G,J,Q,tt,et,nt,rt={exports:{}},it=(Z||(Z=1,Y=rt.exports,K=function(t){return function(e){var n=t(e);return e.add(n),n}},G=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,J=2*536870912,Q=function(t,e){return function(n){var r=e.get(n),i=void 0===r?n.size:r<J?r+1:0;if(!n.has(i))return t(n,i);if(n.size<536870912){for(;n.has(i);)i=Math.floor(Math.random()*J);return t(n,i)}if(n.size>G)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;n.has(i);)i=Math.floor(Math.random()*G);return t(n,i)}},nt=K(et=Q(function(t){return function(e,n){return t.set(e,n),n}}(tt=new WeakMap),tt)),Y.addUniqueNumber=nt,Y.generateUniqueNumber=et),rt.exports);const st=((t,e,n)=>r=>{const i=e(r);return e=>{const r=t(e);e.addEventListener("message",(({data:t})=>{const{id:e}=t;if(null!==e&&r.has(e)){const{reject:n,resolve:i}=r.get(e);r.delete(e),void 0===t.error?i(t.result):n(new Error(t.error.message))}})),(t=>"function"==typeof t.start)(e)&&e.start();const s=(t,i=null,s=[])=>new Promise(((o,a)=>{const c=n(r);r.set(c,{reject:a,resolve:o}),e.postMessage(null===i?{id:c,method:t}:{id:c,method:t,params:i},s)})),o=(t,n,r=[])=>{e.postMessage({id:null,method:t,params:n},r)};let a={};for(const[t,e]of Object.entries(i))a={...a,[t]:e({call:s,notify:o})};return{...a}}})((at=new WeakMap,t=>{if(at.has(t))return at.get(t);const e=new Map;return at.set(t,e),e}),(ot=new WeakMap,t=>({...t,connect:({call:t})=>async()=>{const{port1:e,port2:n}=new MessageChannel,r=await t("connect",{port:e},[e]);return ot.set(n,r),n},disconnect:({call:t})=>async e=>{const n=ot.get(e);if(void 0===n)throw new Error("The given port is not connected.");await t("disconnect",{portId:n})},isSupported:({call:t})=>()=>t("isSupported")})),it.generateUniqueNumber);var ot,at;const ct=new Set,ht=new Set,lt=new WeakMap,ut=st({deregister:({call:t})=>async e=>{const n=lt.get(e);if(void 0===n)throw new Error("There is no encoder registered with the given port.");const r=await t("deregister",{encoderId:n});return ct.delete(n),lt.delete(e),r},encode:({call:t})=>async(e,n)=>{const r=await t("encode",{encoderInstanceId:e,timeslice:n});return ht.delete(e),r},instantiate:({call:t})=>async(e,n)=>{const r=it.addUniqueNumber(ht);return{encoderInstanceId:r,port:await t("instantiate",{encoderInstanceId:r,mimeType:e,sampleRate:n})}},register:({call:t})=>async e=>{if(lt.has(e))throw new Error("");const n=it.addUniqueNumber(ct);lt.set(e,n);try{return await t("register",{encoderId:n,port:e},[e])}catch(t){throw ct.delete(n),lt.delete(e),t}}}),dt=new Blob(['(()=>{var e={455(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),c=void 0===a?r.size:a<s?a+1:0;if(!r.has(c))return e(r,c);if(r.size<o){for(;r.has(c);)c=Math.floor(Math.random()*s);return e(r,c)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(c);)c=Math.floor(Math.random()*n);return e(r,c)}},c=new WeakMap,i=r(c),d=a(i,c),l=t(d);e.addUniqueNumber=l,e.generateUniqueNumber=d}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";var e=r(455);const t=((e,t,r,n)=>o=>{const s=t(o);return t=>{const o=e(t);t.addEventListener("message",({data:e})=>{const{id:t}=e;if(null!==t&&o.has(t)){const{reject:r,resolve:n}=o.get(t);o.delete(t),void 0===e.error?n(e.result):r(new Error(e.error.message))}}),n(t)&&t.start();const a=(e,n=null,s=[])=>new Promise((a,c)=>{const i=r(o);o.set(i,{reject:c,resolve:a}),null===n?t.postMessage({id:i,method:e},s):t.postMessage({id:i,method:e,params:n},s)}),c=(e,r,n=[])=>{t.postMessage({id:null,method:e,params:r},n)};let i={};for(const[e,t]of Object.entries(s))i={...i,[e]:t({call:a,notify:c})};return{...i}}})((o=new WeakMap,e=>{if(o.has(e))return o.get(e);const t=new Map;return o.set(e,t),t}),(n=new WeakMap,e=>({...e,connect:({call:e})=>async()=>{const{port1:t,port2:r}=new MessageChannel,o=await e("connect",{port:t},[t]);return n.set(r,o),r},disconnect:({call:e})=>async t=>{const r=n.get(t);if(void 0===r)throw new Error("The given port is not connected.");await e("disconnect",{portId:r})},isSupported:({call:e})=>()=>e("isSupported")})),e.generateUniqueNumber,e=>"function"==typeof e.start);var n,o;const s=t({characterize:({call:e})=>()=>e("characterize"),encode:({call:e})=>(t,r)=>e("encode",{recordingId:t,timeslice:r}),record:({call:e})=>async(t,r,n)=>{await e("record",{recordingId:t,sampleRate:r,typedArrays:n},n.map(({buffer:e})=>e).filter(e=>e instanceof ArrayBuffer))}}),a=-32603,c=-32602,i=-32601,d=(e,t)=>Object.assign(new Error(e),{status:t}),l=e=>d(\'The handler of the method called "\'.concat(e,\'" returned an unexpected result.\'),a),u=(e,t)=>async({data:{id:r,method:n,params:o}})=>{const s=t[n];try{if(void 0===s)throw(e=>d(\'The requested method called "\'.concat(e,\'" is not supported.\'),i))(n);const t=void 0===o?s():s(o);if(void 0===t)throw(e=>d(\'The handler of the method called "\'.concat(e,\'" returned no required result.\'),a))(n);const c=t instanceof Promise?await t:t;if(null===r){if(void 0!==c.result)throw l(n)}else{if(void 0===c.result)throw l(n);const{result:t,transferables:o=[]}=c;e.postMessage({id:r,result:t},o)}}catch(t){const{message:n,status:o=-32603}=t;e.postMessage({error:{code:o,message:n},id:r})}},h=new Map,f=(t,r,n)=>({...r,connect:({port:n})=>{n.start();const o=t(n,r),s=(0,e.generateUniqueNumber)(h);return h.set(s,()=>{o(),n.close(),h.delete(s)}),{result:s}},disconnect:({portId:e})=>{const t=h.get(e);if(void 0===t)throw(e=>d(\'The specified parameter called "portId" with the given value "\'.concat(e,\'" does not identify a port connected to this worker.\'),c))(e);return t(),{result:null}},isSupported:async()=>{if(await new Promise(e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])})){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),w=(e,t,r=()=>!0)=>{const n=f(w,t,r),o=u(e,n);return e.addEventListener("message",o),()=>e.removeEventListener("message",o)},p=e=>{e.onmessage=null,e.close()},m=new Map,g=new Map,v=((e,t)=>r=>{const n=t.get(r);if(void 0===n)throw new Error("There was no encoder stored with the given id.");e.delete(n),t.delete(r)})(m,g),y=new Map,M=(e=>t=>{const r=e.get(t);if(void 0===r)throw new Error("There was no instance of an encoder stored with the given id.");return r})(y),E=((e,t)=>r=>{const n=t(r);return e.delete(r),n})(y,M),b=((e,t)=>r=>{const[n,o,s,a]=t(r);return s?new Promise(t=>{o.onmessage=({data:s})=>{0===s.length?(e(o),t(n.encode(r,null))):n.record(r,a,s)}}):n.encode(r,null)})(p,E),T=(e=>t=>{for(const[r,n]of Array.from(e.values()))if(r.test(t))return n;throw new Error("There is no encoder registered which could handle the given mimeType.")})(m),I=((e,t,r)=>(n,o,s)=>{if(t.has(n))throw new Error(\'There is already an encoder instance registered with an id called "\'.concat(n,\'".\'));const a=r(o),{port1:c,port2:i}=new MessageChannel,d=[a,c,!0,s];return t.set(n,d),c.onmessage=({data:t})=>{0===t.length?(e(c),d[2]=!1):a.record(n,s,t.map(e=>"number"==typeof e?new Float32Array(e):e))},i})(p,y,T),A=((e,t,r)=>async(n,o)=>{const s=r(o),a=await s.characterize(),c=a.toString();if(e.has(c))throw new Error("There is already an encoder stored which handles exactly the same mime types.");if(t.has(n))throw new Error(\'There is already an encoder registered with an id called "\'.concat(n,\'".\'));return e.set(c,[a,s]),t.set(n,c),a})(m,g,s),N=(e=>(t,r)=>{const[n]=e(t);return n.encode(t,r)})(M);w(self,{deregister:async({encoderId:e})=>(v(e),{result:null}),encode:async({encoderInstanceId:e,timeslice:t})=>{const r=null===t?await b(e):await N(e,t);return{result:r,transferables:r}},instantiate:({encoderInstanceId:e,mimeType:t,sampleRate:r})=>{const n=I(e,t,r);return{result:n,transferables:[n]}},register:async({encoderId:e,port:t})=>({result:await A(e,t)})})})()})();'],{type:"application/javascript; charset=utf-8"}),ft=URL.createObjectURL(dt),pt=(()=>{const t=new Worker(ft);return ut(t)})(),vt=pt.encode,wt=pt.instantiate,mt=pt.register;URL.revokeObjectURL(ft);const yt=()=>{try{return new DOMException("","NotSupportedError")}catch(t){return t.code=9,t.name="NotSupportedError",t}},gt=Symbol.observable||"@@observable",bt=()=>{},Mt=t=>{throw t},kt=(t=>(e,n,r)=>t((t=>{const i=e=>t.next(e);return e.addEventListener(n,i,r),()=>e.removeEventListener(n,i,r)})))(((t,e)=>{const n=()=>{};return t=>{const r=(...r)=>{const i=t((t=>"function"==typeof t[0])(r)?e({next:r[0]}):e(...r));return void 0!==i?i:n};return r[Symbol.observable]=()=>({subscribe:(...t)=>({unsubscribe:r(...t)})}),i=r,Symbol.observable||("function"==typeof i&&i.prototype&&i.prototype[Symbol.observable]?(i.prototype[gt]=i.prototype[Symbol.observable],delete i.prototype[Symbol.observable]):(i[gt]=i[Symbol.observable],delete i[Symbol.observable])),i;var i}})(0,(function(t){return t?t.next&&t.error&&t.complete?t:{complete:(t.complete??bt).bind(t),error:(t.error??Mt).bind(t),next:(t.next??bt).bind(t)}:{complete:bt,error:Mt,next:bt}}))),xt=(Ct=Blob,At=URL,async t=>{const e=new Ct(['(()=>{"use strict";class e extends AudioWorkletProcessor{constructor(){super(),this._encoderPort=null,this._numberOfChannels=0,this._state="inactive",this.port.onmessage=({data:e})=>{"pause"===e.method?"active"===this._state||"recording"===this._state?(this._state="paused",this._sendAcknowledgement(e.id)):this._sendUnexpectedStateError(e.id):"record"===e.method?"inactive"===this._state?(this._encoderPort=e.params.encoderPort,this._state="active",this._sendAcknowledgement(e.id)):this._sendUnexpectedStateError(e.id):"resume"===e.method?"paused"===this._state?(this._state="active",this._sendAcknowledgement(e.id)):this._sendUnexpectedStateError(e.id):"stop"===e.method?"active"!==this._state&&"paused"!==this._state&&"recording"!==this._state||null===this._encoderPort?this._sendUnexpectedStateError(e.id):(this._stop(this._encoderPort),this._sendAcknowledgement(e.id)):"number"==typeof e.id&&this.port.postMessage({error:{code:-32601,message:"The requested method is not supported."},id:e.id})}}process([e]){if("inactive"===this._state||"paused"===this._state)return!0;if("active"===this._state){if(void 0===e)throw new Error("No channelData was received for the first input.");if(0===e.length)return!0;this._state="recording"}if("recording"===this._state&&null!==this._encoderPort){if(void 0===e)throw new Error("No channelData was received for the first input.");return 0===e.length?this._encoderPort.postMessage(Array.from({length:this._numberOfChannels},()=>128)):(this._encoderPort.postMessage(e,e.map(({buffer:e})=>e)),this._numberOfChannels=e.length),!0}return!1}_sendAcknowledgement(e){this.port.postMessage({id:e,result:null})}_sendUnexpectedStateError(e){this.port.postMessage({error:{code:-32603,message:"The internal state does not allow to process the given message."},id:e})}_stop(e){e.postMessage([]),e.close(),this._encoderPort=null,this._state="stopped"}}e.parameterDescriptors=[],registerProcessor("recorder-audio-worklet-processor",e)})();'],{type:"application/javascript; charset=utf-8"}),n=At.createObjectURL(e);try{await t(n)}finally{At.revokeObjectURL(n)}}),Et=((t,e,n,r)=>(t,i,s={})=>{const o=new t(i,"recorder-audio-worklet-processor",{...s,channelCountMode:"explicit",numberOfInputs:1,numberOfOutputs:0}),a=new Map,c=e(a,o.port),h=n(o.port,"message")((t=>({data:e})=>{const{id:n}=e;if(null!==n){const r=t.get(n);if(void 0!==r){const{reject:i,resolve:s}=r;t.delete(n),void 0===e.error?s(e.result):i(new Error(e.error.message))}}})(a));o.port.start();let l="inactive";return Object.defineProperties(o,{pause:{get:()=>async()=>(r(["recording"],l),l="paused",c({method:"pause"}))},port:{get(){throw new Error("The port of a RecorderAudioWorkletNode can't be accessed.")}},record:{get:()=>async t=>(r(["inactive"],l),l="recording",c({method:"record",params:{encoderPort:t}},[t]))},resume:{get:()=>async()=>(r(["paused"],l),l="recording",c({method:"resume"}))},stop:{get:()=>async()=>{r(["paused","recording"],l),l="stopped";try{await c({method:"stop"})}finally{h()}}}}),o})(0,(t=>(e,n)=>(r,i=[])=>new Promise(((s,o)=>{const a=t(e);e.set(a,{reject:o,resolve:s}),n.postMessage({id:a,...r},i)})))(it.generateUniqueNumber),kt,((t,e)=>{if(!t.includes(e))throw new Error(`Expected the state to be ${t.map((t=>`"${t}"`)).join(" or ")} but it was "${e}".`)}));var Ct,At,St={exports:{}};function It(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var Tt=Object.freeze({__proto__:null,default:function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,s,o,a=[],c=!0,h=!1;try{if(s=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=s.call(n)).done)&&(a.push(r.value),a.length!==e);c=!0);}catch(t){h=!0,i=t}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(h)throw i}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return It(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?It(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}}),Rt=o(Tt),Ot=Object.freeze({__proto__:null,default:function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}}),Pt=o(Ot);function Wt(t){return Wt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Wt(t)}function jt(t){var e=function(t){if("object"!=Wt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Wt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Wt(e)?e:e+""}function _t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,jt(r.key),r)}}var Ut,Nt=Object.freeze({__proto__:null,default:function(t,e,n){return e&&_t(t.prototype,e),n&&_t(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}}),Vt=o(Nt),Dt=(Ut||(Ut=1,function(t,e,n,r){var i=function(t,e,n){return{endTime:e,insertTime:n,type:"exponentialRampToValue",value:t}},s=function(t,e,n){return{endTime:e,insertTime:n,type:"linearRampToValue",value:t}},o=function(t,e){return{startTime:e,type:"setValue",value:t}},a=function(t,e,n){return{duration:n,startTime:e,type:"setValueCurve",values:t}},c=function(t,e,n){var r=n.target;return r+(e-r)*Math.exp((n.startTime-t)/n.timeConstant)},h=function(t){return"exponentialRampToValue"===t.type},l=function(t){return"linearRampToValue"===t.type},u=function(t){return h(t)||l(t)},d=function(t){return"setValue"===t.type},f=function(t){return"setValueCurve"===t.type},p=function(t,e,n,r){var i=t[e];return void 0===i?r:u(i)||d(i)?i.value:f(i)?i.values[i.values.length-1]:c(n,p(t,e-1,i.startTime,r),i)},v=function(t,e,n,r,i){return void 0===n?[r.insertTime,i]:u(n)?[n.endTime,n.value]:d(n)?[n.startTime,n.value]:f(n)?[n.startTime+n.duration,n.values[n.values.length-1]]:[n.startTime,p(t,e-1,n.startTime,i)]},w=function(t){return"cancelAndHold"===t.type},m=function(t){return"cancelScheduledValues"===t.type},y=function(t){return w(t)||m(t)?t.cancelTime:h(t)||l(t)?t.endTime:t.startTime},g=function(t,e,n,r){var i=r.value;return n===i?i:0<n&&0<i||n<0&&i<0?n*Math.pow(i/n,(t-e)/(r.endTime-e)):0},b=function(t,e,n,r){return n+(t-e)/(r.endTime-e)*(r.value-n)},M=function(t,e){var n=e.values;return function(t,e){var n=Math.floor(e),r=Math.ceil(e);return n===r?t[n]:(1-(e-n))*t[n]+(1-(r-e))*t[r]}(n,(t-e.startTime)/e.duration*(n.length-1))},k=function(t){return"setTarget"===t.type},x=function(){return r((function t(e){n(this,t),this._automationEvents=[],this._currenTime=0,this._defaultValue=e}),[{key:Symbol.iterator,value:function(){return this._automationEvents[Symbol.iterator]()}},{key:"add",value:function(t){var e=y(t);if(w(t)||m(t)){var n=this._automationEvents.findIndex((function(n){return m(t)&&f(n)?n.startTime+n.duration>=e:y(n)>=e})),r=this._automationEvents[n];if(-1!==n&&(this._automationEvents=this._automationEvents.slice(0,n)),w(t)){var c=this._automationEvents[this._automationEvents.length-1];if(void 0!==r&&u(r)){if(void 0!==c&&k(c))throw new Error("The internal list is malformed.");var d=void 0===c?r.insertTime:f(c)?c.startTime+c.duration:y(c),p=void 0===c?this._defaultValue:f(c)?c.values[c.values.length-1]:c.value,v=h(r)?g(e,d,p,r):b(e,d,p,r),M=h(r)?i(v,e,this._currenTime):s(v,e,this._currenTime);this._automationEvents.push(M)}if(void 0!==c&&k(c)&&this._automationEvents.push(o(this.getValue(e),e)),void 0!==c&&f(c)&&c.startTime+c.duration>e){var x=e-c.startTime,E=(c.values.length-1)/c.duration,C=Math.max(2,1+Math.ceil(x*E)),A=x/(C-1)*E,S=c.values.slice(0,C);if(A<1)for(var I=1;I<C;I+=1){var T=A*I%1;S[I]=c.values[I-1]*(1-T)+c.values[I]*T}this._automationEvents[this._automationEvents.length-1]=a(S,c.startTime,x)}}}else{var R=this._automationEvents.findIndex((function(t){return y(t)>e})),O=-1===R?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[R-1];if(void 0!==O&&f(O)&&y(O)+O.duration>e)return!1;var P=h(t)?i(t.value,t.endTime,this._currenTime):l(t)?s(t.value,e,this._currenTime):t;if(-1===R)this._automationEvents.push(P);else{if(f(t)&&e+t.duration>y(this._automationEvents[R]))return!1;this._automationEvents.splice(R,0,P)}}return!0}},{key:"flush",value:function(t){var e=this._automationEvents.findIndex((function(e){return y(e)>t}));if(e>1){var n=this._automationEvents.slice(e-1),r=n[0];k(r)&&n.unshift(o(p(this._automationEvents,e-2,r.startTime,this._defaultValue),r.startTime)),this._automationEvents=n}}},{key:"getValue",value:function(t){if(0===this._automationEvents.length)return this._defaultValue;var n=this._automationEvents.findIndex((function(e){return y(e)>t})),r=this._automationEvents[n],i=(-1===n?this._automationEvents.length:n)-1,s=this._automationEvents[i];if(void 0!==s&&k(s)&&(void 0===r||!u(r)||r.insertTime>t))return c(t,p(this._automationEvents,i-1,s.startTime,this._defaultValue),s);if(void 0!==s&&d(s)&&(void 0===r||!u(r)))return s.value;if(void 0!==s&&f(s)&&(void 0===r||!u(r)||s.startTime+s.duration>t))return t<s.startTime+s.duration?M(t,s):s.values[s.values.length-1];if(void 0!==s&&u(s)&&(void 0===r||!u(r)))return s.value;if(void 0!==r&&h(r)){var o=v(this._automationEvents,i,s,r,this._defaultValue),a=e(o,2);return g(t,a[0],a[1],r)}if(void 0!==r&&l(r)){var w=v(this._automationEvents,i,s,r,this._defaultValue),m=e(w,2);return b(t,m[0],m[1],r)}return this._defaultValue}}])}();t.AutomationEventList=x,t.createCancelAndHoldAutomationEvent=function(t){return{cancelTime:t,type:"cancelAndHold"}},t.createCancelScheduledValuesAutomationEvent=function(t){return{cancelTime:t,type:"cancelScheduledValues"}},t.createExponentialRampToValueAutomationEvent=function(t,e){return{endTime:e,type:"exponentialRampToValue",value:t}},t.createLinearRampToValueAutomationEvent=function(t,e){return{endTime:e,type:"linearRampToValue",value:t}},t.createSetTargetAutomationEvent=function(t,e,n){return{startTime:e,target:t,timeConstant:n,type:"setTarget"}},t.createSetValueAutomationEvent=o,t.createSetValueCurveAutomationEvent=a}(St.exports,Rt,Pt,Vt)),St.exports);const Lt=new WeakSet,zt=new WeakMap,Bt=new WeakMap,Ft=new WeakMap,Ht=new WeakMap,$t=new WeakMap,qt=new WeakMap,Xt=new WeakMap,Zt=new WeakMap,Yt=new WeakMap,Kt={construct:()=>Kt},Gt=/^import(?:(?:[\s]+[\w]+|(?:[\s]+[\w]+[\s]*,)?[\s]*\{[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?(?:[\s]*,[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?)*[\s]*}|(?:[\s]+[\w]+[\s]*,)?[\s]*\*[\s]+as[\s]+[\w]+)[\s]+from)?(?:[\s]*)("([^"\\]|\\.)+"|'([^'\\]|\\.)+')(?:[\s]*);?/,Jt=(t,e)=>{const n=[];let r=t.replace(/^[\s]+/,""),i=r.match(Gt);for(;null!==i;){const t=i[1].slice(1,-1),s=i[0].replace(/([\s]+)?;?$/,"").replace(t,new URL(t,e).toString());n.push(s),r=r.slice(i[0].length).replace(/^[\s]+/,""),i=r.match(Gt)}return[n.join(";"),r]},Qt=t=>{if(void 0!==t&&!Array.isArray(t))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},te=t=>{if(!(t=>{try{new new Proxy(t,Kt)}catch{return!1}return!0})(t))throw new TypeError("The given value for processorCtor should be a constructor.");if(null===t.prototype||"object"!=typeof t.prototype)throw new TypeError("The given value for processorCtor should have a prototype.")},ee=(t,e)=>{const n=t.get(e);if(void 0===n)throw new Error("A value with the given key could not be found.");return n},ne=(t,e)=>{const n=Array.from(t).filter(e);if(n.length>1)throw Error("More than one element was found.");if(0===n.length)throw Error("No element was found.");const[r]=n;return t.delete(r),r},re=(t,e,n,r)=>{const i=ee(t,e),s=ne(i,(t=>t[0]===n&&t[1]===r));return 0===i.size&&t.delete(e),s},ie=t=>ee(qt,t),se=t=>{if(Lt.has(t))throw new Error("The AudioNode is already stored.");Lt.add(t),ie(t).forEach((t=>t(!0)))},oe=t=>"port"in t,ae=t=>{if(!Lt.has(t))throw new Error("The AudioNode is not stored.");Lt.delete(t),ie(t).forEach((t=>t(!1)))},ce=(t,e)=>{!oe(t)&&e.every((t=>0===t.size))&&ae(t)},he=(t,e)=>t.context===e,le=t=>{try{t.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},ue=()=>new DOMException("","IndexSizeError"),de={numberOfChannels:1},fe=-34028234663852886e22,pe=34028234663852886e22,ve=t=>Lt.has(t),we={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},me=t=>ee(zt,t),ye=t=>ee(Ft,t),ge=(t,e)=>{const{activeInputs:n}=me(t);n.forEach((n=>n.forEach((([n])=>{e.includes(t)||ge(n,[...e,t])}))));const r=(t=>"playbackRate"in t)(t)?[t.playbackRate]:oe(t)?Array.from(t.parameters.values()):(t=>"frequency"in t&&"gain"in t)(t)?[t.Q,t.detune,t.frequency,t.gain]:(t=>"offset"in t)(t)?[t.offset]:(t=>!("frequency"in t)&&"gain"in t)(t)?[t.gain]:(t=>"detune"in t&&"frequency"in t&&!("gain"in t))(t)?[t.detune,t.frequency]:(t=>"pan"in t)(t)?[t.pan]:[];for(const t of r){const n=ye(t);void 0!==n&&n.activeInputs.forEach((([t])=>ge(t,e)))}ve(t)&&ae(t)},be=t=>"context"in t,Me=t=>be(t[0]),ke=(t,e,n,r)=>{for(const e of t)if(n(e)){if(r)return!1;throw Error("The set contains at least one similar element.")}return t.add(e),!0},xe=(t,e,[n,r],i)=>{ke(t,[e,n,r],(t=>t[0]===e&&t[1]===n),i)},Ee=(t,[e,n,r],i)=>{const s=t.get(e);void 0===s?t.set(e,new Set([[n,r]])):ke(s,[n,r],(t=>t[0]===n),i)},Ce=t=>"inputs"in t,Ae=(t,e,n,r)=>{if(Ce(e)){const i=e.inputs[r];return t.connect(i,n,0),[i,n,0]}return t.connect(e,n,r),[e,n,r]},Se=(t,e,n)=>{for(const r of t)if(r[0]===e&&r[1]===n)return t.delete(r),r;return null},Ie=(t,e)=>{if(!ie(t).delete(e))throw new Error("Missing the expected event listener.")},Te=(t,e,n)=>{const r=ee(t,e),i=ne(r,(t=>t[0]===n));return 0===r.size&&t.delete(e),i},Re=(t,e,n,r)=>{Ce(e)?t.disconnect(e.inputs[r],n,0):t.disconnect(e,n,r)},Oe=t=>ee(Bt,t),Pe=t=>ee(Ht,t),We=t=>Xt.has(t),je=t=>!Lt.has(t),_e=(t,e)=>new Promise((n=>{if(null!==e)n(!0);else{const e=t.createScriptProcessor(256,1,1),r=t.createGain(),i=t.createBuffer(1,2,44100),s=i.getChannelData(0);s[0]=1,s[1]=1;const o=t.createBufferSource();o.buffer=i,o.loop=!0,o.connect(e).connect(t.destination),o.connect(r),o.disconnect(r),e.onaudioprocess=r=>{const i=r.inputBuffer.getChannelData(0);Array.prototype.some.call(i,(t=>1===t))?n(!0):n(!1),o.stop(),e.onaudioprocess=null,o.disconnect(e),e.disconnect(t.destination)},o.start()}})),Ue=(t,e)=>{const n=new Map;for(const e of t)for(const t of e){const e=n.get(t);n.set(t,void 0===e?1:e+1)}n.forEach(((t,n)=>e(n,t)))},Ne=t=>"context"in t,Ve=(t,e,n,r,i)=>{const[s,o]=((t,e,n,r)=>{const{activeInputs:i,passiveInputs:s}=me(e),o=Se(i[r],t,n);return null===o?[re(s,t,n,r)[2],!1]:[o[2],!0]})(t,n,r,i);if(null!==s&&(Ie(t,s),!o||e||We(t)||Re(Oe(t),Oe(n),r,i)),ve(n)){const{activeInputs:t}=me(n);ce(n,t)}},De=(t,e,n,r)=>{const[i,s]=((t,e,n)=>{const{activeInputs:r,passiveInputs:i}=ye(e),s=Se(r,t,n);return null===s?[Te(i,t,n)[1],!1]:[s[2],!0]})(t,n,r);null!==i&&(Ie(t,i),!s||e||We(t)||Oe(t).disconnect(Pe(n),r))};class Le{constructor(t){this._map=new Map(t)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(t,e=null){return this._map.forEach(((n,r)=>t.call(e,n,r,this)))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}}const ze={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}};function Be(t,e,n,r,i){if("function"==typeof t.copyFromChannel)0===e[n].byteLength&&(e[n]=new Float32Array(128)),t.copyFromChannel(e[n],r,i);else{const s=t.getChannelData(r);if(0===e[n].byteLength)e[n]=s.slice(i,i+128);else{const t=new Float32Array(s.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);e[n].set(t)}}}const Fe=(t,e,n,r,i)=>{"function"==typeof t.copyToChannel?0!==e[n].byteLength&&t.copyToChannel(e[n],r,i):0!==e[n].byteLength&&t.getChannelData(r).set(e[n],i)},He=(t,e)=>{const n=[];for(let r=0;r<t;r+=1){const t=[],i="number"==typeof e?e:e[r];for(let e=0;e<i;e+=1)t.push(new Float32Array(128));n.push(t)}return n},$e=async(t,e,n,r,i,s,o)=>{const a=null===e?128*Math.ceil(t.context.length/128):e.length,c=r.channelCount*r.numberOfInputs,h=i.reduce(((t,e)=>t+e),0),l=0===h?null:n.createBuffer(h,a,n.sampleRate);if(void 0===s)throw new Error("Missing the processor constructor.");const u=me(t),d=await((t,e)=>{const n=ee(Yt,t),r=Oe(e);return ee(n,r)})(n,t),f=He(r.numberOfInputs,r.channelCount),p=He(r.numberOfOutputs,i),v=Array.from(t.parameters.keys()).reduce(((t,e)=>({...t,[e]:new Float32Array(128)})),{});for(let h=0;h<a;h+=128){if(r.numberOfInputs>0&&null!==e)for(let t=0;t<r.numberOfInputs;t+=1)for(let n=0;n<r.channelCount;n+=1)Be(e,f[t],n,n,h);void 0!==s.parameterDescriptors&&null!==e&&s.parameterDescriptors.forEach((({name:t},n)=>{Be(e,v,t,c+n,h)}));for(let t=0;t<r.numberOfInputs;t+=1)for(let e=0;e<i[t];e+=1)0===p[t][e].byteLength&&(p[t][e]=new Float32Array(128));try{const t=f.map(((t,e)=>0===u.activeInputs[e].size?[]:t)),e=o(h/n.sampleRate,n.sampleRate,(()=>d.process(t,p,v)));if(null!==l)for(let t=0,e=0;t<r.numberOfOutputs;t+=1){for(let n=0;n<i[t];n+=1)Fe(l,p[t],n,e+n,h);e+=i[t]}if(!e)break}catch(e){t.dispatchEvent(new ErrorEvent("processorerror",{colno:e.colno,filename:e.filename,lineno:e.lineno,message:e.message}));break}}return l},qe=(t,e,n)=>{const r=e[n];if(void 0===r)throw t();return r},Xe=()=>new DOMException("","InvalidStateError"),Ze=t=>{const e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const n=t.decodeAudioData(e.buffer,(()=>{}));return void 0!==n&&(n.catch((()=>{})),!0)}catch{}return!1},Ye=(t,e,n)=>{const r=e[n];void 0!==r&&r!==t[n]&&(t[n]=r)},Ke=(t,e)=>{Ye(t,e,"channelCount"),Ye(t,e,"channelCountMode"),Ye(t,e,"channelInterpretation")},Ge=(t,e,n)=>{const r=e[n];void 0!==r&&r!==t[n].value&&(t[n].value=r)},Je=t=>{var e;t.start=(e=t.start,(n=0,r=0,i)=>{if("number"==typeof i&&i<0||r<0||n<0)throw new RangeError("The parameters can't be negative.");e.call(t,n,r,i)})},Qe=t=>{var e;t.stop=(e=t.stop,(n=0)=>{if(n<0)throw new RangeError("The parameter can't be negative.");e.call(t,n)})},tn=(t,e)=>{const n=t.createChannelSplitter(e.numberOfOutputs);return Ke(n,e),(t=>{const e=t.numberOfOutputs;Object.defineProperty(t,"channelCount",{get:()=>e,set:t=>{if(t!==e)throw Xe()}}),Object.defineProperty(t,"channelCountMode",{get:()=>"explicit",set:t=>{if("explicit"!==t)throw Xe()}}),Object.defineProperty(t,"channelInterpretation",{get:()=>"discrete",set:t=>{if("discrete"!==t)throw Xe()}})})(n),n},en=(t,e)=>(t.connect=e.connect.bind(e),t.disconnect=e.disconnect.bind(e),t),nn=(t,e)=>{const n=t.createGain();return Ke(n,e),Ge(n,e,"gain"),n},rn=(t,e,n,r)=>t.createScriptProcessor(e,n,r),sn=()=>new DOMException("","NotSupportedError"),on=(t,e,n,r)=>{let i=t;for(;!i.hasOwnProperty(e);)i=Object.getPrototypeOf(i);const{get:s,set:o}=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(t,e,{get:n(s),set:r(o)})},an=(t,e,n)=>{try{t.setValueAtTime(e,n)}catch(r){if(9!==r.code)throw r;an(t,e,n+1e-7)}},cn=t=>{const e=t.createOscillator();try{e.start(-1)}catch(t){return t instanceof RangeError}return!1},hn=t=>{const e=t.createOscillator();try{e.stop(-1)}catch(t){return t instanceof RangeError}return!1},ln=(t,e)=>n=>{const r={value:t};return Object.defineProperties(n,{currentTarget:r,target:r}),"function"==typeof e?e.call(t,n):e.handleEvent.call(t,n)},un=(t=>(e,n,[r,i,s],o)=>{t(e[i],[n,r,s],(t=>t[0]===n&&t[1]===r),o)})(ke),dn=(t=>(e,n,[r,i,s],o)=>{const a=e.get(r);void 0===a?e.set(r,new Set([[i,n,s]])):t(a,[i,n,s],(t=>t[0]===i&&t[1]===n),o)})(ke),fn=(t=>(e,n,r,i)=>t(e[i],(t=>t[0]===n&&t[1]===r)))(ne),pn=(wn=new WeakMap,t=>{var e;return null!==(e=wn.get(t))&&void 0!==e?e:0}),vn=(mn=new Map,yn=new WeakMap,(t,e)=>{const n=yn.get(t);if(void 0!==n)return n;const r=mn.get(t);if(void 0!==r)return r;try{const n=e();return n instanceof Promise?(mn.set(t,n),n.catch((()=>!1)).then((e=>(mn.delete(t),yn.set(t,e),e)))):(yn.set(t,n),n)}catch{return yn.set(t,!1),!1}});var wn,mn,yn;const gn="undefined"==typeof window?null:window,bn=(t=>e=>{const n=t(e);if(null===n.renderer)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return n.renderer})(me),Mn=((t,e,n)=>async(r,i,s)=>{const o=t(r);await Promise.all(o.activeInputs.map(((t,o)=>Array.from(t).map((async([t,a])=>{const c=e(t),h=await c.render(t,i),l=r.context.destination;n(t)||r===l&&n(r)||h.connect(s,a,o)})))).reduce(((t,e)=>[...t,...e]),[]))})(me,bn,We),kn=(xn=$t,t=>{const e=xn.get(t);if(void 0===e)throw Xe();return e});var xn;const En=(t=>null===t?null:t.hasOwnProperty("OfflineAudioContext")?t.OfflineAudioContext:t.hasOwnProperty("webkitOfflineAudioContext")?t.webkitOfflineAudioContext:null)(gn),Cn=(t=>e=>null!==t&&e instanceof t)(En),An=new WeakMap,Sn=(jn=ln,class{constructor(t){this._nativeEventTarget=t,this._listeners=new WeakMap}addEventListener(t,e,n){if(null!==e){let r=this._listeners.get(e);void 0===r&&(r=jn(this,e),"function"==typeof e&&this._listeners.set(e,r)),this._nativeEventTarget.addEventListener(t,r,n)}}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,e,n){const r=null===e?void 0:this._listeners.get(e);this._nativeEventTarget.removeEventListener(t,void 0===r?null:r,n)}}),In=(t=>null===t?null:t.hasOwnProperty("AudioContext")?t.AudioContext:t.hasOwnProperty("webkitAudioContext")?t.webkitAudioContext:null)(gn),Tn=(t=>e=>null!==t&&e instanceof t)(In),Rn=(t=>e=>null!==t&&"function"==typeof t.AudioNode&&e instanceof t.AudioNode)(gn),On=(t=>e=>null!==t&&"function"==typeof t.AudioParam&&e instanceof t.AudioParam)(gn),Pn=(t=>null===t?null:t.hasOwnProperty("AudioWorkletNode")?t.AudioWorkletNode:null)(gn),Wn=((t,e,n,r,i,s,o,a,c,h,l,u,d,f,p,v)=>class extends h{constructor(e,r,i,s){super(i),this._context=e,this._nativeAudioNode=i;const o=l(e);u(o)&&!0!==n(_e,(()=>_e(o,v)))&&(t=>{const e=new Map;var n;t.connect=(t=>(n,r=0,i=0)=>{const s=Ne(n)?t(n,r,i):t(n,r),o=e.get(n);return void 0===o?e.set(n,[{input:i,output:r}]):o.every((t=>t.input!==i||t.output!==r))&&o.push({input:i,output:r}),s})(t.connect.bind(t)),t.disconnect=(n=t.disconnect,(r,i,s)=>{if(n.apply(t),void 0===r)e.clear();else if("number"==typeof r)for(const[t,n]of e){const i=n.filter((t=>t.output!==r));0===i.length?e.delete(t):e.set(t,i)}else if(e.has(r))if(void 0===i)e.delete(r);else{const t=e.get(r);if(void 0!==t){const n=t.filter((t=>t.output!==i&&(t.input!==s||void 0===s)));0===n.length?e.delete(r):e.set(r,n)}}for(const[n,r]of e)r.forEach((e=>{Ne(n)?t.connect(n,e.output,e.input):t.connect(n,e.output)}))})})(i),Bt.set(this,i),qt.set(this,new Set),"closed"!==e.state&&r&&se(this),t(this,s,i)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(t){this._nativeAudioNode.channelCount=t}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(t){this._nativeAudioNode.channelCountMode=t}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(t){this._nativeAudioNode.channelInterpretation=t}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(t,n=0,a=0){if(n<0||n>=this._nativeAudioNode.numberOfOutputs)throw i();const h=l(this._context),u=p(h);if(d(t)||f(t))throw s();if(be(t)){const i=Oe(t);try{const e=Ae(this._nativeAudioNode,i,n,a),r=je(this);(u||r)&&this._nativeAudioNode.disconnect(...e),"closed"!==this.context.state&&!r&&je(t)&&se(t)}catch(t){if(12===t.code)throw s();throw t}if(e(this,t,n,a,u)){const e=c([this],t);Ue(e,r(u))}return t}const v=Pe(t);if("playbackRate"===v.name&&1024===v.maxValue)throw o();try{this._nativeAudioNode.connect(v,n),(u||je(this))&&this._nativeAudioNode.disconnect(v,n)}catch(t){if(12===t.code)throw s();throw t}if(((t,e,n,r)=>{const{activeInputs:i,passiveInputs:s}=ye(e),{outputs:o}=me(t),a=ie(t),c=o=>{const a=Oe(t),c=Pe(e);if(o){const e=Te(s,t,n);xe(i,t,e,!1),r||We(t)||a.connect(c,n)}else{const e=((t,e,n)=>ne(t,(t=>t[0]===e&&t[1]===n)))(i,t,n);Ee(s,e,!1),r||We(t)||a.disconnect(c,n)}};return!!ke(o,[e,n],(t=>t[0]===e&&t[1]===n),!0)&&(a.add(c),ve(t)?xe(i,t,[n,c],!0):Ee(s,[t,n,c],!0),!0)})(this,t,n,u)){const e=c([this],t);Ue(e,r(u))}}disconnect(t,e,n){let r;const o=l(this._context),h=p(o);if(void 0===t)r=((t,e)=>{const n=me(t),r=[];for(const i of n.outputs)Me(i)?Ve(t,e,...i):De(t,e,...i),r.push(i[0]);return n.outputs.clear(),r})(this,h);else if("number"==typeof t){if(t<0||t>=this.numberOfOutputs)throw i();r=((t,e,n)=>{const r=me(t),i=[];for(const s of r.outputs)s[1]===n&&(Me(s)?Ve(t,e,...s):De(t,e,...s),i.push(s[0]),r.outputs.delete(s));return i})(this,h,t)}else{if(void 0!==e&&(e<0||e>=this.numberOfOutputs))throw i();if(be(t)&&void 0!==n&&(n<0||n>=t.numberOfInputs))throw i();if(r=((t,e,n,r,i)=>{const s=me(t);return Array.from(s.outputs).filter((t=>!(t[0]!==n||void 0!==r&&t[1]!==r||void 0!==i&&t[2]!==i))).map((n=>(Me(n)?Ve(t,e,...n):De(t,e,...n),s.outputs.delete(n),n[0])))})(this,h,t,e,n),0===r.length)throw s()}for(const t of r){const e=c([this],t);Ue(e,a)}}})((_n=zt,(t,e,n)=>{const r=[];for(let t=0;t<n.numberOfInputs;t+=1)r.push(new Set);_n.set(t,{activeInputs:r,outputs:new Set,passiveInputs:new WeakMap,renderer:e})}),((t,e,n,r,i,s,o,a,c,h,l,u,d)=>{const f=new WeakMap;return(p,v,w,m,y)=>{const{activeInputs:g,passiveInputs:b}=s(v),{outputs:M}=s(p),k=a(p),x=s=>{const a=c(v),h=c(p);if(s){const e=re(b,p,w,m);t(g,p,e,!1),y||u(p)||n(h,a,w,m),d(v)&&se(v)}else{const t=r(g,p,w,m);e(b,m,t,!1),y||u(p)||i(h,a,w,m);const n=o(v);if(0===n)l(v)&&ce(v,g);else{const t=f.get(v);void 0!==t&&clearTimeout(t),f.set(v,setTimeout((()=>{l(v)&&ce(v,g)}),1e3*n))}}};return!!h(M,[v,w,m],(t=>t[0]===v&&t[1]===w&&t[2]===m),!0)&&(k.add(x),l(p)?t(g,p,[w,m,x],!0):e(b,m,[p,w,x],!0),!0)}})(un,dn,Ae,fn,Re,me,pn,ie,Oe,ke,ve,We,je),vn,((t,e,n,r,i,s)=>o=>(a,c)=>{const h=t.get(a);if(void 0===h){if(!o&&s(a)){const t=r(a),{outputs:s}=n(a);for(const n of s)if(Me(n)){const i=r(n[0]);e(t,i,n[1],n[2])}else{const e=i(n[0]);t.disconnect(e,n[1])}}t.set(a,c)}else t.set(a,h+c)})(Xt,Re,me,Oe,Pe,ve),ue,(()=>new DOMException("","InvalidAccessError")),sn,((t,e,n,r,i,s,o,a)=>(c,h)=>{const l=e.get(c);if(void 0===l)throw new Error("Missing the expected cycle count.");const u=s(c.context),d=a(u);if(l===h){if(e.delete(c),!d&&o(c)){const e=r(c),{outputs:s}=n(c);for(const n of s)if(Me(n)){const i=r(n[0]);t(e,i,n[1],n[2])}else{const t=i(n[0]);e.connect(t,n[1])}}}else e.set(c,l-h)})(Ae,Xt,me,Oe,Pe,kn,ve,Cn),((t,e,n)=>function r(i,s){const o=be(s)?s:n(t,s);if((t=>"delayTime"in t)(o))return[];if(i[0]===o)return[i];if(i.includes(o))return[];const{outputs:a}=e(o);return Array.from(a).map((t=>r([...i,o],t[0]))).reduce(((t,e)=>t.concat(e)),[])})(An,me,ee),Sn,kn,Tn,Rn,On,Cn,Pn);var jn,_n;const Un=new WeakSet,Nn=(t=>null===t?null:t.hasOwnProperty("AudioBuffer")?t.AudioBuffer:null)(gn),Vn=(Dn=new Uint32Array(1),t=>(Dn[0]=t,Dn[0]));var Dn;const Ln=((t,e)=>n=>{n.copyFromChannel=(r,i,s=0)=>{const o=t(s),a=t(i);if(a>=n.numberOfChannels)throw e();const c=n.length,h=n.getChannelData(a),l=r.length;for(let t=o<0?-o:0;t+o<c&&t<l;t+=1)r[t]=h[t+o]},n.copyToChannel=(r,i,s=0)=>{const o=t(s),a=t(i);if(a>=n.numberOfChannels)throw e();const c=n.length,h=n.getChannelData(a),l=r.length;for(let t=o<0?-o:0;t+o<c&&t<l;t+=1)h[t+o]=r[t]}})(Vn,ue),zn=(t=>e=>{e.copyFromChannel=(n=>(r,i,s=0)=>{const o=t(s),a=t(i);if(o<e.length)return n.call(e,r,a,o)})(e.copyFromChannel),e.copyToChannel=(n=>(r,i,s=0)=>{const o=t(s),a=t(i);if(o<e.length)return n.call(e,r,a,o)})(e.copyToChannel)})(Vn),Bn=((t,e,n,r,i,s,o,a)=>{let c=null;return class h{constructor(h){if(null===i)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:l,numberOfChannels:u,sampleRate:d}={...de,...h};null===c&&(c=new i(1,1,44100));const f=null!==r&&e(s,s)?new r({length:l,numberOfChannels:u,sampleRate:d}):c.createBuffer(u,l,d);if(0===f.numberOfChannels)throw n();return"function"!=typeof f.copyFromChannel?(o(f),(t=>{var e;t.getChannelData=(e=t.getChannelData,n=>{try{return e.call(t,n)}catch(t){if(12===t.code)throw ue();throw t}})})(f)):e(le,(()=>le(f)))||a(f),t.add(f),f}static[Symbol.hasInstance](e){return null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===h.prototype||t.has(e)}}})(Un,vn,sn,Nn,En,(t=>()=>{if(null===t)return!1;try{new t({length:1,sampleRate:44100})}catch{return!1}return!0})(Nn),Ln,zn),Fn=(t=>(e,n)=>{const r=t(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});n.connect(r).connect(e.destination);const i=()=>{n.removeEventListener("ended",i),n.disconnect(r),r.disconnect()};n.addEventListener("ended",i)})(nn),Hn=((t,e,n)=>async(r,i,s)=>{const o=e(r);await Promise.all(Array.from(o.activeInputs).map((async([e,r])=>{const o=t(e),a=await o.render(e,i);n(e)||a.connect(s,r)})))})(bn,ye,We),$n=(t=>(e,n,r)=>t(n,e,r))(Hn),qn=((t,e,n,r,i,s,o,a,c,h)=>(c,l)=>{const u=c.createBufferSource();return Ke(u,l),Ge(u,l,"playbackRate"),Ye(u,l,"buffer"),Ye(u,l,"loop"),Ye(u,l,"loopEnd"),Ye(u,l,"loopStart"),e(n,(()=>n(c)))||(t=>{t.start=(e=>{let n=!1;return(r=0,i=0,s)=>{if(n)throw Xe();e.call(t,r,i,s),n=!0}})(t.start)})(u),e(r,(()=>r(c)))||(t=>{var e;t.start=(e=t.start,(n=0,r=0,i)=>{const s=t.buffer,o=null===s?r:Math.min(s.duration,r);null!==s&&o>s.duration-.5/t.context.sampleRate?e.call(t,n,0,0):e.call(t,n,o,i)})})(u),e(i,(()=>i(c)))||h(u,c),e(s,(()=>s(c)))||Je(u),e(o,(()=>o(c)))||((t,e)=>{const n=e.createGain();t.connect(n);const r=(i=t.disconnect,()=>{i.call(t,n),t.removeEventListener("ended",r)});var i;t.addEventListener("ended",r),en(t,n),t.stop=(e=>{let r=!1;return(i=0)=>{if(r)try{e.call(t,i)}catch{n.gain.setValueAtTime(0,i)}else e.call(t,i),r=!0}})(t.stop)})(u,c),e(a,(()=>a(c)))||Qe(u),t(c,u),u})(Fn,vn,(t=>{const e=t.createBufferSource();e.start();try{e.start()}catch{return!0}return!1}),(t=>{const e=t.createBufferSource(),n=t.createBuffer(1,1,44100);e.buffer=n;try{e.start(0,1)}catch{return!1}return!0}),(t=>{const e=t.createBufferSource();e.start();try{e.stop()}catch{return!1}return!0}),cn,(t=>{const e=t.createBuffer(1,1,44100),n=t.createBufferSource();n.buffer=e,n.start(),n.stop();try{return n.stop(),!0}catch{return!1}}),hn,0,(t=>(e,n)=>{const r=n.createBuffer(1,1,44100);null===e.buffer&&(e.buffer=r),t(e,"buffer",(t=>()=>{const n=t.call(e);return n===r?null:n}),(t=>n=>t.call(e,null===n?r:n)))})(on)),Xn=((t,e)=>(n,r,i)=>(t(r).replay(i),e(r,n,i)))((t=>e=>{const n=t(e);if(null===n.renderer)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return n.renderer})(ye),Hn),Zn=((t,e,n,r,i)=>()=>{const s=new WeakMap;let o=null,a=null;return{set start(t){o=t},set stop(t){a=t},render(c,h){const l=s.get(h);return void 0!==l?Promise.resolve(l):(async(c,h)=>{let l=n(c);const u=he(l,h);return u||(l=e(h,{buffer:l.buffer,channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,loop:l.loop,loopEnd:l.loopEnd,loopStart:l.loopStart,playbackRate:l.playbackRate.value}),null!==o&&l.start(...o),null!==a&&l.stop(a)),s.set(h,l),u?await t(h,c.playbackRate,l.playbackRate):await r(h,c.playbackRate,l.playbackRate),await i(c,h,l),l})(c,h)}}})($n,qn,Oe,Xn,Mn),Yn=((t,e,n,r,i,s,o,a,c,h,l,u,d)=>(r,f,p,v=null,w=null)=>{const m=p.value,y=new Dt.AutomationEventList(m),g=f?(t=>({replay(e){for(const n of t)if("exponentialRampToValue"===n.type){const{endTime:t,value:r}=n;e.exponentialRampToValueAtTime(r,t)}else if("linearRampToValue"===n.type){const{endTime:t,value:r}=n;e.linearRampToValueAtTime(r,t)}else if("setTarget"===n.type){const{startTime:t,target:r,timeConstant:i}=n;e.setTargetAtTime(r,t,i)}else if("setValue"===n.type){const{startTime:t,value:r}=n;e.setValueAtTime(r,t)}else{if("setValueCurve"!==n.type)throw new Error("Can't apply an unknown automation.");{const{duration:t,startTime:r,values:i}=n;e.setValueCurveAtTime(i,r,t)}}}}))(y):null,b={get defaultValue(){return m},get maxValue(){return null===v?p.maxValue:v},get minValue(){return null===w?p.minValue:w},get value(){return p.value},set value(t){p.value=t,b.setValueAtTime(t,r.context.currentTime)},cancelAndHoldAtTime(t){if("function"==typeof p.cancelAndHoldAtTime)null===g&&y.flush(r.context.currentTime),y.add(i(t)),p.cancelAndHoldAtTime(t);else{const e=Array.from(y).pop();null===g&&y.flush(r.context.currentTime),y.add(i(t));const n=Array.from(y).pop();p.cancelScheduledValues(t),e!==n&&void 0!==n&&("exponentialRampToValue"===n.type?p.exponentialRampToValueAtTime(n.value,n.endTime):"linearRampToValue"===n.type?p.linearRampToValueAtTime(n.value,n.endTime):"setValue"===n.type?p.setValueAtTime(n.value,n.startTime):"setValueCurve"===n.type&&p.setValueCurveAtTime(n.values,n.startTime,n.duration))}return b},cancelScheduledValues:t=>(null===g&&y.flush(r.context.currentTime),y.add(s(t)),p.cancelScheduledValues(t),b),exponentialRampToValueAtTime(t,e){if(0===t)throw new RangeError;if(!Number.isFinite(e)||e<0)throw new RangeError;const n=r.context.currentTime;return null===g&&y.flush(n),0===Array.from(y).length&&(y.add(h(m,n)),p.setValueAtTime(m,n)),y.add(o(t,e)),p.exponentialRampToValueAtTime(t,e),b},linearRampToValueAtTime(t,e){const n=r.context.currentTime;return null===g&&y.flush(n),0===Array.from(y).length&&(y.add(h(m,n)),p.setValueAtTime(m,n)),y.add(a(t,e)),p.linearRampToValueAtTime(t,e),b},setTargetAtTime:(t,e,n)=>(null===g&&y.flush(r.context.currentTime),y.add(c(t,e,n)),p.setTargetAtTime(t,e,n),b),setValueAtTime:(t,e)=>(null===g&&y.flush(r.context.currentTime),y.add(h(t,e)),p.setValueAtTime(t,e),b),setValueCurveAtTime(t,e,n){const i=t instanceof Float32Array?t:new Float32Array(t);if(null!==u&&"webkitAudioContext"===u.name){const t=e+n,s=r.context.sampleRate,o=Math.ceil(e*s),a=Math.floor(t*s),c=a-o,h=new Float32Array(c);for(let t=0;t<c;t+=1){const r=(i.length-1)/n*((o+t)/s-e),a=Math.floor(r),c=Math.ceil(r);h[t]=a===c?i[a]:(1-(r-a))*i[a]+(1-(c-r))*i[c]}null===g&&y.flush(r.context.currentTime),y.add(l(h,e,n)),p.setValueCurveAtTime(h,e,n);const u=a/s;u<t&&d(b,h[h.length-1],u),d(b,i[i.length-1],t)}else null===g&&y.flush(r.context.currentTime),y.add(l(i,e,n)),p.setValueCurveAtTime(i,e,n);return b}};return n.set(b,p),e.set(b,r),t(b,g),b})((Kn=Ft,(t,e)=>{Kn.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})}),An,Ht,0,Dt.createCancelAndHoldAutomationEvent,Dt.createCancelScheduledValuesAutomationEvent,Dt.createExponentialRampToValueAutomationEvent,Dt.createLinearRampToValueAutomationEvent,Dt.createSetTargetAutomationEvent,Dt.createSetValueAutomationEvent,Dt.createSetValueCurveAutomationEvent,In,an);var Kn;const Gn=((t,e,n,r,i,s,o,a)=>class extends t{constructor(t,r){const a=s(t),c={...we,...r},h=i(a,c),l=o(a),u=l?e():null;super(t,!1,h,u),this._audioBufferSourceNodeRenderer=u,this._isBufferNullified=!1,this._isBufferSet=null!==c.buffer,this._nativeAudioBufferSourceNode=h,this._onended=null,this._playbackRate=n(this,l,h.playbackRate,pe,fe)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(t){if(this._nativeAudioBufferSourceNode.buffer=t,null!==t){if(this._isBufferSet)throw r();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(t){this._nativeAudioBufferSourceNode.loop=t}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(t){this._nativeAudioBufferSourceNode.loopEnd=t}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(t){this._nativeAudioBufferSourceNode.loopStart=t}get onended(){return this._onended}set onended(t){const e="function"==typeof t?a(this,t):null;this._nativeAudioBufferSourceNode.onended=e;const n=this._nativeAudioBufferSourceNode.onended;this._onended=null!==n&&n===e?t:n}get playbackRate(){return this._playbackRate}start(t=0,e=0,n){if(this._nativeAudioBufferSourceNode.start(t,e,n),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.start=void 0===n?[t,e]:[t,e,n]),"closed"!==this.context.state){se(this);const t=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",t),ve(this)&&ae(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeAudioBufferSourceNode.stop(t),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.stop=t)}})(Wn,Zn,Yn,Xe,qn,kn,Cn,ln),Jn=((t,e,n,r,i,s,o,a)=>class extends t{constructor(t,e){const n=s(t),r=o(n),c=i(n,e,r);super(t,!1,c,r?(t=>{const e=new WeakMap;return{render(n,r){const i=e.get(r);return void 0!==i?Promise.resolve(i):(async(n,r)=>{const i=r.destination;return e.set(r,i),await t(n,r,i),i})(n,r)}}})(a):null),this._isNodeOfNativeOfflineAudioContext=r,this._nativeAudioDestinationNode=c}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(t){if(this._isNodeOfNativeOfflineAudioContext)throw r();if(t>this._nativeAudioDestinationNode.maxChannelCount)throw n();this._nativeAudioDestinationNode.channelCount=t}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(t){if(this._isNodeOfNativeOfflineAudioContext)throw r();this._nativeAudioDestinationNode.channelCountMode=t}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}})(Wn,0,ue,Xe,((t,e)=>(n,r,i)=>{const s=n.destination;if(s.channelCount!==r)try{s.channelCount=r}catch{}i&&"explicit"!==s.channelCountMode&&(s.channelCountMode="explicit"),0===s.maxChannelCount&&Object.defineProperty(s,"maxChannelCount",{value:r});const o=t(n,{channelCount:r,channelCountMode:s.channelCountMode,channelInterpretation:s.channelInterpretation,gain:1});return e(o,"channelCount",(t=>()=>t.call(o)),(t=>e=>{t.call(o,e);try{s.channelCount=e}catch(t){if(e>s.maxChannelCount)throw t}})),e(o,"channelCountMode",(t=>()=>t.call(o)),(t=>e=>{t.call(o,e),s.channelCountMode=e})),e(o,"channelInterpretation",(t=>()=>t.call(o)),(t=>e=>{t.call(o,e),s.channelInterpretation=e})),Object.defineProperty(o,"maxChannelCount",{get:()=>s.maxChannelCount}),o.connect(s),o})(nn,on),kn,Cn,Mn),Qn=((t,e)=>(n,r,i)=>{const s=new Set;var o;return n.connect=(i=>(o,a=0,c=0)=>{const h=0===s.size;if(e(o))return i.call(n,o,a,c),t(s,[o,a,c],(t=>t[0]===o&&t[1]===a&&t[2]===c),!0),h&&r(),o;i.call(n,o,a),t(s,[o,a],(t=>t[0]===o&&t[1]===a),!0),h&&r()})(n.connect),n.disconnect=(o=n.disconnect,(t,r,a)=>{const c=s.size>0;if(void 0===t)o.apply(n),s.clear();else if("number"==typeof t){o.call(n,t);for(const e of s)e[1]===t&&s.delete(e)}else{e(t)?o.call(n,t,r,a):o.call(n,t,r);for(const e of s)e[0]!==t||void 0!==r&&e[1]!==r||void 0!==a&&e[2]!==a||s.delete(e)}c&&0===s.size&&i()}),n})(ke,Rn),tr=((t,e)=>(n,r)=>{r.channelCount=1,r.channelCountMode="explicit",Object.defineProperty(r,"channelCount",{get:()=>1,set:()=>{throw t()}}),Object.defineProperty(r,"channelCountMode",{get:()=>"explicit",set:()=>{throw t()}});const i=n.createBufferSource();e(r,(()=>{const t=r.numberOfInputs;for(let e=0;e<t;e+=1)i.connect(r,0,e)}),(()=>i.disconnect(r)))})(Xe,Qn),er=((t,e)=>(n,r)=>{const i=n.createChannelMerger(r.numberOfInputs);return null!==t&&"webkitAudioContext"===t.name&&e(n,i),Ke(i,r),i})(In,tr),nr=((t,e,n,r)=>(i,{offset:s,...o})=>{const a=i.createBuffer(1,2,44100),c=e(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),h=n(i,{...o,gain:s}),l=a.getChannelData(0);l[0]=1,l[1]=1,c.buffer=a,c.loop=!0;const u={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(t){h.channelCount=t},get channelCountMode(){return h.channelCountMode},set channelCountMode(t){h.channelCountMode=t},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(t){h.channelInterpretation=t},get context(){return h.context},get inputs(){return[]},get numberOfInputs(){return c.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get offset(){return h.gain},get onended(){return c.onended},set onended(t){c.onended=t},addEventListener:(...t)=>c.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>c.dispatchEvent(t[0]),removeEventListener:(...t)=>c.removeEventListener(t[0],t[1],t[2]),start(t=0){c.start.call(c,t)},stop(t=0){c.stop.call(c,t)}};return t(i,c),r(en(u,h),(()=>c.connect(h)),(()=>c.disconnect(h)))})(Fn,qn,nn,Qn),rr=((t,e,n,r,i)=>(s,o)=>{if(void 0===s.createConstantSource)return n(s,o);const a=s.createConstantSource();return Ke(a,o),Ge(a,o,"offset"),e(r,(()=>r(s)))||Je(a),e(i,(()=>i(s)))||Qe(a),t(s,a),a})(Fn,vn,nr,cn,hn),ir=((t,e,n,r)=>i=>t(Ze,(()=>Ze(i)))?Promise.resolve(t(r,r)).then((t=>{if(!t){const t=n(i,512,0,1);i.oncomplete=()=>{t.onaudioprocess=null,t.disconnect()},t.onaudioprocess=()=>i.currentTime,t.connect(i.destination)}return i.startRendering()})):new Promise((t=>{const n=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=e=>{n.disconnect(),t(e.renderedBuffer)},n.connect(i.destination),i.startRendering()})))(vn,nn,rn,((t,e)=>()=>{if(null===e)return Promise.resolve(!1);const n=new e(1,1,44100),r=t(n,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise((t=>{n.oncomplete=()=>{r.disconnect(),t(0!==n.currentTime)},n.startRendering()}))})(nn,En)),sr=((t,e,n,r,i,s,o,a)=>(c,h)=>{const l=h.listener,{forwardX:u,forwardY:d,forwardZ:f,positionX:p,positionY:v,positionZ:w,upX:m,upY:y,upZ:g}=void 0===l.forwardX?(()=>{const u=new Float32Array(1),d=e(h,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),f=o(h);let p=!1,v=[0,0,-1,0,1,0],w=[0,0,0];const m=()=>{if(p)return;p=!0;const t=r(h,256,9,0);t.onaudioprocess=({inputBuffer:t})=>{const e=[s(t,u,0),s(t,u,1),s(t,u,2),s(t,u,3),s(t,u,4),s(t,u,5)];e.some(((t,e)=>t!==v[e]))&&(l.setOrientation(...e),v=e);const n=[s(t,u,6),s(t,u,7),s(t,u,8)];n.some(((t,e)=>t!==w[e]))&&(l.setPosition(...n),w=n)},d.connect(t)},y=t=>e=>{e!==v[t]&&(v[t]=e,l.setOrientation(...v))},g=t=>e=>{e!==w[t]&&(w[t]=e,l.setPosition(...w))},b=(e,r,s)=>{const o=n(h,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:r});o.connect(d,0,e),o.start(),Object.defineProperty(o.offset,"defaultValue",{get:()=>r});const l=t({context:c},f,o.offset,pe,fe);var u,p,v,w,y,g,b;return a(l,"value",(t=>()=>t.call(l)),(t=>e=>{try{t.call(l,e)}catch(t){if(9!==t.code)throw t}m(),f&&s(e)})),l.cancelAndHoldAtTime=(u=l.cancelAndHoldAtTime,f?()=>{throw i()}:(...t)=>{const e=u.apply(l,t);return m(),e}),l.cancelScheduledValues=(p=l.cancelScheduledValues,f?()=>{throw i()}:(...t)=>{const e=p.apply(l,t);return m(),e}),l.exponentialRampToValueAtTime=(v=l.exponentialRampToValueAtTime,f?()=>{throw i()}:(...t)=>{const e=v.apply(l,t);return m(),e}),l.linearRampToValueAtTime=(w=l.linearRampToValueAtTime,f?()=>{throw i()}:(...t)=>{const e=w.apply(l,t);return m(),e}),l.setTargetAtTime=(y=l.setTargetAtTime,f?()=>{throw i()}:(...t)=>{const e=y.apply(l,t);return m(),e}),l.setValueAtTime=(g=l.setValueAtTime,f?()=>{throw i()}:(...t)=>{const e=g.apply(l,t);return m(),e}),l.setValueCurveAtTime=(b=l.setValueCurveAtTime,f?()=>{throw i()}:(...t)=>{const e=b.apply(l,t);return m(),e}),l};return{forwardX:b(0,0,y(0)),forwardY:b(1,0,y(1)),forwardZ:b(2,-1,y(2)),positionX:b(6,0,g(0)),positionY:b(7,0,g(1)),positionZ:b(8,0,g(2)),upX:b(3,0,y(3)),upY:b(4,1,y(4)),upZ:b(5,0,y(5))}})():l;return{get forwardX(){return u},get forwardY(){return d},get forwardZ(){return f},get positionX(){return p},get positionY(){return v},get positionZ(){return w},get upX(){return m},get upY(){return y},get upZ(){return g}}})(Yn,er,rr,rn,sn,((t,e,n)=>void 0===t.copyFromChannel?t.getChannelData(n)[0]:(t.copyFromChannel(e,n),e[0])),Cn,on),or=new WeakMap,ar=((t,e,n,r,i,s)=>class extends n{constructor(n,s){super(n),this._nativeContext=n,$t.set(this,n),r(n)&&i.set(n,new Set),this._destination=new t(this,s),this._listener=e(this,n),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(t){const e="function"==typeof t?s(this,t):null;this._nativeContext.onstatechange=e;const n=this._nativeContext.onstatechange;this._onstatechange=null!==n&&n===e?t:n}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}})(Jn,sr,Sn,Cn,or,ln),cr=null!==gn&&gn.isSecureContext,hr=(t=>(e,n,r)=>{Object.defineProperties(t,{currentFrame:{configurable:!0,get:()=>Math.round(e*n)},currentTime:{configurable:!0,get:()=>e}});try{return r()}finally{null!==t&&(delete t.currentFrame,delete t.currentTime)}})(gn),lr=new WeakMap,ur=((t,e)=>n=>{let r=t.get(n);if(void 0!==r)return r;if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");return r=new e(1,1,44100),t.set(n,r),r})(lr,En),dr=cr?((t,e,n,r,i,s,o,a,c,h,l,u,d)=>{let f=0;return(p,v,w={credentials:"omit"})=>{const m=l.get(p);if(void 0!==m&&m.has(v))return Promise.resolve();const y=h.get(p);if(void 0!==y){const t=y.get(v);if(void 0!==t)return t}const g=s(p),b=void 0===g.audioWorklet?i(v).then((([t,e])=>{const[r,i]=Jt(t,e);return n(`${r};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${i}\n})})(window,'_AWGS')`)})).then((()=>{const t=d._AWGS.pop();if(void 0===t)throw new SyntaxError;r(g.currentTime,g.sampleRate,(()=>t(class{},void 0,((t,n)=>{if(""===t.trim())throw e();const r=Zt.get(g);if(void 0!==r){if(r.has(t))throw e();te(n),Qt(n.parameterDescriptors),r.set(t,n)}else te(n),Qt(n.parameterDescriptors),Zt.set(g,new Map([[t,n]]))}),g.sampleRate,void 0,void 0)))})):Promise.all([i(v),Promise.resolve(t(u,u))]).then((([[t,e],n])=>{const r=f+1;f=r;const[i,s]=Jt(t,e),h=new Blob([`${i};((AudioWorkletProcessor,registerProcessor)=>{${s}\n})(${n?"AudioWorkletProcessor":"class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}"},(n,p)=>registerProcessor(n,class extends p{${n?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${n?"":"i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}));registerProcessor('__sac${r}',class extends AudioWorkletProcessor{process(){return !1}})`],{type:"application/javascript; charset=utf-8"}),l=URL.createObjectURL(h);return g.audioWorklet.addModule(l,w).then((()=>{if(a(g))return g;const t=o(g);return t.audioWorklet.addModule(l,w).then((()=>t))})).then((t=>{if(null===c)throw new SyntaxError;try{new c(t,`__sac${r}`)}catch{throw new SyntaxError}})).finally((()=>URL.revokeObjectURL(l)))}));return void 0===y?h.set(p,new Map([[v,b]])):y.set(v,b),b.then((()=>{const t=l.get(p);void 0===t?l.set(p,new Set([v])):t.add(v)})).finally((()=>{const t=h.get(p);void 0!==t&&t.delete(v)})),b}})(vn,sn,(t=>e=>new Promise(((n,r)=>{if(null===t)return void r(new SyntaxError);const i=t.document.head;if(null===i)r(new SyntaxError);else{const s=t.document.createElement("script"),o=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(o),c=t.onerror,h=()=>{t.onerror=c,URL.revokeObjectURL(a)};t.onerror=(e,n,i,s,o)=>n===a||n===t.location.href&&1===i&&1===s?(h(),r(o),!1):null!==c?c(e,n,i,s,o):void 0,s.onerror=()=>{h(),r(new SyntaxError)},s.onload=()=>{h(),n()},s.src=a,s.type="module",i.appendChild(s)}})))(gn),hr,(async t=>{try{const e=await fetch(t);if(e.ok)return[await e.text(),e.url]}catch{}throw new DOMException("","AbortError")}),kn,ur,Cn,Pn,new WeakMap,new WeakMap,((t,e)=>async()=>{if(null===t)return!0;if(null===e)return!1;const n=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),r=new e(1,128,44100),i=URL.createObjectURL(n);let s=!1,o=!1;try{await r.audioWorklet.addModule(i);const e=new t(r,"a",{numberOfOutputs:0}),n=r.createOscillator();e.port.onmessage=()=>s=!0,e.onprocessorerror=()=>o=!0,n.connect(e),n.start(0),await r.startRendering(),await new Promise((t=>setTimeout(t)))}catch{}finally{URL.revokeObjectURL(i)}return s&&!o})(Pn,En),gn):void 0,fr=((t,e,n,r)=>class extends t{constructor(t,e){const i=n(t),s=((t,{mediaStream:e})=>{const n=e.getAudioTracks();n.sort(((t,e)=>t.id<e.id?-1:t.id>e.id?1:0));const r=n.slice(0,1),i=t.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(i,"mediaStream",{value:e}),i})(i,e);if(r(i))throw new TypeError;super(t,!0,s,null),this._nativeMediaStreamAudioSourceNode=s}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}})(Wn,0,kn,Cn),pr=(t=>e=>{const n=t.get(e);if(void 0===n)throw new Error("The context has no set of AudioWorkletNodes.");return n})(or),vr=(t=>(e,n)=>{t(e).add(n)})(pr),wr=(t=>(e,n,r=0,i=0)=>{const s=e[r];if(void 0===s)throw t();return Ne(n)?s.connect(n,0,i):s.connect(n,0)})(ue),mr=(t=>(e,n)=>{t(e).delete(n)})(pr),yr=(t=>(e,n,r,i=0)=>void 0===n?e.forEach((t=>t.disconnect())):"number"==typeof n?qe(t,e,n).disconnect():Ne(n)?void 0===r?e.forEach((t=>t.disconnect(n))):void 0===i?qe(t,e,r).disconnect(n,0):qe(t,e,r).disconnect(n,0,i):void 0===r?e.forEach((t=>t.disconnect(n))):qe(t,e,r).disconnect(n,0))(ue),gr=new WeakMap,br=((t,e)=>n=>e(t,n))(gr,ee),Mr=((t,e,n,r,i,s,o,a,c,h,l,u,d)=>(f,p,v,w)=>{if(0===w.numberOfInputs&&0===w.numberOfOutputs)throw c();const m=Array.isArray(w.outputChannelCount)?w.outputChannelCount:Array.from(w.outputChannelCount);if(m.some((t=>t<1)))throw c();if(m.length!==w.numberOfOutputs)throw e();if("explicit"!==w.channelCountMode)throw c();const y=w.channelCount*w.numberOfInputs,g=m.reduce(((t,e)=>t+e),0),b=void 0===v.parameterDescriptors?0:v.parameterDescriptors.length;if(y+b>6||g>6)throw c();const M=new MessageChannel,k=[],x=[];for(let t=0;t<w.numberOfInputs;t+=1)k.push(o(f,{channelCount:w.channelCount,channelCountMode:w.channelCountMode,channelInterpretation:w.channelInterpretation,gain:1})),x.push(i(f,{channelCount:w.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:w.channelCount}));const E=[];if(void 0!==v.parameterDescriptors)for(const{defaultValue:t,maxValue:e,minValue:n,name:r}of v.parameterDescriptors){const i=s(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:void 0!==w.parameterData[r]?w.parameterData[r]:void 0===t?0:t});Object.defineProperties(i.offset,{defaultValue:{get:()=>void 0===t?0:t},maxValue:{get:()=>void 0===e?pe:e},minValue:{get:()=>void 0===n?fe:n}}),E.push(i)}const C=r(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,y+b)}),A=((t,e)=>null===t?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(t*e))))))(p,f.sampleRate),S=a(f,A,y+b,Math.max(1,g)),I=i(f,{channelCount:Math.max(1,g),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,g)}),T=[];for(let t=0;t<w.numberOfOutputs;t+=1)T.push(r(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:m[t]}));for(let t=0;t<w.numberOfInputs;t+=1){k[t].connect(x[t]);for(let e=0;e<w.channelCount;e+=1)x[t].connect(C,e,t*w.channelCount+e)}const R=new Le(void 0===v.parameterDescriptors?[]:v.parameterDescriptors.map((({name:t},e)=>{const n=E[e];return n.connect(C,0,y+e),n.start(0),[t,n.offset]})));C.connect(S);let O=w.channelInterpretation,P=null;const W=0===w.numberOfOutputs?[S]:T,j={get bufferSize(){return A},get channelCount(){return w.channelCount},set channelCount(t){throw n()},get channelCountMode(){return w.channelCountMode},set channelCountMode(t){throw n()},get channelInterpretation(){return O},set channelInterpretation(t){for(const e of k)e.channelInterpretation=t;O=t},get context(){return S.context},get inputs(){return k},get numberOfInputs(){return w.numberOfInputs},get numberOfOutputs(){return w.numberOfOutputs},get onprocessorerror(){return P},set onprocessorerror(t){"function"==typeof P&&j.removeEventListener("processorerror",P),P="function"==typeof t?t:null,"function"==typeof P&&j.addEventListener("processorerror",P)},get parameters(){return R},get port(){return M.port2},addEventListener:(...t)=>S.addEventListener(t[0],t[1],t[2]),connect:t.bind(null,W),disconnect:h.bind(null,W),dispatchEvent:(...t)=>S.dispatchEvent(t[0]),removeEventListener:(...t)=>S.removeEventListener(t[0],t[1],t[2])},_=new Map;var U,N;M.port1.addEventListener=(U=M.port1.addEventListener,(...t)=>{if("message"===t[0]){const e="function"==typeof t[1]?t[1]:"object"==typeof t[1]&&null!==t[1]&&"function"==typeof t[1].handleEvent?t[1].handleEvent:null;if(null!==e){const n=_.get(t[1]);void 0!==n?t[1]=n:(t[1]=t=>{l(f.currentTime,f.sampleRate,(()=>e(t)))},_.set(e,t[1]))}}return U.call(M.port1,t[0],t[1],t[2])}),M.port1.removeEventListener=(N=M.port1.removeEventListener,(...t)=>{if("message"===t[0]){const e=_.get(t[1]);void 0!==e&&(_.delete(t[1]),t[1]=e)}return N.call(M.port1,t[0],t[1],t[2])});let V=null;Object.defineProperty(M.port1,"onmessage",{get:()=>V,set:t=>{"function"==typeof V&&M.port1.removeEventListener("message",V),V="function"==typeof t?t:null,"function"==typeof V&&(M.port1.addEventListener("message",V),M.port1.start())}}),v.prototype.port=M.port1;let D=null;const L=((t,e,n,r)=>{let i=Yt.get(t);void 0===i&&(i=new WeakMap,Yt.set(t,i));const s=(async(t,e)=>{const n=await(t=>new Promise(((e,n)=>{const{port1:r,port2:i}=new MessageChannel;r.onmessage=({data:t})=>{r.close(),i.close(),e(t)},r.onmessageerror=({data:t})=>{r.close(),i.close(),n(t)},i.postMessage(t)})))(e);return new t(n)})(n,r);return i.set(e,s),s})(f,j,v,w);L.then((t=>D=t));const z=He(w.numberOfInputs,w.channelCount),B=He(w.numberOfOutputs,m),F=void 0===v.parameterDescriptors?[]:v.parameterDescriptors.reduce(((t,{name:e})=>({...t,[e]:new Float32Array(128)})),{});let H=!0;const $=()=>{w.numberOfOutputs>0&&S.disconnect(I);for(let t=0,e=0;t<w.numberOfOutputs;t+=1){const n=T[t];for(let r=0;r<m[t];r+=1)I.disconnect(n,e+r,r);e+=m[t]}},q=new Map;S.onaudioprocess=({inputBuffer:t,outputBuffer:e})=>{if(null!==D){const n=u(j);for(let r=0;r<A;r+=128){for(let e=0;e<w.numberOfInputs;e+=1)for(let n=0;n<w.channelCount;n+=1)Be(t,z[e],n,n,r);void 0!==v.parameterDescriptors&&v.parameterDescriptors.forEach((({name:e},n)=>{Be(t,F,e,y+n,r)}));for(let t=0;t<w.numberOfInputs;t+=1)for(let e=0;e<m[t];e+=1)0===B[t][e].byteLength&&(B[t][e]=new Float32Array(128));try{const t=z.map(((t,e)=>{if(n[e].size>0)return q.set(e,A/128),t;const r=q.get(e);return void 0===r?[]:(t.every((t=>t.every((t=>0===t))))&&(1===r?q.delete(e):q.set(e,r-1)),t)})),i=l(f.currentTime+r/f.sampleRate,f.sampleRate,(()=>D.process(t,B,F)));H=i;for(let t=0,n=0;t<w.numberOfOutputs;t+=1){for(let i=0;i<m[t];i+=1)Fe(e,B[t],i,n+i,r);n+=m[t]}}catch(t){H=!1,j.dispatchEvent(new ErrorEvent("processorerror",{colno:t.colno,filename:t.filename,lineno:t.lineno,message:t.message}))}if(!H){for(let t=0;t<w.numberOfInputs;t+=1){k[t].disconnect(x[t]);for(let e=0;e<w.channelCount;e+=1)x[r].disconnect(C,e,t*w.channelCount+e)}if(void 0!==v.parameterDescriptors){const t=v.parameterDescriptors.length;for(let e=0;e<t;e+=1){const t=E[e];t.disconnect(C,0,y+e),t.stop()}}C.disconnect(S),S.onaudioprocess=null,X?$():K();break}}}};let X=!1;const Z=o(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),Y=()=>S.connect(Z).connect(f.destination),K=()=>{S.disconnect(Z),Z.disconnect()};return Y(),d(j,(()=>{if(H){K(),w.numberOfOutputs>0&&S.connect(I);for(let t=0,e=0;t<w.numberOfOutputs;t+=1){const n=T[t];for(let r=0;r<m[t];r+=1)I.connect(n,e+r,r);e+=m[t]}}X=!0}),(()=>{H&&(Y(),$()),X=!1}))})(wr,ue,Xe,er,tn,rr,nn,rn,sn,yr,hr,br,Qn),kr=((t,e,n,r,i)=>(s,o,a,c,h,l)=>{if(null!==a)try{const e=new a(s,c,l),r=new Map;let o=null;if(Object.defineProperties(e,{channelCount:{get:()=>l.channelCount,set:()=>{throw t()}},channelCountMode:{get:()=>"explicit",set:()=>{throw t()}},onprocessorerror:{get:()=>o,set:t=>{"function"==typeof o&&e.removeEventListener("processorerror",o),o="function"==typeof t?t:null,"function"==typeof o&&e.addEventListener("processorerror",o)}}}),e.addEventListener=(d=e.addEventListener,(...t)=>{if("processorerror"===t[0]){const e="function"==typeof t[1]?t[1]:"object"==typeof t[1]&&null!==t[1]&&"function"==typeof t[1].handleEvent?t[1].handleEvent:null;if(null!==e){const n=r.get(t[1]);void 0!==n?t[1]=n:(t[1]=n=>{"error"===n.type?(Object.defineProperties(n,{type:{value:"processorerror"}}),e(n)):e(new ErrorEvent(t[0],{...n}))},r.set(e,t[1]))}}return d.call(e,"error",t[1],t[2]),d.call(e,...t)}),e.removeEventListener=(u=e.removeEventListener,(...t)=>{if("processorerror"===t[0]){const e=r.get(t[1]);void 0!==e&&(r.delete(t[1]),t[1]=e)}return u.call(e,"error",t[1],t[2]),u.call(e,t[0],t[1],t[2])}),0!==l.numberOfOutputs){const t=n(s,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return e.connect(t).connect(s.destination),i(e,(()=>t.disconnect()),(()=>t.connect(s.destination)))}return e}catch(t){if(11===t.code)throw r();throw t}var u,d;if(void 0===h)throw r();return(t=>{const{port1:e}=new MessageChannel;try{e.postMessage(t)}finally{e.close()}})(l),e(s,o,h,l)})(Xe,Mr,nn,sn,Qn),xr=((t,e,n,r,i,s,o,a,c,h,l,u,d,f,p,v)=>(w,m,y)=>{const g=new WeakMap;let b=null;return{render(M,k){a(k,M);const x=g.get(k);return void 0!==x?Promise.resolve(x):(async(a,M)=>{let k=l(a),x=null;const E=he(k,M),C=Array.isArray(m.outputChannelCount)?m.outputChannelCount:Array.from(m.outputChannelCount);if(null===u){const t=C.reduce(((t,e)=>t+e),0),n=i(M,{channelCount:Math.max(1,t),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,t)}),s=[];for(let t=0;t<a.numberOfOutputs;t+=1)s.push(r(M,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:C[t]}));const h=o(M,{channelCount:m.channelCount,channelCountMode:m.channelCountMode,channelInterpretation:m.channelInterpretation,gain:1});h.connect=e.bind(null,s),h.disconnect=c.bind(null,s),x=[n,s,h]}else E||(k=new u(M,w));if(g.set(M,null===x?k:x[2]),null!==x){if(null===b){if(void 0===y)throw new Error("Missing the processor constructor.");if(null===d)throw new Error("Missing the native OfflineAudioContext constructor.");const t=a.channelCount*a.numberOfInputs,e=void 0===y.parameterDescriptors?0:y.parameterDescriptors.length,n=t+e,c=async()=>{const c=new d(n,128*Math.ceil(a.context.length/128),M.sampleRate),h=[],l=[];for(let t=0;t<m.numberOfInputs;t+=1)h.push(o(c,{channelCount:m.channelCount,channelCountMode:m.channelCountMode,channelInterpretation:m.channelInterpretation,gain:1})),l.push(i(c,{channelCount:m.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:m.channelCount}));const u=await Promise.all(Array.from(a.parameters.values()).map((async t=>{const e=s(c,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:t.value});return await f(c,t,e.offset),e}))),w=r(c,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,t+e)});for(let t=0;t<m.numberOfInputs;t+=1){h[t].connect(l[t]);for(let e=0;e<m.channelCount;e+=1)l[t].connect(w,e,t*m.channelCount+e)}for(const[e,n]of u.entries())n.connect(w,0,t+e),n.start(0);return w.connect(c.destination),await Promise.all(h.map((t=>p(a,c,t)))),v(c)};b=$e(a,0===n?null:await c(),M,m,C,y,h)}const t=await b,e=n(M,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[c,l,u]=x;null!==t&&(e.buffer=t,e.start(0)),e.connect(c);for(let t=0,e=0;t<a.numberOfOutputs;t+=1){const n=l[t];for(let r=0;r<C[t];r+=1)c.connect(n,e+r,r);e+=C[t]}return u}if(E)for(const[e,n]of a.parameters.entries())await t(M,n,k.parameters.get(e));else for(const[t,e]of a.parameters.entries())await f(M,e,k.parameters.get(t));return await p(a,M,k),k})(M,k)}}})($n,wr,qn,er,tn,rr,nn,mr,yr,hr,Oe,Pn,En,Xn,Mn,ir),Er=(t=>e=>t.get(e))(lr),Cr=(t=>(e,n)=>{t.set(e,n)})(gr),Ar=cr?((t,e,n,r,i,s,o,a,c,h,l,u,d,f)=>class extends e{constructor(e,l,d){var f;const p=a(e),v=c(p),w=(t=>({...t,outputChannelCount:void 0!==t.outputChannelCount?t.outputChannelCount:1===t.numberOfInputs&&1===t.numberOfOutputs?[t.channelCount]:Array.from({length:t.numberOfOutputs},(()=>1))}))({...ze,...d});(t=>{const{port1:e,port2:n}=new MessageChannel;try{e.postMessage(t)}finally{e.close(),n.close()}})(w);const m=Zt.get(p),y=null==m?void 0:m.get(l),g=v||"closed"!==p.state?p:null!==(f=o(p))&&void 0!==f?f:p,b=i(g,v?null:e.baseLatency,h,l,y,w);super(e,!0,b,v?r(l,w,y):null);const M=[];b.parameters.forEach(((t,e)=>{const r=n(this,v,t);M.push([e,r])})),this._nativeAudioWorkletNode=b,this._onprocessorerror=null,this._parameters=new Le(M),v&&t(p,this);const{activeInputs:k}=s(this);u(b,k)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(t){const e="function"==typeof t?f(this,t):null;this._nativeAudioWorkletNode.onprocessorerror=e;const n=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=null!==n&&n===e?t:n}get parameters(){return null===this._parameters?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}})(vr,Wn,Yn,xr,kr,me,Er,kn,Cn,Pn,0,Cr,0,ln):void 0,Sr=((t,e,n,r,i)=>class extends r{constructor(t={}){if(null===i)throw new Error("Missing the native AudioContext constructor.");let n;try{n=new i(t)}catch(t){if(12===t.code&&"sampleRate is not in range"===t.message)throw e();throw t}if(null===n)throw new DOMException("","UnknownError");if(!(t=>void 0===t||"number"==typeof t||"string"==typeof t&&("balanced"===t||"interactive"===t||"playback"===t))(t.latencyHint))throw new TypeError(`The provided value '${t.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(void 0!==t.sampleRate&&n.sampleRate!==t.sampleRate)throw e();super(n,2);const{latencyHint:r}=t,{sampleRate:s}=n;if(this._baseLatency="number"==typeof n.baseLatency?n.baseLatency:"balanced"===r?512/s:"interactive"===r||void 0===r?256/s:"playback"===r?1024/s:128*Math.max(2,Math.min(128,Math.round(r*s/128)))/s,this._nativeAudioContext=n,"webkitAudioContext"===i.name?(this._nativeGainNode=n.createGain(),this._nativeOscillatorNode=n.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(n.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,"running"===n.state){this._state="suspended";const t=()=>{"suspended"===this._state&&(this._state=null),n.removeEventListener("statechange",t)};n.addEventListener("statechange",t)}}get baseLatency(){return this._baseLatency}get state(){return null!==this._state?this._state:this._nativeAudioContext.state}close(){return"closed"===this.state?this._nativeAudioContext.close().then((()=>{throw t()})):("suspended"===this._state&&(this._state=null),this._nativeAudioContext.close().then((()=>{null!==this._nativeGainNode&&null!==this._nativeOscillatorNode&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),ge(this.destination,[])})))}resume(){return"suspended"===this._state?new Promise(((t,e)=>{const n=()=>{this._nativeAudioContext.removeEventListener("statechange",n),"running"===this._nativeAudioContext.state?t():this.resume().then(t,e)};this._nativeAudioContext.addEventListener("statechange",n)})):this._nativeAudioContext.resume().catch((e=>{if(void 0===e||15===e.code)throw t();throw e}))}suspend(){return this._nativeAudioContext.suspend().catch((e=>{if(void 0===e)throw t();throw e}))}})(Xe,sn,0,ar,In),Ir="Missing AudioWorklet support. Maybe this is not running in a secure context.";var Tr,Rr={exports:{}},Or=(Tr||(Tr=1,function(t,e,n,r){function i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return s(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(t,e):void 0}}(t))||e){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw o}}}}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var o=function(){return r((function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=arguments.length>2?arguments[2]:void 0;if(n(this,t),r<0||void 0!==s&&s<0)throw new RangeError;var o=e.reduce((function(t,e){return t+e.byteLength}),0);if(r>o||void 0!==s&&r+s>o)throw new RangeError;var a,c=[],h=void 0===s?o-r:s,l=[],u=0,d=r,f=i(e);try{for(f.s();!(a=f.n()).done;){var p=a.value;0===l.length?p.byteLength>d?(u=p.byteLength-d,c.push(new DataView(p,d,u>h?h:u)),l.push(p)):d-=p.byteLength:u<h&&(u+=p.byteLength,c.push(new DataView(p,0,u>h?p.byteLength-u+h:p.byteLength)),l.push(p))}}catch(t){f.e(t)}finally{f.f()}this._buffers=l,this._byteLength=h,this._byteOffset=d,this._dataViews=c,this._internalBuffer=new DataView(new ArrayBuffer(8))}),[{key:"buffers",get:function(){return this._buffers}},{key:"byteLength",get:function(){return this._byteLength}},{key:"byteOffset",get:function(){return this._byteOffset}},{key:"getFloat32",value:function(t,e){return this._internalBuffer.setUint8(0,this.getUint8(t+0)),this._internalBuffer.setUint8(1,this.getUint8(t+1)),this._internalBuffer.setUint8(2,this.getUint8(t+2)),this._internalBuffer.setUint8(3,this.getUint8(t+3)),this._internalBuffer.getFloat32(0,e)}},{key:"getFloat64",value:function(t,e){return this._internalBuffer.setUint8(0,this.getUint8(t+0)),this._internalBuffer.setUint8(1,this.getUint8(t+1)),this._internalBuffer.setUint8(2,this.getUint8(t+2)),this._internalBuffer.setUint8(3,this.getUint8(t+3)),this._internalBuffer.setUint8(4,this.getUint8(t+4)),this._internalBuffer.setUint8(5,this.getUint8(t+5)),this._internalBuffer.setUint8(6,this.getUint8(t+6)),this._internalBuffer.setUint8(7,this.getUint8(t+7)),this._internalBuffer.getFloat64(0,e)}},{key:"getInt16",value:function(t,e){return this._internalBuffer.setUint8(0,this.getUint8(t+0)),this._internalBuffer.setUint8(1,this.getUint8(t+1)),this._internalBuffer.getInt16(0,e)}},{key:"getInt32",value:function(t,e){return this._internalBuffer.setUint8(0,this.getUint8(t+0)),this._internalBuffer.setUint8(1,this.getUint8(t+1)),this._internalBuffer.setUint8(2,this.getUint8(t+2)),this._internalBuffer.setUint8(3,this.getUint8(t+3)),this._internalBuffer.getInt32(0,e)}},{key:"getInt8",value:function(t){var n=this._findDataViewWithOffset(t),r=e(n,2);return r[0].getInt8(t-r[1])}},{key:"getUint16",value:function(t,e){return this._internalBuffer.setUint8(0,this.getUint8(t+0)),this._internalBuffer.setUint8(1,this.getUint8(t+1)),this._internalBuffer.getUint16(0,e)}},{key:"getUint32",value:function(t,e){return this._internalBuffer.setUint8(0,this.getUint8(t+0)),this._internalBuffer.setUint8(1,this.getUint8(t+1)),this._internalBuffer.setUint8(2,this.getUint8(t+2)),this._internalBuffer.setUint8(3,this.getUint8(t+3)),this._internalBuffer.getUint32(0,e)}},{key:"getUint8",value:function(t){var n=this._findDataViewWithOffset(t),r=e(n,2);return r[0].getUint8(t-r[1])}},{key:"setFloat32",value:function(t,e,n){this._internalBuffer.setFloat32(0,e,n),this.setUint8(t,this._internalBuffer.getUint8(0)),this.setUint8(t+1,this._internalBuffer.getUint8(1)),this.setUint8(t+2,this._internalBuffer.getUint8(2)),this.setUint8(t+3,this._internalBuffer.getUint8(3))}},{key:"setFloat64",value:function(t,e,n){this._internalBuffer.setFloat64(0,e,n),this.setUint8(t,this._internalBuffer.getUint8(0)),this.setUint8(t+1,this._internalBuffer.getUint8(1)),this.setUint8(t+2,this._internalBuffer.getUint8(2)),this.setUint8(t+3,this._internalBuffer.getUint8(3)),this.setUint8(t+4,this._internalBuffer.getUint8(4)),this.setUint8(t+5,this._internalBuffer.getUint8(5)),this.setUint8(t+6,this._internalBuffer.getUint8(6)),this.setUint8(t+7,this._internalBuffer.getUint8(7))}},{key:"setInt16",value:function(t,e,n){this._internalBuffer.setInt16(0,e,n),this.setUint8(t,this._internalBuffer.getUint8(0)),this.setUint8(t+1,this._internalBuffer.getUint8(1))}},{key:"setInt32",value:function(t,e,n){this._internalBuffer.setInt32(0,e,n),this.setUint8(t,this._internalBuffer.getUint8(0)),this.setUint8(t+1,this._internalBuffer.getUint8(1)),this.setUint8(t+2,this._internalBuffer.getUint8(2)),this.setUint8(t+3,this._internalBuffer.getUint8(3))}},{key:"setInt8",value:function(t,n){var r=this._findDataViewWithOffset(t),i=e(r,2);i[0].setInt8(t-i[1],n)}},{key:"setUint16",value:function(t,e,n){this._internalBuffer.setUint16(0,e,n),this.setUint8(t,this._internalBuffer.getUint8(0)),this.setUint8(t+1,this._internalBuffer.getUint8(1))}},{key:"setUint32",value:function(t,e,n){this._internalBuffer.setUint32(0,e,n),this.setUint8(t,this._internalBuffer.getUint8(0)),this.setUint8(t+1,this._internalBuffer.getUint8(1)),this.setUint8(t+2,this._internalBuffer.getUint8(2)),this.setUint8(t+3,this._internalBuffer.getUint8(3))}},{key:"setUint8",value:function(t,n){var r=this._findDataViewWithOffset(t),i=e(r,2);i[0].setUint8(t-i[1],n)}},{key:"_findDataViewWithOffset",value:function(t){var e,n=0,r=i(this._dataViews);try{for(r.s();!(e=r.n()).done;){var s=e.value,o=n+s.byteLength;if(t>=n&&t<o)return[s,n];n=o}}catch(t){r.e(t)}finally{r.f()}throw new RangeError}}])}();t.MultiBufferDataView=o}(Rr.exports,Rt,Pt,Vt)),Rr.exports);const Pr=(t,e)=>{if(e>=t.byteLength)return null;const n=t.getUint8(e);if(n>127)return 1;if(n>63)return 2;if(n>31)return 3;if(n>15)return 4;if(n>7)return 5;if(n>3)return 6;if(n>1)return 7;if(n>0)return 8;const r=Pr(t,e+1);return null===r?null:r+8},Wr=[],jr="undefined"==typeof window?null:window,_r=(Gr=null!==jr&&void 0!==jr.BlobEvent?jr.BlobEvent:null,(t,e)=>{if(null===Gr)throw new Error("A native BlobEvent could not be created.");return new Gr(t,e)}),Ur=((t,e,n,r)=>(i,s,o)=>{var a;const c=null===(a=s.getAudioTracks()[0])||void 0===a?void 0:a.getSettings().sampleRate,h=new Sr({latencyHint:"playback",sampleRate:c}),l=MediaRecorder.isTypeSupported("audio/mp4")?new Bn({length:2688,sampleRate:h.sampleRate}):null,u=[],d=xt((t=>{if(void 0===dr)throw new Error(Ir);return dr(h,t)}));let f=null,p=null,v=null,w=null,m=!0;const y=e=>{i.dispatchEvent(t("dataavailable",{data:new Blob(e,{type:o})}))},g=async(t,e)=>{const n=await vt(t,e);null===v?u.push(...n):(y(n),w=g(t,e))},b=()=>(m=!0,h.resume()),M=()=>{null!==v&&(null!==f&&(s.removeEventListener("addtrack",f),s.removeEventListener("removetrack",f)),null!==p&&clearTimeout(p),v.then((async({encoderInstanceId:t,mediaStreamAudioSourceNode:e,recorderAudioWorkletNode:n})=>{null!==w&&(w.catch((()=>{})),w=null),await n.stop(),e.disconnect(n);const r=await vt(t,null);null===v&&await k(),y([...u,...r]),u.length=0,i.dispatchEvent(new Event("stop"))})),v=null)},k=()=>(m=!1,h.suspend());return k(),{get mimeType(){return o},get state(){return null===v?"inactive":m?"recording":"paused"},pause(){if(null===v)throw n();m&&(k(),i.dispatchEvent(new Event("pause")))},resume(){if(null===v)throw n();m||(b(),i.dispatchEvent(new Event("resume")))},start(t){var a;if(null!==v)throw n();if(s.getVideoTracks().length>0)throw r();i.dispatchEvent(new Event("start"));const c=s.getAudioTracks(),u=0===c.length?2:null!==(a=c[0].getSettings().channelCount)&&void 0!==a?a:2;v=Promise.all([b(),d.then((()=>(async(t,e,n,r,i)=>{const{encoderInstanceId:s,port:o}=await wt(i,e.sampleRate);if(void 0===Ar)throw new Error(Ir);return{audioBufferSourceNode:null===t?null:new Gn(e,{buffer:t}),encoderInstanceId:s,mediaStreamAudioSourceNode:new fr(e,{mediaStream:r}),port:o,recorderAudioWorkletNode:Et(Ar,e,{channelCount:n})}})(l,h,u,s,o)))]).then((async([,{audioBufferSourceNode:e,encoderInstanceId:n,mediaStreamAudioSourceNode:r,port:i,recorderAudioWorkletNode:s}])=>(r.connect(s),null!==e&&(await new Promise((t=>{e.onended=t,e.connect(s),e.start()})),e.disconnect(s)),await s.record(i),void 0!==t&&(w=g(n,t)),{encoderInstanceId:n,mediaStreamAudioSourceNode:r,recorderAudioWorkletNode:s})));const m=s.getTracks();f=()=>{M(),i.dispatchEvent(new ErrorEvent("error",{error:e()}))},s.addEventListener("addtrack",f),s.addEventListener("removetrack",f),p=setInterval((()=>{const t=s.getTracks();t.length===m.length&&!t.some(((t,e)=>t!==m[e]))||null===f||f()}),1e3)},stop:M}})(_r,((t="")=>{try{return new DOMException(t,"InvalidModificationError")}catch(e){return e.code=13,e.message=t,e.name="InvalidModificationError",e}}),(()=>{try{return new DOMException("","InvalidStateError")}catch(t){return t.code=11,t.name="InvalidStateError",t}}),yt),Nr=(t=>(e,n)=>{const r=t(e,n);if(null===r)return r;const i=n+Math.floor((r-1)/8);if(i+r>e.byteLength)return null;let s=e.getUint8(i)&(1<<8-r%8)-1;for(let t=1;t<r;t+=1)s=(s<<8)+e.getUint8(i+t);return{length:r,value:s}})(Pr),Vr=(t=>(e,n,r,i=2)=>{const s=t(e,n);if(null===s)return s;const{length:o,value:a}=s;if("master"===r)return{content:null,length:o};if(n+o+a>e.byteLength)return null;if("binary"===r){const t=(a/Float32Array.BYTES_PER_ELEMENT-1)/i,r=Array.from({length:i},(()=>new Float32Array(t)));for(let s=0;s<t;s+=1){const t=s*i+1;for(let a=0;a<i;a+=1)r[a][s]=e.getFloat32(n+o+(t+a)*Float32Array.BYTES_PER_ELEMENT,!0)}return{content:r,length:o+a}}return{content:null,length:o+a}})(Nr),Dr=(t=>(e,n)=>{const r=t(e,n);if(null===r)return r;const{length:i,value:s}=r;return 35===s?{length:i,type:"binary"}:46===s||97===s||88713574===s||106212971===s||139690087===s||172351395===s||256095861===s?{length:i,type:"master"}:{length:i,type:"unknown"}})(Nr),Lr=((t,e)=>(n,r,i)=>{const s=[];let o=r,a=0;for(;a<n.byteLength;)if(null===o){const t=e(n,a);if(null===t)break;const{length:r,type:i}=t;o=i,a+=r}else{const e=t(n,a,o,i);if(null===e)break;const{content:r,length:c}=e;o=null,a+=c,null!==r&&s.push(r)}return{contents:s,currentElementType:o,offset:a}})(Vr,Dr),zr=((t,e,n)=>(r,i,s,o)=>{const a=[],c=new i(s,{mimeType:"audio/webm; codecs=pcm"});let h=null,l=()=>{};const u=e=>{r.dispatchEvent(t("dataavailable",{data:new Blob(e,{type:o})}))},d=async(t,e)=>{const n=await vt(t,e);"inactive"===c.state?a.push(...n):(u(n),h=d(t,e))},f=()=>{"inactive"!==c.state&&(null!==h&&(h.catch((()=>{})),h=null),l(),l=()=>{},c.stop())};return c.addEventListener("error",(t=>{f(),r.dispatchEvent(new ErrorEvent("error",{error:t.error}))})),c.addEventListener("pause",(()=>r.dispatchEvent(new Event("pause")))),c.addEventListener("resume",(()=>r.dispatchEvent(new Event("resume")))),c.addEventListener("start",(()=>r.dispatchEvent(new Event("start")))),{get mimeType(){return o},get state(){return c.state},pause:()=>c.pause(),resume:()=>c.resume(),start(t){const[i]=s.getAudioTracks();if(void 0!==i&&"inactive"===c.state){const{channelCount:s,sampleRate:f}=i.getSettings();if(void 0===s)throw new Error("The channelCount is not defined.");if(void 0===f)throw new Error("The sampleRate is not defined.");let p=!1,v=!1,w=0,m=wt(o,f);l=()=>{v=!0};const y=kt(c,"dataavailable")((({data:t})=>{w+=1;const i=t.arrayBuffer();m=m.then((async({dataView:t=null,elementType:o=null,encoderInstanceId:h,port:l})=>{const d=await i;w-=1;const f=null===t?new Or.MultiBufferDataView([d]):new Or.MultiBufferDataView([...t.buffers,d],t.byteOffset);if(!p&&"recording"===c.state&&!v){const e=n(f,0);if(null===e)return{dataView:f,elementType:o,encoderInstanceId:h,port:l};const{value:r}=e;if(172351395!==r)return{dataView:t,elementType:o,encoderInstanceId:h,port:l};p=!0}const{currentElementType:m,offset:g,contents:b}=e(f,o,s),M=g<f.byteLength?new Or.MultiBufferDataView(f.buffers,f.byteOffset+g):null;return b.forEach((t=>l.postMessage(t,t.map((({buffer:t})=>t))))),0!==w||"inactive"!==c.state&&!v||(vt(h,null).then((t=>{u([...a,...t]),a.length=0,r.dispatchEvent(new Event("stop"))})),l.postMessage([]),l.close(),y()),{dataView:M,elementType:m,encoderInstanceId:h,port:l}}))}));void 0!==t&&m.then((({encoderInstanceId:e})=>{v||(h=d(e,t))}))}c.start(100)},stop:f}})(_r,Lr,Nr),Br=(t=>()=>{if(null===t)throw new Error("A native EventTarget could not be created.");return t.document.createElement("p")})(jr),Fr=null===jr||void 0===jr.MediaRecorder?null:jr.MediaRecorder,Hr=((t,e,n,r,i,s,o)=>class extends s{constructor(s,a={}){const{mimeType:c}=a;if(null!==o&&(void 0===c||void 0!==o.isTypeSupported&&o.isTypeSupported(c))){const e=t(o,s,a);super(e),this._internalMediaRecorder=e}else{if(void 0===c||!i.some((t=>t.test(c))))throw null!==o&&t(o,s,a),e();super(),this._internalMediaRecorder=null!==o&&void 0!==o.isTypeSupported&&o.isTypeSupported("audio/webm; codecs=pcm")?r(this,o,s,c):n(this,s,c)}this._ondataavailable=null,this._onerror=null,this._onpause=null,this._onresume=null,this._onstart=null,this._onstop=null}get mimeType(){return this._internalMediaRecorder.mimeType}get ondataavailable(){return null===this._ondataavailable?this._ondataavailable:this._ondataavailable[0]}set ondataavailable(t){if(null!==this._ondataavailable&&this.removeEventListener("dataavailable",this._ondataavailable[1]),"function"==typeof t){const e=t.bind(this);this.addEventListener("dataavailable",e),this._ondataavailable=[t,e]}else this._ondataavailable=null}get onerror(){return null===this._onerror?this._onerror:this._onerror[0]}set onerror(t){if(null!==this._onerror&&this.removeEventListener("error",this._onerror[1]),"function"==typeof t){const e=t.bind(this);this.addEventListener("error",e),this._onerror=[t,e]}else this._onerror=null}get onpause(){return null===this._onpause?this._onpause:this._onpause[0]}set onpause(t){if(null!==this._onpause&&this.removeEventListener("pause",this._onpause[1]),"function"==typeof t){const e=t.bind(this);this.addEventListener("pause",e),this._onpause=[t,e]}else this._onpause=null}get onresume(){return null===this._onresume?this._onresume:this._onresume[0]}set onresume(t){if(null!==this._onresume&&this.removeEventListener("resume",this._onresume[1]),"function"==typeof t){const e=t.bind(this);this.addEventListener("resume",e),this._onresume=[t,e]}else this._onresume=null}get onstart(){return null===this._onstart?this._onstart:this._onstart[0]}set onstart(t){if(null!==this._onstart&&this.removeEventListener("start",this._onstart[1]),"function"==typeof t){const e=t.bind(this);this.addEventListener("start",e),this._onstart=[t,e]}else this._onstart=null}get onstop(){return null===this._onstop?this._onstop:this._onstop[0]}set onstop(t){if(null!==this._onstop&&this.removeEventListener("stop",this._onstop[1]),"function"==typeof t){const e=t.bind(this);this.addEventListener("stop",e),this._onstop=[t,e]}else this._onstop=null}get state(){return this._internalMediaRecorder.state}pause(){return this._internalMediaRecorder.pause()}resume(){return this._internalMediaRecorder.resume()}start(t){return this._internalMediaRecorder.start(t)}stop(){return this._internalMediaRecorder.stop()}static isTypeSupported(t){return null!==o&&void 0!==o.isTypeSupported&&o.isTypeSupported(t)||i.some((e=>e.test(t)))}})((t=>(e,n,r)=>{const i=new Map,s=new WeakMap,o=new WeakMap,a=[],c=new e(n,r),h=new WeakMap;var l,u,d,f;return c.addEventListener("stop",(({isTrusted:t})=>{t&&setTimeout((()=>a.shift()))})),c.addEventListener=(l=c.addEventListener,(t,e,n)=>{let r=e;if("function"==typeof e)if("dataavailable"===t){const t=[];r=n=>{const[[r,i]=[!1,!1]]=a;r&&!i?t.push(n):e.call(c,n)},i.set(e,t),s.set(e,r)}else"error"===t?(r=t=>{t instanceof ErrorEvent?e.call(c,t):e.call(c,new ErrorEvent("error",{error:t.error}))},o.set(e,r)):"stop"===t&&(r=t=>{for(const[t,e]of i.entries())if(e.length>0){const[n]=e;e.length>1&&Object.defineProperty(n,"data",{value:new Blob(e.map((({data:t})=>t)),{type:n.data.type})}),e.length=0,t.call(c,n)}e.call(c,t)},h.set(e,r));return l.call(c,t,r,n)}),c.removeEventListener=(u=c.removeEventListener,(t,e,n)=>{let r=e;if("function"==typeof e)if("dataavailable"===t){i.delete(e);const t=s.get(e);void 0!==t&&(r=t)}else if("error"===t){const t=o.get(e);void 0!==t&&(r=t)}else if("stop"===t){const t=h.get(e);void 0!==t&&(r=t)}return u.call(c,t,r,n)}),c.start=(d=c.start,e=>{if(void 0!==r.mimeType&&r.mimeType.startsWith("audio/")&&n.getVideoTracks().length>0)throw t();return"inactive"===c.state&&a.push([void 0!==e,!0]),void 0===e?d.call(c):d.call(c,e)}),c.stop=(f=c.stop,()=>{"inactive"!==c.state&&(a[0][1]=!1),f.call(c)}),c})(yt),yt,Ur,zr,Wr,(t=>class{constructor(e=null){this._listeners=new WeakMap,this._nativeEventTarget=null===e?t():e}addEventListener(t,e,n){if(null!==e){let s=this._listeners.get(e);void 0===s&&(r=this,i=e,s=t=>{const e={value:r};return Object.defineProperties(t,{currentTarget:e,target:e}),"function"==typeof i?i.call(r,t):i.handleEvent.call(r,t)},"function"==typeof e&&this._listeners.set(e,s)),this._nativeEventTarget.addEventListener(t,s,n)}var r,i}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,e,n){const r=null===e?void 0:this._listeners.get(e);this._nativeEventTarget.removeEventListener(t,void 0===r?null:r,n)}})(Br),Fr),$r=new WeakMap,qr=st({characterize:({call:t})=>()=>t("characterize"),encode:({call:t})=>(e,n)=>t("encode",{recordingId:e,timeslice:n}),record:({call:t})=>async(e,n,r)=>{await t("record",{recordingId:e,sampleRate:n,typedArrays:r},r.map((({buffer:t})=>t)).filter((t=>t instanceof ArrayBuffer)))}}),Xr=new Blob(['(()=>{var e={455(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,s=536870912,a=2*s,o=function(e,t){return function(r){var o=t.get(r),i=void 0===o?r.size:o<a?o+1:0;if(!r.has(i))return e(r,i);if(r.size<s){for(;r.has(i);)i=Math.floor(Math.random()*a);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,c=r(i),l=o(c,i),u=t(l);e.addUniqueNumber=u,e.generateUniqueNumber=l}(t)}},t={};function r(n){var s=t[n];if(void 0!==s)return s.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,s=(e,t)=>Object.assign(new Error(e),{status:t}),a=t=>s(\'The handler of the method called "\'.concat(t,\'" returned an unexpected result.\'),e),o=(t,r)=>async({data:{id:o,method:i,params:c}})=>{const l=r[i];try{if(void 0===l)throw(e=>s(\'The requested method called "\'.concat(e,\'" is not supported.\'),n))(i);const r=void 0===c?l():l(c);if(void 0===r)throw(t=>s(\'The handler of the method called "\'.concat(t,\'" returned no required result.\'),e))(i);const u=r instanceof Promise?await r:r;if(null===o){if(void 0!==u.result)throw a(i)}else{if(void 0===u.result)throw a(i);const{result:e,transferables:r=[]}=u;t.postMessage({id:o,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:o})}};var i=r(455);const c=new Map,l=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),s=(0,i.generateUniqueNumber)(c);return c.set(s,()=>{n(),t.close(),c.delete(s)}),{result:s}},disconnect:({portId:e})=>{const r=c.get(e);if(void 0===r)throw(e=>s(\'The specified parameter called "portId" with the given value "\'.concat(e,\'" does not identify a port connected to this worker.\'),t))(e);return r(),{result:null}},isSupported:async()=>{if(await new Promise(e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])})){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),u=(e,t,r=()=>!0)=>{const n=l(u,t,r),s=o(e,n);return e.addEventListener("message",s),()=>e.removeEventListener("message",s)},d=e=>e.reduce((e,t)=>e+t.length,0),h=(e,t)=>{const r=[];let n=0;e:for(;n<t;){const t=e.length;for(let s=0;s<t;s+=1){const t=e[s];void 0===r[s]&&(r[s]=[]);const a=t.shift();if(void 0===a)break e;r[s].push(a),0===s&&(n+=a.length)}}if(n>t){const s=n-t;r.forEach((t,r)=>{const n=t.pop(),a=n.length-s;t.push(n.subarray(0,a)),e[r].unshift(n.subarray(a))})}return r},f=new Map,m=(e=>(t,r,n)=>{const s=e.get(t);if(void 0===s){const s={channelDataArrays:n.map(e=>[e]),isComplete:!0,sampleRate:r};return e.set(t,s),s}return s.channelDataArrays.forEach((e,t)=>e.push(n[t])),s})(f),p=((e,t)=>(r,n,s,a)=>{const o=s>>3,i="subsequent"===n?0:44,c=r.length,l=e(r[0]),u=new ArrayBuffer(l*c*o+i),d=new DataView(u);return"subsequent"!==n&&t(d,s,c,"complete"===n?l:Number.POSITIVE_INFINITY,a),r.forEach((e,t)=>{let r=i+t*o;e.forEach(e=>{const t=e.length;for(let n=0;n<t;n+=1){const t=e[n];d.setInt16(r,t<0?32768*Math.max(-1,t):32767*Math.min(1,t),!0),r+=c*o}})}),[u]})(d,(e,t,r,n,s)=>{const a=t>>3,o=Math.min(n*r*a,4294967251);e.setUint32(0,1380533830),e.setUint32(4,o+36,!0),e.setUint32(8,1463899717),e.setUint32(12,1718449184),e.setUint32(16,16,!0),e.setUint16(20,1,!0),e.setUint16(22,r,!0),e.setUint32(24,s,!0),e.setUint32(28,s*r*a,!0),e.setUint16(32,r*a,!0),e.setUint16(34,t,!0),e.setUint32(36,1684108385),e.setUint32(40,o,!0)}),v=new Map;u(self,{characterize:()=>({result:/^audio\\/wav$/}),encode:({recordingId:e,timeslice:t})=>{const r=v.get(e);void 0!==r&&(v.delete(e),r.reject(new Error("Another request was made to initiate an encoding.")));const n=f.get(e);if(null!==t){if(void 0===n||d(n.channelDataArrays[0])*(1e3/n.sampleRate)<t)return new Promise((r,n)=>{v.set(e,{reject:n,resolve:r,timeslice:t})});const r=h(n.channelDataArrays,Math.ceil(t*(n.sampleRate/1e3))),s=p(r,n.isComplete?"initial":"subsequent",16,n.sampleRate);return n.isComplete=!1,{result:s,transferables:s}}if(void 0!==n){const t=p(n.channelDataArrays,n.isComplete?"complete":"subsequent",16,n.sampleRate);return f.delete(e),{result:t,transferables:t}}return{result:[],transferables:[]}},record:({recordingId:e,sampleRate:t,typedArrays:r})=>{const n=m(e,t,r),s=v.get(e);if(void 0!==s&&d(n.channelDataArrays[0])*(1e3/t)>=s.timeslice){const r=h(n.channelDataArrays,Math.ceil(s.timeslice*(t/1e3))),a=p(r,n.isComplete?"initial":"subsequent",16,t);n.isComplete=!1,v.delete(e),s.resolve({result:a,transferables:a})}return{result:null}}})})()})();'],{type:"application/javascript; charset=utf-8"}),Zr=URL.createObjectURL(Xr),Yr=(t=>{const e=new Worker(t);return qr(e)})(Zr),Kr=Yr.connect;var Gr;URL.revokeObjectURL(Zr);const Jr=n(class extends r{constructor(t){super(),!1!==t&&this.__registerHost(),this.startRecord=i(this,"startRecord",7),this.stopRecord=i(this,"stopRecord",7),this.sendTranscript=i(this,"sendTranscript",7),this.isRecording=!1,this.isProcessing=!1,this.time=0,this.transcript="",this.fullTranscript="",this.isSpeechRecognitionSupported=!0,this.userCountry="",this.audioBase64="",this.originalMediaRecorder=window.MediaRecorder,this.pendingStop=!1,this.recognitionEnded=!1}resolveParentState(){const t=(t=>{const e=t?w(t):m.state.activeParentScope,n=m.state.parentContexts[e];return(null==n?void 0:n.dataKey)?n:{dataKey:m.state.dataKey||"",dataMode:m.state.dataMode||v}})(this.componentType);return{dataKey:this.dataKey||t.dataKey,dataMode:this.dataMode||t.dataMode}}async componentWillLoad(){var t;this.isSpeechRecognitionSupported=this.checkSpeechRecognitionSupport();const e=Intl.DateTimeFormat().resolvedOptions().timeZone;if(this.userCountry=h(e),l(e)&&(console.warn("User is likely in China, which may have limited Web Speech API support. Falling back to audio processing mode."),this.isSpeechRecognitionSupported=!1),!window.MediaRecorder.isTypeSupported("audio/wav"))try{await(async t=>{const e=await mt(t);Wr.push(e),$r.set(t,e)})(await Kr())}catch(e){(null===(t=e.message)||void 0===t?void 0:t.includes("already an encoder"))?console.warn("WAV encoder was already registered. Continuing..."):console.error("Unexpected encoder registration error:",e)}}checkSpeechRecognitionSupport(){return"undefined"!=typeof window&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)}getRecognitionLanguage(){var t,e;return"undefined"==typeof navigator?"en-US":(null!==(e=null===(t=navigator.languages)||void 0===t?void 0:t[0])&&void 0!==e?e:navigator.language)||"en-US"}async startRecording(){this.fullTranscript="",this.pendingStop=!1,this.recognitionEnded=!1,this.startRecord.emit(this),this.isRecording=!0,m.state.activeParentScope=w(this.componentType);try{window.MediaRecorder=Hr,this.startRecognition(),setTimeout((()=>this.createWaveSurfer()),500),this.time=0,this.timer=setInterval((()=>{this.time++}),500)}catch(t){console.error("Error accessing microphone:",t)}}createWaveSurfer(){this.wavesurfer&&this.wavesurfer.destroy();const t=getComputedStyle(this.element),e=e=>t.getPropertyValue(e).trim(),n=e("--ai12z-audio-wave-color")||e("--ai12zBot-v2-searchbar-mic-color")||e("--ai12z-mic-color")||e("--ai12z-primary-color")||"#007bff",r=e("--ai12z-audio-progress-color")||e("--ai12zBot-v2-secondary-accent")||e("--ai12z-secondary-accent")||n;window.MediaRecorder=Hr;try{this.wavesurfer=z.create({container:this.element.querySelector("#mic"),waveColor:n,progressColor:r,barWidth:3,barGap:2,height:30}),this.record=this.wavesurfer.registerPlugin(X.create({renderRecordedAudio:!1,scrollingWaveform:!0,continuousWaveform:!0,continuousWaveformDuration:30,mimeType:"audio/wav"})),this.record.on("record-end",(t=>{const e=new FileReader;e.onloadend=async()=>{if(this.audioBase64=e.result,this.isProcessing)try{const t=this.resolveParentState(),e=await c(t.dataKey,this.getRecognitionLanguage(),t.dataMode,this.audioBase64);this.sendTranscript.emit(e.success?e.transcript:""),this.stopRecord.emit(this)}catch(t){console.error("API Error:",t),this.stopRecord.emit(this)}finally{this.isProcessing=!1,this.isRecording=!1,this.audioBase64="",window.MediaRecorder=this.originalMediaRecorder}},e.readAsDataURL(t)})),this.record.startRecording()}catch(t){console.error("Failed to initialize WaveSurfer or RecordPlugin:",t),this.isRecording=!1,window.MediaRecorder=this.originalMediaRecorder}}startRecognition(){if(this.isSpeechRecognitionSupported){const t=window.SpeechRecognition||window.webkitSpeechRecognition;this.recognition=new t,this.recognition.lang=this.getRecognitionLanguage(),this.recognition.interimResults=!0,this.recognition.start(),this.recognition.onresult=t=>{let e="";for(let n=t.resultIndex;n<t.results.length;n++)e+=t.results[n][0].transcript;this.fullTranscript=e,this.transcript=this.fullTranscript},this.recognition.onerror=t=>{console.error("Error occurred in recognition:",t.error)},this.recognition.onend=()=>{this.recognitionEnded=!0,this.pendingStop&&(this.pendingStop=!1,this.resolveStopAction())}}}resolveStopAction(){this.fullTranscript||this.isSpeechRecognitionSupported?(this.sendTranscript.emit(this.fullTranscript),this.stopRecord.emit(this),this.isRecording=!1,window.MediaRecorder=this.originalMediaRecorder):this.isProcessing=!0}stopRecording(t){this.record.isRecording()&&this.record.stopRecording(),this.recognition&&this.recognition.stop(),clearInterval(this.timer),"stop"===t&&(this.isSpeechRecognitionSupported&&this.recognition?this.recognitionEnded?this.resolveStopAction():this.pendingStop=!0:this.isProcessing=!0)}render(){const t=Math.floor(this.time/60),e=this.time%60;return s("div",{key:"b73747279b29f4a1caf317a5d0f00da382315346",class:"flex w-full"},(this.isRecording||this.isProcessing)&&s("div",{key:"534a01d1be9ae431f46029615db42c87a2587f36",class:"relative flex items-center w-full rounded-full"},this.isRecording&&s("button",{key:"862cdaa52da77d810a441853181c06f3a26da726","aria-label":"Cancel Recording",onClick:t=>{t.preventDefault(),this.stopRecording("cancel")},class:"w-10 h-10 rounded-full flex items-center justify-center text-white"},"❌"),s("div",{key:"62495256b25dc06fe0653702ae080e33c7745c8c",id:"mic",style:{width:"100%"}}),this.isRecording&&!this.isProcessing?s("div",{class:"ml-auto text-blue-600 font-semibold"},String(t).padStart(2,"0"),":",String(e).padStart(2,"0")):null,(this.isRecording||this.isProcessing)&&s("button",{key:"036e203205dfc398ed7152f796fc43d7b1bad24a","aria-label":"Confirm Recording",disabled:this.isProcessing,onClick:t=>{t.preventDefault(),this.isProcessing||this.stopRecording("stop")},class:"w-10 h-10 ml-2 rounded-full flex items-center justify-center "+(this.isProcessing?"cursor-not-allowed":"text-blue-600")},this.isProcessing?s("svg",{class:"activity-spinner",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},s("line",{x1:"12",y1:"2",x2:"12",y2:"5","stroke-width":"2","stroke-linecap":"round",style:{"--n":"0"}}),s("line",{x1:"16.24",y1:"3.76",x2:"14.12",y2:"5.88","stroke-width":"2","stroke-linecap":"round",style:{"--n":"1"}}),s("line",{x1:"19",y1:"7.76",x2:"16.24",y2:"9.24","stroke-width":"2","stroke-linecap":"round",style:{"--n":"2"}}),s("line",{x1:"20",y1:"12",x2:"17",y2:"12","stroke-width":"2","stroke-linecap":"round",style:{"--n":"3"}}),s("line",{x1:"19",y1:"16.24",x2:"16.24",y2:"14.76","stroke-width":"2","stroke-linecap":"round",style:{"--n":"4"}}),s("line",{x1:"16.24",y1:"20.24",x2:"14.12",y2:"18.12","stroke-width":"2","stroke-linecap":"round",style:{"--n":"5"}}),s("line",{x1:"12",y1:"22",x2:"12",y2:"19","stroke-width":"2","stroke-linecap":"round",style:{"--n":"6"}}),s("line",{x1:"7.76",y1:"20.24",x2:"9.88",y2:"18.12","stroke-width":"2","stroke-linecap":"round",style:{"--n":"7"}}),s("line",{x1:"5",y1:"16.24",x2:"7.76",y2:"14.76","stroke-width":"2","stroke-linecap":"round",style:{"--n":"8"}}),s("line",{x1:"4",y1:"12",x2:"7",y2:"12","stroke-width":"2","stroke-linecap":"round",style:{"--n":"9"}}),s("line",{x1:"5",y1:"7.76",x2:"7.76",y2:"9.24","stroke-width":"2","stroke-linecap":"round",style:{"--n":"10"}}),s("line",{x1:"7.76",y1:"3.76",x2:"9.88",y2:"5.88","stroke-width":"2","stroke-linecap":"round",style:{"--n":"11"}})):s("span",{class:"text-blue-600 font-sans"},"✔"))),!this.isRecording&&!this.isProcessing&&s("button",{key:"ad24a6225403a8983100667054aa45f3ed5c24a8","aria-label":"Start Recording",title:"Start Recording",onClick:t=>{t.preventDefault(),this.startRecording()},class:"flex "+("search"===this.componentType||"cta"===this.componentType?"p-1.5 mr-0.5 self-center mt-0.5":"w-10 h-8 p-0 mt-4")},s("svg",{key:"7e1b80a53b24d446cdf9bf77512d2bdea8a29450",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",class:"w-5 h-5 translate-y-[0.5px] "+("search"===this.componentType||"cta"===this.componentType?"mic-icon":"mic-botIcon")},s("path",{key:"73917f2f7ffc7f6c243394797ffe83944279bc27",d:"M7 4a3 3 0 016 0v6a3 3 0 11-6 0V4z"}),s("path",{key:"bc2e12c016990bdbb1aaeee292e612e11d7993c8",d:"M5.5 9.643a.75.75 0 00-1.5 0V10c0 3.06 2.29 5.585 5.25 5.954V17.5h-1.5a.75.75 0 000 1.5h4.5a.75.75 0 000-1.5h-1.5v-1.546A6.001 6.001 0 0016 10v-.357a.75.75 0 00-1.5 0V10a4.5 4.5 0 01-9 0v-.357z"}))))}get element(){return this}static get style(){return":host{width:100%}.mic-icon{fill:var(--ai12z-mic-color)}.mic-botIcon{fill:var(--ai12zBot-v2-searchbar-mic-color)}.activity-spinner{width:20px;height:20px;stroke:currentColor;animation:activity-rotate 1s steps(12, end) infinite}.activity-spinner line{opacity:calc(1 - var(--n) / 11 * 0.85)}@keyframes activity-rotate{to{transform:rotate(360deg)}}"}},[0,"audio-recorder",{componentType:[1,"component-type"],dataKey:[32],dataMode:[32],isRecording:[32],isProcessing:[32],time:[32],transcript:[32],fullTranscript:[32],isSpeechRecognitionSupported:[32],userCountry:[32]}]);function Qr(){"undefined"!=typeof customElements&&["audio-recorder","item-list"].forEach((t=>{switch(t){case"audio-recorder":customElements.get(e(t))||customElements.define(e(t),Jr);break;case"item-list":customElements.get(e(t))||a()}}))}Qr();export{Jr as A,Qr as d,y as s}
|
|
1
|
+
import{S as t,t as e,p as n,H as r,d as i,h as s}from"./p-ZGVz1_9H.js";import{L as o,d as a,M as c}from"./p-CrfXJRIo.js";import{q as h,t as l}from"./p-qwKoi5kn.js";const u=(()=>{let t;return(...e)=>{t&&clearTimeout(t),t=setTimeout((()=>{t=0,(t=>{for(let e of t.keys()){const n=t.get(e).filter((t=>{const e=t.deref();return e&&(!("isConnected"in(n=e))||n.isConnected);var n}));t.set(e,n)}})(...e)}),2e3)}})(),d=t.forceUpdate,f=t.getRenderingRef,p=(t,e)=>{const n=t.indexOf(e);n>=0&&(t[n]=t[t.length-1],t.length--)},v="prod",w=t=>{const e=(t||"").toLowerCase();return e.includes("bot")?"bot":e.includes("cta")?"cta":e.includes("search")?"search":"unknown"},m=(()=>{const t=((t,e=(t,e)=>t!==e)=>{const n=()=>{return("function"==typeof(e=t)?e():e)??{};var e},r=n();let i=new Map(Object.entries(r));const s="undefined"!=typeof Proxy,o=s?null:{},a={dispose:[],get:[],set:[],reset:[]},c=new Map,h=()=>{i=new Map(Object.entries(n())),s||w(),a.reset.forEach((t=>t()))},l=t=>(a.get.forEach((e=>e(t))),i.get(t)),u=(t,n)=>{const r=i.get(t);e(n,r,t)&&(i.set(t,n),s||v(t),a.set.forEach((e=>e(t,n,r))))},d=s?new Proxy(r,{get:(t,e)=>l(e),ownKeys:()=>Array.from(i.keys()),getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0}),has:(t,e)=>i.has(e),set:(t,e,n)=>(u(e,n),!0)}):(w(),o),f=(t,e)=>(a[t].push(e),()=>{p(a[t],e)});function v(t){!s&&o&&(Object.prototype.hasOwnProperty.call(o,t)||Object.defineProperty(o,t,{configurable:!0,enumerable:!0,get:()=>l(t),set(e){u(t,e)}}))}function w(){if(s||!o)return;const t=new Set(i.keys());for(const e of Object.keys(o))t.has(e)||delete o[e];for(const e of t)v(e)}return{state:d,get:l,set:u,on:f,onChange:(t,e)=>{const r=(n,r)=>{n===t&&e(r)},i=()=>{const r=n();e(r[t])},s=f("set",r),o=f("reset",i);return c.set(e,{setHandler:r,resetHandler:i,propName:t}),()=>{s(),o(),c.delete(e)}},use:(...t)=>{const e=t.reduce(((t,e)=>(e.set&&t.push(f("set",e.set)),e.get&&t.push(f("get",e.get)),e.reset&&t.push(f("reset",e.reset)),e.dispose&&t.push(f("dispose",e.dispose)),t)),[]);return()=>e.forEach((t=>t()))},dispose:()=>{a.dispose.forEach((t=>t())),h()},reset:h,forceUpdate:t=>{const e=i.get(t);a.set.forEach((n=>n(t,e,e)))},removeListener:(t,e)=>{const n=c.get(e);n&&n.propName===t&&(p(a.set,n.setHandler),p(a.reset,n.resetHandler),c.delete(e))}}})({dataKey:"",dataMode:"prod",activeParentScope:"unknown",parentContexts:{bot:{dataKey:"",dataMode:v},cta:{dataKey:"",dataMode:v},search:{dataKey:"",dataMode:v},unknown:{dataKey:"",dataMode:v}}},void 0);return t.use((()=>{if("function"!=typeof f||"function"!=typeof d)return{};const t=d,e=f,n=new Map;return{dispose:()=>n.clear(),get:t=>{const r=e();r&&((t,e,n)=>{let r=t.get(e);r||(r=[],t.set(e,r)),r.some((t=>t.deref()===n))||r.push(new WeakRef(n))})(n,t,r)},set:e=>{const r=n.get(e);if(r){const i=r.filter((e=>{const n=e.deref();return!!n&&t(n)}));n.set(e,i)}u(n)},reset:()=>{n.forEach((e=>{e.forEach((e=>{const n=e.deref();n&&t(n)}))})),u(n)}}})()),t})(),y=(t,e,n)=>{const r=w(t),i={dataKey:e||"",dataMode:n||v};m.state.parentContexts=Object.assign(Object.assign({},m.state.parentContexts),{[r]:i}),m.state.dataKey=i.dataKey,m.state.dataMode=i.dataMode};function g(t,e,n,r){return new(n||(n=Promise))((function(i,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function a(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,a)}c((r=r.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;let b=class{constructor(){this.listeners={}}on(t,e,n){if(this.listeners[t]||(this.listeners[t]=new Set),null==n?void 0:n.once){const n=(...r)=>{this.un(t,n),e(...r)};return this.listeners[t].add(n),()=>this.un(t,n)}return this.listeners[t].add(e),()=>this.un(t,e)}un(t,e){var n;null===(n=this.listeners[t])||void 0===n||n.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)))}};const M={decode:function(t,e){return g(this,void 0,void 0,(function*(){const n=new AudioContext({sampleRate:e});try{return yield n.decodeAudioData(t)}finally{n.close()}}))},createBuffer:function(t,e){if(!t||0===t.length)throw new Error("channelData must be a non-empty array");if(e<=0)throw new Error("duration must be greater than 0");if("number"==typeof t[0]&&(t=[t]),!t[0]||0===t[0].length)throw new Error("channelData must contain non-empty channel arrays");!function(t){const e=t[0];if(e.some((t=>t>1||t<-1))){const n=e.length;let r=0;for(let t=0;t<n;t++){const n=Math.abs(e[t]);n>r&&(r=n)}for(const e of t)for(let t=0;t<n;t++)e[t]/=r}}(t);const n=t.map((t=>t instanceof Float32Array?t:Float32Array.from(t)));return{duration:e,length:n[0].length,sampleRate:n[0].length/e,numberOfChannels:n.length,getChannelData:t=>{const e=n[t];if(!e)throw new Error(`Channel ${t} not found`);return e},copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function k(t,e){const n=e.xmlns?document.createElementNS(e.xmlns,t):document.createElement(t);for(const[t,r]of Object.entries(e))if("children"===t&&r)for(const[t,e]of Object.entries(r))e instanceof Node?n.appendChild(e):n.appendChild("string"==typeof e?document.createTextNode(e):k(t,e));else"style"===t?Object.assign(n.style,r):"textContent"===t?n.textContent=r:n.setAttribute(t,r.toString());return n}function x(t,e,n){const r=k(t,e||{});return null==n||n.appendChild(r),r}var E=Object.freeze({__proto__:null,createElement:x,default:x});const C={fetchBlob:function(t,e,n){return g(this,void 0,void 0,(function*(){const r=yield fetch(t,n);if(r.status>=400)throw new Error(`Failed to fetch ${t}: ${r.status} (${r.statusText})`);return function(t,e){g(this,void 0,void 0,(function*(){if(!t.body||!t.headers)return;const n=t.body.getReader(),r=Number(t.headers.get("Content-Length"))||0;let i=0;const s=t=>{i+=(null==t?void 0:t.length)||0;const n=Math.round(i/r*100);e(n)};try{for(;;){const t=yield n.read();if(t.done)break;s(t.value)}}catch(n){console.warn("Progress tracking error:",n)}}))}(r.clone(),e),r.blob()}))}};function A(t){let e=t;const n=new Set;return{get value(){return e},set(t){Object.is(e,t)||(e=t,n.forEach((t=>t(e))))},update(t){this.set(t(e))},subscribe:t=>(n.add(t),()=>n.delete(t))}}function S(t,e){const n=A(t());return e.forEach((e=>e.subscribe((()=>{const e=t();Object.is(n.value,e)||n.set(e)})))),{get value(){return n.value},subscribe:t=>n.subscribe(t)}}function I(t,e){let n;const r=()=>{n&&(n(),n=void 0),n=t()},i=e.map((t=>t.subscribe(r)));return r(),()=>{n&&(n(),n=void 0),i.forEach((t=>t()))}}class T extends b{get isPlayingSignal(){return this._isPlaying}get currentTimeSignal(){return this._currentTime}get durationSignal(){return this._duration}get volumeSignal(){return this._volume}get mutedSignal(){return this._muted}get playbackRateSignal(){return this._playbackRate}get seekingSignal(){return this._seeking}constructor(t){super(),this.isExternalMedia=!1,this.reactiveMediaEventCleanups=[],t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),this._isPlaying=A(!1),this._currentTime=A(0),this._duration=A(0),this._volume=A(this.media.volume),this._muted=A(this.media.muted),this._playbackRate=A(this.media.playbackRate||1),this._seeking=A(!1),this.setupReactiveMediaEvents(),t.mediaControls&&(this.media.controls=!0),t.autoplay&&(this.media.autoplay=!0),null!=t.playbackRate&&this.onMediaEvent("canplay",(()=>{null!=t.playbackRate&&(this.media.playbackRate=t.playbackRate)}),{once:!0})}setupReactiveMediaEvents(){this.reactiveMediaEventCleanups.push(this.onMediaEvent("play",(()=>{this._isPlaying.set(!0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("pause",(()=>{this._isPlaying.set(!1)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("ended",(()=>{this._isPlaying.set(!1)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("timeupdate",(()=>{this._currentTime.set(this.media.currentTime)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("durationchange",(()=>{this._duration.set(this.media.duration||0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("loadedmetadata",(()=>{this._duration.set(this.media.duration||0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeking",(()=>{this._seeking.set(!0)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeked",(()=>{this._seeking.set(!1)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("volumechange",(()=>{this._volume.set(this.media.volume),this._muted.set(this.media.muted)}))),this.reactiveMediaEventCleanups.push(this.onMediaEvent("ratechange",(()=>{this._playbackRate.set(this.media.playbackRate)})))}onMediaEvent(t,e,n){return this.media.addEventListener(t,e,n),()=>this.media.removeEventListener(t,e,n)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const t=this.getSrc();t.startsWith("blob:")&&URL.revokeObjectURL(t)}canPlayType(t){return""!==this.media.canPlayType(t)}setSrc(t,e){const n=this.getSrc();if(t&&n===t)return;this.revokeSrc();const r=e instanceof Blob&&(this.canPlayType(e.type)||!t)?URL.createObjectURL(e):t;if(n&&this.media.removeAttribute("src"),r||t)try{this.media.src=r}catch(e){this.media.src=t}}destroy(){this.reactiveMediaEventCleanups.forEach((t=>t())),this.reactiveMediaEventCleanups=[],this.isExternalMedia||(this.media.pause(),this.revokeSrc(),this.media.removeAttribute("src"),this.media.load(),this.media.remove())}setMediaElement(t){this.reactiveMediaEventCleanups.forEach((t=>t())),this.reactiveMediaEventCleanups=[],this.media=t,this.setupReactiveMediaEvents()}play(){return g(this,void 0,void 0,(function*(){try{return yield this.media.play()}catch(t){if(t instanceof DOMException&&"AbortError"===t.name)return;throw t}}))}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=Math.max(0,Math.min(t,this.getDuration()))}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)}}function R({maxTop:t,maxBottom:e,halfHeight:n,vScale:r,barMinHeight:i=0,barAlign:s}){let o=Math.round(t*n*r),a=o+Math.round(e*n*r)||1;return a<i&&(a=i,s||(o=a/2)),{topHeight:o,totalHeight:a}}function O({barAlign:t,halfHeight:e,topHeight:n,totalHeight:r,canvasHeight:i}){return"top"===t?0:"bottom"===t?i-r:e-n}function P(t,e,n){return[(e-t.left)/t.width,(n-t.top)/t.height]}function W(t){return Boolean(t.barWidth||t.barGap||t.barAlign)}function j(t,e){if(!W(e))return t;const n=e.barWidth||.5,r=n+(e.barGap||n/2);return 0===r?t:Math.floor(t/r)*r}function _({scrollLeft:t,totalWidth:e,numCanvases:n}){if(0===e)return[0];const r=Math.floor(t/e*n);return[r-1,r,r+1]}function U(t){const e=t._cleanup;"function"==typeof e&&e()}class N extends b{constructor(t,e){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.subscriptions=[],this.unsubscribeOnScroll=[],this.dragStream=null,this.scrollStream=null,this.subscriptions=[],this.options=t;const n=this.parentFromOptionsContainer(t.container);this.parent=n;const[r,i]=this.initHtml();n.appendChild(r),this.container=r,this.scrollContainer=i.querySelector(".scroll"),this.wrapper=i.querySelector(".wrapper"),this.canvasWrapper=i.querySelector(".canvases"),this.progressWrapper=i.querySelector(".progress"),this.cursor=i.querySelector(".cursor"),e&&i.appendChild(e),this.initEvents()}parentFromOptionsContainer(t){let e;if("string"==typeof t?e=document.querySelector(t):t instanceof HTMLElement&&(e=t),!e)throw new Error("Container not found");return e}initEvents(){this.wrapper.addEventListener("click",(t=>{const e=this.wrapper.getBoundingClientRect(),[n,r]=P(e,t.clientX,t.clientY);this.emit("click",n,r)})),this.wrapper.addEventListener("dblclick",(t=>{const e=this.wrapper.getBoundingClientRect(),[n,r]=P(e,t.clientX,t.clientY);this.emit("dblclick",n,r)})),!0!==this.options.dragToSeek&&"object"!=typeof this.options.dragToSeek||this.initDrag(),this.scrollStream=function(t){const e=A({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth}),n=S((()=>function(t){const{scrollLeft:e,scrollWidth:n,clientWidth:r}=t;if(0===n)return{startX:0,endX:1};const i=(e+r)/n;return{startX:Math.max(0,Math.min(1,e/n)),endX:Math.max(0,Math.min(1,i))}}(e.value)),[e]),r=S((()=>function(t){return{left:t.scrollLeft,right:t.scrollLeft+t.clientWidth}}(e.value)),[e]),i=()=>{e.set({scrollLeft:t.scrollLeft,scrollWidth:t.scrollWidth,clientWidth:t.clientWidth})};return t.addEventListener("scroll",i,{passive:!0}),{scrollData:e,percentages:n,bounds:r,cleanup:()=>{t.removeEventListener("scroll",i),U(e)}}}(this.scrollContainer);const t=I((()=>{const{startX:t,endX:e}=this.scrollStream.percentages.value,{left:n,right:r}=this.scrollStream.bounds.value;this.emit("scroll",t,e,n,r)}),[this.scrollStream.percentages,this.scrollStream.bounds]);if(this.subscriptions.push(t),"function"==typeof ResizeObserver){const t=this.createDelay(100);this.resizeObserver=new ResizeObserver((()=>{t().then((()=>this.onContainerResize())).catch((()=>{}))})),this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const t=this.parent.clientWidth;t===this.lastContainerWidth&&"auto"!==this.options.height||(this.lastContainerWidth=t,this.reRender(),this.emit("resize"))}initDrag(){if(this.dragStream)return;this.dragStream=function(t,e={}){const{threshold:n=3,mouseButton:r=0,touchDelay:i=100}=e,s=A(null),o=new Map,a=matchMedia("(pointer: coarse)").matches;let c=()=>{};const h=e=>{if(e.button!==r)return;if(o.set(e.pointerId,e),o.size>1)return;let h=e.clientX,l=e.clientY,u=!1;const d=Date.now(),f=t.getBoundingClientRect(),{left:p,top:v}=f,w=t=>{if(t.defaultPrevented||o.size>1)return;if(a&&Date.now()-d<i)return;const e=t.clientX,r=t.clientY,c=e-h,f=r-l;(u||Math.abs(c)>n||Math.abs(f)>n)&&(t.preventDefault(),t.stopPropagation(),u||(s.set({type:"start",x:h-p,y:l-v}),u=!0),s.set({type:"move",x:e-p,y:r-v,deltaX:c,deltaY:f}),h=e,l=r)},m=t=>{o.delete(t.pointerId),u&&s.set({type:"end",x:t.clientX-p,y:t.clientY-v}),c()},y=t=>{o.delete(t.pointerId),t.relatedTarget&&t.relatedTarget!==document.documentElement||m(t)},g=t=>{u&&(t.stopPropagation(),t.preventDefault())},b=t=>{t.defaultPrevented||o.size>1||u&&t.preventDefault()};document.addEventListener("pointermove",w),document.addEventListener("pointerup",m),document.addEventListener("pointerout",y),document.addEventListener("pointercancel",y),document.addEventListener("touchmove",b,{passive:!1}),document.addEventListener("click",g,{capture:!0}),c=()=>{document.removeEventListener("pointermove",w),document.removeEventListener("pointerup",m),document.removeEventListener("pointerout",y),document.removeEventListener("pointercancel",y),document.removeEventListener("touchmove",b),setTimeout((()=>{document.removeEventListener("click",g,{capture:!0})}),10)}};return t.addEventListener("pointerdown",h),{signal:s,cleanup:()=>{c(),t.removeEventListener("pointerdown",h),o.clear(),U(s)}}}(this.wrapper);const t=I((()=>{const t=this.dragStream.signal.value;if(!t)return;const e=this.wrapper.getBoundingClientRect().width,n=(r=t.x/e)<0?0:r>1?1:r;var r;"start"===t.type?(this.isDragging=!0,this.emit("dragstart",n)):"move"===t.type?this.emit("drag",n):"end"===t.type&&(this.isDragging=!1,this.emit("dragend",n))}),[this.dragStream.signal]);this.subscriptions.push(t)}initHtml(){const t=document.createElement("div"),e=t.attachShadow({mode:"open"}),n=this.options.cspNonce&&"string"==typeof this.options.cspNonce?this.options.cspNonce.replace(/"/g,""):"";return e.innerHTML=`\n <style${n?` nonce="${n}"`:""}>\n :host {\n user-select: none;\n min-width: 1px;\n }\n :host audio {\n display: block;\n width: 100%;\n }\n :host .scroll {\n overflow-x: auto;\n overflow-y: hidden;\n width: 100%;\n position: relative;\n }\n :host .noScrollbar {\n scrollbar-color: transparent;\n scrollbar-width: none;\n }\n :host .noScrollbar::-webkit-scrollbar {\n display: none;\n -webkit-appearance: none;\n }\n :host .wrapper {\n position: relative;\n overflow: visible;\n z-index: 2;\n }\n :host .canvases {\n min-height: ${this.getHeight(this.options.height,this.options.splitChannels)}px;\n pointer-events: none;\n }\n :host .canvases > div {\n position: relative;\n }\n :host canvas {\n display: block;\n position: absolute;\n top: 0;\n image-rendering: pixelated;\n }\n :host .progress {\n pointer-events: none;\n position: absolute;\n z-index: 2;\n top: 0;\n left: 0;\n width: 0;\n height: 100%;\n overflow: hidden;\n }\n :host .progress > div {\n position: relative;\n }\n :host .cursor {\n pointer-events: none;\n position: absolute;\n z-index: 5;\n top: 0;\n left: 0;\n height: 100%;\n border-radius: 2px;\n }\n </style>\n\n <div class="scroll" part="scroll">\n <div class="wrapper" part="wrapper">\n <div class="canvases" part="canvases"></div>\n <div class="progress" part="progress"></div>\n <div class="cursor" part="cursor"></div>\n </div>\n </div>\n `,[t,e]}setOptions(t){if(this.options.container!==t.container){const e=this.parentFromOptionsContainer(t.container);e.appendChild(this.container),this.parent=e}!0!==t.dragToSeek&&"object"!=typeof this.options.dragToSeek||this.initDrag(),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:e}=this.scrollContainer;this.setScroll(e*t)}destroy(){var t;this.subscriptions.forEach((t=>t())),this.container.remove(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),null===(t=this.unsubscribeOnScroll)||void 0===t||t.forEach((t=>t())),this.unsubscribeOnScroll=[],this.dragStream&&(this.dragStream.cleanup(),this.dragStream=null),this.scrollStream&&(this.scrollStream.cleanup(),this.scrollStream=null)}createDelay(t=10){let e,n;const r=()=>{e&&(clearTimeout(e),e=void 0),n&&(n(),n=void 0)};return this.timeouts.push(r),()=>new Promise(((i,s)=>{r(),n=s,e=setTimeout((()=>{e=void 0,n=void 0,i()}),t)}))}getHeight(t,e){var n;const r=(null===(n=this.audioData)||void 0===n?void 0:n.numberOfChannels)||1;return function({optionsHeight:t,optionsSplitChannels:e,parentHeight:n,numberOfChannels:r,defaultHeight:i=128}){if(null==t)return i;const s=Number(t);if(!isNaN(s))return s;if("auto"===t){const t=n||i;return(null==e?void 0:e.every((t=>!t.overlay)))?t/r:t}return i}({optionsHeight:t,optionsSplitChannels:e,parentHeight:this.parent.clientHeight,numberOfChannels:r,defaultHeight:128})}convertColorValues(t,e){return function(t,e,n){if(!Array.isArray(t))return t||"";if(0===t.length)return"#999";if(t.length<2)return t[0]||"";const r=document.createElement("canvas"),i=r.getContext("2d").createLinearGradient(0,0,0,(null!=n?n:r.height*e)||e),s=1/(t.length-1);return t.forEach(((t,e)=>{i.addColorStop(e*s,t)})),i}(t,this.getPixelRatio(),null==e?void 0:e.canvas.height)}getPixelRatio(){return t=window.devicePixelRatio,Math.max(1,t||1);var t}renderBarWaveform(t,e,n,r){const{width:i,height:s}=n.canvas,{halfHeight:o,barWidth:a,barRadius:c,barIndexScale:h,barSpacing:l,barMinHeight:u}=function({width:t,height:e,length:n,options:r,pixelRatio:i}){const s=r.barWidth?r.barWidth*i:1,o=r.barGap?r.barGap*i:r.barWidth?s/2:0,a=s+o||1;return{halfHeight:e/2,barWidth:s,barGap:o,barRadius:r.barRadius||0,barMinHeight:r.barMinHeight?r.barMinHeight*i:0,barIndexScale:n>0?t/a/n:0,barSpacing:a}}({width:i,height:s,length:(t[0]||[]).length,options:e,pixelRatio:this.getPixelRatio()}),d=function({channelData:t,barIndexScale:e,barSpacing:n,barWidth:r,halfHeight:i,vScale:s,canvasHeight:o,barAlign:a,barMinHeight:c}){const h=t[0]||[],l=t[1]||h,u=h.length,d=[];let f=0,p=0,v=0;for(let t=0;t<=u;t++){const u=Math.round(t*e);if(u>f){const{topHeight:t,totalHeight:e}=R({maxTop:p,maxBottom:v,halfHeight:i,vScale:s,barMinHeight:c,barAlign:a}),h=O({barAlign:a,halfHeight:i,topHeight:t,totalHeight:e,canvasHeight:o});d.push({x:f*n,y:h,width:r,height:e}),f=u,p=0,v=0}const w=Math.abs(h[t]||0),m=Math.abs(l[t]||0);w>p&&(p=w),m>v&&(v=m)}return d}({channelData:t,barIndexScale:h,barSpacing:l,barWidth:a,halfHeight:o,vScale:r,canvasHeight:s,barAlign:e.barAlign,barMinHeight:u});n.beginPath();for(const t of d)c&&"roundRect"in n?n.roundRect(t.x,t.y,t.width,t.height,c):n.rect(t.x,t.y,t.width,t.height);n.fill(),n.closePath()}renderLineWaveform(t,e,n,r){const{width:i,height:s}=n.canvas,o=function({channelData:t,width:e,height:n,vScale:r}){const i=n/2,s=t[0]||[];return[s,t[1]||s].map(((t,n)=>{const s=t.length,o=s?e/s:0,a=i,c=0===n?-1:1,h=[{x:0,y:a}];let l=0,u=0;for(let e=0;e<=s;e++){const n=Math.round(e*o);if(n>l){const t=a+(Math.round(u*i*r)||1)*c;h.push({x:l,y:t}),l=n,u=0}const s=Math.abs(t[e]||0);s>u&&(u=s)}return h.push({x:l,y:a}),h}))}({channelData:t,width:i,height:s,vScale:r});n.beginPath();for(const t of o)if(t.length){n.moveTo(t[0].x,t[0].y);for(let e=1;e<t.length;e++){const r=t[e];n.lineTo(r.x,r.y)}}n.fill(),n.closePath()}renderWaveform(t,e,n){if(n.fillStyle=this.convertColorValues(e.waveColor,n),e.renderFunction)return void e.renderFunction(t,n);const r=function({channelData:t,barHeight:e,normalize:n,maxPeak:r}){var i;const s=e||1;if(!n)return s;const o=t[0];if(!o||0===o.length)return s;let a=null!=r?r:0;if(!r)for(let t=0;t<o.length;t++){const e=null!==(i=o[t])&&void 0!==i?i:0,n=Math.abs(e);n>a&&(a=n)}return a?s/a:s}({channelData:t,barHeight:e.barHeight,normalize:e.normalize,maxPeak:e.maxPeak});W(e)?this.renderBarWaveform(t,e,n,r):this.renderLineWaveform(t,e,n,r)}renderSingleCanvas(t,e,n,r,i,s,o){const a=this.getPixelRatio(),c=document.createElement("canvas");c.width=Math.round(n*a),c.height=Math.round(r*a),c.style.width=`${n}px`,c.style.height=`${r}px`,c.style.left=`${Math.round(i)}px`,s.appendChild(c);const h=c.getContext("2d");if(e.renderFunction?(h.fillStyle=this.convertColorValues(e.waveColor,h),e.renderFunction(t,h)):this.renderWaveform(t,e,h),c.width>0&&c.height>0){const t=c.cloneNode(),n=t.getContext("2d");n.drawImage(c,0,0),n.globalCompositeOperation="source-in",n.fillStyle=this.convertColorValues(e.progressColor,n),n.fillRect(0,0,c.width,c.height),o.appendChild(t)}}renderMultiCanvas(t,e,n,r,i,s){const o=this.getPixelRatio(),{clientWidth:a}=this.scrollContainer,c=n/o,h=function({clientWidth:t,totalWidth:e,options:n}){return j(Math.min(8e3,t,e),n)}({clientWidth:a,totalWidth:c,options:e});let l={};if(0===h)return;const u=n=>{if(n<0||n>=d)return;if(l[n])return;l[n]=!0;const o=n*h;let a=Math.min(c-o,h);if(a=j(a,e),a<=0)return;const u=function({channelData:t,offset:e,clampedWidth:n,totalWidth:r}){return t.map((t=>{const i=Math.floor(e/r*t.length),s=Math.floor((e+n)/r*t.length);return t.slice(i,s)}))}({channelData:t,offset:o,clampedWidth:a,totalWidth:c});this.renderSingleCanvas(u,e,a,r,o,i,s)},d=Math.ceil(c/h);if(this.isScrollable){if(_({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:c,numCanvases:d}).forEach((t=>u(t))),d>1){const t=this.on("scroll",(()=>{const{scrollLeft:t}=this.scrollContainer;Object.keys(l).length>10&&(i.innerHTML="",s.innerHTML="",l={}),_({scrollLeft:t,totalWidth:c,numCanvases:d}).forEach((t=>u(t)))}));this.unsubscribeOnScroll.push(t)}}else for(let t=0;t<d;t++)u(t)}renderChannel(t,e,n,r){var{overlay:i}=e,s=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]])}return n}(e,["overlay"]);const o=document.createElement("div"),a=this.getHeight(s.height,s.splitChannels);o.style.height=`${a}px`,i&&r>0&&(o.style.marginTop=`-${a}px`),this.canvasWrapper.style.minHeight=`${a}px`,this.canvasWrapper.appendChild(o);const c=o.cloneNode();this.progressWrapper.appendChild(c),this.renderMultiCanvas(t,s,n,a,o,c)}render(t){return g(this,void 0,void 0,(function*(){var e;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);const n=this.getPixelRatio(),r=this.scrollContainer.clientWidth,{scrollWidth:i,isScrollable:s,useParentWidth:o,width:a}=function({duration:t,minPxPerSec:e=0,parentWidth:n,fillParent:r,pixelRatio:i}){const s=Math.ceil(t*e),o=s>n,a=Boolean(r&&!o);return{scrollWidth:s,isScrollable:o,useParentWidth:a,width:(a?n:s)*i}}({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:r,fillParent:this.options.fillParent,pixelRatio:n});if(this.isScrollable=s,this.wrapper.style.width=o?"100%":`${i}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 n=0;n<t.numberOfChannels;n++){const r=Object.assign(Object.assign({},this.options),null===(e=this.options.splitChannels)||void 0===e?void 0:e[n]);this.renderChannel([t.getChannelData(n)],r,a,n)}else{const e=[t.getChannelData(0)];t.numberOfChannels>1&&e.push(t.getChannelData(1)),this.renderChannel(e,this.options,a,0)}Promise.resolve().then((()=>this.emit("rendered")))}))}reRender(){if(this.unsubscribeOnScroll.forEach((t=>t())),this.unsubscribeOnScroll=[],!this.audioData)return;const{scrollWidth:t}=this.scrollContainer,{right:e}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:t}=this.progressWrapper.getBoundingClientRect(),n=function(t){const e=2*t;return(e<0?Math.floor(e):Math.ceil(e))/2}(t-e);this.scrollContainer.scrollLeft+=n}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,e=!1){const{scrollLeft:n,scrollWidth:r,clientWidth:i}=this.scrollContainer,s=t*r,o=n,a=n+i,c=i/2;if(this.isDragging){const t=30;s+t>a?this.scrollContainer.scrollLeft+=t:s-t<o&&(this.scrollContainer.scrollLeft-=t)}else{(s<o||s>a)&&(this.scrollContainer.scrollLeft=s-(this.options.autoCenter?c:0));const t=s-n-c;e&&this.options.autoCenter&&t>0&&(this.scrollContainer.scrollLeft+=t)}}renderProgress(t,e){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,e)}exportImage(t,e,n){return g(this,void 0,void 0,(function*(){const r=this.canvasWrapper.querySelectorAll("canvas");if(!r.length)throw new Error("No waveform data");if("dataURL"===n){const n=Array.from(r).map((n=>n.toDataURL(t,e)));return Promise.resolve(n)}return Promise.all(Array.from(r).map((n=>new Promise(((r,i)=>{n.toBlob((t=>{t?r(t):i(new Error("Could not export image"))}),t,e)})))))}))}}class V extends b{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,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop()}}class D extends b{constructor(t=new AudioContext){super(),this.bufferNode=null,this.playStartTime=0,this.playedDuration=0,this._muted=!1,this._playbackRate=1,this._duration=void 0,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.seeking=!1,this.autoplay=!1,this.addEventListener=this.on,this.removeEventListener=this.un,this.audioContext=t,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return g(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((e=>{if(e.status>=400)throw new 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())})).catch((t=>{console.error("WebAudioPlayer load error:",t)}))}_play(){if(!this.paused)return;this.paused=!1,this.bufferNode&&(this.bufferNode.onended=null,this.bufferNode.disconnect()),this.bufferNode=this.audioContext.createBufferSource(),this.buffer&&(this.bufferNode.buffer=this.buffer),this.bufferNode.playbackRate.value=this._playbackRate,this.bufferNode.connect(this.gainNode);let t=this.playedDuration*this._playbackRate;(t>=this.duration||t<0)&&(t=0,this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,t),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 g(this,void 0,void 0,(function*(){this.paused&&(this._play(),this.emit("play"))}))}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){const e=this.bufferNode;null==e||e.stop(this.audioContext.currentTime+(t-this.currentTime)),null==e||e.addEventListener("ended",(()=>{e===this.bufferNode&&(this.bufferNode=null,this.pause())}),{once:!0})}setSinkId(t){return g(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}set currentTime(t){const e=!this.paused;e&&this._pause(),this.playedDuration=t/this._playbackRate,e&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,e;return null!==(t=this._duration)&&void 0!==t?t:(null===(e=this.buffer)||void 0===e?void 0:e.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 e=this.buffer.numberOfChannels;for(let n=0;n<e;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 L={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class z extends T{static create(t){return new z(t)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(t){const e=t.media||("WebAudio"===t.backend?new D:void 0);super({media:e,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({},L,t);const{state:n,actions:r}=function(t){var e,n,r,i,s,o;const a=null!==(e=null==t?void 0:t.currentTime)&&void 0!==e?e:A(0),c=null!==(n=null==t?void 0:t.duration)&&void 0!==n?n:A(0),h=null!==(r=null==t?void 0:t.isPlaying)&&void 0!==r?r:A(!1),l=null!==(i=null==t?void 0:t.isSeeking)&&void 0!==i?i:A(!1),u=null!==(s=null==t?void 0:t.volume)&&void 0!==s?s:A(1),d=null!==(o=null==t?void 0:t.playbackRate)&&void 0!==o?o:A(1),f=A(null),p=A(null),v=A(""),w=A(0),m=A(0),y=S((()=>!h.value),[h]),g=S((()=>null!==f.value),[f]),b=S((()=>g.value&&c.value>0),[g,c]),M=S((()=>a.value),[a]),k=S((()=>c.value>0?a.value/c.value:0),[a,c]);return{state:{currentTime:a,duration:c,isPlaying:h,isPaused:y,isSeeking:l,volume:u,playbackRate:d,audioBuffer:f,peaks:p,url:v,zoom:w,scrollPosition:m,canPlay:g,isReady:b,progress:M,progressPercent:k},actions:{setCurrentTime:t=>{const e=Math.max(0,Math.min(c.value||1/0,t));a.set(e)},setDuration:t=>{c.set(Math.max(0,t))},setPlaying:t=>{h.set(t)},setSeeking:t=>{l.set(t)},setVolume:t=>{const e=Math.max(0,Math.min(1,t));u.set(e)},setPlaybackRate:t=>{const e=Math.max(.1,Math.min(16,t));d.set(e)},setAudioBuffer:t=>{f.set(t),t&&c.set(t.duration)},setPeaks:t=>{p.set(t)},setUrl:t=>{v.set(t)},setZoom:t=>{w.set(Math.max(0,t))},setScrollPosition:t=>{m.set(Math.max(0,t))}}}}({isPlaying:this.isPlayingSignal,currentTime:this.currentTimeSignal,duration:this.durationSignal,volume:this.volumeSignal,playbackRate:this.playbackRateSignal,isSeeking:this.seekingSignal});this.wavesurferState=n,this.wavesurferActions=r,this.timer=new V;const i=e?void 0:this.getMediaElement();this.renderer=new N(this.options,i),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initReactiveState(),this.initPlugins();const s=this.options.url||this.getSrc()||"";Promise.resolve().then((()=>{this.emit("init");const{peaks:t,duration:e}=this.options;(s||t&&e)&&this.load(s,t,e).catch((t=>{this.emit("error",t instanceof Error?t:new Error(String(t)))}))}))}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),null!=this.stopAtPosition&&this.isPlaying()&&t>=this.stopAtPosition&&this.pause()}})))}initReactiveState(){this.reactiveCleanups.push(function(t,e){const n=[];n.push(I((()=>{e.emit(t.isPlaying.value?"play":"pause")}),[t.isPlaying])),n.push(I((()=>{const n=t.currentTime.value;e.emit("timeupdate",n),t.isPlaying.value&&e.emit("audioprocess",n)}),[t.currentTime,t.isPlaying])),n.push(I((()=>{t.isSeeking.value&&e.emit("seeking",t.currentTime.value)}),[t.isSeeking,t.currentTime]));let r=!1;n.push(I((()=>{t.isReady.value&&!r&&(r=!0,e.emit("ready",t.duration.value))}),[t.isReady,t.duration]));let i=!1;return n.push(I((()=>{const n=t.isPlaying.value,r=t.duration.value,s=r>0&&t.currentTime.value>=r;i&&!n&&s&&e.emit("finish"),i=n&&s}),[t.isPlaying,t.currentTime,t.duration])),n.push(I((()=>{const n=t.zoom.value;n>0&&e.emit("zoom",n)}),[t.zoom])),()=>{n.forEach((t=>t()))}}(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",null!==(t=this.getMediaElement().error)&&void 0!==t?t:new Error("Media error")),this.stopAtPosition=null})))}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,n,r)=>{const i=this.getDuration();this.emit("scroll",t*i,e*i,n,r)})),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 e=this.renderer.on("drag",(e=>{var n;if(!this.options.interact)return;this.renderer.renderProgress(e),clearTimeout(t);let r=0;const i=this.options.dragToSeek;this.isPlaying()?r=0:!0===i?r=200:i&&"object"==typeof i&&(r=null!==(n=i.debounceTime)&&void 0!==n?n:200),t=setTimeout((()=>{this.seekTo(e)}),r),this.emit("interaction",e*this.getDuration()),this.emit("drag",e)}));this.subscriptions.push((()=>{clearTimeout(t),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),t.duration&&!t.peaks&&(this.decodedData=M.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=M.createBuffer(t.peaks,t.duration)),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),null!=t.mediaControls&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){if(this.plugins.includes(t))return t;t._init(this),this.plugins.push(t);const e=t.once("destroy",(()=>{this.plugins=this.plugins.filter((e=>e!==t)),this.subscriptions=this.subscriptions.filter((t=>t!==e))}));return this.subscriptions.push(e),t}unregisterPlugin(t){this.plugins=this.plugins.filter((e=>e!==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 e=t/this.getDuration();this.renderer.setScrollPercentage(e)}getActivePlugins(){return this.plugins}loadAudio(t,e,n,r){return g(this,void 0,void 0,(function*(){var i;if(this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,this.stopAtPosition=null,null===(i=this.abortController)||void 0===i||i.abort(),this.abortController=null,!e&&!n){const n=this.options.fetchParams||{};window.AbortController&&!n.signal&&(this.abortController=new AbortController,n.signal=this.abortController.signal);const r=t=>this.emit("loading",t);e=yield C.fetchBlob(t,r,n);const i=this.options.blobMimeType;i&&(e=new Blob([e],{type:i}))}this.setSrc(t,e);const s=yield new Promise((t=>{const e=r||this.getDuration();e?t(e):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",(()=>t(this.getDuration())),{once:!0}))}));if(!t&&!e){const t=this.getMediaElement();t instanceof D&&(t.duration=s)}if(n)this.decodedData=M.createBuffer(n,s||0);else if(e){const t=yield e.arrayBuffer();this.decodedData=yield M.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,n){return g(this,void 0,void 0,(function*(){try{return yield this.loadAudio(t,void 0,e,n)}catch(t){throw this.emit("error",t),t}}))}loadBlob(t,e,n){return g(this,void 0,void 0,(function*(){try{return yield this.loadAudio("",t,e,n)}catch(t){throw this.emit("error",t),t}}))}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:e=8e3,precision:n=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const r=Math.min(t,this.decodedData.numberOfChannels),i=[];for(let t=0;t<r;t++){const r=this.decodedData.getChannelData(t),s=[],o=r.length/e;for(let t=0;t<e;t++){const e=r.slice(Math.floor(t*o),Math.ceil((t+1)*o));let i=0;for(let t=0;t<e.length;t++){const n=e[t];Math.abs(n)>Math.abs(i)&&(i=n)}s.push(Math.round(i*n)/n)}i.push(s)}return i}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){this.stopAtPosition=null,super.setTime(t),this.updateProgress(t),this.emit("timeupdate",t)}seekTo(t){const e=this.getDuration()*t;this.setTime(e)}play(t,e){const n=Object.create(null,{play:{get:()=>super.play}});return g(this,void 0,void 0,(function*(){null!=t&&this.setTime(t);const r=yield n.play.call(this);return null!=e&&(this.media instanceof D?this.media.stopAt(e):this.stopAtPosition=e),r}))}playPause(){return g(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 g(this,arguments,void 0,(function*(t="image/png",e=1,n="dataURL"){return this.renderer.exportImage(t,e,n)}))}destroy(){var t;this.emit("destroy"),null===(t=this.abortController)||void 0===t||t.abort(),this.plugins.forEach((t=>t.destroy())),this.subscriptions.forEach((t=>t())),this.unsubscribePlayerEvents(),this.reactiveCleanups.forEach((t=>t())),this.reactiveCleanups=[],this.timer.destroy(),this.renderer.destroy(),super.destroy()}}function B(t,e,n,r){return new(n||(n=Promise))((function(e,i){function s(t){try{a(r.next(t))}catch(t){i(t)}}function o(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var r;t.done?e(t.value):(r=t.value,r instanceof n?r:new n((function(t){t(r)}))).then(s,o)}a((r=r.apply(t,[])).next())}))}z.BasePlugin=class extends b{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}},z.dom=E,"function"==typeof SuppressedError&&SuppressedError;class F{constructor(){this.listeners={}}on(t,e,n){if(this.listeners[t]||(this.listeners[t]=new Set),null==n?void 0:n.once){const n=(...r)=>{this.un(t,n),e(...r)};return this.listeners[t].add(n),()=>this.un(t,n)}return this.listeners[t].add(e),()=>this.un(t,e)}un(t,e){var n;null===(n=this.listeners[t])||void 0===n||n.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 H extends F{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}}class $ extends F{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,null!==this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop()}}const q=["audio/webm","audio/wav","audio/mpeg","audio/mp4","audio/mp3"];class X extends H{constructor(t){var e,n,r,i,s,o;super(Object.assign(Object.assign({},t),{audioBitsPerSecond:null!==(e=t.audioBitsPerSecond)&&void 0!==e?e:128e3,scrollingWaveform:null!==(n=t.scrollingWaveform)&&void 0!==n&&n,scrollingWaveformWindow:null!==(r=t.scrollingWaveformWindow)&&void 0!==r?r:5,continuousWaveform:null!==(i=t.continuousWaveform)&&void 0!==i&&i,renderRecordedAudio:null===(s=t.renderRecordedAudio)||void 0===s||s,mediaRecorderTimeslice:null!==(o=t.mediaRecorderTimeslice)&&void 0!==o?o:void 0})),this.stream=null,this.mediaRecorder=null,this.dataWindow=null,this.isWaveformPaused=!1,this.lastStartTime=0,this.lastDuration=0,this.duration=0,this.micStream=null,this.recordedBlobUrl=null,this.timer=new $,this.subscriptions.push(this.timer.on("tick",(()=>{const t=performance.now()-this.lastStartTime;this.duration=this.isPaused()?this.duration:this.lastDuration+t,this.emit("record-progress",this.duration)})))}static create(t){return new X(t||{})}renderMicStream(t){var e;const n=new AudioContext,r=n.createMediaStreamSource(t),i=n.createAnalyser();r.connect(i),(this.options.continuousWaveform||this.options.scrollingWaveform)&&(i.fftSize=32);const s=i.frequencyBinCount,o=new Float32Array(s);let a=0;this.wavesurfer&&(null!==(e=this.originalOptions)&&void 0!==e||(this.originalOptions=Object.assign({},this.wavesurfer.options)),this.wavesurfer.options.interact=!1,this.options.scrollingWaveform&&(this.wavesurfer.options.cursorWidth=0,this.wavesurfer.options.normalize=!0,this.wavesurfer.options.maxPeak=1));const c=setInterval((()=>{var t,e,n,r;if(!this.isWaveformPaused){if(i.getFloatTimeDomainData(o),this.options.scrollingWaveform){const t=Math.floor(100*(this.options.scrollingWaveformWindow||0));let e=0;for(let t=0;t<s;t++){const n=Math.abs(o[t]);n>e&&(e=n)}this.dataWindow||(this.dataWindow=new Float32Array(t));const n=new Float32Array(t);if(this.dataWindow&&this.dataWindow.length>0){const e=this.dataWindow.slice(-(t-1));n.set(e,0)}n[t-1]=e,this.dataWindow=n}else if(this.options.continuousWaveform){if(!this.dataWindow){const n=this.options.continuousWaveformDuration?Math.round(100*this.options.continuousWaveformDuration):(null!==(e=null===(t=this.wavesurfer)||void 0===t?void 0:t.getWidth())&&void 0!==e?e:0)*window.devicePixelRatio;this.dataWindow=new Float32Array(n)}let n=0;for(let t=0;t<s;t++){const e=Math.abs(o[t]);e>n&&(n=e)}if(a+1>this.dataWindow.length){const t=new Float32Array(2*this.dataWindow.length);t.set(this.dataWindow,0),this.dataWindow=t}this.dataWindow[a]=n,a++}else this.dataWindow=o;if(this.wavesurfer){const t=(null!==(r=null===(n=this.dataWindow)||void 0===n?void 0:n.length)&&void 0!==r?r:0)/100;this.wavesurfer.load("",[this.dataWindow],this.options.scrollingWaveform?this.options.scrollingWaveformWindow:t).then((()=>{this.wavesurfer&&this.options.continuousWaveform&&(this.wavesurfer.setTime(this.getDuration()/1e3),this.wavesurfer.options.minPxPerSec||this.wavesurfer.setOptions({minPxPerSec:this.wavesurfer.getWidth()/this.wavesurfer.getDuration()}))})).catch((t=>{console.error("Error rendering real-time recording data:",t)}))}}}),10);return{onDestroy:()=>{clearInterval(c),null==r||r.disconnect(),null==n||n.close()},onEnd:()=>{this.isWaveformPaused=!0,this.stopMic()}}}startMic(t){return B(this,0,void 0,(function*(){let e;this.micStream&&this.stopMic();try{e=yield navigator.mediaDevices.getUserMedia({audio:null==t||t})}catch(e){throw new Error("Error accessing the microphone: "+e.message)}const n=this.renderMicStream(e);return this.micStream=n,this.unsubscribeDestroy=this.once("destroy",n.onDestroy),this.unsubscribeRecordEnd=this.once("record-end",n.onEnd),this.stream=e,e}))}stopMic(){var t,e,n;null===(t=this.micStream)||void 0===t||t.onDestroy(),null===(e=this.unsubscribeDestroy)||void 0===e||e.call(this),null===(n=this.unsubscribeRecordEnd)||void 0===n||n.call(this),this.micStream=null,this.unsubscribeDestroy=void 0,this.unsubscribeRecordEnd=void 0,this.stream&&(this.stream.getTracks().forEach((t=>t.stop())),this.stream=null,this.mediaRecorder=null)}startRecording(t){return B(this,0,void 0,(function*(){const e=this.stream||(yield this.startMic(t));this.dataWindow=null;const n=this.mediaRecorder||new MediaRecorder(e,{mimeType:this.options.mimeType||q.find((t=>MediaRecorder.isTypeSupported(t))),audioBitsPerSecond:this.options.audioBitsPerSecond});this.mediaRecorder=n,this.stopRecording();const r=[];n.ondataavailable=t=>{t.data.size>0&&r.push(t.data),this.emit("record-data-available",t.data)};const i=t=>{var e;const i=new Blob(r,{type:n.mimeType});this.emit(t,i),this.options.renderRecordedAudio&&(this.applyOriginalOptionsIfNeeded(),this.recordedBlobUrl&&URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=URL.createObjectURL(i),null===(e=this.wavesurfer)||void 0===e||e.load(this.recordedBlobUrl))};n.onpause=()=>i("record-pause"),n.onstop=()=>i("record-end"),n.start(this.options.mediaRecorderTimeslice),this.lastStartTime=performance.now(),this.lastDuration=0,this.duration=0,this.isWaveformPaused=!1,this.timer.start(),this.emit("record-start")}))}getDuration(){return this.duration}isRecording(){var t;return"recording"===(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}isPaused(){var t;return"paused"===(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}isActive(){var t;return"inactive"!==(null===(t=this.mediaRecorder)||void 0===t?void 0:t.state)}stopRecording(){var t;this.isActive()&&(null===(t=this.mediaRecorder)||void 0===t||t.stop(),this.timer.stop())}pauseRecording(){var t,e;this.isRecording()&&(this.isWaveformPaused=!0,null===(t=this.mediaRecorder)||void 0===t||t.requestData(),null===(e=this.mediaRecorder)||void 0===e||e.pause(),this.timer.stop(),this.lastDuration=this.duration)}resumeRecording(){var t;this.isPaused()&&(this.isWaveformPaused=!1,null===(t=this.mediaRecorder)||void 0===t||t.resume(),this.timer.start(),this.lastStartTime=performance.now(),this.emit("record-resume"))}static getAvailableAudioDevices(){return B(this,0,void 0,(function*(){return navigator.mediaDevices.enumerateDevices().then((t=>t.filter((t=>"audioinput"===t.kind))))}))}destroy(){this.applyOriginalOptionsIfNeeded(),super.destroy(),this.stopRecording(),this.stopMic(),this.recordedBlobUrl&&(URL.revokeObjectURL(this.recordedBlobUrl),this.recordedBlobUrl=null)}applyOriginalOptionsIfNeeded(){this.wavesurfer&&this.originalOptions&&(this.wavesurfer.setOptions(this.originalOptions),delete this.originalOptions)}}var K,Y,Z,G,J,Q,tt,et,nt,rt={exports:{}},it=(K||(K=1,Y=rt.exports,Z=function(t){return function(e){var n=t(e);return e.add(n),n}},G=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,J=2*536870912,Q=function(t,e){return function(n){var r=e.get(n),i=void 0===r?n.size:r<J?r+1:0;if(!n.has(i))return t(n,i);if(n.size<536870912){for(;n.has(i);)i=Math.floor(Math.random()*J);return t(n,i)}if(n.size>G)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;n.has(i);)i=Math.floor(Math.random()*G);return t(n,i)}},nt=Z(et=Q(function(t){return function(e,n){return t.set(e,n),n}}(tt=new WeakMap),tt)),Y.addUniqueNumber=nt,Y.generateUniqueNumber=et),rt.exports);const st=((t,e,n)=>r=>{const i=e(r);return e=>{const r=t(e);e.addEventListener("message",(({data:t})=>{const{id:e}=t;if(null!==e&&r.has(e)){const{reject:n,resolve:i}=r.get(e);r.delete(e),void 0===t.error?i(t.result):n(new Error(t.error.message))}})),(t=>"function"==typeof t.start)(e)&&e.start();const s=(t,i=null,s=[])=>new Promise(((o,a)=>{const c=n(r);r.set(c,{reject:a,resolve:o}),e.postMessage(null===i?{id:c,method:t}:{id:c,method:t,params:i},s)})),o=(t,n,r=[])=>{e.postMessage({id:null,method:t,params:n},r)};let a={};for(const[t,e]of Object.entries(i))a={...a,[t]:e({call:s,notify:o})};return{...a}}})((at=new WeakMap,t=>{if(at.has(t))return at.get(t);const e=new Map;return at.set(t,e),e}),(ot=new WeakMap,t=>({...t,connect:({call:t})=>async()=>{const{port1:e,port2:n}=new MessageChannel,r=await t("connect",{port:e},[e]);return ot.set(n,r),n},disconnect:({call:t})=>async e=>{const n=ot.get(e);if(void 0===n)throw new Error("The given port is not connected.");await t("disconnect",{portId:n})},isSupported:({call:t})=>()=>t("isSupported")})),it.generateUniqueNumber);var ot,at;const ct=new Set,ht=new Set,lt=new WeakMap,ut=st({deregister:({call:t})=>async e=>{const n=lt.get(e);if(void 0===n)throw new Error("There is no encoder registered with the given port.");const r=await t("deregister",{encoderId:n});return ct.delete(n),lt.delete(e),r},encode:({call:t})=>async(e,n)=>{const r=await t("encode",{encoderInstanceId:e,timeslice:n});return ht.delete(e),r},instantiate:({call:t})=>async(e,n)=>{const r=it.addUniqueNumber(ht);return{encoderInstanceId:r,port:await t("instantiate",{encoderInstanceId:r,mimeType:e,sampleRate:n})}},register:({call:t})=>async e=>{if(lt.has(e))throw new Error("");const n=it.addUniqueNumber(ct);lt.set(e,n);try{return await t("register",{encoderId:n,port:e},[e])}catch(t){throw ct.delete(n),lt.delete(e),t}}}),dt=new Blob(['(()=>{var e={455(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),c=void 0===a?r.size:a<s?a+1:0;if(!r.has(c))return e(r,c);if(r.size<o){for(;r.has(c);)c=Math.floor(Math.random()*s);return e(r,c)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(c);)c=Math.floor(Math.random()*n);return e(r,c)}},c=new WeakMap,i=r(c),d=a(i,c),l=t(d);e.addUniqueNumber=l,e.generateUniqueNumber=d}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";var e=r(455);const t=((e,t,r,n)=>o=>{const s=t(o);return t=>{const o=e(t);t.addEventListener("message",({data:e})=>{const{id:t}=e;if(null!==t&&o.has(t)){const{reject:r,resolve:n}=o.get(t);o.delete(t),void 0===e.error?n(e.result):r(new Error(e.error.message))}}),n(t)&&t.start();const a=(e,n=null,s=[])=>new Promise((a,c)=>{const i=r(o);o.set(i,{reject:c,resolve:a}),null===n?t.postMessage({id:i,method:e},s):t.postMessage({id:i,method:e,params:n},s)}),c=(e,r,n=[])=>{t.postMessage({id:null,method:e,params:r},n)};let i={};for(const[e,t]of Object.entries(s))i={...i,[e]:t({call:a,notify:c})};return{...i}}})((o=new WeakMap,e=>{if(o.has(e))return o.get(e);const t=new Map;return o.set(e,t),t}),(n=new WeakMap,e=>({...e,connect:({call:e})=>async()=>{const{port1:t,port2:r}=new MessageChannel,o=await e("connect",{port:t},[t]);return n.set(r,o),r},disconnect:({call:e})=>async t=>{const r=n.get(t);if(void 0===r)throw new Error("The given port is not connected.");await e("disconnect",{portId:r})},isSupported:({call:e})=>()=>e("isSupported")})),e.generateUniqueNumber,e=>"function"==typeof e.start);var n,o;const s=t({characterize:({call:e})=>()=>e("characterize"),encode:({call:e})=>(t,r)=>e("encode",{recordingId:t,timeslice:r}),record:({call:e})=>async(t,r,n)=>{await e("record",{recordingId:t,sampleRate:r,typedArrays:n},n.map(({buffer:e})=>e).filter(e=>e instanceof ArrayBuffer))}}),a=-32603,c=-32602,i=-32601,d=(e,t)=>Object.assign(new Error(e),{status:t}),l=e=>d(\'The handler of the method called "\'.concat(e,\'" returned an unexpected result.\'),a),u=(e,t)=>async({data:{id:r,method:n,params:o}})=>{const s=t[n];try{if(void 0===s)throw(e=>d(\'The requested method called "\'.concat(e,\'" is not supported.\'),i))(n);const t=void 0===o?s():s(o);if(void 0===t)throw(e=>d(\'The handler of the method called "\'.concat(e,\'" returned no required result.\'),a))(n);const c=t instanceof Promise?await t:t;if(null===r){if(void 0!==c.result)throw l(n)}else{if(void 0===c.result)throw l(n);const{result:t,transferables:o=[]}=c;e.postMessage({id:r,result:t},o)}}catch(t){const{message:n,status:o=-32603}=t;e.postMessage({error:{code:o,message:n},id:r})}},h=new Map,f=(t,r,n)=>({...r,connect:({port:n})=>{n.start();const o=t(n,r),s=(0,e.generateUniqueNumber)(h);return h.set(s,()=>{o(),n.close(),h.delete(s)}),{result:s}},disconnect:({portId:e})=>{const t=h.get(e);if(void 0===t)throw(e=>d(\'The specified parameter called "portId" with the given value "\'.concat(e,\'" does not identify a port connected to this worker.\'),c))(e);return t(),{result:null}},isSupported:async()=>{if(await new Promise(e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])})){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),w=(e,t,r=()=>!0)=>{const n=f(w,t,r),o=u(e,n);return e.addEventListener("message",o),()=>e.removeEventListener("message",o)},p=e=>{e.onmessage=null,e.close()},m=new Map,g=new Map,v=((e,t)=>r=>{const n=t.get(r);if(void 0===n)throw new Error("There was no encoder stored with the given id.");e.delete(n),t.delete(r)})(m,g),y=new Map,M=(e=>t=>{const r=e.get(t);if(void 0===r)throw new Error("There was no instance of an encoder stored with the given id.");return r})(y),E=((e,t)=>r=>{const n=t(r);return e.delete(r),n})(y,M),b=((e,t)=>r=>{const[n,o,s,a]=t(r);return s?new Promise(t=>{o.onmessage=({data:s})=>{0===s.length?(e(o),t(n.encode(r,null))):n.record(r,a,s)}}):n.encode(r,null)})(p,E),T=(e=>t=>{for(const[r,n]of Array.from(e.values()))if(r.test(t))return n;throw new Error("There is no encoder registered which could handle the given mimeType.")})(m),I=((e,t,r)=>(n,o,s)=>{if(t.has(n))throw new Error(\'There is already an encoder instance registered with an id called "\'.concat(n,\'".\'));const a=r(o),{port1:c,port2:i}=new MessageChannel,d=[a,c,!0,s];return t.set(n,d),c.onmessage=({data:t})=>{0===t.length?(e(c),d[2]=!1):a.record(n,s,t.map(e=>"number"==typeof e?new Float32Array(e):e))},i})(p,y,T),A=((e,t,r)=>async(n,o)=>{const s=r(o),a=await s.characterize(),c=a.toString();if(e.has(c))throw new Error("There is already an encoder stored which handles exactly the same mime types.");if(t.has(n))throw new Error(\'There is already an encoder registered with an id called "\'.concat(n,\'".\'));return e.set(c,[a,s]),t.set(n,c),a})(m,g,s),N=(e=>(t,r)=>{const[n]=e(t);return n.encode(t,r)})(M);w(self,{deregister:async({encoderId:e})=>(v(e),{result:null}),encode:async({encoderInstanceId:e,timeslice:t})=>{const r=null===t?await b(e):await N(e,t);return{result:r,transferables:r}},instantiate:({encoderInstanceId:e,mimeType:t,sampleRate:r})=>{const n=I(e,t,r);return{result:n,transferables:[n]}},register:async({encoderId:e,port:t})=>({result:await A(e,t)})})})()})();'],{type:"application/javascript; charset=utf-8"}),ft=URL.createObjectURL(dt),pt=(()=>{const t=new Worker(ft);return ut(t)})(),vt=pt.encode,wt=pt.instantiate,mt=pt.register;URL.revokeObjectURL(ft);const yt=()=>{try{return new DOMException("","NotSupportedError")}catch(t){return t.code=9,t.name="NotSupportedError",t}},gt=Symbol.observable||"@@observable",bt=()=>{},Mt=t=>{throw t},kt=(t=>(e,n,r)=>t((t=>{const i=e=>t.next(e);return e.addEventListener(n,i,r),()=>e.removeEventListener(n,i,r)})))(((t,e)=>{const n=()=>{};return t=>{const r=(...r)=>{const i=t((t=>"function"==typeof t[0])(r)?e({next:r[0]}):e(...r));return void 0!==i?i:n};return r[Symbol.observable]=()=>({subscribe:(...t)=>({unsubscribe:r(...t)})}),i=r,Symbol.observable||("function"==typeof i&&i.prototype&&i.prototype[Symbol.observable]?(i.prototype[gt]=i.prototype[Symbol.observable],delete i.prototype[Symbol.observable]):(i[gt]=i[Symbol.observable],delete i[Symbol.observable])),i;var i}})(0,(function(t){return t?t.next&&t.error&&t.complete?t:{complete:(t.complete??bt).bind(t),error:(t.error??Mt).bind(t),next:(t.next??bt).bind(t)}:{complete:bt,error:Mt,next:bt}}))),xt=(Ct=Blob,At=URL,async t=>{const e=new Ct(['(()=>{"use strict";class e extends AudioWorkletProcessor{constructor(){super(),this._encoderPort=null,this._numberOfChannels=0,this._state="inactive",this.port.onmessage=({data:e})=>{"pause"===e.method?"active"===this._state||"recording"===this._state?(this._state="paused",this._sendAcknowledgement(e.id)):this._sendUnexpectedStateError(e.id):"record"===e.method?"inactive"===this._state?(this._encoderPort=e.params.encoderPort,this._state="active",this._sendAcknowledgement(e.id)):this._sendUnexpectedStateError(e.id):"resume"===e.method?"paused"===this._state?(this._state="active",this._sendAcknowledgement(e.id)):this._sendUnexpectedStateError(e.id):"stop"===e.method?"active"!==this._state&&"paused"!==this._state&&"recording"!==this._state||null===this._encoderPort?this._sendUnexpectedStateError(e.id):(this._stop(this._encoderPort),this._sendAcknowledgement(e.id)):"number"==typeof e.id&&this.port.postMessage({error:{code:-32601,message:"The requested method is not supported."},id:e.id})}}process([e]){if("inactive"===this._state||"paused"===this._state)return!0;if("active"===this._state){if(void 0===e)throw new Error("No channelData was received for the first input.");if(0===e.length)return!0;this._state="recording"}if("recording"===this._state&&null!==this._encoderPort){if(void 0===e)throw new Error("No channelData was received for the first input.");return 0===e.length?this._encoderPort.postMessage(Array.from({length:this._numberOfChannels},()=>128)):(this._encoderPort.postMessage(e,e.map(({buffer:e})=>e)),this._numberOfChannels=e.length),!0}return!1}_sendAcknowledgement(e){this.port.postMessage({id:e,result:null})}_sendUnexpectedStateError(e){this.port.postMessage({error:{code:-32603,message:"The internal state does not allow to process the given message."},id:e})}_stop(e){e.postMessage([]),e.close(),this._encoderPort=null,this._state="stopped"}}e.parameterDescriptors=[],registerProcessor("recorder-audio-worklet-processor",e)})();'],{type:"application/javascript; charset=utf-8"}),n=At.createObjectURL(e);try{await t(n)}finally{At.revokeObjectURL(n)}}),Et=((t,e,n,r)=>(t,i,s={})=>{const o=new t(i,"recorder-audio-worklet-processor",{...s,channelCountMode:"explicit",numberOfInputs:1,numberOfOutputs:0}),a=new Map,c=e(a,o.port),h=n(o.port,"message")((t=>({data:e})=>{const{id:n}=e;if(null!==n){const r=t.get(n);if(void 0!==r){const{reject:i,resolve:s}=r;t.delete(n),void 0===e.error?s(e.result):i(new Error(e.error.message))}}})(a));o.port.start();let l="inactive";return Object.defineProperties(o,{pause:{get:()=>async()=>(r(["recording"],l),l="paused",c({method:"pause"}))},port:{get(){throw new Error("The port of a RecorderAudioWorkletNode can't be accessed.")}},record:{get:()=>async t=>(r(["inactive"],l),l="recording",c({method:"record",params:{encoderPort:t}},[t]))},resume:{get:()=>async()=>(r(["paused"],l),l="recording",c({method:"resume"}))},stop:{get:()=>async()=>{r(["paused","recording"],l),l="stopped";try{await c({method:"stop"})}finally{h()}}}}),o})(0,(t=>(e,n)=>(r,i=[])=>new Promise(((s,o)=>{const a=t(e);e.set(a,{reject:o,resolve:s}),n.postMessage({id:a,...r},i)})))(it.generateUniqueNumber),kt,((t,e)=>{if(!t.includes(e))throw new Error(`Expected the state to be ${t.map((t=>`"${t}"`)).join(" or ")} but it was "${e}".`)}));var Ct,At,St={exports:{}};function It(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var Tt=Object.freeze({__proto__:null,default:function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,s,o,a=[],c=!0,h=!1;try{if(s=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=s.call(n)).done)&&(a.push(r.value),a.length!==e);c=!0);}catch(t){h=!0,i=t}finally{try{if(!c&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(h)throw i}}return a}}(t,e)||function(t,e){if(t){if("string"==typeof t)return It(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?It(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}}),Rt=o(Tt),Ot=Object.freeze({__proto__:null,default:function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}}),Pt=o(Ot);function Wt(t){return Wt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Wt(t)}function jt(t){var e=function(t){if("object"!=Wt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Wt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Wt(e)?e:e+""}function _t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,jt(r.key),r)}}var Ut,Nt=Object.freeze({__proto__:null,default:function(t,e,n){return e&&_t(t.prototype,e),n&&_t(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}}),Vt=o(Nt),Dt=(Ut||(Ut=1,function(t,e,n,r){var i=function(t,e,n){return{endTime:e,insertTime:n,type:"exponentialRampToValue",value:t}},s=function(t,e,n){return{endTime:e,insertTime:n,type:"linearRampToValue",value:t}},o=function(t,e){return{startTime:e,type:"setValue",value:t}},a=function(t,e,n){return{duration:n,startTime:e,type:"setValueCurve",values:t}},c=function(t,e,n){var r=n.target;return r+(e-r)*Math.exp((n.startTime-t)/n.timeConstant)},h=function(t){return"exponentialRampToValue"===t.type},l=function(t){return"linearRampToValue"===t.type},u=function(t){return h(t)||l(t)},d=function(t){return"setValue"===t.type},f=function(t){return"setValueCurve"===t.type},p=function(t,e,n,r){var i=t[e];return void 0===i?r:u(i)||d(i)?i.value:f(i)?i.values[i.values.length-1]:c(n,p(t,e-1,i.startTime,r),i)},v=function(t,e,n,r,i){return void 0===n?[r.insertTime,i]:u(n)?[n.endTime,n.value]:d(n)?[n.startTime,n.value]:f(n)?[n.startTime+n.duration,n.values[n.values.length-1]]:[n.startTime,p(t,e-1,n.startTime,i)]},w=function(t){return"cancelAndHold"===t.type},m=function(t){return"cancelScheduledValues"===t.type},y=function(t){return w(t)||m(t)?t.cancelTime:h(t)||l(t)?t.endTime:t.startTime},g=function(t,e,n,r){var i=r.value;return n===i?i:0<n&&0<i||n<0&&i<0?n*Math.pow(i/n,(t-e)/(r.endTime-e)):0},b=function(t,e,n,r){return n+(t-e)/(r.endTime-e)*(r.value-n)},M=function(t,e){var n=e.values;return function(t,e){var n=Math.floor(e),r=Math.ceil(e);return n===r?t[n]:(1-(e-n))*t[n]+(1-(r-e))*t[r]}(n,(t-e.startTime)/e.duration*(n.length-1))},k=function(t){return"setTarget"===t.type},x=function(){return r((function t(e){n(this,t),this._automationEvents=[],this._currenTime=0,this._defaultValue=e}),[{key:Symbol.iterator,value:function(){return this._automationEvents[Symbol.iterator]()}},{key:"add",value:function(t){var e=y(t);if(w(t)||m(t)){var n=this._automationEvents.findIndex((function(n){return m(t)&&f(n)?n.startTime+n.duration>=e:y(n)>=e})),r=this._automationEvents[n];if(-1!==n&&(this._automationEvents=this._automationEvents.slice(0,n)),w(t)){var c=this._automationEvents[this._automationEvents.length-1];if(void 0!==r&&u(r)){if(void 0!==c&&k(c))throw new Error("The internal list is malformed.");var d=void 0===c?r.insertTime:f(c)?c.startTime+c.duration:y(c),p=void 0===c?this._defaultValue:f(c)?c.values[c.values.length-1]:c.value,v=h(r)?g(e,d,p,r):b(e,d,p,r),M=h(r)?i(v,e,this._currenTime):s(v,e,this._currenTime);this._automationEvents.push(M)}if(void 0!==c&&k(c)&&this._automationEvents.push(o(this.getValue(e),e)),void 0!==c&&f(c)&&c.startTime+c.duration>e){var x=e-c.startTime,E=(c.values.length-1)/c.duration,C=Math.max(2,1+Math.ceil(x*E)),A=x/(C-1)*E,S=c.values.slice(0,C);if(A<1)for(var I=1;I<C;I+=1){var T=A*I%1;S[I]=c.values[I-1]*(1-T)+c.values[I]*T}this._automationEvents[this._automationEvents.length-1]=a(S,c.startTime,x)}}}else{var R=this._automationEvents.findIndex((function(t){return y(t)>e})),O=-1===R?this._automationEvents[this._automationEvents.length-1]:this._automationEvents[R-1];if(void 0!==O&&f(O)&&y(O)+O.duration>e)return!1;var P=h(t)?i(t.value,t.endTime,this._currenTime):l(t)?s(t.value,e,this._currenTime):t;if(-1===R)this._automationEvents.push(P);else{if(f(t)&&e+t.duration>y(this._automationEvents[R]))return!1;this._automationEvents.splice(R,0,P)}}return!0}},{key:"flush",value:function(t){var e=this._automationEvents.findIndex((function(e){return y(e)>t}));if(e>1){var n=this._automationEvents.slice(e-1),r=n[0];k(r)&&n.unshift(o(p(this._automationEvents,e-2,r.startTime,this._defaultValue),r.startTime)),this._automationEvents=n}}},{key:"getValue",value:function(t){if(0===this._automationEvents.length)return this._defaultValue;var n=this._automationEvents.findIndex((function(e){return y(e)>t})),r=this._automationEvents[n],i=(-1===n?this._automationEvents.length:n)-1,s=this._automationEvents[i];if(void 0!==s&&k(s)&&(void 0===r||!u(r)||r.insertTime>t))return c(t,p(this._automationEvents,i-1,s.startTime,this._defaultValue),s);if(void 0!==s&&d(s)&&(void 0===r||!u(r)))return s.value;if(void 0!==s&&f(s)&&(void 0===r||!u(r)||s.startTime+s.duration>t))return t<s.startTime+s.duration?M(t,s):s.values[s.values.length-1];if(void 0!==s&&u(s)&&(void 0===r||!u(r)))return s.value;if(void 0!==r&&h(r)){var o=v(this._automationEvents,i,s,r,this._defaultValue),a=e(o,2);return g(t,a[0],a[1],r)}if(void 0!==r&&l(r)){var w=v(this._automationEvents,i,s,r,this._defaultValue),m=e(w,2);return b(t,m[0],m[1],r)}return this._defaultValue}}])}();t.AutomationEventList=x,t.createCancelAndHoldAutomationEvent=function(t){return{cancelTime:t,type:"cancelAndHold"}},t.createCancelScheduledValuesAutomationEvent=function(t){return{cancelTime:t,type:"cancelScheduledValues"}},t.createExponentialRampToValueAutomationEvent=function(t,e){return{endTime:e,type:"exponentialRampToValue",value:t}},t.createLinearRampToValueAutomationEvent=function(t,e){return{endTime:e,type:"linearRampToValue",value:t}},t.createSetTargetAutomationEvent=function(t,e,n){return{startTime:e,target:t,timeConstant:n,type:"setTarget"}},t.createSetValueAutomationEvent=o,t.createSetValueCurveAutomationEvent=a}(St.exports,Rt,Pt,Vt)),St.exports);const Lt=new WeakSet,zt=new WeakMap,Bt=new WeakMap,Ft=new WeakMap,Ht=new WeakMap,$t=new WeakMap,qt=new WeakMap,Xt=new WeakMap,Kt=new WeakMap,Yt=new WeakMap,Zt={construct:()=>Zt},Gt=/^import(?:(?:[\s]+[\w]+|(?:[\s]+[\w]+[\s]*,)?[\s]*\{[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?(?:[\s]*,[\s]*[\w]+(?:[\s]+as[\s]+[\w]+)?)*[\s]*}|(?:[\s]+[\w]+[\s]*,)?[\s]*\*[\s]+as[\s]+[\w]+)[\s]+from)?(?:[\s]*)("([^"\\]|\\.)+"|'([^'\\]|\\.)+')(?:[\s]*);?/,Jt=(t,e)=>{const n=[];let r=t.replace(/^[\s]+/,""),i=r.match(Gt);for(;null!==i;){const t=i[1].slice(1,-1),s=i[0].replace(/([\s]+)?;?$/,"").replace(t,new URL(t,e).toString());n.push(s),r=r.slice(i[0].length).replace(/^[\s]+/,""),i=r.match(Gt)}return[n.join(";"),r]},Qt=t=>{if(void 0!==t&&!Array.isArray(t))throw new TypeError("The parameterDescriptors property of given value for processorCtor is not an array.")},te=t=>{if(!(t=>{try{new new Proxy(t,Zt)}catch{return!1}return!0})(t))throw new TypeError("The given value for processorCtor should be a constructor.");if(null===t.prototype||"object"!=typeof t.prototype)throw new TypeError("The given value for processorCtor should have a prototype.")},ee=(t,e)=>{const n=t.get(e);if(void 0===n)throw new Error("A value with the given key could not be found.");return n},ne=(t,e)=>{const n=Array.from(t).filter(e);if(n.length>1)throw Error("More than one element was found.");if(0===n.length)throw Error("No element was found.");const[r]=n;return t.delete(r),r},re=(t,e,n,r)=>{const i=ee(t,e),s=ne(i,(t=>t[0]===n&&t[1]===r));return 0===i.size&&t.delete(e),s},ie=t=>ee(qt,t),se=t=>{if(Lt.has(t))throw new Error("The AudioNode is already stored.");Lt.add(t),ie(t).forEach((t=>t(!0)))},oe=t=>"port"in t,ae=t=>{if(!Lt.has(t))throw new Error("The AudioNode is not stored.");Lt.delete(t),ie(t).forEach((t=>t(!1)))},ce=(t,e)=>{!oe(t)&&e.every((t=>0===t.size))&&ae(t)},he=(t,e)=>t.context===e,le=t=>{try{t.copyToChannel(new Float32Array(1),0,-1)}catch{return!1}return!0},ue=()=>new DOMException("","IndexSizeError"),de={numberOfChannels:1},fe=-34028234663852886e22,pe=34028234663852886e22,ve=t=>Lt.has(t),we={buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1},me=t=>ee(zt,t),ye=t=>ee(Ft,t),ge=(t,e)=>{const{activeInputs:n}=me(t);n.forEach((n=>n.forEach((([n])=>{e.includes(t)||ge(n,[...e,t])}))));const r=(t=>"playbackRate"in t)(t)?[t.playbackRate]:oe(t)?Array.from(t.parameters.values()):(t=>"frequency"in t&&"gain"in t)(t)?[t.Q,t.detune,t.frequency,t.gain]:(t=>"offset"in t)(t)?[t.offset]:(t=>!("frequency"in t)&&"gain"in t)(t)?[t.gain]:(t=>"detune"in t&&"frequency"in t&&!("gain"in t))(t)?[t.detune,t.frequency]:(t=>"pan"in t)(t)?[t.pan]:[];for(const t of r){const n=ye(t);void 0!==n&&n.activeInputs.forEach((([t])=>ge(t,e)))}ve(t)&&ae(t)},be=t=>"context"in t,Me=t=>be(t[0]),ke=(t,e,n,r)=>{for(const e of t)if(n(e)){if(r)return!1;throw Error("The set contains at least one similar element.")}return t.add(e),!0},xe=(t,e,[n,r],i)=>{ke(t,[e,n,r],(t=>t[0]===e&&t[1]===n),i)},Ee=(t,[e,n,r],i)=>{const s=t.get(e);void 0===s?t.set(e,new Set([[n,r]])):ke(s,[n,r],(t=>t[0]===n),i)},Ce=t=>"inputs"in t,Ae=(t,e,n,r)=>{if(Ce(e)){const i=e.inputs[r];return t.connect(i,n,0),[i,n,0]}return t.connect(e,n,r),[e,n,r]},Se=(t,e,n)=>{for(const r of t)if(r[0]===e&&r[1]===n)return t.delete(r),r;return null},Ie=(t,e)=>{if(!ie(t).delete(e))throw new Error("Missing the expected event listener.")},Te=(t,e,n)=>{const r=ee(t,e),i=ne(r,(t=>t[0]===n));return 0===r.size&&t.delete(e),i},Re=(t,e,n,r)=>{Ce(e)?t.disconnect(e.inputs[r],n,0):t.disconnect(e,n,r)},Oe=t=>ee(Bt,t),Pe=t=>ee(Ht,t),We=t=>Xt.has(t),je=t=>!Lt.has(t),_e=(t,e)=>new Promise((n=>{if(null!==e)n(!0);else{const e=t.createScriptProcessor(256,1,1),r=t.createGain(),i=t.createBuffer(1,2,44100),s=i.getChannelData(0);s[0]=1,s[1]=1;const o=t.createBufferSource();o.buffer=i,o.loop=!0,o.connect(e).connect(t.destination),o.connect(r),o.disconnect(r),e.onaudioprocess=r=>{const i=r.inputBuffer.getChannelData(0);Array.prototype.some.call(i,(t=>1===t))?n(!0):n(!1),o.stop(),e.onaudioprocess=null,o.disconnect(e),e.disconnect(t.destination)},o.start()}})),Ue=(t,e)=>{const n=new Map;for(const e of t)for(const t of e){const e=n.get(t);n.set(t,void 0===e?1:e+1)}n.forEach(((t,n)=>e(n,t)))},Ne=t=>"context"in t,Ve=(t,e,n,r,i)=>{const[s,o]=((t,e,n,r)=>{const{activeInputs:i,passiveInputs:s}=me(e),o=Se(i[r],t,n);return null===o?[re(s,t,n,r)[2],!1]:[o[2],!0]})(t,n,r,i);if(null!==s&&(Ie(t,s),!o||e||We(t)||Re(Oe(t),Oe(n),r,i)),ve(n)){const{activeInputs:t}=me(n);ce(n,t)}},De=(t,e,n,r)=>{const[i,s]=((t,e,n)=>{const{activeInputs:r,passiveInputs:i}=ye(e),s=Se(r,t,n);return null===s?[Te(i,t,n)[1],!1]:[s[2],!0]})(t,n,r);null!==i&&(Ie(t,i),!s||e||We(t)||Oe(t).disconnect(Pe(n),r))};class Le{constructor(t){this._map=new Map(t)}get size(){return this._map.size}entries(){return this._map.entries()}forEach(t,e=null){return this._map.forEach(((n,r)=>t.call(e,n,r,this)))}get(t){return this._map.get(t)}has(t){return this._map.has(t)}keys(){return this._map.keys()}values(){return this._map.values()}}const ze={channelCount:2,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:1,numberOfOutputs:1,parameterData:{},processorOptions:{}};function Be(t,e,n,r,i){if("function"==typeof t.copyFromChannel)0===e[n].byteLength&&(e[n]=new Float32Array(128)),t.copyFromChannel(e[n],r,i);else{const s=t.getChannelData(r);if(0===e[n].byteLength)e[n]=s.slice(i,i+128);else{const t=new Float32Array(s.buffer,i*Float32Array.BYTES_PER_ELEMENT,128);e[n].set(t)}}}const Fe=(t,e,n,r,i)=>{"function"==typeof t.copyToChannel?0!==e[n].byteLength&&t.copyToChannel(e[n],r,i):0!==e[n].byteLength&&t.getChannelData(r).set(e[n],i)},He=(t,e)=>{const n=[];for(let r=0;r<t;r+=1){const t=[],i="number"==typeof e?e:e[r];for(let e=0;e<i;e+=1)t.push(new Float32Array(128));n.push(t)}return n},$e=async(t,e,n,r,i,s,o)=>{const a=null===e?128*Math.ceil(t.context.length/128):e.length,c=r.channelCount*r.numberOfInputs,h=i.reduce(((t,e)=>t+e),0),l=0===h?null:n.createBuffer(h,a,n.sampleRate);if(void 0===s)throw new Error("Missing the processor constructor.");const u=me(t),d=await((t,e)=>{const n=ee(Yt,t),r=Oe(e);return ee(n,r)})(n,t),f=He(r.numberOfInputs,r.channelCount),p=He(r.numberOfOutputs,i),v=Array.from(t.parameters.keys()).reduce(((t,e)=>({...t,[e]:new Float32Array(128)})),{});for(let h=0;h<a;h+=128){if(r.numberOfInputs>0&&null!==e)for(let t=0;t<r.numberOfInputs;t+=1)for(let n=0;n<r.channelCount;n+=1)Be(e,f[t],n,n,h);void 0!==s.parameterDescriptors&&null!==e&&s.parameterDescriptors.forEach((({name:t},n)=>{Be(e,v,t,c+n,h)}));for(let t=0;t<r.numberOfInputs;t+=1)for(let e=0;e<i[t];e+=1)0===p[t][e].byteLength&&(p[t][e]=new Float32Array(128));try{const t=f.map(((t,e)=>0===u.activeInputs[e].size?[]:t)),e=o(h/n.sampleRate,n.sampleRate,(()=>d.process(t,p,v)));if(null!==l)for(let t=0,e=0;t<r.numberOfOutputs;t+=1){for(let n=0;n<i[t];n+=1)Fe(l,p[t],n,e+n,h);e+=i[t]}if(!e)break}catch(e){t.dispatchEvent(new ErrorEvent("processorerror",{colno:e.colno,filename:e.filename,lineno:e.lineno,message:e.message}));break}}return l},qe=(t,e,n)=>{const r=e[n];if(void 0===r)throw t();return r},Xe=()=>new DOMException("","InvalidStateError"),Ke=t=>{const e=new Uint32Array([1179011410,40,1163280727,544501094,16,131073,44100,176400,1048580,1635017060,4,0]);try{const n=t.decodeAudioData(e.buffer,(()=>{}));return void 0!==n&&(n.catch((()=>{})),!0)}catch{}return!1},Ye=(t,e,n)=>{const r=e[n];void 0!==r&&r!==t[n]&&(t[n]=r)},Ze=(t,e)=>{Ye(t,e,"channelCount"),Ye(t,e,"channelCountMode"),Ye(t,e,"channelInterpretation")},Ge=(t,e,n)=>{const r=e[n];void 0!==r&&r!==t[n].value&&(t[n].value=r)},Je=t=>{var e;t.start=(e=t.start,(n=0,r=0,i)=>{if("number"==typeof i&&i<0||r<0||n<0)throw new RangeError("The parameters can't be negative.");e.call(t,n,r,i)})},Qe=t=>{var e;t.stop=(e=t.stop,(n=0)=>{if(n<0)throw new RangeError("The parameter can't be negative.");e.call(t,n)})},tn=(t,e)=>{const n=t.createChannelSplitter(e.numberOfOutputs);return Ze(n,e),(t=>{const e=t.numberOfOutputs;Object.defineProperty(t,"channelCount",{get:()=>e,set:t=>{if(t!==e)throw Xe()}}),Object.defineProperty(t,"channelCountMode",{get:()=>"explicit",set:t=>{if("explicit"!==t)throw Xe()}}),Object.defineProperty(t,"channelInterpretation",{get:()=>"discrete",set:t=>{if("discrete"!==t)throw Xe()}})})(n),n},en=(t,e)=>(t.connect=e.connect.bind(e),t.disconnect=e.disconnect.bind(e),t),nn=(t,e)=>{const n=t.createGain();return Ze(n,e),Ge(n,e,"gain"),n},rn=(t,e,n,r)=>t.createScriptProcessor(e,n,r),sn=()=>new DOMException("","NotSupportedError"),on=(t,e,n,r)=>{let i=t;for(;!i.hasOwnProperty(e);)i=Object.getPrototypeOf(i);const{get:s,set:o}=Object.getOwnPropertyDescriptor(i,e);Object.defineProperty(t,e,{get:n(s),set:r(o)})},an=(t,e,n)=>{try{t.setValueAtTime(e,n)}catch(r){if(9!==r.code)throw r;an(t,e,n+1e-7)}},cn=t=>{const e=t.createOscillator();try{e.start(-1)}catch(t){return t instanceof RangeError}return!1},hn=t=>{const e=t.createOscillator();try{e.stop(-1)}catch(t){return t instanceof RangeError}return!1},ln=(t,e)=>n=>{const r={value:t};return Object.defineProperties(n,{currentTarget:r,target:r}),"function"==typeof e?e.call(t,n):e.handleEvent.call(t,n)},un=(t=>(e,n,[r,i,s],o)=>{t(e[i],[n,r,s],(t=>t[0]===n&&t[1]===r),o)})(ke),dn=(t=>(e,n,[r,i,s],o)=>{const a=e.get(r);void 0===a?e.set(r,new Set([[i,n,s]])):t(a,[i,n,s],(t=>t[0]===i&&t[1]===n),o)})(ke),fn=(t=>(e,n,r,i)=>t(e[i],(t=>t[0]===n&&t[1]===r)))(ne),pn=(wn=new WeakMap,t=>{var e;return null!==(e=wn.get(t))&&void 0!==e?e:0}),vn=(mn=new Map,yn=new WeakMap,(t,e)=>{const n=yn.get(t);if(void 0!==n)return n;const r=mn.get(t);if(void 0!==r)return r;try{const n=e();return n instanceof Promise?(mn.set(t,n),n.catch((()=>!1)).then((e=>(mn.delete(t),yn.set(t,e),e)))):(yn.set(t,n),n)}catch{return yn.set(t,!1),!1}});var wn,mn,yn;const gn="undefined"==typeof window?null:window,bn=(t=>e=>{const n=t(e);if(null===n.renderer)throw new Error("Missing the renderer of the given AudioNode in the audio graph.");return n.renderer})(me),Mn=((t,e,n)=>async(r,i,s)=>{const o=t(r);await Promise.all(o.activeInputs.map(((t,o)=>Array.from(t).map((async([t,a])=>{const c=e(t),h=await c.render(t,i),l=r.context.destination;n(t)||r===l&&n(r)||h.connect(s,a,o)})))).reduce(((t,e)=>[...t,...e]),[]))})(me,bn,We),kn=(xn=$t,t=>{const e=xn.get(t);if(void 0===e)throw Xe();return e});var xn;const En=(t=>null===t?null:t.hasOwnProperty("OfflineAudioContext")?t.OfflineAudioContext:t.hasOwnProperty("webkitOfflineAudioContext")?t.webkitOfflineAudioContext:null)(gn),Cn=(t=>e=>null!==t&&e instanceof t)(En),An=new WeakMap,Sn=(jn=ln,class{constructor(t){this._nativeEventTarget=t,this._listeners=new WeakMap}addEventListener(t,e,n){if(null!==e){let r=this._listeners.get(e);void 0===r&&(r=jn(this,e),"function"==typeof e&&this._listeners.set(e,r)),this._nativeEventTarget.addEventListener(t,r,n)}}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,e,n){const r=null===e?void 0:this._listeners.get(e);this._nativeEventTarget.removeEventListener(t,void 0===r?null:r,n)}}),In=(t=>null===t?null:t.hasOwnProperty("AudioContext")?t.AudioContext:t.hasOwnProperty("webkitAudioContext")?t.webkitAudioContext:null)(gn),Tn=(t=>e=>null!==t&&e instanceof t)(In),Rn=(t=>e=>null!==t&&"function"==typeof t.AudioNode&&e instanceof t.AudioNode)(gn),On=(t=>e=>null!==t&&"function"==typeof t.AudioParam&&e instanceof t.AudioParam)(gn),Pn=(t=>null===t?null:t.hasOwnProperty("AudioWorkletNode")?t.AudioWorkletNode:null)(gn),Wn=((t,e,n,r,i,s,o,a,c,h,l,u,d,f,p,v)=>class extends h{constructor(e,r,i,s){super(i),this._context=e,this._nativeAudioNode=i;const o=l(e);u(o)&&!0!==n(_e,(()=>_e(o,v)))&&(t=>{const e=new Map;var n;t.connect=(t=>(n,r=0,i=0)=>{const s=Ne(n)?t(n,r,i):t(n,r),o=e.get(n);return void 0===o?e.set(n,[{input:i,output:r}]):o.every((t=>t.input!==i||t.output!==r))&&o.push({input:i,output:r}),s})(t.connect.bind(t)),t.disconnect=(n=t.disconnect,(r,i,s)=>{if(n.apply(t),void 0===r)e.clear();else if("number"==typeof r)for(const[t,n]of e){const i=n.filter((t=>t.output!==r));0===i.length?e.delete(t):e.set(t,i)}else if(e.has(r))if(void 0===i)e.delete(r);else{const t=e.get(r);if(void 0!==t){const n=t.filter((t=>t.output!==i&&(t.input!==s||void 0===s)));0===n.length?e.delete(r):e.set(r,n)}}for(const[n,r]of e)r.forEach((e=>{Ne(n)?t.connect(n,e.output,e.input):t.connect(n,e.output)}))})})(i),Bt.set(this,i),qt.set(this,new Set),"closed"!==e.state&&r&&se(this),t(this,s,i)}get channelCount(){return this._nativeAudioNode.channelCount}set channelCount(t){this._nativeAudioNode.channelCount=t}get channelCountMode(){return this._nativeAudioNode.channelCountMode}set channelCountMode(t){this._nativeAudioNode.channelCountMode=t}get channelInterpretation(){return this._nativeAudioNode.channelInterpretation}set channelInterpretation(t){this._nativeAudioNode.channelInterpretation=t}get context(){return this._context}get numberOfInputs(){return this._nativeAudioNode.numberOfInputs}get numberOfOutputs(){return this._nativeAudioNode.numberOfOutputs}connect(t,n=0,a=0){if(n<0||n>=this._nativeAudioNode.numberOfOutputs)throw i();const h=l(this._context),u=p(h);if(d(t)||f(t))throw s();if(be(t)){const i=Oe(t);try{const e=Ae(this._nativeAudioNode,i,n,a),r=je(this);(u||r)&&this._nativeAudioNode.disconnect(...e),"closed"!==this.context.state&&!r&&je(t)&&se(t)}catch(t){if(12===t.code)throw s();throw t}if(e(this,t,n,a,u)){const e=c([this],t);Ue(e,r(u))}return t}const v=Pe(t);if("playbackRate"===v.name&&1024===v.maxValue)throw o();try{this._nativeAudioNode.connect(v,n),(u||je(this))&&this._nativeAudioNode.disconnect(v,n)}catch(t){if(12===t.code)throw s();throw t}if(((t,e,n,r)=>{const{activeInputs:i,passiveInputs:s}=ye(e),{outputs:o}=me(t),a=ie(t),c=o=>{const a=Oe(t),c=Pe(e);if(o){const e=Te(s,t,n);xe(i,t,e,!1),r||We(t)||a.connect(c,n)}else{const e=((t,e,n)=>ne(t,(t=>t[0]===e&&t[1]===n)))(i,t,n);Ee(s,e,!1),r||We(t)||a.disconnect(c,n)}};return!!ke(o,[e,n],(t=>t[0]===e&&t[1]===n),!0)&&(a.add(c),ve(t)?xe(i,t,[n,c],!0):Ee(s,[t,n,c],!0),!0)})(this,t,n,u)){const e=c([this],t);Ue(e,r(u))}}disconnect(t,e,n){let r;const o=l(this._context),h=p(o);if(void 0===t)r=((t,e)=>{const n=me(t),r=[];for(const i of n.outputs)Me(i)?Ve(t,e,...i):De(t,e,...i),r.push(i[0]);return n.outputs.clear(),r})(this,h);else if("number"==typeof t){if(t<0||t>=this.numberOfOutputs)throw i();r=((t,e,n)=>{const r=me(t),i=[];for(const s of r.outputs)s[1]===n&&(Me(s)?Ve(t,e,...s):De(t,e,...s),i.push(s[0]),r.outputs.delete(s));return i})(this,h,t)}else{if(void 0!==e&&(e<0||e>=this.numberOfOutputs))throw i();if(be(t)&&void 0!==n&&(n<0||n>=t.numberOfInputs))throw i();if(r=((t,e,n,r,i)=>{const s=me(t);return Array.from(s.outputs).filter((t=>!(t[0]!==n||void 0!==r&&t[1]!==r||void 0!==i&&t[2]!==i))).map((n=>(Me(n)?Ve(t,e,...n):De(t,e,...n),s.outputs.delete(n),n[0])))})(this,h,t,e,n),0===r.length)throw s()}for(const t of r){const e=c([this],t);Ue(e,a)}}})((_n=zt,(t,e,n)=>{const r=[];for(let t=0;t<n.numberOfInputs;t+=1)r.push(new Set);_n.set(t,{activeInputs:r,outputs:new Set,passiveInputs:new WeakMap,renderer:e})}),((t,e,n,r,i,s,o,a,c,h,l,u,d)=>{const f=new WeakMap;return(p,v,w,m,y)=>{const{activeInputs:g,passiveInputs:b}=s(v),{outputs:M}=s(p),k=a(p),x=s=>{const a=c(v),h=c(p);if(s){const e=re(b,p,w,m);t(g,p,e,!1),y||u(p)||n(h,a,w,m),d(v)&&se(v)}else{const t=r(g,p,w,m);e(b,m,t,!1),y||u(p)||i(h,a,w,m);const n=o(v);if(0===n)l(v)&&ce(v,g);else{const t=f.get(v);void 0!==t&&clearTimeout(t),f.set(v,setTimeout((()=>{l(v)&&ce(v,g)}),1e3*n))}}};return!!h(M,[v,w,m],(t=>t[0]===v&&t[1]===w&&t[2]===m),!0)&&(k.add(x),l(p)?t(g,p,[w,m,x],!0):e(b,m,[p,w,x],!0),!0)}})(un,dn,Ae,fn,Re,me,pn,ie,Oe,ke,ve,We,je),vn,((t,e,n,r,i,s)=>o=>(a,c)=>{const h=t.get(a);if(void 0===h){if(!o&&s(a)){const t=r(a),{outputs:s}=n(a);for(const n of s)if(Me(n)){const i=r(n[0]);e(t,i,n[1],n[2])}else{const e=i(n[0]);t.disconnect(e,n[1])}}t.set(a,c)}else t.set(a,h+c)})(Xt,Re,me,Oe,Pe,ve),ue,(()=>new DOMException("","InvalidAccessError")),sn,((t,e,n,r,i,s,o,a)=>(c,h)=>{const l=e.get(c);if(void 0===l)throw new Error("Missing the expected cycle count.");const u=s(c.context),d=a(u);if(l===h){if(e.delete(c),!d&&o(c)){const e=r(c),{outputs:s}=n(c);for(const n of s)if(Me(n)){const i=r(n[0]);t(e,i,n[1],n[2])}else{const t=i(n[0]);e.connect(t,n[1])}}}else e.set(c,l-h)})(Ae,Xt,me,Oe,Pe,kn,ve,Cn),((t,e,n)=>function r(i,s){const o=be(s)?s:n(t,s);if((t=>"delayTime"in t)(o))return[];if(i[0]===o)return[i];if(i.includes(o))return[];const{outputs:a}=e(o);return Array.from(a).map((t=>r([...i,o],t[0]))).reduce(((t,e)=>t.concat(e)),[])})(An,me,ee),Sn,kn,Tn,Rn,On,Cn,Pn);var jn,_n;const Un=new WeakSet,Nn=(t=>null===t?null:t.hasOwnProperty("AudioBuffer")?t.AudioBuffer:null)(gn),Vn=(Dn=new Uint32Array(1),t=>(Dn[0]=t,Dn[0]));var Dn;const Ln=((t,e)=>n=>{n.copyFromChannel=(r,i,s=0)=>{const o=t(s),a=t(i);if(a>=n.numberOfChannels)throw e();const c=n.length,h=n.getChannelData(a),l=r.length;for(let t=o<0?-o:0;t+o<c&&t<l;t+=1)r[t]=h[t+o]},n.copyToChannel=(r,i,s=0)=>{const o=t(s),a=t(i);if(a>=n.numberOfChannels)throw e();const c=n.length,h=n.getChannelData(a),l=r.length;for(let t=o<0?-o:0;t+o<c&&t<l;t+=1)h[t+o]=r[t]}})(Vn,ue),zn=(t=>e=>{e.copyFromChannel=(n=>(r,i,s=0)=>{const o=t(s),a=t(i);if(o<e.length)return n.call(e,r,a,o)})(e.copyFromChannel),e.copyToChannel=(n=>(r,i,s=0)=>{const o=t(s),a=t(i);if(o<e.length)return n.call(e,r,a,o)})(e.copyToChannel)})(Vn),Bn=((t,e,n,r,i,s,o,a)=>{let c=null;return class h{constructor(h){if(null===i)throw new Error("Missing the native OfflineAudioContext constructor.");const{length:l,numberOfChannels:u,sampleRate:d}={...de,...h};null===c&&(c=new i(1,1,44100));const f=null!==r&&e(s,s)?new r({length:l,numberOfChannels:u,sampleRate:d}):c.createBuffer(u,l,d);if(0===f.numberOfChannels)throw n();return"function"!=typeof f.copyFromChannel?(o(f),(t=>{var e;t.getChannelData=(e=t.getChannelData,n=>{try{return e.call(t,n)}catch(t){if(12===t.code)throw ue();throw t}})})(f)):e(le,(()=>le(f)))||a(f),t.add(f),f}static[Symbol.hasInstance](e){return null!==e&&"object"==typeof e&&Object.getPrototypeOf(e)===h.prototype||t.has(e)}}})(Un,vn,sn,Nn,En,(t=>()=>{if(null===t)return!1;try{new t({length:1,sampleRate:44100})}catch{return!1}return!0})(Nn),Ln,zn),Fn=(t=>(e,n)=>{const r=t(e,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});n.connect(r).connect(e.destination);const i=()=>{n.removeEventListener("ended",i),n.disconnect(r),r.disconnect()};n.addEventListener("ended",i)})(nn),Hn=((t,e,n)=>async(r,i,s)=>{const o=e(r);await Promise.all(Array.from(o.activeInputs).map((async([e,r])=>{const o=t(e),a=await o.render(e,i);n(e)||a.connect(s,r)})))})(bn,ye,We),$n=(t=>(e,n,r)=>t(n,e,r))(Hn),qn=((t,e,n,r,i,s,o,a,c,h)=>(c,l)=>{const u=c.createBufferSource();return Ze(u,l),Ge(u,l,"playbackRate"),Ye(u,l,"buffer"),Ye(u,l,"loop"),Ye(u,l,"loopEnd"),Ye(u,l,"loopStart"),e(n,(()=>n(c)))||(t=>{t.start=(e=>{let n=!1;return(r=0,i=0,s)=>{if(n)throw Xe();e.call(t,r,i,s),n=!0}})(t.start)})(u),e(r,(()=>r(c)))||(t=>{var e;t.start=(e=t.start,(n=0,r=0,i)=>{const s=t.buffer,o=null===s?r:Math.min(s.duration,r);null!==s&&o>s.duration-.5/t.context.sampleRate?e.call(t,n,0,0):e.call(t,n,o,i)})})(u),e(i,(()=>i(c)))||h(u,c),e(s,(()=>s(c)))||Je(u),e(o,(()=>o(c)))||((t,e)=>{const n=e.createGain();t.connect(n);const r=(i=t.disconnect,()=>{i.call(t,n),t.removeEventListener("ended",r)});var i;t.addEventListener("ended",r),en(t,n),t.stop=(e=>{let r=!1;return(i=0)=>{if(r)try{e.call(t,i)}catch{n.gain.setValueAtTime(0,i)}else e.call(t,i),r=!0}})(t.stop)})(u,c),e(a,(()=>a(c)))||Qe(u),t(c,u),u})(Fn,vn,(t=>{const e=t.createBufferSource();e.start();try{e.start()}catch{return!0}return!1}),(t=>{const e=t.createBufferSource(),n=t.createBuffer(1,1,44100);e.buffer=n;try{e.start(0,1)}catch{return!1}return!0}),(t=>{const e=t.createBufferSource();e.start();try{e.stop()}catch{return!1}return!0}),cn,(t=>{const e=t.createBuffer(1,1,44100),n=t.createBufferSource();n.buffer=e,n.start(),n.stop();try{return n.stop(),!0}catch{return!1}}),hn,0,(t=>(e,n)=>{const r=n.createBuffer(1,1,44100);null===e.buffer&&(e.buffer=r),t(e,"buffer",(t=>()=>{const n=t.call(e);return n===r?null:n}),(t=>n=>t.call(e,null===n?r:n)))})(on)),Xn=((t,e)=>(n,r,i)=>(t(r).replay(i),e(r,n,i)))((t=>e=>{const n=t(e);if(null===n.renderer)throw new Error("Missing the renderer of the given AudioParam in the audio graph.");return n.renderer})(ye),Hn),Kn=((t,e,n,r,i)=>()=>{const s=new WeakMap;let o=null,a=null;return{set start(t){o=t},set stop(t){a=t},render(c,h){const l=s.get(h);return void 0!==l?Promise.resolve(l):(async(c,h)=>{let l=n(c);const u=he(l,h);return u||(l=e(h,{buffer:l.buffer,channelCount:l.channelCount,channelCountMode:l.channelCountMode,channelInterpretation:l.channelInterpretation,loop:l.loop,loopEnd:l.loopEnd,loopStart:l.loopStart,playbackRate:l.playbackRate.value}),null!==o&&l.start(...o),null!==a&&l.stop(a)),s.set(h,l),u?await t(h,c.playbackRate,l.playbackRate):await r(h,c.playbackRate,l.playbackRate),await i(c,h,l),l})(c,h)}}})($n,qn,Oe,Xn,Mn),Yn=((t,e,n,r,i,s,o,a,c,h,l,u,d)=>(r,f,p,v=null,w=null)=>{const m=p.value,y=new Dt.AutomationEventList(m),g=f?(t=>({replay(e){for(const n of t)if("exponentialRampToValue"===n.type){const{endTime:t,value:r}=n;e.exponentialRampToValueAtTime(r,t)}else if("linearRampToValue"===n.type){const{endTime:t,value:r}=n;e.linearRampToValueAtTime(r,t)}else if("setTarget"===n.type){const{startTime:t,target:r,timeConstant:i}=n;e.setTargetAtTime(r,t,i)}else if("setValue"===n.type){const{startTime:t,value:r}=n;e.setValueAtTime(r,t)}else{if("setValueCurve"!==n.type)throw new Error("Can't apply an unknown automation.");{const{duration:t,startTime:r,values:i}=n;e.setValueCurveAtTime(i,r,t)}}}}))(y):null,b={get defaultValue(){return m},get maxValue(){return null===v?p.maxValue:v},get minValue(){return null===w?p.minValue:w},get value(){return p.value},set value(t){p.value=t,b.setValueAtTime(t,r.context.currentTime)},cancelAndHoldAtTime(t){if("function"==typeof p.cancelAndHoldAtTime)null===g&&y.flush(r.context.currentTime),y.add(i(t)),p.cancelAndHoldAtTime(t);else{const e=Array.from(y).pop();null===g&&y.flush(r.context.currentTime),y.add(i(t));const n=Array.from(y).pop();p.cancelScheduledValues(t),e!==n&&void 0!==n&&("exponentialRampToValue"===n.type?p.exponentialRampToValueAtTime(n.value,n.endTime):"linearRampToValue"===n.type?p.linearRampToValueAtTime(n.value,n.endTime):"setValue"===n.type?p.setValueAtTime(n.value,n.startTime):"setValueCurve"===n.type&&p.setValueCurveAtTime(n.values,n.startTime,n.duration))}return b},cancelScheduledValues:t=>(null===g&&y.flush(r.context.currentTime),y.add(s(t)),p.cancelScheduledValues(t),b),exponentialRampToValueAtTime(t,e){if(0===t)throw new RangeError;if(!Number.isFinite(e)||e<0)throw new RangeError;const n=r.context.currentTime;return null===g&&y.flush(n),0===Array.from(y).length&&(y.add(h(m,n)),p.setValueAtTime(m,n)),y.add(o(t,e)),p.exponentialRampToValueAtTime(t,e),b},linearRampToValueAtTime(t,e){const n=r.context.currentTime;return null===g&&y.flush(n),0===Array.from(y).length&&(y.add(h(m,n)),p.setValueAtTime(m,n)),y.add(a(t,e)),p.linearRampToValueAtTime(t,e),b},setTargetAtTime:(t,e,n)=>(null===g&&y.flush(r.context.currentTime),y.add(c(t,e,n)),p.setTargetAtTime(t,e,n),b),setValueAtTime:(t,e)=>(null===g&&y.flush(r.context.currentTime),y.add(h(t,e)),p.setValueAtTime(t,e),b),setValueCurveAtTime(t,e,n){const i=t instanceof Float32Array?t:new Float32Array(t);if(null!==u&&"webkitAudioContext"===u.name){const t=e+n,s=r.context.sampleRate,o=Math.ceil(e*s),a=Math.floor(t*s),c=a-o,h=new Float32Array(c);for(let t=0;t<c;t+=1){const r=(i.length-1)/n*((o+t)/s-e),a=Math.floor(r),c=Math.ceil(r);h[t]=a===c?i[a]:(1-(r-a))*i[a]+(1-(c-r))*i[c]}null===g&&y.flush(r.context.currentTime),y.add(l(h,e,n)),p.setValueCurveAtTime(h,e,n);const u=a/s;u<t&&d(b,h[h.length-1],u),d(b,i[i.length-1],t)}else null===g&&y.flush(r.context.currentTime),y.add(l(i,e,n)),p.setValueCurveAtTime(i,e,n);return b}};return n.set(b,p),e.set(b,r),t(b,g),b})((Zn=Ft,(t,e)=>{Zn.set(t,{activeInputs:new Set,passiveInputs:new WeakMap,renderer:e})}),An,Ht,0,Dt.createCancelAndHoldAutomationEvent,Dt.createCancelScheduledValuesAutomationEvent,Dt.createExponentialRampToValueAutomationEvent,Dt.createLinearRampToValueAutomationEvent,Dt.createSetTargetAutomationEvent,Dt.createSetValueAutomationEvent,Dt.createSetValueCurveAutomationEvent,In,an);var Zn;const Gn=((t,e,n,r,i,s,o,a)=>class extends t{constructor(t,r){const a=s(t),c={...we,...r},h=i(a,c),l=o(a),u=l?e():null;super(t,!1,h,u),this._audioBufferSourceNodeRenderer=u,this._isBufferNullified=!1,this._isBufferSet=null!==c.buffer,this._nativeAudioBufferSourceNode=h,this._onended=null,this._playbackRate=n(this,l,h.playbackRate,pe,fe)}get buffer(){return this._isBufferNullified?null:this._nativeAudioBufferSourceNode.buffer}set buffer(t){if(this._nativeAudioBufferSourceNode.buffer=t,null!==t){if(this._isBufferSet)throw r();this._isBufferSet=!0}}get loop(){return this._nativeAudioBufferSourceNode.loop}set loop(t){this._nativeAudioBufferSourceNode.loop=t}get loopEnd(){return this._nativeAudioBufferSourceNode.loopEnd}set loopEnd(t){this._nativeAudioBufferSourceNode.loopEnd=t}get loopStart(){return this._nativeAudioBufferSourceNode.loopStart}set loopStart(t){this._nativeAudioBufferSourceNode.loopStart=t}get onended(){return this._onended}set onended(t){const e="function"==typeof t?a(this,t):null;this._nativeAudioBufferSourceNode.onended=e;const n=this._nativeAudioBufferSourceNode.onended;this._onended=null!==n&&n===e?t:n}get playbackRate(){return this._playbackRate}start(t=0,e=0,n){if(this._nativeAudioBufferSourceNode.start(t,e,n),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.start=void 0===n?[t,e]:[t,e,n]),"closed"!==this.context.state){se(this);const t=()=>{this._nativeAudioBufferSourceNode.removeEventListener("ended",t),ve(this)&&ae(this)};this._nativeAudioBufferSourceNode.addEventListener("ended",t)}}stop(t=0){this._nativeAudioBufferSourceNode.stop(t),null!==this._audioBufferSourceNodeRenderer&&(this._audioBufferSourceNodeRenderer.stop=t)}})(Wn,Kn,Yn,Xe,qn,kn,Cn,ln),Jn=((t,e,n,r,i,s,o,a)=>class extends t{constructor(t,e){const n=s(t),r=o(n),c=i(n,e,r);super(t,!1,c,r?(t=>{const e=new WeakMap;return{render(n,r){const i=e.get(r);return void 0!==i?Promise.resolve(i):(async(n,r)=>{const i=r.destination;return e.set(r,i),await t(n,r,i),i})(n,r)}}})(a):null),this._isNodeOfNativeOfflineAudioContext=r,this._nativeAudioDestinationNode=c}get channelCount(){return this._nativeAudioDestinationNode.channelCount}set channelCount(t){if(this._isNodeOfNativeOfflineAudioContext)throw r();if(t>this._nativeAudioDestinationNode.maxChannelCount)throw n();this._nativeAudioDestinationNode.channelCount=t}get channelCountMode(){return this._nativeAudioDestinationNode.channelCountMode}set channelCountMode(t){if(this._isNodeOfNativeOfflineAudioContext)throw r();this._nativeAudioDestinationNode.channelCountMode=t}get maxChannelCount(){return this._nativeAudioDestinationNode.maxChannelCount}})(Wn,0,ue,Xe,((t,e)=>(n,r,i)=>{const s=n.destination;if(s.channelCount!==r)try{s.channelCount=r}catch{}i&&"explicit"!==s.channelCountMode&&(s.channelCountMode="explicit"),0===s.maxChannelCount&&Object.defineProperty(s,"maxChannelCount",{value:r});const o=t(n,{channelCount:r,channelCountMode:s.channelCountMode,channelInterpretation:s.channelInterpretation,gain:1});return e(o,"channelCount",(t=>()=>t.call(o)),(t=>e=>{t.call(o,e);try{s.channelCount=e}catch(t){if(e>s.maxChannelCount)throw t}})),e(o,"channelCountMode",(t=>()=>t.call(o)),(t=>e=>{t.call(o,e),s.channelCountMode=e})),e(o,"channelInterpretation",(t=>()=>t.call(o)),(t=>e=>{t.call(o,e),s.channelInterpretation=e})),Object.defineProperty(o,"maxChannelCount",{get:()=>s.maxChannelCount}),o.connect(s),o})(nn,on),kn,Cn,Mn),Qn=((t,e)=>(n,r,i)=>{const s=new Set;var o;return n.connect=(i=>(o,a=0,c=0)=>{const h=0===s.size;if(e(o))return i.call(n,o,a,c),t(s,[o,a,c],(t=>t[0]===o&&t[1]===a&&t[2]===c),!0),h&&r(),o;i.call(n,o,a),t(s,[o,a],(t=>t[0]===o&&t[1]===a),!0),h&&r()})(n.connect),n.disconnect=(o=n.disconnect,(t,r,a)=>{const c=s.size>0;if(void 0===t)o.apply(n),s.clear();else if("number"==typeof t){o.call(n,t);for(const e of s)e[1]===t&&s.delete(e)}else{e(t)?o.call(n,t,r,a):o.call(n,t,r);for(const e of s)e[0]!==t||void 0!==r&&e[1]!==r||void 0!==a&&e[2]!==a||s.delete(e)}c&&0===s.size&&i()}),n})(ke,Rn),tr=((t,e)=>(n,r)=>{r.channelCount=1,r.channelCountMode="explicit",Object.defineProperty(r,"channelCount",{get:()=>1,set:()=>{throw t()}}),Object.defineProperty(r,"channelCountMode",{get:()=>"explicit",set:()=>{throw t()}});const i=n.createBufferSource();e(r,(()=>{const t=r.numberOfInputs;for(let e=0;e<t;e+=1)i.connect(r,0,e)}),(()=>i.disconnect(r)))})(Xe,Qn),er=((t,e)=>(n,r)=>{const i=n.createChannelMerger(r.numberOfInputs);return null!==t&&"webkitAudioContext"===t.name&&e(n,i),Ze(i,r),i})(In,tr),nr=((t,e,n,r)=>(i,{offset:s,...o})=>{const a=i.createBuffer(1,2,44100),c=e(i,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),h=n(i,{...o,gain:s}),l=a.getChannelData(0);l[0]=1,l[1]=1,c.buffer=a,c.loop=!0;const u={get bufferSize(){},get channelCount(){return h.channelCount},set channelCount(t){h.channelCount=t},get channelCountMode(){return h.channelCountMode},set channelCountMode(t){h.channelCountMode=t},get channelInterpretation(){return h.channelInterpretation},set channelInterpretation(t){h.channelInterpretation=t},get context(){return h.context},get inputs(){return[]},get numberOfInputs(){return c.numberOfInputs},get numberOfOutputs(){return h.numberOfOutputs},get offset(){return h.gain},get onended(){return c.onended},set onended(t){c.onended=t},addEventListener:(...t)=>c.addEventListener(t[0],t[1],t[2]),dispatchEvent:(...t)=>c.dispatchEvent(t[0]),removeEventListener:(...t)=>c.removeEventListener(t[0],t[1],t[2]),start(t=0){c.start.call(c,t)},stop(t=0){c.stop.call(c,t)}};return t(i,c),r(en(u,h),(()=>c.connect(h)),(()=>c.disconnect(h)))})(Fn,qn,nn,Qn),rr=((t,e,n,r,i)=>(s,o)=>{if(void 0===s.createConstantSource)return n(s,o);const a=s.createConstantSource();return Ze(a,o),Ge(a,o,"offset"),e(r,(()=>r(s)))||Je(a),e(i,(()=>i(s)))||Qe(a),t(s,a),a})(Fn,vn,nr,cn,hn),ir=((t,e,n,r)=>i=>t(Ke,(()=>Ke(i)))?Promise.resolve(t(r,r)).then((t=>{if(!t){const t=n(i,512,0,1);i.oncomplete=()=>{t.onaudioprocess=null,t.disconnect()},t.onaudioprocess=()=>i.currentTime,t.connect(i.destination)}return i.startRendering()})):new Promise((t=>{const n=e(i,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});i.oncomplete=e=>{n.disconnect(),t(e.renderedBuffer)},n.connect(i.destination),i.startRendering()})))(vn,nn,rn,((t,e)=>()=>{if(null===e)return Promise.resolve(!1);const n=new e(1,1,44100),r=t(n,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return new Promise((t=>{n.oncomplete=()=>{r.disconnect(),t(0!==n.currentTime)},n.startRendering()}))})(nn,En)),sr=((t,e,n,r,i,s,o,a)=>(c,h)=>{const l=h.listener,{forwardX:u,forwardY:d,forwardZ:f,positionX:p,positionY:v,positionZ:w,upX:m,upY:y,upZ:g}=void 0===l.forwardX?(()=>{const u=new Float32Array(1),d=e(h,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:9}),f=o(h);let p=!1,v=[0,0,-1,0,1,0],w=[0,0,0];const m=()=>{if(p)return;p=!0;const t=r(h,256,9,0);t.onaudioprocess=({inputBuffer:t})=>{const e=[s(t,u,0),s(t,u,1),s(t,u,2),s(t,u,3),s(t,u,4),s(t,u,5)];e.some(((t,e)=>t!==v[e]))&&(l.setOrientation(...e),v=e);const n=[s(t,u,6),s(t,u,7),s(t,u,8)];n.some(((t,e)=>t!==w[e]))&&(l.setPosition(...n),w=n)},d.connect(t)},y=t=>e=>{e!==v[t]&&(v[t]=e,l.setOrientation(...v))},g=t=>e=>{e!==w[t]&&(w[t]=e,l.setPosition(...w))},b=(e,r,s)=>{const o=n(h,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:r});o.connect(d,0,e),o.start(),Object.defineProperty(o.offset,"defaultValue",{get:()=>r});const l=t({context:c},f,o.offset,pe,fe);var u,p,v,w,y,g,b;return a(l,"value",(t=>()=>t.call(l)),(t=>e=>{try{t.call(l,e)}catch(t){if(9!==t.code)throw t}m(),f&&s(e)})),l.cancelAndHoldAtTime=(u=l.cancelAndHoldAtTime,f?()=>{throw i()}:(...t)=>{const e=u.apply(l,t);return m(),e}),l.cancelScheduledValues=(p=l.cancelScheduledValues,f?()=>{throw i()}:(...t)=>{const e=p.apply(l,t);return m(),e}),l.exponentialRampToValueAtTime=(v=l.exponentialRampToValueAtTime,f?()=>{throw i()}:(...t)=>{const e=v.apply(l,t);return m(),e}),l.linearRampToValueAtTime=(w=l.linearRampToValueAtTime,f?()=>{throw i()}:(...t)=>{const e=w.apply(l,t);return m(),e}),l.setTargetAtTime=(y=l.setTargetAtTime,f?()=>{throw i()}:(...t)=>{const e=y.apply(l,t);return m(),e}),l.setValueAtTime=(g=l.setValueAtTime,f?()=>{throw i()}:(...t)=>{const e=g.apply(l,t);return m(),e}),l.setValueCurveAtTime=(b=l.setValueCurveAtTime,f?()=>{throw i()}:(...t)=>{const e=b.apply(l,t);return m(),e}),l};return{forwardX:b(0,0,y(0)),forwardY:b(1,0,y(1)),forwardZ:b(2,-1,y(2)),positionX:b(6,0,g(0)),positionY:b(7,0,g(1)),positionZ:b(8,0,g(2)),upX:b(3,0,y(3)),upY:b(4,1,y(4)),upZ:b(5,0,y(5))}})():l;return{get forwardX(){return u},get forwardY(){return d},get forwardZ(){return f},get positionX(){return p},get positionY(){return v},get positionZ(){return w},get upX(){return m},get upY(){return y},get upZ(){return g}}})(Yn,er,rr,rn,sn,((t,e,n)=>void 0===t.copyFromChannel?t.getChannelData(n)[0]:(t.copyFromChannel(e,n),e[0])),Cn,on),or=new WeakMap,ar=((t,e,n,r,i,s)=>class extends n{constructor(n,s){super(n),this._nativeContext=n,$t.set(this,n),r(n)&&i.set(n,new Set),this._destination=new t(this,s),this._listener=e(this,n),this._onstatechange=null}get currentTime(){return this._nativeContext.currentTime}get destination(){return this._destination}get listener(){return this._listener}get onstatechange(){return this._onstatechange}set onstatechange(t){const e="function"==typeof t?s(this,t):null;this._nativeContext.onstatechange=e;const n=this._nativeContext.onstatechange;this._onstatechange=null!==n&&n===e?t:n}get sampleRate(){return this._nativeContext.sampleRate}get state(){return this._nativeContext.state}})(Jn,sr,Sn,Cn,or,ln),cr=null!==gn&&gn.isSecureContext,hr=(t=>(e,n,r)=>{Object.defineProperties(t,{currentFrame:{configurable:!0,get:()=>Math.round(e*n)},currentTime:{configurable:!0,get:()=>e}});try{return r()}finally{null!==t&&(delete t.currentFrame,delete t.currentTime)}})(gn),lr=new WeakMap,ur=((t,e)=>n=>{let r=t.get(n);if(void 0!==r)return r;if(null===e)throw new Error("Missing the native OfflineAudioContext constructor.");return r=new e(1,1,44100),t.set(n,r),r})(lr,En),dr=cr?((t,e,n,r,i,s,o,a,c,h,l,u,d)=>{let f=0;return(p,v,w={credentials:"omit"})=>{const m=l.get(p);if(void 0!==m&&m.has(v))return Promise.resolve();const y=h.get(p);if(void 0!==y){const t=y.get(v);if(void 0!==t)return t}const g=s(p),b=void 0===g.audioWorklet?i(v).then((([t,e])=>{const[r,i]=Jt(t,e);return n(`${r};((a,b)=>{(a[b]=a[b]||[]).push((AudioWorkletProcessor,global,registerProcessor,sampleRate,self,window)=>{${i}\n})})(window,'_AWGS')`)})).then((()=>{const t=d._AWGS.pop();if(void 0===t)throw new SyntaxError;r(g.currentTime,g.sampleRate,(()=>t(class{},void 0,((t,n)=>{if(""===t.trim())throw e();const r=Kt.get(g);if(void 0!==r){if(r.has(t))throw e();te(n),Qt(n.parameterDescriptors),r.set(t,n)}else te(n),Qt(n.parameterDescriptors),Kt.set(g,new Map([[t,n]]))}),g.sampleRate,void 0,void 0)))})):Promise.all([i(v),Promise.resolve(t(u,u))]).then((([[t,e],n])=>{const r=f+1;f=r;const[i,s]=Jt(t,e),h=new Blob([`${i};((AudioWorkletProcessor,registerProcessor)=>{${s}\n})(${n?"AudioWorkletProcessor":"class extends AudioWorkletProcessor {__b=new WeakSet();constructor(){super();(p=>p.postMessage=(q=>(m,t)=>q.call(p,m,t?t.filter(u=>!this.__b.has(u)):t))(p.postMessage))(this.port)}}"},(n,p)=>registerProcessor(n,class extends p{${n?"":"__c = (a) => a.forEach(e=>this.__b.add(e.buffer));"}process(i,o,p){${n?"":"i.forEach(this.__c);o.forEach(this.__c);this.__c(Object.values(p));"}return super.process(i.map(j=>j.some(k=>k.length===0)?[]:j),o,p)}}));registerProcessor('__sac${r}',class extends AudioWorkletProcessor{process(){return !1}})`],{type:"application/javascript; charset=utf-8"}),l=URL.createObjectURL(h);return g.audioWorklet.addModule(l,w).then((()=>{if(a(g))return g;const t=o(g);return t.audioWorklet.addModule(l,w).then((()=>t))})).then((t=>{if(null===c)throw new SyntaxError;try{new c(t,`__sac${r}`)}catch{throw new SyntaxError}})).finally((()=>URL.revokeObjectURL(l)))}));return void 0===y?h.set(p,new Map([[v,b]])):y.set(v,b),b.then((()=>{const t=l.get(p);void 0===t?l.set(p,new Set([v])):t.add(v)})).finally((()=>{const t=h.get(p);void 0!==t&&t.delete(v)})),b}})(vn,sn,(t=>e=>new Promise(((n,r)=>{if(null===t)return void r(new SyntaxError);const i=t.document.head;if(null===i)r(new SyntaxError);else{const s=t.document.createElement("script"),o=new Blob([e],{type:"application/javascript"}),a=URL.createObjectURL(o),c=t.onerror,h=()=>{t.onerror=c,URL.revokeObjectURL(a)};t.onerror=(e,n,i,s,o)=>n===a||n===t.location.href&&1===i&&1===s?(h(),r(o),!1):null!==c?c(e,n,i,s,o):void 0,s.onerror=()=>{h(),r(new SyntaxError)},s.onload=()=>{h(),n()},s.src=a,s.type="module",i.appendChild(s)}})))(gn),hr,(async t=>{try{const e=await fetch(t);if(e.ok)return[await e.text(),e.url]}catch{}throw new DOMException("","AbortError")}),kn,ur,Cn,Pn,new WeakMap,new WeakMap,((t,e)=>async()=>{if(null===t)return!0;if(null===e)return!1;const n=new Blob(['class A extends AudioWorkletProcessor{process(i){this.port.postMessage(i,[i[0][0].buffer])}}registerProcessor("a",A)'],{type:"application/javascript; charset=utf-8"}),r=new e(1,128,44100),i=URL.createObjectURL(n);let s=!1,o=!1;try{await r.audioWorklet.addModule(i);const e=new t(r,"a",{numberOfOutputs:0}),n=r.createOscillator();e.port.onmessage=()=>s=!0,e.onprocessorerror=()=>o=!0,n.connect(e),n.start(0),await r.startRendering(),await new Promise((t=>setTimeout(t)))}catch{}finally{URL.revokeObjectURL(i)}return s&&!o})(Pn,En),gn):void 0,fr=((t,e,n,r)=>class extends t{constructor(t,e){const i=n(t),s=((t,{mediaStream:e})=>{const n=e.getAudioTracks();n.sort(((t,e)=>t.id<e.id?-1:t.id>e.id?1:0));const r=n.slice(0,1),i=t.createMediaStreamSource(new MediaStream(r));return Object.defineProperty(i,"mediaStream",{value:e}),i})(i,e);if(r(i))throw new TypeError;super(t,!0,s,null),this._nativeMediaStreamAudioSourceNode=s}get mediaStream(){return this._nativeMediaStreamAudioSourceNode.mediaStream}})(Wn,0,kn,Cn),pr=(t=>e=>{const n=t.get(e);if(void 0===n)throw new Error("The context has no set of AudioWorkletNodes.");return n})(or),vr=(t=>(e,n)=>{t(e).add(n)})(pr),wr=(t=>(e,n,r=0,i=0)=>{const s=e[r];if(void 0===s)throw t();return Ne(n)?s.connect(n,0,i):s.connect(n,0)})(ue),mr=(t=>(e,n)=>{t(e).delete(n)})(pr),yr=(t=>(e,n,r,i=0)=>void 0===n?e.forEach((t=>t.disconnect())):"number"==typeof n?qe(t,e,n).disconnect():Ne(n)?void 0===r?e.forEach((t=>t.disconnect(n))):void 0===i?qe(t,e,r).disconnect(n,0):qe(t,e,r).disconnect(n,0,i):void 0===r?e.forEach((t=>t.disconnect(n))):qe(t,e,r).disconnect(n,0))(ue),gr=new WeakMap,br=((t,e)=>n=>e(t,n))(gr,ee),Mr=((t,e,n,r,i,s,o,a,c,h,l,u,d)=>(f,p,v,w)=>{if(0===w.numberOfInputs&&0===w.numberOfOutputs)throw c();const m=Array.isArray(w.outputChannelCount)?w.outputChannelCount:Array.from(w.outputChannelCount);if(m.some((t=>t<1)))throw c();if(m.length!==w.numberOfOutputs)throw e();if("explicit"!==w.channelCountMode)throw c();const y=w.channelCount*w.numberOfInputs,g=m.reduce(((t,e)=>t+e),0),b=void 0===v.parameterDescriptors?0:v.parameterDescriptors.length;if(y+b>6||g>6)throw c();const M=new MessageChannel,k=[],x=[];for(let t=0;t<w.numberOfInputs;t+=1)k.push(o(f,{channelCount:w.channelCount,channelCountMode:w.channelCountMode,channelInterpretation:w.channelInterpretation,gain:1})),x.push(i(f,{channelCount:w.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:w.channelCount}));const E=[];if(void 0!==v.parameterDescriptors)for(const{defaultValue:t,maxValue:e,minValue:n,name:r}of v.parameterDescriptors){const i=s(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:void 0!==w.parameterData[r]?w.parameterData[r]:void 0===t?0:t});Object.defineProperties(i.offset,{defaultValue:{get:()=>void 0===t?0:t},maxValue:{get:()=>void 0===e?pe:e},minValue:{get:()=>void 0===n?fe:n}}),E.push(i)}const C=r(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,y+b)}),A=((t,e)=>null===t?512:Math.max(512,Math.min(16384,Math.pow(2,Math.round(Math.log2(t*e))))))(p,f.sampleRate),S=a(f,A,y+b,Math.max(1,g)),I=i(f,{channelCount:Math.max(1,g),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,g)}),T=[];for(let t=0;t<w.numberOfOutputs;t+=1)T.push(r(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:m[t]}));for(let t=0;t<w.numberOfInputs;t+=1){k[t].connect(x[t]);for(let e=0;e<w.channelCount;e+=1)x[t].connect(C,e,t*w.channelCount+e)}const R=new Le(void 0===v.parameterDescriptors?[]:v.parameterDescriptors.map((({name:t},e)=>{const n=E[e];return n.connect(C,0,y+e),n.start(0),[t,n.offset]})));C.connect(S);let O=w.channelInterpretation,P=null;const W=0===w.numberOfOutputs?[S]:T,j={get bufferSize(){return A},get channelCount(){return w.channelCount},set channelCount(t){throw n()},get channelCountMode(){return w.channelCountMode},set channelCountMode(t){throw n()},get channelInterpretation(){return O},set channelInterpretation(t){for(const e of k)e.channelInterpretation=t;O=t},get context(){return S.context},get inputs(){return k},get numberOfInputs(){return w.numberOfInputs},get numberOfOutputs(){return w.numberOfOutputs},get onprocessorerror(){return P},set onprocessorerror(t){"function"==typeof P&&j.removeEventListener("processorerror",P),P="function"==typeof t?t:null,"function"==typeof P&&j.addEventListener("processorerror",P)},get parameters(){return R},get port(){return M.port2},addEventListener:(...t)=>S.addEventListener(t[0],t[1],t[2]),connect:t.bind(null,W),disconnect:h.bind(null,W),dispatchEvent:(...t)=>S.dispatchEvent(t[0]),removeEventListener:(...t)=>S.removeEventListener(t[0],t[1],t[2])},_=new Map;var U,N;M.port1.addEventListener=(U=M.port1.addEventListener,(...t)=>{if("message"===t[0]){const e="function"==typeof t[1]?t[1]:"object"==typeof t[1]&&null!==t[1]&&"function"==typeof t[1].handleEvent?t[1].handleEvent:null;if(null!==e){const n=_.get(t[1]);void 0!==n?t[1]=n:(t[1]=t=>{l(f.currentTime,f.sampleRate,(()=>e(t)))},_.set(e,t[1]))}}return U.call(M.port1,t[0],t[1],t[2])}),M.port1.removeEventListener=(N=M.port1.removeEventListener,(...t)=>{if("message"===t[0]){const e=_.get(t[1]);void 0!==e&&(_.delete(t[1]),t[1]=e)}return N.call(M.port1,t[0],t[1],t[2])});let V=null;Object.defineProperty(M.port1,"onmessage",{get:()=>V,set:t=>{"function"==typeof V&&M.port1.removeEventListener("message",V),V="function"==typeof t?t:null,"function"==typeof V&&(M.port1.addEventListener("message",V),M.port1.start())}}),v.prototype.port=M.port1;let D=null;const L=((t,e,n,r)=>{let i=Yt.get(t);void 0===i&&(i=new WeakMap,Yt.set(t,i));const s=(async(t,e)=>{const n=await(t=>new Promise(((e,n)=>{const{port1:r,port2:i}=new MessageChannel;r.onmessage=({data:t})=>{r.close(),i.close(),e(t)},r.onmessageerror=({data:t})=>{r.close(),i.close(),n(t)},i.postMessage(t)})))(e);return new t(n)})(n,r);return i.set(e,s),s})(f,j,v,w);L.then((t=>D=t));const z=He(w.numberOfInputs,w.channelCount),B=He(w.numberOfOutputs,m),F=void 0===v.parameterDescriptors?[]:v.parameterDescriptors.reduce(((t,{name:e})=>({...t,[e]:new Float32Array(128)})),{});let H=!0;const $=()=>{w.numberOfOutputs>0&&S.disconnect(I);for(let t=0,e=0;t<w.numberOfOutputs;t+=1){const n=T[t];for(let r=0;r<m[t];r+=1)I.disconnect(n,e+r,r);e+=m[t]}},q=new Map;S.onaudioprocess=({inputBuffer:t,outputBuffer:e})=>{if(null!==D){const n=u(j);for(let r=0;r<A;r+=128){for(let e=0;e<w.numberOfInputs;e+=1)for(let n=0;n<w.channelCount;n+=1)Be(t,z[e],n,n,r);void 0!==v.parameterDescriptors&&v.parameterDescriptors.forEach((({name:e},n)=>{Be(t,F,e,y+n,r)}));for(let t=0;t<w.numberOfInputs;t+=1)for(let e=0;e<m[t];e+=1)0===B[t][e].byteLength&&(B[t][e]=new Float32Array(128));try{const t=z.map(((t,e)=>{if(n[e].size>0)return q.set(e,A/128),t;const r=q.get(e);return void 0===r?[]:(t.every((t=>t.every((t=>0===t))))&&(1===r?q.delete(e):q.set(e,r-1)),t)})),i=l(f.currentTime+r/f.sampleRate,f.sampleRate,(()=>D.process(t,B,F)));H=i;for(let t=0,n=0;t<w.numberOfOutputs;t+=1){for(let i=0;i<m[t];i+=1)Fe(e,B[t],i,n+i,r);n+=m[t]}}catch(t){H=!1,j.dispatchEvent(new ErrorEvent("processorerror",{colno:t.colno,filename:t.filename,lineno:t.lineno,message:t.message}))}if(!H){for(let t=0;t<w.numberOfInputs;t+=1){k[t].disconnect(x[t]);for(let e=0;e<w.channelCount;e+=1)x[r].disconnect(C,e,t*w.channelCount+e)}if(void 0!==v.parameterDescriptors){const t=v.parameterDescriptors.length;for(let e=0;e<t;e+=1){const t=E[e];t.disconnect(C,0,y+e),t.stop()}}C.disconnect(S),S.onaudioprocess=null,X?$():Z();break}}}};let X=!1;const K=o(f,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0}),Y=()=>S.connect(K).connect(f.destination),Z=()=>{S.disconnect(K),K.disconnect()};return Y(),d(j,(()=>{if(H){Z(),w.numberOfOutputs>0&&S.connect(I);for(let t=0,e=0;t<w.numberOfOutputs;t+=1){const n=T[t];for(let r=0;r<m[t];r+=1)I.connect(n,e+r,r);e+=m[t]}}X=!0}),(()=>{H&&(Y(),$()),X=!1}))})(wr,ue,Xe,er,tn,rr,nn,rn,sn,yr,hr,br,Qn),kr=((t,e,n,r,i)=>(s,o,a,c,h,l)=>{if(null!==a)try{const e=new a(s,c,l),r=new Map;let o=null;if(Object.defineProperties(e,{channelCount:{get:()=>l.channelCount,set:()=>{throw t()}},channelCountMode:{get:()=>"explicit",set:()=>{throw t()}},onprocessorerror:{get:()=>o,set:t=>{"function"==typeof o&&e.removeEventListener("processorerror",o),o="function"==typeof t?t:null,"function"==typeof o&&e.addEventListener("processorerror",o)}}}),e.addEventListener=(d=e.addEventListener,(...t)=>{if("processorerror"===t[0]){const e="function"==typeof t[1]?t[1]:"object"==typeof t[1]&&null!==t[1]&&"function"==typeof t[1].handleEvent?t[1].handleEvent:null;if(null!==e){const n=r.get(t[1]);void 0!==n?t[1]=n:(t[1]=n=>{"error"===n.type?(Object.defineProperties(n,{type:{value:"processorerror"}}),e(n)):e(new ErrorEvent(t[0],{...n}))},r.set(e,t[1]))}}return d.call(e,"error",t[1],t[2]),d.call(e,...t)}),e.removeEventListener=(u=e.removeEventListener,(...t)=>{if("processorerror"===t[0]){const e=r.get(t[1]);void 0!==e&&(r.delete(t[1]),t[1]=e)}return u.call(e,"error",t[1],t[2]),u.call(e,t[0],t[1],t[2])}),0!==l.numberOfOutputs){const t=n(s,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",gain:0});return e.connect(t).connect(s.destination),i(e,(()=>t.disconnect()),(()=>t.connect(s.destination)))}return e}catch(t){if(11===t.code)throw r();throw t}var u,d;if(void 0===h)throw r();return(t=>{const{port1:e}=new MessageChannel;try{e.postMessage(t)}finally{e.close()}})(l),e(s,o,h,l)})(Xe,Mr,nn,sn,Qn),xr=((t,e,n,r,i,s,o,a,c,h,l,u,d,f,p,v)=>(w,m,y)=>{const g=new WeakMap;let b=null;return{render(M,k){a(k,M);const x=g.get(k);return void 0!==x?Promise.resolve(x):(async(a,M)=>{let k=l(a),x=null;const E=he(k,M),C=Array.isArray(m.outputChannelCount)?m.outputChannelCount:Array.from(m.outputChannelCount);if(null===u){const t=C.reduce(((t,e)=>t+e),0),n=i(M,{channelCount:Math.max(1,t),channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:Math.max(1,t)}),s=[];for(let t=0;t<a.numberOfOutputs;t+=1)s.push(r(M,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:C[t]}));const h=o(M,{channelCount:m.channelCount,channelCountMode:m.channelCountMode,channelInterpretation:m.channelInterpretation,gain:1});h.connect=e.bind(null,s),h.disconnect=c.bind(null,s),x=[n,s,h]}else E||(k=new u(M,w));if(g.set(M,null===x?k:x[2]),null!==x){if(null===b){if(void 0===y)throw new Error("Missing the processor constructor.");if(null===d)throw new Error("Missing the native OfflineAudioContext constructor.");const t=a.channelCount*a.numberOfInputs,e=void 0===y.parameterDescriptors?0:y.parameterDescriptors.length,n=t+e,c=async()=>{const c=new d(n,128*Math.ceil(a.context.length/128),M.sampleRate),h=[],l=[];for(let t=0;t<m.numberOfInputs;t+=1)h.push(o(c,{channelCount:m.channelCount,channelCountMode:m.channelCountMode,channelInterpretation:m.channelInterpretation,gain:1})),l.push(i(c,{channelCount:m.channelCount,channelCountMode:"explicit",channelInterpretation:"discrete",numberOfOutputs:m.channelCount}));const u=await Promise.all(Array.from(a.parameters.values()).map((async t=>{const e=s(c,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"discrete",offset:t.value});return await f(c,t,e.offset),e}))),w=r(c,{channelCount:1,channelCountMode:"explicit",channelInterpretation:"speakers",numberOfInputs:Math.max(1,t+e)});for(let t=0;t<m.numberOfInputs;t+=1){h[t].connect(l[t]);for(let e=0;e<m.channelCount;e+=1)l[t].connect(w,e,t*m.channelCount+e)}for(const[e,n]of u.entries())n.connect(w,0,t+e),n.start(0);return w.connect(c.destination),await Promise.all(h.map((t=>p(a,c,t)))),v(c)};b=$e(a,0===n?null:await c(),M,m,C,y,h)}const t=await b,e=n(M,{buffer:null,channelCount:2,channelCountMode:"max",channelInterpretation:"speakers",loop:!1,loopEnd:0,loopStart:0,playbackRate:1}),[c,l,u]=x;null!==t&&(e.buffer=t,e.start(0)),e.connect(c);for(let t=0,e=0;t<a.numberOfOutputs;t+=1){const n=l[t];for(let r=0;r<C[t];r+=1)c.connect(n,e+r,r);e+=C[t]}return u}if(E)for(const[e,n]of a.parameters.entries())await t(M,n,k.parameters.get(e));else for(const[t,e]of a.parameters.entries())await f(M,e,k.parameters.get(t));return await p(a,M,k),k})(M,k)}}})($n,wr,qn,er,tn,rr,nn,mr,yr,hr,Oe,Pn,En,Xn,Mn,ir),Er=(t=>e=>t.get(e))(lr),Cr=(t=>(e,n)=>{t.set(e,n)})(gr),Ar=cr?((t,e,n,r,i,s,o,a,c,h,l,u,d,f)=>class extends e{constructor(e,l,d){var f;const p=a(e),v=c(p),w=(t=>({...t,outputChannelCount:void 0!==t.outputChannelCount?t.outputChannelCount:1===t.numberOfInputs&&1===t.numberOfOutputs?[t.channelCount]:Array.from({length:t.numberOfOutputs},(()=>1))}))({...ze,...d});(t=>{const{port1:e,port2:n}=new MessageChannel;try{e.postMessage(t)}finally{e.close(),n.close()}})(w);const m=Kt.get(p),y=null==m?void 0:m.get(l),g=v||"closed"!==p.state?p:null!==(f=o(p))&&void 0!==f?f:p,b=i(g,v?null:e.baseLatency,h,l,y,w);super(e,!0,b,v?r(l,w,y):null);const M=[];b.parameters.forEach(((t,e)=>{const r=n(this,v,t);M.push([e,r])})),this._nativeAudioWorkletNode=b,this._onprocessorerror=null,this._parameters=new Le(M),v&&t(p,this);const{activeInputs:k}=s(this);u(b,k)}get onprocessorerror(){return this._onprocessorerror}set onprocessorerror(t){const e="function"==typeof t?f(this,t):null;this._nativeAudioWorkletNode.onprocessorerror=e;const n=this._nativeAudioWorkletNode.onprocessorerror;this._onprocessorerror=null!==n&&n===e?t:n}get parameters(){return null===this._parameters?this._nativeAudioWorkletNode.parameters:this._parameters}get port(){return this._nativeAudioWorkletNode.port}})(vr,Wn,Yn,xr,kr,me,Er,kn,Cn,Pn,0,Cr,0,ln):void 0,Sr=((t,e,n,r,i)=>class extends r{constructor(t={}){if(null===i)throw new Error("Missing the native AudioContext constructor.");let n;try{n=new i(t)}catch(t){if(12===t.code&&"sampleRate is not in range"===t.message)throw e();throw t}if(null===n)throw new DOMException("","UnknownError");if(!(t=>void 0===t||"number"==typeof t||"string"==typeof t&&("balanced"===t||"interactive"===t||"playback"===t))(t.latencyHint))throw new TypeError(`The provided value '${t.latencyHint}' is not a valid enum value of type AudioContextLatencyCategory.`);if(void 0!==t.sampleRate&&n.sampleRate!==t.sampleRate)throw e();super(n,2);const{latencyHint:r}=t,{sampleRate:s}=n;if(this._baseLatency="number"==typeof n.baseLatency?n.baseLatency:"balanced"===r?512/s:"interactive"===r||void 0===r?256/s:"playback"===r?1024/s:128*Math.max(2,Math.min(128,Math.round(r*s/128)))/s,this._nativeAudioContext=n,"webkitAudioContext"===i.name?(this._nativeGainNode=n.createGain(),this._nativeOscillatorNode=n.createOscillator(),this._nativeGainNode.gain.value=1e-37,this._nativeOscillatorNode.connect(this._nativeGainNode).connect(n.destination),this._nativeOscillatorNode.start()):(this._nativeGainNode=null,this._nativeOscillatorNode=null),this._state=null,"running"===n.state){this._state="suspended";const t=()=>{"suspended"===this._state&&(this._state=null),n.removeEventListener("statechange",t)};n.addEventListener("statechange",t)}}get baseLatency(){return this._baseLatency}get state(){return null!==this._state?this._state:this._nativeAudioContext.state}close(){return"closed"===this.state?this._nativeAudioContext.close().then((()=>{throw t()})):("suspended"===this._state&&(this._state=null),this._nativeAudioContext.close().then((()=>{null!==this._nativeGainNode&&null!==this._nativeOscillatorNode&&(this._nativeOscillatorNode.stop(),this._nativeGainNode.disconnect(),this._nativeOscillatorNode.disconnect()),ge(this.destination,[])})))}resume(){return"suspended"===this._state?new Promise(((t,e)=>{const n=()=>{this._nativeAudioContext.removeEventListener("statechange",n),"running"===this._nativeAudioContext.state?t():this.resume().then(t,e)};this._nativeAudioContext.addEventListener("statechange",n)})):this._nativeAudioContext.resume().catch((e=>{if(void 0===e||15===e.code)throw t();throw e}))}suspend(){return this._nativeAudioContext.suspend().catch((e=>{if(void 0===e)throw t();throw e}))}})(Xe,sn,0,ar,In),Ir="Missing AudioWorklet support. Maybe this is not running in a secure context.";var Tr,Rr={exports:{}},Or=(Tr||(Tr=1,function(t,e,n,r){function i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return s(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(t,e):void 0}}(t))||e){n&&(t=n);var r=0,i=function(){};return{s:i,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,c=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){c=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(c)throw o}}}}function s(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var o=function(){return r((function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=arguments.length>2?arguments[2]:void 0;if(n(this,t),r<0||void 0!==s&&s<0)throw new RangeError;var o=e.reduce((function(t,e){return t+e.byteLength}),0);if(r>o||void 0!==s&&r+s>o)throw new RangeError;var a,c=[],h=void 0===s?o-r:s,l=[],u=0,d=r,f=i(e);try{for(f.s();!(a=f.n()).done;){var p=a.value;0===l.length?p.byteLength>d?(u=p.byteLength-d,c.push(new DataView(p,d,u>h?h:u)),l.push(p)):d-=p.byteLength:u<h&&(u+=p.byteLength,c.push(new DataView(p,0,u>h?p.byteLength-u+h:p.byteLength)),l.push(p))}}catch(t){f.e(t)}finally{f.f()}this._buffers=l,this._byteLength=h,this._byteOffset=d,this._dataViews=c,this._internalBuffer=new DataView(new ArrayBuffer(8))}),[{key:"buffers",get:function(){return this._buffers}},{key:"byteLength",get:function(){return this._byteLength}},{key:"byteOffset",get:function(){return this._byteOffset}},{key:"getFloat32",value:function(t,e){return this._internalBuffer.setUint8(0,this.getUint8(t+0)),this._internalBuffer.setUint8(1,this.getUint8(t+1)),this._internalBuffer.setUint8(2,this.getUint8(t+2)),this._internalBuffer.setUint8(3,this.getUint8(t+3)),this._internalBuffer.getFloat32(0,e)}},{key:"getFloat64",value:function(t,e){return this._internalBuffer.setUint8(0,this.getUint8(t+0)),this._internalBuffer.setUint8(1,this.getUint8(t+1)),this._internalBuffer.setUint8(2,this.getUint8(t+2)),this._internalBuffer.setUint8(3,this.getUint8(t+3)),this._internalBuffer.setUint8(4,this.getUint8(t+4)),this._internalBuffer.setUint8(5,this.getUint8(t+5)),this._internalBuffer.setUint8(6,this.getUint8(t+6)),this._internalBuffer.setUint8(7,this.getUint8(t+7)),this._internalBuffer.getFloat64(0,e)}},{key:"getInt16",value:function(t,e){return this._internalBuffer.setUint8(0,this.getUint8(t+0)),this._internalBuffer.setUint8(1,this.getUint8(t+1)),this._internalBuffer.getInt16(0,e)}},{key:"getInt32",value:function(t,e){return this._internalBuffer.setUint8(0,this.getUint8(t+0)),this._internalBuffer.setUint8(1,this.getUint8(t+1)),this._internalBuffer.setUint8(2,this.getUint8(t+2)),this._internalBuffer.setUint8(3,this.getUint8(t+3)),this._internalBuffer.getInt32(0,e)}},{key:"getInt8",value:function(t){var n=this._findDataViewWithOffset(t),r=e(n,2);return r[0].getInt8(t-r[1])}},{key:"getUint16",value:function(t,e){return this._internalBuffer.setUint8(0,this.getUint8(t+0)),this._internalBuffer.setUint8(1,this.getUint8(t+1)),this._internalBuffer.getUint16(0,e)}},{key:"getUint32",value:function(t,e){return this._internalBuffer.setUint8(0,this.getUint8(t+0)),this._internalBuffer.setUint8(1,this.getUint8(t+1)),this._internalBuffer.setUint8(2,this.getUint8(t+2)),this._internalBuffer.setUint8(3,this.getUint8(t+3)),this._internalBuffer.getUint32(0,e)}},{key:"getUint8",value:function(t){var n=this._findDataViewWithOffset(t),r=e(n,2);return r[0].getUint8(t-r[1])}},{key:"setFloat32",value:function(t,e,n){this._internalBuffer.setFloat32(0,e,n),this.setUint8(t,this._internalBuffer.getUint8(0)),this.setUint8(t+1,this._internalBuffer.getUint8(1)),this.setUint8(t+2,this._internalBuffer.getUint8(2)),this.setUint8(t+3,this._internalBuffer.getUint8(3))}},{key:"setFloat64",value:function(t,e,n){this._internalBuffer.setFloat64(0,e,n),this.setUint8(t,this._internalBuffer.getUint8(0)),this.setUint8(t+1,this._internalBuffer.getUint8(1)),this.setUint8(t+2,this._internalBuffer.getUint8(2)),this.setUint8(t+3,this._internalBuffer.getUint8(3)),this.setUint8(t+4,this._internalBuffer.getUint8(4)),this.setUint8(t+5,this._internalBuffer.getUint8(5)),this.setUint8(t+6,this._internalBuffer.getUint8(6)),this.setUint8(t+7,this._internalBuffer.getUint8(7))}},{key:"setInt16",value:function(t,e,n){this._internalBuffer.setInt16(0,e,n),this.setUint8(t,this._internalBuffer.getUint8(0)),this.setUint8(t+1,this._internalBuffer.getUint8(1))}},{key:"setInt32",value:function(t,e,n){this._internalBuffer.setInt32(0,e,n),this.setUint8(t,this._internalBuffer.getUint8(0)),this.setUint8(t+1,this._internalBuffer.getUint8(1)),this.setUint8(t+2,this._internalBuffer.getUint8(2)),this.setUint8(t+3,this._internalBuffer.getUint8(3))}},{key:"setInt8",value:function(t,n){var r=this._findDataViewWithOffset(t),i=e(r,2);i[0].setInt8(t-i[1],n)}},{key:"setUint16",value:function(t,e,n){this._internalBuffer.setUint16(0,e,n),this.setUint8(t,this._internalBuffer.getUint8(0)),this.setUint8(t+1,this._internalBuffer.getUint8(1))}},{key:"setUint32",value:function(t,e,n){this._internalBuffer.setUint32(0,e,n),this.setUint8(t,this._internalBuffer.getUint8(0)),this.setUint8(t+1,this._internalBuffer.getUint8(1)),this.setUint8(t+2,this._internalBuffer.getUint8(2)),this.setUint8(t+3,this._internalBuffer.getUint8(3))}},{key:"setUint8",value:function(t,n){var r=this._findDataViewWithOffset(t),i=e(r,2);i[0].setUint8(t-i[1],n)}},{key:"_findDataViewWithOffset",value:function(t){var e,n=0,r=i(this._dataViews);try{for(r.s();!(e=r.n()).done;){var s=e.value,o=n+s.byteLength;if(t>=n&&t<o)return[s,n];n=o}}catch(t){r.e(t)}finally{r.f()}throw new RangeError}}])}();t.MultiBufferDataView=o}(Rr.exports,Rt,Pt,Vt)),Rr.exports);const Pr=(t,e)=>{if(e>=t.byteLength)return null;const n=t.getUint8(e);if(n>127)return 1;if(n>63)return 2;if(n>31)return 3;if(n>15)return 4;if(n>7)return 5;if(n>3)return 6;if(n>1)return 7;if(n>0)return 8;const r=Pr(t,e+1);return null===r?null:r+8},Wr=[],jr="undefined"==typeof window?null:window,_r=(Gr=null!==jr&&void 0!==jr.BlobEvent?jr.BlobEvent:null,(t,e)=>{if(null===Gr)throw new Error("A native BlobEvent could not be created.");return new Gr(t,e)}),Ur=((t,e,n,r)=>(i,s,o)=>{var a;const c=null===(a=s.getAudioTracks()[0])||void 0===a?void 0:a.getSettings().sampleRate,h=new Sr({latencyHint:"playback",sampleRate:c}),l=MediaRecorder.isTypeSupported("audio/mp4")?new Bn({length:2688,sampleRate:h.sampleRate}):null,u=[],d=xt((t=>{if(void 0===dr)throw new Error(Ir);return dr(h,t)}));let f=null,p=null,v=null,w=null,m=!0;const y=e=>{i.dispatchEvent(t("dataavailable",{data:new Blob(e,{type:o})}))},g=async(t,e)=>{const n=await vt(t,e);null===v?u.push(...n):(y(n),w=g(t,e))},b=()=>(m=!0,h.resume()),M=()=>{null!==v&&(null!==f&&(s.removeEventListener("addtrack",f),s.removeEventListener("removetrack",f)),null!==p&&clearTimeout(p),v.then((async({encoderInstanceId:t,mediaStreamAudioSourceNode:e,recorderAudioWorkletNode:n})=>{null!==w&&(w.catch((()=>{})),w=null),await n.stop(),e.disconnect(n);const r=await vt(t,null);null===v&&await k(),y([...u,...r]),u.length=0,i.dispatchEvent(new Event("stop"))})),v=null)},k=()=>(m=!1,h.suspend());return k(),{get mimeType(){return o},get state(){return null===v?"inactive":m?"recording":"paused"},pause(){if(null===v)throw n();m&&(k(),i.dispatchEvent(new Event("pause")))},resume(){if(null===v)throw n();m||(b(),i.dispatchEvent(new Event("resume")))},start(t){var a;if(null!==v)throw n();if(s.getVideoTracks().length>0)throw r();i.dispatchEvent(new Event("start"));const c=s.getAudioTracks(),u=0===c.length?2:null!==(a=c[0].getSettings().channelCount)&&void 0!==a?a:2;v=Promise.all([b(),d.then((()=>(async(t,e,n,r,i)=>{const{encoderInstanceId:s,port:o}=await wt(i,e.sampleRate);if(void 0===Ar)throw new Error(Ir);return{audioBufferSourceNode:null===t?null:new Gn(e,{buffer:t}),encoderInstanceId:s,mediaStreamAudioSourceNode:new fr(e,{mediaStream:r}),port:o,recorderAudioWorkletNode:Et(Ar,e,{channelCount:n})}})(l,h,u,s,o)))]).then((async([,{audioBufferSourceNode:e,encoderInstanceId:n,mediaStreamAudioSourceNode:r,port:i,recorderAudioWorkletNode:s}])=>(r.connect(s),null!==e&&(await new Promise((t=>{e.onended=t,e.connect(s),e.start()})),e.disconnect(s)),await s.record(i),void 0!==t&&(w=g(n,t)),{encoderInstanceId:n,mediaStreamAudioSourceNode:r,recorderAudioWorkletNode:s})));const m=s.getTracks();f=()=>{M(),i.dispatchEvent(new ErrorEvent("error",{error:e()}))},s.addEventListener("addtrack",f),s.addEventListener("removetrack",f),p=setInterval((()=>{const t=s.getTracks();t.length===m.length&&!t.some(((t,e)=>t!==m[e]))||null===f||f()}),1e3)},stop:M}})(_r,((t="")=>{try{return new DOMException(t,"InvalidModificationError")}catch(e){return e.code=13,e.message=t,e.name="InvalidModificationError",e}}),(()=>{try{return new DOMException("","InvalidStateError")}catch(t){return t.code=11,t.name="InvalidStateError",t}}),yt),Nr=(t=>(e,n)=>{const r=t(e,n);if(null===r)return r;const i=n+Math.floor((r-1)/8);if(i+r>e.byteLength)return null;let s=e.getUint8(i)&(1<<8-r%8)-1;for(let t=1;t<r;t+=1)s=(s<<8)+e.getUint8(i+t);return{length:r,value:s}})(Pr),Vr=(t=>(e,n,r,i=2)=>{const s=t(e,n);if(null===s)return s;const{length:o,value:a}=s;if("master"===r)return{content:null,length:o};if(n+o+a>e.byteLength)return null;if("binary"===r){const t=(a/Float32Array.BYTES_PER_ELEMENT-1)/i,r=Array.from({length:i},(()=>new Float32Array(t)));for(let s=0;s<t;s+=1){const t=s*i+1;for(let a=0;a<i;a+=1)r[a][s]=e.getFloat32(n+o+(t+a)*Float32Array.BYTES_PER_ELEMENT,!0)}return{content:r,length:o+a}}return{content:null,length:o+a}})(Nr),Dr=(t=>(e,n)=>{const r=t(e,n);if(null===r)return r;const{length:i,value:s}=r;return 35===s?{length:i,type:"binary"}:46===s||97===s||88713574===s||106212971===s||139690087===s||172351395===s||256095861===s?{length:i,type:"master"}:{length:i,type:"unknown"}})(Nr),Lr=((t,e)=>(n,r,i)=>{const s=[];let o=r,a=0;for(;a<n.byteLength;)if(null===o){const t=e(n,a);if(null===t)break;const{length:r,type:i}=t;o=i,a+=r}else{const e=t(n,a,o,i);if(null===e)break;const{content:r,length:c}=e;o=null,a+=c,null!==r&&s.push(r)}return{contents:s,currentElementType:o,offset:a}})(Vr,Dr),zr=((t,e,n)=>(r,i,s,o)=>{const a=[],c=new i(s,{mimeType:"audio/webm; codecs=pcm"});let h=null,l=()=>{};const u=e=>{r.dispatchEvent(t("dataavailable",{data:new Blob(e,{type:o})}))},d=async(t,e)=>{const n=await vt(t,e);"inactive"===c.state?a.push(...n):(u(n),h=d(t,e))},f=()=>{"inactive"!==c.state&&(null!==h&&(h.catch((()=>{})),h=null),l(),l=()=>{},c.stop())};return c.addEventListener("error",(t=>{f(),r.dispatchEvent(new ErrorEvent("error",{error:t.error}))})),c.addEventListener("pause",(()=>r.dispatchEvent(new Event("pause")))),c.addEventListener("resume",(()=>r.dispatchEvent(new Event("resume")))),c.addEventListener("start",(()=>r.dispatchEvent(new Event("start")))),{get mimeType(){return o},get state(){return c.state},pause:()=>c.pause(),resume:()=>c.resume(),start(t){const[i]=s.getAudioTracks();if(void 0!==i&&"inactive"===c.state){const{channelCount:s,sampleRate:f}=i.getSettings();if(void 0===s)throw new Error("The channelCount is not defined.");if(void 0===f)throw new Error("The sampleRate is not defined.");let p=!1,v=!1,w=0,m=wt(o,f);l=()=>{v=!0};const y=kt(c,"dataavailable")((({data:t})=>{w+=1;const i=t.arrayBuffer();m=m.then((async({dataView:t=null,elementType:o=null,encoderInstanceId:h,port:l})=>{const d=await i;w-=1;const f=null===t?new Or.MultiBufferDataView([d]):new Or.MultiBufferDataView([...t.buffers,d],t.byteOffset);if(!p&&"recording"===c.state&&!v){const e=n(f,0);if(null===e)return{dataView:f,elementType:o,encoderInstanceId:h,port:l};const{value:r}=e;if(172351395!==r)return{dataView:t,elementType:o,encoderInstanceId:h,port:l};p=!0}const{currentElementType:m,offset:g,contents:b}=e(f,o,s),M=g<f.byteLength?new Or.MultiBufferDataView(f.buffers,f.byteOffset+g):null;return b.forEach((t=>l.postMessage(t,t.map((({buffer:t})=>t))))),0!==w||"inactive"!==c.state&&!v||(vt(h,null).then((t=>{u([...a,...t]),a.length=0,r.dispatchEvent(new Event("stop"))})),l.postMessage([]),l.close(),y()),{dataView:M,elementType:m,encoderInstanceId:h,port:l}}))}));void 0!==t&&m.then((({encoderInstanceId:e})=>{v||(h=d(e,t))}))}c.start(100)},stop:f}})(_r,Lr,Nr),Br=(t=>()=>{if(null===t)throw new Error("A native EventTarget could not be created.");return t.document.createElement("p")})(jr),Fr=null===jr||void 0===jr.MediaRecorder?null:jr.MediaRecorder,Hr=((t,e,n,r,i,s,o)=>class extends s{constructor(s,a={}){const{mimeType:c}=a;if(null!==o&&(void 0===c||void 0!==o.isTypeSupported&&o.isTypeSupported(c))){const e=t(o,s,a);super(e),this._internalMediaRecorder=e}else{if(void 0===c||!i.some((t=>t.test(c))))throw null!==o&&t(o,s,a),e();super(),this._internalMediaRecorder=null!==o&&void 0!==o.isTypeSupported&&o.isTypeSupported("audio/webm; codecs=pcm")?r(this,o,s,c):n(this,s,c)}this._ondataavailable=null,this._onerror=null,this._onpause=null,this._onresume=null,this._onstart=null,this._onstop=null}get mimeType(){return this._internalMediaRecorder.mimeType}get ondataavailable(){return null===this._ondataavailable?this._ondataavailable:this._ondataavailable[0]}set ondataavailable(t){if(null!==this._ondataavailable&&this.removeEventListener("dataavailable",this._ondataavailable[1]),"function"==typeof t){const e=t.bind(this);this.addEventListener("dataavailable",e),this._ondataavailable=[t,e]}else this._ondataavailable=null}get onerror(){return null===this._onerror?this._onerror:this._onerror[0]}set onerror(t){if(null!==this._onerror&&this.removeEventListener("error",this._onerror[1]),"function"==typeof t){const e=t.bind(this);this.addEventListener("error",e),this._onerror=[t,e]}else this._onerror=null}get onpause(){return null===this._onpause?this._onpause:this._onpause[0]}set onpause(t){if(null!==this._onpause&&this.removeEventListener("pause",this._onpause[1]),"function"==typeof t){const e=t.bind(this);this.addEventListener("pause",e),this._onpause=[t,e]}else this._onpause=null}get onresume(){return null===this._onresume?this._onresume:this._onresume[0]}set onresume(t){if(null!==this._onresume&&this.removeEventListener("resume",this._onresume[1]),"function"==typeof t){const e=t.bind(this);this.addEventListener("resume",e),this._onresume=[t,e]}else this._onresume=null}get onstart(){return null===this._onstart?this._onstart:this._onstart[0]}set onstart(t){if(null!==this._onstart&&this.removeEventListener("start",this._onstart[1]),"function"==typeof t){const e=t.bind(this);this.addEventListener("start",e),this._onstart=[t,e]}else this._onstart=null}get onstop(){return null===this._onstop?this._onstop:this._onstop[0]}set onstop(t){if(null!==this._onstop&&this.removeEventListener("stop",this._onstop[1]),"function"==typeof t){const e=t.bind(this);this.addEventListener("stop",e),this._onstop=[t,e]}else this._onstop=null}get state(){return this._internalMediaRecorder.state}pause(){return this._internalMediaRecorder.pause()}resume(){return this._internalMediaRecorder.resume()}start(t){return this._internalMediaRecorder.start(t)}stop(){return this._internalMediaRecorder.stop()}static isTypeSupported(t){return null!==o&&void 0!==o.isTypeSupported&&o.isTypeSupported(t)||i.some((e=>e.test(t)))}})((t=>(e,n,r)=>{const i=new Map,s=new WeakMap,o=new WeakMap,a=[],c=new e(n,r),h=new WeakMap;var l,u,d,f;return c.addEventListener("stop",(({isTrusted:t})=>{t&&setTimeout((()=>a.shift()))})),c.addEventListener=(l=c.addEventListener,(t,e,n)=>{let r=e;if("function"==typeof e)if("dataavailable"===t){const t=[];r=n=>{const[[r,i]=[!1,!1]]=a;r&&!i?t.push(n):e.call(c,n)},i.set(e,t),s.set(e,r)}else"error"===t?(r=t=>{t instanceof ErrorEvent?e.call(c,t):e.call(c,new ErrorEvent("error",{error:t.error}))},o.set(e,r)):"stop"===t&&(r=t=>{for(const[t,e]of i.entries())if(e.length>0){const[n]=e;e.length>1&&Object.defineProperty(n,"data",{value:new Blob(e.map((({data:t})=>t)),{type:n.data.type})}),e.length=0,t.call(c,n)}e.call(c,t)},h.set(e,r));return l.call(c,t,r,n)}),c.removeEventListener=(u=c.removeEventListener,(t,e,n)=>{let r=e;if("function"==typeof e)if("dataavailable"===t){i.delete(e);const t=s.get(e);void 0!==t&&(r=t)}else if("error"===t){const t=o.get(e);void 0!==t&&(r=t)}else if("stop"===t){const t=h.get(e);void 0!==t&&(r=t)}return u.call(c,t,r,n)}),c.start=(d=c.start,e=>{if(void 0!==r.mimeType&&r.mimeType.startsWith("audio/")&&n.getVideoTracks().length>0)throw t();return"inactive"===c.state&&a.push([void 0!==e,!0]),void 0===e?d.call(c):d.call(c,e)}),c.stop=(f=c.stop,()=>{"inactive"!==c.state&&(a[0][1]=!1),f.call(c)}),c})(yt),yt,Ur,zr,Wr,(t=>class{constructor(e=null){this._listeners=new WeakMap,this._nativeEventTarget=null===e?t():e}addEventListener(t,e,n){if(null!==e){let s=this._listeners.get(e);void 0===s&&(r=this,i=e,s=t=>{const e={value:r};return Object.defineProperties(t,{currentTarget:e,target:e}),"function"==typeof i?i.call(r,t):i.handleEvent.call(r,t)},"function"==typeof e&&this._listeners.set(e,s)),this._nativeEventTarget.addEventListener(t,s,n)}var r,i}dispatchEvent(t){return this._nativeEventTarget.dispatchEvent(t)}removeEventListener(t,e,n){const r=null===e?void 0:this._listeners.get(e);this._nativeEventTarget.removeEventListener(t,void 0===r?null:r,n)}})(Br),Fr),$r=new WeakMap,qr=st({characterize:({call:t})=>()=>t("characterize"),encode:({call:t})=>(e,n)=>t("encode",{recordingId:e,timeslice:n}),record:({call:t})=>async(e,n,r)=>{await t("record",{recordingId:e,sampleRate:n,typedArrays:r},r.map((({buffer:t})=>t)).filter((t=>t instanceof ArrayBuffer)))}}),Xr=new Blob(['(()=>{var e={455(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,s=536870912,a=2*s,o=function(e,t){return function(r){var o=t.get(r),i=void 0===o?r.size:o<a?o+1:0;if(!r.has(i))return e(r,i);if(r.size<s){for(;r.has(i);)i=Math.floor(Math.random()*a);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,c=r(i),l=o(c,i),u=t(l);e.addUniqueNumber=u,e.generateUniqueNumber=l}(t)}},t={};function r(n){var s=t[n];if(void 0!==s)return s.exports;var a=t[n]={exports:{}};return e[n].call(a.exports,a,a.exports,r),a.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,s=(e,t)=>Object.assign(new Error(e),{status:t}),a=t=>s(\'The handler of the method called "\'.concat(t,\'" returned an unexpected result.\'),e),o=(t,r)=>async({data:{id:o,method:i,params:c}})=>{const l=r[i];try{if(void 0===l)throw(e=>s(\'The requested method called "\'.concat(e,\'" is not supported.\'),n))(i);const r=void 0===c?l():l(c);if(void 0===r)throw(t=>s(\'The handler of the method called "\'.concat(t,\'" returned no required result.\'),e))(i);const u=r instanceof Promise?await r:r;if(null===o){if(void 0!==u.result)throw a(i)}else{if(void 0===u.result)throw a(i);const{result:e,transferables:r=[]}=u;t.postMessage({id:o,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:o})}};var i=r(455);const c=new Map,l=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),s=(0,i.generateUniqueNumber)(c);return c.set(s,()=>{n(),t.close(),c.delete(s)}),{result:s}},disconnect:({portId:e})=>{const r=c.get(e);if(void 0===r)throw(e=>s(\'The specified parameter called "portId" with the given value "\'.concat(e,\'" does not identify a port connected to this worker.\'),t))(e);return r(),{result:null}},isSupported:async()=>{if(await new Promise(e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])})){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),u=(e,t,r=()=>!0)=>{const n=l(u,t,r),s=o(e,n);return e.addEventListener("message",s),()=>e.removeEventListener("message",s)},d=e=>e.reduce((e,t)=>e+t.length,0),h=(e,t)=>{const r=[];let n=0;e:for(;n<t;){const t=e.length;for(let s=0;s<t;s+=1){const t=e[s];void 0===r[s]&&(r[s]=[]);const a=t.shift();if(void 0===a)break e;r[s].push(a),0===s&&(n+=a.length)}}if(n>t){const s=n-t;r.forEach((t,r)=>{const n=t.pop(),a=n.length-s;t.push(n.subarray(0,a)),e[r].unshift(n.subarray(a))})}return r},f=new Map,m=(e=>(t,r,n)=>{const s=e.get(t);if(void 0===s){const s={channelDataArrays:n.map(e=>[e]),isComplete:!0,sampleRate:r};return e.set(t,s),s}return s.channelDataArrays.forEach((e,t)=>e.push(n[t])),s})(f),p=((e,t)=>(r,n,s,a)=>{const o=s>>3,i="subsequent"===n?0:44,c=r.length,l=e(r[0]),u=new ArrayBuffer(l*c*o+i),d=new DataView(u);return"subsequent"!==n&&t(d,s,c,"complete"===n?l:Number.POSITIVE_INFINITY,a),r.forEach((e,t)=>{let r=i+t*o;e.forEach(e=>{const t=e.length;for(let n=0;n<t;n+=1){const t=e[n];d.setInt16(r,t<0?32768*Math.max(-1,t):32767*Math.min(1,t),!0),r+=c*o}})}),[u]})(d,(e,t,r,n,s)=>{const a=t>>3,o=Math.min(n*r*a,4294967251);e.setUint32(0,1380533830),e.setUint32(4,o+36,!0),e.setUint32(8,1463899717),e.setUint32(12,1718449184),e.setUint32(16,16,!0),e.setUint16(20,1,!0),e.setUint16(22,r,!0),e.setUint32(24,s,!0),e.setUint32(28,s*r*a,!0),e.setUint16(32,r*a,!0),e.setUint16(34,t,!0),e.setUint32(36,1684108385),e.setUint32(40,o,!0)}),v=new Map;u(self,{characterize:()=>({result:/^audio\\/wav$/}),encode:({recordingId:e,timeslice:t})=>{const r=v.get(e);void 0!==r&&(v.delete(e),r.reject(new Error("Another request was made to initiate an encoding.")));const n=f.get(e);if(null!==t){if(void 0===n||d(n.channelDataArrays[0])*(1e3/n.sampleRate)<t)return new Promise((r,n)=>{v.set(e,{reject:n,resolve:r,timeslice:t})});const r=h(n.channelDataArrays,Math.ceil(t*(n.sampleRate/1e3))),s=p(r,n.isComplete?"initial":"subsequent",16,n.sampleRate);return n.isComplete=!1,{result:s,transferables:s}}if(void 0!==n){const t=p(n.channelDataArrays,n.isComplete?"complete":"subsequent",16,n.sampleRate);return f.delete(e),{result:t,transferables:t}}return{result:[],transferables:[]}},record:({recordingId:e,sampleRate:t,typedArrays:r})=>{const n=m(e,t,r),s=v.get(e);if(void 0!==s&&d(n.channelDataArrays[0])*(1e3/t)>=s.timeslice){const r=h(n.channelDataArrays,Math.ceil(s.timeslice*(t/1e3))),a=p(r,n.isComplete?"initial":"subsequent",16,t);n.isComplete=!1,v.delete(e),s.resolve({result:a,transferables:a})}return{result:null}}})})()})();'],{type:"application/javascript; charset=utf-8"}),Kr=URL.createObjectURL(Xr),Yr=(t=>{const e=new Worker(t);return qr(e)})(Kr),Zr=Yr.connect;var Gr;URL.revokeObjectURL(Kr);const Jr=n(class extends r{constructor(t){super(),!1!==t&&this.__registerHost(),this.startRecord=i(this,"startRecord",7),this.stopRecord=i(this,"stopRecord",7),this.sendTranscript=i(this,"sendTranscript",7),this.isRecording=!1,this.isProcessing=!1,this.time=0,this.transcript="",this.fullTranscript="",this.isSpeechRecognitionSupported=!0,this.userCountry="",this.audioBase64="",this.originalMediaRecorder=window.MediaRecorder,this.pendingStop=!1,this.recognitionEnded=!1}resolveParentState(){const t=(t=>{const e=t?w(t):m.state.activeParentScope,n=m.state.parentContexts[e];return(null==n?void 0:n.dataKey)?n:{dataKey:m.state.dataKey||"",dataMode:m.state.dataMode||v}})(this.componentType);return{dataKey:this.dataKey||t.dataKey,dataMode:this.dataMode||t.dataMode}}async componentWillLoad(){var t;this.isSpeechRecognitionSupported=this.checkSpeechRecognitionSupport();const e=Intl.DateTimeFormat().resolvedOptions().timeZone;if(this.userCountry=h(e),l(e)&&(console.warn("User is likely in China, which may have limited Web Speech API support. Falling back to audio processing mode."),this.isSpeechRecognitionSupported=!1),!window.MediaRecorder.isTypeSupported("audio/wav"))try{await(async t=>{const e=await mt(t);Wr.push(e),$r.set(t,e)})(await Zr())}catch(e){(null===(t=e.message)||void 0===t?void 0:t.includes("already an encoder"))?console.warn("WAV encoder was already registered. Continuing..."):console.error("Unexpected encoder registration error:",e)}}checkSpeechRecognitionSupport(){return"undefined"!=typeof window&&("SpeechRecognition"in window||"webkitSpeechRecognition"in window)}getRecognitionLanguage(){var t,e;return"undefined"==typeof navigator?"en-US":(null!==(e=null===(t=navigator.languages)||void 0===t?void 0:t[0])&&void 0!==e?e:navigator.language)||"en-US"}async startRecording(){this.fullTranscript="",this.pendingStop=!1,this.recognitionEnded=!1,this.startRecord.emit(this),this.isRecording=!0,m.state.activeParentScope=w(this.componentType);try{window.MediaRecorder=Hr,this.startRecognition(),setTimeout((()=>this.createWaveSurfer()),500),this.time=0,this.timer=setInterval((()=>{this.time++}),500)}catch(t){console.error("Error accessing microphone:",t)}}createWaveSurfer(){this.wavesurfer&&this.wavesurfer.destroy();const t=getComputedStyle(this.element),e=e=>t.getPropertyValue(e).trim(),n=e("--ai12z-audio-wave-color")||e("--ai12zBot-v2-searchbar-mic-color")||e("--ai12z-mic-color")||e("--ai12z-primary-color")||"#007bff",r=e("--ai12z-audio-progress-color")||e("--ai12zBot-v2-secondary-accent")||e("--ai12z-secondary-accent")||n;window.MediaRecorder=Hr;try{this.wavesurfer=z.create({container:this.element.querySelector("#mic"),waveColor:n,progressColor:r,barWidth:3,barGap:2,height:30}),this.record=this.wavesurfer.registerPlugin(X.create({renderRecordedAudio:!1,scrollingWaveform:!0,continuousWaveform:!0,continuousWaveformDuration:30,mimeType:"audio/wav"})),this.record.on("record-end",(t=>{const e=new FileReader;e.onloadend=async()=>{if(this.audioBase64=e.result,this.isProcessing)try{const t=this.resolveParentState(),e=await c(t.dataKey,this.getRecognitionLanguage(),t.dataMode,this.audioBase64);this.sendTranscript.emit(e.success?e.transcript:""),this.stopRecord.emit(this)}catch(t){console.error("API Error:",t),this.stopRecord.emit(this)}finally{this.isProcessing=!1,this.isRecording=!1,this.audioBase64="",window.MediaRecorder=this.originalMediaRecorder}},e.readAsDataURL(t)})),this.record.startRecording()}catch(t){console.error("Failed to initialize WaveSurfer or RecordPlugin:",t),this.isRecording=!1,window.MediaRecorder=this.originalMediaRecorder}}startRecognition(){if(this.isSpeechRecognitionSupported){const t=window.SpeechRecognition||window.webkitSpeechRecognition;this.recognition=new t,this.recognition.lang=this.getRecognitionLanguage(),this.recognition.interimResults=!0,this.recognition.start(),this.recognition.onresult=t=>{let e="";for(let n=t.resultIndex;n<t.results.length;n++)e+=t.results[n][0].transcript;this.fullTranscript=e,this.transcript=this.fullTranscript},this.recognition.onerror=t=>{console.error("Error occurred in recognition:",t.error)},this.recognition.onend=()=>{this.recognitionEnded=!0,this.pendingStop&&(this.pendingStop=!1,this.resolveStopAction())}}}resolveStopAction(){this.fullTranscript||this.isSpeechRecognitionSupported?(this.sendTranscript.emit(this.fullTranscript),this.stopRecord.emit(this),this.isRecording=!1,window.MediaRecorder=this.originalMediaRecorder):this.isProcessing=!0}stopRecording(t){this.record.isRecording()&&this.record.stopRecording(),this.recognition&&this.recognition.stop(),clearInterval(this.timer),"stop"===t&&(this.isSpeechRecognitionSupported&&this.recognition?this.recognitionEnded?this.resolveStopAction():this.pendingStop=!0:this.isProcessing=!0)}render(){const t=Math.floor(this.time/60),e=this.time%60;return s("div",{key:"b73747279b29f4a1caf317a5d0f00da382315346",class:"flex w-full"},(this.isRecording||this.isProcessing)&&s("div",{key:"534a01d1be9ae431f46029615db42c87a2587f36",class:"relative flex items-center w-full rounded-full"},this.isRecording&&s("button",{key:"862cdaa52da77d810a441853181c06f3a26da726","aria-label":"Cancel Recording",onClick:t=>{t.preventDefault(),this.stopRecording("cancel")},class:"w-10 h-10 rounded-full flex items-center justify-center text-white"},"❌"),s("div",{key:"62495256b25dc06fe0653702ae080e33c7745c8c",id:"mic",style:{width:"100%"}}),this.isRecording&&!this.isProcessing?s("div",{class:"ml-auto text-blue-600 font-semibold"},String(t).padStart(2,"0"),":",String(e).padStart(2,"0")):null,(this.isRecording||this.isProcessing)&&s("button",{key:"036e203205dfc398ed7152f796fc43d7b1bad24a","aria-label":"Confirm Recording",disabled:this.isProcessing,onClick:t=>{t.preventDefault(),this.isProcessing||this.stopRecording("stop")},class:"w-10 h-10 ml-2 rounded-full flex items-center justify-center "+(this.isProcessing?"cursor-not-allowed":"text-blue-600")},this.isProcessing?s("svg",{class:"activity-spinner",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},s("line",{x1:"12",y1:"2",x2:"12",y2:"5","stroke-width":"2","stroke-linecap":"round",style:{"--n":"0"}}),s("line",{x1:"16.24",y1:"3.76",x2:"14.12",y2:"5.88","stroke-width":"2","stroke-linecap":"round",style:{"--n":"1"}}),s("line",{x1:"19",y1:"7.76",x2:"16.24",y2:"9.24","stroke-width":"2","stroke-linecap":"round",style:{"--n":"2"}}),s("line",{x1:"20",y1:"12",x2:"17",y2:"12","stroke-width":"2","stroke-linecap":"round",style:{"--n":"3"}}),s("line",{x1:"19",y1:"16.24",x2:"16.24",y2:"14.76","stroke-width":"2","stroke-linecap":"round",style:{"--n":"4"}}),s("line",{x1:"16.24",y1:"20.24",x2:"14.12",y2:"18.12","stroke-width":"2","stroke-linecap":"round",style:{"--n":"5"}}),s("line",{x1:"12",y1:"22",x2:"12",y2:"19","stroke-width":"2","stroke-linecap":"round",style:{"--n":"6"}}),s("line",{x1:"7.76",y1:"20.24",x2:"9.88",y2:"18.12","stroke-width":"2","stroke-linecap":"round",style:{"--n":"7"}}),s("line",{x1:"5",y1:"16.24",x2:"7.76",y2:"14.76","stroke-width":"2","stroke-linecap":"round",style:{"--n":"8"}}),s("line",{x1:"4",y1:"12",x2:"7",y2:"12","stroke-width":"2","stroke-linecap":"round",style:{"--n":"9"}}),s("line",{x1:"5",y1:"7.76",x2:"7.76",y2:"9.24","stroke-width":"2","stroke-linecap":"round",style:{"--n":"10"}}),s("line",{x1:"7.76",y1:"3.76",x2:"9.88",y2:"5.88","stroke-width":"2","stroke-linecap":"round",style:{"--n":"11"}})):s("span",{class:"text-blue-600 font-sans"},"✔"))),!this.isRecording&&!this.isProcessing&&s("button",{key:"ad24a6225403a8983100667054aa45f3ed5c24a8","aria-label":"Start Recording",title:"Start Recording",onClick:t=>{t.preventDefault(),this.startRecording()},class:"flex "+("search"===this.componentType||"cta"===this.componentType?"p-1.5 mr-0.5 self-center mt-0.5":"w-10 h-8 p-0 mt-4")},s("svg",{key:"7e1b80a53b24d446cdf9bf77512d2bdea8a29450",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",class:"w-5 h-5 translate-y-[0.5px] "+("search"===this.componentType||"cta"===this.componentType?"mic-icon":"mic-botIcon")},s("path",{key:"73917f2f7ffc7f6c243394797ffe83944279bc27",d:"M7 4a3 3 0 016 0v6a3 3 0 11-6 0V4z"}),s("path",{key:"bc2e12c016990bdbb1aaeee292e612e11d7993c8",d:"M5.5 9.643a.75.75 0 00-1.5 0V10c0 3.06 2.29 5.585 5.25 5.954V17.5h-1.5a.75.75 0 000 1.5h4.5a.75.75 0 000-1.5h-1.5v-1.546A6.001 6.001 0 0016 10v-.357a.75.75 0 00-1.5 0V10a4.5 4.5 0 01-9 0v-.357z"}))))}get element(){return this}static get style(){return":host{width:100%}.mic-icon{fill:var(--ai12z-mic-color)}.mic-botIcon{fill:var(--ai12zBot-v2-searchbar-mic-color)}.activity-spinner{width:20px;height:20px;stroke:currentColor;animation:activity-rotate 1s steps(12, end) infinite}.activity-spinner line{opacity:calc(1 - var(--n) / 11 * 0.85)}@keyframes activity-rotate{to{transform:rotate(360deg)}}"}},[0,"audio-recorder",{componentType:[1,"component-type"],dataKey:[32],dataMode:[32],isRecording:[32],isProcessing:[32],time:[32],transcript:[32],fullTranscript:[32],isSpeechRecognitionSupported:[32],userCountry:[32]}]);function Qr(){"undefined"!=typeof customElements&&["audio-recorder","item-list"].forEach((t=>{switch(t){case"audio-recorder":customElements.get(e(t))||customElements.define(e(t),Jr);break;case"item-list":customElements.get(e(t))||a()}}))}Qr();export{Jr as A,Qr as d,y as s}
|