carta1 1.8.0 → 1.9.0
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/codec/allocation/distortion.js +371 -0
- package/codec/allocation/refine.js +461 -0
- package/codec/allocation/solve.js +247 -318
- package/codec/allocation/source.js +44 -22
- package/codec/allocation/stage.js +15 -3
- package/codec/analysis/bands.js +7 -6
- package/codec/analysis/blocks.js +19 -8
- package/codec/analysis/spectrum.js +9 -10
- package/codec/core/constants.js +13 -1
- package/codec/core/tables.js +87 -16
- package/codec/index.js +1 -1
- package/codec/pipeline/decoder.js +3 -1
- package/codec/pipeline/encoder.js +3 -1
- package/codec/state/decoder.js +71 -0
- package/codec/state/encoder.js +113 -0
- package/codec/state/storage.js +38 -0
- package/codec/state/transform.js +61 -0
- package/codec/syntax/frame.js +3 -4
- package/codec/synthesis/bands.js +9 -13
- package/codec/synthesis/pcm.js +7 -6
- package/dist/carta1-worker.min.js +1 -1
- package/dist/carta1-worker.min.js.map +1 -1
- package/dist/carta1.min.js +1 -1
- package/dist/carta1.min.js.map +1 -1
- package/package.json +1 -1
- package/codec/state.js +0 -112
package/dist/carta1.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(r,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Carta1=e():r.Carta1=e()}(this,()=>(()=>{"use strict";const r={d:(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var o=t[n++],a=t[n++];r.o(e,o)?0===a&&n++:0===a?Object.defineProperty(e,o,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,o,{enumerable:!0,get:a})}else for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},o:(r,e)=>Object.prototype.hasOwnProperty.call(r,e),r:r=>{Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})}};let e={};function t(r){throw new Error(r)}function n(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];var o=t.map(function(e){return e(r)});return function(r){return o.reduce(function(r,e){return e(r)},r)}}r.r(e),r.d(e,{AeaFile:()=>we,AudioProcessor:()=>Dt,BFU_START_LONG:()=>D,BufferPool:()=>ne,EncoderOptions:()=>Vr,FFT:()=>yr,SCALE_FACTORS:()=>W,SPECS_PER_BFU:()=>x,WORD_LENGTH_BITS:()=>V,decode:()=>ye,decodeAeaPcm:()=>bt,dequantize:()=>$r,deserializeFrame:()=>Pe,encode:()=>oe,encodeAeaPcm:()=>dt,mdctStage:()=>zr,pipe:()=>n,qmfAnalysisStage:()=>cr,quantize:()=>Wr,serializeFrame:()=>Fe});var o=2,a=44100,i=512,u=2048,l=212,c=8*l,f=40,s=52,h=10,y=64,v=512,d=32,p=32,b=16,m=2,w=48,g=24,S=48-m,A=24,k=24,O=m*A,j=128,F=128,P=256,M=16,T=4,I=6,C=1,B=15,E=new Uint8Array([0,8,0,0]),x=new Int32Array([8,8,8,8,4,4,4,4,8,8,8,8,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,9,9,9,9,10,10,10,10,12,12,12,12,12,12,12,12,20,20,20,20,20,20,20,20]),z=new Int32Array([20,28,32,36,40,44,48,52]),q=new Int32Array([20,36,52]),D=new Int32Array([0,8,16,24,32,36,40,44,48,56,64,72,80,86,92,98,104,110,116,122,128,134,140,146,152,159,166,173,180,189,198,207,216,226,236,246,256,268,280,292,304,316,328,340,352,372,392,412,432,452,472,492]),_=new Int32Array([0,32,64,96,8,40,72,104,12,44,76,108,20,52,84,116,26,58,90,122,128,160,192,224,134,166,198,230,141,173,205,237,150,182,214,246,256,288,320,352,384,416,448,480,268,300,332,364,396,428,460,492]),U=function(){for(var r=new Float64Array(32),e=0;e<32;e++)r[e]=Math.sin((e+.5)*Math.PI/64);return r}(),H=new Float32Array([-1461907e-11,-9205479e-11,-56157569e-12,.00030117269,.0002422519,-.00085293897,-.0005205574,.0020340169,.00078333891,-.0042153862,-.00075614988,.0078402944,-61169922e-12,-.01344162,.0024626821,.021736089,-.007801671,-.034090221,.01880949,.054326009,-.043596379,-.099384367,.13207909,.46424159]),R=function(){for(var r=new Float32Array(48),e=0;e<24;e++)r[e]=2*H[e],r[47-e]=2*H[e];return r}(),L=function(){for(var r=new Float32Array(24),e=0;e<24;e++)r[e]=R[2*e];return r}(),N=function(){for(var r=new Float32Array(24),e=0;e<24;e++)r[e]=R[2*e+1];return r}(),G=[{size:128,longMdctSize:256,windowStart:48,analysisScale:.5},{size:128,longMdctSize:256,windowStart:48,analysisScale:.5},{size:256,longMdctSize:512,windowStart:112,analysisScale:1}],V=new Int32Array([0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),W=function(){for(var r=new Float64Array(64),e=0;e<64;e++)r[e]=Math.pow(2,e/3-21);return r}(),$=function(){for(var r=V[B],e=new Float64Array(r+1),t=0;t<=r;t++)e[t]=Math.pow(2,-t);return e}(),Q=function(){for(var r=new Int32Array(B),e=0;e<B;e++)r[e]=V[e+1]-V[e]|0;return r}(),Y=function(){var r=new Float64Array(B);r[0]=2-$[V[1]];for(var e=1;e<B;e++){var t=0|V[e],n=0|V[e+1];r[e]=$[t]-$[n]}return r}();function J(r,e){return function(r,e){for(var t=[],n=[],o=0,a=0,i=0;i<3;i++){for(var u=o,l=2===i?256:128,c=i<2?q[i]:x.length,f=0===e[i]?D:_;a<c;){var s=x[a],h=f[a]-u,y=h+s,v=new Float32Array(s);if(h>=0&&y<=l)v.set(r.subarray(u+h,u+y));else if(h<l&&y>0){var d=Math.max(0,h),p=Math.min(l,y);v.set(r.subarray(u+d,u+p),Math.max(0,-h))}t.push(v),n.push(s),a++}o+=l}return{bfuData:t,bfuSizes:n,bfuCount:a}}(r,e)}function K(r){return K="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},K(r)}function X(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=function(r,e){if(r){if("string"==typeof r)return Z(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Z(r,e):void 0}}(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,o=function(){};return{s:o,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(r){throw r},f:o}}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 a,i=!0,u=!1;return{s:function(){t=t.call(r)},n:function(){var r=t.next();return i=r.done,r},e:function(r){u=!0,a=r},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function Z(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function rr(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})),t.push.apply(t,n)}return t}function er(r,e,t){return(e=function(r){var e=function(r,e){if("object"!=K(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=K(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==K(e)?e:e+""}(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var tr=new Map;function nr(r,e,t,n,o,a,i){var u=function(r,e,t,n,o,a){for(var i=new Int32Array(r),u=new Int32Array(r),l=new Float32Array(r),c=0,f=0;f<r;f++){var s=0|e[f];if(0!==s){var h=o[f];if(0!==a[f]){var y=Q[0];if(!(y<=0)){var v=(0===h?a[f]/(2*s):n[h])*Y[0];u[c]=f,l[c]=v/y,c++}}}}if(0===c)return{wordLengths:i,scaleFactorIndices:o};for(var d=(c>>1)-1;d>=0;d--)or(u,l,d,c);for(;t>0&&c>0;){var p=u[0],b=0|i[p],m=0|e[p],w=Q[b]*m;if(w>t||w<=0){var g=c-1;u[0]=u[g],l[0]=l[g],--c>0&&or(u,l,0,c)}else{t-=w;var S=b+1;i[p]=S;var A=Q[S];if(S<B&&A>0){var k=o[p],O=(0===k?a[p]/(2*m):n[k])*Y[S];l[0]=O/A,or(u,l,0,c)}else{var j=c-1;u[0]=u[j],l[0]=l[j],--c>0&&or(u,l,0,c)}}}return{wordLengths:i,scaleFactorIndices:o}}(r,t,n,o,a,i),l=function(r,e,t,n,o,a,i){for(var u=0,l=0;l<r;l++){var c=0|n[l],f=0|V[c];if(0!==f){var s=o[l];u+=(0===s?i[l]/(2*t[l]):a[s])*$[f]*t[l]}else u+=i[l]}for(var h=r;h<e;h++)u+=i[h];return u}(r,e,t,u.wordLengths,u.scaleFactorIndices,o,i);return function(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?rr(Object(t),!0).forEach(function(e){er(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):rr(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}({distortion:l},u)}function or(r,e,t,n){for(var o=t,a=r[o],i=e[o];;){var u=1+(o<<1),l=u+1,c=o,f=i;if(u<n&&e[u]>f&&(c=u,f=e[u]),l<n&&e[l]>f&&(c=l),c===o)break;r[o]=r[c],e[o]=e[c],o=c}r[o]=a,e[o]=i}function ar(r,e,t,n){for(var o=new Int32Array(t),a=new Float32Array(t),i=function(r){if(tr.has(r))return tr.get(r);var e=new Float64Array(64);if(1===r)e.set(W);else for(var t=0;t<64;t++)e[t]=Math.pow(W[t],r);return tr.set(r,e),e}(n),u=0;u<t;u++){var l=0|e[u];if(0!==l){var y=ir(r[u],l);o[u]=y;var v=i[y];if(0===y){for(var d=0,p=0;p<l;p++)d=Math.max(d,Math.abs(r[u][p]));v=0===d?0:Math.pow(d,n)}a[u]=2*v*l}}var b,m=null,w=1/0,g=X(z);try{for(g.s();!(b=g.n()).done;){var S=b.value;if(!(S>t)){var A=c-f-S*h;if(!(A<0)){var k=nr(S,t,e,A,i,o,a);k.distortion<w&&(w=k.distortion,m={bfuCount:S,allocation:k.wordLengths,scaleFactorIndices:k.scaleFactorIndices})}}}}catch(r){g.e(r)}finally{g.f()}if(!m){var O=z[0];return{bfuCount:O,allocation:new Int32Array(O),scaleFactorIndices:new Int32Array(s)}}return m}function ir(r,e){for(var t=0,n=0;n<e;n++){var o=Math.abs(r[n]);o>t&&(t=o)}if(0===t)return 0;var a=Math.ceil(3*(Math.log2(t)+21));return Math.max(0,Math.min(63,a))}function ur(r){var e,n=null!==(e=null==r?void 0:r.options)&&void 0!==e?e:t("allocate: options is required");return function(r){var e=r.coefficients,t=r.blockModes,o=J(e,t),a=o.bfuData,i=o.bfuSizes,u=ar(a,i,o.bfuCount,n.allocationBias),l=u.bfuCount;return{bfuData:a,bfuSizes:i,nBfu:l,scaleFactorIndices:u.scaleFactorIndices.slice(0,l),wordLengthIndices:u.allocation.slice(0,l),blockModes:t}}}function lr(r,e,n){var o,a=null!==(o=n.analysisWindows[r.length])&&void 0!==o?o:t("QMF analysis window for ".concat(r.length," samples is required"));a.set(e),a.set(r,e.length);var i=r.length/2,u=[new Float32Array(i),new Float32Array(i)];return function(r,e,t){var n,o,a;if(!(r instanceof Float32Array)||(null==e?void 0:e.length)!==m||e.some(function(r){return!(r instanceof Float32Array)||r.length!==e[0].length})||!t||(null===(n=t.polyphase)||void 0===n?void 0:n.length)!==m||(null===(o=t.extended)||void 0===o?void 0:o.length)!==m||(null===(a=t.bands)||void 0===a?void 0:a.length)!==m)throw new RangeError("QMF analysis geometry is invalid");var i=e[0].length,u=Math.max(0,i-1)*m+w;if(r.length<u)throw new RangeError("QMF analysis window is incomplete");for(var l=0;l<i;l++){for(var c=2*l,f=0,s=0,h=0;h<g;h++)f+=r[c+47-2*h]*L[h],s+=r[c+46-2*h]*N[h];e[0][l]=f+s,e[1][l]=f-s}}(a,u,n),e.set(a.subarray(r.length,r.length+S)),u}function cr(r){var e,n=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:t("analyzeBands: bufferPool is required"),o=n.qmfAnalysisDelays,a=n.qmfScratch;return function(r){var e=lr(r,o.lowBand,a),t=lr(e[0],o.midBand,a),i=a.highBandWindows[e[1].length];i.set(n.qmfHighBandDelay),i.set(e[1],n.qmfHighBandDelay.length);var u=i.slice(0,e[1].length);return n.qmfHighBandDelay.set(i.subarray(e[1].length,e[1].length+n.qmfHighBandDelay.length)),{bands:[t[0],t[1],u]}}}function fr(r){return fr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},fr(r)}function sr(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,hr(n.key),n)}}function hr(r){var e=function(r,e){if("object"!=fr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=fr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==fr(e)?e:e+""}var yr=function(){return r=function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r)},t=[{key:"transform",value:function(r,e){var t=r.length;if(1!==t){for(var n=Math.log2(t),o=0;o<t;o++){for(var a=0,i=o,u=0;u<n;u++)a=a<<1|1&i,i>>=1;if(a>o){var l=r[o];r[o]=r[a],r[a]=l;var c=e[o];e[o]=e[a],e[a]=c}}for(var f=2;f<=t;f<<=1)for(var s=f>>1,h=-2*Math.PI/f,y=Math.cos(h),v=Math.sin(h),d=0;d<t;d+=f)for(var p=1,b=0,m=0;m<s;m++){var w=d+m,g=w+s,S=r[w],A=e[w],k=r[g],O=e[g],j=k*p-O*b,F=k*b+O*p;r[w]=S+j,e[w]=A+F,r[g]=S-j,e[g]=A-F;var P=p*y-b*v;b=p*v+b*y,p=P}}}}],(e=null)&&sr(r.prototype,e),t&&sr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function vr(r,e){var t=function(r,e){for(var t=0,n=0,o=0;o<r.length;o++){var a=Math.abs(r[o]),i=a-Math.abs(e[o]);i>0&&(t+=i),n+=a*a}var u=Math.sqrt(n)||1e-6;return t/u}(r,e),n=dr(r),o=dr(e),a=Math.abs(n-o),i=pr(r),u=pr(e),l=Math.abs(i-u),c=function(r,e){for(var t=0,n=0,o=0;o<r.length;o++)t+=r[o]*r[o],n+=e[o]*e[o];t=Math.max(t,1e-10),n=Math.max(n,1e-10);var a=10*Math.log10(t/n);return Math.max(0,a)}(r,e);return{spectralFlux:t,flatnessChange:a,hfChange:l,energyChange:c}}function dr(r){for(var e=0,t=0,n=0,o=0;o<r.length;o++){var a=Math.abs(r[o]);a>1e-10&&(e+=Math.log(a),t+=a,n++)}if(0===n)return 0;var i=Math.exp(e/n),u=t/n;return u>1e-10?i/u:0}function pr(r){for(var e=Math.floor(r.length/2),t=0,n=0,o=0;o<e;o++)t+=r[o]*r[o];for(var a=e;a<r.length;a++)n+=r[a]*r[a];var i=t+n;return i>0?n/i:0}function br(r,e,t){if(!e)return!1;var n=function(r){var e=r.spectralFlux,t=r.flatnessChange,n=r.hfChange,o=r.energyChange;return(e+Math.sqrt(t)+Math.log1p(10*n)/Math.log1p(10)+Math.min(o/30,1))/4}(vr(r,e));return n>t}function mr(r){var e,n,o=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:t("selectBlocks: bufferPool is required"),a=null!==(n=null==r?void 0:r.options)&&void 0!==n?n:t("selectBlocks: options is required"),i=[j,F,P];return function(r){var e,t=r.bands;if(a.fixedBlockModes)e=a.fixedBlockModes;else{var n=[a.transientThresholdLow,a.transientThresholdMid,a.transientThresholdHigh];e=t.map(function(r,e){var t=function(r,e){var t=new Float32Array(e),n=new Float32Array(e),o=Math.min(r.length,e);t.set(r.subarray(0,o)),yr.transform(t,n);for(var a=new Float32Array(e/2),i=0;i<e/2;i++)a[i]=Math.sqrt(t[i]*t[i]+n[i]*n[i]);return a}(r,i[e]),a=br(t,o.transientDetection[e],n[e]);return o.transientDetection[e]=t,a*Math.max(e+1,2)})}return{bands:t,blockModes:e}}}function wr(r){return wr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},wr(r)}function gr(r,e,t){return e=Ar(e),function(r,e){if(e&&("object"==wr(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}(r)}(r,Sr()?Reflect.construct(e,t||[],Ar(r).constructor):e.apply(r,t))}function Sr(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(r){}return(Sr=function(){return!!r})()}function Ar(r){return Ar=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Ar(r)}function kr(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&Or(r,e)}function Or(r,e){return Or=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},Or(r,e)}function jr(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,Pr(n.key),n)}}function Fr(r,e,t){return e&&jr(r.prototype,e),t&&jr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function Pr(r){var e=function(r,e){if("object"!=wr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=wr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==wr(e)?e:e+""}function Mr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var Tr=Fr(function r(e,t){Mr(this,r),this.size=e,this.halfSize=e>>1,this.quarterSize=e>>2,this.fftSize=this.halfSize>>1;var n=2*Math.PI/(8*e),o=2*Math.PI/e,a=Math.sqrt(t/e);this.sinCosTable=new Float64Array(this.halfSize);for(var i=0;i<this.quarterSize;i++){var u=o*i+n;this.sinCosTable[2*i]=a*Math.cos(u),this.sinCosTable[2*i+1]=a*Math.sin(u)}}),Ir=function(r){function e(r,t){return Mr(this,e),gr(this,e,[r,t])}return kr(e,r),Fr(e,[{key:"transform",value:function(r){var e,n,o,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,l=this.halfSize,c=this.quarterSize,f=this.fftSize,s=this.sinCosTable,h=null!==(e=null==a?void 0:a[f])&&void 0!==e?e:t("MDCT.transform: mdctBuffers[".concat(f,"] is required")),y=null!==(n=null==h?void 0:h.real)&&void 0!==n?n:t("MDCT.transform: mdctBuffers[".concat(f,"].real is required")),v=null!==(o=null==h?void 0:h.imaginary)&&void 0!==o?o:t("MDCT.transform: mdctBuffers[".concat(f,"].imaginary is required")),d=c,p=3*d;y.fill(0),v.fill(0);for(var b=0;b<d;b+=2){var m=p+b,w=d+b,g=d-1-b,S=r[p-1-b]+r[m],A=r[w]-r[g],k=s[b],O=s[b+1];y[b>>1]=S*k+A*O,v[b>>1]=A*k-S*O}for(var j=d;j<l;j+=2){var F=j>>1,P=j-d,M=d+j,T=5*d-1-j,I=r[p-1-j]-r[P],C=r[M]+r[T],B=s[j],E=s[j+1];y[F]=I*B+C*E,v[F]=C*B-I*E}yr.transform(y,v);for(var x=null!=i?i:new Float32Array(l),z=0;z<f;z++){var q=s[2*z],D=s[2*z+1],_=y[z],U=v[z];x[u+2*z]=-_*q-U*D,x[u+l-1-2*z]=-_*D+U*q}return x}}])}(Tr),Cr=function(r){function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return Mr(this,e),gr(this,e,[r,t||r])}return kr(e,r),Fr(e,[{key:"transform",value:function(r){var e,n,o,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,l=this.size,c=this.halfSize,f=this.quarterSize,s=this.fftSize,h=this.sinCosTable,y=null!==(e=null==a?void 0:a[s])&&void 0!==e?e:t("IMDCT.transform: mdctBuffers[".concat(s,"] is required")),v=null!==(n=null==y?void 0:y.real)&&void 0!==n?n:t("IMDCT.transform: mdctBuffers[".concat(s,"].real is required")),d=null!==(o=null==y?void 0:y.imaginary)&&void 0!==o?o:t("IMDCT.transform: mdctBuffers[".concat(s,"].imaginary is required")),p=f,b=3*p;v.fill(0),d.fill(0);for(var m=0;m<s;m++){var w=2*m,g=-r[w],S=-r[c-1-w],A=h[w],k=h[w+1];v[m]=S*k+g*A,d[m]=S*A-g*k}yr.transform(v,d);for(var O=null!=i?i:new Float32Array(l),j=0;j<s/2;j++){var F=2*j,P=h[F],M=h[F+1],T=v[j],I=d[j],C=T*P+I*M,B=T*M-I*P;O[u+b-1-F]=C,O[u+b+F]=C,O[u+p+F]=B,O[u+p-1-F]=-B}for(var E=s/2;E<s;E++){var x=2*(E-s/2)+p,z=2*E,q=h[z],D=h[z+1],_=v[E],U=d[E],H=_*q+U*D,R=_*D-U*q;O[u+b-1-x]=H,O[u+x-p]=-H,O[u+p+x]=R,O[u+5*p-1-x]=R}return O}}])}(Tr);function Br(r,e){for(var t=e[r.length],n=0;n<r.length;n++)t[n]=r[r.length-1-n];return t}var Er=G.map(function(r){var e=r.analysisScale;return new Ir(y,e)}),xr=G.map(function(r){var e=r.longMdctSize,t=r.analysisScale;return new Ir(e,t)});function zr(r){var e,n=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:t("transformSpectrum: bufferPool is required"),o=n.mdctOverlap;function a(r,e,t,o){var a=G[e];return 0===t?function(r,e,t,o,a){var u=n.transformBuffers[o.size];u.fill(0),u.set(a,t.windowStart),i(r,a,t.size),u.set(r,t.windowStart+p);var l=o.transform(u,n.mdctBuffers);e>0&&(l=Br(l,n.reversalBuffers));return l}(r,e,a,xr[e],o):function(r,e,t,o){for(var a=1<<(256===t.size?3:2),u=new Float32Array(t.size),l=0;l<a;l++){var c=l*d,f=r.subarray(c,c+d),s=n.transformBuffers[y];s.fill(0),s.set(o,0),i(f,o,d),s.set(f,p);var h=Er[e].transform(s,n.mdctBuffers);e>0&&(h=Br(h,n.reversalBuffers)),u.set(h,c)}return u}(r,e,a,o)}function i(r,e,t){for(var n=t-p,o=0;o<p;o++){var a=r[n+o];e[o]=U[o]*a,r[n+o]=a*U[31-o]}}return function(r){var e=r.bands,t=r.blockModes,n=r.originalFrame,i=new Float32Array(512);return e.forEach(function(r,e){var n=a(r,e,t[e],o[e]);i.set(n,function(r){return 0===r?0:1===r?128:256}(e))}),{bands:e,coefficients:i,blockModes:t,originalFrame:n}}}function qr(r){var e=n(r,cr,mr,zr);return function(r){var t=e(r);return{coefficients:t.coefficients,blockModes:t.blockModes}}}function Dr(r){return Dr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Dr(r)}function _r(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})),t.push.apply(t,n)}return t}function Ur(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?_r(Object(t),!0).forEach(function(e){Hr(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):_r(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}function Hr(r,e,t){return(e=Gr(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Rr(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a,i,u=[],l=!0,c=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;l=!1}else for(;!(l=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(r){c=!0,o=r}finally{try{if(!l&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(c)throw o}}return u}}(r,e)||function(r,e){if(r){if("string"==typeof r)return Lr(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Lr(r,e):void 0}}(r,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.")}()}function Lr(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function Nr(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,Gr(n.key),n)}}function Gr(r){var e=function(r,e){if("object"!=Dr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Dr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Dr(e)?e:e+""}var Vr=function(){return r=function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),this.values={transientThresholdLow:1,transientThresholdMid:1.5,transientThresholdHigh:2,allocationBias:1,fixedBlockModes:null},this.metadata={transientThresholdLow:{default:this.values.transientThresholdLow,name:"Low Band Transient Threshold",description:"Controls the transient detection threshold for the low frequency band (0-5.5kHz). Lower values make detection more sensitive, triggering short blocks more easily. Higher values require stronger transients.",range:[.01,2],step:.01},transientThresholdMid:{default:this.values.transientThresholdMid,name:"Mid Band Transient Threshold",description:"Controls the transient detection threshold for the mid frequency band (5.5-11kHz). Lower values make detection more sensitive, triggering short blocks more easily. Higher values require stronger transients.",range:[.01,3],step:.01},transientThresholdHigh:{default:this.values.transientThresholdHigh,name:"High Band Transient Threshold",description:"Controls the transient detection threshold for the high frequency band (11-22kHz). Lower values make detection more sensitive, triggering short blocks more easily. Higher values require stronger transients.",range:[.01,4],step:.01},allocationBias:{default:this.values.allocationBias,name:"Bit allocation bias",description:"Controls how bits are distributed across the frequency spectrum during allocation. Higher values focus more bits on loud spectral components, while lower values spread bits more evenly across frequencies.",range:[0,5],step:.01},fixedBlockModes:{default:this.values.fixedBlockModes,name:"Fixed block modes",description:"Override transient detection and use fixed block modes. Format: [low, mid, high] where low/mid can be 0 or 2, high can be 0 or 3. When set, transient detection is skipped.",type:"array"}},e&&this.setOptions(e)},(e=[{key:"setOptions",value:function(r){for(var e=0,t=Object.entries(r);e<t.length;e++){var n=Rr(t[e],2),o=n[0],a=n[1];o in this.values&&this.setValue(o,a)}}},{key:"setValue",value:function(r,e){if(!(r in this.metadata))throw new Error("Unknown option: ".concat(r));var t=this.metadata[r];if("array"!==t.type){var n=Rr(t.range,2),o=n[0],a=n[1];if(e<o||e>a)throw new Error("Value for ".concat(r," must be between ").concat(o," and ").concat(a,", got ").concat(e))}this.values[r]=e}},{key:"getValue",value:function(r){if(!(r in this.values))throw new Error("Unknown option: ".concat(r));return this.values[r]}},{key:"transientThresholdLow",get:function(){return this.values.transientThresholdLow}},{key:"transientThresholdMid",get:function(){return this.values.transientThresholdMid}},{key:"transientThresholdHigh",get:function(){return this.values.transientThresholdHigh}},{key:"allocationBias",get:function(){return this.values.allocationBias}},{key:"fixedBlockModes",get:function(){return this.values.fixedBlockModes}},{key:"getMetadata",value:function(r){return this.metadata[r]}},{key:"getAllMetadata",value:function(){return Ur({},this.metadata)}},{key:"reset",value:function(){for(var r=0,e=Object.entries(this.metadata);r<e.length;r++){var t=Rr(e[r],2),n=t[0],o=t[1];this.values[n]=o.default}}},{key:"toObject",value:function(){return{values:Ur({},this.values),metadata:Ur({},this.metadata)}}}])&&Nr(r.prototype,e),t&&Nr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function Wr(r,e,t){var n=r.length,o=new Int32Array(n);if(0===t)return o.fill(0,0,n),o;for(var a=W[e],i=(1<<t-C)-1,u=i/a,l=i,c=-i,f=0;f<n;f++){var s=r[f]*u,h=s+(s>=0?.5:-.5)|0;o[f]=h>l?l:h<c?c:h}return o}function $r(r,e,t){if(0===t)return new Float32Array(r.length);for(var n=W[e],o=(1<<t-C)-1,a=new Float32Array(r.length),i=0;i<r.length;i++)a[i]=r[i]*n/o;return a}function Qr(){return function(r){for(var e=r.bfuData,t=r.bfuSizes,n=r.nBfu,o=r.scaleFactorIndices,a=r.wordLengthIndices,i=r.blockModes,u=[],l=0;l<n;l++){var c=e[l].subarray(0,t[l]),f=V[a[l]];u.push(Wr(c,o[l],f))}return{nBfu:n,scaleFactorIndices:o,wordLengthIndices:a,quantizedCoefficients:u,blockModes:i}}}function Yr(r){return Yr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Yr(r)}function Jr(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,Xr(n.key),n)}}function Kr(r,e,t){return e&&Jr(r.prototype,e),t&&Jr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function Xr(r){var e=function(r,e){if("object"!=Yr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Yr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Yr(e)?e:e+""}function Zr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var re=Kr(function r(){Zr(this,r),this.delay=new Float32Array(O),this.delayRow=0}),ee=Kr(function r(){Zr(this,r),this.qmfAnalysisDelays={lowBand:new Float32Array(S),midBand:new Float32Array(S)},this.qmfSynthesisStates={lowBand:new re,midBand:new re},this.qmfHighBandDelay=new Float32Array(39),this.transientDetection=[new Float32Array(64),new Float32Array(64),new Float32Array(128)],this.mdctOverlap=[new Float32Array(32),new Float32Array(32),new Float32Array(32)],this.imdctOverlap=[new Float32Array(256),new Float32Array(256),new Float32Array(512)]}),te=Kr(function r(){Zr(this,r),this.transformBuffers={64:new Float32Array(64),128:new Float32Array(128),256:new Float32Array(256),512:new Float32Array(512)},this.qmfScratch={analysisWindows:{128:new Float32Array(S+128),256:new Float32Array(S+256),512:new Float32Array(S+512)},highBandWindows:{128:new Float32Array(167),256:new Float32Array(295)},polyphase:new Float32Array(m),extended:new Float64Array(m),bands:new Float32Array(m)},this.mdctBuffers={16:{real:new Float32Array(16),imaginary:new Float32Array(16)},64:{real:new Float32Array(64),imaginary:new Float32Array(64)},128:{real:new Float32Array(128),imaginary:new Float32Array(128)}},this.reversalBuffers={32:new Float32Array(32),128:new Float32Array(128),256:new Float32Array(256)}}),ne=Kr(function r(){Zr(this,r),Object.assign(this,new ee,new te)});function oe(){return n({options:arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Vr,bufferPool:arguments.length>1&&void 0!==arguments[1]?arguments[1]:new ne},qr,ur,Qr)}function ae(){return function(r){for(var e=new Float32Array(512),t=r.nBfu,n=r.scaleFactorIndices,o=r.wordLengthIndices,a=r.quantizedCoefficients,i=r.blockModes,u=0;u<t;u++){var l=V[o[u]],c=0;u>=q[0]&&(c=1),u>=q[1]&&(c=2);var f=0===i[c]?D[u]:_[u];if(l>0){var s=$r(a[u],n[u],l);e.set(s,f)}}return{coefficients:e,blockModes:i}}}var ie=new Cr(y,y),ue=G.map(function(r){var e=r.longMdctSize;return new Cr(e,e)});function le(r,e,t){for(var n=r.length,o=new Float32Array(2*n),a=0;a<n;a++){var i=t[a],u=t[2*n-1-a],l=r[a],c=e[n-1-a];o[a]=l*u-c*i,o[2*n-1-a]=l*i+c*u}return o}function ce(r){var e,n=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:t("synthesizeSpectrum: bufferPool is required"),o=n.imdctOverlap;function a(r,e,t,o,a){return 0===t?function(r,e,t,o,a){var i=r;e>0&&(i=Br(r,n.reversalBuffers));var u=a.transform(i,n.mdctBuffers),l=u.length/4,c=n.transformBuffers[v];c.fill(0);for(var f=0;f<o.size;f++)c[f]=u[l+f];var s=t.slice(2*o.size-b,2*o.size),h=le(s.slice(0,b),c.slice(0,b),U);t.set(h,0);for(var y=0;y<b;y++)s[y]=c[b+y];for(var d=2===e?240:112,p=0;p<d;p++)t[32+p]=c[b+p];for(var m=0;m<b;m++)t[2*o.size-b+m]=c[o.size-b+m];return t.slice(0,o.size)}(r,e,o,a,ue[e]):function(r,e,t,o){var a=1<<(256===o.size?3:2),i=n.transformBuffers[v];i.fill(0);for(var u=t.slice(2*o.size-b,2*o.size),l=0,c=0,f=0;f<a;f++){var s=r.slice(c,c+d);e>0&&(s=Br(s,n.reversalBuffers));for(var h=ie.transform(s,n.mdctBuffers),y=h.length/4,p=0;p<d;p++)i[l+p]=h[y+p];var m=le(u.slice(0,b),i.slice(l,l+b),U);t.set(m,l);for(var w=0;w<b;w++)u[w]=i[l+b+w];l+=d,c+=d}for(var g=0;g<b;g++)t[2*o.size-b+g]=i[o.size-b+g];return t.slice(0,o.size)}(r,e,o,a)}return function(r){var e=r.coefficients,t=r.blockModes;return G.map(function(r,n){var i=function(r,e){var t=[0,128,256,512];return r.subarray(t[e],t[e+1])}(e,n);return a(i,n,t[n],o[n],r)})}}function fe(r,e,t){var n=new Float32Array(2*r[0].length);return e.delayRow=function(r,e,t,n,o){var a,i;if((null==r?void 0:r.length)!==m||r.some(function(e){return!(e instanceof Float32Array)||e.length!==r[0].length})||!(e instanceof Float32Array)||e.length!==A*m||!Number.isInteger(t)||t<0||t>=A||!(n instanceof Float32Array)||n.length<r[0].length*m||!o||(null===(a=o.polyphase)||void 0===a?void 0:a.length)!==m||(null===(i=o.bands)||void 0===i?void 0:i.length)!==m)throw new RangeError("QMF synthesis geometry is invalid");for(var u=0;u<r[0].length;u++){var l=r[0][u],c=r[1][u];e[2*t]=l+c,e[2*t+1]=l-c;for(var f=0,s=0,h=0;h<k;h++){var y=(t+A-1-h)%A;f+=e[2*y+1]*N[h],s+=e[2*y]*L[h]}n[2*u]=f,n[2*u+1]=s,t=0===t?A-1:t-1}return t}(r,e.delay,e.delayRow,n,t),n}function se(r){var e,n=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:t("synthesizePcm: bufferPool is required"),a=n.qmfSynthesisStates,i=n.qmfScratch;return function(r){var e=i.highBandWindows[r[2].length];e.set(n.qmfHighBandDelay),e.set(r[2],n.qmfHighBandDelay.length);var t=e.slice(0,2*r[0].length);n.qmfHighBandDelay.set(e.subarray(2*r[0].length,2*r[0].length+n.qmfHighBandDelay.length));for(var u=fe([r[0],r[1]],a.midBand,i),l=fe([u,t],a.lowBand,i),c=0;c<l.length;c++)l[c]*=o;return l}}function he(r){return n(r,ce,se)}function ye(){return n({bufferPool:arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ne},ae,he)}function ve(r){return ve="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ve(r)}function de(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,pe(n.key),n)}}function pe(r){var e=function(r,e){if("object"!=ve(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=ve(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==ve(e)?e:e+""}var be=new TextEncoder,me=new TextDecoder;var we=function(){return r=function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r)},t=[{key:"createHeader",value:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:266,a=new Uint8Array(u),i=new DataView(a.buffer);return a.set(E,0),be.encodeInto(r,a.subarray(4,259)),i.setUint32(260,e,!0),a[264]=t,i.setUint32(268,o>>>0,!0),i.setUint32(272,n>>>0,!0),a}},{key:"parseHeader",value:function(r){if(r.length!==u)throw new Error("Header must be ".concat(u," bytes"));for(var e=0;e<E.length;e++)if(r[e]!==E[e])throw new Error("Invalid AEA file");var t=new DataView(r.buffer,r.byteOffset,r.byteLength),n=r.indexOf(0,4),o=-1===n?256:n-4;return{title:me.decode(r.subarray(4,4+o)),frameCount:t.getUint32(260,!0),channelCount:r[264],primingSampleCount:t.getUint32(268,!0),sampleCount:t.getUint32(272,!0)}}}],(e=null)&&de(r.prototype,e),t&&de(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function ge(r){if(!Number.isInteger(r)||r<0||r>32)throw new RangeError("Bit count must be an integer in 0..32, got ".concat(r))}function Se(r,e,t,n){if(ge(n),0!==n)for(var o=Math.floor(e/8),a=e%8,i=0|Number(t),u=0;u<n&&o<r.length;){var l=8-a,c=Math.min(n-u,l),f=i>>>n-u-c&Math.pow(2,c)-1,s=Math.pow(2,c)-1<<l-c;r[o]=r[o]&~s|f<<l-c,u+=c,o++,a=0}}function Ae(r,e,t){if(ge(t),0===t)return 0;for(var n=Math.floor(e/8),o=e%8,a=0,i=0;i<t&&n<r.length;){var u=8-o,l=Math.min(t-i,u),c=Math.pow(2,l)-1,f=r[n]>>u-l&c;a=a*Math.pow(2,l)+f>>>0,i+=l,n++,o=0}return a}function ke(r,e,t){if(ge(t),0===t)return 0;var n=Ae(r,e,t);return n>=Math.pow(2,t-1)?n-Math.pow(2,t):n}function Oe(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=function(r,e){if(r){if("string"==typeof r)return je(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?je(r,e):void 0}}(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,o=function(){};return{s:o,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(r){throw r},f:o}}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 a,i=!0,u=!1;return{s:function(){t=t.call(r)},n:function(){var r=t.next();return i=r.done,r},e:function(r){u=!0,a=r},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function je(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function Fe(r){var e=new Uint8Array(l),t=new DataView(e.buffer),n=z.indexOf(r.nBfu),o=2-r.blockModes[0]<<14|2-r.blockModes[1]<<12|3-r.blockModes[2]<<10|n<<5;t.setUint16(0,o,!1);for(var a=M,i=0;i<r.nBfu;i++)Se(e,a,r.wordLengthIndices[i],T),a+=T;for(var u=0;u<r.nBfu;u++)Se(e,a,r.scaleFactorIndices[u],I),a+=I;for(var c=0;c<r.nBfu;c++){var f=V[r.wordLengthIndices[c]];if(f>0){var s,h=Oe(r.quantizedCoefficients[c]);try{for(h.s();!(s=h.n()).done;){var y=s.value;Se(e,a,y<0?y+(1<<f):y,f),a+=f}}catch(r){h.e(r)}finally{h.f()}}}return e[l-3]=0,e[l-2]=0,e[l-1]=0,e}function Pe(r){if(r.length!==l)throw new Error("Frame must be ".concat(l," bytes"));for(var e=new DataView(r.buffer,r.byteOffset,r.byteLength).getUint16(0,!1),t=[2-(e>>14&3),2-(e>>12&3),3-(e>>10&3)],n=z[e>>5&7],o=M,a=new Int32Array(n),i=0;i<n;i++)a[i]=Ae(r,o,T),o+=T;for(var u=new Int32Array(n),c=0;c<n;c++)u[c]=Ae(r,o,I),o+=I;for(var f=[],s=0;s<n;s++){var h=V[a[s]],y=x[s],v=new Int32Array(y);if(h>0)for(var d=0;d<y;d++)v[d]=ke(r,o,h),o+=h;f.push(v)}return{nBfu:n,scaleFactorIndices:u,wordLengthIndices:a,quantizedCoefficients:f,blockModes:t}}function Me(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var r,e,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function a(t,n,o,a){var l=n&&n.prototype instanceof u?n:u,c=Object.create(l.prototype);return Te(c,"_invoke",function(t,n,o){var a,u,l,c=0,f=o||[],s=!1,h={p:0,n:0,v:r,a:y,f:y.bind(r,4),d:function(e,t){return a=e,u=0,l=r,h.n=t,i}};function y(t,n){for(u=t,l=n,e=0;!s&&c&&!o&&e<f.length;e++){var o,a=f[e],y=h.p,v=a[2];t>3?(o=v===n)&&(l=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):a[0]<=y&&((o=t<2&&y<a[1])?(u=0,h.v=n,h.n=a[1]):y<v&&(o=t<3||a[0]>n||n>v)&&(a[4]=t,a[5]=n,h.n=v,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,f,v){if(c>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,v),u=f,l=v;(e=u<2?r:l)||!s;){a||(u?u<3?(u>1&&(h.n=-1),y(u,l)):h.n=l:h.v=l);try{if(c=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?l:t.call(n,h))!==i)break}catch(e){a=r,u=1,l=e}finally{c=1}}return{value:e,done:s}}}(t,o,a),!0),c}var i={};function u(){}function l(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Te(e={},n,function(){return this}),e),s=c.prototype=u.prototype=Object.create(f);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,c):(r.__proto__=c,Te(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return l.prototype=c,Te(s,"constructor",c),Te(c,"constructor",l),l.displayName="GeneratorFunction",Te(c,o,"GeneratorFunction"),Te(s),Te(s,o,"Generator"),Te(s,n,function(){return this}),Te(s,"toString",function(){return"[object Generator]"}),(Me=function(){return{w:a,m:h}})()}function Te(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}Te=function(r,e,t,n){function a(e,t){Te(r,e,function(r){return this._invoke(e,t,r)})}e?o?o(r,e,{value:t,enumerable:!n,configurable:!n,writable:!n}):r[e]=t:(a("next",0),a("throw",1),a("return",2))},Te(r,e,t,n)}function Ie(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a,i,u=[],l=!0,c=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;l=!1}else for(;!(l=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(r){c=!0,o=r}finally{try{if(!l&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(c)throw o}}return u}}(r,e)||Be(r,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.")}()}function Ce(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=Be(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,o=function(){};return{s:o,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(r){throw r},f:o}}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 a,i=!0,u=!1;return{s:function(){t=t.call(r)},n:function(){var r=t.next();return i=r.done,r},e:function(r){u=!0,a=r},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function Be(r,e){if(r){if("string"==typeof r)return Ee(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ee(r,e):void 0}}function Ee(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function xe(r,e,t){for(var n=0;n<t.length;n++)r.setUint8(e+n,t.charCodeAt(n))}function ze(r){var e,t=r.reduce(function(r,e){return r+e.length},0),n=new Float32Array(t),o=0,a=Ce(r);try{for(a.s();!(e=a.n()).done;){var i=e.value;n.set(i,o),o+=i.length}}catch(r){a.e(r)}finally{a.f()}return n}function qe(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i;return Me().m(function t(){var n,o,a,i,u,l,c,f,s,h,y;return Me().w(function(t){for(;;)switch(t.n){case 0:if(Array.isArray(r)&&(1===r.length||2===r.length)&&r.every(function(e){return e instanceof Float32Array&&e.length===r[0].length})&&Number.isInteger(e)&&!(e<1)){t.n=1;break}throw new RangeError("ATRAC1 framing requires one or two equally sized Float32 channels and a positive integer frame size");case 1:if(1!==r.length){t.n=5;break}n=Ie(r,1),o=n[0],a=0;case 2:if(!(a<o.length)){t.n=4;break}return(i=new Float32Array(e)).set(o.subarray(a,a+e)),t.n=3,i;case 3:a+=e,t.n=2;break;case 4:return t.a(2);case 5:if(2!==r.length){t.n=9;break}u=Ie(r,2),l=u[0],c=u[1],f=l.length,s=0;case 6:if(!(s<f)){t.n=8;break}return h=new Float32Array(e),y=new Float32Array(e),h.set(l.subarray(s,s+e)),y.set(c.subarray(s,s+e)),t.n=7,[h,y];case 7:s+=e,t.n=6;break;case 8:case 9:return t.a(2)}},t)})()}function De(r){var e=Math.max(-1,Math.min(1,r));return e<0?32768*e:32767*e}function _e(r){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).sampleRate,t=void 0===e?a:e,n=function(r){if(!Array.isArray(r)||r.length<1||!r.every(function(e){return e instanceof Float32Array&&e.length===r[0].length}))throw new RangeError("PCM must contain equally sized Float32 channels");for(var e=r[0].length,t=new Uint8Array(e*r.length*2),n=new DataView(t.buffer),o=0,a=0;a<e;a++){var i,u=Ce(r);try{for(u.s();!(i=u.n()).done;){var l=i.value;n.setInt16(o,De(l[a]),!0),o+=2}}catch(r){u.e(r)}finally{u.f()}}return t}(r),o=function(r){var e=r.sampleCount,t=r.sampleRate,n=r.channels,o=t*n*2,a=2*n,i=e*a,u=new Uint8Array(44),l=new DataView(u.buffer);return xe(l,0,"RIFF"),l.setUint32(4,36+i,!0),xe(l,8,"WAVE"),xe(l,12,"fmt "),l.setUint32(16,16,!0),l.setUint16(20,1,!0),l.setUint16(22,n,!0),l.setUint32(24,t,!0),l.setUint32(28,o,!0),l.setUint16(32,a,!0),l.setUint16(34,16,!0),xe(l,36,"data"),l.setUint32(40,i,!0),u}({sampleCount:r[0].length,sampleRate:t,channels:r.length}),i=new Uint8Array(o.length+n.length);return i.set(o),i.set(n,o.length),i}function Ue(r){return Ue="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ue(r)}var He=["title"];function Re(r){return function(r){if(Array.isArray(r))return $e(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||We(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Le(r,e){if(null==r)return{};var t,n,o=function(r,e){if(null==r)return{};var t={};for(var n in r)if({}.hasOwnProperty.call(r,n)){if(-1!==e.indexOf(n))continue;t[n]=r[n]}return t}(r,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);for(n=0;n<a.length;n++)t=a[n],-1===e.indexOf(t)&&{}.propertyIsEnumerable.call(r,t)&&(o[t]=r[t])}return o}function Ne(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var r,e,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function a(t,n,o,a){var l=n&&n.prototype instanceof u?n:u,c=Object.create(l.prototype);return Ge(c,"_invoke",function(t,n,o){var a,u,l,c=0,f=o||[],s=!1,h={p:0,n:0,v:r,a:y,f:y.bind(r,4),d:function(e,t){return a=e,u=0,l=r,h.n=t,i}};function y(t,n){for(u=t,l=n,e=0;!s&&c&&!o&&e<f.length;e++){var o,a=f[e],y=h.p,v=a[2];t>3?(o=v===n)&&(l=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):a[0]<=y&&((o=t<2&&y<a[1])?(u=0,h.v=n,h.n=a[1]):y<v&&(o=t<3||a[0]>n||n>v)&&(a[4]=t,a[5]=n,h.n=v,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,f,v){if(c>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,v),u=f,l=v;(e=u<2?r:l)||!s;){a||(u?u<3?(u>1&&(h.n=-1),y(u,l)):h.n=l:h.v=l);try{if(c=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?l:t.call(n,h))!==i)break}catch(e){a=r,u=1,l=e}finally{c=1}}return{value:e,done:s}}}(t,o,a),!0),c}var i={};function u(){}function l(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Ge(e={},n,function(){return this}),e),s=c.prototype=u.prototype=Object.create(f);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,c):(r.__proto__=c,Ge(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return l.prototype=c,Ge(s,"constructor",c),Ge(c,"constructor",l),l.displayName="GeneratorFunction",Ge(c,o,"GeneratorFunction"),Ge(s),Ge(s,o,"Generator"),Ge(s,n,function(){return this}),Ge(s,"toString",function(){return"[object Generator]"}),(Ne=function(){return{w:a,m:h}})()}function Ge(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}Ge=function(r,e,t,n){function a(e,t){Ge(r,e,function(r){return this._invoke(e,t,r)})}e?o?o(r,e,{value:t,enumerable:!n,configurable:!n,writable:!n}):r[e]=t:(a("next",0),a("throw",1),a("return",2))},Ge(r,e,t,n)}function Ve(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a,i,u=[],l=!0,c=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;l=!1}else for(;!(l=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(r){c=!0,o=r}finally{try{if(!l&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(c)throw o}}return u}}(r,e)||We(r,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.")}()}function We(r,e){if(r){if("string"==typeof r)return $e(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?$e(r,e):void 0}}function $e(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function Qe(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Ye(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,Ke(n.key),n)}}function Je(r,e,t){return e&&Ye(r.prototype,e),t&&Ye(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function Ke(r){var e=function(r,e){if("object"!=Ue(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Ue(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Ue(e)?e:e+""}function Xe(r,e,t,n,o,a,i){try{var u=r[a](i),l=u.value}catch(r){return void t(r)}u.done?e(l):Promise.resolve(l).then(n,o)}function Ze(r){return function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(r){Xe(a,n,o,i,u,"next",r)}function u(r){Xe(a,n,o,i,u,"throw",r)}i(void 0)})}}function rt(r){return new nt(r,0)}function et(r){return function(){return new tt(r.apply(this,arguments))}}function tt(r){var e,t;function n(e,t){try{var a=r[e](t),i=a.value,u=i instanceof nt;Promise.resolve(u?i.v:i).then(function(t){if(u){var l="return"===e&&i.k?e:"next";if(!i.k||t.done)return n(l,t);t=r[l](t).value}o(!!a.done,t)},function(r){n("throw",r)})}catch(r){o(2,r)}}function o(r,o){2===r?e.reject(o):e.resolve({value:o,done:r}),(e=e.next)?n(e.key,e.arg):t=null}this._invoke=function(r,o){return new Promise(function(a,i){var u={key:r,arg:o,resolve:a,reject:i,next:null};t?t=t.next=u:(e=t=u,n(r,o))})},"function"!=typeof r.return&&(this.return=void 0)}function nt(r,e){this.v=r,this.k=e}function ot(r){var e,t,n,o=2;for("undefined"!=typeof Symbol&&(t=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(t&&null!=(e=r[t]))return e.call(r);if(n&&null!=(e=r[n]))return new at(e.call(r));t="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function at(r){function e(r){if(Object(r)!==r)return Promise.reject(new TypeError(r+" is not an object."));var e=r.done;return Promise.resolve(r.value).then(function(r){return{value:r,done:e}})}return at=function(r){this.s=r,this.n=r.next},at.prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(r){var t=this.s.return;return void 0===t?Promise.resolve({value:r,done:!0}):e(t.apply(this.s,arguments))},throw:function(r){var t=this.s.return;return void 0===t?Promise.reject(r):e(t.apply(this.s,arguments))}},new at(r)}function it(r){if(1!==r&&2!==r)throw new Error("Unsupported channel count: ".concat(r))}function ut(r,e){var t=1===e?[r]:r;if(!Array.isArray(t)||t.length!==e||t.some(function(r){return!(r instanceof Float32Array)}))throw new TypeError("ATRAC1 streaming requires ".concat(e," Float32 channel").concat(1===e?"":"s"," per frame"));if(t.some(function(r){return r.length!==i}))throw new RangeError("ATRAC1 streaming requires exactly ".concat(i," samples per channel"))}function lt(){return{nBfu:0,blockModes:[0,0,0],scaleFactorIndices:new Int32Array(0),wordLengthIndices:new Int32Array(0),quantizedCoefficients:[]}}function ct(r){return ft.apply(this,arguments)}function ft(){return(ft=Ze(Ne().m(function r(e){var t,n,o,a,i,u,l,c;return Ne().w(function(r){for(;;)switch(r.p=r.n){case 0:t=[],n=!1,o=!1,r.p=1,i=ot(e);case 2:return r.n=3,i.next();case 3:if(!(n=!(u=r.v).done)){r.n=5;break}l=u.value,t.push(l);case 4:n=!1,r.n=2;break;case 5:r.n=7;break;case 6:r.p=6,c=r.v,o=!0,a=c;case 7:if(r.p=7,r.p=8,!n||null==i.return){r.n=9;break}return r.n=9,i.return();case 9:if(r.p=9,!o){r.n=10;break}throw a;case 10:return r.f(9);case 11:return r.f(7);case 12:return r.a(2,t)}},r,null,[[8,,9,11],[1,6,7,12]])}))).apply(this,arguments)}tt.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},tt.prototype.next=function(r){return this._invoke("next",r)},tt.prototype.throw=function(r){return this._invoke("throw",r)},tt.prototype.return=function(r){return this._invoke("return",r)};var st=function(){return Je(function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Qe(this,r);var t=e.channelCount,n=void 0===t?1:t,o=e.onProgress,a=e.encoderOptions;it(n);var i=a||new Vr;this.channelCount=n,this.onProgress=o,this.frameIndex=0,this.sampleCount=0,this.finalized=!1,this.leftEncoder=oe(i),this.rightEncoder=2===n?oe(i):null},[{key:"frames",value:function(r){var e=this;return et(Ne().m(function t(){var n,o,a,u,l,c,f,s,h,y;return Ne().w(function(t){for(;;)switch(t.p=t.n){case 0:if(!e.finalized){t.n=1;break}throw new Error("ATRAC1 encoder has already been finalized");case 1:n=!1,o=!1,t.p=2,u=ot(r);case 3:return t.n=4,rt(u.next());case 4:if(!(n=!(l=t.v).done)){t.n=10;break}if(ut(c=l.value,e.channelCount),1!==e.channelCount){t.n=6;break}return t.n=5,e.leftEncoder(c);case 5:t.n=8;break;case 6:return f=Ve(c,2),s=f[0],h=f[1],t.n=7,e.leftEncoder(s);case 7:return t.n=8,e.rightEncoder(h);case 8:e.sampleCount+=i,e.onProgress&&e.onProgress(e.frameIndex++);case 9:n=!1,t.n=3;break;case 10:t.n=12;break;case 11:t.p=11,y=t.v,o=!0,a=y;case 12:if(t.p=12,t.p=13,!n||null==u.return){t.n=14;break}return t.n=14,rt(u.return());case 14:if(t.p=14,!o){t.n=15;break}throw a;case 15:return t.f(14);case 16:return t.f(12);case 17:return t.a(2)}},t,null,[[13,,14,16],[2,11,12,17]])}))()}},{key:"finish",value:Ne().m(function r(){var e,t;return Ne().w(function(r){for(;;)switch(r.n){case 0:if(!this.finalized){r.n=1;break}return r.a(2);case 1:if(this.finalized=!0,0!==this.sampleCount){r.n=2;break}return r.a(2);case 2:e=new Float32Array(i),t=0;case 3:if(!(t<1)){r.n=6;break}return r.n=4,this.leftEncoder(e);case 4:if(2!==this.channelCount){r.n=5;break}return r.n=5,this.rightEncoder(e);case 5:t++,r.n=3;break;case 6:return r.a(2)}},r,this)})}])}(),ht=function(){return Je(function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Qe(this,r);var t=e.channelCount,n=void 0===t?1:t,o=e.onProgress,a=e.primingSampleCount,i=void 0===a?0:a,u=e.sampleCount,l=void 0===u?Number.POSITIVE_INFINITY:u;it(n),this.channelCount=n,this.onProgress=o,this.frameIndex=0,this.primingSampleCount=i,this.sampleCount=l,this.timelinePosition=0,this.emittedSamples=0,this.leftFrame=null,this.leftDecoder=ye(),this.rightDecoder=2===n?ye():null},[{key:"frames",value:function(r){var e=this;return et(Ne().m(function t(){var n,o,a,i,u,l,c;return Ne().w(function(t){for(;;)switch(t.p=t.n){case 0:n=!1,o=!1,t.p=1,i=ot(r);case 2:return t.n=3,rt(i.next());case 3:if(!(n=!(u=t.v).done)){t.n=9;break}if(l=u.value,1!==e.channelCount){t.n=5;break}return t.n=4,e.trim(e.leftDecoder(l));case 4:e.reportProgress(),t.n=8;break;case 5:if(null!==e.leftFrame){t.n=6;break}e.leftFrame=l,t.n=8;break;case 6:return t.n=7,e.trim([e.leftDecoder(e.leftFrame),e.rightDecoder(l)]);case 7:e.leftFrame=null,e.reportProgress();case 8:n=!1,t.n=2;break;case 9:t.n=11;break;case 10:t.p=10,c=t.v,o=!0,a=c;case 11:if(t.p=11,t.p=12,!n||null==i.return){t.n=13;break}return t.n=13,rt(i.return());case 13:if(t.p=13,!o){t.n=14;break}throw a;case 14:return t.f(13);case 15:return t.f(11);case 16:return t.a(2)}},t,null,[[12,,13,15],[1,10,11,16]])}))()}},{key:"finish",value:Ne().m(function r(){return Ne().w(function(r){for(;;)switch(r.n){case 0:if(2!==this.channelCount||null===this.leftFrame){r.n=2;break}return r.n=1,this.trim([this.leftDecoder(this.leftFrame),this.rightDecoder(lt())]);case 1:this.leftFrame=null,this.reportProgress();case 2:if(!Number.isFinite(this.sampleCount)||this.emittedSamples===this.sampleCount){r.n=3;break}throw new RangeError("Truncated ATRAC1 timeline: decoded ".concat(this.emittedSamples," of ").concat(this.sampleCount," samples"));case 3:return r.a(2)}},r,this)})},{key:"trim",value:function(r){var e=Math.max(0,this.primingSampleCount-this.timelinePosition),t=this.sampleCount-this.emittedSamples,n=Math.max(0,Math.min(i-e,t));return this.timelinePosition+=i,this.emittedSamples+=n,1===this.channelCount?r.slice(e,e+n):r.map(function(r){return r.slice(e,e+n)})}},{key:"reportProgress",value:function(){this.onProgress&&this.onProgress(this.frameIndex++)}}])}();function yt(r){return new st(r)}function vt(r){return new ht(r)}function dt(r){return pt.apply(this,arguments)}function pt(){return pt=Ze(Ne().m(function r(e){var t,n,o,a,i,u,c,f,s,h=arguments;return Ne().w(function(r){for(;;)switch(r.n){case 0:if(t=h.length>1&&void 0!==h[1]?h[1]:{},Array.isArray(e)&&(1===e.length||2===e.length)&&!e.some(function(r){return!(r instanceof Float32Array)})){r.n=1;break}throw new TypeError("ATRAC1 encoding requires one or two Float32 channels");case 1:return n=t.title,o=void 0===n?"encoded by carta1":n,a=Le(t,He),i=yt({channelCount:e.length,encoderOptions:new Vr(a)}),u=i.frames(qe(e)),r.n=2,ct(u);case 2:return(c=r.v).push.apply(c,Re(i.finish())),f=we.createHeader(o,c.length,e.length,e[0].length,266),(s=new Uint8Array(f.length+c.length*l)).set(f),c.forEach(function(r,e){s.set(Fe(r),f.length+e*l)}),r.a(2,s)}},r)})),pt.apply(this,arguments)}function bt(r){return mt.apply(this,arguments)}function mt(){return(mt=Ze(Ne().m(function r(e){var t,n,o,a,i,c,f;return Ne().w(function(r){for(;;)switch(r.n){case 0:if(!(e instanceof Blob)){r.n=2;break}return c=Uint8Array,r.n=1,e.arrayBuffer();case 1:f=r.v,t=new c(f),r.n=5;break;case 2:if(!(e instanceof Uint8Array)){r.n=3;break}t=e,r.n=5;break;case 3:if(!(e instanceof ArrayBuffer)){r.n=4;break}t=new Uint8Array(e),r.n=5;break;case 4:throw new TypeError("ATRAC1 decoding requires AEA bytes or a Blob");case 5:return n=we.parseHeader(t.subarray(0,u)),o=vt({channelCount:n.channelCount,primingSampleCount:n.primingSampleCount,sampleCount:n.sampleCount}),a=et(Ne().m(function r(){var e;return Ne().w(function(r){for(;;)switch(r.n){case 0:e=u;case 1:if(!(e+l<=t.length)){r.n=3;break}return r.n=2,Pe(t.subarray(e,e+l));case 2:e+=l,r.n=1;break;case 3:return r.a(2)}},r)}))(),r.n=6,ct(o.frames(a));case 6:if((i=r.v).push.apply(i,Re(o.finish())),1!==n.channelCount){r.n=7;break}return r.a(2,[ze(i)]);case 7:return r.a(2,[ze(i.map(function(r){return Ve(r,1)[0]})),ze(i.map(function(r){return Ve(r,2)[1]}))])}},r)}))).apply(this,arguments)}function wt(r){return wt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},wt(r)}function gt(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a,i,u=[],l=!0,c=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;l=!1}else for(;!(l=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(r){c=!0,o=r}finally{try{if(!l&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(c)throw o}}return u}}(r,e)||At(r,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.")}()}function St(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=At(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,o=function(){};return{s:o,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(r){throw r},f:o}}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 a,i=!0,u=!1;return{s:function(){t=t.call(r)},n:function(){var r=t.next();return i=r.done,r},e:function(r){u=!0,a=r},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function At(r,e){if(r){if("string"==typeof r)return kt(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?kt(r,e):void 0}}function kt(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function Ot(r,e,t,n,o,a,i){try{var u=r[a](i),l=u.value}catch(r){return void t(r)}u.done?e(l):Promise.resolve(l).then(n,o)}function jt(r){return function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(r){Ot(a,n,o,i,u,"next",r)}function u(r){Ot(a,n,o,i,u,"throw",r)}i(void 0)})}}function Ft(r){if(null!=r){var e=r["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],t=0;if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length))return{next:function(){return r&&t>=r.length&&(r=void 0),{value:r&&r[t++],done:!r}}}}throw new TypeError(wt(r)+" is not iterable")}function Pt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var r,e,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function a(t,n,o,a){var l=n&&n.prototype instanceof u?n:u,c=Object.create(l.prototype);return Mt(c,"_invoke",function(t,n,o){var a,u,l,c=0,f=o||[],s=!1,h={p:0,n:0,v:r,a:y,f:y.bind(r,4),d:function(e,t){return a=e,u=0,l=r,h.n=t,i}};function y(t,n){for(u=t,l=n,e=0;!s&&c&&!o&&e<f.length;e++){var o,a=f[e],y=h.p,v=a[2];t>3?(o=v===n)&&(l=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):a[0]<=y&&((o=t<2&&y<a[1])?(u=0,h.v=n,h.n=a[1]):y<v&&(o=t<3||a[0]>n||n>v)&&(a[4]=t,a[5]=n,h.n=v,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,f,v){if(c>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,v),u=f,l=v;(e=u<2?r:l)||!s;){a||(u?u<3?(u>1&&(h.n=-1),y(u,l)):h.n=l:h.v=l);try{if(c=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?l:t.call(n,h))!==i)break}catch(e){a=r,u=1,l=e}finally{c=1}}return{value:e,done:s}}}(t,o,a),!0),c}var i={};function u(){}function l(){}function c(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Mt(e={},n,function(){return this}),e),s=c.prototype=u.prototype=Object.create(f);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,c):(r.__proto__=c,Mt(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return l.prototype=c,Mt(s,"constructor",c),Mt(c,"constructor",l),l.displayName="GeneratorFunction",Mt(c,o,"GeneratorFunction"),Mt(s),Mt(s,o,"Generator"),Mt(s,n,function(){return this}),Mt(s,"toString",function(){return"[object Generator]"}),(Pt=function(){return{w:a,m:h}})()}function Mt(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}Mt=function(r,e,t,n){function a(e,t){Mt(r,e,function(r){return this._invoke(e,t,r)})}e?o?o(r,e,{value:t,enumerable:!n,configurable:!n,writable:!n}):r[e]=t:(a("next",0),a("throw",1),a("return",2))},Mt(r,e,t,n)}function Tt(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,It(n.key),n)}}function It(r){var e=function(r,e){if("object"!=wt(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=wt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==wt(e)?e:e+""}function Ct(r){return function(){return new Bt(r.apply(this,arguments))}}function Bt(r){var e,t;function n(e,t){try{var a=r[e](t),i=a.value,u=i instanceof xt;Promise.resolve(u?i.v:i).then(function(t){if(u){var l="return"===e&&i.k?e:"next";if(!i.k||t.done)return n(l,t);t=r[l](t).value}o(!!a.done,t)},function(r){n("throw",r)})}catch(r){o(2,r)}}function o(r,o){2===r?e.reject(o):e.resolve({value:o,done:r}),(e=e.next)?n(e.key,e.arg):t=null}this._invoke=function(r,o){return new Promise(function(a,i){var u={key:r,arg:o,resolve:a,reject:i,next:null};t?t=t.next=u:(e=t=u,n(r,o))})},"function"!=typeof r.return&&(this.return=void 0)}function Et(r){var e={},t=!1;function n(e,n){return t=!0,n=new Promise(function(t){t(r[e](n))}),{done:!1,value:new xt(n,1)}}return e["undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator"]=function(){return this},e.next=function(r){return t?(t=!1,r):n("next",r)},"function"==typeof r.throw&&(e.throw=function(r){if(t)throw t=!1,r;return n("throw",r)}),"function"==typeof r.return&&(e.return=function(r){return t?(t=!1,r):n("return",r)}),e}function xt(r,e){this.v=r,this.k=e}function zt(r){var e,t,n,o=2;for("undefined"!=typeof Symbol&&(t=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(t&&null!=(e=r[t]))return e.call(r);if(n&&null!=(e=r[n]))return new qt(e.call(r));t="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function qt(r){function e(r){if(Object(r)!==r)return Promise.reject(new TypeError(r+" is not an object."));var e=r.done;return Promise.resolve(r.value).then(function(r){return{value:r,done:e}})}return qt=function(r){this.s=r,this.n=r.next},qt.prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(r){var t=this.s.return;return void 0===t?Promise.resolve({value:r,done:!0}):e(t.apply(this.s,arguments))},throw:function(r){var t=this.s.return;return void 0===t?Promise.reject(r):e(t.apply(this.s,arguments))}},new qt(r)}Bt.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},Bt.prototype.next=function(r){return this._invoke("next",r)},Bt.prototype.throw=function(r){return this._invoke("throw",r)},Bt.prototype.return=function(r){return this._invoke("return",r)};var Dt=function(){function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r)}return e=r,t=null,n=[{key:"encodeAeaPcm",value:function(r){return dt(r,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}},{key:"decodeAeaPcm",value:function(r){return bt(r)}},{key:"encodeStream",value:function(r){return Ct(function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Pt().m(function t(){var n;return Pt().w(function(t){for(;;)switch(t.n){case 0:return n=yt(e),t.d(Ft(Et(zt(n.frames(r)))),1);case 1:return t.d(Ft(Et(zt(n.finish()))),2);case 2:return t.a(2)}},t)})()}).apply(this,arguments)}},{key:"decodeStream",value:function(r){return Ct(function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Pt().m(function t(){var n;return Pt().w(function(t){for(;;)switch(t.n){case 0:return n=vt(e),t.d(Ft(Et(zt(n.frames(r)))),1);case 1:return t.d(Ft(Et(zt(n.finish()))),2);case 2:return t.a(2)}},t)})()}).apply(this,arguments)}},{key:"frameBufferToFrames",value:Pt().m(function r(e,t){return Pt().w(function(r){for(;;)switch(r.n){case 0:return r.d(Ft(qe(e,t)),1);case 1:return r.a(2)}},r)})},{key:"collectFrames",value:(f=jt(Pt().m(function r(e){var t,n,o,a,i,u,l,c;return Pt().w(function(r){for(;;)switch(r.p=r.n){case 0:t=[],n=!1,o=!1,r.p=1,i=zt(e);case 2:return r.n=3,i.next();case 3:if(!(n=!(u=r.v).done)){r.n=5;break}l=u.value,t.push(l);case 4:n=!1,r.n=2;break;case 5:r.n=7;break;case 6:r.p=6,c=r.v,o=!0,a=c;case 7:if(r.p=7,r.p=8,!n||null==i.return){r.n=9;break}return r.n=9,i.return();case 9:if(r.p=9,!o){r.n=10;break}throw a;case 10:return r.f(9);case 11:return r.f(7);case 12:return r.a(2,t)}},r,null,[[8,,9,11],[1,6,7,12]])})),function(r){return f.apply(this,arguments)})},{key:"createAeaBlob",value:(c=jt(Pt().m(function r(e){var t,n,o,a,u,l,c,f,s,h,y,v,d,p,b,m,w,g=arguments;return Pt().w(function(r){for(;;)switch(r.p=r.n){case 0:o=(n=g.length>1&&void 0!==g[1]?g[1]:{}).title,a=void 0===o?"encoded by atrac1.js":o,u=n.channelCount,l=void 0===u?1:u,c=[],f=!1,s=!1,r.p=1,y=zt(e);case 2:return r.n=3,y.next();case 3:if(!(f=!(v=r.v).done)){r.n=5;break}d=v.value,c.push(Fe(d));case 4:f=!1,r.n=2;break;case 5:r.n=7;break;case 6:r.p=6,w=r.v,s=!0,h=w;case 7:if(r.p=7,r.p=8,!f||null==y.return){r.n=9;break}return r.n=9,y.return();case 9:if(r.p=9,!s){r.n=10;break}throw h;case 10:return r.f(9);case 11:return r.f(7);case 12:return p=c.length/l,b=null!==(t=n.sampleCount)&&void 0!==t?t:Math.max(0,p-1)*i,m=we.createHeader(a,c.length,l,b,266),r.a(2,new Blob([m].concat(c),{type:"application/octet-stream"}))}},r,null,[[8,,9,11],[1,6,7,12]])})),function(r){return c.apply(this,arguments)})},{key:"parseAeaBlob",value:(o=jt(Pt().m(function r(e){var t,n,o,a,i,c;return Pt().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,e.arrayBuffer();case 1:for(t=r.v,n=new Uint8Array(t.slice(0,u)),o=we.parseHeader(n),a=[],i=u;i<t.byteLength;)(c=new Uint8Array(t.slice(i,i+l))).length===l&&a.push(c),i+=l;return r.a(2,{info:o,frameData:a})}},r)})),function(r){return o.apply(this,arguments)})},{key:"deserializedFrameStream",value:Pt().m(function r(e){var t,n,o,a;return Pt().w(function(r){for(;;)switch(r.p=r.n){case 0:t=St(e),r.p=1,t.s();case 2:if((n=t.n()).done){r.n=4;break}return o=n.value,r.n=3,Pe(o);case 3:r.n=2;break;case 4:r.n=6;break;case 5:r.p=5,a=r.v,t.e(a);case 6:return r.p=6,t.f(),r.f(6);case 7:return r.a(2)}},r,null,[[1,5,6,7]])})},{key:"createPcmWaveBlob",value:function(r){var e,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a;if(1===t)e=[ze(r)];else{if(2!==t)throw new Error("Unsupported channel count: ".concat(t));e=[ze(r.map(function(r){return gt(r,1)[0]})),ze(r.map(function(r){return gt(r,2)[1]}))]}return new Blob([_e(e,{sampleRate:n})],{type:"audio/wav"})}},{key:"createWavBlob",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a;return r.createPcmWaveBlob(e,t,n)}},{key:"assemblePcmFrames",value:function(r,e){if(1===e)return ze(r);if(2!==e)throw new Error("Unsupported channel count: ".concat(e));for(var t=ze(r.map(function(r){return gt(r,1)[0]})),n=ze(r.map(function(r){return gt(r,2)[1]})),o=new Float32Array(2*Math.max(t.length,n.length)),a=0;a<o.length/2;a++){var i,u;o[2*a]=null!==(i=t[a])&&void 0!==i?i:0,o[2*a+1]=null!==(u=n[a])&&void 0!==u?u:0}return o}}],t&&Tt(e.prototype,t),n&&Tt(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n,o,c,f}();return e})());
|
|
1
|
+
!function(r,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Carta1=e():r.Carta1=e()}(this,()=>(()=>{"use strict";const r={d:(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var o=t[n++],a=t[n++];r.o(e,o)?0===a&&n++:0===a?Object.defineProperty(e,o,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,o,{enumerable:!0,get:a})}else for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},o:(r,e)=>Object.prototype.hasOwnProperty.call(r,e),r:r=>{Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})}};let e={};function t(r){throw new Error(r)}function n(r){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];var o=t.map(function(e){return e(r)});return function(r){return o.reduce(function(r,e){return e(r)},r)}}r.r(e),r.d(e,{AeaFile:()=>Qe,AudioProcessor:()=>vn,BFU_START_LONG:()=>Y,BufferPool:()=>Ie,EncoderOptions:()=>ce,FFT:()=>Ir,SCALE_FACTORS:()=>or,SPECS_PER_BFU:()=>V,WORD_LENGTH_BITS:()=>nr,decode:()=>Le,decodeAeaPcm:()=>Vt,dequantize:()=>he,deserializeFrame:()=>tt,encode:()=>xe,encodeAeaPcm:()=>Gt,mdctStage:()=>re,pipe:()=>n,qmfAnalysisStage:()=>Mr,quantize:()=>se,serializeFrame:()=>et});var o=2,a=44100,i=512,u=2048,l=212,f=8*l,c=32,s=52,h=20,v=10,y=64,d=256,p=512,m=p,b=32,w=32,g=16,A=2,S=48,k=24,F=48-A,P=24,j=24,O=A*P,M=128,T=128,C=256,B=16,I=4,x=6,E=1,q=15,z=16,D=10,_=4,U=4,H=.4,R=.3,L=1e-6,N=1e-30,G=1e-9,W=new Uint8Array([0,8,0,0]),V=new Int32Array([8,8,8,8,4,4,4,4,8,8,8,8,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,9,9,9,9,10,10,10,10,12,12,12,12,12,12,12,12,20,20,20,20,20,20,20,20]),$=new Int32Array([20,28,32,36,40,44,48,52]),Q=new Int32Array([20,36,52]),Y=new Int32Array([0,8,16,24,32,36,40,44,48,56,64,72,80,86,92,98,104,110,116,122,128,134,140,146,152,159,166,173,180,189,198,207,216,226,236,246,256,268,280,292,304,316,328,340,352,372,392,412,432,452,472,492]),J=new Int32Array([0,32,64,96,8,40,72,104,12,44,76,108,20,52,84,116,26,58,90,122,128,160,192,224,134,166,198,230,141,173,205,237,150,182,214,246,256,288,320,352,384,416,448,480,268,300,332,364,396,428,460,492]),K=function(){for(var r=new Float64Array(32),e=0;e<32;e++)r[e]=Math.sin((e+.5)*Math.PI/64);return r}(),X=new Float32Array([-1461907e-11,-9205479e-11,-56157569e-12,.00030117269,.0002422519,-.00085293897,-.0005205574,.0020340169,.00078333891,-.0042153862,-.00075614988,.0078402944,-61169922e-12,-.01344162,.0024626821,.021736089,-.007801671,-.034090221,.01880949,.054326009,-.043596379,-.099384367,.13207909,.46424159]),Z=function(){for(var r=new Float32Array(48),e=0;e<24;e++)r[e]=2*X[e],r[47-e]=2*X[e];return r}(),rr=function(){for(var r=new Float32Array(24),e=0;e<24;e++)r[e]=Z[2*e];return r}(),er=function(){for(var r=new Float32Array(24),e=0;e<24;e++)r[e]=Z[2*e+1];return r}(),tr=[{size:128,longMdctSize:d,windowStart:48,analysisScale:.5},{size:128,longMdctSize:d,windowStart:48,analysisScale:.5},{size:256,longMdctSize:p,windowStart:112,analysisScale:1}],nr=new Int32Array([0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),or=function(){for(var r=new Float64Array(64),e=0;e<64;e++)r[e]=Math.pow(2,e/3-21);return r}(),ar=new Float64Array([1,.03162277660168379,.001,3162277660168379e-20]),ir=new Float64Array([1,.005011872336272725,19952623149688796e-21]),ur=function(){for(var r=new Int32Array(16),e=1;e<=q;e++){var t=nr[e];r[e]=(1<<t-1)-1}return r}(),lr=function(){for(var r=new Float64Array(16),e=1;e<=q;e++){var t=ur[e];r[e]=2*t/(2*t+1)}return r}(),fr=function(){for(var r=new Float64Array(h+1),e=2;e<=h;e++)r[e]=1/Math.log(e);return r}(),cr=function(){for(var r=new Float64Array(s),e=0;e<s;e++){var t=Y[e]+.5*V[e],n=Math.max(.05,t/512*22.05),o=Math.max(-9,-2.184*Math.pow(n,-.8)+6.5*Math.exp(-.6*(n-3.3)*(n-3.3))-.001*Math.pow(n,3.6));r[e]=Math.pow(10,o/10)}return r}(),sr=function(){for(var r=new Float64Array(s),e=new Int32Array([0,8,12,20,26]),t=new Int32Array([0,6,13,22]),n=new Int32Array([0,12]),o=0;o<s;o++){var a=.05;if(o<20){var i=o>>2;a=Math.max(.05,(e[i]+.5*V[o])/32*5.5125)}else if(o<36){a=5.5125+(t[o-20>>2]+.5*V[o])/32*5.5125}else{a=11.025+(n[o-36>>3]+.5*V[o])/32*11.025}var u=Math.max(-9,-2.184*Math.pow(a,-.8)+6.5*Math.exp(-.6*(a-3.3)*(a-3.3))-.001*Math.pow(a,3.6));r[o]=Math.pow(10,u/10)}return r}();function hr(r,e){return function(r,e){for(var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=t?t.bfuData:[],o=t?t.bfuSizes:[],a=0,i=0,u=0;u<3;u++){for(var l=a,f=2===u?256:128,c=u<2?Q[u]:V.length,s=0===e[u]?Y:J;i<c;){var h=V[i],v=s[i]-l,y=v+h,d=t?n[i]:new Float32Array(h);if(v>=0&&y<=f)for(var p=l+v,m=0;m<h;m++)d[m]=r[p+m];else if(v<f&&y>0){d.fill(0);for(var b=Math.max(0,v),w=Math.min(f,y),g=Math.max(0,-v),A=w-b,S=0;S<A;S++)d[g+S]=r[l+b+S]}else t&&d.fill(0);t||(n.push(d),o.push(h)),i++}a+=f}return{bfuData:n,bfuSizes:o,bfuCount:i}}(r,e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)}function vr(r){return vr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},vr(r)}function yr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function dr(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,mr(n.key),n)}}function pr(r,e,t){return e&&dr(r.prototype,e),t&&dr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function mr(r){var e=function(r,e){if("object"!=vr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=vr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==vr(e)?e:e+""}var br=function(){return pr(function r(){yr(this,r),this.qmfAnalysisDelays={lowBand:new Float32Array(F),midBand:new Float32Array(F)},this.qmfHighBandDelay=new Float32Array(39),this.transientDetection=[new Float32Array(M/2),new Float32Array(T/2),new Float32Array(C/2)],this.mdctOverlap=[new Float32Array(w),new Float32Array(w),new Float32Array(w)]},[{key:"reset",value:function(){this.qmfAnalysisDelays.lowBand.fill(0),this.qmfAnalysisDelays.midBand.fill(0),this.qmfHighBandDelay.fill(0);for(var r=0;r<this.transientDetection.length;r++)this.transientDetection[r].fill(0);for(var e=0;e<this.mdctOverlap.length;e++)this.mdctOverlap[e].fill(0);return this}}])}(),wr=pr(function r(){yr(this,r),this.fft={128:{real:new Float32Array(M),imaginary:new Float32Array(M),magnitudes:new Float32Array(M/2)},256:{real:new Float32Array(C),imaginary:new Float32Array(C),magnitudes:new Float32Array(C/2)}}}),gr=pr(function r(){yr(this,r);for(var e=[],t=[],n=0;n<s;n++){var o=V[n];e.push(new Float32Array(o)),t.push(o)}this.bfuData=e,this.bfuSizes=t,this.energies=new Float64Array(s),this.maxAmplitudes=new Float64Array(s),this.initialScaleFactorIndices=new Int32Array(s),this.maskThresholds=new Float64Array(s),this.perceptualWeights=new Float64Array(s),this.seedThresholds=new Float64Array(s),this.distortionCache=new Float64Array(s*z),this.candidateWordLengths=new Int32Array(s),this.selectedWordLengths=new Int32Array(s),this.refinedScaleFactorIndices=new Int32Array(s)});function Ar(r,e,t,n){if(n<=0){for(var o=0,a=0;a<e;a++){var i=r[a];o+=i*i}return o}for(var u=ur[n],l=or[t],f=u/l,c=1/u,s=0,h=0;h<e;h++){var v=r[h],y=v*f,d=v-(y>=u?u:y<=-u?-u:y+(y>=0?.5:-.5)|0)*l*c;s+=d*d}return s}function Sr(r,e,t,n,o,a,i){var u=r*z+e,l=i[u];if(l>=0)return l;var f=o[r];e>0&&f>0&&or[f-1]>=a[r]*lr[e]&&(f-=1);var c=Ar(t[r],0|n[r],f,e);return i[u]=c,c}var kr=new gr;function Fr(r,e,t,n,o,a,i,u,l,s){var h=f-c-r*v,y=function(r,e,t,n,o,a){for(var i=1e9,u=-1e9,l=0,f=0;f<r;f++){var c=0|t[f];if(n[f]>0&&c>0){var s=o[f];s<i&&(i=s),s>u&&(u=s),l=1}}if(0===l||e<=0){for(var h=0;h<r;h++)a[h]=0;return 0}for(var v=i-16,y=u+2,d=0;d<D;d++){for(var p=.5*(v+y),m=0,b=0;b<r;b++){var w=0|t[b];if(!(n[b]<=0||w<=0)){var g=Math.floor(o[b]-p+.5),A=0;g>=q?A=q:g>0&&(A=0|g),m+=nr[A]*w}}m<=e?y=p:v=p}for(var S=0,k=0;k<r;k++){var F=0|t[k];if(n[k]<=0||F<=0)a[k]=0;else{var P=Math.floor(o[k]-y+.5),j=0;P>=q?j=q:P>0&&(j=0|P),a[k]=j,S+=nr[j]*F}}return S}(r,h,t,a,u,s);y=function(r,e,t,n,o,a,i,u,l,f,c){for(var s=0;s<_;s++){for(var h=-1,v=0,y=0,d=0,p=0;p<r;p++){var m=0|o[p],b=c[p];if(!(u[p]<=0||m<=0||b>=q)){var w=l[p],g=Sr(p,b,n,o,a,i,f),A=b+1;0===b&&(A=3),A>q&&(A=q);for(var S=b+1;S<=A;S++){var k=(nr[S]-nr[b])*m;if(!(k<=0||k>e)){var F=(g-Sr(p,S,n,o,a,i,f))*w/k;F>d&&(d=F,h=p,v=S,y=k)}}}}if(h<0)break;if(t+y<=e)c[h]=v,t+=y;else{for(var P=-1,j=0,O=1e300,M=0;M<r;M++)if(M!==h){var T=c[M],C=0|o[M];if(!(T<=0||C<=0)){var B=(nr[T]-nr[T-1])*C;if(!(B<=0||t-B+y>e)){var I=Sr(M,T,n,o,a,i,f),x=(Sr(M,T-1,n,o,a,i,f)-I)*l[M]/B;x<O&&(O=x,P=M,j=B)}}}if(!(P>=0&&d>1.02*O))break;c[P]=c[P]-1,c[h]=v,t=t-j+y}}return t}(r,h,y,e,t,n,o,a,i,l,s),function(r,e,t,n,o,a,i,u,l,f){for(;e>=U;){for(var c=-1,s=0,h=0,v=0,y=0;y<r;y++){var d=0|n[y],p=f[y];if(!(i[y]<=0||d<=0||p>=q)){var m=Sr(y,p,t,n,o,a,l),b=u[y],w=p+1;0===p&&(w=3),w>q&&(w=q);for(var g=p+1;g<=w;g++){var A=(nr[g]-nr[p])*d;if(!(A<=0||A>e)){var S=(m-Sr(y,g,t,n,o,a,l))*b;if(S>0){var k=S/A;k>v&&(v=k,c=y,s=g,h=A)}}}}}if(c<0)break;f[c]=s,e-=h}}(r,h-y,e,t,n,o,a,i,l,s)}function Pr(r,e,t,n){for(var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,i=null!=a?a:kr,u=i.energies,l=i.maxAmplitudes,f=i.initialScaleFactorIndices,c=i.maskThresholds,s=i.perceptualWeights,v=i.seedThresholds,y=i.distortionCache,d=i.candidateWordLengths,p=i.selectedWordLengths,m=i.refinedScaleFactorIndices,b=0,w=0;w<t;w++){var g=0|e[w];if(g<=0)u[w]=0,l[w]=0,f[w]=0;else{for(var A=r[w],S=0,k=0,F=0;F<g;F++){var P=A[F];S+=P*P;var j=P<0?-P:P;j>k&&(k=j)}if(u[w]=S,l[w]=k,b+=S,0===k)f[w]=0;else{var O=0|Math.ceil(3*(Math.log2(k)+21));f[w]=O<0?0:O>63?63:O}}}for(var M=t*z,T=0;T<M;T++)y[T]=-1;var C=t,B=$[0];B<C&&(C=B);for(var I=1;I<$.length;I++){var x=$[I];x<=t&&(C=x)}if(0===b||C<=0)return{bfuCount:C,allocation:new Int32Array(C),scaleFactorIndices:new Int32Array(t)};var E=0,q=0,D=0;o&&(E=0|o[0],q=0|o[1],D=0|o[2]),function(r,e,t,n,o,a,i,u,l){for(var f=0;f<n;f++)l[f]=0;for(var c=ir.length-1,s=ar.length,v=0;v<n;v++){var y=r[v];if(!(y<=0)){var d=0|t[v];if(!(d<=0)){var p=e[v],m=p*p*d/y,b=m<1?1:m,w=0;w=d<=h?fr[d]:1/Math.log(d);var g=d>1?Math.min(1,Math.log(b)*w):0,A=!1,S=v;v<20?(A=0!==a)&&(S=4*(v>>2)):v<36?(A=0!==i)&&(S=20+4*(v-20>>2)):(A=0!==u)&&(S=36+8*(v-36>>3));var k=g*(14.5+.3*S)+5.5*(1-g),F=y*Math.pow(10,.1*-k);if(!(F<=0))if(A){var P=0,j=2,O=0,M=0,T=5;v<20?(P=0,j=2,O=3&v,M=v>>2,T=5):v<36?(P=20,j=2,O=v-20&3,M=v-20>>2,T=4):(P=36,j=3,O=v-36&7,M=v-36>>3,T=2);for(var C=1;C<=c;C++){var B=M-C;if(B>=0){var I=P+(B<<j)+O;I<n&&(l[I]=l[I]+F*ir[C])}}for(var x=0;x<s;x++){var E=M+x;if(E<T){var q=P+(E<<j)+O;q<n&&(l[q]=l[q]+F*ar[x])}}}else{var z=0;v>=36?z=0!==i?36:0:v>=20&&(z=0!==a?20:0);var D=n;v<20?0!==i&&20<n&&(D=20):v<36&&0!==u&&36<n&&(D=36);for(var _=v-c,U=_>z?_:z;U<v;U++)l[U]=l[U]+F*ir[v-U];for(var H=v+s,R=H<D?H:D,G=v;G<R;G++)l[G]=l[G]+F*ar[G-v]}}}}for(var W=o/n*L+N,V=0;V<n;V++)l[V]=l[V]+W}(u,l,e,t,b,E,q,D,c),function(r,e,t,n,o,a,i,u,l,f,c,s){for(var h=.5*(a-1),v=0;v<o;v++){var y=r[v],d=0|n[v];if(y<=0||d<=0)c[v]=0,s[v]=-1e9;else{var p=v<20?0!==i:v<36?0!==u:0!==l,m=cr[v],b=H;p&&(m=sr[v],b=R);var w=f[v]+G/Math.max(m,1e-6),g=m/Math.pow(w,b);if(0!==h){var A=t[v],S=or[A];0===A&&(S=Math.max(e[v],1e-12)),g*=Math.pow(S*S,h)}c[v]=g;var k=e[v],F=y/d*.5+.5*k*k;s[v]=.5*Math.log2(F*g)}}}(u,l,f,e,t,n,E,q,D,c,s,v),Fr(C,r,e,f,l,u,s,v,y,d);for(var _=0,U=C-1;U>=0;U--)if(d[U]>0){_=U+1;break}for(var W=C,V=0;V<$.length;V++){var Q=$[V];if(Q<=C&&Q>=_){W=Q;break}}W<C&&Fr(W,r,e,f,l,u,s,v,y,d);for(var Y=0;Y<W;Y++)p[Y]=d[Y];return function(r,e,t,n,o,a,i,u){for(var l=0;l<e;l++)u[l]=a[l];for(var f=0;f<r;f++){var c=i[f],s=a[f],h=0|n[f];if(!(c<=0||s<=0||h<=0||o[f]<=0)){var v=t[f],y=s,d=Ar(v,h,s,c),p=0;s>2&&(p=s-2);for(var m=p;m<s;m++){var b=Ar(v,h,m,c);b<d&&(d=b,y=m)}u[f]=y}}}(W,t,r,e,u,f,p,m),{bfuCount:W,allocation:p.slice(0,W),scaleFactorIndices:m.slice(0,t)}}function jr(r){var e,n,o,a=null!==(e=null==r?void 0:r.options)&&void 0!==e?e:t("allocate: options is required"),i=null!==(n=null==r||null===(o=r.bufferPool)||void 0===o||null===(o=o.encoder)||void 0===o||null===(o=o.scratch)||void 0===o?void 0:o.allocation)&&void 0!==n?n:null;return function(r){var e=r.coefficients,t=r.blockModes,n=hr(e,t,i),o=n.bfuData,u=n.bfuSizes,l=Pr(o,u,n.bfuCount,a.allocationBias,t,i),f=l.bfuCount;return{bfuData:o,bfuSizes:u,nBfu:f,scaleFactorIndices:l.scaleFactorIndices.slice(0,f),wordLengthIndices:l.allocation,blockModes:t}}}function Or(r,e,n){var o,a=null!==(o=n.analysisWindows[r.length])&&void 0!==o?o:t("QMF analysis window for ".concat(r.length," samples is required"));a.set(e),a.set(r,e.length);var i=r.length/2,u=[new Float32Array(i),new Float32Array(i)];return function(r,e,t){var n,o,a;if(!(r instanceof Float32Array)||(null==e?void 0:e.length)!==A||e.some(function(r){return!(r instanceof Float32Array)||r.length!==e[0].length})||!t||(null===(n=t.polyphase)||void 0===n?void 0:n.length)!==A||(null===(o=t.extended)||void 0===o?void 0:o.length)!==A||(null===(a=t.bands)||void 0===a?void 0:a.length)!==A)throw new RangeError("QMF analysis geometry is invalid");var i=e[0].length,u=Math.max(0,i-1)*A+S;if(r.length<u)throw new RangeError("QMF analysis window is incomplete");for(var l=0;l<i;l++){for(var f=2*l,c=0,s=0,h=0;h<k;h++)c+=r[f+47-2*h]*rr[h],s+=r[f+46-2*h]*er[h];e[0][l]=c+s,e[1][l]=c-s}}(a,u,n),e.set(a.subarray(r.length,r.length+F)),u}function Mr(r){var e,n=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:t("analyzeBands: bufferPool is required"),o=n.encoder.state,a=o.qmfAnalysisDelays,i=n.encoder.scratch.qmf;return function(r){var e=Or(r,a.lowBand,i),t=Or(e[0],a.midBand,i),n=i.highBandWindows[e[1].length];n.set(o.qmfHighBandDelay),n.set(e[1],o.qmfHighBandDelay.length);var u=n.slice(0,e[1].length);return o.qmfHighBandDelay.set(n.subarray(e[1].length,e[1].length+o.qmfHighBandDelay.length)),{bands:[t[0],t[1],u]}}}function Tr(r){return Tr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Tr(r)}function Cr(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,Br(n.key),n)}}function Br(r){var e=function(r,e){if("object"!=Tr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Tr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Tr(e)?e:e+""}var Ir=function(){return r=function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r)},t=[{key:"transform",value:function(r,e){var t=r.length;if(1!==t){for(var n=Math.log2(t),o=0;o<t;o++){for(var a=0,i=o,u=0;u<n;u++)a=a<<1|1&i,i>>=1;if(a>o){var l=r[o];r[o]=r[a],r[a]=l;var f=e[o];e[o]=e[a],e[a]=f}}for(var c=2;c<=t;c<<=1)for(var s=c>>1,h=-2*Math.PI/c,v=Math.cos(h),y=Math.sin(h),d=0;d<t;d+=c)for(var p=1,m=0,b=0;b<s;b++){var w=d+b,g=w+s,A=r[w],S=e[w],k=r[g],F=e[g],P=k*p-F*m,j=k*m+F*p;r[w]=A+P,e[w]=S+j,r[g]=A-P,e[g]=S-j;var O=p*v-m*y;m=p*y+m*v,p=O}}}}],(e=null)&&Cr(r.prototype,e),t&&Cr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function xr(r,e){var t=function(r,e){for(var t=0,n=0,o=0;o<r.length;o++){var a=Math.abs(r[o]),i=a-Math.abs(e[o]);i>0&&(t+=i),n+=a*a}var u=Math.sqrt(n)||1e-6;return t/u}(r,e),n=Er(r),o=Er(e),a=Math.abs(n-o),i=qr(r),u=qr(e),l=Math.abs(i-u),f=function(r,e){for(var t=0,n=0,o=0;o<r.length;o++)t+=r[o]*r[o],n+=e[o]*e[o];t=Math.max(t,1e-10),n=Math.max(n,1e-10);var a=10*Math.log10(t/n);return Math.max(0,a)}(r,e);return{spectralFlux:t,flatnessChange:a,hfChange:l,energyChange:f}}function Er(r){for(var e=0,t=0,n=0,o=0;o<r.length;o++){var a=Math.abs(r[o]);a>1e-10&&(e+=Math.log(a),t+=a,n++)}if(0===n)return 0;var i=Math.exp(e/n),u=t/n;return u>1e-10?i/u:0}function qr(r){for(var e=Math.floor(r.length/2),t=0,n=0,o=0;o<e;o++)t+=r[o]*r[o];for(var a=e;a<r.length;a++)n+=r[a]*r[a];var i=t+n;return i>0?n/i:0}function zr(r,e,t){if(!e)return!1;var n=function(r){var e=r.spectralFlux,t=r.flatnessChange,n=r.hfChange,o=r.energyChange;return(e+Math.sqrt(t)+Math.log1p(10*n)/Math.log1p(10)+Math.min(o/30,1))/4}(xr(r,e));return n>t}function Dr(r){var e,n,o=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:t("selectBlocks: bufferPool is required"),a=null!==(n=null==r?void 0:r.options)&&void 0!==n?n:t("selectBlocks: options is required"),i=o.encoder.state,u=o.encoder.scratch.transient,l=[M,T,C];return function(r){var e,t=r.bands;if(a.fixedBlockModes)e=a.fixedBlockModes;else{var n=[a.transientThresholdLow,a.transientThresholdMid,a.transientThresholdHigh];e=t.map(function(r,e){var t=function(r,e){var t,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=null==n||null===(t=n.fft)||void 0===t?void 0:t[e],a=o?o.real:new Float32Array(e),i=o?o.imaginary:new Float32Array(e);o&&(a.fill(0),i.fill(0));var u=Math.min(r.length,e);a.set(r.subarray(0,u)),Ir.transform(a,i);for(var l=o?o.magnitudes:new Float32Array(e/2),f=0;f<e/2;f++)l[f]=Math.sqrt(a[f]*a[f]+i[f]*i[f]);return l}(r,l[e],u),o=zr(t,i.transientDetection[e],n[e]);return i.transientDetection[e].set(t),o*Math.max(e+1,2)})}return{bands:t,blockModes:e}}}function _r(r){return _r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},_r(r)}function Ur(r,e,t){return e=Rr(e),function(r,e){if(e&&("object"==_r(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(r){if(void 0===r)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}(r)}(r,Hr()?Reflect.construct(e,t||[],Rr(r).constructor):e.apply(r,t))}function Hr(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(r){}return(Hr=function(){return!!r})()}function Rr(r){return Rr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Rr(r)}function Lr(r,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&Nr(r,e)}function Nr(r,e){return Nr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},Nr(r,e)}function Gr(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,Vr(n.key),n)}}function Wr(r,e,t){return e&&Gr(r.prototype,e),t&&Gr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function Vr(r){var e=function(r,e){if("object"!=_r(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=_r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==_r(e)?e:e+""}function $r(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var Qr=Wr(function r(e,t){$r(this,r),this.size=e,this.halfSize=e>>1,this.quarterSize=e>>2,this.fftSize=this.halfSize>>1;var n=2*Math.PI/(8*e),o=2*Math.PI/e,a=Math.sqrt(t/e);this.sinCosTable=new Float64Array(this.halfSize);for(var i=0;i<this.quarterSize;i++){var u=o*i+n;this.sinCosTable[2*i]=a*Math.cos(u),this.sinCosTable[2*i+1]=a*Math.sin(u)}}),Yr=function(r){function e(r,t){return $r(this,e),Ur(this,e,[r,t])}return Lr(e,r),Wr(e,[{key:"transform",value:function(r){var e,n,o,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,l=this.halfSize,f=this.quarterSize,c=this.fftSize,s=this.sinCosTable,h=null!==(e=null==a?void 0:a[c])&&void 0!==e?e:t("MDCT.transform: mdctBuffers[".concat(c,"] is required")),v=null!==(n=null==h?void 0:h.real)&&void 0!==n?n:t("MDCT.transform: mdctBuffers[".concat(c,"].real is required")),y=null!==(o=null==h?void 0:h.imaginary)&&void 0!==o?o:t("MDCT.transform: mdctBuffers[".concat(c,"].imaginary is required")),d=f,p=3*d;v.fill(0),y.fill(0);for(var m=0;m<d;m+=2){var b=p+m,w=d+m,g=d-1-m,A=r[p-1-m]+r[b],S=r[w]-r[g],k=s[m],F=s[m+1];v[m>>1]=A*k+S*F,y[m>>1]=S*k-A*F}for(var P=d;P<l;P+=2){var j=P>>1,O=P-d,M=d+P,T=5*d-1-P,C=r[p-1-P]-r[O],B=r[M]+r[T],I=s[P],x=s[P+1];v[j]=C*I+B*x,y[j]=B*I-C*x}Ir.transform(v,y);for(var E=null!=i?i:new Float32Array(l),q=0;q<c;q++){var z=s[2*q],D=s[2*q+1],_=v[q],U=y[q];E[u+2*q]=-_*z-U*D,E[u+l-1-2*q]=-_*D+U*z}return E}}])}(Qr),Jr=function(r){function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return $r(this,e),Ur(this,e,[r,t||r])}return Lr(e,r),Wr(e,[{key:"transform",value:function(r){var e,n,o,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,l=this.size,f=this.halfSize,c=this.quarterSize,s=this.fftSize,h=this.sinCosTable,v=null!==(e=null==a?void 0:a[s])&&void 0!==e?e:t("IMDCT.transform: mdctBuffers[".concat(s,"] is required")),y=null!==(n=null==v?void 0:v.real)&&void 0!==n?n:t("IMDCT.transform: mdctBuffers[".concat(s,"].real is required")),d=null!==(o=null==v?void 0:v.imaginary)&&void 0!==o?o:t("IMDCT.transform: mdctBuffers[".concat(s,"].imaginary is required")),p=c,m=3*p;y.fill(0),d.fill(0);for(var b=0;b<s;b++){var w=2*b,g=-r[w],A=-r[f-1-w],S=h[w],k=h[w+1];y[b]=A*k+g*S,d[b]=A*S-g*k}Ir.transform(y,d);for(var F=null!=i?i:new Float32Array(l),P=0;P<s/2;P++){var j=2*P,O=h[j],M=h[j+1],T=y[P],C=d[P],B=T*O+C*M,I=T*M-C*O;F[u+m-1-j]=B,F[u+m+j]=B,F[u+p+j]=I,F[u+p-1-j]=-I}for(var x=s/2;x<s;x++){var E=2*(x-s/2)+p,q=2*x,z=h[q],D=h[q+1],_=y[x],U=d[x],H=_*z+U*D,R=_*D-U*z;F[u+m-1-E]=H,F[u+E-p]=-H,F[u+p+E]=R,F[u+5*p-1-E]=R}return F}}])}(Qr);function Kr(r,e){for(var t=e[r.length],n=0;n<r.length;n++)t[n]=r[r.length-1-n];return t}var Xr=tr.map(function(r){var e=r.analysisScale;return new Yr(y,e)}),Zr=tr.map(function(r){var e=r.longMdctSize,t=r.analysisScale;return new Yr(e,t)});function re(r){var e,n=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:t("transformSpectrum: bufferPool is required"),o=n.encoder.state,a=n.encoder.scratch.mdct,i=o.mdctOverlap;function u(r,e,t,n){var o=tr[e];return 0===t?function(r,e,t,n,o){var i=a.transformBuffers[n.size];i.fill(0),i.set(o,t.windowStart),l(r,o,t.size),i.set(r,t.windowStart+w);var u=n.transform(i,a.fftBuffers);e>0&&(u=Kr(u,a.reversalBuffers));return u}(r,e,o,Zr[e],n):function(r,e,t,n){for(var o=1<<(256===t.size?3:2),i=new Float32Array(t.size),u=0;u<o;u++){var f=u*b,c=r.subarray(f,f+b),s=a.transformBuffers[y];s.fill(0),s.set(n,0),l(c,n,b),s.set(c,w);var h=Xr[e].transform(s,a.fftBuffers);e>0&&(h=Kr(h,a.reversalBuffers)),i.set(h,f)}return i}(r,e,o,n)}function l(r,e,t){for(var n=t-w,o=0;o<w;o++){var a=r[n+o];e[o]=K[o]*a,r[n+o]=a*K[31-o]}}return function(r){var e=r.bands,t=r.blockModes,n=r.originalFrame,o=new Float32Array(512);return e.forEach(function(r,e){var n=u(r,e,t[e],i[e]);o.set(n,function(r){return 0===r?0:1===r?128:256}(e))}),{bands:e,coefficients:o,blockModes:t,originalFrame:n}}}function ee(r){var e=n(r,Mr,Dr,re);return function(r){var t=e(r);return{coefficients:t.coefficients,blockModes:t.blockModes}}}function te(r){return te="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},te(r)}function ne(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable})),t.push.apply(t,n)}return t}function oe(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?ne(Object(t),!0).forEach(function(e){ae(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ne(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}function ae(r,e,t){return(e=fe(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function ie(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a,i,u=[],l=!0,f=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;l=!1}else for(;!(l=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(r){f=!0,o=r}finally{try{if(!l&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(f)throw o}}return u}}(r,e)||function(r,e){if(r){if("string"==typeof r)return ue(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ue(r,e):void 0}}(r,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.")}()}function ue(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function le(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,fe(n.key),n)}}function fe(r){var e=function(r,e){if("object"!=te(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=te(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==te(e)?e:e+""}var ce=function(){return r=function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),this.values={transientThresholdLow:1,transientThresholdMid:1.5,transientThresholdHigh:2,allocationBias:1,fixedBlockModes:null},this.metadata={transientThresholdLow:{default:this.values.transientThresholdLow,name:"Low Band Transient Threshold",description:"Controls the transient detection threshold for the low frequency band (0-5.5kHz). Lower values make detection more sensitive, triggering short blocks more easily. Higher values require stronger transients.",range:[.01,2],step:.01},transientThresholdMid:{default:this.values.transientThresholdMid,name:"Mid Band Transient Threshold",description:"Controls the transient detection threshold for the mid frequency band (5.5-11kHz). Lower values make detection more sensitive, triggering short blocks more easily. Higher values require stronger transients.",range:[.01,3],step:.01},transientThresholdHigh:{default:this.values.transientThresholdHigh,name:"High Band Transient Threshold",description:"Controls the transient detection threshold for the high frequency band (11-22kHz). Lower values make detection more sensitive, triggering short blocks more easily. Higher values require stronger transients.",range:[.01,4],step:.01},allocationBias:{default:this.values.allocationBias,name:"Bit allocation bias",description:"Controls how bits are distributed across the frequency spectrum during allocation. Higher values focus more bits on loud spectral components, while lower values spread bits more evenly across frequencies.",range:[0,5],step:.01},fixedBlockModes:{default:this.values.fixedBlockModes,name:"Fixed block modes",description:"Override transient detection and use fixed block modes. Format: [low, mid, high] where low/mid can be 0 or 2, high can be 0 or 3. When set, transient detection is skipped.",type:"array"}},e&&this.setOptions(e)},(e=[{key:"setOptions",value:function(r){for(var e=0,t=Object.entries(r);e<t.length;e++){var n=ie(t[e],2),o=n[0],a=n[1];o in this.values&&this.setValue(o,a)}}},{key:"setValue",value:function(r,e){if(!(r in this.metadata))throw new Error("Unknown option: ".concat(r));var t=this.metadata[r];if("array"!==t.type){var n=ie(t.range,2),o=n[0],a=n[1];if(e<o||e>a)throw new Error("Value for ".concat(r," must be between ").concat(o," and ").concat(a,", got ").concat(e))}this.values[r]=e}},{key:"getValue",value:function(r){if(!(r in this.values))throw new Error("Unknown option: ".concat(r));return this.values[r]}},{key:"transientThresholdLow",get:function(){return this.values.transientThresholdLow}},{key:"transientThresholdMid",get:function(){return this.values.transientThresholdMid}},{key:"transientThresholdHigh",get:function(){return this.values.transientThresholdHigh}},{key:"allocationBias",get:function(){return this.values.allocationBias}},{key:"fixedBlockModes",get:function(){return this.values.fixedBlockModes}},{key:"getMetadata",value:function(r){return this.metadata[r]}},{key:"getAllMetadata",value:function(){return oe({},this.metadata)}},{key:"reset",value:function(){for(var r=0,e=Object.entries(this.metadata);r<e.length;r++){var t=ie(e[r],2),n=t[0],o=t[1];this.values[n]=o.default}}},{key:"toObject",value:function(){return{values:oe({},this.values),metadata:oe({},this.metadata)}}}])&&le(r.prototype,e),t&&le(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function se(r,e,t){var n=r.length,o=new Int32Array(n);if(0===t)return o.fill(0,0,n),o;for(var a=or[e],i=(1<<t-E)-1,u=i/a,l=i,f=-i,c=0;c<n;c++){var s=r[c]*u,h=s+(s>=0?.5:-.5)|0;o[c]=h>l?l:h<f?f:h}return o}function he(r,e,t){if(0===t)return new Float32Array(r.length);for(var n=or[e],o=(1<<t-E)-1,a=new Float32Array(r.length),i=0;i<r.length;i++)a[i]=r[i]*n/o;return a}function ve(){return function(r){for(var e=r.bfuData,t=r.bfuSizes,n=r.nBfu,o=r.scaleFactorIndices,a=r.wordLengthIndices,i=r.blockModes,u=[],l=0;l<n;l++){var f=e[l].subarray(0,t[l]),c=nr[a[l]];u.push(se(f,o[l],c))}return{nBfu:n,scaleFactorIndices:o,wordLengthIndices:a,quantizedCoefficients:u,blockModes:i}}}function ye(r){return ye="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ye(r)}function de(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function pe(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,be(n.key),n)}}function me(r,e,t){return e&&pe(r.prototype,e),t&&pe(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function be(r){var e=function(r,e){if("object"!=ye(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=ye(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==ye(e)?e:e+""}var we=function(){return me(function r(){de(this,r),this.delay=new Float32Array(O),this.delayRow=0},[{key:"reset",value:function(){return this.delay.fill(0),this.delayRow=0,this}}])}(),ge=function(){return me(function r(){de(this,r),this.qmfSynthesisStates={lowBand:new we,midBand:new we},this.qmfHighBandDelay=new Float32Array(39),this.imdctOverlap=[new Float32Array(d),new Float32Array(d),new Float32Array(p)]},[{key:"reset",value:function(){this.qmfSynthesisStates.lowBand.reset(),this.qmfSynthesisStates.midBand.reset(),this.qmfHighBandDelay.fill(0);for(var r=0;r<this.imdctOverlap.length;r++)this.imdctOverlap[r].fill(0);return this}}])}();function Ae(r){return Ae="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ae(r)}function Se(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,Fe(n.key),n)}}function ke(r,e,t){return e&&Se(r.prototype,e),t&&Se(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function Fe(r){var e=function(r,e){if("object"!=Ae(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Ae(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Ae(e)?e:e+""}function Pe(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var je=ke(function r(){Pe(this,r),this.analysisWindows={128:new Float32Array(F+128),256:new Float32Array(F+256),512:new Float32Array(F+512)},this.highBandWindows={128:new Float32Array(167),256:new Float32Array(295)},this.polyphase=new Float32Array(A),this.extended=new Float64Array(A),this.bands=new Float32Array(A)}),Oe=ke(function r(){Pe(this,r),this.transformBuffers={64:new Float32Array(y),128:new Float32Array(128),256:new Float32Array(d),512:new Float32Array(p)},this.fftBuffers={16:{real:new Float32Array(16),imaginary:new Float32Array(16)},64:{real:new Float32Array(64),imaginary:new Float32Array(64)},128:{real:new Float32Array(128),imaginary:new Float32Array(128)}},this.reversalBuffers={32:new Float32Array(32),128:new Float32Array(128),256:new Float32Array(256)}});function Me(r){return Me="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Me(r)}function Te(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,Be(n.key),n)}}function Ce(r,e,t){return e&&Te(r.prototype,e),t&&Te(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function Be(r){var e=function(r,e){if("object"!=Me(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Me(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Me(e)?e:e+""}var Ie=Ce(function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),this.encoder={state:new br,scratch:{qmf:new je,transient:new wr,mdct:new Oe,allocation:new gr}},this.decoder={state:new ge,scratch:{mdct:new Oe,qmf:new je}}});function xe(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ce,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Ie;return e.encoder.state.reset(),n({options:r,bufferPool:e},ee,jr,ve)}function Ee(){return function(r){for(var e=new Float32Array(512),t=r.nBfu,n=r.scaleFactorIndices,o=r.wordLengthIndices,a=r.quantizedCoefficients,i=r.blockModes,u=0;u<t;u++){var l=nr[o[u]],f=0;u>=Q[0]&&(f=1),u>=Q[1]&&(f=2);var c=0===i[f]?Y[u]:J[u];if(l>0){var s=he(a[u],n[u],l);e.set(s,c)}}return{coefficients:e,blockModes:i}}}var qe=new Jr(y,y),ze=tr.map(function(r){var e=r.longMdctSize;return new Jr(e,e)});function De(r,e,t){for(var n=r.length,o=new Float32Array(2*n),a=0;a<n;a++){var i=t[a],u=t[2*n-1-a],l=r[a],f=e[n-1-a];o[a]=l*u-f*i,o[2*n-1-a]=l*i+f*u}return o}function _e(r){var e,n=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:t("synthesizeSpectrum: bufferPool is required"),o=n.decoder.state,a=n.decoder.scratch.mdct,i=o.imdctOverlap;function u(r,e,t,n,o){return 0===t?function(r,e,t,n,o){var i=r;e>0&&(i=Kr(r,a.reversalBuffers));var u=o.transform(i,a.fftBuffers),l=u.length/4,f=a.transformBuffers[m];f.fill(0);for(var c=0;c<n.size;c++)f[c]=u[l+c];var s=t.slice(2*n.size-g,2*n.size),h=De(s.slice(0,g),f.slice(0,g),K);t.set(h,0);for(var v=0;v<g;v++)s[v]=f[g+v];for(var y=2===e?240:112,d=0;d<y;d++)t[32+d]=f[g+d];for(var p=0;p<g;p++)t[2*n.size-g+p]=f[n.size-g+p];return t.slice(0,n.size)}(r,e,n,o,ze[e]):function(r,e,t,n){var o=1<<(256===n.size?3:2),i=a.transformBuffers[m];i.fill(0);for(var u=t.slice(2*n.size-g,2*n.size),l=0,f=0,c=0;c<o;c++){var s=r.slice(f,f+b);e>0&&(s=Kr(s,a.reversalBuffers));for(var h=qe.transform(s,a.fftBuffers),v=h.length/4,y=0;y<b;y++)i[l+y]=h[v+y];var d=De(u.slice(0,g),i.slice(l,l+g),K);t.set(d,l);for(var p=0;p<g;p++)u[p]=i[l+g+p];l+=b,f+=b}for(var w=0;w<g;w++)t[2*n.size-g+w]=i[n.size-g+w];return t.slice(0,n.size)}(r,e,n,o)}return function(r){var e=r.coefficients,t=r.blockModes;return tr.map(function(r,n){var o=function(r,e){var t=[0,128,256,512];return r.subarray(t[e],t[e+1])}(e,n);return u(o,n,t[n],i[n],r)})}}function Ue(r,e,t){var n=new Float32Array(2*r[0].length);return e.delayRow=function(r,e,t,n,o){var a,i;if((null==r?void 0:r.length)!==A||r.some(function(e){return!(e instanceof Float32Array)||e.length!==r[0].length})||!(e instanceof Float32Array)||e.length!==P*A||!Number.isInteger(t)||t<0||t>=P||!(n instanceof Float32Array)||n.length<r[0].length*A||!o||(null===(a=o.polyphase)||void 0===a?void 0:a.length)!==A||(null===(i=o.bands)||void 0===i?void 0:i.length)!==A)throw new RangeError("QMF synthesis geometry is invalid");for(var u=0;u<r[0].length;u++){var l=r[0][u],f=r[1][u];e[2*t]=l+f,e[2*t+1]=l-f;for(var c=0,s=0,h=0;h<j;h++){var v=(t+P-1-h)%P;c+=e[2*v+1]*er[h],s+=e[2*v]*rr[h]}n[2*u]=c,n[2*u+1]=s,t=0===t?P-1:t-1}return t}(r,e.delay,e.delayRow,n,t),n}function He(r){var e,n=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:t("synthesizePcm: bufferPool is required"),a=n.decoder.state,i=a.qmfSynthesisStates,u=n.decoder.scratch.qmf;return function(r){var e=u.highBandWindows[r[2].length];e.set(a.qmfHighBandDelay),e.set(r[2],a.qmfHighBandDelay.length);var t=e.slice(0,2*r[0].length);a.qmfHighBandDelay.set(e.subarray(2*r[0].length,2*r[0].length+a.qmfHighBandDelay.length));for(var n=Ue([r[0],r[1]],i.midBand,u),l=Ue([n,t],i.lowBand,u),f=0;f<l.length;f++)l[f]*=o;return l}}function Re(r){return n(r,_e,He)}function Le(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Ie;return r.decoder.state.reset(),n({bufferPool:r},Ee,Re)}function Ne(r){return Ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ne(r)}function Ge(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,We(n.key),n)}}function We(r){var e=function(r,e){if("object"!=Ne(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Ne(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Ne(e)?e:e+""}var Ve=new TextEncoder,$e=new TextDecoder;var Qe=function(){return r=function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r)},t=[{key:"createHeader",value:function(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:266,a=new Uint8Array(u),i=new DataView(a.buffer);return a.set(W,0),Ve.encodeInto(r,a.subarray(4,259)),i.setUint32(260,e,!0),a[264]=t,i.setUint32(268,o>>>0,!0),i.setUint32(272,n>>>0,!0),a}},{key:"parseHeader",value:function(r){if(r.length!==u)throw new Error("Header must be ".concat(u," bytes"));for(var e=0;e<W.length;e++)if(r[e]!==W[e])throw new Error("Invalid AEA file");var t=new DataView(r.buffer,r.byteOffset,r.byteLength),n=r.indexOf(0,4),o=-1===n?256:n-4;return{title:$e.decode(r.subarray(4,4+o)),frameCount:t.getUint32(260,!0),channelCount:r[264],primingSampleCount:t.getUint32(268,!0),sampleCount:t.getUint32(272,!0)}}}],(e=null)&&Ge(r.prototype,e),t&&Ge(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function Ye(r){if(!Number.isInteger(r)||r<0||r>32)throw new RangeError("Bit count must be an integer in 0..32, got ".concat(r))}function Je(r,e,t,n){if(Ye(n),0!==n)for(var o=Math.floor(e/8),a=e%8,i=0|Number(t),u=0;u<n&&o<r.length;){var l=8-a,f=Math.min(n-u,l),c=i>>>n-u-f&Math.pow(2,f)-1,s=Math.pow(2,f)-1<<l-f;r[o]=r[o]&~s|c<<l-f,u+=f,o++,a=0}}function Ke(r,e,t){if(Ye(t),0===t)return 0;for(var n=Math.floor(e/8),o=e%8,a=0,i=0;i<t&&n<r.length;){var u=8-o,l=Math.min(t-i,u),f=Math.pow(2,l)-1,c=r[n]>>u-l&f;a=a*Math.pow(2,l)+c>>>0,i+=l,n++,o=0}return a}function Xe(r,e,t){if(Ye(t),0===t)return 0;var n=Ke(r,e,t);return n>=Math.pow(2,t-1)?n-Math.pow(2,t):n}function Ze(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=function(r,e){if(r){if("string"==typeof r)return rt(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?rt(r,e):void 0}}(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,o=function(){};return{s:o,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(r){throw r},f:o}}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 a,i=!0,u=!1;return{s:function(){t=t.call(r)},n:function(){var r=t.next();return i=r.done,r},e:function(r){u=!0,a=r},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function rt(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function et(r){var e=new Uint8Array(l),t=new DataView(e.buffer),n=$.indexOf(r.nBfu),o=2-r.blockModes[0]<<14|2-r.blockModes[1]<<12|3-r.blockModes[2]<<10|n<<5;t.setUint16(0,o,!1);for(var a=B,i=0;i<r.nBfu;i++)Je(e,a,r.wordLengthIndices[i],I),a+=I;for(var u=0;u<r.nBfu;u++)Je(e,a,r.scaleFactorIndices[u],x),a+=x;for(var f=0;f<r.nBfu;f++){var c=nr[r.wordLengthIndices[f]];if(c>0){var s,h=Ze(r.quantizedCoefficients[f]);try{for(h.s();!(s=h.n()).done;){var v=s.value;Je(e,a,v<0?v+(1<<c):v,c),a+=c}}catch(r){h.e(r)}finally{h.f()}}}return e[l-2]=e[0],e[l-1]=e[1],e}function tt(r){if(r.length!==l)throw new Error("Frame must be ".concat(l," bytes"));for(var e=new DataView(r.buffer,r.byteOffset,r.byteLength).getUint16(0,!1),t=[2-(e>>14&3),2-(e>>12&3),3-(e>>10&3)],n=$[e>>5&7],o=B,a=new Int32Array(n),i=0;i<n;i++)a[i]=Ke(r,o,I),o+=I;for(var u=new Int32Array(n),f=0;f<n;f++)u[f]=Ke(r,o,x),o+=x;for(var c=[],s=0;s<n;s++){var h=nr[a[s]],v=V[s],y=new Int32Array(v);if(h>0)for(var d=0;d<v;d++)y[d]=Xe(r,o,h),o+=h;c.push(y)}return{nBfu:n,scaleFactorIndices:u,wordLengthIndices:a,quantizedCoefficients:c,blockModes:t}}function nt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var r,e,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function a(t,n,o,a){var l=n&&n.prototype instanceof u?n:u,f=Object.create(l.prototype);return ot(f,"_invoke",function(t,n,o){var a,u,l,f=0,c=o||[],s=!1,h={p:0,n:0,v:r,a:v,f:v.bind(r,4),d:function(e,t){return a=e,u=0,l=r,h.n=t,i}};function v(t,n){for(u=t,l=n,e=0;!s&&f&&!o&&e<c.length;e++){var o,a=c[e],v=h.p,y=a[2];t>3?(o=y===n)&&(l=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):a[0]<=v&&((o=t<2&&v<a[1])?(u=0,h.v=n,h.n=a[1]):v<y&&(o=t<3||a[0]>n||n>y)&&(a[4]=t,a[5]=n,h.n=y,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,c,y){if(f>1)throw TypeError("Generator is already running");for(s&&1===c&&v(c,y),u=c,l=y;(e=u<2?r:l)||!s;){a||(u?u<3?(u>1&&(h.n=-1),v(u,l)):h.n=l:h.v=l);try{if(f=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?l:t.call(n,h))!==i)break}catch(e){a=r,u=1,l=e}finally{f=1}}return{value:e,done:s}}}(t,o,a),!0),f}var i={};function u(){}function l(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(ot(e={},n,function(){return this}),e),s=f.prototype=u.prototype=Object.create(c);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,f):(r.__proto__=f,ot(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return l.prototype=f,ot(s,"constructor",f),ot(f,"constructor",l),l.displayName="GeneratorFunction",ot(f,o,"GeneratorFunction"),ot(s),ot(s,o,"Generator"),ot(s,n,function(){return this}),ot(s,"toString",function(){return"[object Generator]"}),(nt=function(){return{w:a,m:h}})()}function ot(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}ot=function(r,e,t,n){function a(e,t){ot(r,e,function(r){return this._invoke(e,t,r)})}e?o?o(r,e,{value:t,enumerable:!n,configurable:!n,writable:!n}):r[e]=t:(a("next",0),a("throw",1),a("return",2))},ot(r,e,t,n)}function at(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a,i,u=[],l=!0,f=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;l=!1}else for(;!(l=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(r){f=!0,o=r}finally{try{if(!l&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(f)throw o}}return u}}(r,e)||ut(r,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.")}()}function it(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=ut(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,o=function(){};return{s:o,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(r){throw r},f:o}}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 a,i=!0,u=!1;return{s:function(){t=t.call(r)},n:function(){var r=t.next();return i=r.done,r},e:function(r){u=!0,a=r},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function ut(r,e){if(r){if("string"==typeof r)return lt(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?lt(r,e):void 0}}function lt(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function ft(r,e,t){for(var n=0;n<t.length;n++)r.setUint8(e+n,t.charCodeAt(n))}function ct(r){var e,t=r.reduce(function(r,e){return r+e.length},0),n=new Float32Array(t),o=0,a=it(r);try{for(a.s();!(e=a.n()).done;){var i=e.value;n.set(i,o),o+=i.length}}catch(r){a.e(r)}finally{a.f()}return n}function st(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:i;return nt().m(function t(){var n,o,a,i,u,l,f,c,s,h,v;return nt().w(function(t){for(;;)switch(t.n){case 0:if(Array.isArray(r)&&(1===r.length||2===r.length)&&r.every(function(e){return e instanceof Float32Array&&e.length===r[0].length})&&Number.isInteger(e)&&!(e<1)){t.n=1;break}throw new RangeError("ATRAC1 framing requires one or two equally sized Float32 channels and a positive integer frame size");case 1:if(1!==r.length){t.n=5;break}n=at(r,1),o=n[0],a=0;case 2:if(!(a<o.length)){t.n=4;break}return(i=new Float32Array(e)).set(o.subarray(a,a+e)),t.n=3,i;case 3:a+=e,t.n=2;break;case 4:return t.a(2);case 5:if(2!==r.length){t.n=9;break}u=at(r,2),l=u[0],f=u[1],c=l.length,s=0;case 6:if(!(s<c)){t.n=8;break}return h=new Float32Array(e),v=new Float32Array(e),h.set(l.subarray(s,s+e)),v.set(f.subarray(s,s+e)),t.n=7,[h,v];case 7:s+=e,t.n=6;break;case 8:case 9:return t.a(2)}},t)})()}function ht(r){var e=Math.max(-1,Math.min(1,r));return e<0?32768*e:32767*e}function vt(r){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).sampleRate,t=void 0===e?a:e,n=function(r){if(!Array.isArray(r)||r.length<1||!r.every(function(e){return e instanceof Float32Array&&e.length===r[0].length}))throw new RangeError("PCM must contain equally sized Float32 channels");for(var e=r[0].length,t=new Uint8Array(e*r.length*2),n=new DataView(t.buffer),o=0,a=0;a<e;a++){var i,u=it(r);try{for(u.s();!(i=u.n()).done;){var l=i.value;n.setInt16(o,ht(l[a]),!0),o+=2}}catch(r){u.e(r)}finally{u.f()}}return t}(r),o=function(r){var e=r.sampleCount,t=r.sampleRate,n=r.channels,o=t*n*2,a=2*n,i=e*a,u=new Uint8Array(44),l=new DataView(u.buffer);return ft(l,0,"RIFF"),l.setUint32(4,36+i,!0),ft(l,8,"WAVE"),ft(l,12,"fmt "),l.setUint32(16,16,!0),l.setUint16(20,1,!0),l.setUint16(22,n,!0),l.setUint32(24,t,!0),l.setUint32(28,o,!0),l.setUint16(32,a,!0),l.setUint16(34,16,!0),ft(l,36,"data"),l.setUint32(40,i,!0),u}({sampleCount:r[0].length,sampleRate:t,channels:r.length}),i=new Uint8Array(o.length+n.length);return i.set(o),i.set(n,o.length),i}function yt(r){return yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},yt(r)}var dt=["title"];function pt(r){return function(r){if(Array.isArray(r))return St(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||At(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function mt(r,e){if(null==r)return{};var t,n,o=function(r,e){if(null==r)return{};var t={};for(var n in r)if({}.hasOwnProperty.call(r,n)){if(-1!==e.indexOf(n))continue;t[n]=r[n]}return t}(r,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(r);for(n=0;n<a.length;n++)t=a[n],-1===e.indexOf(t)&&{}.propertyIsEnumerable.call(r,t)&&(o[t]=r[t])}return o}function bt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var r,e,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function a(t,n,o,a){var l=n&&n.prototype instanceof u?n:u,f=Object.create(l.prototype);return wt(f,"_invoke",function(t,n,o){var a,u,l,f=0,c=o||[],s=!1,h={p:0,n:0,v:r,a:v,f:v.bind(r,4),d:function(e,t){return a=e,u=0,l=r,h.n=t,i}};function v(t,n){for(u=t,l=n,e=0;!s&&f&&!o&&e<c.length;e++){var o,a=c[e],v=h.p,y=a[2];t>3?(o=y===n)&&(l=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):a[0]<=v&&((o=t<2&&v<a[1])?(u=0,h.v=n,h.n=a[1]):v<y&&(o=t<3||a[0]>n||n>y)&&(a[4]=t,a[5]=n,h.n=y,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,c,y){if(f>1)throw TypeError("Generator is already running");for(s&&1===c&&v(c,y),u=c,l=y;(e=u<2?r:l)||!s;){a||(u?u<3?(u>1&&(h.n=-1),v(u,l)):h.n=l:h.v=l);try{if(f=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?l:t.call(n,h))!==i)break}catch(e){a=r,u=1,l=e}finally{f=1}}return{value:e,done:s}}}(t,o,a),!0),f}var i={};function u(){}function l(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(wt(e={},n,function(){return this}),e),s=f.prototype=u.prototype=Object.create(c);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,f):(r.__proto__=f,wt(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return l.prototype=f,wt(s,"constructor",f),wt(f,"constructor",l),l.displayName="GeneratorFunction",wt(f,o,"GeneratorFunction"),wt(s),wt(s,o,"Generator"),wt(s,n,function(){return this}),wt(s,"toString",function(){return"[object Generator]"}),(bt=function(){return{w:a,m:h}})()}function wt(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}wt=function(r,e,t,n){function a(e,t){wt(r,e,function(r){return this._invoke(e,t,r)})}e?o?o(r,e,{value:t,enumerable:!n,configurable:!n,writable:!n}):r[e]=t:(a("next",0),a("throw",1),a("return",2))},wt(r,e,t,n)}function gt(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a,i,u=[],l=!0,f=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;l=!1}else for(;!(l=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(r){f=!0,o=r}finally{try{if(!l&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(f)throw o}}return u}}(r,e)||At(r,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.")}()}function At(r,e){if(r){if("string"==typeof r)return St(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?St(r,e):void 0}}function St(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function kt(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Ft(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,jt(n.key),n)}}function Pt(r,e,t){return e&&Ft(r.prototype,e),t&&Ft(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function jt(r){var e=function(r,e){if("object"!=yt(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=yt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==yt(e)?e:e+""}function Ot(r,e,t,n,o,a,i){try{var u=r[a](i),l=u.value}catch(r){return void t(r)}u.done?e(l):Promise.resolve(l).then(n,o)}function Mt(r){return function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(r){Ot(a,n,o,i,u,"next",r)}function u(r){Ot(a,n,o,i,u,"throw",r)}i(void 0)})}}function Tt(r){return new It(r,0)}function Ct(r){return function(){return new Bt(r.apply(this,arguments))}}function Bt(r){var e,t;function n(e,t){try{var a=r[e](t),i=a.value,u=i instanceof It;Promise.resolve(u?i.v:i).then(function(t){if(u){var l="return"===e&&i.k?e:"next";if(!i.k||t.done)return n(l,t);t=r[l](t).value}o(!!a.done,t)},function(r){n("throw",r)})}catch(r){o(2,r)}}function o(r,o){2===r?e.reject(o):e.resolve({value:o,done:r}),(e=e.next)?n(e.key,e.arg):t=null}this._invoke=function(r,o){return new Promise(function(a,i){var u={key:r,arg:o,resolve:a,reject:i,next:null};t?t=t.next=u:(e=t=u,n(r,o))})},"function"!=typeof r.return&&(this.return=void 0)}function It(r,e){this.v=r,this.k=e}function xt(r){var e,t,n,o=2;for("undefined"!=typeof Symbol&&(t=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(t&&null!=(e=r[t]))return e.call(r);if(n&&null!=(e=r[n]))return new Et(e.call(r));t="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function Et(r){function e(r){if(Object(r)!==r)return Promise.reject(new TypeError(r+" is not an object."));var e=r.done;return Promise.resolve(r.value).then(function(r){return{value:r,done:e}})}return Et=function(r){this.s=r,this.n=r.next},Et.prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(r){var t=this.s.return;return void 0===t?Promise.resolve({value:r,done:!0}):e(t.apply(this.s,arguments))},throw:function(r){var t=this.s.return;return void 0===t?Promise.reject(r):e(t.apply(this.s,arguments))}},new Et(r)}function qt(r){if(1!==r&&2!==r)throw new Error("Unsupported channel count: ".concat(r))}function zt(r,e){var t=1===e?[r]:r;if(!Array.isArray(t)||t.length!==e||t.some(function(r){return!(r instanceof Float32Array)}))throw new TypeError("ATRAC1 streaming requires ".concat(e," Float32 channel").concat(1===e?"":"s"," per frame"));if(t.some(function(r){return r.length!==i}))throw new RangeError("ATRAC1 streaming requires exactly ".concat(i," samples per channel"))}function Dt(){return{nBfu:0,blockModes:[0,0,0],scaleFactorIndices:new Int32Array(0),wordLengthIndices:new Int32Array(0),quantizedCoefficients:[]}}function _t(r){return Ut.apply(this,arguments)}function Ut(){return(Ut=Mt(bt().m(function r(e){var t,n,o,a,i,u,l,f;return bt().w(function(r){for(;;)switch(r.p=r.n){case 0:t=[],n=!1,o=!1,r.p=1,i=xt(e);case 2:return r.n=3,i.next();case 3:if(!(n=!(u=r.v).done)){r.n=5;break}l=u.value,t.push(l);case 4:n=!1,r.n=2;break;case 5:r.n=7;break;case 6:r.p=6,f=r.v,o=!0,a=f;case 7:if(r.p=7,r.p=8,!n||null==i.return){r.n=9;break}return r.n=9,i.return();case 9:if(r.p=9,!o){r.n=10;break}throw a;case 10:return r.f(9);case 11:return r.f(7);case 12:return r.a(2,t)}},r,null,[[8,,9,11],[1,6,7,12]])}))).apply(this,arguments)}Bt.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},Bt.prototype.next=function(r){return this._invoke("next",r)},Bt.prototype.throw=function(r){return this._invoke("throw",r)},Bt.prototype.return=function(r){return this._invoke("return",r)};var Ht=function(){return Pt(function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};kt(this,r);var t=e.channelCount,n=void 0===t?1:t,o=e.onProgress,a=e.encoderOptions;qt(n);var i=a||new ce;this.channelCount=n,this.onProgress=o,this.frameIndex=0,this.sampleCount=0,this.finalized=!1,this.leftEncoder=xe(i),this.rightEncoder=2===n?xe(i):null},[{key:"frames",value:function(r){var e=this;return Ct(bt().m(function t(){var n,o,a,u,l,f,c,s,h,v;return bt().w(function(t){for(;;)switch(t.p=t.n){case 0:if(!e.finalized){t.n=1;break}throw new Error("ATRAC1 encoder has already been finalized");case 1:n=!1,o=!1,t.p=2,u=xt(r);case 3:return t.n=4,Tt(u.next());case 4:if(!(n=!(l=t.v).done)){t.n=10;break}if(zt(f=l.value,e.channelCount),1!==e.channelCount){t.n=6;break}return t.n=5,e.leftEncoder(f);case 5:t.n=8;break;case 6:return c=gt(f,2),s=c[0],h=c[1],t.n=7,e.leftEncoder(s);case 7:return t.n=8,e.rightEncoder(h);case 8:e.sampleCount+=i,e.onProgress&&e.onProgress(e.frameIndex++);case 9:n=!1,t.n=3;break;case 10:t.n=12;break;case 11:t.p=11,v=t.v,o=!0,a=v;case 12:if(t.p=12,t.p=13,!n||null==u.return){t.n=14;break}return t.n=14,Tt(u.return());case 14:if(t.p=14,!o){t.n=15;break}throw a;case 15:return t.f(14);case 16:return t.f(12);case 17:return t.a(2)}},t,null,[[13,,14,16],[2,11,12,17]])}))()}},{key:"finish",value:bt().m(function r(){var e,t;return bt().w(function(r){for(;;)switch(r.n){case 0:if(!this.finalized){r.n=1;break}return r.a(2);case 1:if(this.finalized=!0,0!==this.sampleCount){r.n=2;break}return r.a(2);case 2:e=new Float32Array(i),t=0;case 3:if(!(t<1)){r.n=6;break}return r.n=4,this.leftEncoder(e);case 4:if(2!==this.channelCount){r.n=5;break}return r.n=5,this.rightEncoder(e);case 5:t++,r.n=3;break;case 6:return r.a(2)}},r,this)})}])}(),Rt=function(){return Pt(function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};kt(this,r);var t=e.channelCount,n=void 0===t?1:t,o=e.onProgress,a=e.primingSampleCount,i=void 0===a?0:a,u=e.sampleCount,l=void 0===u?Number.POSITIVE_INFINITY:u;qt(n),this.channelCount=n,this.onProgress=o,this.frameIndex=0,this.primingSampleCount=i,this.sampleCount=l,this.timelinePosition=0,this.emittedSamples=0,this.leftFrame=null,this.leftDecoder=Le(),this.rightDecoder=2===n?Le():null},[{key:"frames",value:function(r){var e=this;return Ct(bt().m(function t(){var n,o,a,i,u,l,f;return bt().w(function(t){for(;;)switch(t.p=t.n){case 0:n=!1,o=!1,t.p=1,i=xt(r);case 2:return t.n=3,Tt(i.next());case 3:if(!(n=!(u=t.v).done)){t.n=9;break}if(l=u.value,1!==e.channelCount){t.n=5;break}return t.n=4,e.trim(e.leftDecoder(l));case 4:e.reportProgress(),t.n=8;break;case 5:if(null!==e.leftFrame){t.n=6;break}e.leftFrame=l,t.n=8;break;case 6:return t.n=7,e.trim([e.leftDecoder(e.leftFrame),e.rightDecoder(l)]);case 7:e.leftFrame=null,e.reportProgress();case 8:n=!1,t.n=2;break;case 9:t.n=11;break;case 10:t.p=10,f=t.v,o=!0,a=f;case 11:if(t.p=11,t.p=12,!n||null==i.return){t.n=13;break}return t.n=13,Tt(i.return());case 13:if(t.p=13,!o){t.n=14;break}throw a;case 14:return t.f(13);case 15:return t.f(11);case 16:return t.a(2)}},t,null,[[12,,13,15],[1,10,11,16]])}))()}},{key:"finish",value:bt().m(function r(){return bt().w(function(r){for(;;)switch(r.n){case 0:if(2!==this.channelCount||null===this.leftFrame){r.n=2;break}return r.n=1,this.trim([this.leftDecoder(this.leftFrame),this.rightDecoder(Dt())]);case 1:this.leftFrame=null,this.reportProgress();case 2:if(!Number.isFinite(this.sampleCount)||this.emittedSamples===this.sampleCount){r.n=3;break}throw new RangeError("Truncated ATRAC1 timeline: decoded ".concat(this.emittedSamples," of ").concat(this.sampleCount," samples"));case 3:return r.a(2)}},r,this)})},{key:"trim",value:function(r){var e=Math.max(0,this.primingSampleCount-this.timelinePosition),t=this.sampleCount-this.emittedSamples,n=Math.max(0,Math.min(i-e,t));return this.timelinePosition+=i,this.emittedSamples+=n,1===this.channelCount?r.slice(e,e+n):r.map(function(r){return r.slice(e,e+n)})}},{key:"reportProgress",value:function(){this.onProgress&&this.onProgress(this.frameIndex++)}}])}();function Lt(r){return new Ht(r)}function Nt(r){return new Rt(r)}function Gt(r){return Wt.apply(this,arguments)}function Wt(){return Wt=Mt(bt().m(function r(e){var t,n,o,a,i,u,f,c,s,h=arguments;return bt().w(function(r){for(;;)switch(r.n){case 0:if(t=h.length>1&&void 0!==h[1]?h[1]:{},Array.isArray(e)&&(1===e.length||2===e.length)&&!e.some(function(r){return!(r instanceof Float32Array)})){r.n=1;break}throw new TypeError("ATRAC1 encoding requires one or two Float32 channels");case 1:return n=t.title,o=void 0===n?"encoded by carta1":n,a=mt(t,dt),i=Lt({channelCount:e.length,encoderOptions:new ce(a)}),u=i.frames(st(e)),r.n=2,_t(u);case 2:return(f=r.v).push.apply(f,pt(i.finish())),c=Qe.createHeader(o,f.length,e.length,e[0].length,266),(s=new Uint8Array(c.length+f.length*l)).set(c),f.forEach(function(r,e){s.set(et(r),c.length+e*l)}),r.a(2,s)}},r)})),Wt.apply(this,arguments)}function Vt(r){return $t.apply(this,arguments)}function $t(){return($t=Mt(bt().m(function r(e){var t,n,o,a,i,f,c;return bt().w(function(r){for(;;)switch(r.n){case 0:if(!(e instanceof Blob)){r.n=2;break}return f=Uint8Array,r.n=1,e.arrayBuffer();case 1:c=r.v,t=new f(c),r.n=5;break;case 2:if(!(e instanceof Uint8Array)){r.n=3;break}t=e,r.n=5;break;case 3:if(!(e instanceof ArrayBuffer)){r.n=4;break}t=new Uint8Array(e),r.n=5;break;case 4:throw new TypeError("ATRAC1 decoding requires AEA bytes or a Blob");case 5:return n=Qe.parseHeader(t.subarray(0,u)),o=Nt({channelCount:n.channelCount,primingSampleCount:n.primingSampleCount,sampleCount:n.sampleCount}),a=Ct(bt().m(function r(){var e;return bt().w(function(r){for(;;)switch(r.n){case 0:e=u;case 1:if(!(e+l<=t.length)){r.n=3;break}return r.n=2,tt(t.subarray(e,e+l));case 2:e+=l,r.n=1;break;case 3:return r.a(2)}},r)}))(),r.n=6,_t(o.frames(a));case 6:if((i=r.v).push.apply(i,pt(o.finish())),1!==n.channelCount){r.n=7;break}return r.a(2,[ct(i)]);case 7:return r.a(2,[ct(i.map(function(r){return gt(r,1)[0]})),ct(i.map(function(r){return gt(r,2)[1]}))])}},r)}))).apply(this,arguments)}function Qt(r){return Qt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Qt(r)}function Yt(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a,i,u=[],l=!0,f=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;l=!1}else for(;!(l=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(r){f=!0,o=r}finally{try{if(!l&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(f)throw o}}return u}}(r,e)||Kt(r,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.")}()}function Jt(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=Kt(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,o=function(){};return{s:o,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(r){throw r},f:o}}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 a,i=!0,u=!1;return{s:function(){t=t.call(r)},n:function(){var r=t.next();return i=r.done,r},e:function(r){u=!0,a=r},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function Kt(r,e){if(r){if("string"==typeof r)return Xt(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Xt(r,e):void 0}}function Xt(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function Zt(r,e,t,n,o,a,i){try{var u=r[a](i),l=u.value}catch(r){return void t(r)}u.done?e(l):Promise.resolve(l).then(n,o)}function rn(r){return function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(r){Zt(a,n,o,i,u,"next",r)}function u(r){Zt(a,n,o,i,u,"throw",r)}i(void 0)})}}function en(r){if(null!=r){var e=r["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],t=0;if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length))return{next:function(){return r&&t>=r.length&&(r=void 0),{value:r&&r[t++],done:!r}}}}throw new TypeError(Qt(r)+" is not iterable")}function tn(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var r,e,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function a(t,n,o,a){var l=n&&n.prototype instanceof u?n:u,f=Object.create(l.prototype);return nn(f,"_invoke",function(t,n,o){var a,u,l,f=0,c=o||[],s=!1,h={p:0,n:0,v:r,a:v,f:v.bind(r,4),d:function(e,t){return a=e,u=0,l=r,h.n=t,i}};function v(t,n){for(u=t,l=n,e=0;!s&&f&&!o&&e<c.length;e++){var o,a=c[e],v=h.p,y=a[2];t>3?(o=y===n)&&(l=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):a[0]<=v&&((o=t<2&&v<a[1])?(u=0,h.v=n,h.n=a[1]):v<y&&(o=t<3||a[0]>n||n>y)&&(a[4]=t,a[5]=n,h.n=y,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,c,y){if(f>1)throw TypeError("Generator is already running");for(s&&1===c&&v(c,y),u=c,l=y;(e=u<2?r:l)||!s;){a||(u?u<3?(u>1&&(h.n=-1),v(u,l)):h.n=l:h.v=l);try{if(f=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?l:t.call(n,h))!==i)break}catch(e){a=r,u=1,l=e}finally{f=1}}return{value:e,done:s}}}(t,o,a),!0),f}var i={};function u(){}function l(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(nn(e={},n,function(){return this}),e),s=f.prototype=u.prototype=Object.create(c);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,f):(r.__proto__=f,nn(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return l.prototype=f,nn(s,"constructor",f),nn(f,"constructor",l),l.displayName="GeneratorFunction",nn(f,o,"GeneratorFunction"),nn(s),nn(s,o,"Generator"),nn(s,n,function(){return this}),nn(s,"toString",function(){return"[object Generator]"}),(tn=function(){return{w:a,m:h}})()}function nn(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}nn=function(r,e,t,n){function a(e,t){nn(r,e,function(r){return this._invoke(e,t,r)})}e?o?o(r,e,{value:t,enumerable:!n,configurable:!n,writable:!n}):r[e]=t:(a("next",0),a("throw",1),a("return",2))},nn(r,e,t,n)}function on(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,an(n.key),n)}}function an(r){var e=function(r,e){if("object"!=Qt(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Qt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Qt(e)?e:e+""}function un(r){return function(){return new ln(r.apply(this,arguments))}}function ln(r){var e,t;function n(e,t){try{var a=r[e](t),i=a.value,u=i instanceof cn;Promise.resolve(u?i.v:i).then(function(t){if(u){var l="return"===e&&i.k?e:"next";if(!i.k||t.done)return n(l,t);t=r[l](t).value}o(!!a.done,t)},function(r){n("throw",r)})}catch(r){o(2,r)}}function o(r,o){2===r?e.reject(o):e.resolve({value:o,done:r}),(e=e.next)?n(e.key,e.arg):t=null}this._invoke=function(r,o){return new Promise(function(a,i){var u={key:r,arg:o,resolve:a,reject:i,next:null};t?t=t.next=u:(e=t=u,n(r,o))})},"function"!=typeof r.return&&(this.return=void 0)}function fn(r){var e={},t=!1;function n(e,n){return t=!0,n=new Promise(function(t){t(r[e](n))}),{done:!1,value:new cn(n,1)}}return e["undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator"]=function(){return this},e.next=function(r){return t?(t=!1,r):n("next",r)},"function"==typeof r.throw&&(e.throw=function(r){if(t)throw t=!1,r;return n("throw",r)}),"function"==typeof r.return&&(e.return=function(r){return t?(t=!1,r):n("return",r)}),e}function cn(r,e){this.v=r,this.k=e}function sn(r){var e,t,n,o=2;for("undefined"!=typeof Symbol&&(t=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(t&&null!=(e=r[t]))return e.call(r);if(n&&null!=(e=r[n]))return new hn(e.call(r));t="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function hn(r){function e(r){if(Object(r)!==r)return Promise.reject(new TypeError(r+" is not an object."));var e=r.done;return Promise.resolve(r.value).then(function(r){return{value:r,done:e}})}return hn=function(r){this.s=r,this.n=r.next},hn.prototype={s:null,n:null,next:function(){return e(this.n.apply(this.s,arguments))},return:function(r){var t=this.s.return;return void 0===t?Promise.resolve({value:r,done:!0}):e(t.apply(this.s,arguments))},throw:function(r){var t=this.s.return;return void 0===t?Promise.reject(r):e(t.apply(this.s,arguments))}},new hn(r)}ln.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},ln.prototype.next=function(r){return this._invoke("next",r)},ln.prototype.throw=function(r){return this._invoke("throw",r)},ln.prototype.return=function(r){return this._invoke("return",r)};var vn=function(){function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r)}return e=r,t=null,n=[{key:"encodeAeaPcm",value:function(r){return Gt(r,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}},{key:"decodeAeaPcm",value:function(r){return Vt(r)}},{key:"encodeStream",value:function(r){return un(function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return tn().m(function t(){var n;return tn().w(function(t){for(;;)switch(t.n){case 0:return n=Lt(e),t.d(en(fn(sn(n.frames(r)))),1);case 1:return t.d(en(fn(sn(n.finish()))),2);case 2:return t.a(2)}},t)})()}).apply(this,arguments)}},{key:"decodeStream",value:function(r){return un(function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return tn().m(function t(){var n;return tn().w(function(t){for(;;)switch(t.n){case 0:return n=Nt(e),t.d(en(fn(sn(n.frames(r)))),1);case 1:return t.d(en(fn(sn(n.finish()))),2);case 2:return t.a(2)}},t)})()}).apply(this,arguments)}},{key:"frameBufferToFrames",value:tn().m(function r(e,t){return tn().w(function(r){for(;;)switch(r.n){case 0:return r.d(en(st(e,t)),1);case 1:return r.a(2)}},r)})},{key:"collectFrames",value:(c=rn(tn().m(function r(e){var t,n,o,a,i,u,l,f;return tn().w(function(r){for(;;)switch(r.p=r.n){case 0:t=[],n=!1,o=!1,r.p=1,i=sn(e);case 2:return r.n=3,i.next();case 3:if(!(n=!(u=r.v).done)){r.n=5;break}l=u.value,t.push(l);case 4:n=!1,r.n=2;break;case 5:r.n=7;break;case 6:r.p=6,f=r.v,o=!0,a=f;case 7:if(r.p=7,r.p=8,!n||null==i.return){r.n=9;break}return r.n=9,i.return();case 9:if(r.p=9,!o){r.n=10;break}throw a;case 10:return r.f(9);case 11:return r.f(7);case 12:return r.a(2,t)}},r,null,[[8,,9,11],[1,6,7,12]])})),function(r){return c.apply(this,arguments)})},{key:"createAeaBlob",value:(f=rn(tn().m(function r(e){var t,n,o,a,u,l,f,c,s,h,v,y,d,p,m,b,w,g=arguments;return tn().w(function(r){for(;;)switch(r.p=r.n){case 0:o=(n=g.length>1&&void 0!==g[1]?g[1]:{}).title,a=void 0===o?"encoded by atrac1.js":o,u=n.channelCount,l=void 0===u?1:u,f=[],c=!1,s=!1,r.p=1,v=sn(e);case 2:return r.n=3,v.next();case 3:if(!(c=!(y=r.v).done)){r.n=5;break}d=y.value,f.push(et(d));case 4:c=!1,r.n=2;break;case 5:r.n=7;break;case 6:r.p=6,w=r.v,s=!0,h=w;case 7:if(r.p=7,r.p=8,!c||null==v.return){r.n=9;break}return r.n=9,v.return();case 9:if(r.p=9,!s){r.n=10;break}throw h;case 10:return r.f(9);case 11:return r.f(7);case 12:return p=f.length/l,m=null!==(t=n.sampleCount)&&void 0!==t?t:Math.max(0,p-1)*i,b=Qe.createHeader(a,f.length,l,m,266),r.a(2,new Blob([b].concat(f),{type:"application/octet-stream"}))}},r,null,[[8,,9,11],[1,6,7,12]])})),function(r){return f.apply(this,arguments)})},{key:"parseAeaBlob",value:(o=rn(tn().m(function r(e){var t,n,o,a,i,f;return tn().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,e.arrayBuffer();case 1:for(t=r.v,n=new Uint8Array(t.slice(0,u)),o=Qe.parseHeader(n),a=[],i=u;i<t.byteLength;)(f=new Uint8Array(t.slice(i,i+l))).length===l&&a.push(f),i+=l;return r.a(2,{info:o,frameData:a})}},r)})),function(r){return o.apply(this,arguments)})},{key:"deserializedFrameStream",value:tn().m(function r(e){var t,n,o,a;return tn().w(function(r){for(;;)switch(r.p=r.n){case 0:t=Jt(e),r.p=1,t.s();case 2:if((n=t.n()).done){r.n=4;break}return o=n.value,r.n=3,tt(o);case 3:r.n=2;break;case 4:r.n=6;break;case 5:r.p=5,a=r.v,t.e(a);case 6:return r.p=6,t.f(),r.f(6);case 7:return r.a(2)}},r,null,[[1,5,6,7]])})},{key:"createPcmWaveBlob",value:function(r){var e,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a;if(1===t)e=[ct(r)];else{if(2!==t)throw new Error("Unsupported channel count: ".concat(t));e=[ct(r.map(function(r){return Yt(r,1)[0]})),ct(r.map(function(r){return Yt(r,2)[1]}))]}return new Blob([vt(e,{sampleRate:n})],{type:"audio/wav"})}},{key:"createWavBlob",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a;return r.createPcmWaveBlob(e,t,n)}},{key:"assemblePcmFrames",value:function(r,e){if(1===e)return ct(r);if(2!==e)throw new Error("Unsupported channel count: ".concat(e));for(var t=ct(r.map(function(r){return Yt(r,1)[0]})),n=ct(r.map(function(r){return Yt(r,2)[1]})),o=new Float32Array(2*Math.max(t.length,n.length)),a=0;a<o.length/2;a++){var i,u;o[2*a]=null!==(i=t[a])&&void 0!==i?i:0,o[2*a+1]=null!==(u=n[a])&&void 0!==u?u:0}return o}}],t&&on(e.prototype,t),n&&on(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n,o,f,c}();return e})());
|
|
2
2
|
//# sourceMappingURL=carta1.min.js.map
|