carta1 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ /** Carta1 Audio Codec - Reusable typed-array ownership. */
2
+
3
+ import {
4
+ EncoderState,
5
+ SoundUnitAllocationScratch,
6
+ TransientAnalysisScratch,
7
+ } from './encoder.js'
8
+ import { DecoderState } from './decoder.js'
9
+ import { MdctScratch, QmfScratch } from './transform.js'
10
+
11
+ /**
12
+ * Own reusable codec storage according to the lifetime of its contents.
13
+ *
14
+ * - `state` is committed history with meaning across chronological frames;
15
+ * - `scratch` is private to one algorithm call and carries no stage meaning.
16
+ */
17
+ export class BufferPool {
18
+ /** Allocate neutral encoder and decoder storage. */
19
+ constructor() {
20
+ this.encoder = {
21
+ state: new EncoderState(),
22
+ scratch: {
23
+ qmf: new QmfScratch(),
24
+ transient: new TransientAnalysisScratch(),
25
+ mdct: new MdctScratch(),
26
+ allocation: new SoundUnitAllocationScratch(),
27
+ },
28
+ }
29
+
30
+ this.decoder = {
31
+ state: new DecoderState(),
32
+ scratch: {
33
+ mdct: new MdctScratch(),
34
+ qmf: new QmfScratch(),
35
+ },
36
+ }
37
+ }
38
+ }
@@ -0,0 +1,61 @@
1
+ /** Fixed reusable transform storage for ATRAC1 QMF and MDCT kernels. */
2
+
3
+ import {
4
+ MDCT_SIZE_LONG_HIGH,
5
+ MDCT_SIZE_LONG_LOW_MID,
6
+ MDCT_SIZE_SHORT,
7
+ QMF_ANALYSIS_DELAY_SAMPLES,
8
+ QMF_BANDS,
9
+ QMF_HIGH_BAND_DELAY,
10
+ } from '../core/constants.js'
11
+
12
+ /** Reusable windows and polyphase accumulators for two-band QMF stages. */
13
+ export class QmfScratch {
14
+ /** Allocate sliding analysis windows, high-band delay windows, and work rows. */
15
+ constructor() {
16
+ this.analysisWindows = {
17
+ 128: new Float32Array(QMF_ANALYSIS_DELAY_SAMPLES + 128),
18
+ 256: new Float32Array(QMF_ANALYSIS_DELAY_SAMPLES + 256),
19
+ 512: new Float32Array(QMF_ANALYSIS_DELAY_SAMPLES + 512),
20
+ }
21
+ this.highBandWindows = {
22
+ 128: new Float32Array(QMF_HIGH_BAND_DELAY + 128),
23
+ 256: new Float32Array(QMF_HIGH_BAND_DELAY + 256),
24
+ }
25
+ this.polyphase = new Float32Array(QMF_BANDS)
26
+ this.extended = new Float64Array(QMF_BANDS)
27
+ this.bands = new Float32Array(QMF_BANDS)
28
+ }
29
+ }
30
+
31
+ /** Fixed work vectors for forward MDCT and inverse IMDCT band transforms. */
32
+ export class MdctScratch {
33
+ /** Allocate input/output framing buffers, complex FFT rows, and reversal buffers. */
34
+ constructor() {
35
+ this.transformBuffers = {
36
+ 64: new Float32Array(MDCT_SIZE_SHORT),
37
+ 128: new Float32Array(128),
38
+ 256: new Float32Array(MDCT_SIZE_LONG_LOW_MID),
39
+ 512: new Float32Array(MDCT_SIZE_LONG_HIGH),
40
+ }
41
+ this.fftBuffers = {
42
+ 16: {
43
+ real: new Float32Array(16),
44
+ imaginary: new Float32Array(16),
45
+ },
46
+ 64: {
47
+ real: new Float32Array(64),
48
+ imaginary: new Float32Array(64),
49
+ },
50
+ 128: {
51
+ real: new Float32Array(128),
52
+ imaginary: new Float32Array(128),
53
+ },
54
+ }
55
+ this.reversalBuffers = {
56
+ 32: new Float32Array(32),
57
+ 128: new Float32Array(128),
58
+ 256: new Float32Array(256),
59
+ }
60
+ }
61
+ }
@@ -85,10 +85,9 @@ export function serializeFrame(frameData) {
85
85
  }
86
86
  }
87
87
 
88
- // Zero padding at end
89
- buffer[SOUND_UNIT_SIZE - 3] = 0
90
- buffer[SOUND_UNIT_SIZE - 2] = 0
91
- buffer[SOUND_UNIT_SIZE - 1] = 0
88
+ // Mirror 16-bit Sound-Unit header into final two trailer bytes
89
+ buffer[SOUND_UNIT_SIZE - 2] = buffer[0]
90
+ buffer[SOUND_UNIT_SIZE - 1] = buffer[1]
92
91
 
93
92
  return buffer
94
93
  }
@@ -53,7 +53,9 @@ export function synthesizeSpectrum(context) {
53
53
  const bufferPool =
54
54
  context?.bufferPool ??
55
55
  throwError('synthesizeSpectrum: bufferPool is required')
56
- const overlapBuffers = bufferPool.imdctOverlap
56
+ const state = bufferPool.decoder.state
57
+ const scratch = bufferPool.decoder.scratch.mdct
58
+ const overlapBuffers = state.imdctOverlap
57
59
 
58
60
  /**
59
61
  * @param {Float32Array} coefficients
@@ -100,15 +102,15 @@ export function synthesizeSpectrum(context) {
100
102
  ) {
101
103
  let blockSpectrum = coefficients
102
104
  if (bandIndex > 0) {
103
- blockSpectrum = reverseSpectrum(coefficients, bufferPool.reversalBuffers)
105
+ blockSpectrum = reverseSpectrum(coefficients, scratch.reversalBuffers)
104
106
  }
105
107
 
106
108
  const inverse = transformFunction.transform(
107
109
  blockSpectrum,
108
- bufferPool.mdctBuffers
110
+ scratch.fftBuffers
109
111
  )
110
112
  const inverseStart = inverse.length / 4
111
- const inverseBuffer = bufferPool.transformBuffers[MAX_MDCT_SIZE]
113
+ const inverseBuffer = scratch.transformBuffers[MAX_MDCT_SIZE]
112
114
  inverseBuffer.fill(0)
113
115
 
114
116
  for (let i = 0; i < config.size; i++) {
@@ -152,7 +154,7 @@ export function synthesizeSpectrum(context) {
152
154
  */
153
155
  function inverseShortBlocks(coefficients, bandIndex, overlapBuffer, config) {
154
156
  const numBlocks = 1 << (config.size === 256 ? 3 : 2)
155
- const inverseBuffer = bufferPool.transformBuffers[MAX_MDCT_SIZE]
157
+ const inverseBuffer = scratch.transformBuffers[MAX_MDCT_SIZE]
156
158
  inverseBuffer.fill(0)
157
159
 
158
160
  const previous = overlapBuffer.slice(
@@ -168,16 +170,10 @@ export function synthesizeSpectrum(context) {
168
170
  position + MDCT_SHORT_BLOCK_SIZE
169
171
  )
170
172
  if (bandIndex > 0) {
171
- blockSpectrum = reverseSpectrum(
172
- blockSpectrum,
173
- bufferPool.reversalBuffers
174
- )
173
+ blockSpectrum = reverseSpectrum(blockSpectrum, scratch.reversalBuffers)
175
174
  }
176
175
 
177
- const inverse = shortImdct.transform(
178
- blockSpectrum,
179
- bufferPool.mdctBuffers
180
- )
176
+ const inverse = shortImdct.transform(blockSpectrum, scratch.fftBuffers)
181
177
  const inverseStart = inverse.length / 4
182
178
  for (let i = 0; i < MDCT_SHORT_BLOCK_SIZE; i++) {
183
179
  inverseBuffer[start + i] = inverse[inverseStart + i]
@@ -36,8 +36,9 @@ function synthesizePair(bands, state, scratch) {
36
36
  export function synthesizePcm(context) {
37
37
  const bufferPool =
38
38
  context?.bufferPool ?? throwError('synthesizePcm: bufferPool is required')
39
- const states = bufferPool.qmfSynthesisStates
40
- const scratch = bufferPool.qmfScratch
39
+ const state = bufferPool.decoder.state
40
+ const states = state.qmfSynthesisStates
41
+ const scratch = bufferPool.decoder.scratch.qmf
41
42
 
42
43
  /**
43
44
  * @param {Array<Float32Array>} bands
@@ -45,14 +46,14 @@ export function synthesizePcm(context) {
45
46
  */
46
47
  return (bands) => {
47
48
  const delayedHigh = scratch.highBandWindows[bands[2].length]
48
- delayedHigh.set(bufferPool.qmfHighBandDelay)
49
- delayedHigh.set(bands[2], bufferPool.qmfHighBandDelay.length)
49
+ delayedHigh.set(state.qmfHighBandDelay)
50
+ delayedHigh.set(bands[2], state.qmfHighBandDelay.length)
50
51
 
51
52
  const highBand = delayedHigh.slice(0, bands[0].length * 2)
52
- bufferPool.qmfHighBandDelay.set(
53
+ state.qmfHighBandDelay.set(
53
54
  delayedHigh.subarray(
54
55
  bands[0].length * 2,
55
- bands[0].length * 2 + bufferPool.qmfHighBandDelay.length
56
+ bands[0].length * 2 + state.qmfHighBandDelay.length
56
57
  )
57
58
  )
58
59
 
@@ -1,2 +1,2 @@
1
- (()=>{"use strict";let r={};var e=44100,t=512,n=2048,o=212,a=32,i=32,u=16,c=46,l=24,f=15,s=new Uint8Array([0,8,0,0]),h=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]),y=new Int32Array([20,28,32,36,40,44,48,52]),v=new Int32Array([20,36,52]),p=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]),d=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]),b=function(){for(var r=new Float64Array(32),e=0;e<32;e++)r[e]=Math.sin((e+.5)*Math.PI/64);return r}(),m=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]),w=function(){for(var r=new Float32Array(48),e=0;e<24;e++)r[e]=2*m[e],r[47-e]=2*m[e];return r}(),g=function(){for(var r=new Float32Array(24),e=0;e<24;e++)r[e]=w[2*e];return r}(),S=function(){for(var r=new Float32Array(24),e=0;e<24;e++)r[e]=w[2*e+1];return r}(),A=[{size:128,longMdctSize:256,windowStart:48,analysisScale:.5},{size:128,longMdctSize:256,windowStart:48,analysisScale:.5},{size:256,longMdctSize:512,windowStart:112,analysisScale:1}],k=new Int32Array([0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),O=function(){for(var r=new Float64Array(64),e=0;e<64;e++)r[e]=Math.pow(2,e/3-21);return r}(),j=function(){for(var r=k[15],e=new Float64Array(r+1),t=0;t<=r;t++)e[t]=Math.pow(2,-t);return e}(),P=function(){for(var r=new Int32Array(f),e=0;e<f;e++)r[e]=k[e+1]-k[e]|0;return r}(),F=function(){var r=new Float64Array(f);r[0]=2-j[k[1]];for(var e=1;e<f;e++){var t=0|k[e],n=0|k[e+1];r[e]=j[t]-j[n]}return r}();function M(r){return M="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},M(r)}function T(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,C(n.key),n)}}function C(r){var e=function(r,e){if("object"!=M(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=M(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==M(e)?e:e+""}var I=new TextEncoder,B=new TextDecoder;var E=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,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:266,i=new Uint8Array(n),u=new DataView(i.buffer);return i.set(s,0),I.encodeInto(r,i.subarray(4,259)),u.setUint32(260,e,!0),i[264]=t,u.setUint32(268,a>>>0,!0),u.setUint32(272,o>>>0,!0),i}},{key:"parseHeader",value:function(r){if(r.length!==n)throw new Error("Header must be ".concat(n," bytes"));for(var e=0;e<s.length;e++)if(r[e]!==s[e])throw new Error("Invalid AEA file");var t=new DataView(r.buffer,r.byteOffset,r.byteLength),o=r.indexOf(0,4),a=-1===o?256:o-4;return{title:B.decode(r.subarray(4,4+a)),frameCount:t.getUint32(260,!0),channelCount:r[264],primingSampleCount:t.getUint32(268,!0),sampleCount:t.getUint32(272,!0)}}}],(e=null)&&T(r.prototype,e),t&&T(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function x(r){return x="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},x(r)}function z(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 q(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?z(Object(t),!0).forEach(function(e){D(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):z(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}function D(r,e,t){return(e=R(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function _(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=[],c=!0,l=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(r){l=!0,o=r}finally{try{if(!c&&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 U(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)?U(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 U(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 H(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,R(n.key),n)}}function R(r){var e=function(r,e){if("object"!=x(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=x(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==x(e)?e:e+""}var L=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=_(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=_(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 q({},this.metadata)}},{key:"reset",value:function(){for(var r=0,e=Object.entries(this.metadata);r<e.length;r++){var t=_(e[r],2),n=t[0],o=t[1];this.values[n]=o.default}}},{key:"toObject",value:function(){return{values:q({},this.values),metadata:q({},this.metadata)}}}])&&H(r.prototype,e),t&&H(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function G(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 N(r,e,t,n){if(G(n),0!==n)for(var o=Math.floor(e/8),a=e%8,i=0|Number(t),u=0;u<n&&o<r.length;){var c=8-a,l=Math.min(n-u,c),f=i>>>n-u-l&Math.pow(2,l)-1,s=Math.pow(2,l)-1<<c-l;r[o]=r[o]&~s|f<<c-l,u+=l,o++,a=0}}function W(r,e,t){if(G(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,c=Math.min(t-i,u),l=Math.pow(2,c)-1,f=r[n]>>u-c&l;a=a*Math.pow(2,c)+f>>>0,i+=c,n++,o=0}return a}function V(r,e,t){if(G(t),0===t)return 0;var n=W(r,e,t);return n>=Math.pow(2,t-1)?n-Math.pow(2,t):n}function $(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 Q(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)?Q(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 Q(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 Y(r){var e=new Uint8Array(o),t=new DataView(e.buffer),n=y.indexOf(r.nBfu),a=2-r.blockModes[0]<<14|2-r.blockModes[1]<<12|3-r.blockModes[2]<<10|n<<5;t.setUint16(0,a,!1);for(var i=16,u=0;u<r.nBfu;u++)N(e,i,r.wordLengthIndices[u],4),i+=4;for(var c=0;c<r.nBfu;c++)N(e,i,r.scaleFactorIndices[c],6),i+=6;for(var l=0;l<r.nBfu;l++){var f=k[r.wordLengthIndices[l]];if(f>0){var s,h=$(r.quantizedCoefficients[l]);try{for(h.s();!(s=h.n()).done;){var v=s.value;N(e,i,v<0?v+(1<<f):v,f),i+=f}}catch(r){h.e(r)}finally{h.f()}}}return e[209]=0,e[210]=0,e[211]=0,e}function J(r){if(r.length!==o)throw new Error("Frame must be ".concat(o," 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=y[e>>5&7],a=16,i=new Int32Array(n),u=0;u<n;u++)i[u]=W(r,a,4),a+=4;for(var c=new Int32Array(n),l=0;l<n;l++)c[l]=W(r,a,6),a+=6;for(var f=[],s=0;s<n;s++){var v=k[i[s]],p=h[s],d=new Int32Array(p);if(v>0)for(var b=0;b<p;b++)d[b]=V(r,a,v),a+=v;f.push(d)}return{nBfu:n,scaleFactorIndices:c,wordLengthIndices:i,quantizedCoefficients:f,blockModes:t}}function K(){/*! 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 c=n&&n.prototype instanceof u?n:u,l=Object.create(c.prototype);return X(l,"_invoke",function(t,n,o){var a,u,c,l=0,f=o||[],s=!1,h={p:0,n:0,v:r,a:y,f:y.bind(r,4),d:function(e,t){return a=e,u=0,c=r,h.n=t,i}};function y(t,n){for(u=t,c=n,e=0;!s&&l&&!o&&e<f.length;e++){var o,a=f[e],y=h.p,v=a[2];t>3?(o=v===n)&&(c=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):a[0]<=y&&((o=t<2&&y<a[1])?(u=0,h.v=n,h.n=a[1]):y<v&&(o=t<3||a[0]>n||n>v)&&(a[4]=t,a[5]=n,h.n=v,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,f,v){if(l>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,v),u=f,c=v;(e=u<2?r:c)||!s;){a||(u?u<3?(u>1&&(h.n=-1),y(u,c)):h.n=c:h.v=c);try{if(l=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?c:t.call(n,h))!==i)break}catch(e){a=r,u=1,c=e}finally{l=1}}return{value:e,done:s}}}(t,o,a),!0),l}var i={};function u(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(X(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(f);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,l):(r.__proto__=l,X(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return c.prototype=l,X(s,"constructor",l),X(l,"constructor",c),c.displayName="GeneratorFunction",X(l,o,"GeneratorFunction"),X(s),X(s,o,"Generator"),X(s,n,function(){return this}),X(s,"toString",function(){return"[object Generator]"}),(K=function(){return{w:a,m:h}})()}function X(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}X=function(r,e,t,n){function a(e,t){X(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))},X(r,e,t,n)}function Z(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=[],c=!0,l=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(r){l=!0,o=r}finally{try{if(!c&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(r,e)||er(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 rr(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=er(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 er(r,e){if(r){if("string"==typeof r)return tr(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)?tr(r,e):void 0}}function tr(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function nr(r,e,t){for(var n=0;n<t.length;n++)r.setUint8(e+n,t.charCodeAt(n))}function or(r){var e,t=r.reduce(function(r,e){return r+e.length},0),n=new Float32Array(t),o=0,a=rr(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 ar(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;return K().m(function t(){var n,o,a,i,u,c,l,f,s,h,y;return K().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=Z(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=Z(r,2),c=u[0],l=u[1],f=c.length,s=0;case 6:if(!(s<f)){t.n=8;break}return h=new Float32Array(e),y=new Float32Array(e),h.set(c.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 ir(r){var e=Math.max(-1,Math.min(1,r));return e<0?32768*e:32767*e}function ur(r){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).sampleRate,n=void 0===t?e:t,o=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=rr(r);try{for(u.s();!(i=u.n()).done;){var c=i.value;n.setInt16(o,ir(c[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),c=new DataView(u.buffer);return nr(c,0,"RIFF"),c.setUint32(4,36+i,!0),nr(c,8,"WAVE"),nr(c,12,"fmt "),c.setUint32(16,16,!0),c.setUint16(20,1,!0),c.setUint16(22,n,!0),c.setUint32(24,t,!0),c.setUint32(28,o,!0),c.setUint16(32,a,!0),c.setUint16(34,16,!0),nr(c,36,"data"),c.setUint32(40,i,!0),u}({sampleCount:r[0].length,sampleRate:n,channels:r.length}),i=new Uint8Array(a.length+o.length);return i.set(a),i.set(o,a.length),i}function cr(r,e,t){var n=r.length,o=new Int32Array(n);if(0===t)return o.fill(0,0,n),o;for(var a=(1<<t-1)-1,i=a/O[e],u=a,c=-a,l=0;l<n;l++){var f=r[l]*i,s=f+(f>=0?.5:-.5)|0;o[l]=s>u?u:s<c?c:s}return o}function lr(r,e,t){if(0===t)return new Float32Array(r.length);for(var n=O[e],o=(1<<t-1)-1,a=new Float32Array(r.length),i=0;i<r.length;i++)a[i]=r[i]*n/o;return a}function fr(){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 c=k[o[u]],l=0;u>=v[0]&&(l=1),u>=v[1]&&(l=2);var f=0===i[l]?p[u]:d[u];if(c>0){var s=lr(a[u],n[u],c);e.set(s,f)}}return{coefficients:e,blockModes:i}}}function sr(r){return sr="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},sr(r)}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,vr(n.key),n)}}function yr(r,e,t){return e&&hr(r.prototype,e),t&&hr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function vr(r){var e=function(r,e){if("object"!=sr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=sr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==sr(e)?e:e+""}function pr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var dr=yr(function r(){pr(this,r),this.delay=new Float32Array(48),this.delayRow=0}),br=yr(function r(){pr(this,r),this.qmfAnalysisDelays={lowBand:new Float32Array(c),midBand:new Float32Array(c)},this.qmfSynthesisStates={lowBand:new dr,midBand:new dr},this.qmfHighBandDelay=new Float32Array(39),this.transientDetection=[new Float32Array(64),new Float32Array(64),new Float32Array(128)],this.mdctOverlap=[new Float32Array(32),new Float32Array(32),new Float32Array(32)],this.imdctOverlap=[new Float32Array(256),new Float32Array(256),new Float32Array(512)]}),mr=yr(function r(){pr(this,r),this.transformBuffers={64:new Float32Array(64),128:new Float32Array(128),256:new Float32Array(256),512:new Float32Array(512)},this.qmfScratch={analysisWindows:{128:new Float32Array(174),256:new Float32Array(302),512:new Float32Array(558)},highBandWindows:{128:new Float32Array(167),256:new Float32Array(295)},polyphase:new Float32Array(2),extended:new Float64Array(2),bands:new Float32Array(2)},this.mdctBuffers={16:{real:new Float32Array(16),imaginary:new Float32Array(16)},64:{real:new Float32Array(64),imaginary:new Float32Array(64)},128:{real:new Float32Array(128),imaginary:new Float32Array(128)}},this.reversalBuffers={32:new Float32Array(32),128:new Float32Array(128),256:new Float32Array(256)}}),wr=yr(function r(){pr(this,r),Object.assign(this,new br,new mr)});function gr(r){throw new Error(r)}function Sr(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)}}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 kr(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,Or(n.key),n)}}function Or(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 jr=function(){return r=function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r)},t=[{key:"transform",value:function(r,e){var t=r.length;if(1!==t){for(var n=Math.log2(t),o=0;o<t;o++){for(var a=0,i=o,u=0;u<n;u++)a=a<<1|1&i,i>>=1;if(a>o){var c=r[o];r[o]=r[a],r[a]=c;var l=e[o];e[o]=e[a],e[a]=l}}for(var f=2;f<=t;f<<=1)for(var s=f>>1,h=-2*Math.PI/f,y=Math.cos(h),v=Math.sin(h),p=0;p<t;p+=f)for(var d=1,b=0,m=0;m<s;m++){var w=p+m,g=w+s,S=r[w],A=e[w],k=r[g],O=e[g],j=k*d-O*b,P=k*b+O*d;r[w]=S+j,e[w]=A+P,r[g]=S-j,e[g]=A-P;var F=d*y-b*v;b=d*v+b*y,d=F}}}}],(e=null)&&kr(r.prototype,e),t&&kr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function Pr(r){return Pr="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},Pr(r)}function Fr(r,e,t){return e=Tr(e),function(r,e){if(e&&("object"==Pr(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,Mr()?Reflect.construct(e,t||[],Tr(r).constructor):e.apply(r,t))}function Mr(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(r){}return(Mr=function(){return!!r})()}function Tr(r){return Tr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},Tr(r)}function Cr(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&&Ir(r,e)}function Ir(r,e){return Ir=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},Ir(r,e)}function Br(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 Er(r,e,t){return e&&Br(r.prototype,e),t&&Br(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function xr(r){var e=function(r,e){if("object"!=Pr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Pr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Pr(e)?e:e+""}function zr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var qr=Er(function r(e,t){zr(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)}}),Dr=function(r){function e(r,t){return zr(this,e),Fr(this,e,[r,t])}return Cr(e,r),Er(e,[{key:"transform",value:function(r){var e,t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,u=this.halfSize,c=this.quarterSize,l=this.fftSize,f=this.sinCosTable,s=null!==(e=null==o?void 0:o[l])&&void 0!==e?e:gr("MDCT.transform: mdctBuffers[".concat(l,"] is required")),h=null!==(t=null==s?void 0:s.real)&&void 0!==t?t:gr("MDCT.transform: mdctBuffers[".concat(l,"].real is required")),y=null!==(n=null==s?void 0:s.imaginary)&&void 0!==n?n:gr("MDCT.transform: mdctBuffers[".concat(l,"].imaginary is required")),v=c,p=3*v;h.fill(0),y.fill(0);for(var d=0;d<v;d+=2){var b=p+d,m=v+d,w=v-1-d,g=r[p-1-d]+r[b],S=r[m]-r[w],A=f[d],k=f[d+1];h[d>>1]=g*A+S*k,y[d>>1]=S*A-g*k}for(var O=v;O<u;O+=2){var j=O>>1,P=O-v,F=v+O,M=5*v-1-O,T=r[p-1-O]-r[P],C=r[F]+r[M],I=f[O],B=f[O+1];h[j]=T*I+C*B,y[j]=C*I-T*B}jr.transform(h,y);for(var E=null!=a?a:new Float32Array(u),x=0;x<l;x++){var z=f[2*x],q=f[2*x+1],D=h[x],_=y[x];E[i+2*x]=-D*z-_*q,E[i+u-1-2*x]=-D*q+_*z}return E}}])}(qr),_r=function(r){function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return zr(this,e),Fr(this,e,[r,t||r])}return Cr(e,r),Er(e,[{key:"transform",value:function(r){var e,t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,u=this.size,c=this.halfSize,l=this.quarterSize,f=this.fftSize,s=this.sinCosTable,h=null!==(e=null==o?void 0:o[f])&&void 0!==e?e:gr("IMDCT.transform: mdctBuffers[".concat(f,"] is required")),y=null!==(t=null==h?void 0:h.real)&&void 0!==t?t:gr("IMDCT.transform: mdctBuffers[".concat(f,"].real is required")),v=null!==(n=null==h?void 0:h.imaginary)&&void 0!==n?n:gr("IMDCT.transform: mdctBuffers[".concat(f,"].imaginary is required")),p=l,d=3*p;y.fill(0),v.fill(0);for(var b=0;b<f;b++){var m=2*b,w=-r[m],g=-r[c-1-m],S=s[m],A=s[m+1];y[b]=g*A+w*S,v[b]=g*S-w*A}jr.transform(y,v);for(var k=null!=a?a:new Float32Array(u),O=0;O<f/2;O++){var j=2*O,P=s[j],F=s[j+1],M=y[O],T=v[O],C=M*P+T*F,I=M*F-T*P;k[i+d-1-j]=C,k[i+d+j]=C,k[i+p+j]=I,k[i+p-1-j]=-I}for(var B=f/2;B<f;B++){var E=2*(B-f/2)+p,x=2*B,z=s[x],q=s[x+1],D=y[B],_=v[B],U=D*z+_*q,H=D*q-_*z;k[i+d-1-E]=U,k[i+E-p]=-U,k[i+p+E]=H,k[i+5*p-1-E]=H}return k}}])}(qr);function Ur(r,e){for(var t=e[r.length],n=0;n<r.length;n++)t[n]=r[r.length-1-n];return t}var Hr=new _r(64,64),Rr=A.map(function(r){var e=r.longMdctSize;return new _r(e,e)});function Lr(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],c=r[a],l=e[n-1-a];o[a]=c*u-l*i,o[2*n-1-a]=c*i+l*u}return o}function Gr(r){var e,t=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:gr("synthesizeSpectrum: bufferPool is required"),n=t.imdctOverlap;function o(r,e,n,o,i){return 0===n?function(r,e,n,o,a){var i=r;e>0&&(i=Ur(r,t.reversalBuffers));var c=a.transform(i,t.mdctBuffers),l=c.length/4,f=t.transformBuffers[512];f.fill(0);for(var s=0;s<o.size;s++)f[s]=c[l+s];var h=n.slice(2*o.size-u,2*o.size),y=Lr(h.slice(0,u),f.slice(0,u),b);n.set(y,0);for(var v=0;v<u;v++)h[v]=f[u+v];for(var p=2===e?240:112,d=0;d<p;d++)n[32+d]=f[u+d];for(var m=0;m<u;m++)n[2*o.size-u+m]=f[o.size-u+m];return n.slice(0,o.size)}(r,e,o,i,Rr[e]):function(r,e,n,o){var i=1<<(256===o.size?3:2),c=t.transformBuffers[512];c.fill(0);for(var l=n.slice(2*o.size-u,2*o.size),f=0,s=0,h=0;h<i;h++){var y=r.slice(s,s+a);e>0&&(y=Ur(y,t.reversalBuffers));for(var v=Hr.transform(y,t.mdctBuffers),p=v.length/4,d=0;d<a;d++)c[f+d]=v[p+d];var m=Lr(l.slice(0,u),c.slice(f,f+u),b);n.set(m,f);for(var w=0;w<u;w++)l[w]=c[f+u+w];f+=a,s+=a}for(var g=0;g<u;g++)n[2*o.size-u+g]=c[o.size-u+g];return n.slice(0,o.size)}(r,e,o,i)}return function(r){var e=r.coefficients,t=r.blockModes;return A.map(function(r,a){var i=function(r,e){var t=[0,128,256,512];return r.subarray(t[e],t[e+1])}(e,a);return o(i,a,t[a],n[a],r)})}}function Nr(r,e,t){var n=new Float32Array(2*r[0].length);return e.delayRow=function(r,e,t,n,o){var a,i;if(2!==(null==r?void 0:r.length)||r.some(function(e){return!(e instanceof Float32Array)||e.length!==r[0].length})||!(e instanceof Float32Array)||48!==e.length||!Number.isInteger(t)||t<0||t>=l||!(n instanceof Float32Array)||n.length<2*r[0].length||!o||2!==(null===(a=o.polyphase)||void 0===a?void 0:a.length)||2!==(null===(i=o.bands)||void 0===i?void 0:i.length))throw new RangeError("QMF synthesis geometry is invalid");for(var u=0;u<r[0].length;u++){var c=r[0][u],f=r[1][u];e[2*t]=c+f,e[2*t+1]=c-f;for(var s=0,h=0,y=0;y<24;y++){var v=(t+l-1-y)%l;s+=e[2*v+1]*S[y],h+=e[2*v]*g[y]}n[2*u]=s,n[2*u+1]=h,t=0===t?23:t-1}return t}(r,e.delay,e.delayRow,n,t),n}function Wr(r){var e,t=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:gr("synthesizePcm: bufferPool is required"),n=t.qmfSynthesisStates,o=t.qmfScratch;return function(r){var e=o.highBandWindows[r[2].length];e.set(t.qmfHighBandDelay),e.set(r[2],t.qmfHighBandDelay.length);var a=e.slice(0,2*r[0].length);t.qmfHighBandDelay.set(e.subarray(2*r[0].length,2*r[0].length+t.qmfHighBandDelay.length));for(var i=Nr([r[0],r[1]],n.midBand,o),u=Nr([i,a],n.lowBand,o),c=0;c<u.length;c++)u[c]*=2;return u}}function Vr(r){return Sr(r,Gr,Wr)}function $r(){return Sr({bufferPool:arguments.length>0&&void 0!==arguments[0]?arguments[0]:new wr},fr,Vr)}function Qr(r,e){return function(r,e){for(var t=[],n=[],o=0,a=0,i=0;i<3;i++){for(var u=o,c=2===i?256:128,l=i<2?v[i]:h.length,f=0===e[i]?p:d;a<l;){var s=h[a],y=f[a]-u,b=y+s,m=new Float32Array(s);if(y>=0&&b<=c)m.set(r.subarray(u+y,u+b));else if(y<c&&b>0){var w=Math.max(0,y),g=Math.min(c,b);m.set(r.subarray(u+w,u+g),Math.max(0,-y))}t.push(m),n.push(s),a++}o+=c}return{bfuData:t,bfuSizes:n,bfuCount:a}}(r,e)}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){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 Kr(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)?Kr(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 Kr(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 Xr(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 Zr(r,e,t){return(e=function(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+""}(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var re=new Map;function ee(r,e,t,n,o,a,i){var u=function(r,e,t,n,o,a){for(var i=new Int32Array(r),u=new Int32Array(r),c=new Float32Array(r),l=0,s=0;s<r;s++){var h=0|e[s];if(0!==h){var y=o[s];if(0!==a[s]){var v=P[0];if(!(v<=0)){var p=(0===y?a[s]/(2*h):n[y])*F[0];u[l]=s,c[l]=p/v,l++}}}}if(0===l)return{wordLengths:i,scaleFactorIndices:o};for(var d=(l>>1)-1;d>=0;d--)te(u,c,d,l);for(;t>0&&l>0;){var b=u[0],m=0|i[b],w=0|e[b],g=P[m]*w;if(g>t||g<=0){var S=l-1;u[0]=u[S],c[0]=c[S],--l>0&&te(u,c,0,l)}else{t-=g;var A=m+1;i[b]=A;var k=P[A];if(A<f&&k>0){var O=o[b],j=(0===O?a[b]/(2*w):n[O])*F[A];c[0]=j/k,te(u,c,0,l)}else{var M=l-1;u[0]=u[M],c[0]=c[M],--l>0&&te(u,c,0,l)}}}return{wordLengths:i,scaleFactorIndices:o}}(r,t,n,o,a,i),c=function(r,e,t,n,o,a,i){for(var u=0,c=0;c<r;c++){var l=0|n[c],f=0|k[l];if(0!==f){var s=o[c];u+=(0===s?i[c]/(2*t[c]):a[s])*j[f]*t[c]}else u+=i[c]}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?Xr(Object(t),!0).forEach(function(e){Zr(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Xr(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}({distortion:c},u)}function te(r,e,t,n){for(var o=t,a=r[o],i=e[o];;){var u=1+(o<<1),c=u+1,l=o,f=i;if(u<n&&e[u]>f&&(l=u,f=e[u]),c<n&&e[c]>f&&(l=c),l===o)break;r[o]=r[l],e[o]=e[l],o=l}r[o]=a,e[o]=i}function ne(r,e,t,n){for(var o=new Int32Array(t),a=new Float32Array(t),i=function(r){if(re.has(r))return re.get(r);var e=new Float64Array(64);if(1===r)e.set(O);else for(var t=0;t<64;t++)e[t]=Math.pow(O[t],r);return re.set(r,e),e}(n),u=0;u<t;u++){var c=0|e[u];if(0!==c){var l=oe(r[u],c);o[u]=l;var f=i[l];if(0===l){for(var s=0,h=0;h<c;h++)s=Math.max(s,Math.abs(r[u][h]));f=0===s?0:Math.pow(s,n)}a[u]=2*f*c}}var v,p=null,d=1/0,b=Jr(y);try{for(b.s();!(v=b.n()).done;){var m=v.value;if(!(m>t)){var w=1656-10*m;if(!(w<0)){var g=ee(m,t,e,w,i,o,a);g.distortion<d&&(d=g.distortion,p={bfuCount:m,allocation:g.wordLengths,scaleFactorIndices:g.scaleFactorIndices})}}}}catch(r){b.e(r)}finally{b.f()}if(!p){var S=y[0];return{bfuCount:S,allocation:new Int32Array(S),scaleFactorIndices:new Int32Array(52)}}return p}function oe(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 ae(r){var e,t=null!==(e=null==r?void 0:r.options)&&void 0!==e?e:gr("allocate: options is required");return function(r){var e=r.coefficients,n=r.blockModes,o=Qr(e,n),a=o.bfuData,i=o.bfuSizes,u=ne(a,i,o.bfuCount,t.allocationBias),c=u.bfuCount;return{bfuData:a,bfuSizes:i,nBfu:c,scaleFactorIndices:u.scaleFactorIndices.slice(0,c),wordLengthIndices:u.allocation.slice(0,c),blockModes:n}}}function ie(r,e,t){var n,o=null!==(n=t.analysisWindows[r.length])&&void 0!==n?n:gr("QMF analysis window for ".concat(r.length," samples is required"));o.set(e),o.set(r,e.length);var a=r.length/2,i=[new Float32Array(a),new Float32Array(a)];return function(r,e,t){var n,o,a;if(!(r instanceof Float32Array)||2!==(null==e?void 0:e.length)||e.some(function(r){return!(r instanceof Float32Array)||r.length!==e[0].length})||!t||2!==(null===(n=t.polyphase)||void 0===n?void 0:n.length)||2!==(null===(o=t.extended)||void 0===o?void 0:o.length)||2!==(null===(a=t.bands)||void 0===a?void 0:a.length))throw new RangeError("QMF analysis geometry is invalid");var i=e[0].length,u=2*Math.max(0,i-1)+48;if(r.length<u)throw new RangeError("QMF analysis window is incomplete");for(var c=0;c<i;c++){for(var l=2*c,f=0,s=0,h=0;h<24;h++)f+=r[l+47-2*h]*g[h],s+=r[l+46-2*h]*S[h];e[0][c]=f+s,e[1][c]=f-s}}(o,i,t),e.set(o.subarray(r.length,r.length+c)),i}function ue(r){var e,t=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:gr("analyzeBands: bufferPool is required"),n=t.qmfAnalysisDelays,o=t.qmfScratch;return function(r){var e=ie(r,n.lowBand,o),a=ie(e[0],n.midBand,o),i=o.highBandWindows[e[1].length];i.set(t.qmfHighBandDelay),i.set(e[1],t.qmfHighBandDelay.length);var u=i.slice(0,e[1].length);return t.qmfHighBandDelay.set(i.subarray(e[1].length,e[1].length+t.qmfHighBandDelay.length)),{bands:[a[0],a[1],u]}}}function ce(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=le(r),o=le(e),a=Math.abs(n-o),i=fe(r),u=fe(e),c=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:c,energyChange:l}}function le(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 fe(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 se(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}(ce(r,e));return n>t}function he(r){var e,t,n=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:gr("selectBlocks: bufferPool is required"),o=null!==(t=null==r?void 0:r.options)&&void 0!==t?t:gr("selectBlocks: options is required"),a=[128,128,256];return function(r){var e,t=r.bands;if(o.fixedBlockModes)e=o.fixedBlockModes;else{var i=[o.transientThresholdLow,o.transientThresholdMid,o.transientThresholdHigh];e=t.map(function(r,e){var t=function(r,e){var t=new Float32Array(e),n=new Float32Array(e),o=Math.min(r.length,e);t.set(r.subarray(0,o)),jr.transform(t,n);for(var a=new Float32Array(e/2),i=0;i<e/2;i++)a[i]=Math.sqrt(t[i]*t[i]+n[i]*n[i]);return a}(r,a[e]),o=se(t,n.transientDetection[e],i[e]);return n.transientDetection[e]=t,o*Math.max(e+1,2)})}return{bands:t,blockModes:e}}}var ye=A.map(function(r){var e=r.analysisScale;return new Dr(64,e)}),ve=A.map(function(r){var e=r.longMdctSize,t=r.analysisScale;return new Dr(e,t)});function pe(r){var e,t=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:gr("transformSpectrum: bufferPool is required"),n=t.mdctOverlap;function o(r,e,n,o){var c=A[e];return 0===n?function(r,e,n,o,a){var i=t.transformBuffers[o.size];i.fill(0),i.set(a,n.windowStart),u(r,a,n.size),i.set(r,n.windowStart+32);var c=o.transform(i,t.mdctBuffers);e>0&&(c=Ur(c,t.reversalBuffers));return c}(r,e,c,ve[e],o):function(r,e,n,o){for(var c=1<<(256===n.size?3:2),l=new Float32Array(n.size),f=0;f<c;f++){var s=f*a,h=r.subarray(s,s+a),y=t.transformBuffers[64];y.fill(0),y.set(o,0),u(h,o,a),y.set(h,i);var v=ye[e].transform(y,t.mdctBuffers);e>0&&(v=Ur(v,t.reversalBuffers)),l.set(v,s)}return l}(r,e,c,o)}function u(r,e,t){for(var n=t-i,o=0;o<i;o++){var a=r[n+o];e[o]=b[o]*a,r[n+o]=a*b[31-o]}}return function(r){var e=r.bands,t=r.blockModes,a=r.originalFrame,i=new Float32Array(512);return e.forEach(function(r,e){var a=o(r,e,t[e],n[e]);i.set(a,function(r){return 0===r?0:1===r?128:256}(e))}),{bands:e,coefficients:i,blockModes:t,originalFrame:a}}}function de(r){var e=Sr(r,ue,he,pe);return function(r){var t=e(r);return{coefficients:t.coefficients,blockModes:t.blockModes}}}function be(){return function(r){for(var e=r.bfuData,t=r.bfuSizes,n=r.nBfu,o=r.scaleFactorIndices,a=r.wordLengthIndices,i=r.blockModes,u=[],c=0;c<n;c++){var l=e[c].subarray(0,t[c]),f=k[a[c]];u.push(cr(l,o[c],f))}return{nBfu:n,scaleFactorIndices:o,wordLengthIndices:a,quantizedCoefficients:u,blockModes:i}}}function me(){return Sr({options:arguments.length>0&&void 0!==arguments[0]?arguments[0]:new L,bufferPool:arguments.length>1&&void 0!==arguments[1]?arguments[1]:new wr},de,ae,be)}function we(r){return we="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},we(r)}var ge=["title"];function Se(r){return function(r){if(Array.isArray(r))return Fe(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||Pe(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 Ae(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 ke(){/*! 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 c=n&&n.prototype instanceof u?n:u,l=Object.create(c.prototype);return Oe(l,"_invoke",function(t,n,o){var a,u,c,l=0,f=o||[],s=!1,h={p:0,n:0,v:r,a:y,f:y.bind(r,4),d:function(e,t){return a=e,u=0,c=r,h.n=t,i}};function y(t,n){for(u=t,c=n,e=0;!s&&l&&!o&&e<f.length;e++){var o,a=f[e],y=h.p,v=a[2];t>3?(o=v===n)&&(c=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):a[0]<=y&&((o=t<2&&y<a[1])?(u=0,h.v=n,h.n=a[1]):y<v&&(o=t<3||a[0]>n||n>v)&&(a[4]=t,a[5]=n,h.n=v,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,f,v){if(l>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,v),u=f,c=v;(e=u<2?r:c)||!s;){a||(u?u<3?(u>1&&(h.n=-1),y(u,c)):h.n=c:h.v=c);try{if(l=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?c:t.call(n,h))!==i)break}catch(e){a=r,u=1,c=e}finally{l=1}}return{value:e,done:s}}}(t,o,a),!0),l}var i={};function u(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Oe(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(f);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,l):(r.__proto__=l,Oe(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return c.prototype=l,Oe(s,"constructor",l),Oe(l,"constructor",c),c.displayName="GeneratorFunction",Oe(l,o,"GeneratorFunction"),Oe(s),Oe(s,o,"Generator"),Oe(s,n,function(){return this}),Oe(s,"toString",function(){return"[object Generator]"}),(ke=function(){return{w:a,m:h}})()}function Oe(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}Oe=function(r,e,t,n){function a(e,t){Oe(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))},Oe(r,e,t,n)}function je(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=[],c=!0,l=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(r){l=!0,o=r}finally{try{if(!c&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(r,e)||Pe(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 Pe(r,e){if(r){if("string"==typeof r)return Fe(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)?Fe(r,e):void 0}}function Fe(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 Me(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Te(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,Ie(n.key),n)}}function Ce(r,e,t){return e&&Te(r.prototype,e),t&&Te(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function Ie(r){var e=function(r,e){if("object"!=we(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=we(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==we(e)?e:e+""}function Be(r,e,t,n,o,a,i){try{var u=r[a](i),c=u.value}catch(r){return void t(r)}u.done?e(c):Promise.resolve(c).then(n,o)}function Ee(r){return function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(r){Be(a,n,o,i,u,"next",r)}function u(r){Be(a,n,o,i,u,"throw",r)}i(void 0)})}}function xe(r){return new De(r,0)}function ze(r){return function(){return new qe(r.apply(this,arguments))}}function qe(r){var e,t;function n(e,t){try{var a=r[e](t),i=a.value,u=i instanceof De;Promise.resolve(u?i.v:i).then(function(t){if(u){var c="return"===e&&i.k?e:"next";if(!i.k||t.done)return n(c,t);t=r[c](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 De(r,e){this.v=r,this.k=e}function _e(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 Ue(e.call(r));t="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function Ue(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 Ue=function(r){this.s=r,this.n=r.next},Ue.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 Ue(r)}function He(r){if(1!==r&&2!==r)throw new Error("Unsupported channel count: ".concat(r))}function Re(r,e){var n=1===e?[r]:r;if(!Array.isArray(n)||n.length!==e||n.some(function(r){return!(r instanceof Float32Array)}))throw new TypeError("ATRAC1 streaming requires ".concat(e," Float32 channel").concat(1===e?"":"s"," per frame"));if(n.some(function(r){return r.length!==t}))throw new RangeError("ATRAC1 streaming requires exactly ".concat(t," samples per channel"))}function Le(){return{nBfu:0,blockModes:[0,0,0],scaleFactorIndices:new Int32Array(0),wordLengthIndices:new Int32Array(0),quantizedCoefficients:[]}}function Ge(r){return Ne.apply(this,arguments)}function Ne(){return(Ne=Ee(ke().m(function r(e){var t,n,o,a,i,u,c,l;return ke().w(function(r){for(;;)switch(r.p=r.n){case 0:t=[],n=!1,o=!1,r.p=1,i=_e(e);case 2:return r.n=3,i.next();case 3:if(!(n=!(u=r.v).done)){r.n=5;break}c=u.value,t.push(c);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)}qe.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},qe.prototype.next=function(r){return this._invoke("next",r)},qe.prototype.throw=function(r){return this._invoke("throw",r)},qe.prototype.return=function(r){return this._invoke("return",r)};var We=function(){return Ce(function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Me(this,r);var t=e.channelCount,n=void 0===t?1:t,o=e.onProgress,a=e.encoderOptions;He(n);var i=a||new L;this.channelCount=n,this.onProgress=o,this.frameIndex=0,this.sampleCount=0,this.finalized=!1,this.leftEncoder=me(i),this.rightEncoder=2===n?me(i):null},[{key:"frames",value:function(r){var e=this;return ze(ke().m(function n(){var o,a,i,u,c,l,f,s,h,y;return ke().w(function(n){for(;;)switch(n.p=n.n){case 0:if(!e.finalized){n.n=1;break}throw new Error("ATRAC1 encoder has already been finalized");case 1:o=!1,a=!1,n.p=2,u=_e(r);case 3:return n.n=4,xe(u.next());case 4:if(!(o=!(c=n.v).done)){n.n=10;break}if(Re(l=c.value,e.channelCount),1!==e.channelCount){n.n=6;break}return n.n=5,e.leftEncoder(l);case 5:n.n=8;break;case 6:return f=je(l,2),s=f[0],h=f[1],n.n=7,e.leftEncoder(s);case 7:return n.n=8,e.rightEncoder(h);case 8:e.sampleCount+=t,e.onProgress&&e.onProgress(e.frameIndex++);case 9:o=!1,n.n=3;break;case 10:n.n=12;break;case 11:n.p=11,y=n.v,a=!0,i=y;case 12:if(n.p=12,n.p=13,!o||null==u.return){n.n=14;break}return n.n=14,xe(u.return());case 14:if(n.p=14,!a){n.n=15;break}throw i;case 15:return n.f(14);case 16:return n.f(12);case 17:return n.a(2)}},n,null,[[13,,14,16],[2,11,12,17]])}))()}},{key:"finish",value:ke().m(function r(){var e,n;return ke().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(t),n=0;case 3:if(!(n<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:n++,r.n=3;break;case 6:return r.a(2)}},r,this)})}])}(),Ve=function(){return Ce(function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Me(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,c=void 0===u?Number.POSITIVE_INFINITY:u;He(n),this.channelCount=n,this.onProgress=o,this.frameIndex=0,this.primingSampleCount=i,this.sampleCount=c,this.timelinePosition=0,this.emittedSamples=0,this.leftFrame=null,this.leftDecoder=$r(),this.rightDecoder=2===n?$r():null},[{key:"frames",value:function(r){var e=this;return ze(ke().m(function t(){var n,o,a,i,u,c,l;return ke().w(function(t){for(;;)switch(t.p=t.n){case 0:n=!1,o=!1,t.p=1,i=_e(r);case 2:return t.n=3,xe(i.next());case 3:if(!(n=!(u=t.v).done)){t.n=9;break}if(c=u.value,1!==e.channelCount){t.n=5;break}return t.n=4,e.trim(e.leftDecoder(c));case 4:e.reportProgress(),t.n=8;break;case 5:if(null!==e.leftFrame){t.n=6;break}e.leftFrame=c,t.n=8;break;case 6:return t.n=7,e.trim([e.leftDecoder(e.leftFrame),e.rightDecoder(c)]);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,xe(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:ke().m(function r(){return ke().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(Le())]);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),n=this.sampleCount-this.emittedSamples,o=Math.max(0,Math.min(t-e,n));return this.timelinePosition+=t,this.emittedSamples+=o,1===this.channelCount?r.slice(e,e+o):r.map(function(r){return r.slice(e,e+o)})}},{key:"reportProgress",value:function(){this.onProgress&&this.onProgress(this.frameIndex++)}}])}();function $e(r){return new We(r)}function Qe(r){return new Ve(r)}function Ye(){return Ye=Ee(ke().m(function r(e){var t,n,a,i,u,c,l,f,s,h=arguments;return ke().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,a=void 0===n?"encoded by carta1":n,i=Ae(t,ge),u=$e({channelCount:e.length,encoderOptions:new L(i)}),c=u.frames(ar(e)),r.n=2,Ge(c);case 2:return(l=r.v).push.apply(l,Se(u.finish())),f=E.createHeader(a,l.length,e.length,e[0].length,266),(s=new Uint8Array(f.length+l.length*o)).set(f),l.forEach(function(r,e){s.set(Y(r),f.length+e*o)}),r.a(2,s)}},r)})),Ye.apply(this,arguments)}function Je(){return(Je=Ee(ke().m(function r(e){var t,a,i,u,c,l,f;return ke().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:f=r.v,t=new l(f),r.n=5;break;case 2:if(!(e instanceof Uint8Array)){r.n=3;break}t=e,r.n=5;break;case 3:if(!(e instanceof ArrayBuffer)){r.n=4;break}t=new Uint8Array(e),r.n=5;break;case 4:throw new TypeError("ATRAC1 decoding requires AEA bytes or a Blob");case 5:return a=E.parseHeader(t.subarray(0,n)),i=Qe({channelCount:a.channelCount,primingSampleCount:a.primingSampleCount,sampleCount:a.sampleCount}),u=ze(ke().m(function r(){var e;return ke().w(function(r){for(;;)switch(r.n){case 0:e=n;case 1:if(!(e+o<=t.length)){r.n=3;break}return r.n=2,J(t.subarray(e,e+o));case 2:e+=o,r.n=1;break;case 3:return r.a(2)}},r)}))(),r.n=6,Ge(i.frames(u));case 6:if((c=r.v).push.apply(c,Se(i.finish())),1!==a.channelCount){r.n=7;break}return r.a(2,[or(c)]);case 7:return r.a(2,[or(c.map(function(r){return je(r,1)[0]})),or(c.map(function(r){return je(r,2)[1]}))])}},r)}))).apply(this,arguments)}function Ke(r){return Ke="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},Ke(r)}function Xe(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=[],c=!0,l=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;c=!1}else for(;!(c=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(r){l=!0,o=r}finally{try{if(!c&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(l)throw o}}return u}}(r,e)||rt(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 Ze(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=rt(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,o=function(){};return{s:o,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(r){throw r},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){t=t.call(r)},n:function(){var r=t.next();return i=r.done,r},e:function(r){u=!0,a=r},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function rt(r,e){if(r){if("string"==typeof r)return et(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)?et(r,e):void 0}}function et(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 tt(r,e,t,n,o,a,i){try{var u=r[a](i),c=u.value}catch(r){return void t(r)}u.done?e(c):Promise.resolve(c).then(n,o)}function nt(r){return function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(r){tt(a,n,o,i,u,"next",r)}function u(r){tt(a,n,o,i,u,"throw",r)}i(void 0)})}}function ot(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(Ke(r)+" is not iterable")}function at(){/*! 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 c=n&&n.prototype instanceof u?n:u,l=Object.create(c.prototype);return it(l,"_invoke",function(t,n,o){var a,u,c,l=0,f=o||[],s=!1,h={p:0,n:0,v:r,a:y,f:y.bind(r,4),d:function(e,t){return a=e,u=0,c=r,h.n=t,i}};function y(t,n){for(u=t,c=n,e=0;!s&&l&&!o&&e<f.length;e++){var o,a=f[e],y=h.p,v=a[2];t>3?(o=v===n)&&(c=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):a[0]<=y&&((o=t<2&&y<a[1])?(u=0,h.v=n,h.n=a[1]):y<v&&(o=t<3||a[0]>n||n>v)&&(a[4]=t,a[5]=n,h.n=v,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,f,v){if(l>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,v),u=f,c=v;(e=u<2?r:c)||!s;){a||(u?u<3?(u>1&&(h.n=-1),y(u,c)):h.n=c:h.v=c);try{if(l=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?c:t.call(n,h))!==i)break}catch(e){a=r,u=1,c=e}finally{l=1}}return{value:e,done:s}}}(t,o,a),!0),l}var i={};function u(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(it(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(f);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,l):(r.__proto__=l,it(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return c.prototype=l,it(s,"constructor",l),it(l,"constructor",c),c.displayName="GeneratorFunction",it(l,o,"GeneratorFunction"),it(s),it(s,o,"Generator"),it(s,n,function(){return this}),it(s,"toString",function(){return"[object Generator]"}),(at=function(){return{w:a,m:h}})()}function it(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}it=function(r,e,t,n){function a(e,t){it(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))},it(r,e,t,n)}function ut(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,ct(n.key),n)}}function ct(r){var e=function(r,e){if("object"!=Ke(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Ke(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Ke(e)?e:e+""}function lt(r){return function(){return new ft(r.apply(this,arguments))}}function ft(r){var e,t;function n(e,t){try{var a=r[e](t),i=a.value,u=i instanceof ht;Promise.resolve(u?i.v:i).then(function(t){if(u){var c="return"===e&&i.k?e:"next";if(!i.k||t.done)return n(c,t);t=r[c](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 st(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 ht(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 ht(r,e){this.v=r,this.k=e}function yt(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 vt(e.call(r));t="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function vt(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 vt=function(r){this.s=r,this.n=r.next},vt.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 vt(r)}ft.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},ft.prototype.next=function(r){return this._invoke("next",r)},ft.prototype.throw=function(r){return this._invoke("throw",r)},ft.prototype.return=function(r){return this._invoke("return",r)};var pt=function(){function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r)}return a=r,i=null,u=[{key:"encodeAeaPcm",value:function(r){return function(r){return Ye.apply(this,arguments)}(r,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}},{key:"decodeAeaPcm",value:function(r){return function(r){return Je.apply(this,arguments)}(r)}},{key:"encodeStream",value:function(r){return lt(function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return at().m(function t(){var n;return at().w(function(t){for(;;)switch(t.n){case 0:return n=$e(e),t.d(ot(st(yt(n.frames(r)))),1);case 1:return t.d(ot(st(yt(n.finish()))),2);case 2:return t.a(2)}},t)})()}).apply(this,arguments)}},{key:"decodeStream",value:function(r){return lt(function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return at().m(function t(){var n;return at().w(function(t){for(;;)switch(t.n){case 0:return n=Qe(e),t.d(ot(st(yt(n.frames(r)))),1);case 1:return t.d(ot(st(yt(n.finish()))),2);case 2:return t.a(2)}},t)})()}).apply(this,arguments)}},{key:"frameBufferToFrames",value:at().m(function r(e,t){return at().w(function(r){for(;;)switch(r.n){case 0:return r.d(ot(ar(e,t)),1);case 1:return r.a(2)}},r)})},{key:"collectFrames",value:(f=nt(at().m(function r(e){var t,n,o,a,i,u,c,l;return at().w(function(r){for(;;)switch(r.p=r.n){case 0:t=[],n=!1,o=!1,r.p=1,i=yt(e);case 2:return r.n=3,i.next();case 3:if(!(n=!(u=r.v).done)){r.n=5;break}c=u.value,t.push(c);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 f.apply(this,arguments)})},{key:"createAeaBlob",value:(l=nt(at().m(function r(e){var n,o,a,i,u,c,l,f,s,h,y,v,p,d,b,m,w,g=arguments;return at().w(function(r){for(;;)switch(r.p=r.n){case 0:a=(o=g.length>1&&void 0!==g[1]?g[1]:{}).title,i=void 0===a?"encoded by atrac1.js":a,u=o.channelCount,c=void 0===u?1:u,l=[],f=!1,s=!1,r.p=1,y=yt(e);case 2:return r.n=3,y.next();case 3:if(!(f=!(v=r.v).done)){r.n=5;break}p=v.value,l.push(Y(p));case 4:f=!1,r.n=2;break;case 5:r.n=7;break;case 6:r.p=6,w=r.v,s=!0,h=w;case 7:if(r.p=7,r.p=8,!f||null==y.return){r.n=9;break}return r.n=9,y.return();case 9:if(r.p=9,!s){r.n=10;break}throw h;case 10:return r.f(9);case 11:return r.f(7);case 12:return d=l.length/c,b=null!==(n=o.sampleCount)&&void 0!==n?n:Math.max(0,d-1)*t,m=E.createHeader(i,l.length,c,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:(c=nt(at().m(function r(e){var t,a,i,u,c,l;return at().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,e.arrayBuffer();case 1:for(t=r.v,a=new Uint8Array(t.slice(0,n)),i=E.parseHeader(a),u=[],c=n;c<t.byteLength;)(l=new Uint8Array(t.slice(c,c+o))).length===o&&u.push(l),c+=o;return r.a(2,{info:i,frameData:u})}},r)})),function(r){return c.apply(this,arguments)})},{key:"deserializedFrameStream",value:at().m(function r(e){var t,n,o,a;return at().w(function(r){for(;;)switch(r.p=r.n){case 0:t=Ze(e),r.p=1,t.s();case 2:if((n=t.n()).done){r.n=4;break}return o=n.value,r.n=3,J(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 t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e;if(1===n)t=[or(r)];else{if(2!==n)throw new Error("Unsupported channel count: ".concat(n));t=[or(r.map(function(r){return Xe(r,1)[0]})),or(r.map(function(r){return Xe(r,2)[1]}))]}return new Blob([ur(t,{sampleRate:o})],{type:"audio/wav"})}},{key:"createWavBlob",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e;return r.createPcmWaveBlob(t,n,o)}},{key:"assemblePcmFrames",value:function(r,e){if(1===e)return or(r);if(2!==e)throw new Error("Unsupported channel count: ".concat(e));for(var t=or(r.map(function(r){return Xe(r,1)[0]})),n=or(r.map(function(r){return Xe(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}}],i&&ut(a.prototype,i),u&&ut(a,u),Object.defineProperty(a,"prototype",{writable:!1}),a;var a,i,u,c,l,f}();function dt(r){return dt="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},dt(r)}function bt(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 mt(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?bt(Object(t),!0).forEach(function(e){wt(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):bt(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}function wt(r,e,t){return(e=function(r){var e=function(r,e){if("object"!=dt(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=dt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==dt(e)?e:e+""}(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}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 c=n&&n.prototype instanceof u?n:u,l=Object.create(c.prototype);return St(l,"_invoke",function(t,n,o){var a,u,c,l=0,f=o||[],s=!1,h={p:0,n:0,v:r,a:y,f:y.bind(r,4),d:function(e,t){return a=e,u=0,c=r,h.n=t,i}};function y(t,n){for(u=t,c=n,e=0;!s&&l&&!o&&e<f.length;e++){var o,a=f[e],y=h.p,v=a[2];t>3?(o=v===n)&&(c=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):a[0]<=y&&((o=t<2&&y<a[1])?(u=0,h.v=n,h.n=a[1]):y<v&&(o=t<3||a[0]>n||n>v)&&(a[4]=t,a[5]=n,h.n=v,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,f,v){if(l>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,v),u=f,c=v;(e=u<2?r:c)||!s;){a||(u?u<3?(u>1&&(h.n=-1),y(u,c)):h.n=c:h.v=c);try{if(l=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?c:t.call(n,h))!==i)break}catch(e){a=r,u=1,c=e}finally{l=1}}return{value:e,done:s}}}(t,o,a),!0),l}var i={};function u(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(St(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(f);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,l):(r.__proto__=l,St(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return c.prototype=l,St(s,"constructor",l),St(l,"constructor",c),c.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,t,n,o,a,i){try{var u=r[a](i),c=u.value}catch(r){return void t(r)}u.done?e(c):Promise.resolve(c).then(n,o)}function kt(r){return function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(r){At(a,n,o,i,u,"next",r)}function u(r){At(a,n,o,i,u,"throw",r)}i(void 0)})}}function Ot(r,e,t){return jt.apply(this,arguments)}function jt(){return(jt=kt(gt().m(function r(e,t,n){var o,a,i,u,c,l,f;return gt().w(function(r){for(;;)switch(r.p=r.n){case 0:return n=null!=n?n:"encoded by carta1",r.p=1,o=pt.frameBufferToFrames(e),a=e.length,i=new L(t),u=pt.encodeStream(o,{channelCount:a,encoderOptions:i}),r.n=2,pt.collectFrames(u);case 2:return c=r.v,r.n=3,pt.createAeaBlob(c,{title:n,channelCount:a,sampleCount:e[0].length});case 3:return l=r.v,r.a(2,{aeaBlob:l});case 4:throw r.p=4,f=r.v,console.error("Worker encode error:",f),f;case 5:return r.a(2)}},r,null,[[1,4]])}))).apply(this,arguments)}function Pt(){return(new L).toObject()}function Ft(r){return Mt.apply(this,arguments)}function Mt(){return(Mt=kt(gt().m(function r(t){var n,o,a,i,u,c,l,f,s;return gt().w(function(r){for(;;)switch(r.n){case 0:return n=t.header,o=t.aeaData,(a=t.info)?i=mt({sampleRate:e},a):n?(u=E.parseHeader(n),i=mt({sampleRate:e},u)):i={channelCount:2,sampleRate:e},c=pt.deserializedFrameStream(o),l=pt.decodeStream(c,{channelCount:i.channelCount,primingSampleCount:i.primingSampleCount,sampleCount:i.sampleCount}),r.n=1,pt.collectFrames(l);case 1:return f=r.v,s=pt.createPcmWaveBlob(f,i.channelCount,i.sampleRate),r.a(2,{wavBlob:s,info:i})}},r)}))).apply(this,arguments)}self.onmessage=function(){var r=kt(gt().m(function r(e){var t,n,o,a,i,u,c,l,f,s,h;return gt().w(function(r){for(;;)switch(r.p=r.n){case 0:t=e.data,n=t.jobId,o=t.type,a=t.pcmData,i=t.aea,u=t.options,c=t.title,l=t.blob,r.p=1,s=o,r.n="encode"===s?2:"decode"===s?4:"parseAea"===s?6:"getEncoderOptions"===s?8:9;break;case 2:return r.n=3,Ot(a,u,c);case 3:return f=r.v,r.a(3,10);case 4:return r.n=5,Ft(i);case 5:return f=r.v,r.a(3,10);case 6:return r.n=7,pt.parseAeaBlob(l);case 7:return f=r.v,r.a(3,10);case 8:return f=Pt(),r.a(3,10);case 9:throw new Error("Unknown worker message type: ".concat(o));case 10:self.postMessage({jobId:n,result:f}),r.n=12;break;case 11:r.p=11,h=r.v,console.error("Worker error:",h),self.postMessage({jobId:n,error:h.message});case 12:return r.a(2)}},r,null,[[1,11]])}));return function(e){return r.apply(this,arguments)}}();const Tt=self;for(var Ct in r)Tt[Ct]=r[Ct];r.__esModule&&Object.defineProperty(Tt,"__esModule",{value:!0})})();
1
+ (()=>{"use strict";let r={};var e=44100,t=512,n=2048,o=212,a=52,i=256,u=512,l=32,f=32,c=16,s=46,h=24,v=128,y=256,d=15,p=new Uint8Array([0,8,0,0]),m=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]),w=new Int32Array([20,36,52]),g=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]),S=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]),A=function(){for(var r=new Float64Array(32),e=0;e<32;e++)r[e]=Math.sin((e+.5)*Math.PI/64);return r}(),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]),O=function(){for(var r=new Float32Array(48),e=0;e<24;e++)r[e]=2*k[e],r[47-e]=2*k[e];return r}(),j=function(){for(var r=new Float32Array(24),e=0;e<24;e++)r[e]=O[2*e];return r}(),F=function(){for(var r=new Float32Array(24),e=0;e<24;e++)r[e]=O[2*e+1];return r}(),P=[{size:128,longMdctSize:i,windowStart:48,analysisScale:.5},{size:128,longMdctSize:i,windowStart:48,analysisScale:.5},{size:256,longMdctSize:u,windowStart:112,analysisScale:1}],M=new Int32Array([0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]),T=function(){for(var r=new Float64Array(64),e=0;e<64;e++)r[e]=Math.pow(2,e/3-21);return r}(),C=new Float64Array([1,.03162277660168379,.001,3162277660168379e-20]),B=new Float64Array([1,.005011872336272725,19952623149688796e-21]),I=function(){for(var r=new Int32Array(16),e=1;e<=d;e++){var t=M[e];r[e]=(1<<t-1)-1}return r}(),E=function(){for(var r=new Float64Array(16),e=1;e<=d;e++){var t=I[e];r[e]=2*t/(2*t+1)}return r}(),x=function(){for(var r=new Float64Array(21),e=2;e<=20;e++)r[e]=1/Math.log(e);return r}(),q=function(){for(var r=new Float64Array(a),e=0;e<a;e++){var t=g[e]+.5*m[e],n=Math.max(.05,t/512*22.05),o=Math.max(-9,-2.184*Math.pow(n,-.8)+6.5*Math.exp(-.6*(n-3.3)*(n-3.3))-.001*Math.pow(n,3.6));r[e]=Math.pow(10,o/10)}return r}(),z=function(){for(var r=new Float64Array(a),e=new Int32Array([0,8,12,20,26]),t=new Int32Array([0,6,13,22]),n=new Int32Array([0,12]),o=0;o<a;o++){var i=.05;if(o<20){var u=o>>2;i=Math.max(.05,(e[u]+.5*m[o])/32*5.5125)}else if(o<36){i=5.5125+(t[o-20>>2]+.5*m[o])/32*5.5125}else{i=11.025+(n[o-36>>3]+.5*m[o])/32*11.025}var l=Math.max(-9,-2.184*Math.pow(i,-.8)+6.5*Math.exp(-.6*(i-3.3)*(i-3.3))-.001*Math.pow(i,3.6));r[o]=Math.pow(10,l/10)}return r}();function D(r){return D="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},D(r)}function _(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,U(n.key),n)}}function U(r){var e=function(r,e){if("object"!=D(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=D(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==D(e)?e:e+""}var H=new TextEncoder,R=new TextDecoder;var L=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,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:266,i=new Uint8Array(n),u=new DataView(i.buffer);return i.set(p,0),H.encodeInto(r,i.subarray(4,259)),u.setUint32(260,e,!0),i[264]=t,u.setUint32(268,a>>>0,!0),u.setUint32(272,o>>>0,!0),i}},{key:"parseHeader",value:function(r){if(r.length!==n)throw new Error("Header must be ".concat(n," bytes"));for(var e=0;e<p.length;e++)if(r[e]!==p[e])throw new Error("Invalid AEA file");var t=new DataView(r.buffer,r.byteOffset,r.byteLength),o=r.indexOf(0,4),a=-1===o?256:o-4;return{title:R.decode(r.subarray(4,4+a)),frameCount:t.getUint32(260,!0),channelCount:r[264],primingSampleCount:t.getUint32(268,!0),sampleCount:t.getUint32(272,!0)}}}],(e=null)&&_(r.prototype,e),t&&_(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function N(r){return N="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},N(r)}function G(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 W(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?G(Object(t),!0).forEach(function(e){V(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):G(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}function V(r,e,t){return(e=J(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function $(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a,i,u=[],l=!0,f=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;l=!1}else for(;!(l=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(r){f=!0,o=r}finally{try{if(!l&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(f)throw o}}return u}}(r,e)||function(r,e){if(r){if("string"==typeof r)return Q(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)?Q(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 Q(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 Y(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,J(n.key),n)}}function J(r){var e=function(r,e){if("object"!=N(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=N(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==N(e)?e:e+""}var K=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=$(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=$(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 W({},this.metadata)}},{key:"reset",value:function(){for(var r=0,e=Object.entries(this.metadata);r<e.length;r++){var t=$(e[r],2),n=t[0],o=t[1];this.values[n]=o.default}}},{key:"toObject",value:function(){return{values:W({},this.values),metadata:W({},this.metadata)}}}])&&Y(r.prototype,e),t&&Y(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function X(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 Z(r,e,t,n){if(X(n),0!==n)for(var o=Math.floor(e/8),a=e%8,i=0|Number(t),u=0;u<n&&o<r.length;){var l=8-a,f=Math.min(n-u,l),c=i>>>n-u-f&Math.pow(2,f)-1,s=Math.pow(2,f)-1<<l-f;r[o]=r[o]&~s|c<<l-f,u+=f,o++,a=0}}function rr(r,e,t){if(X(t),0===t)return 0;for(var n=Math.floor(e/8),o=e%8,a=0,i=0;i<t&&n<r.length;){var u=8-o,l=Math.min(t-i,u),f=Math.pow(2,l)-1,c=r[n]>>u-l&f;a=a*Math.pow(2,l)+c>>>0,i+=l,n++,o=0}return a}function er(r,e,t){if(X(t),0===t)return 0;var n=rr(r,e,t);return n>=Math.pow(2,t-1)?n-Math.pow(2,t):n}function tr(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 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&&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 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 or(r){var e=new Uint8Array(o),t=new DataView(e.buffer),n=b.indexOf(r.nBfu),a=2-r.blockModes[0]<<14|2-r.blockModes[1]<<12|3-r.blockModes[2]<<10|n<<5;t.setUint16(0,a,!1);for(var i=16,u=0;u<r.nBfu;u++)Z(e,i,r.wordLengthIndices[u],4),i+=4;for(var l=0;l<r.nBfu;l++)Z(e,i,r.scaleFactorIndices[l],6),i+=6;for(var f=0;f<r.nBfu;f++){var c=M[r.wordLengthIndices[f]];if(c>0){var s,h=tr(r.quantizedCoefficients[f]);try{for(h.s();!(s=h.n()).done;){var v=s.value;Z(e,i,v<0?v+(1<<c):v,c),i+=c}}catch(r){h.e(r)}finally{h.f()}}}return e[210]=e[0],e[211]=e[1],e}function ar(r){if(r.length!==o)throw new Error("Frame must be ".concat(o," 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],a=16,i=new Int32Array(n),u=0;u<n;u++)i[u]=rr(r,a,4),a+=4;for(var l=new Int32Array(n),f=0;f<n;f++)l[f]=rr(r,a,6),a+=6;for(var c=[],s=0;s<n;s++){var h=M[i[s]],v=m[s],y=new Int32Array(v);if(h>0)for(var d=0;d<v;d++)y[d]=er(r,a,h),a+=h;c.push(y)}return{nBfu:n,scaleFactorIndices:l,wordLengthIndices:i,quantizedCoefficients:c,blockModes:t}}function ir(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var r,e,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function a(t,n,o,a){var l=n&&n.prototype instanceof u?n:u,f=Object.create(l.prototype);return ur(f,"_invoke",function(t,n,o){var a,u,l,f=0,c=o||[],s=!1,h={p:0,n:0,v:r,a:v,f:v.bind(r,4),d:function(e,t){return a=e,u=0,l=r,h.n=t,i}};function v(t,n){for(u=t,l=n,e=0;!s&&f&&!o&&e<c.length;e++){var o,a=c[e],v=h.p,y=a[2];t>3?(o=y===n)&&(l=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):a[0]<=v&&((o=t<2&&v<a[1])?(u=0,h.v=n,h.n=a[1]):v<y&&(o=t<3||a[0]>n||n>y)&&(a[4]=t,a[5]=n,h.n=y,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,c,y){if(f>1)throw TypeError("Generator is already running");for(s&&1===c&&v(c,y),u=c,l=y;(e=u<2?r:l)||!s;){a||(u?u<3?(u>1&&(h.n=-1),v(u,l)):h.n=l:h.v=l);try{if(f=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?l:t.call(n,h))!==i)break}catch(e){a=r,u=1,l=e}finally{f=1}}return{value:e,done:s}}}(t,o,a),!0),f}var i={};function u(){}function l(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(ur(e={},n,function(){return this}),e),s=f.prototype=u.prototype=Object.create(c);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,f):(r.__proto__=f,ur(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return l.prototype=f,ur(s,"constructor",f),ur(f,"constructor",l),l.displayName="GeneratorFunction",ur(f,o,"GeneratorFunction"),ur(s),ur(s,o,"Generator"),ur(s,n,function(){return this}),ur(s,"toString",function(){return"[object Generator]"}),(ir=function(){return{w:a,m:h}})()}function ur(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}ur=function(r,e,t,n){function a(e,t){ur(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))},ur(r,e,t,n)}function lr(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a,i,u=[],l=!0,f=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;l=!1}else for(;!(l=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(r){f=!0,o=r}finally{try{if(!l&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(f)throw o}}return u}}(r,e)||cr(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 fr(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=cr(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 cr(r,e){if(r){if("string"==typeof r)return sr(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)?sr(r,e):void 0}}function sr(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,t){for(var n=0;n<t.length;n++)r.setUint8(e+n,t.charCodeAt(n))}function vr(r){var e,t=r.reduce(function(r,e){return r+e.length},0),n=new Float32Array(t),o=0,a=fr(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 yr(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;return ir().m(function t(){var n,o,a,i,u,l,f,c,s,h,v;return ir().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=lr(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=lr(r,2),l=u[0],f=u[1],c=l.length,s=0;case 6:if(!(s<c)){t.n=8;break}return h=new Float32Array(e),v=new Float32Array(e),h.set(l.subarray(s,s+e)),v.set(f.subarray(s,s+e)),t.n=7,[h,v];case 7:s+=e,t.n=6;break;case 8:case 9:return t.a(2)}},t)})()}function dr(r){var e=Math.max(-1,Math.min(1,r));return e<0?32768*e:32767*e}function pr(r){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).sampleRate,n=void 0===t?e:t,o=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=fr(r);try{for(u.s();!(i=u.n()).done;){var l=i.value;n.setInt16(o,dr(l[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),l=new DataView(u.buffer);return hr(l,0,"RIFF"),l.setUint32(4,36+i,!0),hr(l,8,"WAVE"),hr(l,12,"fmt "),l.setUint32(16,16,!0),l.setUint16(20,1,!0),l.setUint16(22,n,!0),l.setUint32(24,t,!0),l.setUint32(28,o,!0),l.setUint16(32,a,!0),l.setUint16(34,16,!0),hr(l,36,"data"),l.setUint32(40,i,!0),u}({sampleCount:r[0].length,sampleRate:n,channels:r.length}),i=new Uint8Array(a.length+o.length);return i.set(a),i.set(o,a.length),i}function mr(r,e,t){var n=r.length,o=new Int32Array(n);if(0===t)return o.fill(0,0,n),o;for(var a=(1<<t-1)-1,i=a/T[e],u=a,l=-a,f=0;f<n;f++){var c=r[f]*i,s=c+(c>=0?.5:-.5)|0;o[f]=s>u?u:s<l?l:s}return o}function br(r,e,t){if(0===t)return new Float32Array(r.length);for(var n=T[e],o=(1<<t-1)-1,a=new Float32Array(r.length),i=0;i<r.length;i++)a[i]=r[i]*n/o;return a}function wr(){return function(r){for(var e=new Float32Array(512),t=r.nBfu,n=r.scaleFactorIndices,o=r.wordLengthIndices,a=r.quantizedCoefficients,i=r.blockModes,u=0;u<t;u++){var l=M[o[u]],f=0;u>=w[0]&&(f=1),u>=w[1]&&(f=2);var c=0===i[f]?g[u]:S[u];if(l>0){var s=br(a[u],n[u],l);e.set(s,c)}}return{coefficients:e,blockModes:i}}}function gr(r){return gr="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},gr(r)}function Sr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Ar(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,Or(n.key),n)}}function kr(r,e,t){return e&&Ar(r.prototype,e),t&&Ar(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function Or(r){var e=function(r,e){if("object"!=gr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=gr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==gr(e)?e:e+""}var jr=function(){return kr(function r(){Sr(this,r),this.delay=new Float32Array(48),this.delayRow=0},[{key:"reset",value:function(){return this.delay.fill(0),this.delayRow=0,this}}])}(),Fr=function(){return kr(function r(){Sr(this,r),this.qmfSynthesisStates={lowBand:new jr,midBand:new jr},this.qmfHighBandDelay=new Float32Array(39),this.imdctOverlap=[new Float32Array(i),new Float32Array(i),new Float32Array(u)]},[{key:"reset",value:function(){this.qmfSynthesisStates.lowBand.reset(),this.qmfSynthesisStates.midBand.reset(),this.qmfHighBandDelay.fill(0);for(var r=0;r<this.imdctOverlap.length;r++)this.imdctOverlap[r].fill(0);return this}}])}();function Pr(r){return Pr="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},Pr(r)}function Mr(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Tr(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,Br(n.key),n)}}function Cr(r,e,t){return e&&Tr(r.prototype,e),t&&Tr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function Br(r){var e=function(r,e){if("object"!=Pr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Pr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Pr(e)?e:e+""}var Ir=function(){return Cr(function r(){Mr(this,r),this.qmfAnalysisDelays={lowBand:new Float32Array(s),midBand:new Float32Array(s)},this.qmfHighBandDelay=new Float32Array(39),this.transientDetection=[new Float32Array(64),new Float32Array(64),new Float32Array(128)],this.mdctOverlap=[new Float32Array(f),new Float32Array(f),new Float32Array(f)]},[{key:"reset",value:function(){this.qmfAnalysisDelays.lowBand.fill(0),this.qmfAnalysisDelays.midBand.fill(0),this.qmfHighBandDelay.fill(0);for(var r=0;r<this.transientDetection.length;r++)this.transientDetection[r].fill(0);for(var e=0;e<this.mdctOverlap.length;e++)this.mdctOverlap[e].fill(0);return this}}])}(),Er=Cr(function r(){Mr(this,r),this.fft={128:{real:new Float32Array(v),imaginary:new Float32Array(v),magnitudes:new Float32Array(64)},256:{real:new Float32Array(y),imaginary:new Float32Array(y),magnitudes:new Float32Array(128)}}}),xr=Cr(function r(){Mr(this,r);for(var e=[],t=[],n=0;n<a;n++){var o=m[n];e.push(new Float32Array(o)),t.push(o)}this.bfuData=e,this.bfuSizes=t,this.energies=new Float64Array(a),this.maxAmplitudes=new Float64Array(a),this.initialScaleFactorIndices=new Int32Array(a),this.maskThresholds=new Float64Array(a),this.perceptualWeights=new Float64Array(a),this.seedThresholds=new Float64Array(a),this.distortionCache=new Float64Array(832),this.candidateWordLengths=new Int32Array(a),this.selectedWordLengths=new Int32Array(a),this.refinedScaleFactorIndices=new Int32Array(a)});function qr(r){return qr="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},qr(r)}function zr(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,_r(n.key),n)}}function Dr(r,e,t){return e&&zr(r.prototype,e),t&&zr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function _r(r){var e=function(r,e){if("object"!=qr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=qr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==qr(e)?e:e+""}function Ur(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var Hr=Dr(function r(){Ur(this,r),this.analysisWindows={128:new Float32Array(174),256:new Float32Array(302),512:new Float32Array(558)},this.highBandWindows={128:new Float32Array(167),256:new Float32Array(295)},this.polyphase=new Float32Array(2),this.extended=new Float64Array(2),this.bands=new Float32Array(2)}),Rr=Dr(function r(){Ur(this,r),this.transformBuffers={64:new Float32Array(64),128:new Float32Array(128),256:new Float32Array(i),512:new Float32Array(u)},this.fftBuffers={16:{real:new Float32Array(16),imaginary:new Float32Array(16)},64:{real:new Float32Array(64),imaginary:new Float32Array(64)},128:{real:new Float32Array(128),imaginary:new Float32Array(128)}},this.reversalBuffers={32:new Float32Array(32),128:new Float32Array(128),256:new Float32Array(256)}});function Lr(r){return Lr="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},Lr(r)}function Nr(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,Wr(n.key),n)}}function Gr(r,e,t){return e&&Nr(r.prototype,e),t&&Nr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function Wr(r){var e=function(r,e){if("object"!=Lr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Lr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Lr(e)?e:e+""}var Vr=Gr(function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r),this.encoder={state:new Ir,scratch:{qmf:new Hr,transient:new Er,mdct:new Rr,allocation:new xr}},this.decoder={state:new Fr,scratch:{mdct:new Rr,qmf:new Hr}}});function $r(r){throw new Error(r)}function Qr(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)}}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,Kr(n.key),n)}}function Kr(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+""}var Xr=function(){return r=function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r)},t=[{key:"transform",value:function(r,e){var t=r.length;if(1!==t){for(var n=Math.log2(t),o=0;o<t;o++){for(var a=0,i=o,u=0;u<n;u++)a=a<<1|1&i,i>>=1;if(a>o){var l=r[o];r[o]=r[a],r[a]=l;var f=e[o];e[o]=e[a],e[a]=f}}for(var c=2;c<=t;c<<=1)for(var s=c>>1,h=-2*Math.PI/c,v=Math.cos(h),y=Math.sin(h),d=0;d<t;d+=c)for(var p=1,m=0,b=0;b<s;b++){var w=d+b,g=w+s,S=r[w],A=e[w],k=r[g],O=e[g],j=k*p-O*m,F=k*m+O*p;r[w]=S+j,e[w]=A+F,r[g]=S-j,e[g]=A-F;var P=p*v-m*y;m=p*y+m*v,p=P}}}}],(e=null)&&Jr(r.prototype,e),t&&Jr(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,e,t}();function Zr(r){return Zr="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},Zr(r)}function re(r,e,t){return e=te(e),function(r,e){if(e&&("object"==Zr(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,ee()?Reflect.construct(e,t||[],te(r).constructor):e.apply(r,t))}function ee(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(r){}return(ee=function(){return!!r})()}function te(r){return te=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},te(r)}function ne(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&&oe(r,e)}function oe(r,e){return oe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,e){return r.__proto__=e,r},oe(r,e)}function ae(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,ue(n.key),n)}}function ie(r,e,t){return e&&ae(r.prototype,e),t&&ae(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function ue(r){var e=function(r,e){if("object"!=Zr(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Zr(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Zr(e)?e:e+""}function le(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}var fe=ie(function r(e,t){le(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)}}),ce=function(r){function e(r,t){return le(this,e),re(this,e,[r,t])}return ne(e,r),ie(e,[{key:"transform",value:function(r){var e,t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,u=this.halfSize,l=this.quarterSize,f=this.fftSize,c=this.sinCosTable,s=null!==(e=null==o?void 0:o[f])&&void 0!==e?e:$r("MDCT.transform: mdctBuffers[".concat(f,"] is required")),h=null!==(t=null==s?void 0:s.real)&&void 0!==t?t:$r("MDCT.transform: mdctBuffers[".concat(f,"].real is required")),v=null!==(n=null==s?void 0:s.imaginary)&&void 0!==n?n:$r("MDCT.transform: mdctBuffers[".concat(f,"].imaginary is required")),y=l,d=3*y;h.fill(0),v.fill(0);for(var p=0;p<y;p+=2){var m=d+p,b=y+p,w=y-1-p,g=r[d-1-p]+r[m],S=r[b]-r[w],A=c[p],k=c[p+1];h[p>>1]=g*A+S*k,v[p>>1]=S*A-g*k}for(var O=y;O<u;O+=2){var j=O>>1,F=O-y,P=y+O,M=5*y-1-O,T=r[d-1-O]-r[F],C=r[P]+r[M],B=c[O],I=c[O+1];h[j]=T*B+C*I,v[j]=C*B-T*I}Xr.transform(h,v);for(var E=null!=a?a:new Float32Array(u),x=0;x<f;x++){var q=c[2*x],z=c[2*x+1],D=h[x],_=v[x];E[i+2*x]=-D*q-_*z,E[i+u-1-2*x]=-D*z+_*q}return E}}])}(fe),se=function(r){function e(r){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return le(this,e),re(this,e,[r,t||r])}return ne(e,r),ie(e,[{key:"transform",value:function(r){var e,t,n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,u=this.size,l=this.halfSize,f=this.quarterSize,c=this.fftSize,s=this.sinCosTable,h=null!==(e=null==o?void 0:o[c])&&void 0!==e?e:$r("IMDCT.transform: mdctBuffers[".concat(c,"] is required")),v=null!==(t=null==h?void 0:h.real)&&void 0!==t?t:$r("IMDCT.transform: mdctBuffers[".concat(c,"].real is required")),y=null!==(n=null==h?void 0:h.imaginary)&&void 0!==n?n:$r("IMDCT.transform: mdctBuffers[".concat(c,"].imaginary is required")),d=f,p=3*d;v.fill(0),y.fill(0);for(var m=0;m<c;m++){var b=2*m,w=-r[b],g=-r[l-1-b],S=s[b],A=s[b+1];v[m]=g*A+w*S,y[m]=g*S-w*A}Xr.transform(v,y);for(var k=null!=a?a:new Float32Array(u),O=0;O<c/2;O++){var j=2*O,F=s[j],P=s[j+1],M=v[O],T=y[O],C=M*F+T*P,B=M*P-T*F;k[i+p-1-j]=C,k[i+p+j]=C,k[i+d+j]=B,k[i+d-1-j]=-B}for(var I=c/2;I<c;I++){var E=2*(I-c/2)+d,x=2*I,q=s[x],z=s[x+1],D=v[I],_=y[I],U=D*q+_*z,H=D*z-_*q;k[i+p-1-E]=U,k[i+E-d]=-U,k[i+d+E]=H,k[i+5*d-1-E]=H}return k}}])}(fe);function he(r,e){for(var t=e[r.length],n=0;n<r.length;n++)t[n]=r[r.length-1-n];return t}var ve=new se(64,64),ye=P.map(function(r){var e=r.longMdctSize;return new se(e,e)});function de(r,e,t){for(var n=r.length,o=new Float32Array(2*n),a=0;a<n;a++){var i=t[a],u=t[2*n-1-a],l=r[a],f=e[n-1-a];o[a]=l*u-f*i,o[2*n-1-a]=l*i+f*u}return o}function pe(r){var e,t=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:$r("synthesizeSpectrum: bufferPool is required"),n=t.decoder.state,o=t.decoder.scratch.mdct,a=n.imdctOverlap;function i(r,e,t,n,a){return 0===t?function(r,e,t,n,a){var i=r;e>0&&(i=he(r,o.reversalBuffers));var u=a.transform(i,o.fftBuffers),l=u.length/4,f=o.transformBuffers[512];f.fill(0);for(var s=0;s<n.size;s++)f[s]=u[l+s];var h=t.slice(2*n.size-c,2*n.size),v=de(h.slice(0,c),f.slice(0,c),A);t.set(v,0);for(var y=0;y<c;y++)h[y]=f[c+y];for(var d=2===e?240:112,p=0;p<d;p++)t[32+p]=f[c+p];for(var m=0;m<c;m++)t[2*n.size-c+m]=f[n.size-c+m];return t.slice(0,n.size)}(r,e,n,a,ye[e]):function(r,e,t,n){var a=1<<(256===n.size?3:2),i=o.transformBuffers[512];i.fill(0);for(var u=t.slice(2*n.size-c,2*n.size),f=0,s=0,h=0;h<a;h++){var v=r.slice(s,s+l);e>0&&(v=he(v,o.reversalBuffers));for(var y=ve.transform(v,o.fftBuffers),d=y.length/4,p=0;p<l;p++)i[f+p]=y[d+p];var m=de(u.slice(0,c),i.slice(f,f+c),A);t.set(m,f);for(var b=0;b<c;b++)u[b]=i[f+c+b];f+=l,s+=l}for(var w=0;w<c;w++)t[2*n.size-c+w]=i[n.size-c+w];return t.slice(0,n.size)}(r,e,n,a)}return function(r){var e=r.coefficients,t=r.blockModes;return P.map(function(r,n){var o=function(r,e){var t=[0,128,256,512];return r.subarray(t[e],t[e+1])}(e,n);return i(o,n,t[n],a[n],r)})}}function me(r,e,t){var n=new Float32Array(2*r[0].length);return e.delayRow=function(r,e,t,n,o){var a,i;if(2!==(null==r?void 0:r.length)||r.some(function(e){return!(e instanceof Float32Array)||e.length!==r[0].length})||!(e instanceof Float32Array)||48!==e.length||!Number.isInteger(t)||t<0||t>=h||!(n instanceof Float32Array)||n.length<2*r[0].length||!o||2!==(null===(a=o.polyphase)||void 0===a?void 0:a.length)||2!==(null===(i=o.bands)||void 0===i?void 0:i.length))throw new RangeError("QMF synthesis geometry is invalid");for(var u=0;u<r[0].length;u++){var l=r[0][u],f=r[1][u];e[2*t]=l+f,e[2*t+1]=l-f;for(var c=0,s=0,v=0;v<24;v++){var y=(t+h-1-v)%h;c+=e[2*y+1]*F[v],s+=e[2*y]*j[v]}n[2*u]=c,n[2*u+1]=s,t=0===t?23:t-1}return t}(r,e.delay,e.delayRow,n,t),n}function be(r){var e,t=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:$r("synthesizePcm: bufferPool is required"),n=t.decoder.state,o=n.qmfSynthesisStates,a=t.decoder.scratch.qmf;return function(r){var e=a.highBandWindows[r[2].length];e.set(n.qmfHighBandDelay),e.set(r[2],n.qmfHighBandDelay.length);var t=e.slice(0,2*r[0].length);n.qmfHighBandDelay.set(e.subarray(2*r[0].length,2*r[0].length+n.qmfHighBandDelay.length));for(var i=me([r[0],r[1]],o.midBand,a),u=me([i,t],o.lowBand,a),l=0;l<u.length;l++)u[l]*=2;return u}}function we(r){return Qr(r,pe,be)}function ge(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Vr;return r.decoder.state.reset(),Qr({bufferPool:r},wr,we)}function Se(r,e){return function(r,e){for(var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,n=t?t.bfuData:[],o=t?t.bfuSizes:[],a=0,i=0,u=0;u<3;u++){for(var l=a,f=2===u?256:128,c=u<2?w[u]:m.length,s=0===e[u]?g:S;i<c;){var h=m[i],v=s[i]-l,y=v+h,d=t?n[i]:new Float32Array(h);if(v>=0&&y<=f)for(var p=l+v,b=0;b<h;b++)d[b]=r[p+b];else if(v<f&&y>0){d.fill(0);for(var A=Math.max(0,v),k=Math.min(f,y),O=Math.max(0,-v),j=k-A,F=0;F<j;F++)d[O+F]=r[l+A+F]}else t&&d.fill(0);t||(n.push(d),o.push(h)),i++}a+=f}return{bfuData:n,bfuSizes:o,bfuCount:i}}(r,e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:null)}function Ae(r,e,t,n){if(n<=0){for(var o=0,a=0;a<e;a++){var i=r[a];o+=i*i}return o}for(var u=I[n],l=T[t],f=u/l,c=1/u,s=0,h=0;h<e;h++){var v=r[h],y=v*f,d=v-(y>=u?u:y<=-u?-u:y+(y>=0?.5:-.5)|0)*l*c;s+=d*d}return s}function ke(r,e,t,n,o,a,i){var u=16*r+e,l=i[u];if(l>=0)return l;var f=o[r];e>0&&f>0&&T[f-1]>=a[r]*E[e]&&(f-=1);var c=Ae(t[r],0|n[r],f,e);return i[u]=c,c}var Oe=new xr;function je(r,e,t,n,o,a,i,u,l,f){var c=1664-10*r,s=function(r,e,t,n,o,a){for(var i=1e9,u=-1e9,l=0,f=0;f<r;f++){var c=0|t[f];if(n[f]>0&&c>0){var s=o[f];s<i&&(i=s),s>u&&(u=s),l=1}}if(0===l||e<=0){for(var h=0;h<r;h++)a[h]=0;return 0}for(var v=i-16,y=u+2,p=0;p<10;p++){for(var m=.5*(v+y),b=0,w=0;w<r;w++){var g=0|t[w];if(!(n[w]<=0||g<=0)){var S=Math.floor(o[w]-m+.5),A=0;S>=d?A=d:S>0&&(A=0|S),b+=M[A]*g}}b<=e?y=m:v=m}for(var k=0,O=0;O<r;O++){var j=0|t[O];if(n[O]<=0||j<=0)a[O]=0;else{var F=Math.floor(o[O]-y+.5),P=0;F>=d?P=d:F>0&&(P=0|F),a[O]=P,k+=M[P]*j}}return k}(r,c,t,a,u,f);s=function(r,e,t,n,o,a,i,u,l,f,c){for(var s=0;s<4;s++){for(var h=-1,v=0,y=0,p=0,m=0;m<r;m++){var b=0|o[m],w=c[m];if(!(u[m]<=0||b<=0||w>=d)){var g=l[m],S=ke(m,w,n,o,a,i,f),A=w+1;0===w&&(A=3),A>d&&(A=d);for(var k=w+1;k<=A;k++){var O=(M[k]-M[w])*b;if(!(O<=0||O>e)){var j=(S-ke(m,k,n,o,a,i,f))*g/O;j>p&&(p=j,h=m,v=k,y=O)}}}}if(h<0)break;if(t+y<=e)c[h]=v,t+=y;else{for(var F=-1,P=0,T=1e300,C=0;C<r;C++)if(C!==h){var B=c[C],I=0|o[C];if(!(B<=0||I<=0)){var E=(M[B]-M[B-1])*I;if(!(E<=0||t-E+y>e)){var x=ke(C,B,n,o,a,i,f),q=(ke(C,B-1,n,o,a,i,f)-x)*l[C]/E;q<T&&(T=q,F=C,P=E)}}}if(!(F>=0&&p>1.02*T))break;c[F]=c[F]-1,c[h]=v,t=t-P+y}}return t}(r,c,s,e,t,n,o,a,i,l,f),function(r,e,t,n,o,a,i,u,l,f){for(;e>=4;){for(var c=-1,s=0,h=0,v=0,y=0;y<r;y++){var p=0|n[y],m=f[y];if(!(i[y]<=0||p<=0||m>=d)){var b=ke(y,m,t,n,o,a,l),w=u[y],g=m+1;0===m&&(g=3),g>d&&(g=d);for(var S=m+1;S<=g;S++){var A=(M[S]-M[m])*p;if(!(A<=0||A>e)){var k=(b-ke(y,S,t,n,o,a,l))*w;if(k>0){var O=k/A;O>v&&(v=O,c=y,s=S,h=A)}}}}}if(c<0)break;f[c]=s,e-=h}}(r,c-s,e,t,n,o,a,i,l,f)}function Fe(r,e,t,n){for(var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,i=null!=a?a:Oe,u=i.energies,l=i.maxAmplitudes,f=i.initialScaleFactorIndices,c=i.maskThresholds,s=i.perceptualWeights,h=i.seedThresholds,v=i.distortionCache,y=i.candidateWordLengths,d=i.selectedWordLengths,p=i.refinedScaleFactorIndices,m=0,w=0;w<t;w++){var g=0|e[w];if(g<=0)u[w]=0,l[w]=0,f[w]=0;else{for(var S=r[w],A=0,k=0,O=0;O<g;O++){var j=S[O];A+=j*j;var F=j<0?-j:j;F>k&&(k=F)}if(u[w]=A,l[w]=k,m+=A,0===k)f[w]=0;else{var P=0|Math.ceil(3*(Math.log2(k)+21));f[w]=P<0?0:P>63?63:P}}}for(var M=16*t,I=0;I<M;I++)v[I]=-1;var E=t,D=b[0];D<E&&(E=D);for(var _=1;_<b.length;_++){var U=b[_];U<=t&&(E=U)}if(0===m||E<=0)return{bfuCount:E,allocation:new Int32Array(E),scaleFactorIndices:new Int32Array(t)};var H=0,R=0,L=0;o&&(H=0|o[0],R=0|o[1],L=0|o[2]),function(r,e,t,n,o,a,i,u,l){for(var f=0;f<n;f++)l[f]=0;for(var c=B.length-1,s=C.length,h=0;h<n;h++){var v=r[h];if(!(v<=0)){var y=0|t[h];if(!(y<=0)){var d=e[h],p=d*d*y/v,m=p<1?1:p,b=0;b=y<=20?x[y]:1/Math.log(y);var w=y>1?Math.min(1,Math.log(m)*b):0,g=!1,S=h;h<20?(g=0!==a)&&(S=4*(h>>2)):h<36?(g=0!==i)&&(S=20+4*(h-20>>2)):(g=0!==u)&&(S=36+8*(h-36>>3));var A=w*(14.5+.3*S)+5.5*(1-w),k=v*Math.pow(10,.1*-A);if(!(k<=0))if(g){var O=0,j=2,F=0,P=0,M=5;h<20?(O=0,j=2,F=3&h,P=h>>2,M=5):h<36?(O=20,j=2,F=h-20&3,P=h-20>>2,M=4):(O=36,j=3,F=h-36&7,P=h-36>>3,M=2);for(var T=1;T<=c;T++){var I=P-T;if(I>=0){var E=O+(I<<j)+F;E<n&&(l[E]=l[E]+k*B[T])}}for(var q=0;q<s;q++){var z=P+q;if(z<M){var D=O+(z<<j)+F;D<n&&(l[D]=l[D]+k*C[q])}}}else{var _=0;h>=36?_=0!==i?36:0:h>=20&&(_=0!==a?20:0);var U=n;h<20?0!==i&&20<n&&(U=20):h<36&&0!==u&&36<n&&(U=36);for(var H=h-c,R=H>_?H:_;R<h;R++)l[R]=l[R]+k*B[h-R];for(var L=h+s,N=L<U?L:U,G=h;G<N;G++)l[G]=l[G]+k*C[G-h]}}}}for(var W=o/n*1e-6+1e-30,V=0;V<n;V++)l[V]=l[V]+W}(u,l,e,t,m,H,R,L,c),function(r,e,t,n,o,a,i,u,l,f,c,s){for(var h=.5*(a-1),v=0;v<o;v++){var y=r[v],d=0|n[v];if(y<=0||d<=0)c[v]=0,s[v]=-1e9;else{var p=v<20?0!==i:v<36?0!==u:0!==l,m=q[v],b=.4;p&&(m=z[v],b=.3);var w=f[v]+1e-9/Math.max(m,1e-6),g=m/Math.pow(w,b);if(0!==h){var S=t[v],A=T[S];0===S&&(A=Math.max(e[v],1e-12)),g*=Math.pow(A*A,h)}c[v]=g;var k=e[v],O=y/d*.5+.5*k*k;s[v]=.5*Math.log2(O*g)}}}(u,l,f,e,t,n,H,R,L,c,s,h),je(E,r,e,f,l,u,s,h,v,y);for(var N=0,G=E-1;G>=0;G--)if(y[G]>0){N=G+1;break}for(var W=E,V=0;V<b.length;V++){var $=b[V];if($<=E&&$>=N){W=$;break}}W<E&&je(W,r,e,f,l,u,s,h,v,y);for(var Q=0;Q<W;Q++)d[Q]=y[Q];return function(r,e,t,n,o,a,i,u){for(var l=0;l<e;l++)u[l]=a[l];for(var f=0;f<r;f++){var c=i[f],s=a[f],h=0|n[f];if(!(c<=0||s<=0||h<=0||o[f]<=0)){var v=t[f],y=s,d=Ae(v,h,s,c),p=0;s>2&&(p=s-2);for(var m=p;m<s;m++){var b=Ae(v,h,m,c);b<d&&(d=b,y=m)}u[f]=y}}}(W,t,r,e,u,f,d,p),{bfuCount:W,allocation:d.slice(0,W),scaleFactorIndices:p.slice(0,t)}}function Pe(r){var e,t,n,o=null!==(e=null==r?void 0:r.options)&&void 0!==e?e:$r("allocate: options is required"),a=null!==(t=null==r||null===(n=r.bufferPool)||void 0===n||null===(n=n.encoder)||void 0===n||null===(n=n.scratch)||void 0===n?void 0:n.allocation)&&void 0!==t?t:null;return function(r){var e=r.coefficients,t=r.blockModes,n=Se(e,t,a),i=n.bfuData,u=n.bfuSizes,l=Fe(i,u,n.bfuCount,o.allocationBias,t,a),f=l.bfuCount;return{bfuData:i,bfuSizes:u,nBfu:f,scaleFactorIndices:l.scaleFactorIndices.slice(0,f),wordLengthIndices:l.allocation,blockModes:t}}}function Me(r,e,t){var n,o=null!==(n=t.analysisWindows[r.length])&&void 0!==n?n:$r("QMF analysis window for ".concat(r.length," samples is required"));o.set(e),o.set(r,e.length);var a=r.length/2,i=[new Float32Array(a),new Float32Array(a)];return function(r,e,t){var n,o,a;if(!(r instanceof Float32Array)||2!==(null==e?void 0:e.length)||e.some(function(r){return!(r instanceof Float32Array)||r.length!==e[0].length})||!t||2!==(null===(n=t.polyphase)||void 0===n?void 0:n.length)||2!==(null===(o=t.extended)||void 0===o?void 0:o.length)||2!==(null===(a=t.bands)||void 0===a?void 0:a.length))throw new RangeError("QMF analysis geometry is invalid");var i=e[0].length,u=2*Math.max(0,i-1)+48;if(r.length<u)throw new RangeError("QMF analysis window is incomplete");for(var l=0;l<i;l++){for(var f=2*l,c=0,s=0,h=0;h<24;h++)c+=r[f+47-2*h]*j[h],s+=r[f+46-2*h]*F[h];e[0][l]=c+s,e[1][l]=c-s}}(o,i,t),e.set(o.subarray(r.length,r.length+s)),i}function Te(r){var e,t=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:$r("analyzeBands: bufferPool is required"),n=t.encoder.state,o=n.qmfAnalysisDelays,a=t.encoder.scratch.qmf;return function(r){var e=Me(r,o.lowBand,a),t=Me(e[0],o.midBand,a),i=a.highBandWindows[e[1].length];i.set(n.qmfHighBandDelay),i.set(e[1],n.qmfHighBandDelay.length);var u=i.slice(0,e[1].length);return n.qmfHighBandDelay.set(i.subarray(e[1].length,e[1].length+n.qmfHighBandDelay.length)),{bands:[t[0],t[1],u]}}}function Ce(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=Be(r),o=Be(e),a=Math.abs(n-o),i=Ie(r),u=Ie(e),l=Math.abs(i-u),f=function(r,e){for(var t=0,n=0,o=0;o<r.length;o++)t+=r[o]*r[o],n+=e[o]*e[o];t=Math.max(t,1e-10),n=Math.max(n,1e-10);var a=10*Math.log10(t/n);return Math.max(0,a)}(r,e);return{spectralFlux:t,flatnessChange:a,hfChange:l,energyChange:f}}function Be(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 Ie(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 Ee(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}(Ce(r,e));return n>t}function xe(r){var e,t,n=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:$r("selectBlocks: bufferPool is required"),o=null!==(t=null==r?void 0:r.options)&&void 0!==t?t:$r("selectBlocks: options is required"),a=n.encoder.state,i=n.encoder.scratch.transient,u=[v,128,y];return function(r){var e,t=r.bands;if(o.fixedBlockModes)e=o.fixedBlockModes;else{var n=[o.transientThresholdLow,o.transientThresholdMid,o.transientThresholdHigh];e=t.map(function(r,e){var t=function(r,e){var t,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,o=null==n||null===(t=n.fft)||void 0===t?void 0:t[e],a=o?o.real:new Float32Array(e),i=o?o.imaginary:new Float32Array(e);o&&(a.fill(0),i.fill(0));var u=Math.min(r.length,e);a.set(r.subarray(0,u)),Xr.transform(a,i);for(var l=o?o.magnitudes:new Float32Array(e/2),f=0;f<e/2;f++)l[f]=Math.sqrt(a[f]*a[f]+i[f]*i[f]);return l}(r,u[e],i),o=Ee(t,a.transientDetection[e],n[e]);return a.transientDetection[e].set(t),o*Math.max(e+1,2)})}return{bands:t,blockModes:e}}}var qe=P.map(function(r){var e=r.analysisScale;return new ce(64,e)}),ze=P.map(function(r){var e=r.longMdctSize,t=r.analysisScale;return new ce(e,t)});function De(r){var e,t=null!==(e=null==r?void 0:r.bufferPool)&&void 0!==e?e:$r("transformSpectrum: bufferPool is required"),n=t.encoder.state,o=t.encoder.scratch.mdct,a=n.mdctOverlap;function i(r,e,t,n){var a=P[e];return 0===t?function(r,e,t,n,a){var i=o.transformBuffers[n.size];i.fill(0),i.set(a,t.windowStart),u(r,a,t.size),i.set(r,t.windowStart+f);var l=n.transform(i,o.fftBuffers);e>0&&(l=he(l,o.reversalBuffers));return l}(r,e,a,ze[e],n):function(r,e,t,n){for(var a=1<<(256===t.size?3:2),i=new Float32Array(t.size),c=0;c<a;c++){var s=c*l,h=r.subarray(s,s+l),v=o.transformBuffers[64];v.fill(0),v.set(n,0),u(h,n,l),v.set(h,f);var y=qe[e].transform(v,o.fftBuffers);e>0&&(y=he(y,o.reversalBuffers)),i.set(y,s)}return i}(r,e,a,n)}function u(r,e,t){for(var n=t-f,o=0;o<f;o++){var a=r[n+o];e[o]=A[o]*a,r[n+o]=a*A[31-o]}}return function(r){var e=r.bands,t=r.blockModes,n=r.originalFrame,o=new Float32Array(512);return e.forEach(function(r,e){var n=i(r,e,t[e],a[e]);o.set(n,function(r){return 0===r?0:1===r?128:256}(e))}),{bands:e,coefficients:o,blockModes:t,originalFrame:n}}}function _e(r){var e=Qr(r,Te,xe,De);return function(r){var t=e(r);return{coefficients:t.coefficients,blockModes:t.blockModes}}}function Ue(){return function(r){for(var e=r.bfuData,t=r.bfuSizes,n=r.nBfu,o=r.scaleFactorIndices,a=r.wordLengthIndices,i=r.blockModes,u=[],l=0;l<n;l++){var f=e[l].subarray(0,t[l]),c=M[a[l]];u.push(mr(f,o[l],c))}return{nBfu:n,scaleFactorIndices:o,wordLengthIndices:a,quantizedCoefficients:u,blockModes:i}}}function He(){var r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new K,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Vr;return e.encoder.state.reset(),Qr({options:r,bufferPool:e},_e,Pe,Ue)}function Re(r){return Re="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},Re(r)}var Le=["title"];function Ne(r){return function(r){if(Array.isArray(r))return Ye(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||Qe(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 Ge(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 We(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var r,e,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function a(t,n,o,a){var l=n&&n.prototype instanceof u?n:u,f=Object.create(l.prototype);return Ve(f,"_invoke",function(t,n,o){var a,u,l,f=0,c=o||[],s=!1,h={p:0,n:0,v:r,a:v,f:v.bind(r,4),d:function(e,t){return a=e,u=0,l=r,h.n=t,i}};function v(t,n){for(u=t,l=n,e=0;!s&&f&&!o&&e<c.length;e++){var o,a=c[e],v=h.p,y=a[2];t>3?(o=y===n)&&(l=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):a[0]<=v&&((o=t<2&&v<a[1])?(u=0,h.v=n,h.n=a[1]):v<y&&(o=t<3||a[0]>n||n>y)&&(a[4]=t,a[5]=n,h.n=y,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,c,y){if(f>1)throw TypeError("Generator is already running");for(s&&1===c&&v(c,y),u=c,l=y;(e=u<2?r:l)||!s;){a||(u?u<3?(u>1&&(h.n=-1),v(u,l)):h.n=l:h.v=l);try{if(f=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?l:t.call(n,h))!==i)break}catch(e){a=r,u=1,l=e}finally{f=1}}return{value:e,done:s}}}(t,o,a),!0),f}var i={};function u(){}function l(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(Ve(e={},n,function(){return this}),e),s=f.prototype=u.prototype=Object.create(c);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,f):(r.__proto__=f,Ve(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return l.prototype=f,Ve(s,"constructor",f),Ve(f,"constructor",l),l.displayName="GeneratorFunction",Ve(f,o,"GeneratorFunction"),Ve(s),Ve(s,o,"Generator"),Ve(s,n,function(){return this}),Ve(s,"toString",function(){return"[object Generator]"}),(We=function(){return{w:a,m:h}})()}function Ve(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}Ve=function(r,e,t,n){function a(e,t){Ve(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))},Ve(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=[],l=!0,f=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;l=!1}else for(;!(l=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(r){f=!0,o=r}finally{try{if(!l&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(f)throw o}}return u}}(r,e)||Qe(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 Qe(r,e){if(r){if("string"==typeof r)return Ye(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)?Ye(r,e):void 0}}function Ye(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 Je(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function Ke(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,Ze(n.key),n)}}function Xe(r,e,t){return e&&Ke(r.prototype,e),t&&Ke(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function Ze(r){var e=function(r,e){if("object"!=Re(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=Re(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==Re(e)?e:e+""}function rt(r,e,t,n,o,a,i){try{var u=r[a](i),l=u.value}catch(r){return void t(r)}u.done?e(l):Promise.resolve(l).then(n,o)}function et(r){return function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(r){rt(a,n,o,i,u,"next",r)}function u(r){rt(a,n,o,i,u,"throw",r)}i(void 0)})}}function tt(r){return new at(r,0)}function nt(r){return function(){return new ot(r.apply(this,arguments))}}function ot(r){var e,t;function n(e,t){try{var a=r[e](t),i=a.value,u=i instanceof at;Promise.resolve(u?i.v:i).then(function(t){if(u){var l="return"===e&&i.k?e:"next";if(!i.k||t.done)return n(l,t);t=r[l](t).value}o(!!a.done,t)},function(r){n("throw",r)})}catch(r){o(2,r)}}function o(r,o){2===r?e.reject(o):e.resolve({value:o,done:r}),(e=e.next)?n(e.key,e.arg):t=null}this._invoke=function(r,o){return new Promise(function(a,i){var u={key:r,arg:o,resolve:a,reject:i,next:null};t?t=t.next=u:(e=t=u,n(r,o))})},"function"!=typeof r.return&&(this.return=void 0)}function at(r,e){this.v=r,this.k=e}function it(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 ut(e.call(r));t="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function ut(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 ut=function(r){this.s=r,this.n=r.next},ut.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 ut(r)}function lt(r){if(1!==r&&2!==r)throw new Error("Unsupported channel count: ".concat(r))}function ft(r,e){var n=1===e?[r]:r;if(!Array.isArray(n)||n.length!==e||n.some(function(r){return!(r instanceof Float32Array)}))throw new TypeError("ATRAC1 streaming requires ".concat(e," Float32 channel").concat(1===e?"":"s"," per frame"));if(n.some(function(r){return r.length!==t}))throw new RangeError("ATRAC1 streaming requires exactly ".concat(t," samples per channel"))}function ct(){return{nBfu:0,blockModes:[0,0,0],scaleFactorIndices:new Int32Array(0),wordLengthIndices:new Int32Array(0),quantizedCoefficients:[]}}function st(r){return ht.apply(this,arguments)}function ht(){return(ht=et(We().m(function r(e){var t,n,o,a,i,u,l,f;return We().w(function(r){for(;;)switch(r.p=r.n){case 0:t=[],n=!1,o=!1,r.p=1,i=it(e);case 2:return r.n=3,i.next();case 3:if(!(n=!(u=r.v).done)){r.n=5;break}l=u.value,t.push(l);case 4:n=!1,r.n=2;break;case 5:r.n=7;break;case 6:r.p=6,f=r.v,o=!0,a=f;case 7:if(r.p=7,r.p=8,!n||null==i.return){r.n=9;break}return r.n=9,i.return();case 9:if(r.p=9,!o){r.n=10;break}throw a;case 10:return r.f(9);case 11:return r.f(7);case 12:return r.a(2,t)}},r,null,[[8,,9,11],[1,6,7,12]])}))).apply(this,arguments)}ot.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},ot.prototype.next=function(r){return this._invoke("next",r)},ot.prototype.throw=function(r){return this._invoke("throw",r)},ot.prototype.return=function(r){return this._invoke("return",r)};var vt=function(){return Xe(function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Je(this,r);var t=e.channelCount,n=void 0===t?1:t,o=e.onProgress,a=e.encoderOptions;lt(n);var i=a||new K;this.channelCount=n,this.onProgress=o,this.frameIndex=0,this.sampleCount=0,this.finalized=!1,this.leftEncoder=He(i),this.rightEncoder=2===n?He(i):null},[{key:"frames",value:function(r){var e=this;return nt(We().m(function n(){var o,a,i,u,l,f,c,s,h,v;return We().w(function(n){for(;;)switch(n.p=n.n){case 0:if(!e.finalized){n.n=1;break}throw new Error("ATRAC1 encoder has already been finalized");case 1:o=!1,a=!1,n.p=2,u=it(r);case 3:return n.n=4,tt(u.next());case 4:if(!(o=!(l=n.v).done)){n.n=10;break}if(ft(f=l.value,e.channelCount),1!==e.channelCount){n.n=6;break}return n.n=5,e.leftEncoder(f);case 5:n.n=8;break;case 6:return c=$e(f,2),s=c[0],h=c[1],n.n=7,e.leftEncoder(s);case 7:return n.n=8,e.rightEncoder(h);case 8:e.sampleCount+=t,e.onProgress&&e.onProgress(e.frameIndex++);case 9:o=!1,n.n=3;break;case 10:n.n=12;break;case 11:n.p=11,v=n.v,a=!0,i=v;case 12:if(n.p=12,n.p=13,!o||null==u.return){n.n=14;break}return n.n=14,tt(u.return());case 14:if(n.p=14,!a){n.n=15;break}throw i;case 15:return n.f(14);case 16:return n.f(12);case 17:return n.a(2)}},n,null,[[13,,14,16],[2,11,12,17]])}))()}},{key:"finish",value:We().m(function r(){var e,n;return We().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(t),n=0;case 3:if(!(n<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:n++,r.n=3;break;case 6:return r.a(2)}},r,this)})}])}(),yt=function(){return Xe(function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};Je(this,r);var t=e.channelCount,n=void 0===t?1:t,o=e.onProgress,a=e.primingSampleCount,i=void 0===a?0:a,u=e.sampleCount,l=void 0===u?Number.POSITIVE_INFINITY:u;lt(n),this.channelCount=n,this.onProgress=o,this.frameIndex=0,this.primingSampleCount=i,this.sampleCount=l,this.timelinePosition=0,this.emittedSamples=0,this.leftFrame=null,this.leftDecoder=ge(),this.rightDecoder=2===n?ge():null},[{key:"frames",value:function(r){var e=this;return nt(We().m(function t(){var n,o,a,i,u,l,f;return We().w(function(t){for(;;)switch(t.p=t.n){case 0:n=!1,o=!1,t.p=1,i=it(r);case 2:return t.n=3,tt(i.next());case 3:if(!(n=!(u=t.v).done)){t.n=9;break}if(l=u.value,1!==e.channelCount){t.n=5;break}return t.n=4,e.trim(e.leftDecoder(l));case 4:e.reportProgress(),t.n=8;break;case 5:if(null!==e.leftFrame){t.n=6;break}e.leftFrame=l,t.n=8;break;case 6:return t.n=7,e.trim([e.leftDecoder(e.leftFrame),e.rightDecoder(l)]);case 7:e.leftFrame=null,e.reportProgress();case 8:n=!1,t.n=2;break;case 9:t.n=11;break;case 10:t.p=10,f=t.v,o=!0,a=f;case 11:if(t.p=11,t.p=12,!n||null==i.return){t.n=13;break}return t.n=13,tt(i.return());case 13:if(t.p=13,!o){t.n=14;break}throw a;case 14:return t.f(13);case 15:return t.f(11);case 16:return t.a(2)}},t,null,[[12,,13,15],[1,10,11,16]])}))()}},{key:"finish",value:We().m(function r(){return We().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(ct())]);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),n=this.sampleCount-this.emittedSamples,o=Math.max(0,Math.min(t-e,n));return this.timelinePosition+=t,this.emittedSamples+=o,1===this.channelCount?r.slice(e,e+o):r.map(function(r){return r.slice(e,e+o)})}},{key:"reportProgress",value:function(){this.onProgress&&this.onProgress(this.frameIndex++)}}])}();function dt(r){return new vt(r)}function pt(r){return new yt(r)}function mt(){return mt=et(We().m(function r(e){var t,n,a,i,u,l,f,c,s,h=arguments;return We().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,a=void 0===n?"encoded by carta1":n,i=Ge(t,Le),u=dt({channelCount:e.length,encoderOptions:new K(i)}),l=u.frames(yr(e)),r.n=2,st(l);case 2:return(f=r.v).push.apply(f,Ne(u.finish())),c=L.createHeader(a,f.length,e.length,e[0].length,266),(s=new Uint8Array(c.length+f.length*o)).set(c),f.forEach(function(r,e){s.set(or(r),c.length+e*o)}),r.a(2,s)}},r)})),mt.apply(this,arguments)}function bt(){return(bt=et(We().m(function r(e){var t,a,i,u,l,f,c;return We().w(function(r){for(;;)switch(r.n){case 0:if(!(e instanceof Blob)){r.n=2;break}return f=Uint8Array,r.n=1,e.arrayBuffer();case 1:c=r.v,t=new f(c),r.n=5;break;case 2:if(!(e instanceof Uint8Array)){r.n=3;break}t=e,r.n=5;break;case 3:if(!(e instanceof ArrayBuffer)){r.n=4;break}t=new Uint8Array(e),r.n=5;break;case 4:throw new TypeError("ATRAC1 decoding requires AEA bytes or a Blob");case 5:return a=L.parseHeader(t.subarray(0,n)),i=pt({channelCount:a.channelCount,primingSampleCount:a.primingSampleCount,sampleCount:a.sampleCount}),u=nt(We().m(function r(){var e;return We().w(function(r){for(;;)switch(r.n){case 0:e=n;case 1:if(!(e+o<=t.length)){r.n=3;break}return r.n=2,ar(t.subarray(e,e+o));case 2:e+=o,r.n=1;break;case 3:return r.a(2)}},r)}))(),r.n=6,st(i.frames(u));case 6:if((l=r.v).push.apply(l,Ne(i.finish())),1!==a.channelCount){r.n=7;break}return r.a(2,[vr(l)]);case 7:return r.a(2,[vr(l.map(function(r){return $e(r,1)[0]})),vr(l.map(function(r){return $e(r,2)[1]}))])}},r)}))).apply(this,arguments)}function wt(r){return wt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},wt(r)}function gt(r,e){return function(r){if(Array.isArray(r))return r}(r)||function(r,e){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var n,o,a,i,u=[],l=!0,f=!1;try{if(a=(t=t.call(r)).next,0===e){if(Object(t)!==t)return;l=!1}else for(;!(l=(n=a.call(t)).done)&&(u.push(n.value),u.length!==e);l=!0);}catch(r){f=!0,o=r}finally{try{if(!l&&null!=t.return&&(i=t.return(),Object(i)!==i))return}finally{if(f)throw o}}return u}}(r,e)||At(r,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function St(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=At(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var n=0,o=function(){};return{s:o,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(r){throw r},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,u=!1;return{s:function(){t=t.call(r)},n:function(){var r=t.next();return i=r.done,r},e:function(r){u=!0,a=r},f:function(){try{i||null==t.return||t.return()}finally{if(u)throw a}}}}function At(r,e){if(r){if("string"==typeof r)return kt(r,e);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?kt(r,e):void 0}}function kt(r,e){(null==e||e>r.length)&&(e=r.length);for(var t=0,n=Array(e);t<e;t++)n[t]=r[t];return n}function Ot(r,e,t,n,o,a,i){try{var u=r[a](i),l=u.value}catch(r){return void t(r)}u.done?e(l):Promise.resolve(l).then(n,o)}function jt(r){return function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(r){Ot(a,n,o,i,u,"next",r)}function u(r){Ot(a,n,o,i,u,"throw",r)}i(void 0)})}}function Ft(r){if(null!=r){var e=r["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],t=0;if(e)return e.call(r);if("function"==typeof r.next)return r;if(!isNaN(r.length))return{next:function(){return r&&t>=r.length&&(r=void 0),{value:r&&r[t++],done:!r}}}}throw new TypeError(wt(r)+" is not iterable")}function Pt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var r,e,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function a(t,n,o,a){var l=n&&n.prototype instanceof u?n:u,f=Object.create(l.prototype);return Mt(f,"_invoke",function(t,n,o){var a,u,l,f=0,c=o||[],s=!1,h={p:0,n:0,v:r,a:v,f:v.bind(r,4),d:function(e,t){return a=e,u=0,l=r,h.n=t,i}};function v(t,n){for(u=t,l=n,e=0;!s&&f&&!o&&e<c.length;e++){var o,a=c[e],v=h.p,y=a[2];t>3?(o=y===n)&&(l=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):a[0]<=v&&((o=t<2&&v<a[1])?(u=0,h.v=n,h.n=a[1]):v<y&&(o=t<3||a[0]>n||n>y)&&(a[4]=t,a[5]=n,h.n=y,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,c,y){if(f>1)throw TypeError("Generator is already running");for(s&&1===c&&v(c,y),u=c,l=y;(e=u<2?r:l)||!s;){a||(u?u<3?(u>1&&(h.n=-1),v(u,l)):h.n=l:h.v=l);try{if(f=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?l:t.call(n,h))!==i)break}catch(e){a=r,u=1,l=e}finally{f=1}}return{value:e,done:s}}}(t,o,a),!0),f}var i={};function u(){}function l(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(Mt(e={},n,function(){return this}),e),s=f.prototype=u.prototype=Object.create(c);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,f):(r.__proto__=f,Mt(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return l.prototype=f,Mt(s,"constructor",f),Mt(f,"constructor",l),l.displayName="GeneratorFunction",Mt(f,o,"GeneratorFunction"),Mt(s),Mt(s,o,"Generator"),Mt(s,n,function(){return this}),Mt(s,"toString",function(){return"[object Generator]"}),(Pt=function(){return{w:a,m:h}})()}function Mt(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}Mt=function(r,e,t,n){function a(e,t){Mt(r,e,function(r){return this._invoke(e,t,r)})}e?o?o(r,e,{value:t,enumerable:!n,configurable:!n,writable:!n}):r[e]=t:(a("next",0),a("throw",1),a("return",2))},Mt(r,e,t,n)}function Tt(r,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(r,Ct(n.key),n)}}function Ct(r){var e=function(r,e){if("object"!=wt(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=wt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==wt(e)?e:e+""}function Bt(r){return function(){return new It(r.apply(this,arguments))}}function It(r){var e,t;function n(e,t){try{var a=r[e](t),i=a.value,u=i instanceof xt;Promise.resolve(u?i.v:i).then(function(t){if(u){var l="return"===e&&i.k?e:"next";if(!i.k||t.done)return n(l,t);t=r[l](t).value}o(!!a.done,t)},function(r){n("throw",r)})}catch(r){o(2,r)}}function o(r,o){2===r?e.reject(o):e.resolve({value:o,done:r}),(e=e.next)?n(e.key,e.arg):t=null}this._invoke=function(r,o){return new Promise(function(a,i){var u={key:r,arg:o,resolve:a,reject:i,next:null};t?t=t.next=u:(e=t=u,n(r,o))})},"function"!=typeof r.return&&(this.return=void 0)}function Et(r){var e={},t=!1;function n(e,n){return t=!0,n=new Promise(function(t){t(r[e](n))}),{done:!1,value:new xt(n,1)}}return e["undefined"!=typeof Symbol&&Symbol.iterator||"@@iterator"]=function(){return this},e.next=function(r){return t?(t=!1,r):n("next",r)},"function"==typeof r.throw&&(e.throw=function(r){if(t)throw t=!1,r;return n("throw",r)}),"function"==typeof r.return&&(e.return=function(r){return t?(t=!1,r):n("return",r)}),e}function xt(r,e){this.v=r,this.k=e}function qt(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 zt(e.call(r));t="@@asyncIterator",n="@@iterator"}throw new TypeError("Object is not async iterable")}function zt(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 zt=function(r){this.s=r,this.n=r.next},zt.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 zt(r)}It.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},It.prototype.next=function(r){return this._invoke("next",r)},It.prototype.throw=function(r){return this._invoke("throw",r)},It.prototype.return=function(r){return this._invoke("return",r)};var Dt=function(){function r(){!function(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}(this,r)}return a=r,i=null,u=[{key:"encodeAeaPcm",value:function(r){return function(r){return mt.apply(this,arguments)}(r,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}},{key:"decodeAeaPcm",value:function(r){return function(r){return bt.apply(this,arguments)}(r)}},{key:"encodeStream",value:function(r){return Bt(function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Pt().m(function t(){var n;return Pt().w(function(t){for(;;)switch(t.n){case 0:return n=dt(e),t.d(Ft(Et(qt(n.frames(r)))),1);case 1:return t.d(Ft(Et(qt(n.finish()))),2);case 2:return t.a(2)}},t)})()}).apply(this,arguments)}},{key:"decodeStream",value:function(r){return Bt(function(r){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Pt().m(function t(){var n;return Pt().w(function(t){for(;;)switch(t.n){case 0:return n=pt(e),t.d(Ft(Et(qt(n.frames(r)))),1);case 1:return t.d(Ft(Et(qt(n.finish()))),2);case 2:return t.a(2)}},t)})()}).apply(this,arguments)}},{key:"frameBufferToFrames",value:Pt().m(function r(e,t){return Pt().w(function(r){for(;;)switch(r.n){case 0:return r.d(Ft(yr(e,t)),1);case 1:return r.a(2)}},r)})},{key:"collectFrames",value:(c=jt(Pt().m(function r(e){var t,n,o,a,i,u,l,f;return Pt().w(function(r){for(;;)switch(r.p=r.n){case 0:t=[],n=!1,o=!1,r.p=1,i=qt(e);case 2:return r.n=3,i.next();case 3:if(!(n=!(u=r.v).done)){r.n=5;break}l=u.value,t.push(l);case 4:n=!1,r.n=2;break;case 5:r.n=7;break;case 6:r.p=6,f=r.v,o=!0,a=f;case 7:if(r.p=7,r.p=8,!n||null==i.return){r.n=9;break}return r.n=9,i.return();case 9:if(r.p=9,!o){r.n=10;break}throw a;case 10:return r.f(9);case 11:return r.f(7);case 12:return r.a(2,t)}},r,null,[[8,,9,11],[1,6,7,12]])})),function(r){return c.apply(this,arguments)})},{key:"createAeaBlob",value:(f=jt(Pt().m(function r(e){var n,o,a,i,u,l,f,c,s,h,v,y,d,p,m,b,w,g=arguments;return Pt().w(function(r){for(;;)switch(r.p=r.n){case 0:a=(o=g.length>1&&void 0!==g[1]?g[1]:{}).title,i=void 0===a?"encoded by atrac1.js":a,u=o.channelCount,l=void 0===u?1:u,f=[],c=!1,s=!1,r.p=1,v=qt(e);case 2:return r.n=3,v.next();case 3:if(!(c=!(y=r.v).done)){r.n=5;break}d=y.value,f.push(or(d));case 4:c=!1,r.n=2;break;case 5:r.n=7;break;case 6:r.p=6,w=r.v,s=!0,h=w;case 7:if(r.p=7,r.p=8,!c||null==v.return){r.n=9;break}return r.n=9,v.return();case 9:if(r.p=9,!s){r.n=10;break}throw h;case 10:return r.f(9);case 11:return r.f(7);case 12:return p=f.length/l,m=null!==(n=o.sampleCount)&&void 0!==n?n:Math.max(0,p-1)*t,b=L.createHeader(i,f.length,l,m,266),r.a(2,new Blob([b].concat(f),{type:"application/octet-stream"}))}},r,null,[[8,,9,11],[1,6,7,12]])})),function(r){return f.apply(this,arguments)})},{key:"parseAeaBlob",value:(l=jt(Pt().m(function r(e){var t,a,i,u,l,f;return Pt().w(function(r){for(;;)switch(r.n){case 0:return r.n=1,e.arrayBuffer();case 1:for(t=r.v,a=new Uint8Array(t.slice(0,n)),i=L.parseHeader(a),u=[],l=n;l<t.byteLength;)(f=new Uint8Array(t.slice(l,l+o))).length===o&&u.push(f),l+=o;return r.a(2,{info:i,frameData:u})}},r)})),function(r){return l.apply(this,arguments)})},{key:"deserializedFrameStream",value:Pt().m(function r(e){var t,n,o,a;return Pt().w(function(r){for(;;)switch(r.p=r.n){case 0:t=St(e),r.p=1,t.s();case 2:if((n=t.n()).done){r.n=4;break}return o=n.value,r.n=3,ar(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 t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e;if(1===n)t=[vr(r)];else{if(2!==n)throw new Error("Unsupported channel count: ".concat(n));t=[vr(r.map(function(r){return gt(r,1)[0]})),vr(r.map(function(r){return gt(r,2)[1]}))]}return new Blob([pr(t,{sampleRate:o})],{type:"audio/wav"})}},{key:"createWavBlob",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e;return r.createPcmWaveBlob(t,n,o)}},{key:"assemblePcmFrames",value:function(r,e){if(1===e)return vr(r);if(2!==e)throw new Error("Unsupported channel count: ".concat(e));for(var t=vr(r.map(function(r){return gt(r,1)[0]})),n=vr(r.map(function(r){return gt(r,2)[1]})),o=new Float32Array(2*Math.max(t.length,n.length)),a=0;a<o.length/2;a++){var i,u;o[2*a]=null!==(i=t[a])&&void 0!==i?i:0,o[2*a+1]=null!==(u=n[a])&&void 0!==u?u:0}return o}}],i&&Tt(a.prototype,i),u&&Tt(a,u),Object.defineProperty(a,"prototype",{writable:!1}),a;var a,i,u,l,f,c}();function _t(r){return _t="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},_t(r)}function Ut(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 Ht(r){for(var e=1;e<arguments.length;e++){var t=null!=arguments[e]?arguments[e]:{};e%2?Ut(Object(t),!0).forEach(function(e){Rt(r,e,t[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Ut(Object(t)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(t,e))})}return r}function Rt(r,e,t){return(e=function(r){var e=function(r,e){if("object"!=_t(r)||!r)return r;var t=r[Symbol.toPrimitive];if(void 0!==t){var n=t.call(r,e||"default");if("object"!=_t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(r)}(r,"string");return"symbol"==_t(e)?e:e+""}(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Lt(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var r,e,t="function"==typeof Symbol?Symbol:{},n=t.iterator||"@@iterator",o=t.toStringTag||"@@toStringTag";function a(t,n,o,a){var l=n&&n.prototype instanceof u?n:u,f=Object.create(l.prototype);return Nt(f,"_invoke",function(t,n,o){var a,u,l,f=0,c=o||[],s=!1,h={p:0,n:0,v:r,a:v,f:v.bind(r,4),d:function(e,t){return a=e,u=0,l=r,h.n=t,i}};function v(t,n){for(u=t,l=n,e=0;!s&&f&&!o&&e<c.length;e++){var o,a=c[e],v=h.p,y=a[2];t>3?(o=y===n)&&(l=a[(u=a[4])?5:(u=3,3)],a[4]=a[5]=r):a[0]<=v&&((o=t<2&&v<a[1])?(u=0,h.v=n,h.n=a[1]):v<y&&(o=t<3||a[0]>n||n>y)&&(a[4]=t,a[5]=n,h.n=y,u=0))}if(o||t>1)return i;throw s=!0,n}return function(o,c,y){if(f>1)throw TypeError("Generator is already running");for(s&&1===c&&v(c,y),u=c,l=y;(e=u<2?r:l)||!s;){a||(u?u<3?(u>1&&(h.n=-1),v(u,l)):h.n=l:h.v=l);try{if(f=2,a){if(u||(o="next"),e=a[o]){if(!(e=e.call(a,l)))throw TypeError("iterator result is not an object");if(!e.done)return e;l=e.value,u<2&&(u=0)}else 1===u&&(e=a.return)&&e.call(a),u<2&&(l=TypeError("The iterator does not provide a '"+o+"' method"),u=1);a=r}else if((e=(s=h.n<0)?l:t.call(n,h))!==i)break}catch(e){a=r,u=1,l=e}finally{f=1}}return{value:e,done:s}}}(t,o,a),!0),f}var i={};function u(){}function l(){}function f(){}e=Object.getPrototypeOf;var c=[][n]?e(e([][n]())):(Nt(e={},n,function(){return this}),e),s=f.prototype=u.prototype=Object.create(c);function h(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,f):(r.__proto__=f,Nt(r,o,"GeneratorFunction")),r.prototype=Object.create(s),r}return l.prototype=f,Nt(s,"constructor",f),Nt(f,"constructor",l),l.displayName="GeneratorFunction",Nt(f,o,"GeneratorFunction"),Nt(s),Nt(s,o,"Generator"),Nt(s,n,function(){return this}),Nt(s,"toString",function(){return"[object Generator]"}),(Lt=function(){return{w:a,m:h}})()}function Nt(r,e,t,n){var o=Object.defineProperty;try{o({},"",{})}catch(r){o=0}Nt=function(r,e,t,n){function a(e,t){Nt(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))},Nt(r,e,t,n)}function Gt(r,e,t,n,o,a,i){try{var u=r[a](i),l=u.value}catch(r){return void t(r)}u.done?e(l):Promise.resolve(l).then(n,o)}function Wt(r){return function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(r){Gt(a,n,o,i,u,"next",r)}function u(r){Gt(a,n,o,i,u,"throw",r)}i(void 0)})}}function Vt(r,e,t){return $t.apply(this,arguments)}function $t(){return($t=Wt(Lt().m(function r(e,t,n){var o,a,i,u,l,f,c;return Lt().w(function(r){for(;;)switch(r.p=r.n){case 0:return n=null!=n?n:"encoded by carta1",r.p=1,o=Dt.frameBufferToFrames(e),a=e.length,i=new K(t),u=Dt.encodeStream(o,{channelCount:a,encoderOptions:i}),r.n=2,Dt.collectFrames(u);case 2:return l=r.v,r.n=3,Dt.createAeaBlob(l,{title:n,channelCount:a,sampleCount:e[0].length});case 3:return f=r.v,r.a(2,{aeaBlob:f});case 4:throw r.p=4,c=r.v,console.error("Worker encode error:",c),c;case 5:return r.a(2)}},r,null,[[1,4]])}))).apply(this,arguments)}function Qt(){return(new K).toObject()}function Yt(r){return Jt.apply(this,arguments)}function Jt(){return(Jt=Wt(Lt().m(function r(t){var n,o,a,i,u,l,f,c,s;return Lt().w(function(r){for(;;)switch(r.n){case 0:return n=t.header,o=t.aeaData,(a=t.info)?i=Ht({sampleRate:e},a):n?(u=L.parseHeader(n),i=Ht({sampleRate:e},u)):i={channelCount:2,sampleRate:e},l=Dt.deserializedFrameStream(o),f=Dt.decodeStream(l,{channelCount:i.channelCount,primingSampleCount:i.primingSampleCount,sampleCount:i.sampleCount}),r.n=1,Dt.collectFrames(f);case 1:return c=r.v,s=Dt.createPcmWaveBlob(c,i.channelCount,i.sampleRate),r.a(2,{wavBlob:s,info:i})}},r)}))).apply(this,arguments)}self.onmessage=function(){var r=Wt(Lt().m(function r(e){var t,n,o,a,i,u,l,f,c,s,h;return Lt().w(function(r){for(;;)switch(r.p=r.n){case 0:t=e.data,n=t.jobId,o=t.type,a=t.pcmData,i=t.aea,u=t.options,l=t.title,f=t.blob,r.p=1,s=o,r.n="encode"===s?2:"decode"===s?4:"parseAea"===s?6:"getEncoderOptions"===s?8:9;break;case 2:return r.n=3,Vt(a,u,l);case 3:return c=r.v,r.a(3,10);case 4:return r.n=5,Yt(i);case 5:return c=r.v,r.a(3,10);case 6:return r.n=7,Dt.parseAeaBlob(f);case 7:return c=r.v,r.a(3,10);case 8:return c=Qt(),r.a(3,10);case 9:throw new Error("Unknown worker message type: ".concat(o));case 10:self.postMessage({jobId:n,result:c}),r.n=12;break;case 11:r.p=11,h=r.v,console.error("Worker error:",h),self.postMessage({jobId:n,error:h.message});case 12:return r.a(2)}},r,null,[[1,11]])}));return function(e){return r.apply(this,arguments)}}();const Kt=self;for(var Xt in r)Kt[Xt]=r[Xt];r.__esModule&&Object.defineProperty(Kt,"__esModule",{value:!0})})();
2
2
  //# sourceMappingURL=carta1-worker.min.js.map