carta1 1.1.10 → 1.2.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.
Files changed (42) hide show
  1. package/bin/cli.js +8 -4
  2. package/codec/{coding/bitallocation.js → allocation/solve.js} +131 -97
  3. package/codec/allocation/source.js +69 -0
  4. package/codec/allocation/stage.js +38 -0
  5. package/codec/analysis/bands.js +49 -0
  6. package/codec/analysis/{transient.js → blocks.js} +90 -47
  7. package/codec/analysis/spectrum.js +160 -0
  8. package/codec/analysis/stage.js +32 -0
  9. package/codec/{browser/interface.js → boundary/browser.js} +1 -1
  10. package/codec/boundary/container.js +96 -0
  11. package/codec/boundary/pcm.js +193 -0
  12. package/codec/boundary/processor.js +208 -0
  13. package/codec/{io/readers.js → boundary/reader.js} +2 -1
  14. package/codec/boundary/stream.js +361 -0
  15. package/codec/{browser → boundary}/worker.js +45 -42
  16. package/codec/core/constants.js +9 -131
  17. package/codec/core/geometry.js +25 -0
  18. package/codec/core/tables.js +117 -0
  19. package/codec/dequantization.js +54 -0
  20. package/codec/index.js +10 -11
  21. package/codec/pipeline/decoder.js +10 -399
  22. package/codec/pipeline/encoder.js +12 -434
  23. package/codec/quantization/spectrum.js +67 -0
  24. package/codec/quantization/stage.js +45 -0
  25. package/codec/{transforms/qmf.js → signal/bands.js} +8 -5
  26. package/codec/{transforms → signal}/fft.js +1 -1
  27. package/codec/{transforms/mdct.js → signal/spectrum.js} +16 -1
  28. package/codec/{core/buffers.js → state.js} +46 -35
  29. package/codec/{io → syntax}/bitstream.js +27 -8
  30. package/codec/{io/serialization.js → syntax/frame.js} +5 -101
  31. package/codec/synthesis/bands.js +201 -0
  32. package/codec/synthesis/pcm.js +50 -0
  33. package/codec/synthesis/stage.js +17 -0
  34. package/codec/utils.js +9 -52
  35. package/dist/carta1-worker-interface.min.js.map +1 -1
  36. package/dist/carta1-worker.min.js +1 -1
  37. package/dist/carta1-worker.min.js.map +1 -1
  38. package/dist/carta1.min.js +1 -1
  39. package/dist/carta1.min.js.map +1 -1
  40. package/package.json +1 -1
  41. package/codec/coding/quantization.js +0 -149
  42. package/codec/io/processor.js +0 -671
@@ -1,2 +1,2 @@
1
- !function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.Carta1=r():e.Carta1=r()}(this,()=>(()=>{"use strict";const e={d:(r,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var o=t[n++],a=t[n++];e.o(r,o)?0===a&&n++:0===a?Object.defineProperty(r,o,{enumerable:!0,value:t[n++]}):Object.defineProperty(r,o,{enumerable:!0,get:a})}else for(var o in t)e.o(t,o)&&!e.o(r,o)&&Object.defineProperty(r,o,{enumerable:!0,get:t[o]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}};let r={};function t(e){throw new Error(e)}function n(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];var o=t.map(function(r){return r(e)});return function(e){return o.reduce(function(e,r){return r(e)},e)}}function o(e,r){for(var t=r[e.length],n=0;n<e.length;n++)t[n]=e[e.length-1-n];return t}e.r(r),e.d(r,{AeaFile:()=>lr,AudioProcessor:()=>Cr,BFU_START_LONG:()=>d,BufferPool:()=>Ce,EncoderOptions:()=>Le,FFT:()=>Q,SCALE_FACTORS:()=>H,SPECS_PER_BFU:()=>v,WORD_LENGTH_BITS:()=>L,decode:()=>Ye,decodeAeaPcm:()=>zr,dequantize:()=>me,deserializeFrame:()=>fr,encode:()=>Je,encodeAeaPcm:()=>Ir,mdctStage:()=>Ge,pipe:()=>n,qmfAnalysisStage:()=>Ve,quantize:()=>pe,serializeFrame:()=>ur});var a=new Uint8Array([0,8,0,0]),i=2048,u=212,f=8*u,l=40,c=52,s=10,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]),h=new Int32Array([20,28,32,36,40,44,48,52]),y=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]),b=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]),p=64,m=256,w=512,g=function(){for(var e=new Float64Array(32),r=0;r<32;r++)e[r]=Math.sin((r+.5)*Math.PI/64);return e}(),S=46,k=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]),A=function(){for(var e=new Float32Array(48),r=0;r<24;r++)e[r]=2*k[r],e[47-r]=2*k[r];return e}(),B=function(){for(var e=new Float32Array(24),r=0;r<24;r++)e[r]=A[2*r];return e}(),M=function(){for(var e=new Float32Array(24),r=0;r<24;r++)e[r]=A[2*r+1];return e}(),F=128,O=128,j=256,P=[{size:128,windowStart:48},{size:128,windowStart:48},{size:256,windowStart:112}],T=32,C=32,I=16,x=32767,z=32768,q=16,E=4,_=6,D=1,U=15,L=new Int32Array([0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),H=function(){for(var e=new Float64Array(64),r=0;r<64;r++)e[r]=Math.pow(2,r/3-21);return e}(),W=function(){for(var e=L[U],r=new Float64Array(e+1),t=0;t<=e;t++)r[t]=Math.pow(2,-t);return r}(),N=function(){for(var e=new Int32Array(U),r=0;r<U;r++)e[r]=L[r+1]-L[r]|0;return e}(),V=function(){var e=new Float64Array(U);e[0]=2-W[L[1]];for(var r=1;r<U;r++){var t=0|L[r],n=0|L[r+1];e[r]=W[t]-W[n]}return e}();function R(e,r){var n,o,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=e.length,u=i>>1,f=null!==(n=null==a||null===(o=a.delay)||void 0===o?void 0:o[i])&&void 0!==n?n:t("qmfAnalysis: qmfWorkBuffers.delay[".concat(i,"] is required"));f.set(r),f.set(e,r.length);for(var l=new Float32Array(u),c=new Float32Array(u),s=0;s<u;s++){for(var v=0,h=0,y=2*s,d=0;d<24;d++)v+=f[y+47-2*d]*B[d],h+=f[y+46-2*d]*M[d];l[s]=v+h,c[s]=v-h}return{lowBand:l,highBand:c,newDelay:f.slice(-S)}}function G(e,r,n){var o,a,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,u=e.length,f=2*u,l=null!==(o=null==i||null===(a=i.delay)||void 0===a?void 0:a[f])&&void 0!==o?o:t("qmfSynthesis: qmfWorkBuffers.delay[".concat(f,"] is required"));l.set(n);for(var c=0;c<u;c++){var s=e[c],v=r[c],h=S+2*c;l[h]=.5*(s+v),l[h+1]=.5*(s-v)}for(var y=new Float32Array(f),d=0;d<u;d++){for(var b=2*d,p=0,m=0,w=0;w<24;w++){var g=b+2*w;p+=l[g]*B[w],m+=l[g+1]*M[w]}y[2*d]=m,y[2*d+1]=p}return{output:y,newDelay:l.slice(-S)}}function $(e){return $="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},$(e)}function J(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,K(n.key),n)}}function K(e){var r=function(e,r){if("object"!=$(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=$(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==$(r)?r:r+""}var Q=function(){return e=function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e)},t=[{key:"fft",value:function(e,r){var t=e.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 f=[e[a],e[o]];e[o]=f[0],e[a]=f[1];var l=[r[a],r[o]];r[o]=l[0],r[a]=l[1]}}for(var c=2;c<=t;c<<=1)for(var s=c>>1,v=-2*Math.PI/c,h=Math.cos(v),y=Math.sin(v),d=0;d<t;d+=c)for(var b=1,p=0,m=0;m<s;m++){var w=d+m,g=w+s,S=e[w],k=r[w],A=e[g],B=r[g],M=A*b-B*p,F=A*p+B*b;e[w]=S+M,r[w]=k+F,e[g]=S-M,r[g]=k-F;var O=b*h-p*y;p=b*y+p*h,b=O}}}}],(r=null)&&J(e.prototype,r),t&&J(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,t}();function X(e){return X="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},X(e)}function Y(e,r,t){return r=ee(r),function(e,r){if(r&&("object"==X(r)||"function"==typeof r))return r;if(void 0!==r)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,Z()?Reflect.construct(r,t||[],ee(e).constructor):r.apply(e,t))}function Z(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(Z=function(){return!!e})()}function ee(e){return ee=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},ee(e)}function re(e,r){if("function"!=typeof r&&null!==r)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(r&&r.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),r&&te(e,r)}function te(e,r){return te=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,r){return e.__proto__=r,e},te(e,r)}function ne(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,ae(n.key),n)}}function oe(e,r,t){return r&&ne(e.prototype,r),t&&ne(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function ae(e){var r=function(e,r){if("object"!=X(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=X(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==X(r)?r:r+""}function ie(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}var ue=oe(function e(r,t){ie(this,e),this.size=r,this.halfSize=r>>1,this.quarterSize=r>>2,this.fftSize=this.halfSize>>1;var n=2*Math.PI/(8*r),o=2*Math.PI/r,a=Math.sqrt(t/r);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)}}),fe=function(e){function r(e,t){return ie(this,r),Y(this,r,[e,t])}return re(r,e),oe(r,[{key:"transform",value:function(e){var r,n,o,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=null!==(r=null==a?void 0:a[this.fftSize])&&void 0!==r?r:t("MDCT.transform: mdctBuffers[".concat(this.fftSize,"] is required")),u=null!==(n=null==i?void 0:i.real)&&void 0!==n?n:t("MDCT.transform: mdctBuffers[".concat(this.fftSize,"].real is required")),f=null!==(o=null==i?void 0:i.imag)&&void 0!==o?o:t("MDCT.transform: mdctBuffers[".concat(this.fftSize,"].imag is required")),l=this.quarterSize,c=3*l;u.fill(0),f.fill(0);for(var s=0;s<l;s+=2){var v=c+s,h=l+s,y=l-1-s,d=e[c-1-s]+e[v],b=e[h]-e[y],p=this.sinCosTable[s],m=this.sinCosTable[s+1];u[s>>1]=d*p+b*m,f[s>>1]=b*p-d*m}for(var w=l;w<this.halfSize;w+=2){var g=w>>1,S=w-l,k=l+w,A=5*l-1-w,B=e[c-1-w]-e[S],M=e[k]+e[A],F=this.sinCosTable[w],O=this.sinCosTable[w+1];u[g]=B*F+M*O,f[g]=M*F-B*O}Q.fft(u,f);for(var j=new Float32Array(this.halfSize),P=0;P<this.fftSize;P++){var T=this.sinCosTable[2*P],C=this.sinCosTable[2*P+1],I=u[P],x=f[P];j[2*P]=-I*T-x*C,j[this.halfSize-1-2*P]=-I*C+x*T}return j}}])}(ue),le=function(e){function r(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return ie(this,r),Y(this,r,[e,t||e])}return re(r,e),oe(r,[{key:"transform",value:function(e){var r,n,o,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=null!==(r=null==a?void 0:a[this.fftSize])&&void 0!==r?r:t("IMDCT.transform: mdctBuffers[".concat(this.fftSize,"] is required")),u=null!==(n=null==i?void 0:i.real)&&void 0!==n?n:t("IMDCT.transform: mdctBuffers[".concat(this.fftSize,"].real is required")),f=null!==(o=null==i?void 0:i.imag)&&void 0!==o?o:t("IMDCT.transform: mdctBuffers[".concat(this.fftSize,"].imag is required")),l=this.quarterSize,c=3*l;u.fill(0),f.fill(0);for(var s=0;s<this.fftSize;s++){var v=2*s,h=-e[v],y=-e[this.halfSize-1-v],d=this.sinCosTable[v],b=this.sinCosTable[v+1];u[s]=y*b+h*d,f[s]=y*d-h*b}Q.fft(u,f);for(var p=new Float32Array(this.size),m=0;m<this.fftSize/2;m++){var w=2*m,g=this.sinCosTable[w],S=this.sinCosTable[w+1],k=u[m],A=f[m],B=k*g+A*S,M=k*S-A*g;p[c-1-w]=B,p[c+w]=B,p[l+w]=M,p[l-1-w]=-M}for(var F=this.fftSize/2;F<this.fftSize;F++){var O=2*(F-this.fftSize/2)+l,j=2*F,P=this.sinCosTable[j],T=this.sinCosTable[j+1],C=u[F],I=f[F],x=C*P+I*T,z=C*T-I*P;p[c-1-O]=x,p[O-l]=-x,p[l+O]=z,p[5*l-1-O]=z}return p}}])}(ue),ce=new fe(p,.5),se=new fe(m,.5),ve=new fe(w,1),he=new le(p,8*p),ye=new le(m,8*m),de=new le(w,4*w);function be(e,r,t){for(var n=e.length,o=new Float32Array(2*n),a=0;a<n;a++){var i=t[a],u=t[2*n-1-a],f=e[a],l=r[n-1-a];o[a]=f*u-l*i,o[2*n-1-a]=f*i+l*u}return o}function pe(e,r,t){var n=e.length,o=new Int32Array(n);if(0===t||0===r)return o.fill(0,0,n),o;for(var a=H[r],i=(1<<t-D)-1,u=i/a,f=i,l=-i,c=0;c<n;c++){var s=e[c]*u,v=s+(s>=0?.5:-.5)|0;o[c]=v>f?f:v<l?l:v}return o}function me(e,r,t){if(0===t||0===r)return new Float32Array(e.length);for(var n=H[r],o=(1<<t-D)-1,a=new Float32Array(e.length),i=0;i<e.length;i++)a[i]=e[i]*n/o;return a}function we(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return ge(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ge(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},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(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function ge(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}var Se=new Map;function ke(e,r,t,n){for(var o=new Int32Array(t),a=new Float32Array(t),i=function(e){if(Se.has(e))return Se.get(e);var r=new Float64Array(64);if(1===e)r.set(H);else for(var t=0;t<64;t++)r[t]=Math.pow(H[t],e);return Se.set(e,r),r}(n),u=0;u<t;u++){var v=0|r[u];if(0!==v){var y=Me(e[u],v);if(o[u]=y,y>0){var d=i[y];a[u]=2*d*v}}}var b,p=null,m=1/0,w=we(h);try{for(w.s();!(b=w.n()).done;){var g=b.value;if(!(g>t)){var S=f-l-g*s;if(!(S<0)){var k=Be(g,r,S,i,o),A=Ae(g,t,r,k.wordLengths,k.scaleFactorIndices,i,a);A<m&&(m=A,p={bfuCount:g,allocation:k.wordLengths,scaleFactorIndices:k.scaleFactorIndices})}}}}catch(e){w.e(e)}finally{w.f()}if(!p){var B=h[0];return{bfuCount:B,allocation:new Int32Array(B),scaleFactorIndices:new Int32Array(c)}}return p}function Ae(e,r,t,n,o,a,i){for(var u=0,f=0;f<e;f++){var l=0|n[f],c=0|L[l];if(0!==c){var s=o[f];if(0!==s)u+=a[s]*W[c]*t[f]}else u+=i[f]}for(var v=e;v<r;v++)u+=i[v];return u}function Be(e,r,t,n,o){for(var a=new Int32Array(e),i=new Int32Array(e),u=new Float32Array(e),f=0,l=0;l<e;l++){if(0!==(0|r[l])){var c=o[l];if(0!==c){var s=N[0];if(!(s<=0)){var v=n[c]*V[0];i[f]=l,u[f]=v/s,f++}}}}if(0===f)return{wordLengths:a,scaleFactorIndices:o};for(var h=(f>>1)-1;h>=0;h--)Fe(i,u,h,f);for(;t>0&&f>0;){var y=i[0],d=0|a[y],b=0|r[y],p=N[d]*b;if(p>t||p<=0){var m=f-1;i[0]=i[m],u[0]=u[m],--f>0&&Fe(i,u,0,f)}else{t-=p;var w=d+1;a[y]=w;var g=N[w];if(w<U&&g>0){var S=n[o[y]]*V[w];u[0]=S/g,Fe(i,u,0,f)}else{var k=f-1;i[0]=i[k],u[0]=u[k],--f>0&&Fe(i,u,0,f)}}}return{wordLengths:a,scaleFactorIndices:o}}function Me(e,r){for(var t=0,n=0;n<r;n++){var o=Math.abs(e[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 Fe(e,r,t,n){for(var o=t,a=e[o],i=r[o];;){var u=1+(o<<1),f=u+1,l=o,c=i;if(u<n&&r[u]>c&&(l=u,c=r[u]),f<n&&r[f]>c&&(l=f),l===o)break;e[o]=e[l],r[o]=r[l],o=l}e[o]=a,r[o]=i}function Oe(e){return Oe="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Oe(e)}function je(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Te(n.key),n)}}function Pe(e,r,t){return r&&je(e.prototype,r),t&&je(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Te(e){var r=function(e,r){if("object"!=Oe(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=Oe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==Oe(r)?r:r+""}var Ce=Pe(function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),this.transformBuffers={64:new Float32Array(64),128:new Float32Array(128),256:new Float32Array(256),512:new Float32Array(512)},this.qmfWorkBuffers={delay:{128:new Float32Array(S+128),256:new Float32Array(S+256),512:new Float32Array(S+512)},highBandDelay:{128:new Float32Array(167),256:new Float32Array(295)}},this.qmfDelays={lowBand:new Float32Array(S),midBand:new Float32Array(S),highBand:new Float32Array(39)},this.transientDetection=[new Float32Array(64),new Float32Array(64),new Float32Array(128)],this.mdctBuffers={16:{real:new Float32Array(16),imag:new Float32Array(16)},64:{real:new Float32Array(64),imag:new Float32Array(64)},128:{real:new Float32Array(128),imag: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)],this.reversalBuffers={32:new Float32Array(32),128:new Float32Array(128),256:new Float32Array(256)}});function Ie(e){return Ie="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Ie(e)}function xe(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,n)}return t}function ze(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?xe(Object(t),!0).forEach(function(r){qe(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):xe(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function qe(e,r,t){return(r=Ue(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function Ee(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,u=[],f=!0,l=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=a.call(t)).done)&&(u.push(n.value),u.length!==r);f=!0);}catch(e){l=!0,o=e}finally{try{if(!f&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(e,r)||function(e,r){if(e){if("string"==typeof e)return _e(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_e(e,r):void 0}}(e,r)||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 _e(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function De(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Ue(n.key),n)}}function Ue(e){var r=function(e,r){if("object"!=Ie(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=Ie(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==Ie(r)?r:r+""}var Le=function(){return e=function e(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e),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"}},r&&this.setOptions(r)},(r=[{key:"setOptions",value:function(e){for(var r=0,t=Object.entries(e);r<t.length;r++){var n=Ee(t[r],2),o=n[0],a=n[1];o in this.values&&this.setValue(o,a)}}},{key:"setValue",value:function(e,r){if(!(e in this.metadata))throw new Error("Unknown option: ".concat(e));var t=this.metadata[e];if("array"!==t.type){var n=Ee(t.range,2),o=n[0],a=n[1];if(r<o||r>a)throw new Error("Value for ".concat(e," must be between ").concat(o," and ").concat(a,", got ").concat(r))}this.values[e]=r}},{key:"getValue",value:function(e){if(!(e in this.values))throw new Error("Unknown option: ".concat(e));return this.values[e]}},{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(e){return this.metadata[e]}},{key:"getAllMetadata",value:function(){return ze({},this.metadata)}},{key:"reset",value:function(){for(var e=0,r=Object.entries(this.metadata);e<r.length;e++){var t=Ee(r[e],2),n=t[0],o=t[1];this.values[n]=o.default}}},{key:"toObject",value:function(){return{values:ze({},this.values),metadata:ze({},this.metadata)}}}])&&De(e.prototype,r),t&&De(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,t}();function He(e,r,t){if(!r)return!1;var n=function(e,r){var t=function(e,r){for(var t=0,n=0,o=0;o<e.length;o++){var a=Math.abs(e[o]),i=a-Math.abs(r[o]);i>0&&(t+=i),n+=a*a}var u=Math.sqrt(n)||1e-6;return t/u}(e,r),n=We(e),o=We(r),a=Math.abs(n-o),i=Ne(e),u=Ne(r),f=Math.abs(i-u),l=function(e,r){for(var t=0,n=0,o=0;o<e.length;o++)t+=e[o]*e[o],n+=r[o]*r[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)}(e,r);return{spectralFlux:t,flatnessChange:a,hfChange:f,energyChange:l}}(e,r),o=function(e){var r=e.spectralFlux,t=e.flatnessChange,n=e.hfChange,o=e.energyChange,a=r,i=Math.sqrt(t),u=Math.log1p(10*n)/Math.log1p(10),f=Math.min(o/30,1);return(a+i+u+f)/4}(n);return o>t}function We(e){for(var r=0,t=0,n=0,o=0;o<e.length;o++){var a=Math.abs(e[o]);a>1e-10&&(r+=Math.log(a),t+=a,n++)}if(0===n)return 0;var i=Math.exp(r/n),u=t/n;return u>1e-10?i/u:0}function Ne(e){for(var r=Math.floor(e.length/2),t=0,n=0,o=0;o<r;o++)t+=e[o]*e[o];for(var a=r;a<e.length;a++)n+=e[a]*e[a];var i=t+n;return i>0?n/i:0}function Ve(e){var r,n=null!==(r=null==e?void 0:e.bufferPool)&&void 0!==r?r:t("qmfAnalysisStage: bufferPool is required"),o=n.qmfDelays;return function(e){var r=R(e,o.lowBand,n.qmfWorkBuffers);o.lowBand=r.newDelay;var t=R(r.lowBand,o.midBand,n.qmfWorkBuffers);o.midBand=t.newDelay;var a=n.qmfWorkBuffers.highBandDelay[r.highBand.length];a.set(o.highBand),a.set(r.highBand,o.highBand.length);var i=a.slice(0,r.highBand.length);return o.highBand=a.slice(r.highBand.length),{bands:[t.lowBand,t.highBand,i]}}}function Re(e){var r,n,o=null!==(r=null==e?void 0:e.bufferPool)&&void 0!==r?r:t("blockSelectorStage: bufferPool is required"),a=null!==(n=null==e?void 0:e.options)&&void 0!==n?n:t("blockSelectorStage: options is required");return function(e){var r,t=e.bands;if(a.fixedBlockModes)r=a.fixedBlockModes;else{var n=[F,O,j];r=t.map(function(e,r){var t=function(e,r){var t=new Float32Array(r),n=new Float32Array(r),o=Math.min(e.length,r);t.set(e.subarray(0,o)),Q.fft(t,n);for(var a=new Float32Array(r/2),i=0;i<r/2;i++)a[i]=Math.sqrt(t[i]*t[i]+n[i]*n[i]);return a}(e,n[r]),i=He(t,o.transientDetection[r],a.transientThresholdLow);return o.transientDetection[r]=t,i*Math.max(r+1,2)})}return{bands:t,blockModes:r}}}function Ge(e){var r,n=null!==(r=null==e?void 0:e.bufferPool)&&void 0!==r?r:t("mdctStage: bufferPool is required"),a=n.mdctOverlap,i=[se,se,ve];function u(e,r,t,n,a){var u=P[r];return 0===t?function(e,r,t,n,a,i){var u=2===r?w:m,l=i.transformBuffers[u];l.fill(0),l.set(a,t.windowStart),f(e,a,t.size),l.set(e,t.windowStart+C);var c=n.transform(l,i.mdctBuffers);r>0&&(c=o(c,i.reversalBuffers));return c}(e,r,u,i[r],n,a):function(e,r,t,n,a){for(var i=1<<(256===t.size?3:2),u=new Float32Array(t.size),l=0;l<i;l++){var c=l*T,s=e.subarray(c,c+T),v=a.transformBuffers[p];v.fill(0),v.set(n,0),f(s,n,T),v.set(s,C);var h=ce.transform(v,a.mdctBuffers);r>0&&(h=o(h,a.reversalBuffers)),u.set(h,c)}return u}(e,r,u,n,a)}function f(e,r,t){for(var n=t-C,o=0;o<C;o++){var a=e[n+o];r[o]=g[o]*a,e[n+o]=a*g[31-o]}}return function(e){var r=e.bands,t=e.blockModes,o=e.originalFrame,i=new Float32Array(512);return r.forEach(function(e,r){var o=u(e,r,t[r],a[r],n),f=function(e){return 0===e?0:1===e?128:256}(r);i.set(o,f)}),{bands:r,coefficients:i,blockModes:t,originalFrame:o}}}function $e(e){var r,n=null!==(r=null==e?void 0:e.options)&&void 0!==r?r:t("quantizationStage: options is required");return function(e){for(var r=e.coefficients,t=e.blockModes,o=function(e,r){for(var t=[],n=[],o=0,a=0,i=0;i<3;i++){for(var u=o,f=2===i?256:128,l=i<2?y[i]:v.length,c=0===r[i]?d:b;a<l;){var s=v[a],h=c[a]-u,p=h+s,m=new Float32Array(s);if(h>=0&&p<=f)m.set(e.subarray(u+h,u+p));else if(m.fill(0),h<f&&p>0){var w=Math.max(0,h),g=Math.min(f,p);m.set(e.subarray(u+w,u+g),Math.max(0,-h))}t.push(m),n.push(s),a++}o+=f}return{bfuData:t,bfuSizes:n,bfuCount:a}}(r,t),a=o.bfuData,i=o.bfuSizes,u=ke(a,i,o.bfuCount,n.allocationBias),f=u.bfuCount,l=u.allocation,c=u.scaleFactorIndices,s=l.slice(0,f),h=c.slice(0,f),p=[],m=0;m<f;m++){var w=a[m].subarray(0,i[m]),g=s[m],S=L[g],k=pe(w,c[m],S);p.push(k)}return{nBfu:f,scaleFactorIndices:h,wordLengthIndices:s,quantizedCoefficients:p,blockModes:t}}}function Je(){return n({options:arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Le,bufferPool:arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Ce},Ve,Re,Ge,$e)}function Ke(){return function(e){for(var r=new Float32Array(512),t=e.nBfu,n=e.scaleFactorIndices,o=e.wordLengthIndices,a=e.quantizedCoefficients,i=e.blockModes,u=0;u<t;u++){var f=L[o[u]],l=0;u>=y[0]&&(l=1),u>=y[1]&&(l=2);var c=0===i[l]?d[u]:b[u];if(f>0){var s=me(a[u],n[u],f);r.set(s,c)}}return{coefficients:r,blockModes:i}}}function Qe(e){var r,n=null!==(r=null==e?void 0:e.bufferPool)&&void 0!==r?r:t("imdctStage: bufferPool is required"),a=n.imdctOverlap,i=[ye,ye,de];function u(e,r,t,n,a,u){return 0===t?function(e,r,t,n,a,i){var u=e;r>0&&(u=o(e,n.reversalBuffers));var f=i.transform(u,n.mdctBuffers),l=f.length/4,c=n.transformBuffers[w];c.fill(0);for(var s=0;s<a.size;s++)c[s]=f[l+s];var v=t.slice(2*a.size-I,2*a.size),h=be(v.slice(0,I),c.slice(0,I),g);t.set(h,0);for(var y=0;y<I;y++)v[y]=c[I+y];for(var d=2===r?240:112,b=0;b<d;b++)t[32+b]=c[I+b];for(var p=0;p<I;p++)t[2*a.size-I+p]=c[a.size-I+p];return t.slice(0,a.size)}(e,r,n,a,u,i[r]):function(e,r,t,n,a){var i=1<<(256===a.size?3:2),u=n.transformBuffers[w];u.fill(0);for(var f=t.slice(2*a.size-I,2*a.size),l=0,c=0,s=0;s<i;s++){var v=e.slice(c,c+T);r>0&&(v=o(v,n.reversalBuffers));for(var h=he.transform(v,n.mdctBuffers),y=h.length/4,d=0;d<T;d++)u[l+d]=h[y+d];var b=be(f.slice(0,I),u.slice(l,l+I),g);t.set(b,l);for(var p=0;p<I;p++)f[p]=u[l+I+p];l+=T,c+=T}for(var m=0;m<I;m++)t[2*a.size-I+m]=u[a.size-I+m];return t.slice(0,a.size)}(e,r,n,a,u)}return function(e){var r=e.coefficients,t=e.blockModes;return P.map(function(e,o){var i=function(e,r){var t=[0,128,256,512];return e.subarray(t[r],t[r+1])}(r,o);return u(i,o,t[o],a[o],n,e)})}}function Xe(e){var r,n=null!==(r=null==e?void 0:e.bufferPool)&&void 0!==r?r:t("qmfSynthesisStage: bufferPool is required"),o=n.qmfDelays;return function(e){var r=n.qmfWorkBuffers.highBandDelay[e[2].length];r.set(o.highBand),r.set(e[2],o.highBand.length);var t=r.slice(0,2*e[0].length);o.highBand=r.slice(2*e[0].length);var a=G(e[0],e[1],o.midBand,n.qmfWorkBuffers);o.midBand=a.newDelay;var i=G(a.output,t,o.lowBand,n.qmfWorkBuffers);return o.lowBand=i.newDelay,i.output}}function Ye(){return n({bufferPool:arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Ce},Ke,Qe,Xe)}function Ze(e,r,t,n){if(0!==n){var o=Math.floor(r/8),a=r%8;t&=(1<<n)-1;for(var i=0;i<n&&o<e.length;){var u=8-a,f=Math.min(n-i,u),l=t>>n-i-f&(1<<f)-1,c=(1<<f)-1<<u-f;e[o]=e[o]&~c|l<<u-f,i+=f,o++,a=0}}}function er(e,r,t){if(0===t)return 0;for(var n=Math.floor(r/8),o=r%8,a=0,i=0;i<t&&n<e.length;){var u=8-o,f=Math.min(t-i,u),l=(1<<f)-1;a=a<<f|e[n]>>u-f&l,i+=f,n++,o=0}return a}function rr(e,r,t){var n=er(e,r,t);return n>=1<<t-1?n-(1<<t):n}function tr(e){return tr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},tr(e)}function nr(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,or(n.key),n)}}function or(e){var r=function(e,r){if("object"!=tr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=tr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==tr(r)?r:r+""}function ar(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=function(e,r){if(e){if("string"==typeof e)return ir(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ir(e,r):void 0}}(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},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(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function ir(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function ur(e){var r=new Uint8Array(u),t=new DataView(r.buffer),n=h.indexOf(e.nBfu),o=2-e.blockModes[0]<<14|2-e.blockModes[1]<<12|3-e.blockModes[2]<<10|n<<5;t.setUint16(0,o,!1);for(var a=q,i=0;i<e.nBfu;i++)Ze(r,a,e.wordLengthIndices[i],E),a+=E;for(var f=0;f<e.nBfu;f++)Ze(r,a,e.scaleFactorIndices[f],_),a+=_;for(var l=0;l<e.nBfu;l++){var c=L[e.wordLengthIndices[l]];if(c>0){var s,v=ar(e.quantizedCoefficients[l]);try{for(v.s();!(s=v.n()).done;){var y=s.value;Ze(r,a,y<0?y+(1<<c):y,c),a+=c}}catch(e){v.e(e)}finally{v.f()}}}return r[u-3]=0,r[u-2]=0,r[u-1]=0,r}function fr(e){if(e.length!==u)throw new Error("Frame must be ".concat(u," bytes"));for(var r=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,!1),t=[2-(r>>14&3),2-(r>>12&3),3-(r>>10&3)],n=h[r>>5&7],o=q,a=new Int32Array(n),i=0;i<n;i++)a[i]=er(e,o,E),o+=E;for(var f=new Int32Array(n),l=0;l<n;l++)f[l]=er(e,o,_),o+=_;for(var c=[],s=0;s<n;s++){var y=L[a[s]],d=v[s],b=new Int32Array(d);if(y>0)for(var p=0;p<d;p++)b[p]=rr(e,o,y),o+=y;c.push(b)}return{nBfu:n,scaleFactorIndices:f,wordLengthIndices:a,quantizedCoefficients:c,blockModes:t}}var lr=function(){return e=function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e)},t=[{key:"createHeader",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,n=new Uint8Array(i),o=new DataView(n.buffer);n.set(a,0);var u=(new TextEncoder).encode(e);return n.set(u.subarray(0,Math.min(u.length,255)),4),o.setUint32(260,r,!0),n[264]=t,n}},{key:"parseHeader",value:function(e){if(e.length!==i)throw new Error("Header must be ".concat(i," bytes"));for(var r=0;r<a.length;r++)if(e[r]!==a[r])throw new Error("Invalid AEA file");var t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=e.indexOf(0,4),o=-1===n?256:n-4;return{title:(new TextDecoder).decode(e.subarray(4,4+o)),frameCount:t.getUint32(260,!0),channelCount:e[264]}}}],(r=null)&&nr(e.prototype,r),t&&nr(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,t}(),cr=["title"];function sr(e,r){if(null==e)return{};var t,n,o=function(e,r){if(null==e)return{};var t={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==r.indexOf(n))continue;t[n]=e[n]}return t}(e,r);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)t=a[n],-1===r.indexOf(t)&&{}.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function vr(e){return vr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},vr(e)}function hr(e,r){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!t){if(Array.isArray(e)||(t=pr(e))||r&&e&&"number"==typeof e.length){t&&(e=t);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},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(e)},n:function(){var e=t.next();return i=e.done,e},e:function(e){u=!0,a=e},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function yr(e,r,t,n,o,a,i){try{var u=e[a](i),f=u.value}catch(e){return void t(e)}u.done?r(f):Promise.resolve(f).then(n,o)}function dr(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){yr(a,n,o,i,u,"next",e)}function u(e){yr(a,n,o,i,u,"throw",e)}i(void 0)})}}function br(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var n,o,a,i,u=[],f=!0,l=!1;try{if(a=(t=t.call(e)).next,0===r){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=a.call(t)).done)&&(u.push(n.value),u.length!==r);f=!0);}catch(e){l=!0,o=e}finally{try{if(!f&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(e,r)||pr(e,r)||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 pr(e,r){if(e){if("string"==typeof e)return mr(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?mr(e,r):void 0}}function mr(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function wr(e){if(null!=e){var r=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],t=0;if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&t>=e.length&&(e=void 0),{value:e&&e[t++],done:!e}}}}throw new TypeError(vr(e)+" is not iterable")}function gr(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,r,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function a(t,n,o,a){var f=n&&n.prototype instanceof u?n:u,l=Object.create(f.prototype);return Sr(l,"_invoke",function(t,n,o){var a,u,f,l=0,c=o||[],s=!1,v={p:0,n:0,v:e,a:h,f:h.bind(e,4),d:function(r,t){return a=r,u=0,f=e,v.n=t,i}};function h(t,n){for(u=t,f=n,r=0;!s&&l&&!o&&r<c.length;r++){var o,a=c[r],h=v.p,y=a[2];t>3?(o=y===n)&&(f=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=e):a[0]<=h&&((o=t<2&&h<a[1])?(u=0,v.v=n,v.n=a[1]):h<y&&(o=t<3||a[0]>n||n>y)&&(a[4]=t,a[5]=n,v.n=y,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,c,y){if(l>1)throw TypeError("Generator is already running");for(s&&1===c&&h(c,y),u=c,f=y;(r=u<2?e:f)||!s;){a||(u?u<3?(u>1&&(v.n=-1),h(u,f)):v.n=f:v.v=f);try{if(l=2,a){if(u||(o="next"),r=a[o]){if(!(r=r.call(a,f)))throw TypeError("iterator result is not an object");if(!r.done)return r;f=r.value,u<2&&(u=0)}else 1===u&&(r=a.return)&&r.call(a),u<2&&(f=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=e}else if((r=(s=v.n<0)?f:t.call(n,v))!==i)break}catch(r){a=e,u=1,f=r}finally{l=1}}return{value:r,done:s}}}(t,o,a),!0),l}var i={};function u(){}function f(){}function l(){}r=Object.getPrototypeOf;var c=[][n]?r(r([][n]())):(Sr(r={},n,function(){return this}),r),s=l.prototype=u.prototype=Object.create(c);function v(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,Sr(e,o,"GeneratorFunction")),e.prototype=Object.create(s),e}return f.prototype=l,Sr(s,"constructor",l),Sr(l,"constructor",f),f.displayName="GeneratorFunction",Sr(l,o,"GeneratorFunction"),Sr(s),Sr(s,o,"Generator"),Sr(s,n,function(){return this}),Sr(s,"toString",function(){return"[object Generator]"}),(gr=function(){return{w:a,m:v}})()}function Sr(e,r,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}Sr=function(e,r,t,n){function a(r,t){Sr(e,r,function(e){return this._invoke(r,t,e)})}r?o?o(e,r,{value:t,enumerable:!n,configurable:!n,writable:!n}):e[r]=t:(a("next",0),a("throw",1),a("return",2))},Sr(e,r,t,n)}function kr(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,Ar(n.key),n)}}function Ar(e){var r=function(e,r){if("object"!=vr(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,r||"default");if("object"!=vr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(e)}(e,"string");return"symbol"==vr(r)?r:r+""}function Br(e){return function(){return new Mr(e.apply(this,arguments))}}function Mr(e){var r,t;function n(r,t){try{var a=e[r](t),i=a.value,u=i instanceof jr;Promise.resolve(u?i.v:i).then(function(t){if(u){var f="return"===r&&i.k?r:"next";if(!i.k||t.done)return n(f,t);t=e[f](t).value}o(!!a.done,t)},function(e){n("throw",e)})}catch(e){o(2,e)}}function o(e,o){2===e?r.reject(o):r.resolve({value:o,done:e}),(r=r.next)?n(r.key,r.arg):t=null}this._invoke=function(e,o){return new Promise(function(a,i){var u={key:e,arg:o,resolve:a,reject:i,next:null};t?t=t.next=u:(r=t=u,n(e,o))})},"function"!=typeof e.return&&(this.return=void 0)}function Fr(e){return new jr(e,0)}function Or(e){var r={},t=!1;function n(r,n){return t=!0,n=new Promise(function(t){t(e[r](n))}),{done:!1,value:new jr(n,1)}}return r["undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator"]=function(){return this},r.next=function(e){return t?(t=!1,e):n("next",e)},"function"==typeof e.throw&&(r.throw=function(e){if(t)throw t=!1,e;return n("throw",e)}),"function"==typeof e.return&&(r.return=function(e){return t?(t=!1,e):n("return",e)}),r}function jr(e,r){this.v=e,this.k=r}function Pr(e){var r,t,n,o=2;for("undefined"!=typeof Symbol&&(t=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(t&&null!=(r=e[t]))return r.call(e);if(n&&null!=(r=e[n]))return new Tr(r.call(e));t="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function Tr(e){function r(e){if(Object(e)!==e)return Promise.reject(new TypeError(e+" is not an object."));var r=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:r}})}return Tr=function(e){this.s=e,this.n=e.next},Tr.prototype={s:null,n:null,next:function(){return r(this.n.apply(this.s,arguments))},return:function(e){var t=this.s.return;return void 0===t?Promise.resolve({value:e,done:!0}):r(t.apply(this.s,arguments))},throw:function(e){var t=this.s.return;return void 0===t?Promise.reject(e):r(t.apply(this.s,arguments))}},new Tr(e)}Mr.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},Mr.prototype.next=function(e){return this._invoke("next",e)},Mr.prototype.throw=function(e){return this._invoke("throw",e)},Mr.prototype.return=function(e){return this._invoke("return",e)};var Cr=function(){function e(){!function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}(this,e)}return r=e,t=null,n=[{key:"encodeAeaPcm",value:function(e){return Ir(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}},{key:"decodeAeaPcm",value:function(e){return zr(e)}},{key:"encodeStream",value:function(r){return Br(function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return gr().m(function n(){var o,a,i,u;return gr().w(function(n){for(;;)switch(n.n){case 0:if(o=t.channelCount,a=void 0===o?1:o,i=t.onProgress,u=t.encoderOptions,1!==a){n.n=2;break}return n.d(wr(Or(Pr(e._encodeMonoStream(r,i,u)))),1);case 1:case 3:n.n=5;break;case 2:if(2!==a){n.n=4;break}return n.d(wr(Or(Pr(e._encodeStereoStream(r,i,u)))),3);case 4:throw new Error("Unsupported channel count: ".concat(a));case 5:return n.a(2)}},n)})()}).apply(this,arguments)}},{key:"_encodeMonoStream",value:function(e,r,t){return Br(gr().m(function n(){var o,a,i,u,f,l,c,s,v,h,y;return gr().w(function(n){for(;;)switch(n.p=n.n){case 0:o=t||new Le,a=Je(o),i=0,u=!1,f=!1,n.p=1,c=Pr(e);case 2:return n.n=3,Fr(c.next());case 3:if(!(u=!(s=n.v).done)){n.n=6;break}return v=s.value,h=a(v),n.n=4,h;case 4:r&&r(i++);case 5:u=!1,n.n=2;break;case 6:n.n=8;break;case 7:n.p=7,y=n.v,f=!0,l=y;case 8:if(n.p=8,n.p=9,!u||null==c.return){n.n=10;break}return n.n=10,Fr(c.return());case 10:if(n.p=10,!f){n.n=11;break}throw l;case 11:return n.f(10);case 12:return n.f(8);case 13:return n.a(2)}},n,null,[[9,,10,12],[1,7,8,13]])}))()}},{key:"_encodeStereoStream",value:function(e,r,t){return Br(gr().m(function n(){var o,a,i,u,f,l,c,s,v,h,y,d,b,p,m;return gr().w(function(n){for(;;)switch(n.p=n.n){case 0:o=t||new Le,a=Je(o),i=Je(o),u=0,f=!1,l=!1,n.p=1,s=Pr(e);case 2:return n.n=3,Fr(s.next());case 3:if(!(f=!(v=n.v).done)){n.n=7;break}return h=br(v.value,2),y=h[0],d=h[1],b=a(y),p=i(d),n.n=4,b;case 4:return n.n=5,p;case 5:r&&r(u++);case 6:f=!1,n.n=2;break;case 7:n.n=9;break;case 8:n.p=8,m=n.v,l=!0,c=m;case 9:if(n.p=9,n.p=10,!f||null==s.return){n.n=11;break}return n.n=11,Fr(s.return());case 11:if(n.p=11,!l){n.n=12;break}throw c;case 12:return n.f(11);case 13:return n.f(9);case 14:return n.a(2)}},n,null,[[10,,11,13],[1,8,9,14]])}))()}},{key:"decodeStream",value:function(r){return Br(function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return gr().m(function n(){var o,a,i;return gr().w(function(n){for(;;)switch(n.n){case 0:if(o=t.channelCount,a=void 0===o?1:o,i=t.onProgress,1!==a){n.n=2;break}return n.d(wr(Or(Pr(e._decodeMonoStream(r,i)))),1);case 1:case 3:n.n=5;break;case 2:if(2!==a){n.n=4;break}return n.d(wr(Or(Pr(e._decodeStereoStream(r,i)))),3);case 4:throw new Error("Unsupported channel count: ".concat(a));case 5:return n.a(2)}},n)})()}).apply(this,arguments)}},{key:"_decodeMonoStream",value:function(e,r){return Br(gr().m(function t(){var n,o,a;return gr().w(function(t){for(;;)switch(t.n){case 0:return n=Ye(),o=0,a=function(){var t=Br(gr().m(function t(){var a,i,u,f,l,c,s,v;return gr().w(function(t){for(;;)switch(t.p=t.n){case 0:a=!1,i=!1,t.p=1,f=Pr(e);case 2:return t.n=3,Fr(f.next());case 3:if(!(a=!(l=t.v).done)){t.n=6;break}return c=l.value,s=n(c),t.n=4,s;case 4:r&&r(o++);case 5:a=!1,t.n=2;break;case 6:t.n=8;break;case 7:t.p=7,v=t.v,i=!0,u=v;case 8:if(t.p=8,t.p=9,!a||null==f.return){t.n=10;break}return t.n=10,Fr(f.return());case 10:if(t.p=10,!i){t.n=11;break}throw u;case 11:return t.f(10);case 12:return t.f(8);case 13:return t.a(2)}},t,null,[[9,,10,12],[1,7,8,13]])}));return function(){return t.apply(this,arguments)}}(),t.d(wr(Or(Pr(a()))),1);case 1:return t.a(2)}},t)}))()}},{key:"_decodeStereoStream",value:function(r,t){return Br(gr().m(function n(){var o,a,i,u;return gr().w(function(n){for(;;)switch(n.n){case 0:return o=Ye(),a=Ye(),i=0,u=function(){var n=Br(gr().m(function n(){var u,f,l,c,s,v,h,y,d,b,p,m,w,g,S;return gr().w(function(n){for(;;)switch(n.p=n.n){case 0:u=null,f=!0,l=!1,c=!1,n.p=1,v=Pr(r);case 2:return n.n=3,Fr(v.next());case 3:if(!(l=!(h=n.v).done)){n.n=8;break}if(y=h.value,!f){n.n=4;break}u=y,n.n=6;break;case 4:return d=y,b=o(u),p=a(d),n.n=5,[b,p];case 5:t&&t(i++);case 6:f=!f;case 7:l=!1,n.n=2;break;case 8:n.n=10;break;case 9:n.p=9,S=n.v,c=!0,s=S;case 10:if(n.p=10,n.p=11,!l||null==v.return){n.n=12;break}return n.n=12,Fr(v.return());case 12:if(n.p=12,!c){n.n=13;break}throw s;case 13:return n.f(12);case 14:return n.f(10);case 15:if(f||!u){n.n=17;break}return m=e._createDummyFrame(),w=o(u),g=a(m),n.n=16,[w,g];case 16:t&&t(i++);case 17:return n.a(2)}},n,null,[[11,,12,14],[1,9,10,15]])}));return function(){return n.apply(this,arguments)}}(),n.d(wr(Or(Pr(u()))),1);case 1:return n.a(2)}},n)}))()}},{key:"frameBufferToFrames",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:512;return gr().m(function t(){var n,o,a,i,u,f,l,c,s,v,h,y,d,b,p,m;return gr().w(function(t){for(;;)switch(t.n){case 0:if(1!==(n=e.length)){t.n=4;break}o=br(e,1),a=o[0],i=0;case 1:if(!(i<a.length)){t.n=3;break}for(u=new Float32Array(r),f=Math.min(i+r,a.length),l=0;l<f-i;l++)u[l]=a[i+l];return t.n=2,u;case 2:i+=r,t.n=1;break;case 3:t.n=9;break;case 4:if(2!==n){t.n=8;break}c=br(e,2),s=c[0],v=c[1],h=Math.max(s.length,v.length),y=0;case 5:if(!(y<h)){t.n=7;break}for(d=new Float32Array(r),b=new Float32Array(r),p=Math.min(y+r,h),m=0;m<p-y;m++)d[m]=y+m<s.length?s[y+m]:0,b[m]=y+m<v.length?v[y+m]:0;return t.n=6,[d,b];case 6:y+=r,t.n=5;break;case 7:t.n=9;break;case 8:throw new Error("Unsupported channel count: ".concat(n));case 9:return t.a(2)}},t)})()}},{key:"collectFrames",value:(f=dr(gr().m(function e(r){var t,n,o,a,i,u,f,l;return gr().w(function(e){for(;;)switch(e.p=e.n){case 0:t=[],n=!1,o=!1,e.p=1,i=Pr(r);case 2:return e.n=3,i.next();case 3:if(!(n=!(u=e.v).done)){e.n=5;break}f=u.value,t.push(f);case 4:n=!1,e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,l=e.v,o=!0,a=l;case 7:if(e.p=7,e.p=8,!n||null==i.return){e.n=9;break}return e.n=9,i.return();case 9:if(e.p=9,!o){e.n=10;break}throw a;case 10:return e.f(9);case 11:return e.f(7);case 12:return e.a(2,t)}},e,null,[[8,,9,11],[1,6,7,12]])})),function(e){return f.apply(this,arguments)})},{key:"_createDummyFrame",value:function(){return{nBfu:0,blockModes:[0,0,0],scaleFactorIndices:new Int32Array(0),wordLengthIndices:new Int32Array(0),quantizedCoefficients:[]}}},{key:"createAeaBlob",value:(a=dr(gr().m(function e(r){var t,n,o,a,i,u,f,l,c,s,v,h,y,d,b,p,m,w,g,S,k=arguments;return gr().w(function(e){for(;;)switch(e.p=e.n){case 0:n=(t=k.length>1&&void 0!==k[1]?k[1]:{}).title,o=void 0===n?"encoded by atrac1.js":n,a=t.channelCount,i=void 0===a?1:a,u=[],f=!1,l=!1,e.p=1,s=Pr(r);case 2:return e.n=3,s.next();case 3:if(!(f=!(v=e.v).done)){e.n=5;break}h=v.value,u.push(ur(h));case 4:f=!1,e.n=2;break;case 5:e.n=7;break;case 6:e.p=6,S=e.v,l=!0,c=S;case 7:if(e.p=7,e.p=8,!f||null==s.return){e.n=9;break}return e.n=9,s.return();case 9:if(e.p=9,!l){e.n=10;break}throw c;case 10:return e.f(9);case 11:return e.f(7);case 12:for(y=lr.createHeader(o,u.length,i),d=y.length+u.reduce(function(e,r){return e+r.length},0),(b=new Uint8Array(d)).set(y,0),p=y.length,m=0,w=u;m<w.length;m++)g=w[m],b.set(g,p),p+=g.length;return e.a(2,new Blob([b],{type:"application/octet-stream"}))}},e,null,[[8,,9,11],[1,6,7,12]])})),function(e){return a.apply(this,arguments)})},{key:"createWavBlob",value:function(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:44100,o=Array.isArray(r)?r:[r];if(1===t)return e._createMonoWavBlob(o,n);if(2===t)return e._createStereoWavBlob(o,n);throw new Error("Unsupported channel count: ".concat(t))}},{key:"_createMonoWavBlob",value:function(r,t){var n=r.reduce(function(e,r){return e+r.length},0),o=new ArrayBuffer(44+2*n),a=new DataView(o);e._writeWavHeader(a,n,1,t);var i,u=44,f=hr(r);try{for(f.s();!(i=f.n()).done;)for(var l=i.value,c=0;c<l.length;c++){var s=Math.max(-1,Math.min(1,l[c]));a.setInt16(u,s<0?s*z:s*x,!0),u+=2}}catch(e){f.e(e)}finally{f.f()}return new Blob([o],{type:"audio/wav"})}},{key:"_createStereoWavBlob",value:function(r,t){var n=r.reduce(function(e,r){var t=br(r,2),n=t[0],o=t[1];return e+Math.max(n.length,o.length)},0),o=new ArrayBuffer(44+2*n*2),a=new DataView(o);e._writeWavHeader(a,n,2,t);var i,u=44,f=hr(r);try{for(f.s();!(i=f.n()).done;)for(var l=br(i.value,2),c=l[0],s=l[1],v=Math.max(c.length,s.length),h=0;h<v;h++){var y=h<c.length?c[h]:0,d=h<s.length?s[h]:0,b=Math.max(-1,Math.min(1,y)),p=Math.max(-1,Math.min(1,d));a.setInt16(u,b<0?b*z:b*x,!0),u+=2,a.setInt16(u,p<0?p*z:p*x,!0),u+=2}}catch(e){f.e(e)}finally{f.f()}return new Blob([o],{type:"audio/wav"})}},{key:"_writeWavHeader",value:function(e,r,t,n){var o=n*t*2,a=2*t,i=r*a,u=36+i,f=0,l=function(r,t){for(var n=0;n<t.length;n++)e.setUint8(r+n,t.charCodeAt(n))};l(f,"RIFF"),f+=4,e.setUint32(f,u,!0),l(f+=4,"WAVE"),l(f+=4,"fmt "),f+=4,e.setUint32(f,16,!0),f+=4,e.setUint16(f,1,!0),f+=2,e.setUint16(f,t,!0),f+=2,e.setUint32(f,n,!0),f+=4,e.setUint32(f,o,!0),f+=4,e.setUint16(f,a,!0),f+=2,e.setUint16(f,16,!0),l(f+=2,"data"),f+=4,e.setUint32(f,i,!0)}},{key:"parseAeaBlob",value:(o=dr(gr().m(function e(r){var t,n,o,a,f,l;return gr().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,r.arrayBuffer();case 1:for(t=e.v,n=new Uint8Array(t.slice(0,i)),o=lr.parseHeader(n),a=[],f=i;f<t.byteLength;f+=u)(l=new Uint8Array(t.slice(f,f+u))).length===u&&a.push(l);return e.a(2,{info:o,frameData:a})}},e)})),function(e){return o.apply(this,arguments)})},{key:"deserializedFrameStream",value:gr().m(function e(r){var t,n,o,a;return gr().w(function(e){for(;;)switch(e.p=e.n){case 0:t=hr(r),e.p=1,t.s();case 2:if((n=t.n()).done){e.n=4;break}return o=n.value,e.n=3,fr(o);case 3:e.n=2;break;case 4:e.n=6;break;case 5:e.p=5,a=e.v,t.e(a);case 6:return e.p=6,t.f(),e.f(6);case 7:return e.a(2)}},e,null,[[1,5,6,7]])})},{key:"assemblePcmFrames",value:function(e,r){if(1===r){var t,n=e.reduce(function(e,r){return e+r.length},0),o=new Float32Array(n),a=0,i=hr(e);try{for(i.s();!(t=i.n()).done;){var u=t.value;o.set(u,a),a+=u.length}}catch(e){i.e(e)}finally{i.f()}return o}if(2===r){var f,l=e.reduce(function(e,r){var t=br(r,2),n=t[0],o=t[1];return e+Math.max(n.length,o.length)},0),c=new Float32Array(2*l),s=0,v=hr(e);try{for(v.s();!(f=v.n()).done;)for(var h=br(f.value,2),y=h[0],d=h[1],b=Math.max(y.length,d.length),p=0;p<b;p++)c[2*s]=p<y.length?y[p]:0,c[2*s+1]=p<d.length?d[p]:0,s++}catch(e){v.e(e)}finally{v.f()}return c}throw new Error("Unsupported channel count: ".concat(r))}}],t&&kr(r.prototype,t),n&&kr(r,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,t,n,o,a,f}();function Ir(e){return xr.apply(this,arguments)}function xr(){return xr=dr(gr().m(function e(r){var t,n,o,a,i,u,f,l,c,s=arguments;return gr().w(function(e){for(;;)switch(e.n){case 0:if(t=s.length>1&&void 0!==s[1]?s[1]:{},Array.isArray(r)&&(1===r.length||2===r.length)&&!r.some(function(e){return!(e instanceof Float32Array)})){e.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=sr(t,cr),i=Cr.frameBufferToFrames(r),u=Cr.encodeStream(i,{channelCount:r.length,encoderOptions:new Le(a)}),e.n=2,Cr.createAeaBlob(u,{title:o,channelCount:r.length});case 2:return f=e.v,l=Uint8Array,e.n=3,f.arrayBuffer();case 3:return c=e.v,e.a(2,new l(c))}},e)})),xr.apply(this,arguments)}function zr(e){return qr.apply(this,arguments)}function qr(){return(qr=dr(gr().m(function e(r){var t,n,o,a,i,u;return gr().w(function(e){for(;;)switch(e.n){case 0:if(!(r instanceof Blob)){e.n=1;break}t=r,e.n=3;break;case 1:if(!(r instanceof Uint8Array||r instanceof ArrayBuffer)){e.n=2;break}t=new Blob([r]),e.n=3;break;case 2:throw new TypeError("ATRAC1 decoding requires AEA bytes or a Blob");case 3:return e.n=4,Cr.parseAeaBlob(t);case 4:return n=e.v,o=n.info,a=n.frameData,i=Cr.deserializedFrameStream(a),e.n=5,Cr.collectFrames(Cr.decodeStream(i,{channelCount:o.channelCount}));case 5:if(u=e.v,1!==o.channelCount){e.n=6;break}return e.a(2,[Er(u)]);case 6:return e.a(2,[Er(u.map(function(e){return br(e,1)[0]})),Er(u.map(function(e){return br(e,2)[1]}))])}},e)}))).apply(this,arguments)}function Er(e){var r,t=e.reduce(function(e,r){return e+r.length},0),n=new Float32Array(t),o=0,a=hr(e);try{for(a.s();!(r=a.n()).done;){var i=r.value;n.set(i,o),o+=i.length}}catch(e){a.e(e)}finally{a.f()}return n}return r})());
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:()=>he,AudioProcessor:()=>Mt,BFU_START_LONG:()=>C,BufferPool:()=>te,EncoderOptions:()=>Wr,FFT:()=>fr,SCALE_FACTORS:()=>L,SPECS_PER_BFU:()=>T,WORD_LENGTH_BITS:()=>U,decode:()=>fe,decodeAeaPcm:()=>ct,dequantize:()=>$r,deserializeFrame:()=>ge,encode:()=>ne,encodeAeaPcm:()=>ft,mdctStage:()=>zr,pipe:()=>n,qmfAnalysisStage:()=>or,quantize:()=>Vr,serializeFrame:()=>we});var o=44100,a=512,i=2048,u=212,f=8*u,l=40,c=52,s=10,h=64,y=256,v=512,d=32,p=32,b=16,m=46,w=128,g=128,S=256,A=16,k=4,O=6,j=1,P=15,F=new Uint8Array([0,8,0,0]),T=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]),B=new Int32Array([20,28,32,36,40,44,48,52]),M=new Int32Array([20,36,52]),C=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]),I=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]),E=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}(),q=function(){for(var r=new Float32Array(24),e=0;e<24;e++)r[e]=z[2*e];return r}(),D=function(){for(var r=new Float32Array(24),e=0;e<24;e++)r[e]=z[2*e+1];return r}(),_=[{size:128,windowStart:48},{size:128,windowStart:48},{size:256,windowStart:112}],U=new Int32Array([0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),L=function(){for(var r=new Float64Array(64),e=0;e<64;e++)r[e]=Math.pow(2,e/3-21);return r}(),R=function(){for(var r=U[P],e=new Float64Array(r+1),t=0;t<=r;t++)e[t]=Math.pow(2,-t);return e}(),N=function(){for(var r=new Int32Array(P),e=0;e<P;e++)r[e]=U[e+1]-U[e]|0;return r}(),H=function(){var r=new Float64Array(P);r[0]=2-R[U[1]];for(var e=1;e<P;e++){var t=0|U[e],n=0|U[e+1];r[e]=R[t]-R[n]}return r}();function G(r,e){return function(r,e){for(var t=[],n=[],o=0,a=0,i=0;i<3;i++){for(var u=o,f=2===i?256:128,l=i<2?M[i]:T.length,c=0===e[i]?C:I;a<l;){var s=T[a],h=c[a]-u,y=h+s,v=new Float32Array(s);if(h>=0&&y<=f)v.set(r.subarray(u+h,u+y));else if(h<f&&y>0){var d=Math.max(0,h),p=Math.min(f,y);v.set(r.subarray(u+d,u+p),Math.max(0,-h))}t.push(v),n.push(s),a++}o+=f}return{bfuData:t,bfuSizes:n,bfuCount:a}}(r,e)}function W(r){return W="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},W(r)}function V(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 $(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)?$(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 $(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 Q(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 Y(r,e,t){return(e=function(r){var e=function(r,e){if("object"!=W(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=W(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==W(e)?e:e+""}(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var J=new Map;function K(r,e,t,n,o,a,i){var u=function(r,e,t,n,o){for(var a=new Int32Array(r),i=new Int32Array(r),u=new Float32Array(r),f=0,l=0;l<r;l++){if(0!==(0|e[l])){var c=o[l];if(0!==c){var s=N[0];if(!(s<=0)){var h=n[c]*H[0];i[f]=l,u[f]=h/s,f++}}}}if(0===f)return{wordLengths:a,scaleFactorIndices:o};for(var y=(f>>1)-1;y>=0;y--)X(i,u,y,f);for(;t>0&&f>0;){var v=i[0],d=0|a[v],p=0|e[v],b=N[d]*p;if(b>t||b<=0){var m=f-1;i[0]=i[m],u[0]=u[m],--f>0&&X(i,u,0,f)}else{t-=b;var w=d+1;a[v]=w;var g=N[w];if(w<P&&g>0){var S=n[o[v]]*H[w];u[0]=S/g,X(i,u,0,f)}else{var A=f-1;i[0]=i[A],u[0]=u[A],--f>0&&X(i,u,0,f)}}}return{wordLengths:a,scaleFactorIndices:o}}(r,t,n,o,a),f=function(r,e,t,n,o,a,i){for(var u=0,f=0;f<r;f++){var l=0|n[f],c=0|U[l];if(0!==c){var s=o[f];if(0!==s)u+=a[s]*R[c]*t[f]}else u+=i[f]}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?Q(Object(t),!0).forEach(function(e){Y(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Q(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}({distortion:f},u)}function X(r,e,t,n){for(var o=t,a=r[o],i=e[o];;){var u=1+(o<<1),f=u+1,l=o,c=i;if(u<n&&e[u]>c&&(l=u,c=e[u]),f<n&&e[f]>c&&(l=f),l===o)break;r[o]=r[l],e[o]=e[l],o=l}r[o]=a,e[o]=i}function Z(r,e,t,n){for(var o=new Int32Array(t),a=new Float32Array(t),i=function(r){if(J.has(r))return J.get(r);var e=new Float64Array(64);if(1===r)e.set(L);else for(var t=0;t<64;t++)e[t]=Math.pow(L[t],r);return J.set(r,e),e}(n),u=0;u<t;u++){var h=0|e[u];if(0!==h){var y=rr(r[u],h);if(o[u]=y,y>0){var v=i[y];a[u]=2*v*h}}}var d,p=null,b=1/0,m=V(B);try{for(m.s();!(d=m.n()).done;){var w=d.value;if(!(w>t)){var g=f-l-w*s;if(!(g<0)){var S=K(w,t,e,g,i,o,a);S.distortion<b&&(b=S.distortion,p={bfuCount:w,allocation:S.wordLengths,scaleFactorIndices:S.scaleFactorIndices})}}}}catch(r){m.e(r)}finally{m.f()}if(!p){var A=B[0];return{bfuCount:A,allocation:new Int32Array(A),scaleFactorIndices:new Int32Array(c)}}return p}function rr(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 er(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=G(e,t),a=o.bfuData,i=o.bfuSizes,u=Z(a,i,o.bfuCount,n.allocationBias),f=u.bfuCount;return{bfuData:a,bfuSizes:i,nBfu:f,scaleFactorIndices:u.scaleFactorIndices.slice(0,f),wordLengthIndices:u.allocation.slice(0,f),blockModes:t}}}function tr(r,e){var n,o,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=r.length,u=i>>1,f=null!==(n=null==a||null===(o=a.delay)||void 0===o?void 0:o[i])&&void 0!==n?n:t("analyzeQmfPair: qmfWorkBuffers.delay[".concat(i,"] is required"));f.set(e),f.set(r,e.length);for(var l=new Float32Array(u),c=new Float32Array(u),s=0;s<u;s++){for(var h=0,y=0,v=2*s,d=0;d<24;d++)h+=f[v+47-2*d]*q[d],y+=f[v+46-2*d]*D[d];l[s]=h+y,c[s]=h-y}return{lowBand:l,highBand:c,newDelay:f.slice(-m)}}function nr(r,e,n){var o,a,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,u=r.length,f=2*u,l=null!==(o=null==i||null===(a=i.delay)||void 0===a?void 0:a[f])&&void 0!==o?o:t("synthesizeQmfPair: qmfWorkBuffers.delay[".concat(f,"] is required"));l.set(n);for(var c=0;c<u;c++){var s=r[c],h=e[c],y=m+2*c;l[y]=.5*(s+h),l[y+1]=.5*(s-h)}for(var v=new Float32Array(f),d=0;d<u;d++){for(var p=2*d,b=0,w=0,g=0;g<24;g++){var S=p+2*g;b+=l[S]*q[g],w+=l[S+1]*D[g]}v[2*d]=w,v[2*d+1]=b}return{output:v,newDelay:l.slice(-m)}}function or(r){var e,n=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:t("analyzeBands: bufferPool is required"),o=n.qmfDelays;return function(r){var e=tr(r,o.lowBand,n.qmfWorkBuffers);o.lowBand=e.newDelay;var t=tr(e.lowBand,o.midBand,n.qmfWorkBuffers);o.midBand=t.newDelay;var a=n.qmfWorkBuffers.highBandDelay[e.highBand.length];a.set(o.highBand),a.set(e.highBand,o.highBand.length);var i=a.slice(0,e.highBand.length);return o.highBand=a.slice(e.highBand.length),{bands:[t.lowBand,t.highBand,i]}}}function ar(r){return ar="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},ar(r)}function ir(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,ur(n.key),n)}}function ur(r){var e=function(r,e){if("object"!=ar(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=ar(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==ar(e)?e:e+""}var fr=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:"fft",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 f=[r[a],r[o]];r[o]=f[0],r[a]=f[1];var l=[e[a],e[o]];e[o]=l[0],e[a]=l[1]}}for(var c=2;c<=t;c<<=1)for(var s=c>>1,h=-2*Math.PI/c,y=Math.cos(h),v=Math.sin(h),d=0;d<t;d+=c)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,P=k*b+O*p;r[w]=S+j,e[w]=A+P,r[g]=S-j,e[g]=A-P;var F=p*y-b*v;b=p*v+b*y,p=F}}}}],(e=null)&&ir(r.prototype,e),t&&ir(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function lr(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=cr(r),o=cr(e),a=Math.abs(n-o),i=sr(r),u=sr(e),f=Math.abs(i-u),l=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:f,energyChange:l}}function cr(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 sr(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 hr(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}(lr(r,e));return n>t}function yr(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=[w,g,S];return function(r){var e,t=r.bands;return e=a.fixedBlockModes?a.fixedBlockModes: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)),fr.fft(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]),n=hr(t,o.transientDetection[e],a.transientThresholdLow);return o.transientDetection[e]=t,n*Math.max(e+1,2)}),{bands:t,blockModes:e}}}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 dr(r,e,t){return e=br(e),function(r,e){if(e&&("object"==vr(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,pr()?Reflect.construct(e,t||[],br(r).constructor):e.apply(r,t))}function pr(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(r){}return(pr=function(){return!!r})()}function br(r){return br=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},br(r)}function mr(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&&wr(r,e)}function wr(r,e){return wr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},wr(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,Ar(n.key),n)}}function Sr(r,e,t){return e&&gr(r.prototype,e),t&&gr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function Ar(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+""}function kr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var Or=Sr(function r(e,t){kr(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)}}),jr=function(r){function e(r,t){return kr(this,e),dr(this,e,[r,t])}return mr(e,r),Sr(e,[{key:"transform",value:function(r){var e,n,o,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=null!==(e=null==a?void 0:a[this.fftSize])&&void 0!==e?e:t("MDCT.transform: mdctBuffers[".concat(this.fftSize,"] is required")),u=null!==(n=null==i?void 0:i.real)&&void 0!==n?n:t("MDCT.transform: mdctBuffers[".concat(this.fftSize,"].real is required")),f=null!==(o=null==i?void 0:i.imag)&&void 0!==o?o:t("MDCT.transform: mdctBuffers[".concat(this.fftSize,"].imag is required")),l=this.quarterSize,c=3*l;u.fill(0),f.fill(0);for(var s=0;s<l;s+=2){var h=c+s,y=l+s,v=l-1-s,d=r[c-1-s]+r[h],p=r[y]-r[v],b=this.sinCosTable[s],m=this.sinCosTable[s+1];u[s>>1]=d*b+p*m,f[s>>1]=p*b-d*m}for(var w=l;w<this.halfSize;w+=2){var g=w>>1,S=w-l,A=l+w,k=5*l-1-w,O=r[c-1-w]-r[S],j=r[A]+r[k],P=this.sinCosTable[w],F=this.sinCosTable[w+1];u[g]=O*P+j*F,f[g]=j*P-O*F}fr.fft(u,f);for(var T=new Float32Array(this.halfSize),B=0;B<this.fftSize;B++){var M=this.sinCosTable[2*B],C=this.sinCosTable[2*B+1],I=u[B],E=f[B];T[2*B]=-I*M-E*C,T[this.halfSize-1-2*B]=-I*C+E*M}return T}}])}(Or),Pr=function(r){function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return kr(this,e),dr(this,e,[r,t||r])}return mr(e,r),Sr(e,[{key:"transform",value:function(r){var e,n,o,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=null!==(e=null==a?void 0:a[this.fftSize])&&void 0!==e?e:t("IMDCT.transform: mdctBuffers[".concat(this.fftSize,"] is required")),u=null!==(n=null==i?void 0:i.real)&&void 0!==n?n:t("IMDCT.transform: mdctBuffers[".concat(this.fftSize,"].real is required")),f=null!==(o=null==i?void 0:i.imag)&&void 0!==o?o:t("IMDCT.transform: mdctBuffers[".concat(this.fftSize,"].imag is required")),l=this.quarterSize,c=3*l;u.fill(0),f.fill(0);for(var s=0;s<this.fftSize;s++){var h=2*s,y=-r[h],v=-r[this.halfSize-1-h],d=this.sinCosTable[h],p=this.sinCosTable[h+1];u[s]=v*p+y*d,f[s]=v*d-y*p}fr.fft(u,f);for(var b=new Float32Array(this.size),m=0;m<this.fftSize/2;m++){var w=2*m,g=this.sinCosTable[w],S=this.sinCosTable[w+1],A=u[m],k=f[m],O=A*g+k*S,j=A*S-k*g;b[c-1-w]=O,b[c+w]=O,b[l+w]=j,b[l-1-w]=-j}for(var P=this.fftSize/2;P<this.fftSize;P++){var F=2*(P-this.fftSize/2)+l,T=2*P,B=this.sinCosTable[T],M=this.sinCosTable[T+1],C=u[P],I=f[P],E=C*B+I*M,x=C*M-I*B;b[c-1-F]=E,b[F-l]=-E,b[l+F]=x,b[5*l-1-F]=x}return b}}])}(Or),Fr=new jr(h,.5),Tr=new jr(y,.5),Br=new jr(v,1),Mr=new Pr(h,8*h),Cr=new Pr(y,8*y),Ir=new Pr(v,4*v);function Er(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],f=r[a],l=e[n-1-a];o[a]=f*u-l*i,o[2*n-1-a]=f*i+l*u}return o}function xr(r,e){for(var t=e[r.length],n=0;n<r.length;n++)t[n]=r[r.length-1-n];return 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,a=[Tr,Tr,Br];function i(r,e,t,o){var i=_[e];return 0===t?function(r,e,t,o,a){var i=2===e?v:y,f=n.transformBuffers[i];f.fill(0),f.set(a,t.windowStart),u(r,a,t.size),f.set(r,t.windowStart+p);var l=o.transform(f,n.mdctBuffers);e>0&&(l=xr(l,n.reversalBuffers));return l}(r,e,i,a[e],o):function(r,e,t,o){for(var a=1<<(256===t.size?3:2),i=new Float32Array(t.size),f=0;f<a;f++){var l=f*d,c=r.subarray(l,l+d),s=n.transformBuffers[h];s.fill(0),s.set(o,0),u(c,o,d),s.set(c,p);var y=Fr.transform(s,n.mdctBuffers);e>0&&(y=xr(y,n.reversalBuffers)),i.set(y,l)}return i}(r,e,i,o)}function u(r,e,t){for(var n=t-p,o=0;o<p;o++){var a=r[n+o];e[o]=E[o]*a,r[n+o]=a*E[31-o]}}return function(r){var e=r.bands,t=r.blockModes,n=r.originalFrame,a=new Float32Array(512);return e.forEach(function(r,e){var n=i(r,e,t[e],o[e]);a.set(n,function(r){return 0===r?0:1===r?128:256}(e))}),{bands:e,coefficients:a,blockModes:t,originalFrame:n}}}function qr(r){var e=n(r,or,yr,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){Lr(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 Lr(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=[],f=!0,l=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);f=!0);}catch(r){l=!0,o=r}finally{try{if(!f&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(r,e)||function(r,e){if(r){if("string"==typeof r)return Nr(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)?Nr(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 Nr(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 Hr(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 Wr=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)}}}])&&Hr(r.prototype,e),t&&Hr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function Vr(r,e,t){var n=r.length,o=new Int32Array(n);if(0===t||0===e)return o.fill(0,0,n),o;for(var a=L[e],i=(1<<t-j)-1,u=i/a,f=i,l=-i,c=0;c<n;c++){var s=r[c]*u,h=s+(s>=0?.5:-.5)|0;o[c]=h>f?f:h<l?l:h}return o}function $r(r,e,t){if(0===t||0===e)return new Float32Array(r.length);for(var n=L[e],o=(1<<t-j)-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=[],f=0;f<n;f++){var l=e[f].subarray(0,t[f]),c=U[a[f]];u.push(Vr(l,o[f],c))}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.qmfDelays={lowBand:new Float32Array(m),midBand:new Float32Array(m),highBand: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)]}),ee=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.qmfWorkBuffers={delay:{128:new Float32Array(m+128),256:new Float32Array(m+256),512:new Float32Array(m+512)},highBandDelay:{128:new Float32Array(167),256:new Float32Array(295)}},this.mdctBuffers={16:{real:new Float32Array(16),imag:new Float32Array(16)},64:{real:new Float32Array(64),imag:new Float32Array(64)},128:{real:new Float32Array(128),imag:new Float32Array(128)}},this.reversalBuffers={32:new Float32Array(32),128:new Float32Array(128),256:new Float32Array(256)}}),te=Kr(function r(){Zr(this,r),Object.assign(this,new re,new ee)});function ne(){return n({options:arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Wr,bufferPool:arguments.length>1&&void 0!==arguments[1]?arguments[1]:new te},qr,er,Qr)}function oe(){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 f=U[o[u]],l=0;u>=M[0]&&(l=1),u>=M[1]&&(l=2);var c=0===i[l]?C[u]:I[u];if(f>0){var s=$r(a[u],n[u],f);e.set(s,c)}}return{coefficients:e,blockModes:i}}}function ae(r){var e,n=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:t("synthesizeSpectrum: bufferPool is required"),o=n.imdctOverlap,a=[Cr,Cr,Ir];function i(r,e,t,o,i){return 0===t?function(r,e,t,o,a){var i=r;e>0&&(i=xr(r,n.reversalBuffers));var u=a.transform(i,n.mdctBuffers),f=u.length/4,l=n.transformBuffers[v];l.fill(0);for(var c=0;c<o.size;c++)l[c]=u[f+c];var s=t.slice(2*o.size-b,2*o.size),h=Er(s.slice(0,b),l.slice(0,b),E);t.set(h,0);for(var y=0;y<b;y++)s[y]=l[b+y];for(var d=2===e?240:112,p=0;p<d;p++)t[32+p]=l[b+p];for(var m=0;m<b;m++)t[2*o.size-b+m]=l[o.size-b+m];return t.slice(0,o.size)}(r,e,o,i,a[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),f=0,l=0,c=0;c<a;c++){var s=r.slice(l,l+d);e>0&&(s=xr(s,n.reversalBuffers));for(var h=Mr.transform(s,n.mdctBuffers),y=h.length/4,p=0;p<d;p++)i[f+p]=h[y+p];var m=Er(u.slice(0,b),i.slice(f,f+b),E);t.set(m,f);for(var w=0;w<b;w++)u[w]=i[f+b+w];f+=d,l+=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,i)}return function(r){var e=r.coefficients,t=r.blockModes;return _.map(function(r,n){var a=function(r,e){var t=[0,128,256,512];return r.subarray(t[e],t[e+1])}(e,n);return i(a,n,t[n],o[n],r)})}}function ie(r){var e,n=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:t("synthesizePcm: bufferPool is required"),o=n.qmfDelays;return function(r){var e=n.qmfWorkBuffers.highBandDelay[r[2].length];e.set(o.highBand),e.set(r[2],o.highBand.length);var t=e.slice(0,2*r[0].length);o.highBand=e.slice(2*r[0].length);var a=nr(r[0],r[1],o.midBand,n.qmfWorkBuffers);o.midBand=a.newDelay;var i=nr(a.output,t,o.lowBand,n.qmfWorkBuffers);return o.lowBand=i.newDelay,i.output}}function ue(r){return n(r,ae,ie)}function fe(){return n({bufferPool:arguments.length>0&&void 0!==arguments[0]?arguments[0]:new te},oe,ue)}function le(r){return le="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},le(r)}function ce(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,se(n.key),n)}}function se(r){var e=function(r,e){if("object"!=le(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=le(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==le(e)?e:e+""}var he=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(i),u=new DataView(a.buffer);a.set(F,0);var f=(new TextEncoder).encode(r);return a.set(f.subarray(0,Math.min(f.length,255)),4),u.setUint32(260,e,!0),a[264]=t,u.setUint32(268,o>>>0,!0),u.setUint32(272,n>>>0,!0),a}},{key:"parseHeader",value:function(r){if(r.length!==i)throw new Error("Header must be ".concat(i," bytes"));for(var e=0;e<F.length;e++)if(r[e]!==F[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:(new TextDecoder).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)&&ce(r.prototype,e),t&&ce(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 ve(r,e,t,n){if(ye(n),0!==n)for(var o=Math.floor(e/8),a=e%8,i=Number(t)>>>0,u=0;u<n&&o<r.length;){var f=8-a,l=Math.min(n-u,f),c=i>>>n-u-l&Math.pow(2,l)-1,s=Math.pow(2,l)-1<<f-l;r[o]=r[o]&~s|c<<f-l,u+=l,o++,a=0}}function de(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,f=Math.min(t-i,u),l=Math.pow(2,f)-1,c=r[n]>>u-f&l;a=a*Math.pow(2,f)+c>>>0,i+=f,n++,o=0}return a}function pe(r,e,t){if(ye(t),0===t)return 0;var n=de(r,e,t);return n>=Math.pow(2,t-1)?n-Math.pow(2,t):n}function be(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 me(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)?me(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 me(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 we(r){var e=new Uint8Array(u),t=new DataView(e.buffer),n=B.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=A,i=0;i<r.nBfu;i++)ve(e,a,r.wordLengthIndices[i],k),a+=k;for(var f=0;f<r.nBfu;f++)ve(e,a,r.scaleFactorIndices[f],O),a+=O;for(var l=0;l<r.nBfu;l++){var c=U[r.wordLengthIndices[l]];if(c>0){var s,h=be(r.quantizedCoefficients[l]);try{for(h.s();!(s=h.n()).done;){var y=s.value;ve(e,a,y<0?y+(1<<c):y,c),a+=c}}catch(r){h.e(r)}finally{h.f()}}}return e[u-3]=0,e[u-2]=0,e[u-1]=0,e}function ge(r){if(r.length!==u)throw new Error("Frame must be ".concat(u," 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=B[e>>5&7],o=A,a=new Int32Array(n),i=0;i<n;i++)a[i]=de(r,o,k),o+=k;for(var f=new Int32Array(n),l=0;l<n;l++)f[l]=de(r,o,O),o+=O;for(var c=[],s=0;s<n;s++){var h=U[a[s]],y=T[s],v=new Int32Array(y);if(h>0)for(var d=0;d<y;d++)v[d]=pe(r,o,h),o+=h;c.push(v)}return{nBfu:n,scaleFactorIndices:f,wordLengthIndices:a,quantizedCoefficients:c,blockModes:t}}function Se(){/*! 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 f=n&&n.prototype instanceof u?n:u,l=Object.create(f.prototype);return Ae(l,"_invoke",function(t,n,o){var a,u,f,l=0,c=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,f=r,h.n=t,i}};function y(t,n){for(u=t,f=n,e=0;!s&&l&&!o&&e<c.length;e++){var o,a=c[e],y=h.p,v=a[2];t>3?(o=v===n)&&(f=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,c,v){if(l>1)throw TypeError("Generator is already running");for(s&&1===c&&y(c,v),u=c,f=v;(e=u<2?r:f)||!s;){a||(u?u<3?(u>1&&(h.n=-1),y(u,f)):h.n=f:h.v=f);try{if(l=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,f)))throw TypeError("iterator result is not an object");if(!e.done)return e;f=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(f=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?f:t.call(n,h))!==i)break}catch(e){a=r,u=1,f=e}finally{l=1}}return{value:e,done:s}}}(t,o,a),!0),l}var i={};function u(){}function f(){}function l(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(Ae(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(c);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,l):(r.__proto__=l,Ae(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return f.prototype=l,Ae(s,"constructor",l),Ae(l,"constructor",f),f.displayName="GeneratorFunction",Ae(l,o,"GeneratorFunction"),Ae(s),Ae(s,o,"Generator"),Ae(s,n,function(){return this}),Ae(s,"toString",function(){return"[object Generator]"}),(Se=function(){return{w:a,m:h}})()}function Ae(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}Ae=function(r,e,t,n){function a(e,t){Ae(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))},Ae(r,e,t,n)}function ke(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=[],f=!0,l=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);f=!0);}catch(r){l=!0,o=r}finally{try{if(!f&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(r,e)||je(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 Oe(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=je(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){if(r){if("string"==typeof r)return Pe(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)?Pe(r,e):void 0}}function Pe(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,e,t){for(var n=0;n<t.length;n++)r.setUint8(e+n,t.charCodeAt(n))}function Te(r){var e,t=r.reduce(function(r,e){return r+e.length},0),n=new Float32Array(t),o=0,a=Oe(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 Be(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a;return Se().m(function t(){var n,o,a,i,u,f,l,c,s,h,y;return Se().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=ke(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=ke(r,2),f=u[0],l=u[1],c=f.length,s=0;case 6:if(!(s<c)){t.n=8;break}return h=new Float32Array(e),y=new Float32Array(e),h.set(f.subarray(s,s+e)),y.set(l.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 Me(r){var e=Math.max(-1,Math.min(1,r));return e<0?32768*e:32767*e}function Ce(r){var e=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).sampleRate,t=void 0===e?o: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=Oe(r);try{for(u.s();!(i=u.n()).done;){var f=i.value;n.setInt16(o,Me(f[a]),!0),o+=2}}catch(r){u.e(r)}finally{u.f()}}return t}(r),a=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),f=new DataView(u.buffer);return Fe(f,0,"RIFF"),f.setUint32(4,36+i,!0),Fe(f,8,"WAVE"),Fe(f,12,"fmt "),f.setUint32(16,16,!0),f.setUint16(20,1,!0),f.setUint16(22,n,!0),f.setUint32(24,t,!0),f.setUint32(28,o,!0),f.setUint16(32,a,!0),f.setUint16(34,16,!0),Fe(f,36,"data"),f.setUint32(40,i,!0),u}({sampleCount:r[0].length,sampleRate:t,channels:r.length}),i=new Uint8Array(a.length+n.length);return i.set(a),i.set(n,a.length),i}function Ie(r){return Ie="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},Ie(r)}var Ee=["title"];function xe(r){return function(r){if(Array.isArray(r))return Le(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||Ue(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 ze(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 qe(){/*! 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 f=n&&n.prototype instanceof u?n:u,l=Object.create(f.prototype);return De(l,"_invoke",function(t,n,o){var a,u,f,l=0,c=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,f=r,h.n=t,i}};function y(t,n){for(u=t,f=n,e=0;!s&&l&&!o&&e<c.length;e++){var o,a=c[e],y=h.p,v=a[2];t>3?(o=v===n)&&(f=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,c,v){if(l>1)throw TypeError("Generator is already running");for(s&&1===c&&y(c,v),u=c,f=v;(e=u<2?r:f)||!s;){a||(u?u<3?(u>1&&(h.n=-1),y(u,f)):h.n=f:h.v=f);try{if(l=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,f)))throw TypeError("iterator result is not an object");if(!e.done)return e;f=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(f=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?f:t.call(n,h))!==i)break}catch(e){a=r,u=1,f=e}finally{l=1}}return{value:e,done:s}}}(t,o,a),!0),l}var i={};function u(){}function f(){}function l(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(De(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(c);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,l):(r.__proto__=l,De(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return f.prototype=l,De(s,"constructor",l),De(l,"constructor",f),f.displayName="GeneratorFunction",De(l,o,"GeneratorFunction"),De(s),De(s,o,"Generator"),De(s,n,function(){return this}),De(s,"toString",function(){return"[object Generator]"}),(qe=function(){return{w:a,m:h}})()}function De(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}De=function(r,e,t,n){function a(e,t){De(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))},De(r,e,t,n)}function _e(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=[],f=!0,l=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);f=!0);}catch(r){l=!0,o=r}finally{try{if(!f&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(r,e)||Ue(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){if(r){if("string"==typeof r)return Le(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)?Le(r,e):void 0}}function Le(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 Re(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Ne(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,Ge(n.key),n)}}function He(r,e,t){return e&&Ne(r.prototype,e),t&&Ne(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function Ge(r){var e=function(r,e){if("object"!=Ie(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Ie(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Ie(e)?e:e+""}function We(r,e,t,n,o,a,i){try{var u=r[a](i),f=u.value}catch(r){return void t(r)}u.done?e(f):Promise.resolve(f).then(n,o)}function Ve(r){return function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(r){We(a,n,o,i,u,"next",r)}function u(r){We(a,n,o,i,u,"throw",r)}i(void 0)})}}function $e(r){return new Je(r,0)}function Qe(r){return function(){return new Ye(r.apply(this,arguments))}}function Ye(r){var e,t;function n(e,t){try{var a=r[e](t),i=a.value,u=i instanceof Je;Promise.resolve(u?i.v:i).then(function(t){if(u){var f="return"===e&&i.k?e:"next";if(!i.k||t.done)return n(f,t);t=r[f](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 Je(r,e){this.v=r,this.k=e}function Ke(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 Xe(e.call(r));t="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function Xe(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 Xe=function(r){this.s=r,this.n=r.next},Xe.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 Xe(r)}function Ze(r){if(1!==r&&2!==r)throw new Error("Unsupported channel count: ".concat(r))}function rt(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!==a}))throw new RangeError("ATRAC1 streaming requires exactly ".concat(a," samples per channel"))}function et(){return{nBfu:0,blockModes:[0,0,0],scaleFactorIndices:new Int32Array(0),wordLengthIndices:new Int32Array(0),quantizedCoefficients:[]}}function tt(r){return nt.apply(this,arguments)}function nt(){return(nt=Ve(qe().m(function r(e){var t,n,o,a,i,u,f,l;return qe().w(function(r){for(;;)switch(r.p=r.n){case 0:t=[],n=!1,o=!1,r.p=1,i=Ke(e);case 2:return r.n=3,i.next();case 3:if(!(n=!(u=r.v).done)){r.n=5;break}f=u.value,t.push(f);case 4:n=!1,r.n=2;break;case 5:r.n=7;break;case 6:r.p=6,l=r.v,o=!0,a=l;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)}Ye.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},Ye.prototype.next=function(r){return this._invoke("next",r)},Ye.prototype.throw=function(r){return this._invoke("throw",r)},Ye.prototype.return=function(r){return this._invoke("return",r)};var ot=function(){return He(function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Re(this,r);var t=e.channelCount,n=void 0===t?1:t,o=e.onProgress,a=e.encoderOptions;Ze(n);var i=a||new Wr;this.channelCount=n,this.onProgress=o,this.frameIndex=0,this.sampleCount=0,this.finalized=!1,this.leftEncoder=ne(i),this.rightEncoder=2===n?ne(i):null},[{key:"frames",value:function(r){var e=this;return Qe(qe().m(function t(){var n,o,i,u,f,l,c,s,h,y;return qe().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=Ke(r);case 3:return t.n=4,$e(u.next());case 4:if(!(n=!(f=t.v).done)){t.n=10;break}if(rt(l=f.value,e.channelCount),1!==e.channelCount){t.n=6;break}return t.n=5,e.leftEncoder(l);case 5:t.n=8;break;case 6:return c=_e(l,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+=a,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,i=y;case 12:if(t.p=12,t.p=13,!n||null==u.return){t.n=14;break}return t.n=14,$e(u.return());case 14:if(t.p=14,!o){t.n=15;break}throw i;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:qe().m(function r(){var e,t;return qe().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(a),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)})}])}(),at=function(){return He(function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Re(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,f=void 0===u?Number.POSITIVE_INFINITY:u;Ze(n),this.channelCount=n,this.onProgress=o,this.frameIndex=0,this.primingSampleCount=i,this.sampleCount=f,this.timelinePosition=0,this.emittedSamples=0,this.leftFrame=null,this.leftDecoder=fe(),this.rightDecoder=2===n?fe():null},[{key:"frames",value:function(r){var e=this;return Qe(qe().m(function t(){var n,o,a,i,u,f,l;return qe().w(function(t){for(;;)switch(t.p=t.n){case 0:n=!1,o=!1,t.p=1,i=Ke(r);case 2:return t.n=3,$e(i.next());case 3:if(!(n=!(u=t.v).done)){t.n=9;break}if(f=u.value,1!==e.channelCount){t.n=5;break}return t.n=4,e.trim(e.leftDecoder(f));case 4:e.reportProgress(),t.n=8;break;case 5:if(null!==e.leftFrame){t.n=6;break}e.leftFrame=f,t.n=8;break;case 6:return t.n=7,e.trim([e.leftDecoder(e.leftFrame),e.rightDecoder(f)]);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,l=t.v,o=!0,a=l;case 11:if(t.p=11,t.p=12,!n||null==i.return){t.n=13;break}return t.n=13,$e(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:qe().m(function r(){return qe().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(et())]);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(a-e,t));return this.timelinePosition+=a,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 it(r){return new ot(r)}function ut(r){return new at(r)}function ft(r){return lt.apply(this,arguments)}function lt(){return lt=Ve(qe().m(function r(e){var t,n,o,a,i,f,l,c,s,h=arguments;return qe().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=ze(t,Ee),i=it({channelCount:e.length,encoderOptions:new Wr(a)}),f=i.frames(Be(e)),r.n=2,tt(f);case 2:return(l=r.v).push.apply(l,xe(i.finish())),c=he.createHeader(o,l.length,e.length,e[0].length,266),(s=new Uint8Array(c.length+l.length*u)).set(c),l.forEach(function(r,e){s.set(we(r),c.length+e*u)}),r.a(2,s)}},r)})),lt.apply(this,arguments)}function ct(r){return st.apply(this,arguments)}function st(){return(st=Ve(qe().m(function r(e){var t,n,o,a,f,l,c;return qe().w(function(r){for(;;)switch(r.n){case 0:if(!(e instanceof Blob)){r.n=2;break}return l=Uint8Array,r.n=1,e.arrayBuffer();case 1:c=r.v,t=new l(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=he.parseHeader(t.subarray(0,i)),o=ut({channelCount:n.channelCount,primingSampleCount:n.primingSampleCount,sampleCount:n.sampleCount}),a=Qe(qe().m(function r(){var e;return qe().w(function(r){for(;;)switch(r.n){case 0:e=i;case 1:if(!(e+u<=t.length)){r.n=3;break}return r.n=2,ge(t.subarray(e,e+u));case 2:e+=u,r.n=1;break;case 3:return r.a(2)}},r)}))(),r.n=6,tt(o.frames(a));case 6:if((f=r.v).push.apply(f,xe(o.finish())),1!==n.channelCount){r.n=7;break}return r.a(2,[Te(f)]);case 7:return r.a(2,[Te(f.map(function(r){return _e(r,1)[0]})),Te(f.map(function(r){return _e(r,2)[1]}))])}},r)}))).apply(this,arguments)}function ht(r){return ht="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},ht(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=[],f=!0,l=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;f=!1}else for(;!(f=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);f=!0);}catch(r){l=!0,o=r}finally{try{if(!f&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(r,e)||dt(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 vt(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=dt(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 dt(r,e){if(r){if("string"==typeof r)return pt(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)?pt(r,e):void 0}}function pt(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 bt(r,e,t,n,o,a,i){try{var u=r[a](i),f=u.value}catch(r){return void t(r)}u.done?e(f):Promise.resolve(f).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){bt(a,n,o,i,u,"next",r)}function u(r){bt(a,n,o,i,u,"throw",r)}i(void 0)})}}function wt(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(ht(r)+" is not iterable")}function gt(){/*! 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 f=n&&n.prototype instanceof u?n:u,l=Object.create(f.prototype);return St(l,"_invoke",function(t,n,o){var a,u,f,l=0,c=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,f=r,h.n=t,i}};function y(t,n){for(u=t,f=n,e=0;!s&&l&&!o&&e<c.length;e++){var o,a=c[e],y=h.p,v=a[2];t>3?(o=v===n)&&(f=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,c,v){if(l>1)throw TypeError("Generator is already running");for(s&&1===c&&y(c,v),u=c,f=v;(e=u<2?r:f)||!s;){a||(u?u<3?(u>1&&(h.n=-1),y(u,f)):h.n=f:h.v=f);try{if(l=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,f)))throw TypeError("iterator result is not an object");if(!e.done)return e;f=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(f=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?f:t.call(n,h))!==i)break}catch(e){a=r,u=1,f=e}finally{l=1}}return{value:e,done:s}}}(t,o,a),!0),l}var i={};function u(){}function f(){}function l(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(St(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(c);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,l):(r.__proto__=l,St(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return f.prototype=l,St(s,"constructor",l),St(l,"constructor",f),f.displayName="GeneratorFunction",St(l,o,"GeneratorFunction"),St(s),St(s,o,"Generator"),St(s,n,function(){return this}),St(s,"toString",function(){return"[object Generator]"}),(gt=function(){return{w:a,m:h}})()}function St(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}St=function(r,e,t,n){function a(e,t){St(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))},St(r,e,t,n)}function At(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,kt(n.key),n)}}function kt(r){var e=function(r,e){if("object"!=ht(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=ht(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==ht(e)?e:e+""}function Ot(r){return function(){return new jt(r.apply(this,arguments))}}function jt(r){var e,t;function n(e,t){try{var a=r[e](t),i=a.value,u=i instanceof Ft;Promise.resolve(u?i.v:i).then(function(t){if(u){var f="return"===e&&i.k?e:"next";if(!i.k||t.done)return n(f,t);t=r[f](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 Pt(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 Ft(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 Ft(r,e){this.v=r,this.k=e}function Tt(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 Bt(e.call(r));t="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function Bt(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 Bt=function(r){this.s=r,this.n=r.next},Bt.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 Bt(r)}jt.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},jt.prototype.next=function(r){return this._invoke("next",r)},jt.prototype.throw=function(r){return this._invoke("throw",r)},jt.prototype.return=function(r){return this._invoke("return",r)};var Mt=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 ft(r,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}},{key:"decodeAeaPcm",value:function(r){return ct(r)}},{key:"encodeStream",value:function(r){return Ot(function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return gt().m(function t(){var n;return gt().w(function(t){for(;;)switch(t.n){case 0:return n=it(e),t.d(wt(Pt(Tt(n.frames(r)))),1);case 1:return t.d(wt(Pt(Tt(n.finish()))),2);case 2:return t.a(2)}},t)})()}).apply(this,arguments)}},{key:"decodeStream",value:function(r){return Ot(function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return gt().m(function t(){var n;return gt().w(function(t){for(;;)switch(t.n){case 0:return n=ut(e),t.d(wt(Pt(Tt(n.frames(r)))),1);case 1:return t.d(wt(Pt(Tt(n.finish()))),2);case 2:return t.a(2)}},t)})()}).apply(this,arguments)}},{key:"frameBufferToFrames",value:gt().m(function r(e,t){return gt().w(function(r){for(;;)switch(r.n){case 0:return r.d(wt(Be(e,t)),1);case 1:return r.a(2)}},r)})},{key:"collectFrames",value:(c=mt(gt().m(function r(e){var t,n,o,a,i,u,f,l;return gt().w(function(r){for(;;)switch(r.p=r.n){case 0:t=[],n=!1,o=!1,r.p=1,i=Tt(e);case 2:return r.n=3,i.next();case 3:if(!(n=!(u=r.v).done)){r.n=5;break}f=u.value,t.push(f);case 4:n=!1,r.n=2;break;case 5:r.n=7;break;case 6:r.p=6,l=r.v,o=!0,a=l;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:(l=mt(gt().m(function r(e){var t,n,o,i,u,f,l,c,s,h,y,v,d,p,b,m,w,g=arguments;return gt().w(function(r){for(;;)switch(r.p=r.n){case 0:o=(n=g.length>1&&void 0!==g[1]?g[1]:{}).title,i=void 0===o?"encoded by atrac1.js":o,u=n.channelCount,f=void 0===u?1:u,l=[],c=!1,s=!1,r.p=1,y=Tt(e);case 2:return r.n=3,y.next();case 3:if(!(c=!(v=r.v).done)){r.n=5;break}d=v.value,l.push(we(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==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=l.length/f,b=null!==(t=n.sampleCount)&&void 0!==t?t:Math.max(0,p-1)*a,m=he.createHeader(i,l.length,f,b,266),r.a(2,new Blob([m].concat(l),{type:"application/octet-stream"}))}},r,null,[[8,,9,11],[1,6,7,12]])})),function(r){return l.apply(this,arguments)})},{key:"parseAeaBlob",value:(f=mt(gt().m(function r(e){var t,n,o,a,f,l;return gt().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,i)),o=he.parseHeader(n),a=[],f=i;f<t.byteLength;)(l=new Uint8Array(t.slice(f,f+u))).length===u&&a.push(l),f+=u;return r.a(2,{info:o,frameData:a})}},r)})),function(r){return f.apply(this,arguments)})},{key:"deserializedFrameStream",value:gt().m(function r(e){var t,n,o,a;return gt().w(function(r){for(;;)switch(r.p=r.n){case 0:t=vt(e),r.p=1,t.s();case 2:if((n=t.n()).done){r.n=4;break}return o=n.value,r.n=3,ge(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]:o;if(1===t)e=[Te(r)];else{if(2!==t)throw new Error("Unsupported channel count: ".concat(t));e=[Te(r.map(function(r){return yt(r,1)[0]})),Te(r.map(function(r){return yt(r,2)[1]}))]}return new Blob([Ce(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]:o;return r.createPcmWaveBlob(e,t,n)}},{key:"assemblePcmFrames",value:function(r,e){if(1===e)return Te(r);if(2!==e)throw new Error("Unsupported channel count: ".concat(e));for(var t=Te(r.map(function(r){return yt(r,1)[0]})),n=Te(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&&At(e.prototype,t),n&&At(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t,n,f,l,c}();return e})());
2
2
  //# sourceMappingURL=carta1.min.js.map