rx-player 4.1.0-dev.2024031100 → 4.1.0-dev.2024040900
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.
- package/CHANGELOG.md +270 -128
- package/VERSION +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/commonjs/__GENERATED_CODE/embedded_worker_es5.js +1 -1
- package/dist/commonjs/compat/should_wait_for_data_before_loaded.d.ts +1 -1
- package/dist/commonjs/compat/should_wait_for_data_before_loaded.js +5 -3
- package/dist/commonjs/core/segment_sinks/inventory/segment_inventory.d.ts +4 -3
- package/dist/commonjs/core/segment_sinks/inventory/segment_inventory.js +66 -41
- package/dist/commonjs/core/stream/representation/utils/get_buffer_status.js +1 -35
- package/dist/commonjs/core/stream/representation/utils/get_needed_segments.js +17 -5
- package/dist/commonjs/default_config.js +1 -1
- package/dist/commonjs/main_thread/api/public_api.js +2 -2
- package/dist/commonjs/main_thread/decrypt/content_decryptor.d.ts +28 -1
- package/dist/commonjs/main_thread/decrypt/content_decryptor.js +90 -70
- package/dist/commonjs/main_thread/decrypt/session_events_listener.js +2 -1
- package/dist/commonjs/main_thread/init/utils/get_loaded_reference.js +1 -1
- package/dist/commonjs/main_thread/init/utils/initial_seek_and_play.js +4 -1
- package/dist/commonjs/main_thread/text_displayer/html/text_track_cues_store.js +1 -1
- package/dist/commonjs/main_thread/text_displayer/html/utils.d.ts +15 -0
- package/dist/commonjs/main_thread/text_displayer/html/utils.js +24 -1
- package/dist/commonjs/parsers/containers/isobmff/extract_complete_chunks.d.ts +1 -1
- package/dist/commonjs/parsers/containers/isobmff/extract_complete_chunks.js +1 -26
- package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +1 -10
- package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.js +6 -1
- package/dist/commonjs/transports/dash/low_latency_segment_loader.js +3 -1
- package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
- package/dist/es2017/__GENERATED_CODE/embedded_worker_es5.js +1 -1
- package/dist/es2017/compat/should_wait_for_data_before_loaded.d.ts +1 -1
- package/dist/es2017/compat/should_wait_for_data_before_loaded.js +5 -3
- package/dist/es2017/core/segment_sinks/inventory/segment_inventory.d.ts +4 -3
- package/dist/es2017/core/segment_sinks/inventory/segment_inventory.js +55 -20
- package/dist/es2017/core/stream/representation/utils/get_buffer_status.js +2 -36
- package/dist/es2017/core/stream/representation/utils/get_needed_segments.js +17 -5
- package/dist/es2017/default_config.js +1 -1
- package/dist/es2017/main_thread/api/public_api.js +2 -2
- package/dist/es2017/main_thread/decrypt/content_decryptor.d.ts +28 -1
- package/dist/es2017/main_thread/decrypt/content_decryptor.js +53 -24
- package/dist/es2017/main_thread/decrypt/session_events_listener.js +2 -1
- package/dist/es2017/main_thread/init/utils/get_loaded_reference.js +1 -1
- package/dist/es2017/main_thread/init/utils/initial_seek_and_play.js +4 -1
- package/dist/es2017/main_thread/text_displayer/html/text_track_cues_store.js +2 -2
- package/dist/es2017/main_thread/text_displayer/html/utils.d.ts +15 -0
- package/dist/es2017/main_thread/text_displayer/html/utils.js +22 -0
- package/dist/es2017/parsers/containers/isobmff/extract_complete_chunks.d.ts +1 -1
- package/dist/es2017/parsers/containers/isobmff/extract_complete_chunks.js +2 -2
- package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +1 -10
- package/dist/es2017/parsers/manifest/dash/common/parse_representation_index.js +6 -1
- package/dist/es2017/transports/dash/low_latency_segment_loader.js +3 -1
- package/dist/rx-player.js +199 -146
- package/dist/rx-player.min.js +1 -1
- package/dist/worker.es5.js +1 -1
- package/dist/worker.js +7 -7
- package/package.json +2 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EMBEDDED_WORKER = void 0;
|
|
4
|
-
var blob = new Blob(["(function(){" + "\"use strict\";(()=>{var Gs=Object.defineProperty,Ks=Object.defineProperties;var js=Object.getOwnPropertyDescriptors;var za=Object.getOwnPropertySymbols;var Ys=Object.prototype.hasOwnProperty,Qs=Object.prototype.propertyIsEnumerable;var Wa=(n,e,t)=>e in n?Gs(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,_e=(n,e)=>{for(var t in e||(e={}))Ys.call(e,t)&&Wa(n,t,e[t]);if(za)for(var t of za(e))Qs.call(e,t)&&Wa(n,t,e[t]);return n},Le=(n,e)=>Ks(n,js(e));var b={PRODUCTION:0,DEV:1,CURRENT_ENV:0};var Xs={DEFAULT_REQUEST_TIMEOUT:3e4,DEFAULT_CONNECTION_TIMEOUT:15e3,DEFAULT_TEXT_TRACK_MODE:\"native\",DEFAULT_ENABLE_FAST_SWITCHING:!0,DELTA_POSITION_AFTER_RELOAD:{bitrateSwitch:-.1,trackSwitch:{audio:0,video:0,other:0}},DEFAULT_CODEC_SWITCHING_BEHAVIOR:\"continue\",DEFAULT_AUTO_PLAY:!1,DEFAULT_WANTED_BUFFER_AHEAD:30,DEFAULT_MAX_BUFFER_AHEAD:1/0,DEFAULT_MAX_BUFFER_BEHIND:1/0,DEFAULT_MAX_VIDEO_BUFFER_SIZE:1/0,MAXIMUM_MAX_BUFFER_AHEAD:{text:18e3},MINIMUM_MAX_BUFFER_AHEAD:{text:120},MAXIMUM_MAX_BUFFER_BEHIND:{text:18e3},DEFAULT_BASE_BANDWIDTH:0,INACTIVITY_DELAY:6e4,DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN:!1,DEFAULT_VIDEO_RESOLUTION_LIMIT:\"none\",DEFAULT_LIVE_GAP:{DEFAULT:10,LOW_LATENCY:3.5},BUFFER_DISCONTINUITY_THRESHOLD:.2,BITRATE_REBUFFERING_RATIO:1.5,DEFAULT_MAX_MANIFEST_REQUEST_RETRY:4,DEFAULT_CDN_DOWNGRADE_TIME:60,DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:4,INITIAL_BACKOFF_DELAY_BASE:{REGULAR:200,LOW_LATENCY:50},MAX_BACKOFF_DELAY_BASE:{REGULAR:3e3,LOW_LATENCY:1e3},SAMPLING_INTERVAL_MEDIASOURCE:1e3,SAMPLING_INTERVAL_LOW_LATENCY:500,SAMPLING_INTERVAL_NO_MEDIASOURCE:500,ABR_ENTER_BUFFER_BASED_ALGO:10,ABR_EXIT_BUFFER_BASED_ALGO:5,ABR_MINIMUM_TOTAL_BYTES:15e4,ABR_MINIMUM_CHUNK_SIZE:16e3,ABR_STARVATION_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_REGULAR_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_STARVATION_GAP:{DEFAULT:5,LOW_LATENCY:5},OUT_OF_STARVATION_GAP:{DEFAULT:7,LOW_LATENCY:7},ABR_STARVATION_DURATION_DELTA:.1,ABR_FAST_EMA:2,ABR_SLOW_EMA:10,RESUME_GAP_AFTER_SEEKING:{DEFAULT:1.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_NOT_ENOUGH_DATA:{DEFAULT:.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_BUFFERING:{DEFAULT:5,LOW_LATENCY:.5},REBUFFERING_GAP:{DEFAULT:.5,LOW_LATENCY:.2},MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING:2,UNFREEZING_SEEK_DELAY:6e3,FREEZING_STALLED_DELAY:600,UNFREEZING_DELTA_POSITION:.001,SEGMENT_SYNCHRONIZATION_DELAY:1500,MISSING_DATA_TRIGGER_SYNC_DELAY:.1,MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:.15,MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:.4,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:.3,MINIMUM_SEGMENT_SIZE:.005,APPEND_WINDOW_SECURITIES:{START:.2,END:.1},MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL:50,TEXT_TRACK_SIZE_CHECKS_INTERVAL:250,BUFFER_PADDING:{audio:1,video:3,other:1},SEGMENT_PRIORITIES_STEPS:[2,4,8,12,18,25],MAX_HIGH_PRIORITY_LEVEL:1,MIN_CANCELABLE_PRIORITY:3,EME_DEFAULT_VIDEO_CODECS:['video/mp4;codecs=\"avc1.4d401e\"','video/mp4;codecs=\"avc1.42e01e\"','video/webm;codecs=\"vp8\"'],EME_DEFAULT_AUDIO_CODECS:['audio/mp4;codecs=\"mp4a.40.2\"',\"audio/webm;codecs=opus\"],EME_DEFAULT_WIDEVINE_ROBUSTNESSES:[\"HW_SECURE_ALL\",\"HW_SECURE_DECODE\",\"HW_SECURE_CRYPTO\",\"SW_SECURE_DECODE\",\"SW_SECURE_CRYPTO\"],EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES:[\"3000\",\"2000\"],EME_KEY_SYSTEMS:{clearkey:[\"webkit-org.w3.clearkey\",\"org.w3.clearkey\"],widevine:[\"com.widevine.alpha\"],playready:[\"com.microsoft.playready.recommendation\",\"com.microsoft.playready\",\"com.chromecast.playready\",\"com.youtube.playready\"],fairplay:[\"com.apple.fps.1_0\"]},MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:10,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:200,MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:300,OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:3e3,FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:3e3,DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:3,EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS:15,EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION:1e3,EME_WAITING_DELAY_LOADED_SESSION_EMPTY_KEYSTATUSES:100,FORCED_ENDED_THRESHOLD:8e-4,ADAP_REP_SWITCH_BUFFER_PADDINGS:{video:{before:5,after:5},audio:{before:2,after:2.5},text:{before:0,after:0}},SOURCE_BUFFER_FLUSHING_INTERVAL:500,CONTENT_REPLACEMENT_PADDING:1.2,CACHE_LOAD_DURATION_THRESHOLDS:{video:50,audio:10},STREAM_EVENT_EMITTER_POLL_INTERVAL:250,DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR:.001,BUFFERED_HISTORY_RETENTION_TIME:6e4,BUFFERED_HISTORY_MAXIMUM_ENTRIES:200,MIN_BUFFER_AHEAD:5,UPTO_CURRENT_POSITION_CLEANUP:5,DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE:\"seamless\",DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE:\"seamless\",DEFAULT_VIDEO_TRACK_SWITCHING_MODE:\"reload\",DEFAULT_AUDIO_TRACK_SWITCHING_MODE:\"seamless\"},Va=Xs;function Zs(n,...e){if(n==null)throw new TypeError(\"Cannot convert undefined or null to object\");let t=Object(n);for(let r=0;r<e.length;r++){let i=e[r];for(let a in i)Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a])}return t}var H=typeof Object.assign==\"function\"?Object.assign:Zs;function qr(n){return n!=null&&!Array.isArray(n)&&typeof n==\"object\"}function jt(n,...e){if(e.length===0)return n;let t=e.shift();if(qr(n)&&qr(t))for(let r in t)if(qr(t[r])){let i=n[r];i===void 0&&(i={},n[r]=i),jt(i,t[r])}else H(n,{[r]:t[r]});return jt(n,...e)}var Hr=class{constructor(){this._config=Va}update(e){let t=jt(this._config,e);this._config=t}getCurrent(){return this._config}},Js=new Hr,U=Js;var Ge=class n extends Error{constructor(e,t,r){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"CustomLoaderError\",this.message=e,this.canRetry=t,this.xhr=r}};function R(n){return n==null}var oe=class{constructor(){this._listeners={}}addEventListener(e,t,r){let i=this._listeners[e];Array.isArray(i)?i.push(t):this._listeners[e]=[t],r!==void 0&&r.register(()=>{this.removeEventListener(e,t)})}removeEventListener(e,t){if(R(e)){this._listeners={};return}let r=this._listeners[e];if(!Array.isArray(r))return;if(R(t)){delete this._listeners[e];return}let i=r.indexOf(t);i!==-1&&r.splice(i,1),r.length===0&&delete this._listeners[e]}trigger(e,t){let r=this._listeners[e];Array.isArray(r)&&r.slice().forEach(i=>{try{i(t)}catch(a){if(b.CURRENT_ENV===b.DEV)throw a instanceof Error?a:new Error(\"EventEmitter: listener error\");console.error(\"RxPlayer: EventEmitter error\",a instanceof Error?a:null)}})}};function N(){}var eu=\"NONE\",Yt=class extends oe{constructor(){super(),this.error=N,this.warn=N,this.info=N,this.debug=N,this._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},this._currentLevel=eu}setLevel(e,t){let r,i=this._levels[e];typeof i==\"number\"?(r=i,this._currentLevel=e):(r=0,this._currentLevel=\"NONE\"),t===void 0?(this.error=r>=this._levels.ERROR?console.error.bind(console):N,this.warn=r>=this._levels.WARNING?console.warn.bind(console):N,this.info=r>=this._levels.INFO?console.info.bind(console):N,this.debug=r>=this._levels.DEBUG?console.log.bind(console):N):(this.error=r>=this._levels.ERROR?(...a)=>t(\"ERROR\",a):N,this.warn=r>=this._levels.WARNING?(...a)=>t(\"WARNING\",a):N,this.info=r>=this._levels.INFO?(...a)=>t(\"INFO\",a):N,this.debug=r>=this._levels.DEBUG?(...a)=>t(\"DEBUG\",a):N),this.trigger(\"onLogLevelChange\",this._currentLevel)}getLevel(){return this._currentLevel}hasLevel(e){return this._levels[e]>=this._levels[this._currentLevel]}};var tu=new Yt,c=tu;var st=typeof WorkerGlobalScope!=\"undefined\"&&self instanceof WorkerGlobalScope;var nu=typeof window==\"undefined\"&&!st,er=nu;var tr;st?tr=self:er?tr=global:tr=window;var Ee=tr;function ne(n,e,t){if(typeof Array.prototype.findIndex==\"function\")return n.findIndex(e,t);let r=n.length>>>0;for(let i=0;i<r;i++)if(e.call(t,n[i],i,n))return i;return-1}var nr=class{constructor(e,t){this._value=e,this._listeners=[],this._isFinished=!1,this._onFinishCbs=[],t!==void 0&&(this._deregisterCancellation=t.register(()=>this.finish()))}getValue(){return this._value}setValue(e){if(this._isFinished){b.CURRENT_ENV===b.DEV&&console.error(\"Finished shared references cannot be updated\");return}if(this._value=e,this._listeners.length===0)return;let t=this._listeners.slice();for(let r of t)try{r.hasBeenCleared||r.trigger(e,r.complete)}catch(i){}}setValueIfChanged(e){e!==this._value&&this.setValue(e)}onUpdate(e,t){let r=()=>{if((t==null?void 0:t.clearSignal)!==void 0&&t.clearSignal.deregister(r),i.hasBeenCleared)return;i.hasBeenCleared=!0;let a=this._listeners.indexOf(i);a>=0&&this._listeners.splice(a,1)},i={trigger:e,complete:r,hasBeenCleared:!1};if(this._listeners.push(i),(t==null?void 0:t.emitCurrentValue)===!0&&e(this._value,r),this._isFinished||i.hasBeenCleared){r();return}(t==null?void 0:t.clearSignal)!==void 0&&t.clearSignal.register(r)}waitUntilDefined(e,t){this.onUpdate((r,i)=>{r!==void 0&&(i(),e(this._value))},{clearSignal:t==null?void 0:t.clearSignal,emitCurrentValue:!0})}_onFinished(e,t){if(t.isCancelled())return N;let r=()=>{let o=ne(this._onFinishCbs,s=>s.trigger===i);o>=0&&(this._onFinishCbs[o].hasBeenCleared=!0,this._onFinishCbs.splice(o,1))},i=()=>{r(),e()},a=t.register(r);return this._onFinishCbs.push({trigger:i,hasBeenCleared:!1}),a}finish(){this._deregisterCancellation!==void 0&&this._deregisterCancellation(),this._isFinished=!0;let e=this._listeners.slice();for(let t of e)try{t.hasBeenCleared||(t.complete(),t.hasBeenCleared=!0)}catch(r){}if(this._listeners.length=0,this._onFinishCbs.length>0){let t=this._onFinishCbs.slice();for(let r of t)try{r.hasBeenCleared||(r.trigger(),r.hasBeenCleared=!0)}catch(i){}this._onFinishCbs.length=0}}};function Qt(n,e,t){let r=new nr(e(n.getValue()),t);return n.onUpdate(function(a){r.setValue(e(a))},{clearSignal:t}),n._onFinished(()=>{r.finish()},t),r}var G=nr;var Gr=new G(0);function qa({date:n,timestamp:e}){let t=n-e,r=typeof performance!=\"undefined\"?Date.now()-performance.now():0;Gr.setValueIfChanged(r-t)}var ru=typeof performance!=\"undefined\"?()=>performance.now()+Gr.getValue():()=>Date.now()+Gr.getValue(),L=ru;var re=class n extends Error{constructor(e,t,r){switch(super(),Object.setPrototypeOf(this,n.prototype),this.name=\"RequestError\",this.url=e,this.status=t,this.type=r,r){case\"TIMEOUT\":this.message=\"The request timed out\";break;case\"ERROR_EVENT\":this.message=\"An error prevented the request to be performed successfully\";break;case\"PARSE_ERROR\":this.message=\"An error happened while formatting the response data\";break;case\"ERROR_HTTP_CODE\":this.message=\"An HTTP status code indicating failure was received: \"+String(this.status);break}}serialize(){return{url:this.url,status:this.status,type:this.type}}},Se={TIMEOUT:\"TIMEOUT\",ERROR_EVENT:\"ERROR_EVENT\",ERROR_HTTP_CODE:\"ERROR_HTTP_CODE\",PARSE_ERROR:\"PARSE_ERROR\"};var Kr=typeof Headers==\"function\"?Headers:null,jr=typeof AbortController==\"function\"?AbortController:null;function rr(n){let e;if(!R(n.headers))if(R(Kr))e=n.headers;else{e=new Kr;let m=Object.keys(n.headers);for(let p=0;p<m.length;p++){let g=m[p];e.append(g,n.headers[g])}}c.debug(\"Fetch: Called with URL\",n.url);let t=null,r=!1,i=!1,a=L(),o=R(jr)?null:new jr;function s(){if(R(o)){c.warn(\"Fetch: AbortController API not available.\");return}o.abort()}let u;n.timeout!==void 0&&(u=setTimeout(()=>{r=!0,l!==void 0&&clearTimeout(l),s()},n.timeout));let l;n.connectionTimeout!==void 0&&(l=setTimeout(()=>{i=!0,u!==void 0&&clearTimeout(u),s()},n.connectionTimeout));let d=n.cancelSignal.register(function(p){t=p,s()}),f={method:\"GET\"};return e!==void 0&&(f.headers=e),f.signal=R(o)?null:o.signal,fetch(n.url,f).then(m=>{if(l!==void 0&&clearTimeout(l),m.status>=300)throw c.warn(\"Fetch: Request HTTP Error\",m.status,m.url),new re(m.url,m.status,Se.ERROR_HTTP_CODE);if(R(m.body))throw new re(m.url,m.status,Se.PARSE_ERROR);let p=m.headers.get(\"Content-Length\"),g=!R(p)&&!isNaN(+p)?+p:void 0,I=m.body.getReader(),h=0;return y();async function y(){let E=await I.read();if(!E.done&&!R(E.value)){h+=E.value.byteLength;let v=L(),T={url:m.url,currentTime:v,duration:v-a,sendingTime:a,chunkSize:E.value.byteLength,chunk:E.value.buffer,size:h,totalSize:g};return n.onData(T),y()}else if(E.done){u!==void 0&&clearTimeout(u),d();let v=L();return{requestDuration:v-a,receivedTime:v,sendingTime:a,size:h,status:m.status,url:m.url}}return y()}}).catch(m=>{throw t!==null?t:(d(),r?(c.warn(\"Fetch: Request timed out.\"),new re(n.url,0,Se.TIMEOUT)):i?(c.warn(\"Fetch: Request connection timed out.\"),new re(n.url,0,Se.TIMEOUT)):m instanceof re?m:(c.warn(\"Fetch: Request Error\",m instanceof Error?m.toString():\"\"),new re(n.url,0,Se.ERROR_EVENT)))})}function $t(){return typeof Ee.fetch==\"function\"&&!R(jr)&&!R(Kr)}function Z(n){return typeof n==\"string\"&&n.length>0}var iu=\"json\";function Yr(n){let e={url:n.url,headers:n.headers,responseType:R(n.responseType)?iu:n.responseType,timeout:n.timeout,connectionTimeout:n.connectionTimeout};return new Promise((t,r)=>{let{onProgress:i,cancelSignal:a}=n,{url:o,headers:s,responseType:u,timeout:l,connectionTimeout:d}=e,f=new XMLHttpRequest;f.open(\"GET\",o,!0);let m;l!==void 0&&(f.timeout=l,m=setTimeout(()=>{h(),r(new re(o,f.status,Se.TIMEOUT))},l+3e3));let p;if(d!==void 0&&(p=setTimeout(()=>{h(),f.readyState!==XMLHttpRequest.DONE&&f.abort(),r(new re(o,f.status,Se.TIMEOUT))},d)),f.responseType=u,f.responseType===\"document\"&&f.overrideMimeType(\"text/xml\"),!R(s)){let y=s;for(let E in y)y.hasOwnProperty(E)&&f.setRequestHeader(E,y[E])}let g=L(),I=null;if(a!==void 0&&(I=a.register(function(E){h(),f.readyState!==XMLHttpRequest.DONE&&f.abort(),r(E)}),a.isCancelled()))return;f.onerror=function(){h(),r(new re(o,f.status,Se.ERROR_EVENT))},f.ontimeout=function(){h(),r(new re(o,f.status,Se.TIMEOUT))},d!==void 0&&(f.onreadystatechange=function(){f.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(p)}),i!==void 0&&(f.onprogress=function(E){let v=L();i({url:o,duration:v-g,sendingTime:g,currentTime:v,size:E.loaded,totalSize:E.total})}),f.onload=function(E){if(f.readyState===XMLHttpRequest.DONE)if(h(),f.status>=200&&f.status<300){let v=L(),T=f.response instanceof ArrayBuffer?f.response.byteLength:E.total,C=f.status,P=f.responseType,M=Z(f.responseURL)?f.responseURL:o,_;if(P===\"json\"?_=typeof f.response==\"object\"?f.response:au(f.responseText):_=f.response,R(_)){r(new re(o,f.status,Se.PARSE_ERROR));return}t({status:C,url:M,responseType:P,sendingTime:g,receivedTime:v,requestDuration:v-g,size:T,responseData:_})}else r(new re(o,f.status,Se.ERROR_HTTP_CODE))},f.send();function h(){m!==void 0&&clearTimeout(m),p!==void 0&&clearTimeout(p),I!==null&&I()}})}function au(n){try{return JSON.parse(n)}catch(e){return null}}var le=Yr;var bt=Se,Fe={NETWORK_ERROR:\"NETWORK_ERROR\",MEDIA_ERROR:\"MEDIA_ERROR\",ENCRYPTED_MEDIA_ERROR:\"ENCRYPTED_MEDIA_ERROR\",OTHER_ERROR:\"OTHER_ERROR\"};function $e(n,e){return`${n}: ${e}`}var Xt=class n extends Error{constructor(e,t,r){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"EncryptedMediaError\",this.type=Fe.ENCRYPTED_MEDIA_ERROR,this.code=e,this._originalMessage=t,this.message=$e(this.code,t),this.fatal=!1,typeof(r==null?void 0:r.keyStatuses)==\"string\"&&(this.keyStatuses=r.keyStatuses)}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage,keyStatuses:this.keyStatuses}}};var j=class n extends Error{constructor(e,t,r){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"MediaError\",this.type=Fe.MEDIA_ERROR,this._originalMessage=t,this.code=e,this.message=$e(this.code,t),this.fatal=!1,(r==null?void 0:r.tracks)!==void 0&&(r==null?void 0:r.tracks.length)>0&&(this.tracksInfo=r.tracks)}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage,tracks:this.tracksInfo}}};var Ke=class n extends Error{constructor(e,t){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"NetworkError\",this.type=Fe.NETWORK_ERROR,this.url=t.url,this.status=t.status,this.errorType=t.type,this._baseError=t,this.code=e,this.message=$e(this.code,t.message),this.fatal=!1}isHttpError(e){return this.errorType===bt.ERROR_HTTP_CODE&&this.status===e}serialize(){return{name:this.name,code:this.code,baseError:this._baseError.serialize()}}};var Re=class n extends Error{constructor(e,t){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"OtherError\",this.type=Fe.OTHER_ERROR,this.code=e,this.message=$e(this.code,t),this.fatal=!1,this._originalMessage=t}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage}}};function Mt(n){return(n instanceof Xt||n instanceof j||n instanceof Re||n instanceof Ke)&&Object.keys(Fe).indexOf(n.type)>=0}function ge(n,{defaultCode:e,defaultReason:t}){if(Mt(n))return n;let r=n instanceof Error?n.toString():t;return new Re(e,r)}var Ce=class n extends Error{constructor(e,t,r){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"SourceBufferError\",this.errorName=e,this.message=t,this.isBufferFull=r}serialize(){return{errorName:this.name,message:this.message,isBufferFull:this.isBufferFull}}toString(){return`${this.errorName}: ${this.message}`}};var ou={dashParsers:{wasm:null,native:null,fastJs:null},codecSupportProber:null,createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},mainThreadMediaSourceInit:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}},Ha=ou;var ae=Ha;function K(n,e,t){if(typeof Array.prototype.find==\"function\")return n.find(e,t);let r=n.length>>>0;for(let i=0;i<r;i++){let a=n[i];if(e.call(t,a,i,n))return a}}var su={aa:\"aar\",ab:\"abk\",ae:\"ave\",af:\"afr\",ak:\"aka\",am:\"amh\",an:\"arg\",ar:\"ara\",as:\"asm\",av:\"ava\",ay:\"aym\",az:\"aze\",ba:\"bak\",be:\"bel\",bg:\"bul\",bi:\"bis\",bm:\"bam\",bn:\"ben\",bo:\"bod\",br:\"bre\",bs:\"bos\",ca:\"cat\",ce:\"che\",ch:\"cha\",co:\"cos\",cr:\"cre\",cs:\"ces\",cu:\"chu\",cv:\"chv\",cy:\"cym\",da:\"dan\",de:\"deu\",dv:\"div\",dz:\"dzo\",ee:\"ewe\",el:\"ell\",en:\"eng\",eo:\"epo\",es:\"spa\",et:\"est\",eu:\"eus\",fa:\"fas\",ff:\"ful\",fi:\"fin\",fj:\"fij\",fo:\"fao\",fr:\"fra\",fy:\"fry\",ga:\"gle\",gd:\"gla\",gl:\"glg\",gn:\"grn\",gu:\"guj\",gv:\"glv\",ha:\"hau\",he:\"heb\",hi:\"hin\",ho:\"hmo\",hr:\"hrv\",ht:\"hat\",hu:\"hun\",hy:\"hye\",hz:\"her\",ia:\"ina\",id:\"ind\",ie:\"ile\",ig:\"ibo\",ii:\"iii\",ik:\"ipk\",io:\"ido\",is:\"isl\",it:\"ita\",iu:\"iku\",ja:\"jpn\",jv:\"jav\",ka:\"kat\",kg:\"kon\",ki:\"kik\",kj:\"kua\",kk:\"kaz\",kl:\"kal\",km:\"khm\",kn:\"kan\",ko:\"kor\",kr:\"kau\",ks:\"kas\",ku:\"kur\",kv:\"kom\",kw:\"cor\",ky:\"kir\",la:\"lat\",lb:\"ltz\",lg:\"lug\",li:\"lim\",ln:\"lin\",lo:\"lao\",lt:\"lit\",lu:\"lub\",lv:\"lav\",mg:\"mlg\",mh:\"mah\",mi:\"mri\",mk:\"mkd\",ml:\"mal\",mn:\"mon\",mr:\"mar\",ms:\"msa\",mt:\"mlt\",my:\"mya\",na:\"nau\",nb:\"nob\",nd:\"nde\",ne:\"nep\",ng:\"ndo\",nl:\"nld\",nn:\"nno\",no:\"nor\",nr:\"nbl\",nv:\"nav\",ny:\"nya\",oc:\"oci\",oj:\"oji\",om:\"orm\",or:\"ori\",os:\"oss\",pa:\"pan\",pi:\"pli\",pl:\"pol\",ps:\"pus\",pt:\"por\",qu:\"que\",rm:\"roh\",rn:\"run\",ro:\"ron\",ru:\"rus\",rw:\"kin\",sa:\"san\",sc:\"srd\",sd:\"snd\",se:\"sme\",sg:\"sag\",si:\"sin\",sk:\"slk\",sl:\"slv\",sm:\"smo\",sn:\"sna\",so:\"som\",sq:\"sqi\",sr:\"srp\",ss:\"ssw\",st:\"sot\",su:\"sun\",sv:\"swe\",sw:\"swa\",ta:\"tam\",te:\"tel\",tg:\"tgk\",th:\"tha\",ti:\"tir\",tk:\"tuk\",tl:\"tgl\",tn:\"tsn\",to:\"ton\",tr:\"tur\",ts:\"tso\",tt:\"tat\",tw:\"twi\",ty:\"tah\",ug:\"uig\",uk:\"ukr\",ur:\"urd\",uz:\"uzb\",ve:\"ven\",vi:\"vie\",vo:\"vol\",wa:\"wln\",wo:\"wol\",xh:\"xho\",yi:\"yid\",yo:\"yor\",za:\"zha\",zh:\"zho\",zu:\"zul\"},Ga=su;var uu={alb:\"sqi\",arm:\"hye\",baq:\"eus\",bur:\"mya\",chi:\"zho\",cze:\"ces\",dut:\"nld\",fre:\"fra\",geo:\"kat\",ger:\"deu\",gre:\"ell\",ice:\"isl\",mac:\"mkd\",mao:\"mri\",may:\"msa\",per:\"fas\",slo:\"slk\",rum:\"ron\",tib:\"bod\",wel:\"cym\"},Ka=uu;function du(n){if(R(n)||n===\"\")return\"\";let t=(\"\"+n).toLowerCase().split(\"-\")[0],r=lu(t);return Z(r)?r:n}function lu(n){let e;switch(n.length){case 2:e=Ga[n];break;case 3:e=Ka[n];break}return e}var ja=du;var Ya=ja;function ir(n,e){if(n.length!==e.length)return!1;if(n===e)return!0;for(let t=n.length-1;t>=0;t--)if(n[t]!==e[t])return!1;return!0}function Ae(){let n=\"\",e=-1;return function(){return e++,e>=Number.MAX_SAFE_INTEGER&&(n+=\"0\",e=0),n+String(e)}}var fu=Ae(),Qr=class{constructor(e,t){var r,i,a,o,s;if(this.id=e.id,this.uniqueId=fu(),this.bitrate=e.bitrate,this.codecs=[],e.isSpatialAudio!==void 0&&(this.isSpatialAudio=e.isSpatialAudio),e.height!==void 0&&(this.height=e.height),e.width!==void 0&&(this.width=e.width),e.mimeType!==void 0&&(this.mimeType=e.mimeType),e.contentProtections!==void 0&&(this.contentProtections=e.contentProtections),e.frameRate!==void 0&&(this.frameRate=e.frameRate),e.hdrInfo!==void 0&&(this.hdrInfo=e.hdrInfo),this.cdnMetadata=e.cdnMetadata,this.index=e.index,t===\"audio\"||t===\"video\")if(ae.codecSupportProber!==null){if(e.supplementalCodecs!==void 0){let u=ae.codecSupportProber.isSupported((r=this.mimeType)!=null?r:\"\",(i=e.supplementalCodecs)!=null?i:\"\");u!==!1&&(this.codecs=[e.supplementalCodecs],u===!0&&(this.isSupported=!0))}this.isSupported!==!0&&(this.codecs.length>0?this.codecs.push((a=e.codecs)!=null?a:\"\"):(this.codecs=e.codecs===void 0?[]:[e.codecs],this.isSupported=ae.codecSupportProber.isSupported((o=this.mimeType)!=null?o:\"\",(s=e.codecs)!=null?s:\"\")))}else e.supplementalCodecs!==void 0&&this.codecs.push(e.supplementalCodecs),e.codecs!==void 0&&this.codecs.push(e.codecs);else e.codecs!==void 0&&this.codecs.push(e.codecs),this.isSupported=!0}refreshCodecSupport(e){var i;let t=(i=this.mimeType)!=null?i:\"\",r=this.codecs;r.length===0&&(r=[\"\"]);for(let a=0;a<r.length;a++)for(let o of e){let s=r[a];if(o.codec===s&&o.mimeType===t){if(o.result){this.isSupported=!0,this.codecs=[s];return}else if(a===r.length){this.isSupported=!1,this.codecs=[s];return}}}}getMimeTypeString(){var e,t,r;return`${(e=this.mimeType)!=null?e:\"\"};codecs=\"${(r=(t=this.codecs)==null?void 0:t[0])!=null?r:\"\"}\"`}getEncryptionData(e){var i,a;let t=this.getAllEncryptionData(),r=[];for(let o=0;o<t.length;o++){let s=!1,u=t[o];for(let l=0;l<u.values.length;l++)if(u.values[l].systemId.toLowerCase()===e.toLowerCase())if(s)r[r.length-1].values.push(u.values[l]);else{let d=(a=(i=this.contentProtections)==null?void 0:i.keyIds)==null?void 0:a.map(f=>f.keyId);r.push({type:u.type,keyIds:d,values:[u.values[l]]}),s=!0}}return r}getAllEncryptionData(){var t,r;if(this.contentProtections===void 0||this.contentProtections.initData.length===0)return[];let e=(r=(t=this.contentProtections)==null?void 0:t.keyIds)==null?void 0:r.map(i=>i.keyId);return this.contentProtections.initData.map(i=>({type:i.type,keyIds:e,values:i.values}))}addProtectionData(e,t,r){let i=!1;if(this.contentProtections===void 0)return this.contentProtections={keyIds:t!==void 0?[{keyId:t}]:[],initData:[{type:e,values:r}]},!0;if(t!==void 0){let o=this.contentProtections.keyIds;if(o===void 0)this.contentProtections.keyIds=[{keyId:t}];else{let s=!1;for(let u of o)ir(u.keyId,t)&&(s=!0);s||(c.warn(\"Manifest: found unanounced key id.\"),o.push({keyId:t}))}}let a=this.contentProtections.initData;for(let o=0;o<a.length;o++)if(a[o].type===e){let s=a[o].values;for(let u=0;u<r.length;u++){let l=r[u],d;for(d=0;d<s.length;d++)if(l.systemId===s[d].systemId){if(ir(l.data,s[d].data))break;c.warn(\"Manifest: different init data for the same system ID\")}d===s.length&&(s.push(l),i=!0)}return i}return this.contentProtections.initData.push({type:e,values:r}),!0}getMetadataSnapshot(){return{id:this.id,uniqueId:this.uniqueId,bitrate:this.bitrate,codecs:this.codecs,mimeType:this.mimeType,width:this.width,height:this.height,frameRate:this.frameRate,isSupported:this.isSupported,hdrInfo:this.hdrInfo,contentProtections:this.contentProtections,decipherable:this.decipherable}}},Zt=Qr;var ut=class n{constructor(e,t={}){let{trickModeTracks:r}=e,{representationFilter:i,isManuallyAdded:a}=t;this.id=e.id,this.type=e.type,e.isTrickModeTrack!==void 0&&(this.isTrickModeTrack=e.isTrickModeTrack),e.language!==void 0&&(this.language=e.language,this.normalizedLanguage=Ya(e.language)),e.closedCaption!==void 0&&(this.isClosedCaption=e.closedCaption),e.audioDescription!==void 0&&(this.isAudioDescription=e.audioDescription),e.isDub!==void 0&&(this.isDub=e.isDub),e.forcedSubtitles!==void 0&&(this.isForcedSubtitles=e.forcedSubtitles),e.isSignInterpreted!==void 0&&(this.isSignInterpreted=e.isSignInterpreted),e.label!==void 0&&(this.label=e.label),r!==void 0&&r.length>0&&(this.trickModeTracks=r.map(l=>new n(l)));let o=e.representations,s=[],u;for(let l=0;l<o.length;l++){let d=new Zt(o[l],this.type),f=!0;if(!R(i)){let m={id:d.id,bitrate:d.bitrate,codecs:d.codecs,height:d.height,width:d.width,frameRate:d.frameRate,hdrInfo:d.hdrInfo};if(d.contentProtections!==void 0&&(m.contentProtections={},d.contentProtections.keyIds!==void 0)){let p=d.contentProtections.keyIds.map(({keyId:g})=>g);m.contentProtections.keyIds=p}f=i(m,{trackType:this.type,language:this.language,normalizedLanguage:this.normalizedLanguage,isClosedCaption:this.isClosedCaption,isDub:this.isDub,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted})}f?(s.push(d),u===void 0&&(d.isSupported===!0?u=!0:d.isSupported===!1&&(u=!1))):c.debug(\"Filtering Representation due to representationFilter\",this.type,`Adaptation: ${this.id}`,`Representation: ${d.id}`,`(${d.bitrate})`)}s.sort((l,d)=>l.bitrate-d.bitrate),this.representations=s,this.isSupported=u,this.manuallyAdded=a===!0}refreshCodecSupport(e){for(let t of this.representations)t.isSupported===void 0&&(t.refreshCodecSupport(e),this.isSupported!==!0&&t.isSupported===!0?this.isSupported=!0:this.isSupported===void 0&&t.isSupported===!1&&(this.isSupported=!1))}getRepresentation(e){return K(this.representations,({id:t})=>e===t)}getMetadataSnapshot(){let e=[],t=this.representations;for(let r of t)e.push(r.getMetadataSnapshot());return{id:this.id,type:this.type,isSupported:this.isSupported,language:this.language,isForcedSubtitles:this.isForcedSubtitles,isClosedCaption:this.isClosedCaption,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted,normalizedLanguage:this.normalizedLanguage,representations:e,label:this.label,isDub:this.isDub}}};function se(n,e,t){if(typeof Array.prototype.includes==\"function\")return n.includes(e,t);let r=n.length>>>0;if(r===0)return!1;let i=t|0,a=i>=0?Math.min(i,r-1):Math.max(r+i,0),o=(s,u)=>s===u||typeof s==\"number\"&&typeof u==\"number\"&&isNaN(s)&&isNaN(u);for(;a<r;){if(o(n[a],e))return!0;a++}return!1}var Qa=[];function Xe(n){se(Qa,n)||(console.warn(n),Qa.push(n))}function $r(n){return Object.keys(n).map(e=>n[e])}var ar=typeof Object.values==\"function\"?Object.values:$r;var Ot=[\"audio\",\"video\",\"text\"];function Xa(n){var a,o;let e=n.timeBounds;if(e.timeshiftDepth===null)return(a=e.minimumSafePosition)!=null?a:0;let{maximumTimeData:t}=e,r;if(!e.maximumTimeData.isLinear)r=t.maximumSafePosition;else{let s=L()-t.time;r=t.maximumSafePosition+s/1e3}let i=r-e.timeshiftDepth;return Math.max((o=e.minimumSafePosition)!=null?o:0,i)}function Za(n){let{maximumTimeData:e}=n.timeBounds;if(!n.isLive||e.livePosition===void 0)return;if(!e.isLinear)return e.livePosition;let t=L()-e.time;return e.livePosition+t/1e3}function Ja(n){let{maximumTimeData:e}=n.timeBounds;if(!e.isLinear)return e.maximumSafePosition;let t=L()-e.time;return e.maximumSafePosition+t/1e3}function eo(n,e){if(e===void 0)return Zr(n).filter(r=>r.isSupported===!0);let t=n.adaptations[e];return t===void 0?[]:t.filter(r=>r.isSupported===!0)}function to(n,e){let t=null;for(let r=n.periods.length-1;r>=0;r--){let i=n.periods[r];if(Xr(i,e,t))return i;t=i}}function no(n,e){let t=e.end;if(t===void 0)return null;let r=K(n.periods,i=>i.end===void 0||t<i.end);return r===void 0?null:r}function Xr(n,e,t){return e>=n.start&&(n.end===void 0||e<n.end)?!0:e===n.end&&(t===null||t.start>n.end)}function Zr(n){let e=n.adaptations;return $r(e).reduce((t,r)=>R(r)?t:t.concat(r),[])}function mu(n,e){var r,i;let t={language:(r=n.language)!=null?r:\"\",normalized:(i=n.normalizedLanguage)!=null?i:\"\",audioDescription:n.isAudioDescription===!0,id:n.id,representations:(e?n.representations.filter(a=>a.isSupported===!0&&a.decipherable!==!1):n.representations).map(gu),label:n.label};return n.isDub===!0&&(t.dub=!0),t}function cu(n){var e,t;return{language:(e=n.language)!=null?e:\"\",normalized:(t=n.normalizedLanguage)!=null?t:\"\",closedCaption:n.isClosedCaption===!0,id:n.id,label:n.label,forced:n.isForcedSubtitles}}function pu(n,e){let t=n.trickModeTracks!==void 0?n.trickModeTracks.map(i=>{let a=(e?i.representations.filter(s=>s.isSupported===!0&&s.decipherable!==!1):i.representations).map($a),o={id:i.id,representations:a,isTrickModeTrack:!0};return i.isSignInterpreted===!0&&(o.signInterpreted=!0),o}):void 0,r={id:n.id,representations:(e?n.representations.filter(i=>i.isSupported===!0&&i.decipherable!==!1):n.representations).map($a),label:n.label};return n.isSignInterpreted===!0&&(r.signInterpreted=!0),n.isTrickModeTrack===!0&&(r.isTrickModeTrack=!0),t!==void 0&&(r.trickModeTracks=t),r}function gu(n){let{id:e,bitrate:t,codecs:r,isSpatialAudio:i,isSupported:a,decipherable:o}=n;return{id:e,bitrate:t,codec:r==null?void 0:r[0],isSpatialAudio:i,isCodecSupported:a,decipherable:o}}function $a(n){let{id:e,bitrate:t,frameRate:r,width:i,height:a,codecs:o,hdrInfo:s,isSupported:u,decipherable:l}=n;return{id:e,bitrate:t,frameRate:r,width:i,height:a,codec:o==null?void 0:o[0],hdrInfo:s,isCodecSupported:u,decipherable:l}}function dt(n){switch(n.type){case\"audio\":return{type:\"audio\",track:mu(n,!1)};case\"video\":return{type:\"video\",track:pu(n,!1)};case\"text\":return{type:\"text\",track:cu(n)}}}function ro(n){return new Function(`return (${n}(arguments[0], arguments[1]))`)}var lt=class{constructor(e,t,r){if(this.id=e.id,this.adaptations=Object.keys(e.adaptations).reduce((i,a)=>{let o=e.adaptations[a];if(R(o))return i;let s=o.map(u=>{let l=new ut(u,{representationFilter:r});return l.representations.length>0&&l.isSupported===!1&&t.push(l),l}).filter(u=>u.representations.length>0);if(s.every(u=>u.isSupported===!1)&&o.length>0&&(a===\"video\"||a===\"audio\"))throw new j(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"No supported \"+a+\" adaptations\",{tracks:void 0});return s.length>0&&(i[a]=s),i},{}),!Array.isArray(this.adaptations.video)&&!Array.isArray(this.adaptations.audio))throw new j(\"MANIFEST_PARSE_ERROR\",\"No supported audio and video tracks.\");this.duration=e.duration,this.start=e.start,!R(this.duration)&&!R(this.start)&&(this.end=this.start+this.duration),this.streamEvents=e.streamEvents===void 0?[]:e.streamEvents}refreshCodecSupport(e,t){Object.keys(this.adaptations).forEach(r=>{let i=this.adaptations[r];if(i===void 0)return;let a=!1;for(let o of i){let s=o.isSupported;o.refreshCodecSupport(e),s!==!1&&o.isSupported===!1&&t.push(o),a===!1?a=o.isSupported:a===void 0&&o.isSupported===!0&&(a=!0)}if((r===\"video\"||r===\"audio\")&&a===!1)throw new j(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"No supported \"+r+\" adaptations\",{tracks:void 0})},{})}getAdaptations(){return Zr(this)}getAdaptationsForType(e){let t=this.adaptations[e];return t!=null?t:[]}getAdaptation(e){return K(this.getAdaptations(),({id:t})=>e===t)}getSupportedAdaptations(e){return eo(this,e)}containsTime(e,t){return Xr(this,e,t)}getMetadataSnapshot(){let e={},t=this.getAdaptations();for(let r of t){let i=e[r.type];i===void 0&&(i=[],e[r.type]=i),i.push(r.getMetadataSnapshot())}return{start:this.start,end:this.end,id:this.id,streamEvents:this.streamEvents,adaptations:e}}};function Jt(n,e,t){let r={updatedAdaptations:[],removedAdaptations:[],addedAdaptations:[]};n.start=e.start,n.end=e.end,n.duration=e.duration,n.streamEvents=e.streamEvents;let i=n.getAdaptations(),a=e.getAdaptations();for(let o=0;o<i.length;o++){let s=i[o],u=ne(a,l=>l.id===s.id);if(u===-1){c.warn('Manifest: Adaptation \"'+i[o].id+'\" not found when merging.');let[l]=i.splice(o,1);o--,r.removedAdaptations.push({id:l.id,trackType:l.type})}else{let[l]=a.splice(u,1),d=[],f=[],m=[];r.updatedAdaptations.push({adaptation:s.id,trackType:s.type,updatedRepresentations:d,addedRepresentations:f,removedRepresentations:m});let p=s.representations,g=l.representations.slice();for(let I=0;I<p.length;I++){let h=p[I],y=ne(g,E=>E.id===h.id);if(y===-1){c.warn(`Manifest: Representation \"${p[I].id}\" not found when merging.`);let[E]=p.splice(I,1);I--,m.push(E.id)}else{let[E]=g.splice(y,1);d.push(h.getMetadataSnapshot()),h.cdnMetadata=E.cdnMetadata,t===0?h.index._replace(E.index):h.index._update(E.index)}}g.length>0&&(c.warn(`Manifest: ${g.length} new Representations found when merging.`),s.representations.push(...g),f.push(...g.map(I=>I.getMetadataSnapshot())))}}if(a.length>0){c.warn(`Manifest: ${a.length} new Adaptations found when merging.`);for(let o of a){let s=n.adaptations[o.type];s===void 0?n.adaptations[o.type]=[o]:s.push(o),r.addedAdaptations.push(o.getMetadataSnapshot())}}return r}function io(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},r=0;for(let a=0;a<e.length;a++){let o=e[a],s=r,u=n[s];for(;u!==void 0&&u.id!==o.id;)s++,u=n[s];if(u!==void 0){let l=Jt(u,o,0);t.updatedPeriods.push({period:{id:u.id,start:u.start,end:u.end,duration:u.duration,streamEvents:u.streamEvents},result:l});let d=e.slice(r,a),f=s-r,m=n.splice(r,f,...d);t.removedPeriods.push(...m.map(p=>({id:p.id,start:p.start,end:p.end}))),t.addedPeriods.push(...d.map(p=>p.getMetadataSnapshot())),r=a+1}}if(r>n.length)return c.error(\"Manifest: error when updating Periods\"),t;if(r<n.length){let a=n.splice(r,n.length-r);t.removedPeriods.push(...a.map(o=>({id:o.id,start:o.start,end:o.end})))}let i=e.slice(r,e.length);return i.length>0&&(n.push(...i),t.addedPeriods.push(...i.map(a=>a.getMetadataSnapshot()))),t}function ao(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]};if(n.length===0)return n.splice(0,0,...e),t.addedPeriods.push(...e.map(s=>s.getMetadataSnapshot())),t;if(e.length===0)return t;let r=n[n.length-1];if(r.start<e[0].start){if(r.end!==e[0].start)throw new j(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: not enough data\");return n.push(...e),t.addedPeriods.push(...e.map(s=>s.getMetadataSnapshot())),t}let i=ne(n,({id:s})=>s===e[0].id);if(i<0)throw new j(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: incoherent data\");let a=Jt(n[i],e[0],1);t.updatedPeriods.push({period:H(n[i].getMetadataSnapshot(),{adaptations:void 0}),result:a});let o=i+1;for(let s=1;s<e.length;s++){let u=e[s],l=-1;for(let d=o;d<n.length;d++)if(u.id===n[d].id){l=d;break}if(l<0){let d=-1;for(let p=o;p<n.length;p++)if(u.start<n[p].start){d=p;break}let f=d-o,m=n.splice(o,f,u);t.addedPeriods.push(u.getMetadataSnapshot()),t.removedPeriods.push(...m.map(p=>({id:p.id,start:p.start,end:p.end})))}else{if(l>o){c.warn(\"Manifest: old Periods not found in new when updating, removing\");let f=n.splice(o,l-o);t.removedPeriods.push(...f.map(m=>({id:m.id,start:m.start,end:m.end}))),l=o}let d=Jt(n[l],u,0);t.updatedPeriods.push({period:H(n[l].getMetadataSnapshot(),{adaptations:void 0}),result:d})}o++}if(o<n.length){c.warn(\"Manifest: Ending Periods not found in new when updating, removing\");let s=n.splice(o,n.length-o);t.removedPeriods.push(...s.map(u=>({id:u.id,start:u.start,end:u.end})))}return t}var hu=Ae(),en=class extends oe{constructor(e,t,r){var s;super();let{representationFilter:i,manifestUpdateUrl:a}=t;this.manifestFormat=0,this.id=hu(),this.expired=(s=e.expired)!=null?s:null,this.transport=e.transportType,this.clockOffset=e.clockOffset;let o=[];if(this.periods=e.periods.map(u=>new lt(u,o,i)).sort((u,l)=>u.start-l.start),o.length>0){let u=new j(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"An Adaptation contains only incompatible codecs.\",{tracks:o.map(dt)});r.push(u)}this.adaptations=this.periods[0]===void 0?{}:this.periods[0].adaptations,this.timeBounds=e.timeBounds,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.uris=e.uris===void 0?[]:e.uris,this.updateUrl=a,this.lifetime=e.lifetime,this.clockOffset=e.clockOffset,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.availabilityStartTime=e.availabilityStartTime,this.publishTime=e.publishTime}refreshCodecSupport(e){let t=[];for(let r of this.periods)r.refreshCodecSupport(e,t);return t.length>0?new j(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"An Adaptation contains only incompatible codecs.\",{tracks:t.map(dt)}):null}getPeriod(e){return K(this.periods,t=>e===t.id)}getPeriodForTime(e){return to(this,e)}getNextPeriod(e){return K(this.periods,t=>t.start>e)}getPeriodAfter(e){return no(this,e)}getUrls(){return this.uris}replace(e){this._performUpdate(e,0)}update(e){this._performUpdate(e,1)}getMinimumSafePosition(){return Xa(this)}getLivePosition(){return Za(this)}getMaximumSafePosition(){return Ja(this)}updateRepresentationsDeciperability(e){let t=Iu(this,e);t.length>0&&this.trigger(\"decipherabilityUpdate\",t)}getAdaptations(){Xe(\"manifest.getAdaptations() is deprecated. Please use manifest.period[].getAdaptations() instead\");let e=this.periods[0];if(e===void 0)return[];let t=e.adaptations,r=[];for(let i in t)if(t.hasOwnProperty(i)){let a=t[i];r.push(...a)}return r}getAdaptationsForType(e){Xe(\"manifest.getAdaptationsForType(type) is deprecated. Please use manifest.period[].getAdaptationsForType(type) instead\");let t=this.periods[0];if(t===void 0)return[];let r=t.adaptations[e];return r===void 0?[]:r}getAdaptation(e){return Xe(\"manifest.getAdaptation(id) is deprecated. Please use manifest.period[].getAdaptation(id) instead\"),K(this.getAdaptations(),({id:t})=>e===t)}getMetadataSnapshot(){let e=[];for(let t of this.periods)e.push(t.getMetadataSnapshot());return{manifestFormat:1,id:this.id,periods:e,isDynamic:this.isDynamic,isLive:this.isLive,isLastPeriodKnown:this.isLastPeriodKnown,suggestedPresentationDelay:this.suggestedPresentationDelay,clockOffset:this.clockOffset,uris:this.uris,availabilityStartTime:this.availabilityStartTime,timeBounds:this.timeBounds}}_performUpdate(e,t){this.availabilityStartTime=e.availabilityStartTime,this.expired=e.expired,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.lifetime=e.lifetime,this.clockOffset=e.clockOffset,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.transport=e.transport,this.publishTime=e.publishTime;let r;if(t===0)this.timeBounds=e.timeBounds,this.uris=e.uris,r=io(this.periods,e.periods);else{this.timeBounds.maximumTimeData=e.timeBounds.maximumTimeData,this.updateUrl=e.uris[0],r=ao(this.periods,e.periods);let i=this.getMinimumSafePosition();for(;this.periods.length>0;){let a=this.periods[0];if(a.end===void 0||a.end>i)break;this.periods.shift()}}this.adaptations=this.periods[0]===void 0?{}:this.periods[0].adaptations,this.trigger(\"manifestUpdate\",r)}};function Iu(n,e){let t=[];for(let r of n.periods)for(let i of r.getAdaptations())for(let a of i.representations){let o={manifest:n,period:r,adaptation:i,representation:a},s=e(o);s!==a.decipherable&&(t.push(o),a.decipherable=s,c.debug(`Decipherability changed for \"${a.id}\"`,`(${a.bitrate})`,String(a.decipherable)))}return t}function Ze(n,e){return n.segment.id===e.segment.id&&n.representation.uniqueId===e.representation.uniqueId}function St(n){if(R(n))return\"\";let{period:e,adaptation:t,representation:r,segment:i}=n,a;return i.isInit?a=\"init\":i.complete?a=`${i.time}-${i.duration}`:a=`${i.time}`,`${t.type} P: ${e.id} A: ${t.id} R: ${r.id} S: ${a}`}var wt=en;var ft=Ee,yt=ft===void 0?void 0:R(ft.MediaSource)?R(ft.MozMediaSource)?R(ft.WebKitMediaSource)?ft.MSMediaSource:ft.WebKitMediaSource:ft.MozMediaSource:ft.MediaSource;var bu=200,or=new Map;function Jr(n){if(R(yt))return st&&c.error(\"Compat: Cannot request codec support in a worker without MSE.\"),!1;if(typeof yt.isTypeSupported==\"function\"){let e=or.get(n);if(e!==void 0)return e;{let t=yt.isTypeSupported(n);return or.size>=bu&&or.clear(),or.set(n,t),t}}return!0}var Su=50,ei=class{constructor(){this._cachedCodecSupport=new Map}isSupported(e,t){let r=`${e!=null?e:\"\"};codecs=\"${t!=null?t:\"\"}\"`,i=this._cachedCodecSupport.get(r);if(i!==void 0)return i;this._cachedCodecSupport.size>=Su&&this._cachedCodecSupport.clear();let a=Jr(r);return this._cachedCodecSupport.set(r,a),a}},yu=new ei,oo=yu;var ti=class{constructor(){this._currentCacheSize=0,this._cachedCodecSupport=new Map}isSupported(e,t){var i;let r=(i=this._cachedCodecSupport.get(e))==null?void 0:i.get(t);if(r!==void 0)return r}updateCache(e,t,r){this._currentCacheSize>=50&&(this._cachedCodecSupport.clear(),this._currentCacheSize=0);let i=this._cachedCodecSupport.get(e);if(i!==void 0)i.set(t,r);else{let a=new Map;a.set(t,r),this._cachedCodecSupport.set(e,a)}}},so=new ti;var sr=class n extends Error{constructor(e){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"AssertionError\",this.message=e}};function he(n,e){if(b.DEV===b.CURRENT_ENV&&!n)throw new sr(e===void 0?\"invalid assertion\":e)}function ze(n){throw new sr(\"Unreachable path taken\")}var Tu=\"<\";var uo=\">\";var _u=`\\r\n\t>/= `;function ni(n,e={}){var m,p;let t=(m=e.pos)!=null?m:0,r=e.keepComments===!0,i=e.keepWhitespace===!0,a;if(e.attrValue!==void 0)for(e.attrName=(p=e.attrName)!=null?p:\"id\",a=[];(t=f())!==-1;)t=n.lastIndexOf(\"<\",t),t!==-1&&a.push(l()),n=n.substring(t),t=0;else a=o(\"\");return e.filter&&(a=lo(a,e.filter)),a;function o(g){let I=[];for(;n[t];)if(n.charCodeAt(t)===60){if(n.charCodeAt(t+1)===47){let y=t+2;if(t=n.indexOf(uo,t),n.substring(y,t).indexOf(g)===-1){let v=n.substring(0,t).split(`\n`);throw new Error(`Unexpected close tag\nLine: `+(v.length-1)+`\nColumn: `+(v[v.length-1].length+1)+`\nChar: `+n[t])}return t!==-1&&(t+=1),I}else if(n.charCodeAt(t+1)===33){if(n.charCodeAt(t+2)===45){let y=t;for(;t!==-1&&!(n.charCodeAt(t)===62&&n.charCodeAt(t-1)===45&&n.charCodeAt(t-2)===45);)t=n.indexOf(uo,t+1);t===-1&&(t=n.length),r&&I.push(n.substring(y,t+1))}else if(n.charCodeAt(t+2)===91&&n.charCodeAt(t+8)===91&&n.substring(t+3,t+8).toLowerCase()===\"cdata\"){let y=n.indexOf(\"]]>\",t);y===-1?(I.push(n.substring(t+9)),t=n.length):(I.push(n.substring(t+9,y)),t=y+3);continue}else{let y=t+1;t+=2;let E=!1;for(;(n.charCodeAt(t)!==62||E)&&n[t];)n.charCodeAt(t)===91?E=!0:E&&n.charCodeAt(t)===93&&(E=!1),t++;I.push(n.substring(y,t))}t++;continue}let h=l();I.push(h),h.tagName[0]===\"?\"&&(I.push(...h.children),h.children=[])}else{let h=s();if(i)h.length>0&&I.push(h);else{let y=h.trim();y.length>0&&I.push(y)}t++}return I}function s(){let g=t;return t=n.indexOf(Tu,t)-1,t===-2&&(t=n.length),n.slice(g,t+1)}function u(){let g=t;for(;_u.indexOf(n[t])===-1&&n[t];)t++;return n.slice(g,t)}function l(){let g=t;t++;let I=u(),h={},y=[];for(;n.charCodeAt(t)!==62&&n[t];){let E=n.charCodeAt(t);if(E>64&&E<91||E>96&&E<123){let v=u(),T=n.charCodeAt(t);for(;T&&T!==39&&T!==34&&!(T>64&&T<91||T>96&&T<123)&&T!==62;)t++,T=n.charCodeAt(t);let C;T===39||T===34?C=d():(C=null,t--),h[v]=C===null?null:fo(C)}t++}return n.charCodeAt(t-1)!==47?(t++,y=o(I)):t++,{tagName:I,attributes:h,children:y,posStart:g,posEnd:t}}function d(){let g=n[t],I=t+1;return t=n.indexOf(g,I),n.slice(I,t)}function f(){let g=new RegExp(\"\\\\s\"+e.attrName+`\\\\s*=['\"]`+e.attrValue+`['\"]`).exec(n);return g?g.index:-1}}function lo(n,e,t=0,r=\"\"){let i=[];return n.forEach(function(a,o){if(typeof a==\"object\"&&(e(a,o,t,r)&&i.push(a),a.children.length>0)){let s=lo(a.children,e,t+1,(r?r+\".\":\"\")+o+\".\"+a.tagName);i=i.concat(s)}}),i}function ur(n){if(Array.isArray(n)){let e=\"\";return n.forEach(function(t){e+=\" \"+ur(t),e=e.trim()}),e}else return typeof n==\"object\"?ur(n.children):\" \"+fo(n)}function fo(n){return n.indexOf(\"&\")<0?n:n.replace(/</g,\"<\").replace(/>/g,\">\").replace(/"/g,'\"').replace(/'/g,\"'\").replace(/&#x([A-Fa-f0-9]+);/g,(e,t)=>String.fromCharCode(parseInt(t,16))).replace(/&/g,\"&\")}function ri(n,e,t){let{repeatCount:r}=n;if(r>=0)return r;let i;return R(e)?t!==void 0?i=t:i=Number.MAX_VALUE:i=e.start,Math.ceil((i-n.start)/n.duration)-1}function De(n,e,t){let{start:r,duration:i}=n;if(i<=0)return r;let a=ri(n,e,t);return r+(a+1)*i}function Pe(n,e){var t;return n*e.timescale+((t=e.indexTimeOffset)!=null?t:0)}function je(n,e){var t;return(n-((t=e.indexTimeOffset)!=null?t:0))/e.timescale}function mo(n,e,t){return[n*t,(n+e)*t]}function Eu(n,e){let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i].start<=e?t=i+1:r=i}return t-1}function co(n,e,t){let{timeline:r}=n,i=Pe(e,n);if(i<0)return null;let a=Eu(r,i);if(a<0||a>=r.length-1)return null;let o=r[a];if(o.duration<=0)return null;let s=r[a+1];if(s===void 0)return null;let u=s.start,l=De(o,s,t);return i>=l&&i<u?je(u,n):null}function Je(n,e){var i;let{initialization:t}=n,r={};return e!==void 0&&(r.isEMSGWhitelisted=e),{id:\"init\",isInit:!0,time:0,end:0,duration:0,timescale:1,range:R(t)?void 0:t.range,indexRange:n.indexRange,url:(i=t==null?void 0:t.url)!=null?i:null,complete:!0,privateInfos:r,timestampOffset:-(n.indexTimeOffset/n.timescale)}}function Ru(n,e){let t=n.toString();return t.length>=e?t:(new Array(e+1).join(\"0\")+t).slice(-e)}function ii(n){return(e,t,r)=>{let i=Z(r)?parseInt(r,10):1;return Ru(String(n),i)}}function Ne(n,e,t){return Pu(n,e,t)}function Pu(n,e,t){return n.indexOf(\"$\")===-1?n:n.replace(/\\$\\$/g,\"$\").replace(/\\$RepresentationID\\$/g,String(e)).replace(/\\$Bandwidth(\\%0(\\d+)d)?\\$/g,ii(t===void 0?0:t))}function dr(n,e){return function(r){return r.indexOf(\"$\")===-1?r:r.replace(/\\$\\$/g,\"$\").replace(/\\$Number(\\%0(\\d+)d)?\\$/g,(i,a,o)=>{if(e===void 0)throw new Error(\"Segment number not defined in a $Number$ scheme\");return ii(e)(i,a,o)}).replace(/\\$Time(\\%0(\\d+)d)?\\$/g,(i,a,o)=>{if(n===void 0)throw new Error(\"Segment time not defined in a $Time$ scheme\");return ii(n)(i,a,o)})}}function vu(n,e,t){let r=t-n;return r>0?Math.floor(r/e):0}function tn(n,e,t,r,i,a){var E;let o=r.getEstimatedMaximumPosition((E=n.availabilityTimeOffset)!=null?E:0),s=Math.min(e+t,o!=null?o:1/0),u=Pe(e,n),l=Pe(s,n),{timeline:d,timescale:f,segmentUrlTemplate:m,startNumber:p,endNumber:g}=n,I=p!=null?p:1,h=[],y=d.length;for(let v=0;v<y;v++){let T=d[v],{duration:C,start:P,range:M}=T,_;o===void 0?_=i:_=Math.min(o*f,i!=null?i:1/0);let A=ri(T,d[v+1],_),x=n.availabilityTimeComplete!==!1||v!==y-1&&A!==0,k=vu(P,C,u),D=P+k*C;for(;D<l&&k<=A;){let w=I+k;if(g!==void 0&&w>g)break;let O=m===null?null:dr(D,w)(m),B=D-n.indexTimeOffset,z=C;B<0&&(z=C+B,B=0);let q={id:String(D),time:B/f,end:(B+z)/f,duration:z/f,isInit:!1,range:M,timescale:1,url:O,number:w,timestampOffset:-(n.indexTimeOffset/f),complete:x,privateInfos:{isEMSGWhitelisted:a}};h.push(q),k++,D=P+k*C}if(D>=l||(I+=A+1,g!==void 0&&I>g))return h}return h}function Cu(n,e){if(e.timescale!==n.timescale){let{timescale:t}=n;n.timeline.push({start:e.time/e.timescale*t,duration:e.duration/e.timescale*t,repeatCount:e.count===void 0?0:e.count,range:e.range})}else n.timeline.push({start:e.time,duration:e.duration,repeatCount:e.count===void 0?0:e.count,range:e.range});return!0}var Tt=class{constructor(e,t){var g,I,h,y;let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t,u=(g=e.timescale)!=null?g:1,d=((I=e.presentationTimeOffset)!=null?I:0)-r*u,f=((h=e.initialization)==null?void 0:h.media)===void 0?null:Ne(e.initialization.media,a,o),m=e.media===void 0?null:Ne(e.media,a,o),p;e.initialization!==void 0?p=e.initialization.range:e.indexRange!==void 0&&(p=[0,e.indexRange[0]-1]),this._index={indexRange:e.indexRange,indexTimeOffset:d,initialization:{url:f,range:p},segmentUrlTemplate:m,startNumber:e.startNumber,endNumber:e.endNumber,timeline:(y=e.timeline)!=null?y:[],timescale:u},this._manifestBoundsCalculator=t.manifestBoundsCalculator,this._scaledPeriodStart=Pe(r,this._index),this._scaledPeriodEnd=R(i)?void 0:Pe(i,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=s}getInitSegment(){return Je(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return tn(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){let e=this._index;return e.timeline.length===0?null:je(Math.max(this._scaledPeriodStart,e.timeline[0].start),e)}getLastAvailablePosition(){var i;let{timeline:e}=this._index;if(e.length===0)return null;let t=e[e.length-1],r=Math.min(De(t,null,this._scaledPeriodEnd),(i=this._scaledPeriodEnd)!=null?i:1/0);return je(r,this._index)}getEnd(){return this.getLastAvailablePosition()}awaitSegmentBetween(){return!1}isSegmentStillAvailable(){return!0}checkDiscontinuity(){return null}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){return!1}isInitialized(){return this._isInitialized}initialize(e){if(!this._isInitialized){for(let t=0;t<e.length;t++)Cu(this._index,e[t]);this._isInitialized=!0}}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `BaseRepresentationIndex`\")}_replace(e){this._index=e._index,this._isInitialized=e._isInitialized,this._scaledPeriodEnd=e._scaledPeriodEnd,this._isEMSGWhitelisted=e._isEMSGWhitelisted}_update(){c.error(\"Base RepresentationIndex: Cannot update a SegmentList\")}};var _t=class{constructor(e,t){var p,g,I;if(e.duration===void 0)throw new Error(\"Invalid SegmentList: no duration\");let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t;this._isEMSGWhitelisted=s,this._periodStart=r,this._periodEnd=i;let u=(p=e.presentationTimeOffset)!=null?p:0,l=(g=e.timescale)!=null?g:1,d=u-r*l,f=((I=e.initialization)==null?void 0:I.media)===void 0?null:Ne(e.initialization.media,a,o),m=e.list.map(h=>({url:h.media===void 0?null:Ne(h.media,a,o),mediaRange:h.mediaRange}));this._index={list:m,timescale:l,duration:e.duration,indexTimeOffset:d,indexRange:e.indexRange,initialization:R(e.initialization)?void 0:{url:f,range:e.initialization.range}}}getInitSegment(){let e=Je(this._index);return e.privateInfos===void 0&&(e.privateInfos={}),e.privateInfos.isEMSGWhitelisted=this._isEMSGWhitelisted,e}getSegments(e,t){let r=this._index,{duration:i,list:a,timescale:o}=r,s=i/o,u=e-this._periodStart,[l,d]=mo(u,t,o),f=Math.min(a.length-1,Math.floor(d/i)),m=[],p=Math.floor(l/i);for(;p<=f;){let g=a[p].mediaRange,I=a[p].url,h=p*s+this._periodStart,y={id:String(p),time:h,isInit:!1,range:g,duration:s,timescale:1,end:h+s,url:I,timestampOffset:-(r.indexTimeOffset/o),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};m.push(y),p++}return m}shouldRefresh(e,t){return!1}getFirstAvailablePosition(){return this._periodStart}getLastAvailablePosition(){var i;let e=this._index,{duration:t,list:r}=e;return Math.min(r.length*t/e.timescale+this._periodStart,(i=this._periodEnd)!=null?i:1/0)}getEnd(){return this.getLastAvailablePosition()}awaitSegmentBetween(){return!1}isSegmentStillAvailable(){return!0}checkDiscontinuity(){return null}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){return!1}isInitialized(){return!0}initialize(){c.error(\"A `ListRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `ListRepresentationIndex`\")}_replace(e){this._index=e._index}_update(){c.error(\"A `ListRepresentationIndex` cannot be updated\")}};function Dt(n){return U.getCurrent().DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR*n}var Et=class{constructor(e,t){var y,E,v;let{availabilityTimeOffset:r,manifestBoundsCalculator:i,isDynamic:a,periodEnd:o,periodStart:s,representationId:u,representationBitrate:l,isEMSGWhitelisted:d}=t,f=(y=e.timescale)!=null?y:1;this._availabilityTimeOffset=r,this._manifestBoundsCalculator=i;let m=(E=e.presentationTimeOffset)!=null?E:0,p=s*f,g=m-p;if(e.duration===void 0)throw new Error(\"Invalid SegmentTemplate: no duration\");let I=((v=e.initialization)==null?void 0:v.media)===void 0?null:Ne(e.initialization.media,u,l),h=e.media===void 0?null:Ne(e.media,u,l);this._index={duration:e.duration,timescale:f,indexRange:e.indexRange,indexTimeOffset:g,initialization:R(e.initialization)?void 0:{url:I,range:e.initialization.range},url:h,presentationTimeOffset:m,startNumber:e.startNumber,endNumber:e.endNumber},this._isDynamic=a,this._periodStart=s,this._scaledRelativePeriodEnd=o===void 0?void 0:(o-s)*f,this._isEMSGWhitelisted=d}getInitSegment(){return Je(this._index,this._isEMSGWhitelisted)}getSegments(e,t){let r=this._index,{duration:i,startNumber:a,endNumber:o,timescale:s,url:u}=r,l=this._periodStart*s,d=this._scaledRelativePeriodEnd,f=e*s-l,m=(e+t)*s-l,p=this._getFirstSegmentStart(),g=this._getLastSegmentStart();if(R(p)||R(g))return[];let I=Math.max(p,f),h=Math.min(g,m);if(h+i<=I)return[];let y=[],E=a!=null?a:1,v=Math.floor(I/i);for(let T=v*i;T<=h;T+=i){let C=v+E;if(o!==void 0&&C>o)return y;let P=!R(d)&&T+i>d?d-T:i,M=T+l,_=T+this._index.presentationTimeOffset,A=u===null?null:dr(_,C)(u),x={id:String(C),number:C,time:M/s,end:(M+P)/s,duration:P/s,timescale:1,isInit:!1,scaledDuration:P/s,url:A,timestampOffset:-(r.indexTimeOffset/s),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};y.push(x),v++}return y}getFirstAvailablePosition(){let e=this._getFirstSegmentStart();return R(e)?e:e/this._index.timescale+this._periodStart}getLastAvailablePosition(){let e=this._getLastSegmentStart();if(R(e))return e;let t=this._estimateRelativeScaledEnd();return Math.min(e+this._index.duration,t!=null?t:1/0)/this._index.timescale+this._periodStart}getEnd(){if(!this._isDynamic)return this.getLastAvailablePosition();let e=this._estimateRelativeScaledEnd();if(e===void 0)return;let{timescale:t}=this._index;return(e+this._periodStart*t)/t}awaitSegmentBetween(e,t){if(he(e<=t),!this._isDynamic)return!1;let{timescale:r}=this._index,i=Dt(r),a=this._periodStart*r,o=e*r-a,s=t*r-a,u=this._getLastSegmentStart();if(R(u)){let f=this._estimateRelativeScaledEnd();return f===void 0?s+i>=0:s+i>=0&&o<f-i}let l=u+this._index.duration,d=this._estimateRelativeScaledEnd();return d===void 0?s>l-i:s>l-i&&o<d-i}shouldRefresh(){return!1}checkDiscontinuity(){return null}isSegmentStillAvailable(e){if(e.isInit)return!0;let t=this.getSegments(e.time,.1);return t.length===0?!1:t[0].time===e.time&&t[0].end===e.end&&t[0].number===e.number}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){if(!this._isDynamic)return!1;let e=this._estimateRelativeScaledEnd();if(e===void 0)return!0;let{timescale:t}=this._index,r=this._getLastSegmentStart();if(R(r))return!0;let i=r+this._index.duration,a=Dt(t);return i+a<e}isInitialized(){return!0}initialize(){c.error(\"A `TemplateRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `TemplateRepresentationIndex`\")}_replace(e){this._index=e._index,this._isDynamic=e._isDynamic,this._periodStart=e._periodStart,this._scaledRelativePeriodEnd=e._scaledRelativePeriodEnd,this._manifestBoundsCalculator=e._manifestBoundsCalculator}_update(e){this._replace(e)}_getFirstSegmentStart(){var o;if(!this._isDynamic)return 0;if(this._scaledRelativePeriodEnd===0||this._scaledRelativePeriodEnd===void 0){let s=this._manifestBoundsCalculator.getEstimatedMaximumPosition((o=this._availabilityTimeOffset)!=null?o:0);if(s!==void 0&&s<this._periodStart)return null}let{duration:e,timescale:t}=this._index,r=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();if(r===void 0)return;let i=r>this._periodStart?(r-this._periodStart)*t:0;return Math.floor(i/e)*e}_getLastSegmentStart(){var a,o;let{duration:e,timescale:t,endNumber:r,startNumber:i=1}=this._index;if(this._isDynamic){let s=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(s!==void 0&&this._scaledRelativePeriodEnd!==void 0&&this._scaledRelativePeriodEnd<s-this._periodStart*this._index.timescale){let f=Math.ceil(this._scaledRelativePeriodEnd/e);return r!==void 0&&r-i+1<f&&(f=r-i+1),(f-1)*e}let u=this._manifestBoundsCalculator.getEstimatedMaximumPosition((a=this._availabilityTimeOffset)!=null?a:0);if(u===void 0)return;let l=(u-this._periodStart)*t;if(l<0)return null;let d=Math.floor(l/e);return r!==void 0&&r-i+1<d&&(d=r-i+1),d<=0?null:(d-1)*e}else{let s=(o=this._scaledRelativePeriodEnd)!=null?o:0,u=Math.ceil(s/e);r!==void 0&&r-i+1<u&&(u=r-i+1);let l=(u-1)*e,d=U.getCurrent().MINIMUM_SEGMENT_SIZE*t;return r!==void 0||s-l>d||u<2?l:(u-2)*e}}_estimateRelativeScaledEnd(){var e,t;if(this._index.endNumber!==void 0){let r=this._index.endNumber-((e=this._index.startNumber)!=null?e:1)+1;return Math.max(Math.min(r*this._index.duration,(t=this._scaledRelativePeriodEnd)!=null?t:1/0),0)}if(this._scaledRelativePeriodEnd!==void 0)return Math.max(this._scaledRelativePeriodEnd,0)}};function ai(n,e){let t=0;for(;n.length>0;){let r=n[0];if(r.start>=e||r.repeatCount===-1)return t;if(r.repeatCount===0)n.shift(),t+=1;else{let i=n[1];if(i!==void 0&&i.start<=e)n.shift(),t+=1;else{if(r.duration<=0)return t;let a=r.start+r.duration,o=1;for(;a<e&&o<=r.repeatCount;)a+=r.duration,o++;if(o>r.repeatCount)n.shift(),t=r.repeatCount+1;else{let s=r.repeatCount-o;return r.start=a,r.repeatCount=s,t+=o,t}}}}return t}function oi(n,e){if(n.length===0)return n.push(...e),!0;if(e.length===0)return!1;let t=n.length,r=e[0].start,i=n[t-1];if(De(i,e[0])<r)throw new j(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: not enough data\");for(let d=t-1;d>=0;d--){let f=n[d].start;if(f===r){let m=t-d;return n.splice(d,m,...e),!1}else if(f<r){let m=n[d];if(m.start+m.duration>r)return c.warn(\"RepresentationIndex: Manifest update removed all previous segments\"),n.splice(0,t,...e),!0;if(m.repeatCount===void 0||m.repeatCount<=0)return m.repeatCount<0&&(m.repeatCount=Math.floor((r-m.start)/m.duration)-1),n.splice(d+1,t-(d+1),...e),!1;if(m.start+m.duration*(m.repeatCount+1)<=r)return n.splice(d+1,t-(d+1),...e),!1;let g=(r-m.start)/m.duration-1;if(g%1===0&&m.duration===e[0].duration){let I=e[0].repeatCount<0?-1:e[0].repeatCount+g+1;return n.splice(d,t-d,...e),n[d].start=m.start,n[d].repeatCount=I,!1}return c.warn(\"RepresentationIndex: Manifest update removed previous segments\"),n[d].repeatCount=Math.floor(g),n.splice(d+1,t-(d+1),...e),!1}}let o=n[n.length-1],s=e[e.length-1];if(o.repeatCount!==void 0&&o.repeatCount<0)return o.start>s.start?(c.warn(\"RepresentationIndex: The new index is older than the previous one\"),!1):(c.warn('RepresentationIndex: The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0);let u=o.start+o.duration*(o.repeatCount+1),l=s.start+s.duration*(s.repeatCount+1);return u>=l?(c.warn(\"RepresentationIndex: The new index is older than the previous one\"),!1):(c.warn('RepresentationIndex: The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0)}function nn(n,e,t){let r=n.start,i=n.duration,a=n.repeatCount;return r===void 0&&(e===null?r=0:R(e.duration)||(r=e.start+e.duration*(e.repeatCount+1))),(i===void 0||isNaN(i))&&t!==null&&t.start!==void 0&&!isNaN(t.start)&&r!==void 0&&!isNaN(r)&&(i=t.start-r),r!==void 0&&!isNaN(r)&&i!==void 0&&!isNaN(i)&&(a===void 0||!isNaN(a))?{start:r,duration:i,repeatCount:a===void 0?0:a}:(c.warn('DASH: A \"S\" Element could not have been parsed.'),null)}function rn(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!R(r))switch(t){case\"t\":let i=parseInt(r,10);isNaN(i)?c.warn(`DASH: invalid t (\"${r}\")`):e.start=i;break;case\"d\":let a=parseInt(r,10);isNaN(a)?c.warn(`DASH: invalid d (\"${r}\")`):e.duration=a;break;case\"r\":let o=parseInt(r,10);isNaN(o)?c.warn(`DASH: invalid r (\"${r}\")`):e.repeatCount=o;break}}return e}function an(n){let e={};for(let t=0;t<n.attributes.length;t++){let r=n.attributes[t];switch(r.name){case\"t\":let i=parseInt(r.value,10);isNaN(i)?c.warn(`DASH: invalid t (\"${r.value}\")`):e.start=i;break;case\"d\":let a=parseInt(r.value,10);isNaN(a)?c.warn(`DASH: invalid d (\"${r.value}\")`):e.duration=a;break;case\"r\":let o=parseInt(r.value,10);isNaN(o)?c.warn(`DASH: invalid r (\"${r.value}\")`):e.repeatCount=o;break}}return e}function mt(n){let e=[];if(Array.isArray(n))for(let r=0;r<n.length;r++)e.push(rn(n[r]));else for(let r=0;r<n.length;r++)e.push(an(n[r]));let t=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[t.length-1]===void 0?null:t[t.length-1],o=e[r+1]===void 0?null:e[r+1],s=nn(i,a,o);s!==null&&t.push(s)}return t}function si(n,e){if(n.length===0||e.length===0)return null;let t=n[0].start,r=Array.isArray(e)?e[0].attributes.t:e[0].getAttribute(\"t\"),i=R(r)?null:parseInt(r,10);if(i===null||Number.isNaN(i))return null;if(t===i)return{prevSegmentsIdx:0,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(t<i){let a=n[0],o=0;for(;;){if(a.repeatCount>0){let s=i-a.start;if(s%a.duration===0&&s/a.duration<=a.repeatCount)return{repeatNumberInPrevSegments:s/a.duration,prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInNewElements:0}}if(o++,o>=n.length)return null;if(a=n[o],a.start===i)return{prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(a.start>i)return null}}else{let a=0,o=Array.isArray(e)?e[0]:null,s=Array.isArray(e)?null:e[0],u=i;for(;;){let l=o!==null?o.attributes.d:s==null?void 0:s.getAttribute(\"d\"),d=R(l)?null:parseInt(l,10);if(d===null||Number.isNaN(d))return null;let f=o!==null?o.attributes.r:s==null?void 0:s.getAttribute(\"r\"),m=R(f)?null:parseInt(f,10);if(m!==null){if(Number.isNaN(m)||m<0)return null;if(m>0){let I=t-u;if(I%d===0&&I/d<=m)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:I/d,prevSegmentsIdx:0,newElementsIdx:a}}u+=d*(m+1)}else u+=d;if(a++,a>=e.length)return null;Array.isArray(e)?o=e[a]:s=e[a];let p=o!==null?o.attributes.t:s==null?void 0:s.getAttribute(\"t\"),g=R(p)?null:parseInt(p,10);if(g!==null){if(Number.isNaN(g))return null;u=g}if(u===t)return{newElementsIdx:a,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(u>i)return null}}}function ui(n,e){var I;let t=si(e,n);if(t===null)return c.warn('DASH: Cannot perform \"based\" update. Common segment not found.'),mt(n);let{prevSegmentsIdx:r,newElementsIdx:i,repeatNumberInPrevSegments:a,repeatNumberInNewElements:o}=t,u=e.length-r+i-1;if(u>=n.length)return c.info('DASH: Cannot perform \"based\" update. New timeline too short'),mt(n);let l=e.slice(r);if(a>0){let h=l[0];h.start+=h.duration*a,l[0].repeatCount-=a}if(o>0&&i!==0)return c.info('DASH: Cannot perform \"based\" update. The new timeline has a different form.'),mt(n);let d=l[l.length-1],f=Array.isArray(n)?rn(n[u]):an(n[u]),m=((I=f.repeatCount)!=null?I:0)-o;if(f.duration!==d.duration||d.repeatCount>m)return c.info('DASH: Cannot perform \"based\" update. The new timeline has a different form at the beginning.'),mt(n);f.repeatCount!==void 0&&f.repeatCount>d.repeatCount&&(d.repeatCount=f.repeatCount);let p=[],g=[];if(Array.isArray(n))for(let h=u+1;h<n.length;h++)g.push(rn(n[h]));else for(let h=u+1;h<n.length;h++)g.push(an(n[h]));for(let h=0;h<g.length;h++){let y=g[h],E=p[p.length-1]===void 0?d:p[p.length-1],v=g[h+1]===void 0?null:g[h+1],T=nn(y,E,v);T!==null&&p.push(T)}return l.concat(p)}var on=class n{constructor(e,t){var T,C,P,M,_;if(!n.isTimelineIndexArgument(e))throw new Error(\"The given index is not compatible with a TimelineRepresentationIndex.\");let{availabilityTimeComplete:r,availabilityTimeOffset:i,manifestBoundsCalculator:a,isDynamic:o,isLastPeriod:s,representationId:u,representationBitrate:l,periodStart:d,periodEnd:f,isEMSGWhitelisted:m}=t,p=(T=e.timescale)!=null?T:1,g=(C=e.presentationTimeOffset)!=null?C:0,I=d*p,h=g-I;this._manifestBoundsCalculator=a,this._isEMSGWhitelisted=m,this._isLastPeriod=s,this._lastUpdate=(P=t.receivedTime)!=null?P:L(),this._unsafelyBaseOnPreviousIndex=null,t.unsafelyBaseOnPreviousRepresentation!==null&&t.unsafelyBaseOnPreviousRepresentation.index instanceof n&&(t.unsafelyBaseOnPreviousRepresentation.index._unsafelyBaseOnPreviousIndex=null,this._unsafelyBaseOnPreviousIndex=t.unsafelyBaseOnPreviousRepresentation.index),this._isDynamic=o,this._parseTimeline=(M=e.timelineParser)!=null?M:null;let y=((_=e.initialization)==null?void 0:_.media)===void 0?null:Ne(e.initialization.media,u,l),E=e.media===void 0?null:Ne(e.media,u,l),v;i===void 0&&r===void 0?v=1/0:v=i!=null?i:0,this._index={availabilityTimeComplete:r!=null?r:!0,availabilityTimeOffset:v,indexRange:e.indexRange,indexTimeOffset:h,initialization:R(e.initialization)?void 0:{url:y,range:e.initialization.range},segmentUrlTemplate:E,startNumber:e.startNumber,endNumber:e.endNumber,timeline:e.timeline===void 0?null:di(e.timeline,e.startNumber,e.endNumber),timescale:p},this._scaledPeriodStart=Pe(d,this._index),this._scaledPeriodEnd=f===void 0?void 0:Pe(f,this._index)}getInitSegment(){return Je(this._index,this._isEMSGWhitelisted)}getSegments(e,t){this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let{segmentUrlTemplate:r,startNumber:i,endNumber:a,timeline:o,timescale:s,indexTimeOffset:u}=this._index;return tn({segmentUrlTemplate:r,startNumber:i,endNumber:a,timeline:o,timescale:s,indexTimeOffset:u},e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let e=this._index.timeline;return e.length===0?null:je(Math.max(this._scaledPeriodStart,e[0].start),this._index)}getLastAvailablePosition(){var r;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let e=lr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(e===null)return null;let t=Math.min(e.end,(r=this._scaledPeriodEnd)!=null?r:1/0);return je(t,this._index)}getEnd(){var r;if(this._isDynamic&&!this._isLastPeriod)return;if(this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),this._index.timeline.length<=0)return null;let e=this._index.timeline[this._index.timeline.length-1],t=Math.min(De(e,null,this._scaledPeriodEnd),(r=this._scaledPeriodEnd)!=null?r:1/0);return je(t,this._index)}awaitSegmentBetween(e,t){var l,d;if(he(e<=t),!this._isDynamic)return!1;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let{timescale:r,timeline:i}=this._index,a=Dt(r),o=Pe(t,this._index),s=lr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(s!==null&&Math.min(s.end,(l=this._scaledPeriodEnd)!=null?l:1/0)+a>=Math.min(o,(d=this._scaledPeriodEnd)!=null?d:1/0))return!1;let u=Pe(e,this._index);if(i.length>0&&s!==null&&!s.isLastOfTimeline){let f=i[i.length-1],p=De(f,null,this._scaledPeriodEnd)+a;if(u<p+a)return!0}return this._isLastPeriod?this._scaledPeriodEnd===void 0?o+a>this._scaledPeriodStart?void 0:!1:u-a<this._scaledPeriodEnd&&o+a>this._scaledPeriodStart:!1}isSegmentStillAvailable(e){return e.isInit?!0:(this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),Au(e,this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd))}checkDiscontinuity(e){this._refreshTimeline();let t=this._index.timeline;return t===null&&(t=this._getTimeline(),this._index.timeline=t),co({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)}canBeOutOfSyncError(e){return this._isDynamic?e instanceof Ke&&e.isHttpError(404):!1}_replace(e){this._parseTimeline=e._parseTimeline,this._index=e._index,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._manifestBoundsCalculator=e._manifestBoundsCalculator,this._isLastPeriod=e._isLastPeriod}_update(e){this._index.timeline===null&&(this._index.timeline=this._getTimeline()),e._index.timeline===null&&(e._index.timeline=e._getTimeline()),oi(this._index.timeline,e._index.timeline)&&(this._index.startNumber=e._index.startNumber),this._index.availabilityTimeOffset=e._index.availabilityTimeOffset,this._index.availabilityTimeComplete=e._index.availabilityTimeComplete,this._index.endNumber=e._index.endNumber,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._isLastPeriod=e._isLastPeriod}isStillAwaitingFutureSegments(){var o;if(!this._isDynamic)return!1;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let{timeline:e}=this._index;if(e.length===0){if(this._scaledPeriodEnd!==void 0){let s=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(s!==void 0&&Pe(s,this._index)>this._scaledPeriodEnd)return!1}return this._isLastPeriod}let t=Dt(this._index.timescale),r=lr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(r!==null&&!r.isLastOfTimeline){let s=Math.min(r.end,(o=this._scaledPeriodEnd)!=null?o:1/0);return!(this._scaledPeriodEnd!==void 0&&s+t>=this._scaledPeriodEnd)}if(!this._isLastPeriod)return!1;if(this._scaledPeriodEnd===void 0)return!0;let i=e[e.length-1];return De(i,null,this._scaledPeriodEnd)+t<this._scaledPeriodEnd}isInitialized(){return!0}initialize(){c.error(\"A `TimelineRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `TimelineRepresentationIndex`\")}static isTimelineIndexArgument(e){return typeof e.timelineParser==\"function\"||Array.isArray(e.timeline)}_refreshTimeline(){if(this._index.timeline===null&&(this._index.timeline=this._getTimeline()),!this._isDynamic)return;let e=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();if(R(e))return;let t=Pe(e,this._index),r=ai(this._index.timeline,t);this._index.startNumber!==void 0?this._index.startNumber+=r:this._index.endNumber!==void 0&&(this._index.startNumber=r+1)}_getTimeline(){if(this._parseTimeline===null)return this._index.timeline!==null?this._index.timeline:(c.error(\"DASH: Timeline already lazily parsed.\"),[]);let e=this._parseTimeline();this._parseTimeline=null;let{MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:t}=U.getCurrent();if(this._unsafelyBaseOnPreviousIndex===null||e.length<t)return di(mt(e),this._index.startNumber,this._index.endNumber);let r;return this._unsafelyBaseOnPreviousIndex._index.timeline===null?(r=this._unsafelyBaseOnPreviousIndex._getTimeline(),this._unsafelyBaseOnPreviousIndex._index.timeline=r):r=this._unsafelyBaseOnPreviousIndex._index.timeline,this._unsafelyBaseOnPreviousIndex=null,di(ui(e,r),this._index.startNumber,this._index.endNumber)}};function di(n,e,t){if(t===void 0)return n;let r=e!=null?e:1;for(let i=0;i<n.length;i++){let a=n[i];if(r+=a.repeatCount+1,r>t){if(r===t+1)return n.slice(0,i+1);{let o=n.slice(0,i),s=_e({},a),u=r-a.repeatCount-1;return s.repeatCount=Math.max(0,t-u),o.push(s),o}}}return n}function Au(n,e,t,r){let i=lr(e,t,r);if(i===null)return!1;for(let a=0;a<e.timeline.length;a++){if(i.timelineIdx<a)return!1;let o=e.timeline[a],s=(o.start-e.indexTimeOffset)/e.timescale;if(s>n.time)return!1;if(s===n.time)return o.range===void 0?n.range===void 0:!R(n.range)&&o.range[0]===n.range[0]&&o.range[1]===n.range[1];if(o.repeatCount>=0&&o.duration!==void 0){let l=(s-o.start)/o.duration-1;return l%1===0&&l<=i.newRepeatCount}}return!1}function lr(n,e,t){if(n.timeline.length<=0)return null;if(n.availabilityTimeOffset===1/0){let i=n.timeline.length-1,a=n.timeline[i];return{isLastOfTimeline:!0,timelineIdx:i,newRepeatCount:a.repeatCount,end:De(a,null,t)}}let r=e.getEstimatedMaximumPosition(n.availabilityTimeOffset);if(r===void 0){let i=n.timeline.length-1,a=n.timeline[i];return{isLastOfTimeline:!0,timelineIdx:i,newRepeatCount:a.repeatCount,end:De(a,null,t)}}for(let i=n.timeline.length-1;i>=n.timeline.length;i--){let a=n.timeline[i],o=a.start+a.duration;if(je(o,n)<=r){let s=De(a,n.timeline[i+1],t);if(je(s,n)<=r)return{isLastOfTimeline:i===n.timeline.length-1,timelineIdx:i,newRepeatCount:a.repeatCount,end:o};{let l=Pe(r,n)-a.start,d=Math.floor(l/a.duration);return he(d>=1),{isLastOfTimeline:!1,timelineIdx:i,newRepeatCount:d-1,end:a.start+d*a.duration}}}}return null}var fr=on;var po=/^(?:[a-z]+:)?\\/\\//i,ku=/\\/\\.{1,2}\\//;function xu(n){if(!ku.test(n))return n;let e=[],t=n.split(\"/\");for(let r=0,i=t.length;r<i;r++)if(t[r]===\"..\")e.pop();else{if(t[r]===\".\")continue;e.push(t[r])}return e.join(\"/\")}function sn(...n){let e=n.length;if(e===0)return\"\";let t=\"\";for(let r=0;r<e;r++){let i=n[r];typeof i!=\"string\"||i===\"\"||(po.test(i)?t=i:(i[0]===\"/\"&&(i=i.substring(1)),t[t.length-1]===\"/\"&&(t=t.substring(0,t.length-1)),t=t+\"/\"+i))}return xu(t)}function li(n){let e=n.lastIndexOf(\"/\");if(e<0)return n.length;if(po.test(n)){let r=n.indexOf(\"/\");if(r>=0&&e===r+1)return n.length}let t=n.indexOf(\"?\");return t>=0&&t<e?li(n.substring(0,t)):e+1}function mr(n){let e=Date.parse(n)-L();if(isNaN(e)){c.warn(\"DASH Parser: Invalid clock received: \",n);return}return e}function fi(n){let e=n.children.utcTimings.filter(t=>(t.schemeIdUri===\"urn:mpeg:dash:utc:http-iso:2014\"||t.schemeIdUri===\"urn:mpeg:dash:utc:http-xsdate:2014\")&&t.value!==void 0);return e.length>0?e[0].value:void 0}function cr(n){let{representations:e}=n,t=null;for(let r=0;r<e.length;r++){let i=e[r].index.getLastAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.min(t,i))}return t===null?null:t}function mi(n){for(let e=n.length-1;e>=0;e--){let t=n[e].adaptations,r=t.audio===void 0?void 0:t.audio[0],i=t.video===void 0?void 0:t.video[0];if(r!==void 0||i!==void 0){let a=null,o=null;if(r!==void 0){let s=cr(r);if(s===void 0)return{safe:void 0,unsafe:void 0};a=s}if(i!==void 0){let s=cr(i);if(s===void 0)return{safe:void 0,unsafe:void 0};o=s}if(r!==void 0&&a===null||i!==void 0&&o===null)return c.info(\"Parser utils: found Period with no segment. \",\"Going to previous one to calculate last position\"),{safe:void 0,unsafe:void 0};if(o!==null)return a!==null?{safe:Math.min(a,o),unsafe:Math.max(a,o)}:{safe:o,unsafe:o};if(a!==null)return{safe:a,unsafe:a}}}return{safe:void 0,unsafe:void 0}}function pr(n){let{representations:e}=n,t=null;for(let r=0;r<e.length;r++){let i=e[r].index.getFirstAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.max(t,i))}return t===null?null:t}function ci(n){for(let e=0;e<=n.length-1;e++){let t=n[e].adaptations,r=t.audio===void 0?void 0:t.audio[0],i=t.video===void 0?void 0:t.video[0];if(r!==void 0||i!==void 0){let a=null,o=null;if(r!==void 0){let s=pr(r);if(s===void 0)return;a=s}if(i!==void 0){let s=pr(i);if(s===void 0)return;o=s}if(r!==void 0&&a===null||i!==void 0&&o===null){c.info(\"Parser utils: found Period with no segment. \",\"Going to next one to calculate first position\");return}if(o!==null)return a!==null?Math.max(a,o):o;if(a!==null)return a}}}function pi(n){if(n.length===0)throw new Error(\"DASH Parser: no period available for a dynamic content\");let e=ci(n),t=mi(n);return{minimumSafePosition:e,maximumSafePosition:t.safe,maximumUnsafePosition:t.unsafe}}var un=class{constructor(e){this._isDynamic=e.isDynamic,this._timeShiftBufferDepth=!e.isDynamic||e.timeShiftBufferDepth===void 0?null:e.timeShiftBufferDepth,this._serverTimestampOffset=e.serverTimestampOffset,this._availabilityStartTime=e.availabilityStartTime}setLastPosition(e,t){this._lastPosition=e,this._positionTime=t}lastPositionIsKnown(){return this._isDynamic?this._positionTime!==void 0&&this._lastPosition!==void 0:this._lastPosition!==void 0}getEstimatedMinimumSegmentTime(){var r;if(!this._isDynamic||this._timeShiftBufferDepth===null)return 0;let e=(r=this.getEstimatedLiveEdge())!=null?r:this.getEstimatedMaximumPosition(0);return e===void 0?void 0:e-this._timeShiftBufferDepth}getEstimatedLiveEdge(){if(!(!this._isDynamic||this._serverTimestampOffset===void 0))return(L()+this._serverTimestampOffset)/1e3-this._availabilityStartTime}getEstimatedMaximumPosition(e){if(!this._isDynamic)return this._lastPosition;let t=this.getEstimatedLiveEdge();return t!==void 0&&e!==1/0?t+e:this._positionTime!==void 0&&this._lastPosition!==void 0?Math.max(this._lastPosition-this._positionTime+L()/1e3,0):this._lastPosition}};function gi(n,e){return n.type!==\"dynamic\"?0:R(n.availabilityStartTime)?e!=null?e:0:n.availabilityStartTime}function hi(n,e){return typeof Array.prototype.flatMap==\"function\"?n.flatMap(e):n.reduce((t,r)=>{let i=e(r);return Array.isArray(i)?(t.push(...i),t):(t.push(i),t)},[])}var Mu=typeof Ee==\"object\"&&typeof Ee.TextDecoder==\"function\",Ou=typeof Ee==\"object\"&&typeof Ee.TextEncoder==\"function\";function dn(n){if(Ou)try{return new TextEncoder().encode(n)}catch(i){let a=i instanceof Error?i:\"\";c.warn(\"Utils: could not use TextEncoder to encode string into UTF-8, fallbacking to another implementation\",a)}let e,t=encodeURIComponent(n);if(typeof unescape==\"function\")e=unescape(t);else{let i=/[0-9a-fA-F]/,a=t.length;e=\"\";for(let o=0;o<t.length;o++){let s=!1;if(t[o]===\"%\"){if(o<=a-6&&t[o+1]===\"u\"&&i.test(t[o+2])&&i.test(t[o+3])&&i.test(t[o+4])&&i.test(t[o+5])){let u=parseInt(t.substring(o+1,o+6),16);e+=String.fromCharCode(u),s=!0,o+=5}else if(o<=a-3&&i.test(t[o+1])&&i.test(t[o+2])){let u=parseInt(t.substring(o+1,o+3),16);e+=String.fromCharCode(u),s=!0,o+=2}}s||(e+=t[o])}}let r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i)&255;return r}function wu(n){let t=\"\";for(let r=0;r<n.length;r+=16e3){let i=n.subarray(r,r+16e3);t+=String.fromCharCode.apply(null,i)}return t}function go(n,e){let t=n.toString(16);return t.length>=e?t:new Array(e-t.length+1).join(\"0\")+t}function Be(n){if(Mu)try{return new TextDecoder().decode(n)}catch(i){let a=i instanceof Error?i:\"\";c.warn(\"Utils: could not use TextDecoder to parse UTF-8, fallbacking to another implementation\",a)}let e=n;e[0]===239&&e[1]===187&&e[2]===191&&(e=e.subarray(3));let t=wu(e),r;if(typeof escape==\"function\")r=escape(t);else{let i=/[A-Za-z0-9*_\\+-\\.\\/]/;r=\"\";for(let a=0;a<t.length;a++)if(i.test(t[a]))r+=t[a];else{let o=t.charCodeAt(a);r+=o>=256?\"%u\"+go(o,4):\"%\"+go(o,2)}}return decodeURIComponent(r)}function ln(n){let e=n.length,t=new Uint8Array(e/2);for(let r=0,i=0;r<e;r+=2,i++)t[i]=parseInt(n.substring(r,r+2),16)&255;return t}function ho(n,e=\"\"){let t=\"\";for(let r=0;r<n.byteLength;r++)t+=(n[r]>>>4).toString(16),t+=(n[r]&15).toString(16),e.length>0&&r<n.byteLength-1&&(t+=e);return t}function Ii(n,e){let t=e;for(;t<n.length&&n[t]!==0;)t+=1;let r=n.subarray(e,t);return{end:t+1,string:Be(r)}}function bi(n){if(n.length===0)return[];let e=[n[0]];for(let t=1;t<n.length;t++){let r=n[t],i=e[e.length-1];for(;(i.duration===void 0||i.start+i.duration>r.start)&&(c.warn(\"DASH: Updating overlapping Periods.\",i==null?void 0:i.start,r.start),i.duration=r.start-i.start,i.end=r.start,!(i.duration>0));){if(e.pop(),e.length===0)break;i=e[e.length-1]}e.push(r)}return e}function Si(n,e){let t=[];return n.forEach((r,i)=>{let a;if(!R(r.attributes.start))a=r.attributes.start;else if(i===0)a=!e.isDynamic||R(e.availabilityStartTime)?0:e.availabilityStartTime;else{let l=t[t.length-1];if(!R(l)&&!R(l.periodEnd))a=l.periodEnd;else throw new Error(\"Missing start time when parsing periods.\")}let o,s=n[i+1];R(r.attributes.duration)?i===n.length-1?o=e.duration:R(s.attributes.start)||(o=s.attributes.start-a):o=r.attributes.duration;let u=R(o)?void 0:a+o;t.push({periodStart:a,periodDuration:o,periodEnd:u})}),t}function Du(n,e){for(let t of e){let{adaptation:r,trickModeAttachedAdaptationIds:i}=t;for(let a of i)for(let o of Ot){let s=n[o];if(s!==void 0)for(let u of s)u.id===a&&(u.trickModeTracks===void 0&&(u.trickModeTracks=[]),u.trickModeTracks.push(r))}}}var Io=Du;var Nu=[\"subtitle\",\"caption\"];function yi(n,e,t,r){function i(o,s){let u=o.split(\"/\")[0];if(se(Ot,u))return u;if(o===\"application/ttml+xml\")return\"text\";if(o===\"application/mp4\")return s!==null&&K(s,l=>l.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&se(Nu,l.value))!==void 0?\"text\":void 0}function a(o){switch(o.substring(0,3)){case\"avc\":case\"hev\":case\"hvc\":case\"vp8\":case\"vp9\":case\"av1\":return\"video\";case\"vtt\":return\"text\"}switch(o.substring(0,4)){case\"mp4a\":return\"audio\";case\"wvtt\":case\"stpp\":return\"text\"}}if(e!==null){let o=i(e,r);if(o!==void 0)return o}if(t!==null){let o=a(t);if(o!==void 0)return o}for(let o=0;o<n.length;o++){let s=n[o],{mimeType:u,codecs:l}=s.attributes;if(u!==void 0){let d=i(u,r);if(d!==void 0)return d}if(l!==void 0){let d=a(l);if(d!==void 0)return d}}}var Bu=/[, ]+/g;function bo(n){return Z(n)?n.trim().replace(Bu,\", \"):\"\"}function So(n){let[e,t,r,i,a,o,s,u]=n.split(\".\");if(e!==\"vp08\"&&e!==\"vp09\"&&e!==\"vp10\")return;let l,d,f;if((i!==void 0&&i===\"10\"||i===\"12\")&&(l=parseInt(i,10)),s!==void 0&&(s===\"16\"?d=\"pq\":s===\"18\"&&(d=\"hlg\")),o!==void 0&&u!==void 0&&o===\"09\"&&u===\"09\"&&(f=\"rec2020\"),!(l===void 0||d===void 0))return{colorDepth:l,eotf:d,colorSpace:f}}function Ti(n,e){var g,I;let{availabilityTimeOffset:t,manifestBoundsCalculator:r,isDynamic:i,end:a,start:o,receivedTime:s,unsafelyBaseOnPreviousRepresentation:u,inbandEventStreams:l,isLastPeriod:d}=e,m={availabilityTimeComplete:void 0,availabilityTimeOffset:t,unsafelyBaseOnPreviousRepresentation:u,isEMSGWhitelisted:h=>l===void 0?!1:l.some(({schemeIdUri:y})=>y===h.schemeIdUri),isLastPeriod:d,manifestBoundsCalculator:r,isDynamic:i,periodEnd:a,periodStart:o,receivedTime:s,representationBitrate:n.attributes.bitrate,representationId:n.attributes.id},p;if(n.children.segmentBase!==void 0){let{segmentBase:h}=n.children;p=new Tt(h,m)}else if(n.children.segmentList!==void 0){let{segmentList:h}=n.children;p=new _t(h,m)}else if(n.children.segmentTemplate!==void 0||e.parentSegmentTemplates.length>0){let h=e.parentSegmentTemplates.slice(),y=n.children.segmentTemplate;y!==void 0&&h.push(y);let E=H({},...h);(E.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(m.availabilityTimeOffset=((g=E.availabilityTimeOffset)!=null?g:0)+((I=e.availabilityTimeOffset)!=null?I:0)),p=fr.isTimelineIndexArgument(E)?new fr(E,m):new Et(E,m)}else{let h=e.adaptation.children;if(h.segmentBase!==void 0){let{segmentBase:y}=h;p=new Tt(y,m)}else if(h.segmentList!==void 0){let{segmentList:y}=h;p=new _t(y,m)}else p=new Et({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:\"\"},m)}return p}function et(n,e){var i;if(e.length===0)return n;let t=e.map(a=>({url:a.value}));if(n.length===0)return t;let r=[];for(let a=0;a<n.length;a++){let o=n[a];for(let s=0;s<t.length;s++){let u=t[s],l=sn(o.url,u.url);r.push({url:l,serviceLocation:(i=u.serviceLocation)!=null?i:o.serviceLocation})}}return r}function Uu(n,e){let t=[];if(n.children.inbandEventStreams!==void 0&&t.push(...n.children.inbandEventStreams),e.children.inbandEventStreams!==void 0&&t.push(...e.children.inbandEventStreams),t.length!==0)return t}function Lu({adaptationProfiles:n,essentialProperties:e,supplementalProperties:t,manifestProfiles:r,codecs:i}){if(((n!=null?n:\"\")+(r!=null?r:\"\")).indexOf(\"http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10\")!==-1&&(i===\"hvc1.2.4.L153.B0\"||i===\"hev1.2.4.L153.B0\"))return{colorDepth:10,eotf:\"pq\",colorSpace:\"rec2020\"};let o=K([...e!=null?e:[],...t!=null?t:[]],s=>s.schemeIdUri===\"urn:mpeg:mpegB:cicp:TransferCharacteristics\");if(o!==void 0)switch(o.value){case\"15\":return;case\"16\":return{eotf:\"pq\"};case\"18\":return{eotf:\"hlg\"}}if(i!==void 0&&/^vp(08|09|10)/.exec(i))return So(i)}function _i(n,e,t){var i,a,o,s,u;let r=[];for(let l of n){let d=l.attributes.id!==void 0?l.attributes.id:String(l.attributes.bitrate)+(l.attributes.height!==void 0?`-${l.attributes.height}`:\"\")+(l.attributes.width!==void 0?`-${l.attributes.width}`:\"\")+(l.attributes.mimeType!==void 0?`-${l.attributes.mimeType}`:\"\")+(l.attributes.codecs!==void 0?`-${l.attributes.codecs}`:\"\");for(;r.some(_=>_.id===d);)d+=\"-dup\";let f=(a=(i=t.unsafelyBaseOnPreviousAdaptation)==null?void 0:i.getRepresentation(d))!=null?a:null,m=Uu(l,e),p=(o=l.attributes.availabilityTimeComplete)!=null?o:t.availabilityTimeComplete,g;(l.attributes.availabilityTimeOffset!==void 0||t.availabilityTimeOffset!==void 0)&&(g=((s=l.attributes.availabilityTimeOffset)!=null?s:0)+((u=t.availabilityTimeOffset)!=null?u:0));let I=H({},t,{availabilityTimeOffset:g,availabilityTimeComplete:p,unsafelyBaseOnPreviousRepresentation:f,adaptation:e,inbandEventStreams:m}),h=Ti(l,I),y;l.attributes.bitrate===void 0?(c.warn(\"DASH: No usable bitrate found in the Representation.\"),y=0):y=l.attributes.bitrate;let E=et(t.baseURLs,l.children.baseURLs),v=E.length===0?[{baseUrl:\"\",id:void 0}]:E.map(_=>({baseUrl:_.url,id:_.serviceLocation})),T={bitrate:y,cdnMetadata:v,index:h,id:d};l.children.supplementalProperties!==void 0&&K(l.children.supplementalProperties,_=>_.schemeIdUri===\"tag:dolby.com,2018:dash:EC3_ExtensionType:2018\"&&_.value===\"JOC\")&&(T.isSpatialAudio=!0);let C;l.attributes.codecs!==void 0?C=l.attributes.codecs:e.attributes.codecs!==void 0&&(C=e.attributes.codecs),C!==void 0&&(C=C===\"mp4a.40.02\"?\"mp4a.40.2\":C,T.codecs=C);let P;l.attributes.supplementalCodecs!==void 0?P=l.attributes.supplementalCodecs:e.attributes.supplementalCodecs!==void 0&&(P=e.attributes.supplementalCodecs),P!==void 0&&(T.supplementalCodecs=bo(P)),l.attributes.frameRate!==void 0?T.frameRate=l.attributes.frameRate:e.attributes.frameRate!==void 0&&(T.frameRate=e.attributes.frameRate),l.attributes.height!==void 0?T.height=l.attributes.height:e.attributes.height!==void 0&&(T.height=e.attributes.height),l.attributes.mimeType!==void 0?T.mimeType=l.attributes.mimeType:e.attributes.mimeType!==void 0&&(T.mimeType=e.attributes.mimeType),l.attributes.width!==void 0?T.width=l.attributes.width:e.attributes.width!==void 0&&(T.width=e.attributes.width);let M=e.children.contentProtections!==void 0?e.children.contentProtections:[];if(l.children.contentProtections!==void 0&&M.push(...l.children.contentProtections),M.length>0){let _=M.reduce((A,x)=>{let k;if(x.attributes.schemeIdUri!==void 0&&x.attributes.schemeIdUri.substring(0,9)===\"urn:uuid:\"&&(k=x.attributes.schemeIdUri.substring(9).replace(/-/g,\"\").toLowerCase()),x.attributes.keyId!==void 0&&x.attributes.keyId.length>0){let D={keyId:x.attributes.keyId,systemId:k};A.keyIds===void 0?A.keyIds=[D]:A.keyIds.push(D)}if(k!==void 0){let{cencPssh:D}=x.children,w=[];for(let O of D)w.push({systemId:k,data:O});if(w.length>0){let O=K(A.initData,B=>B.type===\"cenc\");O===void 0?A.initData.push({type:\"cenc\",values:w}):O.values.push(...w)}}return A},{keyIds:void 0,initData:[]});(Object.keys(_.initData).length>0||_.keyIds!==void 0&&_.keyIds.length>0)&&(T.contentProtections=_)}T.hdrInfo=Lu({adaptationProfiles:e.attributes.profiles,supplementalProperties:e.children.supplementalProperties,essentialProperties:e.children.essentialProperties,manifestProfiles:t.manifestProfiles,codecs:C}),r.push(T)}return r}function Fu(n){if(n===void 0)return!1;let e=n.schemeIdUri===\"urn:tva:metadata:cs:AudioPurposeCS:2007\"&&n.value===\"1\",t=n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"description\";return e||t}function zu(n,e){return!!(n!==void 0&&n.some(r=>r.schemeIdUri===\"urn:tva:metadata:cs:AudioPurposeCS:2007\"&&r.value===\"2\")||e!==void 0&&e.some(r=>r.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&r.value===\"caption\"))}function Wu(n){return n===void 0?!1:n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"sign\"}function Vu(n,e){if(Z(n.attributes.id))return n.attributes.id;let{isClosedCaption:t,isForcedSubtitle:r,isAudioDescription:i,isSignInterpreted:a,isTrickModeTrack:o,type:s}=e,u=s;return Z(n.attributes.language)&&(u+=`-${n.attributes.language}`),t===!0&&(u+=\"-cc\"),r===!0&&(u+=\"-cc\"),i===!0&&(u+=\"-ad\"),a===!0&&(u+=\"-si\"),o&&(u+=\"-trickMode\"),Z(n.attributes.contentType)&&(u+=`-${n.attributes.contentType}`),Z(n.attributes.codecs)&&(u+=`-${n.attributes.codecs}`),Z(n.attributes.mimeType)&&(u+=`-${n.attributes.mimeType}`),n.attributes.frameRate!==void 0&&(u+=`-${String(n.attributes.frameRate)}`),u}function qu(n){if(!R(n.children.supplementalProperties)){let{supplementalProperties:e}=n.children;for(let t of e)if(t.schemeIdUri===\"urn:mpeg:dash:adaptation-set-switching:2016\"&&!R(t.value))return t.value.split(\",\").map(r=>r.trim()).filter(r=>r)}return[]}function Ei(n,e){var s,u,l,d,f,m,p;let t={video:[],audio:[],text:[]},r=[],i={},a=[];for(let g=0;g<n.length;g++){let I=n[g],h=I.children,{essentialProperties:y,roles:E,label:v}=h,T=Array.isArray(E)&&E.some(be=>be.value===\"main\")&&E.some(be=>be.schemeIdUri===\"urn:mpeg:dash:role:2011\"),C=I.children.representations,P=(s=I.attributes.availabilityTimeComplete)!=null?s:e.availabilityTimeComplete,M;(I.attributes.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(M=((u=I.attributes.availabilityTimeOffset)!=null?u:0)+((l=e.availabilityTimeOffset)!=null?l:0));let _=I.attributes.mimeType,A=I.attributes.codecs,x=yi(C,Z(_)?_:null,Z(A)?A:null,R(h.roles)?null:h.roles);if(x===void 0)continue;let k=(d=I.attributes.selectionPriority)!=null?d:1,D=I.attributes.id,w=qu(I),O=[];e.segmentTemplate!==void 0&&O.push(e.segmentTemplate),I.children.segmentTemplate!==void 0&&O.push(I.children.segmentTemplate);let B={availabilityTimeComplete:P,availabilityTimeOffset:M,baseURLs:et(e.baseURLs,h.baseURLs),manifestBoundsCalculator:e.manifestBoundsCalculator,end:e.end,isDynamic:e.isDynamic,isLastPeriod:e.isLastPeriod,manifestProfiles:e.manifestProfiles,parentSegmentTemplates:O,receivedTime:e.receivedTime,start:e.start,unsafelyBaseOnPreviousAdaptation:null},z=Array.isArray(y)?K(y,be=>be.schemeIdUri===\"http://dashif.org/guidelines/trickmode\"):void 0,q=(f=z==null?void 0:z.value)==null?void 0:f.split(\" \"),J=q!==void 0,{accessibilities:$}=h,V;E!==void 0&&E.some(be=>be.value===\"dub\")&&(V=!0);let Y;x!==\"text\"?Y=!1:Y=zu($,E);let X;x===\"text\"&&E!==void 0&&E.some(be=>be.value===\"forced-subtitle\"||be.value===\"forced_subtitle\")&&(X=!0);let me;x!==\"audio\"?me=!1:$!==void 0&&(me=$.some(Fu));let ce;x!==\"video\"?ce=!1:$!==void 0&&(ce=$.some(Wu));let de=Vu(I,{isAudioDescription:me,isForcedSubtitle:X,isClosedCaption:Y,isSignInterpreted:ce,isTrickModeTrack:J,type:x});for(;se(a,de);)de+=\"-dup\";let Ie=de;a.push(de),B.unsafelyBaseOnPreviousAdaptation=(p=(m=e.unsafelyBaseOnPreviousPeriod)==null?void 0:m.getAdaptation(de))!=null?p:null;let Jn=_i(C,I,B),pe={id:de,representations:Jn,type:x,isTrickModeTrack:J};if(R(I.attributes.language)||(pe.language=I.attributes.language),R(Y)||(pe.closedCaption=Y),R(me)||(pe.audioDescription=me),V===!0&&(pe.isDub=!0),X!==void 0&&(pe.forcedSubtitles=X),ce===!0&&(pe.isSignInterpreted=!0),v!==void 0&&(pe.label=v),q!==void 0)r.push({adaptation:pe,trickModeAttachedAdaptationIds:q});else{let be=-1;for(let Kt of w){let He=i[Kt];if(He!==void 0&&He.newID!==Ie&&se(He.adaptationSetSwitchingIDs,D)){be=ne(t[x],xt=>xt[0].id===Kt);let xe=t[x][be];if(xe!==void 0&&xe[0].audioDescription===pe.audioDescription&&xe[0].closedCaption===pe.closedCaption&&xe[0].language===pe.language){c.info('DASH Parser: merging \"switchable\" AdaptationSets',D,Kt),xe[0].representations.push(...pe.representations),xe[1]={priority:Math.max(k,xe[1].priority),isMainAdaptation:T||xe[1].isMainAdaptation,indexInMpd:Math.min(g,xe[1].indexInMpd)};break}}}be<0&&t[x].push([pe,{priority:k,isMainAdaptation:T,indexInMpd:g}])}!R(D)&&R(i[D])&&(i[D]={newID:Ie,adaptationSetSwitchingIDs:w})}let o=Ot.reduce((g,I)=>{let h=t[I];return h.length>0&&(h.sort(yo),g[I]=h.map(([y])=>y)),g},{});return t.video.sort(yo),Io(o,r),o}function yo(n,e){let t=e[1].priority-n[1].priority;return t!==0?t:n[1].isMainAdaptation!==e[1].isMainAdaptation?n[1].isMainAdaptation?-1:1:n[1].indexInMpd-e[1].indexInMpd}var Hu=Ae();function Ri(n,e){var o,s,u,l;let t=[],r=Si(n,e);if(r.length!==n.length)throw new Error(\"MPD parsing error: the time information are incoherent.\");let{isDynamic:i,manifestBoundsCalculator:a}=e;!i&&!R(e.duration)&&a.setLastPosition(e.duration);for(let d=n.length-1;d>=0;d--){let f=d===n.length-1,m=n[d],p=e.xlinkInfos.get(m),g=et(e.baseURLs,m.children.baseURLs),{periodStart:I,periodDuration:h,periodEnd:y}=r[d],E;for(R(m.attributes.id)?(c.warn(\"DASH: No usable id found in the Period. Generating one.\"),E=\"gen-dash-period-\"+Hu()):E=m.attributes.id;t.some(O=>O.id===E);)E+=\"-dup\";let v=p!==void 0?p.receivedTime:e.receivedTime,T=(s=(o=e.unsafelyBaseOnPreviousManifest)==null?void 0:o.getPeriod(E))!=null?s:null,C=m.attributes.availabilityTimeComplete,P=m.attributes.availabilityTimeOffset,{manifestProfiles:M}=e,{segmentTemplate:_}=m.children,A={availabilityTimeComplete:C,availabilityTimeOffset:P,baseURLs:g,manifestBoundsCalculator:a,end:y,isDynamic:i,isLastPeriod:f,manifestProfiles:M,receivedTime:v,segmentTemplate:_,start:I,unsafelyBaseOnPreviousPeriod:T},x=Ei(m.children.adaptations,A),k=((u=e.xmlNamespaces)!=null?u:[]).concat((l=m.attributes.namespaces)!=null?l:[]),D=Ku(m.children.eventStreams,I,k),w={id:E,start:I,end:y,duration:h,adaptations:x,streamEvents:D};if(t.unshift(w),!a.lastPositionIsKnown()){let O=Gu(x);if(!i)typeof O==\"number\"&&a.setLastPosition(O);else if(typeof O==\"number\"){let B=L()/1e3;a.setLastPosition(O,B)}else{let B=To(e,I);if(B!==void 0){let[z,q]=B;a.setLastPosition(z,q)}}}}if(e.isDynamic&&!a.lastPositionIsKnown()){let d=To(e,0);if(d!==void 0){let[f,m]=d;a.setLastPosition(f,m)}}return bi(t)}function To(n,e){if(R(n.clockOffset)){let t=Date.now()/1e3;if(t>=e){c.warn(\"DASH Parser: no clock synchronization mechanism found. Using the system clock instead.\");let r=t-n.availabilityStartTime,i=L()/1e3;return[r,i]}}else{let t=n.clockOffset/1e3-n.availabilityStartTime,r=L()/1e3,i=r+t;if(i>=e)return[i,r]}}function Gu(n){let e=null,t=!0,r=ar(n).filter(a=>!R(a)),i=hi(r,a=>a);for(let a of i){let o=a.representations;for(let s of o){let u=s.index.getLastAvailablePosition();u!==null&&(t=!1,typeof u==\"number\"&&(e=R(e)?u:Math.max(e,u)))}}if(R(e)){if(t)return null}else return e}function Ku(n,e,t){var i,a;let r=[];for(let o of n){let{schemeIdUri:s=\"\",timescale:u=1}=o.attributes,l=t.concat((i=o.attributes.namespaces)!=null?i:[]);for(let d of o.children.events)if(d.eventStreamData!==void 0){let f=((a=d.presentationTime)!=null?a:0)/u+e,m=d.duration===void 0?void 0:f+d.duration/u,p,g;if(!st&&d.eventStreamData instanceof Element)p=d.eventStreamData;else try{g={namespaces:l,data:typeof d.eventStreamData==\"string\"?d.eventStreamData:Be(new Uint8Array(d.eventStreamData))}}catch(I){c.error(\"DASH: Error while parsing event-stream:\",I instanceof Error?I.message:\"Unknown error\")}r.push({start:f,end:m,id:d.id,data:{type:\"dash-event-stream\",value:{schemeIdUri:s,timescale:u,element:p,xmlData:g}}})}}return r}function Nt(n,e,t,r,i=new WeakMap){let{children:a,attributes:o}=n;if(R(e.externalClockOffset)){let u=o.type===\"dynamic\",l=K(a.utcTimings,m=>m.schemeIdUri===\"urn:mpeg:dash:utc:direct:2014\"&&!R(m.value)),d=!R(l)&&!R(l.value)?mr(l.value):void 0,f=!R(d)&&!isNaN(d)?d:void 0;if(!R(f)&&r!==!0)e.externalClockOffset=f;else if(u&&r!==!0){let m=fi(n);if(!R(m)&&m.length>0)return{type:\"needs-clock\",value:{url:m,continue:function(g){return g.success?(e.externalClockOffset=mr(g.data),Nt(n,e,t,!0)):(t.push(g.error),c.warn(\"DASH Parser: Error on fetching the clock ressource\",g.error),Nt(n,e,t,!0))}}}}}let s=[];for(let u=0;u<a.periods.length;u++){let{xlinkHref:l,xlinkActuate:d}=a.periods[u].attributes;!R(l)&&d===\"onLoad\"&&s.push({index:u,ressource:l})}return s.length===0?ju(n,e,t,i):{type:\"needs-xlinks\",value:{xlinksUrls:s.map(({ressource:u})=>u),continue:function(l){if(l.length!==s.length)throw new Error(\"DASH parser: wrong number of loaded ressources.\");for(let d=l.length-1;d>=0;d--){let f=s[d].index,{parsed:m,warnings:p,receivedTime:g,sendingTime:I,url:h}=l[d];p.length>0&&t.push(...p);for(let y of m)i.set(y,{receivedTime:g,sendingTime:I,url:h});a.periods.splice(f,1,...m)}return Nt(n,e,t,r,i)}}}}function ju(n,e,t,r){var D,w,O,B;let{children:i,attributes:a}=n,o=a.type===\"dynamic\",s=e.url!==void 0?[{url:e.url.substring(0,li(e.url))}]:[],u=et(s,i.baseURLs),l=gi(a,e.referenceDateTime),d=a.timeShiftBufferDepth,{externalClockOffset:f,unsafelyBaseOnPreviousManifest:m}=e,{externalClockOffset:p}=e,g=new un({availabilityStartTime:l,isDynamic:o,timeShiftBufferDepth:d,serverTimestampOffset:p}),I={availabilityStartTime:l,baseURLs:u,clockOffset:f,duration:a.duration,isDynamic:o,manifestBoundsCalculator:g,manifestProfiles:n.attributes.profiles,receivedTime:e.manifestReceivedTime,timeShiftBufferDepth:d,unsafelyBaseOnPreviousManifest:m,xlinkInfos:r,xmlNamespaces:n.attributes.namespaces},h=Ri(i.periods,I),y=a.duration,E,v,T=null,C;a.minimumUpdatePeriod!==void 0&&a.minimumUpdatePeriod>=0&&(E=a.minimumUpdatePeriod===0?U.getCurrent().DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:a.minimumUpdatePeriod);let{minimumSafePosition:P,maximumSafePosition:M,maximumUnsafePosition:_}=pi(h),A=L();if(o){let z;M!==void 0?z=M:p===void 0?(c.warn(\"DASH Parser: use system clock to define maximum position\"),z=Date.now()/1e3-l):z=(L()+p)/1e3-l;let q=g.getEstimatedLiveEdge();q===void 0&&(_!==void 0?q=_:q=z),C={isLinear:!0,maximumSafePosition:z,livePosition:q,time:A},v=P,T=d!=null?d:null,T!==null&&v!==void 0&&q-v>T&&(T=q-v)}else{v=P,v===void 0&&(v=(w=(D=h[0])==null?void 0:D.start)!=null?w:0);let z=y!=null?y:1/0;if(h[h.length-1]!==void 0){let q=h[h.length-1],J=(O=q.end)!=null?O:q.duration!==void 0?q.start+q.duration:void 0;J!==void 0&&J<z&&(z=J)}M!==void 0&&M<z&&(z=M),C={isLinear:!1,maximumSafePosition:z,livePosition:void 0,time:A}}let x=!o||n.attributes.minimumUpdatePeriod===void 0&&(((B=h[h.length-1])==null?void 0:B.end)!==void 0||n.attributes.duration!==void 0);return{type:\"done\",value:{parsed:{availabilityStartTime:l,clockOffset:e.externalClockOffset,isDynamic:o,isLive:o,isLastPeriodKnown:x,periods:h,publishTime:a.publishTime,suggestedPresentationDelay:a.suggestedPresentationDelay,transportType:\"dash\",timeBounds:{minimumSafePosition:v,timeshiftDepth:T,maximumTimeData:C},lifetime:E,uris:R(e.url)?i.locations:[e.url,...i.locations]},warnings:t}}}var gr=Nt;function Ye(n,e,t){if(typeof String.prototype.startsWith==\"function\")return n.startsWith(e,t);let r=typeof t==\"number\"?Math.max(t,0):0;return n.substring(r,r+e.length)===e}var _o=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51];function hr(n){if(n>=_o.length)throw new Error(\"Unable to parse base64 string.\");let e=_o[n];if(e===255)throw new Error(\"Unable to parse base64 string.\");return e}function Ir(n){let e=n.length%4,t=n;e!==0&&(c.warn(\"base64ToBytes: base64 given miss padding\"),t+=e===3?\"=\":e===2?\"==\":\"===\");let r=t.indexOf(\"=\");if(r!==-1&&r<t.length-2)throw new Error(\"Unable to parse base64 string.\");let i=t.endsWith(\"==\")?2:t.endsWith(\"=\")?1:0,a=t.length,o=new Uint8Array(a/4*3),s;for(let u=0,l=0;u<a;u+=4,l+=3)s=hr(t.charCodeAt(u))<<18|hr(t.charCodeAt(u+1))<<12|hr(t.charCodeAt(u+2))<<6|hr(t.charCodeAt(u+3)),o[l]=s>>16,o[l+1]=s>>8&255,o[l+2]=s&255;return o.subarray(0,o.length-i)}var Yu=/^P(([\\d.]*)Y)?(([\\d.]*)M)?(([\\d.]*)D)?T?(([\\d.]*)H)?(([\\d.]*)M)?(([\\d.]*)S)?/,Qu=/([0-9]+)-([0-9]+)/;function ve(n,e){return n===\"true\"?[!0,null]:n===\"false\"?[!1,null]:[!1,new Me(`\\`${e}\\` property is not a boolean value but \"${n}\"`)]}function ee(n,e){let t=parseInt(n,10);return isNaN(t)?[null,new Me(`\\`${e}\\` property is not an integer value but \"${n}\"`)]:[t,null]}function ke(n,e){if(n===\"INF\")return[1/0,null];let t=parseFloat(n);return isNaN(t)?[null,new Me(`\\`${e}\\` property is invalid: \"${n}\"`)]:[t,null]}function Pi(n,e){if(n===\"true\")return[!0,null];if(n===\"false\")return[!1,null];let t=parseInt(n,10);return isNaN(t)?[null,new Me(`\\`${e}\\` property is not a boolean nor an integer but \"${n}\"`)]:[t,null]}function br(n,e){let t=Date.parse(n);return isNaN(t)?[null,new Me(`\\`${e}\\` is in an invalid date format: \"${n}\"`)]:[new Date(Date.parse(n)).getTime()/1e3,null]}function We(n,e){if(!Z(n))return[0,new Me(`\\`${e}\\` property is empty`)];let t=Yu.exec(n);return t===null?[null,new Me(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[parseFloat(Z(t[2])?t[2]:\"0\")*365*24*60*60+parseFloat(Z(t[4])?t[4]:\"0\")*30*24*60*60+parseFloat(Z(t[6])?t[6]:\"0\")*24*60*60+parseFloat(Z(t[8])?t[8]:\"0\")*60*60+parseFloat(Z(t[10])?t[10]:\"0\")*60+parseFloat(Z(t[12])?t[12]:\"0\"),null]}function Rt(n,e){let t=Qu.exec(n);return t===null?[null,new Me(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[[+t[1],+t[2]],null]}function Eo(n,e){try{return[Ir(n),null]}catch(t){return[null,new Me(`\\`${e}\\` is not a valid base64 string: \"${n}\"`)]}}function Bt(n,e){let t=/^(\\d+)\\/(\\d+)$/.exec(n);return t!==null?[+t[1]/+t[2],null]:ke(n,e)}function ye(n){let e,t;for(let r of Object.keys(n.attributes)){let i=n.attributes[r];if(!R(i))switch(r){case\"schemeIdUri\":e=i;break;case\"value\":t=i;break}}return{schemeIdUri:e,value:t}}function fe(n,e){return function(t,{asKey:r,parser:i,dashName:a}){let[o,s]=i(t,a);s!==null&&(c.warn(s.message),e.push(s)),o!==null&&(n[r]=o)}}var Me=class n extends Error{constructor(e){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"MPDError\",this.message=e}};function ct(n){return ur(n)}function tt(n){let e=typeof n==\"string\"?n:ct(n.children),t=[];return e===null||e.length===0?[void 0,t]:[{value:e},t]}function vi(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!R(r))switch(t){case\"id\":e.id=r;break;case\"lang\":e.language=r;break;case\"contentType\":e.contentType=r;break;case\"par\":e.par=r;break}}return e}function $u(n){let e=[],t=[];for(let r=0;r<n.length;r++){let i=n[r];if(typeof i!=\"string\"&&i.tagName===\"cenc:pssh\"){let a=ct(i.children);if(a!==null&&a.length>0){let[o,s]=Eo(a,\"cenc:pssh\");s!==null&&(c.warn(s.message),e.push(s)),o!==null&&t.push(o)}}}return[{cencPssh:t},e]}function Xu(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!R(r))switch(t){case\"schemeIdUri\":e.schemeIdUri=r;break;case\"value\":e.value=r;break;case\"cenc:default_KID\":e.keyId=ln(r.replace(/-/g,\"\"))}}return e}function fn(n){let[e,t]=$u(n.children),r=Xu(n);return[{children:e,attributes:r},t]}function Ci(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!R(a))switch(i){case\"range\":r(a,{asKey:\"range\",parser:Rt,dashName:\"range\"});break;case\"sourceURL\":e.media=a;break}}return[e,t]}function nt(n){let e={},t=[],r=fe(e,t),i=n.children;for(let a=0;a<i.length;a++){let o=i[a];if(typeof o!=\"string\"&&o.tagName===\"Initialization\"){let[s,u]=Ci(o);e.initialization=s,t=t.concat(u)}}for(let a of Object.keys(n.attributes)){let o=n.attributes[a];if(!R(o))switch(a){case\"timescale\":r(o,{asKey:\"timescale\",parser:ee,dashName:\"timescale\"});break;case\"presentationTimeOffset\":r(o,{asKey:\"presentationTimeOffset\",parser:ke,dashName:\"presentationTimeOffset\"});break;case\"indexRange\":r(o,{asKey:\"indexRange\",parser:Rt,dashName:\"indexRange\"});break;case\"indexRangeExact\":r(o,{asKey:\"indexRangeExact\",parser:ve,dashName:\"indexRangeExact\"});break;case\"availabilityTimeOffset\":r(o,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(o,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break;case\"duration\":r(o,{asKey:\"duration\",parser:ee,dashName:\"duration\"});break;case\"startNumber\":r(o,{asKey:\"startNumber\",parser:ee,dashName:\"startNumber\"});break;case\"endNumber\":r(o,{asKey:\"endNumber\",parser:ee,dashName:\"endNumber\"});break}}return[e,t]}function Ai(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!R(a))switch(i){case\"media\":e.media=a;break;case\"indexRange\":r(a,{asKey:\"indexRange\",parser:Rt,dashName:\"indexRange\"});break;case\"index\":e.index=a;break;case\"mediaRange\":r(a,{asKey:\"mediaRange\",parser:Rt,dashName:\"mediaRange\"});break}}return[e,t]}function mn(n){let[e,t]=nt(n),r=t,i=[],a=n.children;for(let s=0;s<a.length;s++){let u=a[s];if(typeof u!=\"string\"&&u.tagName===\"SegmentURL\"){let[l,d]=Ai(u);i.push(l),r=r.concat(d)}}return[H(e,{list:i}),r]}function ki(n){let e=n.children;return function(){for(let t=e.length-1;t>=0;t--){let r=e[t];(typeof r==\"string\"||r.tagName!==\"S\")&&e.splice(t,1)}return e}}function Pt(n){let[e,t]=nt(n),r=t,i;for(let s=0;s<n.children.length;s++){let u=n.children[s];typeof u!=\"string\"&&u.tagName===\"SegmentTimeline\"&&(i=ki(u))}let a=H({},e,{duration:e.duration,timelineParser:i}),o=fe(a,r);for(let s of Object.keys(n.attributes)){let u=n.attributes[s];if(!R(u))switch(s){case\"initialization\":R(a.initialization)&&(a.initialization={media:u});break;case\"index\":a.index=u;break;case\"availabilityTimeOffset\":o(u,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":o(u,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break;case\"media\":a.media=u;break;case\"bitstreamSwitching\":o(u,{asKey:\"bitstreamSwitching\",parser:ve,dashName:\"bitstreamSwitching\"});break}}return[a,r]}function Zu(n){let e={baseURLs:[]},t=[],r=[];for(let i=0;i<n.length;i++){let a=n[i];if(typeof a!=\"string\")switch(a.tagName){case\"BaseURL\":let[o,s]=tt(a);o!==void 0&&e.baseURLs.push(o),r=r.concat(s);break;case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(ye(a));break;case\"SegmentBase\":let[u,l]=nt(a);e.segmentBase=u,l.length>0&&(r=r.concat(l));break;case\"SegmentList\":let[d,f]=mn(a);r=r.concat(f),e.segmentList=d;break;case\"SegmentTemplate\":let[m,p]=Pt(a);r=r.concat(p),e.segmentTemplate=m;break;case\"ContentProtection\":let[g,I]=fn(a);I.length>0&&(r=r.concat(I)),g!==void 0&&t.push(g);break;case\"SupplementalProperty\":R(e.supplementalProperties)?e.supplementalProperties=[ye(a)]:e.supplementalProperties.push(ye(a));break}}return t.length>0&&(e.contentProtections=t),[e,r]}function Ju(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!R(a))switch(i){case\"audioSamplingRate\":e.audioSamplingRate=a;break;case\"bandwidth\":r(a,{asKey:\"bitrate\",parser:ee,dashName:\"bandwidth\"});break;case\"codecs\":e.codecs=a;break;case\"codingDependency\":r(a,{asKey:\"codingDependency\",parser:ve,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Bt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ee,dashName:\"height\"});break;case\"id\":e.id=a;break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:ke,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:ke,dashName:\"maximumSAPPeriod\"});break;case\"mimeType\":e.mimeType=a;break;case\"profiles\":e.profiles=a;break;case\"qualityRanking\":r(a,{asKey:\"qualityRanking\",parser:ee,dashName:\"qualityRanking\"});break;case\"scte214:supplementalCodecs\":e.supplementalCodecs=a;break;case\"segmentProfiles\":e.segmentProfiles=a;break;case\"width\":r(a,{asKey:\"width\",parser:ee,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break}}return e.bitrate===void 0&&t.push(new Me(\"No bitrate found on a Representation\")),[e,t]}function Ro(n){let[e,t]=Zu(n.children),[r,i]=Ju(n),a=t.concat(i);return[{children:e,attributes:r},a]}function ed(n){let e={baseURLs:[],representations:[]},t=[],r=[];for(let i=0;i<n.length;i++){let a=n[i];if(typeof a!=\"string\")switch(a.tagName){case\"Accessibility\":e.accessibilities===void 0?e.accessibilities=[ye(a)]:e.accessibilities.push(ye(a));break;case\"BaseURL\":let[o,s]=tt(a);o!==void 0&&e.baseURLs.push(o),s.length>0&&(r=r.concat(s));break;case\"ContentComponent\":e.contentComponent=vi(a);break;case\"EssentialProperty\":R(e.essentialProperties)?e.essentialProperties=[ye(a)]:e.essentialProperties.push(ye(a));break;case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(ye(a));break;case\"Label\":let u=ct(a.children);u!=null&&(e.label=u);break;case\"Representation\":let[l,d]=Ro(a);e.representations.push(l),d.length>0&&(r=r.concat(d));break;case\"Role\":R(e.roles)?e.roles=[ye(a)]:e.roles.push(ye(a));break;case\"SupplementalProperty\":R(e.supplementalProperties)?e.supplementalProperties=[ye(a)]:e.supplementalProperties.push(ye(a));break;case\"SegmentBase\":let[f,m]=nt(a);e.segmentBase=f,m.length>0&&(r=r.concat(m));break;case\"SegmentList\":let[p,g]=mn(a);e.segmentList=p,g.length>0&&(r=r.concat(g));break;case\"SegmentTemplate\":let[I,h]=Pt(a);e.segmentTemplate=I,h.length>0&&(r=r.concat(h));break;case\"ContentProtection\":let[y,E]=fn(a);E.length>0&&(r=r.concat(E)),y!==void 0&&t.push(y);break}}return t.length>0&&(e.contentProtections=t),[e,r]}function td(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!R(a))switch(i){case\"id\":e.id=a;break;case\"group\":r(a,{asKey:\"group\",parser:ee,dashName:\"group\"});break;case\"lang\":e.language=a;break;case\"contentType\":e.contentType=a;break;case\"par\":e.par=a;break;case\"minBandwidth\":r(a,{asKey:\"minBitrate\",parser:ee,dashName:\"minBandwidth\"});break;case\"maxBandwidth\":r(a,{asKey:\"maxBitrate\",parser:ee,dashName:\"maxBandwidth\"});break;case\"minWidth\":r(a,{asKey:\"minWidth\",parser:ee,dashName:\"minWidth\"});break;case\"maxWidth\":r(a,{asKey:\"maxWidth\",parser:ee,dashName:\"maxWidth\"});break;case\"minHeight\":r(a,{asKey:\"minHeight\",parser:ee,dashName:\"minHeight\"});break;case\"maxHeight\":r(a,{asKey:\"maxHeight\",parser:ee,dashName:\"maxHeight\"});break;case\"minFrameRate\":r(a,{asKey:\"minFrameRate\",parser:Bt,dashName:\"minFrameRate\"});break;case\"maxFrameRate\":r(a,{asKey:\"maxFrameRate\",parser:Bt,dashName:\"maxFrameRate\"});break;case\"selectionPriority\":r(a,{asKey:\"selectionPriority\",parser:ee,dashName:\"selectionPriority\"});break;case\"segmentAlignment\":r(a,{asKey:\"segmentAlignment\",parser:Pi,dashName:\"segmentAlignment\"});break;case\"subsegmentAlignment\":r(a,{asKey:\"subsegmentAlignment\",parser:Pi,dashName:\"subsegmentAlignment\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:ve,dashName:\"bitstreamSwitching\"});break;case\"audioSamplingRate\":e.audioSamplingRate=a;break;case\"codecs\":e.codecs=a;break;case\"scte214:supplementalCodecs\":e.supplementalCodecs=a;break;case\"codingDependency\":r(a,{asKey:\"codingDependency\",parser:ve,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Bt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ee,dashName:\"height\"});break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:ke,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:ke,dashName:\"maximumSAPPeriod\"});break;case\"mimeType\":e.mimeType=a;break;case\"profiles\":e.profiles=a;break;case\"segmentProfiles\":e.segmentProfiles=a;break;case\"width\":r(a,{asKey:\"width\",parser:ee,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break}}return[e,t]}function Po(n){let e=n.children,[t,r]=ed(e),[i,a]=td(n),o=r.concat(a);return[{children:t,attributes:i},o]}function nd(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!R(a))switch(i){case\"schemeIdUri\":e.schemeIdUri=a;break;case\"value\":e.value=a;break;case\"timescale\":r(a,{asKey:\"timescale\",parser:ee,dashName:\"timescale\"});break;default:Ye(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function vo(n,e){let[t,r]=nd(n),i=[];for(let a of n.children)if(typeof a!=\"string\"&&a.tagName===\"Event\"){let o={};if(R(a.attributes.id)||(o.id=a.attributes.id),!R(a.attributes.presentationTime)){let[s,u]=ee(a.attributes.presentationTime,\"presentationTime\");u!==null&&r.push(u),s!==null&&(o.presentationTime=s)}if(!R(a.attributes.duration)){let[s,u]=ee(a.attributes.duration,\"duration\");u!==null&&r.push(u),s!==null&&(o.duration=s)}if(a.posStart<a.posEnd){let s=e.substring(a.posStart,a.posEnd);o.eventStreamData=s}i.push(o)}return[{children:{events:i},attributes:t},r]}function rd(n,e){let t=[],r=[],i,a=[],o=[];for(let s=0;s<n.length;s++){let u=n[s];if(typeof u!=\"string\")switch(u.tagName){case\"BaseURL\":let[l,d]=tt(u);l!==void 0&&t.push(l),a=a.concat(d);break;case\"AdaptationSet\":let[f,m]=Po(u);r.push(f),a=a.concat(m);break;case\"EventStream\":let[p,g]=vo(u,e);o.push(p),a=a.concat(g);break;case\"SegmentTemplate\":let[I,h]=Pt(u);i=I,h.length>0&&(a=a.concat(h));break}}return[{baseURLs:t,adaptations:r,eventStreams:o,segmentTemplate:i},a]}function id(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!R(a))switch(i){case\"id\":e.id=a;break;case\"start\":r(a,{asKey:\"start\",parser:We,dashName:\"start\"});break;case\"duration\":r(a,{asKey:\"duration\",parser:We,dashName:\"duration\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:ve,dashName:\"bitstreamSwitching\"});break;case\"xlink:href\":e.xlinkHref=a;break;case\"xlink:actuate\":e.xlinkActuate=a;break;default:Ye(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Sr(n,e){let[t,r]=rd(n.children,e),[i,a]=id(n),o=r.concat(a);return[{children:t,attributes:i},o]}function ad(n,e){let t=[],r=[],i=[],a=[],o=[];for(let s=0;s<n.length;s++){let u=n[s];if(typeof u!=\"string\")switch(u.tagName){case\"BaseURL\":let[l,d]=tt(u);l!==void 0&&t.push(l),o=o.concat(d);break;case\"Location\":r.push(ct(u.children));break;case\"Period\":let[f,m]=Sr(u,e);i.push(f),o=o.concat(m);break;case\"UTCTiming\":let p=ye(u);a.push(p);break}}return[{baseURLs:t,locations:r,periods:i,utcTimings:a},o]}function od(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!R(a))switch(i){case\"id\":e.id=a;break;case\"profiles\":e.profiles=a;break;case\"type\":e.type=a;break;case\"availabilityStartTime\":r(a,{asKey:\"availabilityStartTime\",parser:br,dashName:\"availabilityStartTime\"});break;case\"availabilityEndTime\":r(a,{asKey:\"availabilityEndTime\",parser:br,dashName:\"availabilityEndTime\"});break;case\"publishTime\":r(a,{asKey:\"publishTime\",parser:br,dashName:\"publishTime\"});break;case\"mediaPresentationDuration\":r(a,{asKey:\"duration\",parser:We,dashName:\"mediaPresentationDuration\"});break;case\"minimumUpdatePeriod\":r(a,{asKey:\"minimumUpdatePeriod\",parser:We,dashName:\"minimumUpdatePeriod\"});break;case\"minBufferTime\":r(a,{asKey:\"minBufferTime\",parser:We,dashName:\"minBufferTime\"});break;case\"timeShiftBufferDepth\":r(a,{asKey:\"timeShiftBufferDepth\",parser:We,dashName:\"timeShiftBufferDepth\"});break;case\"suggestedPresentationDelay\":r(a,{asKey:\"suggestedPresentationDelay\",parser:We,dashName:\"suggestedPresentationDelay\"});break;case\"maxSegmentDuration\":r(a,{asKey:\"maxSegmentDuration\",parser:We,dashName:\"maxSegmentDuration\"});break;case\"maxSubsegmentDuration\":r(a,{asKey:\"maxSubsegmentDuration\",parser:We,dashName:\"maxSubsegmentDuration\"});break;default:Ye(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Co(n,e){let[t,r]=ad(n.children,e),[i,a]=od(n),o=r.concat(a);return[{children:t,attributes:i},o]}function xi(n,e){let t=ni(n),r=t[t.length-1];if(r===void 0||typeof r==\"string\"||r.tagName!==\"MPD\")throw new Error(\"DASH Parser: document root should be MPD\");let[i,a]=Co(r,n),o=gr(i,e,a);return s(o);function s(u){if(u.type===\"done\")return u;if(u.type===\"needs-clock\")return{type:\"needs-resources\",value:{urls:[u.value.url],format:\"string\",continue(l){if(l.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let d=u.value.continue(l[0].responseData);return s(d)}}};if(u.type===\"needs-xlinks\")return{type:\"needs-resources\",value:{urls:u.value.xlinksUrls,format:\"string\",continue(l){let d=[];for(let m=0;m<l.length;m++){let{responseData:p,receivedTime:g,sendingTime:I,url:h}=l[m];if(!p.success)throw p.error;let y=\"<root>\"+p.data+\"</root>\",E=ni(y),v=E[E.length-1];if(v===void 0||typeof v==\"string\")throw new Error(\"DASH parser: Invalid external ressources\");let T=v.children,C=[],P=[];for(let M=0;M<T.length;M++){let _=T[M];if(typeof _==\"string\"||_.tagName!==\"Period\")continue;let[A,x]=Sr(_,y);P.push(...x),C.push(A)}d.push({url:h,receivedTime:g,sendingTime:I,parsed:C,warnings:P})}let f=u.value.continue(d);return s(f)}}};ze(u)}}var Ao=xi;var sd=typeof WebAssembly==\"object\"&&typeof WebAssembly.instantiate==\"function\",ko=sd;function F(n,e,t,r){let i=new Uint8Array(e,t,r);return n.decode(i)}function Mi(n){return n===1/0?!0:n===-1/0?!1:n}function pt(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.value=F(t,e.buffer,a,o))}}function xo(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 60:n.language=F(t,e.buffer,a,o);break;case 61:n.contentType=F(t,e.buffer,a,o);break;case 62:n.par=F(t,e.buffer,a,o);break}}}function yr(n,e){let t=n.attributes,r=n.children,i=new TextDecoder;return function(o,s,u){switch(o){case 16:t.schemeIdUri=F(i,e.buffer,s,u);break;case 13:t.value=F(i,e.buffer,s,u);break;case 14:let l=F(i,e.buffer,s,u);t.keyId=ln(l.replace(/-/g,\"\"));break;case 15:try{let d=F(i,e.buffer,s,u);r.cencPssh.push(Ir(d))}catch(d){}break}}}function Ve(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 16:n.schemeIdUri=F(t,e.buffer,a,o);break;case 17:n.value=F(t,e.buffer,a,o);break}}}function Ut(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 29:{let s=new DataView(e.buffer);n.initialization===void 0&&(n.initialization={}),n.initialization.range=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 67:n.initialization===void 0&&(n.initialization={}),n.initialization.media=F(t,e.buffer,a,o);break;case 43:{let s=new DataView(e.buffer);n.availabilityTimeOffset=s.getFloat64(a,!0);break}case 22:{n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break}case 24:{let s=new DataView(e.buffer);n.presentationTimeOffset=s.getFloat64(a,!0);break}case 27:{let s=new DataView(e.buffer);n.timescale=s.getFloat64(a,!0);break}case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 23:{n.indexRangeExact=new DataView(e.buffer).getUint8(0)===0;break}case 1:{let s=new DataView(e.buffer);n.duration=s.getFloat64(a,!0);break}case 20:{let s=new DataView(e.buffer);n.startNumber=s.getFloat64(a,!0);break}case 76:{let s=new DataView(e.buffer);n.endNumber=s.getFloat64(a,!0);break}}}}function Mo(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 28:n.index=F(t,e.buffer,a,o);break;case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 30:n.media=F(t,e.buffer,a,o);break;case 18:{let s=new DataView(e.buffer);n.mediaRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}}}}function Tr(n,e,t){return function(i){switch(i){case 20:{let a={};n.list===void 0&&(n.list=[]),n.list.push(a);let o=Mo(a,e);t.pushParsers(i,N,o);break}default:t.pushParsers(i,N,N);break}}}function Lt(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 19:{let s=new DataView(e.buffer);n.timeline=[];let u=a;for(let l=0;l<o/24;l++)n.timeline.push({start:s.getFloat64(u,!0),duration:s.getFloat64(u+8,!0),repeatCount:s.getFloat64(u+16,!0)}),u+=24;break}case 67:n.initialization={media:F(t,e.buffer,a,o)};break;case 28:n.index=F(t,e.buffer,a,o);break;case 43:{let s=new DataView(e.buffer);n.availabilityTimeOffset=s.getFloat64(a,!0);break}case 22:{n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break}case 24:{let s=new DataView(e.buffer);n.presentationTimeOffset=s.getFloat64(a,!0);break}case 27:{let s=new DataView(e.buffer);n.timescale=s.getFloat64(a,!0);break}case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 23:{n.indexRangeExact=new DataView(e.buffer).getUint8(0)===0;break}case 30:n.media=F(t,e.buffer,a,o);break;case 32:{n.bitstreamSwitching=new DataView(e.buffer).getUint8(0)===0;break}case 1:{let s=new DataView(e.buffer);n.duration=s.getFloat64(a,!0);break}case 20:{let s=new DataView(e.buffer);n.startNumber=s.getFloat64(a,!0);break}case 76:{let s=new DataView(e.buffer);n.endNumber=s.getFloat64(a,!0);break}}}}function Oo(n,e,t){return function(i){switch(i){case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a),t.pushParsers(i,N,pt(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=yr(a,e);t.pushParsers(i,N,o);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a),t.pushParsers(i,N,Ve(a,e));break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=Ve(a,e);t.pushParsers(i,N,o);break}case 17:{let a={};n.segmentBase=a;let o=Ut(a,e);t.pushParsers(i,N,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Tr(a,e,t),s=Ut(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,N,Lt(a,e));break}default:t.pushParsers(i,N,N);break}}}function wo(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 3:n.audioSamplingRate=F(t,e.buffer,a,o);break;case 63:n.bitrate=s.getFloat64(a,!0);break;case 4:n.codecs=F(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=F(t,e.buffer,a,o);break;case 5:n.codingDependency=new DataView(e.buffer).getUint8(0)===0;break;case 6:n.frameRate=s.getFloat64(a,!0);break;case 7:n.height=s.getFloat64(a,!0);break;case 8:n.width=s.getFloat64(a,!0);break;case 9:n.maxPlayoutRate=s.getFloat64(a,!0);break;case 10:n.maximumSAPPeriod=s.getFloat64(a,!0);break;case 11:n.mimeType=F(t,e.buffer,a,o);break;case 2:n.profiles=F(t,e.buffer,a,o);break;case 65:n.qualityRanking=s.getFloat64(a,!0);break;case 12:n.segmentProfiles=F(t,e.buffer,a,o);break;case 43:n.availabilityTimeOffset=s.getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=s.getUint8(0)===0;break}}}function Do(n,e,t){return function(i){switch(i){case 8:{let a={};n.accessibilities===void 0&&(n.accessibilities=[]),n.accessibilities.push(a);let o=Ve(a,e);t.pushParsers(i,N,o);break}case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a);let o=pt(a,e);t.pushParsers(i,N,o);break}case 9:{let a={};n.contentComponent=a,t.pushParsers(i,N,xo(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=yr(a,e);t.pushParsers(i,N,o);break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=N,s=Ve(a,e);t.pushParsers(i,o,s);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a);let o=N,s=Ve(a,e);t.pushParsers(i,o,s);break}case 7:{let a={children:{baseURLs:[]},attributes:{}};n.representations.push(a);let o=Oo(a.children,e,t),s=wo(a.attributes,e);t.pushParsers(i,o,s);break}case 12:{let a={};n.roles===void 0&&(n.roles=[]),n.roles.push(a);let o=Ve(a,e);t.pushParsers(i,N,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=Ve(a,e);t.pushParsers(i,N,o);break}case 17:{let a={};n.segmentBase=a;let o=Ut(a,e);t.pushParsers(i,N,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Tr(a,e,t),s=Ut(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,N,Lt(a,e));break}default:t.pushParsers(i,N,N);break}}}function No(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 48:n.group=s.getFloat64(a,!0);break;case 60:n.language=F(t,e.buffer,a,o);break;case 61:n.contentType=F(t,e.buffer,a,o);break;case 62:n.par=F(t,e.buffer,a,o);break;case 53:n.minBitrate=s.getFloat64(a,!0);break;case 49:n.maxBitrate=s.getFloat64(a,!0);break;case 56:n.minWidth=s.getFloat64(a,!0);break;case 52:n.maxWidth=s.getFloat64(a,!0);break;case 55:n.minHeight=s.getFloat64(a,!0);break;case 51:n.maxHeight=s.getFloat64(a,!0);break;case 54:n.minFrameRate=s.getFloat64(a,!0);break;case 50:n.maxFrameRate=s.getFloat64(a,!0);break;case 57:n.selectionPriority=s.getFloat64(a,!0);break;case 58:n.segmentAlignment=Mi(s.getFloat64(a,!0));break;case 59:n.subsegmentAlignment=Mi(s.getFloat64(a,!0));break;case 32:n.bitstreamSwitching=s.getFloat64(a,!0)!==0;break;case 3:n.audioSamplingRate=F(t,e.buffer,a,o);break;case 4:n.codecs=F(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=F(t,e.buffer,a,o);break;case 2:n.profiles=F(t,e.buffer,a,o);break;case 12:n.segmentProfiles=F(t,e.buffer,a,o);break;case 11:n.mimeType=F(t,e.buffer,a,o);break;case 5:n.codingDependency=s.getFloat64(a,!0)!==0;break;case 6:n.frameRate=s.getFloat64(a,!0);break;case 7:n.height=s.getFloat64(a,!0);break;case 8:n.width=s.getFloat64(a,!0);break;case 9:n.maxPlayoutRate=s.getFloat64(a,!0);break;case 10:n.maximumSAPPeriod=s.getFloat64(a,!0);break;case 43:n.availabilityTimeOffset=s.getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=s.getUint8(0)===0;break;case 71:let u=F(t,e.buffer,a,o);n.label=u;break}}}function Bo(n,e,t,r){return function(a){switch(a){case 6:{let o={};n.events.push(o);let s=ud(o,e,r);t.pushParsers(a,N,s);break}default:t.pushParsers(a,N,N);break}}}function Uo(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 16:n.schemeIdUri=F(t,e.buffer,a,o);break;case 17:n.value=F(t,e.buffer,a,o);break;case 27:n.timescale=s.getFloat64(a,!0);break;case 70:let u={key:\"\",value:\"\"},l=a,d=s.getUint32(l);l+=4,u.key=F(t,e.buffer,l,d),l+=d;let f=s.getUint32(l);l+=4,u.value=F(t,e.buffer,l,f),n.namespaces===void 0?n.namespaces=[u]:n.namespaces.push(u);break}}}function ud(n,e,t){let r=new TextDecoder;return function(a,o,s){let u=new DataView(e.buffer);switch(a){case 25:n.presentationTime=u.getFloat64(o,!0);break;case 1:n.duration=u.getFloat64(o,!0);break;case 0:n.id=F(r,e.buffer,o,s);break;case 69:let l=u.getFloat64(o,!0),d=u.getFloat64(o+8,!0);n.eventStreamData=t.slice(l,d);break}}}function _r(n,e,t,r){return function(a){switch(a){case 4:{let o={children:{baseURLs:[],representations:[]},attributes:{}};n.adaptations.push(o);let s=Do(o.children,e,t),u=No(o.attributes,e);t.pushParsers(a,s,u);break}case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=N,u=pt(o,e);t.pushParsers(a,s,u);break}case 5:{let o={children:{events:[]},attributes:{}};n.eventStreams.push(o);let s=Bo(o.children,e,t,r),u=Uo(o.attributes,e);t.pushParsers(a,s,u);break}case 16:{let o={};n.segmentTemplate=o,t.pushParsers(a,N,Lt(o,e));break}default:t.pushParsers(a,N,N);break}}}function Er(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 45:n.start=new DataView(e.buffer).getFloat64(a,!0);break;case 1:n.duration=new DataView(e.buffer).getFloat64(a,!0);break;case 32:n.bitstreamSwitching=new DataView(e.buffer).getUint8(0)===0;break;case 46:n.xlinkHref=F(t,e.buffer,a,o);break;case 47:n.xlinkActuate=F(t,e.buffer,a,o);break;case 43:n.availabilityTimeOffset=new DataView(e.buffer).getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break;case 70:let s={key:\"\",value:\"\"},u=new DataView(e.buffer),l=a,d=u.getUint32(l);l+=4,s.key=F(t,e.buffer,l,d),l+=d;let f=u.getUint32(l);l+=4,s.value=F(t,e.buffer,l,f),n.namespaces===void 0?n.namespaces=[s]:n.namespaces.push(s);break}}}function Lo(n,e,t,r){return function(a){switch(a){case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=N,u=pt(o,e);t.pushParsers(a,s,u);break}case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=_r(o.children,e,t,r),u=Er(o.attributes,e);t.pushParsers(a,s,u);break}case 3:{let o={};n.utcTimings.push(o);let s=N,u=Ve(o,e);t.pushParsers(a,s,u);break}default:t.pushParsers(a,N,N);break}}}function Fo(n,e,t){let r,i=new TextDecoder;return function(o,s,u){switch(o){case 0:e.id=F(i,t.buffer,s,u);break;case 2:e.profiles=F(i,t.buffer,s,u);break;case 33:e.type=F(i,t.buffer,s,u);break;case 34:let l=F(i,t.buffer,s,u);e.availabilityStartTime=new Date(l).getTime()/1e3;break;case 35:let d=F(i,t.buffer,s,u);e.availabilityEndTime=new Date(d).getTime()/1e3;break;case 36:let f=F(i,t.buffer,s,u);e.publishTime=new Date(f).getTime()/1e3;break;case 68:r=new DataView(t.buffer),e.duration=r.getFloat64(s,!0);break;case 37:r=new DataView(t.buffer),e.minimumUpdatePeriod=r.getFloat64(s,!0);break;case 38:r=new DataView(t.buffer),e.minBufferTime=r.getFloat64(s,!0);break;case 39:r=new DataView(t.buffer),e.timeShiftBufferDepth=r.getFloat64(s,!0);break;case 40:r=new DataView(t.buffer),e.suggestedPresentationDelay=r.getFloat64(s,!0);break;case 41:r=new DataView(t.buffer),e.maxSegmentDuration=r.getFloat64(s,!0);break;case 42:r=new DataView(t.buffer),e.maxSubsegmentDuration=r.getFloat64(s,!0);break;case 66:let m=F(i,t.buffer,s,u);n.locations.push(m);break;case 70:let p={key:\"\",value:\"\"};r=new DataView(t.buffer);let g=s,I=r.getUint32(g);g+=4,p.key=F(i,t.buffer,g,I),g+=I;let h=r.getUint32(g);g+=4,p.value=F(i,t.buffer,g,h),e.namespaces===void 0?e.namespaces=[p]:e.namespaces.push(p);break}}}function Oi(n,e,t,r){return function(a){switch(a){case 1:n.mpd={children:{baseURLs:[],locations:[],periods:[],utcTimings:[]},attributes:{}};let o=Lo(n.mpd.children,e,t,r),s=Fo(n.mpd.children,n.mpd.attributes,e);t.pushParsers(a,o,s);break;default:t.pushParsers(a,N,N);break}}}function zo(n,e,t,r){return function(a){switch(a){case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=_r(o.children,e,t,r),u=Er(o.attributes,e);t.pushParsers(a,s,u);break}default:t.pushParsers(a,N,N);break}}}var cn=class{constructor(){this._currentNodeId=null,this.childrenParser=N,this.attributeParser=N,this._stack=[{nodeId:null,children:N,attribute:N}]}pushParsers(e,t,r){this._currentNodeId=e,this.childrenParser=t,this.attributeParser=r,this._stack.push({nodeId:e,attribute:r,children:t})}popIfCurrent(e){if(this._currentNodeId!==e)return;this._stack.pop();let{nodeId:t,children:r,attribute:i}=this._stack[this._stack.length-1];this._currentNodeId=t,this.attributeParser=i,this.childrenParser=r}reset(){this.childrenParser=N,this.attributeParser=N,this._stack=[{nodeId:null,children:N,attribute:N}]}};var dd=15e3,pn=class{constructor(){this._parsersStack=new cn,this._instance=null,this._mpdData=null,this._linearMemory=null,this.status=\"uninitialized\",this._initProm=null,this._warnings=[],this._isParsing=!1}waitForInitialization(){var e;return(e=this._initProm)!=null?e:Promise.reject(\"No initialization performed yet.\")}async initialize(e){if(this.status!==\"uninitialized\")return Promise.reject(new Error(\"DashWasmParser already initialized.\"));if(!this.isCompatible())return this.status=\"failure\",Promise.reject(new Error(\"Target not compatible with WebAssembly.\"));this.status=\"initializing\";let t=this._parsersStack,r=new TextDecoder,i=this,a={env:{memoryBase:0,tableBase:0,memory:new WebAssembly.Memory({initial:10}),table:new WebAssembly.Table({initial:1,element:\"anyfunc\"}),onTagOpen:l,onCustomEvent:m,onAttribute:f,readNext:p,onTagClose:d}},o=null,s;typeof e.wasmUrl==\"string\"?s=fetch(e.wasmUrl):(o=URL.createObjectURL(new Blob([e.wasmUrl],{type:\"application/wasm\"})),s=fetch(o));let u=typeof WebAssembly.instantiateStreaming==\"function\"?WebAssembly.instantiateStreaming(s,a):Promise.reject(\"`WebAssembly.instantiateStreaming` API not available\");return this._initProm=u.catch(async g=>{o!==null&&(URL.revokeObjectURL(o),o=null),c.warn(\"Unable to call `instantiateStreaming` on WASM\",g instanceof Error?g:\"\");let I=await s;if(I.status<200||I.status>=300)throw new Error(\"WebAssembly request failed. status: \"+String(I.status));let h=await I.arrayBuffer();return WebAssembly.instantiate(h,a)}).then(g=>{o!==null&&(URL.revokeObjectURL(o),o=null),this._instance=g,this._linearMemory=this._instance.instance.exports.memory,this.status=\"initialized\"}).catch(g=>{let I=g instanceof Error?g.toString():\"Unknown error\";throw c.warn(\"DW: Could not create DASH-WASM parser:\",I),this.status=\"failure\",g}),this._initProm;function l(g){return t.childrenParser(g)}function d(g){return t.popIfCurrent(g)}function f(g,I,h){return t.attributeParser(g,I,h)}function m(g,I,h){let y=i._linearMemory,E=new Uint8Array(y.buffer,I,h);if(g===1){let v=r.decode(E);c.warn(\"WASM Error Event:\",v),i._warnings.push(new Error(v))}else if(g===0){let v=r.decode(E);c.warn(\"WASM Log Event:\",v)}}function p(g,I){if(i._mpdData===null)throw new Error(\"DashWasmParser Error: No MPD to read.\");let h=i._linearMemory,{mpd:y,cursor:E}=i._mpdData,v=Math.min(I,dd,y.byteLength-E);return new Uint8Array(h.buffer,g,v).set(new Uint8Array(y,E,v)),i._mpdData.cursor+=v,v}}runWasmParser(e,t){let[r,i]=this._parseMpd(e);if(r===null)throw new Error(\"DASH Parser: Unknown error while parsing the MPD\");let a=gr(r,t,i);return this._processParserReturnValue(a)}isCompatible(){return ko&&typeof Ee.TextDecoder==\"function\"}_parseMpd(e){var s;if(this._instance===null)throw new Error(\"DashWasmParser not initialized\");if(this._isParsing)throw new Error(\"Parsing operation already pending.\");this._isParsing=!0,this._mpdData={mpd:e,cursor:0};let t={},r=this._linearMemory,i=Oi(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,N),this._warnings=[];try{this._instance.instance.exports.parse()}catch(u){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,u}let a=(s=t.mpd)!=null?s:null,o=this._warnings;return this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,[a,o]}_parseXlink(e){if(this._instance===null)throw new Error(\"DashWasmParser not initialized\");if(this._isParsing)throw new Error(\"Parsing operation already pending.\");this._isParsing=!0,this._mpdData={mpd:e,cursor:0};let t={periods:[]},r=this._linearMemory,i=zo(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,N),this._warnings=[];try{this._instance.instance.exports.parse()}catch(s){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,s}let{periods:a}=t,o=this._warnings;return this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,[a,o]}_processParserReturnValue(e){if(e.type===\"done\")return e;if(e.type===\"needs-clock\"){let t=r=>{if(r.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let i=e.value.continue(r[0].responseData);return this._processParserReturnValue(i)};return{type:\"needs-resources\",value:{urls:[e.value.url],format:\"string\",continue:t}}}else if(e.type===\"needs-xlinks\"){let t=r=>{let i=[];for(let o=0;o<r.length;o++){let{responseData:s,receivedTime:u,sendingTime:l,url:d}=r[o];if(!s.success)throw s.error;let[f,m]=this._parseXlink(s.data);i.push({url:d,receivedTime:u,sendingTime:l,parsed:f,warnings:m})}let a=e.value.continue(i);return this._processParserReturnValue(a)};return{type:\"needs-resources\",value:{urls:e.value.xlinksUrls,format:\"arraybuffer\",continue:t}}}else ze(e)}};var Wo=pn;var vt=class{constructor(e,t){this._last=e,this._wanted=t}serialize(){return[this._last,this._wanted]}getPolled(){return this._last}getWanted(){var e;return(e=this._wanted)!=null?e:this._last}forceWantedPosition(e){this._wanted=e}isAwaitingFuturePosition(){return this._wanted!==null}};function Rr(n,e,t){let r=e(n.getReference(),t);return{getCurrentTime(){return n.getCurrentTime()},getReadyState(){return n.getReadyState()},getPlaybackRate(){return n.getPlaybackRate()},getIsPaused(){return n.getIsPaused()},getReference(){return r},listen(i,a){var o;t.isCancelled()||((o=a==null?void 0:a.clearSignal)==null?void 0:o.isCancelled())===!0||r.onUpdate(i,{clearSignal:a==null?void 0:a.clearSignal,emitCurrentValue:a==null?void 0:a.includeLastObservation})},deriveReadOnlyObserver(i){return Rr(this,i,t)}}}var gn=class{constructor(e,t,r,i){this._src=e,this._contentId=t,this._messageSender=r,this._cancelSignal=i}getCurrentTime(){}getReadyState(){}getIsPaused(){}getReference(){return this._src}setPlaybackRate(e){this._messageSender({type:\"update-playback-rate\",contentId:this._contentId,value:e})}getPlaybackRate(){}listen(e,t){var r;this._cancelSignal.isCancelled()||((r=t==null?void 0:t.clearSignal)==null?void 0:r.isCancelled())===!0||this._src.onUpdate(e,{clearSignal:t==null?void 0:t.clearSignal,emitCurrentValue:t==null?void 0:t.includeLastObservation})}deriveReadOnlyObserver(e){return Rr(this,e,this._cancelSignal)}};function wi(n,e){return(t,r,i)=>new Promise((a,o)=>{let s=Date.now()-L(),u=!1,m={reject:I=>{var v,T;if(u||i.isCancelled())return;u=!0,i.deregister(g);let h=I,y=(v=h==null?void 0:h.message)!=null?v:\"Unknown error when fetching the Manifest through a custom manifestLoader.\",E=new Ge(y,(T=h==null?void 0:h.canRetry)!=null?T:!1,h==null?void 0:h.xhr);o(E)},resolve:I=>{if(u||i.isCancelled())return;u=!0,i.deregister(g);let h=I.receivingTime!==void 0?I.receivingTime-s:void 0,y=I.sendingTime!==void 0?I.sendingTime-s:void 0;a({responseData:I.data,size:I.size,requestDuration:I.duration,url:I.url,receivedTime:h,sendingTime:y})},fallback:()=>{u||i.isCancelled()||(u=!0,i.deregister(g),e(t,r,i).then(a,o))}},p=n({url:t,timeout:r.timeout},m);i.register(g);function g(I){u||(u=!0,typeof p==\"function\"&&p(),o(I))}})}function ld(n){return function(t,r,i){if(t===void 0)throw new Error(\"Cannot perform HTTP(s) request. URL not known\");switch(n){case\"arraybuffer\":return le({url:t,responseType:\"arraybuffer\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"text\":return le({url:t,responseType:\"text\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"document\":return le({url:t,responseType:\"document\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});default:ze(n)}}}function Di({customManifestLoader:n},e){let t=ld(e);return typeof n!=\"function\"?t:wi(n,t)}function Ni(n){let{referenceDateTime:e}=n,t=n.serverSyncInfos!==void 0?n.serverSyncInfos.serverTimestamp-n.serverSyncInfos.clientTime:void 0;return function(i,a,o,s,u){var E;let{responseData:l}=i,d=a.externalClockOffset,f=(E=i.url)!=null?E:a.originalUrl,m=t!=null?t:d,g={unsafelyBaseOnPreviousManifest:a.unsafeMode?a.previousManifest:null,url:f,referenceDateTime:e,externalClockOffset:m},I=ae.dashParsers;if(I.wasm===null||I.wasm.status===\"uninitialized\"||I.wasm.status===\"failure\")return c.debug(\"DASH: WASM MPD Parser not initialized. Running JS one.\"),h();{let v=gd(l);if(!hd(v))return c.info(\"DASH: MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one.\"),h();if(I.wasm.status===\"initialized\"){c.debug(\"DASH: Running WASM MPD Parser.\");let T=I.wasm.runWasmParser(v,g);return y(T)}else return c.debug(\"DASH: Awaiting WASM initialization before parsing the MPD.\"),I.wasm.waitForInitialization().catch(()=>{}).then(()=>{if(I.wasm===null||I.wasm.status!==\"initialized\")return c.warn(\"DASH: WASM MPD parser initialization failed. Running JS parser instead\"),h();c.debug(\"DASH: Running WASM MPD Parser.\");let C=I.wasm.runWasmParser(v,g);return y(C)})}function h(){if(I.fastJs!==null){let v=cd(l),T=I.fastJs(v,g);return y(T)}else if(I.native!==null){let v=pd(l),T=I.native(v,g);return y(T)}else throw new Error(\"No MPD parser is imported\")}function y(v){if(v.type===\"done\"){if(v.value.warnings.length>0&&o(v.value.warnings),s.isCancelled())return Promise.reject(s.cancellationError);let P=[];return{manifest:new wt(v.value.parsed,n,P),url:f,warnings:P}}let{value:T}=v,C=T.urls.map(P=>u(()=>{let M=U.getCurrent().DEFAULT_REQUEST_TIMEOUT,_=U.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return T.format===\"string\"?le({url:P,responseType:\"text\",timeout:M,connectionTimeout:_,cancelSignal:s}):le({url:P,responseType:\"arraybuffer\",timeout:M,connectionTimeout:_,cancelSignal:s})}).then(M=>{if(T.format===\"string\"){if(typeof M.responseData!=\"string\")throw new Error(\"External DASH resources should have been a string\");return H(M,{responseData:{success:!0,data:M.responseData}})}else{if(!(M.responseData instanceof ArrayBuffer))throw new Error(\"External DASH resources should have been ArrayBuffers\");return H(M,{responseData:{success:!0,data:M.responseData}})}},M=>{let _=ge(M,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"An unknown error occured when parsing ressources.\"});return H({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:_}})}));return Promise.all(C).then(P=>T.format===\"string\"?(fd(P),y(T.continue(P))):(md(P),y(T.continue(P))))}}}function fd(n){b.CURRENT_ENV!==b.PRODUCTION&&n.forEach(e=>{let{responseData:t}=e;if(!(t.success&&typeof t.data==\"string\")&&t.success)throw new Error(\"Invalid data given to the LoadedRessource\")})}function md(n){b.CURRENT_ENV!==b.PRODUCTION&&n.forEach(e=>{let{responseData:t}=e;if(!(t.success&&t.data instanceof ArrayBuffer)&&t.success)throw new Error(\"Invalid data given to the LoadedRessource\")})}function cd(n){if(n instanceof ArrayBuffer)return Be(new Uint8Array(n));if(typeof n==\"string\")return n;if(n instanceof Document)return n.documentElement.outerHTML;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function pd(n){if(n instanceof ArrayBuffer)return new DOMParser().parseFromString(Be(new Uint8Array(n)),\"text/xml\");if(typeof n==\"string\")return new DOMParser().parseFromString(n,\"text/xml\");if(n instanceof Document)return n;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function gd(n){if(n instanceof ArrayBuffer)return n;if(typeof n==\"string\")return dn(n).buffer;if(n instanceof Document)return dn(n.documentElement.innerHTML).buffer;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function hd(n){let e=new DataView(n);return e.getUint16(0)===61371&&e.getUint8(2)===191?!0:!(e.getUint16(0)===65279||e.getUint16(0)===65534)}function Oe([n,e]){return e===1/0?`bytes=${n}-`:`bytes=${n}-${e}`}function qe(n,e){if(n===\"audio\"||n===\"video\")return e===\"video/mp4\"||e===\"audio/mp4\"?\"mp4\":e===\"video/webm\"||e===\"audio/webm\"?\"webm\":void 0;if(n===\"text\")return e===\"application/mp4\"?\"mp4\":void 0}var W=class{constructor(){let[e,t]=Id();this._isUsed=!1,this._trigger=e,this.signal=new Bi(t)}isUsed(){return this._isUsed}linkToSignal(e){let t=e.register(()=>{this.cancel()});return this.signal.register(t),t}cancel(e){if(this._isUsed)return;this._isUsed=!0;let t=e!=null?e:new ie;this._trigger(t)}static isCancellationError(e){return e instanceof ie}},Bi=class{constructor(e){this._isCancelled=!1,this.cancellationError=null,this._listeners=[],e(t=>{for(this.cancellationError=t,this._isCancelled=!0;this._listeners.length>0;)try{let r=this._listeners.pop();r==null||r(t)}catch(r){c.error(\"Error while calling clean up listener\",r instanceof Error?r.toString():\"Unknown error\")}})}isCancelled(){return this._isCancelled}register(e){return this._isCancelled?(he(this.cancellationError!==null),e(this.cancellationError),N):(this._listeners.push(e),()=>this.deregister(e))}deregister(e){for(let t=this._listeners.length-1;t>=0;t--)this._listeners[t]===e&&this._listeners.splice(t,1)}},ie=class n extends Error{constructor(){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"CancellationError\",this.message=\"This task was cancelled.\"}};function Id(){let n=N;return[function(t){n(t)},function(t){n=t}]}function rt(...n){let e=n.length,t=-1,r=0,i;for(;++t<e;)i=n[t],r+=typeof i==\"number\"?i:i.length;let a=new Uint8Array(r),o=0;for(t=-1;++t<e;)i=n[t],typeof i==\"number\"?o+=i:i.length>0&&(a.set(i,o),o+=i.length);return a}function Vo(n,e){return(n[e+0]<<8)+(n[e+1]<<0)}function Ui(n,e){return n[e+0]*65536+n[e+1]*256+n[e+2]}function te(n,e){return n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3]}function gt(n,e){return(n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3])*4294967296+n[e+4]*16777216+n[e+5]*65536+n[e+6]*256+n[e+7]}function Qe(n,e){let t=n.length,r=0;for(;r+8<=t;){let i=te(n,r);if(i===0)i=t-r;else if(i===1){if(r+16>t)return-1;i=gt(n,r+8)}if(isNaN(i)||i<=0)return-1;if(te(n,r+4)===e)return r+i<=t?r:-1;r+=i}return-1}function Pr(n){let e=0,t=[],r=null;for(;e<=n.length;){if(e===n.length){r=null;break}r=n.subarray(e,1/0);let i=Qe(r,1836019558);if(i<0)break;let a=te(n,i+e),o=e+i+a;if(o>n.length)break;let s=Qe(r,1835295092);if(s<0)break;let u=te(n,s+e),l=e+s+u;if(l>n.length)break;let d=Math.max(o,l),f=n.subarray(e,d);t.push(f),e=d}return t.length===0?[null,r]:[rt(...t),r]}function bd(n,e,t){return new Uint8Array(Array.prototype.slice.call(n,e,t))}function Sd(n,e,t){return n.slice(e,t)}var Li=typeof Uint8Array.prototype.slice==\"function\"?Sd:bd;function Fi(n,e){let t=n;for(let r of e){let i=ue(t,r);if(i===null)return null;t=i}return t}function ue(n,e){let t=Ft(n,e);return t!==null?n.subarray(t[1],t[2]):null}function qo(n,e){let t=[],r=n;for(;;){let i=Ft(r,e);if(i===null)return t;he(i[2]!==0&&r.length!==0),t.push(r.subarray(i[1],i[2])),r=r.subarray(i[2])}}function Ft(n,e){let t=n.length,r=0,i,a=0,o;for(;r+8<=t;){if(o=r,a=te(n,o),o+=4,i=te(n,o),o+=4,a===0)a=t-r;else if(a===1){if(o+8>t)return null;a=gt(n,o),o+=8}if(a<0)throw new Error(\"ISOBMFF: Size out of range\");if(i===e)return e===1970628964&&(o+=16),[r,o,r+a];r+=a}return null}function vr(n){let e=0,t=ue(n,1836019574);if(t===null)return[];let r=[];for(;e<t.length;){let i;try{i=Ft(t,1886614376)}catch(s){let u=s instanceof Error?s:\"\";return c.warn(\"Error while removing PSSH from ISOBMFF\",u),r}if(i===null)return r;let a=Li(t,i[0],i[2]),o=Ho(a,i[1]-i[0]);o!==void 0&&r.push({systemId:o,data:a}),t[i[0]+4]=102,t[i[0]+5]=114,t[i[0]+6]=101,t[i[0]+7]=101,e=i[2]}return r}function Ho(n,e){if(n[e]>1){c.warn(\"ISOBMFF: un-handled PSSH version\");return}let t=e+4;if(t+16>n.length)return;let r=Li(n,t,t+16);return ho(r)}function zi(n){let e=ue(n,1836019558);return e===null?null:ue(e,1953653094)}function Go(n){return qo(n,1836019558).reduce((t,r)=>{let i=ue(r,1953653094);return i!==null&&t.push(i),t},[])}function Wi(n){return ue(n,1835295092)}function Vi(n){let e=ue(n,1836019574);if(e===null)return null;let t=ue(e,1953653099);return t===null?null:ue(t,1835297121)}function Ko(n,e=0){return ue(n.subarray(e),1701671783)}function hn(n,e){let t=Ft(n,1936286840);if(t===null)return null;let r=e,i=t[2]-t[0],a=t[1],o=n[a];a+=8;let s=te(n,a);a+=4;let u;if(o===0)u=te(n,a),a+=4,r+=te(n,a)+i,a+=4;else if(o===1)u=gt(n,a),a+=8,r+=gt(n,a)+i,a+=8;else return null;let l=[];a+=2;let d=Vo(n,a);for(a+=2;--d>=0;){let f=te(n,a);a+=4;let m=(f&2147483648)>>>31,p=f&2147483647;if(m===1)throw new Error(\"sidx with reference_type `1` not yet implemented\");let g=te(n,a);a+=4,a+=4,l.push({time:u,duration:g,timescale:s,range:[r,r+p-1]}),u+=g,r+=p}return l}function qi(n){let e=zi(n);if(e===null)return;let t=ue(e,1952867444);if(t===null)return;let r=t[0];if(r===1)return gt(t,4);if(r===0)return te(t,4)}function yd(n){let e=ue(n,1952868452);if(e===null)return;let t=1,r=Ui(e,t);t+=3;let i=(r&1)>0,a=(r&2)>0;return(r&8)>0?(t+=4,i&&(t+=8),a&&(t+=4),te(e,t)):void 0}function Hi(n){let e=Go(n);if(e.length===0)return;let t=0;for(let r of e){let i=ue(r,1953658222);if(i===null)return;let a=0,o=i[a];if(a+=1,o>1)return;let s=Ui(i,a);a+=3;let u=(s&256)>0,l=0;if(!u&&(l=yd(r),l===void 0))return;let d=(s&1)>0,f=(s&4)>0,m=(s&512)>0,p=(s&1024)>0,g=(s&2048)>0,I=te(i,a);a+=4,d&&(a+=4),f&&(a+=4);let h=I,y=0;for(;h-- >0;)u?(y+=te(i,a),a+=4):y+=l,m&&(a+=4),p&&(a+=4),g&&(a+=4);t+=y}return t}function In(n){let e=Vi(n);if(e===null)return;let t=ue(e,1835296868);if(t===null)return;let r=0,i=t[r];if(r+=4,i===1)return te(t,r+16);if(i===0)return te(t,r+8)}function jo(n){let e=[],t=0;for(;t<n.length;){let r=Ko(n,t);if(r===null)break;let i=r.length;t+=i;let a=r[0];if(a!==0)c.warn(\"ISOBMFF: EMSG version \"+a.toString()+\" not supported.\");else{let o=4,{end:s,string:u}=Ii(r,o);o=s;let{end:l,string:d}=Ii(r,o);o=l;let f=te(r,o);o+=4;let m=te(r,o);o+=4;let p=te(r,o);o+=4;let g=te(r,o);o+=4;let I=r.subarray(o,i),h={schemeIdUri:u,value:d,timescale:f,presentationTimeDelta:m,eventDuration:p,id:g,messageData:I};e.push(h)}}if(e.length!==0)return e}function Yo(n){let e=Fi(n,[1836019574,1953653099,1835297121,1835626086,1937007212,1937011556]);if(e===null)return null;let t=e.subarray(8),r=ue(t,1701733238),i=0;if(r===null?(i=28,r=ue(t,1701733217)):i=78,r===null)return null;let a=Fi(r.subarray(i),[1936289382,1935894633,1952804451]);return a===null||a.byteLength<24?null:a.subarray(8,24)}function Gi(n,e){if(e){if(Qe(n,1718909296)<0)throw new Re(\"INTEGRITY_ERROR\",\"Incomplete `ftyp` box\");if(Qe(n,1836019574)<0)throw new Re(\"INTEGRITY_ERROR\",\"Incomplete `moov` box\")}else{if(Qe(n,1836019558)<0)throw new Re(\"INTEGRITY_ERROR\",\"Incomplete `moof` box\");if(Qe(n,1835295092)<0)throw new Re(\"INTEGRITY_ERROR\",\"Incomplete `mdat` box\")}}function bn(n){return(e,t,r,i,a)=>{return new Promise((s,u)=>{let l=new W,d=l.linkToSignal(i);l.signal.register(u),n(e,t,r,l.signal,Le(_e({},a),{onNewChunk(m){try{o(m),a.onNewChunk(m)}catch(p){f(),l.cancel(),u(p)}}})).then(m=>{if(f(),!l.isUsed()){if(m.resultType===\"segment-loaded\")try{o(m.resultData.responseData)}catch(p){u(p);return}s(m)}},m=>{f(),u(m)});function f(){l.signal.deregister(u),d()}});function o(s){!(s instanceof ArrayBuffer)&&!(s instanceof Uint8Array)||qe(t.type,t.mimeType)!==\"mp4\"||Gi(new Uint8Array(s),t.segment.isInit)}}}function Sn(n,e){return n===null?null:e.url===null?n.baseUrl:sn(n.baseUrl,e.url)}function yn(n,e,t,r,i){if(e.range===void 0)return le({url:n,responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(s=>({resultType:\"segment-loaded\",resultData:s}));if(e.indexRange===void 0)return le({url:n,headers:{Range:Oe(e.range)},responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(s=>({resultType:\"segment-loaded\",resultData:s}));if(e.range[1]+1===e.indexRange[0])return le({url:n,headers:{Range:Oe([e.range[0],e.indexRange[1]])},responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(s=>({resultType:\"segment-loaded\",resultData:s}));let a=le({url:n,headers:{Range:Oe(e.range)},responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),o=le({url:n,headers:{Range:Oe(e.indexRange)},responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([a,o]).then(([s,u])=>{let l=rt(new Uint8Array(s.responseData),new Uint8Array(u.responseData)),d=Math.min(s.sendingTime,u.sendingTime),f=Math.max(s.receivedTime,u.receivedTime);return{resultType:\"segment-loaded\",resultData:{url:n,responseData:l,size:s.size+u.size,requestDuration:f-d,sendingTime:d,receivedTime:f}}})}function Tn(n,e,t,r,i){let{segment:a}=e,o=a.range!==void 0?{Range:Oe(a.range)}:void 0,s=null;function u(l){let d=new Uint8Array(l.chunk),f=s!==null?rt(s,d):d,m=Pr(f),p=m[0];s=m[1],!(p!==null&&(r.onNewChunk(p),i.isCancelled()))&&(r.onProgress({duration:l.duration,size:l.size,totalSize:l.totalSize}),i.isCancelled())}return rr({url:n,headers:o,onData:u,timeout:t.timeout,cancelSignal:i}).then(l=>({resultType:\"chunk-complete\",resultData:l}))}function Qo(n,e,t,r,i,a){if(e.segment.isInit)return yn(n,e.segment,r,a,i);let o=qe(e.type,e.mimeType);if(t&&(o===\"mp4\"||o===void 0)){if($t())return Tn(n,e,r,i,a);Xe(\"DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge\")}let{segment:s}=e;return le({url:n,responseType:\"arraybuffer\",headers:s.range!==void 0?{Range:Oe(s.range)}:void 0,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:a,onProgress:i.onProgress}).then(u=>({resultType:\"segment-loaded\",resultData:u}))}function Ki({lowLatencyMode:n,segmentLoader:e,checkMediaSegmentIntegrity:t}){return t!==!0?r:bn(r);function r(i,a,o,s,u){let l=Sn(i,a.segment);return l===null?Promise.resolve({resultType:\"segment-created\",resultData:null}):n||e===void 0?Qo(l,a,n,o,u,s):new Promise((d,f)=>{let m=!1,y={reject:P=>{var x,k;if(m||s.isCancelled())return;m=!0,s.deregister(C);let M=P,_=(x=M==null?void 0:M.message)!=null?x:\"Unknown error when fetching a DASH segment through a custom segmentLoader.\",A=new Ge(_,(k=M==null?void 0:M.canRetry)!=null?k:!1,M==null?void 0:M.xhr);f(A)},resolve:P=>{m||s.isCancelled()||(m=!0,s.deregister(C),d({resultType:\"segment-loaded\",resultData:{responseData:P.data,size:P.size,requestDuration:P.duration}}))},progress:P=>{m||s.isCancelled()||u.onProgress({duration:P.duration,size:P.size,totalSize:P.totalSize})},fallback:()=>{m||s.isCancelled()||(m=!0,s.deregister(C),Qo(l,a,n,o,u,s).then(d,f))}},E;a.segment.range!==void 0&&(E=[a.segment.range],a.segment.indexRange!==void 0&&E.push(a.segment.indexRange));let v={isInit:a.segment.isInit,timeout:o.timeout,byteRanges:E,trackType:a.type,url:l},T=e(v,y);s.register(C);function C(P){m||(m=!0,typeof T==\"function\"&&T(),f(P))}})}}var Yi=408125543,$o=357149030,Td=2807729,_d=17545,Ed=475249515,Rd=187,Pd=179,vd=183,Cd=241;function ht(n,e,t,[r,i]){let a=r;for(;a<i;){let o=kd(t,a);if(o===null)return null;let{value:s,length:u}=o,l=a+u,d=xd(t,l);if(d===null)return null;let{length:f,value:m}=d,p=l+f,g=p+m;if(s===n)return[p,g];if(e.length>0){for(let I=0;I<e.length;I++)if(s===e[I]){let h=e.slice(I+1,e.length);return ht(n,h,t,[p,g])}}a=g}return null}function Cr(n,e){let t=ht(Td,[Yi,$o],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return 1e9/ji(n,t[0],r)}function Ad(n,e){let t=ht(_d,[Yi,$o],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return r===4?Md(n,t[0]):r===8?Od(n,t[0]):null}function Qi(n,e){let t=ht(Yi,[],n,[e,n.length]);if(t===null)return null;let[r,i]=t,a=Cr(n,r);if(a===null)return null;let o=Ad(n,r);if(o===null)return null;let s=ht(Ed,[],n,[r,i]);if(s===null)return null;let u=[],l=s[0];for(;l<s[1];){let f=ht(Rd,[],n,[l,s[1]]);if(f===null)break;let m=ht(Pd,[],n,[f[0],f[1]]);if(m===null)return null;let p=ji(n,m[0],m[1]-m[0]),g=ht(Cd,[vd],n,[f[0],f[1]]);if(g===null)return null;let I=ji(n,g[0],g[1]-g[0])+r;u.push({time:p,rangeStart:I}),l=f[1]}let d=[];for(let f=0;f<u.length;f++){let m=u[f];f===u.length-1?d.push({time:m.time,timescale:a,duration:f===0?o:o-m.time,range:[m.rangeStart,1/0]}):d.push({time:m.time,timescale:a,duration:u[f+1].time-m.time,range:[m.rangeStart,u[f+1].rangeStart-1]})}return d}function Xo(n,e){for(let t=1;t<=8;t++)if(n[e]>=Math.pow(2,8-t))return t}function kd(n,e){let t=Xo(n,e);if(t===void 0)return c.warn(\"webm: unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm: impossible length\"),null;let r=0;for(let i=0;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return{length:t,value:r}}function xd(n,e){let t=Xo(n,e);if(t===void 0)return c.warn(\"webm: unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm: impossible length\"),null;let r=(n[e]&(1<<8-t)-1)*Math.pow(2,(t-1)*8);for(let i=1;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return{length:t,value:r}}function Md(n,e){return new DataView(n.buffer).getFloat32(e)}function Od(n,e){return new DataView(n.buffer).getFloat64(e)}function ji(n,e,t){let r=0;for(let i=0;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return r}function _n(n,e,t,r){let i=qi(n);if(i===void 0||r===void 0)return null;let a=t.timestampOffset!==void 0?i+t.timestampOffset*r:i,o=Hi(n);if(a<0&&(o!==void 0&&(o+=a),a=0),e||!t.complete)return o===void 0&&c.warn(\"DASH: Chunked segments should indicate a duration through their trun boxes\"),{time:a/r,duration:o!==void 0?o/r:void 0};let s,u=t.duration*r,l=Math.min(r*.9,u/4);return o!==void 0&&Math.abs(o-u)<=l&&(s=o),{time:a/r,duration:s!==void 0?s/r:s}}function wd(n,e){if(n.length<=0)return!1;let t=n.length;for(let r=0;r<t;r++){let i=n[r],a=e,{messageData:o}=i,s=Be(o),u=Date.parse(s);if(a===void 0||u===void 0||isNaN(u)||u>=a)return!0}return!1}function $i(n,e){if(n.length===0)return;let{manifestRefreshEventsFromEMSGs:t,EMSGs:r}=n.reduce((o,s)=>(s.schemeIdUri===\"urn:mpeg:dash:event:2012\"&&s.value===\"1\"?(o.manifestRefreshEventsFromEMSGs===void 0&&(o.manifestRefreshEventsFromEMSGs=[]),o.manifestRefreshEventsFromEMSGs.push(s)):(o.EMSGs===void 0&&(o.EMSGs=[]),o.EMSGs.push(s)),o),{manifestRefreshEventsFromEMSGs:void 0,EMSGs:void 0}),i=r==null?void 0:r.map(o=>({type:\"emsg\",value:o})),a=e===void 0||t===void 0?!1:wd(t,e);return{inbandEvents:i,needsManifestRefresh:a}}function Xi({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var v,T;let{segment:a,periodStart:o,periodEnd:s}=r,{data:u,isChunked:l}=t,d=[o,s];if(u===null)return a.isInit?{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:\"media\",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:0,protectionData:[],appendWindow:d};let f=u instanceof Uint8Array?u:new Uint8Array(u),m=qe(r.type,r.mimeType),p=m===\"mp4\"||m===void 0,g=[];if(p){let C=vr(f),P;a.isInit&&(P=(v=Yo(f))!=null?v:void 0),(C.length>0||P!==void 0)&&g.push({initDataType:\"cenc\",keyId:P,initData:C})}if(!a.isInit){let C=p?_n(f,l,a,i):null,P=(T=a.timestampOffset)!=null?T:0;if(p){let M=jo(f);if(M!==void 0){let _=M.filter(x=>a.privateInfos===void 0||a.privateInfos.isEMSGWhitelisted===void 0?!1:a.privateInfos.isEMSGWhitelisted(x)),A=$i(_,r.manifestPublishTime);if(A!==void 0){let{needsManifestRefresh:x,inbandEvents:k}=A;return{segmentType:\"media\",chunkData:f,chunkSize:f.length,chunkInfos:C,chunkOffset:P,appendWindow:d,inbandEvents:k,protectionData:g,needsManifestRefresh:x}}}}return{segmentType:\"media\",chunkData:f,chunkSize:f.length,chunkInfos:C,chunkOffset:P,protectionData:g,appendWindow:d}}let{indexRange:I}=a,h;if(m===\"webm\")h=Qi(f,0);else if(p&&(h=hn(f,Array.isArray(I)?I[0]:0),n===!0&&h!==null&&h.length>0)){let C=h[h.length-1];Array.isArray(C.range)&&(C.range[1]=1/0)}let y;p?y=In(f):m===\"webm\"&&(y=Cr(f,0));let E=R(y)?void 0:y;return{segmentType:\"init\",initializationData:f,initializationDataSize:f.length,protectionData:g,initTimescale:E,segmentList:h!=null?h:void 0}}}function Zi({lowLatencyMode:n,checkMediaSegmentIntegrity:e}){return e!==!0?t:bn(t);function t(r,i,a,o,s){let{segment:u}=i,{range:l}=u,d=Sn(r,u);if(d===null)return Promise.resolve({resultType:\"segment-created\",resultData:null});if(u.isInit)return yn(d,u,a,o,s);let f=qe(i.type,i.mimeType),m=f===\"mp4\"||f===void 0;if(n&&m){if($t())return Tn(d,i,a,s,o);Xe(\"DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge\")}return m?le({url:d,responseType:\"arraybuffer\",headers:Array.isArray(l)?{Range:Oe(l)}:null,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}).then(p=>({resultType:\"segment-loaded\",resultData:p})):le({url:d,responseType:\"text\",headers:Array.isArray(l)?{Range:Oe(l)}:null,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}).then(p=>({resultType:\"segment-loaded\",resultData:p}))}}function Dd(n){let e=Wi(n);return e===null?\"\":Be(e)}function Nd(n){if(n===void 0)throw new Error(\"Cannot parse subtitles: unknown format\");switch(n.toLowerCase()){case\"stpp\":case\"stpp.ttml.im1t\":return\"ttml\";case\"wvtt\":return\"vtt\"}throw new Error(`The codec used for the subtitles \"${n}\" is not managed yet.`)}function Bd(n,e){switch(e){case\"application/ttml+xml\":return\"ttml\";case\"application/x-sami\":case\"application/smil\":return\"sami\";case\"text/vtt\":return\"vtt\"}if(n!==void 0&&n.toLowerCase()===\"srt\")return\"srt\";throw new Error(`could not find a text-track parser for the type ${e!=null?e:\"\"}`)}function Zo({segment:n,language:e,codecs:t},r,i,a){if(n.isInit)return null;let o,s;i===null?a?(o=n.time,s=n.end):c.warn(\"Transport: Unavailable time data for current text track.\"):(o=i.time,i.duration!==void 0?s=o+i.duration:!a&&n.complete&&(s=o+n.duration));let u=Nd(t);return{data:Dd(r),type:u,language:e,start:o,end:s}}function Jo(n,e,t){let{segment:r}=n;if(r.isInit)return null;let i,a;t?c.warn(\"Transport: Unavailable time data for current text track.\"):(i=r.time,r.complete&&(a=r.time+r.duration));let o=Bd(n.codecs,n.mimeType);return{data:e,type:o,language:n.language,start:i,end:a}}function Ud(n,e,t,r,i){var m;let{segment:a}=t,{isInit:o,indexRange:s}=a,u;if(typeof n==\"string\"?u=dn(n):n instanceof Uint8Array?u=n:u=new Uint8Array(n),o){let p=hn(u,Array.isArray(s)?s[0]:0);if(i===!0&&p!==null&&p.length>0){let I=p[p.length-1];Array.isArray(I.range)&&(I.range[1]=1/0)}let g=In(u);return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:g,segmentList:p!=null?p:void 0}}let l=_n(u,e,a,r),d=Zo(t,u,l,e),f=(m=a.timestampOffset)!=null?m:0;return{segmentType:\"media\",chunkData:d,chunkSize:u.length,chunkInfos:l,chunkOffset:f,protectionData:[],appendWindow:[t.periodStart,t.periodEnd]}}function Ld(n,e,t){let{periodStart:r,periodEnd:i,segment:a}=t,{timestampOffset:o=0}=a;if(a.isInit)return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};let s,u;if(typeof n!=\"string\"){let d=n instanceof Uint8Array?n:new Uint8Array(n);s=Be(d),u=d.length}else s=n;return{segmentType:\"media\",chunkData:Jo(t,s,e),chunkSize:u,chunkInfos:null,chunkOffset:o,protectionData:[],appendWindow:[r,i]}}function Ji({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var f;let{periodStart:a,periodEnd:o,segment:s}=r,{data:u,isChunked:l}=t;if(u===null)return s.isInit?{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:\"media\",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:(f=s.timestampOffset)!=null?f:0,protectionData:[],appendWindow:[a,o]};let d=qe(r.type,r.mimeType);if(d===\"webm\")throw new Error(\"Text tracks with a WEBM container are not yet handled.\");return d===\"mp4\"?Ud(u,l,r,i,n):Ld(u,l,r)}}function es(n){let e=Di({customManifestLoader:n.manifestLoader},Fd()?\"text\":\"arraybuffer\"),t=Ni(n),r=Ki(n),i=Xi(n),a=Zi(n),o=Ji(n);return{manifest:{loadManifest:e,parseManifest:t},audio:{loadSegment:r,parseSegment:i},video:{loadSegment:r,parseSegment:i},text:{loadSegment:a,parseSegment:o}}}function Fd(){return ae.dashParsers.wasm!==null&&(ae.dashParsers.wasm.status===\"initialized\"||ae.dashParsers.wasm.status===\"initializing\")}var ts=es;var Ct=typeof queueMicrotask==\"function\"?queueMicrotask:function(e){Promise.resolve().then(e,()=>e())};var At=class{constructor(e){this._array=[],this._sortingFn=e}add(...e){e.sort(this._sortingFn);let t=0;for(let r=0;r<e.length;r++){let i=e[r],a=!1;for(;!a&&t<this._array.length;)this._sortingFn(i,this._array[t])<0?(this._array.splice(t,0,i),a=!0):t++;a||this._array.push(i)}}length(){return this._array.length}get(e){if(e<0||e>=this._array.length)throw new Error(\"Invalid index.\");return this._array[e]}toArray(){return this._array.slice()}findFirst(e){return K(this._array,e)}has(e){return se(this._array,e)}removeElement(e){let t=this._array.indexOf(e);if(t>=0)return this._array.splice(t,1),t}head(){return this._array[0]}last(){return this._array[this._array.length-1]}shift(){return this._array.shift()}pop(){return this._array.pop()}};var En=class{constructor(e){this._weakMap=new WeakMap,this._fn=e}get(e){let t=this._weakMap.get(e);if(t===void 0){let r=this._fn(e);return this._weakMap.set(e,r),r}else return t}destroy(e){this._weakMap.delete(e)}};var zd=.016666666666666666;function ns(n,e){return Math.abs(n-e)<zd}function is(n,e){let t=Math.min(n.start,e.start),r=Math.max(n.end,e.end);return{start:t,end:r}}function Wd(n){for(let e=0;e<n.length;e++){let t=n[e];t.start===t.end&&n.splice(e--,1)}return n}function Vd(n){for(let e=1;e<n.length;e++){let t=n[e-1],r=n[e];if(os(t,r)){let i=is(t,r);n.splice(--e,2,i)}}return n}function ea(n,e){return n.end<=e.start}function rs({start:n,end:e},t){return n<=t&&t<e}function as(n,e){return rs(n,e.start)||n.start<e.end&&e.end<n.end||rs(e,n.start)}function os(n,e){return ns(e.start,n.end)||ns(e.end,n.start)}function ta(n){let e=[];for(let t=0;t<n.length;t++)e.push({start:n.start(t),end:n.end(t)});return e}function qd(n,e){for(let t=n.length-1;t>=0;t--){let r=n[t].start;if(e>=r){let i=n[t].end;if(e<i)return n[t]}}return null}function ss(n,e){let t=null,r=[];for(let i=0;i<n.length;i++){let a=n[i].start,o=n[i].end;e<a||e>=o?r.push({start:a,end:o}):t={start:a,end:o}}return{outerRanges:r,innerRange:t}}function Ar(n,e){let t=qd(n,e);return t!==null?t.end-e:1/0}function zt(n,e){if(e.start===e.end)return n;let t=e,r=0;for(;r<n.length;r++){let i=n[r],a=as(t,i),o=os(t,i);if(a||o)t=is(t,i),n.splice(r--,1);else if(r===0){if(ea(t,n[0]))break}else if(ea(n[r-1],t)&&ea(t,i))break}return n.splice(r,0,t),Vd(Wd(n))}function Hd(n,e){let t=[];for(let r=0;r<e.length;r++)as(n,e[r])&&t.push(e[r]);return t}function kr(n,e){let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=[],o=Hd(i,e);if(o.length>0)for(let s=0;s<o.length;s++){let u=o[s];a.push({start:Math.max(i.start,u.start),end:Math.min(i.end,u.end)})}if(a.length===0)t.push(i);else{let s=i.start;for(let u=0;u<a.length;u++)a[u].start>s&&t.push({start:s,end:a[u].start}),s=a[u].end;s<i.end&&t.push({start:s,end:i.end})}}return t}function xr({segmentSink:n,playbackObserver:e,maxBufferBehind:t,maxBufferAhead:r},i){let a,o=[];e.listen(u=>{a=u.position.getWanted(),o=u.buffered[n.bufferType],s()},{includeLastObservation:!0,clearSignal:i});function s(){o!==null&&Gd(n,a,o,t.getValue(),r.getValue(),i).catch(u=>{let l=u instanceof Error?u.message:\"Unknown error\";c.error(\"Could not run BufferGarbageCollector:\",l)})}t.onUpdate(s,{clearSignal:i}),r.onUpdate(s,{clearSignal:i}),s()}async function Gd(n,e,t,r,i,a){if(!isFinite(r)&&!isFinite(i))return Promise.resolve();let o=[],{innerRange:s,outerRanges:u}=ss(t,e),l=()=>{if(isFinite(r)){for(let f=0;f<u.length;f++){let m=u[f];e-r>=m.end?o.push(m):e>=m.end&&e-r>m.start&&e-r<m.end&&o.push({start:m.start,end:e-r})}R(s)||e-r>s.start&&o.push({start:s.start,end:e-r})}},d=()=>{if(isFinite(i)){for(let f=0;f<u.length;f++){let m=u[f];e+i<=m.start?o.push(m):e<=m.start&&e+i<m.end&&e+i>m.start&&o.push({start:e+i,end:m.end})}R(s)||e+i<s.end&&o.push({start:e+i,end:s.end})}};l(),d();for(let f of o)if(f.start<f.end){if(c.debug(\"GC: cleaning range from SegmentSink\",f.start,f.end),a.cancellationError!==null)throw a.cancellationError;await n.removeBuffer(f.start,f.end)}}var Rn=class{constructor(e,t){this._history=[],this._lifetime=e,this._maxHistoryLength=t}addBufferedSegment(e,t){let r=L();this._history.push({date:r,buffered:t,context:e}),this._cleanHistory(r)}getHistoryFor(e){return this._history.filter(t=>Ze(t.context,e))}_cleanHistory(e){let t=e-this._lifetime,r=0;for(let i of this._history)if(i.date<t)r++;else break;if(r>0&&(this._history=this._history.splice(r)),this._history.length>this._maxHistoryLength){let i=this._history.length-this._maxHistoryLength;this._history=this._history.splice(i)}}};var Pn=class{constructor(){let{BUFFERED_HISTORY_RETENTION_TIME:e,BUFFERED_HISTORY_MAXIMUM_ENTRIES:t}=U.getCurrent();this._inventory=[],this._bufferedHistory=new Rn(e,t)}reset(){this._inventory.length=0}synchronizeBuffered(e){var u,l,d,f,m,p,g;let t=this._inventory,r=0,i=t[0],{MINIMUM_SEGMENT_SIZE:a}=U.getCurrent(),o=i==null?void 0:i.infos.adaptation.type,s=e.length;for(let I=0;I<s;I++){if(i===void 0)return;let h=e[I].start,y=e[I].end;if(y-h<a){c.warn(\"SI: skipped range when synchronizing because it was too small\",o,h,y);continue}let E=r;for(;i!==void 0&&((u=i.bufferedEnd)!=null?u:i.end)-h<a;)i=t[++r];let v=null,T=r-E;if(T>0){let P=t[E+T-1];v={end:(l=P.bufferedEnd)!=null?l:P.end,precizeEnd:P.precizeEnd},c.debug(`SI: ${T} segments GCed.`,o);let M=t.splice(E,T);for(let _ of M)_.bufferedStart===void 0&&_.bufferedEnd===void 0&&_.status!==2&&this._bufferedHistory.addBufferedSegment(_.infos,null);r=E}if(i===void 0)return;if(y-((d=i.bufferedStart)!=null?d:i.start)>=a){if(Kd(i,h,v,o),r===t.length-1){ds(i,y,o);return}i=t[++r];let P=(f=i.bufferedStart)!=null?f:i.start,M=(m=i.bufferedEnd)!=null?m:i.end,_=I<s-1?e[I+1].start:void 0;for(;i!==void 0&&y-P>=a&&(_===void 0||y-P>=M-_);){let A=t[r-1];A.bufferedEnd===void 0&&(A.bufferedEnd=i.precizeStart?i.start:A.end,c.debug(\"SI: calculating buffered end of contiguous segment\",o,A.bufferedEnd,A.end)),i.bufferedStart=A.bufferedEnd,i=t[++r],i!==void 0&&(P=(p=i.bufferedStart)!=null?p:i.start,M=(g=i.bufferedEnd)!=null?g:i.end)}}let C=t[r-1];C!==void 0&&ds(C,y,o)}if(!R(i)){c.debug(\"SI: last segments have been GCed\",o,r,t.length);let I=t.splice(r,t.length-r);for(let h of I)h.bufferedStart===void 0&&h.bufferedEnd===void 0&&h.status!==2&&this._bufferedHistory.addBufferedSegment(h.infos,null)}o!==void 0&&c.hasLevel(\"DEBUG\")&&c.debug(`SI: current ${o} inventory timeline:\n`+jd(this._inventory))}insertChunk({period:e,adaptation:t,representation:r,segment:i,chunkSize:a,start:o,end:s},u,l){if(i.isInit)return;let d=t.type;if(o>=s){c.warn(\"SI: Invalid chunked inserted: starts before it ends\",d,o,s);return}let f=this._inventory,m={status:u?0:2,insertionTs:l,chunkSize:a,splitted:!1,start:o,end:s,precizeStart:!1,precizeEnd:!1,bufferedStart:void 0,bufferedEnd:void 0,infos:{segment:i,period:e,adaptation:t,representation:r}};for(let g=f.length-1;g>=0;g--){let I=f[g];if(I.start<=o)if(I.end<=o){for(c.debug(\"SI: Pushing segment strictly after previous one.\",d,o,I.end),this._inventory.splice(g+1,0,m),g+=2;g<f.length&&f[g].start<m.end;){if(f[g].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",d,m.end,f[g].start),f[g].start=m.end,f[g].bufferedStart=void 0,f[g].precizeStart=f[g].precizeStart&&m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",d,o,s,f[g].start,f[g].end),f.splice(g,1)}return}else if(I.start===o)if(I.end<=s){for(c.debug(\"SI: Segment pushed replace another one\",d,o,s,I.end),this._inventory.splice(g,1,m),g+=1;g<f.length&&f[g].start<m.end;){if(f[g].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",d,m.end,f[g].start),f[g].start=m.end,f[g].bufferedStart=void 0,f[g].precizeStart=f[g].precizeStart&&m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",d,o,s,f[g].start,f[g].end),f.splice(g,1)}return}else{c.debug(\"SI: Segment pushed ends before another with the same start\",d,o,s,I.end),f.splice(g,0,m),I.start=m.end,I.bufferedStart=void 0,I.precizeStart=I.precizeStart&&m.precizeEnd;return}else if(I.end<=m.end){for(c.debug(\"SI: Segment pushed updates end of previous one\",d,o,s,I.start,I.end),this._inventory.splice(g+1,0,m),I.end=m.start,I.bufferedEnd=void 0,I.precizeEnd=I.precizeEnd&&m.precizeStart,g+=2;g<f.length&&f[g].start<m.end;){if(f[g].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",d,m.end,f[g].start),f[g].start=m.end,f[g].bufferedStart=void 0,f[g].precizeStart=f[g].precizeStart&&m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",d,o,s,f[g].start,f[g].end),f.splice(g,1)}return}else{c.warn(\"SI: Segment pushed is contained in a previous one\",d,o,s,I.start,I.end);let h={status:I.status,insertionTs:I.insertionTs,chunkSize:I.chunkSize,splitted:!0,start:m.end,end:I.end,precizeStart:I.precizeStart&&I.precizeEnd&&m.precizeEnd,precizeEnd:I.precizeEnd,bufferedStart:void 0,bufferedEnd:I.end,infos:I.infos};I.end=m.start,I.splitted=!0,I.bufferedEnd=void 0,I.precizeEnd=I.precizeEnd&&m.precizeStart,f.splice(g+1,0,m),f.splice(g+2,0,h);return}}let p=this._inventory[0];if(p===void 0){c.debug(\"SI: first segment pushed\",d,o,s),this._inventory.push(m);return}if(p.start>=s)c.debug(\"SI: Segment pushed comes before all previous ones\",d,o,s,p.start),this._inventory.splice(0,0,m);else if(p.end<=s){for(c.debug(\"SI: Segment pushed starts before and completely recovers the previous first one\",d,o,s,p.start,p.end),this._inventory.splice(0,1,m);f.length>1&&f[1].start<m.end;){if(f[1].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",d,m.end,f[1].start),f[1].start=m.end,f[1].bufferedStart=void 0,f[1].precizeStart=m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",d,o,s,f[1].start,f[1].end),f.splice(1,1)}return}else{c.debug(\"SI: Segment pushed start of the next one\",d,o,s,p.start,p.end),p.start=s,p.bufferedStart=void 0,p.precizeStart=m.precizeEnd,this._inventory.splice(0,0,m);return}}completeSegment(e){if(e.segment.isInit)return;let t=this._inventory,r=[];for(let i=0;i<t.length;i++)if(Ze(t[i].infos,e)){let a=!1;r.length>0&&(a=!0,r.length===1&&(c.warn(\"SI: Completed Segment is splitted.\",e.segment.id,e.segment.time,e.segment.end),r[0].splitted=!0));let o=i,s=t[i].chunkSize;for(i+=1;i<t.length&&Ze(t[i].infos,e);){let m=t[i].chunkSize;s!==void 0&&m!==void 0&&(s+=m),i++}let u=i-1,l=u-o,d=t[u].end,f=t[u].bufferedEnd;l>0&&(this._inventory.splice(o+1,l),i-=l),this._inventory[o].status===0&&(this._inventory[o].status=1),this._inventory[o].chunkSize=s,this._inventory[o].end=d,this._inventory[o].bufferedEnd=f,this._inventory[o].splitted=a,r.push(this._inventory[o])}if(r.length===0)c.warn(\"SI: Completed Segment not found\",e.segment.id,e.segment.time);else for(let i of r)i.bufferedStart!==void 0&&i.bufferedEnd!==void 0?i.status!==2&&this._bufferedHistory.addBufferedSegment(i.infos,{start:i.bufferedStart,end:i.bufferedEnd}):c.debug(\"SI: buffered range not known after sync. Skipping history.\",i.start,i.end)}getInventory(){return this._inventory}getHistoryFor(e){return this._bufferedHistory.getHistoryFor(e)}};function na(n){if(n.bufferedStart===void 0||n.status!==1)return!1;let{start:e,end:t}=n,r=t-e,{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:a}=U.getCurrent();return Math.abs(e-n.bufferedStart)<=i&&(n.bufferedEnd===void 0||n.bufferedEnd>n.bufferedStart&&Math.abs(n.bufferedEnd-n.bufferedStart-r)<=Math.min(a,r/3))}function us(n){if(n.bufferedEnd===void 0||n.status!==1)return!1;let{start:e,end:t}=n,r=t-e,{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:a}=U.getCurrent();return Math.abs(t-n.bufferedEnd)<=i&&n.bufferedStart!==void 0&&n.bufferedEnd>n.bufferedStart&&Math.abs(n.bufferedEnd-n.bufferedStart-r)<=Math.min(a,r/3)}function Kd(n,e,t,r){let{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MISSING_DATA_TRIGGER_SYNC_DELAY:a,SEGMENT_SYNCHRONIZATION_DELAY:o}=U.getCurrent();if(n.bufferedStart!==void 0)n.bufferedStart<e&&(c.debug(\"SI: Segment partially GCed at the start\",r,n.bufferedStart,e),n.bufferedStart=e),!n.precizeStart&&na(n)&&(n.start=n.bufferedStart,n.precizeStart=!0);else if(n.precizeStart)c.debug(\"SI: buffered start is precize start\",r,n.start),n.bufferedStart=n.start;else if(t!==null&&t.end>e&&(t.precizeEnd||n.start-t.end<=i))c.debug(\"SI: buffered start is end of previous segment\",r,e,n.start,t.end),n.bufferedStart=t.end,na(n)&&(n.start=t.end,n.precizeStart=!0);else if(n.start-e<=i){let s=L();if(n.start-e>=a&&s-n.insertionTs<o){c.debug(\"SI: Ignored bufferedStart synchronization\",r,e,n.start,s-n.insertionTs);return}c.debug(\"SI: found true buffered start\",r,e,n.start),n.bufferedStart=e,na(n)&&(n.start=e,n.precizeStart=!0)}else if(e<n.start)c.debug(\"SI: range start too far from expected start\",r,e,n.start),n.bufferedStart=n.start;else{let s=L();if(n.start-e>=a&&s-n.insertionTs<o){c.debug(\"SI: Ignored bufferedStart synchronization\",r,e,n.start,s-n.insertionTs);return}c.debug(\"SI: Segment appears immediately garbage collected at the start\",r,e,n.start),n.bufferedStart=e}}function ds(n,e,t){let{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:r,MISSING_DATA_TRIGGER_SYNC_DELAY:i,SEGMENT_SYNCHRONIZATION_DELAY:a}=U.getCurrent();if(n.bufferedEnd!==void 0)n.bufferedEnd>e&&(c.debug(\"SI: Segment partially GCed at the end\",t,n.bufferedEnd,e),n.bufferedEnd=e),!n.precizeEnd&&e-n.end<=r&&us(n)&&(n.precizeEnd=!0,n.end=e);else if(n.precizeEnd)c.debug(\"SI: buffered end is precize end\",t,n.end),n.bufferedEnd=n.end;else if(e-n.end<=r){let o=L();if(e-n.end>=i&&o-n.insertionTs<a){c.debug(\"SI: Ignored bufferedEnd synchronization\",t,e,n.end,o-n.insertionTs);return}c.debug(\"SI: found true buffered end\",t,e,n.end),n.bufferedEnd=e,us(n)&&(n.end=e,n.precizeEnd=!0)}else if(e>n.end)c.debug(\"SI: range end too far from expected end\",t,e,n.end),n.bufferedEnd=n.end;else{let o=L();if(e-n.end>=i&&o-n.insertionTs<a){c.debug(\"SI: Ignored bufferedEnd synchronization\",t,e,n.end,o-n.insertionTs);return}c.debug(\"SI: Segment appears immediately garbage collected at the end\",t,n.bufferedEnd,e),n.bufferedEnd=e}}function jd(n){let e=.016666666666666666,t={},r=[],i=null,a=null;function o(u){let l=String.fromCharCode(r.length+65);return r.push({letter:l,periodId:u.period.id,representationId:u.representation.id,bitrate:u.representation.bitrate}),l}let s=\"\";for(let u=0;u<n.length;u++){let l=n[u];if(l.bufferedStart!==void 0&&l.bufferedEnd!==void 0){let d=l.infos.period.id,f=l.infos.representation.id,m=t[d],p;m===void 0?(p=o(l.infos),t[d]={[f]:p}):m[f]===void 0?(p=o(l.infos),m[f]=p):p=m[f],i===null?s+=`${l.bufferedStart.toFixed(2)}|${p}|`:a===p?i.bufferedEnd+e<l.bufferedStart&&(s+=`${i.bufferedEnd.toFixed(2)} ~ ${l.bufferedStart.toFixed(2)}|${p}|`):s+=`${i.bufferedEnd.toFixed(2)} ~ ${l.bufferedStart.toFixed(2)}|${p}|`,i=l,a=p}}return i!==null&&(s+=String(i.end.toFixed(2))),r.forEach(u=>{var l;s+=`\n[${u.letter}] P: ${u.periodId} || R: ${u.representationId}(${(l=u.bitrate)!=null?l:\"unknown bitrate\"})`}),s}function Wt(n,e){for(let t=0;t<n.length;t++)if(n[t].infos.period.start>=e.start)return t>0?n[t-1]:null;return n.length>0?n[n.length-1]:null}function Vt(n,e){for(let t=0;t<n.length;t++)if(n[t].infos.period.start>e.start)return n[t];return null}var fs=Pn;var qt=class{constructor(){this._segmentInventory=new fs}synchronizeInventory(e){this._segmentInventory.synchronizeBuffered(e)}getLastKnownInventory(){return this._segmentInventory.getInventory()}getSegmentHistory(e){return this._segmentInventory.getHistoryFor(e)}};var vn=class extends qt{constructor(e,t,r){super(),c.info(\"AVSB: calling `mediaSource.addSourceBuffer`\",t);let i=r.addSourceBuffer(e,t);this.bufferType=e,this._sourceBuffer=i,this._lastInitSegmentUniqueId=null,this.codec=t,this._initSegmentsMap=new Map,this._pendingOperations=[]}declareInitSegment(e,t){ms(t),this._initSegmentsMap.set(e,t)}freeInitSegment(e){this._initSegmentsMap.delete(e)}async pushChunk(e){ms(e.data.chunk),c.debug(\"AVSB: receiving order to push data to the SourceBuffer\",this.bufferType,St(e.inventoryInfos));let t=this._getActualDataToPush(e.data);t.length===0&&t.push(new Uint8Array);let r=Promise.all(t.map(o=>{let{codec:s,timestampOffset:u,appendWindow:l}=e.data;return c.debug(\"AVSB: pushing segment\",this.bufferType,St(e.inventoryInfos)),this._sourceBuffer.appendBuffer(o,{codec:s,timestampOffset:u,appendWindow:l})}));this._addToOperationQueue(r,{type:0,value:e});let i;try{i=await r}catch(o){throw this._segmentInventory.insertChunk(e.inventoryInfos,!1,L()),o}e.inventoryInfos!==null&&this._segmentInventory.insertChunk(e.inventoryInfos,!0,L());let a=i[i.length-1];return this._segmentInventory.synchronizeBuffered(a),a}async removeBuffer(e,t){c.debug(\"AVSB: receiving order to remove data from the SourceBuffer\",this.bufferType,e,t);let r=this._sourceBuffer.remove(e,t);this._addToOperationQueue(r,{type:1,value:{start:e,end:t}});let i=await r;return this._segmentInventory.synchronizeBuffered(i),i}async signalSegmentComplete(e){if(this._pendingOperations.length>0){let{promise:t}=this._pendingOperations[this._pendingOperations.length-1];this._addToOperationQueue(t,{type:2,value:e});try{await t}catch(r){}}this._segmentInventory.completeSegment(e)}getPendingOperations(){return this._pendingOperations.map(e=>e.operation)}dispose(){try{c.debug(\"AVSB: Calling `dispose` on the SourceBufferInterface\"),this._sourceBuffer.dispose()}catch(e){c.debug(`AVSB: Failed to dispose a ${this.bufferType} SourceBufferInterface:`,e instanceof Error?e:\"\")}}_getActualDataToPush(e){let t=[];if(e.initSegmentUniqueId!==null&&!this._isLastInitSegment(e.initSegmentUniqueId)){let r=this._initSegmentsMap.get(e.initSegmentUniqueId);if(r===void 0)throw new Error(\"Invalid initialization segment uniqueId\");let i=new ArrayBuffer(r.byteLength),a=new Uint8Array(i);a.set(r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer)),r=a,t.push(r),this._lastInitSegmentUniqueId=e.initSegmentUniqueId}return e.chunk!==null&&t.push(e.chunk),t}_isLastInitSegment(e){return this._lastInitSegmentUniqueId===null?!1:this._lastInitSegmentUniqueId===e}_addToOperationQueue(e,t){let r={operation:t,promise:e};this._pendingOperations.push(r);let i=()=>{let a=this._pendingOperations.indexOf(r);a>=0&&this._pendingOperations.splice(a,1)};e.then(i,i)}};function ms(n){if(b.CURRENT_ENV!==b.PRODUCTION&&(typeof n!=\"object\"||n!==null&&!(n instanceof ArrayBuffer)&&!(n.buffer instanceof ArrayBuffer)))throw new Error(\"Invalid data given to the AudioVideoSegmentSink\")}var Or=vn;var Cn=class extends qt{constructor(e){c.debug(\"HTSB: Creating TextSegmentSink\"),super(),this.bufferType=\"text\",this._sender=e,this._pendingOperations=[],this._sender.reset()}declareInitSegment(e){c.warn(\"HTSB: Declaring initialization segment for Text SegmentSink\",e)}freeInitSegment(e){c.warn(\"HTSB: Freeing initialization segment for Text SegmentSink\",e)}async pushChunk(e){let{data:t}=e;Yd(t.chunk);let r=this._sender.pushTextData(Le(_e({},t),{chunk:t.chunk}));this._addToOperationQueue(r,{type:0,value:e});let i=await r;return e.inventoryInfos!==null&&this._segmentInventory.insertChunk(e.inventoryInfos,!0,L()),this._segmentInventory.synchronizeBuffered(i),i}async removeBuffer(e,t){let r=this._sender.remove(e,t);this._addToOperationQueue(r,{type:1,value:{start:e,end:t}});let i=await r;return this._segmentInventory.synchronizeBuffered(i),i}async signalSegmentComplete(e){if(this._pendingOperations.length>0){let{promise:t}=this._pendingOperations[this._pendingOperations.length-1];this._addToOperationQueue(t,{type:2,value:e});try{await t}catch(r){}}this._segmentInventory.completeSegment(e)}getPendingOperations(){return this._pendingOperations.map(e=>e.operation)}dispose(){c.debug(\"HTSB: Disposing TextSegmentSink\"),this._sender.reset()}_addToOperationQueue(e,t){let r={operation:t,promise:e};this._pendingOperations.push(r);let i=()=>{let a=this._pendingOperations.indexOf(r);a>=0&&this._pendingOperations.splice(a,1)};e.then(i,i)}};function Yd(n){if(b.CURRENT_ENV!==b.PRODUCTION&&(typeof n!=\"object\"||n===null||typeof n.data!=\"string\"||typeof n.type!=\"string\"||n.language!==void 0&&typeof n.language!=\"string\"||n.start!==void 0&&typeof n.start!=\"number\"||n.end!==void 0&&typeof n.end!=\"number\"))throw new Error(\"Invalid format given to a TextSegmentSink\")}b.CURRENT_ENV===b.DEV&&(Qd=function(e){function t(r){}});var Qd;var cs=Cn;function kt(n,e){let t;return new Promise((r,i)=>{if(n.cancellationError!==null)return i(n.cancellationError);let a=!1;t=e(function(u){n.deregister(o),a=!0,r(u)},function(u){n.deregister(o),a=!0,i(u)}),a||n.register(o);function o(s){t!==void 0&&t(),i(s)}})}var $d=[\"audio\",\"video\",\"text\"],An=class n{static isNative(e){return ps(e)}constructor(e,t,r){this._mediaSource=e,this._textInterface=r,this._hasVideo=t,this._initializedSegmentSinks={},this._onNativeBufferAddedOrDisabled=[]}getBufferTypes(){let e=this.getNativeBufferTypes();return this._textInterface!==null&&e.push(\"text\"),e}getNativeBufferTypes(){return this._hasVideo?[\"video\",\"audio\"]:[\"audio\"]}getStatus(e){let t=this._initializedSegmentSinks[e];return t===void 0?{type:\"uninitialized\"}:t===null?{type:\"disabled\"}:{type:\"initialized\",value:t}}waitForUsableBuffers(e){return this._areNativeBuffersUsable()?Promise.resolve():kt(e,t=>{let r,i=()=>{let a=this._onNativeBufferAddedOrDisabled.indexOf(r);a>=0&&this._onNativeBufferAddedOrDisabled.splice(a,1)};return r=()=>{this._areNativeBuffersUsable()&&(i(),t())},this._onNativeBufferAddedOrDisabled.push(r),i})}disableSegmentSink(e){let t=this._initializedSegmentSinks[e];if(t===null){c.warn(`SBS: The ${e} SegmentSink was already disabled.`);return}if(t!==void 0)throw new Error(\"Cannot disable an active SegmentSink.\");this._initializedSegmentSinks[e]=null,n.isNative(e)&&this._onNativeBufferAddedOrDisabled.forEach(r=>r())}createSegmentSink(e,t){let r=this._initializedSegmentSinks[e];if(ps(e)){if(!R(r))return r instanceof Or&&r.codec!==t?c.warn(\"SB: Reusing native SegmentSink with codec\",r.codec,\"for codec\",t):c.info(\"SB: Reusing native SegmentSink with codec\",t),r;c.info(\"SB: Adding native SegmentSink with codec\",t);let a=e===\"audio\"?\"audio\":\"video\",o=new Or(a,t,this._mediaSource);return this._initializedSegmentSinks[e]=o,this._onNativeBufferAddedOrDisabled.forEach(s=>s()),o}if(!R(r))return c.info(\"SB: Reusing a previous custom SegmentSink for the type\",e),r;let i;if(e===\"text\"){if(c.info(\"SB: Creating a new text SegmentSink\"),this._textInterface===null)throw new Error(\"HTML Text track feature not activated\");return i=new cs(this._textInterface),this._initializedSegmentSinks.text=i,i}throw c.error(\"SB: Unknown buffer type:\",e),new j(\"BUFFER_TYPE_UNKNOWN\",\"The player wants to create a SegmentSink of an unknown type.\")}disposeSegmentSink(e){let t=this._initializedSegmentSinks[e];if(R(t)){c.warn(\"SB: Trying to dispose a SegmentSink that does not exist\");return}c.info(\"SB: Aborting SegmentSink\",e),t.dispose(),delete this._initializedSegmentSinks[e]}disposeAll(){$d.forEach(e=>{this.getStatus(e).type===\"initialized\"&&this.disposeSegmentSink(e)})}_areNativeBuffersUsable(){let e=this.getNativeBufferTypes();return!(e.some(i=>this._initializedSegmentSinks[i]===void 0)||e.every(i=>this._initializedSegmentSinks[i]===null))}};function ps(n){return n===\"audio\"||n===\"video\"}var It=An;function kn(n,e){return kt(e,t=>{let r=setTimeout(()=>t(),n);return()=>clearTimeout(r)})}var xn=class extends oe{constructor(e,t,r,i){super(),this._content=e,this._currentCanceller=null,this._downloadQueue=t,this._initSegmentRequest=null,this._mediaSegmentRequest=null,this._segmentFetcher=r,this._initSegmentInfoRef=new G(void 0),this._mediaSegmentAwaitingInitMetadata=null,i||this._initSegmentInfoRef.setValue(null)}getRequestedInitSegment(){return this._initSegmentRequest===null?null:this._initSegmentRequest.segment}getRequestedMediaSegment(){return this._mediaSegmentRequest===null?null:this._mediaSegmentRequest.segment}start(){this._currentCanceller===null&&(this._currentCanceller=new W,this._downloadQueue.onUpdate(e=>{let{segmentQueue:t}=e;if(t.length>0&&t[0].segment.id===this._mediaSegmentAwaitingInitMetadata)return;let r=this._mediaSegmentRequest;if(t.length===0){if(r===null)return;c.debug(\"Stream: no more media segment to request. Cancelling queue.\",this._content.adaptation.type),this._restartMediaSegmentDownloadingQueue();return}else if(r===null){c.debug(\"Stream: Media segments now need to be requested. Starting queue.\",this._content.adaptation.type,t.length),this._restartMediaSegmentDownloadingQueue();return}else{let i=t[0];if(r.segment.id!==i.segment.id){c.debug(\"Stream: Next media segment changed, cancelling previous\",this._content.adaptation.type),this._restartMediaSegmentDownloadingQueue();return}r.priority!==i.priority&&(c.debug(\"Stream: Priority of next media segment changed, updating\",this._content.adaptation.type,r.priority,i.priority),this._segmentFetcher.updatePriority(r.request,i.priority));return}},{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}),this._downloadQueue.onUpdate(e=>{var r;let t=this._initSegmentRequest;if(e.initSegment!==null&&t!==null){e.initSegment.priority!==t.priority&&this._segmentFetcher.updatePriority(t.request,e.initSegment.priority);return}else if(((r=e.initSegment)==null?void 0:r.segment.id)===(t==null?void 0:t.segment.id))return;e.initSegment===null&&c.debug(\"Stream: no more init segment to request. Cancelling queue.\",this._content.adaptation.type),this._restartInitSegmentDownloadingQueue(e.initSegment)},{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}))}stop(){var e;(e=this._currentCanceller)==null||e.cancel(),this._currentCanceller=null}_restartMediaSegmentDownloadingQueue(){this._mediaSegmentRequest!==null&&this._mediaSegmentRequest.canceller.cancel();let{segmentQueue:e}=this._downloadQueue.getValue(),t=e[0],r=i=>{if(this._currentCanceller!==null&&this._currentCanceller.isUsed()){this._mediaSegmentRequest=null;return}if(i===void 0){this._mediaSegmentRequest=null,this.trigger(\"emptyQueue\",null);return}let a=new W,o=this._currentCanceller===null?N:a.linkToSignal(this._currentCanceller.signal),{segment:s,priority:u}=i,l=H({segment:s},this._content),d=!1,f=!1;a.signal.register(()=>{this._mediaSegmentRequest=null,!d&&(this._mediaSegmentAwaitingInitMetadata===s.id&&(this._mediaSegmentAwaitingInitMetadata=null),d=!0,f=!1)});let m=I=>{he(I.segmentType===\"media\",\"Should have loaded a media segment.\"),this.trigger(\"parsedMediaSegment\",H({},I,{segment:s}))},p=()=>{let I=this._downloadQueue.getValue().segmentQueue;if(I.length===0){d=!0,this.trigger(\"emptyQueue\",null);return}else I[0].segment.id===s.id&&I.shift();d=!0,r(I[0])},g=this._segmentFetcher.createRequest(l,u,{onRetry:I=>{this.trigger(\"requestRetry\",{segment:s,error:I})},beforeInterrupted(){c.info(\"Stream: segment request interrupted temporarly.\",s.id,s.time)},onChunk:I=>{let h=this._initSegmentInfoRef.getValue();h!==void 0?m(I(h!=null?h:void 0)):(f=!0,this._initSegmentInfoRef.waitUntilDefined(y=>{m(I(y!=null?y:void 0))},{clearSignal:a.signal}))},onAllChunksReceived:()=>{f?(this._mediaSegmentAwaitingInitMetadata=s.id,this._initSegmentInfoRef.waitUntilDefined(()=>{this._mediaSegmentAwaitingInitMetadata=null,f=!1,this.trigger(\"fullyLoadedSegment\",s)},{clearSignal:a.signal})):this.trigger(\"fullyLoadedSegment\",s)},beforeEnded:()=>{o(),this._mediaSegmentRequest=null,f?this._initSegmentInfoRef.waitUntilDefined(p,{clearSignal:a.signal}):p()}},a.signal);g.catch(I=>{o(),d||(d=!0,this.stop(),this.trigger(\"error\",I))}),this._mediaSegmentRequest={segment:s,priority:u,request:g,canceller:a}};r(t)}_restartInitSegmentDownloadingQueue(e){if(this._currentCanceller!==null&&this._currentCanceller.isUsed()||(this._initSegmentRequest!==null&&this._initSegmentRequest.canceller.cancel(),e===null))return;let t=new W,r=this._currentCanceller===null?N:t.linkToSignal(this._currentCanceller.signal),{segment:i,priority:a}=e,o=H({segment:i},this._content),s=!1,u=this._segmentFetcher.createRequest(o,a,{onRetry:l=>{this.trigger(\"requestRetry\",{segment:i,error:l})},beforeInterrupted:()=>{c.info(\"Stream: init segment request interrupted temporarly.\",i.id)},beforeEnded:()=>{r(),this._initSegmentRequest=null,s=!0},onChunk:l=>{var f;let d=l(void 0);he(d.segmentType===\"init\",\"Should have loaded an init segment.\"),this.trigger(\"parsedInitSegment\",H({},d,{segment:i})),d.segmentType===\"init\"&&this._initSegmentInfoRef.setValue((f=d.initTimescale)!=null?f:null)},onAllChunksReceived:()=>{this.trigger(\"fullyLoadedSegment\",i)}},t.signal);u.catch(l=>{r(),s||(s=!0,this.stop(),this.trigger(\"error\",l))}),t.signal.register(()=>{this._initSegmentRequest=null,!s&&(s=!0)}),this._initSegmentRequest={segment:i,priority:a,request:u,canceller:t}}};function ra(n,e,t,r,i){let{period:a,adaptation:o,representation:s}=n,u=Xd(i,e);if(u===null){if(t===null){if(r&&a.end!==void 0&&e.end>=a.end)return{start:void 0,end:null};let f=s.index.checkDiscontinuity(e.start);if(f!==null)return{start:void 0,end:f}}return null}let l=i[u];if(l.bufferedStart!==void 0&&l.bufferedStart>e.start&&(t===null||l.infos.segment.end<=t)){let f=l.bufferedStart;return!r&&s.index.awaitSegmentBetween(e.start,f)!==!1?null:(c.debug(\"RS: current discontinuity encountered\",o.type,l.bufferedStart),{start:void 0,end:f})}let d=Zd(i,e,u+1);if(d!==null){let f=i[d-1],m=i[d];if(t===null||m.infos.segment.end<=t){if(!r&&s.index.awaitSegmentBetween(f.infos.segment.end,m.infos.segment.time)!==!1)return null;let p=f.bufferedEnd,g=m.bufferedStart;return c.debug(\"RS: future discontinuity encountered\",o.type,p,g),{start:p,end:g}}}if(t===null){if(r&&a.end!==void 0){if(e.end<a.end)return null;let f=Jd(i,a.end);if(f!==null){let m=i[f];if(m.bufferedEnd!==void 0&&m.bufferedEnd<a.end)return c.debug(\"RS: discontinuity encountered at the end of the current period\",o.type,m.bufferedEnd,a.end),{start:m.bufferedEnd,end:null}}}if(a.end!==void 0&&e.end>=a.end)return null;for(let f=i.length-1;f>=0;f--){let m=i[f];if(m.bufferedStart===void 0)break;if(m.bufferedStart<e.end){if(m.bufferedEnd!==void 0&&m.bufferedEnd<e.end){let p=s.index.checkDiscontinuity(e.end);if(p!==null)return{start:m.bufferedEnd,end:p}}return null}}}return null}function Xd(n,e){for(let t=0;t<n.length;t++){let r=n[t];if(r.bufferedStart===void 0||r.bufferedEnd===void 0||r.bufferedStart>=e.end)return null;if(r.bufferedEnd>e.start)return t}return null}function Zd(n,e,t){if(t<=0)return c.error(\"RS: Asked to check a discontinuity before the first chunk.\"),null;for(let r=t;r<n.length;r++){let i=n[r],a=n[r-1];if(i.bufferedStart===void 0||a.bufferedEnd===void 0||i.bufferedStart>=e.end)return null;if(i.bufferedStart-a.bufferedEnd>0)return r}return null}function Jd(n,e){for(let t=n.length-1;t>=0;t--){let r=n[t];if(r.bufferedStart===void 0)return null;if(r.bufferedStart<e)return t}return null}function ia({bufferedSegments:n,content:e,currentPlaybackTime:t,fastSwitchThreshold:r,getBufferedHistory:i,neededRange:a,segmentsBeingPushed:o,maxBufferSize:s}){let{adaptation:u,representation:l}=e,d=el(n,o,s),f=l.index.getSegments(a.start,a.end-a.start),m=n.filter(T=>!gs(T.infos,e,t,r)).filter((T,C,P)=>{let M=C===0?null:P[C-1],_=C>=P.length-1?null:P[C+1],A=null;if(rl(T,M,a.start)){if(A=i(T.infos),al(A,T.bufferedStart))return!1;c.debug(\"Stream: skipping segment gc-ed at the start\",T.start,T.bufferedStart)}if(il(T,_,a.end)){if(A=A!=null?A:i(T.infos),ol(A,T.bufferedEnd))return!1;c.debug(\"Stream: skipping segment gc-ed at the end\",T.end,T.bufferedEnd)}return!0}),{MINIMUM_SEGMENT_SIZE:p,MIN_BUFFER_AHEAD:g}=U.getCurrent(),I=!1,h=Math.min(1/60,p),y=!1,E=[];return{segmentsToLoad:f.filter(T=>{let C=H({segment:T},e);if(o.length>0&&o.some(D=>Ze(C,D)))return!1;let{duration:P,time:M,end:_}=T;if(T.isInit)return!0;if(I)return E.push(T),!1;if(T.complete&&P<p||o.length>0&&o.some(D=>{if(D.period.id!==e.period.id||D.adaptation.id!==e.adaptation.id)return!1;let{segment:w}=D;return w.time-h>M||w.end+h<_?!1:!gs(D,C,t,r)}))return!1;for(let k=0;k<m.length;k++){let D=m[k];if(D.infos.period.id===e.period.id){let O=D.infos.segment;if(M-O.time>-h&&O.end-_>-h)return!1}}let A=P*e.representation.bitrate;if(d-A<0&&(y=!0,M>a.start+g))return I=!0,E.push(T),!1;let x=i(C);if(x.length>1){let k=x[x.length-1],D=x[x.length-2];if(k.buffered===null&&D.buffered===null)return c.warn(\"Stream: Segment GCed multiple times in a row, ignoring it.\",\"If this happens a lot and lead to unpleasant experience, please check your device's available memory. If it's low when this message is emitted, you might want to update the RxPlayer's settings (`maxBufferAhead`, `maxVideoBufferSize` etc.) so less memory is used by regular media data buffering.\"+u.type,l.id,T.time),!1}for(let k=0;k<m.length;k++){let D=m[k];if(D.end+h>M){let w=D.start>M+h||tl(m,k).end<_-h;return w&&(d-=A),w}}return d-=A,!0}),segmentsOnHold:E,isBufferFull:y}}function el(n,e,t){let r=t*8e3;return r-=e.reduce((i,a)=>{let{bitrate:o}=a.representation,{duration:s}=a.segment;return i+o*s},0),n.reduce((i,a)=>a.chunkSize!==void 0?i-a.chunkSize*8:i,r)}function tl(n,e){let t=e+1,{MINIMUM_SEGMENT_SIZE:r}=U.getCurrent(),i=Math.min(1/60,r);for(;t<n.length-1&&n[t-1].end+i>n[t].start;)t++;return t--,n[t]}function gs(n,e,t,r){let{CONTENT_REPLACEMENT_PADDING:i}=U.getCurrent();if(n.period.id!==e.period.id)return!1;let{segment:a}=n;return a.time<t+i?!1:n.adaptation.id!==e.adaptation.id?!0:nl(n.representation,e.representation,r)}function nl(n,e,t){let r=n.bitrate,{BITRATE_REBUFFERING_RATIO:i}=U.getCurrent();if(t===void 0){let a=r*i;return e.bitrate>a}return r<t&&e.bitrate>r}function rl(n,e,t){let{MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:r}=U.getCurrent();return n.bufferedStart===void 0||e!==null&&e.bufferedEnd!==void 0&&n.bufferedStart-e.bufferedEnd<.1?!1:t<n.bufferedStart&&n.bufferedStart-n.start>r?(c.info(\"Stream: The start of the wanted segment has been garbage collected\",n.start,n.bufferedStart),!0):!1}function il(n,e,t){let{MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:r}=U.getCurrent();return n.bufferedEnd===void 0||e!==null&&e.bufferedStart!==void 0&&e.bufferedStart-n.bufferedEnd<.1?!1:t>n.bufferedEnd&&n.end-n.bufferedEnd>r?(c.info(\"Stream: The end of the wanted segment has been garbage collected\",n.end,n.bufferedEnd),!0):!1}function al(n,e){var o,s;if(n.length<2)return!0;let r=(o=n[n.length-1].buffered)==null?void 0:o.start;if(e!==void 0&&r!==void 0&&e-r>.05)return!0;let a=(s=n[n.length-2].buffered)==null?void 0:s.start;return a===void 0||r===void 0?!0:Math.abs(a-r)>.01}function ol(n,e){var o,s;if(n.length<2)return!0;let r=(o=n[n.length-1].buffered)==null?void 0:o.end;if(e!==void 0&&r!==void 0&&r-e>.05)return!0;let a=(s=n[n.length-2].buffered)==null?void 0:s.end;return a===void 0||r===void 0?!0:Math.abs(a-r)>.01}function Mn(n,e){let t=n-e,{SEGMENT_PRIORITIES_STEPS:r}=U.getCurrent();for(let i=0;i<r.length;i++)if(t<r[i])return i;return r.length}function aa(n,e,t,r,i,a,o){var _,A,x;let{representation:s}=n,u=(A=(_=t.getIsPaused())!=null?_:t.getReference().getValue().paused.pending)!=null?A:t.getReference().getValue().paused.last,l=(x=t.getPlaybackRate())!=null?x:t.getReference().getValue().speed,d=e;(u===void 0||l===void 0||u||l<=0)&&(d-=.1);let f=sl(n,d,i),m=s.index.shouldRefresh(f.start,f.end),p=o.getPendingOperations().filter(k=>k.type===2).map(k=>k.value),g=dl({start:Math.max(f.start-.5,0),end:f.end+.5},o.getLastKnownInventory()),I=t.getCurrentTime();I===void 0&&(I=t.getReference().getValue().position.getWanted());let h=o.getSegmentHistory.bind(o),{segmentsToLoad:y,segmentsOnHold:E,isBufferFull:v}=ia({content:n,bufferedSegments:g,currentPlaybackTime:I,fastSwitchThreshold:r,getBufferedHistory:h,neededRange:f,segmentsBeingPushed:p,maxBufferSize:a}),T=y.map(k=>({priority:Mn(k.time,d),segment:k})),C=s.index.isInitialized()&&!s.index.isStillAwaitingFutureSegments()&&f.hasReachedPeriodEnd&&T.length===0&&E.length===0,P=null;return p.length>0&&(P=Math.min(...p.map(k=>k.segment.time))),E.length>0&&(P=P!==null?Math.min(P,E[0].time):E[0].time),T.length>0&&(P=P!==null?Math.min(P,T[0].segment.time):T[0].segment.time),{imminentDiscontinuity:ra(n,f,P,C,g),hasFinishedLoading:C,neededSegments:T,isBufferFull:v,shouldRefreshManifest:m}}function sl(n,e,t){var f;let r,{manifest:i,period:a,representation:o}=n,s=o.index.getLastAvailablePosition(),u=o.index;!R(s)&&It.isNative(n.adaptation.type)&&e>=s&&u.isInitialized()&&!u.isStillAwaitingFutureSegments()&&ul(i,a,e)?r=s-1:r=e-.1;let l=r+t,d;return!o.index.isInitialized()||o.index.isStillAwaitingFutureSegments()||a.end===void 0?d=!1:s===void 0?d=l>=a.end:s===null?d=!0:d=l>=s,{start:Math.max(r,a.start),end:Math.min(l,(f=a.end)!=null?f:1/0),hasReachedPeriodEnd:d}}function ul(n,e,t){var i;let r=n.getPeriodAfter(e);return e.containsTime(t,r)&&n.isLastPeriodKnown&&e.id===((i=n.periods[n.periods.length-1])==null?void 0:i.id)}function dl(n,e){let{MINIMUM_SEGMENT_SIZE:t}=U.getCurrent(),r=Math.max(1/60,t),i=n.start+r,a=n.end-r,o=[];for(let s=e.length-1;s>=0;s--){let u=e[s],{representation:l}=u.infos;if(u.status===1&&l.decipherable!==!1&&l.isSupported!==!1){let d=u.infos.segment,f=d.time/d.timescale;((d.complete?f+d.duration/d.timescale:u.end)>i&&f<a||u.end>i&&u.start<a)&&o.unshift(u)}}return o}function oa(n){return new Promise(e=>{setTimeout(e,n)})}async function On(n,e,t,r,i){try{return await e.pushChunk(t)}catch(a){if(i.isCancelled()&&a instanceof ie)throw a;if(!(a instanceof Ce)||!a.isBufferFull){let u=a instanceof Error?a.toString():\"An unknown error happened when pushing content\";throw new j(\"BUFFER_APPEND_ERROR\",u,{tracks:[dt(t.inventoryInfos.adaptation)]})}let{position:o}=n.getReference().getValue(),s=o.getWanted();try{c.warn(\"Stream: Running garbage collector\");let u=Math.max(s-5,0),l=s+r.getValue()+12;if(await e.removeBuffer(0,u),await e.removeBuffer(l,Number.MAX_VALUE),await oa(200),i.cancellationError!==null)throw i.cancellationError;return await e.pushChunk(t)}catch(u){if(u instanceof ie)throw u;let l=u instanceof Error?u.toString():\"Could not clean the buffer\";throw new j(\"BUFFER_FULL_ERROR\",l,{tracks:[dt(t.inventoryInfos.adaptation)]})}}}async function sa({playbackObserver:n,content:e,initSegmentUniqueId:t,segment:r,segmentSink:i,bufferGoal:a},o){if(o.cancellationError!==null)throw o.cancellationError;let s=e.representation.getMimeTypeString(),u={initSegmentUniqueId:t,chunk:null,timestampOffset:0,appendWindow:[void 0,void 0],codec:s},l=H({segment:r,chunkSize:void 0,start:0,end:0},e),d=await On(n,i,{data:u,inventoryInfos:l},a,o);return{content:e,segment:r,buffered:d}}async function ua({playbackObserver:n,bufferGoal:e,content:t,initSegmentUniqueId:r,parsedSegment:i,segment:a,segmentSink:o},s){var P,M;if(i.chunkData===null)return null;if(s.cancellationError!==null)throw s.cancellationError;let{chunkData:u,chunkInfos:l,chunkOffset:d,chunkSize:f,appendWindow:m}=i,p=t.representation.getMimeTypeString(),{APPEND_WINDOW_SECURITIES:g}=U.getCurrent(),I=[m[0]!==void 0?Math.max(0,m[0]-g.START):void 0,m[1]!==void 0?m[1]+g.END:void 0],h={initSegmentUniqueId:r,chunk:u,timestampOffset:d,appendWindow:I,codec:p},y=(P=l==null?void 0:l.time)!=null?P:a.time,E=(M=l==null?void 0:l.duration)!=null?M:a.duration,v=y+E;I[0]!==void 0&&(y=Math.max(y,I[0])),I[1]!==void 0&&(v=Math.min(v,I[1]));let T=H({segment:a,chunkSize:f,start:y,end:v},t),C=await On(n,o,{data:h,inventoryInfos:T},e,s);return{content:t,segment:a,buffered:C}}function da({content:n,options:e,playbackObserver:t,segmentSink:r,segmentFetcher:i,terminate:a},o,s){let{period:u,adaptation:l,representation:d}=n,{bufferGoal:f,maxBufferSize:m,drmSystemId:p,fastSwitchThreshold:g}=e,I=l.type,h=new W;h.linkToSignal(s);let y=new W;y.linkToSignal(h.signal);let E={segment:d.index.getInitSegment(),uniqueId:null,isLoaded:!1};h.signal.register(()=>{E.uniqueId!==null&&r.freeInitSegment(E.uniqueId)});let v=new G({initSegment:null,segmentQueue:[]},y.signal),T=E.segment!==null;T||(E.isLoaded=!0);let C=!1;if(p!==void 0){let x=d.getEncryptionData(p);if(x.length>0&&x.every(k=>k.keyIds!==void 0)&&(C=!0,o.encryptionDataEncountered(x.map(k=>H({content:n},k))),h.isUsed()))return}let P=new xn(n,v,i,T);P.addEventListener(\"error\",x=>{y.signal.isCancelled()||(h.cancel(),o.error(x))}),P.addEventListener(\"parsedInitSegment\",_),P.addEventListener(\"parsedMediaSegment\",_),P.addEventListener(\"emptyQueue\",M),P.addEventListener(\"requestRetry\",x=>{if(o.warning(x.error),y.signal.isCancelled())return;let k=x.segment,{index:D}=d;D.isSegmentStillAvailable(k)===!1?M():D.canBeOutOfSyncError(x.error,k)&&o.manifestMightBeOufOfSync()}),P.addEventListener(\"fullyLoadedSegment\",x=>{r.signalSegmentComplete(H({segment:x},n)).catch(A)}),P.start(),y.signal.register(()=>{P.removeEventListener(),P.stop()}),t.listen(M,{includeLastObservation:!1,clearSignal:y.signal}),n.manifest.addEventListener(\"manifestUpdate\",M,y.signal),f.onUpdate(M,{emitCurrentValue:!1,clearSignal:y.signal}),m.onUpdate(M,{emitCurrentValue:!1,clearSignal:y.signal}),a.onUpdate(M,{emitCurrentValue:!1,clearSignal:y.signal}),M();return;function M(){if(y.isUsed())return;let x=t.getReference().getValue(),k=x.position.getWanted(),D=aa(n,k,t,g.getValue(),f.getValue(),m.getValue(),r),{neededSegments:w}=D,O=null;if(d.index.isInitialized()){if(w.length>0&&!E.isLoaded&&E.segment!==null){let q=w[0].priority;O={segment:E.segment,priority:q}}}else if(E.segment===null)c.warn(\"Stream: Uninitialized index without an initialization segment\");else if(E.isLoaded)c.warn(\"Stream: Uninitialized index with an already loaded initialization segment\");else{let q=x.position.getWanted();O={segment:E.segment,priority:Mn(u.start,q)}}let B=a.getValue();if(B===null)v.setValue({initSegment:O,segmentQueue:w});else if(B.urgent){c.debug(\"Stream: Urgent switch, terminate now.\",I),v.setValue({initSegment:null,segmentQueue:[]}),v.finish(),y.cancel(),o.terminating();return}else{let q=w[0],J=P.getRequestedInitSegment(),$=P.getRequestedMediaSegment(),V=$===null||q===void 0||$.id!==q.segment.id?[]:[q],Y=J===null?null:O;if(v.setValue({initSegment:Y,segmentQueue:V}),V.length===0&&Y===null){c.debug(\"Stream: No request left, terminate\",I),v.finish(),y.cancel(),o.terminating();return}}if(o.streamStatusUpdate({period:u,position:x.position.getWanted(),bufferType:I,imminentDiscontinuity:D.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:D.hasFinishedLoading,neededSegments:D.neededSegments}),y.signal.isCancelled())return;let{UPTO_CURRENT_POSITION_CLEANUP:z}=U.getCurrent();if(D.isBufferFull){let q=Math.max(0,k-z);q>0&&r.removeBuffer(0,q).catch(A)}D.shouldRefreshManifest&&o.needsManifestRefresh()}function _(x){if(!h.isUsed()){for(let k of x.protectionData)d.addProtectionData(k.initDataType,k.keyId,k.initData);if(!C){let k=d.getAllEncryptionData();if(k.length>0&&(o.encryptionDataEncountered(k.map(D=>H({content:n},D))),C=!0,h.isUsed()))return}if(x.segmentType===\"init\"){if(!d.index.isInitialized()&&x.segmentList!==void 0&&d.index.initialize(x.segmentList),E.isLoaded=!0,x.initializationData!==null){let k=d.uniqueId;E.uniqueId=k,r.declareInitSegment(k,x.initializationData),sa({playbackObserver:t,bufferGoal:f,content:n,initSegmentUniqueId:k,segment:x.segment,segmentData:x.initializationData,segmentSink:r},h.signal).then(D=>{D!==null&&o.addedSegment(D)}).catch(A)}M();return}else{let{inbandEvents:k,predictedSegments:D,needsManifestRefresh:w}=x;if(D!==void 0&&d.index.addPredictedSegments(D,x.segment),w===!0&&(o.needsManifestRefresh(),h.isUsed())||k!==void 0&&k.length>0&&(o.inbandEvent(k),h.isUsed()))return;let O=E.uniqueId;ua({playbackObserver:t,bufferGoal:f,content:n,initSegmentUniqueId:O,parsedSegment:x,segment:x.segment,segmentSink:r},h.signal).then(B=>{B!==null&&o.addedSegment(B)}).catch(A)}}}function A(x){h.isUsed()&&x instanceof ie||(h.cancel(),o.error(x))}}var hs=da;function la(n,e,t,r,i){var m,p,g,I;if(t.switchingMode===\"lazy\")return{type:\"continue\",value:void 0};let a=r.getLastKnownInventory(),o=[];for(let h of a)h.infos.period.id===n.id&&(h.infos.adaptation.id!==e.id||!se(t.representationIds,h.infos.representation.id))&&zt(o,{start:(m=h.bufferedStart)!=null?m:h.start,end:(p=h.bufferedEnd)!=null?p:h.end});let s=r.getPendingOperations();for(let h of s)if(h.type===0){let y=h.value.inventoryInfos;if(y.period.id===n.id&&(y.adaptation.id!==e.id||!se(t.representationIds,y.representation.id))){let E=y.segment.time,v=E+y.segment.duration;zt(o,{start:E,end:v})}}if(o.length===0)return{type:\"continue\",value:void 0};if(t.switchingMode===\"reload\"){let h=i.getReadyState();if(h===void 0||h>1)return{type:\"needs-reload\",value:void 0}}let u=t.switchingMode===\"direct\",l=[],d=Wt(a,n);if(d!==null&&(d.bufferedEnd===void 0||n.start-d.bufferedEnd<1)&&l.push({start:0,end:n.start+1}),!u){let{ADAP_REP_SWITCH_BUFFER_PADDINGS:h}=U.getCurrent(),y=e.type,E=(g=h[y].before)!=null?g:0,v=(I=h[y].after)!=null?I:0,T=i.getCurrentTime();T===void 0&&(T=i.getReference().getValue().position.getPolled()),l.push({start:T-E,end:T+v})}if(n.end!==void 0){let h=Vt(a,n);h!==null&&(h.bufferedStart===void 0||h.bufferedStart-n.end<1)&&l.push({start:n.end-1,end:Number.MAX_VALUE})}let f=kr(o,l);return f.length===0?{type:\"continue\",value:void 0}:u?{type:\"flush-buffer\",value:f}:{type:\"clean-buffer\",value:f}}function fa({playbackObserver:n,content:e,options:t,representationEstimator:r,segmentSink:i,segmentFetcherCreator:a,wantedBufferAhead:o,maxVideoBufferSize:s},u,l){let{manifest:d,period:f,adaptation:m}=e,p=new W;p.linkToSignal(l);let g=new Map,I=new G(null,p.signal),h,y=e.representations.getValue().representationIds,E=e.adaptation.representations.filter(w=>se(y,w.id)&&w.decipherable!==!1&&w.isSupported!==!1),v=new G(E,p.signal),{estimates:T,callbacks:C}=r({manifest:d,period:f,adaptation:m},I,v,n,p.signal),P=a.createSegmentFetcher(m.type,{onRequestBegin:C.requestBegin,onRequestEnd:C.requestEnd,onProgress:C.requestProgress,onMetrics:C.metrics}),M=new G(0);T.onUpdate(({bitrate:w,knownStableBitrate:O})=>{t.enableFastSwitching&&M.setValueIfChanged(O),!(w===void 0||w===h)&&(h=w,c.debug(`Stream: new ${m.type} bitrate estimate`,w),u.bitrateEstimateChange({type:m.type,bitrate:w}))},{emitCurrentValue:!0,clearSignal:p.signal});let _;e.representations.onUpdate(w=>{_!==void 0&&_.cancel();let O=e.representations.getValue().representationIds,B=e.adaptation.representations.filter(z=>se(O,z.id));v.setValueIfChanged(B),_=new W,_.linkToSignal(p.signal),A(w,_.signal).catch(z=>{(_==null?void 0:_.isUsed())===!0&&W.isCancellationError(z)||(p.cancel(),u.error(z))})},{clearSignal:p.signal,emitCurrentValue:!0});return;async function A(w,O){let B=la(f,m,w,i,n);switch(B.type){case\"continue\":break;case\"needs-reload\":return Ct(()=>{n.listen(()=>{if(O.isCancelled())return;let{DELTA_POSITION_AFTER_RELOAD:z}=U.getCurrent(),q=z.bitrateSwitch;return u.waitingMediaSourceReload({bufferType:m.type,period:f,timeOffset:q,stayInPeriod:!0})},{includeLastObservation:!0,clearSignal:O})});case\"flush-buffer\":case\"clean-buffer\":for(let z of B.value)if(await i.removeBuffer(z.start,z.end),O.isCancelled())return;if(B.type===\"flush-buffer\"&&(u.needsBufferFlush(),O.isCancelled()))return;break;default:ze(B)}x(O)}function x(w){let O=new W;O.linkToSignal(w);let{representation:B}=T.getValue();if(B===null)return;let z=new G(null,O.signal);T.onUpdate($=>{if(!($.representation===null||$.representation.id===B.id))return $.urgent?(c.info(\"Stream: urgent Representation switch\",m.type),z.setValue({urgent:!0})):(c.info(\"Stream: slow Representation switch\",m.type),z.setValue({urgent:!1}))},{clearSignal:O.signal,emitCurrentValue:!0});let q={type:m.type,adaptation:m,period:f,representation:B};if(I.setValue(B),p.isUsed()||(u.representationChange(q),p.isUsed()))return;let J={streamStatusUpdate:u.streamStatusUpdate,encryptionDataEncountered:u.encryptionDataEncountered,manifestMightBeOufOfSync:u.manifestMightBeOufOfSync,needsManifestRefresh:u.needsManifestRefresh,inbandEvent:u.inbandEvent,warning:u.warning,error($){p.cancel(),u.error($)},addedSegment($){C.addedSegment($)},terminating(){if(!O.isUsed())return O.cancel(),x(w)}};k(B,z,J,w)}function k(w,O,B,z){let q=new W;q.linkToSignal(z);let J=Qt(o,Y=>Y*D(w),q.signal),$=m.type===\"video\"?s:new G(1/0);c.info(\"Stream: changing representation\",m.type,w.id,w.bitrate);let V=H({},B,{error(Y){var me;let X=ge(Y,{defaultCode:\"NONE\",defaultReason:\"Unknown `RepresentationStream` error\"});if(X.code!==\"BUFFER_FULL_ERROR\")B.error(Y);else{let ce=o.getValue(),Ie=((me=g.get(w.id))!=null?me:1)*.7;if(Ie<=.05||ce*Ie<=2)throw X;g.set(w.id,Ie),kn(4e3,p.signal).then(()=>k(w,O,B,z)).catch(N)}},terminating(){q.cancel(),B.terminating()}});hs({playbackObserver:n,content:{representation:w,adaptation:m,period:f,manifest:d},segmentSink:i,segmentFetcher:P,terminate:O,options:{bufferGoal:J,maxBufferSize:$,drmSystemId:t.drmSystemId,fastSwitchThreshold:M}},V,z),d.addEventListener(\"manifestUpdate\",Y=>{for(let X of Y.updatedPeriods)if(X.period.id===f.id){for(let me of X.result.updatedAdaptations)if(me.adaptation===m.id){for(let ce of me.removedRepresentations)if(ce===w.id)return z.isCancelled()?void 0:u.waitingMediaSourceReload({bufferType:m.type,period:f,timeOffset:0,stayInPeriod:!0})}}else if(X.period.start>f.start)break},z)}function D(w){let O=g.get(w.id),B=O!==void 0?O:1;return O===void 0&&g.set(w.id,B),B}}var Is=fa;function ll(n,e){let[t,...r]=n.split(\";\"),[i,...a]=e.split(\";\");if(t!==i)return!1;let o=K(r,d=>Ye(d,\"codecs=\")),s=K(a,d=>Ye(d,\"codecs=\"));if(o===void 0||s===void 0)return!1;let u=o.substring(7),l=s.substring(7);return u.split(\".\")[0]===l.split(\".\")[0]}var bs=ll;function ma(n,e,t,r,i,a){var p,g,I,h;if(n.codec!==void 0&&a.onCodecSwitch===\"reload\"&&!fl(t,n.codec))return{type:\"needs-reload\",value:void 0};let o=n.getLastKnownInventory(),s=[];for(let y of o)y.infos.period.id===e.id&&y.infos.adaptation.id!==t.id&&zt(s,{start:(p=y.bufferedStart)!=null?p:y.start,end:(g=y.bufferedEnd)!=null?g:y.end});let u=n.getPendingOperations();for(let y of u)if(y.type===0){let E=y.value.inventoryInfos;if(E.period.id===e.id&&E.adaptation.id!==t.id){let v=E.segment.time,T=v+E.segment.duration;zt(s,{start:v,end:T})}}if(s.length===0)return{type:\"continue\",value:void 0};if(r===\"reload\"){let y=i.getReadyState();if(y===void 0||y>1)return{type:\"needs-reload\",value:void 0}}let l=r===\"direct\",d=[],f=Wt(o,e);if(f!==null&&(f.bufferedEnd===void 0||e.start-f.bufferedEnd<1)&&d.push({start:0,end:e.start+1}),!l){let y=t.type,{ADAP_REP_SWITCH_BUFFER_PADDINGS:E}=U.getCurrent(),v=(I=E[y].before)!=null?I:0,T=(h=E[y].after)!=null?h:0,C=i.getCurrentTime();C===void 0&&(C=i.getReference().getValue().position.getPolled()),d.push({start:C-v,end:C+T})}if(e.end!==void 0){let y=Vt(o,e);y!==null&&(y.bufferedStart===void 0||y.bufferedStart-e.end<1)&&d.push({start:e.end-1,end:Number.MAX_VALUE})}let m=kr(s,d);return m.length===0?{type:\"continue\",value:void 0}:l&&t.type!==\"text\"?{type:\"flush-buffer\",value:m}:{type:\"clean-buffer\",value:m}}function fl(n,e){return n.representations.some(t=>t.isSupported===!0&&t.decipherable!==!1&&bs(t.getMimeTypeString(),e))}function ca({bufferType:n,content:e,garbageCollectors:t,playbackObserver:r,representationEstimator:i,segmentFetcherCreator:a,segmentSinksStore:o,options:s,wantedBufferAhead:u,maxVideoBufferSize:l},d,f){let{manifest:m,period:p}=e,g=new G(void 0,f);if(d.periodStreamReady({type:n,manifest:m,period:p,adaptationRef:g}),f.isCancelled())return;let I,h=!0;g.onUpdate(v=>{(async()=>{var w;if(v===void 0)return;let T=new W;if(T.linkToSignal(f),I==null||I.cancel(),I=T,v===null){c.info(`Stream: Set no ${n} Adaptation. P:`,p.start);let O=o.getStatus(n);if(O.type===\"initialized\"){if(c.info(`Stream: Clearing previous ${n} SegmentSink`),It.isNative(n))return E(0,!0,T.signal);{let B=(w=p.end)!=null?w:1/0;if(p.start>B)c.warn(\"Stream: Can't free buffer: period's start is after its end\");else if(await O.value.removeBuffer(p.start,B),T.isUsed())return}}else if(O.type===\"uninitialized\"&&(o.disableSegmentSink(n),T.isUsed()))return;return d.adaptationChange({type:n,adaptation:null,period:p}),T.isUsed()?void 0:Ss(r,u,n,{period:p},d,T.signal)}let C=p.adaptations[n],P=K(C!=null?C:[],O=>O.id===v.adaptationId);if(P===void 0){I.cancel(),c.warn(\"Stream: Unfound chosen Adaptation choice\",v.adaptationId);return}let{DELTA_POSITION_AFTER_RELOAD:M}=U.getCurrent(),_=!1,A;if(h)A=0;else if(v.relativeResumingPosition!==void 0)A=v.relativeResumingPosition;else switch(_=!0,n){case\"audio\":A=M.trackSwitch.audio;break;case\"video\":A=M.trackSwitch.video;break;default:A=M.trackSwitch.other;break}if(h=!1,It.isNative(n)&&o.getStatus(n).type===\"disabled\")return E(A,!0,T.signal);m.addEventListener(\"manifestUpdate\",O=>{for(let B of O.updatedPeriods)if(B.period.id===p.id){for(let z of B.result.removedAdaptations)if(z.id===P.id)return E(A,!0,T.signal)}else if(B.period.start>p.start)break},I.signal);let{representations:x}=v;if(c.info(`Stream: Updating ${n} adaptation`,`A: ${P.id}`,`P: ${p.start}`),d.adaptationChange({type:n,adaptation:P,period:p}),T.isUsed())return;let k=ml(o,n,P),D=ma(k,p,P,v.switchingMode,r,s);if(D.type===\"needs-reload\")return E(A,!0,T.signal);if(await o.waitForUsableBuffers(T.signal),!T.isUsed()){if(D.type===\"flush-buffer\"||D.type===\"clean-buffer\"){for(let{start:O,end:B}of D.value)if(await k.removeBuffer(O,B),T.isUsed())return;if(D.type===\"flush-buffer\"&&(d.needsBufferFlush({relativeResumingPosition:A,relativePosHasBeenDefaulted:_}),T.isUsed()))return}t.get(k)(T.signal),y(P,x,k,T.signal)}})().catch(T=>{T instanceof ie||(I==null||I.cancel(),d.error(T))})},{clearSignal:f,emitCurrentValue:!0});function y(v,T,C,P){let M=pl(r,v.type);Is({content:{manifest:m,period:p,adaptation:v,representations:T},options:s,playbackObserver:M,representationEstimator:i,segmentSink:C,segmentFetcherCreator:a,wantedBufferAhead:u,maxVideoBufferSize:l},Le(_e({},d),{error:_}),P);function _(A){if(!It.isNative(n)){c.error(`Stream: ${n} Stream crashed. Aborting it.`,A instanceof Error?A:\"\"),o.disposeSegmentSink(n);let x=ge(A,{defaultCode:\"NONE\",defaultReason:\"Unknown `AdaptationStream` error\"});return d.warning(x),P.isCancelled()?void 0:Ss(r,u,n,{period:p},d,P)}c.error(`Stream: ${n} Stream crashed. Stopping playback.`,A instanceof Error?A:\"\"),d.error(A)}}function E(v,T,C){Ct(()=>{r.listen(()=>{C.isCancelled()||d.waitingMediaSourceReload({bufferType:n,period:p,timeOffset:v,stayInPeriod:T})},{includeLastObservation:!0,clearSignal:C})})}}function ml(n,e,t){let r=n.getStatus(e);if(r.type===\"initialized\")return c.info(\"Stream: Reusing a previous SegmentSink for the type\",e),r.value;let i=cl(t);return n.createSegmentSink(e,i)}function cl(n){let e=n.representations.filter(t=>t.isSupported===!0&&t.decipherable!==!1);if(e.length===0)throw new j(\"NO_PLAYABLE_REPRESENTATION\",\"No Representation in the chosen \"+n.type+\" Adaptation can be played\",{tracks:[dt(n)]});return e[0].getMimeTypeString()}function pl(n,e){return n.deriveReadOnlyObserver(function(r,i){let a=new G(o(),i);return r.onUpdate(s,{clearSignal:i,emitCurrentValue:!1}),a;function o(){let u=r.getValue(),l=u.buffered[e],d=l!==null?Ar(l,u.position.getWanted()):0;return H({},u,{bufferGap:d,buffered:l})}function s(){a.setValue(o())}})}function Ss(n,e,t,r,i,a){let{period:o}=r,s=!1;e.onUpdate(u,{emitCurrentValue:!1,clearSignal:a}),n.listen(u,{includeLastObservation:!1,clearSignal:a}),u();function u(){let l=n.getReference().getValue(),d=e.getValue(),f=l.position.getWanted();o.end!==void 0&&f+d>=o.end&&(c.debug('Stream: full \"empty\" AdaptationStream',t),s=!0),i.streamStatusUpdate({period:o,bufferType:t,imminentDiscontinuity:null,position:f,isEmptyStream:!0,hasFinishedLoading:s,neededSegments:[]})}}var ys=ca;function wr(n,e){if(e.length===0)return[];let t=[],r=n.getLastKnownInventory();for(let i=0;i<r.length;i++){let a=r[i];if(e.some(s=>a.infos.period.id===s.period.id&&a.infos.adaptation.id===s.adaptation.id&&a.infos.representation.id===s.representation.id)){let{bufferedStart:s,bufferedEnd:u}=a;if(s===void 0||u===void 0)return c.warn(\"SO: No buffered start or end found from a segment.\"),[{start:0,end:Number.MAX_VALUE}];let l=t[t.length-1];l!==void 0&&l.end===s?l.end=u:t.push({start:s,end:u})}}return t}function pa(n,e,t,r,i,a,o,s){let{manifest:u,initialPeriod:l}=n,{maxBufferAhead:d,maxBufferBehind:f,wantedBufferAhead:m,maxVideoBufferSize:p}=a,{MINIMUM_MAX_BUFFER_AHEAD:g,MAXIMUM_MAX_BUFFER_AHEAD:I,MAXIMUM_MAX_BUFFER_BEHIND:h}=U.getCurrent(),y=new En(T=>{var _,A;let{bufferType:C}=T,P=(_=h[C])!=null?_:1/0,M=(A=I[C])!=null?A:1/0;return x=>{xr({segmentSink:T,playbackObserver:e,maxBufferBehind:Qt(f,k=>Math.min(k,P),x),maxBufferAhead:Qt(d,k=>{var w;let D=Math.max(k,(w=g[C])!=null?w:0);return Math.min(D,M)},x)},x)}});for(let T of r.getBufferTypes())E(T,l);function E(T,C){let P=new At((D,w)=>D.start-w.start),M=!1,_=new W;return _.linkToSignal(s),e.listen(({position:D})=>{var B;let w=D.getWanted();if(!M||!x(w))return;for(c.info(\"Stream: Destroying all PeriodStreams due to out of bounds situation\",T,w),M=!1;P.length()>0;){let z=P.get(P.length()-1);P.removeElement(z),o.periodStreamCleared({type:T,manifest:u,period:z})}_.cancel(),_=new W,_.linkToSignal(s);let O=(B=u.getPeriodForTime(w))!=null?B:u.getNextPeriod(w);if(O===void 0){c.warn(\"Stream: The wanted position is not found in the Manifest.\"),M=!0;return}A(O)},{clearSignal:s,includeLastObservation:!0}),u.addEventListener(\"decipherabilityUpdate\",D=>{s.isCancelled()||k(D).catch(w=>{s.isCancelled()||(_.cancel(),o.error(w))})},s),A(C);function A(D){let w=Le(_e({},o),{waitingMediaSourceReload(O){let B=P.head();B===void 0||B.id!==O.period.id?o.lockedStream({bufferType:O.bufferType,period:O.period}):o.needsMediaSourceReload({timeOffset:O.timeOffset,minimumPosition:O.stayInPeriod?O.period.start:void 0,maximumPosition:O.stayInPeriod?O.period.end:void 0})},periodStreamReady(O){M=!0,P.add(O.period),o.periodStreamReady(O)},periodStreamCleared(O){P.removeElement(O.period),o.periodStreamCleared(O)},error(O){_.cancel(),o.error(O)}});v(T,D,w,_.signal)}function x(D){let w=P.head(),O=P.last();return w===void 0||O===void 0?!0:w.start>D||(R(O.end)?1/0:O.end)<D}async function k(D){let w=r.getStatus(T),O=D.filter(V=>V.adaptation.type===T);if(O.length===0||w.type!==\"initialized\"||O.every(V=>V.representation.decipherable===!0))return;let B=w.value,z=O.filter(V=>V.representation.decipherable===void 0),q=O.filter(V=>V.representation.decipherable===!1),J=wr(B,q),$=wr(B,z);for(M=!1,c.info(\"Stream: Destroying all PeriodStreams for decipherability matters\",T);P.length()>0;){let V=P.get(P.length()-1);P.removeElement(V),o.periodStreamCleared({type:T,manifest:u,period:V})}_.cancel(),_=new W,_.linkToSignal(s);for(let{start:V,end:Y}of[...J,...$]){if(s.isCancelled())return;if(V<Y){if(s.isCancelled())return;await B.removeBuffer(V,Y)}}Ct(()=>{if(s.isCancelled())return;let V=e.getReference().getValue();if(Ts(V,J)){if(o.needsDecipherabilityFlush(),s.isCancelled())return}else if(Ts(V,$)&&(o.needsBufferFlush(),s.isCancelled()))return;let Y=V.position.getWanted(),X=u.getPeriodForTime(Y);if(X===void 0){o.error(new j(\"MEDIA_TIME_NOT_FOUND\",\"The wanted position is not found in the Manifest.\"));return}A(X)})}}function v(T,C,P,M){c.info(\"Stream: Creating new Stream for\",T,C.start);let _=null,A=new W;A.linkToSignal(M),e.listen(({position:O},B)=>{if(C.end!==void 0&&O.getWanted()>=C.end){let z=u.getPeriodAfter(C);if(C.containsTime(O.getWanted(),z))return;c.info(\"Stream: Destroying PeriodStream as the current playhead moved above it\",T,C.start,O.getWanted(),C.end),B(),P.periodStreamCleared({type:T,manifest:u,period:C}),A.cancel()}},{clearSignal:M,includeLastObservation:!0});let x={bufferType:T,content:{manifest:u,period:C},garbageCollectors:y,maxVideoBufferSize:p,segmentFetcherCreator:i,segmentSinksStore:r,options:a,playbackObserver:e,representationEstimator:t,wantedBufferAhead:m},k=Le(_e({},P),{streamStatusUpdate(O){if(O.hasFinishedLoading){let B=u.getPeriodAfter(C);B!==null&&D(B)}else _!==null&&(c.info(\"Stream: Destroying next PeriodStream due to current one being active\",T,_.period.start),P.periodStreamCleared({type:T,manifest:u,period:_.period}),_.canceller.cancel(),_=null);P.streamStatusUpdate(O)},error(O){_!==null&&(_.canceller.cancel(),_=null),A.cancel(),P.error(O)}});ys(x,k,A.signal),w(A.signal);function D(O){if(_!==null){if(_.period.id===O.id)return;c.warn(\"Stream: Creating next `PeriodStream` while one was already created.\",T,O.id,_.period.id),P.periodStreamCleared({type:T,manifest:u,period:_.period}),_.canceller.cancel()}let B=new W;B.linkToSignal(M),_={canceller:B,period:O},v(T,O,P,_.canceller.signal)}function w(O){u.addEventListener(\"manifestUpdate\",B=>{for(let z of B.removedPeriods)if(z.id===C.id){if(u.periods.length>0&&u.periods[0].start<=z.start)return Ct(()=>{if(!O.isCancelled())return o.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})})}else if(z.start>C.start)break;if(B.addedPeriods.length>0&&_!==null){let z=u.getPeriodAfter(C);(z===null||_.period.id!==z.id)&&(c.warn(\"Stream: Destroying next PeriodStream due to new one being added\",T,_.period.start),P.periodStreamCleared({type:T,manifest:u,period:_.period}),_.canceller.cancel(),_=null)}},O)}}}function Ts(n,e){if(e.length===0)return!1;let t=n.position.getPolled();return n.speed>=0?e[e.length-1].end>=t-5:e[0].start<=t+5}var _s=pa;var Es=_s;var wn=class extends oe{constructor(e,t,r){super(),this._canceller=new W,this._manifest=e,this._activeStreams=new Map,this._allBufferTypes=r,this._lastCurrentPeriodId=null;let i=new ga(e);this._maximumPositionCalculator=i;let a=this._canceller.signal;t.listen(({position:o})=>{let s=o.getWanted();if(s<e.getMinimumSafePosition()){let u=new j(\"MEDIA_TIME_BEFORE_MANIFEST\",\"The current position is behind the earliest time announced in the Manifest.\");this.trigger(\"warning\",u)}else if(s>i.getMaximumAvailablePosition()){let u=new j(\"MEDIA_TIME_AFTER_MANIFEST\",\"The current position is after the latest time announced in the Manifest.\");this.trigger(\"warning\",u)}},{includeLastObservation:!0,clearSignal:a}),e.addEventListener(\"manifestUpdate\",()=>{this.trigger(\"endingPositionChange\",this._getManifestEndTime()),!a.isCancelled()&&this._checkEndOfStream()},a)}getCurrentEndingTime(){return this._getManifestEndTime()}onAdaptationChange(e,t,r){if(this._manifest.isLastPeriodKnown){let i=this._manifest.periods[this._manifest.periods.length-1];if(t.id===(i==null?void 0:i.id)&&(e===\"audio\"||e===\"video\")){e===\"audio\"?this._maximumPositionCalculator.updateLastAudioAdaptation(r):this._maximumPositionCalculator.updateLastVideoAdaptation(r);let a=this._maximumPositionCalculator.getEndingPosition(),o=a!==void 0?{isEnd:!0,endingPosition:a}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()};this.trigger(\"endingPositionChange\",o)}}this._canceller.isUsed()||r===null&&this._addActivelyLoadedPeriod(t,e)}onRepresentationChange(e,t){this._addActivelyLoadedPeriod(t,e)}onPeriodCleared(e,t){this._removeActivelyLoadedPeriod(t,e)}onLastSegmentFinishedLoading(e){let t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod||(t.hasFinishedLoadingLastPeriod=!0,this._checkEndOfStream())}onLastSegmentLoadingResume(e){let t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod&&(t.hasFinishedLoadingLastPeriod=!1,this._checkEndOfStream())}dispose(){this.removeEventListener(),this._canceller.cancel()}_addActivelyLoadedPeriod(e,t){let r=this._lazilyCreateActiveStreamInfo(t);r.activePeriods.has(e)||(r.activePeriods.add(e),this._checkCurrentPeriod())}_removeActivelyLoadedPeriod(e,t){let r=this._activeStreams.get(t);r!==void 0&&r.activePeriods.has(e)&&(r.activePeriods.removeElement(e),this._checkCurrentPeriod())}_checkCurrentPeriod(){if(this._allBufferTypes.length===0)return;let e=this._activeStreams.get(this._allBufferTypes[0]);if(e!==void 0)for(let t of e.activePeriods.toArray()){let r=!0;for(let i=1;i<this._allBufferTypes.length;i++){let a=this._activeStreams.get(this._allBufferTypes[i]);if(a===void 0)return;if(!a.activePeriods.toArray().some(u=>u.id===t.id)){r=!1;break}}if(r){this._lastCurrentPeriodId!==t.id&&(this._lastCurrentPeriodId=t.id,this.trigger(\"periodChange\",t));return}}}_getManifestEndTime(){let e=this._maximumPositionCalculator.getEndingPosition();return e!==void 0?{isEnd:!0,endingPosition:e}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()}}_lazilyCreateActiveStreamInfo(e){let t=this._activeStreams.get(e);return t===void 0&&(t={activePeriods:new At((r,i)=>r.start-i.start),hasFinishedLoadingLastPeriod:!1},this._activeStreams.set(e,t)),t}_checkEndOfStream(){if(!this._manifest.isLastPeriodKnown)return;this._allBufferTypes.every(t=>{let r=this._activeStreams.get(t);return r!==void 0&&r.hasFinishedLoadingLastPeriod})?this.trigger(\"endOfStream\",null):this.trigger(\"resumeStream\",null)}},ga=class{constructor(e){this._manifest=e,this._lastAudioAdaptation=void 0,this._lastVideoAdaptation=void 0}updateLastAudioAdaptation(e){this._lastAudioAdaptation=e}updateLastVideoAdaptation(e){this._lastVideoAdaptation=e}getMaximumAvailablePosition(){if(this._manifest.isDynamic)return this._manifest.getMaximumSafePosition();if(this._lastVideoAdaptation===void 0||this._lastAudioAdaptation===void 0)return this._manifest.getMaximumSafePosition();if(this._lastAudioAdaptation===null){if(this._lastVideoAdaptation===null)return this._manifest.getMaximumSafePosition();{let e=Dr(this._lastVideoAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}}else if(this._lastVideoAdaptation===null){let e=Dr(this._lastAudioAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}else{let e=Dr(this._lastAudioAdaptation),t=Dr(this._lastVideoAdaptation);return typeof e!=\"number\"||typeof t!=\"number\"?this._manifest.getMaximumSafePosition():Math.min(e,t)}}getEndingPosition(){var e,t;if(!this._manifest.isDynamic)return this.getMaximumAvailablePosition();if(!(this._lastVideoAdaptation===void 0||this._lastAudioAdaptation===void 0)){if(this._lastAudioAdaptation===null)return this._lastVideoAdaptation===null?void 0:(e=Nr(this._lastVideoAdaptation))!=null?e:void 0;if(this._lastVideoAdaptation===null)return(t=Nr(this._lastAudioAdaptation))!=null?t:void 0;{let r=Nr(this._lastAudioAdaptation),i=Nr(this._lastVideoAdaptation);return typeof r!=\"number\"||typeof i!=\"number\"?void 0:Math.min(r,i)}}}};function Dr(n){let{representations:e}=n,t=null,r;for(let i=0;i<e.length;i++)if(e[i].index!==r){r=e[i].index;let a=e[i].index.getLastAvailablePosition();if(a===void 0)return;a!==null&&(t=R(t)?a:Math.min(t,a))}return t}function Nr(n){let{representations:e}=n,t=null,r;for(let i=0;i<e.length;i++)if(e[i].index!==r){r=e[i].index;let a=e[i].index.getEnd();if(a===void 0)return;a!==null&&(t=R(t)?a:Math.min(t,a))}return t}function ha(n,e,t,r,i,a){a.register(()=>{e.interruptDurationSetting()});let o=new wn(n,t,r.getBufferTypes());a.register(()=>{o.dispose()}),o.addEventListener(\"warning\",u=>i.onWarning(u)),o.addEventListener(\"periodChange\",u=>i.onPeriodChanged(u)),o.addEventListener(\"endingPositionChange\",u=>{e.setDuration(u.endingPosition,u.isEnd)}),o.addEventListener(\"endOfStream\",()=>{c.debug(\"Init: end-of-stream order received.\"),e.maintainEndOfStream()}),o.addEventListener(\"resumeStream\",()=>{e.stopEndOfStream()});let s=o.getCurrentEndingTime();return e.setDuration(s.endingPosition,s.isEnd),o}function Ia(n,e){let t={audio:null,video:null,text:null};if(e!==null&&(t.text=e.getBufferedRanges()),n===null)return t;let r=K(n.sourceBuffers,s=>s.type===\"audio\"),i=K(n.sourceBuffers,s=>s.type===\"video\"),a=r==null?void 0:r.getBuffered();a!==void 0&&(t.audio=a);let o=i==null?void 0:i.getBuffered();return o!==void 0&&(t.video=o),t}function ba(n,e){if(typeof n.changeType==\"function\"){try{n.changeType(e)}catch(t){return c.warn(\"Could not call 'changeType' on the given SourceBuffer:\",t instanceof Error?t:\"\"),!1}return!0}return!1}var gl=[\"\",\"webkit\",\"moz\",\"ms\"];function hl(n,e){let t=document.createElement(n.tagName),r=\"on\"+e;return r in t?!0:(t.setAttribute(r,\"return;\"),typeof t[r]==\"function\")}function Il(n,e){return e.filter(t=>hl(n,t))[0]}function bl(n,e){return n.reduce((t,r)=>t.concat((e===void 0?gl:e).map(i=>i+r)),[])}function Te(n,e){let t,r=bl(n,e);return(i,a,o)=>{if(!o.isCancelled()){if(typeof HTMLElement!=\"undefined\"&&i instanceof HTMLElement)if(typeof t==\"undefined\"&&(t=Il(i,r)),Z(t))i.addEventListener(t,a),o.register(()=>{t!==void 0&&i.removeEventListener(t,a)});else{b.CURRENT_ENV===b.DEV&&c.warn(`compat: element ${i.tagName} does not support any of these events: `+r.join(\", \"));return}r.forEach(s=>{let u=!1;typeof i.addEventListener==\"function\"?i.addEventListener(s,a):(u=!0,i[\"on\"+s]=a),o.register(()=>{typeof i.removeEventListener==\"function\"&&i.removeEventListener(s,a),u&&delete i[\"on\"+s]})})}}}var kD=Te([\"loadedmetadata\"]),xD=Te([\"timeupdate\"]),MD=Te([\"addtrack\"]),OD=Te([\"removetrack\"]),Ht=Te([\"sourceopen\",\"webkitsourceopen\"]),Br=Te([\"sourceclose\",\"webkitsourceclose\"]),Ur=Te([\"sourceended\",\"webkitsourceended\"]),Rs=Te([\"update\"]),Ps=Te([\"removesourcebuffer\"]),wD=Te([\"keymessage\",\"message\"]),DD=Te([\"keyadded\",\"ready\"]),ND=Te([\"keyerror\",\"error\"]),BD=Te([\"keystatuseschange\"]),UD=Te([\"seeking\"]),LD=Te([\"seeked\"]),FD=Te([\"ended\"]);function Sl(n){let e=[];for(let t=0;t<n.length;t++){let r=n[t];r.updating&&e.push(r)}return e}function Dn(n,e){if(c.debug(\"Init: Trying to call endOfStream\"),n.readyState!==\"open\"){c.debug(\"Init: MediaSource not open, cancel endOfStream\");return}let{sourceBuffers:t}=n,r=Sl(t);if(r.length===0){c.info(\"Init: Triggering end of stream\"),n.endOfStream();return}c.debug(\"Init: Waiting SourceBuffers to be updated before calling endOfStream.\");let i=new W;i.linkToSignal(e);for(let a of r)Rs(a,()=>{i.cancel(),Dn(n,e)},i.signal);Ps(t,()=>{i.cancel(),Dn(n,e)},i.signal)}function vs(n,e){let t=new W;t.linkToSignal(e),Ht(n,()=>{c.debug(\"Init: MediaSource re-opened while end-of-stream is active\"),t.cancel(),t=new W,t.linkToSignal(e),Dn(n,t.signal)},e),Dn(n,t.signal)}var yl=!1,Tl=!1,Cs=!1,_l=!1,El=!1,Rl=!1,Pl=!1,vl=!1,Cl=!1,Al=!1,kl=!1,xl=!1,Ml=!1,Sa=!1,Ol=!1;(function(){var e,t,r;er||(typeof Ee.MSInputMethodContext!=\"undefined\"&&typeof document.documentMode!=\"undefined\"?(Tl=!0,Cs=!0):navigator.appName===\"Microsoft Internet Explorer\"||navigator.appName===\"Netscape\"&&/(Trident|Edge)\\//.test(navigator.userAgent)?Cs=!0:navigator.userAgent.toLowerCase().indexOf(\"edg/\")!==-1?yl=!0:navigator.userAgent.toLowerCase().indexOf(\"firefox\")!==-1?_l=!0:typeof navigator.platform==\"string\"&&/iPad|iPhone|iPod/.test(navigator.platform)?Rl=!0:(Object.prototype.toString.call(Ee.HTMLElement).indexOf(\"Constructor\")>=0||((t=(e=Ee.safari)==null?void 0:e.pushNotification)==null?void 0:t.toString())===\"[object SafariRemoteNotification]\"||/Safari\\/(\\d+)/.test(navigator.userAgent)&&/Version\\/(\\d+)/.test(navigator.userAgent)&&((r=navigator.vendor)==null?void 0:r.indexOf(\"Apple\"))!==-1&&!/Chrome\\/(\\d+)/.test(navigator.userAgent)&&!/Chromium\\/(\\d+)/.test(navigator.userAgent))&&(El=!0),/SamsungBrowser/.test(navigator.userAgent)&&(Pl=!0),navigator.userAgent.indexOf(\"PlayStation 4\")!==-1?Ml=!0:navigator.userAgent.indexOf(\"PlayStation 5\")!==-1?Sa=!0:/Tizen/.test(navigator.userAgent)?vl=!0:/[Ww]eb[O0]S/.test(navigator.userAgent)?(Cl=!0,/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/87/.test(navigator.userAgent)?kl=!0:(/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/79/.test(navigator.userAgent))&&(Al=!0)):/[Pp]anasonic/.test(navigator.userAgent)?xl=!0:navigator.userAgent.indexOf(\"Xbox\")!==-1&&(Ol=!0))})();function ya(){return Sa}var wl=365*24*3600,Nn=class{constructor(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}updateDuration(e,t){this._currentMediaSourceDurationUpdateCanceller!==null&&this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=new W;let r=this._mediaSource,i=this._currentMediaSourceDurationUpdateCanceller.signal,a=Bl(r,i),o=new W;o.linkToSignal(i),a.onUpdate(s,{emitCurrentValue:!0,clearSignal:i});function s(){if(o.cancel(),!a.getValue())return;o=new W,o.linkToSignal(i);let u=Nl(r.sourceBuffers,o.signal),l=new W;return l.linkToSignal(o.signal),u.onUpdate(d=>{l.cancel(),l=new W,l.linkToSignal(o.signal),!d&&ks(r,e,t,l.signal)},{clearSignal:o.signal,emitCurrentValue:!0})}}stopUpdating(){this._currentMediaSourceDurationUpdateCanceller!==null&&(this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=null)}};function Dl(n,e,t){let r=e;t||(r=ya()?1/0:As(e));let i=0;for(let a=0;a<n.sourceBuffers.length;a++){let o=n.sourceBuffers[a],s=o.buffered.length;s>0&&(i=Math.max(o.buffered.end(s-1)))}if(r===n.duration)return\"success\";if(i>r){if(i<n.duration)try{c.info(\"Init: Updating duration to what is currently buffered\",i),n.duration=i}catch(a){return c.warn(\"Duration Updater: Can't update duration on the MediaSource.\",a instanceof Error?a:\"\"),\"failed\"}return\"partial\"}else{let a=n.duration;try{if(c.info(\"Init: Updating duration\",r),n.duration=r,n.readyState===\"open\"&&!isFinite(r)){let s=As(e);c.info(\"Init: calling `mediaSource.setLiveSeekableRange`\",s),n.setLiveSeekableRange(0,s)}}catch(s){return c.warn(\"Duration Updater: Can't update duration on the MediaSource.\",s instanceof Error?s:\"\"),\"failed\"}let o=Math.abs(n.duration-r);if(o>=.1){let s=Math.abs(n.duration-a);return o<s?\"partial\":\"failed\"}return\"success\"}}function Nl(n,e){if(n.length===0){let i=new G(!1);return i.finish(),i}let t=new G(!1,e);r();for(let i=0;i<n.length;i++){let a=n[i];a.addEventListener(\"updatestart\",r),a.addEventListener(\"update\",r),e.register(()=>{a.removeEventListener(\"updatestart\",r),a.removeEventListener(\"update\",r)})}return t;function r(){for(let i=0;i<n.length;i++)if(n[i].updating){t.setValueIfChanged(!0);return}t.setValueIfChanged(!1)}}function Bl(n,e){let t=new G(n.readyState===\"open\",e);return Ht(n,()=>{c.debug(\"Init: Reacting to MediaSource open in duration updater\"),t.setValueIfChanged(!0)},e),Ur(n,()=>{c.debug(\"Init: Reacting to MediaSource ended in duration updater\"),t.setValueIfChanged(!1)},e),Br(n,()=>{c.debug(\"Init: Reacting to MediaSource close in duration updater\"),t.setValueIfChanged(!1)},e),t}function ks(n,e,t,r){if(Dl(n,e,t)===\"success\")return;let a=setTimeout(()=>{o(),ks(n,e,t,r)},2e3),o=r.register(()=>{clearTimeout(a)})}function As(n){return Math.max(Math.pow(2,32),n+wl)}var Bn=class extends oe{constructor(e){if(super(),this.id=e,this.sourceBuffers=[],this._canceller=new W,R(yt))throw new j(\"MEDIA_SOURCE_NOT_SUPPORTED\",\"No MediaSource Object was found in the current browser.\");c.info(\"Init: Creating MediaSource\");let t=new yt;this.readyState=t.readyState;let r=t.handle;this.handle=R(r)?{type:\"media-source\",value:t}:{type:\"handle\",value:r},this._mediaSource=t,this._durationUpdater=new Nn(t),this._endOfStreamCanceller=null,Ht(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceOpen\",null)},this._canceller.signal),Ur(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceEnded\",null)},this._canceller.signal),Br(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceClose\",null)},this._canceller.signal)}addSourceBuffer(e,t){let r=this._mediaSource.addSourceBuffer(t),i=new Ta(e,t,r);return this.sourceBuffers.push(i),i}setDuration(e,t){this._durationUpdater.updateDuration(e,t)}interruptDurationSetting(){this._durationUpdater.stopUpdating()}maintainEndOfStream(){this._endOfStreamCanceller===null&&(this._endOfStreamCanceller=new W,this._endOfStreamCanceller.linkToSignal(this._canceller.signal),c.debug(\"Init: end-of-stream order received.\"),vs(this._mediaSource,this._endOfStreamCanceller.signal))}stopEndOfStream(){this._endOfStreamCanceller!==null&&(c.debug(\"Init: resume-stream order received.\"),this._endOfStreamCanceller.cancel(),this._endOfStreamCanceller=null)}dispose(){this.sourceBuffers.forEach(e=>e.dispose()),this._canceller.cancel(),Ul(this._mediaSource)}},Ta=class{constructor(e,t,r){this.type=e,this.codec=t,this._canceller=new W,this._sourceBuffer=r,this._operationQueue=[],this._currentOperations=[];let i=o=>{let s;o instanceof Error?s=o:o.error instanceof Error?s=o.error:s=new Error(\"Unknown SourceBuffer Error\");let u=this._currentOperations;if(this._currentOperations=[],u.length===0)c.error(\"SBI: error for an unknown operation\",s);else{let l=new Ce(s.name,s.message,s.name===\"QuotaExceededError\");for(let d of u)d.reject(l)}},a=()=>{let o=this._currentOperations;this._currentOperations=[];try{for(let s of o)s.resolve(ta(this._sourceBuffer.buffered))}catch(s){for(let u of o)s instanceof Error&&s.name===\"InvalidStateError\"?u.resolve([]):u.reject(s)}this._performNextOperation()};r.addEventListener(\"error\",i),r.addEventListener(\"updateend\",a),this._canceller.signal.register(()=>{r.removeEventListener(\"error\",i),r.removeEventListener(\"updateend\",a)})}appendBuffer(...e){return c.debug(\"SBI: receiving order to push data to the SourceBuffer\",this.type),this._addToQueue({operationName:0,params:e})}remove(e,t){return c.debug(\"SBI: receiving order to remove data from the SourceBuffer\",this.type,e,t),this._addToQueue({operationName:1,params:[e,t]})}getBuffered(){try{return ta(this._sourceBuffer.buffered)}catch(e){return c.error(\"Failed to get buffered time range of SourceBuffer\",this.type,e instanceof Error?e:null),[]}}abort(){try{this._sourceBuffer.abort()}catch(e){c.debug(\"Init: Failed to abort SourceBuffer:\",e instanceof Error?e:null)}this._emptyCurrentQueue()}dispose(){try{this._sourceBuffer.abort()}catch(e){}this._emptyCurrentQueue()}_emptyCurrentQueue(){let e=new ie;this._currentOperations.length>0&&(this._currentOperations.forEach(t=>{t.reject(e)}),this._currentOperations=[]),this._operationQueue.length>0&&(this._operationQueue.forEach(t=>{t.reject(e)}),this._operationQueue=[])}_addToQueue(e){return new Promise((t,r)=>{let i=this._operationQueue.length===0&&this._currentOperations.length===0,a=H({resolve:t,reject:r},e);this._operationQueue.push(a),i&&this._performNextOperation()})}_performNextOperation(){var t,r,i,a,o;if(this._currentOperations.length!==0||this._sourceBuffer.updating)return;let e=this._operationQueue.shift();if(e!==void 0)if(e.operationName===0){this._currentOperations=[{operationName:0,resolve:e.resolve,reject:e.reject}];let s=e.params[0],u=e.params[1],l=s;if(this._operationQueue.length>0&&this._operationQueue[0].operationName===0){let d;s instanceof ArrayBuffer?d=new Uint8Array(s):s instanceof Uint8Array?d=s:d=new Uint8Array(s.buffer);let f=[d];for(;((t=this._operationQueue[0])==null?void 0:t.operationName)===0;){let m=this._operationQueue[0],p=(r=u.appendWindow)!=null?r:[void 0,void 0],g=(i=m.params[1].appendWindow)!=null?i:[void 0,void 0],I=(a=u.timestampOffset)!=null?a:0,h=(o=m.params[1].timestampOffset)!=null?o:0;if(p[0]===g[0]&&p[1]===g[1]&&u.codec===m.params[1].codec&&I===h){let y=m.params[0],E;y instanceof ArrayBuffer?E=new Uint8Array(y):y instanceof Uint8Array?E=y:E=new Uint8Array(y.buffer),f.push(E),this._operationQueue.splice(0,1),this._currentOperations.push({operationName:0,resolve:m.resolve,reject:m.reject})}else break}f.length>1&&(c.info(`MMSI: Merging ${f.length} segments together for perf`,this.type),l=rt(...f))}try{this._appendBufferNow(l,u)}catch(d){let f=d instanceof Error?new Ce(d.name,d.message,d.name===\"QuotaExceededError\"):new Ce(\"Error\",\"Unknown SourceBuffer Error during appendBuffer\",!1);this._currentOperations.forEach(m=>{m.reject(f)}),this._currentOperations=[]}}else{this._currentOperations=[e];let[s,u]=e.params;c.debug(\"SBI: removing data from SourceBuffer\",this.type,s,u);try{this._sourceBuffer.remove(s,u)}catch(l){let d=l instanceof Error?new Ce(l.name,l.message,!1):new Ce(\"Error\",\"Unknown SourceBuffer Error during remove\",!1);e.reject(d),this._currentOperations=[]}}}_appendBufferNow(e,t){let r=this._sourceBuffer,{codec:i,timestampOffset:a,appendWindow:o=[]}=t;if(i!==void 0&&i!==this.codec&&(c.debug(\"SBI: updating codec\",i),ba(r,i)?this.codec=i:c.debug(\"SBI: could not update codec\",i,this.codec)),a!==void 0&&r.timestampOffset!==a){let s=a;c.debug(\"SBI: updating timestampOffset\",i,r.timestampOffset,s),r.timestampOffset=s}if(o[0]===void 0)r.appendWindowStart>0&&(c.debug(\"SBI: re-setting `appendWindowStart` to `0`\"),r.appendWindowStart=0);else if(o[0]!==r.appendWindowStart){if(o[0]>=r.appendWindowEnd){let s=o[0]+1;c.debug(\"SBI: pre-updating `appendWindowEnd`\",s),r.appendWindowEnd=s}c.debug(\"SBI: setting `appendWindowStart`\",o[0]),r.appendWindowStart=o[0]}o[1]===void 0?r.appendWindowEnd!==1/0&&(c.debug(\"SBI: re-setting `appendWindowEnd` to `Infinity`\"),r.appendWindowEnd=1/0):o[1]!==r.appendWindowEnd&&(c.debug(\"SBI: setting `appendWindowEnd`\",o[1]),r.appendWindowEnd=o[1]),c.debug(\"SBI: pushing segment\",this.type),r.appendBuffer(e)}};function Ul(n){if(n.readyState!==\"closed\"){let{readyState:e,sourceBuffers:t}=n;for(let r=t.length-1;r>=0;r--){let i=t[r];try{if(e===\"open\"){c.info(\"Init: Aborting SourceBuffer before removing\");try{i.abort()}catch(a){}}c.info(\"Init: Removing SourceBuffer from mediaSource\"),n.removeSourceBuffer(i)}catch(a){}}t.length>0&&c.info(\"Init: Not all SourceBuffers could have been removed.\")}}var Ll=Ae(),Lr=Ae(),xs=1/0,Un=class extends oe{constructor(e,t,r){super(),this.id=e,this.sourceBuffers=[],this._canceller=new W,this.readyState=\"closed\",this._messageSender=r;let i=Ll();this._messageSender({type:\"create-media-source\",contentId:t,mediaSourceId:i})}onMediaSourceReadyStateChanged(e){switch(e){case\"closed\":this.readyState=\"closed\",this.trigger(\"mediaSourceClose\",null);break;case\"open\":this.readyState=\"open\",this.trigger(\"mediaSourceOpen\",null);break;case\"ended\":this.readyState=\"ended\",this.trigger(\"mediaSourceEnded\",null);break}}addSourceBuffer(e,t){this._messageSender({type:\"add-source-buffer\",mediaSourceId:this.id,value:{sourceBufferType:e,codec:t}});let r=new _a(e,t,this.id,this._messageSender);return this.sourceBuffers.push(r),r}setDuration(e,t){this._messageSender({type:\"update-media-source-duration\",mediaSourceId:this.id,value:{duration:e,isRealEndKnown:t}})}interruptDurationSetting(){this._messageSender({type:\"stop-media-source-duration\",mediaSourceId:this.id,value:null})}maintainEndOfStream(){this._messageSender({type:\"end-of-stream\",mediaSourceId:this.id,value:null})}stopEndOfStream(){this._messageSender({type:\"stop-end-of-stream\",mediaSourceId:this.id,value:null})}dispose(){this.sourceBuffers.forEach(e=>e.dispose()),this._canceller.cancel(),this._messageSender({type:\"dispose-media-source\",mediaSourceId:this.id,value:null})}},_a=class{constructor(e,t,r,i){this.type=e,this.codec=t,this._canceller=new W,this._mediaSourceId=r,this._queuedOperations=[],this._pendingOperations=new Map,this._messageSender=i}onOperationSuccess(e,t){let r=this._pendingOperations.get(e);r===void 0?c.warn(\"SBI: unknown SourceBuffer operation succeeded\"):(this._pendingOperations.delete(e),r.resolve(t)),this._performNextQueuedOperationIfItExists()}onOperationFailure(e,t){let r=t.errorName===\"CancellationError\"?new ie:new Ce(t.errorName,t.message,t.isBufferFull),i=this._pendingOperations.get(e);i===void 0?c.info(\"SBI: unknown SourceBuffer operation failed\",r):(this._pendingOperations.delete(e),i.reject(r));let a=new ie;for(let o of this._queuedOperations)o.reject(a);this._queuedOperations=[]}appendBuffer(e,t){return new Promise((r,i)=>{if(this._queuedOperations.length>0||this._pendingOperations.size>=xs){this._queuedOperations.push({operationName:0,params:[e,t],resolve:r,reject:i});return}try{let a;e instanceof ArrayBuffer?a=e:e.byteLength===e.buffer.byteLength?a=e.buffer:a=e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset);let o=Lr();this._messageSender({type:\"source-buffer-append\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:o,value:{data:a,params:t}},[a]),this._addOperationToQueue(o,r,i)}catch(a){i(a)}})}remove(e,t){return new Promise((r,i)=>{if(this._queuedOperations.length>0||this._pendingOperations.size>=xs){this._queuedOperations.push({operationName:1,params:[e,t],resolve:r,reject:i});return}try{let a=Lr();this._messageSender({type:\"source-buffer-remove\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:a,value:{start:e,end:t}}),this._addOperationToQueue(a,r,i)}catch(a){i(a)}})}abort(){this._messageSender({type:\"abort-source-buffer\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,value:null})}dispose(){this.abort(),this._canceller.cancel()}getBuffered(){}_addOperationToQueue(e,t,r){this._pendingOperations.set(e,{resolve:a,reject:o});let i=this._canceller.signal.register(s=>{this._pendingOperations.delete(e),r(s)});function a(s){i(),t(s)}function o(s){i(),r(s)}}_performNextQueuedOperationIfItExists(){let e=this._queuedOperations.shift();if(e!==void 0)try{if(e.operationName===0){let[t,r]=e.params,i;t instanceof ArrayBuffer?i=t:t.byteLength===t.buffer.byteLength?i=t.buffer:i=t.buffer.slice(t.byteOffset,t.byteLength+t.byteOffset);let a=Lr();this._messageSender({type:\"source-buffer-append\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:a,value:{data:i,params:r}},[i]),this._addOperationToQueue(a,e.resolve,e.reject)}else{let[t,r]=e.params,i=Lr();this._messageSender({type:\"source-buffer-remove\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:i,value:{start:t,end:r}}),this._addOperationToQueue(i,e.resolve,e.reject)}}catch(t){e.reject(t)}}};function Ea(n){let e=n.map(o=>Math.log(o/n[0])),t=e.map(o=>o-e[0]+1),r=(t[t.length-1]-1)/(n.length*2+10),i=1/r;return n.map((o,s)=>a(s));function a(o){if(o===0)return 0;let s=Math.min(Math.max(1,o),n.length-1);return n[s]===n[s-1]?a(o-1):i*(r+(n[s]*t[s-1]-n[s-1]*t[s])/(n[s]-n[s-1]))+4}}var Ue=class{constructor(e){this._alpha=Math.exp(Math.log(.5)/e),this._lastEstimate=0,this._totalWeight=0}addSample(e,t){let r=Math.pow(this._alpha,e),i=t*(1-r)+r*this._lastEstimate;isNaN(i)||(this._lastEstimate=i,this._totalWeight+=e)}getEstimate(){let e=1-Math.pow(this._alpha,this._totalWeight);return this._lastEstimate/e}};var Ln=class{constructor(){this._currentRepresentationData=null,this._lastRepresentationWithGoodScore=null}addSample(e,t,r){let i=r/t,a=this._currentRepresentationData,o;a!==null&&a.representation.id===e.id?(o=a.ewma,a.ewma.addSample(t,i),a.loadedDuration+=r,a.loadedSegments++):(o=new Ue(5),o.addSample(t,i),this._currentRepresentationData={representation:e,ewma:o,loadedDuration:r,loadedSegments:0}),o.getEstimate()>1&&this._lastRepresentationWithGoodScore!==e&&(c.debug(\"ABR: New last stable representation\",e.bitrate),this._lastRepresentationWithGoodScore=e)}getEstimate(e){if(this._currentRepresentationData===null||this._currentRepresentationData.representation.id!==e.id)return;let{ewma:t,loadedSegments:r,loadedDuration:i}=this._currentRepresentationData,a=t.getEstimate(),o=r>=5&&i>=10?1:0;return{score:a,confidenceLevel:o}}getLastStableRepresentation(){return this._lastRepresentationWithGoodScore}};var Ms=6e3,Fl=15e3,zl=3e3,Wl=1e3,Vl=9e3,Fn=class{constructor(e){this._levelsMap=Ea(e).map(t=>t+4),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=Ms,c.debug(\"ABR: Steps for buffer based chooser.\",this._levelsMap.map((t,r)=>`bufferLevel: ${t}, bitrate: ${e[r]}`).join(\" ,\"))}onAddedSegment(e){let t=this._levelsMap,r=this._bitrates,{bufferGap:i,currentBitrate:a,currentScore:o,speed:s}=e;if(R(a)){this._currentEstimate=r[0];return}let u=-1;for(let g=0;g<r.length;g++){let I=r[g];if(I===a)u=g;else if(I>a)break}if(u<0||r.length!==t.length){c.info(\"ABR: Current Bitrate not found in the calculated levels\"),this._currentEstimate=r[0];return}let l;o!==void 0&&(l=s===0?o.score:o.score/s);let d=isFinite(i)?i:0,f=L();if(d<t[u]||l!==void 0&&l<1&&(o==null?void 0:o.confidenceLevel)===1){if((this._lastUnsuitableQualityTimestamp===void 0?-1:f-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+Vl){let h=this._blockRaiseDelay+zl;this._blockRaiseDelay=Math.min(h,Fl),c.debug(\"ABR: Incrementing blocking raise in BufferBasedChooser due to unstable quality\",this._blockRaiseDelay)}else{let h=this._blockRaiseDelay-Wl;this._blockRaiseDelay=Math.max(Ms,h),c.debug(\"ABR: Lowering quality in BufferBasedChooser\",this._blockRaiseDelay)}this._lastUnsuitableQualityTimestamp=f;let I=ne(r,h=>h===a);for(let h=I-1;h>=0;h--)if(d>=t[h]){this._currentEstimate=r[h];return}this._currentEstimate=r[0];return}if(this._lastUnsuitableQualityTimestamp!==void 0&&f-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||l===void 0||l<1.15||(o==null?void 0:o.confidenceLevel)!==1){this._currentEstimate=a;return}let m=t[u],p=(()=>{for(let g=u+1;g<t.length;g++)if(t[g]>m)return g})();if(p!==void 0){let g=t[p];if(i>=g){c.debug(\"ABR: Raising quality in BufferBasedChooser\",r[p]),this._currentEstimate=r[p];return}}this._currentEstimate=a}getLastEstimate(){return this._currentEstimate}};function ql(n,e){let t=-1;for(let o=0;o<n.length;o++){let{segment:s}=n[o].content;if(s.duration<=0)continue;let u=s.time+s.duration;if(!s.complete&&o===n.length-1&&e-s.time>-1.2){t=o;break}if(u>e&&e-s.time>-1.2){t=o;break}}if(t<0)return[];let r=n[t],i=r.content.segment.time,a=[r];for(let o=t+1;o<n.length&&n[o].content.segment.time===i;o++)a.push(n[o]);return a}function Fr(n){if(n.progress.length<5)return;let e=new Ue(2),{progress:t}=n;for(let r=1;r<t.length;r++){let i=t[r].size-t[r-1].size,a=t[r].timestamp-t[r-1].timestamp,o=i*8/(a/1e3);e.addSample(a/1e3,o)}return e.getEstimate()}function Os(n,e){let t=(n.totalSize-n.size)*8;return Math.max(t/e,0)}function Hl(n,e,t,r,i){if(r)return;let{bufferGap:a,speed:o,position:s}=e,u=isFinite(a)?a:0,l=s.getWanted()+u,d=ql(n,l);if(d.length!==1)return;let f=d[0],m=L(),p=f.content.segment.duration*1.5;if(p=Math.min(p,3e3),p=Math.max(p,12e3),m-f.requestTimestamp<p)return;let g=f.progress.length>0?f.progress[f.progress.length-1]:void 0,I=Fr(f);if(g!==void 0&&I!==void 0){let C=Os(g,I);if((m-g.timestamp)/1e3<=C&&C-u/o>2500)return I}if(!f.content.segment.complete)return;let h=f.content.segment.duration,y=(m-f.requestTimestamp)/1e3,E=y<=(h*1.5+2)/o;if(R(t)||E)return;let v=h/y,T=t.bitrate*Math.min(.7,v);if(i===void 0||T<i)return T}function Gl(n,e,t){if(t)return!0;let r=isFinite(n.bufferGap)?n.bufferGap:0,i=n.position.getWanted()+r,a=K(e,({content:f})=>f.segment.duration>0&&f.segment.time+f.segment.duration>i);if(a===void 0)return!0;let o=L(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,u=Fr(a);if(s===void 0||u===void 0)return!0;let l=Os(s,u);return(o-s.timestamp)/1e3>l*1.2?!0:l-r/n.speed>-1.5}var zn=class{constructor(e,t){let{ABR_STARVATION_GAP:r,OUT_OF_STARVATION_GAP:i,ABR_STARVATION_FACTOR:a,ABR_REGULAR_FACTOR:o}=U.getCurrent();this._initialBitrate=e,this._inStarvationMode=!1,this._lowLatencyMode=t,t?this._config={starvationGap:r.LOW_LATENCY,outOfStarvationGap:i.LOW_LATENCY,starvationBitrateFactor:a.LOW_LATENCY,regularBitrateFactor:o.LOW_LATENCY}:this._config={starvationGap:r.DEFAULT,outOfStarvationGap:i.DEFAULT,starvationBitrateFactor:a.DEFAULT,regularBitrateFactor:o.DEFAULT}}getBandwidthEstimate(e,t,r,i,a){let o,s,u=this._config,{bufferGap:l,position:d,duration:f}=e,m=isFinite(l)?l:0,{ABR_STARVATION_DURATION_DELTA:p}=U.getCurrent();return isNaN(f)||m+d.getWanted()<f-p?!this._inStarvationMode&&m<=u.starvationGap?(c.info(\"ABR: enter starvation mode.\"),this._inStarvationMode=!0):this._inStarvationMode&&m>=u.outOfStarvationGap&&(c.info(\"ABR: exit starvation mode.\"),this._inStarvationMode=!1):this._inStarvationMode&&(c.info(\"ABR: exit starvation mode.\"),this._inStarvationMode=!1),this._inStarvationMode&&(s=Hl(i,e,r,this._lowLatencyMode,a),s!==void 0&&(c.info(\"ABR: starvation mode emergency estimate:\",s),t.reset(),o=R(r)?s:Math.min(s,r.bitrate))),R(o)&&(s=t.getEstimate(),s!==void 0?o=s*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):a!==void 0?o=a*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):o=this._initialBitrate),e.speed>1&&(o/=e.speed),{bandwidthEstimate:s,bitrateChosen:o}}isUrgent(e,t,r,i){return t===null?!0:e>=t.bitrate?!1:Gl(i,r,this._lowLatencyMode)}};var Wn=class{constructor(){this.bandwidth=void 0,this.representation=null,this.algorithmType=3}update(e,t,r){this.representation=e,this.bandwidth=t,this.algorithmType=r}};var Vn=class{constructor(e,t){this._scoreCalculator=e,this._lastAbrEstimate=t,this._consecutiveWrongGuesses=0,this._blockGuessesUntil=0,this._lastMaintanableBitrate=null}getGuess(e,t,r,i,a){let{bufferGap:o,speed:s}=t,u=this._lastAbrEstimate.representation;if(u===null)return null;if(i>u.bitrate)return this._lastAbrEstimate.algorithmType===2&&(this._lastAbrEstimate.representation!==null&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;let l=this._scoreCalculator.getEstimate(r);if(this._lastAbrEstimate.algorithmType!==2){if(l===void 0)return null;if(this._canGuessHigher(o,s,l)){let f=ws(e,r);if(f!==null)return f}return null}if(this._isLastGuessValidated(u,i,l)&&(c.debug(\"ABR: Guessed Representation validated\",u.bitrate),this._lastMaintanableBitrate=u.bitrate,this._consecutiveWrongGuesses=0),r.id!==u.id)return u;if(this._shouldStopGuess(r,l,o,a))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=L()+Math.min(this._consecutiveWrongGuesses*15e3,12e4),Kl(e,r);if(l===void 0)return r;if(this._canGuessHigher(o,s,l)){let f=ws(e,r);if(f!==null)return f}return r}_canGuessHigher(e,t,{score:r,confidenceLevel:i}){return isFinite(e)&&e>=2.5&&L()>this._blockGuessesUntil&&i===1&&r/t>1.01}_shouldStopGuess(e,t,r,i){if(t!==void 0&&t.score<1.01)return!0;if((t===void 0||t.score<1.2)&&r<.6)return!0;let a=i.filter(s=>s.content.representation.id===e.id),o=L();for(let s of a){let u=o-s.requestTimestamp;if(s.content.segment.isInit){if(u>1e3)return!0}else{if(u>s.content.segment.duration*1e3+200)return!0;{let l=Fr(s);if(l!==void 0&&l<e.bitrate*.8)return!0}}}return!1}_isLastGuessValidated(e,t,r){return r!==void 0&&r.confidenceLevel===1&&r.score>1.5?!0:t>=e.bitrate&&(this._lastMaintanableBitrate===null||this._lastMaintanableBitrate<e.bitrate)}};function ws(n,e){let t=n.length,r=ne(n,({id:i})=>i===e.id);if(r<0)return c.error(\"ABR: Current Representation not found.\"),null;for(;++r<t;)if(n[r].bitrate>e.bitrate)return n[r];return null}function Kl(n,e){let t=ne(n,({id:r})=>r===e.id);if(t<0)return c.error(\"ABR: Current Representation not found.\"),null;for(;--t>=0;)if(n[t].bitrate<e.bitrate)return n[t];return null}var qn=class{constructor(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=U.getCurrent();this._fastEWMA=new Ue(e),this._slowEWMA=new Ue(t),this._bytesSampled=0}addSample(e,t){let{ABR_MINIMUM_CHUNK_SIZE:r}=U.getCurrent();if(t<r)return;let i=t*8e3/e,a=e/1e3;this._bytesSampled+=t,this._fastEWMA.addSample(a,i),this._slowEWMA.addSample(a,i)}getEstimate(){let{ABR_MINIMUM_TOTAL_BYTES:e}=U.getCurrent();if(!(this._bytesSampled<e))return Math.min(this._fastEWMA.getEstimate(),this._slowEWMA.getEstimate())}reset(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=U.getCurrent();this._fastEWMA=new Ue(e),this._slowEWMA=new Ue(t),this._bytesSampled=0}};function Ra(n,e){if(n.length===0)return[];n.sort((a,o)=>a.bitrate-o.bitrate);let t=n[0].bitrate,r=Math.max(e,t),i=ne(n,a=>a.bitrate>r);return i===-1?n:n.slice(0,i)}function Pa(n,e){if(e.width===void 0||e.height===void 0)return n;let t=e.width*e.pixelRatio,r=e.height*e.pixelRatio,i=n.slice().sort((s,u)=>{var l,d;return((l=s.width)!=null?l:0)-((d=u.width)!=null?d:0)}),a=K(i,s=>typeof s.width==\"number\"&&s.width>=t&&typeof s.height==\"number\"&&s.height>=r);if(a===void 0)return n;let o=typeof a.width==\"number\"?a.width:0;return n.filter(s=>typeof s.width==\"number\"?s.width<=o:!0)}var Hn=class{constructor(){this._currentRequests={}}add(e){let{id:t,requestTimestamp:r,content:i}=e;this._currentRequests[t]={requestTimestamp:r,progress:[],content:i}}addProgress(e){let t=this._currentRequests[e.id];if(R(t)){if(b.CURRENT_ENV===b.DEV)throw new Error(\"ABR: progress for a request not added\");c.warn(\"ABR: progress for a request not added\");return}t.progress.push(e)}remove(e){if(R(this._currentRequests[e])){if(b.CURRENT_ENV===b.DEV)throw new Error(\"ABR: can't remove unknown request\");c.warn(\"ABR: can't remove unknown request\")}delete this._currentRequests[e]}getRequests(){return ar(this._currentRequests).filter(e=>!R(e)).sort((e,t)=>e.content.segment.time-t.content.segment.time)}};function zr(n,e){let t=ne(n,r=>r.bitrate>e);return t===-1?n[n.length-1]:t===0?n[0]:n[t-1]}var Ds=new G(void 0);Ds.finish();var Ns=new G(1/0);Ns.finish();function va(n){let e={},{initialBitrates:t,throttlers:r,lowLatencyMode:i}=n;return function(s,u,l,d,f){var h,y,E;let{type:m}=s.adaptation,p=a(m),g=(h=t[m])!=null?h:0,I={limitResolution:(y=r.limitResolution[m])!=null?y:Ds,throttleBitrate:(E=r.throttleBitrate[m])!=null?E:Ns};return jl({bandwidthEstimator:p,context:s,currentRepresentation:u,filters:I,initialBitrate:g,playbackObserver:d,representations:l,lowLatencyMode:i},f)};function a(o){let s=e[o];if(R(s)){c.debug(\"ABR: Creating new BandwidthEstimator for \",o);let u=new qn;return e[o]=u,u}return s}}function jl({bandwidthEstimator:n,context:e,currentRepresentation:t,filters:r,initialBitrate:i,lowLatencyMode:a,playbackObserver:o,representations:s},u){let l=new Ln,d=new zn(i!=null?i:0,a),f=new Hn,m=N,p={metrics:E,requestBegin:v,requestProgress:T,requestEnd:C,addedSegment(P){m(P)}},g=new W;g.linkToSignal(u);let I=h(s.getValue(),g.signal);return s.onUpdate(y,{clearSignal:u}),{estimates:I,callbacks:p};function h(P,M){if(P.length<=1)return new G({bitrate:void 0,representation:P[0],urgent:!0,knownStableBitrate:void 0});let _=!1,A=P.sort((q,J)=>q.bitrate-J.bitrate),x=new Fn(A.map(q=>q.bitrate)),k=new Wn,D=new Vn(l,k),w=o.getReference().getValue(),O=new G(z());return o.listen(q=>{w=q,B()},{includeLastObservation:!1,clearSignal:M}),m=function(q){if(w===null)return;let{position:J,speed:$}=w,V=q.buffered,Y=Ar(V,J.getWanted()),{representation:X}=q.content,me=l.getEstimate(X),ce=X.bitrate,de={bufferGap:Y,currentBitrate:ce,currentScore:me,speed:$};x.onAddedSegment(de),B()},M.register(()=>{m=N}),r.throttleBitrate.onUpdate(B,{clearSignal:M}),r.limitResolution.onUpdate(B,{clearSignal:M}),O;function B(){O.setValue(z())}function z(){let{bufferGap:q,position:J,maximumPosition:$}=w,V=r.limitResolution.getValue(),Y=r.throttleBitrate.getValue(),X=t.getValue(),me=Yl(A,V,Y),ce=f.getRequests(),{bandwidthEstimate:de,bitrateChosen:Ie}=d.getBandwidthEstimate(w,n,X,ce,k.bandwidth),Jn=l.getLastStableRepresentation(),pe=Jn===null?void 0:Jn.bitrate/(w.speed>0?w.speed:1),{ABR_ENTER_BUFFER_BASED_ALGO:be,ABR_EXIT_BUFFER_BASED_ALGO:Kt}=U.getCurrent();_&&q<=Kt?_=!1:!_&&isFinite(q)&&q>=be&&(_=!0);let He=zr(me,Ie),xe=x.getLastEstimate(),xt=He.bitrate,at=null;_&&xe!==void 0&&xe>xt&&(at=zr(me,xe),xt=at.bitrate);let ot=null;return a&&X!==null&&e.manifest.isDynamic&&$-J.getWanted()<40&&(ot=D.getGuess(A,w,X,xt,ce)),ot!==null&&ot.bitrate>xt?(c.debug(\"ABR: Choosing representation with guess-based estimation.\",ot.bitrate,ot.id),k.update(ot,de,2),{bitrate:de,representation:ot,urgent:X===null||ot.bitrate<X.bitrate,knownStableBitrate:pe}):at!==null?(c.debug(\"ABR: Choosing representation with buffer-based estimation.\",at.bitrate,at.id),k.update(at,de,0),{bitrate:de,representation:at,urgent:d.isUrgent(at.bitrate,X,ce,w),knownStableBitrate:pe}):(c.debug(\"ABR: Choosing representation with bandwidth estimation.\",He.bitrate,He.id),k.update(He,de,1),{bitrate:de,representation:He,urgent:d.isUrgent(He.bitrate,X,ce,w),knownStableBitrate:pe})}}function y(){let P=s.getValue();g.cancel(),g=new W,g.linkToSignal(u),h(P,g.signal).onUpdate(function(A){I.setValue(A)},{clearSignal:g.signal,emitCurrentValue:!0})}function E(P){let{requestDuration:M,segmentDuration:_,size:A,content:x}=P;if(n.addSample(M,A),!x.segment.isInit){let{segment:k,representation:D}=x;if(_===void 0&&!k.complete)return;let w=_!=null?_:k.duration;l.addSample(D,M/1e3,w)}}function v(P){f.add(P)}function T(P){f.addProgress(P)}function C(P){f.remove(P.id)}}function Yl(n,e,t){let r=n;return t!==void 0&&t<1/0&&(r=Ra(r,t)),e!==void 0&&(r=Pa(r,e)),r}var Bs=va;function it(n){return n instanceof re?new Ke(\"PIPELINE_LOAD_ERROR\",n):ge(n,{defaultCode:\"PIPELINE_LOAD_ERROR\",defaultReason:\"Unknown error when fetching the Manifest\"})}function Ca(n){let e=(Math.random()*2-1)*.3;return n*(e+1)}function Ql(n){return n instanceof re?n.type===bt.ERROR_HTTP_CODE?n.status>=500||n.status===404||n.status===415||n.status===412:n.type===bt.TIMEOUT||n.type===bt.ERROR_EVENT:n instanceof Ge?typeof n.canRetry==\"boolean\"?n.canRetry:n.xhr!==void 0?n.xhr.status>=500||n.xhr.status===404||n.xhr.status===415||n.xhr.status===412:!1:Mt(n)&&n.code===\"INTEGRITY_ERROR\"}async function Aa(n,e,t,r,i){if(i.cancellationError!==null)return Promise.reject(i.cancellationError);let{baseDelay:a,maxDelay:o,maxRetry:s,onRetry:u}=r;n!==null&&n.length===0&&c.warn(\"Fetchers: no CDN given to `scheduleRequestWithCdns`.\");let l=new Map,d=f();if(d===void 0)throw new Error(\"No CDN to request\");return m(d);function f(){if(n===null){let h=l.get(null);return h!==void 0&&h.isBlacklisted?void 0:null}else{if(e===null)return I(n);{let h=e.getCdnPreferenceForResource(n);return I(h)}}}async function m(h){try{return await t(h,i)}catch(y){if(W.isCancellationError(y))throw y;h!==null&&e!==null&&e.downgradeCdn(h);let E=l.get(h);if(E===void 0?(E={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},l.set(h,E)):E.errorCounter++,!Ql(y))return E.blockedUntil=void 0,E.isBlacklisted=!0,p(y);if(E.errorCounter>s)E.blockedUntil=void 0,E.isBlacklisted=!0;else{let v=E.errorCounter,T=Math.min(a*Math.pow(2,v-1),o),C=Ca(T);E.blockedUntil=L()+C}return p(y)}}async function p(h){let y=f();if(i.isCancelled())throw i.cancellationError;if(y===void 0)throw h;if(u(h),i.isCancelled())throw i.cancellationError;return g(y,h)}function g(h,y){let E=l.get(h);if(E===void 0||E.blockedUntil===void 0)return m(h);let v=L(),T=E.blockedUntil-v;if(T<=0)return m(h);let C=new W,P=C.linkToSignal(i);return new Promise((M,_)=>{e==null||e.addEventListener(\"priorityChange\",()=>{let k=f();if(i.isCancelled())throw i.cancellationError;if(k===void 0)return x(y);k!==h&&(C.cancel(),g(k,y).then(A,x))},C.signal),kn(T,C.signal).then(()=>m(h).then(A,x),N);function A(k){P(),M(k)}function x(k){P(),_(k)}})}function I(h){var E;if(l.size===0)return h[0];let y=L();return(E=h.filter(v=>{var T;return((T=l.get(v))==null?void 0:T.isBlacklisted)!==!0}).reduce((v,T)=>{var P;let C=(P=l.get(T))==null?void 0:P.blockedUntil;return C!==void 0&&C<=y&&(C=void 0),v===void 0?[T,C]:v[1]===void 0?v:C===void 0?[T,void 0]:C<v[1]?[T,C]:v},void 0))==null?void 0:E[0]}}function ka(n,e,t){return Aa(null,null,n,e,t)}var Gn=class extends oe{constructor(e,t,r){super(),this.scheduleManualRefresh=N,this._manifestUrls=e,this._pipelines=t.manifest,this._settings=r,this._canceller=new W,this._isStarted=!1,this._isRefreshPending=!1,this._consecutiveUnsafeMode=0,this._prioritizedContentUrl=null}dispose(){this._canceller.cancel(),this.removeEventListener()}start(){if(this._isStarted)return;this._isStarted=!0;let e,t=this._settings.initialManifest;t instanceof wt?e=Promise.resolve({manifest:t}):t!==void 0?e=this.parse(t,{previousManifest:null,unsafeMode:!1},void 0):e=this._fetchManifest(void 0).then(r=>r.parse({previousManifest:null,unsafeMode:!1})),e.then(r=>{this.trigger(\"manifestReady\",r.manifest),this._canceller.isUsed()||this._recursivelyRefreshManifest(r.manifest,r)}).catch(r=>this._onFatalError(r))}updateContentUrls(e,t){var r;this._prioritizedContentUrl=(r=e==null?void 0:e[0])!=null?r:void 0,t&&this.scheduleManualRefresh({enablePartialRefresh:!1,delay:0,canUseUnsafeMode:!1})}async _fetchManifest(e){var u;let t=this._canceller.signal,r=this._settings,i=this._pipelines,a=e!=null?e:(u=this._manifestUrls)==null?void 0:u[0],o=this._getBackoffSetting(l=>{this.trigger(\"warning\",it(l))});try{let l=await s(a);return{parse:d=>this._parseLoadedManifest(l,d,a)}}catch(l){throw it(l)}function s(l){let{loadManifest:d}=i,f=r.requestTimeout===void 0?U.getCurrent().DEFAULT_REQUEST_TIMEOUT:r.requestTimeout,m=r.connectionTimeout===void 0?U.getCurrent().DEFAULT_CONNECTION_TIMEOUT:r.connectionTimeout;return f<0&&(f=void 0),m<0&&(m=void 0),ka(()=>d(l,{timeout:f,connectionTimeout:m},t),o,t)}}parse(e,t,r){return this._parseLoadedManifest({responseData:e,size:void 0,requestDuration:void 0},t,r)}async _parseLoadedManifest(e,t,r){var I;let i=L(),a=this._canceller.signal,o=this.trigger.bind(this),{sendingTime:s,receivedTime:u}=e,l=this._getBackoffSetting(h=>{this.trigger(\"warning\",it(h))}),d=r!=null?r:(I=this._manifestUrls)==null?void 0:I[0],f={externalClockOffset:t.externalClockOffset,unsafeMode:t.unsafeMode,previousManifest:t.previousManifest,originalUrl:d};try{let h=this._pipelines.parseManifest(e,f,p,a,m);if($l(h)){let{manifest:y,warnings:E}=await h;return g(y,E)}else return g(h.manifest,h.warnings)}catch(h){throw ge(h,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"})}async function m(h){try{return await ka(h,l,a)}catch(y){throw it(y)}}function p(h){for(let y of h){if(a.isCancelled())return;let E=ge(y,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"});o(\"warning\",E)}}function g(h,y){p(y);let E=L()-i;return c.info(`MF: Manifest parsed in ${E}ms`),{manifest:h,sendingTime:s,receivedTime:u,parsingTime:E}}}_getBackoffSetting(e){let{DEFAULT_MAX_MANIFEST_REQUEST_RETRY:t,INITIAL_BACKOFF_DELAY_BASE:r,MAX_BACKOFF_DELAY_BASE:i}=U.getCurrent(),{lowLatencyMode:a,maxRetry:o}=this._settings,s=a?r.LOW_LATENCY:r.REGULAR,u=a?i.LOW_LATENCY:i.REGULAR,l=o!=null?o:t;return{onRetry:e,baseDelay:s,maxDelay:u,maxRetry:l}}_recursivelyRefreshManifest(e,{sendingTime:t,parsingTime:r,updatingTime:i}){let{MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:a,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:o}=U.getCurrent(),s=r!==void 0?r+(i!=null?i:0):void 0,u=!1;this._consecutiveUnsafeMode>0?u=this._consecutiveUnsafeMode<a:s!==void 0&&(u=s>=o);let l=t===void 0?0:L()-t,d=Math.max(this._settings.minimumManifestUpdateInterval-l,0),f=new W;if(f.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=m=>{let{enablePartialRefresh:p,delay:g,canUseUnsafeMode:I}=m,h=I&&u,y=t===void 0?0:L()-t,E=Math.max(this._settings.minimumManifestUpdateInterval-y,0),v=setTimeout(()=>{f.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:p,unsafeMode:h})},Math.max((g!=null?g:0)-y,E));f.signal.register(()=>{clearTimeout(v)})},e.expired!==null){let m=setTimeout(()=>{var p;(p=e.expired)==null||p.then(()=>{f.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:u})},N)},d);f.signal.register(()=>{clearTimeout(m)})}if(e.lifetime!==void 0&&e.lifetime>=0){let m=e.lifetime*1e3-l,p;s===void 0?p=m:e.lifetime<3&&s>=100?(p=Math.min(Math.max(3e3-l,Math.max(m,0)+s),m*6),c.info(\"MUS: Manifest update rythm is too frequent. Postponing next request.\",m,p)):s>=e.lifetime*1e3/10?(p=Math.min(Math.max(m,0)+s,m*6),c.info(\"MUS: Manifest took too long to parse. Postponing next request\",p,p)):p=m;let g=setTimeout(()=>{f.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:u})},Math.max(p,d));f.signal.register(()=>{clearTimeout(g)})}}_triggerNextManifestRefresh(e,{enablePartialRefresh:t,unsafeMode:r}){let i=e.updateUrl,a,o;this._prioritizedContentUrl!==null?(a=!0,o=this._prioritizedContentUrl,this._prioritizedContentUrl=null):(a=!t||i===void 0,o=a?e.getUrls()[0]:i);let s=e.clockOffset;r?(this._consecutiveUnsafeMode+=1,c.info('Init: Refreshing the Manifest in \"unsafeMode\" for the '+String(this._consecutiveUnsafeMode)+\" consecutive time.\")):this._consecutiveUnsafeMode>0&&(c.info('Init: Not parsing the Manifest in \"unsafeMode\" anymore after '+String(this._consecutiveUnsafeMode)+\" consecutive times.\"),this._consecutiveUnsafeMode=0),!this._isRefreshPending&&(this._isRefreshPending=!0,this._fetchManifest(o).then(u=>u.parse({externalClockOffset:s,previousManifest:e,unsafeMode:r})).then(u=>{this._isRefreshPending=!1;let{manifest:l,sendingTime:d,parsingTime:f}=u,m=L();if(a)e.replace(l);else try{e.update(l)}catch(g){let I=g instanceof Error?g.message:\"unknown error\";c.warn(`MUS: Attempt to update Manifest failed: ${I}`,\"Re-downloading the Manifest fully\");let{FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:h}=U.getCurrent(),y=d===void 0?0:L()-d,E=Math.max(this._settings.minimumManifestUpdateInterval-y,0),v=N,T=setTimeout(()=>{v(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})},Math.max(h-y,E));v=this._canceller.signal.register(()=>{clearTimeout(T)});return}let p=L()-m;this._recursivelyRefreshManifest(e,{sendingTime:d,parsingTime:f,updatingTime:p})}).catch(u=>{this._isRefreshPending=!1,this._onFatalError(u)}))}_onFatalError(e){this._canceller.isUsed()||(this.trigger(\"error\",e),this.dispose())}};function $l(n){return n instanceof Promise}var xa=Gn;function Ma(n,e){let t=new WeakMap;return{createRequest(r,i,a,o){let s=l=>e(r,a,l),u=n.create(s,i,a,o);return t.set(u,s),u},updatePriority(r,i){let a=t.get(r);if(a===void 0){c.warn(\"Fetchers: Cannot update the priority of a request: task not found.\");return}n.updatePriority(a,i)}}}var Kn=class extends oe{constructor(e){super(),this._downgradedCdnList={metadata:[],timeouts:[]},e.register(()=>{for(let t of this._downgradedCdnList.timeouts)clearTimeout(t);this._downgradedCdnList={metadata:[],timeouts:[]}})}getCdnPreferenceForResource(e){return e.length<=1?e:this._innerGetCdnPreferenceForResource(e)}downgradeCdn(e){let t=Us(this._downgradedCdnList.metadata,e);t>=0&&this._removeIndexFromDowngradeList(t);let{DEFAULT_CDN_DOWNGRADE_TIME:r}=U.getCurrent(),i=r;this._downgradedCdnList.metadata.push(e);let a=setTimeout(()=>{let o=Us(this._downgradedCdnList.metadata,e);o>=0&&this._removeIndexFromDowngradeList(o),this.trigger(\"priorityChange\",null)},i);this._downgradedCdnList.timeouts.push(a),this.trigger(\"priorityChange\",null)}_innerGetCdnPreferenceForResource(e){let[t,r]=e.reduce((i,a)=>(this._downgradedCdnList.metadata.some(o=>o.id===a.id&&o.baseUrl===a.baseUrl)?i[1].push(a):i[0].push(a),i),[[],[]]);return t.concat(r)}_removeIndexFromDowngradeList(e){this._downgradedCdnList.metadata.splice(e,1);let t=this._downgradedCdnList.timeouts.splice(e,1);clearTimeout(t[0])}};function Us(n,e){return n.length===0?-1:e.id!==void 0?ne(n,t=>t.id===e.id):ne(n,t=>t.baseUrl===e.baseUrl)}var Oa=class{constructor(){this._cache=new WeakMap}add({representation:e,segment:t},r){t.isInit&&this._cache.set(e,r)}get({representation:e,segment:t}){if(t.isInit){let r=this._cache.get(e);if(r!==void 0)return r}return null}},Ls=Oa;var Xl=Ae();function wa(n,e,t,r,i){let a;i.connectionTimeout===void 0||i.connectionTimeout<0?a=void 0:a=i.connectionTimeout;let o={timeout:i.requestTimeout<0?void 0:i.requestTimeout,connectionTimeout:a},s=se([\"audio\",\"video\"],n)?new Ls:void 0,{loadSegment:u,parseSegment:l}=e;return async function(f,m,p){var q,J,$;let{segment:g,adaptation:I,representation:h,manifest:y,period:E}=f,v=St(f),T=Xl(),C,P=[],M=0,_=!1,A={segment:g,type:I.type,language:I.language,isLive:y.isLive,periodStart:E.start,periodEnd:E.end,mimeType:h.mimeType,codecs:h.codecs[0],manifestPublishTime:y.publishTime},x={onProgress(V){var Y;C===void 0&&V.totalSize!==void 0&&V.size<V.totalSize&&((Y=r.onProgress)==null||Y.call(r,{duration:V.duration,size:V.size,totalSize:V.totalSize,timestamp:L(),id:T}))},onNewChunk(V){m.onChunk(O(V,!0))}},k=s!==void 0?s.get(f):null;if(k!==null)return c.debug(\"SF: Found wanted segment in cache\",v),m.onChunk(O(k,!1)),Promise.resolve();c.debug(\"SF: Beginning request\",v),(q=r.onRequestBegin)==null||q.call(r,{requestTimestamp:L(),id:T,content:f}),p.register(D);try{let V=await Aa(f.representation.cdnMetadata,t,w,H({onRetry:B},i),p);if(V.resultType===\"segment-loaded\"){let Y=V.resultData.responseData;s!==void 0&&s.add(f,V.resultData.responseData),m.onChunk(O(Y,!1))}else V.resultType===\"segment-created\"&&m.onChunk(O(V.resultData,!1));c.debug(\"SF: Segment request ended with success\",v),m.onAllChunksReceived(),V.resultType!==\"segment-created\"?(C=V.resultData,z()):C=null,p.isCancelled()||(J=r.onRequestEnd)==null||J.call(r,{id:T}),p.deregister(D)}catch(V){throw p.deregister(D),C=null,V instanceof ie?(c.debug(\"SF: Segment request aborted\",v),V):(c.debug(\"SF: Segment request failed\",v),($=r.onRequestEnd)==null||$.call(r,{id:T}),it(V))}function D(){var V;C===void 0&&(c.debug(\"SF: Segment request cancelled\",v),C=null,(V=r.onRequestEnd)==null||V.call(r,{id:T}))}function w(V){return u(V,A,o,p,x)}function O(V,Y){P.push(!1);let X=P.length-1;return function(ce){let de={data:V,isChunked:Y};try{let Ie=l(de,A,ce);return P[X]||(M=M!==void 0&&Ie.segmentType===\"media\"&&Ie.chunkInfos!==null&&Ie.chunkInfos.duration!==void 0?M+Ie.chunkInfos.duration:void 0,P[X]=!0,z()),Ie}catch(Ie){throw ge(Ie,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}}function B(V){m.onRetry(it(V))}function z(){var V;_||!R(C)&&C.size!==void 0&&C.requestDuration!==void 0&&P.length>0&&P.every(Y=>Y)&&(_=!0,(V=r.onMetrics)==null||V.call(r,{size:C.size,requestDuration:C.requestDuration,content:f,segmentDuration:M}))}}}function Fs({maxRetry:n,lowLatencyMode:e,requestTimeout:t,connectionTimeout:r}){let{DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:i,DEFAULT_REQUEST_TIMEOUT:a,DEFAULT_CONNECTION_TIMEOUT:o,INITIAL_BACKOFF_DELAY_BASE:s,MAX_BACKOFF_DELAY_BASE:u}=U.getCurrent();return{maxRetry:n!=null?n:i,baseDelay:e?s.LOW_LATENCY:s.REGULAR,maxDelay:e?u.LOW_LATENCY:u.REGULAR,requestTimeout:t===void 0?a:t,connectionTimeout:r===void 0?o:r}}var Yn=class{constructor({prioritySteps:e}){if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=e,this._prioritySteps.high>=this._prioritySteps.low)throw new Error(\"TP: the max high level priority should be given a lowerpriority number than the min low priority.\")}create(e,t,r,i){let a;return kt(i,(o,s)=>(a={hasEnded:!1,priority:t,trigger:()=>{if(a.hasEnded)return;let l=()=>{p(),this._endTask(a)},d=g=>{r.beforeEnded(),l(),o(g)},f=g=>{l(),s(g)},m=new W,p=m.linkToSignal(i);a.interrupter=m,m.signal.register(()=>{a.interrupter=null,i.isCancelled()||r.beforeInterrupted()}),this._minPendingPriority=this._minPendingPriority===null?a.priority:Math.min(this._minPendingPriority,a.priority),this._pendingTasks.push(a),a.taskFn(m.signal).then(d).catch(g=>{!i.isCancelled()&&m.isUsed()&&g instanceof ie||f(g)})},taskFn:e,interrupter:null},this._canBeStartedNow(a)?(a.trigger(),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()):this._waitingQueue.push(a),()=>this._endTask(a)))}_endTask(e){e.hasEnded=!0;let t=jn(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{let r=jn(e.taskFn,this._pendingTasks);if(r<0)return;this._pendingTasks.splice(r,1),this._pendingTasks.length>0?this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min(...this._pendingTasks.map(i=>i.priority))):this._minPendingPriority=null,this._loopThroughWaitingQueue()}}updatePriority(e,t){let r=jn(e,this._waitingQueue);if(r>=0){let s=this._waitingQueue[r];if(s.priority===t||(s.priority=t,!this._canBeStartedNow(s)))return;this._findAndRunWaitingQueueTask(r),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks();return}let i=jn(e,this._pendingTasks);if(i<0){c.warn(\"TP: request to update the priority of a non-existent task\");return}let a=this._pendingTasks[i];if(a.priority===t)return;let o=a.priority;a.priority=t,this._minPendingPriority===null||t<this._minPendingPriority?this._minPendingPriority=t:this._minPendingPriority===o&&(this._pendingTasks.length===1?this._minPendingPriority=t:this._minPendingPriority=Math.min(...this._pendingTasks.map(s=>s.priority)),this._loopThroughWaitingQueue()),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()}_loopThroughWaitingQueue(){let e=this._waitingQueue.reduce((t,r)=>t===null||t>r.priority?r.priority:t,null);if(!(e===null||this._minPendingPriority!==null&&this._minPendingPriority<e))for(let t=0;t<this._waitingQueue.length;t++){let r=this._minPendingPriority===null?e:Math.min(this._minPendingPriority,e);this._waitingQueue[t].priority<=r&&(this._findAndRunWaitingQueueTask(t),t--)}}_interruptCancellableTasks(){for(let e=0;e<this._pendingTasks.length;e++){let t=this._pendingTasks[e];if(t.priority>=this._prioritySteps.low)return this._interruptPendingTask(t),this._interruptCancellableTasks()}}_findAndRunWaitingQueueTask(e){return e>=this._waitingQueue.length||e<0?(c.warn(\"TP : Tried to start a non existing task\"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)}_interruptPendingTask(e){var r;let t=jn(e.taskFn,this._pendingTasks);if(t<0){c.warn(\"TP: Interrupting a non-existent pending task. Aborting...\");return}this._pendingTasks.splice(t,1),this._waitingQueue.push(e),this._pendingTasks.length===0?this._minPendingPriority=null:this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min(...this._pendingTasks.map(i=>i.priority))),(r=e.interrupter)==null||r.cancel()}_canBeStartedNow(e){return this._minPendingPriority===null||e.priority<=this._minPendingPriority}_isRunningHighPriorityTasks(){return this._minPendingPriority!==null&&this._minPendingPriority<=this._prioritySteps.high}};function jn(n,e){return ne(e,t=>t.taskFn===n)}var Qn=class{constructor(e,t,r){let i=new Kn(r),{MIN_CANCELABLE_PRIORITY:a,MAX_HIGH_PRIORITY_LEVEL:o}=U.getCurrent();this._transport=e,this._prioritizer=new Yn({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=i,this._backoffOptions=t}createSegmentFetcher(e,t){let r=Fs(this._backoffOptions),i=this._transport[e],a=wa(e,i,this._cdnPrioritizer,t,r);return Ma(this._prioritizer,a)}};var Da=Qn;var $n=class{constructor(e){this._segmentSinksStore=e,this._currentFreezeTimestamp=null}needToReload(e){let{readyState:t,rebuffering:r,freezing:i}=e;if((e.bufferGap!==void 0&&isFinite(e.bufferGap)?e.bufferGap:0)<6||r===null&&i===null||t>1)return this._currentFreezeTimestamp=null,!1;let o=L();this._currentFreezeTimestamp===null&&(this._currentFreezeTimestamp=o);let s=r!==null&&o-r.timestamp>4e3,u=i!==null&&o-i.timestamp>4e3;if((s||u)&&L()-this._currentFreezeTimestamp>4e3){let l=this._segmentSinksStore.getStatus(\"audio\"),d=this._segmentSinksStore.getStatus(\"video\"),f=!0,m=!0;for(let p of[l,d])if(p.type===\"initialized\")for(let g of p.value.getLastKnownInventory()){let{representation:I}=g.infos;if(I.decipherable===!1)return c.warn(\"Init: we have undecipherable segments left in the buffer, reloading\"),this._currentFreezeTimestamp=null,!0;I.contentProtections!==void 0&&(m=!1,I.decipherable!==!0&&(f=!1))}if(!m&&f)return c.warn(\"Init: we are frozen despite only having decipherable segments left in the buffer, reloading\"),this._currentFreezeTimestamp=null,!0}return!1}};var{DEFAULT_WANTED_BUFFER_AHEAD:Zl,DEFAULT_MAX_VIDEO_BUFFER_SIZE:Jl,DEFAULT_MAX_BUFFER_AHEAD:ef,DEFAULT_MAX_BUFFER_BEHIND:tf}=U.getCurrent(),Na=new G(Zl),Ba=new G(Jl),Ua=new G(ef),La=new G(tf),Wr=new G({height:void 0,width:void 0,pixelRatio:1}),Vr=new G(1/0);function Q(n,e){c.debug(\"<--- Sending to Main:\",n.type),e===void 0?postMessage(n):postMessage(n,e)}function we(n){return ge(n,{defaultCode:\"NONE\",defaultReason:\"An unknown error stopped content playback.\"}).serialize()}var Xn=class{constructor(){this._refs=new Map}reset(){var e,t,r,i,a,o,s,u,l,d,f,m;for(let p of this._refs.keys())(t=(e=this._refs.get(p))==null?void 0:e.audio)==null||t.trackReference.finish(),(i=(r=this._refs.get(p))==null?void 0:r.audio)==null||i.representations.finish(),(o=(a=this._refs.get(p))==null?void 0:a.video)==null||o.trackReference.finish(),(u=(s=this._refs.get(p))==null?void 0:s.video)==null||u.representations.finish(),(d=(l=this._refs.get(p))==null?void 0:l.text)==null||d.trackReference.finish(),(m=(f=this._refs.get(p))==null?void 0:f.text)==null||m.representations.finish();this._refs=new Map}addTrackSetter(e,t,r){var s,u;let i=this._refs.get(e);i===void 0&&(i={},this._refs.set(e,i)),i[t]!==void 0&&(c.warn(\"WP: Track for periodId already declared\",e,t),(s=i[t])==null||s.trackReference.finish(),(u=i[t])==null||u.representations.finish());let a=r.getValue(),o;R(a)?o=new G({representationIds:[],switchingMode:\"lazy\"}):(o=new G(a.representations.getValue()),r.setValue(H({},a,{representations:o}))),i[t]={trackReference:r,representations:o}}setTrack(e,t,r){var a;let i=(a=this._refs.get(e))==null?void 0:a[t];return i===void 0?(c.debug(\"WP: Setting track for inexistent periodId\",e,t),!1):(R(r)?(i.representations=new G({representationIds:[],switchingMode:\"lazy\"}),i.trackReference.setValue(r)):(i.representations=new G(r.initialRepresentations),i.trackReference.setValue({adaptationId:r.adaptationId,switchingMode:r.switchingMode,representations:i.representations,relativeResumingPosition:r.relativeResumingPosition})),!0)}updateRepresentations(e,t,r,i){var s;let a=(s=this._refs.get(e))==null?void 0:s[r];if(a===void 0)return c.debug(\"WP: Setting track for inexistent periodId\",e,r),!1;let o=a.trackReference.getValue();return R(o)||o.adaptationId!==t?(c.debug(\"WP: Desynchronized Adaptation id\",o==null?void 0:o.adaptationId,t),!1):(a.representations.setValue(i),!0)}removeTrackSetter(e,t){let r=this._refs.get(e),i=r==null?void 0:r[t];return r===void 0||i===void 0?(c.debug(\"WP: Removing track setter for inexistent periodId\",e,t),!1):(i.trackReference.finish(),i.representations.finish(),delete r[t],Object.keys(r).length===0&&this._refs.delete(e),!0)}};var Zn=class{constructor(e,t){this._contentId=e,this._messageSender=t,this._queues={pushTextData:[],remove:[]}}pushTextData(e){return new Promise((t,r)=>{this._messageSender({type:\"push-text-data\",contentId:this._contentId,value:e}),this._queues.pushTextData.push({resolve:t,reject:r})})}remove(e,t){return new Promise((r,i)=>{this._messageSender({type:\"remove-text-data\",contentId:this._contentId,value:{start:e,end:t}}),this._queues.remove.push({resolve:r,reject:i})})}reset(){this._messageSender({type:\"reset-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue()}stop(){this._messageSender({type:\"stop-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue()}_resetCurrentQueue(){let e=new ie;this._queues.pushTextData.forEach(t=>{t.reject(e)}),this._queues.remove.forEach(t=>{t.reject(e)})}onPushedTrackSuccess(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"WMS: pushTextData success for inexistant operation\");return}t.resolve(e)}onPushedTrackError(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"WMS: pushTextData error for inexistant operation\");return}t.reject(e)}onRemoveSuccess(e){let t=this._queues.remove.shift();if(t===void 0){c.error(\"WMS: remove success for inexistant operation\");return}t.resolve(e)}onRemoveError(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"WMS: pushTextData error for inexistant operation\");return}t.reject(e)}};var zs=Ae(),Gt=class{constructor({hasMseInWorker:e,hasVideo:t}){this._currentContent=null,this._currentMediaSourceCanceller=new W,this._hasVideo=t,this._hasMseInWorker=e;let r=new W;this._contentCanceller=r}initializeNewContent(e){return new Promise((t,r)=>{var M,_;this.disposeCurrentContent();let i=this._contentCanceller,a=new W;this._currentMediaSourceCanceller=a,a.linkToSignal(i.signal);let{contentId:o,url:s,hasText:u,transportOptions:l}=e,d=null;he(ae.transports.dash!==void 0,\"Multithread RxPlayer should have access to the DASH feature\");let f=typeof l.representationFilter==\"string\"?ro(l.representationFilter):void 0,m=ae.transports.dash(Le(_e({},l),{representationFilter:f})),p=new xa(s===void 0?void 0:[s],m,e.manifestRetryOptions),g=Bs({initialBitrates:{audio:(M=e.initialAudioBitrate)!=null?M:0,video:(_=e.initialVideoBitrate)!=null?_:0},lowLatencyMode:l.lowLatencyMode,throttlers:{limitResolution:{video:Wr},throttleBitrate:{video:Vr}}}),I=a.signal.register(A=>{r(A)}),h=new Da(m,e.segmentRetryOptions,i.signal),y=new Xn,[E,v,T]=Ws(o,{hasMseInWorker:this._hasMseInWorker,hasVideo:this._hasVideo,hasText:u},a.signal),C=new $n(v);this._currentContent={contentId:o,decipherabilityFreezeDetector:C,mediaSource:E,manifest:null,manifestFetcher:p,representationEstimator:g,segmentSinksStore:v,segmentFetcherCreator:h,workerTextSender:T,trackChoiceSetter:y},E.addEventListener(\"mediaSourceOpen\",function(){P()},a.signal),i.signal.register(()=>{p.dispose()}),p.addEventListener(\"warning\",A=>{Q({type:\"warning\",contentId:o,value:we(A)})},i.signal),p.addEventListener(\"manifestReady\",A=>{if(d!==null){c.warn(\"WP: Multiple `manifestReady` events, ignoring\");return}d=A,this._currentContent!==null&&(this._currentContent.manifest=d),P()},a.signal),p.addEventListener(\"error\",A=>{r(A)},i.signal),p.start();function P(){if(d===null||E.readyState===\"closed\"||a.isUsed())return;let A=d.getMetadataSnapshot();d.addEventListener(\"manifestUpdate\",x=>{if(d===null)return;let k=H(d.getMetadataSnapshot(),{periods:[]});Q({type:\"manifest-update\",contentId:o,value:{manifest:k,updates:x}})},i.signal),I(),t(A)}})}getCurrentContent(){return this._currentContent}scheduleManifestRefresh(e){var t;(t=this._currentContent)==null||t.manifestFetcher.scheduleManualRefresh(e)}reloadMediaSource(e){if(this._currentMediaSourceCanceller.cancel(),this._currentContent===null)return Promise.reject(new Error(\"CP: No content anymore\"));this._currentContent.trackChoiceSetter.reset(),this._currentMediaSourceCanceller=new W,Q({type:\"reloading-media-source\",contentId:this._currentContent.contentId,value:e},[]);let[t,r,i]=Ws(this._currentContent.contentId,{hasMseInWorker:this._hasMseInWorker,hasVideo:this._hasVideo,hasText:this._currentContent.workerTextSender!==null},this._currentMediaSourceCanceller.signal);return this._currentContent.mediaSource=t,this._currentContent.segmentSinksStore=r,this._currentContent.workerTextSender=i,new Promise((a,o)=>{t.addEventListener(\"mediaSourceOpen\",function(){a()},this._currentMediaSourceCanceller.signal),t.addEventListener(\"mediaSourceClose\",function(){o(new Error(\"MediaSource ReadyState changed to close during init.\"))},this._currentMediaSourceCanceller.signal),this._currentMediaSourceCanceller.signal.register(s=>{o(s)})})}disposeCurrentContent(){this._contentCanceller.cancel(),this._contentCanceller=new W}};function Ws(n,e,t){let r;if(e.hasMseInWorker){let s=new Bn(zs());r=s;let u,l=s.handle;if(l.type===\"handle\")u={type:\"handle\",value:l.value};else{let d=URL.createObjectURL(l.value);u={type:\"url\",value:d},t.register(()=>{URL.revokeObjectURL(d)})}Q({type:\"attach-media-source\",contentId:n,value:u,mediaSourceId:r.id},[l.value])}else r=new Un(zs(),n,Q);let i=e.hasText?new Zn(n,Q):null,{hasVideo:a}=e,o=new It(r,a,i);return t.register(()=>{o.disposeAll(),i==null||i.stop(),r.dispose()}),[r,o,i]}function Fa(){let n=!1,e=new Gt({hasMseInWorker:!1,hasVideo:!0}),t=null,r=new Wo;ae.dashParsers.wasm=r,ae.dashParsers.fastJs=Ao,ae.transports.dash=ts;let i=null;onmessage=function(a){var s,u,l;c.debug(\"Worker: received message\",a.data.type);let o=a.data;switch(o.type){case\"init\":he(!n),n=!0,qa(o.value),Vs(o.value.logLevel,o.value.sendBackLogs),o.value.dashWasmUrl!==void 0&&r.isCompatible()&&r.initialize({wasmUrl:o.value.dashWasmUrl}).catch(d=>{let f=d instanceof Error?d.toString():\"Unknown Error\";c.error(\"Worker: Could not initialize DASH_WASM parser\",f)}),(!o.value.hasVideo||o.value.hasMseInWorker)&&(e.disposeCurrentContent(),e=new Gt({hasMseInWorker:o.value.hasMseInWorker,hasVideo:o.value.hasVideo})),ae.codecSupportProber=o.value.hasMseInWorker?oo:so,Q({type:\"init-success\",value:null});break;case\"log-level-update\":Vs(o.value.logLevel,o.value.sendBackLogs);break;case\"prepare\":nf(e,o.value);break;case\"start\":{let d=e.getCurrentContent();if(o.contentId!==(d==null?void 0:d.contentId))return;t!==null&&(t.cancel(),t=null);let f=new W,m=new G(H(o.value.initialObservation,{position:new vt(...o.value.initialObservation.position)}));i=m,t=f,t.signal.register(()=>{m.finish()}),qs(o.value,e,m,f.signal);break}case\"observation\":{let d=e.getCurrentContent();if(o.contentId!==(d==null?void 0:d.contentId))return;let f=o.value,{buffered:m}=f,p=Ia(d.mediaSource,null);p.audio!==null&&(m.audio=p.audio),p.video!==null&&(m.video=p.video),i==null||i.setValue(H(f,{position:new vt(...o.value.position)}));break}case\"ref-update\":rf(o);break;case\"stop\":if(o.contentId!==((s=e.getCurrentContent())==null?void 0:s.contentId))return;e.disposeCurrentContent(),t!==null&&(t.cancel(),t=null);break;case\"sb-success\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;let{sourceBuffers:f}=d.mediaSource,m=K(f,p=>p.type===o.sourceBufferType);if(m===void 0){c.info(\"WP: Success for an unknown SourceBuffer\",o.sourceBufferType);return}if(m.onOperationSuccess===void 0){c.warn(\"WP: A SourceBufferInterface with MSE performed a cross-thread operation\",o.sourceBufferType);return}m.onOperationSuccess(o.operationId,o.value.buffered);break}case\"sb-error\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;let{sourceBuffers:f}=d.mediaSource,m=K(f,p=>p.type===o.sourceBufferType);if(m===void 0){c.info(\"WP: Error for an unknown SourceBuffer\",o.sourceBufferType);return}if(m.onOperationFailure===void 0){c.warn(\"WP: A SourceBufferInterface with MSE performed a cross-thread operation\",o.sourceBufferType);return}m.onOperationFailure(o.operationId,o.value);break}case\"media-source-ready-state-change\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;if(d.mediaSource.onMediaSourceReadyStateChanged===void 0){c.warn(\"WP: A MediaSourceInterface with MSE performed a cross-thread operation\");return}d.mediaSource.onMediaSourceReadyStateChanged(o.value);break}case\"decipherability-update\":{if(o.contentId!==((u=e.getCurrentContent())==null?void 0:u.contentId))return;let d=e.getCurrentContent();if(d===null||d.manifest===null)return;let f=o.value;d.manifest.updateRepresentationsDeciperability(m=>{for(let p of f)if(m.representation.uniqueId===p.representationUniqueId)return p.decipherable;return m.representation.decipherable});break}case\"codec-support-update\":{let d=e.getCurrentContent();if(d===null||d.manifest===null)return;if(typeof((l=ae.codecSupportProber)==null?void 0:l.updateCache)==\"function\")for(let{mimeType:f,codec:m,result:p}of o.value)ae.codecSupportProber.updateCache(f,m,p);try{let f=d.manifest.refreshCodecSupport(o.value);f!==null&&Q({type:\"warning\",contentId:d.contentId,value:we(f)})}catch(f){Q({type:\"error\",contentId:d.contentId,value:we(f)})}break}case\"urls-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.manifestFetcher.updateContentUrls(o.value.urls,o.value.refreshNow);break}case\"track-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.trackChoiceSetter.setTrack(o.value.periodId,o.value.bufferType,o.value.choice);break}case\"rep-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.trackChoiceSetter.updateRepresentations(o.value.periodId,o.value.adaptationId,o.value.bufferType,o.value.choice);break}case\"add-text-success\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Added text track but text track aren't enabled\");return}d.workerTextSender.onPushedTrackSuccess(o.value.ranges);break}case\"push-text-error\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Added text track but text track aren't enabled\");return}d.workerTextSender.onPushedTrackError(new Error(o.value.message));break}case\"remove-text-success\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Removed text track but text track aren't enabled\");return}d.workerTextSender.onRemoveSuccess(o.value.ranges);break}case\"remove-text-error\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Removed text track but text track aren't enabled\");return}d.workerTextSender.onRemoveError(new Error(o.value.message));break}default:ze(o)}}}function nf(n,e){n.initializeNewContent(e).then(t=>{Q({type:\"manifest-ready\",contentId:e.contentId,value:{manifest:t}})},t=>{Q({type:\"error\",contentId:e.contentId,value:we(t)})})}function rf(n){switch(n.value.name){case\"wantedBufferAhead\":Na.setValueIfChanged(n.value.newVal);break;case\"maxVideoBufferSize\":Ba.setValueIfChanged(n.value.newVal);break;case\"maxBufferBehind\":La.setValueIfChanged(n.value.newVal);break;case\"maxBufferAhead\":Ua.setValueIfChanged(n.value.newVal);break;case\"limitVideoResolution\":Wr.setValueIfChanged(n.value.newVal);break;case\"throttleVideoBitrate\":Vr.setValueIfChanged(n.value.newVal);break;default:ze(n.value)}}function qs(n,e,t,r){var M;let i=new W;i.linkToSignal(r);let a=new Map,o=e.getCurrentContent();if(o===null||o.manifest===null){let _=new Re(\"NONE\",\"Loading content when none is prepared\");Q({type:\"error\",contentId:void 0,value:we(_)});return}let{contentId:s,manifest:u,mediaSource:l,representationEstimator:d,segmentSinksStore:f,segmentFetcherCreator:m}=o,{drmSystemId:p,enableFastSwitching:g,initialTime:I,onCodecSwitch:h}=n;if(t.onUpdate(_=>{o.decipherabilityFreezeDetector.needToReload(_)&&P({timeOffset:0,minimumPosition:0,maximumPosition:1/0}),[\"video\",\"audio\",\"text\"].forEach(A=>{var k;let x=f.getStatus(A);x.type===\"initialized\"&&x.value.synchronizeInventory((k=_.buffered[A])!=null?k:[])})}),((M=u.getPeriodForTime(I))!=null?M:u.getNextPeriod(I))===void 0){let _=new j(\"MEDIA_STARTING_TIME_NOT_FOUND\",\"Wanted starting time not found in the Manifest.\");Q({type:\"error\",contentId:s,value:we(_)});return}let E=new gn(t,s,Q,i.signal),v=ha(u,l,E,f,{onWarning:_=>Q({type:\"warning\",contentId:s,value:we(_)}),onPeriodChanged:_=>{Q({type:\"active-period-changed\",contentId:s,value:{periodId:_.id}})}},i.signal);Es({initialPeriod:u.periods[0],manifest:u},E,d,f,m,{wantedBufferAhead:Na,maxVideoBufferSize:Ba,maxBufferAhead:Ua,maxBufferBehind:La,drmSystemId:p,enableFastSwitching:g,onCodecSwitch:h},T(),i.signal);function T(){return{needsBufferFlush(_){Q({type:\"needs-buffer-flush\",contentId:s,value:_})},streamStatusUpdate(_){C(_),u.isLastPeriodKnown&&_.period.id===u.periods[u.periods.length-1].id&&(_.hasFinishedLoading||_.isEmptyStream?v.onLastSegmentFinishedLoading(_.bufferType):v.onLastSegmentLoadingResume(_.bufferType))},needsManifestRefresh(){e.scheduleManifestRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync(){let{OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:_}=U.getCurrent();e.scheduleManifestRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:_})},lockedStream(_){Q({type:\"locked-stream\",contentId:s,value:{periodId:_.period.id,bufferType:_.bufferType}})},adaptationChange(_){var A,x;v.onAdaptationChange(_.type,_.period,_.adaptation),!i.signal.isCancelled()&&Q({type:\"adaptation-changed\",contentId:s,value:{adaptationId:(x=(A=_.adaptation)==null?void 0:A.id)!=null?x:null,periodId:_.period.id,type:_.type}})},representationChange(_){var A,x;v.onRepresentationChange(_.type,_.period),!i.signal.isCancelled()&&Q({type:\"representation-changed\",contentId:s,value:{adaptationId:_.adaptation.id,representationId:(x=(A=_.representation)==null?void 0:A.id)!=null?x:null,periodId:_.period.id,type:_.type}})},inbandEvent(_){Q({type:\"inband-event\",contentId:s,value:_})},warning(_){Q({type:\"warning\",contentId:s,value:we(_)})},periodStreamReady(_){o!==null&&(o.trackChoiceSetter.addTrackSetter(_.period.id,_.type,_.adaptationRef),Q({type:\"period-stream-ready\",contentId:s,value:{periodId:_.period.id,bufferType:_.type}}))},periodStreamCleared(_){if(o===null)return;let A=a.get(_.period);A!==void 0&&(A.delete(_.type),A.size===0&&a.delete(_.period)),o.trackChoiceSetter.removeTrackSetter(_.period.id,_.type),Q({type:\"period-stream-cleared\",contentId:s,value:{periodId:_.period.id,bufferType:_.type}})},bitrateEstimateChange(_){Q({type:\"bitrate-estimate-change\",contentId:s,value:{bitrate:_.bitrate,bufferType:_.type}})},needsMediaSourceReload(_){P(_)},needsDecipherabilityFlush(){Q({type:\"needs-decipherability-flush\",contentId:s,value:null})},encryptionDataEncountered(_){for(let A of _){let x=A.content,k=_e({},x);k.manifest instanceof wt&&(k.manifest=k.manifest.getMetadataSnapshot()),k.period instanceof lt&&(k.period=k.period.getMetadataSnapshot()),k.adaptation instanceof ut&&(k.adaptation=k.adaptation.getMetadataSnapshot()),k.representation instanceof Zt&&(k.representation=k.representation.getMetadataSnapshot()),Q({type:\"encryption-data-encountered\",contentId:s,value:{keyIds:A.keyIds,values:A.values,content:k,type:A.type}})}},error(_){Q({type:\"error\",contentId:s,value:we(_)})}}}function C(_){let{imminentDiscontinuity:A}=_,x=a.get(_.period),k=x==null?void 0:x.get(_.bufferType);if(k!==void 0){if(k.discontinuity===null){if(A===null)return}else if(A!==null&&k.discontinuity.start===A.start&&k.discontinuity.end===A.end)return}x===void 0&&(x=new Map,a.set(_.period,x));let D={periodId:_.period.id,bufferType:_.bufferType,discontinuity:_.imminentDiscontinuity,position:_.position};x.set(_.bufferType,D),Q({type:\"discontinuity-update\",contentId:s,value:D})}function P(_){let x=t.getValue().position.getWanted();i!==null&&i.cancel(),e.reloadMediaSource(_).then(()=>{qs({initialTime:x,drmSystemId:n.drmSystemId,enableFastSwitching:n.enableFastSwitching,onCodecSwitch:n.onCodecSwitch},e,t,r)},k=>{Q({type:\"error\",contentId:s,value:we(k)})})}}function Vs(n,e){e?c.setLevel(n,(t,r)=>{let i=r.map(a=>a instanceof Error?we(a):a);postMessage({type:\"log\",value:{logLevel:t,logs:i}})}):c.setLevel(n)}var Hs=Fa;Hs();})();\n" + "})()"], { type: "application/javascript" });
|
|
4
|
+
var blob = new Blob(["(function(){" + "\"use strict\";(()=>{var Hs=Object.defineProperty,Gs=Object.defineProperties;var Ks=Object.getOwnPropertyDescriptors;var za=Object.getOwnPropertySymbols;var js=Object.prototype.hasOwnProperty,Ys=Object.prototype.propertyIsEnumerable;var Wa=(n,e,t)=>e in n?Hs(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,_e=(n,e)=>{for(var t in e||(e={}))js.call(e,t)&&Wa(n,t,e[t]);if(za)for(var t of za(e))Ys.call(e,t)&&Wa(n,t,e[t]);return n},Le=(n,e)=>Gs(n,Ks(e));var b={PRODUCTION:0,DEV:1,CURRENT_ENV:0};var $s={DEFAULT_REQUEST_TIMEOUT:3e4,DEFAULT_CONNECTION_TIMEOUT:15e3,DEFAULT_TEXT_TRACK_MODE:\"native\",DEFAULT_ENABLE_FAST_SWITCHING:!0,DELTA_POSITION_AFTER_RELOAD:{bitrateSwitch:-.1,trackSwitch:{audio:0,video:0,other:0}},DEFAULT_CODEC_SWITCHING_BEHAVIOR:\"continue\",DEFAULT_AUTO_PLAY:!1,DEFAULT_WANTED_BUFFER_AHEAD:30,DEFAULT_MAX_BUFFER_AHEAD:1/0,DEFAULT_MAX_BUFFER_BEHIND:1/0,DEFAULT_MAX_VIDEO_BUFFER_SIZE:1/0,MAXIMUM_MAX_BUFFER_AHEAD:{text:18e3},MINIMUM_MAX_BUFFER_AHEAD:{text:120},MAXIMUM_MAX_BUFFER_BEHIND:{text:18e3},DEFAULT_BASE_BANDWIDTH:0,INACTIVITY_DELAY:6e4,DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN:!1,DEFAULT_VIDEO_RESOLUTION_LIMIT:\"none\",DEFAULT_LIVE_GAP:{DEFAULT:10,LOW_LATENCY:3.5},BUFFER_DISCONTINUITY_THRESHOLD:.2,BITRATE_REBUFFERING_RATIO:1.5,DEFAULT_MAX_MANIFEST_REQUEST_RETRY:4,DEFAULT_CDN_DOWNGRADE_TIME:60,DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:4,INITIAL_BACKOFF_DELAY_BASE:{REGULAR:200,LOW_LATENCY:50},MAX_BACKOFF_DELAY_BASE:{REGULAR:3e3,LOW_LATENCY:1e3},SAMPLING_INTERVAL_MEDIASOURCE:1e3,SAMPLING_INTERVAL_LOW_LATENCY:500,SAMPLING_INTERVAL_NO_MEDIASOURCE:500,ABR_ENTER_BUFFER_BASED_ALGO:10,ABR_EXIT_BUFFER_BASED_ALGO:5,ABR_MINIMUM_TOTAL_BYTES:15e4,ABR_MINIMUM_CHUNK_SIZE:16e3,ABR_STARVATION_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_REGULAR_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_STARVATION_GAP:{DEFAULT:5,LOW_LATENCY:5},OUT_OF_STARVATION_GAP:{DEFAULT:7,LOW_LATENCY:7},ABR_STARVATION_DURATION_DELTA:.1,ABR_FAST_EMA:2,ABR_SLOW_EMA:10,RESUME_GAP_AFTER_SEEKING:{DEFAULT:1.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_NOT_ENOUGH_DATA:{DEFAULT:.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_BUFFERING:{DEFAULT:5,LOW_LATENCY:.5},REBUFFERING_GAP:{DEFAULT:.5,LOW_LATENCY:.2},MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING:2,UNFREEZING_SEEK_DELAY:6e3,FREEZING_STALLED_DELAY:600,UNFREEZING_DELTA_POSITION:.001,SEGMENT_SYNCHRONIZATION_DELAY:1500,MISSING_DATA_TRIGGER_SYNC_DELAY:.1,MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:.15,MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:.4,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:.3,MINIMUM_SEGMENT_SIZE:.001,APPEND_WINDOW_SECURITIES:{START:.2,END:.1},MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL:50,TEXT_TRACK_SIZE_CHECKS_INTERVAL:250,BUFFER_PADDING:{audio:1,video:3,other:1},SEGMENT_PRIORITIES_STEPS:[2,4,8,12,18,25],MAX_HIGH_PRIORITY_LEVEL:1,MIN_CANCELABLE_PRIORITY:3,EME_DEFAULT_VIDEO_CODECS:['video/mp4;codecs=\"avc1.4d401e\"','video/mp4;codecs=\"avc1.42e01e\"','video/webm;codecs=\"vp8\"'],EME_DEFAULT_AUDIO_CODECS:['audio/mp4;codecs=\"mp4a.40.2\"',\"audio/webm;codecs=opus\"],EME_DEFAULT_WIDEVINE_ROBUSTNESSES:[\"HW_SECURE_ALL\",\"HW_SECURE_DECODE\",\"HW_SECURE_CRYPTO\",\"SW_SECURE_DECODE\",\"SW_SECURE_CRYPTO\"],EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES:[\"3000\",\"2000\"],EME_KEY_SYSTEMS:{clearkey:[\"webkit-org.w3.clearkey\",\"org.w3.clearkey\"],widevine:[\"com.widevine.alpha\"],playready:[\"com.microsoft.playready.recommendation\",\"com.microsoft.playready\",\"com.chromecast.playready\",\"com.youtube.playready\"],fairplay:[\"com.apple.fps.1_0\"]},MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:10,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:200,MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:300,OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:3e3,FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:3e3,DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:3,EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS:15,EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION:1e3,EME_WAITING_DELAY_LOADED_SESSION_EMPTY_KEYSTATUSES:100,FORCED_ENDED_THRESHOLD:8e-4,ADAP_REP_SWITCH_BUFFER_PADDINGS:{video:{before:5,after:5},audio:{before:2,after:2.5},text:{before:0,after:0}},SOURCE_BUFFER_FLUSHING_INTERVAL:500,CONTENT_REPLACEMENT_PADDING:1.2,CACHE_LOAD_DURATION_THRESHOLDS:{video:50,audio:10},STREAM_EVENT_EMITTER_POLL_INTERVAL:250,DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR:.001,BUFFERED_HISTORY_RETENTION_TIME:6e4,BUFFERED_HISTORY_MAXIMUM_ENTRIES:200,MIN_BUFFER_AHEAD:5,UPTO_CURRENT_POSITION_CLEANUP:5,DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE:\"seamless\",DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE:\"seamless\",DEFAULT_VIDEO_TRACK_SWITCHING_MODE:\"reload\",DEFAULT_AUDIO_TRACK_SWITCHING_MODE:\"seamless\"},Va=$s;function Xs(n,...e){if(n==null)throw new TypeError(\"Cannot convert undefined or null to object\");let t=Object(n);for(let r=0;r<e.length;r++){let i=e[r];for(let a in i)Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a])}return t}var H=typeof Object.assign==\"function\"?Object.assign:Xs;function qr(n){return n!=null&&!Array.isArray(n)&&typeof n==\"object\"}function jt(n,...e){if(e.length===0)return n;let t=e.shift();if(qr(n)&&qr(t))for(let r in t)if(qr(t[r])){let i=n[r];i===void 0&&(i={},n[r]=i),jt(i,t[r])}else H(n,{[r]:t[r]});return jt(n,...e)}var Hr=class{constructor(){this._config=Va}update(e){let t=jt(this._config,e);this._config=t}getCurrent(){return this._config}},Zs=new Hr,U=Zs;var Ge=class n extends Error{constructor(e,t,r){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"CustomLoaderError\",this.message=e,this.canRetry=t,this.xhr=r}};function v(n){return n==null}var oe=class{constructor(){this._listeners={}}addEventListener(e,t,r){let i=this._listeners[e];Array.isArray(i)?i.push(t):this._listeners[e]=[t],r!==void 0&&r.register(()=>{this.removeEventListener(e,t)})}removeEventListener(e,t){if(v(e)){this._listeners={};return}let r=this._listeners[e];if(!Array.isArray(r))return;if(v(t)){delete this._listeners[e];return}let i=r.indexOf(t);i!==-1&&r.splice(i,1),r.length===0&&delete this._listeners[e]}trigger(e,t){let r=this._listeners[e];Array.isArray(r)&&r.slice().forEach(i=>{try{i(t)}catch(a){if(b.CURRENT_ENV===b.DEV)throw a instanceof Error?a:new Error(\"EventEmitter: listener error\");console.error(\"RxPlayer: EventEmitter error\",a instanceof Error?a:null)}})}};function N(){}var Js=\"NONE\",Yt=class extends oe{constructor(){super(),this.error=N,this.warn=N,this.info=N,this.debug=N,this._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},this._currentLevel=Js}setLevel(e,t){let r,i=this._levels[e];typeof i==\"number\"?(r=i,this._currentLevel=e):(r=0,this._currentLevel=\"NONE\"),t===void 0?(this.error=r>=this._levels.ERROR?console.error.bind(console):N,this.warn=r>=this._levels.WARNING?console.warn.bind(console):N,this.info=r>=this._levels.INFO?console.info.bind(console):N,this.debug=r>=this._levels.DEBUG?console.log.bind(console):N):(this.error=r>=this._levels.ERROR?(...a)=>t(\"ERROR\",a):N,this.warn=r>=this._levels.WARNING?(...a)=>t(\"WARNING\",a):N,this.info=r>=this._levels.INFO?(...a)=>t(\"INFO\",a):N,this.debug=r>=this._levels.DEBUG?(...a)=>t(\"DEBUG\",a):N),this.trigger(\"onLogLevelChange\",this._currentLevel)}getLevel(){return this._currentLevel}hasLevel(e){return this._levels[e]>=this._levels[this._currentLevel]}};var eu=new Yt,c=eu;var ot=typeof WorkerGlobalScope!=\"undefined\"&&self instanceof WorkerGlobalScope;var tu=typeof window==\"undefined\"&&!ot,er=tu;var tr;ot?tr=self:er?tr=global:tr=window;var Ee=tr;function ne(n,e,t){if(typeof Array.prototype.findIndex==\"function\")return n.findIndex(e,t);let r=n.length>>>0;for(let i=0;i<r;i++)if(e.call(t,n[i],i,n))return i;return-1}var nr=class{constructor(e,t){this._value=e,this._listeners=[],this._isFinished=!1,this._onFinishCbs=[],t!==void 0&&(this._deregisterCancellation=t.register(()=>this.finish()))}getValue(){return this._value}setValue(e){if(this._isFinished){b.CURRENT_ENV===b.DEV&&console.error(\"Finished shared references cannot be updated\");return}if(this._value=e,this._listeners.length===0)return;let t=this._listeners.slice();for(let r of t)try{r.hasBeenCleared||r.trigger(e,r.complete)}catch(i){}}setValueIfChanged(e){e!==this._value&&this.setValue(e)}onUpdate(e,t){let r=()=>{if((t==null?void 0:t.clearSignal)!==void 0&&t.clearSignal.deregister(r),i.hasBeenCleared)return;i.hasBeenCleared=!0;let a=this._listeners.indexOf(i);a>=0&&this._listeners.splice(a,1)},i={trigger:e,complete:r,hasBeenCleared:!1};if(this._listeners.push(i),(t==null?void 0:t.emitCurrentValue)===!0&&e(this._value,r),this._isFinished||i.hasBeenCleared){r();return}(t==null?void 0:t.clearSignal)!==void 0&&t.clearSignal.register(r)}waitUntilDefined(e,t){this.onUpdate((r,i)=>{r!==void 0&&(i(),e(this._value))},{clearSignal:t==null?void 0:t.clearSignal,emitCurrentValue:!0})}_onFinished(e,t){if(t.isCancelled())return N;let r=()=>{let o=ne(this._onFinishCbs,s=>s.trigger===i);o>=0&&(this._onFinishCbs[o].hasBeenCleared=!0,this._onFinishCbs.splice(o,1))},i=()=>{r(),e()},a=t.register(r);return this._onFinishCbs.push({trigger:i,hasBeenCleared:!1}),a}finish(){this._deregisterCancellation!==void 0&&this._deregisterCancellation(),this._isFinished=!0;let e=this._listeners.slice();for(let t of e)try{t.hasBeenCleared||(t.complete(),t.hasBeenCleared=!0)}catch(r){}if(this._listeners.length=0,this._onFinishCbs.length>0){let t=this._onFinishCbs.slice();for(let r of t)try{r.hasBeenCleared||(r.trigger(),r.hasBeenCleared=!0)}catch(i){}this._onFinishCbs.length=0}}};function Qt(n,e,t){let r=new nr(e(n.getValue()),t);return n.onUpdate(function(a){r.setValue(e(a))},{clearSignal:t}),n._onFinished(()=>{r.finish()},t),r}var G=nr;var Gr=new G(0);function qa({date:n,timestamp:e}){let t=n-e,r=typeof performance!=\"undefined\"?Date.now()-performance.now():0;Gr.setValueIfChanged(r-t)}var nu=typeof performance!=\"undefined\"?()=>performance.now()+Gr.getValue():()=>Date.now()+Gr.getValue(),L=nu;var re=class n extends Error{constructor(e,t,r){switch(super(),Object.setPrototypeOf(this,n.prototype),this.name=\"RequestError\",this.url=e,this.status=t,this.type=r,r){case\"TIMEOUT\":this.message=\"The request timed out\";break;case\"ERROR_EVENT\":this.message=\"An error prevented the request to be performed successfully\";break;case\"PARSE_ERROR\":this.message=\"An error happened while formatting the response data\";break;case\"ERROR_HTTP_CODE\":this.message=\"An HTTP status code indicating failure was received: \"+String(this.status);break}}serialize(){return{url:this.url,status:this.status,type:this.type}}},Se={TIMEOUT:\"TIMEOUT\",ERROR_EVENT:\"ERROR_EVENT\",ERROR_HTTP_CODE:\"ERROR_HTTP_CODE\",PARSE_ERROR:\"PARSE_ERROR\"};var Kr=typeof Headers==\"function\"?Headers:null,jr=typeof AbortController==\"function\"?AbortController:null;function rr(n){let e;if(!v(n.headers))if(v(Kr))e=n.headers;else{e=new Kr;let m=Object.keys(n.headers);for(let p=0;p<m.length;p++){let g=m[p];e.append(g,n.headers[g])}}c.debug(\"Fetch: Called with URL\",n.url);let t=null,r=!1,i=!1,a=L(),o=v(jr)?null:new jr;function s(){if(v(o)){c.warn(\"Fetch: AbortController API not available.\");return}o.abort()}let u;n.timeout!==void 0&&(u=setTimeout(()=>{r=!0,l!==void 0&&clearTimeout(l),s()},n.timeout));let l;n.connectionTimeout!==void 0&&(l=setTimeout(()=>{i=!0,u!==void 0&&clearTimeout(u),s()},n.connectionTimeout));let d=n.cancelSignal.register(function(p){t=p,s()}),f={method:\"GET\"};return e!==void 0&&(f.headers=e),f.signal=v(o)?null:o.signal,fetch(n.url,f).then(m=>{if(l!==void 0&&clearTimeout(l),m.status>=300)throw c.warn(\"Fetch: Request HTTP Error\",m.status,m.url),new re(m.url,m.status,Se.ERROR_HTTP_CODE);if(v(m.body))throw new re(m.url,m.status,Se.PARSE_ERROR);let p=m.headers.get(\"Content-Length\"),g=!v(p)&&!isNaN(+p)?+p:void 0,h=m.body.getReader(),I=0;return y();async function y(){let E=await h.read();if(!E.done&&!v(E.value)){I+=E.value.byteLength;let R=L(),T={url:m.url,currentTime:R,duration:R-a,sendingTime:a,chunkSize:E.value.byteLength,chunk:E.value.buffer,size:I,totalSize:g};return n.onData(T),y()}else if(E.done){u!==void 0&&clearTimeout(u),d();let R=L();return{requestDuration:R-a,receivedTime:R,sendingTime:a,size:I,status:m.status,url:m.url}}return y()}}).catch(m=>{throw t!==null?t:(d(),r?(c.warn(\"Fetch: Request timed out.\"),new re(n.url,0,Se.TIMEOUT)):i?(c.warn(\"Fetch: Request connection timed out.\"),new re(n.url,0,Se.TIMEOUT)):m instanceof re?m:(c.warn(\"Fetch: Request Error\",m instanceof Error?m.toString():\"\"),new re(n.url,0,Se.ERROR_EVENT)))})}function $t(){return typeof Ee.fetch==\"function\"&&!v(jr)&&!v(Kr)}function Z(n){return typeof n==\"string\"&&n.length>0}var ru=\"json\";function Yr(n){let e={url:n.url,headers:n.headers,responseType:v(n.responseType)?ru:n.responseType,timeout:n.timeout,connectionTimeout:n.connectionTimeout};return new Promise((t,r)=>{let{onProgress:i,cancelSignal:a}=n,{url:o,headers:s,responseType:u,timeout:l,connectionTimeout:d}=e,f=new XMLHttpRequest;f.open(\"GET\",o,!0);let m;l!==void 0&&(f.timeout=l,m=setTimeout(()=>{I(),r(new re(o,f.status,Se.TIMEOUT))},l+3e3));let p;if(d!==void 0&&(p=setTimeout(()=>{I(),f.readyState!==XMLHttpRequest.DONE&&f.abort(),r(new re(o,f.status,Se.TIMEOUT))},d)),f.responseType=u,f.responseType===\"document\"&&f.overrideMimeType(\"text/xml\"),!v(s)){let y=s;for(let E in y)y.hasOwnProperty(E)&&f.setRequestHeader(E,y[E])}let g=L(),h=null;if(a!==void 0&&(h=a.register(function(E){I(),f.readyState!==XMLHttpRequest.DONE&&f.abort(),r(E)}),a.isCancelled()))return;f.onerror=function(){I(),r(new re(o,f.status,Se.ERROR_EVENT))},f.ontimeout=function(){I(),r(new re(o,f.status,Se.TIMEOUT))},d!==void 0&&(f.onreadystatechange=function(){f.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(p)}),i!==void 0&&(f.onprogress=function(E){let R=L();i({url:o,duration:R-g,sendingTime:g,currentTime:R,size:E.loaded,totalSize:E.total})}),f.onload=function(E){if(f.readyState===XMLHttpRequest.DONE)if(I(),f.status>=200&&f.status<300){let R=L(),T=f.response instanceof ArrayBuffer?f.response.byteLength:E.total,C=f.status,P=f.responseType,x=Z(f.responseURL)?f.responseURL:o,_;if(P===\"json\"?_=typeof f.response==\"object\"?f.response:iu(f.responseText):_=f.response,v(_)){r(new re(o,f.status,Se.PARSE_ERROR));return}t({status:C,url:x,responseType:P,sendingTime:g,receivedTime:R,requestDuration:R-g,size:T,responseData:_})}else r(new re(o,f.status,Se.ERROR_HTTP_CODE))},f.send();function I(){m!==void 0&&clearTimeout(m),p!==void 0&&clearTimeout(p),h!==null&&h()}})}function iu(n){try{return JSON.parse(n)}catch(e){return null}}var le=Yr;var It=Se,Fe={NETWORK_ERROR:\"NETWORK_ERROR\",MEDIA_ERROR:\"MEDIA_ERROR\",ENCRYPTED_MEDIA_ERROR:\"ENCRYPTED_MEDIA_ERROR\",OTHER_ERROR:\"OTHER_ERROR\"};function $e(n,e){return`${n}: ${e}`}var Xt=class n extends Error{constructor(e,t,r){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"EncryptedMediaError\",this.type=Fe.ENCRYPTED_MEDIA_ERROR,this.code=e,this._originalMessage=t,this.message=$e(this.code,t),this.fatal=!1,typeof(r==null?void 0:r.keyStatuses)==\"string\"&&(this.keyStatuses=r.keyStatuses)}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage,keyStatuses:this.keyStatuses}}};var j=class n extends Error{constructor(e,t,r){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"MediaError\",this.type=Fe.MEDIA_ERROR,this._originalMessage=t,this.code=e,this.message=$e(this.code,t),this.fatal=!1,(r==null?void 0:r.tracks)!==void 0&&(r==null?void 0:r.tracks.length)>0&&(this.tracksInfo=r.tracks)}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage,tracks:this.tracksInfo}}};var Ke=class n extends Error{constructor(e,t){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"NetworkError\",this.type=Fe.NETWORK_ERROR,this.url=t.url,this.status=t.status,this.errorType=t.type,this._baseError=t,this.code=e,this.message=$e(this.code,t.message),this.fatal=!1}isHttpError(e){return this.errorType===It.ERROR_HTTP_CODE&&this.status===e}serialize(){return{name:this.name,code:this.code,baseError:this._baseError.serialize()}}};var Re=class n extends Error{constructor(e,t){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"OtherError\",this.type=Fe.OTHER_ERROR,this.code=e,this.message=$e(this.code,t),this.fatal=!1,this._originalMessage=t}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage}}};function Mt(n){return(n instanceof Xt||n instanceof j||n instanceof Re||n instanceof Ke)&&Object.keys(Fe).indexOf(n.type)>=0}function ge(n,{defaultCode:e,defaultReason:t}){if(Mt(n))return n;let r=n instanceof Error?n.toString():t;return new Re(e,r)}var Ce=class n extends Error{constructor(e,t,r){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"SourceBufferError\",this.errorName=e,this.message=t,this.isBufferFull=r}serialize(){return{errorName:this.name,message:this.message,isBufferFull:this.isBufferFull}}toString(){return`${this.errorName}: ${this.message}`}};var au={dashParsers:{wasm:null,native:null,fastJs:null},codecSupportProber:null,createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},mainThreadMediaSourceInit:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}},Ha=au;var ae=Ha;function K(n,e,t){if(typeof Array.prototype.find==\"function\")return n.find(e,t);let r=n.length>>>0;for(let i=0;i<r;i++){let a=n[i];if(e.call(t,a,i,n))return a}}var ou={aa:\"aar\",ab:\"abk\",ae:\"ave\",af:\"afr\",ak:\"aka\",am:\"amh\",an:\"arg\",ar:\"ara\",as:\"asm\",av:\"ava\",ay:\"aym\",az:\"aze\",ba:\"bak\",be:\"bel\",bg:\"bul\",bi:\"bis\",bm:\"bam\",bn:\"ben\",bo:\"bod\",br:\"bre\",bs:\"bos\",ca:\"cat\",ce:\"che\",ch:\"cha\",co:\"cos\",cr:\"cre\",cs:\"ces\",cu:\"chu\",cv:\"chv\",cy:\"cym\",da:\"dan\",de:\"deu\",dv:\"div\",dz:\"dzo\",ee:\"ewe\",el:\"ell\",en:\"eng\",eo:\"epo\",es:\"spa\",et:\"est\",eu:\"eus\",fa:\"fas\",ff:\"ful\",fi:\"fin\",fj:\"fij\",fo:\"fao\",fr:\"fra\",fy:\"fry\",ga:\"gle\",gd:\"gla\",gl:\"glg\",gn:\"grn\",gu:\"guj\",gv:\"glv\",ha:\"hau\",he:\"heb\",hi:\"hin\",ho:\"hmo\",hr:\"hrv\",ht:\"hat\",hu:\"hun\",hy:\"hye\",hz:\"her\",ia:\"ina\",id:\"ind\",ie:\"ile\",ig:\"ibo\",ii:\"iii\",ik:\"ipk\",io:\"ido\",is:\"isl\",it:\"ita\",iu:\"iku\",ja:\"jpn\",jv:\"jav\",ka:\"kat\",kg:\"kon\",ki:\"kik\",kj:\"kua\",kk:\"kaz\",kl:\"kal\",km:\"khm\",kn:\"kan\",ko:\"kor\",kr:\"kau\",ks:\"kas\",ku:\"kur\",kv:\"kom\",kw:\"cor\",ky:\"kir\",la:\"lat\",lb:\"ltz\",lg:\"lug\",li:\"lim\",ln:\"lin\",lo:\"lao\",lt:\"lit\",lu:\"lub\",lv:\"lav\",mg:\"mlg\",mh:\"mah\",mi:\"mri\",mk:\"mkd\",ml:\"mal\",mn:\"mon\",mr:\"mar\",ms:\"msa\",mt:\"mlt\",my:\"mya\",na:\"nau\",nb:\"nob\",nd:\"nde\",ne:\"nep\",ng:\"ndo\",nl:\"nld\",nn:\"nno\",no:\"nor\",nr:\"nbl\",nv:\"nav\",ny:\"nya\",oc:\"oci\",oj:\"oji\",om:\"orm\",or:\"ori\",os:\"oss\",pa:\"pan\",pi:\"pli\",pl:\"pol\",ps:\"pus\",pt:\"por\",qu:\"que\",rm:\"roh\",rn:\"run\",ro:\"ron\",ru:\"rus\",rw:\"kin\",sa:\"san\",sc:\"srd\",sd:\"snd\",se:\"sme\",sg:\"sag\",si:\"sin\",sk:\"slk\",sl:\"slv\",sm:\"smo\",sn:\"sna\",so:\"som\",sq:\"sqi\",sr:\"srp\",ss:\"ssw\",st:\"sot\",su:\"sun\",sv:\"swe\",sw:\"swa\",ta:\"tam\",te:\"tel\",tg:\"tgk\",th:\"tha\",ti:\"tir\",tk:\"tuk\",tl:\"tgl\",tn:\"tsn\",to:\"ton\",tr:\"tur\",ts:\"tso\",tt:\"tat\",tw:\"twi\",ty:\"tah\",ug:\"uig\",uk:\"ukr\",ur:\"urd\",uz:\"uzb\",ve:\"ven\",vi:\"vie\",vo:\"vol\",wa:\"wln\",wo:\"wol\",xh:\"xho\",yi:\"yid\",yo:\"yor\",za:\"zha\",zh:\"zho\",zu:\"zul\"},Ga=ou;var su={alb:\"sqi\",arm:\"hye\",baq:\"eus\",bur:\"mya\",chi:\"zho\",cze:\"ces\",dut:\"nld\",fre:\"fra\",geo:\"kat\",ger:\"deu\",gre:\"ell\",ice:\"isl\",mac:\"mkd\",mao:\"mri\",may:\"msa\",per:\"fas\",slo:\"slk\",rum:\"ron\",tib:\"bod\",wel:\"cym\"},Ka=su;function uu(n){if(v(n)||n===\"\")return\"\";let t=(\"\"+n).toLowerCase().split(\"-\")[0],r=du(t);return Z(r)?r:n}function du(n){let e;switch(n.length){case 2:e=Ga[n];break;case 3:e=Ka[n];break}return e}var ja=uu;var Ya=ja;function ir(n,e){if(n.length!==e.length)return!1;if(n===e)return!0;for(let t=n.length-1;t>=0;t--)if(n[t]!==e[t])return!1;return!0}function Ae(){let n=\"\",e=-1;return function(){return e++,e>=Number.MAX_SAFE_INTEGER&&(n+=\"0\",e=0),n+String(e)}}var lu=Ae(),Qr=class{constructor(e,t){var r,i,a,o,s;if(this.id=e.id,this.uniqueId=lu(),this.bitrate=e.bitrate,this.codecs=[],e.isSpatialAudio!==void 0&&(this.isSpatialAudio=e.isSpatialAudio),e.height!==void 0&&(this.height=e.height),e.width!==void 0&&(this.width=e.width),e.mimeType!==void 0&&(this.mimeType=e.mimeType),e.contentProtections!==void 0&&(this.contentProtections=e.contentProtections),e.frameRate!==void 0&&(this.frameRate=e.frameRate),e.hdrInfo!==void 0&&(this.hdrInfo=e.hdrInfo),this.cdnMetadata=e.cdnMetadata,this.index=e.index,t===\"audio\"||t===\"video\")if(ae.codecSupportProber!==null){if(e.supplementalCodecs!==void 0){let u=ae.codecSupportProber.isSupported((r=this.mimeType)!=null?r:\"\",(i=e.supplementalCodecs)!=null?i:\"\");u!==!1&&(this.codecs=[e.supplementalCodecs],u===!0&&(this.isSupported=!0))}this.isSupported!==!0&&(this.codecs.length>0?this.codecs.push((a=e.codecs)!=null?a:\"\"):(this.codecs=e.codecs===void 0?[]:[e.codecs],this.isSupported=ae.codecSupportProber.isSupported((o=this.mimeType)!=null?o:\"\",(s=e.codecs)!=null?s:\"\")))}else e.supplementalCodecs!==void 0&&this.codecs.push(e.supplementalCodecs),e.codecs!==void 0&&this.codecs.push(e.codecs);else e.codecs!==void 0&&this.codecs.push(e.codecs),this.isSupported=!0}refreshCodecSupport(e){var i;let t=(i=this.mimeType)!=null?i:\"\",r=this.codecs;r.length===0&&(r=[\"\"]);for(let a=0;a<r.length;a++)for(let o of e){let s=r[a];if(o.codec===s&&o.mimeType===t){if(o.result){this.isSupported=!0,this.codecs=[s];return}else if(a===r.length){this.isSupported=!1,this.codecs=[s];return}}}}getMimeTypeString(){var e,t,r;return`${(e=this.mimeType)!=null?e:\"\"};codecs=\"${(r=(t=this.codecs)==null?void 0:t[0])!=null?r:\"\"}\"`}getEncryptionData(e){var i,a;let t=this.getAllEncryptionData(),r=[];for(let o=0;o<t.length;o++){let s=!1,u=t[o];for(let l=0;l<u.values.length;l++)if(u.values[l].systemId.toLowerCase()===e.toLowerCase())if(s)r[r.length-1].values.push(u.values[l]);else{let d=(a=(i=this.contentProtections)==null?void 0:i.keyIds)==null?void 0:a.map(f=>f.keyId);r.push({type:u.type,keyIds:d,values:[u.values[l]]}),s=!0}}return r}getAllEncryptionData(){var t,r;if(this.contentProtections===void 0||this.contentProtections.initData.length===0)return[];let e=(r=(t=this.contentProtections)==null?void 0:t.keyIds)==null?void 0:r.map(i=>i.keyId);return this.contentProtections.initData.map(i=>({type:i.type,keyIds:e,values:i.values}))}addProtectionData(e,t,r){let i=!1;if(this.contentProtections===void 0)return this.contentProtections={keyIds:t!==void 0?[{keyId:t}]:[],initData:[{type:e,values:r}]},!0;if(t!==void 0){let o=this.contentProtections.keyIds;if(o===void 0)this.contentProtections.keyIds=[{keyId:t}];else{let s=!1;for(let u of o)ir(u.keyId,t)&&(s=!0);s||(c.warn(\"Manifest: found unanounced key id.\"),o.push({keyId:t}))}}let a=this.contentProtections.initData;for(let o=0;o<a.length;o++)if(a[o].type===e){let s=a[o].values;for(let u=0;u<r.length;u++){let l=r[u],d;for(d=0;d<s.length;d++)if(l.systemId===s[d].systemId){if(ir(l.data,s[d].data))break;c.warn(\"Manifest: different init data for the same system ID\")}d===s.length&&(s.push(l),i=!0)}return i}return this.contentProtections.initData.push({type:e,values:r}),!0}getMetadataSnapshot(){return{id:this.id,uniqueId:this.uniqueId,bitrate:this.bitrate,codecs:this.codecs,mimeType:this.mimeType,width:this.width,height:this.height,frameRate:this.frameRate,isSupported:this.isSupported,hdrInfo:this.hdrInfo,contentProtections:this.contentProtections,decipherable:this.decipherable}}},Zt=Qr;var st=class n{constructor(e,t={}){let{trickModeTracks:r}=e,{representationFilter:i,isManuallyAdded:a}=t;this.id=e.id,this.type=e.type,e.isTrickModeTrack!==void 0&&(this.isTrickModeTrack=e.isTrickModeTrack),e.language!==void 0&&(this.language=e.language,this.normalizedLanguage=Ya(e.language)),e.closedCaption!==void 0&&(this.isClosedCaption=e.closedCaption),e.audioDescription!==void 0&&(this.isAudioDescription=e.audioDescription),e.isDub!==void 0&&(this.isDub=e.isDub),e.forcedSubtitles!==void 0&&(this.isForcedSubtitles=e.forcedSubtitles),e.isSignInterpreted!==void 0&&(this.isSignInterpreted=e.isSignInterpreted),e.label!==void 0&&(this.label=e.label),r!==void 0&&r.length>0&&(this.trickModeTracks=r.map(l=>new n(l)));let o=e.representations,s=[],u;for(let l=0;l<o.length;l++){let d=new Zt(o[l],this.type),f=!0;if(!v(i)){let m={id:d.id,bitrate:d.bitrate,codecs:d.codecs,height:d.height,width:d.width,frameRate:d.frameRate,hdrInfo:d.hdrInfo};if(d.contentProtections!==void 0&&(m.contentProtections={},d.contentProtections.keyIds!==void 0)){let p=d.contentProtections.keyIds.map(({keyId:g})=>g);m.contentProtections.keyIds=p}f=i(m,{trackType:this.type,language:this.language,normalizedLanguage:this.normalizedLanguage,isClosedCaption:this.isClosedCaption,isDub:this.isDub,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted})}f?(s.push(d),u===void 0&&(d.isSupported===!0?u=!0:d.isSupported===!1&&(u=!1))):c.debug(\"Filtering Representation due to representationFilter\",this.type,`Adaptation: ${this.id}`,`Representation: ${d.id}`,`(${d.bitrate})`)}s.sort((l,d)=>l.bitrate-d.bitrate),this.representations=s,this.isSupported=u,this.manuallyAdded=a===!0}refreshCodecSupport(e){for(let t of this.representations)t.isSupported===void 0&&(t.refreshCodecSupport(e),this.isSupported!==!0&&t.isSupported===!0?this.isSupported=!0:this.isSupported===void 0&&t.isSupported===!1&&(this.isSupported=!1))}getRepresentation(e){return K(this.representations,({id:t})=>e===t)}getMetadataSnapshot(){let e=[],t=this.representations;for(let r of t)e.push(r.getMetadataSnapshot());return{id:this.id,type:this.type,isSupported:this.isSupported,language:this.language,isForcedSubtitles:this.isForcedSubtitles,isClosedCaption:this.isClosedCaption,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted,normalizedLanguage:this.normalizedLanguage,representations:e,label:this.label,isDub:this.isDub}}};function se(n,e,t){if(typeof Array.prototype.includes==\"function\")return n.includes(e,t);let r=n.length>>>0;if(r===0)return!1;let i=t|0,a=i>=0?Math.min(i,r-1):Math.max(r+i,0),o=(s,u)=>s===u||typeof s==\"number\"&&typeof u==\"number\"&&isNaN(s)&&isNaN(u);for(;a<r;){if(o(n[a],e))return!0;a++}return!1}var Qa=[];function Xe(n){se(Qa,n)||(console.warn(n),Qa.push(n))}function $r(n){return Object.keys(n).map(e=>n[e])}var ar=typeof Object.values==\"function\"?Object.values:$r;var Ot=[\"audio\",\"video\",\"text\"];function Xa(n){var a,o;let e=n.timeBounds;if(e.timeshiftDepth===null)return(a=e.minimumSafePosition)!=null?a:0;let{maximumTimeData:t}=e,r;if(!e.maximumTimeData.isLinear)r=t.maximumSafePosition;else{let s=L()-t.time;r=t.maximumSafePosition+s/1e3}let i=r-e.timeshiftDepth;return Math.max((o=e.minimumSafePosition)!=null?o:0,i)}function Za(n){let{maximumTimeData:e}=n.timeBounds;if(!n.isLive||e.livePosition===void 0)return;if(!e.isLinear)return e.livePosition;let t=L()-e.time;return e.livePosition+t/1e3}function Ja(n){let{maximumTimeData:e}=n.timeBounds;if(!e.isLinear)return e.maximumSafePosition;let t=L()-e.time;return e.maximumSafePosition+t/1e3}function eo(n,e){if(e===void 0)return Zr(n).filter(r=>r.isSupported===!0);let t=n.adaptations[e];return t===void 0?[]:t.filter(r=>r.isSupported===!0)}function to(n,e){let t=null;for(let r=n.periods.length-1;r>=0;r--){let i=n.periods[r];if(Xr(i,e,t))return i;t=i}}function no(n,e){let t=e.end;if(t===void 0)return null;let r=K(n.periods,i=>i.end===void 0||t<i.end);return r===void 0?null:r}function Xr(n,e,t){return e>=n.start&&(n.end===void 0||e<n.end)?!0:e===n.end&&(t===null||t.start>n.end)}function Zr(n){let e=n.adaptations;return $r(e).reduce((t,r)=>v(r)?t:t.concat(r),[])}function fu(n,e){var r,i;let t={language:(r=n.language)!=null?r:\"\",normalized:(i=n.normalizedLanguage)!=null?i:\"\",audioDescription:n.isAudioDescription===!0,id:n.id,representations:(e?n.representations.filter(a=>a.isSupported===!0&&a.decipherable!==!1):n.representations).map(pu),label:n.label};return n.isDub===!0&&(t.dub=!0),t}function mu(n){var e,t;return{language:(e=n.language)!=null?e:\"\",normalized:(t=n.normalizedLanguage)!=null?t:\"\",closedCaption:n.isClosedCaption===!0,id:n.id,label:n.label,forced:n.isForcedSubtitles}}function cu(n,e){let t=n.trickModeTracks!==void 0?n.trickModeTracks.map(i=>{let a=(e?i.representations.filter(s=>s.isSupported===!0&&s.decipherable!==!1):i.representations).map($a),o={id:i.id,representations:a,isTrickModeTrack:!0};return i.isSignInterpreted===!0&&(o.signInterpreted=!0),o}):void 0,r={id:n.id,representations:(e?n.representations.filter(i=>i.isSupported===!0&&i.decipherable!==!1):n.representations).map($a),label:n.label};return n.isSignInterpreted===!0&&(r.signInterpreted=!0),n.isTrickModeTrack===!0&&(r.isTrickModeTrack=!0),t!==void 0&&(r.trickModeTracks=t),r}function pu(n){let{id:e,bitrate:t,codecs:r,isSpatialAudio:i,isSupported:a,decipherable:o}=n;return{id:e,bitrate:t,codec:r==null?void 0:r[0],isSpatialAudio:i,isCodecSupported:a,decipherable:o}}function $a(n){let{id:e,bitrate:t,frameRate:r,width:i,height:a,codecs:o,hdrInfo:s,isSupported:u,decipherable:l}=n;return{id:e,bitrate:t,frameRate:r,width:i,height:a,codec:o==null?void 0:o[0],hdrInfo:s,isCodecSupported:u,decipherable:l}}function ut(n){switch(n.type){case\"audio\":return{type:\"audio\",track:fu(n,!1)};case\"video\":return{type:\"video\",track:cu(n,!1)};case\"text\":return{type:\"text\",track:mu(n)}}}function ro(n){return new Function(`return (${n}(arguments[0], arguments[1]))`)}var dt=class{constructor(e,t,r){if(this.id=e.id,this.adaptations=Object.keys(e.adaptations).reduce((i,a)=>{let o=e.adaptations[a];if(v(o))return i;let s=o.map(u=>{let l=new st(u,{representationFilter:r});return l.representations.length>0&&l.isSupported===!1&&t.push(l),l}).filter(u=>u.representations.length>0);if(s.every(u=>u.isSupported===!1)&&o.length>0&&(a===\"video\"||a===\"audio\"))throw new j(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"No supported \"+a+\" adaptations\",{tracks:void 0});return s.length>0&&(i[a]=s),i},{}),!Array.isArray(this.adaptations.video)&&!Array.isArray(this.adaptations.audio))throw new j(\"MANIFEST_PARSE_ERROR\",\"No supported audio and video tracks.\");this.duration=e.duration,this.start=e.start,!v(this.duration)&&!v(this.start)&&(this.end=this.start+this.duration),this.streamEvents=e.streamEvents===void 0?[]:e.streamEvents}refreshCodecSupport(e,t){Object.keys(this.adaptations).forEach(r=>{let i=this.adaptations[r];if(i===void 0)return;let a=!1;for(let o of i){let s=o.isSupported;o.refreshCodecSupport(e),s!==!1&&o.isSupported===!1&&t.push(o),a===!1?a=o.isSupported:a===void 0&&o.isSupported===!0&&(a=!0)}if((r===\"video\"||r===\"audio\")&&a===!1)throw new j(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"No supported \"+r+\" adaptations\",{tracks:void 0})},{})}getAdaptations(){return Zr(this)}getAdaptationsForType(e){let t=this.adaptations[e];return t!=null?t:[]}getAdaptation(e){return K(this.getAdaptations(),({id:t})=>e===t)}getSupportedAdaptations(e){return eo(this,e)}containsTime(e,t){return Xr(this,e,t)}getMetadataSnapshot(){let e={},t=this.getAdaptations();for(let r of t){let i=e[r.type];i===void 0&&(i=[],e[r.type]=i),i.push(r.getMetadataSnapshot())}return{start:this.start,end:this.end,id:this.id,streamEvents:this.streamEvents,adaptations:e}}};function Jt(n,e,t){let r={updatedAdaptations:[],removedAdaptations:[],addedAdaptations:[]};n.start=e.start,n.end=e.end,n.duration=e.duration,n.streamEvents=e.streamEvents;let i=n.getAdaptations(),a=e.getAdaptations();for(let o=0;o<i.length;o++){let s=i[o],u=ne(a,l=>l.id===s.id);if(u===-1){c.warn('Manifest: Adaptation \"'+i[o].id+'\" not found when merging.');let[l]=i.splice(o,1);o--,r.removedAdaptations.push({id:l.id,trackType:l.type})}else{let[l]=a.splice(u,1),d=[],f=[],m=[];r.updatedAdaptations.push({adaptation:s.id,trackType:s.type,updatedRepresentations:d,addedRepresentations:f,removedRepresentations:m});let p=s.representations,g=l.representations.slice();for(let h=0;h<p.length;h++){let I=p[h],y=ne(g,E=>E.id===I.id);if(y===-1){c.warn(`Manifest: Representation \"${p[h].id}\" not found when merging.`);let[E]=p.splice(h,1);h--,m.push(E.id)}else{let[E]=g.splice(y,1);d.push(I.getMetadataSnapshot()),I.cdnMetadata=E.cdnMetadata,t===0?I.index._replace(E.index):I.index._update(E.index)}}g.length>0&&(c.warn(`Manifest: ${g.length} new Representations found when merging.`),s.representations.push(...g),f.push(...g.map(h=>h.getMetadataSnapshot())))}}if(a.length>0){c.warn(`Manifest: ${a.length} new Adaptations found when merging.`);for(let o of a){let s=n.adaptations[o.type];s===void 0?n.adaptations[o.type]=[o]:s.push(o),r.addedAdaptations.push(o.getMetadataSnapshot())}}return r}function io(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},r=0;for(let a=0;a<e.length;a++){let o=e[a],s=r,u=n[s];for(;u!==void 0&&u.id!==o.id;)s++,u=n[s];if(u!==void 0){let l=Jt(u,o,0);t.updatedPeriods.push({period:{id:u.id,start:u.start,end:u.end,duration:u.duration,streamEvents:u.streamEvents},result:l});let d=e.slice(r,a),f=s-r,m=n.splice(r,f,...d);t.removedPeriods.push(...m.map(p=>({id:p.id,start:p.start,end:p.end}))),t.addedPeriods.push(...d.map(p=>p.getMetadataSnapshot())),r=a+1}}if(r>n.length)return c.error(\"Manifest: error when updating Periods\"),t;if(r<n.length){let a=n.splice(r,n.length-r);t.removedPeriods.push(...a.map(o=>({id:o.id,start:o.start,end:o.end})))}let i=e.slice(r,e.length);return i.length>0&&(n.push(...i),t.addedPeriods.push(...i.map(a=>a.getMetadataSnapshot()))),t}function ao(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]};if(n.length===0)return n.splice(0,0,...e),t.addedPeriods.push(...e.map(s=>s.getMetadataSnapshot())),t;if(e.length===0)return t;let r=n[n.length-1];if(r.start<e[0].start){if(r.end!==e[0].start)throw new j(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: not enough data\");return n.push(...e),t.addedPeriods.push(...e.map(s=>s.getMetadataSnapshot())),t}let i=ne(n,({id:s})=>s===e[0].id);if(i<0)throw new j(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: incoherent data\");let a=Jt(n[i],e[0],1);t.updatedPeriods.push({period:H(n[i].getMetadataSnapshot(),{adaptations:void 0}),result:a});let o=i+1;for(let s=1;s<e.length;s++){let u=e[s],l=-1;for(let d=o;d<n.length;d++)if(u.id===n[d].id){l=d;break}if(l<0){let d=-1;for(let p=o;p<n.length;p++)if(u.start<n[p].start){d=p;break}let f=d-o,m=n.splice(o,f,u);t.addedPeriods.push(u.getMetadataSnapshot()),t.removedPeriods.push(...m.map(p=>({id:p.id,start:p.start,end:p.end})))}else{if(l>o){c.warn(\"Manifest: old Periods not found in new when updating, removing\");let f=n.splice(o,l-o);t.removedPeriods.push(...f.map(m=>({id:m.id,start:m.start,end:m.end}))),l=o}let d=Jt(n[l],u,0);t.updatedPeriods.push({period:H(n[l].getMetadataSnapshot(),{adaptations:void 0}),result:d})}o++}if(o<n.length){c.warn(\"Manifest: Ending Periods not found in new when updating, removing\");let s=n.splice(o,n.length-o);t.removedPeriods.push(...s.map(u=>({id:u.id,start:u.start,end:u.end})))}return t}var gu=Ae(),en=class extends oe{constructor(e,t,r){var s;super();let{representationFilter:i,manifestUpdateUrl:a}=t;this.manifestFormat=0,this.id=gu(),this.expired=(s=e.expired)!=null?s:null,this.transport=e.transportType,this.clockOffset=e.clockOffset;let o=[];if(this.periods=e.periods.map(u=>new dt(u,o,i)).sort((u,l)=>u.start-l.start),o.length>0){let u=new j(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"An Adaptation contains only incompatible codecs.\",{tracks:o.map(ut)});r.push(u)}this.adaptations=this.periods[0]===void 0?{}:this.periods[0].adaptations,this.timeBounds=e.timeBounds,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.uris=e.uris===void 0?[]:e.uris,this.updateUrl=a,this.lifetime=e.lifetime,this.clockOffset=e.clockOffset,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.availabilityStartTime=e.availabilityStartTime,this.publishTime=e.publishTime}refreshCodecSupport(e){let t=[];for(let r of this.periods)r.refreshCodecSupport(e,t);return t.length>0?new j(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"An Adaptation contains only incompatible codecs.\",{tracks:t.map(ut)}):null}getPeriod(e){return K(this.periods,t=>e===t.id)}getPeriodForTime(e){return to(this,e)}getNextPeriod(e){return K(this.periods,t=>t.start>e)}getPeriodAfter(e){return no(this,e)}getUrls(){return this.uris}replace(e){this._performUpdate(e,0)}update(e){this._performUpdate(e,1)}getMinimumSafePosition(){return Xa(this)}getLivePosition(){return Za(this)}getMaximumSafePosition(){return Ja(this)}updateRepresentationsDeciperability(e){let t=hu(this,e);t.length>0&&this.trigger(\"decipherabilityUpdate\",t)}getAdaptations(){Xe(\"manifest.getAdaptations() is deprecated. Please use manifest.period[].getAdaptations() instead\");let e=this.periods[0];if(e===void 0)return[];let t=e.adaptations,r=[];for(let i in t)if(t.hasOwnProperty(i)){let a=t[i];r.push(...a)}return r}getAdaptationsForType(e){Xe(\"manifest.getAdaptationsForType(type) is deprecated. Please use manifest.period[].getAdaptationsForType(type) instead\");let t=this.periods[0];if(t===void 0)return[];let r=t.adaptations[e];return r===void 0?[]:r}getAdaptation(e){return Xe(\"manifest.getAdaptation(id) is deprecated. Please use manifest.period[].getAdaptation(id) instead\"),K(this.getAdaptations(),({id:t})=>e===t)}getMetadataSnapshot(){let e=[];for(let t of this.periods)e.push(t.getMetadataSnapshot());return{manifestFormat:1,id:this.id,periods:e,isDynamic:this.isDynamic,isLive:this.isLive,isLastPeriodKnown:this.isLastPeriodKnown,suggestedPresentationDelay:this.suggestedPresentationDelay,clockOffset:this.clockOffset,uris:this.uris,availabilityStartTime:this.availabilityStartTime,timeBounds:this.timeBounds}}_performUpdate(e,t){this.availabilityStartTime=e.availabilityStartTime,this.expired=e.expired,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.lifetime=e.lifetime,this.clockOffset=e.clockOffset,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.transport=e.transport,this.publishTime=e.publishTime;let r;if(t===0)this.timeBounds=e.timeBounds,this.uris=e.uris,r=io(this.periods,e.periods);else{this.timeBounds.maximumTimeData=e.timeBounds.maximumTimeData,this.updateUrl=e.uris[0],r=ao(this.periods,e.periods);let i=this.getMinimumSafePosition();for(;this.periods.length>0;){let a=this.periods[0];if(a.end===void 0||a.end>i)break;this.periods.shift()}}this.adaptations=this.periods[0]===void 0?{}:this.periods[0].adaptations,this.trigger(\"manifestUpdate\",r)}};function hu(n,e){let t=[];for(let r of n.periods)for(let i of r.getAdaptations())for(let a of i.representations){let o={manifest:n,period:r,adaptation:i,representation:a},s=e(o);s!==a.decipherable&&(t.push(o),a.decipherable=s,c.debug(`Decipherability changed for \"${a.id}\"`,`(${a.bitrate})`,String(a.decipherable)))}return t}function Ze(n,e){return n.segment.id===e.segment.id&&n.representation.uniqueId===e.representation.uniqueId}function bt(n){if(v(n))return\"\";let{period:e,adaptation:t,representation:r,segment:i}=n,a;return i.isInit?a=\"init\":i.complete?a=`${i.time}-${i.duration}`:a=`${i.time}`,`${t.type} P: ${e.id} A: ${t.id} R: ${r.id} S: ${a}`}var wt=en;var lt=Ee,St=lt===void 0?void 0:v(lt.MediaSource)?v(lt.MozMediaSource)?v(lt.WebKitMediaSource)?lt.MSMediaSource:lt.WebKitMediaSource:lt.MozMediaSource:lt.MediaSource;var Iu=200,or=new Map;function Jr(n){if(v(St))return ot&&c.error(\"Compat: Cannot request codec support in a worker without MSE.\"),!1;if(typeof St.isTypeSupported==\"function\"){let e=or.get(n);if(e!==void 0)return e;{let t=St.isTypeSupported(n);return or.size>=Iu&&or.clear(),or.set(n,t),t}}return!0}var bu=50,ei=class{constructor(){this._cachedCodecSupport=new Map}isSupported(e,t){let r=`${e!=null?e:\"\"};codecs=\"${t!=null?t:\"\"}\"`,i=this._cachedCodecSupport.get(r);if(i!==void 0)return i;this._cachedCodecSupport.size>=bu&&this._cachedCodecSupport.clear();let a=Jr(r);return this._cachedCodecSupport.set(r,a),a}},Su=new ei,oo=Su;var ti=class{constructor(){this._currentCacheSize=0,this._cachedCodecSupport=new Map}isSupported(e,t){var i;let r=(i=this._cachedCodecSupport.get(e))==null?void 0:i.get(t);if(r!==void 0)return r}updateCache(e,t,r){this._currentCacheSize>=50&&(this._cachedCodecSupport.clear(),this._currentCacheSize=0);let i=this._cachedCodecSupport.get(e);if(i!==void 0)i.set(t,r);else{let a=new Map;a.set(t,r),this._cachedCodecSupport.set(e,a)}}},so=new ti;var sr=class n extends Error{constructor(e){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"AssertionError\",this.message=e}};function he(n,e){if(b.DEV===b.CURRENT_ENV&&!n)throw new sr(e===void 0?\"invalid assertion\":e)}function ze(n){throw new sr(\"Unreachable path taken\")}var yu=\"<\";var uo=\">\";var Tu=`\\r\n\t>/= `;function ni(n,e={}){var m,p;let t=(m=e.pos)!=null?m:0,r=e.keepComments===!0,i=e.keepWhitespace===!0,a;if(e.attrValue!==void 0)for(e.attrName=(p=e.attrName)!=null?p:\"id\",a=[];(t=f())!==-1;)t=n.lastIndexOf(\"<\",t),t!==-1&&a.push(l()),n=n.substring(t),t=0;else a=o(\"\");return e.filter&&(a=lo(a,e.filter)),a;function o(g){let h=[];for(;n[t];)if(n.charCodeAt(t)===60){if(n.charCodeAt(t+1)===47){let y=t+2;if(t=n.indexOf(uo,t),n.substring(y,t).indexOf(g)===-1){let R=n.substring(0,t).split(`\n`);throw new Error(`Unexpected close tag\nLine: `+(R.length-1)+`\nColumn: `+(R[R.length-1].length+1)+`\nChar: `+n[t])}return t!==-1&&(t+=1),h}else if(n.charCodeAt(t+1)===33){if(n.charCodeAt(t+2)===45){let y=t;for(;t!==-1&&!(n.charCodeAt(t)===62&&n.charCodeAt(t-1)===45&&n.charCodeAt(t-2)===45);)t=n.indexOf(uo,t+1);t===-1&&(t=n.length),r&&h.push(n.substring(y,t+1))}else if(n.charCodeAt(t+2)===91&&n.charCodeAt(t+8)===91&&n.substring(t+3,t+8).toLowerCase()===\"cdata\"){let y=n.indexOf(\"]]>\",t);y===-1?(h.push(n.substring(t+9)),t=n.length):(h.push(n.substring(t+9,y)),t=y+3);continue}else{let y=t+1;t+=2;let E=!1;for(;(n.charCodeAt(t)!==62||E)&&n[t];)n.charCodeAt(t)===91?E=!0:E&&n.charCodeAt(t)===93&&(E=!1),t++;h.push(n.substring(y,t))}t++;continue}let I=l();h.push(I),I.tagName[0]===\"?\"&&(h.push(...I.children),I.children=[])}else{let I=s();if(i)I.length>0&&h.push(I);else{let y=I.trim();y.length>0&&h.push(y)}t++}return h}function s(){let g=t;return t=n.indexOf(yu,t)-1,t===-2&&(t=n.length),n.slice(g,t+1)}function u(){let g=t;for(;Tu.indexOf(n[t])===-1&&n[t];)t++;return n.slice(g,t)}function l(){let g=t;t++;let h=u(),I={},y=[];for(;n.charCodeAt(t)!==62&&n[t];){let E=n.charCodeAt(t);if(E>64&&E<91||E>96&&E<123){let R=u(),T=n.charCodeAt(t);for(;T&&T!==39&&T!==34&&!(T>64&&T<91||T>96&&T<123)&&T!==62;)t++,T=n.charCodeAt(t);let C;T===39||T===34?C=d():(C=null,t--),I[R]=C===null?null:fo(C)}t++}return n.charCodeAt(t-1)!==47?(t++,y=o(h)):t++,{tagName:h,attributes:I,children:y,posStart:g,posEnd:t}}function d(){let g=n[t],h=t+1;return t=n.indexOf(g,h),n.slice(h,t)}function f(){let g=new RegExp(\"\\\\s\"+e.attrName+`\\\\s*=['\"]`+e.attrValue+`['\"]`).exec(n);return g?g.index:-1}}function lo(n,e,t=0,r=\"\"){let i=[];return n.forEach(function(a,o){if(typeof a==\"object\"&&(e(a,o,t,r)&&i.push(a),a.children.length>0)){let s=lo(a.children,e,t+1,(r?r+\".\":\"\")+o+\".\"+a.tagName);i=i.concat(s)}}),i}function ur(n){if(Array.isArray(n)){let e=\"\";return n.forEach(function(t){e+=\" \"+ur(t),e=e.trim()}),e}else return typeof n==\"object\"?ur(n.children):\" \"+fo(n)}function fo(n){return n.indexOf(\"&\")<0?n:n.replace(/</g,\"<\").replace(/>/g,\">\").replace(/"/g,'\"').replace(/'/g,\"'\").replace(/&#x([A-Fa-f0-9]+);/g,(e,t)=>String.fromCharCode(parseInt(t,16))).replace(/&/g,\"&\")}function ri(n,e,t){let{repeatCount:r}=n;if(r>=0)return r;let i;return v(e)?t!==void 0?i=t:i=Number.MAX_VALUE:i=e.start,Math.ceil((i-n.start)/n.duration)-1}function De(n,e,t){let{start:r,duration:i}=n;if(i<=0)return r;let a=ri(n,e,t);return r+(a+1)*i}function Pe(n,e){var t;return n*e.timescale+((t=e.indexTimeOffset)!=null?t:0)}function je(n,e){var t;return(n-((t=e.indexTimeOffset)!=null?t:0))/e.timescale}function mo(n,e,t){return[n*t,(n+e)*t]}function _u(n,e){let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i].start<=e?t=i+1:r=i}return t-1}function co(n,e,t){let{timeline:r}=n,i=Pe(e,n);if(i<0)return null;let a=_u(r,i);if(a<0||a>=r.length-1)return null;let o=r[a];if(o.duration<=0)return null;let s=r[a+1];if(s===void 0)return null;let u=s.start,l=De(o,s,t);return i>=l&&i<u?je(u,n):null}function Je(n,e){var i;let{initialization:t}=n,r={};return e!==void 0&&(r.isEMSGWhitelisted=e),{id:\"init\",isInit:!0,time:0,end:0,duration:0,timescale:1,range:v(t)?void 0:t.range,indexRange:n.indexRange,url:(i=t==null?void 0:t.url)!=null?i:null,complete:!0,privateInfos:r,timestampOffset:-(n.indexTimeOffset/n.timescale)}}function Eu(n,e){let t=n.toString();return t.length>=e?t:(new Array(e+1).join(\"0\")+t).slice(-e)}function ii(n){return(e,t,r)=>{let i=Z(r)?parseInt(r,10):1;return Eu(String(n),i)}}function Ne(n,e,t){return Ru(n,e,t)}function Ru(n,e,t){return n.indexOf(\"$\")===-1?n:n.replace(/\\$\\$/g,\"$\").replace(/\\$RepresentationID\\$/g,String(e)).replace(/\\$Bandwidth(\\%0(\\d+)d)?\\$/g,ii(t===void 0?0:t))}function dr(n,e){return function(r){return r.indexOf(\"$\")===-1?r:r.replace(/\\$\\$/g,\"$\").replace(/\\$Number(\\%0(\\d+)d)?\\$/g,(i,a,o)=>{if(e===void 0)throw new Error(\"Segment number not defined in a $Number$ scheme\");return ii(e)(i,a,o)}).replace(/\\$Time(\\%0(\\d+)d)?\\$/g,(i,a,o)=>{if(n===void 0)throw new Error(\"Segment time not defined in a $Time$ scheme\");return ii(n)(i,a,o)})}}function Pu(n,e,t){let r=t-n;return r>0?Math.floor(r/e):0}function tn(n,e,t,r,i,a){var E;let o=r.getEstimatedMaximumPosition((E=n.availabilityTimeOffset)!=null?E:0),s=Math.min(e+t,o!=null?o:1/0),u=Pe(e,n),l=Pe(s,n),{timeline:d,timescale:f,segmentUrlTemplate:m,startNumber:p,endNumber:g}=n,h=p!=null?p:1,I=[],y=d.length;for(let R=0;R<y;R++){let T=d[R],{duration:C,start:P,range:x}=T,_;o===void 0?_=i:_=Math.min(o*f,i!=null?i:1/0);let A=ri(T,d[R+1],_),M=n.availabilityTimeComplete!==!1||R!==y-1&&A!==0,k=Pu(P,C,u),D=P+k*C;for(;D<l&&k<=A;){let w=h+k;if(g!==void 0&&w>g)break;let O=m===null?null:dr(D,w)(m),B=D-n.indexTimeOffset,z=C;B<0&&(z=C+B,B=0);let q={id:String(D),time:B/f,end:(B+z)/f,duration:z/f,isInit:!1,range:x,timescale:1,url:O,number:w,timestampOffset:-(n.indexTimeOffset/f),complete:M,privateInfos:{isEMSGWhitelisted:a}};I.push(q),k++,D=P+k*C}if(D>=l||(h+=A+1,g!==void 0&&h>g))return I}return I}function vu(n,e){if(e.timescale!==n.timescale){let{timescale:t}=n;n.timeline.push({start:e.time/e.timescale*t,duration:e.duration/e.timescale*t,repeatCount:e.count===void 0?0:e.count,range:e.range})}else n.timeline.push({start:e.time,duration:e.duration,repeatCount:e.count===void 0?0:e.count,range:e.range});return!0}var yt=class{constructor(e,t){var g,h,I,y;let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t,u=(g=e.timescale)!=null?g:1,d=((h=e.presentationTimeOffset)!=null?h:0)-r*u,f=((I=e.initialization)==null?void 0:I.media)===void 0?null:Ne(e.initialization.media,a,o),m=e.media===void 0?null:Ne(e.media,a,o),p;e.initialization!==void 0?p=e.initialization.range:e.indexRange!==void 0&&(p=[0,e.indexRange[0]-1]),this._index={indexRange:e.indexRange,indexTimeOffset:d,initialization:{url:f,range:p},segmentUrlTemplate:m,startNumber:e.startNumber,endNumber:e.endNumber,timeline:(y=e.timeline)!=null?y:[],timescale:u},this._manifestBoundsCalculator=t.manifestBoundsCalculator,this._scaledPeriodStart=Pe(r,this._index),this._scaledPeriodEnd=v(i)?void 0:Pe(i,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=s}getInitSegment(){return Je(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return tn(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){let e=this._index;return e.timeline.length===0?null:je(Math.max(this._scaledPeriodStart,e.timeline[0].start),e)}getLastAvailablePosition(){var i;let{timeline:e}=this._index;if(e.length===0)return null;let t=e[e.length-1],r=Math.min(De(t,null,this._scaledPeriodEnd),(i=this._scaledPeriodEnd)!=null?i:1/0);return je(r,this._index)}getEnd(){return this.getLastAvailablePosition()}awaitSegmentBetween(){return!1}isSegmentStillAvailable(){return!0}checkDiscontinuity(){return null}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){return!1}isInitialized(){return this._isInitialized}initialize(e){if(!this._isInitialized){for(let t=0;t<e.length;t++)vu(this._index,e[t]);this._isInitialized=!0}}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `BaseRepresentationIndex`\")}_replace(e){this._index=e._index,this._isInitialized=e._isInitialized,this._scaledPeriodEnd=e._scaledPeriodEnd,this._isEMSGWhitelisted=e._isEMSGWhitelisted}_update(){c.error(\"Base RepresentationIndex: Cannot update a SegmentList\")}};var Tt=class{constructor(e,t){var p,g,h;if(e.duration===void 0)throw new Error(\"Invalid SegmentList: no duration\");let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t;this._isEMSGWhitelisted=s,this._periodStart=r,this._periodEnd=i;let u=(p=e.presentationTimeOffset)!=null?p:0,l=(g=e.timescale)!=null?g:1,d=u-r*l,f=((h=e.initialization)==null?void 0:h.media)===void 0?null:Ne(e.initialization.media,a,o),m=e.list.map(I=>({url:I.media===void 0?null:Ne(I.media,a,o),mediaRange:I.mediaRange}));this._index={list:m,timescale:l,duration:e.duration,indexTimeOffset:d,indexRange:e.indexRange,initialization:v(e.initialization)?void 0:{url:f,range:e.initialization.range}}}getInitSegment(){let e=Je(this._index);return e.privateInfos===void 0&&(e.privateInfos={}),e.privateInfos.isEMSGWhitelisted=this._isEMSGWhitelisted,e}getSegments(e,t){let r=this._index,{duration:i,list:a,timescale:o}=r,s=i/o,u=e-this._periodStart,[l,d]=mo(u,t,o),f=Math.min(a.length-1,Math.floor(d/i)),m=[],p=Math.floor(l/i);for(;p<=f;){let g=a[p].mediaRange,h=a[p].url,I=p*s+this._periodStart,y={id:String(p),time:I,isInit:!1,range:g,duration:s,timescale:1,end:I+s,url:h,timestampOffset:-(r.indexTimeOffset/o),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};m.push(y),p++}return m}shouldRefresh(e,t){return!1}getFirstAvailablePosition(){return this._periodStart}getLastAvailablePosition(){var i;let e=this._index,{duration:t,list:r}=e;return Math.min(r.length*t/e.timescale+this._periodStart,(i=this._periodEnd)!=null?i:1/0)}getEnd(){return this.getLastAvailablePosition()}awaitSegmentBetween(){return!1}isSegmentStillAvailable(){return!0}checkDiscontinuity(){return null}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){return!1}isInitialized(){return!0}initialize(){c.error(\"A `ListRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `ListRepresentationIndex`\")}_replace(e){this._index=e._index}_update(){c.error(\"A `ListRepresentationIndex` cannot be updated\")}};function Dt(n){return U.getCurrent().DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR*n}var _t=class{constructor(e,t){var y,E,R;let{availabilityTimeOffset:r,manifestBoundsCalculator:i,isDynamic:a,periodEnd:o,periodStart:s,representationId:u,representationBitrate:l,isEMSGWhitelisted:d}=t,f=(y=e.timescale)!=null?y:1;this._availabilityTimeOffset=r,this._manifestBoundsCalculator=i;let m=(E=e.presentationTimeOffset)!=null?E:0,p=s*f,g=m-p;if(e.duration===void 0)throw new Error(\"Invalid SegmentTemplate: no duration\");let h=((R=e.initialization)==null?void 0:R.media)===void 0?null:Ne(e.initialization.media,u,l),I=e.media===void 0?null:Ne(e.media,u,l);this._index={duration:e.duration,timescale:f,indexRange:e.indexRange,indexTimeOffset:g,initialization:v(e.initialization)?void 0:{url:h,range:e.initialization.range},url:I,presentationTimeOffset:m,startNumber:e.startNumber,endNumber:e.endNumber},this._isDynamic=a,this._periodStart=s,this._scaledRelativePeriodEnd=o===void 0?void 0:(o-s)*f,this._isEMSGWhitelisted=d}getInitSegment(){return Je(this._index,this._isEMSGWhitelisted)}getSegments(e,t){let r=this._index,{duration:i,startNumber:a,endNumber:o,timescale:s,url:u}=r,l=this._periodStart*s,d=this._scaledRelativePeriodEnd,f=e*s-l,m=(e+t)*s-l,p=this._getFirstSegmentStart(),g=this._getLastSegmentStart();if(v(p)||v(g))return[];let h=Math.max(p,f),I=Math.min(g,m);if(I+i<=h)return[];let y=[],E=a!=null?a:1,R=Math.floor(h/i);for(let T=R*i;T<=I;T+=i){let C=R+E;if(o!==void 0&&C>o)return y;let P=!v(d)&&T+i>d?d-T:i,x=T+l,_=T+this._index.presentationTimeOffset,A=u===null?null:dr(_,C)(u),M={id:String(C),number:C,time:x/s,end:(x+P)/s,duration:P/s,timescale:1,isInit:!1,scaledDuration:P/s,url:A,timestampOffset:-(r.indexTimeOffset/s),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};y.push(M),R++}return y}getFirstAvailablePosition(){let e=this._getFirstSegmentStart();return v(e)?e:e/this._index.timescale+this._periodStart}getLastAvailablePosition(){let e=this._getLastSegmentStart();if(v(e))return e;let t=this._estimateRelativeScaledEnd();return Math.min(e+this._index.duration,t!=null?t:1/0)/this._index.timescale+this._periodStart}getEnd(){if(!this._isDynamic)return this.getLastAvailablePosition();let e=this._estimateRelativeScaledEnd();if(e===void 0)return;let{timescale:t}=this._index;return(e+this._periodStart*t)/t}awaitSegmentBetween(e,t){if(he(e<=t),!this._isDynamic)return!1;let{timescale:r}=this._index,i=Dt(r),a=this._periodStart*r,o=e*r-a,s=t*r-a,u=this._getLastSegmentStart();if(v(u)){let f=this._estimateRelativeScaledEnd();return f===void 0?s+i>=0:s+i>=0&&o<f-i}let l=u+this._index.duration,d=this._estimateRelativeScaledEnd();return d===void 0?s>l-i:s>l-i&&o<d-i}shouldRefresh(){return!1}checkDiscontinuity(){return null}isSegmentStillAvailable(e){if(e.isInit)return!0;let t=this.getSegments(e.time,.1);return t.length===0?!1:t[0].time===e.time&&t[0].end===e.end&&t[0].number===e.number}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){if(!this._isDynamic)return!1;let e=this._estimateRelativeScaledEnd();if(e===void 0)return!0;let{timescale:t}=this._index,r=this._getLastSegmentStart();if(v(r))return!0;let i=r+this._index.duration,a=Dt(t);return i+a<e}isInitialized(){return!0}initialize(){c.error(\"A `TemplateRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `TemplateRepresentationIndex`\")}_replace(e){this._index=e._index,this._isDynamic=e._isDynamic,this._periodStart=e._periodStart,this._scaledRelativePeriodEnd=e._scaledRelativePeriodEnd,this._manifestBoundsCalculator=e._manifestBoundsCalculator}_update(e){this._replace(e)}_getFirstSegmentStart(){var o;if(!this._isDynamic)return 0;if(this._scaledRelativePeriodEnd===0||this._scaledRelativePeriodEnd===void 0){let s=this._manifestBoundsCalculator.getEstimatedMaximumPosition((o=this._availabilityTimeOffset)!=null?o:0);if(s!==void 0&&s<this._periodStart)return null}let{duration:e,timescale:t}=this._index,r=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();if(r===void 0)return;let i=r>this._periodStart?(r-this._periodStart)*t:0;return Math.floor(i/e)*e}_getLastSegmentStart(){var a,o;let{duration:e,timescale:t,endNumber:r,startNumber:i=1}=this._index;if(this._isDynamic){let s=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(s!==void 0&&this._scaledRelativePeriodEnd!==void 0&&this._scaledRelativePeriodEnd<s-this._periodStart*this._index.timescale){let f=Math.ceil(this._scaledRelativePeriodEnd/e);return r!==void 0&&r-i+1<f&&(f=r-i+1),(f-1)*e}let u=this._manifestBoundsCalculator.getEstimatedMaximumPosition((a=this._availabilityTimeOffset)!=null?a:0);if(u===void 0)return;let l=(u-this._periodStart)*t;if(l<0)return null;let d=Math.floor(l/e);return r!==void 0&&r-i+1<d&&(d=r-i+1),d<=0?null:(d-1)*e}else{let s=(o=this._scaledRelativePeriodEnd)!=null?o:0,u=Math.ceil(s/e);r!==void 0&&r-i+1<u&&(u=r-i+1);let l=(u-1)*e,d=U.getCurrent().MINIMUM_SEGMENT_SIZE*t;return r!==void 0||s-l>d||u<2?l:(u-2)*e}}_estimateRelativeScaledEnd(){var e,t;if(this._index.endNumber!==void 0){let r=this._index.endNumber-((e=this._index.startNumber)!=null?e:1)+1;return Math.max(Math.min(r*this._index.duration,(t=this._scaledRelativePeriodEnd)!=null?t:1/0),0)}if(this._scaledRelativePeriodEnd!==void 0)return Math.max(this._scaledRelativePeriodEnd,0)}};function ai(n,e){let t=0;for(;n.length>0;){let r=n[0];if(r.start>=e||r.repeatCount===-1)return t;if(r.repeatCount===0)n.shift(),t+=1;else{let i=n[1];if(i!==void 0&&i.start<=e)n.shift(),t+=1;else{if(r.duration<=0)return t;let a=r.start+r.duration,o=1;for(;a<e&&o<=r.repeatCount;)a+=r.duration,o++;if(o>r.repeatCount)n.shift(),t=r.repeatCount+1;else{let s=r.repeatCount-o;return r.start=a,r.repeatCount=s,t+=o,t}}}}return t}function oi(n,e){if(n.length===0)return n.push(...e),!0;if(e.length===0)return!1;let t=n.length,r=e[0].start,i=n[t-1];if(De(i,e[0])<r)throw new j(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: not enough data\");for(let d=t-1;d>=0;d--){let f=n[d].start;if(f===r){let m=t-d;return n.splice(d,m,...e),!1}else if(f<r){let m=n[d];if(m.start+m.duration>r)return c.warn(\"RepresentationIndex: Manifest update removed all previous segments\"),n.splice(0,t,...e),!0;if(m.repeatCount===void 0||m.repeatCount<=0)return m.repeatCount<0&&(m.repeatCount=Math.floor((r-m.start)/m.duration)-1),n.splice(d+1,t-(d+1),...e),!1;if(m.start+m.duration*(m.repeatCount+1)<=r)return n.splice(d+1,t-(d+1),...e),!1;let g=(r-m.start)/m.duration-1;if(g%1===0&&m.duration===e[0].duration){let h=e[0].repeatCount<0?-1:e[0].repeatCount+g+1;return n.splice(d,t-d,...e),n[d].start=m.start,n[d].repeatCount=h,!1}return c.warn(\"RepresentationIndex: Manifest update removed previous segments\"),n[d].repeatCount=Math.floor(g),n.splice(d+1,t-(d+1),...e),!1}}let o=n[n.length-1],s=e[e.length-1];if(o.repeatCount!==void 0&&o.repeatCount<0)return o.start>s.start?(c.warn(\"RepresentationIndex: The new index is older than the previous one\"),!1):(c.warn('RepresentationIndex: The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0);let u=o.start+o.duration*(o.repeatCount+1),l=s.start+s.duration*(s.repeatCount+1);return u>=l?(c.warn(\"RepresentationIndex: The new index is older than the previous one\"),!1):(c.warn('RepresentationIndex: The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0)}function nn(n,e,t){let r=n.start,i=n.duration,a=n.repeatCount;return r===void 0&&(e===null?r=0:v(e.duration)||(r=e.start+e.duration*(e.repeatCount+1))),(i===void 0||isNaN(i))&&t!==null&&t.start!==void 0&&!isNaN(t.start)&&r!==void 0&&!isNaN(r)&&(i=t.start-r),r!==void 0&&!isNaN(r)&&i!==void 0&&!isNaN(i)&&(a===void 0||!isNaN(a))?{start:r,duration:i,repeatCount:a===void 0?0:a}:(c.warn('DASH: A \"S\" Element could not have been parsed.'),null)}function rn(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!v(r))switch(t){case\"t\":let i=parseInt(r,10);isNaN(i)?c.warn(`DASH: invalid t (\"${r}\")`):e.start=i;break;case\"d\":let a=parseInt(r,10);isNaN(a)?c.warn(`DASH: invalid d (\"${r}\")`):e.duration=a;break;case\"r\":let o=parseInt(r,10);isNaN(o)?c.warn(`DASH: invalid r (\"${r}\")`):e.repeatCount=o;break}}return e}function an(n){let e={};for(let t=0;t<n.attributes.length;t++){let r=n.attributes[t];switch(r.name){case\"t\":let i=parseInt(r.value,10);isNaN(i)?c.warn(`DASH: invalid t (\"${r.value}\")`):e.start=i;break;case\"d\":let a=parseInt(r.value,10);isNaN(a)?c.warn(`DASH: invalid d (\"${r.value}\")`):e.duration=a;break;case\"r\":let o=parseInt(r.value,10);isNaN(o)?c.warn(`DASH: invalid r (\"${r.value}\")`):e.repeatCount=o;break}}return e}function ft(n){let e=[];if(Array.isArray(n))for(let r=0;r<n.length;r++)e.push(rn(n[r]));else for(let r=0;r<n.length;r++)e.push(an(n[r]));let t=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[t.length-1]===void 0?null:t[t.length-1],o=e[r+1]===void 0?null:e[r+1],s=nn(i,a,o);s!==null&&t.push(s)}return t}function si(n,e){if(n.length===0||e.length===0)return null;let t=n[0].start,r=Array.isArray(e)?e[0].attributes.t:e[0].getAttribute(\"t\"),i=v(r)?null:parseInt(r,10);if(i===null||Number.isNaN(i))return null;if(t===i)return{prevSegmentsIdx:0,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(t<i){let a=n[0],o=0;for(;;){if(a.repeatCount>0){let s=i-a.start;if(s%a.duration===0&&s/a.duration<=a.repeatCount)return{repeatNumberInPrevSegments:s/a.duration,prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInNewElements:0}}if(o++,o>=n.length)return null;if(a=n[o],a.start===i)return{prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(a.start>i)return null}}else{let a=0,o=Array.isArray(e)?e[0]:null,s=Array.isArray(e)?null:e[0],u=i;for(;;){let l=o!==null?o.attributes.d:s==null?void 0:s.getAttribute(\"d\"),d=v(l)?null:parseInt(l,10);if(d===null||Number.isNaN(d))return null;let f=o!==null?o.attributes.r:s==null?void 0:s.getAttribute(\"r\"),m=v(f)?null:parseInt(f,10);if(m!==null){if(Number.isNaN(m)||m<0)return null;if(m>0){let h=t-u;if(h%d===0&&h/d<=m)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:h/d,prevSegmentsIdx:0,newElementsIdx:a}}u+=d*(m+1)}else u+=d;if(a++,a>=e.length)return null;Array.isArray(e)?o=e[a]:s=e[a];let p=o!==null?o.attributes.t:s==null?void 0:s.getAttribute(\"t\"),g=v(p)?null:parseInt(p,10);if(g!==null){if(Number.isNaN(g))return null;u=g}if(u===t)return{newElementsIdx:a,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(u>i)return null}}}function ui(n,e){var h;let t=si(e,n);if(t===null)return c.warn('DASH: Cannot perform \"based\" update. Common segment not found.'),ft(n);let{prevSegmentsIdx:r,newElementsIdx:i,repeatNumberInPrevSegments:a,repeatNumberInNewElements:o}=t,u=e.length-r+i-1;if(u>=n.length)return c.info('DASH: Cannot perform \"based\" update. New timeline too short'),ft(n);let l=e.slice(r);if(a>0){let I=l[0];I.start+=I.duration*a,l[0].repeatCount-=a}if(o>0&&i!==0)return c.info('DASH: Cannot perform \"based\" update. The new timeline has a different form.'),ft(n);let d=l[l.length-1],f=Array.isArray(n)?rn(n[u]):an(n[u]),m=((h=f.repeatCount)!=null?h:0)-o;if(f.duration!==d.duration||d.repeatCount>m)return c.info('DASH: Cannot perform \"based\" update. The new timeline has a different form at the beginning.'),ft(n);f.repeatCount!==void 0&&f.repeatCount>d.repeatCount&&(d.repeatCount=f.repeatCount);let p=[],g=[];if(Array.isArray(n))for(let I=u+1;I<n.length;I++)g.push(rn(n[I]));else for(let I=u+1;I<n.length;I++)g.push(an(n[I]));for(let I=0;I<g.length;I++){let y=g[I],E=p[p.length-1]===void 0?d:p[p.length-1],R=g[I+1]===void 0?null:g[I+1],T=nn(y,E,R);T!==null&&p.push(T)}return l.concat(p)}var on=class n{constructor(e,t){var T,C,P,x,_;if(!n.isTimelineIndexArgument(e))throw new Error(\"The given index is not compatible with a TimelineRepresentationIndex.\");let{availabilityTimeComplete:r,availabilityTimeOffset:i,manifestBoundsCalculator:a,isDynamic:o,isLastPeriod:s,representationId:u,representationBitrate:l,periodStart:d,periodEnd:f,isEMSGWhitelisted:m}=t,p=(T=e.timescale)!=null?T:1,g=(C=e.presentationTimeOffset)!=null?C:0,h=d*p,I=g-h;this._manifestBoundsCalculator=a,this._isEMSGWhitelisted=m,this._isLastPeriod=s,this._lastUpdate=(P=t.receivedTime)!=null?P:L(),this._unsafelyBaseOnPreviousIndex=null,t.unsafelyBaseOnPreviousRepresentation!==null&&t.unsafelyBaseOnPreviousRepresentation.index instanceof n&&(t.unsafelyBaseOnPreviousRepresentation.index._unsafelyBaseOnPreviousIndex=null,this._unsafelyBaseOnPreviousIndex=t.unsafelyBaseOnPreviousRepresentation.index),this._isDynamic=o,this._parseTimeline=(x=e.timelineParser)!=null?x:null;let y=((_=e.initialization)==null?void 0:_.media)===void 0?null:Ne(e.initialization.media,u,l),E=e.media===void 0?null:Ne(e.media,u,l),R;i===void 0&&r===void 0?R=1/0:R=i!=null?i:0,this._index={availabilityTimeComplete:r!=null?r:!0,availabilityTimeOffset:R,indexRange:e.indexRange,indexTimeOffset:I,initialization:v(e.initialization)?void 0:{url:y,range:e.initialization.range},segmentUrlTemplate:E,startNumber:e.startNumber,endNumber:e.endNumber,timeline:e.timeline===void 0?null:di(e.timeline,e.startNumber,e.endNumber),timescale:p},this._scaledPeriodStart=Pe(d,this._index),this._scaledPeriodEnd=f===void 0?void 0:Pe(f,this._index)}getInitSegment(){return Je(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),tn(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let e=this._index.timeline;return e.length===0?null:je(Math.max(this._scaledPeriodStart,e[0].start),this._index)}getLastAvailablePosition(){var r;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let e=lr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(e===null)return null;let t=Math.min(e.end,(r=this._scaledPeriodEnd)!=null?r:1/0);return je(t,this._index)}getEnd(){var r;if(this._isDynamic&&!this._isLastPeriod)return;if(this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),this._index.timeline.length<=0)return null;let e=this._index.timeline[this._index.timeline.length-1],t=Math.min(De(e,null,this._scaledPeriodEnd),(r=this._scaledPeriodEnd)!=null?r:1/0);return je(t,this._index)}awaitSegmentBetween(e,t){var l,d;if(he(e<=t),!this._isDynamic)return!1;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let{timescale:r,timeline:i}=this._index,a=Dt(r),o=Pe(t,this._index),s=lr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(s!==null&&Math.min(s.end,(l=this._scaledPeriodEnd)!=null?l:1/0)+a>=Math.min(o,(d=this._scaledPeriodEnd)!=null?d:1/0))return!1;let u=Pe(e,this._index);if(i.length>0&&s!==null&&!s.isLastOfTimeline){let f=i[i.length-1],p=De(f,null,this._scaledPeriodEnd)+a;if(u<p+a)return!0}return this._isLastPeriod?this._scaledPeriodEnd===void 0?o+a>this._scaledPeriodStart?void 0:!1:u-a<this._scaledPeriodEnd&&o+a>this._scaledPeriodStart:!1}isSegmentStillAvailable(e){return e.isInit?!0:(this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),Cu(e,this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd))}checkDiscontinuity(e){this._refreshTimeline();let t=this._index.timeline;return t===null&&(t=this._getTimeline(),this._index.timeline=t),co({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)}canBeOutOfSyncError(e){return this._isDynamic?e instanceof Ke&&e.isHttpError(404):!1}_replace(e){this._parseTimeline=e._parseTimeline,this._index=e._index,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._manifestBoundsCalculator=e._manifestBoundsCalculator,this._isLastPeriod=e._isLastPeriod}_update(e){this._index.timeline===null&&(this._index.timeline=this._getTimeline()),e._index.timeline===null&&(e._index.timeline=e._getTimeline()),oi(this._index.timeline,e._index.timeline)&&(this._index.startNumber=e._index.startNumber),this._index.availabilityTimeOffset=e._index.availabilityTimeOffset,this._index.availabilityTimeComplete=e._index.availabilityTimeComplete,this._index.endNumber=e._index.endNumber,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._isLastPeriod=e._isLastPeriod}isStillAwaitingFutureSegments(){var o;if(!this._isDynamic)return!1;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let{timeline:e}=this._index;if(e.length===0){if(this._scaledPeriodEnd!==void 0){let s=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(s!==void 0&&Pe(s,this._index)>this._scaledPeriodEnd)return!1}return this._isLastPeriod}let t=Dt(this._index.timescale),r=lr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(r!==null&&!r.isLastOfTimeline){let s=Math.min(r.end,(o=this._scaledPeriodEnd)!=null?o:1/0);return!(this._scaledPeriodEnd!==void 0&&s+t>=this._scaledPeriodEnd)}if(!this._isLastPeriod)return!1;if(this._scaledPeriodEnd===void 0)return!0;let i=e[e.length-1];return De(i,null,this._scaledPeriodEnd)+t<this._scaledPeriodEnd}isInitialized(){return!0}initialize(){c.error(\"A `TimelineRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `TimelineRepresentationIndex`\")}static isTimelineIndexArgument(e){return typeof e.timelineParser==\"function\"||Array.isArray(e.timeline)}_refreshTimeline(){if(this._index.timeline===null&&(this._index.timeline=this._getTimeline()),!this._isDynamic)return;let e=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();if(v(e))return;let t=Pe(e,this._index),r=ai(this._index.timeline,t);this._index.startNumber!==void 0?this._index.startNumber+=r:this._index.endNumber!==void 0&&(this._index.startNumber=r+1)}_getTimeline(){if(this._parseTimeline===null)return this._index.timeline!==null?this._index.timeline:(c.error(\"DASH: Timeline already lazily parsed.\"),[]);let e=this._parseTimeline();this._parseTimeline=null;let{MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:t}=U.getCurrent();if(this._unsafelyBaseOnPreviousIndex===null||e.length<t)return di(ft(e),this._index.startNumber,this._index.endNumber);let r;return this._unsafelyBaseOnPreviousIndex._index.timeline===null?(r=this._unsafelyBaseOnPreviousIndex._getTimeline(),this._unsafelyBaseOnPreviousIndex._index.timeline=r):r=this._unsafelyBaseOnPreviousIndex._index.timeline,this._unsafelyBaseOnPreviousIndex=null,di(ui(e,r),this._index.startNumber,this._index.endNumber)}};function di(n,e,t){if(t===void 0)return n;let r=e!=null?e:1;for(let i=0;i<n.length;i++){let a=n[i];if(r+=a.repeatCount+1,r>t){if(r===t+1)return n.slice(0,i+1);{let o=n.slice(0,i),s=_e({},a),u=r-a.repeatCount-1;return s.repeatCount=Math.max(0,t-u),o.push(s),o}}}return n}function Cu(n,e,t,r){let i=lr(e,t,r);if(i===null)return!1;for(let a=0;a<e.timeline.length;a++){if(i.timelineIdx<a)return!1;let o=e.timeline[a],s=(o.start-e.indexTimeOffset)/e.timescale;if(s>n.time)return!1;if(s===n.time)return o.range===void 0?n.range===void 0:!v(n.range)&&o.range[0]===n.range[0]&&o.range[1]===n.range[1];if(o.repeatCount>=0&&o.duration!==void 0){let l=(s-o.start)/o.duration-1;return l%1===0&&l<=i.newRepeatCount}}return!1}function lr(n,e,t){if(n.timeline.length<=0)return null;if(n.availabilityTimeOffset===1/0){let i=n.timeline.length-1,a=n.timeline[i];return{isLastOfTimeline:!0,timelineIdx:i,newRepeatCount:a.repeatCount,end:De(a,null,t)}}let r=e.getEstimatedMaximumPosition(n.availabilityTimeOffset);if(r===void 0){let i=n.timeline.length-1,a=n.timeline[i];return{isLastOfTimeline:!0,timelineIdx:i,newRepeatCount:a.repeatCount,end:De(a,null,t)}}for(let i=n.timeline.length-1;i>=n.timeline.length;i--){let a=n.timeline[i],o=a.start+a.duration;if(je(o,n)<=r){let s=De(a,n.timeline[i+1],t);if(je(s,n)<=r)return{isLastOfTimeline:i===n.timeline.length-1,timelineIdx:i,newRepeatCount:a.repeatCount,end:o};{let l=Pe(r,n)-a.start,d=Math.floor(l/a.duration);return he(d>=1),{isLastOfTimeline:!1,timelineIdx:i,newRepeatCount:d-1,end:a.start+d*a.duration}}}}return null}var fr=on;var po=/^(?:[a-z]+:)?\\/\\//i,Au=/\\/\\.{1,2}\\//;function ku(n){if(!Au.test(n))return n;let e=[],t=n.split(\"/\");for(let r=0,i=t.length;r<i;r++)if(t[r]===\"..\")e.pop();else{if(t[r]===\".\")continue;e.push(t[r])}return e.join(\"/\")}function sn(...n){let e=n.length;if(e===0)return\"\";let t=\"\";for(let r=0;r<e;r++){let i=n[r];typeof i!=\"string\"||i===\"\"||(po.test(i)?t=i:(i[0]===\"/\"&&(i=i.substring(1)),t[t.length-1]===\"/\"&&(t=t.substring(0,t.length-1)),t=t+\"/\"+i))}return ku(t)}function li(n){let e=n.lastIndexOf(\"/\");if(e<0)return n.length;if(po.test(n)){let r=n.indexOf(\"/\");if(r>=0&&e===r+1)return n.length}let t=n.indexOf(\"?\");return t>=0&&t<e?li(n.substring(0,t)):e+1}function mr(n){let e=Date.parse(n)-L();if(isNaN(e)){c.warn(\"DASH Parser: Invalid clock received: \",n);return}return e}function fi(n){let e=n.children.utcTimings.filter(t=>(t.schemeIdUri===\"urn:mpeg:dash:utc:http-iso:2014\"||t.schemeIdUri===\"urn:mpeg:dash:utc:http-xsdate:2014\")&&t.value!==void 0);return e.length>0?e[0].value:void 0}function cr(n){let{representations:e}=n,t=null;for(let r=0;r<e.length;r++){let i=e[r].index.getLastAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.min(t,i))}return t===null?null:t}function mi(n){for(let e=n.length-1;e>=0;e--){let t=n[e].adaptations,r=t.audio===void 0?void 0:t.audio[0],i=t.video===void 0?void 0:t.video[0];if(r!==void 0||i!==void 0){let a=null,o=null;if(r!==void 0){let s=cr(r);if(s===void 0)return{safe:void 0,unsafe:void 0};a=s}if(i!==void 0){let s=cr(i);if(s===void 0)return{safe:void 0,unsafe:void 0};o=s}if(r!==void 0&&a===null||i!==void 0&&o===null)return c.info(\"Parser utils: found Period with no segment. \",\"Going to previous one to calculate last position\"),{safe:void 0,unsafe:void 0};if(o!==null)return a!==null?{safe:Math.min(a,o),unsafe:Math.max(a,o)}:{safe:o,unsafe:o};if(a!==null)return{safe:a,unsafe:a}}}return{safe:void 0,unsafe:void 0}}function pr(n){let{representations:e}=n,t=null;for(let r=0;r<e.length;r++){let i=e[r].index.getFirstAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.max(t,i))}return t===null?null:t}function ci(n){for(let e=0;e<=n.length-1;e++){let t=n[e].adaptations,r=t.audio===void 0?void 0:t.audio[0],i=t.video===void 0?void 0:t.video[0];if(r!==void 0||i!==void 0){let a=null,o=null;if(r!==void 0){let s=pr(r);if(s===void 0)return;a=s}if(i!==void 0){let s=pr(i);if(s===void 0)return;o=s}if(r!==void 0&&a===null||i!==void 0&&o===null){c.info(\"Parser utils: found Period with no segment. \",\"Going to next one to calculate first position\");return}if(o!==null)return a!==null?Math.max(a,o):o;if(a!==null)return a}}}function pi(n){if(n.length===0)throw new Error(\"DASH Parser: no period available for a dynamic content\");let e=ci(n),t=mi(n);return{minimumSafePosition:e,maximumSafePosition:t.safe,maximumUnsafePosition:t.unsafe}}var un=class{constructor(e){this._isDynamic=e.isDynamic,this._timeShiftBufferDepth=!e.isDynamic||e.timeShiftBufferDepth===void 0?null:e.timeShiftBufferDepth,this._serverTimestampOffset=e.serverTimestampOffset,this._availabilityStartTime=e.availabilityStartTime}setLastPosition(e,t){this._lastPosition=e,this._positionTime=t}lastPositionIsKnown(){return this._isDynamic?this._positionTime!==void 0&&this._lastPosition!==void 0:this._lastPosition!==void 0}getEstimatedMinimumSegmentTime(){var r;if(!this._isDynamic||this._timeShiftBufferDepth===null)return 0;let e=(r=this.getEstimatedLiveEdge())!=null?r:this.getEstimatedMaximumPosition(0);return e===void 0?void 0:e-this._timeShiftBufferDepth}getEstimatedLiveEdge(){if(!(!this._isDynamic||this._serverTimestampOffset===void 0))return(L()+this._serverTimestampOffset)/1e3-this._availabilityStartTime}getEstimatedMaximumPosition(e){if(!this._isDynamic)return this._lastPosition;let t=this.getEstimatedLiveEdge();return t!==void 0&&e!==1/0?t+e:this._positionTime!==void 0&&this._lastPosition!==void 0?Math.max(this._lastPosition-this._positionTime+L()/1e3,0):this._lastPosition}};function gi(n,e){return n.type!==\"dynamic\"?0:v(n.availabilityStartTime)?e!=null?e:0:n.availabilityStartTime}function hi(n,e){return typeof Array.prototype.flatMap==\"function\"?n.flatMap(e):n.reduce((t,r)=>{let i=e(r);return Array.isArray(i)?(t.push(...i),t):(t.push(i),t)},[])}var xu=typeof Ee==\"object\"&&typeof Ee.TextDecoder==\"function\",Mu=typeof Ee==\"object\"&&typeof Ee.TextEncoder==\"function\";function dn(n){if(Mu)try{return new TextEncoder().encode(n)}catch(i){let a=i instanceof Error?i:\"\";c.warn(\"Utils: could not use TextEncoder to encode string into UTF-8, fallbacking to another implementation\",a)}let e,t=encodeURIComponent(n);if(typeof unescape==\"function\")e=unescape(t);else{let i=/[0-9a-fA-F]/,a=t.length;e=\"\";for(let o=0;o<t.length;o++){let s=!1;if(t[o]===\"%\"){if(o<=a-6&&t[o+1]===\"u\"&&i.test(t[o+2])&&i.test(t[o+3])&&i.test(t[o+4])&&i.test(t[o+5])){let u=parseInt(t.substring(o+1,o+6),16);e+=String.fromCharCode(u),s=!0,o+=5}else if(o<=a-3&&i.test(t[o+1])&&i.test(t[o+2])){let u=parseInt(t.substring(o+1,o+3),16);e+=String.fromCharCode(u),s=!0,o+=2}}s||(e+=t[o])}}let r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i)&255;return r}function Ou(n){let t=\"\";for(let r=0;r<n.length;r+=16e3){let i=n.subarray(r,r+16e3);t+=String.fromCharCode.apply(null,i)}return t}function go(n,e){let t=n.toString(16);return t.length>=e?t:new Array(e-t.length+1).join(\"0\")+t}function Be(n){if(xu)try{return new TextDecoder().decode(n)}catch(i){let a=i instanceof Error?i:\"\";c.warn(\"Utils: could not use TextDecoder to parse UTF-8, fallbacking to another implementation\",a)}let e=n;e[0]===239&&e[1]===187&&e[2]===191&&(e=e.subarray(3));let t=Ou(e),r;if(typeof escape==\"function\")r=escape(t);else{let i=/[A-Za-z0-9*_\\+-\\.\\/]/;r=\"\";for(let a=0;a<t.length;a++)if(i.test(t[a]))r+=t[a];else{let o=t.charCodeAt(a);r+=o>=256?\"%u\"+go(o,4):\"%\"+go(o,2)}}return decodeURIComponent(r)}function ln(n){let e=n.length,t=new Uint8Array(e/2);for(let r=0,i=0;r<e;r+=2,i++)t[i]=parseInt(n.substring(r,r+2),16)&255;return t}function ho(n,e=\"\"){let t=\"\";for(let r=0;r<n.byteLength;r++)t+=(n[r]>>>4).toString(16),t+=(n[r]&15).toString(16),e.length>0&&r<n.byteLength-1&&(t+=e);return t}function Ii(n,e){let t=e;for(;t<n.length&&n[t]!==0;)t+=1;let r=n.subarray(e,t);return{end:t+1,string:Be(r)}}function bi(n){if(n.length===0)return[];let e=[n[0]];for(let t=1;t<n.length;t++){let r=n[t],i=e[e.length-1];for(;(i.duration===void 0||i.start+i.duration>r.start)&&(c.warn(\"DASH: Updating overlapping Periods.\",i==null?void 0:i.start,r.start),i.duration=r.start-i.start,i.end=r.start,!(i.duration>0));){if(e.pop(),e.length===0)break;i=e[e.length-1]}e.push(r)}return e}function Si(n,e){let t=[];return n.forEach((r,i)=>{let a;if(!v(r.attributes.start))a=r.attributes.start;else if(i===0)a=!e.isDynamic||v(e.availabilityStartTime)?0:e.availabilityStartTime;else{let l=t[t.length-1];if(!v(l)&&!v(l.periodEnd))a=l.periodEnd;else throw new Error(\"Missing start time when parsing periods.\")}let o,s=n[i+1];v(r.attributes.duration)?i===n.length-1?o=e.duration:v(s.attributes.start)||(o=s.attributes.start-a):o=r.attributes.duration;let u=v(o)?void 0:a+o;t.push({periodStart:a,periodDuration:o,periodEnd:u})}),t}function wu(n,e){for(let t of e){let{adaptation:r,trickModeAttachedAdaptationIds:i}=t;for(let a of i)for(let o of Ot){let s=n[o];if(s!==void 0)for(let u of s)u.id===a&&(u.trickModeTracks===void 0&&(u.trickModeTracks=[]),u.trickModeTracks.push(r))}}}var Io=wu;var Du=[\"subtitle\",\"caption\"];function yi(n,e,t,r){function i(o,s){let u=o.split(\"/\")[0];if(se(Ot,u))return u;if(o===\"application/ttml+xml\")return\"text\";if(o===\"application/mp4\")return s!==null&&K(s,l=>l.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&se(Du,l.value))!==void 0?\"text\":void 0}function a(o){switch(o.substring(0,3)){case\"avc\":case\"hev\":case\"hvc\":case\"vp8\":case\"vp9\":case\"av1\":return\"video\";case\"vtt\":return\"text\"}switch(o.substring(0,4)){case\"mp4a\":return\"audio\";case\"wvtt\":case\"stpp\":return\"text\"}}if(e!==null){let o=i(e,r);if(o!==void 0)return o}if(t!==null){let o=a(t);if(o!==void 0)return o}for(let o=0;o<n.length;o++){let s=n[o],{mimeType:u,codecs:l}=s.attributes;if(u!==void 0){let d=i(u,r);if(d!==void 0)return d}if(l!==void 0){let d=a(l);if(d!==void 0)return d}}}var Nu=/[, ]+/g;function bo(n){return Z(n)?n.trim().replace(Nu,\", \"):\"\"}function So(n){let[e,t,r,i,a,o,s,u]=n.split(\".\");if(e!==\"vp08\"&&e!==\"vp09\"&&e!==\"vp10\")return;let l,d,f;if((i!==void 0&&i===\"10\"||i===\"12\")&&(l=parseInt(i,10)),s!==void 0&&(s===\"16\"?d=\"pq\":s===\"18\"&&(d=\"hlg\")),o!==void 0&&u!==void 0&&o===\"09\"&&u===\"09\"&&(f=\"rec2020\"),!(l===void 0||d===void 0))return{colorDepth:l,eotf:d,colorSpace:f}}function Ti(n,e){var g,h,I;let{availabilityTimeOffset:t,manifestBoundsCalculator:r,isDynamic:i,end:a,start:o,receivedTime:s,unsafelyBaseOnPreviousRepresentation:u,inbandEventStreams:l,isLastPeriod:d}=e,m={availabilityTimeComplete:void 0,availabilityTimeOffset:t,unsafelyBaseOnPreviousRepresentation:u,isEMSGWhitelisted:y=>l===void 0?!1:l.some(({schemeIdUri:E})=>E===y.schemeIdUri),isLastPeriod:d,manifestBoundsCalculator:r,isDynamic:i,periodEnd:a,periodStart:o,receivedTime:s,representationBitrate:n.attributes.bitrate,representationId:n.attributes.id},p;if(n.children.segmentBase!==void 0){let{segmentBase:y}=n.children;p=new yt(y,m)}else if(n.children.segmentList!==void 0){let{segmentList:y}=n.children;p=new Tt(y,m)}else if(n.children.segmentTemplate!==void 0||e.parentSegmentTemplates.length>0){let y=e.parentSegmentTemplates.slice(),E=n.children.segmentTemplate;E!==void 0&&y.push(E);let R=H({},...y);(R.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(m.availabilityTimeOffset=((g=R.availabilityTimeOffset)!=null?g:0)+((h=e.availabilityTimeOffset)!=null?h:0)),(R.availabilityTimeComplete!==void 0||e.availabilityTimeComplete!==void 0)&&(m.availabilityTimeComplete=(I=R.availabilityTimeComplete)!=null?I:e.availabilityTimeComplete),p=fr.isTimelineIndexArgument(R)?new fr(R,m):new _t(R,m)}else{let y=e.adaptation.children;if(y.segmentBase!==void 0){let{segmentBase:E}=y;p=new yt(E,m)}else if(y.segmentList!==void 0){let{segmentList:E}=y;p=new Tt(E,m)}else p=new _t({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:\"\"},m)}return p}function et(n,e){var i;if(e.length===0)return n;let t=e.map(a=>({url:a.value}));if(n.length===0)return t;let r=[];for(let a=0;a<n.length;a++){let o=n[a];for(let s=0;s<t.length;s++){let u=t[s],l=sn(o.url,u.url);r.push({url:l,serviceLocation:(i=u.serviceLocation)!=null?i:o.serviceLocation})}}return r}function Bu(n,e){let t=[];if(n.children.inbandEventStreams!==void 0&&t.push(...n.children.inbandEventStreams),e.children.inbandEventStreams!==void 0&&t.push(...e.children.inbandEventStreams),t.length!==0)return t}function Uu({adaptationProfiles:n,essentialProperties:e,supplementalProperties:t,manifestProfiles:r,codecs:i}){if(((n!=null?n:\"\")+(r!=null?r:\"\")).indexOf(\"http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10\")!==-1&&(i===\"hvc1.2.4.L153.B0\"||i===\"hev1.2.4.L153.B0\"))return{colorDepth:10,eotf:\"pq\",colorSpace:\"rec2020\"};let o=K([...e!=null?e:[],...t!=null?t:[]],s=>s.schemeIdUri===\"urn:mpeg:mpegB:cicp:TransferCharacteristics\");if(o!==void 0)switch(o.value){case\"15\":return;case\"16\":return{eotf:\"pq\"};case\"18\":return{eotf:\"hlg\"}}if(i!==void 0&&/^vp(08|09|10)/.exec(i))return So(i)}function _i(n,e,t){var i,a,o,s,u;let r=[];for(let l of n){let d=l.attributes.id!==void 0?l.attributes.id:String(l.attributes.bitrate)+(l.attributes.height!==void 0?`-${l.attributes.height}`:\"\")+(l.attributes.width!==void 0?`-${l.attributes.width}`:\"\")+(l.attributes.mimeType!==void 0?`-${l.attributes.mimeType}`:\"\")+(l.attributes.codecs!==void 0?`-${l.attributes.codecs}`:\"\");for(;r.some(_=>_.id===d);)d+=\"-dup\";let f=(a=(i=t.unsafelyBaseOnPreviousAdaptation)==null?void 0:i.getRepresentation(d))!=null?a:null,m=Bu(l,e),p=(o=l.attributes.availabilityTimeComplete)!=null?o:t.availabilityTimeComplete,g;(l.attributes.availabilityTimeOffset!==void 0||t.availabilityTimeOffset!==void 0)&&(g=((s=l.attributes.availabilityTimeOffset)!=null?s:0)+((u=t.availabilityTimeOffset)!=null?u:0));let h=H({},t,{availabilityTimeOffset:g,availabilityTimeComplete:p,unsafelyBaseOnPreviousRepresentation:f,adaptation:e,inbandEventStreams:m}),I=Ti(l,h),y;l.attributes.bitrate===void 0?(c.warn(\"DASH: No usable bitrate found in the Representation.\"),y=0):y=l.attributes.bitrate;let E=et(t.baseURLs,l.children.baseURLs),R=E.length===0?[{baseUrl:\"\",id:void 0}]:E.map(_=>({baseUrl:_.url,id:_.serviceLocation})),T={bitrate:y,cdnMetadata:R,index:I,id:d};l.children.supplementalProperties!==void 0&&K(l.children.supplementalProperties,_=>_.schemeIdUri===\"tag:dolby.com,2018:dash:EC3_ExtensionType:2018\"&&_.value===\"JOC\")&&(T.isSpatialAudio=!0);let C;l.attributes.codecs!==void 0?C=l.attributes.codecs:e.attributes.codecs!==void 0&&(C=e.attributes.codecs),C!==void 0&&(C=C===\"mp4a.40.02\"?\"mp4a.40.2\":C,T.codecs=C);let P;l.attributes.supplementalCodecs!==void 0?P=l.attributes.supplementalCodecs:e.attributes.supplementalCodecs!==void 0&&(P=e.attributes.supplementalCodecs),P!==void 0&&(T.supplementalCodecs=bo(P)),l.attributes.frameRate!==void 0?T.frameRate=l.attributes.frameRate:e.attributes.frameRate!==void 0&&(T.frameRate=e.attributes.frameRate),l.attributes.height!==void 0?T.height=l.attributes.height:e.attributes.height!==void 0&&(T.height=e.attributes.height),l.attributes.mimeType!==void 0?T.mimeType=l.attributes.mimeType:e.attributes.mimeType!==void 0&&(T.mimeType=e.attributes.mimeType),l.attributes.width!==void 0?T.width=l.attributes.width:e.attributes.width!==void 0&&(T.width=e.attributes.width);let x=e.children.contentProtections!==void 0?e.children.contentProtections:[];if(l.children.contentProtections!==void 0&&x.push(...l.children.contentProtections),x.length>0){let _=x.reduce((A,M)=>{let k;if(M.attributes.schemeIdUri!==void 0&&M.attributes.schemeIdUri.substring(0,9)===\"urn:uuid:\"&&(k=M.attributes.schemeIdUri.substring(9).replace(/-/g,\"\").toLowerCase()),M.attributes.keyId!==void 0&&M.attributes.keyId.length>0){let D={keyId:M.attributes.keyId,systemId:k};A.keyIds===void 0?A.keyIds=[D]:A.keyIds.push(D)}if(k!==void 0){let{cencPssh:D}=M.children,w=[];for(let O of D)w.push({systemId:k,data:O});if(w.length>0){let O=K(A.initData,B=>B.type===\"cenc\");O===void 0?A.initData.push({type:\"cenc\",values:w}):O.values.push(...w)}}return A},{keyIds:void 0,initData:[]});(Object.keys(_.initData).length>0||_.keyIds!==void 0&&_.keyIds.length>0)&&(T.contentProtections=_)}T.hdrInfo=Uu({adaptationProfiles:e.attributes.profiles,supplementalProperties:e.children.supplementalProperties,essentialProperties:e.children.essentialProperties,manifestProfiles:t.manifestProfiles,codecs:C}),r.push(T)}return r}function Lu(n){if(n===void 0)return!1;let e=n.schemeIdUri===\"urn:tva:metadata:cs:AudioPurposeCS:2007\"&&n.value===\"1\",t=n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"description\";return e||t}function Fu(n,e){return!!(n!==void 0&&n.some(r=>r.schemeIdUri===\"urn:tva:metadata:cs:AudioPurposeCS:2007\"&&r.value===\"2\")||e!==void 0&&e.some(r=>r.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&r.value===\"caption\"))}function zu(n){return n===void 0?!1:n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"sign\"}function Wu(n,e){if(Z(n.attributes.id))return n.attributes.id;let{isClosedCaption:t,isForcedSubtitle:r,isAudioDescription:i,isSignInterpreted:a,isTrickModeTrack:o,type:s}=e,u=s;return Z(n.attributes.language)&&(u+=`-${n.attributes.language}`),t===!0&&(u+=\"-cc\"),r===!0&&(u+=\"-cc\"),i===!0&&(u+=\"-ad\"),a===!0&&(u+=\"-si\"),o&&(u+=\"-trickMode\"),Z(n.attributes.contentType)&&(u+=`-${n.attributes.contentType}`),Z(n.attributes.codecs)&&(u+=`-${n.attributes.codecs}`),Z(n.attributes.mimeType)&&(u+=`-${n.attributes.mimeType}`),n.attributes.frameRate!==void 0&&(u+=`-${String(n.attributes.frameRate)}`),u}function Vu(n){if(!v(n.children.supplementalProperties)){let{supplementalProperties:e}=n.children;for(let t of e)if(t.schemeIdUri===\"urn:mpeg:dash:adaptation-set-switching:2016\"&&!v(t.value))return t.value.split(\",\").map(r=>r.trim()).filter(r=>r)}return[]}function Ei(n,e){var s,u,l,d,f,m,p;let t={video:[],audio:[],text:[]},r=[],i={},a=[];for(let g=0;g<n.length;g++){let h=n[g],I=h.children,{essentialProperties:y,roles:E,label:R}=I,T=Array.isArray(E)&&E.some(be=>be.value===\"main\")&&E.some(be=>be.schemeIdUri===\"urn:mpeg:dash:role:2011\"),C=h.children.representations,P=(s=h.attributes.availabilityTimeComplete)!=null?s:e.availabilityTimeComplete,x;(h.attributes.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(x=((u=h.attributes.availabilityTimeOffset)!=null?u:0)+((l=e.availabilityTimeOffset)!=null?l:0));let _=h.attributes.mimeType,A=h.attributes.codecs,M=yi(C,Z(_)?_:null,Z(A)?A:null,v(I.roles)?null:I.roles);if(M===void 0)continue;let k=(d=h.attributes.selectionPriority)!=null?d:1,D=h.attributes.id,w=Vu(h),O=[];e.segmentTemplate!==void 0&&O.push(e.segmentTemplate),h.children.segmentTemplate!==void 0&&O.push(h.children.segmentTemplate);let B={availabilityTimeComplete:P,availabilityTimeOffset:x,baseURLs:et(e.baseURLs,I.baseURLs),manifestBoundsCalculator:e.manifestBoundsCalculator,end:e.end,isDynamic:e.isDynamic,isLastPeriod:e.isLastPeriod,manifestProfiles:e.manifestProfiles,parentSegmentTemplates:O,receivedTime:e.receivedTime,start:e.start,unsafelyBaseOnPreviousAdaptation:null},z=Array.isArray(y)?K(y,be=>be.schemeIdUri===\"http://dashif.org/guidelines/trickmode\"):void 0,q=(f=z==null?void 0:z.value)==null?void 0:f.split(\" \"),J=q!==void 0,{accessibilities:$}=I,V;E!==void 0&&E.some(be=>be.value===\"dub\")&&(V=!0);let Y;M!==\"text\"?Y=!1:Y=Fu($,E);let X;M===\"text\"&&E!==void 0&&E.some(be=>be.value===\"forced-subtitle\"||be.value===\"forced_subtitle\")&&(X=!0);let me;M!==\"audio\"?me=!1:$!==void 0&&(me=$.some(Lu));let ce;M!==\"video\"?ce=!1:$!==void 0&&(ce=$.some(zu));let de=Wu(h,{isAudioDescription:me,isForcedSubtitle:X,isClosedCaption:Y,isSignInterpreted:ce,isTrickModeTrack:J,type:M});for(;se(a,de);)de+=\"-dup\";let Ie=de;a.push(de),B.unsafelyBaseOnPreviousAdaptation=(p=(m=e.unsafelyBaseOnPreviousPeriod)==null?void 0:m.getAdaptation(de))!=null?p:null;let Jn=_i(C,h,B),pe={id:de,representations:Jn,type:M,isTrickModeTrack:J};if(v(h.attributes.language)||(pe.language=h.attributes.language),v(Y)||(pe.closedCaption=Y),v(me)||(pe.audioDescription=me),V===!0&&(pe.isDub=!0),X!==void 0&&(pe.forcedSubtitles=X),ce===!0&&(pe.isSignInterpreted=!0),R!==void 0&&(pe.label=R),q!==void 0)r.push({adaptation:pe,trickModeAttachedAdaptationIds:q});else{let be=-1;for(let Kt of w){let He=i[Kt];if(He!==void 0&&He.newID!==Ie&&se(He.adaptationSetSwitchingIDs,D)){be=ne(t[M],xt=>xt[0].id===Kt);let xe=t[M][be];if(xe!==void 0&&xe[0].audioDescription===pe.audioDescription&&xe[0].closedCaption===pe.closedCaption&&xe[0].language===pe.language){c.info('DASH Parser: merging \"switchable\" AdaptationSets',D,Kt),xe[0].representations.push(...pe.representations),xe[1]={priority:Math.max(k,xe[1].priority),isMainAdaptation:T||xe[1].isMainAdaptation,indexInMpd:Math.min(g,xe[1].indexInMpd)};break}}}be<0&&t[M].push([pe,{priority:k,isMainAdaptation:T,indexInMpd:g}])}!v(D)&&v(i[D])&&(i[D]={newID:Ie,adaptationSetSwitchingIDs:w})}let o=Ot.reduce((g,h)=>{let I=t[h];return I.length>0&&(I.sort(yo),g[h]=I.map(([y])=>y)),g},{});return t.video.sort(yo),Io(o,r),o}function yo(n,e){let t=e[1].priority-n[1].priority;return t!==0?t:n[1].isMainAdaptation!==e[1].isMainAdaptation?n[1].isMainAdaptation?-1:1:n[1].indexInMpd-e[1].indexInMpd}var qu=Ae();function Ri(n,e){var o,s,u,l;let t=[],r=Si(n,e);if(r.length!==n.length)throw new Error(\"MPD parsing error: the time information are incoherent.\");let{isDynamic:i,manifestBoundsCalculator:a}=e;!i&&!v(e.duration)&&a.setLastPosition(e.duration);for(let d=n.length-1;d>=0;d--){let f=d===n.length-1,m=n[d],p=e.xlinkInfos.get(m),g=et(e.baseURLs,m.children.baseURLs),{periodStart:h,periodDuration:I,periodEnd:y}=r[d],E;for(v(m.attributes.id)?(c.warn(\"DASH: No usable id found in the Period. Generating one.\"),E=\"gen-dash-period-\"+qu()):E=m.attributes.id;t.some(O=>O.id===E);)E+=\"-dup\";let R=p!==void 0?p.receivedTime:e.receivedTime,T=(s=(o=e.unsafelyBaseOnPreviousManifest)==null?void 0:o.getPeriod(E))!=null?s:null,C=m.attributes.availabilityTimeComplete,P=m.attributes.availabilityTimeOffset,{manifestProfiles:x}=e,{segmentTemplate:_}=m.children,A={availabilityTimeComplete:C,availabilityTimeOffset:P,baseURLs:g,manifestBoundsCalculator:a,end:y,isDynamic:i,isLastPeriod:f,manifestProfiles:x,receivedTime:R,segmentTemplate:_,start:h,unsafelyBaseOnPreviousPeriod:T},M=Ei(m.children.adaptations,A),k=((u=e.xmlNamespaces)!=null?u:[]).concat((l=m.attributes.namespaces)!=null?l:[]),D=Gu(m.children.eventStreams,h,k),w={id:E,start:h,end:y,duration:I,adaptations:M,streamEvents:D};if(t.unshift(w),!a.lastPositionIsKnown()){let O=Hu(M);if(!i)typeof O==\"number\"&&a.setLastPosition(O);else if(typeof O==\"number\"){let B=L()/1e3;a.setLastPosition(O,B)}else{let B=To(e,h);if(B!==void 0){let[z,q]=B;a.setLastPosition(z,q)}}}}if(e.isDynamic&&!a.lastPositionIsKnown()){let d=To(e,0);if(d!==void 0){let[f,m]=d;a.setLastPosition(f,m)}}return bi(t)}function To(n,e){if(v(n.clockOffset)){let t=Date.now()/1e3;if(t>=e){c.warn(\"DASH Parser: no clock synchronization mechanism found. Using the system clock instead.\");let r=t-n.availabilityStartTime,i=L()/1e3;return[r,i]}}else{let t=n.clockOffset/1e3-n.availabilityStartTime,r=L()/1e3,i=r+t;if(i>=e)return[i,r]}}function Hu(n){let e=null,t=!0,r=ar(n).filter(a=>!v(a)),i=hi(r,a=>a);for(let a of i){let o=a.representations;for(let s of o){let u=s.index.getLastAvailablePosition();u!==null&&(t=!1,typeof u==\"number\"&&(e=v(e)?u:Math.max(e,u)))}}if(v(e)){if(t)return null}else return e}function Gu(n,e,t){var i,a;let r=[];for(let o of n){let{schemeIdUri:s=\"\",timescale:u=1}=o.attributes,l=t.concat((i=o.attributes.namespaces)!=null?i:[]);for(let d of o.children.events)if(d.eventStreamData!==void 0){let f=((a=d.presentationTime)!=null?a:0)/u+e,m=d.duration===void 0?void 0:f+d.duration/u,p,g;if(!ot&&d.eventStreamData instanceof Element)p=d.eventStreamData;else try{g={namespaces:l,data:typeof d.eventStreamData==\"string\"?d.eventStreamData:Be(new Uint8Array(d.eventStreamData))}}catch(h){c.error(\"DASH: Error while parsing event-stream:\",h instanceof Error?h.message:\"Unknown error\")}r.push({start:f,end:m,id:d.id,data:{type:\"dash-event-stream\",value:{schemeIdUri:s,timescale:u,element:p,xmlData:g}}})}}return r}function Nt(n,e,t,r,i=new WeakMap){let{children:a,attributes:o}=n;if(v(e.externalClockOffset)){let u=o.type===\"dynamic\",l=K(a.utcTimings,m=>m.schemeIdUri===\"urn:mpeg:dash:utc:direct:2014\"&&!v(m.value)),d=!v(l)&&!v(l.value)?mr(l.value):void 0,f=!v(d)&&!isNaN(d)?d:void 0;if(!v(f)&&r!==!0)e.externalClockOffset=f;else if(u&&r!==!0){let m=fi(n);if(!v(m)&&m.length>0)return{type:\"needs-clock\",value:{url:m,continue:function(g){return g.success?(e.externalClockOffset=mr(g.data),Nt(n,e,t,!0)):(t.push(g.error),c.warn(\"DASH Parser: Error on fetching the clock ressource\",g.error),Nt(n,e,t,!0))}}}}}let s=[];for(let u=0;u<a.periods.length;u++){let{xlinkHref:l,xlinkActuate:d}=a.periods[u].attributes;!v(l)&&d===\"onLoad\"&&s.push({index:u,ressource:l})}return s.length===0?Ku(n,e,t,i):{type:\"needs-xlinks\",value:{xlinksUrls:s.map(({ressource:u})=>u),continue:function(l){if(l.length!==s.length)throw new Error(\"DASH parser: wrong number of loaded ressources.\");for(let d=l.length-1;d>=0;d--){let f=s[d].index,{parsed:m,warnings:p,receivedTime:g,sendingTime:h,url:I}=l[d];p.length>0&&t.push(...p);for(let y of m)i.set(y,{receivedTime:g,sendingTime:h,url:I});a.periods.splice(f,1,...m)}return Nt(n,e,t,r,i)}}}}function Ku(n,e,t,r){var D,w,O,B;let{children:i,attributes:a}=n,o=a.type===\"dynamic\",s=e.url!==void 0?[{url:e.url.substring(0,li(e.url))}]:[],u=et(s,i.baseURLs),l=gi(a,e.referenceDateTime),d=a.timeShiftBufferDepth,{externalClockOffset:f,unsafelyBaseOnPreviousManifest:m}=e,{externalClockOffset:p}=e,g=new un({availabilityStartTime:l,isDynamic:o,timeShiftBufferDepth:d,serverTimestampOffset:p}),h={availabilityStartTime:l,baseURLs:u,clockOffset:f,duration:a.duration,isDynamic:o,manifestBoundsCalculator:g,manifestProfiles:n.attributes.profiles,receivedTime:e.manifestReceivedTime,timeShiftBufferDepth:d,unsafelyBaseOnPreviousManifest:m,xlinkInfos:r,xmlNamespaces:n.attributes.namespaces},I=Ri(i.periods,h),y=a.duration,E,R,T=null,C;a.minimumUpdatePeriod!==void 0&&a.minimumUpdatePeriod>=0&&(E=a.minimumUpdatePeriod===0?U.getCurrent().DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:a.minimumUpdatePeriod);let{minimumSafePosition:P,maximumSafePosition:x,maximumUnsafePosition:_}=pi(I),A=L();if(o){let z;x!==void 0?z=x:p===void 0?(c.warn(\"DASH Parser: use system clock to define maximum position\"),z=Date.now()/1e3-l):z=(L()+p)/1e3-l;let q=g.getEstimatedLiveEdge();q===void 0&&(_!==void 0?q=_:q=z),C={isLinear:!0,maximumSafePosition:z,livePosition:q,time:A},R=P,T=d!=null?d:null,T!==null&&R!==void 0&&q-R>T&&(T=q-R)}else{R=P,R===void 0&&(R=(w=(D=I[0])==null?void 0:D.start)!=null?w:0);let z=y!=null?y:1/0;if(I[I.length-1]!==void 0){let q=I[I.length-1],J=(O=q.end)!=null?O:q.duration!==void 0?q.start+q.duration:void 0;J!==void 0&&J<z&&(z=J)}x!==void 0&&x<z&&(z=x),C={isLinear:!1,maximumSafePosition:z,livePosition:void 0,time:A}}let M=!o||n.attributes.minimumUpdatePeriod===void 0&&(((B=I[I.length-1])==null?void 0:B.end)!==void 0||n.attributes.duration!==void 0);return{type:\"done\",value:{parsed:{availabilityStartTime:l,clockOffset:e.externalClockOffset,isDynamic:o,isLive:o,isLastPeriodKnown:M,periods:I,publishTime:a.publishTime,suggestedPresentationDelay:a.suggestedPresentationDelay,transportType:\"dash\",timeBounds:{minimumSafePosition:R,timeshiftDepth:T,maximumTimeData:C},lifetime:E,uris:v(e.url)?i.locations:[e.url,...i.locations]},warnings:t}}}var gr=Nt;function Ye(n,e,t){if(typeof String.prototype.startsWith==\"function\")return n.startsWith(e,t);let r=typeof t==\"number\"?Math.max(t,0):0;return n.substring(r,r+e.length)===e}var _o=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51];function hr(n){if(n>=_o.length)throw new Error(\"Unable to parse base64 string.\");let e=_o[n];if(e===255)throw new Error(\"Unable to parse base64 string.\");return e}function Ir(n){let e=n.length%4,t=n;e!==0&&(c.warn(\"base64ToBytes: base64 given miss padding\"),t+=e===3?\"=\":e===2?\"==\":\"===\");let r=t.indexOf(\"=\");if(r!==-1&&r<t.length-2)throw new Error(\"Unable to parse base64 string.\");let i=t.endsWith(\"==\")?2:t.endsWith(\"=\")?1:0,a=t.length,o=new Uint8Array(a/4*3),s;for(let u=0,l=0;u<a;u+=4,l+=3)s=hr(t.charCodeAt(u))<<18|hr(t.charCodeAt(u+1))<<12|hr(t.charCodeAt(u+2))<<6|hr(t.charCodeAt(u+3)),o[l]=s>>16,o[l+1]=s>>8&255,o[l+2]=s&255;return o.subarray(0,o.length-i)}var ju=/^P(([\\d.]*)Y)?(([\\d.]*)M)?(([\\d.]*)D)?T?(([\\d.]*)H)?(([\\d.]*)M)?(([\\d.]*)S)?/,Yu=/([0-9]+)-([0-9]+)/;function ve(n,e){return n===\"true\"?[!0,null]:n===\"false\"?[!1,null]:[!1,new Me(`\\`${e}\\` property is not a boolean value but \"${n}\"`)]}function ee(n,e){let t=parseInt(n,10);return isNaN(t)?[null,new Me(`\\`${e}\\` property is not an integer value but \"${n}\"`)]:[t,null]}function ke(n,e){if(n===\"INF\")return[1/0,null];let t=parseFloat(n);return isNaN(t)?[null,new Me(`\\`${e}\\` property is invalid: \"${n}\"`)]:[t,null]}function Pi(n,e){if(n===\"true\")return[!0,null];if(n===\"false\")return[!1,null];let t=parseInt(n,10);return isNaN(t)?[null,new Me(`\\`${e}\\` property is not a boolean nor an integer but \"${n}\"`)]:[t,null]}function br(n,e){let t=Date.parse(n);return isNaN(t)?[null,new Me(`\\`${e}\\` is in an invalid date format: \"${n}\"`)]:[new Date(Date.parse(n)).getTime()/1e3,null]}function We(n,e){if(!Z(n))return[0,new Me(`\\`${e}\\` property is empty`)];let t=ju.exec(n);return t===null?[null,new Me(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[parseFloat(Z(t[2])?t[2]:\"0\")*365*24*60*60+parseFloat(Z(t[4])?t[4]:\"0\")*30*24*60*60+parseFloat(Z(t[6])?t[6]:\"0\")*24*60*60+parseFloat(Z(t[8])?t[8]:\"0\")*60*60+parseFloat(Z(t[10])?t[10]:\"0\")*60+parseFloat(Z(t[12])?t[12]:\"0\"),null]}function Et(n,e){let t=Yu.exec(n);return t===null?[null,new Me(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[[+t[1],+t[2]],null]}function Eo(n,e){try{return[Ir(n),null]}catch(t){return[null,new Me(`\\`${e}\\` is not a valid base64 string: \"${n}\"`)]}}function Bt(n,e){let t=/^(\\d+)\\/(\\d+)$/.exec(n);return t!==null?[+t[1]/+t[2],null]:ke(n,e)}function ye(n){let e,t;for(let r of Object.keys(n.attributes)){let i=n.attributes[r];if(!v(i))switch(r){case\"schemeIdUri\":e=i;break;case\"value\":t=i;break}}return{schemeIdUri:e,value:t}}function fe(n,e){return function(t,{asKey:r,parser:i,dashName:a}){let[o,s]=i(t,a);s!==null&&(c.warn(s.message),e.push(s)),o!==null&&(n[r]=o)}}var Me=class n extends Error{constructor(e){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"MPDError\",this.message=e}};function mt(n){return ur(n)}function tt(n){let e=typeof n==\"string\"?n:mt(n.children),t=[];return e===null||e.length===0?[void 0,t]:[{value:e},t]}function vi(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!v(r))switch(t){case\"id\":e.id=r;break;case\"lang\":e.language=r;break;case\"contentType\":e.contentType=r;break;case\"par\":e.par=r;break}}return e}function Qu(n){let e=[],t=[];for(let r=0;r<n.length;r++){let i=n[r];if(typeof i!=\"string\"&&i.tagName===\"cenc:pssh\"){let a=mt(i.children);if(a!==null&&a.length>0){let[o,s]=Eo(a,\"cenc:pssh\");s!==null&&(c.warn(s.message),e.push(s)),o!==null&&t.push(o)}}}return[{cencPssh:t},e]}function $u(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!v(r))switch(t){case\"schemeIdUri\":e.schemeIdUri=r;break;case\"value\":e.value=r;break;case\"cenc:default_KID\":e.keyId=ln(r.replace(/-/g,\"\"))}}return e}function fn(n){let[e,t]=Qu(n.children),r=$u(n);return[{children:e,attributes:r},t]}function Ci(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"range\":r(a,{asKey:\"range\",parser:Et,dashName:\"range\"});break;case\"sourceURL\":e.media=a;break}}return[e,t]}function nt(n){let e={},t=[],r=fe(e,t),i=n.children;for(let a=0;a<i.length;a++){let o=i[a];if(typeof o!=\"string\"&&o.tagName===\"Initialization\"){let[s,u]=Ci(o);e.initialization=s,t=t.concat(u)}}for(let a of Object.keys(n.attributes)){let o=n.attributes[a];if(!v(o))switch(a){case\"timescale\":r(o,{asKey:\"timescale\",parser:ee,dashName:\"timescale\"});break;case\"presentationTimeOffset\":r(o,{asKey:\"presentationTimeOffset\",parser:ke,dashName:\"presentationTimeOffset\"});break;case\"indexRange\":r(o,{asKey:\"indexRange\",parser:Et,dashName:\"indexRange\"});break;case\"indexRangeExact\":r(o,{asKey:\"indexRangeExact\",parser:ve,dashName:\"indexRangeExact\"});break;case\"availabilityTimeOffset\":r(o,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(o,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break;case\"duration\":r(o,{asKey:\"duration\",parser:ee,dashName:\"duration\"});break;case\"startNumber\":r(o,{asKey:\"startNumber\",parser:ee,dashName:\"startNumber\"});break;case\"endNumber\":r(o,{asKey:\"endNumber\",parser:ee,dashName:\"endNumber\"});break}}return[e,t]}function Ai(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"media\":e.media=a;break;case\"indexRange\":r(a,{asKey:\"indexRange\",parser:Et,dashName:\"indexRange\"});break;case\"index\":e.index=a;break;case\"mediaRange\":r(a,{asKey:\"mediaRange\",parser:Et,dashName:\"mediaRange\"});break}}return[e,t]}function mn(n){let[e,t]=nt(n),r=t,i=[],a=n.children;for(let s=0;s<a.length;s++){let u=a[s];if(typeof u!=\"string\"&&u.tagName===\"SegmentURL\"){let[l,d]=Ai(u);i.push(l),r=r.concat(d)}}return[H(e,{list:i}),r]}function ki(n){let e=n.children;return function(){for(let t=e.length-1;t>=0;t--){let r=e[t];(typeof r==\"string\"||r.tagName!==\"S\")&&e.splice(t,1)}return e}}function Rt(n){let[e,t]=nt(n),r=t,i;for(let s=0;s<n.children.length;s++){let u=n.children[s];typeof u!=\"string\"&&u.tagName===\"SegmentTimeline\"&&(i=ki(u))}let a=H({},e,{duration:e.duration,timelineParser:i}),o=fe(a,r);for(let s of Object.keys(n.attributes)){let u=n.attributes[s];if(!v(u))switch(s){case\"initialization\":v(a.initialization)&&(a.initialization={media:u});break;case\"index\":a.index=u;break;case\"availabilityTimeOffset\":o(u,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":o(u,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break;case\"media\":a.media=u;break;case\"bitstreamSwitching\":o(u,{asKey:\"bitstreamSwitching\",parser:ve,dashName:\"bitstreamSwitching\"});break}}return[a,r]}function Xu(n){let e={baseURLs:[]},t=[],r=[];for(let i=0;i<n.length;i++){let a=n[i];if(typeof a!=\"string\")switch(a.tagName){case\"BaseURL\":let[o,s]=tt(a);o!==void 0&&e.baseURLs.push(o),r=r.concat(s);break;case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(ye(a));break;case\"SegmentBase\":let[u,l]=nt(a);e.segmentBase=u,l.length>0&&(r=r.concat(l));break;case\"SegmentList\":let[d,f]=mn(a);r=r.concat(f),e.segmentList=d;break;case\"SegmentTemplate\":let[m,p]=Rt(a);r=r.concat(p),e.segmentTemplate=m;break;case\"ContentProtection\":let[g,h]=fn(a);h.length>0&&(r=r.concat(h)),g!==void 0&&t.push(g);break;case\"SupplementalProperty\":v(e.supplementalProperties)?e.supplementalProperties=[ye(a)]:e.supplementalProperties.push(ye(a));break}}return t.length>0&&(e.contentProtections=t),[e,r]}function Zu(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"audioSamplingRate\":e.audioSamplingRate=a;break;case\"bandwidth\":r(a,{asKey:\"bitrate\",parser:ee,dashName:\"bandwidth\"});break;case\"codecs\":e.codecs=a;break;case\"codingDependency\":r(a,{asKey:\"codingDependency\",parser:ve,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Bt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ee,dashName:\"height\"});break;case\"id\":e.id=a;break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:ke,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:ke,dashName:\"maximumSAPPeriod\"});break;case\"mimeType\":e.mimeType=a;break;case\"profiles\":e.profiles=a;break;case\"qualityRanking\":r(a,{asKey:\"qualityRanking\",parser:ee,dashName:\"qualityRanking\"});break;case\"scte214:supplementalCodecs\":e.supplementalCodecs=a;break;case\"segmentProfiles\":e.segmentProfiles=a;break;case\"width\":r(a,{asKey:\"width\",parser:ee,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break}}return e.bitrate===void 0&&t.push(new Me(\"No bitrate found on a Representation\")),[e,t]}function Ro(n){let[e,t]=Xu(n.children),[r,i]=Zu(n),a=t.concat(i);return[{children:e,attributes:r},a]}function Ju(n){let e={baseURLs:[],representations:[]},t=[],r=[];for(let i=0;i<n.length;i++){let a=n[i];if(typeof a!=\"string\")switch(a.tagName){case\"Accessibility\":e.accessibilities===void 0?e.accessibilities=[ye(a)]:e.accessibilities.push(ye(a));break;case\"BaseURL\":let[o,s]=tt(a);o!==void 0&&e.baseURLs.push(o),s.length>0&&(r=r.concat(s));break;case\"ContentComponent\":e.contentComponent=vi(a);break;case\"EssentialProperty\":v(e.essentialProperties)?e.essentialProperties=[ye(a)]:e.essentialProperties.push(ye(a));break;case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(ye(a));break;case\"Label\":let u=mt(a.children);u!=null&&(e.label=u);break;case\"Representation\":let[l,d]=Ro(a);e.representations.push(l),d.length>0&&(r=r.concat(d));break;case\"Role\":v(e.roles)?e.roles=[ye(a)]:e.roles.push(ye(a));break;case\"SupplementalProperty\":v(e.supplementalProperties)?e.supplementalProperties=[ye(a)]:e.supplementalProperties.push(ye(a));break;case\"SegmentBase\":let[f,m]=nt(a);e.segmentBase=f,m.length>0&&(r=r.concat(m));break;case\"SegmentList\":let[p,g]=mn(a);e.segmentList=p,g.length>0&&(r=r.concat(g));break;case\"SegmentTemplate\":let[h,I]=Rt(a);e.segmentTemplate=h,I.length>0&&(r=r.concat(I));break;case\"ContentProtection\":let[y,E]=fn(a);E.length>0&&(r=r.concat(E)),y!==void 0&&t.push(y);break}}return t.length>0&&(e.contentProtections=t),[e,r]}function ed(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"id\":e.id=a;break;case\"group\":r(a,{asKey:\"group\",parser:ee,dashName:\"group\"});break;case\"lang\":e.language=a;break;case\"contentType\":e.contentType=a;break;case\"par\":e.par=a;break;case\"minBandwidth\":r(a,{asKey:\"minBitrate\",parser:ee,dashName:\"minBandwidth\"});break;case\"maxBandwidth\":r(a,{asKey:\"maxBitrate\",parser:ee,dashName:\"maxBandwidth\"});break;case\"minWidth\":r(a,{asKey:\"minWidth\",parser:ee,dashName:\"minWidth\"});break;case\"maxWidth\":r(a,{asKey:\"maxWidth\",parser:ee,dashName:\"maxWidth\"});break;case\"minHeight\":r(a,{asKey:\"minHeight\",parser:ee,dashName:\"minHeight\"});break;case\"maxHeight\":r(a,{asKey:\"maxHeight\",parser:ee,dashName:\"maxHeight\"});break;case\"minFrameRate\":r(a,{asKey:\"minFrameRate\",parser:Bt,dashName:\"minFrameRate\"});break;case\"maxFrameRate\":r(a,{asKey:\"maxFrameRate\",parser:Bt,dashName:\"maxFrameRate\"});break;case\"selectionPriority\":r(a,{asKey:\"selectionPriority\",parser:ee,dashName:\"selectionPriority\"});break;case\"segmentAlignment\":r(a,{asKey:\"segmentAlignment\",parser:Pi,dashName:\"segmentAlignment\"});break;case\"subsegmentAlignment\":r(a,{asKey:\"subsegmentAlignment\",parser:Pi,dashName:\"subsegmentAlignment\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:ve,dashName:\"bitstreamSwitching\"});break;case\"audioSamplingRate\":e.audioSamplingRate=a;break;case\"codecs\":e.codecs=a;break;case\"scte214:supplementalCodecs\":e.supplementalCodecs=a;break;case\"codingDependency\":r(a,{asKey:\"codingDependency\",parser:ve,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Bt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ee,dashName:\"height\"});break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:ke,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:ke,dashName:\"maximumSAPPeriod\"});break;case\"mimeType\":e.mimeType=a;break;case\"profiles\":e.profiles=a;break;case\"segmentProfiles\":e.segmentProfiles=a;break;case\"width\":r(a,{asKey:\"width\",parser:ee,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break}}return[e,t]}function Po(n){let e=n.children,[t,r]=Ju(e),[i,a]=ed(n),o=r.concat(a);return[{children:t,attributes:i},o]}function td(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"schemeIdUri\":e.schemeIdUri=a;break;case\"value\":e.value=a;break;case\"timescale\":r(a,{asKey:\"timescale\",parser:ee,dashName:\"timescale\"});break;default:Ye(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function vo(n,e){let[t,r]=td(n),i=[];for(let a of n.children)if(typeof a!=\"string\"&&a.tagName===\"Event\"){let o={};if(v(a.attributes.id)||(o.id=a.attributes.id),!v(a.attributes.presentationTime)){let[s,u]=ee(a.attributes.presentationTime,\"presentationTime\");u!==null&&r.push(u),s!==null&&(o.presentationTime=s)}if(!v(a.attributes.duration)){let[s,u]=ee(a.attributes.duration,\"duration\");u!==null&&r.push(u),s!==null&&(o.duration=s)}if(a.posStart<a.posEnd){let s=e.substring(a.posStart,a.posEnd);o.eventStreamData=s}i.push(o)}return[{children:{events:i},attributes:t},r]}function nd(n,e){let t=[],r=[],i,a=[],o=[];for(let s=0;s<n.length;s++){let u=n[s];if(typeof u!=\"string\")switch(u.tagName){case\"BaseURL\":let[l,d]=tt(u);l!==void 0&&t.push(l),a=a.concat(d);break;case\"AdaptationSet\":let[f,m]=Po(u);r.push(f),a=a.concat(m);break;case\"EventStream\":let[p,g]=vo(u,e);o.push(p),a=a.concat(g);break;case\"SegmentTemplate\":let[h,I]=Rt(u);i=h,I.length>0&&(a=a.concat(I));break}}return[{baseURLs:t,adaptations:r,eventStreams:o,segmentTemplate:i},a]}function rd(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"id\":e.id=a;break;case\"start\":r(a,{asKey:\"start\",parser:We,dashName:\"start\"});break;case\"duration\":r(a,{asKey:\"duration\",parser:We,dashName:\"duration\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:ve,dashName:\"bitstreamSwitching\"});break;case\"xlink:href\":e.xlinkHref=a;break;case\"xlink:actuate\":e.xlinkActuate=a;break;default:Ye(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Sr(n,e){let[t,r]=nd(n.children,e),[i,a]=rd(n),o=r.concat(a);return[{children:t,attributes:i},o]}function id(n,e){let t=[],r=[],i=[],a=[],o=[];for(let s=0;s<n.length;s++){let u=n[s];if(typeof u!=\"string\")switch(u.tagName){case\"BaseURL\":let[l,d]=tt(u);l!==void 0&&t.push(l),o=o.concat(d);break;case\"Location\":r.push(mt(u.children));break;case\"Period\":let[f,m]=Sr(u,e);i.push(f),o=o.concat(m);break;case\"UTCTiming\":let p=ye(u);a.push(p);break}}return[{baseURLs:t,locations:r,periods:i,utcTimings:a},o]}function ad(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"id\":e.id=a;break;case\"profiles\":e.profiles=a;break;case\"type\":e.type=a;break;case\"availabilityStartTime\":r(a,{asKey:\"availabilityStartTime\",parser:br,dashName:\"availabilityStartTime\"});break;case\"availabilityEndTime\":r(a,{asKey:\"availabilityEndTime\",parser:br,dashName:\"availabilityEndTime\"});break;case\"publishTime\":r(a,{asKey:\"publishTime\",parser:br,dashName:\"publishTime\"});break;case\"mediaPresentationDuration\":r(a,{asKey:\"duration\",parser:We,dashName:\"mediaPresentationDuration\"});break;case\"minimumUpdatePeriod\":r(a,{asKey:\"minimumUpdatePeriod\",parser:We,dashName:\"minimumUpdatePeriod\"});break;case\"minBufferTime\":r(a,{asKey:\"minBufferTime\",parser:We,dashName:\"minBufferTime\"});break;case\"timeShiftBufferDepth\":r(a,{asKey:\"timeShiftBufferDepth\",parser:We,dashName:\"timeShiftBufferDepth\"});break;case\"suggestedPresentationDelay\":r(a,{asKey:\"suggestedPresentationDelay\",parser:We,dashName:\"suggestedPresentationDelay\"});break;case\"maxSegmentDuration\":r(a,{asKey:\"maxSegmentDuration\",parser:We,dashName:\"maxSegmentDuration\"});break;case\"maxSubsegmentDuration\":r(a,{asKey:\"maxSubsegmentDuration\",parser:We,dashName:\"maxSubsegmentDuration\"});break;default:Ye(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Co(n,e){let[t,r]=id(n.children,e),[i,a]=ad(n),o=r.concat(a);return[{children:t,attributes:i},o]}function xi(n,e){let t=ni(n),r=t[t.length-1];if(r===void 0||typeof r==\"string\"||r.tagName!==\"MPD\")throw new Error(\"DASH Parser: document root should be MPD\");let[i,a]=Co(r,n),o=gr(i,e,a);return s(o);function s(u){if(u.type===\"done\")return u;if(u.type===\"needs-clock\")return{type:\"needs-resources\",value:{urls:[u.value.url],format:\"string\",continue(l){if(l.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let d=u.value.continue(l[0].responseData);return s(d)}}};if(u.type===\"needs-xlinks\")return{type:\"needs-resources\",value:{urls:u.value.xlinksUrls,format:\"string\",continue(l){let d=[];for(let m=0;m<l.length;m++){let{responseData:p,receivedTime:g,sendingTime:h,url:I}=l[m];if(!p.success)throw p.error;let y=\"<root>\"+p.data+\"</root>\",E=ni(y),R=E[E.length-1];if(R===void 0||typeof R==\"string\")throw new Error(\"DASH parser: Invalid external ressources\");let T=R.children,C=[],P=[];for(let x=0;x<T.length;x++){let _=T[x];if(typeof _==\"string\"||_.tagName!==\"Period\")continue;let[A,M]=Sr(_,y);P.push(...M),C.push(A)}d.push({url:I,receivedTime:g,sendingTime:h,parsed:C,warnings:P})}let f=u.value.continue(d);return s(f)}}};ze(u)}}var Ao=xi;var od=typeof WebAssembly==\"object\"&&typeof WebAssembly.instantiate==\"function\",ko=od;function F(n,e,t,r){let i=new Uint8Array(e,t,r);return n.decode(i)}function Mi(n){return n===1/0?!0:n===-1/0?!1:n}function ct(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.value=F(t,e.buffer,a,o))}}function xo(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 60:n.language=F(t,e.buffer,a,o);break;case 61:n.contentType=F(t,e.buffer,a,o);break;case 62:n.par=F(t,e.buffer,a,o);break}}}function yr(n,e){let t=n.attributes,r=n.children,i=new TextDecoder;return function(o,s,u){switch(o){case 16:t.schemeIdUri=F(i,e.buffer,s,u);break;case 13:t.value=F(i,e.buffer,s,u);break;case 14:let l=F(i,e.buffer,s,u);t.keyId=ln(l.replace(/-/g,\"\"));break;case 15:try{let d=F(i,e.buffer,s,u);r.cencPssh.push(Ir(d))}catch(d){}break}}}function Ve(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 16:n.schemeIdUri=F(t,e.buffer,a,o);break;case 17:n.value=F(t,e.buffer,a,o);break}}}function Ut(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 29:{let s=new DataView(e.buffer);n.initialization===void 0&&(n.initialization={}),n.initialization.range=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 67:n.initialization===void 0&&(n.initialization={}),n.initialization.media=F(t,e.buffer,a,o);break;case 43:{let s=new DataView(e.buffer);n.availabilityTimeOffset=s.getFloat64(a,!0);break}case 22:{n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break}case 24:{let s=new DataView(e.buffer);n.presentationTimeOffset=s.getFloat64(a,!0);break}case 27:{let s=new DataView(e.buffer);n.timescale=s.getFloat64(a,!0);break}case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 23:{n.indexRangeExact=new DataView(e.buffer).getUint8(0)===0;break}case 1:{let s=new DataView(e.buffer);n.duration=s.getFloat64(a,!0);break}case 20:{let s=new DataView(e.buffer);n.startNumber=s.getFloat64(a,!0);break}case 76:{let s=new DataView(e.buffer);n.endNumber=s.getFloat64(a,!0);break}}}}function Mo(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 28:n.index=F(t,e.buffer,a,o);break;case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 30:n.media=F(t,e.buffer,a,o);break;case 18:{let s=new DataView(e.buffer);n.mediaRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}}}}function Tr(n,e,t){return function(i){switch(i){case 20:{let a={};n.list===void 0&&(n.list=[]),n.list.push(a);let o=Mo(a,e);t.pushParsers(i,N,o);break}default:t.pushParsers(i,N,N);break}}}function Lt(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 19:{let s=new DataView(e.buffer);n.timeline=[];let u=a;for(let l=0;l<o/24;l++)n.timeline.push({start:s.getFloat64(u,!0),duration:s.getFloat64(u+8,!0),repeatCount:s.getFloat64(u+16,!0)}),u+=24;break}case 67:n.initialization={media:F(t,e.buffer,a,o)};break;case 28:n.index=F(t,e.buffer,a,o);break;case 43:{let s=new DataView(e.buffer);n.availabilityTimeOffset=s.getFloat64(a,!0);break}case 22:{n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break}case 24:{let s=new DataView(e.buffer);n.presentationTimeOffset=s.getFloat64(a,!0);break}case 27:{let s=new DataView(e.buffer);n.timescale=s.getFloat64(a,!0);break}case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 23:{n.indexRangeExact=new DataView(e.buffer).getUint8(0)===0;break}case 30:n.media=F(t,e.buffer,a,o);break;case 32:{n.bitstreamSwitching=new DataView(e.buffer).getUint8(0)===0;break}case 1:{let s=new DataView(e.buffer);n.duration=s.getFloat64(a,!0);break}case 20:{let s=new DataView(e.buffer);n.startNumber=s.getFloat64(a,!0);break}case 76:{let s=new DataView(e.buffer);n.endNumber=s.getFloat64(a,!0);break}}}}function Oo(n,e,t){return function(i){switch(i){case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a),t.pushParsers(i,N,ct(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=yr(a,e);t.pushParsers(i,N,o);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a),t.pushParsers(i,N,Ve(a,e));break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=Ve(a,e);t.pushParsers(i,N,o);break}case 17:{let a={};n.segmentBase=a;let o=Ut(a,e);t.pushParsers(i,N,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Tr(a,e,t),s=Ut(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,N,Lt(a,e));break}default:t.pushParsers(i,N,N);break}}}function wo(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 3:n.audioSamplingRate=F(t,e.buffer,a,o);break;case 63:n.bitrate=s.getFloat64(a,!0);break;case 4:n.codecs=F(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=F(t,e.buffer,a,o);break;case 5:n.codingDependency=new DataView(e.buffer).getUint8(0)===0;break;case 6:n.frameRate=s.getFloat64(a,!0);break;case 7:n.height=s.getFloat64(a,!0);break;case 8:n.width=s.getFloat64(a,!0);break;case 9:n.maxPlayoutRate=s.getFloat64(a,!0);break;case 10:n.maximumSAPPeriod=s.getFloat64(a,!0);break;case 11:n.mimeType=F(t,e.buffer,a,o);break;case 2:n.profiles=F(t,e.buffer,a,o);break;case 65:n.qualityRanking=s.getFloat64(a,!0);break;case 12:n.segmentProfiles=F(t,e.buffer,a,o);break;case 43:n.availabilityTimeOffset=s.getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=s.getUint8(0)===0;break}}}function Do(n,e,t){return function(i){switch(i){case 8:{let a={};n.accessibilities===void 0&&(n.accessibilities=[]),n.accessibilities.push(a);let o=Ve(a,e);t.pushParsers(i,N,o);break}case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a);let o=ct(a,e);t.pushParsers(i,N,o);break}case 9:{let a={};n.contentComponent=a,t.pushParsers(i,N,xo(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=yr(a,e);t.pushParsers(i,N,o);break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=N,s=Ve(a,e);t.pushParsers(i,o,s);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a);let o=N,s=Ve(a,e);t.pushParsers(i,o,s);break}case 7:{let a={children:{baseURLs:[]},attributes:{}};n.representations.push(a);let o=Oo(a.children,e,t),s=wo(a.attributes,e);t.pushParsers(i,o,s);break}case 12:{let a={};n.roles===void 0&&(n.roles=[]),n.roles.push(a);let o=Ve(a,e);t.pushParsers(i,N,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=Ve(a,e);t.pushParsers(i,N,o);break}case 17:{let a={};n.segmentBase=a;let o=Ut(a,e);t.pushParsers(i,N,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Tr(a,e,t),s=Ut(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,N,Lt(a,e));break}default:t.pushParsers(i,N,N);break}}}function No(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 48:n.group=s.getFloat64(a,!0);break;case 60:n.language=F(t,e.buffer,a,o);break;case 61:n.contentType=F(t,e.buffer,a,o);break;case 62:n.par=F(t,e.buffer,a,o);break;case 53:n.minBitrate=s.getFloat64(a,!0);break;case 49:n.maxBitrate=s.getFloat64(a,!0);break;case 56:n.minWidth=s.getFloat64(a,!0);break;case 52:n.maxWidth=s.getFloat64(a,!0);break;case 55:n.minHeight=s.getFloat64(a,!0);break;case 51:n.maxHeight=s.getFloat64(a,!0);break;case 54:n.minFrameRate=s.getFloat64(a,!0);break;case 50:n.maxFrameRate=s.getFloat64(a,!0);break;case 57:n.selectionPriority=s.getFloat64(a,!0);break;case 58:n.segmentAlignment=Mi(s.getFloat64(a,!0));break;case 59:n.subsegmentAlignment=Mi(s.getFloat64(a,!0));break;case 32:n.bitstreamSwitching=s.getFloat64(a,!0)!==0;break;case 3:n.audioSamplingRate=F(t,e.buffer,a,o);break;case 4:n.codecs=F(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=F(t,e.buffer,a,o);break;case 2:n.profiles=F(t,e.buffer,a,o);break;case 12:n.segmentProfiles=F(t,e.buffer,a,o);break;case 11:n.mimeType=F(t,e.buffer,a,o);break;case 5:n.codingDependency=s.getFloat64(a,!0)!==0;break;case 6:n.frameRate=s.getFloat64(a,!0);break;case 7:n.height=s.getFloat64(a,!0);break;case 8:n.width=s.getFloat64(a,!0);break;case 9:n.maxPlayoutRate=s.getFloat64(a,!0);break;case 10:n.maximumSAPPeriod=s.getFloat64(a,!0);break;case 43:n.availabilityTimeOffset=s.getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=s.getUint8(0)===0;break;case 71:let u=F(t,e.buffer,a,o);n.label=u;break}}}function Bo(n,e,t,r){return function(a){switch(a){case 6:{let o={};n.events.push(o);let s=sd(o,e,r);t.pushParsers(a,N,s);break}default:t.pushParsers(a,N,N);break}}}function Uo(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 16:n.schemeIdUri=F(t,e.buffer,a,o);break;case 17:n.value=F(t,e.buffer,a,o);break;case 27:n.timescale=s.getFloat64(a,!0);break;case 70:let u={key:\"\",value:\"\"},l=a,d=s.getUint32(l);l+=4,u.key=F(t,e.buffer,l,d),l+=d;let f=s.getUint32(l);l+=4,u.value=F(t,e.buffer,l,f),n.namespaces===void 0?n.namespaces=[u]:n.namespaces.push(u);break}}}function sd(n,e,t){let r=new TextDecoder;return function(a,o,s){let u=new DataView(e.buffer);switch(a){case 25:n.presentationTime=u.getFloat64(o,!0);break;case 1:n.duration=u.getFloat64(o,!0);break;case 0:n.id=F(r,e.buffer,o,s);break;case 69:let l=u.getFloat64(o,!0),d=u.getFloat64(o+8,!0);n.eventStreamData=t.slice(l,d);break}}}function _r(n,e,t,r){return function(a){switch(a){case 4:{let o={children:{baseURLs:[],representations:[]},attributes:{}};n.adaptations.push(o);let s=Do(o.children,e,t),u=No(o.attributes,e);t.pushParsers(a,s,u);break}case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=N,u=ct(o,e);t.pushParsers(a,s,u);break}case 5:{let o={children:{events:[]},attributes:{}};n.eventStreams.push(o);let s=Bo(o.children,e,t,r),u=Uo(o.attributes,e);t.pushParsers(a,s,u);break}case 16:{let o={};n.segmentTemplate=o,t.pushParsers(a,N,Lt(o,e));break}default:t.pushParsers(a,N,N);break}}}function Er(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 45:n.start=new DataView(e.buffer).getFloat64(a,!0);break;case 1:n.duration=new DataView(e.buffer).getFloat64(a,!0);break;case 32:n.bitstreamSwitching=new DataView(e.buffer).getUint8(0)===0;break;case 46:n.xlinkHref=F(t,e.buffer,a,o);break;case 47:n.xlinkActuate=F(t,e.buffer,a,o);break;case 43:n.availabilityTimeOffset=new DataView(e.buffer).getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break;case 70:let s={key:\"\",value:\"\"},u=new DataView(e.buffer),l=a,d=u.getUint32(l);l+=4,s.key=F(t,e.buffer,l,d),l+=d;let f=u.getUint32(l);l+=4,s.value=F(t,e.buffer,l,f),n.namespaces===void 0?n.namespaces=[s]:n.namespaces.push(s);break}}}function Lo(n,e,t,r){return function(a){switch(a){case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=N,u=ct(o,e);t.pushParsers(a,s,u);break}case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=_r(o.children,e,t,r),u=Er(o.attributes,e);t.pushParsers(a,s,u);break}case 3:{let o={};n.utcTimings.push(o);let s=N,u=Ve(o,e);t.pushParsers(a,s,u);break}default:t.pushParsers(a,N,N);break}}}function Fo(n,e,t){let r,i=new TextDecoder;return function(o,s,u){switch(o){case 0:e.id=F(i,t.buffer,s,u);break;case 2:e.profiles=F(i,t.buffer,s,u);break;case 33:e.type=F(i,t.buffer,s,u);break;case 34:let l=F(i,t.buffer,s,u);e.availabilityStartTime=new Date(l).getTime()/1e3;break;case 35:let d=F(i,t.buffer,s,u);e.availabilityEndTime=new Date(d).getTime()/1e3;break;case 36:let f=F(i,t.buffer,s,u);e.publishTime=new Date(f).getTime()/1e3;break;case 68:r=new DataView(t.buffer),e.duration=r.getFloat64(s,!0);break;case 37:r=new DataView(t.buffer),e.minimumUpdatePeriod=r.getFloat64(s,!0);break;case 38:r=new DataView(t.buffer),e.minBufferTime=r.getFloat64(s,!0);break;case 39:r=new DataView(t.buffer),e.timeShiftBufferDepth=r.getFloat64(s,!0);break;case 40:r=new DataView(t.buffer),e.suggestedPresentationDelay=r.getFloat64(s,!0);break;case 41:r=new DataView(t.buffer),e.maxSegmentDuration=r.getFloat64(s,!0);break;case 42:r=new DataView(t.buffer),e.maxSubsegmentDuration=r.getFloat64(s,!0);break;case 66:let m=F(i,t.buffer,s,u);n.locations.push(m);break;case 70:let p={key:\"\",value:\"\"};r=new DataView(t.buffer);let g=s,h=r.getUint32(g);g+=4,p.key=F(i,t.buffer,g,h),g+=h;let I=r.getUint32(g);g+=4,p.value=F(i,t.buffer,g,I),e.namespaces===void 0?e.namespaces=[p]:e.namespaces.push(p);break}}}function Oi(n,e,t,r){return function(a){switch(a){case 1:n.mpd={children:{baseURLs:[],locations:[],periods:[],utcTimings:[]},attributes:{}};let o=Lo(n.mpd.children,e,t,r),s=Fo(n.mpd.children,n.mpd.attributes,e);t.pushParsers(a,o,s);break;default:t.pushParsers(a,N,N);break}}}function zo(n,e,t,r){return function(a){switch(a){case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=_r(o.children,e,t,r),u=Er(o.attributes,e);t.pushParsers(a,s,u);break}default:t.pushParsers(a,N,N);break}}}var cn=class{constructor(){this._currentNodeId=null,this.childrenParser=N,this.attributeParser=N,this._stack=[{nodeId:null,children:N,attribute:N}]}pushParsers(e,t,r){this._currentNodeId=e,this.childrenParser=t,this.attributeParser=r,this._stack.push({nodeId:e,attribute:r,children:t})}popIfCurrent(e){if(this._currentNodeId!==e)return;this._stack.pop();let{nodeId:t,children:r,attribute:i}=this._stack[this._stack.length-1];this._currentNodeId=t,this.attributeParser=i,this.childrenParser=r}reset(){this.childrenParser=N,this.attributeParser=N,this._stack=[{nodeId:null,children:N,attribute:N}]}};var ud=15e3,pn=class{constructor(){this._parsersStack=new cn,this._instance=null,this._mpdData=null,this._linearMemory=null,this.status=\"uninitialized\",this._initProm=null,this._warnings=[],this._isParsing=!1}waitForInitialization(){var e;return(e=this._initProm)!=null?e:Promise.reject(\"No initialization performed yet.\")}async initialize(e){if(this.status!==\"uninitialized\")return Promise.reject(new Error(\"DashWasmParser already initialized.\"));if(!this.isCompatible())return this.status=\"failure\",Promise.reject(new Error(\"Target not compatible with WebAssembly.\"));this.status=\"initializing\";let t=this._parsersStack,r=new TextDecoder,i=this,a={env:{memoryBase:0,tableBase:0,memory:new WebAssembly.Memory({initial:10}),table:new WebAssembly.Table({initial:1,element:\"anyfunc\"}),onTagOpen:l,onCustomEvent:m,onAttribute:f,readNext:p,onTagClose:d}},o=null,s;typeof e.wasmUrl==\"string\"?s=fetch(e.wasmUrl):(o=URL.createObjectURL(new Blob([e.wasmUrl],{type:\"application/wasm\"})),s=fetch(o));let u=typeof WebAssembly.instantiateStreaming==\"function\"?WebAssembly.instantiateStreaming(s,a):Promise.reject(\"`WebAssembly.instantiateStreaming` API not available\");return this._initProm=u.catch(async g=>{o!==null&&(URL.revokeObjectURL(o),o=null),c.warn(\"Unable to call `instantiateStreaming` on WASM\",g instanceof Error?g:\"\");let h=await s;if(h.status<200||h.status>=300)throw new Error(\"WebAssembly request failed. status: \"+String(h.status));let I=await h.arrayBuffer();return WebAssembly.instantiate(I,a)}).then(g=>{o!==null&&(URL.revokeObjectURL(o),o=null),this._instance=g,this._linearMemory=this._instance.instance.exports.memory,this.status=\"initialized\"}).catch(g=>{let h=g instanceof Error?g.toString():\"Unknown error\";throw c.warn(\"DW: Could not create DASH-WASM parser:\",h),this.status=\"failure\",g}),this._initProm;function l(g){return t.childrenParser(g)}function d(g){return t.popIfCurrent(g)}function f(g,h,I){return t.attributeParser(g,h,I)}function m(g,h,I){let y=i._linearMemory,E=new Uint8Array(y.buffer,h,I);if(g===1){let R=r.decode(E);c.warn(\"WASM Error Event:\",R),i._warnings.push(new Error(R))}else if(g===0){let R=r.decode(E);c.warn(\"WASM Log Event:\",R)}}function p(g,h){if(i._mpdData===null)throw new Error(\"DashWasmParser Error: No MPD to read.\");let I=i._linearMemory,{mpd:y,cursor:E}=i._mpdData,R=Math.min(h,ud,y.byteLength-E);return new Uint8Array(I.buffer,g,R).set(new Uint8Array(y,E,R)),i._mpdData.cursor+=R,R}}runWasmParser(e,t){let[r,i]=this._parseMpd(e);if(r===null)throw new Error(\"DASH Parser: Unknown error while parsing the MPD\");let a=gr(r,t,i);return this._processParserReturnValue(a)}isCompatible(){return ko&&typeof Ee.TextDecoder==\"function\"}_parseMpd(e){var s;if(this._instance===null)throw new Error(\"DashWasmParser not initialized\");if(this._isParsing)throw new Error(\"Parsing operation already pending.\");this._isParsing=!0,this._mpdData={mpd:e,cursor:0};let t={},r=this._linearMemory,i=Oi(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,N),this._warnings=[];try{this._instance.instance.exports.parse()}catch(u){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,u}let a=(s=t.mpd)!=null?s:null,o=this._warnings;return this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,[a,o]}_parseXlink(e){if(this._instance===null)throw new Error(\"DashWasmParser not initialized\");if(this._isParsing)throw new Error(\"Parsing operation already pending.\");this._isParsing=!0,this._mpdData={mpd:e,cursor:0};let t={periods:[]},r=this._linearMemory,i=zo(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,N),this._warnings=[];try{this._instance.instance.exports.parse()}catch(s){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,s}let{periods:a}=t,o=this._warnings;return this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,[a,o]}_processParserReturnValue(e){if(e.type===\"done\")return e;if(e.type===\"needs-clock\"){let t=r=>{if(r.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let i=e.value.continue(r[0].responseData);return this._processParserReturnValue(i)};return{type:\"needs-resources\",value:{urls:[e.value.url],format:\"string\",continue:t}}}else if(e.type===\"needs-xlinks\"){let t=r=>{let i=[];for(let o=0;o<r.length;o++){let{responseData:s,receivedTime:u,sendingTime:l,url:d}=r[o];if(!s.success)throw s.error;let[f,m]=this._parseXlink(s.data);i.push({url:d,receivedTime:u,sendingTime:l,parsed:f,warnings:m})}let a=e.value.continue(i);return this._processParserReturnValue(a)};return{type:\"needs-resources\",value:{urls:e.value.xlinksUrls,format:\"arraybuffer\",continue:t}}}else ze(e)}};var Wo=pn;var Pt=class{constructor(e,t){this._last=e,this._wanted=t}serialize(){return[this._last,this._wanted]}getPolled(){return this._last}getWanted(){var e;return(e=this._wanted)!=null?e:this._last}forceWantedPosition(e){this._wanted=e}isAwaitingFuturePosition(){return this._wanted!==null}};function Rr(n,e,t){let r=e(n.getReference(),t);return{getCurrentTime(){return n.getCurrentTime()},getReadyState(){return n.getReadyState()},getPlaybackRate(){return n.getPlaybackRate()},getIsPaused(){return n.getIsPaused()},getReference(){return r},listen(i,a){var o;t.isCancelled()||((o=a==null?void 0:a.clearSignal)==null?void 0:o.isCancelled())===!0||r.onUpdate(i,{clearSignal:a==null?void 0:a.clearSignal,emitCurrentValue:a==null?void 0:a.includeLastObservation})},deriveReadOnlyObserver(i){return Rr(this,i,t)}}}var gn=class{constructor(e,t,r,i){this._src=e,this._contentId=t,this._messageSender=r,this._cancelSignal=i}getCurrentTime(){}getReadyState(){}getIsPaused(){}getReference(){return this._src}setPlaybackRate(e){this._messageSender({type:\"update-playback-rate\",contentId:this._contentId,value:e})}getPlaybackRate(){}listen(e,t){var r;this._cancelSignal.isCancelled()||((r=t==null?void 0:t.clearSignal)==null?void 0:r.isCancelled())===!0||this._src.onUpdate(e,{clearSignal:t==null?void 0:t.clearSignal,emitCurrentValue:t==null?void 0:t.includeLastObservation})}deriveReadOnlyObserver(e){return Rr(this,e,this._cancelSignal)}};function wi(n,e){return(t,r,i)=>new Promise((a,o)=>{let s=Date.now()-L(),u=!1,m={reject:h=>{var R,T;if(u||i.isCancelled())return;u=!0,i.deregister(g);let I=h,y=(R=I==null?void 0:I.message)!=null?R:\"Unknown error when fetching the Manifest through a custom manifestLoader.\",E=new Ge(y,(T=I==null?void 0:I.canRetry)!=null?T:!1,I==null?void 0:I.xhr);o(E)},resolve:h=>{if(u||i.isCancelled())return;u=!0,i.deregister(g);let I=h.receivingTime!==void 0?h.receivingTime-s:void 0,y=h.sendingTime!==void 0?h.sendingTime-s:void 0;a({responseData:h.data,size:h.size,requestDuration:h.duration,url:h.url,receivedTime:I,sendingTime:y})},fallback:()=>{u||i.isCancelled()||(u=!0,i.deregister(g),e(t,r,i).then(a,o))}},p=n({url:t,timeout:r.timeout},m);i.register(g);function g(h){u||(u=!0,typeof p==\"function\"&&p(),o(h))}})}function dd(n){return function(t,r,i){if(t===void 0)throw new Error(\"Cannot perform HTTP(s) request. URL not known\");switch(n){case\"arraybuffer\":return le({url:t,responseType:\"arraybuffer\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"text\":return le({url:t,responseType:\"text\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"document\":return le({url:t,responseType:\"document\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});default:ze(n)}}}function Di({customManifestLoader:n},e){let t=dd(e);return typeof n!=\"function\"?t:wi(n,t)}function Ni(n){let{referenceDateTime:e}=n,t=n.serverSyncInfos!==void 0?n.serverSyncInfos.serverTimestamp-n.serverSyncInfos.clientTime:void 0;return function(i,a,o,s,u){var E;let{responseData:l}=i,d=a.externalClockOffset,f=(E=i.url)!=null?E:a.originalUrl,m=t!=null?t:d,g={unsafelyBaseOnPreviousManifest:a.unsafeMode?a.previousManifest:null,url:f,referenceDateTime:e,externalClockOffset:m},h=ae.dashParsers;if(h.wasm===null||h.wasm.status===\"uninitialized\"||h.wasm.status===\"failure\")return c.debug(\"DASH: WASM MPD Parser not initialized. Running JS one.\"),I();{let R=pd(l);if(!gd(R))return c.info(\"DASH: MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one.\"),I();if(h.wasm.status===\"initialized\"){c.debug(\"DASH: Running WASM MPD Parser.\");let T=h.wasm.runWasmParser(R,g);return y(T)}else return c.debug(\"DASH: Awaiting WASM initialization before parsing the MPD.\"),h.wasm.waitForInitialization().catch(()=>{}).then(()=>{if(h.wasm===null||h.wasm.status!==\"initialized\")return c.warn(\"DASH: WASM MPD parser initialization failed. Running JS parser instead\"),I();c.debug(\"DASH: Running WASM MPD Parser.\");let C=h.wasm.runWasmParser(R,g);return y(C)})}function I(){if(h.fastJs!==null){let R=md(l),T=h.fastJs(R,g);return y(T)}else if(h.native!==null){let R=cd(l),T=h.native(R,g);return y(T)}else throw new Error(\"No MPD parser is imported\")}function y(R){if(R.type===\"done\"){if(R.value.warnings.length>0&&o(R.value.warnings),s.isCancelled())return Promise.reject(s.cancellationError);let P=[];return{manifest:new wt(R.value.parsed,n,P),url:f,warnings:P}}let{value:T}=R,C=T.urls.map(P=>u(()=>{let x=U.getCurrent().DEFAULT_REQUEST_TIMEOUT,_=U.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return T.format===\"string\"?le({url:P,responseType:\"text\",timeout:x,connectionTimeout:_,cancelSignal:s}):le({url:P,responseType:\"arraybuffer\",timeout:x,connectionTimeout:_,cancelSignal:s})}).then(x=>{if(T.format===\"string\"){if(typeof x.responseData!=\"string\")throw new Error(\"External DASH resources should have been a string\");return H(x,{responseData:{success:!0,data:x.responseData}})}else{if(!(x.responseData instanceof ArrayBuffer))throw new Error(\"External DASH resources should have been ArrayBuffers\");return H(x,{responseData:{success:!0,data:x.responseData}})}},x=>{let _=ge(x,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"An unknown error occured when parsing ressources.\"});return H({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:_}})}));return Promise.all(C).then(P=>T.format===\"string\"?(ld(P),y(T.continue(P))):(fd(P),y(T.continue(P))))}}}function ld(n){b.CURRENT_ENV!==b.PRODUCTION&&n.forEach(e=>{let{responseData:t}=e;if(!(t.success&&typeof t.data==\"string\")&&t.success)throw new Error(\"Invalid data given to the LoadedRessource\")})}function fd(n){b.CURRENT_ENV!==b.PRODUCTION&&n.forEach(e=>{let{responseData:t}=e;if(!(t.success&&t.data instanceof ArrayBuffer)&&t.success)throw new Error(\"Invalid data given to the LoadedRessource\")})}function md(n){if(n instanceof ArrayBuffer)return Be(new Uint8Array(n));if(typeof n==\"string\")return n;if(n instanceof Document)return n.documentElement.outerHTML;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function cd(n){if(n instanceof ArrayBuffer)return new DOMParser().parseFromString(Be(new Uint8Array(n)),\"text/xml\");if(typeof n==\"string\")return new DOMParser().parseFromString(n,\"text/xml\");if(n instanceof Document)return n;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function pd(n){if(n instanceof ArrayBuffer)return n;if(typeof n==\"string\")return dn(n).buffer;if(n instanceof Document)return dn(n.documentElement.innerHTML).buffer;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function gd(n){let e=new DataView(n);return e.getUint16(0)===61371&&e.getUint8(2)===191?!0:!(e.getUint16(0)===65279||e.getUint16(0)===65534)}function Oe([n,e]){return e===1/0?`bytes=${n}-`:`bytes=${n}-${e}`}function qe(n,e){if(n===\"audio\"||n===\"video\")return e===\"video/mp4\"||e===\"audio/mp4\"?\"mp4\":e===\"video/webm\"||e===\"audio/webm\"?\"webm\":void 0;if(n===\"text\")return e===\"application/mp4\"?\"mp4\":void 0}var W=class{constructor(){let[e,t]=hd();this._isUsed=!1,this._trigger=e,this.signal=new Bi(t)}isUsed(){return this._isUsed}linkToSignal(e){let t=e.register(()=>{this.cancel()});return this.signal.register(t),t}cancel(e){if(this._isUsed)return;this._isUsed=!0;let t=e!=null?e:new ie;this._trigger(t)}static isCancellationError(e){return e instanceof ie}},Bi=class{constructor(e){this._isCancelled=!1,this.cancellationError=null,this._listeners=[],e(t=>{for(this.cancellationError=t,this._isCancelled=!0;this._listeners.length>0;)try{let r=this._listeners.pop();r==null||r(t)}catch(r){c.error(\"Error while calling clean up listener\",r instanceof Error?r.toString():\"Unknown error\")}})}isCancelled(){return this._isCancelled}register(e){return this._isCancelled?(he(this.cancellationError!==null),e(this.cancellationError),N):(this._listeners.push(e),()=>this.deregister(e))}deregister(e){for(let t=this._listeners.length-1;t>=0;t--)this._listeners[t]===e&&this._listeners.splice(t,1)}},ie=class n extends Error{constructor(){super(),Object.setPrototypeOf(this,n.prototype),this.name=\"CancellationError\",this.message=\"This task was cancelled.\"}};function hd(){let n=N;return[function(t){n(t)},function(t){n=t}]}function vt(...n){let e=n.length,t=-1,r=0,i;for(;++t<e;)i=n[t],r+=typeof i==\"number\"?i:i.length;let a=new Uint8Array(r),o=0;for(t=-1;++t<e;)i=n[t],typeof i==\"number\"?o+=i:i.length>0&&(a.set(i,o),o+=i.length);return a}function Vo(n,e){return(n[e+0]<<8)+(n[e+1]<<0)}function Ui(n,e){return n[e+0]*65536+n[e+1]*256+n[e+2]}function te(n,e){return n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3]}function pt(n,e){return(n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3])*4294967296+n[e+4]*16777216+n[e+5]*65536+n[e+6]*256+n[e+7]}function Qe(n,e){let t=n.length,r=0;for(;r+8<=t;){let i=te(n,r);if(i===0)i=t-r;else if(i===1){if(r+16>t)return-1;i=pt(n,r+8)}if(isNaN(i)||i<=0)return-1;if(te(n,r+4)===e)return r+i<=t?r:-1;r+=i}return-1}function Pr(n){let e=0,t=[],r=null;for(;e<=n.length;){if(e===n.length){r=null;break}r=n.subarray(e,1/0);let i=Qe(r,1836019558);if(i<0)break;let a=te(n,i+e),o=e+i+a;if(o>n.length)break;let s=Qe(r,1835295092);if(s<0)break;let u=te(n,s+e),l=e+s+u;if(l>n.length)break;let d=Math.max(o,l),f=n.subarray(e,d);t.push(f),e=d}return t.length===0?[null,r]:[t,r]}function Id(n,e,t){return new Uint8Array(Array.prototype.slice.call(n,e,t))}function bd(n,e,t){return n.slice(e,t)}var Li=typeof Uint8Array.prototype.slice==\"function\"?bd:Id;function Fi(n,e){let t=n;for(let r of e){let i=ue(t,r);if(i===null)return null;t=i}return t}function ue(n,e){let t=Ft(n,e);return t!==null?n.subarray(t[1],t[2]):null}function qo(n,e){let t=[],r=n;for(;;){let i=Ft(r,e);if(i===null)return t;he(i[2]!==0&&r.length!==0),t.push(r.subarray(i[1],i[2])),r=r.subarray(i[2])}}function Ft(n,e){let t=n.length,r=0,i,a=0,o;for(;r+8<=t;){if(o=r,a=te(n,o),o+=4,i=te(n,o),o+=4,a===0)a=t-r;else if(a===1){if(o+8>t)return null;a=pt(n,o),o+=8}if(a<0)throw new Error(\"ISOBMFF: Size out of range\");if(i===e)return e===1970628964&&(o+=16),[r,o,r+a];r+=a}return null}function vr(n){let e=0,t=ue(n,1836019574);if(t===null)return[];let r=[];for(;e<t.length;){let i;try{i=Ft(t,1886614376)}catch(s){let u=s instanceof Error?s:\"\";return c.warn(\"Error while removing PSSH from ISOBMFF\",u),r}if(i===null)return r;let a=Li(t,i[0],i[2]),o=Ho(a,i[1]-i[0]);o!==void 0&&r.push({systemId:o,data:a}),t[i[0]+4]=102,t[i[0]+5]=114,t[i[0]+6]=101,t[i[0]+7]=101,e=i[2]}return r}function Ho(n,e){if(n[e]>1){c.warn(\"ISOBMFF: un-handled PSSH version\");return}let t=e+4;if(t+16>n.length)return;let r=Li(n,t,t+16);return ho(r)}function zi(n){let e=ue(n,1836019558);return e===null?null:ue(e,1953653094)}function Go(n){return qo(n,1836019558).reduce((t,r)=>{let i=ue(r,1953653094);return i!==null&&t.push(i),t},[])}function Wi(n){return ue(n,1835295092)}function Vi(n){let e=ue(n,1836019574);if(e===null)return null;let t=ue(e,1953653099);return t===null?null:ue(t,1835297121)}function Ko(n,e=0){return ue(n.subarray(e),1701671783)}function hn(n,e){let t=Ft(n,1936286840);if(t===null)return null;let r=e,i=t[2]-t[0],a=t[1],o=n[a];a+=8;let s=te(n,a);a+=4;let u;if(o===0)u=te(n,a),a+=4,r+=te(n,a)+i,a+=4;else if(o===1)u=pt(n,a),a+=8,r+=pt(n,a)+i,a+=8;else return null;let l=[];a+=2;let d=Vo(n,a);for(a+=2;--d>=0;){let f=te(n,a);a+=4;let m=(f&2147483648)>>>31,p=f&2147483647;if(m===1)throw new Error(\"sidx with reference_type `1` not yet implemented\");let g=te(n,a);a+=4,a+=4,l.push({time:u,duration:g,timescale:s,range:[r,r+p-1]}),u+=g,r+=p}return l}function qi(n){let e=zi(n);if(e===null)return;let t=ue(e,1952867444);if(t===null)return;let r=t[0];if(r===1)return pt(t,4);if(r===0)return te(t,4)}function Sd(n){let e=ue(n,1952868452);if(e===null)return;let t=1,r=Ui(e,t);t+=3;let i=(r&1)>0,a=(r&2)>0;return(r&8)>0?(t+=4,i&&(t+=8),a&&(t+=4),te(e,t)):void 0}function Hi(n){let e=Go(n);if(e.length===0)return;let t=0;for(let r of e){let i=ue(r,1953658222);if(i===null)return;let a=0,o=i[a];if(a+=1,o>1)return;let s=Ui(i,a);a+=3;let u=(s&256)>0,l=0;if(!u&&(l=Sd(r),l===void 0))return;let d=(s&1)>0,f=(s&4)>0,m=(s&512)>0,p=(s&1024)>0,g=(s&2048)>0,h=te(i,a);a+=4,d&&(a+=4),f&&(a+=4);let I=h,y=0;for(;I-- >0;)u?(y+=te(i,a),a+=4):y+=l,m&&(a+=4),p&&(a+=4),g&&(a+=4);t+=y}return t}function In(n){let e=Vi(n);if(e===null)return;let t=ue(e,1835296868);if(t===null)return;let r=0,i=t[r];if(r+=4,i===1)return te(t,r+16);if(i===0)return te(t,r+8)}function jo(n){let e=[],t=0;for(;t<n.length;){let r=Ko(n,t);if(r===null)break;let i=r.length;t+=i;let a=r[0];if(a!==0)c.warn(\"ISOBMFF: EMSG version \"+a.toString()+\" not supported.\");else{let o=4,{end:s,string:u}=Ii(r,o);o=s;let{end:l,string:d}=Ii(r,o);o=l;let f=te(r,o);o+=4;let m=te(r,o);o+=4;let p=te(r,o);o+=4;let g=te(r,o);o+=4;let h=r.subarray(o,i),I={schemeIdUri:u,value:d,timescale:f,presentationTimeDelta:m,eventDuration:p,id:g,messageData:h};e.push(I)}}if(e.length!==0)return e}function Yo(n){let e=Fi(n,[1836019574,1953653099,1835297121,1835626086,1937007212,1937011556]);if(e===null)return null;let t=e.subarray(8),r=ue(t,1701733238),i=0;if(r===null?(i=28,r=ue(t,1701733217)):i=78,r===null)return null;let a=Fi(r.subarray(i),[1936289382,1935894633,1952804451]);return a===null||a.byteLength<24?null:a.subarray(8,24)}function Gi(n,e){if(e){if(Qe(n,1718909296)<0)throw new Re(\"INTEGRITY_ERROR\",\"Incomplete `ftyp` box\");if(Qe(n,1836019574)<0)throw new Re(\"INTEGRITY_ERROR\",\"Incomplete `moov` box\")}else{if(Qe(n,1836019558)<0)throw new Re(\"INTEGRITY_ERROR\",\"Incomplete `moof` box\");if(Qe(n,1835295092)<0)throw new Re(\"INTEGRITY_ERROR\",\"Incomplete `mdat` box\")}}function bn(n){return(e,t,r,i,a)=>{return new Promise((s,u)=>{let l=new W,d=l.linkToSignal(i);l.signal.register(u),n(e,t,r,l.signal,Le(_e({},a),{onNewChunk(m){try{o(m),a.onNewChunk(m)}catch(p){f(),l.cancel(),u(p)}}})).then(m=>{if(f(),!l.isUsed()){if(m.resultType===\"segment-loaded\")try{o(m.resultData.responseData)}catch(p){u(p);return}s(m)}},m=>{f(),u(m)});function f(){l.signal.deregister(u),d()}});function o(s){!(s instanceof ArrayBuffer)&&!(s instanceof Uint8Array)||qe(t.type,t.mimeType)!==\"mp4\"||Gi(new Uint8Array(s),t.segment.isInit)}}}function Sn(n,e){return n===null?null:e.url===null?n.baseUrl:sn(n.baseUrl,e.url)}function yn(n,e,t,r,i){if(e.range===void 0)return le({url:n,responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(s=>({resultType:\"segment-loaded\",resultData:s}));if(e.indexRange===void 0)return le({url:n,headers:{Range:Oe(e.range)},responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(s=>({resultType:\"segment-loaded\",resultData:s}));if(e.range[1]+1===e.indexRange[0])return le({url:n,headers:{Range:Oe([e.range[0],e.indexRange[1]])},responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(s=>({resultType:\"segment-loaded\",resultData:s}));let a=le({url:n,headers:{Range:Oe(e.range)},responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),o=le({url:n,headers:{Range:Oe(e.indexRange)},responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([a,o]).then(([s,u])=>{let l=vt(new Uint8Array(s.responseData),new Uint8Array(u.responseData)),d=Math.min(s.sendingTime,u.sendingTime),f=Math.max(s.receivedTime,u.receivedTime);return{resultType:\"segment-loaded\",resultData:{url:n,responseData:l,size:s.size+u.size,requestDuration:f-d,sendingTime:d,receivedTime:f}}})}function Tn(n,e,t,r,i){let{segment:a}=e,o=a.range!==void 0?{Range:Oe(a.range)}:void 0,s=null;function u(l){let d=new Uint8Array(l.chunk),f=s!==null?vt(s,d):d,m=Pr(f),p=m[0];s=m[1],!(p!==null&&(p.forEach(g=>{r.onNewChunk(g)}),i.isCancelled()))&&(r.onProgress({duration:l.duration,size:l.size,totalSize:l.totalSize}),i.isCancelled())}return rr({url:n,headers:o,onData:u,timeout:t.timeout,cancelSignal:i}).then(l=>({resultType:\"chunk-complete\",resultData:l}))}function Qo(n,e,t,r,i,a){if(e.segment.isInit)return yn(n,e.segment,r,a,i);let o=qe(e.type,e.mimeType);if(t&&(o===\"mp4\"||o===void 0)){if($t())return Tn(n,e,r,i,a);Xe(\"DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge\")}let{segment:s}=e;return le({url:n,responseType:\"arraybuffer\",headers:s.range!==void 0?{Range:Oe(s.range)}:void 0,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:a,onProgress:i.onProgress}).then(u=>({resultType:\"segment-loaded\",resultData:u}))}function Ki({lowLatencyMode:n,segmentLoader:e,checkMediaSegmentIntegrity:t}){return t!==!0?r:bn(r);function r(i,a,o,s,u){let l=Sn(i,a.segment);return l===null?Promise.resolve({resultType:\"segment-created\",resultData:null}):n||e===void 0?Qo(l,a,n,o,u,s):new Promise((d,f)=>{let m=!1,y={reject:P=>{var M,k;if(m||s.isCancelled())return;m=!0,s.deregister(C);let x=P,_=(M=x==null?void 0:x.message)!=null?M:\"Unknown error when fetching a DASH segment through a custom segmentLoader.\",A=new Ge(_,(k=x==null?void 0:x.canRetry)!=null?k:!1,x==null?void 0:x.xhr);f(A)},resolve:P=>{m||s.isCancelled()||(m=!0,s.deregister(C),d({resultType:\"segment-loaded\",resultData:{responseData:P.data,size:P.size,requestDuration:P.duration}}))},progress:P=>{m||s.isCancelled()||u.onProgress({duration:P.duration,size:P.size,totalSize:P.totalSize})},fallback:()=>{m||s.isCancelled()||(m=!0,s.deregister(C),Qo(l,a,n,o,u,s).then(d,f))}},E;a.segment.range!==void 0&&(E=[a.segment.range],a.segment.indexRange!==void 0&&E.push(a.segment.indexRange));let R={isInit:a.segment.isInit,timeout:o.timeout,byteRanges:E,trackType:a.type,url:l},T=e(R,y);s.register(C);function C(P){m||(m=!0,typeof T==\"function\"&&T(),f(P))}})}}var Yi=408125543,$o=357149030,yd=2807729,Td=17545,_d=475249515,Ed=187,Rd=179,Pd=183,vd=241;function gt(n,e,t,[r,i]){let a=r;for(;a<i;){let o=Ad(t,a);if(o===null)return null;let{value:s,length:u}=o,l=a+u,d=kd(t,l);if(d===null)return null;let{length:f,value:m}=d,p=l+f,g=p+m;if(s===n)return[p,g];if(e.length>0){for(let h=0;h<e.length;h++)if(s===e[h]){let I=e.slice(h+1,e.length);return gt(n,I,t,[p,g])}}a=g}return null}function Cr(n,e){let t=gt(yd,[Yi,$o],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return 1e9/ji(n,t[0],r)}function Cd(n,e){let t=gt(Td,[Yi,$o],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return r===4?xd(n,t[0]):r===8?Md(n,t[0]):null}function Qi(n,e){let t=gt(Yi,[],n,[e,n.length]);if(t===null)return null;let[r,i]=t,a=Cr(n,r);if(a===null)return null;let o=Cd(n,r);if(o===null)return null;let s=gt(_d,[],n,[r,i]);if(s===null)return null;let u=[],l=s[0];for(;l<s[1];){let f=gt(Ed,[],n,[l,s[1]]);if(f===null)break;let m=gt(Rd,[],n,[f[0],f[1]]);if(m===null)return null;let p=ji(n,m[0],m[1]-m[0]),g=gt(vd,[Pd],n,[f[0],f[1]]);if(g===null)return null;let h=ji(n,g[0],g[1]-g[0])+r;u.push({time:p,rangeStart:h}),l=f[1]}let d=[];for(let f=0;f<u.length;f++){let m=u[f];f===u.length-1?d.push({time:m.time,timescale:a,duration:f===0?o:o-m.time,range:[m.rangeStart,1/0]}):d.push({time:m.time,timescale:a,duration:u[f+1].time-m.time,range:[m.rangeStart,u[f+1].rangeStart-1]})}return d}function Xo(n,e){for(let t=1;t<=8;t++)if(n[e]>=Math.pow(2,8-t))return t}function Ad(n,e){let t=Xo(n,e);if(t===void 0)return c.warn(\"webm: unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm: impossible length\"),null;let r=0;for(let i=0;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return{length:t,value:r}}function kd(n,e){let t=Xo(n,e);if(t===void 0)return c.warn(\"webm: unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm: impossible length\"),null;let r=(n[e]&(1<<8-t)-1)*Math.pow(2,(t-1)*8);for(let i=1;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return{length:t,value:r}}function xd(n,e){return new DataView(n.buffer).getFloat32(e)}function Md(n,e){return new DataView(n.buffer).getFloat64(e)}function ji(n,e,t){let r=0;for(let i=0;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return r}function _n(n,e,t,r){let i=qi(n);if(i===void 0||r===void 0)return null;let a=t.timestampOffset!==void 0?i+t.timestampOffset*r:i,o=Hi(n);if(a<0&&(o!==void 0&&(o+=a),a=0),e||!t.complete)return o===void 0&&c.warn(\"DASH: Chunked segments should indicate a duration through their trun boxes\"),{time:a/r,duration:o!==void 0?o/r:void 0};let s,u=t.duration*r,l=Math.min(r*.9,u/4);return o!==void 0&&Math.abs(o-u)<=l&&(s=o),{time:a/r,duration:s!==void 0?s/r:s}}function Od(n,e){if(n.length<=0)return!1;let t=n.length;for(let r=0;r<t;r++){let i=n[r],a=e,{messageData:o}=i,s=Be(o),u=Date.parse(s);if(a===void 0||u===void 0||isNaN(u)||u>=a)return!0}return!1}function $i(n,e){if(n.length===0)return;let{manifestRefreshEventsFromEMSGs:t,EMSGs:r}=n.reduce((o,s)=>(s.schemeIdUri===\"urn:mpeg:dash:event:2012\"&&s.value===\"1\"?(o.manifestRefreshEventsFromEMSGs===void 0&&(o.manifestRefreshEventsFromEMSGs=[]),o.manifestRefreshEventsFromEMSGs.push(s)):(o.EMSGs===void 0&&(o.EMSGs=[]),o.EMSGs.push(s)),o),{manifestRefreshEventsFromEMSGs:void 0,EMSGs:void 0}),i=r==null?void 0:r.map(o=>({type:\"emsg\",value:o})),a=e===void 0||t===void 0?!1:Od(t,e);return{inbandEvents:i,needsManifestRefresh:a}}function Xi({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var R,T;let{segment:a,periodStart:o,periodEnd:s}=r,{data:u,isChunked:l}=t,d=[o,s];if(u===null)return a.isInit?{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:\"media\",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:0,protectionData:[],appendWindow:d};let f=u instanceof Uint8Array?u:new Uint8Array(u),m=qe(r.type,r.mimeType),p=m===\"mp4\"||m===void 0,g=[];if(p){let C=vr(f),P;a.isInit&&(P=(R=Yo(f))!=null?R:void 0),(C.length>0||P!==void 0)&&g.push({initDataType:\"cenc\",keyId:P,initData:C})}if(!a.isInit){let C=p?_n(f,l,a,i):null,P=(T=a.timestampOffset)!=null?T:0;if(p){let x=jo(f);if(x!==void 0){let _=x.filter(M=>a.privateInfos===void 0||a.privateInfos.isEMSGWhitelisted===void 0?!1:a.privateInfos.isEMSGWhitelisted(M)),A=$i(_,r.manifestPublishTime);if(A!==void 0){let{needsManifestRefresh:M,inbandEvents:k}=A;return{segmentType:\"media\",chunkData:f,chunkSize:f.length,chunkInfos:C,chunkOffset:P,appendWindow:d,inbandEvents:k,protectionData:g,needsManifestRefresh:M}}}}return{segmentType:\"media\",chunkData:f,chunkSize:f.length,chunkInfos:C,chunkOffset:P,protectionData:g,appendWindow:d}}let{indexRange:h}=a,I;if(m===\"webm\")I=Qi(f,0);else if(p&&(I=hn(f,Array.isArray(h)?h[0]:0),n===!0&&I!==null&&I.length>0)){let C=I[I.length-1];Array.isArray(C.range)&&(C.range[1]=1/0)}let y;p?y=In(f):m===\"webm\"&&(y=Cr(f,0));let E=v(y)?void 0:y;return{segmentType:\"init\",initializationData:f,initializationDataSize:f.length,protectionData:g,initTimescale:E,segmentList:I!=null?I:void 0}}}function Zi({lowLatencyMode:n,checkMediaSegmentIntegrity:e}){return e!==!0?t:bn(t);function t(r,i,a,o,s){let{segment:u}=i,{range:l}=u,d=Sn(r,u);if(d===null)return Promise.resolve({resultType:\"segment-created\",resultData:null});if(u.isInit)return yn(d,u,a,o,s);let f=qe(i.type,i.mimeType),m=f===\"mp4\"||f===void 0;if(n&&m){if($t())return Tn(d,i,a,s,o);Xe(\"DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge\")}return m?le({url:d,responseType:\"arraybuffer\",headers:Array.isArray(l)?{Range:Oe(l)}:null,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}).then(p=>({resultType:\"segment-loaded\",resultData:p})):le({url:d,responseType:\"text\",headers:Array.isArray(l)?{Range:Oe(l)}:null,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}).then(p=>({resultType:\"segment-loaded\",resultData:p}))}}function wd(n){let e=Wi(n);return e===null?\"\":Be(e)}function Dd(n){if(n===void 0)throw new Error(\"Cannot parse subtitles: unknown format\");switch(n.toLowerCase()){case\"stpp\":case\"stpp.ttml.im1t\":return\"ttml\";case\"wvtt\":return\"vtt\"}throw new Error(`The codec used for the subtitles \"${n}\" is not managed yet.`)}function Nd(n,e){switch(e){case\"application/ttml+xml\":return\"ttml\";case\"application/x-sami\":case\"application/smil\":return\"sami\";case\"text/vtt\":return\"vtt\"}if(n!==void 0&&n.toLowerCase()===\"srt\")return\"srt\";throw new Error(`could not find a text-track parser for the type ${e!=null?e:\"\"}`)}function Zo({segment:n,language:e,codecs:t},r,i,a){if(n.isInit)return null;let o,s;i===null?a?(o=n.time,s=n.end):c.warn(\"Transport: Unavailable time data for current text track.\"):(o=i.time,i.duration!==void 0?s=o+i.duration:!a&&n.complete&&(s=o+n.duration));let u=Dd(t);return{data:wd(r),type:u,language:e,start:o,end:s}}function Jo(n,e,t){let{segment:r}=n;if(r.isInit)return null;let i,a;t?c.warn(\"Transport: Unavailable time data for current text track.\"):(i=r.time,r.complete&&(a=r.time+r.duration));let o=Nd(n.codecs,n.mimeType);return{data:e,type:o,language:n.language,start:i,end:a}}function Bd(n,e,t,r,i){var m;let{segment:a}=t,{isInit:o,indexRange:s}=a,u;if(typeof n==\"string\"?u=dn(n):n instanceof Uint8Array?u=n:u=new Uint8Array(n),o){let p=hn(u,Array.isArray(s)?s[0]:0);if(i===!0&&p!==null&&p.length>0){let h=p[p.length-1];Array.isArray(h.range)&&(h.range[1]=1/0)}let g=In(u);return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:g,segmentList:p!=null?p:void 0}}let l=_n(u,e,a,r),d=Zo(t,u,l,e),f=(m=a.timestampOffset)!=null?m:0;return{segmentType:\"media\",chunkData:d,chunkSize:u.length,chunkInfos:l,chunkOffset:f,protectionData:[],appendWindow:[t.periodStart,t.periodEnd]}}function Ud(n,e,t){let{periodStart:r,periodEnd:i,segment:a}=t,{timestampOffset:o=0}=a;if(a.isInit)return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};let s,u;if(typeof n!=\"string\"){let d=n instanceof Uint8Array?n:new Uint8Array(n);s=Be(d),u=d.length}else s=n;return{segmentType:\"media\",chunkData:Jo(t,s,e),chunkSize:u,chunkInfos:null,chunkOffset:o,protectionData:[],appendWindow:[r,i]}}function Ji({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var f;let{periodStart:a,periodEnd:o,segment:s}=r,{data:u,isChunked:l}=t;if(u===null)return s.isInit?{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:\"media\",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:(f=s.timestampOffset)!=null?f:0,protectionData:[],appendWindow:[a,o]};let d=qe(r.type,r.mimeType);if(d===\"webm\")throw new Error(\"Text tracks with a WEBM container are not yet handled.\");return d===\"mp4\"?Bd(u,l,r,i,n):Ud(u,l,r)}}function es(n){let e=Di({customManifestLoader:n.manifestLoader},Ld()?\"text\":\"arraybuffer\"),t=Ni(n),r=Ki(n),i=Xi(n),a=Zi(n),o=Ji(n);return{manifest:{loadManifest:e,parseManifest:t},audio:{loadSegment:r,parseSegment:i},video:{loadSegment:r,parseSegment:i},text:{loadSegment:a,parseSegment:o}}}function Ld(){return ae.dashParsers.wasm!==null&&(ae.dashParsers.wasm.status===\"initialized\"||ae.dashParsers.wasm.status===\"initializing\")}var ts=es;var Ct=typeof queueMicrotask==\"function\"?queueMicrotask:function(e){Promise.resolve().then(e,()=>e())};var At=class{constructor(e){this._array=[],this._sortingFn=e}add(...e){e.sort(this._sortingFn);let t=0;for(let r=0;r<e.length;r++){let i=e[r],a=!1;for(;!a&&t<this._array.length;)this._sortingFn(i,this._array[t])<0?(this._array.splice(t,0,i),a=!0):t++;a||this._array.push(i)}}length(){return this._array.length}get(e){if(e<0||e>=this._array.length)throw new Error(\"Invalid index.\");return this._array[e]}toArray(){return this._array.slice()}findFirst(e){return K(this._array,e)}has(e){return se(this._array,e)}removeElement(e){let t=this._array.indexOf(e);if(t>=0)return this._array.splice(t,1),t}head(){return this._array[0]}last(){return this._array[this._array.length-1]}shift(){return this._array.shift()}pop(){return this._array.pop()}};var En=class{constructor(e){this._weakMap=new WeakMap,this._fn=e}get(e){let t=this._weakMap.get(e);if(t===void 0){let r=this._fn(e);return this._weakMap.set(e,r),r}else return t}destroy(e){this._weakMap.delete(e)}};var Fd=.016666666666666666;function ns(n,e){return Math.abs(n-e)<Fd}function is(n,e){let t=Math.min(n.start,e.start),r=Math.max(n.end,e.end);return{start:t,end:r}}function zd(n){for(let e=0;e<n.length;e++){let t=n[e];t.start===t.end&&n.splice(e--,1)}return n}function Wd(n){for(let e=1;e<n.length;e++){let t=n[e-1],r=n[e];if(os(t,r)){let i=is(t,r);n.splice(--e,2,i)}}return n}function ea(n,e){return n.end<=e.start}function rs({start:n,end:e},t){return n<=t&&t<e}function as(n,e){return rs(n,e.start)||n.start<e.end&&e.end<n.end||rs(e,n.start)}function os(n,e){return ns(e.start,n.end)||ns(e.end,n.start)}function ta(n){let e=[];for(let t=0;t<n.length;t++)e.push({start:n.start(t),end:n.end(t)});return e}function Vd(n,e){for(let t=n.length-1;t>=0;t--){let r=n[t].start;if(e>=r){let i=n[t].end;if(e<i)return n[t]}}return null}function ss(n,e){let t=null,r=[];for(let i=0;i<n.length;i++){let a=n[i].start,o=n[i].end;e<a||e>=o?r.push({start:a,end:o}):t={start:a,end:o}}return{outerRanges:r,innerRange:t}}function Ar(n,e){let t=Vd(n,e);return t!==null?t.end-e:1/0}function zt(n,e){if(e.start===e.end)return n;let t=e,r=0;for(;r<n.length;r++){let i=n[r],a=as(t,i),o=os(t,i);if(a||o)t=is(t,i),n.splice(r--,1);else if(r===0){if(ea(t,n[0]))break}else if(ea(n[r-1],t)&&ea(t,i))break}return n.splice(r,0,t),Wd(zd(n))}function qd(n,e){let t=[];for(let r=0;r<e.length;r++)as(n,e[r])&&t.push(e[r]);return t}function kr(n,e){let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=[],o=qd(i,e);if(o.length>0)for(let s=0;s<o.length;s++){let u=o[s];a.push({start:Math.max(i.start,u.start),end:Math.min(i.end,u.end)})}if(a.length===0)t.push(i);else{let s=i.start;for(let u=0;u<a.length;u++)a[u].start>s&&t.push({start:s,end:a[u].start}),s=a[u].end;s<i.end&&t.push({start:s,end:i.end})}}return t}function xr({segmentSink:n,playbackObserver:e,maxBufferBehind:t,maxBufferAhead:r},i){let a,o=[];e.listen(u=>{a=u.position.getWanted(),o=u.buffered[n.bufferType],s()},{includeLastObservation:!0,clearSignal:i});function s(){o!==null&&Hd(n,a,o,t.getValue(),r.getValue(),i).catch(u=>{let l=u instanceof Error?u.message:\"Unknown error\";c.error(\"Could not run BufferGarbageCollector:\",l)})}t.onUpdate(s,{clearSignal:i}),r.onUpdate(s,{clearSignal:i}),s()}async function Hd(n,e,t,r,i,a){if(!isFinite(r)&&!isFinite(i))return Promise.resolve();let o=[],{innerRange:s,outerRanges:u}=ss(t,e),l=()=>{if(isFinite(r)){for(let f=0;f<u.length;f++){let m=u[f];e-r>=m.end?o.push(m):e>=m.end&&e-r>m.start&&e-r<m.end&&o.push({start:m.start,end:e-r})}v(s)||e-r>s.start&&o.push({start:s.start,end:e-r})}},d=()=>{if(isFinite(i)){for(let f=0;f<u.length;f++){let m=u[f];e+i<=m.start?o.push(m):e<=m.start&&e+i<m.end&&e+i>m.start&&o.push({start:e+i,end:m.end})}v(s)||e+i<s.end&&o.push({start:e+i,end:s.end})}};l(),d();for(let f of o)if(f.start<f.end){if(c.debug(\"GC: cleaning range from SegmentSink\",f.start,f.end),a.cancellationError!==null)throw a.cancellationError;await n.removeBuffer(f.start,f.end)}}var Rn=class{constructor(e,t){this._history=[],this._lifetime=e,this._maxHistoryLength=t}addBufferedSegment(e,t){let r=L();this._history.push({date:r,buffered:t,context:e}),this._cleanHistory(r)}getHistoryFor(e){return this._history.filter(t=>Ze(t.context,e))}_cleanHistory(e){let t=e-this._lifetime,r=0;for(let i of this._history)if(i.date<t)r++;else break;if(r>0&&(this._history=this._history.splice(r)),this._history.length>this._maxHistoryLength){let i=this._history.length-this._maxHistoryLength;this._history=this._history.splice(i)}}};var Pn=class{constructor(){let{BUFFERED_HISTORY_RETENTION_TIME:e,BUFFERED_HISTORY_MAXIMUM_ENTRIES:t}=U.getCurrent();this._inventory=[],this._bufferedHistory=new Rn(e,t)}reset(){this._inventory.length=0}synchronizeBuffered(e){var u,l,d,f,m,p,g;let t=this._inventory,r=0,i=t[0],{MINIMUM_SEGMENT_SIZE:a}=U.getCurrent(),o=i==null?void 0:i.infos.adaptation.type;if(c.hasLevel(\"DEBUG\")){let h=e.map(I=>`${I.start}-${I.end}`).join(\",\");c.debug(`SI: synchronizing ${o!=null?o:\"unknown\"} buffered ranges:`,h)}let s=e.length;for(let h=0;h<s;h++){if(i===void 0)return;let I=e[h].start,y=e[h].end;if(y-I<a){c.warn(\"SI: skipped range when synchronizing because it was too small\",o,I,y);continue}let E=r;for(;i!==void 0&&((u=i.bufferedEnd)!=null?u:i.end)-I<a;)i=t[++r];let R=null,T=r-E;if(T>0){let P=t[E+T-1];R={end:(l=P.bufferedEnd)!=null?l:P.end,precizeEnd:P.precizeEnd},c.debug(`SI: ${T} segments GCed.`,o);let x=t.splice(E,T);for(let _ of x)_.bufferedStart===void 0&&_.bufferedEnd===void 0&&_.status!==2&&this._bufferedHistory.addBufferedSegment(_.infos,null);r=E}if(i===void 0)return;if(y-((d=i.bufferedStart)!=null?d:i.start)>=a){if(Gd(i,I,R,o),r===t.length-1){ds(i,y,o);return}i=t[++r];let P=(f=i.bufferedStart)!=null?f:i.start,x=(m=i.bufferedEnd)!=null?m:i.end,_=h<s-1?e[h+1].start:void 0;for(;i!==void 0&&!(y<P||y-P<a&&x-y>=a||_!==void 0&&y-P<x-_);){let A=t[r-1];A.bufferedEnd===void 0&&(i.precizeStart?A.bufferedEnd=i.start:A.infos.segment.complete?A.bufferedEnd=A.end:A.bufferedEnd=i.start,c.debug(\"SI: calculating buffered end of contiguous segment\",o,A.bufferedEnd,A.end)),i.bufferedStart=A.bufferedEnd,i=t[++r],i!==void 0&&(P=(p=i.bufferedStart)!=null?p:i.start,x=(g=i.bufferedEnd)!=null?g:i.end)}}let C=t[r-1];C!==void 0&&ds(C,y,o)}if(!v(i)){let{SEGMENT_SYNCHRONIZATION_DELAY:h}=U.getCurrent(),I=L();for(let y=r;y<t.length;y++){let E=t[y];I-E.insertionTs>=h&&(c.debug(\"SI: A segment at the end has been completely GCed\",o,`${E.start}-${E.end}`),E.bufferedStart===void 0&&E.bufferedEnd===void 0&&E.status!==2&&this._bufferedHistory.addBufferedSegment(E.infos,null),t.splice(y,1),y--)}}o!==void 0&&c.hasLevel(\"DEBUG\")&&c.debug(`SI: current ${o} inventory timeline:\n`+Kd(this._inventory))}insertChunk({period:e,adaptation:t,representation:r,segment:i,chunkSize:a,start:o,end:s},u,l){if(i.isInit)return;let d=t.type;if(o>=s){c.warn(\"SI: Invalid chunked inserted: starts before it ends\",d,o,s);return}let f=this._inventory,m={status:u?0:2,insertionTs:l,chunkSize:a,splitted:!1,start:o,end:s,precizeStart:!1,precizeEnd:!1,bufferedStart:void 0,bufferedEnd:void 0,infos:{segment:i,period:e,adaptation:t,representation:r}};for(let g=f.length-1;g>=0;g--){let h=f[g];if(h.start<=o)if(h.end<=o){for(c.debug(\"SI: Pushing segment strictly after previous one.\",d,o,h.end),this._inventory.splice(g+1,0,m),g+=2;g<f.length&&f[g].start<m.end;){if(f[g].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",d,m.end,f[g].start),f[g].start=m.end,f[g].bufferedStart=void 0,f[g].precizeStart=f[g].precizeStart&&m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",d,o,s,f[g].start,f[g].end),f.splice(g,1)}return}else if(h.start===o)if(h.end<=s){for(c.debug(\"SI: Segment pushed replace another one\",d,o,s,h.end),this._inventory.splice(g,1,m),g+=1;g<f.length&&f[g].start<m.end;){if(f[g].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",d,m.end,f[g].start),f[g].start=m.end,f[g].bufferedStart=void 0,f[g].precizeStart=f[g].precizeStart&&m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",d,o,s,f[g].start,f[g].end),f.splice(g,1)}return}else{c.debug(\"SI: Segment pushed ends before another with the same start\",d,o,s,h.end),f.splice(g,0,m),h.start=m.end,h.bufferedStart=void 0,h.precizeStart=h.precizeStart&&m.precizeEnd;return}else if(h.end<=m.end){for(c.debug(\"SI: Segment pushed updates end of previous one\",d,o,s,h.start,h.end),this._inventory.splice(g+1,0,m),h.end=m.start,h.bufferedEnd=void 0,h.precizeEnd=h.precizeEnd&&m.precizeStart,g+=2;g<f.length&&f[g].start<m.end;){if(f[g].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",d,m.end,f[g].start),f[g].start=m.end,f[g].bufferedStart=void 0,f[g].precizeStart=f[g].precizeStart&&m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",d,o,s,f[g].start,f[g].end),f.splice(g,1)}return}else{c.warn(\"SI: Segment pushed is contained in a previous one\",d,o,s,h.start,h.end);let I={status:h.status,insertionTs:h.insertionTs,chunkSize:h.chunkSize,splitted:!0,start:m.end,end:h.end,precizeStart:h.precizeStart&&h.precizeEnd&&m.precizeEnd,precizeEnd:h.precizeEnd,bufferedStart:void 0,bufferedEnd:h.end,infos:h.infos};h.end=m.start,h.splitted=!0,h.bufferedEnd=void 0,h.precizeEnd=h.precizeEnd&&m.precizeStart,f.splice(g+1,0,m),f.splice(g+2,0,I);return}}let p=this._inventory[0];if(p===void 0){c.debug(\"SI: first segment pushed\",d,o,s),this._inventory.push(m);return}if(p.start>=s)c.debug(\"SI: Segment pushed comes before all previous ones\",d,o,s,p.start),this._inventory.splice(0,0,m);else if(p.end<=s){for(c.debug(\"SI: Segment pushed starts before and completely recovers the previous first one\",d,o,s,p.start,p.end),this._inventory.splice(0,1,m);f.length>1&&f[1].start<m.end;){if(f[1].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",d,m.end,f[1].start),f[1].start=m.end,f[1].bufferedStart=void 0,f[1].precizeStart=m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",d,o,s,f[1].start,f[1].end),f.splice(1,1)}return}else{c.debug(\"SI: Segment pushed start of the next one\",d,o,s,p.start,p.end),p.start=s,p.bufferedStart=void 0,p.precizeStart=m.precizeEnd,this._inventory.splice(0,0,m);return}}completeSegment(e){if(e.segment.isInit)return;let t=this._inventory,r=[];for(let i=0;i<t.length;i++)if(Ze(t[i].infos,e)){let a=!1;r.length>0&&(a=!0,r.length===1&&(c.warn(\"SI: Completed Segment is splitted.\",e.segment.id,e.segment.time,e.segment.end),r[0].splitted=!0));let o=i,s=t[i].chunkSize;for(i+=1;i<t.length&&Ze(t[i].infos,e);){let m=t[i].chunkSize;s!==void 0&&m!==void 0&&(s+=m),i++}let u=i-1,l=u-o,d=t[u].end,f=t[u].bufferedEnd;l>0&&(this._inventory.splice(o+1,l),i-=l),this._inventory[o].status===0&&(this._inventory[o].status=1),this._inventory[o].chunkSize=s,this._inventory[o].end=d,this._inventory[o].bufferedEnd=f,this._inventory[o].splitted=a,r.push(this._inventory[o])}if(r.length===0)c.warn(\"SI: Completed Segment not found\",e.segment.id,e.segment.time);else for(let i of r)i.bufferedStart!==void 0&&i.bufferedEnd!==void 0?i.status!==2&&this._bufferedHistory.addBufferedSegment(i.infos,{start:i.bufferedStart,end:i.bufferedEnd}):c.debug(\"SI: buffered range not known after sync. Skipping history.\",i.start,i.end)}getInventory(){return this._inventory}getHistoryFor(e){return this._bufferedHistory.getHistoryFor(e)}};function na(n){if(n.bufferedStart===void 0||n.status!==1)return!1;let{start:e,end:t}=n,r=t-e,{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:a}=U.getCurrent();return Math.abs(e-n.bufferedStart)<=i&&(n.bufferedEnd===void 0||n.bufferedEnd>n.bufferedStart&&Math.abs(n.bufferedEnd-n.bufferedStart-r)<=Math.min(a,r/3))}function us(n){if(n.bufferedEnd===void 0||!n.infos.segment.complete||n.status!==1)return!1;let{start:e,end:t}=n,r=t-e,{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:a}=U.getCurrent();return Math.abs(t-n.bufferedEnd)<=i&&n.bufferedStart!==void 0&&n.bufferedEnd>n.bufferedStart&&Math.abs(n.bufferedEnd-n.bufferedStart-r)<=Math.min(a,r/3)}function Gd(n,e,t,r){let{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MISSING_DATA_TRIGGER_SYNC_DELAY:a,SEGMENT_SYNCHRONIZATION_DELAY:o}=U.getCurrent();if(n.bufferedStart!==void 0)n.bufferedStart<e&&(c.debug(\"SI: Segment partially GCed at the start\",r,n.bufferedStart,e),n.bufferedStart=e),!n.precizeStart&&na(n)&&(n.start=n.bufferedStart,n.precizeStart=!0);else if(n.precizeStart)c.debug(\"SI: buffered start is precize start\",r,n.start),n.bufferedStart=n.start;else if(t!==null&&t.end>e&&(t.precizeEnd||n.start-t.end<=i))c.debug(\"SI: buffered start is end of previous segment\",r,e,n.start,t.end),n.bufferedStart=t.end,na(n)&&(n.start=t.end,n.precizeStart=!0);else if(n.start-e<=i){let s=L();if(n.start-e>=a&&s-n.insertionTs<o){c.debug(\"SI: Ignored bufferedStart synchronization\",r,e,n.start,s-n.insertionTs);return}c.debug(\"SI: found true buffered start\",r,e,n.start),n.bufferedStart=e,na(n)&&(n.start=e,n.precizeStart=!0)}else if(e<n.start)c.debug(\"SI: range start too far from expected start\",r,e,n.start),n.bufferedStart=n.start;else{let s=L();if(n.start-e>=a&&s-n.insertionTs<o){c.debug(\"SI: Ignored bufferedStart synchronization\",r,e,n.start,s-n.insertionTs);return}c.debug(\"SI: Segment appears immediately garbage collected at the start\",r,e,n.start),n.bufferedStart=e}}function ds(n,e,t){let{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:r,MISSING_DATA_TRIGGER_SYNC_DELAY:i,SEGMENT_SYNCHRONIZATION_DELAY:a}=U.getCurrent();if(n.bufferedEnd!==void 0)n.bufferedEnd>e&&(c.debug(\"SI: Segment partially GCed at the end\",t,n.bufferedEnd,e),n.bufferedEnd=e),!n.precizeEnd&&e-n.end<=r&&us(n)&&(n.precizeEnd=!0,n.end=e);else if(n.precizeEnd)c.debug(\"SI: buffered end is precize end\",t,n.end),n.bufferedEnd=n.end;else if(e-n.end<=r||!n.infos.segment.complete){let o=L();if(e-n.end>=i&&o-n.insertionTs<a){c.debug(\"SI: Ignored bufferedEnd synchronization\",t,e,n.end,o-n.insertionTs);return}c.debug(\"SI: found true buffered end\",t,e,n.end),n.bufferedEnd=e,us(n)&&(n.end=e,n.precizeEnd=!0)}else if(e>n.end)c.debug(\"SI: range end too far from expected end\",t,e,n.end),n.bufferedEnd=n.end;else{let o=L();if(e-n.end>=i&&o-n.insertionTs<a){c.debug(\"SI: Ignored bufferedEnd synchronization\",t,e,n.end,o-n.insertionTs);return}c.debug(\"SI: Segment appears immediately garbage collected at the end\",t,n.bufferedEnd,e),n.bufferedEnd=e}}function Kd(n){let e=.016666666666666666,t={},r=[],i=null,a=null;function o(u){let l=String.fromCharCode(r.length+65);return r.push({letter:l,periodId:u.period.id,representationId:u.representation.id,bitrate:u.representation.bitrate}),l}let s=\"\";for(let u=0;u<n.length;u++){let l=n[u];if(l.bufferedStart!==void 0&&l.bufferedEnd!==void 0){let d=l.infos.period.id,f=l.infos.representation.id,m=t[d],p;m===void 0?(p=o(l.infos),t[d]={[f]:p}):m[f]===void 0?(p=o(l.infos),m[f]=p):p=m[f],i===null?s+=`${l.bufferedStart.toFixed(2)}|${p}|`:a===p?i.bufferedEnd+e<l.bufferedStart&&(s+=`${i.bufferedEnd.toFixed(2)} ~ ${l.bufferedStart.toFixed(2)}|${p}|`):s+=`${i.bufferedEnd.toFixed(2)} ~ ${l.bufferedStart.toFixed(2)}|${p}|`,i=l,a=p}}return i!==null&&(s+=String(i.end.toFixed(2))),r.forEach(u=>{var l;s+=`\n[${u.letter}] P: ${u.periodId} || R: ${u.representationId}(${(l=u.bitrate)!=null?l:\"unknown bitrate\"})`}),s}function Wt(n,e){for(let t=0;t<n.length;t++)if(n[t].infos.period.start>=e.start)return t>0?n[t-1]:null;return n.length>0?n[n.length-1]:null}function Vt(n,e){for(let t=0;t<n.length;t++)if(n[t].infos.period.start>e.start)return n[t];return null}var ls=Pn;var qt=class{constructor(){this._segmentInventory=new ls}synchronizeInventory(e){this._segmentInventory.synchronizeBuffered(e)}getLastKnownInventory(){return this._segmentInventory.getInventory()}getSegmentHistory(e){return this._segmentInventory.getHistoryFor(e)}};var vn=class extends qt{constructor(e,t,r){super(),c.info(\"AVSB: calling `mediaSource.addSourceBuffer`\",t);let i=r.addSourceBuffer(e,t);this.bufferType=e,this._sourceBuffer=i,this._lastInitSegmentUniqueId=null,this.codec=t,this._initSegmentsMap=new Map,this._pendingOperations=[]}declareInitSegment(e,t){fs(t),this._initSegmentsMap.set(e,t)}freeInitSegment(e){this._initSegmentsMap.delete(e)}async pushChunk(e){fs(e.data.chunk),c.debug(\"AVSB: receiving order to push data to the SourceBuffer\",this.bufferType,bt(e.inventoryInfos));let t=this._getActualDataToPush(e.data);t.length===0&&t.push(new Uint8Array);let r=Promise.all(t.map(o=>{let{codec:s,timestampOffset:u,appendWindow:l}=e.data;return c.debug(\"AVSB: pushing segment\",this.bufferType,bt(e.inventoryInfos)),this._sourceBuffer.appendBuffer(o,{codec:s,timestampOffset:u,appendWindow:l})}));this._addToOperationQueue(r,{type:0,value:e});let i;try{i=await r}catch(o){throw this._segmentInventory.insertChunk(e.inventoryInfos,!1,L()),o}e.inventoryInfos!==null&&this._segmentInventory.insertChunk(e.inventoryInfos,!0,L());let a=i[i.length-1];return this._segmentInventory.synchronizeBuffered(a),a}async removeBuffer(e,t){c.debug(\"AVSB: receiving order to remove data from the SourceBuffer\",this.bufferType,e,t);let r=this._sourceBuffer.remove(e,t);this._addToOperationQueue(r,{type:1,value:{start:e,end:t}});let i=await r;return this._segmentInventory.synchronizeBuffered(i),i}async signalSegmentComplete(e){if(this._pendingOperations.length>0){let{promise:t}=this._pendingOperations[this._pendingOperations.length-1];this._addToOperationQueue(t,{type:2,value:e});try{await t}catch(r){}}this._segmentInventory.completeSegment(e)}getPendingOperations(){return this._pendingOperations.map(e=>e.operation)}dispose(){try{c.debug(\"AVSB: Calling `dispose` on the SourceBufferInterface\"),this._sourceBuffer.dispose()}catch(e){c.debug(`AVSB: Failed to dispose a ${this.bufferType} SourceBufferInterface:`,e instanceof Error?e:\"\")}}_getActualDataToPush(e){let t=[];if(e.initSegmentUniqueId!==null&&!this._isLastInitSegment(e.initSegmentUniqueId)){let r=this._initSegmentsMap.get(e.initSegmentUniqueId);if(r===void 0)throw new Error(\"Invalid initialization segment uniqueId\");let i=new ArrayBuffer(r.byteLength),a=new Uint8Array(i);a.set(r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer)),r=a,t.push(r),this._lastInitSegmentUniqueId=e.initSegmentUniqueId}return e.chunk!==null&&t.push(e.chunk),t}_isLastInitSegment(e){return this._lastInitSegmentUniqueId===null?!1:this._lastInitSegmentUniqueId===e}_addToOperationQueue(e,t){let r={operation:t,promise:e};this._pendingOperations.push(r);let i=()=>{let a=this._pendingOperations.indexOf(r);a>=0&&this._pendingOperations.splice(a,1)};e.then(i,i)}};function fs(n){if(b.CURRENT_ENV!==b.PRODUCTION&&(typeof n!=\"object\"||n!==null&&!(n instanceof ArrayBuffer)&&!(n.buffer instanceof ArrayBuffer)))throw new Error(\"Invalid data given to the AudioVideoSegmentSink\")}var Or=vn;var Cn=class extends qt{constructor(e){c.debug(\"HTSB: Creating TextSegmentSink\"),super(),this.bufferType=\"text\",this._sender=e,this._pendingOperations=[],this._sender.reset()}declareInitSegment(e){c.warn(\"HTSB: Declaring initialization segment for Text SegmentSink\",e)}freeInitSegment(e){c.warn(\"HTSB: Freeing initialization segment for Text SegmentSink\",e)}async pushChunk(e){let{data:t}=e;Yd(t.chunk);let r=this._sender.pushTextData(Le(_e({},t),{chunk:t.chunk}));this._addToOperationQueue(r,{type:0,value:e});let i=await r;return e.inventoryInfos!==null&&this._segmentInventory.insertChunk(e.inventoryInfos,!0,L()),this._segmentInventory.synchronizeBuffered(i),i}async removeBuffer(e,t){let r=this._sender.remove(e,t);this._addToOperationQueue(r,{type:1,value:{start:e,end:t}});let i=await r;return this._segmentInventory.synchronizeBuffered(i),i}async signalSegmentComplete(e){if(this._pendingOperations.length>0){let{promise:t}=this._pendingOperations[this._pendingOperations.length-1];this._addToOperationQueue(t,{type:2,value:e});try{await t}catch(r){}}this._segmentInventory.completeSegment(e)}getPendingOperations(){return this._pendingOperations.map(e=>e.operation)}dispose(){c.debug(\"HTSB: Disposing TextSegmentSink\"),this._sender.reset()}_addToOperationQueue(e,t){let r={operation:t,promise:e};this._pendingOperations.push(r);let i=()=>{let a=this._pendingOperations.indexOf(r);a>=0&&this._pendingOperations.splice(a,1)};e.then(i,i)}};function Yd(n){if(b.CURRENT_ENV!==b.PRODUCTION&&(typeof n!=\"object\"||n===null||typeof n.data!=\"string\"||typeof n.type!=\"string\"||n.language!==void 0&&typeof n.language!=\"string\"||n.start!==void 0&&typeof n.start!=\"number\"||n.end!==void 0&&typeof n.end!=\"number\"))throw new Error(\"Invalid format given to a TextSegmentSink\")}b.CURRENT_ENV===b.DEV&&(Qd=function(e){function t(r){}});var Qd;var ms=Cn;function kt(n,e){let t;return new Promise((r,i)=>{if(n.cancellationError!==null)return i(n.cancellationError);let a=!1;t=e(function(u){n.deregister(o),a=!0,r(u)},function(u){n.deregister(o),a=!0,i(u)}),a||n.register(o);function o(s){t!==void 0&&t(),i(s)}})}var $d=[\"audio\",\"video\",\"text\"],An=class n{static isNative(e){return cs(e)}constructor(e,t,r){this._mediaSource=e,this._textInterface=r,this._hasVideo=t,this._initializedSegmentSinks={},this._onNativeBufferAddedOrDisabled=[]}getBufferTypes(){let e=this.getNativeBufferTypes();return this._textInterface!==null&&e.push(\"text\"),e}getNativeBufferTypes(){return this._hasVideo?[\"video\",\"audio\"]:[\"audio\"]}getStatus(e){let t=this._initializedSegmentSinks[e];return t===void 0?{type:\"uninitialized\"}:t===null?{type:\"disabled\"}:{type:\"initialized\",value:t}}waitForUsableBuffers(e){return this._areNativeBuffersUsable()?Promise.resolve():kt(e,t=>{let r,i=()=>{let a=this._onNativeBufferAddedOrDisabled.indexOf(r);a>=0&&this._onNativeBufferAddedOrDisabled.splice(a,1)};return r=()=>{this._areNativeBuffersUsable()&&(i(),t())},this._onNativeBufferAddedOrDisabled.push(r),i})}disableSegmentSink(e){let t=this._initializedSegmentSinks[e];if(t===null){c.warn(`SBS: The ${e} SegmentSink was already disabled.`);return}if(t!==void 0)throw new Error(\"Cannot disable an active SegmentSink.\");this._initializedSegmentSinks[e]=null,n.isNative(e)&&this._onNativeBufferAddedOrDisabled.forEach(r=>r())}createSegmentSink(e,t){let r=this._initializedSegmentSinks[e];if(cs(e)){if(!v(r))return r instanceof Or&&r.codec!==t?c.warn(\"SB: Reusing native SegmentSink with codec\",r.codec,\"for codec\",t):c.info(\"SB: Reusing native SegmentSink with codec\",t),r;c.info(\"SB: Adding native SegmentSink with codec\",t);let a=e===\"audio\"?\"audio\":\"video\",o=new Or(a,t,this._mediaSource);return this._initializedSegmentSinks[e]=o,this._onNativeBufferAddedOrDisabled.forEach(s=>s()),o}if(!v(r))return c.info(\"SB: Reusing a previous custom SegmentSink for the type\",e),r;let i;if(e===\"text\"){if(c.info(\"SB: Creating a new text SegmentSink\"),this._textInterface===null)throw new Error(\"HTML Text track feature not activated\");return i=new ms(this._textInterface),this._initializedSegmentSinks.text=i,i}throw c.error(\"SB: Unknown buffer type:\",e),new j(\"BUFFER_TYPE_UNKNOWN\",\"The player wants to create a SegmentSink of an unknown type.\")}disposeSegmentSink(e){let t=this._initializedSegmentSinks[e];if(v(t)){c.warn(\"SB: Trying to dispose a SegmentSink that does not exist\");return}c.info(\"SB: Aborting SegmentSink\",e),t.dispose(),delete this._initializedSegmentSinks[e]}disposeAll(){$d.forEach(e=>{this.getStatus(e).type===\"initialized\"&&this.disposeSegmentSink(e)})}_areNativeBuffersUsable(){let e=this.getNativeBufferTypes();return!(e.some(i=>this._initializedSegmentSinks[i]===void 0)||e.every(i=>this._initializedSegmentSinks[i]===null))}};function cs(n){return n===\"audio\"||n===\"video\"}var ht=An;function kn(n,e){return kt(e,t=>{let r=setTimeout(()=>t(),n);return()=>clearTimeout(r)})}var xn=class extends oe{constructor(e,t,r,i){super(),this._content=e,this._currentCanceller=null,this._downloadQueue=t,this._initSegmentRequest=null,this._mediaSegmentRequest=null,this._segmentFetcher=r,this._initSegmentInfoRef=new G(void 0),this._mediaSegmentAwaitingInitMetadata=null,i||this._initSegmentInfoRef.setValue(null)}getRequestedInitSegment(){return this._initSegmentRequest===null?null:this._initSegmentRequest.segment}getRequestedMediaSegment(){return this._mediaSegmentRequest===null?null:this._mediaSegmentRequest.segment}start(){this._currentCanceller===null&&(this._currentCanceller=new W,this._downloadQueue.onUpdate(e=>{let{segmentQueue:t}=e;if(t.length>0&&t[0].segment.id===this._mediaSegmentAwaitingInitMetadata)return;let r=this._mediaSegmentRequest;if(t.length===0){if(r===null)return;c.debug(\"Stream: no more media segment to request. Cancelling queue.\",this._content.adaptation.type),this._restartMediaSegmentDownloadingQueue();return}else if(r===null){c.debug(\"Stream: Media segments now need to be requested. Starting queue.\",this._content.adaptation.type,t.length),this._restartMediaSegmentDownloadingQueue();return}else{let i=t[0];if(r.segment.id!==i.segment.id){c.debug(\"Stream: Next media segment changed, cancelling previous\",this._content.adaptation.type),this._restartMediaSegmentDownloadingQueue();return}r.priority!==i.priority&&(c.debug(\"Stream: Priority of next media segment changed, updating\",this._content.adaptation.type,r.priority,i.priority),this._segmentFetcher.updatePriority(r.request,i.priority));return}},{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}),this._downloadQueue.onUpdate(e=>{var r;let t=this._initSegmentRequest;if(e.initSegment!==null&&t!==null){e.initSegment.priority!==t.priority&&this._segmentFetcher.updatePriority(t.request,e.initSegment.priority);return}else if(((r=e.initSegment)==null?void 0:r.segment.id)===(t==null?void 0:t.segment.id))return;e.initSegment===null&&c.debug(\"Stream: no more init segment to request. Cancelling queue.\",this._content.adaptation.type),this._restartInitSegmentDownloadingQueue(e.initSegment)},{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}))}stop(){var e;(e=this._currentCanceller)==null||e.cancel(),this._currentCanceller=null}_restartMediaSegmentDownloadingQueue(){this._mediaSegmentRequest!==null&&this._mediaSegmentRequest.canceller.cancel();let{segmentQueue:e}=this._downloadQueue.getValue(),t=e[0],r=i=>{if(this._currentCanceller!==null&&this._currentCanceller.isUsed()){this._mediaSegmentRequest=null;return}if(i===void 0){this._mediaSegmentRequest=null,this.trigger(\"emptyQueue\",null);return}let a=new W,o=this._currentCanceller===null?N:a.linkToSignal(this._currentCanceller.signal),{segment:s,priority:u}=i,l=H({segment:s},this._content),d=!1,f=!1;a.signal.register(()=>{this._mediaSegmentRequest=null,!d&&(this._mediaSegmentAwaitingInitMetadata===s.id&&(this._mediaSegmentAwaitingInitMetadata=null),d=!0,f=!1)});let m=h=>{he(h.segmentType===\"media\",\"Should have loaded a media segment.\"),this.trigger(\"parsedMediaSegment\",H({},h,{segment:s}))},p=()=>{let h=this._downloadQueue.getValue().segmentQueue;if(h.length===0){d=!0,this.trigger(\"emptyQueue\",null);return}else h[0].segment.id===s.id&&h.shift();d=!0,r(h[0])},g=this._segmentFetcher.createRequest(l,u,{onRetry:h=>{this.trigger(\"requestRetry\",{segment:s,error:h})},beforeInterrupted(){c.info(\"Stream: segment request interrupted temporarly.\",s.id,s.time)},onChunk:h=>{let I=this._initSegmentInfoRef.getValue();I!==void 0?m(h(I!=null?I:void 0)):(f=!0,this._initSegmentInfoRef.waitUntilDefined(y=>{m(h(y!=null?y:void 0))},{clearSignal:a.signal}))},onAllChunksReceived:()=>{f?(this._mediaSegmentAwaitingInitMetadata=s.id,this._initSegmentInfoRef.waitUntilDefined(()=>{this._mediaSegmentAwaitingInitMetadata=null,f=!1,this.trigger(\"fullyLoadedSegment\",s)},{clearSignal:a.signal})):this.trigger(\"fullyLoadedSegment\",s)},beforeEnded:()=>{o(),this._mediaSegmentRequest=null,f?this._initSegmentInfoRef.waitUntilDefined(p,{clearSignal:a.signal}):p()}},a.signal);g.catch(h=>{o(),d||(d=!0,this.stop(),this.trigger(\"error\",h))}),this._mediaSegmentRequest={segment:s,priority:u,request:g,canceller:a}};r(t)}_restartInitSegmentDownloadingQueue(e){if(this._currentCanceller!==null&&this._currentCanceller.isUsed()||(this._initSegmentRequest!==null&&this._initSegmentRequest.canceller.cancel(),e===null))return;let t=new W,r=this._currentCanceller===null?N:t.linkToSignal(this._currentCanceller.signal),{segment:i,priority:a}=e,o=H({segment:i},this._content),s=!1,u=this._segmentFetcher.createRequest(o,a,{onRetry:l=>{this.trigger(\"requestRetry\",{segment:i,error:l})},beforeInterrupted:()=>{c.info(\"Stream: init segment request interrupted temporarly.\",i.id)},beforeEnded:()=>{r(),this._initSegmentRequest=null,s=!0},onChunk:l=>{var f;let d=l(void 0);he(d.segmentType===\"init\",\"Should have loaded an init segment.\"),this.trigger(\"parsedInitSegment\",H({},d,{segment:i})),d.segmentType===\"init\"&&this._initSegmentInfoRef.setValue((f=d.initTimescale)!=null?f:null)},onAllChunksReceived:()=>{this.trigger(\"fullyLoadedSegment\",i)}},t.signal);u.catch(l=>{r(),s||(s=!0,this.stop(),this.trigger(\"error\",l))}),t.signal.register(()=>{this._initSegmentRequest=null,!s&&(s=!0)}),this._initSegmentRequest={segment:i,priority:a,request:u,canceller:t}}};function ra(n,e,t,r,i){let{period:a,adaptation:o,representation:s}=n,u=Xd(i,e);if(u===null){if(t===null){if(r&&a.end!==void 0&&e.end>=a.end)return{start:void 0,end:null};let f=s.index.checkDiscontinuity(e.start);if(f!==null)return{start:void 0,end:f}}return null}let l=i[u];if(l.bufferedStart!==void 0&&l.bufferedStart>e.start&&(t===null||l.infos.segment.end<=t)){let f=l.bufferedStart;return!r&&s.index.awaitSegmentBetween(e.start,f)!==!1?null:(c.debug(\"RS: current discontinuity encountered\",o.type,l.bufferedStart),{start:void 0,end:f})}let d=Zd(i,e,u+1);if(d!==null){let f=i[d-1],m=i[d];if(t===null||m.infos.segment.end<=t){if(!r&&s.index.awaitSegmentBetween(f.infos.segment.end,m.infos.segment.time)!==!1)return null;let p=f.bufferedEnd,g=m.bufferedStart;return c.debug(\"RS: future discontinuity encountered\",o.type,p,g),{start:p,end:g}}}if(t===null){if(r&&a.end!==void 0){if(e.end<a.end)return null;let f=Jd(i,a.end);if(f!==null){let m=i[f];if(m.bufferedEnd!==void 0&&m.bufferedEnd<a.end)return c.debug(\"RS: discontinuity encountered at the end of the current period\",o.type,m.bufferedEnd,a.end),{start:m.bufferedEnd,end:null}}}if(a.end!==void 0&&e.end>=a.end)return null;for(let f=i.length-1;f>=0;f--){let m=i[f];if(m.bufferedStart===void 0)break;if(m.bufferedStart<e.end){if(m.bufferedEnd!==void 0&&m.bufferedEnd<e.end){let p=s.index.checkDiscontinuity(e.end);if(p!==null)return{start:m.bufferedEnd,end:p}}return null}}}return null}function Xd(n,e){for(let t=0;t<n.length;t++){let r=n[t];if(r.bufferedStart===void 0||r.bufferedEnd===void 0||r.bufferedStart>=e.end)return null;if(r.bufferedEnd>e.start)return t}return null}function Zd(n,e,t){if(t<=0)return c.error(\"RS: Asked to check a discontinuity before the first chunk.\"),null;for(let r=t;r<n.length;r++){let i=n[r],a=n[r-1];if(i.bufferedStart===void 0||a.bufferedEnd===void 0||i.bufferedStart>=e.end)return null;if(i.bufferedStart-a.bufferedEnd>0)return r}return null}function Jd(n,e){for(let t=n.length-1;t>=0;t--){let r=n[t];if(r.bufferedStart===void 0)return null;if(r.bufferedStart<e)return t}return null}function ia({bufferedSegments:n,content:e,currentPlaybackTime:t,fastSwitchThreshold:r,getBufferedHistory:i,neededRange:a,segmentsBeingPushed:o,maxBufferSize:s}){let{adaptation:u,representation:l}=e,d=el(n,o,s),f=l.index.getSegments(a.start,a.end-a.start),m=n.filter(T=>!ps(T.infos,e,t,r)).filter((T,C,P)=>{let x=C===0?null:P[C-1],_=C>=P.length-1?null:P[C+1],A=null;if(rl(T,x,a.start)){if(A=i(T.infos),al(A,T.bufferedStart))return!1;c.debug(\"Stream: skipping segment gc-ed at the start\",T.start,T.bufferedStart)}if(il(T,_,a.end)){if(A=A!=null?A:i(T.infos),ol(A,T.bufferedEnd))return!1;c.debug(\"Stream: skipping segment gc-ed at the end\",T.end,T.bufferedEnd)}return!0}),{MINIMUM_SEGMENT_SIZE:p,MIN_BUFFER_AHEAD:g}=U.getCurrent(),h=!1,I=Math.min(1/60,p),y=!1,E=[];return{segmentsToLoad:f.filter(T=>{let C=H({segment:T},e);if(o.length>0&&o.some(D=>Ze(C,D)))return!1;let{duration:P,time:x,end:_}=T;if(T.isInit)return!0;if(h)return E.push(T),!1;if(T.complete&&P<p||o.length>0&&o.some(D=>{if(D.period.id!==e.period.id||D.adaptation.id!==e.adaptation.id)return!1;let{segment:w}=D;if(w.time-I>x)return!1;if(w.complete){if(w.end+I<_)return!1}else if(Math.abs(x-w.time)>x)return!1;return!ps(D,C,t,r)}))return!1;for(let k=0;k<m.length;k++){let D=m[k],w=D.infos.period.id===e.period.id;if(D.status===1&&w){let O=D.infos.segment;if(x-O.time>-I){if(O.complete){if(O.end-_>-I)return!1}else if(Math.abs(x-O.time)<I)return!1}}}let A=P*e.representation.bitrate;if(d-A<0&&(y=!0,x>a.start+g))return h=!0,E.push(T),!1;let M=i(C);if(M.length>1){let k=M[M.length-1],D=M[M.length-2];if(k.buffered===null&&D.buffered===null)return c.warn(\"Stream: Segment GCed multiple times in a row, ignoring it.\",\"If this happens a lot and lead to unpleasant experience, please check your device's available memory. If it's low when this message is emitted, you might want to update the RxPlayer's settings (`maxBufferAhead`, `maxVideoBufferSize` etc.) so less memory is used by regular media data buffering.\"+u.type,l.id,T.time),!1}for(let k=0;k<m.length;k++){let D=m[k];if(D.end+I>x){let w=D.start>x+I||tl(m,k).end<_-I;return w&&(d-=A),w}}return d-=A,!0}),segmentsOnHold:E,isBufferFull:y}}function el(n,e,t){let r=t*8e3;return r-=e.reduce((i,a)=>{let{bitrate:o}=a.representation,{duration:s}=a.segment;return i+o*s},0),n.reduce((i,a)=>a.chunkSize!==void 0?i-a.chunkSize*8:i,r)}function tl(n,e){let t=e+1,{MINIMUM_SEGMENT_SIZE:r}=U.getCurrent(),i=Math.min(1/60,r);for(;t<n.length-1&&n[t-1].end+i>n[t].start;)t++;return t--,n[t]}function ps(n,e,t,r){let{CONTENT_REPLACEMENT_PADDING:i}=U.getCurrent();if(n.period.id!==e.period.id)return!1;let{segment:a}=n;return a.time<t+i?!1:n.adaptation.id!==e.adaptation.id?!0:nl(n.representation,e.representation,r)}function nl(n,e,t){let r=n.bitrate,{BITRATE_REBUFFERING_RATIO:i}=U.getCurrent();if(t===void 0){let a=r*i;return e.bitrate>a}return r<t&&e.bitrate>r}function rl(n,e,t){let{MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:r}=U.getCurrent();return n.bufferedStart===void 0||e!==null&&e.bufferedEnd!==void 0&&n.bufferedStart-e.bufferedEnd<.1?!1:t<n.bufferedStart&&n.bufferedStart-n.start>r?(c.info(\"Stream: The start of the wanted segment has been garbage collected\",n.start,n.bufferedStart),!0):!1}function il(n,e,t){let{MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:r}=U.getCurrent();return n.bufferedEnd===void 0||e!==null&&e.bufferedStart!==void 0&&e.bufferedStart-n.bufferedEnd<.1?!1:t>n.bufferedEnd&&n.end-n.bufferedEnd>r?(c.info(\"Stream: The end of the wanted segment has been garbage collected\",n.end,n.bufferedEnd),!0):!1}function al(n,e){var o,s;if(n.length<2)return!0;let r=(o=n[n.length-1].buffered)==null?void 0:o.start;if(e!==void 0&&r!==void 0&&e-r>.05)return!0;let a=(s=n[n.length-2].buffered)==null?void 0:s.start;return a===void 0||r===void 0?!0:Math.abs(a-r)>.01}function ol(n,e){var o,s;if(n.length<2)return!0;let r=(o=n[n.length-1].buffered)==null?void 0:o.end;if(e!==void 0&&r!==void 0&&r-e>.05)return!0;let a=(s=n[n.length-2].buffered)==null?void 0:s.end;return a===void 0||r===void 0?!0:Math.abs(a-r)>.01}function Mn(n,e){let t=n-e,{SEGMENT_PRIORITIES_STEPS:r}=U.getCurrent();for(let i=0;i<r.length;i++)if(t<r[i])return i;return r.length}function aa(n,e,t,r,i,a,o){var _,A,M;let{representation:s}=n,u=(A=(_=t.getIsPaused())!=null?_:t.getReference().getValue().paused.pending)!=null?A:t.getReference().getValue().paused.last,l=(M=t.getPlaybackRate())!=null?M:t.getReference().getValue().speed,d=e;(u===void 0||l===void 0||u||l<=0)&&(d-=.1);let f=sl(n,d,i),m=s.index.shouldRefresh(f.start,f.end),p=o.getPendingOperations().filter(k=>k.type===2).map(k=>k.value),g=o.getLastKnownInventory(),h=t.getCurrentTime();h===void 0&&(h=t.getReference().getValue().position.getWanted());let I=o.getSegmentHistory.bind(o),{segmentsToLoad:y,segmentsOnHold:E,isBufferFull:R}=ia({content:n,bufferedSegments:g,currentPlaybackTime:h,fastSwitchThreshold:r,getBufferedHistory:I,neededRange:f,segmentsBeingPushed:p,maxBufferSize:a}),T=y.map(k=>({priority:Mn(k.time,d),segment:k})),C=s.index.isInitialized()&&!s.index.isStillAwaitingFutureSegments()&&f.hasReachedPeriodEnd&&T.length===0&&E.length===0,P=null;return p.length>0&&(P=Math.min(...p.map(k=>k.segment.time))),E.length>0&&(P=P!==null?Math.min(P,E[0].time):E[0].time),T.length>0&&(P=P!==null?Math.min(P,T[0].segment.time):T[0].segment.time),{imminentDiscontinuity:ra(n,f,P,C,g),hasFinishedLoading:C,neededSegments:T,isBufferFull:R,shouldRefreshManifest:m}}function sl(n,e,t){var f;let r,{manifest:i,period:a,representation:o}=n,s=o.index.getLastAvailablePosition(),u=o.index;!v(s)&&ht.isNative(n.adaptation.type)&&e>=s&&u.isInitialized()&&!u.isStillAwaitingFutureSegments()&&ul(i,a,e)?r=s-1:r=e-.1;let l=r+t,d;return!o.index.isInitialized()||o.index.isStillAwaitingFutureSegments()||a.end===void 0?d=!1:s===void 0?d=l>=a.end:s===null?d=!0:d=l>=s,{start:Math.max(r,a.start),end:Math.min(l,(f=a.end)!=null?f:1/0),hasReachedPeriodEnd:d}}function ul(n,e,t){var i;let r=n.getPeriodAfter(e);return e.containsTime(t,r)&&n.isLastPeriodKnown&&e.id===((i=n.periods[n.periods.length-1])==null?void 0:i.id)}function oa(n){return new Promise(e=>{setTimeout(e,n)})}async function On(n,e,t,r,i){try{return await e.pushChunk(t)}catch(a){if(i.isCancelled()&&a instanceof ie)throw a;if(!(a instanceof Ce)||!a.isBufferFull){let u=a instanceof Error?a.toString():\"An unknown error happened when pushing content\";throw new j(\"BUFFER_APPEND_ERROR\",u,{tracks:[ut(t.inventoryInfos.adaptation)]})}let{position:o}=n.getReference().getValue(),s=o.getWanted();try{c.warn(\"Stream: Running garbage collector\");let u=Math.max(s-5,0),l=s+r.getValue()+12;if(await e.removeBuffer(0,u),await e.removeBuffer(l,Number.MAX_VALUE),await oa(200),i.cancellationError!==null)throw i.cancellationError;return await e.pushChunk(t)}catch(u){if(u instanceof ie)throw u;let l=u instanceof Error?u.toString():\"Could not clean the buffer\";throw new j(\"BUFFER_FULL_ERROR\",l,{tracks:[ut(t.inventoryInfos.adaptation)]})}}}async function sa({playbackObserver:n,content:e,initSegmentUniqueId:t,segment:r,segmentSink:i,bufferGoal:a},o){if(o.cancellationError!==null)throw o.cancellationError;let s=e.representation.getMimeTypeString(),u={initSegmentUniqueId:t,chunk:null,timestampOffset:0,appendWindow:[void 0,void 0],codec:s},l=H({segment:r,chunkSize:void 0,start:0,end:0},e),d=await On(n,i,{data:u,inventoryInfos:l},a,o);return{content:e,segment:r,buffered:d}}async function ua({playbackObserver:n,bufferGoal:e,content:t,initSegmentUniqueId:r,parsedSegment:i,segment:a,segmentSink:o},s){var P,x;if(i.chunkData===null)return null;if(s.cancellationError!==null)throw s.cancellationError;let{chunkData:u,chunkInfos:l,chunkOffset:d,chunkSize:f,appendWindow:m}=i,p=t.representation.getMimeTypeString(),{APPEND_WINDOW_SECURITIES:g}=U.getCurrent(),h=[m[0]!==void 0?Math.max(0,m[0]-g.START):void 0,m[1]!==void 0?m[1]+g.END:void 0],I={initSegmentUniqueId:r,chunk:u,timestampOffset:d,appendWindow:h,codec:p},y=(P=l==null?void 0:l.time)!=null?P:a.time,E=(x=l==null?void 0:l.duration)!=null?x:a.duration,R=y+E;h[0]!==void 0&&(y=Math.max(y,h[0])),h[1]!==void 0&&(R=Math.min(R,h[1]));let T=H({segment:a,chunkSize:f,start:y,end:R},t),C=await On(n,o,{data:I,inventoryInfos:T},e,s);return{content:t,segment:a,buffered:C}}function da({content:n,options:e,playbackObserver:t,segmentSink:r,segmentFetcher:i,terminate:a},o,s){let{period:u,adaptation:l,representation:d}=n,{bufferGoal:f,maxBufferSize:m,drmSystemId:p,fastSwitchThreshold:g}=e,h=l.type,I=new W;I.linkToSignal(s);let y=new W;y.linkToSignal(I.signal);let E={segment:d.index.getInitSegment(),uniqueId:null,isLoaded:!1};I.signal.register(()=>{E.uniqueId!==null&&r.freeInitSegment(E.uniqueId)});let R=new G({initSegment:null,segmentQueue:[]},y.signal),T=E.segment!==null;T||(E.isLoaded=!0);let C=!1;if(p!==void 0){let M=d.getEncryptionData(p);if(M.length>0&&M.every(k=>k.keyIds!==void 0)&&(C=!0,o.encryptionDataEncountered(M.map(k=>H({content:n},k))),I.isUsed()))return}let P=new xn(n,R,i,T);P.addEventListener(\"error\",M=>{y.signal.isCancelled()||(I.cancel(),o.error(M))}),P.addEventListener(\"parsedInitSegment\",_),P.addEventListener(\"parsedMediaSegment\",_),P.addEventListener(\"emptyQueue\",x),P.addEventListener(\"requestRetry\",M=>{if(o.warning(M.error),y.signal.isCancelled())return;let k=M.segment,{index:D}=d;D.isSegmentStillAvailable(k)===!1?x():D.canBeOutOfSyncError(M.error,k)&&o.manifestMightBeOufOfSync()}),P.addEventListener(\"fullyLoadedSegment\",M=>{r.signalSegmentComplete(H({segment:M},n)).catch(A)}),P.start(),y.signal.register(()=>{P.removeEventListener(),P.stop()}),t.listen(x,{includeLastObservation:!1,clearSignal:y.signal}),n.manifest.addEventListener(\"manifestUpdate\",x,y.signal),f.onUpdate(x,{emitCurrentValue:!1,clearSignal:y.signal}),m.onUpdate(x,{emitCurrentValue:!1,clearSignal:y.signal}),a.onUpdate(x,{emitCurrentValue:!1,clearSignal:y.signal}),x();return;function x(){if(y.isUsed())return;let M=t.getReference().getValue(),k=M.position.getWanted(),D=aa(n,k,t,g.getValue(),f.getValue(),m.getValue(),r),{neededSegments:w}=D,O=null;if(d.index.isInitialized()){if(w.length>0&&!E.isLoaded&&E.segment!==null){let q=w[0].priority;O={segment:E.segment,priority:q}}}else if(E.segment===null)c.warn(\"Stream: Uninitialized index without an initialization segment\");else if(E.isLoaded)c.warn(\"Stream: Uninitialized index with an already loaded initialization segment\");else{let q=M.position.getWanted();O={segment:E.segment,priority:Mn(u.start,q)}}let B=a.getValue();if(B===null)R.setValue({initSegment:O,segmentQueue:w});else if(B.urgent){c.debug(\"Stream: Urgent switch, terminate now.\",h),R.setValue({initSegment:null,segmentQueue:[]}),R.finish(),y.cancel(),o.terminating();return}else{let q=w[0],J=P.getRequestedInitSegment(),$=P.getRequestedMediaSegment(),V=$===null||q===void 0||$.id!==q.segment.id?[]:[q],Y=J===null?null:O;if(R.setValue({initSegment:Y,segmentQueue:V}),V.length===0&&Y===null){c.debug(\"Stream: No request left, terminate\",h),R.finish(),y.cancel(),o.terminating();return}}if(o.streamStatusUpdate({period:u,position:M.position.getWanted(),bufferType:h,imminentDiscontinuity:D.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:D.hasFinishedLoading,neededSegments:D.neededSegments}),y.signal.isCancelled())return;let{UPTO_CURRENT_POSITION_CLEANUP:z}=U.getCurrent();if(D.isBufferFull){let q=Math.max(0,k-z);q>0&&r.removeBuffer(0,q).catch(A)}D.shouldRefreshManifest&&o.needsManifestRefresh()}function _(M){if(!I.isUsed()){for(let k of M.protectionData)d.addProtectionData(k.initDataType,k.keyId,k.initData);if(!C){let k=d.getAllEncryptionData();if(k.length>0&&(o.encryptionDataEncountered(k.map(D=>H({content:n},D))),C=!0,I.isUsed()))return}if(M.segmentType===\"init\"){if(!d.index.isInitialized()&&M.segmentList!==void 0&&d.index.initialize(M.segmentList),E.isLoaded=!0,M.initializationData!==null){let k=d.uniqueId;E.uniqueId=k,r.declareInitSegment(k,M.initializationData),sa({playbackObserver:t,bufferGoal:f,content:n,initSegmentUniqueId:k,segment:M.segment,segmentData:M.initializationData,segmentSink:r},I.signal).then(D=>{D!==null&&o.addedSegment(D)}).catch(A)}x();return}else{let{inbandEvents:k,predictedSegments:D,needsManifestRefresh:w}=M;if(D!==void 0&&d.index.addPredictedSegments(D,M.segment),w===!0&&(o.needsManifestRefresh(),I.isUsed())||k!==void 0&&k.length>0&&(o.inbandEvent(k),I.isUsed()))return;let O=E.uniqueId;ua({playbackObserver:t,bufferGoal:f,content:n,initSegmentUniqueId:O,parsedSegment:M,segment:M.segment,segmentSink:r},I.signal).then(B=>{B!==null&&o.addedSegment(B)}).catch(A)}}}function A(M){I.isUsed()&&M instanceof ie||(I.cancel(),o.error(M))}}var gs=da;function la(n,e,t,r,i){var m,p,g,h;if(t.switchingMode===\"lazy\")return{type:\"continue\",value:void 0};let a=r.getLastKnownInventory(),o=[];for(let I of a)I.infos.period.id===n.id&&(I.infos.adaptation.id!==e.id||!se(t.representationIds,I.infos.representation.id))&&zt(o,{start:(m=I.bufferedStart)!=null?m:I.start,end:(p=I.bufferedEnd)!=null?p:I.end});let s=r.getPendingOperations();for(let I of s)if(I.type===0){let y=I.value.inventoryInfos;if(y.period.id===n.id&&(y.adaptation.id!==e.id||!se(t.representationIds,y.representation.id))){let E=y.segment.time,R=E+y.segment.duration;zt(o,{start:E,end:R})}}if(o.length===0)return{type:\"continue\",value:void 0};if(t.switchingMode===\"reload\"){let I=i.getReadyState();if(I===void 0||I>1)return{type:\"needs-reload\",value:void 0}}let u=t.switchingMode===\"direct\",l=[],d=Wt(a,n);if(d!==null&&(d.bufferedEnd===void 0||n.start-d.bufferedEnd<1)&&l.push({start:0,end:n.start+1}),!u){let{ADAP_REP_SWITCH_BUFFER_PADDINGS:I}=U.getCurrent(),y=e.type,E=(g=I[y].before)!=null?g:0,R=(h=I[y].after)!=null?h:0,T=i.getCurrentTime();T===void 0&&(T=i.getReference().getValue().position.getPolled()),l.push({start:T-E,end:T+R})}if(n.end!==void 0){let I=Vt(a,n);I!==null&&(I.bufferedStart===void 0||I.bufferedStart-n.end<1)&&l.push({start:n.end-1,end:Number.MAX_VALUE})}let f=kr(o,l);return f.length===0?{type:\"continue\",value:void 0}:u?{type:\"flush-buffer\",value:f}:{type:\"clean-buffer\",value:f}}function fa({playbackObserver:n,content:e,options:t,representationEstimator:r,segmentSink:i,segmentFetcherCreator:a,wantedBufferAhead:o,maxVideoBufferSize:s},u,l){let{manifest:d,period:f,adaptation:m}=e,p=new W;p.linkToSignal(l);let g=new Map,h=new G(null,p.signal),I,y=e.representations.getValue().representationIds,E=e.adaptation.representations.filter(w=>se(y,w.id)&&w.decipherable!==!1&&w.isSupported!==!1),R=new G(E,p.signal),{estimates:T,callbacks:C}=r({manifest:d,period:f,adaptation:m},h,R,n,p.signal),P=a.createSegmentFetcher(m.type,{onRequestBegin:C.requestBegin,onRequestEnd:C.requestEnd,onProgress:C.requestProgress,onMetrics:C.metrics}),x=new G(0);T.onUpdate(({bitrate:w,knownStableBitrate:O})=>{t.enableFastSwitching&&x.setValueIfChanged(O),!(w===void 0||w===I)&&(I=w,c.debug(`Stream: new ${m.type} bitrate estimate`,w),u.bitrateEstimateChange({type:m.type,bitrate:w}))},{emitCurrentValue:!0,clearSignal:p.signal});let _;e.representations.onUpdate(w=>{_!==void 0&&_.cancel();let O=e.representations.getValue().representationIds,B=e.adaptation.representations.filter(z=>se(O,z.id));R.setValueIfChanged(B),_=new W,_.linkToSignal(p.signal),A(w,_.signal).catch(z=>{(_==null?void 0:_.isUsed())===!0&&W.isCancellationError(z)||(p.cancel(),u.error(z))})},{clearSignal:p.signal,emitCurrentValue:!0});return;async function A(w,O){let B=la(f,m,w,i,n);switch(B.type){case\"continue\":break;case\"needs-reload\":return Ct(()=>{n.listen(()=>{if(O.isCancelled())return;let{DELTA_POSITION_AFTER_RELOAD:z}=U.getCurrent(),q=z.bitrateSwitch;return u.waitingMediaSourceReload({bufferType:m.type,period:f,timeOffset:q,stayInPeriod:!0})},{includeLastObservation:!0,clearSignal:O})});case\"flush-buffer\":case\"clean-buffer\":for(let z of B.value)if(await i.removeBuffer(z.start,z.end),O.isCancelled())return;if(B.type===\"flush-buffer\"&&(u.needsBufferFlush(),O.isCancelled()))return;break;default:ze(B)}M(O)}function M(w){let O=new W;O.linkToSignal(w);let{representation:B}=T.getValue();if(B===null)return;let z=new G(null,O.signal);T.onUpdate($=>{if(!($.representation===null||$.representation.id===B.id))return $.urgent?(c.info(\"Stream: urgent Representation switch\",m.type),z.setValue({urgent:!0})):(c.info(\"Stream: slow Representation switch\",m.type),z.setValue({urgent:!1}))},{clearSignal:O.signal,emitCurrentValue:!0});let q={type:m.type,adaptation:m,period:f,representation:B};if(h.setValue(B),p.isUsed()||(u.representationChange(q),p.isUsed()))return;let J={streamStatusUpdate:u.streamStatusUpdate,encryptionDataEncountered:u.encryptionDataEncountered,manifestMightBeOufOfSync:u.manifestMightBeOufOfSync,needsManifestRefresh:u.needsManifestRefresh,inbandEvent:u.inbandEvent,warning:u.warning,error($){p.cancel(),u.error($)},addedSegment($){C.addedSegment($)},terminating(){if(!O.isUsed())return O.cancel(),M(w)}};k(B,z,J,w)}function k(w,O,B,z){let q=new W;q.linkToSignal(z);let J=Qt(o,Y=>Y*D(w),q.signal),$=m.type===\"video\"?s:new G(1/0);c.info(\"Stream: changing representation\",m.type,w.id,w.bitrate);let V=H({},B,{error(Y){var me;let X=ge(Y,{defaultCode:\"NONE\",defaultReason:\"Unknown `RepresentationStream` error\"});if(X.code!==\"BUFFER_FULL_ERROR\")B.error(Y);else{let ce=o.getValue(),Ie=((me=g.get(w.id))!=null?me:1)*.7;if(Ie<=.05||ce*Ie<=2)throw X;g.set(w.id,Ie),kn(4e3,p.signal).then(()=>k(w,O,B,z)).catch(N)}},terminating(){q.cancel(),B.terminating()}});gs({playbackObserver:n,content:{representation:w,adaptation:m,period:f,manifest:d},segmentSink:i,segmentFetcher:P,terminate:O,options:{bufferGoal:J,maxBufferSize:$,drmSystemId:t.drmSystemId,fastSwitchThreshold:x}},V,z),d.addEventListener(\"manifestUpdate\",Y=>{for(let X of Y.updatedPeriods)if(X.period.id===f.id){for(let me of X.result.updatedAdaptations)if(me.adaptation===m.id){for(let ce of me.removedRepresentations)if(ce===w.id)return z.isCancelled()?void 0:u.waitingMediaSourceReload({bufferType:m.type,period:f,timeOffset:0,stayInPeriod:!0})}}else if(X.period.start>f.start)break},z)}function D(w){let O=g.get(w.id),B=O!==void 0?O:1;return O===void 0&&g.set(w.id,B),B}}var hs=fa;function dl(n,e){let[t,...r]=n.split(\";\"),[i,...a]=e.split(\";\");if(t!==i)return!1;let o=K(r,d=>Ye(d,\"codecs=\")),s=K(a,d=>Ye(d,\"codecs=\"));if(o===void 0||s===void 0)return!1;let u=o.substring(7),l=s.substring(7);return u.split(\".\")[0]===l.split(\".\")[0]}var Is=dl;function ma(n,e,t,r,i,a){var p,g,h,I;if(n.codec!==void 0&&a.onCodecSwitch===\"reload\"&&!ll(t,n.codec))return{type:\"needs-reload\",value:void 0};let o=n.getLastKnownInventory(),s=[];for(let y of o)y.infos.period.id===e.id&&y.infos.adaptation.id!==t.id&&zt(s,{start:(p=y.bufferedStart)!=null?p:y.start,end:(g=y.bufferedEnd)!=null?g:y.end});let u=n.getPendingOperations();for(let y of u)if(y.type===0){let E=y.value.inventoryInfos;if(E.period.id===e.id&&E.adaptation.id!==t.id){let R=E.segment.time,T=R+E.segment.duration;zt(s,{start:R,end:T})}}if(s.length===0)return{type:\"continue\",value:void 0};if(r===\"reload\"){let y=i.getReadyState();if(y===void 0||y>1)return{type:\"needs-reload\",value:void 0}}let l=r===\"direct\",d=[],f=Wt(o,e);if(f!==null&&(f.bufferedEnd===void 0||e.start-f.bufferedEnd<1)&&d.push({start:0,end:e.start+1}),!l){let y=t.type,{ADAP_REP_SWITCH_BUFFER_PADDINGS:E}=U.getCurrent(),R=(h=E[y].before)!=null?h:0,T=(I=E[y].after)!=null?I:0,C=i.getCurrentTime();C===void 0&&(C=i.getReference().getValue().position.getPolled()),d.push({start:C-R,end:C+T})}if(e.end!==void 0){let y=Vt(o,e);y!==null&&(y.bufferedStart===void 0||y.bufferedStart-e.end<1)&&d.push({start:e.end-1,end:Number.MAX_VALUE})}let m=kr(s,d);return m.length===0?{type:\"continue\",value:void 0}:l&&t.type!==\"text\"?{type:\"flush-buffer\",value:m}:{type:\"clean-buffer\",value:m}}function ll(n,e){return n.representations.some(t=>t.isSupported===!0&&t.decipherable!==!1&&Is(t.getMimeTypeString(),e))}function ca({bufferType:n,content:e,garbageCollectors:t,playbackObserver:r,representationEstimator:i,segmentFetcherCreator:a,segmentSinksStore:o,options:s,wantedBufferAhead:u,maxVideoBufferSize:l},d,f){let{manifest:m,period:p}=e,g=new G(void 0,f);if(d.periodStreamReady({type:n,manifest:m,period:p,adaptationRef:g}),f.isCancelled())return;let h,I=!0;g.onUpdate(R=>{(async()=>{var w;if(R===void 0)return;let T=new W;if(T.linkToSignal(f),h==null||h.cancel(),h=T,R===null){c.info(`Stream: Set no ${n} Adaptation. P:`,p.start);let O=o.getStatus(n);if(O.type===\"initialized\"){if(c.info(`Stream: Clearing previous ${n} SegmentSink`),ht.isNative(n))return E(0,!0,T.signal);{let B=(w=p.end)!=null?w:1/0;if(p.start>B)c.warn(\"Stream: Can't free buffer: period's start is after its end\");else if(await O.value.removeBuffer(p.start,B),T.isUsed())return}}else if(O.type===\"uninitialized\"&&(o.disableSegmentSink(n),T.isUsed()))return;return d.adaptationChange({type:n,adaptation:null,period:p}),T.isUsed()?void 0:bs(r,u,n,{period:p},d,T.signal)}let C=p.adaptations[n],P=K(C!=null?C:[],O=>O.id===R.adaptationId);if(P===void 0){h.cancel(),c.warn(\"Stream: Unfound chosen Adaptation choice\",R.adaptationId);return}let{DELTA_POSITION_AFTER_RELOAD:x}=U.getCurrent(),_=!1,A;if(I)A=0;else if(R.relativeResumingPosition!==void 0)A=R.relativeResumingPosition;else switch(_=!0,n){case\"audio\":A=x.trackSwitch.audio;break;case\"video\":A=x.trackSwitch.video;break;default:A=x.trackSwitch.other;break}if(I=!1,ht.isNative(n)&&o.getStatus(n).type===\"disabled\")return E(A,!0,T.signal);m.addEventListener(\"manifestUpdate\",O=>{for(let B of O.updatedPeriods)if(B.period.id===p.id){for(let z of B.result.removedAdaptations)if(z.id===P.id)return E(A,!0,T.signal)}else if(B.period.start>p.start)break},h.signal);let{representations:M}=R;if(c.info(`Stream: Updating ${n} adaptation`,`A: ${P.id}`,`P: ${p.start}`),d.adaptationChange({type:n,adaptation:P,period:p}),T.isUsed())return;let k=fl(o,n,P),D=ma(k,p,P,R.switchingMode,r,s);if(D.type===\"needs-reload\")return E(A,!0,T.signal);if(await o.waitForUsableBuffers(T.signal),!T.isUsed()){if(D.type===\"flush-buffer\"||D.type===\"clean-buffer\"){for(let{start:O,end:B}of D.value)if(await k.removeBuffer(O,B),T.isUsed())return;if(D.type===\"flush-buffer\"&&(d.needsBufferFlush({relativeResumingPosition:A,relativePosHasBeenDefaulted:_}),T.isUsed()))return}t.get(k)(T.signal),y(P,M,k,T.signal)}})().catch(T=>{T instanceof ie||(h==null||h.cancel(),d.error(T))})},{clearSignal:f,emitCurrentValue:!0});function y(R,T,C,P){let x=cl(r,R.type);hs({content:{manifest:m,period:p,adaptation:R,representations:T},options:s,playbackObserver:x,representationEstimator:i,segmentSink:C,segmentFetcherCreator:a,wantedBufferAhead:u,maxVideoBufferSize:l},Le(_e({},d),{error:_}),P);function _(A){if(!ht.isNative(n)){c.error(`Stream: ${n} Stream crashed. Aborting it.`,A instanceof Error?A:\"\"),o.disposeSegmentSink(n);let M=ge(A,{defaultCode:\"NONE\",defaultReason:\"Unknown `AdaptationStream` error\"});return d.warning(M),P.isCancelled()?void 0:bs(r,u,n,{period:p},d,P)}c.error(`Stream: ${n} Stream crashed. Stopping playback.`,A instanceof Error?A:\"\"),d.error(A)}}function E(R,T,C){Ct(()=>{r.listen(()=>{C.isCancelled()||d.waitingMediaSourceReload({bufferType:n,period:p,timeOffset:R,stayInPeriod:T})},{includeLastObservation:!0,clearSignal:C})})}}function fl(n,e,t){let r=n.getStatus(e);if(r.type===\"initialized\")return c.info(\"Stream: Reusing a previous SegmentSink for the type\",e),r.value;let i=ml(t);return n.createSegmentSink(e,i)}function ml(n){let e=n.representations.filter(t=>t.isSupported===!0&&t.decipherable!==!1);if(e.length===0)throw new j(\"NO_PLAYABLE_REPRESENTATION\",\"No Representation in the chosen \"+n.type+\" Adaptation can be played\",{tracks:[ut(n)]});return e[0].getMimeTypeString()}function cl(n,e){return n.deriveReadOnlyObserver(function(r,i){let a=new G(o(),i);return r.onUpdate(s,{clearSignal:i,emitCurrentValue:!1}),a;function o(){let u=r.getValue(),l=u.buffered[e],d=l!==null?Ar(l,u.position.getWanted()):0;return H({},u,{bufferGap:d,buffered:l})}function s(){a.setValue(o())}})}function bs(n,e,t,r,i,a){let{period:o}=r,s=!1;e.onUpdate(u,{emitCurrentValue:!1,clearSignal:a}),n.listen(u,{includeLastObservation:!1,clearSignal:a}),u();function u(){let l=n.getReference().getValue(),d=e.getValue(),f=l.position.getWanted();o.end!==void 0&&f+d>=o.end&&(c.debug('Stream: full \"empty\" AdaptationStream',t),s=!0),i.streamStatusUpdate({period:o,bufferType:t,imminentDiscontinuity:null,position:f,isEmptyStream:!0,hasFinishedLoading:s,neededSegments:[]})}}var Ss=ca;function wr(n,e){if(e.length===0)return[];let t=[],r=n.getLastKnownInventory();for(let i=0;i<r.length;i++){let a=r[i];if(e.some(s=>a.infos.period.id===s.period.id&&a.infos.adaptation.id===s.adaptation.id&&a.infos.representation.id===s.representation.id)){let{bufferedStart:s,bufferedEnd:u}=a;if(s===void 0||u===void 0)return c.warn(\"SO: No buffered start or end found from a segment.\"),[{start:0,end:Number.MAX_VALUE}];let l=t[t.length-1];l!==void 0&&l.end===s?l.end=u:t.push({start:s,end:u})}}return t}function pa(n,e,t,r,i,a,o,s){let{manifest:u,initialPeriod:l}=n,{maxBufferAhead:d,maxBufferBehind:f,wantedBufferAhead:m,maxVideoBufferSize:p}=a,{MINIMUM_MAX_BUFFER_AHEAD:g,MAXIMUM_MAX_BUFFER_AHEAD:h,MAXIMUM_MAX_BUFFER_BEHIND:I}=U.getCurrent(),y=new En(T=>{var _,A;let{bufferType:C}=T,P=(_=I[C])!=null?_:1/0,x=(A=h[C])!=null?A:1/0;return M=>{xr({segmentSink:T,playbackObserver:e,maxBufferBehind:Qt(f,k=>Math.min(k,P),M),maxBufferAhead:Qt(d,k=>{var w;let D=Math.max(k,(w=g[C])!=null?w:0);return Math.min(D,x)},M)},M)}});for(let T of r.getBufferTypes())E(T,l);function E(T,C){let P=new At((D,w)=>D.start-w.start),x=!1,_=new W;return _.linkToSignal(s),e.listen(({position:D})=>{var B;let w=D.getWanted();if(!x||!M(w))return;for(c.info(\"Stream: Destroying all PeriodStreams due to out of bounds situation\",T,w),x=!1;P.length()>0;){let z=P.get(P.length()-1);P.removeElement(z),o.periodStreamCleared({type:T,manifest:u,period:z})}_.cancel(),_=new W,_.linkToSignal(s);let O=(B=u.getPeriodForTime(w))!=null?B:u.getNextPeriod(w);if(O===void 0){c.warn(\"Stream: The wanted position is not found in the Manifest.\"),x=!0;return}A(O)},{clearSignal:s,includeLastObservation:!0}),u.addEventListener(\"decipherabilityUpdate\",D=>{s.isCancelled()||k(D).catch(w=>{s.isCancelled()||(_.cancel(),o.error(w))})},s),A(C);function A(D){let w=Le(_e({},o),{waitingMediaSourceReload(O){let B=P.head();B===void 0||B.id!==O.period.id?o.lockedStream({bufferType:O.bufferType,period:O.period}):o.needsMediaSourceReload({timeOffset:O.timeOffset,minimumPosition:O.stayInPeriod?O.period.start:void 0,maximumPosition:O.stayInPeriod?O.period.end:void 0})},periodStreamReady(O){x=!0,P.add(O.period),o.periodStreamReady(O)},periodStreamCleared(O){P.removeElement(O.period),o.periodStreamCleared(O)},error(O){_.cancel(),o.error(O)}});R(T,D,w,_.signal)}function M(D){let w=P.head(),O=P.last();return w===void 0||O===void 0?!0:w.start>D||(v(O.end)?1/0:O.end)<D}async function k(D){let w=r.getStatus(T),O=D.filter(V=>V.adaptation.type===T);if(O.length===0||w.type!==\"initialized\"||O.every(V=>V.representation.decipherable===!0))return;let B=w.value,z=O.filter(V=>V.representation.decipherable===void 0),q=O.filter(V=>V.representation.decipherable===!1),J=wr(B,q),$=wr(B,z);for(x=!1,c.info(\"Stream: Destroying all PeriodStreams for decipherability matters\",T);P.length()>0;){let V=P.get(P.length()-1);P.removeElement(V),o.periodStreamCleared({type:T,manifest:u,period:V})}_.cancel(),_=new W,_.linkToSignal(s);for(let{start:V,end:Y}of[...J,...$]){if(s.isCancelled())return;if(V<Y){if(s.isCancelled())return;await B.removeBuffer(V,Y)}}Ct(()=>{if(s.isCancelled())return;let V=e.getReference().getValue();if(ys(V,J)){if(o.needsDecipherabilityFlush(),s.isCancelled())return}else if(ys(V,$)&&(o.needsBufferFlush(),s.isCancelled()))return;let Y=V.position.getWanted(),X=u.getPeriodForTime(Y);if(X===void 0){o.error(new j(\"MEDIA_TIME_NOT_FOUND\",\"The wanted position is not found in the Manifest.\"));return}A(X)})}}function R(T,C,P,x){c.info(\"Stream: Creating new Stream for\",T,C.start);let _=null,A=new W;A.linkToSignal(x),e.listen(({position:O},B)=>{if(C.end!==void 0&&O.getWanted()>=C.end){let z=u.getPeriodAfter(C);if(C.containsTime(O.getWanted(),z))return;c.info(\"Stream: Destroying PeriodStream as the current playhead moved above it\",T,C.start,O.getWanted(),C.end),B(),P.periodStreamCleared({type:T,manifest:u,period:C}),A.cancel()}},{clearSignal:x,includeLastObservation:!0});let M={bufferType:T,content:{manifest:u,period:C},garbageCollectors:y,maxVideoBufferSize:p,segmentFetcherCreator:i,segmentSinksStore:r,options:a,playbackObserver:e,representationEstimator:t,wantedBufferAhead:m},k=Le(_e({},P),{streamStatusUpdate(O){if(O.hasFinishedLoading){let B=u.getPeriodAfter(C);B!==null&&D(B)}else _!==null&&(c.info(\"Stream: Destroying next PeriodStream due to current one being active\",T,_.period.start),P.periodStreamCleared({type:T,manifest:u,period:_.period}),_.canceller.cancel(),_=null);P.streamStatusUpdate(O)},error(O){_!==null&&(_.canceller.cancel(),_=null),A.cancel(),P.error(O)}});Ss(M,k,A.signal),w(A.signal);function D(O){if(_!==null){if(_.period.id===O.id)return;c.warn(\"Stream: Creating next `PeriodStream` while one was already created.\",T,O.id,_.period.id),P.periodStreamCleared({type:T,manifest:u,period:_.period}),_.canceller.cancel()}let B=new W;B.linkToSignal(x),_={canceller:B,period:O},R(T,O,P,_.canceller.signal)}function w(O){u.addEventListener(\"manifestUpdate\",B=>{for(let z of B.removedPeriods)if(z.id===C.id){if(u.periods.length>0&&u.periods[0].start<=z.start)return Ct(()=>{if(!O.isCancelled())return o.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})})}else if(z.start>C.start)break;if(B.addedPeriods.length>0&&_!==null){let z=u.getPeriodAfter(C);(z===null||_.period.id!==z.id)&&(c.warn(\"Stream: Destroying next PeriodStream due to new one being added\",T,_.period.start),P.periodStreamCleared({type:T,manifest:u,period:_.period}),_.canceller.cancel(),_=null)}},O)}}}function ys(n,e){if(e.length===0)return!1;let t=n.position.getPolled();return n.speed>=0?e[e.length-1].end>=t-5:e[0].start<=t+5}var Ts=pa;var _s=Ts;var wn=class extends oe{constructor(e,t,r){super(),this._canceller=new W,this._manifest=e,this._activeStreams=new Map,this._allBufferTypes=r,this._lastCurrentPeriodId=null;let i=new ga(e);this._maximumPositionCalculator=i;let a=this._canceller.signal;t.listen(({position:o})=>{let s=o.getWanted();if(s<e.getMinimumSafePosition()){let u=new j(\"MEDIA_TIME_BEFORE_MANIFEST\",\"The current position is behind the earliest time announced in the Manifest.\");this.trigger(\"warning\",u)}else if(s>i.getMaximumAvailablePosition()){let u=new j(\"MEDIA_TIME_AFTER_MANIFEST\",\"The current position is after the latest time announced in the Manifest.\");this.trigger(\"warning\",u)}},{includeLastObservation:!0,clearSignal:a}),e.addEventListener(\"manifestUpdate\",()=>{this.trigger(\"endingPositionChange\",this._getManifestEndTime()),!a.isCancelled()&&this._checkEndOfStream()},a)}getCurrentEndingTime(){return this._getManifestEndTime()}onAdaptationChange(e,t,r){if(this._manifest.isLastPeriodKnown){let i=this._manifest.periods[this._manifest.periods.length-1];if(t.id===(i==null?void 0:i.id)&&(e===\"audio\"||e===\"video\")){e===\"audio\"?this._maximumPositionCalculator.updateLastAudioAdaptation(r):this._maximumPositionCalculator.updateLastVideoAdaptation(r);let a=this._maximumPositionCalculator.getEndingPosition(),o=a!==void 0?{isEnd:!0,endingPosition:a}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()};this.trigger(\"endingPositionChange\",o)}}this._canceller.isUsed()||r===null&&this._addActivelyLoadedPeriod(t,e)}onRepresentationChange(e,t){this._addActivelyLoadedPeriod(t,e)}onPeriodCleared(e,t){this._removeActivelyLoadedPeriod(t,e)}onLastSegmentFinishedLoading(e){let t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod||(t.hasFinishedLoadingLastPeriod=!0,this._checkEndOfStream())}onLastSegmentLoadingResume(e){let t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod&&(t.hasFinishedLoadingLastPeriod=!1,this._checkEndOfStream())}dispose(){this.removeEventListener(),this._canceller.cancel()}_addActivelyLoadedPeriod(e,t){let r=this._lazilyCreateActiveStreamInfo(t);r.activePeriods.has(e)||(r.activePeriods.add(e),this._checkCurrentPeriod())}_removeActivelyLoadedPeriod(e,t){let r=this._activeStreams.get(t);r!==void 0&&r.activePeriods.has(e)&&(r.activePeriods.removeElement(e),this._checkCurrentPeriod())}_checkCurrentPeriod(){if(this._allBufferTypes.length===0)return;let e=this._activeStreams.get(this._allBufferTypes[0]);if(e!==void 0)for(let t of e.activePeriods.toArray()){let r=!0;for(let i=1;i<this._allBufferTypes.length;i++){let a=this._activeStreams.get(this._allBufferTypes[i]);if(a===void 0)return;if(!a.activePeriods.toArray().some(u=>u.id===t.id)){r=!1;break}}if(r){this._lastCurrentPeriodId!==t.id&&(this._lastCurrentPeriodId=t.id,this.trigger(\"periodChange\",t));return}}}_getManifestEndTime(){let e=this._maximumPositionCalculator.getEndingPosition();return e!==void 0?{isEnd:!0,endingPosition:e}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()}}_lazilyCreateActiveStreamInfo(e){let t=this._activeStreams.get(e);return t===void 0&&(t={activePeriods:new At((r,i)=>r.start-i.start),hasFinishedLoadingLastPeriod:!1},this._activeStreams.set(e,t)),t}_checkEndOfStream(){if(!this._manifest.isLastPeriodKnown)return;this._allBufferTypes.every(t=>{let r=this._activeStreams.get(t);return r!==void 0&&r.hasFinishedLoadingLastPeriod})?this.trigger(\"endOfStream\",null):this.trigger(\"resumeStream\",null)}},ga=class{constructor(e){this._manifest=e,this._lastAudioAdaptation=void 0,this._lastVideoAdaptation=void 0}updateLastAudioAdaptation(e){this._lastAudioAdaptation=e}updateLastVideoAdaptation(e){this._lastVideoAdaptation=e}getMaximumAvailablePosition(){if(this._manifest.isDynamic)return this._manifest.getMaximumSafePosition();if(this._lastVideoAdaptation===void 0||this._lastAudioAdaptation===void 0)return this._manifest.getMaximumSafePosition();if(this._lastAudioAdaptation===null){if(this._lastVideoAdaptation===null)return this._manifest.getMaximumSafePosition();{let e=Dr(this._lastVideoAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}}else if(this._lastVideoAdaptation===null){let e=Dr(this._lastAudioAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}else{let e=Dr(this._lastAudioAdaptation),t=Dr(this._lastVideoAdaptation);return typeof e!=\"number\"||typeof t!=\"number\"?this._manifest.getMaximumSafePosition():Math.min(e,t)}}getEndingPosition(){var e,t;if(!this._manifest.isDynamic)return this.getMaximumAvailablePosition();if(!(this._lastVideoAdaptation===void 0||this._lastAudioAdaptation===void 0)){if(this._lastAudioAdaptation===null)return this._lastVideoAdaptation===null?void 0:(e=Nr(this._lastVideoAdaptation))!=null?e:void 0;if(this._lastVideoAdaptation===null)return(t=Nr(this._lastAudioAdaptation))!=null?t:void 0;{let r=Nr(this._lastAudioAdaptation),i=Nr(this._lastVideoAdaptation);return typeof r!=\"number\"||typeof i!=\"number\"?void 0:Math.min(r,i)}}}};function Dr(n){let{representations:e}=n,t=null,r;for(let i=0;i<e.length;i++)if(e[i].index!==r){r=e[i].index;let a=e[i].index.getLastAvailablePosition();if(a===void 0)return;a!==null&&(t=v(t)?a:Math.min(t,a))}return t}function Nr(n){let{representations:e}=n,t=null,r;for(let i=0;i<e.length;i++)if(e[i].index!==r){r=e[i].index;let a=e[i].index.getEnd();if(a===void 0)return;a!==null&&(t=v(t)?a:Math.min(t,a))}return t}function ha(n,e,t,r,i,a){a.register(()=>{e.interruptDurationSetting()});let o=new wn(n,t,r.getBufferTypes());a.register(()=>{o.dispose()}),o.addEventListener(\"warning\",u=>i.onWarning(u)),o.addEventListener(\"periodChange\",u=>i.onPeriodChanged(u)),o.addEventListener(\"endingPositionChange\",u=>{e.setDuration(u.endingPosition,u.isEnd)}),o.addEventListener(\"endOfStream\",()=>{c.debug(\"Init: end-of-stream order received.\"),e.maintainEndOfStream()}),o.addEventListener(\"resumeStream\",()=>{e.stopEndOfStream()});let s=o.getCurrentEndingTime();return e.setDuration(s.endingPosition,s.isEnd),o}function Ia(n,e){let t={audio:null,video:null,text:null};if(e!==null&&(t.text=e.getBufferedRanges()),n===null)return t;let r=K(n.sourceBuffers,s=>s.type===\"audio\"),i=K(n.sourceBuffers,s=>s.type===\"video\"),a=r==null?void 0:r.getBuffered();a!==void 0&&(t.audio=a);let o=i==null?void 0:i.getBuffered();return o!==void 0&&(t.video=o),t}function ba(n,e){if(typeof n.changeType==\"function\"){try{n.changeType(e)}catch(t){return c.warn(\"Could not call 'changeType' on the given SourceBuffer:\",t instanceof Error?t:\"\"),!1}return!0}return!1}var pl=[\"\",\"webkit\",\"moz\",\"ms\"];function gl(n,e){let t=document.createElement(n.tagName),r=\"on\"+e;return r in t?!0:(t.setAttribute(r,\"return;\"),typeof t[r]==\"function\")}function hl(n,e){return e.filter(t=>gl(n,t))[0]}function Il(n,e){return n.reduce((t,r)=>t.concat((e===void 0?pl:e).map(i=>i+r)),[])}function Te(n,e){let t,r=Il(n,e);return(i,a,o)=>{if(!o.isCancelled()){if(typeof HTMLElement!=\"undefined\"&&i instanceof HTMLElement)if(typeof t==\"undefined\"&&(t=hl(i,r)),Z(t))i.addEventListener(t,a),o.register(()=>{t!==void 0&&i.removeEventListener(t,a)});else{b.CURRENT_ENV===b.DEV&&c.warn(`compat: element ${i.tagName} does not support any of these events: `+r.join(\", \"));return}r.forEach(s=>{let u=!1;typeof i.addEventListener==\"function\"?i.addEventListener(s,a):(u=!0,i[\"on\"+s]=a),o.register(()=>{typeof i.removeEventListener==\"function\"&&i.removeEventListener(s,a),u&&delete i[\"on\"+s]})})}}}var CD=Te([\"loadedmetadata\"]),AD=Te([\"timeupdate\"]),kD=Te([\"addtrack\"]),xD=Te([\"removetrack\"]),Ht=Te([\"sourceopen\",\"webkitsourceopen\"]),Br=Te([\"sourceclose\",\"webkitsourceclose\"]),Ur=Te([\"sourceended\",\"webkitsourceended\"]),Es=Te([\"update\"]),Rs=Te([\"removesourcebuffer\"]),MD=Te([\"keymessage\",\"message\"]),OD=Te([\"keyadded\",\"ready\"]),wD=Te([\"keyerror\",\"error\"]),DD=Te([\"keystatuseschange\"]),ND=Te([\"seeking\"]),BD=Te([\"seeked\"]),UD=Te([\"ended\"]);function bl(n){let e=[];for(let t=0;t<n.length;t++){let r=n[t];r.updating&&e.push(r)}return e}function Dn(n,e){if(c.debug(\"Init: Trying to call endOfStream\"),n.readyState!==\"open\"){c.debug(\"Init: MediaSource not open, cancel endOfStream\");return}let{sourceBuffers:t}=n,r=bl(t);if(r.length===0){c.info(\"Init: Triggering end of stream\"),n.endOfStream();return}c.debug(\"Init: Waiting SourceBuffers to be updated before calling endOfStream.\");let i=new W;i.linkToSignal(e);for(let a of r)Es(a,()=>{i.cancel(),Dn(n,e)},i.signal);Rs(t,()=>{i.cancel(),Dn(n,e)},i.signal)}function Ps(n,e){let t=new W;t.linkToSignal(e),Ht(n,()=>{c.debug(\"Init: MediaSource re-opened while end-of-stream is active\"),t.cancel(),t=new W,t.linkToSignal(e),Dn(n,t.signal)},e),Dn(n,t.signal)}var Sl=!1,yl=!1,vs=!1,Tl=!1,_l=!1,El=!1,Rl=!1,Pl=!1,vl=!1,Cl=!1,Al=!1,kl=!1,xl=!1,Sa=!1,Ml=!1;(function(){var e,t,r;er||(typeof Ee.MSInputMethodContext!=\"undefined\"&&typeof document.documentMode!=\"undefined\"?(yl=!0,vs=!0):navigator.appName===\"Microsoft Internet Explorer\"||navigator.appName===\"Netscape\"&&/(Trident|Edge)\\//.test(navigator.userAgent)?vs=!0:navigator.userAgent.toLowerCase().indexOf(\"edg/\")!==-1?Sl=!0:navigator.userAgent.toLowerCase().indexOf(\"firefox\")!==-1?Tl=!0:typeof navigator.platform==\"string\"&&/iPad|iPhone|iPod/.test(navigator.platform)?El=!0:(Object.prototype.toString.call(Ee.HTMLElement).indexOf(\"Constructor\")>=0||((t=(e=Ee.safari)==null?void 0:e.pushNotification)==null?void 0:t.toString())===\"[object SafariRemoteNotification]\"||/Safari\\/(\\d+)/.test(navigator.userAgent)&&/Version\\/(\\d+)/.test(navigator.userAgent)&&((r=navigator.vendor)==null?void 0:r.indexOf(\"Apple\"))!==-1&&!/Chrome\\/(\\d+)/.test(navigator.userAgent)&&!/Chromium\\/(\\d+)/.test(navigator.userAgent))&&(_l=!0),/SamsungBrowser/.test(navigator.userAgent)&&(Rl=!0),navigator.userAgent.indexOf(\"PlayStation 4\")!==-1?xl=!0:navigator.userAgent.indexOf(\"PlayStation 5\")!==-1?Sa=!0:/Tizen/.test(navigator.userAgent)?Pl=!0:/[Ww]eb[O0]S/.test(navigator.userAgent)?(vl=!0,/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/87/.test(navigator.userAgent)?Al=!0:(/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/79/.test(navigator.userAgent))&&(Cl=!0)):/[Pp]anasonic/.test(navigator.userAgent)?kl=!0:navigator.userAgent.indexOf(\"Xbox\")!==-1&&(Ml=!0))})();function ya(){return Sa}var Ol=365*24*3600,Nn=class{constructor(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}updateDuration(e,t){this._currentMediaSourceDurationUpdateCanceller!==null&&this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=new W;let r=this._mediaSource,i=this._currentMediaSourceDurationUpdateCanceller.signal,a=Nl(r,i),o=new W;o.linkToSignal(i),a.onUpdate(s,{emitCurrentValue:!0,clearSignal:i});function s(){if(o.cancel(),!a.getValue())return;o=new W,o.linkToSignal(i);let u=Dl(r.sourceBuffers,o.signal),l=new W;return l.linkToSignal(o.signal),u.onUpdate(d=>{l.cancel(),l=new W,l.linkToSignal(o.signal),!d&&As(r,e,t,l.signal)},{clearSignal:o.signal,emitCurrentValue:!0})}}stopUpdating(){this._currentMediaSourceDurationUpdateCanceller!==null&&(this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=null)}};function wl(n,e,t){let r=e;t||(r=ya()?1/0:Cs(e));let i=0;for(let a=0;a<n.sourceBuffers.length;a++){let o=n.sourceBuffers[a],s=o.buffered.length;s>0&&(i=Math.max(o.buffered.end(s-1)))}if(r===n.duration)return\"success\";if(i>r){if(i<n.duration)try{c.info(\"Init: Updating duration to what is currently buffered\",i),n.duration=i}catch(a){return c.warn(\"Duration Updater: Can't update duration on the MediaSource.\",a instanceof Error?a:\"\"),\"failed\"}return\"partial\"}else{let a=n.duration;try{if(c.info(\"Init: Updating duration\",r),n.duration=r,n.readyState===\"open\"&&!isFinite(r)){let s=Cs(e);c.info(\"Init: calling `mediaSource.setLiveSeekableRange`\",s),n.setLiveSeekableRange(0,s)}}catch(s){return c.warn(\"Duration Updater: Can't update duration on the MediaSource.\",s instanceof Error?s:\"\"),\"failed\"}let o=Math.abs(n.duration-r);if(o>=.1){let s=Math.abs(n.duration-a);return o<s?\"partial\":\"failed\"}return\"success\"}}function Dl(n,e){if(n.length===0){let i=new G(!1);return i.finish(),i}let t=new G(!1,e);r();for(let i=0;i<n.length;i++){let a=n[i];a.addEventListener(\"updatestart\",r),a.addEventListener(\"update\",r),e.register(()=>{a.removeEventListener(\"updatestart\",r),a.removeEventListener(\"update\",r)})}return t;function r(){for(let i=0;i<n.length;i++)if(n[i].updating){t.setValueIfChanged(!0);return}t.setValueIfChanged(!1)}}function Nl(n,e){let t=new G(n.readyState===\"open\",e);return Ht(n,()=>{c.debug(\"Init: Reacting to MediaSource open in duration updater\"),t.setValueIfChanged(!0)},e),Ur(n,()=>{c.debug(\"Init: Reacting to MediaSource ended in duration updater\"),t.setValueIfChanged(!1)},e),Br(n,()=>{c.debug(\"Init: Reacting to MediaSource close in duration updater\"),t.setValueIfChanged(!1)},e),t}function As(n,e,t,r){if(wl(n,e,t)===\"success\")return;let a=setTimeout(()=>{o(),As(n,e,t,r)},2e3),o=r.register(()=>{clearTimeout(a)})}function Cs(n){return Math.max(Math.pow(2,32),n+Ol)}var Bn=class extends oe{constructor(e){if(super(),this.id=e,this.sourceBuffers=[],this._canceller=new W,v(St))throw new j(\"MEDIA_SOURCE_NOT_SUPPORTED\",\"No MediaSource Object was found in the current browser.\");c.info(\"Init: Creating MediaSource\");let t=new St;this.readyState=t.readyState;let r=t.handle;this.handle=v(r)?{type:\"media-source\",value:t}:{type:\"handle\",value:r},this._mediaSource=t,this._durationUpdater=new Nn(t),this._endOfStreamCanceller=null,Ht(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceOpen\",null)},this._canceller.signal),Ur(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceEnded\",null)},this._canceller.signal),Br(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceClose\",null)},this._canceller.signal)}addSourceBuffer(e,t){let r=this._mediaSource.addSourceBuffer(t),i=new Ta(e,t,r);return this.sourceBuffers.push(i),i}setDuration(e,t){this._durationUpdater.updateDuration(e,t)}interruptDurationSetting(){this._durationUpdater.stopUpdating()}maintainEndOfStream(){this._endOfStreamCanceller===null&&(this._endOfStreamCanceller=new W,this._endOfStreamCanceller.linkToSignal(this._canceller.signal),c.debug(\"Init: end-of-stream order received.\"),Ps(this._mediaSource,this._endOfStreamCanceller.signal))}stopEndOfStream(){this._endOfStreamCanceller!==null&&(c.debug(\"Init: resume-stream order received.\"),this._endOfStreamCanceller.cancel(),this._endOfStreamCanceller=null)}dispose(){this.sourceBuffers.forEach(e=>e.dispose()),this._canceller.cancel(),Bl(this._mediaSource)}},Ta=class{constructor(e,t,r){this.type=e,this.codec=t,this._canceller=new W,this._sourceBuffer=r,this._operationQueue=[],this._currentOperations=[];let i=o=>{let s;o instanceof Error?s=o:o.error instanceof Error?s=o.error:s=new Error(\"Unknown SourceBuffer Error\");let u=this._currentOperations;if(this._currentOperations=[],u.length===0)c.error(\"SBI: error for an unknown operation\",s);else{let l=new Ce(s.name,s.message,s.name===\"QuotaExceededError\");for(let d of u)d.reject(l)}},a=()=>{let o=this._currentOperations;this._currentOperations=[];try{for(let s of o)s.resolve(ta(this._sourceBuffer.buffered))}catch(s){for(let u of o)s instanceof Error&&s.name===\"InvalidStateError\"?u.resolve([]):u.reject(s)}this._performNextOperation()};r.addEventListener(\"error\",i),r.addEventListener(\"updateend\",a),this._canceller.signal.register(()=>{r.removeEventListener(\"error\",i),r.removeEventListener(\"updateend\",a)})}appendBuffer(...e){return c.debug(\"SBI: receiving order to push data to the SourceBuffer\",this.type),this._addToQueue({operationName:0,params:e})}remove(e,t){return c.debug(\"SBI: receiving order to remove data from the SourceBuffer\",this.type,e,t),this._addToQueue({operationName:1,params:[e,t]})}getBuffered(){try{return ta(this._sourceBuffer.buffered)}catch(e){return c.error(\"Failed to get buffered time range of SourceBuffer\",this.type,e instanceof Error?e:null),[]}}abort(){try{this._sourceBuffer.abort()}catch(e){c.debug(\"Init: Failed to abort SourceBuffer:\",e instanceof Error?e:null)}this._emptyCurrentQueue()}dispose(){try{this._sourceBuffer.abort()}catch(e){}this._emptyCurrentQueue()}_emptyCurrentQueue(){let e=new ie;this._currentOperations.length>0&&(this._currentOperations.forEach(t=>{t.reject(e)}),this._currentOperations=[]),this._operationQueue.length>0&&(this._operationQueue.forEach(t=>{t.reject(e)}),this._operationQueue=[])}_addToQueue(e){return new Promise((t,r)=>{let i=this._operationQueue.length===0&&this._currentOperations.length===0,a=H({resolve:t,reject:r},e);this._operationQueue.push(a),i&&this._performNextOperation()})}_performNextOperation(){var t,r,i,a,o;if(this._currentOperations.length!==0||this._sourceBuffer.updating)return;let e=this._operationQueue.shift();if(e!==void 0)if(e.operationName===0){this._currentOperations=[{operationName:0,resolve:e.resolve,reject:e.reject}];let s=e.params[0],u=e.params[1],l=s;if(this._operationQueue.length>0&&this._operationQueue[0].operationName===0){let d;s instanceof ArrayBuffer?d=new Uint8Array(s):s instanceof Uint8Array?d=s:d=new Uint8Array(s.buffer);let f=[d];for(;((t=this._operationQueue[0])==null?void 0:t.operationName)===0;){let m=this._operationQueue[0],p=(r=u.appendWindow)!=null?r:[void 0,void 0],g=(i=m.params[1].appendWindow)!=null?i:[void 0,void 0],h=(a=u.timestampOffset)!=null?a:0,I=(o=m.params[1].timestampOffset)!=null?o:0;if(p[0]===g[0]&&p[1]===g[1]&&u.codec===m.params[1].codec&&h===I){let y=m.params[0],E;y instanceof ArrayBuffer?E=new Uint8Array(y):y instanceof Uint8Array?E=y:E=new Uint8Array(y.buffer),f.push(E),this._operationQueue.splice(0,1),this._currentOperations.push({operationName:0,resolve:m.resolve,reject:m.reject})}else break}f.length>1&&(c.info(`MMSI: Merging ${f.length} segments together for perf`,this.type),l=vt(...f))}try{this._appendBufferNow(l,u)}catch(d){let f=d instanceof Error?new Ce(d.name,d.message,d.name===\"QuotaExceededError\"):new Ce(\"Error\",\"Unknown SourceBuffer Error during appendBuffer\",!1);this._currentOperations.forEach(m=>{m.reject(f)}),this._currentOperations=[]}}else{this._currentOperations=[e];let[s,u]=e.params;c.debug(\"SBI: removing data from SourceBuffer\",this.type,s,u);try{this._sourceBuffer.remove(s,u)}catch(l){let d=l instanceof Error?new Ce(l.name,l.message,!1):new Ce(\"Error\",\"Unknown SourceBuffer Error during remove\",!1);e.reject(d),this._currentOperations=[]}}}_appendBufferNow(e,t){let r=this._sourceBuffer,{codec:i,timestampOffset:a,appendWindow:o=[]}=t;if(i!==void 0&&i!==this.codec&&(c.debug(\"SBI: updating codec\",i),ba(r,i)?this.codec=i:c.debug(\"SBI: could not update codec\",i,this.codec)),a!==void 0&&r.timestampOffset!==a){let s=a;c.debug(\"SBI: updating timestampOffset\",i,r.timestampOffset,s),r.timestampOffset=s}if(o[0]===void 0)r.appendWindowStart>0&&(c.debug(\"SBI: re-setting `appendWindowStart` to `0`\"),r.appendWindowStart=0);else if(o[0]!==r.appendWindowStart){if(o[0]>=r.appendWindowEnd){let s=o[0]+1;c.debug(\"SBI: pre-updating `appendWindowEnd`\",s),r.appendWindowEnd=s}c.debug(\"SBI: setting `appendWindowStart`\",o[0]),r.appendWindowStart=o[0]}o[1]===void 0?r.appendWindowEnd!==1/0&&(c.debug(\"SBI: re-setting `appendWindowEnd` to `Infinity`\"),r.appendWindowEnd=1/0):o[1]!==r.appendWindowEnd&&(c.debug(\"SBI: setting `appendWindowEnd`\",o[1]),r.appendWindowEnd=o[1]),c.debug(\"SBI: pushing segment\",this.type),r.appendBuffer(e)}};function Bl(n){if(n.readyState!==\"closed\"){let{readyState:e,sourceBuffers:t}=n;for(let r=t.length-1;r>=0;r--){let i=t[r];try{if(e===\"open\"){c.info(\"Init: Aborting SourceBuffer before removing\");try{i.abort()}catch(a){}}c.info(\"Init: Removing SourceBuffer from mediaSource\"),n.removeSourceBuffer(i)}catch(a){}}t.length>0&&c.info(\"Init: Not all SourceBuffers could have been removed.\")}}var Ul=Ae(),Lr=Ae(),ks=1/0,Un=class extends oe{constructor(e,t,r){super(),this.id=e,this.sourceBuffers=[],this._canceller=new W,this.readyState=\"closed\",this._messageSender=r;let i=Ul();this._messageSender({type:\"create-media-source\",contentId:t,mediaSourceId:i})}onMediaSourceReadyStateChanged(e){switch(e){case\"closed\":this.readyState=\"closed\",this.trigger(\"mediaSourceClose\",null);break;case\"open\":this.readyState=\"open\",this.trigger(\"mediaSourceOpen\",null);break;case\"ended\":this.readyState=\"ended\",this.trigger(\"mediaSourceEnded\",null);break}}addSourceBuffer(e,t){this._messageSender({type:\"add-source-buffer\",mediaSourceId:this.id,value:{sourceBufferType:e,codec:t}});let r=new _a(e,t,this.id,this._messageSender);return this.sourceBuffers.push(r),r}setDuration(e,t){this._messageSender({type:\"update-media-source-duration\",mediaSourceId:this.id,value:{duration:e,isRealEndKnown:t}})}interruptDurationSetting(){this._messageSender({type:\"stop-media-source-duration\",mediaSourceId:this.id,value:null})}maintainEndOfStream(){this._messageSender({type:\"end-of-stream\",mediaSourceId:this.id,value:null})}stopEndOfStream(){this._messageSender({type:\"stop-end-of-stream\",mediaSourceId:this.id,value:null})}dispose(){this.sourceBuffers.forEach(e=>e.dispose()),this._canceller.cancel(),this._messageSender({type:\"dispose-media-source\",mediaSourceId:this.id,value:null})}},_a=class{constructor(e,t,r,i){this.type=e,this.codec=t,this._canceller=new W,this._mediaSourceId=r,this._queuedOperations=[],this._pendingOperations=new Map,this._messageSender=i}onOperationSuccess(e,t){let r=this._pendingOperations.get(e);r===void 0?c.warn(\"SBI: unknown SourceBuffer operation succeeded\"):(this._pendingOperations.delete(e),r.resolve(t)),this._performNextQueuedOperationIfItExists()}onOperationFailure(e,t){let r=t.errorName===\"CancellationError\"?new ie:new Ce(t.errorName,t.message,t.isBufferFull),i=this._pendingOperations.get(e);i===void 0?c.info(\"SBI: unknown SourceBuffer operation failed\",r):(this._pendingOperations.delete(e),i.reject(r));let a=new ie;for(let o of this._queuedOperations)o.reject(a);this._queuedOperations=[]}appendBuffer(e,t){return new Promise((r,i)=>{if(this._queuedOperations.length>0||this._pendingOperations.size>=ks){this._queuedOperations.push({operationName:0,params:[e,t],resolve:r,reject:i});return}try{let a;e instanceof ArrayBuffer?a=e:e.byteLength===e.buffer.byteLength?a=e.buffer:a=e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset);let o=Lr();this._messageSender({type:\"source-buffer-append\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:o,value:{data:a,params:t}},[a]),this._addOperationToQueue(o,r,i)}catch(a){i(a)}})}remove(e,t){return new Promise((r,i)=>{if(this._queuedOperations.length>0||this._pendingOperations.size>=ks){this._queuedOperations.push({operationName:1,params:[e,t],resolve:r,reject:i});return}try{let a=Lr();this._messageSender({type:\"source-buffer-remove\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:a,value:{start:e,end:t}}),this._addOperationToQueue(a,r,i)}catch(a){i(a)}})}abort(){this._messageSender({type:\"abort-source-buffer\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,value:null})}dispose(){this.abort(),this._canceller.cancel()}getBuffered(){}_addOperationToQueue(e,t,r){this._pendingOperations.set(e,{resolve:a,reject:o});let i=this._canceller.signal.register(s=>{this._pendingOperations.delete(e),r(s)});function a(s){i(),t(s)}function o(s){i(),r(s)}}_performNextQueuedOperationIfItExists(){let e=this._queuedOperations.shift();if(e!==void 0)try{if(e.operationName===0){let[t,r]=e.params,i;t instanceof ArrayBuffer?i=t:t.byteLength===t.buffer.byteLength?i=t.buffer:i=t.buffer.slice(t.byteOffset,t.byteLength+t.byteOffset);let a=Lr();this._messageSender({type:\"source-buffer-append\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:a,value:{data:i,params:r}},[i]),this._addOperationToQueue(a,e.resolve,e.reject)}else{let[t,r]=e.params,i=Lr();this._messageSender({type:\"source-buffer-remove\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:i,value:{start:t,end:r}}),this._addOperationToQueue(i,e.resolve,e.reject)}}catch(t){e.reject(t)}}};function Ea(n){let e=n.map(o=>Math.log(o/n[0])),t=e.map(o=>o-e[0]+1),r=(t[t.length-1]-1)/(n.length*2+10),i=1/r;return n.map((o,s)=>a(s));function a(o){if(o===0)return 0;let s=Math.min(Math.max(1,o),n.length-1);return n[s]===n[s-1]?a(o-1):i*(r+(n[s]*t[s-1]-n[s-1]*t[s])/(n[s]-n[s-1]))+4}}var Ue=class{constructor(e){this._alpha=Math.exp(Math.log(.5)/e),this._lastEstimate=0,this._totalWeight=0}addSample(e,t){let r=Math.pow(this._alpha,e),i=t*(1-r)+r*this._lastEstimate;isNaN(i)||(this._lastEstimate=i,this._totalWeight+=e)}getEstimate(){let e=1-Math.pow(this._alpha,this._totalWeight);return this._lastEstimate/e}};var Ln=class{constructor(){this._currentRepresentationData=null,this._lastRepresentationWithGoodScore=null}addSample(e,t,r){let i=r/t,a=this._currentRepresentationData,o;a!==null&&a.representation.id===e.id?(o=a.ewma,a.ewma.addSample(t,i),a.loadedDuration+=r,a.loadedSegments++):(o=new Ue(5),o.addSample(t,i),this._currentRepresentationData={representation:e,ewma:o,loadedDuration:r,loadedSegments:0}),o.getEstimate()>1&&this._lastRepresentationWithGoodScore!==e&&(c.debug(\"ABR: New last stable representation\",e.bitrate),this._lastRepresentationWithGoodScore=e)}getEstimate(e){if(this._currentRepresentationData===null||this._currentRepresentationData.representation.id!==e.id)return;let{ewma:t,loadedSegments:r,loadedDuration:i}=this._currentRepresentationData,a=t.getEstimate(),o=r>=5&&i>=10?1:0;return{score:a,confidenceLevel:o}}getLastStableRepresentation(){return this._lastRepresentationWithGoodScore}};var xs=6e3,Ll=15e3,Fl=3e3,zl=1e3,Wl=9e3,Fn=class{constructor(e){this._levelsMap=Ea(e).map(t=>t+4),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=xs,c.debug(\"ABR: Steps for buffer based chooser.\",this._levelsMap.map((t,r)=>`bufferLevel: ${t}, bitrate: ${e[r]}`).join(\" ,\"))}onAddedSegment(e){let t=this._levelsMap,r=this._bitrates,{bufferGap:i,currentBitrate:a,currentScore:o,speed:s}=e;if(v(a)){this._currentEstimate=r[0];return}let u=-1;for(let g=0;g<r.length;g++){let h=r[g];if(h===a)u=g;else if(h>a)break}if(u<0||r.length!==t.length){c.info(\"ABR: Current Bitrate not found in the calculated levels\"),this._currentEstimate=r[0];return}let l;o!==void 0&&(l=s===0?o.score:o.score/s);let d=isFinite(i)?i:0,f=L();if(d<t[u]||l!==void 0&&l<1&&(o==null?void 0:o.confidenceLevel)===1){if((this._lastUnsuitableQualityTimestamp===void 0?-1:f-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+Wl){let I=this._blockRaiseDelay+Fl;this._blockRaiseDelay=Math.min(I,Ll),c.debug(\"ABR: Incrementing blocking raise in BufferBasedChooser due to unstable quality\",this._blockRaiseDelay)}else{let I=this._blockRaiseDelay-zl;this._blockRaiseDelay=Math.max(xs,I),c.debug(\"ABR: Lowering quality in BufferBasedChooser\",this._blockRaiseDelay)}this._lastUnsuitableQualityTimestamp=f;let h=ne(r,I=>I===a);for(let I=h-1;I>=0;I--)if(d>=t[I]){this._currentEstimate=r[I];return}this._currentEstimate=r[0];return}if(this._lastUnsuitableQualityTimestamp!==void 0&&f-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||l===void 0||l<1.15||(o==null?void 0:o.confidenceLevel)!==1){this._currentEstimate=a;return}let m=t[u],p=(()=>{for(let g=u+1;g<t.length;g++)if(t[g]>m)return g})();if(p!==void 0){let g=t[p];if(i>=g){c.debug(\"ABR: Raising quality in BufferBasedChooser\",r[p]),this._currentEstimate=r[p];return}}this._currentEstimate=a}getLastEstimate(){return this._currentEstimate}};function Vl(n,e){let t=-1;for(let o=0;o<n.length;o++){let{segment:s}=n[o].content;if(s.duration<=0)continue;let u=s.time+s.duration;if(!s.complete&&o===n.length-1&&e-s.time>-1.2){t=o;break}if(u>e&&e-s.time>-1.2){t=o;break}}if(t<0)return[];let r=n[t],i=r.content.segment.time,a=[r];for(let o=t+1;o<n.length&&n[o].content.segment.time===i;o++)a.push(n[o]);return a}function Fr(n){if(n.progress.length<5)return;let e=new Ue(2),{progress:t}=n;for(let r=1;r<t.length;r++){let i=t[r].size-t[r-1].size,a=t[r].timestamp-t[r-1].timestamp,o=i*8/(a/1e3);e.addSample(a/1e3,o)}return e.getEstimate()}function Ms(n,e){let t=(n.totalSize-n.size)*8;return Math.max(t/e,0)}function ql(n,e,t,r,i){if(r)return;let{bufferGap:a,speed:o,position:s}=e,u=isFinite(a)?a:0,l=s.getWanted()+u,d=Vl(n,l);if(d.length!==1)return;let f=d[0],m=L(),p=f.content.segment.duration*1.5;if(p=Math.min(p,3e3),p=Math.max(p,12e3),m-f.requestTimestamp<p)return;let g=f.progress.length>0?f.progress[f.progress.length-1]:void 0,h=Fr(f);if(g!==void 0&&h!==void 0){let C=Ms(g,h);if((m-g.timestamp)/1e3<=C&&C-u/o>2500)return h}if(!f.content.segment.complete)return;let I=f.content.segment.duration,y=(m-f.requestTimestamp)/1e3,E=y<=(I*1.5+2)/o;if(v(t)||E)return;let R=I/y,T=t.bitrate*Math.min(.7,R);if(i===void 0||T<i)return T}function Hl(n,e,t){if(t)return!0;let r=isFinite(n.bufferGap)?n.bufferGap:0,i=n.position.getWanted()+r,a=K(e,({content:f})=>f.segment.duration>0&&f.segment.time+f.segment.duration>i);if(a===void 0)return!0;let o=L(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,u=Fr(a);if(s===void 0||u===void 0)return!0;let l=Ms(s,u);return(o-s.timestamp)/1e3>l*1.2?!0:l-r/n.speed>-1.5}var zn=class{constructor(e,t){let{ABR_STARVATION_GAP:r,OUT_OF_STARVATION_GAP:i,ABR_STARVATION_FACTOR:a,ABR_REGULAR_FACTOR:o}=U.getCurrent();this._initialBitrate=e,this._inStarvationMode=!1,this._lowLatencyMode=t,t?this._config={starvationGap:r.LOW_LATENCY,outOfStarvationGap:i.LOW_LATENCY,starvationBitrateFactor:a.LOW_LATENCY,regularBitrateFactor:o.LOW_LATENCY}:this._config={starvationGap:r.DEFAULT,outOfStarvationGap:i.DEFAULT,starvationBitrateFactor:a.DEFAULT,regularBitrateFactor:o.DEFAULT}}getBandwidthEstimate(e,t,r,i,a){let o,s,u=this._config,{bufferGap:l,position:d,duration:f}=e,m=isFinite(l)?l:0,{ABR_STARVATION_DURATION_DELTA:p}=U.getCurrent();return isNaN(f)||m+d.getWanted()<f-p?!this._inStarvationMode&&m<=u.starvationGap?(c.info(\"ABR: enter starvation mode.\"),this._inStarvationMode=!0):this._inStarvationMode&&m>=u.outOfStarvationGap&&(c.info(\"ABR: exit starvation mode.\"),this._inStarvationMode=!1):this._inStarvationMode&&(c.info(\"ABR: exit starvation mode.\"),this._inStarvationMode=!1),this._inStarvationMode&&(s=ql(i,e,r,this._lowLatencyMode,a),s!==void 0&&(c.info(\"ABR: starvation mode emergency estimate:\",s),t.reset(),o=v(r)?s:Math.min(s,r.bitrate))),v(o)&&(s=t.getEstimate(),s!==void 0?o=s*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):a!==void 0?o=a*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):o=this._initialBitrate),e.speed>1&&(o/=e.speed),{bandwidthEstimate:s,bitrateChosen:o}}isUrgent(e,t,r,i){return t===null?!0:e>=t.bitrate?!1:Hl(i,r,this._lowLatencyMode)}};var Wn=class{constructor(){this.bandwidth=void 0,this.representation=null,this.algorithmType=3}update(e,t,r){this.representation=e,this.bandwidth=t,this.algorithmType=r}};var Vn=class{constructor(e,t){this._scoreCalculator=e,this._lastAbrEstimate=t,this._consecutiveWrongGuesses=0,this._blockGuessesUntil=0,this._lastMaintanableBitrate=null}getGuess(e,t,r,i,a){let{bufferGap:o,speed:s}=t,u=this._lastAbrEstimate.representation;if(u===null)return null;if(i>u.bitrate)return this._lastAbrEstimate.algorithmType===2&&(this._lastAbrEstimate.representation!==null&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;let l=this._scoreCalculator.getEstimate(r);if(this._lastAbrEstimate.algorithmType!==2){if(l===void 0)return null;if(this._canGuessHigher(o,s,l)){let f=Os(e,r);if(f!==null)return f}return null}if(this._isLastGuessValidated(u,i,l)&&(c.debug(\"ABR: Guessed Representation validated\",u.bitrate),this._lastMaintanableBitrate=u.bitrate,this._consecutiveWrongGuesses=0),r.id!==u.id)return u;if(this._shouldStopGuess(r,l,o,a))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=L()+Math.min(this._consecutiveWrongGuesses*15e3,12e4),Gl(e,r);if(l===void 0)return r;if(this._canGuessHigher(o,s,l)){let f=Os(e,r);if(f!==null)return f}return r}_canGuessHigher(e,t,{score:r,confidenceLevel:i}){return isFinite(e)&&e>=2.5&&L()>this._blockGuessesUntil&&i===1&&r/t>1.01}_shouldStopGuess(e,t,r,i){if(t!==void 0&&t.score<1.01)return!0;if((t===void 0||t.score<1.2)&&r<.6)return!0;let a=i.filter(s=>s.content.representation.id===e.id),o=L();for(let s of a){let u=o-s.requestTimestamp;if(s.content.segment.isInit){if(u>1e3)return!0}else{if(u>s.content.segment.duration*1e3+200)return!0;{let l=Fr(s);if(l!==void 0&&l<e.bitrate*.8)return!0}}}return!1}_isLastGuessValidated(e,t,r){return r!==void 0&&r.confidenceLevel===1&&r.score>1.5?!0:t>=e.bitrate&&(this._lastMaintanableBitrate===null||this._lastMaintanableBitrate<e.bitrate)}};function Os(n,e){let t=n.length,r=ne(n,({id:i})=>i===e.id);if(r<0)return c.error(\"ABR: Current Representation not found.\"),null;for(;++r<t;)if(n[r].bitrate>e.bitrate)return n[r];return null}function Gl(n,e){let t=ne(n,({id:r})=>r===e.id);if(t<0)return c.error(\"ABR: Current Representation not found.\"),null;for(;--t>=0;)if(n[t].bitrate<e.bitrate)return n[t];return null}var qn=class{constructor(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=U.getCurrent();this._fastEWMA=new Ue(e),this._slowEWMA=new Ue(t),this._bytesSampled=0}addSample(e,t){let{ABR_MINIMUM_CHUNK_SIZE:r}=U.getCurrent();if(t<r)return;let i=t*8e3/e,a=e/1e3;this._bytesSampled+=t,this._fastEWMA.addSample(a,i),this._slowEWMA.addSample(a,i)}getEstimate(){let{ABR_MINIMUM_TOTAL_BYTES:e}=U.getCurrent();if(!(this._bytesSampled<e))return Math.min(this._fastEWMA.getEstimate(),this._slowEWMA.getEstimate())}reset(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=U.getCurrent();this._fastEWMA=new Ue(e),this._slowEWMA=new Ue(t),this._bytesSampled=0}};function Ra(n,e){if(n.length===0)return[];n.sort((a,o)=>a.bitrate-o.bitrate);let t=n[0].bitrate,r=Math.max(e,t),i=ne(n,a=>a.bitrate>r);return i===-1?n:n.slice(0,i)}function Pa(n,e){if(e.width===void 0||e.height===void 0)return n;let t=e.width*e.pixelRatio,r=e.height*e.pixelRatio,i=n.slice().sort((s,u)=>{var l,d;return((l=s.width)!=null?l:0)-((d=u.width)!=null?d:0)}),a=K(i,s=>typeof s.width==\"number\"&&s.width>=t&&typeof s.height==\"number\"&&s.height>=r);if(a===void 0)return n;let o=typeof a.width==\"number\"?a.width:0;return n.filter(s=>typeof s.width==\"number\"?s.width<=o:!0)}var Hn=class{constructor(){this._currentRequests={}}add(e){let{id:t,requestTimestamp:r,content:i}=e;this._currentRequests[t]={requestTimestamp:r,progress:[],content:i}}addProgress(e){let t=this._currentRequests[e.id];if(v(t)){if(b.CURRENT_ENV===b.DEV)throw new Error(\"ABR: progress for a request not added\");c.warn(\"ABR: progress for a request not added\");return}t.progress.push(e)}remove(e){if(v(this._currentRequests[e])){if(b.CURRENT_ENV===b.DEV)throw new Error(\"ABR: can't remove unknown request\");c.warn(\"ABR: can't remove unknown request\")}delete this._currentRequests[e]}getRequests(){return ar(this._currentRequests).filter(e=>!v(e)).sort((e,t)=>e.content.segment.time-t.content.segment.time)}};function zr(n,e){let t=ne(n,r=>r.bitrate>e);return t===-1?n[n.length-1]:t===0?n[0]:n[t-1]}var ws=new G(void 0);ws.finish();var Ds=new G(1/0);Ds.finish();function va(n){let e={},{initialBitrates:t,throttlers:r,lowLatencyMode:i}=n;return function(s,u,l,d,f){var I,y,E;let{type:m}=s.adaptation,p=a(m),g=(I=t[m])!=null?I:0,h={limitResolution:(y=r.limitResolution[m])!=null?y:ws,throttleBitrate:(E=r.throttleBitrate[m])!=null?E:Ds};return Kl({bandwidthEstimator:p,context:s,currentRepresentation:u,filters:h,initialBitrate:g,playbackObserver:d,representations:l,lowLatencyMode:i},f)};function a(o){let s=e[o];if(v(s)){c.debug(\"ABR: Creating new BandwidthEstimator for \",o);let u=new qn;return e[o]=u,u}return s}}function Kl({bandwidthEstimator:n,context:e,currentRepresentation:t,filters:r,initialBitrate:i,lowLatencyMode:a,playbackObserver:o,representations:s},u){let l=new Ln,d=new zn(i!=null?i:0,a),f=new Hn,m=N,p={metrics:E,requestBegin:R,requestProgress:T,requestEnd:C,addedSegment(P){m(P)}},g=new W;g.linkToSignal(u);let h=I(s.getValue(),g.signal);return s.onUpdate(y,{clearSignal:u}),{estimates:h,callbacks:p};function I(P,x){if(P.length<=1)return new G({bitrate:void 0,representation:P[0],urgent:!0,knownStableBitrate:void 0});let _=!1,A=P.sort((q,J)=>q.bitrate-J.bitrate),M=new Fn(A.map(q=>q.bitrate)),k=new Wn,D=new Vn(l,k),w=o.getReference().getValue(),O=new G(z());return o.listen(q=>{w=q,B()},{includeLastObservation:!1,clearSignal:x}),m=function(q){if(w===null)return;let{position:J,speed:$}=w,V=q.buffered,Y=Ar(V,J.getWanted()),{representation:X}=q.content,me=l.getEstimate(X),ce=X.bitrate,de={bufferGap:Y,currentBitrate:ce,currentScore:me,speed:$};M.onAddedSegment(de),B()},x.register(()=>{m=N}),r.throttleBitrate.onUpdate(B,{clearSignal:x}),r.limitResolution.onUpdate(B,{clearSignal:x}),O;function B(){O.setValue(z())}function z(){let{bufferGap:q,position:J,maximumPosition:$}=w,V=r.limitResolution.getValue(),Y=r.throttleBitrate.getValue(),X=t.getValue(),me=jl(A,V,Y),ce=f.getRequests(),{bandwidthEstimate:de,bitrateChosen:Ie}=d.getBandwidthEstimate(w,n,X,ce,k.bandwidth),Jn=l.getLastStableRepresentation(),pe=Jn===null?void 0:Jn.bitrate/(w.speed>0?w.speed:1),{ABR_ENTER_BUFFER_BASED_ALGO:be,ABR_EXIT_BUFFER_BASED_ALGO:Kt}=U.getCurrent();_&&q<=Kt?_=!1:!_&&isFinite(q)&&q>=be&&(_=!0);let He=zr(me,Ie),xe=M.getLastEstimate(),xt=He.bitrate,it=null;_&&xe!==void 0&&xe>xt&&(it=zr(me,xe),xt=it.bitrate);let at=null;return a&&X!==null&&e.manifest.isDynamic&&$-J.getWanted()<40&&(at=D.getGuess(A,w,X,xt,ce)),at!==null&&at.bitrate>xt?(c.debug(\"ABR: Choosing representation with guess-based estimation.\",at.bitrate,at.id),k.update(at,de,2),{bitrate:de,representation:at,urgent:X===null||at.bitrate<X.bitrate,knownStableBitrate:pe}):it!==null?(c.debug(\"ABR: Choosing representation with buffer-based estimation.\",it.bitrate,it.id),k.update(it,de,0),{bitrate:de,representation:it,urgent:d.isUrgent(it.bitrate,X,ce,w),knownStableBitrate:pe}):(c.debug(\"ABR: Choosing representation with bandwidth estimation.\",He.bitrate,He.id),k.update(He,de,1),{bitrate:de,representation:He,urgent:d.isUrgent(He.bitrate,X,ce,w),knownStableBitrate:pe})}}function y(){let P=s.getValue();g.cancel(),g=new W,g.linkToSignal(u),I(P,g.signal).onUpdate(function(A){h.setValue(A)},{clearSignal:g.signal,emitCurrentValue:!0})}function E(P){let{requestDuration:x,segmentDuration:_,size:A,content:M}=P;if(n.addSample(x,A),!M.segment.isInit){let{segment:k,representation:D}=M;if(_===void 0&&!k.complete)return;let w=_!=null?_:k.duration;l.addSample(D,x/1e3,w)}}function R(P){f.add(P)}function T(P){f.addProgress(P)}function C(P){f.remove(P.id)}}function jl(n,e,t){let r=n;return t!==void 0&&t<1/0&&(r=Ra(r,t)),e!==void 0&&(r=Pa(r,e)),r}var Ns=va;function rt(n){return n instanceof re?new Ke(\"PIPELINE_LOAD_ERROR\",n):ge(n,{defaultCode:\"PIPELINE_LOAD_ERROR\",defaultReason:\"Unknown error when fetching the Manifest\"})}function Ca(n){let e=(Math.random()*2-1)*.3;return n*(e+1)}function Yl(n){return n instanceof re?n.type===It.ERROR_HTTP_CODE?n.status>=500||n.status===404||n.status===415||n.status===412:n.type===It.TIMEOUT||n.type===It.ERROR_EVENT:n instanceof Ge?typeof n.canRetry==\"boolean\"?n.canRetry:n.xhr!==void 0?n.xhr.status>=500||n.xhr.status===404||n.xhr.status===415||n.xhr.status===412:!1:Mt(n)&&n.code===\"INTEGRITY_ERROR\"}async function Aa(n,e,t,r,i){if(i.cancellationError!==null)return Promise.reject(i.cancellationError);let{baseDelay:a,maxDelay:o,maxRetry:s,onRetry:u}=r;n!==null&&n.length===0&&c.warn(\"Fetchers: no CDN given to `scheduleRequestWithCdns`.\");let l=new Map,d=f();if(d===void 0)throw new Error(\"No CDN to request\");return m(d);function f(){if(n===null){let I=l.get(null);return I!==void 0&&I.isBlacklisted?void 0:null}else{if(e===null)return h(n);{let I=e.getCdnPreferenceForResource(n);return h(I)}}}async function m(I){try{return await t(I,i)}catch(y){if(W.isCancellationError(y))throw y;I!==null&&e!==null&&e.downgradeCdn(I);let E=l.get(I);if(E===void 0?(E={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},l.set(I,E)):E.errorCounter++,!Yl(y))return E.blockedUntil=void 0,E.isBlacklisted=!0,p(y);if(E.errorCounter>s)E.blockedUntil=void 0,E.isBlacklisted=!0;else{let R=E.errorCounter,T=Math.min(a*Math.pow(2,R-1),o),C=Ca(T);E.blockedUntil=L()+C}return p(y)}}async function p(I){let y=f();if(i.isCancelled())throw i.cancellationError;if(y===void 0)throw I;if(u(I),i.isCancelled())throw i.cancellationError;return g(y,I)}function g(I,y){let E=l.get(I);if(E===void 0||E.blockedUntil===void 0)return m(I);let R=L(),T=E.blockedUntil-R;if(T<=0)return m(I);let C=new W,P=C.linkToSignal(i);return new Promise((x,_)=>{e==null||e.addEventListener(\"priorityChange\",()=>{let k=f();if(i.isCancelled())throw i.cancellationError;if(k===void 0)return M(y);k!==I&&(C.cancel(),g(k,y).then(A,M))},C.signal),kn(T,C.signal).then(()=>m(I).then(A,M),N);function A(k){P(),x(k)}function M(k){P(),_(k)}})}function h(I){var E;if(l.size===0)return I[0];let y=L();return(E=I.filter(R=>{var T;return((T=l.get(R))==null?void 0:T.isBlacklisted)!==!0}).reduce((R,T)=>{var P;let C=(P=l.get(T))==null?void 0:P.blockedUntil;return C!==void 0&&C<=y&&(C=void 0),R===void 0?[T,C]:R[1]===void 0?R:C===void 0?[T,void 0]:C<R[1]?[T,C]:R},void 0))==null?void 0:E[0]}}function ka(n,e,t){return Aa(null,null,n,e,t)}var Gn=class extends oe{constructor(e,t,r){super(),this.scheduleManualRefresh=N,this._manifestUrls=e,this._pipelines=t.manifest,this._settings=r,this._canceller=new W,this._isStarted=!1,this._isRefreshPending=!1,this._consecutiveUnsafeMode=0,this._prioritizedContentUrl=null}dispose(){this._canceller.cancel(),this.removeEventListener()}start(){if(this._isStarted)return;this._isStarted=!0;let e,t=this._settings.initialManifest;t instanceof wt?e=Promise.resolve({manifest:t}):t!==void 0?e=this.parse(t,{previousManifest:null,unsafeMode:!1},void 0):e=this._fetchManifest(void 0).then(r=>r.parse({previousManifest:null,unsafeMode:!1})),e.then(r=>{this.trigger(\"manifestReady\",r.manifest),this._canceller.isUsed()||this._recursivelyRefreshManifest(r.manifest,r)}).catch(r=>this._onFatalError(r))}updateContentUrls(e,t){var r;this._prioritizedContentUrl=(r=e==null?void 0:e[0])!=null?r:void 0,t&&this.scheduleManualRefresh({enablePartialRefresh:!1,delay:0,canUseUnsafeMode:!1})}async _fetchManifest(e){var u;let t=this._canceller.signal,r=this._settings,i=this._pipelines,a=e!=null?e:(u=this._manifestUrls)==null?void 0:u[0],o=this._getBackoffSetting(l=>{this.trigger(\"warning\",rt(l))});try{let l=await s(a);return{parse:d=>this._parseLoadedManifest(l,d,a)}}catch(l){throw rt(l)}function s(l){let{loadManifest:d}=i,f=r.requestTimeout===void 0?U.getCurrent().DEFAULT_REQUEST_TIMEOUT:r.requestTimeout,m=r.connectionTimeout===void 0?U.getCurrent().DEFAULT_CONNECTION_TIMEOUT:r.connectionTimeout;return f<0&&(f=void 0),m<0&&(m=void 0),ka(()=>d(l,{timeout:f,connectionTimeout:m},t),o,t)}}parse(e,t,r){return this._parseLoadedManifest({responseData:e,size:void 0,requestDuration:void 0},t,r)}async _parseLoadedManifest(e,t,r){var h;let i=L(),a=this._canceller.signal,o=this.trigger.bind(this),{sendingTime:s,receivedTime:u}=e,l=this._getBackoffSetting(I=>{this.trigger(\"warning\",rt(I))}),d=r!=null?r:(h=this._manifestUrls)==null?void 0:h[0],f={externalClockOffset:t.externalClockOffset,unsafeMode:t.unsafeMode,previousManifest:t.previousManifest,originalUrl:d};try{let I=this._pipelines.parseManifest(e,f,p,a,m);if(Ql(I)){let{manifest:y,warnings:E}=await I;return g(y,E)}else return g(I.manifest,I.warnings)}catch(I){throw ge(I,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"})}async function m(I){try{return await ka(I,l,a)}catch(y){throw rt(y)}}function p(I){for(let y of I){if(a.isCancelled())return;let E=ge(y,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"});o(\"warning\",E)}}function g(I,y){p(y);let E=L()-i;return c.info(`MF: Manifest parsed in ${E}ms`),{manifest:I,sendingTime:s,receivedTime:u,parsingTime:E}}}_getBackoffSetting(e){let{DEFAULT_MAX_MANIFEST_REQUEST_RETRY:t,INITIAL_BACKOFF_DELAY_BASE:r,MAX_BACKOFF_DELAY_BASE:i}=U.getCurrent(),{lowLatencyMode:a,maxRetry:o}=this._settings,s=a?r.LOW_LATENCY:r.REGULAR,u=a?i.LOW_LATENCY:i.REGULAR,l=o!=null?o:t;return{onRetry:e,baseDelay:s,maxDelay:u,maxRetry:l}}_recursivelyRefreshManifest(e,{sendingTime:t,parsingTime:r,updatingTime:i}){let{MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:a,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:o}=U.getCurrent(),s=r!==void 0?r+(i!=null?i:0):void 0,u=!1;this._consecutiveUnsafeMode>0?u=this._consecutiveUnsafeMode<a:s!==void 0&&(u=s>=o);let l=t===void 0?0:L()-t,d=Math.max(this._settings.minimumManifestUpdateInterval-l,0),f=new W;if(f.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=m=>{let{enablePartialRefresh:p,delay:g,canUseUnsafeMode:h}=m,I=h&&u,y=t===void 0?0:L()-t,E=Math.max(this._settings.minimumManifestUpdateInterval-y,0),R=setTimeout(()=>{f.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:p,unsafeMode:I})},Math.max((g!=null?g:0)-y,E));f.signal.register(()=>{clearTimeout(R)})},e.expired!==null){let m=setTimeout(()=>{var p;(p=e.expired)==null||p.then(()=>{f.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:u})},N)},d);f.signal.register(()=>{clearTimeout(m)})}if(e.lifetime!==void 0&&e.lifetime>=0){let m=e.lifetime*1e3-l,p;s===void 0?p=m:e.lifetime<3&&s>=100?(p=Math.min(Math.max(3e3-l,Math.max(m,0)+s),m*6),c.info(\"MUS: Manifest update rythm is too frequent. Postponing next request.\",m,p)):s>=e.lifetime*1e3/10?(p=Math.min(Math.max(m,0)+s,m*6),c.info(\"MUS: Manifest took too long to parse. Postponing next request\",p,p)):p=m;let g=setTimeout(()=>{f.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:u})},Math.max(p,d));f.signal.register(()=>{clearTimeout(g)})}}_triggerNextManifestRefresh(e,{enablePartialRefresh:t,unsafeMode:r}){let i=e.updateUrl,a,o;this._prioritizedContentUrl!==null?(a=!0,o=this._prioritizedContentUrl,this._prioritizedContentUrl=null):(a=!t||i===void 0,o=a?e.getUrls()[0]:i);let s=e.clockOffset;r?(this._consecutiveUnsafeMode+=1,c.info('Init: Refreshing the Manifest in \"unsafeMode\" for the '+String(this._consecutiveUnsafeMode)+\" consecutive time.\")):this._consecutiveUnsafeMode>0&&(c.info('Init: Not parsing the Manifest in \"unsafeMode\" anymore after '+String(this._consecutiveUnsafeMode)+\" consecutive times.\"),this._consecutiveUnsafeMode=0),!this._isRefreshPending&&(this._isRefreshPending=!0,this._fetchManifest(o).then(u=>u.parse({externalClockOffset:s,previousManifest:e,unsafeMode:r})).then(u=>{this._isRefreshPending=!1;let{manifest:l,sendingTime:d,parsingTime:f}=u,m=L();if(a)e.replace(l);else try{e.update(l)}catch(g){let h=g instanceof Error?g.message:\"unknown error\";c.warn(`MUS: Attempt to update Manifest failed: ${h}`,\"Re-downloading the Manifest fully\");let{FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:I}=U.getCurrent(),y=d===void 0?0:L()-d,E=Math.max(this._settings.minimumManifestUpdateInterval-y,0),R=N,T=setTimeout(()=>{R(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})},Math.max(I-y,E));R=this._canceller.signal.register(()=>{clearTimeout(T)});return}let p=L()-m;this._recursivelyRefreshManifest(e,{sendingTime:d,parsingTime:f,updatingTime:p})}).catch(u=>{this._isRefreshPending=!1,this._onFatalError(u)}))}_onFatalError(e){this._canceller.isUsed()||(this.trigger(\"error\",e),this.dispose())}};function Ql(n){return n instanceof Promise}var xa=Gn;function Ma(n,e){let t=new WeakMap;return{createRequest(r,i,a,o){let s=l=>e(r,a,l),u=n.create(s,i,a,o);return t.set(u,s),u},updatePriority(r,i){let a=t.get(r);if(a===void 0){c.warn(\"Fetchers: Cannot update the priority of a request: task not found.\");return}n.updatePriority(a,i)}}}var Kn=class extends oe{constructor(e){super(),this._downgradedCdnList={metadata:[],timeouts:[]},e.register(()=>{for(let t of this._downgradedCdnList.timeouts)clearTimeout(t);this._downgradedCdnList={metadata:[],timeouts:[]}})}getCdnPreferenceForResource(e){return e.length<=1?e:this._innerGetCdnPreferenceForResource(e)}downgradeCdn(e){let t=Bs(this._downgradedCdnList.metadata,e);t>=0&&this._removeIndexFromDowngradeList(t);let{DEFAULT_CDN_DOWNGRADE_TIME:r}=U.getCurrent(),i=r;this._downgradedCdnList.metadata.push(e);let a=setTimeout(()=>{let o=Bs(this._downgradedCdnList.metadata,e);o>=0&&this._removeIndexFromDowngradeList(o),this.trigger(\"priorityChange\",null)},i);this._downgradedCdnList.timeouts.push(a),this.trigger(\"priorityChange\",null)}_innerGetCdnPreferenceForResource(e){let[t,r]=e.reduce((i,a)=>(this._downgradedCdnList.metadata.some(o=>o.id===a.id&&o.baseUrl===a.baseUrl)?i[1].push(a):i[0].push(a),i),[[],[]]);return t.concat(r)}_removeIndexFromDowngradeList(e){this._downgradedCdnList.metadata.splice(e,1);let t=this._downgradedCdnList.timeouts.splice(e,1);clearTimeout(t[0])}};function Bs(n,e){return n.length===0?-1:e.id!==void 0?ne(n,t=>t.id===e.id):ne(n,t=>t.baseUrl===e.baseUrl)}var Oa=class{constructor(){this._cache=new WeakMap}add({representation:e,segment:t},r){t.isInit&&this._cache.set(e,r)}get({representation:e,segment:t}){if(t.isInit){let r=this._cache.get(e);if(r!==void 0)return r}return null}},Us=Oa;var $l=Ae();function wa(n,e,t,r,i){let a;i.connectionTimeout===void 0||i.connectionTimeout<0?a=void 0:a=i.connectionTimeout;let o={timeout:i.requestTimeout<0?void 0:i.requestTimeout,connectionTimeout:a},s=se([\"audio\",\"video\"],n)?new Us:void 0,{loadSegment:u,parseSegment:l}=e;return async function(f,m,p){var q,J,$;let{segment:g,adaptation:h,representation:I,manifest:y,period:E}=f,R=bt(f),T=$l(),C,P=[],x=0,_=!1,A={segment:g,type:h.type,language:h.language,isLive:y.isLive,periodStart:E.start,periodEnd:E.end,mimeType:I.mimeType,codecs:I.codecs[0],manifestPublishTime:y.publishTime},M={onProgress(V){var Y;C===void 0&&V.totalSize!==void 0&&V.size<V.totalSize&&((Y=r.onProgress)==null||Y.call(r,{duration:V.duration,size:V.size,totalSize:V.totalSize,timestamp:L(),id:T}))},onNewChunk(V){m.onChunk(O(V,!0))}},k=s!==void 0?s.get(f):null;if(k!==null)return c.debug(\"SF: Found wanted segment in cache\",R),m.onChunk(O(k,!1)),Promise.resolve();c.debug(\"SF: Beginning request\",R),(q=r.onRequestBegin)==null||q.call(r,{requestTimestamp:L(),id:T,content:f}),p.register(D);try{let V=await Aa(f.representation.cdnMetadata,t,w,H({onRetry:B},i),p);if(V.resultType===\"segment-loaded\"){let Y=V.resultData.responseData;s!==void 0&&s.add(f,V.resultData.responseData),m.onChunk(O(Y,!1))}else V.resultType===\"segment-created\"&&m.onChunk(O(V.resultData,!1));c.debug(\"SF: Segment request ended with success\",R),m.onAllChunksReceived(),V.resultType!==\"segment-created\"?(C=V.resultData,z()):C=null,p.isCancelled()||(J=r.onRequestEnd)==null||J.call(r,{id:T}),p.deregister(D)}catch(V){throw p.deregister(D),C=null,V instanceof ie?(c.debug(\"SF: Segment request aborted\",R),V):(c.debug(\"SF: Segment request failed\",R),($=r.onRequestEnd)==null||$.call(r,{id:T}),rt(V))}function D(){var V;C===void 0&&(c.debug(\"SF: Segment request cancelled\",R),C=null,(V=r.onRequestEnd)==null||V.call(r,{id:T}))}function w(V){return u(V,A,o,p,M)}function O(V,Y){P.push(!1);let X=P.length-1;return function(ce){let de={data:V,isChunked:Y};try{let Ie=l(de,A,ce);return P[X]||(x=x!==void 0&&Ie.segmentType===\"media\"&&Ie.chunkInfos!==null&&Ie.chunkInfos.duration!==void 0?x+Ie.chunkInfos.duration:void 0,P[X]=!0,z()),Ie}catch(Ie){throw ge(Ie,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}}function B(V){m.onRetry(rt(V))}function z(){var V;_||!v(C)&&C.size!==void 0&&C.requestDuration!==void 0&&P.length>0&&P.every(Y=>Y)&&(_=!0,(V=r.onMetrics)==null||V.call(r,{size:C.size,requestDuration:C.requestDuration,content:f,segmentDuration:x}))}}}function Ls({maxRetry:n,lowLatencyMode:e,requestTimeout:t,connectionTimeout:r}){let{DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:i,DEFAULT_REQUEST_TIMEOUT:a,DEFAULT_CONNECTION_TIMEOUT:o,INITIAL_BACKOFF_DELAY_BASE:s,MAX_BACKOFF_DELAY_BASE:u}=U.getCurrent();return{maxRetry:n!=null?n:i,baseDelay:e?s.LOW_LATENCY:s.REGULAR,maxDelay:e?u.LOW_LATENCY:u.REGULAR,requestTimeout:t===void 0?a:t,connectionTimeout:r===void 0?o:r}}var Yn=class{constructor({prioritySteps:e}){if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=e,this._prioritySteps.high>=this._prioritySteps.low)throw new Error(\"TP: the max high level priority should be given a lowerpriority number than the min low priority.\")}create(e,t,r,i){let a;return kt(i,(o,s)=>(a={hasEnded:!1,priority:t,trigger:()=>{if(a.hasEnded)return;let l=()=>{p(),this._endTask(a)},d=g=>{r.beforeEnded(),l(),o(g)},f=g=>{l(),s(g)},m=new W,p=m.linkToSignal(i);a.interrupter=m,m.signal.register(()=>{a.interrupter=null,i.isCancelled()||r.beforeInterrupted()}),this._minPendingPriority=this._minPendingPriority===null?a.priority:Math.min(this._minPendingPriority,a.priority),this._pendingTasks.push(a),a.taskFn(m.signal).then(d).catch(g=>{!i.isCancelled()&&m.isUsed()&&g instanceof ie||f(g)})},taskFn:e,interrupter:null},this._canBeStartedNow(a)?(a.trigger(),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()):this._waitingQueue.push(a),()=>this._endTask(a)))}_endTask(e){e.hasEnded=!0;let t=jn(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{let r=jn(e.taskFn,this._pendingTasks);if(r<0)return;this._pendingTasks.splice(r,1),this._pendingTasks.length>0?this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min(...this._pendingTasks.map(i=>i.priority))):this._minPendingPriority=null,this._loopThroughWaitingQueue()}}updatePriority(e,t){let r=jn(e,this._waitingQueue);if(r>=0){let s=this._waitingQueue[r];if(s.priority===t||(s.priority=t,!this._canBeStartedNow(s)))return;this._findAndRunWaitingQueueTask(r),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks();return}let i=jn(e,this._pendingTasks);if(i<0){c.warn(\"TP: request to update the priority of a non-existent task\");return}let a=this._pendingTasks[i];if(a.priority===t)return;let o=a.priority;a.priority=t,this._minPendingPriority===null||t<this._minPendingPriority?this._minPendingPriority=t:this._minPendingPriority===o&&(this._pendingTasks.length===1?this._minPendingPriority=t:this._minPendingPriority=Math.min(...this._pendingTasks.map(s=>s.priority)),this._loopThroughWaitingQueue()),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()}_loopThroughWaitingQueue(){let e=this._waitingQueue.reduce((t,r)=>t===null||t>r.priority?r.priority:t,null);if(!(e===null||this._minPendingPriority!==null&&this._minPendingPriority<e))for(let t=0;t<this._waitingQueue.length;t++){let r=this._minPendingPriority===null?e:Math.min(this._minPendingPriority,e);this._waitingQueue[t].priority<=r&&(this._findAndRunWaitingQueueTask(t),t--)}}_interruptCancellableTasks(){for(let e=0;e<this._pendingTasks.length;e++){let t=this._pendingTasks[e];if(t.priority>=this._prioritySteps.low)return this._interruptPendingTask(t),this._interruptCancellableTasks()}}_findAndRunWaitingQueueTask(e){return e>=this._waitingQueue.length||e<0?(c.warn(\"TP : Tried to start a non existing task\"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)}_interruptPendingTask(e){var r;let t=jn(e.taskFn,this._pendingTasks);if(t<0){c.warn(\"TP: Interrupting a non-existent pending task. Aborting...\");return}this._pendingTasks.splice(t,1),this._waitingQueue.push(e),this._pendingTasks.length===0?this._minPendingPriority=null:this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min(...this._pendingTasks.map(i=>i.priority))),(r=e.interrupter)==null||r.cancel()}_canBeStartedNow(e){return this._minPendingPriority===null||e.priority<=this._minPendingPriority}_isRunningHighPriorityTasks(){return this._minPendingPriority!==null&&this._minPendingPriority<=this._prioritySteps.high}};function jn(n,e){return ne(e,t=>t.taskFn===n)}var Qn=class{constructor(e,t,r){let i=new Kn(r),{MIN_CANCELABLE_PRIORITY:a,MAX_HIGH_PRIORITY_LEVEL:o}=U.getCurrent();this._transport=e,this._prioritizer=new Yn({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=i,this._backoffOptions=t}createSegmentFetcher(e,t){let r=Ls(this._backoffOptions),i=this._transport[e],a=wa(e,i,this._cdnPrioritizer,t,r);return Ma(this._prioritizer,a)}};var Da=Qn;var $n=class{constructor(e){this._segmentSinksStore=e,this._currentFreezeTimestamp=null}needToReload(e){let{readyState:t,rebuffering:r,freezing:i}=e;if((e.bufferGap!==void 0&&isFinite(e.bufferGap)?e.bufferGap:0)<6||r===null&&i===null||t>1)return this._currentFreezeTimestamp=null,!1;let o=L();this._currentFreezeTimestamp===null&&(this._currentFreezeTimestamp=o);let s=r!==null&&o-r.timestamp>4e3,u=i!==null&&o-i.timestamp>4e3;if((s||u)&&L()-this._currentFreezeTimestamp>4e3){let l=this._segmentSinksStore.getStatus(\"audio\"),d=this._segmentSinksStore.getStatus(\"video\"),f=!0,m=!0;for(let p of[l,d])if(p.type===\"initialized\")for(let g of p.value.getLastKnownInventory()){let{representation:h}=g.infos;if(h.decipherable===!1)return c.warn(\"Init: we have undecipherable segments left in the buffer, reloading\"),this._currentFreezeTimestamp=null,!0;h.contentProtections!==void 0&&(m=!1,h.decipherable!==!0&&(f=!1))}if(!m&&f)return c.warn(\"Init: we are frozen despite only having decipherable segments left in the buffer, reloading\"),this._currentFreezeTimestamp=null,!0}return!1}};var{DEFAULT_WANTED_BUFFER_AHEAD:Xl,DEFAULT_MAX_VIDEO_BUFFER_SIZE:Zl,DEFAULT_MAX_BUFFER_AHEAD:Jl,DEFAULT_MAX_BUFFER_BEHIND:ef}=U.getCurrent(),Na=new G(Xl),Ba=new G(Zl),Ua=new G(Jl),La=new G(ef),Wr=new G({height:void 0,width:void 0,pixelRatio:1}),Vr=new G(1/0);function Q(n,e){c.debug(\"<--- Sending to Main:\",n.type),e===void 0?postMessage(n):postMessage(n,e)}function we(n){return ge(n,{defaultCode:\"NONE\",defaultReason:\"An unknown error stopped content playback.\"}).serialize()}var Xn=class{constructor(){this._refs=new Map}reset(){var e,t,r,i,a,o,s,u,l,d,f,m;for(let p of this._refs.keys())(t=(e=this._refs.get(p))==null?void 0:e.audio)==null||t.trackReference.finish(),(i=(r=this._refs.get(p))==null?void 0:r.audio)==null||i.representations.finish(),(o=(a=this._refs.get(p))==null?void 0:a.video)==null||o.trackReference.finish(),(u=(s=this._refs.get(p))==null?void 0:s.video)==null||u.representations.finish(),(d=(l=this._refs.get(p))==null?void 0:l.text)==null||d.trackReference.finish(),(m=(f=this._refs.get(p))==null?void 0:f.text)==null||m.representations.finish();this._refs=new Map}addTrackSetter(e,t,r){var s,u;let i=this._refs.get(e);i===void 0&&(i={},this._refs.set(e,i)),i[t]!==void 0&&(c.warn(\"WP: Track for periodId already declared\",e,t),(s=i[t])==null||s.trackReference.finish(),(u=i[t])==null||u.representations.finish());let a=r.getValue(),o;v(a)?o=new G({representationIds:[],switchingMode:\"lazy\"}):(o=new G(a.representations.getValue()),r.setValue(H({},a,{representations:o}))),i[t]={trackReference:r,representations:o}}setTrack(e,t,r){var a;let i=(a=this._refs.get(e))==null?void 0:a[t];return i===void 0?(c.debug(\"WP: Setting track for inexistent periodId\",e,t),!1):(v(r)?(i.representations=new G({representationIds:[],switchingMode:\"lazy\"}),i.trackReference.setValue(r)):(i.representations=new G(r.initialRepresentations),i.trackReference.setValue({adaptationId:r.adaptationId,switchingMode:r.switchingMode,representations:i.representations,relativeResumingPosition:r.relativeResumingPosition})),!0)}updateRepresentations(e,t,r,i){var s;let a=(s=this._refs.get(e))==null?void 0:s[r];if(a===void 0)return c.debug(\"WP: Setting track for inexistent periodId\",e,r),!1;let o=a.trackReference.getValue();return v(o)||o.adaptationId!==t?(c.debug(\"WP: Desynchronized Adaptation id\",o==null?void 0:o.adaptationId,t),!1):(a.representations.setValue(i),!0)}removeTrackSetter(e,t){let r=this._refs.get(e),i=r==null?void 0:r[t];return r===void 0||i===void 0?(c.debug(\"WP: Removing track setter for inexistent periodId\",e,t),!1):(i.trackReference.finish(),i.representations.finish(),delete r[t],Object.keys(r).length===0&&this._refs.delete(e),!0)}};var Zn=class{constructor(e,t){this._contentId=e,this._messageSender=t,this._queues={pushTextData:[],remove:[]}}pushTextData(e){return new Promise((t,r)=>{this._messageSender({type:\"push-text-data\",contentId:this._contentId,value:e}),this._queues.pushTextData.push({resolve:t,reject:r})})}remove(e,t){return new Promise((r,i)=>{this._messageSender({type:\"remove-text-data\",contentId:this._contentId,value:{start:e,end:t}}),this._queues.remove.push({resolve:r,reject:i})})}reset(){this._messageSender({type:\"reset-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue()}stop(){this._messageSender({type:\"stop-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue()}_resetCurrentQueue(){let e=new ie;this._queues.pushTextData.forEach(t=>{t.reject(e)}),this._queues.remove.forEach(t=>{t.reject(e)})}onPushedTrackSuccess(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"WMS: pushTextData success for inexistant operation\");return}t.resolve(e)}onPushedTrackError(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"WMS: pushTextData error for inexistant operation\");return}t.reject(e)}onRemoveSuccess(e){let t=this._queues.remove.shift();if(t===void 0){c.error(\"WMS: remove success for inexistant operation\");return}t.resolve(e)}onRemoveError(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"WMS: pushTextData error for inexistant operation\");return}t.reject(e)}};var Fs=Ae(),Gt=class{constructor({hasMseInWorker:e,hasVideo:t}){this._currentContent=null,this._currentMediaSourceCanceller=new W,this._hasVideo=t,this._hasMseInWorker=e;let r=new W;this._contentCanceller=r}initializeNewContent(e){return new Promise((t,r)=>{var x,_;this.disposeCurrentContent();let i=this._contentCanceller,a=new W;this._currentMediaSourceCanceller=a,a.linkToSignal(i.signal);let{contentId:o,url:s,hasText:u,transportOptions:l}=e,d=null;he(ae.transports.dash!==void 0,\"Multithread RxPlayer should have access to the DASH feature\");let f=typeof l.representationFilter==\"string\"?ro(l.representationFilter):void 0,m=ae.transports.dash(Le(_e({},l),{representationFilter:f})),p=new xa(s===void 0?void 0:[s],m,e.manifestRetryOptions),g=Ns({initialBitrates:{audio:(x=e.initialAudioBitrate)!=null?x:0,video:(_=e.initialVideoBitrate)!=null?_:0},lowLatencyMode:l.lowLatencyMode,throttlers:{limitResolution:{video:Wr},throttleBitrate:{video:Vr}}}),h=a.signal.register(A=>{r(A)}),I=new Da(m,e.segmentRetryOptions,i.signal),y=new Xn,[E,R,T]=zs(o,{hasMseInWorker:this._hasMseInWorker,hasVideo:this._hasVideo,hasText:u},a.signal),C=new $n(R);this._currentContent={contentId:o,decipherabilityFreezeDetector:C,mediaSource:E,manifest:null,manifestFetcher:p,representationEstimator:g,segmentSinksStore:R,segmentFetcherCreator:I,workerTextSender:T,trackChoiceSetter:y},E.addEventListener(\"mediaSourceOpen\",function(){P()},a.signal),i.signal.register(()=>{p.dispose()}),p.addEventListener(\"warning\",A=>{Q({type:\"warning\",contentId:o,value:we(A)})},i.signal),p.addEventListener(\"manifestReady\",A=>{if(d!==null){c.warn(\"WP: Multiple `manifestReady` events, ignoring\");return}d=A,this._currentContent!==null&&(this._currentContent.manifest=d),P()},a.signal),p.addEventListener(\"error\",A=>{r(A)},i.signal),p.start();function P(){if(d===null||E.readyState===\"closed\"||a.isUsed())return;let A=d.getMetadataSnapshot();d.addEventListener(\"manifestUpdate\",M=>{if(d===null)return;let k=H(d.getMetadataSnapshot(),{periods:[]});Q({type:\"manifest-update\",contentId:o,value:{manifest:k,updates:M}})},i.signal),h(),t(A)}})}getCurrentContent(){return this._currentContent}scheduleManifestRefresh(e){var t;(t=this._currentContent)==null||t.manifestFetcher.scheduleManualRefresh(e)}reloadMediaSource(e){if(this._currentMediaSourceCanceller.cancel(),this._currentContent===null)return Promise.reject(new Error(\"CP: No content anymore\"));this._currentContent.trackChoiceSetter.reset(),this._currentMediaSourceCanceller=new W,Q({type:\"reloading-media-source\",contentId:this._currentContent.contentId,value:e},[]);let[t,r,i]=zs(this._currentContent.contentId,{hasMseInWorker:this._hasMseInWorker,hasVideo:this._hasVideo,hasText:this._currentContent.workerTextSender!==null},this._currentMediaSourceCanceller.signal);return this._currentContent.mediaSource=t,this._currentContent.segmentSinksStore=r,this._currentContent.workerTextSender=i,new Promise((a,o)=>{t.addEventListener(\"mediaSourceOpen\",function(){a()},this._currentMediaSourceCanceller.signal),t.addEventListener(\"mediaSourceClose\",function(){o(new Error(\"MediaSource ReadyState changed to close during init.\"))},this._currentMediaSourceCanceller.signal),this._currentMediaSourceCanceller.signal.register(s=>{o(s)})})}disposeCurrentContent(){this._contentCanceller.cancel(),this._contentCanceller=new W}};function zs(n,e,t){let r;if(e.hasMseInWorker){let s=new Bn(Fs());r=s;let u,l=s.handle;if(l.type===\"handle\")u={type:\"handle\",value:l.value};else{let d=URL.createObjectURL(l.value);u={type:\"url\",value:d},t.register(()=>{URL.revokeObjectURL(d)})}Q({type:\"attach-media-source\",contentId:n,value:u,mediaSourceId:r.id},[l.value])}else r=new Un(Fs(),n,Q);let i=e.hasText?new Zn(n,Q):null,{hasVideo:a}=e,o=new ht(r,a,i);return t.register(()=>{o.disposeAll(),i==null||i.stop(),r.dispose()}),[r,o,i]}function Fa(){let n=!1,e=new Gt({hasMseInWorker:!1,hasVideo:!0}),t=null,r=new Wo;ae.dashParsers.wasm=r,ae.dashParsers.fastJs=Ao,ae.transports.dash=ts;let i=null;onmessage=function(a){var s,u,l;c.debug(\"Worker: received message\",a.data.type);let o=a.data;switch(o.type){case\"init\":he(!n),n=!0,qa(o.value),Ws(o.value.logLevel,o.value.sendBackLogs),o.value.dashWasmUrl!==void 0&&r.isCompatible()&&r.initialize({wasmUrl:o.value.dashWasmUrl}).catch(d=>{let f=d instanceof Error?d.toString():\"Unknown Error\";c.error(\"Worker: Could not initialize DASH_WASM parser\",f)}),(!o.value.hasVideo||o.value.hasMseInWorker)&&(e.disposeCurrentContent(),e=new Gt({hasMseInWorker:o.value.hasMseInWorker,hasVideo:o.value.hasVideo})),ae.codecSupportProber=o.value.hasMseInWorker?oo:so,Q({type:\"init-success\",value:null});break;case\"log-level-update\":Ws(o.value.logLevel,o.value.sendBackLogs);break;case\"prepare\":tf(e,o.value);break;case\"start\":{let d=e.getCurrentContent();if(o.contentId!==(d==null?void 0:d.contentId))return;t!==null&&(t.cancel(),t=null);let f=new W,m=new G(H(o.value.initialObservation,{position:new Pt(...o.value.initialObservation.position)}));i=m,t=f,t.signal.register(()=>{m.finish()}),Vs(o.value,e,m,f.signal);break}case\"observation\":{let d=e.getCurrentContent();if(o.contentId!==(d==null?void 0:d.contentId))return;let f=o.value,{buffered:m}=f,p=Ia(d.mediaSource,null);p.audio!==null&&(m.audio=p.audio),p.video!==null&&(m.video=p.video),i==null||i.setValue(H(f,{position:new Pt(...o.value.position)}));break}case\"ref-update\":nf(o);break;case\"stop\":if(o.contentId!==((s=e.getCurrentContent())==null?void 0:s.contentId))return;e.disposeCurrentContent(),t!==null&&(t.cancel(),t=null);break;case\"sb-success\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;let{sourceBuffers:f}=d.mediaSource,m=K(f,p=>p.type===o.sourceBufferType);if(m===void 0){c.info(\"WP: Success for an unknown SourceBuffer\",o.sourceBufferType);return}if(m.onOperationSuccess===void 0){c.warn(\"WP: A SourceBufferInterface with MSE performed a cross-thread operation\",o.sourceBufferType);return}m.onOperationSuccess(o.operationId,o.value.buffered);break}case\"sb-error\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;let{sourceBuffers:f}=d.mediaSource,m=K(f,p=>p.type===o.sourceBufferType);if(m===void 0){c.info(\"WP: Error for an unknown SourceBuffer\",o.sourceBufferType);return}if(m.onOperationFailure===void 0){c.warn(\"WP: A SourceBufferInterface with MSE performed a cross-thread operation\",o.sourceBufferType);return}m.onOperationFailure(o.operationId,o.value);break}case\"media-source-ready-state-change\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;if(d.mediaSource.onMediaSourceReadyStateChanged===void 0){c.warn(\"WP: A MediaSourceInterface with MSE performed a cross-thread operation\");return}d.mediaSource.onMediaSourceReadyStateChanged(o.value);break}case\"decipherability-update\":{if(o.contentId!==((u=e.getCurrentContent())==null?void 0:u.contentId))return;let d=e.getCurrentContent();if(d===null||d.manifest===null)return;let f=o.value;d.manifest.updateRepresentationsDeciperability(m=>{for(let p of f)if(m.representation.uniqueId===p.representationUniqueId)return p.decipherable;return m.representation.decipherable});break}case\"codec-support-update\":{let d=e.getCurrentContent();if(d===null||d.manifest===null)return;if(typeof((l=ae.codecSupportProber)==null?void 0:l.updateCache)==\"function\")for(let{mimeType:f,codec:m,result:p}of o.value)ae.codecSupportProber.updateCache(f,m,p);try{let f=d.manifest.refreshCodecSupport(o.value);f!==null&&Q({type:\"warning\",contentId:d.contentId,value:we(f)})}catch(f){Q({type:\"error\",contentId:d.contentId,value:we(f)})}break}case\"urls-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.manifestFetcher.updateContentUrls(o.value.urls,o.value.refreshNow);break}case\"track-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.trackChoiceSetter.setTrack(o.value.periodId,o.value.bufferType,o.value.choice);break}case\"rep-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.trackChoiceSetter.updateRepresentations(o.value.periodId,o.value.adaptationId,o.value.bufferType,o.value.choice);break}case\"add-text-success\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Added text track but text track aren't enabled\");return}d.workerTextSender.onPushedTrackSuccess(o.value.ranges);break}case\"push-text-error\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Added text track but text track aren't enabled\");return}d.workerTextSender.onPushedTrackError(new Error(o.value.message));break}case\"remove-text-success\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Removed text track but text track aren't enabled\");return}d.workerTextSender.onRemoveSuccess(o.value.ranges);break}case\"remove-text-error\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Removed text track but text track aren't enabled\");return}d.workerTextSender.onRemoveError(new Error(o.value.message));break}default:ze(o)}}}function tf(n,e){n.initializeNewContent(e).then(t=>{Q({type:\"manifest-ready\",contentId:e.contentId,value:{manifest:t}})},t=>{Q({type:\"error\",contentId:e.contentId,value:we(t)})})}function nf(n){switch(n.value.name){case\"wantedBufferAhead\":Na.setValueIfChanged(n.value.newVal);break;case\"maxVideoBufferSize\":Ba.setValueIfChanged(n.value.newVal);break;case\"maxBufferBehind\":La.setValueIfChanged(n.value.newVal);break;case\"maxBufferAhead\":Ua.setValueIfChanged(n.value.newVal);break;case\"limitVideoResolution\":Wr.setValueIfChanged(n.value.newVal);break;case\"throttleVideoBitrate\":Vr.setValueIfChanged(n.value.newVal);break;default:ze(n.value)}}function Vs(n,e,t,r){var x;let i=new W;i.linkToSignal(r);let a=new Map,o=e.getCurrentContent();if(o===null||o.manifest===null){let _=new Re(\"NONE\",\"Loading content when none is prepared\");Q({type:\"error\",contentId:void 0,value:we(_)});return}let{contentId:s,manifest:u,mediaSource:l,representationEstimator:d,segmentSinksStore:f,segmentFetcherCreator:m}=o,{drmSystemId:p,enableFastSwitching:g,initialTime:h,onCodecSwitch:I}=n;if(t.onUpdate(_=>{o.decipherabilityFreezeDetector.needToReload(_)&&P({timeOffset:0,minimumPosition:0,maximumPosition:1/0}),[\"video\",\"audio\",\"text\"].forEach(A=>{var k;let M=f.getStatus(A);M.type===\"initialized\"&&M.value.synchronizeInventory((k=_.buffered[A])!=null?k:[])})}),((x=u.getPeriodForTime(h))!=null?x:u.getNextPeriod(h))===void 0){let _=new j(\"MEDIA_STARTING_TIME_NOT_FOUND\",\"Wanted starting time not found in the Manifest.\");Q({type:\"error\",contentId:s,value:we(_)});return}let E=new gn(t,s,Q,i.signal),R=ha(u,l,E,f,{onWarning:_=>Q({type:\"warning\",contentId:s,value:we(_)}),onPeriodChanged:_=>{Q({type:\"active-period-changed\",contentId:s,value:{periodId:_.id}})}},i.signal);_s({initialPeriod:u.periods[0],manifest:u},E,d,f,m,{wantedBufferAhead:Na,maxVideoBufferSize:Ba,maxBufferAhead:Ua,maxBufferBehind:La,drmSystemId:p,enableFastSwitching:g,onCodecSwitch:I},T(),i.signal);function T(){return{needsBufferFlush(_){Q({type:\"needs-buffer-flush\",contentId:s,value:_})},streamStatusUpdate(_){C(_),u.isLastPeriodKnown&&_.period.id===u.periods[u.periods.length-1].id&&(_.hasFinishedLoading||_.isEmptyStream?R.onLastSegmentFinishedLoading(_.bufferType):R.onLastSegmentLoadingResume(_.bufferType))},needsManifestRefresh(){e.scheduleManifestRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync(){let{OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:_}=U.getCurrent();e.scheduleManifestRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:_})},lockedStream(_){Q({type:\"locked-stream\",contentId:s,value:{periodId:_.period.id,bufferType:_.bufferType}})},adaptationChange(_){var A,M;R.onAdaptationChange(_.type,_.period,_.adaptation),!i.signal.isCancelled()&&Q({type:\"adaptation-changed\",contentId:s,value:{adaptationId:(M=(A=_.adaptation)==null?void 0:A.id)!=null?M:null,periodId:_.period.id,type:_.type}})},representationChange(_){var A,M;R.onRepresentationChange(_.type,_.period),!i.signal.isCancelled()&&Q({type:\"representation-changed\",contentId:s,value:{adaptationId:_.adaptation.id,representationId:(M=(A=_.representation)==null?void 0:A.id)!=null?M:null,periodId:_.period.id,type:_.type}})},inbandEvent(_){Q({type:\"inband-event\",contentId:s,value:_})},warning(_){Q({type:\"warning\",contentId:s,value:we(_)})},periodStreamReady(_){o!==null&&(o.trackChoiceSetter.addTrackSetter(_.period.id,_.type,_.adaptationRef),Q({type:\"period-stream-ready\",contentId:s,value:{periodId:_.period.id,bufferType:_.type}}))},periodStreamCleared(_){if(o===null)return;let A=a.get(_.period);A!==void 0&&(A.delete(_.type),A.size===0&&a.delete(_.period)),o.trackChoiceSetter.removeTrackSetter(_.period.id,_.type),Q({type:\"period-stream-cleared\",contentId:s,value:{periodId:_.period.id,bufferType:_.type}})},bitrateEstimateChange(_){Q({type:\"bitrate-estimate-change\",contentId:s,value:{bitrate:_.bitrate,bufferType:_.type}})},needsMediaSourceReload(_){P(_)},needsDecipherabilityFlush(){Q({type:\"needs-decipherability-flush\",contentId:s,value:null})},encryptionDataEncountered(_){for(let A of _){let M=A.content,k=_e({},M);k.manifest instanceof wt&&(k.manifest=k.manifest.getMetadataSnapshot()),k.period instanceof dt&&(k.period=k.period.getMetadataSnapshot()),k.adaptation instanceof st&&(k.adaptation=k.adaptation.getMetadataSnapshot()),k.representation instanceof Zt&&(k.representation=k.representation.getMetadataSnapshot()),Q({type:\"encryption-data-encountered\",contentId:s,value:{keyIds:A.keyIds,values:A.values,content:k,type:A.type}})}},error(_){Q({type:\"error\",contentId:s,value:we(_)})}}}function C(_){let{imminentDiscontinuity:A}=_,M=a.get(_.period),k=M==null?void 0:M.get(_.bufferType);if(k!==void 0){if(k.discontinuity===null){if(A===null)return}else if(A!==null&&k.discontinuity.start===A.start&&k.discontinuity.end===A.end)return}M===void 0&&(M=new Map,a.set(_.period,M));let D={periodId:_.period.id,bufferType:_.bufferType,discontinuity:_.imminentDiscontinuity,position:_.position};M.set(_.bufferType,D),Q({type:\"discontinuity-update\",contentId:s,value:D})}function P(_){let M=t.getValue().position.getWanted();i!==null&&i.cancel(),e.reloadMediaSource(_).then(()=>{Vs({initialTime:M,drmSystemId:n.drmSystemId,enableFastSwitching:n.enableFastSwitching,onCodecSwitch:n.onCodecSwitch},e,t,r)},k=>{Q({type:\"error\",contentId:s,value:we(k)})})}}function Ws(n,e){e?c.setLevel(n,(t,r)=>{let i=r.map(a=>a instanceof Error?we(a):a);postMessage({type:\"log\",value:{logLevel:t,logs:i}})}):c.setLevel(n)}var qs=Fa;qs();})();\n" + "})()"], { type: "application/javascript" });
|
|
5
5
|
exports.EMBEDDED_WORKER = blob;
|
|
6
6
|
exports.default = blob;
|