-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathdecode-webm.js
More file actions
141 lines (141 loc) · 120 KB
/
Copy pathdecode-webm.js
File metadata and controls
141 lines (141 loc) · 120 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import Ms from"./src/opus.wasm.js";var li=new Map([[-1,"OPUS_BAD_ARG"],[-2,"OPUS_BUFFER_TOO_SMALL"],[-3,"OPUS_INTERNAL_ERROR"],[-4,"OPUS_INVALID_PACKET"],[-5,"OPUS_UNIMPLEMENTED"],[-6,"OPUS_INVALID_STATE"],[-7,"OPUS_ALLOC_FAIL"]]),mt;async function Ss(){if(mt)return mt;let t=Ms();mt=t;try{return await t}catch(e){throw mt=null,e}}async function oi(){return new er(await Ss())}var er=class{constructor(e){this.module=e,this.handle=0,this.input=0,this.capacity=0,this.channels=0,this.sampleRate=0,this.frameNumber=0,this.inputBytes=0,this.outputSamples=0,this.freed=!1}configure(e){if(this.freed)throw Error("Decoder already freed");let i=e.sampleRate??48e3,n=e.channels;if(![8e3,12e3,16e3,24e3,48e3].includes(i))throw RangeError("Invalid Opus sample rate");if(!Number.isInteger(n)||n<1||n>255)throw RangeError("Invalid Opus channel count");let r=e.streamCount??1,s=e.coupledStreamCount??(n===2?1:0);if(!Number.isInteger(r)||r<1||r>255||!Number.isInteger(s)||s<0||s>r||r+s>255)throw RangeError("Invalid Opus stream layout");let a=e.channelMappingTable??(n===1?[0]:n===2?[0,1]:null);if(!a||a.length!==n)throw Error("Invalid Opus channel mapping");a=Array.from(a);let l=r+s;if(a.some(h=>!Number.isInteger(h)||h<0||h>255||h>=l&&h!==255))throw Error("Invalid Opus channel mapping");let o=e.preSkip??0,c=e.outputGain??0;if(!Number.isSafeInteger(o)||o<0||o>2147483647)throw RangeError("Invalid Opus pre-skip");if(!Number.isInteger(c)||c<-32768||c>32767)throw RangeError("Invalid Opus output gain");this.unconfigure();let u=this.module._malloc(n);if(!u)throw Error("Unable to allocate Opus channel mapping");try{this.module.HEAPU8.set(a,u),this.handle=this.module._audio_opus_create(i,n,r,s,u,o,c)}finally{this.module._free(u)}if(!this.handle){let h=this.module._audio_opus_last_error();throw Error("libopus "+h+" "+(li.get(h)||"UNKNOWN_ERROR"))}this.channels=n,this.sampleRate=i,this.frameNumber=0,this.inputBytes=0,this.outputSamples=0}decodeFrames(e){if(this.freed)throw Error("Decoder already freed");if(!this.handle)throw Error("Opus decoder is not configured");let i=[],n=[],r=0;for(let a of e){if(!(a instanceof Uint8Array))throw TypeError("Opus packet must be a Uint8Array");if(a.length>this.capacity){let o=this.module._malloc(a.length);if(!o)throw Error("Unable to allocate Opus input buffer");this.input&&this.module._free(this.input),this.input=o,this.capacity=a.length}a.length&&this.module.HEAPU8.set(a,this.input);let l=this.module._audio_opus_decode(this.handle,this.input,a.length);if(l<0)n.push({message:"libopus "+l+" "+(li.get(l)||"UNKNOWN_ERROR"),frameLength:a.length,frameNumber:this.frameNumber,inputBytes:this.inputBytes,outputSamples:this.outputSamples});else if(l){let o=this.module._audio_opus_output(this.handle)>>2;i.push(Array.from({length:this.channels},(c,u)=>this.module.HEAPF32.slice(o+u*l,o+(u+1)*l))),r+=l,this.outputSamples+=l}this.frameNumber++,this.inputBytes+=a.length}let s=r?Array.from({length:this.channels},(a,l)=>{let o=new Float32Array(r),c=0;for(let u of i)o.set(u[l],c),c+=u[l].length;return o}):[];return{errors:n,channelData:s,samplesDecoded:r,sampleRate:this.sampleRate,bitDepth:32}}unconfigure(){this.handle&&(this.module._audio_opus_destroy(this.handle),this.handle=0,this.channels=0,this.sampleRate=0)}free(){this.freed||(this.unconfigure(),this.input&&this.module._free(this.input),this.input=0,this.capacity=0,this.freed=!0)}};var ws=(t,e=4294967295,i=79764919)=>{let n=new Int32Array(256),r,s,a,l=e;for(r=0;r<256;r++){for(a=r<<24,s=8;s>0;--s)a=2147483648&a?a<<1^i:a<<1;n[r]=a}for(r=0;r<t.length;r++)l=l<<8^n[255&(l>>24^t[r])];return l},ci=(t,e=ws)=>{let i=m=>new Uint8Array(m.length/2).map(((b,V)=>parseInt(m.substring(2*V,2*(V+1)),16))),n=m=>i(m)[0],r=new Map;[,8364,,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,,381,,,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,,382,376].forEach(((m,b)=>r.set(m,b)));let s=new Uint8Array(t.length),a,l,o,c=!1,u=0,h=42,p=t.length>13&&t.substring(0,9)==="dynEncode",_=0;p&&(_=11,l=n(t.substring(9,_)),l<=1&&(_+=2,h=n(t.substring(11,_))),l===1&&(_+=8,o=(m=>new DataView(i(m).buffer).getInt32(0,!0))(t.substring(13,_))));let H=256-h;for(let m=_;m<t.length;m++)if(a=t.charCodeAt(m),a!==61||c){if(a===92&&m<t.length-5&&p){let b=t.charCodeAt(m+1);b!==117&&b!==85||(a=parseInt(t.substring(m+2,m+6),16),m+=5)}if(a>255){let b=r.get(a);b&&(a=b+127)}c&&(c=!1,a-=64),s[u++]=a<h&&a>0?a+H:a-h}else c=!0;let g=s.subarray(0,u);if(p&&l===1){let m=e(g);if(m!==o){let b="Decode failed crc32 validation";throw console.error("`simple-yenc`\n",b+`
`,"Expected: "+o+"; Got: "+m+`
`,"Visit https://github.com/eshaz/simple-yenc for more information"),Error(b)}}return g};function Q(){let t=Uint8Array,e=Float32Array;Q.modules||Object.defineProperties(Q,{modules:{value:new WeakMap},setModule:{value(i,n){Q.modules.set(i,Promise.resolve(n))}},getModule:{value(i,n){let r=Q.modules.get(i);return r||(n?r=WebAssembly.compile(ci(n)):(n=i.wasm,r=Q.inflateDynEncodeString(n).then(s=>WebAssembly.compile(s))),Q.modules.set(i,r)),r}},concatFloat32:{value(i,n){let r=new e(n),s=0,a=0;for(;s<i.length;)r.set(i[s],a),a+=i[s++].length;return r}},getDecodedAudio:{value:(i,n,r,s,a)=>({errors:i,channelData:n,samplesDecoded:r,sampleRate:s,bitDepth:a})},getDecodedAudioMultiChannel:{value(i,n,r,s,a,l){let o=[],c,u;for(c=0;c<r;c++){let h=[];for(u=0;u<n.length;)h.push(n[u++][c]||[]);o.push(Q.concatFloat32(h,s))}return Q.getDecodedAudio(i,o,s,a,l)}},inflateDynEncodeString:{value(i){return i=ci(i),new Promise(n=>{let r=String.raw`dynEncode012804c7886d()((()>+*§§)§,§§§§)§+§§§)§+.-()(*)-+)(.7*§)i¸¸,3§(i¸¸,3/G+.¡*(,(,3+)2å:-),§H(P*DI*H(P*@I++hH)H*r,hH(H(P*<J,i)^*<H,H(P*4U((I-H(H*i0J,^*DH+H-H*I+H,I*4)33H(H*H)^*DH(H+H)^*@H+i§H)i§3æ*).§K(iHI/+§H,iHn,§H+i(H+i(rCJ0I,H*I-+hH,,hH(H-V)(i)J.H.W)(i)c)(H,i)I,H-i*I-4)33i(I.*hH(V)(H+n5(H(i*I-i(I,i)I.+hH,i*J+iHn,hi(I-i*I,+hH,H/H-c)(H,iFn,hi(I,+hH,H0n5-H*V)(J(,hH/H(i)J(H(V)(J(i)c)(H)H(i)H,c)(3H*i*I*H,i)I,4(3(-H(H,W)(H-I-H,i*I,4)3(3(3H,H-I1H+I,H.i)H1V)(J.i(v5(33H.-H(H,i(c)(H,i*I,4)333)-§i*I*+§H*iHn,hi73H,H(i)8(H+J+H)P*(H*V)(J-r,§H)P*,H.i)H+H,i)V)(-H*i*I*H+i)I+H-H.I.H,H-i)I,4)333Ã+)-§iø7i(^*(iü7I,*h+hH+iDn,h*hilI+i)I,+hH+,hH+iô7H,c)(i)H+i´8W)(H,I,H+i*I+4)-+hH(H)8*J-i(p5.*h*h*hH-i')u,hH(P*(J+,hH(P*0J,H(P*,n50H+H,H-b((3H(P*0i)I.4)3H-i¨*n5*H-iÅ*s,hi73H-i)J+V)&+I,H(H+V)æ,8(I.H(H*8*J-i(p51H-i)J+i¸7V)(H(H+iø7V)(8(J/H(P*0J+s,hi73H+H,H.J,I.H(P*(m5(H.H(P*,s5.+hH,m5*H(P*(J.H+H.H+H/U((b((H(H(P*0i)J+^*0H,i)I,4(3(3H(H.^*03H-i¨*o5)33i(73(3(3-H,H+i)c)(H,i*I,H+i)I+4)33i)I-3H-3!2)0§K(i2J,L(H,H(^*(H,H*^*4H,i(^*0H,i(^*DH,j(_*<H,H)P*(^*,H,H+P*(^*8*h*h+hH,i)8(I3i§I**h*h*h*h*h*h*hH,i*8(6+(),03H,j(_*@i*I-H,P*<J.i,J(H,P*8J/s50H,H.i+J0^*<i¦I*H.H,P*4J1J.U(*H.U((J2i')o5/H.U()I.H,H(^*<H0H1U((H.i0J.i§i0i')o5/H/H.H2J*H(J.q50H,P*0J/H*I-H,P*(J0,hH,P*,H-q,hi)I-423+hH*m5+H/H0H(H1U((b((H/i)I/H(i)I(H*i)I*4(3(3H,H.^*<H,H-^*04*3iØ1U((5+i(I(i¨7i1^*(i$6iè1^*(i°7iè6^*(i¬7iÈ6^*(+hH(iÈ*n,hiÈ*I(+hH(i¨,n,hi¨,I(+hH(iØ,n,hiØ,I(+hH(iè,o,hH,i-H(i0c)(H(i*I(4)33iè1i1H,i-iÈ*8)Bi(I(+hH(ido,hH,i-H(i-c)(H(i*I(4)33iÈ6iè6H,i-iF8)BiØ1i)b((41-H,i-H(i/c)(H(i*I(4)3(3(-H,i-H(i1c)(H(i*I(4)3(3(-H,i-H(i0c)(H(i*I(4)3(3(3H,H/^*0H,H(^*<3i(I*4*3H,H,i¸)^*TH,H,iø-^*PH,H,iX^*LH,H,i(^*HH,i-8(I(H,i-8(I-i¥I*H,i,8(I.H(iErH-iEr5)H(i©*I1H-i)I0i(i;H.i,J(i(H(i(rCJ(J*H*i;sCI*i¨1I-H(I/+hH/,hH,i-H-V)(i)H,i+8(c)(H/i)I/H-i*I-H*i)I*4)-H(i)i¨1I/+hH(H*o,hH,i-H/V)(i)i(c)(H/i*I/H(i)I(4)33i¤I*H,iø-H,i¸)H,i-i;8)5+H0H1I2i(I-+hH-H2p,hH,H,iP8*J*i(p5-H*i7u,hH,i-H-i)H*c)(H-i)I-4*3i(I/i+I.i+I(*h*h*hH*i86*(*)3H-m,hi£I*403H-i)H,W)-I/i*I(4)3i3I.i/I(3H2H,H(8(H.J(H-J.p,hi¢I*4.3H,i-H-i)I*+hH(,hH*H/c)(H*i*I*H(i)I(4)-H.I-4+3(3(33H,W)1m,hiI*4,3H,iø-H,i¸)H,i-H18)J(,hi¡I*H(i(p5,H1H,V)ú-H,V)ø-o5,3H,i(H,iXH,i-H1i)H08)J(,hi I*H(i(p5,H0H,V)H,V)o5,3H,H,iPH,iH8+I*4+3(3(3H,i$6i¬78+I*3H*H3m5(3i)I-H*i(r5)3H)H,P*0^*(H+H,P*<^*(H*I-3H,i2L(H-33Á)+(i¨03b+(,(-(.(/(0(1(2(3(5(7(9(;(?(C(G(K(S([(c(k({(((«(Ë(ë((*)(iø03O)()()()(*(*(*(*(+(+(+(+(,(,(,(,(-(-(-(-(i¨13M8(9(:(((0(/(1(.(2(-(3(,(4(+(5(*(6()(7(T7*S7US0U `;Q.getModule(Q,r).then(s=>WebAssembly.instantiate(s,{})).then(({exports:s})=>{let a=new Map(Object.entries(s)),l=a.get("puff"),o=a.get("memory").buffer,c=new t(o),u=new DataView(o),h=a.get("__heap_base"),p=i.length,_=h;h+=4,u.setInt32(_,p,!0);let H=h;h+=p,c.set(i,H);let g=h;h+=4,u.setInt32(g,c.byteLength-h,!0),l(h,g,H,_),n(c.slice(h,h+u.getInt32(g,!0)))})})}}}),Object.defineProperty(this,"wasm",{enumerable:!0,get:()=>this._wasm}),this.getOutputChannels=(i,n,r)=>{let s=[],a=0;for(;a<n;)s.push(i.slice(a*r,a++*r+r));return s},this.allocateTypedArray=(i,n,r=!0)=>{let s=this._wasm.malloc(n.BYTES_PER_ELEMENT*i);return r&&this._pointers.add(s),{ptr:s,len:i,buf:new n(this._wasm.HEAP,s,i)}},this.free=()=>{this._pointers.forEach(i=>{this._wasm.free(i)}),this._pointers.clear()},this.codeToString=i=>{let n=[],r=new Uint8Array(this._wasm.HEAP);for(let s=r[i];s!==0;s=r[++i])n.push(s);return String.fromCharCode.apply(null,n)},this.addError=(i,n,r,s,a,l)=>{i.push({message:n,frameLength:r,frameNumber:s,inputBytes:a,outputSamples:l})},this.instantiate=(i,n)=>(n&&Q.setModule(i,n),this._wasm=new i(Q).instantiate(),this._pointers=new Set,this._wasm.ready.then(()=>this))}var C=Symbol,Si=", ",v=(()=>{let t="front",e="side",i="rear",n="left",r="center",s="right";return["",t+" ",e+" ",i+" "].map(a=>[[n,s],[n,s,r],[n,r,s],[r,n,s],[r]].flatMap(l=>l.map(o=>a+o).join(Si)))})(),le="LFE",lt="monophonic (mono)",Le="stereo",Je="surround",k=(t,...e)=>`${[lt,Le,`linear ${Je}`,"quadraphonic",`5.0 ${Je}`,`5.1 ${Je}`,`6.1 ${Je}`,`7.1 ${Je}`][t-1]} (${e.join(Si)})`,Dr=[lt,k(2,v[0][0]),k(3,v[0][2]),k(4,v[1][0],v[3][0]),k(5,v[1][2],v[3][0]),k(6,v[1][2],v[3][0],le),k(7,v[1][2],v[2][0],v[3][4],le),k(8,v[1][2],v[2][0],v[3][0],le)],bs=192e3,As=176400,wi=96e3,bi=88200,Is=64e3,Qt=48e3,Br=44100,Nr=32e3,Tr=24e3,Vr=22050,Qr=16e3,Ai=12e3,Ii=11025,Gr=8e3,Cs=7350,Se="absoluteGranulePosition",A="bandwidth",he="bitDepth",W="bitrate",tr=W+"Maximum",rr=W+"Minimum",ir=W+"Nominal",ot="buffer",sr=ot+"Fullness",O="codec",$=O+"Frames",nr="coupledStreamCount",Bt="crc",Ci=Bt+"16",Fi=Bt+"32",B="data",y="description",Ue="duration",_t="emphasis",ar="hasOpusPadding",ae="header",rt="isContinuedPacket",lr="isCopyrighted",it="isFirstPage",or="isHome",oe="isLastPage",ke="isOriginal",Re="isPrivate",cr="isVbr",X="layer",d="length",M="mode",ye=M+"Extension",Pi="mpeg",xe=Pi+"Version",hr="numberAACFrames",ur="outputGain",Dt="preSkip",dr="profile",fr=C(),Oe="protection",Fs="rawData",Me="segments",P="subarray",st="version",Gt="vorbis",pr=Gt+"Comments",Ut=Gt+"Setup",zt="block",mr=zt+"ingStrategy",_r=C(),_e=zt+"Size",je=zt+"size0",Ze=zt+"size1",gt=C(),qt="channel",ge=qt+"MappingFamily",gr=qt+"MappingTable",ue=qt+"Mode",Ht=C(),w=qt+"s",Ei="copyright",Hr=Ei+"Id",vr=Ei+"IdStart",be="frame",De=be+"Count",de=be+"Length",Kt="Number",nt=be+Kt,se=be+"Padding",S=be+"Size",Di="Rate",yr="inputSample"+Di,zr="page",Lt=zr+"Checksum",Nt=C(),$e=zr+"SegmentTable",G=zr+"Sequence"+Kt,qr="sample",Mr=qr+Kt,U=qr+Di,ne=C(),F=qr+"s",Wt="stream",Sr=Wt+"Count",Ui=Wt+"Info",Be=Wt+"Serial"+Kt,Ps=Wt+"StructureVersion",Kr="total",kt=Kr+"BytesOut",Rt=Kr+"Duration",Tt=Kr+"Samples",L=C(),ce=C(),vt=C(),Xt=C(),Ve=C(),Li=C(),hi=C(),Jt=C(),T=C(),Ge=C(),Ae=C(),ct=C(),Yt=C(),ki=C(),we=C(),Qe=C(),ze=C(),Ri=C(),ee=Uint8Array,jt=DataView,I="reserved",K="bad",Ye="free",Wr="none",xi="16bit CRC",Xr=(t,e,i)=>{for(let n=0;n<t[d];n++){let r=e(n);for(let s=8;s>0;s--)r=i(r);t[n]=r}return t},Es=Xr(new ee(256),t=>t,t=>t&128?7^t<<1:t<<1),E=[Xr(new Uint16Array(256),t=>t<<8,t=>t<<1^(t&32768?32773:0))],D=[Xr(new Uint32Array(256),t=>t,t=>t>>>1^(t&1)*3988292384)];for(let t=0;t<15;t++){E.push(new Uint16Array(256)),D.push(new Uint32Array(256));for(let e=0;e<=255;e++)E[t+1][e]=E[0][E[t][e]>>>8]^E[t][e]<<8,D[t+1][e]=D[t][e]>>>8^D[0][D[t][e]&255]}var Ds=t=>{let e=0,i=t[d];for(let n=0;n!==i;n++)e=Es[e^t[n]];return e},Us=t=>{let e=t[d],i=e-16,n=0,r=0;for(;r<=i;)n^=t[r++]<<8|t[r++],n=E[15][n>>8]^E[14][n&255]^E[13][t[r++]]^E[12][t[r++]]^E[11][t[r++]]^E[10][t[r++]]^E[9][t[r++]]^E[8][t[r++]]^E[7][t[r++]]^E[6][t[r++]]^E[5][t[r++]]^E[4][t[r++]]^E[3][t[r++]]^E[2][t[r++]]^E[1][t[r++]]^E[0][t[r++]];for(;r!==e;)n=(n&255)<<8^E[0][n>>8^t[r++]];return n},Ls=t=>{let e=t[d],i=e-16,n=0,r=0;for(;r<=i;)n=D[15][(t[r++]^n)&255]^D[14][(t[r++]^n>>>8)&255]^D[13][(t[r++]^n>>>16)&255]^D[12][t[r++]^n>>>24]^D[11][t[r++]]^D[10][t[r++]]^D[9][t[r++]]^D[8][t[r++]]^D[7][t[r++]]^D[6][t[r++]]^D[5][t[r++]]^D[4][t[r++]]^D[3][t[r++]]^D[2][t[r++]]^D[1][t[r++]]^D[0][t[r++]];for(;r!==e;)n=D[0][(n^t[r++])&255]^n>>>8;return n^-1},Ur=(...t)=>{let e=new ee(t.reduce((i,n)=>i+n[d],0));return t.reduce((i,n)=>(e.set(n,i),i+n[d]),0),e},Ie=t=>String.fromCharCode(...t),ui=[0,8,4,12,2,10,6,14,1,9,5,13,3,11,7,15],Vt=t=>ui[t&15]<<4|ui[t>>4],ks=class{constructor(t){this._data=t,this._pos=t[d]*8}set position(t){this._pos=t}get position(){return this._pos}read(t){let e=Math.floor(this._pos/8),i=this._pos%8;return this._pos-=t,(Vt(this._data[e-1])<<8)+Vt(this._data[e])>>7-i&255}},Rs=(t,e)=>{try{return t.getBigInt64(e,!0)}catch{let i=t.getUint8(e+7)&128?-1:1,n=t.getUint32(e,!0),r=t.getUint32(e+4,!0);return i===-1&&(n=~n+1,r=~r+1),r>1048575&&console.warn("This platform does not support BigInt"),i*(n+r*2**32)}},xs=class{constructor(t,e){this._onCodecHeader=t,this._onCodecUpdate=e,this[we]()}[Qe](){this._isEnabled=!0}[we](){this._headerCache=new Map,this._codecUpdateData=new WeakMap,this._codecHeaderSent=!1,this._codecShouldUpdate=!1,this._bitrate=null,this._isEnabled=!1}[ki](t,e){if(this._onCodecUpdate){this._bitrate!==t&&(this._bitrate=t,this._codecShouldUpdate=!0);let i=this._codecUpdateData.get(this._headerCache.get(this._currentHeader));this._codecShouldUpdate&&i&&this._onCodecUpdate({bitrate:t,...i},e),this._codecShouldUpdate=!1}}[T](t){let e=this._headerCache.get(t);return e&&this._updateCurrentHeader(t),e}[Ge](t,e,i){this._isEnabled&&(this._codecHeaderSent||(this._onCodecHeader({...e}),this._codecHeaderSent=!0),this._updateCurrentHeader(t),this._headerCache.set(t,e),this._codecUpdateData.set(e,i))}_updateCurrentHeader(t){this._onCodecUpdate&&t!==this._currentHeader&&(this._codecShouldUpdate=!0,this._currentHeader=t)}},Y=new WeakMap,fe=new WeakMap,qe=class{constructor(t,e){this._codecParser=t,this._headerCache=e}*[hi](){let t;do{if(t=yield*this.Frame[Ae](this._codecParser,this._headerCache,0),t)return t;this._codecParser[ce](1)}while(!0)}*[Jt](t){let e=yield*this[hi](),i=fe.get(e)[d];if(t||this._codecParser._flushing||(yield*this.Header[T](this._codecParser,this._headerCache,i)))return this._headerCache[Qe](),this._codecParser[ce](i),this._codecParser[Xt](e),e;this._codecParser[Ve](`Missing ${be} at ${i} bytes from current position.`,`Dropping current ${be} and trying again.`),this._headerCache[we](),this._codecParser[ce](1)}},Oi=class{constructor(t,e){fe.set(this,{[ae]:t}),this[B]=e}},ht=class extends Oi{static*[Ae](t,e,i,n,r){let s=yield*t[T](i,n,r);if(s){let a=Y.get(s)[de],l=Y.get(s)[F],o=(yield*i[L](a,r))[P](0,a);return new e(s,o,l)}else return null}constructor(t,e,i){super(t,e),this[ae]=t,this[F]=i,this[Ue]=i/t[U]*1e3,this[nt]=null,this[kt]=null,this[Tt]=null,this[Rt]=null,fe.get(this)[d]=e[d]}},wr="unsynchronizationFlag",br="extendedHeaderFlag",Ar="experimentalFlag",Ir="footerPresent",Os=class Bi{static*getID3v2Header(e,i,n){let s={},a=yield*e[L](3,n);if(a[0]!==73||a[1]!==68||a[2]!==51||(a=yield*e[L](10,n),s[st]=`id3v2.${a[3]}.${a[4]}`,a[5]&15)||(s[wr]=!!(a[5]&128),s[br]=!!(a[5]&64),s[Ar]=!!(a[5]&32),s[Ir]=!!(a[5]&16),a[6]&128||a[7]&128||a[8]&128||a[9]&128))return null;let l=a[6]<<21|a[7]<<14|a[8]<<7|a[9];return s[d]=10+l,new Bi(s)}constructor(e){this[st]=e[st],this[wr]=e[wr],this[br]=e[br],this[Ar]=e[Ar],this[Ir]=e[Ir],this[d]=e[d]}},ut=class{constructor(t){Y.set(this,t),this[he]=t[he],this[W]=null,this[w]=t[w],this[ue]=t[ue],this[U]=t[U]}},Ni={0:[Ye,Ye,Ye,Ye,Ye],16:[32,32,32,32,8],240:[K,K,K,K,K]},yt=(t,e,i)=>8*((t+i)%e+e)*(1<<(t+i)/e)-8*e*(e/8|0);for(let t=2;t<15;t++)Ni[t<<4]=[t*32,yt(t,4,0),yt(t,4,-1),yt(t,8,4),yt(t,8,0)];var Bs=0,Ns=1,Ts=2,Vs=3,di=4,Mt="bands ",St=" to 31",fi={0:Mt+4+St,16:Mt+8+St,32:Mt+12+St,48:Mt+16+St},ve="bitrateIndex",at="v2",xt="v1",wt="Intensity stereo ",bt=", MS stereo ",At="on",It="off",Qs={0:wt+It+bt+It,16:wt+At+bt+It,32:wt+It+bt+At,48:wt+At+bt+At},Cr={0:{[y]:I},2:{[y]:"Layer III",[se]:1,[ye]:Qs,[xt]:{[ve]:Ts,[F]:1152},[at]:{[ve]:di,[F]:576}},4:{[y]:"Layer II",[se]:1,[ye]:fi,[F]:1152,[xt]:{[ve]:Ns},[at]:{[ve]:di}},6:{[y]:"Layer I",[se]:4,[ye]:fi,[F]:384,[xt]:{[ve]:Bs},[at]:{[ve]:Vs}}},Fr="MPEG Version ",pi="ISO/IEC ",Gs={0:{[y]:`${Fr}2.5 (later extension of MPEG 2)`,[X]:at,[U]:{0:Ii,4:Ai,8:Gr,12:I}},8:{[y]:I},16:{[y]:`${Fr}2 (${pi}13818-3)`,[X]:at,[U]:{0:Vr,4:Tr,8:Qr,12:I}},24:{[y]:`${Fr}1 (${pi}11172-3)`,[X]:xt,[U]:{0:Br,4:Qt,8:Nr,12:I}},length:d},zs={0:xi,1:Wr},qs={0:Wr,1:"50/15 ms",2:I,3:"CCIT J.17"},mi={0:{[w]:2,[y]:Le},64:{[w]:2,[y]:"joint "+Le},128:{[w]:2,[y]:"dual channel"},192:{[w]:1,[y]:lt}},Ti=class Lr extends ut{static*[T](e,i,n){let r={},s=yield*Os.getID3v2Header(e,i,n);s&&(yield*e[L](s[d],n),e[ce](s[d]));let a=yield*e[L](4,n),l=Ie(a[P](0,4)),o=i[T](l);if(o)return new Lr(o);if(a[0]!==255||a[1]<224)return null;let c=Gs[a[1]&24];if(c[y]===I)return null;let u=a[1]&6;if(Cr[u][y]===I)return null;let h={...Cr[u],...Cr[u][c[X]]};if(r[xe]=c[y],r[X]=h[y],r[F]=h[F],r[Oe]=zs[a[1]&1],r[d]=4,r[W]=Ni[a[2]&240][h[ve]],r[W]===K||(r[U]=c[U][a[2]&12],r[U]===I)||(r[se]=a[2]&2&&h[se],r[Re]=!!(a[2]&1),r[de]=Math.floor(125*r[W]*r[F]/r[U]+r[se]),!r[de]))return null;let p=a[3]&192;if(r[ue]=mi[p][y],r[w]=mi[p][w],r[ye]=h[ye][a[3]&48],r[lr]=!!(a[3]&8),r[ke]=!!(a[3]&4),r[_t]=qs[a[3]&3],r[_t]===I)return null;r[he]=16;{let{length:_,frameLength:H,samples:g,...m}=r;i[Ge](l,r,m)}return new Lr(r)}constructor(e){super(e),this[W]=e[W],this[_t]=e[_t],this[se]=e[se],this[lr]=e[lr],this[ke]=e[ke],this[Re]=e[Re],this[X]=e[X],this[ye]=e[ye],this[xe]=e[xe],this[Oe]=e[Oe]}},Ks=class Vi extends ht{static*[Ae](e,i,n){return yield*super[Ae](Ti,Vi,e,i,n)}constructor(e,i,n){super(e,i,n)}},Ws=class extends qe{constructor(t,e,i){super(t,e),this.Frame=Ks,this.Header=Ti,i(this[O])}get[O](){return Pi}*[ct](){return yield*this[Jt]()}},Xs={0:"MPEG-4",8:"MPEG-2"},Js={0:"valid",2:K,4:K,6:K},Ys={0:xi,1:Wr},js={0:"AAC Main",64:"AAC LC (Low Complexity)",128:"AAC SSR (Scalable Sample Rate)",192:"AAC LTP (Long Term Prediction)"},Zs={0:wi,4:bi,8:Is,12:Qt,16:Br,20:Nr,24:Tr,28:Vr,32:Qr,36:Ai,40:Ii,44:Gr,48:Cs,52:I,56:I,60:"frequency is written explicitly"},_i={0:{[w]:0,[y]:"Defined in AOT Specific Config"},64:{[w]:1,[y]:lt},128:{[w]:2,[y]:k(2,v[0][0])},192:{[w]:3,[y]:k(3,v[1][3])},256:{[w]:4,[y]:k(4,v[1][3],v[3][4])},320:{[w]:5,[y]:k(5,v[1][3],v[3][0])},384:{[w]:6,[y]:k(6,v[1][3],v[3][0],le)},448:{[w]:8,[y]:k(8,v[1][3],v[2][0],v[3][0],le)}},Qi=class Gi extends ut{static*[T](e,i,n){let r={},s=yield*e[L](7,n),a=Ie([s[0],s[1],s[2],s[3]&252|s[6]&3]),l=i[T](a);if(l)Object.assign(r,l);else{if(s[0]!==255||s[1]<240||(r[xe]=Xs[s[1]&8],r[X]=Js[s[1]&6],r[X]===K))return null;let c=s[1]&1;r[Oe]=Ys[c],r[d]=c?7:9,r[fr]=s[2]&192,r[ne]=s[2]&60;let u=s[2]&2;if(r[dr]=js[r[fr]],r[U]=Zs[r[ne]],r[U]===I)return null;r[Re]=!!u,r[Ht]=(s[2]<<8|s[3])&448,r[ue]=_i[r[Ht]][y],r[w]=_i[r[Ht]][w],r[ke]=!!(s[3]&32),r[or]=!!(s[3]&8),r[Hr]=!!(s[3]&8),r[vr]=!!(s[3]&4),r[he]=16,r[F]=1024,r[hr]=s[6]&3;{let{length:h,channelModeBits:p,profileBits:_,sampleRateBits:H,frameLength:g,samples:m,numberAACFrames:b,...V}=r;i[Ge](a,r,V)}}if(r[de]=(s[3]<<11|s[4]<<3|s[5]>>5)&8191,!r[de])return null;let o=(s[5]<<6|s[6]>>2)&2047;return r[sr]=o===2047?"VBR":o,new Gi(r)}constructor(e){super(e),this[Hr]=e[Hr],this[vr]=e[vr],this[sr]=e[sr],this[or]=e[or],this[ke]=e[ke],this[Re]=e[Re],this[X]=e[X],this[d]=e[d],this[xe]=e[xe],this[hr]=e[hr],this[dr]=e[dr],this[Oe]=e[Oe]}get audioSpecificConfig(){let e=Y.get(this),i=e[fr]+64<<5|e[ne]<<5|e[Ht]>>3,n=new ee(2);return new jt(n[ot]).setUint16(0,i,!1),n}},$s=class zi extends ht{static*[Ae](e,i,n){return yield*super[Ae](Qi,zi,e,i,n)}constructor(e,i,n){super(e,i,n)}},en=class extends qe{constructor(t,e,i){super(t,e),this.Frame=$s,this.Header=Qi,i(this[O])}get[O](){return"aac"}*[ct](){return yield*this[Jt]()}},Ct=class kr extends ht{static _getFrameFooterCrc16(e){return(e[e[d]-2]<<8)+e[e[d]-1]}static[Ri](e){let i=kr._getFrameFooterCrc16(e),n=Us(e[P](0,-2));return i===n}constructor(e,i,n){i[Ui]=n,i[Ci]=kr._getFrameFooterCrc16(e),super(i,e,Y.get(i)[F])}},qi="get from STREAMINFO metadata block",tn={0:"Fixed",1:"Variable"},Ki={0:I,16:192};for(let t=2;t<16;t++)Ki[t<<4]=t<6?576*2**(t-2):2**t;var rn={0:qi,1:bi,2:As,3:bs,4:Gr,5:Qr,6:Vr,7:Tr,8:Nr,9:Br,10:Qt,11:wi,15:K},sn={0:{[w]:1,[y]:lt},16:{[w]:2,[y]:k(2,v[0][0])},32:{[w]:3,[y]:k(3,v[0][1])},48:{[w]:4,[y]:k(4,v[1][0],v[3][0])},64:{[w]:5,[y]:k(5,v[1][1],v[3][0])},80:{[w]:6,[y]:k(6,v[1][1],le,v[3][0])},96:{[w]:7,[y]:k(7,v[1][1],le,v[3][4],v[2][0])},112:{[w]:8,[y]:k(8,v[1][1],le,v[3][0],v[2][0])},128:{[w]:2,[y]:`${Le} (left, diff)`},144:{[w]:2,[y]:`${Le} (diff, right)`},160:{[w]:2,[y]:`${Le} (avg, diff)`},176:I,192:I,208:I,224:I,240:I},nn={0:qi,2:8,4:12,6:I,8:16,10:20,12:24,14:I},Ft=class Ot extends ut{static _decodeUTF8Int(e){if(e[0]>254)return null;if(e[0]<128)return{value:e[0],length:1};let i=1;for(let a=64;a&e[0];a>>=1)i++;let n=i-1,r=0,s=0;for(;n>0;s+=6,n--){if((e[n]&192)!==128)return null;r|=(e[n]&63)<<s}return r|=(e[n]&127>>i)<<s,{value:r,length:i}}static[ze](e,i){let n={[L]:function*(){return e}};return Ot[T](n,i,0).next().value}static*[T](e,i,n){let r=yield*e[L](6,n);if(r[0]!==255||!(r[1]===248||r[1]===249))return null;let s={},a=Ie(r[P](0,4)),l=i[T](a);if(l)Object.assign(s,l);else{if(s[_r]=r[1]&1,s[mr]=tn[s[_r]],s[gt]=r[2]&240,s[ne]=r[2]&15,s[_e]=Ki[s[gt]],s[_e]===I||(s[U]=rn[s[ne]],s[U]===K)||r[3]&1)return null;let c=sn[r[3]&240];if(c===I||(s[w]=c[w],s[ue]=c[y],s[he]=nn[r[3]&14],s[he]===I))return null}s[d]=5,r=yield*e[L](s[d]+8,n);let o=Ot._decodeUTF8Int(r[P](4));if(!o||(s[_r]?s[Mr]=o.value:s[nt]=o.value,s[d]+=o[d],s[gt]===96?(r[d]<s[d]&&(r=yield*e[L](s[d],n)),s[_e]=r[s[d]-1]+1,s[d]+=1):s[gt]===112&&(r[d]<s[d]&&(r=yield*e[L](s[d],n)),s[_e]=(r[s[d]-1]<<8)+r[s[d]]+1,s[d]+=2),s[F]=s[_e],s[ne]===12?(r[d]<s[d]&&(r=yield*e[L](s[d],n)),s[U]=r[s[d]-1]*1e3,s[d]+=1):s[ne]===13?(r[d]<s[d]&&(r=yield*e[L](s[d],n)),s[U]=(r[s[d]-1]<<8)+r[s[d]],s[d]+=2):s[ne]===14&&(r[d]<s[d]&&(r=yield*e[L](s[d],n)),s[U]=((r[s[d]-1]<<8)+r[s[d]])*10,s[d]+=2),r[d]<s[d]&&(r=yield*e[L](s[d],n)),s[Bt]=r[s[d]-1],s[Bt]!==Ds(r[P](0,s[d]-1))))return null;if(!l){let{blockingStrategyBits:c,frameNumber:u,sampleNumber:h,samples:p,sampleRateBits:_,blockSizeBits:H,crc:g,length:m,...b}=s;i[Ge](a,s,b)}return new Ot(s)}constructor(e){super(e),this[Ci]=null,this[mr]=e[mr],this[_e]=e[_e],this[nt]=e[nt],this[Mr]=e[Mr],this[Ui]=null}},an=2,ln=512*1024,Wi=class extends qe{constructor(t,e,i){super(t,e),this.Frame=Ct,this.Header=Ft,i(this[O])}get[O](){return"flac"}*_getNextFrameSyncOffset(t){let e=yield*this._codecParser[L](2,0),i=e[d]-2;for(;t<i;){if(e[t]===255){let r=e[t+1];if(r===248||r===249)break;r!==255&&t++}t++}return t}*[ct](){do{let t=yield*Ft[T](this._codecParser,this._headerCache,0);if(t){let e=Y.get(t)[d]+an;for(;e<=ln;){if(this._codecParser._flushing||(yield*Ft[T](this._codecParser,this._headerCache,e))){let i=yield*this._codecParser[L](e);if(this._codecParser._flushing||(i=i[P](0,e)),Ct[Ri](i)){let n=new Ct(i,t);return this._headerCache[Qe](),this._codecParser[ce](e),this._codecParser[Xt](n),n}}e=yield*this._getNextFrameSyncOffset(e+1)}this._codecParser[Ve](`Unable to sync FLAC frame after searching ${e} bytes.`),this._codecParser[ce](e)}else this._codecParser[ce](yield*this._getNextFrameSyncOffset(1))}while(!0)}[Yt](t){return t[G]===0?(this._headerCache[Qe](),this._streamInfo=t[B][P](13)):t[G]===1||(t[$]=fe.get(t)[Me].map(e=>{let i=Ft[ze](e,this._headerCache);if(i)return new Ct(e,i,this._streamInfo);this._codecParser[Ve]("Failed to parse Ogg FLAC frame","Skipping invalid FLAC frame")}).filter(e=>!!e)),t}},Xi=class Ji{static*[T](e,i,n){let r={},s=yield*e[L](28,n);if(s[0]!==79||s[1]!==103||s[2]!==103||s[3]!==83||(r[Ps]=s[4],s[5]&248))return null;r[oe]=!!(s[5]&4),r[it]=!!(s[5]&2),r[rt]=!!(s[5]&1);let l=new jt(ee.from(s[P](0,28))[ot]);r[Se]=Rs(l,6),r[Be]=l.getInt32(14,!0),r[G]=l.getInt32(18,!0),r[Lt]=l.getInt32(22,!0);let o=s[26];r[d]=o+27,s=yield*e[L](r[d],n),r[de]=0,r[$e]=[],r[Nt]=ee.from(s[P](27,r[d]));for(let c=0,u=0;c<o;c++){let h=r[Nt][c];r[de]+=h,u+=h,(h!==255||c===o-1)&&(r[$e].push(u),u=0)}return new Ji(r)}constructor(e){Y.set(this,e),this[Se]=e[Se],this[rt]=e[rt],this[it]=e[it],this[oe]=e[oe],this[$e]=e[$e],this[G]=e[G],this[Lt]=e[Lt],this[Be]=e[Be]}},on=class Yi extends Oi{static*[Ae](e,i,n){let r=yield*Xi[T](e,i,n);if(r){let s=Y.get(r)[de],a=Y.get(r)[d],l=a+s,o=(yield*e[L](l,0))[P](0,l),c=o[P](a,l);return new Yi(r,c,o)}else return null}constructor(e,i,n){super(e,i),fe.get(this)[d]=n[d],this[$]=[],this[Fs]=n,this[Se]=e[Se],this[Fi]=e[Lt],this[Ue]=0,this[rt]=e[rt],this[it]=e[it],this[oe]=e[oe],this[G]=e[G],this[F]=0,this[Be]=e[Be]}},gi=class extends ht{constructor(t,e,i){super(e,t,i)}},Hi={0:Dr.slice(0,2),1:Dr},q="SILK-only",N="CELT-only",Pt="Hybrid",re="narrowband",Et="medium-band",ie="wideband",Pe="super-wideband",Ee="fullband",cn={0:{[M]:q,[A]:re,[S]:10},8:{[M]:q,[A]:re,[S]:20},16:{[M]:q,[A]:re,[S]:40},24:{[M]:q,[A]:re,[S]:60},32:{[M]:q,[A]:Et,[S]:10},40:{[M]:q,[A]:Et,[S]:20},48:{[M]:q,[A]:Et,[S]:40},56:{[M]:q,[A]:Et,[S]:60},64:{[M]:q,[A]:ie,[S]:10},72:{[M]:q,[A]:ie,[S]:20},80:{[M]:q,[A]:ie,[S]:40},88:{[M]:q,[A]:ie,[S]:60},96:{[M]:Pt,[A]:Pe,[S]:10},104:{[M]:Pt,[A]:Pe,[S]:20},112:{[M]:Pt,[A]:Ee,[S]:10},120:{[M]:Pt,[A]:Ee,[S]:20},128:{[M]:N,[A]:re,[S]:2.5},136:{[M]:N,[A]:re,[S]:5},144:{[M]:N,[A]:re,[S]:10},152:{[M]:N,[A]:re,[S]:20},160:{[M]:N,[A]:ie,[S]:2.5},168:{[M]:N,[A]:ie,[S]:5},176:{[M]:N,[A]:ie,[S]:10},184:{[M]:N,[A]:ie,[S]:20},192:{[M]:N,[A]:Pe,[S]:2.5},200:{[M]:N,[A]:Pe,[S]:5},208:{[M]:N,[A]:Pe,[S]:10},216:{[M]:N,[A]:Pe,[S]:20},224:{[M]:N,[A]:Ee,[S]:2.5},232:{[M]:N,[A]:Ee,[S]:5},240:{[M]:N,[A]:Ee,[S]:10},248:{[M]:N,[A]:Ee,[S]:20}},vi=class Rr extends ut{static[ze](e,i,n){let r={};if(r[w]=e[9],r[ge]=e[18],r[d]=r[ge]!==0?21+r[w]:19,e[d]<r[d])throw new Error("Out of data while inside an Ogg Page");let s=i[0]&3,a=s===3?2:1,l=Ie(e[P](0,r[d]))+Ie(i[P](0,a)),o=n[T](l);if(o)return new Rr(o);if(l.substr(0,8)!=="OpusHead"||e[8]!==1)return null;r[B]=ee.from(e[P](0,r[d]));let c=new jt(r[B][ot]);if(r[he]=16,r[Dt]=c.getUint16(10,!0),r[yr]=c.getUint32(12,!0),r[U]=Qt,r[ur]=c.getInt16(16,!0),r[ge]in Hi&&(r[ue]=Hi[r[ge]][r[w]-1],!r[ue]))return null;r[ge]!==0&&(r[Sr]=e[19],r[nr]=e[20],r[gr]=[...e[P](21,r[w]+21)]);let u=cn[248&i[0]];switch(r[M]=u[M],r[A]=u[A],r[S]=u[S],s){case 0:r[De]=1;break;case 1:case 2:r[De]=2;break;case 3:r[cr]=!!(128&i[1]),r[ar]=!!(64&i[1]),r[De]=63&i[1];break;default:return null}{let{length:h,data:p,channelMappingFamily:_,...H}=r;n[Ge](l,r,H)}return new Rr(r)}constructor(e){super(e),this[B]=e[B],this[A]=e[A],this[ge]=e[ge],this[gr]=e[gr],this[nr]=e[nr],this[De]=e[De],this[S]=e[S],this[ar]=e[ar],this[yr]=e[yr],this[cr]=e[cr],this[M]=e[M],this[ur]=e[ur],this[Dt]=e[Dt],this[Sr]=e[Sr]}},hn=class extends qe{constructor(t,e,i){super(t,e),this.Frame=gi,this.Header=vi,i(this[O]),this._identificationHeader=null,this._preSkipRemaining=null}get[O](){return"opus"}[Yt](t){return t[G]===0?(this._headerCache[Qe](),this._identificationHeader=t[B]):t[G]===1||(t[$]=fe.get(t)[Me].map(e=>{let i=vi[ze](this._identificationHeader,e,this._headerCache);if(i){this._preSkipRemaining===null&&(this._preSkipRemaining=i[Dt]);let n=i[S]*i[De]/1e3*i[U];return this._preSkipRemaining>0&&(this._preSkipRemaining-=n,n=this._preSkipRemaining<0?-this._preSkipRemaining:0),new gi(e,i,n)}this._codecParser[Li]("Failed to parse Ogg Opus Header","Not a valid Ogg Opus file")})),t}},yi=class extends ht{constructor(t,e,i){super(e,t,i)}},xr={};for(let t=0;t<8;t++)xr[t+6]=2**(6+t);var un=class Or extends ut{static[ze](e,i,n,r){if(e[d]<30)throw new Error("Out of data while inside an Ogg Page");let s=Ie(e[P](0,30)),a=i[T](s);if(a)return new Or(a);let l={[d]:30};if(s.substr(0,7)!=="vorbis")return null;l[B]=ee.from(e[P](0,30));let o=new jt(l[B][ot]);if(l[st]=o.getUint32(7,!0),l[st]!==0||(l[w]=e[11],l[ue]=Dr[l[w]-1]||"application defined",l[U]=o.getUint32(12,!0),l[tr]=o.getInt32(16,!0),l[ir]=o.getInt32(20,!0),l[rr]=o.getInt32(24,!0),l[Ze]=xr[(e[28]&240)>>4],l[je]=xr[e[28]&15],l[je]>l[Ze])||e[29]!==1)return null;l[he]=32,l[Ut]=r,l[pr]=n;{let{length:c,data:u,version:h,vorbisSetup:p,vorbisComments:_,...H}=l;i[Ge](s,l,H)}return new Or(l)}constructor(e){super(e),this[tr]=e[tr],this[rr]=e[rr],this[ir]=e[ir],this[je]=e[je],this[Ze]=e[Ze],this[B]=e[B],this[pr]=e[pr],this[Ut]=e[Ut]}},dn=class extends qe{constructor(t,e,i){super(t,e),this.Frame=yi,i(this[O]),this._identificationHeader=null,this._setupComplete=!1,this._prevBlockSize=null}get[O](){return Gt}[Yt](t){t[$]=[];for(let e of fe.get(t)[Me])if(e[0]===1)this._headerCache[Qe](),this._identificationHeader=t[B],this._setupComplete=!1;else if(e[0]===3)this._vorbisComments=e;else if(e[0]===5)this._vorbisSetup=e,this._mode=this._parseSetupHeader(e),this._setupComplete=!0;else if(this._setupComplete){let i=un[ze](this._identificationHeader,this._headerCache,this._vorbisComments,this._vorbisSetup);i?t[$].push(new yi(e,i,this._getSamples(e,i))):this._codecParser[logError]("Failed to parse Ogg Vorbis Header","Not a valid Ogg Vorbis file")}return t}_getSamples(t,e){let n=this._mode.blockFlags[t[0]>>1&this._mode.mask]?e[Ze]:e[je],r=this._prevBlockSize===null?0:(this._prevBlockSize+n)/4;return this._prevBlockSize=n,r}_parseSetupHeader(t){let e=new ks(t),i={count:0,blockFlags:[]};for(;(e.read(1)&1)!==1;);let n;for(;i.count<64&&e.position>0;){Vt(e.read(8));let r=0;for(;e.read(8)===0&&r++<3;);if(r===4)n=e.read(7),i.blockFlags.unshift(n&1),e.position+=6,i.count++;else{((Vt(n)&126)>>1)+1!==i.count&&this._codecParser[Ve]("vorbis derived mode count did not match actual mode count");break}}return i.mask=(1<<Math.log2(i.count))-1,i}},fn=class{constructor(t,e,i){this._codecParser=t,this._headerCache=e,this._onCodec=i,this._continuedPacket=new ee,this._codec=null,this._isSupported=null,this._previousAbsoluteGranulePosition=null}get[O](){return this._codec||""}_updateCodec(t,e){this._codec!==t&&(this._headerCache[we](),this._parser=new e(this._codecParser,this._headerCache,this._onCodec),this._codec=t)}_checkCodecSupport({data:t}){let e=Ie(t[P](0,8));switch(e){case"fishead\0":return!1;case"OpusHead":return this._updateCodec("opus",hn),!0;case(/^\x7fFLAC/.test(e)&&e):return this._updateCodec("flac",Wi),!0;case(/^\x01vorbis/.test(e)&&e):return this._updateCodec(Gt,dn),!0;default:return!1}}_checkPageSequenceNumber(t){t[G]!==this._pageSequenceNumber+1&&this._pageSequenceNumber>1&&t[G]>1&&this._codecParser[Ve]("Unexpected gap in Ogg Page Sequence Number.",`Expected: ${this._pageSequenceNumber+1}, Got: ${t[G]}`),this._pageSequenceNumber=t[G]}_parsePage(t){this._isSupported===null&&(this._pageSequenceNumber=t[G],this._isSupported=this._checkCodecSupport(t)),this._checkPageSequenceNumber(t);let e=fe.get(t),i=Y.get(e[ae]),n=0;if(e[Me]=i[$e].map(r=>t[B][P](n,n+=r)),this._continuedPacket[d]&&(e[Me][0]=Ur(this._continuedPacket,e[Me][0]),this._continuedPacket=new ee),i[Nt][i[Nt][d]-1]===255&&(this._continuedPacket=Ur(this._continuedPacket,e[Me].pop())),this._previousAbsoluteGranulePosition!==null&&(t[F]=Number(t[Se]-this._previousAbsoluteGranulePosition)),this._previousAbsoluteGranulePosition=t[Se],this._isSupported){let r=this._parser[Yt](t);return this._codecParser[Xt](r),r}else return t}},pn=class extends qe{constructor(t,e,i){super(t,e),this._onCodec=i,this.Frame=on,this.Header=Xi,this._streams=new Map,this._currentSerialNumber=null}get[O](){let t=this._streams.get(this._currentSerialNumber);return t?t.codec:""}*[ct](){let t=yield*this[Jt](!0);this._currentSerialNumber=t[Be];let e=this._streams.get(this._currentSerialNumber);return e||(e=new fn(this._codecParser,this._headerCache,this._onCodec),this._streams.set(this._currentSerialNumber,e)),t[oe]&&this._streams.delete(this._currentSerialNumber),e._parsePage(t)}},Pr=()=>{},mn=class{constructor(t,{onCodec:e,onCodecHeader:i,onCodecUpdate:n,enableLogging:r=!1,enableFrameCRC32:s=!0}={}){this._inputMimeType=t,this._onCodec=e||Pr,this._onCodecHeader=i||Pr,this._onCodecUpdate=n,this._enableLogging=r,this._crc32=s?Ls:Pr,this[we]()}get[O](){return this._parser?this._parser[O]:""}[we](){this._headerCache=new xs(this._onCodecHeader,this._onCodecUpdate),this._generator=this._getGenerator(),this._generator.next()}*flush(){this._flushing=!0;for(let t=this._generator.next();t.value;t=this._generator.next())yield t.value;this._flushing=!1,this[we]()}*parseChunk(t){for(let e=this._generator.next(t);e.value;e=this._generator.next())yield e.value}parseAll(t){return[...this.parseChunk(t),...this.flush()]}*_getGenerator(){if(this._inputMimeType.match(/aac/))this._parser=new en(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/mpeg/))this._parser=new Ws(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/flac/))this._parser=new Wi(this,this._headerCache,this._onCodec);else if(this._inputMimeType.match(/ogg/))this._parser=new pn(this,this._headerCache,this._onCodec);else throw new Error(`Unsupported Codec ${mimeType}`);for(this._frameNumber=0,this._currentReadPosition=0,this._totalBytesIn=0,this._totalBytesOut=0,this._totalSamples=0,this._sampleRate=void 0,this._rawData=new Uint8Array(0);;){let t=yield*this._parser[ct]();t&&(yield t)}}*[L](t=0,e=0){let i;for(;this._rawData[d]<=t+e;){if(i=yield,this._flushing)return this._rawData[P](e);i&&(this._totalBytesIn+=i[d],this._rawData=Ur(this._rawData,i))}return this._rawData[P](e)}[ce](t){this._currentReadPosition+=t,this._rawData=this._rawData[P](t)}[vt](t){this._sampleRate=t[ae][U],t[ae][W]=t[Ue]>0?Math.round(t[B][d]/t[Ue])*8:0,t[nt]=this._frameNumber++,t[kt]=this._totalBytesOut,t[Tt]=this._totalSamples,t[Rt]=this._totalSamples/this._sampleRate*1e3,t[Fi]=this._crc32(t[B]),this._headerCache[ki](t[ae][W],t[Rt]),this._totalBytesOut+=t[B][d],this._totalSamples+=t[F]}[Xt](t){if(t[$]){if(t[oe]){let e=t[F];t[$].forEach(i=>{let n=i[F];e<n&&(i[F]=e>0?e:0,i[Ue]=i[F]/i[ae][U]*1e3),e-=n,this[vt](i)})}else t[F]=0,t[$].forEach(e=>{t[F]+=e[F],this[vt](e)});t[Ue]=t[F]/this._sampleRate*1e3||0,t[Tt]=this._totalSamples,t[Rt]=this._totalSamples/this._sampleRate*1e3||0,t[kt]=this._totalBytesOut}else this[vt](t)}_log(t,e){if(this._enableLogging){let i=[`${O}: ${this[O]}`,`inputMimeType: ${this._inputMimeType}`,`readPosition: ${this._currentReadPosition}`,`totalBytesIn: ${this._totalBytesIn}`,`${kt}: ${this._totalBytesOut}`],n=Math.max(...i.map(r=>r[d]));e.push(`--stats--${"-".repeat(n-9)}`,...i,"-".repeat(n)),t("codec-parser",e.reduce((r,s)=>r+`
`+s,""))}}[Ve](...t){this._log(console.warn,t)}[Li](...t){this._log(console.error,t)}},ji=mn,Ne=$,Te=B,Zi=ae,$i=oe,es=Ut,ts=Tt;function et(t){var e=e;function i(){}e={};function n(f){throw f}var r,s,a,l,o,c,u,h,p,_,H;function g(){var f=H.buffer;r=new Int8Array(f),s=new Int16Array(f),l=new Uint8Array(f),o=new Uint16Array(f),a=new Int32Array(f),c=new Uint32Array(f),u=new Float32Array(f),h=new Float64Array(f),p=new BigInt64Array(f),_=new BigUint64Array(f)}for(var m=f=>{for(var z,Xe,Fe=0,dt=0,ft=f.length,pt=new Uint8Array((ft*3>>2)-(f[ft-2]=="=")-(f[ft-1]=="="));Fe<ft;Fe+=4,dt+=3)z=Z[f.charCodeAt(Fe+1)],Xe=Z[f.charCodeAt(Fe+2)],pt[dt]=Z[f.charCodeAt(Fe)]<<2|z>>4,pt[dt+1]=z<<4|Xe>>2,pt[dt+2]=Xe<<6|Z[f.charCodeAt(Fe+3)];return pt},b=()=>n(""),V=()=>{},x={},me=f=>f(),J=()=>performance.now(),j=(f,z)=>{if(x[f]&&(clearTimeout(x[f].id),delete x[f]),!z)return 0;var Xe=setTimeout(()=>{delete x[f],me(()=>ai(f,J()))},z);return x[f]={id:Xe,timeout_ms:z},0},Ce=Math.atan,hs=Math.cos,us=Math.exp,ds=Math.log,fs=Math.pow,ps=Math.sin,ms=f=>{var z=l.length;return f>>>=0,!1},_s=f=>{throw`exit(${f})`},Z=new Uint8Array(123),te=25;te>=0;--te)Z[48+te]=52+te,Z[65+te]=te,Z[97+te]=26+te;Z[43]=62,Z[47]=63;var gs={e:b,d:V,f:j,b:Ce,a:hs,i:us,h:ds,g:fs,c:ps,k:ms,j:_s};function Hs(f){$r=f.n,ei=f.o,ti=f.p,ri=f.q,ii=f.r,si=f.s,ni=f.t,ai=f.v}var $r,ei,ti,ri,ii,si,ni,ai;function vs(f){f.m()}et.wasm||Object.defineProperty(et,"wasm",{get:()=>String.raw`dynEncode012091253f87dì%nä= 4&