UNPKG

rx-player

Version:
1 lines 564 kB
"use strict";(()=>{var Bp=Object.defineProperty,Fp=Object.defineProperties;var Kp=Object.getOwnPropertyDescriptors;var Ql=Object.getOwnPropertySymbols;var Vp=Object.prototype.hasOwnProperty,zp=Object.prototype.propertyIsEnumerable;var $l=(n,e,t)=>e in n?Bp(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ae=(n,e)=>{for(var t in e||(e={}))Vp.call(e,t)&&$l(n,t,e[t]);if(Ql)for(var t of Ql(e))zp.call(e,t)&&$l(n,t,e[t]);return n},ue=(n,e)=>Fp(n,Kp(e));var y={PRODUCTION:0,DEV:1,CURRENT_ENV:0};var S={CURRENT_LEVEL:"NONE"};function E(n){return n==null}var se=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(E(e)){this._listeners={};return}let r=this._listeners[e];if(!Array.isArray(r))return;if(E(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(o){if(y.CURRENT_ENV===y.DEV)throw o instanceof Error?o:new Error("EventEmitter: listener error");console.error("RxPlayer: EventEmitter error",o instanceof Error?o:null)}})}};var Vn=typeof WorkerGlobalScope!="undefined"&&self instanceof WorkerGlobalScope;var qp=typeof window=="undefined"&&!Vn,$t=qp;var Eo;Vn?Eo=self:$t?Eo=global:Eo=window;var Z=Eo;var It=typeof queueMicrotask=="function"?queueMicrotask:function(e){Promise.resolve().then(e,()=>e())};function ts(){if(!$t&&!E(Z.WebKitSourceBuffer)&&Z.WebKitSourceBuffer.prototype.addEventListener===void 0){let e=Z.WebKitSourceBuffer.prototype;for(let t in se.prototype)Object.prototype.hasOwnProperty.call(se.prototype,t)&&(e[t]=se.prototype[t]);e._listeners=[],e._emitUpdate=function(t,r){It(()=>{this.trigger(t,r),this.updating=!1,this.trigger("updateend",new Event("updateend"))})},e.appendBuffer=function(t){var r,i;if(this.updating)throw new Error("updating");this.trigger("updatestart",new Event("updatestart")),this.updating=!0;try{this.append(t)}catch(o){(r=this._emitUpdate)==null||r.call(this,"error",o);return}(i=this._emitUpdate)==null||i.call(this,"update",new Event("update"))}}}function Ie(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}function te(){}var _o=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){y.CURRENT_ENV===y.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.clearSignal!==void 0&&t.clearSignal.deregister(r),i.hasBeenCleared)return;i.hasBeenCleared=!0;let o=this._listeners.indexOf(i);o>=0&&this._listeners.splice(o,1)},i={trigger:e,complete:r,hasBeenCleared:!1};if(this._listeners.push(i),t.emitCurrentValue===!0&&e(this._value,r),this._isFinished||i.hasBeenCleared){r();return}t.clearSignal.register(r)}waitUntilDefined(e,t){this.onUpdate((r,i)=>{r!==void 0&&(i(),e(this._value))},{clearSignal:t.clearSignal,emitCurrentValue:!0})}_onFinished(e,t){if(t.isCancelled())return te;let r=()=>{let a=Ie(this._onFinishCbs,s=>s.trigger===i);a>=0&&(this._onFinishCbs[a].hasBeenCleared=!0,this._onFinishCbs.splice(a,1))},i=()=>{r(),e()},o=t.register(r);return this._onFinishCbs.push({trigger:i,hasBeenCleared:!1}),o}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 gn(n,e,t){let r=new _o(e(n.getValue()),t);return n.onUpdate(function(o){r.setValue(e(o))},{clearSignal:t}),n._onFinished(()=>{r.finish()},t),r}var j=_o;var Xl=new j(0);var Gp=typeof performance!="undefined"?()=>performance.now()+Xl.getValue():()=>Date.now()+Xl.getValue(),z=Gp;var jp="NONE",br=class extends se{constructor(){super(),this.error=te,this.warn=te,this.info=te,this.debug=te,this._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},this._currentFormat="standard",this._currentLevel=jp}setLevel(e,t,r){let i,o=this._levels[e];typeof o=="number"?(i=o,this._currentLevel=e):(i=0,this._currentLevel="NONE");let a;if(t==="standard"||t==="full"?a=t:a="standard",a==="full"&&a!==this._currentFormat){let d=z();console.log(String(d.toFixed(2)),"[Init]",`Local-Date: ${Date.now()}`)}this._currentFormat=a;let s=this._currentFormat==="full"?(d,u)=>(c,...l)=>{let f=z();return u(String(f.toFixed(2)),`[${d}]`,c+":",...l.map(p=>typeof p=="object"&&p!==null&&!(p instanceof Error)?Zl(p):p))}:(d,u)=>(c,...l)=>u(c+":",...l.map(f=>typeof f=="object"&&f!==null&&!(f instanceof Error)?Zl(f):f));if(r===void 0)this.error=i>=this._levels.ERROR?s("error",console.error.bind(console)):te,this.warn=i>=this._levels.WARNING?s("warn",console.warn.bind(console)):te,this.info=i>=this._levels.INFO?s("info",console.info.bind(console)):te,this.debug=i>=this._levels.DEBUG?s("log",console.log.bind(console)):te;else{let d=u=>i>=this._levels[u]?(c,...l)=>r(u,c,l):te;this.error=d("ERROR"),this.warn=d("WARNING"),this.info=d("INFO"),this.debug=d("DEBUG")}this.trigger("onLogLevelChange",{level:this._currentLevel,format:this._currentFormat})}getLevel(){return this._currentLevel}getFormat(){return this._currentFormat}hasLevel(e){return this._levels[e]>=this._levels[this._currentLevel]}};function Zl(n){let e="";for(let t in n)if(Object.prototype.hasOwnProperty.call(n,t)){e.length>0&&(e+=" ");let r=n[t];r instanceof Error?e+=`${t}="${JSON.stringify(r==null?void 0:r.toString())}"`:e+=`${t}=${typeof r=="string"?`${JSON.stringify(r)}`:String(r)}`}return e}var Yp=new br,m=Yp;var Be=Z,Jl,ec,tc,nc,rc,wt=(rc=(nc=(tc=(ec=(Jl=Be==null?void 0:Be.MediaSource)!=null?Jl:Be==null?void 0:Be.MozMediaSource)!=null?ec:Be==null?void 0:Be.WebKitMediaSource)!=null?tc:Be==null?void 0:Be.MSMediaSource)!=null?nc:Be==null?void 0:Be.ManagedMediaSource)!=null?rc:void 0,ic=wt!==void 0&&wt===(Be==null?void 0:Be.ManagedMediaSource);var Qp=200,vo=new Map;function ns(n,e){if(n.isDummy)return n.FORCED_MEDIA_SOURCE.isTypeSupported(e);if(E(wt))return Vn&&m.error("mse","Cannot request codec support in a worker without MSE."),!1;if(typeof wt.isTypeSupported=="function"){let t=vo.get(e);if(t!==void 0)return t;{let r=wt.isTypeSupported(e);return vo.size>=Qp&&vo.clear(),vo.set(e,r),r}}return!0}var oc={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_AUDIO_TRACKS_NOT_PLAYABLE_BEHAVIOR:"error",DEFAULT_VIDEO_TRACKS_NOT_PLAYABLE_BEHAVIOR:"error",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,FREEZING_FLUSH_FAILURE_DELAY:{MAXIMUM:2e4,MINIMUM:4e3,POSITION_DELTA:1},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/mp4;codecs="hvc1.1.6.L93.B0"','video/webm;codecs="vp8"'],EME_DEFAULT_AUDIO_CODECS:['audio/mp4;codecs="mp4a.40.2"','audio/webm;codecs="opus"','audio/mp4;codecs="ec-3"'],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",DEFAULT_MAX_THUMBNAIL_REQUESTS_RETRY_ON_ERROR:1,DEFAULT_THUMBNAIL_REQUEST_TIMEOUT:1e4,DEFAULT_THUMBNAIL_CONNECTION_TIMEOUT:7e3,FORCE_CANNOT_RELY_ON_REQUEST_MEDIA_KEY_SYSTEM_ACCESS:!1,FORCE_CANNOT_REUSE_MEDIA_KEYS:!1,FORCE_HAS_ISSUES_WITH_HIGH_MEDIA_SOURCE_DURATION:!1,FORCE_IS_SEEKING_APPROXIMATE:!1,FORCE_MEDIA_ELEMENT_FAIL_ON_UNDECIPHERABLE_DATA:!1,FORCE_SHOULD_AWAIT_SET_MEDIA_KEYS:!1,FORCE_SHOULD_FAVOUR_CUSTOM_SAFARI_EME:!1,FORCE_SHOULD_RELOAD_MEDIA_SOURCE_ON_DECIPHERABILITY_UPDATE:!1,FORCE_SHOULD_RENEW_MEDIA_KEY_SYSTEM_ACCESS:!1,FORCE_SHOULD_UNSET_MEDIA_KEYS:!1,FORCE_SHOULD_VALIDATE_METADATA:!1,FORCE_DONT_WAIT_FOR_DATA_BEFORE_LOADED:!1,FORCE_WAIT_FOR_HAVE_ENOUGH_DATA:!1},ac=oc;function $p(n,...e){if(n==null)throw new TypeError("Cannot convert undefined or null to object");let t=Object(n);for(let r of e)for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i]);return t}var Y=typeof Object.assign=="function"?Object.assign:$p;function rs(n){return n!=null&&!Array.isArray(n)&&typeof n=="object"}function Sr(n,...e){if(e.length===0)return n;let t=e.shift();if(rs(n)&&rs(t))for(let r in t)if(rs(t[r])){let i=n[r];i===void 0&&(i={},n[r]=i),Sr(i,t[r])}else Y(n,{[r]:t[r]});return Sr(n,...e)}var is=class extends se{constructor(){super(...arguments);this.updated=!1;this._config=ac}update(t){let r=Sr(this._config,t);this._config=r,this.updated=!0,this.trigger("update",t)}getCurrent(){return this._config}},Xp=new is,O=Xp;var Xt={EdgeChromium:0,Firefox:1,Ie11:2,OtherIeOrEdgePreEdgeChromium:3,SafariDesktop:4,SafariMobile:5,Other:6},at={A1KStb40xx:100,Panasonic:101,PhilipsNetTv:102,PlayStation4:103,PlayStation5:104,Tizen:105,WebOs2021:106,WebOs2022:107,WebOsOther:108,Xbox:109,Other:110},Fe={DEVICES:at,BROWSERS:Xt,browser:Xt.Other,device:at.Other,isSamsungBrowser:!1};Zp();function Zp(){var n,e,t;$t||(typeof Z.MSInputMethodContext!="undefined"&&typeof document.documentMode!="undefined"?Fe.browser=Xt.Ie11:navigator.appName==="Microsoft Internet Explorer"||navigator.appName==="Netscape"&&/(Trident|Edge)\//.test(navigator.userAgent)?Fe.browser=Xt.OtherIeOrEdgePreEdgeChromium:navigator.userAgent.toLowerCase().indexOf("edg/")!==-1?Fe.browser=Xt.EdgeChromium:navigator.userAgent.toLowerCase().indexOf("firefox")!==-1?Fe.browser=Xt.Firefox:typeof navigator.platform=="string"&&/iPad|iPhone|iPod/.test(navigator.platform)?Fe.browser=Xt.SafariMobile:(Object.prototype.toString.call(Z.HTMLElement).indexOf("Constructor")>=0||((e=(n=Z.safari)==null?void 0:n.pushNotification)==null?void 0:e.toString())==="[object SafariRemoteNotification]"||/Safari\/(\d+)/.test(navigator.userAgent)&&/Version\/(\d+)/.test(navigator.userAgent)&&((t=navigator.vendor)==null?void 0:t.indexOf("Apple"))!==-1&&!/Chrome\/(\d+)/.test(navigator.userAgent)&&!/Chromium\/(\d+)/.test(navigator.userAgent))&&(Fe.browser=Xt.SafariDesktop),/SamsungBrowser/.test(navigator.userAgent)&&(Fe.isSamsungBrowser=!0),navigator.userAgent.indexOf("PlayStation 4")!==-1?Fe.device=at.PlayStation4:navigator.userAgent.indexOf("PlayStation 5")!==-1?Fe.device=at.PlayStation5:/Tizen/.test(navigator.userAgent)?Fe.device=at.Tizen:/[Ww]eb[O0]S/.test(navigator.userAgent)?/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\/87/.test(navigator.userAgent)?Fe.device=at.WebOs2022:/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\/79/.test(navigator.userAgent)?Fe.device=at.WebOs2021:Fe.device=at.WebOsOther:navigator.userAgent.indexOf("NETTV")!==-1&&navigator.userAgent.indexOf("Philips")!==-1?Fe.device=at.PhilipsNetTv:/[Pp]anasonic/.test(navigator.userAgent)?Fe.device=at.Panasonic:navigator.userAgent.indexOf("Xbox")!==-1?Fe.device=at.Xbox:navigator.userAgent.indexOf("Model/a1-kstb40xx")!==-1&&(Fe.device=at.A1KStb40xx))}var V=Fe;function os(){let{FORCE_MEDIA_ELEMENT_FAIL_ON_UNDECIPHERABLE_DATA:n}=O.getCurrent();return n||V.device===V.DEVICES.PlayStation5}function as(n){let{FORCE_SHOULD_RELOAD_MEDIA_SOURCE_ON_DECIPHERABILITY_UPDATE:e}=O.getCurrent();return e||n===void 0||n.indexOf("widevine")<0}var Jp=.016666666666666666;function sc(n,e){return Math.abs(n-e)<Jp}function uc(n,e){let t=Math.min(n.start,e.start),r=Math.max(n.end,e.end);return{start:t,end:r}}function eg(n){for(let e=0;e<n.length;e++){let t=n[e];t.start===t.end&&n.splice(e--,1)}return n}function tg(n){for(let e=1;e<n.length;e++){let t=n[e-1],r=n[e];if(cc(t,r)){let i=uc(t,r);n.splice(--e,2,i)}}return n}function ss(n,e){return n.end<=e.start}function dc({start:n,end:e},t){return n<=t&&t<e}function lc(n,e){return dc(n,e.start)||n.start<e.end&&e.end<n.end||dc(e,n.start)}function cc(n,e){return sc(e.start,n.end)||sc(e.end,n.start)}function Le(n){let e=[];for(let t=0;t<n.length;t++)e.push({start:n.start(t),end:n.end(t)});return e}function ds(n,e){for(let t=n.length-1;t>=0;t--){let r=n.start(t);if(e>=r){let i=n.end(t);if(e<i)return{start:r,end:i}}}return null}function ng(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 fc(n,e){let t=n.length;for(let r=0;r<t;r++){let i=n.start(r);if(e<i)return i-e}return 1/0}function mc(n,e){let t=null,r=[];for(let i=0;i<n.length;i++){let o=n[i].start,a=n[i].end;e<o||e>=a?r.push({start:o,end:a}):t={start:o,end:a}}return{outerRanges:r,innerRange:t}}function pc(n,e){let t=ds(n,e);return t!==null?t.end-e:1/0}function Ro(n,e){let t=ng(n,e);return t!==null?t.end-e:1/0}function vt(n,e){if(e.start===e.end)return n;let t=e,r=0;for(;r<n.length;r++){let i=n[r],o=lc(t,i),a=cc(t,i);if(o||a)t=uc(t,i),n.splice(r--,1);else if(r===0){if(ss(t,n[0]))break}else if(ss(n[r-1],t)&&ss(t,i))break}return n.splice(r,0,t),tg(eg(n))}function gc(n,e){let t=[];for(let r=0;r<e.length;r++)lc(n,e[r])&&t.push(e[r]);return t}function hc(n,e){let t=[];for(let r=0;r<n.length;r++){let i=n[r],o=gc(i,e);if(o.length>0)for(let a=0;a<o.length;a++){let s=o[a];t.push({start:Math.max(i.start,s.start),end:Math.min(i.end,s.end)})}}return t}function ko(n,e){let t=[];for(let r=0;r<n.length;r++){let i=n[r],o=[],a=gc(i,e);if(a.length>0)for(let s=0;s<a.length;s++){let d=a[s];o.push({start:Math.max(i.start,d.start),end:Math.min(i.end,d.end)})}if(o.length===0)t.push(i);else{let s=i.start;for(let d=0;d<o.length;d++)o[d].start>s&&t.push({start:s,end:o[d].start}),s=o[d].end;s<i.end&&t.push({start:s,end:i.end})}}return t}var Po=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name="AssertionError"}};function ne(n,e){if(y.DEV===y.CURRENT_ENV&&!n)throw new Po(e===void 0?"invalid assertion":e)}function yc(n,e,t="object"){ne(!E(n),`${t} should be an object`);for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&ne(typeof n[r]===e[r],`${t} should have property ${r} as a ${e[r]}`)}function ze(n){throw new Po("Unreachable path taken")}var U=class{constructor(){let[e,t]=rg();this._isUsed=!1,this._trigger=e,this.signal=new Tr(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 we;this._trigger(t)}static isCancellationError(e){return e instanceof we}},Tr=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){m.error("utils","Error while calling clean up listener",r instanceof Error?r:"Unknown Error")}})}isCancelled(){return this._isCancelled}register(e){return this._isCancelled?(ne(this.cancellationError!==null),e(this.cancellationError),te):(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)}},we=class n extends Error{constructor(){super("This task was cancelled."),Object.setPrototypeOf(this,n.prototype),this.name="CancellationError"}};function rg(){let n=te;return[function(t){n(t)},function(t){n=t}]}function us(n){let e=n.map(a=>Math.log(a/n[0])),t=e.map(a=>a-e[0]+1),r=(t[t.length-1]-1)/(n.length*2+10),i=1/r;return n.map((a,s)=>o(s));function o(a){if(a===0)return 0;let s=Math.min(Math.max(1,a),n.length-1);return n[s]===n[s-1]?o(a-1):i*(r+(n[s]*t[s-1]-n[s-1]*t[s])/(n[s]-n[s-1]))+4}}var st=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 Er=class{constructor(){this._currentRepresentationData=null,this._lastRepresentationWithGoodScore=null}addSample(e,t,r){let i=r/t,o=this._currentRepresentationData,a;o!==null&&o.representation.id===e.id?(a=o.ewma,o.ewma.addSample(t,i),o.loadedDuration+=r,o.loadedSegments++):(a=new st(5),a.addSample(t,i),this._currentRepresentationData={representation:e,ewma:a,loadedDuration:r,loadedSegments:0}),a.getEstimate()>1&&this._lastRepresentationWithGoodScore!==e&&(m.debug("ABR","New last stable representation",{bitrate: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,o=t.getEstimate(),a=r>=5&&i>=10?1:0;return{score:o,confidenceLevel:a}}getLastStableRepresentation(){return this._lastRepresentationWithGoodScore}};var Ic=6e3,ig=15e3,og=3e3,ag=1e3,sg=9e3,_r=class{constructor(e){this._levelsMap=us(e).map(t=>t+4),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=Ic,m.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:o,currentScore:a,speed:s}=e;if(E(o)){this._currentEstimate=r[0];return}let d=-1;for(let h=0;h<r.length;h++){let I=r[h];if(I===o)d=h;else if(I>o)break}if(d<0||r.length!==t.length){m.info("ABR","Current Bitrate not found in the calculated levels"),this._currentEstimate=r[0];return}let u;a!==void 0&&(u=s===0?a.score:a.score/s);let c=isFinite(i)?i:0,l=z();if(c<t[d]||u!==void 0&&u<1&&(a==null?void 0:a.confidenceLevel)===1){if((this._lastUnsuitableQualityTimestamp===void 0?-1:l-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+sg){let g=this._blockRaiseDelay+og;m.debug("ABR","Incrementing blocking raise in BufferBasedChooser due to unstable quality",{prevDelay:this._blockRaiseDelay,newDelay:g}),this._blockRaiseDelay=Math.min(g,ig)}else{let g=this._blockRaiseDelay-ag;m.debug("ABR","Lowering quality in BufferBasedChooser",{prevDelay:this._blockRaiseDelay,newDelay:g}),this._blockRaiseDelay=Math.max(Ic,g)}this._lastUnsuitableQualityTimestamp=l;let I=Ie(r,g=>g===o);for(let g=I-1;g>=0;g--)if(c>=t[g]){this._currentEstimate=r[g];return}this._currentEstimate=r[0];return}if(this._lastUnsuitableQualityTimestamp!==void 0&&l-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||u===void 0||u<1.15||(a==null?void 0:a.confidenceLevel)!==1){this._currentEstimate=o;return}let f=t[d],p=(()=>{for(let h=d+1;h<t.length;h++)if(t[h]>f)return h})();if(p!==void 0){let h=t[p];if(i>=h){m.debug("ABR","Raising quality in BufferBasedChooser",{bitrate:r[p]}),this._currentEstimate=r[p];return}}this._currentEstimate=o}getLastEstimate(){return this._currentEstimate}};function Q(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 o=n[i];if(e.call(t,o,i,n))return o}}function dg(n,e){let t=-1;for(let a=0;a<n.length;a++){let{segment:s}=n[a].content;if(s.duration<=0)continue;let d=s.time+s.duration;if(!s.complete&&a===n.length-1&&e-s.time>-1.2){t=a;break}if(d>e&&e-s.time>-1.2){t=a;break}}if(t<0)return[];let r=n[t],i=r.content.segment.time,o=[r];for(let a=t+1;a<n.length&&n[a].content.segment.time===i;a++)o.push(n[a]);return o}function Co(n){if(n.progress.length<5)return;let e=new st(2),{progress:t}=n;for(let r=1;r<t.length;r++){let i=t[r].size-t[r-1].size,o=t[r].timestamp-t[r-1].timestamp,a=i*8/(o/1e3);e.addSample(o/1e3,a)}return e.getEstimate()}function bc(n,e){let t=(n.totalSize-n.size)*8;return Math.max(t/e,0)}function ug(n,e,t,r,i){if(r)return;let{bufferGap:o,speed:a,position:s}=e,d=isFinite(o)?o:0,u=s.getWanted()+d,c=dg(n,u);if(c.length!==1)return;let l=c[0],f=z(),p=l.content.segment.duration*1.5;if(p=Math.min(p,3e3),p=Math.max(p,12e3),f-l.requestTimestamp<p)return;let h=l.progress.length>0?l.progress[l.progress.length-1]:void 0,I=Co(l);if(h!==void 0&&I!==void 0){let R=bc(h,I);if((f-h.timestamp)/1e3<=R&&R-d/a>2500)return I}if(!l.content.segment.complete)return;let g=l.content.segment.duration,b=(f-l.requestTimestamp)/1e3,T=b<=(g*1.5+2)/a;if(E(t)||T)return;let v=g/b,_=t.bitrate*Math.min(.7,v);if(i===void 0||_<i)return _}function lg(n,e,t){if(t)return!0;let r=isFinite(n.bufferGap)?n.bufferGap:0,i=n.position.getWanted()+r,o=Q(e,({content:l})=>l.segment.duration>0&&l.segment.time+l.segment.duration>i);if(o===void 0)return!0;let a=z(),s=o.progress.length>0?o.progress[o.progress.length-1]:void 0,d=Co(o);if(s===void 0||d===void 0)return!0;let u=bc(s,d);return(a-s.timestamp)/1e3>u*1.2?!0:u-r/n.speed>-1.5}var vr=class{constructor(e,t){let{ABR_STARVATION_GAP:r,OUT_OF_STARVATION_GAP:i,ABR_STARVATION_FACTOR:o,ABR_REGULAR_FACTOR:a}=O.getCurrent();this._initialBitrate=e,this._inStarvationMode=!1,this._lowLatencyMode=t,t?this._config={starvationGap:r.LOW_LATENCY,outOfStarvationGap:i.LOW_LATENCY,starvationBitrateFactor:o.LOW_LATENCY,regularBitrateFactor:a.LOW_LATENCY}:this._config={starvationGap:r.DEFAULT,outOfStarvationGap:i.DEFAULT,starvationBitrateFactor:o.DEFAULT,regularBitrateFactor:a.DEFAULT}}getBandwidthEstimate(e,t,r,i,o){let a,s,d=this._config,{bufferGap:u,position:c,duration:l}=e,f=isFinite(u)?u:0,{ABR_STARVATION_DURATION_DELTA:p}=O.getCurrent();return isNaN(l)||f+c.getWanted()<l-p?!this._inStarvationMode&&f<=d.starvationGap?(m.info("ABR","enter starvation mode.",{buffergap:f,enterStarvation:d.starvationGap}),this._inStarvationMode=!0):this._inStarvationMode&&f>=d.outOfStarvationGap&&(m.info("ABR","exit starvation mode.",{bufferGap:f,outOfStarvation:d.starvationGap}),this._inStarvationMode=!1):this._inStarvationMode&&(m.info("ABR","exit starvation mode.",{bufferGap:f}),this._inStarvationMode=!1),this._inStarvationMode&&(s=ug(i,e,r,this._lowLatencyMode,o),s!==void 0&&(m.info("ABR","starvation mode emergency estimate:",{bandwidth:s}),t.reset(),a=E(r)?s:Math.min(s,r.bitrate))),E(a)&&(s=t.getEstimate(),s!==void 0?a=s*(this._inStarvationMode?d.starvationBitrateFactor:d.regularBitrateFactor):o!==void 0?a=o*(this._inStarvationMode?d.starvationBitrateFactor:d.regularBitrateFactor):a=this._initialBitrate),e.speed>1&&(a/=e.speed),{bandwidthEstimate:s,bitrateChosen:a}}isUrgent(e,t,r,i){return t===null?!0:e>=t.bitrate?!1:lg(i,r,this._lowLatencyMode)}};var Rr=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 kr=class{constructor(e,t){this._scoreCalculator=e,this._lastAbrEstimate=t,this._consecutiveWrongGuesses=0,this._blockGuessesUntil=0,this._lastMaintanableBitrate=null}getGuess(e,t,r,i,o){let{bufferGap:a,speed:s}=t,d=this._lastAbrEstimate.representation;if(d===null)return null;if(i>d.bitrate)return this._lastAbrEstimate.algorithmType===2&&(this._lastAbrEstimate.representation!==null&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;let u=this._scoreCalculator.getEstimate(r);if(this._lastAbrEstimate.algorithmType!==2){if(u===void 0)return null;if(this._canGuessHigher(a,s,u)){let l=Sc(e,r);if(l!==null)return l}return null}if(this._isLastGuessValidated(d,i,u)&&(m.debug("ABR","Guessed Representation validated",{chosenBitrate:d.bitrate,otherAbrAlgosBitrate:i,scoreData:u==null?void 0:u.score,scoreConfidence:u==null?void 0:u.confidenceLevel}),this._lastMaintanableBitrate=d.bitrate,this._consecutiveWrongGuesses=0),r.id!==d.id)return d;if(this._shouldStopGuess(r,u,a,o))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=z()+Math.min(this._consecutiveWrongGuesses*15e3,12e4),cg(e,r);if(u===void 0)return r;if(this._canGuessHigher(a,s,u)){let l=Sc(e,r);if(l!==null)return l}return r}_canGuessHigher(e,t,{score:r,confidenceLevel:i}){return isFinite(e)&&e>=2.5&&z()>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 o=i.filter(s=>s.content.representation.id===e.id),a=z();for(let s of o){let d=a-s.requestTimestamp;if(s.content.segment.isInit){if(d>1e3)return!0}else{if(d>s.content.segment.duration*1e3+200)return!0;{let u=Co(s);if(u!==void 0&&u<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 Sc(n,e){let t=n.length,r=Ie(n,({id:i})=>i===e.id);if(r<0)return m.error("ABR","Current Representation not found."),null;for(;++r<t;)if(n[r].bitrate>e.bitrate)return n[r];return null}function cg(n,e){let t=Ie(n,({id:r})=>r===e.id);if(t<0)return m.error("ABR","Current Representation not found."),null;for(;--t>=0;)if(n[t].bitrate<e.bitrate)return n[t];return null}var Pr=class{constructor(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=O.getCurrent();this._fastEWMA=new st(e),this._slowEWMA=new st(t),this._bytesSampled=0}addSample(e,t){let{ABR_MINIMUM_CHUNK_SIZE:r}=O.getCurrent();if(t<r)return;let i=t*8e3/e,o=e/1e3;this._bytesSampled+=t,this._fastEWMA.addSample(o,i),this._slowEWMA.addSample(o,i)}getEstimate(){let{ABR_MINIMUM_TOTAL_BYTES:e}=O.getCurrent();if(!(this._bytesSampled<e))return Math.min(this._fastEWMA.getEstimate(),this._slowEWMA.getEstimate())}reset(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=O.getCurrent();this._fastEWMA=new st(e),this._slowEWMA=new st(t),this._bytesSampled=0}};function ls(n,e){if(n.length===0)return[];n.sort((o,a)=>o.bitrate-a.bitrate);let t=n[0].bitrate,r=Math.max(e,t),i=Ie(n,o=>o.bitrate>r);return i===-1?n:n.slice(0,i)}function cs(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,d)=>{var u,c;return((u=s.width)!=null?u:0)-((c=d.width)!=null?c:0)}),o=Q(i,s=>typeof s.width=="number"&&s.width>=t&&typeof s.height=="number"&&s.height>=r);if(o===void 0)return n;let a=typeof o.width=="number"?o.width:0;return n.filter(s=>typeof s.width=="number"?s.width<=a:!0)}function Cr(n){return Object.keys(n).map(e=>n[e])}var zn=typeof Object.values=="function"?Object.values:Cr;var Ar=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(E(t)){if(y.CURRENT_ENV===y.DEV)throw new Error("ABR: progress for a request not added");m.warn("ABR","progress for a request not added",{requestId:e.id});return}t.progress.push(e)}remove(e){if(E(this._currentRequests[e])){if(y.CURRENT_ENV===y.DEV)throw new Error("ABR: can't remove unknown request");m.warn("ABR","can't remove unknown request",{requestId:e})}delete this._currentRequests[e]}getRequests(){return zn(this._currentRequests).filter(e=>!E(e)).sort((e,t)=>e.content.segment.time-t.content.segment.time)}};function Ao(n,e){let t=Ie(n,r=>r.bitrate>e);return t===-1?n[n.length-1]:t===0?n[0]:n[t-1]}var Tc=new j(void 0);Tc.finish();var Ec=new j(1/0);Ec.finish();function fs(n){let e={},{initialBitrates:t,throttlers:r,lowLatencyMode:i}=n;return function(s,d,u,c,l){var g,b,T;let{type:f}=s.adaptation,p=o(f),h=(g=t[f])!=null?g:0,I={limitResolution:(b=r.limitResolution[f])!=null?b:Tc,throttleBitrate:(T=r.throttleBitrate[f])!=null?T:Ec};return fg({bandwidthEstimator:p,context:s,currentRepresentation:d,filters:I,initialBitrate:h,playbackObserver:c,representations:u,lowLatencyMode:i},l)};function o(a){let s=e[a];if(E(s)){m.debug("ABR","Creating new BandwidthEstimator",{bufferType:a});let d=new Pr;return e[a]=d,d}return s}}function fg({bandwidthEstimator:n,context:e,currentRepresentation:t,filters:r,initialBitrate:i,lowLatencyMode:o,playbackObserver:a,representations:s},d){let u=new Er,c=new vr(i!=null?i:0,o),l=new Ar,f=te,p={metrics:T,requestBegin:v,requestProgress:_,requestEnd:R,addedSegment(k){f(k)}},h=new U;h.linkToSignal(d);let I=g(s.getValue(),h.signal);return s.onUpdate(b,{clearSignal:d}),{estimates:I,callbacks:p};function g(k,x){if(k.length<=1)return new j({bitrate:void 0,representation:k[0],urgent:!0,knownStableBitrate:void 0});let P=!1,M=k.sort((K,q)=>K.bitrate-q.bitrate),L=new _r(M.map(K=>K.bitrate)),F=new Rr,D=new kr(u,F),B=a.getReference().getValue(),A=new j(N());return a.listen(K=>{B=K,C()},{includeLastObservation:!1,clearSignal:x}),f=function(K){if(B===null)return;let{position:q,speed:X}=B,W=K.buffered,H=Ro(W,q.getWanted()),{representation:G}=K.content,ie=u.getEstimate(G),oe=G.bitrate,fe={bufferGap:H,currentBitrate:oe,currentScore:ie,speed:X};L.onAddedSegment(fe),C()},x.register(()=>{f=te}),r.throttleBitrate.onUpdate(C,{clearSignal:x}),r.limitResolution.onUpdate(C,{clearSignal:x}),A;function C(){A.setValue(N())}function N(){let{bufferGap:K,position:q,maximumPosition:X}=B,W=r.limitResolution.getValue(),H=r.throttleBitrate.getValue(),G=t.getValue(),ie=mg(M,W,H),oe=l.getRequests(),{bandwidthEstimate:fe,bitrateChosen:Re}=c.getBandwidthEstimate(B,n,G,oe,F.bandwidth),ge=u.getLastStableRepresentation(),he=ge===null?void 0:ge.bitrate/(B.speed>0?B.speed:1),{ABR_ENTER_BUFFER_BASED_ALGO:_t,ABR_EXIT_BUFFER_BASED_ALGO:ee}=O.getCurrent();P&&K<=ee?P=!1:!P&&isFinite(K)&&K>=_t&&(P=!0);let ye=Ao(ie,Re),ot=L.getLastEstimate(),pn=ye.bitrate,ht=null;P&&ot!==void 0&&ot>pn&&(ht=Ao(ie,ot),pn=ht.bitrate);let yt=null;return o&&G!==null&&e.manifest.isDynamic&&X-q.getWanted()<40&&(yt=D.getGuess(M,B,G,pn,oe)),yt!==null&&yt.bitrate>pn?(m.debug("ABR","new guess-based estimate",{bitrate:yt.bitrate,representation:yt.id}),F.update(yt,fe,2),{bitrate:fe,representation:yt,urgent:G===null||yt.bitrate<G.bitrate,knownStableBitrate:he}):ht!==null?(m.debug("ABR","new buffer-based estimate",{bitrate:ht.bitrate,representation:ht.id}),F.update(ht,fe,0),{bitrate:fe,representation:ht,urgent:c.isUrgent(ht.bitrate,G,oe,B),knownStableBitrate:he}):(m.debug("ABR","new bandwidth estimate",{bitrate:ye.bitrate,representation:ye.id}),F.update(ye,fe,1),{bitrate:fe,representation:ye,urgent:c.isUrgent(ye.bitrate,G,oe,B),knownStableBitrate:he})}}function b(){let k=s.getValue();h.cancel(),h=new U,h.linkToSignal(d),g(k,h.signal).onUpdate(function(M){I.setValue(M)},{clearSignal:h.signal,emitCurrentValue:!0})}function T(k){let{requestDuration:x,segmentDuration:P,size:M,content:L}=k;if(n.addSample(x,M),!L.segment.isInit){let{segment:F,representation:D}=L;if(P===void 0&&!F.complete)return;let B=P!=null?P:F.duration;u.addSample(D,x/1e3,B)}}function v(k){l.add(k)}function _(k){l.addProgress(k)}function R(k){l.remove(k.id)}}function mg(n,e,t){let r=n;return t!==void 0&&t<1/0&&(r=ls(r,t)),e!==void 0&&(r=cs(r,e)),r}var _c=fs;function Mo(){var t;if(typeof((t=Z.crypto)==null?void 0:t.randomUUID)=="function")return Z.crypto.randomUUID();let n=new Date().getTime(),e=z();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){let i=Math.random()*16;return n>0?(i=(n+i)%16|0,n=Math.floor(n/16)):(i=(e+i)%16|0,e=Math.floor(e/16)),(r==="x"?i:i&3|8).toString(16)})}function w(n){return typeof n=="string"&&n.length>0}function Ce(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 pg=/^(?:[a-z]+:)?\/\//i,gg=/^(?:([^:/?#]+):)?(?:\/\/([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?$/;function wr(n){let e=n.lastIndexOf("/");if(e<0)return n.length;if(pg.test(n)){let r=n.indexOf("/");if(r>=0&&e===r+1)return n.length}let t=n.indexOf("?");return t>=0&&t<e?wr(n.substring(0,t)):e+1}function vc(n,e){let t=xo(n),r=xo(e);if(t.scheme!==r.scheme||t.authority!==r.authority||t.path[0]!==void 0&&t.path[0]!=="/"&&r.path[0]==="/"||r.path[0]!==void 0&&r.path[0]!=="/"&&t.path[0]==="/")return null;let i=xr(t.path),o=xr(r.path),a;if(i===o)a="";else{let d=i.split("/");d.pop();let u=o.split("/");for(;d.length>0&&u.length>0&&d[0]===u[0];)d.shift(),u.shift();for(;d.length>0;)d.shift(),u.unshift("..");let c=u.join("/");(c.endsWith("../")||c.endsWith("./"))&&(c=c.slice(0,c.length-1)),a=c===""?".":c}let s=a;return a===""&&r.query===t.query||w(r.query)&&(s+="?",s+=r.query),w(r.fragment)&&(s+="#",s+=r.fragment),s}function hg(n,e){let t=xo(n),r=xo(e);if(w(r.scheme))return ms(r);let i={scheme:t.scheme,authority:t.authority,path:"",query:r.query,fragment:r.fragment};return w(r.authority)?(i.authority=r.authority,i.path=xr(r.path),ms(i)):(r.path===""?(i.path=t.path,w(r.query)||(i.query=t.query)):Ce(r.path,"/")?i.path=xr(r.path):i.path=xr(Ig(t,r.path)),ms(i))}var Mr=new Map,yg=200;function xo(n){var r,i,o,a,s;if(Mr.has(n))return Mr.get(n);let e=n.match(gg),t;return e===null?t={scheme:"",authority:"",path:"",query:"",fragment:""}:t={scheme:(r=e[1])!=null?r:"",authority:(i=e[2])!=null?i:"",path:(o=e[3])!=null?o:"",query:(a=e[4])!=null?a:"",fragment:(s=e[5])!=null?s:""},Mr.size>=yg&&Mr.clear(),Mr.set(n,t),t}function ms(n){let e="";return w(n.scheme)&&(e+=n.scheme+":"),w(n.authority)&&(e+="//"+n.authority),e+=n.path,w(n.query)&&(e+="?"+n.query),w(n.fragment)&&(e+="#"+n.fragment),e}function xr(n){let e=n.split(/(?=\/)/),t=[];for(let r=0;r<e.length;r++){let i=e[r];if(!(i===".."||i==="."||i==="")){if(i==="/.."){t.pop(),r===e.length-1&&t.push("/");continue}if(i==="/."){r===e.length-1&&t.push("/");continue}t.push(i)}}return t.join("")}function Ig(n,e){if(w(n.authority)&&n.path==="")return"/"+e;let t=n.path;return t.substring(0,t.lastIndexOf("/")+1)+e}function hn(...n){var r,i,o;let e=n.filter(a=>a!==""),t=e.length;if(t===0)return"";if(t===1)return(r=e[0])!=null?r:"";{let a=(i=e[0])!=null?i:"",s=(o=e[1])!=null?o:"",d=hg(a,s),u=e.slice(2);return hn(d,...u)}}var bg=4,Or=class{constructor(e){var t,r;this._sessionId=(t=e.sessionId)!=null?t:Mo(),this._contentId=(r=e.contentId)!=null?r:Mo(),this._typePreference=e.communicationType==="headers"?0:1,this._bufferStarvationToggle=!1,this._playbackObserver=null,this._lastThroughput={},this._canceller=null}startMonitoringPlayback(e){var t;(t=this._canceller)==null||t.cancel(),this._canceller=new U,this._playbackObserver=e,e.listen(r=>{r.rebuffering!==null&&(this._bufferStarvationToggle=!0)},{includeLastObservation:!0,clearSignal:this._canceller.signal})}stopMonitoringPlayback(){var e;(e=this._canceller)==null||e.cancel(),this._canceller=null,this._playbackObserver=null}updateThroughput(e,t){this._lastThroughput[e]=t}_getCommonCmcdData(e){var i;let t={};t.bs=this._bufferStarvationToggle,this._bufferStarvationToggle=!1,t.cid=this._contentId,t.mtp=e!==void 0?Math.floor(Math.round(e/1e3/100)*100):void 0,t.sid=this._sessionId;let r=(i=this._playbackObserver)==null?void 0:i.getReference().getValue();return t.pr=r===void 0||r.speed===1?void 0:r.speed,r!==void 0&&(t.su=r.rebuffering!==null),t}getCmcdDataForManifest(e){var r;let t=this._getCommonCmcdData((r=this._lastThroughput.video)!=null?r:this._lastThroughput.audio);switch(t.ot="m",e){case"dash":t.sf="d";break;case"smooth":t.sf="s";break;default:t.sf="o";break}return this._producePayload(t)}getCmcdDataForSegmentRequest(e){var a,s,d,u;let t=(a=this._playbackObserver)==null?void 0:a.getReference().getValue(),r=this._getCommonCmcdData(this._lastThroughput[e.adaptation.type]);switch(r.br=Math.round(e.representation.bitrate/1e3),r.d=Math.round(e.segment.duration*1e3),e.adaptation.type){case"video":r.ot="v";break;case"audio":r.ot="a";break;case"text":r.ot="c";break}if(e.segment.isInit&&(r.ot="i"),!E(e.nextSegment)&&e.segment.url!==null&&e.nextSegment.url!==null&&(!e.nextSegment.isInit||e.nextSegment.indexRange===void 0)){let c=e.segment.url,l=e.nextSegment.url,f=vc(c,l);f!==null&&(f!=="."&&(r.nor=encodeURIComponent(f)),e.nextSegment.range!==void 0&&(r.nrr=String(e.nextSegment.range[0])+"-",isFinite(e.nextSegment.range[1])&&(r.nrr+=String(e.nextSegment.range[1]))))}let i;if(t!==void 0&&(r.ot==="v"||r.ot==="a"||r.ot==="av")){let c=t.buffered[e.adaptation.type];if(!E(c)){let l=(u=(d=(s=this._playbackObserver)==null?void 0:s.getCurrentTime())!=null?d:t.position.getWanted())!=null?u:t.position.getPolled();for(let f of c)if(l>=f.start&&l<f.end){i=(f.end-l)*1e3,r.bl=Math.floor(Math.round(i/100)*100);break}}}let o=i===void 0||t===void 0?void 0:i/t.speed;if(r.dl=o===void 0?void 0:Math.floor(Math.round(o/100)*100),o!==void 0){let l=e.representation.bitrate*e.segment.duration/1e3/(o/1e3);r.rtp=Math.floor(Math.round(l*bg/100)*100)}switch(e.manifest.transport){case"dash":r.sf="d";break;case"smooth":r.sf="s";break;default:r.sf="o";break}return r.st=e.manifest.isDynamic?"l":"v",r.tb=e.adaptation.representations.reduce((c,l)=>l.isPlayable()!==!0?c:c===void 0?Math.round(l.bitrate/1e3):Math.max(c,Math.round(l.bitrate/1e3)),void 0),this._producePayload(r)}_producePayload(e){let t={object:"",request:"",session:"",status:""},r="",i=(u,c)=>{this._typePreference===0?t[c]+=u:r+=u},o=(u,c)=>{let l=e[u];if(l!==void 0){let f=`${u}=${String(l)},`;i(f,c)}},a=(u,c)=>{if(e[u]===!0){let l=`${u},`;i(l,c)}},s=(u,c)=>{let l=e[u];if(l!==void 0){let p=`prop=${`"${l.replace("\\","\\\\").replace('"','\\"')}"`},`;i(p,c)}},d=(u,c)=>{let l=e[u];if(l!==void 0){let f=`prop=${l},`;i(f,c)}};return o("bl","request"),o("br","object"),a("bs","status"),s("cid","session"),o("d","object"),o("dl","request"),o("mtp","request"),s("nor","request"),s("nrr","request"),d("ot","object"),o("pr","session"),o("rtp","status"),d("sf","session"),s("sid","session"),d("st","session"),a("su","request"),o("tb","object"),this._typePreference===0?(t.object[t.object.length-1]===","&&(t.object=t.object.substring(0,t.object.length-1)),t.request[t.request.length-1]===","&&(t.request=t.request.substring(0,t.request.length-1)),t.session[t.session.length-1]===","&&(t.session=t.session.substring(0,t.session.length-1)),t.status[t.status.length-1]===","&&(t.status=t.status.substring(0,t.status.length-1)),m.debug("CMCD","proposing headers payload"),{type:"headers",value:{"CMCD-Object":t.object,"CMCD-Request":t.request,"CMCD-Session":t.session,"CMCD-Status":t.status}}):(r[r.length-1]===","&&(r=r.substring(0,r.length-1)),r=encodeURIComponent(r),m.debug("CMCD","proposing query string payload",{queryString:r}),{type:"query",value:[["CMCD",r]]})}};var Rc=Or;var Wn=class extends se{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=kc(this._downgradedCdnList.metadata,e);t>=0&&this._removeIndexFromDowngradeList(t);let{DEFAULT_CDN_DOWNGRADE_TIME:r}=O.getCurrent(),i=r;this._downgradedCdnList.metadata.push(e);let o=setTimeout(()=>{let a=kc(this._downgradedCdnList.metadata,e);a>=0&&this._removeIndexFromDowngradeList(a),this.trigger("priorityChange",null)},i);this._downgradedCdnList.timeouts.push(o),this.trigger("priorityChange",null)}_innerGetCdnPreferenceForResource(e){let[t,r]=e.reduce((i,o)=>(this._downgradedCdnList.metadata.some(a=>a.id===o.id&&a.baseUrl===o.baseUrl)?i[1].push(o):i[0].push(o),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 kc(n,e){return n.length===0?-1:e.id!==void 0?Ie(n,t=>t.id===e.id):Ie(n,t=>t.baseUrl===e.baseUrl)}var dt=class n extends Error{constructor(e,t,r){super(e),Object.setPrototypeOf(this,n.prototype),this.name="CustomLoaderError",this.canRetry=t,this.xhr=r}};var Ae=class n extends Error{constructor(e,t,r){let i;switch(r){case"TIMEOUT":i="The request timed out";break;case"ERROR_EVENT":i="An error prevented the request to be performed successfully";break;case"PARSE_ERROR":i="An error happened while formatting the response data";break;case"ERROR_HTTP_CODE":i="An HTTP status code indicating failure was received: "+String(t);break}super(i),Object.setPrototypeOf(this,n.prototype),this.name="RequestError",this.url=e,this.status=t,this.type=r}serialize(){return{url:this.url,status:this.status,type:this.type}}},He={TIMEOUT:"TIMEOUT",ERROR_EVENT:"ERROR_EVENT",ERROR_HTTP_CODE:"ERROR_HTTP_CODE",PARSE_ERROR:"PARSE_ERROR"};var ps=typeof Headers=="function"?Headers:null,wo=typeof AbortController=="function"?AbortController:null;function Oo(n){var f,p;let e;if(!E(n.headers))if(E(ps))e=n.headers;else{e=new ps;let h=Object.keys(n.headers);for(let I=0;I<h.length;I++){let g=h[I];e.append(g,n.headers[g])}}m.debug("utils","Fetch",{url:n.url});let t=null,r=!1,i=!1,o=z(),a=E(wo)?null:new wo;function s(){if(E(a)){m.warn("utils","Fetch: AbortController API not available.");return}a.abort()}let d;n.timeout!==void 0&&(d=setTimeout(()=>{r=!0,u!==void 0&&clearTimeout(u),s()},n.timeout));let u;n.connectionTimeout!==void 0&&(u=setTimeout(()=>{i=!0,d!==void 0&&clearTimeout(d),s()},n.connectionTimeout));let c=n.cancelSignal.register(function(I){t=I,s()}),l={method:"GET"};if(e!==void 0&&(l.headers=e),l.signal=E(a)?null:a.signal,m.hasLevel("DEBUG")){let h="fetch GET "+n.url;n.timeout!==void 0&&(h+=" to="+String(n.timeout/1e3)),n.connectionTimeout!==void 0&&(h+=" cto="+String(n.connectionTimeout/1e3)),((f=n.headers)==null?void 0:f.Range)!==void 0&&(h+=" Range="+((p=n.headers)==null?void 0:p.Range)),m.debug("utils",h)}return fetch(n.url,l).then(h=>{if(u!==void 0&&clearTimeout(u),h.status>=300)throw m.warn("utils","Fetch: Request HTTP Error",{status:h.status,responseUrl:h.url}),new Ae(h.url,h.status,He.ERROR_HTTP_CODE);if(E(h.body))throw new Ae(h.url,h.status,He.PARSE_ERROR);let I=h.headers.get("Content-Length"),g=!E(I)&&!isNaN(+I)?+I:void 0,b=h.body.getReader(),T=0;return v();async function v(){let _=await b.read();if(!_.done&&!E(_.value)){T+=_.value.byteLength;let R=z(),k={url:h.url,currentTime:R,duration:R-o,sendingTime:o,chunkSize:_.value.byteLength,chunk:_.value.buffer,size:T,totalSize:g};return n.onData(k),v()}else if(_.done){d!==void 0&&clearTimeout(d),c();let R=z();return{requestDuration:R-o,receivedTime:R,sendingTime:o,size:T,status:h.status,url:h.url}}return v()}}).catch(h=>{throw t!==null?t:(c(),r?(m.warn("utils","Fetch: Request timed out.",{url:n.url,timeout:n.timeout}),new Ae(n.url,0,He.TIMEOUT)):i?(m.warn("utils","Fetch: Request connection timed out.",{url:n.url,connectionTimeout:n.connectionTimeout}),new Ae(n.url,0,He.TIMEOUT)):h instanceof Ae?h:(m.warn("utils","Fetch: Request Error",{error:h instanceof Error?h.toString():"Unkwown Error"}),new Ae(n.url,0,He.ERROR_EVENT)))})}function Dr(){let n=/\[\s*native\s+code\s*\]/;return typeof Z.fetch=="function"&&!E(wo)&&n.test(wo.toString())&&!E(ps)}var Sg="json";function Lr(n){let e={url:n.url,headers:n.headers,responseType:E(n.responseType)?Sg:n.responseType,timeout:n.timeout,connectionTimeout:n.connectionTimeout};return new Promise((t,r)=>{let{onProgress:i,cancelSignal:o}=n,{url:a,headers:s,responseType:d,timeout:u,connectionTimeout:c}=e,l=new XMLHttpRequest;l.open("GET",a,!0);let f;u!==void 0&&(l.timeout=u,f=setTimeout(()=>{g(),r(new Ae(a,l.status,He.TIMEOUT))},u+3e3));let p;if(c!==void 0&&(p=setTimeout(()=>{g(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(new Ae(a,l.status,He.TIMEOUT))},c)),l.responseType=d,l.responseType==="document"&&l.overrideMimeType("text/xml"),!E(s)){let b=s;for(let T in b)Object.prototype.hasOwnProperty.call(b,T)&&l.setRequestHeader(T,b[T])}let h=z(),I=null;if(o!==void 0&&(I=o.register(function(T){g(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(T)}),o.isCancelled()))return;if(l.onerror=function(){g(),r(new Ae(a,l.status,He.ERROR_EVENT))},l.ontimeout=function(){g(),r(new Ae(a,l.status,He.TIMEOUT))},c!==void 0&&(l.onreadystatechange=function(){l.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(p)}),i!==void 0&&(l.onprogress=function(T){let v=z();i({url:a,duration:v-h,sendingTime:h,currentTime:v,size:T.loaded,totalSize:T.total})}),l.onload=function(T){if(l.readyState===XMLHttpRequest.DONE)if(g(),l.status>=200&&l.status<300){let v=z(),_=l.response instanceof ArrayBuffer?l.response.byteLength:T.total,R=l.status,k=l.responseType,x=w(l.responseURL)?l.responseURL:a,P;if(k==="json"?P=typeof l.response=="object"?l.response:Tg(l.responseText):P=l.response,E(P)){r(new Ae(a,l.status,He.PARSE_ERROR));return}t({status:R,url:x,responseType:k,sendingTime:h,receivedTime:v,requestDuration:v-h,size:_,responseData:P})}else r(new Ae(a,l.status,He.ERROR_HTTP_CODE))},m.hasLevel("DEBUG")){let b="XHR GET "+a;n.responseType!==void 0&&(b+=" type="+n.responseType),u!==void 0&&(b+=" to="+String(u/1e3)),c!==void 0&&(b+=" cto="+String(c/1e3)),(s==null?void 0:s.Range)!==void 0&&(b+=" Range="+(s==null?void 0:s.Range)),m.debug("utils",b)}l.send();function g(){f!==void 0&&clearTimeout(f),p!==void 0&&clearTimeout(p),I!==null&&I()}})}function Tg(n){try{return JSON.parse(n)}catch(e){return null}}var ke=Lr;var yn=He,tt={NETWORK_ERROR:"NETWORK_ERROR",MEDIA_ERROR:"MEDIA_ERROR",ENCRYPTED_MEDIA_ERROR:"ENCRYPTED_MEDIA_ERROR",OTHER_ERROR:"OTHER_ERROR"},gs={PIPELINE_LOAD_ERROR:"PIPELINE_LOAD_ERROR",PIPELINE_PARSE_ERROR:"PIPELINE_PARSE_ERROR",INTEGRITY_ERROR:"INTEGRITY_ERROR",MANIFEST_PARSE_ERROR:"MANIFEST_PARSE_ERROR",MANIFEST_INCOMPATIBLE_CODECS_ERROR:"MANIFEST_INCOMPATIBLE_CODECS_ERROR",MANIFEST_UPDATE_ERROR:"MANIFEST_UPDATE_ERROR",MANIFEST_UNSUPPORTED_ADAPTATION_TYPE:"MANIFEST_UNSUPPORTED_ADAPTATION_TYPE",MEDIA_STARTING_TIME_NOT_FOUND:"MEDIA_STARTING_TIME_NOT_FOUND",MEDIA_TIME_BEFORE_MANIFEST:"MEDIA_TIME_BEFORE_MANIFEST",MEDIA_TIME_AFTER_MANIFEST:"MEDIA_TIME_AFTER_MANIFEST",MEDIA_TIME_NOT_FOUND:"MEDIA_TIME_NOT_FOUND",NO_PLAYABLE_REPRESENTATION:"NO_PLAYABLE_REPRESENTATION",MEDIA_IS_ENCRYPTED_ERROR:"MEDIA_IS_ENCRYPTED_ERROR",CREATE_MEDIA_KEYS_ERROR:"CREATE_MEDIA_KEYS_ERROR",MEDIA_KEYS_ATTACHMENT_ERROR:"MEDIA_KEYS_ATTACHMENT_ERROR",KEY_ERROR:"KEY_ERROR",KEY_STATUS_CHANGE_ERROR:"KEY_STATUS_CHANGE_ERROR",KEY_UPDATE_ERROR:"KEY_UPDATE_ERROR",KEY_LOAD_ERROR:"KEY_LOAD_ERROR",KEY_LOAD_TIMEOUT:"KEY_LOAD_TIMEOUT",KEY_GENERATE_REQUEST_ERROR:"KEY_GENERATE_REQUEST_ERROR",INCOMPATIBLE_KEYSYSTEMS:"INCOMPATIBLE_KEYSYSTEMS",INVALID_ENCRYPTED_EVENT:"INVALID_ENCRYPTED_EVENT",INVALID_KEY_SYSTEM:"INVALID_KEY_SYSTEM",LICENSE_SERVER_CERTIFICATE_ERROR:"LICENSE_SERVER_CERTIFICATE_ERROR",MULTIPLE_SESSIONS_SAME_INIT_DATA:"MULTIPLE_SESSIONS_SAME_INIT_DATA",BUFFER_APPEND_ERROR:"BUFFER_APPEND_ERROR",BUFFER_FULL_ERROR:"BUFFER_FULL_ERROR",BUFFER_TYPE_UNKNOWN:"BUFFER_TYPE_UNKNOWN