From bae53b0cfdf74d6dd0a77074c59d69cd4e1b5537 Mon Sep 17 00:00:00 2001 From: zhaohappy <2281756061@qq.com> Date: Wed, 22 May 2024 00:19:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=20cheap=EF=BC=8C?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20chrome=20=E5=86=85=E5=AD=98=E6=B3=84?= =?UTF-8?q?=E6=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/avplayer.js | 2 +- dist/legacy/avplayer-legacy.js | 2 +- src/cheap | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/avplayer.js b/dist/avplayer.js index 583d0e89..09b9018c 100644 --- a/dist/avplayer.js +++ b/dist/avplayer.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.AVPlayer=e():t.AVPlayer=e()}(self,(()=>(()=>{var t,e,i={1128:(t,e,i)=>{"use strict";i.d(e,{d:()=>r});const r={86017:"mp3",86018:"mp4a.40",86021:"vorbis",86028:"flac",86076:"opus",65542:"ulaw",65543:"alaw",226:"av01",27:"avc1",173:"hev1",139:"vp8",167:"vp09",12:"mp4v"}},9603:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var r=i(3939),s=i(1128);function a(t){const e=r.f[15](t+4);let i=r.f[15](t+40),a=s.d[e];return 86018===e&&(a=`${a}.${i}`),a||"unknown"}},1233:(t,e,i)=>{"use strict";i.d(e,{C:()=>s});var r=i(4214);function s(t){return t?!r.A.chrome||r.A.checkVersion(r.A.majorVersion,"94",!0)?"prefer-hardware":"allow":!r.A.chrome||r.A.checkVersion(r.A.majorVersion,"94",!0)?"prefer-software":"deny"}},4663:(t,e,i)=>{"use strict";i.d(e,{A:()=>d});var r=i(3939),s=i(1128),a=i(412),n=i(4392),o=i(8919),h=i(525),c=i(7231),u=i(4686);function d(t,e){const i=r.f[15](t+4);let d=r.f[15](t+40),l=r.f[15](t+44);e||0===r.f[20](t+12)||(e=(0,u.s3)(r.f[20](t+12),r.f[15](t+16)));let f=s.d[i],p="";if(27===i)110===d&&(d=100),p=h.GP("%s.%02x%02x%02x",f,255&d,e?e[2]:0,255&l);else if(173===i){var m;let t=0,i=0,r=0,s=0;(null===(m=e)||void 0===m?void 0:m.length)>13&&(t=e[1]>>>6&3,r=e[1]>>>5&1,i=e[2]|e[3]<<8|e[4]<<16|e[5]<<24,s=240&e[6]);const a={0:"",1:"A",2:"B",3:"C"};p=h.GP("%s.%s%d.%x.%s%d.%x",f,a[t],d,i,0===r?"L":"H",l,s)}else if(226===i)if(e){const t=a.Ui(e);p=h.GP("%s.%d.%02d%s.%02d.%d.%d%d%d",f,t.profile,t.level,t.tier?"H":"M",t.bitDepth,t.monochrome,t.chromaSubsamplingX,t.chromaSubsamplingY,t.chromaSamplePosition)}else p=h.GP("%s.%d.%02dM.08",f,d,l);else if(139===i)if(e){const t=n.U(e);p=h.GP("%s.%02d.%02d.%02d",f,t.profile,t.level,t.bitDepth)}else p=d!==c.N_&&l!==c.N_?h.GP("%s.%02d.%02d.08",f,d,l):f;else if(167===i)if(e){const t=o.U(e);p=h.GP("%s.%02d.%02d.%02d.%02d.%02d.%02d.%02d.%02d",f,t.profile,t.level,t.bitDepth,t.chromaSubsampling,t.colorPrimaries,t.colorTrc,t.colorSpace,t.fullRangeFlag)}else p=d!==c.N_&&l!==c.N_?h.GP("%s.%02d.%02d.08.00",f,d,l):h.GP("%s.%02d.%02d.08.00",f,0,40);else p=f||"unknown";return p}},1091:(t,e,i)=>{"use strict";i.d(e,{X:()=>p,f:()=>m});var r=i(1026),s=i(662),a=i.n(s),n=i(4503),o=i(4300),h=i(5495),c=i(7231),u=i(9599);class d{constructor(){(0,r.A)(this,"index",c.N_),(0,r.A)(this,"id",c.N_),(0,r.A)(this,"privData",null),(0,r.A)(this,"codecpar",(0,n.A)(h.A,new h.A)),(0,r.A)(this,"sideData",{}),(0,r.A)(this,"nbFrames",BigInt(0)),(0,r.A)(this,"metadata",{}),(0,r.A)(this,"duration",c.Dh),(0,r.A)(this,"startTime",c.Dh),(0,r.A)(this,"firstDTS",BigInt(0)),(0,r.A)(this,"disposition",0),(0,r.A)(this,"timeBase",(0,n.A)(u.P)),(0,r.A)(this,"sampleIndexes",[]),(0,r.A)(this,"sampleIndexesPosMap",new(a()))}destroy(){this.codecpar&&(this.codecpar.destroy(),(0,o.A)(this.codecpar),this.codecpar=null),this.timeBase&&((0,o.A)(this.timeBase),this.timeBase=null),this.sampleIndexes.length=0,this.sampleIndexesPosMap.clear()}}class l{constructor(){(0,r.A)(this,"packetBuffer",void 0),this.packetBuffer=[]}}class f{constructor(){(0,r.A)(this,"metadataHeaderPadding",-1),(0,r.A)(this,"streams",void 0),(0,r.A)(this,"options",void 0),(0,r.A)(this,"privateData",void 0),(0,r.A)(this,"processPrivateData",void 0),(0,r.A)(this,"iformat",void 0),(0,r.A)(this,"oformat",void 0),(0,r.A)(this,"ioReader",void 0),(0,r.A)(this,"ioWriter",void 0),(0,r.A)(this,"errorFlag",void 0),(0,r.A)(this,"interval",void 0),(0,r.A)(this,"streamIndex",void 0),this.streams=[],this.errorFlag=0,this.streamIndex=0,this.interval=new l,this.options={},this.privateData={}}getStreamById(t){return this.streams.find((e=>e.id===t))}getStreamByIndex(t){return this.streams.find((e=>e.index===t))}getStreamByMediaType(t){return this.streams.find((e=>{var i;return(null===(i=e.codecpar)||void 0===i?void 0:i.codecType)===t}))}createStream(){const t=new d;return t.index=this.streamIndex++,t.id=t.index,this.removeStreamByIndex(t.index),this.streams.push(t),t}addStream(t){this.removeStreamByIndex(t.index),this.streams.push(t)}removeStream(t){this.removeStreamByIndex(t.index)}removeStreamById(t){const e=this.streams.findIndex((e=>e.id===t));if(e>-1){const t=this.streams.splice(e,1);t[0]&&t[0].destroy()}}removeStreamByIndex(t){const e=this.streams.findIndex((e=>e.index===t));if(e>-1){const t=this.streams.splice(e,1);t[0]&&t[0].destroy()}}destroy(){this.oformat&&this.oformat.destroy(this),this.iformat&&this.iformat.destroy(this),this.streams.forEach((t=>{t.destroy()})),this.streams=[],this.interval=null,this.ioReader=this.ioWriter=null,this.oformat=this.iformat=null}}function p(){return new f}function m(){return new f}},4436:(t,e,i)=>{"use strict";i.d(e,{A:()=>o});var r=i(1026),s=i(3939),a=i(7837),n=i(5546);class o{constructor(){(0,r.A)(this,"inCodecpar",void 0),(0,r.A)(this,"inTimeBase",void 0),(0,r.A)(this,"outCodecpar",void 0)}init(t,e){return this.inCodecpar=(0,a.Gy)(184),(0,n.Yi)(this.inCodecpar,t),this.inTimeBase={den:s.f[15](e+4),num:s.f[15](e)},0}destroy(){this.inCodecpar&&((0,n.dn)(this.inCodecpar),this.inCodecpar=0)}}},412:(t,e,i)=>{"use strict";i.d(e,{Ui:()=>a,XC:()=>s});var r=i(7246);function s(t,e){if(!e&&t.sideData[1]&&(e=t.sideData[1]),e&&e.length>=4){const i=a(e);t.codecpar.profile=i.profile,t.codecpar.level=i.level}}function a(t){const e=new r.A(t.length);e.appendBuffer(t),e.readU1(),e.readU(7);const i=e.readU(3),s=e.readU(5),a=e.readU1();let n=e.readU1()?10:8;return e.readU1()&&(n=12),{profile:i,level:s,tier:a,bitDepth:n,monochrome:e.readU1(),chromaSubsamplingX:e.readU1(),chromaSubsamplingY:e.readU1(),chromaSamplePosition:e.readU(2)}}},620:(t,e,i)=>{"use strict";i.d(e,{Jk:()=>y,XC:()=>b,ci:()=>w,oT:()=>A});var r=i(3939),s=i(932),a=i(2739),n=i(729),o=i(1865),h=i(7246),c=i(4624),u=i(4686),d=i(1517),l=i(264),f=i(7837),p=i(3991),m="src/avformat/codecs/h264.ts";const g=3;function v(t,e,i=[]){t.length>32&&(c.R8(`h264 metadata's sps max length is 32, but get ${t.length}`,m,159),t=t.slice(0,32)),t.length>256&&(c.R8(`h264 metadata's pps max length is 256, but get ${t.length}`,m,163),t=t.slice(0,256));let r=7;r=t.reduce(((t,e)=>t+2+e.length),r),r=e.reduce(((t,e)=>t+2+e.length),r);const s=t[0],o=k(s);66!==o.profile&&77!==o.profile&&88!==o.profile&&(r+=4,i.length&&(r=i.reduce(((t,e)=>t+2+e.length),r)));const h=new Uint8Array(r),u=new n.A(h);return u.writeUint8(1),u.writeUint8(s[1]),u.writeUint8(s[2]),u.writeUint8(s[3]),u.writeUint8(252|g),u.writeUint8(224|31&t.length),a.__(t,(t=>{u.writeUint16(t.length),u.writeBuffer(t)})),u.writeUint8(e.length),a.__(e,(t=>{u.writeUint16(t.length),u.writeBuffer(t)})),66!==o.profile&&77!==o.profile&&88!==o.profile&&(u.writeUint8(252|o.chromaFormatIdc),u.writeUint8(248|o.bitDepthLumaMinus8),u.writeUint8(248|o.bitDepthChromaMinus8),i.length&&a.__(i,(t=>{u.writeUint16(t.length),u.writeBuffer(t)}))),h}function A(t){let e,i=(0,l.py)(t),r=!1;if(i.length>1){const t=[],r=[],s=[];i.forEach((e=>{const i=31&e[0];7===i?t.push(e):8===i?r.push(e):13===i&&s.push(e)})),t.length&&r.length&&(e=v(t,r,s)),i=i.filter((t=>{const e=31&t[0];return 9!==e&&8!==e&&7!==e&&13!==e}))}const s=i.reduce(((t,e)=>t+g+1+e.length),0),o=(0,f.sY)(s),h=(0,u.s3)(o,s),c=new n.A(h);return a.__(i,(t=>{3===g?c.writeUint32(t.length):2===g?c.writeUint24(t.length):1===g?c.writeUint16(t.length):c.writeUint8(t.length),c.writeBuffer(t.subarray(0)),5==(31&t[0])&&(r=!0)})),{bufferPointer:o,length:s,key:r,extradata:e}}function y(t,e){var i;if(!(1&r.f[15](t+36)))return;const s=(0,d.iI)(t);if((0,l.Bs)(s))return;const a=null!==(i=e.metadata.naluLengthSizeMinusOne)&&void 0!==i?i:g;let n=[],h=[],c=[],p=[];const m=new o.A(s);for(;m.remainingSize()>0;){let t=0;t=3===a?m.readUint32():2===a?m.readUint24():1===a?m.readUint16():m.readUint8();const e=s.subarray(0|Number(0xffffffffn&m.getPos()),(0|Number(0xffffffffn&m.getPos()))+t);m.skip(t);const i=31&e[0];7===i?n.push(e):8===i?h.push(e):13===i?c.push(e):p.push(e)}if(n.length||h.length){const e=v(n,h,c),i=(0,f.sY)(e.length);(0,u.lW)(i,e.length,e),(0,d.Ow)(t,1,i,e.length)}}function w(t,e=!1){if(!(1&r.f[15](t+36)||e))return;const i=(0,d.iI)(t);if(!(0,l.Bs)(i))return;let a=(0,l.py)(i);if(a.length>1){const e=[],i=[],n=[];if(a.forEach((t=>{const r=31&t[0];7===r?e.push(t):8===r?i.push(t):13===r&&n.push(t)})),e.length&&i.length){const a=v(e,i,n),o=(0,f.sY)(a.length);(0,u.lW)(o,a.length,a),(0,d.Ow)(t,1,o,a.length),s.M[15](t+36,1|r.f[15](t+36))}}}function b(t,e){if(!e&&t.sideData[1]&&(e=t.sideData[1]),e&&e.length>=6){t.metadata.naluLengthSizeMinusOne=3&e[4];const{spss:i}=function(t){const e=new o.A(t);e.skip(5);const i=[],r=[],s=[],a=31&e.readUint8();for(let t=0;t4){e.skip(3);const t=e.readUint8();if(t>0)for(let i=0;i{"use strict";i.d(e,{Jk:()=>v,XC:()=>y,ci:()=>A,oT:()=>g});var r=i(3939),s=i(932),a=i(2739),n=i(729),o=i(1865),h=i(7246),c=i(4686),u=i(264),d=i(1517),l=i(7837),f=i(3991);const p=3;function m(t,e,i){const r=e[0];let s=23;t.length&&(s+=3,s=t.reduce(((t,e)=>t+2+e.length),s)),e.length&&(s+=3,s=e.reduce(((t,e)=>t+2+e.length),s)),i.length&&(s+=3,s=i.reduce(((t,e)=>t+2+e.length),s));const o=new Uint8Array(s),h=new n.A(o,!0),c=w(r);h.writeUint8(1),h.writeUint8(r[1]),h.writeUint8(r[2]),h.writeUint8(r[3]),h.writeUint8(r[4]),h.writeUint8(r[5]),h.writeUint8(r[6]),h.writeUint8(r[7]),h.writeUint8(r[8]),h.writeUint8(r[9]),h.writeUint8(r[10]),h.writeUint8(r[11]),h.writeUint8(c.level),h.writeUint8(1020),h.writeUint8(0),h.writeUint8(16320),h.writeUint8(16320|c.chromaFormatIdc),h.writeUint8(8160|c.bitDepthLumaMinus8),h.writeUint8(8160|c.bitDepthChromaMinus8),h.writeUint16(0),h.writeUint8(8|(1&r[0])<<2|p);let u=0;return t.length&&u++,e.length&&u++,i.length&&u++,h.writeUint8(u),t.length&&(h.writeUint8(160),h.writeUint16(t.length),a.__(t,(t=>{h.writeUint16(t.length),h.writeBuffer(t)}))),e.length&&(h.writeUint8(161),h.writeUint16(e.length),a.__(e,(t=>{h.writeUint16(t.length),h.writeBuffer(t)}))),i.length&&(h.writeUint8(162),h.writeUint16(i.length),a.__(i,(t=>{h.writeUint16(t.length),h.writeBuffer(t)}))),o}function g(t){let e,i=!1,r=(0,u.py)(t);if(r.length>2){const t=[],i=[],s=[];r.forEach((e=>{const r=e[0]>>>1&63;32===r?t.push(e):33===r?i.push(e):34===r&&s.push(e)})),t.length&&i.length&&s.length&&(e=m(t,i,s),r=r.filter((t=>{const e=t[0]>>>1&63;return 32!==e&&33!==e&&34!==e&&35!==e})))}const s=r.reduce(((t,e)=>t+p+1+e.length),0),o=(0,l.sY)(s),h=(0,c.s3)(o,s),d=new n.A(h);return a.__(r,(t=>{3===p?d.writeUint32(t.length):2===p?d.writeUint24(t.length):1===p?d.writeUint16(t.length):d.writeUint8(t.length),d.writeBuffer(t.subarray(0));const e=t[0]>>>1&63;19!==e&&20!==e&&21!==e||(i=!0)})),{bufferPointer:o,length:s,extradata:e,key:i}}function v(t,e){var i;if(!(1&r.f[15](t+36)))return;const s=(0,d.iI)(t);if((0,u.Bs)(s))return;const a=null!==(i=e.metadata.naluLengthSizeMinusOne)&&void 0!==i?i:p;let n=[],h=[],f=[];const g=new o.A(s);for(;g.remainingSize()>0;){let t=0;t=3===a?g.readUint32():2===a?g.readUint24():1===a?g.readUint16():g.readUint8();const e=s.subarray(0|Number(0xffffffffn&g.getPos()),(0|Number(0xffffffffn&g.getPos()))+t);g.skip(t);const i=e[0]>>>1&63;33===i?h.push(e):34===i?f.push(e):32===i&&n.push(e)}if(h.length||f.length||n.length){const e=m(n,h,f),i=(0,l.sY)(e.length);(0,c.lW)(i,e.length,e),(0,d.Ow)(t,1,i,e.length)}}function A(t,e=!1){if(!(1&r.f[15](t+36)||e))return;const i=(0,d.iI)(t);if(!(0,u.Bs)(i))return;let a=(0,u.py)(i);if(a.length>2){const e=[],i=[],n=[];if(a.forEach((t=>{const r=t[0]>>>1&63;32===r?e.push(t):33===r?i.push(t):34===r&&n.push(t)})),e.length&&i.length&&n.length){const a=m(e,i,n),o=(0,l.sY)(a.length);(0,c.lW)(o,a.length,a),(0,d.Ow)(t,1,o,a.length),s.M[15](t+36,1|r.f[15](t+36))}}}function y(t,e){if(!e&&t.sideData[1]&&(e=t.sideData[1]),e&&e.length>=6){t.metadata.naluLengthSizeMinusOne=3&e[21];const{spss:i}=function(t){const e=new o.A(t,!0);e.skip(22);let i=[],r=[],s=[];const a=e.readUint8();for(let t=0;t0)for(let t=A;t<8;t++)v.readU(2);for(let i=0;i{"use strict";i.d(e,{U:()=>a,X:()=>s});var r=i(7246);function s(t,e){if(!e&&t.sideData[1]&&(e=t.sideData[1]),e&&e.length>=6){const i=a(e);t.codecpar.profile=i.profile,t.codecpar.level=i.level}}function a(t){const e=new r.A(t.length);return e.appendBuffer(t.subarray(4)),{profile:e.readU(8),level:e.readU(8),bitDepth:e.readU(4),chromaSubsampling:e.readU(3),fullRangeFlag:e.readU1(),colorPrimaries:e.readU(8),colorTrc:e.readU(8),colorSpace:e.readU(8)}}},8919:(t,e,i)=>{"use strict";i.d(e,{U:()=>a,X:()=>s});var r=i(7246);function s(t,e){if(!e&&t.sideData[1]&&(e=t.sideData[1]),e&&e.length>=6){const i=a(e);t.codecpar.profile=i.profile,t.codecpar.level=i.level}}function a(t){const e=new r.A(t.length);return e.appendBuffer(t.subarray(4)),{profile:e.readU(8),level:e.readU(8),bitDepth:e.readU(4),chromaSubsampling:e.readU(3),fullRangeFlag:e.readU1(),colorPrimaries:e.readU(8),colorTrc:e.readU(8),colorSpace:e.readU(8)}}},1071:(t,e,i)=>{"use strict";i.d(e,{_l:()=>r,gQ:()=>s});const r=["hmhd","nmhd","iods","xml ","url ","bxml","ipro","mere","stts","ctts","stss","stsz","stz2","stsc","stco","co64","stsd","dref","mvhd","tkhd","mdhd","hdlr"],s=["moov","trak","edts","mdia","minf","dinf","stbl","mvex","moof","traf","vttc","tref","iref","mfra","hnti","hinf","strd","sinf","rinf","schi","trgr","udta","iprp","ipco","strk","meco"]},3384:(t,e,i)=>{"use strict";function r(){return{trackId:0,baseDataOffset:BigInt(0),defaultSampleDuration:0,defaultSampleSize:0,defaultSampleFlags:0,baseMediaDecodeTime:BigInt(0),sampleCount:0,dataOffset:0,dataOffsetPos:BigInt(0),firstSampleFlags:0,sampleDurations:[],sampleSizes:[],sampleFlags:[],sampleCompositionTimeOffset:[],baseIsMoof:!1,ioWriter:null,buffers:[]}}i.d(e,{A:()=>r})},9690:(t,e,i)=>{"use strict";i.d(e,{A:()=>s});var r=i(7231);function s(){return{isom:!1,timescale:r.N_,duration:r.Dh,foundMoov:!1,foundMdat:!1,majorBrand:0,minorVersion:0,compatibleBrand:[],creationTime:BigInt(0),modificationTime:BigInt(0),rate:r.N_,volume:r.N_,matrix:null,nextTrackId:1,fragment:!1,trexs:[],currentFragment:null,boxsPositionInfo:[],holdMoovPos:BigInt(0),currentChunk:null}}},8106:(t,e,i)=>{"use strict";i.d(e,{A:()=>s});var r=i(7231);function s(){return{chunkOffsets:null,cttsSampleCounts:null,cttsSampleOffsets:null,stscFirstChunk:null,stscSamplesPerChunk:null,stscSampleDescriptionIndex:null,stssSampleNumbersMap:null,stssSampleNumbers:null,sampleSizes:null,sttsSampleCounts:null,sttsSampleDeltas:null,timescale:0,duration:BigInt(0),trackId:r.N_,layer:0,alternateGroup:0,volume:0,matrix:null,width:0,height:0,audioCid:0,samplesPerFrame:0,bytesPerFrame:0,currentSample:0,sampleEnd:!1,samplesIndex:[],fragIndexes:[],lastPts:BigInt(0),lastDts:BigInt(0),startDts:BigInt(0),startCT:0,lastDuration:0,chunkCount:0,firstWrote:!1,lastStscCount:0,perStreamGrouping:!1,index:0,flags:0}}},6660:(t,e,i)=>{"use strict";i.d(e,{Q9:()=>a,f3:()=>n,uf:()=>o,zs:()=>s});var r=i(5977);const s={86018:64,86017:105,86076:173,86028:193,86021:221,12:32,27:33,173:35,167:177,0:0},a={32:12,33:27,35:173,177:167,64:86018,102:86018,103:86018,104:86018,105:86017,107:86017,173:86076,193:86028,221:86021,0:0},n={vide:0,soun:1,clcp:3,sbtl:3,subt:3,subp:3,text:3},o={[(0,r.A)("mp4a")]:86018,1836253269:86017,[(0,r.A)("Opus")]:86076,[(0,r.A)("fLaC")]:86028,[(0,r.A)("spex")]:86051,[(0,r.A)("SPXN")]:86051,[(0,r.A)("ac-3")]:86019,[(0,r.A)("sac3")]:86019,[r.A.mp4v]:12,[(0,r.A)("av01")]:226,[(0,r.A)("vp08")]:139,[(0,r.A)("vp09")]:167,[(0,r.A)("avc1")]:27,[(0,r.A)("hev1")]:173,[(0,r.A)("hvc1")]:173,[(0,r.A)("text")]:94213,[(0,r.A)("tx3g")]:94213}},5977:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var r=i(4624),s="src/avformat/function/mktag.ts";function a(t){4!==t.length&&r.R8(`tag length is not 4, tag: ${t}`,s,30);let e=0;for(let i=0;i<4;i++)e=e<<8|t.charCodeAt(i);return e}},7580:(t,e,i)=>{"use strict";i.d(e,{A:()=>d});var r=i(1026),s=i(2348),a=i.n(s),n=i(3724),o=i(2800),h=i(5335),c=i(4624),u="src/avnetwork/ioLoader/FetchIOLoader.ts";class d extends o.A{constructor(t={}){super(t),(0,r.A)(this,"contentLength",void 0),(0,r.A)(this,"receivedLength",void 0),(0,r.A)(this,"info",void 0),(0,r.A)(this,"range",void 0),(0,r.A)(this,"startBytes",void 0),(0,r.A)(this,"endBytes",void 0),(0,r.A)(this,"eofIndex",void 0),(0,r.A)(this,"abortController",void 0),(0,r.A)(this,"reader",void 0),(0,r.A)(this,"buffers",void 0)}async open(t,e){var i;if(this.info=t,this.range=e,this.range.to||(this.range.to=-1),this.range.from=Math.max(this.range.from,0),this.eofIndex<0&&(this.eofIndex=e.to),this.startBytes=0,this.endBytes=-1,this.receivedLength=0,this.buffers=[],this.range&&!this.options.isLive&&(this.startBytes=null!==(i=this.range.from)&&void 0!==i?i:0),this.status=1,!this.options.isLive&&!this.options.disableSegment){const t={method:"HEAD",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};this.info.headers&&h.__(this.info.headers,((e,i)=>{t.headers[i]=e})),this.info.withCredentials&&(t.credentials="include"),this.info.referrerPolicy&&(t.referrerPolicy=this.info.referrerPolicy),AbortController&&(this.abortController=new AbortController,t.signal=this.abortController.signal);try{const e=await fetch(this.info.url,t);if(e.ok&&e.status>=200&&e.status<=299){const t=e.headers.get("X-Content-Length")||e.headers.get("Content-Length");null!=t&&(this.contentLength=a()(t),this.range.to<0&&(this.eofIndex=this.contentLength+this.range.to)),this.endBytes=Math.min(this.startBytes+this.options.preload-1,this.eofIndex),this.status=2}else this.endBytes=-1}catch(t){this.endBytes=-1}}}async openReader(){const t={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};this.info.headers&&h.__(this.info.headers,((e,i)=>{t.headers[i]=e})),this.options.isLive||(t.headers.range=`bytes=${this.startBytes}-${this.endBytes>0?this.endBytes:""}`),this.info.withCredentials&&(t.credentials="include"),this.info.referrerPolicy&&(t.referrerPolicy=this.info.referrerPolicy),this.abortController&&this.abortController.abort(),"function"==typeof AbortController&&(this.abortController=new AbortController,t.signal=this.abortController.signal);try{const e=await fetch(this.info.url,t);e.ok&&e.status>=200&&e.status<=299?this.reader=e.body.getReader():(this.status=3,c.h2(`FetchStreamLoader: Http code invalid, ${e.status} ${e.statusText}`,u,189))}catch(t){if(this.retryCountt.length-i?(t.set(e.subarray(0,t.length-i),i),this.buffers.unshift(e.subarray(t.length-i)),i=t.length):(t.set(e,i),i+=e.length)}if(i>=t.length)return t.length+e;if(4===this.status)return i>0?i+e:e>0?e:-1048576;this.reader||await this.openReader();const{value:r,done:s}=await this.reader.read();return s?null!==this.contentLength&&this.receivedLength+this.range.from=this.eofIndex?(this.status=4,this.startBytes=0,i>0?i+e:e>0?e:-1048576):(await this.reader.cancel(),this.abortController&&this.abortController.abort(),this.reader=null,this.startBytes=this.endBytes+1,this.endBytes=Math.min(this.startBytes+this.options.preload-1,this.eofIndex),this.readInterval(t.subarray(i),i)):(this.receivedLength+=r.length,r.length>t.length-i?(t.set(r.subarray(0,t.length-i),i),this.buffers.push(r.subarray(t.length-i)),t.length+e):(t.set(r,i),i+=r.length,i+e))}async read(t){return this.readInterval(t)}async seek(t){await this.abort(),this.receivedLength=Number(t)-this.range.from,this.startBytes=Number(t),this.options.disableSegment||(this.endBytes=Math.min(this.startBytes+this.options.preload,this.eofIndex)),this.buffers.length=0,4===this.status&&(this.status=2)}async size(){return this.options.isLive?BigInt(0):BigInt(Math.floor(this.contentLength))}async abort(){this.reader&&(await this.reader.cancel(),this.abortController&&this.abortController.abort(),this.reader=null)}async stop(){await this.abort(),this.status=0}}},2800:(t,e,i)=>{"use strict";i.d(e,{A:()=>n});var r=i(1026),s=i(5335);const a={isLive:!0,preload:5242880,retryCount:20,retryInterval:1};class n{constructor(t={}){(0,r.A)(this,"options",void 0),(0,r.A)(this,"status",void 0),(0,r.A)(this,"retryCount",void 0),(0,r.A)(this,"retryTimeout",void 0),this.options=t,this.status=0,this.retryCount=0,this.options=s.X$({},a),s.X$(this.options,t)}}},8393:(t,e,i)=>{"use strict";i.d(e,{A:()=>k});var r=i(4001),s=i.n(r),a=i(2264),n=i(915),o=i(3939),h=i(932),c=i(4527),u=i(9705),d=i(4149),l=i(1026),f=i(1063),p=i(4363),m=i(4624);class g{constructor(t){(0,l.A)(this,"options",void 0),(0,l.A)(this,"decoder",void 0),(0,l.A)(this,"frame",void 0),this.options=t,this.decoder=new f.A(t.resource)}getAVFrame(){return this.frame?this.frame:this.frame=this.options.avframePool?this.options.avframePool.alloc():(0,p.FP)()}outputAVFrame(){this.frame&&(this.options.onReceiveFrame?this.options.onReceiveFrame(this.frame):this.options.avframePool?this.options.avframePool.release(this.frame):(0,p.xj)(this.frame),this.frame=0)}receiveAVFrame(){return this.decoder.call("decoder_receive",this.getAVFrame())}async open(t){await this.decoder.run();let e=this.decoder.call("decoder_open",t,0,1);e<0&&m.h2(`open audio decoder failed, ret: ${e}`,"src/avcodec/wasmcodec/AudioDecoder.ts",82)}decode(t){let e=this.decoder.call("decoder_decode",t);if(e)return e;for(;;){if(e=this.receiveAVFrame(),1!==e){if(e<0)return e;break}this.outputAVFrame()}return 0}async flush(){for(this.decoder.call("decoder_flush");;){if(this.receiveAVFrame()<1)return;this.outputAVFrame()}}close(){this.decoder.call("decoder_close"),this.decoder.destroy(),this.decoder=null,this.frame&&(this.options.avframePool?this.options.avframePool.release(this.frame):(0,p.xj)(this.frame),this.frame=0)}}var v=i(6041),A=i(4290),y=i(2739),w=i(6932),b="src/avpipeline/AudioDecodePipeline.ts";class k extends c.A{constructor(){super()}createTask(t){const e=new d.Ay(t.leftPort),i=new d.Ay(t.rightPort),r=[],s=new v.A((0,n.A)(t.avframeList,a.A),t.avframeListMutex),c=new g({resource:t.resource,onError:e=>{m.z3(`audio decode error, taskId: ${t.taskId}, error: ${e}`,b,88);const i=this.tasks.get(t.taskId);i.openReject&&(i.openReject(e),i.openReject=null)},onReceiveFrame(t){r.push(t),h.M[17](u.stats+56,o.f[17](u.stats+56)+BigInt(1)),u.lastDecodeTimestamp&&h.M[15](u.stats+216,Math.max((0,w.A)()-u.lastDecodeTimestamp,o.f[15](u.stats+216))),u.lastDecodeTimestamp=(0,w.A)()},avframePool:s}),u={...t,frameCaches:r,inputEnd:!1,decoder:c,lastDecodeTimestamp:0,avframePool:s,avpacketPool:new A.A((0,n.A)(t.avpacketList,a.A),t.avpacketListMutex)};return this.tasks.set(t.taskId,u),i.on(d.S3,(async s=>{switch(s.method){case"pull":if(r.length){const t=r.shift();i.reply(s,t);break}if(!u.inputEnd){for(;;){if(r.length){const t=r.shift();i.reply(s,t);break}const a=await e.request("pull");if(-1048576===a){if(await u.decoder.flush(),u.inputEnd=!0,r.length){const t=r.shift();i.reply(s,t);break}m.pq(`audio decoder ended, taskId: ${u.taskId}`,b,165),i.reply(s,-1048576);break}if(!(a>0)){m.z3(`audio decode pull avpacket error, taskId: ${t.taskId}, ret: ${a}`,b,184),i.reply(s,a);break}{const e=u.decoder.decode(a);if(u.avpacketPool.release(a),e<0){h.M[15](u.stats+48,o.f[15](u.stats+48)+1),m.z3(`audio decode error, taskId: ${t.taskId}, ret: ${e}`,b,177),i.reply(s,e);break}}}break}i.reply(s,-1048576)}})),0}async open(t,e,i){const r=this.tasks.get(t);if(r)return new(s())((async(t,i)=>{r.openReject=i,await r.decoder.open(e),t()}));m.h2("task not found",b,209)}async resetTask(t){const e=this.tasks.get(t);e&&(e.decoder&&await e.decoder.flush(),y.__(e.frameCaches,(t=>{e.avframePool.release(t)})),e.frameCaches.length=0,e.inputEnd=!1,e.lastDecodeTimestamp=(0,w.A)(),m.pq(`reset audio decoder, taskId: ${e.taskId}`,b,225))}async registerTask(t){return this.tasks.has(t.taskId)?u.lh:this.createTask(t)}async unregisterTask(t){const e=this.tasks.get(t);e&&(e.rightPort.close(),e.leftPort.close(),e.decoder.close(),e.frameCaches.forEach((t=>{e.avframePool.release(t)})),this.tasks.delete(t))}}},5181:(t,e,i)=>{"use strict";i.d(e,{A:()=>O});var r=i(1026),s=i(662),a=i.n(s),n=i(4001),o=i.n(n),h=i(1499),c=i(4503),u=i(2264),d=i(915),l=i(3939),f=i(932),p=i(4300),m=i(4527),g=i(9705),v=i(4149),A=i(4624),y=i(6041),w=i(2699),b=i(1063);class k{constructor(t){(0,r.A)(this,"resampler",void 0),(0,r.A)(this,"options",void 0),(0,r.A)(this,"inputParameters",void 0),(0,r.A)(this,"outputParameters",void 0),this.options=t,this.resampler=new b.A(this.options.resource)}async open(t,e){var i,r;this.inputParameters=t,this.outputParameters=e,await this.resampler.run();const s=w.z(8);f.M[10](s,null!==(i=t.layout)&&void 0!==i?i:BigInt(0)),this.resampler.call("resample_set_input_parameters",t.sampleRate,t.channels,t.format,s),f.M[10](s,null!==(r=e.layout)&&void 0!==r?r:BigInt(0)),this.resampler.call("resample_set_output_parameters",e.sampleRate,e.channels,e.format,s),w.t(8);let a=this.resampler.call("resample_init");a<0&&A.h2(`open resampler failed, ret: ${a}`,"src/audioresample/Resampler.ts",88)}resample(t,e,i){return this.resampler.call("resample_process",t,e,i)}close(){this.resampler.call("resample_destroy"),this.resampler.destroy(),this.resampler=null}getInputPCMParameters(){return this.inputParameters}getOutputPCMParameters(){return this.outputParameters}}var x,_,P=i(2085);class T{constructor(){(0,r.A)(this,"data",void 0),(0,r.A)(this,"nbSamples",void 0),(0,r.A)(this,"maxnbSamples",void 0),(0,r.A)(this,"channels",void 0),(0,r.A)(this,"sampleRate",void 0),(0,r.A)(this,"timestamp",void 0),(0,r.A)(this,"duration",void 0)}}x=T.prototype,(_=new(a())).set("data",{0:2,1:1,2:2,3:0,4:0,5:0,6:0,7:0,8:0}),_.set("nbSamples",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:4,8:0}),_.set("maxnbSamples",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:8,8:0}),_.set("channels",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:12,8:0}),_.set("sampleRate",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:16,8:0}),_.set("timestamp",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:24,8:0}),_.set("duration",{0:19,1:0,2:0,3:0,4:0,5:0,6:0,7:32,8:0}),(0,P.A)(x,h.Og,!0),(0,P.A)(x,h.dc,8),(0,P.A)(x,h.g7,40),(0,P.A)(x,h.JY,_),function(t){var e=new(a());e.set("refCount",{0:16,1:0,2:0,3:0,4:0,5:0,6:0,7:40,8:0}),(0,P.A)(t,h.Og,!0),(0,P.A)(t,h.dc,8),(0,P.A)(t,h.g7,48),(0,P.A)(t,h.JY,e)}(class extends T{constructor(...t){super(...t),(0,r.A)(this,"refCount",void 0)}}.prototype);var I=i(46),C=i(3783),B=i(7837);class S{constructor(t,e){(0,r.A)(this,"list",void 0),(0,r.A)(this,"mutex",void 0),this.list=t,this.mutex=e}alloc(){let t=this.list.find((t=>-1===I.p_(t+40,-1,1,16,2)),20);return t||(t=(0,B.Gy)(48),f.M[16](t+40,1),C.s2(this.mutex),this.list.push(t,20),C.Tl(this.mutex)),t}release(t){I.Hh(t+40,16,2)<=0||1===I.jb(t+40,1,16,2)&&I.M_(t+40,-1,16,2)}}class M{constructor(t){(0,r.A)(this,"processor",void 0),(0,r.A)(this,"options",void 0),this.options=t,this.processor=new b.A(this.options.resource)}async open(t){await this.processor.run(),this.processor.call("stretchpitch_init"),this.processor.call("stretchpitch_set_channels",t.channels),this.processor.call("stretchpitch_set_samplerate",t.sampleRate)}setRate(t){this.processor.call("stretchpitch_set_rate",t)}setRateChange(t){this.processor.call("stretchpitch_set_rate_change",t)}setTempo(t){this.processor.call("stretchpitch_set_tempo",t)}setTempoChange(t){this.processor.call("stretchpitch_set_tempo_change",t)}setPitch(t){this.processor.call("stretchpitch_set_pitch",t)}setPitchOctaves(t){this.processor.call("stretchpitch_set_pitch_octaves",t)}setPitchSemiTones(t){this.processor.call("stretchpitch_set_pitch_semi_tones",t)}sendSamples(t,e){this.processor.call("stretchpitch_send_samples",t,e)}receiveSamples(t,e){return this.processor.call("stretchpitch_receive_samples",t,e)}flush(){this.processor.call("stretchpitch_flush")}clear(){this.processor.call("stretchpitch_clear")}getUnprocessedSamplesCount(){return this.processor.call("stretchpitch_get_unprocessed_samples_num")}getInputOutputSamplesRatio(){return this.processor.call("stretchpitch_get_input_output_sample_ratio")}getLatency(){return this.processor.call("get_latency")}close(){this.processor.call("stretchpitch_destroy"),this.processor.destroy(),this.processor=null}}var R=i(4686),U=i(4328),E=i(7231),D=i(6932),L=i(3724),F=i(3607),z="src/avpipeline/AudioRenderPipeline.ts";class O extends m.A{constructor(){super(),(0,r.A)(this,"avPCMBufferPool",void 0),(0,r.A)(this,"avPCMBufferList",void 0),this.avPCMBufferList=(0,c.A)(u.A),this.avPCMBufferPool=new S(this.avPCMBufferList)}async createTask(t){const e=new v.Ay(t.leftPort),i=new v.Ay(t.rightPort),r=new v.Ay(t.controlPort),s={...t,leftIPCPort:e,rightIPCPort:i,controlIPCPort:r,resampler:null,stretchpitcher:new(a()),outPCMBuffer:null,waitPCMBuffer:0,waitAVFrame:0,waitPCMBufferPos:0,frameEnded:!1,stretchpitcherEnded:!1,playRate:1,playTempo:1,playPitch:1,useStretchpitcher:!1,lastNotifyPTS:BigInt(0),currentPTS:E.Dh,firstPlayed:!1,seeking:!1,pausing:!1,seekSync:null,receivePCMSync:null,paddingAVFrame:0,fakePlayStartTimestamp:0,fakePlaySamples:BigInt(0),fakePlayTimer:null,fakePlay:!1,lastRenderTimestamp:0,avframePool:new y.A((0,d.A)(t.avframeList,u.A),t.avframeListMutex)};s.startPTS=(0,U.k)(s.startPTS,s.timeBase,E.i0);for(let e=0;e{s.receivePCMSync=t})),s.enableJitterBuffer&&l.f[15](s.stats+32)/l.f[15](s.stats+212)*1e3<=l.f[15](s.jitterBuffer)&&n.setPlayRate(s.taskId,1),s.frameEnded&&s.useStretchpitcher){let i=0;for(let r=0;r=BigInt(1e3)){s.lastNotifyPTS=s.currentPTS;const e=((s.useStretchpitcher?s.stretchpitcher.get(0).getLatency():0)+(3*l.f[15](t+8)>>>1))/s.playSampleRate*1e3>>>0;s.controlIPCPort.notify("syncPts",{pts:F.T9(s.currentPTS-BigInt(Math.floor(e)),BigInt(0))})}return s.seekSync&&(s.seekSync(),s.seekSync=null),0}return i.on(v.S3,(async t=>{switch(t.method){case"pull":{if(s.fakePlay&&(s.fakePlay=!1,s.fakePlayTimer&&(clearTimeout(s.fakePlayTimer),s.fakePlayTimer=null),s.fakePlaySamples=BigInt(0),s.fakePlayStartTimestamp=0),s.frameEnded&&(s.stretchpitcherEnded||!s.useStretchpitcher))return void i.reply(t,-1048576);const e=t.params.buffer,r=await g(e);i.reply(t,r);break}case"pullBuffer":{if(s.fakePlay&&(s.fakePlay=!1,s.fakePlayTimer&&(clearTimeout(s.fakePlayTimer),s.fakePlayTimer=null),s.fakePlaySamples=BigInt(0),s.fakePlayStartTimestamp=0),s.frameEnded&&(s.stretchpitcherEnded||!s.useStretchpitcher))return void i.reply(t,-1048576);const e=t.params.nbSamples;if(!s.outPCMBuffer||s.outPCMBuffer.maxnbSamples!==e){s.outPCMBuffer&&((0,B.aI)(s.outPCMBuffer.data),(0,B.aI)(s.outPCMBuffer[h.o9]),(0,p.A)(s.outPCMBuffer)),s.outPCMBuffer=(0,c.A)(T),s.outPCMBuffer.data=(0,B.sY)(4*s.playChannels);const t=(0,B.Gy)(4*e*s.playChannels);for(let i=0;i{e.seekSync=t}))),e.seeking=!0,e.stretchpitcher.size)for(const t of e.stretchpitcher.keys())e.stretchpitcher.get(t).clear();e.waitPCMBuffer&&(e.waitAVFrame&&(f.M[20](e.waitPCMBuffer,0),f.M[15](e.waitPCMBuffer+8,0),e.avframePool.release(e.waitAVFrame),e.waitAVFrame=0),this.avPCMBufferPool.release(e.waitPCMBuffer),e.waitPCMBuffer=0),A.Yz(`before seek end, taskId: ${e.taskId}`,z,633)}}async syncSeekTime(t,e,i){const r=this.tasks.get(t);if(r){let s=!1;for(;;){let a=(0,D.A)(),n=l.f[15](r.stats+112);for(;!s&&i&&l.f[15](r.stats+112)>i;)await new L.A(0),(0,D.A)()-a>200&&n===l.f[15](r.stats+112)&&(s=!0),n!==l.f[15](r.stats+112)&&(n=l.f[15](r.stats+112),a=(0,D.A)());let o=await r.leftIPCPort.request("pull");if(o<0){A.R8(`pull audio frame end after seek, taskId: ${t}`,z,663),r.frameEnded=!0;break}if(e=e){r.paddingAVFrame=o,r.frameEnded=!1,r.lastNotifyPTS=h;break}r.avframePool.release(o)}A.Yz(`sync seek time end, taskId: ${r.taskId}`,z,693)}}async afterSeek(t,e){const i=this.tasks.get(t);i&&(i.seeking=!1,i.receivePCMSync&&(i.receivePCMSync(),i.receivePCMSync=null),i.pausing||(i.fakePlay&&(i.fakePlayStartTimestamp=(0,D.A)(),i.fakePlaySamples=BigInt(0),this.fakePlayNext(i)),i.lastRenderTimestamp=(0,D.A)()),A.Yz(`after seek end, taskId: ${i.taskId}`,z,715))}async restart(t){const e=this.tasks.get(t);if(e){var i;if(e.lastNotifyPTS=BigInt(0),e.frameEnded=!1,e.firstPlayed=!1,e.stretchpitcherEnded=!1,null!==(i=e.stretchpitcher)&&void 0!==i&&i.size)for(let t=0;t>>0;i/=t.playRate*t.playTempo;const r=BigInt(Math.floor((0,D.A)()-t.fakePlayStartTimestamp))*BigInt(l.f[15](e+168)>>>0)/BigInt(1e3);i-=Number(r-t.fakePlaySamples)/l.f[15](e+168)*1e3>>>0,t.fakePlaySamples+=BigInt(l.f[15](e+76)>>>0),t.avframePool.release(e),t.fakePlayTimer=setTimeout((()=>{t.fakePlayTimer=null,this.fakePlayNext(t)}),i)}async fakePlay(t){const e=this.tasks.get(t);e&&(e.fakePlayStartTimestamp=(0,D.A)(),e.fakePlay=!0,e.fakePlaySamples=BigInt(0),this.fakePlayNext(e),A.pq(`start fake play, taskId: ${e.taskId}`,z,787))}async pause(t){const e=this.tasks.get(t);e&&(e.pausing=!0,e.fakePlay&&e.fakePlayTimer&&(clearTimeout(e.fakePlayTimer),e.fakePlayTimer=null),A.pq(`task paused, taskId: ${e.taskId}`,z,802))}async unpause(t){const e=this.tasks.get(t);e&&(e.pausing=!1,e.fakePlay&&(e.fakePlayStartTimestamp=(0,D.A)(),e.fakePlaySamples=BigInt(0),e.lastRenderTimestamp=(0,D.A)(),this.fakePlayNext(e)),A.pq(`task unpaused, taskId: ${e.taskId}`,z,817))}async registerTask(t){return this.tasks.has(t.taskId)?g.lh:await this.createTask(t)}async unregisterTask(t){const e=this.tasks.get(t);if(e){if(e.resampler&&e.resampler.close(),e.stretchpitcher.size){for(const t of e.stretchpitcher.keys())e.stretchpitcher.get(t).close();e.stretchpitcher.clear()}e.outPCMBuffer&&((0,B.aI)(e.outPCMBuffer.data),(0,B.aI)(e.outPCMBuffer[h.o9]),(0,p.A)(e.outPCMBuffer)),e.waitPCMBuffer&&(e.waitAVFrame&&(f.M[20](e.waitPCMBuffer,0),f.M[15](e.waitPCMBuffer+8,0),e.avframePool.release(e.waitAVFrame)),this.avPCMBufferPool.release(e.waitPCMBuffer),e.waitPCMBuffer=0),e.paddingAVFrame&&e.avframePool.release(e.paddingAVFrame),e.leftIPCPort.destroy(),e.rightIPCPort.destroy(),this.tasks.delete(t)}}async clear(){await super.clear(),this.avPCMBufferList.clear((t=>{l.f[20](t)&&((0,B.aI)(l.f[20](t)),(0,B.aI)(t))}),20),(0,p.A)(this.avPCMBufferList)}}},4582:(t,e,i)=>{"use strict";i.d(e,{A:()=>L});var r=i(662),s=i.n(r),a=i(1499),n=i(2264),o=i(915),h=i(3939),c=i(932),u=i(9599),d=i(4527),l=i(9705),f=i(4149),p=i(1091),m=i(4175),g=i(5335),v=i(2739),A=i(7231),y=i(4328);function w(t){let e=!0;return v.__(t.streams,(t=>{switch(t.codecpar.codecType){case 1:t.codecpar.chLayout.nbChannels!==A.N_&&t.codecpar.sampleRate!==A.N_&&t.codecpar.frameSize!==A.N_&&t.codecpar.bitRate!==BigInt(0)||(e=!1);break;case 0:0!==(0,y.lb)(t.codecpar.framerate)&&t.codecpar.width!==A.N_&&t.codecpar.height!==A.N_&&t.codecpar.bitRate!==BigInt(0)||(e=!1),27!==t.codecpar.codecId&&173!==t.codecpar.codecId&&12!==t.codecpar.codecId||t.codecpar.profile!==A.N_&&t.codecpar.level!==A.N_||(e=!1)}})),e}var b=i(1517);const k=BigInt(5e3);var x=i(4624),_="src/avformat/demux.ts";const P={fastOpen:!1,maxAnalyzeDuration:1e3};function T(t,e){const i=v.El(t.sampleIndexes,(t=>t.pts-1?(t.sampleIndexesPosMap.set(h.f[17](e+56),i),t.sampleIndexes.splice(i,0,r)):(t.sampleIndexesPosMap.set(h.f[17](e+56),t.sampleIndexes.length),t.sampleIndexes.push(r))}async function I(t,e){const i=t.getStreamById(h.f[15](e+32));let r=0;if(i&&(27===i.codecpar.codecId||173===i.codecpar.codecId||86018===i.codecpar.codecId))if(!h.f[15](e+28)&&(0,b.fQ)(e,1))for(;;){const i=(0,b._5)();if(r=await t.iformat.readAVPacket(t,i),0!==r){if(t.interval.packetBuffer.length){let i=t.interval.packetBuffer.shift();return(0,b.Up)(e),(0,b.rN)(e,i),(0,b.Qe)(i),I(t,e)}return r}if(h.f[15](i+32)!==h.f[15](e+32))t.interval.packetBuffer.push(i);else{if(h.f[15](i+28))return(0,b.Zx)(e,i),(0,b.Qe)(i),0;(0,b.Up)(e),(0,b.rN)(e,i),(0,b.Qe)(i)}}else if(32&h.f[15](e+36))return C(t,e);if(1&t.ioReader.flags&&!i.sampleIndexesPosMap.has(h.f[17](e+56)))if(0===i.codecpar.codecType)1&h.f[15](e+36)&&T(i,e);else if(1===i.codecpar.codecType){const t=v.El(i.sampleIndexes,(t=>t.pts=k||t>0&&t=k||0===t&&(0,y.k)(i.sampleIndexes[0].pts-h.f[17](e+8),(0,o.A)(e+72,u.P),A.i0)>=k)&&T(i,e)}return 0}async function C(t,e){let i=0;if((0,b.Up)(e),t.interval.packetBuffer.length){const i=t.interval.packetBuffer.shift();return(0,b.rN)(e,i),(0,b.Qe)(i),I(t,e)}return i=await t.iformat.readAVPacket(t,e),0!==i?((0,b.Up)(e),i):I(t,e)}async function B(t,e,i,r){let s=t.streams[e];if(s||(s=t.getStreamByMediaType(0),s||(s=t.getStreamByMediaType(1))),!s)return x.z3(`not found any stream to seek, streamIndex: ${s.index}`,_,463),BigInt(l.LR);x.Yz(`seek in ${0===s.codecpar.codecType?"video":"audio"} stream, streamIndex: ${s.index}, timestamp: ${i}, flags: ${r}`,_,467),i=(0,y.k)(i,A.i0,s.timeBase);const a=await t.iformat.seek(t,s,i,r);return a>=BigInt(0)?(v.__(t.interval.packetBuffer,(t=>{(0,b.Qe)(t)})),t.interval.packetBuffer.length=0,BigInt(0)):a}var S=i(7837),M=i(4211),R=i(4290),U=i(9148),E="src/avpipeline/DemuxPipeline.ts";const D=-1;class L extends d.A{constructor(){super()}async judgeFormat(t,e=-1){let i=await t.peekString(8);return/^FLV/.test(i)?0:/^DKIF/.test(i)?4:/^ftyp/.test(i.slice(4,8))?1:/^OggS/.test(i)?3:/^ID3/.test(i)?7:/^fLaC/.test(i)?10:/^RIFF/.test(i)?9:440786851===await t.peekUint32()?5:e}createTask(t){let e;if(t.mainTaskId){const i=this.tasks.get(t.mainTaskId);e=i.leftIPCPort}else e=new f.Ay(t.leftPort);const i=t.bufferLength||1048576,r=(0,S.sY)(i);if(!r)return l.gR;const a=new M.A(r,i),h=new m.A(i,!0,a);t.isLive||(h.flags|=1),h.onFlush=async i=>{const r={pointer:i.byteOffset,length:i.length};t.ioloaderOptions&&(r.ioloaderOptions=t.ioloaderOptions);try{return await e.request("read",r)}catch(t){return-1048574}},h.onSeek=async i=>{try{const r={pos:i};return t.ioloaderOptions&&(r.ioloaderOptions=t.ioloaderOptions),await e.request("seek",r),0}catch(t){return-1048574}},h.onSize=async()=>{try{return await e.request("size")}catch(t){return BigInt(-1048574)}};const c=(0,p.X)();return c.ioReader=h,this.tasks.set(t.taskId,{...t,leftIPCPort:e,rightIPCPorts:new(s()),formatContext:c,ioReader:h,buffer:r,cacheAVPackets:new(s()),cacheRequests:new(s()),realFormat:-1,demuxEnded:!1,loop:null,gopCounter:0,lastKeyFramePts:BigInt(0),lastAudioDts:BigInt(0),lastVideoDts:BigInt(0),avpacketPool:new R.A((0,o.A)(t.avpacketList,n.A),t.avpacketListMutex)}),0}async openStream(t){const e=this.tasks.get(t);if(e){let t,r;await e.leftIPCPort.request("open");try{t=await this.judgeFormat(e.ioReader,e.format),e.format=t}catch(t){return l.LR}switch(t){case 0:r=new((await i.e(717).then(i.bind(i,681))).default);break;case 1:r=new((await i.e(556).then(i.bind(i,5844))).default);break;case 2:r=new((await i.e(485).then(i.bind(i,6485))).default);break;case 4:r=new((await i.e(634).then(i.bind(i,6634))).default);break;case 3:r=new((await i.e(968).then(i.bind(i,7968))).default);break;case 7:r=new((await i.e(940).then(i.bind(i,7940))).default);break;case 5:r=new((await i.e(984).then(i.bind(i,2816))).default);break;case 8:r=new((await i.e(94).then(i.bind(i,7094))).default);break;case 10:r=new((await i.e(797).then(i.bind(i,2797))).default);break;case 9:r=new((await i.e(228).then(i.bind(i,3228))).default);break;default:return x.z3("format not support",E,360),l.E$}return e.realFormat=t,e.formatContext.iformat=r,await async function(t,e={}){const i=g.X$({},P,e);return t.ioReader||x.h2("need IOReader",_,62),t.iformat||x.h2("need iformat",_,65),2===t.iformat.type&&(i.maxAnalyzeDuration=Math.max(i.maxAnalyzeDuration,2e3)),t.iformat.init(t),t.options=i,t.iformat.readHeader(t)}(e.formatContext,{maxAnalyzeDuration:2,fastOpen:e.isLive})}x.h2("task not found",E,375)}async getFormat(t){const e=this.tasks.get(t);if(e)return e.realFormat;x.h2("task not found",E,385)}async analyzeStreams(t){const e=this.tasks.get(t);if(e){await async function(t){const e=t.iformat.getAnalyzeStreamsCount(),i={},r={},s={};let a=0;const n=[];let o=0;for(;!(t.streams.length>=e&&w(t)&&t.options.fastOpen);){a||(a=(0,b._5)());let e=!1;if(o=await C(t,a),0!==o)break;const c=t.getStreamByIndex(h.f[15](a+32));if(h.f[15](a+28)&&(e=!0,n.push(a),i[c.index]||(c.firstDTS=h.f[17](a+16),c.startTime=h.f[17](a+8),i[c.index]=!0),h.f[17](a+8)0?c.codecpar.frameSize=Math.round(e/c.timeBase.den*c.timeBase.num*c.codecpar.sampleRate):0===c.codecpar.codecType&&(c.codecpar.framerate.num=c.timeBase.den*c.timeBase.num,c.codecpar.framerate.den=e>>>0);const i=Number(h.f[17](a+16)-c.firstDTS)*c.timeBase.num/c.timeBase.den;i&&(c.codecpar.bitRate=BigInt(Math.floor(8*s[c.index]/i)))}if(h.f[17](a+16)-c.startTime>(0,y.k)(BigInt(Math.floor(t.options.maxAnalyzeDuration)),A.i0,c.timeBase)){g.__(r,((e,i)=>{const n=t.getStreamById(+i);if(e&&e.length>1){let t=BigInt(0);for(let i=1;i0?n.codecpar.frameSize=Math.round(i/n.timeBase.den*n.timeBase.num*n.codecpar.sampleRate):0===n.codecpar.codecType&&(n.codecpar.framerate.num=n.timeBase.den*n.timeBase.num,n.codecpar.framerate.den=i>>>0);const o=Number(h.f[17](a+16)-n.firstDTS)*n.timeBase.num/n.timeBase.den;o&&(n.codecpar.bitRate=BigInt(Math.floor(8*s[n.index]/o)))}})),e&&(a=0);break}e&&(a=0)}return a&&(0,b.Qe)(a),n.length&&(t.interval.packetBuffer=n.concat(t.interval.packetBuffer)),-1048576===o?0:0!==o?o:(2===t.iformat.type&&1&t.ioReader.flags&&await async function(t){const e=await t.ioReader.fileSize();if(e<=BigInt(0))return;const i=t.interval.packetBuffer;t.interval.packetBuffer=[];let r=t.ioReader.getPos(),s=0;for(;s<4;){const i=e-BigInt(Math.floor(256e3<BigInt(0)&&(r=a);const n={},o=(0,b._5)();for(;!(await C(t,o)<0);){let e=h.f[17](o+8);const i=t.getStreamByIndex(h.f[15](o+32));i.startTime!==A.Dh?e-=i.startTime:e-=i.firstDTS,e>BigInt(0)&&((i.duration===A.Dh||!n[h.f[15](o+32)]||i.duration{if(t.duration===A.Dh)return c=!1,!1})),c)break;s++}v.__(t.interval.packetBuffer,(t=>{(0,b.Qe)(t)})),t.interval.packetBuffer=i,await t.iformat.seek(t,null,r,2)}(t),0)}(e.formatContext);const t=[];for(let i=0;i{switch(i.method){case"pull":{const s=r.cacheAVPackets.get(e);if(s.length){const e=s.shift();1===r.formatContext.streams[h.f[15](e+32)].codecpar.codecType?c.M[15](r.stats+32,h.f[15](r.stats+32)-1):0===r.formatContext.streams[h.f[15](e+32)].codecpar.codecType&&c.M[15](r.stats+112,h.f[15](r.stats+112)-1),t.reply(i,e)}else r.demuxEnded?t.reply(i,-1048576):(r.cacheRequests.set(e,i),r.loop&&r.loop.isStarted()&&r.loop.resetInterval());break}}})),r.rightIPCPorts.set(e,t),x.Yz(`connect stream ${e}, taskId: ${r.taskId}`,E,455)}else x.h2("task not found",E,458)}async startDemux(t,e,i){const r=this.tasks.get(t);r?(2===r.format&&(i=Math.max(i,20)),r.loop&&r.loop.destroy(),r.loop=new U.A((async()=>{if(!e){let t=!1,e=!1;if(r.cacheAVPackets.forEach((r=>{r.length>i&&(t=!0),0===r.length&&(e=!0)})),t&&!e)return void r.loop.emptyTask()}const s=r.avpacketPool.alloc();let a=await C(r.formatContext,s);if(a){r.avpacketPool.release(s),-1048576!==a&&x.z3(`demux error, ret: ${a}, taskId: ${t}`,E,594),r.demuxEnded=!0,x.pq(`demuxer ended, taskId: ${r.taskId}`,E,599);for(let t of r.cacheRequests.keys())r.cacheAVPackets.get(t).length||(r.rightIPCPorts.get(t).reply(r.cacheRequests.get(t),-1048576),r.cacheRequests.delete(t));r.loop.stop()}else{const t=h.f[15](s+32);if(1===r.formatContext.streams[t].codecpar.codecType&&r.cacheAVPackets.has(t)){if(c.M[17](r.stats+24,h.f[17](r.stats+24)+BigInt(1)),c.M[17](r.stats+16,h.f[17](r.stats+16)+BigInt(h.f[15](s+28)>>>0)),h.f[17](r.stats+24)>1&&h.f[17](s+16)>r.lastAudioDts){const e=r.cacheAVPackets.get(t);e&&e.length?c.M[15](r.stats+212,Math.round(h.f[15](s+76)/h.f[15](s+72)/((0|Number(h.f[17](s+16)-h.f[17](e[0]+16)&0xffffffffn))/e.length))):c.M[15](r.stats+212,Math.round(h.f[15](s+76)/h.f[15](s+72)/(0|Number(h.f[17](s+16)-r.lastAudioDts&0xffffffffn))))}r.lastAudioDts=h.f[17](s+16)}else if(0===r.formatContext.streams[t].codecpar.codecType&&r.cacheAVPackets.has(t)){if(c.M[17](r.stats+104,h.f[17](r.stats+104)+BigInt(1)),c.M[17](r.stats+96,h.f[17](r.stats+96)+BigInt(h.f[15](s+28)>>>0)),1&h.f[15](s+36)?(c.M[17](r.stats+160,h.f[17](r.stats+160)+BigInt(1)),h.f[17](r.stats+160)>1&&h.f[17](s+8)>r.lastKeyFramePts&&(c.M[15](r.stats+88,r.gopCounter),r.gopCounter=1,c.M[15](r.stats+84,0|Number(0xffffffffn&(0,y.k)(h.f[17](s+8)-r.lastKeyFramePts,(0,o.A)(s+72,u.P),A.i0)))),r.lastKeyFramePts=h.f[17](s+8)):r.gopCounter++,h.f[17](r.stats+104)>1&&h.f[17](s+16)>r.lastVideoDts){const e=r.cacheAVPackets.get(t);e&&e.length?c.M[15](r.stats+200,Math.round(h.f[15](s+76)/h.f[15](s+72)/((0|Number(h.f[17](s+16)-h.f[17](e[0]+16)&0xffffffffn))/e.length))):c.M[15](r.stats+200,Math.round(h.f[15](s+76)/h.f[15](s+72)/(0|Number(h.f[17](s+16)-r.lastVideoDts&0xffffffffn))))}r.lastVideoDts=h.f[17](s+16)}r.cacheRequests.has(t)?(r.rightIPCPorts.get(t).reply(r.cacheRequests.get(t),s),r.cacheRequests.delete(t)):r.cacheAVPackets.has(t)?(r.cacheAVPackets.get(t).push(s),1===r.formatContext.streams[t].codecpar.codecType?c.M[15](r.stats+32,h.f[15](r.stats+32)+1):0===r.formatContext.streams[t].codecpar.codecType&&c.M[15](r.stats+112,h.f[15](r.stats+112)+1)):r.rightIPCPorts.has(D)?r.cacheRequests.has(D)?(r.rightIPCPorts.get(D).reply(r.cacheRequests.get(D),s),r.cacheRequests.delete(D)):r.cacheAVPackets.get(D).push(s):r.avpacketPool.release(s)}}),0,0,!0,!1),r.loop.start(),x.Yz(`start demux loop, taskId: ${r.taskId}`,E,614)):x.h2("task not found",E,617)}async seek(t,e,i){const r=this.tasks.get(t);if(r){if(r.loop){await r.loop.stopBeforeNextTick();let t=await B(r.formatContext,-1,e,i);if(t>=BigInt(0)){r.cacheAVPackets.forEach((t=>{v.__(t,(t=>{r.avpacketPool.release(t)})),t.length=0})),c.M[15](r.stats+32,0),c.M[15](r.stats+112,0);const i=r.avpacketPool.alloc();for(;t=await C(r.formatContext,i),!(t<0||r.cacheAVPackets.has(h.f[15](i+32))););if(t>=0){r.demuxEnded=!1;const t=h.f[15](i+32);r.cacheAVPackets.get(t).push(i),1===r.formatContext.streams[h.f[15](i+32)].codecpar.codecType?c.M[15](r.stats+32,h.f[15](r.stats+32)+1):0===r.formatContext.streams[h.f[15](i+32)].codecpar.codecType&&c.M[15](r.stats+112,h.f[15](r.stats+112)+1),r.loop.start();let e=h.f[17](i+8);return r.formatContext.streams[t].startTime!==A.Dh?e-=r.formatContext.streams[t].startTime:e-=r.formatContext.streams[t].firstDTS,(0,y.k)(e,(0,o.A)(i+72,u.P),A.i0)}return x.R8(`got first packet failed after seek, taskId: ${r.taskId}`,E,670),r.avpacketPool.release(i),r.demuxEnded=!0,e}return t}{x.pq("seek before demux loop start",E,681);let t=await B(r.formatContext,-1,e,i);return t<0?t:e}}}async croppingAVPacketQueue(t,e){const i=this.tasks.get(t);i&&i.cacheAVPackets.forEach(((t,r)=>{const s=h.f[17](t[t.length-1]+16);let a=t.length-2;for(a=t.length-2;a>=0&&!(1&h.f[15](t[a]+36)&&(0,y.k)(s-h.f[17](t[a]+16),(0,o.A)(t[a]+72,u.P),A.i0)>=e);a--);a>0&&(t.splice(0,a).forEach((t=>{i.avpacketPool.release(t)})),1===i.formatContext.streams[r].codecpar.codecType?c.M[15](i.stats+32,t.length):0===i.formatContext.streams[r].codecpar.codecType&&c.M[15](i.stats+112,t.length))}))}async registerTask(t){return this.tasks.has(t.taskId)?l.lh:this.createTask(t)}async unregisterTask(t){const e=this.tasks.get(t);e&&(e.loop&&(await e.loop.stopBeforeNextTick(),e.loop.destroy()),e.leftIPCPort.destroy(),e.rightIPCPorts.forEach((t=>{t.destroy()})),e.rightIPCPorts.clear(),e.formatContext.destroy(),(0,S.Eb)(e.buffer),e.cacheAVPackets.forEach((t=>{t.forEach((t=>{e.avpacketPool.release(t)}))})),this.tasks.delete(t))}}},115:(t,e,i)=>{"use strict";i.d(e,{A:()=>A});var r=i(3939),s=i(932),a=i(4527),n=i(7580),o=i(9705),h=i(4149),c=i(4686),u=i(1026),d=i(4001),l=i.n(d),f=i(2800),p=i(7672);class m extends f.A{constructor(...t){super(...t),(0,u.A)(this,"info",void 0),(0,u.A)(this,"range",void 0),(0,u.A)(this,"readPos",void 0),(0,u.A)(this,"endPos",void 0),(0,u.A)(this,"reader",void 0),(0,u.A)(this,"readerResolve",void 0)}async open(t,e){this.info=t,this.range=e,this.readPos=0,this.endPos=this.info.file.size,e.from>0&&(this.readPos=e.from),e.to>0&&(this.endPos=e.to),this.status=2}async readBufferByReader(t){this.reader||(this.reader=new FileReader,this.reader.onloadend=t=>{this.readerResolve&&this.readerResolve(t.target.result)});const e=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice;return new(l())((i=>{this.readerResolve=i,this.reader.readAsArrayBuffer(e.call(this.info.file,this.readPos,this.readPos+t))}))}async read(t){if(this.readPos>=this.endPos)return this.status,-1048576;const e=Math.min(t.length,this.endPos-this.readPos);return p.Pc(Blob.prototype.arrayBuffer)?t.set(new Uint8Array(await this.info.file.slice(this.readPos,this.readPos+e).arrayBuffer()),0):t.set(new Uint8Array(await this.readBufferByReader(e)),0),this.readPos+=e,this.readPos>=this.endPos&&(this.status=4),e}async seek(t){return await this.abort(),this.readPos=Number(t),4===this.status&&(this.status=2),0}async size(){return BigInt(Math.floor(this.info.file.size))}async abort(){}async stop(){await this.abort(),this.status=0}}var g=i(4624),v="src/avpipeline/IOPipeline.ts";class A extends a.A{constructor(){super()}async createTask(t){let e;switch(t.type){case 0:e=new n.A(t.options);break;case 1:e=new m(t.options);break;case 2:e=new((await i.e(983).then(i.bind(i,384))).default)(t.options);break;case 3:e=new((await i.e(949).then(i.bind(i,2949))).default)(t.options)}if(!e)return o.UY;const a=new h.Ay(t.rightPort),u={...t,ioLoader:e,ipcPort:a};return a.on(h.S3,(async i=>{switch(i.method){case"open":try{await e.open(t.info,t.range),a.reply(i,{})}catch(e){g.z3(`loader open error, ${e}, taskId: ${t.taskId}`,v,118),a.reply(i,null,e)}break;case"read":{const n=i.params.pointer,h=i.params.length,d=i.params.ioloaderOptions,l=(0,c.JW)(n,h);try{const t=await e.read(l,d);s.M[17](u.stats+176,r.f[17](u.stats+176)+BigInt(t>>>0)),a.reply(i,t)}catch(e){g.z3(`loader read error, ${e}, taskId: ${t.taskId}`,v,139),a.reply(i,o.LR)}break}case"seek":{const r=i.params.pos,s=i.params.ioloaderOptions;try{await e.seek(r,s),a.reply(i)}catch(e){g.z3(`loader seek error, ${e}, taskId: ${t.taskId}`,v,157),a.reply(i,null,e)}break}case"size":a.reply(i,await e.size())}})),this.tasks.set(t.taskId,u),0}async open(t){const e=this.tasks.get(t);if(e)return await e.ioLoader.open(e.info,e.range),0}async getDuration(t){const e=this.tasks.get(t);if(e)return 2===e.type||3===e.type?e.ioLoader.getDuration():0}async hasAudio(t){const e=this.tasks.get(t);if(e)return 3===e.type&&e.ioLoader.hasAudio()}async hasVideo(t){const e=this.tasks.get(t);if(e)return 3===e.type&&e.ioLoader.hasVideo()}async hasSubtitle(t){const e=this.tasks.get(t);if(e)return 3===e.type&&e.ioLoader.hasSubtitle()}async getVideoList(t){const e=this.tasks.get(t);if(e)return 3===e.type||2===e.type?e.ioLoader.getVideoList():{list:[],selectedIndex:0}}async getAudioList(t){const e=this.tasks.get(t);if(e)return 3===e.type?e.ioLoader.getAudioList():{list:[],selectedIndex:0}}async getSubtitleList(t){const e=this.tasks.get(t);if(e)return 3===e.type?e.ioLoader.getSubtitleList():{list:[],selectedIndex:0}}async selectVideo(t,e){const i=this.tasks.get(t);if(i)if(3===i.type)i.ioLoader.selectVideo(e);else if(2===i.type)return i.ioLoader.selectVideo(e)}async selectAudio(t,e){const i=this.tasks.get(t);i&&3===i.type&&i.ioLoader.selectAudio(e)}async selectSubtitle(t,e){const i=this.tasks.get(t);i&&3===i.type&&i.ioLoader.selectSubtitle(e)}async getMinBuffer(t){const e=this.tasks.get(t);if(e)return 3===e.type||2===e.type?e.ioLoader.getMinBuffer():0}async registerTask(t){return this.tasks.has(t.taskId)?o.lh:this.createTask(t)}async unregisterTask(t){const e=this.tasks.get(t);e&&(await e.ioLoader.stop(),e.ipcPort.destroy(),this.tasks.delete(t))}}},4527:(t,e,i)=>{"use strict";i.d(e,{A:()=>o});var r=i(1026),s=i(662),a=i.n(s),n=i(4624);class o{constructor(){(0,r.A)(this,"tasks",void 0),this.tasks=new(a())}async clear(){if(this.tasks.size)for(const t of this.tasks.keys())await this.unregisterTask(t)}async setLogLevel(t){n.V$(t)}async getTaskCount(){return this.tasks.size}}},3823:(t,e,i)=>{"use strict";i.d(e,{A:()=>E});var r=i(4001),s=i.n(r),a=i(3939),n=i(932),o=i(2264),h=i(915),c=i(9599),u=i(4527),d=i(9705),l=i(4149),f=i(1026),p=i(1063),m=i(4363),g=i(4624);class v{constructor(t){(0,f.A)(this,"options",void 0),(0,f.A)(this,"decoder",void 0),(0,f.A)(this,"frame",void 0),(0,f.A)(this,"parameters",void 0),this.options=t,this.decoder=new p.A(this.options.resource)}getAVFrame(){return this.frame?this.frame:this.frame=this.options.avframePool?this.options.avframePool.alloc():(0,m.FP)()}outputAVFrame(){this.frame&&(this.options.onReceiveFrame?this.options.onReceiveFrame(this.frame):this.options.avframePool?this.options.avframePool.release(this.frame):(0,m.xj)(this.frame),this.frame=0)}receiveAVFrame(){return this.decoder.call("decoder_receive",this.getAVFrame())}async open(t,e=1){await this.decoder.run();let i=this.decoder.call("decoder_open",t,0,e);i<0&&g.h2(`open video decoder failed, ret: ${i}`,"src/avcodec/wasmcodec/VideoDecoder.ts",119),this.parameters=t,await this.decoder.childrenThreadReady()}decode(t){let e=this.decoder.call("decoder_decode",t);if(e)return e;for(;;){if(e=this.receiveAVFrame(),1!==e){if(e<0)return e;break}this.outputAVFrame()}return 0}async flush(){for(this.decoder.call("decoder_flush");;){if(this.receiveAVFrame()<1)return;this.outputAVFrame()}}close(){this.decoder.call("decoder_close"),this.decoder.destroy(),this.decoder=null,this.frame&&(this.options.avframePool?this.options.avframePool.release(this.frame):(0,m.xj)(this.frame),this.frame=0),this.parameters=0}setSkipFrameDiscard(t){this.decoder.call("decoder_discard",t)}}var A=i(4214),y=i(4663),w=i(4686),b=i(1517),k=i(1233);class x{constructor(t){(0,f.A)(this,"decoder",void 0),(0,f.A)(this,"options",void 0),(0,f.A)(this,"parameters",void 0),(0,f.A)(this,"extradata",void 0),(0,f.A)(this,"currentError",void 0),(0,f.A)(this,"inputQueue",void 0),(0,f.A)(this,"outputQueue",void 0),(0,f.A)(this,"sort",void 0),(0,f.A)(this,"keyframeRequire",void 0),this.options=t,this.inputQueue=[],this.outputQueue=[],this.sort=A.A.safari}async output(t){if(this.sort){let e=0;for(;et.timestamp){this.outputQueue.splice(e,0,t);break}for(e===this.outputQueue.length&&this.outputQueue.push(t);this.outputQueue.length>2&&this.outputQueue[0].timestamp===this.inputQueue[0];){const t=this.outputQueue.shift();this.options.onReceiveFrame?this.options.onReceiveFrame(t):t.close(),this.inputQueue.shift()}}else this.options.onReceiveFrame?this.options.onReceiveFrame(t):t.close()}error(t){this.currentError=t,this.options.onError(t)}changeExtraData(t){var e;if(t.length===this.extradata.length){let e=!0;for(let i=0;ii){this.inputQueue.splice(t,0,i);break}t===this.inputQueue.length&&this.inputQueue.push(i)}try{this.decoder.decode(s)}catch(t){return-1}return r&&(this.keyframeRequire=!1),0}async flush(){if(await this.decoder.flush(),this.sort)for(;this.outputQueue.length;){const t=this.outputQueue.shift();this.options.onReceiveFrame?this.options.onReceiveFrame(t):t.close()}this.keyframeRequire=!0}close(){var t;this.decoder&&"closed"!==this.decoder.state&&this.decoder.close(),this.decoder=null,this.currentError=null,null!==(t=this.outputQueue)&&void 0!==t&&t.length&&this.outputQueue.forEach((t=>{t.close()})),this.inputQueue=null,this.outputQueue=null}getQueueLength(){return this.decoder.decodeQueueSize}setSkipFrameDiscard(t){}}var _=i(6041),P=i(7672),T=i(2739),I=i(3724),C=i(4290),B=i(9638),S=i(4328),M=i(6932),R=i(5797),U="src/avpipeline/VideoDecodePipeline.ts";class E extends u.A{constructor(){super()}createWebcodecDecoder(t,e=!0){return new x({onError:e=>{if(t.hardwareRetryCount>3||!t.firstDecoded)t.targetDecoder=t.softwareDecoder,t.hardwareDecoder.close(),t.hardwareDecoder=null,t.decoderReady=this.openSoftwareDecoder(t),g.R8(`video decode error width hardware(${t.hardwareRetryCount}), taskId: ${t.taskId}, error: ${e}, try to fallback to software decoder`,U,116);else{t.hardwareRetryCount++;try{g.pq(`retry open hardware decoder(${t.hardwareRetryCount}), taskId: ${t.taskId}`,U,121),t.decoderReady=t.hardwareDecoder.open(t.parameters)}catch(e){g.R8(`retry open hardware decoder failed, fallback to software decoder, taskId: ${t.taskId}`,U,125)}}t.needKeyFrame=!0,t.leftIPCPort.request("requestKeyframe")},onReceiveFrame(e){t.firstDecoded=!0,t.frameCaches.push(e),n.M[17](t.stats+136,a.f[17](t.stats+136)+BigInt(1)),t.lastDecodeTimestamp&&n.M[15](t.stats+224,Math.max((0,M.A)()-t.lastDecodeTimestamp,a.f[15](t.stats+224))),t.lastDecodeTimestamp=(0,M.A)()},enableHardwareAcceleration:e})}createTask(t){const e=new l.Ay(t.leftPort),i=new l.Ay(t.rightPort),r=[],c=new _.A((0,h.A)(t.avframeList,o.A),t.avframeListMutex),u={...t,leftIPCPort:e,rightIPCPort:i,softwareDecoder:null,hardwareDecoder:null,frameCaches:r,inputEnd:!1,targetDecoder:null,needKeyFrame:!0,parameters:0,hardwareRetryCount:0,lastDecodeTimestamp:0,firstDecoded:!1,decoderReady:null,softwareDecoderOpened:!1,avframePool:c,avpacketPool:new C.A((0,h.A)(t.avpacketList,o.A),t.avpacketListMutex)};return u.softwareDecoder=t.resource?new v({resource:t.resource,onError:e=>{g.z3(`video decode error, taskId: ${t.taskId}, error: ${e}`,U,183);const i=this.tasks.get(t.taskId);i.openReject&&(i.openReject(e),i.openReject=null)},onReceiveFrame(t){u.firstDecoded=!0,r.push(t),n.M[17](u.stats+136,a.f[17](u.stats+136)+BigInt(1)),u.lastDecodeTimestamp&&n.M[15](u.stats+224,Math.max((0,M.A)()-u.lastDecodeTimestamp,a.f[15](u.stats+224))),u.lastDecodeTimestamp=(0,M.A)()},avframePool:c}):R.A.videoDecoder?this.createWebcodecDecoder(u,!1):null,u.softwareDecoder?(R.A.videoDecoder&&t.enableHardware&&(u.hardwareDecoder=this.createWebcodecDecoder(u)),u.targetDecoder=u.hardwareDecoder||u.softwareDecoder,this.tasks.set(t.taskId,u),i.on(l.S3,(async o=>{switch(o.method){case"pull":if(r.length){const t=r.shift();i.reply(o,t,null,P.ai(t)?null:[t]);break}if(!u.inputEnd){for(;;){if(r.length){const t=r.shift();i.reply(o,t,null,P.ai(t)?null:[t]);break}u.decoderReady&&(await u.decoderReady,u.decoderReady=null);const h=await e.request("pull");if(-1048576===h){if(u.targetDecoder===u.hardwareDecoder){let t=await s().race([new I.A(2),u.targetDecoder.flush()]);P.ai(t)&&g.R8(`video hardware decoder flush failed, ignore it, taskId: ${u.taskId}`,U,250)}else await u.targetDecoder.flush();if(u.inputEnd=!0,u.targetDecoder===u.hardwareDecoder&&await new I.A(0),r.length){const t=r.shift();i.reply(o,t,null,u.targetDecoder===u.hardwareDecoder?[t]:null);break}g.pq(`video decoder ended, taskId: ${u.taskId}`,U,267),i.reply(o,-1048576);break}if(!(h>0)){g.z3(`video decode pull avpacket error, taskId: ${t.taskId}, ret: ${h}`,U,326),i.reply(o,h);break}{if(u.needKeyFrame){if(!(1&a.f[15](h+36))){u.avpacketPool.release(h);continue}u.needKeyFrame=!1}let e=u.targetDecoder.decode(h);if(e<0){if(n.M[15](u.stats+128,a.f[15](u.stats+128)+1),u.targetDecoder===u.hardwareDecoder&&u.softwareDecoder){if(u.targetDecoder=u.softwareDecoder,u.hardwareDecoder.close(),u.hardwareDecoder=null,await this.openSoftwareDecoder(u),g.R8(`video decode error width hardware, taskId: ${u.taskId}, error: ${e}, try to fallback to software decoder`,U,296),!(1&a.f[15](h+36))){u.avpacketPool.release(h),u.needKeyFrame=!0,u.leftIPCPort.request("requestKeyframe");continue}if(e=u.targetDecoder.decode(h),e>=0){u.avpacketPool.release(h);continue}}u.avpacketPool.release(h),g.z3(`video decode error, taskId: ${t.taskId}, ret: ${e}`,U,312),i.reply(o,e);break}for(u.avpacketPool.release(h);u.targetDecoder===u.hardwareDecoder&&u.hardwareDecoder.getQueueLength()>20;)await new I.A(0)}}break}g.pq(`video decoder ended, taskId: ${u.taskId}`,U,333),i.reply(o,-1048576)}})),0):(g.z3("software decoder not support",U,207),d.lh)}async openSoftwareDecoder(t){if(t.softwareDecoder&&!t.softwareDecoderOpened){const e=t.parameters;let i=1;if((0,B.A)()){let t=a.f[15](e+48)*a.f[15](e+52),r=(0,S.lb)((0,h.A)(e+160,c.P));t>=2073600&&t<=2211840?(173!==a.f[15](e+4)&&226!==a.f[15](e+4)||(i=2),r>30?(i=2,173!==a.f[15](e+4)&&226!==a.f[15](e+4)||(i=4)):r>60&&(i=4,173!==a.f[15](e+4)&&226!==a.f[15](e+4)||(i=6))):t>2211840&&t<=8294400?(i=4,173!==a.f[15](e+4)&&226!==a.f[15](e+4)||(i=6)):t>8294400&&(i=6,173!==a.f[15](e+4)&&226!==a.f[15](e+4)||(i=8)),i=Math.min(i,navigator.hardwareConcurrency)}await t.softwareDecoder.open(e,i),t.softwareDecoderOpened=!0}}async open(t,e){const i=this.tasks.get(t);if(i)return new(s())((async(t,r)=>{if(i.openReject=r,i.hardwareDecoder)try{await i.hardwareDecoder.open(e)}catch(t){g.z3(`cannot open hardware decoder, ${t}`,U,407),i.hardwareDecoder.close(),i.hardwareDecoder=null,i.targetDecoder=i.softwareDecoder}i.parameters=e,i.targetDecoder===i.softwareDecoder&&await this.openSoftwareDecoder(i),t()}));g.h2("task not found",U,423)}async setPlayRate(t,e){const i=this.tasks.get(t);if(i&&i.softwareDecoder){let t=-16,r=(0,S.lb)((0,h.A)(i.parameters+160,c.P));t=r>=120?e<=1?-16:e<1.5||e<3?8:32:r>=60?e<1.5?-16:e<3?8:e<8?24:32:-16,i.softwareDecoder.setSkipFrameDiscard(t)}else g.h2("task not found",U,467)}async resetTask(t){const e=this.tasks.get(t);e&&(e.targetDecoder===e.softwareDecoder?await e.targetDecoder.flush():e.targetDecoder===e.hardwareDecoder&&(e.hardwareDecoder.close(),e.hardwareDecoder=this.createWebcodecDecoder(e),await e.hardwareDecoder.open(e.parameters),e.targetDecoder=e.hardwareDecoder),T.__(e.frameCaches,(t=>{P.ai(t)?e.avframePool.release(t):t.close()})),e.frameCaches.length=0,e.needKeyFrame=!0,e.inputEnd=!1,e.lastDecodeTimestamp=(0,M.A)(),g.pq(`reset video decoder, taskId: ${e.taskId}`,U,497))}async registerTask(t){return this.tasks.has(t.taskId)?d.lh:this.createTask(t)}async unregisterTask(t){const e=this.tasks.get(t);e&&(e.rightPort.close(),e.leftPort.close(),e.softwareDecoder&&e.softwareDecoder.close(),e.hardwareDecoder&&e.hardwareDecoder.close(),e.frameCaches.forEach((t=>{P.ai(t)?e.avframePool.release(t):t.close()})),this.tasks.delete(t))}async getTasksInfo(){const t=[];return this.tasks.forEach((e=>{t.push({codecId:a.f[15](e.parameters+4),width:a.f[15](e.parameters+48),height:a.f[15](e.parameters+52),framerate:(0,S.lb)((0,h.A)(e.parameters+160,c.P)),hardware:e.targetDecoder===e.hardwareDecoder})})),t}}},7303:(t,e,i)=>{"use strict";i.d(e,{A:()=>qt});var r=i(4001),s=i.n(r),a=i(2264),n=i(915),o=i(3939),h=i(932),c=i(4527),u=i(9705),d=i(4149),l=i(7672),f=i(2739),p=i(6041),m=i(5797),g=i(9148),v=i(6932),A=i(4328),y=i(7231),w=i(4214),b=i(4624),k=i(3607),x=i(1026);class _{constructor(t){(0,x.A)(this,"element",void 0),this.element=new Float32Array(3),t&&(this.element[0]=t[0],this.element[1]=t[1],this.element[2]=t[2])}normalize(){let t=this.x,e=this.y,i=this.z,r=this.magnitude;return r?(1===r||(r=1/r,this.x=t*r,this.y=e*r,this.z=i*r),this):(this.x=this.y=this.z=0,this)}toArray(){return[this.x,this.y,this.z]}get magnitude(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}get sqrMagnitude(){return this.x*this.x+this.y*this.y+this.z*this.z}get x(){return this.element[0]}set x(t){this.element[0]=t}get y(){return this.element[1]}set y(t){this.element[1]=t}get z(){return this.element[2]}set z(t){this.element[2]=t}}class P{constructor(t){(0,x.A)(this,"element",void 0),this.element=new Float32Array(4),t&&(this.element[0]=t[0],this.element[1]=t[1],this.element[2]=t[2],this.element[4]=t[3])}}var T="src/common/math/Matrix4.ts";let I;class C{static shared(){return I||(I=new C)}static RowMajor(t){return new C([t[0],t[4],t[8],t[12],t[1],t[5],t[9],t[13],t[2],t[6],t[10],t[14],t[3],t[7],t[11],t[15]])}static ColMajor(t){return new C(t)}constructor(t){(0,x.A)(this,"element",void 0),t?(this.element=new Float32Array(16),this.set(t)):this.element=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}rc(t,e){return this.getValue(4*e+t)}setRC(t,e,i){this.setValue(4*e+t,i)}getValue(t){if(t>=0&&t<=15)return this.element[t];b.z3("index out of Matrix4's rang [0 - 15]",T,58)}setValue(t,e){t>=0&&t<=15?this.element[t]=e:b.z3("index out of Matrix4's rang [0 - 15]",T,67)}setIdentity(){return this.element=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),this}set(t){return f.__(t,((t,e)=>{this.element[e]=t})),this}multiply(t){let e,i,r,s,a,n,o,h;if(s=i=this.element,r=t.element,s===r)for(r=new Float32Array(16),e=0;e<16;e++)r[e]=s[e];for(e=0;e<4;e++)a=i[e],n=i[e+4],o=i[e+8],h=i[e+12],s[e]=a*r[0]+n*r[1]+o*r[2]+h*r[3],s[e+4]=a*r[4]+n*r[5]+o*r[6]+h*r[7],s[e+8]=a*r[8]+n*r[9]+o*r[10]+h*r[11],s[e+12]=a*r[12]+n*r[13]+o*r[14]+h*r[15];return this}multiplyVector3(t){let e=this.element,i=t.element;return new _([i[0]*e[0]+i[1]*e[4]+i[2]*e[8]+e[12],i[0]*e[1]+i[1]*e[5]+i[2]*e[9]+e[13],i[0]*e[2]+i[1]*e[6]+i[2]*e[10]+e[14]])}multiplyVector4(t){let e=this.element,i=t.element;return new P([i[0]*e[0]+i[1]*e[4]+i[2]*e[8]+i[3]*e[12],i[0]*e[1]+i[1]*e[5]+i[2]*e[9]+i[3]*e[13],i[0]*e[2]+i[1]*e[6]+i[2]*e[10]+i[3]*e[14],i[0]*e[3]+i[1]*e[7]+i[2]*e[11]+i[3]*e[15]])}transpose(){let t,e;return t=this.element,e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setInverseOf(t){let e,i,r,s,a;if(i=t.element,r=this.element,s=new Float32Array(16),s[0]=i[5]*i[10]*i[15]-i[5]*i[11]*i[14]-i[9]*i[6]*i[15]+i[9]*i[7]*i[14]+i[13]*i[6]*i[11]-i[13]*i[7]*i[10],s[1]=-i[1]*i[10]*i[15]+i[1]*i[11]*i[14]+i[9]*i[2]*i[15]-i[9]*i[3]*i[14]-i[13]*i[2]*i[11]+i[13]*i[3]*i[10],s[2]=i[1]*i[6]*i[15]-i[1]*i[7]*i[14]-i[5]*i[2]*i[15]+i[5]*i[3]*i[14]+i[13]*i[2]*i[7]-i[13]*i[3]*i[6],s[3]=-i[1]*i[6]*i[11]+i[1]*i[7]*i[10]+i[5]*i[2]*i[11]-i[5]*i[3]*i[10]-i[9]*i[2]*i[7]+i[9]*i[3]*i[6],s[4]=-i[4]*i[10]*i[15]+i[4]*i[11]*i[14]+i[8]*i[6]*i[15]-i[8]*i[7]*i[14]-i[12]*i[6]*i[11]+i[12]*i[7]*i[10],s[5]=i[0]*i[10]*i[15]-i[0]*i[11]*i[14]-i[8]*i[2]*i[15]+i[8]*i[3]*i[14]+i[12]*i[2]*i[11]-i[12]*i[3]*i[10],s[6]=-i[0]*i[6]*i[15]+i[0]*i[7]*i[14]+i[4]*i[2]*i[15]-i[4]*i[3]*i[14]-i[12]*i[2]*i[7]+i[12]*i[3]*i[6],s[7]=i[0]*i[6]*i[11]-i[0]*i[7]*i[10]-i[4]*i[2]*i[11]+i[4]*i[3]*i[10]+i[8]*i[2]*i[7]-i[8]*i[3]*i[6],s[8]=i[4]*i[9]*i[15]-i[4]*i[11]*i[13]-i[8]*i[5]*i[15]+i[8]*i[7]*i[13]+i[12]*i[5]*i[11]-i[12]*i[7]*i[9],s[9]=-i[0]*i[9]*i[15]+i[0]*i[11]*i[13]+i[8]*i[1]*i[15]-i[8]*i[3]*i[13]-i[12]*i[1]*i[11]+i[12]*i[3]*i[9],s[10]=i[0]*i[5]*i[15]-i[0]*i[7]*i[13]-i[4]*i[1]*i[15]+i[4]*i[3]*i[13]+i[12]*i[1]*i[7]-i[12]*i[3]*i[5],s[11]=-i[0]*i[5]*i[11]+i[0]*i[7]*i[9]+i[4]*i[1]*i[11]-i[4]*i[3]*i[9]-i[8]*i[1]*i[7]+i[8]*i[3]*i[5],s[12]=-i[4]*i[9]*i[14]+i[4]*i[10]*i[13]+i[8]*i[5]*i[14]-i[8]*i[6]*i[13]-i[12]*i[5]*i[10]+i[12]*i[6]*i[9],s[13]=i[0]*i[9]*i[14]-i[0]*i[10]*i[13]-i[8]*i[1]*i[14]+i[8]*i[2]*i[13]+i[12]*i[1]*i[10]-i[12]*i[2]*i[9],s[14]=-i[0]*i[5]*i[14]+i[0]*i[6]*i[13]+i[4]*i[1]*i[14]-i[4]*i[2]*i[13]-i[12]*i[1]*i[6]+i[12]*i[2]*i[5],s[15]=i[0]*i[5]*i[10]-i[0]*i[6]*i[9]-i[4]*i[1]*i[10]+i[4]*i[2]*i[9]+i[8]*i[1]*i[6]-i[8]*i[2]*i[5],a=i[0]*s[0]+i[1]*s[4]+i[2]*s[8]+i[3]*s[12],0===a)return this;for(a=1/a,e=0;e<16;e++)r[e]=s[e]*a;return this}invert(){return this.setInverseOf(this),this}setOrtho(t,e,i,r,s,a){let n,o,h;return t!==e&&i!==r&&s!==a||b.h2("null frustum",T,240),n=1/(e-t),o=1/(r-i),h=1/(a-s),this.set([2*n,0,0,0,0,2*o,0,0,0,0,-2*h,0,-(e+t)*n,-(r+i)*o,-(a+s)*h,1]),this}ortho(t,e,i,r,s,a){return this.multiply((new C).setOrtho(t,e,i,r,s,a))}setFrustum(t,e,i,r,s,a){let n,o,h;return t!==e&&i!==r&&s!==a||b.z3("null frustum",T,281),s<=0&&b.h2("near <= 0",T,284),a<=0&&b.h2("far <= 0",T,287),n=1/(e-t),o=1/(r-i),h=1/(a-s),this.set([2*s*n,0,0,0,0,2*s*o,0,0,(e+t)*n,(r+i)*o,-(a+s)*h,-1,0,0,-2*s*a*h,0]),this}frustum(t,e,i,r,s,a){return this.multiply((new C).setOrtho(t,e,i,r,s,a))}setPerspective(t,e,i,r){let s,a,n;return i!==r&&0!==e||b.h2("null frustum",T,328),i<=0&&b.h2("near <= 0",T,331),r<=0&&b.h2("far <= 0",T,334),t=Math.PI*t/180/2,a=Math.sin(t),0===a&&b.h2("null frustum",T,342),s=1/(r-i),n=Math.cos(t)/a,this.set([n/e,0,0,0,0,n,0,0,0,0,-(r+i)*s,-1,0,0,-2*i*r*s,0]),this}perspective(t,e,i,r){return this.multiply((new C).setPerspective(t,e,i,r))}setScale(t){return this.set([t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1]),this}scale(t){let e=this.element;return e[0]*=t.x,e[1]*=t.x,e[2]*=t.x,e[3]*=t.x,e[4]*=t.y,e[5]*=t.y,e[6]*=t.y,e[7]*=t.y,e[8]*=t.z,e[9]*=t.z,e[10]*=t.z,e[11]*=t.z,this}setTranslate(t){return this.set([1,0,0,0,0,1,0,0,0,0,1,0,t.x,t.y,t.z,1]),this}preTranslate(t){let e=this.element;return e[12]+=e[0]*t.x+e[4]*t.y+e[8]*t.z,e[13]+=e[1]*t.x+e[5]*t.y+e[9]*t.z,e[14]+=e[2]*t.x+e[6]*t.y+e[10]*t.z,e[15]+=e[3]*t.x+e[7]*t.y+e[11]*t.z,this}postTranslate(t){let e=this.element;return e[0]+=t.x*e[3],e[1]+=t.y*e[3],e[2]+=t.z*e[3],e[4]+=t.x*e[7],e[5]+=t.y*e[7],e[6]+=t.z*e[7],e[8]+=t.x*e[11],e[9]+=t.y*e[11],e[10]+=t.z*e[11],e[12]+=t.x*e[15],e[13]+=t.y*e[15],e[14]+=t.z*e[15],this}setRotate(t,e){let i,r,s,a,n,o,h,c,u,d,l,f,p,m;return t=Math.PI*t/180,i=e.x,r=e.y,s=e.z,a=Math.sin(t),n=Math.cos(t),0!==e.x&&0===e.y&&0===e.z?(e.x<0&&(a=-a),this.set([1,0,0,0,0,n,-a,0,0,a,n,0,0,0,0,1])):0===e.x&&0!==e.y&&0===e.z?(e.y<0&&(a=-a),this.set([n,0,a,0,0,1,0,0,-a,0,n,0,0,0,0,1])):0===e.x&&0===e.y&&0!==e.z?(e.z<0&&(a=-a),this.set([n,-a,0,0,a,n,0,0,0,0,1,0,0,0,0,1])):(o=e.magnitude,1!==o&&(h=1/o,i*=h,r*=h,s*=h),c=1-n,u=i*r,d=r*s,l=s*i,f=i*a,p=r*a,m=s*a,this.set([i*i*c+n,u*c+m,l*c-p,0,u*c-m,r*r*c+n,d*c+f,0,l*c+p,d*c-f,s*s*c+n,0,0,0,0,1])),this}rotate(t,e){return this.multiply((new C).setRotate(t,e)),this}setLookAt(t,e,i){let r,s,a,n,o,h,c,u,d,l,f;return r=e.x-t.x,s=e.y-t.y,a=e.z-t.z,n=1/Math.sqrt(r*r+s*s+a*a),r*=n,s*=n,a*=n,o=s*i.z-a*i.y,h=a*i.x-r*i.z,c=r*i.y-s*i.x,u=1/Math.sqrt(o*o+h*h+c*c),o*=u,h*=u,c*=u,d=h*a-c*s,l=c*r-o*a,f=o*s-h*r,this.set([o,d,-r,0,h,l,-s,0,c,f,-a,0,0,0,0,1]),this.preTranslate(new _([-t.x,-t.y,-t.z]))}lookAt(t,e,i){return this.multiply((new C).setLookAt(t,e,i))}toArray(){let t=[];for(let e=0;e<16;e++)t[e]=this.element[e];return t}copy(){return(new C).set(this.toArray())}}const B={g:2.2,a:1,b:0,c:0,d:0,e:0,f:0},S={g:2.8,a:1,b:0,c:0,d:0,e:0,f:0},M={g:2.222222222222,a:.899626676224,b:.100373323776,c:.25,d:.091286342118,e:0,f:0},R={g:1,a:1,b:0,c:0,d:0,e:0,f:0},U={g:2.4,a:.9478672985781991,b:.05213270142180095,c:.07739938080495357,d:.04045,e:0,f:0},E={g:2.6,a:1.034080527699,b:0,c:0,d:0,e:0,f:0};var D="src/common/math/Matrix3.ts";class L{static RowMajor(t){return new L([t[0],t[3],t[6],t[1],t[4],t[7],t[2],t[5],t[8]])}static ColMajor(t){return new L(t)}constructor(t){(0,x.A)(this,"element",void 0),t?(this.element=new Float32Array(9),this.set(t)):this.element=new Float32Array([1,0,0,0,1,0,0,0,1])}rc(t,e){return this.getValue(3*e+t)}setRC(t,e,i){this.setValue(3*e+t,i)}getValue(t){if(t>=0&&t<9)return this.element[t];b.z3("index out of Matrix4's rang [0 - 9]",D,47)}setValue(t,e){t>=0&&t<9?this.element[t]=e:b.z3("index out of Matrix4's rang [0 - 9]",D,56)}setIdentity(){return this.element=new Float32Array([1,0,0,0,1,0,0,0,1]),this}set(t){return f.__(t,((t,e)=>{this.element[e]=t})),this}invert(){const t=this.element,e=t[0],i=t[1],r=t[2],s=t[3],a=t[4],n=t[5],o=t[6],h=t[7],c=t[8],u=c*a-n*h,d=n*o-c*s,l=h*s-a*o,f=e*u+i*d+r*l;if(0===f)return this.set([0,0,0,0,0,0,0,0,0]);const p=1/f;return t[0]=u*p,t[1]=(r*h-c*i)*p,t[2]=(n*i-r*a)*p,t[3]=d*p,t[4]=(c*e-r*o)*p,t[5]=(r*s-n*e)*p,t[6]=l*p,t[7]=(i*o-h*e)*p,t[8]=(a*e-i*s)*p,this}toArray(){let t=[];for(let e=0;e<9;e++)t[e]=this.element[e];return t}copy(){return(new L).set(this.toArray())}}function F(t,e){const i=new L([0,0,0,0,0,0,0,0,0]);for(let r=0;r<3;r++)for(let s=0;s<3;s++){let a=t.rc(r,0)*e.rc(0,s)+t.rc(r,1)*e.rc(1,s)+t.rc(r,2)*e.rc(2,s);i.setRC(r,s,a)}return i}function z(t,e){const i=new _([0,0,0]);for(let r=0;r<3;r++)i.element[r]=t.rc(r,0)*e.x+t.rc(r,1)*e.y+t.rc(r,2)*e.z;return i}const O=[.64,.33,.3,.6,.15,.06,.3127,.329],V=[.67,.33,.21,.71,.14,.08,.31,.316],N=[.64,.33,.29,.6,.15,.06,.3127,.329],$=[.63,.34,.31,.595,.155,.07,.3127,.329],W=[.681,.319,.243,.692,.145,.049,.31,.316],G=[.708,.292,.17,.797,.131,.046,.3127,.329],q=[1,0,0,1,0,0,.3333333333333333,.3333333333333333],j=[.68,.32,.265,.69,.15,.06,.314,.351],H=[.68,.32,.265,.69,.15,.06,.3127,.329],Q=[0,0,0,0,0,0,0,0];class Y{constructor(t,e,i,r){(0,x.A)(this,"matrixId",void 0),(0,x.A)(this,"primaryId",void 0),(0,x.A)(this,"transferId",void 0),(0,x.A)(this,"rangeId",void 0),this.matrixId=t,this.primaryId=e,this.transferId=i,this.rangeId=r}getMatrixId(){return this.matrixId}getPrimaryId(){return this.primaryId}getTransferId(){return this.transferId}getRangeId(){return this.rangeId}isWide(){return 9===this.primaryId||11===this.primaryId||12===this.primaryId}isHDR(){return 18===this.transferId||16===this.transferId}isToneMappedByDefault(){return 18===this.transferId||16===this.transferId}isAffectedBySDRWhiteLevel(){return 18===this.transferId||16===this.transferId}fullRangeEncodedValues(){return 12===this.transferId||11===this.transferId}getTransferMatrix(t){const e=(1<0&&e.g>0){const i=Math.pow(e.a,e.g);t.a=1/i,t.b=-e.e/i,t.g=1/e.g}return t.d=e.c*e.d+e.f,t.e=-e.b/e.a,0!=e.c&&(t.c=1/e.c,t.f=-e.f/e.c),t}}hasExtendedSkTransferFn(){return 0===this.matrixId}isValid(){return 2!==this.matrixId&&2!==this.primaryId&&2!==this.transferId&&0!==this.rangeId}getColorSpacePrimaries(){const t=Q;switch(this.primaryId){case 1:return O;case 4:return V;case 5:return N;case 7:return $;case 8:return W;case 9:return G;case 10:return q;case 11:return j;case 12:return H}return t}getPrimaryMatrix(){const t=function(t){const e=L.RowMajor([t[0],t[2],t[4],t[1],t[3],t[5],1-t[0]-t[1],1-t[2]-t[3],1-t[4]-t[5]]),i=z(e.copy().invert(),new _([t[6]/t[7],1,(1-t[6]-t[7])/t[7]]));let r=new L([i.x,0,0,0,i.y,0,0,0,i.z]);r=F(e,r);const s=function(t,e){const i=new _([t/e,1,(1-t-e)/e]),r=new _([.96422,1,.82521]),s=L.RowMajor([.8951,.2664,-.1614,-.7502,1.7135,.0367,.0389,-.0685,1.0296]),a=L.RowMajor([.9869929,-.1470543,.1599627,.4323053,.5183603,.0492912,-.0085287,.0400428,.9684867]),n=z(s,i),o=z(s,r);let h=new L([o.x/n.x,0,0,0,o.y/n.y,0,0,0,o.z/n.z]);return h=F(h,s),h=F(a,h),h}(t[6],t[7]);return F(s,r)}(this.getColorSpacePrimaries());return C.RowMajor([t.rc(0,0),t.rc(0,1),t.rc(0,2),0,t.rc(1,0),t.rc(1,1),t.rc(1,2),0,t.rc(2,0),t.rc(2,1),t.rc(2,2),0,0,0,0,1])}}class K{constructor(t,e){(0,x.A)(this,"canvas",void 0),(0,x.A)(this,"options",void 0),(0,x.A)(this,"textureWidth",void 0),(0,x.A)(this,"videoWidth",void 0),(0,x.A)(this,"videoHeight",void 0),(0,x.A)(this,"canvasWidth",void 0),(0,x.A)(this,"canvasHeight",void 0),(0,x.A)(this,"rotate",void 0),(0,x.A)(this,"renderMode",void 0),(0,x.A)(this,"format",void 0),(0,x.A)(this,"lost",void 0),(0,x.A)(this,"destroyed",void 0),(0,x.A)(this,"srcColorSpace",void 0),(0,x.A)(this,"dstColorSpace",void 0),(0,x.A)(this,"flipHorizontal",void 0),(0,x.A)(this,"flipVertical",void 0),this.canvas=t,this.options=e,this.canvasWidth=t.width,this.canvasHeight=t.height,this.videoWidth=0,this.videoHeight=0,this.textureWidth=0,this.rotate=0,this.renderMode=e.renderMode,this.flipHorizontal=!1,this.flipVertical=!1,this.lost=!1,this.destroyed=!1,e.dstColorSpace?this.dstColorSpace=e.dstColorSpace:this.dstColorSpace=new Y(1,1,1,1)}getRotateMatrix(t){t=Math.PI*t/180;const e=Math.sin(t),i=Math.cos(t);return[i,-e,0,0,e,i,0,0,0,0,1,0,0,0,0,1]}setRenderMode(t){this.renderMode!==t&&(this.renderMode=t,this.layout(),this.clear())}enableHorizontalFlip(t){this.flipHorizontal!==t&&(this.flipHorizontal=t,this.layout(),this.clear())}enableVerticalFlip(t){this.flipVertical!==t&&(this.flipVertical=t,this.layout(),this.clear())}viewport(t,e){const i=this.options.devicePixelRatio;this.canvasWidth=t,this.canvasHeight=e,this.canvas.width=t*i,this.canvas.height=e*i,this.videoWidth&&this.videoHeight&&this.layout()}getVideoWidth(){return this.videoWidth}getVideoHeight(){return this.videoHeight}destroy(){this.canvas=null,this.destroyed=!0}setDstColorSpace(t){this.dstColorSpace=t}static isSupport(t){return!1}}class J extends K{constructor(t,e){super(t,e),(0,x.A)(this,"context",void 0),(0,x.A)(this,"paddingLeft",void 0),(0,x.A)(this,"paddingTop",void 0),this.paddingLeft=0,this.paddingTop=0}async init(){this.context=this.canvas.getContext("2d")}clear(){const t=this.canvas.width>>1,e=this.canvas.height>>1;this.rotate&&(this.context.translate(t,e),this.context.rotate(-this.rotate*Math.PI/180),this.context.translate(-t,-e)),this.context.clearRect(0,0,this.canvasWidth*this.options.devicePixelRatio,this.canvasHeight*this.options.devicePixelRatio),this.rotate&&(this.context.translate(t,e),this.context.rotate(this.rotate*Math.PI/180),this.context.translate(-t,-e))}checkFrame(t){t.codedWidth===this.textureWidth&&t.codedHeight===this.videoHeight&&t.codedWidth===this.videoWidth||(this.videoWidth=t.codedWidth,this.videoHeight=t.codedHeight,this.textureWidth=t.codedWidth,this.layout())}render(t){this.lost||(this.checkFrame(t),this.context.drawImage(t,this.paddingLeft,this.paddingTop,this.canvasWidth*this.options.devicePixelRatio-2*this.paddingLeft,this.canvasHeight*this.options.devicePixelRatio-2*this.paddingTop))}layout(){let t=this.videoWidth,e=this.videoHeight,i=this.canvasWidth,r=this.canvasHeight,s=0,a=0;90!==this.rotate&&270!==this.rotate||(a=Math.floor((r-i)/2),s=Math.floor((i-r)/2),i=this.canvasHeight,r=this.canvasWidth);const n=t/i,o=e/r;let h;if(h=n>1?!(no,1===this.renderMode&&(h=!h),h){const n=(r-e*i/t)/r;this.paddingTop=(Math.floor(n/2*r)+a)*this.options.devicePixelRatio,this.paddingLeft=s*this.options.devicePixelRatio}else{const n=(i-t*r/e)/i;this.paddingLeft=(Math.floor(n/2*i)+s)*this.options.devicePixelRatio,this.paddingTop=a*this.options.devicePixelRatio}if(this.context){let t=1,e=1;this.flipHorizontal&&(t=-1),this.flipVertical&&(e=-1),this.context.scale(t,e)}}setRotate(t){if((t%=360)===this.rotate)return;const e=this.canvas.width>>1,i=this.canvas.height>>1;this.rotate&&(this.context.translate(e,i),this.context.rotate(-this.rotate*Math.PI/180),this.context.translate(-e,-i)),this.clear(),this.rotate=t,this.context&&(this.context.translate(e,i),this.context.rotate(this.rotate*Math.PI/180),this.context.translate(-e,-i)),this.layout()}destroy(){this.context=null,super.destroy()}static isSupport(t){return t instanceof VideoFrame||t instanceof ImageBitmap}}const X="struct PositionColorInput {\n @location(0) in_position_3d: vec3,\n @location(1) in_color_rgba: vec4\n};\n\nstruct PositionColorOutput {\n @builtin(position) coords_output: vec4,\n @location(0) color_output: vec4\n};\n\nstruct RotateMatrix {\n matrix: mat4x4\n};\n\n@group(0) @binding(0) var rotateMatrix: RotateMatrix;\n\n@vertex\nfn main(input: PositionColorInput) -> PositionColorOutput {\n var output: PositionColorOutput;\n output.color_output = input.in_color_rgba;\n output.coords_output = rotateMatrix.matrix * vec4(input.in_position_3d, 1.0);\n return output;\n}";function Z(t,e,i){if(e){let e=t[3],i=t[4];t[3]=t[17],t[4]=t[18],t[17]=e,t[18]=i,e=t[10],i=t[11],t[10]=t[24],t[11]=t[25],t[24]=e,t[25]=i}if(i){let e=t[3],i=t[4];t[3]=t[10],t[4]=t[11],t[10]=e,t[11]=i,e=t[17],i=t[18],t[17]=t[24],t[18]=t[25],t[24]=e,t[25]=i}}var tt="src/avrender/image/WebGPURender.ts";class et extends K{constructor(t,e){super(t,e),(0,x.A)(this,"adapter",void 0),(0,x.A)(this,"device",void 0),(0,x.A)(this,"context",void 0),(0,x.A)(this,"vsModule",void 0),(0,x.A)(this,"fsModule",void 0),(0,x.A)(this,"rotateMatrixBuffer",void 0),(0,x.A)(this,"renderPipeline",void 0),(0,x.A)(this,"rotateMatrix",void 0),(0,x.A)(this,"vbo",void 0),(0,x.A)(this,"sampler",void 0),(0,x.A)(this,"vertex",void 0),(0,x.A)(this,"fragmentSource",void 0),(0,x.A)(this,"vertexSource",void 0),(0,x.A)(this,"renderBundleEncoder",void 0),(0,x.A)(this,"renderBundle",void 0),(0,x.A)(this,"bindGroupLayout",void 0),(0,x.A)(this,"bindGroup",void 0),(0,x.A)(this,"pipelineLayout",void 0)}async init(t){var e;this.adapter=await navigator.gpu.requestAdapter({powerPreference:null!==(e=this.options.powerPreference)&&void 0!==e?e:"high-performance"});const i=[];f.__(t,(t=>{this.adapter.features.has(t)&&i.push(t)})),this.device=await this.adapter.requestDevice({requiredFeatures:i.length?i:void 0}),this.device.lost.then((()=>{var t;this.destroyed||(this.lost=!0,b.z3("gpu device lost",tt,101),null!==(t=this.options)&&void 0!==t&&t.onRenderContextLost&&this.options.onRenderContextLost())})),this.context=this.canvas.getContext("webgpu"),this.context||b.h2("can not support webgpu, got GPUCanvasContext failed",tt,110),this.context.configure({device:this.device,format:navigator.gpu.getPreferredCanvasFormat(),alphaMode:"premultiplied"}),this.sampler=this.device.createSampler({magFilter:"linear",minFilter:"linear"}),this.vbo=this.device.createBuffer({size:28*Float32Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_DST}),this.rotateMatrixBuffer=this.device.createBuffer({size:16*Float32Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.setRotateMatrix(this.getRotateMatrix(0))}generatePipeline(){this.generateBindGroup(),this.pipelineLayout=this.device.createPipelineLayout({bindGroupLayouts:[this.bindGroupLayout]}),this.vsModule=this.device.createShaderModule({code:this.vertexSource}),this.fsModule=this.device.createShaderModule({code:this.fragmentSource}),this.renderPipeline=this.device.createRenderPipeline({layout:this.pipelineLayout,vertex:{module:this.vsModule,entryPoint:"main",buffers:[{arrayStride:28,attributes:[{shaderLocation:0,offset:0,format:"float32x3"},{shaderLocation:1,offset:12,format:"float32x4"}]}]},fragment:{module:this.fsModule,entryPoint:"main",targets:[{format:navigator.gpu.getPreferredCanvasFormat()}]},primitive:{topology:"triangle-strip"}})}generateRenderBundleEncoder(){this.renderPipeline&&(this.renderBundleEncoder=this.device.createRenderBundleEncoder({colorFormats:[navigator.gpu.getPreferredCanvasFormat()]}),this.renderBundleEncoder.setPipeline(this.renderPipeline),this.renderBundleEncoder.setBindGroup(0,this.bindGroup),this.renderBundleEncoder.setVertexBuffer(0,this.vbo),this.renderBundleEncoder.draw(4,4,0,0),this.renderBundle=this.renderBundleEncoder.finish())}setRotateMatrix(t){this.rotateMatrix=t;const e=new Float32Array(this.rotateMatrix);this.device.queue.writeBuffer(this.rotateMatrixBuffer,0,e.buffer,e.byteOffset,e.byteLength)}setVertices(){const t=new Float32Array(this.vertex);this.device.queue.writeBuffer(this.vbo,0,t.buffer,t.byteOffset,t.byteLength)}clear(){this.context.getCurrentTexture().destroy()}layout(){let t=this.videoWidth,e=this.videoHeight,i=this.canvasWidth,r=this.canvasHeight;90!==this.rotate&&270!==this.rotate||(i=this.canvasHeight,r=this.canvasWidth);const s=t/i,a=e/r;let n;n=s>1?!(sa,1===this.renderMode&&(n=!n);let o=0;if(this.textureWidth!==this.videoWidth&&(o=(this.textureWidth-this.videoWidth)/this.textureWidth),n){const s=(r-e*i/t)/r;this.vertex=[-1,1-s,0,0,0,0,0,-1,-1+s,0,0,1,0,0,1,1-s,0,1-o,0,0,0,1,-1+s,0,1-o,1,0,0]}else{const s=(i-t*r/e)/i;this.vertex=[-1+s,1,0,0,0,0,0,-1+s,-1,0,0,1,0,0,1-s,1,0,1-o,0,0,0,1-s,-1,0,1-o,1,0,0]}Z(this.vertex,this.flipHorizontal,this.flipVertical),this.setVertices()}viewport(t,e){super.viewport(t,e)}setRotate(t){(t%=360)!==this.rotate&&(this.rotate=t,this.setRotateMatrix(this.getRotateMatrix(t)),this.layout(),this.clear())}destroy(){this.sampler=null,this.vbo&&this.vbo.destroy(),this.rotateMatrixBuffer&&this.rotateMatrixBuffer.destroy(),this.bindGroupLayout=null,this.bindGroup=null,this.pipelineLayout=null,this.renderBundle=null,this.renderBundleEncoder=null,this.fsModule=null,this.vsModule=null,this.renderPipeline=null,this.rotateMatrix=null,this.vertex=null,this.context=null,this.options=null,this.destroyed=!0,this.device&&(this.device.destroy(),this.device=null),this.adapter&&(this.adapter=null),super.destroy()}}class it extends et{constructor(t,e){super(t,e),this.vertexSource=X,this.fragmentSource="\n@group(0) @binding(1) var eTexture: texture_external;\n@group(0) @binding(2) var s: sampler;\n\n@fragment\nfn main(@location(0) in_texcoord: vec4) -> @location(0) vec4 {\n return textureSampleBaseClampToEdge(eTexture, s, in_texcoord.xy);\n}"}checkFrame(t){t.codedWidth===this.textureWidth&&t.codedHeight===this.videoHeight&&t.codedWidth===this.videoWidth||(this.videoWidth=t.codedWidth,this.videoHeight=t.codedHeight,this.textureWidth=t.codedWidth,this.layout(),this.generatePipeline())}generateBindGroup(){this.bindGroupLayout=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,externalTexture:{}},{binding:2,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]})}render(t){if(this.lost)return;this.checkFrame(t);const e=this.device.createBindGroup({layout:this.renderPipeline.getBindGroupLayout(0),entries:[{binding:0,resource:{buffer:this.rotateMatrixBuffer,size:16*Float32Array.BYTES_PER_ELEMENT}},{binding:1,resource:this.device.importExternalTexture({source:t})},{binding:2,resource:this.sampler}]}),i=this.device.createCommandEncoder(),r={colorAttachments:[{view:this.context.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]},s=i.beginRenderPass(r);s.setPipeline(this.renderPipeline),s.setBindGroup(0,e),s.setVertexBuffer(0,this.vbo),s.draw(4,4,0,0),s.end(),this.device.queue.submit([i.finish()])}destroy(){super.destroy()}static isSupport(t){return t instanceof VideoFrame}}var rt=i(4686);const st={0:{depth:8,max:255,nbComponents:3,log2ChromaW:1,log2ChromaH:1,flags:2},12:{depth:8,max:255,nbComponents:3,log2ChromaW:1,log2ChromaH:1,flags:2},4:{depth:8,max:255,nbComponents:3,log2ChromaW:1,log2ChromaH:0,flags:2},13:{depth:8,max:255,nbComponents:3,log2ChromaW:1,log2ChromaH:0,flags:2},5:{depth:8,max:255,nbComponents:3,log2ChromaW:0,log2ChromaH:0,flags:2},14:{depth:8,max:255,nbComponents:3,log2ChromaW:0,log2ChromaH:0,flags:2},59:{depth:9,max:511,nbComponents:3,log2ChromaW:1,log2ChromaH:1,flags:3},60:{depth:9,max:511,nbComponents:3,log2ChromaW:1,log2ChromaH:1,flags:2},61:{depth:10,max:1023,nbComponents:3,log2ChromaW:1,log2ChromaH:1,flags:3},62:{depth:10,max:1023,nbComponents:3,log2ChromaW:1,log2ChromaH:1,flags:2},122:{depth:12,max:4095,nbComponents:3,log2ChromaW:1,log2ChromaH:1,flags:3},123:{depth:12,max:4095,nbComponents:3,log2ChromaW:1,log2ChromaH:1,flags:2},124:{depth:14,max:16383,nbComponents:3,log2ChromaW:1,log2ChromaH:1,flags:3},125:{depth:14,max:16383,nbComponents:3,log2ChromaW:1,log2ChromaH:1,flags:2},46:{depth:16,max:65535,nbComponents:3,log2ChromaW:1,log2ChromaH:1,flags:3},45:{depth:16,max:65535,nbComponents:3,log2ChromaW:1,log2ChromaH:1,flags:2},69:{depth:9,max:511,nbComponents:3,log2ChromaW:1,log2ChromaH:0,flags:3},70:{depth:9,max:511,nbComponents:3,log2ChromaW:1,log2ChromaH:0,flags:2},63:{depth:10,max:1023,nbComponents:3,log2ChromaW:1,log2ChromaH:0,flags:3},64:{depth:10,max:1023,nbComponents:3,log2ChromaW:1,log2ChromaH:0,flags:2},126:{depth:12,max:4095,nbComponents:3,log2ChromaW:1,log2ChromaH:0,flags:3},127:{depth:12,max:4095,nbComponents:3,log2ChromaW:1,log2ChromaH:0,flags:2},128:{depth:14,max:16383,nbComponents:3,log2ChromaW:1,log2ChromaH:0,flags:3},129:{depth:14,max:16383,nbComponents:3,log2ChromaW:1,log2ChromaH:0,flags:2},48:{depth:16,max:65535,nbComponents:3,log2ChromaW:1,log2ChromaH:0,flags:3},47:{depth:16,max:65535,nbComponents:3,log2ChromaW:1,log2ChromaH:0,flags:2},65:{depth:9,max:511,nbComponents:3,log2ChromaW:0,log2ChromaH:0,flags:3},66:{depth:9,max:511,nbComponents:3,log2ChromaW:0,log2ChromaH:0,flags:2},67:{depth:10,max:1023,nbComponents:3,log2ChromaW:0,log2ChromaH:0,flags:3},68:{depth:10,max:1023,nbComponents:3,log2ChromaW:0,log2ChromaH:0,flags:2},130:{depth:12,max:4095,nbComponents:3,log2ChromaW:0,log2ChromaH:0,flags:3},131:{depth:12,max:4095,nbComponents:3,log2ChromaW:0,log2ChromaH:0,flags:2},132:{depth:14,max:16383,nbComponents:3,log2ChromaW:0,log2ChromaH:0,flags:3},133:{depth:14,max:16383,nbComponents:3,log2ChromaW:0,log2ChromaH:0,flags:2},50:{depth:16,max:65535,nbComponents:3,log2ChromaW:0,log2ChromaH:0,flags:3},49:{depth:16,max:65535,nbComponents:3,log2ChromaW:0,log2ChromaH:0,flags:2}};class at{constructor(t,e,i){(0,x.A)(this,"gl",void 0),(0,x.A)(this,"width",void 0),(0,x.A)(this,"height",void 0),(0,x.A)(this,"texture",void 0),this.gl=t,this.width=e,this.height=i,this.texture=this.gl.createTexture()}getTexture(){return this.texture}bind(t){l.ai(t)&&this.gl.activeTexture(this.gl.TEXTURE0+t),this.gl.bindTexture(this.gl.TEXTURE_2D,this.texture)}setSize(t,e){this.width=t,this.height=e}setUnpackAlignment(){this.width%8==0?this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,8):this.width%4==0?this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,4):this.width%2==0?this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,2):this.gl.pixelStorei(this.gl.UNPACK_ALIGNMENT,1)}destroy(){this.texture&&(this.gl.deleteTexture(this.texture),this.texture=null)}}class nt extends at{constructor(t,e,i,r){super(t,i,r),(0,x.A)(this,"data",void 0),(0,x.A)(this,"filter",void 0),(0,x.A)(this,"format",void 0),(0,x.A)(this,"internalformat",void 0),(0,x.A)(this,"dataType",void 0),this.data=e,this.format=this.gl.LUMINANCE,this.filter=this.gl.LINEAR,this.internalformat=this.gl.LUMINANCE,this.dataType=this.gl.UNSIGNED_BYTE}init(){this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.filter),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.filter),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE)}setFormat(t){this.format=t}setInternalformat(t){this.internalformat=t}setDataType(t){this.dataType=t}setFilter(t){this.filter=t}fill(t){this.gl.bindTexture(this.gl.TEXTURE_2D,this.texture),this.setUnpackAlignment(),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.internalformat,this.width,this.height,0,this.format,this.dataType,t)}}var ot="src/avrender/image/WebGLRender.ts";class ht extends K{constructor(t,e){super(t,e),(0,x.A)(this,"gl",void 0),(0,x.A)(this,"VAO",void 0),(0,x.A)(this,"program",void 0),(0,x.A)(this,"vertex",void 0),(0,x.A)(this,"webglContextLostTimer",void 0),(0,x.A)(this,"onWebglContextLost",void 0),(0,x.A)(this,"onWebglContextRestored",void 0),(0,x.A)(this,"fragmentSource",void 0),(0,x.A)(this,"vertexSource",void 0)}async init(){this.gl=this.canvas.getContext("webgl2",{alpha:!1,antialias:!1,preserveDrawingBuffer:this.options.preserveDrawingBuffer}),this.gl||(this.gl=this.canvas.getContext("webgl",{alpha:!1,antialias:!1,preserveDrawingBuffer:this.options.preserveDrawingBuffer})),this.gl||(this.gl=this.canvas.getContext("experimental-webgl",{alpha:!1,antialias:!1,preserveDrawingBuffer:this.options.preserveDrawingBuffer})),this.gl||b.h2("can not support webgl, got WebGLRenderingContext failed",ot,96),this.VAO=this.gl.createBuffer(),this.VAO||b.h2("create vao buffer failed",ot,101),this.gl.bindBuffer(this.gl.ARRAY_BUFFER,this.VAO),this.gl.enable(this.gl.BLEND),this.gl.clearColor(0,0,0,0),this.gl.clearDepth(1),this.viewport(this.canvasWidth||this.canvas.width,this.canvasHeight||this.canvas.height),this.onWebglContextLost=t=>{this.destroyed||(this.webglContextLostTimer=setTimeout((()=>{this.lost=!0,this.webglContextLostTimer=null,b.z3("webgl context lost",ot,118),this.options.onRenderContextLost&&this.options.onRenderContextLost()}),3e3))},this.onWebglContextRestored=t=>{this.webglContextLostTimer&&(clearTimeout(this.webglContextLostTimer),this.webglContextLostTimer=null)},this.canvas.addEventListener("webglcontextlost",this.onWebglContextLost),this.canvas.addEventListener("webglcontextrestored",this.onWebglContextRestored)}viewport(t,e){this.gl.viewport(0,0,t*this.options.devicePixelRatio,e*this.options.devicePixelRatio),super.viewport(t,e)}useProgram(){this.program.link(this.gl),this.program.bind(),this.program.setRotateMatrix(this.getRotateMatrix(this.rotate))}clear(){this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT)}layout(){let t=this.videoWidth,e=this.videoHeight,i=this.canvasWidth,r=this.canvasHeight;90!==this.rotate&&270!==this.rotate||(i=this.canvasHeight,r=this.canvasWidth);const s=t/i,a=e/r;let n;n=s>1?!(sa,1===this.renderMode&&(n=!n);let o=0;if(this.textureWidth!==this.videoWidth&&(o=(this.textureWidth-this.videoWidth)/this.textureWidth),n){const s=(r-e*i/t)/r;this.vertex=[-1,1-s,0,0,0,0,0,-1,-1+s,0,0,1,0,0,1,1-s,0,1-o,0,0,0,1,-1+s,0,1-o,1,0,0]}else{const s=(i-t*r/e)/i;this.vertex=[-1+s,1,0,0,0,0,0,-1+s,-1,0,0,1,0,0,1-s,1,0,1-o,0,0,0,1-s,-1,0,1-o,1,0,0]}Z(this.vertex,this.flipHorizontal,this.flipVertical),this.gl&&this.gl.bufferData(this.gl.ARRAY_BUFFER,new Float32Array(this.vertex),this.gl.STATIC_DRAW)}setRotate(t){(t%=360)!==this.rotate&&(this.rotate=t,this.gl&&this.program.setRotateMatrix(this.getRotateMatrix(this.rotate)),this.layout(),this.clear())}destroy(){this.program&&this.program.stop(),this.gl=null,this.VAO=null,this.vertex=null,this.onWebglContextLost&&(this.canvas.removeEventListener("webglcontextlost",this.onWebglContextLost),this.onWebglContextLost=null),this.onWebglContextRestored&&(this.canvas.removeEventListener("webglcontextrestored",this.onWebglContextRestored),this.onWebglContextRestored=null),super.destroy()}}class ct extends ht{constructor(t,e){super(t,e),(0,x.A)(this,"yTexture",void 0),(0,x.A)(this,"uTexture",void 0),(0,x.A)(this,"vTexture",void 0)}useProgram(){super.useProgram(),this.yTexture=new nt(this.gl),this.yTexture.bind(0),this.yTexture.init(),this.program.bindYTexture(0),this.uTexture=new nt(this.gl),this.uTexture.bind(1),this.uTexture.init(),this.program.bindUTexture(1),this.vTexture=new nt(this.gl),this.vTexture.bind(2),this.vTexture.init(),this.program.bindVTexture(2)}destroy(){this.yTexture&&(this.yTexture.destroy(),this.yTexture=null),this.uTexture&&(this.uTexture.destroy(),this.uTexture=null),this.vTexture&&(this.vTexture.destroy(),this.vTexture=null),super.destroy()}}class ut{constructor(t,e){(0,x.A)(this,"gl",void 0),(0,x.A)(this,"_program",void 0),(0,x.A)(this,"vertexShader",void 0),(0,x.A)(this,"fragmentShader",void 0),this.vertexShader=t,this.fragmentShader=e}link(t){this.gl=t,this.vertexShader&&this.vertexShader.compile(this.gl),this.fragmentShader&&this.fragmentShader.compile(this.gl),this._program=this.gl.createProgram(),this.gl.attachShader(this._program,this.vertexShader.shader),this.gl.attachShader(this._program,this.fragmentShader.shader),this.gl.linkProgram(this._program)}stop(){this.vertexShader.stop(this.gl),this.fragmentShader.stop(this.gl),this.gl.deleteProgram(this._program),this.vertexShader=null,this.fragmentShader=null,this._program=null}bind(){this.gl.useProgram(this._program)}get program(){return this._program}}class dt extends ut{constructor(t,e,i=!0){super(t,e),(0,x.A)(this,"enableColor",void 0),(0,x.A)(this,"aPoint",void 0),(0,x.A)(this,"aColor",void 0),this.enableColor=i}link(t){super.link(t),this.aPoint=this.gl.getAttribLocation(this.program,"point"),this.aColor=this.gl.getAttribLocation(this.program,"color"),this.enableColor?(this.gl.enableVertexAttribArray(this.aPoint),this.gl.enableVertexAttribArray(this.aColor)):this.gl.enableVertexAttribArray(this.aPoint)}bind(){super.bind(),this.enableColor?(this.gl.vertexAttribPointer(this.aPoint,3,this.gl.FLOAT,!1,7*Float32Array.BYTES_PER_ELEMENT,0),this.gl.vertexAttribPointer(this.aColor,4,this.gl.FLOAT,!1,7*Float32Array.BYTES_PER_ELEMENT,3*Float32Array.BYTES_PER_ELEMENT)):this.gl.vertexAttribPointer(this.aPoint,3,this.gl.FLOAT,!1,7*Float32Array.BYTES_PER_ELEMENT,0)}}class lt{constructor(t,e){(0,x.A)(this,"type",void 0),(0,x.A)(this,"_shader",void 0),(0,x.A)(this,"_source",void 0),(0,x.A)(this,"compiled",void 0),this.type=t,this._shader=null,this._source=e,this.compiled=!1}compile(t){this.compiled||(this._shader=t.createShader(0===this.type?t.VERTEX_SHADER:t.FRAGMENT_SHADER),t.shaderSource(this._shader,this._source),t.compileShader(this._shader),this.compiled=!0)}stop(t){t.deleteShader(this._shader),this._shader=null}get shader(){return this._shader}}class ft extends lt{constructor(t){super(0,t)}}class pt extends lt{constructor(t){super(1,t)}}class mt extends dt{constructor(t){super(new ft("precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 point;\nattribute vec4 color;\nvarying vec4 v_color;\n\nuniform mat4 rotateMatrix;\n\nvoid main(void){\n gl_Position = rotateMatrix * vec4(point, 1.0);\n v_color = color;\n}\n"),new pt(t)),(0,x.A)(this,"rotateMatrixLocation",void 0)}link(t){super.link(t),this.rotateMatrixLocation=this.gl.getUniformLocation(this.program,"rotateMatrix")}setRotateMatrix(t){this.gl.uniformMatrix4fv(this.rotateMatrixLocation,!1,new Float32Array(t))}}class gt extends mt{constructor(t){super(t),(0,x.A)(this,"ySamplerLocation",void 0),(0,x.A)(this,"uSamplerLocation",void 0),(0,x.A)(this,"vSamplerLocation",void 0)}link(t){super.link(t),this.ySamplerLocation=this.gl.getUniformLocation(this.program,"y_Sampler"),this.uSamplerLocation=this.gl.getUniformLocation(this.program,"u_Sampler"),this.vSamplerLocation=this.gl.getUniformLocation(this.program,"v_Sampler")}bindYTexture(t=0){this.gl.uniform1i(this.ySamplerLocation,t)}bindUTexture(t=0){this.gl.uniform1i(this.uSamplerLocation,t)}bindVTexture(t=0){this.gl.uniform1i(this.vSamplerLocation,t)}}class vt extends gt{constructor(t){super(t)}}const At=203,yt=1e3;function wt(t,e){let i="",r="";if(0===e.type?(i="mat4",r="vec4"):1===e.type&&(i="mat4x4",r="vec4"),!i||!r)return"";let s=`\n color = ${i}(\n ${t.rc(0,0)}, ${t.rc(1,0)}, ${t.rc(2,0)}, 0,\n ${t.rc(0,1)}, ${t.rc(1,1)}, ${t.rc(2,1)}, 0,\n ${t.rc(0,2)}, ${t.rc(1,2)}, ${t.rc(2,2)}, 0,\n 0, 0, 0, 1\n ) * color;\n `;return 0===t.rc(0,3)&&0===t.rc(1,3)&&0===t.rc(2,3)||(s+=`\n color += ${r}(${t.rc(0,3)}, ${t.rc(1,3)}, ${t.rc(2,3)}, 0);\n `),s}function bt(t,e,i){return e?`\n {\n ${1===i.type?"var v: f32":"float v"} = abs(color.r);\n ${t()}\n color.r = sign(color.r) * v;\n }\n {\n ${1===i.type?"var v: f32":"float v"} = abs(color.g);\n ${t()}\n color.g = sign(color.g) * v;\n }\n {\n ${1===i.type?"var v: f32":"float v"} = abs(color.b);\n ${t()}\n color.b = sign(color.b) * v;\n }\n `:`\n {\n ${1===i.type?"var v: f32":"float v"} = color.r;\n ${t()}\n color.r = v;\n }\n {\n ${1===i.type?"var v: f32":"float v"} = color.g;\n ${t()}\n color.g = v;\n }\n {\n ${1===i.type?"var v: f32":"float v"} = color.b;\n ${t()}\n color.b = v;\n }\n `}function kt(t){return t===t>>>0?`${t}.0`:t.toString()}function xt(t,e,i){return bt((function(){let e=.0009765625,i="v";Math.abs(t.c-1)>e&&(i=`${kt(t.c)} * ${i}`),Math.abs(t.f)>e&&(i=`${i} + ${kt(t.f)}`);let r="v";return Math.abs(t.a=1)>e&&(r=`${kt(t.a)} * ${r}`),Math.abs(t.b)>e&&(r=`${r} + ${kt(t.b)}`),Math.abs(t.g-1)>e&&(r=`pow(${r}, ${kt(t.g)})`),Math.abs(t.e)>e&&(r=`${r} + ${kt(t.e)}`),`\n if (v < ${kt(t.d)}) {\n v = ${i};\n }\n else {\n v = ${r};\n }\n `}),!1,i)}function _t(t,e,i){let r=i.dstSdrMaxLuminanceNits;e&&(r=At,i.ndwl&&(r=i.ndwl)),i.metadata.nitsToSdrRelativeFactor=t/r}function Pt(t,e){e.metadata.sdrRelativeToNitsFactor=e.dstSdrMaxLuminanceNits/t}function Tt(t,e,i){const r=[],s=8===t.getMatrixId(),a=wt(t.getRangeAdjustMatrix(i.bitDepth),i);if(s||r.push(a),10===t.getMatrixId()||r.push(wt(t.getTransferMatrix(i.bitDepth).invert(),i)),s&&r.push(a),e.isValid()){if(t.isHDR()){switch(t.getTransferId()){case 18:r.push(function(t){return bt((function(){return`\n v = max(0.0, v);\n ${1===t.type?"let a: f32":"float a"} = 0.17883277f;\n ${1===t.type?"let b: f32":"float b"} = 0.28466892f;\n ${1===t.type?"let c: f32":"float c"} = 0.55991073f;\n if (v <= 0.5) {\n v = v * v + 4.0;\n }\n else {\n v = exp((v - c) / a) + b;\n }\n v = v / 12.0;\n `}),!1,t)}(i));break;case 16:r.push(function(t){return bt((function(){return`\n v = max(0.0, v);\n ${1===t.type?"let m1: f32":"float m1"} = (2610.0 / 4096.0) / 4.0;\n ${1===t.type?"let m2: f32":"float m2"} = (2523.0 / 4096.0) * 128.0;\n ${1===t.type?"let c1: f32":"float c1"} = 3424.0 / 4096.0;\n ${1===t.type?"let c2: f32":"float c2"} = (2413.0 / 4096.0) * 32.0;\n ${1===t.type?"let c3: f32":"float c3"} = (2392.0 / 4096.0) * 32.0;\n \n ${0===t.type?"\n #ifdef GL_FRAGMENT_PRECISION_HIGH\n highp float v2 = v;\n #else\n float v2 = v;\n #endif\n ":"var v2: f32 = v;"}\n \n v2 = pow(max(pow(v2, 1.0 / m2) - c1, 0.0) / (c2 - c3 * pow(v2, 1.0 / m2)), 1.0 / m1);\n v = v2;\n `}),!1,t)}(i));break;default:const e=t.getTransferFunction();e?r.push(xt(e,t.hasExtendedSkTransferFn(),i)):r.push(function(t,e){return bt((function(){switch(t){case 9:return"\n if (v < 0.0) {\n v = 0.0;\n }\n else {\n v = pow(10.0, (v - 1.0) * 2.0);\n }\n ";case 10:return"\n if (v < 0.0) {\n v = 0.0;\n }\n else {\n v = pow(10.0, (v - 1.0) * 2.5);\n }\n ";case 11:return`\n ${1===e.type?"let a: f32":"float a"} = 1.099296826809442;\n ${1===e.type?"let from_linear_neg_a: f32":"float from_linear_neg_a"} = -1.047844;\n ${1===e.type?"let from_linear_b: f32":"float from_linear_b"} = 0.081243;\n if (v < from_linear_neg_a) {\n v = -pow((a - 1.0 - v) / a, 1.0 / 0.45);\n }\n else if (v <= from_linear_b) {\n v = v / 4.5;\n }\n else {\n v = pow((v + a - 1.0) / a, 1.0 / 0.45);\n }\n `;case 12:return`\n ${1===e.type?"let a: f32":"float a"} = 1.099;\n ${1===e.type?"let from_linear_neg_l: f32":"float from_linear_neg_l"} = -0.020250;\n ${1===e.type?"let from_linear_b: f32":"float from_linear_b"} = 0.081000;\n if (v < from_linear_neg_l) {\n v = -pow((1.0 - a - v * 4.0) / a, 1.0 / 0.45) / 4.0;\n }\n else if (v <= from_linear_b) {\n v = v / 4.5;\n }\n else {\n v = pow((v + a - 1.0) / a, 1.0 / 0.45);\n }\n `;default:return""}}),!1,e)}(t.getTransferId(),i))}10===t.getMatrixId()&&r.push(wt(t.getTransferMatrix(i.bitDepth).invert(),i)),r.push(wt(t.getPrimaryMatrix(),i));const s=new Y(0,9,8,2);switch(t.getTransferId()){case 18:i.toneMapPQAndHlgToDst?(function(t){t.metadata.hlgDstMaxLuminanceRelative=t.dstMaxLuminanceRelative;const e=t.dstSdrMaxLuminanceNits*t.dstMaxLuminanceRelative;t.metadata.hlgOOTFGammaMinusOne=1.2+.42*Math.log10(e/yt)/Math.log10(10)-1}(i),r.push(function(t){return 0===t.type?"\n {\n vec4 luma_vec = vec4(0.2627, 0.678, 0.0593, 0.0);\n float L = dot(color, luma_vec);\n if (L > 0.0) {\n color.r *= pow(L, hlg_ootf_gamma_minus_one);\n color.g *= pow(L, hlg_ootf_gamma_minus_one);\n color.b *= pow(L, hlg_ootf_gamma_minus_one);\n color.r *= hlg_dst_max_luminance_relative;\n color.g *= hlg_dst_max_luminance_relative;\n color.b *= hlg_dst_max_luminance_relative;\n }\n }\n ":1===t.type?"\n {\n let luma_vec: vec4 = vec4(0.2627, 0.678, 0.0593, 0.0);\n let L: f32 = dot(color, luma_vec);\n if (L > 0.0) {\n color.r *= pow(L, hlg_ootf_gamma_minus_one);\n color.g *= pow(L, hlg_ootf_gamma_minus_one);\n color.b *= pow(L, hlg_ootf_gamma_minus_one);\n color.r *= hlg_dst_max_luminance_relative;\n color.g *= hlg_dst_max_luminance_relative;\n color.b *= hlg_dst_max_luminance_relative;\n }\n }\n ":""}(i))):(_t(12/At,!1,i),r.push("\n color.r *= nits_to_sdr_relative_factor;\n color.g *= nits_to_sdr_relative_factor;\n color.b *= nits_to_sdr_relative_factor;\n "));break;case 16:_t(1e4,!0,i),r.push("\n color.r *= nits_to_sdr_relative_factor;\n color.g *= nits_to_sdr_relative_factor;\n color.b *= nits_to_sdr_relative_factor;\n "),i.toneMapPQAndHlgToDst&&(r.push(wt(s.getPrimaryMatrix().invert(),i)),function(t,e){const i=function(t,e){let i=yt;return 18!==t.getTransferId()&&e.maxContentLightLevel>0&&(i=e.maxContentLightLevel),i/e.dstSdrMaxLuminanceNits}(t,e);i>e.dstMaxLuminanceRelative?(e.metadata.pqTonemapA=e.dstMaxLuminanceRelative/(i*i),e.metadata.pqTonemapB=1/e.dstMaxLuminanceRelative):(e.metadata.pqTonemapA=0,e.metadata.pqTonemapB=0)}(t,i),r.push(function(t){return`\n {\n ${1===t.type?"let maximum: f32":"float maximum"} = max(color.r, max(color.g, color.b));\n if (maximum > 0.0) {\n color.r *= (1.0 + pq_tonemap_a * maximum) / (1.0 + pq_tonemap_b * maximum);\n color.g *= (1.0 + pq_tonemap_a * maximum) / (1.0 + pq_tonemap_b * maximum);\n color.b *= (1.0 + pq_tonemap_a * maximum) / (1.0 + pq_tonemap_b * maximum);\n }\n }\n `}(i)),r.push(wt(s.getPrimaryMatrix(),i)))}switch(r.push(wt(e.getPrimaryMatrix().invert(),i)),10===e.getMatrixId()&&r.push(wt(e.getTransferMatrix(i.bitDepth),i)),e.getTransferId()){case 18:Pt(At,i),r.push("\n color.r *= sdr_relative_to_nits_factor;\n color.g *= sdr_relative_to_nits_factor;\n color.b *= sdr_relative_to_nits_factor;\n "),r.push(function(t){return bt((function(){return`\n v = max(0.0, v);\n ${1===t.type?"let a: f32":"float a"} = 0.17883277f;\n ${1===t.type?"let b: f32":"float b"} = 0.28466892f;\n ${1===t.type?"let c: f32":"float c"} = 0.55991073f;\n if (v <= 1.0) {\n v = 0.5 * sqrt(v);\n }\n else {\n v = a * log(v - b) + c;\n }\n `}),!1,t)}(i));break;case 16:Pt(1e4,i),r.push("\n color.r *= sdr_relative_to_nits_factor;\n color.g *= sdr_relative_to_nits_factor;\n color.b *= sdr_relative_to_nits_factor;\n "),r.push(function(t){return bt((function(){return`\n v = max(0.0, v);\n ${1===t.type?"let m1: f32":"float m1"} = (2610.0 / 4096.0) / 4.0;\n ${1===t.type?"let m2: f32":"float m2"} = (2523.0 / 4096.0) * 128.0;\n ${1===t.type?"let c1: f32":"float c1"} = 3424.0 / 4096.0;\n ${1===t.type?"let c2: f32":"float c2"} = (2413.0 / 4096.0) * 32.0;\n ${1===t.type?"let c3: f32":"float c3"} = (2392.0 / 4096.0) * 32.0;\n v = pow((c1 + c2 * pow(v, m1)) / (1.0 + c3 * pow(v, m1)), m2);\n `}),!1,t)}(i));default:const s=e.getInverseTransferFunction();s?r.push(xt(s,t.hasExtendedSkTransferFn(),i)):r.push(function(t,e){return bt((function(){switch(t){case 9:return"\n if (v < 0.0) {\n v = 0.0;\n }\n else {\n v = 1.0 + log(v) / log(10.0) / 2.0;\n }\n ";case 10:return"\n if (v < sqrt(10.0) / 1000.0)\n v = 0.0;\n }\n else {\n v = 1.0 + log(v) / log(10.0) / 2.5;\n }\n ";case 11:return`\n ${1===e.type?"let a: f32":"float a"} = 1.099296826809442;\n ${1===e.type?"let b: f32":"float b"}= 0.018053968510807;\n if (v < -b) {\n v = -a * pow(-v, 0.45) + (a - 1.0);\n }\n else if (v <= b) {\n v = 4.5 * v;\n }\n else {\n v = a * pow(v, 0.45) - (a - 1.0);\n }\n `;case 12:return`\n ${1===e.type?"let a: f32":"float a"} = 1.099;\n ${1===e.type?"let b: f32":"float b"} = 0.018;\n ${1===e.type?"let l: f32":"float l"} = 0.0045;\n\n if (v < -l) {\n v = -(a * pow(-4.0 * v, 0.45) + (a - 1.0)) / 4.0;\n }\n else if (v <= b) {\n v = 4.5 * v;\n }\n else {\n v = a * pow(v, 0.45) - (a - 1.0);\n }\n `;default:return""}}),!1,e)}(t.getTransferId(),i))}}if(!i.outputRGB){const t=8===e.getMatrixId(),s=wt(e.getRangeAdjustMatrix(i.bitDepth).invert(),i);t&&r.push(s),10===e.getMatrixId()||r.push(wt(e.getTransferMatrix(i.bitDepth),i)),t||r.push(s)}}return r}var It,Ct,Bt=i(4503),St=i(4300),Mt=i(662),Rt=i.n(Mt),Ut=i(1499),Et=i(2085);class Dt{constructor(){(0,x.A)(this,"offset",void 0),(0,x.A)(this,"multiplier",void 0),(0,x.A)(this,"pqTonemapA",void 0),(0,x.A)(this,"pqTonemapB",void 0),(0,x.A)(this,"hlgOOTFGammaMinusOne",void 0),(0,x.A)(this,"hlgDstMaxLuminanceRelative",void 0),(0,x.A)(this,"nitsToSdrRelativeFactor",void 0),(0,x.A)(this,"sdrRelativeToNitsFactor",void 0)}}It=Dt.prototype,(Ct=new(Rt())).set("offset",{0:18,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),Ct.set("multiplier",{0:18,1:0,2:0,3:0,4:0,5:0,6:0,7:4,8:0}),Ct.set("pqTonemapA",{0:18,1:0,2:0,3:0,4:0,5:0,6:0,7:8,8:0}),Ct.set("pqTonemapB",{0:18,1:0,2:0,3:0,4:0,5:0,6:0,7:12,8:0}),Ct.set("hlgOOTFGammaMinusOne",{0:18,1:0,2:0,3:0,4:0,5:0,6:0,7:16,8:0}),Ct.set("hlgDstMaxLuminanceRelative",{0:18,1:0,2:0,3:0,4:0,5:0,6:0,7:20,8:0}),Ct.set("nitsToSdrRelativeFactor",{0:18,1:0,2:0,3:0,4:0,5:0,6:0,7:24,8:0}),Ct.set("sdrRelativeToNitsFactor",{0:18,1:0,2:0,3:0,4:0,5:0,6:0,7:28,8:0}),(0,Et.A)(It,Ut.Og,!0),(0,Et.A)(It,Ut.dc,4),(0,Et.A)(It,Ut.g7,32),(0,Et.A)(It,Ut.JY,Ct);var Lt=i(4363);class Ft extends gt{constructor(t){super(t),(0,x.A)(this,"maxUniformLocation",void 0),(0,x.A)(this,"offsetLocation",void 0),(0,x.A)(this,"multiplierLocation",void 0),(0,x.A)(this,"pqTonemapALocation",void 0),(0,x.A)(this,"pqTonemapBLocation",void 0),(0,x.A)(this,"hlgOOTFGammaMinusOneLocation",void 0),(0,x.A)(this,"hlgDstMaxLuminanceRelativeLocation",void 0),(0,x.A)(this,"nitsToSdrRelativeFactorLocation",void 0),(0,x.A)(this,"sdrRelativeToNitsFactorLocation",void 0)}link(t){super.link(t),this.maxUniformLocation=this.gl.getUniformLocation(this.program,"v_max"),this.offsetLocation=this.gl.getUniformLocation(this.program,"offset"),this.multiplierLocation=this.gl.getUniformLocation(this.program,"multiplier"),this.pqTonemapALocation=this.gl.getUniformLocation(this.program,"pq_tonemap_a"),this.pqTonemapBLocation=this.gl.getUniformLocation(this.program,"pq_tonemap_b"),this.hlgOOTFGammaMinusOneLocation=this.gl.getUniformLocation(this.program,"hlg_ootf_gamma_minus_one"),this.hlgDstMaxLuminanceRelativeLocation=this.gl.getUniformLocation(this.program,"hlg_dst_max_luminance_relative"),this.nitsToSdrRelativeFactorLocation=this.gl.getUniformLocation(this.program,"nits_to_sdr_relative_factor"),this.sdrRelativeToNitsFactorLocation=this.gl.getUniformLocation(this.program,"sdr_relative_to_nits_factor")}setMax(t){this.gl.uniform1f(this.maxUniformLocation,t)}setMetaData(t){this.gl.uniform1f(this.offsetLocation,t.offset),this.gl.uniform1f(this.multiplierLocation,t.multiplier),this.gl.uniform1f(this.pqTonemapALocation,t.pqTonemapA),this.gl.uniform1f(this.pqTonemapBLocation,t.pqTonemapB),this.gl.uniform1f(this.hlgOOTFGammaMinusOneLocation,t.hlgOOTFGammaMinusOne),this.gl.uniform1f(this.hlgDstMaxLuminanceRelativeLocation,t.hlgDstMaxLuminanceRelative),this.gl.uniform1f(this.nitsToSdrRelativeFactorLocation,t.nitsToSdrRelativeFactor),this.gl.uniform1f(this.sdrRelativeToNitsFactorLocation,t.sdrRelativeToNitsFactor)}}class zt extends et{constructor(t,e){super(t,e),(0,x.A)(this,"yTexture",void 0),(0,x.A)(this,"uTexture",void 0),(0,x.A)(this,"vTexture",void 0),this.vertexSource=X}generateBindGroup(){this.yTexture&&(this.bindGroupLayout=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:3,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:4,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}}]}),this.bindGroup=this.device.createBindGroup({layout:this.bindGroupLayout,entries:[{binding:0,resource:{buffer:this.rotateMatrixBuffer,size:16*Float32Array.BYTES_PER_ELEMENT}},{binding:1,resource:this.yTexture.createView()},{binding:2,resource:this.uTexture.createView()},{binding:3,resource:this.vTexture.createView()},{binding:4,resource:this.sampler}]}))}destroy(){this.yTexture&&this.yTexture.destroy(),this.uTexture&&this.uTexture.destroy(),this.vTexture&&this.vTexture.destroy(),super.destroy()}}var Ot=i(9638),Vt="src/avpipeline/VideoRenderPipeline.ts";const Nt=[class extends zt{constructor(t,e){super(t,e)}generateFragmentSource(){const t=Tt(this.srcColorSpace,this.dstColorSpace,{bitDepth:8,type:1,outputRGB:!0});this.fragmentSource=`\n @group(0) @binding(1) var yTexture: texture_2d;\n @group(0) @binding(2) var uTexture: texture_2d;\n @group(0) @binding(3) var vTexture: texture_2d;\n @group(0) @binding(4) var s: sampler;\n \n @fragment\n fn main(@location(0) in_texcoord: vec4) -> @location(0) vec4 {\n var color = vec4(textureSample(yTexture, s, in_texcoord.xy).x, textureSample(uTexture, s, in_texcoord.xy).x, textureSample(vTexture, s, in_texcoord.xy).x, 1.0);\n ${t.reduce(((t,e)=>t+e),"")}\n return color;\n }\n `}checkFrame(t){o.f[15](t+32)===this.textureWidth&&o.f[15](t+72)===this.videoHeight&&o.f[15](t+68)===this.videoWidth||(this.yTexture&&this.yTexture.destroy(),this.uTexture&&this.uTexture.destroy(),this.vTexture&&this.vTexture.destroy(),this.yTexture=this.device.createTexture({size:[o.f[15](t+32),o.f[15](t+72)],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT,format:"r8unorm"}),this.uTexture=this.device.createTexture({size:[o.f[15](t+32+4),o.f[15](t+72)>>>st[o.f[15](t+80)].log2ChromaH],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT,format:"r8unorm"}),this.vTexture=this.device.createTexture({size:[o.f[15](t+32+8),o.f[15](t+72)>>>st[o.f[15](t+80)].log2ChromaH],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.RENDER_ATTACHMENT,format:"r8unorm"}),this.srcColorSpace=new Y(o.f[15](t+248),o.f[15](t+240),o.f[15](t+244),o.f[15](t+236)),this.generateFragmentSource(),this.videoWidth=o.f[15](t+68),this.videoHeight=o.f[15](t+72),this.textureWidth=o.f[15](t+32),this.format=o.f[15](t+80),this.layout(),this.generatePipeline(),this.generateRenderBundleEncoder())}render(t){if(this.lost)return;this.checkFrame(t),this.device.queue.writeTexture({texture:this.yTexture},(0,rt.s3)(o.f[20](t),this.yTexture.width*this.yTexture.height),{offset:0,bytesPerRow:this.yTexture.width,rowsPerImage:this.yTexture.height},{width:this.yTexture.width,height:this.yTexture.height,depthOrArrayLayers:1}),this.device.queue.writeTexture({texture:this.uTexture},(0,rt.s3)(o.f[20](t+4),this.uTexture.width*this.uTexture.height),{offset:0,bytesPerRow:this.uTexture.width,rowsPerImage:this.uTexture.height},{width:this.uTexture.width,height:this.uTexture.height,depthOrArrayLayers:1}),this.device.queue.writeTexture({texture:this.vTexture},(0,rt.s3)(o.f[20](t+8),this.vTexture.width*this.vTexture.height),{offset:0,bytesPerRow:this.vTexture.width,rowsPerImage:this.vTexture.height},{width:this.vTexture.width,height:this.vTexture.height,depthOrArrayLayers:1});const e=this.device.createCommandEncoder(),i=e.beginRenderPass({colorAttachments:[{view:this.context.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});i.executeBundles([this.renderBundle]),i.end(),this.device.queue.submit([e.finish()])}static isSupport(t){if(l.ai(t)){const e=st[o.f[15](t+80)];if(e)return e.depth+7>>>3==1}return!1}}];Nt.push(class extends zt{constructor(t,e){super(t,e),(0,x.A)(this,"metaYBuffer",void 0),(0,x.A)(this,"metaUBuffer",void 0),(0,x.A)(this,"metaVBuffer",void 0),(0,x.A)(this,"computeBindGroupLayout",void 0),(0,x.A)(this,"computeBindGroupY",void 0),(0,x.A)(this,"computeBindGroupU",void 0),(0,x.A)(this,"computeBindGroupV",void 0),(0,x.A)(this,"computePipelineLayout",void 0),(0,x.A)(this,"computePipeline",void 0),(0,x.A)(this,"inputYTexture",void 0),(0,x.A)(this,"inputUTexture",void 0),(0,x.A)(this,"inputVTexture",void 0),(0,x.A)(this,"computeModule",void 0),(0,x.A)(this,"uint2Float",void 0),(0,x.A)(this,"hdrMetadata",void 0),(0,x.A)(this,"hdrMetadataBuffer",void 0),this.hdrMetadata=(0,Bt.A)(Dt),this.hdrMetadata.multiplier=1}generateFragmentSource(t){t.outputRGB=!0;const e=Tt(this.srcColorSpace,this.dstColorSpace,t);this.fragmentSource=`\n struct HdrMetadata {\n offset: f32,\n multiplier: f32,\n pqTonemapA: f32,\n pqTonemapB: f32,\n hlgOOTFGammaMinusOne: f32,\n hlgDstMaxLuminanceRelative: f32,\n nitsToSdrRelativeFactor: f32,\n sdrRelativeToNitsFactor: f32\n };\n\n @group(0) @binding(1) var yTexture: texture_2d;\n @group(0) @binding(2) var uTexture: texture_2d;\n @group(0) @binding(3) var vTexture: texture_2d;\n @group(0) @binding(4) var s: sampler;\n @group(0) @binding(5) var hdrMetadata: HdrMetadata;\n\n @fragment\n fn main(@location(0) in_texcoord: vec4) -> @location(0) vec4 {\n\n let offset = hdrMetadata.offset;\n let multiplier = hdrMetadata.multiplier;\n let pq_tonemap_a = hdrMetadata.pqTonemapA;\n let pq_tonemap_b = hdrMetadata.pqTonemapB;\n let hlg_ootf_gamma_minus_one = hdrMetadata.hlgOOTFGammaMinusOne;\n let hlg_dst_max_luminance_relative = hdrMetadata.hlgDstMaxLuminanceRelative;\n let nits_to_sdr_relative_factor = hdrMetadata.nitsToSdrRelativeFactor;\n let sdr_relative_to_nits_factor = hdrMetadata.sdrRelativeToNitsFactor;\n\n var color = vec4(textureSample(yTexture, s, in_texcoord.xy).x, textureSample(uTexture, s, in_texcoord.xy).x, textureSample(vTexture, s, in_texcoord.xy).x, 1.0);\n\n if (color.a > 0) {\n color.r /= color.a;\n color.g /= color.a;\n color.b /= color.a;\n }\n color.r -= offset;\n color.g -= offset;\n color.b -= offset;\n\n color.r *= multiplier;\n color.g *= multiplier;\n color.b *= multiplier;\n \n ${e.reduce(((t,e)=>t+e),"")}\n\n color.r *= color.a;\n color.g *= color.a;\n color.b *= color.a;\n\n return color;\n }\n `}async init(){await super.init(["float32-filterable"]),this.metaYBuffer=this.device.createBuffer({size:4*Uint32Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.metaUBuffer=this.device.createBuffer({size:4*Uint32Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.metaVBuffer=this.device.createBuffer({size:4*Uint32Array.BYTES_PER_ELEMENT,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST}),this.hdrMetadataBuffer=this.device.createBuffer({size:32,usage:GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST})}generateComputeBindGroup(){this.computeBindGroupLayout=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.COMPUTE,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.COMPUTE,texture:{sampleType:"uint"}},{binding:2,visibility:GPUShaderStage.COMPUTE,storageTexture:{format:"r32float"}}]}),this.computeBindGroupY=this.device.createBindGroup({layout:this.computeBindGroupLayout,entries:[{binding:0,resource:{buffer:this.metaYBuffer,size:4*Uint32Array.BYTES_PER_ELEMENT}},{binding:1,resource:this.inputYTexture.createView()},{binding:2,resource:this.yTexture.createView()}]}),this.computeBindGroupU=this.device.createBindGroup({layout:this.computeBindGroupLayout,entries:[{binding:0,resource:{buffer:this.metaUBuffer,size:4*Uint32Array.BYTES_PER_ELEMENT}},{binding:1,resource:this.inputUTexture.createView()},{binding:2,resource:this.uTexture.createView()}]}),this.computeBindGroupV=this.device.createBindGroup({layout:this.computeBindGroupLayout,entries:[{binding:0,resource:{buffer:this.metaVBuffer,size:4*Uint32Array.BYTES_PER_ELEMENT}},{binding:1,resource:this.inputVTexture.createView()},{binding:2,resource:this.vTexture.createView()}]})}generateComputePipeline(){this.generateComputeBindGroup(),this.computePipelineLayout=this.device.createPipelineLayout({bindGroupLayouts:[this.computeBindGroupLayout]}),this.computeModule=this.device.createShaderModule({code:this.uint2Float}),this.computePipeline=this.device.createComputePipeline({layout:this.computePipelineLayout,compute:{module:this.computeModule,entryPoint:"main"}})}generateBindGroup(){this.yTexture&&(this.bindGroupLayout=this.device.createBindGroupLayout({entries:[{binding:0,visibility:GPUShaderStage.VERTEX,buffer:{type:"uniform"}},{binding:1,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:2,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:3,visibility:GPUShaderStage.FRAGMENT,texture:{sampleType:"float"}},{binding:4,visibility:GPUShaderStage.FRAGMENT,sampler:{type:"filtering"}},{binding:5,visibility:GPUShaderStage.FRAGMENT,buffer:{type:"uniform"}}]}),this.bindGroup=this.device.createBindGroup({layout:this.bindGroupLayout,entries:[{binding:0,resource:{buffer:this.rotateMatrixBuffer,size:this.rotateMatrixBuffer.size}},{binding:1,resource:this.yTexture.createView()},{binding:2,resource:this.uTexture.createView()},{binding:3,resource:this.vTexture.createView()},{binding:4,resource:this.sampler},{binding:5,resource:{buffer:this.hdrMetadataBuffer,size:this.hdrMetadataBuffer.size}}]}))}checkFrame(t){const e=st[o.f[15](t+80)];if(e&&(o.f[15](t+32)>>>1!==this.textureWidth||o.f[15](t+72)!==this.videoHeight||o.f[15](t+68)!==this.videoWidth||o.f[15](t+80)!==this.format)){this.yTexture&&this.yTexture.destroy(),this.uTexture&&this.uTexture.destroy(),this.vTexture&&this.vTexture.destroy(),this.inputYTexture&&this.inputYTexture.destroy(),this.inputUTexture&&this.inputUTexture.destroy(),this.inputVTexture&&this.inputVTexture.destroy(),this.yTexture=this.device.createTexture({size:[o.f[15](t+32)>>>1,o.f[15](t+72)],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.STORAGE_BINDING,format:"r32float"}),this.uTexture=this.device.createTexture({size:[o.f[15](t+32+4)>>>1,o.f[15](t+72)>>>e.log2ChromaH],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.STORAGE_BINDING,format:"r32float"}),this.vTexture=this.device.createTexture({size:[o.f[15](t+32+8)>>>1,o.f[15](t+72)>>>e.log2ChromaH],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.STORAGE_BINDING,format:"r32float"}),this.inputYTexture=this.device.createTexture({size:[this.yTexture.width,this.yTexture.height],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST,format:"r16uint"}),this.inputUTexture=this.device.createTexture({size:[this.uTexture.width,this.uTexture.height],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST,format:"r16uint"}),this.inputVTexture=this.device.createTexture({size:[this.vTexture.width,this.vTexture.height],usage:GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST,format:"r16uint"});const i=new Uint32Array([e.max,this.inputYTexture.width,this.inputYTexture.height]);this.device.queue.writeBuffer(this.metaYBuffer,0,i.buffer,i.byteOffset,i.byteLength);const r=new Uint32Array([e.max,this.inputUTexture.width,this.inputUTexture.height]);this.device.queue.writeBuffer(this.metaUBuffer,0,r.buffer,r.byteOffset,r.byteLength);const s=new Uint32Array([e.max,this.inputVTexture.width,this.inputVTexture.height]);this.device.queue.writeBuffer(this.metaVBuffer,0,s.buffer,s.byteOffset,s.byteLength),this.srcColorSpace=new Y(o.f[15](t+248),o.f[15](t+240),o.f[15](t+244),o.f[15](t+236)),this.videoWidth=o.f[15](t+68),this.videoHeight=o.f[15](t+72),this.textureWidth=o.f[15](t+32)>>>1,this.format=o.f[15](t+80);const a={type:1,bitDepth:e.depth,toneMapPQAndHlgToDst:!0,metadata:this.hdrMetadata,dstSdrMaxLuminanceNits:At,dstMaxLuminanceRelative:1},n=(0,Lt.aH)(t,14);if(n){const t=o.f[20](n+4);o.f[8](t)>0&&(a.maxContentLightLevel=o.f[8](t))}this.generateFragmentSource(a),this.uint2Float=1&e.flags?"\nstruct Meta {\n max: u32,\n width: u32,\n height: u32\n};\n\n@group(0) @binding(0) var metaData: Meta;\n@group(0) @binding(1) var input: texture_2d;\n@group(0) @binding(2) var output: texture_storage_2d;\n\n@compute @workgroup_size(8, 8) fn main(\n @builtin(workgroup_id) workgroup_id: vec3,\n @builtin(local_invocation_id) local_invocation_id: vec3\n) {\n var x = workgroup_id.x * 8 + local_invocation_id.x;\n var y = workgroup_id.y * 8 + local_invocation_id.y;\n if (x < metaData.width && y < metaData.height) {\n var value: u32 = textureLoad(input, vec2(x, y), 0).x;\n var low = value & 0xff;\n var high = (value >> 8) & 0xff;\n value = (low << 8) | high;\n var value_no: f32 = f32(value) / f32(metaData.max);\n textureStore(output, vec2(x, y), vec4(value_no, 0, 0, 0));\n }\n}":"\nstruct Meta {\n max: u32,\n width: u32,\n height: u32\n};\n\n@group(0) @binding(0) var metaData: Meta;\n@group(0) @binding(1) var input: texture_2d;\n@group(0) @binding(2) var output: texture_storage_2d;\n\n@compute @workgroup_size(8, 8) fn main(\n @builtin(workgroup_id) workgroup_id: vec3,\n @builtin(local_invocation_id) local_invocation_id: vec3\n) {\n var x = workgroup_id.x * 8 + local_invocation_id.x;\n var y = workgroup_id.y * 8 + local_invocation_id.y;\n if (x < metaData.width && y < metaData.height) {\n var value: u32 = textureLoad(input, vec2(x, y), 0).x;\n var value_no: f32 = f32(value) / f32(metaData.max);\n textureStore(output, vec2(x, y), vec4(value_no, 0, 0, 0));\n }\n}",this.layout(),this.generatePipeline(),this.generateRenderBundleEncoder(),this.generateComputePipeline();const h=(0,rt.s3)(this.hdrMetadata[Ut.o9],32).slice();this.device.queue.writeBuffer(this.hdrMetadataBuffer,0,h.buffer,h.byteOffset,h.byteLength)}}render(t){if(this.lost)return;this.checkFrame(t);const e=this.device.createCommandEncoder(),i=e.beginComputePass({});i.setPipeline(this.computePipeline),i.setBindGroup(0,this.computeBindGroupY),this.device.queue.writeTexture({texture:this.inputYTexture},(0,rt.s3)(o.f[20](t),this.inputYTexture.width*this.inputYTexture.height<<1),{offset:0,bytesPerRow:this.inputYTexture.width<<1,rowsPerImage:this.inputYTexture.height},{width:this.inputYTexture.width,height:this.inputYTexture.height,depthOrArrayLayers:1}),i.dispatchWorkgroups(this.inputYTexture.width+7>>>3,this.inputYTexture.height+7>>>3),i.setBindGroup(0,this.computeBindGroupU),this.device.queue.writeTexture({texture:this.inputUTexture},(0,rt.s3)(o.f[20](t+4),this.inputUTexture.width*this.inputUTexture.height<<1),{offset:0,bytesPerRow:this.inputUTexture.width<<1,rowsPerImage:this.inputUTexture.height},{width:this.inputUTexture.width,height:this.inputUTexture.height,depthOrArrayLayers:1}),i.dispatchWorkgroups(this.inputUTexture.width+7>>>3,this.inputUTexture.height+7>>>3),i.setBindGroup(0,this.computeBindGroupV),this.device.queue.writeTexture({texture:this.inputVTexture},(0,rt.s3)(o.f[20](t+8),this.inputVTexture.width*this.inputVTexture.height<<1),{offset:0,bytesPerRow:this.inputVTexture.width<<1,rowsPerImage:this.inputVTexture.height},{width:this.inputVTexture.width,height:this.inputVTexture.height,depthOrArrayLayers:1}),i.dispatchWorkgroups(this.inputVTexture.width+7>>>3,this.inputVTexture.height+7>>>3),i.end();const r=e.beginRenderPass({colorAttachments:[{view:this.context.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});r.executeBundles([this.renderBundle]),r.end(),this.device.queue.submit([e.finish()])}destroy(){this.inputYTexture&&(this.inputYTexture.destroy(),this.inputYTexture=null),this.inputUTexture&&(this.inputUTexture.destroy(),this.inputUTexture=null),this.inputVTexture&&(this.inputVTexture.destroy(),this.inputVTexture=null),this.metaYBuffer&&(this.metaYBuffer.destroy(),this.metaYBuffer=null),this.metaUBuffer&&(this.metaUBuffer.destroy(),this.metaUBuffer=null),this.metaVBuffer&&(this.metaVBuffer.destroy(),this.metaVBuffer=null),this.hdrMetadata&&((0,St.A)(this.hdrMetadata),this.hdrMetadata=null),this.computeModule=null,this.computeBindGroupY=null,this.computeBindGroupU=null,this.computeBindGroupV=null,this.computeBindGroupLayout=null,this.computePipelineLayout=null,this.computePipeline=null,super.destroy()}static isSupport(t){if(l.ai(t)){const e=st[o.f[15](t+80)];if(e)return e.depth+7>>>3==2}return!1}});const $t=[class extends ct{constructor(t,e){super(t,e)}generateFragmentSource(){const t=Tt(this.srcColorSpace,this.dstColorSpace,{bitDepth:8,type:0,outputRGB:!0});this.fragmentSource=`\n precision highp float;\n varying vec4 v_color;\n uniform sampler2D y_Sampler;\n uniform sampler2D u_Sampler;\n uniform sampler2D v_Sampler;\n void main () {\n vec4 color = vec4(texture2D(y_Sampler, v_color.xy).x, texture2D(u_Sampler, v_color.xy).x, texture2D(v_Sampler, v_color.xy).x, 1);\n ${t.reduce(((t,e)=>t+e),"")}\n gl_FragColor = color;\n }\n `}checkFrame(t){o.f[15](t+32)===this.textureWidth&&o.f[15](t+72)===this.videoHeight&&o.f[15](t+68)===this.videoWidth||(this.srcColorSpace=new Y(o.f[15](t+248),o.f[15](t+240),o.f[15](t+244),o.f[15](t+236)),this.generateFragmentSource(),this.program=new vt(this.fragmentSource),this.useProgram(),this.yTexture.setSize(o.f[15](t+32),o.f[15](t+72)),this.uTexture.setSize(o.f[15](t+32+4),o.f[15](t+72)>>>st[o.f[15](t+80)].log2ChromaH),this.vTexture.setSize(o.f[15](t+32+8),o.f[15](t+72)>>>st[o.f[15](t+80)].log2ChromaH),this.videoWidth=o.f[15](t+68),this.videoHeight=o.f[15](t+72),this.textureWidth=o.f[15](t+32),this.format=o.f[15](t+80),this.layout())}render(t){this.lost||(this.checkFrame(t),this.yTexture.fill((0,rt.s3)(o.f[20](t),this.yTexture.width*this.yTexture.height)),this.uTexture.fill((0,rt.s3)(o.f[20](t+4),this.uTexture.width*this.uTexture.height)),this.vTexture.fill((0,rt.s3)(o.f[20](t+8),this.vTexture.width*this.vTexture.height)),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4))}static isSupport(t){if(l.ai(t)){const e=st[o.f[15](t+80)];if(e)return e.depth+7>>>3==1}return!1}}];var Wt;$t.push(class extends ct{constructor(t,e){super(t,e),(0,x.A)(this,"hdrMetadata",void 0),(0,x.A)(this,"ext",void 0),this.hdrMetadata=(0,Bt.A)(Dt),this.hdrMetadata.multiplier=1}async init(){if(await super.init(),this.ext=this.gl.getExtension("EXT_texture_norm16"),!this.ext)throw Error("not support")}generateFragmentSource(t,e){e.outputRGB=!0;const i=Tt(this.srcColorSpace,this.dstColorSpace,e);this.fragmentSource=`\n precision highp float;\n\n varying vec4 v_color;\n uniform sampler2D y_Sampler;\n uniform sampler2D u_Sampler;\n uniform sampler2D v_Sampler;\n \n uniform float v_max;\n\n uniform float offset;\n uniform float multiplier;\n uniform float pq_tonemap_a;\n uniform float pq_tonemap_b;\n uniform float hlg_ootf_gamma_minus_one;\n uniform float hlg_dst_max_luminance_relative;\n uniform float nits_to_sdr_relative_factor;\n uniform float sdr_relative_to_nits_factor;\n\n ${1&t.flags?"\n float swap(float x) {\n int value = int(x * 65535.0);\n int low = value & 0xff;\n int high = (value >> 8) & 0xff;\n value = (low << 8) | high;\n return float(value) / v_max;\n }\n ":""}\n \n void main () {\n \n float y = texture2D(y_Sampler, v_color.xy).x;\n float u = texture2D(u_Sampler, v_color.xy).x;\n float v = texture2D(v_Sampler, v_color.xy).x;\n \n ${1&t.flags?"\n y = swap(y);\n u = swap(u);\n v = swap(v);\n ":"\n y = y * 65535.0 / v_max;\n u = u * 65535.0 / v_max;\n v = v * 65535.0 / v_max;\n "}\n \n vec4 color = vec4(y, u, v, 1.0);\n\n if (color.a > 0.0) {\n color.r /= color.a;\n color.g /= color.a;\n color.b /= color.a;\n }\n color.r -= offset;\n color.g -= offset;\n color.b -= offset;\n\n color.r *= multiplier;\n color.g *= multiplier;\n color.b *= multiplier;\n \n ${i.reduce(((t,e)=>t+e),"")}\n\n color.r *= color.a;\n color.g *= color.a;\n color.b *= color.a;\n\n gl_FragColor = color;\n }\n `}checkFrame(t){const e=st[o.f[15](t+80)];if(!e)return;const i=e.depth+7>>>3;if(o.f[15](t+32)/i!==this.textureWidth||o.f[15](t+72)!==this.videoHeight||o.f[15](t+68)!==this.videoWidth||o.f[15](t+80)!==this.format){this.srcColorSpace=new Y(o.f[15](t+248),o.f[15](t+240),o.f[15](t+244),o.f[15](t+236));const i={type:0,bitDepth:e.depth,toneMapPQAndHlgToDst:!0,metadata:this.hdrMetadata,dstSdrMaxLuminanceNits:At,dstMaxLuminanceRelative:1},r=(0,Lt.aH)(t,14);if(r){const t=o.f[20](r+4);o.f[8](t)>0&&(i.maxContentLightLevel=o.f[8](t))}this.generateFragmentSource(e,i),this.program=new Ft(this.fragmentSource),this.useProgram(),this.program.setMetaData(this.hdrMetadata),this.yTexture.setFormat(this.gl.RED),this.yTexture.setInternalformat(this.ext.R16_EXT),this.yTexture.setDataType(this.gl.UNSIGNED_SHORT),this.uTexture.setFormat(this.gl.RED),this.uTexture.setInternalformat(this.ext.R16_EXT),this.uTexture.setDataType(this.gl.UNSIGNED_SHORT),this.vTexture.setFormat(this.gl.RED),this.vTexture.setInternalformat(this.ext.R16_EXT),this.vTexture.setDataType(this.gl.UNSIGNED_SHORT),this.yTexture.setSize(o.f[15](t+32)>>>1,o.f[15](t+72)),this.uTexture.setSize(o.f[15](t+32+4)>>>1,o.f[15](t+72)>>>st[o.f[15](t+80)].log2ChromaH),this.vTexture.setSize(o.f[15](t+32+8)>>>1,o.f[15](t+72)>>>st[o.f[15](t+80)].log2ChromaH),this.program.setMax(e.max),this.videoWidth=o.f[15](t+68),this.videoHeight=o.f[15](t+72),this.textureWidth=o.f[15](t+32)>>>1,this.format=o.f[15](t+80),this.layout()}}render(t){this.lost||(this.checkFrame(t),this.yTexture.fill((0,rt.bg)(o.f[20](t),this.yTexture.width*this.yTexture.height)),this.uTexture.fill((0,rt.bg)(o.f[20](t+4),this.uTexture.width*this.uTexture.height)),this.vTexture.fill((0,rt.bg)(o.f[20](t+8),this.vTexture.width*this.vTexture.height)),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4))}destroy(){this.hdrMetadata&&((0,St.A)(this.hdrMetadata),this.hdrMetadata=null),super.destroy()}static isSupport(t){if(l.ai(t)){const e=st[o.f[15](t+80)];if(e)return e.depth+7>>>3==2}return!1}}),function(t){t[t.None=0]="None",t[t.Accelerate=1]="Accelerate",t[t.Decelerate=2]="Decelerate"}(Wt||(Wt={}));const Gt=["bt2020","bt2100","st2048","p3-dcl","hlg"];class qt extends c.A{constructor(){super()}async createTask(t){const e=new d.Ay(t.leftPort),i=new d.Ay(t.controlPort),r={...t,leftIPCPort:e,controlIPCPort:i,render:null,currentPTS:y.Dh,firstPTS:BigInt(0),startTimestamp:BigInt(0),playRate:BigInt(100),targetRate:BigInt(100),frontFrame:null,backFrame:null,renderFrame:null,renderFrameCount:BigInt(0),loop:null,renderRedyed:!1,adjust:Wt.None,adjustDiff:BigInt(0),lastAdjustTimestamp:BigInt(0),firstRendered:!1,canvasUpdated:!1,renderCreating:!1,pauseTimestamp:0,lastNotifyPTS:BigInt(0),skipRender:!1,isSupport:()=>!1,frontBuffered:!1,ended:!1,seeking:!1,seekSync:null,afterPullResolver:null,pausing:!1,lastRenderTimestamp:0,avframePool:new p.A((0,n.A)(t.avframeList,a.A),t.avframeListMutex)};return r.startPTS=(0,A.k)(r.startPTS,r.timeBase,y.i0),i.on(d.Wo,(async t=>{switch(t.method){case"syncPts":{const e=t.params.pts,i=Math.abs(Number(e-r.currentPTS));i>100&&r.currentPTS>BigInt(0)&&(e>r.currentPTS?(r.adjust=Wt.Accelerate,b.Yz(`video render sync pts accelerate, targetPTS: ${e}, currentPTS: ${r.currentPTS}, diff: ${i}, taskId: ${r.taskId}`,Vt,226)):(r.adjust=Wt.Decelerate,b.Yz(`video render sync pts decelerate, targetPTS: ${e}, currentPTS: ${r.currentPTS}, diff: ${i} taskId: ${r.taskId}`,Vt,230)),r.adjustDiff=BigInt(Math.floor(i)));break}case"skipRender":r.skipRender=t.params.skipRender}})),this.tasks.set(t.taskId,r),0}async createRender(t,e){var i,r,s,a;t.renderCreating||(t.renderCreating=!0,t.renderRedyed=!1,t.render&&t.render.destroy(),l.ai(e)?t.enableWebGPU&&m.A.webgpu?f.__(Nt,(i=>{if(i.isSupport(e))return t.render=new i(t.canvas,{devicePixelRatio:t.devicePixelRatio,renderMode:t.renderMode,onRenderContextLost:()=>{t.canvasUpdated=!1,t.renderRedyed=!1,b.R8("render context lost",Vt,301),t.controlIPCPort.notify("updateCanvas")}}),t.isSupport=i.isSupport,!1})):f.__($t,(i=>{if(i.isSupport(e))return t.render=new i(t.canvas,{devicePixelRatio:t.devicePixelRatio,renderMode:t.renderMode,onRenderContextLost:()=>{t.canvasUpdated=!1,t.renderRedyed=!1,b.R8("render context lost",Vt,319),t.controlIPCPort.notify("updateCanvas")}}),t.isSupport=i.isSupport,!1})):t.enableWebGPU&&m.A.webgpu&&w.A.chrome&&w.A.checkVersion(w.A.majorVersion,"116",!0)&&(a=e.colorSpace.primaries,!f.zy(Gt,a))?(t.render=new it(t.canvas,{devicePixelRatio:t.devicePixelRatio,renderMode:t.renderMode,onRenderContextLost:()=>{t.canvasUpdated=!1,t.renderRedyed=!1,b.R8("render context lost",Vt,275),t.controlIPCPort.notify("updateCanvas")}}),t.isSupport=it.isSupport):(t.render=new J(t.canvas,{devicePixelRatio:t.devicePixelRatio,renderMode:t.renderMode}),t.isSupport=J.isSupport),t.render?(await t.render.init(),t.render.viewport(t.viewportWidth,t.viewportHeight),t.render.clear(),t.render.setRotate(null!==(i=t.renderRotate)&&void 0!==i?i:0),t.render.enableHorizontalFlip(null!==(r=t.flipHorizontal)&&void 0!==r&&r),t.render.enableVerticalFlip(null!==(s=t.flipVertical)&&void 0!==s&&s),t.renderRedyed=!0,t.renderCreating=!1):t.renderCreating=!1)}async play(t){const e=this.tasks.get(t);if(e){if(e.loop&&b.h2("task has already call play",Vt,348),e.backFrame=await e.leftIPCPort.request("pull"),l.ai(e.backFrame)&&e.backFrame<0)return e.backFrame=0,b.pq(`video render ended, taskId: ${e.taskId}`,Vt,355),void e.controlIPCPort.notify("ended");e.frontFrame=await e.leftIPCPort.request("pull"),e.frontBuffered=!0,e.ended=!1,l.ai(e.frontFrame)&&e.frontFrame<0&&(e.ended=!0,e.frontBuffered=!1,e.frontFrame=0);const i=this;function r(){if(e.seeking)return;if(e.backFrame&&(l.ai(e.backFrame)?e.avframePool.release(e.backFrame):e.backFrame.close()),e.backFrame=null,!e.frontBuffered)return!1;if(e.backFrame=e.frontFrame,e.frontFrame=null,e.ended)return;e.frontBuffered=!1;const t=(0,v.A)();return e.leftIPCPort.request("pull").then((i=>{if(e.afterPullResolver&&e.afterPullResolver(),l.ai(i)&&i<0)return e.ended=!0,void(e.frontFrame=null);const s=(0,v.A)()-t;if(s>1e3&&(e.startTimestamp+=BigInt(Math.floor(s))),e.frontFrame=i,e.frontBuffered=!0,e.seekSync)return e.seekSync(),void(e.seekSync=null);e.backFrame||r()})),!0}await this.createRender(e,e.backFrame),e.firstPTS=(0,A.k)(l.ai(e.backFrame)?o.f[17](e.backFrame+104):BigInt(Math.floor(e.backFrame.timestamp)),e.timeBase,y.i0),b.Yz(`got first video frame, pts: ${l.ai(e.backFrame)?o.f[17](e.backFrame+104):BigInt(Math.floor(e.backFrame.timestamp))}(${e.firstPTS}ms), taskId: ${e.taskId}`,Vt,446),e.firstPTS{if(!e.backFrame)return void(e.ended?(e.render&&e.renderRedyed&&e.render.clear(),e.loop.stop(),e.adjust=Wt.None,b.pq(`video render ended, taskId: ${e.taskId}`,Vt,472),e.controlIPCPort.notify("ended")):e.loop.emptyTask());if(!e.isSupport(e.backFrame)){if(e.render)return e.renderRedyed=!1,e.renderFrame=e.backFrame,void e.controlIPCPort.notify("updateCanvas");this.createRender(e,e.backFrame)}const t=(0,A.k)(l.ai(e.backFrame)?o.f[17](e.backFrame+104):BigInt(Math.floor(e.backFrame.timestamp)),e.timeBase,y.i0);if(tBigInt(1e6)))return b.R8(`dropping frame with pts ${t}, which is earlier then the last rendered frame(${e.currentPTS}), taskId: ${e.taskId}`,Vt,502),void r();e.startTimestamp=BigInt(Math.floor((0,v.A)()))-t*BigInt(100)/e.targetRate}if(e.adjust===Wt.Accelerate){if(e.adjustDiff<=0)e.adjust=Wt.None,e.startTimestamp=BigInt(Math.floor((0,v.A)()))-t*BigInt(100)/e.targetRate,e.lastAdjustTimestamp=BigInt(0);else if(BigInt(Math.floor((0,v.A)()))-e.lastAdjustTimestamp>=BigInt(200)){const t=e.adjustDiff<=BigInt(100)?e.adjustDiff:k.jk(e.adjustDiff,BigInt(100))*BigInt(100)/e.targetRate;e.startTimestamp-=t,e.adjustDiff-=t,b.Yz(`video render accelerate startTimestamp sub: ${t}, taskId: ${e.taskId}`,Vt,523),e.lastAdjustTimestamp=BigInt(Math.floor((0,v.A)()))}}else if(e.adjust===Wt.Decelerate)if(e.adjustDiff<=0)e.adjust=Wt.None,e.startTimestamp=BigInt(Math.floor((0,v.A)()))-t*BigInt(100)/e.targetRate,e.lastAdjustTimestamp=BigInt(0);else if(BigInt(Math.floor((0,v.A)()))-e.lastAdjustTimestamp>=BigInt(300)){const t=e.adjustDiff=BigInt(1e3)&&(e.lastNotifyPTS=t,e.controlIPCPort.notify("syncPts",{pts:t})),r()):e.loop.emptyTask()}),0,0),e.loop.start()}else b.h2("task not found",Vt,615)}async restart(t){const e=this.tasks.get(t);e&&(e.loop||b.h2("task has not played",Vt,623),e.loop.isStarted()&&b.h2("task has already run",Vt,627),e.backFrame&&(l.ai(e.backFrame)?e.avframePool.release(e.backFrame):e.backFrame.close()),e.frontFrame&&(l.ai(e.frontFrame)?e.avframePool.release(e.frontFrame):e.frontFrame.close()),e.backFrame=await e.leftIPCPort.request("pull"),e.frontFrame=await e.leftIPCPort.request("pull"),e.frontBuffered=!0,e.ended=!1,e.adjust=Wt.None,e.lastNotifyPTS=y.Dh,e.firstRendered=!1,e.firstPTS=(0,A.k)(l.ai(e.backFrame)?o.f[17](e.backFrame+104):BigInt(Math.floor(e.backFrame.timestamp)),e.timeBase,y.i0),e.currentPTS=e.firstPTS,e.firstPTS!1,i.canvasUpdated=!0,i.firstRendered=!1,i.renderRedyed=!1):b.h2("task not found",Vt,724)}async setPlayRate(t,e){const i=this.tasks.get(t);i?(i.enableJitterBuffer&&o.f[15](i.stats+112)/o.f[15](i.stats+200)*1e3<=o.f[15](i.jitterBuffer)&&(e=1),i.targetRate=BigInt(Math.floor(Math.floor(100*e)))):b.h2("task not found",Vt,740)}async setRenderMode(t,e){const i=this.tasks.get(t);i?i.render&&(i.renderMode=e,i.render.setRenderMode(e)):b.h2("task not found",Vt,753)}async setRenderRotate(t,e){const i=this.tasks.get(t);i?i.render&&(i.renderRotate=e,i.render.setRotate(e)):b.h2("task not found",Vt,766)}async enableHorizontalFlip(t,e){const i=this.tasks.get(t);i?i.render&&(i.flipHorizontal=e,i.render.enableHorizontalFlip(e)):b.h2("task not found",Vt,779)}async enableVerticalFlip(t,e){const i=this.tasks.get(t);i?i.render&&(i.flipVertical=e,i.render.enableVerticalFlip(e)):b.h2("task not found",Vt,792)}async resize(t,e,i){const r=this.tasks.get(t);r?r.render&&r.render.viewport(e,i):b.h2("task not found",Vt,804)}async setSkipRender(t,e){const i=this.tasks.get(t);i?i.skipRender=e:b.h2("task not found",Vt,814)}async beforeSeek(t){const e=this.tasks.get(t);e&&(e.ended||e.frontBuffered||(b.Yz(`wait current pull front frame before seek, taskId: ${e.taskId}`,Vt,823),await new(s())((t=>{e.seekSync=t}))),e.seeking=!0,e.loop.stop(),e.backFrame&&(l.ai(e.backFrame)?e.avframePool.release(e.backFrame):e.backFrame.close()),e.frontFrame&&(l.ai(e.frontFrame)?e.avframePool.release(e.frontFrame):e.frontFrame.close()),e.frontFrame=null,e.backFrame=null,e.currentPTS=y.Dh,b.Yz(`before seek end, taskId: ${e.taskId}`,Vt,851))}async syncSeekTime(t,e,i){const r=this.tasks.get(t);if(r){for(;;){if(r.backFrame=await r.leftIPCPort.request("pull"),l.ai(r.backFrame)&&r.backFrame<0)return r.ended=!0,r.seeking=!1,r.adjust=Wt.None,b.R8(`pull video frame end after seek, taskId: ${t}`,Vt,866),void r.controlIPCPort.notify("ended");if(e=e)break;l.ai(r.backFrame)?r.avframePool.release(r.backFrame):r.backFrame.close()}b.Yz(`sync seek time end, taskId: ${r.taskId}`,Vt,899)}}async afterSeek(t,e){const i=this.tasks.get(t);i&&(i.startTimestamp=BigInt(Math.floor((0,v.A)()))-(e+i.startPTS)*BigInt(100)/i.playRate,i.frontFrame=await i.leftIPCPort.request("pull"),l.ai(i.frontFrame)&&i.frontFrame<0?(i.frontFrame=null,i.frontBuffered=!1,i.ended=!0):i.frontBuffered=!0,i.ended=!1,i.adjust=Wt.None,i.lastRenderTimestamp=(0,v.A)(),i.currentPTS=(0,A.k)(l.ai(i.backFrame)?o.f[17](i.backFrame+104):BigInt(Math.floor(i.backFrame.timestamp)),i.timeBase,y.i0),b.Yz(`got first video frame, pts: ${l.ai(i.backFrame)?o.f[17](i.backFrame+104):BigInt(Math.floor(i.backFrame.timestamp))}(${i.currentPTS}ms), taskId: ${i.taskId}`,Vt,928),i.seeking=!1,i.pausing||i.loop.start(),b.Yz(`after seek end, taskId: ${i.taskId}`,Vt,937))}async registerTask(t){return this.tasks.has(t.taskId)?u.lh:await this.createTask(t)}async unregisterTask(t){const e=this.tasks.get(t);e&&(e.loop&&(await e.loop.stopBeforeNextTick(),e.loop.destroy(),e.loop=null),e.ended||e.frontFrame||await new(s())((t=>{e.afterPullResolver=t})),e.render&&(e.render.destroy(),e.render=null),e.backFrame&&(l.ai(e.backFrame)&&e.backFrame>0?e.avframePool.release(e.backFrame):e.backFrame.close(),e.backFrame=null),e.frontFrame&&(l.ai(e.frontFrame)&&e.frontFrame>0?e.avframePool.release(e.frontFrame):e.frontFrame.close(),e.frontFrame=null),e.leftIPCPort.destroy(),e.controlIPCPort.destroy(),this.tasks.delete(t))}}},9510:(t,e,i)=>{"use strict";i.d(e,{default:()=>Kt});var r,s,a=i(1026),n=i(662),o=i.n(n),h=i(4001),c=i.n(h),u=i(3146),d=i.n(u),l=i(1499),f=i(2085),p=i(2264),m=i(3783);class g{constructor(){(0,a.A)(this,"min",void 0),(0,a.A)(this,"max",void 0)}}r=g.prototype,(s=new(o())).set("min",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),s.set("max",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:4,8:0}),(0,f.A)(r,l.Og,!0),(0,f.A)(r,l.dc,4),(0,f.A)(r,l.g7,8),(0,f.A)(r,l.JY,s);var v=i(4503),A=i(3939),y=i(9599),w=i(915),b=i(4300),k=i(115),x=i(4582),_=i(3823),P=i(8393),T=i(5062),I=i.n(T),C=i(4059),B=i(4149),S=i(1837),M=i(6429),R=i(7672),U=i(576),E=i(2100);let D=U.TK.Worker,L=U.TK.MessageChannel;i(1574),i(6848),i(7524);const F=(0,S.A)(1574,{varName:"init"}),z=((0,S.A)(6848,{varName:"init"}),(0,S.A)(7524,{varName:"init"}),I()("revoke")),O=new(o());function V(t,e){return`${t}_${e}`}function N(t,e={},i){let r,s=[];function a(...e){const r=new t(...e);return new(c())((e=>{const s={$worker:null,$ipc:null,$channel:null,$moduleId:(0,E.A)(i),$stackPointer:0,$instance:r,$type:"class"},{proxy:a,revoke:n}=Proxy.revocable(s,{get(e,i,a){if(e[i])return s[i];if(i in t.prototype&&"function"==typeof t.prototype[i]){const t=function(...t){return r[i](...t)};t.transfer=function(...t){return{invoke:function(...t){return r[i](...t)}}},e[i]=t}return e[i]}});s[z]=n,e(a)}))}return r=(...r)=>{let a;if(i instanceof D)a=i;else{let e;const r=V(i,"class");if(O.has(r))e=O.get(r).url,O.get(r).refCount++;else{const s=`\n ${(0,S.A)(i,{varName:`__module_${t.name}__`,exportName:`__${t.name}__`,pointName:t.name,exportIsClass:!0})}\n function run(params) {\n params.unshift(null)\n return new (Function.prototype.bind.apply(__module_${t.name}__.__${t.name}__, params))()\n }\n ${F}\n init.default(run);\n `;{const t=new Blob([s],{type:"text/javascript"});e=URL.createObjectURL(t)}O.set(r,{url:e,refCount:1})}a=new D(e)}const n=new L;return new(c())(((o,h)=>{var c;const u=C.s_.alignedAlloc(M.ZI,e.stackSize?e.stackSize+M.ZI&~M.ZI:M.pw),d=e=>{const h=e.data,c=h.type;switch(h.data,c){case"ready":a.postMessage({type:"run",data:{port:n.port2,params:r}},[n.port2,...s]);break;case"running":!function(){const e=new B.Ay(n.port1),r={$worker:a,$ipc:e,$channel:n,$moduleId:(0,E.A)(i),$stackPointer:u,$type:"class"},{proxy:s,revoke:h}=Proxy.revocable(r,{get(i,s,a){if(i[s])return r[s];if(s in t.prototype&&"function"==typeof t.prototype[s]){const t=async function(...t){return e.request(s,{params:t})};t.transfer=function(...t){return{invoke:async function(...i){return e.request(s,{params:i},t)}}},i[s]=t}return i[s]}});r[z]=h,o(s)}()}};a.onmessage=d,a.onmessage=d,a.postMessage({type:"init",data:{memory:C.ce,name:e.name||t.name,stackPointer:u,stackSize:null!==(c=e.stackSize)&&void 0!==c?c:M.pw}})}))},{run:M._7&&!e.disableWorker?r:a,transfer:function(...t){return s=t,{run:M._7&&!e.disableWorker?r:a}}}}function $(t){if(t.$worker&&(t.$worker.terminate(),t.$worker=null),t.$moduleId){if(R.Yj(t.$moduleId)){const e=V(t.$moduleId,t.$type);O.has(e)&&(O.get(e).refCount--,0===O.get(e).refCount&&(URL.revokeObjectURL(O.get(e).url),O.delete(e)))}t.$moduleId=null}if(t.$ipc&&(t.$ipc.destroy(),t.$ipc=null),t.$stackPointer&&(C.s_.free(t.$stackPointer),t.$stackPointer=0),t.$channel=null,t.$instance=null,t[z]){const e=t[z];t[z]=null,e()}}var W=i(2758);function G(){let t=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){let i=(t+16*Math.random())%16|0;return t=Math.floor(t/16),("x"==e?i:3&i|8).toString(16)}))}var q=i(5335),j=i(4175),H=i(11);class Q{constructor(t=1048576,e=!0,i){if((0,a.A)(this,"data",void 0),(0,a.A)(this,"buffer",void 0),(0,a.A)(this,"pointer",void 0),(0,a.A)(this,"pos",void 0),(0,a.A)(this,"size",void 0),(0,a.A)(this,"littleEndian",void 0),(0,a.A)(this,"error",void 0),(0,a.A)(this,"onFlush",void 0),(0,a.A)(this,"onSeek",void 0),this.pointer=0,this.pos=BigInt(0),this.size=t,this.littleEndian=!e,this.error=0,i&&i.view)this.size=i.length,this.buffer=i,this.data=i.view;else if(i&&!i.byteOffset)this.size=i.length,this.buffer=i,this.data=new DataView(this.buffer.buffer);else{if(i)throw new Error("not support subarray of ArrayBuffer");this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}async writeUint8(t){this.remainingLength()<1&&await this.flush(),this.data.setUint8(this.pointer,t),this.pointer++,this.pos++}async writeUint16(t){this.remainingLength()<2&&await this.flush(),this.data.setUint16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}async writeUint24(t){this.remainingLength()<3&&await this.flush();const e=(16711680&t)>>16,i=(65280&t)>>8,r=255&t;this.littleEndian?(await this.writeUint8(r),await this.writeUint8(i),await this.writeUint8(e)):(await this.writeUint8(e),await this.writeUint8(i),await this.writeUint8(r))}async writeUint32(t){this.remainingLength()<4&&await this.flush(),this.data.setUint32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeUint64(t){this.remainingLength()<8&&await this.flush(),this.data.setBigUint64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}async writeInt8(t){this.remainingLength()<1&&await this.flush(),this.data.setInt8(this.pointer,t),this.pointer++,this.pos++}async writeInt16(t){this.remainingLength()<2&&await this.flush(),this.data.setInt16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}async writeInt32(t){this.remainingLength()<4&&await this.flush(),this.data.setInt32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeInt64(t){this.remainingLength()<8&&await this.flush(),this.data.setBigInt64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}async writeFloat(t){this.remainingLength()<4&&await this.flush(),this.data.setFloat32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeDouble(t){this.remainingLength()<8&&await this.flush(),this.data.setFloat64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}getPointer(){return this.pointer}getPos(){return this.pos}remainingLength(){return this.size-this.pointer}async writeBuffer(t){if(!t.length)return;let e=t.length;if(this.remainingLength()0;){await this.flush();const r=Math.min(this.size,e);this.buffer.set(t.subarray(i,i+r),this.pointer),this.pointer+=r,this.pos+=BigInt(r),i+=r,e-=r}}else this.buffer.set(t,this.pointer),this.pointer+=e,this.pos+=BigInt(e)}async writeString(t){const e=H.l(t);return await this.writeBuffer(e),e.length}encodeString(t){return H.l(t)}async flush(){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const t=await this.onFlush(this.buffer.subarray(0,this.pointer));if(0!==t)throw this.error=t,Error("IOWriter error, flush failed")}this.pointer=0}async flushToPos(t){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const e=await this.onFlush(this.buffer.subarray(0,this.pointer),t);if(0!==e)throw this.error=e,Error("IOWriter error, flush failed")}this.pointer=0}async seek(t){if(!this.onSeek)throw this.error=-1048574,Error("IOWriter error, seek failed because of no seek callback");await this.flush();const e=await this.onSeek(t);if(0!==e)throw this.error=e,Error("IOWriter error, seek failed");this.pos=t}seekInline(t){const e=this.pointer;this.pointer=Math.max(0,Math.min(this.size,t)),this.pos+=BigInt(this.pointer-e)}skip(t){const e=this.pointer;this.pointer=Math.min(this.size,this.pointer+t),this.pos+=BigInt(this.pointer-e)}back(t){const e=this.pointer;this.pointer=Math.max(0,this.pointer-t),this.pos+=BigInt(this.pointer-e)}getBuffer(){return this.buffer.subarray(0,this.pointer)}setEndian(t){this.littleEndian=!t}reset(){this.pointer=0,this.pos=BigInt(0),this.error=0}getBufferSize(){return this.size}}var Y=i(8096),K=i(2647);async function J(t,e={}){let i,r,s,a;if(e=q.X$({enableThread:M._7,initFuncs:e.child?[]:["__wasm_apply_data_relocs"]},e),R.ai(t.dataSize)&&R.ai(t.tableSize))if(r=t.dataSize,s=t.dataSize,R.Yj(t.source)){const e={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};if(R.Pc(WebAssembly.compileStreaming))i=await WebAssembly.compileStreaming(fetch(t.source,e));else{const r=await fetch(t.source,e);a=await r.arrayBuffer(),i=await WebAssembly.compile(a)}}else i=await WebAssembly.compile(t.source),a=R.sv(t.source)?t.source:t.source.buffer;else{const n={ioReader:new j.A(1048576),ioWriter:new Q(1048576),bufferEnded:!1,compileStopped:!1,error:"",abortController:null,pullResolve:null,bufferResolve:null,buffers:[],data:{},options:e},o=new Response(new ReadableStream({async start(e){if(R.Yj(t.source)){var i;AbortController&&(n.abortController=new AbortController);const r={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade",signal:null===(i=n.abortController)||void 0===i?void 0:i.signal},s=await fetch(t.source,r);let a;s.ok&&s.status>=200&&s.status<=299?a=s.body.getReader():e.error(`Http code invalid, ${s.status} ${s.statusText}`);const o=[];n.ioReader.onFlush=async t=>{let e=0;for(;o.length&&et.length-e?(t.set(i.subarray(0,t.length-e),e),o.unshift(i.subarray(t.length-e)),e=t.length):(t.set(i,e),e+=i.length)}if(e>=t.length)return t.length;const{value:i,done:r}=await a.read();return r?e>0?e:-1048576:(n.buffers.push(i),i.length>t.length-e?(t.set(i.subarray(0,t.length-e),e),o.push(i.subarray(t.length-e)),t.length):(t.set(i,e),e+=i.length,e))}}else{let e=0,i=t.source.byteLength;const r=R.sv(t.source)?new Uint8Array(t.source):t.source;n.ioReader.onFlush=async t=>{if(e>=i)return-1048576;const s=Math.min(t.length,i-e);return t.set(r.subarray(e,e+s),0),e+=s,s}}n.ioWriter.onFlush=async t=>n.pullResolve?(n.pullResolve(t.slice()),n.pullResolve=null,0):((await new(c())(((t,e)=>{n.bufferResolve=t}))).enqueue(t.slice()),0),async function(t){try{for(await t.ioWriter.writeUint32(await t.ioReader.readUint32()),await t.ioWriter.writeUint32(await t.ioReader.readUint32());;){if(t.compileStopped){t.abortController&&t.abortController.abort();break}const e=await t.ioReader.readUint8();if(t.options.child&&11===e){await t.ioWriter.writeUint8(e),await(0,Y.$z)(t.ioWriter,7),await(0,Y.$z)(t.ioWriter,1),await(0,Y.$z)(t.ioWriter,0),await t.ioWriter.writeUint8(65),await t.ioWriter.writeUint8(0),await t.ioWriter.writeUint8(11),await(0,Y.$z)(t.ioWriter,1),await t.ioWriter.writeUint8(0);const i=await(0,Y.GG)(t.ioReader);await t.ioReader.skip(i);continue}await t.ioWriter.writeUint8(e);const i=await(0,Y.GG)(t.ioReader);await(0,Y.$z)(t.ioWriter,i);const r=t.ioReader.getPos();if(11===e){const e=await(0,Y.GG)(t.ioReader);if(await(0,Y.$z)(t.ioWriter,e),e){for(await(0,Y.$z)(t.ioWriter,await(0,Y.GG)(t.ioReader));;){const e=await t.ioReader.readUint8();if(await t.ioWriter.writeUint8(e),11===e)break}t.data.dataSize=await(0,Y.GG)(t.ioReader),await(0,Y.$z)(t.ioWriter,t.data.dataSize)}}else if(2===e){let e=await(0,Y.GG)(t.ioReader);await(0,Y.$z)(t.ioWriter,e);let i=0;for(;e--;){const e=await(0,Y.GG)(t.ioReader);await(0,Y.$z)(t.ioWriter,e),await t.ioWriter.writeBuffer(await t.ioReader.readBuffer(e));const r=await(0,Y.GG)(t.ioReader);await(0,Y.$z)(t.ioWriter,r),await t.ioWriter.writeBuffer(await t.ioReader.readBuffer(r));const s=await t.ioReader.readUint8();switch(await t.ioWriter.writeUint8(s),s){case 0:await(0,Y.$z)(t.ioWriter,await(0,Y.GG)(t.ioReader));break;case 3:await(0,Y.p7)(t.ioWriter,await(0,Y.Ee)(t.ioReader)),await(0,Y.$z)(t.ioWriter,await(0,Y.GG)(t.ioReader));break;case 2:{let e=await(0,Y.GG)(t.ioReader);t.options.enableThread?e|=2:e&=-3,await(0,Y.$z)(t.ioWriter,e),await(0,Y.$z)(t.ioWriter,await(0,Y.GG)(t.ioReader)),1&e&&await(0,Y.$z)(t.ioWriter,await(0,Y.GG)(t.ioReader)),i++;break}case 1:{await(0,Y.p7)(t.ioWriter,await(0,Y.Ee)(t.ioReader));const e=await(0,Y.GG)(t.ioReader);await(0,Y.$z)(t.ioWriter,e);const r=await(0,Y.GG)(t.ioReader);await(0,Y.$z)(t.ioWriter,r),t.data.tableSize=r,1&e&&await(0,Y.$z)(t.ioWriter,await(0,Y.GG)(t.ioReader)),i++;break}}if(2===i)break}}i-Number(t.ioReader.getPos()-r)&&await t.ioReader.pipe(t.ioWriter,i-Number(t.ioReader.getPos()-r))}}catch(e){-1048576===t.ioReader.error?t.bufferEnded=!0:t.error=e,t.ioReader.remainingLength()&&await t.ioWriter.writeBuffer(await t.ioReader.readBuffer(t.ioReader.remainingLength())),await t.ioWriter.flush()}}(n)},async pull(t){if(n.error)t.close();else{if(n.bufferResolve)return n.bufferResolve(t),void(n.bufferResolve=null);t.enqueue(await new(c())(((t,e)=>{n.pullResolve=t}))),n.bufferEnded?t.close():n.error&&t.error(n.error)}},cancel(t){n.compileStopped=!0}}),{headers:{"Content-Type":"application/wasm"}});i=R.Pc(WebAssembly.compileStreaming)?await WebAssembly.compileStreaming(o):await WebAssembly.compile(await o.arrayBuffer()),a=R.Yj(t.source)?(0,K.A)(Uint8Array,n.buffers).buffer:R.sv(t.source)?t.source:t.source.buffer,r=n.data.tableSize,s=n.data.dataSize}return e.child?{module:i,initFuncs:e.initFuncs||[]}:{module:i,tableSize:r,dataSize:s,initFuncs:e.initFuncs||[],buffer:a}}var X=i(4363),Z=i(1517),tt=i(5181),et=i(7303),it=i(8507);class rt{constructor(t,e,i,r={}){(0,a.A)(this,"audioWorkletNode",void 0),(0,a.A)(this,"ipcPort",void 0),(0,a.A)(this,"observer",void 0),this.observer=e,this.audioWorkletNode=new AudioWorkletNode(t,i,r),this.ipcPort=new B.Ay(this.audioWorkletNode.port),this.ipcPort.on(B.Wo,(t=>{switch(t.method){case"ended":this.observer.onEnded();break;case"firstRendered":this.observer.onFirstRendered();break;case"stutter":this.observer.onStutter()}}))}async request(t,e,i){return this.ipcPort.request(t,e,i)}connect(t){this.audioWorkletNode.connect(t)}getNode(){return this.audioWorkletNode}disconnect(){this.audioWorkletNode.disconnect()}getParameters(t){const e=this.audioWorkletNode.parameters;if(R.Pc(e.get))return e.get(t);e.forEach(((e,i)=>{if(i===t)return e}))}}class st extends rt{constructor(t,e,i={}){super(t,e,"audio-source-processor",i)}}class at extends EventTarget{constructor(...t){super(...t),(0,a.A)(this,"peer",void 0),(0,a.A)(this,"onmessage",void 0),(0,a.A)(this,"onmessageerror",void 0)}postMessage(t,e){var i;null!==(i=this.peer)&&void 0!==i&&i.onmessage&&this.peer.onmessage({data:t})}close(){this.peer=null}start(){}}class nt{constructor(){(0,a.A)(this,"port1",void 0),(0,a.A)(this,"port2",void 0),this.port1=new at,this.port2=new at,this.port1.peer=this.port2,this.port2.peer=this.port1}}function ot(){return M._7?new MessageChannel:new nt}class ht{constructor(t){(0,a.A)(this,"videoRenderControlChannel",void 0),(0,a.A)(this,"audioRenderControlChannel",void 0),(0,a.A)(this,"muxerControlChannel",void 0),(0,a.A)(this,"videoRenderControlIPCPort",void 0),(0,a.A)(this,"audioRenderControlIPCPort",void 0),(0,a.A)(this,"muxerControlIPCPort",void 0),(0,a.A)(this,"observer",void 0),(0,a.A)(this,"visibilityHidden",void 0),(0,a.A)(this,"onVisibilityChange",void 0),(0,a.A)(this,"timeUpdateListenType",void 0),(0,a.A)(this,"enableAudioVideoSync",void 0),this.observer=t,this.videoRenderControlChannel=ot(),this.audioRenderControlChannel=ot(),this.muxerControlChannel=ot(),this.videoRenderControlIPCPort=new B.Ay(this.videoRenderControlChannel.port2),this.audioRenderControlIPCPort=new B.Ay(this.audioRenderControlChannel.port2),this.muxerControlIPCPort=new B.Ay(this.muxerControlChannel.port2),this.enableAudioVideoSync=!0,this.videoRenderControlIPCPort.on(B.Wo,(t=>{switch(t.method){case"ended":this.observer.onVideoEnded();break;case"updateCanvas":this.observer.onCanvasUpdated();break;case"firstRendered":this.observer.onFirstVideoRendered();break;case"firstRenderedAfterUpdateCanvas":this.observer.onFirstVideoRenderedAfterUpdateCanvas();break;case"syncPts":0===this.timeUpdateListenType&&this.observer.onTimeUpdate(t.params.pts)}})),this.audioRenderControlIPCPort.on(B.Wo,(t=>{switch(t.method){case"syncPts":this.enableAudioVideoSync&&this.videoRenderControlIPCPort.notify("syncPts",t.params),1===this.timeUpdateListenType&&this.observer.onTimeUpdate(t.params.pts);break;case"ended":this.observer.onAudioEnded()}})),this.muxerControlIPCPort.on(B.Wo,(t=>{"seek"===t.method&&this.observer.onMSESeek(t.params.time)})),this.onVisibilityChange=t=>{this.visibilityHidden="hidden"===document.visibilityState,this.videoRenderControlIPCPort.notify("skipRender",{skipRender:this.visibilityHidden})},this.visibilityHidden="hidden"===document.visibilityState,document.addEventListener("visibilitychange",this.onVisibilityChange)}getVideoRenderControlPort(){return this.videoRenderControlChannel.port1}getAudioRenderControlPort(){return this.audioRenderControlChannel.port1}getMuxerRenderControlPort(){return this.muxerControlChannel.port1}setTimeUpdateListenType(t){this.timeUpdateListenType=t}setEnableAudioVideoSync(t){this.enableAudioVideoSync=t}destroy(){this.videoRenderControlIPCPort&&this.videoRenderControlIPCPort.destroy(),this.audioRenderControlIPCPort&&this.audioRenderControlIPCPort.destroy(),this.muxerControlIPCPort&&this.muxerControlIPCPort.destroy(),this.onVisibilityChange&&(document.removeEventListener("visibilitychange",this.onVisibilityChange),this.onVisibilityChange=null),this.videoRenderControlIPCPort=this.audioRenderControlIPCPort=this.muxerControlIPCPort=this.videoRenderControlChannel=this.audioRenderControlChannel=this.muxerControlChannel=null}}const ct="played",ut="time",dt="resume",lt="firstVideoRendered";var ft=i(5797),pt=i(2739);const mt=[["iphone",/iphone os ([\d_.]+)/],["ipad",/ipad; cpu os ([\d_.]+)/],["itouch",/itouch; cpu os ([\d_.]+)/],["android",/android ([\d_.]+)/],["wp",/windows phone ([\d_.]+)/],["windows",/windows nt ([\d_.]+)/],["linux",/linux/],["mac",/mac os x ([\d_.]+)/]],gt=function(t){let e,i;return(0,pt.__)(mt,(r=>{let s=r[1].exec(t);if(s)return e=r[0],i=s[1],i&&(i=i.replace(/_/g,".")),!1})),{name:e||"",version:i||""}}(("object"==typeof navigator&&navigator.userAgent||"").toLowerCase());gt.name&&(gt[gt.name]=!0,{iphone:1,ipad:1,itouch:1}[gt.name]&&(gt.ios=!0));const vt=gt;var At=i(4214);function yt(){let t=ft.A.offscreenCanvas;return vt.mac&&At.A.safari&&(vt.version<"12"||At.A.version<"17")&&(t=!1),t}var wt=i(4624),bt=i(932),kt=i(7837);class xt{constructor(t,e,i={}){(0,a.A)(this,"context",void 0),(0,a.A)(this,"observer",void 0),(0,a.A)(this,"options",void 0),(0,a.A)(this,"pullIPC",void 0),(0,a.A)(this,"buffer",void 0),(0,a.A)(this,"channels",void 0),(0,a.A)(this,"ended",void 0),(0,a.A)(this,"float32",void 0),(0,a.A)(this,"buffered",void 0),(0,a.A)(this,"pause",void 0),(0,a.A)(this,"startTime",void 0),(0,a.A)(this,"dest",void 0),(0,a.A)(this,"queue",void 0),(0,a.A)(this,"firstRendered",void 0),this.context=t,this.observer=e,this.options=i}async request(t,e,i){switch(t){case"init":break;case"start":{const{port:t,channels:i}=e;this.channels=i,this.pullIPC=new B.Ay(t),this.buffer=this.allocBuffer(),this.float32=new Float32Array((0,C.eq)().buffer),this.queue=[],this.startTime=0,this.ended=!1,this.pause=!1,this.firstRendered=!1,await this.pullIPC.request("pull",{buffer:this.buffer}),this.buffering(),await this.pullIPC.request("pull",{buffer:this.buffer}),this.buffered=!0,this.process();break}case"restart":if(!this.ended)return;this.buffer=this.allocBuffer(),this.queue=[],this.startTime=0,this.ended=!1,this.pause=!1,this.firstRendered=!1,await this.pullIPC.request("pull",{buffer:this.buffer}),this.buffering(),await this.pullIPC.request("pull",{buffer:this.buffer}),this.buffered=!0,this.process();break;case"stop":this.freeBuffer(this.buffer),this.buffer=null,this.ended=!0,this.pullIPC.destroy();break;case"clear":this.queue.forEach((t=>{t.disconnect()})),this.queue.length=0;break;case"pause":this.pause=!0;break;case"unpause":this.pause=!1,this.queue.length||this.process()}}allocBuffer(){const t=(0,kt.Gy)(40);bt.M[20](t,(0,kt.Gy)(4*this.channels));const e=(0,kt.Gy)(5120*this.channels);for(let i=0;i>>2;t.copyToChannel&&!M._7?t.copyToChannel(this.float32.subarray(i,i+1280),e,0):t.getChannelData(e).set(this.float32.subarray(i,i+1280),0)}const e=this.context.createBufferSource();e.buffer=t,e.onended=()=>{if(this.queue.shift(),this.ended&&!this.queue.length)return this.freeBuffer(this.buffer),wt.pq("audio source ended","src/avrender/pcm/AudioSourceBufferNode.ts",229),void this.observer.onEnded();this.process(),this.queue.length||this.observer.onStutter(),this.firstRendered||(this.firstRendered=!0,this.observer.onFirstRendered())},0===this.startTime&&(this.startTime=this.context.currentTime),e.start(this.startTime),this.dest&&e.connect(this.dest),this.startTime+=e.buffer.duration,this.queue.push(e)}connect(t){this.dest=t}disconnect(){for(let t=0;ti&&(t=i),t}var Pt=i(4328),Tt=i(7231);class It{constructor(){(0,a.A)(this,"channels",void 0),(0,a.A)(this,"sampleRate",void 0),(0,a.A)(this,"audioFrameSize",void 0),(0,a.A)(this,"audioPacketBytes",void 0),(0,a.A)(this,"audioPacketCount",void 0),(0,a.A)(this,"audioPacketQueueLength",void 0),(0,a.A)(this,"audioDropPacketCount",void 0),(0,a.A)(this,"audioDecodeErrorPacketCount",void 0),(0,a.A)(this,"audioFrameDecodeCount",void 0),(0,a.A)(this,"audioFrameRenderCount",void 0),(0,a.A)(this,"audioFrameDropCount",void 0),(0,a.A)(this,"width",void 0),(0,a.A)(this,"height",void 0),(0,a.A)(this,"keyFrameInterval",void 0),(0,a.A)(this,"gop",void 0),(0,a.A)(this,"videoPacketBytes",void 0),(0,a.A)(this,"videoPacketCount",void 0),(0,a.A)(this,"videoPacketQueueLength",void 0),(0,a.A)(this,"videoDropPacketCount",void 0),(0,a.A)(this,"videoDecodeErrorPacketCount",void 0),(0,a.A)(this,"videoFrameDecodeCount",void 0),(0,a.A)(this,"videoFrameRenderCount",void 0),(0,a.A)(this,"videoFrameDropCount",void 0),(0,a.A)(this,"keyFrameCount",void 0),(0,a.A)(this,"bufferDropBytes",void 0),(0,a.A)(this,"bufferReceiveBytes",void 0),(0,a.A)(this,"audioBitrate",void 0),(0,a.A)(this,"videoBitrate",void 0),(0,a.A)(this,"videoDecodeFramerate",void 0),(0,a.A)(this,"videoRenderFramerate",void 0),(0,a.A)(this,"videoEncodeFramerate",void 0),(0,a.A)(this,"audioDecodeFramerate",void 0),(0,a.A)(this,"audioRenderFramerate",void 0),(0,a.A)(this,"audioEncodeFramerate",void 0),(0,a.A)(this,"audioFrameDecodeIntervalMax",void 0),(0,a.A)(this,"audioFrameRenderIntervalMax",void 0),(0,a.A)(this,"videoFrameDecodeIntervalMax",void 0),(0,a.A)(this,"videoFrameRenderIntervalMax",void 0),(0,a.A)(this,"bandwidth",void 0),(0,a.A)(this,"jitter",void 0),(0,a.A)(this,"audioStutter",void 0),(0,a.A)(this,"videoStutter",void 0),(0,a.A)(this,"audiocodec",void 0),(0,a.A)(this,"videocodec",void 0)}}!function(t){var e=new(o());e.set("channels",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),e.set("sampleRate",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:4,8:0}),e.set("audioFrameSize",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:8,8:0}),e.set("audioPacketBytes",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:16,8:0}),e.set("audioPacketCount",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:24,8:0}),e.set("audioPacketQueueLength",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:32,8:0}),e.set("audioDropPacketCount",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:40,8:0}),e.set("audioDecodeErrorPacketCount",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:48,8:0}),e.set("audioFrameDecodeCount",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:56,8:0}),e.set("audioFrameRenderCount",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:64,8:0}),e.set("audioFrameDropCount",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:72,8:0}),e.set("width",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:76,8:0}),e.set("height",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:80,8:0}),e.set("keyFrameInterval",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:84,8:0}),e.set("gop",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:88,8:0}),e.set("videoPacketBytes",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:96,8:0}),e.set("videoPacketCount",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:104,8:0}),e.set("videoPacketQueueLength",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:112,8:0}),e.set("videoDropPacketCount",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:120,8:0}),e.set("videoDecodeErrorPacketCount",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:128,8:0}),e.set("videoFrameDecodeCount",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:136,8:0}),e.set("videoFrameRenderCount",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:144,8:0}),e.set("videoFrameDropCount",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:152,8:0}),e.set("keyFrameCount",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:160,8:0}),e.set("bufferDropBytes",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:168,8:0}),e.set("bufferReceiveBytes",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:176,8:0}),e.set("audioBitrate",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:184,8:0}),e.set("videoBitrate",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:188,8:0}),e.set("videoDecodeFramerate",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:192,8:0}),e.set("videoRenderFramerate",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:196,8:0}),e.set("videoEncodeFramerate",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:200,8:0}),e.set("audioDecodeFramerate",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:204,8:0}),e.set("audioRenderFramerate",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:208,8:0}),e.set("audioEncodeFramerate",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:212,8:0}),e.set("audioFrameDecodeIntervalMax",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:216,8:0}),e.set("audioFrameRenderIntervalMax",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:220,8:0}),e.set("videoFrameDecodeIntervalMax",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:224,8:0}),e.set("videoFrameRenderIntervalMax",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:228,8:0}),e.set("bandwidth",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:232,8:0}),e.set("jitter",{0:19,1:0,2:0,3:0,4:0,5:0,6:0,7:240,8:0}),e.set("audioStutter",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:248,8:0}),e.set("videoStutter",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:252,8:0}),(0,f.A)(t,l.Og,!0),(0,f.A)(t,l.dc,8),(0,f.A)(t,l.g7,256),(0,f.A)(t,l.JY,e)}(It.prototype);var Ct=i(4686),Bt=i(4663),St=i(333),Mt=i(5224),Rt=i(5915),Ut=i(1233),Et=i(3724);class Dt{constructor(t,e,i){(0,a.A)(this,"task",void 0),(0,a.A)(this,"timeout",void 0),(0,a.A)(this,"interval",void 0),(0,a.A)(this,"timer",void 0),this.task=t,this.timeout=e,this.interval=i}start(){const t=this;t.stop();let e=t.timeout;const i=t.interval,r=function(){!1!==t.task()&&t.timer?t.timer=setTimeout(r,t.interval):t.stop()};null==e&&(e=i),t.timer=setTimeout(r,e)}stop(){this.timer&&(clearTimeout(this.timer),this.timer=null)}updateInterval(t){this.interval=t}isStarted(){return!!this.timer}destroy(){this.stop(),this.task=this.timeout=this.interval=null}}class Lt{constructor(t){(0,a.A)(this,"stats",void 0),(0,a.A)(this,"timer",void 0),(0,a.A)(this,"videoFrameRenderCount",void 0),(0,a.A)(this,"videoFrameDecodeCount",void 0),(0,a.A)(this,"audioFrameRenderCount",void 0),(0,a.A)(this,"audioFrameDecodeCount",void 0),(0,a.A)(this,"videoPacketBytes",void 0),(0,a.A)(this,"audioPacketBytes",void 0),(0,a.A)(this,"bufferReceiveBytes",void 0),this.stats=t,this.timer=new Dt(this.onTimer.bind(this),1e3,1e3)}reset(){this.videoFrameRenderCount=A.f[17](this.stats+144),this.videoFrameDecodeCount=A.f[17](this.stats+136),this.audioFrameRenderCount=A.f[17](this.stats+64),this.audioFrameDecodeCount=A.f[17](this.stats+56),this.videoPacketBytes=A.f[17](this.stats+96),this.audioPacketBytes=A.f[17](this.stats+16),this.bufferReceiveBytes=A.f[17](this.stats+176)}start(){this.reset(),this.timer.start()}stop(){this.timer.stop()}onTimer(){bt.M[15](this.stats+216,0),bt.M[15](this.stats+220,0),bt.M[15](this.stats+224,0),bt.M[15](this.stats+228,0),bt.M[15](this.stats+196,0|Number(A.f[17](this.stats+144)-this.videoFrameRenderCount&0xffffffffn)),bt.M[15](this.stats+192,0|Number(A.f[17](this.stats+136)-this.videoFrameDecodeCount&0xffffffffn)),bt.M[15](this.stats+208,0|Number(A.f[17](this.stats+64)-this.audioFrameRenderCount&0xffffffffn)),bt.M[15](this.stats+204,0|Number(A.f[17](this.stats+56)-this.audioFrameDecodeCount&0xffffffffn)),bt.M[15](this.stats+188,0|Number(A.f[17](this.stats+96)-this.videoPacketBytes&0xffffffffn)),bt.M[15](this.stats+184,0|Number(A.f[17](this.stats+16)-this.audioPacketBytes&0xffffffffn)),bt.M[15](this.stats+232,0|Number(A.f[17](this.stats+176)-this.bufferReceiveBytes&0xffffffffn)),"visible"===document.visibilityState&&(A.f[15](this.stats+196)<.5*A.f[15](this.stats+200)||A.f[15](this.stats+228)>6e3/A.f[15](this.stats+200))&&bt.M[15](this.stats+252,A.f[15](this.stats+252)+1),this.reset()}}var Ft=i(3607),zt=i(6750),Ot=i(3765);class Vt{constructor(t,e,i){(0,a.A)(this,"task",void 0),(0,a.A)(this,"timeout",void 0),(0,a.A)(this,"interval",void 0),(0,a.A)(this,"clock",void 0),(0,a.A)(this,"started",void 0),(0,a.A)(this,"timer",void 0),this.task=t,this.timeout=e,this.interval=i,this.started=!1,this.clock=new Ot.A(this.interval,!1),this.clock.onClock=t=>{this.started&&!1===this.task()?this.stop():t()}}start(){this.started=!0,this.timeout>0?this.timer=setTimeout((()=>{this.timer=null,this.clock.start()}),this.timeout):this.clock.start()}stop(){this.started=!1,this.clock.stop(),this.timer&&(clearTimeout(this.timer),this.timer=null)}isStarted(){return this.started}updateInterval(t){this.interval=t,this.clock.setInterval(t)}destroy(){this.clock&&(this.stop(),this.clock.destroy(),this.clock=null),this.started=!1,this.task=this.timeout=this.interval=null}}const Nt=200;class $t{constructor(t){(0,a.A)(this,"timer",void 0),(0,a.A)(this,"interval",void 0),(0,a.A)(this,"data",void 0),(0,a.A)(this,"lastIncomingPacketCount",void 0),(0,a.A)(this,"shutterCount",void 0),(0,a.A)(this,"lastShutterCount",void 0),(0,a.A)(this,"isFirst",void 0),(0,a.A)(this,"max",void 0),(0,a.A)(this,"min",void 0),(0,a.A)(this,"targetPlaybackRate",void 0),(0,a.A)(this,"currentPlaybackRate",void 0),(0,a.A)(this,"playbackRateTimer",void 0),(0,a.A)(this,"options",void 0),this.options=t,this.interval=1e3,this.isFirst=!0,this.data=[],this.lastIncomingPacketCount=BigInt(0),this.shutterCount=0,this.lastShutterCount=0,this.max=1e3*t.max>>>0,this.min=1e3*t.min>>>0,bt.M[15](this.options.jitterBuffer,this.min),bt.M[15](this.options.jitterBuffer+4,this.max),t.lowLatencyStart&&bt.M[15](this.options.jitterBuffer+4,this.min+Nt),this.targetPlaybackRate=1,this.currentPlaybackRate=1,this.playbackRateTimer=new Dt((()=>{if(this.currentPlaybackRate>this.targetPlaybackRate){const t=Math.max(this.targetPlaybackRate,this.currentPlaybackRate-.01);this.options.observer.onSetPlayRate(t),this.currentPlaybackRate=t}else if(this.currentPlaybackRate>1&&t<2?this.setPlayRate(.8):tA.f[15](this.options.jitterBuffer+4)+Nt?this.setPlayRate(1.05):this.setPlayRate(1),t>this.max<<1&&this.options.observer.onCroppingBuffer(A.f[15](this.options.jitterBuffer+4))}process(){const t=this.data.reduce(((t,e,i)=>t+e*(i+1)),0)/55,e=this.data.reduce(((e,i)=>e+Math.pow(i-t,2)),0)/this.data.length,i=Math.sqrt(e),r=Math.round(t/(this.interval/1e3)),s=A.f[15](this.options.stats+200)+A.f[15](this.options.stats+212);r>1||this.shutterCount>3?(bt.M[15](this.options.jitterBuffer,Math.min(2*A.f[15](this.options.jitterBuffer),this.max-Nt)),bt.M[15](this.options.jitterBuffer+4,Math.min(2*A.f[15](this.options.jitterBuffer+4),this.max))):r>=s&&i<50?(bt.M[15](this.options.jitterBuffer,Math.max(A.f[15](this.options.jitterBuffer)-Nt,this.min)),bt.M[15](this.options.jitterBuffer+4,Math.max(A.f[15](this.options.jitterBuffer+4)-Nt,this.min+Nt))):i>100?(bt.M[15](this.options.jitterBuffer,Math.min(A.f[15](this.options.jitterBuffer)+Nt,this.max-Nt)),bt.M[15](this.options.jitterBuffer+4,Math.min(A.f[15](this.options.jitterBuffer+4)+Nt,this.max))):i<20?A.f[15](this.options.jitterBuffer)===this.min?bt.M[15](this.options.jitterBuffer+4,Math.max(A.f[15](this.options.jitterBuffer+4)-Nt,this.min+Nt)):bt.M[15](this.options.jitterBuffer,Math.max(A.f[15](this.options.jitterBuffer)-Nt,this.min)):A.f[15](this.options.jitterBuffer+4)===this.max?bt.M[15](this.options.jitterBuffer,Math.min(A.f[15](this.options.jitterBuffer)+Nt,this.max-Nt)):bt.M[15](this.options.jitterBuffer+4,Math.min(A.f[15](this.options.jitterBuffer+4)+Nt,this.max)),this.computePlayRate(),bt.M[19](this.options.stats+240,i)}onTimer(){const t=A.f[17](this.options.stats+24)+A.f[17](this.options.stats+104);this.isFirst?this.isFirst=!1:this.data.push(0|Number(t-this.lastIncomingPacketCount&0xffffffffn)),this.lastIncomingPacketCount=t,A.f[15](this.options.stats+252)+A.f[15](this.options.stats+248)>this.lastShutterCount?this.shutterCount++:this.shutterCount=0,this.lastShutterCount=A.f[15](this.options.stats+252)+A.f[15](this.options.stats+248),this.data.length>10&&this.data.shift(),10===this.data.length&&this.process()}}var Wt=i(9603),Gt="src/avplayer/AVPlayer.ts";const qt={1:"cover",0:"contain"},jt={enableHardware:!0,enableWebGPU:!0,loop:!1,jitterBufferMax:10,jitterBufferMin:4,lowLatency:!1};class Ht{constructor(){(0,a.A)(this,"avpacketList",void 0),(0,a.A)(this,"avframeList",void 0),(0,a.A)(this,"avpacketListMutex",void 0),(0,a.A)(this,"avframeListMutex",void 0),(0,a.A)(this,"jitterBuffer",void 0)}}!function(t){var e=new(o());e.set("avpacketList",{0:p.A,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),e.set("avframeList",{0:p.A,1:0,2:0,3:0,4:0,5:0,6:0,7:12,8:0}),e.set("avpacketListMutex",{0:m.eu,1:0,2:0,3:0,4:0,5:0,6:0,7:24,8:0}),e.set("avframeListMutex",{0:m.eu,1:0,2:0,3:0,4:0,5:0,6:0,7:28,8:0}),e.set("jitterBuffer",{0:g,1:0,2:0,3:0,4:0,5:0,6:0,7:32,8:0}),(0,f.A)(t,l.Og,!0),(0,f.A)(t,l.dc,4),(0,f.A)(t,l.g7,40),(0,f.A)(t,l.JY,e)}(Ht.prototype);const Qt={flv:0,mp4:1,mov:1,ts:2,ivf:4,opus:3,ogg:3,m3u8:2,m3u:2,mpd:1,mp3:7,mkv:5,mka:5,webm:5,aac:8,flac:10,wav:9},Yt={m3u8:2,m3u:2,mpd:3};class Kt extends W.A{constructor(t){super(!0),(0,a.A)(this,"VideoDecoderThread",void 0),(0,a.A)(this,"GlobalData",void 0),(0,a.A)(this,"taskId",void 0),(0,a.A)(this,"subTaskId",void 0),(0,a.A)(this,"ext",void 0),(0,a.A)(this,"source",void 0),(0,a.A)(this,"options",void 0),(0,a.A)(this,"ioloader2DemuxerChannel",void 0),(0,a.A)(this,"demuxer2VideoDecoderChannel",void 0),(0,a.A)(this,"demuxer2AudioDecoderChannel",void 0),(0,a.A)(this,"videoDecoder2VideoRenderChannel",void 0),(0,a.A)(this,"audioDecoder2AudioRenderChannel",void 0),(0,a.A)(this,"audioRender2AudioWorkletChannel",void 0),(0,a.A)(this,"audioSourceNode",void 0),(0,a.A)(this,"gainNode",void 0),(0,a.A)(this,"streams",void 0),(0,a.A)(this,"canvas",void 0),(0,a.A)(this,"updateCanvas",void 0),(0,a.A)(this,"video",void 0),(0,a.A)(this,"audio",void 0),(0,a.A)(this,"controller",void 0),(0,a.A)(this,"volume",void 0),(0,a.A)(this,"playRate",void 0),(0,a.A)(this,"renderMode",void 0),(0,a.A)(this,"renderRotate",void 0),(0,a.A)(this,"flipHorizontal",void 0),(0,a.A)(this,"flipVertical",void 0),(0,a.A)(this,"useMSE",void 0),(0,a.A)(this,"audioEnded",void 0),(0,a.A)(this,"videoEnded",void 0),(0,a.A)(this,"status",void 0),(0,a.A)(this,"lastStatus",void 0),(0,a.A)(this,"stats",void 0),(0,a.A)(this,"statsController",void 0),(0,a.A)(this,"jitterBufferController",void 0),this.options=q.X$({},jt,t),this.taskId=G(),this.status=0,this.volume=1,this.playRate=1,this.renderMode=0,this.renderRotate=0,this.flipHorizontal=!1,this.flipVertical=!1,this.stats=(0,v.A)(It),this.statsController=new Lt(this.stats[l.o9]),this.GlobalData=(0,v.A)(Ht),m.Ts(this.GlobalData[l.o9]+24),m.Ts(this.GlobalData[l.o9]+28),wt.pq(`create player, taskId: ${this.taskId}`,Gt,240)}async checkUseMSE(){{if(!ft.A.mse)return!1;if(!ft.A.wasmBaseSupported)return!0;const t=this.streams.find((t=>0===A.f[15](t.codecpar))),e=this.streams.find((t=>1===A.f[15](t.codecpar)));if(t&&!(0,zt.A)().isTypeSupported((0,St.A)(t.codecpar)))return wt.R8(`can not support mse for codec: ${(0,St.A)(t.codecpar)}, taskId: ${this.taskId}`,Gt,263),!1;if(e&&!(0,zt.A)().isTypeSupported((0,Mt.A)(e.codecpar)))return wt.R8(`can not support mse for codec: ${(0,Mt.A)(e.codecpar)}, taskId: ${this.taskId}`,Gt,267),!1;if(this.options.checkUseMES)return this.options.checkUseMES(this.streams);if(t)if(A.f[15](t.codecpar+48)*A.f[15](t.codecpar+52)>2073600){if(!ft.A.videoDecoder)return!0;let e=null;if(0!==A.f[20](t.codecpar+12)&&(e=(0,Ct.s3)(A.f[20](t.codecpar+12),A.f[15](t.codecpar+16))),!(await VideoDecoder.isConfigSupported({codec:(0,Bt.A)(t.codecpar),codedWidth:A.f[15](t.codecpar+48),codedHeight:A.f[15](t.codecpar+52),description:e,hardwareAcceleration:(0,Ut.C)(!0)})).supported)return!0}else if(A.f[15](t.codecpar+48)*A.f[15](t.codecpar+52)==2073600&&At.A.safari&&!At.A.checkVersion(At.A.version,"16.1",!0)&&(0,Pt.lb)((0,w.A)(t.codecpar+160,y.P))>30)return!0}return!1}createCanvas(){const t=document.createElement("canvas");return t.className="avplayer-canvas",t.width=this.options.container.offsetWidth*devicePixelRatio,t.height=this.options.container.offsetHeight*devicePixelRatio,t.style.cssText="\n width: 100%;\n height: 100%;\n ",t.ondragstart=()=>!1,t}createVideo(){this.video&&this.options.container.removeChild(this.video);const t=document.createElement("video");t.autoplay=!0,t.className="avplayer-video",t.style.cssText="\n width: 100%;\n height: 100%;\n ",this.options.container.appendChild(t),this.video=t}createAudio(){this.audio&&this.options.container.removeChild(this.audio);const t=document.createElement("audio");t.autoplay=!0,t.className="avplayer-audio",this.options.container.appendChild(t),this.audio=t}handleTimeupdate(t){let e=0;t.ontimeupdate=()=>{const i=t.currentTime;Math.abs(i-e)>=1&&(4===this.status&&(this.fire(ut,[BigInt(Math.floor(1e3*i))]),Kt.MSEThread.setCurrentTime(this.taskId,i)),e=i)},t.onended=()=>{this.audioEnded=!0,this.videoEnded=!0,this.handleEnded()},t.onwaiting=()=>{this.audio===t?this.stats.audioStutter++:(this.stats.audioStutter++,this.stats.videoStutter++)}}async handleEnded(){var t;if(this.audioEnded&&this.videoEnded)if(wt.pq(`player ended, taskId: ${this.taskId}`,Gt,384),this.options.loop&&!this.options.isLive)if(wt.pq(`loop play, taskId: ${this.taskId}`,Gt,388),"m3u8"===this.ext||"m3u"===this.ext?await Kt.DemuxerThread.seek(this.taskId,BigInt(0),16):"mpd"===this.ext?(await Kt.DemuxerThread.seek(this.taskId,BigInt(0),16),this.subTaskId&&await Kt.DemuxerThread.seek(this.subTaskId,BigInt(0),16)):await Kt.DemuxerThread.seek(this.taskId,BigInt(0),8),this.fire(ut,[BigInt(0)]),this.useMSE){var e;null!==(e=this.video||this.audio)&&void 0!==e&&e.src&&URL.revokeObjectURL((this.video||this.audio).src),await Kt.MSEThread.restart(this.taskId);const t=await Kt.MSEThread.getMediaSource(this.taskId);var i,r;t&&(ft.A.workerMSE&&t instanceof MediaSourceHandle?(this.video||this.audio).srcObject=t:(this.video||this.audio).src=URL.createObjectURL(t),this.video?(this.video.currentTime=0,this.video.playbackRate=this.playRate):this.audio&&(this.audio.currentTime=0,this.audio.playbackRate=this.playRate),await c().all([null===(i=this.video)||void 0===i?void 0:i.play(),null===(r=this.audio)||void 0===r?void 0:r.play()]))}else this.audioDecoder2AudioRenderChannel&&(await Kt.AudioDecoderThread.resetTask(this.taskId),await Kt.AudioRenderThread.restart(this.taskId)),this.audioSourceNode&&(await this.audioSourceNode.request("restart"),"suspended"===Kt.audioContext.state&&await Kt.AudioRenderThread.fakePlay(this.taskId),this.audioEnded=!1),this.videoDecoder2VideoRenderChannel&&(await this.VideoDecoderThread.resetTask(this.taskId),await Kt.VideoRenderThread.restart(this.taskId),this.videoEnded=!1);else null!==(t=this.video||this.audio)&&void 0!==t&&t.src&&URL.revokeObjectURL((this.video||this.audio).src),this.video&&(this.options.container.removeChild(this.video),this.video=null),this.audio&&(this.options.container.removeChild(this.audio),this.audio=null),this.canvas&&(this.options.container.removeChild(this.canvas),this.canvas=null),await this.stop(),this.fire("ended")}async load(t){wt.pq(`call load, taskId: ${this.taskId}`,Gt,481),this.status=1,this.fire("loading"),this.controller=new ht(this),this.ioloader2DemuxerChannel=ot(),(0,Ct.sO)(this.stats[l.o9],0,256),await Kt.startDemuxPipeline();let e="",i=0;var r;if(R.Yj(t)?(e=it.qg(t).file.split(".").pop(),i=await Kt.IOThread.registerTask.transfer(this.ioloader2DemuxerChannel.port1).invoke({type:null!==(r=Yt[e])&&void 0!==r?r:0,info:{url:t},range:{from:-1,to:-1},taskId:this.taskId,options:{isLive:this.options.isLive},rightPort:this.ioloader2DemuxerChannel.port1,stats:this.stats[l.o9]})):(this.options.isLive=!1,e=t.name.split(".").pop(),i=await Kt.IOThread.registerTask.transfer(this.ioloader2DemuxerChannel.port1).invoke({type:1,info:{file:t},range:{from:-1,to:-1},taskId:this.taskId,options:{isLive:!1},rightPort:this.ioloader2DemuxerChannel.port1,stats:this.stats[l.o9]})),i<0&&wt.h2(`register io task failed, ret: ${i}, taskId: ${this.taskId}`,Gt,542),"mpd"===e){await Kt.IOThread.open(this.taskId);const t=await Kt.IOThread.hasAudio(this.taskId),i=await Kt.IOThread.hasVideo(this.taskId);t&&i?(this.subTaskId=G(),await Kt.DemuxerThread.registerTask.transfer(this.ioloader2DemuxerChannel.port2).invoke({taskId:this.taskId,leftPort:this.ioloader2DemuxerChannel.port2,format:Qt[e],stats:this.stats[l.o9],isLive:this.options.isLive,ioloaderOptions:{type:"audio"},avpacketList:this.GlobalData[l.o9],avpacketListMutex:this.GlobalData[l.o9]+24}),await Kt.DemuxerThread.registerTask({taskId:this.subTaskId,mainTaskId:this.taskId,format:Qt[e],stats:this.stats[l.o9],isLive:this.options.isLive,ioloaderOptions:{type:"video"},avpacketList:this.GlobalData[l.o9],avpacketListMutex:this.GlobalData[l.o9]+24})):await Kt.DemuxerThread.registerTask.transfer(this.ioloader2DemuxerChannel.port2).invoke({taskId:this.taskId,leftPort:this.ioloader2DemuxerChannel.port2,format:Qt[e],stats:this.stats[l.o9],isLive:this.options.isLive,ioloaderOptions:{type:t?"audio":"video"},avpacketList:this.GlobalData[l.o9],avpacketListMutex:this.GlobalData[l.o9]+24})}else await Kt.DemuxerThread.registerTask.transfer(this.ioloader2DemuxerChannel.port2).invoke({taskId:this.taskId,leftPort:this.ioloader2DemuxerChannel.port2,format:Qt[e],stats:this.stats[l.o9],isLive:this.options.isLive,avpacketList:this.GlobalData[l.o9],avpacketListMutex:this.GlobalData[l.o9]+24});i=await Kt.DemuxerThread.openStream(this.taskId),i<0&&wt.h2(`open stream failed, ret: ${i}, taskId: ${this.taskId}`,Gt,613);let s=await Kt.DemuxerThread.analyzeStreams(this.taskId);if(s.length||wt.h2(`analyze stream failed, ret: ${s}`,Gt,617),this.subTaskId){i=await Kt.DemuxerThread.openStream(this.subTaskId),i<0&&wt.h2(`open stream failed, ret: ${i}, taskId: ${this.taskId}`,Gt,623);const t=await Kt.DemuxerThread.analyzeStreams(this.subTaskId);t.length||wt.h2(`analyze stream failed, ret: ${s}`,Gt,627),s=s.concat(t)}this.streams=s,this.ext=e,this.source=t;let a=`\n taskId: ${this.taskId}\n input: ${R.Yj(t)?t:t.name}\n stream:\n `;if(this.streams.forEach((t=>{1===A.f[15](t.codecpar)?this.stats.audiocodec=(0,Wt.A)(t.codecpar):0===A.f[15](t.codecpar)&&(this.stats.videocodec=(0,Bt.A)(t.codecpar)),a+=`\n #${t.index}(und): ${1===A.f[15](t.codecpar)?"Audio":"Video"}: ${1===A.f[15](t.codecpar)?this.stats.audiocodec:this.stats.videocodec}\n `})),wt.pq(a,Gt,653),"m3u8"===e||"m3u"===e||"mpd"===e){const t=1e3*await Kt.IOThread.getDuration(this.taskId);if(t>0)for(let e=0;e{var e;wt.Yz(`cropping buffer by jitter buffer, max: ${t}, taskId: ${this.taskId}`,Gt,686),null===(e=Kt.DemuxerThread)||void 0===e||e.croppingAVPacketQueue(this.taskId,BigInt(t>>>0))},onSetPlayRate:t=>{wt.Yz(`set play rate by jitter buffer, rate: ${t}, taskId: ${this.taskId}`,Gt,690),this.useMSE?(Kt.MSEThread.setPlayRate(this.taskId,t),this.video?this.video.playbackRate=t:this.audio&&(this.audio.playbackRate=t)):(this.audioDecoder2AudioRenderChannel&&Kt.AudioRenderThread.setPlayTempo(this.taskId,t),this.videoDecoder2VideoRenderChannel&&Kt.VideoRenderThread.setPlayRate(this.taskId,t))}}})}this.status=2,this.fire("loaded")}async play(t={audio:!0,video:!0}){if(wt.pq(`call play, options: ${d()(t)}, status: ${this.status} taskId: ${this.taskId}`,Gt,726),4===this.status)return;t.audio||t.video||(wt.R8(`video and audio must play one, ignore options, we will try to play video and audio, taskId: ${this.taskId}`,Gt,733),t.audio=!0,t.video=!0);const e=[];if(5===this.status)return this.useMSE?(e.push(Kt.MSEThread.unpause(this.taskId)),this.audio?this.audio.play():this.video&&this.video.play()):(this.audioSourceNode&&(e.push(this.audioSourceNode.request("unpause")),"suspended"===Kt.audioContext.state&&e.push(Kt.AudioRenderThread.unpause(this.taskId))),this.videoDecoder2VideoRenderChannel&&e.push(Kt.VideoRenderThread.unpause(this.taskId))),c().all(e).then((()=>{this.status=4,this.fire(ct),this.jitterBufferController&&this.jitterBufferController.start()}));if(this.status=3,this.fire("playing"),this.useMSE=await this.checkUseMSE(),this.audioEnded=!0,this.videoEnded=!0,this.useMSE){await Kt.startMSEPipeline(),await Kt.MSEThread.registerTask.transfer(this.controller.getMuxerRenderControlPort()).invoke({taskId:this.taskId,stats:this.stats[l.o9],format:await Kt.DemuxerThread.getFormat(this.taskId),controlPort:this.controller.getMuxerRenderControlPort(),isLive:this.options.isLive,avpacketList:this.GlobalData[l.o9],avpacketListMutex:this.GlobalData[l.o9]+24,enableJitterBuffer:!!this.jitterBufferController,jitterBuffer:this.GlobalData[l.o9]+32});let e=!1;for(let i=0;i0===A.f[15](t.codecpar)));await Kt.VideoRenderThread.registerTask.transfer(this.videoDecoder2VideoRenderChannel.port2,this.controller.getVideoRenderControlPort(),t).invoke({taskId:this.taskId,leftPort:this.videoDecoder2VideoRenderChannel.port2,controlPort:this.controller.getVideoRenderControlPort(),canvas:t,renderMode:this.renderMode,renderRotate:this.renderRotate,flipHorizontal:this.flipHorizontal,flipVertical:this.flipVertical,timeBase:{num:A.f[15](i.timeBase),den:A.f[15](i.timeBase+4)},viewportWidth:this.options.container.offsetWidth,viewportHeight:this.options.container.offsetHeight,devicePixelRatio,stats:this.stats[l.o9],enableWebGPU:this.options.enableWebGPU,startPTS:i.startTime,avframeList:this.GlobalData[l.o9]+12,avframeListMutex:this.GlobalData[l.o9]+28,enableJitterBuffer:!!this.jitterBufferController&&!this.audioDecoder2AudioRenderChannel,jitterBuffer:this.GlobalData[l.o9]+32}),this.videoEnded=!1,await Kt.VideoRenderThread.setPlayRate(this.taskId,this.playRate),e.push(Kt.VideoRenderThread.play(this.taskId))}if(this.audioDecoder2AudioRenderChannel){const t=this.streams.find((t=>1===A.f[15](t.codecpar)));this.audioRender2AudioWorkletChannel=new MessageChannel,await Kt.AudioRenderThread.registerTask.transfer(this.audioDecoder2AudioRenderChannel.port2,this.audioRender2AudioWorkletChannel.port1,this.controller.getAudioRenderControlPort()).invoke({taskId:this.taskId,leftPort:this.audioDecoder2AudioRenderChannel.port2,rightPort:this.audioRender2AudioWorkletChannel.port1,controlPort:this.controller.getAudioRenderControlPort(),playFormat:8,playSampleRate:Kt.audioContext.sampleRate,playChannels:A.f[15](t.codecpar+140),resamplerResource:await J({source:this.options.getWasm("resampler")}),stretchpitcherResource:await J({source:this.options.getWasm("stretchpitcher")}),stats:this.stats[l.o9],timeBase:{num:A.f[15](t.timeBase),den:A.f[15](t.timeBase+4)},startPTS:t.startTime,avframeList:this.GlobalData[l.o9]+12,avframeListMutex:this.GlobalData[l.o9]+28,enableJitterBuffer:!!this.jitterBufferController,jitterBuffer:this.GlobalData[l.o9]+32}),ft.A.audioWorklet?this.audioSourceNode=new st(Kt.audioContext,{onEnded:()=>{this.onAudioEnded()},onFirstRendered:()=>{this.onFirstAudioRendered()},onStutter:()=>{this.onStutter()}},{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[A.f[15](t.codecpar+140)]}):this.audioSourceNode=new xt(Kt.audioContext,{onEnded:()=>{this.onAudioEnded()},onFirstRendered:()=>{this.onFirstAudioRendered()},onStutter:()=>{this.onStutter()}},{numberOfInputs:1,numberOfOutputs:1,outputChannelCount:[A.f[15](t.codecpar+140)]}),M._7&&ft.A.audioWorklet&&(!At.A.safari||At.A.checkVersion(At.A.version,"16.1",!0))&&await this.audioSourceNode.request("init",{memory:C.ce}),await Kt.AudioRenderThread.setPlayTempo(this.taskId,this.playRate),this.gainNode=Kt.audioContext.createGain(),this.gainNode.connect(Kt.audioContext.destination),this.audioSourceNode.connect(this.gainNode),this.setVolume(this.volume),this.audioEnded=!1,e.push(this.audioSourceNode.request("start",{port:this.audioRender2AudioWorkletChannel.port2,channels:A.f[15](t.codecpar+140)},[this.audioRender2AudioWorkletChannel.port2]))}this.audioDecoder2AudioRenderChannel?this.controller.setTimeUpdateListenType(1):this.videoDecoder2VideoRenderChannel&&this.controller.setTimeUpdateListenType(0),this.videoDecoder2VideoRenderChannel&&this.audioDecoder2AudioRenderChannel&&Ft.tn(r-i)>BigInt(1e4)&&this.controller.setEnableAudioVideoSync(!1)}let i=10;return R.Yj(this.source)&&!this.options.isLive&&this.streams.forEach((t=>{i=Math.max(Math.ceil(4*(0,Pt.lb)((0,w.A)(t.codecpar+160,y.P))),i)})),e.push(Kt.DemuxerThread.startDemux(this.taskId,this.options.isLive,i)),this.subTaskId&&e.push(Kt.DemuxerThread.startDemux(this.subTaskId,this.options.isLive,i)),c().all(e).then((async()=>{var t,e;if(this.status=4,this.useMSE)await c().all([null===(t=this.video)||void 0===t?void 0:t.play(),null===(e=this.audio)||void 0===e?void 0:e.play()]).catch((t=>{if(this.video)return this.video.muted=!0,this.fire(dt),wt.R8("the audioContext was not started. It must be resumed after a user gesture",Gt,1159),this.video.play();throw t}));else if(this.audioSourceNode&&"suspended"===Kt.audioContext.state){if("suspended"===Kt.audioContext.state&&(this.fire(dt),wt.R8("the audioContext was not started. It must be resumed after a user gesture",Gt,1171)),!this.videoDecoder2VideoRenderChannel)throw new Error("the audioContext was not started. It must be resumed after a user gesture");Kt.AudioRenderThread.fakePlay(this.taskId),this.controller.setTimeUpdateListenType(0)}this.fire(ct),this.statsController.start(),this.jitterBufferController&&this.jitterBufferController.start()}))}async pause(){if(wt.pq(`call pause, taskId: ${this.taskId}`,Gt,1196),!this.options.isLive){const t=[];return this.useMSE?(this.audio&&this.audio.pause(),this.video&&this.video.pause(),t.push(Kt.MSEThread.pause(this.taskId))):(this.audioSourceNode&&(t.push(this.audioSourceNode.request("pause")),"suspended"===Kt.audioContext.state&&t.push(Kt.AudioRenderThread.pause(this.taskId))),this.videoDecoder2VideoRenderChannel&&t.push(Kt.VideoRenderThread.pause(this.taskId))),c().all(t).then((()=>{6===this.status?this.lastStatus=5:this.status=5,this.fire("paused"),this.jitterBufferController&&this.jitterBufferController.stop()}))}wt.R8(`pause can only used in vod, taskId: ${this.taskId}`,Gt,1235)}async seek(t){if(wt.pq(`call seek, timestamp: ${t}, taskId: ${this.taskId}`,Gt,1247),this.streams.length)if(6!==this.status)if(this.fire("seeking"),this.options.isLive)wt.R8(`seek can only used in vod, taskId: ${this.taskId}`,Gt,1361);else{this.lastStatus=this.status,this.status=6;const p=BigInt(Math.floor(t));var e,i;this.useMSE?await Kt.MSEThread.beforeSeek(this.taskId):await c().all([null===(e=Kt.AudioRenderThread)||void 0===e?void 0:e.beforeSeek(this.taskId),null===(i=Kt.VideoRenderThread)||void 0===i?void 0:i.beforeSeek(this.taskId)]);let m=-BigInt(1);if("m3u8"===this.ext||"m3u"===this.ext?m=await Kt.DemuxerThread.seek(this.taskId,p,16):"mpd"===this.ext?(m=await Kt.DemuxerThread.seek(this.taskId,p,16),this.subTaskId&&await Kt.DemuxerThread.seek(this.subTaskId,p,16)):m=await Kt.DemuxerThread.seek(this.taskId,p,8),m>=BigInt(0)?wt.Yz(`seeked to packet timestamp: ${m}, taskId: ${this.taskId}`,Gt,1292):wt.z3(`demuxer seek failed, code: ${m}, taskId: ${this.taskId}`,Gt,1295),this.useMSE){if(m>=BigInt(0)){const t=await Kt.MSEThread.afterSeek(this.taskId,m>p?m:p);this.video?this.video.currentTime=t:this.audio&&(this.audio.currentTime=t)}else await Kt.MSEThread.afterSeek(this.taskId,Tt.Dh);this.status=this.lastStatus,this.fire("seeked")}else{let t=20;var r,s,a,n,o,h,u,d,l,f;this.streams.forEach((e=>{0===A.f[15](e.codecpar)&&(t=Math.max(Math.ceil((0,Pt.lb)((0,w.A)(e.codecpar+160,y.P))),t))})),m>=BigInt(0)?(await c().all([null===(r=Kt.AudioDecoderThread)||void 0===r?void 0:r.resetTask(this.taskId),null===(s=this.VideoDecoderThread)||void 0===s?void 0:s.resetTask(this.taskId)]),await c().all([null===(a=Kt.AudioRenderThread)||void 0===a?void 0:a.syncSeekTime(this.taskId,m>p?m:p,t),null===(n=Kt.VideoRenderThread)||void 0===n?void 0:n.syncSeekTime(this.taskId,m>p?m:p,t)]),await c().all([null===(o=Kt.AudioRenderThread)||void 0===o?void 0:o.afterSeek(this.taskId,m>p?m:p),null===(h=Kt.VideoRenderThread)||void 0===h?void 0:h.afterSeek(this.taskId,m>p?m:p)])):(await c().all([null===(u=Kt.AudioRenderThread)||void 0===u?void 0:u.syncSeekTime(this.taskId,Tt.Dh,t),null===(d=Kt.VideoRenderThread)||void 0===d?void 0:d.syncSeekTime(this.taskId,Tt.Dh,t)]),await c().all([null===(l=Kt.AudioRenderThread)||void 0===l?void 0:l.afterSeek(this.taskId,Tt.Dh),null===(f=Kt.VideoRenderThread)||void 0===f?void 0:f.afterSeek(this.taskId,Tt.Dh)])),this.status=this.lastStatus,this.jitterBufferController&&this.jitterBufferController.reset()}}else wt.R8(`player is seeking now, taskId: ${this.taskId}`,Gt,1255);else wt.z3(`cannot found any stream to seek, taskId: ${this.taskId}`,Gt,1250)}getStreams(){return this.streams}getDuration(){if(!this.options.isLive){let t=BigInt(0);return this.streams.forEach((e=>{const i=(0,Pt.k)(e.duration,{den:A.f[15](e.timeBase+4),num:A.f[15](e.timeBase)},Tt.i0);i>t&&(t=i)})),t}return BigInt(0)}async stop(){var t;wt.pq(`call stop, taskId: ${this.taskId}`,Gt,1397),0!==this.status?(this.audioSourceNode&&(await this.audioSourceNode.request("stop"),this.audioSourceNode.disconnect(),this.audioSourceNode=null),Kt.VideoRenderThread&&await Kt.VideoRenderThread.unregisterTask(this.taskId),Kt.AudioRenderThread&&await Kt.AudioRenderThread.unregisterTask(this.taskId),this.VideoDecoderThread&&await this.VideoDecoderThread.unregisterTask(this.taskId),Kt.AudioDecoderThread&&await Kt.AudioDecoderThread.unregisterTask(this.taskId),Kt.MSEThread&&await Kt.MSEThread.unregisterTask(this.taskId),Kt.DemuxerThread&&(await Kt.DemuxerThread.unregisterTask(this.taskId),this.subTaskId&&await Kt.DemuxerThread.unregisterTask(this.subTaskId)),Kt.IOThread&&await Kt.IOThread.unregisterTask(this.taskId),this.gainNode&&(this.gainNode.disconnect(),this.gainNode=null),this.controller&&this.controller.destroy(),null!==(t=this.video||this.audio)&&void 0!==t&&t.src&&URL.revokeObjectURL((this.video||this.audio).src),this.video&&(this.options.container.removeChild(this.video),this.video=null),this.audio&&(this.options.container.removeChild(this.audio),this.audio=null),this.canvas&&(this.options.container.removeChild(this.canvas),this.canvas=null),this.ioloader2DemuxerChannel=null,this.demuxer2VideoDecoderChannel=null,this.demuxer2AudioDecoderChannel=null,this.videoDecoder2VideoRenderChannel=null,this.audioDecoder2AudioRenderChannel=null,this.audioRender2AudioWorkletChannel=null,this.statsController.stop(),this.jitterBufferController&&this.jitterBufferController.stop(),this.fire("stopped"),this.status=0):wt.R8(`player has already stopped, taskId: ${this.taskId}`,Gt,1400)}setPlaybackRate(t){var e,i,r;this.options.isLive?wt.R8(`setPlaybackRate can only used in playback, taskId: ${this.taskId}`,Gt,1499):(this.playRate=_t(t,.5,2),this.useMSE?(Kt.MSEThread.setPlayRate(this.taskId,this.playRate),this.video?this.video.playbackRate=this.playRate:this.audio&&(this.audio.playbackRate=this.playRate)):(null===(e=Kt.AudioRenderThread)||void 0===e||e.setPlayTempo(this.taskId,this.playRate),null===(i=Kt.VideoRenderThread)||void 0===i||i.setPlayRate(this.taskId,this.playRate),null===(r=this.VideoDecoderThread)||void 0===r||r.setPlayRate(this.taskId,this.playRate)),wt.pq(`player call setPlaybackRate, set ${this.playRate}, taskId: ${this.taskId}`,Gt,1496))}getPlaybackRate(){return this.playRate}async resume(){var t;"suspended"===(null===(t=Kt.audioContext)||void 0===t?void 0:t.state)&&(await c().race([Kt.audioContext.resume(),new Et.A(.1)]),"suspended"===Kt.audioContext.state?wt.R8("the audioContext was not allowed to start. It must be resumed after a user gesture",Gt,1522):(this.audioSourceNode&&this.controller.setTimeUpdateListenType(1),this.video&&(this.video.muted=!1))),this.video?(this.video.muted=!1,this.video.played||await this.video.play()):this.audio&&(this.audio.muted=!1,this.audio.played||await this.audio.play()),wt.pq(`call resume, taskId: ${this.taskId}`,Gt,1546)}getVolume(){return this.volume}setVolume(t,e=!1){this.volume=_t(t,0,3),this.gainNode&&Kt.audioContext?(this.gainNode.gain.cancelScheduledValues(Kt.audioContext.currentTime),At.A.firefox&&!e?this.gainNode.gain.setValueAtTime(this.volume,Kt.audioContext.currentTime+1):0===this.gainNode.gain.value||0===this.volume||e?this.gainNode.gain.value=this.volume:this.gainNode.gain.exponentialRampToValueAtTime(this.volume,Kt.audioContext.currentTime+1)):this.video?this.video.volume=this.volume:this.audio&&(this.audio.volume=this.volume),wt.pq(`player call setVolume, set ${t}, used ${this.volume}, taskId: ${this.taskId}`,Gt,1588)}getRenderMode(){return this.renderMode}setRenderMode(t){var e;this.renderMode=t,this.useMSE&&this.video?this.video.style["object-fit"]=qt[this.renderMode]:null===(e=Kt.VideoRenderThread)||void 0===e||e.setRenderMode(this.taskId,t),wt.pq(`player call setRenderMode, mode: ${t}, taskId: ${this.taskId}`,Gt,1618)}getVideoTransformContext(){let t="";return 0!==this.renderRotate&&(t+=`rotateZ(${this.renderRotate}deg)`),this.flipHorizontal&&(t+=(t.length?" ":"")+"scaleX(-1)"),this.flipVertical&&(t+=(t.length?" ":"")+"scaleY(-1)"),t}setRotate(t){var e;this.renderRotate=t,this.useMSE&&this.video?this.video.style.transform=this.getVideoTransformContext():null===(e=Kt.VideoRenderThread)||void 0===e||e.setRenderRotate(this.taskId,t),wt.pq(`player call setRotate, angle: ${t}, taskId: ${this.taskId}`,Gt,1648)}enableHorizontalFlip(t){var e;this.flipHorizontal=t,this.useMSE&&this.video?this.video.style.transform=this.getVideoTransformContext():null===(e=Kt.VideoRenderThread)||void 0===e||e.enableHorizontalFlip(this.taskId,t),wt.pq(`player call enableHorizontalFlip, enable: ${t}, taskId: ${this.taskId}`,Gt,1659)}enableVerticalFlip(t){var e;this.flipVertical=t,this.useMSE&&this.video?this.video.style.transform=this.getVideoTransformContext():null===(e=Kt.VideoRenderThread)||void 0===e||e.enableVerticalFlip(this.taskId,t),wt.pq(`player call enableVerticalFlip, enable: ${t}, taskId: ${this.taskId}`,Gt,1670)}setLoop(t){this.options.loop=t,wt.pq(`call setLoop, enable: ${t}, taskId: ${this.taskId}`,Gt,1682)}resize(t,e){var i;this.useMSE||null===(i=Kt.VideoRenderThread)||void 0===i||i.resize(this.taskId,t,e),wt.pq(`player call resize, width: ${t}, height: ${e}, taskId: ${this.taskId}`,Gt,1695)}isMSE(){return this.useMSE}async getVideoList(){var t;return null===(t=Kt.IOThread)||void 0===t?void 0:t.getVideoList(this.taskId)}async getAudioList(){var t;return null===(t=Kt.IOThread)||void 0===t?void 0:t.getAudioList(this.taskId)}async getSubtitleList(){var t;return null===(t=Kt.IOThread)||void 0===t?void 0:t.getSubtitleList(this.taskId)}async selectVideo(t){var e;return null===(e=Kt.IOThread)||void 0===e?void 0:e.selectVideo(this.taskId,t)}async selectAudio(t){var e;return null===(e=Kt.IOThread)||void 0===e?void 0:e.selectAudio(this.taskId,t)}async selectSubtitle(t){var e;return null===(e=Kt.IOThread)||void 0===e?void 0:e.selectSubtitle(this.taskId,t)}enterFullscreen(){const t=this.useMSE?this.video:this.canvas;t.requestFullscreen?t.requestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen?t.webkitRequestFullscreen():t.msRequestFullscreen&&t.msRequestFullscreen(),wt.pq(`player call enterFullscreen, taskId: ${this.taskId}`,Gt,1743)}exitFullscreen(){document.exitFullscreen?document.exitFullscreen():document.mozExitFullScreen?document.mozExitFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen(),wt.pq(`player call exitFullscreen, taskId: ${this.taskId}`,Gt,1759)}snapshot(t="png",e=1){if(this.useMSE&&this.video){const i=document.createElement("canvas");return i.width=this.video.videoWidth,i.height=this.video.videoHeight,i.getContext("2d").drawImage(this.video,0,0),i.toDataURL(`image/${t}`,e)}if(this.canvas)return this.canvas.toDataURL(`image/${t}`,e)}getStats(){return this.stats}async destroy(){wt.pq(`call destroy, taskId: ${this.taskId}`,Gt,1788),8!==this.status?(await this.stop(),(0,b.A)(this.stats),this.stats=null,this.VideoDecoderThread&&(await this.VideoDecoderThread.clear(),$(this.VideoDecoderThread),this.VideoDecoderThread=null),this.GlobalData&&(this.GlobalData.avframeList.clear((t=>{(0,X.to)(t)}),20),this.GlobalData.avpacketList.clear((t=>{(0,Z.Up)(t)}),20),m.zr(this.GlobalData[l.o9]+24),m.zr(this.GlobalData[l.o9]+28),(0,b.A)(this.GlobalData),this.GlobalData=null),this.status=8):wt.R8(`player has already destroyed, taskId: ${this.taskId}`,Gt,1791)}onVideoEnded(){this.videoEnded=!0,this.handleEnded()}onAudioEnded(){this.audioEnded=!0,this.handleEnded()}onCanvasUpdated(){this.updateCanvas=this.createCanvas();const t=yt()&&M._7?this.updateCanvas.transferControlToOffscreen():this.updateCanvas;Kt.VideoRenderThread.updateCanvas.transfer(t).invoke(this.taskId,t)}onFirstVideoRendered(){wt.pq(`first video frame rendered, taskId: ${this.taskId}`,Gt,1844),this.fire(lt)}onFirstAudioRendered(){wt.pq(`first audio frame rendered, taskId: ${this.taskId}`,Gt,1849),this.fire(lt)}onStutter(){this.stats.audioStutter++}onFirstVideoRenderedAfterUpdateCanvas(){this.updateCanvas&&(this.canvas&&this.options.container.removeChild(this.canvas),this.canvas=this.updateCanvas,this.options.container.appendChild(this.canvas),this.updateCanvas=null)}onTimeUpdate(t){this.fire(ut,[t])}onMSESeek(t){this.audio?this.audio.currentTime=t:this.video&&(this.video.currentTime=t)}async createVideoDecoderThread(){this.VideoDecoderThread||(this.VideoDecoderThread=await N(_.A,{name:"VideoDecoderThread",disableWorker:At.A.safari&&!At.A.checkVersion(At.A.version,"16.1",!0)},3823).run(),this.VideoDecoderThread.setLogLevel(Kt.level))}static async startDemuxPipeline(){return Kt.DemuxThreadReady?Kt.DemuxThreadReady:Kt.DemuxThreadReady=new(c())((async t=>{Kt.IOThread=await N(k.A,{name:"IOThread"},115).run(),Kt.IOThread.setLogLevel(Kt.level),Kt.DemuxerThread=await N(x.A,{name:"DemuxerThread"},4582).run(),Kt.DemuxerThread.setLogLevel(Kt.level),t()}))}static async startAudioPipeline(){return Kt.AudioThreadReady?Kt.AudioThreadReady:Kt.AudioThreadReady=new(c())((async t=>{Kt.audioContext=new(AudioContext||webkitAudioContext),ft.A.audioWorklet&&await async function(t,e){const i=(0,S.A)(e,{varName:"processor"}),r=new Blob([i],{type:"text/javascript"}),s=URL.createObjectURL(r);await t.audioWorklet.addModule(s)}(Kt.audioContext,!M._7||At.A.safari&&!At.A.checkVersion(At.A.version,"16.1",!0)?4268:5676),Kt.AudioDecoderThread=await N(P.A,{name:"AudioDecoderThread",disableWorker:At.A.safari&&!At.A.checkVersion(At.A.version,"16.1",!0)},8393).run(),Kt.AudioDecoderThread.setLogLevel(Kt.level),Kt.AudioRenderThread=await N(tt.A,{name:"AudioRenderThread",disableWorker:At.A.safari&&!At.A.checkVersion(At.A.version,"16.1",!0)},5181).run(),Kt.AudioRenderThread.setLogLevel(Kt.level),t()}))}static async startVideoRenderPipeline(){return Kt.VideoThreadReady?Kt.VideoThreadReady:Kt.VideoThreadReady=new(c())((async t=>{Kt.VideoRenderThread=await N(et.A,{name:"VideoRenderThread",disableWorker:!yt()},7303).run(),Kt.VideoRenderThread.setLogLevel(Kt.level),t()}))}static async startMSEPipeline(){return Kt.MSEThreadReady?Kt.MSEThreadReady:Kt.MSEThreadReady=new(c())((async t=>{Kt.MSEThread=await N(Rt.A,{name:"MSEThread",disableWorker:!ft.A.workerMSE},5915).run(),Kt.MSEThread.setLogLevel(Kt.level),t()}))}static async startPipelines(){await Kt.startDemuxPipeline(),await Kt.startAudioPipeline(),await Kt.startVideoRenderPipeline(),await Kt.startMSEPipeline(),wt.pq("AVPlayer pipelines started",Gt,1980)}static async stopPipelines(){Kt.VideoRenderThread&&(await Kt.VideoRenderThread.clear(),$(Kt.VideoRenderThread)),Kt.AudioRenderThread&&(await Kt.AudioRenderThread.clear(),$(Kt.AudioRenderThread)),Kt.AudioDecoderThread&&(await Kt.AudioDecoderThread.clear(),$(Kt.AudioDecoderThread)),Kt.DemuxerThread&&(await Kt.DemuxerThread.clear(),$(Kt.DemuxerThread)),Kt.IOThread&&(await Kt.IOThread.clear(),$(Kt.IOThread)),Kt.MSEThread&&(await Kt.MSEThread.clear(),$(Kt.MSEThread)),Kt.AudioDecoderThread=null,Kt.DemuxerThread=null,Kt.IOThread=null,Kt.audioContext=null,Kt.MSEThread=null,wt.pq("AVPlayer pipelines stopped",Gt,2017)}static setLogLevel(t){Kt.level=t,wt.V$(t),Kt.IOThread&&Kt.IOThread.setLogLevel(t),Kt.DemuxerThread&&Kt.DemuxerThread.setLogLevel(t),Kt.AudioDecoderThread&&Kt.AudioDecoderThread.setLogLevel(t),Kt.AudioRenderThread&&Kt.AudioRenderThread.setLogLevel(t),Kt.VideoRenderThread&&Kt.VideoRenderThread.setLogLevel(t),Kt.MSEThread&&Kt.MSEThread.setLogLevel(t),wt.pq(`set log level: ${t}`,Gt,2044)}}(0,a.A)(Kt,"level",wt.rD),(0,a.A)(Kt,"DemuxThreadReady",void 0),(0,a.A)(Kt,"AudioThreadReady",void 0),(0,a.A)(Kt,"VideoThreadReady",void 0),(0,a.A)(Kt,"MSEThreadReady",void 0),(0,a.A)(Kt,"IOThread",void 0),(0,a.A)(Kt,"DemuxerThread",void 0),(0,a.A)(Kt,"AudioDecoderThread",void 0),(0,a.A)(Kt,"AudioRenderThread",void 0),(0,a.A)(Kt,"VideoRenderThread",void 0),(0,a.A)(Kt,"MSEThread",void 0),(0,a.A)(Kt,"audioContext",void 0)},6750:(t,e,i)=>{"use strict";function r(){if("function"==typeof MediaSource)return MediaSource;if("function"==typeof ManagedMediaSource)return ManagedMediaSource;throw new Error("not support mse")}i.d(e,{A:()=>r})},5915:(t,e,i)=>{"use strict";i.d(e,{A:()=>Ct});var r=i(4001),s=i.n(r),a=i(4686),n=i(1499),o=i(3939),h=i(9599),c=i(915),u=i(932),d=i(2264),l=i(1091),f=i(4527),p=i(9705),m=i(4149),g=i(4624),v=i(5336),A=i(662),y=i.n(A),w=i(5335),b="src/avformat/mux.ts";const k={paddingZero:!1};function x(t,e={}){const i=w.X$({},k,e);return t.ioWriter||g.h2("need ioWriter",b,46),t.oformat||g.h2("need oformat",b,49),t.options=i,t.processPrivateData={first:new(y())},t.oformat.init(t)}function _(t){t.oformat.writeHeader(t)}function P(t){t.oformat.writeTrailer(t)}function T(t){t.oformat.flush(t)}var I=i(1026);class C{constructor(){(0,I.A)(this,"type",-1)}destroy(t){}}var B=i(9690),S=i(5977),M=i(1071),R=i(2739),U=i(7231);function E(t,e,i,r,s,a,n){t.writeUint32(e<<16),t.writeUint32(i<<16),t.writeUint32(0),t.writeUint32(r<<16),t.writeUint32(s<<16),t.writeUint32(0),t.writeUint32(a<<16),t.writeUint32(n<<16),t.writeUint32(1073741824)}var D=i(4328);function L(t,e,i){const r=t.getPos();t.writeUint32(0),t.writeString("hdlr"),t.writeUint8(0),t.writeUint24(0);let s="dhlr",a="url ",n="DataHandler";e&&(s="mhlr",1===e.codecpar.codecType?(a="soun",n="SoundHandler"):0===e.codecpar.codecType?(a="vide",n="VideoHandler"):3===e.codecpar.codecType?(a="text",n="SubtitleHandler"):(e.metadata.handlerName&&(n=e.metadata.handlerName),e.metadata.hdlrType&&(a=e.metadata.hdlrType))),t.writeString(s),t.writeString(a),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),e&&!i.isom||t.writeUint8(n.length),t.writeString(n),e&&!i.isom&&t.writeUint8(0),i.boxsPositionInfo.push({pos:r,type:"hdlr",size:Number(t.getPos()-r)})}var F=i(1865),z=i(6660);function O(t,e,i){t.writeUint8(e);for(let e=3;e>0;e--)t.writeUint8(i>>7*e|128);t.writeUint8(127&i)}function V(t,e,i){const r=e.privData,s=e.codecpar.extradata?5+e.codecpar.extradataSize:0,n=t.getPos();t.writeUint32(0),t.writeString("esds"),t.writeUint32(0),O(t,3,21+s+5+1),t.writeUint16(r.trackId),t.writeUint8(0),O(t,4,13+s),(86016===e.codecpar.codecId||86017===e.codecpar.codecId)&&e.codecpar.sampleRate>24e3?t.writeUint8(107):t.writeUint8(z.zs[e.codecpar.codecId]),94208===e.codecpar.codecId?t.writeUint8(225):1===e.codecpar.codecType?t.writeUint8(21):t.writeUint8(17),t.writeUint24(0),t.writeUint32(0),t.writeUint32(0),e.codecpar.extradata&&(O(t,5,e.codecpar.extradataSize),t.writeBuffer((0,a.s3)(e.codecpar.extradata,e.codecpar.extradataSize))),O(t,6,1),t.writeUint8(2),i.boxsPositionInfo.push({pos:n,type:"esds",size:Number(t.getPos()-n)})}function N(t,e,i){t.writeUint32(20),t.writeString("btrt"),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0)}var $=i(7672);const W={27:"avc1",173:"hvc1",226:"av01",167:"vp09"};function G(t){if(t.codecTag)return function(t,e=4){let i="";for(let r=0;r>>=8):(i=String.fromCharCode(Number(t&BigInt(255)))+i,t>>=BigInt(8));return i}(t.codecTag);let e=W[t.codecId];return e||(e=0===t.codecType?"mp4v":1===t.codecType?86076===t.codecId?"Opus":86028===t.codecId?"fLaC":"mp4a":3===t.codecType?"text":"none"),e}const q={stts:function(t,e,i){const r=e.privData,s=r.sttsSampleCounts||[],a=r.sttsSampleDeltas||[];s.length!==a.length&&g.R8("stts sampleCounts's length is not match sampleDeltas's length","src/avformat/formats/mov/writing/stts.ts",39);const n=Math.min(s.length,a.length);t.writeUint32(16+8*n),t.writeString("stts"),t.writeUint8(0),t.writeUint24(0),t.writeUint32(n);for(let e=0;e0?e.codecpar.width:0,u=e.codecpar.height>0?e.codecpar.height:0;c0;)t.writeUint8(0),e--}i.isom&&e.codecpar.bitsPerCodedSample?t.writeUint16(e.codecpar.bitsPerCodedSample):t.writeUint16(24),t.writeUint16(65535),"mp4v"===s?V(t,e,i):27===e.codecpar.codecId?function(t,e,i){var r;t.writeUint32(null!==(r=8+e.codecpar.extradataSize)&&void 0!==r?r:0),t.writeString("avcC"),i.fragment&&e.sideData[1]?(t.writeBuffer(e.sideData[1]),delete e.sideData[1]):e.codecpar.extradata&&t.writeBuffer((0,a.s3)(e.codecpar.extradata,e.codecpar.extradataSize))}(t,e,i):173===e.codecpar.codecId?function(t,e,i){var r;t.writeUint32(null!==(r=8+e.codecpar.extradataSize)&&void 0!==r?r:0),t.writeString("hvcC"),i.fragment&&e.sideData[1]?(t.writeBuffer(e.sideData[1]),delete e.sideData[1]):e.codecpar.extradata&&t.writeBuffer((0,a.s3)(e.codecpar.extradata,e.codecpar.extradataSize))}(t,e,i):167===e.codecpar.codecId?function(t,e,i){var r;t.writeUint32(null!==(r=8+e.codecpar.extradataSize)&&void 0!==r?r:0),t.writeString("vpcC"),i.fragment&&e.sideData[1]?(t.writeBuffer(e.sideData[1]),delete e.sideData[1]):e.codecpar.extradata&&t.writeBuffer((0,a.s3)(e.codecpar.extradata,e.codecpar.extradataSize))}(t,e,i):226===e.codecpar.codecId&&function(t,e,i){var r;t.writeUint32(null!==(r=8+e.codecpar.extradataSize)&&void 0!==r?r:0),t.writeString("av1C"),i.fragment&&e.sideData[1]?(t.writeBuffer(e.sideData[1]),delete e.sideData[1]):e.codecpar.extradata&&t.writeBuffer((0,a.s3)(e.codecpar.extradata,e.codecpar.extradataSize))}(t,e,i),function(t,e,i){const r=e.sideData[28];if(r)t.writeUint32(12+r.length),t.writeString("colr"),t.writeString("prof"),t.writeBuffer(r);else{const i=2===e.codecpar.colorRange;t.writeUint32(19),t.writeString("colr"),t.writeString("nclx"),t.writeUint16(e.codecpar.colorPrimaries),t.writeUint16(e.codecpar.colorTrc),t.writeUint16(e.codecpar.colorSpace),t.writeUint8(i?128:0)}}(t,e),function(t,e,i){t.writeUint32(16),t.writeString("pasp"),t.writeUint32(1),t.writeUint32(1)}(t),i.isom||N(t),i.boxsPositionInfo.push({pos:r,type:s,size:Number(t.getPos()-r)})}(t,e,i):3===e.codecpar.codecType&&function(t,e,i){const r=t.getPos(),s=G(e.codecpar);t.writeUint32(0),t.writeString(s),t.writeUint32(0),t.writeUint16(0),t.writeUint16(1),94208===e.codecpar.codecId?V(t,e,i):e.codecpar.extradata&&t.writeBuffer((0,a.s3)(e.codecpar.extradata,e.codecpar.extradataSize)),i.isom||N(t),i.boxsPositionInfo.push({pos:r,type:s,size:Number(t.getPos()-r)})}(t,e,i),i.boxsPositionInfo.push({pos:r,type:"esds",size:Number(t.getPos()-r)})},vmhd:function(t,e,i){t.writeUint32(20),t.writeString("vmhd"),t.writeUint8(0),t.writeUint24(1),t.writeUint64(BigInt(0))},edts:function(t,e,i){const r=e.privData;let s=(0,D.k)(r.lastPts,e.timeBase,{den:i.timescale,num:1}),a=r.startCT;const n=(0,D.k)(r.startDts+BigInt(Math.floor(a)),e.timeBase,{den:r.timescale,num:1});let o=s0?1:0),c=24+h*(1===o?20:12);t.writeUint32(c),t.writeString("edts"),t.writeUint32(c-8),t.writeString("elst"),t.writeUint8(o),t.writeUint24(0),t.writeUint32(h),n>0?(1===o?(t.writeUint64(n),t.writeInt64(U.Dh)):(t.writeUint32(Number(n)),t.writeInt32(-1)),t.writeUint32(65536)):(a=-Math.min(Number(r.startDts),0),s+=n),i.fragment&&(s=BigInt(0)),1===o?(t.writeUint64(s),t.writeInt64(BigInt(Math.floor(a)))):(t.writeUint32(Number(s)),t.writeInt32(a)),t.writeUint32(65536)},smhd:function(t,e,i){t.writeUint32(16),t.writeString("smhd"),t.writeUint32(0),t.writeUint16(0),t.writeUint16(0)},dref:function(t,e,i){t.writeUint32(28),t.writeString("dref"),t.writeUint32(0),t.writeUint32(1),t.writeUint32(12),t.writeString("url "),t.writeUint32(1)},trex:function(t,e,i){var r,s,a;const n=i.currentFragment.tracks.find((t=>t.trackId===e.privData.trackId)),o=i.trexs.find((t=>{t.trackId,e.privData.trackId})),h=null!==(r=null==o?void 0:o.duration)&&void 0!==r?r:0,c=null!==(s=null==o?void 0:o.size)&&void 0!==s?s:0,u=null!==(a=null==o?void 0:o.flags)&&void 0!==a?a:0;t.writeUint32(32),t.writeString("trex"),t.writeUint8(0),t.writeUint24(0),t.writeUint32(n.trackId),t.writeUint32(1),t.writeUint32(h),t.writeUint32(c),t.writeUint32(u)},mfhd:function(t,e,i){t.writeUint32(16),t.writeString("mfhd"),t.writeUint8(0),t.writeUint24(0),t.writeUint32(i.currentFragment.sequence)},tfhd:function(t,e,i){const r=i.currentFragment.tracks.find((t=>t.trackId===e.privData.trackId));let s=57;r.baseIsMoof&&(s&=-2,s|=131072);const a=t.getPos();t.writeUint32(0),t.writeString("tfhd"),t.writeUint8(0),t.writeUint24(s),t.writeUint32(r.trackId),1&s&&t.writeUint64(r.baseDataOffset),8&s&&t.writeUint32(r.defaultSampleDuration),16&s&&t.writeUint32(r.defaultSampleSize),32&s&&t.writeUint32(r.defaultSampleFlags),i.boxsPositionInfo.push({pos:a,type:"tfhd",size:Number(t.getPos()-a)})},tfdt:function(t,e,i){const r=i.currentFragment.tracks.find((t=>t.trackId===e.privData.trackId)),s=r?r.baseMediaDecodeTime:BigInt(0);t.writeUint32(20),t.writeString("tfdt"),t.writeUint8(1),t.writeUint24(0),t.writeUint64(s)},trun:function(t,e,i){const r=e.privData,s=i.currentFragment.tracks.find((t=>t.trackId===r.trackId)),a=s.firstSampleFlags||0,n=s.dataOffset||0,o=s.sampleDurations,h=s.sampleSizes,c=s.sampleFlags,u=s.sampleCompositionTimeOffset,d=s.sampleCount,l=o.length>0,f=h.length>0,p=c.length>0,m=u.length>0,g=0!==a;let v=1;g&&(v|=4),l&&(v|=256),f&&(v|=512),p&&(v|=1024),m&&(v|=2048);const A=t.getPos();t.writeUint32(0),t.writeString("trun"),t.writeUint8(1),t.writeUint24(v),t.writeUint32(d),s.dataOffsetPos=t.getPos(),t.writeInt32(n),g&&t.writeUint32(a);for(let e=0;e{e.pos=s?(t.seekInline(r+Number(e.pos-i)),t.writeUint32(e.size)):a.push(e)})),R.__(a,(e=>{t.seek(e.pos),t.writeUint32(e.size)})),a.length?t.seek(i):t.seekInline(r),e.boxsPositionInfo=[]}function K(t,e,i,r){R.__(e,(e=>{if(!e)return!0;if(q[e.type])q[e.type](t,i,r);else if(e.children){const s=t.getPos();t.writeUint32(0),t.writeUint32((0,S.A)(e.type)),K(t,e.children,i,r),r.boxsPositionInfo.push({pos:s,type:e.type,size:Number(t.getPos()-s)})}else!function(t,e){const i=R.zy(M._l,e);t.writeUint32(i?12:8),t.writeUint32((0,S.A)(e)),i&&t.writeUint32(0)}(t,e.type)}))}function J(t,e,i){const r=t.getPos();if(t.writeUint32(0),t.writeUint32((0,S.A)("moov")),q.mvhd(t,null,i),R.__(e.streams,(e=>{const r=t.getPos();t.writeUint32(0),t.writeUint32((0,S.A)("trak")),K(t,i.fragment?j[e.codecpar.codecType](i):H[e.codecpar.codecType](i),e,i),i.boxsPositionInfo.push({pos:r,type:"trak",size:Number(t.getPos()-r)})})),i.fragment){const r=t.getPos();t.writeUint32(0),t.writeUint32((0,S.A)("mvex")),R.__(e.streams,(e=>{q.trex(t,e,i)})),i.boxsPositionInfo.push({pos:r,type:"mvex",size:Number(t.getPos()-r)})}i.boxsPositionInfo.push({pos:r,type:"moov",size:Number(t.getPos()-r)}),Y(t,i)}var X=i(8106),Z=i(3384),tt=i(2647);function et(t,e=0){if(!t)return!1;if(t.length<2)return!0;let i=t[e],r=e+1;for(;r{if(-1===t.codecpar.codecType||t.codecpar.codecType>=5)return!0;i[t.codecpar.codecType]<0&&(i[t.codecpar.codecType]=r),1&t.disposition&&(e[t.codecpar.codecType]++,t.privData.flags|=1)}));for(let r=0;r<5;r++)switch(r){case 0:case 1:case 3:e[r]>1&&(t.streams[e[r]].privData.perStreamGrouping=!0),!e[r]&&i[r]>=0&&(t.streams[i[r]].privData.flags|=1)}}writeHeader(t){if(this.context.majorBrand=(0,S.A)("isom"),this.context.minorVersion=512,this.context.compatibleBrand=[(0,S.A)("isom")],this.context.timescale=1e3,this.options.fragment&&(this.context.compatibleBrand.push((0,S.A)("iso6")),this.context.fragment=!0),1===this.options.movMode&&(this.context.isom=!0,this.context.majorBrand=(0,S.A)("qt "),this.context.compatibleBrand=[this.context.majorBrand]),1!==this.options.movMode){this.context.compatibleBrand.push((0,S.A)("iso2"));const e=t.getStreamByMediaType(0);e&&27===e.codecpar.codecId&&this.context.compatibleBrand.push((0,S.A)("avc1")),this.context.compatibleBrand.push((0,S.A)("mp41"))}if(function(t,e){t.flush();const i=t.getPointer(),r=t.getPos();t.writeUint32(0),t.writeUint32((0,S.A)("ftyp")),t.writeUint32(e.majorBrand||(0,S.A)("isom")),t.writeUint32(e.minorVersion||512),R.__(e.compatibleBrand,(e=>{t.writeUint32(e)})),function(t,e,i){const r=t.getPointer();t.seekInline(e),t.writeUint32(i),t.seekInline(r)}(t,i,Number(t.getPos()-r)),e.isom?(t.writeUint32(8),t.writeUint32((0,S.A)("wide"))):e.fragment||(t.writeUint32(8),t.writeUint32((0,S.A)("free")))}(t.ioWriter,this.context),this.context.holdMoovPos=t.ioWriter.getPos(),this.options.fragment)this.context.currentFragment={pos:BigInt(0),currentTrack:null,sequence:1,tracks:[],size:0,firstWrote:!1},R.__(t.streams,((t,e)=>{const i=(0,X.A)();t.privData=i,i.chunkOffsets=[],i.cttsSampleCounts=[],i.cttsSampleOffsets=[],i.stscFirstChunk=[],i.stscSamplesPerChunk=[],i.stscSampleDescriptionIndex=[],i.stssSampleNumbers=[],i.sampleSizes=[],i.sttsSampleCounts=[],i.sttsSampleDeltas=[],i.alternateGroup=e;const r=(0,Z.A)();r.baseIsMoof=this.options.defaultBaseIsMoof,r.streamIndex=t.index,r.trackId=this.context.nextTrackId++,i.trackId=r.trackId,r.ioWriter=new v.A,r.ioWriter.onFlush=t=>(r.buffers.push(t.slice()),0),this.context.currentFragment.tracks.push(r)})),this.enableStreams(t),J(t.ioWriter,t,this.context),t.ioWriter.flush();else{R.__(t.streams,((t,e)=>{const i=(0,X.A)();t.privData=i,i.trackId=this.context.nextTrackId++,i.chunkOffsets=[],i.cttsSampleCounts=[],i.cttsSampleOffsets=[],i.stscFirstChunk=[],i.stscSamplesPerChunk=[],i.stscSampleDescriptionIndex=[],i.stssSampleNumbers=[],i.sampleSizes=[],i.sttsSampleCounts=[],i.sttsSampleDeltas=[],i.alternateGroup=e})),this.enableStreams(t);const e=t.ioWriter.getPos();t.ioWriter.writeUint32(0),t.ioWriter.writeUint32((0,S.A)("mdat")),this.context.boxsPositionInfo.push({pos:e,type:"mdat",size:0})}return 0}updateCurrentChunk(t){let e=this.context.currentChunk;if(!e.sampleCount)return;const i=t.streams.find((t=>t.index===e.streamIndex)).privData;i.chunkCount++,i.chunkOffsets.push(e.pos),i.stscFirstChunk.length?i.lastStscCount!==e.sampleCount&&(i.stscFirstChunk.push(i.chunkCount),i.stscSamplesPerChunk.push(e.sampleCount),i.stscSampleDescriptionIndex.push(1),i.lastStscCount=e.sampleCount):(i.stscFirstChunk.push(i.chunkCount),i.stscSamplesPerChunk.push(e.sampleCount),i.stscSampleDescriptionIndex.push(1),i.lastStscCount=e.sampleCount)}checkMdat(t,e){const i=this.context.boxsPositionInfo[this.context.boxsPositionInfo.length-1];if("mdat"!==i.type)return void g.z3("last box is not mdat",ct,298);const r=t.ioWriter.getPos(),s=Number(r-i.pos);s+e>U.f7&&(i.size=s,t.ioWriter.writeUint32(0),t.ioWriter.writeUint32((0,S.A)("mdat")),this.context.boxsPositionInfo.push({pos:r,type:"mdat",size:0}))}updateCurrentFragment(t,e){if(this.context.currentFragment.firstWrote){R.__(this.context.currentFragment.tracks,(i=>{const r=t.streams.find((t=>t.index===i.streamIndex));if(!i.sampleCount||!r)return!0;const s=r.privData;var a;i.baseDataOffset=t.ioWriter.getPos(),i.sampleDurations.length?e&&i.sampleDurations.length===i.sampleSizes.length-1&&i.sampleDurations.push(Number(e-s.lastDts)):1===r.codecpar.codecType?e?i.sampleDurations.push(Number(e-s.lastDts)):r.codecpar.frameSize>0?i.sampleDurations.push(Number((0,D.k)(BigInt(r.codecpar.frameSize/r.codecpar.sampleRate*U.SF),U.KR,r.timeBase))):(r.codecpar.codecId,i.sampleDurations.push(Number((0,D.k)(BigInt(1024/r.codecpar.sampleRate*U.SF),U.KR,r.timeBase)))):0===r.codecpar.codecType?e?i.sampleDurations.push(Number(e-s.lastDts)):(0,D.lb)(r.codecpar.framerate)>0?i.sampleDurations.push(Number((0,D.k)(BigInt(Math.floor(1/(0,D.lb)(r.codecpar.framerate)*U.SF)),U.KR,r.timeBase))):i.sampleDurations.push(r.timeBase.den/(30*r.timeBase.num)>>>0):i.sampleDurations.push(0),s.lastDuration=i.sampleDurations[i.sampleSizes.length-1],(1===i.sampleFlags.length||et(i.sampleFlags,1))&&(i.firstSampleFlags=i.sampleFlags[0],i.defaultSampleFlags=null!==(a=i.sampleFlags[1])&&void 0!==a?a:i.firstSampleFlags,i.sampleFlags=[]),(1===i.sampleSizes.length||et(i.sampleSizes))&&(i.defaultSampleSize=i.sampleSizes[0],i.sampleSizes=[]),(1===i.sampleDurations.length||et(i.sampleDurations))&&(i.defaultSampleDuration=i.sampleDurations[0],i.sampleDurations=[]),1===r.codecpar.codecType?i.defaultSampleFlags=33554432:i.sampleFlags.length&&(i.defaultSampleFlags=i.sampleFlags[0]),i.sampleSizes.length&&(i.defaultSampleSize=i.sampleSizes[0]),i.sampleDurations.length&&(i.defaultSampleDuration=i.sampleDurations[0])})),t.ioWriter.flush(),function(t,e,i){const r=t.getPos();t.writeUint32(0),t.writeUint32((0,S.A)("moof")),q.mfhd(t,null,i),R.__(i.currentFragment.tracks,(r=>{if(!r.sampleCount)return!0;const s=t.getPos();t.writeUint32(0),t.writeUint32((0,S.A)("traf"));const a=e.streams.find((t=>t.privData.trackId===r.trackId));K(t,Q,a,i),i.boxsPositionInfo.push({pos:s,type:"traf",size:Number(t.getPos()-s)})}));const s=Number(t.getPos()-r);i.boxsPositionInfo.push({pos:r,type:"moof",size:s}),i.currentFragment.size=s}(t.ioWriter,t,this.context);let i=this.context.currentFragment.size+8;const r=[];let s=8;R.__(this.context.currentFragment.tracks,(e=>{if(!e.sampleCount)return!0;e.ioWriter.flush();const a=(0,tt.A)(Uint8Array,e.buffers);e.dataOffset=i,i+=a.length,s+=a.length,r.push(a),function(t,e,i,r){const s=t.getPos(),a=t.getPointer(),n=s-BigInt(Math.floor(a));let o=!1;e=n?(t.seekInline(a+Number(e-s)),o=!0):t.seek(e),t.writeInt32(i),o?t.seekInline(a):t.seek(s)}(t.ioWriter,e.dataOffsetPos,e.dataOffset),e.buffers=[],e.sampleFlags=[],e.sampleSizes=[],e.sampleDurations=[],e.sampleCompositionTimeOffset=[],e.sampleCount=0,e.firstSampleFlags=0})),t.ioWriter.writeUint32(s),t.ioWriter.writeUint32((0,S.A)("mdat")),R.__(r,(e=>{t.ioWriter.writeBuffer(e)})),Y(t.ioWriter,this.context),t.ioWriter.flush(),this.context.currentFragment.firstWrote=!1,this.context.currentFragment.sequence++}}writeAVPacket(t,e){if(!o.f[15](e+28))return g.R8(`packet's size is 0: ${o.f[15](e+32)}, ignore it`,ct,465),0;const i=t.getStreamByIndex(o.f[15](e+32));if(!i)return void g.R8(`can not found the stream width the avpacket's streamIndex: ${o.f[15](e+32)}, ignore it`,ct,472);const r=i.privData,s=(0,D.k)(o.f[17](e+16),(0,c.A)(e+72,h.P),i.timeBase),a=(0,D.k)(o.f[17](e+8)t.streamIndex===o.f[15](e+32)));if(n){if((0===this.options.fragmentMode&&0===i.codecpar.codecType&&1&o.f[15](e+36)||1===this.options.fragmentMode)&&(1===this.context.currentFragment.tracks.length?this.updateCurrentFragment(t,s):this.updateCurrentFragment(t)),n.ioWriter.writeBuffer((0,it.iI)(e)),n.sampleSizes.length||(n.baseMediaDecodeTime=s),n.sampleSizes.length&&(!n.sampleDurations[n.sampleSizes.length-1]||n.sampleDurations[n.sampleSizes.length-1]<=0)&&(n.sampleDurations[n.sampleSizes.length-1]=Number(s-r.lastDts)),o.f[17](e+48)>0&&n.sampleDurations.push(Number((0,D.k)(o.f[17](e+48),(0,c.A)(e+72,h.P),i.timeBase))),n.sampleSizes.push(o.f[15](e+28)),0===i.codecpar.codecType){let t=0;1&o.f[15](e+36)?t|=33554432:t|=16842752,n.sampleCompositionTimeOffset.push(Number((a||s)-s)),n.sampleFlags.push(t)}n.sampleCount++,r.lastPts=a>r.lastPts?a:r.lastPts,r.lastDts=s,this.context.currentFragment.firstWrote=!0}else g.R8(`can not found track width streamIndex ${o.f[15](e+32)}, ignore it`,ct,551)}else{this.checkMdat(t,o.f[15](e+28));const n=t.ioWriter.getPos();let h=this.context.currentChunk;if(h?h.streamIndex!==o.f[15](e+32)?(this.updateCurrentChunk(t),h.streamIndex=o.f[15](e+32),h.sampleCount=1,h.pos=n):h.sampleCount++:h=this.context.currentChunk={pos:n,streamIndex:o.f[15](e+32),sampleCount:1},t.ioWriter.writeBuffer((0,it.iI)(e)),r.sampleSizes.push(o.f[15](e+28)),0===i.codecpar.codecType&&1&o.f[15](e+36)&&r.stssSampleNumbers.push(r.sampleSizes.length),r.firstWrote){const t=Number(s-r.lastDts);r.sttsSampleCounts.length&&r.sttsSampleDeltas[r.sttsSampleDeltas.length-1]===t?r.sttsSampleCounts[r.sttsSampleCounts.length-1]++:(r.sttsSampleCounts.push(1),r.sttsSampleDeltas.push(t))}else r.startDts=s,r.startCT=Number((a||s)-s),r.firstWrote=!0;if(0===i.codecpar.codecType){const t=Number((a||s)-s);r.cttsSampleCounts.length&&r.cttsSampleOffsets[r.cttsSampleOffsets.length-1]===t?r.cttsSampleCounts[r.cttsSampleCounts.length-1]++:(r.cttsSampleCounts.push(1),r.cttsSampleOffsets.push(t))}r.lastPts=(a||s)>r.lastPts?a||s:r.lastPts,r.lastDts=s}return 0}writeTrailer(t){if(this.context.fragment)R.__(this.context.currentFragment.tracks,(e=>{const i=t.streams.find((t=>t.index===e.streamIndex)).privData;e.sampleCount&&(e.sampleDurations.length?e.sampleDurations.push(e.sampleDurations[e.sampleDurations.length-1]):e.sampleDurations=[i.lastDuration])})),this.updateCurrentFragment(t),t.ioWriter.writeUint32(8),t.ioWriter.writeString("mfra"),t.ioWriter.flush();else{this.updateCurrentChunk(t);let e,i=BigInt(0);R.__(t.streams,(t=>{const r=t.privData;r.sampleSizes.length&&(r.sttsSampleDeltas.length?r.sttsSampleCounts[r.sttsSampleCounts.length-1]++:(r.sttsSampleCounts=[1],r.sttsSampleDeltas=[0])),r.lastPts>i&&(i=r.lastPts,e=t.timeBase)})),this.context.duration=(0,D.k)(i,e,{den:1e3,num:1});const r=this.context.boxsPositionInfo[this.context.boxsPositionInfo.length-1];if("mdat"!==r.type&&g.z3("last box is not mdat",ct,665),r.size=Number(t.ioWriter.getPos()-r.pos),Y(t.ioWriter,this.context),this.options.fastOpen){t.ioWriter.flush();let e=[];const i=t.ioWriter.onFlush;t.ioWriter.onFlush=t=>(e.push(t.slice()),0),J(t.ioWriter,t,this.context),t.ioWriter.flush();let r=(0,tt.A)(Uint8Array,e);R.__(t.streams,(t=>{const e=t.privData;if(e.chunkOffsets.length)for(let t=0;t{const i=t.streams.find((t=>t.index===e.streamIndex)).privData;e.sampleCount&&(e.sampleDurations.length?e.sampleDurations.push(e.sampleDurations[e.sampleDurations.length-1]):e.sampleDurations=[i.lastDuration])})),this.updateCurrentFragment(t)),t.ioWriter.flush(),0}}var lt,ft=i(5546),pt=i(9148);!function(t){t[t.ADD=0]="ADD",t[t.REMOVE=1]="REMOVE",t[t.UPDATE_TIMESTAMP_OFFSET=2]="UPDATE_TIMESTAMP_OFFSET"}(lt||(lt={}));const mt={mediaBufferMax:10};class gt{constructor(t={}){(0,I.A)(this,"sourceBuffer",void 0),(0,I.A)(this,"operatorQueue",void 0),(0,I.A)(this,"updating",void 0),(0,I.A)(this,"lastRemoveTime",void 0),(0,I.A)(this,"paddingCallback",void 0),(0,I.A)(this,"options",void 0),(0,I.A)(this,"ending",void 0),(0,I.A)(this,"onQuotaExceededError",void 0),(0,I.A)(this,"onEnded",void 0),this.options=w.X$({},mt,t),this.operatorQueue=[],this.updating=!1,this.lastRemoveTime=0,this.ending=!1}setSourceBuffer(t){this.sourceBuffer=t,this.sourceBuffer.addEventListener("updateend",(()=>{this.paddingCallback&&(this.paddingCallback(),this.paddingCallback=null),this.operatorQueue&&this.operatorQueue.length?this.enqueue():(this.updating=!1,this.ending&&this.onEnded&&this.onEnded())})),this.sourceBuffer.addEventListener("error",(t=>{g.z3("track update buffer error","src/avrender/track/Track.ts",102)}))}changeMimeType(t){this.sourceBuffer&&this.sourceBuffer.changeType(t)}addBuffer(t,e){if(t)if(this.updating||this.operatorQueue.length)this.operatorQueue.push({operator:lt.ADD,buffer:t,callback:e});else try{this.sourceBuffer.appendBuffer(t),this.updating=!0,e&&(this.paddingCallback=e)}catch(i){if(!(i instanceof DOMException&&"QuotaExceededError"===i.name))throw i;this.operatorQueue.push({operator:lt.ADD,buffer:t,callback:e}),this.onQuotaExceededError&&this.onQuotaExceededError()}else e&&e()}updateTimestampOffset(t,e){this.updating||this.operatorQueue.length?this.operatorQueue.push({operator:lt.UPDATE_TIMESTAMP_OFFSET,timestampOffset:t,callback:e}):(this.sourceBuffer.timestampOffset=t,e&&e(),this.enqueue())}end(){this.ending=!0,this.updating||this.operatorQueue.length||this.onEnded&&this.onEnded()}isPaused(){return!this.updating&&this.operatorQueue.length}getQueueLength(){return this.operatorQueue.length}enqueue(){if(this.operatorQueue.length){const t=this.operatorQueue.shift();if(t.operator===lt.ADD)try{this.sourceBuffer.appendBuffer(t.buffer),this.updating=!0,t.callback&&(this.paddingCallback=t.callback)}catch(e){if(!(e instanceof DOMException&&"QuotaExceededError"===e.name))throw e;this.operatorQueue.unshift(t),this.onQuotaExceededError&&this.onQuotaExceededError(),this.updating=!1}else t.operator===lt.REMOVE?(this.sourceBuffer.remove(t.start,t.end),this.updating=!0,t.callback&&(this.paddingCallback=t.callback)):t.operator===lt.UPDATE_TIMESTAMP_OFFSET&&(this.sourceBuffer.timestampOffset=t.timestampOffset,t.callback&&t.callback(),this.enqueue())}}removeBuffer(t,e){this.ending||(t=Math.floor(t))-this.lastRemoveTimethis.endPos)return!1;this.pos=t,this.index=-1,this.offset=-1;let e=this.startPos;for(let i=0;i0&&t.avpacketPool.release(t.audio.backPacket),t.audio.backPacket=await this.pullAVPacket(t.audio,t),t.audio.backPacket<0){t.audio.packetEnded=!0,t.audio.backPacket=0;break}if((0,D.k)(o.f[17](t.audio.backPacket+16),(0,c.A)(t.audio.backPacket+72,h.P),U.i0)>(0,D.k)(o.f[17](t.video.backPacket+16),(0,c.A)(t.video.backPacket+72,h.P),U.i0))break}if(1&o.f[15](t.video.backPacket+36))break;e=!1,t.avpacketPool.release(t.video.backPacket)}return e}getSourceOpenHandler(t){return async()=>{await this.syncToKeyframe(t);const e=[];t.audio&&(t.audio.track.setSourceBuffer(this.createSourceBuffer(t.mediaSource,t.audio.oformatContext.streams[0].codecpar[n.o9])),t.audio.enableRawMpeg||(x(t.audio.oformatContext,{paddingZero:!0}),_(t.audio.oformatContext)),e.push(this.startMux(t.audio,t))),t.video&&(t.video.track.setSourceBuffer(this.createSourceBuffer(t.mediaSource,t.video.oformatContext.streams[0].codecpar[n.o9])),t.video.enableRawMpeg||(x(t.video.oformatContext,{paddingZero:!0}),_(t.video.oformatContext)),e.push(this.startMux(t.video,t))),await s().all(e);let i=!1,r=!1;t.audio&&(t.audio.backPacket=await this.pullAVPacket(t.audio,t),t.audio.backPacket>0?(i=!0,t.audio.frontPacket=await this.pullAVPacket(t.audio,t),t.audio.frontPacket>0?t.audio.frontBuffered=!0:(t.audio.frontPacket=0,t.audio.packetEnded=!0)):t.audio.packetEnded=!0,t.audio.enableRawMpeg||t.audio.oformatContext.ioWriter.flush(),t.audio.track.addBuffer(t.audio.bufferQueue.flush())),t.video&&(t.video.backPacket=await this.pullAVPacket(t.video,t),t.video.backPacket>0?(r=!0,t.video.frontPacket=await this.pullAVPacket(t.video,t),t.video.frontPacket>0?t.video.frontBuffered=!0:(t.video.frontPacket=0,t.video.packetEnded=!0)):t.video.packetEnded=!0,t.video.enableRawMpeg||t.video.oformatContext.ioWriter.flush(),t.video.track.addBuffer(t.video.bufferQueue.flush())),t.audio&&(i?(this.createLoop(t.audio,t),t.audio.loop.start()):t.audio.track.end()),t.video&&(r?(this.createLoop(t.video,t),t.video.loop.start()):t.video.track.end()),await new xt.A(.1);let a=0;t.audio?a=t.video?Math.max(t.audio.track.getBufferedStart(),t.video.track.getBufferedStart()):t.audio.track.getBufferedStart():t.video&&(a=t.video.track.getBufferedStart()),(kt.A.safari||a>.2)&&t.controlIPCPort.notify("seek",{time:a})}}createSourceBuffer(t,e){let i="";return 1===o.f[15](e)?i=(0,yt.A)(e):0===o.f[15](e)&&(i=(0,wt.A)(e)),i||g.h2("invalid stream",Tt,343),t.addSourceBuffer(i)}mixExtradata(t,e,i,r){e.oformatContext.streams[0].codecpar.codecId;const s=e.oformatContext.streams[0].codecpar;s.extradata&&(0,ot.Eb)(s.extradata),s.extradata=(0,ot.sY)(r),(0,a.Mr)(s.extradata,i,r),s.extradataSize=r}async pullAVPacket(t,e){const i=t.pullQueue;if(i.ended&&!i.queue.length)return-1048576;const r=i.queue.length?i.queue.shift():await t.pullIPC.request("pull");if(r<0)return i.ended=!0,-1048576;if(o.f[17](r+16)0)u.M[17](r+8,o.f[17](r+16));else if("video"===t.type&&!e.isLive)if(1&o.f[15](r+36))if(o.f[17](r+8)a)break;s=_t.jk(s,o.f[17](e+8))}si.lastPTS&&(i.lastPTS=o.f[17](r+8)),i.lastDTS=o.f[17](r+16),"audio"===t.type&&i.useSampleRateTimeBase&&(i.frameCount===U.Dh?(i.frameCount=(0,D.k)(o.f[17](r+16),(0,c.A)(r+72,h.P),t.oformatContext.streams[0].timeBase),u.M[17](r+16,i.frameCount),u.M[17](r+8,i.frameCount)):(i.frameCount=i.frameCount+BigInt(o.f[15](t.codecpar+116)>>>0),u.M[17](r+16,i.frameCount),u.M[17](r+8,i.frameCount)),(0,a.Mr)(r+72,t.oformatContext.streams[0].timeBase[n.o9],8)),r}writeAVPacket(t,e,i=!1){if(e.enableRawMpeg){if(!e.timestampOffsetUpdated){const i=(0,D.k)(o.f[17](t+8),(0,c.A)(t+72,h.P),U.i0);e.track.updateTimestampOffset((0|Number(0xffffffffn&i))/1e3),e.timestampOffsetUpdated=!0}e.bufferQueue.push((0,a.s3)(o.f[20](t+24),o.f[15](t+28)).slice())}else!function(t,e){const i=t.processPrivateData;i.first.has(o.f[15](e+32))||(o.f[17](e+16)>BigInt(0)?i.first.set(o.f[15](e+32),o.f[17](e+16)):i.first.set(o.f[15](e+32),BigInt(0))),t.options.paddingZero&&(u.M[17](e+16,o.f[17](e+16)-i.first.get(o.f[15](e+32))),u.M[17](e+8,o.f[17](e+8)-i.first.get(o.f[15](e+32)))),t.oformat.writeAVPacket(t,e)}(e.oformatContext,t),i&&e.oformatContext.ioWriter.flush()}swap(t,e){if(t.backPacket&&e.avpacketPool.release(t.backPacket),t.backPacket=0,!t.frontBuffered)return!1;t.backPacket=t.frontPacket,t.frontPacket=0,t.frontBuffered=!1;const i=(0,At.A)();return this.pullAVPacket(t,e).then((r=>{if(r<0)return t.packetEnded=!0,void(t.frontPacket=0);const s=(0,At.A)()-i;s>5&&(t.startTimestamp+=BigInt(Math.floor(s))),t.frontPacket=r,t.frontBuffered=!0,t.seekSync&&(t.seekSync(),t.seekSync=null),t.backPacket||this.swap(t,e)})),!0}createLoop(t,e){t.loop=new pt.A((()=>{const i=t.track.getBufferedEnd()-(e.currentTime+((0,At.A)()-e.currentTimeNTP)/1e3);if(i>1*(e.playRate>BigInt(100)?Number(e.playRate)/100:1))return void t.loop.emptyTask();if(!t.backPacket)return void(t.packetEnded&&!t.frontPacket?(t.ended=!0,t.loop.stop(),t.enableRawMpeg||(P(t.oformatContext),T(t.oformatContext)),t.bufferQueue.size&&t.track.addBuffer(t.bufferQueue.flush()),t.track.end()):t.loop.emptyTask());let r=t.backPacket;const s=(0,D.k)(o.f[17](r+16),(0,c.A)(r+72,h.P),U.i0);if(e.enableJitterBuffer&&(o.f[15](e.stats+212)?o.f[15](e.stats+32)/o.f[15](e.stats+212)*1e3:o.f[15](e.stats+200)?o.f[15](e.stats+112)/o.f[15](e.stats+200)*1e3:0)<=o.f[15](e.jitterBuffer)&&this.setPlayRate(e.taskId,1),s*BigInt(100)/e.playRate+t.startTimestamp-BigInt(Math.floor((0,At.A)()))<=0||i<.5*(e.playRate>BigInt(100)?Number(e.playRate)/100:1)){t.track.isPaused()&&t.track.enqueue(),u.M[15](r+32,t.oformatContext.streams[0].index);const i=(0,it.rU)(r,1);i&&It(t.oformatContext.streams[0].codecpar.extradata,t.oformatContext.streams[0].codecpar.extradataSize,o.f[20](i),o.f[15](i+4))&&this.mixExtradata(r,t,o.f[20](i),o.f[15](i+4)),this.writeAVPacket(r,t,!0),t.track.addBuffer(t.bufferQueue.flush());const a=t.oformatContext.streams[0].codecpar.codecType;if(0===a?(u.M[17](e.stats+136,o.f[17](e.stats+136)+BigInt(1)),u.M[17](e.stats+144,o.f[17](e.stats+144)+BigInt(1))):1===a&&(u.M[17](e.stats+56,o.f[17](e.stats+56)+BigInt(1)),u.M[17](e.stats+64,o.f[17](e.stats+64)+BigInt(1))),e.playRate!==e.targetRate&&(t.startTimestamp=BigInt(Math.floor((0,At.A)()))-s*BigInt(100)/e.targetRate,e.playRate=e.targetRate),t.packetEnded&&!t.frontPacket)return t.ended=!0,t.loop.stop(),t.enableRawMpeg||(P(t.oformatContext),T(t.oformatContext)),t.bufferQueue.size&&t.track.addBuffer(t.bufferQueue.flush()),void t.track.end();this.swap(t,e)}else t.loop.emptyTask()}),0,0)}async startMux(t,e){let i,r=U.Dh,s=U.Dh,a=BigInt(0);const n=t.oformatContext.streams[0].timeBase;for(t.backPacket>0&&(r=o.f[17](t.backPacket+16),s=o.f[17](t.backPacket+8),u.M[15](t.backPacket+32,t.oformatContext.streams[0].index),this.writeAVPacket(t.backPacket,t),e.avpacketPool.release(t.backPacket),t.backPacket=0);r{t.startTimestamp-=BigInt(100)},r.onEnded=()=>{e.audio&&!e.audio.ended||e.video&&!e.video.ended||(e.mediaSource.endOfStream(),g.pq(`muxer ended, taskId: ${e.taskId}`,Tt,718))},t.track=r,t.packetEnded=!1,t.ended=!1,t.startTimestamp=BigInt(0),t.frontBuffered=!1,t.seekSync=null,t.loop&&(t.loop.destroy(),t.loop=null),t.frontPacket&&(e.avpacketPool.release(t.frontPacket),t.frontPacket=0),t.backPacket&&(e.avpacketPool.release(t.backPacket),t.backPacket=0),t.pullQueue.ended=!1,t.pullQueue.index=0,t.pullQueue.frameCount=U.Dh,t.pullQueue.lastPTS=BigInt(0),t.pullQueue.lastDTS=BigInt(0),t.pullQueue.diff=BigInt(0)}async addStream(t,e,i,r,s,a){const h=this.tasks.get(t);if(h){const t=new v.A(1048576),c=(0,l.f)(),d=new dt({fragmentMode:1,fragment:!0,fastOpen:!0,movMode:0,defaultBaseIsMoof:!0}),f=new bt;t.onFlush=t=>(f.push(t.slice()),0),t.onSeek=t=>f.seek(t)?0:p.lh;const A=c.createStream();(0,ft.Yi)(A.codecpar[n.o9],i),86017===o.f[15](i+4)&&(A.codecpar.codecTag=(0,S.A)(".mp3"));const y=1===o.f[15](i)&&o.f[15](i+116)&&!h.isLive&&(0,D.Vt)(r)>(0,D.lb)({num:1,den:o.f[15](i+108)});y?(A.timeBase.den=o.f[15](i+108),A.timeBase.num=1):(A.timeBase.den=o.f[15](r+4),A.timeBase.num=o.f[15](r)),c.oformat=d,c.ioWriter=t;const w=new gt,b={type:"audio",codecpar:i,ioWriter:t,oformatContext:c,oformat:d,track:w,bufferQueue:f,streamIndex:e,pullIPC:new m.Ay(a),loop:null,frontPacket:0,backPacket:0,frontBuffered:!1,startTimestamp:BigInt(0),packetEnded:!1,ended:!1,seekSync:null,startPTS:s,pullQueue:{queue:[],index:0,frameCount:U.Dh,diff:BigInt(0),lastPTS:BigInt(0),lastDTS:BigInt(0),ended:!1,useSampleRateTimeBase:y},enableRawMpeg:86017===o.f[15](i+4)&&!kt.A.firefox,timestampOffsetUpdated:!1};w.onQuotaExceededError=()=>{b.startTimestamp-=BigInt(100)},w.onEnded=()=>{h.audio&&!h.audio.ended||h.video&&!h.video.ended||(h.mediaSource.endOfStream(),g.pq(`muxer ended, taskId: ${h.taskId}`,Tt,851))},1===o.f[15](i)?(h.audio=b,u.M[15](h.stats+4,o.f[15](i+108)),u.M[15](h.stats,o.f[15](i+140))):0===o.f[15](i)&&(b.type="video",h.video=b,u.M[15](h.stats+76,o.f[15](i+48)),u.M[15](h.stats+80,o.f[15](i+52)),o.f[15](h.stats+76)*o.f[15](h.stats+80)>8294400&&kt.A.safari&&(h.cacheDuration=_t.T9(BigInt(3e3),h.cacheDuration)))}else g.h2("task not found",Tt,872)}async pause(t){const e=this.tasks.get(t);var i,r,s,a;e?(null!==(i=e.audio)&&void 0!==i&&i.loop||null!==(r=e.video)&&void 0!==r&&r.loop||g.h2("task has not played",Tt,880),e.pausing=!0,e.pauseTimestamp=(0,At.A)(),null===(s=e.audio)||void 0===s||s.loop.stop(),null===(a=e.video)||void 0===a||a.loop.stop()):g.h2("task not found",Tt,888)}async unpause(t){const e=this.tasks.get(t);var i,r;e?(null!==(i=e.audio)&&void 0!==i&&i.loop||null!==(r=e.video)&&void 0!==r&&r.loop||g.h2("task has not played",Tt,896),e.pausing=!1,e.seeking||(e.audio&&(e.audio.startTimestamp+=BigInt(Math.floor((0,At.A)()-e.pauseTimestamp)),e.audio.loop.start()),e.video&&(e.video.startTimestamp+=BigInt(Math.floor((0,At.A)()-e.pauseTimestamp)),e.video.loop.start()))):g.h2("task not found",Tt,913)}async beforeSeek(t){const e=this.tasks.get(t);if(e){var i,r;const t=[];e.audio&&(e.audio.ended||e.audio.frontBuffered||t.push(new(s())((t=>{e.audio.seekSync=t})))),e.video&&(e.video.ended||e.video.frontBuffered||t.push(new(s())((t=>{e.video.seekSync=t})))),await s().all(t),e.seeking=!0,null===(i=e.audio)||void 0===i||i.loop.stop(),null===(r=e.video)||void 0===r||r.loop.stop(),e.audio&&(e.audio.enableRawMpeg||T(e.audio.oformatContext),e.audio.bufferQueue.flush(),kt.A.safari&&await new(s())((t=>{e.audio.track.removeAllBuffer((()=>{t()}))})),e.audio.track.reset(),e.audio.packetEnded=!1,e.audio.timestampOffsetUpdated=!1,e.audio.backPacket&&(e.avpacketPool.release(e.audio.backPacket),e.audio.backPacket=0),e.audio.frontPacket&&(e.avpacketPool.release(e.audio.frontPacket),e.audio.frontPacket=0),e.audio.pullQueue.queue.length&&e.audio.pullQueue.queue.forEach((t=>{e.avpacketPool.release(t)})),e.audio.pullQueue.queue.length=0,e.audio.pullQueue.ended=!1,e.audio.pullQueue.index=0,e.audio.pullQueue.lastPTS=BigInt(0),e.audio.pullQueue.lastDTS=BigInt(0),e.audio.pullQueue.diff=BigInt(0),e.audio.pullQueue.frameCount=U.Dh),e.video&&(e.video.enableRawMpeg||T(e.video.oformatContext),e.video.bufferQueue.flush(),kt.A.safari&&await new(s())((t=>{e.video.track.removeAllBuffer((()=>{t()}))})),e.video.track.reset(),e.video.packetEnded=!1,e.video.timestampOffsetUpdated=!1,e.video.backPacket&&(e.avpacketPool.release(e.video.backPacket),e.video.backPacket=0),e.video.frontPacket&&(e.avpacketPool.release(e.video.frontPacket),e.video.frontPacket=0),e.video.pullQueue.queue.length&&e.video.pullQueue.queue.forEach((t=>{e.avpacketPool.release(t)})),e.video.pullQueue.queue.length=0,e.video.pullQueue.ended=!1,e.video.pullQueue.index=0,e.video.pullQueue.diff=BigInt(0),e.video.pullQueue.lastPTS=BigInt(0),e.video.pullQueue.lastDTS=BigInt(0))}}async afterSeek(t,e){const i=this.tasks.get(t);if(i){let t=e,r=await this.syncToKeyframe(i);for(i.audio&&i.audio.backPacket>0&&(e0&&((!r||e{i.audio.track.addBuffer(i.audio.bufferQueue.flush(),(()=>{t()}))})))),i.video&&(i.video.enableRawMpeg||T(i.video.oformatContext),a.push(new(s())((t=>{i.video.track.addBuffer(i.video.bufferQueue.flush(),(()=>{t()}))})))),await s().all(a),i.audio&&!i.audio.packetEnded&&(i.audio.backPacket<=0&&(i.audio.backPacket=await this.pullAVPacket(i.audio,i),i.audio.backPacket<0&&(i.audio.packetEnded=!0,i.audio.backPacket=0)),i.audio.packetEnded||(i.audio.frontPacket=await this.pullAVPacket(i.audio,i),i.audio.frontPacket<0?(i.audio.frontPacket=0,i.audio.packetEnded=!0,i.audio.frontBuffered=!1):(i.audio.packetEnded=!1,i.audio.frontBuffered=!0),i.audio.startTimestamp=BigInt(Math.floor((0,At.A)()))-(t+i.cacheDuration+(0,D.k)(i.audio.startPTS,i.audio.oformatContext.streams[0].timeBase,U.i0))*BigInt(100)/i.playRate,i.pausing?i.pauseTimestamp=(0,At.A)():i.audio.loop.start())),i.video&&!i.video.packetEnded&&(i.video.backPacket<=0&&(i.video.backPacket=await this.pullAVPacket(i.video,i),i.video.backPacket<0&&(i.video.packetEnded=!0,i.video.backPacket=0)),i.video.packetEnded||(i.video.frontPacket=await this.pullAVPacket(i.video,i),i.video.frontPacket<0?(i.video.packetEnded=!0,i.video.frontBuffered=!1,i.video.frontPacket=0):(i.video.packetEnded=!1,i.video.frontBuffered=!0),i.video.startTimestamp=BigInt(Math.floor((0,At.A)()))-(t+i.cacheDuration+(0,D.k)(i.video.startPTS,i.video.oformatContext.streams[0].timeBase,U.i0))*BigInt(100)/i.playRate,i.pausing?i.pauseTimestamp=(0,At.A)():i.video.loop.start())),r||await new xt.A(.5);let n=0,d=0;i.audio?i.video?(n=Math.max(i.audio.track.getBufferedStart(),i.video.track.getBufferedStart()),d=Math.min(i.audio.track.getBufferedEnd(),i.video.track.getBufferedEnd())):(n=i.audio.track.getBufferedStart(),d=i.audio.track.getBufferedEnd()):i.video&&(n=i.video.track.getBufferedStart(),d=i.video.track.getBufferedEnd());let l=function(t){const e=t/BigInt(1e3),i=t-e*BigInt(1e3);return Number(e)+Number(i)/1e3}(t);return l>=n&&l<=d||(l=Math.abs(l-n)>Math.abs(l-d)?d:n),i.currentTimeNTP=(0,At.A)(),i.currentTime=l,i.seeking=!1,l}}async setPlayRate(t,e){const i=this.tasks.get(t);if(i){if(i.enableJitterBuffer){let t=o.f[15](i.stats+212)?o.f[15](i.stats+32)/o.f[15](i.stats+212)*1e3:o.f[15](i.stats+200)?o.f[15](i.stats+112)/o.f[15](i.stats+200)*1e3:0;t&&t<=o.f[15](i.jitterBuffer)&&(e=1)}i.targetRate=BigInt(Math.floor(Math.floor(100*e))),i.enableJitterBuffer||(i.audio&&i.audio.loop.resetInterval(),i.video&&i.video.loop.resetInterval())}else g.h2("task not found",Tt,1269)}async restart(t){const e=this.tasks.get(t);if(e){e.audio&&this.resetResource(e.audio,e),e.video&&this.resetResource(e.video,e);const t=new((0,Pt.A)());t.onsourceopen=this.getSourceOpenHandler(e),e.mediaSource=t}}async setCurrentTime(t,e){const i=this.tasks.get(t);i?(i.audio&&i.audio.track.removeBuffer(e),i.video&&o.f[15](i.stats+84)>0&&(i.video.track.setMediaBufferMax(Math.max(i.video.track.getMediaBufferMax(),Math.ceil(o.f[15](i.stats+84)/1e3*1.5),10)),i.video.track.removeBuffer(e)),i.currentTime=e,i.currentTimeNTP=(0,At.A)()):g.h2("task not found",Tt,1311)}async getMediaSource(t){const e=this.tasks.get(t);if(e)return e.mediaSource.handle?($.YO(arguments[arguments.length-1])&&arguments[arguments.length-1].push(e.mediaSource.handle),e.mediaSource.handle):e.mediaSource;g.h2("task not found",Tt,1329)}createTask(t){const e=new m.Ay(t.controlPort),i=new MediaSource||new ManagedMediaSource,r={...t,mediaSource:i,audio:null,video:null,playRate:BigInt(100),targetRate:BigInt(100),pauseTimestamp:0,seeking:!1,pausing:!1,controlIPCPort:e,currentTime:0,currentTimeNTP:0,cacheDuration:BigInt(Math.floor(500)),avpacketPool:new vt.A((0,c.A)(t.avpacketList,d.A),t.avpacketListMutex)};return this.tasks.set(t.taskId,r),i.onsourceopen=this.getSourceOpenHandler(r),0}async registerTask(t){return this.tasks.has(t.taskId)?p.lh:this.createTask(t)}async unregisterTask(t){const e=this.tasks.get(t);e&&(e.audio&&(e.audio.loop&&(e.audio.oformatContext.destroy(),e.audio.loop.destroy()),e.audio.pullIPC&&e.audio.pullIPC.destroy(),e.audio.pullQueue.queue.length&&(e.audio.pullQueue.queue.forEach((t=>{e.avpacketPool.release(t)})),e.audio.pullQueue.queue.length=0)),e.video&&(e.video.loop&&(e.video.oformatContext.destroy(),e.video.loop.destroy()),e.video.pullIPC&&e.video.pullIPC.destroy(),e.video.pullQueue.queue.length&&(e.video.pullQueue.queue.forEach((t=>{e.avpacketPool.release(t)})),e.video.pullQueue.queue.length=0)),e.controlIPCPort&&e.controlIPCPort.destroy(),this.tasks.delete(t))}}},5224:(t,e,i)=>{"use strict";i.d(e,{A:()=>n});var r=i(3939),s=i(9603),a=i(4214);function n(t){let e="";return e=86017!==r.f[15](t+4)||a.A.firefox?`audio/mp4; codecs="${(0,s.A)(t)}"`:"audio/mpeg",e}},333:(t,e,i)=>{"use strict";i.d(e,{A:()=>s});var r=i(4663);function s(t){return`video/mp4; codecs="${(0,r.A)(t)}"`}},7231:(t,e,i)=>{"use strict";i.d(e,{Dh:()=>s,KR:()=>o,N_:()=>a,SF:()=>n,f7:()=>d,go:()=>c,i0:()=>h,zg:()=>u});var r=i(9599);const s=-BigInt(1),a=-1,n=1e6,o=new r.P({den:n,num:1}),h=new r.P({den:1e3,num:1}),c=(new r.P({den:1,num:1}),2147483647),u=65535,d=4294967295},9705:(t,e,i)=>{"use strict";i.d(e,{E$:()=>r,LR:()=>s,LT:()=>h,UY:()=>a,gR:()=>n,lh:()=>o});const r=-1,s=-2,a=-3,n=-4,o=-5,h=-7},6041:(t,e,i)=>{"use strict";i.d(e,{A:()=>c});var r=i(1026),s=i(932),a=i(46),n=i(3783),o=i(7837),h=i(4363);class c{constructor(t,e){(0,r.A)(this,"list",void 0),(0,r.A)(this,"mutex",void 0),this.list=t,this.mutex=e}alloc(){let t=this.list.find((t=>-1===a.p_(t+360,-1,1,16,2)),20);return t||(t=(0,o.Gy)(368),(0,h._h)(t),s.M[16](t+360,1),n.s2(this.mutex),this.list.push(t,20),n.Tl(this.mutex)),t}release(t){a.Hh(t+360,16,2)<=0||1===a.jb(t+360,1,16,2)&&((0,h.to)(t),a.M_(t+360,-1,16,2))}}},4290:(t,e,i)=>{"use strict";i.d(e,{A:()=>c});var r=i(1026),s=i(932),a=i(46),n=i(3783),o=i(7837),h=i(1517);class c{constructor(t,e){(0,r.A)(this,"list",void 0),(0,r.A)(this,"mutex",void 0),this.list=t,this.mutex=e}alloc(){let t=this.list.find((t=>-1===a.p_(t+88,-1,1,16,2)),20);return t||(t=(0,o.Gy)(96),(0,h.Pd)(t),s.M[16](t+88,1),n.s2(this.mutex),this.list.push(t,20),n.Tl(this.mutex)),t}release(t){a.Hh(t+88,16,2)<=0||1===a.jb(t+88,1,16,2)&&((0,h.Up)(t),a.M_(t+88,-1,16,2))}}},5495:(t,e,i)=>{"use strict";i.d(e,{A:()=>x});var r,s,a=i(1026),n=i(662),o=i.n(n),h=i(1499),c=i(2085),u=i(9599);class d{constructor(){(0,a.A)(this,"id",void 0),(0,a.A)(this,"name",void 0),(0,a.A)(this,"opaque",void 0)}}r=d.prototype,(s=new(o())).set("id",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),s.set("name",{0:4,1:0,2:0,3:1,4:16,5:0,6:0,7:4,8:0}),s.set("opaque",{0:1,1:1,2:1,3:0,4:0,5:0,6:0,7:20,8:0}),(0,c.A)(r,h.Og,!0),(0,c.A)(r,h.dc,4),(0,c.A)(r,h.g7,24),(0,c.A)(r,h.JY,s);class l{constructor(){(0,a.A)(this,"order",void 0),(0,a.A)(this,"nbChannels",void 0),(0,a.A)(this,"u",void 0),(0,a.A)(this,"opaque",void 0)}}!function(t){var e=new(o());e.set("order",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),e.set("nbChannels",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:4,8:0}),e.set("u",{0:function(t){var e=new(o());return e.set("mask",{0:10,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),e.set("map",{0:d,1:1,2:1,3:0,4:0,5:0,6:0,7:0,8:0}),(0,c.A)(t,h.Og,!0),(0,c.A)(t,h.dc,8),(0,c.A)(t,h.g7,8),(0,c.A)(t,h.JY,e),t}({}),1:0,2:0,3:0,4:0,5:0,6:0,7:8,8:0}),e.set("opaque",{0:1,1:1,2:1,3:0,4:0,5:0,6:0,7:16,8:0}),(0,c.A)(t,h.Og,!0),(0,c.A)(t,h.dc,8),(0,c.A)(t,h.g7,24),(0,c.A)(t,h.JY,e)}(l.prototype);var f,p=i(3783);class m{constructor(){(0,a.A)(this,"data",0),(0,a.A)(this,"size",0),(0,a.A)(this,"refcount",0),(0,a.A)(this,"free",0),(0,a.A)(this,"opaque",0),(0,a.A)(this,"flags",0),(0,a.A)(this,"flagsInternal",0)}}!function(t){var e=new(o());e.set("data",{0:2,1:1,2:1,3:0,4:0,5:0,6:0,7:0,8:0}),e.set("size",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:4,8:0}),e.set("refcount",{0:9,1:0,2:0,3:0,4:0,5:0,6:0,7:8,8:0}),e.set("free",{0:1,1:1,2:1,3:0,4:0,5:0,6:0,7:12,8:0}),e.set("opaque",{0:1,1:1,2:1,3:0,4:0,5:0,6:0,7:16,8:0}),e.set("flags",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:20,8:0}),e.set("flagsInternal",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:24,8:0}),(0,c.A)(t,h.Og,!0),(0,c.A)(t,h.dc,4),(0,c.A)(t,h.g7,28),(0,c.A)(t,h.JY,e)}(m.prototype);class g{constructor(){(0,a.A)(this,"buffer",0),(0,a.A)(this,"data",0),(0,a.A)(this,"size",0)}}!function(t){var e=new(o());e.set("buffer",{0:m,1:1,2:1,3:0,4:0,5:0,6:0,7:0,8:0}),e.set("data",{0:2,1:1,2:1,3:0,4:0,5:0,6:0,7:4,8:0}),e.set("size",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:8,8:0}),(0,c.A)(t,h.Og,!0),(0,c.A)(t,h.dc,4),(0,c.A)(t,h.g7,12),(0,c.A)(t,h.JY,e)}(g.prototype);class v{constructor(){(0,a.A)(this,"mutex",void 0),(0,a.A)(this,"pool",0),(0,a.A)(this,"refcount",0),(0,a.A)(this,"size",0),(0,a.A)(this,"opaque",0),(0,a.A)(this,"alloc",0),(0,a.A)(this,"alloc2",0),(0,a.A)(this,"poolFree",0)}}!function(t){var e=new(o());e.set("mutex",{0:p.eu,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),e.set("pool",{0:f,1:1,2:1,3:0,4:0,5:0,6:0,7:4,8:0}),e.set("refcount",{0:9,1:0,2:0,3:0,4:0,5:0,6:0,7:8,8:0}),e.set("size",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:12,8:0}),e.set("opaque",{0:1,1:1,2:1,3:0,4:0,5:0,6:0,7:16,8:0}),e.set("alloc",{0:1,1:1,2:1,3:0,4:0,5:0,6:0,7:20,8:0}),e.set("alloc2",{0:1,1:1,2:1,3:0,4:0,5:0,6:0,7:24,8:0}),e.set("poolFree",{0:1,1:1,2:1,3:0,4:0,5:0,6:0,7:28,8:0}),(0,c.A)(t,h.Og,!0),(0,c.A)(t,h.dc,4),(0,c.A)(t,h.g7,32),(0,c.A)(t,h.JY,e)}(v.prototype);class A{constructor(){(0,a.A)(this,"data",0),(0,a.A)(this,"opaque",0),(0,a.A)(this,"free",0),(0,a.A)(this,"pool",0),(0,a.A)(this,"next",0),(0,a.A)(this,"buffer",void 0)}}!function(t){var e=new(o());e.set("data",{0:2,1:1,2:1,3:0,4:0,5:0,6:0,7:0,8:0}),e.set("opaque",{0:1,1:1,2:1,3:0,4:0,5:0,6:0,7:4,8:0}),e.set("free",{0:1,1:1,2:1,3:0,4:0,5:0,6:0,7:8,8:0}),e.set("pool",{0:v,1:1,2:1,3:0,4:0,5:0,6:0,7:12,8:0}),e.set("next",{0:A,1:1,2:1,3:0,4:0,5:0,6:0,7:16,8:0}),e.set("buffer",{0:m,1:0,2:0,3:0,4:0,5:0,6:0,7:20,8:0}),(0,c.A)(t,h.Og,!0),(0,c.A)(t,h.dc,4),(0,c.A)(t,h.g7,48),(0,c.A)(t,h.JY,e)}(A.prototype),f=A;var y=i(7231);class w{constructor(){(0,a.A)(this,"data",0),(0,a.A)(this,"size",y.N_),(0,a.A)(this,"type",-1)}}!function(t){var e=new(o());e.set("data",{0:2,1:1,2:1,3:0,4:0,5:0,6:0,7:0,8:0}),e.set("size",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:4,8:0}),e.set("type",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:8,8:0}),(0,c.A)(t,h.Og,!0),(0,c.A)(t,h.dc,4),(0,c.A)(t,h.g7,12),(0,c.A)(t,h.JY,e)}(w.prototype);class b{constructor(){(0,a.A)(this,"buf",0),(0,a.A)(this,"pts",y.Dh),(0,a.A)(this,"dts",y.Dh),(0,a.A)(this,"data",0),(0,a.A)(this,"size",0),(0,a.A)(this,"streamIndex",y.N_),(0,a.A)(this,"flags",0),(0,a.A)(this,"sideData",0),(0,a.A)(this,"sideDataElems",0),(0,a.A)(this,"duration",y.Dh),(0,a.A)(this,"pos",y.Dh),(0,a.A)(this,"opaque",0),(0,a.A)(this,"opaqueRef",0),(0,a.A)(this,"timeBase",new u.P({den:y.SF,num:1})),(0,a.A)(this,"bitFormat",0)}}!function(t){var e=new(o());e.set("buf",{0:g,1:1,2:1,3:0,4:0,5:0,6:0,7:0,8:0}),e.set("pts",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:8,8:0}),e.set("dts",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:16,8:0}),e.set("data",{0:2,1:1,2:1,3:0,4:0,5:0,6:0,7:24,8:0}),e.set("size",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:28,8:0}),e.set("streamIndex",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:32,8:0}),e.set("flags",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:36,8:0}),e.set("sideData",{0:w,1:1,2:1,3:0,4:0,5:0,6:0,7:40,8:0}),e.set("sideDataElems",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:44,8:0}),e.set("duration",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:48,8:0}),e.set("pos",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:56,8:0}),e.set("opaque",{0:1,1:1,2:1,3:0,4:0,5:0,6:0,7:64,8:0}),e.set("opaqueRef",{0:g,1:1,2:1,3:0,4:0,5:0,6:0,7:68,8:0}),e.set("timeBase",{0:u.P,1:0,2:0,3:0,4:0,5:0,6:0,7:72,8:0}),e.set("bitFormat",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:80,8:0}),(0,c.A)(t,h.Og,!0),(0,c.A)(t,h.dc,8),(0,c.A)(t,h.g7,88),(0,c.A)(t,h.JY,e)}(b.prototype),function(t){var e=new(o());e.set("refCount",{0:16,1:0,2:0,3:0,4:0,5:0,6:0,7:88,8:0}),(0,c.A)(t,h.Og,!0),(0,c.A)(t,h.dc,8),(0,c.A)(t,h.g7,96),(0,c.A)(t,h.JY,e)}(class extends b{constructor(...t){super(...t),(0,a.A)(this,"refCount",void 0)}}.prototype);var k=i(5546);class x{constructor(){(0,a.A)(this,"codecType",-1),(0,a.A)(this,"codecId",0),(0,a.A)(this,"codecTag",0),(0,a.A)(this,"extradata",0),(0,a.A)(this,"extradataSize",0),(0,a.A)(this,"format",y.N_),(0,a.A)(this,"bitRate",BigInt(0)),(0,a.A)(this,"bitsPerCodedSample",0),(0,a.A)(this,"bitsPerRawSample",0),(0,a.A)(this,"profile",y.N_),(0,a.A)(this,"level",y.N_),(0,a.A)(this,"width",0),(0,a.A)(this,"height",0),(0,a.A)(this,"sampleAspectRatio",new u.P({den:1,num:0})),(0,a.A)(this,"fieldOrder",0),(0,a.A)(this,"colorRange",0),(0,a.A)(this,"colorPrimaries",2),(0,a.A)(this,"colorTrc",2),(0,a.A)(this,"colorSpace",2),(0,a.A)(this,"chromaLocation",0),(0,a.A)(this,"videoDelay",0),(0,a.A)(this,"channelLayout",BigInt(0)),(0,a.A)(this,"channels",y.N_),(0,a.A)(this,"sampleRate",y.N_),(0,a.A)(this,"blockAlign",0),(0,a.A)(this,"frameSize",0),(0,a.A)(this,"initialPadding",0),(0,a.A)(this,"trailingPadding",0),(0,a.A)(this,"seekPreroll",0),(0,a.A)(this,"chLayout",void 0),(0,a.A)(this,"framerate",new u.P({den:1,num:0})),(0,a.A)(this,"codedSideData",0),(0,a.A)(this,"nbCodedSideData",0),(0,a.A)(this,"bitFormat",0)}destroy(){(0,k.dn)(this[h.o9]),this[h.o9]=0}}!function(t){var e=new(o());e.set("codecType",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),e.set("codecId",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:4,8:0}),e.set("codecTag",{0:8,1:0,2:0,3:0,4:0,5:0,6:0,7:8,8:0}),e.set("extradata",{0:2,1:1,2:1,3:0,4:0,5:0,6:0,7:12,8:0}),e.set("extradataSize",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:16,8:0}),e.set("format",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:20,8:0}),e.set("bitRate",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:24,8:0}),e.set("bitsPerCodedSample",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:32,8:0}),e.set("bitsPerRawSample",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:36,8:0}),e.set("profile",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:40,8:0}),e.set("level",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:44,8:0}),e.set("width",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:48,8:0}),e.set("height",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:52,8:0}),e.set("sampleAspectRatio",{0:u.P,1:0,2:0,3:0,4:0,5:0,6:0,7:56,8:0}),e.set("fieldOrder",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:64,8:0}),e.set("colorRange",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:68,8:0}),e.set("colorPrimaries",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:72,8:0}),e.set("colorTrc",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:76,8:0}),e.set("colorSpace",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:80,8:0}),e.set("chromaLocation",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:84,8:0}),e.set("videoDelay",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:88,8:0}),e.set("channelLayout",{0:10,1:0,2:0,3:0,4:0,5:0,6:0,7:96,8:0}),e.set("channels",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:104,8:0}),e.set("sampleRate",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:108,8:0}),e.set("blockAlign",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:112,8:0}),e.set("frameSize",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:116,8:0}),e.set("initialPadding",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:120,8:0}),e.set("trailingPadding",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:124,8:0}),e.set("seekPreroll",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:128,8:0}),e.set("chLayout",{0:l,1:0,2:0,3:0,4:0,5:0,6:0,7:136,8:0}),e.set("framerate",{0:u.P,1:0,2:0,3:0,4:0,5:0,6:0,7:160,8:0}),e.set("codedSideData",{0:w,1:1,2:1,3:0,4:0,5:0,6:0,7:168,8:0}),e.set("nbCodedSideData",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:172,8:0}),e.set("bitFormat",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:176,8:0}),(0,c.A)(t,h.Og,!0),(0,c.A)(t,h.dc,8),(0,c.A)(t,h.g7,184),(0,c.A)(t,h.JY,e)}(x.prototype)},9599:(t,e,i)=>{"use strict";i.d(e,{P:()=>u});var r,s,a=i(1026),n=i(662),o=i.n(n),h=i(1499),c=i(2085);class u{constructor(t){(0,a.A)(this,"num",1),(0,a.A)(this,"den",1),t&&(this.den=t.den,this.num=t.num)}}r=u.prototype,(s=new(o())).set("num",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),s.set("den",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:4,8:0}),(0,c.A)(r,h.Og,!0),(0,c.A)(r,h.dc,4),(0,c.A)(r,h.g7,8),(0,c.A)(r,h.JY,s)},7815:(t,e,i)=>{"use strict";i.d(e,{A6:()=>g,Q7:()=>p,VG:()=>l,aw:()=>d,us:()=>m});var r=i(4686),s=i(3939),a=i(932),n=i(7837),o=i(46),h=i(3783),c=i(2699);const u=1;function d(t,e,i=0,r=0,s=0){const h=(0,n.Gy)(28);if(!h)return 0;const c=function(t,e,i,r=0,s=0,h=0){a.M[20](t,e),a.M[15](t+4,i),a.M[20](t+12,r),a.M[20](t+16,s),o.M_(t+8,1,9,2),a.M[15](t+20,h);const c=(0,n.Gy)(12);return c?(a.M[20](c,t),a.M[20](c+4,e),a.M[15](c+8,i),c):0}(h,t,e,i,r,s);return c||((0,n.Eb)(h),0)}function l(t){const e=(0,n.Gy)(12);return(0,r.Mr)(e,t,12),o.WQ(s.f[20](t)+8,1,9,2),e}function f(t,e){const i=s.f[20](s.f[20](t));if(e?((0,r.Mr)(s.f[20](t),s.f[20](e),12),(0,n.aI)(e)):(0,n.aI)(t),1===o.jb(i+8,1,9,2)){const t=!(2&s.f[15](i+24));s.f[20](i+16)?v(s.f[20](i+16),s.f[20](i)):(0,n.Eb)(s.f[20](i)),t&&(0,n.Eb)(i)}}function p(t){t&&s.f[20](t)&&f(t,0)}function m(t,e){const i=s.f[20](t);if(!e)return p(t),0;if(i&&s.f[20](i+4)===s.f[20](e+4))return a.M[20](i+4,s.f[20](e+4)),a.M[15](i+8,s.f[15](e+8)),0;const r=l(e);return p(t),a.M[20](t,r),0}function g(t,e){if(!s.f[20](t)){const i=d((0,n.cz)(0,e),e);return a.M[20](t,i),a.M[15](s.f[20](i)+24,s.f[15](s.f[20](i)+24)|u),0}const i=s.f[20](t),h=s.f[20](i);if(s.f[15](i+8)===e)return 0;if(!(s.f[15](h+24)&u&&function(t){return 1&s.f[15](s.f[20](t)+20)?0:1===o.Hh(s.f[20](t)+8,9,2)?1:0}(i)&&s.f[20](i+4)===s.f[20](h))){let i=c.z(4);a.M[20](i,0);const n=g(i,e);return n<0?(c.t(4),n):((0,r.Mr)(s.f[20](s.f[20](i)+4),s.f[20](h),Math.min(e,s.f[15](h+4))),f(t,i),c.t(4),0)}const l=(0,n.cz)(s.f[20](h),e);return a.M[20](i+4,l),a.M[20](h,l),a.M[15](i+8,e),a.M[15](h+4,e),0}function v(t,e){const i=t,r=s.f[20](i+12);h.s2(r),a.M[20](i+16,s.f[20](r+4)),a.M[20](r+4,i),h.Tl(r),1===o.jb(r+8,1,9,2)&&function(t){!function(t){for(;s.f[20](t+4);){const e=s.f[20](t+4);a.M[20](t+4,s.f[20](e+16)),s.f[20](e+4)?v(s.f[20](e+4),s.f[20](e)):(0,n.Eb)(s.f[20](e)),(0,n.Eb)(e)}}(t),h.zr(t),(0,n.Eb)(t)}(r)}},4363:(t,e,i)=>{"use strict";i.d(e,{FP:()=>u,xj:()=>d,_h:()=>p,aH:()=>f,to:()=>m});var r=i(3939),s=i(932),a=i(7837),n=i(4686),o=i(7231),h=i(7815);function c(t){const e=r.f[20](t);if(e){for(;s.M[15](e,r.f[15](e)-1),r.f[15](e)+1;)(0,a.aI)(r.f[20](e+4)+8*r.f[15](e)),(0,a.aI)(r.f[20](e+4)+8*r.f[15](e)+4);(0,a.aI)(e+4)}(0,a.aI)(t)}function u(){const t=(0,a.Gy)(360);return p(t),t}function d(t){m(t),(0,a.Eb)(t)}function l(t){const e=r.f[20](t);(0,h.Q7)(e+16),c(e+12),(0,a.aI)(t)}function f(t,e){for(let i=0;i{"use strict";i.d(e,{Is:()=>p,NX:()=>_,NZ:()=>v,Ow:()=>f,Pd:()=>A,Qe:()=>g,Up:()=>k,Zx:()=>x,_5:()=>m,fQ:()=>l,iI:()=>u,rN:()=>b,rU:()=>d,zu:()=>y});var r=i(4686),s=i(3939),a=i(932),n=i(7837),o=i(7231),h=i(7815);const c=64;function u(t,e){return e?(0,r.JW)(s.f[20](t+24),s.f[15](t+28)):(0,r.s3)(s.f[20](t+24),s.f[15](t+28))}function d(t,e){for(let i=0;i-1)if(1===s.f[15](t+44))(0,n.Eb)(s.f[20](s.f[20](t+40))),(0,n.Eb)(s.f[20](t+40)),a.M[20](t+40,0),a.M[15](t+44,0);else{const e=12*(s.f[15](t+44)-1),o=(0,n.Gy)(e);for(let e=0;e{"use strict";i.d(e,{Yi:()=>c,dn:()=>u});var r=i(4686),s=i(3939),a=i(932),n=i(7837),o=i(1517),h=i(7231);function c(t,e){a.M[15](t,s.f[15](e)),a.M[15](t+4,s.f[15](e+4)),a.M[8](t+8,s.f[8](e+8)),a.M[15](t+20,s.f[15](e+20)),a.M[17](t+24,s.f[17](e+24)),a.M[15](t+32,s.f[15](e+32)),a.M[15](t+36,s.f[15](e+36)),a.M[15](t+40,s.f[15](e+40)),a.M[15](t+44,s.f[15](e+44)),a.M[15](t+48,s.f[15](e+48)),a.M[15](t+52,s.f[15](e+52)),a.M[15](t+60,s.f[15](e+60)),a.M[15](t+56,s.f[15](e+56)),a.M[15](t+64,s.f[15](e+64)),a.M[15](t+68,s.f[15](e+68)),a.M[15](t+72,s.f[15](e+72)),a.M[15](t+76,s.f[15](e+76)),a.M[15](t+80,s.f[15](e+80)),a.M[15](t+84,s.f[15](e+84)),a.M[15](t+88,s.f[15](e+88)),(0,r.Mr)(t+136,e+136,24),a.M[10](t+96,s.f[10](e+96)),a.M[15](t+104,s.f[15](e+104)),a.M[15](t+108,s.f[15](e+108)),a.M[15](t+112,s.f[15](e+112)),a.M[15](t+116,s.f[15](e+116)),a.M[15](t+120,s.f[15](e+120)),a.M[15](t+124,s.f[15](e+124)),a.M[15](t+128,s.f[15](e+128)),(0,r.Mr)(t+160,e+160,8),s.f[20](e+12)&&(s.f[20](t+12)&&(0,n.Eb)(s.f[20](t+12)),a.M[20](t+12,(0,n.sY)(s.f[15](e+16))),a.M[15](t+16,s.f[15](e+16)),(0,r.Mr)(s.f[20](t+12),s.f[20](e+12),s.f[15](e+16))),s.f[20](e+168)&&function(t,e,i,o){if(!i)return;const h=(0,n.Gy)(12*o);for(let t=0;t{"use strict";function r(t){let e=0,i=0;for(;i<32&&0===t.readU1();)i++;return e=t.readU(i),e+=(1<s,xb:()=>r})},7837:(t,e,i)=>{"use strict";i.d(e,{Eb:()=>d,Gy:()=>u,aI:()=>l,cz:()=>f,sY:()=>c});var r=i(4059),s=i(3939),a=i(932),n=i(4686),o=i(4624),h="src/avutil/util/mem.ts";function c(t){const e=r.s_.malloc(t);return e||o.h2("can not alloc buffer",h,32),e}function u(t){const e=r.s_.malloc(t);return e||o.h2("can not alloc buffer",h,40),(0,n.sO)(e,0,t),e}function d(t){r.s_.free(t)}function l(t){r.s_.free(s.f[20](t)),a.M[20](t,0)}function f(t,e){return r.s_.realloc(t,e)}},264:(t,e,i)=>{"use strict";function r(t){return t.length>4&&0===t[0]&&0===t[1]&&(1===t[2]||0===t[2]&&1===t[3])}function s(t,e){let i=0;for(let r=e;r=2)return{offset:r-Math.min(i,3),startCode:Math.min(i+1,4)};i=0;break;default:i=0}return{offset:-1,startCode:0}}function a(t){const e=[];let i=s(t,0),r={offset:-1,startCode:0};for(;r=s(t,i.offset+i.startCode),r.offset>-1;)e.push(t.subarray(i.offset+i.startCode,r.offset,!0)),i=r;return e.push(t.subarray(i.offset+i.startCode,void 0,!0)),e}function n(t,e=0,i){i||(i=t.length);const r=new Uint8Array(t.length);let s=0,a=0;for(let n=0;n=e&&nn,Bs:()=>r,py:()=>a})},4328:(t,e,i)=>{"use strict";i.d(e,{Vt:()=>n,k:()=>s,lb:()=>a});var r=i(3939);function s(t,e,i){return t*BigInt(e.num>>>0)*BigInt(i.den>>>0)/(BigInt(e.den>>>0)*BigInt(i.num>>>0))}function a(t){return t.num/t.den}function n(t){return r.f[15](t)/r.f[15](t+4)}},6429:(t,e,i)=>{"use strict";i.d(e,{Gx:()=>d,YN:()=>u,ZI:()=>o,_7:()=>n,dP:()=>c,pw:()=>h});var r,s=i(5797),a=i(576);const n=!!s.A.thread&&!0!==a.TK.CHEAP_DISABLE_PTHREAD;let o=16,h=1048576;const c=1024,u=null!==(r=a.TK.CHEAP_HEAP_INITIAL)&&void 0!==r?r:265,d=32768},3939:(t,e,i)=>{"use strict";i.d(e,{$:()=>a,f:()=>s});var r=i(5335);const s={4:function(t){throw new Error("unimplemented")},5:function(t){throw new Error("unimplemented")},2:function(t){throw new Error("unimplemented")},3:function(t){throw new Error("unimplemented")},6:function(t){throw new Error("unimplemented")},7:function(t){throw new Error("unimplemented")},8:function(t){throw new Error("unimplemented")},9:function(t){throw new Error("unimplemented")},10:function(t){throw new Error("unimplemented")},11:function(t){throw new Error("unimplemented")},12:function(t){throw new Error("unimplemented")},13:function(t){throw new Error("unimplemented")},14:function(t){throw new Error("unimplemented")},15:function(t){throw new Error("unimplemented")},16:function(t){throw new Error("unimplemented")},17:function(t){throw new Error("unimplemented")},18:function(t){throw new Error("unimplemented")},19:function(t){throw new Error("unimplemented")},20:function(t){throw new Error("unimplemented")},0:function(t){throw new Error("invalid operate")},1:function(t){throw new Error("invalid operate")},22:function(t){throw new Error("invalid operate")},21:function(t){throw new Error("invalid operate")}};function a(t){r.X$(s,t)}},932:(t,e,i)=>{"use strict";i.d(e,{$:()=>a,M:()=>s});var r=i(5335);const s={4:function(t,e){throw new Error("unimplemented")},5:function(t,e){throw new Error("unimplemented")},2:function(t,e){throw new Error("unimplemented")},3:function(t,e){throw new Error("unimplemented")},6:function(t,e){throw new Error("unimplemented")},7:function(t,e){throw new Error("unimplemented")},8:function(t,e){throw new Error("unimplemented")},9:function(t,e){throw new Error("unimplemented")},10:function(t,e){throw new Error("unimplemented")},11:function(t,e){throw new Error("unimplemented")},12:function(t,e){throw new Error("unimplemented")},13:function(t,e){throw new Error("unimplemented")},14:function(t,e){throw new Error("unimplemented")},15:function(t,e){throw new Error("unimplemented")},16:function(t,e){throw new Error("unimplemented")},17:function(t,e){throw new Error("unimplemented")},18:function(t,e){throw new Error("unimplemented")},19:function(t,e){throw new Error("unimplemented")},20:function(t,e){throw new Error("unimplemented")},0:function(t,e){throw new Error("invalid operate")},1:function(t,e){throw new Error("invalid operate")},22:function(t,e){throw new Error("invalid operate")},21:function(t,e){throw new Error("invalid operate")}};function a(t){r.X$(s,t)}},5323:(t,e,i)=>{"use strict";i.d(e,{X:()=>M,l:()=>S});var r=i(6681),s=i.n(r),a=i(1919),n=i.n(a),o=i(5019),h=i.n(o),c=i(9921),u=i(3939),d=i(932),l=i(1499),f=i(6704),p=i(7672),m=i(5335),g=i(2100),v=i(2739);function A(t,e,i,r){s()(t,e,{get:i,set:r,configurable:!0,enumerable:!0})}function y(t){return function(){return u.f[20](t())}}function w(t,e,i,r){return function(){return t[`__$__${e}`]||(t[`__$__${e}`]=S(i(),r))}}function b(t,e){return function(){return u.f[e](t())}}function k(t,e,i,r){const s=8*f.i[e]-r-i,a=Math.pow(2,i)-1;return function(){return u.f[e](t())>>>s&a}}function x(t){return function(e){d.M[8](t(),e)}}function _(t,e,i,r){const s=`__$__${e}`;return function(e){const a=t[s]||(t[s]=S(i(),r));m.__(e,((t,e)=>{a[e]=t})),t[s]=a}}function P(t,e){return function(i){d.M[e](t(),i)}}function T(t,e,i,r){let s=0,a=8*f.i[e];for(let t=0;tt()+s*a),i),_(r,e,(()=>t()+s*a),i))}return r}(i,r,s);n[l.o9]=i(),v.__(e,((t,e)=>{n[e]=t})),t[a]=n}}function B(t,e,i,r,s){const a=`__$__${e}`;return function(e){let n=t[a]||function(t,e,i){const r={};let s=(0,c.A)(i);for(let a=0;at()+s*a),i),P((()=>t()+s*a),i));return r}(i,r,s);n[l.o9]=i(),v.__(e,((t,e)=>{n[e]=t})),t[a]=n}}function S(t,e){let i=p.Pc(e)?e.prototype:e;const r={};for(r[l.o9]=t,n()(r,i);;){let t=i[l.JY];if(t&&t.forEach(((t,e)=>{t[3]?t[1]?A(r,e,I((()=>r[l.o9]+t[7]),r,e),B(r,e,(()=>r[l.o9]+t[7]),t[4],20)):p.Pc(t[0])||p.Ik(t[0])?A(r,e,I((()=>r[l.o9]+t[7]),r,e),C(r,e,(()=>r[l.o9]+t[7]),t[4],t[0])):A(r,e,I((()=>r[l.o9]+t[7]),r,e),B(r,e,(()=>r[l.o9]+t[7]),t[4],t[0])):t[1]?A(r,e,y((()=>r[l.o9]+t[7])),x((()=>r[l.o9]+t[7]))):p.Pc(t[0])||p.Ik(t[0])?A(r,e,w(r,e,(()=>r[l.o9]+t[7]),t[0]),_(r,e,(()=>r[l.o9]+t[7]),t[0])):t[5]?A(r,e,k((()=>r[l.o9]+t[7]),t[0],t[6],t[8]),T((()=>r[l.o9]+t[7]),t[0],t[6],t[8])):A(r,e,b((()=>r[l.o9]+t[7]),t[0]),P((()=>r[l.o9]+t[7]),t[0]))})),i=h()(i),!i)break}return r}function M(t){let e=h()(t);for(;;){let i=e[l.JY];if(i&&i.forEach(((e,i)=>{delete t[i]})),e=h()(e),!e)break}}},2085:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var r=i(6681),s=i.n(r);function a(t,e,i){s()(t,e,{value:i,writable:!1,enumerable:!1,configurable:!1})}},4059:(t,e,i)=>{"use strict";i.d(e,{s_:()=>me,ce:()=>ge,GE:()=>de,wE:()=>le,XI:()=>pe,pv:()=>De,hZ:()=>Me,eq:()=>Se,KZ:()=>Re,Tg:()=>Le});var r,s,a=i(9638),n=i(1026),o=i(5335),h=i(2739),c=i(3783),u=i(576);let d=1;function l(t,e=1){let i=d;for(;i%e;)i+=1;return d=i+t,i}const f=null!==(r=u.TK.CHeap)&&void 0!==r&&r.threadCounter?u.TK.CHeap.threadCounter:l(4,4),p=null!==(s=u.TK.CHeap)&&void 0!==s&&s.heapMutex?u.TK.CHeap.heapMutex:l(4,4);var m=i(4624),g="src/cheap/allocator/AllocatorJS.ts";const v=2,A=S(16),y=32,w=1+2*y,b=1,k=0,x=2,_=1,P=b+w+2;class T{constructor(t,e=!0){var i,r,s,a;(0,n.A)(this,"buffer",void 0),(0,n.A)(this,"byteOffset",void 0),(0,n.A)(this,"heapOffset",void 0),(0,n.A)(this,"heapLength",void 0),(0,n.A)(this,"int32Array",void 0),(0,n.A)(this,"updates",void 0),(0,n.A)(this,"options",void 0),(0,n.A)(this,"shared",void 0),(0,n.A)(this,"handles",void 0),this.options=o.X$({growSize:1048576,maxHeapSize:2097152e3},t),this.handles=[],this.buffer=t.buffer,this.shared=!1,this.options.memory||this.buffer instanceof ArrayBuffer||this.buffer instanceof SharedArrayBuffer?(this.byteOffset=null!==(i=t.byteOffset)&&void 0!==i?i:0,this.heapOffset=R(this.byteOffset+B(y),null!==(r=t.byteLength)&&void 0!==r?r:this.buffer.byteLength),this.heapLength=U((null!==(s=t.byteLength)&&void 0!==s?s:this.buffer.byteLength)-this.heapOffset),this.int32Array=new Int32Array(this.buffer,this.heapOffset,S(this.heapLength)),this.updates=new Int32Array(this.buffer,this.byteOffset,y),"function"==typeof SharedArrayBuffer&&this.buffer instanceof SharedArrayBuffer&&(this.shared=!0)):m.h2("Expected buffer to be an instance of Buffer or ArrayBuffer",g,109),e&&(this.updates.fill(b),function(t){return t[b-1]===w&&t[b+w]===w}(a=this.int32Array)||function(t){const e=b,i=w,r=P,s=t.length-(e+i+2+_);L(t,i,e),t[e+k]=1,t[e+x]=r;for(let i=1;i=t.length-P?m.h2(`Got invalid sized chunk at ${B(e)} (${B(i)} bytes).`,g,563):O(t,e)?I(t,e,i):C(t,e,i),e+=i+2}}(this.int32Array))}addUpdateHandle(t){h.zy(this.handles,t)||this.handles.push(t)}removeUpdateHandle(t){h.TF(this.handles,t)}malloc_(t){(t=M(t,7))<16&&(t=16);const e=S(t),i=this.findFreeBlock(this.int32Array,e);if(i<=b)return 0;const r=D(this.int32Array,i);return r-(e+2)>=A?function(t,e,i,r,s){const a=e+i+2,n=r-(a-e);z(t,e,r,s),t[e-1]=-i,t[e+i]=-i,t[a-1]=-n,t[a+n]=-n,$(t,a,n,s)}(this.int32Array,i,e,r,this.updates):z(this.int32Array,i,r,this.updates),B(i)+this.heapOffset}malloc(t){this.shared&&((0,c.s2)(p,!0),this.checkBuffer());const e=this.malloc_(t);return this.shared&&(0,c.Tl)(p),e}calloc_(t,e){let i=t*e;i=i<16?16:M(i,7);const r=this.malloc_(i);if(0===r)return 0;const s=S(r);return this.int32Array.subarray(s,s+i>>2).fill(0),r}calloc(t,e){this.shared&&((0,c.s2)(p,!0),this.checkBuffer());const i=this.calloc_(t,e);return this.shared&&(0,c.Tl)(p),i}realloc_(t,e){if(0===t)return this.malloc_(e);const i=t;if(0===e)return this.free_(i),0;let r=S(t-=this.heapOffset),s=r,a=0;V(this.int32Array,r)&&(s=this.int32Array[r-1],a=r-s);const n=D(this.int32Array,s)-a;if(n>=S(M(e,7)))return i;{const t=this.malloc_(e);return 0===t?(this.free_(i),0):(this.int32Array.set(this.int32Array.subarray(r,r+n),S(t-this.heapOffset)),this.free_(i),t)}}realloc(t,e){return this.shared&&((0,c.s2)(p,!0),this.checkBuffer()),t=this.realloc_(t,e),this.shared&&(0,c.Tl)(p),t}alignedAlloc_(t,e){if(t<=8)return this.malloc_(e);const i=this.malloc_(e+t-1+4);if(0===i)return 0;const r=i+t-1+4&~(t-1);return this.int32Array[S(r-this.heapOffset)-_]=S(i-this.heapOffset),r}alignedAlloc(t,e){this.shared&&((0,c.s2)(p,!0),this.checkBuffer());const i=this.alignedAlloc_(t,e);return this.shared&&(0,c.Tl)(p),i}free_(t){if(0===t)return;let e=S(t-=this.heapOffset);if(V(this.int32Array,e)&&(e=this.int32Array[e-_]),O(this.int32Array,e))return;const i=D(this.int32Array,e),r=N(this.int32Array,e),s=function(t,e){const i=D(t,e);if(e+i+2>=t.length-2)return 0;const r=e+i+2;return t[r-_]<2?0:r}(this.int32Array,e);0!==r?0!==s?function(t,e,i,r,s,a){const n=D(t,e),o=D(t,s),h=s-e+o;z(t,e,n,a),z(t,s,o,a),t[e-_]=-h,t[s+o]=-h,$(t,e,h,a)}(this.int32Array,r,0,0,s,this.updates):W(this.int32Array,r,e,i,this.updates):0!==s?function(t,e,i,r,s){const a=D(t,e);z(t,e,a,s);const n=r+a+2;t[i-_]=-n,t[e+a]=-n,$(t,i,n,s)}(this.int32Array,s,e,i,this.updates):$(this.int32Array,e,i,this.updates)}free(t){this.shared&&((0,c.s2)(p,!0),this.checkBuffer()),this.free_(t),this.shared&&(0,c.Tl)(p)}sizeof(t){if(0===t)return 0;let e=S(t-=this.heapOffset);return V(this.int32Array,e)&&(e=this.int32Array[e-_]),B(D(this.int32Array,e))}inspect(){return this.checkBuffer(),function(t,e){const i=[],r=E(t,b,e);let s=P,a=0;for(;s=t.length)&&m.h2(`Got invalid sized chunk at ${B(s)} (${B(r)})`,g,619),O(t,s)?i.push(E(t,s,e)):(a+=B(r),i.push({type:"used",block:s,offset:B(s)+e,size:B(r)})),s+=r+2}return{header:r,blocks:i,total:B(t.length),used:a}}(this.int32Array,this.heapOffset)}findFreeBlock(t,e){let i=function(t,e){let i=b;for(let r=t[b+k];r>0;r--){let s=t[i+x+(r-1)];for(;s!==b&&t[s-_]{t(this.buffer)})),this.findFreeBlock(this.int32Array,e)}return i}return i}getBuffer(){return this.buffer}isAlloc(t){this.shared&&((0,c.s2)(p,!0),this.checkBuffer());const e=S(t-this.heapOffset);let i=this.int32Array[b+x];for(;i&&i!==b;){if(e>=i&&ey)&&m.h2(`Block ${B(e)} height must be between 1 and ${y}, got ${r}.`,g,584);for(let i=0;i=P&&!O(t,r)&&m.h2(`Block ${B(e)} has a pointer to a non-free block (${B(r)}).`,g,590)}return!0}function C(t,e,i){if(t[e-1]===t[e+i])return!0;m.h2(`Block length header does not match footer (${B(t[e-1])} vs ${B(t[e+i])}).`,g,599)}function B(t){return t<>>v}function M(t,e){return t+e&~e}function R(t,e){const i=e-t;return t+(M(i,7)===i?0:i-M(i,7)+8)}function U(t){return(b+w)%2||(t-=4),t}function E(t,e,i){const r=t[e+k],s=[];for(let i=0;i>31;return i+r^r}function L(t,e,i){t[i-1]=e,t[i+e]=e}function F(t,e,i){const r=t[b+k];let s=b;for(let a=r;a>0;a--){let r=s+x+(a-1);for(;t[r]>=P&&t[t[r]-1]=0;i--)t[s+x+i]===e&&(r[i]=s);s=t[s+x]}let a=t[b+k];for(let i=0;i0&&t[b+x+(a-1)]===b;)a--,t[b+k]=a;t[e-1]=-i,t[e+i]=-i}function O(t,e){return!(es){const i=s+1;return t[b+k]=i,t[b+x+(i-1)]=b,r[i]=b,t[e+k]=i,i}return t[e+k]=a,a}(t,e,i,r);for(let i=1;i<=s;i++){const s=r[i-1]+x+(i-1);t[e+x+(i-1)]=t[s],t[s]=e,r[i-1]=b}return t[e-1]=i,t[e+i]=i,i}function W(t,e,i,r,s){const a=i-e+r;return z(t,e,i-e-2,s),t[e-_]=-a,t[i+r]=-a,$(t,e,a,s),r}class G{constructor(){(0,n.A)(this,"table",void 0),(0,n.A)(this,"pointer",void 0),(0,n.A)(this,"nodes",void 0),this.table=new WebAssembly.Table({initial:10,element:"anyfunc"}),this.pointer=1,this.nodes=[{pointer:1,length:9,free:!0}]}getPointer(){return this.pointer}alloc(t){let e=this.findFree(t);if(e<0){const i=this.nodes[this.nodes.length-1],r=t-(i.free?i.length:0);this.table.grow(r),i.free?i.length=i.length+r:this.nodes.push({pointer:i.pointer+i.length,length:r,free:!0}),e=this.findFree(t)}const i=this.nodes[e];return i.length>t&&(this.nodes.splice(e+1,0,{pointer:i.pointer+t,length:i.length-t,free:!0}),i.length=t),i.free=!1,i.pointer}free(t){let e=this.findNode(t);const i=this.nodes[e];if(i&&!i.free){const t=this.nodes[e-1],r=this.nodes[e+1];t&&t.free?r&&r.free?(t.length+=i.length+r.length,this.nodes.splice(e,2)):(t.length+=i.length,this.nodes.splice(e,1)):r&&r.free?(i.length+=r.length,this.nodes.splice(e+1,1),i.free=!0):i.free=!0}}get(t){return this.table.get(t)}set(t,e){if(t<0||t>=this.pointer)throw new RangeError("index out of bound");this.table.set(t,e)}inspect(){return this.nodes}findFree(t){let e=-1;for(let i=0;i=t&&this.nodes[i].free){e=i;break}return e}findNode(t){let e=-1;for(let i=0;i>>r,e);{const s=at(i),a=t>>>r,n=s[a];return s[a]+=e,n}}function ht(t,e,i,r){if(nt)return Atomics.sub(at(i),t>>>r,e);{const s=at(i),a=t>>>r,n=s[a];return s[a]-=e,n}}function ct(t,e,i,r){if(nt)return Atomics.and(at(i),t>>>r,e);{const s=at(i),a=t>>>r,n=s[a];return s[a]&=e,n}}function ut(t,e,i,r){if(nt)return Atomics.or(at(i),t>>>r,e);{const s=at(i),a=t>>>r,n=s[a];return s[a]|=e,n}}function dt(t,e,i,r){if(nt)return Atomics.xor(at(i),t>>>r,e);{const s=at(i),a=t>>>r,n=s[a];return s[a]^=e,n}}function lt(t,e,i,r){if(nt)return Atomics.store(at(i),t>>>r,e);{const s=at(i),a=t>>>r,n=s[a];return s[a]=e,n}}function ft(t,e,i){return nt?Atomics.load(at(e),t>>>i):at(e)[t>>>i]}function pt(t,e,i,r,s){if(nt)return Atomics.compareExchange(at(r),t>>>s,e,i);{const a=at(r),n=t>>>s,o=a[n];return o===e&&(a[n]=i),o}}function mt(t,e,i,r){if(nt)return Atomics.exchange(at(i),t>>>r,e);{const s=at(i),a=t>>>r,n=s[a];return s[a]=e,n}}function gt(t,e){return nt?Atomics.notify(at(16),t>>>2,e):void 0}const vt={ok:0,"not-equal":1,"timed-out":2};function At(t,e){return vt[Atomics.wait(at(16),t>>>2,e)]}function yt(t,e,i){return vt[Atomics.wait(at(16),t>>>2,e,i)]}async function wt(t,e){if(Atomics.waitAsync){const i=Atomics.waitAsync(at(16),t>>>2,e);return i.async?vt[await i.value]:vt[i.value]}if(ft(t)!==e)return 1;for(;ft(t)===e;)await new(H())((t=>{it((()=>{t()}))}));return 0}async function bt(t,e,i){if(Atomics.waitAsync){const r=Atomics.waitAsync(at(16),t>>>2,e,i);return r.async?vt[await r.value]:vt[r.value]}if(ft(t)!==e)return 1;{const r=(0,Q.A)();for(;ft(t)===e&&(0,Q.A)()-r{it((()=>{t()}))}));return ft(t)!==e?0:2}}function kt(t){at=t,(0,rt.$Z)({add:ot,sub:ht,and:ct,or:ut,xor:dt,store:lt,load:ft,compareExchange:pt,exchange:mt,notify:gt,wait:At,waitTimeout:yt,waitAsync:wt,waitTimeoutAsync:bt})}var xt=i(4919),_t=i(3939),Pt=i(932),Tt=i(8096),It=i(3945),Ct=i.n(It),Bt="src/cheap/asm/memory.ts";let St;async function Mt(t){try{let e=(0,xt.E_)(Ct());Tt.DD(e,"function"==typeof SharedArrayBuffer&&t.buffer instanceof SharedArrayBuffer),St=(await WebAssembly.instantiate(e,{env:{memory:t}})).instance,(0,_t.$)({4:St.exports.readU8,5:St.exports.readU8,2:St.exports.readU8,3:St.exports.readU8,6:St.exports.readU16,7:St.exports.readU16,8:t=>St.exports.read32(t)>>>0,9:t=>St.exports.read32(t)>>>0,10:t=>BigInt.asUintN(64,St.exports.read64(t)),22:t=>BigInt.asUintN(64,St.exports.read64(t)),11:St.exports.read8,12:St.exports.read8,13:St.exports.read16,14:St.exports.read16,15:St.exports.read32,16:St.exports.read32,17:St.exports.read64,21:St.exports.read64,18:St.exports.readf32,19:St.exports.readf64,20:t=>St.exports.read32(t)>>>0}),(0,Pt.$)({4:St.exports.write8,5:St.exports.write8,2:St.exports.write8,3:St.exports.write8,6:St.exports.write16,7:St.exports.write16,8:St.exports.write32,9:St.exports.write32,10:St.exports.write64,22:St.exports.write64,11:St.exports.write8,12:St.exports.write8,13:St.exports.write16,14:St.exports.write16,15:St.exports.write32,16:St.exports.write32,17:St.exports.write64,21:St.exports.write64,18:St.exports.writef32,19:St.exports.writef64,20:St.exports.write32})}catch(t){m.R8("memory asm not support, cannot use asm memory function",Bt,96)}}var Rt=i(2854),Ut=i(4677);let Et,Dt,Lt;const Ft=function(){if((0,Ut.A)(Et))return Et;const t=new ArrayBuffer(2);return new DataView(t).setInt16(0,256,!0),Et=256===new Int16Array(t)[0],Et}();function zt(t,e){Lt().setUint8(t,e)}function Ot(t){return Lt().getUint8(t)}function Vt(t,e){Lt().setUint16(t,e,Ft)}function Nt(t){return Lt().getUint16(t,Ft)}function $t(t,e){Lt().setUint32(t,e,Ft)}function Wt(t){return Lt().getUint32(t,Ft)}function Gt(t,e){Lt().setBigUint64(t,e,Ft)}function qt(t){return Lt().getBigUint64(t,Ft)}function jt(t,e){Lt().setInt8(t,e)}function Ht(t){return Lt().getInt8(t)}function Qt(t,e){Lt().setInt16(t,e,Ft)}function Yt(t){return Lt().getInt16(t,Ft)}function Kt(t,e){Lt().setInt32(t,e,Ft)}function Jt(t){return Lt().getInt32(t,Ft)}function Xt(t,e){Lt().setBigInt64(t,e,Ft)}function Zt(t){return Lt().getBigInt64(t,Ft)}function te(t,e){Lt().setFloat32(t,e,Ft)}function ee(t){return Lt().getFloat32(t,Ft)}function ie(t,e){Lt().setFloat64(t,e,Ft)}function re(t){return Lt().getFloat64(t,Ft)}function se(t){return Lt().getUint32(t,Ft)}function ae(t,e){return Lt().setUint32(t,e,Ft)}function ne(t,e){Dt=t,Lt=e,(0,_t.$)({4:Ot,5:Ot,2:Ot,3:Ot,6:Nt,7:Nt,8:Wt,9:Wt,10:qt,11:Ht,12:Ht,13:Yt,14:Yt,15:Jt,16:Jt,17:Zt,18:ee,19:re,20:se}),(0,Pt.$)({4:zt,5:zt,2:zt,3:zt,6:Vt,7:Vt,8:$t,9:$t,10:Gt,11:jt,12:jt,13:Qt,14:Qt,15:Kt,16:Kt,17:Xt,18:te,19:ie,20:ae})}var oe=i(4568);let he=-1,ce=!0,ue="",de=null,le=null,fe=0,pe=null,me=null,ge=null,ve=null,Ae=null,ye=null,we=null,be=null,ke=null,xe=null,_e=null,Pe=null,Te=null,Ie=null,Ce={5:be,3:be,7:ke,9:xe,22:_e,12:ve,14:Ae,16:ye,21:we};function Be(){return!(!ge||ge.buffer===be.buffer)}function Se(){return Be()&&Ee(ge.buffer),be}function Me(){return Be()&&Ee(ge.buffer),ke}function Re(){return Be()&&Ee(ge.buffer),Ie}function Ue(t){return Be()&&Ee(ge.buffer),Ce[t]}function Ee(t){ve=new Int8Array(t),Ae=new Int16Array(t),ye=new Int32Array(t),we=new BigInt64Array(t),be=new Uint8Array(t),ke=new Uint16Array(t),xe=new Uint32Array(t),_e=new BigUint64Array(t),Pe=new Float32Array(t),Te=new Float64Array(t),Ie=new DataView(t),Ce={5:be,3:be,7:ke,9:xe,22:_e,12:ve,14:Ae,16:ye,21:we}}function De(){return Atomics.add(xe,f>>>2,1)}async function Le(t){var e;ne((()=>me),Re),kt(Ue),ge=t.memory;var i;i=new T({buffer:ge.buffer,memory:ge,byteOffset:q.dP,growAllowed:!0,onResize:(t,e)=>(ge.grow(e-t.byteLength>>>16),{buffer:ge.buffer,byteOffset:q.dP})},!1),me&&me.removeUpdateHandle(Ee),me=i,u.TK.CHeap&&(u.TK.CHeap.Allocator=me),me.addUpdateHandle(Ee),Ee(me.getBuffer()),t.stackPointer&&(fe=t.stackSize,le=t.stackPointer,de=new WebAssembly.Global({value:"i32",mutable:!0},le+fe),pe=new G),he="number"==typeof t.id?t.id:Atomics.add(xe,f>>>2,1),ue=null!==(e=t.name)&&void 0!==e?e:"anonymous",u.TK.CHeap={initThread:Le,Allocator:me,Table:pe,ThreadId:he,ThreadName:ue,Memory:ge,StackSize:fe,StackTop:le,StackPointer:de,isMainThread:!1},ce=!1,t.disableAsm||("function"==typeof BigInt&&BigInt!==Number&&(st.A.chrome&&st.A.checkVersion(st.A.majorVersion,"85",!0)||st.A.firefox&&st.A.checkVersion(st.A.majorVersion,"78",!0)||st.A.safari&&st.A.checkVersion(st.A.majorVersion,"15",!0)||st.A.newEdge)&&await Mt(ge),q._7&&(st.A.chrome&&st.A.checkVersion(st.A.majorVersion,"85",!0)||st.A.firefox&&st.A.checkVersion(st.A.majorVersion,"78",!0)||st.A.safari&&st.A.checkVersion(st.A.majorVersion,"15",!0)||st.A.newEdge)&&await(0,Rt.Ay)(ge))}(0,a.A)()||(0,oe.A)()?(u.TK.CHeap={initThread:Le,isMainThread:!1},ce=!1):function(){var t,e,i,r,s,a,n,o;ne((()=>me),Re),kt(Ue),ge=null!==(t=u.TK.CHeap)&&void 0!==t&&t.Memory?u.TK.CHeap.Memory:new WebAssembly.Memory({initial:q.YN,maximum:q.Gx,shared:q._7}),me=null!==(e=u.TK.CHeap)&&void 0!==e&&e.Allocator?u.TK.CHeap.Allocator:new T({buffer:ge.buffer,memory:ge,byteOffset:q.dP,growAllowed:!0,onResize:(t,e)=>(ge.grow(e-t.byteLength>>>16),{buffer:ge.buffer,byteOffset:q.dP})}),me.addUpdateHandle(Ee),Ee(me.getBuffer()),fe=null!==(i=u.TK.CHeap)&&void 0!==i&&i.StackSize?u.TK.CHeap.StackSize:q.pw,le=null!==(r=u.TK.CHeap)&&void 0!==r&&r.StackTop?u.TK.CHeap.StackTop:me.malloc(fe),de=null!==(s=u.TK.CHeap)&&void 0!==s&&s.StackPointer?u.TK.CHeap.StackPointer:new WebAssembly.Global({value:"i32",mutable:!0},le+fe),pe=null!==(a=u.TK.CHeap)&&void 0!==a&&a.Table?u.TK.CHeap.Table:new G,he=null!==(n=u.TK.CHeap)&&void 0!==n&&n.ThreadId?u.TK.CHeap.ThreadId:0,ue=null!==(o=u.TK.CHeap)&&void 0!==o&&o.ThreadName?u.TK.CHeap.ThreadName:"main",u.TK.CHeap||(q._7?(Atomics.store(xe,f>>>2,he+1),Atomics.store(ye,p>>>2,0)):(xe[f>>>2]=he+1,ye[p>>>2]=0)),"function"==typeof BigInt&&BigInt!==Number&&(st.A.chrome&&st.A.checkVersion(st.A.majorVersion,"85",!0)||st.A.firefox&&st.A.checkVersion(st.A.majorVersion,"78",!0)||st.A.safari&&st.A.checkVersion(st.A.majorVersion,"15",!0)||st.A.newEdge)&&Mt(ge),q._7&&(st.A.chrome&&st.A.checkVersion(st.A.majorVersion,"85",!0)||st.A.firefox&&st.A.checkVersion(st.A.majorVersion,"78",!0)||st.A.safari&&st.A.checkVersion(st.A.majorVersion,"15",!0)||st.A.newEdge)&&(0,Rt.Ay)(ge),u.TK.CHeap||(u.TK.CHeap={Allocator:me,Table:pe,ThreadId:he,ThreadName:ue,Memory:ge,StackSize:fe,StackTop:le,StackPointer:de,isMainThread:!0,threadCounter:f,heapMutex:p}),ce=!0}()},98:(t,e,i)=>{"use strict";i.d(e,{I_:()=>A,SQ:()=>y});var r=i(5019),s=i.n(r),a=i(1919),n=i.n(a),o=i(9921),h=i(3939),c=i(932),u=i(1499),d=i(6704),l=i(7672),f=i(5335),p=i(2739),m=i(2148);const g=s()({});function v(t,e){for(;;){let i=t[u.JY];if(i){const t=i.get(e);if(t)return t}if(!(t=s()(t))||t===g)return null}}function A(t,e){const i=l.Pc(e)?e.prototype:e,r={};r[u.o9]=t,n()(r,i);const{proxy:s,revoke:a}=Proxy.revocable(r,{get(t,e,r){if(l.Yj(e)){const r=v(i,e.replace(/^\$+/,""));if(r){const i=t[u.o9]+r[7];if(r[3]){const r=t[e];return r[u.o9]=i,r}if(r[1])return h.f[20](i);if(l.Pc(r[0])||l.Ik(r[0]))return t[e]||(t[e]=A(i,r[0]));{let t=h.f[r[0]](i);return r[5]&&(t=t>>>8*d.i[r[0]]-r[8]-r[6]&Math.pow(2,r[6])-1),t}}return t[e]}return t[e]},set(t,e,r,s){if(l.Yj(e)){const s=v(i,e.replace(/^\$+/,""));if(s){const i=t[u.o9]+s[7];if(s[3]){const a=t[e]||function(t,e,i,r){const s={};s[u.o9]=t;let a=(0,o.A)(r?20:i);return new Proxy(s,{get(t,e,s){if(e===u.o9)return t[u.o9];const n=(0,m.A)(e);return r?h.f[20](t[u.o9]+n*a):l.Pc(i)?t[e]:h.f[i](t[u.o9]+n*a)},set(t,e,s,n){if(e===u.o9)return t[u.o9]=s,!0;const o=(0,m.A)(e);if(r)c.M[20](t[u.o9]+o*a,s),t[e]=s;else if(l.Pc(i)){const r=t[e]||(t[e]=A(t[u.o9]+o*a,i));f.__(s,((t,e)=>{r[e]=t})),t[e]=r}else c.M[i](t[u.o9]+o*a,s),t[e]=s;return!0}})}(i,s[4],s[0],s[1]);p.__(r,((t,e)=>{a[e]=t})),t[e]=a}else if(s[1])c.M[20](i,r),t[e]=r;else if(l.Pc(s[0])||l.Ik(s[0])){const a=t[e]||(t[e]=A(i,s[0]));f.__(r,((t,e)=>{a[e]=t})),t[e]=a}else{if(s[5]){let t=0,e=8*d.i[s[0]];for(let i=0;i{"use strict";i.d(e,{t:()=>a,z:()=>s});var r=i(4059);function s(t){return r.GE.value-=t,r.GE.value}function a(t){r.GE.value+=t}},4211:(t,e,i)=>{"use strict";i.d(e,{A:()=>u});var r=i(1026),s=i(3939),a=i(932),n=i(4059),o=i(7672);class h{constructor(){(0,r.A)(this,"proxy",void 0),this.proxy=new Proxy(this,{get:(t,e,i)=>o.sH(e)?t.getIndexValue(+e):t[e],set:(t,e,i,r)=>(o.sH(e)?t.setIndexValue(+e,i):t[e]=i,!0)})}}class c{constructor(t,e){(0,r.A)(this,"pointer",void 0),(0,r.A)(this,"len",void 0),this.pointer=t,this.len=e}get byteLength(){return this.len}get buffer(){return(0,n.eq)().buffer}get byteOffset(){return this.pointer}getFloat32(t,e){return(0,n.KZ)().getFloat32(this.pointer+t,e)}getFloat64(t,e){return(0,n.KZ)().getFloat64(this.pointer+t,e)}getInt8(t){return(0,n.KZ)().getInt8(this.pointer+t)}getInt16(t,e){return(0,n.KZ)().getInt16(this.pointer+t,e)}getInt32(t,e){return(0,n.KZ)().getInt32(this.pointer+t,e)}getUint8(t){return(0,n.KZ)().getUint8(this.pointer+t)}getUint16(t,e){return(0,n.KZ)().getUint16(this.pointer+t,e)}getUint32(t,e){return(0,n.KZ)().getUint32(this.pointer+t,e)}setFloat32(t,e,i){(0,n.KZ)().setFloat32(this.pointer+t,e,i)}setFloat64(t,e,i){(0,n.KZ)().setFloat64(this.pointer+t,e,i)}setInt8(t,e){(0,n.KZ)().setInt8(this.pointer+t,e)}setInt16(t,e,i){(0,n.KZ)().setInt16(this.pointer+t,e,i)}setInt32(t,e,i){(0,n.KZ)().setInt32(this.pointer+t,e,i)}setUint8(t,e){(0,n.KZ)().setUint8(this.pointer+t,e)}setUint16(t,e,i){(0,n.KZ)().setUint16(this.pointer+t,e,i)}setUint32(t,e,i){(0,n.KZ)().setUint32(this.pointer+t,e,i)}getBigInt64(t,e){return(0,n.KZ)().getBigInt64(this.pointer+t,e)}getBigUint64(t,e){return(0,n.KZ)().getBigUint64(this.pointer+t,e)}setBigInt64(t,e,i){(0,n.KZ)().setBigInt64(this.pointer+t,e,i)}setBigUint64(t,e,i){(0,n.KZ)().setBigUint64(this.pointer+t,e,i)}}class u extends h{constructor(t,e){return super(),(0,r.A)(this,"pointer",void 0),(0,r.A)(this,"len",void 0),this.pointer=t,this.len=e,this.proxy}getIndexValue(t){return s.f[2](this.pointer+t)}setIndexValue(t,e){a.M[2](this.pointer+t,e)}set(t,e=0){(0,n.eq)().set(t,this.pointer+e)}subarray(t=0,e,i){return i?new u(this.pointer+t,(e||this.len)-t):(0,n.eq)().subarray(this.pointer+t,this.pointer+(null!=e?e:this.len))}slice(t=0,e){return(0,n.eq)().slice(this.pointer+t,this.pointer+(null!=e?e:this.len))}get length(){return this.len}get byteLength(){return this.len}get buffer(){return(0,n.eq)().buffer}get byteOffset(){return this.pointer}get view(){return new c(this.pointer,this.len)}}},2264:(t,e,i)=>{"use strict";i.d(e,{A:()=>A});var r,s,a=i(1026),n=i(662),o=i.n(n),h=i(1499),c=i(2085),u=i(4059),d=i(3939),l=i(932),f=i(9921),p=i(4686),m=i(7672),g=i(915);class v{constructor(){(0,a.A)(this,"prev",void 0),(0,a.A)(this,"next",void 0),(0,a.A)(this,"data",void 0)}}r=v.prototype,(s=new(o())).set("prev",{0:v,1:1,2:1,3:0,4:0,5:0,6:0,7:0,8:0}),s.set("next",{0:v,1:1,2:1,3:0,4:0,5:0,6:0,7:4,8:0}),s.set("data",{0:1,1:1,2:1,3:0,4:0,5:0,6:0,7:8,8:0}),(0,c.A)(r,h.Og,!0),(0,c.A)(r,h.dc,4),(0,c.A)(r,h.g7,12),(0,c.A)(r,h.JY,s);class A{constructor(){(0,a.A)(this,"length",0),(0,a.A)(this,"head",0),(0,a.A)(this,"tail",0)}createNode(t,e,i=!1){const r=u.s_.malloc(12);if(l.M[20](r+4,0),l.M[20](r,0),m.ai(e))if(20===e)l.M[20](r+8,t);else{const i=u.s_.malloc((0,f.A)(e));l.M[e](i,t),l.M[20](r+8,i)}else if(i)l.M[20](r+8,t);else{const i=u.s_.malloc((0,f.A)(e));(0,p.Mr)(i,t[h.o9],(0,f.A)(e)),l.M[20](r+8,i)}return r}getItem(t,e){let i;return i=m.ai(e)?20===e?t:d.f[e](t):(0,g.A)(t,e),i}push(t,e,i=!1){const r=this.createNode(t,e,i);this.tail?(l.M[20](this.tail+4,r),l.M[20](r,this.tail),this.tail=r):(this.head=r,this.tail=r),this.length++}pop(t){const e=this.tail;let i=this.getItem(d.f[20](e+8),t);return this.length>1?(l.M[20](d.f[20](e)+4,0),this.tail=d.f[20](e)):(this.head=0,this.tail=0),this.length--,u.s_.free(d.f[20](e+8)),u.s_.free(e),i}shift(t){const e=this.head;let i=this.getItem(d.f[20](e+8),t);return this.length>1?(l.M[20](d.f[20](e+4),0),this.head=d.f[20](e+4)):(this.head=0,this.tail=0),this.length--,u.s_.free(d.f[20](e+8)),u.s_.free(e),i}unshift(t,e,i=!1){const r=this.createNode(t,e,i);this.head?(l.M[20](this.head,r),l.M[20](r+4,this.head),this.head=r):(this.head=r,this.tail=r),this.length++}forEach(t,e){if(!this.length)return;let i=this.head,r=0;for(;0!==i&&!1!==t(this.getItem(d.f[20](i+8),e),r);)i=d.f[20](i+4),r++}find(t,e){if(!this.length)return 0;let i=this.head,r=0;for(;0!==i;){const s=this.getItem(d.f[20](i+8),e);if(!0===t(s,r))return s;i=d.f[20](i+4),r++}return 0}indexOf(t,e){if(!this.length)return 0;let i=this.head,r=0;for(;0!==i;){if(r===t)return this.getItem(d.f[20](i+8),e);i=d.f[20](i+4),r++}return 0}clear(t,e){if(this.length){let i=this.head;for(;0!==i;){t&&t(this.getItem(d.f[20](i+8),e)),u.s_.free(d.f[20](i+8));const r=d.f[20](i+4);u.s_.free(i),i=r}}this.head=0,this.tail=0,this.length=0}}!function(t){var e=new(o());e.set("length",{0:8,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),e.set("head",{0:v,1:1,2:1,3:0,4:0,5:0,6:0,7:4,8:0}),e.set("tail",{0:v,1:1,2:1,3:0,4:0,5:0,6:0,7:8,8:0}),(0,c.A)(t,h.Og,!0),(0,c.A)(t,h.dc,4),(0,c.A)(t,h.g7,12),(0,c.A)(t,h.JY,e)}(A.prototype)},4503:(t,e,i)=>{"use strict";i.d(e,{A:()=>c});var r=i(9921),s=i(4059),a=i(4686),n=i(5335),o=i(4677),h=i(915);function c(t,e){const i=(0,r.A)(t),c=s.s_.malloc(i);if(!c)throw new TypeError("cannot alloc memory for struct");(0,a.sO)(c,0,i);const u=(0,h.A)(c,t),d=new t;return e&&n.X$(d,e),n.__(d,((t,e)=>{(0,o.A)(t)&&(u[e]=t)})),u}},4686:(t,e,i)=>{"use strict";i.d(e,{JW:()=>c,Mr:()=>n,bg:()=>d,lW:()=>o,s3:()=>u,sO:()=>h});var r=i(4059),s=i(4211),a=i(6429);function n(t,e,i){(0,r.eq)().set((0,r.eq)().subarray(e,e+i),t)}function o(t,e,i){(0,r.eq)().set(i.subarray(0,e),t)}function h(t,e,i){(0,r.eq)().subarray(t,t+i).fill(e)}function c(t,e){return a._7?u(t,e):new s.A(t,e)}function u(t,e){return(0,r.eq)().subarray(t,t+e)}function d(t,e){return(0,r.hZ)().subarray(t>>>1,t+2*e)}},9921:(t,e,i)=>{"use strict";i.d(e,{A:()=>n});var r=i(1499),s=i(7672),a=i(6704);function n(t){return s.ai(t)?a.i[t]||0:s.Pc(t)&&t.prototype[r.Og]?t.prototype[r.g7]:0}},915:(t,e,i)=>{"use strict";i.d(e,{A:()=>u});var r=i(1499),s=i(98),a=i(5323),n=i(5797),o=i(7672),h=i(576);const c={};function u(t,e){return arguments[2]&&o.Yj(arguments[2])&&(e=e.prototype,function(t,e){const i=c.hasOwnProperty(t)?c[t]:c[t]=t.split(h.ZG);for(let t=0,r=i.length-1;t<=r&&e(i[t])!==h.W8;t++);}(arguments[2],(t=>{const i=e[r.JY];e=i.get(t)[0]}))),n.A.proxy?(0,s.I_)(t,e):(0,a.l)(t,e)}},4300:(t,e,i)=>{"use strict";i.d(e,{A:()=>h});var r=i(4059),s=i(1499),a=i(98),n=i(5323),o=i(5797);function h(t){const e=t[s.o9];e&&(r.s_.free(e),t[s.o9]=0,o.A.proxy?(0,a.SQ)(t):(0,n.X)(t))}},1499:(t,e,i)=>{"use strict";i.d(e,{JY:()=>c,Og:()=>a,dc:()=>o,g7:()=>n,kE:()=>u,o9:()=>h});var r=i(5062),s=i.n(r);const a=s()("Struct"),n=s()("StructLength"),o=s()("StructMaxBaseTypeByteLength"),h=s()("StructAddress"),c=(s()("StructKeysQueue"),s()("StructKeysMeta")),u=(s()("StructKeysInstance"),s()("StructProxyRevoke"))},2854:(t,e,i)=>{"use strict";i.d(e,{Ay:()=>l,KJ:()=>u,Ko:()=>d});var r=i(4919),s=i(4624),a=i(8096),n=i(9583),o=i.n(n),h=i(46),c="src/cheap/thread/asm/atomics.ts";let u;function d(){return!!u}async function l(t){try{if(!("function"==typeof SharedArrayBuffer&&t.buffer instanceof SharedArrayBuffer))return;{const e=(0,r.E_)(o());a.DD(e,!0),u=(await WebAssembly.instantiate(e,{env:{memory:t}})).instance}(0,h.$Z)({add:function(t,e,i){switch(i){case 5:case 3:return 255&u.exports.add8(t,e);case 12:return u.exports.add8(t,e);case 14:return u.exports.add16(t,e);case 7:return 65535&u.exports.add16(t,e);case 16:return u.exports.add32(t,e);case 9:return 4294967295&u.exports.add32(t,e);case 21:return u.exports.add64(t,e);case 22:return BigInt.asUintN(64,u.exports.add64(t,e))}},sub:function(t,e,i){switch(i){case 5:case 3:return 255&u.exports.sub8(t,e);case 12:return u.exports.sub8(t,e);case 14:return u.exports.sub16(t,e);case 7:return 65535&u.exports.sub16(t,e);case 16:return u.exports.sub32(t,e);case 9:return 4294967295&u.exports.sub32(t,e);case 21:return u.exports.sub64(t,e);case 22:return BigInt.asUintN(64,u.exports.sub64(t,e))}},and:function(t,e,i){switch(i){case 5:case 3:return 255&u.exports.and8(t,e);case 12:return u.exports.and8(t,e);case 14:return u.exports.and16(t,e);case 7:return 65535&u.exports.and16(t,e);case 16:return u.exports.and32(t,e);case 9:return 4294967295&u.exports.and32(t,e);case 21:return u.exports.and64(t,e);case 22:return BigInt.asUintN(64,u.exports.and64(t,e))}},or:function(t,e,i){switch(i){case 5:case 3:return 255&u.exports.or8(t,e);case 12:return u.exports.or8(t,e);case 14:return u.exports.or16(t,e);case 7:return 65535&u.exports.or16(t,e);case 16:case 9:return u.exports.or32(t,e);case 21:return u.exports.or64(t,e);case 22:return BigInt.asUintN(64,u.exports.or64(t,e))}},xor:function(t,e,i){switch(i){case 5:case 3:return 255&u.exports.xor8(t,e);case 12:return u.exports.xor8(t,e);case 14:return u.exports.xor16(t,e);case 7:return 65535&u.exports.xor16(t,e);case 16:case 9:return u.exports.xor32(t,e);case 21:return u.exports.xor64(t,e);case 22:return BigInt.asUintN(64,u.exports.xor64(t,e))}},store:function(t,e,i){switch(i){case 5:case 12:case 3:return u.exports.store8(t,e);case 14:case 7:return u.exports.store16(t,e);case 16:case 9:return u.exports.store32(t,e);case 21:case 22:return u.exports.store64(t,e)}},load:function(t,e){switch(e){case 5:case 3:return 255&u.exports.load8(t);case 12:return u.exports.load8(t);case 14:case 7:return u.exports.load16(t);case 16:return u.exports.load32(t);case 9:return 4294967295&u.exports.load32(t);case 21:return u.exports.load64(t);case 22:return BigInt.asUintN(64,u.exports.load64(t))}},compareExchange:function(t,e,i,r){switch(r){case 5:case 3:return 255&u.exports.compare_exchange8(t,e,i);case 12:return u.exports.compare_exchange8(t,e,i);case 14:return u.exports.compare_exchange16(t,e,i);case 7:return 65535&u.exports.compare_exchange16(t,e,i);case 16:return u.exports.compare_exchange32(t,e,i);case 9:return 4294967295&u.exports.compare_exchange32(t,e,i);case 21:return u.exports.compare_exchange64(t,e,i);case 22:return BigInt.asUintN(64,u.exports.compare_exchange64(t,e,i))}},exchange:function(t,e,i){switch(i){case 5:case 3:return 255&u.exports.exchange8(t,e);case 12:return u.exports.exchange8(t,e);case 14:return u.exports.exchange16(t,e);case 7:return 65535&u.exports.exchange16(t,e);case 16:return u.exports.exchange32(t,e);case 9:return 4294967295&u.exports.exchange32(t,e);case 21:return u.exports.exchange64(t,e);case 22:return BigInt.asUintN(64,u.exports.exchange64(t,e))}},notify:function(t,e){return u.exports.notify(t,e)},wait:function(t,e){return u.exports.wait(t,e)},waitTimeout:function(t,e,i){return u.exports.waitTimeout(t,e,BigInt(i>>>0))}})}catch(t){s.R8("atomics asm not support, cannot use asm atomics function",c,284)}}},46:(t,e,i)=>{"use strict";let r,s,a,n,o,h,c,u,d,l,f,p,m,g;function v(t){t.add&&(r=t.add),t.sub&&(s=t.sub),t.and&&(a=t.and),t.or&&(n=t.or),t.xor&&(o=t.xor),t.store&&(h=t.store),t.load&&(c=t.load),t.compareExchange&&(u=t.compareExchange),t.exchange&&(d=t.exchange),t.notify&&(l=t.notify),t.wait&&(f=t.wait),t.waitTimeout&&(p=t.waitTimeout),t.waitAsync&&(m=t.waitAsync),t.waitTimeoutAsync&&(g=t.waitTimeoutAsync)}i.d(e,{$Z:()=>v,Hh:()=>c,I8:()=>o,M_:()=>h,Uo:()=>a,WQ:()=>r,cv:()=>d,j4:()=>p,jb:()=>s,me:()=>l,or:()=>n,p_:()=>u,uk:()=>f})},1574:(t,e,i)=>{"use strict";i.r(e),i.d(e,{default:()=>o});var r=i(4149),s=i(576),a=i(7672);let n=s.TK;function o(t){let e,i;n.onmessage=o=>{const h=o.data,c=h.type,u=h.data;switch(c){case"init":if(s.TK.CHeap&&s.TK.CHeap.initThread)return void s.TK.CHeap.initThread(u).then((()=>{n.postMessage({type:"ready"})}));n.postMessage({type:"ready"});break;case"run":n.postMessage({type:"running"}),i=t(u.params),d=u.port,e=new r.Ay(d),e.on(r.S3,(async t=>{const r=t.method,s=t.params;if(a.Pc(i[r]))try{const a=[],n=await i[r](...s.params,a);e.reply(t,n,null,a)}catch(i){e.reply(t,-2097152,{message:i.message})}}));break;case"stop":e&&e.destroy(),n.postMessage({type:"stopped"})}var d}}},6848:(t,e,i)=>{"use strict";i.r(e),i.d(e,{default:()=>a});var r=i(576);let s=r.TK;function a(t){let e;s.onmessage=i=>{const a=i.data,n=a.type,o=a.data;switch(n){case"init":if(r.TK.CHeap&&r.TK.CHeap.initThread)return void r.TK.CHeap.initThread(o).then((()=>{s.postMessage({type:"ready"})}));s.postMessage({type:"ready"});break;case"run":e=t(o.params);break;case"stop":e&&e.then?e.then((t=>{s.postMessage({type:"stopped",data:t})})):s.postMessage({type:"stopped",data:e});break;default:console.log("default")}}}},7524:(t,e,i)=>{"use strict";i.r(e),i.d(e,{default:()=>o});var r=i(4149),s=i(576),a=i(7672);let n=s.TK;function o(t){let e;n.onmessage=i=>{const o=i.data,h=o.type,c=o.data;switch(h){case"init":if(s.TK.CHeap&&s.TK.CHeap.initThread)return void s.TK.CHeap.initThread(c).then((()=>{n.postMessage({type:"ready"})}));n.postMessage({type:"ready"});break;case"run":n.postMessage({type:"running"}),u=c.port,e=new r.Ay(u),e.on(r.S3,(async i=>{const r=i.method,s=i.params;if(a.Pc(t[r]))try{const a=[],n=await t[r](...s.params,a);e.reply(i,n,null,a)}catch(t){e.reply(i,-2097152,{message:t.message})}}));break;case"stop":e&&e.destroy(),n.postMessage({type:"stopped"})}var u}}},3783:(t,e,i)=>{"use strict";i.d(e,{Tl:()=>m,Ts:()=>f,eu:()=>l,s2:()=>p,zr:()=>g});var r,s,a=i(1026),n=i(662),o=i.n(n),h=i(1499),c=i(2085),u=i(46),d=i(9638);class l{constructor(){(0,a.A)(this,"atomic",void 0)}}function f(t){return u.M_(t,0,16,2),0}function p(t,e=!1){let i;if(0!==(i=u.p_(t,0,1,16,2)))do{2!=i&&0===u.p_(t,1,2,16,2)||!e&&(0,d.A)()&&u.uk(t,2)}while(0!==(i=u.p_(t,0,2,16,2)));return 0}function m(t){return 1!==u.jb(t,1,16,2)&&(u.M_(t,0,16,2),u.me(t,1)),0}function g(t){return u.M_(t,0,16,2),0}r=l.prototype,(s=new(o())).set("atomic",{0:16,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),(0,c.A)(r,h.Og,!0),(0,c.A)(r,h.dc,4),(0,c.A)(r,h.g7,4),(0,c.A)(r,h.JY,s)},6704:(t,e,i)=>{"use strict";i.d(e,{_:()=>s,i:()=>r});const r={2:1,3:1,4:1,5:1,6:2,7:2,8:4,9:4,10:8,11:1,12:1,13:2,14:2,15:4,16:4,17:8,18:4,19:8,20:4,0:4,1:4,22:8,21:8},s={2:0,3:0,4:0,5:0,6:1,7:1,8:2,9:2,10:4,11:0,12:0,13:1,14:1,15:2,16:2,17:4,18:2,19:4,20:2,1:2,0:2,22:4,21:4}},1063:(t,e,i)=>{"use strict";i.d(e,{A:()=>ce});var r={};i.r(r),i.d(r,{atomic_add_i16:()=>N,atomic_add_i32:()=>K,atomic_add_i64:()=>at,atomic_add_i8:()=>R,atomic_and_i16:()=>W,atomic_and_i32:()=>X,atomic_and_i64:()=>ot,atomic_and_i8:()=>E,atomic_compare_exchange_i16:()=>Q,atomic_compare_exchange_i32:()=>rt,atomic_compare_exchange_i64:()=>lt,atomic_compare_exchange_i8:()=>O,atomic_exchange_i16:()=>Y,atomic_exchange_i32:()=>st,atomic_exchange_i64:()=>ft,atomic_exchange_i8:()=>V,atomic_load_i16:()=>H,atomic_load_i32:()=>it,atomic_load_i64:()=>dt,atomic_load_i8:()=>z,atomic_or_i16:()=>G,atomic_or_i32:()=>Z,atomic_or_i64:()=>ht,atomic_or_i8:()=>D,atomic_store_i16:()=>j,atomic_store_i32:()=>et,atomic_store_i64:()=>ut,atomic_store_i8:()=>F,atomic_sub_i16:()=>$,atomic_sub_i32:()=>J,atomic_sub_i64:()=>nt,atomic_sub_i8:()=>U,atomic_xor_i16:()=>q,atomic_xor_i32:()=>tt,atomic_xor_i64:()=>ct,atomic_xor_i8:()=>L,atomics_notify:()=>pt,atomics_wait:()=>mt,atomics_wait_timeout:()=>gt,override:()=>vt});var s={};i.r(s),i.d(s,{Pthread:()=>_t,PthreadOnce:()=>xt,override:()=>Vt,wasm_cpu_core_count:()=>Ot,wasm_pthread_cond_broadcast:()=>Et,wasm_pthread_cond_destroy:()=>St,wasm_pthread_cond_init:()=>Bt,wasm_pthread_cond_signal:()=>Ut,wasm_pthread_cond_timedwait:()=>Rt,wasm_pthread_cond_wait:()=>Mt,wasm_pthread_equal2:()=>Ft,wasm_pthread_exit:()=>Lt,wasm_pthread_mutex_destroy:()=>Tt,wasm_pthread_mutex_init:()=>Pt,wasm_pthread_mutex_lock:()=>It,wasm_pthread_mutex_unlock:()=>Ct,wasm_pthread_once:()=>Dt,wasm_pthread_support:()=>zt});var a={};i.r(a),i.d(a,{Timespec:()=>Nt,wasm_sem_destroy:()=>Wt,wasm_sem_init:()=>$t,wasm_sem_post:()=>Ht,wasm_sem_timedwait:()=>jt,wasm_sem_trywait:()=>qt,wasm_sem_wait:()=>Gt});var n=i(1026),o=i(662),h=i.n(o),c=i(4001),u=i.n(c),d=i(1499),l=i(2085),f=i(4059),p=i(932),m=i(3939),g=i(5335),v=i(2739),A=i(4624),y=i(7672),w=i(4686),b=i(11);const k=[null,[],[]];function x(t,e){const i=k[t];0===e||10===e?(console.log.bind(console)(b.D(i)),i.length=0):i.push(e)}function _(t,e){let i=0;return 0==t?i=2:1!=t&&2!=t||(i=64),p.M[11](e,2),p.M[13](e+2,1),p.M[15](e+8,0|i),p.M[15](e+12,0),p.M[17](e+16,BigInt(0)),0}function P(t,e,i,r){let s=0;for(let r=0;r>>0),0}function T(t){throw t=`abort(${t+=""}). Build with -s ASSERTIONS=1 for more info.`,new WebAssembly.RuntimeError(t)}function I(t,e,i){if(0!==t)return 28;const r=(new Date).getTime();return p.M[10](i,BigInt(r)*BigInt(1e6)),0}function C(t,e){return 0!==t?28:(p.M[10](e,BigInt(1e6)),0)}function B(t,e){const i=(0,w.s3)(t,e);return crypto.getRandomValues(i),0}var S=i(46),M=i(6704);let R=function(t,e){return S.WQ(t,e,12,M._[12])},U=function(t,e){return S.jb(t,e,12,M._[12])},E=function(t,e){return S.Uo(t,e,12,M._[12])},D=function(t,e){return S.or(t,e,12,M._[12])},L=function(t,e){return S.I8(t,e,12,M._[12])},F=function(t,e){return S.M_(t,e,12,M._[12])},z=function(t){return S.Hh(t,12,M._[12])},O=function(t,e,i){return S.p_(t,e,i,12,M._[12])},V=function(t,e){return S.cv(t,e,12,M._[12])},N=function(t,e){return S.WQ(t,e,14,M._[14])},$=function(t,e){return S.jb(t,e,14,M._[14])},W=function(t,e){return S.Uo(t,e,14,M._[14])},G=function(t,e){return S.or(t,e,14,M._[14])},q=function(t,e){return S.I8(t,e,14,M._[14])},j=function(t,e){return S.M_(t,e,14,M._[14])},H=function(t){return S.Hh(t,14,M._[14])},Q=function(t,e,i){return S.p_(t,e,i,14,M._[14])},Y=function(t,e){return S.cv(t,e,14,M._[14])},K=function(t,e){return S.WQ(t,e,16,M._[16])},J=function(t,e){return S.jb(t,e,16,M._[16])},X=function(t,e){return S.Uo(t,e,16,M._[16])},Z=function(t,e){return S.or(t,e,16,M._[16])},tt=function(t,e){return S.I8(t,e,16,M._[16])},et=function(t,e){return S.M_(t,e,16,M._[16])},it=function(t){return S.Hh(t,16,M._[16])},rt=function(t,e,i){return S.p_(t,e,i,16,M._[16])},st=function(t,e){return S.cv(t,e,16,M._[16])},at=function(t,e){return S.WQ(t,e,21,M._[21])},nt=function(t,e){return S.jb(t,e,21,M._[21])},ot=function(t,e){return S.Uo(t,e,21,M._[21])},ht=function(t,e){return S.or(t,e,21,M._[21])},ct=function(t,e){return S.I8(t,e,21,M._[21])},ut=function(t,e){return S.M_(t,e,21,M._[21])},dt=function(t){return S.Hh(t,21,M._[21])},lt=function(t,e,i){return S.p_(t,e,i,21,M._[21])},ft=function(t,e){return S.cv(t,e,21,M._[21])},pt=function(t,e){return S.me(t,e)},mt=function(t,e){return S.uk(t,e)},gt=function(t,e,i){return S.j4(t,e,0|Number(0xffffffffn&i))};function vt(t){t.atomic_add_i8&&(R=t.atomic_add_i8),t.atomic_sub_i8&&(U=t.atomic_sub_i8),t.atomic_and_i8&&(E=t.atomic_and_i8),t.atomic_or_i8&&(D=t.atomic_or_i8),t.atomic_xor_i8&&(L=t.atomic_xor_i8),t.atomic_store_i8&&(F=t.atomic_store_i8),t.atomic_load_i8&&(z=t.atomic_load_i8),t.atomic_compare_exchange_i8&&(O=t.atomic_compare_exchange_i8),t.atomic_exchange_i8&&(V=t.atomic_exchange_i8),t.atomic_add_i16&&(N=t.atomic_add_i16),t.atomic_sub_i16&&($=t.atomic_sub_i16),t.atomic_and_i16&&(W=t.atomic_and_i16),t.atomic_or_i16&&(G=t.atomic_or_i16),t.atomic_xor_i16&&(q=t.atomic_xor_i16),t.atomic_store_i16&&(j=t.atomic_store_i16),t.atomic_load_i16&&(H=t.atomic_load_i16),t.atomic_compare_exchange_i16&&(Q=t.atomic_compare_exchange_i16),t.atomic_exchange_i16&&(Y=t.atomic_exchange_i16),t.atomic_add_i32&&(K=t.atomic_add_i32),t.atomic_sub_i32&&(J=t.atomic_sub_i32),t.atomic_and_i32&&(X=t.atomic_and_i32),t.atomic_or_i32&&(Z=t.atomic_or_i32),t.atomic_xor_i32&&(tt=t.atomic_xor_i32),t.atomic_store_i32&&(et=t.atomic_store_i32),t.atomic_load_i32&&(it=t.atomic_load_i32),t.atomic_compare_exchange_i32&&(rt=t.atomic_compare_exchange_i32),t.atomic_exchange_i32&&(st=t.atomic_exchange_i32),t.atomic_add_i64&&(at=t.atomic_add_i64),t.atomic_sub_i64&&(nt=t.atomic_sub_i64),t.atomic_and_i64&&(ot=t.atomic_and_i64),t.atomic_or_i64&&(ht=t.atomic_or_i64),t.atomic_xor_i64&&(ct=t.atomic_xor_i64),t.atomic_store_i64&&(ut=t.atomic_store_i64),t.atomic_load_i64&&(dt=t.atomic_load_i64),t.atomic_compare_exchange_i64&&(lt=t.atomic_compare_exchange_i64),t.atomic_exchange_i64&&(ft=t.atomic_exchange_i64),t.atomics_notify&&(pt=t.atomics_notify),t.atomics_wait&&(mt=t.atomics_wait),t.atomics_wait_timeout&&(gt=t.atomics_wait_timeout)}var At,yt,wt=i(3783);At=class{constructor(){(0,n.A)(this,"atomic",void 0)}}.prototype,(yt=new(h())).set("atomic",{0:16,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),(0,l.A)(At,d.Og,!0),(0,l.A)(At,d.dc,4),(0,l.A)(At,d.g7,4),(0,l.A)(At,d.JY,yt);var bt=i(6429),kt=i(576);class xt{constructor(){(0,n.A)(this,"atomic",void 0)}}!function(t){var e=new(h());e.set("atomic",{0:16,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),(0,l.A)(t,d.Og,!0),(0,l.A)(t,d.dc,4),(0,l.A)(t,d.g7,4),(0,l.A)(t,d.JY,e)}(xt.prototype);class _t{constructor(){(0,n.A)(this,"id",void 0),(0,n.A)(this,"retval",void 0),(0,n.A)(this,"flags",void 0),(0,n.A)(this,"status",void 0)}}let Pt,Tt,It,Ct,Bt,St,Mt,Rt,Ut,Et,Dt;function Lt(t){const e=kt.TK.__SELF_THREAD__;p.M[20](e+4,t)}function Ft(t,e){return m.f[15](t)===m.f[15](e)?1:0}function zt(){return bt._7?1:0}function Ot(){return navigator.hardwareConcurrency}function Vt(t){t.wasm_pthread_mutex_lock&&(It=t.wasm_pthread_mutex_lock),t.wasm_pthread_mutex_unlock&&(Ct=t.wasm_pthread_mutex_unlock),t.wasm_pthread_cond_wait&&(Mt=t.wasm_pthread_cond_wait),t.wasm_pthread_cond_timedwait&&(Rt=t.wasm_pthread_cond_timedwait),t.wasm_pthread_cond_signal&&(Ut=t.wasm_pthread_cond_signal),t.wasm_pthread_cond_broadcast&&(Et=t.wasm_pthread_cond_broadcast)}!function(t){var e=new(h());e.set("id",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),e.set("retval",{0:1,1:1,2:1,3:0,4:0,5:0,6:0,7:4,8:0}),e.set("flags",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:8,8:0}),e.set("status",{0:16,1:0,2:0,3:0,4:0,5:0,6:0,7:12,8:0}),(0,l.A)(t,d.Og,!0),(0,l.A)(t,d.dc,4),(0,l.A)(t,d.g7,16),(0,l.A)(t,d.JY,e)}(_t.prototype),Pt=function(t,e){return wt.Ts(t)},Tt=function(t){return wt.zr(t)},It=function(t){return wt.s2(t)},Ct=function(t){return wt.Tl(t)},Bt=function(t,e){return function(t,e){return S.M_(t,0,16,2),0}(t)},St=function(t){return function(t){return S.M_(t,0,16,2),0}(t)},Mt=function(t,e){return function(t,e){let i=S.Hh(t,16,2);return wt.Tl(e),S.uk(t,i),wt.s2(e),0}(t,e)},Rt=function(t,e,i){return function(t,e,i){let r=S.Hh(t,16,2);wt.Tl(e);let s=S.j4(t,r,i);return wt.s2(e),2===s?110:0}(t,e,1e3*Number(m.f[17](i))+m.f[15](i+8)/1e6)},Ut=function(t){return function(t){return S.WQ(t,1,16,2),S.me(t,1),0}(t)},Et=function(t){return function(t){return S.WQ(t,1,16,2),S.me(t,1073741824),0}(t)},Dt=function(t,e){return 0===S.WQ(t,1,16,2)&&f.XI.get(e)(),0},function(t){var e=new(h());e.set("atomic",{0:16,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),e.set("mutex",{0:wt.eu,1:0,2:0,3:0,4:0,5:0,6:0,7:4,8:0}),(0,l.A)(t,d.Og,!0),(0,l.A)(t,d.dc,4),(0,l.A)(t,d.g7,8),(0,l.A)(t,d.JY,e)}(class{constructor(){(0,n.A)(this,"atomic",void 0),(0,n.A)(this,"mutex",void 0)}}.prototype);class Nt{constructor(){(0,n.A)(this,"tvSec",void 0),(0,n.A)(this,"tvNSec",void 0)}}function $t(t,e,i){return function(t,e){return S.M_(t,0|e,16,2),wt.Ts(t+4),0}(t,i)}function Wt(t){return function(t){return wt.zr(t+4),0}(t)}function Gt(t){return function(t){for(;S.uk(t,0),S.jb(t,1,16,2)<=0;)S.WQ(t,1,16,2);return 0}(t)}function qt(t){return function(t){return wt.s2(t+4),m.f[16](t)>0?(p.M[16](t,m.f[16](t)-1),wt.Tl(t+4),0):(wt.Tl(t+4),11)}(t)}function jt(t,e){return function(t,e){return 2!==S.j4(t,0,e)&&S.jb(t,1,16,2)<=0?(S.WQ(t,1,16,2),110):0}(t,1e3*Number(m.f[17](e))+m.f[15](e+8)/1e6)}function Ht(t){return function(t){return S.WQ(t,1,16,2),S.me(t,1),0}(t)}!function(t){var e=new(h());e.set("tvSec",{0:17,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),e.set("tvNSec",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:8,8:0}),(0,l.A)(t,d.Og,!0),(0,l.A)(t,d.dc,8),(0,l.A)(t,d.g7,16),(0,l.A)(t,d.JY,e)}(Nt.prototype);var Qt=i(1837),Yt=i(2854),Kt=i(4919),Jt=i(5454),Xt=i.n(Jt),Zt=i(8096);let te,ee=!0;function ie(){return ee}async function re(t,e){try{if(!("function"==typeof SharedArrayBuffer&&t.buffer instanceof SharedArrayBuffer))return void(ee=!1);{const e=(0,Kt.E_)(Xt());Zt.DD(e,!0),te=(await WebAssembly.instantiate(e,{env:{memory:t}})).instance}e({wasm_pthread_mutex_lock:te.exports.lock,wasm_pthread_mutex_unlock:te.exports.unlock,wasm_pthread_cond_wait:te.exports.wait,wasm_pthread_cond_timedwait:te.exports.timedwait,wasm_pthread_cond_signal:te.exports.signal,wasm_pthread_cond_broadcast:te.exports.broadcast})}catch(t){ee=!1,A.R8("thread asm not support, cannot use asm thread function","src/cheap/webassembly/runtime/asm/thread.ts",65)}}var se=i(9638),ae="src/cheap/webassembly/WebAssemblyRunner.ts";i(1999);const ne=(0,Qt.A)(1999,{varName:"init"});function oe(){}let he=!1;!function(t){var e=new(h());e.set("flags",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),(0,l.A)(t,d.Og,!0),(0,l.A)(t,d.dc,4),(0,l.A)(t,d.g7,4),(0,l.A)(t,d.JY,e)}(class{constructor(){(0,n.A)(this,"flags",void 0)}}.prototype);class ce{static getTable(){return f.XI}constructor(t,e={}){var i;if((0,n.A)(this,"resource",void 0),(0,n.A)(this,"instance",void 0),(0,n.A)(this,"options",void 0),(0,n.A)(this,"builtinMalloc",void 0),(0,n.A)(this,"memoryBase",void 0),(0,n.A)(this,"tableBase",void 0),(0,n.A)(this,"childImports",void 0),(0,n.A)(this,"childUrl",void 0),(0,n.A)(this,"childBlob",void 0),(0,n.A)(this,"childThreads",void 0),(0,n.A)(this,"imports",void 0),(0,n.A)(this,"childReadyPromises",void 0),this.resource=t,this.builtinMalloc=[],this.childThreads=new(h()),this.childReadyPromises=[],y.Yj(e.childImports)?this.childImports=e.childImports:y.Ik(e.childImports)&&e.childImports instanceof Blob&&(this.childImports=URL.createObjectURL(e.childImports)),this.memoryBase=t.dataSize?f.s_.malloc(t.dataSize):0,e.thread&&e.tableBase&&f.XI.getPointer()!==e.tableBase&&f.XI.alloc(e.tableBase-f.XI.getPointer()),this.tableBase=t.tableSize?f.XI.alloc(t.tableSize):0,this.options=e,this.imports={env:{memory:f.ce,__stack_pointer:f.GE,__indirect_function_table:f.XI.table,clock_time_get:I,clock_res_get:C,random_get:B,abort:T,proc_exit:function(t){A.z3(`wasm module exit, code: ${t}`,ae,133)},environ_get:oe,environ_sizes_get:oe,fd_close:oe,fd_fdstat_get:_,fd_read:oe,fd_seek:oe,fd_write:P,emscripten_builtin_malloc:t=>{const e=f.s_.malloc(t);return this.builtinMalloc.push(e),e},emscripten_builtin_free:t=>{f.s_.free(t)},emscripten_builtin_memalign:(t,e,i)=>{const r=f.s_.alignedAlloc(e,i);return 0!==r?(p.M[20](t,r),this.builtinMalloc.push(r),0):-1},emscripten_memcpy_big:function(t,e,i){(0,w.Mr)(t,e,i)},__libc_malloc:function(t){return f.s_.malloc(t)},malloc:function(t){return f.s_.malloc(t)},calloc:function(t,e){return f.s_.calloc(t,e)},realloc:function(t,e){return f.s_.realloc(t,e)},aligned_alloc:(t,e)=>f.s_.alignedAlloc(t,e),free:function(t){f.s_.free(t)},posix_memalign:function(t,e,i){const r=f.s_.alignedAlloc(e,i);return 0!==r?(p.M[20](t,r),0):-1}}},g.X$(this.imports.env,{wasm_pthread_create:(t,e,i,r)=>{if(!this.childUrl){const t=`\n ${(0,Qt.A)(1063,{varName:"__WebAssemblyRunner__",exportName:"__WebAssemblyRunner__",pointName:ce.name,exportIsClass:!0})}\n ${ne}\n var preRun;\n ${this.childImports?`\n preRun = import('${this.childImports}')\n `:""}\n init.default(preRun);\n `;this.childBlob=new Blob([t],{type:"text/javascript"}),this.childUrl=URL.createObjectURL(this.childBlob)}const s=new Worker(this.childUrl);p.M[15](t,(0,f.pv)()),p.M[16](t+12,1),p.M[15](t+8,0),p.M[20](t+4,0);const a=f.s_.alignedAlloc(bt.ZI,bt.pw),n=f.s_.malloc(4);let o;return(0,w.sO)(n,0,4),this.childThreads.set(m.f[15](t),{thread:t,worker:s,stackPointer:a,threadDescriptor:n}),this.childReadyPromises.push(new(u())((t=>{o=t}))),s.onmessage=t=>{const e=t.data,i=e.type;e.data,"run"===i&&o()},s.postMessage({type:"run",data:{cheap:{memory:f.ce,stackPointer:a,stackSize:bt.pw,id:m.f[15](t)},runner:{resource:{tableSize:this.resource.tableSize,module:this.resource.threadModule.module,initFuncs:this.resource.threadModule.initFuncs},options:{memoryBase:this.options.memoryBase||this.memoryBase,tableBase:this.tableBase,thread:t,threadDescriptor:n,childImports:this.childImports},func:i,args:r,imports:this.childImports,thread:t}}}),0},wasm_pthread_join2:(t,e)=>{if(1&m.f[15](t+8))return this.childThreads.delete(m.f[15](t)),0;S.uk(t+12,1),0!==e&&p.M[20](e,m.f[20](t+4));const i=this.childThreads.get(m.f[15](t));return f.s_.free(i.stackPointer),f.s_.free(i.threadDescriptor),i.worker.terminate(),this.childThreads.delete(m.f[15](t)),0},wasm_pthread_detach2:t=>{const e=this.childThreads.get(m.f[15](t));p.M[15](e.threadDescriptor,1|m.f[15](e.threadDescriptor)),p.M[15](t+8,1|m.f[15](t+8))}}),g.X$(this.imports.env,r),g.X$(this.imports.env,s),g.X$(this.imports.env,a),this.memoryBase?g.X$(this.imports.env,{__memory_base:this.memoryBase}):e.memoryBase&&g.X$(this.imports.env,{__memory_base:e.memoryBase}),this.tableBase&&g.X$(this.imports.env,{__table_base:this.tableBase}),null!==(i=e.imports)&&void 0!==i&&i.env&&(g.X$(this.imports.env,e.imports.env),e.envKey&&e.importMap)){const t={};g.__(this.imports.env,((i,r)=>{e.importMap[r]&&(t[e.importMap[r]]=i)})),this.imports[e.envKey]=t}this.imports.wasi_snapshot_preview1=this.imports.env}overrideAtomic(){vt({atomic_add_i8:Yt.KJ.exports.add8,atomic_sub_i8:Yt.KJ.exports.sub8,atomic_and_i8:Yt.KJ.exports.and8,atomic_or_i8:Yt.KJ.exports.or8,atomic_xor_i8:Yt.KJ.exports.xor8,atomic_store_i8:Yt.KJ.exports.store8,atomic_load_i8:Yt.KJ.exports.load8,atomic_compare_exchange_i8:Yt.KJ.exports.compare_exchange8,atomic_exchange_i8:Yt.KJ.exports.exchange8,atomic_add_i16:Yt.KJ.exports.add16,atomic_sub_i16:Yt.KJ.exports.sub16,atomic_and_i16:Yt.KJ.exports.and16,atomic_or_i16:Yt.KJ.exports.or16,atomic_xor_i16:Yt.KJ.exports.xor16,atomic_store_i16:Yt.KJ.exports.store16,atomic_load_i16:Yt.KJ.exports.load16,atomic_compare_exchange_i16:Yt.KJ.exports.compare_exchange16,atomic_exchange_i16:Yt.KJ.exports.exchange16,atomic_add_i32:Yt.KJ.exports.add32,atomic_sub_i32:Yt.KJ.exports.sub32,atomic_and_i32:Yt.KJ.exports.and32,atomic_or_i32:Yt.KJ.exports.or32,atomic_xor_i32:Yt.KJ.exports.xor32,atomic_store_i32:Yt.KJ.exports.store32,atomic_load_i32:Yt.KJ.exports.load32,atomic_compare_exchange_i32:Yt.KJ.exports.compare_exchange32,atomic_exchange_i32:Yt.KJ.exports.exchange32,atomic_add_i64:Yt.KJ.exports.add64,atomic_sub_i64:Yt.KJ.exports.sub64,atomic_and_i64:Yt.KJ.exports.and64,atomic_or_i64:Yt.KJ.exports.or64,atomic_xor_i64:Yt.KJ.exports.xor64,atomic_store_i64:Yt.KJ.exports.store64,atomic_load_i64:Yt.KJ.exports.load64,atomic_compare_exchange_i64:Yt.KJ.exports.compare_exchange64,atomic_exchange_i64:Yt.KJ.exports.exchange64,atomics_notify:Yt.KJ.exports.notify,atomics_wait:Yt.KJ.exports.wait}),g.X$(this.imports.env,r)}async run(t){y.Ik(t)&&g.X$(this.options.imports,t),(0,se.A)()&&!te&&ie()&&this.resource.threadModule&&(await re(f.ce,Vt),g.X$(this.imports.env,s)),!he&&Yt.Ko()&&(he=!0,this.overrideAtomic()),this.instance=await WebAssembly.instantiate(this.resource.module,this.imports),this.initRunTime()}async runAsChild(t){y.Ik(t)&&g.X$(this.options.imports,t),!te&&ie()&&(await re(f.ce,Vt),g.X$(this.imports.env,s)),!he&&Yt.Ko()&&(he=!0,this.overrideAtomic()),this.instance=new WebAssembly.Instance(this.resource.module,this.imports),this.initRunTime()}async childrenThreadReady(){if(!this.childReadyPromises.length)return;const t=this.childReadyPromises;this.childReadyPromises=[],await u().all(t)}initRunTime(){this.builtinMalloc=[],y.YO(this.resource.initFuncs)&&v.__(this.resource.initFuncs,(t=>{this.call(t)}))}call(t,...e){if(!this.asm)return-1;let i;if(this.asm[t]?i=this.asm[t]:this.options.exportMap&&this.options.exportMap[t]&&this.asm[this.options.exportMap[t]]&&(i=this.asm[this.options.exportMap[t]]),i)return i.apply(null,e);A.z3(`the wasm module has not function ${t} to call`,ae,489)}get asm(){return this.instance&&this.instance.exports}getInstance(){return this.instance}destroy(){var t;null!==(t=this.builtinMalloc)&&void 0!==t&&t.length&&(v.__(this.builtinMalloc,(t=>{f.s_.free(t)})),this.builtinMalloc.length=0),this.memoryBase&&(f.s_.free(this.memoryBase),this.memoryBase=null),this.tableBase&&(f.XI.free(this.tableBase),this.tableBase=null),this.childImports&&(URL.revokeObjectURL(this.childImports),this.childImports=null),this.childUrl&&(URL.revokeObjectURL(this.childUrl),this.childUrl=null),this.childBlob=null,this.childReadyPromises.length=0,this.childThreads.size&&this.childThreads.forEach(((t,e)=>{1&m.f[15](t.threadDescriptor)||(A.R8("has child thread running, maybe resource leakage",ae,534),t.worker.terminate(),p.M[16](t.thread+12,0),t.stackPointer&&f.s_.free(t.stackPointer),f.s_.free(t.threadDescriptor),this.childThreads.delete(e))})),this.builtinMalloc=null,this.instance=null,this.options.thread&&(this.options.threadDescriptor&&1&m.f[15](this.options.threadDescriptor)?(f.wE&&f.s_.free(f.wE),f.s_.free(this.options.threadDescriptor),self.close()):(p.M[16](this.options.thread+12,0),S.me(this.options.thread+12,1)))}}},1999:(t,e,i)=>{"use strict";i.r(e),i.d(e,{default:()=>a});var r=i(576);r.TK.imports={env:{}};let s=r.TK;function a(t){s.onmessage=e=>{const i=e.data,a=i.type,n=i.data;let o;"run"===a&&(s.postMessage({type:"run"}),r.TK.CHeap&&r.TK.CHeap.initThread&&r.TK.CHeap.initThread(n.cheap).then((()=>{function e(){r.TK.__SELF_THREAD__=n.runner.thread,n.runner.options.imports=r.TK.imports,o=new __WebAssemblyRunner__.__WebAssemblyRunner__(n.runner.resource,n.runner.options),o.runAsChild().then((()=>{__WebAssemblyRunner__.__WebAssemblyRunner__.getTable().get(n.runner.func)(n.runner.args),o.destroy()}))}t?t.then((()=>{e()})):e()})))}}},2758:(t,e,i)=>{"use strict";i.d(e,{A:()=>d});var r=i(1026),s=i(7672),a=i(2739),n=i(576);class o{constructor(t,e){(0,r.A)(this,"type",void 0),(0,r.A)(this,"phase",void 0),(0,r.A)(this,"ns",void 0),(0,r.A)(this,"target",void 0),(0,r.A)(this,"originalEvent",void 0),(0,r.A)(this,"isPrevented",void 0),(0,r.A)(this,"isStopped",void 0),(0,r.A)(this,"listener",void 0),this.type=t,this.phase=o.PHASE_CURRENT,e&&(this.originalEvent=e)}preventDefault(){const t=this;if(!t.isPrevented){const{originalEvent:e}=t;e&&e.preventDefault(),t.isPrevented=n.rT}return t}stopPropagation(){const t=this;if(!t.isStopped){const{originalEvent:e}=t;e&&e.stopPropagation(),t.isStopped=n.rT}return t}prevent(){return this.preventDefault()}stop(){return this.stopPropagation()}}(0,r.A)(o,"PHASE_CURRENT",0),(0,r.A)(o,"PHASE_UPWARD",1),(0,r.A)(o,"PHASE_DOWNWARD",n.Cy);var h=i(5335),c=i(525),u=i(6401);class d{constructor(t){(0,r.A)(this,"ns",void 0),(0,r.A)(this,"listeners",void 0),(0,r.A)(this,"nativeListeners",void 0),this.ns=t||n.W8,this.listeners={}}fire(t,e,i){let r=this,c=s.Yj(t)?r.parse(t):t,d=r.listeners[c.type],l=n.rT;if(d){d=h.C(d);const t=e&&e[0]instanceof o?e[0]:n.ZH;a.__(d,(function(s){if(!p(c.ns,s,n.rT)||!a.zy(d,s)||i&&!i(c,e,s))return;t&&(t.listener=s.fn);let o=(0,u.A)(s.fn,s.ctx,e);return t&&(t.listener=n.ZH),s.num=s.num?s.num+1:1,s.num===s.max&&r.off(c,s.fn),t&&(o===n.W8?t.prevent().stop():t.isStopped&&(o=n.W8)),o===n.W8?l=n.W8:void 0}))}return l}on(t,e){const i=this,r=i.listeners,n=s.Pc(e)?{fn:e}:e;if(s.Ik(n)&&s.Pc(n.fn)){const e=s.Yj(t)?i.parse(t):t;n.ns=e.ns,a.VC(r[e.type]||(r[e.type]=[]),n)}return this}one(t,e){return s.Pc(e)?e={fn:e,max:1}:e.max=1,this.on(t,e)}off(t,e){const i=this,r=i.listeners;if(t){const o=s.Yj(t)?i.parse(t):t,c=o.type,u=o.ns,d=f(e),l=function(t,e){a.__(t,(function(e,i){d(e)&&t.splice(i,1)}),n.rT),t.length||delete r[e]},m=function(t,e){a.__(t,(function(e,i){p(u,e)&&t.splice(i,1)}),n.rT),t.length||delete r[e]};c?r[c]&&l(r[c],c):u&&h.__(r,m)}else i.listeners={}}has(t,e){let i=this.listeners,r=s.Yj(t)?this.parse(t):t,o=r.type,c=r.ns,u=n.rT,d=f(e);var l;return o?i[o]&&(l=i[o],a.__(l,(function(t){if(d(t))return u=n.W8}))):c&&h.__(i,(function(t){return a.__(t,(function(t){if(p(c,t))return u=n.W8})),u})),!u}parse(t){const e={type:t,ns:n.u1};if(this.ns){const i=c.qh(t,n.ZG);i>=0&&(e.type=c.di(t,0,i),e.ns=c.di(t,i+1))}return e}}function l(){return n.rT}function f(t){return s.Pc(t)?function(e){return t===e.fn}:l}function p(t,e,i){const{ns:r}=e;return r&&t?r===t:i?n.rT:n.W8}},2647:(t,e,i)=>{"use strict";function r(t,e){if(!e.length)return null;if(1===e.length)return e[0];let i,r=0;for(i of e)r+=i.length;let s=new t(r),a=0;for(i of e)s.set(i,a),a+=i.length;return s}i.d(e,{A:()=>r})},6401:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var r=i(7672),s=i(576);function a(t,e,i){if(r.Pc(t))return r.YO(i)?t.apply(e,i):e!==s.ZH?t.call(e,i):i!==s.ZH?t(i):t()}},6932:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var r=i(5249),s=i.n(r);function a(){return s()()}},4568:(t,e,i)=>{"use strict";function r(){return"function"==typeof registerProcessor&&"number"==typeof sampleRate&&"number"==typeof currentFrame&&"number"==typeof currentTime}i.d(e,{A:()=>r})},4677:(t,e,i)=>{"use strict";i.d(e,{A:()=>s});var r=i(576);function s(t){return t!==r.ZH}},9638:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var r=i(4677),s=i(4568);function a(){return!("object"==typeof window&&(0,r.A)(window.document)||(0,s.A)())}},1837:(t,e,i)=>{"use strict";i.d(e,{A:()=>f});var r=i(9736),s=i.n(r),a=i(3146),n=i.n(a);const o='\nfunction webpackBootstrapFunc (modules) {\n var installedModules = {};\n function __webpack_require__(moduleId) {\n if(installedModules[moduleId])\n return installedModules[moduleId].exports;\n var module = installedModules[moduleId] = {\n i: moduleId,\n l: false,\n exports: {}\n };\n if (!modules[moduleId]) {\n console.log(\'can not found module:\', moduleId)\n }\n modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n module.l = true;\n return module.exports;\n }\n __webpack_require__.m = modules;\n __webpack_require__.c = installedModules;\n __webpack_require__.i = function(value) { return value; };\n __webpack_require__.d = function(exports, definition, getter) {\n if (typeof definition === \'string\') {\n if(!__webpack_require__.o(exports, definition)) {\n Object.defineProperty(exports, definition, {\n enumerable: true,\n get: getter\n });\n }\n }\n else {\n for(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, {\n enumerable: true,\n get: definition[key]\n });\n }\n }\n }\n };\n __webpack_require__.r = function(exports) {\n if(typeof Symbol !== \'undefined\' && Symbol.toStringTag) {\n \tObject.defineProperty(exports, Symbol.toStringTag, { value: \'Module\' });\n }\n Object.defineProperty(exports, \'__esModule\', { value: true });\n };\n __webpack_require__.f = {};\n __webpack_require__.e = function(chunkId) {\n return Promise.all(Object.keys(__webpack_require__.f).reduce(function (promises, key) {\n __webpack_require__.f[key](chunkId, promises);\n return promises;\n \t}, []));\n\t};\n __webpack_require__.u = function(chunkId) {\n return chunkId + "LIB_NAME";\n };\n __webpack_require__.n = function(module) {\n var getter = module && module.__esModule ?\n function getDefault() { return module[\'default\']; } :\n function getModuleExports() { return module; };\n __webpack_require__.d(getter, \'a\', getter);\n return getter;\n };\n (function() {\n var installedChunks = {\n "main": 0\n };\n __webpack_require__.f.j = function(chunkId, promises) {\n var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;\n if (installedChunkData !== 0) {\n if(installedChunkData) {\n promises.push(installedChunkData[2]);\n } else {\n if (true) {\n var promise = new Promise(function(resolve, reject){installedChunkData = installedChunks[chunkId] = [resolve, reject]});\n promises.push(installedChunkData[2] = promise);\n var url = __webpack_require__.p + __webpack_require__.u(chunkId);\n var error = new Error();\n var loadingEnded = function(event) {\n if(__webpack_require__.o(installedChunks, chunkId)) {\n installedChunkData = installedChunks[chunkId];\n if(installedChunkData !== 0) installedChunks[chunkId] = undefined;\n if(installedChunkData) {\n var errorType = event && (event.type === \'load\' ? \'missing\' : event.type);\n var realSrc = url;\n error.message = "Loading chunk " + chunkId + " failed.\\n(" + errorType + ": " + realSrc + ")";\n error.name = "ChunkLoadError";\n error.type = errorType;\n error.request = realSrc;\n installedChunkData[1](error);\n }\n }\n };\n __webpack_require__.l(url, loadingEnded);\n }\n }\n }\n };\n var webpackJsonpCallback = function(parentChunkLoadingFunction, data) {\n var [chunkIds, moreModules, runtime] = data;\n var moduleId, chunkId, i = 0;\n if (chunkIds.some(function(id){return installedChunks[id] !== 0})) {\n for(moduleId in moreModules) {\n if(__webpack_require__.o(moreModules, moduleId)) {\n __webpack_require__.m[moduleId] = moreModules[moduleId];\n }\n }\n if(runtime) runtime(__webpack_require__);\n }\n if (parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n for (;i < chunkIds.length; i++) {\n chunkId = chunkIds[i];\n if (__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n installedChunks[chunkId][0]();\n }\n installedChunks[chunkId] = 0;\n }\n }\n var self = typeof globalThis !== undefined ? globalThis : self\n var chunkLoadingGlobal = self["webpackChunkAVPlayer"] = self["webpackChunkAVPlayer"] || [];\n chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\n chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));\n })();\n (function() {\n var inProgress = {};\n __webpack_require__.l = function(url, done) {\n if (inProgress[url]) { inProgress[url].push(done); return; }\n inProgress[url] = [done];\n var onComplete = function(event) {\n clearTimeout(timeout);\n var doneFns = inProgress[url];\n delete inProgress[url];\n doneFns && doneFns.forEach(function(fn){fn(event)});\n }\n var timeout = setTimeout(onComplete.bind(null, undefined, { type: "timeout" }), 120000);\n import(url).then(function() {\n onComplete({\n type: "load"\n })\n }, function (error) {\n onComplete({\n type: "missing"\n })\n });\n };\n })();\n __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n __webpack_require__.p = "ROOT_URL";\n __webpack_require__.oe = function(err) { console.error(err); throw err; };\n var f = __webpack_require__(__webpack_require__.s = ENTRY_MODULE);\n return f;\n}\n',h="[\\.|\\-|\\+|\\w|/|@|!]+",c="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+h+").*?\\)";function u(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function d(t,e,r,a){const n={};n[r]=[];let o=e.toString();const d=o.match(/^(function)?\s?\w*\(\w+,\s*(\w+),\s*(\w+)\)/);if(!d)return n;const l=d[3];a.__webpack_exports_process__||(a.__webpack_require__=l,a.__webpack_exports__=d[2],a.__webpack_exports_process__=!0);let f,p=new RegExp("(\\\\n|\\W)"+u(l)+c,"g");for(;f=p.exec(o);)"dll-reference"!==f[3]&&n[r].push(f[3]);for(p=new RegExp("\\("+u(l)+'\\("(dll-reference\\s('+h+'))"\\)\\)'+c,"g");f=p.exec(o);)t[f[2]]||(n[r].push(f[1]),t[f[2]]=i(f[1]).m),n[f[2]]=n[f[2]]||[],n[f[2]].push(f[4]);const m=s()(n);for(let t=0;t0}),!1)}function f(t,e){const r={main:i.m},a=function(t,e){const i={main:[e]},r={main:[],__webpack_exports__:"__webpack_exports__",__webpack_require__:"__webpack_require__",__webpack_exports_process__:!1},a={main:{}};for(;l(i);){const e=s()(i);for(let n=0;n{"use strict";i.d(e,{A:()=>a});var r=i(7672),s=i(576);function a(t,e){return r.sH(t)?+t:e!==s.ZH?e:0}},2100:(t,e,i)=>{"use strict";i.d(e,{A:()=>s});var r=i(576);function s(t,e){return t!=r.Cq&&t.toString?t.toString():e!==r.ZH?e:r.u1}},7246:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var r=i(1026),s=i(4624);class a{constructor(t=1048576){(0,r.A)(this,"buffer",void 0),(0,r.A)(this,"pointer",void 0),(0,r.A)(this,"bitsLeft",void 0),(0,r.A)(this,"size",void 0),(0,r.A)(this,"endPointer",void 0),(0,r.A)(this,"error",void 0),(0,r.A)(this,"onFlush",void 0),this.pointer=0,this.bitsLeft=8,this.size=t,this.endPointer=0,this.error=0,this.buffer=new Uint8Array(this.size)}peekU1(){let t=0;(this.remainingLength()<1||1===this.remainingLength()&&0===this.bitsLeft)&&this.flush();let e=this.pointer,i=this.bitsLeft;return 0===i&&(e++,i=8),t=this.buffer[e]>>i-1&1,t}readU1(){let t=0;return(this.remainingLength()<1||1===this.remainingLength()&&0===this.bitsLeft)&&this.flush(),this.bitsLeft--,t=this.buffer[this.pointer]>>this.bitsLeft&1,0===this.bitsLeft&&(this.pointer++,this.bitsLeft=8),t}readU(t){let e=0;for(let i=0;i=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else if(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer,this.pointer=0,this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else{const e=Math.min(this.size-this.endPointer,t.length);this.buffer.set(t.subarray(0,e),this.endPointer),this.endPointer+=e,s.R8("BSReader, call appendBuffer but the buffer's size is lagger then the remaining size","src/common/io/BitReader.ts",174)}}clear(){this.pointer=this.endPointer=0,this.bitsLeft=8,this.error=0}skipPadding(){this.bitsLeft<8&&(this.bitsLeft=8,this.pointer++)}}},1865:(t,e,i)=>{"use strict";i.d(e,{A:()=>n});var r=i(1026),s=i(2647),a=i(11);class n{constructor(t,e=!0){(0,r.A)(this,"data",void 0),(0,r.A)(this,"buffer",void 0),(0,r.A)(this,"byteStart",void 0),(0,r.A)(this,"pos",void 0),(0,r.A)(this,"size",void 0),(0,r.A)(this,"littleEndian",void 0),this.buffer=t,this.data=t instanceof Uint8Array?new DataView(t.buffer):t.view,this.byteStart=t instanceof Uint8Array?t.byteOffset:0,this.pos=0,this.size=t.byteLength,this.littleEndian=!e}readUint8(){return this.data.getUint8(this.pos+++this.byteStart)}readUint16(){const t=this.data.getUint16(this.pos+this.byteStart,this.littleEndian);return this.pos+=2,t}readUint24(){return this.readUint16()<<8|this.readUint8()}readUint32(){const t=this.data.getUint32(this.pos+this.byteStart,this.littleEndian);return this.pos+=4,t}readUint64(){const t=BigInt(this.readUint32()),e=BigInt(this.readUint32());return this.littleEndian?e<this.size&&(t=this.size),this.pos=Math.max(0,t)}skip(t){this.seek(this.pos+t)}back(t){this.seek(this.pos-t)}remainingSize(){return this.size-this.pos}readBuffer(t){t=Math.min(t,this.remainingSize());const e=this.buffer.slice(this.pos,this.pos+t);return this.pos+=t,e}appendBuffer(t){this.buffer=(0,s.A)(Uint8Array,[this.buffer.slice(),t.slice()]),this.data=new DataView(this.buffer.buffer),this.size+=t.byteLength,this.byteStart=0}resetBuffer(t,e=!0){this.buffer=t,this.data=t instanceof Uint8Array?new DataView(t.buffer):t.view,this.byteStart=t instanceof Uint8Array?t.byteOffset:0,this.pos=0,this.size=t.byteLength,this.littleEndian=!e}}},729:(t,e,i)=>{"use strict";i.d(e,{A:()=>n});var r=i(1026),s=i(4624),a=i(11);class n{constructor(t,e=!0){(0,r.A)(this,"data",void 0),(0,r.A)(this,"buffer",void 0),(0,r.A)(this,"byteStart",void 0),(0,r.A)(this,"pos",void 0),(0,r.A)(this,"size",void 0),(0,r.A)(this,"littleEndian",void 0),this.buffer=t,this.data=t instanceof Uint8Array?new DataView(t.buffer):t.view,this.byteStart=t instanceof Uint8Array?t.byteOffset:0,this.pos=0,this.size=t.byteLength,this.littleEndian=!e}writeUint8(t){this.data.setUint8(this.pos+++this.byteStart,t)}writeUint16(t){this.data.setUint16(this.pos+this.byteStart,t,this.littleEndian),this.pos+=2}writeUint24(t){const e=3840&t,i=240&t,r=15&t;this.littleEndian?(this.writeUint8(r),this.writeUint8(i),this.writeUint8(e)):(this.writeUint8(e),this.writeUint8(i),this.writeUint8(r))}writeUint32(t){this.data.setUint32(this.pos+this.byteStart,t,this.littleEndian),this.pos+=4}writeUint64(t){const e=t&BigInt(4294967295),i=(t&BigInt(4294967295)<>BigInt(32);this.littleEndian?(this.writeUint32(Number(e)),this.writeUint32(Number(i))):(this.writeUint32(Number(i)),this.writeUint32(Number(e)))}writeInt8(t){this.data.setInt8(this.pos+++this.byteStart,t)}writeInt16(t){this.data.setInt16(this.pos+this.byteStart,t,this.littleEndian),this.pos+=2}writeInt32(t){this.data.setInt32(this.pos+this.byteStart,t,this.littleEndian),this.pos+=4}writeInt64(t){const e=t&BigInt(4294967295),i=(t&BigInt(4294967295)<>BigInt(32);this.littleEndian?(this.writeInt32(Number(e)),this.writeInt32(Number(i))):(this.writeInt32(Number(i)),this.writeInt32(Number(e)))}writeFloat(t){this.data.setFloat32(this.pos+this.byteStart,t,this.littleEndian),this.pos+=4}writeDouble(t){this.data.setFloat64(this.pos+this.byteStart,t,this.littleEndian),this.pos+=8}getPos(){return this.pos}seek(t){t>this.size&&(t=this.size),this.pos=Math.max(0,t)}skip(t){this.seek(this.pos+t)}back(t){this.seek(this.pos-t)}remainingSize(){return this.size-this.pos}writeBuffer(t){let e=t.length;this.remainingSize(){"use strict";i.d(e,{A:()=>h});var r=i(1026),s=i(4624),a=i(11),n=i(3724),o="src/common/io/IOReader.ts";class h{constructor(t=1048576,e=!0,i){if((0,r.A)(this,"data",void 0),(0,r.A)(this,"buffer",void 0),(0,r.A)(this,"pointer",void 0),(0,r.A)(this,"endPointer",void 0),(0,r.A)(this,"pos",void 0),(0,r.A)(this,"size",void 0),(0,r.A)(this,"littleEndian",void 0),(0,r.A)(this,"fileSize_",void 0),(0,r.A)(this,"error",void 0),(0,r.A)(this,"onFlush",void 0),(0,r.A)(this,"onSeek",void 0),(0,r.A)(this,"onSize",void 0),(0,r.A)(this,"flags",void 0),this.pos=BigInt(0),this.pointer=0,this.error=0,this.endPointer=0,this.littleEndian=!e,this.flags=0,i&&i.view)this.size=i.length,this.buffer=i,this.data=i.view;else if(i&&!i.byteOffset)this.size=i.length,this.buffer=i,this.data=new DataView(this.buffer.buffer);else{if(i)throw new Error("not support subarray of ArrayBuffer");this.size=Math.max(t,102400),this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}async readUint8(){this.remainingLength()<1&&await this.flush(1);const t=this.data.getUint8(this.pointer);return this.pointer++,this.pos++,t}async peekUint8(){return this.remainingLength()<1&&await this.flush(1),this.data.getUint8(this.pointer)}async readUint16(){this.remainingLength()<2&&await this.flush(2);const t=this.data.getUint16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}async peekUint16(){return this.remainingLength()<2&&await this.flush(2),this.data.getUint16(this.pointer,this.littleEndian)}async readUint24(){return this.remainingLength()<3&&await this.flush(3),await this.readUint16()<<8|await this.readUint8()}async peekUint24(){this.remainingLength()<3&&await this.flush(3);const t=this.pointer,e=this.pos,i=await this.readUint16()<<8|await this.readUint8();return this.pointer=t,this.pos=e,i}async readUint32(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getUint32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekUint32(){return this.remainingLength()<4&&await this.flush(4),this.data.getUint32(this.pointer,this.littleEndian)}async readUint64(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getBigUint64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekUint64(){return this.remainingLength()<8&&await this.flush(8),this.data.getBigUint64(this.pointer,this.littleEndian)}async readInt8(){this.remainingLength()<1&&await this.flush(1);const t=this.data.getInt8(this.pointer);return this.pointer++,this.pos++,t}async peekInt8(){return this.remainingLength()<1&&await this.flush(1),this.data.getInt8(this.pointer)}async readInt16(){this.remainingLength()<2&&await this.flush(2);const t=this.data.getInt16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}async peekInt16(){return this.remainingLength()<2&&await this.flush(2),this.data.getInt16(this.pointer,this.littleEndian)}async readInt32(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getInt32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekInt32(){return this.remainingLength()<4&&await this.flush(4),this.data.getInt32(this.pointer,this.littleEndian)}async readInt64(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getBigInt64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekInt64(){return this.remainingLength()<8&&await this.flush(8),this.data.getBigInt64(this.pointer,this.littleEndian)}async readFloat(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getFloat32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekFloat(){return this.remainingLength()<4&&await this.flush(4),this.data.getFloat32(this.pointer,this.littleEndian)}async readDouble(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getFloat64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekDouble(){return this.remainingLength()<8&&await this.flush(8),this.data.getFloat64(this.pointer,this.littleEndian)}async readHex(t=1){let e="";for(let i=0;ithis.size&&(this.error=-1048574,s.h2("peekHex, length too large",o,334)),this.remainingLength()0){const r=this.remainingLength();e.set(this.buffer.subarray(this.pointer,this.pointer+r),i),i+=r,this.pointer+=r,this.pos+=BigInt(r),t-=r}for(;t>0;){await this.flush();const r=Math.min(this.endPointer-this.pointer,t);e.set(this.buffer.subarray(this.pointer,this.pointer+r),i),i+=r,this.pointer+=r,this.pos+=BigInt(r),t-=r}}else e.set(this.buffer.subarray(this.pointer,this.pointer+t),0),this.pointer+=t,this.pos+=BigInt(t);return e}async peekBuffer(t,e){return t>this.size&&(this.error=-1048574,s.h2("peekBuffer, length too large",o,410)),this.remainingLength()=t&&(this.pointer+=t),this.pos+=BigInt(e)}remainingLength(){return this.endPointer-this.pointer}async flush_(t){for(;;){const e=await this.onFlush(t);if(-1048575!==e)return e;await new n.A(0)}}async flush(t=0){if(this.onFlush||(this.error=-1048574,s.h2("IOReader error, flush failed because of no flush callback",o,566)),!(this.size-this.remainingLength()<=0))if(t=Math.min(t,this.size),this.pointer0&&this.pointer+e=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else if(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer,this.pointer=0,this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else{const e=Math.min(this.size-this.endPointer,t.length);this.buffer.set(t.subarray(0,e),this.endPointer),this.endPointer+=e,s.R8("IOReader, call appendBuffer but the buffer's size is lagger then the remaining size",o,666)}}reset(){this.pointer=this.endPointer=0,this.pos=BigInt(0),this.error=0}setEndian(t){this.littleEndian=!t}async fileSize(){return this.fileSize_||(this.onSize||(this.error=-1048574,s.h2("IOReader error, fileSize failed because of no onSize callback",o,687)),this.fileSize_=await this.onSize()),this.fileSize_}getBufferSize(){return this.size}async pipe(t,e){if(e)if(this.remainingLength()0){const i=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i),e-=i}for(;e>0;){await this.flush();const i=Math.min(this.remainingLength(),e);await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i),e-=i}}else await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e);else{if(this.remainingLength()>0){const e=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e)}for(;await this.flush_(this.buffer.subarray(0))>0;){const e=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e)}}}}},5336:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var r=i(1026),s=i(11);class a{constructor(t=1048576,e=!0,i){if((0,r.A)(this,"data",void 0),(0,r.A)(this,"buffer",void 0),(0,r.A)(this,"pointer",void 0),(0,r.A)(this,"pos",void 0),(0,r.A)(this,"size",void 0),(0,r.A)(this,"littleEndian",void 0),(0,r.A)(this,"error",void 0),(0,r.A)(this,"onFlush",void 0),(0,r.A)(this,"onSeek",void 0),this.pointer=0,this.pos=BigInt(0),this.size=t,this.littleEndian=!e,this.error=0,i&&i.view)this.size=i.length,this.buffer=i,this.data=i.view;else if(i&&!i.byteOffset)this.size=i.length,this.buffer=i,this.data=new DataView(this.buffer.buffer);else{if(i)throw new Error("not support subarray of ArrayBuffer");this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}writeUint8(t){this.remainingLength()<1&&this.flush(),this.data.setUint8(this.pointer,t),this.pointer++,this.pos++}writeUint16(t){this.remainingLength()<2&&this.flush(),this.data.setUint16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeUint24(t){this.remainingLength()<3&&this.flush();const e=(16711680&t)>>16,i=(65280&t)>>8,r=255&t;this.littleEndian?(this.writeUint8(r),this.writeUint8(i),this.writeUint8(e)):(this.writeUint8(e),this.writeUint8(i),this.writeUint8(r))}writeUint32(t){this.remainingLength()<4&&this.flush(),this.data.setUint32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeUint64(t){this.remainingLength()<8&&this.flush(),this.data.setBigUint64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeInt8(t){this.remainingLength()<1&&this.flush(),this.data.setInt8(this.pointer,t),this.pointer++,this.pos++}writeInt16(t){this.remainingLength()<2&&this.flush(),this.data.setInt16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeInt32(t){this.remainingLength()<4&&this.flush(),this.data.setInt32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeInt64(t){this.remainingLength()<8&&this.flush(),this.data.setBigInt64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeFloat(t){this.remainingLength()<4&&this.flush(),this.data.setFloat32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeDouble(t){this.remainingLength()<8&&this.flush(),this.data.setFloat64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}getPointer(){return this.pointer}getPos(){return this.pos}remainingLength(){return this.size-this.pointer}writeBuffer(t){if(!t.length)return;let e=t.length;if(this.remainingLength()0;){this.flush();const r=Math.min(this.size,e);this.buffer.set(t.subarray(i,i+r),this.pointer),this.pointer+=r,this.pos+=BigInt(r),i+=r,e-=r}}else this.buffer.set(t,this.pointer),this.pointer+=e,this.pos+=BigInt(e)}writeString(t){const e=s.l(t);return this.writeBuffer(e),e.length}encodeString(t){return s.l(t)}flush(){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const t=this.onFlush(this.buffer.subarray(0,this.pointer));if(0!==t)throw this.error=t,Error("IOWriter error, flush failed")}this.pointer=0}flushToPos(t){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const e=this.onFlush(this.buffer.subarray(0,this.pointer),t);if(0!==e)throw this.error=e,Error("IOWriter error, flush failed")}this.pointer=0}seek(t){if(!this.onSeek)throw this.error=-1048574,Error("IOWriter error, seek failed because of no seek callback");this.flush();const e=this.onSeek(t);if(0!==e)throw this.error=e,Error("IOWriter error, seek failed");this.pos=t}seekInline(t){const e=this.pointer;this.pointer=Math.max(0,Math.min(this.size,t)),this.pos+=BigInt(this.pointer-e)}skip(t){const e=this.pointer;this.pointer=Math.min(this.size,this.pointer+t),this.pos+=BigInt(this.pointer-e)}back(t){const e=this.pointer;this.pointer=Math.max(0,this.pointer-t),this.pos+=BigInt(this.pointer-e)}getBuffer(){return this.buffer.subarray(0,this.pointer)}setEndian(t){this.littleEndian=!t}reset(){this.pointer=0,this.pos=BigInt(0),this.error=0}getBufferSize(){return this.size}}},4149:(t,e,i)=>{"use strict";i.d(e,{Ay:()=>l,S3:()=>d,Wo:()=>u});var r=i(1026),s=i(662),a=i.n(s),n=i(4001),o=i.n(n),h=i(2758),c=i(4677);const u="notify",d="request";class l extends h.A{constructor(t){super(!0),(0,r.A)(this,"port",void 0),(0,r.A)(this,"requestMap",void 0),(0,r.A)(this,"seq",void 0),(0,r.A)(this,"closed",void 0),this.port=t,this.port.onmessage=this.handle.bind(this),this.seq=0,this.requestMap=new(a()),this.port.start(),this.closed=!1}handle(t){const e=t.data,i=e.type,r=e.data;if("notify"===i)this.fire(u,r);else if("reply"===i){const t=this.requestMap.get(r.seq);t&&((0,c.A)(r.result)?t.resolve(r.result):r.error?t.reject(r.error):t.resolve(void 0),this.requestMap.delete(r.seq))}else"request"===i&&this.fire(d,r)}notify(t,e={},i=[]){this.port.postMessage({type:"notify",data:{method:t,params:e}},i)}async request(t,e={},i=[]){return new(o())(((r,s)=>{const a=this.seq++;this.requestMap.set(a,{resolve:r,reject:s}),this.port.postMessage({type:"request",data:{seq:a,method:t,params:e}},i)}))}reply(t,e,i,r=[]){const s={seq:t.seq};(0,c.A)(e)?s.result=e:i&&(s.error=i),null!=r&&r.length?this.port.postMessage({type:"reply",data:s},r):this.port.postMessage({type:"reply",data:s})}getPort(){return this.port}destroy(){this.requestMap.size&&(this.requestMap.forEach((t=>{t.reject("ipc port close")})),this.requestMap.clear()),this.port&&(this.port.close(),this.port=null),this.closed=!0}}},3765:(t,e,i)=>{"use strict";i.d(e,{A:()=>v});var r=i(1026),s=i(9638),a=i(6932),n=i(662),o=i.n(n),h=i(1837);i(7903);class c{constructor(){(0,r.A)(this,"worker",void 0),(0,r.A)(this,"workerUrl",void 0),(0,r.A)(this,"taskMap",void 0),(0,r.A)(this,"id",void 0),this.id=0,this.taskMap=new(o());const t=`\n ${(0,h.A)(7903,{varName:"workerSetTimeoutTask"})}\n workerSetTimeoutTask.default(self)\n `,e=new Blob([t],{type:"text/javascript"});this.workerUrl=URL.createObjectURL(e),this.worker=new Worker(this.workerUrl),this.worker.addEventListener("message",(t=>{const e=t.data,i=e.type,r=e.id;if("pong"===i){const t=this.taskMap.get(r);t&&t(!0)}}))}setTimeout(t,e=0){const i=this.id++;return this.taskMap.set(i,t),this.worker.postMessage({type:"ping",data:{timeout:e,id:i}}),i}clearTimeout(t){this.taskMap.delete(t)}destroy(){this.worker&&(this.worker.terminate(),this.worker=null),this.workerUrl&&(URL.revokeObjectURL(this.workerUrl),this.workerUrl=null),this.taskMap&&(this.taskMap.clear(),this.taskMap=null)}}var u=i(6401),d=i(2739),l=i(576);let f,p=0;function m(){return f?(p++,f):(f=new c,p=1,f)}function g(){0!==p&&(p--,0===p&&(f.destroy(),f=null))}class v{constructor(t,e=!0){(0,r.A)(this,"messageChannel",void 0),(0,r.A)(this,"interval",void 0),(0,r.A)(this,"started",void 0),(0,r.A)(this,"timer",void 0),(0,r.A)(this,"workerTimer",void 0),(0,r.A)(this,"workerSetTimeout",void 0),(0,r.A)(this,"onClock",void 0),(0,r.A)(this,"nextTick",void 0),(0,r.A)(this,"a",void 0),(0,r.A)(this,"b",void 0),(0,r.A)(this,"beta",void 0),(0,r.A)(this,"alpha",void 0),(0,r.A)(this,"count",void 0),(0,r.A)(this,"equivalent",void 0),(0,r.A)(this,"timestamp",void 0),(0,r.A)(this,"onVisibilityChange",void 0),(0,r.A)(this,"timeoutNext",void 0),(0,r.A)(this,"running",void 0),(0,r.A)(this,"highPerformance",void 0),this.started=!1,this.interval=t,this.highPerformance=e,this.a=.2,this.b=4,this.equivalent=50,this.timestamp=0,this.nextTick=()=>{if(this.started&&!this.running)if(this.running=!0,this.interval>=4||!this.highPerformance)this.timeoutTick();else if(this.interval<=0)this.messageChannel.port1.postMessage(null);else{const t=(0,a.A)();t-this.timestamp>this.equivalent&&(this.count=0,this.timestamp=t),this.count{t?this.workerTimer=null:this.timer=null,this.running=!1,this.count++,this.onClock?this.onClock(this.nextTick):this.nextTick()},(0,s.A)()||"hidden"!==document.visibilityState||(this.workerSetTimeout=m()),this.running=!1}compute(t=!0){this.interval>0&&(this.beta=Math.ceil(this.equivalent*(1-this.b/this.interval)/(this.a-this.b)),this.alpha=Math.floor(this.equivalent/this.interval-this.beta),t&&(this.count=0))}timeoutTick(){this.workerSetTimeout&&"hidden"===document.visibilityState&&this.interval<1e3?this.workerTimer=this.workerSetTimeout.setTimeout(this.timeoutNext,this.interval):this.timer=setTimeout(this.timeoutNext,this.interval)}start(){this.started||(this.started=!0,this.timestamp=(0,a.A)(),this.nextTick())}stop(){this.started=!1,this.timer&&(clearTimeout(this.timer),this.timer=null),this.workerTimer&&this.workerSetTimeout&&this.workerSetTimeout.clearTimeout(this.workerTimer),this.running=!1}isStarted(){return this.started}setInterval(t){this.interval=Math.max(t,0),this.compute()}getInterval(){return this.interval}isZeroTimeout(){return this.interval<4}destroy(){this.stop(),this.workerSetTimeout&&(g(),this.workerSetTimeout=null),this.onVisibilityChange&&(document.removeEventListener("visibilitychange",this.onVisibilityChange),this.onVisibilityChange=null)}handleEvent(){this.messageChannel.port2.onmessage=()=>{this.started&&(this.running=!1,this.count++,this.onClock?this.onClock(this.nextTick):this.nextTick())},(0,s.A)()||(this.onVisibilityChange=function(t,e,i){let r;return function(){let e=this;if(!r){const i=d.$r(arguments);r=setTimeout((function(){r=l.ZH,(0,u.A)(t,e,i)}),20)}}}((t=>{"hidden"===document.visibilityState?(this.workerSetTimeout=m(),this.timer&&(clearTimeout(this.timer),this.timer=null,this.running=!1),this.nextTick()):(this.workerTimer&&(this.workerSetTimeout.clearTimeout(this.workerTimer),this.workerTimer=null,this.running=!1),this.timer&&(clearTimeout(this.timer),this.timer=null,this.running=!1),g(),this.workerSetTimeout=null,this.nextTick())})),document.addEventListener("visibilitychange",this.onVisibilityChange))}}},9148:(t,e,i)=>{"use strict";i.d(e,{A:()=>h});var r=i(1026),s=i(4001),a=i.n(s),n=i(3765),o=i(6932);class h{constructor(t,e=0,i=0,s=!0,a=!0){(0,r.A)(this,"task",void 0),(0,r.A)(this,"count",void 0),(0,r.A)(this,"emptyCount",void 0),(0,r.A)(this,"started",void 0),(0,r.A)(this,"clock",void 0),(0,r.A)(this,"timestamp",void 0),(0,r.A)(this,"timeout",void 0),(0,r.A)(this,"interval",void 0),(0,r.A)(this,"startTimer",void 0),(0,r.A)(this,"autoInterval",void 0),(0,r.A)(this,"sync",void 0),(0,r.A)(this,"tickAfter",void 0),(0,r.A)(this,"processing",void 0),this.task=t,this.timeout=e,this.interval=i,this.autoInterval=s,this.sync=a,this.count=0,this.emptyCount=0,this.timestamp=0,this.started=!1,this.processing=!1,this.clock=new n.A(this.interval),this.clock.onClock=t=>{if(this.started)if(this.count++,this.sync)this.tickAfter&&(this.tickAfter(),this.tickAfter=null),!1===this.task()?this.stop():this.next(t);else{if(this.processing)return;this.processing=!0,this.task().then((e=>{this.processing=!1,this.tickAfter&&(this.tickAfter(),this.tickAfter=null),!1===e?this.stop():this.next(t)}))}}}next(t){if(!this.started)return;const e=(0,o.A)();if(this.autoInterval&&e-this.timestamp>50){const t=this.emptyCount/this.count;0===this.emptyCount?this.clock.setInterval(Math.max(this.clock.getInterval()>>1,this.interval)):t<.1?this.clock.setInterval(this.clock.getInterval()-1):t>.2?this.clock.setInterval(Math.min(this.clock.getInterval()+1,20)):t>.5&&this.clock.setInterval(this.clock.getInterval()<<1),this.count=0,this.emptyCount=0,this.timestamp=e}t()}start(){this.started=!0,this.timeout?this.startTimer=setTimeout((()=>{this.count=0,this.emptyCount=0,this.timestamp=(0,o.A)(),this.clock.start(),this.startTimer=null}),this.timeout):(this.count=0,this.emptyCount=0,this.timestamp=(0,o.A)(),this.clock.start())}stop(){this.started=!1,this.processing=!1,this.startTimer&&(clearTimeout(this.startTimer),this.startTimer=null),this.clock.stop()}async stopBeforeNextTick(){if(this.startTimer&&(clearTimeout(this.startTimer),this.startTimer=null),this.clock.isStarted())return this.sync?(this.started=!1,this.processing=!1,void this.clock.stop()):new(a())((t=>{this.tickAfter=()=>{this.started=!1,this.processing=!1,this.clock.stop(),t()}}))}isStarted(){return this.started}emptyTask(){this.emptyCount++}isZeroTimeout(){var t;return null===(t=this.clock)||void 0===t?void 0:t.isZeroTimeout()}restart(){this.clock&&(this.stop(),this.clock.setInterval(this.interval),this.start())}resetInterval(){this.clock.setInterval(Math.max(this.clock.getInterval()>>1,this.interval)),this.emptyCount=0,this.count=0,this.timestamp=(0,o.A)()}destroy(){this.stop(),this.task=null,this.timeout=null,this.interval=null}}},3724:(t,e,i)=>{"use strict";i.d(e,{A:()=>n});var r=i(1026),s=i(5249),a=i.n(s);class n{constructor(t){(0,r.A)(this,"timeout",void 0),(0,r.A)(this,"timer",void 0),(0,r.A)(this,"resolve",void 0),(0,r.A)(this,"reject",void 0),(0,r.A)(this,"startTime",void 0),this.timeout=t}then(t,e){this.resolve=t,this.reject=e,this.startTime=a()(),this.timer=setTimeout((()=>{this.resolve(a()()-this.startTime),this.timer=null}),1e3*this.timeout)}stop(t=!0){this.timer&&(clearTimeout(this.timer),this.timer=null,this.resolve&&t?this.resolve(a()()-this.startTime):this.reject&&!t&&this.reject(a()()-this.startTime))}reset(t){t&&(this.timeout=t),this.timer&&(clearTimeout(this.timer),this.timer=setTimeout((()=>{this.resolve(a()()-this.startTime),this.timer=null}),1e3*this.timeout))}}},7903:(t,e,i)=>{"use strict";i.r(e),i.d(e,{default:()=>o});var r=i(1026),s=i(4624),a="src/common/timer/workerSetTimeoutTask.ts";class n{constructor(t){(0,r.A)(this,"worker",void 0),this.worker=t,this.handleEvents()}handleEvents(){this.worker.addEventListener("message",(t=>{var e;let i=t.data.data;setTimeout((()=>{this.worker.postMessage({type:"pong",id:i.id})}),Math.max(null!==(e=i.timeout)&&void 0!==e?e:0,4))}))}}function o(t){try{new n(t)}catch(t){s.z3("new WorkerSetTimeout failed",a,32)}}},2739:(t,e,i)=>{"use strict";i.d(e,{$r:()=>d,El:()=>l,TF:()=>c,VC:()=>h,__:()=>n,zy:()=>u});var r=i(7672),s=i(576),a=i(6401);function n(t,e,i){if(!t)return;const{length:r}=t;if(r)if(i)for(let i=r-1;i>=0&&e(t[i],i)!==s.W8;i--);else for(let i=0;i=0}function d(t){return r.YO(t)?t:(0,a.A)(s.Ml.slice,t)}function l(t,e){let i=0,r=t.length-1,s=-1;for(;i<=r;){let a=(i+r)/2>>>0;const n=e(t[a]);if(0===n){s=a;break}1===n?i=a+1:(r=a-1,s=a)}return s}},4919:(t,e,i)=>{"use strict";i.d(e,{E_:()=>a});var r=i(2739);const s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function a(t){const e="function"==typeof atob?atob(t):function(t){function e(t){const e=s.indexOf(t);return-1===e?0:e}let i="";for(let r=0;r>4,c=(15&a)<<4|n>>2,u=(3&n)<<6|o;i+=String.fromCharCode(h),64!==n&&(i+=String.fromCharCode(c)),64!==o&&(i+=String.fromCharCode(u))}return i}(t),i=new Uint8Array(e.length);for(let t=0;t{n[t]=e}))},3607:(t,e,i)=>{"use strict";function r(t){return t>0?t:-t}function s(t,e){return t>e?t:e}function a(t,e){return t>e?e:t}i.d(e,{T9:()=>s,jk:()=>a,tn:()=>r})},4214:(t,e,i)=>{"use strict";i.d(e,{A:()=>p});var r=i(2348),s=i.n(r),a=i(2739),n=i(7672),o=i(2148);function h(t,e,i=!1){const r=e.split("."),s=t.split(".");for(let t=0;t=(0,o.A)(r[t]))return s.length>=r.length;if((0,o.A)(s[t])>(0,o.A)(r[t]))return!0;if((0,o.A)(s[t])<(0,o.A)(r[t]))return!1;if(t===r.length-1&&t===s.length-1)return i;if(t===r.length-1)return!0;if(t===s.length-1)return!1}return!0}function c(t){return n.Yj(t)&&t.split(".").shift()||""}const u=[["alipay",/alipay/],["wechat",/micromessenger/],["dingtalk",/dingtalk[ \/]([\d_.]+)/],["baiduApp",/baiduboxapp/],["baidu",/baidubrowser/],["baidu",/bdbrowser/],["uc",/ucbrowser/],["uc",/ucweb/],["qq",/qqbrowser/],["qqApp",/qq/],["ie",/iemobile[ \/]([\d_.]+)/],["ie",/msie[ \/]([\d_.]+)/],["ie",/trident[ \/]([\d_.]+)/,4],["edge",/edge[ \/]([\d_.]+)/],["newEdge",/edg[ \/]([\d_.]+)/],["chrome",/chrome[ \/]([\d_.]+)/],["firefox",/firefox[ \/]([\d_.]+)/],["opera",/opera(?:.*version)?[ \/]([\d_.]+)/],["safari",/version[ \/]([\d_.]+) safari/],["safari",/version[ \/]([\d_.]+) \S* safari/],["safari",/safari/]],d={},l={},f=function(t){let e,i;return(0,a.__)(u,(r=>{let a=r[1].exec(t);if(a)return e=r[0],i=a[1],i&&(i=i.replace(/_/g,"."),r[2]&&(i=s()(i,10)+r[2]+".0")),!1})),{name:e||"",version:i||"",majorVersion:(d[e]||c)(i),checkVersion:l[e]||h}}(("object"==typeof navigator&&navigator.userAgent||"").toLowerCase());f.name&&(f[f.name]=!0);const p=f},576:(t,e,i)=>{"use strict";i.d(e,{Cq:()=>o,Cy:()=>c,M_:()=>p,Ml:()=>v,TK:()=>m,W8:()=>n,ZG:()=>l,ZH:()=>h,aV:()=>u,jf:()=>f,rT:()=>a,s0:()=>d,u1:()=>A,x7:()=>g});var r=i(7403),s=i.n(r);const a=!0,n=!1,o=null,h=void 0,c=-1,u="undefined",d="function",l=".",f=typeof window!==u?window:h,p=(typeof document!==u&&document,typeof globalThis!==u?globalThis:typeof i.g!==u?i.g:f),m=typeof self!==u?self:p,g=function(){},v=(s()({}),s()([])),A=""},7672:(t,e,i)=>{"use strict";i.d(e,{Ik:()=>u,Pc:()=>h,YO:()=>c,Yj:()=>d,ai:()=>l,o:()=>f,sH:()=>m,sv:()=>g,zM:()=>p});var r=i(8632),s=i.n(r),a=i(8032),n=i.n(a),o=i(576);function h(t){return typeof t===o.s0}function c(t){return s()(t)}function u(t){return t!==o.Cq&&"object"==typeof t}function d(t){return"string"==typeof t}function l(t){return"number"==typeof t&&!isNaN(t)}function f(t){return"bigint"==typeof t}function p(t){return"boolean"==typeof t}function m(t){return l(t)||d(t)&&!isNaN(n()(t))&&isFinite(+t)}function g(t){return t instanceof ArrayBuffer}},4624:(t,e,i)=>{"use strict";i.d(e,{R8:()=>w,V$:()=>g,Yz:()=>A,h2:()=>k,pq:()=>y,rD:()=>o,z3:()=>b});var r=i(576),s=i(2100);const a=0,n=1,o=2,h=3,c=4,u=5,d=typeof console!==r.aV?console:r.Cq,l=/common/.test((0,s.A)(r.x7))?o:h,f=(r.jf&&/edge|msie|trident/i.test(r.jf.navigator.userAgent),r.u1),p=d?f?function(t,e,i){d.log(f+t,i,e)}:function(t,e){d.log(t,e)}:r.x7;function m(){if(r.M_){const t=r.TK.COMMON_LOG_LEVEL;if(t>=a&&t<=u)return t}return l}function g(t){r.TK.COMMON_LOG_LEVEL=t}function v(t){return`background-color:${t};border-radius:12px;color:#fff;font-size:10px;padding:3px 6px;`}function A(t,e,i){m()<=n&&p(`[${arguments[1]}][line ${arguments[2]}] [debug]`,t,v("#999"))}function y(t,e,i){m()<=o&&p(`[${arguments[1]}][line ${arguments[2]}] [info]`,t,v("#2db7f5"))}function w(t,e,i){m()<=h&&p(`[${arguments[1]}][line ${arguments[2]}] [warn]`,t,v("#f90"))}function b(t,e,i){m()<=c&&p(`[${arguments[1]}][line ${arguments[2]}] [error]`,t,v("#ed4014"))}function k(t,e,i){if(m()<=u)throw b(t,e,i),new Error(`[${arguments[1]}][line ${arguments[2]}] [fatal]: ${t}`)}},5335:(t,e,i)=>{"use strict";i.d(e,{C:()=>c,X$:()=>h,__:()=>n}),i(9736);var r=i(7672),s=i(2739),a=i(576);function n(t,e){for(let i in t)if(e(t[i],i)===a.W8)break}function o(t,e){return r.Ik(t)?r.Ik(e)?(n(e,(function(e,i){t[i]=e})),t):t:e}function h(t,e,i){return o(o(t,e),i)}function c(t,e){let i=t;return r.YO(t)?e?(i=[],s.__(t,(function(t,r){i[r]=c(t,e)}))):i=t.slice():r.Ik(t)&&(i={},n(t,(function(t,r){i[r]=e?c(t,e):t}))),i}},525:(t,e,i)=>{"use strict";i.d(e,{GP:()=>d,di:()=>h,qh:()=>c,zy:()=>u});var r=i(2348),s=i.n(r),a=i(7672),n=i(576),o=i(2100);function h(t,e,i){return a.ai(i)?e===i?n.u1:t.slice(e,i):t.slice(e)}function c(t,e,i){return t.indexOf(e,i!==n.ZH?i:0)}function u(t,e){return c(t,e)>=0}function d(t,...e){let i=0;const r=e.length;return t.replace(/(%[sdvx%])|(%0(\d)+[dx])/g,(t=>{if(i>=r)return t;const a=e[i++];if(/%0(\d)+[dx]/g.test(t)){const e=s()(t.substring(1));let i="d"===t[t.length-1]?(0,o.A)(Number(a)):Number(a).toString(16);return e>i.length&&(i=new Array(e-i.length).fill("0").join("")+i),i}switch(t){case"%%":return"%";case"%s":return String(a);case"%d":return(0,o.A)(Number(a));case"%v":return"";case"%x":return Number(a).toString(16)}return t}))}},5797:(t,e,i)=>{"use strict";i.d(e,{A:()=>s});var r=i(4214);const s=function(){let t="function"==typeof Blob,e="object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate,i="function"==typeof fetch,s="object"==typeof document&&document.createElement("canvas"),a=s&&!!s.getContext("webgl"),n="function"==typeof OffscreenCanvas,o="function"==typeof Worker,h="function"==typeof ArrayBuffer,c="object"==typeof Atomics,u="function"==typeof AudioContext||"function"==typeof webkitAudioContext,d="function"==typeof AudioWorklet,l="function"==typeof VideoDecoder,f="function"==typeof AudioDecoder,p="function"==typeof SharedArrayBuffer,m="function"==typeof MediaSource||"function"==typeof ManagedMediaSource,g="function"==typeof Proxy,v=o&&p&&c&&g;r.A.safari&&!r.A.checkVersion(r.A.majorVersion,"11",!0)&&(e=!1),r.A.chrome&&!r.A.checkVersion(r.A.majorVersion,"94",!0)&&(l=!1,f=!1),r.A.safari&&!r.A.checkVersion(r.A.majorVersion,"17",!0)&&(l=!1);let A="object"==typeof navigator&&"object"==typeof navigator.gpu,y="function"==typeof MediaSourceHandle,w=e&&"function"==typeof WebAssembly.Global;return{browser:r.A,blob:t,wasm:e,fetch:i,webgl:a,worker:o,mse:m,arrayBuffer:h,audioContext:u,audioWorklet:d,videoDecoder:l,audioDecoder:f,atomics:c,shareArrayBuffer:p,thread:v,webgpu:A,offscreenCanvas:n,workerMSE:y,webAssemblyGlobal:w,proxy:g,simd:r.A.chrome&&r.A.checkVersion(r.A.majorVersion,"91",!0)||r.A.firefox&&r.A.checkVersion(r.A.majorVersion,"89",!0)||r.A.safari&&r.A.checkVersion(r.A.version,"16.4",!0),wasmBaseSupported:i&&e&&a&&u&&h&&w}}()},11:(t,e,i)=>{"use strict";i.d(e,{D:()=>n,l:()=>a});const r="function"==typeof TextEncoder?new TextEncoder:null,s="function"==typeof TextDecoder?new TextDecoder:null;function a(t){if(r)return r.encode(t);const e=[];for(let i=0;i=55296&&r<=57343&&(r=65536+((1023&r)<<10)|1023&t.charCodeAt(++i)),r<=127?e.push(r):r<=2047?(e.push(192|r>>6),e.push(128|63&r)):r<=65535?(e.push(224|r>>12),e.push(128|r>>6&63),e.push(128|63&r)):(e.push(240|r>>18),e.push(128|r>>12&63),e.push(128|r>>6&63),e.push(128|63&r))}return new Uint8Array(e)}function n(t){if(t instanceof Uint8Array&&s&&!("function"==typeof SharedArrayBuffer&&t.buffer instanceof SharedArrayBuffer))return s.decode(t);let e="";for(let i=0;i>>0];if(!(128&r)){e+=String.fromCharCode(r);continue}let s=63&t[i++>>>0];if(192==(224&r)){e+=String.fromCharCode((31&r)<<6|s);continue}let a=63&t[i++>>>0];if(r=224==(240&r)?(15&r)<<12|s<<6|a:(7&r)<<18|s<<12|a<<6|63&t[i++>>>0],r<65536)e+=String.fromCharCode(r);else{let t=r-65536;e+=String.fromCharCode(55296|t>>10,56320|1023&t)}}return e}},8507:(t,e,i)=>{"use strict";function r(t){const e=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],i={},r=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(t);let s=14;for(;s--;){var a;i[e[s]]=null!==(a=r[s])&&void 0!==a?a:""}return{protocol:i.protocol,file:i.file,host:i.host,port:i.port,user:i.user,password:i.password,origin:`${i.protocol}://${i.authority}`,pathname:i.path,search:`?${i.query}`,hash:i.anchor?`#${i.anchor}`:""}}i.d(e,{ll:()=>d,qg:()=>r}),i(3146);const s=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,n=/^(?=([^\/?#]*))\1([^]*)$/,o=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/;function h(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}function c(t){const e=o.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null}function u(t){for(t=t.split("").reverse().join("").replace(s,"");t.length!==(t=t.replace(a,"")).length;);return t.split("").reverse().join("")}function d(t,e,i){if(i=i||{},t=t.trim(),!(e=e.trim())){if(!i.alwaysNormalize)return t;let e=c(t);if(!e)throw new Error("Error trying to parse base URL.");return e.path=u(e.path),h(e)}let r=c(e);if(!r)throw new Error("Error trying to parse relative URL.");if(r.scheme)return i.alwaysNormalize?(r.path=u(r.path),h(r)):e;let s=c(t);if(!s)throw new Error("Error trying to parse base URL.");if(!s.netLoc&&s.path&&"/"!==s.path[0]){let t=n.exec(s.path);s.netLoc=t[1],s.path=t[2]}s.netLoc&&!s.path&&(s.path="/");const a={scheme:s.scheme,netLoc:r.netLoc,path:null,params:r.params,query:r.query,fragment:r.fragment};if(!r.netLoc&&(a.netLoc=s.netLoc,"/"!==r.path[0]))if(r.path){let t=s.path,e=t.substring(0,t.lastIndexOf("/")+1)+r.path;a.path=u(e)}else a.path=s.path,r.params||(a.params=s.params,r.query||(a.query=s.query));return null===a.path&&(a.path=i.alwaysNormalize?u(r.path):r.path),h(a)}},8096:(t,e,i)=>{"use strict";i.d(e,{$z:()=>c,DD:()=>u,Ee:()=>o,GG:()=>a,p7:()=>h});var r=i(1865);function s(t){let e=0,i=0;for(;;){const r=t.readUint8();if(e|=(127&r)<>=7)&&!(64&r)||-1===e&&64&r?i=!1:r|=128,await t.writeUint8(r)}}async function c(t,e){do{let i=127&e;0!=(e>>=7)&&(i|=128),await t.writeUint8(i)}while(0!==e)}function u(t,e){const i=new r.A(t,!0);for(i.skip(8);i.remainingSize();){const r=i.readUint8(),a=s(i);if(2===r){let r=s(i);for(;r--;){const r=s(i);i.skip(r);const a=s(i);switch(i.skip(a),i.readUint8()){case 0:s(i);break;case 3:n(i),s(i);break;case 2:{const r=Number(i.getPos());return void(t[r]=e?2|t[r]:-3&t[r])}case 1:{n(i);const t=s(i);s(i),1&t&&s(i);break}}}return}i.skip(a)}}},4268:(t,e,i)=>{"use strict";var r=i(1026),s=i(4001),a=i.n(s),n=i(4149),o=i(7503),h=i(7672),c=i(4624);class u extends o.A{constructor(){super(),(0,r.A)(this,"pullIPC",void 0),(0,r.A)(this,"frontBuffer",void 0),(0,r.A)(this,"backBuffer",void 0),(0,r.A)(this,"channels",void 0),(0,r.A)(this,"backBufferOffset",void 0),(0,r.A)(this,"ended",void 0),(0,r.A)(this,"frontBuffered",void 0),(0,r.A)(this,"pause",void 0),(0,r.A)(this,"firstRendered",void 0),(0,r.A)(this,"stopped",void 0),(0,r.A)(this,"afterPullResolve",void 0),this.ipcPort.on(n.S3,(async t=>{switch(t.method){case"init":this.ipcPort.reply(t);break;case"start":{const{port:e,channels:i}=t.params;this.channels=i,this.pullIPC=new n.Ay(e);const r=[],s=[];await this.pull(r),await this.pull(s),this.frontBuffer=s,this.backBuffer=r,this.backBufferOffset=0,this.ended=!1,this.frontBuffered=!0,this.pause=!1,this.firstRendered=!1,this.stopped=!1,this.ipcPort.reply(t);break}case"restart":{if(!this.ended)return void this.ipcPort.reply(t);const e=[],i=[];await this.pull(e),await this.pull(i),this.frontBuffer=i,this.backBuffer=e,this.backBufferOffset=0,this.ended=!1,this.frontBuffered=!0,this.pause=!1,this.firstRendered=!1,this.stopped=!1,this.ipcPort.reply(t);break}case"clear":this.backBufferOffset=10,this.ipcPort.reply(t);break;case"stop":this.ended||await new(a())((t=>{this.afterPullResolve=t})),this.stopped=!0,this.pullIPC.destroy(),this.ipcPort.reply(t);break;case"pause":this.pause=!0,this.ipcPort.reply(t);break;case"unpause":this.pause=!1,this.ipcPort.reply(t)}}))}async pull(t){const e=await this.pullIPC.request("pullBuffer",{nbSamples:1280});if(h.ai(e))this.ended=!0;else{const i=new Float32Array(e);for(let e=0;e{this.frontBuffered=!0})),!0)}process(t,e,i){if(this.stopped)return!1;if(this.backBuffer&&!this.pause){if(10===this.backBufferOffset){if(this.ended)return this.backBuffer=null,this.frontBuffer=null,c.pq("audio source ended","src/avrender/pcm/AudioSourceWorkletProcessor.ts",196),this.ipcPort.notify("ended"),!0;if(!this.swapBuffer())return this.ipcPort.notify("stutter"),!0}const t=e[0];for(let e=0;e{"use strict";var r=i(1026),s=i(4001),a=i.n(s),n=i(3939),o=i(932),h=i(4149),c=i(7503),u=i(4059),d=i(7837),l=i(4624);class f extends c.A{constructor(){super(),(0,r.A)(this,"pullIPC",void 0),(0,r.A)(this,"frontBuffer",void 0),(0,r.A)(this,"backBuffer",void 0),(0,r.A)(this,"channels",void 0),(0,r.A)(this,"backBufferOffset",void 0),(0,r.A)(this,"ended",void 0),(0,r.A)(this,"frontBuffered",void 0),(0,r.A)(this,"firstRendered",void 0),(0,r.A)(this,"float32",void 0),(0,r.A)(this,"pause",void 0),(0,r.A)(this,"stopped",void 0),(0,r.A)(this,"afterPullResolve",void 0),this.ipcPort.on(h.S3,(async t=>{switch(t.method){case"init":{const{memory:e}=t.params;await(0,u.Tg)({memory:e,disableAsm:!0}),this.ipcPort.reply(t);break}case"start":{const{port:e,channels:i}=t.params;this.channels=i,this.pullIPC=new h.Ay(e);const r=this.allocBuffer(),s=this.allocBuffer();await this.pullIPC.request("pull",{buffer:s}),await this.pullIPC.request("pull",{buffer:r}),this.frontBuffer=r,this.backBuffer=s,this.backBufferOffset=0,this.ended=!1,this.pause=!1,this.frontBuffered=!0,this.firstRendered=!1,this.stopped=!1,this.float32=new Float32Array((0,u.eq)().buffer),this.ipcPort.reply(t);break}case"restart":{if(!this.ended)return void this.ipcPort.reply(t);const e=this.allocBuffer(),i=this.allocBuffer();await this.pullIPC.request("pull",{buffer:i}),await this.pullIPC.request("pull",{buffer:e}),this.frontBuffer=e,this.backBuffer=i,this.backBufferOffset=0,this.ended=!1,this.pause=!1,this.frontBuffered=!0,this.firstRendered=!1,this.stopped=!1,this.float32=new Float32Array((0,u.eq)().buffer),this.ipcPort.reply(t);break}case"stop":this.ended||await new(a())((t=>{this.afterPullResolve=t})),this.freeBuffer(this.backBuffer),this.freeBuffer(this.frontBuffer),this.backBuffer=0,this.frontBuffer=0,this.stopped=!0,this.pullIPC.destroy(),this.ipcPort.reply(t);break;case"clear":this.backBufferOffset=10,this.ipcPort.reply(t);break;case"pause":this.pause=!0,this.ipcPort.reply(t);break;case"unpause":this.pause=!1,this.ipcPort.reply(t)}}))}allocBuffer(){const t=(0,d.Gy)(40);o.M[20](t,(0,d.Gy)(4*this.channels));const e=(0,d.Gy)(5120*this.channels);for(let i=0;i{this.frontBuffered=!0})),!0}process(t,e,i){if(this.stopped)return!1;if(this.backBuffer&&!this.pause){if(10===this.backBufferOffset){if(this.ended)return this.freeBuffer(this.backBuffer),this.freeBuffer(this.frontBuffer),this.backBuffer=0,this.frontBuffer=0,l.pq("audio source ended","src/avrender/pcm/AudioSourceWorkletProcessor2.ts",236),this.ipcPort.notify("ended"),!0;if(!this.swapBuffer())return this.ipcPort.notify("stutter"),!0}const t=e[0];for(let e=0;e>>2)+128*this.backBufferOffset,(n.f[20](n.f[20](this.backBuffer)+4*e)>>>2)+128*(this.backBufferOffset+1)),0);this.backBufferOffset++,this.firstRendered||(this.firstRendered=!0,this.ipcPort.notify("firstRendered"))}return!0}}registerProcessor("audio-source-processor",f)},7503:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var r=i(1026),s=i(4149);class a extends AudioWorkletProcessor{constructor(){super(),(0,r.A)(this,"ipcPort",void 0),this.ipcPort=new s.Ay(this.port)}async request(t,e,i){return this.ipcPort.request(t,e,i)}notify(t,e,i){this.ipcPort.notify(t,e,i)}}},7149:(t,e,i)=>{i(8355),t.exports=i(6438).Array.isArray},7172:(t,e,i)=>{i(3204),t.exports=i(6438).Date.now},5079:(t,e,i)=>{var r=i(6438),s=r.JSON||(r.JSON={stringify:JSON.stringify});t.exports=function(t){return s.stringify.apply(s,arguments)}},2861:(t,e,i)=>{i(8978),i(7863),i(7914),i(6050),i(8337),i(4674),i(2223),t.exports=i(6438).Map},2696:(t,e,i)=>{i(4712);var r=i(6438).Object;t.exports=function(t,e,i){return r.defineProperty(t,e,i)}},2948:(t,e,i)=>{i(1780),t.exports=i(6438).Object.freeze},2160:(t,e,i)=>{i(8128),t.exports=i(6438).Object.getPrototypeOf},7567:(t,e,i)=>{i(6847),t.exports=i(6438).Object.keys},1724:(t,e,i)=>{i(4284),t.exports=i(6438).Object.setPrototypeOf},7279:(t,e,i)=>{i(5828),t.exports=i(6438).parseFloat},5216:(t,e,i)=>{i(5331),t.exports=i(6438).parseInt},4750:(t,e,i)=>{i(8978),i(7863),i(7914),i(1229),i(2639),i(6121),t.exports=i(6438).Promise},1707:(t,e,i)=>{i(6801),t.exports=i(6438).setImmediate},6560:(t,e,i)=>{i(9626),i(8978),i(2860),i(716),t.exports=i(6438).Symbol},4220:(t,e,i)=>{i(7863),i(7914),t.exports=i(4336).f("iterator")},9967:(t,e,i)=>{t.exports=i(4336).f("toPrimitive")},5219:t=>{t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},2560:t=>{t.exports=function(){}},2832:t=>{t.exports=function(t,e,i,r){if(!(t instanceof e)||void 0!==r&&r in t)throw TypeError(i+": incorrect invocation!");return t}},812:(t,e,i)=>{var r=i(4401);t.exports=function(t){if(!r(t))throw TypeError(t+" is not an object!");return t}},7076:(t,e,i)=>{var r=i(5838);t.exports=function(t,e){var i=[];return r(t,!1,i.push,i,e),i}},4448:(t,e,i)=>{var r=i(5133),s=i(181),a=i(2917);t.exports=function(t){return function(e,i,n){var o,h=r(e),c=s(h.length),u=a(n,c);if(t&&i!=i){for(;c>u;)if((o=h[u++])!=o)return!0}else for(;c>u;u++)if((t||u in h)&&h[u]===i)return t||u||0;return!t&&-1}}},600:(t,e,i)=>{var r=i(8852),s=i(7001),a=i(6310),n=i(181),o=i(9244);t.exports=function(t,e){var i=1==t,h=2==t,c=3==t,u=4==t,d=6==t,l=5==t||d,f=e||o;return function(e,o,p){for(var m,g,v=a(e),A=s(v),y=r(o,p,3),w=n(A.length),b=0,k=i?f(e,w):h?f(e,0):void 0;w>b;b++)if((l||b in A)&&(g=y(m=A[b],b,v),t))if(i)k[b]=g;else if(g)switch(t){case 3:return!0;case 5:return m;case 6:return b;case 2:k.push(m)}else if(u)return!1;return d?-1:c||u?u:k}}},9742:(t,e,i)=>{var r=i(4401),s=i(5461),a=i(254)("species");t.exports=function(t){var e;return s(t)&&("function"!=typeof(e=t.constructor)||e!==Array&&!s(e.prototype)||(e=void 0),r(e)&&null===(e=e[a])&&(e=void 0)),void 0===e?Array:e}},9244:(t,e,i)=>{var r=i(9742);t.exports=function(t,e){return new(r(t))(e)}},4968:(t,e,i)=>{var r=i(3417),s=i(254)("toStringTag"),a="Arguments"==r(function(){return arguments}());t.exports=function(t){var e,i,n;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(i=function(t,e){try{return t[e]}catch(t){}}(e=Object(t),s))?i:a?r(e):"Object"==(n=r(e))&&"function"==typeof e.callee?"Arguments":n}},3417:t=>{var e={}.toString;t.exports=function(t){return e.call(t).slice(8,-1)}},5933:(t,e,i)=>{"use strict";var r=i(8423).f,s=i(2087),a=i(953),n=i(8852),o=i(2832),h=i(5838),c=i(8839),u=i(322),d=i(5274),l=i(8219),f=i(5172).fastKey,p=i(6096),m=l?"_s":"size",g=function(t,e){var i,r=f(e);if("F"!==r)return t._i[r];for(i=t._f;i;i=i.n)if(i.k==e)return i};t.exports={getConstructor:function(t,e,i,c){var u=t((function(t,r){o(t,u,e,"_i"),t._t=e,t._i=s(null),t._f=void 0,t._l=void 0,t[m]=0,null!=r&&h(r,i,t[c],t)}));return a(u.prototype,{clear:function(){for(var t=p(this,e),i=t._i,r=t._f;r;r=r.n)r.r=!0,r.p&&(r.p=r.p.n=void 0),delete i[r.i];t._f=t._l=void 0,t[m]=0},delete:function(t){var i=p(this,e),r=g(i,t);if(r){var s=r.n,a=r.p;delete i._i[r.i],r.r=!0,a&&(a.n=s),s&&(s.p=a),i._f==r&&(i._f=s),i._l==r&&(i._l=a),i[m]--}return!!r},forEach:function(t){p(this,e);for(var i,r=n(t,arguments.length>1?arguments[1]:void 0,3);i=i?i.n:this._f;)for(r(i.v,i.k,this);i&&i.r;)i=i.p},has:function(t){return!!g(p(this,e),t)}}),l&&r(u.prototype,"size",{get:function(){return p(this,e)[m]}}),u},def:function(t,e,i){var r,s,a=g(t,e);return a?a.v=i:(t._l=a={i:s=f(e,!0),k:e,v:i,p:r=t._l,n:void 0,r:!1},t._f||(t._f=a),r&&(r.n=a),t[m]++,"F"!==s&&(t._i[s]=a)),t},getEntry:g,setStrong:function(t,e,i){c(t,e,(function(t,i){this._t=p(t,e),this._k=i,this._l=void 0}),(function(){for(var t=this,e=t._k,i=t._l;i&&i.r;)i=i.p;return t._t&&(t._l=i=i?i.n:t._t._f)?u(0,"keys"==e?i.k:"values"==e?i.v:[i.k,i.v]):(t._t=void 0,u(1))}),i?"entries":"values",!i,!0),d(e)}}},5874:(t,e,i)=>{var r=i(4968),s=i(7076);t.exports=function(t){return function(){if(r(this)!=t)throw TypeError(t+"#toJSON isn't generic");return s(this)}}},9373:(t,e,i)=>{"use strict";var r=i(6670),s=i(8535),a=i(5172),n=i(1984),o=i(2677),h=i(953),c=i(5838),u=i(2832),d=i(4401),l=i(1356),f=i(8423).f,p=i(600)(0),m=i(8219);t.exports=function(t,e,i,g,v,A){var y=r[t],w=y,b=v?"set":"add",k=w&&w.prototype,x={};return m&&"function"==typeof w&&(A||k.forEach&&!n((function(){(new w).entries().next()})))?(w=e((function(e,i){u(e,w,t,"_c"),e._c=new y,null!=i&&c(i,v,e[b],e)})),p("add,clear,delete,forEach,get,has,set,keys,values,entries,toJSON".split(","),(function(t){var e="add"==t||"set"==t;!(t in k)||A&&"clear"==t||o(w.prototype,t,(function(i,r){if(u(this,w,t),!e&&A&&!d(i))return"get"==t&&void 0;var s=this._c[t](0===i?0:i,r);return e?this:s}))})),A||f(w.prototype,"size",{get:function(){return this._c.size}})):(w=g.getConstructor(e,t,v,b),h(w.prototype,i),a.NEED=!0),l(w,t),x[t]=w,s(s.G+s.W+s.F,x),A||g.setStrong(w,t,v),w}},6438:t=>{var e=t.exports={version:"2.6.12"};"number"==typeof __e&&(__e=e)},8852:(t,e,i)=>{var r=i(5219);t.exports=function(t,e,i){if(r(t),void 0===e)return t;switch(i){case 1:return function(i){return t.call(e,i)};case 2:return function(i,r){return t.call(e,i,r)};case 3:return function(i,r,s){return t.call(e,i,r,s)}}return function(){return t.apply(e,arguments)}}},7608:t=>{t.exports=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t}},8219:(t,e,i)=>{t.exports=!i(1984)((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))},3802:(t,e,i)=>{var r=i(4401),s=i(6670).document,a=r(s)&&r(s.createElement);t.exports=function(t){return a?s.createElement(t):{}}},7956:t=>{t.exports="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(",")},6473:(t,e,i)=>{var r=i(4311),s=i(9820),a=i(6569);t.exports=function(t){var e=r(t),i=s.f;if(i)for(var n,o=i(t),h=a.f,c=0;o.length>c;)h.call(t,n=o[c++])&&e.push(n);return e}},8535:(t,e,i)=>{var r=i(6670),s=i(6438),a=i(8852),n=i(2677),o=i(5509),h="prototype",c=function(t,e,i){var u,d,l,f=t&c.F,p=t&c.G,m=t&c.S,g=t&c.P,v=t&c.B,A=t&c.W,y=p?s:s[e]||(s[e]={}),w=y[h],b=p?r:m?r[e]:(r[e]||{})[h];for(u in p&&(i=e),i)(d=!f&&b&&void 0!==b[u])&&o(y,u)||(l=d?b[u]:i[u],y[u]=p&&"function"!=typeof b[u]?i[u]:v&&d?a(l,r):A&&b[u]==l?function(t){var e=function(e,i,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,i)}return new t(e,i,r)}return t.apply(this,arguments)};return e[h]=t[h],e}(l):g&&"function"==typeof l?a(Function.call,l):l,g&&((y.virtual||(y.virtual={}))[u]=l,t&c.R&&w&&!w[u]&&n(w,u,l)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,t.exports=c},1984:t=>{t.exports=function(t){try{return!!t()}catch(t){return!0}}},5838:(t,e,i)=>{var r=i(8852),s=i(7904),a=i(2828),n=i(812),o=i(181),h=i(5298),c={},u={},d=t.exports=function(t,e,i,d,l){var f,p,m,g,v=l?function(){return t}:h(t),A=r(i,d,e?2:1),y=0;if("function"!=typeof v)throw TypeError(t+" is not iterable!");if(a(v)){for(f=o(t.length);f>y;y++)if((g=e?A(n(p=t[y])[0],p[1]):A(t[y]))===c||g===u)return g}else for(m=v.call(t);!(p=m.next()).done;)if((g=s(m,A,p.value,e))===c||g===u)return g};d.BREAK=c,d.RETURN=u},6670:t=>{var e=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=e)},5509:t=>{var e={}.hasOwnProperty;t.exports=function(t,i){return e.call(t,i)}},2677:(t,e,i)=>{var r=i(8423),s=i(6260);t.exports=i(8219)?function(t,e,i){return r.f(t,e,s(1,i))}:function(t,e,i){return t[e]=i,t}},3879:(t,e,i)=>{var r=i(6670).document;t.exports=r&&r.documentElement},2484:(t,e,i)=>{t.exports=!i(8219)&&!i(1984)((function(){return 7!=Object.defineProperty(i(3802)("div"),"a",{get:function(){return 7}}).a}))},709:t=>{t.exports=function(t,e,i){var r=void 0===i;switch(e.length){case 0:return r?t():t.call(i);case 1:return r?t(e[0]):t.call(i,e[0]);case 2:return r?t(e[0],e[1]):t.call(i,e[0],e[1]);case 3:return r?t(e[0],e[1],e[2]):t.call(i,e[0],e[1],e[2]);case 4:return r?t(e[0],e[1],e[2],e[3]):t.call(i,e[0],e[1],e[2],e[3])}return t.apply(i,e)}},7001:(t,e,i)=>{var r=i(3417);t.exports=Object("z").propertyIsEnumerable(0)?Object:function(t){return"String"==r(t)?t.split(""):Object(t)}},2828:(t,e,i)=>{var r=i(210),s=i(254)("iterator"),a=Array.prototype;t.exports=function(t){return void 0!==t&&(r.Array===t||a[s]===t)}},5461:(t,e,i)=>{var r=i(3417);t.exports=Array.isArray||function(t){return"Array"==r(t)}},4401:t=>{t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},7904:(t,e,i)=>{var r=i(812);t.exports=function(t,e,i,s){try{return s?e(r(i)[0],i[1]):e(i)}catch(e){var a=t.return;throw void 0!==a&&r(a.call(t)),e}}},8248:(t,e,i)=>{"use strict";var r=i(2087),s=i(6260),a=i(1356),n={};i(2677)(n,i(254)("iterator"),(function(){return this})),t.exports=function(t,e,i){t.prototype=r(n,{next:s(1,i)}),a(t,e+" Iterator")}},8839:(t,e,i)=>{"use strict";var r=i(4742),s=i(8535),a=i(1331),n=i(2677),o=i(210),h=i(8248),c=i(1356),u=i(6123),d=i(254)("iterator"),l=!([].keys&&"next"in[].keys()),f="keys",p="values",m=function(){return this};t.exports=function(t,e,i,g,v,A,y){h(i,e,g);var w,b,k,x=function(t){if(!l&&t in I)return I[t];switch(t){case f:case p:return function(){return new i(this,t)}}return function(){return new i(this,t)}},_=e+" Iterator",P=v==p,T=!1,I=t.prototype,C=I[d]||I["@@iterator"]||v&&I[v],B=C||x(v),S=v?P?x("entries"):B:void 0,M="Array"==e&&I.entries||C;if(M&&(k=u(M.call(new t)))!==Object.prototype&&k.next&&(c(k,_,!0),r||"function"==typeof k[d]||n(k,d,m)),P&&C&&C.name!==p&&(T=!0,B=function(){return C.call(this)}),r&&!y||!l&&!T&&I[d]||n(I,d,B),o[e]=B,o[_]=m,v)if(w={values:P?B:x(p),keys:A?B:x(f),entries:S},y)for(b in w)b in I||a(I,b,w[b]);else s(s.P+s.F*(l||T),e,w);return w}},7899:(t,e,i)=>{var r=i(254)("iterator"),s=!1;try{var a=[7][r]();a.return=function(){s=!0},Array.from(a,(function(){throw 2}))}catch(t){}t.exports=function(t,e){if(!e&&!s)return!1;var i=!1;try{var a=[7],n=a[r]();n.next=function(){return{done:i=!0}},a[r]=function(){return n},t(a)}catch(t){}return i}},322:t=>{t.exports=function(t,e){return{value:e,done:!!t}}},210:t=>{t.exports={}},4742:t=>{t.exports=!0},5172:(t,e,i)=>{var r=i(9191)("meta"),s=i(4401),a=i(5509),n=i(8423).f,o=0,h=Object.isExtensible||function(){return!0},c=!i(1984)((function(){return h(Object.preventExtensions({}))})),u=function(t){n(t,r,{value:{i:"O"+ ++o,w:{}}})},d=t.exports={KEY:r,NEED:!1,fastKey:function(t,e){if(!s(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!a(t,r)){if(!h(t))return"F";if(!e)return"E";u(t)}return t[r].i},getWeak:function(t,e){if(!a(t,r)){if(!h(t))return!0;if(!e)return!1;u(t)}return t[r].w},onFreeze:function(t){return c&&d.NEED&&h(t)&&!a(t,r)&&u(t),t}}},3792:(t,e,i)=>{var r=i(6670),s=i(8036).set,a=r.MutationObserver||r.WebKitMutationObserver,n=r.process,o=r.Promise,h="process"==i(3417)(n);t.exports=function(){var t,e,i,c=function(){var r,s;for(h&&(r=n.domain)&&r.exit();t;){s=t.fn,t=t.next;try{s()}catch(r){throw t?i():e=void 0,r}}e=void 0,r&&r.enter()};if(h)i=function(){n.nextTick(c)};else if(!a||r.navigator&&r.navigator.standalone)if(o&&o.resolve){var u=o.resolve(void 0);i=function(){u.then(c)}}else i=function(){s.call(r,c)};else{var d=!0,l=document.createTextNode("");new a(c).observe(l,{characterData:!0}),i=function(){l.data=d=!d}}return function(r){var s={fn:r,next:void 0};e&&(e.next=s),t||(t=s,i()),e=s}}},1642:(t,e,i)=>{"use strict";var r=i(5219);function s(t){var e,i;this.promise=new t((function(t,r){if(void 0!==e||void 0!==i)throw TypeError("Bad Promise constructor");e=t,i=r})),this.resolve=r(e),this.reject=r(i)}t.exports.f=function(t){return new s(t)}},2087:(t,e,i)=>{var r=i(812),s=i(82),a=i(7956),n=i(4566)("IE_PROTO"),o=function(){},h="prototype",c=function(){var t,e=i(3802)("iframe"),r=a.length;for(e.style.display="none",i(3879).appendChild(e),e.src="javascript:",(t=e.contentWindow.document).open(),t.write("