fix(build): update cpy options to use flat for output directory

This commit is contained in:
Harvey Zhao committed 2026-03-07 15:32:38 +08:00
1 parent 699bf09577
commit 3bf0707faa
95 files changed
+29 -90819

No files matched your search

@@ -4,218 +4,4 @@
* (c) 2017-2026 Harvey Zhao
* Released under the MIT License.
*/
!function(e,t){"object"===typeof exports&&"undefined"!==typeof module?module.exports=t():"function"==typeof define&&define.amd?(t.ArtplayerProxyMediabunny=t(),define(function(){return t.ArtplayerProxyMediabunny})):(e="undefined"!==typeof globalThis?globalThis:e||self).ArtplayerProxyMediabunny=t()}(this,function(){"use strict";var e=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,a=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),o=Math.pow,l=(t,r,i)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[r]=i,c=(e,t)=>{for(var r in t||(t={}))n.call(t,r)&&l(e,r,t[r]);if(i)for(var r of i(t))s.call(t,r)&&l(e,r,t[r]);return e},u=(e,t,r)=>new Promise((i,n)=>{var s=e=>{try{o(r.next(e))}catch(t){n(t)}},a=e=>{try{o(r.throw(e))}catch(t){n(t)}},o=e=>e.done?i(e.value):Promise.resolve(e.value).then(s,a);o((r=r.apply(e,t)).next())}),d=function(e,t){this[0]=e,this[1]=t},h=e=>{var t,r=e[a("asyncIterator")],i=!1,n={};return null==r?(r=e[a("iterator")](),t=e=>n[e]=t=>r[e](t)):(r=r.call(e),t=e=>n[e]=t=>{if(i){if(i=!1,"throw"===e)throw t;return t}return i=!0,{done:!1,value:new d(new Promise(i=>{var n=r[e](t);n instanceof Object||(e=>{throw TypeError(e)})("Object expected"),i(n)}),1)}}),n[a("iterator")]=()=>n,t("next"),"throw"in r?t("throw"):n.throw=e=>{throw e},"return"in r&&t("return"),n},m=(e,t,r)=>(t=e[a("asyncIterator")])?t.call(e):(e=e[a("iterator")](),t={},(r=(r,i)=>(i=e[r])&&(t[r]=t=>new Promise((r,n,s)=>(t=i.call(e,t),s=t.done,Promise.resolve(t.value).then(e=>r({value:e,done:s}),n)))))("next"),r("return"),t);class f{constructor(){this.listeners=new Map}addEventListener(e,t){this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t)}removeEventListener(e,t){const r=this.listeners.get(e);if(!r)return;const i=r.indexOf(t);i>=0&&r.splice(i,1)}emit(e,t){const r=new Event(e);r.detail=t;const i=this.listeners.get(e);i&&i.forEach(e=>e(r))}}
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/function p(e){if(!e)throw new Error("Assertion failed.")}const g=e=>{const t=(e%360+360)%360;if(0===t||90===t||180===t||270===t)return t;throw new Error(`Invalid rotation ${e}.`)},k=e=>e&&e[e.length-1];class b{constructor(e){this.bytes=e,this.pos=0}seekToByte(e){this.pos=8*e}readBit(){var e;const t=Math.floor(this.pos/8),r=null!=(e=this.bytes[t])?e:0,i=7-(7&this.pos),n=(r&1<<i)>>i;return this.pos++,n}readBits(e){if(1===e)return this.readBit();let t=0;for(let r=0;r<e;r++)t<<=1,t|=this.readBit();return t}writeBits(e,t){const r=this.pos+e;for(let i=this.pos;i<r;i++){const e=Math.floor(i/8);let n=this.bytes[e];const s=7-(7&i);n&=~(1<<s),n|=(t&1<<r-i-1)>>r-i-1<<s,this.bytes[e]=n}this.pos=r}readAlignedByte(){var e;if(this.pos%8!==0)throw new Error("Bitstream is not byte-aligned.");const t=this.pos/8,r=null!=(e=this.bytes[t])?e:0;return this.pos+=8,r}skipBits(e){this.pos+=e}getBitsLeft(){return 8*this.bytes.length-this.pos}clone(){const e=new b(this.bytes);return e.pos=this.pos,e}}const y=e=>{let t=0;for(;0===e.readBits(1)&&t<32;)t++;if(t>=32)throw new Error("Invalid exponential-Golomb code.");return(1<<t)-1+e.readBits(t)},T=e=>{const t=y(e);return 0===(1&t)?-(t>>1):t+1>>1},S=e=>e.constructor===Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),v=e=>e.constructor===DataView?e:ArrayBuffer.isView(e)?new DataView(e.buffer,e.byteOffset,e.byteLength):new DataView(e),w=new TextDecoder,I=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e])),P={bt709:1,bt470bg:5,smpte170m:6,bt2020:9,smpte432:12},x=I(P),C={bt709:1,smpte170m:6,linear:8,"iec61966-2-1":13,pq:16,hlg:18},_=I(C),B={rgb:0,bt709:1,bt470bg:5,smpte170m:6,"bt2020-ncl":9},E=I(B),F=e=>e instanceof ArrayBuffer||"undefined"!==typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer||ArrayBuffer.isView(e);class D{constructor(){this.currentPromise=Promise.resolve()}acquire(){return u(this,null,function*(){let e;const t=new Promise(t=>{e=t}),r=this.currentPromise;return this.currentPromise=t,yield r,e})}}const A=e=>[...e].map(e=>e.toString(16).padStart(2,"0")).join(""),R=e=>(e=(e=(e=(e=(e=e>>1&1431655765|(1431655765&e)<<1)>>2&858993459|(858993459&e)<<2)>>4&252645135|(252645135&e)<<4)>>8&16711935|(16711935&e)<<8)>>16&65535|(65535&e)<<16)>>>0,M=(e,t,r)=>{let i=0,n=e.length-1,s=-1;for(;i<=n;){const a=i+n>>1,o=r(e[a]);o===t?(s=a,n=a-1):o<t?i=a+1:n=a-1}return s},N=(e,t,r)=>{let i=0,n=e.length-1,s=-1;for(;i<=n;){const a=i+(n-i+1)/2|0;r(e[a])<=t?(s=a,i=a+1):n=a-1}return s},z=(e,t,r)=>{const i=N(e,r(t),r);e.splice(i+1,0,t)},O=()=>{let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}},L=(e,t)=>{for(let r=e.length-1;r>=0;r--)if(t(e[r]))return e[r]},U=(e,t)=>{for(let r=e.length-1;r>=0;r--)if(t(e[r]))return r;return-1},V=function(e){return((e,t,r)=>{var i=(e,t,n,s)=>{try{var a=r[e](t),o=(t=a.value)instanceof d,l=a.done;Promise.resolve(o?t[0]:t).then(r=>o?i("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,s):n({value:r,done:l})).catch(e=>i("throw",e,n,s))}catch(c){s(c)}},n=e=>s[e]=t=>new Promise((r,n)=>i(e,t,r,n)),s={};return r=r.apply(e,t),s[a("asyncIterator")]=()=>s,n("next"),n("throw"),n("return"),s})(this,null,function*(){Symbol.iterator in e?yield*h(e[Symbol.iterator]()):yield*h(e[Symbol.asyncIterator]())})},q=e=>{throw new Error(`Unexpected value: ${e}`)},H=(e,t,r)=>{const i=e.getUint8(t),n=e.getUint8(t+1),s=e.getUint8(t+2);return r?i|n<<8|s<<16:i<<16|n<<8|s},W=(e,t,r,i)=>{r>>>=0,r&=16777215,e.setUint8(t,r>>>16&255),e.setUint8(t+1,r>>>8&255),e.setUint8(t+2,255&r)},j=(e,t)=>({next(){return u(this,null,function*(){const r=yield e.next();return r.done?{value:void 0,done:!0}:{value:t(r.value),done:!1}})},return:()=>e.return(),throw:t=>e.throw(t),[Symbol.asyncIterator](){return this}}),K=(e,t,r)=>Math.max(t,Math.min(r,e)),$="und",Q=e=>{const t=Math.round(e);return Math.abs(e/t-1)<10*Number.EPSILON?t:e},G=/^[a-z]{3}$/,X=e=>G.test(e),Y=1e6*(1+Number.EPSILON),J=(e,t)=>{const r=c(c({},e),t);if(e.headers||t.headers){const i=e.headers?Z(e.headers):{},n=t.headers?Z(t.headers):{},s=c({},i);Object.entries(n).forEach(([e,t])=>{const r=Object.keys(s).find(t=>t.toLowerCase()===e.toLowerCase());r&&delete s[r],s[e]=t}),r.headers=s}return r},Z=e=>{if(e instanceof Headers){const t={};return e.forEach((e,r)=>{t[r]=e}),t}if(Array.isArray(e)){const t={};return e.forEach(([e,r])=>{t[e]=r}),t}return e},ee=(e,t,r,i,n)=>u(null,null,function*(){let s=0;for(;;)try{return yield e(t,r)}catch(a){if(n())throw a;s++;const e=i(s,a,t);if(null===e)throw a;if(console.error("Retrying failed fetch. Error:",a),!Number.isFinite(e)||e<0)throw new TypeError("Retry delay must be a non-negative finite number.");if(e>0&&(yield new Promise(t=>setTimeout(t,1e3*e))),n())throw a}});class te{constructor(){this.currentPromise=Promise.resolve()}call(e){return this.currentPromise=this.currentPromise.then(e)}}let re=null;const ie=()=>{var e;return null!==re?re:re=!("undefined"===typeof navigator||!((null==(e=navigator.vendor)?void 0:e.match(/Line truncated
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
class fe{constructor(e,t){if(this.data=e,this.mimeType=t,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if("string"!==typeof t)throw new TypeError("mimeType must be a string.")}}class pe{constructor(e,t,r,i){if(this.data=e,this.mimeType=t,this.name=r,this.description=i,!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if(void 0!==t&&"string"!==typeof t)throw new TypeError("mimeType, when provided, must be a string.");if(void 0!==r&&"string"!==typeof r)throw new TypeError("name, when provided, must be a string.");if(void 0!==i&&"string"!==typeof i)throw new TypeError("description, when provided, must be a string.")}}const ge={default:!0,forced:!1,original:!1,commentary:!1,hearingImpaired:!1,visuallyImpaired:!1},ke=["pcm-s16","pcm-s16be","pcm-s24","pcm-s24be","pcm-s32","pcm-s32be","pcm-f32","pcm-f32be","pcm-f64","pcm-f64be","pcm-u8","pcm-s8","ulaw","alaw"],be=[{maxPictureSize:36864,maxBitrate:2e5,level:10},{maxPictureSize:73728,maxBitrate:8e5,level:11},{maxPictureSize:122880,maxBitrate:18e5,level:20},{maxPictureSize:245760,maxBitrate:36e5,level:21},{maxPictureSize:552960,maxBitrate:72e5,level:30},{maxPictureSize:983040,maxBitrate:12e6,level:31},{maxPictureSize:2228224,maxBitrate:18e6,level:40},{maxPictureSize:2228224,maxBitrate:3e7,level:41},{maxPictureSize:8912896,maxBitrate:6e7,level:50},{maxPictureSize:8912896,maxBitrate:12e7,level:51},{maxPictureSize:8912896,maxBitrate:18e7,level:52},{maxPictureSize:35651584,maxBitrate:18e7,level:60},{maxPictureSize:35651584,maxBitrate:24e7,level:61},{maxPictureSize:35651584,maxBitrate:48e7,level:62}],ye=".01.01.01.01.00",Te=".0.110.01.01.01.0",Se=e=>{const{codec:t,codecDescription:r,colorSpace:i,avcCodecInfo:n,hevcCodecInfo:s,vp9CodecInfo:a,av1CodecInfo:o}=e;if("avc"===t){if(p(null!==e.avcType),n){const t=new Uint8Array([n.avcProfileIndication,n.profileCompatibility,n.avcLevelIndication]);return`avc${e.avcType}.${A(t)}`}if(!r||r.byteLength<4)throw new TypeError("AVC decoder description is not provided or is not at least 4 bytes long.");return`avc${e.avcType}.${A(r.subarray(1,4))}`}if("hevc"===t){let e,t,i,n,a,o;if(s)e=s.generalProfileSpace,t=s.generalProfileIdc,i=R(s.generalProfileCompatibilityFlags),n=s.generalTierFlag,a=s.generalLevelIdc,o=[...s.generalConstraintIndicatorFlags];else{if(!r||r.byteLength<23)throw new TypeError("HEVC decoder description is not provided or is not at least 23 bytes long.");const s=v(r),l=s.getUint8(1);e=l>>6&3,t=31&l,i=R(s.getUint32(2)),n=l>>5&1,a=s.getUint8(12),o=[];for(let e=0;e<6;e++)o.push(s.getUint8(6+e))}let l="hev1.";for(l+=["","A","B","C"][e]+t,l+=".",l+=i.toString(16).toUpperCase(),l+=".",l+=0===n?"L":"H",l+=a;o.length>0&&0===o[o.length-1];)o.pop();return o.length>0&&(l+=".",l+=o.map(e=>e.toString(16).toUpperCase()).join(".")),l}if("vp8"===t)return"vp8";if("vp9"===t){if(!a){const t=e.width*e.height;let r=k(be).level;for(const e of be)if(t<=e.maxPictureSize){r=e.level;break}return`vp09.00.${r.toString().padStart(2,"0")}.08`}let t=`vp09.${a.profile.toString().padStart(2,"0")}.${a.level.toString().padStart(2,"0")}.${a.bitDepth.toString().padStart(2,"0")}.${a.chromaSubsampling.toString().padStart(2,"0")}`;return t+=`.${a.colourPrimaries.toString().padStart(2,"0")}.${a.transferCharacteristics.toString().padStart(2,"0")}.${a.matrixCoefficients.toString().padStart(2,"0")}.${a.videoFullRangeFlag.toString().padStart(2,"0")}`,t.endsWith(ye)&&(t=t.slice(0,-15)),t}if("av1"===t){if(!o){const t=e.width*e.height;let r=k(be).level;for(const e of be)if(t<=e.maxPictureSize){r=e.level;break}return`av01.0.${r.toString().padStart(2,"0")}M.08`}const t=o.profile,r=o.level.toString().padStart(2,"0"),n=o.tier?"H":"M",s=o.bitDepth.toString().padStart(2,"0"),a=o.monochrome?"1":"0",l=100*o.chromaSubsamplingX+10*o.chromaSubsamplingY+1*(o.chromaSubsamplingX&&o.chromaSubsamplingY?o.chromaSamplePosition:0),c=(null==i?void 0:i.primaries)?P[i.primaries]:1,u=(null==i?void 0:i.transfer)?C[i.transfer]:1,d=(null==i?void 0:i.matrix)?B[i.matrix]:1,h=(null==i?void 0:i.fullRange)?1:0;let m=`av01.${t}.${r}${n}.${s}`;return m+=`.${a}.${l.toString().padStart(3,"0")}`,m+=`.${c.toString().padStart(2,"0")}`,m+=`.${u.toString().padStart(2,"0")}`,m+=`.${d.toString().padStart(2,"0")}`,m+=`.${h}`,m.endsWith(Te)&&(m=m.slice(0,-17)),m}throw new TypeError(`Unhandled codec '${t}'.`)},ve=e=>{const{codec:t,codecDescription:r,aacCodecInfo:i}=e;if("aac"===t){if(!i)throw new TypeError("AAC codec info must be provided.");if(i.isMpeg2)return"mp4a.67";return`mp4a.40.${Pe(r).objectType}`}if("mp3"===t)return"mp3";if("opus"===t)return"opus";if("vorbis"===t)return"vorbis";if("flac"===t)return"flac";if(t&&ke.includes(t))return t;throw new TypeError(`Unhandled codec '${t}'.`)},we=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],Ie=[-1,1,2,3,4,5,6,8],Pe=e=>{if(!e||e.byteLength<2)throw new TypeError("AAC description must be at least 2 bytes long.");const t=new b(e);let r=t.readBits(5);31===r&&(r=32+t.readBits(6));const i=t.rLine truncated
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
var Be,Ee,Fe,De;(Ee=Be||(Be={}))[Ee.IDR=5]="IDR",Ee[Ee.SEI=6]="SEI",Ee[Ee.SPS=7]="SPS",Ee[Ee.PPS=8]="PPS",Ee[Ee.SPS_EXT=13]="SPS_EXT",(De=Fe||(Fe={}))[De.RASL_N=8]="RASL_N",De[De.RASL_R=9]="RASL_R",De[De.BLA_W_LP=16]="BLA_W_LP",De[De.RSV_IRAP_VCL23=23]="RSV_IRAP_VCL23",De[De.VPS_NUT=32]="VPS_NUT",De[De.SPS_NUT=33]="SPS_NUT",De[De.PPS_NUT=34]="PPS_NUT",De[De.PREFIX_SEI_NUT=39]="PREFIX_SEI_NUT",De[De.SUFFIX_SEI_NUT=40]="SUFFIX_SEI_NUT";const Ae=e=>{const t=[];let r=0;for(;r<e.length;){let i=-1,n=0;for(let t=r;t<e.length-3;t++){if(0===e[t]&&0===e[t+1]&&1===e[t+2]){i=t,n=3;break}if(t<e.length-4&&0===e[t]&&0===e[t+1]&&0===e[t+2]&&1===e[t+3]){i=t,n=4;break}}if(-1===i)break;if(r>0&&i>r){const n=e.subarray(r,i);n.length>0&&t.push(n)}r=i+n}if(r<e.length){const i=e.subarray(r);i.length>0&&t.push(i)}return t},Re=(e,t)=>{const r=[];let i=0;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);for(;i+t<=e.length;){let s;1===t?s=n.getUint8(i):2===t?s=n.getUint16(i,!1):3===t?s=H(n,i,!1):4===t?s=n.getUint32(i,!1):(q(t),p(!1)),i+=t;const a=e.subarray(i,i+s);r.push(a),i+=s}return r},Me=e=>{const t=[],r=e.length;for(let i=0;i<r;i++)i+2<r&&0===e[i]&&0===e[i+1]&&3===e[i+2]?(t.push(0,0),i+=2):t.push(e[i]);return new Uint8Array(t)},Ne=new Uint8Array([0,0,0,1]),ze=(e,t)=>{if(t.description){const r=3&S(t.description)[4];return Re(e,r+1)}return Ae(e)},Oe=(e,t)=>{if(t.description){return((e,t)=>{const r=e.reduce((e,r)=>e+t+r.byteLength,0),i=new Uint8Array(r);let n=0;for(const s of e){const e=new DataView(i.buffer,i.byteOffset,i.byteLength);switch(t){case 1:e.setUint8(n,s.byteLength);break;case 2:e.setUint16(n,s.byteLength,!1);break;case 3:W(e,n,s.byteLength);break;case 4:e.setUint32(n,s.byteLength,!1)}n+=t,i.set(s,n),n+=s.byteLength}return i})(e,(3&S(t.description)[4])+1)}return(e=>{const t=e.reduce((e,t)=>e+Ne.byteLength+t.byteLength,0),r=new Uint8Array(t);let i=0;for(const n of e)r.set(Ne,i),i+=Ne.byteLength,r.set(n,i),i+=n.byteLength;return r})(e)},Le=e=>31&e[0],Ue=e=>{try{const t=Ae(e),r=t.filter(e=>Le(e)===Be.SPS),i=t.filter(e=>Le(e)===Be.PPS),n=t.filter(e=>Le(e)===Be.SPS_EXT);if(0===r.length)return null;if(0===i.length)return null;const s=r[0],a=Ve(s);p(null!==a);const o=100===a.profileIdc||110===a.profileIdc||122===a.profileIdc||144===a.profileIdc;return{configurationVersion:1,avcProfileIndication:a.profileIdc,profileCompatibility:a.constraintFlags,avcLevelIndication:a.levelIdc,lengthSizeMinusOne:3,sequenceParameterSets:r,pictureParameterSets:i,chromaFormat:o?a.chromaFormatIdc:null,bitDepthLumaMinus8:o?a.bitDepthLumaMinus8:null,bitDepthChromaMinus8:o?a.bitDepthChromaMinus8:null,sequenceParameterSetExt:o?n:null}}catch(t){return console.error("Error building AVC Decoder Configuration Record:",t),null}},Ve=e=>{try{const t=new b(Me(e));t.skipBits(1),t.skipBits(2);if(7!==t.readBits(5))return null;const r=t.readAlignedByte(),i=t.readAlignedByte(),n=t.readAlignedByte();y(t);let s=null,a=null,o=null;if(100===r||110===r||122===r||244===r||44===r||83===r||86===r||118===r||128===r){s=y(t),3===s&&t.skipBits(1),a=y(t),o=y(t),t.skipBits(1);if(t.readBits(1))for(let e=0;e<(3!==s?8:12);e++){if(t.readBits(1)){const r=e<6?16:64;let i=8,n=8;for(let e=0;e<r;e++){if(0!==n){n=(i+T(t)+256)%256}i=0===n?i:n}}}}y(t);const l=y(t);if(0===l)y(t);else if(1===l){t.skipBits(1),T(t),T(t);const e=y(t);for(let r=0;r<e;r++)T(t)}y(t),t.skipBits(1),y(t),y(t);return{profileIdc:r,constraintFlags:i,levelIdc:n,frameMbsOnlyFlag:t.readBits(1),chromaFormatIdc:s,bitDepthLumaMinus8:a,bitDepthChromaMinus8:o}}catch(t){return console.error("Error parsing AVC SPS:",t),null}},qe=(e,t)=>{if(t.description){const r=3&S(t.description)[21];return Re(e,r+1)}return Ae(e)},He=e=>e[0]>>1&63,We=e=>{try{const t=Ae(e),r=t.filter(e=>He(e)===Fe.VPS_NUT),i=t.filter(e=>He(e)===Fe.SPS_NUT),n=t.filter(e=>He(e)===Fe.PPS_NUT),s=t.filter(e=>He(e)===Fe.PREFIX_SEI_NUT||He(e)===Fe.SUFFIX_SEI_NUT);if(0===i.length||0===n.length)return null;const a=i[0],o=new b(Me(a));o.skipBits(16),o.readBits(4);const l=o.readBits(3),c=o.readBits(1),{general_profile_space:u,general_tier_flag:d,general_profile_idc:h,general_profile_compatibility_flags:m,general_constraint_indicator_flags:f,general_level_idc:p}=je(o,l);y(o);const g=y(o);3===g&&o.skipBits(1),y(o),y(o),o.readBits(1)&&(y(o),y(o),y(o),y(o));const k=y(o),S=y(o);y(o);const v=o.readBits(1);for(let e=v?0:l;e<=l;e++)y(o),y(o),y(o);y(o),y(o),y(o),y(o),y(o),y(o),o.readBits(1)&&o.readBits(1)&&Ke(o),o.skipBits(1),o.skipBits(1),o.readBits(1)&&(o.skipBits(4),o.skipBits(4),y(o),y(o),o.skipBits(1));const w=y(o);if($e(o,w),o.readBits(1)){const e=y(o);for(let t=0;t<e;t++)y(o),o.skipBits(1)}o.skipBits(1),o.skipBits(1);let I=0;o.readBits(1)&&(I=Ge(o,l));let P=0;if(n.length>0){const e=n[0],t=new b(Me(e));t.skipBits(16),y(t),y(t),t.skipBits(1),t.skipBits(1),t.skipBits(3),t.skipBits(1),t.skipBits(1),y(t),y(t),T(t),t.skipBits(1),t.skipBits(1),t.readBits(1)&&y(t),T(t),T(t),t.skipBits(1),t.skipBits(1),t.skipBits(1),t.skipBits(1);const r=t.readBits(1),i=t.readBits(1);P=r||i?r&&!iLine truncated
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/class ot{constructor(e){this.input=e}}
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/const lt=[],ct=[],ut=new Uint8Array(0);class dt{constructor(e,t,r,i,n=-1,s,a){if(this.data=e,this.type=t,this.timestamp=r,this.duration=i,this.sequenceNumber=n,e===ut&&void 0===s)throw new Error("Internal error: byteLength must be explicitly provided when constructing metadata-only packets.");if(void 0===s&&(s=e.byteLength),!(e instanceof Uint8Array))throw new TypeError("data must be a Uint8Array.");if("key"!==t&&"delta"!==t)throw new TypeError('type must be either "key" or "delta".');if(!Number.isFinite(r))throw new TypeError("timestamp must be a number.");if(!Number.isFinite(i)||i<0)throw new TypeError("duration must be a non-negative number.");if(!Number.isFinite(n))throw new TypeError("sequenceNumber must be a number.");if(!Number.isInteger(s)||s<0)throw new TypeError("byteLength must be a non-negative integer.");if(void 0!==a&&("object"!==typeof a||!a))throw new TypeError("sideData, when provided, must be an object.");if(void 0!==(null==a?void 0:a.alpha)&&!(a.alpha instanceof Uint8Array))throw new TypeError("sideData.alpha, when provided, must be a Uint8Array.");if(void 0!==(null==a?void 0:a.alphaByteLength)&&(!Number.isInteger(a.alphaByteLength)||a.alphaByteLength<0))throw new TypeError("sideData.alphaByteLength, when provided, must be a non-negative integer.");this.byteLength=s,this.sideData=null!=a?a:{},this.sideData.alpha&&void 0===this.sideData.alphaByteLength&&(this.sideData.alphaByteLength=this.sideData.alpha.byteLength)}get isMetadataOnly(){return this.data===ut}get microsecondTimestamp(){return Math.trunc(Y*this.timestamp)}get microsecondDuration(){return Math.trunc(Y*this.duration)}toEncodedVideoChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if("undefined"===typeof EncodedVideoChunk)throw new Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}alphaToEncodedVideoChunk(e=this.type){if(!this.sideData.alpha)throw new TypeError("This packet does not contain alpha side data.");if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to a video chunk.");if("undefined"===typeof EncodedVideoChunk)throw new Error("Your browser does not support EncodedVideoChunk.");return new EncodedVideoChunk({data:this.sideData.alpha,type:e,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}toEncodedAudioChunk(){if(this.isMetadataOnly)throw new TypeError("Metadata-only packets cannot be converted to an audio chunk.");if("undefined"===typeof EncodedAudioChunk)throw new Error("Your browser does not support EncodedAudioChunk.");return new EncodedAudioChunk({data:this.data,type:this.type,timestamp:this.microsecondTimestamp,duration:this.microsecondDuration})}static fromEncodedChunk(e,t){var r;if(!(e instanceof EncodedVideoChunk||e instanceof EncodedAudioChunk))throw new TypeError("chunk must be an EncodedVideoChunk or EncodedAudioChunk.");const i=new Uint8Array(e.byteLength);return e.copyTo(i),new dt(i,e.type,e.timestamp/1e6,(null!=(r=e.duration)?r:0)/1e6,void 0,void 0,t)}clone(e){var t,r;if(void 0!==e&&("object"!==typeof e||null===e))throw new TypeError("options, when provided, must be an object.");if(void 0!==(null==e?void 0:e.timestamp)&&!Number.isFinite(e.timestamp))throw new TypeError("options.timestamp, when provided, must be a number.");if(void 0!==(null==e?void 0:e.duration)&&!Number.isFinite(e.duration))throw new TypeError("options.duration, when provided, must be a number.");return new dt(this.data,this.type,null!=(t=null==e?void 0:e.timestamp)?t:this.timestamp,null!=(r=null==e?void 0:e.duration)?r:this.duration,this.sequenceNumber,this.byteLength)}}
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
he();let ht=-1/0,mt=-1/0,ft=null;"undefined"!==typeof FinalizationRegistry&&(ft=new FinalizationRegistry(e=>{const t=Date.now();"video"===e.type?(t-ht>=1e3&&(console.error("A VideoSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your VideoSamples as soon as you're done using them."),ht=t),"undefined"!==typeof VideoFrame&&e.data instanceof VideoFrame&&e.data.close()):(t-mt>=1e3&&(console.error("An AudioSample was garbage collected without first being closed. For proper resource management, make sure to call close() on all your AudioSamples as soon as you're done using them."),mt=t),"undefined"!==typeof AudioData&&e.data instanceof AudioData&&e.data.close())}));const pt=["I420","I420P10","I420P12","I420A","I420AP10","I420AP12","I422","I422P10","I422P12","I422A","I422AP10","I422AP12","I444","I444P10","I444P12","I444A","I444AP10","I444AP12","NV12","RGBA","RGBX","BGRA","BGRX"],gt=new Set(pt);class kt{get displayWidth(){return this.rotation%180===0?this.codedWidth:this.codedHeight}get displayHeight(){return this.rotation%180===0?this.codedHeight:this.codedWidth}get microsecondTimestamp(){return Math.trunc(Y*this.timestamp)}get microsecondDuration(){return Math.trunc(Y*this.duration)}get hasAlpha(){return this.format&&this.format.includes("A")}constructor(e,t){var r,i,n,s,a,o,l,c,u,d;if(this._closed=!1,e instanceof ArrayBuffer||"undefined"!==typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer||ArrayBuffer.isView(e)){if(!t||"object"!==typeof t)throw new TypeError("init must be an object.");if(void 0===t.format||!gt.has(t.format))throw new TypeError("init.format must be one of: "+pt.join(", "));if(!Number.isInteger(t.codedWidth)||t.codedWidth<=0)throw new TypeError("init.codedWidth must be a positive integer.");if(!Number.isInteger(t.codedHeight)||t.codedHeight<=0)throw new TypeError("init.codedHeight must be a positive integer.");if(void 0!==t.rotation&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(void 0!==t.duration&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");this._data=S(e).slice(),this._layout=null!=(r=t.layout)?r:wt(t.format,t.codedWidth,t.codedHeight),this.format=t.format,this.codedWidth=t.codedWidth,this.codedHeight=t.codedHeight,this.rotation=null!=(i=t.rotation)?i:0,this.timestamp=t.timestamp,this.duration=null!=(n=t.duration)?n:0,this.colorSpace=new bt(t.colorSpace)}else if("undefined"!==typeof VideoFrame&&e instanceof VideoFrame){if(void 0!==(null==t?void 0:t.rotation)&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(void 0!==(null==t?void 0:t.timestamp)&&!Number.isFinite(null==t?void 0:t.timestamp))throw new TypeError("init.timestamp, when provided, must be a number.");if(void 0!==(null==t?void 0:t.duration)&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");this._data=e,this._layout=null,this.format=e.format,this.codedWidth=e.displayWidth,this.codedHeight=e.displayHeight,this.rotation=null!=(s=null==t?void 0:t.rotation)?s:0,this.timestamp=null!=(a=null==t?void 0:t.timestamp)?a:e.timestamp/1e6,this.duration=null!=(l=null==t?void 0:t.duration)?l:(null!=(o=e.duration)?o:0)/1e6,this.colorSpace=new bt(e.colorSpace)}else{if(!("undefined"!==typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!==typeof SVGImageElement&&e instanceof SVGImageElement||"undefined"!==typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!==typeof HTMLVideoElement&&e instanceof HTMLVideoElement||"undefined"!==typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!==typeof OffscreenCanvas&&e instanceof OffscreenCanvas))throw new TypeError("Invalid data type: Must be a BufferSource or CanvasImageSource.");{if(!t||"object"!==typeof t)throw new TypeError("init must be an object.");if(void 0!==t.rotation&&![0,90,180,270].includes(t.rotation))throw new TypeError("init.rotation, when provided, must be 0, 90, 180, or 270.");if(!Number.isFinite(t.timestamp))throw new TypeError("init.timestamp must be a number.");if(void 0!==t.duration&&(!Number.isFinite(t.duration)||t.duration<0))throw new TypeError("init.duration, when provided, must be a non-negative number.");if("undefined"!==typeof VideoFrame)return new kt(new VideoFrame(e,{timestamp:Math.trunc(t.timestamp*Y),duration:Math.trunc((null!=(c=t.duration)?c:0)*Y)||void 0}),t);let r=0,i=0;if("naturalWidth"in e?(r=e.naturalWidth,i=e.naturalHeight):"videoWidth"in e?(r=e.videoWidth,i=e.videoHeight):"width"in e&&(r=Number(e.width),i=Number(e.height)),!r||!i)throw new TypeError("Could not determine dimensions.");const n=new OffscreenCanvas(r,i),s=n.getContext("2d",{alpha:se(),willReadFrequentlyLine truncated
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/class Qt{constructor(e,t){this.input=e,this._backing=t}isVideoTrack(){return this instanceof Gt}isAudioTrack(){return this instanceof Xt}get id(){return this._backing.getId()}get internalCodecId(){return this._backing.getInternalCodecId()}get languageCode(){return this._backing.getLanguageCode()}get name(){return this._backing.getName()}get timeResolution(){return this._backing.getTimeResolution()}get disposition(){return this._backing.getDisposition()}getFirstTimestamp(){return this._backing.getFirstTimestamp()}computeDuration(){return this._backing.computeDuration()}computePacketStats(e=1/0){return u(this,null,function*(){const t=new Nt(this);let r=1/0,i=-1/0,n=0,s=0;try{for(var a,o,l,c=m(t.packets(void 0,void 0,{metadataOnly:!0}));a=!(o=yield c.next()).done;a=!1){const t=o.value;if(n>=e&&t.timestamp>=i)break;r=Math.min(r,t.timestamp),i=Math.max(i,t.timestamp+t.duration),n++,s+=t.byteLength}}catch(o){l=[o]}finally{try{a&&(o=c.return)&&(yield o.call(c))}finally{if(l)throw l[0]}}return{packetCount:n,averagePacketRate:n?Number((n/(i-r)).toPrecision(16)):0,averageBitrate:n?Number((8*s/(i-r)).toPrecision(16)):0}})}}class Gt extends Qt{constructor(e,t){super(e,t),this._backing=t}get type(){return"video"}get codec(){return this._backing.getCodec()}get codedWidth(){return this._backing.getCodedWidth()}get codedHeight(){return this._backing.getCodedHeight()}get rotation(){return this._backing.getRotation()}get displayWidth(){return this._backing.getRotation()%180===0?this._backing.getCodedWidth():this._backing.getCodedHeight()}get displayHeight(){return this._backing.getRotation()%180===0?this._backing.getCodedHeight():this._backing.getCodedWidth()}getColorSpace(){return this._backing.getColorSpace()}hasHighDynamicRange(){return u(this,null,function*(){const e=yield this._backing.getColorSpace();return"bt2020"===e.primaries||"smpte432"===e.primaries||"pg"===e.transfer||"hlg"===e.transfer||"bt2020-ncl"===e.matrix})}canBeTransparent(){return this._backing.canBeTransparent()}getDecoderConfig(){return this._backing.getDecoderConfig()}getCodecParameterString(){return u(this,null,function*(){var e;const t=yield this._backing.getDecoderConfig();return null!=(e=null==t?void 0:t.codec)?e:null})}canDecode(){return u(this,null,function*(){try{const e=yield this._backing.getDecoderConfig();if(!e)return!1;const t=this._backing.getCodec();if(p(null!==t),lt.some(r=>r.supports(t,e)))return!0;if("undefined"===typeof VideoDecoder)return!1;return!0===(yield VideoDecoder.isConfigSupported(e)).supported}catch(e){return console.error("Error during decodability check:",e),!1}})}determinePacketType(e){return u(this,null,function*(){if(!(e instanceof dt))throw new TypeError("packet must be an EncodedPacket.");if(e.isMetadataOnly)throw new TypeError("packet must not be metadata-only to determine its type.");if(null===this.codec)return null;const t=yield this.getDecoderConfig();return p(t),it(this.codec,t,e.data)})}}class Xt extends Qt{constructor(e,t){super(e,t),this._backing=t}get type(){return"audio"}get codec(){return this._backing.getCodec()}get numberOfChannels(){return this._backing.getNumberOfChannels()}get sampleRate(){return this._backing.getSampleRate()}getDecoderConfig(){return this._backing.getDecoderConfig()}getCodecParameterString(){return u(this,null,function*(){var e;const t=yield this._backing.getDecoderConfig();return null!=(e=null==t?void 0:t.codec)?e:null})}canDecode(){return u(this,null,function*(){try{const e=yield this._backing.getDecoderConfig();if(!e)return!1;const t=this._backing.getCodec();if(p(null!==t),ct.some(r=>r.supports(t,e)))return!0;if(e.codec.startsWith("pcm-"))return!0;if("undefined"===typeof AudioDecoder)return!1;return!0===(yield AudioDecoder.isConfigSupported(e)).supported}catch(e){return console.error("Error during decodability check:",e),!1}})}determinePacketType(e){return u(this,null,function*(){if(!(e instanceof dt))throw new TypeError("packet must be an EncodedPacket.");return null===this.codec?null:"key"})}}
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/const Yt=e=>{let t=Cn(e);const r=Nn(e,4);let i=8;1===t&&(t=Fn(e),i=16);const n=t-i;return n<0?null:{name:r,totalSize:t,headerSize:i,contentSize:n}},Jt=e=>Bn(e)/65536,Zt=e=>Bn(e)/1073741824,er=e=>{let t=0;for(let r=0;r<4;r++){t<<=7;const r=Sn(e);if(t|=127&r,0===(128&r))break}return t},tr=e=>{let t=wn(e);return e.skip(2),t=Math.min(t,e.remainingLength),w.decode(Tn(e,t))},rr=e=>{const t=Yt(e);if(!t||"data"!==t.name)return null;if(e.remainingLength<8)return null;const r=Cn(e);e.skip(4);const i=Tn(e,t.contentSize-8);switch(r){case 1:return w.decode(i);case 2:return new TextDecoder("utf-16be").decode(i);case 13:return new fe(i,"image/jpeg");case 14:return new fe(i,"image/png");case 27:return new fe(i,"image/bmp");default:return i}};
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
class ir extends ot{constructor(e){super(e),this.moovSlice=null,this.currentTrack=null,this.tracks=[],this.metadataPromise=null,this.movieTimescale=-1,this.movieDurationInTimescale=-1,this.isQuickTime=!1,this.metadataTags={},this.currentMetadataKeys=null,this.isFragmented=!1,this.fragmentTrackDefaults=[],this.currentFragment=null,this.lastReadFragment=null,this.reader=e._reader}computeDuration(){return u(this,null,function*(){const e=yield this.getTracks(),t=yield Promise.all(e.map(e=>e.computeDuration()));return Math.max(0,...t)})}getTracks(){return u(this,null,function*(){return yield this.readMetadata(),this.tracks.map(e=>e.inputTrack)})}getMimeType(){return u(this,null,function*(){yield this.readMetadata();const e=yield Promise.all(this.tracks.map(e=>e.inputTrack.getCodecParameterString()));return(e=>{let t=(e.hasVideo?"video/":e.hasAudio?"audio/":"application/")+(e.isQuickTime?"quicktime":"mp4");e.codecStrings.length>0&&(t+=`; codecs="${[...new Set(e.codecStrings)].join(", ")}"`);return t})({isQuickTime:this.isQuickTime,hasVideo:this.tracks.some(e=>{var t;return"video"===(null==(t=e.info)?void 0:t.type)}),hasAudio:this.tracks.some(e=>{var t;return"audio"===(null==(t=e.info)?void 0:t.type)}),codecStrings:e.filter(Boolean)})})}getMetadataTags(){return u(this,null,function*(){return yield this.readMetadata(),this.metadataTags})}readMetadata(){var e;return null!=(e=this.metadataPromise)?e:this.metadataPromise=(()=>u(this,null,function*(){let e=0;for(;;){let t=this.reader.requestSliceRange(e,8,16);if(t instanceof Promise&&(t=yield t),!t)break;const r=e,i=Yt(t);if(!i)break;if("ftyp"===i.name){const e=Nn(t,4);this.isQuickTime="qt "===e}else if("moov"===i.name){let e=this.reader.requestSlice(t.filePos,i.contentSize);if(e instanceof Promise&&(e=yield e),!e)break;this.moovSlice=e,this.readContiguousBoxes(this.moovSlice),this.tracks.sort((e,t)=>Number(t.disposition.default)-Number(e.disposition.default));for(const t of this.tracks){const e=t.editListPreviousSegmentDurations/this.movieTimescale;t.editListOffset-=Math.round(e*t.timescale)}break}e=r+i.totalSize}if(this.isFragmented&&null!==this.reader.fileSize){let e=this.reader.requestSlice(this.reader.fileSize-4,4);e instanceof Promise&&(e=yield e),p(e);const t=Cn(e),r=this.reader.fileSize-t;if(r>=0&&r<=this.reader.fileSize-16){let e=this.reader.requestSliceRange(r,8,16);if(e instanceof Promise&&(e=yield e),e){const t=Yt(e);if(t&&"mfra"===t.name){let r=this.reader.requestSlice(e.filePos,t.contentSize);r instanceof Promise&&(r=yield r),r&&this.readContiguousBoxes(r)}}}}}))()}getSampleTableForTrack(e){var t,r;if(e.sampleTable)return e.sampleTable;const i={sampleTimingEntries:[],sampleCompositionTimeOffsets:[],sampleSizes:[],keySampleIndices:null,chunkOffsets:[],sampleToChunk:[],presentationTimestamps:null,presentationTimestampIndexMap:null};e.sampleTable=i,p(this.moovSlice);const n=this.moovSlice.slice(e.sampleTableByteOffset);this.currentTrack=e,this.traverseBox(n),this.currentTrack=null;if("audio"===(null==(t=e.info)?void 0:t.type)&&e.info.codec&&ke.includes(e.info.codec)&&0===i.sampleCompositionTimeOffsets.length){p("audio"===(null==(r=e.info)?void 0:r.type));const t=_e(e.info.codec),n=[],s=[];for(let r=0;r<i.sampleToChunk.length;r++){const a=i.sampleToChunk[r],o=i.sampleToChunk[r+1],l=(o?o.startChunkIndex:i.chunkOffsets.length)-a.startChunkIndex;for(let r=0;r<l;r++){const o=a.startSampleIndex+r*a.samplesPerChunk,l=o+a.samplesPerChunk,c=N(i.sampleTimingEntries,o,e=>e.startIndex),u=i.sampleTimingEntries[c],d=N(i.sampleTimingEntries,l,e=>e.startIndex),h=i.sampleTimingEntries[d],m=u.startDecodeTimestamp+(o-u.startIndex)*u.delta,f=h.startDecodeTimestamp+(l-h.startIndex)*h.delta-m,p=k(n);p&&p.delta===f?p.count++:n.push({startIndex:a.startChunkIndex+r,startDecodeTimestamp:m,count:1,delta:f});const g=a.samplesPerChunk*t.sampleSize*e.info.numberOfChannels;s.push(g)}a.startSampleIndex=a.startChunkIndex,a.samplesPerChunk=1}i.sampleTimingEntries=n,i.sampleSizes=s}if(i.sampleCompositionTimeOffsets.length>0){i.presentationTimestamps=[];for(const e of i.sampleTimingEntries)for(let t=0;t<e.count;t++)i.presentationTimestamps.push({presentationTimestamp:e.startDecodeTimestamp+t*e.delta,sampleIndex:e.startIndex+t});for(const e of i.sampleCompositionTimeOffsets)for(let t=0;t<e.count;t++){const r=e.startIndex+t,n=i.presentationTimestamps[r];n&&(n.presentationTimestamp+=e.offset)}i.presentationTimestamps.sort((e,t)=>e.presentationTimestamp-t.presentationTimestamp),i.presentationTimestampIndexMap=Array(i.presentationTimestamps.length).fill(-1);for(let e=0;e<i.presentationTimestamps.length;e++)i.presentationTimestampIndexMap[i.presentationTimestamps[e].sampleIndex]=e}return i}readFragment(e){return u(this,null,function*(){var t;if((null==(t=this.lastReadFragment)?void 0:t.moofOffset)===e)return this.lastReadFragment;let r=this.reader.requestSliceRange(e,8,16);r instanceof Promise&&(r=yield r),p(r);const i=Yt(r);p("moof"===(null==i?void 0:i.name));let n=this.reader.requestSlice(e,i.toLine truncated
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
var fr,pr;(pr=fr||(fr={}))[pr.EBML=440786851]="EBML",pr[pr.EBMLVersion=17030]="EBMLVersion",pr[pr.EBMLReadVersion=17143]="EBMLReadVersion",pr[pr.EBMLMaxIDLength=17138]="EBMLMaxIDLength",pr[pr.EBMLMaxSizeLength=17139]="EBMLMaxSizeLength",pr[pr.DocType=17026]="DocType",pr[pr.DocTypeVersion=17031]="DocTypeVersion",pr[pr.DocTypeReadVersion=17029]="DocTypeReadVersion",pr[pr.Void=236]="Void",pr[pr.Segment=408125543]="Segment",pr[pr.SeekHead=290298740]="SeekHead",pr[pr.Seek=19899]="Seek",pr[pr.SeekID=21419]="SeekID",pr[pr.SeekPosition=21420]="SeekPosition",pr[pr.Duration=17545]="Duration",pr[pr.Info=357149030]="Info",pr[pr.TimestampScale=2807729]="TimestampScale",pr[pr.MuxingApp=19840]="MuxingApp",pr[pr.WritingApp=22337]="WritingApp",pr[pr.Tracks=374648427]="Tracks",pr[pr.TrackEntry=174]="TrackEntry",pr[pr.TrackNumber=215]="TrackNumber",pr[pr.TrackUID=29637]="TrackUID",pr[pr.TrackType=131]="TrackType",pr[pr.FlagEnabled=185]="FlagEnabled",pr[pr.FlagDefault=136]="FlagDefault",pr[pr.FlagForced=21930]="FlagForced",pr[pr.FlagOriginal=21934]="FlagOriginal",pr[pr.FlagHearingImpaired=21931]="FlagHearingImpaired",pr[pr.FlagVisualImpaired=21932]="FlagVisualImpaired",pr[pr.FlagCommentary=21935]="FlagCommentary",pr[pr.FlagLacing=156]="FlagLacing",pr[pr.Name=21358]="Name",pr[pr.Language=2274716]="Language",pr[pr.LanguageBCP47=2274717]="LanguageBCP47",pr[pr.CodecID=134]="CodecID",pr[pr.CodecPrivate=25506]="CodecPrivate",pr[pr.CodecDelay=22186]="CodecDelay",pr[pr.SeekPreRoll=22203]="SeekPreRoll",pr[pr.DefaultDuration=2352003]="DefaultDuration",pr[pr.Video=224]="Video",pr[pr.PixelWidth=176]="PixelWidth",pr[pr.PixelHeight=186]="PixelHeight",pr[pr.AlphaMode=21440]="AlphaMode",pr[pr.Audio=225]="Audio",pr[pr.SamplingFrequency=181]="SamplingFrequency",pr[pr.Channels=159]="Channels",pr[pr.BitDepth=25188]="BitDepth",pr[pr.SimpleBlock=163]="SimpleBlock",pr[pr.BlockGroup=160]="BlockGroup",pr[pr.Block=161]="Block",pr[pr.BlockAdditions=30113]="BlockAdditions",pr[pr.BlockMore=166]="BlockMore",pr[pr.BlockAdditional=165]="BlockAdditional",pr[pr.BlockAddID=238]="BlockAddID",pr[pr.BlockDuration=155]="BlockDuration",pr[pr.ReferenceBlock=251]="ReferenceBlock",pr[pr.Cluster=524531317]="Cluster",pr[pr.Timestamp=231]="Timestamp",pr[pr.Cues=475249515]="Cues",pr[pr.CuePoint=187]="CuePoint",pr[pr.CueTime=179]="CueTime",pr[pr.CueTrackPositions=183]="CueTrackPositions",pr[pr.CueTrack=247]="CueTrack",pr[pr.CueClusterPosition=241]="CueClusterPosition",pr[pr.Colour=21936]="Colour",pr[pr.MatrixCoefficients=21937]="MatrixCoefficients",pr[pr.TransferCharacteristics=21946]="TransferCharacteristics",pr[pr.Primaries=21947]="Primaries",pr[pr.Range=21945]="Range",pr[pr.Projection=30320]="Projection",pr[pr.ProjectionType=30321]="ProjectionType",pr[pr.ProjectionPoseRoll=30325]="ProjectionPoseRoll",pr[pr.Attachments=423732329]="Attachments",pr[pr.AttachedFile=24999]="AttachedFile",pr[pr.FileDescription=18046]="FileDescription",pr[pr.FileName=18030]="FileName",pr[pr.FileMediaType=18016]="FileMediaType",pr[pr.FileData=18012]="FileData",pr[pr.FileUID=18094]="FileUID",pr[pr.Chapters=272869232]="Chapters",pr[pr.Tags=307544935]="Tags",pr[pr.Tag=29555]="Tag",pr[pr.Targets=25536]="Targets",pr[pr.TargetTypeValue=26826]="TargetTypeValue",pr[pr.TargetType=25546]="TargetType",pr[pr.TagTrackUID=25541]="TagTrackUID",pr[pr.TagEditionUID=25545]="TagEditionUID",pr[pr.TagChapterUID=25540]="TagChapterUID",pr[pr.TagAttachmentUID=25542]="TagAttachmentUID",pr[pr.SimpleTag=26568]="SimpleTag",pr[pr.TagName=17827]="TagName",pr[pr.TagLanguage=17530]="TagLanguage",pr[pr.TagString=17543]="TagString",pr[pr.TagBinary=17541]="TagBinary",pr[pr.ContentEncodings=28032]="ContentEncodings",pr[pr.ContentEncoding=25152]="ContentEncoding",pr[pr.ContentEncodingOrder=20529]="ContentEncodingOrder",pr[pr.ContentEncodingScope=20530]="ContentEncodingScope",pr[pr.ContentCompression=20532]="ContentCompression",pr[pr.ContentCompAlgo=16980]="ContentCompAlgo",pr[pr.ContentCompSettings=16981]="ContentCompSettings",pr[pr.ContentEncryption=20533]="ContentEncryption";const gr=[fr.EBML,fr.Segment],kr=[fr.SeekHead,fr.Info,fr.Cluster,fr.Tracks,fr.Cues,fr.Attachments,fr.Chapters,fr.Tags],br=[...gr,...kr],yr=16,Tr=e=>{if(e.remainingLength<1)return null;const t=Sn(e);if(e.skip(-1),0===t)return null;let r=1,i=128;for(;0===(t&i);)r++,i>>=1;return e.remainingLength<r?null:r},Sr=e=>{if(e.remainingLength<1)return null;const t=Sn(e);if(0===t)return null;let r=1,i=128;for(;0===(t&i);)r++,i>>=1;if(e.remainingLength<r-1)return null;let n=t&i-1;for(let s=1;s<r;s++)n*=256,n+=Sn(e);return n},vr=(e,t)=>{if(t<1||t>8)throw new Error("Bad unsigned int size "+t);let r=0;for(let i=0;i<t;i++)r*=256,r+=Sn(e);return r},wr=e=>{const t=Tr(e);if(null===t)return null;if(e.remainingLength<t)return null;return vr(e,t)},Ir=e=>{if(e.remainingLength<1)return null;if(255===Sn(e))return;e.skip(-1);const t=Sr(e);return null===t?null:72057594037927940!==t?t:void 0},Pr=e=>{p(e.remainingLength>=2);const t=wr(e);if(null===t)return null;const r=Ir(e);return null==Line truncated
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
var qr,Hr,Wr,jr,Kr,$r;(Hr=qr||(qr={}))[Hr.None=0]="None",Hr[Hr.Xiph=1]="Xiph",Hr[Hr.FixedSize=2]="FixedSize",Hr[Hr.Ebml=3]="Ebml",(jr=Wr||(Wr={}))[jr.Block=1]="Block",jr[jr.Private=2]="Private",jr[jr.Next=4]="Next",($r=Kr||(Kr={}))[$r.Zlib=0]="Zlib",$r[$r.Bzlib=1]="Bzlib",$r[$r.lzo1x=2]="lzo1x",$r[$r.HeaderStripping=3]="HeaderStripping";const Qr=[{id:fr.SeekHead,flag:"seekHeadSeen"},{id:fr.Info,flag:"infoSeen"},{id:fr.Tracks,flag:"tracksSeen"},{id:fr.Cues,flag:"cuesSeen"}],Gr=10*o(2,20);class Xr extends ot{constructor(e){super(e),this.readMetadataPromise=null,this.segments=[],this.currentSegment=null,this.currentTrack=null,this.currentCluster=null,this.currentBlock=null,this.currentBlockAdditional=null,this.currentCueTime=null,this.currentDecodingInstruction=null,this.currentTagTargetIsMovie=!0,this.currentSimpleTagName=null,this.currentAttachedFile=null,this.isWebM=!1,this.reader=e._reader}computeDuration(){return u(this,null,function*(){const e=yield this.getTracks(),t=yield Promise.all(e.map(e=>e.computeDuration()));return Math.max(0,...t)})}getTracks(){return u(this,null,function*(){return yield this.readMetadata(),this.segments.flatMap(e=>e.tracks.map(e=>e.inputTrack))})}getMimeType(){return u(this,null,function*(){yield this.readMetadata();const e=yield this.getTracks(),t=yield Promise.all(e.map(e=>e.getCodecParameterString()));return(e=>{let t=(e.hasVideo?"video/":e.hasAudio?"audio/":"application/")+(e.isWebM?"webm":"x-matroska");e.codecStrings.length>0&&(t+=`; codecs="${[...new Set(e.codecStrings.filter(Boolean))].join(", ")}"`);return t})({isWebM:this.isWebM,hasVideo:this.segments.some(e=>e.tracks.some(e=>{var t;return"video"===(null==(t=e.info)?void 0:t.type)})),hasAudio:this.segments.some(e=>e.tracks.some(e=>{var t;return"audio"===(null==(t=e.info)?void 0:t.type)})),codecStrings:t.filter(Boolean)})})}getMetadataTags(){return u(this,null,function*(){yield this.readMetadata();for(const t of this.segments)t.metadataTagsCollected||(null!==this.reader.fileSize&&(yield this.loadSegmentMetadata(t)),t.metadataTagsCollected=!0);let e={};for(const t of this.segments)e=c(c({},e),t.metadataTags);return e})}readMetadata(){var e;return null!=(e=this.readMetadataPromise)?e:this.readMetadataPromise=(()=>u(this,null,function*(){let e=0;for(;;){let t=this.reader.requestSliceRange(e,2,yr);if(t instanceof Promise&&(t=yield t),!t)break;const r=Pr(t);if(!r)break;const i=r.id;let n=r.size;const s=t.filePos;if(i===fr.EBML){Vr(n);let e=this.reader.requestSlice(s,n);if(e instanceof Promise&&(e=yield e),!e)break;this.readContiguousElements(e)}else if(i===fr.Segment){if(yield this.readSegment(s,n),void 0===n)break;if(null===this.reader.fileSize)break}else if(i===fr.Cluster){if(null===this.reader.fileSize)break;if(void 0===n){n=(yield Br(this.reader,s,br,this.reader.fileSize)).pos-s}const e=k(this.segments);e&&(e.elementEndPos=s+n)}Vr(n),e=s+n}}))()}readSegment(e,t){return u(this,null,function*(){var r;this.currentSegment={seekHeadSeen:!1,infoSeen:!1,tracksSeen:!1,cuesSeen:!1,tagsSeen:!1,attachmentsSeen:!1,timestampScale:-1,timestampFactor:-1,duration:-1,seekEntries:[],tracks:[],cuePoints:[],dataStartPos:e,elementEndPos:void 0===t?null:e+t,clusterSeekStartPos:e,lastReadCluster:null,metadataTags:{},metadataTagsCollected:!1},this.segments.push(this.currentSegment);let i=e;for(;null===this.currentSegment.elementEndPos||i<this.currentSegment.elementEndPos;){let e=this.reader.requestSliceRange(i,2,yr);if(e instanceof Promise&&(e=yield e),!e)break;const t=i,n=Pr(e);if(!n||!kr.includes(n.id)&&n.id!==fr.Void){const e=yield Er(this.reader,t,kr,Math.min(null!=(r=this.currentSegment.elementEndPos)?r:1/0,t+Gr));if(e){i=e;continue}break}const{id:s,size:a}=n,o=e.filePos,l=Qr.findIndex(e=>e.id===s);if(-1!==l){const e=Qr[l].flag;this.currentSegment[e]=!0,Vr(a);let t=this.reader.requestSlice(o,a);t instanceof Promise&&(t=yield t),t&&this.readContiguousElements(t)}else if(s===fr.Tags||s===fr.Attachments){s===fr.Tags?this.currentSegment.tagsSeen=!0:this.currentSegment.attachmentsSeen=!0,Vr(a);let e=this.reader.requestSlice(o,a);e instanceof Promise&&(e=yield e),e&&this.readContiguousElements(e)}else if(s===fr.Cluster){this.currentSegment.clusterSeekStartPos=t;break}if(void 0===a)break;i=o+a}if(this.currentSegment.seekEntries.sort((e,t)=>e.segmentPosition-t.segmentPosition),null!==this.reader.fileSize)for(const t of this.currentSegment.seekEntries){const r=Qr.find(e=>e.id===t.id);if(!r)continue;if(this.currentSegment[r.flag])continue;let i=this.reader.requestSliceRange(e+t.segmentPosition,2,yr);if(i instanceof Promise&&(i=yield i),!i)continue;const n=Pr(i);if(!n)continue;const{id:s,size:a}=n;if(s!==r.id)continue;Vr(a),this.currentSegment[r.flag]=!0;let o=this.reader.requestSlice(i.filePos,a);o instanceof Promise&&(o=yield o),o&&this.readContiguousElements(o)}-1===this.currentSegment.timestampScale&&(this.currentSegment.timestampScale=1e6,this.currentSegment.timestampFactor=1e3);for(const e of this.currentSegment.tracks)null!==e.defaultDurationLine truncated
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/const ei=[44100,48e3,32e3],ti=[-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,32,40,48,56,64,80,96,112,128,160,192,224,256,320,-1,-1,32,48,56,64,80,96,112,128,160,192,224,256,320,384,-1,-1,32,64,96,128,160,192,224,256,288,320,352,384,416,448,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1,-1,8,16,24,32,40,48,56,64,80,96,112,128,144,160,-1,-1,32,48,56,64,80,96,112,128,144,160,176,192,224,256,-1],ri=(e,t)=>{const r=e>>>24,i=e>>>16&255,n=e>>>8&255,s=255&e;if(255!==r&&255!==i&&255!==n&&255!==s)return{header:null,bytesAdvanced:4};if(255!==r)return{header:null,bytesAdvanced:1};if(224!==(224&i))return{header:null,bytesAdvanced:1};let a=0,o=0;16&i?a=8&i?0:1:(a=1,o=1);const l=i>>3&3,c=i>>1&3,u=(n>>2&3)%3,d=s>>6&3,h=s>>4&3,m=s>>3&1,f=s>>2&1,p=3&s,g=ti[16*a*4+16*c+(n>>4&15)];if(-1===g)return{header:null,bytesAdvanced:1};const k=1e3*g,b=ei[u]>>a+o,y=((e,t,r,i,n)=>0===t?0:1===t?Math.floor(144*r/(i<<e))+n:2===t?Math.floor(144*r/i)+n:4*(Math.floor(12*r/i)+n))(a,c,k,b,n>>1&1);if(null!==t&&t<y)return{header:null,bytesAdvanced:1};let T;return T=3===l?3===c?384:1152:3===c?384:2===c?1152:576,{header:{totalSize:y,mpegVersionId:l,layer:c,bitrate:k,frequencyIndex:u,sampleRate:b,channel:d,modeExtension:h,copyright:m,original:f,emphasis:p,audioSamplesInFrame:T},bytesAdvanced:1}},ii=e=>{let t=2130706432,r=0;for(;0!==t;)r>>=1,r|=e&t,t>>=8;return r};
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
var ni,si,ai,oi;(si=ni||(ni={}))[si.Unsynchronisation=128]="Unsynchronisation",si[si.ExtendedHeader=64]="ExtendedHeader",si[si.ExperimentalIndicator=32]="ExperimentalIndicator",si[si.Footer=16]="Footer",(oi=ai||(ai={}))[oi.ISO_8859_1=0]="ISO_8859_1",oi[oi.UTF_16_WITH_BOM=1]="UTF_16_WITH_BOM",oi[oi.UTF_16_BE_NO_BOM=2]="UTF_16_BE_NO_BOM",oi[oi.UTF_8=3]="UTF_8";const li=128,ci=["Blues","Classic rock","Country","Dance","Disco","Funk","Grunge","Hip-hop","Jazz","Metal","New age","Oldies","Other","Pop","Rhythm and blues","Rap","Reggae","Rock","Techno","Industrial","Alternative","Ska","Death metal","Pranks","Soundtrack","Euro-techno","Ambient","Trip-hop","Vocal","Jazz & funk","Fusion","Trance","Classical","Instrumental","Acid","House","Game","Sound clip","Gospel","Noise","Alternative rock","Bass","Soul","Punk","Space","Meditative","Instrumental pop","Instrumental rock","Ethnic","Gothic","Darkwave","Techno-industrial","Electronic","Pop-folk","Eurodance","Dream","Southern rock","Comedy","Cult","Gangsta","Top 40","Christian rap","Pop/funk","Jungle music","Native US","Cabaret","New wave","Psychedelic","Rave","Showtunes","Trailer","Lo-fi","Tribal","Acid punk","Acid jazz","Polka","Retro","Musical","Rock 'n' roll","Hard rock","Folk","Folk rock","National folk","Swing","Fast fusion","Bebop","Latin","Revival","Celtic","Bluegrass","Avantgarde","Gothic rock","Progressive rock","Psychedelic rock","Symphonic rock","Slow rock","Big band","Chorus","Easy listening","Acoustic","Humour","Speech","Chanson","Opera","Chamber music","Sonata","Symphony","Booty bass","Primus","Porn groove","Satire","Slow jam","Club","Tango","Samba","Folklore","Ballad","Power ballad","Rhythmic Soul","Freestyle","Duet","Punk rock","Drum solo","A cappella","Euro-house","Dance hall","Goa music","Drum & bass","Club-house","Hardcore techno","Terror","Indie","Britpop","Negerpunk","Polsk punk","Beat","Christian gangsta rap","Heavy metal","Black metal","Crossover","Contemporary Christian","Christian rock","Merengue","Salsa","Thrash metal","Anime","Jpop","Synthpop","Christmas","Art rock","Baroque","Bhangra","Big beat","Breakbeat","Chillout","Downtempo","Dub","EBM","Eclectic","Electro","Electroclash","Emo","Experimental","Garage","Global","IDM","Illbient","Industro-Goth","Jam Band","Krautrock","Leftfield","Lounge","Math rock","New romantic","Nu-breakz","Post-punk","Post-rock","Psytrance","Shoegaze","Space rock","Trop rock","World music","Neoclassical","Audiobook","Audio theatre","Neue Deutsche Welle","Podcast","Indie rock","G-Funk","Dubstep","Garage rock","Psybient"],ui=(e,t)=>{const r=Tn(e,t),i=ce(r.indexOf(0),r.length),n=r.subarray(0,i);let s="";for(let a=0;a<n.length;a++)s+=String.fromCharCode(n[a]);return s.trimEnd()},di=e=>{const t=e.filePos,r=Nn(e,3),i=Sn(e),n=Sn(e),s=Sn(e),a=Cn(e);if("ID3"!==r||255===i||255===n||0!==(2155905152&a))return e.filePos=t,null;return{majorVersion:i,revision:n,flags:s,size:ii(a)}},hi=(e,t,r)=>{var i,n,s,a;if(![2,3,4].includes(t.majorVersion))return void console.warn(`Unsupported ID3v2 major version: ${t.majorVersion}`);const o=Tn(e,t.size),l=new mi(t,o);if(t.flags&ni.Footer&&l.removeFooter(),t.flags&ni.Unsynchronisation&&3===t.majorVersion&&l.ununsynchronizeAll(),t.flags&ni.ExtendedHeader){const e=l.readU32();3===t.majorVersion?l.pos+=e:l.pos+=e-4}for(;l.pos<=l.bytes.length-l.frameHeaderSize();){const e=l.readId3V2Frame();if(!e)break;const o=l.pos,c=l.pos+e.size;let u=!1,d=!1,h=!1;if(3===t.majorVersion?(u=!!(64&e.flags),d=!!(128&e.flags)):4===t.majorVersion&&(u=!!(4&e.flags),d=!!(8&e.flags),h=!!(2&e.flags)||!!(t.flags&ni.Unsynchronisation)),u)console.warn(`Skipping encrypted ID3v2 frame ${e.id}`),l.pos=c;else if(d)console.warn(`Skipping compressed ID3v2 frame ${e.id}`),l.pos=c;else{switch(h&&l.ununsynchronizeRegion(l.pos,c),null!=r.raw||(r.raw={}),"T"===e.id[0]?null!=(i=r.raw)[n=e.id]||(i[n]=l.readId3V2EncodingAndText(c)):null!=(s=r.raw)[a=e.id]||(s[a]=l.readBytes(e.size)),l.pos=o,e.id){case"TIT2":case"TT2":null!=r.title||(r.title=l.readId3V2EncodingAndText(c));break;case"TIT3":case"TT3":null!=r.description||(r.description=l.readId3V2EncodingAndText(c));break;case"TPE1":case"TP1":null!=r.artist||(r.artist=l.readId3V2EncodingAndText(c));break;case"TALB":case"TAL":null!=r.album||(r.album=l.readId3V2EncodingAndText(c));break;case"TPE2":case"TP2":null!=r.albumArtist||(r.albumArtist=l.readId3V2EncodingAndText(c));break;case"TRCK":case"TRK":{const e=l.readId3V2EncodingAndText(c).split("/"),t=Number.parseInt(e[0],10),i=e[1]&&Number.parseInt(e[1],10);Number.isInteger(t)&&t>0&&(null!=r.trackNumber||(r.trackNumber=t)),i&&Number.isInteger(i)&&i>0&&(null!=r.tracksTotal||(r.tracksTotal=i))}break;case"TPOS":case"TPA":{const e=l.readId3V2EncodingAndText(c).split("/"),t=Number.parseInt(e[0],10),i=e[1]&&Number.parseInt(e[1],10);Number.isInteger(t)&&t>0&&(null!=r.discNumber||(r.discNumber=t)),i&&Number.isInteger(i)&&i>0&&(null!=r.discsTotal||(r.discsTotal=i))}break;case"TCON":case"TCO":{const e=l.readId3V2EncodingAndText(c);let t=/^\((\d+)\)/.exec(eLine truncated
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/const fi=(e,t,r)=>u(null,null,function*(){let i=t;for(;null===r||i<r;){let t=e.requestSlice(i,4);if(t instanceof Promise&&(t=yield t),!t)break;const r=Cn(t),n=ri(r,null!==e.fileSize?e.fileSize-i:null);if(n.header)return{header:n.header,startPos:i};i+=n.bytesAdvanced}return null});
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/class pi extends ot{constructor(e){super(e),this.metadataPromise=null,this.firstFrameHeader=null,this.loadedSamples=[],this.metadataTags=null,this.tracks=[],this.readingMutex=new D,this.lastSampleLoaded=!1,this.lastLoadedPos=0,this.nextTimestampInSamples=0,this.reader=e._reader}readMetadata(){return u(this,null,function*(){var e;return null!=(e=this.metadataPromise)?e:this.metadataPromise=(()=>u(this,null,function*(){for(;!this.firstFrameHeader&&!this.lastSampleLoaded;)yield this.advanceReader();if(!this.firstFrameHeader)throw new Error("No valid MP3 frame found.");this.tracks=[new Xt(this.input,new gi(this))]}))()})}advanceReader(){return u(this,null,function*(){if(0===this.lastLoadedPos)for(;;){let e=this.reader.requestSlice(this.lastLoadedPos,10);if(e instanceof Promise&&(e=yield e),!e)return void(this.lastSampleLoaded=!0);const t=di(e);if(!t)break;this.lastLoadedPos=e.filePos+t.size}const e=yield fi(this.reader,this.lastLoadedPos,this.reader.fileSize);if(!e)return void(this.lastSampleLoaded=!0);const t=e.header;this.lastLoadedPos=e.startPos+t.totalSize-1;const r=(i=t.mpegVersionId,n=t.channel,3===i?3===n?21:36:3===n?13:21);var i,n;let s=this.reader.requestSlice(e.startPos+r,4);if(s instanceof Promise&&(s=yield s),s){const e=Cn(s);if(1483304551===e||1231971951===e)return}this.firstFrameHeader||(this.firstFrameHeader=t),t.sampleRate!==this.firstFrameHeader.sampleRate&&console.warn(`MP3 changed sample rate mid-file: ${this.firstFrameHeader.sampleRate} Hz to ${t.sampleRate} Hz. Might be a bug, so please report this file.`);const a=t.audioSamplesInFrame/this.firstFrameHeader.sampleRate,o={timestamp:this.nextTimestampInSamples/this.firstFrameHeader.sampleRate,duration:a,dataStart:e.startPos,dataSize:t.totalSize};this.loadedSamples.push(o),this.nextTimestampInSamples+=t.audioSamplesInFrame})}getMimeType(){return u(this,null,function*(){return"audio/mpeg"})}getTracks(){return u(this,null,function*(){return yield this.readMetadata(),this.tracks})}computeDuration(){return u(this,null,function*(){yield this.readMetadata();const e=this.tracks[0];return p(e),e.computeDuration()})}getMetadataTags(){return u(this,null,function*(){const e=yield this.readingMutex.acquire();try{if(yield this.readMetadata(),this.metadataTags)return this.metadataTags;this.metadataTags={};let e=0,t=!1;for(;;){let r=this.reader.requestSlice(e,10);if(r instanceof Promise&&(r=yield r),!r)break;const i=di(r);if(!i)break;t=!0;let n=this.reader.requestSlice(r.filePos,i.size);if(n instanceof Promise&&(n=yield n),!n)break;hi(n,i,this.metadataTags),e=r.filePos+i.size}if(!t&&null!==this.reader.fileSize&&this.reader.fileSize>=li){let e=this.reader.requestSlice(this.reader.fileSize-li,li);e instanceof Promise&&(e=yield e),p(e);"TAG"===Nn(e,3)&&((e,t)=>{var r;const i=e.filePos;null!=t.raw||(t.raw={}),null!=(r=t.raw).TAG||(r.TAG=Tn(e,125)),e.filePos=i;const n=ui(e,30);n&&(null!=t.title||(t.title=n));const s=ui(e,30);s&&(null!=t.artist||(t.artist=s));const a=ui(e,30);a&&(null!=t.album||(t.album=a));const o=ui(e,4),l=Number.parseInt(o,10);Number.isInteger(l)&&l>0&&(null!=t.date||(t.date=new Date(l,0,1)));const c=Tn(e,30);let u;if(0===c[28]&&0!==c[29]){const r=c[29];r>0&&(null!=t.trackNumber||(t.trackNumber=r)),e.skip(-30),u=ui(e,28),e.skip(2)}else e.skip(-30),u=ui(e,30);u&&(null!=t.comment||(t.comment=u));const d=Sn(e);d<ci.length&&(null!=t.genre||(t.genre=ci[d]))})(e,this.metadataTags)}return this.metadataTags}finally{e()}})}}class gi{constructor(e){this.demuxer=e}getId(){return 1}getFirstTimestamp(){return u(this,null,function*(){return 0})}getTimeResolution(){return p(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.sampleRate/this.demuxer.firstFrameHeader.audioSamplesInFrame}computeDuration(){return u(this,null,function*(){var e,t;const r=yield this.getPacket(1/0,{metadataOnly:!0});return(null!=(e=null==r?void 0:r.timestamp)?e:0)+(null!=(t=null==r?void 0:r.duration)?t:0)})}getName(){return null}getLanguageCode(){return $}getCodec(){return"mp3"}getInternalCodecId(){return null}getNumberOfChannels(){return p(this.demuxer.firstFrameHeader),3===this.demuxer.firstFrameHeader.channel?1:2}getSampleRate(){return p(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.sampleRate}getDisposition(){return c({},ge)}getDecoderConfig(){return u(this,null,function*(){return p(this.demuxer.firstFrameHeader),{codec:"mp3",numberOfChannels:3===this.demuxer.firstFrameHeader.channel?1:2,sampleRate:this.demuxer.firstFrameHeader.sampleRate}})}getPacketAtIndex(e,t){return u(this,null,function*(){if(-1===e)return null;const r=this.demuxer.loadedSamples[e];if(!r)return null;let i;if(t.metadataOnly)i=ut;else{let e=this.demuxer.reader.requestSlice(r.dataStart,r.dataSize);if(e instanceof Promise&&(e=yield e),!e)return null;i=Tn(e,r.dataSize)}return new dt(i,"key",r.timestamp,r.duration,e,r.dataSize)})}getFirstPacket(e){return this.getPacketAtIndex(0,e)}getNextPacket(e,t){return u(this,null,function*(){const r=yield this.demuxer.readingMutex.acquire();try{coLine truncated
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/const ki=1399285583,bi=new Uint32Array(256);for(let qn=0;qn<256;qn++){let e=qn<<24;for(let t=0;t<8;t++)e=2147483648&e?e<<1^79764919:e<<1;bi[qn]=e>>>0&4294967295}const yi=e=>{const t=v(e),r=t.getUint32(22,!0);t.setUint32(22,0,!0);let i=0;for(let n=0;n<e.length;n++){const t=e[n];i=(i<<8^bi[i>>>24^t])>>>0}return t.setUint32(22,r,!0),i},Ti=(e,t,r)=>{let i=0,n=null;if(e.length>0)if("vorbis"===t.codec){p(t.vorbisInfo);const s=(1<<(e=>{let t=0;for(;e;)t++,e>>=1;return t})(t.vorbisInfo.modeBlockflags.length-1))-1<<1,a=(e[0]&s)>>1;if(a>=t.vorbisInfo.modeBlockflags.length)throw new Error("Invalid mode number.");let o=r;const l=t.vorbisInfo.modeBlockflags[a];if(n=t.vorbisInfo.blocksizes[l],1===l){const r=1+(1|s),i=e[0]&r?1:0;o=t.vorbisInfo.blocksizes[i]}i=null!==o?o+n>>2:0}else if("opus"===t.codec){i=(e=>{const t=e[0]>>3;return{durationInSamples:tt[t]}})(e).durationInSamples}return{durationInSamples:i,vorbisBlockSize:n}},Si=27,vi=282,wi=e=>{const t=e.filePos;if(_n(e)!==ki)return null;e.skip(1);const r=Sn(e),i=An(e),n=_n(e),s=_n(e),a=_n(e),o=Sn(e),l=new Uint8Array(o);for(let d=0;d<o;d++)l[d]=Sn(e);const c=27+o,u=l.reduce((e,t)=>e+t,0);return{headerStartPos:t,totalSize:c+u,dataStartPos:t+c,dataSize:u,headerType:r,granulePosition:i,serialNumber:n,sequenceNumber:s,checksum:a,lacingValues:l}},Ii=(e,t)=>{for(;e.filePos<t-3;){const t=_n(e),r=79;if((255&t)===r||(t>>>8&255)===r||(t>>>16&255)===r||(t>>>24&255)===r){if(e.skip(-4),t===ki)return!0;e.skip(1)}}return!1};
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
class Pi extends ot{constructor(e){super(e),this.metadataPromise=null,this.bitstreams=[],this.tracks=[],this.metadataTags={},this.reader=e._reader}readMetadata(){return u(this,null,function*(){var e;return null!=(e=this.metadataPromise)?e:this.metadataPromise=(()=>u(this,null,function*(){let e=0;for(;;){let t=this.reader.requestSliceRange(e,Si,vi);if(t instanceof Promise&&(t=yield t),!t)break;const r=wi(t);if(!r)break;if(!!!(2&r.headerType))break;this.bitstreams.push({serialNumber:r.serialNumber,bosPage:r,description:null,numberOfChannels:-1,sampleRate:-1,codecInfo:{codec:null,vorbisInfo:null,opusInfo:null},lastMetadataPacket:null}),e=r.headerStartPos+r.totalSize}for(const t of this.bitstreams){const e=yield this.readPacket(t.bosPage,0);e&&(e.data.byteLength>=7&&1===e.data[0]&&118===e.data[1]&&111===e.data[2]&&114===e.data[3]&&98===e.data[4]&&105===e.data[5]&&115===e.data[6]?yield this.readVorbisMetadata(e,t):e.data.byteLength>=8&&79===e.data[0]&&112===e.data[1]&&117===e.data[2]&&115===e.data[3]&&72===e.data[4]&&101===e.data[5]&&97===e.data[6]&&100===e.data[7]&&(yield this.readOpusMetadata(e,t)),null!==t.codecInfo.codec&&this.tracks.push(new Xt(this.input,new xi(t,this))))}}))()})}readVorbisMetadata(e,t){return u(this,null,function*(){let r=yield this.findNextPacketStart(e);if(!r)return;const i=yield this.readPacket(r.startPage,r.startSegmentIndex);if(!i)return;if(r=yield this.findNextPacketStart(i),!r)return;const n=yield this.readPacket(r.startPage,r.startSegmentIndex);if(!n)return;if(3!==i.data[0]||5!==n.data[0])return;const s=[],a=e=>{for(;s.push(Math.min(255,e)),!(e<255);)e-=255};a(e.data.length),a(i.data.length);const o=new Uint8Array(1+s.length+e.data.length+i.data.length+n.data.length);o[0]=2,o.set(s,1),o.set(e.data,1+s.length),o.set(i.data,1+s.length+e.data.length),o.set(n.data,1+s.length+e.data.length+i.data.length),t.codecInfo.codec="vorbis",t.description=o,t.lastMetadataPacket=n;const l=v(e.data);t.numberOfChannels=l.getUint8(11),t.sampleRate=l.getUint32(12,!0);const c=l.getUint8(28);t.codecInfo.vorbisInfo={blocksizes:[1<<(15&c),1<<(c>>4)],modeBlockflags:rt(n.data).modeBlockflags},at(i.data.subarray(7),this.metadataTags)})}readOpusMetadata(e,t){return u(this,null,function*(){const r=yield this.findNextPacketStart(e);if(!r)return;const i=yield this.readPacket(r.startPage,r.startSegmentIndex);if(!i)return;t.codecInfo.codec="opus",t.description=e.data,t.lastMetadataPacket=i;const n=(e=>{const t=v(e),r=t.getUint8(9),i=t.getUint16(10,!0),n=t.getUint32(12,!0),s=t.getInt16(16,!0),a=t.getUint8(18);let o=null;return a&&(o=e.subarray(19,21+r)),{outputChannelCount:r,preSkip:i,inputSampleRate:n,outputGain:s,channelMappingFamily:a,channelMappingTable:o}})(e.data);t.numberOfChannels=n.outputChannelCount,t.sampleRate=xe,t.codecInfo.opusInfo={preSkip:n.preSkip},at(i.data.subarray(8),this.metadataTags)})}readPacket(e,t){return u(this,null,function*(){p(t<e.lacingValues.length);let r=0;for(let u=0;u<t;u++)r+=e.lacingValues[u];let i=e,n=r,s=t;const a=[];e:for(;;){let t=this.reader.requestSlice(i.dataStartPos,i.dataSize);t instanceof Promise&&(t=yield t),p(t);const o=Tn(t,i.dataSize);for(;;){if(s===i.lacingValues.length){a.push(o.subarray(r,n));break}const e=i.lacingValues[s];if(n+=e,e<255){a.push(o.subarray(r,n));break e}s++}let l=i.headerStartPos+i.totalSize;for(;;){let t=this.reader.requestSliceRange(l,Si,vi);if(t instanceof Promise&&(t=yield t),!t)return null;const r=wi(t);if(!r)return null;if(i=r,i.serialNumber===e.serialNumber)break;l=i.headerStartPos+i.totalSize}r=0,n=0,s=0}const o=a.reduce((e,t)=>e+t.length,0);if(0===o)return null;const l=new Uint8Array(o);let c=0;for(let e=0;e<a.length;e++){const t=a[e];l.set(t,c),c+=t.length}return{data:l,endPage:i,endSegmentIndex:s}})}findNextPacketStart(e){return u(this,null,function*(){if(e.endSegmentIndex<e.endPage.lacingValues.length-1)return{startPage:e.endPage,startSegmentIndex:e.endSegmentIndex+1};if(!!(4&e.endPage.headerType))return null;let t=e.endPage.headerStartPos+e.endPage.totalSize;for(;;){let r=this.reader.requestSliceRange(t,Si,vi);if(r instanceof Promise&&(r=yield r),!r)return null;const i=wi(r);if(!i)return null;if(i.serialNumber===e.endPage.serialNumber)return{startPage:i,startSegmentIndex:0};t=i.headerStartPos+i.totalSize}})}getMimeType(){return u(this,null,function*(){yield this.readMetadata();return(e=>{let t="audio/ogg";e.codecStrings&&(t+=`; codecs="${[...new Set(e.codecStrings)].join(", ")}"`);return t})({codecStrings:(yield Promise.all(this.tracks.map(e=>e.getCodecParameterString()))).filter(Boolean)})})}getTracks(){return u(this,null,function*(){return yield this.readMetadata(),this.tracks})}computeDuration(){return u(this,null,function*(){const e=yield this.getTracks(),t=yield Promise.all(e.map(e=>e.computeDuration()));return Math.max(0,...t)})}getMetadataTags(){return u(this,null,function*(){return yield this.readMetadata(),this.metadataTags})}}class xi{constructor(e,t){this.bitstream=e,this.demuxer=t,this.encodedPacketToMetadata=new WeakMapLine truncated
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
var Bi,Ei;(Ei=Bi||(Bi={}))[Ei.PCM=1]="PCM",Ei[Ei.IEEE_FLOAT=3]="IEEE_FLOAT",Ei[Ei.ALAW=6]="ALAW",Ei[Ei.MULAW=7]="MULAW",Ei[Ei.EXTENSIBLE=65534]="EXTENSIBLE";class Fi extends ot{constructor(e){super(e),this.metadataPromise=null,this.dataStart=-1,this.dataSize=-1,this.audioInfo=null,this.tracks=[],this.lastKnownPacketIndex=0,this.metadataTags={},this.reader=e._reader}readMetadata(){return u(this,null,function*(){var e;return null!=(e=this.metadataPromise)?e:this.metadataPromise=(()=>u(this,null,function*(){var e,t;let r=this.reader.requestSlice(0,12);r instanceof Promise&&(r=yield r),p(r);const i=Nn(r,4),n="RIFX"!==i,s="RF64"===i,a=xn(r,n);let o=s?this.reader.fileSize:Math.min(a+8,null!=(e=this.reader.fileSize)?e:1/0);if("WAVE"!==Nn(r,4))throw new Error("Invalid WAVE file - wrong format");let l=0,c=null,u=r.filePos;for(;null===o||u<o;){let e=this.reader.requestSlice(u,8);if(e instanceof Promise&&(e=yield e),!e)break;const r=Nn(e,4),i=xn(e,n),a=e.filePos;if(s&&0===l&&"ds64"!==r)throw new Error('Invalid RF64 file: First chunk must be "ds64".');if("fmt "===r)yield this.parseFmtChunk(a,i,n);else if("data"===r){if(null!=c||(c=i),this.dataStart=e.filePos,this.dataSize=Math.min(c,(null!=o?o:1/0)-this.dataStart),null===this.reader.fileSize)break}else if("ds64"===r){let e=this.reader.requestSlice(a,i);if(e instanceof Promise&&(e=yield e),!e)break;const r=En(e,n);c=En(e,n),o=Math.min(r+8,null!=(t=this.reader.fileSize)?t:1/0)}else"LIST"===r?yield this.parseListChunk(a,i,n):"ID3 "!==r&&"id3 "!==r||(yield this.parseId3Chunk(a,i));u=a+i+(1&i),l++}if(!this.audioInfo)throw new Error('Invalid WAVE file - missing "fmt " chunk');if(-1===this.dataStart)throw new Error('Invalid WAVE file - missing "data" chunk');const d=this.audioInfo.blockSizeInBytes;this.dataSize=Math.floor(this.dataSize/d)*d,this.tracks.push(new Xt(this.input,new Ai(this)))}))()})}parseFmtChunk(e,t,r){return u(this,null,function*(){let i=this.reader.requestSlice(e,t);if(i instanceof Promise&&(i=yield i),!i)return;let n=vn(i,r);const s=vn(i,r),a=xn(i,r);i.skip(4);const o=vn(i,r);let l;if(l=14===t?8:vn(i,r),t>=18&&357!==n){const e=vn(i,r),s=t-18;if(Math.min(s,e)>=22&&n===Bi.EXTENSIBLE){i.skip(6);const e=Tn(i,16);n=e[0]|e[1]<<8}}n!==Bi.MULAW&&n!==Bi.ALAW||(l=8),this.audioInfo={format:n,numberOfChannels:s,sampleRate:a,sampleSizeInBytes:Math.ceil(l/8),blockSizeInBytes:o}})}parseListChunk(e,t,r){return u(this,null,function*(){var i,n,s,a,o,l,c,u,d,h,m;let f=this.reader.requestSlice(e,t);if(f instanceof Promise&&(f=yield f),!f)return;const p=Nn(f,4);if("INFO"!==p&&"INF0"!==p)return;let g=f.filePos;for(;g<=e+t-8;){f.filePos=g;const e=Nn(f,4),t=xn(f,r),p=Tn(f,t);let k=0;for(let r=0;r<p.length&&0!==p[r];r++)k++;const b=String.fromCharCode(...p.subarray(0,k));switch(null!=(i=this.metadataTags).raw||(i.raw={}),this.metadataTags.raw[e]=b,e){case"INAM":case"TITL":null!=(n=this.metadataTags).title||(n.title=b);break;case"TIT3":null!=(s=this.metadataTags).description||(s.description=b);break;case"IART":null!=(a=this.metadataTags).artist||(a.artist=b);break;case"IPRD":null!=(o=this.metadataTags).album||(o.album=b);break;case"IPRT":case"ITRK":case"TRCK":{const e=b.split("/"),t=Number.parseInt(e[0],10),r=e[1]&&Number.parseInt(e[1],10);Number.isInteger(t)&&t>0&&(null!=(l=this.metadataTags).trackNumber||(l.trackNumber=t)),r&&Number.isInteger(r)&&r>0&&(null!=(c=this.metadataTags).tracksTotal||(c.tracksTotal=r))}break;case"ICRD":case"IDIT":{const e=new Date(b);Number.isNaN(e.getTime())||null!=(u=this.metadataTags).date||(u.date=e)}break;case"YEAR":{const e=Number.parseInt(b,10);Number.isInteger(e)&&e>0&&(null!=(d=this.metadataTags).date||(d.date=new Date(e,0,1)))}break;case"IGNR":case"GENR":null!=(h=this.metadataTags).genre||(h.genre=b);break;case"ICMT":case"CMNT":case"COMM":null!=(m=this.metadataTags).comment||(m.comment=b)}g+=8+t+(1&t)}})}parseId3Chunk(e,t){return u(this,null,function*(){let r=this.reader.requestSlice(e,t);if(r instanceof Promise&&(r=yield r),!r)return;const i=di(r);if(i){const t=r.slice(e+10,i.size);hi(t,i,this.metadataTags)}})}getCodec(){if(p(this.audioInfo),this.audioInfo.format===Bi.MULAW)return"ulaw";if(this.audioInfo.format===Bi.ALAW)return"alaw";if(this.audioInfo.format===Bi.PCM){if(1===this.audioInfo.sampleSizeInBytes)return"pcm-u8";if(2===this.audioInfo.sampleSizeInBytes)return"pcm-s16";if(3===this.audioInfo.sampleSizeInBytes)return"pcm-s24";if(4===this.audioInfo.sampleSizeInBytes)return"pcm-s32"}return this.audioInfo.format===Bi.IEEE_FLOAT&&4===this.audioInfo.sampleSizeInBytes?"pcm-f32":null}getMimeType(){return u(this,null,function*(){return"audio/wav"})}computeDuration(){return u(this,null,function*(){yield this.readMetadata();const e=this.tracks[0];return p(e),e.computeDuration()})}getTracks(){return u(this,null,function*(){return yield this.readMetadata(),this.tracks})}getMetadataTags(){return u(this,null,function*(){return yield this.readMetadata(),this.metadataTags})}}const Di=2048;class Ai{constructor(e){this.demuxer=e}getId(){return 1}getCodec()Line truncated
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/const Ri=e=>{const t=e.filePos,r=Tn(e,9),i=new b(r);if(4095!==i.readBits(12))return null;i.skipBits(1);if(0!==i.readBits(2))return null;const n=i.readBits(1),s=i.readBits(2)+1,a=i.readBits(4);if(15===a)return null;i.skipBits(1);const o=i.readBits(3);if(0===o)throw new Error("ADTS frames with channel configuration 0 are not supported.");i.skipBits(1),i.skipBits(1),i.skipBits(1),i.skipBits(1);const l=i.readBits(13);i.skipBits(11);const c=i.readBits(2)+1;if(1!==c)throw new Error("ADTS frames with more than one AAC frame are not supported.");let u=null;return 1===n?e.filePos-=2:u=i.readBits(16),{objectType:s,samplingFrequencyIndex:a,channelConfiguration:o,frameLength:l,numberOfAacFrames:c,crcCheck:u,startPos:t}},Mi=1024;class Ni extends ot{constructor(e){super(e),this.metadataPromise=null,this.firstFrameHeader=null,this.loadedSamples=[],this.tracks=[],this.readingMutex=new D,this.lastSampleLoaded=!1,this.lastLoadedPos=0,this.nextTimestampInSamples=0,this.reader=e._reader}readMetadata(){return u(this,null,function*(){var e;return null!=(e=this.metadataPromise)?e:this.metadataPromise=(()=>u(this,null,function*(){for(;!this.firstFrameHeader&&!this.lastSampleLoaded;)yield this.advanceReader();p(this.firstFrameHeader),this.tracks=[new Xt(this.input,new zi(this))]}))()})}advanceReader(){return u(this,null,function*(){let e=this.reader.requestSliceRange(this.lastLoadedPos,7,9);if(e instanceof Promise&&(e=yield e),!e)return void(this.lastSampleLoaded=!0);const t=Ri(e);if(!t)return void(this.lastSampleLoaded=!0);if(null!==this.reader.fileSize&&t.startPos+t.frameLength>this.reader.fileSize)return void(this.lastSampleLoaded=!0);this.firstFrameHeader||(this.firstFrameHeader=t);const r=we[t.samplingFrequencyIndex];p(void 0!==r);const i=Mi/r,n=t.crcCheck?9:7,s={timestamp:this.nextTimestampInSamples/r,duration:i,dataStart:t.startPos+n,dataSize:t.frameLength-n};this.loadedSamples.push(s),this.nextTimestampInSamples+=Mi,this.lastLoadedPos=t.startPos+t.frameLength})}getMimeType(){return u(this,null,function*(){return"audio/aac"})}getTracks(){return u(this,null,function*(){return yield this.readMetadata(),this.tracks})}computeDuration(){return u(this,null,function*(){yield this.readMetadata();const e=this.tracks[0];return p(e),e.computeDuration()})}getMetadataTags(){return u(this,null,function*(){return{}})}}class zi{constructor(e){this.demuxer=e}getId(){return 1}getFirstTimestamp(){return u(this,null,function*(){return 0})}getTimeResolution(){return this.getSampleRate()/Mi}computeDuration(){return u(this,null,function*(){var e,t;const r=yield this.getPacket(1/0,{metadataOnly:!0});return(null!=(e=null==r?void 0:r.timestamp)?e:0)+(null!=(t=null==r?void 0:r.duration)?t:0)})}getName(){return null}getLanguageCode(){return $}getCodec(){return"aac"}getInternalCodecId(){return p(this.demuxer.firstFrameHeader),this.demuxer.firstFrameHeader.objectType}getNumberOfChannels(){p(this.demuxer.firstFrameHeader);const e=Ie[this.demuxer.firstFrameHeader.channelConfiguration];return p(void 0!==e),e}getSampleRate(){p(this.demuxer.firstFrameHeader);const e=we[this.demuxer.firstFrameHeader.samplingFrequencyIndex];return p(void 0!==e),e}getDisposition(){return c({},ge)}getDecoderConfig(){return u(this,null,function*(){p(this.demuxer.firstFrameHeader);const e=new Uint8Array(3),t=new b(e),{objectType:r,samplingFrequencyIndex:i,channelConfiguration:n}=this.demuxer.firstFrameHeader;return r>31?(t.writeBits(5,31),t.writeBits(6,r-32)):t.writeBits(5,r),t.writeBits(4,i),t.writeBits(4,n),{codec:`mp4a.40.${this.demuxer.firstFrameHeader.objectType}`,numberOfChannels:this.getNumberOfChannels(),sampleRate:this.getSampleRate(),description:e.subarray(0,Math.ceil((t.pos-1)/8))}})}getPacketAtIndex(e,t){return u(this,null,function*(){if(-1===e)return null;const r=this.demuxer.loadedSamples[e];if(!r)return null;let i;if(t.metadataOnly)i=ut;else{let e=this.demuxer.reader.requestSlice(r.dataStart,r.dataSize);if(e instanceof Promise&&(e=yield e),!e)return null;i=Tn(e,r.dataSize)}return new dt(i,"key",r.timestamp,r.duration,e,r.dataSize)})}getFirstPacket(e){return this.getPacketAtIndex(0,e)}getNextPacket(e,t){return u(this,null,function*(){const r=yield this.demuxer.readingMutex.acquire();try{const r=M(this.demuxer.loadedSamples,e.timestamp,e=>e.timestamp);if(-1===r)throw new Error("Packet was not created from this track.");const i=r+1;for(;i>=this.demuxer.loadedSamples.length&&!this.demuxer.lastSampleLoaded;)yield this.demuxer.advanceReader();return this.getPacketAtIndex(i,t)}finally{r()}})}getPacket(e,t){return u(this,null,function*(){const r=yield this.demuxer.readingMutex.acquire();try{for(;;){const r=N(this.demuxer.loadedSamples,e,e=>e.timestamp);if(-1===r&&this.demuxer.loadedSamples.length>0)return null;if(this.demuxer.lastSampleLoaded)return this.getPacketAtIndex(r,t);if(r>=0&&r+1<this.demuxer.loadedSamples.length)return this.getPacketAtIndex(r,t);yield this.demuxer.advanceReader()}}finally{r()}})}getKeyPacket(e,t){return this.getPacket(e,t)}getNextKeyPacket(e,Line truncated
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
class Oi extends ot{constructor(e){super(e),this.loadedSamples=[],this.metadataPromise=null,this.track=null,this.metadataTags={},this.audioInfo=null,this.lastLoadedPos=null,this.blockingBit=null,this.readingMutex=new D,this.lastSampleLoaded=!1,this.reader=e._reader}computeDuration(){return u(this,null,function*(){return yield this.readMetadata(),p(this.track),this.track.computeDuration()})}getMetadataTags(){return u(this,null,function*(){return yield this.readMetadata(),this.metadataTags})}getTracks(){return u(this,null,function*(){return yield this.readMetadata(),p(this.track),[this.track]})}getMimeType(){return u(this,null,function*(){return"audio/flac"})}readMetadata(){return u(this,null,function*(){var e;let t=4;return null!=(e=this.metadataPromise)?e:this.metadataPromise=(()=>u(this,null,function*(){for(var e;null===this.reader.fileSize||t<this.reader.fileSize;){let r=this.reader.requestSlice(t,4);if(r instanceof Promise&&(r=yield r),t+=4,null===r)throw new Error(`Metadata block at position ${t} is too small! Corrupted file.`);p(r);const i=Sn(r),n=In(r),s=0!==(128&i);switch(127&i){case nt.STREAMINFO:{let e=this.reader.requestSlice(t,n);if(e instanceof Promise&&(e=yield e),p(e),null===e)throw new Error(`StreamInfo block at position ${t} is too small! Corrupted file.`);const r=Tn(e,34),i=new b(r),s=i.readBits(16),a=i.readBits(16),o=i.readBits(24),l=i.readBits(24),c=i.readBits(20),u=i.readBits(3)+1;i.readBits(5);const d=i.readBits(36);i.skipBits(128);const h=new Uint8Array(42);h.set(new Uint8Array([102,76,97,67]),0),h.set(new Uint8Array([128,0,0,34]),4),h.set(r,8),this.audioInfo={numberOfChannels:u,sampleRate:c,totalSamples:d,minimumBlockSize:s,maximumBlockSize:a,minimumFrameSize:o,maximumFrameSize:l,description:h},this.track=new Xt(this.input,new Li(this));break}case nt.VORBIS_COMMENT:{let e=this.reader.requestSlice(t,n);e instanceof Promise&&(e=yield e),p(e),at(Tn(e,n),this.metadataTags);break}case nt.PICTURE:{let r=this.reader.requestSlice(t,n);r instanceof Promise&&(r=yield r),p(r);const i=Cn(r),s=Cn(r),a=w.decode(Tn(r,s)),o=Cn(r),l=w.decode(Tn(r,o));r.skip(16);const c=Cn(r),u=Tn(r,c);null!=(e=this.metadataTags).images||(e.images=[]),this.metadataTags.images.push({data:u,mimeType:a,kind:3===i?"coverFront":4===i?"coverBack":"unknown",description:l});break}}if(t+=n,s){this.lastLoadedPos=t;break}}}))()})}readNextFlacFrame(e){return u(this,arguments,function*({startPos:e,isFirstPacket:t}){p(this.audioInfo);const r=this.audioInfo.maximumFrameSize+16,i=yield this.reader.requestSliceRange(e,this.audioInfo.minimumFrameSize,r);if(!i)return null;const n=this.readFlacFrameHeader({slice:i,isFirstPacket:t});if(!n)return null;for(i.filePos=e+this.audioInfo.minimumFrameSize;;){if(i.filePos>i.end-6)return{num:n.num,blockSize:n.blockSize,sampleRate:n.sampleRate,size:i.end-e,isLastFrame:!0};if(255===Sn(i)){const t=i.filePos;if(Sn(i)!==(1===this.blockingBit?249:248)){i.filePos=t;continue}i.skip(-2);const r=i.filePos-e,s=this.readFlacFrameHeader({slice:i,isFirstPacket:!1});if(!s){i.filePos=t;continue}if(0===this.blockingBit){if(s.num-n.num!==1){i.filePos=t;continue}}else if(s.num-n.num!==n.blockSize){i.filePos=t;continue}return{num:n.num,blockSize:n.blockSize,sampleRate:n.sampleRate,size:r,isLastFrame:!1}}}})}readFlacFrameHeader({slice:e,isFirstPacket:t}){const r=e.filePos,i=Tn(e,4),n=new b(i);if(32764!==n.readBits(15))return null;if(null===this.blockingBit){p(t);const e=n.readBits(1);this.blockingBit=e}else if(1===this.blockingBit){p(!t);if(1!==n.readBits(1))return null}else{if(0!==this.blockingBit)throw new Error("Invalid blocking bit");p(!t);if(0!==n.readBits(1))return null}const s=(e=>0===e?null:1===e?192:e>=2&&e<=5?144*o(2,e):6===e?"uncommon-u8":7===e?"uncommon-u16":e>=8&&e<=15?o(2,e):null)(n.readBits(4));if(!s)return null;p(this.audioInfo);const a=((e,t)=>{switch(e){case 0:return t;case 1:return 88200;case 2:return 176400;case 3:return 192e3;case 4:return 8e3;case 5:return 16e3;case 6:return 22050;case 7:return 24e3;case 8:return 32e3;case 9:return 44100;case 10:return 48e3;case 11:return 96e3;case 12:return"uncommon-u8";case 13:return"uncommon-u16";case 14:return"uncommon-u16-10";default:return null}})(n.readBits(4),this.audioInfo.sampleRate);if(!a)return null;n.readBits(4),n.readBits(3);if(0!==n.readBits(1))return null;const l=(e=>{let t=0;const r=new b(Tn(e,1));for(;1===r.readBits(1);)t++;if(0===t)return r.readBits(7);const i=[],n=t-1,s=new b(Tn(e,n)),a=8-t-1;for(let o=0;o<a;o++)i.unshift(r.readBits(1));for(let o=0;o<n;o++)for(let e=0;e<8;e++){const t=s.readBits(1);e<2||i.unshift(t)}return i.reduce((e,t,r)=>e|t<<r,0)})(e),c=((e,t)=>"uncommon-u16"===t?wn(e)+1:"uncommon-u8"===t?Sn(e)+1:"number"===typeof t?t:(q(t),void p(!1)))(e,s),u=((e,t)=>"uncommon-u16"===t?wn(e):"uncommon-u16-10"===t?10*wn(e):"uncommon-u8"===t?Sn(e):"number"===typeof t?t:null)(e,a);if(null===u)return null;if(u!==this.audioInfo.sampleRate)return null;const d=e.filePos-r,h=Sn(e);e.skip(-d),e.skip(-1);const m=(e=>{let t=0;for(const r of e){t^=r;fLine truncated
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/class Ui{}class Vi extends Ui{_getMajorBrand(e){return u(this,null,function*(){let t=e._reader.requestSlice(0,12);if(t instanceof Promise&&(t=yield t),!t)return null;t.skip(4);return"ftyp"!==Nn(t,4)?null:Nn(t,4)})}_createDemuxer(e){return new ir(e)}}class qi extends Vi{_canReadInput(e){return u(this,null,function*(){const t=yield this._getMajorBrand(e);return!!t&&"qt "!==t})}get name(){return"MP4"}get mimeType(){return"video/mp4"}}class Hi extends Vi{_canReadInput(e){return u(this,null,function*(){return"qt "===(yield this._getMajorBrand(e))})}get name(){return"QuickTime File Format"}get mimeType(){return"video/quicktime"}}class Wi extends Ui{isSupportedEBMLOfDocType(e,t){return u(this,null,function*(){let r=e._reader.requestSlice(0,yr);if(r instanceof Promise&&(r=yield r),!r)return!1;const i=Tr(r);if(null===i)return!1;if(i<1||i>8)return!1;if(vr(r,i)!==fr.EBML)return!1;const n=Ir(r);if("number"!==typeof n)return!1;let s=e._reader.requestSlice(r.filePos,n);if(s instanceof Promise&&(s=yield s),!s)return!1;const a=r.filePos;for(;s.filePos<=a+n-2;){const e=Pr(s);if(!e)break;const{id:r,size:i}=e,n=s.filePos;if(void 0===i)return!1;switch(r){case fr.EBMLVersion:if(1!==vr(s,i))return!1;break;case fr.EBMLReadVersion:if(1!==vr(s,i))return!1;break;case fr.DocType:if(xr(s,i)!==t)return!1;break;case fr.DocTypeVersion:if(vr(s,i)>4)return!1}s.filePos=n+i}return!0})}_canReadInput(e){return this.isSupportedEBMLOfDocType(e,"matroska")}_createDemuxer(e){return new Xr(e)}get name(){return"Matroska"}get mimeType(){return"video/x-matroska"}}class ji extends Wi{_canReadInput(e){return this.isSupportedEBMLOfDocType(e,"webm")}get name(){return"WebM"}get mimeType(){return"video/webm"}}class Ki extends Ui{_canReadInput(e){return u(this,null,function*(){let t=e._reader.requestSlice(0,10);if(t instanceof Promise&&(t=yield t),!t)return!1;let r=0,i=!1;for(;;){let t=e._reader.requestSlice(r,10);if(t instanceof Promise&&(t=yield t),!t)break;const n=di(t);if(!n)break;i=!0,r=t.filePos+n.size}const n=yield fi(e._reader,r,r+4096);if(!n)return!1;if(i)return!0;r=n.startPos+n.header.totalSize;const s=yield fi(e._reader,r,r+4);if(!s)return!1;const a=n.header,o=s.header;return a.channel===o.channel&&a.sampleRate===o.sampleRate})}_createDemuxer(e){return new pi(e)}get name(){return"MP3"}get mimeType(){return"audio/mpeg"}}class $i extends Ui{_canReadInput(e){return u(this,null,function*(){let t=e._reader.requestSlice(0,12);if(t instanceof Promise&&(t=yield t),!t)return!1;const r=Nn(t,4);if("RIFF"!==r&&"RIFX"!==r&&"RF64"!==r)return!1;t.skip(4);return"WAVE"===Nn(t,4)})}_createDemuxer(e){return new Fi(e)}get name(){return"WAVE"}get mimeType(){return"audio/wav"}}class Qi extends Ui{_canReadInput(e){return u(this,null,function*(){let t=e._reader.requestSlice(0,4);return t instanceof Promise&&(t=yield t),!!t&&"OggS"===Nn(t,4)})}_createDemuxer(e){return new Pi(e)}get name(){return"Ogg"}get mimeType(){return"application/ogg"}}class Gi extends Ui{_canReadInput(e){return u(this,null,function*(){let t=e._reader.requestSlice(0,4);return t instanceof Promise&&(t=yield t),!!t&&"fLaC"===Nn(t,4)})}get name(){return"FLAC"}get mimeType(){return"audio/flac"}_createDemuxer(e){return new Oi(e)}}class Xi extends Ui{_canReadInput(e){return u(this,null,function*(){let t=e._reader.requestSliceRange(0,7,9);if(t instanceof Promise&&(t=yield t),!t)return!1;const r=Ri(t);if(!r)return!1;if(t=e._reader.requestSliceRange(r.frameLength,7,9),t instanceof Promise&&(t=yield t),!t)return!1;const i=Ri(t);return!!i&&(r.objectType===i.objectType&&r.samplingFrequencyIndex===i.samplingFrequencyIndex&&r.channelConfiguration===i.channelConfiguration)})}_createDemuxer(e){return new Ni(e)}get name(){return"ADTS"}get mimeType(){return"audio/aac"}}const Yi=new qi,Ji=new Hi,Zi=new Wi,en=new ji,tn=new Ki,rn=new $i,nn=new Qi,sn=new Xi,an=[Yi,Ji,Zi,en,rn,nn,new Gi,tn,sn];
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
class on{constructor(){this._disposed=!1,this._sizePromise=null,this.onread=null}getSizeOrNull(){return u(this,null,function*(){var e;if(this._disposed)throw new gn;return null!=(e=this._sizePromise)?e:this._sizePromise=Promise.resolve(this._retrieveSize())})}getSize(){return u(this,null,function*(){if(this._disposed)throw new gn;const e=yield this.getSizeOrNull();if(null===e)throw new Error("Cannot determine the size of an unsized source.");return e})}}class ln extends on{constructor(e,t={}){var r;if(!(e instanceof Blob))throw new TypeError("blob must be a Blob.");if(!t||"object"!==typeof t)throw new TypeError("options must be an object.");if(void 0!==t.maxCacheSize&&(!me(t.maxCacheSize)||t.maxCacheSize<0))throw new TypeError("options.maxCacheSize, when provided, must be a non-negative number.");super(),this._readers=new WeakMap,this._blob=e,this._orchestrator=new fn({maxCacheSize:null!=(r=t.maxCacheSize)?r:8*o(2,20),maxWorkerCount:4,runWorker:this._runWorker.bind(this),prefetchProfile:mn.fileSystem})}_retrieveSize(){const e=this._blob.size;return this._orchestrator.fileSize=e,e}_read(e,t){return this._orchestrator.read(e,t)}_runWorker(e){return u(this,null,function*(){var t,r;let i=this._readers.get(e);if(void 0===i){if("stream"in this._blob&&!ie()){i=this._blob.slice(e.currentPos).stream().getReader()}else i=null;this._readers.set(e,i)}for(;e.currentPos<e.targetPos&&!e.aborted;)if(i){const{done:r,value:n}=yield i.read();if(r)throw this._orchestrator.forgetWorker(e),new Error("Blob reader stopped unexpectedly before all requested data was read.");if(e.aborted)break;null==(t=this.onread)||t.call(this,e.currentPos,e.currentPos+n.length),this._orchestrator.supplyWorkerData(e,n)}else{const t=yield this._blob.slice(e.currentPos,e.targetPos).arrayBuffer();if(e.aborted)break;null==(r=this.onread)||r.call(this,e.currentPos,e.currentPos+t.byteLength),this._orchestrator.supplyWorkerData(e,new Uint8Array(t))}e.running=!1,e.aborted&&(yield null==i?void 0:i.cancel())})}_dispose(){this._orchestrator.dispose()}}const cn=.5*o(2,20),un=(e,t,r)=>{if(t instanceof Error&&(t.message.includes("Failed to fetch")||t.message.includes("Load failed")||t.message.includes("NetworkError when attempting to fetch resource"))){let e=null;try{"undefined"!==typeof window&&"undefined"!==typeof window.location&&(e=new URL(r instanceof Request?r.url:r,window.location.href).origin)}catch(i){}if(("undefined"===typeof navigator||"boolean"!==typeof navigator.onLine||navigator.onLine)&&null!==e&&e!==window.location.origin)return console.warn("Request will not be retried because a CORS error was suspected due to different origins. You can modify this behavior by providing your own function for the 'getRetryDelay' option."),null}return Math.min(o(2,e-2),16)};class dn extends on{constructor(e,t={}){var r,i;if("string"!==typeof e&&!(e instanceof URL)&&!("undefined"!==typeof Request&&e instanceof Request))throw new TypeError("url must be a string, URL or Request.");if(!t||"object"!==typeof t)throw new TypeError("options must be an object.");if(void 0!==t.requestInit&&(!t.requestInit||"object"!==typeof t.requestInit))throw new TypeError("options.requestInit, when provided, must be an object.");if(void 0!==t.getRetryDelay&&"function"!==typeof t.getRetryDelay)throw new TypeError("options.getRetryDelay, when provided, must be a function.");if(void 0!==t.maxCacheSize&&(!me(t.maxCacheSize)||t.maxCacheSize<0))throw new TypeError("options.maxCacheSize, when provided, must be a non-negative number.");if(void 0!==t.fetchFn&&"function"!==typeof t.fetchFn)throw new TypeError("options.fetchFn, when provided, must be a function.");super(),this._existingResponses=new WeakMap,this._url=e,this._options=t,this._getRetryDelay=null!=(r=t.getRetryDelay)?r:un,this._orchestrator=new fn({maxCacheSize:null!=(i=t.maxCacheSize)?i:64*o(2,20),maxWorkerCount:2,runWorker:this._runWorker.bind(this),prefetchProfile:mn.network})}_retrieveSize(){return u(this,null,function*(){var e,t;const r=new AbortController,i=yield ee(null!=(e=this._options.fetchFn)?e:fetch,this._url,J(null!=(t=this._options.requestInit)?t:{},{headers:{Range:"bytes=0-"},signal:r.signal}),this._getRetryDelay,()=>this._disposed);if(!i.ok)throw new Error(`Error fetching ${String(this._url)}: ${i.status} ${i.statusText}`);let n,s;if(206===i.status)s=this._getTotalLengthFromRangeResponse(i),n=this._orchestrator.createWorker(0,Math.min(s,cn));else{const e=i.headers.get("Content-Length");if(!e)throw new Error(`HTTP response (status ${i.status}) must surface Content-Length header.`);s=Number(e),n=this._orchestrator.createWorker(0,s),this._orchestrator.options.maxCacheSize=1/0,console.warn("HTTP server did not respond with 206 Partial Content, meaning the entire remote resource now has to be downloaded. For efficient media file streaming across a network, please make sure your server supports range requests.")}return this._orchestrator.fileSize=s,this._existingResponses.set(n,{response:i,abortController:r}),this._orchestratLine truncated
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/he();class pn{get disposed(){return this._disposed}constructor(e){if(this._demuxerPromise=null,this._format=null,this._disposed=!1,!e||"object"!==typeof e)throw new TypeError("options must be an object.");if(!Array.isArray(e.formats)||e.formats.some(e=>!(e instanceof Ui)))throw new TypeError("options.formats must be an array of InputFormat.");if(!(e.source instanceof on))throw new TypeError("options.source must be a Source.");if(e.source._disposed)throw new Error("options.source must not be disposed.");this._formats=e.formats,this._source=e.source,this._reader=new kn(e.source)}_getDemuxer(){var e;return null!=(e=this._demuxerPromise)?e:this._demuxerPromise=(()=>u(this,null,function*(){this._reader.fileSize=yield this._source.getSizeOrNull();for(const e of this._formats){if(yield e._canReadInput(this))return this._format=e,e._createDemuxer(this)}throw new Error("Input has an unsupported or unrecognizable format.")}))()}get source(){return this._source}getFormat(){return u(this,null,function*(){return yield this._getDemuxer(),p(this._format),this._format})}computeDuration(){return u(this,null,function*(){return(yield this._getDemuxer()).computeDuration()})}getTracks(){return u(this,null,function*(){return(yield this._getDemuxer()).getTracks()})}getVideoTracks(){return u(this,null,function*(){return(yield this.getTracks()).filter(e=>e.isVideoTrack())})}getAudioTracks(){return u(this,null,function*(){return(yield this.getTracks()).filter(e=>e.isAudioTrack())})}getPrimaryVideoTrack(){return u(this,null,function*(){var e;return null!=(e=(yield this.getTracks()).find(e=>e.isVideoTrack()))?e:null})}getPrimaryAudioTrack(){return u(this,null,function*(){var e;return null!=(e=(yield this.getTracks()).find(e=>e.isAudioTrack()))?e:null})}getMimeType(){return u(this,null,function*(){return(yield this._getDemuxer()).getMimeType()})}getMetadataTags(){return u(this,null,function*(){return(yield this._getDemuxer()).getMetadataTags()})}dispose(){this._disposed||(this._disposed=!0,this._source._disposed=!0,this._source._dispose())}[Symbol.dispose](){this.dispose()}}class gn extends Error{constructor(e="Input has been disposed."){super(e),this.name="InputDisposedError"}}
/*!
* Copyright (c) 2025-present, Vanilagy and contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/class kn{constructor(e){this.source=e}requestSlice(e,t){if(this.source._disposed)throw new gn;if(null!==this.fileSize&&e+t>this.fileSize)return null;const r=e+t,i=this.source._read(e,r);return i instanceof Promise?i.then(t=>t?new bn(t.bytes,t.view,t.offset,e,r):null):i?new bn(i.bytes,i.view,i.offset,e,r):null}requestSliceRange(e,t,r){if(this.source._disposed)throw new gn;if(null!==this.fileSize)return this.requestSlice(e,K(this.fileSize-e,t,r));{const i=this.requestSlice(e,r),n=i=>{if(i)return i;const n=i=>(p(null!==i),this.requestSlice(e,K(i-e,t,r))),s=this.source._retrieveSize();return s instanceof Promise?s.then(n):n(s)};return i instanceof Promise?i.then(n):n(i)}}}class bn{constructor(e,t,r,i,n){this.bytes=e,this.view=t,this.offset=r,this.start=i,this.end=n,this.bufferPos=i-r}static tempFromBytes(e){return new bn(e,v(e),0,0,e.length)}get length(){return this.end-this.start}get filePos(){return this.offset+this.bufferPos}set filePos(e){this.bufferPos=e-this.offset}get remainingLength(){return Math.max(this.end-this.filePos,0)}skip(e){this.bufferPos+=e}slice(e,t=this.end-e){if(e<this.start||e+t>this.end)throw new RangeError("Slicing outside of original slice.");return new bn(this.bytes,this.view,this.offset,e,e+t)}}const yn=(e,t)=>{if(e.filePos<e.start||e.filePos+t>e.end)throw new RangeError(`Tried reading [${e.filePos}, ${e.filePos+t}), but slice is [${e.start}, ${e.end}). This is likely an internal error, please report it alongside the file that caused it.`)},Tn=(e,t)=>{yn(e,t);const r=e.bytes.subarray(e.bufferPos,e.bufferPos+t);return e.bufferPos+=t,r},Sn=e=>(yn(e,1),e.view.getUint8(e.bufferPos++)),vn=(e,t)=>{yn(e,2);const r=e.view.getUint16(e.bufferPos,t);return e.bufferPos+=2,r},wn=e=>{yn(e,2);const t=e.view.getUint16(e.bufferPos,!1);return e.bufferPos+=2,t},In=e=>{yn(e,3);const t=H(e.view,e.bufferPos,!1);return e.bufferPos+=3,t},Pn=e=>{yn(e,2);const t=e.view.getInt16(e.bufferPos,!1);return e.bufferPos+=2,t},xn=(e,t)=>{yn(e,4);const r=e.view.getUint32(e.bufferPos,t);return e.bufferPos+=4,r},Cn=e=>{yn(e,4);const t=e.view.getUint32(e.bufferPos,!1);return e.bufferPos+=4,t},_n=e=>{yn(e,4);const t=e.view.getUint32(e.bufferPos,!0);return e.bufferPos+=4,t},Bn=e=>{yn(e,4);const t=e.view.getInt32(e.bufferPos,!1);return e.bufferPos+=4,t},En=(e,t)=>{let r,i;return t?(r=xn(e,!0),i=xn(e,!0)):(i=xn(e,!1),r=xn(e,!1)),4294967296*i+r},Fn=e=>4294967296*Cn(e)+Cn(e),Dn=e=>4294967296*Bn(e)+Cn(e),An=e=>{const t=_n(e),r=(e=>{yn(e,4);const t=e.view.getInt32(e.bufferPos,!0);return e.bufferPos+=4,t})(e);return 4294967296*r+t},Rn=e=>{yn(e,4);const t=e.view.getFloat32(e.bufferPos,!1);return e.bufferPos+=4,t},Mn=e=>{yn(e,8);const t=e.view.getFloat64(e.bufferPos,!1);return e.bufferPos+=8,t},Nn=(e,t)=>{yn(e,t);let r="";for(let i=0;i<t;i++)r+=String.fromCharCode(e.bytes[e.bufferPos++]);return r};class zn{constructor(e){this.events=e,this.input=null,this.audioSink=null,this.audioIterator=null,this.audioContext=null,this.gainNode=null,this.audioContextStartTime=0,this.playbackTimeAtStart=0,this.latestScheduledEndTime=0,this.duration=Number.NaN,this.paused=!0,this.volume=.7,this.muted=!1,this.playbackRate=1,this.asyncId=0,this.queuedNodes=new Set}get currentTime(){return this.paused?this.playbackTimeAtStart:(this.audioContext.currentTime-this.audioContextStartTime)*this.playbackRate+this.playbackTimeAtStart}normalizeSource(e){return"string"===typeof e?new dn(e):e instanceof Blob?new ln(e):"undefined"!==typeof ReadableStream&&e instanceof ReadableStream?new hn(e):e}ensureAudioContext(e){if(this.audioContext)return;const t=window.AudioContext||window.webkitAudioContext;try{this.audioContext=new t({sampleRate:e})}catch(r){this.audioContext=new t}this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination),this.updateGain()}updateGain(){if(!this.gainNode)return;const e=this.muted?0:this.volume;this.gainNode.gain.value=e*e}stopQueuedNodes(){this.queuedNodes.forEach(e=>e.stop()),this.queuedNodes.clear()}stopIterator(){return u(this,null,function*(){var e;yield null==(e=this.audioIterator)?void 0:e.return(),this.audioIterator=null})}load(e,t){return u(this,null,function*(){const r=++this.asyncId;yield this.stopIterator(),this.stopQueuedNodes(),this.paused=!0,this.playbackTimeAtStart=0,this.audioContextStartTime=0;const i=this.normalizeSource(e);if(!i)return;if(this.input=new pn({source:i,formats:an}),this.duration=yield this.input.computeDuration(),r!==this.asyncId)return;const n=yield this.input.getPrimaryAudioTrack();return n&&null!==n.codec&&(yield n.canDecode())?(this.ensureAudioContext(n.sampleRate),this.audioSink=new $t(n),void(null==t||t())):(this.audioSink=null,this.ensureAudioContext(),void(null==t||t()))})}runIterator(e){return u(this,null,function*(){if(this.audioSink)for(yield this.stopIterator(),this.audioIterator=this.audioSink.buffers(this.currentTime);;){if(e!==this.asyncId||this.paused)return;const r=this.audioIterator.next(),i=setInterval(()=>{e!==this.asyncId||this.paused?clearIntLine truncated
!function(e,t){"object"===typeof exports&&"undefined"!==typeof module?module.exports=t():"function"==typeof define&&define.amd?(t.ArtplayerProxyMediabunny=t(),define(function(){return t.ArtplayerProxyMediabunny})):(e="undefined"!==typeof globalThis?globalThis:e||self).ArtplayerProxyMediabunny=t()}(this,function(){"use strict";var e=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,a=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),o=Math.pow,l=(t,r,i)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[r]=i,c=(e,t)=>{for(var r in t||(t={}))n.call(t,r)&&l(e,r,t[r]);if(i)for(var r of i(t))s.call(t,r)&&l(e,r,t[r]);return e},u=(e,t,r)=>new Promise((i,n)=>{var s=e=>{try{o(r.next(e))}catch(t){n(t)}},a=e=>{try{o(r.throw(e))}catch(t){n(t)}},o=e=>e.done?i(e.value):Promise.resolve(e.value).then(s,a);o((r=r.apply(e,t)).next())}),d=function(e,t){this[0]=e,this[1]=t},h=e=>{var t,r=e[a("asyncIterator")],i=!1,n={};return null==r?(r=e[a("iterator")](),t=e=>n[e]=t=>r[e](t)):(r=r.call(e),t=e=>n[e]=t=>{if(i){if(i=!1,"throw"===e)throw t;return t}return i=!0,{done:!1,value:new d(new Promise(i=>{var n=r[e](t);n instanceof Object||(e=>{throw TypeError(e)})("Object expected"),i(n)}),1)}}),n[a("iterator")]=()=>n,t("next"),"throw"in r?t("throw"):n.throw=e=>{throw e},"return"in r&&t("return"),n},m=(e,t,r)=>(t=e[a("asyncIterator")])?t.call(e):(e=e[a("iterator")](),t={},(r=(r,i)=>(i=e[r])&&(t[r]=t=>new Promise((r,n,s)=>(t=i.call(e,t),s=t.done,Promise.resolve(t.value).then(e=>r({value:e,done:s}),n)))))("next"),r("return"),t);class f{constructor(){this.listeners=new Map}addEventListener(e,t){this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t)}removeEventListener(e,t){const r=this.listeners.get(e);if(!r)return;const i=r.indexOf(t);i>=0&&r.splice(i,1)}emit(e,t){const r=new Event(e);r.detail=t;const i=this.listeners.get(e);i&&i.forEach(e=>e(r))}}function p(e){if(!e)throw new Error("Assertion failed.")}const g=e=>{const t=(e%360+360)%360;if(0===t||90===t||180===t||270===t)return t;throw new Error(`Invalid rotation ${e}.`)},k=e=>e&&e[e.length-1];class b{constructor(e){this.bytes=e,this.pos=0}seekToByte(e){this.pos=8*e}readBit(){var e;const t=Math.floor(this.pos/8),r=null!=(e=this.bytes[t])?e:0,i=7-(7&this.pos),n=(r&1<<i)>>i;return this.pos++,n}readBits(e){if(1===e)return this.readBit();let t=0;for(let r=0;r<e;r++)t<<=1,t|=this.readBit();return t}writeBits(e,t){const r=this.pos+e;for(let i=this.pos;i<r;i++){const e=Math.floor(i/8);let n=this.bytes[e];const s=7-(7&i);n&=~(1<<s),n|=(t&1<<r-i-1)>>r-i-1<<s,this.bytes[e]=n}this.pos=r}readAlignedByte(){var e;if(this.pos%8!==0)throw new Error("Bitstream is not byte-aligned.");const t=this.pos/8,r=null!=(e=this.bytes[t])?e:0;return this.pos+=8,r}skipBits(e){this.pos+=e}getBitsLeft(){return 8*this.bytes.length-this.pos}clone(){const e=new b(this.bytes);return e.pos=this.pos,e}}const y=e=>{let t=0;for(;0===e.readBits(1)&&t<32;)t++;if(t>=32)throw new Error("Invalid exponential-Golomb code.");return(1<<t)-1+e.readBits(t)},T=e=>{const t=y(e);return 0===(1&t)?-(t>>1):t+1>>1},S=e=>e.constructor===Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e),v=e=>e.constructor===DataView?e:ArrayBuffer.isView(e)?new DataView(e.buffer,e.byteOffset,e.byteLength):new DataView(e),w=new TextDecoder,I=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[t,e])),P={bt709:1,bt470bg:5,smpte170m:6,bt2020:9,smpte432:12},x=I(P),C={bt709:1,smpte170m:6,linear:8,"iec61966-2-1":13,pq:16,hlg:18},_=I(C),B={rgb:0,bt709:1,bt470bg:5,smpte170m:6,"bt2020-ncl":9},E=I(B),F=e=>e instanceof ArrayBuffer||"undefined"!==typeof SharedArrayBuffer&&e instanceof SharedArrayBuffer||ArrayBuffer.isView(e);class D{constructor(){this.currentPromise=Promise.resolve()}acquire(){return u(this,null,function*(){let e;const t=new Promise(t=>{e=t}),r=this.currentPromise;return this.currentPromise=t,yield r,e})}}const A=e=>[...e].map(e=>e.toString(16).padStart(2,"0")).join(""),R=e=>(e=(e=(e=(e=(e=e>>1&1431655765|(1431655765&e)<<1)>>2&858993459|(858993459&e)<<2)>>4&252645135|(252645135&e)<<4)>>8&16711935|(16711935&e)<<8)>>16&65535|(65535&e)<<16)>>>0,M=(e,t,r)=>{let i=0,n=e.length-1,s=-1;for(;i<=n;){const a=i+n>>1,o=r(e[a]);o===t?(s=a,n=a-1):o<t?i=a+1:n=a-1}return s},N=(e,t,r)=>{let i=0,n=e.length-1,s=-1;for(;i<=n;){const a=i+(n-i+1)/2|0;r(e[a])<=t?(s=a,i=a+1):n=a-1}return s},z=(e,t,r)=>{const i=N(e,r(t),r);e.splice(i+1,0,t)},O=()=>{let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}},L=(e,t)=>{for(let r=e.length-1;r>=0;r--)if(t(e[r]))return e[r]},U=(e,t)=>{for(let r=e.length-1;r>=0;r--)if(t(e[r]))return r;return-1},V=function(e){return((e,t,r)=>{var i=(e,t,n,s)=>{try{var a=r[e](t),o=(t=a.value)instanceof d,l=a.done;Promise.resolve(o?t[0]:t).then(r=>o?i("return"===e?e:"next",t[1]?{done:r.done,value:r.value}:r,n,s):n({vaLine truncated