figpack 0.2.21__py3-none-any.whl → 0.2.22__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of figpack might be problematic. Click here for more details.

@@ -1,2 +0,0 @@
1
- var Wn=r=>{throw TypeError(r)};var Dn=(r,t,e)=>t.has(r)||Wn("Cannot "+e);var Kn=(r,t,e)=>(Dn(r,t,"read from private field"),e?e.call(r):t.get(r)),Ln=(r,t,e)=>t.has(r)?Wn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),Xn=(r,t,e,i)=>(Dn(r,t,"write to private field"),i?i.call(r,e):t.set(r,e),e),Hn=(r,t,e)=>(Dn(r,t,"access private method"),e);var Wa=Object.defineProperty,ra=(r,t)=>{for(var e in t)Wa(r,e,{get:t[e],enumerable:!0})},On=Math.pow(2,32),w=Math.pow(2,32)-1,Ka=1,Xa=2,Qa=4,bn=1,vn=2,Un=8,Sn=16,Bn=32,Qn=131072,ln=1,wn=4,dn=256,fn=512,un=1024,pn=2048,na=-1,j=0,F=1,N=class aa extends ArrayBuffer{constructor(t){super(t),this.fileStart=0,this.usedBytes=0}static fromArrayBuffer(t,e){const i=new aa(t.byteLength);return new Uint8Array(i).set(new Uint8Array(t)),i.fileStart=e,i}},Ja=(r=>(r[r.BIG_ENDIAN=1]="BIG_ENDIAN",r[r.LITTLE_ENDIAN=2]="LITTLE_ENDIAN",r))(Ja||{}),mn,Rn,g,z=(g=class{constructor(t,e,i){Ln(this,mn);this._byteLength=0,this.failurePosition=0,this._dynamicSize=1,this._byteOffset=e||0,t instanceof ArrayBuffer?this.buffer=N.fromArrayBuffer(t,0):t instanceof DataView?(this.dataView=t,e&&(this._byteOffset+=e)):this.buffer=new N(t||0),this.position=0,this.endianness=i||1}getPosition(){return this.position}_realloc(t){if(!this._dynamicSize)return;const e=this._byteOffset+this.position+t;let i=this._buffer.byteLength;if(e<=i){e>this._byteLength&&(this._byteLength=e);return}for(i<1&&(i=1);e>i;)i*=2;const s=new N(i),n=new Uint8Array(this._buffer);new Uint8Array(s,0,n.length).set(n),this.buffer=s,this._byteLength=e}_trimAlloc(){if(this._byteLength===this._buffer.byteLength)return;const t=new N(this._byteLength),e=new Uint8Array(t),i=new Uint8Array(this._buffer,0,e.length);e.set(i),this.buffer=t}get byteLength(){return this._byteLength-this._byteOffset}get buffer(){return this._trimAlloc(),this._buffer}set buffer(t){this._buffer=t,this._dataView=new DataView(t,this._byteOffset),this._byteLength=t.byteLength}get byteOffset(){return this._byteOffset}set byteOffset(t){this._byteOffset=t,this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._buffer.byteLength}get dataView(){return this._dataView}set dataView(t){this._byteOffset=t.byteOffset,this._buffer=N.fromArrayBuffer(t.buffer,0),this._dataView=new DataView(this._buffer,this._byteOffset),this._byteLength=this._byteOffset+t.byteLength}seek(t){const e=Math.max(0,Math.min(this.byteLength,t));this.position=isNaN(e)||!isFinite(e)?0:e}isEof(){return this.position>=this._byteLength}mapUint8Array(t){this._realloc(t*1);const e=new Uint8Array(this._buffer,this.byteOffset+this.position,t);return this.position+=t*1,e}readInt32Array(t,e){t=t===void 0?this.byteLength-this.position/4:t;const i=new Int32Array(t);return g.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),g.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i}readInt16Array(t,e){t=t===void 0?this.byteLength-this.position/2:t;const i=new Int16Array(t);return g.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),g.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i}readInt8Array(t){t=t===void 0?this.byteLength-this.position:t;const e=new Int8Array(t);return g.memcpy(e.buffer,0,this.buffer,this.byteOffset+this.position,t*e.BYTES_PER_ELEMENT),this.position+=e.byteLength,e}readUint32Array(t,e){t=t===void 0?this.byteLength-this.position/4:t;const i=new Uint32Array(t);return g.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),g.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i}readUint16Array(t,e){t=t===void 0?this.byteLength-this.position/2:t;const i=new Uint16Array(t);return g.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),g.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i}readUint8Array(t){t=t===void 0?this.byteLength-this.position:t;const e=new Uint8Array(t);return g.memcpy(e.buffer,0,this.buffer,this.byteOffset+this.position,t*e.BYTES_PER_ELEMENT),this.position+=e.byteLength,e}readFloat64Array(t,e){t=t===void 0?this.byteLength-this.position/8:t;const i=new Float64Array(t);return g.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),g.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i}readFloat32Array(t,e){t=t===void 0?this.byteLength-this.position/4:t;const i=new Float32Array(t);return g.memcpy(i.buffer,0,this.buffer,this.byteOffset+this.position,t*i.BYTES_PER_ELEMENT),g.arrayToNative(i,e??this.endianness),this.position+=i.byteLength,i}readInt32(t){const e=this._dataView.getInt32(this.position,(t??this.endianness)===2);return this.position+=4,e}readInt16(t){const e=this._dataView.getInt16(this.position,(t??this.endianness)===2);return this.position+=2,e}readInt8(){const t=this._dataView.getInt8(this.position);return this.position+=1,t}readUint32(t){const e=this._dataView.getUint32(this.position,(t??this.endianness)===2);return this.position+=4,e}readUint16(t){const e=this._dataView.getUint16(this.position,(t??this.endianness)===2);return this.position+=2,e}readUint8(){const t=this._dataView.getUint8(this.position);return this.position+=1,t}readFloat32(t){const e=this._dataView.getFloat32(this.position,(t??this.endianness)===2);return this.position+=4,e}readFloat64(t){const e=this._dataView.getFloat64(this.position,(t??this.endianness)===2);return this.position+=8,e}static memcpy(t,e,i,s,n){const a=new Uint8Array(t,e,n),o=new Uint8Array(i,s,n);a.set(o)}static arrayToNative(t,e){return e===g.ENDIANNESS?t:this.flipArrayEndianness(t)}static nativeToEndian(t,e){return e&&g.ENDIANNESS===2?t:this.flipArrayEndianness(t)}static flipArrayEndianness(t){const e=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);for(let i=0;i<t.byteLength;i+=t.BYTES_PER_ELEMENT)for(let s=i+t.BYTES_PER_ELEMENT-1,n=i;s>n;s--,n++){const a=e[n];e[n]=e[s],e[s]=a}return t}readString(t,e){return e===void 0||e==="ASCII"?Jn(this.mapUint8Array(t===void 0?this.byteLength-this.position:t)):new TextDecoder(e).decode(this.mapUint8Array(t))}readCString(t){let e=0;const i=this.byteLength-this.position,s=new Uint8Array(this._buffer,this._byteOffset+this.position),n=t!==void 0?Math.min(t,i):i;for(;e<n&&s[e]!==0;e++);const a=Jn(this.mapUint8Array(e));return t!==void 0?this.position+=n-e:e!==i&&(this.position+=1),a}readInt64(){return this.readInt32()*On+this.readUint32()}readUint64(){return this.readUint32()*On+this.readUint32()}readUint24(){return(this.readUint8()<<16)+(this.readUint8()<<8)+this.readUint8()}save(t){const e=new Blob([this.buffer]);if(typeof window<"u"&&typeof document<"u")if(window.URL&&URL.createObjectURL){const i=window.URL.createObjectURL(e),s=document.createElement("a");document.body.appendChild(s),s.setAttribute("href",i),s.setAttribute("download",t),s.setAttribute("target","_self"),s.click(),window.URL.revokeObjectURL(i),document.body.removeChild(s)}else throw new Error("DataStream.save: Can't create object URL.");return e}get dynamicSize(){return this._dynamicSize}set dynamicSize(t){t||this._trimAlloc(),this._dynamicSize=t}shift(t){const e=new N(this._byteLength-t),i=new Uint8Array(e),s=new Uint8Array(this._buffer,t,i.length);i.set(s),this.buffer=e,this.position-=t}writeInt32Array(t,e){if(this._realloc(t.length*4),t instanceof Int32Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)g.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapInt32Array(t.length,e);else for(let i=0;i<t.length;i++)this.writeInt32(t[i],e)}writeInt16Array(t,e){if(this._realloc(t.length*2),t instanceof Int16Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)g.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapInt16Array(t.length,e);else for(let i=0;i<t.length;i++)this.writeInt16(t[i],e)}writeInt8Array(t){if(this._realloc(t.length*1),t instanceof Int8Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)g.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapInt8Array(t.length);else for(let e=0;e<t.length;e++)this.writeInt8(t[e])}writeUint32Array(t,e){if(this._realloc(t.length*4),t instanceof Uint32Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)g.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapUint32Array(t.length,e);else for(let i=0;i<t.length;i++)this.writeUint32(t[i],e)}writeUint16Array(t,e){if(this._realloc(t.length*2),t instanceof Uint16Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)g.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapUint16Array(t.length,e);else for(let i=0;i<t.length;i++)this.writeUint16(t[i],e)}writeUint8Array(t){if(this._realloc(t.length*1),t instanceof Uint8Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)g.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapUint8Array(t.length);else for(let e=0;e<t.length;e++)this.writeUint8(t[e])}writeFloat64Array(t,e){if(this._realloc(t.length*8),t instanceof Float64Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)g.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapFloat64Array(t.length,e);else for(let i=0;i<t.length;i++)this.writeFloat64(t[i],e)}writeFloat32Array(t,e){if(this._realloc(t.length*4),t instanceof Float32Array&&this.byteOffset+this.position%t.BYTES_PER_ELEMENT===0)g.memcpy(this._buffer,this.byteOffset+this.position,t.buffer,0,t.byteLength),this.mapFloat32Array(t.length,e);else for(let i=0;i<t.length;i++)this.writeFloat32(t[i],e)}writeInt64(t,e){this._realloc(8),this._dataView.setBigInt64(this.position,BigInt(t),(e??this.endianness)===2),this.position+=8}writeInt32(t,e){this._realloc(4),this._dataView.setInt32(this.position,t,(e??this.endianness)===2),this.position+=4}writeInt16(t,e){this._realloc(2),this._dataView.setInt16(this.position,t,(e??this.endianness)===2),this.position+=2}writeInt8(t){this._realloc(1),this._dataView.setInt8(this.position,t),this.position+=1}writeUint32(t,e){this._realloc(4),this._dataView.setUint32(this.position,t,(e??this.endianness)===2),this.position+=4}writeUint16(t,e){this._realloc(2),this._dataView.setUint16(this.position,t,(e??this.endianness)===2),this.position+=2}writeUint8(t){this._realloc(1),this._dataView.setUint8(this.position,t),this.position+=1}writeFloat32(t,e){this._realloc(4),this._dataView.setFloat32(this.position,t,(e??this.endianness)===2),this.position+=4}writeFloat64(t,e){this._realloc(8),this._dataView.setFloat64(this.position,t,(e??this.endianness)===2),this.position+=8}writeUCS2String(t,e,i){i===void 0&&(i=t.length);let s;for(s=0;s<t.length&&s<i;s++)this.writeUint16(t.charCodeAt(s),e);for(;s<i;s++)this.writeUint16(0)}writeString(t,e,i){let s=0;if(e===void 0||e==="ASCII")if(i!==void 0){const n=Math.min(t.length,i);for(s=0;s<n;s++)this.writeUint8(t.charCodeAt(s));for(;s<i;s++)this.writeUint8(0)}else for(s=0;s<t.length;s++)this.writeUint8(t.charCodeAt(s));else this.writeUint8Array(new TextEncoder(e).encode(t.substring(0,i)))}writeCString(t,e){let i=0;if(e!==void 0){const s=Math.min(t.length,e);for(i=0;i<s;i++)this.writeUint8(t.charCodeAt(i));for(;i<e;i++)this.writeUint8(0)}else{for(i=0;i<t.length;i++)this.writeUint8(t.charCodeAt(i));this.writeUint8(0)}}writeStruct(t,e){for(let i=0;i<t.length;i++){const[s,n]=t[i],a=e[s];this.writeType(n,a,e)}}writeType(t,e,i){if(typeof t=="function")return t(this,e);if(typeof t=="object"&&!(t instanceof Array))return t.set(this,e,i);let s,n="ASCII";const a=this.position;let o=t;if(typeof t=="string"&&/:/.test(t)){const h=t.split(":");o=h[0],s=parseInt(h[1])}if(typeof o=="string"&&/,/.test(o)){const h=o.split(",");o=h[0],n=h[1]}switch(o){case"uint8":this.writeUint8(e);break;case"int8":this.writeInt8(e);break;case"uint16":this.writeUint16(e,this.endianness);break;case"int16":this.writeInt16(e,this.endianness);break;case"uint32":this.writeUint32(e,this.endianness);break;case"int32":this.writeInt32(e,this.endianness);break;case"float32":this.writeFloat32(e,this.endianness);break;case"float64":this.writeFloat64(e,this.endianness);break;case"uint16be":this.writeUint16(e,1);break;case"int16be":this.writeInt16(e,1);break;case"uint32be":this.writeUint32(e,1);break;case"int32be":this.writeInt32(e,1);break;case"float32be":this.writeFloat32(e,1);break;case"float64be":this.writeFloat64(e,1);break;case"uint16le":this.writeUint16(e,2);break;case"int16le":this.writeInt16(e,2);break;case"uint32le":this.writeUint32(e,2);break;case"int32le":this.writeInt32(e,2);break;case"float32le":this.writeFloat32(e,2);break;case"float64le":this.writeFloat64(e,2);break;case"cstring":this.writeCString(e,s);break;case"string":this.writeString(e,n,s);break;case"u16string":this.writeUCS2String(e,this.endianness,s);break;case"u16stringle":this.writeUCS2String(e,2,s);break;case"u16stringbe":this.writeUCS2String(e,1,s);break;default:if(Hn(this,mn,Rn).call(this,o)){const[,h]=o;for(let c=0;c<e.length;c++)this.writeType(h,e[c]);break}else{this.writeStruct(o,e);break}}s&&(this.position=a,this._realloc(s),this.position=a+s)}writeUint64(t){const e=Math.floor(t/On);this.writeUint32(e),this.writeUint32(t&4294967295)}writeUint24(t){this.writeUint8((t&16711680)>>16),this.writeUint8((t&65280)>>8),this.writeUint8(t&255)}adjustUint32(t,e){const i=this.position;this.seek(t),this.writeUint32(e),this.seek(i)}readStruct(t){const e={},i=this.position;for(let s=0;s<t.length;s+=1){const n=t[s][1],a=this.readType(n,e);if(!a){this.failurePosition===0&&(this.failurePosition=this.position),this.position=i;return}e[t[s][0]]=a}return e}readUCS2String(t,e){return String.fromCharCode.apply(void 0,this.readUint16Array(t,e))}readType(t,e){if(typeof t=="function")return t(this,e);if(typeof t=="object"&&!(t instanceof Array))return t.get(this,e);if(t instanceof Array&&t.length!==3)return this.readStruct(t);let i,s,n="ASCII";const a=this.position;let o=t;if(typeof o=="string"&&/:/.test(o)){const h=o.split(":");o=h[0],s=parseInt(h[1])}if(typeof o=="string"&&/,/.test(o)){const h=o.split(",");o=h[0],n=h[1]}switch(o){case"uint8":i=this.readUint8();break;case"int8":i=this.readInt8();break;case"uint16":i=this.readUint16(this.endianness);break;case"int16":i=this.readInt16(this.endianness);break;case"uint32":i=this.readUint32(this.endianness);break;case"int32":i=this.readInt32(this.endianness);break;case"float32":i=this.readFloat32(this.endianness);break;case"float64":i=this.readFloat64(this.endianness);break;case"uint16be":i=this.readUint16(1);break;case"int16be":i=this.readInt16(1);break;case"uint32be":i=this.readUint32(1);break;case"int32be":i=this.readInt32(1);break;case"float32be":i=this.readFloat32(1);break;case"float64be":i=this.readFloat64(1);break;case"uint16le":i=this.readUint16(2);break;case"int16le":i=this.readInt16(2);break;case"uint32le":i=this.readUint32(2);break;case"int32le":i=this.readInt32(2);break;case"float32le":i=this.readFloat32(2);break;case"float64le":i=this.readFloat64(2);break;case"cstring":i=this.readCString(s);break;case"string":i=this.readString(s,n);break;case"u16string":i=this.readUCS2String(s,this.endianness);break;case"u16stringle":i=this.readUCS2String(s,2);break;case"u16stringbe":i=this.readUCS2String(s,1);break;default:if(Hn(this,mn,Rn).call(this,o)){const[,h,c]=o,f=typeof c=="function"?c(e,this,o):typeof c=="string"&&e[c]!==void 0?parseInt(e[c]):typeof c=="number"?c:c==="*"?void 0:parseInt(c);if(typeof h=="string"){const u=h.replace(/(le|be)$/,"");let _;switch(/le$/.test(h)?_=2:/be$/.test(h)&&(_=1),u){case"uint8":i=this.readUint8Array(f);break;case"uint16":i=this.readUint16Array(f,_);break;case"uint32":i=this.readUint32Array(f,_);break;case"int8":i=this.readInt8Array(f);break;case"int16":i=this.readInt16Array(f,_);break;case"int32":i=this.readInt32Array(f,_);break;case"float32":i=this.readFloat32Array(f,_);break;case"float64":i=this.readFloat64Array(f,_);break;case"cstring":case"utf16string":case"string":if(f){i=new Array(f);for(let m=0;m<f;m++)i[m]=this.readType(h,e)}else for(i=[];!this.isEof();){const m=this.readType(h,e);if(!m)break;i.push(m)}break}}else if(f){i=new Array(f);for(let u=0;u<f;u++){const _=this.readType(h,e);if(!_)return;i[u]=_}}else for(i=[];;){const u=this.position;try{const _=this.readType(h,e);if(!_){this.position=u;break}i.push(_)}catch{this.position=u;break}}break}}return s&&(this.position=a+s),i}mapInt32Array(t,e){this._realloc(t*4);const i=new Int32Array(this._buffer,this.byteOffset+this.position,t);return g.arrayToNative(i,e??this.endianness),this.position+=t*4,i}mapInt16Array(t,e){this._realloc(t*2);const i=new Int16Array(this._buffer,this.byteOffset+this.position,t);return g.arrayToNative(i,e??this.endianness),this.position+=t*2,i}mapInt8Array(t,e){this._realloc(t*1);const i=new Int8Array(this._buffer,this.byteOffset+this.position,t);return this.position+=t*1,i}mapUint32Array(t,e){this._realloc(t*4);const i=new Uint32Array(this._buffer,this.byteOffset+this.position,t);return g.arrayToNative(i,e??this.endianness),this.position+=t*4,i}mapUint16Array(t,e){this._realloc(t*2);const i=new Uint16Array(this._buffer,this.byteOffset+this.position,t);return g.arrayToNative(i,e??this.endianness),this.position+=t*2,i}mapFloat64Array(t,e){this._realloc(t*8);const i=new Float64Array(this._buffer,this.byteOffset+this.position,t);return g.arrayToNative(i,e??this.endianness),this.position+=t*8,i}mapFloat32Array(t,e){this._realloc(t*4);const i=new Float32Array(this._buffer,this.byteOffset+this.position,t);return g.arrayToNative(i,e??this.endianness),this.position+=t*4,i}},mn=new WeakSet,Rn=function(t){return Array.isArray(t)&&t.length===3&&t[0]==="[]"},g.ENDIANNESS=new Int8Array(new Int16Array([1]).buffer)[0]>0?2:1,g);function Jn(r){const t=[];for(let e=0;e<r.length;e++)t[e]=r[e];return String.fromCharCode.apply(void 0,t)}var xn=new Date,zn=4,Zn=3,ta=2,ea=1,R=zn,l={setLogLevel(r){r===this.debug?R=ea:r===this.info?R=ta:r===this.warn?R=Zn:(this.error,R=zn)},debug(r,t){console.debug===void 0&&(console.debug=console.log),ea>=R&&console.debug("["+l.getDurationString(new Date().getTime()-xn.getTime(),1e3)+"]","["+r+"]",t)},log(r,t){this.debug(r.msg)},info(r,t){ta>=R&&console.info("["+l.getDurationString(new Date().getTime()-xn.getTime(),1e3)+"]","["+r+"]",t)},warn(r,t){Zn>=R&&console.warn("["+l.getDurationString(new Date().getTime()-xn.getTime(),1e3)+"]","["+r+"]",t)},error(r,t,e){e?.onError?e.onError(r,t):zn>=R&&console.error("["+l.getDurationString(new Date().getTime()-xn.getTime(),1e3)+"]","["+r+"]",t)},getDurationString(r,t){let e;function i(c,f){const _=(""+c).split(".");for(;_[0].length<f;)_[0]="0"+_[0];return _.join(".")}r<0?(e=!0,r=-r):e=!1;let n=r/(t||1);const a=Math.floor(n/3600);n-=a*3600;const o=Math.floor(n/60);n-=o*60;let h=n*1e3;return n=Math.floor(n),h-=n*1e3,h=Math.floor(h),(e?"-":"")+a+":"+i(o,2)+":"+i(n,2)+"."+i(h,3)},printRanges(r){const t=r.length;if(t>0){let e="";for(let i=0;i<t;i++)i>0&&(e+=","),e+="["+l.getDurationString(r.start(i))+","+l.getDurationString(r.end(i))+"]";return e}else return"(empty)"}};function Za(r,t){l.debug("ArrayBuffer","Trying to create a new buffer of size: "+(r.byteLength+t.byteLength));const e=new Uint8Array(r.byteLength+t.byteLength);return e.set(new Uint8Array(r),0),e.set(new Uint8Array(t),r.byteLength),e.buffer}var _n=class extends z{constructor(r){super(new ArrayBuffer,0),this.buffers=[],this.bufferIndex=-1,r&&(this.insertBuffer(r),this.bufferIndex=0)}initialized(){if(this.bufferIndex>-1)return!0;if(this.buffers.length>0){const r=this.buffers[0];return r.fileStart===0?(this.buffer=r,this.bufferIndex=0,l.debug("MultiBufferStream","Stream ready for parsing"),!0):(l.warn("MultiBufferStream","The first buffer should have a fileStart of 0"),this.logBufferLevel(),!1)}else return l.warn("MultiBufferStream","No buffer to start parsing from"),this.logBufferLevel(),!1}reduceBuffer(r,t,e){const i=new Uint8Array(e);return i.set(new Uint8Array(r,t,e)),i.buffer.fileStart=r.fileStart+t,i.buffer.usedBytes=0,i.buffer}insertBuffer(r){let t=!0,e=0;for(;e<this.buffers.length;e++){const i=this.buffers[e];if(r.fileStart<=i.fileStart){if(r.fileStart===i.fileStart)if(r.byteLength>i.byteLength){this.buffers.splice(e,1),e--;continue}else l.warn("MultiBufferStream","Buffer (fileStart: "+r.fileStart+" - Length: "+r.byteLength+") already appended, ignoring");else r.fileStart+r.byteLength<=i.fileStart||(r=this.reduceBuffer(r,0,i.fileStart-r.fileStart)),l.debug("MultiBufferStream","Appending new buffer (fileStart: "+r.fileStart+" - Length: "+r.byteLength+")"),this.buffers.splice(e,0,r),e===0&&(this.buffer=r);t=!1;break}else if(r.fileStart<i.fileStart+i.byteLength){const s=i.fileStart+i.byteLength-r.fileStart,n=r.byteLength-s;if(n>0)r=this.reduceBuffer(r,s,n);else{t=!1;break}}}t&&(l.debug("MultiBufferStream","Appending new buffer (fileStart: "+r.fileStart+" - Length: "+r.byteLength+")"),this.buffers.push(r),e===0&&(this.buffer=r))}logBufferLevel(r){const t=[];let e="",i,s=0,n=0;for(let o=0;o<this.buffers.length;o++){const h=this.buffers[o];o===0?(i={start:h.fileStart,end:h.fileStart+h.byteLength},t.push(i),e+="["+i.start+"-"):i.end===h.fileStart?i.end=h.fileStart+h.byteLength:(i={start:h.fileStart,end:h.fileStart+h.byteLength},e+=t[t.length-1].end-1+"], ["+i.start+"-",t.push(i)),s+=h.usedBytes,n+=h.byteLength}t.length>0&&(e+=i.end-1+"]");const a=r?l.info:l.debug;this.buffers.length===0?a("MultiBufferStream","No more buffer in memory"):a("MultiBufferStream",""+this.buffers.length+" stored buffer(s) ("+s+"/"+n+" bytes), continuous ranges: "+e)}cleanBuffers(){for(let r=0;r<this.buffers.length;r++){const t=this.buffers[r];t.usedBytes===t.byteLength&&(l.debug("MultiBufferStream","Removing buffer #"+r),this.buffers.splice(r,1),r--)}}mergeNextBuffer(){if(this.bufferIndex+1<this.buffers.length){const r=this.buffers[this.bufferIndex+1];if(r.fileStart===this.buffer.fileStart+this.buffer.byteLength){const t=this.buffer.byteLength,e=this.buffer.usedBytes,i=this.buffer.fileStart;return this.buffers[this.bufferIndex]=Za(this.buffer,r),this.buffer=this.buffers[this.bufferIndex],this.buffers.splice(this.bufferIndex+1,1),this.buffer.usedBytes=e,this.buffer.fileStart=i,l.debug("ISOFile","Concatenating buffer for box parsing (length: "+t+"->"+this.buffer.byteLength+")"),!0}else return!1}else return!1}findPosition(r,t,e){let i=-1,s=r===!0?0:this.bufferIndex;for(;s<this.buffers.length;){const a=this.buffers[s];if(a&&a.fileStart<=t)i=s,e&&(a.fileStart+a.byteLength<=t?a.usedBytes=a.byteLength:a.usedBytes=t-a.fileStart,this.logBufferLevel());else break;s++}if(i===-1)return-1;const n=this.buffers[i];return n.fileStart+n.byteLength>=t?(l.debug("MultiBufferStream","Found position in existing buffer #"+i),i):-1}findEndContiguousBuf(r){const t=r!==void 0?r:this.bufferIndex;let e=this.buffers[t];if(this.buffers.length>t+1)for(let i=t+1;i<this.buffers.length;i++){const s=this.buffers[i];if(s.fileStart===e.fileStart+e.byteLength)e=s;else break}return e.fileStart+e.byteLength}getEndFilePositionAfter(r){const t=this.findPosition(!0,r,!1);return t!==-1?this.findEndContiguousBuf(t):r}addUsedBytes(r){this.buffer.usedBytes+=r,this.logBufferLevel()}setAllUsedBytes(){this.buffer.usedBytes=this.buffer.byteLength,this.logBufferLevel()}seek(r,t,e){const i=this.findPosition(t,r,e);return i!==-1?(this.buffer=this.buffers[i],this.bufferIndex=i,this.position=r-this.buffer.fileStart,l.debug("MultiBufferStream","Repositioning parser at buffer position: "+this.position),!0):(l.debug("MultiBufferStream","Position "+r+" not found in buffered data"),!1)}getPosition(){return this.bufferIndex===-1||this.buffers[this.bufferIndex]===void 0?0:this.buffers[this.bufferIndex].fileStart+this.position}getLength(){return this.byteLength}getEndPosition(){return this.bufferIndex===-1||this.buffers[this.bufferIndex]===void 0?0:this.buffers[this.bufferIndex].fileStart+this.byteLength}getAbsoluteEndPosition(){if(this.buffers.length===0)return 0;const r=this.buffers[this.buffers.length-1];return r.fileStart+r.byteLength}},gn,Z,p=(Z=class{constructor(t=0){Ln(this,gn);this.size=t}get type(){return this.constructor.fourcc??Kn(this,gn)}set type(t){Xn(this,gn,t)}addBox(t){return this.boxes||(this.boxes=[]),this.boxes.push(t),this[t.type+"s"]?this[t.type+"s"].push(t):this[t.type]=t,t}set(t,e){return this[t]=e,this}addEntry(t,e){const i=e||"entries";return this[i]||(this[i]=[]),this[i].push(t),this}writeHeader(t,e){if(this.size+=8,(this.size>w||this.original_size===1)&&(this.size+=8),this.type==="uuid"&&(this.size+=16),l.debug("BoxWriter","Writing box "+this.type+" of size: "+this.size+" at position "+t.getPosition()+(e||"")),this.original_size===0?t.writeUint32(0):this.size>w||this.original_size===1?t.writeUint32(1):(this.sizePosition=t.getPosition(),t.writeUint32(this.size)),t.writeString(this.type,void 0,4),this.type==="uuid"){const i=new Uint8Array(16);for(let s=0;s<16;s++)i[s]=parseInt(this.uuid.substring(s*2,s*2+2),16);t.writeUint8Array(i)}(this.size>w||this.original_size===1)&&(this.sizePosition=t.getPosition(),t.writeUint64(this.size))}write(t){if(this.type==="mdat"){const e=this;if(e.stream){this.size=e.stream.getAbsoluteEndPosition(),this.writeHeader(t);for(const i of e.stream.buffers){const s=new Uint8Array(i);t.writeUint8Array(s)}}else e.data&&(this.size=e.data.length,this.writeHeader(t),t.writeUint8Array(e.data))}else this.size=this.data?this.data.length:0,this.writeHeader(t),this.data&&t.writeUint8Array(this.data)}printHeader(t){this.size+=8,this.size>w&&(this.size+=8),this.type==="uuid"&&(this.size+=16),t.log(t.indent+"size:"+this.size),t.log(t.indent+"type:"+this.type)}print(t){this.printHeader(t)}parse(t){this.type!=="mdat"?this.data=t.readUint8Array(this.size-this.hdr_size):this.size===0?t.seek(t.getEndPosition()):t.seek(this.start+this.size)}parseDataAndRewind(t){this.data=t.readUint8Array(this.size-this.hdr_size),t.seek(this.start+this.hdr_size)}parseLanguage(t){this.language=t.readUint16();const e=[];e[0]=this.language>>10&31,e[1]=this.language>>5&31,e[2]=this.language&31,this.languageString=String.fromCharCode(e[0]+96,e[1]+96,e[2]+96)}computeSize(t){const e=t||new _n;this.write(e)}isEndOfBox(t){const e=t.getPosition(),i=this.start+this.size;return e===i}},gn=new WeakMap,Z.registryId=Symbol.for("BoxIdentifier"),Z),d=class extends p{constructor(){super(...arguments),this.flags=0,this.version=0}writeHeader(r){this.size+=4,super.writeHeader(r," v="+this.version+" f="+this.flags),r.writeUint8(this.version),r.writeUint24(this.flags)}printHeader(r){this.size+=4,super.printHeader(r),r.log(r.indent+"version:"+this.version),r.log(r.indent+"flags:"+this.flags)}parseDataAndRewind(r){this.parseFullHeader(r),this.data=r.readUint8Array(this.size-this.hdr_size),this.hdr_size-=4,r.seek(this.start+this.hdr_size)}parseFullHeader(r){this.version=r.readUint8(),this.flags=r.readUint24(),this.hdr_size+=4}parse(r){this.parseFullHeader(r),this.data=r.readUint8Array(this.size-this.hdr_size)}},tt,B=(tt=class{constructor(t){this.grouping_type=t}write(t){t.writeUint8Array(this.data)}parse(t){l.warn("BoxParser",`Unknown sample group type: '${this.grouping_type}'`),this.data=t.readUint8Array(this.description_length)}},tt.registryId=Symbol.for("SampleGroupEntryIdentifier"),tt),to=class extends d{parse(r){this.parseFullHeader(r),this.track_group_id=r.readUint32()}},eo=class extends p{constructor(r,t,e,i,s){super(t),this.box_name=e,this.hdr_size=i,this.start=s,this.type=r}parse(r){this.from_item_ID=r.readUint16();const t=r.readUint16();this.references=[];for(let e=0;e<t;e++)this.references[e]={to_item_ID:r.readUint16()}}},io=class extends p{constructor(r,t,e,i,s){super(t),this.box_name=e,this.hdr_size=i,this.start=s,this.type=r}parse(r){this.from_item_ID=r.readUint32();const t=r.readUint16();this.references=[];for(let e=0;e<t;e++)this.references[e]={to_item_ID:r.readUint32()}}},so=class extends p{constructor(r,t,e,i){super(t),this.hdr_size=e,this.start=i,this.type=r}parse(r){this.track_ids=r.readUint32Array((this.size-this.hdr_size)/4)}write(r){this.size=this.track_ids.length*4,this.writeHeader(r),r.writeUint32Array(this.track_ids)}},Nn=["boxes","entries","references","subsamples","items","item_infos","extents","associations","subsegments","ranges","seekLists","seekPoints","esd","levels"],ro=["compatible_brands","matrix","opcolor","sample_counts","sample_deltas","first_chunk","samples_per_chunk","sample_sizes","chunk_offsets","sample_offsets","sample_description_index","sample_duration"];function no(r,t){if(r&&!t)return!1;let e;for(e in r)if(!Nn.find(i=>i===e)){if(r[e]instanceof p||t[e]instanceof p)continue;if(typeof r[e]>"u"||typeof t[e]>"u")continue;if(typeof r[e]=="function"||typeof t[e]=="function")continue;if("subBoxNames"in r&&r.subBoxNames.indexOf(e.slice(0,4))>-1||"subBoxNames"in t&&t.subBoxNames.indexOf(e.slice(0,4))>-1)continue;if(e==="data"||e==="start"||e==="size"||e==="creation_time"||e==="modification_time")continue;if(ro.find(i=>i===e))continue;if(r[e]!==t[e])return!1}return!0}function oa(r,t){if(!no(r,t))return!1;for(let e=0;e<Nn.length;e++){const i=Nn[e];if(r[i]&&t[i]&&!oa(r[i],t[i]))return!1}return!0}function $n(r){let t=r;for(;t;){if("registryId"in t)return t.registryId;t=Object.getPrototypeOf(t)}}var ao=r=>{const t=Symbol.for("SampleGroupEntryIdentifier");return $n(r)===t},oo=r=>{const t=Symbol.for("SampleEntryIdentifier");return $n(r)===t},ho=r=>{const t=Symbol.for("BoxIdentifier");return $n(r)===t},C={uuid:{},sampleEntry:{},sampleGroupEntry:{},box:{}};function co(r){const t={uuid:{},sampleEntry:{},sampleGroupEntry:{},box:{}};for(const[e,i]of Object.entries(r)){if(ao(i)){const s="grouping_type"in i?i.grouping_type:void 0;if(!s)throw new Error(`SampleGroupEntry class ${e} does not have a valid static grouping_type. Please ensure it is defined correctly.`);if(s in t.sampleGroupEntry)throw new Error(`SampleGroupEntry class ${e} has a grouping_type that is already registered. Please ensure it is unique.`);t.sampleGroupEntry[s]=i;continue}if(oo(i)){const s="fourcc"in i?i.fourcc:void 0;if(!s)throw new Error(`SampleEntry class ${e} does not have a valid static fourcc. Please ensure it is defined correctly.`);if(s in t.sampleEntry)throw new Error(`SampleEntry class ${e} has a fourcc that is already registered. Please ensure it is unique.`);t.sampleEntry[s]=i;continue}if(ho(i)){const s="fourcc"in i?i.fourcc:void 0,n="uuid"in i?i.uuid:void 0;if(s==="uuid"){if(!n)throw new Error(`Box class ${e} has a fourcc of 'uuid' but does not have a valid uuid. Please ensure it is defined correctly.`);if(n in t.uuid)throw new Error(`Box class ${e} has a uuid that is already registered. Please ensure it is unique.`);t.uuid[n]=i;continue}t.box[s]=i;continue}throw new Error(`Box class ${e} does not have a valid static fourcc, uuid, or grouping_type. Please ensure it is defined correctly.`)}return C.uuid={...t.uuid},C.sampleEntry={...t.sampleEntry},C.sampleGroupEntry={...t.sampleGroupEntry},C.box={...t.box},C}var Tn={};function lo(r){return Object.entries(r).forEach(([t,e])=>Tn[t]=e),Tn}function fo(r){return K(r)}function K(r){let t="";for(let e=0;e<16;e++){const i=r.readUint8().toString(16);t+=i.length===1?"0"+i:i}return t}function H(r,t,e){let i,s;const n=r.getPosition();let a=0,o;if(r.getEndPosition()-n<8)return l.debug("BoxParser","Not enough data in stream to parse the type and size of the box"),{code:j};if(e&&e<8)return l.debug("BoxParser","Not enough bytes left in the parent box to parse a new box"),{code:j};let h=r.readUint32();const c=r.readString(4);if(c.length!==4||!/^[\x20-\x7E]{4}$/.test(c))return l.error("BoxParser",`Invalid box type: '${c}'`),{code:na,start:n,type:c};let f=c;if(l.debug("BoxParser","Found box of type '"+c+"' and size "+h+" at position "+n),a=8,c==="uuid"){if(r.getEndPosition()-r.getPosition()<16||e-a<16)return r.seek(n),l.debug("BoxParser","Not enough bytes left in the parent box to parse a UUID box"),{code:j};o=fo(r),a+=16,f=o}if(h===1){if(r.getEndPosition()-r.getPosition()<8||e&&e-a<8)return r.seek(n),l.warn("BoxParser",'Not enough data in stream to parse the extended size of the "'+c+'" box'),{code:j};s=h,h=r.readUint64(),a+=8}else if(h===0){if(e)h=e;else if(c!=="mdat")return l.error("BoxParser","Unlimited box size not supported for type: '"+c+"'"),i=new p(h),i.type=c,{code:F,box:i,size:i.size}}if(h!==0&&h<a)return l.error("BoxParser","Box of type "+c+" has an invalid size "+h+" (too small to be a box)"),{code:j,type:c,size:h,hdr_size:a,start:n};if(h!==0&&e&&h>e)return l.error("BoxParser","Box of type '"+c+"' has a size "+h+" greater than its container size "+e),{code:j,type:c,size:h,hdr_size:a,start:n};if(h!==0&&n+h>r.getEndPosition())return r.seek(n),l.info("BoxParser","Not enough data in stream to parse the entire '"+c+"' box"),{code:j,type:c,size:h,hdr_size:a,start:n,original_size:s};if(t)return{code:F,type:c,size:h,hdr_size:a,start:n};c in C.box?i=new C.box[c](h):c!=="uuid"?(l.warn("BoxParser",`Unknown box type: '${c}'`),i=new p(h),i.type=c,i.has_unparsed_data=!0):o in C.uuid?i=new C.uuid[o](h):(l.warn("BoxParser",`Unknown UUID box type: '${o}'`),i=new p(h),i.type=c,i.uuid=o,i.has_unparsed_data=!0),i.original_size=s,i.hdr_size=a,i.start=n,i.write===p.prototype.write&&i.type!=="mdat"&&(l.info("BoxParser","'"+f+"' box writing not yet implemented, keeping unparsed data in memory for later write"),i.parseDataAndRewind(r)),i.parse(r);const u=r.getPosition()-(i.start+i.size);return u<0?(l.warn("BoxParser","Parsing of box '"+f+"' did not read the entire indicated box data size (missing "+-u+" bytes), seeking forward"),r.seek(i.start+i.size)):u>0&&i.size!==0&&(l.error("BoxParser","Parsing of box '"+f+"' read "+u+" more bytes than the indicated box data size, seeking backwards"),r.seek(i.start+i.size)),{code:F,box:i,size:i.size}}var y=class extends p{write(r){if(this.size=0,this.writeHeader(r),this.boxes)for(let t=0;t<this.boxes.length;t++)this.boxes[t]&&(this.boxes[t].write(r),this.size+=this.boxes[t].size);l.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),r.adjustUint32(this.sizePosition,this.size)}print(r){this.printHeader(r);for(let t=0;t<this.boxes.length;t++)if(this.boxes[t]){const e=r.indent;r.indent+=" ",this.boxes[t].print(r),r.indent=e}}parse(r){let t;for(;r.getPosition()<this.start+this.size;)if(t=H(r,!1,this.size-(r.getPosition()-this.start)),t.code===F){const e=t.box;if(this.boxes||(this.boxes=[]),this.boxes.push(e),this.subBoxNames&&this.subBoxNames.indexOf(e.type)!==-1){const i=this.subBoxNames[this.subBoxNames.indexOf(e.type)]+"s";this[i]||(this[i]=[]),this[i].push(e)}else{const i=e.type!=="uuid"?e.type:e.uuid;this[i]?l.warn("ContainerBox",`Box of type ${i} already exists in container box ${this.type}.`):this[i]=e}}else return}},et,G=(et=class extends y{constructor(t,e,i){super(t),this.hdr_size=e,this.start=i}isVideo(){return!1}isAudio(){return!1}isSubtitle(){return!1}isMetadata(){return!1}isHint(){return!1}getCodec(){return this.type.replace(".","")}getWidth(){return""}getHeight(){return""}getChannelCount(){return""}getSampleRate(){return""}getSampleSize(){return""}parseHeader(t){t.readUint8Array(6),this.data_reference_index=t.readUint16(),this.hdr_size+=8}parse(t){this.parseHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size)}parseDataAndRewind(t){this.parseHeader(t),this.data=t.readUint8Array(this.size-this.hdr_size),this.hdr_size-=8,t.seek(this.start+this.hdr_size)}parseFooter(t){super.parse(t)}writeHeader(t){this.size=8,super.writeHeader(t),t.writeUint8(0),t.writeUint8(0),t.writeUint8(0),t.writeUint8(0),t.writeUint8(0),t.writeUint8(0),t.writeUint16(this.data_reference_index)}writeFooter(t){if(this.boxes)for(let e=0;e<this.boxes.length;e++)this.boxes[e].write(t),this.size+=this.boxes[e].size;l.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)}write(t){this.writeHeader(t),t.writeUint8Array(this.data),this.size+=this.data.length,l.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)}},et.registryId=Symbol.for("SampleEntryIdentifier"),et),ia=class extends G{},an=class extends G{isMetadata(){return!0}},X=class extends G{isSubtitle(){return!0}},uo=class extends G{},U=class extends G{parse(r){this.parseHeader(r),r.readUint16(),r.readUint16(),r.readUint32Array(3),this.width=r.readUint16(),this.height=r.readUint16(),this.horizresolution=r.readUint32(),this.vertresolution=r.readUint32(),r.readUint32(),this.frame_count=r.readUint16();const t=Math.min(31,r.readUint8());this.compressorname=r.readString(t),t<31&&r.readString(31-t),this.depth=r.readUint16(),r.readUint16(),this.parseFooter(r)}isVideo(){return!0}getWidth(){return this.width}getHeight(){return this.height}write(r){this.writeHeader(r),this.size+=70,r.writeUint16(0),r.writeUint16(0),r.writeUint32(0),r.writeUint32(0),r.writeUint32(0),r.writeUint16(this.width),r.writeUint16(this.height),r.writeUint32(this.horizresolution),r.writeUint32(this.vertresolution),r.writeUint32(0),r.writeUint16(this.frame_count),r.writeUint8(Math.min(31,this.compressorname.length)),r.writeString(this.compressorname,void 0,31),r.writeUint16(this.depth),r.writeInt16(-1),this.writeFooter(r)}},D=class extends G{parse(r){this.parseHeader(r),this.version=r.readUint16(),r.readUint16(),r.readUint32(),this.channel_count=r.readUint16(),this.samplesize=r.readUint16(),r.readUint16(),r.readUint16(),this.samplerate=r.readUint32()/65536,r.isofile?.ftyp?.major_brand.includes("qt")&&(this.version===1?this.extensions=r.readUint8Array(16):this.version===2&&(this.extensions=r.readUint8Array(36))),this.parseFooter(r)}isAudio(){return!0}getChannelCount(){return this.channel_count}getSampleRate(){return this.samplerate}getSampleSize(){return this.samplesize}write(r){this.writeHeader(r),this.size+=20,r.writeUint32(0),r.writeUint32(0),r.writeUint16(this.channel_count),r.writeUint16(this.samplesize),r.writeUint16(0),r.writeUint16(0),r.writeUint32(this.samplerate<<16),this.writeFooter(r)}},qn=class extends G{parse(r){this.parseHeader(r),this.parseFooter(r)}write(r){this.writeHeader(r),this.writeFooter(r)}},sa=class extends Array{toString(){let r="<table class='inner-table'>";r+="<thead><tr><th>length</th><th>nalu_data</th></tr></thead>",r+="<tbody>";for(let t=0;t<this.length;t++){const e=this[t];r+="<tr>",r+="<td>"+e.length+"</td>",r+="<td>",r+=e.data.reduce(function(i,s){return i+s.toString(16).padStart(2,"0")},"0x"),r+="</td></tr>"}return r+="</tbody></table>",r}},it,ha=(it=class extends p{constructor(){super(...arguments),this.box_name="AVCConfigurationBox"}parse(t){this.configurationVersion=t.readUint8(),this.AVCProfileIndication=t.readUint8(),this.profile_compatibility=t.readUint8(),this.AVCLevelIndication=t.readUint8(),this.lengthSizeMinusOne=t.readUint8()&3,this.nb_SPS_nalus=t.readUint8()&31;let e=this.size-this.hdr_size-6;this.SPS=new sa;for(let i=0;i<this.nb_SPS_nalus;i++){const s=t.readUint16();this.SPS.push({length:s,data:t.readUint8Array(s)}),e-=2+s}this.nb_PPS_nalus=t.readUint8(),e--,this.PPS=new sa;for(let i=0;i<this.nb_PPS_nalus;i++){const s=t.readUint16();this.PPS.push({length:s,data:t.readUint8Array(s)}),e-=2+s}e>0&&(this.ext=t.readUint8Array(e))}write(t){this.size=7;for(let e=0;e<this.SPS.length;e++)this.size+=2+this.SPS[e].length;for(let e=0;e<this.PPS.length;e++)this.size+=2+this.PPS[e].length;this.ext&&(this.size+=this.ext.length),this.writeHeader(t),t.writeUint8(this.configurationVersion),t.writeUint8(this.AVCProfileIndication),t.writeUint8(this.profile_compatibility),t.writeUint8(this.AVCLevelIndication),t.writeUint8(this.lengthSizeMinusOne+252),t.writeUint8(this.SPS.length+224);for(let e=0;e<this.SPS.length;e++)t.writeUint16(this.SPS[e].length),t.writeUint8Array(this.SPS[e].data);t.writeUint8(this.PPS.length);for(let e=0;e<this.PPS.length;e++)t.writeUint16(this.PPS[e].length),t.writeUint8Array(this.PPS[e].data);this.ext&&t.writeUint8Array(this.ext)}},it.fourcc="avcC",it),st,En=(st=class extends p{constructor(){super(...arguments),this.box_name="MediaDataBox"}},st.fourcc="mdat",st),rt,po=(rt=class extends p{constructor(){super(...arguments),this.box_name="ItemDataBox"}},rt.fourcc="idat",rt),nt,_o=(nt=class extends p{constructor(){super(...arguments),this.box_name="FreeSpaceBox"}},nt.fourcc="free",nt),at,mo=(at=class extends p{constructor(){super(...arguments),this.box_name="FreeSpaceBox"}},at.fourcc="skip",at),ot,ca=(ot=class extends d{constructor(){super(...arguments),this.box_name="HintMediaHeaderBox"}},ot.fourcc="hmhd",ot),ht,kn=(ht=class extends d{constructor(){super(...arguments),this.box_name="NullMediaHeaderBox"}},ht.fourcc="nmhd",ht),ct,go=(ct=class extends d{constructor(){super(...arguments),this.box_name="ObjectDescriptorBox"}},ct.fourcc="iods",ct),lt,xo=(lt=class extends d{constructor(){super(...arguments),this.box_name="XMLBox"}},lt.fourcc="xml ",lt),dt,yo=(dt=class extends d{constructor(){super(...arguments),this.box_name="BinaryXMLBox"}},dt.fourcc="bxml",dt),ft,bo=(ft=class extends d{constructor(){super(...arguments),this.box_name="ItemProtectionBox",this.sinfs=[]}get protections(){return this.sinfs}},ft.fourcc="ipro",ft),ut,Gn=(ut=class extends y{constructor(){super(...arguments),this.box_name="MovieBox",this.traks=[],this.psshs=[],this.subBoxNames=["trak","pssh"]}},ut.fourcc="moov",ut),pt,la=(pt=class extends y{constructor(){super(...arguments),this.box_name="TrackBox",this.samples=[]}},pt.fourcc="trak",pt),_t,vo=(_t=class extends y{constructor(){super(...arguments),this.box_name="EditBox"}},_t.fourcc="edts",_t),mt,da=(mt=class extends y{constructor(){super(...arguments),this.box_name="MediaBox"}},mt.fourcc="mdia",mt),gt,fa=(gt=class extends y{constructor(){super(...arguments),this.box_name="MediaInformationBox"}},gt.fourcc="minf",gt),xt,ua=(xt=class extends y{constructor(){super(...arguments),this.box_name="DataInformationBox"}},xt.fourcc="dinf",xt),yt,pa=(yt=class extends y{constructor(){super(...arguments),this.box_name="SampleTableBox",this.sgpds=[],this.sbgps=[],this.subBoxNames=["sgpd","sbgp"]}},yt.fourcc="stbl",yt),bt,Vn=(bt=class extends y{constructor(){super(...arguments),this.box_name="MovieExtendsBox",this.trexs=[],this.subBoxNames=["trex"]}},bt.fourcc="mvex",bt),vt,_a=(vt=class extends y{constructor(){super(...arguments),this.box_name="MovieFragmentBox",this.trafs=[],this.subBoxNames=["traf"]}},vt.fourcc="moof",vt),Ut,ma=(Ut=class extends y{constructor(){super(...arguments),this.box_name="TrackFragmentBox",this.truns=[],this.sgpds=[],this.sbgps=[],this.subBoxNames=["trun","sgpd","sbgp"]}},Ut.fourcc="traf",Ut),St,Uo=(St=class extends y{constructor(){super(...arguments),this.box_name="VTTCueBox"}},St.fourcc="vttc",St),Bt,So=(Bt=class extends y{constructor(){super(...arguments),this.box_name="MovieFragmentRandomAccessBox",this.tfras=[],this.subBoxNames=["tfra"]}},Bt.fourcc="mfra",Bt),wt,Bo=(wt=class extends y{constructor(){super(...arguments),this.box_name="AdditionalMetadataContainerBox"}},wt.fourcc="meco",wt),zt,wo=(zt=class extends y{constructor(){super(...arguments),this.box_name="trackhintinformation",this.subBoxNames=["sdp ","rtp "]}},zt.fourcc="hnti",zt),Et,zo=(Et=class extends y{constructor(){super(...arguments),this.box_name="hintstatisticsbox",this.maxrs=[],this.subBoxNames=["maxr"]}},Et.fourcc="hinf",Et),kt,Eo=(kt=class extends y{constructor(){super(...arguments),this.box_name="SubTrackBox"}},kt.fourcc="strk",kt),It,ko=(It=class extends y{constructor(){super(...arguments),this.box_name="SubTrackDefinitionBox"}},It.fourcc="strd",It),Tt,Io=(Tt=class extends y{constructor(){super(...arguments),this.box_name="ProtectionSchemeInfoBox"}},Tt.fourcc="sinf",Tt),At,To=(At=class extends y{constructor(){super(...arguments),this.box_name="RestrictedSchemeInfoBox"}},At.fourcc="rinf",At),Pt,Ao=(Pt=class extends y{constructor(){super(...arguments),this.box_name="SchemeInformationBox"}},Pt.fourcc="schi",Pt),Ct,Po=(Ct=class extends y{constructor(){super(...arguments),this.box_name="TrackGroupBox"}},Ct.fourcc="trgr",Ct),Ft,Co=(Ft=class extends y{constructor(){super(...arguments),this.box_name="UserDataBox",this.kinds=[],this.strks=[],this.subBoxNames=["kind","strk"]}},Ft.fourcc="udta",Ft),Dt,Fo=(Dt=class extends y{constructor(){super(...arguments),this.box_name="ItemPropertiesBox",this.ipmas=[],this.subBoxNames=["ipma"]}},Dt.fourcc="iprp",Dt),Lt,Do=(Lt=class extends y{constructor(){super(...arguments),this.box_name="ItemPropertyContainerBox",this.hvcCs=[],this.ispes=[],this.claps=[],this.irots=[],this.subBoxNames=["hvcC","ispe","clap","irot"]}},Lt.fourcc="ipco",Lt),Ht,Lo=(Ht=class extends y{constructor(){super(...arguments),this.box_name="GroupsListBox"}},Ht.fourcc="grpl",Ht),Ot,Ho=(Ot=class extends y{constructor(){super(...arguments),this.box_name="J2KHeaderInfoBox"}},Ot.fourcc="j2kH",Ot),Mt,Oo=(Mt=class extends y{constructor(){super(...arguments),this.box_name="ExtendedTypeBox",this.tycos=[],this.subBoxNames=["tyco"]}},Mt.fourcc="etyp",Mt),Rt,Mo=(Rt=class extends y{constructor(){super(...arguments),this.box_name="ProjectedOmniVideoBox",this.subBoxNames=["prfr"]}},Rt.fourcc="povd",Rt),Nt,ga=(Nt=class extends d{constructor(){super(...arguments),this.box_name="DataReferenceBox"}parse(t){this.parseFullHeader(t),this.entries=[];const e=t.readUint32();for(let i=0;i<e;i++){const s=H(t,!1,this.size-(t.getPosition()-this.start));if(s.code===F){const n=s.box;this.entries.push(n)}else return}}write(t){this.version=0,this.flags=0,this.size=4,this.writeHeader(t),t.writeUint32(this.entries.length);for(let e=0;e<this.entries.length;e++)this.entries[e].write(t),this.size+=this.entries[e].size;l.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)}},Nt.fourcc="dref",Nt),Gt,xa=(Gt=class extends d{constructor(){super(...arguments),this.box_name="ExtendedLanguageBox"}parse(t){this.parseFullHeader(t),this.extended_language=t.readString(this.size-this.hdr_size)}write(t){this.version=0,this.flags=0,this.size=this.extended_language.length,this.writeHeader(t),t.writeString(this.extended_language)}},Gt.fourcc="elng",Gt),Vt,ya=(Vt=class extends p{constructor(){super(...arguments),this.box_name="FileTypeBox"}parse(t){let e=this.size-this.hdr_size;this.major_brand=t.readString(4),this.minor_version=t.readUint32(),e-=8,this.compatible_brands=[];let i=0;for(;e>=4;)this.compatible_brands[i]=t.readString(4),e-=4,i++}write(t){this.size=8+4*this.compatible_brands.length,this.writeHeader(t),t.writeString(this.major_brand,void 0,4),t.writeUint32(this.minor_version);for(let e=0;e<this.compatible_brands.length;e++)t.writeString(this.compatible_brands[e],void 0,4)}},Vt.fourcc="ftyp",Vt),jt,ba=(jt=class extends d{constructor(){super(...arguments),this.box_name="HandlerBox"}parse(t){if(this.parseFullHeader(t),this.version===0&&(t.readUint32(),this.handler=t.readString(4),t.readUint32Array(3),!this.isEndOfBox(t))){const e=this.start+this.size-t.getPosition();this.name=t.readCString();const i=this.start+this.size-1;t.seek(i),t.readUint8()!==0&&e>1&&(l.info("BoxParser","Warning: hdlr name is not null-terminated, possibly length-prefixed string. Trimming first byte."),this.name=this.name.slice(1))}}write(t){this.size=20+this.name.length+1,this.version=0,this.flags=0,this.writeHeader(t),t.writeUint32(0),t.writeString(this.handler,void 0,4),t.writeUint32Array([0,0,0]),t.writeCString(this.name)}},jt.fourcc="hdlr",jt),$t,va=($t=class extends p{constructor(){super(...arguments),this.box_name="HEVCConfigurationBox"}parse(t){this.configurationVersion=t.readUint8();let e=t.readUint8();this.general_profile_space=e>>6,this.general_tier_flag=(e&32)>>5,this.general_profile_idc=e&31,this.general_profile_compatibility=t.readUint32(),this.general_constraint_indicator=t.readUint8Array(6),this.general_level_idc=t.readUint8(),this.min_spatial_segmentation_idc=t.readUint16()&4095,this.parallelismType=t.readUint8()&3,this.chroma_format_idc=t.readUint8()&3,this.bit_depth_luma_minus8=t.readUint8()&7,this.bit_depth_chroma_minus8=t.readUint8()&7,this.avgFrameRate=t.readUint16(),e=t.readUint8(),this.constantFrameRate=e>>6,this.numTemporalLayers=(e&13)>>3,this.temporalIdNested=(e&4)>>2,this.lengthSizeMinusOne=e&3,this.nalu_arrays=[];const i=t.readUint8();for(let s=0;s<i;s++){const n=[];this.nalu_arrays.push(n),e=t.readUint8(),n.completeness=(e&128)>>7,n.nalu_type=e&63;const a=t.readUint16();for(let o=0;o<a;o++){const h=t.readUint16();n.push({data:t.readUint8Array(h)})}}}write(t){this.size=23;for(let e=0;e<this.nalu_arrays.length;e++){this.size+=3;for(let i=0;i<this.nalu_arrays[e].length;i++)this.size+=2+this.nalu_arrays[e][i].data.length}this.writeHeader(t),t.writeUint8(this.configurationVersion),t.writeUint8((this.general_profile_space<<6)+(this.general_tier_flag<<5)+this.general_profile_idc),t.writeUint32(this.general_profile_compatibility),t.writeUint8Array(this.general_constraint_indicator),t.writeUint8(this.general_level_idc),t.writeUint16(this.min_spatial_segmentation_idc+(15<<24)),t.writeUint8(this.parallelismType+252),t.writeUint8(this.chroma_format_idc+252),t.writeUint8(this.bit_depth_luma_minus8+248),t.writeUint8(this.bit_depth_chroma_minus8+248),t.writeUint16(this.avgFrameRate),t.writeUint8((this.constantFrameRate<<6)+(this.numTemporalLayers<<3)+(this.temporalIdNested<<2)+this.lengthSizeMinusOne),t.writeUint8(this.nalu_arrays.length);for(let e=0;e<this.nalu_arrays.length;e++){t.writeUint8((this.nalu_arrays[e].completeness<<7)+this.nalu_arrays[e].nalu_type),t.writeUint16(this.nalu_arrays[e].length);for(let i=0;i<this.nalu_arrays[e].length;i++)t.writeUint16(this.nalu_arrays[e][i].data.length),t.writeUint8Array(this.nalu_arrays[e][i].data)}}},$t.fourcc="hvcC",$t),qt,Ua=(qt=class extends d{constructor(){super(...arguments),this.box_name="MediaHeaderBox"}parse(t){this.parseFullHeader(t),this.version===1?(this.creation_time=t.readUint64(),this.modification_time=t.readUint64(),this.timescale=t.readUint32(),this.duration=t.readUint64()):(this.creation_time=t.readUint32(),this.modification_time=t.readUint32(),this.timescale=t.readUint32(),this.duration=t.readUint32()),this.parseLanguage(t),t.readUint16()}write(t){const e=this.modification_time>w||this.creation_time>w||this.duration>w||this.version===1;this.version=e?1:0,this.size=20,this.size+=e?12:0,this.flags=0,this.writeHeader(t),e?(t.writeUint64(this.creation_time),t.writeUint64(this.modification_time),t.writeUint32(this.timescale),t.writeUint64(this.duration)):(t.writeUint32(this.creation_time),t.writeUint32(this.modification_time),t.writeUint32(this.timescale),t.writeUint32(this.duration)),t.writeUint16(this.language),t.writeUint16(0)}},qt.fourcc="mdhd",qt),Yt,Sa=(Yt=class extends d{constructor(){super(...arguments),this.box_name="MovieExtendsHeaderBox"}parse(t){this.parseFullHeader(t),this.flags&1&&(l.warn("BoxParser","mehd box incorrectly uses flags set to 1, converting version to 1"),this.version=1),this.version===1?this.fragment_duration=t.readUint64():this.fragment_duration=t.readUint32()}write(t){const e=this.fragment_duration>w||this.version===1;this.version=e?1:0,this.size=4,this.size+=e?4:0,this.flags=0,this.writeHeader(t),e?t.writeUint64(this.fragment_duration):t.writeUint32(this.fragment_duration)}},Yt.fourcc="mehd",Yt),Wt,Ro=(Wt=class extends d{constructor(){super(...arguments),this.box_name="ItemInfoEntry"}parse(t){if(this.parseFullHeader(t),(this.version===0||this.version===1)&&(this.item_ID=t.readUint16(),this.item_protection_index=t.readUint16(),this.item_name=t.readCString(),this.content_type=t.readCString(),this.isEndOfBox(t)||(this.content_encoding=t.readCString())),this.version===1){this.extension_type=t.readString(4),l.warn("BoxParser","Cannot parse extension type"),t.seek(this.start+this.size);return}this.version>=2&&(this.version===2?this.item_ID=t.readUint16():this.version===3&&(this.item_ID=t.readUint32()),this.item_protection_index=t.readUint16(),this.item_type=t.readString(4),this.item_name=t.readCString(),this.item_type==="mime"?(this.content_type=t.readCString(),this.content_encoding=t.readCString()):this.item_type==="uri "&&(this.item_uri_type=t.readCString()))}},Wt.fourcc="infe",Wt),Kt,No=(Kt=class extends d{constructor(){super(...arguments),this.box_name="ItemInfoBox"}parse(t){this.parseFullHeader(t),this.version===0?this.entry_count=t.readUint16():this.entry_count=t.readUint32(),this.item_infos=[];for(let e=0;e<this.entry_count;e++){const i=H(t,!1,this.size-(t.getPosition()-this.start));if(i.code===F){const s=i.box;s.type==="infe"?this.item_infos[e]=s:l.error("BoxParser","Expected 'infe' box, got "+i.box.type,t.isofile)}else return}}},Kt.fourcc="iinf",Kt),Xt,Go=(Xt=class extends d{constructor(){super(...arguments),this.box_name="ItemLocationBox"}parse(t){this.parseFullHeader(t);let e;e=t.readUint8(),this.offset_size=e>>4&15,this.length_size=e&15,e=t.readUint8(),this.base_offset_size=e>>4&15,this.version===1||this.version===2?this.index_size=e&15:this.index_size=0,this.items=[];let i=0;if(this.version<2)i=t.readUint16();else if(this.version===2)i=t.readUint32();else throw new Error("version of iloc box not supported");for(let s=0;s<i;s++){let n=0,a=0,o=0;if(this.version<2)n=t.readUint16();else if(this.version===2)n=t.readUint32();else throw new Error("version of iloc box not supported");this.version===1||this.version===2?a=t.readUint16()&15:a=0;const h=t.readUint16();switch(this.base_offset_size){case 0:o=0;break;case 4:o=t.readUint32();break;case 8:o=t.readUint64();break;default:throw new Error("Error reading base offset size")}const c=[],f=t.readUint16();for(let u=0;u<f;u++){let _=0,m=0,v=0;if(this.version===1||this.version===2)switch(this.index_size){case 0:_=0;break;case 4:_=t.readUint32();break;case 8:_=t.readUint64();break;default:throw new Error("Error reading extent index")}switch(this.offset_size){case 0:m=0;break;case 4:m=t.readUint32();break;case 8:m=t.readUint64();break;default:throw new Error("Error reading extent index")}switch(this.length_size){case 0:v=0;break;case 4:v=t.readUint32();break;case 8:v=t.readUint64();break;default:throw new Error("Error reading extent index")}c.push({extent_index:_,extent_length:v,extent_offset:m})}this.items.push({base_offset:o,construction_method:a,item_ID:n,data_reference_index:h,extents:c})}}},Xt.fourcc="iloc",Xt),Vo={auxl:"Auxiliary image item",base:"Pre-derived image item base",cdsc:"Item describes referenced item",dimg:"Derived image item",dpnd:"Item coding dependency",eroi:"Region",evir:"EVC slice",exbl:"Scalable image item","fdl ":"File delivery",font:"Font item",iloc:"Item data location",mask:"Region mask",mint:"Data integrity",pred:"Predictively coded item",prem:"Pre-multiplied item",tbas:"HEVC tile track base item",thmb:"Thumbnail image item"},q,jo=(q=class extends d{constructor(){super(...arguments),this.box_name="ItemReferenceBox",this.references=[]}parse(t){for(this.parseFullHeader(t),this.references=[];t.getPosition()<this.start+this.size;){const e=H(t,!0,this.size-(t.getPosition()-this.start));if(e.code===F){let i="Unknown item reference";q.allowed_types.includes(e.type)?i=Vo[e.type]:l.warn("BoxParser",`Unknown item reference type: '${e.type}'`);const s=this.version===0?new eo(e.type,e.size,i,e.hdr_size,e.start):new io(e.type,e.size,i,e.hdr_size,e.start);s.write===p.prototype.write&&s.type!=="mdat"&&(l.warn("BoxParser",s.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),s.parseDataAndRewind(t)),s.parse(t),this.references.push(s)}else return}}},q.fourcc="iref",q.allowed_types=["auxl","base","cdsc","dimg","dpnd","eroi","evir","exbl","fdl ","font","iloc","mask","mint","pred","prem","tbas","thmb"],q),Qt,$o=(Qt=class extends d{constructor(){super(...arguments),this.box_name="PrimaryItemBox"}parse(t){this.parseFullHeader(t),this.version===0?this.item_id=t.readUint16():this.item_id=t.readUint32()}},Qt.fourcc="pitm",Qt),Jt,qo=(Jt=class extends d{constructor(){super(...arguments),this.box_name="MetaBox",this.isQT=!1}parse(t){const e=t.getPosition();if(this.size>8){switch(t.readUint32(),t.readString(4)){case"hdlr":case"mhdr":case"keys":case"ilst":case"ctry":case"lang":this.isQT=!0;break}t.seek(e)}this.isQT||this.parseFullHeader(t),y.prototype.parse.call(this,t)}},Jt.fourcc="meta",Jt),Zt,Ba=(Zt=class extends d{constructor(){super(...arguments),this.box_name="MovieFragmentHeaderBox"}parse(t){this.parseFullHeader(t),this.sequence_number=t.readUint32()}write(t){this.version=0,this.flags=0,this.size=4,this.writeHeader(t),t.writeUint32(this.sequence_number)}},Zt.fourcc="mfhd",Zt),te,wa=(te=class extends d{constructor(){super(...arguments),this.box_name="MovieHeaderBox"}parse(t){this.parseFullHeader(t),this.version===1?(this.creation_time=t.readUint64(),this.modification_time=t.readUint64(),this.timescale=t.readUint32(),this.duration=t.readUint64()):(this.creation_time=t.readUint32(),this.modification_time=t.readUint32(),this.timescale=t.readUint32(),this.duration=t.readUint32()),this.rate=t.readUint32(),this.volume=t.readUint16()>>8,t.readUint16(),t.readUint32Array(2),this.matrix=t.readInt32Array(9),t.readUint32Array(6),this.next_track_id=t.readUint32()}write(t){const e=this.modification_time>w||this.creation_time>w||this.duration>w||this.version===1;this.version=e?1:0,this.size=96,this.size+=e?12:0,this.flags=0,this.writeHeader(t),e?(t.writeUint64(this.creation_time),t.writeUint64(this.modification_time),t.writeUint32(this.timescale),t.writeUint64(this.duration)):(t.writeUint32(this.creation_time),t.writeUint32(this.modification_time),t.writeUint32(this.timescale),t.writeUint32(this.duration)),t.writeUint32(this.rate),t.writeUint16(this.volume<<8),t.writeUint16(0),t.writeUint32(0),t.writeUint32(0),t.writeInt32Array(this.matrix),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(0),t.writeUint32(this.next_track_id)}print(t){super.printHeader(t),t.log(t.indent+"creation_time: "+this.creation_time),t.log(t.indent+"modification_time: "+this.modification_time),t.log(t.indent+"timescale: "+this.timescale),t.log(t.indent+"duration: "+this.duration),t.log(t.indent+"rate: "+this.rate),t.log(t.indent+"volume: "+(this.volume>>8)),t.log(t.indent+"matrix: "+this.matrix.join(", ")),t.log(t.indent+"next_track_id: "+this.next_track_id)}},te.fourcc="mvhd",te),ee,Yo=(ee=class extends an{parse(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.mime_format=t.readCString(),this.parseFooter(t)}},ee.fourcc="mett",ee),ie,Wo=(ie=class extends an{parse(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.namespace=t.readCString(),this.schema_location=t.readCString(),this.parseFooter(t)}},ie.fourcc="metx",ie),se,Ko=(se=class extends p{constructor(){super(...arguments),this.box_name="AV1CodecConfigurationBox"}parse(t){let e=t.readUint8();if((e>>7&1)!==1){l.error("BoxParser","av1C marker problem",t.isofile);return}if(this.version=e&127,this.version!==1){l.error("BoxParser","av1C version "+this.version+" not supported",t.isofile);return}if(e=t.readUint8(),this.seq_profile=e>>5&7,this.seq_level_idx_0=e&31,e=t.readUint8(),this.seq_tier_0=e>>7&1,this.high_bitdepth=e>>6&1,this.twelve_bit=e>>5&1,this.monochrome=e>>4&1,this.chroma_subsampling_x=e>>3&1,this.chroma_subsampling_y=e>>2&1,this.chroma_sample_position=e&3,e=t.readUint8(),this.reserved_1=e>>5&7,this.reserved_1!==0){l.error("BoxParser","av1C reserved_1 parsing problem",t.isofile);return}if(this.initial_presentation_delay_present=e>>4&1,this.initial_presentation_delay_present===1)this.initial_presentation_delay_minus_one=e&15;else if(this.reserved_2=e&15,this.reserved_2!==0){l.error("BoxParser","av1C reserved_2 parsing problem",t.isofile);return}const i=this.size-this.hdr_size-4;this.configOBUs=t.readUint8Array(i)}},se.fourcc="av1C",se),re,Xo=(re=class extends d{constructor(){super(...arguments),this.box_name="ElementaryStreamDescriptorBox"}parse(t){this.parseFullHeader(t);const e=t.readUint8Array(this.size-this.hdr_size);if("MPEG4DescriptorParser"in Tn){const i=new Tn.MPEG4DescriptorParser;this.esd=i.parseOneDescriptor(new z(e.buffer,0))}}},re.fourcc="esds",re),ne,Qo=(ne=class extends d{constructor(){super(...arguments),this.box_name="VPCodecConfigurationRecord"}parse(t){if(this.parseFullHeader(t),this.version===1){this.profile=t.readUint8(),this.level=t.readUint8();const e=t.readUint8();this.bitDepth=e>>4,this.chromaSubsampling=e>>1&7,this.videoFullRangeFlag=e&1,this.colourPrimaries=t.readUint8(),this.transferCharacteristics=t.readUint8(),this.matrixCoefficients=t.readUint8(),this.codecIntializationDataSize=t.readUint16(),this.codecIntializationData=t.readUint8Array(this.codecIntializationDataSize)}else{this.profile=t.readUint8(),this.level=t.readUint8();let e=t.readUint8();this.bitDepth=e>>4&15,this.colorSpace=e&15,e=t.readUint8(),this.chromaSubsampling=e>>4&15,this.transferFunction=e>>1&7,this.videoFullRangeFlag=e&1,this.codecIntializationDataSize=t.readUint16(),this.codecIntializationData=t.readUint8Array(this.codecIntializationDataSize)}}},ne.fourcc="vpcC",ne),ae,Jo=(ae=class extends d{constructor(){super(...arguments),this.box_name="VvcConfigurationBox"}parse(t){this.parseFullHeader(t);const e={held_bits:void 0,num_held_bits:0,stream_read_1_bytes:function(a){this.held_bits=a.readUint8(),this.num_held_bits=8},stream_read_2_bytes:function(a){this.held_bits=a.readUint16(),this.num_held_bits=16},extract_bits:function(a){const o=this.held_bits>>this.num_held_bits-a&(1<<a)-1;return this.num_held_bits-=a,o}};if(e.stream_read_1_bytes(t),e.extract_bits(5),this.lengthSizeMinusOne=e.extract_bits(2),this.ptl_present_flag=e.extract_bits(1),this.ptl_present_flag){e.stream_read_2_bytes(t),this.ols_idx=e.extract_bits(9),this.num_sublayers=e.extract_bits(3),this.constant_frame_rate=e.extract_bits(2),this.chroma_format_idc=e.extract_bits(2),e.stream_read_1_bytes(t),this.bit_depth_minus8=e.extract_bits(3),e.extract_bits(5);{if(e.stream_read_2_bytes(t),e.extract_bits(2),this.num_bytes_constraint_info=e.extract_bits(6),this.general_profile_idc=e.extract_bits(7),this.general_tier_flag=e.extract_bits(1),this.general_level_idc=t.readUint8(),e.stream_read_1_bytes(t),this.ptl_frame_only_constraint_flag=e.extract_bits(1),this.ptl_multilayer_enabled_flag=e.extract_bits(1),this.general_constraint_info=new Uint8Array(this.num_bytes_constraint_info),this.num_bytes_constraint_info){for(let a=0;a<this.num_bytes_constraint_info-1;a++){const o=e.extract_bits(6);e.stream_read_1_bytes(t);const h=e.extract_bits(2);this.general_constraint_info[a]=o<<2|h}this.general_constraint_info[this.num_bytes_constraint_info-1]=e.extract_bits(6)}else e.extract_bits(6);if(this.num_sublayers>1){e.stream_read_1_bytes(t),this.ptl_sublayer_present_mask=0;for(let a=this.num_sublayers-2;a>=0;--a){const o=e.extract_bits(1);this.ptl_sublayer_present_mask|=o<<a}for(let a=this.num_sublayers;a<=8&&this.num_sublayers>1;++a)e.extract_bits(1);this.sublayer_level_idc=[];for(let a=this.num_sublayers-2;a>=0;--a)this.ptl_sublayer_present_mask&1<<a&&(this.sublayer_level_idc[a]=t.readUint8())}if(this.ptl_num_sub_profiles=t.readUint8(),this.general_sub_profile_idc=[],this.ptl_num_sub_profiles)for(let a=0;a<this.ptl_num_sub_profiles;a++)this.general_sub_profile_idc.push(t.readUint32())}this.max_picture_width=t.readUint16(),this.max_picture_height=t.readUint16(),this.avg_frame_rate=t.readUint16()}const i=12,s=13;this.nalu_arrays=[];const n=t.readUint8();for(let a=0;a<n;a++){const o=[];this.nalu_arrays.push(o),e.stream_read_1_bytes(t),o.completeness=e.extract_bits(1),e.extract_bits(2),o.nalu_type=e.extract_bits(5);let h=1;o.nalu_type!==s&&o.nalu_type!==i&&(h=t.readUint16());for(let c=0;c<h;c++){const f=t.readUint16();o.push({data:t.readUint8Array(f),length:f})}}}},ae.fourcc="vvcC",ae),oe,Zo=(oe=class extends p{constructor(){super(...arguments),this.box_name="ColourInformationBox"}parse(t){if(this.colour_type=t.readString(4),this.colour_type==="nclx"){this.colour_primaries=t.readUint16(),this.transfer_characteristics=t.readUint16(),this.matrix_coefficients=t.readUint16();const e=t.readUint8();this.full_range_flag=e>>7}else this.colour_type==="rICC"?this.ICC_profile=t.readUint8Array(this.size-4):this.colour_type==="prof"&&(this.ICC_profile=t.readUint8Array(this.size-4))}},oe.fourcc="colr",oe);function J(r,t){let e=Number(r).toString(16);for(t=typeof t>"u"?2:t;e.length<t;)e="0"+e;return e}var Pn=class extends U{getCodec(){const r=super.getCodec();return this.avcC?`${r}.${J(this.avcC.AVCProfileIndication)}${J(this.avcC.profile_compatibility)}${J(this.avcC.AVCLevelIndication)}`:r}},he,th=(he=class extends Pn{constructor(){super(...arguments),this.box_name="AVCSampleEntry"}},he.fourcc="avc1",he),ce,eh=(ce=class extends Pn{constructor(){super(...arguments),this.box_name="AVC2SampleEntry"}},ce.fourcc="avc2",ce),le,ih=(le=class extends Pn{constructor(){super(...arguments),this.box_name="AVCSampleEntry"}},le.fourcc="avc3",le),de,sh=(de=class extends Pn{constructor(){super(...arguments),this.box_name="AVC2SampleEntry"}},de.fourcc="avc4",de),fe,rh=(fe=class extends U{constructor(){super(...arguments),this.box_name="AV1SampleEntry"}getCodec(){const t=super.getCodec(),e=this.av1C.seq_level_idx_0,i=e<10?"0"+e:e;let s;return this.av1C.seq_profile===2&&this.av1C.high_bitdepth===1?s=this.av1C.twelve_bit===1?"12":"10":this.av1C.seq_profile<=2&&(s=this.av1C.high_bitdepth===1?"10":"08"),t+"."+this.av1C.seq_profile+"."+i+(this.av1C.seq_tier_0?"H":"M")+"."+s}},fe.fourcc="av01",fe),ue,nh=(ue=class extends U{},ue.fourcc="dav1",ue),Cn=class extends U{getCodec(){let r=super.getCodec();if(this.hvcC){switch(r+=".",this.hvcC.general_profile_space){case 0:r+="";break;case 1:r+="A";break;case 2:r+="B";break;case 3:r+="C";break}r+=this.hvcC.general_profile_idc,r+=".";let t=this.hvcC.general_profile_compatibility,e=0;for(let n=0;n<32&&(e|=t&1,n!==31);n++)e<<=1,t>>=1;r+=J(e,0),r+=".",this.hvcC.general_tier_flag===0?r+="L":r+="H",r+=this.hvcC.general_level_idc;let i=!1,s="";for(let n=5;n>=0;n--)(this.hvcC.general_constraint_indicator[n]||i)&&(s="."+J(this.hvcC.general_constraint_indicator[n],0)+s,i=!0);r+=s}return r}},pe,ah=(pe=class extends Cn{constructor(){super(...arguments),this.box_name="HEVCSampleEntry"}},pe.fourcc="hvc1",pe),_e,oh=(_e=class extends Cn{},_e.fourcc="hvc2",_e),me,hh=(me=class extends Cn{constructor(){super(...arguments),this.box_name="HEVCSampleEntry",this.colrs=[],this.subBoxNames=["colr"]}},me.fourcc="hev1",me),ge,ch=(ge=class extends Cn{},ge.fourcc="hev2",ge),xe,lh=(xe=class extends U{constructor(){super(...arguments),this.box_name="HEVCTileSampleSampleEntry"}},xe.fourcc="hvt1",xe),ye,dh=(ye=class extends U{constructor(){super(...arguments),this.box_name="LHEVCSampleEntry"}},ye.fourcc="lhe1",ye),be,fh=(be=class extends U{constructor(){super(...arguments),this.box_name="LHEVCSampleEntry"}},be.fourcc="lhv1",be),ve,uh=(ve=class extends U{},ve.fourcc="dvh1",ve),Ue,ph=(Ue=class extends U{},Ue.fourcc="dvhe",Ue),za=class extends U{getCodec(){let r=super.getCodec();if(this.vvcC){r+="."+this.vvcC.general_profile_idc,this.vvcC.general_tier_flag?r+=".H":r+=".L",r+=this.vvcC.general_level_idc;let t="";if(this.vvcC.general_constraint_info){const e=[];let i=0;i|=this.vvcC.ptl_frame_only_constraint_flag<<7,i|=this.vvcC.ptl_multilayer_enabled_flag<<6;let s;for(let n=0;n<this.vvcC.general_constraint_info.length;++n)i|=this.vvcC.general_constraint_info[n]>>2&63,e.push(i),i&&(s=n),i=this.vvcC.general_constraint_info[n]>>2&3;if(s===void 0)t=".CA";else{t=".C";const n="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";let a=0,o=0;for(let h=0;h<=s;++h)for(a=a<<8|e[h],o+=8;o>=5;){const c=a>>o-5&31;t+=n[c],o-=5,a&=(1<<o)-1}o&&(a<<=5-o,t+=n[a&31])}}r+=t}return r}},Se,_h=(Se=class extends za{constructor(){super(...arguments),this.box_name="VvcSampleEntry"}},Se.fourcc="vvc1",Se),Be,mh=(Be=class extends za{constructor(){super(...arguments),this.box_name="VvcSampleEntry"}},Be.fourcc="vvi1",Be),we,gh=(we=class extends U{constructor(){super(...arguments),this.box_name="VvcSampleEntry"}},we.fourcc="vvs1",we),ze,xh=(ze=class extends U{constructor(){super(...arguments),this.box_name="VvcNonVCLSampleEntry"}},ze.fourcc="vvcN",ze),Ea=class extends U{getCodec(){const r=super.getCodec();let t=this.vpcC.level;t===0&&(t="00");let e=this.vpcC.bitDepth;return e===8&&(e="08"),`${r}.0${this.vpcC.profile}.${t}.${e}`}},Ee,yh=(Ee=class extends Ea{},Ee.fourcc="vp08",Ee),ke,bh=(ke=class extends Ea{},ke.fourcc="vp09",ke),Ie,vh=(Ie=class extends U{},Ie.fourcc="avs3",Ie),Te,Uh=(Te=class extends U{constructor(){super(...arguments),this.box_name="J2KSampleEntry"}},Te.fourcc="j2ki",Te),Ae,Sh=(Ae=class extends U{},Ae.fourcc="mjp2",Ae),Pe,Bh=(Pe=class extends U{},Pe.fourcc="mjpg",Pe),Ce,wh=(Ce=class extends U{constructor(){super(...arguments),this.box_name="UncompressedVideoSampleEntry"}},Ce.fourcc="uncv",Ce),Fe,zh=(Fe=class extends U{constructor(){super(...arguments),this.box_name="MP4VisualSampleEntry"}},Fe.fourcc="mp4v",Fe),De,Eh=(De=class extends D{constructor(){super(...arguments),this.box_name="MP4AudioSampleEntry"}getCodec(){const t=super.getCodec();if(this.esds&&this.esds.esd){const e=this.esds.esd.getOTI(),i=this.esds.esd.getAudioConfig();return t+"."+J(e)+(i?"."+i:"")}else return t}},De.fourcc="mp4a",De),Le,kh=(Le=class extends D{},Le.fourcc="m4ae",Le),He,Ih=(He=class extends D{},He.fourcc="ac-3",He),Oe,Th=(Oe=class extends D{},Oe.fourcc="ac-4",Oe),Me,Ah=(Me=class extends D{},Me.fourcc="ec-3",Me),Re,Ph=(Re=class extends D{},Re.fourcc="Opus",Re),Ne,Ch=(Ne=class extends D{},Ne.fourcc="mha1",Ne),Ge,Fh=(Ge=class extends D{},Ge.fourcc="mha2",Ge),Ve,Dh=(Ve=class extends D{},Ve.fourcc="mhm1",Ve),je,Lh=(je=class extends D{},je.fourcc="mhm2",je),$e,Hh=($e=class extends D{},$e.fourcc="fLaC",$e),qe,Oh=(qe=class extends U{},qe.fourcc="encv",qe),Ye,Mh=(Ye=class extends D{},Ye.fourcc="enca",Ye),We,Rh=(We=class extends X{constructor(){super(...arguments),this.subBoxNames=["sinf"],this.sinfs=[]}},We.fourcc="encu",We),Ke,Nh=(Ke=class extends qn{constructor(){super(...arguments),this.subBoxNames=["sinf"],this.sinfs=[]}},Ke.fourcc="encs",Ke),Xe,Gh=(Xe=class extends qn{},Xe.fourcc="mp4s",Xe),Qe,Vh=(Qe=class extends uo{constructor(){super(...arguments),this.subBoxNames=["sinf"],this.sinfs=[]}},Qe.fourcc="enct",Qe),Je,jh=(Je=class extends an{constructor(){super(...arguments),this.subBoxNames=["sinf"],this.sinfs=[]}},Je.fourcc="encm",Je),Ze,$h=(Ze=class extends U{constructor(){super(...arguments),this.box_name="RestrictedVideoSampleEntry"}},Ze.fourcc="resv",Ze),ti,qh=(ti=class extends X{parse(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.mime_format=t.readCString(),this.parseFooter(t)}},ti.fourcc="sbtt",ti),ei,ka=(ei=class extends X{parse(t){this.parseHeader(t),this.namespace=t.readCString(),this.schema_location=t.readCString(),this.auxiliary_mime_types=t.readCString(),this.parseFooter(t)}write(t){this.writeHeader(t),this.size+=this.namespace.length+1+this.schema_location.length+1+this.auxiliary_mime_types.length+1,t.writeCString(this.namespace),t.writeCString(this.schema_location),t.writeCString(this.auxiliary_mime_types),this.writeFooter(t)}},ei.fourcc="stpp",ei),ii,Yh=(ii=class extends X{parse(t){this.parseHeader(t),this.content_encoding=t.readCString(),this.mime_format=t.readCString(),this.parseFooter(t)}getCodec(){const t=super.getCodec();return this.mime_format?t+"."+this.mime_format:t}},ii.fourcc="stxt",ii),si,Wh=(si=class extends X{parse(t){this.parseHeader(t),this.displayFlags=t.readUint32(),this.horizontal_justification=t.readInt8(),this.vertical_justification=t.readInt8(),this.bg_color_rgba=t.readUint8Array(4),this.box_record=t.readInt16Array(4),this.style_record=t.readUint8Array(12),this.parseFooter(t)}},si.fourcc="tx3g",si),ri,Kh=(ri=class extends an{parse(t){this.parseHeader(t),this.parseFooter(t)}},ri.fourcc="wvtt",ri),ni,Xh=(ni=class extends d{constructor(){super(...arguments),this.box_name="SampleToGroupBox"}parse(t){this.parseFullHeader(t),this.grouping_type=t.readString(4),this.version===1?this.grouping_type_parameter=t.readUint32():this.grouping_type_parameter=0,this.entries=[];const e=t.readUint32();for(let i=0;i<e;i++)this.entries.push({sample_count:t.readInt32(),group_description_index:t.readInt32()})}write(t){this.grouping_type_parameter?this.version=1:this.version=0,this.flags=0,this.size=8+8*this.entries.length+(this.version===1?4:0),this.writeHeader(t),t.writeString(this.grouping_type,void 0,4),this.version===1&&t.writeUint32(this.grouping_type_parameter),t.writeUint32(this.entries.length);for(let e=0;e<this.entries.length;e++){const i=this.entries[e];t.writeInt32(i.sample_count),t.writeInt32(i.group_description_index)}}},ni.fourcc="sbgp",ni),ai,Qh=(ai=class extends d{constructor(){super(...arguments),this.box_name="SampleDependencyTypeBox"}parse(t){this.parseFullHeader(t);const e=this.size-this.hdr_size;this.is_leading=[],this.sample_depends_on=[],this.sample_is_depended_on=[],this.sample_has_redundancy=[];for(let i=0;i<e;i++){const s=t.readUint8();this.is_leading[i]=s>>6,this.sample_depends_on[i]=s>>4&3,this.sample_is_depended_on[i]=s>>2&3,this.sample_has_redundancy[i]=s&3}}},ai.fourcc="sdtp",ai),oi,Jh=(oi=class extends d{constructor(){super(...arguments),this.box_name="SampleGroupDescriptionBox"}parse(t){this.parseFullHeader(t),this.grouping_type=t.readString(4),l.debug("BoxParser","Found Sample Groups of type "+this.grouping_type),this.version===1?this.default_length=t.readUint32():this.default_length=0,this.version>=2&&(this.default_group_description_index=t.readUint32()),this.entries=[];const e=t.readUint32();for(let i=0;i<e;i++){let s;this.grouping_type in C.sampleGroupEntry?s=new C.sampleGroupEntry[this.grouping_type](this.grouping_type):s=new B(this.grouping_type),this.entries.push(s),this.version===1?this.default_length===0?s.description_length=t.readUint32():s.description_length=this.default_length:s.description_length=this.default_length,s.write===B.prototype.write&&(l.info("BoxParser","SampleGroup for type "+this.grouping_type+" writing not yet implemented, keeping unparsed data in memory for later write"),s.data=t.readUint8Array(s.description_length),t.seek(t.getPosition()-s.description_length)),s.parse(t)}}write(t){this.flags=0,this.size=12;for(let e=0;e<this.entries.length;e++){const i=this.entries[e];this.version===1&&(this.default_length===0&&(this.size+=4),this.size+=i.data.length)}this.writeHeader(t),t.writeString(this.grouping_type,void 0,4),this.version===1&&t.writeUint32(this.default_length),this.version>=2&&t.writeUint32(this.default_sample_description_index),t.writeUint32(this.entries.length);for(let e=0;e<this.entries.length;e++){const i=this.entries[e];this.version===1&&this.default_length===0&&t.writeUint32(i.description_length),i.write(t)}}},oi.fourcc="sgpd",oi),hi,Zh=(hi=class extends d{constructor(){super(...arguments),this.box_name="CompressedSegmentIndexBox"}parse(t){this.parseFullHeader(t),this.reference_ID=t.readUint32(),this.timescale=t.readUint32(),this.version===0?(this.earliest_presentation_time=t.readUint32(),this.first_offset=t.readUint32()):(this.earliest_presentation_time=t.readUint64(),this.first_offset=t.readUint64()),t.readUint16(),this.references=[];const e=t.readUint16();for(let i=0;i<e;i++){const s=t.readUint32(),n=t.readUint32(),a=t.readUint32();this.references.push({reference_type:s>>31&1,referenced_size:s&2147483647,subsegment_duration:n,starts_with_SAP:a>>31&1,SAP_type:a>>28&7,SAP_delta_time:a&268435455})}}write(t){const e=this.earliest_presentation_time>w||this.first_offset>w||this.version===1;this.version=e?1:0,this.size=12+12*this.references.length,this.size+=e?16:8,this.flags=0,this.writeHeader(t),t.writeUint32(this.reference_ID),t.writeUint32(this.timescale),e?(t.writeUint64(this.earliest_presentation_time),t.writeUint64(this.first_offset)):(t.writeUint32(this.earliest_presentation_time),t.writeUint32(this.first_offset)),t.writeUint16(0),t.writeUint16(this.references.length);for(let i=0;i<this.references.length;i++){const s=this.references[i];t.writeUint32(s.reference_type<<31|s.referenced_size),t.writeUint32(s.subsegment_duration),t.writeUint32(s.starts_with_SAP<<31|s.SAP_type<<28|s.SAP_delta_time)}}},hi.fourcc="sidx",hi),ci,Ia=(ci=class extends d{constructor(){super(...arguments),this.box_name="SoundMediaHeaderBox"}parse(t){this.parseFullHeader(t),this.balance=t.readUint16(),t.readUint16()}write(t){this.version=0,this.size=4,this.writeHeader(t),t.writeUint16(this.balance),t.writeUint16(0)}},ci.fourcc="smhd",ci),li,Ta=(li=class extends d{constructor(){super(...arguments),this.box_name="ChunkOffsetBox"}parse(t){this.parseFullHeader(t);const e=t.readUint32();if(this.chunk_offsets=[],this.version===0)for(let i=0;i<e;i++)this.chunk_offsets.push(t.readUint32())}write(t){this.version=0,this.flags=0,this.size=4+4*this.chunk_offsets.length,this.writeHeader(t),t.writeUint32(this.chunk_offsets.length),t.writeUint32Array(this.chunk_offsets)}unpack(t){for(let e=0;e<this.chunk_offsets.length;e++)t[e].offset=this.chunk_offsets[e]}},li.fourcc="stco",li),di,Aa=(di=class extends d{constructor(){super(...arguments),this.box_name="SubtitleMediaHeaderBox"}},di.fourcc="sthd",di),fi,Pa=(fi=class extends d{constructor(){super(...arguments),this.box_name="SampleToChunkBox"}parse(t){this.parseFullHeader(t);const e=t.readUint32();if(this.first_chunk=[],this.samples_per_chunk=[],this.sample_description_index=[],this.version===0)for(let i=0;i<e;i++)this.first_chunk.push(t.readUint32()),this.samples_per_chunk.push(t.readUint32()),this.sample_description_index.push(t.readUint32())}write(t){this.version=0,this.flags=0,this.size=4+12*this.first_chunk.length,this.writeHeader(t),t.writeUint32(this.first_chunk.length);for(let e=0;e<this.first_chunk.length;e++)t.writeUint32(this.first_chunk[e]),t.writeUint32(this.samples_per_chunk[e]),t.writeUint32(this.sample_description_index[e])}unpack(t){let e=0,i=0;for(let s=0;s<this.first_chunk.length;s++)for(let n=0;n<(s+1<this.first_chunk.length?this.first_chunk[s+1]:1/0);n++){i++;for(let a=0;a<this.samples_per_chunk[s];a++){if(t[e])t[e].description_index=this.sample_description_index[s],t[e].chunk_index=i;else return;e++}}}},fi.fourcc="stsc",fi),ui,Ca=(ui=class extends d{constructor(){super(...arguments),this.box_name="SampleDescriptionBox"}parse(t){this.parseFullHeader(t),this.entries=[];const e=t.readUint32();for(let i=1;i<=e;i++){const s=H(t,!0,this.size-(t.getPosition()-this.start));if(s.code===F){let n;s.type in C.sampleEntry?(n=new C.sampleEntry[s.type](s.size),n.hdr_size=s.hdr_size,n.start=s.start):(l.warn("BoxParser",`Unknown sample entry type: '${s.type}'`),n=new G(s.size,s.hdr_size,s.start),n.type=s.type),n.write===G.prototype.write&&(l.info("BoxParser","SampleEntry "+n.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),n.parseDataAndRewind(t)),n.parse(t),this.entries.push(n)}else return}}write(t){this.version=0,this.flags=0,this.size=0,this.writeHeader(t),t.writeUint32(this.entries.length),this.size+=4;for(let e=0;e<this.entries.length;e++)this.entries[e].write(t),this.size+=this.entries[e].size;l.debug("BoxWriter","Adjusting box "+this.type+" with new size "+this.size),t.adjustUint32(this.sizePosition,this.size)}},ui.fourcc="stsd",ui),pi,Fa=(pi=class extends d{constructor(){super(...arguments),this.box_name="SampleSizeBox"}parse(t){if(this.parseFullHeader(t),this.sample_sizes=[],this.version===0){this.sample_size=t.readUint32(),this.sample_count=t.readUint32();for(let e=0;e<this.sample_count;e++)this.sample_size===0?this.sample_sizes.push(t.readUint32()):this.sample_sizes[e]=this.sample_size}}write(t){let e=!0;if(this.version=0,this.flags=0,this.sample_sizes.length>0){let i=0;for(;i+1<this.sample_sizes.length;)if(this.sample_sizes[i+1]!==this.sample_sizes[0]){e=!1;break}else i++}else e=!1;this.size=8,e||(this.size+=4*this.sample_sizes.length),this.writeHeader(t),e?t.writeUint32(this.sample_sizes[0]):t.writeUint32(0),t.writeUint32(this.sample_sizes.length),e||t.writeUint32Array(this.sample_sizes)}unpack(t){for(let e=0;e<this.sample_sizes.length;e++)t[e].size=this.sample_sizes[e]}},pi.fourcc="stsz",pi),_i,Da=(_i=class extends d{constructor(){super(...arguments),this.box_name="TimeToSampleBox",this.sample_counts=[],this.sample_deltas=[]}parse(t){this.parseFullHeader(t);const e=t.readUint32();if(this.sample_counts.length=0,this.sample_deltas.length=0,this.version===0)for(let i=0;i<e;i++){this.sample_counts.push(t.readUint32());let s=t.readInt32();s<0&&(l.warn("BoxParser","File uses negative stts sample delta, using value 1 instead, sync may be lost!"),s=1),this.sample_deltas.push(s)}}write(t){this.version=0,this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(t),t.writeUint32(this.sample_counts.length);for(let e=0;e<this.sample_counts.length;e++)t.writeUint32(this.sample_counts[e]),t.writeUint32(this.sample_deltas[e])}unpack(t){let e=0;for(let i=0;i<this.sample_counts.length;i++)for(let s=0;s<this.sample_counts[i];s++)e===0?t[e].dts=0:t[e].dts=t[e-1].dts+this.sample_deltas[i],e++}},_i.fourcc="stts",_i),mi,La=(mi=class extends d{constructor(){super(...arguments),this.box_name="TrackFragmentBaseMediaDecodeTimeBox"}parse(t){this.parseFullHeader(t),this.version===1?this.baseMediaDecodeTime=t.readUint64():this.baseMediaDecodeTime=t.readUint32()}write(t){const e=this.baseMediaDecodeTime>w||this.version===1;this.version=e?1:0,this.size=4,this.size+=e?4:0,this.flags=0,this.writeHeader(t),e?t.writeUint64(this.baseMediaDecodeTime):t.writeUint32(this.baseMediaDecodeTime)}},mi.fourcc="tfdt",mi),gi,Ha=(gi=class extends d{constructor(){super(...arguments),this.box_name="TrackFragmentHeaderBox"}parse(t){this.parseFullHeader(t);let e=0;this.track_id=t.readUint32(),this.size-this.hdr_size>e&&this.flags&bn?(this.base_data_offset=t.readUint64(),e+=8):this.base_data_offset=0,this.size-this.hdr_size>e&&this.flags&vn?(this.default_sample_description_index=t.readUint32(),e+=4):this.default_sample_description_index=0,this.size-this.hdr_size>e&&this.flags&Un?(this.default_sample_duration=t.readUint32(),e+=4):this.default_sample_duration=0,this.size-this.hdr_size>e&&this.flags&Sn?(this.default_sample_size=t.readUint32(),e+=4):this.default_sample_size=0,this.size-this.hdr_size>e&&this.flags&Bn?(this.default_sample_flags=t.readUint32(),e+=4):this.default_sample_flags=0}write(t){this.version=0,this.size=4,this.flags&bn&&(this.size+=8),this.flags&vn&&(this.size+=4),this.flags&Un&&(this.size+=4),this.flags&Sn&&(this.size+=4),this.flags&Bn&&(this.size+=4),this.writeHeader(t),t.writeUint32(this.track_id),this.flags&bn&&t.writeUint64(this.base_data_offset),this.flags&vn&&t.writeUint32(this.default_sample_description_index),this.flags&Un&&t.writeUint32(this.default_sample_duration),this.flags&Sn&&t.writeUint32(this.default_sample_size),this.flags&Bn&&t.writeUint32(this.default_sample_flags)}},gi.fourcc="tfhd",gi),xi,Oa=(xi=class extends d{constructor(){super(...arguments),this.box_name="TrackHeaderBox",this.layer=0,this.alternate_group=0}parse(t){this.parseFullHeader(t),this.version===1?(this.creation_time=t.readUint64(),this.modification_time=t.readUint64(),this.track_id=t.readUint32(),t.readUint32(),this.duration=t.readUint64()):(this.creation_time=t.readUint32(),this.modification_time=t.readUint32(),this.track_id=t.readUint32(),t.readUint32(),this.duration=t.readUint32()),t.readUint32Array(2),this.layer=t.readInt16(),this.alternate_group=t.readInt16(),this.volume=t.readInt16()>>8,t.readUint16(),this.matrix=t.readInt32Array(9),this.width=t.readUint32(),this.height=t.readUint32()}write(t){const e=this.modification_time>w||this.creation_time>w||this.duration>w||this.version===1;this.version=e?1:0,this.size=80,this.size+=e?12:0,this.flags=this.flags??3,this.writeHeader(t),e?(t.writeUint64(this.creation_time),t.writeUint64(this.modification_time),t.writeUint32(this.track_id),t.writeUint32(0),t.writeUint64(this.duration)):(t.writeUint32(this.creation_time),t.writeUint32(this.modification_time),t.writeUint32(this.track_id),t.writeUint32(0),t.writeUint32(this.duration)),t.writeUint32Array([0,0]),t.writeInt16(this.layer),t.writeInt16(this.alternate_group),t.writeInt16(this.volume<<8),t.writeInt16(0),t.writeInt32Array(this.matrix),t.writeUint32(this.width),t.writeUint32(this.height)}print(t){super.printHeader(t),t.log(t.indent+"creation_time: "+this.creation_time),t.log(t.indent+"modification_time: "+this.modification_time),t.log(t.indent+"track_id: "+this.track_id),t.log(t.indent+"duration: "+this.duration),t.log(t.indent+"volume: "+(this.volume>>8)),t.log(t.indent+"matrix: "+this.matrix.join(", ")),t.log(t.indent+"layer: "+this.layer),t.log(t.indent+"alternate_group: "+this.alternate_group),t.log(t.indent+"width: "+this.width),t.log(t.indent+"height: "+this.height)}},xi.fourcc="tkhd",xi),yi,jn=(yi=class extends d{constructor(){super(...arguments),this.box_name="TrackExtendsBox"}parse(t){this.parseFullHeader(t),this.track_id=t.readUint32(),this.default_sample_description_index=t.readUint32(),this.default_sample_duration=t.readUint32(),this.default_sample_size=t.readUint32(),this.default_sample_flags=t.readUint32()}write(t){this.version=0,this.flags=0,this.size=20,this.writeHeader(t),t.writeUint32(this.track_id),t.writeUint32(this.default_sample_description_index),t.writeUint32(this.default_sample_duration),t.writeUint32(this.default_sample_size),t.writeUint32(this.default_sample_flags)}},yi.fourcc="trex",yi),bi,Ma=(bi=class extends d{constructor(){super(...arguments),this.box_name="TrackRunBox",this.sample_duration=[],this.sample_size=[],this.sample_flags=[],this.sample_composition_time_offset=[]}parse(t){this.parseFullHeader(t);let e=0;if(this.sample_count=t.readUint32(),e+=4,this.size-this.hdr_size>e&&this.flags&ln?(this.data_offset=t.readInt32(),e+=4):this.data_offset=0,this.size-this.hdr_size>e&&this.flags&wn?(this.first_sample_flags=t.readUint32(),e+=4):this.first_sample_flags=0,this.sample_duration=[],this.sample_size=[],this.sample_flags=[],this.sample_composition_time_offset=[],this.size-this.hdr_size>e)for(let i=0;i<this.sample_count;i++)this.flags&dn&&(this.sample_duration[i]=t.readUint32()),this.flags&fn&&(this.sample_size[i]=t.readUint32()),this.flags&un&&(this.sample_flags[i]=t.readUint32()),this.flags&pn&&(this.version===0?this.sample_composition_time_offset[i]=t.readUint32():this.sample_composition_time_offset[i]=t.readInt32())}write(t){this.size=4,this.flags&ln&&(this.size+=4),this.flags&wn&&(this.size+=4),this.flags&dn&&(this.size+=4*this.sample_duration.length),this.flags&fn&&(this.size+=4*this.sample_size.length),this.flags&un&&(this.size+=4*this.sample_flags.length),this.flags&pn&&(this.size+=4*this.sample_composition_time_offset.length),this.writeHeader(t),t.writeUint32(this.sample_count),this.flags&ln&&(this.data_offset_position=t.getPosition(),t.writeInt32(this.data_offset)),this.flags&wn&&t.writeUint32(this.first_sample_flags);for(let e=0;e<this.sample_count;e++)this.flags&dn&&t.writeUint32(this.sample_duration[e]),this.flags&fn&&t.writeUint32(this.sample_size[e]),this.flags&un&&t.writeUint32(this.sample_flags[e]),this.flags&pn&&(this.version===0?t.writeUint32(this.sample_composition_time_offset[e]):t.writeInt32(this.sample_composition_time_offset[e]))}},bi.fourcc="trun",bi),vi,Ra=(vi=class extends d{constructor(){super(...arguments),this.box_name="DataEntryUrlBox"}parse(t){this.parseFullHeader(t),this.flags!==1&&(this.location=t.readCString())}write(t){this.version=0,this.location?(this.flags=0,this.size=this.location.length+1):(this.flags=1,this.size=0),this.writeHeader(t),this.location&&t.writeCString(this.location)}},vi.fourcc="url ",vi),Ui,Na=(Ui=class extends d{constructor(){super(...arguments),this.box_name="VideoMediaHeaderBox"}parse(t){this.parseFullHeader(t),this.graphicsmode=t.readUint16(),this.opcolor=t.readUint16Array(3)}write(t){this.version=0,this.size=8,this.writeHeader(t),t.writeUint16(this.graphicsmode),t.writeUint16Array(this.opcolor)}},Ui.fourcc="vmhd",Ui),Mn=class{constructor(r,t,e){this.grouping_type=r,this.grouping_type_parameter=t,this.sbgp=e,this.last_sample_in_run=-1,this.entry_index=-1}},tc=class ${constructor(t,e=!0){this.boxes=[],this.mdats=[],this.moofs=[],this.isProgressive=!1,this.moovStartFound=!1,this.moovStartSent=!1,this.readySent=!1,this.sampleListBuilt=!1,this.fragmentedTracks=[],this.extractedTracks=[],this.isFragmentationInitialized=!1,this.sampleProcessingStarted=!1,this.nextMoofNumber=0,this.itemListBuilt=!1,this.sidxSent=!1,this.items=[],this.entity_groups=[],this.itemsDataSize=0,this.lastMoofIndex=0,this.samplesDataSize=0,this.lastBoxStartPosition=0,this.nextParsePosition=0,this.discardMdatData=!0,this.discardMdatData=e,t?(this.stream=t,this.parse()):this.stream=new _n,this.stream.isofile=this}setSegmentOptions(t,e,i){const{sizePerSegment:s=Number.MAX_SAFE_INTEGER,rapAlignement:n=!0}=i;let a=i.nbSamples??i.nbSamplesPerFragment??1e3;const o=i.nbSamplesPerFragment??a;if(a<=0||o<=0||s<=0){l.error("ISOFile",`Invalid segment options: nbSamples=${a}, nbSamplesPerFragment=${o}, sizePerSegment=${s}`);return}if(a<o&&(l.warn("ISOFile",`nbSamples (${a}) is less than nbSamplesPerFragment (${o}), setting nbSamples to nbSamplesPerFragment`),a=o),this.fragmentedTracks.some(c=>c.nb_samples!==a)){l.error("ISOFile",`Cannot set segment options for track ${t}: nbSamples (${a}) does not match existing tracks`);return}const h=this.getTrackById(t);if(h){const c={id:t,user:e,trak:h,segmentStream:void 0,nb_samples:a,nb_samples_per_fragment:o,size_per_segment:s,rapAlignement:n,state:{lastFragmentSampleNumber:0,lastSegmentSampleNumber:0,accumulatedSize:0}};this.fragmentedTracks.push(c),h.nextSample=0}this.discardMdatData&&l.warn("ISOFile","Segmentation options set but discardMdatData is true, samples will not be segmented")}unsetSegmentOptions(t){let e=-1;for(let i=0;i<this.fragmentedTracks.length;i++)this.fragmentedTracks[i].id===t&&(e=i);e>-1&&this.fragmentedTracks.splice(e,1)}setExtractionOptions(t,e,{nbSamples:i=1e3}={}){const s=this.getTrackById(t);s&&(this.extractedTracks.push({id:t,user:e,trak:s,nb_samples:i,samples:[]}),s.nextSample=0),this.discardMdatData&&l.warn("ISOFile","Extraction options set but discardMdatData is true, samples will not be extracted")}unsetExtractionOptions(t){let e=-1;for(let i=0;i<this.extractedTracks.length;i++)this.extractedTracks[i].id===t&&(e=i);e>-1&&this.extractedTracks.splice(e,1)}parse(){if(!(this.restoreParsePosition&&!this.restoreParsePosition()))for(;;)if(this.hasIncompleteMdat&&this.hasIncompleteMdat()){if(this.processIncompleteMdat())continue;return}else{this.saveParsePosition&&this.saveParsePosition();const e=H(this.stream,!1);if(e.code===j)if(this.processIncompleteBox){if(this.processIncompleteBox(e))continue;return}else return;else if(e.code===F){const i=e.box;if(this.boxes.push(i),i.type==="uuid")this[i.uuid]!==void 0&&l.warn("ISOFile","Duplicate Box of uuid: "+i.uuid+", overriding previous occurrence"),this[i.uuid]=i;else switch(i.type){case"mdat":this.mdats.push(i),this.transferMdatData(i);break;case"moof":this.moofs.push(i);break;case"free":case"skip":break;case"moov":this.moovStartFound=!0,this.mdats.length===0&&(this.isProgressive=!0);default:this[i.type]!==void 0?Array.isArray(this[i.type+"s"])?(l.info("ISOFile",`Found multiple boxes of type ${i.type} in ISOFile, adding to array`),this[i.type+"s"].push(i)):(l.warn("ISOFile",`Found multiple boxes of type ${i.type} but no array exists. Creating array dynamically.`),this[i.type+"s"]=[this[i.type],i]):(this[i.type]=i,Array.isArray(this[i.type+"s"])&&this[i.type+"s"].push(i));break}this.updateUsedBytes&&this.updateUsedBytes(i,e)}else if(e.code===na){l.error("ISOFile",`Invalid data found while parsing box of type '${e.type}' at position ${e.start}. Aborting parsing.`,this);break}}}checkBuffer(t){if(!t)throw new Error("Buffer must be defined and non empty");return t.byteLength===0?(l.warn("ISOFile","Ignoring empty buffer (fileStart: "+t.fileStart+")"),this.stream.logBufferLevel(),!1):(l.info("ISOFile","Processing buffer (fileStart: "+t.fileStart+")"),t.usedBytes=0,this.stream.insertBuffer(t),this.stream.logBufferLevel(),this.stream.initialized()?!0:(l.warn("ISOFile","Not ready to start parsing"),!1))}appendBuffer(t,e){let i;if(this.checkBuffer(t))return this.parse(),this.moovStartFound&&!this.moovStartSent&&(this.moovStartSent=!0,this.onMoovStart&&this.onMoovStart()),this.moov?(this.sampleListBuilt||(this.buildSampleLists(),this.sampleListBuilt=!0),this.updateSampleLists(),this.onReady&&!this.readySent&&(this.readySent=!0,this.onReady(this.getInfo())),this.processSamples(e),this.nextSeekPosition?(i=this.nextSeekPosition,this.nextSeekPosition=void 0):i=this.nextParsePosition,this.stream.getEndFilePositionAfter&&(i=this.stream.getEndFilePositionAfter(i))):this.nextParsePosition?i=this.nextParsePosition:i=0,this.sidx&&this.onSidx&&!this.sidxSent&&(this.onSidx(this.sidx),this.sidxSent=!0),this.meta&&(this.flattenItemInfo&&!this.itemListBuilt&&(this.flattenItemInfo(),this.itemListBuilt=!0),this.processItems&&this.processItems(this.onItem)),this.stream.cleanBuffers&&(l.info("ISOFile","Done processing buffer (fileStart: "+t.fileStart+") - next buffer to fetch should have a fileStart position of "+i),this.stream.logBufferLevel(),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0),l.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize())),i}getFragmentDuration(){const t=this.getBox("mvex");if(!t)return;if(t.mehd)return{num:t.mehd.fragment_duration,den:this.moov.mvhd.timescale};const e=this.getBoxes("trak",!1);let i={num:0,den:1};for(const s of e){const n=s.samples_duration,a=s.mdia.mdhd.timescale;n&&a&&n/a>i.num/i.den&&(i={num:n,den:a})}return i}getInfo(){if(!this.moov)return{hasMoov:!1,mime:""};const t=new Date("1904-01-01T00:00:00Z").getTime(),e=this.getBox("mvex")!==void 0,i={hasMoov:!0,duration:this.moov.mvhd.duration,timescale:this.moov.mvhd.timescale,isFragmented:e,fragment_duration:this.getFragmentDuration(),isProgressive:this.isProgressive,hasIOD:this.moov.iods!==void 0,brands:[this.ftyp.major_brand].concat(this.ftyp.compatible_brands),created:new Date(t+this.moov.mvhd.creation_time*1e3),modified:new Date(t+this.moov.mvhd.modification_time*1e3),tracks:[],audioTracks:[],videoTracks:[],subtitleTracks:[],metadataTracks:[],hintTracks:[],otherTracks:[],mime:""};for(let s=0;s<this.moov.traks.length;s++){const n=this.moov.traks[s],a=n.mdia.minf.stbl.stsd.entries[0],o=n.samples_size,h=n.mdia.mdhd.timescale,c=n.samples_duration,f=o*8*h/c,u={samples_duration:c,bitrate:f,size:o,timescale:h,alternate_group:n.tkhd.alternate_group,codec:a.getCodec(),created:new Date(t+n.tkhd.creation_time*1e3),cts_shift:n.mdia.minf.stbl.cslg,duration:n.mdia.mdhd.duration,id:n.tkhd.track_id,kind:n.udta&&n.udta.kinds.length?n.udta.kinds[0]:{schemeURI:"",value:""},language:n.mdia.elng?n.mdia.elng.extended_language:n.mdia.mdhd.languageString,layer:n.tkhd.layer,matrix:n.tkhd.matrix,modified:new Date(t+n.tkhd.modification_time*1e3),movie_duration:n.tkhd.duration,movie_timescale:i.timescale,name:n.mdia.hdlr.name,nb_samples:n.samples.length,references:[],track_height:n.tkhd.height/65536,track_width:n.tkhd.width/65536,volume:n.tkhd.volume};if(i.tracks.push(u),n.tref)for(let _=0;_<n.tref.references.length;_++)u.references.push({type:n.tref.references[_].type,track_ids:n.tref.references[_].track_ids});n.edts&&(u.edits=n.edts.elst.entries),a instanceof D?(u.type="audio",i.audioTracks.push(u),u.audio={sample_rate:a.getSampleRate(),channel_count:a.getChannelCount(),sample_size:a.getSampleSize()}):a instanceof U?(u.type="video",i.videoTracks.push(u),u.video={width:a.getWidth(),height:a.getHeight()}):a instanceof X?(u.type="subtitles",i.subtitleTracks.push(u)):a instanceof ia?(u.type="metadata",i.hintTracks.push(u)):a instanceof an?(u.type="metadata",i.metadataTracks.push(u)):(u.type="metadata",i.otherTracks.push(u))}i.videoTracks&&i.videoTracks.length>0?i.mime+='video/mp4; codecs="':i.audioTracks&&i.audioTracks.length>0?i.mime+='audio/mp4; codecs="':i.mime+='application/mp4; codecs="';for(let s=0;s<i.tracks.length;s++)s!==0&&(i.mime+=","),i.mime+=i.tracks[s].codec;return i.mime+='"; profiles="',i.mime+=this.ftyp.compatible_brands.join(),i.mime+='"',i}setNextSeekPositionFromSample(t){t&&(this.nextSeekPosition?this.nextSeekPosition=Math.min(t.offset+t.alreadyRead,this.nextSeekPosition):this.nextSeekPosition=t.offset+t.alreadyRead)}processSamples(t){if(this.sampleProcessingStarted){if(this.isFragmentationInitialized&&this.onSegment!==void 0){const e=new Set;for(;e.size<this.fragmentedTracks.length&&this.fragmentedTracks.some(i=>i.trak.nextSample<i.trak.samples.length)&&this.sampleProcessingStarted;)for(const i of this.fragmentedTracks){const s=i.trak;if(!e.has(i.id)){const n=s.nextSample<s.samples.length?this.getSample(s,s.nextSample):void 0;if(!n){this.setNextSeekPositionFromSample(s.samples[s.nextSample]),e.add(i.id);continue}i.state.accumulatedSize+=n.size;const a=s.nextSample+1,o=a-i.state.lastFragmentSampleNumber>i.nb_samples_per_fragment,h=a-i.state.lastSegmentSampleNumber>i.nb_samples;let c=o||a%i.nb_samples_per_fragment===0,f=h||a%i.nb_samples===0,u=i.state.accumulatedSize>=i.size_per_segment;const _=!i.rapAlignement||n.is_sync,m=t||s.nextSample+1>=s.samples.length;if(m&&!_&&l.warn("ISOFile","Flushing track #"+i.id+" at sample #"+s.nextSample+" which is not a RAP, this may lead to playback issues"),c=c&&_,f=f&&_,u=u&&_,c||u||m){o?l.warn("ISOFile","Fragment on track #"+i.id+" is overdue, creating it with samples ["+i.state.lastFragmentSampleNumber+", "+s.nextSample+"]"):l.debug("ISOFile","Creating media fragment on track #"+i.id+" for samples ["+i.state.lastFragmentSampleNumber+", "+s.nextSample+"]");const v=this.createFragment(i.id,i.state.lastFragmentSampleNumber,s.nextSample,i.segmentStream);if(v)i.segmentStream=v,i.state.lastFragmentSampleNumber=s.nextSample+1;else{e.add(i.id);continue}}(f||u||m)&&(h?l.warn("ISOFile","Segment on track #"+i.id+" is overdue, sending it with samples ["+Math.max(0,s.nextSample-i.nb_samples)+", "+(s.nextSample-1)+"]"):l.info("ISOFile","Sending fragmented data on track #"+i.id+" for samples ["+Math.max(0,s.nextSample-i.nb_samples)+", "+(s.nextSample-1)+"]"),l.info("ISOFile","Sample data size in memory: "+this.getAllocatedSampleDataSize()),this.onSegment&&this.onSegment(i.id,i.user,i.segmentStream.buffer,s.nextSample+1,t||s.nextSample+1>=s.samples.length),i.segmentStream=void 0,i.state.accumulatedSize=0,i.state.lastSegmentSampleNumber=s.nextSample+1),s.nextSample++}}}if(this.onSamples!==void 0)for(let e=0;e<this.extractedTracks.length;e++){const i=this.extractedTracks[e],s=i.trak;for(;s.nextSample<s.samples.length&&this.sampleProcessingStarted;){l.debug("ISOFile","Exporting on track #"+i.id+" sample #"+s.nextSample);const n=this.getSample(s,s.nextSample);if(n)s.nextSample++,i.samples.push(n);else{this.setNextSeekPositionFromSample(s.samples[s.nextSample]);break}if((s.nextSample%i.nb_samples===0||s.nextSample>=s.samples.length)&&(l.debug("ISOFile","Sending samples on track #"+i.id+" for sample "+s.nextSample),this.onSamples&&this.onSamples(i.id,i.user,i.samples),i.samples=[],i!==this.extractedTracks[e]))break}}}}getBox(t){const e=this.getBoxes(t,!0);return e.length?e[0]:void 0}getBoxes(t,e){const i=[],s=n=>{n instanceof p&&n.type&&n.type===t&&i.push(n);const a=[];n.boxes&&a.push(...n.boxes),n.entries&&a.push(...n.entries),n.item_infos&&a.push(...n.item_infos),n.references&&a.push(...n.references);for(const o of a){if(i.length&&e)return;s(o)}};return s(this),i}getTrackSamplesInfo(t){const e=this.getTrackById(t);if(e)return e.samples}getTrackSample(t,e){const i=this.getTrackById(t);return this.getSample(i,e)}releaseUsedSamples(t,e){let i=0;const s=this.getTrackById(t);s.lastValidSample||(s.lastValidSample=0);for(let n=s.lastValidSample;n<e;n++)i+=this.releaseSample(s,n);l.info("ISOFile","Track #"+t+" released samples up to "+e+" (released size: "+i+", remaining: "+this.samplesDataSize+")"),s.lastValidSample=e}start(){this.sampleProcessingStarted=!0,this.processSamples(!1)}stop(){this.sampleProcessingStarted=!1}flush(){l.info("ISOFile","Flushing remaining samples"),this.updateSampleLists(),this.processSamples(!0),this.stream.cleanBuffers(),this.stream.logBufferLevel(!0)}seekTrack(t,e,i){let s=0,n=0,a;if(i.samples.length===0)return l.info("ISOFile","No sample in track, cannot seek! Using time "+l.getDurationString(0,1)+" and offset: 0"),{offset:0,time:0};for(let h=0;h<i.samples.length;h++){const c=i.samples[h];if(h===0)n=0,a=c.timescale;else if(c.cts>t*c.timescale){n=h-1;break}e&&c.is_sync&&(s=h)}for(e&&(n=s),t=i.samples[n].cts,i.nextSample=n;i.samples[n].alreadyRead===i.samples[n].size&&i.samples[n+1];)n++;const o=i.samples[n].offset+i.samples[n].alreadyRead;return l.info("ISOFile","Seeking to "+(e?"RAP":"")+" sample #"+i.nextSample+" on track "+i.tkhd.track_id+", time "+l.getDurationString(t,a)+" and offset: "+o),{offset:o,time:t/a}}getTrackDuration(t){if(!t.samples)return 1/0;const e=t.samples[t.samples.length-1];return(e.cts+e.duration)/e.timescale}seek(t,e){const i=this.moov;let s={offset:1/0,time:1/0};if(this.moov){for(let n=0;n<i.traks.length;n++){const a=i.traks[n];if(t>this.getTrackDuration(a))continue;const o=this.seekTrack(t,e,a);o.offset<s.offset&&(s.offset=o.offset),o.time<s.time&&(s.time=o.time)}return l.info("ISOFile","Seeking at time "+l.getDurationString(s.time,1)+" needs a buffer with a fileStart position of "+s.offset),s.offset===1/0?s={offset:this.nextParsePosition,time:0}:s.offset=this.stream.getEndFilePositionAfter(s.offset),l.info("ISOFile","Adjusted seek position (after checking data already in buffer): "+s.offset),s}else throw new Error("Cannot seek: moov not received!")}equal(t){let e=0;for(;e<this.boxes.length&&e<t.boxes.length;){const i=this.boxes[e],s=t.boxes[e];if(!oa(i,s))return!1;e++}return!0}write(t){for(let e=0;e<this.boxes.length;e++)this.boxes[e].write(t)}createFragment(t,e,i,s){const n=[];for(let f=e;f<=i;f++){const u=this.getTrackById(t),_=this.getSample(u,f);if(!_){this.setNextSeekPositionFromSample(u.samples[f]);return}n.push(_)}const a=s||new z,o=this.createMoof(n);o.write(a),o.trafs[0].truns[0].data_offset=o.size+8,l.debug("MP4Box","Adjusting data_offset with new value "+o.trafs[0].truns[0].data_offset),a.adjustUint32(o.trafs[0].truns[0].data_offset_position,o.trafs[0].truns[0].data_offset);const h=new En;h.stream=new _n;let c=0;for(const f of n)if(f.data){const u=N.fromArrayBuffer(f.data.buffer,c);h.stream.insertBuffer(u),c+=f.data.byteLength}return h.write(a),a}static writeInitializationSegment(t,e,i){l.debug("ISOFile","Generating initialization segment");const s=new z;t.write(s);const n=e.addBox(new Vn);if(i){const a=n.addBox(new Sa);a.fragment_duration=i}for(let a=0;a<e.traks.length;a++){const o=n.addBox(new jn);o.track_id=e.traks[a].tkhd.track_id,o.default_sample_description_index=1,o.default_sample_duration=e.traks[a].samples[0]?.duration??0,o.default_sample_size=0,o.default_sample_flags=65536}return e.write(s),s.buffer}save(t){const e=new z;return e.isofile=this,this.write(e),e.save(t)}getBuffer(){const t=new z;return t.isofile=this,this.write(t),t}initializeSegmentation(){this.onSegment||l.warn("MP4Box","No segmentation callback set!"),this.isFragmentationInitialized||(this.isFragmentationInitialized=!0,this.resetTables());const t=new Gn;t.addBox(this.moov.mvhd);for(let e=0;e<this.fragmentedTracks.length;e++){const i=this.getTrackById(this.fragmentedTracks[e].id);if(!i){l.warn("ISOFile",`Track with id ${this.fragmentedTracks[e].id} not found, skipping fragmentation initialization`);continue}t.addBox(i)}return{tracks:t.traks.map((e,i)=>({id:e.tkhd.track_id,user:this.fragmentedTracks[i].user})),buffer:$.writeInitializationSegment(this.ftyp,t,this.moov?.mvex?.mehd.fragment_duration)}}resetTables(){this.initial_duration=this.moov.mvhd.duration,this.moov.mvhd.duration=0;for(let t=0;t<this.moov.traks.length;t++){const e=this.moov.traks[t];e.tkhd.duration=0,e.mdia.mdhd.duration=0;const i=e.mdia.minf.stbl.stco||e.mdia.minf.stbl.co64;i.chunk_offsets=[];const s=e.mdia.minf.stbl.stsc;s.first_chunk=[],s.samples_per_chunk=[],s.sample_description_index=[];const n=e.mdia.minf.stbl.stsz||e.mdia.minf.stbl.stz2;n.sample_sizes=[];const a=e.mdia.minf.stbl.stts;a.sample_counts=[],a.sample_deltas=[];const o=e.mdia.minf.stbl.ctts;o&&(o.sample_counts=[],o.sample_offsets=[]);const h=e.mdia.minf.stbl.stss,c=e.mdia.minf.stbl.boxes.indexOf(h);c!==-1&&(e.mdia.minf.stbl.boxes[c]=void 0)}}static initSampleGroups(t,e,i,s,n){e&&(e.sample_groups_info=[]),t.sample_groups_info||(t.sample_groups_info=[]);for(let a=0;a<i.length;a++){const o=i[a].grouping_type+"/"+i[a].grouping_type_parameter,h=new Mn(i[a].grouping_type,i[a].grouping_type_parameter,i[a]);e&&(e.sample_groups_info[o]=h),t.sample_groups_info[o]||(t.sample_groups_info[o]=h);for(let c=0;c<s.length;c++)s[c].grouping_type===i[a].grouping_type&&(h.description=s[c],h.description.used=!0);if(n)for(let c=0;c<n.length;c++)n[c].grouping_type===i[a].grouping_type&&(h.fragment_description=n[c],h.fragment_description.used=!0,h.is_fragment=!0)}if(e){if(n){for(let a=0;a<n.length;a++)if(!n[a].used&&n[a].version>=2){const o=n[a].grouping_type+"/0",h=new Mn(n[a].grouping_type,0);h.is_fragment=!0,e.sample_groups_info[o]||(e.sample_groups_info[o]=h)}}}else for(let a=0;a<s.length;a++)if(!s[a].used&&s[a].version>=2){const o=s[a].grouping_type+"/0",h=new Mn(s[a].grouping_type,0);t.sample_groups_info[o]||(t.sample_groups_info[o]=h)}}static setSampleGroupProperties(t,e,i,s){e.sample_groups=[];for(const n in s)if(e.sample_groups[n]={grouping_type:s[n].grouping_type,grouping_type_parameter:s[n].grouping_type_parameter},i>=s[n].last_sample_in_run&&(s[n].last_sample_in_run<0&&(s[n].last_sample_in_run=0),s[n].entry_index++,s[n].entry_index<=s[n].sbgp.entries.length-1&&(s[n].last_sample_in_run+=s[n].sbgp.entries[s[n].entry_index].sample_count)),s[n].entry_index<=s[n].sbgp.entries.length-1?e.sample_groups[n].group_description_index=s[n].sbgp.entries[s[n].entry_index].group_description_index:e.sample_groups[n].group_description_index=-1,e.sample_groups[n].group_description_index!==0){let a;if(s[n].fragment_description?a=s[n].fragment_description:a=s[n].description,e.sample_groups[n].group_description_index>0){let o;e.sample_groups[n].group_description_index>65535?o=(e.sample_groups[n].group_description_index>>16)-1:o=e.sample_groups[n].group_description_index-1,a&&o>=0&&(e.sample_groups[n].description=a.entries[o])}else a&&a.version>=2&&a.default_group_description_index>0&&(e.sample_groups[n].description=a.entries[a.default_group_description_index-1])}}static process_sdtp(t,e,i){e&&(t?(e.is_leading=t.is_leading[i],e.depends_on=t.sample_depends_on[i],e.is_depended_on=t.sample_is_depended_on[i],e.has_redundancy=t.sample_has_redundancy[i]):(e.is_leading=0,e.depends_on=0,e.is_depended_on=0,e.has_redundancy=0))}buildSampleLists(){for(let t=0;t<this.moov.traks.length;t++)this.buildTrakSampleLists(this.moov.traks[t])}buildTrakSampleLists(t){let e,i,s,n,a,o;t.samples=[],t.samples_duration=0,t.samples_size=0;const h=t.mdia.minf.stbl.stco||t.mdia.minf.stbl.co64,c=t.mdia.minf.stbl.stsc,f=t.mdia.minf.stbl.stsz||t.mdia.minf.stbl.stz2,u=t.mdia.minf.stbl.stts,_=t.mdia.minf.stbl.ctts,m=t.mdia.minf.stbl.stss,v=t.mdia.minf.stbl.stsd,b=t.mdia.minf.stbl.subs,T=t.mdia.minf.stbl.stdp,k=t.mdia.minf.stbl.sbgps,P=t.mdia.minf.stbl.sgpds;let A=-1,V=-1,L=-1,S=-1,M=0,I=0,O=0;if($.initSampleGroups(t,void 0,k,P),!(typeof f>"u")){for(e=0;e<f.sample_sizes.length;e++){const x={number:e,track_id:t.tkhd.track_id,timescale:t.mdia.mdhd.timescale,alreadyRead:0,size:f.sample_sizes[e]};t.samples[e]=x,t.samples_size+=x.size,e===0?(s=1,i=0,x.chunk_index=s,x.chunk_run_index=i,o=c.samples_per_chunk[i],a=0,i+1<c.first_chunk.length?n=c.first_chunk[i+1]-1:n=1/0):e<o?(x.chunk_index=s,x.chunk_run_index=i):(s++,x.chunk_index=s,a=0,s<=n||(i++,i+1<c.first_chunk.length?n=c.first_chunk[i+1]-1:n=1/0),x.chunk_run_index=i,o+=c.samples_per_chunk[i]),x.description_index=c.sample_description_index[x.chunk_run_index]-1,x.description=v.entries[x.description_index],x.offset=h.chunk_offsets[x.chunk_index-1]+a,a+=x.size,e>A&&(V++,A<0&&(A=0),A+=u.sample_counts[V]),e>0?(t.samples[e-1].duration=u.sample_deltas[V],t.samples_duration+=t.samples[e-1].duration,x.dts=t.samples[e-1].dts+t.samples[e-1].duration):x.dts=0,_?(e>=L&&(S++,L<0&&(L=0),L+=_.sample_counts[S]),x.cts=t.samples[e].dts+_.sample_offsets[S]):x.cts=x.dts,m?(e===m.sample_numbers[M]-1?(x.is_sync=!0,M++):(x.is_sync=!1,x.degradation_priority=0),b&&b.entries[I].sample_delta+O===e+1&&(x.subsamples=b.entries[I].subsamples,O+=b.entries[I].sample_delta,I++)):x.is_sync=!0,$.process_sdtp(t.mdia.minf.stbl.sdtp,x,x.number),T?x.degradation_priority=T.priority[e]:x.degradation_priority=0,b&&b.entries[I].sample_delta+O===e&&(x.subsamples=b.entries[I].subsamples,O+=b.entries[I].sample_delta),(k.length>0||P.length>0)&&$.setSampleGroupProperties(t,x,e,t.sample_groups_info)}e>0&&(t.samples[e-1].duration=Math.max(t.mdia.mdhd.duration-t.samples[e-1].dts,0),t.samples_duration+=t.samples[e-1].duration)}}updateSampleLists(){let t,e,i,s,n;if(this.moov!==void 0)for(;this.lastMoofIndex<this.moofs.length;){const a=this.moofs[this.lastMoofIndex];if(this.lastMoofIndex++,a.type==="moof"){const o=a;for(let h=0;h<o.trafs.length;h++){const c=o.trafs[h],f=this.getTrackById(c.tfhd.track_id),u=this.getTrexById(c.tfhd.track_id);c.tfhd.flags&vn?t=c.tfhd.default_sample_description_index:t=u?u.default_sample_description_index:1,c.tfhd.flags&Un?e=c.tfhd.default_sample_duration:e=u?u.default_sample_duration:0,c.tfhd.flags&Sn?i=c.tfhd.default_sample_size:i=u?u.default_sample_size:0,c.tfhd.flags&Bn?s=c.tfhd.default_sample_flags:s=u?u.default_sample_flags:0,c.sample_number=0,c.sbgps.length>0&&$.initSampleGroups(f,c,c.sbgps,f.mdia.minf.stbl.sgpds,c.sgpds);for(let _=0;_<c.truns.length;_++){const m=c.truns[_];for(let v=0;v<m.sample_count;v++){const b=t-1;let T=s;m.flags&un?T=m.sample_flags[v]:v===0&&m.flags&wn&&(T=m.first_sample_flags);let k=i;m.flags&fn&&(k=m.sample_size[v]),f.samples_size+=k;let P=e;m.flags&dn&&(P=m.sample_duration[v]),f.samples_duration+=P;let A;f.first_traf_merged||v>0?A=f.samples[f.samples.length-1].dts+f.samples[f.samples.length-1].duration:(c.tfdt?A=c.tfdt.baseMediaDecodeTime:A=0,f.first_traf_merged=!0);let V=A;m.flags&pn&&(V=A+m.sample_composition_time_offset[v]);const L=!!(c.tfhd.flags&bn),S=!!(c.tfhd.flags&Qn),M=!!(m.flags&ln);let I=0;L?I=c.tfhd.base_data_offset:S||_===0?I=o.start:I=n;let O;_===0&&v===0?M?O=I+m.data_offset:O=I:O=n,n=O+k;const x=c.sample_number;c.sample_number++;const Fn={cts:V,description_index:b,description:f.mdia.minf.stbl.stsd.entries[b],dts:A,duration:P,moof_number:this.lastMoofIndex,number_in_traf:x,number:f.samples.length,offset:O,size:k,timescale:f.mdia.mdhd.timescale,track_id:f.tkhd.track_id,is_sync:!(T>>16&1),is_leading:T>>26&3,depends_on:T>>24&3,is_depended_on:T>>22&3,has_redundancy:T>>20&3,degradation_priority:T&65535};c.first_sample_index=f.samples.length,f.samples.push(Fn),(c.sbgps.length>0||c.sgpds.length>0||f.mdia.minf.stbl.sbgps.length>0||f.mdia.minf.stbl.sgpds.length>0)&&$.setSampleGroupProperties(f,Fn,Fn.number_in_traf,c.sample_groups_info)}}if(c.subs){f.has_fragment_subsamples=!0;let _=c.first_sample_index;for(let m=0;m<c.subs.entries.length;m++){_+=c.subs.entries[m].sample_delta;const v=f.samples[_-1];v.subsamples=c.subs.entries[m].subsamples}}}}}}getSample(t,e){const i=t.samples[e];if(this.moov){if(!i.data)i.data=new Uint8Array(i.size),i.alreadyRead=0,this.samplesDataSize+=i.size,l.debug("ISOFile","Allocating sample #"+e+" on track #"+t.tkhd.track_id+" of size "+i.size+" (total: "+this.samplesDataSize+")");else if(i.alreadyRead===i.size)return i;for(;;){let s=this.stream,n=s.findPosition(!0,i.offset+i.alreadyRead,!1),a,o;if(n>-1)a=s.buffers[n],o=a.fileStart;else for(const h of this.mdats){if(!h.stream){l.debug("ISOFile","mdat stream not yet fully read for #"+this.mdats.indexOf(h)+" mdat");continue}if(n=h.stream.findPosition(!0,i.offset+i.alreadyRead-h.start-h.hdr_size,!1),n>-1){s=h.stream,a=h.stream.buffers[n],o=h.start+h.hdr_size+a.fileStart;break}}if(a){const h=a.byteLength-(i.offset+i.alreadyRead-o);if(i.size-i.alreadyRead<=h)return l.debug("ISOFile","Getting sample #"+e+" data (alreadyRead: "+i.alreadyRead+" offset: "+(i.offset+i.alreadyRead-o)+" read size: "+(i.size-i.alreadyRead)+" full size: "+i.size+")"),z.memcpy(i.data.buffer,i.alreadyRead,a,i.offset+i.alreadyRead-o,i.size-i.alreadyRead),a.usedBytes+=i.size-i.alreadyRead,s.logBufferLevel(),i.alreadyRead=i.size,i;if(h===0)return;l.debug("ISOFile","Getting sample #"+e+" partial data (alreadyRead: "+i.alreadyRead+" offset: "+(i.offset+i.alreadyRead-o)+" read size: "+h+" full size: "+i.size+")"),z.memcpy(i.data.buffer,i.alreadyRead,a,i.offset+i.alreadyRead-o,h),i.alreadyRead+=h,a.usedBytes+=h,s.logBufferLevel()}else return}}}releaseSample(t,e){const i=t.samples[e];return i.data?(this.samplesDataSize-=i.size,i.data=void 0,i.alreadyRead=0,i.size):0}getAllocatedSampleDataSize(){return this.samplesDataSize}getCodecs(){let t="";for(let e=0;e<this.moov.traks.length;e++){const i=this.moov.traks[e];e>0&&(t+=","),t+=i.mdia.minf.stbl.stsd.entries[0].getCodec()}return t}getTrexById(t){if(!(!this.moov||!this.moov.mvex))for(let e=0;e<this.moov.mvex.trexs.length;e++){const i=this.moov.mvex.trexs[e];if(i.track_id===t)return i}}getTrackById(t){if(this.moov)for(let e=0;e<this.moov.traks.length;e++){const i=this.moov.traks[e];if(i.tkhd.track_id===t)return i}}flattenItemInfo(){const t=this.items,e=this.entity_groups,i=this.meta;if(!(!i||!i.hdlr||!i.iinf)){for(let s=0;s<i.iinf.item_infos.length;s++){const n=i.iinf.item_infos[s].item_ID;t[n]={id:n,name:i.iinf.item_infos[s].item_name,ref_to:[],content_type:i.iinf.item_infos[s].content_type,content_encoding:i.iinf.item_infos[s].content_encoding,item_uri_type:i.iinf.item_infos[s].item_uri_type,type:i.iinf.item_infos[s].item_type?i.iinf.item_infos[s].item_type:"mime",protection:i.iinf.item_infos[s].item_protection_index>0?i.ipro.protections[i.iinf.item_infos[s].item_protection_index-1]:void 0}}if(i.grpl)for(let s=0;s<i.grpl.boxes.length;s++){const n=i.grpl.boxes[s];e[n.group_id]={id:n.group_id,entity_ids:n.entity_ids,type:n.type}}if(i.iloc)for(let s=0;s<i.iloc.items.length;s++){const n=i.iloc.items[s],a=t[n.item_ID];n.data_reference_index!==0&&(l.warn("Item storage with reference to other files: not supported"),a.source=i.dinf.boxes[n.data_reference_index-1]),a.extents=[],a.size=0;for(let o=0;o<n.extents.length;o++)a.extents[o]={offset:n.extents[o].extent_offset+n.base_offset,length:n.extents[o].extent_length,alreadyRead:0},n.construction_method===1&&(a.extents[o].offset+=i.idat.start+i.idat.hdr_size),a.size+=a.extents[o].length}if(i.pitm&&(t[i.pitm.item_id].primary=!0),i.iref)for(let s=0;s<i.iref.references.length;s++){const n=i.iref.references[s];for(let a=0;a<n.references.length;a++)t[n.from_item_ID].ref_to.push({type:n.type,id:n.references[a]})}if(i.iprp)for(let s=0;s<i.iprp.ipmas.length;s++){const n=i.iprp.ipmas[s];for(let a=0;a<n.associations.length;a++){const o=n.associations[a],h=t[o.id]??e[o.id];if(h){h.properties===void 0&&(h.properties={boxes:[]});for(let c=0;c<o.props.length;c++){const f=o.props[c];if(f.property_index>0&&f.property_index-1<i.iprp.ipco.boxes.length){const u=i.iprp.ipco.boxes[f.property_index-1];h.properties[u.type]=u,h.properties.boxes.push(u)}}}}}}}getItem(t){if(!this.meta)return;const e=this.items[t];if(!e.data&&e.size)e.data=new Uint8Array(e.size),e.alreadyRead=0,this.itemsDataSize+=e.size,l.debug("ISOFile","Allocating item #"+t+" of size "+e.size+" (total: "+this.itemsDataSize+")");else if(e.alreadyRead===e.size)return e;for(let i=0;i<e.extents.length;i++){const s=e.extents[i];if(s.alreadyRead!==s.length){const n=this.stream.findPosition(!0,s.offset+s.alreadyRead,!1);if(n>-1){const a=this.stream.buffers[n],o=a.byteLength-(s.offset+s.alreadyRead-a.fileStart);if(s.length-s.alreadyRead<=o)l.debug("ISOFile","Getting item #"+t+" extent #"+i+" data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-a.fileStart)+" read size: "+(s.length-s.alreadyRead)+" full extent size: "+s.length+" full item size: "+e.size+")"),z.memcpy(e.data.buffer,e.alreadyRead,a,s.offset+s.alreadyRead-a.fileStart,s.length-s.alreadyRead),(!this.parsingMdat||this.discardMdatData)&&(a.usedBytes+=s.length-s.alreadyRead),this.stream.logBufferLevel(),e.alreadyRead+=s.length-s.alreadyRead,s.alreadyRead=s.length;else{l.debug("ISOFile","Getting item #"+t+" extent #"+i+" partial data (alreadyRead: "+s.alreadyRead+" offset: "+(s.offset+s.alreadyRead-a.fileStart)+" read size: "+o+" full extent size: "+s.length+" full item size: "+e.size+")"),z.memcpy(e.data.buffer,e.alreadyRead,a,s.offset+s.alreadyRead-a.fileStart,o),s.alreadyRead+=o,e.alreadyRead+=o,(!this.parsingMdat||this.discardMdatData)&&(a.usedBytes+=o),this.stream.logBufferLevel();return}}else return}}if(e.alreadyRead===e.size)return e}releaseItem(t){const e=this.items[t];if(e.data){this.itemsDataSize-=e.size,e.data=void 0,e.alreadyRead=0;for(let i=0;i<e.extents.length;i++){const s=e.extents[i];s.alreadyRead=0}return e.size}else return 0}processItems(t){for(const e in this.items){const i=this.items[e];this.getItem(i.id),t&&!i.sent&&(t(i),i.sent=!0,i.data=void 0)}}hasItem(t){for(const e in this.items){const i=this.items[e];if(i.name===t)return i.id}return-1}getMetaHandler(){if(this.meta)return this.meta.hdlr.handler}getPrimaryItem(){if(this.meta&&this.meta.pitm)return this.getItem(this.meta.pitm.item_id)}itemToFragmentedTrackFile({itemId:t}={}){let e;if(t?e=this.getItem(t):e=this.getPrimaryItem(),!e)return;const i=new $;i.discardMdatData=!1;const s={type:e.type,description_boxes:e.properties.boxes};e.properties.ispe&&(s.width=e.properties.ispe.image_width,s.height=e.properties.ispe.image_height);const n=i.addTrack(s);if(n)return i.addSample(n,e.data),i}processIncompleteBox(t){if(t.type==="mdat"){const e=new En(t.size);return this.parsingMdat=e,this.boxes.push(e),this.mdats.push(e),e.start=t.start,e.hdr_size=t.hdr_size,e.original_size=t.original_size,this.stream.addUsedBytes(e.hdr_size),this.lastBoxStartPosition=e.start+e.size,this.stream.seek(e.start+e.size,!1,this.discardMdatData)?(this.transferMdatData(),this.parsingMdat=void 0,!0):(this.moovStartFound?this.nextParsePosition=this.stream.findEndContiguousBuf():this.nextParsePosition=e.start+e.size,!1)}else return t.type==="moov"&&(this.moovStartFound=!0,this.mdats.length===0&&(this.isProgressive=!0)),(this.stream.mergeNextBuffer?this.stream.mergeNextBuffer():!1)?(this.nextParsePosition=this.stream.getEndPosition(),!0):(t.type?this.moovStartFound?this.nextParsePosition=this.stream.getEndPosition():this.nextParsePosition=this.stream.getPosition()+t.size:this.nextParsePosition=this.stream.getEndPosition(),!1)}hasIncompleteMdat(){return this.parsingMdat!==void 0}transferMdatData(t){const e=t??this.parsingMdat;if(this.discardMdatData){l.debug("ISOFile","Discarding 'mdat' data, not transferring it to the mdat box stream");return}if(!e){l.warn("ISOFile","Cannot transfer 'mdat' data, no mdat box is being parsed");return}const i=this.stream.findPosition(!0,e.start+e.hdr_size,!1),s=this.stream.findPosition(!0,e.start+e.size,!1);if(i===-1||s===-1){console.trace(e,i,s),l.warn("ISOFile","Cannot transfer 'mdat' data, start or end buffer not found");return}e.stream=new _n;for(let n=i;n<=s;n++){const a=this.stream.buffers[n],o=n===i?e.start+e.hdr_size-a.fileStart:0,h=n===s?e.start+e.size-a.fileStart:a.byteLength;if(h>o){l.debug("ISOFile","Transferring 'mdat' data from buffer #"+n+" ("+o+" to "+h+")");const c=h-o,f=new N(c),u=e.stream.getAbsoluteEndPosition();z.memcpy(f,0,a,o,c),f.fileStart=u,e.stream.insertBuffer(f),a.usedBytes+=c}}}processIncompleteMdat(){const t=this.parsingMdat;return this.stream.seek(t.start+t.size,!1,this.discardMdatData)?(l.debug("ISOFile","Found 'mdat' end in buffered data"),this.transferMdatData(),this.parsingMdat=void 0,!0):(this.nextParsePosition=this.stream.findEndContiguousBuf(),!1)}restoreParsePosition(){return this.stream.seek(this.lastBoxStartPosition,!0,this.discardMdatData)}saveParsePosition(){this.lastBoxStartPosition=this.stream.getPosition()}updateUsedBytes(t,e){this.stream.addUsedBytes&&(t.type==="mdat"?(this.stream.addUsedBytes(t.hdr_size),this.discardMdatData&&this.stream.addUsedBytes(t.size-t.hdr_size)):this.stream.addUsedBytes(t.size))}addBox(t){return p.prototype.addBox.call(this,t)}init(t={}){const e=this.addBox(new ya);e.major_brand=t.brands&&t.brands[0]||"iso4",e.minor_version=0,e.compatible_brands=t.brands||["iso4"];const i=this.addBox(new Gn);i.addBox(new Vn);const s=i.addBox(new wa);return s.timescale=t.timescale||600,s.rate=t.rate||65536,s.creation_time=0,s.modification_time=0,s.duration=t.duration||0,s.volume=t.width?0:256,s.matrix=[65536,0,0,0,65536,0,0,0,1073741824],s.next_track_id=1,this}addTrack(t={}){this.moov||this.init(t);const e=t||{};e.width=e.width||320,e.height=e.height||320,e.id=e.id||this.moov.mvhd.next_track_id,e.type=e.type||"avc1";const i=this.moov.addBox(new la);this.moov.mvhd.next_track_id=e.id+1;const s=i.addBox(new Oa);s.flags=Ka|Xa|Qa,s.creation_time=0,s.modification_time=0,s.track_id=e.id,s.duration=e.duration||0,s.layer=e.layer||0,s.alternate_group=0,s.volume=1,s.matrix=[65536,0,0,0,65536,0,0,0,1073741824],s.width=e.width<<16,s.height=e.height<<16;const n=i.addBox(new da),a=n.addBox(new Ua);a.creation_time=0,a.modification_time=0,a.timescale=e.timescale||1,a.duration=e.media_duration||0,a.language=e.language||"und";const o=n.addBox(new ba);o.handler=e.hdlr||"vide",o.name=e.name||"Track created with MP4Box.js";const h=n.addBox(new xa);h.extended_language=e.language||"fr-FR";const c=n.addBox(new fa),f=C.sampleEntry[e.type];if(!f)return;const u=new f;if(u.data_reference_index=1,u instanceof U){const S=u,M=c.addBox(new Na);M.graphicsmode=0,M.opcolor=[0,0,0],S.width=e.width,S.height=e.height,S.horizresolution=72<<16,S.vertresolution=72<<16,S.frame_count=1,S.compressorname=e.type+" Compressor",S.depth=24,e.avcDecoderConfigRecord?S.addBox(new ha(e.avcDecoderConfigRecord.byteLength)).parse(new z(e.avcDecoderConfigRecord)):e.hevcDecoderConfigRecord&&S.addBox(new va(e.hevcDecoderConfigRecord.byteLength)).parse(new z(e.hevcDecoderConfigRecord))}else if(u instanceof D){const S=u,M=c.addBox(new Ia);M.balance=e.balance||0,S.channel_count=e.channel_count||2,S.samplesize=e.samplesize||16,S.samplerate=e.samplerate||65536}else u instanceof ia?c.addBox(new ca):u instanceof X?(c.addBox(new Aa),u instanceof ka&&(u.namespace=e.namespace||"nonamespace",u.schema_location=e.schema_location||"",u.auxiliary_mime_types=e.auxiliary_mime_types||"")):u instanceof an?c.addBox(new kn):u instanceof qn?c.addBox(new kn):c.addBox(new kn);e.description&&u.addBox.call(u,e.description),e.description_boxes&&e.description_boxes.forEach(function(S){u.addBox.call(u,S)});const m=c.addBox(new ua).addBox(new ga),v=new Ra;v.flags=1,m.addEntry(v);const b=c.addBox(new pa);b.addBox(new Ca).addEntry(u);const k=b.addBox(new Da);k.sample_counts=[],k.sample_deltas=[];const P=b.addBox(new Pa);P.first_chunk=[],P.samples_per_chunk=[],P.sample_description_index=[];const A=b.addBox(new Ta);A.chunk_offsets=[];const V=b.addBox(new Fa);V.sample_sizes=[];const L=this.moov.mvex.addBox(new jn);return L.track_id=e.id,L.default_sample_description_index=e.default_sample_description_index||1,L.default_sample_duration=e.default_sample_duration||0,L.default_sample_size=e.default_sample_size||0,L.default_sample_flags=e.default_sample_flags||0,this.buildTrakSampleLists(i),e.id}addSample(t,e,{sample_description_index:i,duration:s=1,cts:n=0,dts:a=0,is_sync:o=!1,is_leading:h=0,depends_on:c=0,is_depended_on:f=0,has_redundancy:u=0,degradation_priority:_=0,subsamples:m,offset:v=0}={}){const b=this.getTrackById(t);if(b===void 0)return;const T=i?i-1:0,k={number:b.samples.length,track_id:b.tkhd.track_id,timescale:b.mdia.mdhd.timescale,description_index:T,description:b.mdia.minf.stbl.stsd.entries[T],data:e,size:e.byteLength,alreadyRead:e.byteLength,duration:s,cts:n,dts:a,is_sync:o,is_leading:h,depends_on:c,is_depended_on:f,has_redundancy:u,degradation_priority:_,offset:v,subsamples:m};b.samples.push(k),b.samples_size+=k.size,b.samples_duration+=k.duration,b.first_dts===void 0&&(b.first_dts=a),this.processSamples();const P=this.addBox(this.createMoof([k]));P.computeSize(),P.trafs[0].truns[0].data_offset=P.size+8;const A=this.addBox(new En);return A.data=new Uint8Array(e),k}createMoof(t){if(t.length===0)return;if(t.some(f=>f.track_id!==t[0].track_id))throw new Error("Cannot create moof for samples from different tracks: "+t.map(f=>f.track_id).join(", "));const e=t[0].track_id,i=this.getTrackById(e);if(!i)throw new Error("Cannot create moof for non-existing track: "+e);const s=new _a,n=s.addBox(new Ba);n.sequence_number=++this.nextMoofNumber;const a=s.addBox(new ma),o=a.addBox(new Ha);o.track_id=e,o.flags=Qn;const h=a.addBox(new La);h.baseMediaDecodeTime=t[0].dts-(i.first_dts||0);const c=a.addBox(new Ma);c.flags=ln|dn|fn|un|pn,c.data_offset=0,c.first_sample_flags=0,c.sample_count=t.length;for(const f of t){let u=0;f.is_sync?u=1<<25:u=65536,c.sample_duration.push(f.duration),c.sample_size.push(f.size),c.sample_flags.push(u),c.sample_composition_time_offset.push(f.cts-f.dts)}return s}print(t){t.indent="";for(let e=0;e<this.boxes.length;e++)this.boxes[e]&&this.boxes[e].print(t)}};function Wd(r=!1,t){return new tc(t,!r)}var Ga={};ra(Ga,{Descriptor:()=>Q,ES_Descriptor:()=>qa,MPEG4DescriptorParser:()=>nc});var Va=3,An=4,Yn=5,ja=6,Q=class $a{constructor(t,e){this.tag=t,this.size=e,this.descs=[]}parse(t){this.data=t.readUint8Array(this.size)}findDescriptor(t){for(let e=0;e<this.descs.length;e++)if(this.descs[e].tag===t)return this.descs[e]}parseOneDescriptor(t){let e=0;const i=t.readUint8();let s=t.readUint8();for(;s&128;)e=(e<<7)+(s&127),s=t.readUint8();e=(e<<7)+(s&127),l.debug("Descriptor","Found "+(In[i]||"Descriptor "+i)+", size "+e+" at position "+t.getPosition());const n=In[i]?new rc[In[i]](e):new $a(e);return n.parse(t),n}parseRemainingDescriptors(t){const e=t.getPosition();for(;t.getPosition()<e+this.size;){const i=this.parseOneDescriptor?.(t);this.descs.push(i)}}},qa=class extends Q{constructor(r){super(Va,r)}parse(r){if(this.ES_ID=r.readUint16(),this.flags=r.readUint8(),this.size-=3,this.flags&128?(this.dependsOn_ES_ID=r.readUint16(),this.size-=2):this.dependsOn_ES_ID=0,this.flags&64){const t=r.readUint8();this.URL=r.readString(t),this.size-=t+1}else this.URL="";this.flags&32?(this.OCR_ES_ID=r.readUint16(),this.size-=2):this.OCR_ES_ID=0,this.parseRemainingDescriptors(r)}getOTI(){const r=this.findDescriptor(An);return r?r.oti:0}getAudioConfig(){const r=this.findDescriptor(An);if(!r)return;const t=r.findDescriptor(Yn);if(t&&t.data){let e=(t.data[0]&248)>>3;return e===31&&t.data.length>=2&&(e=32+((t.data[0]&7)<<3)+((t.data[1]&224)>>5)),e}}},ec=class extends Q{constructor(r){super(An,r)}parse(r){this.oti=r.readUint8(),this.streamType=r.readUint8(),this.upStream=(this.streamType>>1&1)!==0,this.streamType=this.streamType>>>2,this.bufferSize=r.readUint24(),this.maxBitrate=r.readUint32(),this.avgBitrate=r.readUint32(),this.size-=13,this.parseRemainingDescriptors(r)}},ic=class extends Q{constructor(r){super(Yn,r)}},sc=class extends Q{constructor(r){super(ja,r)}},rc={Descriptor:Q,ES_Descriptor:qa,DecoderConfigDescriptor:ec,DecoderSpecificInfo:ic,SLConfigDescriptor:sc},In={[Va]:"ES_Descriptor",[An]:"DecoderConfigDescriptor",[Yn]:"DecoderSpecificInfo",[ja]:"SLConfigDescriptor"},nc=class{constructor(){this.parseOneDescriptor=Q.prototype.parseOneDescriptor}getDescriptorName(r){return In[r]}},Kd=class{parseSample(r){const t=[],e=new _n(N.fromArrayBuffer(r.buffer,0));for(;!e.isEof();){const i=H(e,!1);i.code===F&&i.box?.type==="vttc"&&t.push(i.box)}return t}getText(r,t,e){function i(o,h){const c=o.toString();return c.length>=h?c:new Array(h-c.length+1).join("0")+c}function s(o){const h=Math.floor(o/3600),c=Math.floor((o-h*3600)/60),f=Math.floor(o-h*3600-c*60),u=Math.floor((o-h*3600-c*60-f)*1e3);return""+i(h,2)+":"+i(c,2)+":"+i(f,2)+"."+i(u,3)}const n=this.parseSample(e);let a="";for(let o=0;o<n.length;o++){const h=n[o];a+=s(r)+" --> "+s(t)+`\r
2
- `,a+=h.payl.text}return a}},Xd=class{parseSample(r){const t={resources:[],documentString:"",document:void 0},e=new z(r.data.buffer);if(!r.subsamples||r.subsamples.length===0)t.documentString=e.readString(r.data.length);else if(t.documentString=e.readString(r.subsamples[0].size),r.subsamples.length>1)for(let i=1;i<r.subsamples.length;i++)t.resources[i]=e.readUint8Array(r.subsamples[i].size);return typeof DOMParser<"u"&&(t.document=new DOMParser().parseFromString(t.documentString,"application/xml")),t}},Qd=class{parseSample(r){return new z(r.data.buffer).readString(r.data.length)}parseConfig(r){const t=new z(r.buffer);return t.readUint32(),t.readCString()}},Jd=class{parseSample(r){const t=new z(r.data.buffer),e=t.readUint16();if(e!==0)return t.readString(e)}},Ya={};ra(Ya,{CoLLBox:()=>xc,ItemContentIDPropertyBox:()=>qd,OpusSampleEntry:()=>Ph,SmDmBox:()=>jl,a1lxBox:()=>ac,a1opBox:()=>oc,ac_3SampleEntry:()=>Ih,ac_4SampleEntry:()=>Th,aebrBox:()=>Lc,afbrBox:()=>Hc,albcBox:()=>Oc,alstSampleGroupEntry:()=>vd,altrBox:()=>Mc,auxCBox:()=>hc,av01SampleEntry:()=>rh,av1CBox:()=>Ko,avc1SampleEntry:()=>th,avc2SampleEntry:()=>eh,avc3SampleEntry:()=>ih,avc4SampleEntry:()=>sh,avcCBox:()=>ha,avllSampleGroupEntry:()=>Ud,avs3SampleEntry:()=>vh,avssSampleGroupEntry:()=>Sd,brstBox:()=>Rc,btrtBox:()=>cc,bxmlBox:()=>yo,ccstBox:()=>lc,cdefBox:()=>dc,clapBox:()=>fc,clefBox:()=>kl,clliBox:()=>uc,cmexBox:()=>pc,cminBox:()=>_c,cmpdBox:()=>mc,co64Box:()=>gc,colrBox:()=>Zo,coviBox:()=>vc,cprtBox:()=>Uc,cschBox:()=>Sc,cslgBox:()=>Bc,cttsBox:()=>wc,dOpsBox:()=>Pc,dac3Box:()=>zc,dataBox:()=>cn,dav1SampleEntry:()=>nh,dec3Box:()=>Ec,dfLaBox:()=>kc,dimmBox:()=>Ic,dinfBox:()=>ua,dmax:()=>Tc,dmedBox:()=>Ac,dobrBox:()=>Nc,drefBox:()=>ga,drepBox:()=>Cc,dtrtSampleGroupEntry:()=>Bd,dvh1SampleEntry:()=>uh,dvheSampleEntry:()=>ph,ec_3SampleEntry:()=>Ah,edtsBox:()=>vo,elngBox:()=>xa,elstBox:()=>Fc,emsgBox:()=>Dc,encaSampleEntry:()=>Mh,encmSampleEntry:()=>jh,encsSampleEntry:()=>Nh,enctSampleEntry:()=>Vh,encuSampleEntry:()=>Rh,encvSampleEntry:()=>Oh,enofBox:()=>Tl,eqivBox:()=>Gc,esdsBox:()=>Xo,etypBox:()=>Oo,fLaCSampleEntry:()=>Hh,favcBox:()=>Vc,fielBox:()=>Zc,fobrBox:()=>jc,freeBox:()=>_o,frmaBox:()=>tl,ftypBox:()=>ya,grplBox:()=>Lo,hdlrBox:()=>ba,hev1SampleEntry:()=>hh,hev2SampleEntry:()=>ch,hinfBox:()=>zo,hmhdBox:()=>ca,hntiBox:()=>wo,hvc1SampleEntry:()=>ah,hvc2SampleEntry:()=>oh,hvcCBox:()=>va,hvt1SampleEntry:()=>lh,iaugBox:()=>$c,idatBox:()=>po,iinfBox:()=>No,ilocBox:()=>Go,ilstBox:()=>Al,imirBox:()=>el,infeBox:()=>Ro,iodsBox:()=>go,ipcoBox:()=>Do,ipmaBox:()=>il,iproBox:()=>bo,iprpBox:()=>Fo,irefBox:()=>jo,irotBox:()=>sl,ispeBox:()=>rl,itaiBox:()=>nl,j2kHBox:()=>Ho,j2kiSampleEntry:()=>Uh,keysBox:()=>Pl,kindBox:()=>al,levaBox:()=>ol,lhe1SampleEntry:()=>dh,lhv1SampleEntry:()=>fh,lhvCBox:()=>hl,lselBox:()=>cl,m4aeSampleEntry:()=>kh,maxrBox:()=>ll,mdatBox:()=>En,mdcvBox:()=>dl,mdhdBox:()=>Ua,mdiaBox:()=>da,mecoBox:()=>Bo,mehdBox:()=>Sa,metaBox:()=>qo,mettSampleEntry:()=>Yo,metxSampleEntry:()=>Wo,mfhdBox:()=>Ba,mfraBox:()=>So,mfroBox:()=>fl,mha1SampleEntry:()=>Ch,mha2SampleEntry:()=>Fh,mhm1SampleEntry:()=>Dh,mhm2SampleEntry:()=>Lh,minfBox:()=>fa,mjp2SampleEntry:()=>Sh,mjpgSampleEntry:()=>Bh,moofBox:()=>_a,moovBox:()=>Gn,mp4aSampleEntry:()=>Eh,mp4sSampleEntry:()=>Gh,mp4vSampleEntry:()=>zh,mskCBox:()=>ul,msrcTrackGroupTypeBox:()=>cd,mvexBox:()=>Vn,mvhdBox:()=>wa,mvifSampleGroupEntry:()=>wd,nmhdBox:()=>kn,npckBox:()=>pl,numpBox:()=>_l,padbBox:()=>gl,panoBox:()=>qc,paspBox:()=>xl,paylBox:()=>yl,paytBox:()=>bl,pdinBox:()=>vl,piffLsmBox:()=>Rd,piffPsshBox:()=>Nd,piffSencBox:()=>Gd,piffTencBox:()=>Vd,piffTfrfBox:()=>jd,piffTfxdBox:()=>$d,pitmBox:()=>$o,pixiBox:()=>Ul,pmaxBox:()=>Sl,povdBox:()=>Mo,prdiBox:()=>Bl,prfrBox:()=>wl,prftBox:()=>zl,prgrBox:()=>Qc,profBox:()=>Cl,prolSampleGroupEntry:()=>zd,psshBox:()=>El,pymdBox:()=>Jc,rapSampleGroupEntry:()=>Ed,rashSampleGroupEntry:()=>kd,resvSampleEntry:()=>$h,rinfBox:()=>To,rollSampleGroupEntry:()=>Id,rtp_Box:()=>Ll,saioBox:()=>Hl,saizBox:()=>Ol,sbgpBox:()=>Xh,sbpmBox:()=>Rl,sbttSampleEntry:()=>qh,schiBox:()=>Ao,schmBox:()=>Nl,scifSampleGroupEntry:()=>Td,scnmSampleGroupEntry:()=>Ad,sdp_Box:()=>Gl,sdtpBox:()=>Qh,seigSampleGroupEntry:()=>Pd,sencBox:()=>Vl,sgpdBox:()=>Jh,sidxBox:()=>Zh,sinfBox:()=>Io,skipBox:()=>mo,slidBox:()=>Yc,smhdBox:()=>Ia,ssixBox:()=>$l,stblBox:()=>pa,stcoBox:()=>Ta,stdpBox:()=>ql,sterBox:()=>Wc,sthdBox:()=>Aa,stppSampleEntry:()=>ka,strdBox:()=>ko,striBox:()=>Yl,strkBox:()=>Eo,stsaSampleGroupEntry:()=>Cd,stscBox:()=>Pa,stsdBox:()=>Ca,stsgBox:()=>Wl,stshBox:()=>Kl,stssBox:()=>Xl,stszBox:()=>Fa,sttsBox:()=>Da,stviBox:()=>Ql,stxtSampleEntry:()=>Yh,stypBox:()=>Jl,stz2Box:()=>Zl,subsBox:()=>td,syncSampleGroupEntry:()=>Fd,taicBox:()=>ed,taptBox:()=>Fl,teleSampleGroupEntry:()=>Dd,tencBox:()=>id,tfdtBox:()=>La,tfhdBox:()=>Ha,tfraBox:()=>sd,tkhdBox:()=>Oa,tmaxBox:()=>rd,tminBox:()=>nd,totlBox:()=>ad,tpayBox:()=>od,tpylBox:()=>hd,trafBox:()=>ma,trakBox:()=>la,trefBox:()=>ld,trepBox:()=>dd,trexBox:()=>jn,trgrBox:()=>Po,trpyBox:()=>fd,trunBox:()=>Ma,tsasSampleGroupEntry:()=>Ld,tsclSampleGroupEntry:()=>Hd,tselBox:()=>ud,tsynBox:()=>Kc,tx3gSampleEntry:()=>Wh,txtcBox:()=>pd,tycoBox:()=>_d,udesBox:()=>md,udtaBox:()=>Co,uncCBox:()=>gd,uncvSampleEntry:()=>wh,urlBox:()=>Ra,urnBox:()=>xd,viprSampleGroupEntry:()=>Od,vmhdBox:()=>Na,vp08SampleEntry:()=>yh,vp09SampleEntry:()=>bh,vpcCBox:()=>Qo,vttCBox:()=>yd,vttcBox:()=>Uo,vvc1SampleEntry:()=>_h,vvcCBox:()=>Jo,vvcNSampleEntry:()=>xh,vvi1SampleEntry:()=>mh,vvnCBox:()=>bd,vvs1SampleEntry:()=>gh,waveBox:()=>Dl,wbbrBox:()=>Xc,wvttSampleEntry:()=>Kh,xmlBox:()=>xo});var Si,ac=(Si=class extends p{constructor(){super(...arguments),this.box_name="AV1LayeredImageIndexingProperty"}parse(t){const i=((t.readUint8()&1&1)+1)*16;this.layer_size=[];for(let s=0;s<3;s++)i===16?this.layer_size[s]=t.readUint16():this.layer_size[s]=t.readUint32()}},Si.fourcc="a1lx",Si),Bi,oc=(Bi=class extends p{constructor(){super(...arguments),this.box_name="OperatingPointSelectorProperty"}parse(t){this.op_index=t.readUint8()}},Bi.fourcc="a1op",Bi),wi,hc=(wi=class extends d{constructor(){super(...arguments),this.box_name="AuxiliaryTypeProperty"}parse(t){this.parseFullHeader(t),this.aux_type=t.readCString();const e=this.size-this.hdr_size-(this.aux_type.length+1);this.aux_subtype=t.readUint8Array(e)}},wi.fourcc="auxC",wi),zi,cc=(zi=class extends p{constructor(){super(...arguments),this.box_name="BitRateBox"}parse(t){this.bufferSizeDB=t.readUint32(),this.maxBitrate=t.readUint32(),this.avgBitrate=t.readUint32()}},zi.fourcc="btrt",zi),Ei,lc=(Ei=class extends d{constructor(){super(...arguments),this.box_name="CodingConstraintsBox"}parse(t){this.parseFullHeader(t);const e=t.readUint8();this.all_ref_pics_intra=(e&128)===128,this.intra_pred_used=(e&64)===64,this.max_ref_per_pic=(e&63)>>2,t.readUint24()}},Ei.fourcc="ccst",Ei),ki,dc=(ki=class extends p{constructor(){super(...arguments),this.box_name="ComponentDefinitionBox"}parse(t){this.channel_count=t.readUint16(),this.channel_indexes=[],this.channel_types=[],this.channel_associations=[];for(let e=0;e<this.channel_count;e++)this.channel_indexes.push(t.readUint16()),this.channel_types.push(t.readUint16()),this.channel_associations.push(t.readUint16())}},ki.fourcc="cdef",ki),Ii,fc=(Ii=class extends p{constructor(){super(...arguments),this.box_name="CleanApertureBox"}parse(t){this.cleanApertureWidthN=t.readUint32(),this.cleanApertureWidthD=t.readUint32(),this.cleanApertureHeightN=t.readUint32(),this.cleanApertureHeightD=t.readUint32(),this.horizOffN=t.readUint32(),this.horizOffD=t.readUint32(),this.vertOffN=t.readUint32(),this.vertOffD=t.readUint32()}},Ii.fourcc="clap",Ii),Ti,uc=(Ti=class extends p{constructor(){super(...arguments),this.box_name="ContentLightLevelBox"}parse(t){this.max_content_light_level=t.readUint16(),this.max_pic_average_light_level=t.readUint16()}},Ti.fourcc="clli",Ti),Ai,pc=(Ai=class extends p{constructor(){super(...arguments),this.box_name="CameraExtrinsicMatrixProperty"}parse(t){this.flags&1&&(this.pos_x=t.readInt32()),this.flags&2&&(this.pos_y=t.readInt32()),this.flags&4&&(this.pos_z=t.readInt32()),this.flags&8&&(this.version===0?this.flags&16?(this.quat_x=t.readInt32(),this.quat_y=t.readInt32(),this.quat_z=t.readInt32()):(this.quat_x=t.readInt16(),this.quat_y=t.readInt16(),this.quat_z=t.readInt16()):this.version),this.flags&32&&(this.id=t.readUint32())}},Ai.fourcc="cmex",Ai),Pi,_c=(Pi=class extends p{constructor(){super(...arguments),this.box_name="CameraIntrinsicMatrixProperty"}parse(t){this.focal_length_x=t.readInt32(),this.principal_point_x=t.readInt32(),this.principal_point_y=t.readInt32(),this.flags&1&&(this.focal_length_y=t.readInt32(),this.skew_factor=t.readInt32())}},Pi.fourcc="cmin",Pi),Ci,mc=(Ci=class extends p{constructor(){super(...arguments),this.box_name="ComponentDefinitionBox"}parse(t){this.component_count=t.readUint32(),this.component_types=[],this.component_type_urls=[];for(let e=0;e<this.component_count;e++){const i=t.readUint16();this.component_types.push(i),i>=32768&&this.component_type_urls.push(t.readCString())}}},Ci.fourcc="cmpd",Ci),Fi,gc=(Fi=class extends d{constructor(){super(...arguments),this.box_name="ChunkLargeOffsetBox"}parse(t){this.parseFullHeader(t);const e=t.readUint32();if(this.chunk_offsets=[],this.version===0)for(let i=0;i<e;i++)this.chunk_offsets.push(t.readUint64())}write(t){this.version=0,this.flags=0,this.size=4+8*this.chunk_offsets.length,this.writeHeader(t),t.writeUint32(this.chunk_offsets.length);for(let e=0;e<this.chunk_offsets.length;e++)t.writeUint64(this.chunk_offsets[e])}},Fi.fourcc="co64",Fi),Di,xc=(Di=class extends d{constructor(){super(...arguments),this.box_name="ContentLightLevelBox"}parse(t){this.parseFullHeader(t),this.maxCLL=t.readUint16(),this.maxFALL=t.readUint16()}},Di.fourcc="CoLL",Di),yc=class{toString(){let r="centre_azimuth: ";return r+=this.centre_azimuth,r+=" (",r+=this.centre_azimuth*2**-16,r+="°), centre_elevation: ",r+=this.centre_elevation,r+=" (",r+=this.centre_elevation*2**-16,r+="°), centre_tilt: ",r+=this.centre_tilt,r+=" (",r+=this.centre_tilt*2**-16,r+="°)",this.range_included_flag&&(r+=", azimuth_range: ",r+=this.azimuth_range,r+=" (",r+=this.azimuth_range*2**-16,r+="°), elevation_range: ",r+=this.elevation_range,r+=" (",r+=this.elevation_range*2**-16,r+="°)"),this.interpolate_included_flag&&(r+=", interpolate: ",r+=this.interpolate),r}},bc=class{toString(){let r="";return this.view_idc&&(r+="view_idc: ",r+=this.view_idc,r+=", "),r+="sphere_region: {",r+=this.sphere_region,r+="}",r}},Li,vc=(Li=class extends d{constructor(){super(...arguments),this.box_name="CoverageInformationBox"}parse(t){this.parseFullHeader(t),this.coverage_shape_type=t.readUint8();const e=t.readUint8(),i=t.readInt8(),s=i&128;s&&(this.default_view_idc=(i&96)>>5),this.coverage_regions=new Array;for(let n=0;n<e;n++){const a=new bc;s&&(a.view_idc=t.readUint8()>>6),a.sphere_region=this.parseSphereRegion(t,!0,!0),this.coverage_regions.push(a)}}parseSphereRegion(t,e,i){const s=new yc;return s.centre_azimuth=t.readInt32(),s.centre_elevation=t.readInt32(),s.centre_tilt=t.readInt32(),s.range_included_flag=e,e&&(s.azimuth_range=t.readUint32(),s.elevation_range=t.readUint32()),s.interpolate_included_flag=i,i&&(s.interpolate=(t.readUint8()&128)===128),s}},Li.fourcc="covi",Li),Hi,Uc=(Hi=class extends d{constructor(){super(...arguments),this.box_name="CopyrightBox"}parse(t){this.parseFullHeader(t),this.parseLanguage(t),this.notice=t.readCString()}},Hi.fourcc="cprt",Hi),Oi,Sc=(Oi=class extends d{constructor(){super(...arguments),this.box_name="CompatibleSchemeTypeBox"}parse(t){this.parseFullHeader(t),this.scheme_type=t.readString(4),this.scheme_version=t.readUint32(),this.flags&1&&(this.scheme_uri=t.readCString())}},Oi.fourcc="csch",Oi),hn=2147483647,Mi,Bc=(Mi=class extends d{constructor(){super(...arguments),this.box_name="CompositionToDecodeBox"}parse(t){this.parseFullHeader(t),this.version===0?(this.compositionToDTSShift=t.readInt32(),this.leastDecodeToDisplayDelta=t.readInt32(),this.greatestDecodeToDisplayDelta=t.readInt32(),this.compositionStartTime=t.readInt32(),this.compositionEndTime=t.readInt32()):this.version===1&&(this.compositionToDTSShift=t.readInt64(),this.leastDecodeToDisplayDelta=t.readInt64(),this.greatestDecodeToDisplayDelta=t.readInt64(),this.compositionStartTime=t.readInt64(),this.compositionEndTime=t.readInt64())}write(t){this.version=0,(this.compositionToDTSShift>hn||this.leastDecodeToDisplayDelta>hn||this.greatestDecodeToDisplayDelta>hn||this.compositionStartTime>hn||this.compositionEndTime>hn)&&(this.version=1),this.flags=0,this.version===0?(this.size=20,this.writeHeader(t),t.writeInt32(this.compositionToDTSShift),t.writeInt32(this.leastDecodeToDisplayDelta),t.writeInt32(this.greatestDecodeToDisplayDelta),t.writeInt32(this.compositionStartTime),t.writeInt32(this.compositionEndTime)):this.version===1&&(this.size=40,this.writeHeader(t),t.writeInt64(this.compositionToDTSShift),t.writeInt64(this.leastDecodeToDisplayDelta),t.writeInt64(this.greatestDecodeToDisplayDelta),t.writeInt64(this.compositionStartTime),t.writeInt64(this.compositionEndTime))}},Mi.fourcc="cslg",Mi),Ri,wc=(Ri=class extends d{constructor(){super(...arguments),this.box_name="CompositionOffsetBox"}parse(t){this.parseFullHeader(t);const e=t.readUint32();if(this.sample_counts=[],this.sample_offsets=[],this.version===0)for(let i=0;i<e;i++){this.sample_counts.push(t.readUint32());const s=t.readInt32();s<0&&l.warn("BoxParser","ctts box uses negative values without using version 1"),this.sample_offsets.push(s)}else if(this.version===1)for(let i=0;i<e;i++)this.sample_counts.push(t.readUint32()),this.sample_offsets.push(t.readInt32())}write(t){this.version=this.sample_offsets.some(e=>e<0)?1:0,this.flags=0,this.size=4+8*this.sample_counts.length,this.writeHeader(t),t.writeUint32(this.sample_counts.length);for(let e=0;e<this.sample_counts.length;e++)t.writeUint32(this.sample_counts[e]),this.version===1?t.writeInt32(this.sample_offsets[e]):t.writeUint32(this.sample_offsets[e])}unpack(t){let e=0;for(let i=0;i<this.sample_counts.length;i++)for(let s=0;s<this.sample_counts[i];s++)t[e].pts=t[e].dts+this.sample_offsets[i],e++}},Ri.fourcc="ctts",Ri),Ni,zc=(Ni=class extends p{constructor(){super(...arguments),this.box_name="AC3SpecificBox"}parse(t){const e=t.readUint8(),i=t.readUint8(),s=t.readUint8();this.fscod=e>>6,this.bsid=e>>1&31,this.bsmod=(e&1)<<2|i>>6&3,this.acmod=i>>3&7,this.lfeon=i>>2&1,this.bit_rate_code=i&3|s>>5&7}},Ni.fourcc="dac3",Ni),Gi,Ec=(Gi=class extends p{constructor(){super(...arguments),this.box_name="EC3SpecificBox"}parse(t){const e=t.readUint16();this.data_rate=e>>3,this.num_ind_sub=e&7,this.ind_subs=[];for(let i=0;i<this.num_ind_sub+1;i++){const s=t.readUint8(),n=t.readUint8(),a=t.readUint8(),o={fscod:s>>6,bsid:s>>1&31,bsmod:(s&1)<<4|n>>4&15,acmod:n>>1&7,lfeon:n&1,num_dep_sub:a>>1&15};this.ind_subs.push(o),o.num_dep_sub>0&&(o.chan_loc=(a&1)<<8|t.readUint8())}}},Gi.fourcc="dec3",Gi),Vi,kc=(Vi=class extends d{constructor(){super(...arguments),this.box_name="FLACSpecificBox"}parse(t){this.parseFullHeader(t);const e=127,i=128,s=[],n=["STREAMINFO","PADDING","APPLICATION","SEEKTABLE","VORBIS_COMMENT","CUESHEET","PICTURE","RESERVED"];let a;do{a=t.readUint8();const o=Math.min(a&e,n.length-1);o?t.readUint8Array(t.readUint24()):(t.readUint8Array(13),this.samplerate=t.readUint32()>>12,t.readUint8Array(20)),s.push(n[o])}while(a&i);this.numMetadataBlocks=s.length+" ("+s.join(", ")+")"}},Vi.fourcc="dfLa",Vi),ji,Ic=(ji=class extends p{constructor(){super(...arguments),this.box_name="hintimmediateBytesSent"}parse(t){this.bytessent=t.readUint64()}},ji.fourcc="dimm",ji),$i,Tc=($i=class extends p{constructor(){super(...arguments),this.box_name="hintlongestpacket"}parse(t){this.time=t.readUint32()}},$i.fourcc="dmax",$i),qi,Ac=(qi=class extends p{constructor(){super(...arguments),this.box_name="hintmediaBytesSent"}parse(t){this.bytessent=t.readUint64()}},qi.fourcc="dmed",qi),Yi,Pc=(Yi=class extends p{constructor(){super(...arguments),this.box_name="OpusSpecificBox"}parse(t){if(this.Version=t.readUint8(),this.OutputChannelCount=t.readUint8(),this.PreSkip=t.readUint16(),this.InputSampleRate=t.readUint32(),this.OutputGain=t.readInt16(),this.ChannelMappingFamily=t.readUint8(),this.ChannelMappingFamily!==0){this.StreamCount=t.readUint8(),this.CoupledCount=t.readUint8(),this.ChannelMapping=[];for(let e=0;e<this.OutputChannelCount;e++)this.ChannelMapping[e]=t.readUint8()}}write(t){if(this.size=11,this.ChannelMappingFamily!==0&&(this.size+=2+this.OutputChannelCount),this.writeHeader(t),t.writeUint8(this.Version),t.writeUint8(this.OutputChannelCount),t.writeUint16(this.PreSkip),t.writeUint32(this.InputSampleRate),t.writeInt16(this.OutputGain),t.writeUint8(this.ChannelMappingFamily),this.ChannelMappingFamily!==0){t.writeUint8(this.StreamCount),t.writeUint8(this.CoupledCount);for(let e=0;e<this.OutputChannelCount;e++)t.writeUint8(this.ChannelMapping[e])}}},Yi.fourcc="dOps",Yi),Wi,Cc=(Wi=class extends p{constructor(){super(...arguments),this.box_name="hintrepeatedBytesSent"}parse(t){this.bytessent=t.readUint64()}},Wi.fourcc="drep",Wi),Ki,Fc=(Ki=class extends d{constructor(){super(...arguments),this.box_name="EditListBox"}parse(t){this.parseFullHeader(t),this.entries=[];const e=t.readUint32();for(let i=0;i<e;i++){const s={segment_duration:this.version===1?t.readUint64():t.readUint32(),media_time:this.version===1?t.readInt64():t.readInt32(),media_rate_integer:t.readInt16(),media_rate_fraction:t.readInt16()};this.entries.push(s)}}write(t){const e=this.entries.some(i=>i.segment_duration>w||i.media_time>w)||this.version===1;this.version=e?1:0,this.size=4+12*this.entries.length,this.size+=e?8*this.entries.length:0,this.writeHeader(t),t.writeUint32(this.entries.length);for(let i=0;i<this.entries.length;i++){const s=this.entries[i];e?(t.writeUint64(s.segment_duration),t.writeInt64(s.media_time)):(t.writeUint32(s.segment_duration),t.writeInt32(s.media_time)),t.writeInt16(s.media_rate_integer),t.writeInt16(s.media_rate_fraction)}}},Ki.fourcc="elst",Ki),Xi,Dc=(Xi=class extends d{constructor(){super(...arguments),this.box_name="EventMessageBox"}parse(t){this.parseFullHeader(t),this.version===1?(this.timescale=t.readUint32(),this.presentation_time=t.readUint64(),this.event_duration=t.readUint32(),this.id=t.readUint32(),this.scheme_id_uri=t.readCString(),this.value=t.readCString()):(this.scheme_id_uri=t.readCString(),this.value=t.readCString(),this.timescale=t.readUint32(),this.presentation_time_delta=t.readUint32(),this.event_duration=t.readUint32(),this.id=t.readUint32());let e=this.size-this.hdr_size-(16+(this.scheme_id_uri.length+1)+(this.value.length+1));this.version===1&&(e-=4),this.message_data=t.readUint8Array(e)}write(t){this.version=0,this.flags=0,this.size=16+this.message_data.length+(this.scheme_id_uri.length+1)+(this.value.length+1),this.writeHeader(t),t.writeCString(this.scheme_id_uri),t.writeCString(this.value),t.writeUint32(this.timescale),t.writeUint32(this.presentation_time_delta),t.writeUint32(this.event_duration),t.writeUint32(this.id),t.writeUint8Array(this.message_data)}},Xi.fourcc="emsg",Xi),E=class extends d{parse(r){this.parseFullHeader(r),this.group_id=r.readUint32(),this.num_entities_in_group=r.readUint32(),this.entity_ids=[];for(let t=0;t<this.num_entities_in_group;t++){const e=r.readUint32();this.entity_ids.push(e)}}},Qi,Lc=(Qi=class extends E{constructor(){super(...arguments),this.box_name="Auto exposure bracketing"}},Qi.fourcc="aebr",Qi),Ji,Hc=(Ji=class extends E{constructor(){super(...arguments),this.box_name="Flash exposure information"}},Ji.fourcc="afbr",Ji),Zi,Oc=(Zi=class extends E{constructor(){super(...arguments),this.box_name="Album collection"}},Zi.fourcc="albc",Zi),ts,Mc=(ts=class extends E{constructor(){super(...arguments),this.box_name="Alternative entity"}},ts.fourcc="altr",ts),es,Rc=(es=class extends E{constructor(){super(...arguments),this.box_name="Burst image"}},es.fourcc="brst",es),is,Nc=(is=class extends E{constructor(){super(...arguments),this.box_name="Depth of field bracketing"}},is.fourcc="dobr",is),ss,Gc=(ss=class extends E{constructor(){super(...arguments),this.box_name="Equivalent entity"}},ss.fourcc="eqiv",ss),rs,Vc=(rs=class extends E{constructor(){super(...arguments),this.box_name="Favorites collection"}},rs.fourcc="favc",rs),ns,jc=(ns=class extends E{constructor(){super(...arguments),this.box_name="Focus bracketing"}},ns.fourcc="fobr",ns),as,$c=(as=class extends E{constructor(){super(...arguments),this.box_name="Image item with an audio track"}},as.fourcc="iaug",as),os,qc=(os=class extends E{constructor(){super(...arguments),this.box_name="Panorama"}},os.fourcc="pano",os),hs,Yc=(hs=class extends E{constructor(){super(...arguments),this.box_name="Slideshow"}},hs.fourcc="slid",hs),cs,Wc=(cs=class extends E{constructor(){super(...arguments),this.box_name="Stereo"}},cs.fourcc="ster",cs),ls,Kc=(ls=class extends E{constructor(){super(...arguments),this.box_name="Time-synchronized capture"}},ls.fourcc="tsyn",ls),ds,Xc=(ds=class extends E{constructor(){super(...arguments),this.box_name="White balance bracketing"}},ds.fourcc="wbbr",ds),fs,Qc=(fs=class extends E{constructor(){super(...arguments),this.box_name="Progressive rendering"}},fs.fourcc="prgr",fs),us,Jc=(us=class extends E{constructor(){super(...arguments),this.box_name="Image pyramid"}parse(t){this.parseFullHeader(t),this.group_id=t.readUint32(),this.num_entities_in_group=t.readUint32(),this.entity_ids=[];for(let e=0;e<this.num_entities_in_group;e++){const i=t.readUint32();this.entity_ids.push(i)}this.tile_size_x=t.readUint16(),this.tile_size_y=t.readUint16(),this.layer_binning=[],this.tiles_in_layer_column_minus1=[],this.tiles_in_layer_row_minus1=[];for(let e=0;e<this.num_entities_in_group;e++)this.layer_binning[e]=t.readUint16(),this.tiles_in_layer_row_minus1[e]=t.readUint16(),this.tiles_in_layer_column_minus1[e]=t.readUint16()}},us.fourcc="pymd",us),ps,Zc=(ps=class extends p{constructor(){super(...arguments),this.box_name="FieldHandlingBox"}parse(t){this.fieldCount=t.readUint8(),this.fieldOrdering=t.readUint8()}},ps.fourcc="fiel",ps),_s,tl=(_s=class extends p{constructor(){super(...arguments),this.box_name="OriginalFormatBox"}parse(t){this.data_format=t.readString(4)}},_s.fourcc="frma",_s),ms,el=(ms=class extends p{constructor(){super(...arguments),this.box_name="ImageMirror"}parse(t){const e=t.readUint8();this.reserved=e>>7,this.axis=e&1}},ms.fourcc="imir",ms),gs,il=(gs=class extends d{constructor(){super(...arguments),this.box_name="ItemPropertyAssociationBox"}parse(t){this.parseFullHeader(t);const e=t.readUint32();this.associations=[];for(let i=0;i<e;i++){const s=this.version<1?t.readUint16():t.readUint32(),n=[],a=t.readUint8();for(let o=0;o<a;o++){const h=t.readUint8();n.push({essential:(h&128)>>7===1,property_index:this.flags&1?(h&127)<<8|t.readUint8():h&127})}this.associations.push({id:s,props:n})}}},gs.fourcc="ipma",gs),xs,sl=(xs=class extends p{constructor(){super(...arguments),this.box_name="ImageRotation"}parse(t){this.angle=t.readUint8()&3}},xs.fourcc="irot",xs),ys,rl=(ys=class extends d{constructor(){super(...arguments),this.box_name="ImageSpatialExtentsProperty"}parse(t){this.parseFullHeader(t),this.image_width=t.readUint32(),this.image_height=t.readUint32()}},ys.fourcc="ispe",ys),bs,nl=(bs=class extends d{constructor(){super(...arguments),this.box_name="TAITimestampBox"}parse(t){this.TAI_timestamp=t.readUint64();const e=t.readUint8();this.sychronization_state=e>>7&1,this.timestamp_generation_failure=e>>6&1,this.timestamp_is_modified=e>>5&1}},bs.fourcc="itai",bs),vs,al=(vs=class extends d{constructor(){super(...arguments),this.box_name="KindBox"}parse(t){this.parseFullHeader(t),this.schemeURI=t.readCString(),this.isEndOfBox(t)||(this.value=t.readCString())}write(t){this.version=0,this.flags=0,this.size=this.schemeURI.length+1+(this.value?this.value.length+1:0),this.writeHeader(t),t.writeCString(this.schemeURI),this.value&&t.writeCString(this.value)}},vs.fourcc="kind",vs),Us,ol=(Us=class extends d{constructor(){super(...arguments),this.box_name="LevelAssignmentBox"}parse(t){this.parseFullHeader(t);const e=t.readUint8();this.levels=[];for(let i=0;i<e;i++){const s={};this.levels[i]=s,s.track_ID=t.readUint32();const n=t.readUint8();switch(s.padding_flag=n>>7,s.assignment_type=n&127,s.assignment_type){case 0:s.grouping_type=t.readString(4);break;case 1:s.grouping_type=t.readString(4),s.grouping_type_parameter=t.readUint32();break;case 2:break;case 3:break;case 4:s.sub_track_id=t.readUint32();break;default:l.warn("BoxParser",`Unknown level assignment type: ${s.assignment_type}`)}}}},Us.fourcc="leva",Us),Ss,hl=(Ss=class extends p{constructor(){super(...arguments),this.box_name="LHEVCConfigurationBox"}parse(t){this.configurationVersion=t.readUint8(),this.min_spatial_segmentation_idc=t.readUint16()&4095,this.parallelismType=t.readUint8()&3;let e=t.readUint8();this.numTemporalLayers=(e&13)>>3,this.temporalIdNested=(e&4)>>2,this.lengthSizeMinusOne=e&3,this.nalu_arrays=[];const i=t.readUint8();for(let s=0;s<i;s++){const n=[];this.nalu_arrays.push(n),e=t.readUint8(),n.completeness=(e&128)>>7,n.nalu_type=e&63;const a=t.readUint16();for(let o=0;o<a;o++){const h=t.readUint16();n.push({data:t.readUint8Array(h)})}}}},Ss.fourcc="lhvC",Ss),Bs,cl=(Bs=class extends p{constructor(){super(...arguments),this.box_name="LayerSelectorProperty"}parse(t){this.layer_id=t.readUint16()}},Bs.fourcc="lsel",Bs),ws,ll=(ws=class extends p{constructor(){super(...arguments),this.box_name="hintmaxrate"}parse(t){this.period=t.readUint32(),this.bytes=t.readUint32()}},ws.fourcc="maxr",ws),yn=class{constructor(r,t){this.x=r,this.y=t}toString(){return"("+this.x+","+this.y+")"}},zs,dl=(zs=class extends p{constructor(){super(...arguments),this.box_name="MasteringDisplayColourVolumeBox"}parse(t){this.display_primaries=[],this.display_primaries[0]=new yn(t.readUint16(),t.readUint16()),this.display_primaries[1]=new yn(t.readUint16(),t.readUint16()),this.display_primaries[2]=new yn(t.readUint16(),t.readUint16()),this.white_point=new yn(t.readUint16(),t.readUint16()),this.max_display_mastering_luminance=t.readUint32(),this.min_display_mastering_luminance=t.readUint32()}},zs.fourcc="mdcv",zs),Es,fl=(Es=class extends d{constructor(){super(...arguments),this.box_name="MovieFragmentRandomAccessOffsetBox"}parse(t){this.parseFullHeader(t),this._size=t.readUint32()}},Es.fourcc="mfro",Es),ks,ul=(ks=class extends d{constructor(){super(...arguments),this.box_name="MaskConfigurationProperty"}parse(t){this.parseFullHeader(t),this.bits_per_pixel=t.readUint8()}},ks.fourcc="mskC",ks),Is,pl=(Is=class extends p{constructor(){super(...arguments),this.box_name="hintPacketsSent"}parse(t){this.packetssent=t.readUint32()}},Is.fourcc="npck",Is),Ts,_l=(Ts=class extends p{constructor(){super(...arguments),this.box_name="hintPacketsSent"}parse(t){this.packetssent=t.readUint64()}},Ts.fourcc="nump",Ts),ml=class{constructor(r,t){this.pad1=r,this.pad2=t}},As,gl=(As=class extends d{constructor(){super(...arguments),this.box_name="PaddingBitsBox"}parse(t){this.parseFullHeader(t);const e=t.readUint32();this.padbits=[];for(let i=0;i<Math.floor((e+1)/2);i++){const s=t.readUint8(),n=(s&112)>>4,a=s&7;this.padbits.push(new ml(n,a))}}},As.fourcc="padb",As),Ps,xl=(Ps=class extends p{constructor(){super(...arguments),this.box_name="PixelAspectRatioBox"}parse(t){this.hSpacing=t.readUint32(),this.vSpacing=t.readUint32()}},Ps.fourcc="pasp",Ps),Cs,yl=(Cs=class extends p{constructor(){super(...arguments),this.box_name="CuePayloadBox"}parse(t){this.text=t.readString(this.size-this.hdr_size)}},Cs.fourcc="payl",Cs),Fs,bl=(Fs=class extends p{constructor(){super(...arguments),this.box_name="hintpayloadID"}parse(t){this.payloadID=t.readUint32();const e=t.readUint8();this.rtpmap_string=t.readString(e)}},Fs.fourcc="payt",Fs),Ds,vl=(Ds=class extends d{constructor(){super(...arguments),this.box_name="ProgressiveDownloadInfoBox",this.rate=[],this.initial_delay=[]}parse(t){this.parseFullHeader(t);const e=(this.size-this.hdr_size)/8;for(let i=0;i<e;i++)this.rate[i]=t.readUint32(),this.initial_delay[i]=t.readUint32()}},Ds.fourcc="pdin",Ds),Ls,Ul=(Ls=class extends d{constructor(){super(...arguments),this.box_name="PixelInformationProperty"}parse(t){this.parseFullHeader(t),this.num_channels=t.readUint8(),this.bits_per_channels=[];for(let e=0;e<this.num_channels;e++)this.bits_per_channels[e]=t.readUint8()}},Ls.fourcc="pixi",Ls),Hs,Sl=(Hs=class extends p{constructor(){super(...arguments),this.box_name="hintlargestpacket"}parse(t){this.bytes=t.readUint32()}},Hs.fourcc="pmax",Hs),Os,Bl=(Os=class extends d{constructor(){super(...arguments),this.box_name="ProgressiveDerivedImageItemInformationProperty"}parse(t){if(this.parseFullHeader(t),this.step_count=t.readUint16(),this.item_count=[],this.flags&2)for(let e=0;e<this.step_count;e++)this.item_count[e]=t.readUint16()}},Os.fourcc="prdi",Os),Ms,wl=(Ms=class extends d{constructor(){super(...arguments),this.box_name="ProjectionFormatBox"}parse(t){this.parseFullHeader(t),this.projection_type=t.readUint8()&31}},Ms.fourcc="prfr",Ms),Rs,zl=(Rs=class extends d{constructor(){super(...arguments),this.box_name="ProducerReferenceTimeBox"}parse(t){this.parseFullHeader(t),this.ref_track_id=t.readUint32(),this.ntp_timestamp=t.readUint64(),this.version===0?this.media_time=t.readUint32():this.media_time=t.readUint64()}},Rs.fourcc="prft",Rs),Ns,El=(Ns=class extends d{constructor(){super(...arguments),this.box_name="ProtectionSystemSpecificHeaderBox"}parse(t){if(this.parseFullHeader(t),this.system_id=K(t),this.version>0){const i=t.readUint32();this.kid=[];for(let s=0;s<i;s++)this.kid[s]=K(t)}const e=t.readUint32();e>0&&(this.protection_data=t.readUint8Array(e))}},Ns.fourcc="pssh",Ns),Gs,kl=(Gs=class extends d{constructor(){super(...arguments),this.box_name="TrackCleanApertureDimensionsBox"}parse(t){this.parseFullHeader(t),this.width=t.readUint32(),this.height=t.readUint32()}},Gs.fourcc="clef",Gs);function Il(r,t){if(r===cn.Types.UTF8)return new TextDecoder("utf-8").decode(t);const e=new DataView(t.buffer);if(r===cn.Types.BE_UNSIGNED_INT){if(t.length===1)return e.getUint8(0);if(t.length===2)return e.getUint16(0,!1);if(t.length===4)return e.getUint32(0,!1);if(t.length===8)return e.getBigUint64(0,!1);throw new Error("Unsupported ITIF_TYPE_BE_UNSIGNED_INT length "+t.length)}else if(r===cn.Types.BE_SIGNED_INT){if(t.length===1)return e.getInt8(0);if(t.length===2)return e.getInt16(0,!1);if(t.length===4)return e.getInt32(0,!1);if(t.length===8)return e.getBigInt64(0,!1);throw new Error("Unsupported ITIF_TYPE_BE_SIGNED_INT length "+t.length)}else if(r===cn.Types.BE_FLOAT32)return e.getFloat32(0,!1);l.warn("DataBox","Unsupported or unimplemented itif data type: "+r)}var W,cn=(W=class extends p{constructor(){super(...arguments),this.box_name="DataBox"}parse(t){this.valueType=t.readUint32(),this.country=t.readUint16(),this.country>255&&(t.seek(t.getPosition()-2),this.countryString=t.readString(2)),this.language=t.readUint16(),this.language>255&&(t.seek(t.getPosition()-2),this.parseLanguage(t)),this.raw=t.readUint8Array(this.size-this.hdr_size-8),this.value=Il(this.valueType,this.raw)}},W.fourcc="data",W.Types={RESERVED:0,UTF8:1,UTF16:2,SJIS:3,UTF8_SORT:4,UTF16_SORT:5,JPEG:13,PNG:14,BE_SIGNED_INT:21,BE_UNSIGNED_INT:22,BE_FLOAT32:23,BE_FLOAT64:24,BMP:27,QT_ATOM:28,BE_SIGNED_INT8:65,BE_SIGNED_INT16:66,BE_SIGNED_INT32:67,BE_FLOAT32_POINT:70,BE_FLOAT32_DIMENSIONS:71,BE_FLOAT32_RECT:72,BE_SIGNED_INT64:74,BE_UNSIGNED_INT8:75,BE_UNSIGNED_INT16:76,BE_UNSIGNED_INT32:77,BE_UNSIGNED_INT64:78,BE_FLOAT64_AFFINE_TRANSFORM:79},W),Vs,Tl=(Vs=class extends d{constructor(){super(...arguments),this.box_name="TrackEncodedPixelsDimensionsBox"}parse(t){this.parseFullHeader(t),this.width=t.readUint32(),this.height=t.readUint32()}},Vs.fourcc="enof",Vs),js,Al=(js=class extends p{constructor(){super(...arguments),this.box_name="IlstBox"}parse(t){this.list={};let e=this.size-this.hdr_size;for(;e>0;){const i=t.readUint32(),s=t.readUint32(),n=H(t,!1,i-8);n.code===F&&(this.list[s]=n.box),e-=i}}},js.fourcc="ilst",js),$s,Pl=($s=class extends d{constructor(){super(...arguments),this.box_name="KeysBox"}parse(t){this.parseFullHeader(t),this.count=t.readUint32(),this.keys={};for(let e=0;e<this.count;e++){const i=t.readUint32();this.keys[e+1]=t.readString(i-4)}}},$s.fourcc="keys",$s),qs,Cl=(qs=class extends d{constructor(){super(...arguments),this.box_name="TrackProductionApertureDimensionsBox"}parse(t){this.parseFullHeader(t),this.width=t.readUint32(),this.height=t.readUint32()}},qs.fourcc="prof",qs),Ys,Fl=(Ys=class extends y{constructor(){super(...arguments),this.box_name="TrackApertureModeDimensionsBox",this.clefs=[],this.profs=[],this.enofs=[],this.subBoxNames=["clef","prof","enof"]}},Ys.fourcc="tapt",Ys),Ws,Dl=(Ws=class extends y{constructor(){super(...arguments),this.box_name="siDecompressionParamBox"}},Ws.fourcc="wave",Ws),Ks,Ll=(Ks=class extends p{constructor(){super(...arguments),this.box_name="rtpmoviehintinformation"}parse(t){this.descriptionformat=t.readString(4),this.sdptext=t.readString(this.size-this.hdr_size-4)}},Ks.fourcc="rtp ",Ks),Xs,Hl=(Xs=class extends d{constructor(){super(...arguments),this.box_name="SampleAuxiliaryInformationOffsetsBox"}parse(t){this.parseFullHeader(t),this.flags&1&&(this.aux_info_type=t.readString(4),this.aux_info_type_parameter=t.readUint32());const e=t.readUint32();this.offset=[];for(let i=0;i<e;i++)this.version===0?this.offset[i]=t.readUint32():this.offset[i]=t.readUint64()}},Xs.fourcc="saio",Xs),Qs,Ol=(Qs=class extends d{constructor(){super(...arguments),this.box_name="SampleAuxiliaryInformationSizesBox"}parse(t){if(this.parseFullHeader(t),this.flags&1&&(this.aux_info_type=t.readString(4),this.aux_info_type_parameter=t.readUint32()),this.default_sample_info_size=t.readUint8(),this.sample_count=t.readUint32(),this.sample_info_size=[],this.default_sample_info_size===0)for(let e=0;e<this.sample_count;e++)this.sample_info_size[e]=t.readUint8()}},Qs.fourcc="saiz",Qs),Ml=class{constructor(r,t){this.bad_pixel_row=r,this.bad_pixel_column=t}toString(){return"[row: "+this.bad_pixel_row+", column: "+this.bad_pixel_column+"]"}},Js,Rl=(Js=class extends d{constructor(){super(...arguments),this.box_name="SensorBadPixelsMapBox"}parse(t){this.parseFullHeader(t),this.component_count=t.readUint16(),this.component_index=[];for(let i=0;i<this.component_count;i++)this.component_index.push(t.readUint16());const e=t.readUint8();this.correction_applied=(e&128)===128,this.num_bad_rows=t.readUint32(),this.num_bad_cols=t.readUint32(),this.num_bad_pixels=t.readUint32(),this.bad_rows=[],this.bad_columns=[],this.bad_pixels=[];for(let i=0;i<this.num_bad_rows;i++)this.bad_rows.push(t.readUint32());for(let i=0;i<this.num_bad_cols;i++)this.bad_columns.push(t.readUint32());for(let i=0;i<this.num_bad_pixels;i++){const s=t.readUint32(),n=t.readUint32();this.bad_pixels.push(new Ml(s,n))}}},Js.fourcc="sbpm",Js),Zs,Nl=(Zs=class extends d{constructor(){super(...arguments),this.box_name="SchemeTypeBox"}parse(t){this.parseFullHeader(t),this.scheme_type=t.readString(4),this.scheme_version=t.readUint32(),this.flags&1&&(this.scheme_uri=t.readString(this.size-this.hdr_size-8))}},Zs.fourcc="schm",Zs),tr,Gl=(tr=class extends p{constructor(){super(...arguments),this.box_name="rtptracksdphintinformation"}parse(t){this.sdptext=t.readString(this.size-this.hdr_size)}},tr.fourcc="sdp ",tr),er,Vl=(er=class extends d{constructor(){super(...arguments),this.box_name="SampleEncryptionBox"}},er.fourcc="senc",er),ir,jl=(ir=class extends d{constructor(){super(...arguments),this.box_name="SMPTE2086MasteringDisplayMetadataBox"}parse(t){this.parseFullHeader(t),this.primaryRChromaticity_x=t.readUint16(),this.primaryRChromaticity_y=t.readUint16(),this.primaryGChromaticity_x=t.readUint16(),this.primaryGChromaticity_y=t.readUint16(),this.primaryBChromaticity_x=t.readUint16(),this.primaryBChromaticity_y=t.readUint16(),this.whitePointChromaticity_x=t.readUint16(),this.whitePointChromaticity_y=t.readUint16(),this.luminanceMax=t.readUint32(),this.luminanceMin=t.readUint32()}},ir.fourcc="SmDm",ir),sr,$l=(sr=class extends d{constructor(){super(...arguments),this.box_name="CompressedSubsegmentIndexBox"}parse(t){this.parseFullHeader(t),this.subsegments=[];const e=t.readUint32();for(let i=0;i<e;i++){const s={};this.subsegments.push(s),s.ranges=[];const n=t.readUint32();for(let a=0;a<n;a++){const o={};s.ranges.push(o),o.level=t.readUint8(),o.range_size=t.readUint24()}}}},sr.fourcc="ssix",sr),rr,ql=(rr=class extends d{constructor(){super(...arguments),this.box_name="DegradationPriorityBox"}parse(t){this.parseFullHeader(t);const e=(this.size-this.hdr_size)/2;this.priority=[];for(let i=0;i<e;i++)this.priority[i]=t.readUint16()}},rr.fourcc="stpd",rr),nr,Yl=(nr=class extends d{constructor(){super(...arguments),this.box_name="SubTrackInformationBox"}parse(t){this.parseFullHeader(t),this.switch_group=t.readUint16(),this.alternate_group=t.readUint16(),this.sub_track_id=t.readUint32();const e=(this.size-this.hdr_size-8)/4;this.attribute_list=[];for(let i=0;i<e;i++)this.attribute_list[i]=t.readUint32()}},nr.fourcc="stri",nr),ar,Wl=(ar=class extends d{constructor(){super(...arguments),this.box_name="SubTrackSampleGroupBox"}parse(t){this.parseFullHeader(t),this.grouping_type=t.readUint32();const e=t.readUint16();this.group_description_index=[];for(let i=0;i<e;i++)this.group_description_index[i]=t.readUint32()}},ar.fourcc="stsg",ar),or,Kl=(or=class extends d{constructor(){super(...arguments),this.box_name="ShadowSyncSampleBox"}parse(t){this.parseFullHeader(t);const e=t.readUint32();if(this.shadowed_sample_numbers=[],this.sync_sample_numbers=[],this.version===0)for(let i=0;i<e;i++)this.shadowed_sample_numbers.push(t.readUint32()),this.sync_sample_numbers.push(t.readUint32())}write(t){this.version=0,this.flags=0,this.size=4+8*this.shadowed_sample_numbers.length,this.writeHeader(t),t.writeUint32(this.shadowed_sample_numbers.length);for(let e=0;e<this.shadowed_sample_numbers.length;e++)t.writeUint32(this.shadowed_sample_numbers[e]),t.writeUint32(this.sync_sample_numbers[e])}},or.fourcc="stsh",or),hr,Xl=(hr=class extends d{constructor(){super(...arguments),this.box_name="SyncSampleBox"}parse(t){this.parseFullHeader(t);const e=t.readUint32();if(this.version===0){this.sample_numbers=[];for(let i=0;i<e;i++)this.sample_numbers.push(t.readUint32())}}write(t){this.version=0,this.flags=0,this.size=4+4*this.sample_numbers.length,this.writeHeader(t),t.writeUint32(this.sample_numbers.length),t.writeUint32Array(this.sample_numbers)}},hr.fourcc="stss",hr),cr,Ql=(cr=class extends d{constructor(){super(...arguments),this.box_name="StereoVideoBox"}parse(t){this.parseFullHeader(t);const e=t.readUint32();this.single_view_allowed=e&3,this.stereo_scheme=t.readUint32();const i=t.readUint32();for(this.stereo_indication_type=t.readString(i),this.boxes=[];t.getPosition()<this.start+this.size;){const s=H(t,!1,this.size-(t.getPosition()-this.start));if(s.code===F){const n=s.box;this.boxes.push(n),this[n.type]=n}else return}}},cr.fourcc="stvi",cr),lr,Jl=(lr=class extends p{constructor(){super(...arguments),this.box_name="SegmentTypeBox"}parse(t){let e=this.size-this.hdr_size;this.major_brand=t.readString(4),this.minor_version=t.readUint32(),e-=8,this.compatible_brands=[];let i=0;for(;e>=4;)this.compatible_brands[i]=t.readString(4),e-=4,i++}write(t){this.size=8+4*this.compatible_brands.length,this.writeHeader(t),t.writeString(this.major_brand,void 0,4),t.writeUint32(this.minor_version);for(let e=0;e<this.compatible_brands.length;e++)t.writeString(this.compatible_brands[e],void 0,4)}},lr.fourcc="styp",lr),dr,Zl=(dr=class extends d{constructor(){super(...arguments),this.box_name="CompactSampleSizeBox"}parse(t){if(this.parseFullHeader(t),this.sample_sizes=[],this.version===0){this.reserved=t.readUint24(),this.field_size=t.readUint8();const e=t.readUint32();if(this.field_size===4)for(let i=0;i<e;i+=2){const s=t.readUint8();this.sample_sizes[i]=s>>4&15,this.sample_sizes[i+1]=s&15}else if(this.field_size===8)for(let i=0;i<e;i++)this.sample_sizes[i]=t.readUint8();else if(this.field_size===16)for(let i=0;i<e;i++)this.sample_sizes[i]=t.readUint16();else l.error("BoxParser","Error in length field in stz2 box",t.isofile)}}},dr.fourcc="stz2",dr),fr,td=(fr=class extends d{constructor(){super(...arguments),this.box_name="SubSampleInformationBox"}parse(t){this.parseFullHeader(t);const e=t.readUint32();this.entries=[];let i;for(let s=0;s<e;s++){const n={};if(this.entries[s]=n,n.sample_delta=t.readUint32(),n.subsamples=[],i=t.readUint16(),i>0)for(let a=0;a<i;a++){const o={};n.subsamples.push(o),this.version===1?o.size=t.readUint32():o.size=t.readUint16(),o.priority=t.readUint8(),o.discardable=t.readUint8(),o.codec_specific_parameters=t.readUint32()}}}},fr.fourcc="subs",fr),ur,ed=(ur=class extends d{constructor(){super(...arguments),this.box_name="TAIClockInfoBox"}parse(t){this.time_uncertainty=t.readUint64(),this.clock_resolution=t.readUint32(),this.clock_drift_rate=t.readInt32();const e=t.readUint8();this.clock_type=(e&192)>>6}},ur.fourcc="taic",ur),pr,id=(pr=class extends d{constructor(){super(...arguments),this.box_name="TrackEncryptionBox"}parse(t){if(this.parseFullHeader(t),t.readUint8(),this.version===0)t.readUint8();else{const e=t.readUint8();this.default_crypt_byte_block=e>>4&15,this.default_skip_byte_block=e&15}this.default_isProtected=t.readUint8(),this.default_Per_Sample_IV_Size=t.readUint8(),this.default_KID=K(t),this.default_isProtected===1&&this.default_Per_Sample_IV_Size===0&&(this.default_constant_IV_size=t.readUint8(),this.default_constant_IV=t.readUint8Array(this.default_constant_IV_size))}},pr.fourcc="tenc",pr),_r,sd=(_r=class extends d{constructor(){super(...arguments),this.box_name="TrackFragmentRandomAccessBox"}parse(t){this.parseFullHeader(t),this.track_ID=t.readUint32(),t.readUint24();const e=t.readUint8();this.length_size_of_traf_num=e>>4&3,this.length_size_of_trun_num=e>>2&3,this.length_size_of_sample_num=e&3,this.entries=[];const i=t.readUint32();for(let s=0;s<i;s++)this.version===1?(this.time=t.readUint64(),this.moof_offset=t.readUint64()):(this.time=t.readUint32(),this.moof_offset=t.readUint32()),this.traf_number=t["readUint"+8*(this.length_size_of_traf_num+1)](),this.trun_number=t["readUint"+8*(this.length_size_of_trun_num+1)](),this.sample_number=t["readUint"+8*(this.length_size_of_sample_num+1)]()}},_r.fourcc="tfra",_r),mr,rd=(mr=class extends p{constructor(){super(...arguments),this.box_name="hintmaxrelativetime"}parse(t){this.time=t.readUint32()}},mr.fourcc="tmax",mr),gr,nd=(gr=class extends p{constructor(){super(...arguments),this.box_name="hintminrelativetime"}parse(t){this.time=t.readUint32()}},gr.fourcc="tmin",gr),xr,ad=(xr=class extends p{constructor(){super(...arguments),this.box_name="hintBytesSent"}parse(t){this.bytessent=t.readUint32()}},xr.fourcc="totl",xr),yr,od=(yr=class extends p{constructor(){super(...arguments),this.box_name="hintBytesSent"}parse(t){this.bytessent=t.readUint32()}},yr.fourcc="tpay",yr),br,hd=(br=class extends p{constructor(){super(...arguments),this.box_name="hintBytesSent"}parse(t){this.bytessent=t.readUint64()}},br.fourcc="tpyl",br),vr,cd=(vr=class extends to{},vr.fourcc="msrc",vr),Y,ld=(Y=class extends p{constructor(){super(...arguments),this.box_name="TrackReferenceBox",this.references=[]}parse(t){for(;t.getPosition()<this.start+this.size;){const e=H(t,!0,this.size-(t.getPosition()-this.start));if(e.code===F){Y.allowed_types.includes(e.type)||l.warn("BoxParser",`Unknown track reference type: '${e.type}'`);const i=new so(e.type,e.size,e.hdr_size,e.start);i.write===p.prototype.write&&i.type!=="mdat"&&(l.info("BoxParser","TrackReference "+i.type+" box writing not yet implemented, keeping unparsed data in memory for later write"),i.parseDataAndRewind(t)),i.parse(t),this.references.push(i)}else return}}},Y.fourcc="tref",Y.allowed_types=["hint","cdsc","font","hind","vdep","vplx","subt","thmb","auxl","cdtg","shsc","aest"],Y),Ur,dd=(Ur=class extends d{constructor(){super(...arguments),this.box_name="TrackExtensionPropertiesBox"}parse(t){for(this.parseFullHeader(t),this.track_ID=t.readUint32(),this.boxes=[];t.getPosition()<this.start+this.size;){const e=H(t,!1,this.size-(t.getPosition()-this.start));if(e.code===F){const i=e.box;this.boxes.push(i)}else return}}},Ur.fourcc="trep",Ur),Sr,fd=(Sr=class extends p{constructor(){super(...arguments),this.box_name="hintBytesSent"}parse(t){this.bytessent=t.readUint64()}},Sr.fourcc="trpy",Sr),Br,ud=(Br=class extends d{constructor(){super(...arguments),this.box_name="TrackSelectionBox"}parse(t){this.parseFullHeader(t),this.switch_group=t.readUint32();const e=(this.size-this.hdr_size-4)/4;this.attribute_list=[];for(let i=0;i<e;i++)this.attribute_list[i]=t.readUint32()}},Br.fourcc="tsel",Br),wr,pd=(wr=class extends d{constructor(){super(...arguments),this.box_name="TextConfigBox"}parse(t){this.parseFullHeader(t),this.config=t.readCString()}},wr.fourcc="txtc",wr),zr,_d=(zr=class extends p{constructor(){super(...arguments),this.box_name="TypeCombinationBox"}parse(t){const e=(this.size-this.hdr_size)/4;this.compatible_brands=[];for(let i=0;i<e;i++)this.compatible_brands[i]=t.readString(4)}},zr.fourcc="tyco",zr),Er,md=(Er=class extends d{constructor(){super(...arguments),this.box_name="UserDescriptionProperty"}parse(t){this.parseFullHeader(t),this.lang=t.readCString(),this.name=t.readCString(),this.description=t.readCString(),this.tags=t.readCString()}},Er.fourcc="udes",Er),kr,gd=(kr=class extends d{constructor(){super(...arguments),this.box_name="UncompressedFrameConfigBox"}parse(t){if(this.parseFullHeader(t),this.profile=t.readString(4),this.version!==1){if(this.version===0){this.component_count=t.readUint32(),this.component_index=[],this.component_bit_depth_minus_one=[],this.component_format=[],this.component_align_size=[];for(let i=0;i<this.component_count;i++)this.component_index.push(t.readUint16()),this.component_bit_depth_minus_one.push(t.readUint8()),this.component_format.push(t.readUint8()),this.component_align_size.push(t.readUint8());this.sampling_type=t.readUint8(),this.interleave_type=t.readUint8(),this.block_size=t.readUint8();const e=t.readUint8();this.component_little_endian=e>>7&1,this.block_pad_lsb=e>>6&1,this.block_little_endian=e>>5&1,this.block_reversed=e>>4&1,this.pad_unknown=e>>3&1,this.pixel_size=t.readUint32(),this.row_align_size=t.readUint32(),this.tile_align_size=t.readUint32(),this.num_tile_cols_minus_one=t.readUint32(),this.num_tile_rows_minus_one=t.readUint32()}}}},kr.fourcc="uncC",kr),Ir,xd=(Ir=class extends d{constructor(){super(...arguments),this.box_name="DataEntryUrnBox"}parse(t){this.parseFullHeader(t),this.name=t.readCString(),this.size-this.hdr_size-this.name.length-1>0&&(this.location=t.readCString())}write(t){this.version=0,this.flags=0,this.size=this.name.length+1+(this.location?this.location.length+1:0),this.writeHeader(t),t.writeCString(this.name),this.location&&t.writeCString(this.location)}},Ir.fourcc="urn ",Ir),Tr,yd=(Tr=class extends p{constructor(){super(...arguments),this.box_name="WebVTTConfigurationBox"}parse(t){this.text=t.readString(this.size-this.hdr_size)}},Tr.fourcc="vttC",Tr),Ar,bd=(Ar=class extends d{constructor(){super(...arguments),this.box_name="VvcNALUConfigBox"}parse(t){this.parseFullHeader(t);const e=t.readUint8();this.lengthSizeMinusOne=e&3}},Ar.fourcc="vvnC",Ar),Pr,vd=(Pr=class extends B{parse(t){const e=t.readUint16();this.first_output_sample=t.readUint16(),this.sample_offset=[];for(let s=0;s<e;s++)this.sample_offset[s]=t.readUint32();const i=this.description_length-4-4*e;this.num_output_samples=[],this.num_total_samples=[];for(let s=0;s<i/4;s++)this.num_output_samples[s]=t.readUint16(),this.num_total_samples[s]=t.readUint16()}},Pr.grouping_type="alst",Pr),Cr,Ud=(Cr=class extends B{parse(t){this.layerNumber=t.readUint8(),this.accurateStatisticsFlag=t.readUint8(),this.avgBitRate=t.readUint16(),this.avgFrameRate=t.readUint16()}},Cr.grouping_type="avll",Cr),Fr,Sd=(Fr=class extends B{parse(t){this.subSequenceIdentifier=t.readUint16(),this.layerNumber=t.readUint8();const e=t.readUint8();this.durationFlag=e>>7,this.avgRateFlag=e>>6&1,this.durationFlag&&(this.duration=t.readUint32()),this.avgRateFlag&&(this.accurateStatisticsFlag=t.readUint8(),this.avgBitRate=t.readUint16(),this.avgFrameRate=t.readUint16()),this.dependency=[];const i=t.readUint8();for(let s=0;s<i;s++)this.dependency.push({subSeqDirectionFlag:t.readUint8(),layerNumber:t.readUint8(),subSequenceIdentifier:t.readUint16()})}},Fr.grouping_type="avss",Fr),Dr,Bd=(Dr=class extends B{parse(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},Dr.grouping_type="dtrt",Dr),Lr,wd=(Lr=class extends B{parse(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},Lr.grouping_type="mvif",Lr),Hr,zd=(Hr=class extends B{parse(t){this.roll_distance=t.readInt16()}},Hr.grouping_type="prol",Hr),Or,Ed=(Or=class extends B{parse(t){const e=t.readUint8();this.num_leading_samples_known=e>>7,this.num_leading_samples=e&127}},Or.grouping_type="rap ",Or),Mr,kd=(Mr=class extends B{parse(t){if(this.operation_point_count=t.readUint16(),this.description_length!==2+(this.operation_point_count===1?2:this.operation_point_count*6)+9)l.warn("BoxParser","Mismatch in "+this.grouping_type+" sample group length"),this.data=t.readUint8Array(this.description_length-2);else{if(this.operation_point_count===1)this.target_rate_share=t.readUint16();else{this.target_rate_share=[],this.available_bitrate=[];for(let e=0;e<this.operation_point_count;e++)this.available_bitrate[e]=t.readUint32(),this.target_rate_share[e]=t.readUint16()}this.maximum_bitrate=t.readUint32(),this.minimum_bitrate=t.readUint32(),this.discard_priority=t.readUint8()}}},Mr.grouping_type="rash",Mr),Rr,Id=(Rr=class extends B{parse(t){this.roll_distance=t.readInt16()}},Rr.grouping_type="roll",Rr),Nr,Td=(Nr=class extends B{parse(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},Nr.grouping_type="scif",Nr),Gr,Ad=(Gr=class extends B{parse(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},Gr.grouping_type="scnm",Gr),Vr,Pd=(Vr=class extends B{parse(t){this.reserved=t.readUint8();const e=t.readUint8();this.crypt_byte_block=e>>4,this.skip_byte_block=e&15,this.isProtected=t.readUint8(),this.Per_Sample_IV_Size=t.readUint8(),this.KID=K(t),this.constant_IV_size=0,this.constant_IV=0,this.isProtected===1&&this.Per_Sample_IV_Size===0&&(this.constant_IV_size=t.readUint8(),this.constant_IV=t.readUint8Array(this.constant_IV_size))}},Vr.grouping_type="seig",Vr),jr,Cd=(jr=class extends B{parse(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},jr.grouping_type="stsa",jr),$r,Fd=($r=class extends B{parse(t){const e=t.readUint8();this.NAL_unit_type=e&63}},$r.grouping_type="sync",$r),qr,Dd=(qr=class extends B{parse(t){const e=t.readUint8();this.level_independently_decodable=e>>7}},qr.grouping_type="tele",qr),Yr,Ld=(Yr=class extends B{parse(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},Yr.grouping_type="tsas",Yr),Wr,Hd=(Wr=class extends B{parse(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},Wr.grouping_type="tscl",Wr),Kr,Od=(Kr=class extends B{parse(t){l.warn("BoxParser","Sample Group type: "+this.grouping_type+" not fully parsed")}},Kr.grouping_type="vipr",Kr),Xr,Md=(Xr=class extends p{},Xr.fourcc="uuid",Xr),Qr,on=(Qr=class extends d{},Qr.fourcc="uuid",Qr),Jr,Rd=(Jr=class extends on{constructor(){super(...arguments),this.box_name="LiveServerManifestBox"}parse(t){this.parseFullHeader(t),this.LiveServerManifest=t.readString(this.size-this.hdr_size).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}},Jr.uuid="a5d40b30e81411ddba2f0800200c9a66",Jr),Zr,Nd=(Zr=class extends on{constructor(){super(...arguments),this.box_name="PiffProtectionSystemSpecificHeaderBox"}parse(t){this.parseFullHeader(t),this.system_id=K(t);const e=t.readUint32();e>0&&(this.data=t.readUint8Array(e))}},Zr.uuid="d08a4f1810f34a82b6c832d8aba183d3",Zr),tn,Gd=(tn=class extends on{constructor(){super(...arguments),this.box_name="PiffSampleEncryptionBox"}},tn.uuid="a2394f525a9b4f14a2446c427c648df4",tn),en,Vd=(en=class extends on{constructor(){super(...arguments),this.box_name="PiffTrackEncryptionBox"}parse(t){this.parseFullHeader(t),this.default_AlgorithmID=t.readUint24(),this.default_IV_size=t.readUint8(),this.default_KID=K(t)}},en.uuid="8974dbce7be74c5184f97148f9882554",en),sn,jd=(sn=class extends on{constructor(){super(...arguments),this.box_name="TfrfBox"}parse(t){this.parseFullHeader(t),this.fragment_count=t.readUint8(),this.entries=[];for(let e=0;e<this.fragment_count;e++){let i=0,s=0;this.version===1?(i=t.readUint64(),s=t.readUint64()):(i=t.readUint32(),s=t.readUint32()),this.entries.push({absolute_time:i,absolute_duration:s})}}},sn.uuid="d4807ef2ca3946958e5426cb9e46a79f",sn),rn,$d=(rn=class extends on{constructor(){super(...arguments),this.box_name="TfxdBox"}parse(t){this.parseFullHeader(t),this.version===1?(this.absolute_time=t.readUint64(),this.duration=t.readUint64()):(this.absolute_time=t.readUint32(),this.duration=t.readUint32())}},rn.uuid="6d1d9b0542d544e680e2141daff757b2",rn),nn,qd=(nn=class extends Md{constructor(){super(...arguments),this.box_name="ItemContentIDProperty"}parse(t){this.content_id=t.readCString()}},nn.uuid="261ef3741d975bbaacbd9d2c8ea73522",nn),Zd=co(Ya);lo(Ga);export{D as AudioSampleEntry,p as Box,Zd as BoxParser,Nn as DIFF_BOXES_PROP_NAMES,ro as DIFF_PRIMITIVE_ARRAY_PROP_NAMES,z as DataStream,Q as Descriptor,qa as ES_Descriptor,Ja as Endianness,d as FullBox,ia as HintSampleEntry,tc as ISOFile,l as Log,N as MP4BoxBuffer,nc as MPEG4DescriptorParser,an as MetadataSampleEntry,_n as MultiBufferStream,G as SampleEntry,B as SampleGroupEntry,Mn as SampleGroupInfo,eo as SingleItemTypeReferenceBox,io as SingleItemTypeReferenceBoxLarge,X as SubtitleSampleEntry,qn as SystemSampleEntry,Jd as TX3GParser,uo as TextSampleEntry,Qd as Textin4Parser,to as TrackGroupTypeBox,so as TrackReferenceTypeBox,Kd as VTTin4Parser,U as VisualSampleEntry,Xd as XMLSubtitlein4Parser,oa as boxEqual,no as boxEqualFields,Wd as createFile};
@@ -1,46 +0,0 @@
1
- figpack/__init__.py,sha256=2Qddvz5O2DF036bSSTl5UUpe_DzNU52ixrJE9IYHOX0,358
2
- figpack/cli.py,sha256=s1mGQuFSntxiIvU6OWwHVlM9Cj-l1zMQ3OzFFe1-5ZE,11089
3
- figpack/extensions.py,sha256=mILB4_F1RHkca4I7t88zh74IX8VCmfT7XFZZT4XYdNw,13009
4
- figpack/core/__init__.py,sha256=7zU6O1piTk07aeCfbU81QqTgSHIO2n5MZ4LFNmsrtfs,192
5
- figpack/core/_bundle_utils.py,sha256=xJafDtH9M575usys8t2S8qOJT1a1xLcI6-m2oD18rFU,9064
6
- figpack/core/_file_handler.py,sha256=TC4Z23Xy4dKky8BEwyp3Gj4K9-gpnKRiF1u6KkxWprc,6984
7
- figpack/core/_save_figure.py,sha256=52ny-m1ThGgxY4ZgMn7m33n8A2OCyezj8H8TMvw0Y8Q,1043
8
- figpack/core/_server_manager.py,sha256=I8PQImUa4C0L6LfIiCnpRnfQT7B-XVseCs80qnUvIlI,12374
9
- figpack/core/_show_view.py,sha256=noADkomP1ovH-Jb7Bj0unmkPXvS_uOkkCILJSWag1RI,5171
10
- figpack/core/_upload_bundle.py,sha256=54hdWayJJdRZdx7N9V2aH_X33KkR6hImMjN6tkBTLi8,14894
11
- figpack/core/_view_figure.py,sha256=GYTgSCWBxi1pR16aBgAYRcEuFcgj0vjsrLIVfy1HYzM,5374
12
- figpack/core/config.py,sha256=oOR7SlP192vuFhYlS-h14HnG-kd_3gaz0vshXch2RNc,173
13
- figpack/core/extension_view.py,sha256=MUj66ccjQJGyOyHzyYNwMd84isN2DfEoZ3X-TSzemAs,1257
14
- figpack/core/figpack_extension.py,sha256=KSJKlnLYueFnGa8QFMpbIF3CDMwnIZJOqsI0smz6cUc,2252
15
- figpack/core/figpack_view.py,sha256=L--pBg-PjEiAE2Ry4u-1eZsRVu4j4-p-NKwtJSVnGj0,6304
16
- figpack/core/zarr.py,sha256=LTWOIX6vuH25STYTQS9_apfnfYXmATAEQkil3z9eYKE,1634
17
- figpack/figpack-figure-dist/index.html,sha256=3pejmescRSEERdWXVUYwe2BRPyn2LzM-_ttgdtvg2SI,688
18
- figpack/figpack-figure-dist/assets/index-CpEyLZdu.js,sha256=JMMOZi6Nq_-8T5hsg50Rg1cwEQrmU7VZWiCY4qNAEI0,1105709
19
- figpack/figpack-figure-dist/assets/index-V5m_wCvw.css,sha256=WRtQLW6SNlTlLtepSOt89t1z41SD7XzYUyRldqowjMM,7286
20
- figpack/figpack-figure-dist/assets/mp4box.all-o28ogbiz.js,sha256=tOV6Q86MR90pMUIzADBdH2u6M3yZDXR_WipmNUm7aPA,182154
21
- figpack/figpack-figure-dist/assets/neurosift-logo-CLsuwLMO.png,sha256=g5m-TwrGh5f6-9rXtWV-znH4B0nHgc__0GWclRDLUHs,9307
22
- figpack/views/Box.py,sha256=dH4Vxax4NPJExZSx8jAG6feMgkNU5mOPEf-lLOd41-4,2421
23
- figpack/views/DataFrame.py,sha256=FAqrEddh3v0MNXlXA1DQzN34d9gacDXHUdiahIKlgOI,3401
24
- figpack/views/Gallery.py,sha256=D6drCKfnPN6MNn3wjQV0i5FW2s3q9xP-X75q-PR4Sc8,3326
25
- figpack/views/GalleryItem.py,sha256=b_upJno5P3ANSulbG-h3t6Xj56tPGJ7iVxqyiZu3zaQ,1244
26
- figpack/views/Image.py,sha256=8eNWzednvpsz0EcaoK3GdWGBfCybT2pXnBhMlZMr4yA,3742
27
- figpack/views/LayoutItem.py,sha256=wy8DggkIzZpU0F1zFIBceS7HpBb6lu-A3hpYINQzedk,1595
28
- figpack/views/Markdown.py,sha256=8kScwS1XaiQt5KRcbWG1B4RNUbA_FG5fIUJcv6csB8g,1134
29
- figpack/views/MatplotlibFigure.py,sha256=v4rc8sT9FcuHPrwljq9s-BUT5vlJiRDAf5tBP4YujAE,2423
30
- figpack/views/MultiChannelTimeseries.py,sha256=loZ1zGyIC_VJbduR7EIBbFHFPEr8DRQw-QNQSFVSdHQ,8292
31
- figpack/views/Spectrogram.py,sha256=9aJpzlOsOo7ReddR-i6riN2MG2RdveRS7m6MI2cCYjM,9336
32
- figpack/views/Splitter.py,sha256=q29pBu4RJgr0o_m1Jliv5FrGGCm5_jhowMg8Xgh70gk,2019
33
- figpack/views/TabLayout.py,sha256=bKLjeI_CnllThB6t7AwlP-Oh5mKbWt8hpubW5Zyj420,1910
34
- figpack/views/TabLayoutItem.py,sha256=xmHA0JsW_6naJze4_mQuP_Fy0Nm17p2N7w_AsmVRp8k,880
35
- figpack/views/TimeseriesGraph.py,sha256=VErwmzRqNFq1i2XEWzAHM6csbHry064did32AbxLMms,17700
36
- figpack/views/__init__.py,sha256=jquSaF1bU_oT9oV-2KfFKiRb_CG-UGXFpFygGswHO2k,547
37
- figpack/views/PlotlyExtension/PlotlyExtension.py,sha256=W8ucSnAaPOHVGvOXRt0DpdgGNLQRmfUUdKzHICuJKJ0,2151
38
- figpack/views/PlotlyExtension/__init__.py,sha256=80Wy1mDMWyagjuR99ECxJePIYpRQ6TSyHkB0uZoBZ_0,70
39
- figpack/views/PlotlyExtension/_plotly_extension.py,sha256=yZjG1NMGlQedeeLdV6TQWpi_NTm5Wfk5eWbXEdZbbFE,1455
40
- figpack/views/PlotlyExtension/plotly_view.js,sha256=9BjgOPkqGl87SSonnb48nFeQV3UTIi1trpSPxd9qlKo,3055
41
- figpack-0.2.21.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
42
- figpack-0.2.21.dist-info/METADATA,sha256=g-mkNOOuAE7RoB2qAaTcy3k66hhXAkvPvHJDHPcK9WI,4539
43
- figpack-0.2.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
44
- figpack-0.2.21.dist-info/entry_points.txt,sha256=l6d3siH2LxXa8qJGbjAqpIZtI5AkMSyDeoRDCzdrUto,45
45
- figpack-0.2.21.dist-info/top_level.txt,sha256=lMKGaC5xWmAYBx9Ac1iMokm42KFnJFjmkP2ldyvOo-c,8
46
- figpack-0.2.21.dist-info/RECORD,,