export const MIN_BOX_HEADER_SIZE=8,MAX_BOX_HEADER_SIZE=16;export class IsobmffReader{constructor(e){this.reader=e,this.pos=0}readBytes(e){const{view:t,offset:s}=this.reader.getViewAndOffset(this.pos,this.pos+e);return this.pos+=e,new Uint8Array(t.buffer,s,e)}readU8(){const{view:e,offset:t}=this.reader.getViewAndOffset(this.pos,this.pos+1);return this.pos++,e.getUint8(t)}readU16(){const{view:e,offset:t}=this.reader.getViewAndOffset(this.pos,this.pos+2);return this.pos+=2,e.getUint16(t,!1)}readI16(){const{view:e,offset:t}=this.reader.getViewAndOffset(this.pos,this.pos+2);return this.pos+=2,e.getInt16(t,!1)}readU24(){const{view:e,offset:t}=this.reader.getViewAndOffset(this.pos,this.pos+3);this.pos+=3;const s=e.getUint16(t,!1),r=e.getUint8(t+2);return s*256+r}readU32(){const{view:e,offset:t}=this.reader.getViewAndOffset(this.pos,this.pos+4);return this.pos+=4,e.getUint32(t,!1)}readI32(){const{view:e,offset:t}=this.reader.getViewAndOffset(this.pos,this.pos+4);return this.pos+=4,e.getInt32(t,!1)}readU64(){const e=this.readU32(),t=this.readU32();return e*4294967296+t}readI64(){const e=this.readI32(),t=this.readU32();return e*4294967296+t}readF64(){const{view:e,offset:t}=this.reader.getViewAndOffset(this.pos,this.pos+8);return this.pos+=8,e.getFloat64(t,!1)}readFixed_16_16(){return this.readI32()/65536}readFixed_2_30(){return this.readI32()/1073741824}readAscii(e){const{view:t,offset:s}=this.reader.getViewAndOffset(this.pos,this.pos+e);this.pos+=e;let r="";for(let i=0;i<e;i++)r+=String.fromCharCode(t.getUint8(s+i));return r}readIsomVariableInteger(){let e=0;for(let t=0;t<4;t++){e<<=7;const s=this.readU8();if(e|=s&127,(s&128)===0)break}return e}readBoxHeader(){let e=this.readU32();const t=this.readAscii(4);let s=8;return e===1&&(e=this.readU64(),s=16),{name:t,totalSize:e,headerSize:s,contentSize:e-s}}}
