hls.js
Version:
JavaScript HLS client using MediaSourceExtension
1 lines • 103 kB
JavaScript
!function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t,r={exports:{}};var a=(t||(t=1,function(e){var t=Object.prototype.hasOwnProperty,r="~";function a(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function n(e,t,a,n,s){if("function"!=typeof a)throw new TypeError("The listener must be a function");var o=new i(a,n||e,s),u=r?r+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],o]:e._events[u].push(o):(e._events[u]=o,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new a:delete e._events[t]}function o(){this._events=new a,this._eventsCount=0}Object.create&&(a.prototype=Object.create(null),(new a).__proto__||(r=!1)),o.prototype.eventNames=function(){var e,a,i=[];if(0===this._eventsCount)return i;for(a in e=this._events)t.call(e,a)&&i.push(r?a.slice(1):a);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},o.prototype.listeners=function(e){var t=r?r+e:e,a=this._events[t];if(!a)return[];if(a.fn)return[a.fn];for(var i=0,n=a.length,s=new Array(n);i<n;i++)s[i]=a[i].fn;return s},o.prototype.listenerCount=function(e){var t=r?r+e:e,a=this._events[t];return a?a.fn?1:a.length:0},o.prototype.emit=function(e,t,a,i,n,s){var o=r?r+e:e;if(!this._events[o])return!1;var u,d,c=this._events[o],l=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,a),!0;case 4:return c.fn.call(c.context,t,a,i),!0;case 5:return c.fn.call(c.context,t,a,i,n),!0;case 6:return c.fn.call(c.context,t,a,i,n,s),!0}for(d=1,u=new Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var h,f=c.length;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,a);break;case 4:c[d].fn.call(c[d].context,t,a,i);break;default:if(!u)for(h=1,u=new Array(l-1);h<l;h++)u[h-1]=arguments[h];c[d].fn.apply(c[d].context,u)}}return!0},o.prototype.on=function(e,t,r){return n(this,e,t,r,!1)},o.prototype.once=function(e,t,r){return n(this,e,t,r,!0)},o.prototype.removeListener=function(e,t,a,i){var n=r?r+e:e;if(!this._events[n])return this;if(!t)return s(this,n),this;var o=this._events[n];if(o.fn)o.fn!==t||i&&!o.once||a&&o.context!==a||s(this,n);else{for(var u=0,d=[],c=o.length;u<c;u++)(o[u].fn!==t||i&&!o[u].once||a&&o[u].context!==a)&&d.push(o[u]);d.length?this._events[n]=1===d.length?d[0]:d:s(this,n)}return this},o.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new a,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=r,o.EventEmitter=o,e.exports=o}(r)),r.exports),i=e(a);function n(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,t);if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)({}).hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},s.apply(null,arguments)}function o(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,c(e,t)}function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,a)}return r}function d(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){n(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function c(e,t){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},c(e,t)}function l(e,t){return t+10<=e.length&&51===e[t]&&68===e[t+1]&&73===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function h(e,t){return t+10<=e.length&&73===e[t]&&68===e[t+1]&&51===e[t+2]&&e[t+3]<255&&e[t+4]<255&&e[t+6]<128&&e[t+7]<128&&e[t+8]<128&&e[t+9]<128}function f(e,t){var r=0;return r=(127&e[t])<<21,r|=(127&e[t+1])<<14,r|=(127&e[t+2])<<7,r|=127&e[t+3]}function p(e,t){for(var r=t,a=0;h(e,t);){a+=10,a+=f(e,t+6),l(e,t+10)&&(a+=10),t+=a}if(a>0)return e.subarray(r,r+a)}var m=function(e){return e.NETWORK_ERROR="networkError",e.MEDIA_ERROR="mediaError",e.KEY_SYSTEM_ERROR="keySystemError",e.MUX_ERROR="muxError",e.OTHER_ERROR="otherError",e}({}),v=function(e){return e.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",e.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",e.KEY_SYSTEM_NO_SESSION="keySystemNoSession",e.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",e.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",e.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",e.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",e.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",e.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",e.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",e.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",e.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",e.MANIFEST_LOAD_ERROR="manifestLoadError",e.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",e.MANIFEST_PARSING_ERROR="manifestParsingError",e.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",e.LEVEL_EMPTY_ERROR="levelEmptyError",e.LEVEL_LOAD_ERROR="levelLoadError",e.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",e.LEVEL_PARSING_ERROR="levelParsingError",e.LEVEL_SWITCH_ERROR="levelSwitchError",e.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",e.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",e.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",e.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",e.FRAG_LOAD_ERROR="fragLoadError",e.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",e.FRAG_DECRYPT_ERROR="fragDecryptError",e.FRAG_PARSING_ERROR="fragParsingError",e.FRAG_GAP="fragGap",e.REMUX_ALLOC_ERROR="remuxAllocError",e.KEY_LOAD_ERROR="keyLoadError",e.KEY_LOAD_TIMEOUT="keyLoadTimeOut",e.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",e.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",e.BUFFER_APPEND_ERROR="bufferAppendError",e.BUFFER_APPENDING_ERROR="bufferAppendingError",e.BUFFER_STALLED_ERROR="bufferStalledError",e.BUFFER_FULL_ERROR="bufferFullError",e.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",e.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",e.ASSET_LIST_LOAD_ERROR="assetListLoadError",e.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",e.ASSET_LIST_PARSING_ERROR="assetListParsingError",e.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",e.INTERNAL_EXCEPTION="internalException",e.INTERNAL_ABORTED="aborted",e.ATTACH_MEDIA_ERROR="attachMediaError",e.UNKNOWN="unknown",e}({}),y=function(e){return e.MEDIA_ATTACHING="hlsMediaAttaching",e.MEDIA_ATTACHED="hlsMediaAttached",e.MEDIA_DETACHING="hlsMediaDetaching",e.MEDIA_DETACHED="hlsMediaDetached",e.MEDIA_ENDED="hlsMediaEnded",e.STALL_RESOLVED="hlsStallResolved",e.BUFFER_RESET="hlsBufferReset",e.BUFFER_CODECS="hlsBufferCodecs",e.BUFFER_CREATED="hlsBufferCreated",e.BUFFER_APPENDING="hlsBufferAppending",e.BUFFER_APPENDED="hlsBufferAppended",e.BUFFER_EOS="hlsBufferEos",e.BUFFERED_TO_END="hlsBufferedToEnd",e.BUFFER_FLUSHING="hlsBufferFlushing",e.BUFFER_FLUSHED="hlsBufferFlushed",e.MANIFEST_LOADING="hlsManifestLoading",e.MANIFEST_LOADED="hlsManifestLoaded",e.MANIFEST_PARSED="hlsManifestParsed",e.LEVEL_SWITCHING="hlsLevelSwitching",e.LEVEL_SWITCHED="hlsLevelSwitched",e.LEVEL_LOADING="hlsLevelLoading",e.LEVEL_LOADED="hlsLevelLoaded",e.LEVEL_UPDATED="hlsLevelUpdated",e.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",e.LEVELS_UPDATED="hlsLevelsUpdated",e.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",e.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",e.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",e.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",e.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",e.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",e.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",e.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",e.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",e.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",e.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",e.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",e.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",e.CUES_PARSED="hlsCuesParsed",e.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",e.INIT_PTS_FOUND="hlsInitPtsFound",e.FRAG_LOADING="hlsFragLoading",e.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",e.FRAG_LOADED="hlsFragLoaded",e.FRAG_DECRYPTED="hlsFragDecrypted",e.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",e.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",e.FRAG_PARSING_METADATA="hlsFragParsingMetadata",e.FRAG_PARSED="hlsFragParsed",e.FRAG_BUFFERED="hlsFragBuffered",e.FRAG_CHANGED="hlsFragChanged",e.FPS_DROP="hlsFpsDrop",e.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",e.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",e.ERROR="hlsError",e.DESTROYING="hlsDestroying",e.KEY_LOADING="hlsKeyLoading",e.KEY_LOADED="hlsKeyLoaded",e.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",e.BACK_BUFFER_REACHED="hlsBackBufferReached",e.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",e.ASSET_LIST_LOADING="hlsAssetListLoading",e.ASSET_LIST_LOADED="hlsAssetListLoaded",e.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",e.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",e.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",e.INTERSTITIAL_STARTED="hlsInterstitialStarted",e.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",e.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",e.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",e.INTERSTITIAL_ENDED="hlsInterstitialEnded",e.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",e.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",e.EVENT_CUE_ENTER="hlsEventCueEnter",e}({}),g=function(e,t){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;var r="["+e+"]:";this.trace=S,this.debug=t.debug.bind(null,r),this.log=t.log.bind(null,r),this.warn=t.warn.bind(null,r),this.info=t.info.bind(null,r),this.error=t.error.bind(null,r)},S=function(){},T={trace:S,debug:S,log:S,warn:S,info:S,error:S};function E(){return s({},T)}function b(e,t,r){return t[e]?t[e].bind(t):(a=e,(i=self.console[a])?i.bind(self.console,"["+a+"] >"):S);var a,i}var A=E();var _=A;function k(e,t){return 255===e[t]&&240==(246&e[t+1])}function R(e,t){return 1&e[t+1]?7:9}function I(e,t){return(3&e[t+3])<<11|e[t+4]<<3|(224&e[t+5])>>>5}function w(e,t){return t+1<e.length&&k(e,t)}function P(e,t){if(w(e,t)){var r=R(e,t);if(t+r>=e.length)return!1;var a=I(e,t);if(a<=r)return!1;var i=t+a;return i===e.length||w(e,i)}return!1}function U(e,t,r,a,i){if(!e.samplerate){var n=function(e,t,r,a){var i=t[r+2],n=i>>2&15;if(!(n>12)){var s=1+(i>>6&3),o=t[r+3]>>6&3|(1&i)<<2,u="mp4a.40."+s,d=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][n],c=n;5!==s&&29!==s||(c-=3);var l=[s<<3|(14&c)>>1,(1&c)<<7|o<<3];return _.log("manifest codec:"+a+", parsed codec:"+u+", channels:"+o+", rate:"+d+" (ADTS object type:"+s+" sampling index:"+n+")"),{config:l,samplerate:d,channelCount:o,codec:u,parsedCodec:u,manifestCodec:a}}var h=new Error("invalid ADTS sampling index:"+n);e.emit(y.ERROR,y.ERROR,{type:m.MEDIA_ERROR,details:v.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message})}(t,r,a,i);if(!n)return;s(e,n)}}function x(e){return 9216e4/e}function D(e,t,r,a,i){var n,s=a+i*x(e.samplerate),o=function(e,t){var r=R(e,t);if(t+r<=e.length){var a=I(e,t)-r;if(a>0)return{headerLength:r,frameLength:a}}}(t,r);if(o){var u=o.frameLength,d=o.headerLength,c=d+u,l=Math.max(0,r+c-t.length);l?(n=new Uint8Array(c-d)).set(t.subarray(r+d,t.length),0):n=t.subarray(r+d,r+c);var h={unit:n,pts:s};return l||e.samples.push(h),{sample:h,length:c,missing:l}}var f=t.length-r;return(n=new Uint8Array(f)).set(t.subarray(r,t.length),0),{sample:{unit:n,pts:s},length:f,missing:-1}}var C=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},L=Number.isSafeInteger||function(e){return"number"==typeof e&&Math.abs(e)<=O},O=Number.MAX_SAFE_INTEGER||9007199254740991;function B(e,t){return h(e,t)&&f(e,t+6)+10<=e.length-t}function M(e,t){if(void 0===t&&(t=!1),"undefined"!=typeof TextDecoder){var r=new TextDecoder("utf-8").decode(e);if(t){var a=r.indexOf("\0");return-1!==a?r.substring(0,a):r}return r.replace(/\0/g,"")}for(var i,n,s,o=e.length,u="",d=0;d<o;){if(0===(i=e[d++])&&t)return u;if(0!==i&&3!==i)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(i);break;case 12:case 13:n=e[d++],u+=String.fromCharCode((31&i)<<6|63&n);break;case 14:n=e[d++],s=e[d++],u+=String.fromCharCode((15&i)<<12|(63&n)<<6|(63&s)<<0)}}return u}function N(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=1/0),function(e,t,r,a){var i=function(e){return e instanceof ArrayBuffer?e:e.buffer}(e),n=1;"BYTES_PER_ELEMENT"in a&&(n=a.BYTES_PER_ELEMENT);var s=(l=e,l&&l.buffer instanceof ArrayBuffer&&void 0!==l.byteLength&&void 0!==l.byteOffset?e.byteOffset:0),o=(s+e.byteLength)/n,u=(s+t)/n,d=Math.floor(Math.max(0,Math.min(u,o))),c=Math.floor(Math.min(d+Math.max(r,0),o));var l;return new a(i,d,c-d)}(e,t,r,Uint8Array)}function F(e){var t={key:e.type,description:"",data:"",mimeType:null,pictureType:null};if(!(e.size<2))if(3===e.data[0]){var r=e.data.subarray(1).indexOf(0);if(-1!==r){var a=M(N(e.data,1,r)),i=e.data[2+r],n=e.data.subarray(3+r).indexOf(0);if(-1!==n){var s,o=M(N(e.data,3+r,n));return s="--\x3e"===a?M(N(e.data,4+r+n)):function(e){return e instanceof ArrayBuffer?e:0==e.byteOffset&&e.byteLength==e.buffer.byteLength?e.buffer:new Uint8Array(e).buffer}(e.data.subarray(4+r+n)),t.mimeType=a,t.pictureType=i,t.description=o,t.data=s,t}}}else console.log("Ignore frame with unrecognized character encoding")}function G(e){return"PRIV"===e.type?function(e){if(!(e.size<2)){var t=M(e.data,!0),r=new Uint8Array(e.data.subarray(t.length+1));return{key:e.type,info:t,data:r.buffer}}}(e):"W"===e.type[0]?function(e){if("WXXX"===e.type){if(e.size<2)return;var t=1,r=M(e.data.subarray(t),!0);t+=r.length+1;var a=M(e.data.subarray(t));return{key:e.type,info:r,data:a}}var i=M(e.data);return{key:e.type,info:"",data:i}}(e):"APIC"===e.type?F(e):function(e){if(!(e.size<2)){if("TXXX"===e.type){var t=1,r=M(e.data.subarray(t),!0);t+=r.length+1;var a=M(e.data.subarray(t));return{key:e.type,info:r,data:a}}var i=M(e.data.subarray(1));return{key:e.type,info:"",data:i}}}(e)}function V(e){var t=String.fromCharCode(e[0],e[1],e[2],e[3]),r=f(e,4);return{type:t,size:r,data:e.subarray(10,10+r)}}var K=10,Y=10;function j(e){return e&&"PRIV"===e.key&&"com.apple.streaming.transportStreamTimestamp"===e.info}function z(e){if(8===e.data.byteLength){var t=new Uint8Array(e.data),r=1&t[3],a=(t[4]<<23)+(t[5]<<15)+(t[6]<<7)+t[7];return a/=45,r&&(a+=47721858.84),Math.round(a)}}function H(e){for(var t=function(e){for(var t=0,r=[];h(e,t);){var a=f(e,t+6);e[t+5]>>6&1&&(t+=K);for(var i=(t+=K)+a;t+Y<i;){var n=V(e.subarray(t)),s=G(n);s&&r.push(s),t+=n.size+K}l(e,t)&&(t+=K)}return r}(e),r=0;r<t.length;r++){var a=t[r];if(j(a))return z(a)}}var W=function(e){return e.audioId3="org.id3",e.dateRange="com.apple.quicktime.HLS",e.emsg="https://aomedia.org/emsg/ID3",e.misbklv="urn:misb:KLV:bin:1910.1",e}({});function q(e){for(var t="",r=0;r<e.length;r++){var a=e[r].toString(16);a.length<2&&(a="0"+a),t+=a}return t}var X,Z,J,Q,$,ee,te={exports:{}};X||(X=1,Z=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,J=/^(?=([^\/?#]*))\1([^]*)$/,Q=/(?:\/|^)\.(?=\/)/g,$=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,te.exports=ee={buildAbsoluteURL:function(e,t,r){if(r=r||{},e=e.trim(),!(t=t.trim())){if(!r.alwaysNormalize)return e;var a=ee.parseURL(e);if(!a)throw new Error("Error trying to parse base URL.");return a.path=ee.normalizePath(a.path),ee.buildURLFromParts(a)}var i=ee.parseURL(t);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return r.alwaysNormalize?(i.path=ee.normalizePath(i.path),ee.buildURLFromParts(i)):t;var n=ee.parseURL(e);if(!n)throw new Error("Error trying to parse base URL.");if(!n.netLoc&&n.path&&"/"!==n.path[0]){var s=J.exec(n.path);n.netLoc=s[1],n.path=s[2]}n.netLoc&&!n.path&&(n.path="/");var o={scheme:n.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};if(!i.netLoc&&(o.netLoc=n.netLoc,"/"!==i.path[0]))if(i.path){var u=n.path,d=u.substring(0,u.lastIndexOf("/")+1)+i.path;o.path=ee.normalizePath(d)}else o.path=n.path,i.params||(o.params=n.params,i.query||(o.query=n.query));return null===o.path&&(o.path=r.alwaysNormalize?ee.normalizePath(i.path):i.path),ee.buildURLFromParts(o)},parseURL:function(e){var t=Z.exec(e);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(e){for(e=e.split("").reverse().join("").replace(Q,"");e.length!==(e=e.replace($,"")).length;);return e.split("").reverse().join("")},buildURLFromParts:function(e){return e.scheme+e.netLoc+e.path+e.params+e.query+e.fragment}});var re="audio",ae="video",ie=Math.pow(2,32)-1,ne=[].push,se={video:1,audio:2,id3:3,text:4};function oe(e){return String.fromCharCode.apply(null,e)}function ue(e,t){var r=e[t]<<8|e[t+1];return r<0?65536+r:r}function de(e,t){var r=le(e,t);return r<0?4294967296+r:r}function ce(e,t){var r=de(e,t);return r*=Math.pow(2,32),r+=de(e,t+4)}function le(e,t){return e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}function he(e,t){var r=[];if(!t.length)return r;for(var a=e.byteLength,i=0;i<a;){var n=de(e,i),s=n>1?i+n:a;if(oe(e.subarray(i+4,i+8))===t[0])if(1===t.length)r.push(e.subarray(i+8,s));else{var o=he(e.subarray(i+8,s),t.slice(1));o.length&&ne.apply(r,o)}i=s}return r}function fe(e){var t=[],r=e[0],a=8,i=de(e,a);a+=4;var n=0,s=0;0===r?(n=de(e,a),s=de(e,a+4),a+=8):(n=ce(e,a),s=ce(e,a+8),a+=16),a+=2;var o=e.length+s,u=ue(e,a);a+=2;for(var d=0;d<u;d++){var c=a,l=de(e,c);c+=4;var h=2147483647&l;if(1===(2147483648&l)>>>31)return _.warn("SIDX has hierarchical references (not supported)"),null;var f=de(e,c);c+=4,t.push({referenceSize:h,subsegmentDuration:f,info:{duration:f/i,start:o,end:o+h-1}}),o+=h,a=c+=4}return{earliestPresentationTime:n,timescale:i,version:r,referencesCount:u,references:t}}function pe(e){for(var t=[],r=he(e,["moov","trak"]),a=0;a<r.length;a++){var i=r[a],n=he(i,["tkhd"])[0];if(n){var s=n[0],o=de(n,0===s?12:20),u=he(i,["mdia","mdhd"])[0];if(u){var c=de(u,0===(s=u[0])?12:20),l=he(i,["mdia","hdlr"])[0];if(l){var h=oe(l.subarray(8,12)),f={soun:re,vide:ae}[h],p=me(he(i,["mdia","minf","stbl","stsd"])[0]);f?(t[o]={timescale:c,type:f,stsd:p},t[f]=d({timescale:c,id:o},p)):t[o]={timescale:c,type:h,stsd:p}}}}}return he(e,["moov","mvex","trex"]).forEach((function(e){var r=de(e,4),a=t[r];a&&(a.default={duration:de(e,12),flags:de(e,20)})})),t}function me(e){var t,r=e.subarray(8),a=r.subarray(86),i=oe(r.subarray(4,8)),n=i,s="enca"===i||"encv"===i;if(s){var o=he(r,[i])[0];he(o.subarray("enca"===i?28:78),["sinf"]).forEach((function(e){var t=he(e,["schm"])[0];if(t){var r=oe(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var a=he(e,["frma"])[0];a&&(n=oe(a))}}}))}var u=n;switch(n){case"avc1":case"avc2":case"avc3":case"avc4":var d=he(a,["avcC"])[0];d&&d.length>3&&(n+="."+ge(d[1])+ge(d[2])+ge(d[3]),t=ve("avc1"===u?"dva1":"dvav",a));break;case"mp4a":var c=he(r,[i])[0],l=he(c.subarray(28),["esds"])[0];if(l&&l.length>7){var h=4;if(3!==l[h++])break;h=ye(l,h),h+=2;var f=l[h++];if(128&f&&(h+=2),64&f&&(h+=l[h++]),4!==l[h++])break;h=ye(l,h);var p=l[h++];if(64!==p)break;if(n+="."+ge(p),h+=12,5!==l[h++])break;h=ye(l,h);var m=l[h++],v=(248&m)>>3;31===v&&(v+=1+((7&m)<<3)+((224&l[h])>>5)),n+="."+v}break;case"hvc1":case"hev1":var y=he(a,["hvcC"])[0];if(y&&y.length>12){var g=y[1],S=["","A","B","C"][g>>6],T=31&g,E=de(y,2),b=(32&g)>>5?"H":"L",A=y[12],_=y.subarray(6,12);n+="."+S+T,n+="."+function(e){for(var t=0,r=0;r<32;r++)t|=(e>>r&1)<<31-r;return t>>>0}(E).toString(16).toUpperCase(),n+="."+b+A;for(var k="",R=_.length;R--;){var I=_[R];if(I||k)k="."+I.toString(16).toUpperCase()+k}n+=k}t=ve("hev1"==u?"dvhe":"dvh1",a);break;case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":n=ve(n,a)||n;break;case"vp09":var w=he(a,["vpcC"])[0];if(w&&w.length>6){var P=w[4],U=w[5],x=w[6]>>4&15;n+="."+Se(P)+"."+Se(U)+"."+Se(x)}break;case"av01":var D=he(a,["av1C"])[0];if(D&&D.length>2){var C=D[1]>>>5,L=31&D[1],O=D[2]>>>7?"H":"M",B=(64&D[2])>>6,M=(32&D[2])>>5,N=2===C&&B?M?12:10:B?10:8,F=(16&D[2])>>4,G=(8&D[2])>>3,V=(4&D[2])>>2,K=3&D[2];n+="."+C+"."+Se(L)+O+"."+Se(N)+"."+F+"."+G+V+K+"."+Se(1)+"."+Se(1)+"."+Se(1)+".0",t=ve("dav1",a)}}return{codec:n,encrypted:s,supplemental:t}}function ve(e,t){var r=he(t,["dvvC"]),a=r.length?r[0]:he(t,["dvcC"])[0];if(a){var i=a[2]>>1&127,n=a[2]<<5&32|a[3]>>3&31;return e+"."+Se(i)+"."+Se(n)}}function ye(e,t){for(var r=t+5;128&e[t++]&&t<r;);return t}function ge(e){return("0"+e.toString(16).toUpperCase()).slice(-2)}function Se(e){return(e<10?"0":"")+e}function Te(e,t){if(e&&t){var r=t.keyId;r&&t.isCommonEncryption&&function(e,t){var r=he(e,["moov","trak"]);r.forEach((function(e){var r=he(e,["mdia","minf","stbl","stsd"])[0];if(r){var a=r.subarray(8),i=he(a,["enca"]),n=i.length>0;n||(i=he(a,["encv"])),i.forEach((function(e){he(n?e.subarray(28):e.subarray(78),["sinf"]).forEach((function(e){var r=function(e){var t=he(e,["schm"])[0];if(t){var r=oe(t.subarray(4,8));if("cbcs"===r||"cenc"===r){var a=he(e,["schi","tenc"])[0];if(a)return a}}}(e);r&&t(r,n)}))}))}}))}(e,(function(e,t){var a=e.subarray(8,24);a.some((function(e){return 0!==e}))||(_.log("[eme] Patching keyId in 'enc"+(t?"a":"v")+">sinf>>tenc' box: "+q(a)+" -> "+q(r)),e.set(r,8))}))}}function Ee(e,t){var r=new Uint8Array(e.length+t.length);return r.set(e),r.set(t,e.length),r}function be(e,t){var r=[],a=t.samples,i=t.timescale,n=t.id,s=!1;return he(a,["moof"]).map((function(o){var u=o.byteOffset-8;he(o,["traf"]).map((function(o){var d=he(o,["tfdt"]).map((function(e){var t=e[0],r=de(e,4);return 1===t&&(r*=Math.pow(2,32),r+=de(e,8)),r/i}))[0];return void 0!==d&&(e=d),he(o,["tfhd"]).map((function(d){var c=de(d,4),l=16777215&de(d,0),h=0,f=0!=(16&l),p=0,m=0!=(32&l),v=8;c===n&&(0!=(1&l)&&(v+=8),0!=(2&l)&&(v+=4),0!=(8&l)&&(h=de(d,v),v+=4),f&&(p=de(d,v),v+=4),m&&(v+=4),"video"===t.type&&(s=function(e){if(!e)return!1;var t=e.substring(0,4);return"hvc1"===t||"hev1"===t||"dvh1"===t||"dvhe"===t}(t.codec)),he(o,["trun"]).map((function(n){var o=n[0],d=16777215&de(n,0),c=0!=(1&d),l=0,f=0!=(4&d),m=0!=(256&d),v=0,y=0!=(512&d),g=0,S=0!=(1024&d),T=0!=(2048&d),E=0,b=de(n,4),A=8;c&&(l=de(n,A),A+=4),f&&(A+=4);for(var _=l+u,k=0;k<b;k++){if(m?(v=de(n,A),A+=4):v=h,y?(g=de(n,A),A+=4):g=p,S&&(A+=4),T&&(E=0===o?de(n,A):le(n,A),A+=4),t.type===ae)for(var R=0;R<g;){var I=de(a,_);if(Ae(s,a[_+=4]))_e(a.subarray(_,_+I),s?2:1,e+E/i,r);_+=I,R+=I+4}e+=v/i}})))}))}))})),r}function Ae(e,t){if(e){var r=t>>1&63;return 39===r||40===r}return 6===(31&t)}function _e(e,t,r,a){var i=ke(e),n=0;n+=t;for(var s=0,o=0,u=0;n<i.length;){s=0;do{if(n>=i.length)break;s+=u=i[n++]}while(255===u);o=0;do{if(n>=i.length)break;o+=u=i[n++]}while(255===u);var d=i.length-n,c=n;if(o<d)n+=o;else if(o>d){_.error("Malformed SEI payload. "+o+" is too small, only "+d+" bytes left to parse.");break}if(4===s){if(181===i[c++]){var l=ue(i,c);if(c+=2,49===l){var h=de(i,c);if(c+=4,1195456820===h){var f=i[c++];if(3===f){var p=i[c++],m=64&p,v=m?2+3*(31&p):0,y=new Uint8Array(v);if(m){y[0]=p;for(var g=1;g<v;g++)y[g]=i[c++]}a.push({type:f,payloadType:s,pts:r,bytes:y})}}}}}else if(5===s&&o>16){for(var S=[],T=0;T<16;T++){var E=i[c++].toString(16);S.push(1==E.length?"0"+E:E),3!==T&&5!==T&&7!==T&&9!==T||S.push("-")}for(var b=o-16,A=new Uint8Array(b),k=0;k<b;k++)A[k]=i[c++];a.push({payloadType:s,pts:r,uuid:S.join(""),userData:M(A),userDataBytes:A})}}}function ke(e){for(var t=e.byteLength,r=[],a=1;a<t-2;)0===e[a]&&0===e[a+1]&&3===e[a+2]?(r.push(a+2),a+=2):a++;if(0===r.length)return e;var i=t-r.length,n=new Uint8Array(i),s=0;for(a=0;a<i;s++,a++)s===r[0]&&(s++,r.shift()),n[a]=e[s];return n}function Re(e,t){return void 0===e&&(e=""),void 0===t&&(t=9e4),{type:e,id:-1,pid:-1,inputTimeScale:t,sequenceNumber:-1,samples:[],dropped:0}}var Ie=function(){function e(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var t=e.prototype;return t.resetInitSegment=function(e,t,r,a){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},t.resetTimeStamp=function(e){this.initPTS=e,this.resetContiguity()},t.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},t.canParse=function(e,t){return!1},t.appendFrame=function(e,t,r){},t.demux=function(e,t){this.cachedData&&(e=Ee(this.cachedData,e),this.cachedData=null);var r,a=p(e,0),i=a?a.length:0,n=this._audioTrack,s=this._id3Track,o=a?H(a):void 0,u=e.length;for((null===this.basePTS||0===this.frameIndex&&C(o))&&(this.basePTS=we(o,t,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),a&&a.length>0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:a,type:W.audioId3,duration:Number.POSITIVE_INFINITY});i<u;){if(this.canParse(e,i)){var d=this.appendFrame(n,e,i);d?(this.frameIndex++,this.lastPTS=d.sample.pts,r=i+=d.length):i=u}else B(e,i)?(a=p(e,i),s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:a,type:W.audioId3,duration:Number.POSITIVE_INFINITY}),r=i+=a.length):i++;if(i===u&&r!==u){var c=e.slice(r);this.cachedData?this.cachedData=Ee(this.cachedData,c):this.cachedData=c}}return{audioTrack:n,videoTrack:Re(),id3Track:s,textTrack:Re()}},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},t.flush=function(e){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:Re(),id3Track:this._id3Track,textTrack:Re()}},t.destroy=function(){this.cachedData=null,this._audioTrack=this._id3Track=void 0},e}(),we=function(e,t,r){return C(e)?90*e:9e4*t+(r?9e4*r.baseTime/r.timescale:0)},Pe=null,Ue=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],xe=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],De=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Ce=[0,1,1,4];function Le(e,t,r,a,i){if(!(r+24>t.length)){var n=Oe(t,r);if(n&&r+n.frameLength<=t.length){var s=a+i*(9e4*n.samplesPerFrame/n.sampleRate),o={unit:t.subarray(r,r+n.frameLength),pts:s,dts:s};return e.config=[],e.channelCount=n.channelCount,e.samplerate=n.sampleRate,e.samples.push(o),{sample:o,length:n.frameLength,missing:0}}}}function Oe(e,t){var r=e[t+1]>>3&3,a=e[t+1]>>1&3,i=e[t+2]>>4&15,n=e[t+2]>>2&3;if(1!==r&&0!==i&&15!==i&&3!==n){var s=e[t+2]>>1&1,o=e[t+3]>>6,u=1e3*Ue[14*(3===r?3-a:3===a?3:4)+i-1],d=xe[3*(3===r?0:2===r?1:2)+n],c=3===o?1:2,l=De[r][a],h=Ce[a],f=8*l*h,p=Math.floor(l*u/d+s)*h;if(null===Pe){var m=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Pe=m?parseInt(m[1]):0}return!!Pe&&Pe<=87&&2===a&&u>=224e3&&0===o&&(e[t+3]=128|e[t+3]),{sampleRate:d,channelCount:c,frameLength:p,samplesPerFrame:f}}}function Be(e,t){return 255===e[t]&&224==(224&e[t+1])&&0!=(6&e[t+1])}function Me(e,t){return t+1<e.length&&Be(e,t)}function Ne(e,t){if(t+1<e.length&&Be(e,t)){var r=Oe(e,t),a=4;null!=r&&r.frameLength&&(a=r.frameLength);var i=t+a;return i===e.length||Me(e,i)}return!1}var Fe=function(e){function t(t,r){var a;return(a=e.call(this)||this).observer=void 0,a.config=void 0,a.observer=t,a.config=r,a}o(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,a,i){e.prototype.resetInitSegment.call(this,t,r,a,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:i,inputTimeScale:9e4,dropped:0}},t.probe=function(e,t){if(!e)return!1;var r=p(e,0),a=(null==r?void 0:r.length)||0;if(Ne(e,a))return!1;for(var i=e.length;a<i;a++)if(P(e,a))return t.log("ADTS sync word found !"),!0;return!1},r.canParse=function(e,t){return function(e,t){return function(e,t){return t+5<e.length}(e,t)&&k(e,t)&&I(e,t)<=e.length-t}(e,t)},r.appendFrame=function(e,t,r){U(e,this.observer,t,r,e.manifestCodec);var a=D(e,t,r,this.basePTS,this.frameIndex);if(a&&0===a.missing)return a},t}(Ie),Ge=function(e,t){var r=0,a=5;t+=a;for(var i=new Uint32Array(1),n=new Uint32Array(1),s=new Uint8Array(1);a>0;){s[0]=e[t];var o=Math.min(a,8),u=8-o;n[0]=4278190080>>>24+u<<u,i[0]=(s[0]&n[0])>>u,r=r?r<<o|i[0]:i[0],t+=1,a-=o}return r},Ve=function(e){function t(t){var r;return(r=e.call(this)||this).observer=void 0,r.observer=t,r}o(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,a,i){e.prototype.resetInitSegment.call(this,t,r,a,i),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:r,duration:i,inputTimeScale:9e4,dropped:0}},r.canParse=function(e,t){return t+64<e.length},r.appendFrame=function(e,t,r){var a=Ke(e,t,r,this.basePTS,this.frameIndex);if(-1!==a)return{sample:e.samples[e.samples.length-1],length:a,missing:0}},t.probe=function(e){if(!e)return!1;var t=p(e,0);if(!t)return!1;var r=t.length;return 11===e[r]&&119===e[r+1]&&void 0!==H(t)&&Ge(e,r)<16},t}(Ie);function Ke(e,t,r,a,i){if(r+8>t.length)return-1;if(11!==t[r]||119!==t[r+1])return-1;var n=t[r+4]>>6;if(n>=3)return-1;var s=[48e3,44100,32e3][n],o=63&t[r+4],u=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+n];if(r+u>t.length)return-1;var d=t[r+6]>>5,c=0;2===d?c+=2:(1&d&&1!==d&&(c+=2),4&d&&(c+=2));var l=(t[r+6]<<8|t[r+7])>>12-c&1,h=[2,1,2,3,3,4,4,5][d]+l,f=t[r+5]>>3,p=7&t[r+5],m=new Uint8Array([n<<6|f<<1|p>>2,(3&p)<<6|d<<3|l<<2|o>>4,o<<4&224]),v=a+i*(1536/s*9e4),y=t.subarray(r,r+u);return e.config=m,e.channelCount=h,e.samplerate=s,e.samples.push({unit:y,pts:v}),u}var Ye=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.resetInitSegment=function(t,r,a,i){e.prototype.resetInitSegment.call(this,t,r,a,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:i,inputTimeScale:9e4,dropped:0}},t.probe=function(e){if(!e)return!1;var t=p(e,0),r=(null==t?void 0:t.length)||0;if(t&&11===e[r]&&119===e[r+1]&&void 0!==H(t)&&Ge(e,r)<=16)return!1;for(var a=e.length;r<a;r++)if(Ne(e,r))return _.log("MPEG Audio sync word found !"),!0;return!1},r.canParse=function(e,t){return function(e,t){return Be(e,t)&&4<=e.length-t}(e,t)},r.appendFrame=function(e,t,r){if(null!==this.basePTS)return Le(e,t,r,this.basePTS,this.frameIndex)},t}(Ie),je=0,ze=1,He=function(){function e(e,t,r){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=e,this.aesIV=t,this.aesMode=r}return e.prototype.decrypt=function(e,t){switch(this.aesMode){case je:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e);case ze:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},t,e);default:throw new Error("[AESCrypto] invalid aes mode "+this.aesMode)}},e}();var We=function(){function e(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}var t=e.prototype;return t.uint8ArrayToUint32Array_=function(e){for(var t=new DataView(e),r=new Uint32Array(4),a=0;a<4;a++)r[a]=t.getUint32(4*a);return r},t.initTable=function(){var e=this.sBox,t=this.invSBox,r=this.subMix,a=r[0],i=r[1],n=r[2],s=r[3],o=this.invSubMix,u=o[0],d=o[1],c=o[2],l=o[3],h=new Uint32Array(256),f=0,p=0,m=0;for(m=0;m<256;m++)h[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){var v=p^p<<1^p<<2^p<<3^p<<4;v=v>>>8^255&v^99,e[f]=v,t[v]=f;var y=h[f],g=h[y],S=h[g],T=257*h[v]^16843008*v;a[f]=T<<24|T>>>8,i[f]=T<<16|T>>>16,n[f]=T<<8|T>>>24,s[f]=T,T=16843009*S^65537*g^257*y^16843008*f,u[v]=T<<24|T>>>8,d[v]=T<<16|T>>>16,c[v]=T<<8|T>>>24,l[v]=T,f?(f=y^h[h[h[S^y]]],p^=h[h[p]]):f=p=1}},t.expandKey=function(e){for(var t=this.uint8ArrayToUint32Array_(e),r=!0,a=0;a<t.length&&r;)r=t[a]===this.key[a],a++;if(!r){this.key=t;var i=this.keySize=t.length;if(4!==i&&6!==i&&8!==i)throw new Error("Invalid aes key size="+i);var n,s,o,u,d=this.ksRows=4*(i+6+1),c=this.keySchedule=new Uint32Array(d),l=this.invKeySchedule=new Uint32Array(d),h=this.sBox,f=this.rcon,p=this.invSubMix,m=p[0],v=p[1],y=p[2],g=p[3];for(n=0;n<d;n++)n<i?o=c[n]=t[n]:(u=o,n%i==0?(u=h[(u=u<<8|u>>>24)>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[255&u],u^=f[n/i|0]<<24):i>6&&n%i==4&&(u=h[u>>>24]<<24|h[u>>>16&255]<<16|h[u>>>8&255]<<8|h[255&u]),c[n]=o=(c[n-i]^u)>>>0);for(s=0;s<d;s++)n=d-s,u=3&s?c[n]:c[n-4],l[s]=s<4||n<=4?u:m[h[u>>>24]]^v[h[u>>>16&255]]^y[h[u>>>8&255]]^g[h[255&u]],l[s]=l[s]>>>0}},t.networkToHostOrderSwap=function(e){return e<<24|(65280&e)<<8|(16711680&e)>>8|e>>>24},t.decrypt=function(e,t,r){for(var a,i,n,s,o,u,d,c,l,h,f,p,m,v,y=this.keySize+6,g=this.invKeySchedule,S=this.invSBox,T=this.invSubMix,E=T[0],b=T[1],A=T[2],_=T[3],k=this.uint8ArrayToUint32Array_(r),R=k[0],I=k[1],w=k[2],P=k[3],U=new Int32Array(e),x=new Int32Array(U.length),D=this.networkToHostOrderSwap;t<U.length;){for(l=D(U[t]),h=D(U[t+1]),f=D(U[t+2]),p=D(U[t+3]),o=l^g[0],u=p^g[1],d=f^g[2],c=h^g[3],m=4,v=1;v<y;v++)a=E[o>>>24]^b[u>>16&255]^A[d>>8&255]^_[255&c]^g[m],i=E[u>>>24]^b[d>>16&255]^A[c>>8&255]^_[255&o]^g[m+1],n=E[d>>>24]^b[c>>16&255]^A[o>>8&255]^_[255&u]^g[m+2],s=E[c>>>24]^b[o>>16&255]^A[u>>8&255]^_[255&d]^g[m+3],o=a,u=i,d=n,c=s,m+=4;a=S[o>>>24]<<24^S[u>>16&255]<<16^S[d>>8&255]<<8^S[255&c]^g[m],i=S[u>>>24]<<24^S[d>>16&255]<<16^S[c>>8&255]<<8^S[255&o]^g[m+1],n=S[d>>>24]<<24^S[c>>16&255]<<16^S[o>>8&255]<<8^S[255&u]^g[m+2],s=S[c>>>24]<<24^S[o>>16&255]<<16^S[u>>8&255]<<8^S[255&d]^g[m+3],x[t]=D(a^R),x[t+1]=D(s^I),x[t+2]=D(n^w),x[t+3]=D(i^P),R=l,I=h,w=f,P=p,t+=4}return x.buffer},e}(),qe=function(){function e(e,t,r){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=e,this.key=t,this.aesMode=r}return e.prototype.expandKey=function(){var e=function(e){switch(e){case je:return"AES-CBC";case ze:return"AES-CTR";default:throw new Error("[FastAESKey] invalid aes mode "+e)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:e},!1,["encrypt","decrypt"])},e}();var Xe=function(){function e(e,t){var r=(void 0===t?{}:t).removePKCS7Padding,a=void 0===r||r;if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=e.enableSoftwareAES,this.removePKCS7Padding=a,a)try{var i=self.crypto;i&&(this.subtle=i.subtle||i.webkitSubtle)}catch(e){}this.useSoftware=!this.subtle}var t=e.prototype;return t.destroy=function(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null},t.isSync=function(){return this.useSoftware},t.flush=function(){var e=this.currentResult,t=this.remainderData;if(!e||t)return this.reset(),null;var r,a,i,n=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?(a=(r=n).byteLength,(i=a&&new DataView(r.buffer).getUint8(a-1))?r.slice(0,a-i):r):n},t.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},t.decrypt=function(e,t,r,a){var i=this;return this.useSoftware?new Promise((function(n,s){var o=ArrayBuffer.isView(e)?e:new Uint8Array(e);i.softwareDecrypt(o,t,r,a);var u=i.flush();u?n(u.buffer):s(new Error("[softwareDecrypt] Failed to decrypt data"))})):this.webCryptoDecrypt(new Uint8Array(e),t,r,a)},t.softwareDecrypt=function(e,t,r,a){var i=this.currentIV,n=this.currentResult,s=this.remainderData;if(a!==je||16!==t.byteLength)return _.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),s&&(e=Ee(s,e),this.remainderData=null);var o=this.getValidChunk(e);if(!o.length)return null;i&&(r=i);var u=this.softwareDecrypter;u||(u=this.softwareDecrypter=new We),u.expandKey(t);var d=n;return this.currentResult=u.decrypt(o.buffer,0,r),this.currentIV=o.slice(-16).buffer,d||null},t.webCryptoDecrypt=function(e,t,r,a){var i=this;if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r,a));this.key=t,this.fastAesKey=new qe(this.subtle,t,a)}return this.fastAesKey.expandKey().then((function(t){return i.subtle?(i.logOnce("WebCrypto AES decrypt"),new He(i.subtle,new Uint8Array(r),a).decrypt(e.buffer,t)):Promise.reject(new Error("web crypto not initialized"))})).catch((function(n){return _.warn("[decrypter]: WebCrypto Error, disable WebCrypto API, "+n.name+": "+n.message),i.onWebCryptoError(e,t,r,a)}))},t.onWebCryptoError=function(e,t,r,a){var i=this.enableSoftwareAES;if(i){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r,a);var n=this.flush();if(n)return n.buffer}throw new Error("WebCrypto"+(i?" and softwareDecrypt":"")+": failed to decrypt data")},t.getValidChunk=function(e){var t=e,r=e.length-e.length%16;return r!==e.length&&(t=e.slice(0,r),this.remainderData=e.slice(r)),t},t.logOnce=function(e){this.logEnabled&&(_.log("[decrypter]: "+e),this.logEnabled=!1)},e}(),Ze=/\/emsg[-/]ID3/i,Je=function(){function e(e,t){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=t}var t=e.prototype;return t.resetTimeStamp=function(){},t.resetInitSegment=function(e,t,r,a){var i=this.videoTrack=Re("video",1),n=this.audioTrack=Re("audio",1),s=this.txtTrack=Re("text",1);if(this.id3Track=Re("id3",1),this.timeOffset=0,null!=e&&e.byteLength){var o=pe(e);if(o.video){var u=o.video,d=u.id,c=u.timescale,l=u.codec,h=u.supplemental;i.id=d,i.timescale=s.timescale=c,i.codec=l,i.supplemental=h}if(o.audio){var f=o.audio,p=f.id,m=f.timescale,v=f.codec;n.id=p,n.timescale=m,n.codec=v}s.id=se.text,i.sampleDuration=0,i.duration=n.duration=a}},t.resetContiguity=function(){this.remainderData=null},e.probe=function(e){return function(e){for(var t=e.byteLength,r=0;r<t;){var a=de(e,r);if(a>8&&109===e[r+4]&&111===e[r+5]&&111===e[r+6]&&102===e[r+7])return!0;r=a>1?r+a:t}return!1}(e)},t.demux=function(e,t){this.timeOffset=t;var r=e,a=this.videoTrack,i=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Ee(this.remainderData,e));var n=function(e){var t={valid:null,remainder:null},r=he(e,["moof"]);if(r.length<2)return t.remainder=e,t;var a=r[r.length-1];return t.valid=e.slice(0,a.byteOffset-8),t.remainder=e.slice(a.byteOffset-8),t}(r);this.remainderData=n.remainder,a.samples=n.valid||new Uint8Array}else a.samples=r;var s=this.extractID3Track(a,t);return i.samples=be(t,a),{videoTrack:a,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},t.flush=function(){var e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;var a=this.extractID3Track(t,this.timeOffset);return r.samples=be(e,t),{videoTrack:t,audioTrack:Re(),id3Track:a,textTrack:Re()}},t.extractID3Track=function(e,t){var r=this,a=this.id3Track;if(e.samples.length){var i=he(e.samples,["emsg"]);i&&i.forEach((function(e){var i=function(e){var t=e[0],r="",a="",i=0,n=0,s=0,o=0,u=0,d=0;if(0===t){for(;"\0"!==oe(e.subarray(d,d+1));)r+=oe(e.subarray(d,d+1)),d+=1;for(r+=oe(e.subarray(d,d+1)),d+=1;"\0"!==oe(e.subarray(d,d+1));)a+=oe(e.subarray(d,d+1)),d+=1;a+=oe(e.subarray(d,d+1)),d+=1,i=de(e,12),n=de(e,16),o=de(e,20),u=de(e,24),d=28}else if(1===t){i=de(e,d+=4);var c=de(e,d+=4),l=de(e,d+=4);for(d+=4,s=Math.pow(2,32)*c+l,L(s)||(s=Number.MAX_SAFE_INTEGER,_.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=de(e,d),u=de(e,d+=4),d+=4;"\0"!==oe(e.subarray(d,d+1));)r+=oe(e.subarray(d,d+1)),d+=1;for(r+=oe(e.subarray(d,d+1)),d+=1;"\0"!==oe(e.subarray(d,d+1));)a+=oe(e.subarray(d,d+1)),d+=1;a+=oe(e.subarray(d,d+1)),d+=1}return{schemeIdUri:r,value:a,timeScale:i,presentationTime:s,presentationTimeDelta:n,eventDuration:o,id:u,payload:e.subarray(d,e.byteLength)}}(e);if(Ze.test(i.schemeIdUri)){var n=Qe(i,t),s=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;s<=.001&&(s=Number.POSITIVE_INFINITY);var o=i.payload;a.samples.push({data:o,len:o.byteLength,dts:n,pts:n,type:W.emsg,duration:s})}else if(r.config.enableEmsgKLVMetadata&&i.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){var u=Qe(i,t);a.samples.push({data:i.payload,len:i.payload.byteLength,dts:u,pts:u,type:W.misbklv,duration:Number.POSITIVE_INFINITY})}}))}return a},t.demuxSampleAes=function(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},t.destroy=function(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0},e}();function Qe(e,t){return C(e.presentationTime)?e.presentationTime/e.timeScale:t+e.presentationTimeDelta/e.timeScale}var $e=function(){function e(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Xe(t,{removePKCS7Padding:!1})}var t=e.prototype;return t.decryptBuffer=function(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer,je)},t.decryptAacSample=function(e,t,r){var a=this,i=e[t].unit;if(!(i.length<=16)){var n=i.subarray(16,i.length-i.length%16),s=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(s).then((function(n){var s=new Uint8Array(n);i.set(s,16),a.decrypter.isSync()||a.decryptAacSamples(e,t+1,r)})).catch(r)}},t.decryptAacSamples=function(e,t,r){for(;;t++){if(t>=e.length)return void r();if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}},t.getAvcEncryptedData=function(e){for(var t=16*Math.floor((e.length-48)/160)+16,r=new Int8Array(t),a=0,i=32;i<e.length-16;i+=160,a+=16)r.set(e.subarray(i,i+16),a);return r},t.getAvcDecryptedUnit=function(e,t){for(var r=new Uint8Array(t),a=0,i=32;i<e.length-16;i+=160,a+=16)e.set(r.subarray(a,a+16),i);return e},t.decryptAvcSample=function(e,t,r,a,i){var n=this,s=ke(i.data),o=this.getAvcEncryptedData(s);this.decryptBuffer(o.buffer).then((function(o){i.data=n.getAvcDecryptedUnit(s,o),n.decrypter.isSync()||n.decryptAvcSamples(e,t,r+1,a)})).catch(a)},t.decryptAvcSamples=function(e,t,r,a){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length)return void a();for(var i=e[t].units;!(r>=i.length);r++){var n=i[r];if(!(n.data.length<=48||1!==n.type&&5!==n.type||(this.decryptAvcSample(e,t,r,a,n),this.decrypter.isSync())))return}}},e}(),et=function(){function e(){this.VideoSample=null}var t=e.prototype;return t.createVideoSample=function(e,t,r){return{key:e,frame:!1,pts:t,dts:r,units:[],length:0}},t.getLastNalUnit=function(e){var t,r,a=this.VideoSample;if(a&&0!==a.units.length||(a=e[e.length-1]),null!=(t=a)&&t.units){var i=a.units;r=i[i.length-1]}return r},t.pushAccessUnit=function(e,t){if(e.units.length&&e.frame){if(void 0===e.pts){var r=t.samples,a=r.length;if(!a)return void t.dropped++;var i=r[a-1];e.pts=i.pts,e.dts=i.dts}t.samples.push(e)}},t.parseNALu=function(e,t,r){var a,i,n=t.byteLength,s=e.naluState||0,o=s,u=[],d=0,c=-1,l=0;for(-1===s&&(c=0,l=this.getNALuType(t,0),s=0,d=1);d<n;)if(a=t[d++],s)if(1!==s)if(a)if(1===a){if(i=d-s-1,c>=0){var h={data:t.subarray(c,i),type:l};u.push(h)}else{var f=this.getLastNalUnit(e.samples);f&&(o&&d<=4-o&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-o)),i>0&&(f.data=Ee(f.data,t.subarray(0,i)),f.state=0))}d<n?(c=d,l=this.getNALuType(t,d),s=0):s=-1}else s=0;else s=3;else s=a?0:2;else s=a?0:1;if(c>=0&&s>=0){var p={data:t.subarray(c,n),type:l,state:s};u.push(p)}if(0===u.length){var m=this.getLastNalUnit(e.samples);m&&(m.data=Ee(m.data,t))}return e.naluState=s,u},e}(),tt=function(){function e(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}var t=e.prototype;return t.loadWord=function(){var e=this.data,t=this.bytesAvailable,r=e.byteLength-t,a=new Uint8Array(4),i=Math.min(4,t);if(0===i)throw new Error("no bytes available");a.set(e.subarray(r,r+i)),this.word=new DataView(a.buffer).getUint32(0),this.bitsAvailable=8*i,this.bytesAvailable-=i},t.skipBits=function(e){var t;e=Math.min(e,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,e-=(t=e>>3)<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)},t.readBits=function(e){var t=Math.min(this.bitsAvailable,e),r=this.word>>>32-t;if(e>32&&_.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(t=e-t)>0&&this.bitsAvailable?r<<t|this.readBits(t):r},t.skipLZ=function(){var e;for(e=0;e<this.bitsAvailable;++e)if(0!=(this.word&2147483648>>>e))return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()},t.skipUEG=function(){this.skipBits(1+this.skipLZ())},t.skipEG=function(){this.skipBits(1+this.skipLZ())},t.readUEG=function(){var e=this.skipLZ();return this.readBits(e+1)-1},t.readEG=function(){var e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)},t.readBoolean=function(){return 1===this.readBits(1)},t.readUByte=function(){return this.readBits(8)},t.readUShort=function(){return this.readBits(16)},t.readUInt=function(){return this.readBits(32)},e}(),rt=function(e){function t(){return e.apply(this,arguments)||this}o(t,e);var r=t.prototype;return r.parsePES=function(e,t,r,a){var i,n=this,s=this.parseNALu(e,r.data,a),o=this.VideoSample,u=!1;r.data=null,o&&s.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts)),s.forEach((function(a){var s,d;switch(a.type){case 1:var c=!1;i=!0;var l,h=a.data;if(u&&h.length>4){var f=n.readSliceType(h);2!==f&&4!==f&&7!==f&&9!==f||(c=!0)}if(c)null!=(l=o)&&l.frame&&!o.key&&(n.pushAccessUnit(o,e),o=n.VideoSample=null);o||(o=n.VideoSample=n.createVideoSample(!0,r.pts,r.dts)),o.frame=!0,o.key=c;break;case 5:i=!0,null!=(s=o)&&s.frame&&!o.key&&(n.pushAccessUnit(o,e),o=n.VideoSample=null),o||(o=n.VideoSample=n.createVideoSample(!0,r.pts,r.dts)),o.key=!0,o.frame=!0;break;case 6:i=!0,_e(a.data,1,r.pts,t.samples);break;case 7:var p,m;i=!0,u=!0;var v=a.data,y=n.readSPS(v);if(!e.sps||e.width!==y.width||e.height!==y.height||(null==(p=e.pixelRatio)?void 0:p[0])!==y.pixelRatio[0]||(null==(m=e.pixelRatio)?void 0:m[1])!==y.pixelRatio[1]){e.width=y.width,e.height=y.height,e.pixelRatio=y.pixelRatio,e.sps=[v];for(var g=v.subarray(1,4),S="avc1.",T=0;T<3;T++){var E=g[T].toString(16);E.length<2&&(E="0"+E),S+=E}e.codec=S}break;case 8:i=!0,e.pps=[a.data];break;case 9:i=!0,e.audFound=!0,null!=(d=o)&&d.frame&&(n.pushAccessUnit(o,e),o=null),o||(o=n.VideoSample=n.createVideoSample(!1,r.pts,r.dts));break;case 12:i=!0;break;default:i=!1}o&&i&&o.units.push(a)})),a&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)},r.getNALuType=function(e,t){return 31&e[t]},r.readSliceType=function(e){var t=new tt(e);return t.readUByte(),t.readUEG(),t.readUEG()},r.skipScalingList=function(e,t){for(var r=8,a=8,i=0;i<e;i++)0!==a&&(a=(r+t.readEG()+256)%256),r=0===a?r:a},r.readSPS=function(e){var t,r,a,i=new tt(e),n=0,s=0,o=0,u=0,d=i.readUByte.bind(i),c=i.readBits.bind(i),l=i.readUEG.bind(i),h=i.readBoolean.bind(i),f=i.skipBits.bind(i),p=i.skipEG.bind(i),m=i.skipUEG.bind(i),v=this.skipScalingList.bind(this);d();var y=d();if(c(5),f(3),d(),m(),100===y||110===y||122===y||244===y||44===y||83===y||86===y||118===y||128===y){var g=l();if(3===g&&f(1),m(),m(),f(1),h())for(r=3!==g?8:12,a=0;a<r;a++)h()&&v(a<6?16:64,i)}m();var S=l();if(0===S)l();else if(1===S)for(f(1),p(),p(),t=l(),a=0;a<t;a++)p();m(),f(1);var T=l(),E=l(),b=c(1);0===b&&f(1),f(1),h()&&(n=l(),s=l(),o=l(),u=l());var A=[1,1];if(h()&&h())switch(d()){case 1:A=[1,1];break;case 2:A=[12,11];break;case 3:A=[10,11];break;case 4:A=[16,11];break;case 5:A=[40,33];break;case 6:A=[24,11];break;case 7:A=[20,11];break;case 8:A=[32,11];break;case 9:A=[80,33];break;case 10:A=[18,11];break;case 11:A=[15,11];break;case 12: