@libmedia/avplayer 0.11.3 → 0.12.0

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.
Files changed (56) hide show
  1. package/dist/esm/19.avplayer.js +1 -1
  2. package/dist/esm/195.avplayer.js +1 -0
  3. package/dist/esm/367.avplayer.js +1 -1
  4. package/dist/esm/400.avplayer.js +1 -1
  5. package/dist/esm/421.avplayer.js +1 -1
  6. package/dist/esm/430.avplayer.js +1 -1
  7. package/dist/esm/464.avplayer.js +1 -1
  8. package/dist/esm/566.avplayer.js +1 -1
  9. package/dist/esm/60.avplayer.js +1 -1
  10. package/dist/esm/690.avplayer.js +1 -1
  11. package/dist/esm/799.avplayer.js +1 -1
  12. package/dist/esm/801.avplayer.js +1 -1
  13. package/dist/esm/81.avplayer.js +1 -1
  14. package/dist/esm/814.avplayer.js +1 -1
  15. package/dist/esm/82.avplayer.js +1 -1
  16. package/dist/esm/852.avplayer.js +1 -1
  17. package/dist/esm/902.avplayer.js +1 -1
  18. package/dist/esm/913.avplayer.js +1 -1
  19. package/dist/esm/945.avplayer.js +1 -1
  20. package/dist/esm/949.avplayer.js +1 -1
  21. package/dist/esm/953.avplayer.js +1 -1
  22. package/dist/esm/avplayer.js +1 -1
  23. package/dist/types/AVPlayer.d.ts +39 -21
  24. package/dist/types/Controller.d.ts +3 -2
  25. package/dist/types/JitterBufferController.d.ts +2 -1
  26. package/dist/types/StatsController.d.ts +1 -1
  27. package/dist/types/mse/MSEPipeline.d.ts +10 -9
  28. package/dist/types/struct.d.ts +5 -5
  29. package/dist/types/subtitle/AssRender.d.ts +1 -1
  30. package/dist/types/subtitle/SubtitleRender.d.ts +4 -4
  31. package/dist/types/type.d.ts +2 -2
  32. package/dist/umd/19.avplayer.js +1 -1
  33. package/dist/umd/195.avplayer.js +1 -0
  34. package/dist/umd/367.avplayer.js +1 -1
  35. package/dist/umd/400.avplayer.js +1 -1
  36. package/dist/umd/421.avplayer.js +1 -1
  37. package/dist/umd/430.avplayer.js +1 -1
  38. package/dist/umd/464.avplayer.js +1 -1
  39. package/dist/umd/566.avplayer.js +1 -1
  40. package/dist/umd/60.avplayer.js +1 -1
  41. package/dist/umd/690.avplayer.js +1 -1
  42. package/dist/umd/799.avplayer.js +1 -1
  43. package/dist/umd/801.avplayer.js +1 -1
  44. package/dist/umd/81.avplayer.js +1 -1
  45. package/dist/umd/814.avplayer.js +1 -1
  46. package/dist/umd/82.avplayer.js +1 -1
  47. package/dist/umd/852.avplayer.js +1 -1
  48. package/dist/umd/902.avplayer.js +1 -1
  49. package/dist/umd/913.avplayer.js +1 -1
  50. package/dist/umd/945.avplayer.js +1 -1
  51. package/dist/umd/949.avplayer.js +1 -1
  52. package/dist/umd/953.avplayer.js +1 -1
  53. package/dist/umd/avplayer.js +1 -1
  54. package/package.json +12 -12
  55. package/dist/esm/733.avplayer.js +0 -1
  56. package/dist/umd/733.avplayer.js +0 -1
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[566],{81534:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(9655);class a{constructor(){(0,s.A)(this,"onFlush",void 0)}}},5866:(t,e,i)=>{i.d(e,{A:()=>p});var s=i(9655),a=i(81534),r=i(54893),n=i(10855),o=i(56719),h=i(20163);const l="src/avnetwork/bsp/aes/AESDecryptPipe.ts",d=16;let u=!0;const c=new Uint8Array(d).fill(d);class p extends a.A{constructor(t=0,e=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),(0,s.A)(this,"mode",void 0),(0,s.A)(this,"pos",void 0),this.mode=t,this.size=e,this.pointer=0,this.endPointer=0,this.pos=0,this.ended=!1,this.buffer=new Uint8Array(e),this.aesSoftDecryptor=new r.A(t),n.A.isSupport()&&u&&(this.aesWebDecryptor=new n.A(t)),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),t.byteLength<=8&&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,128)}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 decryptCBC(t){let e,i=0;this.aesTargetDecryptor!==this.aesWebDecryptor||this.ended||(e=this.buffer.subarray(this.pointer+t,this.pointer+t+d).slice(),this.buffer.set((await this.aesWebDecryptor.encryptPadding(c,this.buffer.subarray(this.pointer+t-d,this.pointer+t))).subarray(0,d),this.pointer+t),i=d);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-d-i,s.length-i).buffer,e&&this.buffer.set(e,this.pointer+t),this.pointer+=t,this.pos+=t,new Uint8Array(a)}catch(i){if(this.aesTargetDecryptor===this.aesWebDecryptor&&this.key.byteLength<=8)return h.R8("web aes decrypt failed, try to use soft decryptor",l,178),e&&this.buffer.set(e,this.pointer+t),this.aesTargetDecryptor=this.aesSoftDecryptor,u=!1,this.decryptCBC(t);h.h2("aes decrypt failed",l,188)}}getCTRIv(){const t=new Uint8Array(this.iv).slice();let e=Math.floor(this.pos/d);for(let i=15;i>=0&&e>0;i--){const s=t[i]+(255&e);t[i]=255&s,e=(e>>>8)+(s>>8)}return t.buffer}async decryptCTR(t){try{const e=this.buffer.subarray(this.pointer,this.pointer+t),i=await this.aesTargetDecryptor.decrypt(e,this.getCTRIv());return this.pointer+=t,this.pos+=t,new Uint8Array(i)}catch(e){if(this.aesTargetDecryptor===this.aesWebDecryptor&&this.key.byteLength<=8)return h.R8("web aes decrypt failed, try to use soft decryptor",l,214),this.aesTargetDecryptor=this.aesSoftDecryptor,u=!1,this.decryptCTR(t);h.h2("aes decrypt failed",l,220)}}async read(t){for(;!this.ended&&this.remainingLength()<48;)await this.flush();if(0===this.remainingLength())return-1048576;if(0===this.mode){const e=Math.min(Math.floor((this.remainingLength()-(this.ended?0:32))/d)*d,t.length);let i=await this.decryptCBC(e);return this.ended&&this.aesTargetDecryptor===this.aesSoftDecryptor&&(i=this.removePadding(i)),t.set(i),i.length}{const e=this.ended?this.remainingLength():Math.min(Math.floor(this.remainingLength()/d)*d,t.length);let i=await this.decryptCTR(e);return t.set(i),i.length}}}},4566:(t,e,i)=>{i.r(e),i.d(e,{default:()=>b});var s=i(9655),a=i(55906),r=i.n(a),n=i(33793),o=i.n(n),h=i(56719),l=i(72277),d=i(99868),u=i(10446),c=i(68141),p=i(33267),f=i(80155),m=i(20163),T=i(5866),E=i(68483),y=i(20086),A=i(10855),g=i(93426);const v="src/avnetwork/ioLoader/HlsIOLoader.ts";function I(t,e="GET"){var i,s,a;const r={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};return null!==(i=t.httpOptions)&&void 0!==i&&i.headers&&d.__(t.httpOptions.headers,((t,e)=>{r.headers[e]=t})),null!==(s=t.httpOptions)&&void 0!==s&&s.credentials&&(r.credentials=t.httpOptions.credentials),null!==(a=t.httpOptions)&&void 0!==a&&a.referrerPolicy&&(r.referrerPolicy=t.httpOptions.referrerPolicy),r}async function S(t,e,i,s){return new(r())(((a,r)=>{let n=0;!async function o(){try{const r=await fetch(t,{...I(e),signal:s}),d=await r.text(),u=(0,c.A)(d);if(i.isLive&&(!u.segments||u.segments.length<2)){var l;let t=5;null!==(l=u.segments)&&void 0!==l&&l.length&&(t=u.segments[0].duration*(2-u.segments.length)),m.R8(`wait for min buffer time, now segments: ${u.segments.length}`,v,92),await new h.A(t),n=0,o()}a(u)}catch(t){if("AbortError"===(null==t?void 0:t.name))return void a(null);if(n<i.retryCount)return n++,m.z3(`failed fetch m3u8 file, retry(${n}/3)`,v,106),await new h.A(i.retryInterval),o();m.z3("HLSLoader: exception, fetch slice error",v,111),r()}}()}))}class X{constructor(t,e,i,a){(0,s.A)(this,"options",void 0),(0,s.A)(this,"info",void 0),(0,s.A)(this,"mediaPlayList",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,"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),(0,s.A)(this,"isInitLoader",void 0),(0,s.A)(this,"minBuffer",void 0),(0,s.A)(this,"pendingBuffer",void 0),(0,s.A)(this,"magicAdded",void 0),(0,s.A)(this,"sleep",void 0),(0,s.A)(this,"aborted",void 0),(0,s.A)(this,"signal",void 0),this.options=t,this.info=e,this.segmentIndex=0,this.fetchedMap=new(o()),this.fetchedHistoryList=[],this.keyMap=new(o()),this.aborted=!1,i&&a&&this.setMediaPlayList(i,a)}setMediaPlayList(t,e){if(this.options.isLive){this.fetchedMap.clear(),this.fetchedHistoryList.length=0,this.segmentIndex=0;const t=e.segments.find((t=>t.uri===this.currentUri));if(t)for(e.segments.forEach(((e,i)=>{e.mediaSequenceNumber===t.mediaSequenceNumber+1?this.segmentIndex=i:e.mediaSequenceNumber<=t.mediaSequenceNumber&&(this.fetchedMap.set(e.uri,!0),this.fetchedHistoryList.push(e.uri))}));this.fetchedHistoryList.length>=10;)this.fetchedMap.delete(this.fetchedHistoryList.shift())}if(this.mediaListUrl=t,this.mediaPlayList=e,this.minBuffer=this.mediaPlayList.duration||0,this.mediaPlayList.endlist&&(this.options.isLive=!1),this.initLoaded=!0,this.mediaPlayList.segments.length&&this.mediaPlayList.segments[0].map&&(this.initLoaded=!1),this.mediaPlayList.lowLatencyCompatibility){const t=this.mediaPlayList.lowLatencyCompatibility.partHoldBack||this.mediaPlayList.lowLatencyCompatibility.holdBack||this.minBuffer;let e=0,s=!1,a=0;for(let r=this.mediaPlayList.segments.length-1;r>=0;r--){var i;const n=this.mediaPlayList.segments[r];if(null!==(i=n.parts)&&void 0!==i&&i.length){if(!n.uri)continue;for(let i=n.parts.length-1;i>=0;i--){const o=n.parts[i];if(!o.hint&&(e+=o.duration,o.independent&&(s=!0),e>=t&&s)){a=r;break}}if(e>=t&&s)break}else if(e+=n.duration,s=!0,e>=t&&s){a=r;break}}this.fetchedMap.clear(),this.fetchedHistoryList.length=0;for(let t=0;t<a;t++){const e=this.mediaPlayList.segments[t];this.fetchedMap.set(e.uri,!0),this.fetchedHistoryList.push(e.uri)}for(;this.fetchedHistoryList.length>=10;)this.fetchedMap.delete(this.fetchedHistoryList.shift());this.segmentIndex=a,this.minBuffer=e}}getMediaListUrl(){return this.mediaListUrl}async checkNeedDecrypt(t,e,i){if(!t)return void(this.aesDecryptPipe=null);if("aes-128"!==t.method.toLocaleLowerCase()&&"aes-128-ctr"!==t.method.toLocaleLowerCase()&&("aes-256"!==t.method.toLocaleLowerCase()&&"aes-256-ctr"!==t.method.toLocaleLowerCase()||!A.A.isSupport())){if("mp4"===e.split(".").pop())return void(this.aesDecryptPipe=null);m.h2(`m3u8 ts not support EXT-X-KEY METHOD ${t.method}`,v,284)}const s=t.uri;if(this.keyMap.has(s)?this.currentKey=this.keyMap.get(s):(this.currentKey=await(await fetch((0,u.ll)(this.mediaListUrl,s),I(this.info))).arrayBuffer(),this.keyMap.set(s,this.currentKey)),t.iv)this.currentIV=t.iv.buffer;else{const t=new Uint8Array(16);new DataView(t.buffer).setUint32(12,i,!1),this.currentIV=t.buffer}this.aesDecryptPipe=new T.A(t.method.toLocaleLowerCase().indexOf("ctr")>0?1:0),this.aesDecryptPipe.onFlush=async t=>this.loader.read(t),await this.aesDecryptPipe.expandKey(this.currentKey,this.currentIV)}handleSlice(t,e){const i=this.loader.getUrl().split(".").pop();if("mp3"!==i&&!this.magicAdded&&73===e[0]&&68===e[1]&&51===e[2]){var s;const a=null!==(s=g.HR[i])&&void 0!==s?s:-1;return-1===a?t:(t+6>e.length&&(this.pendingBuffer=e.slice(t-6)),e.set(e.slice(0,t-6),6),e[0]=76,e[1]=73,e[2]=77,e[3]=65,e[4]=a>>>8&255,e[5]=255&a,this.magicAdded=!0,this.pendingBuffer?t:t+6)}return t}async read(t){if(this.pendingBuffer){let e=this.pendingBuffer.length;return t.set(this.pendingBuffer),this.pendingBuffer=null,e}let e=0;if(this.loader){if(e=this.aesDecryptPipe?await this.aesDecryptPipe.read(t):await this.loader.read(t),-1048576!==e||this.aborted)return e;if(this.isInitLoader)this.initLoaded=!0;else 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-1048576;this.loader=null}if(this.options.isLive){var i,s;const e=this.mediaPlayList.segments.filter((t=>t.uri&&!this.fetchedMap.get(t.uri)));if(!e.length){var a;if(this.mediaPlayList.endlist)return-1048576;const e=(this.minBuffer-((0,f.A)()-this.mediaPlayList.timestamp)/1e3)/2;return e>0&&(this.sleep=new h.A(e),await this.sleep,this.sleep=null,this.aborted)?-1048576:("function"==typeof AbortController&&(this.signal=new AbortController),this.mediaPlayList=await S(this.mediaListUrl,this.info,this.options,null===(a=this.signal)||void 0===a?void 0:a.signal),this.signal=null,this.aborted?-1048576:this.read(t))}this.isInitLoader=!(null===(i=e[0].map)||void 0===i||!i.uri||this.initLoaded),this.currentUri=e[0].uri,this.isInitLoader?null!==(s=e[0].map)&&void 0!==s&&s.key&&await this.checkNeedDecrypt(e[0].map.key,e[0].map.uri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0)):await this.checkNeedDecrypt(e[0].key,this.currentUri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0)),this.loader=new p.A(d.X$({},this.options,{disableSegment:!0,loop:!1}));const r=(0,u.ll)(this.mediaListUrl,this.isInitLoader?e[0].map.uri:this.currentUri),n={from:0,to:-1},o=this.isInitLoader?e[0].map.byterange:e[0].byterange;o&&(n.from=o.offset,n.to=o.offset+o.length),await this.loader.open(d.X$({},this.info,{url:r}),n);const l=await(this.aesDecryptPipe?this.aesDecryptPipe.read(t):this.loader.read(t));return l>10?this.handleSlice(l,t):l}{var r,n;this.loader=new p.A(d.X$({},this.options,{disableSegment:!0,loop:!1}));let e=this.mediaPlayList.segments[this.segmentIndex];for(;e&&!e.uri;)e=this.mediaPlayList.segments[++this.segmentIndex];this.isInitLoader=!(null===(r=e.map)||void 0===r||!r.uri||this.initLoaded),this.isInitLoader?null!==(n=e.map)&&void 0!==n&&n.key&&await this.checkNeedDecrypt(e.map.key,e.map.uri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0)):await this.checkNeedDecrypt(e.key,e.uri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0));const i=(0,u.ll)(this.mediaListUrl,this.isInitLoader?e.map.uri:e.uri),s={from:0,to:-1},a=this.isInitLoader?e.map.byterange:e.byterange;a&&(s.from=a.offset,s.to=a.offset+a.length),await this.loader.open(d.X$({},this.info,{url:i}),s);const o=await(this.aesDecryptPipe?this.aesDecryptPipe.read(t):this.loader.read(t));return o>10?this.handleSlice(o,t):o}}async seek(t){this.loader&&(await this.loader.abort(),this.loader=null);let e=0,i=Number(t),s=-1;for(let t=0;t<this.mediaPlayList.segments.length;t++)if(E.ai(this.mediaPlayList.segments[t].duration)&&(e+=this.mediaPlayList.segments[t].duration,1e3*e>=i)){s=t;break}return-1===s&&(s=this.mediaPlayList.segments.length-1),this.segmentIndex=s,this.aborted=!1,0}abortSleep(){this.aborted=!0,this.loader&&this.loader.abortSleep(),this.sleep&&(this.sleep.stop(),this.sleep=null)}async abort(){this.abortSleep(),this.signal&&(this.signal.abort(),this.signal=null),this.loader&&(await this.loader.abort(),this.loader=null)}getMinBuffer(){return this.minBuffer}getDuration(){return this.mediaPlayList.duration}}class b extends l.A{constructor(...t){super(...t),(0,s.A)(this,"info",void 0),(0,s.A)(this,"masterPlaylist",void 0),(0,s.A)(this,"mediaPlayListIndex",void 0),(0,s.A)(this,"mainLoader",void 0),(0,s.A)(this,"loaders",void 0),(0,s.A)(this,"audioSelectedIndex",void 0),(0,s.A)(this,"subtitleSelectedIndex",void 0),(0,s.A)(this,"sleep",void 0),(0,s.A)(this,"aborted",void 0)}async fetchMasterPlayList(){try{const e=await fetch(this.info.url,I(this.info)),i=await e.text(),s=(0,c.A)(i);if(s.isMasterPlaylist){if(this.masterPlaylist=s,this.options.preferResolution||this.options.preferVideoCodec){let t=1,e=1;if(this.options.preferResolution){const i=this.options.preferResolution.split("*");t=+i[0]||1,e=+i[1]||1}let i=!1,s=1/0,a=this.masterPlaylist.variants.some((t=>t.codecs&&t.codecs.indexOf(this.options.preferVideoCodec)>=0));this.masterPlaylist.variants.forEach(((r,n)=>{if(!(this.options.preferVideoCodec&&a&&r.codecs&&-1===r.codecs.indexOf(this.options.preferVideoCodec))&&(i||(this.mediaPlayListIndex=n,i=!0),r.resolution&&this.options.preferResolution)){const i=1===t?1:r.resolution.width,a=1===e?1:r.resolution.height;Math.abs(i*a-t*e)<s&&(s=Math.abs(i*a-t*e),this.mediaPlayListIndex=n)}}))}const t=this.masterPlaylist.variants[this.mediaPlayListIndex];if(t){if(t.audio.length&&this.options.preferAudioLang){let e=!1;t.audio.forEach(((t,i)=>{t.language&&t.language.indexOf(this.options.preferAudioLang)>=0&&!e&&(this.audioSelectedIndex=i,t.language===this.options.preferAudioLang&&(e=!0))}))}if(t.subtitles.length&&this.options.preferSubtitleLang){let e=!1;t.subtitles.forEach(((t,i)=>{t.language&&t.language.indexOf(this.options.preferSubtitleLang)>=0&&!e&&(this.subtitleSelectedIndex=i,t.language===this.options.preferSubtitleLang&&(e=!0))}))}}}else{const e=s;if(this.options.isLive&&(!e.segments||e.segments.length<2)){var t;let i=5;return null!==(t=e.segments)&&void 0!==t&&t.length&&(i=e.segments[0].duration*(2-e.segments.length)),m.R8(`wait for min buffer time, now segments: ${e.segments.length}`,v,648),await new h.A(i),this.fetchMasterPlayList()}this.mainLoader=new X(this.options,this.info,this.info.url,e),this.loaders.set(0,this.mainLoader)}return s}catch(t){if(this.retryCount<this.options.retryCount)return this.retryCount++,m.z3(`failed fetch m3u8 file, retry(${this.retryCount}/3)`,v,665),this.sleep=new h.A(3),await this.sleep,this.sleep=null,this.aborted&&m.h2("HLSLoader: exception, fetch abort",v,670),this.fetchMasterPlayList();this.status=3,m.h2("HLSLoader: exception, fetch slice error",v,676)}}buildUrl(t){return/^https?/.test(t)||(t=u.ll(this.info.url,t)),t}async createLoader(){if(this.masterPlaylist){const t=this.masterPlaylist.variants[this.mediaPlayListIndex];if(t||m.h2("no media playlist",v,692),t.audio.length){const e=this.buildUrl(t.audio[this.audioSelectedIndex].uri);this.loaders.set(1,new X(this.options,this.info,e,await S(e,this.info,this.options)))}if(t.subtitles.length){const e=this.buildUrl(t.subtitles[this.subtitleSelectedIndex].uri);this.loaders.set(3,new X(this.options,this.info,e,await S(e,this.info,this.options)))}const e=this.buildUrl(t.uri);this.mainLoader=new X(this.options,this.info,e,await S(e,this.info,this.options)),this.loaders.set(0,this.mainLoader)}}async open(t){return 2===this.status?0:0!==this.status?y.lh:(this.info=t,this.mediaPlayListIndex=0,this.audioSelectedIndex=0,this.subtitleSelectedIndex=0,this.loaders=new(o()),this.status=1,this.retryCount=0,this.aborted=!1,await this.fetchMasterPlayList(),!this.loaders.size&&this.masterPlaylist&&await this.createLoader(),this.status=2,0)}async read(t,e){if(!e)return y.UY;const i=await this.loaders.get(e.mediaType).read(t);return i<0&&-1048575!==i&&(this.status=-1048576===i?4:3),i}async seek(t,e){return e?(await this.loaders.get(e.mediaType).seek(t),4===this.status&&(this.status=2),0):y.UY}async size(){return BigInt(0)}async abort(){for(let t of this.loaders)await t[1].abort();this.aborted=!0,this.sleep&&(this.sleep.stop(),this.sleep=null)}async stop(){await this.abort(),this.status=0}getDuration(){var t,e;return null!==(t=null===(e=this.mainLoader)||void 0===e?void 0:e.getDuration())&&void 0!==t?t:0}hasVideo(){return this.masterPlaylist?this.masterPlaylist.variants.length>0:!!this.mainLoader}hasAudio(){if(this.masterPlaylist)return this.masterPlaylist.variants[this.mediaPlayListIndex].audio.length>0}hasSubtitle(){if(this.masterPlaylist)return this.masterPlaylist.variants[this.mediaPlayListIndex].subtitles.length>0}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,codec:t.codecs,bandwidth:t.bandwidth}})))&&void 0!==t?t:[],selectedIndex:this.mediaPlayListIndex||0}}getAudioList(){return this.masterPlaylist&&this.hasAudio()?{list:this.masterPlaylist.variants[this.mediaPlayListIndex].audio.map((t=>({lang:t.language,codec:t.name}))),selectedIndex:this.audioSelectedIndex}:{list:[],selectedIndex:0}}getSubtitleList(){return this.masterPlaylist&&this.hasSubtitle()?{list:this.masterPlaylist.variants[this.mediaPlayListIndex].subtitles.map((t=>({lang:t.language,codec:t.name}))),selectedIndex:this.subtitleSelectedIndex}:{list:[],selectedIndex:0}}selectVideo(t){if(this.masterPlaylist){const e=this.masterPlaylist.variants[t];if(e){const i=this.buildUrl(e.uri);if(S(i,this.info,this.options).then((e=>{this.loaders.get(0).setMediaPlayList(i,e),this.mediaPlayListIndex=t})),1===e.audio.length&&this.loaders.has(1)&&this.buildUrl(e.audio[0].uri)!==this.loaders.get(1).getMediaListUrl()){const t=this.buildUrl(e.audio[0].uri);S(t,this.info,this.options).then((e=>{this.loaders.get(1).setMediaPlayList(t,e)}))}if(1===e.subtitles.length&&this.loaders.has(3)&&this.buildUrl(e.subtitles[0].uri)!==this.loaders.get(3).getMediaListUrl()){const t=this.buildUrl(e.subtitles[0].uri);S(t,this.info,this.options).then((e=>{this.loaders.get(3).setMediaPlayList(t,e)}))}}}}selectAudio(t){if(this.masterPlaylist){const e=this.masterPlaylist.variants[this.mediaPlayListIndex];if(null!=e&&e.audio[t]){const i=this.buildUrl(e.audio[t].uri);S(i,this.info,this.options).then((e=>{this.loaders.get(1).setMediaPlayList(i,e),this.audioSelectedIndex=t}))}}}selectSubtitle(t){if(this.masterPlaylist){const e=this.masterPlaylist.variants[this.mediaPlayListIndex];if(null!=e&&e.subtitles[t]){const i=this.buildUrl(e.subtitles[t].uri);S(i,this.info,this.options).then((e=>{this.loaders.get(3).setMediaPlayList(i,e),this.subtitleSelectedIndex=t}))}}}getMinBuffer(){var t,e;return null!==(t=null===(e=this.mainLoader)||void 0===e?void 0:e.getMinBuffer())&&void 0!==t?t:0}}},68141:(t,e,i)=>{i.d(e,{A:()=>w});var s=i(14265),a=i.n(s),r=i(89730),n=i.n(r),o=i(21955),h=i.n(o),l=i(33793),d=i.n(l),u=i(91325),c=i(41497),p=i(20163);const f="src/avprotocol/m3u8/parser.ts";function m(t){return u.Bq(t,'"')}function T(t){const e=u.gI(t,",");return{duration:u.Ro(e[0]),title:decodeURIComponent(escape(e[1]))}}function E(t){const e=u.gI(t,"@");return{length:u.Ro(e[0]),offset:e[1]?u.Ro(e[1]):-1}}function y(t){const e=u.gI(t,"x");return{width:u.Ro(e[0]),height:u.Ro(e[1])}}function A(t){const e="ALLOWED-CPC: Each entry must consit of KEYFORMAT and Content Protection Configuration",i=t.split(",");0===i.length&&p.z3(e,f,102);const s=[];for(const t of i){const[i,a]=u.gI(t,":");i&&a?s.push({format:i,cpcList:a.split("/")}):p.z3(e,f,108)}return s}function g(t){const e=u.m2(t);return 16!==e.length&&p.z3("IV must be a 128-bit unsigned integer",f,119),e}function v(t,e){e.IV&&t.compatibleVersion<2&&(t.compatibleVersion=2),(e.KEYFORMAT||e.KEYFORMATVERSIONS)&&t.compatibleVersion<5&&(t.compatibleVersion=5)}function I(t){const e={};for(const s of u.HG(t)){const[t,a]=u.gI(s,"="),r=m(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]=E(r);break;case"RESOLUTION":e[t]=y(r);break;case"ALLOWED-CPC":e[t]=A(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('"')?m(i):i.startsWith("0x")||i.startsWith("0X")?u.m2(i):u.Ro(i):("VIDEO-RANGE"===t&&"SDR"!==r&&"HLG"!==r&&"PQ"!==r&&p.h2(`VIDEO-RANGE: unknown value "${r}"`,f,206),e[t]=r)}}var i;return e}function S(t,e,i){const s=function({attributes:t}){return new c.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&&p.h2(r,f,315),a.push(s),s.isDefault&&(t.currentRenditions[u.Th(i)]=a.length-1)}function X(t,e,i,s,a){const r=new c.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"]||p.h2("EXT-X-MEDIA TYPE attribute is REQUIRED.",f,355),e[s]===t["GROUP-ID"]&&(S(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]))&&p.h2(`${s} attribute MUST match the value of the GROUP-ID attribute of an EXT-X-MEDIA tag whose TYPE attribute is ${s}.`,f,330)}(e,r,a),r.isIFrameOnly=s,r}function b(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 N(t,e,i,s,a,r,o){const l=new c.Y4({uri:e,mediaSequenceNumber:a,discontinuitySequence:r});let d=!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&&p.h2("EXTINF duration, when rounded to the nearest integer, MUST be less than or equal to the target duration",f,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&&p.h2("EXT-X-DISCONTINUITY must appear before the first EXT-X-PART tag of the Parent Segment.",f,530),l.discontinuity=!0;else if("EXT-X-KEY"===i)l.parts.length>0&&p.h2("EXT-X-KEY must appear before the first EXT-X-PART tag of the Parent Segment.",f,536),"NONE"!==a.METHOD?(v(o,a),l.key=new c.Uz({method:a.METHOD,uri:a.URI,iv:a.IV,format:a.KEYFORMAT,formatVersion:a.KEYFORMATVERSIONS})):l.key=null;else if("EXT-X-MAP"===i)l.parts.length>0&&p.h2("EXT-X-MAP must appear before the first EXT-X-PART tag of the Parent Segment.",f,555),o.compatibleVersion<5&&(o.compatibleVersion=5),o.hasMap=!0,l.map=new c.qP({uri:a.URI,byterange:a.BYTERANGE,key:l.key});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 c.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 c.xC({type:"OUT",duration:a&&a.DURATION||s}));else if("EXT-X-CUE-IN"===i)l.markers.push(new c.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 c.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)p.h2("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.",f,616);else if("EXT-X-PART"!==i&&"EXT-X-PRELOAD-HINT"!==i||a.URI){if("EXT-X-PRELOAD-HINT"===i&&"MAP"===a.TYPE)d&&p.h2("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.",f,623),d=!0,o.hasMap=!0,l.map=new c.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||p.h2("EXT-X-PART: DURATION attribute is mandatory",f,635),"EXT-X-PRELOAD-HINT"===i&&(u=!0);const t=new c.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 p.h2("EXT-X-PART / EXT-X-PRELOAD-HINT: URI attribute is mandatory",f,619);else p.h2("EXT-X-PRELOAD-HINT: TYPE attribute is mandatory",f,613)}return l}function R(t,e,i,s,a,r,n){const o=new c.Vd({uri:e,mediaSequenceNumber:a,discontinuitySequence:r});for(let e=i;e<=s;e++){const{name:i,attributes:s}=t[e];"EXTINF"===i?p.h2("A prefetch segment must not be advertised with an EXTINF tag.",f,667):"EXT-X-DISCONTINUITY"===i?p.h2("A prefetch segment must not be advertised with an EXT-X-DISCONTINUITY tag.",f,670):"EXT-X-PREFETCH-DISCONTINUITY"===i?o.discontinuity=!0:"EXT-X-KEY"===i?"NONE"!==s.METHOD&&(v(n,s),o.key=new c.Uz({method:s.METHOD,uri:s.URI,iv:s.IV,format:s.KEYFORMAT,formatVersion:s.KEYFORMATVERSIONS})):"EXT-X-MAP"===i&&p.h2("Prefetch segments must not be advertised with an EXT-X-MAP tag.",f,688)}return o}function P(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:p.h2("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST be a sub-range of the same media resource",f,912)}else p.h2("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST appear in the Playlist file",f,916)}return t.segments.push(e),[e.discontinuitySequence,e.key,e.map]}function L(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&&p.h2("The file contains both media and master playlist tags.",f,1023));if("MasterPlaylist"===t){if(void 0===e.isMasterPlaylist)return void(e.isMasterPlaylist=!0);!1===e.isMasterPlaylist&&p.h2("The file contains both media and master playlist tags.",f,1033)}}(r,e),"Unknown"===r)return null;"MediaPlaylist"===r&&"EXT-X-RENDITION-REPORT"!==i&&"EXT-X-PREFETCH"!==i&&(e.hash[i]&&p.h2("There MUST NOT be more than one Media Playlist tag of each type in any Media Playlist",f,1054),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,I(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,I(e)];case"EXTINF":return[T(e),null];case"EXT-X-BYTERANGE":return[E(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 D(t,e){let i;return e.isMasterPlaylist?i=function(t,e){const i=new c.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"))&&p.h2("EXT-X-STREAM-INF must be followed by a URI line",f,417);const n=X(t,o,r,!1,e);n&&("number"==typeof n.score&&(s=!0,n.score<0&&p.h2("SCORE attribute on EXT-X-STREAM-INF must be positive decimal-floating-point number.",f,424)),i.variants.push(n))}else if("EXT-X-I-FRAME-STREAM-INF"===r){const s=X(t,o,o.URI,!0,e);s&&i.variants.push(s)}else if("EXT-X-SESSION-DATA"===r){const t=new c.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))&&p.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.",f,444),i.sessionDataList.push(t)}else if("EXT-X-SESSION-KEY"===r){"NONE"===o.METHOD&&p.h2("EXT-X-SESSION-KEY: The value of the METHOD attribute MUST NOT be NONE",f,450);const t=new c.Uz({method:o.METHOD,uri:o.URI,iv:o.IV,format:o.KEYFORMAT,formatVersion:o.KEYFORMATVERSIONS});i.sessionKeyList.some((e=>b(e,t)))&&p.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.",f,460),v(e,o),i.sessionKeyList.push(t)}else"EXT-X-INDEPENDENT-SEGMENTS"===r?(i.independentSegments&&p.h2("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist",f,467),i.independentSegments=!0):"EXT-X-START"===r&&(i.start&&p.h2("EXT-X-START tag MUST NOT appear more than once in a Playlist",f,473),"number"!=typeof o["TIME-OFFSET"]&&p.h2("EXT-X-START: TIME-OFFSET attribute is REQUIRED",f,476),i.start={offset:o["TIME-OFFSET"],precise:o.PRECISE||!1});if(s)for(const t of i.variants)"number"!=typeof t.score&&p.h2("If any Variant Stream contains the SCORE attribute, then all Variant Streams in the Master Playlist SHOULD have a SCORE attribute",f,484);if(e.isClosedCaptionsNone)for(const t of i.variants)t.closedCaptions.length>0&&p.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",f,491);return i}(t,e):(i=function(t,e){const i=new c.tk;let s=-1,a=0,r=!1,n=!1,o=0,h=null,l=null,u=!1;for(const[d,m]of t.entries()){const{name:T,value:E,attributes:y,category:A}=m;if("Segment"!==A){if("EXT-X-VERSION"===T)void 0===i.version?i.version=E:p.h2("A Playlist file MUST NOT contain more than one EXT-X-VERSION tag.",f,720);else if("EXT-X-TARGETDURATION"===T)i.targetDuration=e.targetDuration=E;else if("EXT-X-MEDIA-SEQUENCE"===T)i.segments.length>0&&p.h2("The EXT-X-MEDIA-SEQUENCE tag MUST appear before the first Media Segment in the Playlist.",f,728),i.mediaSequenceBase=a=E;else if("EXT-X-DISCONTINUITY-SEQUENCE"===T)i.segments.length>0&&p.h2("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before the first Media Segment in the Playlist.",f,734),r&&p.h2("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before any EXT-X-DISCONTINUITY tag.",f,737),i.discontinuitySequenceBase=o=E;else if("EXT-X-ENDLIST"===T)i.endlist=!0;else if("EXT-X-PLAYLIST-TYPE"===T)i.playlistType=E;else if("EXT-X-I-FRAMES-ONLY"===T)e.compatibleVersion<4&&(e.compatibleVersion=4),i.isIFrame=!0;else if("EXT-X-INDEPENDENT-SEGMENTS"===T)i.independentSegments&&p.h2("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist",f,755),i.independentSegments=!0;else if("EXT-X-START"===T)i.start&&p.h2("EXT-X-START tag MUST NOT appear more than once in a Playlist",f,761),"number"!=typeof y["TIME-OFFSET"]&&p.h2("EXT-X-START: TIME-OFFSET attribute is REQUIRED",f,764),i.start={offset:y["TIME-OFFSET"],precise:y.PRECISE||!1};else if("EXT-X-SERVER-CONTROL"===T)y["CAN-BLOCK-RELOAD"]||p.h2("EXT-X-SERVER-CONTROL: CAN-BLOCK-RELOAD=YES is mandatory for Low-Latency HLS",f,770),i.lowLatencyCompatibility={canBlockReload:y["CAN-BLOCK-RELOAD"],canSkipUntil:y["CAN-SKIP-UNTIL"],holdBack:y["HOLD-BACK"],partHoldBack:y["PART-HOLD-BACK"]};else if("EXT-X-PART-INF"===T)y["PART-TARGET"]||p.h2("EXT-X-PART-INF: PART-TARGET attribute is mandatory",f,781),i.partTargetDuration=y["PART-TARGET"];else if("EXT-X-RENDITION-REPORT"===T)y.URI||p.h2("EXT-X-RENDITION-REPORT: URI attribute is mandatory",f,787),0===y.URI.search(/^[a-z]+:/)&&p.h2("EXT-X-RENDITION-REPORT: URI must be relative to the playlist uri",f,790),i.renditionReports.push(new c.h4({uri:y.URI,lastMSN:y["LAST-MSN"],lastPart:y["LAST-PART"]}));else if("EXT-X-SKIP"===T)y["SKIPPED-SEGMENTS"]||p.h2("EXT-X-SKIP: SKIPPED-SEGMENTS attribute is mandatory",f,800),e.compatibleVersion<9&&(e.compatibleVersion=9),i.skip=y["SKIPPED-SEGMENTS"],a+=i.skip;else if("EXT-X-PREFETCH"===T){const r=R(t,E,-1===s?d:s,d-1,a++,o,e);r&&(r.discontinuity&&(r.discontinuitySequence++,o=r.discontinuitySequence),r.key?h=r.key:null===r.key?h=void 0:r.key=h,i.prefetchSegments.push(r)),n=!0,s=-1}else if("string"==typeof m){-1===s&&p.h2("A URI line is not preceded by any segment tags",f,840),i.targetDuration||p.h2("The EXT-X-TARGETDURATION tag is REQUIRED",f,843),n&&p.h2("These segments must appear after all complete segments.",f,846);const r=N(t,m,s,d-1,a++,o,e);r&&(null===r.key&&(h=void 0),[o,h,l]=P(i,r,o,h,l),!u&&r.parts.length>0&&(u=!0)),s=-1}}else-1===s&&(s=d),"EXT-X-DISCONTINUITY"===T&&(r=!0)}if(-1!==s){const r=N(t,"",s,t.length-1,a++,o,e);if(r){var m;null===r.key&&(h=void 0);const{parts:t}=r;!(t.length>0)||i.endlist||null!==(m=t[t.length-1])&&void 0!==m&&m.hint||p.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",f,869),P(i,r,o,h,l),!u&&r.parts.length>0&&(u=!0)}}return function(t){const e=new(d()),i=new(d());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)&&p.h2("An EXT-X-DATERANGE tag with an END-ON-NEXT=YES attribute MUST NOT contain DURATION or END-DATE attributes.",f,936);const t=o.start.getTime(),a=o.duration||0;o.end&&o.duration&&t+1e3*a!==o.end.getTime()&&p.h2("END-DATE MUST be equal to the value of the START-DATE attribute plus the value of the DURATION",f,942),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)&&p.h2("DATERANGE tags with the same CLASS should not overlap",f,954);n.push({start:t,end:r})}else o.classId&&i.set(o.classId,[{start:t,end:r}])}}s&&!a&&p.h2("If a Playlist contains an EXT-X-DATERANGE tag, it MUST also contain at least one EXT-X-PROGRAM-DATE-TIME tag.",f,965)}(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&&p.h2("The Skip Boundary must be at least six times the EXT-X-TARGETDURATION.",f,972),o<3*e&&p.h2("HOLD-BACK must be at least three times the EXT-X-TARGETDURATION.",f,976),r){void 0===i&&p.h2("EXT-X-PART-INF is required if a Playlist contains one or more EXT-X-PART tags",f,980),void 0===h&&p.h2("EXT-X-PART: PART-HOLD-BACK attribute is mandatory",f,983),h<i&&p.h2("PART-HOLD-BACK must be at least PART-TARGET",f,986);for(const[t,{parts:e}]of s.entries())for(const[t,{duration:s}]of e.entries())void 0!==s&&(s>i&&p.h2("PART-TARGET is the maximum duration of any Partial Segment",f,997),t<e.length-1&&s<.85*i&&p.h2("All Partial Segments except the last part of a segment must have a duration of at least 85% of PART-TARGET",f,1e3))}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)&&p.h2(`EXT-X-VERSION needs to be ${e.compatibleVersion} or higher.`,f,1104),i}function w(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=L(t,e);s&&i.push(s)}}else i.push(t)}return 0!==i.length&&"EXTM3U"===i[0].name||p.h2("The EXTM3U tag MUST be the first line.",f,1086),i}(t,e),s=D(i,e);return s.source=t,s}},41497:(t,e,i)=>{i.d(e,{KT:()=>n,Uz:()=>h,Vd:()=>y,Y4:()=>T,ad:()=>d,h4:()=>A,nw:()=>E,pf:()=>o,qP:()=>l,ru:()=>r,tk:()=>m,ts:()=>f,xC:()=>u});var s=i(9655),a=i(80155);class r{constructor({type:t,uri:e,groupId:i,language:a,assocLanguage:r,name:n,isDefault:o,autoselect:h,forced:l,instreamId:d,characteristics:u,channels:c}){(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=d,this.characteristics=u,this.channels=c}}class n{constructor({uri:t,isIFrameOnly:e=!1,bandwidth:i,averageBandwidth:a,score:r,codecs:n,resolution:o,frameRate:h,hdcpLevel:l,allowedCpc:d,videoRange:u,stableVariantId:c,programId:p,audio:f=[],video:m=[],subtitles:T=[],closedCaptions:E=[],currentRenditions:y={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=d,this.videoRange=u,this.stableVariantId=c,this.programId=p,this.audio=f,this.video=m,this.subtitles=T,this.closedCaptions=E,this.currentRenditions=y}}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,key:r}){(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),(0,s.A)(this,"key",void 0),this.hint=t,this.uri=e,this.mimeType=i,this.byterange=a,this.key=r}}class d{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 c{constructor(t){(0,s.A)(this,"type",void 0),this.type=t}}class p extends c{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 f extends p{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 m extends p{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:d=[],lowLatencyCompatibility:u,partTargetDuration:c,renditionReports:p=[],skip:f=0,hash:m,duration:T=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=d,this.lowLatencyCompatibility=u,this.partTargetDuration=c,this.renditionReports=p,this.skip=f,this.hash=m,this.duration=T,this.timestamp=(0,a.A)()}}class T extends c{constructor({uri:t,mimeType:e,data:i,duration:a,title:r,byterange:n,discontinuity:o,mediaSequenceNumber:h=0,discontinuitySequence:l=0,key:d,map:u,programDateTime:c,dateRange:p,markers:f=[],parts:m=[]}){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=d,this.map=u,this.programDateTime=c,this.dateRange=p,this.markers=f,this.parts=m}}class E extends c{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 y extends c{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 A{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}}},91325:(t,e,i)=>{i.d(e,{Bq:()=>c,HG:()=>p,Ro:()=>l,Th:()=>f,gI:()=>u,m2:()=>d});var s=i(46181),a=i.n(s),r=i(27138),n=i.n(r),o=i(14265),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 d(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 c(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 p(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 f(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("")}},93426:(t,e,i)=>{i.d(e,{$$:()=>r,Eh:()=>f,HR:()=>a,IY:()=>y,Ki:()=>E,Mb:()=>T,Sz:()=>d,Xp:()=>h,_R:()=>n,_m:()=>p,d8:()=>m,iW:()=>u,mX:()=>c,n1:()=>o,os:()=>s,qO:()=>l});const s={86017:"mp3",86018:"mp4a.40",86021:"vorbis",86028:"flac",86076:"opus",65542:"ulaw",65543:"alaw",86019:"ac-3",86056:"ec-3",86020:"dtsc",225:"av01",27:"avc1",173:"hev1",196:"vvc1",139:"vp8",167:"vp09",12:"mp4v"},a={flv:0,mp4:1,m4s:1,mov:1,ts:2,mts:2,m2ts:2,ivf:5,opus:4,oggs:4,ogg:4,m3u8:2,m3u:2,mpd:1,mp3:14,mkv:8,mka:8,webm:9,aac:15,flac:17,wav:16,srt:19,vtt:18,ssa:20,ass:20,xml:21,ttml:21,h264:11,264:11,avc:11,h265:12,265:12,hevc:12,h266:13,266:13,vvc:13,mpeg:3,mpg:3,rtsp:6,rtmp:7,avi:10},r={m3u8:4,m3u:4,mpd:5},n={copy:0,h264:27,h261:3,h263:4,h263i:20,h263p:19,mjpeg:7,wmv1:17,wmv2:18,wmv3:71,avc:27,hevc:173,h265:173,vvc:196,h266:196,av1:225,vp9:167,vp8:139,mpeg4:12,theora:30,mpeg2video:2,rv10:5,rv20:6,rv30:68,rv40:69},o={copy:0,aac:86018,ac3:86019,eac3:86056,dts:86020,mp3:86017,opus:86076,flac:86028,speex:86051,vorbis:86021,pcm_alaw:65543,pcm_mulaw:65542,wmav1:86023,wmav2:86024,cook:86036,sipr:86057,ralf:86073,pcm_u8:65541,pcm_s16le:65536,pcm_s24le:65548,pcm_s32le:65544,pcm_s64le:65567,pcm_f32le:65557,pcm_f64le:65559},h={webvtt:94226,subrip:94225,ass:94230,ttml:94232,mov_text:94213,hdmv_pgs:94214,hdmv_text:94231,dvd:94208,dvb:94209,eia_608:94218},l={yuv420p:0,yuv422p:4,yuv444p:5,yuva420p:33,yuva422p:78,yuva444p:79,yuvj420p:12,yuvj422p:13,yuvj444p:14,yuv420p10le:62,yuv422p10le:64,yuv444p10le:68,yuva420p10le:87,yuva422p10le:89,yuva444p10le:91,yuv420p10be:61,yuv422p10be:63,yuv444p10be:67,yuva420p10be:86,yuva422p10be:88,yuva444p10be:90},d={u8:0,"u8-planar":5,s16:1,"s16-planar":6,s32:2,"s32-planar":7,s64:10,"s64-planar":11,float:3,"float-planar":8,double:4,"double-planar":9},u={flv:0,mp4:1,mov:1,ts:2,mpegts:2,mpeg:3,ivf:5,ogg:4,opus:4,m3u8:2,m3u:2,mpd:1,mp3:14,mkv:8,matroska:8,mka:8,webm:9,aac:15,flac:17,wav:16,raw_h264:11,raw_h265:12,raw_vvc:13,rtsp:6,rtmp:7,avi:10},c={tv:1,pc:2},p={bt709:1,fcc:4,bt470bg:5,smpte170m:6,smpte240m:7,ycgco:8,gbr:0,bt2020nc:9},f={bt709:1,bt470m:4,bt470bg:5,smpte170m:6,smpte240m:7,smpte428:10,film:8,smpte431:11,smpte432:12,bt2020:9,"jedec-p22":22,ebu3213:22},m={bt709:1,gamma22:4,gamma28:5,smpte170m:6,smpte240m:7,srgb:13,xvycc:11,"bt2020-10":14,"bt2020-12":15,smpte2084:16,"arib-std-b67":18},T={Audio:1,Video:0,Subtitle:3,Attachment:4,Data:2},E={default:1,dub:2,original:4,comment:8,lyrics:16,karaoke:32,forced:64,"hearing impaired":128,"visual impaired":256,"clean effects":512,"attached pic":1024,"timed thumbnails":2048,captions:65536,descriptions:131072,metadata:262144,dependent:524288,"still image":1048576},y={mono:4,stereo:3,2.1:11,"3.0":7,"3.0(back)":259,"4.0":263,quad:51,"quad(side)":1539,3.1:15,"5.0":55,"5.0(side)":1543,4.1:271,5.1:63,"5.1(side)":1551,"6.0":1799,"6.0(front)":1731,"3.1.2":20495,hexagonal:311,6.1:1807,"6.1(back)":319,"6.1(front)":1739,"7.0":1591,"7.0(front)":1735,7.1:1599,"7.1(wide)":255,"7.1(wide-side)":1743,"5.1.2":20543,octagonal:1847,cube:184371,"5.1.4":184383,"7.1.2":22079,"7.1.4":185919,"7.2.3":34359825983,"9.1.4":186111,hexadecagonal:6442710839,downmix:1610612736,22.2:2164663779327}},54893:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(9655);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],d=o[2],u=o[3],c=new Uint32Array(256);let p=0,f=0,m=0;for(m=0;m<256;m++)c[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){let i=f^f<<1^f<<2^f<<3^f<<4;i=i>>>8^255&i^99,t[p]=i,e[i]=p;const o=c[p],m=c[o],T=c[m];let E=257*c[i]^16843008*i;s[p]=E<<24|E>>>8,a[p]=E<<16|E>>>16,r[p]=E<<8|E>>>24,n[p]=E,E=16843009*T^65537*m^257*o^16843008*p,h[i]=E<<24|E>>>8,l[i]=E<<16|E>>>16,d[i]=E<<8|E>>>24,u[i]=E,p?(p=o^c[c[c[T^o]]],f^=c[c[f]]):p=f=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,d=this.invSubMix,u=d[0],c=d[1],p=d[2],f=d[3];let m,T;for(a=0;a<s;a++)a<i?m=n[a]=e[a]:(T=m,a%i==0?(T=T<<8|T>>>24,T=h[T>>>24]<<24|h[T>>>16&255]<<16|h[T>>>8&255]<<8|h[255&T],T^=l[a/i|0]<<24):i>6&&a%i==4&&(T=h[T>>>24]<<24|h[T>>>16&255]<<16|h[T>>>8&255]<<8|h[255&T]),n[a]=m=(n[a-i]^T)>>>0);for(r=0;r<s;r++)a=s-r,T=3&r?n[a]:n[a-4],o[r]=r<4||a<=4?T:u[h[T>>>24]]^c[h[T>>>16&255]]^p[h[T>>>8&255]]^f[h[255&T]],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],d=this.uint8ArrayToUint32Array_(e);let u=d[0],c=d[1],p=d[2],f=d[3];const m=new Int32Array(t.buffer).subarray(t.byteOffset>>>2,(t.byteOffset>>>2)+(t.length>>>2)),T=new Int32Array(m.length);let E,y,A,g,v,I,S,X,b,N,R,P,L,D;const w=this.networkToHostOrderSwap;let O=0;for(;O<m.length;){for(b=w(m[O]),N=w(m[O+1]),R=w(m[O+2]),P=w(m[O+3]),v=b^s[0],I=P^s[1],S=R^s[2],X=N^s[3],L=4,D=1;D<i;D++)E=n[v>>>24]^o[I>>16&255]^h[S>>8&255]^l[255&X]^s[L],y=n[I>>>24]^o[S>>16&255]^h[X>>8&255]^l[255&v]^s[L+1],A=n[S>>>24]^o[X>>16&255]^h[v>>8&255]^l[255&I]^s[L+2],g=n[X>>>24]^o[v>>16&255]^h[I>>8&255]^l[255&S]^s[L+3],v=E,I=y,S=A,X=g,L+=4;E=a[v>>>24]<<24^a[I>>16&255]<<16^a[S>>8&255]<<8^a[255&X]^s[L],y=a[I>>>24]<<24^a[S>>16&255]<<16^a[X>>8&255]<<8^a[255&v]^s[L+1],A=a[S>>>24]<<24^a[X>>16&255]<<16^a[v>>8&255]<<8^a[255&I]^s[L+2],g=a[X>>>24]<<24^a[v>>16&255]<<16^a[I>>8&255]<<8^a[255&S]^s[L+3],T[O]=w(E^u),T[O+1]=w(g^c),T[O+2]=w(A^p),T[O+3]=w(y^f),u=b,c=N,p=R,f=P,O+=4}return T.buffer}}},10855:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(9655);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)}}},97023:(t,e,i)=>{i(68483),i(31126)},10446:(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:()=>u,qg:()=>s}),i(38035),i(68483),i(97023),i(31126),i(99868);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 d(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=d(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=d(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=d(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?d(s.path):s.path),h(r)}},6431:(t,e,i)=>{var s=i(54446),a=s.JSON||(s.JSON={stringify:JSON.stringify});t.exports=function(t){return a.stringify.apply(a,arguments)}},52214:(t,e,i)=>{i(56930),t.exports=i(54446).Number.isInteger},49669:(t,e,i)=>{i(37305),t.exports=i(54446).Number.isNaN},4801:(t,e,i)=>{i(80613),t.exports=i(54446).Number.parseFloat},81646:(t,e,i)=>{i(50338),t.exports=i(54446).Number.parseInt},40738:(t,e,i)=>{var s=i(72441),a=Math.floor;t.exports=function(t){return!s(t)&&isFinite(t)&&a(t)===t}},56930:(t,e,i)=>{var s=i(78255);s(s.S,"Number",{isInteger:i(40738)})},37305:(t,e,i)=>{var s=i(78255);s(s.S,"Number",{isNaN:function(t){return t!=t}})},80613:(t,e,i)=>{var s=i(78255),a=i(50149);s(s.S+s.F*(Number.parseFloat!=a),"Number",{parseFloat:a})},50338:(t,e,i)=>{var s=i(78255),a=i(25634);s(s.S+s.F*(Number.parseInt!=a),"Number",{parseInt:a})},38035:(t,e,i)=>{t.exports=i(6431)},89730:(t,e,i)=>{t.exports=i(52214)},14265:(t,e,i)=>{t.exports=i(49669)},46181:(t,e,i)=>{t.exports=i(4801)},27138:(t,e,i)=>{t.exports=i(81646)}}]);
1
+ (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[566],{81534:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(9655);class a{constructor(){(0,s.A)(this,"onFlush",void 0)}}},5866:(t,e,i)=>{i.d(e,{A:()=>p});var s=i(9655),a=i(81534),r=i(54893),n=i(10855),o=i(56719),h=i(20163);const l="src/avnetwork/bsp/aes/AESDecryptPipe.ts",d=16;let u=!0;const c=new Uint8Array(d).fill(d);class p extends a.A{constructor(t=0,e=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),(0,s.A)(this,"mode",void 0),(0,s.A)(this,"pos",void 0),this.mode=t,this.size=e,this.pointer=0,this.endPointer=0,this.pos=0,this.ended=!1,this.buffer=new Uint8Array(e),this.aesSoftDecryptor=new r.A(t),n.A.isSupport()&&u&&(this.aesWebDecryptor=new n.A(t)),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),t.byteLength<=8&&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,128)}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 decryptCBC(t){let e,i=0;this.aesTargetDecryptor!==this.aesWebDecryptor||this.ended||(e=this.buffer.subarray(this.pointer+t,this.pointer+t+d).slice(),this.buffer.set((await this.aesWebDecryptor.encryptPadding(c,this.buffer.subarray(this.pointer+t-d,this.pointer+t))).subarray(0,d),this.pointer+t),i=d);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-d-i,s.length-i).buffer,e&&this.buffer.set(e,this.pointer+t),this.pointer+=t,this.pos+=t,new Uint8Array(a)}catch(i){if(this.aesTargetDecryptor===this.aesWebDecryptor&&this.key.byteLength<=8)return h.R8("web aes decrypt failed, try to use soft decryptor",l,178),e&&this.buffer.set(e,this.pointer+t),this.aesTargetDecryptor=this.aesSoftDecryptor,u=!1,this.decryptCBC(t);h.h2("aes decrypt failed",l,188)}}getCTRIv(){const t=new Uint8Array(this.iv).slice();let e=Math.floor(this.pos/d);for(let i=15;i>=0&&e>0;i--){const s=t[i]+(255&e);t[i]=255&s,e=(e>>>8)+(s>>8)}return t.buffer}async decryptCTR(t){try{const e=this.buffer.subarray(this.pointer,this.pointer+t),i=await this.aesTargetDecryptor.decrypt(e,this.getCTRIv());return this.pointer+=t,this.pos+=t,new Uint8Array(i)}catch(e){if(this.aesTargetDecryptor===this.aesWebDecryptor&&this.key.byteLength<=8)return h.R8("web aes decrypt failed, try to use soft decryptor",l,214),this.aesTargetDecryptor=this.aesSoftDecryptor,u=!1,this.decryptCTR(t);h.h2("aes decrypt failed",l,220)}}async read(t){for(;!this.ended&&this.remainingLength()<48;)await this.flush();if(0===this.remainingLength())return-1048576;if(0===this.mode){const e=Math.min(Math.floor((this.remainingLength()-(this.ended?0:32))/d)*d,t.length);let i=await this.decryptCBC(e);return this.ended&&this.aesTargetDecryptor===this.aesSoftDecryptor&&(i=this.removePadding(i)),t.set(i),i.length}{const e=this.ended?this.remainingLength():Math.min(Math.floor(this.remainingLength()/d)*d,t.length);let i=await this.decryptCTR(e);return t.set(i),i.length}}}},4566:(t,e,i)=>{i.r(e),i.d(e,{default:()=>X});var s=i(9655),a=i(55906),r=i.n(a),n=i(33793),o=i.n(n),h=i(56719),l=i(72277),d=i(99868),u=i(10446),c=i(68141),p=i(33267),m=i(80155),f=i(20163),T=i(5866),E=i(68483),y=i(20086),A=i(10855),g=i(93426);const v="src/avnetwork/ioLoader/HlsIOLoader.ts";function S(t,e="GET"){var i,s,a;const r={method:"GET",headers:{},mode:"cors",cache:"default",referrerPolicy:"no-referrer-when-downgrade"};return null!==(i=t.httpOptions)&&void 0!==i&&i.headers&&d.__(t.httpOptions.headers,((t,e)=>{r.headers[e]=t})),null!==(s=t.httpOptions)&&void 0!==s&&s.credentials&&(r.credentials=t.httpOptions.credentials),null!==(a=t.httpOptions)&&void 0!==a&&a.referrerPolicy&&(r.referrerPolicy=t.httpOptions.referrerPolicy),r}async function b(t,e,i,s){return new(r())(((a,r)=>{let n=0;!async function o(){try{const r=await fetch(t,{...S(e),signal:s}),d=await r.text(),u=(0,c.A)(d);if(i.isLive&&(!u.segments||u.segments.length<2)){var l;let t=5;null!==(l=u.segments)&&void 0!==l&&l.length&&(t=u.segments[0].duration*(2-u.segments.length)),f.R8(`wait for min buffer time, now segments: ${u.segments.length}`,v,94),await new h.A(t),n=0,o()}a(u)}catch(t){if("AbortError"===(null==t?void 0:t.name))return void a(null);if(n<i.retryCount)return n++,f.z3(`failed fetch m3u8 file, retry(${n}/3)`,v,108),await new h.A(i.retryInterval),o();f.z3("HLSLoader: exception, fetch slice error",v,113),r()}}()}))}class I{constructor(t,e,i,a){(0,s.A)(this,"options",void 0),(0,s.A)(this,"info",void 0),(0,s.A)(this,"mediaPlayList",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,"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),(0,s.A)(this,"isInitLoader",void 0),(0,s.A)(this,"minBuffer",void 0),(0,s.A)(this,"pendingBuffer",void 0),(0,s.A)(this,"magicAdded",void 0),(0,s.A)(this,"sleep",void 0),(0,s.A)(this,"aborted",void 0),(0,s.A)(this,"signal",void 0),this.options=t,this.info=e,this.segmentIndex=0,this.fetchedMap=new(o()),this.fetchedHistoryList=[],this.keyMap=new(o()),this.aborted=!1,i&&a&&this.setMediaPlayList(i,a)}setMediaPlayList(t,e){if(this.options.isLive){this.fetchedMap.clear(),this.fetchedHistoryList.length=0,this.segmentIndex=0;const t=e.segments.find((t=>t.uri===this.currentUri));if(t)for(e.segments.forEach(((e,i)=>{e.mediaSequenceNumber===t.mediaSequenceNumber+1?this.segmentIndex=i:e.mediaSequenceNumber<=t.mediaSequenceNumber&&(this.fetchedMap.set(e.uri,!0),this.fetchedHistoryList.push(e.uri))}));this.fetchedHistoryList.length>=10;)this.fetchedMap.delete(this.fetchedHistoryList.shift())}if(this.mediaListUrl=t,this.mediaPlayList=e,this.minBuffer=this.mediaPlayList.duration||0,this.mediaPlayList.endlist&&(this.options.isLive=!1),this.initLoaded=!0,this.mediaPlayList.segments.length&&this.mediaPlayList.segments[0].map&&(this.initLoaded=!1),this.mediaPlayList.lowLatencyCompatibility){const t=this.mediaPlayList.lowLatencyCompatibility.partHoldBack||this.mediaPlayList.lowLatencyCompatibility.holdBack||this.minBuffer;let e=0,s=!1,a=0;for(let r=this.mediaPlayList.segments.length-1;r>=0;r--){var i;const n=this.mediaPlayList.segments[r];if(null!==(i=n.parts)&&void 0!==i&&i.length){if(!n.uri)continue;for(let i=n.parts.length-1;i>=0;i--){const o=n.parts[i];if(!o.hint&&(e+=o.duration,o.independent&&(s=!0),e>=t&&s)){a=r;break}}if(e>=t&&s)break}else if(e+=n.duration,s=!0,e>=t&&s){a=r;break}}this.fetchedMap.clear(),this.fetchedHistoryList.length=0;for(let t=0;t<a;t++){const e=this.mediaPlayList.segments[t];this.fetchedMap.set(e.uri,!0),this.fetchedHistoryList.push(e.uri)}for(;this.fetchedHistoryList.length>=10;)this.fetchedMap.delete(this.fetchedHistoryList.shift());this.segmentIndex=a,this.minBuffer=e}}getMediaListUrl(){return this.mediaListUrl}async checkNeedDecrypt(t,e,i){if(!t)return void(this.aesDecryptPipe=null);if("aes-128"!==t.method.toLocaleLowerCase()&&"aes-128-ctr"!==t.method.toLocaleLowerCase()&&("aes-256"!==t.method.toLocaleLowerCase()&&"aes-256-ctr"!==t.method.toLocaleLowerCase()||!A.A.isSupport())){if("mp4"===e.split(".").pop())return void(this.aesDecryptPipe=null);f.h2(`m3u8 ts not support EXT-X-KEY METHOD ${t.method}`,v,286)}const s=t.uri;if(this.keyMap.has(s)?this.currentKey=this.keyMap.get(s):(this.currentKey=await(await fetch((0,u.ll)(this.mediaListUrl,s),S(this.info))).arrayBuffer(),this.keyMap.set(s,this.currentKey)),t.iv)this.currentIV=t.iv.buffer;else{const t=new Uint8Array(16);new DataView(t.buffer).setUint32(12,i,!1),this.currentIV=t.buffer}this.aesDecryptPipe=new T.A(t.method.toLocaleLowerCase().indexOf("ctr")>0?1:0),this.aesDecryptPipe.onFlush=async t=>this.loader.read(t),await this.aesDecryptPipe.expandKey(this.currentKey,this.currentIV)}handleSlice(t,e){const i=this.loader.getUrl().split(".").pop();if("mp3"!==i&&!this.magicAdded&&73===e[0]&&68===e[1]&&51===e[2]){var s;const a=null!==(s=g.HR[i])&&void 0!==s?s:-1;return-1===a?t:(t+6>e.length&&(this.pendingBuffer=e.slice(t-6)),e.set(e.slice(0,t-6),6),e[0]=76,e[1]=73,e[2]=77,e[3]=65,e[4]=a>>>8&255,e[5]=255&a,this.magicAdded=!0,this.pendingBuffer?t:t+6)}return t}async read(t){if(this.pendingBuffer){let e=this.pendingBuffer.length;return t.set(this.pendingBuffer),this.pendingBuffer=null,e}let e=0;if(this.loader){if(e=this.aesDecryptPipe?await this.aesDecryptPipe.read(t):await this.loader.read(t),-1048576!==e||this.aborted)return e;if(this.isInitLoader)this.initLoaded=!0;else 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-1048576;this.loader=null}if(this.options.isLive){var i,s;const e=this.mediaPlayList.segments.filter((t=>t.uri&&!this.fetchedMap.get(t.uri)));if(!e.length){var a;if(this.mediaPlayList.endlist)return-1048576;const e=(this.minBuffer-((0,m.A)()-this.mediaPlayList.timestamp)/1e3)/2;return e>0&&(this.sleep=new h.A(e),await this.sleep,this.sleep=null,this.aborted)?-1048576:("function"==typeof AbortController&&(this.signal=new AbortController),this.mediaPlayList=await b(this.mediaListUrl,this.info,this.options,null===(a=this.signal)||void 0===a?void 0:a.signal),this.signal=null,this.aborted?-1048576:this.read(t))}this.isInitLoader=!(null===(i=e[0].map)||void 0===i||!i.uri||this.initLoaded),this.currentUri=e[0].uri,this.isInitLoader?null!==(s=e[0].map)&&void 0!==s&&s.key&&await this.checkNeedDecrypt(e[0].map.key,e[0].map.uri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0)):await this.checkNeedDecrypt(e[0].key,this.currentUri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0)),this.loader=new p.A(d.X$({},this.options,{disableSegment:!0,loop:!1}));const r=(0,u.ll)(this.mediaListUrl,this.isInitLoader?e[0].map.uri:this.currentUri),n={from:0,to:-1},o=this.isInitLoader?e[0].map.byterange:e[0].byterange;o&&(n.from=o.offset,n.to=o.offset+o.length),await this.loader.open(d.X$({},this.info,{url:r}),n);const l=await(this.aesDecryptPipe?this.aesDecryptPipe.read(t):this.loader.read(t));return l>10?this.handleSlice(l,t):l}{var r,n;this.loader=new p.A(d.X$({},this.options,{disableSegment:!0,loop:!1}));let e=this.mediaPlayList.segments[this.segmentIndex];for(;e&&!e.uri;)e=this.mediaPlayList.segments[++this.segmentIndex];this.isInitLoader=!(null===(r=e.map)||void 0===r||!r.uri||this.initLoaded),this.isInitLoader?null!==(n=e.map)&&void 0!==n&&n.key&&await this.checkNeedDecrypt(e.map.key,e.map.uri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0)):await this.checkNeedDecrypt(e.key,e.uri,this.segmentIndex+(this.mediaPlayList.mediaSequenceBase||0));const i=(0,u.ll)(this.mediaListUrl,this.isInitLoader?e.map.uri:e.uri),s={from:0,to:-1},a=this.isInitLoader?e.map.byterange:e.byterange;a&&(s.from=a.offset,s.to=a.offset+a.length),await this.loader.open(d.X$({},this.info,{url:i}),s);const o=await(this.aesDecryptPipe?this.aesDecryptPipe.read(t):this.loader.read(t));return o>10?this.handleSlice(o,t):o}}async seek(t,e=0){this.loader&&(await this.loader.abort(),this.loader=null);let i=e,s=Number(t),a=-1;for(let t=0;t<this.mediaPlayList.segments.length;t++)if(E.ai(this.mediaPlayList.segments[t].duration)&&(i+=this.mediaPlayList.segments[t].duration,1e3*i>=s)){a=t;break}return-1===a&&(a=this.mediaPlayList.segments.length-1),this.segmentIndex=a,this.aborted=!1,0}abortSleep(){this.aborted=!0,this.loader&&this.loader.abortSleep(),this.sleep&&(this.sleep.stop(),this.sleep=null)}async abort(){this.abortSleep(),this.signal&&(this.signal.abort(),this.signal=null),this.loader&&(await this.loader.abort(),this.loader=null)}getMinBuffer(){return this.minBuffer}getDuration(){return this.mediaPlayList.duration}getNextFragmentStart(t=0){if(this.segmentIndex>=this.mediaPlayList.segments.length-1)return-1;for(let e=0;e<this.segmentIndex+1;e++){if(!E.ai(this.mediaPlayList.segments[e].duration))return-1;t+=this.mediaPlayList.segments[e].duration}return t}}class X extends l.A{constructor(...t){super(...t),(0,s.A)(this,"info",void 0),(0,s.A)(this,"masterPlaylist",void 0),(0,s.A)(this,"mediaPlayListIndex",void 0),(0,s.A)(this,"mainLoader",void 0),(0,s.A)(this,"loaders",void 0),(0,s.A)(this,"audioSelectedIndex",void 0),(0,s.A)(this,"subtitleSelectedIndex",void 0),(0,s.A)(this,"sleep",void 0),(0,s.A)(this,"aborted",void 0),(0,s.A)(this,"start",void 0)}async fetchMasterPlayList(){try{const e=await fetch(this.info.url,S(this.info)),i=await e.text(),s=(0,c.A)(i);if(s.isMasterPlaylist){if(this.masterPlaylist=s,this.options.preferResolution||this.options.preferVideoCodec){let t=1,e=1;if(this.options.preferResolution){const i=this.options.preferResolution.split("*");t=+i[0]||1,e=+i[1]||1}let i=!1,s=1/0,a=this.masterPlaylist.variants.some((t=>t.codecs&&t.codecs.indexOf(this.options.preferVideoCodec)>=0));this.masterPlaylist.variants.forEach(((r,n)=>{if(!(this.options.preferVideoCodec&&a&&r.codecs&&-1===r.codecs.indexOf(this.options.preferVideoCodec))&&(i||(this.mediaPlayListIndex=n,i=!0),r.resolution&&this.options.preferResolution)){const i=1===t?1:r.resolution.width,a=1===e?1:r.resolution.height;Math.abs(i*a-t*e)<s&&(s=Math.abs(i*a-t*e),this.mediaPlayListIndex=n)}}))}const t=this.masterPlaylist.variants[this.mediaPlayListIndex];if(t){if(t.audio.length&&this.options.preferAudioLang){let e=!1;t.audio.forEach(((t,i)=>{t.language&&t.language.indexOf(this.options.preferAudioLang)>=0&&!e&&(this.audioSelectedIndex=i,t.language===this.options.preferAudioLang&&(e=!0))}))}if(t.subtitles.length&&this.options.preferSubtitleLang){let e=!1;t.subtitles.forEach(((t,i)=>{t.language&&t.language.indexOf(this.options.preferSubtitleLang)>=0&&!e&&(this.subtitleSelectedIndex=i,t.language===this.options.preferSubtitleLang&&(e=!0))}))}}}else{const e=s;if(this.options.isLive&&(!e.segments||e.segments.length<2)){var t;let i=5;return null!==(t=e.segments)&&void 0!==t&&t.length&&(i=e.segments[0].duration*(2-e.segments.length)),f.R8(`wait for min buffer time, now segments: ${e.segments.length}`,v,666),await new h.A(i),this.fetchMasterPlayList()}this.mainLoader=new I(d.X$({enableBandwidthReader:!0},this.options),this.info,this.info.url,e),this.loaders.set(0,this.mainLoader)}return s}catch(t){if(this.retryCount<this.options.retryCount)return this.retryCount++,f.z3(`failed fetch m3u8 file, retry(${this.retryCount}/3)`,v,683),this.sleep=new h.A(3),await this.sleep,this.sleep=null,this.aborted&&f.h2("HLSLoader: exception, fetch abort",v,688),this.fetchMasterPlayList();this.status=3,f.h2("HLSLoader: exception, fetch slice error",v,694)}}buildUrl(t){return/^https?/.test(t)||(t=u.ll(this.info.url,t)),t}async createLoader(){if(this.masterPlaylist){const t=this.masterPlaylist.variants[this.mediaPlayListIndex];if(t||f.h2("no media playlist",v,710),t.audio.length){const e=this.buildUrl(t.audio[this.audioSelectedIndex].uri);this.loaders.set(1,new I(this.options,this.info,e,await b(e,this.info,this.options)))}if(t.subtitles.length){const e=this.buildUrl(t.subtitles[this.subtitleSelectedIndex].uri);this.loaders.set(3,new I(this.options,this.info,e,await b(e,this.info,this.options)))}const e=this.buildUrl(t.uri);this.mainLoader=new I(d.X$({enableBandwidthReader:!0},this.options),this.info,e,await b(e,this.info,this.options)),this.loaders.set(0,this.mainLoader)}}async open(t){return 2===this.status?0:0!==this.status?y.lh:(this.info=t,this.mediaPlayListIndex=0,this.audioSelectedIndex=0,this.subtitleSelectedIndex=0,this.loaders=new(o()),this.status=1,this.retryCount=0,this.aborted=!1,this.start=0,await this.fetchMasterPlayList(),!this.loaders.size&&this.masterPlaylist&&await this.createLoader(),this.status=2,0)}async read(t,e){if(!e)return y.UY;const i=await this.loaders.get(e.mediaType).read(t);return i<0&&-1048575!==i&&(this.status=-1048576===i?4:3),i}async seek(t,e){return e?(await this.loaders.get(e.mediaType).seek(t,this.start),4===this.status&&(this.status=2),0):y.UY}async size(){return BigInt(0)}async abort(){for(let t of this.loaders)await t[1].abort();this.aborted=!0,this.sleep&&(this.sleep.stop(),this.sleep=null)}async stop(){await this.abort(),this.status=0}getDuration(){var t,e;return null!==(t=null===(e=this.mainLoader)||void 0===e?void 0:e.getDuration())&&void 0!==t?t:0}hasVideo(){return this.masterPlaylist?this.masterPlaylist.variants.length>0:!!this.mainLoader}hasAudio(){if(this.masterPlaylist)return this.masterPlaylist.variants[this.mediaPlayListIndex].audio.length>0}hasSubtitle(){if(this.masterPlaylist)return this.masterPlaylist.variants[this.mediaPlayListIndex].subtitles.length>0}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,codec:t.codecs,bandwidth:t.bandwidth}})))&&void 0!==t?t:[],selectedIndex:this.mediaPlayListIndex||0}}getAudioList(){return this.masterPlaylist&&this.hasAudio()?{list:this.masterPlaylist.variants[this.mediaPlayListIndex].audio.map((t=>({lang:t.language,codec:t.name}))),selectedIndex:this.audioSelectedIndex}:{list:[],selectedIndex:0}}getSubtitleList(){return this.masterPlaylist&&this.hasSubtitle()?{list:this.masterPlaylist.variants[this.mediaPlayListIndex].subtitles.map((t=>({lang:t.language,codec:t.name}))),selectedIndex:this.subtitleSelectedIndex}:{list:[],selectedIndex:0}}async selectVideo(t){if(this.masterPlaylist){const e=this.masterPlaylist.variants[t];if(e){const i=this.buildUrl(e.uri),s=await b(i,this.info,this.options);if(this.loaders.get(0).setMediaPlayList(i,s),this.mediaPlayListIndex=t,1===e.audio.length&&this.loaders.has(1)&&this.buildUrl(e.audio[0].uri)!==this.loaders.get(1).getMediaListUrl()){const t=this.buildUrl(e.audio[0].uri),i=await b(t,this.info,this.options);this.loaders.get(1).setMediaPlayList(t,i)}if(1===e.subtitles.length&&this.loaders.has(3)&&this.buildUrl(e.subtitles[0].uri)!==this.loaders.get(3).getMediaListUrl()){const t=this.buildUrl(e.subtitles[0].uri),i=await b(t,this.info,this.options);this.loaders.get(3).setMediaPlayList(t,i)}return this.loaders.get(0).getNextFragmentStart(this.start)}}return-1}async selectAudio(t){if(this.masterPlaylist){const e=this.masterPlaylist.variants[this.mediaPlayListIndex];if(null!=e&&e.audio[t]){const i=this.buildUrl(e.audio[t].uri),s=await b(i,this.info,this.options);return this.loaders.get(1).setMediaPlayList(i,s),this.audioSelectedIndex=t,this.loaders.get(1).getNextFragmentStart(this.start)}}return-1}async selectSubtitle(t){if(this.masterPlaylist){const e=this.masterPlaylist.variants[this.mediaPlayListIndex];if(null!=e&&e.subtitles[t]){const i=this.buildUrl(e.subtitles[t].uri),s=await b(i,this.info,this.options);return this.loaders.get(3).setMediaPlayList(i,s),this.subtitleSelectedIndex=t,this.loaders.get(3).getNextFragmentStart(this.start)}}return-1}getMinBuffer(){var t,e;return null!==(t=null===(e=this.mainLoader)||void 0===e?void 0:e.getMinBuffer())&&void 0!==t?t:0}setStart(t){this.start=t}}},68141:(t,e,i)=>{i.d(e,{A:()=>w});var s=i(14265),a=i.n(s),r=i(89730),n=i.n(r),o=i(21955),h=i.n(o),l=i(33793),d=i.n(l),u=i(91325),c=i(41497),p=i(20163);const m="src/avprotocol/m3u8/parser.ts";function f(t){return u.Bq(t,'"')}function T(t){const e=u.gI(t,",");return{duration:u.Ro(e[0]),title:decodeURIComponent(escape(e[1]))}}function E(t){const e=u.gI(t,"@");return{length:u.Ro(e[0]),offset:e[1]?u.Ro(e[1]):-1}}function y(t){const e=u.gI(t,"x");return{width:u.Ro(e[0]),height:u.Ro(e[1])}}function A(t){const e="ALLOWED-CPC: Each entry must consit of KEYFORMAT and Content Protection Configuration",i=t.split(",");0===i.length&&p.z3(e,m,103);const s=[];for(const t of i){const[i,a]=u.gI(t,":");i&&a?s.push({format:i,cpcList:a.split("/")}):p.z3(e,m,109)}return s}function g(t){const e=u.m2(t);return 16!==e.length&&p.z3("IV must be a 128-bit unsigned integer",m,120),e}function v(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]=E(r);break;case"RESOLUTION":e[t]=y(r);break;case"ALLOWED-CPC":e[t]=A(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&&p.h2(`VIDEO-RANGE: unknown value "${r}"`,m,207),e[t]=r)}}var i;return e}function b(t,e,i){const s=function({attributes:t}){return new c.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&&p.h2(r,m,316),a.push(s),s.isDefault&&(t.currentRenditions[u.Th(i)]=a.length-1)}function I(t,e,i,s,a){const r=new c.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"]||p.h2("EXT-X-MEDIA TYPE attribute is REQUIRED.",m,356),e[s]===t["GROUP-ID"]&&(b(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]))&&p.h2(`${s} attribute MUST match the value of the GROUP-ID attribute of an EXT-X-MEDIA tag whose TYPE attribute is ${s}.`,m,331)}(e,r,a),r.isIFrameOnly=s,r}function X(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 N(t,e,i,s,a,r,o){const l=new c.Y4({uri:e,mediaSequenceNumber:a,discontinuitySequence:r});let d=!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&&p.h2("EXTINF duration, when rounded to the nearest integer, MUST be less than or equal to the target duration",m,518),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&&p.h2("EXT-X-DISCONTINUITY must appear before the first EXT-X-PART tag of the Parent Segment.",m,531),l.discontinuity=!0;else if("EXT-X-KEY"===i)l.parts.length>0&&p.h2("EXT-X-KEY must appear before the first EXT-X-PART tag of the Parent Segment.",m,537),"NONE"!==a.METHOD?(v(o,a),l.key=new c.Uz({method:a.METHOD,uri:a.URI,iv:a.IV,format:a.KEYFORMAT,formatVersion:a.KEYFORMATVERSIONS})):l.key=null;else if("EXT-X-MAP"===i)l.parts.length>0&&p.h2("EXT-X-MAP must appear before the first EXT-X-PART tag of the Parent Segment.",m,556),o.compatibleVersion<5&&(o.compatibleVersion=5),o.hasMap=!0,l.map=new c.qP({uri:a.URI,byterange:a.BYTERANGE,key:l.key});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 c.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 c.xC({type:"OUT",duration:a&&a.DURATION||s}));else if("EXT-X-CUE-IN"===i)l.markers.push(new c.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 c.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)p.h2("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.",m,617);else if("EXT-X-PART"!==i&&"EXT-X-PRELOAD-HINT"!==i||a.URI){if("EXT-X-PRELOAD-HINT"===i&&"MAP"===a.TYPE)d&&p.h2("Servers should not add more than one EXT-X-PRELOAD-HINT tag with the same TYPE attribute to a Playlist.",m,624),d=!0,o.hasMap=!0,l.map=new c.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||p.h2("EXT-X-PART: DURATION attribute is mandatory",m,636),"EXT-X-PRELOAD-HINT"===i&&(u=!0);const t=new c.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 p.h2("EXT-X-PART / EXT-X-PRELOAD-HINT: URI attribute is mandatory",m,620);else p.h2("EXT-X-PRELOAD-HINT: TYPE attribute is mandatory",m,614)}return l}function R(t,e,i,s,a,r,n){const o=new c.Vd({uri:e,mediaSequenceNumber:a,discontinuitySequence:r});for(let e=i;e<=s;e++){const{name:i,attributes:s}=t[e];"EXTINF"===i?p.h2("A prefetch segment must not be advertised with an EXTINF tag.",m,668):"EXT-X-DISCONTINUITY"===i?p.h2("A prefetch segment must not be advertised with an EXT-X-DISCONTINUITY tag.",m,671):"EXT-X-PREFETCH-DISCONTINUITY"===i?o.discontinuity=!0:"EXT-X-KEY"===i?"NONE"!==s.METHOD&&(v(n,s),o.key=new c.Uz({method:s.METHOD,uri:s.URI,iv:s.IV,format:s.KEYFORMAT,formatVersion:s.KEYFORMATVERSIONS})):"EXT-X-MAP"===i&&p.h2("Prefetch segments must not be advertised with an EXT-X-MAP tag.",m,689)}return o}function P(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:p.h2("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST be a sub-range of the same media resource",m,913)}else p.h2("If offset of EXT-X-BYTERANGE is not present, a previous Media Segment MUST appear in the Playlist file",m,917)}return t.segments.push(e),[e.discontinuitySequence,e.key,e.map]}function L(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&&p.h2("The file contains both media and master playlist tags.",m,1024));if("MasterPlaylist"===t){if(void 0===e.isMasterPlaylist)return void(e.isMasterPlaylist=!0);!1===e.isMasterPlaylist&&p.h2("The file contains both media and master playlist tags.",m,1034)}}(r,e),"Unknown"===r)return null;"MediaPlaylist"===r&&"EXT-X-RENDITION-REPORT"!==i&&"EXT-X-PREFETCH"!==i&&(e.hash[i]&&p.h2("There MUST NOT be more than one Media Playlist tag of each type in any Media Playlist",m,1055),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[T(e),null];case"EXT-X-BYTERANGE":return[E(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 D(t,e){let i;return e.isMasterPlaylist?i=function(t,e){const i=new c.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"))&&p.h2("EXT-X-STREAM-INF must be followed by a URI line",m,418);const n=I(t,o,r,!1,e);n&&("number"==typeof n.score&&(s=!0,n.score<0&&p.h2("SCORE attribute on EXT-X-STREAM-INF must be positive decimal-floating-point number.",m,425)),i.variants.push(n))}else if("EXT-X-I-FRAME-STREAM-INF"===r){const s=I(t,o,o.URI,!0,e);s&&i.variants.push(s)}else if("EXT-X-SESSION-DATA"===r){const t=new c.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))&&p.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.",m,445),i.sessionDataList.push(t)}else if("EXT-X-SESSION-KEY"===r){"NONE"===o.METHOD&&p.h2("EXT-X-SESSION-KEY: The value of the METHOD attribute MUST NOT be NONE",m,451);const t=new c.Uz({method:o.METHOD,uri:o.URI,iv:o.IV,format:o.KEYFORMAT,formatVersion:o.KEYFORMATVERSIONS});i.sessionKeyList.some((e=>X(e,t)))&&p.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.",m,461),v(e,o),i.sessionKeyList.push(t)}else"EXT-X-INDEPENDENT-SEGMENTS"===r?(i.independentSegments&&p.h2("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist",m,468),i.independentSegments=!0):"EXT-X-START"===r&&(i.start&&p.h2("EXT-X-START tag MUST NOT appear more than once in a Playlist",m,474),"number"!=typeof o["TIME-OFFSET"]&&p.h2("EXT-X-START: TIME-OFFSET attribute is REQUIRED",m,477),i.start={offset:o["TIME-OFFSET"],precise:o.PRECISE||!1});if(s)for(const t of i.variants)"number"!=typeof t.score&&p.h2("If any Variant Stream contains the SCORE attribute, then all Variant Streams in the Master Playlist SHOULD have a SCORE attribute",m,485);if(e.isClosedCaptionsNone)for(const t of i.variants)t.closedCaptions.length>0&&p.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",m,492);return i}(t,e):(i=function(t,e){const i=new c.tk;let s=-1,a=0,r=!1,n=!1,o=0,h=null,l=null,u=!1;for(const[d,f]of t.entries()){const{name:T,value:E,attributes:y,category:A}=f;if("Segment"!==A){if("EXT-X-VERSION"===T)void 0===i.version?i.version=E:p.h2("A Playlist file MUST NOT contain more than one EXT-X-VERSION tag.",m,721);else if("EXT-X-TARGETDURATION"===T)i.targetDuration=e.targetDuration=E;else if("EXT-X-MEDIA-SEQUENCE"===T)i.segments.length>0&&p.h2("The EXT-X-MEDIA-SEQUENCE tag MUST appear before the first Media Segment in the Playlist.",m,729),i.mediaSequenceBase=a=E;else if("EXT-X-DISCONTINUITY-SEQUENCE"===T)i.segments.length>0&&p.h2("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before the first Media Segment in the Playlist.",m,735),r&&p.h2("The EXT-X-DISCONTINUITY-SEQUENCE tag MUST appear before any EXT-X-DISCONTINUITY tag.",m,738),i.discontinuitySequenceBase=o=E;else if("EXT-X-ENDLIST"===T)i.endlist=!0;else if("EXT-X-PLAYLIST-TYPE"===T)i.playlistType=E;else if("EXT-X-I-FRAMES-ONLY"===T)e.compatibleVersion<4&&(e.compatibleVersion=4),i.isIFrame=!0;else if("EXT-X-INDEPENDENT-SEGMENTS"===T)i.independentSegments&&p.h2("EXT-X-INDEPENDENT-SEGMENTS tag MUST NOT appear more than once in a Playlist",m,756),i.independentSegments=!0;else if("EXT-X-START"===T)i.start&&p.h2("EXT-X-START tag MUST NOT appear more than once in a Playlist",m,762),"number"!=typeof y["TIME-OFFSET"]&&p.h2("EXT-X-START: TIME-OFFSET attribute is REQUIRED",m,765),i.start={offset:y["TIME-OFFSET"],precise:y.PRECISE||!1};else if("EXT-X-SERVER-CONTROL"===T)y["CAN-BLOCK-RELOAD"]||p.h2("EXT-X-SERVER-CONTROL: CAN-BLOCK-RELOAD=YES is mandatory for Low-Latency HLS",m,771),i.lowLatencyCompatibility={canBlockReload:y["CAN-BLOCK-RELOAD"],canSkipUntil:y["CAN-SKIP-UNTIL"],holdBack:y["HOLD-BACK"],partHoldBack:y["PART-HOLD-BACK"]};else if("EXT-X-PART-INF"===T)y["PART-TARGET"]||p.h2("EXT-X-PART-INF: PART-TARGET attribute is mandatory",m,782),i.partTargetDuration=y["PART-TARGET"];else if("EXT-X-RENDITION-REPORT"===T)y.URI||p.h2("EXT-X-RENDITION-REPORT: URI attribute is mandatory",m,788),0===y.URI.search(/^[a-z]+:/)&&p.h2("EXT-X-RENDITION-REPORT: URI must be relative to the playlist uri",m,791),i.renditionReports.push(new c.h4({uri:y.URI,lastMSN:y["LAST-MSN"],lastPart:y["LAST-PART"]}));else if("EXT-X-SKIP"===T)y["SKIPPED-SEGMENTS"]||p.h2("EXT-X-SKIP: SKIPPED-SEGMENTS attribute is mandatory",m,801),e.compatibleVersion<9&&(e.compatibleVersion=9),i.skip=y["SKIPPED-SEGMENTS"],a+=i.skip;else if("EXT-X-PREFETCH"===T){const r=R(t,E,-1===s?d:s,d-1,a++,o,e);r&&(r.discontinuity&&(r.discontinuitySequence++,o=r.discontinuitySequence),r.key?h=r.key:null===r.key?h=void 0:r.key=h,i.prefetchSegments.push(r)),n=!0,s=-1}else if("string"==typeof f){-1===s&&p.h2("A URI line is not preceded by any segment tags",m,841),i.targetDuration||p.h2("The EXT-X-TARGETDURATION tag is REQUIRED",m,844),n&&p.h2("These segments must appear after all complete segments.",m,847);const r=N(t,f,s,d-1,a++,o,e);r&&(null===r.key&&(h=void 0),[o,h,l]=P(i,r,o,h,l),!u&&r.parts.length>0&&(u=!0)),s=-1}}else-1===s&&(s=d),"EXT-X-DISCONTINUITY"===T&&(r=!0)}if(-1!==s){const r=N(t,"",s,t.length-1,a++,o,e);if(r){var f;null===r.key&&(h=void 0);const{parts:t}=r;!(t.length>0)||i.endlist||null!==(f=t[t.length-1])&&void 0!==f&&f.hint||p.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",m,870),P(i,r,o,h,l),!u&&r.parts.length>0&&(u=!0)}}return function(t){const e=new(d()),i=new(d());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)&&p.h2("An EXT-X-DATERANGE tag with an END-ON-NEXT=YES attribute MUST NOT contain DURATION or END-DATE attributes.",m,937);const t=o.start.getTime(),a=o.duration||0;o.end&&o.duration&&t+1e3*a!==o.end.getTime()&&p.h2("END-DATE MUST be equal to the value of the START-DATE attribute plus the value of the DURATION",m,943),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)&&p.h2("DATERANGE tags with the same CLASS should not overlap",m,955);n.push({start:t,end:r})}else o.classId&&i.set(o.classId,[{start:t,end:r}])}}s&&!a&&p.h2("If a Playlist contains an EXT-X-DATERANGE tag, it MUST also contain at least one EXT-X-PROGRAM-DATE-TIME tag.",m,966)}(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&&p.h2("The Skip Boundary must be at least six times the EXT-X-TARGETDURATION.",m,973),o<3*e&&p.h2("HOLD-BACK must be at least three times the EXT-X-TARGETDURATION.",m,977),r){void 0===i&&p.h2("EXT-X-PART-INF is required if a Playlist contains one or more EXT-X-PART tags",m,981),void 0===h&&p.h2("EXT-X-PART: PART-HOLD-BACK attribute is mandatory",m,984),h<i&&p.h2("PART-HOLD-BACK must be at least PART-TARGET",m,987);for(const[t,{parts:e}]of s.entries())for(const[t,{duration:s}]of e.entries())void 0!==s&&(s>i&&p.h2("PART-TARGET is the maximum duration of any Partial Segment",m,998),t<e.length-1&&s<.85*i&&p.h2("All Partial Segments except the last part of a segment must have a duration of at least 85% of PART-TARGET",m,1001))}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)&&p.h2(`EXT-X-VERSION needs to be ${e.compatibleVersion} or higher.`,m,1105),i}function w(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=L(t,e);s&&i.push(s)}}else i.push(t)}return 0!==i.length&&"EXTM3U"===i[0].name||p.h2("The EXTM3U tag MUST be the first line.",m,1087),i}(t,e),s=D(i,e);return s.source=t,s}},41497:(t,e,i)=>{i.d(e,{KT:()=>n,Uz:()=>h,Vd:()=>y,Y4:()=>T,ad:()=>d,h4:()=>A,nw:()=>E,pf:()=>o,qP:()=>l,ru:()=>r,tk:()=>f,ts:()=>m,xC:()=>u});var s=i(9655),a=i(80155);class r{constructor({type:t,uri:e,groupId:i,language:a,assocLanguage:r,name:n,isDefault:o,autoselect:h,forced:l,instreamId:d,characteristics:u,channels:c}){(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=d,this.characteristics=u,this.channels=c}}class n{constructor({uri:t,isIFrameOnly:e=!1,bandwidth:i,averageBandwidth:a,score:r,codecs:n,resolution:o,frameRate:h,hdcpLevel:l,allowedCpc:d,videoRange:u,stableVariantId:c,programId:p,audio:m=[],video:f=[],subtitles:T=[],closedCaptions:E=[],currentRenditions:y={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=d,this.videoRange=u,this.stableVariantId=c,this.programId=p,this.audio=m,this.video=f,this.subtitles=T,this.closedCaptions=E,this.currentRenditions=y}}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,key:r}){(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),(0,s.A)(this,"key",void 0),this.hint=t,this.uri=e,this.mimeType=i,this.byterange=a,this.key=r}}class d{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 c{constructor(t){(0,s.A)(this,"type",void 0),this.type=t}}class p extends c{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 m extends p{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 p{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:d=[],lowLatencyCompatibility:u,partTargetDuration:c,renditionReports:p=[],skip:m=0,hash:f,duration:T=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=d,this.lowLatencyCompatibility=u,this.partTargetDuration=c,this.renditionReports=p,this.skip=m,this.hash=f,this.duration=T,this.timestamp=(0,a.A)()}}class T extends c{constructor({uri:t,mimeType:e,data:i,duration:a,title:r,byterange:n,discontinuity:o,mediaSequenceNumber:h=0,discontinuitySequence:l=0,key:d,map:u,programDateTime:c,dateRange:p,markers:m=[],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=d,this.map=u,this.programDateTime=c,this.dateRange=p,this.markers=m,this.parts=f}}class E extends c{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 y extends c{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 A{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}}},91325:(t,e,i)=>{i.d(e,{Bq:()=>c,HG:()=>p,Ro:()=>l,Th:()=>m,gI:()=>u,m2:()=>d});var s=i(46181),a=i.n(s),r=i(27138),n=i.n(r),o=i(14265),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 d(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 c(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 p(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 m(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("")}},93426:(t,e,i)=>{i.d(e,{$$:()=>r,Eh:()=>f,HR:()=>a,IY:()=>g,Ki:()=>A,Ld:()=>l,Mb:()=>E,Sz:()=>u,Xp:()=>h,_R:()=>n,_m:()=>m,d8:()=>T,iW:()=>c,mX:()=>p,n1:()=>o,os:()=>s,qO:()=>d,u6:()=>y});const s={86017:"mp3",86018:"mp4a.40",86021:"vorbis",86028:"flac",86076:"opus",65542:"ulaw",65543:"alaw",86019:"ac-3",86056:"ec-3",86020:"dtsc",65541:"pcm-u8",65540:"pcm-s8",65536:"pcm-s16",65537:"pcm-s16be",65548:"pcm-s24",65549:"pcm-s24be",65544:"pcm-s32",65545:"pcm-s32be",65557:"pcm-f32",65556:"pcm-f32be",65559:"pcm-f64",65558:"pcm-f64be",225:"av01",27:"avc1",173:"hev1",196:"vvc1",139:"vp8",167:"vp09",12:"mp4v"},a={flv:0,mp4:1,m4s:1,mov:1,ts:2,mts:2,m2ts:2,ivf:5,opus:4,oggs:4,ogg:4,m3u8:2,m3u:2,mpd:1,mp3:14,mkv:8,mka:8,webm:9,aac:15,flac:17,wav:16,srt:19,vtt:18,ssa:20,ass:20,xml:21,ttml:21,h264:11,264:11,avc:11,h265:12,265:12,hevc:12,h266:13,266:13,vvc:13,mpeg:3,mpg:3,rtsp:6,rtmp:7,avi:10,avif:1,heic:1},r={m3u8:4,m3u:4,mpd:5},n={copy:0,h264:27,h261:3,h263:4,h263i:20,h263p:19,mjpeg:7,wmv1:17,wmv2:18,wmv3:71,avc:27,hevc:173,h265:173,vvc:196,h266:196,av1:225,vp9:167,vp8:139,mpeg4:12,theora:30,mpeg2video:2,rv10:5,rv20:6,rv30:68,rv40:69,png:61,bmp:78,webp:171,tiff:96,gif:97},o={copy:0,aac:86018,ac3:86019,eac3:86056,dts:86020,mp3:86017,opus:86076,flac:86028,speex:86051,vorbis:86021,pcm_alaw:65543,pcm_mulaw:65542,wmav1:86023,wmav2:86024,cook:86036,sipr:86057,ralf:86073,pcm_u8:65541,pcm_s16le:65536,pcm_s24le:65548,pcm_s32le:65544,pcm_s64le:65567,pcm_f32le:65557,pcm_f64le:65559},h={webvtt:94226,subrip:94225,ass:94230,ttml:94232,mov_text:94213,hdmv_pgs:94214,hdmv_text:94231,dvd:94208,dvb:94209,eia_608:94218},l={bin_data:98314},d={yuv420p:0,yuv422p:4,yuv444p:5,yuva420p:33,yuva422p:78,yuva444p:79,yuvj420p:12,yuvj422p:13,yuvj444p:14,yuv420p10le:62,yuv422p10le:64,yuv444p10le:68,yuva420p10le:87,yuva422p10le:89,yuva444p10le:91,yuv420p10be:61,yuv422p10be:63,yuv444p10be:67,yuva420p10be:86,yuva422p10be:88,yuva444p10be:90,rgba:26,rgb24:2,bgr24:3,gray:8},u={u8:0,"u8-planar":5,s16:1,"s16-planar":6,s32:2,"s32-planar":7,s64:10,"s64-planar":11,float:3,"float-planar":8,double:4,"double-planar":9},c={flv:0,isobmff:1,mp4:1,mov:1,ts:2,mpegts:2,mpeg:3,ivf:5,ogg:4,opus:4,m3u8:2,m3u:2,mpd:1,mp3:14,mkv:8,matroska:8,mka:8,webm:9,aac:15,flac:17,wav:16,raw_h264:11,raw_h265:12,raw_vvc:13,rtsp:6,rtmp:7,avi:10},p={tv:1,pc:2},m={bt709:1,fcc:4,bt470bg:5,smpte170m:6,smpte240m:7,ycgco:8,gbr:0,bt2020nc:9},f={bt709:1,bt470m:4,bt470bg:5,smpte170m:6,smpte240m:7,smpte428:10,film:8,smpte431:11,smpte432:12,bt2020:9,"jedec-p22":22,ebu3213:22},T={bt709:1,gamma22:4,gamma28:5,smpte170m:6,smpte240m:7,srgb:13,xvycc:11,"bt2020-10":14,"bt2020-12":15,smpte2084:16,"arib-std-b67":18},E={Audio:1,Video:0,Subtitle:3,Attachment:4,Data:2},y={"Tile Grid":3,"Audio Element":1,"Mix Presentation":2},A={default:1,dub:2,original:4,comment:8,lyrics:16,karaoke:32,forced:64,"hearing impaired":128,"visual impaired":256,"clean effects":512,"attached pic":1024,"timed thumbnails":2048,captions:65536,descriptions:131072,metadata:262144,dependent:524288,"still image":1048576,thumbnail:8192},g={mono:4,stereo:3,2.1:11,"3.0":7,"3.0(back)":259,"4.0":263,quad:51,"quad(side)":1539,3.1:15,"5.0":55,"5.0(side)":1543,4.1:271,5.1:63,"5.1(side)":1551,"6.0":1799,"6.0(front)":1731,"3.1.2":20495,hexagonal:311,6.1:1807,"6.1(back)":319,"6.1(front)":1739,"7.0":1591,"7.0(front)":1735,7.1:1599,"7.1(wide)":255,"7.1(wide-side)":1743,"5.1.2":20543,octagonal:1847,cube:184371,"5.1.4":184383,"7.1.2":22079,"7.1.4":185919,"7.2.3":34359825983,"9.1.4":186111,hexadecagonal:6442710839,downmix:1610612736,22.2:2164663779327}},54893:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(9655);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],d=o[2],u=o[3],c=new Uint32Array(256);let p=0,m=0,f=0;for(f=0;f<256;f++)c[f]=f<128?f<<1:f<<1^283;for(f=0;f<256;f++){let i=m^m<<1^m<<2^m<<3^m<<4;i=i>>>8^255&i^99,t[p]=i,e[i]=p;const o=c[p],f=c[o],T=c[f];let E=257*c[i]^16843008*i;s[p]=E<<24|E>>>8,a[p]=E<<16|E>>>16,r[p]=E<<8|E>>>24,n[p]=E,E=16843009*T^65537*f^257*o^16843008*p,h[i]=E<<24|E>>>8,l[i]=E<<16|E>>>16,d[i]=E<<8|E>>>24,u[i]=E,p?(p=o^c[c[c[T^o]]],m^=c[c[m]]):p=m=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,d=this.invSubMix,u=d[0],c=d[1],p=d[2],m=d[3];let f,T;for(a=0;a<s;a++)a<i?f=n[a]=e[a]:(T=f,a%i==0?(T=T<<8|T>>>24,T=h[T>>>24]<<24|h[T>>>16&255]<<16|h[T>>>8&255]<<8|h[255&T],T^=l[a/i|0]<<24):i>6&&a%i==4&&(T=h[T>>>24]<<24|h[T>>>16&255]<<16|h[T>>>8&255]<<8|h[255&T]),n[a]=f=(n[a-i]^T)>>>0);for(r=0;r<s;r++)a=s-r,T=3&r?n[a]:n[a-4],o[r]=r<4||a<=4?T:u[h[T>>>24]]^c[h[T>>>16&255]]^p[h[T>>>8&255]]^m[h[255&T]],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],d=this.uint8ArrayToUint32Array_(e);let u=d[0],c=d[1],p=d[2],m=d[3];const f=new Int32Array(t.buffer).subarray(t.byteOffset>>>2,(t.byteOffset>>>2)+(t.length>>>2)),T=new Int32Array(f.length);let E,y,A,g,v,S,b,I,X,N,R,P,L,D;const w=this.networkToHostOrderSwap;let O=0;for(;O<f.length;){for(X=w(f[O]),N=w(f[O+1]),R=w(f[O+2]),P=w(f[O+3]),v=X^s[0],S=P^s[1],b=R^s[2],I=N^s[3],L=4,D=1;D<i;D++)E=n[v>>>24]^o[S>>16&255]^h[b>>8&255]^l[255&I]^s[L],y=n[S>>>24]^o[b>>16&255]^h[I>>8&255]^l[255&v]^s[L+1],A=n[b>>>24]^o[I>>16&255]^h[v>>8&255]^l[255&S]^s[L+2],g=n[I>>>24]^o[v>>16&255]^h[S>>8&255]^l[255&b]^s[L+3],v=E,S=y,b=A,I=g,L+=4;E=a[v>>>24]<<24^a[S>>16&255]<<16^a[b>>8&255]<<8^a[255&I]^s[L],y=a[S>>>24]<<24^a[b>>16&255]<<16^a[I>>8&255]<<8^a[255&v]^s[L+1],A=a[b>>>24]<<24^a[I>>16&255]<<16^a[v>>8&255]<<8^a[255&S]^s[L+2],g=a[I>>>24]<<24^a[v>>16&255]<<16^a[S>>8&255]<<8^a[255&b]^s[L+3],T[O]=w(E^u),T[O+1]=w(g^c),T[O+2]=w(A^p),T[O+3]=w(y^m),u=X,c=N,p=R,m=P,O+=4}return T.buffer}}},10855:(t,e,i)=>{i.d(e,{A:()=>a});var s=i(9655);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)}}},97023:(t,e,i)=>{i(68483),i(31126)},10446:(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:()=>u,qg:()=>s}),i(38035),i(68483),i(97023),i(31126),i(99868);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 d(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=d(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=d(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=d(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?d(s.path):s.path),h(r)}},6431:(t,e,i)=>{var s=i(54446),a=s.JSON||(s.JSON={stringify:JSON.stringify});t.exports=function(t){return a.stringify.apply(a,arguments)}},52214:(t,e,i)=>{i(56930),t.exports=i(54446).Number.isInteger},49669:(t,e,i)=>{i(37305),t.exports=i(54446).Number.isNaN},4801:(t,e,i)=>{i(80613),t.exports=i(54446).Number.parseFloat},81646:(t,e,i)=>{i(50338),t.exports=i(54446).Number.parseInt},40738:(t,e,i)=>{var s=i(72441),a=Math.floor;t.exports=function(t){return!s(t)&&isFinite(t)&&a(t)===t}},56930:(t,e,i)=>{var s=i(78255);s(s.S,"Number",{isInteger:i(40738)})},37305:(t,e,i)=>{var s=i(78255);s(s.S,"Number",{isNaN:function(t){return t!=t}})},80613:(t,e,i)=>{var s=i(78255),a=i(50149);s(s.S+s.F*(Number.parseFloat!=a),"Number",{parseFloat:a})},50338:(t,e,i)=>{var s=i(78255),a=i(25634);s(s.S+s.F*(Number.parseInt!=a),"Number",{parseInt:a})},38035:(t,e,i)=>{t.exports=i(6431)},89730:(t,e,i)=>{t.exports=i(52214)},14265:(t,e,i)=>{t.exports=i(49669)},46181:(t,e,i)=>{t.exports=i(4801)},27138:(t,e,i)=>{t.exports=i(81646)}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[60],{89984:(t,e,i)=>{i.d(e,{A:()=>n});var s=i(9655);class n{constructor(){(0,s.A)(this,"type",-1),(0,s.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},29060:(t,e,i)=>{i.r(e),i.d(e,{default:()=>B});var s=i(9655),n=i(36311),r=i(20163),a=i(20086),o=i(89984),h=i(41321),u=i(1140),d=i(37142),c=i(31126),f=i(19372),l=i(7782),g=i(89378),m=i(69663);const p="src/avformat/formats/IWebVttFormat.ts";class B extends o.A{constructor(){super(),(0,s.A)(this,"type",18),(0,s.A)(this,"queue",void 0),(0,s.A)(this,"index",void 0),(0,s.A)(this,"baseTs",void 0)}init(t){this.queue=[],this.baseTs=BigInt(0)}async readChunk(t){let e="";const i=t.ioReader.getPos();for(;;){const i=await t.ioReader.readLine();if(""===i||"WEBVTT"===i)break;e+=i+"\n"}return{chunk:e.trim(),pos:i}}async readCue(t,e){for(;;){const{chunk:i,pos:s}=await this.readChunk(t);if(""===i||/^NOTE/.test(i)||"WEBVTT"===i)continue;if(/^STYLE/.test(i)){e.push({style:i.replace(/STYLE[\s|\n]?/,""),pos:s});continue}if(/^X-TIMESTAMP-MAP/.test(i)){const t=i.split("=")[1].split(",");let e=BigInt(0),s=BigInt(0);t.forEach((t=>{const i=t.split(":");"LOCAL"===i[0]?(i.shift(),e=(0,l.j)(i.join(":").trim())):"MPEGTS"===i[0]&&(s=BigInt(+i[1])*BigInt(1e3)/BigInt(9e4))})),this.baseTs=s-e;continue}const n=i.split("\n");let r,a;-1===n[0].indexOf("--\x3e")&&(r=n.shift().trim());let o=n.shift().split("--\x3e");const h=(0,l.j)(o.shift())+this.baseTs;o=o.shift().trim().split(" ");const u=(0,l.j)(o.shift())+this.baseTs;if(u<=h)continue;o=o.filter((t=>""!==t)),o.length&&(a=o.join(" "));const d=n.join("\n").trim();if(d)return{identifier:r,options:a,context:d,startTs:h,endTs:u,pos:s}}}async readHeader(t){const e=await t.ioReader.peekBuffer(3);if(239===e[0]&&187===e[1]&&191===e[2]&&await t.ioReader.skip(3),"WEBVTT"!==await t.ioReader.peekString(6))return r.z3("the file format is not vtt",p,169),a.LR;const i=t.createStream();i.codecpar.codecId=94226,i.codecpar.codecType=3,i.timeBase.den=1e3,i.timeBase.num=1;const s=await t.ioReader.readLine();s.indexOf("-")>0&&(i.metadata.title=s.split("-").pop().trim()),this.index=0;const n=[];let o=BigInt(0);try{for(;;){const e=await this.readCue(t,n);if(i.nbFrames++,i.duration=e.endTs,e.startTs>=o?(this.queue.push(e),o=e.startTs):c._(this.queue,e,(t=>t.startTs<e.startTs?1:-1)),2&t.ioReader.flags)break}}catch(t){}return i.metadata.styles=n,0}async readAVPacket(t,e){const i=t.streams.find((t=>3===t.codecpar.codecType));if(2&t.ioReader.flags){if(this.index>=this.queue.length)try{const s=await this.readCue(t,i.metadata.styles);if(this.queue.length){const i=this.queue[this.queue.length-1];if(i.startTs===s.startTs&&i.endTs===s.endTs&&i.context===s.context)return this.readAVPacket(t,e)}this.queue.push(s),i.nbFrames++,i.duration=s.endTs}catch(e){return-1048576!==t.ioReader.error&&-1048572!==t.ioReader.error?(r.z3(`read cue error, ${e}`,p,252),a.LR):t.ioReader.error}}else{if(!this.queue.length)return a.LR;if(this.index>=this.queue.length)return-1048576}const s=this.queue[this.index++];if(n.M[15](e+32,i.index),n.M[15](e+76,i.timeBase.den),n.M[15](e+72,i.timeBase.num),n.M[17](e+16,s.startTs),n.M[17](e+8,s.startTs),n.M[17](e+48,s.endTs-s.startTs),s.identifier){const t=f.encode(s.identifier),i=(0,u.sY)(t.length);(0,h.lW)(i,t.length,t),(0,d.Ow)(e,16,i,t.length)}if(s.options){const t=f.encode(s.options),i=(0,u.sY)(t.length);(0,h.lW)(i,t.length,t),(0,d.Ow)(e,17,i,t.length)}const o=f.encode(s.context),c=(0,u.sY)(o.length);return(0,h.lW)(c,o.length,o),(0,d.NX)(e,c,o.length),0}async seek(t,e,i,s){if(2&s)return BigInt(a.E$);if(16&s&&2&t.ioReader.flags){const s=(0,m.k)(i,e.timeBase,g.i0);return await t.ioReader.seek(s,!0),this.queue.length=0,this.index=0,BigInt(0)}if(i<=BigInt(0))return this.index=0,BigInt(0);const n=c.El(this.queue,(t=>t.startTs>i?-1:1));if(n>=0){for(r.Yz(`seek in cues, found index: ${n}, pts: ${this.queue[n].startTs}, pos: ${this.queue[n].pos}`,p,319),this.index=Math.max(n-1,0);this.index>0&&(this.queue[this.index-1].startTs===this.queue[this.index].startTs||this.queue[this.index-1].endTs>i);)this.index--;return BigInt(0)}return BigInt(a.LR)}getAnalyzeStreamsCount(){return 1}}},7782:(t,e,i)=>{function s(t){if(!t)return-BigInt(1);let e=(t=t.trim()).split(":"),i=BigInt(0);return 3===e.length&&(i+=BigInt(+e.shift().trim())*BigInt(36e5)),i+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split("."),i+=BigInt(+e.shift().trim())*BigInt(1e3),e.length&&(i+=BigInt(+e.shift().trim())),i}function n(t){if(!t)return-BigInt(1);let e=(t=t.trim()).split(":"),i=BigInt(0);return 3===e.length&&(i+=BigInt(+e.shift().trim())*BigInt(36e5)),i+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split(","),i+=BigInt(+e.shift().trim())*BigInt(1e3),e.length&&(i+=BigInt(+e.shift().trim())),i}i.d(e,{j:()=>s,t:()=>n})}}]);
1
+ (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[60],{89984:(t,e,i)=>{i.d(e,{A:()=>n});var s=i(9655);class n{constructor(){(0,s.A)(this,"type",-1),(0,s.A)(this,"onStreamAdd",void 0)}async destroy(t){}}},29060:(t,e,i)=>{i.r(e),i.d(e,{default:()=>p});var s=i(9655),n=i(36311),r=i(20163),a=i(20086),o=i(89984),h=i(41321),u=i(1140),d=i(37142),c=i(31126),f=i(19372),l=i(7782),g=i(89378),B=i(69663);const m="src/avformat/formats/IWebVttFormat.ts";class p extends o.A{constructor(){super(),(0,s.A)(this,"type",18),(0,s.A)(this,"queue",void 0),(0,s.A)(this,"index",void 0),(0,s.A)(this,"baseTs",void 0)}init(t){this.queue=[],this.baseTs=BigInt(0)}async readChunk(t){let e="";const i=t.ioReader.getPos();for(;;){const i=await t.ioReader.readLine();if(""===i||"WEBVTT"===i)break;e+=i+"\n"}return{chunk:e.trim(),pos:i}}async readCue(t,e){for(;;){const{chunk:i,pos:s}=await this.readChunk(t);if(""===i||/^NOTE/.test(i)||"WEBVTT"===i)continue;if(/^STYLE/.test(i)){e.push({style:i.replace(/STYLE[\s|\n]?/,""),pos:s});continue}if(/^X-TIMESTAMP-MAP/.test(i)){const t=i.split("=")[1].split(",");let e=BigInt(0),s=BigInt(0);t.forEach((t=>{const i=t.split(":");"LOCAL"===i[0]?(i.shift(),e=(0,l.j)(i.join(":").trim())):"MPEGTS"===i[0]&&(s=BigInt(+i[1])*BigInt(1e3)/BigInt(9e4))})),this.baseTs=s-e;continue}const n=i.split("\n");let r,a;-1===n[0].indexOf("--\x3e")&&(r=n.shift().trim());let o=n.shift().split("--\x3e");const h=(0,l.j)(o.shift())+this.baseTs;o=o.shift().trim().split(" ");const u=(0,l.j)(o.shift())+this.baseTs;if(u<=h)continue;o=o.filter((t=>""!==t)),o.length&&(a=o.join(" "));const d=n.join("\n").trim();if(d)return{identifier:r,options:a,context:d,startTs:h,endTs:u,pos:s}}}async readHeader(t){const e=await t.ioReader.peekBuffer(3);if(239===e[0]&&187===e[1]&&191===e[2]&&await t.ioReader.skip(3),"WEBVTT"!==await t.ioReader.peekString(6))return r.z3("the file format is not vtt",m,169),a.LR;const i=t.createStream();i.codecpar.codecId=94226,i.codecpar.codecType=3,i.timeBase.den=1e3,i.timeBase.num=1;const s=await t.ioReader.readLine();s.indexOf("-")>0&&(i.metadata.title=s.split("-").pop().trim()),this.index=0;const n=[];let o=BigInt(0);try{for(;;){const e=await this.readCue(t,n);if(i.nbFrames++,i.duration=e.endTs,e.startTs>=o?(this.queue.push(e),o=e.startTs):c._(this.queue,e,(t=>t.startTs<e.startTs?1:-1)),2&t.ioReader.flags)break}}catch(t){}return i.metadata.styles=n,0}async readAVPacket(t,e){const i=t.streams.find((t=>3===t.codecpar.codecType));if(2&t.ioReader.flags){if(this.index>=this.queue.length)try{const s=await this.readCue(t,i.metadata.styles);if(this.queue.length){const i=this.queue[this.queue.length-1];if(i.startTs===s.startTs&&i.endTs===s.endTs&&i.context===s.context)return this.readAVPacket(t,e)}this.queue.push(s),i.nbFrames++,i.duration=s.endTs}catch(e){return-1048576!==t.ioReader.error&&-1048572!==t.ioReader.error?(r.z3(`read cue error, ${e}`,m,252),a.LR):t.ioReader.error}}else{if(!this.queue.length)return a.LR;if(this.index>=this.queue.length)return-1048576}const s=this.queue[this.index++];if(n.M[15](e+32,i.index),n.M[15](e+76,i.timeBase.den),n.M[15](e+72,i.timeBase.num),n.M[17](e+16,s.startTs),n.M[17](e+8,s.startTs),n.M[17](e+48,s.endTs-s.startTs),s.identifier){const t=f.encode(s.identifier),i=(0,u.sY)(t.length);(0,h.lW)(i,t.length,t),(0,d.Ow)(e,16,i,t.length)}if(s.options){const t=f.encode(s.options),i=(0,u.sY)(t.length);(0,h.lW)(i,t.length,t),(0,d.Ow)(e,17,i,t.length)}const o=f.encode(s.context),c=(0,u.sY)(o.length);return(0,h.lW)(c,o.length,o),(0,d.NX)(e,c,o.length),0}async seek(t,e,i,s){if(2&s)return BigInt(a.E$);if(16&s&&2&t.ioReader.flags){const s=(0,B.k)(i,e.timeBase,g.i0);return await t.ioReader.seek(s,!0),this.queue.length=0,this.index=0,BigInt(0)}if(i<=BigInt(0))return this.index=0,BigInt(0);const n=c.El(this.queue,(t=>t.startTs>i?-1:1));if(n>=0){for(r.Yz(`seek in cues, found index: ${n}, pts: ${this.queue[n].startTs}, pos: ${this.queue[n].pos}`,m,319),this.index=Math.max(n-1,0);this.index>0&&(this.queue[this.index-1].startTs===this.queue[this.index].startTs||this.queue[this.index-1].endTs>i);)this.index--;return BigInt(0)}return BigInt(a.LR)}getAnalyzeStreamsCount(){return 1}}},7782:(t,e,i)=>{function s(t){if(!t)return-BigInt(1);let e=(t=t.trim()).split(":"),i=BigInt(0);if(3===e.length&&(i+=BigInt(+e.shift().trim())*BigInt(36e5)),i+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split("."),i+=BigInt(+e.shift().trim())*BigInt(1e3),e.length){let t=e[0].trim().length,s=BigInt(+e.shift().trim());1===t?s*=BigInt(100):2===t&&(s*=BigInt(10)),i+=s}return i}function n(t){if(!t)return-BigInt(1);let e=(t=t.trim()).split(":"),i=BigInt(0);if(3===e.length&&(i+=BigInt(+e.shift().trim())*BigInt(36e5)),i+=BigInt(+e.shift().trim())*BigInt(6e4),e=e.shift().trim().split(","),i+=BigInt(+e.shift().trim())*BigInt(1e3),e.length){let t=e[0].trim().length,s=BigInt(+e.shift().trim());1===t?s*=BigInt(100):2===t&&(s*=BigInt(10)),i+=s}return i}i.d(e,{j:()=>s,t:()=>n})}}]);
@@ -1 +1 @@
1
- (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[690],{5114:(t,i,e)=>{e.d(i,{A:()=>r});var s=e(9655);class r{constructor(){(0,s.A)(this,"signature",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"flags",void 0),(0,s.A)(this,"dataOffset",void 0),(0,s.A)(this,"hasVideo",void 0),(0,s.A)(this,"hasAudio",void 0),this.signature="FLV",this.version=1,this.flags=0,this.dataOffset=9,this.hasAudio=!1,this.hasVideo=!1}async read(t){this.signature=await t.readString(3),this.version=await t.readUint8(),this.flags=await t.readUint8(),this.dataOffset=await t.readUint32(),this.hasAudio=!!(4&this.flags),this.hasVideo=!!(1&this.flags)}write(t){this.flags=0,this.hasAudio&&(this.flags|=4),this.hasVideo&&(this.flags|=1),t.writeString(this.signature),t.writeUint8(this.version),t.writeUint8(this.flags),t.writeUint32(this.dataOffset)}}},63278:(t,i,e)=>{e.d(i,{A:()=>u});var s=e(9655),r=e(81895),n=e(64310),a=e(20163),h=e(68944),o=e(20086),f=e(41177);class u{constructor(){(0,s.A)(this,"onMetaData",void 0),this.onMetaData={canSeekToEnd:!1}}async read(t,i){const e=t.getPos(),s=e+BigInt(Math.floor(i)),r=await(0,f.$x)(t,s),n=await(0,f.$x)(t,s);this[r]=n,s>t.getPos()&&await t.skip(Number(BigInt.asIntN(32,s-t.getPos())));const h=Number(t.getPos()-e),u=await t.readUint32();return h+11!==u?(a.R8(`script size not match, size: ${h+11}, previousTagSize: ${u}`,"src/avformat/formats/flv/FlvScriptTag.ts",63),o.LR):0}computeSize(){const t=[],i=new r.A;return i.onFlush=i=>(t.push(i.slice()),0),(0,f.bD)(i,"onMetaData"),(0,f.bD)(i,this.onMetaData),i.flush(),(0,n.A)(Uint8Array,t).length}write(t){if(this.onMetaData){const i=[],e=new r.A;e.onFlush=t=>(i.push(t.slice()),0),(0,f.bD)(e,"onMetaData"),(0,f.bD)(e,this.onMetaData),e.flush();const s=(0,n.A)(Uint8Array,i);h.M5(t,18,BigInt(0),void 0,s)}}dts2Position(t){if(this.canSeek()){let i=-1;const e=this.onMetaData.keyframes.times,s=this.onMetaData.keyframes.filepositions;let r;for(r=0;r<e.length;r++){if(e[r]===t){i=r;break}if(e[r]>t){i=Math.max(r-1,0);break}}return r&&r===e.length&&(i=e.length-1),{pos:s[i],dts:e[i]}}return{pos:-1,dts:-1}}position2DTS(t){if(this.canSeek()){let e=-1;const s=this.onMetaData.keyframes.times,r=this.onMetaData.keyframes.filepositions;let n=0;for(n=0;n<r.length;n++)if(r[n]>t){e=n;break}var i;return n===r.length?null!==(i=this.onMetaData.duration)&&void 0!==i?i:s[s.length-1]:s[e]}return-1}canSeek(){return!!(this.onMetaData.keyframes&&this.onMetaData.keyframes.filepositions&&this.onMetaData.keyframes.filepositions.length)}}},71619:(t,i,e)=>{e.d(i,{FJ:()=>s,U5:()=>r});const s={10:86018,2:86017,11:86051,1:69645,4:86049,5:86049,6:86049,7:65543,8:65542},r={7:27,12:173,9:12,2:4,3:86,4:92,5:106,6:131}},68944:(t,i,e)=>{e.d(i,{M5:()=>n}),e(71619),e(69663),e(89378),e(92324);var s=e(68483);function r(t,i,e){const s=t.getPos(),r=t.getPointer(),n=s-BigInt(Math.floor(r));i<s&&i>=n?(t.seekInline(r+Number(i-s)),t.writeUint24(e),t.seekInline(r)):(t.seek(i),t.writeUint24(e),t.seek(s))}function n(t,i,e,n,a,h){t.flush(),t.writeUint8(i);const o=t.getPos();t.writeUint24(0),t.writeUint24(Number(e&BigInt(16777215))),t.writeUint8(Number(e>>BigInt(24)&BigInt(255))),t.writeUint24(0);const f=t.getPos();n&&n(t),s.Pc(a)?(a(t),r(t,o,Number(t.getPos()-f))):a&&(r(t,o,a.length+Number(t.getPos()-f)),t.writeBuffer(a));const u=Number(t.getPos()-o)+1;h&&h(u),t.writeUint32(u)}},92324:(t,i,e)=>{e.d(i,{A:()=>n});var s=e(20163);const r="src/avformat/function/mktag.ts";function n(t){4!==t.length&&s.R8(`tag length is not 4, tag: ${t}`,r,30);let i=0;for(let e=0;e<4;e++)i=i<<8|t.charCodeAt(e);return i}},27690:(t,i,e)=>{e.r(i),e.d(i,{default:()=>b});var s=e(9655),r=e(33096),n=e(65160),a=e(90946),h=e(95779),o=e(17848),f=e(73416),u=e(10446),l=e(81895),d=e(5114),p=e(63278),c=e(48162),w=e(41177),g=e(21472);class b extends r.A{constructor(...t){super(...t),(0,s.A)(this,"info",void 0),(0,s.A)(this,"socket",void 0),(0,s.A)(this,"session",void 0),(0,s.A)(this,"ioReader",void 0),(0,s.A)(this,"ioWriter",void 0),(0,s.A)(this,"flvWriter",void 0),(0,s.A)(this,"flvHeader",void 0),(0,s.A)(this,"packetQueue",void 0),(0,s.A)(this,"flvHeaderWrote",void 0),(0,s.A)(this,"hasMetadata",void 0),(0,s.A)(this,"bufferReader",void 0)}writeFlvData(t){this.flvWriter.writeUint8(t.type),this.flvWriter.writeUint24(t.payload.length),this.flvWriter.writeUint24(t.timestamp),this.flvWriter.writeUint8(t.timestamp>>24),this.flvWriter.writeUint24(0),this.flvWriter.writeBuffer(t.payload),this.flvWriter.writeUint32(t.payload.length+11),this.flvWriter.flush()}async handleRtmpPacket(t){if(this.flvHeaderWrote)this.writeFlvData(t);else{if(this.packetQueue.push(t),8===t.type)this.flvHeader.hasAudio=!0;else if(9===t.type)this.flvHeader.hasVideo=!0;else if(18===t.type&&(this.bufferReader?this.bufferReader.resetBuffer(t.payload):this.bufferReader=new c.A(t.payload),"onMetaData"===await w.$x(this.bufferReader,BigInt(t.payload.length)))){this.hasMetadata=!0;const i=await w.$x(this.bufferReader,BigInt(t.payload.length));this.flvHeader.hasAudio=(0,g.A)(i.audiocodecid),this.flvHeader.hasVideo=(0,g.A)(i.videocodecid)}if(this.packetQueue.length>10||this.hasMetadata){if(this.flvHeader.write(this.flvWriter),this.flvWriter.writeUint32(0),!this.hasMetadata&&this.session.getDuration()){const t=new p.A;t.onMetaData={duration:this.session.getDuration()},t.write(this.flvWriter)}this.packetQueue.forEach((t=>{this.writeFlvData(t)})),this.packetQueue.length=0,this.flvHeaderWrote=!0}}}async send(t){return this.socket?(await this.socket.send(t),0):-1048574}async open(t){this.info=t,this.status=1,3===t.subProtocol?(this.socket=new a.A(this.options),await this.socket.open({url:t.url,webtransportOptions:t.webtransportOptions})):(this.socket=new n.A(this.options),await this.socket.open({url:t.url})),this.ioReader=new o.A,this.ioReader.onFlush=async t=>this.socket.read(t),this.ioReader.onSeek=async t=>this.socket.seek(t),this.ioReader.onSize=async()=>this.socket.size(),this.ioWriter=new f.A,this.ioWriter.onFlush=async t=>this.socket.write(t),this.ioWriter.onSeek=async t=>this.socket.seek(t),this.flvWriter=new l.A,this.flvWriter.onFlush=t=>(this.readQueue.push(t.slice()),this.consume&&this.consume(),0),this.flvHeader=new d.A,this.packetQueue=[],this.flvHeaderWrote=!1,this.hasMetadata=!1,this.session=new h.A(this.ioReader,this.ioWriter,{isLive:this.options.isLive,isPull:!0}),this.session.onMediaPacket=async(t,i)=>this.handleRtmpPacket(t),this.session.onError=()=>{this.status=3,this.consume&&this.consume()},await this.session.handshake();const i=u.qg(this.info.uri),e=i.pathname.split("/");await this.session.connect(e[1],`rtmp://${i.host}${i.port?":"+i.port:""}/${e[1]}`);const s=e.slice(2);return this.session.play((s.length>1?s.join("/"):s[0])||""),0}async seek(t){return await this.session.seek(Number(t)),0}async size(){return BigInt(0)}async stop(){this.socket&&(await this.socket.stop(),this.socket=null),this.status=4}}},72231:(t,i,e)=>{e.d(i,{u:()=>r});var s=e(9655);class r{constructor(t,i,e,r){(0,s.A)(this,"channelId",void 0),(0,s.A)(this,"type",void 0),(0,s.A)(this,"timestamp",void 0),(0,s.A)(this,"tsField",0),(0,s.A)(this,"extra",0),(0,s.A)(this,"payload",void 0),this.channelId=t,this.type=i,this.timestamp=e,this.payload=r instanceof Uint8Array?r:new Uint8Array(r)}}},95779:(t,i,e)=>{e.d(i,{A:()=>U});var s=e(9655),r=e(33793),n=e.n(r),a=e(55906),h=e.n(a),o=e(72231),f=e(5332),u=e(80155),l=e(87590),d=e(28495),p=e(41177),c=e(61272),w=e(48162),g=e(20163),b=e(31126),y=e(68483),m=e(56719),k=e(22080);const v="src/avprotocol/rtmp/RtmpSession.ts";class U{constructor(t,i,e){(0,s.A)(this,"ioReader",void 0),(0,s.A)(this,"ioWriter",void 0),(0,s.A)(this,"prevReadPacket",void 0),(0,s.A)(this,"prevWritePacket",void 0),(0,s.A)(this,"inChunkSize",void 0),(0,s.A)(this,"outChunkSize",void 0),(0,s.A)(this,"seq",void 0),(0,s.A)(this,"bufferWriter",void 0),(0,s.A)(this,"bufferReader",void 0),(0,s.A)(this,"requestMap",void 0),(0,s.A)(this,"state",void 0),(0,s.A)(this,"maxSentUnacked",void 0),(0,s.A)(this,"receiveReportSize",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"options",void 0),(0,s.A)(this,"streamIdMap",void 0),(0,s.A)(this,"sendAsync",void 0),(0,s.A)(this,"onMediaPacket",void 0),(0,s.A)(this,"onError",void 0),this.ioReader=t,this.ioWriter=i,this.options=e,this.prevReadPacket=new(n()),this.prevWritePacket=new(n()),this.requestMap=new(n()),this.streamIdMap=new(n()),this.inChunkSize=128,this.outChunkSize=128,this.seq=0,this.maxSentUnacked=25e5,this.receiveReportSize=1048576,this.sendAsync=new k.an,this.bufferWriter=new l.A(new Uint8Array(1)),this.bufferReader=new w.A(new Uint8Array(1)),this.state=0}async handshake(){const t=(0,u.A)();await this.ioWriter.writeUint8(3),await this.ioWriter.writeUint32(0),await this.ioWriter.writeUint32(0);const i=new Uint8Array(1528);f.y(i),await this.ioWriter.writeBuffer(i),await this.ioWriter.flush(),await this.ioReader.readUint8();const e=await this.ioReader.readUint32();await this.ioReader.skip(4);const s=await this.ioReader.readBuffer(1528);await this.ioWriter.writeUint32(e),await this.ioWriter.writeUint32((0,u.A)()-t),await this.ioWriter.writeBuffer(s),await this.ioWriter.flush(),await this.ioReader.skip(1536),this.readRtmpPacket()}async sendPacket(t){await(0,k.s2)(this.sendAsync),await(0,c.U)(this.ioWriter,this.outChunkSize,t,this.prevWritePacket.get(t.channelId)),this.prevWritePacket.set(t.channelId,t),(0,k.Tl)(this.sendAsync)}async readPacket(){const t=await(0,c.w)(this.ioReader,this.inChunkSize,this.prevReadPacket);return this.prevReadPacket.set(t.channelId,t),t}handleChunkSize(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.inChunkSize=this.bufferReader.readUint32())}handleUserControl(t){t.payload.length>=2&&(this.bufferReader.resetBuffer(t.payload),6===this.bufferReader.readUint16()&&this.sendPong(t,this.bufferReader.readUint32()))}handleSetPeerBW(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.maxSentUnacked=this.bufferReader.readUint32(),g.Yz(`Max sent, unacked = ${this.maxSentUnacked}`,v,205))}handleWindowSizeACK(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.receiveReportSize=this.bufferReader.readUint32(),g.Yz(`Window acknowledgement size = ${this.receiveReportSize}`,v,212),this.receiveReportSize>>=1)}async handleInvoke(t){this.bufferReader.resetBuffer(t.payload);const i=BigInt(t.payload.length),e=await p.$x(this.bufferReader,i),s=await p.$x(this.bufferReader,i);if("_result"===e||"_error"===e){if(this.requestMap.has(s)){const t=await p.$x(this.bufferReader,i),r=await p.$x(this.bufferReader,i);"_result"===e?this.requestMap.get(s).resolve({options:t,info:r}):this.requestMap.get(s).reject({options:t,info:r}),this.requestMap.delete(s)}}else if("onStatus"===e){const t=await p.$x(this.bufferReader,i);let e=await p.$x(this.bufferReader,i);if("error"===e.level)g.z3(`Server error: ${e.description}, ${e.code}`,v,248),this.requestMap.has(s)?(this.requestMap.get(s).reject({options:t,info:e}),this.requestMap.delete(s)):this.onError&&this.onError();else{switch(e.code){case"NetStream.Play.Start":case"NetStream.Seek.Notify":this.state=3;break;case"NetStream.Play.Stop":case"NetStream.Play.UnpublishNotify":this.state=8;break;case"NetStream.Publish.Start":this.state=5}this.requestMap.has(s)&&(this.requestMap.get(s).resolve({options:t,info:e}),this.requestMap.delete(s))}}else"onBWDone"===e&&await this.sendCheckBW()}async handleNotify(t){this.bufferReader.resetBuffer(t.payload),"@setDataFrame"===await p.$x(this.bufferReader,BigInt(t.payload.length))&&(t.payload=t.payload.subarray(Number(this.bufferReader.getPos()))),t.payload.length&&this.onMediaPacket&&await this.onMediaPacket(t,this.streamIdMap.get(t.extra))}async readRtmpPacket(){for(;;)try{const t=await this.readPacket();switch(t.type){case 3:default:break;case 1:this.handleChunkSize(t);break;case 4:this.handleUserControl(t);break;case 6:this.handleSetPeerBW(t);break;case 5:this.handleWindowSizeACK(t);break;case 20:await this.handleInvoke(t);break;case 18:await this.handleNotify(t);break;case 22:case 8:case 9:this.onMediaPacket&&await this.onMediaPacket(t,this.streamIdMap.get(t.extra))}}catch(t){break}}async sendPong(t,i){if(t.payload.length<6)return void g.R8(`Too short ping packet (${t.payload.length})`,v,348);const e=new o.u(2,4,t.timestamp+1,6);this.bufferWriter.resetBuffer(e.payload),this.bufferWriter.writeUint16(7),this.bufferWriter.writeUint32(i),this.sendPacket(e)}async sendWindowAckSize(){const t=new o.u(2,5,0,4);this.bufferWriter.resetBuffer(t.payload),this.bufferWriter.writeUint32(this.maxSentUnacked),await this.sendPacket(t)}async sendBufferTime(t){const i=new o.u(2,4,1,10);this.bufferWriter.resetBuffer(i.payload),this.bufferWriter.writeUint16(3),this.bufferWriter.writeUint32(t),this.bufferWriter.writeUint32(this.options.clientBufferTime||3e3),await this.sendPacket(i)}async sendFCSubscribe(t){const i=new o.u(3,20,0,27+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"FCSubscribe"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendFCPublish(t){const i=new o.u(3,20,0,25+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"FCPublish"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendReleaseStream(t){const i=new o.u(3,20,0,29+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"releaseStream"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendCheckBW(){const t=new o.u(3,20,0,21);this.bufferWriter.resetBuffer(t.payload),p.bD(this.bufferWriter,"_checkbw"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),await this.sendPacket(t)}async request(t,i){const e=new o.u(3,20,0,4096+d.iD);return this.bufferWriter.resetBuffer(e.payload),p.bD(this.bufferWriter,t),p.bD(this.bufferWriter,++this.seq),b.__(i,(t=>{p.bD(this.bufferWriter,t)})),e.payload=e.payload.subarray(0,this.bufferWriter.getPos()),new(h())(((t,i)=>{this.requestMap.set(this.seq,{resolve:t,reject:i}),this.sendPacket(e)}))}async connect(t,i){await this.request("connect",[{app:t,fourCcList:["hvc1","av01","vp09"],flashVer:"LNX 9,0,124,2",tcUrl:i,fpad:0,capabilities:15,audioCodecs:4071,videoCodecs:252,videoFunction:1}]),this.options.isPull&&await this.sendWindowAckSize()}async createStream(){return(await this.request("createStream",[null])).info}async play(t){const i=await this.createStream();if(this.streamIdMap.set(i,t),!this.options.isLive){const i=await h().race([this.request("getStreamLength",[null,t]),new m.A(1)]);y.ai(i)||(this.duration=i.info)}await this.sendFCSubscribe(t),this.request("play",[null,t,-1,-1,!0]),await this.sendBufferTime(i)}async publish(t){await this.sendReleaseStream(t),await this.sendFCPublish(t);const i=await this.createStream();this.streamIdMap.set(i,t),await this.request("publish",[null,t,"live"])}async sendStreamPacket(t,i){let e=0;this.streamIdMap.forEach(((t,s)=>{t===i&&(e=s)})),t.extra=e,await this.sendPacket(t)}async seek(t){const i=new o.u(3,20,0,26);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"seek"),p.bD(this.bufferWriter,0),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async pause(t,i){const e=new o.u(3,20,0,29);this.bufferWriter.resetBuffer(e.payload),p.bD(this.bufferWriter,"pause"),p.bD(this.bufferWriter,0),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),p.bD(this.bufferWriter,i),await this.sendPacket(e)}getDuration(){return this.duration}}},28495:(t,i,e)=>{e.d(i,{iD:()=>s});const s=1024},61272:(t,i,e)=>{e.d(i,{U:()=>o,w:()=>f});var s=e(72231),r=e(64310),n=e(20163);const a="src/avprotocol/rtmp/util.ts";async function h(t,i,e){if(i<64)await t.writeUint8(i|e<<6);else if(i<320)await t.writeUint8(e<<6),await t.writeUint8(i-64);else{await t.writeUint8(1|e<<6);const s=i-64;await t.writeUint8(255&s),await t.writeUint8(s>>>8)}}async function o(t,i,e,s){const r=s&&s.extra===e.extra&&e.timestamp>=s.timestamp;let n=e.timestamp;r&&(n-=s.timestamp),e.tsField=n>16777215?16777215:n;let a=0;r&&(e.type===s.type&&e.payload.length===s.payload.length?(a=2,e.tsField===s.tsField&&(a=3)):a=1),await h(t,e.channelId,a),3!==a&&(await t.writeUint24(e.tsField),2!==a&&(await t.writeUint24(e.payload.length),await t.writeUint8(e.type),0===a&&(await t.writeUint8(e.extra),await t.writeUint8(e.extra>>8),await t.writeUint8(e.extra>>16),await t.writeUint8(e.extra>>24)))),16777215===e.tsField&&await t.writeUint32(n);let o=0;for(;o<e.payload.length;){const s=Math.min(i,e.payload.length-o);await t.writeBuffer(e.payload.subarray(o,o+s)),o+=s,o<e.payload.length&&(await h(t,e.channelId,3),16777215===e.tsField&&await t.writeUint32(n))}await t.flush()}async function f(t,i,e){const h=[],o=await t.readUint8();let f=63&o;f<2&&(f=0===await t.readUint8()?await t.readUint8()+64:64+(await t.readUint8()|await t.readUint8()<<8));const u=o>>>6,l=e.get(f);let d=l?l.payload.length:0,p=l?l.type:0,c=l?l.extra:0,w=0,g=0;if(3===u?w=l.tsField:(w=await t.readUint24(),2!==u&&(d=await t.readUint24(),p=await t.readUint8(),0===u&&(c=await t.readUint8(),c|=await t.readUint8()<<8,c|=await t.readUint8()<<16,c|=await t.readUint8()<<24))),g=16777215===w?await t.readUint32():w,0!==u&&(l?g+=l.timestamp:n.R8(`got invalid message fmt, channel id ${f} can not find prev message with fmt ${u}`,a,171)),d<i)h.push(await t.readBuffer(d));else{let e=d;for(;e;){const s=Math.min(i,e);if(h.push(await t.readBuffer(s)),e-=s,e){const i=63&await t.readUint8();i<2&&await t.skip(i+1),16777215===w&&await t.skip(4)}}}const b=new s.u(f,p,g,(0,r.A)(Uint8Array,h));return b.tsField=w,b.extra=c,b}},89378:(t,i,e)=>{e.d(i,{Dh:()=>r,FQ:()=>d,H3:()=>o,KR:()=>u,N_:()=>n,SF:()=>a,WT:()=>f,f7:()=>g,go:()=>p,i0:()=>l,qs:()=>h,vh:()=>c,zg:()=>w});var s=e(51308);const r=-BigInt(1),n=-1,a=1e6,h=1e3,o=1e9,f=BigInt(2208988800)*BigInt(1e6),u=new s.P({den:a,num:1}),l=new s.P({den:h,num:1}),d=new s.P({den:o,num:1}),p=(new s.P({den:1,num:1}),2147483647),c=BigInt(0x8000000000000000),w=65535,g=4294967295;BigInt(0x10000000000000000)},51308:(t,i,e)=>{e.d(i,{P:()=>u});var s,r,n=e(9655),a=e(33793),h=e.n(a),o=e(67312),f=e(7490);class u{constructor(t){(0,n.A)(this,"num",1),(0,n.A)(this,"den",1),t&&(this.den=t.den,this.num=t.num)}}s=u.prototype,(r=new(h())).set("num",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),r.set("den",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:4,8:0}),(0,f.A)(s,o.Og,!0),(0,f.A)(s,o.dc,4),(0,f.A)(s,o.g7,8),(0,f.A)(s,o.JY,r)},41177:(t,i,e)=>{e.d(i,{$x:()=>h,bD:()=>o});var s=e(68483),r=e(31126),n=e(99868);async function a(t,i){return{key:await t.readString(await t.readUint16()),value:await h(t,i)}}async function h(t,i){let e;switch(await t.readUint8()){case 0:e=await t.readDouble();break;case 1:e=!!await t.readUint8();break;case 2:e=await t.readString(await t.readUint16());break;case 3:for(e={};t.getPos()<i;){const{key:s,value:r}=await a(t,i);if(e[s]=r,9==(16777215&await t.peekUint24())){await t.skip(3);break}}break;case 8:for(e={},await t.skip(4);t.getPos()<i;){const{key:s,value:r}=await a(t,i);if(e[s]=r,9==(16777215&await t.peekUint24())){await t.skip(3);break}}break;case 9:case 5:e=null;break;case 10:e=[];const s=await t.readUint32();for(let r=0;r<s;r++)e.push(await h(t,i));break;case 11:const r=await t.readDouble(),n=await t.readInt16();e=new Date(r+60*n*1e3);break;case 12:e=await t.readString(await t.readUint32())}return e}function o(t,i){s.ai(i)?(t.writeUint8(0),t.writeDouble(i)):s.o(i)?(t.writeUint8(0),t.writeDouble(Number(i))):s.zM(i)?(t.writeUint8(1),t.writeUint8(i?1:0)):s.Yj(i)?i.length>=65536?(t.writeUint8(12),t.writeUint32(i.length),t.writeString(i)):(t.writeUint8(2),t.writeUint16(i.length),t.writeString(i)):s.YO(i)?(t.writeUint8(10),t.writeUint32(i.length),r.__(i,(i=>{o(t,i)}))):s.Ik(i)?(t.writeUint8(3),n.__(i,((i,e)=>{t.writeUint16(e.length),t.writeString(e),o(t,i)})),t.writeUint24(9)):i instanceof Date?(t.writeUint8(11),t.writeDouble(i.getTime()),t.writeInt16(0)):null==i&&t.writeUint8(5)}},5332:(t,i,e)=>{function s(t){crypto.getRandomValues(t)}e.d(i,{y:()=>s})},69663:(t,i,e)=>{e.d(i,{FP:()=>o,Mr:()=>h,iU:()=>l,j2:()=>u,k:()=>a,lb:()=>f});var s=e(16566),r=e(89378),n=e(17583);function a(t,i,e){return t*BigInt(i.num)*BigInt(e.den)/(BigInt(i.den)*BigInt(e.num))}function h(t,i,e){return t*BigInt(s.f[15](i))*BigInt(e.den)/(BigInt(s.f[15](i+4))*BigInt(e.num))}function o(t,i,e){return t*BigInt(i.num)*BigInt(s.f[15](e+4))/(BigInt(i.den)*BigInt(s.f[15](e)))}function f(t){return t.num/t.den}function u(t,i){if(isNaN(19))return{den:0,num:0};if(Math.abs(t)>r.go+3)return{den:0,num:t<0?-1:1};const e=t>1?{den:Math.floor(i/t+.5),num:i}:{den:i,num:Math.floor(t*i+.5)};return l(e),e}function l(t){const i=(0,n.A)(t.num,t.den);i<=1||(t.den/=i,t.num/=i)}},22080:(t,i,e)=>{e.d(i,{Tl:()=>o,an:()=>a,s2:()=>h});var s=e(9655),r=e(55906),n=e.n(r);class a{constructor(){(0,s.A)(this,"list",[])}}async function h(t){return new(n())((i=>{t.list.push(i),1===t.list.length&&i()}))}function o(t){t.list.shift(),t.list.length&&t.list[0]()}},97023:(t,i,e)=>{e(68483),e(31126)},17848:(t,i,e)=>{e.d(i,{A:()=>u});var s=e(9655),r=e(55906),n=e.n(r),a=e(20163),h=e(19372),o=e(56719);const f="src/common/io/IOReader.ts";class u{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"endPointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"fileSize_",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),(0,s.A)(this,"onSize",void 0),(0,s.A)(this,"flags",void 0),(0,s.A)(this,"flushResolve",void 0),this.pos=BigInt(0),this.pointer=0,this.error=0,this.endPointer=0,this.littleEndian=!i,this.flags=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.size=Math.max(t,102400),this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}async readUint8(){this.remainingLength()<1&&await this.flush(1);const t=this.data.getUint8(this.pointer);return this.pointer++,this.pos++,t}async peekUint8(){return this.remainingLength()<1&&await this.flush(1),this.data.getUint8(this.pointer)}async readUint16(){this.remainingLength()<2&&await this.flush(2);const t=this.data.getUint16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}async peekUint16(){return this.remainingLength()<2&&await this.flush(2),this.data.getUint16(this.pointer,this.littleEndian)}async readUint24(){this.remainingLength()<3&&await this.flush(3);const t=await this.readUint16(),i=await this.readUint8();return this.littleEndian?i<<16|t:t<<8|i}async peekUint24(){this.remainingLength()<3&&await this.flush(3);const t=this.pointer,i=this.pos,e=await this.readUint16(),s=await this.readUint8(),r=this.littleEndian?s<<16|e:e<<8|s;return this.pointer=t,this.pos=i,r}async readUint32(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getUint32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekUint32(){return this.remainingLength()<4&&await this.flush(4),this.data.getUint32(this.pointer,this.littleEndian)}async readUint64(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getBigUint64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekUint64(){return this.remainingLength()<8&&await this.flush(8),this.data.getBigUint64(this.pointer,this.littleEndian)}async readInt8(){this.remainingLength()<1&&await this.flush(1);const t=this.data.getInt8(this.pointer);return this.pointer++,this.pos++,t}async peekInt8(){return this.remainingLength()<1&&await this.flush(1),this.data.getInt8(this.pointer)}async readInt16(){this.remainingLength()<2&&await this.flush(2);const t=this.data.getInt16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}async peekInt16(){return this.remainingLength()<2&&await this.flush(2),this.data.getInt16(this.pointer,this.littleEndian)}async readInt24(){const t=await this.readUint24();return 8388608&t?t-16777216:t}async peekInt24(){const t=await this.peekUint24();return 8388608&t?t-16777216:t}async readInt32(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getInt32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekInt32(){return this.remainingLength()<4&&await this.flush(4),this.data.getInt32(this.pointer,this.littleEndian)}async readInt64(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getBigInt64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekInt64(){return this.remainingLength()<8&&await this.flush(8),this.data.getBigInt64(this.pointer,this.littleEndian)}async readFloat(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getFloat32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekFloat(){return this.remainingLength()<4&&await this.flush(4),this.data.getFloat32(this.pointer,this.littleEndian)}async readDouble(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getFloat64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekDouble(){return this.remainingLength()<8&&await this.flush(8),this.data.getFloat64(this.pointer,this.littleEndian)}async readHex(t=1){let i="";for(let e=0;e<t;e++){const t=(await this.readUint8()).toString(16);i+=1===t.length?"0"+t:t}return i}async peekHex(t=1){t>this.size&&(this.error=-1048574,a.h2("peekHex, length too large",f,416)),this.remainingLength()<t&&await this.flush(t);const i=this.pointer,e=this.pos;let s="";for(let i=0;i<t;i++){const t=(await this.readUint8()).toString(16);s+=1===t.length?"0"+t:t}return this.pointer=i,this.pos=e,s}async readBuffer(t,i){if(i||(i=new Uint8Array(t)),this.remainingLength()<t){let e=0;if(this.remainingLength()>0){const s=this.remainingLength();i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}for(;t>0;){await this.flush();const s=Math.min(this.endPointer-this.pointer,t);i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}}else i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),this.pointer+=t,this.pos+=BigInt(t);return i}async peekBuffer(t,i){return t>this.size&&(this.error=-1048574,a.h2("peekBuffer, length too large",f,501)),this.remainingLength()<t&&await this.flush(t),i||(i=new Uint8Array(t)),i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),i}async readToBuffer(t,i){if(this.remainingLength()<t){let e=0;if(this.remainingLength()>0){const s=this.remainingLength();i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}for(;t>0;){try{await this.flush()}catch(t){if(-1048576===this.error&&e)return e;throw t}const s=Math.min(this.endPointer-this.pointer,t);i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}return e}return i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),this.pointer+=t,this.pos+=BigInt(t),t}async readString(t=1){const i=await this.readBuffer(t);return h.decode(i)}async peekString(t=1){const i=await this.peekBuffer(t);return h.decode(i)}async readLine(){let t="";for(;;){let i=!1;for(let e=this.pointer;e<this.endPointer;e++)if(10===this.buffer[e]||13===this.buffer[e]){e!==this.pointer&&(t+=await this.readString(e-this.pointer)),i=!0;break}if(i)break;t+=await this.readString(this.remainingLength()),await this.flush()}let i=await this.peekUint8();return 10!==i&&13!==i||(this.pointer++,13===i&&(i=await this.peekUint8(),10===i&&this.pointer++)),t}async peekLine(){if(this.remainingLength()<this.size)try{await this.flush()}catch(t){if(-1048576!==this.error)throw t}let t="",i=!1;for(let e=this.pointer;e<this.endPointer;e++)if(10===this.buffer[e]||13===this.buffer[e]){t+=await this.peekString(e-this.pointer),i=!0;break}return i||(this.error=-1048574,a.h2("peekLine, out of buffer",f,659)),t}getPointer(){return this.pointer}getPos(){return this.pos}async skip(t){const i=t;for(;this.remainingLength()<t;)t-=this.remainingLength(),this.pointer=this.endPointer,await this.flush();this.remainingLength()>=t&&(this.pointer+=t),this.pos+=BigInt(i)}remainingLength(){return this.endPointer-this.pointer}async flush_(t){return new(n())((async i=>{for(this.flushResolve=i;;){const e=await this.onFlush(t);if(-1048575!==e){this.flushResolve=null,i(e);break}await new o.A(0)}}))}async flush(t=0){if(this.onFlush||(this.error=-1048574,a.h2("IOReader error, flush failed because of no flush callback",f,738)),!(this.size-this.remainingLength()<=0)){if(t=Math.min(t,this.size),this.pointer<this.endPointer?(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer):this.endPointer=0,this.pointer=0,t)for(;this.remainingLength()<t;){const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0)throw this.error=t,new Error(`IOReader error, flush ${-1048576===t?"ended":"failed"}, ret: ${t}`);this.endPointer+=t}else{const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0)throw this.error=t,new Error(`IOReader error, flush ${-1048576===t?"ended":"failed"}, ret: ${t}`);this.endPointer+=t}this.error=0}}async seek(t,i=!1,e=!0){if(!i){const i=Number(t-this.pos);if(i<0&&Math.abs(i)<=this.pointer)return this.pointer+=i,void(this.pos=t);if(i>0&&this.pointer+i<this.endPointer)return this.pointer+=i,void(this.pos=t);if(0===i)return}this.onSeek||(this.error=-1048574,a.h2("IOReader error, seek failed because of no seek callback",f,809)),this.pointer=this.endPointer=0,this.pos=t;const s=await this.onSeek(t);0!==s&&(this.error=s,a.h2("IOReader error, seek failed",f,818)),e&&await this.flush()}getBuffer(){return this.buffer}appendBuffer(t){if(this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else if(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer,this.pointer=0,this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else{const i=Math.min(this.size-this.endPointer,t.length);this.buffer.set(t.subarray(0,i),this.endPointer),this.endPointer+=i,a.R8("IOReader, call appendBuffer but the buffer's size is lagger then the remaining size",f,856)}}reset(){this.pointer=this.endPointer=0,this.pos=BigInt(0),this.error=0}setEndian(t){this.littleEndian=!t}isBigEndian(){return!this.littleEndian}async fileSize(){if(this.fileSize_)return this.fileSize_;if(!this.onSize)return a.R8("IOReader error, fileSize failed because of no onSize callback",f,898),BigInt(0);try{this.fileSize_=await this.onSize()}catch(t){a.R8(`IOReader error, call fileSize failed: ${t}`,f,905),this.fileSize_=BigInt(0)}return this.fileSize_}getBufferSize(){return this.size}async pipe(t,i){if(i)if(this.remainingLength()<i){if(this.remainingLength()>0){const e=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}for(;i>0;){await this.flush();const e=Math.min(this.remainingLength(),i);await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}}else await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i);else{if(this.remainingLength()>0){const i=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}for(;await this.flush_(this.buffer.subarray(0))>0;){const i=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}}}abort(){this.error=-1048572,this.flushResolve&&(this.flushResolve(-1048572),this.flushResolve=null)}}},73416:(t,i,e)=>{e.d(i,{A:()=>n});var s=e(9655),r=e(19372);class n{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),this.pointer=0,this.pos=BigInt(0),this.size=t,this.littleEndian=!i,this.error=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}async writeUint8(t){this.remainingLength()<1&&await this.flush(),this.data.setUint8(this.pointer,t),this.pointer++,this.pos++}async writeUint16(t){this.remainingLength()<2&&await this.flush(),this.data.setUint16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}async writeUint24(t){this.remainingLength()<3&&await this.flush();const i=(16711680&t)>>16,e=(65280&t)>>8,s=255&t;this.littleEndian?(await this.writeUint8(s),await this.writeUint8(e),await this.writeUint8(i)):(await this.writeUint8(i),await this.writeUint8(e),await this.writeUint8(s))}async writeUint32(t){this.remainingLength()<4&&await this.flush(),this.data.setUint32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeUint64(t){this.remainingLength()<8&&await this.flush(),this.data.setBigUint64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}async writeInt8(t){this.remainingLength()<1&&await this.flush(),this.data.setInt8(this.pointer,t),this.pointer++,this.pos++}async writeInt16(t){this.remainingLength()<2&&await this.flush(),this.data.setInt16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}async writeInt24(t){await this.writeUint24(t<0?t+16777216:t)}async writeInt32(t){this.remainingLength()<4&&await this.flush(),this.data.setInt32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeInt64(t){this.remainingLength()<8&&await this.flush(),this.data.setBigInt64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}async writeFloat(t){this.remainingLength()<4&&await this.flush(),this.data.setFloat32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeDouble(t){this.remainingLength()<8&&await this.flush(),this.data.setFloat64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}getPointer(){return this.pointer}getPos(){return this.pos}remainingLength(){return this.size-this.pointer}async writeBuffer(t){if(!t.length)return;let i=t.length;if(this.remainingLength()<i){let e=0;for(;i>0;){await this.flush();const s=Math.min(this.size,i);this.buffer.set(t.subarray(e,e+s),this.pointer),this.pointer+=s,this.pos+=BigInt(s),e+=s,i-=s}}else this.buffer.set(t,this.pointer),this.pointer+=i,this.pos+=BigInt(i)}async writeString(t){const i=r.encode(t);return await this.writeBuffer(i),i.length}async flush(){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const t=await this.onFlush(this.buffer.subarray(0,this.pointer));if(0!==t)throw this.error=t,Error("IOWriter error, flush failed")}this.pointer=0}async flushToPos(t){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const i=await this.onFlush(this.buffer.subarray(0,this.pointer),t);if(0!==i)throw this.error=i,Error("IOWriter error, flush failed")}this.pointer=0}async seek(t){if(!this.onSeek)throw this.error=-1048574,Error("IOWriter error, seek failed because of no seek callback");await this.flush();const i=await this.onSeek(t);if(0!==i)throw this.error=i,Error("IOWriter error, seek failed");this.pos=t}seekInline(t){const i=this.pointer;this.pointer=Math.max(0,Math.min(this.size,t)),this.pos+=BigInt(this.pointer-i)}skip(t){const i=this.pointer;this.pointer=Math.min(this.size,this.pointer+t),this.pos+=BigInt(this.pointer-i)}back(t){const i=this.pointer;this.pointer=Math.max(0,this.pointer-t),this.pos+=BigInt(this.pointer-i)}getBuffer(){return this.buffer.subarray(0,this.pointer)}setEndian(t){this.littleEndian=!t}reset(){this.pointer=0,this.pos=BigInt(0),this.error=0}getBufferSize(){return this.size}}},81895:(t,i,e)=>{e.d(i,{A:()=>n});var s=e(9655),r=e(19372);class n{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),this.pointer=0,this.pos=BigInt(0),this.size=t,this.littleEndian=!i,this.error=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}writeUint8(t){this.remainingLength()<1&&this.flush(),this.data.setUint8(this.pointer,t),this.pointer++,this.pos++}writeUint16(t){this.remainingLength()<2&&this.flush(),this.data.setUint16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeUint24(t){this.remainingLength()<3&&this.flush();const i=(16711680&t)>>16,e=(65280&t)>>8,s=255&t;this.littleEndian?(this.writeUint8(s),this.writeUint8(e),this.writeUint8(i)):(this.writeUint8(i),this.writeUint8(e),this.writeUint8(s))}writeUint32(t){this.remainingLength()<4&&this.flush(),this.data.setUint32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeUint64(t){this.remainingLength()<8&&this.flush(),this.data.setBigUint64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeInt8(t){this.remainingLength()<1&&this.flush(),this.data.setInt8(this.pointer,t),this.pointer++,this.pos++}writeInt16(t){this.remainingLength()<2&&this.flush(),this.data.setInt16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeInt24(t){this.writeUint24(t<0?t+16777216:t)}writeInt32(t){this.remainingLength()<4&&this.flush(),this.data.setInt32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeInt64(t){this.remainingLength()<8&&this.flush(),this.data.setBigInt64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeFloat(t){this.remainingLength()<4&&this.flush(),this.data.setFloat32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeDouble(t){this.remainingLength()<8&&this.flush(),this.data.setFloat64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}getPointer(){return this.pointer}getPos(){return this.pos}remainingLength(){return this.size-this.pointer}writeBuffer(t){if(!t.length)return;let i=t.length;if(this.remainingLength()<i){let e=0;for(;i>0;){this.flush();const s=Math.min(this.size,i);this.buffer.set(t.subarray(e,e+s),this.pointer),this.pointer+=s,this.pos+=BigInt(s),e+=s,i-=s}}else this.buffer.set(t,this.pointer),this.pointer+=i,this.pos+=BigInt(i)}writeString(t){const i=r.encode(t);return this.writeBuffer(i),i.length}flush(){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const t=this.onFlush(this.buffer.subarray(0,this.pointer));if(0!==t)throw this.error=t,Error("IOWriter error, flush failed")}this.pointer=0}flushToPos(t){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const i=this.onFlush(this.buffer.subarray(0,this.pointer),t);if(0!==i)throw this.error=i,Error("IOWriter error, flush failed")}this.pointer=0}seek(t){if(!this.onSeek)throw this.error=-1048574,Error("IOWriter error, seek failed because of no seek callback");this.flush();const i=this.onSeek(t);if(0!==i)throw this.error=i,Error("IOWriter error, seek failed");this.pos=t}seekInline(t){const i=this.pointer;this.pointer=Math.max(0,Math.min(this.size,t)),this.pos+=BigInt(this.pointer-i)}skip(t){const i=this.pointer;this.pointer=Math.min(this.size,this.pointer+t),this.pos+=BigInt(this.pointer-i)}back(t){const i=this.pointer;this.pointer=Math.max(0,this.pointer-t),this.pos+=BigInt(this.pointer-i)}getBuffer(){return this.buffer.subarray(0,this.pointer)}setEndian(t){this.littleEndian=!t}reset(){this.pointer=0,this.pos=BigInt(0),this.error=0}getBufferSize(){return this.size}}},17583:(t,i,e)=>{function s(t,i){for(;0!==i;)[t,i]=[i,t%i];return t}e.d(i,{A:()=>s})},10446:(t,i,e)=>{function s(t){const i=t,e=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],s=/:\/\/([^\/@]*@?)\[(\S+)\]/;let r="";s.test(t)&&(t=t.replace(s,((t,i,e)=>(r=e,`://${i||""}a.b`))));const n={},a=/^(?:(?![^:@\/]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*)(?::([^:@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(t);let h=14;for(;h--;){var o;n[e[h]]=null!==(o=a[h])&&void 0!==o?o:""}return r&&(n.host=r,n.source=i,n.authority=r+(n.port?":"+n.port:"")),{protocol:n.protocol,file:n.file,host:n.host,port:n.port,user:n.user,password:n.password,origin:`${n.protocol}://${n.authority}`,pathname:n.path,search:`?${n.query}`,hash:n.anchor?`#${n.anchor}`:""}}e.d(i,{ll:()=>l,qg:()=>s}),e(38035),e(68483),e(97023),e(31126),e(99868);const r=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a=/^(?=([^\/?#]*))\1([^]*)$/,h=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/;function o(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}function f(t){const i=h.exec(t);return i?{scheme:i[1]||"",netLoc:i[2]||"",path:i[3]||"",params:i[4]||"",query:i[5]||"",fragment:i[6]||""}:null}function u(t){for(t=t.split("").reverse().join("").replace(r,"");t.length!==(t=t.replace(n,"")).length;);return t.split("").reverse().join("")}function l(t,i,e){if(e=e||{},t=t.trim(),!(i=i.trim())){if(!e.alwaysNormalize)return t;let i=f(t);if(!i)throw new Error("Error trying to parse base URL.");return i.path=u(i.path),o(i)}let s=f(i);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return e.alwaysNormalize?(s.path=u(s.path),o(s)):i;let r=f(t);if(!r)throw new Error("Error trying to parse base URL.");if(!r.netLoc&&r.path&&"/"!==r.path[0]){let t=a.exec(r.path);r.netLoc=t[1],r.path=t[2]}r.netLoc&&!r.path&&(r.path="/");const n={scheme:r.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(n.netLoc=r.netLoc,"/"!==s.path[0]))if(s.path){let t=r.path,i=t.substring(0,t.lastIndexOf("/")+1)+s.path;n.path=u(i)}else n.path=r.path,s.params||(n.params=r.params,s.query||(n.query=r.query));return null===n.path&&(n.path=e.alwaysNormalize?u(s.path):s.path),o(n)}},6431:(t,i,e)=>{var s=e(54446),r=s.JSON||(s.JSON={stringify:JSON.stringify});t.exports=function(t){return r.stringify.apply(r,arguments)}},38035:(t,i,e)=>{t.exports=e(6431)}}]);
1
+ (self.webpackChunklibmedia=self.webpackChunklibmedia||[]).push([[690],{5114:(t,i,e)=>{e.d(i,{A:()=>r});var s=e(9655);class r{constructor(){(0,s.A)(this,"signature",void 0),(0,s.A)(this,"version",void 0),(0,s.A)(this,"flags",void 0),(0,s.A)(this,"dataOffset",void 0),(0,s.A)(this,"hasVideo",void 0),(0,s.A)(this,"hasAudio",void 0),this.signature="FLV",this.version=1,this.flags=0,this.dataOffset=9,this.hasAudio=!1,this.hasVideo=!1}async read(t){this.signature=await t.readString(3),this.version=await t.readUint8(),this.flags=await t.readUint8(),this.dataOffset=await t.readUint32(),this.hasAudio=!!(4&this.flags),this.hasVideo=!!(1&this.flags)}write(t){this.flags=0,this.hasAudio&&(this.flags|=4),this.hasVideo&&(this.flags|=1),t.writeString(this.signature),t.writeUint8(this.version),t.writeUint8(this.flags),t.writeUint32(this.dataOffset)}}},63278:(t,i,e)=>{e.d(i,{A:()=>u});var s=e(9655),r=e(81895),n=e(64310),a=e(20163),h=e(68944),o=e(20086),f=e(41177);class u{constructor(){(0,s.A)(this,"onMetaData",void 0),this.onMetaData={canSeekToEnd:!1}}async read(t,i){const e=t.getPos(),s=e+BigInt(Math.floor(i)),r=await(0,f.$x)(t,s),n=await(0,f.$x)(t,s);this[r]=n,s>t.getPos()&&await t.skip(Number(BigInt.asIntN(32,s-t.getPos())));const h=Number(t.getPos()-e),u=await t.readUint32();return h+11!==u?(a.R8(`script size not match, size: ${h+11}, previousTagSize: ${u}`,"src/avformat/formats/flv/FlvScriptTag.ts",63),o.LR):0}computeSize(){const t=[],i=new r.A;return i.onFlush=i=>(t.push(i.slice()),0),(0,f.bD)(i,"onMetaData"),(0,f.bD)(i,this.onMetaData),i.flush(),(0,n.A)(Uint8Array,t).length}write(t){if(this.onMetaData){const i=[],e=new r.A;e.onFlush=t=>(i.push(t.slice()),0),(0,f.bD)(e,"onMetaData"),(0,f.bD)(e,this.onMetaData),e.flush();const s=(0,n.A)(Uint8Array,i);h.M5(t,18,BigInt(0),void 0,s)}}dts2Position(t){if(this.canSeek()){let i=-1;const e=this.onMetaData.keyframes.times,s=this.onMetaData.keyframes.filepositions;let r;for(r=0;r<e.length;r++){if(e[r]===t){i=r;break}if(e[r]>t){i=Math.max(r-1,0);break}}return r&&r===e.length&&(i=e.length-1),{pos:s[i],dts:e[i]}}return{pos:-1,dts:-1}}position2DTS(t){if(this.canSeek()){let e=-1;const s=this.onMetaData.keyframes.times,r=this.onMetaData.keyframes.filepositions;let n=0;for(n=0;n<r.length;n++)if(r[n]>t){e=n;break}var i;return n===r.length?null!==(i=this.onMetaData.duration)&&void 0!==i?i:s[s.length-1]:s[e]}return-1}canSeek(){return!!(this.onMetaData.keyframes&&this.onMetaData.keyframes.filepositions&&this.onMetaData.keyframes.filepositions.length)}}},71619:(t,i,e)=>{e.d(i,{FJ:()=>s,U5:()=>r});const s={10:86018,2:86017,11:86051,1:69645,4:86049,5:86049,6:86049,7:65543,8:65542},r={7:27,12:173,9:12,2:4,3:86,4:92,5:106,6:131}},68944:(t,i,e)=>{e.d(i,{M5:()=>n}),e(71619),e(69663),e(89378),e(92324);var s=e(68483);function r(t,i,e){const s=t.getPos(),r=t.getPointer(),n=s-BigInt(Math.floor(r));i<s&&i>=n?(t.seekInline(r+Number(i-s)),t.writeUint24(e),t.seekInline(r)):(t.seek(i),t.writeUint24(e),t.seek(s))}function n(t,i,e,n,a,h){t.flush(),t.writeUint8(i);const o=t.getPos();t.writeUint24(0),t.writeUint24(Number(e&BigInt(16777215))),t.writeUint8(Number(e>>BigInt(24)&BigInt(255))),t.writeUint24(0);const f=t.getPos();n&&n(t),s.Pc(a)?(a(t),r(t,o,Number(t.getPos()-f))):a&&(r(t,o,a.length+Number(t.getPos()-f)),t.writeBuffer(a));const u=Number(t.getPos()-o)+1;h&&h(u),t.writeUint32(u)}},92324:(t,i,e)=>{e.d(i,{A:()=>n});var s=e(20163);const r="src/avformat/function/mktag.ts";function n(t){4!==t.length&&s.R8(`tag length is not 4, tag: ${t}`,r,30);let i=0;for(let e=0;e<4;e++)i=i<<8|t.charCodeAt(e);return i}},27690:(t,i,e)=>{e.r(i),e.d(i,{default:()=>b});var s=e(9655),r=e(33096),n=e(65160),a=e(90946),h=e(95779),o=e(17848),f=e(73416),u=e(10446),l=e(81895),d=e(5114),p=e(63278),c=e(48162),w=e(41177),g=e(21472);class b extends r.A{constructor(...t){super(...t),(0,s.A)(this,"info",void 0),(0,s.A)(this,"socket",void 0),(0,s.A)(this,"session",void 0),(0,s.A)(this,"ioReader",void 0),(0,s.A)(this,"ioWriter",void 0),(0,s.A)(this,"flvWriter",void 0),(0,s.A)(this,"flvHeader",void 0),(0,s.A)(this,"packetQueue",void 0),(0,s.A)(this,"flvHeaderWrote",void 0),(0,s.A)(this,"hasMetadata",void 0),(0,s.A)(this,"bufferReader",void 0)}writeFlvData(t){this.flvWriter.writeUint8(t.type),this.flvWriter.writeUint24(t.payload.length),this.flvWriter.writeUint24(t.timestamp),this.flvWriter.writeUint8(t.timestamp>>24),this.flvWriter.writeUint24(0),this.flvWriter.writeBuffer(t.payload),this.flvWriter.writeUint32(t.payload.length+11),this.flvWriter.flush()}async handleRtmpPacket(t){if(this.flvHeaderWrote)this.writeFlvData(t);else{if(this.packetQueue.push(t),8===t.type)this.flvHeader.hasAudio=!0;else if(9===t.type)this.flvHeader.hasVideo=!0;else if(18===t.type&&(this.bufferReader?this.bufferReader.resetBuffer(t.payload):this.bufferReader=new c.A(t.payload),"onMetaData"===await w.$x(this.bufferReader,BigInt(t.payload.length)))){this.hasMetadata=!0;const i=await w.$x(this.bufferReader,BigInt(t.payload.length));this.flvHeader.hasAudio=(0,g.A)(i.audiocodecid),this.flvHeader.hasVideo=(0,g.A)(i.videocodecid)}if(this.packetQueue.length>10||this.hasMetadata){if(this.flvHeader.write(this.flvWriter),this.flvWriter.writeUint32(0),!this.hasMetadata&&this.session.getDuration()){const t=new p.A;t.onMetaData={duration:this.session.getDuration()},t.write(this.flvWriter)}this.packetQueue.forEach((t=>{this.writeFlvData(t)})),this.packetQueue.length=0,this.flvHeaderWrote=!0}}}async send(t){return this.socket?(await this.socket.send(t),0):-1048574}async open(t){this.info=t,this.status=1,3===t.subProtocol?(this.socket=new a.A(this.options),await this.socket.open({url:t.url,webtransportOptions:t.webtransportOptions})):(this.socket=new n.A(this.options),await this.socket.open({url:t.url})),this.ioReader=new o.A,this.ioReader.onFlush=async t=>this.socket.read(t),this.ioReader.onSeek=async t=>this.socket.seek(t),this.ioReader.onSize=async()=>this.socket.size(),this.ioWriter=new f.A,this.ioWriter.onFlush=async t=>this.socket.write(t),this.ioWriter.onSeek=async t=>this.socket.seek(t),this.flvWriter=new l.A,this.flvWriter.onFlush=t=>(this.readQueue.push(t.slice()),this.consume&&this.consume(),0),this.flvHeader=new d.A,this.packetQueue=[],this.flvHeaderWrote=!1,this.hasMetadata=!1,this.session=new h.A(this.ioReader,this.ioWriter,{isLive:this.options.isLive,isPull:!0}),this.session.onMediaPacket=async(t,i)=>this.handleRtmpPacket(t),this.session.onError=()=>{this.status=3,this.consume&&this.consume()},await this.session.handshake();const i=u.qg(this.info.uri),e=i.pathname.split("/");await this.session.connect(e[1],`rtmp://${i.host}${i.port?":"+i.port:""}/${e[1]}`);const s=e.slice(2);return this.session.play((s.length>1?s.join("/"):s[0])||""),0}async seek(t){return await this.session.seek(Number(t)),0}async size(){return BigInt(0)}async stop(){this.socket&&(await this.socket.stop(),this.socket=null),this.status=4}}},72231:(t,i,e)=>{e.d(i,{u:()=>r});var s=e(9655);class r{constructor(t,i,e,r){(0,s.A)(this,"channelId",void 0),(0,s.A)(this,"type",void 0),(0,s.A)(this,"timestamp",void 0),(0,s.A)(this,"tsField",0),(0,s.A)(this,"extra",0),(0,s.A)(this,"payload",void 0),this.channelId=t,this.type=i,this.timestamp=e,this.payload=r instanceof Uint8Array?r:new Uint8Array(r)}}},95779:(t,i,e)=>{e.d(i,{A:()=>U});var s=e(9655),r=e(33793),n=e.n(r),a=e(55906),h=e.n(a),o=e(72231),f=e(5332),u=e(80155),l=e(87590),d=e(28495),p=e(41177),c=e(61272),w=e(48162),g=e(20163),b=e(31126),y=e(68483),m=e(56719),k=e(22080);const v="src/avprotocol/rtmp/RtmpSession.ts";class U{constructor(t,i,e){(0,s.A)(this,"ioReader",void 0),(0,s.A)(this,"ioWriter",void 0),(0,s.A)(this,"prevReadPacket",void 0),(0,s.A)(this,"prevWritePacket",void 0),(0,s.A)(this,"inChunkSize",void 0),(0,s.A)(this,"outChunkSize",void 0),(0,s.A)(this,"seq",void 0),(0,s.A)(this,"bufferWriter",void 0),(0,s.A)(this,"bufferReader",void 0),(0,s.A)(this,"requestMap",void 0),(0,s.A)(this,"state",void 0),(0,s.A)(this,"maxSentUnacked",void 0),(0,s.A)(this,"receiveReportSize",void 0),(0,s.A)(this,"duration",void 0),(0,s.A)(this,"options",void 0),(0,s.A)(this,"streamIdMap",void 0),(0,s.A)(this,"sendAsync",void 0),(0,s.A)(this,"onMediaPacket",void 0),(0,s.A)(this,"onError",void 0),this.ioReader=t,this.ioWriter=i,this.options=e,this.prevReadPacket=new(n()),this.prevWritePacket=new(n()),this.requestMap=new(n()),this.streamIdMap=new(n()),this.inChunkSize=128,this.outChunkSize=128,this.seq=0,this.maxSentUnacked=25e5,this.receiveReportSize=1048576,this.sendAsync=new k.an,this.bufferWriter=new l.A(new Uint8Array(1)),this.bufferReader=new w.A(new Uint8Array(1)),this.state=0}async handshake(){const t=(0,u.A)();await this.ioWriter.writeUint8(3),await this.ioWriter.writeUint32(0),await this.ioWriter.writeUint32(0);const i=new Uint8Array(1528);f.y(i),await this.ioWriter.writeBuffer(i),await this.ioWriter.flush(),await this.ioReader.readUint8();const e=await this.ioReader.readUint32();await this.ioReader.skip(4);const s=await this.ioReader.readBuffer(1528);await this.ioWriter.writeUint32(e),await this.ioWriter.writeUint32((0,u.A)()-t),await this.ioWriter.writeBuffer(s),await this.ioWriter.flush(),await this.ioReader.skip(1536),this.readRtmpPacket()}async sendPacket(t){await(0,k.s2)(this.sendAsync),await(0,c.U)(this.ioWriter,this.outChunkSize,t,this.prevWritePacket.get(t.channelId)),this.prevWritePacket.set(t.channelId,t),(0,k.Tl)(this.sendAsync)}async readPacket(){const t=await(0,c.w)(this.ioReader,this.inChunkSize,this.prevReadPacket);return this.prevReadPacket.set(t.channelId,t),t}handleChunkSize(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.inChunkSize=this.bufferReader.readUint32())}handleUserControl(t){t.payload.length>=2&&(this.bufferReader.resetBuffer(t.payload),6===this.bufferReader.readUint16()&&this.sendPong(t,this.bufferReader.readUint32()))}handleSetPeerBW(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.maxSentUnacked=this.bufferReader.readUint32(),g.Yz(`Max sent, unacked = ${this.maxSentUnacked}`,v,205))}handleWindowSizeACK(t){t.payload.length>=4&&(this.bufferReader.resetBuffer(t.payload),this.receiveReportSize=this.bufferReader.readUint32(),g.Yz(`Window acknowledgement size = ${this.receiveReportSize}`,v,212),this.receiveReportSize>>=1)}async handleInvoke(t){this.bufferReader.resetBuffer(t.payload);const i=BigInt(t.payload.length),e=await p.$x(this.bufferReader,i),s=await p.$x(this.bufferReader,i);if("_result"===e||"_error"===e){if(this.requestMap.has(s)){const t=await p.$x(this.bufferReader,i),r=await p.$x(this.bufferReader,i);"_result"===e?this.requestMap.get(s).resolve({options:t,info:r}):this.requestMap.get(s).reject({options:t,info:r}),this.requestMap.delete(s)}}else if("onStatus"===e){const t=await p.$x(this.bufferReader,i);let e=await p.$x(this.bufferReader,i);if("error"===e.level)g.z3(`Server error: ${e.description}, ${e.code}`,v,248),this.requestMap.has(s)?(this.requestMap.get(s).reject({options:t,info:e}),this.requestMap.delete(s)):this.onError&&this.onError();else{switch(e.code){case"NetStream.Play.Start":case"NetStream.Seek.Notify":this.state=3;break;case"NetStream.Play.Stop":case"NetStream.Play.UnpublishNotify":this.state=8;break;case"NetStream.Publish.Start":this.state=5}this.requestMap.has(s)&&(this.requestMap.get(s).resolve({options:t,info:e}),this.requestMap.delete(s))}}else"onBWDone"===e&&await this.sendCheckBW()}async handleNotify(t){this.bufferReader.resetBuffer(t.payload),"@setDataFrame"===await p.$x(this.bufferReader,BigInt(t.payload.length))&&(t.payload=t.payload.subarray(Number(this.bufferReader.getPos()))),t.payload.length&&this.onMediaPacket&&await this.onMediaPacket(t,this.streamIdMap.get(t.extra))}async readRtmpPacket(){for(;;)try{const t=await this.readPacket();switch(t.type){case 3:default:break;case 1:this.handleChunkSize(t);break;case 4:this.handleUserControl(t);break;case 6:this.handleSetPeerBW(t);break;case 5:this.handleWindowSizeACK(t);break;case 20:await this.handleInvoke(t);break;case 18:await this.handleNotify(t);break;case 22:case 8:case 9:this.onMediaPacket&&await this.onMediaPacket(t,this.streamIdMap.get(t.extra))}}catch(t){break}}async sendPong(t,i){if(t.payload.length<6)return void g.R8(`Too short ping packet (${t.payload.length})`,v,348);const e=new o.u(2,4,t.timestamp+1,6);this.bufferWriter.resetBuffer(e.payload),this.bufferWriter.writeUint16(7),this.bufferWriter.writeUint32(i),this.sendPacket(e)}async sendWindowAckSize(){const t=new o.u(2,5,0,4);this.bufferWriter.resetBuffer(t.payload),this.bufferWriter.writeUint32(this.maxSentUnacked),await this.sendPacket(t)}async sendBufferTime(t){const i=new o.u(2,4,1,10);this.bufferWriter.resetBuffer(i.payload),this.bufferWriter.writeUint16(3),this.bufferWriter.writeUint32(t),this.bufferWriter.writeUint32(this.options.clientBufferTime||3e3),await this.sendPacket(i)}async sendFCSubscribe(t){const i=new o.u(3,20,0,27+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"FCSubscribe"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendFCPublish(t){const i=new o.u(3,20,0,25+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"FCPublish"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendReleaseStream(t){const i=new o.u(3,20,0,29+t.length);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"releaseStream"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async sendCheckBW(){const t=new o.u(3,20,0,21);this.bufferWriter.resetBuffer(t.payload),p.bD(this.bufferWriter,"_checkbw"),p.bD(this.bufferWriter,++this.seq),p.bD(this.bufferWriter,null),await this.sendPacket(t)}async request(t,i){const e=new o.u(3,20,0,4096+d.iD);return this.bufferWriter.resetBuffer(e.payload),p.bD(this.bufferWriter,t),p.bD(this.bufferWriter,++this.seq),b.__(i,(t=>{p.bD(this.bufferWriter,t)})),e.payload=e.payload.subarray(0,this.bufferWriter.getPos()),new(h())(((t,i)=>{this.requestMap.set(this.seq,{resolve:t,reject:i}),this.sendPacket(e)}))}async connect(t,i){await this.request("connect",[{app:t,fourCcList:["hvc1","av01","vp09"],flashVer:"LNX 9,0,124,2",tcUrl:i,fpad:0,capabilities:15,audioCodecs:4071,videoCodecs:252,videoFunction:1}]),this.options.isPull&&await this.sendWindowAckSize()}async createStream(){return(await this.request("createStream",[null])).info}async play(t){const i=await this.createStream();if(this.streamIdMap.set(i,t),!this.options.isLive){const i=await h().race([this.request("getStreamLength",[null,t]),new m.A(1)]);y.ai(i)||(this.duration=i.info)}await this.sendFCSubscribe(t),this.request("play",[null,t,-1,-1,!0]),await this.sendBufferTime(i)}async publish(t){await this.sendReleaseStream(t),await this.sendFCPublish(t);const i=await this.createStream();this.streamIdMap.set(i,t),await this.request("publish",[null,t,"live"])}async sendStreamPacket(t,i){let e=0;this.streamIdMap.forEach(((t,s)=>{t===i&&(e=s)})),t.extra=e,await this.sendPacket(t)}async seek(t){const i=new o.u(3,20,0,26);this.bufferWriter.resetBuffer(i.payload),p.bD(this.bufferWriter,"seek"),p.bD(this.bufferWriter,0),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),await this.sendPacket(i)}async pause(t,i){const e=new o.u(3,20,0,29);this.bufferWriter.resetBuffer(e.payload),p.bD(this.bufferWriter,"pause"),p.bD(this.bufferWriter,0),p.bD(this.bufferWriter,null),p.bD(this.bufferWriter,t),p.bD(this.bufferWriter,i),await this.sendPacket(e)}getDuration(){return this.duration}}},28495:(t,i,e)=>{e.d(i,{iD:()=>s});const s=1024},61272:(t,i,e)=>{e.d(i,{U:()=>o,w:()=>f});var s=e(72231),r=e(64310),n=e(20163);const a="src/avprotocol/rtmp/util.ts";async function h(t,i,e){if(i<64)await t.writeUint8(i|e<<6);else if(i<320)await t.writeUint8(e<<6),await t.writeUint8(i-64);else{await t.writeUint8(1|e<<6);const s=i-64;await t.writeUint8(255&s),await t.writeUint8(s>>>8)}}async function o(t,i,e,s){const r=s&&s.extra===e.extra&&e.timestamp>=s.timestamp;let n=e.timestamp;r&&(n-=s.timestamp),e.tsField=n>16777215?16777215:n;let a=0;r&&(e.type===s.type&&e.payload.length===s.payload.length?(a=2,e.tsField===s.tsField&&(a=3)):a=1),await h(t,e.channelId,a),3!==a&&(await t.writeUint24(e.tsField),2!==a&&(await t.writeUint24(e.payload.length),await t.writeUint8(e.type),0===a&&(await t.writeUint8(e.extra),await t.writeUint8(e.extra>>8),await t.writeUint8(e.extra>>16),await t.writeUint8(e.extra>>24)))),16777215===e.tsField&&await t.writeUint32(n);let o=0;for(;o<e.payload.length;){const s=Math.min(i,e.payload.length-o);await t.writeBuffer(e.payload.subarray(o,o+s)),o+=s,o<e.payload.length&&(await h(t,e.channelId,3),16777215===e.tsField&&await t.writeUint32(n))}await t.flush()}async function f(t,i,e){const h=[],o=await t.readUint8();let f=63&o;f<2&&(f=0===await t.readUint8()?await t.readUint8()+64:64+(await t.readUint8()|await t.readUint8()<<8));const u=o>>>6,l=e.get(f);let d=l?l.payload.length:0,p=l?l.type:0,c=l?l.extra:0,w=0,g=0;if(3===u?w=l.tsField:(w=await t.readUint24(),2!==u&&(d=await t.readUint24(),p=await t.readUint8(),0===u&&(c=await t.readUint8(),c|=await t.readUint8()<<8,c|=await t.readUint8()<<16,c|=await t.readUint8()<<24))),g=16777215===w?await t.readUint32():w,0!==u&&(l?g+=l.timestamp:n.R8(`got invalid message fmt, channel id ${f} can not find prev message with fmt ${u}`,a,171)),d<i)h.push(await t.readBuffer(d));else{let e=d;for(;e;){const s=Math.min(i,e);if(h.push(await t.readBuffer(s)),e-=s,e){const i=63&await t.readUint8();i<2&&await t.skip(i+1),16777215===w&&await t.skip(4)}}}const b=new s.u(f,p,g,(0,r.A)(Uint8Array,h));return b.tsField=w,b.extra=c,b}},89378:(t,i,e)=>{e.d(i,{Dh:()=>r,FQ:()=>d,H3:()=>o,KR:()=>u,N_:()=>n,SF:()=>a,WT:()=>f,f7:()=>g,go:()=>p,i0:()=>l,pu:()=>b,qs:()=>h,vh:()=>c,zg:()=>w});var s=e(51308);const r=-BigInt(1),n=-1,a=1e6,h=1e3,o=1e9,f=BigInt(2208988800)*BigInt(1e6),u=new s.P({den:a,num:1}),l=new s.P({den:h,num:1}),d=new s.P({den:o,num:1}),p=(new s.P({den:1,num:1}),2147483647),c=BigInt(0x8000000000000000),w=65535,g=4294967295,b=(BigInt(0x10000000000000000),8)},51308:(t,i,e)=>{e.d(i,{P:()=>u});var s,r,n=e(9655),a=e(33793),h=e.n(a),o=e(67312),f=e(7490);class u{constructor(t){(0,n.A)(this,"num",1),(0,n.A)(this,"den",1),t&&(this.den=t.den,this.num=t.num)}}s=u.prototype,(r=new(h())).set("num",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0}),r.set("den",{0:15,1:0,2:0,3:0,4:0,5:0,6:0,7:4,8:0}),(0,f.A)(s,o.Og,!0),(0,f.A)(s,o.dc,4),(0,f.A)(s,o.g7,8),(0,f.A)(s,o.JY,r)},41177:(t,i,e)=>{e.d(i,{$x:()=>h,bD:()=>o});var s=e(68483),r=e(31126),n=e(99868);async function a(t,i){return{key:await t.readString(await t.readUint16()),value:await h(t,i)}}async function h(t,i){let e;switch(await t.readUint8()){case 0:e=await t.readDouble();break;case 1:e=!!await t.readUint8();break;case 2:e=await t.readString(await t.readUint16());break;case 3:for(e={};t.getPos()<i;){const{key:s,value:r}=await a(t,i);if(e[s]=r,9==(16777215&await t.peekUint24())){await t.skip(3);break}}break;case 8:for(e={},await t.skip(4);t.getPos()<i;){const{key:s,value:r}=await a(t,i);if(e[s]=r,9==(16777215&await t.peekUint24())){await t.skip(3);break}}break;case 9:case 5:e=null;break;case 10:e=[];const s=await t.readUint32();for(let r=0;r<s;r++)e.push(await h(t,i));break;case 11:const r=await t.readDouble(),n=await t.readInt16();e=new Date(r+60*n*1e3);break;case 12:e=await t.readString(await t.readUint32())}return e}function o(t,i){s.ai(i)?(t.writeUint8(0),t.writeDouble(i)):s.o(i)?(t.writeUint8(0),t.writeDouble(Number(i))):s.zM(i)?(t.writeUint8(1),t.writeUint8(i?1:0)):s.Yj(i)?i.length>=65536?(t.writeUint8(12),t.writeUint32(i.length),t.writeString(i)):(t.writeUint8(2),t.writeUint16(i.length),t.writeString(i)):s.YO(i)?(t.writeUint8(10),t.writeUint32(i.length),r.__(i,(i=>{o(t,i)}))):s.Ik(i)?(t.writeUint8(3),n.__(i,((i,e)=>{t.writeUint16(e.length),t.writeString(e),o(t,i)})),t.writeUint24(9)):i instanceof Date?(t.writeUint8(11),t.writeDouble(i.getTime()),t.writeInt16(0)):null==i&&t.writeUint8(5)}},5332:(t,i,e)=>{function s(t){crypto.getRandomValues(t)}e.d(i,{y:()=>s})},69663:(t,i,e)=>{e.d(i,{FP:()=>o,Mr:()=>h,iU:()=>l,j2:()=>u,k:()=>a,lb:()=>f});var s=e(16566),r=e(89378),n=e(17583);function a(t,i,e){return t*BigInt(i.num)*BigInt(e.den)/(BigInt(i.den)*BigInt(e.num))}function h(t,i,e){return t*BigInt(s.f[15](i))*BigInt(e.den)/(BigInt(s.f[15](i+4))*BigInt(e.num))}function o(t,i,e){return t*BigInt(i.num)*BigInt(s.f[15](e+4))/(BigInt(i.den)*BigInt(s.f[15](e)))}function f(t){return t.num/t.den}function u(t,i){if(isNaN(19))return{den:0,num:0};if(Math.abs(t)>r.go+3)return{den:0,num:t<0?-1:1};const e=t>1?{den:Math.floor(i/t+.5),num:i}:{den:i,num:Math.floor(t*i+.5)};return l(e),e}function l(t){const i=(0,n.A)(t.num,t.den);i<=1||(t.den/=i,t.num/=i)}},22080:(t,i,e)=>{e.d(i,{Tl:()=>o,an:()=>a,s2:()=>h});var s=e(9655),r=e(55906),n=e.n(r);class a{constructor(){(0,s.A)(this,"list",[])}}async function h(t){return new(n())((i=>{t.list.push(i),1===t.list.length&&i()}))}function o(t){t.list.shift(),t.list.length&&t.list[0]()}},97023:(t,i,e)=>{e(68483),e(31126)},17848:(t,i,e)=>{e.d(i,{A:()=>u});var s=e(9655),r=e(55906),n=e.n(r),a=e(20163),h=e(19372),o=e(56719);const f="src/common/io/IOReader.ts";class u{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"endPointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"fileSize_",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),(0,s.A)(this,"onSize",void 0),(0,s.A)(this,"flags",void 0),(0,s.A)(this,"flushResolve",void 0),this.pos=BigInt(0),this.pointer=0,this.error=0,this.endPointer=0,this.littleEndian=!i,this.flags=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.size=Math.max(t,102400),this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}async readUint8(){this.remainingLength()<1&&await this.flush(1);const t=this.data.getUint8(this.pointer);return this.pointer++,this.pos++,t}async peekUint8(){return this.remainingLength()<1&&await this.flush(1),this.data.getUint8(this.pointer)}async readUint16(){this.remainingLength()<2&&await this.flush(2);const t=this.data.getUint16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}async peekUint16(){return this.remainingLength()<2&&await this.flush(2),this.data.getUint16(this.pointer,this.littleEndian)}async readUint24(){this.remainingLength()<3&&await this.flush(3);const t=await this.readUint16(),i=await this.readUint8();return this.littleEndian?i<<16|t:t<<8|i}async peekUint24(){this.remainingLength()<3&&await this.flush(3);const t=this.pointer,i=this.pos,e=await this.readUint16(),s=await this.readUint8(),r=this.littleEndian?s<<16|e:e<<8|s;return this.pointer=t,this.pos=i,r}async readUint32(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getUint32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekUint32(){return this.remainingLength()<4&&await this.flush(4),this.data.getUint32(this.pointer,this.littleEndian)}async readUint64(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getBigUint64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekUint64(){return this.remainingLength()<8&&await this.flush(8),this.data.getBigUint64(this.pointer,this.littleEndian)}async readInt8(){this.remainingLength()<1&&await this.flush(1);const t=this.data.getInt8(this.pointer);return this.pointer++,this.pos++,t}async peekInt8(){return this.remainingLength()<1&&await this.flush(1),this.data.getInt8(this.pointer)}async readInt16(){this.remainingLength()<2&&await this.flush(2);const t=this.data.getInt16(this.pointer,this.littleEndian);return this.pointer+=2,this.pos+=BigInt(2),t}async peekInt16(){return this.remainingLength()<2&&await this.flush(2),this.data.getInt16(this.pointer,this.littleEndian)}async readInt24(){const t=await this.readUint24();return 8388608&t?t-16777216:t}async peekInt24(){const t=await this.peekUint24();return 8388608&t?t-16777216:t}async readInt32(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getInt32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekInt32(){return this.remainingLength()<4&&await this.flush(4),this.data.getInt32(this.pointer,this.littleEndian)}async readInt64(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getBigInt64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekInt64(){return this.remainingLength()<8&&await this.flush(8),this.data.getBigInt64(this.pointer,this.littleEndian)}async readFloat(){this.remainingLength()<4&&await this.flush(4);const t=this.data.getFloat32(this.pointer,this.littleEndian);return this.pointer+=4,this.pos+=BigInt(4),t}async peekFloat(){return this.remainingLength()<4&&await this.flush(4),this.data.getFloat32(this.pointer,this.littleEndian)}async readDouble(){this.remainingLength()<8&&await this.flush(8);const t=this.data.getFloat64(this.pointer,this.littleEndian);return this.pointer+=8,this.pos+=BigInt(8),t}async peekDouble(){return this.remainingLength()<8&&await this.flush(8),this.data.getFloat64(this.pointer,this.littleEndian)}async readHex(t=1){let i="";for(let e=0;e<t;e++){const t=(await this.readUint8()).toString(16);i+=1===t.length?"0"+t:t}return i}async peekHex(t=1){t>this.size&&(this.error=-1048574,a.h2("peekHex, length too large",f,416)),this.remainingLength()<t&&await this.flush(t);const i=this.pointer,e=this.pos;let s="";for(let i=0;i<t;i++){const t=(await this.readUint8()).toString(16);s+=1===t.length?"0"+t:t}return this.pointer=i,this.pos=e,s}async readBuffer(t,i){if(i||(i=new Uint8Array(t)),this.remainingLength()<t){let e=0;if(this.remainingLength()>0){const s=this.remainingLength();i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}for(;t>0;){await this.flush();const s=Math.min(this.endPointer-this.pointer,t);i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}}else i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),this.pointer+=t,this.pos+=BigInt(t);return i}async peekBuffer(t,i){return t>this.size&&(this.error=-1048574,a.h2("peekBuffer, length too large",f,501)),this.remainingLength()<t&&await this.flush(t),i||(i=new Uint8Array(t)),i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),i}async readToBuffer(t,i){if(this.remainingLength()<t){let e=0;if(this.remainingLength()>0){const s=this.remainingLength();i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}for(;t>0;){try{await this.flush()}catch(t){if(-1048576===this.error&&e)return e;throw t}const s=Math.min(this.endPointer-this.pointer,t);i.set(this.buffer.subarray(this.pointer,this.pointer+s),e),e+=s,this.pointer+=s,this.pos+=BigInt(s),t-=s}return e}return i.set(this.buffer.subarray(this.pointer,this.pointer+t),0),this.pointer+=t,this.pos+=BigInt(t),t}async readString(t=1){const i=await this.readBuffer(t);return h.decode(i)}async peekString(t=1){const i=await this.peekBuffer(t);return h.decode(i)}async readLine(){let t="";for(;;){let i=!1;for(let e=this.pointer;e<this.endPointer;e++)if(10===this.buffer[e]||13===this.buffer[e]){e!==this.pointer&&(t+=await this.readString(e-this.pointer)),i=!0;break}if(i)break;t+=await this.readString(this.remainingLength()),await this.flush()}let i=await this.peekUint8();return 10!==i&&13!==i||(this.pointer++,13===i&&(i=await this.peekUint8(),10===i&&this.pointer++)),t}async peekLine(){if(this.remainingLength()<this.size)try{await this.flush()}catch(t){if(-1048576!==this.error)throw t}let t="",i=!1;for(let e=this.pointer;e<this.endPointer;e++)if(10===this.buffer[e]||13===this.buffer[e]){t+=await this.peekString(e-this.pointer),i=!0;break}return i||(this.error=-1048574,a.h2("peekLine, out of buffer",f,659)),t}getPointer(){return this.pointer}getPos(){return this.pos}async skip(t){const i=t;for(;this.remainingLength()<t;)t-=this.remainingLength(),this.pointer=this.endPointer,await this.flush();this.remainingLength()>=t&&(this.pointer+=t),this.pos+=BigInt(i)}remainingLength(){return this.endPointer-this.pointer}async flush_(t){return new(n())((async i=>{for(this.flushResolve=i;;){const e=await this.onFlush(t);if(-1048575!==e){this.flushResolve=null,i(e);break}await new o.A(0)}}))}async flush(t=0){if(this.onFlush||(this.error=-1048574,a.h2("IOReader error, flush failed because of no flush callback",f,738)),!(this.size-this.remainingLength()<=0)){if(t=Math.min(t,this.size),this.pointer<this.endPointer?(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer):this.endPointer=0,this.pointer=0,t)for(;this.remainingLength()<t;){const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0)throw this.error=t,new Error(`IOReader error, flush ${-1048576===t?"ended":"failed"}, ret: ${t}`);this.endPointer+=t}else{const t=await this.flush_(this.buffer.subarray(this.endPointer));if(t<0)throw this.error=t,new Error(`IOReader error, flush ${-1048576===t?"ended":"failed"}, ret: ${t}`);this.endPointer+=t}this.error=0}}async seek(t,i=!1,e=!0){if(!i){const i=Number(t-this.pos);if(i<0&&Math.abs(i)<=this.pointer)return this.pointer+=i,void(this.pos=t);if(i>0&&this.pointer+i<this.endPointer)return this.pointer+=i,void(this.pos=t);if(0===i)return}this.onSeek||(this.error=-1048574,a.h2("IOReader error, seek failed because of no seek callback",f,809)),this.pointer=this.endPointer=0,this.pos=t;const s=await this.onSeek(t);0!==s&&(this.error=s,a.h2("IOReader error, seek failed",f,818)),e&&await this.flush()}getBuffer(){return this.buffer}appendBuffer(t){if(this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else if(this.buffer.set(this.buffer.subarray(this.pointer,this.endPointer),0),this.endPointer=this.endPointer-this.pointer,this.pointer=0,this.size-this.endPointer>=t.length)this.buffer.set(t,this.endPointer),this.endPointer+=t.length;else{const i=Math.min(this.size-this.endPointer,t.length);this.buffer.set(t.subarray(0,i),this.endPointer),this.endPointer+=i,a.R8("IOReader, call appendBuffer but the buffer's size is lagger then the remaining size",f,856)}}reset(){this.pointer=this.endPointer=0,this.pos=BigInt(0),this.error=0}setEndian(t){this.littleEndian=!t}isBigEndian(){return!this.littleEndian}async fileSize(){if(this.fileSize_)return this.fileSize_;if(!this.onSize)return a.R8("IOReader error, fileSize failed because of no onSize callback",f,898),BigInt(0);try{this.fileSize_=await this.onSize()}catch(t){a.R8(`IOReader error, call fileSize failed: ${t}`,f,905),this.fileSize_=BigInt(0)}return this.fileSize_}getBufferSize(){return this.size}async pipe(t,i){if(i)if(this.remainingLength()<i){if(this.remainingLength()>0){const e=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}for(;i>0;){await this.flush();const e=Math.min(this.remainingLength(),i);await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+e)),this.pointer+=e,this.pos+=BigInt(e),i-=e}}else await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i);else{if(this.remainingLength()>0){const i=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}for(;await this.flush_(this.buffer.subarray(0))>0;){const i=this.remainingLength();await t.writeBuffer(this.buffer.subarray(this.pointer,this.pointer+i)),this.pointer+=i,this.pos+=BigInt(i)}}}abort(){this.error=-1048572,this.flushResolve&&(this.flushResolve(-1048572),this.flushResolve=null)}}},73416:(t,i,e)=>{e.d(i,{A:()=>n});var s=e(9655),r=e(19372);class n{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),this.pointer=0,this.pos=BigInt(0),this.size=t,this.littleEndian=!i,this.error=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}async writeUint8(t){this.remainingLength()<1&&await this.flush(),this.data.setUint8(this.pointer,t),this.pointer++,this.pos++}async writeUint16(t){this.remainingLength()<2&&await this.flush(),this.data.setUint16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}async writeUint24(t){this.remainingLength()<3&&await this.flush();const i=(16711680&t)>>16,e=(65280&t)>>8,s=255&t;this.littleEndian?(await this.writeUint8(s),await this.writeUint8(e),await this.writeUint8(i)):(await this.writeUint8(i),await this.writeUint8(e),await this.writeUint8(s))}async writeUint32(t){this.remainingLength()<4&&await this.flush(),this.data.setUint32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeUint64(t){this.remainingLength()<8&&await this.flush(),this.data.setBigUint64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}async writeInt8(t){this.remainingLength()<1&&await this.flush(),this.data.setInt8(this.pointer,t),this.pointer++,this.pos++}async writeInt16(t){this.remainingLength()<2&&await this.flush(),this.data.setInt16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}async writeInt24(t){await this.writeUint24(t<0?t+16777216:t)}async writeInt32(t){this.remainingLength()<4&&await this.flush(),this.data.setInt32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeInt64(t){this.remainingLength()<8&&await this.flush(),this.data.setBigInt64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}async writeFloat(t){this.remainingLength()<4&&await this.flush(),this.data.setFloat32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}async writeDouble(t){this.remainingLength()<8&&await this.flush(),this.data.setFloat64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}getPointer(){return this.pointer}getPos(){return this.pos}remainingLength(){return this.size-this.pointer}async writeBuffer(t){if(!t.length)return;let i=t.length;if(this.remainingLength()<i){let e=0;for(;i>0;){await this.flush();const s=Math.min(this.size,i);this.buffer.set(t.subarray(e,e+s),this.pointer),this.pointer+=s,this.pos+=BigInt(s),e+=s,i-=s}}else this.buffer.set(t,this.pointer),this.pointer+=i,this.pos+=BigInt(i)}async writeString(t){const i=r.encode(t);return await this.writeBuffer(i),i.length}async flush(){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const t=await this.onFlush(this.buffer.subarray(0,this.pointer));if(0!==t)throw this.error=t,Error("IOWriter error, flush failed")}this.pointer=0}async flushToPos(t){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const i=await this.onFlush(this.buffer.subarray(0,this.pointer),t);if(0!==i)throw this.error=i,Error("IOWriter error, flush failed")}this.pointer=0}async seek(t){if(!this.onSeek)throw this.error=-1048574,Error("IOWriter error, seek failed because of no seek callback");await this.flush();const i=await this.onSeek(t);if(0!==i)throw this.error=i,Error("IOWriter error, seek failed");this.pos=t}seekInline(t){const i=this.pointer;this.pointer=Math.max(0,Math.min(this.size,t)),this.pos+=BigInt(this.pointer-i)}skip(t){const i=this.pointer;this.pointer=Math.min(this.size,this.pointer+t),this.pos+=BigInt(this.pointer-i)}back(t){const i=this.pointer;this.pointer=Math.max(0,this.pointer-t),this.pos+=BigInt(this.pointer-i)}getBuffer(){return this.buffer.subarray(0,this.pointer)}setEndian(t){this.littleEndian=!t}reset(){this.pointer=0,this.pos=BigInt(0),this.error=0}getBufferSize(){return this.size}}},81895:(t,i,e)=>{e.d(i,{A:()=>n});var s=e(9655),r=e(19372);class n{constructor(t=1048576,i=!0,e){if((0,s.A)(this,"data",void 0),(0,s.A)(this,"buffer",void 0),(0,s.A)(this,"pointer",void 0),(0,s.A)(this,"pos",void 0),(0,s.A)(this,"size",void 0),(0,s.A)(this,"littleEndian",void 0),(0,s.A)(this,"error",void 0),(0,s.A)(this,"onFlush",void 0),(0,s.A)(this,"onSeek",void 0),this.pointer=0,this.pos=BigInt(0),this.size=t,this.littleEndian=!i,this.error=0,e&&e.view)this.size=e.length,this.buffer=e,this.data=e.view;else if(e&&!e.byteOffset)this.size=e.length,this.buffer=e,this.data=new DataView(this.buffer.buffer);else{if(e)throw new Error("not support subarray of ArrayBuffer");this.buffer=new Uint8Array(this.size),this.data=new DataView(this.buffer.buffer)}}writeUint8(t){this.remainingLength()<1&&this.flush(),this.data.setUint8(this.pointer,t),this.pointer++,this.pos++}writeUint16(t){this.remainingLength()<2&&this.flush(),this.data.setUint16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeUint24(t){this.remainingLength()<3&&this.flush();const i=(16711680&t)>>16,e=(65280&t)>>8,s=255&t;this.littleEndian?(this.writeUint8(s),this.writeUint8(e),this.writeUint8(i)):(this.writeUint8(i),this.writeUint8(e),this.writeUint8(s))}writeUint32(t){this.remainingLength()<4&&this.flush(),this.data.setUint32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeUint64(t){this.remainingLength()<8&&this.flush(),this.data.setBigUint64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeInt8(t){this.remainingLength()<1&&this.flush(),this.data.setInt8(this.pointer,t),this.pointer++,this.pos++}writeInt16(t){this.remainingLength()<2&&this.flush(),this.data.setInt16(this.pointer,t,this.littleEndian),this.pointer+=2,this.pos+=BigInt(2)}writeInt24(t){this.writeUint24(t<0?t+16777216:t)}writeInt32(t){this.remainingLength()<4&&this.flush(),this.data.setInt32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeInt64(t){this.remainingLength()<8&&this.flush(),this.data.setBigInt64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}writeFloat(t){this.remainingLength()<4&&this.flush(),this.data.setFloat32(this.pointer,t,this.littleEndian),this.pointer+=4,this.pos+=BigInt(4)}writeDouble(t){this.remainingLength()<8&&this.flush(),this.data.setFloat64(this.pointer,t,this.littleEndian),this.pointer+=8,this.pos+=BigInt(8)}getPointer(){return this.pointer}getPos(){return this.pos}remainingLength(){return this.size-this.pointer}writeBuffer(t){if(!t.length)return;let i=t.length;if(this.remainingLength()<i){let e=0;for(;i>0;){this.flush();const s=Math.min(this.size,i);this.buffer.set(t.subarray(e,e+s),this.pointer),this.pointer+=s,this.pos+=BigInt(s),e+=s,i-=s}}else this.buffer.set(t,this.pointer),this.pointer+=i,this.pos+=BigInt(i)}writeString(t){const i=r.encode(t);return this.writeBuffer(i),i.length}flush(){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const t=this.onFlush(this.buffer.subarray(0,this.pointer));if(0!==t)throw this.error=t,Error("IOWriter error, flush failed")}this.pointer=0}flushToPos(t){if(!this.onFlush)throw this.error=-1048574,Error("IOWriter error, flush failed because of no flush callback");if(this.pointer){const i=this.onFlush(this.buffer.subarray(0,this.pointer),t);if(0!==i)throw this.error=i,Error("IOWriter error, flush failed")}this.pointer=0}seek(t){if(!this.onSeek)throw this.error=-1048574,Error("IOWriter error, seek failed because of no seek callback");this.flush();const i=this.onSeek(t);if(0!==i)throw this.error=i,Error("IOWriter error, seek failed");this.pos=t}seekInline(t){const i=this.pointer;this.pointer=Math.max(0,Math.min(this.size,t)),this.pos+=BigInt(this.pointer-i)}skip(t){const i=this.pointer;this.pointer=Math.min(this.size,this.pointer+t),this.pos+=BigInt(this.pointer-i)}back(t){const i=this.pointer;this.pointer=Math.max(0,this.pointer-t),this.pos+=BigInt(this.pointer-i)}getBuffer(){return this.buffer.subarray(0,this.pointer)}setEndian(t){this.littleEndian=!t}reset(){this.pointer=0,this.pos=BigInt(0),this.error=0}getBufferSize(){return this.size}}},17583:(t,i,e)=>{function s(t,i){for(;0!==i;)[t,i]=[i,t%i];return t}e.d(i,{A:()=>s})},10446:(t,i,e)=>{function s(t){const i=t,e=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],s=/:\/\/([^\/@]*@?)\[(\S+)\]/;let r="";s.test(t)&&(t=t.replace(s,((t,i,e)=>(r=e,`://${i||""}a.b`))));const n={},a=/^(?:(?![^:@\/]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*)(?::([^:@\/]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(t);let h=14;for(;h--;){var o;n[e[h]]=null!==(o=a[h])&&void 0!==o?o:""}return r&&(n.host=r,n.source=i,n.authority=r+(n.port?":"+n.port:"")),{protocol:n.protocol,file:n.file,host:n.host,port:n.port,user:n.user,password:n.password,origin:`${n.protocol}://${n.authority}`,pathname:n.path,search:`?${n.query}`,hash:n.anchor?`#${n.anchor}`:""}}e.d(i,{ll:()=>l,qg:()=>s}),e(38035),e(68483),e(97023),e(31126),e(99868);const r=/(?:\/|^)\.(?=\/)/g,n=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a=/^(?=([^\/?#]*))\1([^]*)$/,h=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/;function o(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}function f(t){const i=h.exec(t);return i?{scheme:i[1]||"",netLoc:i[2]||"",path:i[3]||"",params:i[4]||"",query:i[5]||"",fragment:i[6]||""}:null}function u(t){for(t=t.split("").reverse().join("").replace(r,"");t.length!==(t=t.replace(n,"")).length;);return t.split("").reverse().join("")}function l(t,i,e){if(e=e||{},t=t.trim(),!(i=i.trim())){if(!e.alwaysNormalize)return t;let i=f(t);if(!i)throw new Error("Error trying to parse base URL.");return i.path=u(i.path),o(i)}let s=f(i);if(!s)throw new Error("Error trying to parse relative URL.");if(s.scheme)return e.alwaysNormalize?(s.path=u(s.path),o(s)):i;let r=f(t);if(!r)throw new Error("Error trying to parse base URL.");if(!r.netLoc&&r.path&&"/"!==r.path[0]){let t=a.exec(r.path);r.netLoc=t[1],r.path=t[2]}r.netLoc&&!r.path&&(r.path="/");const n={scheme:r.scheme,netLoc:s.netLoc,path:null,params:s.params,query:s.query,fragment:s.fragment};if(!s.netLoc&&(n.netLoc=r.netLoc,"/"!==s.path[0]))if(s.path){let t=r.path,i=t.substring(0,t.lastIndexOf("/")+1)+s.path;n.path=u(i)}else n.path=r.path,s.params||(n.params=r.params,s.query||(n.query=r.query));return null===n.path&&(n.path=e.alwaysNormalize?u(s.path):s.path),o(n)}},6431:(t,i,e)=>{var s=e(54446),r=s.JSON||(s.JSON={stringify:JSON.stringify});t.exports=function(t){return r.stringify.apply(r,arguments)}},38035:(t,i,e)=>{t.exports=e(6431)}}]);