@libmedia/avplayer 0.8.0 → 0.8.2

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.
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[433],{70509:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(134);class a{constructor(){(0,s.A)(this,"onFlush",void 0)}}},97801:(t,e,i)=>{i.d(e,{A:()=>T});var s=i(134),a=i(70509),r=i(13258),n=i(51678),o=i(13724),h=i(4624);const l="src/avnetwork/bsp/aes/AESDecryptPipe.ts",c=16;let d=!0;const u=new Uint8Array(c).fill(c);class T extends a.A{constructor(t=1048576){super(),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"aesSoftDecryptor",void 0),(0,s.A)(this,"aesWebDecryptor",void 0),(0,s.A)(this,"aesTargetDecryptor",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"endPointer",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"ended",void 0),(0,s.A)(this,"iv",void 0),(0,s.A)(this,"key",void 0),this.size=t,this.pointer=0,this.endPointer=0,this.ended=!1,this.buffer=new Uint8Array(t),this.aesSoftDecryptor=new r.A,n.A.isSupport()&&d&&(this.aesWebDecryptor=new n.A),this.aesTargetDecryptor=this.aesWebDecryptor||this.aesSoftDecryptor}remainingLength(){return this.endPointer-this.pointer}async expandKey(t,e){this.key=t,this.iv=e,this.aesWebDecryptor&&await this.aesWebDecryptor.expandKey(t),this.aesSoftDecryptor.expandKey(t)}async flush_(t){for(;;){const e=await this.onFlush(t);if(-1048575!==e)return e;await new o.A(0)}}async flush(){if(this.size-this.remainingLength()<=0)return;this.pointer<this.endPointer?this.pointer&&(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer):this.endPointer=0,this.pointer=0;const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0){if(-1048576===t)return void(this.ended=!0);h.h2(`AESPipe error, flush failed, ret: ${t}`,l,120)}this.endPointer+=t}removePadding(t){const e=t.length,i=e&&new DataView(t.buffer).getUint8(e-1);return i?t.subarray(0,e-i):t}async decrypt(t){let e,i=0;this.aesTargetDecryptor!==this.aesWebDecryptor||this.ended||(e=this.buffer.subarray(this.pointer+t,this.pointer+t+c).slice(),this.buffer.set((await this.aesWebDecryptor.encryptPadding(u,this.buffer.subarray(this.pointer+t-c,this.pointer+t))).subarray(0,c),this.pointer+t),i=c);try{const s=this.buffer.subarray(this.pointer,this.pointer+t+i),a=await this.aesTargetDecryptor.decrypt(s,this.iv);return this.iv=s.slice(s.length-c-i,s.length-i).buffer,e&&this.buffer.set(e,this.pointer+t),this.pointer+=t,new Uint8Array(a)}catch(i){if(this.aesTargetDecryptor=this.aesWebDecryptor)return h.R8("web aes decrypt failed, try to use soft decryptor",l,169),e&&this.buffer.set(e,this.pointer+t),this.aesTargetDecryptor=this.aesSoftDecryptor,d=!1,this.decrypt(t);h.h2("aes decrypt failed",l,179)}}async read(t){for(;!this.ended&&this.remainingLength()<48;)await this.flush();if(0===this.remainingLength())return-1048576;const e=Math.min(Math.floor((this.remainingLength()-(this.ended?0:32))/c)*c,t.length);let i=await this.decrypt(e);return this.ended&&this.aesTargetDecryptor===this.aesSoftDecryptor&&(i=this.removePadding(i)),t.set(i),i.length}}},15433:(t,e,i)=>{i.r(e),i.d(e,{default:()=>p});var s=i(134),a=i(80662),r=i.n(a),n=i(13724),o=i(82800),h=i(95335),l=i(8507),c=i(48182),d=i(77580),u=i(86932),T=i(4624),E=i(97801),f=i(67672);const A="src/avnetwork/ioLoader/HlsIOLoader.ts";class p extends o.A{constructor(...t){super(...t),(0,s.A)(this,"info",void 0),(0,s.A)(this,"range",void 0),(0,s.A)(this,"masterPlaylist",void 0),(0,s.A)(this,"mediaPlayList",void 0),(0,s.A)(this,"mediaPlayListIndex",void 0),(0,s.A)(this,"fetchedMap",void 0),(0,s.A)(this,"fetchedHistoryList",void 0),(0,s.A)(this,"mediaListUrl",void 0),(0,s.A)(this,"segmentIndex",void 0),(0,s.A)(this,"currentUri",void 0),(0,s.A)(this,"loader",void 0),(0,s.A)(this,"minBuffer",void 0),(0,s.A)(this,"keyMap",void 0),(0,s.A)(this,"currentIV",void 0),(0,s.A)(this,"currentKey",void 0),(0,s.A)(this,"aesDecryptPipe",void 0),(0,s.A)(this,"initLoaded",void 0)}getFetchParams(t="GET"){var e,i,s;const a={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};return null!==(e=this.info.httpOptions)&&void 0!==e&&e.headers&&h.__(this.info.httpOptions.headers,((t,e)=>{a.headers[e]=t})),null!==(i=this.info.httpOptions)&&void 0!==i&&i.credentials&&(a.credentials=this.info.httpOptions.credentials),null!==(s=this.info.httpOptions)&&void 0!==s&&s.referrerPolicy&&(a.referrerPolicy=this.info.httpOptions.referrerPolicy),a}async fetchMasterPlayList(){try{const e=await fetch(this.info.url,this.getFetchParams()),i=await e.text(),s=(0,c.A)(i);if(s.isMasterPlaylist)this.masterPlaylist=s;else{if(this.mediaPlayList=s,this.options.isLive&&(!this.mediaPlayList.segments||this.mediaPlayList.segments.length<2)){var t;let e=5;return null!==(t=this.mediaPlayList.segments)&&void 0!==t&&t.length&&(e=this.mediaPlayList.segments[0].duration*(2-this.mediaPlayList.segments.length)),T.R8(`wait for min buffer time, now segments: ${this.mediaPlayList.segments.length}`,A,119),await new n.A(e),this.fetchMasterPlayList()}this.minBuffer=this.mediaPlayList.duration||0,this.mediaPlayList.endlist&&(this.options.isLive=!1),this.mediaListUrl=this.info.url}return s}catch(t){if(this.retryCount<this.options.retryCount)return this.retryCount++,T.z3(`failed fetch m3u8 file, retry(${this.retryCount}/3)`,A,136),await new n.A(5),this.fetchMasterPlayList();this.status=3,T.h2("HLSLoader: exception, fetch slice error",A,142)}}async fetchMediaPlayList(){let t;if(this.masterPlaylist){const e=this.masterPlaylist.variants[this.mediaPlayListIndex];e||T.h2("no media playlist",A,154),t=e.uri}else t=this.mediaListUrl;/^https?/.test(t)||(t=l.ll(this.info.url,t)),this.mediaListUrl=t;try{const i=await fetch(t,this.getFetchParams()),s=await i.text();if(this.mediaPlayList=(0,c.A)(s),this.options.isLive&&(!this.mediaPlayList.segments||this.mediaPlayList.segments.length<2)){var e;let t=5;return null!==(e=this.mediaPlayList.segments)&&void 0!==e&&e.length&&(t=this.mediaPlayList.segments[0].duration*(2-this.mediaPlayList.segments.length)),T.R8(`wait for min buffer time, now segments: ${this.mediaPlayList.segments.length}`,A,178),await new n.A(t),this.fetchMediaPlayList()}return this.minBuffer=this.mediaPlayList.duration||0,this.mediaPlayList.endlist&&(this.options.isLive=!1),this.status=2,this.retryCount=0,this.mediaPlayList}catch(t){if(this.retryCount<this.options.retryCount)return this.retryCount++,T.z3(`failed fetch m3u8 file, retry(${this.retryCount}/3)`,A,197),await new n.A(this.options.retryInterval),this.fetchMasterPlayList();this.status=3,T.h2("HLSLoader: exception, fetch slice error",A,203)}}async open(t,e){return this.info=t,this.range=e,this.range.to||(this.range.to=-1),this.range.from=Math.max(this.range.from,0),this.mediaPlayListIndex=0,this.segmentIndex=0,this.fetchedMap=new(r()),this.fetchedHistoryList=[],this.status=1,this.retryCount=0,this.keyMap=new(r()),await this.fetchMasterPlayList(),!this.mediaPlayList&&this.masterPlaylist&&await this.fetchMediaPlayList(),this.initLoaded=!0,this.mediaPlayList.segments.length&&this.mediaPlayList.segments[0].map&&(this.initLoaded=!1),0}async checkNeedDecrypt(t,e){if(!t.key)return;const i=t.key.uri;if(this.keyMap.has(i)?this.currentKey=this.keyMap.get(i):(this.currentKey=await(await fetch((0,l.ll)(this.mediaListUrl,i),this.getFetchParams())).arrayBuffer(),this.keyMap.set(i,this.currentKey)),t.key.iv)this.currentIV=t.key.iv.buffer;else{const t=new Uint8Array(16);new DataView(t.buffer).setUint32(12,e,!1),this.currentIV=t.buffer}this.aesDecryptPipe=new E.A,this.aesDecryptPipe.onFlush=async t=>this.loader.read(t),await this.aesDecryptPipe.expandKey(this.currentKey,this.currentIV)}async read(t){let e=0;if(this.loader){if(e=this.aesDecryptPipe?await this.aesDecryptPipe.read(t):await this.loader.read(t),-1048576!==e)return e;if(this.initLoaded){if(this.options.isLive)this.fetchedMap.set(this.currentUri,!0),10===this.fetchedHistoryList.length&&this.fetchedMap.delete(this.fetchedHistoryList.shift()),this.fetchedHistoryList.push(this.currentUri),this.segmentIndex++;else if(this.segmentIndex++,this.segmentIndex>=this.mediaPlayList.segments.length)return T.pq("hls segments ended",A,299),this.status=4,-1048576}else this.initLoaded=!0;this.loader=null}if(this.options.isLive){const e=this.mediaPlayList.segments.filter((t=>!this.fetchedMap.get(t.uri)));if(!e.length){if(this.mediaPlayList.endlist)return this.status=4,-1048576;const e=(this.minBuffer-((0,u.A)()-this.mediaPlayList.timestamp)/1e3)/2;return e>0&&await new n.A(e),await this.fetchMediaPlayList(),this.read(t)}this.currentUri=e[0].uri,this.initLoaded&&await this.checkNeedDecrypt(e[0],this.segmentIndex),this.loader=new d.A(h.X$({},this.options,{disableSegment:!0,loop:!1}));const i=(0,l.ll)(this.mediaListUrl,this.initLoaded?this.currentUri:e[0].map.uri),s={from:0,to:-1},a=this.initLoaded?e[0].byterange:e[0].map.byterange;return a&&(s.from=a.offset,s.to=a.offset+a.length),await this.loader.open(h.X$({},this.info,{url:i}),s),this.aesDecryptPipe?this.aesDecryptPipe.read(t):this.loader.read(t)}{this.loader=new d.A(h.X$({},this.options,{disableSegment:!0,loop:!1}));let e=this.mediaPlayList.segments[this.segmentIndex];for(;!e.uri;)e=this.mediaPlayList.segments[++this.segmentIndex];this.initLoaded&&await this.checkNeedDecrypt(e,this.segmentIndex);const i=(0,l.ll)(this.mediaListUrl,this.initLoaded?e.uri:e.map.uri),s={from:0,to:-1},a=this.initLoaded?e.byterange:e.map.byterange;return a&&(s.from=a.offset,s.to=a.offset+a.length),await this.loader.open(h.X$({},this.info,{url:i}),s),this.aesDecryptPipe?this.aesDecryptPipe.read(t):this.loader.read(t)}}async seek(t){this.loader&&(await this.loader.abort(),this.loader=null);let e=0,i=Number(t),s=0;for(let t=0;t<this.mediaPlayList.segments.length;t++)if(f.ai(this.mediaPlayList.segments[t].duration)&&(e+=this.mediaPlayList.segments[t].duration,1e3*e>=i)){s=t;break}return this.segmentIndex=s,4===this.status&&(this.status=2),0}async size(){return BigInt(0)}async abort(){this.loader&&(await this.loader.abort(),this.loader=null)}async stop(){await this.abort(),this.status=0}getDuration(){return this.mediaPlayList.duration}getVideoList(){var t,e;return{list:null!==(t=null===(e=this.masterPlaylist)||void 0===e?void 0:e.variants.map((t=>{var e,i,s,a,r;return{width:null!==(e=null===(i=t.resolution)||void 0===i?void 0:i.width)&&void 0!==e?e:0,height:null!==(s=null===(a=t.resolution)||void 0===a?void 0:a.height)&&void 0!==s?s:0,frameRate:null!==(r=t.frameRate)&&void 0!==r?r:0,codecs:t.codecs}})))&&void 0!==t?t:[],selectedIndex:0}}selectVideo(t){this.mediaPlayListIndex=t,this.fetchMediaPlayList()}getMinBuffer(){return this.minBuffer}}},48182:(t,e,i)=>{i.d(e,{A:()=>L});var s=i(7210),a=i.n(s),r=i(43929),n=i.n(r),o=i(69736),h=i.n(o),l=i(80662),c=i.n(l),d=i(67756),u=i(64608),T=i(4624);const E="src/avprotocol/m3u8/parser.ts";function f(t){return d.Bq(t,'"')}function A(t){const e=d.gI(t,",");return{duration:d.Ro(e[0]),title:decodeURIComponent(escape(e[1]))}}function p(t){const e=d.gI(t,"@");return{length:d.Ro(e[0]),offset:e[1]?d.Ro(e[1]):-1}}function m(t){const e=d.gI(t,"x");return{width:d.Ro(e[0]),height:d.Ro(e[1])}}function y(t){const e="ALLOWED-CPC: Each entry must consit of KEYFORMAT and Content Protection Configuration",i=t.split(",");0===i.length&&T.z3(e,E,102);const s=[];for(const t of i){const[i,a]=d.gI(t,":");i&&a?s.push({format:i,cpcList:a.split("/")}):T.z3(e,E,108)}return s}function g(t){const e=d.m2(t);return 16!==e.length&&T.z3("IV must be a 128-bit unsigned integer",E,119),e}function X(t,e){e.IV&&t.compatibleVersion<2&&(t.compatibleVersion=2),(e.KEYFORMAT||e.KEYFORMATVERSIONS)&&t.compatibleVersion<5&&(t.compatibleVersion=5)}function S(t){const e={};for(const s of d.HG(t)){const[t,a]=d.gI(s,"="),r=f(a);switch(t){case"URI":e[t]=r;break;case"START-DATE":case"END-DATE":e[t]=new Date(r);break;case"IV":e[t]=g(r);break;case"BYTERANGE":e[t]=p(r);break;case"RESOLUTION":e[t]=m(r);break;case"ALLOWED-CPC":e[t]=y(r);break;case"END-ON-NEXT":case"DEFAULT":case"AUTOSELECT":case"FORCED":case"PRECISE":case"CAN-BLOCK-RELOAD":case"INDEPENDENT":case"GAP":e[t]="YES"===r;break;case"DURATION":case"PLANNED-DURATION":case"BANDWIDTH":case"AVERAGE-BANDWIDTH":case"FRAME-RATE":case"TIME-OFFSET":case"CAN-SKIP-UNTIL":case"HOLD-BACK":case"PART-HOLD-BACK":case"PART-TARGET":case"BYTERANGE-START":case"BYTERANGE-LENGTH":case"LAST-MSN":case"LAST-PART":case"SKIPPED-SEGMENTS":case"SCORE":case"PROGRAM-ID":e[t]=d.Ro(r);break;default:t.startsWith("SCTE35-")?e[t]=d.m2(r):t.startsWith("X-")?e[t]=(i=a).startsWith('"')?f(i):i.startsWith("0x")||i.startsWith("0X")?d.m2(i):d.Ro(i):("VIDEO-RANGE"===t&&"SDR"!==r&&"HLG"!==r&&"PQ"!==r&&T.h2(`VIDEO-RANGE: unknown value "${r}"`,E,206),e[t]=r)}}var i;return e}function I(t,e,i){const s=function({attributes:t}){return new u.ru({type:t.TYPE,uri:t.URI,groupId:t["GROUP-ID"],language:t.LANGUAGE,assocLanguage:t["ASSOC-LANGUAGE"],name:t.NAME,isDefault:t.DEFAULT,autoselect:t.AUTOSELECT,forced:t.FORCED,instreamId:t["INSTREAM-ID"],characteristics:t.CHARACTERISTICS,channels:t.CHANNELS})}(e),a=t[d.Th(i)],r=function(t,e){let i=!1;for(const s of t){if(s.name===e.name)return"All EXT-X-MEDIA tags in the same Group MUST have different NAME attributes.";s.isDefault&&(i=!0)}return i&&e.isDefault?"EXT-X-MEDIA A Group MUST NOT have more than one member with a DEFAULT attribute of YES.":""}(a,s);r&&T.h2(r,E,315),a.push(s),s.isDefault&&(t.currentRenditions[d.Th(i)]=a.length-1)}function N(t,e,i,s,a){const r=new u.KT({uri:i,bandwidth:e.BANDWIDTH,averageBandwidth:e["AVERAGE-BANDWIDTH"],score:e.SCORE,codecs:e.CODECS,resolution:e.RESOLUTION,frameRate:e["FRAME-RATE"],hdcpLevel:e["HDCP-LEVEL"],allowedCpc:e["ALLOWED-CPC"],videoRange:e["VIDEO-RANGE"],stableVariantId:e["STABLE-VARIANT-ID"],programId:e["PROGRAM-ID"]});for(const i of t)if("EXT-X-MEDIA"===i.name){const t=i.attributes,s=t.TYPE;if(s&&t["GROUP-ID"]||T.h2("EXT-X-MEDIA TYPE attribute is REQUIRED.",E,355),e[s]===t["GROUP-ID"]&&(I(r,i,s),"CLOSED-CAPTIONS"===s))for(const{instreamId:t}of r.closedCaptions)if(t&&t.startsWith("SERVICE")&&a.compatibleVersion<7){a.compatibleVersion=7;break}}return function(t,e,i){for(const s of["AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS"])"CLOSED-CAPTIONS"===s&&"NONE"===t[s]?(i.isClosedCaptionsNone=!0,e.closedCaptions=[]):t[s]&&!e[d.Th(s)].some((e=>e.groupId===t[s]))&&T.h2(`${s} attribute MUST match the value of the GROUP-ID attribute of an EXT-X-MEDIA tag whose TYPE attribute is ${s}.`,E,330)}(e,r,a),r.isIFrameOnly=s,r}function v(t,e){if(t.method!==e.method)return!1;if(t.uri!==e.uri)return!1;if(t.iv){if(!e.iv)return!1;if(t.iv.length!==e.iv.length)return!1;for(let i=0;i<t.iv.length;i++)if(t.iv[i]!==e.iv[i])return!1}else if(e.iv)return!1;return t.format===e.format&&t.formatVersion===e.formatVersion}function R(t,e,i,s,a,r,o){const l=new u.Y4({uri:e,mediaSequenceNumber:a,discontinuitySequence:r});let c=!1,d=!1;for(let e=i;e<=s;e++){const{name:i,value:s,attributes:a}=t[e];if("EXTINF"===i)!n()(s.duration)&&o.compatibleVersion<3&&(o.compatibleVersion=3),Math.round(s.duration)>o.targetDuration&&T.h2("EXTINF duration, when rounded to the nearest integer, MUST be less than or equal to the target duration",E,517),l.duration=s.duration,l.title=s.title;else if("EXT-X-BYTERANGE"===i)o.compatibleVersion<4&&(o.compatibleVersion=4),l.byterange=s;else if("EXT-X-DISCONTINUITY"===i)l.parts.length>0&&T.h2("EXT-X-DISCONTINUITY must appear before the first EXT-X-PART tag of the Parent Segment.",E,530),l.discontinuity=!0;else if("EXT-X-KEY"===i)l.parts.length>0&&T.h2("EXT-X-KEY must appear before the first EXT-X-PART tag of the Parent Segment.",E,536),"NONE"!==a.METHOD&&(X(o,a),l.key=new u.Uz({method:a.METHOD,uri:a.URI,iv:a.IV,format:a.KEYFORMAT,formatVersion:a.KEYFORMATVERSIONS}));else if("EXT-X-MAP"===i)l.parts.length>0&&T.h2("EXT-X-MAP must appear before the first EXT-X-PART tag of the Parent Segment.",E,552),o.compatibleVersion<5&&(o.compatibleVersion=5),o.hasMap=!0,l.map=new u.qP({uri:a.URI,byterange:a.BYTERANGE});else if("EXT-X-PROGRAM-DATE-TIME"===i)l.programDateTime=s;else if("EXT-X-DATERANGE"===i){const t={};for(const e of h()(a))(e.startsWith("SCTE35-")||e.startsWith("X-"))&&(t[e]=a[e]);l.dateRange=new u.ad({id:a.ID,classId:a.CLASS,start:a["START-DATE"],end:a["END-DATE"],duration:a.DURATION,plannedDuration:a["PLANNED-DURATION"],endOnNext:a["END-ON-NEXT"],attributes:t})}else if("EXT-X-CUE-OUT"===i)l.markers.push(new u.xC({type:"OUT",duration:a&&a.DURATION||s}));else if("EXT-X-CUE-IN"===i)l.markers.push(new u.xC({type:"IN"}));else if("EXT-X-CUE-OUT-CONT"===i||"EXT-X-CUE"===i||"EXT-OATCLS-SCTE35"===i||"EXT-X-ASSET"===i||"EXT-X-SCTE35"===i)l.markers.push(new u.xC({type:"RAW",tagName:i,value:s}));else if("EXT-X-PRELOAD-HINT"!==i||a.TYPE)if("EXT-X-PRELOAD-HINT"===i&&"PART"===a.TYPE&&d)T.h2("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.",E,612);else if("EXT-X-PART"!==i&&"EXT-X-PRELOAD-HINT"!==i||a.URI){if("EXT-X-PRELOAD-HINT"===i&&"MAP"===a.TYPE)c&&T.h2("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.",E,619),c=!0,o.hasMap=!0,l.map=new u.qP({hint:!0,uri:a.URI,byterange:{length:a["BYTERANGE-LENGTH"],offset:a["BYTERANGE-START"]||0}});else if("EXT-X-PART"===i||"EXT-X-PRELOAD-HINT"===i&&"PART"===a.TYPE){"EXT-X-PART"!==i||a.DURATION||T.h2("EXT-X-PART: DURATION attribute is mandatory",E,631),"EXT-X-PRELOAD-HINT"===i&&(d=!0);const t=new u.nw({hint:"EXT-X-PRELOAD-HINT"===i,uri:a.URI,byterange:"EXT-X-PART"===i?a.BYTERANGE:{length:a["BYTERANGE-LENGTH"],offset:a["BYTERANGE-START"]||0},duration:a.DURATION,independent:a.INDEPENDENT,gap:a.GAP});l.parts.push(t)}}else T.h2("EXT-X-PART / EXT-X-PRELOAD-HINT: URI attribute is mandatory",E,615);else T.h2("EXT-X-PRELOAD-HINT: TYPE attribute is mandatory",E,609)}return l}function P(t,e,i,s,a,r,n){const o=new u.Vd({uri:e,mediaSequenceNumber:a,discontinuitySequence:r});for(let e=i;e<=s;e++){const{name:i,attributes:s}=t[e];"EXTINF"===i?T.h2("A prefetch segment must not be advertised with an EXTINF tag.",E,663):"EXT-X-DISCONTINUITY"===i?T.h2("A prefetch segment must not be advertised with an EXT-X-DISCONTINUITY tag.",E,666):"EXT-X-PREFETCH-DISCONTINUITY"===i?o.discontinuity=!0:"EXT-X-KEY"===i?"NONE"!==s.METHOD&&(X(n,s),o.key=new u.Uz({method:s.METHOD,uri:s.URI,iv:s.IV,format:s.KEYFORMAT,formatVersion:s.KEYFORMATVERSIONS})):"EXT-X-MAP"===i&&T.h2("Prefetch segments must not be advertised with an EXT-X-MAP tag.",E,684)}return o}function D(t,e,i,s,a){const{discontinuity:r,key:n,map:o,byterange:h,uri:l}=e;if(r&&(e.discontinuitySequence=i+1),n||(e.key=s),o||(e.map=a),h&&-1===h.offset){const{segments:e}=t;if(e.length>0){const t=e[e.length-1];t.byterange&&t.uri===l?h.offset=t.byterange.offset+t.byterange.length:T.h2("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST be a sub-range of the same media resource",E,900)}else T.h2("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST appear in the Playlist file",E,904)}return t.segments.push(e),[e.discontinuitySequence,e.key,e.map]}function b(t,e){const[i,s]=function(t){const e=t.indexOf(":");return-1===e?[t.slice(1).trim(),null]:[t.slice(1,e).trim(),t.slice(e+1).trim()]}(t),r=function(t){switch(t){case"EXTM3U":case"EXT-X-VERSION":return"Basic";case"EXTINF":case"EXT-X-BYTERANGE":case"EXT-X-DISCONTINUITY":case"EXT-X-PREFETCH-DISCONTINUITY":case"EXT-X-KEY":case"EXT-X-MAP":case"EXT-X-PROGRAM-DATE-TIME":case"EXT-X-DATERANGE":case"EXT-X-CUE-OUT":case"EXT-X-CUE-IN":case"EXT-X-CUE-OUT-CONT":case"EXT-X-CUE":case"EXT-OATCLS-SCTE35":case"EXT-X-ASSET":case"EXT-X-SCTE35":case"EXT-X-PART":case"EXT-X-PRELOAD-HINT":return"Segment";case"EXT-X-TARGETDURATION":case"EXT-X-MEDIA-SEQUENCE":case"EXT-X-DISCONTINUITY-SEQUENCE":case"EXT-X-ENDLIST":case"EXT-X-PLAYLIST-TYPE":case"EXT-X-I-FRAMES-ONLY":case"EXT-X-SERVER-CONTROL":case"EXT-X-PART-INF":case"EXT-X-PREFETCH":case"EXT-X-RENDITION-REPORT":case"EXT-X-SKIP":return"MediaPlaylist";case"EXT-X-MEDIA":case"EXT-X-STREAM-INF":case"EXT-X-I-FRAME-STREAM-INF":case"EXT-X-SESSION-DATA":case"EXT-X-SESSION-KEY":return"MasterPlaylist";case"EXT-X-INDEPENDENT-SEGMENTS":case"EXT-X-START":return"MediaorMasterPlaylist";default:return"Unknown"}}(i);if(function(t,e){if("Segment"===t||"MediaPlaylist"===t)return void 0===e.isMasterPlaylist?void(e.isMasterPlaylist=!1):void(e.isMasterPlaylist&&T.h2("The file contains both media and master playlist tags.",E,1011));if("MasterPlaylist"===t){if(void 0===e.isMasterPlaylist)return void(e.isMasterPlaylist=!0);!1===e.isMasterPlaylist&&T.h2("The file contains both media and master playlist tags.",E,1021)}}(r,e),"Unknown"===r)return null;"MediaPlaylist"===r&&"EXT-X-RENDITION-REPORT"!==i&&"EXT-X-PREFETCH"!==i&&(e.hash[i]&&T.h2("There MUST NOT be more than one Media Playlist tag of each type in any Media Playlist",E,1042),e.hash[i]=!0);const[n,o]=function(t,e){switch(t){case"EXTM3U":case"EXT-X-DISCONTINUITY":case"EXT-X-ENDLIST":case"EXT-X-I-FRAMES-ONLY":case"EXT-X-INDEPENDENT-SEGMENTS":case"EXT-X-CUE-IN":return[null,null];case"EXT-X-VERSION":case"EXT-X-TARGETDURATION":case"EXT-X-MEDIA-SEQUENCE":case"EXT-X-DISCONTINUITY-SEQUENCE":return[d.Ro(e),null];case"EXT-X-CUE-OUT":return a()(Number(e))?[null,S(e)]:[d.Ro(e),null];case"EXT-X-KEY":case"EXT-X-MAP":case"EXT-X-DATERANGE":case"EXT-X-MEDIA":case"EXT-X-STREAM-INF":case"EXT-X-I-FRAME-STREAM-INF":case"EXT-X-SESSION-DATA":case"EXT-X-SESSION-KEY":case"EXT-X-START":case"EXT-X-SERVER-CONTROL":case"EXT-X-PART-INF":case"EXT-X-PART":case"EXT-X-PRELOAD-HINT":case"EXT-X-RENDITION-REPORT":case"EXT-X-SKIP":return[null,S(e)];case"EXTINF":return[A(e),null];case"EXT-X-BYTERANGE":return[p(e),null];case"EXT-X-PROGRAM-DATE-TIME":return[new Date(e),null];default:return[e,null]}}(i,s);return{name:i,category:r,value:n,attributes:o}}function O(t,e){let i;return e.isMasterPlaylist?i=function(t,e){const i=new u.ts;let s=!1;for(const[a,{name:r,value:n,attributes:o}]of t.entries())if("EXT-X-VERSION"===r)i.version=n;else if("EXT-X-STREAM-INF"===r){const r=t[a+1];("string"!=typeof r||r.startsWith("#EXT"))&&T.h2("EXT-X-STREAM-INF must be followed by a URI line",E,417);const n=N(t,o,r,!1,e);n&&("number"==typeof n.score&&(s=!0,n.score<0&&T.h2("SCORE attribute on EXT-X-STREAM-INF must be positive decimal-floating-point number.",E,424)),i.variants.push(n))}else if("EXT-X-I-FRAME-STREAM-INF"===r){const s=N(t,o,o.URI,!0,e);s&&i.variants.push(s)}else if("EXT-X-SESSION-DATA"===r){const t=new u.pf({id:o["DATA-ID"],value:o.VALUE,uri:o.URI,language:o.LANGUAGE});i.sessionDataList.some((e=>e.id===t.id&&e.language===t.language))&&T.h2("A Playlist MUST NOT contain more than one EXT-X-SESSION-DATA tag with the same DATA-ID attribute and the same LANGUAGE attribute.",E,444),i.sessionDataList.push(t)}else if("EXT-X-SESSION-KEY"===r){"NONE"===o.METHOD&&T.h2("EXT-X-SESSION-KEY: The value of the METHOD attribute MUST NOT be NONE",E,450);const t=new u.Uz({method:o.METHOD,uri:o.URI,iv:o.IV,format:o.KEYFORMAT,formatVersion:o.KEYFORMATVERSIONS});i.sessionKeyList.some((e=>v(e,t)))&&T.h2("A Master Playlist MUST NOT contain more than one EXT-X-SESSION-KEY tag with the same METHOD, URI, IV, KEYFORMAT, and KEYFORMATVERSIONS attribute values.",E,460),X(e,o),i.sessionKeyList.push(t)}else"EXT-X-INDEPENDENT-SEGMENTS"===r?(i.independentSegments&&T.h2("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist",E,467),i.independentSegments=!0):"EXT-X-START"===r&&(i.start&&T.h2("EXT-X-START tag MUST NOT appear more than once in a Playlist",E,473),"number"!=typeof o["TIME-OFFSET"]&&T.h2("EXT-X-START: TIME-OFFSET attribute is REQUIRED",E,476),i.start={offset:o["TIME-OFFSET"],precise:o.PRECISE||!1});if(s)for(const t of i.variants)"number"!=typeof t.score&&T.h2("If any Variant Stream contains the SCORE attribute, then all Variant Streams in the Master Playlist SHOULD have a SCORE attribute",E,484);if(e.isClosedCaptionsNone)for(const t of i.variants)t.closedCaptions.length>0&&T.h2("If there is a variant with CLOSED-CAPTIONS attribute of NONE, all EXT-X-STREAM-INF tags MUST have this attribute with a value of NONE",E,491);return i}(t,e):(i=function(t,e){const i=new u.tk;let s=-1,a=0,r=!1,n=!1,o=0,h=null,l=null,d=!1;for(const[c,f]of t.entries()){const{name:A,value:p,attributes:m,category:y}=f;if("Segment"!==y){if("EXT-X-VERSION"===A)void 0===i.version?i.version=p:T.h2("A Playlist file MUST NOT contain more than one EXT-X-VERSION tag.",E,716);else if("EXT-X-TARGETDURATION"===A)i.targetDuration=e.targetDuration=p;else if("EXT-X-MEDIA-SEQUENCE"===A)i.segments.length>0&&T.h2("The EXT-X-MEDIA-SEQUENCE tag MUST appear before the first Media Segment in the Playlist.",E,724),i.mediaSequenceBase=a=p;else if("EXT-X-DISCONTINUITY-SEQUENCE"===A)i.segments.length>0&&T.h2("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before the first Media Segment in the Playlist.",E,730),r&&T.h2("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before any EXT-X-DISCONTINUITY tag.",E,733),i.discontinuitySequenceBase=o=p;else if("EXT-X-ENDLIST"===A)i.endlist=!0;else if("EXT-X-PLAYLIST-TYPE"===A)i.playlistType=p;else if("EXT-X-I-FRAMES-ONLY"===A)e.compatibleVersion<4&&(e.compatibleVersion=4),i.isIFrame=!0;else if("EXT-X-INDEPENDENT-SEGMENTS"===A)i.independentSegments&&T.h2("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist",E,751),i.independentSegments=!0;else if("EXT-X-START"===A)i.start&&T.h2("EXT-X-START tag MUST NOT appear more than once in a Playlist",E,757),"number"!=typeof m["TIME-OFFSET"]&&T.h2("EXT-X-START: TIME-OFFSET attribute is REQUIRED",E,760),i.start={offset:m["TIME-OFFSET"],precise:m.PRECISE||!1};else if("EXT-X-SERVER-CONTROL"===A)m["CAN-BLOCK-RELOAD"]||T.h2("EXT-X-SERVER-CONTROL: CAN-BLOCK-RELOAD=YES is mandatory for Low-Latency HLS",E,766),i.lowLatencyCompatibility={canBlockReload:m["CAN-BLOCK-RELOAD"],canSkipUntil:m["CAN-SKIP-UNTIL"],holdBack:m["HOLD-BACK"],partHoldBack:m["PART-HOLD-BACK"]};else if("EXT-X-PART-INF"===A)m["PART-TARGET"]||T.h2("EXT-X-PART-INF: PART-TARGET attribute is mandatory",E,777),i.partTargetDuration=m["PART-TARGET"];else if("EXT-X-RENDITION-REPORT"===A)m.URI||T.h2("EXT-X-RENDITION-REPORT: URI attribute is mandatory",E,783),0===m.URI.search(/^[a-z]+:/)&&T.h2("EXT-X-RENDITION-REPORT: URI must be relative to the playlist uri",E,786),i.renditionReports.push(new u.h4({uri:m.URI,lastMSN:m["LAST-MSN"],lastPart:m["LAST-PART"]}));else if("EXT-X-SKIP"===A)m["SKIPPED-SEGMENTS"]||T.h2("EXT-X-SKIP: SKIPPED-SEGMENTS attribute is mandatory",E,796),e.compatibleVersion<9&&(e.compatibleVersion=9),i.skip=m["SKIPPED-SEGMENTS"],a+=i.skip;else if("EXT-X-PREFETCH"===A){const r=P(t,p,-1===s?c:s,c-1,a++,o,e);r&&(r.discontinuity&&(r.discontinuitySequence++,o=r.discontinuitySequence),r.key?h=r.key:r.key=h,i.prefetchSegments.push(r)),n=!0,s=-1}else if("string"==typeof f){-1===s&&T.h2("A URI line is not preceded by any segment tags",E,833),i.targetDuration||T.h2("The EXT-X-TARGETDURATION tag is REQUIRED",E,836),n&&T.h2("These segments must appear after all complete segments.",E,839);const r=R(t,f,s,c-1,a++,o,e);r&&([o,h,l]=D(i,r,o,h,l),!d&&r.parts.length>0&&(d=!0)),s=-1}}else-1===s&&(s=c),"EXT-X-DISCONTINUITY"===A&&(r=!0)}if(-1!==s){const r=R(t,"",s,t.length-1,a++,o,e);if(r){var f;const{parts:t}=r;!(t.length>0)||i.endlist||null!==(f=t[t.length-1])&&void 0!==f&&f.hint||T.h2("If the Playlist contains EXT-X-PART tags and does not contain an EXT-X-ENDLIST tag, the Playlist must contain an EXT-X-PRELOAD-HINT tag with a TYPE=PART attribute",E,856),D(i,r,h,l),!d&&r.parts.length>0&&(d=!0)}}return function(t){const e=new(c()),i=new(c());let s=!1,a=!1;for(let r=t.length-1;r>=0;r--){const{programDateTime:n,dateRange:o}=t[r];if(n&&(a=!0),o&&o.start){s=!0,o.endOnNext&&(o.end||o.duration)&&T.h2("An EXT-X-DATERANGE tag with an END-ON-NEXT=YES attribute MUST NOT contain DURATION or END-DATE attributes.",E,924);const t=o.start.getTime(),a=o.duration||0;o.end&&o.duration&&t+1e3*a!==o.end.getTime()&&T.h2("END-DATE MUST be equal to the value of the START-DATE attribute plus the value of the DURATION",E,930),o.endOnNext&&(o.end=e.get(o.classId)),e.set(o.classId,o.start);const r=o.end?o.end.getTime():o.start.getTime()+1e3*(o.duration||0),n=i.get(o.classId);if(n){for(const e of n)(e.start<=t&&e.end>t||e.start>=t&&e.start<r)&&T.h2("DATERANGE tags with the same CLASS should not overlap",E,942);n.push({start:t,end:r})}else o.classId&&i.set(o.classId,[{start:t,end:r}])}}s&&!a&&T.h2("If a Playlist contains an EXT-X-DATERANGE tag, it MUST also contain at least one EXT-X-PROGRAM-DATE-TIME tag.",E,953)}(i.segments),i.lowLatencyCompatibility&&function({lowLatencyCompatibility:t,targetDuration:e,partTargetDuration:i,segments:s,renditionReports:a},r){const{canSkipUntil:n,holdBack:o,partHoldBack:h}=t;if(n<6*e&&T.h2("The Skip Boundary must be at least six times the EXT-X-TARGETDURATION.",E,960),o<3*e&&T.h2("HOLD-BACK must be at least three times the EXT-X-TARGETDURATION.",E,964),r){void 0===i&&T.h2("EXT-X-PART-INF is required if a Playlist contains one or more EXT-X-PART tags",E,968),void 0===h&&T.h2("EXT-X-PART: PART-HOLD-BACK attribute is mandatory",E,971),h<i&&T.h2("PART-HOLD-BACK must be at least PART-TARGET",E,974);for(const[t,{parts:e}]of s.entries()){e.length>0&&t<s.length-3&&T.h2("Remove EXT-X-PART tags from the Playlist after they are greater than three target durations from the end of the Playlist.",E,978);for(const[t,{duration:s}]of e.entries())void 0!==s&&(s>i&&T.h2("PART-TARGET is the maximum duration of any Partial Segment",E,985),t<e.length-1&&s<.85*i&&T.h2("All Partial Segments except the last part of a segment must have a duration of at least 85% of PART-TARGET",E,988))}}for(const t of a){const e=s[s.length-1];null!==t.lastMSN&&void 0!==t.lastMSN||(t.lastMSN=e.mediaSequenceNumber),(null===t.lastPart||void 0===t.lastPart)&&e.parts.length>0&&(t.lastPart=e.parts.length-1)}}(i,d),i.duration=i.segments.reduce(((t,e)=>"number"==typeof e.duration?t+e.duration:t),0),i}(t,e),!i.isIFrame&&e.hasMap&&e.compatibleVersion<6&&(e.compatibleVersion=6)),e.compatibleVersion>1&&(!i.version||i.version<e.compatibleVersion)&&T.h2(`EXT-X-VERSION needs to be ${e.compatibleVersion} or higher.`,E,1092),i}function L(t){const e={version:void 0,isMasterPlaylist:void 0,hasMap:!1,targetDuration:0,compatibleVersion:1,isClosedCaptionsNone:!1,hash:{}},i=function(t,e){const i=[];for(const s of t.split("\n")){const t=s.trim();if(t)if(t.startsWith("#")){if(t.startsWith("#EXT")){const s=b(t,e);s&&i.push(s)}}else i.push(t)}return 0!==i.length&&"EXTM3U"===i[0].name||T.h2("The EXTM3U tag MUST be the first line.",E,1074),i}(t,e),s=O(i,e);return s.source=t,s}},64608:(t,e,i)=>{i.d(e,{KT:()=>n,Uz:()=>h,Vd:()=>m,Y4:()=>A,ad:()=>c,h4:()=>y,nw:()=>p,pf:()=>o,qP:()=>l,ru:()=>r,tk:()=>f,ts:()=>E,xC:()=>d});var s=i(134),a=i(86932);class r{constructor({type:t,uri:e,groupId:i,language:a,assocLanguage:r,name:n,isDefault:o,autoselect:h,forced:l,instreamId:c,characteristics:d,channels:u}){(0,s.A)(this,"type",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"groupId",void 0),(0,s.A)(this,"language",void 0),(0,s.A)(this,"assocLanguage",void 0),(0,s.A)(this,"name",void 0),(0,s.A)(this,"isDefault",void 0),(0,s.A)(this,"autoselect",void 0),(0,s.A)(this,"forced",void 0),(0,s.A)(this,"instreamId",void 0),(0,s.A)(this,"characteristics",void 0),(0,s.A)(this,"channels",void 0),this.type=t,this.uri=e,this.groupId=i,this.language=a,this.assocLanguage=r,this.name=n,this.isDefault=o,this.autoselect=h,this.forced=l,this.instreamId=c,this.characteristics=d,this.channels=u}}class n{constructor({uri:t,isIFrameOnly:e=!1,bandwidth:i,averageBandwidth:a,score:r,codecs:n,resolution:o,frameRate:h,hdcpLevel:l,allowedCpc:c,videoRange:d,stableVariantId:u,programId:T,audio:E=[],video:f=[],subtitles:A=[],closedCaptions:p=[],currentRenditions:m={audio:0,video:0,subtitles:0,closedCaptions:0}}){(0,s.A)(this,"uri",void 0),(0,s.A)(this,"isIFrameOnly",void 0),(0,s.A)(this,"bandwidth",void 0),(0,s.A)(this,"averageBandwidth",void 0),(0,s.A)(this,"score",void 0),(0,s.A)(this,"codecs",void 0),(0,s.A)(this,"resolution",void 0),(0,s.A)(this,"frameRate",void 0),(0,s.A)(this,"hdcpLevel",void 0),(0,s.A)(this,"allowedCpc",void 0),(0,s.A)(this,"videoRange",void 0),(0,s.A)(this,"stableVariantId",void 0),(0,s.A)(this,"programId",void 0),(0,s.A)(this,"audio",void 0),(0,s.A)(this,"video",void 0),(0,s.A)(this,"subtitles",void 0),(0,s.A)(this,"closedCaptions",void 0),(0,s.A)(this,"currentRenditions",void 0),this.uri=t,this.isIFrameOnly=e,this.bandwidth=i,this.averageBandwidth=a,this.score=r,this.codecs=n,this.resolution=o,this.frameRate=h,this.hdcpLevel=l,this.allowedCpc=c,this.videoRange=d,this.stableVariantId=u,this.programId=T,this.audio=E,this.video=f,this.subtitles=A,this.closedCaptions=p,this.currentRenditions=m}}class o{constructor({id:t,value:e,uri:i,language:a}){(0,s.A)(this,"id",void 0),(0,s.A)(this,"value",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"language",void 0),this.id=t,this.value=e,this.uri=i,this.language=a}}class h{constructor({method:t,uri:e,iv:i,format:a,formatVersion:r}){(0,s.A)(this,"method",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"iv",void 0),(0,s.A)(this,"format",void 0),(0,s.A)(this,"formatVersion",void 0),this.method=t,this.uri=e,this.iv=i,this.format=a,this.formatVersion=r}}class l{constructor({hint:t=!1,uri:e,mimeType:i,byterange:a}){(0,s.A)(this,"hint",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"mimeType",void 0),(0,s.A)(this,"byterange",void 0),this.hint=t,this.uri=e,this.mimeType=i,this.byterange=a}}class c{constructor({id:t,classId:e,start:i,end:a,duration:r,plannedDuration:n,endOnNext:o,attributes:h={}}){(0,s.A)(this,"id",void 0),(0,s.A)(this,"classId",void 0),(0,s.A)(this,"start",void 0),(0,s.A)(this,"end",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"plannedDuration",void 0),(0,s.A)(this,"endOnNext",void 0),(0,s.A)(this,"attributes",void 0),this.id=t,this.classId=e,this.start=i,this.end=a,this.duration=r,this.plannedDuration=n,this.endOnNext=o,this.attributes=h}}class d{constructor({type:t,duration:e,tagName:i,value:a}){(0,s.A)(this,"type",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"tagName",void 0),(0,s.A)(this,"value",void 0),this.type=t,this.duration=e,this.tagName=i,this.value=a}}class u{constructor(t){(0,s.A)(this,"type",void 0),this.type=t}}class T extends u{constructor({isMasterPlaylist:t,uri:e,version:i,independentSegments:a=!1,start:r,source:n}){super("playlist"),(0,s.A)(this,"isMasterPlaylist",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"independentSegments",void 0),(0,s.A)(this,"start",void 0),(0,s.A)(this,"source",void 0),this.isMasterPlaylist=t,this.uri=e,this.version=i,this.independentSegments=a,this.start=r,this.source=n}}class E extends T{constructor(t={}){super({...t,isMasterPlaylist:!0}),(0,s.A)(this,"variants",void 0),(0,s.A)(this,"currentVariant",void 0),(0,s.A)(this,"sessionDataList",void 0),(0,s.A)(this,"sessionKeyList",void 0);const{variants:e=[],currentVariant:i,sessionDataList:a=[],sessionKeyList:r=[]}=t;this.variants=e,this.currentVariant=i,this.sessionDataList=a,this.sessionKeyList=r}}class f extends T{constructor(t={}){super({...t,isMasterPlaylist:!1}),(0,s.A)(this,"targetDuration",void 0),(0,s.A)(this,"mediaSequenceBase",void 0),(0,s.A)(this,"discontinuitySequenceBase",void 0),(0,s.A)(this,"endlist",void 0),(0,s.A)(this,"playlistType",void 0),(0,s.A)(this,"isIFrame",void 0),(0,s.A)(this,"segments",void 0),(0,s.A)(this,"prefetchSegments",void 0),(0,s.A)(this,"lowLatencyCompatibility",void 0),(0,s.A)(this,"partTargetDuration",void 0),(0,s.A)(this,"renditionReports",void 0),(0,s.A)(this,"skip",void 0),(0,s.A)(this,"hash",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"timestamp",void 0);const{targetDuration:e,mediaSequenceBase:i=0,discontinuitySequenceBase:r=0,endlist:n=!1,playlistType:o,isIFrame:h,segments:l=[],prefetchSegments:c=[],lowLatencyCompatibility:d,partTargetDuration:u,renditionReports:T=[],skip:E=0,hash:f,duration:A=0}=t;this.targetDuration=e,this.mediaSequenceBase=i,this.discontinuitySequenceBase=r,this.endlist=n,this.playlistType=o,this.isIFrame=h,this.segments=l,this.prefetchSegments=c,this.lowLatencyCompatibility=d,this.partTargetDuration=u,this.renditionReports=T,this.skip=E,this.hash=f,this.duration=A,this.timestamp=(0,a.A)()}}class A extends u{constructor({uri:t,mimeType:e,data:i,duration:a,title:r,byterange:n,discontinuity:o,mediaSequenceNumber:h=0,discontinuitySequence:l=0,key:c,map:d,programDateTime:u,dateRange:T,markers:E=[],parts:f=[]}){super("segment"),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"mimeType",void 0),(0,s.A)(this,"data",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"title",void 0),(0,s.A)(this,"byterange",void 0),(0,s.A)(this,"discontinuity",void 0),(0,s.A)(this,"mediaSequenceNumber",void 0),(0,s.A)(this,"discontinuitySequence",void 0),(0,s.A)(this,"key",void 0),(0,s.A)(this,"map",void 0),(0,s.A)(this,"programDateTime",void 0),(0,s.A)(this,"dateRange",void 0),(0,s.A)(this,"markers",void 0),(0,s.A)(this,"parts",void 0),this.uri=t,this.mimeType=e,this.data=i,this.duration=a,this.title=r,this.byterange=n,this.discontinuity=o,this.mediaSequenceNumber=h,this.discontinuitySequence=l,this.key=c,this.map=d,this.programDateTime=u,this.dateRange=T,this.markers=E,this.parts=f}}class p extends u{constructor({hint:t=!1,uri:e,duration:i,independent:a,byterange:r,gap:n}){super("part"),(0,s.A)(this,"hint",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"independent",void 0),(0,s.A)(this,"byterange",void 0),(0,s.A)(this,"gap",void 0),this.hint=t,this.uri=e,this.duration=i,this.independent=a,this.duration=i,this.byterange=r,this.gap=n}}class m extends u{constructor({uri:t,discontinuity:e,mediaSequenceNumber:i=0,discontinuitySequence:a=0,key:r}){super("prefetch"),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"discontinuity",void 0),(0,s.A)(this,"mediaSequenceNumber",void 0),(0,s.A)(this,"discontinuitySequence",void 0),(0,s.A)(this,"key",void 0),this.uri=t,this.discontinuity=e,this.mediaSequenceNumber=i,this.discontinuitySequence=a,this.key=r}}class y{constructor({uri:t,lastMSN:e,lastPart:i}){(0,s.A)(this,"uri",void 0),(0,s.A)(this,"lastMSN",void 0),(0,s.A)(this,"lastPart",void 0),this.uri=t,this.lastMSN=e,this.lastPart=i}}},67756:(t,e,i)=>{i.d(e,{Bq:()=>u,HG:()=>T,Ro:()=>l,Th:()=>E,gI:()=>d,m2:()=>c});var s=i(99704),a=i.n(s),r=i(17735),n=i.n(r),o=i(7210),h=i.n(o);function l(t,e=10){if("number"==typeof t)return t;const i=10===e?a()(t):n()(t,e);return h()(i)?0:i}function c(t){(t.startsWith("0x")||t.startsWith("0X"))&&(t=t.slice(2));const e=[];for(let i=0;i<t.length;i+=2)e.push(l(t.slice(i,i+2),16));return new Uint8Array(e)}function d(t,e,i=0){let s=-1;for(let a=0,r=0;a<t.length;a++)if(t[a]===e){if(r++===i)return[t.slice(0,a),t.slice(a+1)];s=a}return-1!==s?[t.slice(0,s),t.slice(s+1)]:[t]}function u(t,e=" "){return t?(t=t.trim()," "===e||(t.startsWith(e)&&(t=t.slice(1)),t.endsWith(e)&&(t=t.slice(0,-1))),t):t}function T(t){const e=[];let i=!0,s=0;const a=[];for(let r=0;r<t.length;r++){const n=t[r];i&&","===n?(e.push(t.slice(s,r).trim()),s=r+1):'"'!==n&&"'"!==n||(i?(a.push(n),i=!1):n===a[a.length-1]?(a.pop(),i=!0):a.push(n))}return e.push(t.slice(s).trim()),e}function E(t){const e=[];let i=!1;for(const s of t)"-"!==s&&"_"!==s?i?(e.push(s.toUpperCase()),i=!1):e.push(s.toLowerCase()):i=!0;return e.join("")}},13258:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(134);class a{constructor(t=0){(0,s.A)(this,"rcon",[0,1,2,4,8,16,32,64,128,27,54]),(0,s.A)(this,"subMix",[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)]),(0,s.A)(this,"invSubMix",[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)]),(0,s.A)(this,"sBox",new Uint32Array(256)),(0,s.A)(this,"invSBox",new Uint32Array(256)),(0,s.A)(this,"key",new Uint32Array(0)),(0,s.A)(this,"ksRows",0),(0,s.A)(this,"keySize",0),(0,s.A)(this,"keySchedule",void 0),(0,s.A)(this,"invKeySchedule",void 0),this.initTable()}uint8ArrayToUint32Array_(t){const e=new DataView(t),i=new Uint32Array(4);for(let t=0;t<4;t++)i[t]=e.getUint32(4*t);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,s=i[0],a=i[1],r=i[2],n=i[3],o=this.invSubMix,h=o[0],l=o[1],c=o[2],d=o[3],u=new Uint32Array(256);let T=0,E=0,f=0;for(f=0;f<256;f++)u[f]=f<128?f<<1:f<<1^283;for(f=0;f<256;f++){let i=E^E<<1^E<<2^E<<3^E<<4;i=i>>>8^255&i^99,t[T]=i,e[i]=T;const o=u[T],f=u[o],A=u[f];let p=257*u[i]^16843008*i;s[T]=p<<24|p>>>8,a[T]=p<<16|p>>>16,r[T]=p<<8|p>>>24,n[T]=p,p=16843009*A^65537*f^257*o^16843008*T,h[i]=p<<24|p>>>8,l[i]=p<<16|p>>>16,c[i]=p<<8|p>>>24,d[i]=p,T?(T=o^u[u[u[A^o]]],E^=u[u[E]]):T=E=1}}async expandKey(t){const e=this.uint8ArrayToUint32Array_(t);if(this.key){let t=!0,i=0;for(;i<e.length&&t;)t=e[i]===this.key[i],i++;if(t)return}this.key=e;const i=this.keySize=this.key.length;if(4!==i&&6!==i&&8!==i)throw new Error("Invalid aes key size="+i);const s=this.ksRows=4*(i+6+1);let a,r;const n=this.keySchedule=new Uint32Array(s),o=this.invKeySchedule=new Uint32Array(s),h=this.sBox,l=this.rcon,c=this.invSubMix,d=c[0],u=c[1],T=c[2],E=c[3];let f,A;for(a=0;a<s;a++)a<i?f=n[a]=e[a]:(A=f,a%i==0?(A=A<<8|A>>>24,A=h[A>>>24]<<24|h[A>>>16&255]<<16|h[A>>>8&255]<<8|h[255&A],A^=l[a/i|0]<<24):i>6&&a%i==4&&(A=h[A>>>24]<<24|h[A>>>16&255]<<16|h[A>>>8&255]<<8|h[255&A]),n[a]=f=(n[a-i]^A)>>>0);for(r=0;r<s;r++)a=s-r,A=3&r?n[a]:n[a-4],o[r]=r<4||a<=4?A:d[h[A>>>24]]^u[h[A>>>16&255]]^T[h[A>>>8&255]]^E[h[255&A]],o[r]=o[r]>>>0}networkToHostOrderSwap(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24}async decrypt(t,e){const i=this.keySize+6,s=this.invKeySchedule,a=this.invSBox,r=this.invSubMix,n=r[0],o=r[1],h=r[2],l=r[3],c=this.uint8ArrayToUint32Array_(e);let d=c[0],u=c[1],T=c[2],E=c[3];const f=new Int32Array(t.buffer).subarray(t.byteOffset>>>2,(t.byteOffset>>>2)+(t.length>>>2)),A=new Int32Array(f.length);let p,m,y,g,X,S,I,N,v,R,P,D,b,O;const L=this.networkToHostOrderSwap;let M=0;for(;M<f.length;){for(v=L(f[M]),R=L(f[M+1]),P=L(f[M+2]),D=L(f[M+3]),X=v^s[0],S=D^s[1],I=P^s[2],N=R^s[3],b=4,O=1;O<i;O++)p=n[X>>>24]^o[S>>16&255]^h[I>>8&255]^l[255&N]^s[b],m=n[S>>>24]^o[I>>16&255]^h[N>>8&255]^l[255&X]^s[b+1],y=n[I>>>24]^o[N>>16&255]^h[X>>8&255]^l[255&S]^s[b+2],g=n[N>>>24]^o[X>>16&255]^h[S>>8&255]^l[255&I]^s[b+3],X=p,S=m,I=y,N=g,b+=4;p=a[X>>>24]<<24^a[S>>16&255]<<16^a[I>>8&255]<<8^a[255&N]^s[b],m=a[S>>>24]<<24^a[I>>16&255]<<16^a[N>>8&255]<<8^a[255&X]^s[b+1],y=a[I>>>24]<<24^a[N>>16&255]<<16^a[X>>8&255]<<8^a[255&S]^s[b+2],g=a[N>>>24]<<24^a[X>>16&255]<<16^a[S>>8&255]<<8^a[255&I]^s[b+3],A[M]=L(p^d),A[M+1]=L(g^u),A[M+2]=L(y^T),A[M+3]=L(m^E),d=v,u=R,T=P,E=D,M+=4}return A.buffer}}},51678:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(134);class a{constructor(t=0){(0,s.A)(this,"subtle",void 0),(0,s.A)(this,"key",void 0),(0,s.A)(this,"mode",void 0),(0,s.A)(this,"keyBuffer",void 0),this.mode=t,this.subtle=crypto.subtle||crypto.webkitSubtle}getSubtleAlgoName(){switch(this.mode){case 0:return"AES-CBC";case 1:return"AES-CTR"}}async expandKey(t){let e=new Uint8Array(t);if(this.keyBuffer){let t=!0,i=0;for(;i<e.length&&t;)t=e[i]===this.keyBuffer[i],i++;if(t)return}this.keyBuffer=e,this.key=await this.subtle.importKey("raw",t,{name:this.getSubtleAlgoName()},!1,["encrypt","decrypt"])}async encryptPadding(t,e){return new Uint8Array(await crypto.subtle.encrypt({name:"AES-CBC",iv:e},this.key,t))}async decrypt(t,e){switch(this.mode){case 0:return this.subtle.decrypt({name:"AES-CBC",iv:e},this.key,t);case 1:return this.subtle.decrypt({name:"AES-CTR",counter:e,length:64},this.key,t)}}static isSupport(){return"object"==typeof(crypto.subtle||crypto.webkitSubtle)}}},6498:(t,e,i)=>{i(67672),i(72739)},8507:(t,e,i)=>{function s(t){const e=t,i=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],s=/:\/\/([^\/@]*@?)\[(\S+)\]/;let a="";s.test(t)&&(t=t.replace(s,((t,e,i)=>(a=i,`://${e||""}a.b`))));const r={},n=/^(?:(?![^:@\/]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*)(?::([^:@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(t);let o=14;for(;o--;){var h;r[i[o]]=null!==(h=n[o])&&void 0!==h?h:""}return a&&(r.host=a,r.source=e,r.authority=a+(r.port?":"+r.port:"")),{protocol:r.protocol,file:r.file,host:r.host,port:r.port,user:r.user,password:r.password,origin:`${r.protocol}://${r.authority}`,pathname:r.path,search:`?${r.query}`,hash:r.anchor?`#${r.anchor}`:""}}i.d(e,{ll:()=>d,qg:()=>s}),i(73146),i(67672),i(6498),i(72739),i(95335);const a=/(?:\/|^)\.(?=\/)/g,r=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,n=/^(?=([^\/?#]*))\1([^]*)$/,o=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/;function h(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}function l(t){const e=o.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null}function c(t){for(t=t.split("").reverse().join("").replace(a,"");t.length!==(t=t.replace(r,"")).length;);return t.split("").reverse().join("")}function d(t,e,i){if(i=i||{},t=t.trim(),!(e=e.trim())){if(!i.alwaysNormalize)return t;let e=l(t);if(!e)throw new Error("Error trying to parse base URL.");return e.path=c(e.path),h(e)}let s=l(e);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return i.alwaysNormalize?(s.path=c(s.path),h(s)):e;let a=l(t);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){let t=n.exec(a.path);a.netLoc=t[1],a.path=t[2]}a.netLoc&&!a.path&&(a.path="/");const r={scheme:a.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(r.netLoc=a.netLoc,"/"!==s.path[0]))if(s.path){let t=a.path,e=t.substring(0,t.lastIndexOf("/")+1)+s.path;r.path=c(e)}else r.path=a.path,s.params||(r.params=a.params,s.query||(r.query=a.query));return null===r.path&&(r.path=i.alwaysNormalize?c(s.path):s.path),h(r)}},85079:(t,e,i)=>{var s=i(46438),a=s.JSON||(s.JSON={stringify:JSON.stringify});t.exports=function(t){return a.stringify.apply(a,arguments)}},63342:(t,e,i)=>{i(5882),t.exports=i(46438).Number.isInteger},11837:(t,e,i)=>{i(21489),t.exports=i(46438).Number.isNaN},19737:(t,e,i)=>{i(56477),t.exports=i(46438).Number.parseFloat},58886:(t,e,i)=>{i(15706),t.exports=i(46438).Number.parseInt},25194:(t,e,i)=>{var s=i(24401),a=Math.floor;t.exports=function(t){return!s(t)&&isFinite(t)&&a(t)===t}},5882:(t,e,i)=>{var s=i(88535);s(s.S,"Number",{isInteger:i(25194)})},21489:(t,e,i)=>{var s=i(88535);s(s.S,"Number",{isNaN:function(t){return t!=t}})},56477:(t,e,i)=>{var s=i(88535),a=i(49709);s(s.S+s.F*(Number.parseFloat!=a),"Number",{parseFloat:a})},15706:(t,e,i)=>{var s=i(88535),a=i(15722);s(s.S+s.F*(Number.parseInt!=a),"Number",{parseInt:a})},73146:(t,e,i)=>{t.exports=i(85079)},43929:(t,e,i)=>{t.exports=i(63342)},7210:(t,e,i)=>{t.exports=i(11837)},99704:(t,e,i)=>{t.exports=i(19737)},17735:(t,e,i)=>{t.exports=i(58886)}}]);
1
+ (self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[433],{70509:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var s=i(134);class a{constructor(){(0,s.A)(this,"onFlush",void 0)}}},97801:(t,e,i)=>{"use strict";i.d(e,{A:()=>T});var s=i(134),a=i(70509),r=i(13258),n=i(51678),o=i(13724),h=i(4624);const l="src/avnetwork/bsp/aes/AESDecryptPipe.ts",c=16;let u=!0;const d=new Uint8Array(c).fill(c);class T extends a.A{constructor(t=1048576){super(),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"aesSoftDecryptor",void 0),(0,s.A)(this,"aesWebDecryptor",void 0),(0,s.A)(this,"aesTargetDecryptor",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"endPointer",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"ended",void 0),(0,s.A)(this,"iv",void 0),(0,s.A)(this,"key",void 0),this.size=t,this.pointer=0,this.endPointer=0,this.ended=!1,this.buffer=new Uint8Array(t),this.aesSoftDecryptor=new r.A,n.A.isSupport()&&u&&(this.aesWebDecryptor=new n.A),this.aesTargetDecryptor=this.aesWebDecryptor||this.aesSoftDecryptor}remainingLength(){return this.endPointer-this.pointer}async expandKey(t,e){this.key=t,this.iv=e,this.aesWebDecryptor&&await this.aesWebDecryptor.expandKey(t),this.aesSoftDecryptor.expandKey(t)}async flush_(t){for(;;){const e=await this.onFlush(t);if(-1048575!==e)return e;await new o.A(0)}}async flush(){if(this.size-this.remainingLength()<=0)return;this.pointer<this.endPointer?this.pointer&&(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer):this.endPointer=0,this.pointer=0;const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0){if(-1048576===t)return void(this.ended=!0);h.h2(`AESPipe error, flush failed, ret: ${t}`,l,120)}this.endPointer+=t}removePadding(t){const e=t.length,i=e&&new DataView(t.buffer).getUint8(e-1);return i?t.subarray(0,e-i):t}async decrypt(t){let e,i=0;this.aesTargetDecryptor!==this.aesWebDecryptor||this.ended||(e=this.buffer.subarray(this.pointer+t,this.pointer+t+c).slice(),this.buffer.set((await this.aesWebDecryptor.encryptPadding(d,this.buffer.subarray(this.pointer+t-c,this.pointer+t))).subarray(0,c),this.pointer+t),i=c);try{const s=this.buffer.subarray(this.pointer,this.pointer+t+i),a=await this.aesTargetDecryptor.decrypt(s,this.iv);return this.iv=s.slice(s.length-c-i,s.length-i).buffer,e&&this.buffer.set(e,this.pointer+t),this.pointer+=t,new Uint8Array(a)}catch(i){if(this.aesTargetDecryptor=this.aesWebDecryptor)return h.R8("web aes decrypt failed, try to use soft decryptor",l,169),e&&this.buffer.set(e,this.pointer+t),this.aesTargetDecryptor=this.aesSoftDecryptor,u=!1,this.decrypt(t);h.h2("aes decrypt failed",l,179)}}async read(t){for(;!this.ended&&this.remainingLength()<48;)await this.flush();if(0===this.remainingLength())return-1048576;const e=Math.min(Math.floor((this.remainingLength()-(this.ended?0:32))/c)*c,t.length);let i=await this.decrypt(e);return this.ended&&this.aesTargetDecryptor===this.aesSoftDecryptor&&(i=this.removePadding(i)),t.set(i),i.length}}},15433:(t,e,i)=>{"use strict";i.r(e),i.d(e,{default:()=>p});var s=i(134),a=i(80662),r=i.n(a),n=i(13724),o=i(82800),h=i(95335),l=i(8507),c=i(48182),u=i(77580),d=i(86932),T=i(4624),E=i(97801),f=i(67672);const A="src/avnetwork/ioLoader/HlsIOLoader.ts";class p extends o.A{constructor(...t){super(...t),(0,s.A)(this,"info",void 0),(0,s.A)(this,"range",void 0),(0,s.A)(this,"masterPlaylist",void 0),(0,s.A)(this,"mediaPlayList",void 0),(0,s.A)(this,"mediaPlayListIndex",void 0),(0,s.A)(this,"fetchedMap",void 0),(0,s.A)(this,"fetchedHistoryList",void 0),(0,s.A)(this,"mediaListUrl",void 0),(0,s.A)(this,"segmentIndex",void 0),(0,s.A)(this,"currentUri",void 0),(0,s.A)(this,"loader",void 0),(0,s.A)(this,"minBuffer",void 0),(0,s.A)(this,"keyMap",void 0),(0,s.A)(this,"currentIV",void 0),(0,s.A)(this,"currentKey",void 0),(0,s.A)(this,"aesDecryptPipe",void 0),(0,s.A)(this,"initLoaded",void 0)}getFetchParams(t="GET"){var e,i,s;const a={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};return null!==(e=this.info.httpOptions)&&void 0!==e&&e.headers&&h.__(this.info.httpOptions.headers,((t,e)=>{a.headers[e]=t})),null!==(i=this.info.httpOptions)&&void 0!==i&&i.credentials&&(a.credentials=this.info.httpOptions.credentials),null!==(s=this.info.httpOptions)&&void 0!==s&&s.referrerPolicy&&(a.referrerPolicy=this.info.httpOptions.referrerPolicy),a}async fetchMasterPlayList(){try{const e=await fetch(this.info.url,this.getFetchParams()),i=await e.text(),s=(0,c.A)(i);if(s.isMasterPlaylist)this.masterPlaylist=s;else{if(this.mediaPlayList=s,this.options.isLive&&(!this.mediaPlayList.segments||this.mediaPlayList.segments.length<2)){var t;let e=5;return null!==(t=this.mediaPlayList.segments)&&void 0!==t&&t.length&&(e=this.mediaPlayList.segments[0].duration*(2-this.mediaPlayList.segments.length)),T.R8(`wait for min buffer time, now segments: ${this.mediaPlayList.segments.length}`,A,119),await new n.A(e),this.fetchMasterPlayList()}this.minBuffer=this.mediaPlayList.duration||0,this.mediaPlayList.endlist&&(this.options.isLive=!1),this.mediaListUrl=this.info.url}return s}catch(t){if(this.retryCount<this.options.retryCount)return this.retryCount++,T.z3(`failed fetch m3u8 file, retry(${this.retryCount}/3)`,A,136),await new n.A(5),this.fetchMasterPlayList();this.status=3,T.h2("HLSLoader: exception, fetch slice error",A,142)}}async fetchMediaPlayList(){let t;if(this.masterPlaylist){const e=this.masterPlaylist.variants[this.mediaPlayListIndex];e||T.h2("no media playlist",A,154),t=e.uri}else t=this.mediaListUrl;/^https?/.test(t)||(t=l.ll(this.info.url,t)),this.mediaListUrl=t;try{const i=await fetch(t,this.getFetchParams()),s=await i.text();if(this.mediaPlayList=(0,c.A)(s),this.options.isLive&&(!this.mediaPlayList.segments||this.mediaPlayList.segments.length<2)){var e;let t=5;return null!==(e=this.mediaPlayList.segments)&&void 0!==e&&e.length&&(t=this.mediaPlayList.segments[0].duration*(2-this.mediaPlayList.segments.length)),T.R8(`wait for min buffer time, now segments: ${this.mediaPlayList.segments.length}`,A,178),await new n.A(t),this.fetchMediaPlayList()}return this.minBuffer=this.mediaPlayList.duration||0,this.mediaPlayList.endlist&&(this.options.isLive=!1),this.status=2,this.retryCount=0,this.mediaPlayList}catch(t){if(this.retryCount<this.options.retryCount)return this.retryCount++,T.z3(`failed fetch m3u8 file, retry(${this.retryCount}/3)`,A,197),await new n.A(this.options.retryInterval),this.fetchMasterPlayList();this.status=3,T.h2("HLSLoader: exception, fetch slice error",A,203)}}async open(t,e){return this.info=t,this.range=e,this.range.to||(this.range.to=-1),this.range.from=Math.max(this.range.from,0),this.mediaPlayListIndex=0,this.segmentIndex=0,this.fetchedMap=new(r()),this.fetchedHistoryList=[],this.status=1,this.retryCount=0,this.keyMap=new(r()),await this.fetchMasterPlayList(),!this.mediaPlayList&&this.masterPlaylist&&await this.fetchMediaPlayList(),this.initLoaded=!0,this.mediaPlayList.segments.length&&this.mediaPlayList.segments[0].map&&(this.initLoaded=!1),0}async checkNeedDecrypt(t,e){if(!t.key)return;const i=t.key.uri;if(this.keyMap.has(i)?this.currentKey=this.keyMap.get(i):(this.currentKey=await(await fetch((0,l.ll)(this.mediaListUrl,i),this.getFetchParams())).arrayBuffer(),this.keyMap.set(i,this.currentKey)),t.key.iv)this.currentIV=t.key.iv.buffer;else{const t=new Uint8Array(16);new DataView(t.buffer).setUint32(12,e,!1),this.currentIV=t.buffer}this.aesDecryptPipe=new E.A,this.aesDecryptPipe.onFlush=async t=>this.loader.read(t),await this.aesDecryptPipe.expandKey(this.currentKey,this.currentIV)}async read(t){let e=0;if(this.loader){if(e=this.aesDecryptPipe?await this.aesDecryptPipe.read(t):await this.loader.read(t),-1048576!==e)return e;if(this.initLoaded){if(this.options.isLive)this.fetchedMap.set(this.currentUri,!0),10===this.fetchedHistoryList.length&&this.fetchedMap.delete(this.fetchedHistoryList.shift()),this.fetchedHistoryList.push(this.currentUri),this.segmentIndex++;else if(this.segmentIndex++,this.segmentIndex>=this.mediaPlayList.segments.length)return T.pq("hls segments ended",A,299),this.status=4,-1048576}else this.initLoaded=!0;this.loader=null}if(this.options.isLive){const e=this.mediaPlayList.segments.filter((t=>!this.fetchedMap.get(t.uri)));if(!e.length){if(this.mediaPlayList.endlist)return this.status=4,-1048576;const e=(this.minBuffer-((0,d.A)()-this.mediaPlayList.timestamp)/1e3)/2;return e>0&&await new n.A(e),await this.fetchMediaPlayList(),this.read(t)}this.currentUri=e[0].uri,this.initLoaded&&await this.checkNeedDecrypt(e[0],this.segmentIndex),this.loader=new u.A(h.X$({},this.options,{disableSegment:!0,loop:!1}));const i=(0,l.ll)(this.mediaListUrl,this.initLoaded?this.currentUri:e[0].map.uri),s={from:0,to:-1},a=this.initLoaded?e[0].byterange:e[0].map.byterange;return a&&(s.from=a.offset,s.to=a.offset+a.length),await this.loader.open(h.X$({},this.info,{url:i}),s),this.aesDecryptPipe?this.aesDecryptPipe.read(t):this.loader.read(t)}{this.loader=new u.A(h.X$({},this.options,{disableSegment:!0,loop:!1}));let e=this.mediaPlayList.segments[this.segmentIndex];for(;!e.uri;)e=this.mediaPlayList.segments[++this.segmentIndex];this.initLoaded&&await this.checkNeedDecrypt(e,this.segmentIndex);const i=(0,l.ll)(this.mediaListUrl,this.initLoaded?e.uri:e.map.uri),s={from:0,to:-1},a=this.initLoaded?e.byterange:e.map.byterange;return a&&(s.from=a.offset,s.to=a.offset+a.length),await this.loader.open(h.X$({},this.info,{url:i}),s),this.aesDecryptPipe?this.aesDecryptPipe.read(t):this.loader.read(t)}}async seek(t){this.loader&&(await this.loader.abort(),this.loader=null);let e=0,i=Number(t),s=0;for(let t=0;t<this.mediaPlayList.segments.length;t++)if(f.ai(this.mediaPlayList.segments[t].duration)&&(e+=this.mediaPlayList.segments[t].duration,1e3*e>=i)){s=t;break}return this.segmentIndex=s,4===this.status&&(this.status=2),0}async size(){return BigInt(0)}async abort(){this.loader&&(await this.loader.abort(),this.loader=null)}async stop(){await this.abort(),this.status=0}getDuration(){return this.mediaPlayList.duration}getVideoList(){var t,e;return{list:null!==(t=null===(e=this.masterPlaylist)||void 0===e?void 0:e.variants.map((t=>{var e,i,s,a,r;return{width:null!==(e=null===(i=t.resolution)||void 0===i?void 0:i.width)&&void 0!==e?e:0,height:null!==(s=null===(a=t.resolution)||void 0===a?void 0:a.height)&&void 0!==s?s:0,frameRate:null!==(r=t.frameRate)&&void 0!==r?r:0,codecs:t.codecs}})))&&void 0!==t?t:[],selectedIndex:0}}selectVideo(t){this.mediaPlayListIndex=t,this.fetchMediaPlayList()}getMinBuffer(){return this.minBuffer}}},48182:(t,e,i)=>{"use strict";i.d(e,{A:()=>L});var s=i(7210),a=i.n(s),r=i(43929),n=i.n(r),o=i(69736),h=i.n(o),l=i(80662),c=i.n(l),u=i(67756),d=i(64608),T=i(4624);const E="src/avprotocol/m3u8/parser.ts";function f(t){return u.Bq(t,'"')}function A(t){const e=u.gI(t,",");return{duration:u.Ro(e[0]),title:decodeURIComponent(escape(e[1]))}}function p(t){const e=u.gI(t,"@");return{length:u.Ro(e[0]),offset:e[1]?u.Ro(e[1]):-1}}function m(t){const e=u.gI(t,"x");return{width:u.Ro(e[0]),height:u.Ro(e[1])}}function y(t){const e="ALLOWED-CPC: Each entry must consit of KEYFORMAT and Content Protection Configuration",i=t.split(",");0===i.length&&T.z3(e,E,102);const s=[];for(const t of i){const[i,a]=u.gI(t,":");i&&a?s.push({format:i,cpcList:a.split("/")}):T.z3(e,E,108)}return s}function g(t){const e=u.m2(t);return 16!==e.length&&T.z3("IV must be a 128-bit unsigned integer",E,119),e}function X(t,e){e.IV&&t.compatibleVersion<2&&(t.compatibleVersion=2),(e.KEYFORMAT||e.KEYFORMATVERSIONS)&&t.compatibleVersion<5&&(t.compatibleVersion=5)}function S(t){const e={};for(const s of u.HG(t)){const[t,a]=u.gI(s,"="),r=f(a);switch(t){case"URI":e[t]=r;break;case"START-DATE":case"END-DATE":e[t]=new Date(r);break;case"IV":e[t]=g(r);break;case"BYTERANGE":e[t]=p(r);break;case"RESOLUTION":e[t]=m(r);break;case"ALLOWED-CPC":e[t]=y(r);break;case"END-ON-NEXT":case"DEFAULT":case"AUTOSELECT":case"FORCED":case"PRECISE":case"CAN-BLOCK-RELOAD":case"INDEPENDENT":case"GAP":e[t]="YES"===r;break;case"DURATION":case"PLANNED-DURATION":case"BANDWIDTH":case"AVERAGE-BANDWIDTH":case"FRAME-RATE":case"TIME-OFFSET":case"CAN-SKIP-UNTIL":case"HOLD-BACK":case"PART-HOLD-BACK":case"PART-TARGET":case"BYTERANGE-START":case"BYTERANGE-LENGTH":case"LAST-MSN":case"LAST-PART":case"SKIPPED-SEGMENTS":case"SCORE":case"PROGRAM-ID":e[t]=u.Ro(r);break;default:t.startsWith("SCTE35-")?e[t]=u.m2(r):t.startsWith("X-")?e[t]=(i=a).startsWith('"')?f(i):i.startsWith("0x")||i.startsWith("0X")?u.m2(i):u.Ro(i):("VIDEO-RANGE"===t&&"SDR"!==r&&"HLG"!==r&&"PQ"!==r&&T.h2(`VIDEO-RANGE: unknown value "${r}"`,E,206),e[t]=r)}}var i;return e}function I(t,e,i){const s=function({attributes:t}){return new d.ru({type:t.TYPE,uri:t.URI,groupId:t["GROUP-ID"],language:t.LANGUAGE,assocLanguage:t["ASSOC-LANGUAGE"],name:t.NAME,isDefault:t.DEFAULT,autoselect:t.AUTOSELECT,forced:t.FORCED,instreamId:t["INSTREAM-ID"],characteristics:t.CHARACTERISTICS,channels:t.CHANNELS})}(e),a=t[u.Th(i)],r=function(t,e){let i=!1;for(const s of t){if(s.name===e.name)return"All EXT-X-MEDIA tags in the same Group MUST have different NAME attributes.";s.isDefault&&(i=!0)}return i&&e.isDefault?"EXT-X-MEDIA A Group MUST NOT have more than one member with a DEFAULT attribute of YES.":""}(a,s);r&&T.h2(r,E,315),a.push(s),s.isDefault&&(t.currentRenditions[u.Th(i)]=a.length-1)}function N(t,e,i,s,a){const r=new d.KT({uri:i,bandwidth:e.BANDWIDTH,averageBandwidth:e["AVERAGE-BANDWIDTH"],score:e.SCORE,codecs:e.CODECS,resolution:e.RESOLUTION,frameRate:e["FRAME-RATE"],hdcpLevel:e["HDCP-LEVEL"],allowedCpc:e["ALLOWED-CPC"],videoRange:e["VIDEO-RANGE"],stableVariantId:e["STABLE-VARIANT-ID"],programId:e["PROGRAM-ID"]});for(const i of t)if("EXT-X-MEDIA"===i.name){const t=i.attributes,s=t.TYPE;if(s&&t["GROUP-ID"]||T.h2("EXT-X-MEDIA TYPE attribute is REQUIRED.",E,355),e[s]===t["GROUP-ID"]&&(I(r,i,s),"CLOSED-CAPTIONS"===s))for(const{instreamId:t}of r.closedCaptions)if(t&&t.startsWith("SERVICE")&&a.compatibleVersion<7){a.compatibleVersion=7;break}}return function(t,e,i){for(const s of["AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS"])"CLOSED-CAPTIONS"===s&&"NONE"===t[s]?(i.isClosedCaptionsNone=!0,e.closedCaptions=[]):t[s]&&!e[u.Th(s)].some((e=>e.groupId===t[s]))&&T.h2(`${s} attribute MUST match the value of the GROUP-ID attribute of an EXT-X-MEDIA tag whose TYPE attribute is ${s}.`,E,330)}(e,r,a),r.isIFrameOnly=s,r}function v(t,e){if(t.method!==e.method)return!1;if(t.uri!==e.uri)return!1;if(t.iv){if(!e.iv)return!1;if(t.iv.length!==e.iv.length)return!1;for(let i=0;i<t.iv.length;i++)if(t.iv[i]!==e.iv[i])return!1}else if(e.iv)return!1;return t.format===e.format&&t.formatVersion===e.formatVersion}function R(t,e,i,s,a,r,o){const l=new d.Y4({uri:e,mediaSequenceNumber:a,discontinuitySequence:r});let c=!1,u=!1;for(let e=i;e<=s;e++){const{name:i,value:s,attributes:a}=t[e];if("EXTINF"===i)!n()(s.duration)&&o.compatibleVersion<3&&(o.compatibleVersion=3),Math.round(s.duration)>o.targetDuration&&T.h2("EXTINF duration, when rounded to the nearest integer, MUST be less than or equal to the target duration",E,517),l.duration=s.duration,l.title=s.title;else if("EXT-X-BYTERANGE"===i)o.compatibleVersion<4&&(o.compatibleVersion=4),l.byterange=s;else if("EXT-X-DISCONTINUITY"===i)l.parts.length>0&&T.h2("EXT-X-DISCONTINUITY must appear before the first EXT-X-PART tag of the Parent Segment.",E,530),l.discontinuity=!0;else if("EXT-X-KEY"===i)l.parts.length>0&&T.h2("EXT-X-KEY must appear before the first EXT-X-PART tag of the Parent Segment.",E,536),"NONE"!==a.METHOD&&(X(o,a),l.key=new d.Uz({method:a.METHOD,uri:a.URI,iv:a.IV,format:a.KEYFORMAT,formatVersion:a.KEYFORMATVERSIONS}));else if("EXT-X-MAP"===i)l.parts.length>0&&T.h2("EXT-X-MAP must appear before the first EXT-X-PART tag of the Parent Segment.",E,552),o.compatibleVersion<5&&(o.compatibleVersion=5),o.hasMap=!0,l.map=new d.qP({uri:a.URI,byterange:a.BYTERANGE});else if("EXT-X-PROGRAM-DATE-TIME"===i)l.programDateTime=s;else if("EXT-X-DATERANGE"===i){const t={};for(const e of h()(a))(e.startsWith("SCTE35-")||e.startsWith("X-"))&&(t[e]=a[e]);l.dateRange=new d.ad({id:a.ID,classId:a.CLASS,start:a["START-DATE"],end:a["END-DATE"],duration:a.DURATION,plannedDuration:a["PLANNED-DURATION"],endOnNext:a["END-ON-NEXT"],attributes:t})}else if("EXT-X-CUE-OUT"===i)l.markers.push(new d.xC({type:"OUT",duration:a&&a.DURATION||s}));else if("EXT-X-CUE-IN"===i)l.markers.push(new d.xC({type:"IN"}));else if("EXT-X-CUE-OUT-CONT"===i||"EXT-X-CUE"===i||"EXT-OATCLS-SCTE35"===i||"EXT-X-ASSET"===i||"EXT-X-SCTE35"===i)l.markers.push(new d.xC({type:"RAW",tagName:i,value:s}));else if("EXT-X-PRELOAD-HINT"!==i||a.TYPE)if("EXT-X-PRELOAD-HINT"===i&&"PART"===a.TYPE&&u)T.h2("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.",E,612);else if("EXT-X-PART"!==i&&"EXT-X-PRELOAD-HINT"!==i||a.URI){if("EXT-X-PRELOAD-HINT"===i&&"MAP"===a.TYPE)c&&T.h2("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.",E,619),c=!0,o.hasMap=!0,l.map=new d.qP({hint:!0,uri:a.URI,byterange:{length:a["BYTERANGE-LENGTH"],offset:a["BYTERANGE-START"]||0}});else if("EXT-X-PART"===i||"EXT-X-PRELOAD-HINT"===i&&"PART"===a.TYPE){"EXT-X-PART"!==i||a.DURATION||T.h2("EXT-X-PART: DURATION attribute is mandatory",E,631),"EXT-X-PRELOAD-HINT"===i&&(u=!0);const t=new d.nw({hint:"EXT-X-PRELOAD-HINT"===i,uri:a.URI,byterange:"EXT-X-PART"===i?a.BYTERANGE:{length:a["BYTERANGE-LENGTH"],offset:a["BYTERANGE-START"]||0},duration:a.DURATION,independent:a.INDEPENDENT,gap:a.GAP});l.parts.push(t)}}else T.h2("EXT-X-PART / EXT-X-PRELOAD-HINT: URI attribute is mandatory",E,615);else T.h2("EXT-X-PRELOAD-HINT: TYPE attribute is mandatory",E,609)}return l}function P(t,e,i,s,a,r,n){const o=new d.Vd({uri:e,mediaSequenceNumber:a,discontinuitySequence:r});for(let e=i;e<=s;e++){const{name:i,attributes:s}=t[e];"EXTINF"===i?T.h2("A prefetch segment must not be advertised with an EXTINF tag.",E,663):"EXT-X-DISCONTINUITY"===i?T.h2("A prefetch segment must not be advertised with an EXT-X-DISCONTINUITY tag.",E,666):"EXT-X-PREFETCH-DISCONTINUITY"===i?o.discontinuity=!0:"EXT-X-KEY"===i?"NONE"!==s.METHOD&&(X(n,s),o.key=new d.Uz({method:s.METHOD,uri:s.URI,iv:s.IV,format:s.KEYFORMAT,formatVersion:s.KEYFORMATVERSIONS})):"EXT-X-MAP"===i&&T.h2("Prefetch segments must not be advertised with an EXT-X-MAP tag.",E,684)}return o}function D(t,e,i,s,a){const{discontinuity:r,key:n,map:o,byterange:h,uri:l}=e;if(r&&(e.discontinuitySequence=i+1),n||(e.key=s),o||(e.map=a),h&&-1===h.offset){const{segments:e}=t;if(e.length>0){const t=e[e.length-1];t.byterange&&t.uri===l?h.offset=t.byterange.offset+t.byterange.length:T.h2("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST be a sub-range of the same media resource",E,900)}else T.h2("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST appear in the Playlist file",E,904)}return t.segments.push(e),[e.discontinuitySequence,e.key,e.map]}function b(t,e){const[i,s]=function(t){const e=t.indexOf(":");return-1===e?[t.slice(1).trim(),null]:[t.slice(1,e).trim(),t.slice(e+1).trim()]}(t),r=function(t){switch(t){case"EXTM3U":case"EXT-X-VERSION":return"Basic";case"EXTINF":case"EXT-X-BYTERANGE":case"EXT-X-DISCONTINUITY":case"EXT-X-PREFETCH-DISCONTINUITY":case"EXT-X-KEY":case"EXT-X-MAP":case"EXT-X-PROGRAM-DATE-TIME":case"EXT-X-DATERANGE":case"EXT-X-CUE-OUT":case"EXT-X-CUE-IN":case"EXT-X-CUE-OUT-CONT":case"EXT-X-CUE":case"EXT-OATCLS-SCTE35":case"EXT-X-ASSET":case"EXT-X-SCTE35":case"EXT-X-PART":case"EXT-X-PRELOAD-HINT":return"Segment";case"EXT-X-TARGETDURATION":case"EXT-X-MEDIA-SEQUENCE":case"EXT-X-DISCONTINUITY-SEQUENCE":case"EXT-X-ENDLIST":case"EXT-X-PLAYLIST-TYPE":case"EXT-X-I-FRAMES-ONLY":case"EXT-X-SERVER-CONTROL":case"EXT-X-PART-INF":case"EXT-X-PREFETCH":case"EXT-X-RENDITION-REPORT":case"EXT-X-SKIP":return"MediaPlaylist";case"EXT-X-MEDIA":case"EXT-X-STREAM-INF":case"EXT-X-I-FRAME-STREAM-INF":case"EXT-X-SESSION-DATA":case"EXT-X-SESSION-KEY":return"MasterPlaylist";case"EXT-X-INDEPENDENT-SEGMENTS":case"EXT-X-START":return"MediaorMasterPlaylist";default:return"Unknown"}}(i);if(function(t,e){if("Segment"===t||"MediaPlaylist"===t)return void 0===e.isMasterPlaylist?void(e.isMasterPlaylist=!1):void(e.isMasterPlaylist&&T.h2("The file contains both media and master playlist tags.",E,1011));if("MasterPlaylist"===t){if(void 0===e.isMasterPlaylist)return void(e.isMasterPlaylist=!0);!1===e.isMasterPlaylist&&T.h2("The file contains both media and master playlist tags.",E,1021)}}(r,e),"Unknown"===r)return null;"MediaPlaylist"===r&&"EXT-X-RENDITION-REPORT"!==i&&"EXT-X-PREFETCH"!==i&&(e.hash[i]&&T.h2("There MUST NOT be more than one Media Playlist tag of each type in any Media Playlist",E,1042),e.hash[i]=!0);const[n,o]=function(t,e){switch(t){case"EXTM3U":case"EXT-X-DISCONTINUITY":case"EXT-X-ENDLIST":case"EXT-X-I-FRAMES-ONLY":case"EXT-X-INDEPENDENT-SEGMENTS":case"EXT-X-CUE-IN":return[null,null];case"EXT-X-VERSION":case"EXT-X-TARGETDURATION":case"EXT-X-MEDIA-SEQUENCE":case"EXT-X-DISCONTINUITY-SEQUENCE":return[u.Ro(e),null];case"EXT-X-CUE-OUT":return a()(Number(e))?[null,S(e)]:[u.Ro(e),null];case"EXT-X-KEY":case"EXT-X-MAP":case"EXT-X-DATERANGE":case"EXT-X-MEDIA":case"EXT-X-STREAM-INF":case"EXT-X-I-FRAME-STREAM-INF":case"EXT-X-SESSION-DATA":case"EXT-X-SESSION-KEY":case"EXT-X-START":case"EXT-X-SERVER-CONTROL":case"EXT-X-PART-INF":case"EXT-X-PART":case"EXT-X-PRELOAD-HINT":case"EXT-X-RENDITION-REPORT":case"EXT-X-SKIP":return[null,S(e)];case"EXTINF":return[A(e),null];case"EXT-X-BYTERANGE":return[p(e),null];case"EXT-X-PROGRAM-DATE-TIME":return[new Date(e),null];default:return[e,null]}}(i,s);return{name:i,category:r,value:n,attributes:o}}function O(t,e){let i;return e.isMasterPlaylist?i=function(t,e){const i=new d.ts;let s=!1;for(const[a,{name:r,value:n,attributes:o}]of t.entries())if("EXT-X-VERSION"===r)i.version=n;else if("EXT-X-STREAM-INF"===r){const r=t[a+1];("string"!=typeof r||r.startsWith("#EXT"))&&T.h2("EXT-X-STREAM-INF must be followed by a URI line",E,417);const n=N(t,o,r,!1,e);n&&("number"==typeof n.score&&(s=!0,n.score<0&&T.h2("SCORE attribute on EXT-X-STREAM-INF must be positive decimal-floating-point number.",E,424)),i.variants.push(n))}else if("EXT-X-I-FRAME-STREAM-INF"===r){const s=N(t,o,o.URI,!0,e);s&&i.variants.push(s)}else if("EXT-X-SESSION-DATA"===r){const t=new d.pf({id:o["DATA-ID"],value:o.VALUE,uri:o.URI,language:o.LANGUAGE});i.sessionDataList.some((e=>e.id===t.id&&e.language===t.language))&&T.h2("A Playlist MUST NOT contain more than one EXT-X-SESSION-DATA tag with the same DATA-ID attribute and the same LANGUAGE attribute.",E,444),i.sessionDataList.push(t)}else if("EXT-X-SESSION-KEY"===r){"NONE"===o.METHOD&&T.h2("EXT-X-SESSION-KEY: The value of the METHOD attribute MUST NOT be NONE",E,450);const t=new d.Uz({method:o.METHOD,uri:o.URI,iv:o.IV,format:o.KEYFORMAT,formatVersion:o.KEYFORMATVERSIONS});i.sessionKeyList.some((e=>v(e,t)))&&T.h2("A Master Playlist MUST NOT contain more than one EXT-X-SESSION-KEY tag with the same METHOD, URI, IV, KEYFORMAT, and KEYFORMATVERSIONS attribute values.",E,460),X(e,o),i.sessionKeyList.push(t)}else"EXT-X-INDEPENDENT-SEGMENTS"===r?(i.independentSegments&&T.h2("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist",E,467),i.independentSegments=!0):"EXT-X-START"===r&&(i.start&&T.h2("EXT-X-START tag MUST NOT appear more than once in a Playlist",E,473),"number"!=typeof o["TIME-OFFSET"]&&T.h2("EXT-X-START: TIME-OFFSET attribute is REQUIRED",E,476),i.start={offset:o["TIME-OFFSET"],precise:o.PRECISE||!1});if(s)for(const t of i.variants)"number"!=typeof t.score&&T.h2("If any Variant Stream contains the SCORE attribute, then all Variant Streams in the Master Playlist SHOULD have a SCORE attribute",E,484);if(e.isClosedCaptionsNone)for(const t of i.variants)t.closedCaptions.length>0&&T.h2("If there is a variant with CLOSED-CAPTIONS attribute of NONE, all EXT-X-STREAM-INF tags MUST have this attribute with a value of NONE",E,491);return i}(t,e):(i=function(t,e){const i=new d.tk;let s=-1,a=0,r=!1,n=!1,o=0,h=null,l=null,u=!1;for(const[c,f]of t.entries()){const{name:A,value:p,attributes:m,category:y}=f;if("Segment"!==y){if("EXT-X-VERSION"===A)void 0===i.version?i.version=p:T.h2("A Playlist file MUST NOT contain more than one EXT-X-VERSION tag.",E,716);else if("EXT-X-TARGETDURATION"===A)i.targetDuration=e.targetDuration=p;else if("EXT-X-MEDIA-SEQUENCE"===A)i.segments.length>0&&T.h2("The EXT-X-MEDIA-SEQUENCE tag MUST appear before the first Media Segment in the Playlist.",E,724),i.mediaSequenceBase=a=p;else if("EXT-X-DISCONTINUITY-SEQUENCE"===A)i.segments.length>0&&T.h2("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before the first Media Segment in the Playlist.",E,730),r&&T.h2("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before any EXT-X-DISCONTINUITY tag.",E,733),i.discontinuitySequenceBase=o=p;else if("EXT-X-ENDLIST"===A)i.endlist=!0;else if("EXT-X-PLAYLIST-TYPE"===A)i.playlistType=p;else if("EXT-X-I-FRAMES-ONLY"===A)e.compatibleVersion<4&&(e.compatibleVersion=4),i.isIFrame=!0;else if("EXT-X-INDEPENDENT-SEGMENTS"===A)i.independentSegments&&T.h2("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist",E,751),i.independentSegments=!0;else if("EXT-X-START"===A)i.start&&T.h2("EXT-X-START tag MUST NOT appear more than once in a Playlist",E,757),"number"!=typeof m["TIME-OFFSET"]&&T.h2("EXT-X-START: TIME-OFFSET attribute is REQUIRED",E,760),i.start={offset:m["TIME-OFFSET"],precise:m.PRECISE||!1};else if("EXT-X-SERVER-CONTROL"===A)m["CAN-BLOCK-RELOAD"]||T.h2("EXT-X-SERVER-CONTROL: CAN-BLOCK-RELOAD=YES is mandatory for Low-Latency HLS",E,766),i.lowLatencyCompatibility={canBlockReload:m["CAN-BLOCK-RELOAD"],canSkipUntil:m["CAN-SKIP-UNTIL"],holdBack:m["HOLD-BACK"],partHoldBack:m["PART-HOLD-BACK"]};else if("EXT-X-PART-INF"===A)m["PART-TARGET"]||T.h2("EXT-X-PART-INF: PART-TARGET attribute is mandatory",E,777),i.partTargetDuration=m["PART-TARGET"];else if("EXT-X-RENDITION-REPORT"===A)m.URI||T.h2("EXT-X-RENDITION-REPORT: URI attribute is mandatory",E,783),0===m.URI.search(/^[a-z]+:/)&&T.h2("EXT-X-RENDITION-REPORT: URI must be relative to the playlist uri",E,786),i.renditionReports.push(new d.h4({uri:m.URI,lastMSN:m["LAST-MSN"],lastPart:m["LAST-PART"]}));else if("EXT-X-SKIP"===A)m["SKIPPED-SEGMENTS"]||T.h2("EXT-X-SKIP: SKIPPED-SEGMENTS attribute is mandatory",E,796),e.compatibleVersion<9&&(e.compatibleVersion=9),i.skip=m["SKIPPED-SEGMENTS"],a+=i.skip;else if("EXT-X-PREFETCH"===A){const r=P(t,p,-1===s?c:s,c-1,a++,o,e);r&&(r.discontinuity&&(r.discontinuitySequence++,o=r.discontinuitySequence),r.key?h=r.key:r.key=h,i.prefetchSegments.push(r)),n=!0,s=-1}else if("string"==typeof f){-1===s&&T.h2("A URI line is not preceded by any segment tags",E,833),i.targetDuration||T.h2("The EXT-X-TARGETDURATION tag is REQUIRED",E,836),n&&T.h2("These segments must appear after all complete segments.",E,839);const r=R(t,f,s,c-1,a++,o,e);r&&([o,h,l]=D(i,r,o,h,l),!u&&r.parts.length>0&&(u=!0)),s=-1}}else-1===s&&(s=c),"EXT-X-DISCONTINUITY"===A&&(r=!0)}if(-1!==s){const r=R(t,"",s,t.length-1,a++,o,e);if(r){var f;const{parts:t}=r;!(t.length>0)||i.endlist||null!==(f=t[t.length-1])&&void 0!==f&&f.hint||T.h2("If the Playlist contains EXT-X-PART tags and does not contain an EXT-X-ENDLIST tag, the Playlist must contain an EXT-X-PRELOAD-HINT tag with a TYPE=PART attribute",E,856),D(i,r,h,l),!u&&r.parts.length>0&&(u=!0)}}return function(t){const e=new(c()),i=new(c());let s=!1,a=!1;for(let r=t.length-1;r>=0;r--){const{programDateTime:n,dateRange:o}=t[r];if(n&&(a=!0),o&&o.start){s=!0,o.endOnNext&&(o.end||o.duration)&&T.h2("An EXT-X-DATERANGE tag with an END-ON-NEXT=YES attribute MUST NOT contain DURATION or END-DATE attributes.",E,924);const t=o.start.getTime(),a=o.duration||0;o.end&&o.duration&&t+1e3*a!==o.end.getTime()&&T.h2("END-DATE MUST be equal to the value of the START-DATE attribute plus the value of the DURATION",E,930),o.endOnNext&&(o.end=e.get(o.classId)),e.set(o.classId,o.start);const r=o.end?o.end.getTime():o.start.getTime()+1e3*(o.duration||0),n=i.get(o.classId);if(n){for(const e of n)(e.start<=t&&e.end>t||e.start>=t&&e.start<r)&&T.h2("DATERANGE tags with the same CLASS should not overlap",E,942);n.push({start:t,end:r})}else o.classId&&i.set(o.classId,[{start:t,end:r}])}}s&&!a&&T.h2("If a Playlist contains an EXT-X-DATERANGE tag, it MUST also contain at least one EXT-X-PROGRAM-DATE-TIME tag.",E,953)}(i.segments),i.lowLatencyCompatibility&&function({lowLatencyCompatibility:t,targetDuration:e,partTargetDuration:i,segments:s,renditionReports:a},r){const{canSkipUntil:n,holdBack:o,partHoldBack:h}=t;if(n<6*e&&T.h2("The Skip Boundary must be at least six times the EXT-X-TARGETDURATION.",E,960),o<3*e&&T.h2("HOLD-BACK must be at least three times the EXT-X-TARGETDURATION.",E,964),r){void 0===i&&T.h2("EXT-X-PART-INF is required if a Playlist contains one or more EXT-X-PART tags",E,968),void 0===h&&T.h2("EXT-X-PART: PART-HOLD-BACK attribute is mandatory",E,971),h<i&&T.h2("PART-HOLD-BACK must be at least PART-TARGET",E,974);for(const[t,{parts:e}]of s.entries()){e.length>0&&t<s.length-3&&T.h2("Remove EXT-X-PART tags from the Playlist after they are greater than three target durations from the end of the Playlist.",E,978);for(const[t,{duration:s}]of e.entries())void 0!==s&&(s>i&&T.h2("PART-TARGET is the maximum duration of any Partial Segment",E,985),t<e.length-1&&s<.85*i&&T.h2("All Partial Segments except the last part of a segment must have a duration of at least 85% of PART-TARGET",E,988))}}for(const t of a){const e=s[s.length-1];null!==t.lastMSN&&void 0!==t.lastMSN||(t.lastMSN=e.mediaSequenceNumber),(null===t.lastPart||void 0===t.lastPart)&&e.parts.length>0&&(t.lastPart=e.parts.length-1)}}(i,u),i.duration=i.segments.reduce(((t,e)=>"number"==typeof e.duration?t+e.duration:t),0),i}(t,e),!i.isIFrame&&e.hasMap&&e.compatibleVersion<6&&(e.compatibleVersion=6)),e.compatibleVersion>1&&(!i.version||i.version<e.compatibleVersion)&&T.h2(`EXT-X-VERSION needs to be ${e.compatibleVersion} or higher.`,E,1092),i}function L(t){const e={version:void 0,isMasterPlaylist:void 0,hasMap:!1,targetDuration:0,compatibleVersion:1,isClosedCaptionsNone:!1,hash:{}},i=function(t,e){const i=[];for(const s of t.split("\n")){const t=s.trim();if(t)if(t.startsWith("#")){if(t.startsWith("#EXT")){const s=b(t,e);s&&i.push(s)}}else i.push(t)}return 0!==i.length&&"EXTM3U"===i[0].name||T.h2("The EXTM3U tag MUST be the first line.",E,1074),i}(t,e),s=O(i,e);return s.source=t,s}},64608:(t,e,i)=>{"use strict";i.d(e,{KT:()=>n,Uz:()=>h,Vd:()=>m,Y4:()=>A,ad:()=>c,h4:()=>y,nw:()=>p,pf:()=>o,qP:()=>l,ru:()=>r,tk:()=>f,ts:()=>E,xC:()=>u});var s=i(134),a=i(86932);class r{constructor({type:t,uri:e,groupId:i,language:a,assocLanguage:r,name:n,isDefault:o,autoselect:h,forced:l,instreamId:c,characteristics:u,channels:d}){(0,s.A)(this,"type",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"groupId",void 0),(0,s.A)(this,"language",void 0),(0,s.A)(this,"assocLanguage",void 0),(0,s.A)(this,"name",void 0),(0,s.A)(this,"isDefault",void 0),(0,s.A)(this,"autoselect",void 0),(0,s.A)(this,"forced",void 0),(0,s.A)(this,"instreamId",void 0),(0,s.A)(this,"characteristics",void 0),(0,s.A)(this,"channels",void 0),this.type=t,this.uri=e,this.groupId=i,this.language=a,this.assocLanguage=r,this.name=n,this.isDefault=o,this.autoselect=h,this.forced=l,this.instreamId=c,this.characteristics=u,this.channels=d}}class n{constructor({uri:t,isIFrameOnly:e=!1,bandwidth:i,averageBandwidth:a,score:r,codecs:n,resolution:o,frameRate:h,hdcpLevel:l,allowedCpc:c,videoRange:u,stableVariantId:d,programId:T,audio:E=[],video:f=[],subtitles:A=[],closedCaptions:p=[],currentRenditions:m={audio:0,video:0,subtitles:0,closedCaptions:0}}){(0,s.A)(this,"uri",void 0),(0,s.A)(this,"isIFrameOnly",void 0),(0,s.A)(this,"bandwidth",void 0),(0,s.A)(this,"averageBandwidth",void 0),(0,s.A)(this,"score",void 0),(0,s.A)(this,"codecs",void 0),(0,s.A)(this,"resolution",void 0),(0,s.A)(this,"frameRate",void 0),(0,s.A)(this,"hdcpLevel",void 0),(0,s.A)(this,"allowedCpc",void 0),(0,s.A)(this,"videoRange",void 0),(0,s.A)(this,"stableVariantId",void 0),(0,s.A)(this,"programId",void 0),(0,s.A)(this,"audio",void 0),(0,s.A)(this,"video",void 0),(0,s.A)(this,"subtitles",void 0),(0,s.A)(this,"closedCaptions",void 0),(0,s.A)(this,"currentRenditions",void 0),this.uri=t,this.isIFrameOnly=e,this.bandwidth=i,this.averageBandwidth=a,this.score=r,this.codecs=n,this.resolution=o,this.frameRate=h,this.hdcpLevel=l,this.allowedCpc=c,this.videoRange=u,this.stableVariantId=d,this.programId=T,this.audio=E,this.video=f,this.subtitles=A,this.closedCaptions=p,this.currentRenditions=m}}class o{constructor({id:t,value:e,uri:i,language:a}){(0,s.A)(this,"id",void 0),(0,s.A)(this,"value",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"language",void 0),this.id=t,this.value=e,this.uri=i,this.language=a}}class h{constructor({method:t,uri:e,iv:i,format:a,formatVersion:r}){(0,s.A)(this,"method",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"iv",void 0),(0,s.A)(this,"format",void 0),(0,s.A)(this,"formatVersion",void 0),this.method=t,this.uri=e,this.iv=i,this.format=a,this.formatVersion=r}}class l{constructor({hint:t=!1,uri:e,mimeType:i,byterange:a}){(0,s.A)(this,"hint",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"mimeType",void 0),(0,s.A)(this,"byterange",void 0),this.hint=t,this.uri=e,this.mimeType=i,this.byterange=a}}class c{constructor({id:t,classId:e,start:i,end:a,duration:r,plannedDuration:n,endOnNext:o,attributes:h={}}){(0,s.A)(this,"id",void 0),(0,s.A)(this,"classId",void 0),(0,s.A)(this,"start",void 0),(0,s.A)(this,"end",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"plannedDuration",void 0),(0,s.A)(this,"endOnNext",void 0),(0,s.A)(this,"attributes",void 0),this.id=t,this.classId=e,this.start=i,this.end=a,this.duration=r,this.plannedDuration=n,this.endOnNext=o,this.attributes=h}}class u{constructor({type:t,duration:e,tagName:i,value:a}){(0,s.A)(this,"type",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"tagName",void 0),(0,s.A)(this,"value",void 0),this.type=t,this.duration=e,this.tagName=i,this.value=a}}class d{constructor(t){(0,s.A)(this,"type",void 0),this.type=t}}class T extends d{constructor({isMasterPlaylist:t,uri:e,version:i,independentSegments:a=!1,start:r,source:n}){super("playlist"),(0,s.A)(this,"isMasterPlaylist",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"independentSegments",void 0),(0,s.A)(this,"start",void 0),(0,s.A)(this,"source",void 0),this.isMasterPlaylist=t,this.uri=e,this.version=i,this.independentSegments=a,this.start=r,this.source=n}}class E extends T{constructor(t={}){super({...t,isMasterPlaylist:!0}),(0,s.A)(this,"variants",void 0),(0,s.A)(this,"currentVariant",void 0),(0,s.A)(this,"sessionDataList",void 0),(0,s.A)(this,"sessionKeyList",void 0);const{variants:e=[],currentVariant:i,sessionDataList:a=[],sessionKeyList:r=[]}=t;this.variants=e,this.currentVariant=i,this.sessionDataList=a,this.sessionKeyList=r}}class f extends T{constructor(t={}){super({...t,isMasterPlaylist:!1}),(0,s.A)(this,"targetDuration",void 0),(0,s.A)(this,"mediaSequenceBase",void 0),(0,s.A)(this,"discontinuitySequenceBase",void 0),(0,s.A)(this,"endlist",void 0),(0,s.A)(this,"playlistType",void 0),(0,s.A)(this,"isIFrame",void 0),(0,s.A)(this,"segments",void 0),(0,s.A)(this,"prefetchSegments",void 0),(0,s.A)(this,"lowLatencyCompatibility",void 0),(0,s.A)(this,"partTargetDuration",void 0),(0,s.A)(this,"renditionReports",void 0),(0,s.A)(this,"skip",void 0),(0,s.A)(this,"hash",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"timestamp",void 0);const{targetDuration:e,mediaSequenceBase:i=0,discontinuitySequenceBase:r=0,endlist:n=!1,playlistType:o,isIFrame:h,segments:l=[],prefetchSegments:c=[],lowLatencyCompatibility:u,partTargetDuration:d,renditionReports:T=[],skip:E=0,hash:f,duration:A=0}=t;this.targetDuration=e,this.mediaSequenceBase=i,this.discontinuitySequenceBase=r,this.endlist=n,this.playlistType=o,this.isIFrame=h,this.segments=l,this.prefetchSegments=c,this.lowLatencyCompatibility=u,this.partTargetDuration=d,this.renditionReports=T,this.skip=E,this.hash=f,this.duration=A,this.timestamp=(0,a.A)()}}class A extends d{constructor({uri:t,mimeType:e,data:i,duration:a,title:r,byterange:n,discontinuity:o,mediaSequenceNumber:h=0,discontinuitySequence:l=0,key:c,map:u,programDateTime:d,dateRange:T,markers:E=[],parts:f=[]}){super("segment"),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"mimeType",void 0),(0,s.A)(this,"data",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"title",void 0),(0,s.A)(this,"byterange",void 0),(0,s.A)(this,"discontinuity",void 0),(0,s.A)(this,"mediaSequenceNumber",void 0),(0,s.A)(this,"discontinuitySequence",void 0),(0,s.A)(this,"key",void 0),(0,s.A)(this,"map",void 0),(0,s.A)(this,"programDateTime",void 0),(0,s.A)(this,"dateRange",void 0),(0,s.A)(this,"markers",void 0),(0,s.A)(this,"parts",void 0),this.uri=t,this.mimeType=e,this.data=i,this.duration=a,this.title=r,this.byterange=n,this.discontinuity=o,this.mediaSequenceNumber=h,this.discontinuitySequence=l,this.key=c,this.map=u,this.programDateTime=d,this.dateRange=T,this.markers=E,this.parts=f}}class p extends d{constructor({hint:t=!1,uri:e,duration:i,independent:a,byterange:r,gap:n}){super("part"),(0,s.A)(this,"hint",void 0),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"independent",void 0),(0,s.A)(this,"byterange",void 0),(0,s.A)(this,"gap",void 0),this.hint=t,this.uri=e,this.duration=i,this.independent=a,this.duration=i,this.byterange=r,this.gap=n}}class m extends d{constructor({uri:t,discontinuity:e,mediaSequenceNumber:i=0,discontinuitySequence:a=0,key:r}){super("prefetch"),(0,s.A)(this,"uri",void 0),(0,s.A)(this,"discontinuity",void 0),(0,s.A)(this,"mediaSequenceNumber",void 0),(0,s.A)(this,"discontinuitySequence",void 0),(0,s.A)(this,"key",void 0),this.uri=t,this.discontinuity=e,this.mediaSequenceNumber=i,this.discontinuitySequence=a,this.key=r}}class y{constructor({uri:t,lastMSN:e,lastPart:i}){(0,s.A)(this,"uri",void 0),(0,s.A)(this,"lastMSN",void 0),(0,s.A)(this,"lastPart",void 0),this.uri=t,this.lastMSN=e,this.lastPart=i}}},67756:(t,e,i)=>{"use strict";i.d(e,{Bq:()=>d,HG:()=>T,Ro:()=>l,Th:()=>E,gI:()=>u,m2:()=>c});var s=i(99704),a=i.n(s),r=i(17735),n=i.n(r),o=i(7210),h=i.n(o);function l(t,e=10){if("number"==typeof t)return t;const i=10===e?a()(t):n()(t,e);return h()(i)?0:i}function c(t){(t.startsWith("0x")||t.startsWith("0X"))&&(t=t.slice(2));const e=[];for(let i=0;i<t.length;i+=2)e.push(l(t.slice(i,i+2),16));return new Uint8Array(e)}function u(t,e,i=0){let s=-1;for(let a=0,r=0;a<t.length;a++)if(t[a]===e){if(r++===i)return[t.slice(0,a),t.slice(a+1)];s=a}return-1!==s?[t.slice(0,s),t.slice(s+1)]:[t]}function d(t,e=" "){return t?(t=t.trim()," "===e||(t.startsWith(e)&&(t=t.slice(1)),t.endsWith(e)&&(t=t.slice(0,-1))),t):t}function T(t){const e=[];let i=!0,s=0;const a=[];for(let r=0;r<t.length;r++){const n=t[r];i&&","===n?(e.push(t.slice(s,r).trim()),s=r+1):'"'!==n&&"'"!==n||(i?(a.push(n),i=!1):n===a[a.length-1]?(a.pop(),i=!0):a.push(n))}return e.push(t.slice(s).trim()),e}function E(t){const e=[];let i=!1;for(const s of t)"-"!==s&&"_"!==s?i?(e.push(s.toUpperCase()),i=!1):e.push(s.toLowerCase()):i=!0;return e.join("")}},13258:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var s=i(134);class a{constructor(t=0){(0,s.A)(this,"rcon",[0,1,2,4,8,16,32,64,128,27,54]),(0,s.A)(this,"subMix",[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)]),(0,s.A)(this,"invSubMix",[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)]),(0,s.A)(this,"sBox",new Uint32Array(256)),(0,s.A)(this,"invSBox",new Uint32Array(256)),(0,s.A)(this,"key",new Uint32Array(0)),(0,s.A)(this,"ksRows",0),(0,s.A)(this,"keySize",0),(0,s.A)(this,"keySchedule",void 0),(0,s.A)(this,"invKeySchedule",void 0),this.initTable()}uint8ArrayToUint32Array_(t){const e=new DataView(t),i=new Uint32Array(4);for(let t=0;t<4;t++)i[t]=e.getUint32(4*t);return i}initTable(){const t=this.sBox,e=this.invSBox,i=this.subMix,s=i[0],a=i[1],r=i[2],n=i[3],o=this.invSubMix,h=o[0],l=o[1],c=o[2],u=o[3],d=new Uint32Array(256);let T=0,E=0,f=0;for(f=0;f<256;f++)d[f]=f<128?f<<1:f<<1^283;for(f=0;f<256;f++){let i=E^E<<1^E<<2^E<<3^E<<4;i=i>>>8^255&i^99,t[T]=i,e[i]=T;const o=d[T],f=d[o],A=d[f];let p=257*d[i]^16843008*i;s[T]=p<<24|p>>>8,a[T]=p<<16|p>>>16,r[T]=p<<8|p>>>24,n[T]=p,p=16843009*A^65537*f^257*o^16843008*T,h[i]=p<<24|p>>>8,l[i]=p<<16|p>>>16,c[i]=p<<8|p>>>24,u[i]=p,T?(T=o^d[d[d[A^o]]],E^=d[d[E]]):T=E=1}}async expandKey(t){const e=this.uint8ArrayToUint32Array_(t);if(this.key){let t=!0,i=0;for(;i<e.length&&t;)t=e[i]===this.key[i],i++;if(t)return}this.key=e;const i=this.keySize=this.key.length;if(4!==i&&6!==i&&8!==i)throw new Error("Invalid aes key size="+i);const s=this.ksRows=4*(i+6+1);let a,r;const n=this.keySchedule=new Uint32Array(s),o=this.invKeySchedule=new Uint32Array(s),h=this.sBox,l=this.rcon,c=this.invSubMix,u=c[0],d=c[1],T=c[2],E=c[3];let f,A;for(a=0;a<s;a++)a<i?f=n[a]=e[a]:(A=f,a%i==0?(A=A<<8|A>>>24,A=h[A>>>24]<<24|h[A>>>16&255]<<16|h[A>>>8&255]<<8|h[255&A],A^=l[a/i|0]<<24):i>6&&a%i==4&&(A=h[A>>>24]<<24|h[A>>>16&255]<<16|h[A>>>8&255]<<8|h[255&A]),n[a]=f=(n[a-i]^A)>>>0);for(r=0;r<s;r++)a=s-r,A=3&r?n[a]:n[a-4],o[r]=r<4||a<=4?A:u[h[A>>>24]]^d[h[A>>>16&255]]^T[h[A>>>8&255]]^E[h[255&A]],o[r]=o[r]>>>0}networkToHostOrderSwap(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24}async decrypt(t,e){const i=this.keySize+6,s=this.invKeySchedule,a=this.invSBox,r=this.invSubMix,n=r[0],o=r[1],h=r[2],l=r[3],c=this.uint8ArrayToUint32Array_(e);let u=c[0],d=c[1],T=c[2],E=c[3];const f=new Int32Array(t.buffer).subarray(t.byteOffset>>>2,(t.byteOffset>>>2)+(t.length>>>2)),A=new Int32Array(f.length);let p,m,y,g,X,S,I,N,v,R,P,D,b,O;const L=this.networkToHostOrderSwap;let M=0;for(;M<f.length;){for(v=L(f[M]),R=L(f[M+1]),P=L(f[M+2]),D=L(f[M+3]),X=v^s[0],S=D^s[1],I=P^s[2],N=R^s[3],b=4,O=1;O<i;O++)p=n[X>>>24]^o[S>>16&255]^h[I>>8&255]^l[255&N]^s[b],m=n[S>>>24]^o[I>>16&255]^h[N>>8&255]^l[255&X]^s[b+1],y=n[I>>>24]^o[N>>16&255]^h[X>>8&255]^l[255&S]^s[b+2],g=n[N>>>24]^o[X>>16&255]^h[S>>8&255]^l[255&I]^s[b+3],X=p,S=m,I=y,N=g,b+=4;p=a[X>>>24]<<24^a[S>>16&255]<<16^a[I>>8&255]<<8^a[255&N]^s[b],m=a[S>>>24]<<24^a[I>>16&255]<<16^a[N>>8&255]<<8^a[255&X]^s[b+1],y=a[I>>>24]<<24^a[N>>16&255]<<16^a[X>>8&255]<<8^a[255&S]^s[b+2],g=a[N>>>24]<<24^a[X>>16&255]<<16^a[S>>8&255]<<8^a[255&I]^s[b+3],A[M]=L(p^u),A[M+1]=L(g^d),A[M+2]=L(y^T),A[M+3]=L(m^E),u=v,d=R,T=P,E=D,M+=4}return A.buffer}}},51678:(t,e,i)=>{"use strict";i.d(e,{A:()=>a});var s=i(134);class a{constructor(t=0){(0,s.A)(this,"subtle",void 0),(0,s.A)(this,"key",void 0),(0,s.A)(this,"mode",void 0),(0,s.A)(this,"keyBuffer",void 0),this.mode=t,this.subtle=crypto.subtle||crypto.webkitSubtle}getSubtleAlgoName(){switch(this.mode){case 0:return"AES-CBC";case 1:return"AES-CTR"}}async expandKey(t){let e=new Uint8Array(t);if(this.keyBuffer){let t=!0,i=0;for(;i<e.length&&t;)t=e[i]===this.keyBuffer[i],i++;if(t)return}this.keyBuffer=e,this.key=await this.subtle.importKey("raw",t,{name:this.getSubtleAlgoName()},!1,["encrypt","decrypt"])}async encryptPadding(t,e){return new Uint8Array(await crypto.subtle.encrypt({name:"AES-CBC",iv:e},this.key,t))}async decrypt(t,e){switch(this.mode){case 0:return this.subtle.decrypt({name:"AES-CBC",iv:e},this.key,t);case 1:return this.subtle.decrypt({name:"AES-CTR",counter:e,length:64},this.key,t)}}static isSupport(){return"object"==typeof(crypto.subtle||crypto.webkitSubtle)}}},6498:(t,e,i)=>{"use strict";i(67672),i(72739)},8507:(t,e,i)=>{"use strict";function s(t){const e=t,i=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],s=/:\/\/([^\/@]*@?)\[(\S+)\]/;let a="";s.test(t)&&(t=t.replace(s,((t,e,i)=>(a=i,`://${e||""}a.b`))));const r={},n=/^(?:(?![^:@\/]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*)(?::([^:@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(t);let o=14;for(;o--;){var h;r[i[o]]=null!==(h=n[o])&&void 0!==h?h:""}return a&&(r.host=a,r.source=e,r.authority=a+(r.port?":"+r.port:"")),{protocol:r.protocol,file:r.file,host:r.host,port:r.port,user:r.user,password:r.password,origin:`${r.protocol}://${r.authority}`,pathname:r.path,search:`?${r.query}`,hash:r.anchor?`#${r.anchor}`:""}}i.d(e,{ll:()=>u,qg:()=>s}),i(73146),i(67672),i(6498),i(72739),i(95335);const a=/(?:\/|^)\.(?=\/)/g,r=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,n=/^(?=([^\/?#]*))\1([^]*)$/,o=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/;function h(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}function l(t){const e=o.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null}function c(t){for(t=t.split("").reverse().join("").replace(a,"");t.length!==(t=t.replace(r,"")).length;);return t.split("").reverse().join("")}function u(t,e,i){if(i=i||{},t=t.trim(),!(e=e.trim())){if(!i.alwaysNormalize)return t;let e=l(t);if(!e)throw new Error("Error trying to parse base URL.");return e.path=c(e.path),h(e)}let s=l(e);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return i.alwaysNormalize?(s.path=c(s.path),h(s)):e;let a=l(t);if(!a)throw new Error("Error trying to parse base URL.");if(!a.netLoc&&a.path&&"/"!==a.path[0]){let t=n.exec(a.path);a.netLoc=t[1],a.path=t[2]}a.netLoc&&!a.path&&(a.path="/");const r={scheme:a.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(r.netLoc=a.netLoc,"/"!==s.path[0]))if(s.path){let t=a.path,e=t.substring(0,t.lastIndexOf("/")+1)+s.path;r.path=c(e)}else r.path=a.path,s.params||(r.params=a.params,s.query||(r.query=a.query));return null===r.path&&(r.path=i.alwaysNormalize?c(s.path):s.path),h(r)}},85079:(t,e,i)=>{var s=i(46438),a=s.JSON||(s.JSON={stringify:JSON.stringify});t.exports=function(t){return a.stringify.apply(a,arguments)}},63342:(t,e,i)=>{i(5882),t.exports=i(46438).Number.isInteger},11837:(t,e,i)=>{i(21489),t.exports=i(46438).Number.isNaN},19737:(t,e,i)=>{i(56477),t.exports=i(46438).Number.parseFloat},58886:(t,e,i)=>{i(15706),t.exports=i(46438).Number.parseInt},25194:(t,e,i)=>{var s=i(24401),a=Math.floor;t.exports=function(t){return!s(t)&&isFinite(t)&&a(t)===t}},5882:(t,e,i)=>{var s=i(88535);s(s.S,"Number",{isInteger:i(25194)})},21489:(t,e,i)=>{var s=i(88535);s(s.S,"Number",{isNaN:function(t){return t!=t}})},56477:(t,e,i)=>{var s=i(88535),a=i(49709);s(s.S+s.F*(Number.parseFloat!=a),"Number",{parseFloat:a})},15706:(t,e,i)=>{var s=i(88535),a=i(15722);s(s.S+s.F*(Number.parseInt!=a),"Number",{parseInt:a})},73146:(t,e,i)=>{t.exports=i(85079)},43929:(t,e,i)=>{t.exports=i(63342)},7210:(t,e,i)=>{t.exports=i(11837)},99704:(t,e,i)=>{t.exports=i(19737)},17735:(t,e,i)=>{t.exports=i(58886)}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[453],{18453:(e,t,i)=>{i.r(t),i.d(t,{default:()=>S});var a=i(134),r=i(63939),s=i(50932),n=i(4624),o=i(9705),c=i(85947),h=i(14686),d=i(37837),m=i(71517),f=i(91375),l=i(37246),u=i(92647),p=i(77231),g=i(52071),w=i(72739),x=i(44328),R=i(87400);const B="src/avformat/formats/IFlacFormat.ts",b=1024;class S extends c.A{constructor(){super(),(0,a.A)(this,"type",17),(0,a.A)(this,"context",void 0)}init(e){e.ioReader.setEndian(!0),this.context={streamInfo:{minimumBlockSize:0,maximumBlockSize:0,minimumFrameSize:0,maximumFrameSize:0,sampleRate:0,channels:0,bitPerSample:0,samples:BigInt(0),md5:""},frameInfo:{sampleRate:0,channels:0,bps:0,blocksize:0,chMode:0,frameOrSampleNum:BigInt(0),isVarSize:0},seekPoints:[],cueSheet:{catalogNumber:"",leadInSamples:BigInt(0),compactDisc:!1,tracks:[]},picture:{type:0,mimeType:"",description:"",width:0,height:0,colorDepth:0,indexedColor:0,data:null},cacheBuffer:null,cachePos:BigInt(0),bitReader:new l.A(16),fileSize:BigInt(0),firstFramePos:BigInt(0),isVarSize:-1}}async readHeader(e){if("fLaC"!==await e.ioReader.readString(4))return n.z3("the file format is not flac",B,118),o.LR;this.context.fileSize=await e.ioReader.fileSize();const t=e.createStream();for(t.codecpar.codecType=1,t.codecpar.codecId=86028;;){const i=await e.ioReader.readUint8(),a=await e.ioReader.readUint24(),r=-129&i;if(0===r){t.codecpar.extradata=(0,d.sY)(a),t.codecpar.extradataSize=a,(0,h.lW)(t.codecpar.extradata,a,await e.ioReader.peekBuffer(a)),this.context.streamInfo.minimumBlockSize=await e.ioReader.readUint16(),this.context.streamInfo.maximumBlockSize=await e.ioReader.readUint16(),this.context.streamInfo.minimumFrameSize=await e.ioReader.readUint24(),this.context.streamInfo.maximumFrameSize=await e.ioReader.readUint24();const i=await e.ioReader.readUint24();t.codecpar.sampleRate=i>>4,t.codecpar.chLayout.nbChannels=1+((15&i)>>>1),this.context.streamInfo.sampleRate=t.codecpar.sampleRate,this.context.streamInfo.channels=t.codecpar.chLayout.nbChannels;const r=await e.ioReader.readUint8();t.codecpar.bitsPerRawSample=1+((1&i)<<4|(240&r)>>>4),this.context.streamInfo.bitPerSample=t.codecpar.bitsPerRawSample;const s=await e.ioReader.readUint32(),n=BigInt(Math.floor(15&r))<<BigInt(32)|BigInt(Math.floor(s));this.context.streamInfo.samples=n,t.timeBase.den=t.codecpar.sampleRate,t.timeBase.num=1,t.duration=n,t.startTime=BigInt(0),this.context.streamInfo.md5=await e.ioReader.readString(16)}else if(2===r){const t=e.createStream();t.codecpar.codecType=2,t.codecpar.codecTag=await e.ioReader.readUint32(),t.codecpar.extradata=(0,d.sY)(a-4),t.codecpar.extradataSize=a-4,await e.ioReader.readBuffer(a-4,(0,h.JW)(t.codecpar.extradata,t.codecpar.extradataSize))}else if(3===r)for(let t=0;t<a/18;t++){const t=await e.ioReader.readUint64(),i=await e.ioReader.readUint64(),a=await e.ioReader.readUint16();this.context.seekPoints.push({pts:t,pos:i,samples:a})}else if(4===r){e.ioReader.setEndian(!1);const i=await e.ioReader.readUint32(),a=await e.ioReader.readString(i),r=await e.ioReader.readUint32(),s=[];for(let t=0;t<r;t++){const t=await e.ioReader.readUint32();s.push(await e.ioReader.readString(t))}t.metadata.vendor=a,(0,R.ol)(s,t.metadata),e.ioReader.setEndian(!0)}else if(5===r){this.context.cueSheet.catalogNumber=await e.ioReader.readString(128),this.context.cueSheet.leadInSamples=await e.ioReader.readUint64(),this.context.cueSheet.compactDisc=!!(await e.ioReader.readUint8()>>>7),await e.ioReader.skip(258);const t=await e.ioReader.readUint8();for(let i=0;i<t;i++){const t=await e.ioReader.readUint64(),i=await e.ioReader.readUint8(),a=await e.ioReader.readBuffer(12),r=await e.ioReader.readUint8();await e.ioReader.skip(13);const s=await e.ioReader.readUint8(),n=[];for(let t=0;t<s;t++)n.push({offset:await e.ioReader.readUint64(),point:await e.ioReader.readUint8()}),await e.ioReader.skip(3);this.context.cueSheet.tracks.push({offset:t,number:i,isrc:a,type:r>>>7,preEmphasisFlag:r>>>6&1,points:n})}}else if(6===r){this.context.picture.type=await e.ioReader.readUint32();let t=await e.ioReader.readUint32();this.context.picture.mimeType=await e.ioReader.readString(t),t=await e.ioReader.readUint32(),this.context.picture.description=await e.ioReader.readString(t),this.context.picture.width=await e.ioReader.readUint32(),this.context.picture.height=await e.ioReader.readUint32(),this.context.picture.colorDepth=await e.ioReader.readUint32(),this.context.picture.indexedColor=await e.ioReader.readUint32(),t=await e.ioReader.readUint32(),this.context.picture.data=await e.ioReader.readBuffer(t)}else await e.ioReader.skip(a);if(128&i)break}return this.context.firstFramePos=e.ioReader.getPos(),t.privData=this.context,0}async getNextFrame(e){const t=[];for(;;){if(e.ioReader.getPos()===this.context.fileSize){this.context.cacheBuffer&&(t.push(this.context.cacheBuffer),this.context.cacheBuffer=null);break}this.context.cacheBuffer?this.context.cacheBuffer.length<17&&(this.context.cacheBuffer=(0,u.A)(Uint8Array,[this.context.cacheBuffer,await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos()))))])):(this.context.cachePos=e.ioReader.getPos(),this.context.cacheBuffer=await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos())))));let i=t.length?0:2;const a=this.context.isVarSize<0?[248,249]:this.context.isVarSize?[249]:[248],r=this.context.cacheBuffer.length-2;for(;i<r;i++)if(255===this.context.cacheBuffer[i]&&w.zy(a,this.context.cacheBuffer[i+1])){i&&(t.push(this.context.cacheBuffer.subarray(0,i)),this.context.cacheBuffer=this.context.cacheBuffer.subarray(i),this.context.cachePos+=BigInt(Math.floor(i)));break}if(i===r){e.ioReader.getPos()===this.context.fileSize?(t.push(this.context.cacheBuffer),this.context.cachePos+=BigInt(Math.floor(this.context.cacheBuffer.length)),this.context.cacheBuffer=null):(t.push(this.context.cacheBuffer.subarray(0,i)),this.context.cachePos+=BigInt(Math.floor(i)),this.context.cacheBuffer=this.context.cacheBuffer.subarray(i));continue}this.context.cacheBuffer.length<16&&(this.context.cacheBuffer=(0,u.A)(Uint8Array,[this.context.cacheBuffer,await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos()))))])),this.context.bitReader.reset(),this.context.bitReader.appendBuffer(this.context.cacheBuffer.subarray(0,16));const s={};if(!((0,f.x)(this.context.bitReader,s,!0)<0||s.frameOrSampleNum-this.context.frameInfo.frameOrSampleNum!==BigInt(0|this.context.frameInfo.blocksize)&&s.frameOrSampleNum!==this.context.frameInfo.frameOrSampleNum+BigInt(1)))break;t.push(this.context.cacheBuffer.subarray(0,2)),this.context.cachePos+=BigInt(2),this.context.cacheBuffer=this.context.cacheBuffer.subarray(2)}return 1===t.length?t[0]:(0,u.A)(Uint8Array,t)}async readAVPacket(e,t){const i=e.streams.find((e=>e.codecpar.codecType=1));try{let a=e.ioReader.getPos();if(a===this.context.fileSize)return-1048576;if(this.context.bitReader.reset(),this.context.cacheBuffer?(a=this.context.cachePos,this.context.cacheBuffer.length<16&&(this.context.cacheBuffer=(0,u.A)(Uint8Array,[this.context.cacheBuffer,await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos()))))])),this.context.bitReader.appendBuffer(this.context.cacheBuffer.subarray(0,16))):this.context.bitReader.appendBuffer(await e.ioReader.peekBuffer(16)),(0,f.x)(this.context.bitReader,this.context.frameInfo)<0)return o.LR;const n=await this.getNextFrame(e),c=(0,d.sY)(n.length);return(0,h.lW)(c,n.length,n),(0,m.NX)(t,c,n.length),s.M[17](t+56,a),s.M[15](t+32,i.index),s.M[15](t+76,i.timeBase.den),s.M[15](t+72,i.timeBase.num),s.M[15](t+36,1|r.f[15](t+36)),s.M[17](t+16,this.context.frameInfo.isVarSize?this.context.frameInfo.frameOrSampleNum:this.context.frameInfo.frameOrSampleNum*BigInt(0|this.context.frameInfo.blocksize)),s.M[17](t+8,this.context.frameInfo.isVarSize?this.context.frameInfo.frameOrSampleNum:this.context.frameInfo.frameOrSampleNum*BigInt(0|this.context.frameInfo.blocksize)),this.context.isVarSize<0&&(this.context.isVarSize=this.context.frameInfo.isVarSize),0}catch(t){return-1048576!==e.ioReader.error?(n.z3(`read packet error, ${t}`,B,416),o.LR):e.ioReader.error}}async syncFrame(e){let t=p.Dh;for(;;)try{const i=await e.ioReader.peekUint16();if((65529===i||65528===i)&&(t=e.ioReader.getPos(),this.context.bitReader.reset(),this.context.bitReader.appendBuffer(await e.ioReader.peekBuffer(16)),!(0,f.x)(this.context.bitReader,{},!0)))break;await e.ioReader.skip(1)}catch(e){break}t!==p.Dh&&await e.ioReader.seek(t)}async seek(e,t,i,a){const r=e.ioReader.getPos(),s=t.privData;if(2&a){const t=await e.ioReader.fileSize();return t<=BigInt(0)?BigInt(o.E$):(i<BigInt(0)?i=BigInt(0):i>t&&(i=t),await e.ioReader.seek(i),4&a||await this.syncFrame(e),r)}if(t&&t.sampleIndexes.length){let a=w.El(t.sampleIndexes,(e=>e.pts>i?-1:1));if(a>0&&(0,x.k)(i-t.sampleIndexes[a-1].pts,t.timeBase,p.i0)<BigInt(5e3))return n.Yz(`seek in sampleIndexes, found index: ${a}, pts: ${t.sampleIndexes[a-1].pts}, pos: ${t.sampleIndexes[a-1].pos}`,B,483),await e.ioReader.seek(t.sampleIndexes[a-1].pos),s.cacheBuffer=null,r}if(s.seekPoints.length){let t=0;for(let e=0;e<s.seekPoints.length;e++){if(s.seekPoints[e].pts===i){t=e;break}if(s.seekPoints[e].pts>i){t=Math.max(e-1,0);break}}const a=s.seekPoints[t];return n.Yz(`seek in seekPoints, found index: ${t}, pts: ${a.pts}, pos: ${a.pos+s.firstFramePos}`,B,503),await e.ioReader.seek(a.pos+s.firstFramePos),s.cacheBuffer=null,r}n.Yz("not found any keyframe index, try to seek in bytes",B,509);const c=await(0,g.A)(e,t,i,s.firstFramePos,this.readAVPacket.bind(this),this.syncFrame.bind(this));return c>0&&(s.cacheBuffer=null),c}getAnalyzeStreamsCount(){return 1}}},85947:(e,t,i)=>{i.d(t,{A:()=>r});var a=i(134);class r{constructor(){(0,a.A)(this,"type",-1),(0,a.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},91375:(e,t,i)=>{i.d(t,{x:()=>c});var a=i(9705),r=i(4624),s=i(14769),n=i(13188);const o="src/avformat/formats/flac/iflac.ts";function c(e,t,i=!1){const c=e.getPointer();if(32764!=(32767&e.readU(15)))return!i&&r.z3("invalid sync code",o,57),a.LR;t.isVarSize=e.readU1();const h=e.readU(4),d=e.readU(4);if(t.chMode=e.readU(4),t.chMode<s.jA)t.channels=t.chMode+1,t.chMode=0;else{if(!(t.chMode<s.jA+3))return!i&&r.z3(`invalid channel mode: ${t.chMode}`,o,76),a.LR;t.channels=2,t.chMode-=s.jA-1}const m=e.readU(3);if(3===m)return!i&&r.z3(`invalid sample size code: ${m}`,o,82),a.LR;if(t.bps=s.oe[m],e.readU1())return!i&&r.z3("broken stream, invalid padding",o,88),a.LR;if(t.frameOrSampleNum=function(e){let t=BigInt(Math.floor(e.readU(8))),i=(t&BigInt(128))>>BigInt(1);if((t&BigInt(192))===BigInt(128)||t>=BigInt(254))return-BigInt(1);for(;t&i;){const a=BigInt(Math.floor(e.readU(8)))-BigInt(128);if(a>>BigInt(6))return-BigInt(1);t=(t<<BigInt(6))+a,i<<=BigInt(5)}return t&=(i<<BigInt(1))-BigInt(1),t}(e),t.frameOrSampleNum<0)return!i&&r.z3("sample/frame number invalid",o,95),a.LR;if(0===h)return!i&&r.z3("reserved blocksize code: 0",o,100),a.LR;if(t.blocksize=6===h?e.readU(8)+1:7===h?e.readU(16)+1:s.Xr[h],d<12)t.sampleRate=s.DK[d];else if(12===d)t.sampleRate=1e3*e.readU(8);else if(13===d)t.sampleRate=e.readU(16);else{if(14!==d)return!i&&r.z3(`illegal sample rate code ${d}`,o,126),a.LR;t.sampleRate=10*e.readU(16)}return(0,n.A)(e.getBuffer().subarray(c,e.getPointer()))!==e.readU(8)?(!i&&r.z3("header crc mismatch",o,133),a.LR):0}},38743:(e,t,i)=>{i.d(t,{B:()=>o,h:()=>c});var a=i(134),r=i(77231),s=i(50011);class n{constructor(){(0,a.A)(this,"list",void 0),this.list=[]}read(e,t){for(let i=0;i<t;i++){const t=e.readUint32();this.list.push(e.readString(t))}}write(e){for(let t=0;t<this.list.length;t++){const i=s.encode(this.list[t]);e.writeUint32(i.length),e.writeBuffer(i)}}addComment(e){this.list.push(e)}}class o{constructor(){(0,a.A)(this,"capturePattern",void 0),(0,a.A)(this,"streamStructureVersion",void 0),(0,a.A)(this,"headerTypeFlag",void 0),(0,a.A)(this,"granulePosition",void 0),(0,a.A)(this,"serialNumber",void 0),(0,a.A)(this,"pageSequenceNumber",void 0),(0,a.A)(this,"crcCheckSum",void 0),(0,a.A)(this,"numberPageSegments",void 0),(0,a.A)(this,"segmentTable",void 0),(0,a.A)(this,"payload",void 0),(0,a.A)(this,"pos",void 0),this.reset()}reset(){this.capturePattern="OggS",this.streamStructureVersion=0,this.headerTypeFlag=0,this.granulePosition=r.Dh,this.serialNumber=0,this.pageSequenceNumber=0,this.crcCheckSum=0,this.numberPageSegments=0,this.segmentTable=[],this.pos=BigInt(0)}async read(e){this.pos=e.getPos(),await this.readPageHeader(e);const t=this.segmentTable.reduce(((e,t)=>e+t),0);t&&(this.payload=await e.readBuffer(t))}async readPageHeader(e){if(this.capturePattern=await e.readString(4),this.streamStructureVersion=await e.readUint8(),this.headerTypeFlag=await e.readUint8(),this.granulePosition=await e.readUint64(),this.serialNumber=await e.readUint32(),this.pageSequenceNumber=await e.readUint32(),this.crcCheckSum=await e.readUint32(),this.numberPageSegments=await e.readUint8(),this.numberPageSegments)for(let t=0;t<this.numberPageSegments;t++){const t=await e.readUint8();this.segmentTable.push(t)}}write(e){if(this.pos=e.getPos(),e.writeString(this.capturePattern),e.writeUint8(this.streamStructureVersion),e.writeUint8(this.headerTypeFlag),e.writeUint64(this.granulePosition),e.writeUint32(this.serialNumber),e.writeUint32(this.pageSequenceNumber),e.writeUint32(this.crcCheckSum),this.payload){this.numberPageSegments=Math.floor(this.payload.length/255)+1;const t=this.payload.length%255;e.writeUint8(this.numberPageSegments);for(let t=0;t<this.numberPageSegments-1;t++)e.writeUint8(255);e.writeUint8(t),e.writeBuffer(this.payload)}else e.writeUint8(0)}}class c{constructor(){(0,a.A)(this,"streamIndex",void 0),(0,a.A)(this,"signature",void 0),(0,a.A)(this,"vendorStringLength",void 0),(0,a.A)(this,"vendorString",void 0),(0,a.A)(this,"userCommentListLength",void 0),(0,a.A)(this,"comments",void 0),this.vendorString="v0.7.0-41-g43c066b",this.vendorStringLength=this.vendorString.length,this.userCommentListLength=0,this.comments=new n}read(e){this.vendorStringLength=e.readUint32(),this.vendorString=e.readString(this.vendorStringLength),this.userCommentListLength=e.readUint32(),this.userCommentListLength&&this.comments.read(e,this.userCommentListLength)}write(e){const t=s.encode(this.vendorString);e.writeUint32(t.length),e.writeBuffer(t),e.writeUint32(this.comments.list.length),this.comments.write(e)}addComment(e){this.comments.addComment(e)}setCodec(e){}}},87400:(e,t,i)=>{i.d(t,{GM:()=>c,mS:()=>o,ol:()=>n});var a=i(134),r=i(38743);i(95335),i(34677);const s={album:"album",artist:"artist",description:"description",encoder:"encoder",title:"title",tracknumber:"track",date:"date",genre:"genre",comment:"comment",albumartist:"albumArtist",composer:"composer",performer:"performer",discnumber:"disc",organization:"vendor",copyright:"copyright",license:"license",isrc:"isrc",lyrics:"lyrics",language:"language",label:"vendor",script:"lyrics",encoded_by:"vendor"};function n(e,t){e&&e.forEach((e=>{const i=e.split("=");if(2===i.length){const e=i[0].trim().toLowerCase(),a=i[1].trim();s[e]?t[s[e]]=a:t[e.toLowerCase()]=a}}))}class o{constructor(e="vorbis"){(0,a.A)(this,"streamIndex",void 0),(0,a.A)(this,"packetType",void 0),(0,a.A)(this,"signature",void 0),(0,a.A)(this,"version",void 0),(0,a.A)(this,"channels",void 0),(0,a.A)(this,"sampleRate",void 0),(0,a.A)(this,"bitrateMaximum",void 0),(0,a.A)(this,"bitrateNominal",void 0),(0,a.A)(this,"bitrateMinimum",void 0),(0,a.A)(this,"blocksize0",void 0),(0,a.A)(this,"blocksize1",void 0),(0,a.A)(this,"framingFlag",void 0),this.signature=e,this.version=0,this.channels=1,this.sampleRate=48e3,this.bitrateMaximum=0,this.bitrateNominal=0,this.bitrateMinimum=0,this.blocksize0=2048,this.blocksize1=256}read(e){this.packetType=e.readUint8(),this.signature=e.readString(6),this.version=e.readUint32(),this.channels=e.readUint8(),this.sampleRate=e.readInt32(),this.bitrateMaximum=e.readInt32(),this.bitrateNominal=e.readInt32(),this.bitrateMinimum=e.readInt32();const t=255&e.readUint8();this.blocksize0=Math.pow(2,t>>>4),this.blocksize1=Math.pow(2,15&t),this.framingFlag=e.readUint8()}write(e){e.writeUint8(1),e.writeString(this.signature),e.writeUint32(this.version),e.writeUint8(this.channels),e.writeInt32(this.sampleRate),e.writeInt32(this.bitrateMaximum),e.writeInt32(this.bitrateNominal),e.writeInt32(this.bitrateMinimum),e.writeUint8(Math.log2(this.blocksize0)<<4|Math.log2(this.blocksize1)),e.writeUint8(1)}setCodec(e){this.sampleRate=e.sampleRate,this.channels=e.chLayout.nbChannels}}class c extends r.h{constructor(e="vorbis"){super(),(0,a.A)(this,"packetType",void 0),(0,a.A)(this,"framingFlag",void 0),this.signature=e,this.packetType=1,this.framingFlag=1}read(e){this.packetType=e.readUint8(),this.signature=e.readString(6),super.read(e),"vorbis"===this.signature&&(this.framingFlag=e.readUint8())}write(e){e.writeUint8(this.packetType),e.writeString(this.signature),super.write(e),"vorbis"===this.signature&&e.writeUint8(this.framingFlag)}addComment(e){this.comments.addComment(e)}setCodec(e){}}},2187:(e,t,i)=>{i.d(t,{d:()=>n});var a=i(72739),r=i(44328),s=i(77231);function n(e,t,i){let n=BigInt(0);return a.__(e,(e=>{n+=e.codecpar.bitrate*(0,r.k)(t,i,s.i0)/BigInt(8e3)})),n}},52071:(e,t,i)=>{i.d(t,{A:()=>m});var a=i(63939),r=(i(9599),i(77231)),s=i(44328),n=i(2187),o=i(71517),c=i(9705),h=i(4624);const d="src/avformat/function/seekInBytes.ts";async function m(e,t,i,m,f,l){const u=e.ioReader.getPos(),p=await e.ioReader.fileSize();let g=r.Dh,w=i;t.startTime!==r.Dh?w-=t.startTime:w-=t.firstDTS;const x=(0,s.k)(i,t.timeBase,r.i0);if(x<BigInt(1e4))return h.Yz(`seek pts is earlier then 10s, seek to first packet pos(${m}) directly`,d,62),await e.ioReader.seek(m),u;let R=(0,n.d)(e.streams,w,t.timeBase);const B=p-(0,n.d)(e.streams,BigInt(1e4),r.i0),b=(0,n.d)(e.streams,BigInt(1e4),r.i0);if(R>B&&(R=B),R<m)return await e.ioReader.seek(m),u;const S=(0,o._5)();let I=p,k=BigInt(0);for(;;){if(I-k<b){g=k;break}if(await e.ioReader.seek(R),await l(e),8&e.ioReader.flags)break;const t=e.ioReader.getPos();if(!(await f(e,S)>=0)){g=r.Dh;break}{const e=(0,s.Mr)(a.f[17](S+8),S+72,r.i0),i=e-x;if(h.Yz(`try to seek to pos: ${R}, got packet pts: ${a.f[17](S+8)}(${e}ms), diff: ${i}ms`,d,100),i<=BigInt(0)&&-i<BigInt(1e4)){g=t;break}i>BigInt(0)?(I=R,R=k+I>>BigInt(1)):(k=R,R=k+I>>BigInt(1))}if(8&e.ioReader.flags)break}return(0,o.Qe)(S),g!==r.Dh?(h.Yz(`finally seek to pos ${g}`,d,131),await e.ioReader.seek(g),await l(e),u):(await e.ioReader.seek(u),8&e.ioReader.flags?BigInt(c.LT):BigInt(c.E$))}},14769:(e,t,i)=>{i.d(t,{DK:()=>o,XC:()=>h,Xr:()=>c,jA:()=>s,ob:()=>r,oe:()=>n});var a=i(31865);const r=34,s=8,n=[0,8,12,0,16,20,24,32],o=[0,88200,176400,192e3,8e3,16e3,22050,24e3,32e3,44100,48e3,96e3,0,0,0,0],c=[0,192,576,1152,2304,4608,0,0,256,512,1024,2048,4096,8192,16384,32768];function h(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length===r){const{bitsPerRawSample:i,sampleRate:r,channels:s}=function(e){const t=new a.A(e);t.skip(10);const i=t.readUint24();return{sampleRate:i>>4,channels:1+((15&i)>>>1),bitsPerRawSample:1+((1&i)<<4|(240&t.readUint8())>>>4)}}(t);e.codecpar.bitsPerRawSample=i,e.codecpar.sampleRate=r,e.codecpar.chLayout.nbChannels=s}}},13188:(e,t,i)=>{function a(e,t=0){for(let i=0;i<e.length;i++){t^=e[i];for(let e=0;e<8;e++)128&t?t=t<<1^7:t<<=1}return 255&t}i.d(t,{A:()=>a})}}]);
1
+ "use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[453],{18453:(e,t,i)=>{i.r(t),i.d(t,{default:()=>S});var a=i(134),r=i(63939),s=i(50932),n=i(4624),o=i(9705),c=i(85947),h=i(14686),d=i(37837),m=i(71517),f=i(91375),l=i(37246),u=i(92647),p=i(77231),g=i(52071),w=i(72739),x=i(44328),R=i(87400);const B="src/avformat/formats/IFlacFormat.ts",b=1024;class S extends c.A{constructor(){super(),(0,a.A)(this,"type",17),(0,a.A)(this,"context",void 0)}init(e){e.ioReader.setEndian(!0),this.context={streamInfo:{minimumBlockSize:0,maximumBlockSize:0,minimumFrameSize:0,maximumFrameSize:0,sampleRate:0,channels:0,bitPerSample:0,samples:BigInt(0),md5:""},frameInfo:{sampleRate:0,channels:0,bps:0,blocksize:0,chMode:0,frameOrSampleNum:BigInt(0),isVarSize:0},seekPoints:[],cueSheet:{catalogNumber:"",leadInSamples:BigInt(0),compactDisc:!1,tracks:[]},picture:{type:0,mimeType:"",description:"",width:0,height:0,colorDepth:0,indexedColor:0,data:null},cacheBuffer:null,cachePos:BigInt(0),bitReader:new l.A(16),fileSize:BigInt(0),firstFramePos:BigInt(0),isVarSize:-1}}async readHeader(e){if("fLaC"!==await e.ioReader.readString(4))return n.z3("the file format is not flac",B,118),o.LR;this.context.fileSize=await e.ioReader.fileSize();const t=e.createStream();for(t.codecpar.codecType=1,t.codecpar.codecId=86028;;){const i=await e.ioReader.readUint8(),a=await e.ioReader.readUint24(),r=-129&i;if(0===r){t.codecpar.extradata=(0,d.sY)(a),t.codecpar.extradataSize=a,(0,h.lW)(t.codecpar.extradata,a,await e.ioReader.peekBuffer(a)),this.context.streamInfo.minimumBlockSize=await e.ioReader.readUint16(),this.context.streamInfo.maximumBlockSize=await e.ioReader.readUint16(),this.context.streamInfo.minimumFrameSize=await e.ioReader.readUint24(),this.context.streamInfo.maximumFrameSize=await e.ioReader.readUint24();const i=await e.ioReader.readUint24();t.codecpar.sampleRate=i>>4,t.codecpar.chLayout.nbChannels=1+((15&i)>>>1),this.context.streamInfo.sampleRate=t.codecpar.sampleRate,this.context.streamInfo.channels=t.codecpar.chLayout.nbChannels;const r=await e.ioReader.readUint8();t.codecpar.bitsPerRawSample=1+((1&i)<<4|(240&r)>>>4),this.context.streamInfo.bitPerSample=t.codecpar.bitsPerRawSample;const s=await e.ioReader.readUint32(),n=BigInt(Math.floor(15&r))<<BigInt(32)|BigInt(Math.floor(s));this.context.streamInfo.samples=n,t.timeBase.den=t.codecpar.sampleRate,t.timeBase.num=1,t.duration=n,t.startTime=BigInt(0),this.context.streamInfo.md5=await e.ioReader.readString(16)}else if(2===r){const t=e.createStream();t.codecpar.codecType=2,t.codecpar.codecTag=await e.ioReader.readUint32(),t.codecpar.extradata=(0,d.sY)(a-4),t.codecpar.extradataSize=a-4,await e.ioReader.readBuffer(a-4,(0,h.JW)(t.codecpar.extradata,t.codecpar.extradataSize))}else if(3===r)for(let t=0;t<a/18;t++){const t=await e.ioReader.readUint64(),i=await e.ioReader.readUint64(),a=await e.ioReader.readUint16();this.context.seekPoints.push({pts:t,pos:i,samples:a})}else if(4===r){e.ioReader.setEndian(!1);const i=await e.ioReader.readUint32(),a=await e.ioReader.readString(i),r=await e.ioReader.readUint32(),s=[];for(let t=0;t<r;t++){const t=await e.ioReader.readUint32();s.push(await e.ioReader.readString(t))}t.metadata.vendor=a,(0,R.ol)(s,t.metadata),e.ioReader.setEndian(!0)}else if(5===r){this.context.cueSheet.catalogNumber=await e.ioReader.readString(128),this.context.cueSheet.leadInSamples=await e.ioReader.readUint64(),this.context.cueSheet.compactDisc=!!(await e.ioReader.readUint8()>>>7),await e.ioReader.skip(258);const t=await e.ioReader.readUint8();for(let i=0;i<t;i++){const t=await e.ioReader.readUint64(),i=await e.ioReader.readUint8(),a=await e.ioReader.readBuffer(12),r=await e.ioReader.readUint8();await e.ioReader.skip(13);const s=await e.ioReader.readUint8(),n=[];for(let t=0;t<s;t++)n.push({offset:await e.ioReader.readUint64(),point:await e.ioReader.readUint8()}),await e.ioReader.skip(3);this.context.cueSheet.tracks.push({offset:t,number:i,isrc:a,type:r>>>7,preEmphasisFlag:r>>>6&1,points:n})}}else if(6===r){this.context.picture.type=await e.ioReader.readUint32();let t=await e.ioReader.readUint32();this.context.picture.mimeType=await e.ioReader.readString(t),t=await e.ioReader.readUint32(),this.context.picture.description=await e.ioReader.readString(t),this.context.picture.width=await e.ioReader.readUint32(),this.context.picture.height=await e.ioReader.readUint32(),this.context.picture.colorDepth=await e.ioReader.readUint32(),this.context.picture.indexedColor=await e.ioReader.readUint32(),t=await e.ioReader.readUint32(),this.context.picture.data=await e.ioReader.readBuffer(t)}else await e.ioReader.skip(a);if(128&i)break}return this.context.firstFramePos=e.ioReader.getPos(),t.privData=this.context,0}async getNextFrame(e){const t=[];for(;;){if(e.ioReader.getPos()===this.context.fileSize){this.context.cacheBuffer&&(t.push(this.context.cacheBuffer),this.context.cacheBuffer=null);break}this.context.cacheBuffer?this.context.cacheBuffer.length<17&&(this.context.cacheBuffer=(0,u.A)(Uint8Array,[this.context.cacheBuffer,await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos()))))])):(this.context.cachePos=e.ioReader.getPos(),this.context.cacheBuffer=await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos())))));let i=t.length?0:2;const a=this.context.isVarSize<0?[248,249]:this.context.isVarSize?[249]:[248],r=this.context.cacheBuffer.length-2;for(;i<r;i++)if(255===this.context.cacheBuffer[i]&&w.zy(a,this.context.cacheBuffer[i+1])){i&&(t.push(this.context.cacheBuffer.subarray(0,i)),this.context.cacheBuffer=this.context.cacheBuffer.subarray(i),this.context.cachePos+=BigInt(Math.floor(i)));break}if(i===r){e.ioReader.getPos()===this.context.fileSize?(t.push(this.context.cacheBuffer),this.context.cachePos+=BigInt(Math.floor(this.context.cacheBuffer.length)),this.context.cacheBuffer=null):(t.push(this.context.cacheBuffer.subarray(0,i)),this.context.cachePos+=BigInt(Math.floor(i)),this.context.cacheBuffer=this.context.cacheBuffer.subarray(i));continue}this.context.cacheBuffer.length<16&&(this.context.cacheBuffer=(0,u.A)(Uint8Array,[this.context.cacheBuffer,await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos()))))])),this.context.bitReader.reset(),this.context.bitReader.appendBuffer(this.context.cacheBuffer.subarray(0,16));const s={};if(!((0,f.x)(this.context.bitReader,s,!0)<0||s.frameOrSampleNum-this.context.frameInfo.frameOrSampleNum!==BigInt(0|this.context.frameInfo.blocksize)&&s.frameOrSampleNum!==this.context.frameInfo.frameOrSampleNum+BigInt(1)))break;t.push(this.context.cacheBuffer.subarray(0,2)),this.context.cachePos+=BigInt(2),this.context.cacheBuffer=this.context.cacheBuffer.subarray(2)}return 1===t.length?t[0]:(0,u.A)(Uint8Array,t)}async readAVPacket(e,t){const i=e.streams.find((e=>e.codecpar.codecType=1));try{let a=e.ioReader.getPos();if(a===this.context.fileSize)return-1048576;if(this.context.bitReader.reset(),this.context.cacheBuffer?(a=this.context.cachePos,this.context.cacheBuffer.length<16&&(this.context.cacheBuffer=(0,u.A)(Uint8Array,[this.context.cacheBuffer,await e.ioReader.readBuffer(Math.min(b,Number(BigInt.asIntN(32,this.context.fileSize-e.ioReader.getPos()))))])),this.context.bitReader.appendBuffer(this.context.cacheBuffer.subarray(0,16))):this.context.bitReader.appendBuffer(await e.ioReader.peekBuffer(16)),(0,f.x)(this.context.bitReader,this.context.frameInfo)<0)return o.LR;const n=await this.getNextFrame(e),c=(0,d.sY)(n.length);return(0,h.lW)(c,n.length,n),(0,m.NX)(t,c,n.length),s.M[17](t+56,a),s.M[15](t+32,i.index),s.M[15](t+76,i.timeBase.den),s.M[15](t+72,i.timeBase.num),s.M[15](t+36,1|r.f[15](t+36)),s.M[17](t+16,this.context.frameInfo.isVarSize?this.context.frameInfo.frameOrSampleNum:this.context.frameInfo.frameOrSampleNum*BigInt(0|this.context.frameInfo.blocksize)),s.M[17](t+8,this.context.frameInfo.isVarSize?this.context.frameInfo.frameOrSampleNum:this.context.frameInfo.frameOrSampleNum*BigInt(0|this.context.frameInfo.blocksize)),this.context.isVarSize<0&&(this.context.isVarSize=this.context.frameInfo.isVarSize),0}catch(t){return-1048576!==e.ioReader.error?(n.z3(`read packet error, ${t}`,B,416),o.LR):e.ioReader.error}}async syncFrame(e){let t=p.Dh;for(;;)try{const i=await e.ioReader.peekUint16();if((65529===i||65528===i)&&(t=e.ioReader.getPos(),this.context.bitReader.reset(),this.context.bitReader.appendBuffer(await e.ioReader.peekBuffer(16)),!(0,f.x)(this.context.bitReader,{},!0)))break;await e.ioReader.skip(1)}catch(e){break}t!==p.Dh&&await e.ioReader.seek(t)}async seek(e,t,i,a){const r=e.ioReader.getPos(),s=t.privData;if(2&a){const t=await e.ioReader.fileSize();return t<=BigInt(0)?BigInt(o.E$):(i<BigInt(0)?i=BigInt(0):i>t&&(i=t),await e.ioReader.seek(i),4&a||await this.syncFrame(e),r)}if(t&&t.sampleIndexes.length){let a=w.El(t.sampleIndexes,(e=>e.pts>i?-1:1));if(a>0&&(0,x.k)(i-t.sampleIndexes[a-1].pts,t.timeBase,p.i0)<BigInt(5e3))return n.Yz(`seek in sampleIndexes, found index: ${a}, pts: ${t.sampleIndexes[a-1].pts}, pos: ${t.sampleIndexes[a-1].pos}`,B,483),await e.ioReader.seek(t.sampleIndexes[a-1].pos),s.cacheBuffer=null,r}if(s.seekPoints.length){let t=0;for(let e=0;e<s.seekPoints.length;e++){if(s.seekPoints[e].pts===i){t=e;break}if(s.seekPoints[e].pts>i){t=Math.max(e-1,0);break}}const a=s.seekPoints[t];return n.Yz(`seek in seekPoints, found index: ${t}, pts: ${a.pts}, pos: ${a.pos+s.firstFramePos}`,B,503),await e.ioReader.seek(a.pos+s.firstFramePos),s.cacheBuffer=null,r}n.Yz("not found any keyframe index, try to seek in bytes",B,509);const c=await(0,g.A)(e,t,i,s.firstFramePos,this.readAVPacket.bind(this),this.syncFrame.bind(this));return c>0&&(s.cacheBuffer=null),c}getAnalyzeStreamsCount(){return 1}}},85947:(e,t,i)=>{i.d(t,{A:()=>r});var a=i(134);class r{constructor(){(0,a.A)(this,"type",-1),(0,a.A)(this,"onStreamAdd",void 0)}async destroy(e){}}},91375:(e,t,i)=>{i.d(t,{x:()=>c});var a=i(9705),r=i(4624),s=i(14769),n=i(13188);const o="src/avformat/formats/flac/iflac.ts";function c(e,t,i=!1){const c=e.getPointer();if(32764!=(32767&e.readU(15)))return!i&&r.z3("invalid sync code",o,57),a.LR;t.isVarSize=e.readU1();const h=e.readU(4),d=e.readU(4);if(t.chMode=e.readU(4),t.chMode<s.jA)t.channels=t.chMode+1,t.chMode=0;else{if(!(t.chMode<s.jA+3))return!i&&r.z3(`invalid channel mode: ${t.chMode}`,o,76),a.LR;t.channels=2,t.chMode-=s.jA-1}const m=e.readU(3);if(3===m)return!i&&r.z3(`invalid sample size code: ${m}`,o,82),a.LR;if(t.bps=s.oe[m],e.readU1())return!i&&r.z3("broken stream, invalid padding",o,88),a.LR;if(t.frameOrSampleNum=function(e){let t=BigInt(Math.floor(e.readU(8))),i=(t&BigInt(128))>>BigInt(1);if((t&BigInt(192))===BigInt(128)||t>=BigInt(254))return-BigInt(1);for(;t&i;){const a=BigInt(Math.floor(e.readU(8)))-BigInt(128);if(a>>BigInt(6))return-BigInt(1);t=(t<<BigInt(6))+a,i<<=BigInt(5)}return t&=(i<<BigInt(1))-BigInt(1),t}(e),t.frameOrSampleNum<0)return!i&&r.z3("sample/frame number invalid",o,95),a.LR;if(0===h)return!i&&r.z3("reserved blocksize code: 0",o,100),a.LR;if(t.blocksize=6===h?e.readU(8)+1:7===h?e.readU(16)+1:s.Xr[h],d<12)t.sampleRate=s.DK[d];else if(12===d)t.sampleRate=1e3*e.readU(8);else if(13===d)t.sampleRate=e.readU(16);else{if(14!==d)return!i&&r.z3(`illegal sample rate code ${d}`,o,126),a.LR;t.sampleRate=10*e.readU(16)}return(0,n.A)(e.getBuffer().subarray(c,e.getPointer()))!==e.readU(8)?(!i&&r.z3("header crc mismatch",o,133),a.LR):0}},38743:(e,t,i)=>{i.d(t,{B:()=>o,h:()=>c});var a=i(134),r=i(77231),s=i(50011);class n{constructor(){(0,a.A)(this,"list",void 0),this.list=[]}read(e,t){for(let i=0;i<t;i++){const t=e.readUint32();this.list.push(e.readString(t))}}write(e){for(let t=0;t<this.list.length;t++){const i=s.encode(this.list[t]);e.writeUint32(i.length),e.writeBuffer(i)}}addComment(e){this.list.push(e)}}class o{constructor(){(0,a.A)(this,"capturePattern",void 0),(0,a.A)(this,"streamStructureVersion",void 0),(0,a.A)(this,"headerTypeFlag",void 0),(0,a.A)(this,"granulePosition",void 0),(0,a.A)(this,"serialNumber",void 0),(0,a.A)(this,"pageSequenceNumber",void 0),(0,a.A)(this,"crcCheckSum",void 0),(0,a.A)(this,"numberPageSegments",void 0),(0,a.A)(this,"segmentTable",void 0),(0,a.A)(this,"payload",void 0),(0,a.A)(this,"pos",void 0),this.reset()}reset(){this.capturePattern="OggS",this.streamStructureVersion=0,this.headerTypeFlag=0,this.granulePosition=r.Dh,this.serialNumber=0,this.pageSequenceNumber=0,this.crcCheckSum=0,this.numberPageSegments=0,this.segmentTable=[],this.pos=BigInt(0)}async read(e){this.pos=e.getPos(),await this.readPageHeader(e);const t=this.segmentTable.reduce(((e,t)=>e+t),0);t&&(this.payload=await e.readBuffer(t))}async readPageHeader(e){if(this.capturePattern=await e.readString(4),this.streamStructureVersion=await e.readUint8(),this.headerTypeFlag=await e.readUint8(),this.granulePosition=await e.readUint64(),this.serialNumber=await e.readUint32(),this.pageSequenceNumber=await e.readUint32(),this.crcCheckSum=await e.readUint32(),this.numberPageSegments=await e.readUint8(),this.numberPageSegments)for(let t=0;t<this.numberPageSegments;t++){const t=await e.readUint8();this.segmentTable.push(t)}}write(e){if(this.pos=e.getPos(),e.writeString(this.capturePattern),e.writeUint8(this.streamStructureVersion),e.writeUint8(this.headerTypeFlag),e.writeUint64(this.granulePosition),e.writeUint32(this.serialNumber),e.writeUint32(this.pageSequenceNumber),e.writeUint32(this.crcCheckSum),this.payload){this.numberPageSegments=Math.floor(this.payload.length/255)+1;const t=this.payload.length%255;e.writeUint8(this.numberPageSegments);for(let t=0;t<this.numberPageSegments-1;t++)e.writeUint8(255);e.writeUint8(t),e.writeBuffer(this.payload)}else e.writeUint8(0)}}class c{constructor(){(0,a.A)(this,"streamIndex",void 0),(0,a.A)(this,"signature",void 0),(0,a.A)(this,"vendorStringLength",void 0),(0,a.A)(this,"vendorString",void 0),(0,a.A)(this,"userCommentListLength",void 0),(0,a.A)(this,"comments",void 0),this.vendorString="v0.8.1-7-g5bb8f73",this.vendorStringLength=this.vendorString.length,this.userCommentListLength=0,this.comments=new n}read(e){this.vendorStringLength=e.readUint32(),this.vendorString=e.readString(this.vendorStringLength),this.userCommentListLength=e.readUint32(),this.userCommentListLength&&this.comments.read(e,this.userCommentListLength)}write(e){const t=s.encode(this.vendorString);e.writeUint32(t.length),e.writeBuffer(t),e.writeUint32(this.comments.list.length),this.comments.write(e)}addComment(e){this.comments.addComment(e)}setCodec(e){}}},87400:(e,t,i)=>{i.d(t,{GM:()=>c,mS:()=>o,ol:()=>n});var a=i(134),r=i(38743);i(95335),i(34677);const s={album:"album",artist:"artist",description:"description",encoder:"encoder",title:"title",tracknumber:"track",date:"date",genre:"genre",comment:"comment",albumartist:"albumArtist",composer:"composer",performer:"performer",discnumber:"disc",organization:"vendor",copyright:"copyright",license:"license",isrc:"isrc",lyrics:"lyrics",language:"language",label:"vendor",script:"lyrics",encoded_by:"vendor"};function n(e,t){e&&e.forEach((e=>{const i=e.split("=");if(2===i.length){const e=i[0].trim().toLowerCase(),a=i[1].trim();s[e]?t[s[e]]=a:t[e.toLowerCase()]=a}}))}class o{constructor(e="vorbis"){(0,a.A)(this,"streamIndex",void 0),(0,a.A)(this,"packetType",void 0),(0,a.A)(this,"signature",void 0),(0,a.A)(this,"version",void 0),(0,a.A)(this,"channels",void 0),(0,a.A)(this,"sampleRate",void 0),(0,a.A)(this,"bitrateMaximum",void 0),(0,a.A)(this,"bitrateNominal",void 0),(0,a.A)(this,"bitrateMinimum",void 0),(0,a.A)(this,"blocksize0",void 0),(0,a.A)(this,"blocksize1",void 0),(0,a.A)(this,"framingFlag",void 0),this.signature=e,this.version=0,this.channels=1,this.sampleRate=48e3,this.bitrateMaximum=0,this.bitrateNominal=0,this.bitrateMinimum=0,this.blocksize0=2048,this.blocksize1=256}read(e){this.packetType=e.readUint8(),this.signature=e.readString(6),this.version=e.readUint32(),this.channels=e.readUint8(),this.sampleRate=e.readInt32(),this.bitrateMaximum=e.readInt32(),this.bitrateNominal=e.readInt32(),this.bitrateMinimum=e.readInt32();const t=255&e.readUint8();this.blocksize0=Math.pow(2,t>>>4),this.blocksize1=Math.pow(2,15&t),this.framingFlag=e.readUint8()}write(e){e.writeUint8(1),e.writeString(this.signature),e.writeUint32(this.version),e.writeUint8(this.channels),e.writeInt32(this.sampleRate),e.writeInt32(this.bitrateMaximum),e.writeInt32(this.bitrateNominal),e.writeInt32(this.bitrateMinimum),e.writeUint8(Math.log2(this.blocksize0)<<4|Math.log2(this.blocksize1)),e.writeUint8(1)}setCodec(e){this.sampleRate=e.sampleRate,this.channels=e.chLayout.nbChannels}}class c extends r.h{constructor(e="vorbis"){super(),(0,a.A)(this,"packetType",void 0),(0,a.A)(this,"framingFlag",void 0),this.signature=e,this.packetType=1,this.framingFlag=1}read(e){this.packetType=e.readUint8(),this.signature=e.readString(6),super.read(e),"vorbis"===this.signature&&(this.framingFlag=e.readUint8())}write(e){e.writeUint8(this.packetType),e.writeString(this.signature),super.write(e),"vorbis"===this.signature&&e.writeUint8(this.framingFlag)}addComment(e){this.comments.addComment(e)}setCodec(e){}}},2187:(e,t,i)=>{i.d(t,{d:()=>n});var a=i(72739),r=i(44328),s=i(77231);function n(e,t,i){let n=BigInt(0);return a.__(e,(e=>{n+=e.codecpar.bitrate*(0,r.k)(t,i,s.i0)/BigInt(8e3)})),n}},52071:(e,t,i)=>{i.d(t,{A:()=>m});var a=i(63939),r=(i(9599),i(77231)),s=i(44328),n=i(2187),o=i(71517),c=i(9705),h=i(4624);const d="src/avformat/function/seekInBytes.ts";async function m(e,t,i,m,f,l){const u=e.ioReader.getPos(),p=await e.ioReader.fileSize();let g=r.Dh,w=i;t.startTime!==r.Dh?w-=t.startTime:w-=t.firstDTS;const x=(0,s.k)(i,t.timeBase,r.i0);if(x<BigInt(1e4))return h.Yz(`seek pts is earlier then 10s, seek to first packet pos(${m}) directly`,d,62),await e.ioReader.seek(m),u;let R=(0,n.d)(e.streams,w,t.timeBase);const B=p-(0,n.d)(e.streams,BigInt(1e4),r.i0),b=(0,n.d)(e.streams,BigInt(1e4),r.i0);if(R>B&&(R=B),R<m)return await e.ioReader.seek(m),u;const S=(0,o._5)();let I=p,k=BigInt(0);for(;;){if(I-k<b){g=k;break}if(await e.ioReader.seek(R),await l(e),8&e.ioReader.flags)break;const t=e.ioReader.getPos();if(!(await f(e,S)>=0)){g=r.Dh;break}{const e=(0,s.Mr)(a.f[17](S+8),S+72,r.i0),i=e-x;if(h.Yz(`try to seek to pos: ${R}, got packet pts: ${a.f[17](S+8)}(${e}ms), diff: ${i}ms`,d,100),i<=BigInt(0)&&-i<BigInt(1e4)){g=t;break}i>BigInt(0)?(I=R,R=k+I>>BigInt(1)):(k=R,R=k+I>>BigInt(1))}if(8&e.ioReader.flags)break}return(0,o.Qe)(S),g!==r.Dh?(h.Yz(`finally seek to pos ${g}`,d,131),await e.ioReader.seek(g),await l(e),u):(await e.ioReader.seek(u),8&e.ioReader.flags?BigInt(c.LT):BigInt(c.E$))}},14769:(e,t,i)=>{i.d(t,{DK:()=>o,XC:()=>h,Xr:()=>c,jA:()=>s,ob:()=>r,oe:()=>n});var a=i(31865);const r=34,s=8,n=[0,8,12,0,16,20,24,32],o=[0,88200,176400,192e3,8e3,16e3,22050,24e3,32e3,44100,48e3,96e3,0,0,0,0],c=[0,192,576,1152,2304,4608,0,0,256,512,1024,2048,4096,8192,16384,32768];function h(e,t){if(!t&&e.sideData[1]&&(t=e.sideData[1]),t&&t.length===r){const{bitsPerRawSample:i,sampleRate:r,channels:s}=function(e){const t=new a.A(e);t.skip(10);const i=t.readUint24();return{sampleRate:i>>4,channels:1+((15&i)>>>1),bitsPerRawSample:1+((1&i)<<4|(240&t.readUint8())>>>4)}}(t);e.codecpar.bitsPerRawSample=i,e.codecpar.sampleRate=r,e.codecpar.chLayout.nbChannels=s}}},13188:(e,t,i)=>{function a(e,t=0){for(let i=0;i<e.length;i++){t^=e[i];for(let e=0;e<8;e++)128&t?t=t<<1^7:t<<=1}return 255&t}i.d(t,{A:()=>a})}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[487],{85947:(t,e,s)=>{s.d(e,{A:()=>h});var i=s(134);class h{constructor(){(0,i.A)(this,"type",-1),(0,i.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},85487:(t,e,s)=>{s.r(e),s.d(e,{default:()=>v});var i=s(134),h=s(63939),r=s(50932),a=s(9705),n=s(85947),o=s(14686),u=s(37837),d=s(71517),c=s(95335),p=s(92647),l=s(67659),f=s(77231),g=s(37246),b=s(23991),A=s(37805);const y={framerate:{num:30,den:1}};class v extends n.A{constructor(t={}){super(),(0,i.A)(this,"type",12),(0,i.A)(this,"options",void 0),(0,i.A)(this,"currentDts",void 0),(0,i.A)(this,"currentPts",void 0),(0,i.A)(this,"step",void 0),(0,i.A)(this,"slices",void 0),(0,i.A)(this,"naluPos",void 0),(0,i.A)(this,"queue",void 0),(0,i.A)(this,"bitReader",void 0),(0,i.A)(this,"sliceType",void 0),(0,i.A)(this,"poc",void 0),(0,i.A)(this,"pocTid0",void 0),(0,i.A)(this,"sps",void 0),(0,i.A)(this,"pps",void 0),(0,i.A)(this,"naluReader",void 0),this.options=c.X$({},y,t)}init(t){t.ioReader&&t.ioReader.setEndian(!1),this.slices=[],this.queue=[],this.bitReader=new g.A(50),this.naluReader=new A.A}async destroy(t){if(this.queue.length){for(let t=0;t<this.queue.length;t++)(0,d.Qe)(this.queue[t].avpacket);this.queue.length=0}}isFrameNalu(t){return(t[1===t[2]?3:4]>>>1&63)<32}async readNaluFrame(t){let e=!1;const s=this.slices;for(this.slices=[],s.length&&(e=this.isFrameNalu(s[0]));;){const i=await this.naluReader.read(t.ioReader);if(!i)return s;const h=i[1===i[2]?3:4]>>>1&63;if(this.isFrameNalu(i))if(e){if(i[1===i[2]?5:6]>>>7)return this.slices.push(i),s;s.push(i)}else s.push(i),e=!0;else{if(e&&(35===h||33===h||34===h||32===h))return this.slices.push(i),s;s.push(i)}}}async readHeader(t){const e=t.createStream();for(e.codecpar.codecType=0,e.codecpar.codecId=173,e.timeBase.den=f.SF,e.timeBase.num=1,e.codecpar.bitFormat=2,this.currentDts=BigInt(0),this.currentPts=BigInt(0),this.naluPos=BigInt(0),this.poc=0,this.pocTid0=0,this.step=BigInt(Math.floor(f.SF/this.options.framerate.num*this.options.framerate.den));;){const s=await this.readNaluFrame(t);if(!s.length)return-1048576;const i=(0,p.A)(Uint8Array,s),a=l.sL(i);if(a){e.codecpar.extradata=(0,u.sY)(a.length),(0,o.lW)(e.codecpar.extradata,a.length,a),e.codecpar.extradataSize=a.length,l.XC(e,a);const n=s.find((t=>33==(t[1===t[2]?3:4]>>>1&63))),c=s.find((t=>34==(t[1===t[2]?3:4]>>>1&63)));this.sps=l.wf(n),this.pps=l.ZU(c);const p=(0,d._5)(),f=(0,u.sY)(i.length);(0,o.lW)(f,i.length,i),(0,d.NX)(p,f,i.length),r.M[17](p+56,this.naluPos),this.naluPos+=BigInt(Math.floor(i.length)),r.M[17](p+16,this.currentDts),this.currentDts+=this.step,r.M[17](p+8,this.currentPts),this.currentPts+=this.step,r.M[15](p+32,e.index),r.M[15](p+36,1|h.f[15](p+36)),r.M[15](p+72,e.timeBase.num),r.M[15](p+76,e.timeBase.den),r.M[15](p+80,2),t.interval.packetBuffer.push(p);break}this.naluPos+=BigInt(Math.floor(i.length))}return 0}async readAVPacket_(t,e){const s=t.getStreamByMediaType(0),i=await this.readNaluFrame(t);if(!i.length)return-1048576;this.sliceType=-1;let a=!1,n=!0;i.forEach((t=>{const e=(1===t[2]?t[3]:t[4])>>>1&63,s=7&(1===t[2]?t[4]:t[5]);if(33===e&&(this.sps=l.wf(t)),34===e&&(this.pps=l.ZU(t)),19!==e&&20!==e||(a=!0),e<32&&n){n=!1,this.bitReader.reset(),this.bitReader.appendBuffer(t.subarray(1===t[2]?5:6,50));const i=this.bitReader.readU1();if(e>=16&&e<=23&&(a=!0,this.bitReader.readU1()),b.xb(this.bitReader),!i){this.pps.dependent_slice_segment_flag&&this.bitReader.readU1();const t=Math.ceil(Math.log2(this.sps.ctb_width*this.sps.ctb_height));this.bitReader.readU(t)}for(let t=0;t<this.pps.num_extra_slice_header_bits;t++)this.bitReader.readU1();if(this.sliceType=b.xb(this.bitReader),this.pps.output_flag_present_flag&&this.bitReader.readU1(),this.sps.separate_colour_plane_flag&&this.bitReader.readU(2),19===e||20===e)this.poc=0;else{const t=this.bitReader.readU(this.sps.log2_max_poc_lsb);let s=1<<this.sps.log2_max_poc_lsb,i=this.pocTid0%s,h=this.pocTid0-i,r=0;r=t<i&&i-t>=s/2?h+s:t>i&&t-i>s/2?h-s:h,16!=e&&17!=e&&18!=e||(r=0),this.poc=r+t}0==s&&0!=e&&2!=e&&4!=e&&6!=e&&8!=e&&7!=e&&9!=e&&(this.pocTid0=this.poc)}}));const c=(0,p.A)(Uint8Array,i),f=(0,u.sY)(c.length);return(0,o.lW)(f,c.length,c),(0,d.NX)(e,f,c.length),r.M[17](e+56,this.naluPos),this.naluPos+=BigInt(Math.floor(c.length)),r.M[17](e+16,this.currentDts),this.currentDts+=this.step,r.M[15](e+32,s.index),r.M[15](e+72,s.timeBase.num),r.M[15](e+76,s.timeBase.den),r.M[15](e+80,2),a&&r.M[15](e+36,1|h.f[15](e+36)),0}async readAVPacket(t,e){let s=this.queue.length;const i=()=>{this.queue.length>1&&this.queue.sort(((t,e)=>t.poc-e.poc>0?1:-1));for(let t=0;t<this.queue.length;t++)r.M[17](this.queue[t].avpacket+8,this.currentPts),this.currentPts+=this.step;this.queue.length>1&&this.queue.sort(((t,e)=>h.f[17](t.avpacket+16)-h.f[17](e.avpacket+16)>BigInt(0)?1:-1)),this.queue.length&&((0,d.rN)(e,this.queue[0].avpacket),(0,d.Qe)(this.queue[0].avpacket));for(let e=1;e<this.queue.length;e++)t.interval.packetBuffer.push(this.queue[e].avpacket);this.queue.length=0};for(;;){const e=(0,d._5)();let r=await this.readAVPacket_(t,e);if(r<0)return(0,d.Qe)(e),this.queue.length?(i(),0):r;if(1&h.f[15](e+36)||1===this.sliceType||2===this.sliceType){if(1===s||1&h.f[15](e+36)&&this.queue.length)return i(),this.queue.push({avpacket:e,poc:this.poc}),0;this.queue.push({avpacket:e,poc:this.poc}),s++}else this.queue.push({avpacket:e,poc:this.poc})}}async seek(t,e,s,i){return BigInt(a.E$)}getAnalyzeStreamsCount(){return 1}}},37805:(t,e,s)=>{s.d(e,{A:()=>a});var i=s(134),h=s(60264),r=s(92647);class a{constructor(){(0,i.A)(this,"buffer",void 0),(0,i.A)(this,"pos",void 0),(0,i.A)(this,"end",void 0),(0,i.A)(this,"ended",void 0),this.buffer=new Uint8Array(102400),this.pos=0,this.end=0,this.ended=!1}async read(t){if(this.ended&&this.pos>=this.end)return;const e=[];if(this.pos<this.end-4){let t=h.Ky(this.buffer.subarray(this.pos,this.end-4),3);if(t.offset>-1){const e=this.buffer.slice(this.pos,this.pos+t.offset);return this.pos+=t.offset,e}e.push(this.buffer.slice(this.pos,this.end-4)),this.buffer.copyWithin(0,this.end-4,this.end),this.pos=0,this.end=4}for(;;){if(!this.ended&&this.end<this.buffer.length)try{const e=await t.readToBuffer(this.buffer.length-this.end,this.buffer.subarray(this.end));this.end+=e}catch(t){if(this.ended=!0,this.pos>=this.end)return e.length?(0,r.A)(Uint8Array,e):null}let s=h.Ky(this.buffer.subarray(this.pos,this.end-4),e.length?0:3);if(s.offset>-1)return e.push(this.buffer.slice(this.pos,this.pos+s.offset)),this.pos+=s.offset,(0,r.A)(Uint8Array,e);if(this.ended)return e.push(this.buffer.slice(this.pos,this.end)),this.pos=this.end=0,(0,r.A)(Uint8Array,e);e.push(this.buffer.slice(this.pos,this.end-4)),this.buffer.copyWithin(0,this.end-4,this.end),this.pos=0,this.end=4}}reset(){this.pos=0,this.end=0,this.ended=!1}}}}]);
1
+ "use strict";(self.webpackChunkAVPlayer=self.webpackChunkAVPlayer||[]).push([[487],{85947:(t,e,s)=>{s.d(e,{A:()=>h});var i=s(134);class h{constructor(){(0,i.A)(this,"type",-1),(0,i.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},85487:(t,e,s)=>{s.r(e),s.d(e,{default:()=>v});var i=s(134),h=s(63939),r=s(50932),a=s(9705),n=s(85947),o=s(14686),u=s(37837),d=s(71517),c=s(95335),p=s(92647),l=s(67659),f=s(77231),g=s(37246),A=s(23991),b=s(37805);const y={framerate:{num:30,den:1}};class v extends n.A{constructor(t={}){super(),(0,i.A)(this,"type",12),(0,i.A)(this,"options",void 0),(0,i.A)(this,"currentDts",void 0),(0,i.A)(this,"currentPts",void 0),(0,i.A)(this,"step",void 0),(0,i.A)(this,"slices",void 0),(0,i.A)(this,"naluPos",void 0),(0,i.A)(this,"queue",void 0),(0,i.A)(this,"bitReader",void 0),(0,i.A)(this,"sliceType",void 0),(0,i.A)(this,"poc",void 0),(0,i.A)(this,"pocTid0",void 0),(0,i.A)(this,"sps",void 0),(0,i.A)(this,"pps",void 0),(0,i.A)(this,"naluReader",void 0),this.options=c.X$({},y,t)}init(t){t.ioReader&&t.ioReader.setEndian(!1),this.slices=[],this.queue=[],this.bitReader=new g.A(50),this.naluReader=new b.A}async destroy(t){if(this.queue.length){for(let t=0;t<this.queue.length;t++)(0,d.Qe)(this.queue[t].avpacket);this.queue.length=0}}isFrameNalu(t){return(t[1===t[2]?3:4]>>>1&63)<32}async readNaluFrame(t){let e=!1;const s=this.slices;for(this.slices=[],s.length&&(e=this.isFrameNalu(s[0]));;){const i=await this.naluReader.read(t.ioReader);if(!i)return s;const h=i[1===i[2]?3:4]>>>1&63;if(this.isFrameNalu(i))if(e){if(i[1===i[2]?5:6]>>>7)return this.slices.push(i),s;s.push(i)}else s.push(i),e=!0;else{if(e&&(35===h||33===h||34===h||32===h))return this.slices.push(i),s;s.push(i)}}}async readHeader(t){const e=t.createStream();for(e.codecpar.codecType=0,e.codecpar.codecId=173,e.timeBase.den=f.SF,e.timeBase.num=1,e.codecpar.bitFormat=2,this.currentDts=BigInt(0),this.currentPts=BigInt(0),this.naluPos=BigInt(0),this.poc=0,this.pocTid0=0,this.step=BigInt(Math.floor(f.SF/this.options.framerate.num*this.options.framerate.den));;){const s=await this.readNaluFrame(t);if(!s.length)return-1048576;const i=(0,p.A)(Uint8Array,s),a=l.sL(i);if(a){e.codecpar.extradata=(0,u.sY)(a.length),(0,o.lW)(e.codecpar.extradata,a.length,a),e.codecpar.extradataSize=a.length,l.XC(e,a);const n=s.find((t=>33==(t[1===t[2]?3:4]>>>1&63))),c=s.find((t=>34==(t[1===t[2]?3:4]>>>1&63)));this.sps=l.wf(n),this.pps=l.ZU(c);const p=(0,d._5)(),f=(0,u.sY)(i.length);(0,o.lW)(f,i.length,i),(0,d.NX)(p,f,i.length),r.M[17](p+56,this.naluPos),this.naluPos+=BigInt(Math.floor(i.length)),r.M[17](p+16,this.currentDts),this.currentDts+=this.step,r.M[17](p+8,this.currentPts),this.currentPts+=this.step,r.M[15](p+32,e.index),r.M[15](p+36,1|h.f[15](p+36)),r.M[15](p+72,e.timeBase.num),r.M[15](p+76,e.timeBase.den),r.M[15](p+80,2),t.interval.packetBuffer.push(p);break}this.naluPos+=BigInt(Math.floor(i.length))}return 0}async readAVPacket_(t,e){const s=t.getStreamByMediaType(0),i=await this.readNaluFrame(t);if(!i.length)return-1048576;this.sliceType=-1;let a=!1,n=!0;i.forEach((t=>{const e=(1===t[2]?t[3]:t[4])>>>1&63,s=7&(1===t[2]?t[4]:t[5]);if(33===e&&(this.sps=l.wf(t)),34===e&&(this.pps=l.ZU(t)),19!==e&&20!==e||(a=!0),e<32&&n){n=!1,this.bitReader.reset(),this.bitReader.appendBuffer(t.subarray(1===t[2]?5:6,50));const i=this.bitReader.readU1();if(e>=16&&e<=23&&(a=!0,this.bitReader.readU1()),A.xb(this.bitReader),!i){this.pps.dependent_slice_segment_flag&&this.bitReader.readU1();const t=Math.ceil(Math.log2(this.sps.ctb_width*this.sps.ctb_height));this.bitReader.readU(t)}for(let t=0;t<this.pps.num_extra_slice_header_bits;t++)this.bitReader.readU1();if(this.sliceType=A.xb(this.bitReader),this.pps.output_flag_present_flag&&this.bitReader.readU1(),this.sps.separate_colour_plane_flag&&this.bitReader.readU(2),19===e||20===e)this.poc=0;else{const t=this.bitReader.readU(this.sps.log2_max_poc_lsb);let s=1<<this.sps.log2_max_poc_lsb,i=this.pocTid0%s,h=this.pocTid0-i,r=0;r=t<i&&i-t>=s/2?h+s:t>i&&t-i>s/2?h-s:h,16!=e&&17!=e&&18!=e||(r=0),this.poc=r+t}0==s&&0!=e&&2!=e&&4!=e&&6!=e&&8!=e&&7!=e&&9!=e&&(this.pocTid0=this.poc)}}));const c=(0,p.A)(Uint8Array,i),f=(0,u.sY)(c.length);return(0,o.lW)(f,c.length,c),(0,d.NX)(e,f,c.length),r.M[17](e+56,this.naluPos),this.naluPos+=BigInt(Math.floor(c.length)),r.M[17](e+16,this.currentDts),this.currentDts+=this.step,r.M[15](e+32,s.index),r.M[15](e+72,s.timeBase.num),r.M[15](e+76,s.timeBase.den),r.M[15](e+80,2),a&&r.M[15](e+36,1|h.f[15](e+36)),0}async readAVPacket(t,e){let s=this.queue.length;const i=()=>{this.queue.length>1&&this.queue.sort(((t,e)=>t.poc-e.poc>0?1:-1));for(let t=0;t<this.queue.length;t++)r.M[17](this.queue[t].avpacket+8,this.currentPts),this.currentPts+=this.step;this.queue.length>1&&this.queue.sort(((t,e)=>h.f[17](t.avpacket+16)-h.f[17](e.avpacket+16)>BigInt(0)?1:-1)),this.queue.length&&((0,d.rN)(e,this.queue[0].avpacket),(0,d.Qe)(this.queue[0].avpacket));for(let e=1;e<this.queue.length;e++)t.interval.packetBuffer.push(this.queue[e].avpacket);this.queue.length=0};for(;;){const e=(0,d._5)();let r=await this.readAVPacket_(t,e);if(r<0)return(0,d.Qe)(e),this.queue.length?(i(),0):r;if(1&h.f[15](e+36)||1===this.sliceType||2===this.sliceType){if(1===s||1&h.f[15](e+36)&&this.queue.length)return i(),this.queue.push({avpacket:e,poc:this.poc}),0;this.queue.push({avpacket:e,poc:this.poc}),s++}else this.queue.push({avpacket:e,poc:this.poc})}}async seek(t,e,s,i){return BigInt(a.E$)}getAnalyzeStreamsCount(){return 1}}},37805:(t,e,s)=>{s.d(e,{A:()=>a});var i=s(134),h=s(60264),r=s(92647);class a{constructor(){(0,i.A)(this,"buffer",void 0),(0,i.A)(this,"pos",void 0),(0,i.A)(this,"end",void 0),(0,i.A)(this,"ended",void 0),this.buffer=new Uint8Array(102400),this.pos=0,this.end=0,this.ended=!1}async read(t){if(this.ended&&this.pos>=this.end)return;const e=[];if(this.pos<this.end-4){let t=h.Ky(this.buffer.subarray(this.pos,this.end-4),3);if(t.offset>-1){const e=this.buffer.slice(this.pos,this.pos+t.offset);return this.pos+=t.offset,e}e.push(this.buffer.slice(this.pos,this.end-4)),this.buffer.copyWithin(0,this.end-4,this.end),this.pos=0,this.end=4}for(;;){if(!this.ended&&this.end<this.buffer.length)try{const e=await t.readToBuffer(this.buffer.length-this.end,this.buffer.subarray(this.end));this.end+=e}catch(t){if(this.ended=!0,this.pos>=this.end)return e.length?(0,r.A)(Uint8Array,e):null}let s=h.Ky(this.buffer.subarray(this.pos,this.end-4),e.length?0:3);if(s.offset>-1)return e.push(this.buffer.slice(this.pos,this.pos+s.offset)),this.pos+=s.offset,(0,r.A)(Uint8Array,e);if(this.ended)return e.push(this.buffer.slice(this.pos,this.end)),this.pos=this.end=0,(0,r.A)(Uint8Array,e);e.push(this.buffer.slice(this.pos,this.end-4)),this.buffer.copyWithin(0,this.end-4,this.end),this.pos=0,this.end=4}}reset(){this.pos=0,this.end=0,this.ended=!1}}}}]);