"use strict";exports.id=46,exports.ids=[46],exports.modules={46:(e,t,a)=>{a.r(t),a.d(t,{DsdContentParseError:()=>c,DsfParser:()=>u});var s=a(5753),i=a(4481),n=a(1751),r=a(5031);const o={len:12,get:(e,t)=>({id:r.e.get(e,t),size:n.UINT64_LE.get(e,t+4)})},d={len:16,get:(e,t)=>({fileSize:n.INT64_LE.get(e,t),metadataPointer:n.INT64_LE.get(e,t+8)})},h={len:40,get:(e,t)=>({formatVersion:n.INT32_LE.get(e,t),formatID:n.INT32_LE.get(e,t+4),channelType:n.INT32_LE.get(e,t+8),channelNum:n.INT32_LE.get(e,t+12),samplingFrequency:n.INT32_LE.get(e,t+16),bitsPerSample:n.INT32_LE.get(e,t+20),sampleCount:n.INT64_LE.get(e,t+24),blockSizePerChannel:n.INT32_LE.get(e,t+32)})};var m=a(8621),p=a(3324);const l=s("music-metadata:parser:DSF");class c extends((0,p.fO)("DSD")){}class u extends i.k{async postId3v2Parse(){const e=this.tokenizer.position,t=await this.tokenizer.readToken(o);if("DSD "!==t.id)throw new c("Invalid chunk signature");this.metadata.setFormat("container","DSF"),this.metadata.setFormat("lossless",!0),this.metadata.setAudioOnly();const a=await this.tokenizer.readToken(d);if(a.metadataPointer!==BigInt(0))return l(`expect ID3v2 at offset=${a.metadataPointer}`),await this.parseChunks(a.fileSize-t.size),await this.tokenizer.ignore(Number(a.metadataPointer)-this.tokenizer.position-e),(new m.S).parse(this.metadata,this.tokenizer,this.options);l("No ID3v2 tag present")}async parseChunks(e){for(;e>=o.len;){const t=await this.tokenizer.readToken(o);if(l(`Parsing chunk name=${t.id} size=${t.size}`),"fmt "===t.id){const e=await this.tokenizer.readToken(h);this.metadata.setFormat("numberOfChannels",e.channelNum),this.metadata.setFormat("sampleRate",e.samplingFrequency),this.metadata.setFormat("bitsPerSample",e.bitsPerSample),this.metadata.setFormat("numberOfSamples",e.sampleCount),this.metadata.setFormat("duration",Number(e.sampleCount)/e.samplingFrequency);const t=e.bitsPerSample*e.samplingFrequency*e.channelNum;return void this.metadata.setFormat("bitrate",t)}this.tokenizer.ignore(Number(t.size)-o.len),e-=t.size}}}},4481:(e,t,a)=>{a.d(t,{k:()=>m});var s=a(8989),i=a(5753),n=a(7675),r=a(8621),o=a(8191),d=a(4604);const h=i("music-metadata:parser:ID3");class m extends d.s{constructor(){super(...arguments),this.id3parser=new r.S}static async startsWithID3v2Header(e){return"ID3"===(await e.peekToken(n.yW)).fileIdentifier}async parse(){try{await this.parseID3v2()}catch(e){if(!(e instanceof s.d1))throw e;h("End-of-stream")}}finalize(){}async parseID3v2(){if(await this.tryReadId3v2Headers(),h("End of ID3v2 header, go to MPEG-parser: pos=%s",this.tokenizer.position),await this.postId3v2Parse(),this.options.skipPostHeaders&&this.metadata.hasAny())this.finalize();else{const e=new o.Bn(this.metadata,this.tokenizer,this.options);await e.parse(),this.finalize()}}async tryReadId3v2Headers(){if("ID3"===(await this.tokenizer.peekToken(n.yW)).fileIdentifier)return h("Found ID3v2 header, pos=%s",this.tokenizer.position),await this.id3parser.parse(this.metadata,this.tokenizer,this.options),this.tryReadId3v2Headers()}}}};
//# sourceMappingURL=46.js.map