commit 1c27053a9d222872f0ee4450c3b9a1564a04f798 Author: Hamcha Date: Fri Jun 21 18:40:58 2024 -0400 check in diff --git a/README.md b/README.md new file mode 100644 index 0000000..e9a216e --- /dev/null +++ b/README.md @@ -0,0 +1,94 @@ +# OvenStarter + +This is a template to get started using OvenMediaEngine. It has one very specific audience: Streamers proficient in server management and fucking around with HTML and code wanting to start selfhosting a bit more without quitting popular platforms like Twitch. + +Most of this is my own setup which I've torn apart a little and added tons of comments everywhere I saw fit. + +This README hopefully will work as a guide on how to use the provided files in this repo but feel free to hit me up at [hamcha@crunchy.rocks](mailto:hamcha@crunchy.rocks) if you need some help. + +**What this is NOT**: A comprehensive, beginner-friendly, battery-powered set-up. Prepare to get your hands dirty and possibly dig through some manuals. You will most definetely want to use this as a starting point only and customize the hell out of it. + +## Requirements + +The ingredients you will need to get started are: + +- Some server running any flavor of Docker that supports docker-compose +- TLS certificate setup using LetsEncrypt or something else + +You may be able to get away without a certificate setup but you'd be playing a risky game. + +## Setting up the oven + +Clone this repo somewhere, look at the docker compose file. + +Make sure the ports used by OME are available. If you need to change some, note them down since you'll have to change them in the config file as well. + +Set the `OME_HOST_IP` to whatever IP or domain name your server is reachable at. You're gonna use that IP/domain for your RTMP ingest and output feeds. + +The config folder contains the configuration files, including the most important one, `Server.xml`. I added plenty of comments to it so please look through it all and configure it to your liking. + +Once everything has been set up properly, start it with `docker compose up` (and add `-d` for detached yadda yadda hopefully you know the deal) + +## The SignedPolicy bit + +The config file specifies two credentials to set up, a API access key (for later) and something about SignedPolicy. SignedPolicy is the main authentication method that OME uses to prevent anyone from streaming your content. It has additional benefits like being able to provide lock content or transcoding options behing paywalls as well as provide self-expiring URLs for both streaming and viewing. You can explore the whole thing for yourself but for us it's mostly an annoyance, here is how it works: + +Every URL for either viewing (through WebRTC or HLS) and streaming (RTMP, SRT, WHIP) must be accompanied by a policy object that provides limits to that URL (at minimum an expiration date) and a signature that signs the whole thing as "valid" by whoever has the secret key. + +In other words, you'll need to use whatever secret key you specified in the config file to create signed URLs both to put in your OBS for streaming and in whatever web player for viewing. + +OME provides a very bland shell script for this but I re-implemented all of it as a webpage on https://nebula.cafe/ome.html (all running with clientside javascript) + +If you don't trust using a website you can use the `ome.html` page bundled in this repo, it's the same file and its code is not minimized in any way (feel free to snoop to see how the signing process works, in fact). + +The URLs you're looking to sign are most likely the following: + +### Viewer endpoints (WebRTC, HLS) + +These URLs are used in the web player for letting users access your stream, they look something like this: + +- `wss://your.server.ip:3334/app/stream/webrtc` +- `https://your.server.ip:3334/app/stream/llhls.m3u8` + +after using the tool to sign them, they would look something like this: + +`wss://your.server.ip:3334/app/stream/webrtc?policy=eyJ1cmxfZXhwaXJlIjo2Mjg5MzE4ODAwMDAwfQ&signature=whGrRzv7GrNbHy8pIcG2qEPmeVo` + +This is what you need to use as the URL in your web player. + +### Ingest URLs (RTMP, SRT, WHIP) + +To stream to OME you'll also need a signed URL. For RTMP you'll need to sign something akin to the following: + +`rtmp://your.server.ip:1935/app/stream` + +after using the tool, it should look like this: + +`rtmp://your.server.ip:1935/app/stream?policy=eyJ1cmxfZXhwaXJlIjo2Mjg5MzE4ODAwMDAwfQ&signature=fjS6rae_bzOU6pP_SrM7aRI7eVs` + +To use it in OBS, you'll need to split it in two like this: + +- For server, use `rtmp://your.server.ip:1935/app` +- For stream key, use `stream?policy=eyJ1cmxfZXhwaXJlIjo2Mjg5MzE4ODAwMDAwfQ&signature=fjS6rae_bzOU6pP_SrM7aRI7eVs` + +> SRT and WHIP are work in progress since they're a bit annoying to figure out, I got it once and forgot about it, whoops. I'll update this later I swear! + +## Setting up the player + +The player is the most scuffed part of it all currently. I provided you with my scuffy setup for you to hack at, just mess with the HTML and JS file until it looks passable to you. The biggest problem is that there is no proper offline state and the player will error out when a stream isn't playing. I'd like to make it proper but for now it is what it is. + +## Re-streaming + +You will have noticed the config file has nothing about restreaming to Twitch/Youtube. This is a bit of a weird thing for me as well because currently the only way to restream via the RTMP publisher (which *is* enabled via the config) is to use API calls to set ip up and start it. + +> WIP! Gonna fill this up later, I forgot my Bruno workspace at home and need to finesse my current overlay setup so I can include it in here. + +## Notes + +I currently use a LetsEncrypt setup for certificates, which mean they change roughly every couple months. This means OME needs to reload the cert files every once in a while and I do this with a cronjob that just copies those files over and restarts the container. If you have an `acme.json` file because of managing certificates through tools like Traefik, check `update-cert.sh` on how to extract specific certificates/keys from that. + +The API bit is annoying not only because it's not configurable via the config file but also because you have to redo the calls basically every stream. For some reasons the "pushes" expire in a fashion that I cannot seem to understand. I just use the overlay solution described. I hope a nicer solution comes up to address this. + +## License + +I guess this needs some? The bits in `player/vendor` are provided under their own permissive license, treat anything else as [WTFPL](http://www.wtfpl.net) or whatever. \ No newline at end of file diff --git a/config/Logger.xml b/config/Logger.xml new file mode 100644 index 0000000..48fa2a5 --- /dev/null +++ b/config/Logger.xml @@ -0,0 +1,14 @@ + + + + + /var/log/ovenmediaengine + + + + + + + + + diff --git a/config/Server.xml b/config/Server.xml new file mode 100644 index 0000000..044bb27 --- /dev/null +++ b/config/Server.xml @@ -0,0 +1,411 @@ + + + + + Your stream "service" name + + + origin + + + + + * + + + true + + + stun.ovenmediaengine.com:13478 + + + + + true + + + + + true + + + + + + false + 2 + + + + + + + + 8081 + 1 + + + + + 1 + + + 1 + + + 1935 + 1 + + + 9999 + 1 + + + + 3333 + 3334 + 1 + + + + + *:10000/udp + *:3478 + false + 1 + + + + + + + + 9000 + 1 + + + + 3333 + 3334 + 1 + + + + 3333 + 3334 + 1 + + + + + *:10001-10004/udp + + *:3478 + + false + 1 + + + + + + + + + + + localhost + + + + + cert.crt + cert.key + cert.crt + + + + + admin:changeme + + + * + + + + + + + default + + localhost + + + + + localhost + + + + cert.crt + cert.key + cert.crt + + + + + + policy + signature + + + CHANGEME + + + webrtc,hls,llhls,dash,lldash + rtmp,webrtc,srt + + + + + * + + + + + + + app + + live + + + + + false + + + + + false + + + + + + stream + stream + + + + + + + + + + + + + + + + + + + + webrtc + webrtc + + true + + + + Source + + + + + + + + llhls + llhls + + Source + + + + + + + + + + + + + + + + + 1 + 8 + + 30000 + true + true + false + + + false + + 0 + 0 + 60 + -1 + -1 + + 0.5 + 1.5 + 6 + 10 + + * + + + + + + + + + + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..5dff8eb --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,20 @@ +version: '3' +services: + mediaengine: + image: 'airensoft/ovenmediaengine:0.16.5' + restart: always + environment: + OME_HOST_IP: "127.0.0.1" # Replace with public IP/domain + ports: + #- 8081:8081 # HTTP API + - 8082:8082 # HTTPS API + - 1935:1935 # RTMP ingest + - 9999:9999/udp # SRT ingest + #- 9000:9000 # OVT output (needed for multi-node systems) + - 3333:3333 # WebRTC/HLS output + - 3334:3334 # Like above, but with TLS encryption + - 3478:3478 # TCP relay port (WebRTC punchthrough) + - 10000-10009:10000-10009/udp # ICE UDP ports (WebRTC punchthrough) + volumes: + - './config:/opt/ovenmediaengine/bin/origin_conf' + - './logs:/var/log/ovenmediaengine' diff --git a/ome.html b/ome.html new file mode 100644 index 0000000..b5fe331 --- /dev/null +++ b/ome.html @@ -0,0 +1,499 @@ + + + + + + + Generate signed URL + + + + +
+
+

OvenMediaEngine utility (unofficial)

+

Generate signed URL

+

+ This webpage saves you from needing to run the official signed_policy_url_generator.sh + shell script by using web browser's built-in Crypto APIs. If you want a more in-depth breakdown on how + to generate signed URLs, check the official + documentation on SignedPolicy. +

+

+ Note: + This page works completely in your browser (check the source, it's not minimized or anything!) so your + keys should never reach my server, not even in logs! +

+
+
+ URL to sign + +
+
+ Secret key + +
+
+ Policy +
+ + +
+
+ + +
+ +
+ + + +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/player/index.html b/player/index.html new file mode 100644 index 0000000..45be1b9 --- /dev/null +++ b/player/index.html @@ -0,0 +1,48 @@ + + + + + + Stream player sample + + + + +
+
+
+ Some stream something here +
+
+
+ +
+
+ + +
+ + + + + diff --git a/player/script.js b/player/script.js new file mode 100644 index 0000000..3a97a39 --- /dev/null +++ b/player/script.js @@ -0,0 +1,33 @@ +const player = OvenPlayer.create("player_id", { + autoStart: false, + autoFallback: true, + aspectRatio: "16:9", + mute: false, + disableSeekUI: true, + playbackRates: [], + sources: [ + { + label: "WebRTC (low latency)", + type: "webrtc", + file: "wss://your.server.ip:3334/app/stream/webrtc?policy=eyJ1cmxfZXhwaXJlIjo2Mjg5MzE4ODAwMDAwfQ&signature=whGrRzv7GrNbHy8pIcG2qEPmeVo", + }, + { + label: "HLS", + type: "hls", + file: "https://your.server.ip:3334/app/stream/llhls.m3u8?policy=eyJ1cmxfZXhwaXJlIjo2Mjg5MzE4ODAwMDAwfQ&signature=UqgRtDIuM6PNOHNVO640Ij731yg", + }, + ], +}); + +player.on("ready", () => { + window.player = player; + var audioCheck = player.getMediaElement().play(); + + // If website is not trusted by browser to autoplay with audio, autoplay muted instead + if (audioCheck !== undefined) { + audioCheck.catch((error) => { + player.setMute(true); + player.play(); + }); + } +}); \ No newline at end of file diff --git a/player/style.css b/player/style.css new file mode 100644 index 0000000..ac5fa04 --- /dev/null +++ b/player/style.css @@ -0,0 +1,72 @@ +main { + display: flex; + height: 100vh; +} +#player { + flex: 1; + display: flex; + flex-direction: column; + justify-content: space-evenly; +} +#player > section { + display: none; +} +iframe { + flex: 0 357px; + border: 0; +} +.op-wrapper.ovenplayer { + /* Change this to your "offline" screen */ + background-image: url(https://wallpapercave.com/wp/wp4749222.jpg); + background-size: contain; + background-position: center; + background-repeat: no-repeat; +} +.button { + display: inline-block; + padding: 0.5em 1em; + text-decoration: none; + border-radius: 4px; + background-color: #bebed6; + color: black; + cursor: pointer; + border: 0; +} +.button.disabled { + pointer-events: none; + opacity: 0.5; + cursor: inherit; +} +.twitch { + background-color: #6441a5; + color: white; +} +.twitch:hover { + background-color: #8f75bf; +} +@media (max-aspect-ratio: 19/9) { + #player > section { + display: flex; + } +} +.header { + display: flex; + align-items: center; + padding: 1rem; + font-size: 13pt; +} +#stream-game { + color: #a4a1bc; + padding-left: 1rem; +} +.links { + flex: 1; + padding: 1rem; + display: flex; + gap: 0.5rem; + flex-wrap: wrap; + flex-direction: row-reverse; +} +.bottom { + display: flex; +} diff --git a/player/vendor/hls.min.js b/player/vendor/hls.min.js new file mode 100644 index 0000000..fdb810f --- /dev/null +++ b/player/vendor/hls.min.js @@ -0,0 +1,2 @@ +!function t(e){var r,i;r=this,i=function(){"use strict";function r(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function i(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,i=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function m(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var i=r.call(t,e||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function p(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var y={exports:{}};!function(t,e){var r,i,n,a,s;r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(t,e,r){if(r=r||{},t=t.trim(),!(e=e.trim())){if(!r.alwaysNormalize)return t;var n=s.parseURL(t);if(!n)throw new Error("Error trying to parse base URL.");return n.path=s.normalizePath(n.path),s.buildURLFromParts(n)}var a=s.parseURL(e);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):e;var o=s.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=i.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(u.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var h=o.path,d=h.substring(0,h.lastIndexOf("/")+1)+a.path;u.path=s.normalizePath(d)}else u.path=o.path,a.params||(u.params=o.params,a.query||(u.query=o.query));return null===u.path&&(u.path=r.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(u)},parseURL:function(t){var e=r.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(n,"");t.length!==(t=t.replace(a,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}},t.exports=s}(y);var T=y.exports,E=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},S=function(t){return t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached",t}({}),L=function(t){return t.NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError",t}({}),R=function(t){return t.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",t.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",t.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",t.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_PARSING_ERROR="levelParsingError",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.FRAG_GAP="fragGap",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown",t}({}),A=function(){},k={trace:A,debug:A,log:A,warn:A,info:A,error:A},b=k;function D(t){var e=self.console[t];return e?e.bind(self.console,"["+t+"] >"):A}function I(t,e){if(self.console&&!0===t||"object"==typeof t){!function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;iNumber.MAX_SAFE_INTEGER?1/0:e},e.hexadecimalInteger=function(t){if(this[t]){var e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var r=new Uint8Array(e.length/2),i=0;iNumber.MAX_SAFE_INTEGER?1/0:e},e.decimalFloatingPoint=function(t){return parseFloat(this[t])},e.optionalFloat=function(t,e){var r=this[t];return r?parseFloat(r):e},e.enumeratedString=function(t){return this[t]},e.bool=function(t){return"YES"===this[t]},e.decimalResolution=function(t){var e=C.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},t.parseAttrList=function(t){var e,r={};for(_.lastIndex=0;null!==(e=_.exec(t));){var i=e[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[e[1].trim()]=i}return r},t}();function x(t){return"SCTE35-OUT"===t||"SCTE35-IN"===t}var F=function(){function t(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){var r=e.attr;for(var i in r)if(Object.prototype.hasOwnProperty.call(t,i)&&t[i]!==r[i]){w.warn('DATERANGE tag attribute: "'+i+'" does not match for tags with ID: "'+t.ID+'"'),this._badValueForSameId=i;break}t=o(new P({}),r,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){var n=new Date(this.attr["END-DATE"]);E(n.getTime())&&(this._endDate=n)}}return a(t,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var t=this.duration;return null!==t?new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var t=this.attr.decimalFloatingPoint("DURATION");if(E(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&E(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),t}(),M=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}},O="audio",N="video",U="audiovideo",B=function(){function t(t){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[O]=null,e[N]=null,e[U]=null,e),this.baseurl=t}return t.prototype.setByteRange=function(t,e){var r=t.split("@",2),i=[];1===r.length?i[0]=e?e.byteRangeEndOffset:0:i[0]=parseInt(r[1]),i[1]=parseInt(r[0])+i[0],this._byteRange=i},a(t,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=T.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}]),t}(),G=function(t){function e(e,r){var i;return(i=t.call(this,r)||this)._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkeys=void 0,i.type=void 0,i.loader=null,i.keyLoader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new M,i.urlId=0,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.gap=void 0,i.type=e,i}l(e,t);var r=e.prototype;return r.setKeyFormat=function(t){if(this.levelkeys){var e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}},r.abortRequests=function(){var t,e;null==(t=this.loader)||t.abort(),null==(e=this.keyLoader)||e.abort()},r.setElementaryStreamInfo=function(t,e,r,i,n,a){void 0===a&&(a=!1);var s=this.elementaryStreams,o=s[t];o?(o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):s[t]={startPTS:e,endPTS:r,startDTS:i,endDTS:n,partial:a}},r.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[O]=null,t[N]=null,t[U]=null},a(e,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{var e=Object.keys(this.levelkeys);if(1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!E(this.programDateTime))return null;var t=E(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;if(null!=(t=this._decryptdata)&&t.encrypted)return!0;if(this.levelkeys){var e=Object.keys(this.levelkeys),r=e.length;if(r>1||1===r&&this.levelkeys[e[0]].encrypted)return!0}return!1}}]),e}(B),K=function(t){function e(e,r,i,n,a){var s;(s=t.call(this,i)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.stats=new M,s.duration=e.decimalFloatingPoint("DURATION"),s.gap=e.bool("GAP"),s.independent=e.bool("INDEPENDENT"),s.relurl=e.enumeratedString("URI"),s.fragment=r,s.index=n;var o=e.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,a),a&&(s.fragOffset=a.fragOffset+a.duration),s}return l(e,t),a(e,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}]),e}(B),H=function(){function t(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}return t.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!r||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||0===e&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay},a(t,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&E(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return null!=(t=this.fragments)&&t.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),t}();function V(t){return Uint8Array.from(atob(t),(function(t){return t.charCodeAt(0)}))}function Y(t){var e,r,i=t.split(":"),n=null;if("data"===i[0]&&2===i.length){var a=i[1].split(";"),s=a[a.length-1].split(",");if(2===s.length){var o="base64"===s[0],l=s[1];o?(a.splice(-1,1),n=V(l)):(e=W(l).subarray(0,16),(r=new Uint8Array(16)).set(e,16-e.length),n=r)}}return n}function W(t){return Uint8Array.from(unescape(encodeURIComponent(t)),(function(t){return t.charCodeAt(0)}))}var j={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},q="org.w3.clearkey",X="com.apple.streamingkeydelivery",z="com.microsoft.playready",Q="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function $(t){switch(t){case X:return j.FAIRPLAY;case z:return j.PLAYREADY;case Q:return j.WIDEVINE;case q:return j.CLEARKEY}}var J="edef8ba979d64acea3c827dcd51d21ed";function Z(t){switch(t){case j.FAIRPLAY:return X;case j.PLAYREADY:return z;case j.WIDEVINE:return Q;case j.CLEARKEY:return q}}function tt(t){var e=t.drmSystems,r=t.widevineLicenseUrl,i=e?[j.FAIRPLAY,j.WIDEVINE,j.PLAYREADY,j.CLEARKEY].filter((function(t){return!!e[t]})):[];return!i[j.WIDEVINE]&&r&&i.push(j.WIDEVINE),i}var et="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function rt(t,e,r){return Uint8Array.prototype.slice?t.slice(e,r):new Uint8Array(Array.prototype.slice.call(t,e,r))}var it,nt=function(t,e){return e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},at=function(t,e){return e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},st=function(t,e){for(var r=e,i=0;nt(t,e);)i+=10,i+=ot(t,e+6),at(t,e+10)&&(i+=10),e+=i;if(i>0)return t.subarray(r,r+i)},ot=function(t,e){var r=0;return r=(127&t[e])<<21,r|=(127&t[e+1])<<14,r|=(127&t[e+2])<<7,r|=127&t[e+3]},lt=function(t,e){return nt(t,e)&&ot(t,e+6)+10<=t.length-e},ut=function(t){return t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info},ht=function(t){var e=String.fromCharCode(t[0],t[1],t[2],t[3]),r=ot(t,4);return{type:e,size:r,data:t.subarray(10,10+r)}},dt=function(t){for(var e=0,r=[];nt(t,e);){for(var i=ot(t,e+6),n=(e+=10)+i;e+8>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(a);break;case 12:case 13:s=t[h++],u+=String.fromCharCode((31&a)<<6|63&s);break;case 14:s=t[h++],o=t[h++],u+=String.fromCharCode((15&a)<<12|(63&s)<<6|(63&o)<<0)}}return u};function yt(){return it||void 0===self.TextDecoder||(it=new self.TextDecoder("utf-8")),it}var Tt=function(t){for(var e="",r=0;r>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r}function It(t,e){var r=[];if(!e.length)return r;for(var i=t.byteLength,n=0;n1?n+a:i;if(Rt(t.subarray(n+4,n+8))===e[0])if(1===e.length)r.push(t.subarray(n+8,s));else{var o=It(t.subarray(n+8,s),e.slice(1));o.length&&St.apply(r,o)}n=s}return r}function wt(t){var e=[],r=t[0],i=8,n=kt(t,i);i+=4,i+=0===r?8:16,i+=2;var a=t.length+0,s=At(t,i);i+=2;for(var o=0;o>>31)return w.warn("SIDX has hierarchical references (not supported)"),null;var d=kt(t,l);l+=4,e.push({referenceSize:h,subsegmentDuration:d,info:{duration:d/n,start:a,end:a+h-1}}),a+=h,i=l+=4}return{earliestPresentationTime:0,timescale:n,version:r,referencesCount:s,references:e}}function Ct(t){for(var e=[],r=It(t,["moov","trak"]),i=0;i>1&63;return 39===r||40===r}return 6==(31&e)}function Ot(t,e,r,i){var n=Nt(t),a=0;a+=e;for(var s=0,o=0,l=!1,u=0;a=n.length)break;s+=u=n[a++]}while(255===u);o=0;do{if(a>=n.length)break;o+=u=n[a++]}while(255===u);var h=n.length-a;if(!l&&4===s&&a16){for(var T=[],E=0;E<16;E++){var S=n[a++].toString(16);T.push(1==S.length?"0"+S:S),3!==E&&5!==E&&7!==E&&9!==E||T.push("-")}for(var L=o-16,R=new Uint8Array(L),A=0;Ah)break}}function Nt(t){for(var e=t.byteLength,r=[],i=1;i0?(a=new Uint8Array(4),e.length>0&&new DataView(a.buffer).setUint32(0,e.length,!1)):a=new Uint8Array;var l=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(l.buffer).setUint32(0,r.byteLength,!1),function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i>24&255,o[1]=a>>16&255,o[2]=a>>8&255,o[3]=255&a,o.set(t,4),s=0,a=8;s>8*(15-r)&255;return e}(e);return new t(this.method,this.uri,"identity",this.keyFormatVersions,r)}var i=Y(this.uri);if(i)switch(this.keyFormat){case Q:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case z:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=Ut(n,null,i);var a=new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2),s=String.fromCharCode.apply(null,Array.from(a)),o=s.substring(s.indexOf("<"),s.length),l=(new DOMParser).parseFromString(o,"text/xml").getElementsByTagName("KID")[0];if(l){var u=l.childNodes[0]?l.childNodes[0].nodeValue:l.getAttribute("VALUE");if(u){var h=V(u).subarray(0,16);!function(t){var e=function(t,e,r){var i=t[e];t[e]=t[r],t[r]=i};e(t,0,3),e(t,1,2),e(t,4,5),e(t,6,7)}(h),this.keyId=h}}break;default:var d=i.subarray(0,16);if(16!==d.length){var c=new Uint8Array(16);c.set(d,16-d.length),d=c}this.keyId=d}if(!this.keyId||16!==this.keyId.byteLength){var f=Bt[this.uri];if(!f){var g=Object.keys(Bt).length%Number.MAX_SAFE_INTEGER;f=new Uint8Array(16),new DataView(f.buffer,12,4).setUint32(0,g),Bt[this.uri]=f}this.keyId=f}return this},t}(),Kt=/\{\$([a-zA-Z0-9-_]+)\}/g;function Ht(t){return Kt.test(t)}function Vt(t,e,r){if(null!==t.variableList||t.hasVariableRefs)for(var i=r.length;i--;){var n=r[i],a=e[n];a&&(e[n]=Yt(t,a))}}function Yt(t,e){if(null!==t.variableList||t.hasVariableRefs){var r=t.variableList;return e.replace(Kt,(function(e){var i=e.substring(2,e.length-1),n=null==r?void 0:r[i];return void 0===n?(t.playlistParsingError||(t.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'+i+'"')),e):n}))}return e}function Wt(t,e,r){var i,n,a=t.variableList;if(a||(t.variableList=a={}),"QUERYPARAM"in e){i=e.QUERYPARAM;try{var s=new self.URL(r).searchParams;if(!s.has(i))throw new Error('"'+i+'" does not match any query parameter in URI: "'+r+'"');n=s.get(i)}catch(e){t.playlistParsingError||(t.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+e.message))}}else i=e.NAME,n=e.VALUE;i in a?t.playlistParsingError||(t.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'+i+'"')):a[i]=n||""}function jt(t,e,r){var i=e.IMPORT;if(r&&i in r){var n=t.variableList;n||(t.variableList=n={}),n[i]=r[i]}else t.playlistParsingError||(t.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+i+'"'))}function qt(){if("undefined"!=typeof self)return self.MediaSource||self.WebKitMediaSource}var Xt={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dva1:!0,dvav:!0,dvh1:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}},zt=qt();function Qt(t,e){var r;return null!=(r=null==zt?void 0:zt.isTypeSupported((e||"video")+'/mp4;codecs="'+t+'"'))&&r}var $t=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,Jt=/#EXT-X-MEDIA:(.*)/g,Zt=/^#EXT(?:INF|-X-TARGETDURATION):/m,te=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),ee=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),re=function(){function t(){}return t.findGroup=function(t,e){for(var r=0;r2){var r=e.shift()+".";return r+=parseInt(e.shift()).toString(16),r+=("000"+parseInt(e.shift()).toString(16)).slice(-4)}return t},t.resolve=function(t,e){return T.buildAbsoluteURL(e,t,{alwaysNormalize:!0})},t.isMediaPlaylist=function(t){return Zt.test(t)},t.parseMasterPlaylist=function(e,r){var i,n={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Ht(e)},a=[];for($t.lastIndex=0;null!=(i=$t.exec(e));)if(i[1]){var s,o=new P(i[1]);Vt(n,o,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);var l=Yt(n,i[2]),u={attrs:o,bitrate:o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),name:o.NAME,url:t.resolve(l,r)},h=o.decimalResolution("RESOLUTION");h&&(u.width=h.width,u.height=h.height),ae((o.CODECS||"").split(/[ ,]+/).filter((function(t){return t})),u),u.videoCodec&&-1!==u.videoCodec.indexOf("avc1")&&(u.videoCodec=t.convertAVC1ToAVCOTI(u.videoCodec)),null!=(s=u.unknownCodecs)&&s.length||a.push(u),n.levels.push(u)}else if(i[3]){var d=i[3],c=i[4];switch(d){case"SESSION-DATA":var f=new P(c);Vt(n,f,["DATA-ID","LANGUAGE","VALUE","URI"]);var g=f["DATA-ID"];g&&(null===n.sessionData&&(n.sessionData={}),n.sessionData[g]=f);break;case"SESSION-KEY":var v=ie(c,r,n);v.encrypted&&v.isSupported()?(null===n.sessionKeys&&(n.sessionKeys=[]),n.sessionKeys.push(v)):w.warn('[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "'+c+'"');break;case"DEFINE":var m=new P(c);Vt(n,m,["NAME","VALUE","QUERYPARAM"]),Wt(n,m,r);break;case"CONTENT-STEERING":var p=new P(c);Vt(n,p,["SERVER-URI","PATHWAY-ID"]),n.contentSteering={uri:t.resolve(p["SERVER-URI"],r),pathwayId:p["PATHWAY-ID"]||"."};break;case"START":n.startTimeOffset=ne(c)}}var y=a.length>0&&a.length0&&W.bool("CAN-SKIP-DATERANGES"),h.partHoldBack=W.optionalFloat("PART-HOLD-BACK",0),h.holdBack=W.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var j=new P(D);h.partTarget=j.decimalFloatingPoint("PART-TARGET");break;case"PART":var q=h.partList;q||(q=h.partList=[]);var X=g>0?q[q.length-1]:void 0,z=g++,Q=new P(D);Vt(h,Q,["BYTERANGE","URI"]);var $=new K(Q,y,e,z,X);q.push($),y.duration+=$.duration;break;case"PRELOAD-HINT":var J=new P(D);Vt(h,J,["URI"]),h.preloadHint=J;break;case"RENDITION-REPORT":var Z=new P(D);Vt(h,Z,["URI"]),h.renditionReports=h.renditionReports||[],h.renditionReports.push(Z);break;default:w.warn("line parsed but not handled: "+s)}}}p&&!p.relurl?(d.pop(),v-=p.duration,h.partList&&(h.fragmentHint=p)):h.partList&&(oe(y,p),y.cc=m,h.fragmentHint=y,u&&ue(y,u,h));var tt=d.length,et=d[0],rt=d[tt-1];if((v+=h.skippedSegments*h.targetduration)>0&&tt&&rt){h.averagetargetduration=v/tt;var it=rt.sn;h.endSN="initSegment"!==it?it:0,h.live||(rt.endList=!0),et&&(h.startCC=et.cc)}else h.endSN=0,h.startCC=0;return h.fragmentHint&&(v+=h.fragmentHint.duration),h.totalduration=v,h.endCC=m,T>0&&function(t,e){for(var r=t[e],i=e;i--;){var n=t[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(d,T),h},t}();function ie(t,e,r){var i,n,a=new P(t);Vt(r,a,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var s=null!=(i=a.METHOD)?i:"",o=a.URI,l=a.hexadecimalInteger("IV"),u=a.KEYFORMATVERSIONS,h=null!=(n=a.KEYFORMAT)?n:"identity";o&&a.IV&&!l&&w.error("Invalid IV: "+a.IV);var d=o?re.resolve(o,e):"",c=(u||"1").split("/").map(Number).filter(Number.isFinite);return new Gt(s,d,h,c,l)}function ne(t){var e=new P(t).decimalFloatingPoint("TIME-OFFSET");return E(e)?e:null}function ae(t,e){["video","audio","text"].forEach((function(r){var i=t.filter((function(t){return function(t,e){var r=Xt[e];return!!r&&!0===r[t.slice(0,4)]}(t,r)}));if(i.length){var n=i.filter((function(t){return 0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)}));e[r+"Codec"]=n.length>0?n[0]:i[0],t=t.filter((function(t){return-1===i.indexOf(t)}))}})),e.unknownCodecs=t}function se(t,e,r){var i=e[r];i&&(t[r]=i)}function oe(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),E(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function le(t,e,r,i){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=r,t.sn="initSegment",i&&(t.levelkeys=i),t.initSegment=null}function ue(t,e,r){t.levelkeys=e;var i=r.encryptedFragments;i.length&&i[i.length-1].levelkeys===e||!Object.keys(e).some((function(t){return e[t].isCommonEncryption}))||i.push(t)}var he="manifest",de="level",ce="audioTrack",fe="subtitleTrack",ge="main",ve="audio",me="subtitle";function pe(t){switch(t.type){case ce:return ve;case fe:return me;default:return ge}}function ye(t,e){var r=t.url;return void 0!==r&&0!==r.indexOf("data:")||(r=e.url),r}var Te=function(){function t(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}var e=t.prototype;return e.startLoad=function(t){},e.stopLoad=function(){this.destroyInternalLoaders()},e.registerListeners=function(){var t=this.hls;t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.LEVEL_LOADING,this.onLevelLoading,this),t.on(S.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(S.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.unregisterListeners=function(){var t=this.hls;t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.LEVEL_LOADING,this.onLevelLoading,this),t.off(S.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(S.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.createInternalLoader=function(t){var e=this.hls.config,r=e.pLoader,i=e.loader,n=new(r||i)(e);return this.loaders[t.type]=n,n},e.getInternalLoader=function(t){return this.loaders[t.type]},e.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},e.destroyInternalLoaders=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}},e.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},e.onManifestLoading=function(t,e){var r=e.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:he,url:r,deliveryDirectives:null})},e.onLevelLoading=function(t,e){var r=e.id,i=e.level,n=e.url,a=e.deliveryDirectives;this.load({id:r,level:i,responseType:"text",type:de,url:n,deliveryDirectives:a})},e.onAudioTrackLoading=function(t,e){var r=e.id,i=e.groupId,n=e.url,a=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:ce,url:n,deliveryDirectives:a})},e.onSubtitleTrackLoading=function(t,e){var r=e.id,i=e.groupId,n=e.url,a=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:fe,url:n,deliveryDirectives:a})},e.load=function(t){var e,r,i,n=this,a=this.hls.config,s=this.getInternalLoader(t);if(s){var l=s.context;if(l&&l.url===t.url)return void w.trace("[playlist-loader]: playlist request ongoing");w.log("[playlist-loader]: aborting previous loader for type: "+t.type),s.abort()}if(r=t.type===he?a.manifestLoadPolicy.default:o({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(t),null!=(e=t.deliveryDirectives)&&e.part&&(t.type===de&&null!==t.level?i=this.hls.levels[t.level].details:t.type===ce&&null!==t.id?i=this.hls.audioTracks[t.id].details:t.type===fe&&null!==t.id&&(i=this.hls.subtitleTracks[t.id].details),i)){var u=i.partTarget,h=i.targetduration;if(u&&h){var d=1e3*Math.max(3*u,.8*h);r=o({},r,{maxTimeToFirstByteMs:Math.min(d,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(d,r.maxTimeToFirstByteMs)})}}var c=r.errorRetry||r.timeoutRetry||{},f={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},g={onSuccess:function(t,e,r,i){var a=n.getInternalLoader(r);n.resetInternalLoader(r.type);var s=t.data;0===s.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),re.isMediaPlaylist(s)?n.handleTrackOrLevelPlaylist(t,e,r,i||null,a):n.handleMasterPlaylist(t,e,r,i)):n.handleManifestParsingError(t,r,new Error("no EXTM3U delimiter"),i||null,e)},onError:function(t,e,r,i){n.handleNetworkError(e,r,!1,t,i)},onTimeout:function(t,e,r){n.handleNetworkError(e,r,!0,void 0,t)}};s.load(t,f,g)},e.handleMasterPlaylist=function(t,e,r,i){var n=this.hls,a=t.data,s=ye(t,r),o=re.parseMasterPlaylist(a,s);if(o.playlistParsingError)this.handleManifestParsingError(t,r,o.playlistParsingError,i,e);else{var l=o.contentSteering,u=o.levels,h=o.sessionData,d=o.sessionKeys,c=o.startTimeOffset,f=o.variableList;this.variableList=f;var g=re.parseMasterPlaylistMedia(a,s,o),v=g.AUDIO,m=void 0===v?[]:v,p=g.SUBTITLES,y=g["CLOSED-CAPTIONS"];m.length&&(m.some((function(t){return!t.url}))||!u[0].audioCodec||u[0].attrs.AUDIO||(w.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new P({}),bitrate:0,url:""}))),n.trigger(S.MANIFEST_LOADED,{levels:u,audioTracks:m,subtitles:p,captions:y,contentSteering:l,url:s,stats:e,networkDetails:i,sessionData:h,sessionKeys:d,startTimeOffset:c,variableList:f})}},e.handleTrackOrLevelPlaylist=function(t,e,r,i,n){var a=this.hls,s=r.id,o=r.level,l=r.type,u=ye(t,r),h=E(s)?s:0,d=E(o)?o:h,c=pe(r),f=re.parseLevelPlaylist(t.data,u,d,c,h,this.variableList);if(l===he){var g={attrs:new P({}),bitrate:0,details:f,name:"",url:u};a.trigger(S.MANIFEST_LOADED,{levels:[g],audioTracks:[],url:u,stats:e,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),r.levelDetails=f,this.handlePlaylistLoaded(f,t,e,r,i,n)},e.handleManifestParsingError=function(t,e,r,i,n){this.hls.trigger(S.ERROR,{type:L.NETWORK_ERROR,details:R.MANIFEST_PARSING_ERROR,fatal:e.type===he,url:t.url,err:r,error:r,reason:r.message,response:t,context:e,networkDetails:i,stats:n})},e.handleNetworkError=function(t,e,r,n,a){void 0===r&&(r=!1);var s="A network "+(r?"timeout":"error"+(n?" (status "+n.code+")":""))+" occurred while loading "+t.type;t.type===de?s+=": "+t.level+" id: "+t.id:t.type!==ce&&t.type!==fe||(s+=" id: "+t.id+' group-id: "'+t.groupId+'"');var o=new Error(s);w.warn("[playlist-loader]: "+s);var l=R.UNKNOWN,u=!1,h=this.getInternalLoader(t);switch(t.type){case he:l=r?R.MANIFEST_LOAD_TIMEOUT:R.MANIFEST_LOAD_ERROR,u=!0;break;case de:l=r?R.LEVEL_LOAD_TIMEOUT:R.LEVEL_LOAD_ERROR,u=!1;break;case ce:l=r?R.AUDIO_TRACK_LOAD_TIMEOUT:R.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case fe:l=r?R.SUBTITLE_TRACK_LOAD_TIMEOUT:R.SUBTITLE_LOAD_ERROR,u=!1}h&&this.resetInternalLoader(t.type);var d={type:L.NETWORK_ERROR,details:l,fatal:u,url:t.url,loader:h,context:t,error:o,networkDetails:e,stats:a};if(n){var c=(null==e?void 0:e.url)||t.url;d.response=i({url:c,data:void 0},n)}this.hls.trigger(S.ERROR,d)},e.handlePlaylistLoaded=function(t,e,r,i,n,a){var s=this.hls,o=i.type,l=i.level,u=i.id,h=i.groupId,d=i.deliveryDirectives,c=ye(e,i),f=pe(i),g="number"==typeof i.level&&f===ge?l:void 0;if(t.fragments.length){t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));var v=t.playlistParsingError;if(v)s.trigger(S.ERROR,{type:L.NETWORK_ERROR,details:R.LEVEL_PARSING_ERROR,fatal:!1,url:c,error:v,reason:v.message,response:e,context:i,level:g,parent:f,networkDetails:n,stats:r});else switch(t.live&&a&&(a.getCacheAge&&(t.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),o){case he:case de:s.trigger(S.LEVEL_LOADED,{details:t,level:g||0,id:u||0,stats:r,networkDetails:n,deliveryDirectives:d});break;case ce:s.trigger(S.AUDIO_TRACK_LOADED,{details:t,id:u||0,groupId:h||"",stats:r,networkDetails:n,deliveryDirectives:d});break;case fe:s.trigger(S.SUBTITLE_TRACK_LOADED,{details:t,id:u||0,groupId:h||"",stats:r,networkDetails:n,deliveryDirectives:d})}}else{var m=new Error("No Segments found in Playlist");s.trigger(S.ERROR,{type:L.NETWORK_ERROR,details:R.LEVEL_EMPTY_ERROR,fatal:!1,url:c,error:m,reason:m.message,response:e,context:i,level:g,parent:f,networkDetails:n,stats:r})}},t}();function Ee(t,e){var r;try{r=new Event("addtrack")}catch(t){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)}function Se(t,e){var r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw new Error("addCue is failed for: "+e)}catch(r){w.debug("[texttrack-utils]: "+r);try{var i=new self.TextTrackCue(e.startTime,e.endTime,e.text);i.id=e.id,t.addCue(i)}catch(t){w.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+t)}}"disabled"===r&&(t.mode=r)}function Le(t){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(var r=t.cues.length;r--;)t.removeCue(t.cues[r]);"disabled"===e&&(t.mode=e)}function Re(t,e,r,i){var n=t.mode;if("disabled"===n&&(t.mode="hidden"),t.cues&&t.cues.length>0)for(var a=function(t,e,r){var i=[],n=function(t,e){if(et[r].endTime)return-1;for(var i=0,n=r;i<=n;){var a=Math.floor((n+i)/2);if(et[a].startTime&&i-1)for(var a=n,s=t.length;a=e&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}(t.cues,e,r),s=0;sIe&&(d=Ie),d-h<=0&&(d=h+.25);for(var c=0;ce.startDate&&t.push(i),t}),[]).sort((function(t,e){return t.startDate.getTime()-e.startDate.getTime()}))[0];g&&(h=we(g.startDate,c),l=!0)}for(var m,p,y=Object.keys(e.attr),T=0;T.05&&this.forwardBufferLength>1){var u=Math.min(2,Math.max(1,a)),h=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;t.playbackRate=Math.min(u,Math.max(1,h))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}}}}},e.estimateLiveEdge=function(){var t=this.levelDetails;return null===t?null:t.edge+t.age},e.computeLatency=function(){var t=this.estimateLiveEdge();return null===t?null:t-this.currentTime},a(t,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config,e=this.levelDetails;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(null===t)return null;var e=t.holdBack,r=t.partHoldBack,i=t.targetduration,n=this.config,a=n.liveSyncDuration,s=n.liveSyncDurationCount,o=n.lowLatencyMode,l=this.hls.userConfig,u=o&&r||e;(l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==a?a:s*i);var h=i;return u+Math.min(1*this.stallCount,h)}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),e=this.targetLatency,r=this.levelDetails;if(null===t||null===e||null===r)return null;var i=r.edge,n=t-e-this.edgeStalled,a=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),s)}},{key:"drift",get:function(){var t=this.levelDetails;return null===t?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;if(null===t)return 0;var e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-e,0)}},{key:"forwardBufferLength",get:function(){var t=this.media,e=this.levelDetails;if(!t||!e)return 0;var r=t.buffered.length;return(r?t.buffered.end(r-1):e.edge)-this.currentTime}}]),t}(),Pe=["NONE","TYPE-0","TYPE-1",null],xe="",Fe="YES",Me="v2",Oe=function(){function t(t,e,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=r}return t.prototype.addDirectives=function(t){var e=new self.URL(t);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href},t}(),Ne=function(){function t(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter((function(t){return t})).join(",").replace(/\.[^.,]+/g,"")}return t.prototype.addFallback=function(t){this.url.push(t.url),this._attrs.push(t.attrs)},a(t,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"attrs",get:function(){return this._attrs[this._urlId]}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(t){var e=t%this.url.length;this._urlId!==e&&(this.fragmentError=0,this.loadError=0,this.details=void 0,this._urlId=e)}},{key:"audioGroupId",get:function(){var t;return null==(t=this.audioGroupIds)?void 0:t[this.urlId]}},{key:"textGroupId",get:function(){var t;return null==(t=this.textGroupIds)?void 0:t[this.urlId]}}]),t}();function Ue(t,e){var r=e.startPTS;if(E(r)){var i,n=0;e.sn>t.sn?(n=r-t.start,i=t):(n=t.start-r,i=e),i.duration!==n&&(i.duration=n)}else e.sn>t.sn?t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration:e.start=Math.max(t.start-e.duration,0)}function Be(t,e,r,i,n,a){i-r<=0&&(w.warn("Fragment should have a positive duration",e),i=r+e.duration,a=n+e.duration);var s=r,o=i,l=e.startPTS,u=e.endPTS;if(E(l)){var h=Math.abs(l-r);E(e.deltaPTS)?e.deltaPTS=Math.max(h,e.deltaPTS):e.deltaPTS=h,s=Math.max(r,l),r=Math.min(r,l),n=Math.min(n,e.startDTS),o=Math.min(i,u),i=Math.max(i,u),a=Math.max(a,e.endDTS)}var d=r-e.start;0!==e.start&&(e.start=r),e.duration=i-e.start,e.startPTS=r,e.maxStartPTS=s,e.startDTS=n,e.endPTS=i,e.minEndPTS=o,e.endDTS=a;var c,f=e.sn;if(!t||ft.endSN)return 0;var g=f-t.startSN,v=t.fragments;for(v[g]=e,c=g;c>0;c--)Ue(v[c],v[c-1]);for(c=g;c=0;n--){var a=i[n].initSegment;if(a){r=a;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var s,l,u,h,d,c=0;if(function(t,e,r){for(var i=e.skippedSegments,n=Math.max(t.startSN,e.startSN)-e.startSN,a=(t.fragmentHint?1:0)+(i?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,s=e.startSN-t.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=n;u<=a;u++){var h=l[s+u],d=o[u];i&&!d&&u=i.length||He(e,i[r].start)}function He(t,e){if(e){for(var r=t.fragments,i=t.skippedSegments;i499)}(i)||!!r)}var Qe=function(t,e){for(var r=0,i=t.length-1,n=null,a=null;r<=i;){var s=e(a=t[n=(r+i)/2|0]);if(s>0)r=n+1;else{if(!(s<0))return a;i=n-1}}return null};function $e(t,e,r,i){void 0===r&&(r=0),void 0===i&&(i=0);var n=null;if(t?n=e[t.sn-e[0].sn+1]||null:0===r&&0===e[0].start&&(n=e[0]),n&&0===Je(r,i,n))return n;var a=Qe(e,Je.bind(null,r,i));return!a||a===t&&n?n:a}function Je(t,e,r){if(void 0===t&&(t=0),void 0===e&&(e=0),r.start<=t&&r.start+r.duration>t)return 0;var i=Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=t?1:r.start-i>t&&r.start?-1:0}function Ze(t,e,r){var i=1e3*Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>t}var tr,er=3e5,rr=0,ir=2,nr=5,ar=0,sr=1,or=2,lr=function(){function t(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=w.log.bind(w,"[info]:"),this.warn=w.warn.bind(w,"[warning]:"),this.error=w.error.bind(w,"[error]:"),this.registerListeners()}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(S.ERROR,this.onError,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.LEVEL_UPDATED,this.onLevelUpdated,this)},e.unregisterListeners=function(){var t=this.hls;t&&(t.off(S.ERROR,this.onError,this),t.off(S.ERROR,this.onErrorOut,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.LEVEL_UPDATED,this.onLevelUpdated,this))},e.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},e.startLoad=function(t){this.playlistError=0},e.stopLoad=function(){},e.getVariantLevelIndex=function(t){return(null==t?void 0:t.type)===ge?t.level:this.hls.loadLevel},e.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},e.onLevelUpdated=function(){this.playlistError=0},e.onError=function(t,e){var r,i;if(!e.fatal){var n=this.hls,a=e.context;switch(e.details){case R.FRAG_LOAD_ERROR:case R.FRAG_LOAD_TIMEOUT:case R.KEY_LOAD_ERROR:case R.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case R.FRAG_PARSING_ERROR:if(null!=(r=e.frag)&&r.gap)return void(e.errorAction={action:rr,flags:ar});case R.FRAG_GAP:case R.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=ir);case R.LEVEL_EMPTY_ERROR:case R.LEVEL_PARSING_ERROR:var s,o,l=e.parent===ge?e.level:n.loadLevel;return void(e.details===R.LEVEL_EMPTY_ERROR&&null!=(s=e.context)&&null!=(o=s.levelDetails)&&o.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,l):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,l)));case R.LEVEL_LOAD_ERROR:case R.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,a.level)));case R.AUDIO_TRACK_LOAD_ERROR:case R.AUDIO_TRACK_LOAD_TIMEOUT:case R.SUBTITLE_LOAD_ERROR:case R.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var u=n.levels[n.loadLevel];if(u&&(a.type===ce&&a.groupId===u.audioGroupId||a.type===fe&&a.groupId===u.textGroupId))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,n.loadLevel),e.errorAction.action=ir,void(e.errorAction.flags=sr)}return;case R.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var h=n.levels[n.loadLevel],d=null==h?void 0:h.attrs["HDCP-LEVEL"];return void(d&&(e.errorAction={action:ir,flags:or,hdcpLevel:d}));case R.BUFFER_ADD_CODEC_ERROR:case R.REMUX_ALLOC_ERROR:return void(e.errorAction=this.getLevelSwitchAction(e,null!=(i=e.level)?i:n.loadLevel));case R.INTERNAL_EXCEPTION:case R.BUFFER_APPENDING_ERROR:case R.BUFFER_APPEND_ERROR:case R.BUFFER_FULL_ERROR:case R.LEVEL_SWITCH_ERROR:case R.BUFFER_STALLED_ERROR:case R.BUFFER_SEEK_OVER_HOLE:case R.BUFFER_NUDGE_ON_STALL:return void(e.errorAction={action:rr,flags:ar})}if(e.type===L.KEY_SYSTEM_ERROR){var c=this.getVariantLevelIndex(e.frag);return e.levelRetry=!1,void(e.errorAction=this.getLevelSwitchAction(e,c))}}},e.getPlaylistRetryOrSwitchAction=function(t,e){var r,i=je(this.hls.config.playlistLoadPolicy,t),n=this.playlistError++,a=null==(r=t.response)?void 0:r.code;if(ze(i,n,We(t),a))return{action:nr,flags:ar,retryConfig:i,retryCount:n};var s=this.getLevelSwitchAction(t,e);return i&&(s.retryConfig=i,s.retryCount=n),s},e.getFragRetryOrSwitchAction=function(t){var e=this.hls,r=this.getVariantLevelIndex(t.frag),i=e.levels[r],n=e.config,a=n.fragLoadPolicy,s=n.keyLoadPolicy,o=je(t.details.startsWith("key")?s:a,t),l=e.levels.reduce((function(t,e){return t+e.fragmentError}),0);if(i){var u;t.details!==R.FRAG_GAP&&i.fragmentError++;var h=null==(u=t.response)?void 0:u.code;if(ze(o,l,We(t),h))return{action:nr,flags:ar,retryConfig:o,retryCount:l}}var d=this.getLevelSwitchAction(t,r);return o&&(d.retryConfig=o,d.retryCount=l),d},e.getLevelSwitchAction=function(t,e){var r=this.hls;null==e&&(e=r.loadLevel);var i=this.hls.levels[e];if(i&&(i.loadError++,r.autoLevelEnabled)){for(var n,a,s=-1,o=r.levels,l=r.loadLevel,u=r.minAutoLevel,h=r.maxAutoLevel,d=null==(n=t.frag)?void 0:n.type,c=null!=(a=t.context)?a:{},f=c.type,g=c.groupId,v=o.length;v--;){var m=(v+l)%o.length;if(m!==l&&m>=u&&m<=h&&0===o[m].loadError){var p=o[m];if(t.details===R.FRAG_GAP&&t.frag){var y=o[m].details;if(y){var T=$e(t.frag,y.fragments,t.frag.start);if(null!=T&&T.gap)continue}}else{if(f===ce&&g===p.audioGroupId||f===fe&&g===p.textGroupId)continue;if(d===ve&&i.audioGroupId===p.audioGroupId||d===me&&i.textGroupId===p.textGroupId)continue}s=m;break}}if(s>-1&&r.loadLevel!==s)return t.levelRetry=!0,this.playlistError=0,{action:ir,flags:ar,nextAutoLevel:s}}return{action:ir,flags:sr}},e.onErrorOut=function(t,e){var r;switch(null==(r=e.errorAction)?void 0:r.action){case rr:break;case ir:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===R.FRAG_GAP||(e.fatal=!0)}e.fatal&&this.hls.stopLoad()},e.sendAlternateToPenaltyBox=function(t){var e=this.hls,r=t.errorAction;if(r){var i=r.flags,n=r.hdcpLevel,a=r.nextAutoLevel;switch(i){case ar:this.switchLevel(t,a);break;case sr:r.resolved||(r.resolved=this.redundantFailover(t));break;case or:n&&(e.maxHdcpLevel=Pe[Pe.indexOf(n)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+e.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(t,a)}},e.switchLevel=function(t,e){void 0!==e&&t.errorAction&&(this.warn("switching to level "+e+" after "+t.details),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},e.redundantFailover=function(t){var e=this,r=this.hls,i=this.penalizedRenditions,n=t.parent===ge?t.level:r.loadLevel,a=r.levels[n],s=a.url.length,o=t.frag?t.frag.urlId:a.urlId;a.urlId!==o||t.frag&&!a.details||this.penalizeRendition(a,t);for(var l=function(){var l=(o+u)%s,h=i[l];if(!h||function(t,e,r){if(performance.now()-t.lastErrorPerfMs>er)return!0;var i=t.details;if(e.details===R.FRAG_GAP&&i&&e.frag){var n=e.frag.start,a=$e(null,i.fragments,n);if(a&&!a.gap)return!0}if(r&&t.errors.length3*i.targetduration)return!0}return!1}(h,t,i[o]))return e.warn("Switching to Redundant Stream "+(l+1)+"/"+s+': "'+a.url[l]+'" after '+t.details),e.playlistError=0,r.levels.forEach((function(t){t.urlId=l})),r.nextLoadLevel=n,{v:!0}},u=1;u=0&&h>e.partTarget&&(u+=1)}return new Oe(l,u>=0?u:void 0,xe)}}},e.loadPlaylist=function(t){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},e.shouldLoadPlaylist=function(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)},e.shouldReloadPlaylist=function(t){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(t)},e.playlistLoaded=function(t,e,r){var i=this,n=e.details,a=e.stats,s=self.performance.now(),o=a.loading.first?Math.max(0,s-a.loading.first):0;if(n.advancedDateTime=Date.now()-o,n.live||null!=r&&r.live){if(n.reloaded(r),r&&this.log("live playlist "+t+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED")),r&&n.fragments.length>0&&Ge(r,n),!this.canLoad||!n.live)return;var l,u=void 0,h=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var d=this.hls.config.lowLatencyMode,c=n.lastPartSn,f=n.endSN,g=n.lastPartIndex,v=c===f;-1!==g?(u=v?f+1:c,h=v?d?0:g:g+1):u=f+1;var m=n.age,p=m+n.ageHeader,y=Math.min(p-n.partTarget,1.5*n.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+n.age),y=0;else{var T=Math.floor(y/n.targetduration);u+=T,void 0!==h&&(h+=Math.round(y%n.targetduration/n.partTarget)),this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+m.toFixed(2)+"s goal: "+y+" skip sn "+T+" to part "+h)}n.tuneInGoal=y}if(l=this.getDeliveryDirectives(n,e.deliveryDirectives,u,h),d||!v)return void this.loadPlaylist(l)}else(n.canBlockReload||n.canSkipUntil)&&(l=this.getDeliveryDirectives(n,e.deliveryDirectives,u,h));var E=this.hls.mainForwardBufferInfo,S=E?E.end-E.len:0,L=function(t,e){void 0===e&&(e=1/0);var r=1e3*t.targetduration;if(t.updated){var i=t.fragments;if(i.length&&4*r>e){var n=1e3*i[i.length-1].duration;nthis.requestScheduled+L&&(this.requestScheduled=a.loading.start),void 0!==u&&n.canBlockReload?this.requestScheduled=a.loading.first+L-(1e3*n.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+L=u.maxNumRetry)return!1;if(i&&null!=(d=t.context)&&d.deliveryDirectives)this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var c=qe(u,l);this.timer=self.setTimeout((function(){return e.loadPlaylist()}),c),this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+r+'" in '+c+"ms")}t.levelRetry=!0,n.resolved=!0}return h},t}(),hr=function(t){function e(e,r){var i;return(i=t.call(this,e,"[level-controller]")||this)._levels=[],i._firstLevel=-1,i._startLevel=void 0,i.currentLevel=null,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.steering=void 0,i.onParsedComplete=void 0,i.steering=r,i._registerListeners(),i}l(e,t);var r=e.prototype;return r._registerListeners=function(){var t=this.hls;t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(S.LEVEL_LOADED,this.onLevelLoaded,this),t.on(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(S.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(S.FRAG_LOADED,this.onFragLoaded,this),t.on(S.ERROR,this.onError,this)},r._unregisterListeners=function(){var t=this.hls;t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(S.LEVEL_LOADED,this.onLevelLoaded,this),t.off(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(S.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(S.FRAG_LOADED,this.onFragLoaded,this),t.off(S.ERROR,this.onError,this)},r.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),t.prototype.destroy.call(this)},r.startLoad=function(){this._levels.forEach((function(t){t.loadError=0,t.fragmentError=0})),t.prototype.startLoad.call(this)},r.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[]},r.onManifestLoading=function(t,e){this.resetLevels()},r.onManifestLoaded=function(t,e){var r,i=[],n={};e.levels.forEach((function(t){var e,a=t.attrs;-1!==(null==(e=t.audioCodec)?void 0:e.indexOf("mp4a.40.34"))&&(tr||(tr=/chrome|firefox/i.test(navigator.userAgent)),tr&&(t.audioCodec=void 0));var s=a.AUDIO,o=a.CODECS,l=a["FRAME-RATE"],u=a["PATHWAY-ID"],h=a.RESOLUTION,d=a.SUBTITLES,c=(u||".")+"-"+t.bitrate+"-"+h+"-"+l+"-"+o;(r=n[c])?r.addFallback(t):(r=new Ne(t),n[c]=r,i.push(r)),dr(r,"audio",s),dr(r,"text",d)})),this.filterAndSortMediaOptions(i,e)},r.filterAndSortMediaOptions=function(t,e){var r=this,i=[],n=[],a=!1,s=!1,o=!1,l=t.filter((function(t){var e=t.audioCodec,r=t.videoCodec,i=t.width,n=t.height,l=t.unknownCodecs;return a||(a=!(!i||!n)),s||(s=!!r),o||(o=!!e),!(null!=l&&l.length)&&(!e||Qt(e,"audio"))&&(!r||Qt(r,"video"))}));if((a||s)&&o&&(l=l.filter((function(t){var e=t.videoCodec,r=t.width,i=t.height;return!!e||!(!r||!i)}))),0!==l.length){e.audioTracks&&cr(i=e.audioTracks.filter((function(t){return!t.audioCodec||Qt(t.audioCodec,"audio")}))),e.subtitles&&cr(n=e.subtitles);var u=l.slice(0);l.sort((function(t,e){return t.attrs["HDCP-LEVEL"]!==e.attrs["HDCP-LEVEL"]?(t.attrs["HDCP-LEVEL"]||"")>(e.attrs["HDCP-LEVEL"]||"")?1:-1:t.bitrate!==e.bitrate?t.bitrate-e.bitrate:t.attrs["FRAME-RATE"]!==e.attrs["FRAME-RATE"]?t.attrs.decimalFloatingPoint("FRAME-RATE")-e.attrs.decimalFloatingPoint("FRAME-RATE"):t.attrs.SCORE!==e.attrs.SCORE?t.attrs.decimalFloatingPoint("SCORE")-e.attrs.decimalFloatingPoint("SCORE"):a&&t.height!==e.height?t.height-e.height:0}));var h=u[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==u.length)for(var d=0;d1&&void 0!==e?(n.url=n.url.filter(i),n.audioGroupIds&&(n.audioGroupIds=n.audioGroupIds.filter(i)),n.textGroupIds&&(n.textGroupIds=n.textGroupIds.filter(i)),n.urlId=0,!0):(r.steering&&r.steering.removeLevel(n),!1))}));this.hls.trigger(S.LEVELS_UPDATED,{levels:n})},r.onLevelsUpdated=function(t,e){var r=e.levels;r.forEach((function(t,e){var r=t.details;null!=r&&r.fragments&&r.fragments.forEach((function(t){t.level=e}))})),this._levels=r},a(e,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var e=this._levels;if(0!==e.length){if(t<0||t>=e.length){var r=new Error("invalid level idx"),i=t<0;if(this.hls.trigger(S.ERROR,{type:L.OTHER_ERROR,details:R.LEVEL_SWITCH_ERROR,level:t,fatal:i,error:r,reason:r.message}),i)return;t=Math.min(t,e.length-1)}var n=this.currentLevelIndex,a=this.currentLevel,s=a?a.attrs["PATHWAY-ID"]:void 0,l=e[t],u=l.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=l,n!==t||!l.details||!a||s!==u){this.log("Switching to level "+t+(u?" with Pathway "+u:"")+" from level "+n+(s?" with Pathway "+s:""));var h=o({},l,{level:t,maxBitrate:l.maxBitrate,attrs:l.attrs,uri:l.uri,urlId:l.urlId});delete h._attrs,delete h._urlId,this.hls.trigger(S.LEVEL_SWITCHING,h);var d=l.details;if(!d||d.live){var c=this.switchParams(l.uri,null==a?void 0:a.details);this.loadPlaylist(c)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}}]),e}(ur);function dr(t,e,r){r&&("audio"===e?(t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds[t.url.length-1]=r):"text"===e&&(t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds[t.url.length-1]=r))}function cr(t){var e={};t.forEach((function(t){var r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++}))}var fr="NOT_LOADED",gr="APPENDING",vr="PARTIAL",mr="OK",pr=function(){function t(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}var e=t.prototype;return e._registerListeners=function(){var t=this.hls;t.on(S.BUFFER_APPENDED,this.onBufferAppended,this),t.on(S.FRAG_BUFFERED,this.onFragBuffered,this),t.on(S.FRAG_LOADED,this.onFragLoaded,this)},e._unregisterListeners=function(){var t=this.hls;t.off(S.BUFFER_APPENDED,this.onBufferAppended,this),t.off(S.FRAG_BUFFERED,this.onFragBuffered,this),t.off(S.FRAG_LOADED,this.onFragLoaded,this)},e.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},e.getAppendedFrag=function(t,e){var r=this.activePartLists[e];if(r)for(var i=r.length;i--;){var n=r[i];if(!n)break;var a=n.end;if(n.start<=t&&null!==a&&t<=a)return n}return this.getBufferedFrag(t,e)},e.getBufferedFrag=function(t,e){for(var r=this.fragments,i=Object.keys(r),n=i.length;n--;){var a=r[i[n]];if((null==a?void 0:a.body.type)===e&&a.buffered){var s=a.body;if(s.start<=t&&t<=s.end)return s}}return null},e.detectEvictedFragments=function(t,e,r,i){var n=this;this.timeRanges&&(this.timeRanges[t]=e);var a=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach((function(i){var s=n.fragments[i];if(s&&!(a>=s.body.sn))if(s.buffered||s.loaded){var o=s.range[t];o&&o.time.some((function(t){var r=!n.isTimeBuffered(t.startPTS,t.endPTS,e);return r&&n.removeFragment(s.body),r}))}else s.body.type===r&&n.removeFragment(s.body)}))},e.detectPartialFragments=function(t){var e=this,r=this.timeRanges,i=t.frag,n=t.part;if(r&&"initSegment"!==i.sn){var a=Tr(i),s=this.fragments[a];if(!(!s||s.buffered&&i.gap)){var o=!i.relurl;Object.keys(r).forEach((function(t){var a=i.elementaryStreams[t];if(a){var l=r[t],u=o||!0===a.partial;s.range[t]=e.getBufferedTimes(i,n,u,l)}})),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,(s.body.endList=i.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),yr(s)||this.removeParts(i.sn-1,i.type)):this.removeFragment(s.body)}}},e.removeParts=function(t,e){var r=this.activePartLists[e];r&&(this.activePartLists[e]=r.filter((function(e){return e.fragment.sn>=t})))},e.fragBuffered=function(t,e){var r=Tr(t),i=this.fragments[r];!i&&e&&(i=this.fragments[r]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)},e.getBufferedTimes=function(t,e,r,i){for(var n={time:[],partial:r},a=t.start,s=t.end,o=t.minEndPTS||s,l=t.maxStartPTS||a,u=0;u=h&&o<=d){n.time.push({startPTS:Math.max(a,i.start(u)),endPTS:Math.min(s,i.end(u))});break}if(ah)n.partial=!0,n.time.push({startPTS:Math.max(a,i.start(u)),endPTS:Math.min(s,i.end(u))});else if(s<=h)break}return n},e.getPartialFragment=function(t){var e,r,i,n=null,a=0,s=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach((function(l){var u=o[l];u&&yr(u)&&(r=u.body.start-s,i=u.body.end+s,t>=r&&t<=i&&(e=Math.min(t-r,i-t),a<=e&&(n=u.body,a=e)))})),n},e.isEndListAppended=function(t){var e=this.endListFragments[t];return void 0!==e&&(e.buffered||yr(e))},e.getState=function(t){var e=Tr(t),r=this.fragments[e];return r?r.buffered?yr(r)?vr:mr:gr:fr},e.isTimeBuffered=function(t,e,r){for(var i,n,a=0;a=i&&e<=n)return!0;if(e<=i)return!1}return!1},e.onFragLoaded=function(t,e){var r=e.frag,i=e.part;if("initSegment"!==r.sn&&!r.bitrateTest){var n=i?null:e,a=Tr(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}},e.onBufferAppended=function(t,e){var r=this,i=e.frag,n=e.part,a=e.timeRanges;if("initSegment"!==i.sn){var s=i.type;if(n){var o=this.activePartLists[s];o||(this.activePartLists[s]=o=[]),o.push(n)}this.timeRanges=a,Object.keys(a).forEach((function(t){var e=a[t];r.detectEvictedFragments(t,e,s,n)}))}},e.onFragBuffered=function(t,e){this.detectPartialFragments(e)},e.hasFragment=function(t){var e=Tr(t);return!!this.fragments[e]},e.hasParts=function(t){var e;return!(null==(e=this.activePartLists[t])||!e.length)},e.removeFragmentsInRange=function(t,e,r,i,n){var a=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach((function(s){var o=a.fragments[s];if(o){var l=o.body;l.type!==r||i&&!l.gap||l.startt&&(o.buffered||n)&&a.removeFragment(l)}}))},e.removeFragment=function(t){var e=Tr(t);t.stats.loaded=0,t.clearElementaryStreamInfo();var r=this.activePartLists[t.type];if(r){var i=t.sn;this.activePartLists[t.type]=r.filter((function(t){return t.fragment.sn!==i}))}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]},e.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},t}();function yr(t){var e,r,i;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(r=t.range.audio)?void 0:r.partial)||(null==(i=t.range.audiovideo)?void 0:i.partial))}function Tr(t){return t.type+"_"+t.level+"_"+t.urlId+"_"+t.sn}var Er=Math.pow(2,17),Sr=function(){function t(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var e=t.prototype;return e.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},e.abort=function(){this.loader&&this.loader.abort()},e.load=function(t,e){var r=this,n=t.url;if(!n)return Promise.reject(new Ar({type:L.NETWORK_ERROR,details:R.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a "+(n?"part list":"url")),networkDetails:null}));this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(l,u){if(r.loader&&r.loader.destroy(),t.gap){if(t.tagList.some((function(t){return"GAP"===t[0]})))return void u(Rr(t));t.gap=!1}var h=r.loader=t.loader=s?new s(a):new o(a),d=Lr(t),c=Xe(a.fragLoadPolicy.default),f={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===t.sn?1/0:Er};t.stats=h.stats,h.load(d,f,{onSuccess:function(e,i,n,a){r.resetLoader(t,h);var s=e.data;n.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(s.slice(0,16)),s=s.slice(16)),l({frag:t,part:null,payload:s,networkDetails:a})},onError:function(e,a,s,o){r.resetLoader(t,h),u(new Ar({type:L.NETWORK_ERROR,details:R.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:i({url:n,data:void 0},e),error:new Error("HTTP Error "+e.code+" "+e.text),networkDetails:s,stats:o}))},onAbort:function(e,i,n){r.resetLoader(t,h),u(new Ar({type:L.NETWORK_ERROR,details:R.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:n,stats:e}))},onTimeout:function(e,i,n){r.resetLoader(t,h),u(new Ar({type:L.NETWORK_ERROR,details:R.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error("Timeout after "+f.timeout+"ms"),networkDetails:n,stats:e}))},onProgress:function(r,i,n,a){e&&e({frag:t,part:null,payload:n,networkDetails:a})}})}))},e.loadPart=function(t,e,r){var n=this;this.abort();var a=this.config,s=a.fLoader,o=a.loader;return new Promise((function(l,u){if(n.loader&&n.loader.destroy(),t.gap||e.gap)u(Rr(t,e));else{var h=n.loader=t.loader=s?new s(a):new o(a),d=Lr(t,e),c=Xe(a.fragLoadPolicy.default),f={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Er};e.stats=h.stats,h.load(d,f,{onSuccess:function(i,a,s,o){n.resetLoader(t,h),n.updateStatsFromPart(t,e);var u={frag:t,part:e,payload:i.data,networkDetails:o};r(u),l(u)},onError:function(r,a,s,o){n.resetLoader(t,h),u(new Ar({type:L.NETWORK_ERROR,details:R.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:i({url:d.url,data:void 0},r),error:new Error("HTTP Error "+r.code+" "+r.text),networkDetails:s,stats:o}))},onAbort:function(r,i,a){t.stats.aborted=e.stats.aborted,n.resetLoader(t,h),u(new Ar({type:L.NETWORK_ERROR,details:R.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:a,stats:r}))},onTimeout:function(r,i,a){n.resetLoader(t,h),u(new Ar({type:L.NETWORK_ERROR,details:R.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error("Timeout after "+f.timeout+"ms"),networkDetails:a,stats:r}))}})}}))},e.updateStatsFromPart=function(t,e){var r=t.stats,i=e.stats,n=i.total;if(r.loaded+=i.loaded,n){var a=Math.round(t.duration/e.duration),s=Math.min(Math.round(r.loaded/n),a),o=(a-s)*Math.round(r.loaded/s);r.total=r.loaded+o}else r.total=Math.max(r.loaded,r.total);var l=r.loading,u=i.loading;l.start?l.first+=u.first-u.start:(l.start=u.start,l.first=u.first),l.end=u.end},e.resetLoader=function(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()},t}();function Lr(t,e){void 0===e&&(e=null);var r=e||t,i={frag:t,part:e,responseType:"arraybuffer",url:r.url,headers:{},rangeStart:0,rangeEnd:0},n=r.byteRangeStartOffset,a=r.byteRangeEndOffset;if(E(n)&&E(a)){var s,o=n,l=a;if("initSegment"===t.sn&&"AES-128"===(null==(s=t.decryptdata)?void 0:s.method)){var u=a-n;u%16&&(l=a+(16-u%16)),0!==n&&(i.resetIV=!0,o=n-16)}i.rangeStart=o,i.rangeEnd=l}return i}function Rr(t,e){var r=new Error("GAP "+(t.gap?"tag":"attribute")+" found"),i={type:L.MEDIA_ERROR,details:R.FRAG_GAP,fatal:!1,frag:t,error:r,networkDetails:null};return e&&(i.part=e),(e||t).stats.aborted=!0,new Ar(i)}var Ar=function(t){function e(e){var r;return(r=t.call(this,e.error.message)||this).data=void 0,r.data=e,r}return l(e,t),e}(f(Error)),kr=function(){function t(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}var e=t.prototype;return e.abort=function(t){for(var e in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[e].loader;if(r){if(t&&t!==r.context.frag.type)return;r.abort()}}},e.detach=function(){for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}},e.destroy=function(){for(var t in this.detach(),this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}},e.createKeyLoadError=function(t,e,r,i,n){return void 0===e&&(e=R.KEY_LOAD_ERROR),new Ar({type:L.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:n,error:r,networkDetails:i})},e.loadClear=function(t,e){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=t.sn,n=t.cc,a=function(){var t=e[s];if(n<=t.cc&&("initSegment"===i||"initSegment"===t.sn||i1&&this.tickImmediate(),this._tickCallCount=0)},e.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},e.doTick=function(){},t}(),Dr={length:0,start:function(){return 0},end:function(){return 0}},Ir=function(){function t(){}return t.isBuffered=function(e,r){try{if(e)for(var i=t.getBuffered(e),n=0;n=i.start(n)&&r<=i.end(n))return!0}catch(t){}return!1},t.bufferInfo=function(e,r,i){try{if(e){var n,a=t.getBuffered(e),s=[];for(n=0;ns&&(i[a-1].end=t[n].end):i.push(t[n])}else i.push(t[n])}else i=t;for(var o,l=0,u=e,h=e,d=0;d=c&&er.startCC||t&&t.cc>>8^255&m^99,t[f]=m,e[m]=f;var p=c[f],y=c[p],T=c[y],E=257*c[m]^16843008*m;i[f]=E<<24|E>>>8,n[f]=E<<16|E>>>16,a[f]=E<<8|E>>>24,s[f]=E,E=16843009*T^65537*y^257*p^16843008*f,l[m]=E<<24|E>>>8,u[m]=E<<16|E>>>16,h[m]=E<<8|E>>>24,d[m]=E,f?(f=p^c[c[c[T^p]]],g^=c[c[g]]):f=g=1}},e.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),r=!0,i=0;is.end){var h=a>u;(a0&&a&&a.key&&a.iv&&"AES-128"===a.method){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch((function(e){throw i.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:R.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e})).then((function(r){var n=self.performance.now();return i.trigger(S.FRAG_DECRYPTED,{frag:t,payload:r,stats:{tstart:s,tdecrypt:n}}),e.payload=r,e}))}return e})).then((function(i){var n=r.fragCurrent,a=r.hls;if(!r.levels)throw new Error("init load aborted, missing levels");var s=t.stats;r.state=Kr,e.fragmentError=0,t.data=new Uint8Array(i.payload),s.parsing.start=s.buffering.start=self.performance.now(),s.parsing.end=s.buffering.end=self.performance.now(),i.frag===n&&a.trigger(S.FRAG_BUFFERED,{stats:s,frag:n,part:null,id:t.type}),r.tick()})).catch((function(e){r.state!==Gr&&r.state!==zr&&(r.warn(e),r.resetFragmentLoading(t))}))},r.fragContextChanged=function(t){var e=this.fragCurrent;return!t||!e||t.level!==e.level||t.sn!==e.sn||t.urlId!==e.urlId},r.fragBufferedComplete=function(t,e){var r,i,n,a,s=this.mediaBuffer?this.mediaBuffer:this.media;this.log("Buffered "+t.type+" sn: "+t.sn+(e?" part: "+e.index:"")+" of "+(this.playlistType===ge?"level":"track")+" "+t.level+" (frag:["+(null!=(r=t.startPTS)?r:NaN).toFixed(3)+"-"+(null!=(i=t.endPTS)?i:NaN).toFixed(3)+"] > buffer:"+(s?Br(Ir.getBuffered(s)):"(detached)")+")"),this.state=Kr,s&&(!this.loadedmetadata&&t.type==ge&&s.buffered.length&&(null==(n=this.fragCurrent)?void 0:n.sn)===(null==(a=this.fragPrevious)?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},r.seekToStartPos=function(){},r._handleFragmentLoadComplete=function(t){var e=this.transmuxer;if(e){var r=t.frag,i=t.part,n=t.partsLoaded,a=!n||0===n.length||n.some((function(t){return!t})),s=new wr(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!a);e.flush(s)}},r._handleFragmentLoadProgress=function(t){},r._doFragLoad=function(t,e,r,i){var n,a=this;void 0===r&&(r=null);var s=null==e?void 0:e.details;if(!this.levels||!s)throw new Error("frag load aborted, missing level"+(s?"":" detail")+"s");var o=null;if(!t.encrypted||null!=(n=t.decryptdata)&&n.key?!t.encrypted&&s.encryptedFragments.length&&this.keyLoader.loadClear(t,s.encryptedFragments):(this.log("Loading key for "+t.sn+" of ["+s.startSN+"-"+s.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level),this.state=Hr,this.fragCurrent=t,o=this.keyLoader.load(t).then((function(t){if(!a.fragContextChanged(t.frag))return a.hls.trigger(S.KEY_LOADED,t),a.state===Hr&&(a.state=Kr),t})),this.hls.trigger(S.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),r=Math.max(t.start,r||0),this.config.lowLatencyMode&&"initSegment"!==t.sn){var l=s.partList;if(l&&i){r>t.end&&s.fragmentHint&&(t=s.fragmentHint);var u=this.getNextPart(l,t,r);if(u>-1){var h,d=l[u];return this.log("Loading part sn: "+t.sn+" p: "+d.index+" cc: "+t.cc+" of playlist ["+s.startSN+"-"+s.endSN+"] parts [0-"+u+"-"+(l.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=d.start+d.duration,this.state=Vr,h=o?o.then((function(r){return!r||a.fragContextChanged(r.frag)?null:a.doFragPartsLoad(t,d,e,i)})).catch((function(t){return a.handleFragLoadError(t)})):this.doFragPartsLoad(t,d,e,i).catch((function(t){return a.handleFragLoadError(t)})),this.hls.trigger(S.FRAG_LOADING,{frag:t,part:d,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):h}if(!t.url||this.loadedEndOfParts(l,r))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(s?"of ["+s.startSN+"-"+s.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),E(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=Vr;var c,f=this.config.progressive;return c=f&&o?o.then((function(e){return!e||a.fragContextChanged(null==e?void 0:e.frag)?null:a.fragmentLoader.load(t,i)})).catch((function(t){return a.handleFragLoadError(t)})):Promise.all([this.fragmentLoader.load(t,f?i:void 0),o]).then((function(t){var e=t[0];return!f&&e&&i&&i(e),e})).catch((function(t){return a.handleFragLoadError(t)})),this.hls.trigger(S.FRAG_LOADING,{frag:t,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c},r.doFragPartsLoad=function(t,e,r,i){var n=this;return new Promise((function(a,s){var o,l=[],u=null==(o=r.details)?void 0:o.partList;!function e(o){n.fragmentLoader.loadPart(t,o,i).then((function(i){l[o.index]=i;var s=i.part;n.hls.trigger(S.FRAG_LOADED,i);var h=Ve(r,t.sn,o.index+1)||Ye(u,t.sn,o.index+1);if(!h)return a({frag:t,part:s,partsLoaded:l});e(h)})).catch(s)}(e)}))},r.handleFragLoadError=function(t){if("data"in t){var e=t.data;t.data&&e.details===R.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(S.ERROR,e)}else this.hls.trigger(S.ERROR,{type:L.OTHER_ERROR,details:R.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},r._handleTransmuxerFlush=function(t){var e=this.getCurrentContext(t);if(e&&this.state===jr){var r=e.frag,i=e.part,n=e.level,a=self.performance.now();r.stats.parsing.end=a,i&&(i.stats.parsing.end=a),this.updateLevelTiming(r,i,n,t.partial)}else this.fragCurrent||this.state===Gr||this.state===zr||(this.state=Kr)},r.getCurrentContext=function(t){var e=this.levels,r=this.fragCurrent,i=t.level,n=t.sn,a=t.part;if(null==e||!e[i])return this.warn("Levels object was unset while buffering fragment "+n+" of level "+i+". The current chunk will not be buffered."),null;var s=e[i],o=a>-1?Ve(s,n,a):null,l=o?o.fragment:function(t,e,r){if(null==t||!t.details)return null;var i=t.details,n=i.fragments[e-i.startSN];return n||((n=i.fragmentHint)&&n.sn===e?n:ea&&this.flushMainBuffer(s,t.start)}else this.flushMainBuffer(0,t.start)},r.getFwdBufferInfo=function(t,e){var r=this.getLoadPosition();return E(r)?this.getFwdBufferInfoAtPos(t,r,e):null},r.getFwdBufferInfoAtPos=function(t,e,r){var i=this.config.maxBufferHole,n=Ir.bufferInfo(t,e,i);if(0===n.len&&void 0!==n.nextStart){var a=this.fragmentTracker.getBufferedFrag(e,r);if(a&&n.nextStart=r&&(e.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+e.maxMaxBufferLength+"s"),!0)},r.getAppendedFrag=function(t,e){var r=this.fragmentTracker.getAppendedFrag(t,ge);return r&&"fragment"in r?r.fragment:r},r.getNextFragment=function(t,e){var r=e.fragments,i=r.length;if(!i)return null;var n,a=this.config,s=r[0].start;if(e.live){var o=a.initialLiveManifestSize;if(ie},r.getNextFragmentLoopLoading=function(t,e,r,i,n){var a=t.gap,s=this.getNextFragment(this.nextLoadPosition,e);if(null===s)return s;if(t=s,a&&t&&!t.gap&&r.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i);if(null!==o&&r.len+o.len>=n)return this.log('buffer full after gaps in "'+i+'" playlist starting at sn: '+t.sn),null}return t},r.mapToInitFragWhenRequired=function(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment},r.getNextPart=function(t,e,r){for(var i=-1,n=!1,a=!0,s=0,o=t.length;s-1&&rr.start&&r.loaded},r.getInitialLiveFragment=function(t,e){var r=this.fragPrevious,i=null;if(r){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=function(t,e,r){if(null===e||!Array.isArray(t)||!t.length||!E(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;i=t.startSN&&n<=t.endSN){var a=e[n-t.startSN];r.cc===a.cc&&(i=a,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=function(t,e){return Qe(t,(function(t){return t.cce?-1:0}))}(e,r.cc),i&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn))}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?t.fragmentEnd:t.edge,t))}return i},r.getFragmentAtPosition=function(t,e,r){var i,n=this.config,a=this.fragPrevious,s=r.fragments,o=r.endSN,l=r.fragmentHint,u=n.maxFragLookUpTolerance,h=r.partList,d=!!(n.lowLatencyMode&&null!=h&&h.length&&l);if(d&&l&&!this.bitrateTest&&(s=s.concat(l),o=l.sn),i=te-u?0:u):s[s.length-1]){var c=i.sn-r.startSN,f=this.fragmentTracker.getState(i);if((f===mr||f===vr&&i.gap)&&(a=i),a&&i.sn===a.sn&&(!d||h[0].fragment.sn>i.sn)&&a&&i.level===a.level){var g=s[c+1];i=i.sn=a-e.maxFragLookUpTolerance&&n<=s;if(null!==i&&r.duration>i&&(n"+t.startSN+" prev-sn: "+(n?n.sn:"na")+" fragments: "+s),h}return o},r.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},r.setStartPosition=function(t,e){var r=this.startPosition;if(r "+(null==(n=this.fragCurrent)?void 0:n.url))}else{var a=e.details===R.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(i,!0);var s=e.errorAction,o=s||{},l=o.action,u=o.retryCount,h=void 0===u?0:u,d=o.retryConfig;if(s&&l===nr&&d){var c;this.resetStartWhenNotLoaded(null!=(c=this.levelLastLoaded)?c:i.level);var f=qe(d,h);this.warn("Fragment "+i.sn+" of "+t+" "+i.level+" errored with "+e.details+", retrying loading "+(h+1)+"/"+d.maxNumRetry+" in "+f+"ms"),s.resolved=!0,this.retryDate=self.performance.now()+f,this.state=Yr}else d&&s?(this.resetFragmentErrors(t),h.5;i&&this.reduceMaxBufferLength(r.len);var n=!i;return n&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+e+" buffer"),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),n}return!1},r.resetFragmentErrors=function(t){t===ve&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==Gr&&(this.state=Kr)},r.afterBufferFlushed=function(t,e,r){if(t){var i=Ir.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,i,r),this.state===Xr&&this.resetLoadingState()}},r.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=Kr},r.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var e=this.levels?this.levels[t].details:null;null!=e&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},r.resetWhenMissingContext=function(t){var e;this.warn("The loading context changed while buffering fragment "+t.sn+" of level "+t.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(null!=(e=this.levelLastLoaded)?e:t.level),this.resetLoadingState()},r.removeUnbufferedFrags=function(t){void 0===t&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},r.updateLevelTiming=function(t,e,r,i){var n,a=this,s=r.details;if(s){if(Object.keys(t.elementaryStreams).reduce((function(e,n){var o=t.elementaryStreams[n];if(o){var l=o.endPTS-o.startPTS;if(l<=0)return a.warn("Could not parse fragment "+t.sn+" "+n+" duration reliably ("+l+")"),e||!1;var u=i?0:Be(s,t,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return a.hls.trigger(S.LEVEL_PTS_UPDATED,{details:s,level:r,drift:u,type:n,frag:t,start:o.startPTS,end:o.endPTS}),!0}return e}),!1))r.fragmentError=0;else if(null===(null==(n=this.transmuxer)?void 0:n.error)){var o=new Error("Found no media in fragment "+t.sn+" of level "+t.level+" resetting transmuxer to fallback to playlist timing");if(0===r.fragmentError&&(r.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(o.message),this.hls.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:!1,error:o,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+r.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=qr,this.hls.trigger(S.FRAG_PARSED,{frag:t,part:e})}else this.warn("level.details undefined")},r.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},r.recoverWorkerError=function(t){var e,r,i;"demuxerWorker"===t.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(null!=(e=null!=(r=this.levelLastLoaded)?r:null==(i=this.fragCurrent)?void 0:i.level)?e:0),this.resetLoadingState())},a(e,[{key:"state",get:function(){return this._state},set:function(t){var e=this._state;e!==t&&(this._state=t,this.log(e+"->"+t))}}]),e}(br);function Zr(){return self.SourceBuffer||self.WebKitSourceBuffer}function ti(t,e){return void 0===t&&(t=""),void 0===e&&(e=9e4),{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}var ei=function(){function t(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}var e=t.prototype;return e.resetInitSegment=function(t,e,r,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},e.resetTimeStamp=function(t){this.initPTS=t,this.resetContiguity()},e.resetContiguity=function(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0},e.canParse=function(t,e){return!1},e.appendFrame=function(t,e,r){},e.demux=function(t,e){this.cachedData&&(t=xt(this.cachedData,t),this.cachedData=null);var r,i=st(t,0),n=i?i.length:0,a=this._audioTrack,s=this._id3Track,o=i?function(t){for(var e=dt(t),r=0;r0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ae,duration:Number.POSITIVE_INFINITY});n>>5}function si(t,e){return e+1=t.length)return!1;var i=ai(t,e);if(i<=r)return!1;var n=e+i;return n===t.length||si(t,n)}return!1}function li(t,e,r,i,n){if(!t.samplerate){var a=function(t,e,r,i){var n,a,s,o,l=navigator.userAgent.toLowerCase(),u=i,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=1+((192&e[r+2])>>>6);var d=(60&e[r+2])>>>2;if(!(d>h.length-1))return s=(1&e[r+2])<<2,s|=(192&e[r+3])>>>6,w.log("manifest codec:"+i+", ADTS type:"+n+", samplingIndex:"+d),/firefox/i.test(l)?d>=6?(n=5,o=new Array(4),a=d-3):(n=2,o=new Array(2),a=d):-1!==l.indexOf("android")?(n=2,o=new Array(2),a=d):(n=5,o=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&d>=6?a=d-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(d>=6&&1===s||/vivaldi/i.test(l))||!i&&1===s)&&(n=2,o=new Array(2)),a=d)),o[0]=n<<3,o[0]|=(14&d)>>1,o[1]|=(1&d)<<7,o[1]|=s<<3,5===n&&(o[1]|=(14&a)>>1,o[2]=(1&a)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:h[d],channelCount:s,codec:"mp4a.40."+n,manifestCodec:u};t.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d})}(e,r,i,n);if(!a)return;t.config=a.config,t.samplerate=a.samplerate,t.channelCount=a.channelCount,t.codec=a.codec,t.manifestCodec=a.manifestCodec,w.log("parsed codec:"+t.codec+", rate:"+a.samplerate+", channels:"+a.channelCount)}}function ui(t){return 9216e4/t}function hi(t,e,r,i,n){var a,s=i+n*ui(t.samplerate),o=function(t,e){var r=ni(t,e);if(e+r<=t.length){var i=ai(t,e)-r;if(i>0)return{headerLength:r,frameLength:i}}}(e,r);if(o){var l=o.frameLength,u=o.headerLength,h=u+l,d=Math.max(0,r+h-e.length);d?(a=new Uint8Array(h-u)).set(e.subarray(r+u,e.length),0):a=e.subarray(r+u,r+h);var c={unit:a,pts:s};return d||t.samples.push(c),{sample:c,length:h,missing:d}}var f=e.length-r;return(a=new Uint8Array(f)).set(e.subarray(r,e.length),0),{sample:{unit:a,pts:s},length:f,missing:-1}}var di=function(t){function e(e,r){var i;return(i=t.call(this)||this).observer=void 0,i.config=void 0,i.observer=e,i.config=r,i}l(e,t);var r=e.prototype;return r.resetInitSegment=function(e,r,i,n){t.prototype.resetInitSegment.call(this,e,r,i,n),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},e.probe=function(t){if(!t)return!1;for(var e=(st(t,0)||[]).length,r=t.length;e16384?t.subarray(0,16384):t,["moof"]).length>0},e.demux=function(t,e){this.timeOffset=e;var r=t,i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=xt(this.remainderData,t));var a=function(t){var e={valid:null,remainder:null},r=It(t,["moof"]);if(!r)return e;if(r.length<2)return e.remainder=t,e;var i=r[r.length-1];return e.valid=rt(t,0,i.byteOffset-8),e.remainder=rt(t,i.byteOffset-8),e}(r);this.remainderData=a.remainder,i.samples=a.valid||new Uint8Array}else i.samples=r;var s=this.extractID3Track(i,e);return n.samples=Ft(e,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},e.flush=function(){var t=this.timeOffset,e=this.videoTrack,r=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(e,this.timeOffset);return r.samples=Ft(t,e),{videoTrack:e,audioTrack:ti(),id3Track:i,textTrack:ti()}},e.extractID3Track=function(t,e){var r=this.id3Track;if(t.samples.length){var i=It(t.samples,["emsg"]);i&&i.forEach((function(t){var i=function(t){var e=t[0],r="",i="",n=0,a=0,s=0,o=0,l=0,u=0;if(0===e){for(;"\0"!==Rt(t.subarray(u,u+1));)r+=Rt(t.subarray(u,u+1)),u+=1;for(r+=Rt(t.subarray(u,u+1)),u+=1;"\0"!==Rt(t.subarray(u,u+1));)i+=Rt(t.subarray(u,u+1)),u+=1;i+=Rt(t.subarray(u,u+1)),u+=1,n=kt(t,12),a=kt(t,16),o=kt(t,20),l=kt(t,24),u=28}else if(1===e){n=kt(t,u+=4);var h=kt(t,u+=4),d=kt(t,u+=4);for(u+=4,s=Math.pow(2,32)*h+d,Number.isSafeInteger(s)||(s=Number.MAX_SAFE_INTEGER,w.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=kt(t,u),l=kt(t,u+=4),u+=4;"\0"!==Rt(t.subarray(u,u+1));)r+=Rt(t.subarray(u,u+1)),u+=1;for(r+=Rt(t.subarray(u,u+1)),u+=1;"\0"!==Rt(t.subarray(u,u+1));)i+=Rt(t.subarray(u,u+1)),u+=1;i+=Rt(t.subarray(u,u+1)),u+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:s,presentationTimeDelta:a,eventDuration:o,id:l,payload:t.subarray(u,t.byteLength)}}(t);if(ci.test(i.schemeIdUri)){var n=E(i.presentationTime)?i.presentationTime/i.timeScale:e+i.presentationTimeDelta/i.timeScale,a=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;a<=.001&&(a=Number.POSITIVE_INFINITY);var s=i.payload;r.samples.push({data:s,len:s.byteLength,dts:n,pts:n,type:be,duration:a})}}))}return r},e.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},e.destroy=function(){},t}(),gi=null,vi=[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],mi=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],pi=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],yi=[0,1,1,4];function Ti(t,e,r,i,n){if(!(r+24>e.length)){var a=Ei(e,r);if(a&&r+a.frameLength<=e.length){var s=i+n*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:e.subarray(r,r+a.frameLength),pts:s,dts:s};return t.config=[],t.channelCount=a.channelCount,t.samplerate=a.sampleRate,t.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}}function Ei(t,e){var r=t[e+1]>>3&3,i=t[e+1]>>1&3,n=t[e+2]>>4&15,a=t[e+2]>>2&3;if(1!==r&&0!==n&&15!==n&&3!==a){var s=t[e+2]>>1&1,o=t[e+3]>>6,l=1e3*vi[14*(3===r?3-i:3===i?3:4)+n-1],u=mi[3*(3===r?0:2===r?1:2)+a],h=3===o?1:2,d=pi[r][i],c=yi[i],f=8*d*c,g=Math.floor(d*l/u+s)*c;if(null===gi){var v=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);gi=v?parseInt(v[1]):0}return!!gi&&gi<=87&&2===i&&l>=224e3&&0===o&&(t[e+3]=128|t[e+3]),{sampleRate:u,channelCount:h,frameLength:g,samplesPerFrame:f}}}function Si(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function Li(t,e){return e+1t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,t-=(e=t>>3)<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},e.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;if(t>32&&w.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(e=t-e)>0&&this.bitsAvailable?r<>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},e.skipUEG=function(){this.skipBits(1+this.skipLZ())},e.skipEG=function(){this.skipBits(1+this.skipLZ())},e.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},e.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},e.readBoolean=function(){return 1===this.readBits(1)},e.readUByte=function(){return this.readBits(8)},e.readUShort=function(){return this.readBits(16)},e.readUInt=function(){return this.readBits(32)},e.skipScalingList=function(t){for(var e=8,r=8,i=0;i=t.length)return void r();if(!(t[e].unit.length<32||(this.decryptAacSample(t,e,r),this.decrypter.isSync())))return}},e.getAvcEncryptedData=function(t){for(var e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e),i=0,n=32;n=t.length)return void i();for(var n=t[e].units;!(r>=n.length);r++){var a=n[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(t,e,r,i,a),this.decrypter.isSync())))return}}},t}(),bi=188,Di=function(){function t(t,e,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=e,this.typeSupported=r}t.probe=function(e){var r=t.syncOffset(e);return r>0&&w.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},t.syncOffset=function(t){for(var e=t.length,r=Math.min(940,t.length-bi)+1,i=0;i1&&(0===a&&s>2||o+bi>r))return a}i++}return-1},t.createTrack=function(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:Lt[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}};var e=t.prototype;return e.resetInitSegment=function(e,r,i,n){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=t.createTrack("video"),this._audioTrack=t.createTrack("audio",n),this._id3Track=t.createTrack("id3"),this._txtTrack=t.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i,this._duration=n},e.resetTimeStamp=function(){},e.resetContiguity=function(){var t=this._audioTrack,e=this._avcTrack,r=this._id3Track;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.avcSample=null,this.remainderData=null},e.demux=function(e,r,i,n){var a;void 0===i&&(i=!1),void 0===n&&(n=!1),i||(this.sampleAes=null);var s=this._avcTrack,o=this._audioTrack,l=this._id3Track,u=this._txtTrack,h=s.pid,d=s.pesData,c=o.pid,f=l.pid,g=o.pesData,v=l.pesData,m=null,p=this.pmtParsed,y=this._pmtId,T=e.length;if(this.remainderData&&(T=(e=xt(this.remainderData,e)).length,this.remainderData=null),T>4>1){if((I=k+5+e[k+4])===k+bi)continue}else I=k+4;switch(D){case h:b&&(d&&(a=Pi(d))&&this.parseAVCPES(s,u,a,!1),d={data:[],size:0}),d&&(d.data.push(e.subarray(I,k+bi)),d.size+=k+bi-I);break;case c:if(b){if(g&&(a=Pi(g)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,a);break;case"mp3":this.parseMPEGPES(o,a)}g={data:[],size:0}}g&&(g.data.push(e.subarray(I,k+bi)),g.size+=k+bi-I);break;case f:b&&(v&&(a=Pi(v))&&this.parseID3PES(l,a),v={data:[],size:0}),v&&(v.data.push(e.subarray(I,k+bi)),v.size+=k+bi-I);break;case 0:b&&(I+=e[I]+1),y=this._pmtId=Ci(e,I);break;case y:b&&(I+=e[I]+1);var C=_i(e,I,this.typeSupported,i);(h=C.avc)>0&&(s.pid=h),(c=C.audio)>0&&(o.pid=c,o.segmentCodec=C.segmentCodec),(f=C.id3)>0&&(l.pid=f),null===m||p||(w.warn("MPEG-TS PMT found at "+k+" after unknown PID '"+m+"'. Backtracking to sync byte @"+E+" to parse all TS packets."),m=null,k=E-188),p=this.pmtParsed=!0;break;case 17:case 8191:break;default:m=D}}else A++;if(A>0){var _=new Error("Found "+A+" TS packet/s that do not start with 0x47");this.observer.emit(S.ERROR,S.ERROR,{type:L.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:!1,error:_,reason:_.message})}s.pesData=d,o.pesData=g,l.pesData=v;var P={audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};return n&&this.extractRemainingSamples(P),P},e.flush=function(){var t,e=this.remainderData;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._avcTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},e.extractRemainingSamples=function(t){var e,r=t.audioTrack,i=t.videoTrack,n=t.id3Track,a=t.textTrack,s=i.pesData,o=r.pesData,l=n.pesData;if(s&&(e=Pi(s))?(this.parseAVCPES(i,a,e,!0),i.pesData=null):i.pesData=s,o&&(e=Pi(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,e);break;case"mp3":this.parseMPEGPES(r,e)}r.pesData=null}else null!=o&&o.size&&w.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(e=Pi(l))?(this.parseID3PES(n,e),n.pesData=null):n.pesData=l},e.demuxSampleAes=function(t,e,r){var i=this.demux(t,r,!0,!this.config.progressive),n=this.sampleAes=new ki(this.observer,this.config,e);return this.decrypt(i,n)},e.decrypt=function(t,e){return new Promise((function(r){var i=t.audioTrack,n=t.videoTrack;i.samples&&"aac"===i.segmentCodec?e.decryptAacSamples(i.samples,0,(function(){n.samples?e.decryptAvcSamples(n.samples,0,0,(function(){r(t)})):r(t)})):n.samples&&e.decryptAvcSamples(n.samples,0,0,(function(){r(t)}))}))},e.destroy=function(){this._duration=0},e.parseAVCPES=function(t,e,r,i){var n,a=this,s=this.parseAVCNALu(t,r.data),o=this.avcSample,l=!1;r.data=null,o&&s.length&&!t.audFound&&(xi(o,t),o=this.avcSample=Ii(!1,r.pts,r.dts,"")),s.forEach((function(i){var s;switch(i.type){case 1:var u=!1;n=!0;var h,d=i.data;if(l&&d.length>4){var c=new Ai(d).readSliceType();2!==c&&4!==c&&7!==c&&9!==c||(u=!0)}u&&null!=(h=o)&&h.frame&&!o.key&&(xi(o,t),o=a.avcSample=null),o||(o=a.avcSample=Ii(!0,r.pts,r.dts,"")),o.frame=!0,o.key=u;break;case 5:n=!0,null!=(s=o)&&s.frame&&!o.key&&(xi(o,t),o=a.avcSample=null),o||(o=a.avcSample=Ii(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:n=!0,Ot(i.data,1,r.pts,e.samples);break;case 7:if(n=!0,l=!0,!t.sps){var f=i.data,g=new Ai(f).readSPS();t.width=g.width,t.height=g.height,t.pixelRatio=g.pixelRatio,t.sps=[f],t.duration=a._duration;for(var v=f.subarray(1,4),m="avc1.",p=0;p<3;p++){var y=v[p].toString(16);y.length<2&&(y="0"+y),m+=y}t.codec=m}break;case 8:n=!0,t.pps||(t.pps=[i.data]);break;case 9:n=!1,t.audFound=!0,o&&xi(o,t),o=a.avcSample=Ii(!1,r.pts,r.dts,"");break;case 12:n=!0;break;default:n=!1,o&&(o.debug+="unknown NAL "+i.type+" ")}o&&n&&o.units.push(i)})),i&&o&&(xi(o,t),this.avcSample=null)},e.getLastNalUnit=function(t){var e,r,i=this.avcSample;if(i&&0!==i.units.length||(i=t[t.length-1]),null!=(e=i)&&e.units){var n=i.units;r=n[n.length-1]}return r},e.parseAVCNALu=function(t,e){var r,i,n=e.byteLength,a=t.naluState||0,s=a,o=[],l=0,u=-1,h=0;for(-1===a&&(u=0,h=31&e[0],a=0,l=1);l=0){var d={data:e.subarray(u,l-a-1),type:h};o.push(d)}else{var c=this.getLastNalUnit(t.samples);if(c&&(s&&l<=4-s&&c.state&&(c.data=c.data.subarray(0,c.data.byteLength-s)),(i=l-a-1)>0)){var f=new Uint8Array(c.data.byteLength+i);f.set(c.data,0),f.set(e.subarray(0,i),c.data.byteLength),c.data=f,c.state=0}}l=0&&a>=0){var g={data:e.subarray(u,n),type:h,state:a};o.push(g)}if(0===o.length){var v=this.getLastNalUnit(t.samples);if(v){var m=new Uint8Array(v.data.byteLength+e.byteLength);m.set(v.data,0),m.set(e,v.data.byteLength),v.data=m}}return t.naluState=a,o},e.parseAACPES=function(t,e){var r,i,n,a=0,s=this.aacOverFlow,o=e.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;if(-1===l){var h=new Uint8Array(u+o.byteLength);h.set(s.sample.unit,0),h.set(o,u),o=h}else{var d=u-l;s.sample.unit.set(o.subarray(0,l),d),t.samples.push(s.sample),a=s.missing}}for(r=a,i=o.length;r1;){var l=new Uint8Array(o[0].length+o[1].length);l.set(o[0]),l.set(o[1],o[0].length),o[0]=l,o.splice(1,1)}if(1===((e=o[0])[0]<<16)+(e[1]<<8)+e[2]){if((r=(e[4]<<8)+e[5])&&r>t.size-6)return null;var u=e[7];192&u&&(n=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&u?n-(a=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2)>54e5&&(w.warn(Math.round((n-a)/9e4)+"s delta between PTS and DTS, align them"),n=a):a=n);var h=(i=e[8])+9;if(t.size<=h)return null;t.size-=h;for(var d=new Uint8Array(t.size),c=0,f=o.length;cg){h-=g;continue}e=e.subarray(h),g-=h,h=0}d.set(e,s),s+=g}return r&&(r-=i+3),{data:d,pts:n,dts:a,len:r}}return null}function xi(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){var r=e.samples,i=r.length;if(!i)return void e.dropped++;var n=r[i-1];t.pts=n.pts,t.dts=n.dts}e.samples.push(t)}t.debug.length&&w.log(t.pts+"/"+t.dts+":"+t.debug)}var Fi=function(t){function e(){return t.apply(this,arguments)||this}l(e,t);var r=e.prototype;return r.resetInitSegment=function(e,r,i,n){t.prototype.resetInitSegment.call(this,e,r,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},e.probe=function(t){if(!t)return!1;for(var e=(st(t,0)||[]).length,r=t.length;e1?r-1:0),n=1;n>24&255,o[1]=e>>16&255,o[2]=e>>8&255,o[3]=255&e,o.set(t,4),a=0,e=8;a>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))},t.mdia=function(e){return t.box(t.types.mdia,t.mdhd(e.timescale,e.duration),t.hdlr(e.type),t.minf(e))},t.mfhd=function(e){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},t.minf=function(e){return"audio"===e.type?t.box(t.types.minf,t.box(t.types.smhd,t.SMHD),t.DINF,t.stbl(e)):t.box(t.types.minf,t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(e))},t.moof=function(e,r,i){return t.box(t.types.moof,t.mfhd(e),t.traf(i,r))},t.moov=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trak(e[r]);return t.box.apply(null,[t.types.moov,t.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(t.mvex(e)))},t.mvex=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trex(e[r]);return t.box.apply(null,[t.types.mvex].concat(i))},t.mvhd=function(e,r){r*=e;var i=Math.floor(r/(Oi+1)),n=Math.floor(r%(Oi+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return t.box(t.types.mvhd,a)},t.sdtp=function(e){var r,i,n=e.samples||[],a=new Uint8Array(4+n.length);for(r=0;r>>8&255),a.push(255&n),a=a.concat(Array.prototype.slice.call(i));for(r=0;r>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(i));var o=t.box(t.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|e.sps.length].concat(a).concat([e.pps.length]).concat(s))),l=e.width,u=e.height,h=e.pixelRatio[0],d=e.pixelRatio[1];return t.box(t.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,d>>24,d>>16&255,d>>8&255,255&d])))},t.esds=function(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))},t.mp4a=function(e){var r=e.samplerate;return t.box(t.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]),t.box(t.types.esds,t.esds(e)))},t.mp3=function(e){var r=e.samplerate;return t.box(t.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,r>>8&255,255&r,0,0]))},t.stsd=function(e){return"audio"===e.type?"mp3"===e.segmentCodec&&"mp3"===e.codec?t.box(t.types.stsd,t.STSD,t.mp3(e)):t.box(t.types.stsd,t.STSD,t.mp4a(e)):t.box(t.types.stsd,t.STSD,t.avc1(e))},t.tkhd=function(e){var r=e.id,i=e.duration*e.timescale,n=e.width,a=e.height,s=Math.floor(i/(Oi+1)),o=Math.floor(i%(Oi+1));return t.box(t.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,255&n,0,0,a>>8&255,255&a,0,0]))},t.traf=function(e,r){var i=t.sdtp(e),n=e.id,a=Math.floor(r/(Oi+1)),s=Math.floor(r%(Oi+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s])),t.trun(e,i.length+16+20+8+16+8+8),i)},t.trak=function(e){return e.duration=e.duration||4294967295,t.box(t.types.trak,t.tkhd(e),t.mdia(e))},t.trex=function(e){var r=e.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},t.trun=function(e,r){var i,n,a,s,o,l,u=e.samples||[],h=u.length,d=12+16*h,c=new Uint8Array(d);for(r+=8+d,c.set(["video"===e.type?1:0,0,15,1,h>>>24&255,h>>>16&255,h>>>8&255,255&h,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i>>24&255,a>>>16&255,a>>>8&255,255&a,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return t.box(t.types.trun,c)},t.initSegment=function(e){t.types||t.init();var r=t.moov(e),i=new Uint8Array(t.FTYP.byteLength+r.byteLength);return i.set(t.FTYP),i.set(r,t.FTYP.byteLength),i},t}();function Ui(t,e,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var n=t*e*r;return i?Math.round(n):n}function Bi(t,e){return void 0===e&&(e=!1),Ui(t,1e3,1/9e4,e)}Ni.types=void 0,Ni.HDLR_TYPES=void 0,Ni.STTS=void 0,Ni.STSC=void 0,Ni.STCO=void 0,Ni.STSZ=void 0,Ni.VMHD=void 0,Ni.SMHD=void 0,Ni.STSD=void 0,Ni.FTYP=void 0,Ni.DINF=void 0;var Gi=null,Ki=null,Hi=function(){function t(t,e,r,i){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,null===Gi){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Gi=n?parseInt(n[1]):0}if(null===Ki){var a=navigator.userAgent.match(/Safari\/(\d+)/i);Ki=a?parseInt(a[1]):0}}var e=t.prototype;return e.destroy=function(){},e.resetTimeStamp=function(t){w.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},e.resetNextTimestamp=function(){w.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},e.resetInitSegment=function(){w.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},e.getVideoStartPts=function(t){var e=!1,r=t.reduce((function(t,r){var i=r.pts-t;return i<-4294967296?(e=!0,Vi(t,r.pts)):i>0?t:r.pts}),t[0].pts);return e&&w.debug("PTS rollover detected"),r},e.remux=function(t,e,r,i,n,a,s,o){var l,u,h,d,c,f,g=n,v=n,m=t.pid>-1,p=e.pid>-1,y=e.samples.length,T=t.samples.length>0,E=s&&y>0||y>1;if((!m||T)&&(!p||E)||this.ISGenerated||s){this.ISGenerated||(h=this.generateIS(t,e,n,a));var S,L=this.isVideoContiguous,R=-1;if(E&&(R=function(t){for(var e=0;e0){w.warn("[mp4-remuxer]: Dropped "+R+" out of "+y+" video samples due to a missing keyframe");var A=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(R),e.dropped+=R,S=v+=(e.samples[0].pts-A)/e.inputTimeScale}else-1===R&&(w.warn("[mp4-remuxer]: No keyframe found out of "+y+" video samples"),f=!1);if(this.ISGenerated){if(T&&E){var k=this.getVideoStartPts(e.samples),b=(Vi(t.samples[0].pts,k)-k)/e.inputTimeScale;g+=Math.max(0,b),v+=Math.max(0,-b)}if(T){if(t.samplerate||(w.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(t,e,n,a)),u=this.remuxAudio(t,g,this.isAudioContiguous,a,p||E||o===ve?v:void 0),E){var D=u?u.endPTS-u.startPTS:0;e.inputTimeScale||(w.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(t,e,n,a)),l=this.remuxVideo(e,v,L,D)}}else E&&(l=this.remuxVideo(e,v,L,0));l&&(l.firstKeyFrame=R,l.independent=-1!==R,l.firstKeyFramePTS=S)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(c=Yi(r,n,this._initPTS,this._initDTS)),i.samples.length&&(d=Wi(i,n,this._initPTS))),{audio:u,video:l,initSegment:h,independent:f,text:d,id3:c}},e.generateIS=function(t,e,r,i){var n,a,s,o=t.samples,l=e.samples,u=this.typeSupported,h={},d=this._initPTS,c=!d||i,f="audio/mp4";if(c&&(n=a=1/0),t.config&&o.length&&(t.timescale=t.samplerate,"mp3"===t.segmentCodec&&(u.mpeg?(f="audio/mpeg",t.codec=""):u.mp3&&(t.codec="mp3")),h.audio={id:"audio",container:f,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&u.mpeg?new Uint8Array(0):Ni.initSegment([t]),metadata:{channelCount:t.channelCount}},c&&(s=t.inputTimeScale,d&&s===d.timescale?c=!1:n=a=o[0].pts-Math.round(s*r))),e.sps&&e.pps&&l.length&&(e.timescale=e.inputTimeScale,h.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:Ni.initSegment([e]),metadata:{width:e.width,height:e.height}},c))if(s=e.inputTimeScale,d&&s===d.timescale)c=!1;else{var g=this.getVideoStartPts(l),v=Math.round(s*r);a=Math.min(a,Vi(l[0].dts,g)-v),n=Math.min(n,g-v)}if(Object.keys(h).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:n,timescale:s},this._initDTS={baseTime:a,timescale:s}):n=s=void 0,{tracks:h,initPTS:n,timescale:s}},e.remuxVideo=function(t,e,r,i){var n,a,s=t.inputTimeScale,l=t.samples,u=[],h=l.length,d=this._initPTS,c=this.nextAvcDts,f=8,g=this.videoSampleDuration,v=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,p=!1;r&&null!==c||(c=e*s-(l[0].pts-Vi(l[0].dts,l[0].pts)));for(var y=d.baseTime*s/d.timescale,T=0;T0?T-1:T].dts&&(p=!0)}p&&l.sort((function(t,e){var r=t.dts-e.dts,i=t.pts-e.pts;return r||i})),n=l[0].dts;var A=(a=l[l.length-1].dts)-n,k=A?Math.round(A/(h-1)):g||t.inputTimeScale/30;if(r){var b=n-c,D=b>k,I=b<-1;if((D||I)&&(D?w.warn("AVC: "+Bi(b,!0)+" ms ("+b+"dts) hole between fragments detected, filling it"):w.warn("AVC: "+Bi(-b,!0)+" ms ("+b+"dts) overlapping between fragments detected"),!I||c>=l[0].pts)){n=c;var C=l[0].pts-b;l[0].dts=n,l[0].pts=C,w.log("Video: First PTS/DTS adjusted: "+Bi(C,!0)+"/"+Bi(n,!0)+", delta: "+Bi(b,!0)+" ms")}}n=Math.max(0,n);for(var _=0,P=0,x=0;x0?X.dts-l[q-1].dts:k;if(rt=q>0?X.pts-l[q-1].pts:k,it.stretchShortVideoTrack&&null!==this.nextAudioPts){var at=Math.floor(it.maxBufferHole*s),st=(i?v+i*s:this.nextAudioPts)-X.pts;st>at?((g=st-nt)<0?g=nt:H=!0,w.log("[mp4-remuxer]: It is approximately "+st/90+" ms to the next segment; using duration "+g/90+" ms for the last video frame.")):g=nt}else g=nt}var ot=Math.round(X.pts-X.dts);V=Math.min(V,g),W=Math.max(W,g),Y=Math.min(Y,rt),j=Math.max(j,rt),u.push(new qi(X.key,g,Q,ot))}if(u.length)if(Gi){if(Gi<70){var lt=u[0].flags;lt.dependsOn=2,lt.isNonSync=0}}else if(Ki&&j-Y0&&(i&&Math.abs(p-m)<9e3||Math.abs(Vi(g[0].pts-y,p)-m)<20*u),g.forEach((function(t){t.pts=Vi(t.pts-y,p)})),!r||m<0){if(g=g.filter((function(t){return t.pts>=0})),!g.length)return;m=0===n?0:i&&!f?Math.max(0,p):g[0].pts}if("aac"===t.segmentCodec)for(var T=this.config.maxAudioFramesDrift,E=0,A=m;E=T*u&&I<1e4&&f){var C=Math.round(D/u);(A=b-C*u)<0&&(C--,A+=u),0===E&&(this.nextAudioPts=m=A),w.warn("[mp4-remuxer]: Injecting "+C+" audio frame @ "+(A/a).toFixed(3)+"s due to "+Math.round(1e3*D/a)+" ms gap.");for(var _=0;_0))return;N+=v;try{F=new Uint8Array(N)}catch(t){return void this.observer.emit(S.ERROR,S.ERROR,{type:L.MUX_ERROR,details:R.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:N,reason:"fail allocating audio mdat "+N})}d||(new DataView(F.buffer).setUint32(0,N),F.set(Ni.types.mdat,4))}F.set(H,v);var Y=H.byteLength;v+=Y,c.push(new qi(!0,l,Y,0)),O=V}var W=c.length;if(W){var j=c[c.length-1];this.nextAudioPts=m=O+s*j.duration;var q=d?new Uint8Array(0):Ni.moof(t.sequenceNumber++,M/s,o({},t,{samples:c}));t.samples=[];var X=M/a,z=m/a,Q={data1:q,data2:F,startPTS:X,endPTS:z,startDTS:X,endDTS:z,type:"audio",hasAudio:!0,hasVideo:!1,nb:W};return this.isAudioContiguous=!0,Q}},e.remuxEmptyAudio=function(t,e,r,i){var n=t.inputTimeScale,a=n/(t.samplerate?t.samplerate:n),s=this.nextAudioPts,o=this._initDTS,l=9e4*o.baseTime/o.timescale,u=(null!==s?s:i.startDTS*n)+l,h=i.endDTS*n+l,d=1024*a,c=Math.ceil((h-u)/d),f=Mi.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(w.warn("[mp4-remuxer]: remux empty Audio"),f){for(var g=[],v=0;v4294967296;)t+=r;return t}function Yi(t,e,r,i){var n=t.samples.length;if(n){for(var a=t.inputTimeScale,s=0;s0;n||(i=It(e,["encv"])),i.forEach((function(t){It(n?t.subarray(28):t.subarray(78),["sinf"]).forEach((function(t){var e=_t(t);if(e){var i=e.subarray(8,24);i.some((function(t){return 0!==t}))||(w.log("[eme] Patching keyId in 'enc"+(n?"a":"v")+">sinf>>tenc' box: "+Tt(i)+" -> "+Tt(r)),e.set(r,8))}}))}))})),t}(t,i)),this.emitInitSegment=!0},e.generateInitSegment=function(t){var e=this.audioCodec,r=this.videoCodec;if(null==t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=Ct(t);e||(e=Qi(i.audio,O)),r||(r=Qi(i.video,N));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:w.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n},e.remux=function(t,e,r,i,n,a){var s,o,l=this.initPTS,u=this.lastEndTime,h={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};E(u)||(u=this.lastEndTime=n||0);var d=e.samples;if(null==d||!d.length)return h;var c={initPTS:void 0,timescale:1},f=this.initData;if(null!=(s=f)&&s.length||(this.generateInitSegment(d),f=this.initData),null==(o=f)||!o.length)return w.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var g=function(t,e){for(var r=0,i=0,n=0,a=It(t,["moof","traf"]),s=0;sn}(l,m,n,g)||c.timescale!==l.timescale&&a)&&(c.initPTS=m-n,l&&1===l.timescale&&w.warn("Adjusting initPTS by "+(c.initPTS-l.baseTime)),this.initPTS=l={baseTime:c.initPTS,timescale:1});var p=t?m-l.baseTime/l.timescale:u,y=p+g;!function(t,e,r){It(e,["moof","traf"]).forEach((function(e){It(e,["tfhd"]).forEach((function(i){var n=kt(i,4),a=t[n];if(a){var s=a.timescale||9e4;It(e,["tfdt"]).forEach((function(t){var e=t[0],i=kt(t,4);if(0===e)i-=r*s,Dt(t,4,i=Math.max(i,0));else{i*=Math.pow(2,32),i+=kt(t,8),i-=r*s,i=Math.max(i,0);var n=Math.floor(i/(Et+1)),a=Math.floor(i%(Et+1));Dt(t,4,n),Dt(t,8,a)}}))}}))}))}(f,d,l.baseTime/l.timescale),g>0?this.lastEndTime=y:(w.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var T=!!f.audio,S=!!f.video,L="";T&&(L+="audio"),S&&(L+="video");var R={data1:d,startPTS:p,startDTS:p,endPTS:y,endDTS:y,type:L,hasAudio:T,hasVideo:S,nb:1,dropped:0};return h.audio="audio"===R.type?R:void 0,h.video="audio"!==R.type?R:void 0,h.initSegment=c,h.id3=Yi(r,n,l,l),i.samples.length&&(h.text=Wi(i,n,l)),h},t}();function Qi(t,e){var r=null==t?void 0:t.codec;return r&&r.length>4?r:"hvc1"===r||"hev1"===r?"hvc1.1.6.L120.90":"av01"===r?"av01.0.04M.08":"avc1"===r||e===N?"avc1.42e01e":"mp4a.40.5"}try{ji=self.performance.now.bind(self.performance)}catch(t){w.debug("Unable to use Performance API on this environment"),ji="undefined"!=typeof self&&self.Date.now}var $i=[{demux:fi,remux:zi},{demux:Di,remux:Hi},{demux:di,remux:Hi},{demux:Fi,remux:Hi}],Ji=function(){function t(t,e,r,i,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=e,this.config=r,this.vendor=i,this.id=n}var e=t.prototype;return e.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},e.push=function(t,e,r,i){var n=this,a=r.transmuxing;a.executeStart=ji();var s=new Uint8Array(t),o=this.currentTransmuxState,l=this.transmuxConfig;i&&(this.currentTransmuxState=i);var u=i||o,h=u.contiguous,d=u.discontinuity,c=u.trackSwitch,f=u.accurateTimeOffset,g=u.timeOffset,v=u.initSegmentChange,m=l.audioCodec,p=l.videoCodec,y=l.defaultInitPts,T=l.duration,E=l.initSegmentData,A=function(t,e){var r=null;return t.byteLength>0&&null!=e&&null!=e.key&&null!==e.iv&&null!=e.method&&(r=e),r}(s,e);if(A&&"AES-128"===A.method){var k=this.getDecrypter();if(!k.isSync())return this.decryptionPromise=k.webCryptoDecrypt(s,A.key.buffer,A.iv.buffer).then((function(t){var e=n.push(t,null,r);return n.decryptionPromise=null,e})),this.decryptionPromise;var b=k.softwareDecrypt(s,A.key.buffer,A.iv.buffer);if(r.part>-1&&(b=k.flush()),!b)return a.executeEnd=ji(),Zi(r);s=new Uint8Array(b)}var D=this.needsProbing(d,c);if(D){var I=this.configureTransmuxer(s);if(I)return w.warn("[transmuxer] "+I.message),this.observer.emit(S.ERROR,S.ERROR,{type:L.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,fatal:!1,error:I,reason:I.message}),a.executeEnd=ji(),Zi(r)}(d||c||v||D)&&this.resetInitSegment(E,m,p,T,e),(d||v||D)&&this.resetInitialTimestamp(y),h||this.resetContiguity();var C=this.transmux(s,A,g,f,r),_=this.currentTransmuxState;return _.contiguous=!0,_.discontinuity=!1,_.trackSwitch=!1,a.executeEnd=ji(),C},e.flush=function(t){var e=this,r=t.transmuxing;r.executeStart=ji();var i=this.decrypter,n=this.currentTransmuxState,a=this.decryptionPromise;if(a)return a.then((function(){return e.flush(t)}));var s=[],o=n.timeOffset;if(i){var l=i.flush();l&&s.push(this.push(l,null,t))}var u=this.demuxer,h=this.remuxer;if(!u||!h)return r.executeEnd=ji(),[Zi(t)];var d=u.flush(o);return tn(d)?d.then((function(r){return e.flushRemux(s,r,t),s})):(this.flushRemux(s,d,t),s)},e.flushRemux=function(t,e,r){var i=e.audioTrack,n=e.videoTrack,a=e.id3Track,s=e.textTrack,o=this.currentTransmuxState,l=o.accurateTimeOffset,u=o.timeOffset;w.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var h=this.remuxer.remux(i,n,a,s,u,l,!0,this.id);t.push({remuxResult:h,chunkMeta:r}),r.transmuxing.executeEnd=ji()},e.resetInitialTimestamp=function(t){var e=this.demuxer,r=this.remuxer;e&&r&&(e.resetTimeStamp(t),r.resetTimeStamp(t))},e.resetContiguity=function(){var t=this.demuxer,e=this.remuxer;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())},e.resetInitSegment=function(t,e,r,i,n){var a=this.demuxer,s=this.remuxer;a&&s&&(a.resetInitSegment(t,e,r,i),s.resetInitSegment(t,e,r,n))},e.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},e.transmux=function(t,e,r,i,n){return e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,r,i,n):this.transmuxUnencrypted(t,r,i,n)},e.transmuxUnencrypted=function(t,e,r,i){var n=this.demuxer.demux(t,e,!1,!this.config.progressive),a=n.audioTrack,s=n.videoTrack,o=n.id3Track,l=n.textTrack;return{remuxResult:this.remuxer.remux(a,s,o,l,e,r,!1,this.id),chunkMeta:i}},e.transmuxSampleAes=function(t,e,r,i,n){var a=this;return this.demuxer.demuxSampleAes(t,e,r).then((function(t){return{remuxResult:a.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,r,i,!1,a.id),chunkMeta:n}}))},e.configureTransmuxer=function(t){for(var e,r=this.config,i=this.observer,n=this.typeSupported,a=this.vendor,s=0,o=$i.length;s1&&l.id===(null==m?void 0:m.stats.chunkCount),L=!y&&(1===T||0===T&&(1===E||S&&E<=0)),R=self.performance.now();(y||T||0===n.stats.parsing.start)&&(n.stats.parsing.start=R),!a||!E&&L||(a.stats.parsing.start=R);var A=!(m&&(null==(h=n.initSegment)?void 0:h.url)===(null==(d=m.initSegment)?void 0:d.url)),k=new rn(p,L,o,y,g,A);if(!L||p||A){w.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+l.sn+" p: "+l.part+" level: "+l.level+" id: "+l.id+"\n discontinuity: "+p+"\n trackSwitch: "+y+"\n contiguous: "+L+"\n accurateTimeOffset: "+o+"\n timeOffset: "+g+"\n initSegmentChange: "+A);var b=new en(r,i,e,s,u);this.configureTransmuxer(b)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:v,chunkMeta:l,state:k},t instanceof ArrayBuffer?[t]:[]);else if(f){var D=f.push(t,v,l,k);tn(D)?(f.async=!0,D.then((function(t){c.handleTransmuxComplete(t)})).catch((function(t){c.transmuxerError(t,l,"transmuxer-interface push error")}))):(f.async=!1,this.handleTransmuxComplete(D))}},r.flush=function(t){var e=this;t.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(r){var i=r.flush(t);tn(i)||r.async?(tn(i)||(i=Promise.resolve(i)),i.then((function(r){e.handleFlushResult(r,t)})).catch((function(r){e.transmuxerError(r,t,"transmuxer-interface flush error")}))):this.handleFlushResult(i,t)}},r.transmuxerError=function(t,e,r){this.hls&&(this.error=t,this.hls.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:R.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:r}))},r.handleFlushResult=function(t,e){var r=this;t.forEach((function(t){r.handleTransmuxComplete(t)})),this.onFlush(e)},r.onWorkerMessage=function(t){var e=t.data,r=this.hls;switch(e.event){case"init":var i,n=null==(i=this.workerContext)?void 0:i.objectURL;n&&self.URL.revokeObjectURL(n);break;case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;case"workerLog":w[e.data.logType]&&w[e.data.logType](e.data.message);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,r.trigger(e.event,e.data)}},r.configureTransmuxer=function(t){var e=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)},r.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},e}(),dn=function(){function t(t,e,r,i){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=t,this.media=e,this.fragmentTracker=r,this.hls=i}var e=t.prototype;return e.destroy=function(){this.media=null,this.hls=this.fragmentTracker=null},e.poll=function(t,e){var r=this.config,i=this.media,n=this.stalled;if(null!==i){var a=i.currentTime,s=i.seeking,o=this.seeking&&!s,l=!this.seeking&&s;if(this.seeking=s,a===t){if(l||o)this.stalled=null;else if(!(i.paused&&!s||i.ended||0===i.playbackRate)&&Ir.getBuffered(i).length){var u=Ir.bufferInfo(i,a,0),h=u.len>0,d=u.nextStart||0;if(h||d){if(s){var c=u.len>2,f=!d||e&&e.start<=a||d-a>2&&!this.fragmentTracker.getPartialFragment(a);if(c||f)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var g,v=Math.max(d,u.start||0)-a,m=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,p=(null==m||null==(g=m.details)?void 0:g.live)?2*m.details.targetduration:2,y=this.fragmentTracker.getPartialFragment(a);if(v>0&&(v<=p||y))return void this._trySkipBufferHole(y)}var T=self.performance.now();if(null!==n){var E=T-n;if(s||!(E>=250)||(this._reportStall(u),this.media)){var S=Ir.bufferInfo(i,a,r.maxBufferHole);this._tryFixBufferStall(S,E)}}else this.stalled=T}}}else if(this.moved=!0,null!==n){if(this.stallReported){var L=self.performance.now()-n;w.warn("playback not stuck anymore @"+a+", after "+Math.round(L)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}}},e._tryFixBufferStall=function(t,e){var r=this.config,i=this.fragmentTracker,n=this.media;if(null!==n){var a=n.currentTime,s=i.getPartialFragment(a);if(s&&(this._trySkipBufferHole(s)||!this.media))return;(t.len>r.maxBufferHole||t.nextStart&&t.nextStart-a1e3*r.highBufferWatchdogPeriod&&(w.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},e._reportStall=function(t){var e=this.hls,r=this.media;if(!this.stallReported&&r){this.stallReported=!0;var i=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(t)+")");w.warn(i.message),e.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:R.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:t.len})}},e._trySkipBufferHole=function(t){var e=this.config,r=this.hls,i=this.media;if(null===i)return 0;var n=i.currentTime,a=Ir.bufferInfo(i,n,0),s=n0&&a.len<1&&i.readyState<3,u=s-n;if(u>0&&(o||l)){if(u>e.maxBufferHole){var h=this.fragmentTracker,d=!1;if(0===n){var c=h.getAppendedFrag(0,ge);c&&s1?(i=0,this.bitrateTest=!0):i=r.nextAutoLevel),this.level=r.nextLoadLevel=i,this.loadedmetadata=!1}e>0&&-1===t&&(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e),this.state=Kr,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=Gr},r.stopLoad=function(){this._forceStartLoad=!1,t.prototype.stopLoad.call(this)},r.doTick=function(){switch(this.state){case $r:var t,e=this.levels,r=this.level,i=null==e||null==(t=e[r])?void 0:t.details;if(i&&(!i.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(i))break;this.state=Kr;break}if(this.hls.nextLoadLevel!==this.level){this.state=Kr;break}break;case Yr:var n,a=self.performance.now(),s=this.retryDate;(!s||a>=s||null!=(n=this.media)&&n.seeking)&&(this.resetStartWhenNotLoaded(this.level),this.state=Kr)}this.state===Kr&&this.doTickIdle(),this.onTickEnd()},r.onTickEnd=function(){t.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},r.doTickIdle=function(){var t=this.hls,e=this.levelLastLoaded,r=this.levels,i=this.media,n=t.config,a=t.nextLoadLevel;if(null!==e&&(i||!this.startFragRequested&&n.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&null!=r&&r[a]){var s=r[a],o=this.getMainFwdBufferInfo();if(null!==o){var l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){var u={};return this.altAudio&&(u.type="video"),this.hls.trigger(S.BUFFER_EOS,u),void(this.state=Xr)}t.loadLevel!==a&&-1===t.manualLevel&&this.log("Adapting to level "+a+" from level "+this.level),this.level=t.nextLoadLevel=a;var h=s.details;if(!h||this.state===$r||h.live&&this.levelLastLoaded!==a)return this.level=a,void(this.state=$r);var d=o.len,c=this.getMaxBufferLength(s.maxBitrate);if(!(d>=c)){this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);var f=this.backtrackFragment?this.backtrackFragment.start:o.end,g=this.getNextFragment(f,h);if(this.couldBacktrack&&!this.fragPrevious&&g&&"initSegment"!==g.sn&&this.fragmentTracker.getState(g)!==mr){var v,m=(null!=(v=this.backtrackFragment)?v:g).sn-h.startSN,p=h.fragments[m-1];p&&g.cc===p.cc&&(g=p,this.fragmentTracker.removeFragment(p))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(g&&this.isLoopLoading(g,f)){if(!g.gap){var y=this.audioOnly&&!this.altAudio?O:N,T=(y===N?this.videoBuffer:this.mediaBuffer)||this.media;T&&this.afterBufferFlushed(T,y,ge)}g=this.getNextFragmentLoopLoading(g,h,o,ge,c)}g&&(!g.initSegment||g.initSegment.data||this.bitrateTest||(g=g.initSegment),this.loadFragment(g,s,f))}}}},r.loadFragment=function(e,r,i){var n=this.fragmentTracker.getState(e);this.fragCurrent=e,n===fr||n===vr?"initSegment"===e.sn?this._loadInitSegment(e,r):this.bitrateTest?(this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e,r)):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,e,r,i)):this.clearTrackerIfNeeded(e)},r.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,ge)},r.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},r.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},r.nextLevelSwitch=function(){var t=this.levels,e=this.media;if(null!=e&&e.readyState){var r,i=this.getAppendedFrag(e.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);var n=this.getLevelDetails();if(null!=n&&n.live){var a=this.getMainFwdBufferInfo();if(!a||a.len<2*n.targetduration)return}if(!e.paused&&t){var s=t[this.hls.nextLoadLevel],o=this.fragLastKbps;r=o&&this.fragCurrent?this.fragCurrent.duration*s.maxBitrate/(1e3*o)+1:0}else r=0;var l=this.getBufferedFrag(e.currentTime+r);if(l){var u=this.followingBufferedFrag(l);if(u){this.abortCurrentFrag();var h=u.maxStartPTS?u.maxStartPTS:u.start,d=u.duration,c=Math.max(l.end,h+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,.5*d),.75*d));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}},r.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case Hr:case Vr:case Yr:case jr:case qr:this.state=Kr}this.nextLoadPosition=this.getLoadPosition()},r.flushMainBuffer=function(e,r){t.prototype.flushMainBuffer.call(this,e,r,this.altAudio?"video":null)},r.onMediaAttached=function(e,r){t.prototype.onMediaAttached.call(this,e,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new dn(this.config,i,this.fragmentTracker,this.hls)},r.onMediaDetaching=function(){var e=this.media;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),t.prototype.onMediaDetaching.call(this)},r.onMediaPlaying=function(){this.tick()},r.onMediaSeeked=function(){var t=this.media,e=t?t.currentTime:null;E(e)&&this.log("Media seeked to "+e.toFixed(3));var r=this.getMainFwdBufferInfo();null!==r&&0!==r.len?this.tick():this.warn('Main forward buffer length on "seeked" event '+(r?r.len:"empty")+")")},r.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(S.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=0,this.levels=this.fragPlaying=this.backtrackFragment=null,this.altAudio=this.audioOnly=!1},r.onManifestParsed=function(t,e){var r,i,n,a=!1,s=!1;e.levels.forEach((function(t){(r=t.audioCodec)&&(-1!==r.indexOf("mp4a.40.2")&&(a=!0),-1!==r.indexOf("mp4a.40.5")&&(s=!0))})),this.audioCodecSwitch=a&&s&&!("function"==typeof(null==(n=Zr())||null==(i=n.prototype)?void 0:i.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1},r.onLevelLoading=function(t,e){var r=this.levels;if(r&&this.state===Kr){var i=r[e.level];(!i.details||i.details.live&&this.levelLastLoaded!==e.level||this.waitForCdnTuneIn(i.details))&&(this.state=$r)}},r.onLevelLoaded=function(t,e){var r,i=this.levels,n=e.level,a=e.details,s=a.totalduration;if(i){this.log("Level "+n+" loaded ["+a.startSN+","+a.endSN+"]"+(a.lastPartSn?"[part-"+a.lastPartSn+"-"+a.lastPartIndex+"]":"")+", cc ["+a.startCC+", "+a.endCC+"] duration:"+s);var o=i[n],l=this.fragCurrent;!l||this.state!==Vr&&this.state!==Yr||l.level===e.level&&l.urlId===o.urlId||!l.loader||this.abortCurrentFrag();var u=0;if(a.live||null!=(r=o.details)&&r.live){if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,o.details)}if(o.details=a,this.levelLastLoaded=n,this.hls.trigger(S.LEVEL_UPDATED,{details:a,level:n}),this.state===$r){if(this.waitForCdnTuneIn(a))return;this.state=Kr}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}else this.warn("Levels were reset while loading level "+n)},r._handleFragmentLoadProgress=function(t){var e,r=t.frag,i=t.part,n=t.payload,a=this.levels;if(a){var s=a[r.level],o=s.details;if(!o)return this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset"),void this.fragmentTracker.removeFragment(r);var l=s.videoCodec,u=o.PTSKnown||!o.live,h=null==(e=r.initSegment)?void 0:e.data,d=this._getAudioCodec(s),c=this.transmuxer=this.transmuxer||new hn(this.hls,ge,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,g=-1!==f,v=new wr(r.level,r.sn,r.stats.chunkCount,n.byteLength,f,g),m=this.initPTS[r.cc];c.push(n,h,d,l,r,i,o.totalduration,u,v,m)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},r.onAudioTrackSwitching=function(t,e){var r=this.altAudio;if(!e.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i&&(this.log("Switching to main audio track, cancel main fragment load"),i.abortRequests(),this.fragmentTracker.removeFragment(i)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var n=this.hls;r&&(n.trigger(S.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(S.AUDIO_TRACK_SWITCHED,e)}},r.onAudioTrackSwitched=function(t,e){var r=e.id,i=!!this.hls.audioTracks[r].url;if(i){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i,this.tick()},r.onBufferCreated=function(t,e){var r,i,n=e.tracks,a=!1;for(var s in n){var o=n[s];if("main"===o.id){if(i=s,r=o,"video"===s){var l=n[s];l&&(this.videoBuffer=l.buffer)}}else a=!0}a&&r?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},r.onFragBuffered=function(t,e){var r=e.frag,i=e.part;if(!r||r.type===ge){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===qr&&(this.state=Kr));var n=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}},r.onError=function(t,e){var r;if(e.fatal)this.state=zr;else switch(e.details){case R.FRAG_GAP:case R.FRAG_PARSING_ERROR:case R.FRAG_DECRYPT_ERROR:case R.FRAG_LOAD_ERROR:case R.FRAG_LOAD_TIMEOUT:case R.KEY_LOAD_ERROR:case R.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ge,e);break;case R.LEVEL_LOAD_ERROR:case R.LEVEL_LOAD_TIMEOUT:case R.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==$r||(null==(r=e.context)?void 0:r.type)!==de||(this.state=Kr);break;case R.BUFFER_FULL_ERROR:if(!e.parent||"main"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case R.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}},r.checkBuffer=function(){var t=this.media,e=this.gapController;if(t&&e&&t.readyState){if(this.loadedmetadata||!Ir.getBuffered(t).length){var r=this.state!==Kr?this.fragCurrent:null;e.poll(this.lastCurrentTime,r)}this.lastCurrentTime=t.currentTime}},r.onFragLoadEmergencyAborted=function(){this.state=Kr,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},r.onBufferFlushed=function(t,e){var r=e.type;if(r!==O||this.audioOnly&&!this.altAudio){var i=(r===N?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,ge)}},r.onLevelsUpdated=function(t,e){this.levels=e.levels},r.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},r.seekToStartPos=function(){var t=this.media;if(t){var e=t.currentTime,r=this.startPosition;if(r>=0&&e0&&(nT.cc;if(!1!==n.independent){var A=h.startPTS,k=h.endPTS,b=h.startDTS,D=h.endDTS;if(l)l.elementaryStreams[h.type]={startPTS:A,endPTS:k,startDTS:b,endDTS:D};else if(h.firstKeyFrame&&h.independent&&1===a.id&&!R&&(this.couldBacktrack=!0),h.dropped&&h.independent){var I=this.getMainFwdBufferInfo(),w=(I?I.end:this.getLoadPosition())+this.config.maxBufferHole,C=h.firstKeyFramePTS?h.firstKeyFramePTS:A;if(!L&&w1&&!1===t.seeking){var r=t.currentTime;if(Ir.isBuffered(t,r)?e=this.getAppendedFrag(r):Ir.isBuffered(t,r+.1)&&(e=this.getAppendedFrag(r+.1)),e){this.backtrackFragment=null;var i=this.fragPlaying,n=e.level;i&&e.sn===i.sn&&i.level===n&&e.urlId===i.urlId||(this.fragPlaying=e,this.hls.trigger(S.FRAG_CHANGED,{frag:e}),i&&i.level===n||this.hls.trigger(S.LEVEL_SWITCHED,{level:n}))}}},a(e,[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var e=t.currentTime,r=this.currentFrag;if(r&&E(e)&&E(r.programDateTime)){var i=r.programDateTime+1e3*(e-r.start);return new Date(i)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),e}(Jr),fn=function(){function t(t,e,r){void 0===e&&(e=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=r}var e=t.prototype;return e.sample=function(t,e){var r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t},e.getTotalWeight=function(){return this.totalWeight_},e.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},t}(),gn=function(){function t(t,e,r,i){void 0===i&&(i=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new fn(t),this.fast_=new fn(e),this.defaultTTFB_=i,this.ttfb_=new fn(t)}var e=t.prototype;return e.update=function(t,e){var r=this.slow_,i=this.fast_,n=this.ttfb_;r.halfLife!==t&&(this.slow_=new fn(t,r.getEstimate(),r.getTotalWeight())),i.halfLife!==e&&(this.fast_=new fn(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==t&&(this.ttfb_=new fn(t,n.getEstimate(),n.getTotalWeight()))},e.sample=function(t,e){var r=(t=Math.max(t,this.minDelayMs_))/1e3,i=8*e/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},e.sampleTTFB=function(t){var e=t/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(r,Math.max(t,5))},e.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},e.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},e.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},e.destroy=function(){},t}(),vn=function(){function t(t){this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=-1,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;var e=t.config;this.bwEstimator=new gn(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate),this.registerListeners()}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(S.FRAG_LOADING,this.onFragLoading,this),t.on(S.FRAG_LOADED,this.onFragLoaded,this),t.on(S.FRAG_BUFFERED,this.onFragBuffered,this),t.on(S.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(S.LEVEL_LOADED,this.onLevelLoaded,this)},e.unregisterListeners=function(){var t=this.hls;t.off(S.FRAG_LOADING,this.onFragLoading,this),t.off(S.FRAG_LOADED,this.onFragLoaded,this),t.off(S.FRAG_BUFFERED,this.onFragBuffered,this),t.off(S.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(S.LEVEL_LOADED,this.onLevelLoaded,this)},e.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},e.onFragLoading=function(t,e){var r,i=e.frag;this.ignoreFragment(i)||(this.fragCurrent=i,this.partCurrent=null!=(r=e.part)?r:null,this.clearTimer(),this.timer=self.setInterval(this.onCheck,100))},e.onLevelSwitching=function(t,e){this.clearTimer()},e.getTimeToLoadFrag=function(t,e,r,i){return t+r/e+(i?this.lastLevelLoadSec:0)},e.onLevelLoaded=function(t,e){var r=this.hls.config,i=e.stats,n=i.total,a=i.bwEstimate;E(n)&&E(a)&&(this.lastLevelLoadSec=8*n/a),e.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},e._abandonRulesCheck=function(){var t=this.fragCurrent,e=this.partCurrent,r=this.hls,i=r.autoLevelEnabled,n=r.media;if(t&&n){var a=performance.now(),s=e?e.stats:t.stats,o=e?e.duration:t.duration,l=a-s.loading.start;if(s.aborted||s.loaded&&s.loaded===s.total||0===t.level)return this.clearTimer(),void(this._nextAutoLevel=-1);if(i&&!n.paused&&n.playbackRate&&n.readyState){var u=r.mainForwardBufferInfo;if(null!==u){var h=this.bwEstimator.getEstimateTTFB(),d=Math.abs(n.playbackRate);if(!(l<=Math.max(h,o/(2*d)*1e3))){var c=u.len/d;if(!(c>=2*o/d)){var f=s.loading.first?s.loading.first-s.loading.start:-1,g=s.loaded&&f>-1,v=this.bwEstimator.getEstimate(),m=r.levels,p=r.minAutoLevel,y=m[t.level],T=s.total||Math.max(s.loaded,Math.round(o*y.maxBitrate/8)),L=l-f;L<1&&g&&(L=Math.min(l,8*s.loaded/v));var R=g?1e3*s.loaded/L:0,A=R?(T-s.loaded)/R:8*T/v+h/1e3;if(!(A<=c)){var k,b=R?8*R:v,D=Number.POSITIVE_INFINITY;for(k=t.level-1;k>p;k--){var I=m[k].maxBitrate;if((D=this.getTimeToLoadFrag(h/1e3,b,o*I,!m[k].details))=A||D>10*o||(r.nextLoadLevel=k,g?this.bwEstimator.sample(l-Math.min(h,f),s.loaded):this.bwEstimator.sampleTTFB(l),this.clearTimer(),w.warn("[abr] Fragment "+t.sn+(e?" part "+e.index:"")+" of level "+t.level+" is loading too slowly;\n Time to underbuffer: "+c.toFixed(3)+" s\n Estimated load time for current fragment: "+A.toFixed(3)+" s\n Estimated load time for down switch fragment: "+D.toFixed(3)+" s\n TTFB estimate: "+f+"\n Current BW estimate: "+(E(v)?(v/1024).toFixed(3):"Unknown")+" Kb/s\n New BW estimate: "+(this.bwEstimator.getEstimate()/1024).toFixed(3)+" Kb/s\n Aborting and switching to level "+k),t.loader&&(this.fragCurrent=this.partCurrent=null,t.abortRequests()),r.trigger(S.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:e,stats:s}))}}}}}}},e.onFragLoaded=function(t,e){var r=e.frag,i=e.part,n=i?i.stats:r.stats;if(r.type===ge&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),this.lastLoadedFragLevel=r.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var a=i?i.duration:r.duration,s=this.hls.levels[r.level],o=(s.loaded?s.loaded.bytes:0)+n.loaded,l=(s.loaded?s.loaded.duration:0)+a;s.loaded={bytes:o,duration:l},s.realBitrate=Math.round(8*o/l)}if(r.bitrateTest){var u={stats:n,frag:r,part:i,id:r.type};this.onFragBuffered(S.FRAG_BUFFERED,u),r.bitrateTest=!1}}},e.onFragBuffered=function(t,e){var r=e.frag,i=e.part,n=null!=i&&i.stats.loaded?i.stats:r.stats;if(!n.aborted&&!this.ignoreFragment(r)){var a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.bwEstimator.getEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},e.ignoreFragment=function(t){return t.type!==ge||"initSegment"===t.sn},e.clearTimer=function(){self.clearInterval(this.timer)},e.getNextABRAutoLevel=function(){var t=this.fragCurrent,e=this.partCurrent,r=this.hls,i=r.maxAutoLevel,n=r.config,a=r.minAutoLevel,s=r.media,o=e?e.duration:t?t.duration:0,l=s&&0!==s.playbackRate?Math.abs(s.playbackRate):1,u=this.bwEstimator?this.bwEstimator.getEstimate():n.abrEwmaDefaultEstimate,h=r.mainForwardBufferInfo,d=(h?h.len:0)/l,c=this.findBestLevel(u,a,i,d,n.abrBandWidthFactor,n.abrBandWidthUpFactor);if(c>=0)return c;w.trace("[abr] "+(d?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var f=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay,g=n.abrBandWidthFactor,v=n.abrBandWidthUpFactor;if(!d){var m=this.bitrateTestDelay;m&&(f=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-m,w.trace("[abr] bitrate test took "+Math.round(1e3*m)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*f)+" ms"),g=v=1)}return c=this.findBestLevel(u,a,i,d+f,g,v),Math.max(c,0)},e.findBestLevel=function(t,e,r,i,n,a){for(var s,o=this.fragCurrent,l=this.partCurrent,u=this.lastLoadedFragLevel,h=this.hls.levels,d=h[u],c=!(null==d||null==(s=d.details)||!s.live),f=null==d?void 0:d.codecSet,g=l?l.duration:o?o.duration:0,v=this.bwEstimator.getEstimateTTFB()/1e3,m=e,p=-1,y=r;y>=e;y--){var T=h[y];if(!T||f&&T.codecSet!==f)T&&(m=Math.min(y,m),p=Math.max(y,p));else{-1!==p&&w.trace("[abr] Skipped level(s) "+m+"-"+p+' with CODECS:"'+h[p].attrs.CODECS+'"; not compatible with "'+d.attrs.CODECS+'"');var S=T.details,L=(l?null==S?void 0:S.partTarget:null==S?void 0:S.averagetargetduration)||g,R=void 0;R=y<=u?n*t:a*t;var A=h[y].maxBitrate,k=this.getTimeToLoadFrag(v,R,A*L,void 0===S);if(w.trace("[abr] level:"+y+" adjustedbw-bitrate:"+Math.round(R-A)+" avgDuration:"+L.toFixed(1)+" maxFetchDuration:"+i.toFixed(1)+" fetchDuration:"+k.toFixed(1)),R>A&&(0===k||!E(k)||c&&!this.bitrateTestDelay||kMath.max(t,r)&&i[t].loadError<=i[r].loadError)return t}return-1!==t&&(r=Math.min(t,r)),r},set:function(t){this._nextAutoLevel=t}}]),t}(),mn=function(){function t(){this.chunks=[],this.dataLength=0}var e=t.prototype;return e.push=function(t){this.chunks.push(t),this.dataLength+=t.length},e.flush=function(){var t,e=this.chunks,r=this.dataLength;return e.length?(t=1===e.length?e[0]:function(t,e){for(var r=new Uint8Array(e),i=0,n=0;n0&&-1===t?(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e,this.state=Kr):(this.loadedmetadata=!1,this.state=Wr),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},r.doTick=function(){switch(this.state){case Kr:this.doTickIdle();break;case Wr:var e,r=this.levels,i=this.trackId,n=null==r||null==(e=r[i])?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=Qr}break;case Yr:var a,s=performance.now(),o=this.retryDate;(!o||s>=o||null!=(a=this.media)&&a.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded(this.trackId),this.state=Kr);break;case Qr:var l=this.waitingData;if(l){var u=l.frag,h=l.part,d=l.cache,c=l.complete;if(void 0!==this.initPTS[u.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=Vr;var f={frag:u,part:h,payload:d.flush(),networkDetails:null};this._handleFragmentLoadProgress(f),c&&t.prototype._handleFragmentLoadComplete.call(this,f)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+u.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var g=this.getLoadPosition(),v=Ir.bufferInfo(this.mediaBuffer,g,this.config.maxBufferHole);Je(v.end,this.config.maxFragLookUpTolerance,u)<0&&(this.log("Waiting fragment cc ("+u.cc+") @ "+u.start+" cancelled because another fragment at "+v.end+" is needed"),this.clearWaitingFragment())}}else this.state=Kr}this.onTickEnd()},r.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=Kr)},r.resetLoadingState=function(){this.clearWaitingFragment(),t.prototype.resetLoadingState.call(this)},r.onTickEnd=function(){var t=this.media;null!=t&&t.readyState&&(this.lastCurrentTime=t.currentTime)},r.doTickIdle=function(){var t=this.hls,e=this.levels,r=this.media,i=this.trackId,n=t.config;if(null!=e&&e[i]&&(r||!this.startFragRequested&&n.startFragPrefetch)){var a=e[i],s=a.details;if(!s||s.live&&this.levelLastLoaded!==i||this.waitForCdnTuneIn(s))this.state=Wr;else{var o=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,O,ve));var l=this.getFwdBufferInfo(o,ve);if(null!==l){var u=this.bufferedTrack,h=this.switchingTrack;if(!h&&this._streamEnded(l,s))return t.trigger(S.BUFFER_EOS,{type:"audio"}),void(this.state=Xr);var d=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,ge),c=l.len,f=this.getMaxBufferLength(null==d?void 0:d.len);if(!(c>=f)||h){var g=s.fragments[0].start,v=l.end;if(h&&r){var m=this.getLoadPosition();u&&h.attrs!==u.attrs&&(v=m),s.PTSKnown&&mg||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=g+.05)}var p=this.getNextFragment(v,s),y=!1;if(p&&this.isLoopLoading(p,v)&&(y=!!p.gap,p=this.getNextFragmentLoopLoading(p,s,l,ge,f)),p){var T=d&&p.start>d.end+s.targetduration;if(T||(null==d||!d.len)&&l.len){var E=this.getAppendedFrag(p.start,ge);if(null===E)return;if(y||(y=!!E.gap||!!T&&0===d.len),T&&!y||y&&l.nextStart&&l.nextStart=e.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var r=this.currentTrack;e[this.trackId];var n=e[t],a=n.groupId,s=n.name;if(this.log("Switching to audio-track "+t+' "'+s+'" lang:'+n.lang+" group:"+a),this.trackId=t,this.currentTrack=n,this.selectDefaultTrack=!1,this.hls.trigger(S.AUDIO_TRACK_SWITCHING,i({},n)),!n.details||n.details.live){var o=this.switchParams(n.url,null==r?void 0:r.details);this.loadPlaylist(o)}}},r.selectInitialTrack=function(){var t=this.tracksInGroup,e=this.findTrackId(this.currentTrack)|this.findTrackId(null);if(-1!==e)this.setAudioTrack(e);else{var r=new Error("No track found for running audio group-ID: "+this.groupId+" track count: "+t.length);this.warn(r.message),this.hls.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:R.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:r})}},r.findTrackId=function(t){for(var e=this.tracksInGroup,r=0;r=n[o].start&&s<=n[o].end){a=n[o];break}var l=r.start+r.duration;a?a.end=l:(a={start:s,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r)}}},r.onBufferFlushing=function(t,e){var r=e.startOffset,i=e.endOffset;if(0===r&&i!==Number.POSITIVE_INFINITY){var n=i-1;if(n<=0)return;e.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach((function(t){for(var e=0;e=s.length||n!==a)&&o){this.mediaBuffer=this.mediaBufferTimeRanges;var l=0;if(i.live||null!=(r=o.details)&&r.live){var u=this.mainDetails;if(i.deltaUpdateFailed||!u)return;var h=u.fragments[0];o.details?0===(l=this.alignPlaylists(i,o.details))&&h&&He(i,l=h.start):i.hasProgramDateTime&&u.hasProgramDateTime?(Fr(i,u),l=i.fragments[0].start):h&&He(i,l=h.start)}o.details=i,this.levelLastLoaded=n,this.startFragRequested||!this.mainDetails&&i.live||this.setStartPosition(o.details,l),this.tick(),i.live&&!this.fragCurrent&&this.media&&this.state===Kr&&($e(null,i.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0))}}},r._handleFragmentLoadComplete=function(t){var e=this,r=t.frag,i=t.payload,n=r.decryptdata,a=this.hls;if(!this.fragContextChanged(r)&&i&&i.byteLength>0&&n&&n.key&&n.iv&&"AES-128"===n.method){var s=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer).catch((function(t){throw a.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:R.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:r}),t})).then((function(t){var e=performance.now();a.trigger(S.FRAG_DECRYPTED,{frag:r,payload:t,stats:{tstart:s,tdecrypt:e}})})).catch((function(t){e.warn(t.name+": "+t.message),e.state=Kr}))}},r.doTick=function(){if(this.media){if(this.state===Kr){var t=this.currentTrackId,e=this.levels,r=e[t];if(!e.length||!r||!r.details)return;var i=this.config,n=this.getLoadPosition(),a=Ir.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,i.maxBufferHole),s=a.end,o=a.len,l=this.getFwdBufferInfo(this.media,ge),u=r.details;if(o>this.getMaxBufferLength(null==l?void 0:l.len)+u.levelTargetDuration)return;var h=u.fragments,d=h.length,c=u.edge,f=null,g=this.fragPrevious;if(sc-v?0:v;!(f=$e(g,h,Math.max(h[0].start,s),m))&&g&&g.start>>=0)>i-1)throw new DOMException("Failed to execute '"+e+"' on 'TimeRanges': The index provided ("+r+") is greater than the maximum bound ("+i+")");return t[r][e]};this.buffered={get length(){return t.length},end:function(r){return e("end",r,t.length)},start:function(r){return e("start",r,t.length)}}},Rn=function(t){function e(e){var r;return(r=t.call(this,e,"[subtitle-track-controller]")||this).media=null,r.tracks=[],r.groupId=null,r.tracksInGroup=[],r.trackId=-1,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.trackChangeListener=function(){return r.onTextTracksChanged()},r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r._subtitleDisplay=!0,r.registerListeners(),r}l(e,t);var r=e.prototype;return r.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,t.prototype.destroy.call(this)},r.registerListeners=function(){var t=this.hls;t.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_PARSED,this.onManifestParsed,this),t.on(S.LEVEL_LOADING,this.onLevelLoading,this),t.on(S.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(S.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(S.ERROR,this.onError,this)},r.unregisterListeners=function(){var t=this.hls;t.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_PARSED,this.onManifestParsed,this),t.off(S.LEVEL_LOADING,this.onLevelLoading,this),t.off(S.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(S.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(S.ERROR,this.onError,this)},r.onMediaAttached=function(t,e){this.media=e.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},r.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},r.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),An(this.media.textTracks).forEach((function(t){Le(t)})),this.subtitleTrack=-1,this.media=null)},r.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},r.onManifestParsed=function(t,e){this.tracks=e.subtitleTracks},r.onSubtitleTrackLoaded=function(t,e){var r=e.id,i=e.details,n=this.trackId,a=this.tracksInGroup[n];if(a){var s=a.details;a.details=e.details,this.log("subtitle track "+r+" loaded ["+i.startSN+"-"+i.endSN+"]"),r===this.trackId&&this.playlistLoaded(r,e,s)}else this.warn("Invalid subtitle track id "+r)},r.onLevelLoading=function(t,e){this.switchLevel(e.level)},r.onLevelSwitching=function(t,e){this.switchLevel(e.level)},r.switchLevel=function(t){var e=this.hls.levels[t];if(null!=e&&e.textGroupIds){var r=e.textGroupIds[e.urlId],i=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;if(this.groupId!==r){var n=this.tracks.filter((function(t){return!r||t.groupId===r}));this.tracksInGroup=n;var a=this.findTrackId(null==i?void 0:i.name)||this.findTrackId();this.groupId=r||null;var s={subtitleTracks:n};this.log("Updating subtitle tracks, "+n.length+' track(s) found in "'+r+'" group-id'),this.hls.trigger(S.SUBTITLE_TRACKS_UPDATED,s),-1!==a&&this.setSubtitleTrack(a,i)}else this.shouldReloadPlaylist(i)&&this.setSubtitleTrack(this.trackId,i)}},r.findTrackId=function(t){for(var e=this.tracksInGroup,r=0;r=i.length)){this.clearTimer();var n=i[t];if(this.log("Switching to subtitle-track "+t+(n?' "'+n.name+'" lang:'+n.lang+" group:"+n.groupId:"")),this.trackId=t,n){var a=n.id,s=n.groupId,o=void 0===s?"":s,l=n.name,u=n.type,h=n.url;this.hls.trigger(S.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:u,url:h});var d=this.switchParams(n.url,null==e?void 0:e.details);this.loadPlaylist(d)}else this.hls.trigger(S.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t},r.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,e=An(this.media.textTracks),r=0;r-1&&this.toggleTrackModes(this.trackId)}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1;var e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0;this.setSubtitleTrack(t,e)}}]),e}(ur);function An(t){for(var e=[],r=0;r "+t.src+")")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var e=t.prototype;return e.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},e.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null},e.registerListeners=function(){var t=this.hls;t.on(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_PARSED,this.onManifestParsed,this),t.on(S.BUFFER_RESET,this.onBufferReset,this),t.on(S.BUFFER_APPENDING,this.onBufferAppending,this),t.on(S.BUFFER_CODECS,this.onBufferCodecs,this),t.on(S.BUFFER_EOS,this.onBufferEos,this),t.on(S.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(S.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(S.FRAG_PARSED,this.onFragParsed,this),t.on(S.FRAG_CHANGED,this.onFragChanged,this)},e.unregisterListeners=function(){var t=this.hls;t.off(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_PARSED,this.onManifestParsed,this),t.off(S.BUFFER_RESET,this.onBufferReset,this),t.off(S.BUFFER_APPENDING,this.onBufferAppending,this),t.off(S.BUFFER_CODECS,this.onBufferCodecs,this),t.off(S.BUFFER_EOS,this.onBufferEos,this),t.off(S.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(S.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(S.FRAG_PARSED,this.onFragParsed,this),t.off(S.FRAG_CHANGED,this.onFragChanged,this)},e._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new kn(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.lastMpegAudioChunk=null},e.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},e.onManifestParsed=function(t,e){var r=2;(e.audio&&!e.video||!e.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,w.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},e.onMediaAttaching=function(t,e){var r=this.media=e.media;if(r&&bn){var i=this.mediaSource=new bn;i.addEventListener("sourceopen",this._onMediaSourceOpen),i.addEventListener("sourceended",this._onMediaSourceEnded),i.addEventListener("sourceclose",this._onMediaSourceClose),r.src=self.URL.createObjectURL(i),this._objectUrl=r.src,r.addEventListener("emptied",this._onMediaEmptied)}},e.onMediaDetaching=function(){var t=this.media,e=this.mediaSource,r=this._objectUrl;if(e){if(w.log("[buffer-controller]: media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){w.warn("[buffer-controller]: onMediaDetaching: "+t.message+" while calling endOfStream")}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(t.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),t.src===r?(t.removeAttribute("src"),t.load()):w.warn("[buffer-controller]: media.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(S.MEDIA_DETACHED,void 0)},e.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach((function(e){var r=t.sourceBuffer[e];try{r&&(t.removeBufferListeners(e),t.mediaSource&&t.mediaSource.removeSourceBuffer(r),t.sourceBuffer[e]=void 0)}catch(t){w.warn("[buffer-controller]: Failed to reset the "+e+" buffer",t)}})),this._initSourceBuffer()},e.onBufferCodecs=function(t,e){var r=this,i=this.getSourceBufferTypes().length;Object.keys(e).forEach((function(t){if(i){var n=r.tracks[t];if(n&&"function"==typeof n.buffer.changeType){var a=e[t],s=a.id,o=a.codec,l=a.levelCodec,u=a.container,h=a.metadata,d=(n.levelCodec||n.codec).replace(Dn,"$1"),c=(l||o).replace(Dn,"$1");if(d!==c){var f=u+";codecs="+(l||o);r.appendChangeType(t,f),w.log("[buffer-controller]: switching codec "+d+" to "+c),r.tracks[t]={buffer:n.buffer,codec:o,container:u,levelCodec:l,metadata:h,id:s}}}}else r.pendingTracks[t]=e[t]})),i||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},e.appendChangeType=function(t,e){var r=this,i=this.operationQueue,n={execute:function(){var n=r.sourceBuffer[t];n&&(w.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+e),n.changeType(e)),i.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(e){w.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",e)}};i.append(n,t)},e.onBufferAppending=function(t,e){var r=this,i=this.hls,n=this.operationQueue,a=this.tracks,s=e.data,o=e.type,l=e.frag,u=e.part,h=e.chunkMeta,d=h.buffering[o],c=self.performance.now();d.start=c;var f=l.stats.buffering,g=u?u.stats.buffering:null;0===f.start&&(f.start=c),g&&0===g.start&&(g.start=c);var v=a.audio,m=!1;"audio"===o&&"audio/mpeg"===(null==v?void 0:v.container)&&(m=!this.lastMpegAudioChunk||1===h.id||this.lastMpegAudioChunk.sn!==h.sn,this.lastMpegAudioChunk=h);var p=l.start,y={execute:function(){if(d.executeStart=self.performance.now(),m){var t=r.sourceBuffer[o];if(t){var e=p-t.timestampOffset;Math.abs(e)>=.1&&(w.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+p+" (delta: "+e+") sn: "+l.sn+")"),t.timestampOffset=p)}}r.appendExecutor(s,o)},onStart:function(){},onComplete:function(){var t=self.performance.now();d.executeEnd=d.end=t,0===f.first&&(f.first=t),g&&0===g.first&&(g.first=t);var e=r.sourceBuffer,i={};for(var n in e)i[n]=Ir.getBuffered(e[n]);r.appendError=0,r.hls.trigger(S.BUFFER_APPENDED,{type:o,frag:l,part:u,chunkMeta:h,parent:l.type,timeRanges:i})},onError:function(t){w.error("[buffer-controller]: Error encountered while trying to append to the "+o+" SourceBuffer",t);var e={type:L.MEDIA_ERROR,parent:l.type,details:R.BUFFER_APPEND_ERROR,frag:l,part:u,chunkMeta:h,error:t,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?e.details=R.BUFFER_FULL_ERROR:(r.appendError++,e.details=R.BUFFER_APPEND_ERROR,r.appendError>i.config.appendErrorMaxRetry&&(w.error("[buffer-controller]: Failed "+i.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),e.fatal=!0)),i.trigger(S.ERROR,e)}};n.append(y,o)},e.onBufferFlushing=function(t,e){var r=this,i=this.operationQueue,n=function(t){return{execute:r.removeExecutor.bind(r,t,e.startOffset,e.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(S.BUFFER_FLUSHED,{type:t})},onError:function(e){w.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",e)}}};e.type?i.append(n(e.type),e.type):this.getSourceBufferTypes().forEach((function(t){i.append(n(t),t)}))},e.onFragParsed=function(t,e){var r=this,i=e.frag,n=e.part,a=[],s=n?n.elementaryStreams:i.elementaryStreams;s[U]?a.push("audiovideo"):(s[O]&&a.push("audio"),s[N]&&a.push("video")),0===a.length&&w.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers((function(){var t=self.performance.now();i.stats.buffering.end=t,n&&(n.stats.buffering.end=t);var e=n?n.stats:i.stats;r.hls.trigger(S.FRAG_BUFFERED,{frag:i,part:n,stats:e,id:i.type})}),a)},e.onFragChanged=function(t,e){this.flushBackBuffer()},e.onBufferEos=function(t,e){var r=this;this.getSourceBufferTypes().reduce((function(t,i){var n=r.sourceBuffer[i];return!n||e.type&&e.type!==i||(n.ending=!0,n.ended||(n.ended=!0,w.log("[buffer-controller]: "+i+" sourceBuffer now EOS"))),t&&!(n&&!n.ended)}),!0)&&(w.log("[buffer-controller]: Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){r.getSourceBufferTypes().forEach((function(t){var e=r.sourceBuffer[t];e&&(e.ending=!1)}));var t=r.mediaSource;t&&"open"===t.readyState?(w.log("[buffer-controller]: Calling mediaSource.endOfStream()"),t.endOfStream()):t&&w.info("[buffer-controller]: Could not call mediaSource.endOfStream(). mediaSource.readyState: "+t.readyState)})))},e.onLevelUpdated=function(t,e){var r=e.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},e.flushBackBuffer=function(){var t=this.hls,e=this.details,r=this.media,i=this.sourceBuffer;if(r&&null!==e){var n=this.getSourceBufferTypes();if(n.length){var a=e.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if(E(a)&&!(a<0)){var s=r.currentTime,o=e.levelTargetDuration,l=Math.max(a,o),u=Math.floor(s/o)*o-l;n.forEach((function(r){var n=i[r];if(n){var a=Ir.getBuffered(n);if(a.length>0&&u>a.start(0)){if(t.trigger(S.BACK_BUFFER_REACHED,{bufferEnd:u}),e.live)t.trigger(S.LIVE_BACK_BUFFER_REACHED,{bufferEnd:u});else if(n.ended&&a.end(a.length-1)-s<2*o)return void w.info("[buffer-controller]: Cannot flush "+r+" back buffer while SourceBuffer is in ended state");t.trigger(S.BUFFER_FLUSHING,{startOffset:0,endOffset:u,type:r})}}}))}}}},e.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var t=this.details,e=this.hls,r=this.media,i=this.mediaSource,n=t.fragments[0].start+t.totalduration,a=r.duration,s=E(i.duration)?i.duration:0;t.live&&e.config.liveDurationInfinity?(w.log("[buffer-controller]: Media Source duration is set to Infinity"),i.duration=1/0,this.updateSeekableRange(t)):(n>s&&n>a||!E(a))&&(w.log("[buffer-controller]: Updating Media Source duration to "+n.toFixed(3)),i.duration=n)}},e.updateSeekableRange=function(t){var e=this.mediaSource,r=t.fragments;if(r.length&&t.live&&null!=e&&e.setLiveSeekableRange){var i=Math.max(0,r[0].start),n=Math.max(i,i+t.totalduration);e.setLiveSeekableRange(i,n)}},e.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,e=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&!t||2===i){this.createSourceBuffers(r),this.pendingTracks={};var n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(S.BUFFER_CREATED,{tracks:this.tracks}),n.forEach((function(t){e.executeNext(t)}));else{var a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:R.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}},e.createSourceBuffers=function(t){var e=this.sourceBuffer,r=this.mediaSource;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(var i in t)if(!e[i]){var n=t[i];if(!n)throw Error("source buffer exists for track "+i+", however track does not");var a=n.levelCodec||n.codec,s=n.container+";codecs="+a;w.log("[buffer-controller]: creating sourceBuffer("+s+")");try{var o=e[i]=r.addSourceBuffer(s),l=i;this.addBufferListener(l,"updatestart",this._onSBUpdateStart),this.addBufferListener(l,"updateend",this._onSBUpdateEnd),this.addBufferListener(l,"error",this._onSBUpdateError),this.tracks[i]={buffer:o,codec:a,container:n.container,levelCodec:n.levelCodec,metadata:n.metadata,id:n.id}}catch(t){w.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:R.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:s})}}},e._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},e._onSBUpdateEnd=function(t){var e=this.operationQueue;e.current(t).onComplete(),e.shiftAndExecuteNext(t)},e._onSBUpdateError=function(t,e){var r=new Error(t+" SourceBuffer error");w.error("[buffer-controller]: "+r,e),this.hls.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:R.BUFFER_APPENDING_ERROR,error:r,fatal:!1});var i=this.operationQueue.current(t);i&&i.onError(e)},e.removeExecutor=function(t,e,r){var i=this.media,n=this.mediaSource,a=this.operationQueue,s=this.sourceBuffer[t];if(!i||!n||!s)return w.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void a.shiftAndExecuteNext(t);var o=E(i.duration)?i.duration:1/0,l=E(n.duration)?n.duration:1/0,u=Math.max(0,e),h=Math.min(r,o,l);h>u&&!s.ending?(s.ended=!1,w.log("[buffer-controller]: Removing ["+u+","+h+"] from the "+t+" SourceBuffer"),s.remove(u,h)):a.shiftAndExecuteNext(t)},e.appendExecutor=function(t,e){var r=this.operationQueue,i=this.sourceBuffer[e];if(!i)return w.warn("[buffer-controller]: Attempting to append to the "+e+" SourceBuffer, but it does not exist"),void r.shiftAndExecuteNext(e);i.ended=!1,i.appendBuffer(t)},e.blockBuffers=function(t,e){var r=this;if(void 0===e&&(e=this.getSourceBufferTypes()),!e.length)return w.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(t);var i=this.operationQueue,n=e.map((function(t){return i.appendBlocker(t)}));Promise.all(n).then((function(){t(),e.forEach((function(t){var e=r.sourceBuffer[t];null!=e&&e.updating||i.shiftAndExecuteNext(t)}))}))},e.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},e.addBufferListener=function(t,e,r){var i=this.sourceBuffer[t];if(i){var n=r.bind(this,t);this.listeners[t].push({event:e,listener:n}),i.addEventListener(e,n)}},e.removeBufferListeners=function(t){var e=this.sourceBuffer[t];e&&this.listeners[t].forEach((function(t){e.removeEventListener(t.event,t.listener)}))},t}(),wn={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},Cn=function(t){var e=t;return wn.hasOwnProperty(t)&&(e=wn[t]),String.fromCharCode(e)},_n=15,Pn=100,xn={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Fn={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Mn={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},On={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Nn=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],Un=function(){function t(){this.time=null,this.verboseLevel=0}return t.prototype.log=function(t,e){if(this.verboseLevel>=t){var r="function"==typeof e?e():e;w.log(this.time+" ["+t+"] "+r)}},t}(),Bn=function(t){for(var e=[],r=0;rPn&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Pn)},e.moveCursor=function(t){var e=this.pos+t;if(t>1)for(var r=this.pos+1;r=144&&this.backSpace();var r=Cn(t);this.pos>=Pn?this.logger.log(0,(function(){return"Cannot insert "+t.toString(16)+" ("+r+") at position "+e.pos+". Skipping it!"})):(this.chars[this.pos].setChar(r,this.currPenState),this.moveCursor(1))},e.clearFromPos=function(t){var e;for(e=t;e0&&(r=t?"["+e.join(" | ")+"]":e.join("\n")),r},e.getTextAndFormat=function(){return this.rows},t}(),Yn=function(){function t(t,e,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new Vn(r),this.nonDisplayedMemory=new Vn(r),this.lastOutputScreen=new Vn(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var e=t.prototype;return e.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},e.getHandler=function(){return this.outputFilter},e.setHandler=function(t){this.outputFilter=t},e.setPAC=function(t){this.writeScreen.setPAC(t)},e.setBkgData=function(t){this.writeScreen.setBkgData(t)},e.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(2,(function(){return"MODE="+t})),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)},e.insertChars=function(t){for(var e=this,r=0;r=46,e.italics)e.foreground="white";else{var r=Math.floor(t/2)-16;e.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(2,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)},e.outputDataUpdate=function(t){void 0===t&&(t=!1);var e=this.logger.time;null!==e&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))},e.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},t}(),Wn=function(){function t(t,e,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var i=new Un;this.channels=[null,new Yn(t,e,i),new Yn(t+1,r,i)],this.cmdHistory={a:null,b:null},this.logger=i}var e=t.prototype;return e.getHandler=function(t){return this.channels[t].getHandler()},e.setHandler=function(t,e){this.channels[t].setHandler(e)},e.addData=function(t,e){var r,i,n,a=!1;this.logger.time=t;for(var s=0;s ("+Bn([i,n])+")"),(r=this.parseCmd(i,n))||(r=this.parseMidrow(i,n)),r||(r=this.parsePAC(i,n)),r||(r=this.parseBackgroundAttributes(i,n)),!r&&(a=this.parseChars(i,n))){var o=this.currentChannel;o&&o>0?this.channels[o].insertChars(a):this.logger.log(2,"No channel found yet. TEXT-MODE?")}r||a||this.logger.log(2,"Couldn't parse cleaned data "+Bn([i,n])+" orig: "+Bn([e[s],e[s+1]]))}},e.parseCmd=function(t,e){var r=this.cmdHistory;if(!((20===t||28===t||21===t||29===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=33&&e<=35))return!1;if(qn(t,e,r))return jn(null,null,r),this.logger.log(3,"Repeated command ("+Bn([t,e])+") is dropped"),!0;var i=20===t||21===t||23===t?1:2,n=this.channels[i];return 20===t||21===t||28===t||29===t?32===e?n.ccRCL():33===e?n.ccBS():34===e?n.ccAOF():35===e?n.ccAON():36===e?n.ccDER():37===e?n.ccRU(2):38===e?n.ccRU(3):39===e?n.ccRU(4):40===e?n.ccFON():41===e?n.ccRDC():42===e?n.ccTR():43===e?n.ccRTD():44===e?n.ccEDM():45===e?n.ccCR():46===e?n.ccENM():47===e&&n.ccEOC():n.ccTO(e-32),jn(t,e,r),this.currentChannel=i,!0},e.parseMidrow=function(t,e){var r=0;if((17===t||25===t)&&e>=32&&e<=47){if((r=17===t?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var i=this.channels[r];return!!i&&(i.ccMIDROW(e),this.logger.log(3,"MIDROW ("+Bn([t,e])+")"),!0)}return!1},e.parsePAC=function(t,e){var r,i=this.cmdHistory;if(!((t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127||(16===t||24===t)&&e>=64&&e<=95))return!1;if(qn(t,e,i))return jn(null,null,i),!0;var n=t<=23?1:2;r=e>=64&&e<=95?1===n?xn[t]:Mn[t]:1===n?Fn[t]:On[t];var a=this.channels[n];return!!a&&(a.setPAC(this.interpretPAC(r,e)),jn(t,e,i),this.currentChannel=n,!0)},e.interpretPAC=function(t,e){var r,i={color:null,italics:!1,indent:null,underline:!1,row:t};return r=e>95?e-96:e-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},e.parseChars=function(t,e){var r,i,n=null,a=null;if(t>=25?(r=2,a=t-8):(r=1,a=t),a>=17&&a<=19?(i=17===a?e+80:18===a?e+112:e+144,this.logger.log(2,"Special char '"+Cn(i)+"' in channel "+r),n=[i]):t>=32&&t<=127&&(n=0===e?[t]:[t,e]),n){var s=Bn(n);this.logger.log(3,"Char codes = "+s.join(",")),jn(t,e,this.cmdHistory)}return n},e.parseBackgroundAttributes=function(t,e){var r;if(!((16===t||24===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=45&&e<=47))return!1;var i={};16===t||24===t?(r=Math.floor((e-32)/2),i.background=Nn[r],e%2==1&&(i.background=i.background+"_semi")):45===e?i.background="transparent":(i.foreground="black",47===e&&(i.underline=!0));var n=t<=23?1:2;return this.channels[n].setBkgData(i),jn(t,e,this.cmdHistory),!0},e.reset=function(){for(var t=0;tt)&&(this.startTime=t),this.endTime=e,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},e.reset=function(){this.cueRanges=[],this.startTime=null},t}(),zn=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var t=["","lr","rl"],e=["start","middle","end","left","right"];function r(t,e){if("string"!=typeof e)return!1;if(!Array.isArray(t))return!1;var r=e.toLowerCase();return!!~t.indexOf(r)&&r}function i(t){return r(e,t)}function n(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i100)throw new Error("Position must be between 0 and 100.");T=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",n({},l,{get:function(){return E},set:function(t){var e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");E=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",n({},l,{get:function(){return S},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");S=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",n({},l,{get:function(){return L},set:function(t){var e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");L=e,this.hasBeenReset=!0}})),o.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),Qn=function(){function t(){}return t.prototype.decode=function(t,e){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))},t}();function $n(t){function e(t,e,r,i){return 3600*(0|t)+60*(0|e)+(0|r)+parseFloat(i||0)}var r=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?e(r[2],r[3],0,r[4]):e(r[1],r[2],r[3],r[4]):null}var Jn=function(){function t(){this.values=Object.create(null)}var e=t.prototype;return e.set=function(t,e){this.get(t)||""===e||(this.values[t]=e)},e.get=function(t,e,r){return r?this.has(t)?this.values[t]:e[r]:this.has(t)?this.values[t]:e},e.has=function(t){return t in this.values},e.alt=function(t,e,r){for(var i=0;i=0&&r<=100)return this.set(t,r),!0}return!1},t}();function Zn(t,e,r,i){var n=i?t.split(i):[t];for(var a in n)if("string"==typeof n[a]){var s=n[a].split(r);2===s.length&&e(s[0],s[1])}}var ta=new zn(0,0,""),ea="middle"===ta.align?"middle":"center";function ra(t,e,r){var i=t;function n(){var e=$n(t);if(null===e)throw new Error("Malformed timestamp: "+i);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function a(){t=t.replace(/^\s+/,"")}if(a(),e.startTime=n(),a(),"--\x3e"!==t.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);t=t.slice(3),a(),e.endTime=n(),a(),function(t,e){var i=new Jn;Zn(t,(function(t,e){var n;switch(t){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===e){i.set(t,r[a].region);break}break;case"vertical":i.alt(t,e,["rl","lr"]);break;case"line":n=e.split(","),i.integer(t,n[0]),i.percent(t,n[0])&&i.set("snapToLines",!1),i.alt(t,n[0],["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",ea,"end"]);break;case"position":n=e.split(","),i.percent(t,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",ea,"end","line-left","line-right","auto"]);break;case"size":i.percent(t,e);break;case"align":i.alt(t,e,["start",ea,"end","left","right"])}}),/:/,/\s/),e.region=i.get("region",null),e.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===ta.line&&(n=-1),e.line=n,e.lineAlign=i.get("lineAlign","start"),e.snapToLines=i.get("snapToLines",!0),e.size=i.get("size",100),e.align=i.get("align",ea);var a=i.get("position","auto");"auto"===a&&50===ta.position&&(a="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=a}(t,e)}function ia(t){return t.replace(//gi,"\n")}var na=function(){function t(){this.state="INITIAL",this.buffer="",this.decoder=new Qn,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var e=t.prototype;return e.parse=function(t){var e=this;function r(){var t=e.buffer,r=0;for(t=ia(t);r>>0).toString()};function la(t,e,r){return oa(t.toString())+oa(e.toString())+oa(r)}function ua(t,e,r,i,n,a,s){var o,l,u,h=new na,d=pt(new Uint8Array(t)).trim().replace(aa,"\n").split("\n"),c=[],f=e?(o=e.baseTime,void 0===(l=e.timescale)&&(l=1),Ui(o,9e4,1/l)):0,g="00:00.000",v=0,m=0,p=!0;h.oncue=function(t){var a=r[i],s=r.ccOffset,o=(v-f)/9e4;if(null!=a&&a.new&&(void 0!==m?s=r.ccOffset=a.start:function(t,e,r){var i=t[e],n=t[i.prevCC];if(!n||!n.new&&i.new)return t.ccOffset=t.presentationOffset=i.start,void(i.new=!1);for(;null!=(a=n)&&a.new;){var a;t.ccOffset+=i.start-n.start,i.new=!1,n=t[(i=n).prevCC]}t.presentationOffset=r}(r,i,o)),o){if(!e)return void(u=new Error("Missing initPTS for VTT MPEGTS"));s=o-r.presentationOffset}var l=t.endTime-t.startTime,h=Vi(9e4*(t.startTime+s-m),9e4*n)/9e4;t.startTime=Math.max(h,0),t.endTime=Math.max(h+l,0);var d=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(d)),t.id||(t.id=la(t.startTime,t.endTime,d)),t.endTime>0&&c.push(t)},h.onparsingerror=function(t){u=t},h.onflush=function(){u?s(u):a(c)},d.forEach((function(t){if(p){if(sa(t,"X-TIMESTAMP-MAP=")){p=!1,t.slice(16).split(",").forEach((function(t){sa(t,"LOCAL:")?g=t.slice(6):sa(t,"MPEGTS:")&&(v=parseInt(t.slice(7)))}));try{m=function(t){var e=parseInt(t.slice(-3)),r=parseInt(t.slice(-6,-4)),i=parseInt(t.slice(-9,-7)),n=t.length>9?parseInt(t.substring(0,t.indexOf(":"))):0;if(!(E(e)&&E(r)&&E(i)&&E(n)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+t);return e+=1e3*r,(e+=6e4*i)+36e5*n}(g)/1e3}catch(t){u=t}return}""===t&&(p=!1)}h.parse(t+"\n")})),h.flush()}var ha="stpp.ttml.im1t",da=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,ca=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,fa={left:"start",center:"center",right:"end",start:"start",end:"end"};function ga(t,e,r,i){var n=It(new Uint8Array(t),["mdat"]);if(0!==n.length){var a,s,l,u,h=n.map((function(t){return pt(t)})),d=(a=e.baseTime,s=1,void 0===(l=e.timescale)&&(l=1),void 0===u&&(u=!1),Ui(a,s,1/l,u));try{h.forEach((function(t){return r(function(t,e){var r=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");var i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},n=Object.keys(i).reduce((function(t,e){return t[e]=r.getAttribute("ttp:"+e)||i[e],t}),{}),a="preserve"!==r.getAttribute("xml:space"),s=ma(va(r,"styling","style")),l=ma(va(r,"layout","region")),u=va(r,"body","[begin]");return[].map.call(u,(function(t){var r=pa(t,a);if(!r||!t.hasAttribute("begin"))return null;var i=Ea(t.getAttribute("begin"),n),u=Ea(t.getAttribute("dur"),n),h=Ea(t.getAttribute("end"),n);if(null===i)throw Ta(t);if(null===h){if(null===u)throw Ta(t);h=i+u}var d=new zn(i-e,h-e,r);d.id=la(d.startTime,d.endTime,d.text);var c=function(t,e,r){var i="http://www.w3.org/ns/ttml#styling",n=null,a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],s=null!=t&&t.hasAttribute("style")?t.getAttribute("style"):null;return s&&r.hasOwnProperty(s)&&(n=r[s]),a.reduce((function(r,a){var s=ya(e,i,a)||ya(t,i,a)||ya(n,i,a);return s&&(r[a]=s),r}),{})}(l[t.getAttribute("region")],s[t.getAttribute("style")],s),f=c.textAlign;if(f){var g=fa[f];g&&(d.lineAlign=g),d.align=f}return o(d,c),d})).filter((function(t){return null!==t}))}(t,d))}))}catch(t){i(t)}}else i(new Error("Could not parse IMSC1 mdat"))}function va(t,e,r){var i=t.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function ma(t){return t.reduce((function(t,e){var r=e.getAttribute("xml:id");return r&&(t[r]=e),t}),{})}function pa(t,e){return[].slice.call(t.childNodes).reduce((function(t,r,i){var n;return"br"===r.nodeName&&i?t+"\n":null!=(n=r.childNodes)&&n.length?pa(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent}),"")}function ya(t,e,r){return t&&t.hasAttributeNS(e,r)?t.getAttributeNS(e,r):null}function Ta(t){return new Error("Could not parse ttml timestamp "+t)}function Ea(t,e){if(!t)return null;var r=$n(t);return null===r&&(da.test(t)?r=function(t,e){var r=da.exec(t),i=(0|r[4])+(0|r[5])/e.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/e.frameRate}(t,e):ca.test(t)&&(r=function(t,e){var r=ca.exec(t),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}(t,e))),r}var Sa=function(){function t(t){if(this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},this.config.enableCEA708Captions){var e=new Xn(this,"textTrack1"),r=new Xn(this,"textTrack2"),i=new Xn(this,"textTrack3"),n=new Xn(this,"textTrack4");this.cea608Parser1=new Wn(1,e,r),this.cea608Parser2=new Wn(3,i,n)}t.on(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(S.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(S.FRAG_LOADING,this.onFragLoading,this),t.on(S.FRAG_LOADED,this.onFragLoaded,this),t.on(S.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(S.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(S.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(S.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(S.BUFFER_FLUSHING,this.onBufferFlushing,this)}var e=t.prototype;return e.destroy=function(){var t=this.hls;t.off(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(S.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(S.FRAG_LOADING,this.onFragLoading,this),t.off(S.FRAG_LOADED,this.onFragLoaded,this),t.off(S.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(S.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(S.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(S.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(S.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},e.addCues=function(t,e,r,i,n){for(var a,s,o,l,u=!1,h=n.length;h--;){var d=n[h],c=(a=d[0],s=d[1],o=e,l=r,Math.min(s,l)-Math.max(a,o));if(c>=0&&(d[0]=Math.min(d[0],e),d[1]=Math.max(d[1],r),u=!0,c/(r-e)>.5))return}if(u||n.push([e,r]),this.config.renderTextTracksNatively){var f=this.captionsTracks[t];this.Cues.newCue(f,e,r,i)}else{var g=this.Cues.newCue(null,e,r,i);this.hls.trigger(S.CUES_PARSED,{type:"captions",cues:g,track:t})}},e.onInitPtsFound=function(t,e){var r=this,i=e.frag,n=e.id,a=e.initPTS,s=e.timescale,o=this.unparsedVttFrags;"main"===n&&(this.initPTS[i.cc]={baseTime:a,timescale:s}),o.length&&(this.unparsedVttFrags=[],o.forEach((function(t){r.onFragLoaded(S.FRAG_LOADED,t)})))},e.getExistingTrack=function(t){var e=this.media;if(e)for(var r=0;ri.cc||l.trigger(S.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:e})}))}else s.push(t)},e._fallbackToIMSC1=function(t,e){var r=this,i=this.tracks[t.level];i.textCodec||ga(e,this.initPTS[t.cc],(function(){i.textCodec=ha,r._parseIMSC1(t,e)}),(function(){i.textCodec="wvtt"}))},e._appendCues=function(t,e){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[e];if(!i||"disabled"===i.mode)return;t.forEach((function(t){return Se(i,t)}))}else{var n=this.tracks[e];if(!n)return;var a=n.default?"default":"subtitles"+e;r.trigger(S.CUES_PARSED,{type:"subtitles",cues:t,track:a})}},e.onFragDecrypted=function(t,e){e.frag.type===me&&this.onFragLoaded(S.FRAG_LOADED,e)},e.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},e.onFragParsingUserdata=function(t,e){var r=this.cea608Parser1,i=this.cea608Parser2;if(this.enabled&&r&&i){var n=e.frag,a=e.samples;if(n.type!==ge||"NONE"!==this.closedCaptionsForLevel(n))for(var s=0;s0&&this.mediaWidth>0){var t=this.hls.levels;if(t.length){var e=this.hls;e.autoLevelCapping=this.getMaxLevel(t.length-1),e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},e.getMaxLevel=function(e){var r=this,i=this.hls.levels;if(!i.length)return-1;var n=i.filter((function(t,i){return r.isLevelAllowed(t)&&i<=e}));return this.clientRect=null,t.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)},e.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},e.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},e.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,e={width:0,height:0};if(t){var r=t.getBoundingClientRect();e.width=r.width,e.height=r.height,e.width||e.height||(e.width=r.right-r.left||t.width||0,e.height=r.bottom-r.top||t.height||0)}return this.clientRect=e,e},e.isLevelAllowed=function(t){return!this.restrictedLevels.some((function(e){return t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height}))},t.getMaxLevelByMediaSize=function(t,e,r){if(null==t||!t.length)return-1;for(var i,n,a=t.length-1,s=0;s=e||o.height>=r)&&(i=o,!(n=t[s+1])||i.width!==n.width||i.height!==n.height)){a=s;break}}return a},a(t,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch(t){}return t}}]),t}(),Aa=function(){function t(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}var e=t.prototype;return e.setStreamController=function(t){this.streamController=t},e.registerListeners=function(){this.hls.on(S.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.unregisterListeners=function(){this.hls.off(S.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},e.onMediaAttaching=function(t,e){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=i,i&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},e.checkFPS=function(t,e,r){var i=performance.now();if(e){if(this.lastTime){var n=i-this.lastTime,a=r-this.lastDroppedFrames,s=e-this.lastDecodedFrames,o=1e3*a/n,l=this.hls;if(l.trigger(S.FPS_DROP,{currentDropped:a,currentDecoded:s,totalDroppedFrames:r}),o>0&&a>l.config.fpsDroppedMonitoringThreshold*s){var u=l.currentLevel;w.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=u)&&(u-=1,l.trigger(S.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},e.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},t}(),ka="[eme]",ba=function(){function t(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=t.CDMCleanupPromise?[t.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=w.debug.bind(w,ka),this.log=w.log.bind(w,ka),this.warn=w.warn.bind(w,ka),this.error=w.error.bind(w,ka),this.hls=e,this.config=e.config,this.registerListeners()}var e=t.prototype;return e.destroy=function(){this.unregisterListeners(),this.onMediaDetached();var t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null},e.registerListeners=function(){this.hls.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(S.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(S.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(S.MANIFEST_LOADED,this.onManifestLoaded,this)},e.unregisterListeners=function(){this.hls.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(S.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(S.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(S.MANIFEST_LOADED,this.onManifestLoaded,this)},e.getLicenseServerUrl=function(t){var e=this.config,r=e.drmSystems,i=e.widevineLicenseUrl,n=r[t];if(n)return n.licenseUrl;if(t===j.WIDEVINE&&i)return i;throw new Error('no license server URL configured for key-system "'+t+'"')},e.getServerCertificateUrl=function(t){var e=this.config.drmSystems[t];if(e)return e.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+t+'"]')},e.attemptKeySystemAccess=function(t){var e=this,r=this.hls.levels,i=function(t,e,r){return!!t&&r.indexOf(t)===e},n=r.map((function(t){return t.audioCodec})).filter(i),a=r.map((function(t){return t.videoCodec})).filter(i);return n.length+a.length===0&&a.push("avc1.42e01e"),new Promise((function(r,i){!function t(s){var o=s.shift();e.getMediaKeysPromise(o,n,a).then((function(t){return r({keySystem:o,mediaKeys:t})})).catch((function(e){s.length?t(s):i(e instanceof Da?e:new Da({type:L.KEY_SYSTEM_ERROR,details:R.KEY_SYSTEM_NO_ACCESS,error:e,fatal:!0},e.message))}))}(t)}))},e.requestMediaKeySystemAccess=function(t,e){var r=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof r){var i="Configured requestMediaKeySystemAccess is not a function "+r;return null===et&&"http:"===self.location.protocol&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(i))}return r(t,e)},e.getMediaKeysPromise=function(t,e,r){var i=this,n=function(t,e,r,i){var n;switch(t){case j.FAIRPLAY:n=["cenc","sinf"];break;case j.WIDEVINE:case j.PLAYREADY:n=["cenc"];break;case j.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+t)}return function(t,e,r,i){return[{initDataTypes:t,persistentState:i.persistentState||"not-allowed",distinctiveIdentifier:i.distinctiveIdentifier||"not-allowed",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map((function(t){return{contentType:'audio/mp4; codecs="'+t+'"',robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null}})),videoCapabilities:r.map((function(t){return{contentType:'video/mp4; codecs="'+t+'"',robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}}))}]}(n,e,r,i)}(t,e,r,this.config.drmSystemOptions),a=this.keySystemAccessPromises[t],s=null==a?void 0:a.keySystemAccess;if(!s){this.log('Requesting encrypted media "'+t+'" key-system access with config: '+JSON.stringify(n)),s=this.requestMediaKeySystemAccess(t,n);var o=this.keySystemAccessPromises[t]={keySystemAccess:s};return s.catch((function(e){i.log('Failed to obtain access to key-system "'+t+'": '+e)})),s.then((function(e){i.log('Access for key-system "'+e.keySystem+'" obtained');var r=i.fetchServerCertificate(t);return i.log('Create media-keys for "'+t+'"'),o.mediaKeys=e.createMediaKeys().then((function(e){return i.log('Media-keys created for "'+t+'"'),r.then((function(r){return r?i.setMediaKeysServerCertificate(e,t,r):e}))})),o.mediaKeys.catch((function(e){i.error('Failed to create media-keys for "'+t+'"}: '+e)})),o.mediaKeys}))}return s.then((function(){return a.mediaKeys}))},e.createMediaKeySessionContext=function(t){var e=t.decryptdata,r=t.keySystem,i=t.mediaKeys;this.log('Creating key-system session "'+r+'" keyId: '+Tt(e.keyId||[]));var n=i.createSession(),a={decryptdata:e,keySystem:r,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(a),a},e.renewKeySession=function(t){var e=t.decryptdata;if(e.pssh){var r=this.createMediaKeySessionContext(t),i=this.getKeyIdString(e);this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,"cenc",e.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)},e.getKeyIdString=function(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(null===t.keyId)throw new Error("keyId is null");return Tt(t.keyId)},e.updateKeySession=function(t,e){var r,i=t.mediaKeysSession;return this.log('Updating key-session "'+i.sessionId+'" for keyID '+Tt((null==(r=t.decryptdata)?void 0:r.keyId)||[])+"\n } (data length: "+(e?e.byteLength:e)+")"),i.update(e)},e.selectKeySystemFormat=function(t){var e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+t.sn+" "+t.type+": "+t.level+") key formats "+e.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise},e.getKeyFormatPromise=function(t){var e=this;return new Promise((function(r,i){var n=tt(e.config),a=t.map($).filter((function(t){return!!t&&-1!==n.indexOf(t)}));return e.getKeySystemSelectionPromise(a).then((function(t){var e=t.keySystem,n=Z(e);n?r(n):i(new Error('Unable to find format for key-system "'+e+'"'))})).catch(i)}))},e.loadKey=function(t){var e=this,r=t.keyInfo.decryptdata,i=this.getKeyIdString(r),n="(keyId: "+i+' format: "'+r.keyFormat+'" method: '+r.method+" uri: "+r.uri+")";this.log("Starting session for key "+n);var a=this.keyIdToKeySessionPromise[i];return a||(a=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(r).then((function(i){var a=i.keySystem,s=i.mediaKeys;return e.throwIfDestroyed(),e.log("Handle encrypted media sn: "+t.frag.sn+" "+t.frag.type+": "+t.frag.level+" using key "+n),e.attemptSetMediaKeys(a,s).then((function(){e.throwIfDestroyed();var t=e.createMediaKeySessionContext({keySystem:a,mediaKeys:s,decryptdata:r});return e.generateRequestWithPreferredKeySession(t,"cenc",r.pssh,"playlist-key")}))}))).catch((function(t){return e.handleError(t)})),a},e.throwIfDestroyed=function(t){if(!this.hls)throw new Error("invalid state")},e.handleError=function(t){this.hls&&(this.error(t.message),t instanceof Da?this.hls.trigger(S.ERROR,t.data):this.hls.trigger(S.ERROR,{type:L.KEY_SYSTEM_ERROR,details:R.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))},e.getKeySystemForKeyPromise=function(t){var e=this.getKeyIdString(t),r=this.keyIdToKeySessionPromise[e];if(!r){var i=$(t.keyFormat),n=i?[i]:tt(this.config);return this.attemptKeySystemAccess(n)}return r},e.getKeySystemSelectionPromise=function(t){if(t.length||(t=tt(this.config)),0===t.length)throw new Da({type:L.KEY_SYSTEM_ERROR,details:R.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(t)},e._onMediaEncrypted=function(t){var e=this,r=t.initDataType,i=t.initData;if(this.debug('"'+t.type+'" event: init data type: "'+r+'"'),null!==i){var n,a;if("sinf"===r&&this.config.drmSystems[j.FAIRPLAY]){var s=Rt(new Uint8Array(i));try{var o=V(JSON.parse(s).sinf),l=_t(new Uint8Array(o));if(!l)return;n=l.subarray(8,24),a=j.FAIRPLAY}catch(t){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var u=function(t){if(!(t instanceof ArrayBuffer)||t.byteLength<32)return null;var e={version:0,systemId:"",kids:null,data:null},r=new DataView(t),i=r.getUint32(0);if(t.byteLength!==i&&i>44)return null;if(1886614376!==r.getUint32(4))return null;if(e.version=r.getUint32(8)>>>24,e.version>1)return null;e.systemId=Tt(new Uint8Array(t,12,16));var n=r.getUint32(28);if(0===e.version){if(i-32d||o.status>=400&&o.status<500)a(new Da({type:L.KEY_SYSTEM_ERROR,details:R.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:s,data:void 0,code:o.status,text:o.statusText}},"License Request XHR failed ("+s+"). Status: "+o.status+" ("+o.statusText+")"));else{var c=d-r._requestLicenseFailureCount+1;r.warn("Retrying license request, "+c+" attempts left"),r.requestLicense(t,e).then(n,a)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=o,r.setupLicenseXHR(o,s,t,e).then((function(t){var e=t.xhr,r=t.licenseChallenge;e.send(r)}))}))},e.onMediaAttached=function(t,e){if(this.config.emeEnabled){var r=e.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}},e.onMediaDetached=function(){var e=this,r=this.media,i=this.mediaKeySessions;r&&(r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Gt.clearKeyUriToKeyIdMap();var n=i.length;t.CDMCleanupPromise=Promise.all(i.map((function(t){return e.removeSession(t)})).concat(null==r?void 0:r.setMediaKeys(null).catch((function(t){e.log("Could not clear media keys: "+t+". media.src: "+(null==r?void 0:r.src))})))).then((function(){n&&(e.log("finished closing key sessions and clearing media keys"),i.length=0)})).catch((function(t){e.log("Could not close sessions and clear media keys: "+t+". media.src: "+(null==r?void 0:r.src))}))},e.onManifestLoading=function(){this.keyFormatPromise=null},e.onManifestLoaded=function(t,e){var r=e.sessionKeys;if(r&&this.config.emeEnabled&&!this.keyFormatPromise){var i=r.reduce((function(t,e){return-1===t.indexOf(e.keyFormat)&&t.push(e.keyFormat),t}),[]);this.log("Selecting key-system from session-keys "+i.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(i)}},e.removeSession=function(t){var e=this,r=t.mediaKeysSession,i=t.licenseXhr;if(r){this.log("Remove licenses and keys and close session "+r.sessionId),r.onmessage=null,r.onkeystatuseschange=null,i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;var n=this.mediaKeySessions.indexOf(t);return n>-1&&this.mediaKeySessions.splice(n,1),r.remove().catch((function(t){e.log("Could not remove session: "+t)})).then((function(){return r.close()})).catch((function(t){e.log("Could not close session: "+t)}))}},t}();ba.CDMCleanupPromise=void 0;var Da=function(t){function e(e,r){var i;return(i=t.call(this,r)||this).data=void 0,e.error||(e.error=new Error(r)),i.data=e,e.err=e.error,i}return l(e,t),e}(f(Error)),Ia="m",wa="a",Ca="v",_a="av",Pa="i",xa="tt",Fa=function(){function t(e){var r=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){r.initialized&&(r.starved=!0),r.buffering=!0},this.onPlaying=function(){r.initialized||(r.initialized=!0),r.buffering=!1},this.applyPlaylistData=function(t){try{r.apply(t,{ot:Ia,su:!r.initialized})}catch(t){w.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=function(t){try{var e=t.frag,i=r.hls.levels[e.level],n=r.getObjectType(e),a={d:1e3*e.duration,ot:n};n!==Ca&&n!==wa&&n!=_a||(a.br=i.bitrate/1e3,a.tb=r.getTopBandwidth(n)/1e3,a.bl=r.getBufferLength(n)),r.apply(t,a)}catch(t){w.warn("Could not generate segment CMCD data.",t)}},this.hls=e;var i=this.config=e.config,n=i.cmcd;null!=n&&(i.pLoader=this.createPlaylistLoader(),i.fLoader=this.createFragmentLoader(),this.sid=n.sessionId||t.uuid(),this.cid=n.contentId,this.useHeaders=!0===n.useHeaders,this.registerListeners())}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(S.MEDIA_DETACHED,this.onMediaDetached,this),t.on(S.BUFFER_CREATED,this.onBufferCreated,this)},e.unregisterListeners=function(){var t=this.hls;t.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(S.MEDIA_DETACHED,this.onMediaDetached,this),t.off(S.BUFFER_CREATED,this.onBufferCreated,this)},e.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},e.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},e.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},e.onBufferCreated=function(t,e){var r,i;this.audioBuffer=null==(r=e.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(i=e.tracks.video)?void 0:i.buffer},e.createData=function(){var t;return{v:1,sf:"h",sid:this.sid,cid:this.cid,pr:null==(t=this.media)?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},e.apply=function(e,r){void 0===r&&(r={}),o(r,this.createData());var i=r.ot===Pa||r.ot===Ca||r.ot===_a;if(this.starved&&i&&(r.bs=!0,r.su=!0,this.starved=!1),null==r.su&&(r.su=this.buffering),this.useHeaders){var n=t.toHeaders(r);if(!Object.keys(n).length)return;e.headers||(e.headers={}),o(e.headers,n)}else{var a=t.toQuery(r);if(!a)return;e.url=t.appendQueryToUri(e.url,a)}},e.getObjectType=function(t){var e=t.type;return"subtitle"===e?xa:"initSegment"===t.sn?Pa:"audio"===e?wa:"main"===e?this.hls.audioTracks.length?Ca:_a:void 0},e.getTopBandwidth=function(t){var e,r=0,i=this.hls;if(t===wa)e=i.audioTracks;else{var n=i.maxAutoLevel,a=n>-1?n+1:i.levels.length;e=i.levels.slice(0,a)}for(var s,o=v(e);!(s=o()).done;){var l=s.value;l.bitrate>r&&(r=l.bitrate)}return r>0?r:NaN},e.getBufferLength=function(t){var e=this.hls.media,r=t===wa?this.audioBuffer:this.videoBuffer;return r&&e?1e3*Ir.bufferInfo(r,e.currentTime,this.config.maxBufferHole).len:NaN},e.createPlaylistLoader=function(){var t=this.config.pLoader,e=this.applyPlaylistData,r=t||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new r(t)}var i=t.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(t,r,i){e(t),this.loader.load(t,r,i)},a(t,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),t}()},e.createFragmentLoader=function(){var t=this.config.fLoader,e=this.applyFragmentData,r=t||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new r(t)}var i=t.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(t,r,i){e(t),this.loader.load(t,r,i)},a(t,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),t}()},t.uuid=function(){var t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)},t.serialize=function(t){for(var e,r=[],i=function(t){return!Number.isNaN(t)&&null!=t&&""!==t&&!1!==t},n=function(t){return Math.round(t)},a=function(t){return 100*n(t/100)},s={br:n,d:n,bl:a,dl:a,mtp:a,nor:function(t){return encodeURIComponent(t)},rtp:a,tb:n},o=v(Object.keys(t||{}).sort());!(e=o()).done;){var l=e.value,u=t[l];if(i(u)&&!("v"===l&&1===u||"pr"==l&&1===u)){var h=s[l];h&&(u=h(u));var d=typeof u,c=void 0;c="ot"===l||"sf"===l||"st"===l?l+"="+u:"boolean"===d?l:"number"===d?l+"="+u:l+"="+JSON.stringify(u),r.push(c)}}return r.join(",")},t.toHeaders=function(e){for(var r={},i=["Object","Request","Session","Status"],n=[{},{},{},{}],a={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},s=0,o=Object.keys(e);s1&&(this.updatePathwayPriority(i),r.resolved=this.pathwayId!==n)}},e.filterParsedLevels=function(t){this.levels=t;var e=this.getLevelsForPathway(this.pathwayId);if(0===e.length){var r=t[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),e=this.getLevelsForPathway(r),this.pathwayId=r}return e.length!==t.length?(this.log("Found "+e.length+"/"+t.length+' levels in Pathway "'+this.pathwayId+'"'),e):t},e.getLevelsForPathway=function(t){return null===this.levels?[]:this.levels.filter((function(e){return t===e.pathwayId}))},e.updatePathwayPriority=function(t){var e;this.pathwayPriority=t;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach((function(t){i-r[t]>3e5&&delete r[t]}));for(var n=0;n0){this.log('Setting Pathway to "'+a+'"'),this.pathwayId=a,this.hls.trigger(S.LEVELS_UPDATED,{levels:e});var l=this.hls.levels[s];o&&l&&this.levels&&(l.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==o.bitrate&&this.log("Unstable Pathways change from bitrate "+o.bitrate+" to "+l.bitrate),this.hls.nextLoadLevel=s);break}}}},e.clonePathways=function(t){var e=this,r=this.levels;if(r){var i={},n={};t.forEach((function(t){var a=t.ID,s=t["BASE-ID"],l=t["URI-REPLACEMENT"];if(!r.some((function(t){return t.pathwayId===a}))){var u=e.getLevelsForPathway(s).map((function(t){var e=o({},t);e.details=void 0,e.url=Na(t.uri,t.attrs["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l);var r=new P(t.attrs);r["PATHWAY-ID"]=a;var s=r.AUDIO&&r.AUDIO+"_clone_"+a,u=r.SUBTITLES&&r.SUBTITLES+"_clone_"+a;s&&(i[r.AUDIO]=s,r.AUDIO=s),u&&(n[r.SUBTITLES]=u,r.SUBTITLES=u),e.attrs=r;var h=new Ne(e);return dr(h,"audio",s),dr(h,"text",u),h}));r.push.apply(r,u),Oa(e.audioTracks,i,l,a),Oa(e.subtitleTracks,n,l,a)}}))}},e.loadSteeringManifest=function(t){var e,r=this,i=this.hls.config,n=i.loader;this.loader&&this.loader.destroy(),this.loader=new n(i);try{e=new self.URL(t)}catch(e){return this.enabled=!1,void this.log("Failed to parse Steering Manifest URI: "+t)}if("data:"!==e.protocol){var a=0|(this.hls.bandwidthEstimate||i.abrEwmaDefaultEstimate);e.searchParams.set("_HLS_pathway",this.pathwayId),e.searchParams.set("_HLS_throughput",""+a)}var s={responseType:"json",url:e.href},o=i.steeringManifestLoadPolicy.default,l=o.errorRetry||o.timeoutRetry||{},u={loadPolicy:o,timeout:o.maxLoadTimeMs,maxRetry:l.maxNumRetry||0,retryDelay:l.retryDelayMs||0,maxRetryDelay:l.maxRetryDelayMs||0},h={onSuccess:function(t,i,n,a){r.log('Loaded steering manifest: "'+e+'"');var s=t.data;if(1===s.VERSION){r.updated=performance.now(),r.timeToLoad=s.TTL;var o=s["RELOAD-URI"],l=s["PATHWAY-CLONES"],u=s["PATHWAY-PRIORITY"];if(o)try{r.uri=new self.URL(o,e).href}catch(t){return r.enabled=!1,void r.log("Failed to parse Steering Manifest RELOAD-URI: "+o)}r.scheduleRefresh(r.uri||n.url),l&&r.clonePathways(l),u&&r.updatePathwayPriority(u)}else r.log("Steering VERSION "+s.VERSION+" not supported!")},onError:function(t,e,i,n){if(r.log("Error loading steering manifest: "+t.code+" "+t.text+" ("+e.url+")"),r.stopLoad(),410===t.code)return r.enabled=!1,void r.log("Steering manifest "+e.url+" no longer available");var a=1e3*r.timeToLoad;if(429!==t.code)r.scheduleRefresh(r.uri||e.url,a);else{var s=r.loader;if("function"==typeof(null==s?void 0:s.getResponseHeader)){var o=s.getResponseHeader("Retry-After");o&&(a=1e3*parseFloat(o))}r.log("Steering manifest "+e.url+" rate limited")}},onTimeout:function(t,e,i){r.log("Timeout loading steering manifest ("+e.url+")"),r.scheduleRefresh(r.uri||e.url)}};this.log("Requesting steering manifest: "+e),this.loader.load(s,u,h)},e.scheduleRefresh=function(t,e){var r=this;void 0===e&&(e=1e3*this.timeToLoad),self.clearTimeout(this.reloadTimer),this.reloadTimer=self.setTimeout((function(){r.loadSteeringManifest(t)}),e)},t}();function Oa(t,e,r,i){t&&Object.keys(e).forEach((function(n){var a=t.filter((function(t){return t.groupId===n})).map((function(t){var a=o({},t);return a.details=void 0,a.attrs=new P(a.attrs),a.url=a.attrs.URI=Na(t.url,t.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",r),a.groupId=a.attrs["GROUP-ID"]=e[n],a.attrs["PATHWAY-ID"]=i,a}));t.push.apply(t,a)}))}function Na(t,e,r,i){var n,a=i.HOST,s=i.PARAMS,o=i[r];e&&(n=null==o?void 0:o[e])&&(t=n);var l=new self.URL(t);return a&&!n&&(l.host=a),s&&Object.keys(s).sort().forEach((function(t){t&&l.searchParams.set(t,s[t])})),l.href}var Ua=/^age:\s*[\d.]+\s*$/im,Ba=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new M,this.retryDelay=0}var e=t.prototype;return e.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},e.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},e.abort=function(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},e.load=function(t,e,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=r,this.loadInternal()},e.loadInternal=function(){var t=this,e=this.config,r=this.context;if(e){var i=this.loader=new self.XMLHttpRequest,n=this.stats;n.loading.first=0,n.loaded=0,n.aborted=!1;var a=this.xhrSetup;a?Promise.resolve().then((function(){if(!t.stats.aborted)return a(i,r.url)})).catch((function(t){return i.open("GET",r.url,!0),a(i,r.url)})).then((function(){t.stats.aborted||t.openAndSendXhr(i,r,e)})).catch((function(e){t.callbacks.onError({code:i.status,text:e.message},r,i,n)})):this.openAndSendXhr(i,r,e)}},e.openAndSendXhr=function(t,e,r){t.readyState||t.open("GET",e.url,!0);var i=this.context.headers,n=r.loadPolicy,a=n.maxTimeToFirstByteMs,s=n.maxLoadTimeMs;if(i)for(var o in i)t.setRequestHeader(o,i[o]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),r.timeout=a&&E(a)?a:s,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),t.send()},e.readystatechange=function(){var t=this.context,e=this.loader,r=this.stats;if(t&&e){var i=e.readyState,n=this.config;if(!r.aborted&&i>=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;var a=e.status,s="text"!==e.responseType;if(a>=200&&a<300&&(s&&e.response||null!==e.responseText)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var o=s?e.response:e.responseText,l="arraybuffer"===e.responseType?o.byteLength:o.length;if(r.loaded=r.total=l,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,t,o,e),!this.callbacks)return;var h={url:e.responseURL,data:o,code:a};this.callbacks.onSuccess(h,r,t,e)}else{var d=n.loadPolicy.errorRetry;ze(d,r.retry,!1,a)?this.retry(d):(w.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:e.statusText},t,e,r))}}}},e.loadtimeout=function(){var t,e=null==(t=this.config)?void 0:t.loadPolicy.timeoutRetry;if(ze(e,this.stats.retry,!0))this.retry(e);else{w.warn("timeout while loading "+this.context.url);var r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}},e.retry=function(t){var e=this.context,r=this.stats;this.retryDelay=qe(t,r.retry),r.retry++,w.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+e.url+", retrying "+r.retry+"/"+t.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&Ua.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},e.getResponseHeader=function(t){return this.loader&&new RegExp("^"+t+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null},t}(),Ga=/(\d+)-(\d+)\/(\d+)/,Ka=function(){function t(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||Ha,this.controller=new self.AbortController,this.stats=new M}var e=t.prototype;return e.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},e.abortInternal=function(){var t=this.response;null!=t&&t.ok||(this.stats.aborted=!0,this.controller.abort())},e.abort=function(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},e.load=function(t,e,r){var i=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var a=function(t,e){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(o({},t.headers))};return t.rangeEnd&&r.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),r}(t,this.controller.signal),s=r.onProgress,l="arraybuffer"===t.responseType,u=l?"byteLength":"length",h=e.loadPolicy,d=h.maxTimeToFirstByteMs,c=h.maxLoadTimeMs;this.context=t,this.config=e,this.callbacks=r,this.request=this.fetchSetup(t,a),self.clearTimeout(this.requestTimeout),e.timeout=d&&E(d)?d:c,this.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(n,t,i.response)}),e.timeout),self.fetch(this.request).then((function(a){i.response=i.loader=a;var o=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(i.requestTimeout),e.timeout=c,i.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(n,t,i.response)}),c-(o-n.loading.start)),!a.ok){var u=a.status,h=a.statusText;throw new Va(h||"fetch, bad network response",u,a)}return n.loading.first=o,n.total=function(t){var e=t.get("Content-Range");if(e){var r=function(t){var e=Ga.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}(e);if(E(r))return r}var i=t.get("Content-Length");if(i)return parseInt(i)}(a.headers)||n.total,s&&E(e.highWaterMark)?i.loadProgressively(a,n,t,e.highWaterMark,s):l?a.arrayBuffer():"json"===t.responseType?a.json():a.text()})).then((function(a){var o=i.response;self.clearTimeout(i.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var l=a[u];l&&(n.loaded=n.total=l);var h={url:o.url,data:a,code:o.status};s&&!E(e.highWaterMark)&&s(n,t,a,o),r.onSuccess(h,n,t,o)})).catch((function(e){if(self.clearTimeout(i.requestTimeout),!n.aborted){var a=e&&e.code||0,s=e?e.message:null;r.onError({code:a,text:s},t,e?e.details:null,n)}}))},e.getCacheAge=function(){var t=null;if(this.response){var e=this.response.headers.get("age");t=e?parseFloat(e):null}return t},e.getResponseHeader=function(t){return this.response?this.response.headers.get(t):null},e.loadProgressively=function(t,e,r,i,n){void 0===i&&(i=0);var a=new mn,s=t.body.getReader();return function o(){return s.read().then((function(s){if(s.done)return a.dataLength&&n(e,r,a.flush(),t),Promise.resolve(new ArrayBuffer(0));var l=s.value,u=l.length;return e.loaded+=u,u=i&&n(e,r,a.flush(),t)):n(e,r,l,t),o()})).catch((function(){return Promise.reject()}))}()},t}();function Ha(t,e){return new self.Request(t.url,e)}var Va=function(t){function e(e,r,i){var n;return(n=t.call(this,e)||this).code=void 0,n.details=void 0,n.code=r,n.details=i,n}return l(e,t),e}(f(Error)),Ya=/\s/,Wa=i(i({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Ba,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:vn,bufferController:In,capLevelController:Ra,errorController:lr,fpsController:Aa,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:et,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:{newCue:function(t,e,r,i){for(var n,a,s,o,l,u=[],h=self.VTTCue||self.TextTrackCue,d=0;d=16?o--:o++;var g=ia(l.trim()),v=la(e,r,g);null!=t&&null!=(c=t.cues)&&c.getCueById(v)||((a=new h(e,r,g)).id=v,a.line=d+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*o/32)),u.push(a))}return t&&u.length&&(u.sort((function(t,e){return"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line})),u.forEach((function(e){return Se(t,e)}))),u}},enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:Sn,subtitleTrackController:Rn,timelineController:Sa,audioStreamController:pn,audioTrackController:yn,emeController:ba,cmcdController:Fa,contentSteeringController:Ma});function ja(t){return t&&"object"==typeof t?Array.isArray(t)?t.map(ja):Object.keys(t).reduce((function(e,r){return e[r]=ja(t[r]),e}),{}):t}function qa(t){var e=t.loader;e!==Ka&&e!==Ba?(w.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}()&&(t.loader=Ka,t.progressive=!0,t.enableSoftwareAES=!0,w.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Xa=function(){function t(e){void 0===e&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new an,this._autoLevelCapping=void 0,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,I(e.debug||!1,"Hls instance");var r=this.config=function(t,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var r=ja(t),n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((function(t){var i=("level"===t?"playlist":t)+"LoadPolicy",a=void 0===e[i],s=[];n.forEach((function(n){var o=t+"Loading"+n,l=e[o];if(void 0!==l&&a){s.push(o);var u=r[i].default;switch(e[i]={default:u},n){case"TimeOut":u.maxLoadTimeMs=l,u.maxTimeToFirstByteMs=l;break;case"MaxRetry":u.errorRetry.maxNumRetry=l,u.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":u.errorRetry.retryDelayMs=l,u.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=l,u.timeoutRetry.maxRetryDelayMs=l}}})),s.length&&w.warn('hls.js config: "'+s.join('", "')+'" setting(s) are deprecated, use "'+i+'": '+JSON.stringify(e[i]))})),i(i({},r),e)}(t.DefaultConfig,e);this.userConfig=e,this._autoLevelCapping=-1,r.progressive&&qa(r);var n=r.abrController,a=r.bufferController,s=r.capLevelController,o=r.errorController,l=r.fpsController,u=new o(this),h=this.abrController=new n(this),d=this.bufferController=new a(this),c=this.capLevelController=new s(this),f=new l(this),g=new Te(this),v=new Ce(this),m=r.contentSteeringController,p=m?new m(this):null,y=this.levelController=new hr(this,p),T=new pr(this),E=new kr(this.config),L=this.streamController=new cn(this,T,E);c.setStreamController(L),f.setStreamController(L);var R=[g,y,L];p&&R.splice(1,0,p),this.networkControllers=R;var A=[h,d,c,f,v,T];this.audioTrackController=this.createController(r.audioTrackController,R);var k=r.audioStreamController;k&&R.push(new k(this,T,E)),this.subtitleTrackController=this.createController(r.subtitleTrackController,R);var b=r.subtitleStreamController;b&&R.push(new b(this,T,E)),this.createController(r.timelineController,A),E.emeController=this.emeController=this.createController(r.emeController,A),this.cmcdController=this.createController(r.cmcdController,A),this.latencyController=this.createController(_e,A),this.coreComponents=A,R.push(u);var D=u.onErrorOut;"function"==typeof D&&this.on(S.ERROR,D,u)}t.isSupported=function(){return function(){var t=qt();if(!t)return!1;var e=Zr(),r=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),i=!e||e.prototype&&"function"==typeof e.prototype.appendBuffer&&"function"==typeof e.prototype.remove;return!!r&&!!i}()};var e=t.prototype;return e.createController=function(t,e){if(t){var r=new t(this);return e&&e.push(r),r}return null},e.on=function(t,e,r){void 0===r&&(r=this),this._emitter.on(t,e,r)},e.once=function(t,e,r){void 0===r&&(r=this),this._emitter.once(t,e,r)},e.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},e.off=function(t,e,r,i){void 0===r&&(r=this),this._emitter.off(t,e,r,i)},e.listeners=function(t){return this._emitter.listeners(t)},e.emit=function(t,e,r){return this._emitter.emit(t,e,r)},e.trigger=function(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){w.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),this.trigger(S.ERROR,{type:L.OTHER_ERROR,details:R.INTERNAL_EXCEPTION,fatal:!1,event:t,error:e})}return!1},e.listenerCount=function(t){return this._emitter.listenerCount(t)},e.destroy=function(){w.log("destroy"),this.trigger(S.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(t){return t.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(t){return t.destroy()})),this.coreComponents.length=0;var t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null},e.attachMedia=function(t){w.log("attachMedia"),this._media=t,this.trigger(S.MEDIA_ATTACHING,{media:t})},e.detachMedia=function(){w.log("detachMedia"),this.trigger(S.MEDIA_DETACHING,void 0),this._media=null},e.loadSource=function(t){this.stopLoad();var e=this.media,r=this.url,i=this.url=T.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});w.log("loadSource:"+i),e&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(S.MANIFEST_LOADING,{url:t})},e.startLoad=function(t){void 0===t&&(t=-1),w.log("startLoad("+t+")"),this.networkControllers.forEach((function(e){e.startLoad(t)}))},e.stopLoad=function(){w.log("stopLoad"),this.networkControllers.forEach((function(t){t.stopLoad()}))},e.swapAudioCodec=function(){w.log("swapAudioCodec"),this.streamController.swapAudioCodec()},e.recoverMediaError=function(){w.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},e.removeLevel=function(t,e){void 0===e&&(e=0),this.levelController.removeLevel(t,e)},a(t,[{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){w.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){w.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){w.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){w.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){w.log("set startLevel:"+t),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(w.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"ttfbEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(t){Pe.indexOf(t)>-1&&(this._maxHdcpLevel=t)}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,e=this.config.minAutoBitrate;if(!t)return 0;for(var r=t.length,i=0;i=e)return i;return 0}},{key:"maxAutoLevel",get:function(){var t,e=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(t=-1===r&&e&&e.length?e.length-1:r,i)for(var n=t;n--;){var a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return t}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.4.12"}},{key:"Events",get:function(){return S}},{key:"ErrorTypes",get:function(){return L}},{key:"ErrorDetails",get:function(){return R}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:Wa},set:function(e){t.defaultConfig=e}}]),t}();return Xa.defaultConfig=void 0,Xa},"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(r="undefined"!=typeof globalThis?globalThis:r||self).Hls=i()}(!1); +//# sourceMappingURL=hls.min.js.map diff --git a/player/vendor/ovenplayer.js b/player/vendor/ovenplayer.js new file mode 100644 index 0000000..3041e24 --- /dev/null +++ b/player/vendor/ovenplayer.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.OvenPlayer=t():e.OvenPlayer=t()}(self,(function(){return function(){var e={1597:function(e,t,n){"use strict";n.d(t,{default:function(){return Ar}});var r="0.10.32",o=n(741),i=n.n(o);function a(e){return e?e.replace(/^\s+|\s+$/g,""):""}var A=function(e){if(!e||"rtmp"==e.substr(0,4))return"";var t=function(e){var t="";return/[(,]format=mpd-/i.test(e)?t="mpd":/[(,]format=m3u8-/i.test(e)&&(t="m3u8"),t}(e);return t||((e=e.split("?")[0].split("#")[0]).lastIndexOf(".")>-1?e.substr(e.lastIndexOf(".")+1,e.length).toLowerCase():"")};function s(e){var t=parseInt(e,10);if(!e)return"00:00";var n=Math.floor(t/3600),r=Math.floor((t-3600*n)/60),o=t-3600*n-60*r;return r<10&&(r="0"+r),o<10&&(o="0"+o),n>0?n+":"+r+":"+o:r+":"+o}function c(e,t){if(!e)return 0;if(i().isNumber(e)&&!i().isNaN(e))return e;var n=(e=e.replace(",",".")).split(":"),r=n.length,o=0;if("s"===e.slice(-1))o=parseFloat(e);else if("m"===e.slice(-1))o=60*parseFloat(e);else if("h"===e.slice(-1))o=3600*parseFloat(e);else if(r>1){var a=r-1;4===r&&(t&&(o=parseFloat(n[a])/t),a-=1),o+=parseFloat(n[a]),o+=60*parseFloat(n[a-1]),r>=3&&(o+=3600*parseFloat(n[a-2]))}else o=parseFloat(e);return i().isNaN(o)?0:o}function u(e){var t={},n=e.split("\r\n");1===n.length&&(n=e.split("\n"));var r=1;if(n[0].indexOf(" --\x3e ")>0&&(r=0),n.length>r+1&&n[r+1]){var o=n[r],i=o.indexOf(" --\x3e ");i>0&&(t.start=c(o.substr(0,i)),t.end=c(o.substr(i+5)),t.text=n.slice(r+1).join("\r\n"))}return t}var l=window.VTTCue,f={"":!0,lr:!0,rl:!0},p={start:!0,middle:!0,end:!0,left:!0,right:!0};function d(e){return"string"==typeof e&&!!p[e.toLowerCase()]&&e.toLowerCase()}function g(e){for(var t=1;t100)throw new Error("Position must be between 0 and 100.");C=e,this.hasBeenReset=!0}})),Object.defineProperty(r,"positionAlign",g({},i,{get:function(){return y},set:function(e){var t=d(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(r,"size",g({},i,{get:function(){return b},set:function(e){if(e<0||e>100)throw new Error("Size must be between 0 and 100.");b=e,this.hasBeenReset=!0}})),Object.defineProperty(r,"align",g({},i,{get:function(){return w},set:function(e){var t=d(e);if(!t)throw new SyntaxError("An invalid or illegal string was specified.");w=t,this.hasBeenReset=!0}})),r.displayState=void 0,o)return r}).prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)});var h=l,v={"":!0,up:!0};function m(e){return"number"==typeof e&&e>=0&&e<=100}var C=function(){var e=100,t=3,n=0,r=100,o=0,i=100,a="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return e},set:function(t){if(!m(t))throw new Error("Width must be between 0 and 100.");e=t}},lines:{enumerable:!0,get:function(){return t},set:function(e){if("number"!=typeof e)throw new TypeError("Lines must be set to a number.");t=e}},regionAnchorY:{enumerable:!0,get:function(){return r},set:function(e){if(!m(e))throw new Error("RegionAnchorX must be between 0 and 100.");r=e}},regionAnchorX:{enumerable:!0,get:function(){return n},set:function(e){if(!m(e))throw new Error("RegionAnchorY must be between 0 and 100.");n=e}},viewportAnchorY:{enumerable:!0,get:function(){return i},set:function(e){if(!m(e))throw new Error("ViewportAnchorY must be between 0 and 100.");i=e}},viewportAnchorX:{enumerable:!0,get:function(){return o},set:function(e){if(!m(e))throw new Error("ViewportAnchorX must be between 0 and 100.");o=e}},scroll:{enumerable:!0,get:function(){return a},set:function(e){var t=function(e){return"string"==typeof e&&!!v[e.toLowerCase()]&&e.toLowerCase()}(e);if(!1===t)throw new SyntaxError("An invalid or illegal string was specified.");a=t}}})},y=function(){};function b(e,t){return void 0===t&&(t=1),"rgba("+[parseInt(e.substring(0,2),16),parseInt(e.substring(2,4),16),parseInt(e.substring(4,6),16),t].join(",")+")"}var w=1;function E(e,t,n){switch(n){case"webvtt.font.color":case"webvtt.font.opacity":var r=Services.prefs.getCharPref("webvtt.font.color"),o=Services.prefs.getIntPref("webvtt.font.opacity")/100;B.fontSet=b(r,o);break;case"webvtt.font.scale":w=Services.prefs.getIntPref("webvtt.font.scale")/100;break;case"webvtt.bg.color":case"webvtt.bg.opacity":var i=Services.prefs.getCharPref("webvtt.bg.color"),a=Services.prefs.getIntPref("webvtt.bg.opacity")/100;B.backgroundSet=b(i,a);break;case"webvtt.edge.color":case"webvtt.edge.type":var A=Services.prefs.getIntPref("webvtt.edge.type"),s=Services.prefs.getCharPref("webvtt.edge.color");B.edgeSet=["","0px 0px ","4px 4px 4px ","-2px -2px ","2px 2px "][A]+b(s)}}if("undefined"!=typeof Services){var B={};["webvtt.font.color","webvtt.font.opacity","webvtt.font.scale","webvtt.bg.color","webvtt.bg.opacity","webvtt.edge.color","webvtt.edge.type"].forEach((function(e){E(0,0,e),Services.prefs.addObserver(e,E,!1)}))}var x=Object.create||function(){function e(){}return function(t){if(1!==arguments.length)throw new Error("Object.create shim only accepts one parameter.");return e.prototype=t,new e}}();function k(e,t){this.name="ParsingError",this.code=e.code,this.message=t||e.message}function I(e){function t(e,t,n,r){return 3600*(0|e)+60*(0|t)+(0|n)+(0|r)/1e3}var n=e.match(/^(\d+):(\d{2})(:\d{2})?\.(\d{3})/);return n?n[3]?t(n[1],n[2],n[3].replace(":",""),n[4]):n[1]>59?t(n[1],n[2],0,n[4]):t(0,n[1],n[2],n[4]):null}function S(){this.values=x(null)}function T(e,t,n,r){var o=r?e.split(r):[e];for(var i in o)if("string"==typeof o[i]){var a=o[i].split(n);2===a.length&&t(a[0],a[1])}}function L(e,t,n){var r=e;function o(){var t=I(e);if(null===t)throw new k(k.Errors.BadTimeStamp,"Malformed timestamp: "+r);return e=e.replace(/^[^\sa-zA-Z-]+/,""),t}function i(){e=e.replace(/^\s+/,"")}if(i(),t.startTime=o(),i(),"--\x3e"!==e.substr(0,3))throw new k(k.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '--\x3e'): "+r);e=e.substr(3),i(),t.endTime=o(),i(),function(e,t){var r=new S;T(e,(function(e,t){switch(e){case"region":for(var o=n.length-1;o>=0;o--)if(n[o].id===t){r.set(e,n[o].region);break}break;case"vertical":r.alt(e,t,["rl","lr"]);break;case"line":var i=t.split(","),a=i[0];r.integer(e,a),r.percent(e,a)&&r.set("snapToLines",!1),r.alt(e,a,["auto"]),2===i.length&&r.alt("lineAlign",i[1],["start","middle","end"]);break;case"position":i=t.split(","),r.percent(e,i[0]),2===i.length&&r.alt("positionAlign",i[1],["start","middle","end"]);break;case"size":r.percent(e,t);break;case"align":r.alt(e,t,["start","middle","end","left","right"])}}),/:/,/\s/)}(e)}k.prototype=x(Error.prototype),k.prototype.constructor=k,k.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}},S.prototype={set:function(e,t){this.get(e)||""===t||(this.values[e]=t)},get:function(e,t,n){return n?this.has(e)?this.values[e]:t[n]:this.has(e)?this.values[e]:t},has:function(e){return e in this.values},alt:function(e,t,n){for(var r=0;r=0&&t<=100)&&(this.set(e,t),!0)}};var R={"&":"&","<":"<",">":">","‎":"‎","‏":"‏"," ":" "},M={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},O={v:"title",lang:"lang"},Q={rt:"ruby"};function D(e,t){function n(){if(!t)return null;var e,n=t.match(/^([^<]*)(<[^>]+>?)?/);return e=n[1]?n[1]:n[2],t=t.substr(e.length),e}function r(e){return R[e]}function o(e){for(;p=e.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)e=e.replace(p[0],r);return e}function i(e,t){return!Q[t.localName]||Q[t.localName]===e.localName}function a(t,n){var r=M[t];if(!r)return null;var o=e.document.createElement(r);o.localName=r;var i=O[t];return i&&n&&(o[i]=n.trim()),o}for(var A,s=e.document.createElement("div"),c=s,u=[];null!==(A=n());)if("<"!==A[0])c.appendChild(e.document.createTextNode(o(A)));else{if("/"===A[1]){u.length&&u[u.length-1]===A.substr(2).replace(">","")&&(u.pop(),c=c.parentNode);continue}var l,f=I(A.substr(1,A.length-2));if(f){l=e.document.createProcessingInstruction("timestamp",f),c.appendChild(l);continue}var p=A.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!p)continue;if(!(l=a(p[1],p[3])))continue;if(!i(c,l))continue;p[2]&&(l.className=p[2].substr(1).replace("."," ")),u.push(p[1]),c.appendChild(l),c=l}return s}var P=[1470,1472,1475,1478,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,1520,1521,1522,1523,1524,1544,1547,1549,1563,1566,1567,1568,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,1591,1592,1593,1594,1595,1596,1597,1598,1599,1600,1601,1602,1603,1604,1605,1606,1607,1608,1609,1610,1645,1646,1647,1649,1650,1651,1652,1653,1654,1655,1656,1657,1658,1659,1660,1661,1662,1663,1664,1665,1666,1667,1668,1669,1670,1671,1672,1673,1674,1675,1676,1677,1678,1679,1680,1681,1682,1683,1684,1685,1686,1687,1688,1689,1690,1691,1692,1693,1694,1695,1696,1697,1698,1699,1700,1701,1702,1703,1704,1705,1706,1707,1708,1709,1710,1711,1712,1713,1714,1715,1716,1717,1718,1719,1720,1721,1722,1723,1724,1725,1726,1727,1728,1729,1730,1731,1732,1733,1734,1735,1736,1737,1738,1739,1740,1741,1742,1743,1744,1745,1746,1747,1748,1749,1765,1766,1774,1775,1786,1787,1788,1789,1790,1791,1792,1793,1794,1795,1796,1797,1798,1799,1800,1801,1802,1803,1804,1805,1807,1808,1810,1811,1812,1813,1814,1815,1816,1817,1818,1819,1820,1821,1822,1823,1824,1825,1826,1827,1828,1829,1830,1831,1832,1833,1834,1835,1836,1837,1838,1839,1869,1870,1871,1872,1873,1874,1875,1876,1877,1878,1879,1880,1881,1882,1883,1884,1885,1886,1887,1888,1889,1890,1891,1892,1893,1894,1895,1896,1897,1898,1899,1900,1901,1902,1903,1904,1905,1906,1907,1908,1909,1910,1911,1912,1913,1914,1915,1916,1917,1918,1919,1920,1921,1922,1923,1924,1925,1926,1927,1928,1929,1930,1931,1932,1933,1934,1935,1936,1937,1938,1939,1940,1941,1942,1943,1944,1945,1946,1947,1948,1949,1950,1951,1952,1953,1954,1955,1956,1957,1969,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2e3,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020,2021,2022,2023,2024,2025,2026,2036,2037,2042,2048,2049,2050,2051,2052,2053,2054,2055,2056,2057,2058,2059,2060,2061,2062,2063,2064,2065,2066,2067,2068,2069,2074,2084,2088,2096,2097,2098,2099,2100,2101,2102,2103,2104,2105,2106,2107,2108,2109,2110,2112,2113,2114,2115,2116,2117,2118,2119,2120,2121,2122,2123,2124,2125,2126,2127,2128,2129,2130,2131,2132,2133,2134,2135,2136,2142,2208,2210,2211,2212,2213,2214,2215,2216,2217,2218,2219,2220,8207,64285,64287,64288,64289,64290,64291,64292,64293,64294,64295,64296,64298,64299,64300,64301,64302,64303,64304,64305,64306,64307,64308,64309,64310,64312,64313,64314,64315,64316,64318,64320,64321,64323,64324,64326,64327,64328,64329,64330,64331,64332,64333,64334,64335,64336,64337,64338,64339,64340,64341,64342,64343,64344,64345,64346,64347,64348,64349,64350,64351,64352,64353,64354,64355,64356,64357,64358,64359,64360,64361,64362,64363,64364,64365,64366,64367,64368,64369,64370,64371,64372,64373,64374,64375,64376,64377,64378,64379,64380,64381,64382,64383,64384,64385,64386,64387,64388,64389,64390,64391,64392,64393,64394,64395,64396,64397,64398,64399,64400,64401,64402,64403,64404,64405,64406,64407,64408,64409,64410,64411,64412,64413,64414,64415,64416,64417,64418,64419,64420,64421,64422,64423,64424,64425,64426,64427,64428,64429,64430,64431,64432,64433,64434,64435,64436,64437,64438,64439,64440,64441,64442,64443,64444,64445,64446,64447,64448,64449,64467,64468,64469,64470,64471,64472,64473,64474,64475,64476,64477,64478,64479,64480,64481,64482,64483,64484,64485,64486,64487,64488,64489,64490,64491,64492,64493,64494,64495,64496,64497,64498,64499,64500,64501,64502,64503,64504,64505,64506,64507,64508,64509,64510,64511,64512,64513,64514,64515,64516,64517,64518,64519,64520,64521,64522,64523,64524,64525,64526,64527,64528,64529,64530,64531,64532,64533,64534,64535,64536,64537,64538,64539,64540,64541,64542,64543,64544,64545,64546,64547,64548,64549,64550,64551,64552,64553,64554,64555,64556,64557,64558,64559,64560,64561,64562,64563,64564,64565,64566,64567,64568,64569,64570,64571,64572,64573,64574,64575,64576,64577,64578,64579,64580,64581,64582,64583,64584,64585,64586,64587,64588,64589,64590,64591,64592,64593,64594,64595,64596,64597,64598,64599,64600,64601,64602,64603,64604,64605,64606,64607,64608,64609,64610,64611,64612,64613,64614,64615,64616,64617,64618,64619,64620,64621,64622,64623,64624,64625,64626,64627,64628,64629,64630,64631,64632,64633,64634,64635,64636,64637,64638,64639,64640,64641,64642,64643,64644,64645,64646,64647,64648,64649,64650,64651,64652,64653,64654,64655,64656,64657,64658,64659,64660,64661,64662,64663,64664,64665,64666,64667,64668,64669,64670,64671,64672,64673,64674,64675,64676,64677,64678,64679,64680,64681,64682,64683,64684,64685,64686,64687,64688,64689,64690,64691,64692,64693,64694,64695,64696,64697,64698,64699,64700,64701,64702,64703,64704,64705,64706,64707,64708,64709,64710,64711,64712,64713,64714,64715,64716,64717,64718,64719,64720,64721,64722,64723,64724,64725,64726,64727,64728,64729,64730,64731,64732,64733,64734,64735,64736,64737,64738,64739,64740,64741,64742,64743,64744,64745,64746,64747,64748,64749,64750,64751,64752,64753,64754,64755,64756,64757,64758,64759,64760,64761,64762,64763,64764,64765,64766,64767,64768,64769,64770,64771,64772,64773,64774,64775,64776,64777,64778,64779,64780,64781,64782,64783,64784,64785,64786,64787,64788,64789,64790,64791,64792,64793,64794,64795,64796,64797,64798,64799,64800,64801,64802,64803,64804,64805,64806,64807,64808,64809,64810,64811,64812,64813,64814,64815,64816,64817,64818,64819,64820,64821,64822,64823,64824,64825,64826,64827,64828,64829,64848,64849,64850,64851,64852,64853,64854,64855,64856,64857,64858,64859,64860,64861,64862,64863,64864,64865,64866,64867,64868,64869,64870,64871,64872,64873,64874,64875,64876,64877,64878,64879,64880,64881,64882,64883,64884,64885,64886,64887,64888,64889,64890,64891,64892,64893,64894,64895,64896,64897,64898,64899,64900,64901,64902,64903,64904,64905,64906,64907,64908,64909,64910,64911,64914,64915,64916,64917,64918,64919,64920,64921,64922,64923,64924,64925,64926,64927,64928,64929,64930,64931,64932,64933,64934,64935,64936,64937,64938,64939,64940,64941,64942,64943,64944,64945,64946,64947,64948,64949,64950,64951,64952,64953,64954,64955,64956,64957,64958,64959,64960,64961,64962,64963,64964,64965,64966,64967,65008,65009,65010,65011,65012,65013,65014,65015,65016,65017,65018,65019,65020,65136,65137,65138,65139,65140,65142,65143,65144,65145,65146,65147,65148,65149,65150,65151,65152,65153,65154,65155,65156,65157,65158,65159,65160,65161,65162,65163,65164,65165,65166,65167,65168,65169,65170,65171,65172,65173,65174,65175,65176,65177,65178,65179,65180,65181,65182,65183,65184,65185,65186,65187,65188,65189,65190,65191,65192,65193,65194,65195,65196,65197,65198,65199,65200,65201,65202,65203,65204,65205,65206,65207,65208,65209,65210,65211,65212,65213,65214,65215,65216,65217,65218,65219,65220,65221,65222,65223,65224,65225,65226,65227,65228,65229,65230,65231,65232,65233,65234,65235,65236,65237,65238,65239,65240,65241,65242,65243,65244,65245,65246,65247,65248,65249,65250,65251,65252,65253,65254,65255,65256,65257,65258,65259,65260,65261,65262,65263,65264,65265,65266,65267,65268,65269,65270,65271,65272,65273,65274,65275,65276,67584,67585,67586,67587,67588,67589,67592,67594,67595,67596,67597,67598,67599,67600,67601,67602,67603,67604,67605,67606,67607,67608,67609,67610,67611,67612,67613,67614,67615,67616,67617,67618,67619,67620,67621,67622,67623,67624,67625,67626,67627,67628,67629,67630,67631,67632,67633,67634,67635,67636,67637,67639,67640,67644,67647,67648,67649,67650,67651,67652,67653,67654,67655,67656,67657,67658,67659,67660,67661,67662,67663,67664,67665,67666,67667,67668,67669,67671,67672,67673,67674,67675,67676,67677,67678,67679,67840,67841,67842,67843,67844,67845,67846,67847,67848,67849,67850,67851,67852,67853,67854,67855,67856,67857,67858,67859,67860,67861,67862,67863,67864,67865,67866,67867,67872,67873,67874,67875,67876,67877,67878,67879,67880,67881,67882,67883,67884,67885,67886,67887,67888,67889,67890,67891,67892,67893,67894,67895,67896,67897,67903,67968,67969,67970,67971,67972,67973,67974,67975,67976,67977,67978,67979,67980,67981,67982,67983,67984,67985,67986,67987,67988,67989,67990,67991,67992,67993,67994,67995,67996,67997,67998,67999,68e3,68001,68002,68003,68004,68005,68006,68007,68008,68009,68010,68011,68012,68013,68014,68015,68016,68017,68018,68019,68020,68021,68022,68023,68030,68031,68096,68112,68113,68114,68115,68117,68118,68119,68121,68122,68123,68124,68125,68126,68127,68128,68129,68130,68131,68132,68133,68134,68135,68136,68137,68138,68139,68140,68141,68142,68143,68144,68145,68146,68147,68160,68161,68162,68163,68164,68165,68166,68167,68176,68177,68178,68179,68180,68181,68182,68183,68184,68192,68193,68194,68195,68196,68197,68198,68199,68200,68201,68202,68203,68204,68205,68206,68207,68208,68209,68210,68211,68212,68213,68214,68215,68216,68217,68218,68219,68220,68221,68222,68223,68352,68353,68354,68355,68356,68357,68358,68359,68360,68361,68362,68363,68364,68365,68366,68367,68368,68369,68370,68371,68372,68373,68374,68375,68376,68377,68378,68379,68380,68381,68382,68383,68384,68385,68386,68387,68388,68389,68390,68391,68392,68393,68394,68395,68396,68397,68398,68399,68400,68401,68402,68403,68404,68405,68416,68417,68418,68419,68420,68421,68422,68423,68424,68425,68426,68427,68428,68429,68430,68431,68432,68433,68434,68435,68436,68437,68440,68441,68442,68443,68444,68445,68446,68447,68448,68449,68450,68451,68452,68453,68454,68455,68456,68457,68458,68459,68460,68461,68462,68463,68464,68465,68466,68472,68473,68474,68475,68476,68477,68478,68479,68608,68609,68610,68611,68612,68613,68614,68615,68616,68617,68618,68619,68620,68621,68622,68623,68624,68625,68626,68627,68628,68629,68630,68631,68632,68633,68634,68635,68636,68637,68638,68639,68640,68641,68642,68643,68644,68645,68646,68647,68648,68649,68650,68651,68652,68653,68654,68655,68656,68657,68658,68659,68660,68661,68662,68663,68664,68665,68666,68667,68668,68669,68670,68671,68672,68673,68674,68675,68676,68677,68678,68679,68680,126464,126465,126466,126467,126469,126470,126471,126472,126473,126474,126475,126476,126477,126478,126479,126480,126481,126482,126483,126484,126485,126486,126487,126488,126489,126490,126491,126492,126493,126494,126495,126497,126498,126500,126503,126505,126506,126507,126508,126509,126510,126511,126512,126513,126514,126516,126517,126518,126519,126521,126523,126530,126535,126537,126539,126541,126542,126543,126545,126546,126548,126551,126553,126555,126557,126559,126561,126562,126564,126567,126568,126569,126570,126572,126573,126574,126575,126576,126577,126578,126580,126581,126582,126583,126585,126586,126587,126588,126590,126592,126593,126594,126595,126596,126597,126598,126599,126600,126601,126603,126604,126605,126606,126607,126608,126609,126610,126611,126612,126613,126614,126615,126616,126617,126618,126619,126625,126626,126627,126629,126630,126631,126632,126633,126635,126636,126637,126638,126639,126640,126641,126642,126643,126644,126645,126646,126647,126648,126649,126650,126651,1114109];function F(){}function U(e,t,n){var r="undefined"!=typeof navigator&&/MSIE\s8\.0/.test(navigator.userAgent),o="rgba(255, 255, 255, 1)",i="rgba(0, 0, 0, 0.8)",a="";void 0!==B&&(o=B.fontSet,i=B.backgroundSet,a=B.edgeSet),r&&(o="rgb(255, 255, 255)",i="rgb(0, 0, 0)"),F.call(this),this.cue=t,this.cueDiv=D(e,t.text);var A={color:o,backgroundColor:i,textShadow:a,position:"relative",left:0,right:0,top:0,bottom:0,display:"inline"};r||(A.writingMode=""===t.vertical?"horizontal-tb":"lr"===t.vertical?"vertical-lr":"vertical-rl",A.unicodeBidi="plaintext"),this.applyStyles(A,this.cueDiv),this.div=e.document.createElement("div"),A={textAlign:"middle"===t.align?"center":t.align,font:n.font,whiteSpace:"pre-line",position:"absolute"},r||(A.direction=function(e){var t,n=[],r="";if(!e||!e.childNodes)return"ltr";function o(e,t){for(var n=t.childNodes.length-1;n>=0;n--)e.push(t.childNodes[n])}function i(e){if(!e||!e.length)return null;var t=e.pop(),n=t.textContent||t.innerText;if(n){var r=n.match(/^.*(\n|\r)/);return r?(e.length=0,r[0]):n}return"ruby"===t.tagName?i(e):t.childNodes?(o(e,t),i(e)):void 0}for(o(n,e);r=i(n);)for(var a=0;a=0&&e.line<=100))return e.line;if(!e.track||!e.track.textTrackList||!e.track.textTrackList.mediaElement)return-1;for(var t=e.track,n=t.textTrackList,r=0,o=0;ol&&(u=u<0?-1:1,u*=Math.ceil(l/c)*c),a<0&&(u+=""===i.vertical?n.height:n.width,A=A.reverse()),o.move(f,u)}else{var p=o.lineHeight/n.height*100;switch(i.lineAlign){case"middle":a-=p/2;break;case"end":a-=p}switch(i.vertical){case"":t.applyStyles({top:t.formatStyle(a,"%")});break;case"rl":t.applyStyles({left:t.formatStyle(a,"%")});break;case"lr":t.applyStyles({right:t.formatStyle(a,"%")})}A=["+y","-x","+x","-y"],o=new N(t)}var d=function(e,t){for(var o,i=new N(e),a=1,A=0;As&&(o=new N(e),a=s),e=new N(i)}return o||i}(o,A);t.move(d.toCSSCompatValues(n))}F.prototype.applyStyles=function(e,t){for(var n in t=t||this.div,e)e.hasOwnProperty(n)&&(t.style[n]=e[n])},F.prototype.formatStyle=function(e,t){return 0===e?0:e+t},U.prototype=x(F.prototype),U.prototype.constructor=U,N.prototype.move=function(e,t){switch(t=void 0!==t?t:this.lineHeight,e){case"+x":this.left+=t,this.right+=t;break;case"-x":this.left-=t,this.right-=t;break;case"+y":this.top+=t,this.bottom+=t;break;case"-y":this.top-=t,this.bottom-=t}},N.prototype.overlaps=function(e){return this.lefte.left&&this.tope.top},N.prototype.overlapsAny=function(e){for(var t=0;t=e.top&&this.bottom<=e.bottom&&this.left>=e.left&&this.right<=e.right},N.prototype.overlapsOppositeAxis=function(e,t){switch(t){case"+x":return this.lefte.right;case"+y":return this.tope.bottom}},N.prototype.intersectPercentage=function(e){return Math.max(0,Math.min(this.right,e.right)-Math.max(this.left,e.left))*Math.max(0,Math.min(this.bottom,e.bottom)-Math.max(this.top,e.top))/(this.height*this.width)},N.prototype.toCSSCompatValues=function(e){return{top:this.top-e.top,bottom:e.bottom-this.bottom,left:this.left-e.left,right:e.right-this.right,height:this.height,width:this.width}},N.getSimpleBoxPosition=function(e){var t=e.div?e.div.offsetHeight:e.tagName?e.offsetHeight:0,n=e.div?e.div.offsetWidth:e.tagName?e.offsetWidth:0,r=e.div?e.div.offsetTop:e.tagName?e.offsetTop:0;return{left:(e=e.div?e.div.getBoundingClientRect():e.tagName?e.getBoundingClientRect():e).left,right:e.right,top:e.top||r,height:e.height||t,bottom:e.bottom||r+(e.height||t),width:e.width||n}},y.StringDecoder=function(){return{decode:function(e){if(!e)return"";if("string"!=typeof e)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}},y.convertCueToDOMTree=function(e,t){return e&&t?D(e,t):null},y.processCues=function(e,t,n){if(!e||!t||!n)return null;for(;n.firstChild;)n.removeChild(n.firstChild);var r=e.document.createElement("div");if(r.style.position="absolute",r.style.left="0",r.style.right="0",r.style.top="0",r.style.bottom="0",r.style.margin="1.5%",n.appendChild(r),function(e){for(var t=0;t]*<[a-z]*/g,V=/]+?start[^=]*=[^0-9]*([0-9]*)["^0-9"]*/i,H=/]*>/gi,J=function(e,t){return t=(((t||"")+"").toLowerCase().match(/<[a-z][a-z0-9]*>/g)||[]).join(""),e.replace(/|<\?(?:php)?[\s\S]*?\?>/gi,"").replace(/<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,(function(e,n){return t.indexOf("<"+n.toLowerCase()+">")>-1?e:""}))},Z=function(e){return e.sort((function(e,t){var n;return 0==(n=e.start-t.start)?e.end-t.end:n}))},K=function(){var e={},t=function(e){return e.map((function(e){return new h(e.start,e.end,e.text)}))};return e.load=function(e,n,r,o){fetch(e.file).then((function(e){e.ok?e.text().then((function(e){var o=[],i=[];if(e.indexOf("WEBVTT")>=0){OvenPlayerConsole.log("WEBVTT LOADED");var A=new j.Parser(window,j.StringDecoder());i=[],A.oncue=function(e){i.push(e)},A.onflush=function(){r(i)},A.parse(e)}else if(e.indexOf("SAMI")>=0){OvenPlayerConsole.log("SAMI LOADED");var s=function(e,t){var n,r,o,i,a,A,s,c,u,l;if(s=function(){var t,n,r,a,s,c,u,f,p,d,g,h,v,m,C,y;for(n=function(e){var n;return(n=new Error(e)).line=u,n.context=t,o.push(n)},u=1,p=[],v={},h=e;d=h.search(),!(f<=0||d<0);)f=h.slice(d+1).search(G)+1,t=f>0?h.slice(d,d+f):h.slice(d),u+=(null!=(m=h.slice(0,d).match(z))?m.length:void 0)||0,_.test(t)&&n("ERROR_BROKEN_TAGS"),h=h.slice(d+f),(null===(g=+(null!=(C=t.match(V))?parseFloat(C[1]/1e3):void 0))||g<0)&&n("ERROR_INVALID_TIME"),(s=i(t))||n("ERROR_INVALID_LANGUAGE"),u+=(null!=(y=t.match(z))?y.length:void 0)||0,t=(t=t.replace(z,"")).replace(H,"\n"),a={start:g,text:"",contents:r=J(t).trim()},s&&(a.text=r),v[s]||(v[s]=[]),a.start&&v[s].push(a);l=l||function(){var e,t,n=window.navigator,r=["language","browserLanguage","systemLanguage","userLanguage"];if(Array.isArray(n.languages))for(e=0;e0&&(c=b.indexOf(l)>-1?v[l]:v[b.filter((function(e){return"undefined"!==e}))[0]],c=Z(c),c=A(c),p=p.concat(c)),Z(p)},i=function(e){var t,r;if(e)for(t in n)if((r=n[t]).reClassName.test(e))return r.lang},A=function(e){var t,n,o;for(t=e.length;t--;)n=e[t],null!=(o=e[t-1])&&(o.end=n.start),n.contents&&" "!==n.contents?(delete e[t].contents,n.end||(n.end=n.start+r)):e.splice(t,1);return e},o=[],n={KRCC:{lang:"ko",reClassName:new RegExp("class[^=]*?=[\"'S]*(KRCC)['\"S]?","i")},KOCC:{lang:"ko",reClassName:new RegExp("class[^=]*?=[\"'S]*(KOCC)['\"S]?","i")},KR:{lang:"ko",reClassName:new RegExp("class[^=]*?=[\"'S]*(KR)['\"S]?","i")},ENCC:{lang:"en",reClassName:new RegExp("class[^=]*?=[\"'S]*(ENCC)['\"S]?","i")},EGCC:{lang:"en",reClassName:new RegExp("class[^=]*?=[\"'S]*(EGCC)['\"S]?","i")},EN:{lang:"en",reClassName:new RegExp("class[^=]*?=[\"'S]*(EN)['\"S]?","i")},JPCC:{lang:"ja",reClassName:new RegExp("class[^=]*?=[\"'S]*(JPCC)['\"S]?","i")}},null!=t?t.definedLangs:void 0)for(a in u=t.definedLangs)c=u[a],n[a]=c;return r=(null!=t?t.duration:void 0)||10,l=t.fixedLang,e=e.trim(),{result:s(),errors:o}}(e,{fixedLang:n});i=t(s.result),r(i)}else OvenPlayerConsole.log("SRT LOADED"),o=function(e){var t=[],n=(e=a(e)).split("\r\n\r\n");1===n.length&&(n=e.split("\n\n"));for(var r=0;rGet Adobe Flash player",reason:"It looks like not found swf or your environment is localhost."},103:{code:103,message:"Can not load due to dash.js. Please use the latest dash.js.",reason:"dash.js version is old."},104:{code:104,message:"Can not load due to google ima for Ads. ",reason:"Please check the google ima library."},105:{code:105,message:"Error initializing DASH.",reason:"Error initializing DASH."},106:{code:106,message:"Error initializing HLS.",reason:"Error initializing HLS."},300:{code:300,message:"Can not play due to unknown reasons.",reason:"Can not play due to unknown reasons."},301:{code:301,message:"Fetching process aborted by user.",reason:"Fetching process aborted by user."},302:{code:302,message:"Some of the media could not be downloaded due to a network error.",reason:"Error occurred when downloading."},303:{code:303,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"Error occurred when decoding."},304:{code:304,message:"Media playback has been canceled. It looks like your media is corrupted or your browser does not support the features your media uses.",reason:"Media playback not supported."},305:{code:305,message:"Can not load captions due to unknown reasons.",reason:"Can not load captions due to unknown reasons."},306:{code:306,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"The server cannot or will not process the request."},307:{code:307,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"The server refused the request."},308:{code:308,message:"Unable to load media. This may be due to a server or network error, or due to an unsupported format.",reason:"The server do not accept the request."},501:{code:501,message:"Connection with low-latency(OME) server failed.",reason:"WebSocket connection failed."},502:{code:502,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC addIceCandidate failed."},503:{code:503,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC setRemoteDescription failed."},504:{code:504,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC peer createOffer failed."},505:{code:505,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC setLocalDescription failed."},506:{code:506,message:"Connection with low-latency(OME) server failed.",reason:"WebRTC internal error."},510:{code:510,message:"Network connection is unstable. Check the network connection.",reason:"Network is slow."},511:{code:511,message:"Connection with low-latency(OME) terminated unexpectedly.",reason:"Unexpected end of connection."},512:{code:512,message:"Connection with low-latency(OME) server failed.",reason:"Connection timeout."}}}},{lang:"ko",ui:{context:"오븐플레이어에 관하여",controls:{live:"라이브",low_latency_live:"초저지연 라이브",low_latency_p2p:"초저지연 P2P"},playlist:"플레이리스트",setting:{title:"설정",speed:"재생 속도",speedUnit:"x",source:"소스",quality:"품질",audioTrack:"오디오",caption:"자막",display:"표시"}},api:{message:{muted_play:"눌러서 소리 켜기"},error:{100:{code:100,message:"알 수 없는 이유로 로드 할 수 없습니다.",reason:"알 수 없는 이유로 로드 할 수 없습니다."},101:{code:101,message:"지원되는 미디어를 찾지 못해 로드 할 수 없습니다.",reason:"Can not load due to playable media not found."},102:{code:102,message:"플레시 로드가 중단 되었습니다.
Get Adobe Flash player",reason:"It looks like not found swf or your environment is localhost."},103:{code:103,message:"DashJS로 인해 로드 할 수 없습니다. 최신 dash.js를 사용해 주세요.",reason:"dash.js version is old."},104:{code:104,message:"Google IMA 라이브러리가 없어 로드 할 수 없습니다.",reason:"Please check the google ima library."},105:{code:105,message:"DASH 초기화 중 오류가 발생했습니다.",reason:"Error initializing DASH."},106:{code:106,message:"HLS 초기화 중 오류가 발생했습니다.",reason:"Error initializing HLS."},300:{code:300,message:"알 수 없는 이유로 재생할 수 없습니다.",reason:"Can not play due to unknown reasons."},301:{code:301,message:"사용자에 의한 프로세스 중단.",reason:"Fetching process aborted by user."},302:{code:302,message:"네트워크 오류로 인해 일부 미디어를 다운로드 할 수 없습니다.",reason:"Error occurred when downloading."},303:{code:303,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"Error occurred when decoding."},304:{code:304,message:"미디어 재생이 취소되었습니다. 미디어가 손상되었거나 브라우저가 미디어에서 사용하는 기능을 지원하지 않는 것 같습니다.",reason:"Media playback not supported."},305:{code:305,message:"알 수 없는 이유로 자막을 로드 할 수 없습니다.",reason:"Can not load captions due to unknown reasons."},306:{code:306,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"The server cannot or will not process the request."},307:{code:307,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"The server refused the request."},308:{code:308,message:"미디어를 로드 할 수 없습니다. 서버 또는 네트워크 오류 또는 지원되지 않는 형식으로 인해 발생할 수 있습니다.",reason:"The server do not accept the request."},501:{code:501,message:"웹소켓 연결 실패",reason:"WebSocket connection failed."},502:{code:502,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC addIceCandidate failed."},503:{code:503,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC setRemoteDescription failed."},504:{code:504,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC peer createOffer failed."},505:{code:505,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC setLocalDescription failed."},506:{code:506,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"WebRTC internal error."},510:{code:510,message:"네트워크 연결이 불안정합니다. 네트워크 연결을 확인하십시오.",reason:"Network is slow."},511:{code:511,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"Unexpected end of connection."},512:{code:512,message:"저지연(OME) 서버와 연결에 실패했습니다.",reason:"Connection timeout."}}}},{lang:"pl",ui:{context:"O OvenPlayer",controls:{live:"Transmisja na żywo",low_latency_live:"Transmisja z niskim opóźnieniem",low_latency_p2p:"Transmisja z niskim opóźnieniem P2P"},playlist:"Playlista",setting:{title:"Ustawienia",speed:"Prędkość",speedUnit:"x",source:"Źrodło",quality:"Jakość",audioTrack:"Audio",caption:"Podtytuł",display:"Wyświetlacz"}},api:{message:{muted_play:"Naciśnij tutaj, aby aktywować dźwięk"},error:{100:{code:100,message:"Nie można załadować z nieznanego powodu.",reason:"Can not load due to unknown reasons."},101:{code:101,message:"Nie można załadować, ponieważ nie znaleziono multimediów, który można odtworzyć.",reason:"Can not load due to playable media not found."},102:{code:102,message:"Flash fetching process aborted.
Get Adobe Flash player",reason:"It looks like not found swf or your environment is localhost."},103:{code:103,message:"Nie można załadować, ponieważ wersja dash.js jest za stara.",reason:"dash.js version is old."},104:{code:104,message:"Can not load due to google ima for Ads. ",reason:"Please check the google ima library."},105:{code:105,message:"Nie można załadować, nie znaleziono DASH.",reason:"Error initializing DASH."},106:{code:106,message:"Nie można załadować, nie znaleziono hlsjs.",reason:"Error initializing HLS"},300:{code:300,message:"Nie można odtworzyć z nieznanego powodu.",reason:"Can not play due to unknown reasons."},301:{code:301,message:"Proces pobierania przerwany przez użytkownika.",reason:"Fetching process aborted by user."},302:{code:302,message:"Nie udało się pobrać niektórych multimediów z powodu błędu sieci.",reason:"Error occurred when downloading."},303:{code:303,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"Error occurred when decoding."},304:{code:304,message:"Odtwarzanie zostało anulowane. Wygląda na to, że plik jest uszkodzony lub Twoja przeglądarka nie obsługuje tego pliku.",reason:"Media playback not supported."},305:{code:305,message:"Nie można wczytać napisów z nieznanego powodu.",reason:"Can not load captions due to unknown reasons."},306:{code:306,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"The server cannot or will not process the request."},307:{code:307,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"The server refused the request."},308:{code:308,message:"Nie udało się załadować niektórych multimediów. Może być to spowodowane problemem z serwerem, siecią lub niewspieranym formatem.",reason:"The server do not accept the request."},501:{code:501,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebSocket connection failed."},502:{code:502,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC addIceCandidate failed."},503:{code:503,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC setRemoteDescription failed."},504:{code:504,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC peer createOffer failed."},505:{code:505,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC setLocalDescription failed."},506:{code:506,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"WebRTC internal error."},510:{code:510,message:"Połączenie sieciowe jest niestabilne. Sprawdź swoją sieć.",reason:"Network is slow."},511:{code:511,message:"Połączenie z serwerem niskiego opóźnienia (OME) nieoczekiwanie zakończone.",reason:"Unexpected end of connection."},512:{code:512,message:"Połączenie z serwerem niskiego opóźnienia (OME) nie powiodło się.",reason:"Connection timeout."}}}}],Ye=function(e){return"subtitles"===e||"captions"===e},Ge=function(e){var t=e,n=[],r=function(e,t,n){var r=0,o=e.length;for(r=0;r1?n:n[0]};return(r=i().isElement(t)||i().every(t,(function(e){return i().isElement(e)}))?t:"document"===t?document:"window"===t?window:o(document,t))?(n.show=function(){r.style.display="block"},n.hide=function(){r.style.display="none"},n.addClass=function(e){r.classList?r.classList.add(e):-1===r.className.split(" ").indexOf(e)&&(r.className+=" "+e)},n.after=function(e){r.insertAdjacentHTML("afterend",e)},n.append=function(e){r.appendChild(e)},n.before=function(e){r.insertAdjacentHTML("beforebegin",e)},n.children=function(){return r.children||[]},n.contains=function(e){return r!==e&&r.contains(e)},n.empty=function(){r.innerHTML=""},n.find=function(t){return e(o(r,t))},n.css=function(e,t){if(!t)return r.style[e];r.length>0?r.forEach((function(n){n.style[e]=t})):r.style[e]=t},n.removeClass=function(e){r.classList?r.classList.remove(e):r.className=r.className.replace(new RegExp("(^|\\b)"+e.split(" ").join("|")+"(\\b|$)","gi")," ")},n.removeAttribute=function(e){r.removeAttribute(e)},n.text=function(e){if(void 0===e)return r.textContent;r.textContent=e},n.html=function(e){r.innerHTML=e},n.hasClass=function(e){return r.classList?r.classList.contains(e):new RegExp("(^| )"+e+"( |$)","gi").test(r.name)},n.is=function(e){return r===e},n.offset=function(){var e=r.getBoundingClientRect();return{top:e.top+document.body.scrollTop,left:e.left+document.body.scrollLeft}},n.width=function(){return r.clientWidth},n.height=function(){return r.clientHeight},n.attr=function(e){return r.getAttribute(e)},n.replace=function(e){r.replaceWith(e)},n.remove=function(){r.length>1?r.parentElement.removeChild(r):r.remove()},n.removeChild=function(e){if(e)r.removeChild(e);else for(;r.hasChildNodes();)r.removeChild(r.firstChild)},n.get=function(){return r},n.closest=function(t){r.closest=function(e){var t=r;do{if(t.matches(e))return t;t=t.parentElement||t.parentNode}while(null!==t&&1===t.nodeType);return null};var n=r.closest(t);return n?e(n):null},n):null}),_e=function(e,t){if(e)return 0==e.indexOf("rtmp:")||"rtmp"==t},Ve=function(e,t){return!!e&&(0===e.indexOf("ws:")||0===e.indexOf("wss:")||"webrtc"===t)},He=function(e,t){if(e)return"hls"===t||"m3u8"===t||"application/vnd.apple.mpegurl"===t||"m3u8"==A(e)},Je=function(e,t){if(e)return"mpd"===t||"dash"===t||"application/dash+xml"===t||"mpd"==A(e)},Ze=function(e){if(!e)return null;var t=null;if("string"==typeof e)t=document.getElementById(e);else{if(!e.nodeType)return null;t=e}return t},Ke=function(){var e={};OvenPlayerConsole.log("SupportChecker loaded.");var t=Y(),n=[{name:"html5",checkSupport:function(e){var n=document.createElement("video");if(!n.canPlayType)return!1;var r=e.file,o=e.type,i=e.overrideNative;if(!o)return!1;var a=e.mimeType||{aac:"audio/mp4",mp4:"video/mp4",f4v:"video/mp4",m4v:"video/mp4",mov:"video/mp4",mp3:"audio/mpeg",mpeg:"audio/mpeg",ogv:"video/ogg",ogg:"video/ogg",oga:"video/ogg",vorbis:"video/ogg",webm:"video/webm",f4a:"video/aac",m3u8:"application/vnd.apple.mpegurl",m3u:"application/vnd.apple.mpegurl",hls:"application/vnd.apple.mpegurl"}[o];return!(He(r,o)&&("Microsoft Edge"===t.browser||"Android"===t.os)||He(r,o)&&i||_e(r,o)||Ve(r,o)||!a||!n.canPlayType(a))}},{name:"webrtc",checkSupport:function(e){if(!document.createElement("video").canPlayType)return!1;if(_e(t,n))return!1;var t=e.file,n=e.type;return!!Ve(t,n)}},{name:"dash",checkSupport:function(e){var t=e.file,n=e.type;return!_e(t,n)&&!("function"!=typeof(window.MediaSource||window.WebKitMediaSource)||!Je(t,n))}},{name:"hls",checkSupport:function(e){document.createElement("video");var t,n,r,o,i=e.file,a=e.type;return!_e(i,a)&&(t=function(){if("undefined"!=typeof window)return window.MediaSource||window.WebKitMediaSource}(),n=window.SourceBuffer||window.WebKitSourceBuffer,r=t&&"function"==typeof t.isTypeSupported&&t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"'),o=!n||n.prototype&&"function"==typeof n.prototype.appendBuffer&&"function"==typeof n.prototype.remove,!!r&&!!o)}},{name:"rtmp",checkSupport:function(e){var n=e.file,r=e.type;return!(!_e(n,r)||!function(){var e=!1;if("ActiveXObject"in window)try{e=!!new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(t){e=!1}else e=!!navigator.mimeTypes["application/x-shockwave-flash"];return e}()||"Microsoft Edge"===t.browser||"Android"===t.os||"iOS"===t.os||"Safari"===t.browser)}}];return e.findProviderNameBySource=function(e){OvenPlayerConsole.log("SupportChecker : findProviderNameBySource()",e);for(var t=e===Object(e)?e:{},r=0;r0&&void 0!==arguments[0]?arguments[0]:{};ct(this,e),this.id=t.id||null,this.adId=t.adId||null,this.sequence=t.sequence||null,this.apiFramework=t.apiFramework||null,this.trackingEvents={}})),gt=function(e){nt(n,e);var t=ot(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ct(this,n),(e=t.call(this,r)).type="companion",e.variations=[],e}return st(n)}(dt);function ht(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=[];for(var r in t.ASSETURI&&(t.ASSETURI=vt(t.ASSETURI)),t.CONTENTPLAYHEAD&&(t.CONTENTPLAYHEAD=vt(t.CONTENTPLAYHEAD)),t.ERRORCODE&&!/^[0-9]{3}$/.test(t.ERRORCODE)&&(t.ERRORCODE=900),t.CACHEBUSTING=mt(Math.round(1e8*Math.random()).toString()),t.TIMESTAMP=vt((new Date).toISOString()),t.RANDOM=t.random=t.CACHEBUSTING,e){var o=e[r];if("string"==typeof o){for(var i in t){var a=t[i],A="[".concat(i,"]"),s="%%".concat(i,"%%");o=(o=o.replace(A,a)).replace(s,a)}n.push(o)}}return n}function vt(e){return encodeURIComponent(e).replace(/[!'()*]/g,(function(e){return"%".concat(e.charCodeAt(0).toString(16))}))}function mt(e){return e.length<8?Ct(0,8-e.length,!1).map((function(e){return"0"})).join("")+e:e}function Ct(e,t,n){for(var r=[],o=ei;o?a++:a--)r.push(a);return r}var yt={track:function(e,t){ht(e,t).forEach((function(e){"undefined"!=typeof window&&null!==window&&((new Image).src=e)}))},resolveURLTemplates:ht,encodeURIComponentRFC3986:vt,leftpad:mt,range:Ct,isNumeric:function(e){return!isNaN(parseFloat(e))&&isFinite(e)},flatten:function e(t){return t.reduce((function(t,n){return t.concat(Array.isArray(n)?e(n):n)}),[])}},bt=function(e,t){var n=e.childNodes;for(var r in n){var o=n[r];if(o.nodeName===t)return o}},wt=function(e,t){var n=[],r=e.childNodes;for(var o in r){var i=r[o];i.nodeName===t&&n.push(i)}return n},Et=function(e,t){if(!t)return e;if(0===e.indexOf("//")){var n=location.protocol;return"".concat(n).concat(e)}return-1===e.indexOf("://")?"".concat(t.slice(0,t.lastIndexOf("/")),"/").concat(e):e},Bt=function(e){return-1!==["true","TRUE","1"].indexOf(e)},xt=function(e){return e&&(e.textContent||e.text||"").trim()},kt=function(e,t,n){var r=t.getAttribute(e);r&&n.setAttribute(e,r)},It=function(e){if(null==e)return-1;if(yt.isNumeric(e))return parseInt(e);var t=e.split(":");if(3!==t.length)return-1;var n=t[2].split("."),r=parseInt(n[0]);2===n.length&&(r+=parseFloat("0.".concat(n[1])));var o=parseInt(60*t[1]),i=parseInt(60*t[0]*60);return isNaN(i)||isNaN(o)||isNaN(r)||o>3600||r>60?-1:i+o+r},St=function(e){var t=[],n=null;return e.forEach((function(r,o){if(r.sequence&&(r.sequence=parseInt(r.sequence,10)),r.sequence>1){var i=e[o-1];if(i&&i.sequence===r.sequence-1)return void(n&&n.push(r));delete r.sequence}n=[r],t.push(n)})),t},Tt=function(e,t){e.errorURLTemplates=t.errorURLTemplates.concat(e.errorURLTemplates),e.impressionURLTemplates=t.impressionURLTemplates.concat(e.impressionURLTemplates),e.extensions=t.extensions.concat(e.extensions),e.creatives.forEach((function(e){if(t.trackingEvents&&t.trackingEvents[e.type])for(var n in t.trackingEvents[e.type]){var r=t.trackingEvents[e.type][n];e.trackingEvents[n]||(e.trackingEvents[n]=[]),e.trackingEvents[n]=e.trackingEvents[n].concat(r)}})),t.videoClickTrackingURLTemplates&&t.videoClickTrackingURLTemplates.length&&e.creatives.forEach((function(e){"linear"===e.type&&(e.videoClickTrackingURLTemplates=e.videoClickTrackingURLTemplates.concat(t.videoClickTrackingURLTemplates))})),t.videoCustomClickURLTemplates&&t.videoCustomClickURLTemplates.length&&e.creatives.forEach((function(e){"linear"===e.type&&(e.videoCustomClickURLTemplates=e.videoCustomClickURLTemplates.concat(t.videoCustomClickURLTemplates))})),t.videoClickThroughURLTemplate&&e.creatives.forEach((function(e){"linear"===e.type&&null==e.videoClickThroughURLTemplate&&(e.videoClickThroughURLTemplate=t.videoClickThroughURLTemplate)}))};function Lt(e,t){var n=new gt(t);return wt(e,"Companion").forEach((function(e){var t=new pt;t.id=e.getAttribute("id")||null,t.width=e.getAttribute("width"),t.height=e.getAttribute("height"),t.companionClickTrackingURLTemplates=[],wt(e,"HTMLResource").forEach((function(e){t.type=e.getAttribute("creativeType")||"text/html",t.htmlResource=xt(e)})),wt(e,"IFrameResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.iframeResource=xt(e)})),wt(e,"StaticResource").forEach((function(n){t.type=n.getAttribute("creativeType")||0,wt(e,"AltText").forEach((function(e){t.altText=xt(e)})),t.staticResource=xt(n)})),wt(e,"TrackingEvents").forEach((function(e){wt(e,"Tracking").forEach((function(e){var n=e.getAttribute("event"),r=xt(e);n&&r&&(null==t.trackingEvents[n]&&(t.trackingEvents[n]=[]),t.trackingEvents[n].push(r))}))})),wt(e,"CompanionClickTracking").forEach((function(e){t.companionClickTrackingURLTemplates.push(xt(e))})),t.companionClickThroughURLTemplate=xt(bt(e,"CompanionClickThrough")),t.companionClickTrackingURLTemplate=xt(bt(e,"CompanionClickTracking")),n.variations.push(t)})),n}var Rt=function(e){nt(n,e);var t=ot(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ct(this,n),(e=t.call(this,r)).type="linear",e.duration=0,e.skipDelay=null,e.mediaFiles=[],e.videoClickThroughURLTemplate=null,e.videoClickTrackingURLTemplates=[],e.videoCustomClickURLTemplates=[],e.adParameters=null,e.icons=[],e}return st(n)}(dt),Mt=st((function e(){ct(this,e),this.program=null,this.height=0,this.width=0,this.xPosition=0,this.yPosition=0,this.apiFramework=null,this.offset=null,this.duration=0,this.type=null,this.staticResource=null,this.htmlResource=null,this.iframeResource=null,this.iconClickThroughURLTemplate=null,this.iconClickTrackingURLTemplates=[],this.iconViewTrackingURLTemplate=null})),Ot=st((function e(){ct(this,e),this.id=null,this.fileURL=null,this.deliveryType="progressive",this.mimeType=null,this.codec=null,this.bitrate=0,this.minBitrate=0,this.maxBitrate=0,this.width=0,this.height=0,this.apiFramework=null,this.scalable=null,this.maintainAspectRatio=null}));function Qt(e,t){var n,r=new Rt(t);r.duration=It(xt(bt(e,"Duration")));var o=e.getAttribute("skipoffset");if(null==o)r.skipDelay=null;else if("%"===o.charAt(o.length-1)&&-1!==r.duration){var i=parseInt(o,10);r.skipDelay=r.duration*(i/100)}else r.skipDelay=It(o);var a=bt(e,"VideoClicks");a&&(r.videoClickThroughURLTemplate=xt(bt(a,"ClickThrough")),wt(a,"ClickTracking").forEach((function(e){r.videoClickTrackingURLTemplates.push(xt(e))})),wt(a,"CustomClick").forEach((function(e){r.videoCustomClickURLTemplates.push(xt(e))})));var A=bt(e,"AdParameters");A&&(r.adParameters=xt(A)),wt(e,"TrackingEvents").forEach((function(e){wt(e,"Tracking").forEach((function(e){var t=e.getAttribute("event"),o=xt(e);if(t&&o){if("progress"===t){if(!(n=e.getAttribute("offset")))return;t="%"===n.charAt(n.length-1)?"progress-".concat(n):"progress-".concat(Math.round(It(n)))}null==r.trackingEvents[t]&&(r.trackingEvents[t]=[]),r.trackingEvents[t].push(o)}}))})),wt(e,"MediaFiles").forEach((function(e){wt(e,"MediaFile").forEach((function(e){var t=new Ot;t.id=e.getAttribute("id"),t.fileURL=xt(e),t.deliveryType=e.getAttribute("delivery"),t.codec=e.getAttribute("codec"),t.mimeType=e.getAttribute("type"),t.apiFramework=e.getAttribute("apiFramework"),t.bitrate=parseInt(e.getAttribute("bitrate")||0),t.minBitrate=parseInt(e.getAttribute("minBitrate")||0),t.maxBitrate=parseInt(e.getAttribute("maxBitrate")||0),t.width=parseInt(e.getAttribute("width")||0),t.height=parseInt(e.getAttribute("height")||0);var n=e.getAttribute("scalable");n&&"string"==typeof n&&("true"===(n=n.toLowerCase())?t.scalable=!0:"false"===n&&(t.scalable=!1));var o=e.getAttribute("maintainAspectRatio");o&&"string"==typeof o&&("true"===(o=o.toLowerCase())?t.maintainAspectRatio=!0:"false"===o&&(t.maintainAspectRatio=!1)),r.mediaFiles.push(t)}))}));var s=bt(e,"Icons");return s&&wt(s,"Icon").forEach((function(e){var t=new Mt;t.program=e.getAttribute("program"),t.height=parseInt(e.getAttribute("height")||0),t.width=parseInt(e.getAttribute("width")||0),t.xPosition=function(e){return-1!==["left","right"].indexOf(e)?e:parseInt(e||0)}(e.getAttribute("xPosition")),t.yPosition=function(e){return-1!==["top","bottom"].indexOf(e)?e:parseInt(e||0)}(e.getAttribute("yPosition")),t.apiFramework=e.getAttribute("apiFramework"),t.offset=It(e.getAttribute("offset")),t.duration=It(e.getAttribute("duration")),wt(e,"HTMLResource").forEach((function(e){t.type=e.getAttribute("creativeType")||"text/html",t.htmlResource=xt(e)})),wt(e,"IFrameResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.iframeResource=xt(e)})),wt(e,"StaticResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.staticResource=xt(e)}));var n=bt(e,"IconClicks");n&&(t.iconClickThroughURLTemplate=xt(bt(n,"IconClickThrough")),wt(n,"IconClickTracking").forEach((function(e){t.iconClickTrackingURLTemplates.push(xt(e))}))),t.iconViewTrackingURLTemplate=xt(bt(e,"IconViewTracking")),r.icons.push(t)})),r}var Dt,Pt=function(e){nt(n,e);var t=ot(n);function n(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return ct(this,n),(e=t.call(this,r)).type="nonlinear",e.variations=[],e}return st(n)}(dt),Ft=st((function e(){ct(this,e),this.id=null,this.width=0,this.height=0,this.expandedWidth=0,this.expandedHeight=0,this.scalable=!0,this.maintainAspectRatio=!0,this.minSuggestedDuration=0,this.apiFramework="static",this.type=null,this.staticResource=null,this.htmlResource=null,this.iframeResource=null,this.nonlinearClickThroughURLTemplate=null,this.nonlinearClickTrackingURLTemplates=[],this.adParameters=null}));function Ut(e,t){var n=new Pt(t);return wt(e,"TrackingEvents").forEach((function(e){var t,r;wt(e,"Tracking").forEach((function(e){t=e.getAttribute("event"),r=xt(e),t&&r&&(null==n.trackingEvents[t]&&(n.trackingEvents[t]=[]),n.trackingEvents[t].push(r))}))})),wt(e,"NonLinear").forEach((function(e){var t=new Ft;t.id=e.getAttribute("id")||null,t.width=e.getAttribute("width"),t.height=e.getAttribute("height"),t.expandedWidth=e.getAttribute("expandedWidth"),t.expandedHeight=e.getAttribute("expandedHeight"),t.scalable=Bt(e.getAttribute("scalable")),t.maintainAspectRatio=Bt(e.getAttribute("maintainAspectRatio")),t.minSuggestedDuration=It(e.getAttribute("minSuggestedDuration")),t.apiFramework=e.getAttribute("apiFramework"),wt(e,"HTMLResource").forEach((function(e){t.type=e.getAttribute("creativeType")||"text/html",t.htmlResource=xt(e)})),wt(e,"IFrameResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.iframeResource=xt(e)})),wt(e,"StaticResource").forEach((function(e){t.type=e.getAttribute("creativeType")||0,t.staticResource=xt(e)}));var r=bt(e,"AdParameters");r&&(t.adParameters=xt(r)),t.nonlinearClickThroughURLTemplate=xt(bt(e,"NonLinearClickThrough")),wt(e,"NonLinearClickTracking").forEach((function(e){t.nonlinearClickTrackingURLTemplates.push(xt(e))})),n.variations.push(t)})),n}function Nt(e){var t=e.childNodes;for(var n in t){var r=t[n];if(-1!==["Wrapper","InLine"].indexOf(r.nodeName)){if(kt("id",e,r),kt("sequence",e,r),"Wrapper"===r.nodeName)return jt(r);if("InLine"===r.nodeName)return Wt(r)}}}function Wt(e){var t=e.childNodes,n=new ut;for(var r in n.id=e.getAttribute("id")||null,n.sequence=e.getAttribute("sequence")||null,t){var o=t[r];switch(o.nodeName){case"Error":n.errorURLTemplates.push(xt(o));break;case"Impression":n.impressionURLTemplates.push(xt(o));break;case"Creatives":wt(o,"Creative").forEach((function(e){var t={id:e.getAttribute("id")||null,adId:Gt(e),sequence:e.getAttribute("sequence")||null,apiFramework:e.getAttribute("apiFramework")||null};for(var r in e.childNodes){var o=e.childNodes[r];switch(o.nodeName){case"Linear":var i=Qt(o,t);i&&n.creatives.push(i);break;case"NonLinearAds":var a=Ut(o,t);a&&n.creatives.push(a);break;case"CompanionAds":var A=Lt(o,t);A&&n.creatives.push(A)}}}));break;case"Extensions":Yt(n.extensions,wt(o,"Extension"));break;case"AdSystem":n.system={value:xt(o),version:o.getAttribute("version")||null};break;case"AdTitle":n.title=xt(o);break;case"Description":n.description=xt(o);break;case"Advertiser":n.advertiser=xt(o);break;case"Pricing":n.pricing={value:xt(o),model:o.getAttribute("model")||null,currency:o.getAttribute("currency")||null};break;case"Survey":n.survey=xt(o)}}return n}function jt(e){var t=Wt(e),n=bt(e,"VASTAdTagURI");if(n?t.nextWrapperURL=xt(n):(n=bt(e,"VASTAdTagURL"))&&(t.nextWrapperURL=xt(bt(n,"URL"))),t.creatives.forEach((function(e){if(-1!==["linear","nonlinear"].indexOf(e.type)){if(e.trackingEvents){t.trackingEvents||(t.trackingEvents={}),t.trackingEvents[e.type]||(t.trackingEvents[e.type]={});var n=function(n){var r=e.trackingEvents[n];t.trackingEvents[e.type][n]||(t.trackingEvents[e.type][n]=[]),r.forEach((function(r){t.trackingEvents[e.type][n].push(r)}))};for(var r in e.trackingEvents)n(r)}e.videoClickTrackingURLTemplates&&(t.videoClickTrackingURLTemplates||(t.videoClickTrackingURLTemplates=[]),e.videoClickTrackingURLTemplates.forEach((function(e){t.videoClickTrackingURLTemplates.push(e)}))),e.videoClickThroughURLTemplate&&(t.videoClickThroughURLTemplate=e.videoClickThroughURLTemplate),e.videoCustomClickURLTemplates&&(t.videoCustomClickURLTemplates||(t.videoCustomClickURLTemplates=[]),e.videoCustomClickURLTemplates.forEach((function(e){t.videoCustomClickURLTemplates.push(e)})))}})),t.nextWrapperURL)return t}function Yt(e,t){t.forEach((function(t){var n=new lt,r=t.attributes,o=t.childNodes;if(t.attributes)for(var i in r){var a=r[i];a.nodeName&&a.nodeValue&&(n.attributes[a.nodeName]=a.nodeValue)}for(var A in o){var s=o[A],c=xt(s);if("#comment"!==s.nodeName&&""!==c){var u=new ft;if(u.name=s.nodeName,u.value=c,s.attributes){var l=s.attributes;for(var f in l){var p=l[f];u.attributes[p.nodeName]=p.nodeValue}}n.children.push(u)}}e.push(n)}))}function Gt(e){return e.getAttribute("AdID")||e.getAttribute("adID")||e.getAttribute("adId")||null}function zt(){}function _t(){_t.init.call(this)}function Vt(e){return void 0===e._maxListeners?_t.defaultMaxListeners:e._maxListeners}function Ht(e,t,n){if(t)e.call(n);else for(var r=e.length,o=tn(e,r),i=0;i0&&a.length>o){a.warned=!0;var A=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");A.name="MaxListenersExceededWarning",A.emitter=e,A.type=t,A.count=a.length,function(e){"function"==typeof console.warn?console.warn(e):console.log(e)}(A)}}else a=i[t]=n,++e._eventsCount;return e}function $t(e,t,n){var r=!1;function o(){e.removeListener(t,o),r||(r=!0,n.apply(e,arguments))}return o.listener=n,o}function en(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function tn(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}zt.prototype=Object.create(null),_t.EventEmitter=_t,_t.usingDomains=!1,_t.prototype.domain=void 0,_t.prototype._events=void 0,_t.prototype._maxListeners=void 0,_t.defaultMaxListeners=10,_t.init=function(){this.domain=null,_t.usingDomains&&(!Dt.active||this instanceof Dt.Domain||(this.domain=Dt.active)),this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new zt,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},_t.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},_t.prototype.getMaxListeners=function(){return Vt(this)},_t.prototype.emit=function(e){var t,n,r,o,i,a,A,s="error"===e;if(a=this._events)s=s&&null==a.error;else if(!s)return!1;if(A=this.domain,s){if(t=arguments[1],!A){if(t instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=A,t.domainThrown=!1,A.emit("error",t),!1}if(!(n=a[e]))return!1;var u="function"==typeof n;switch(r=arguments.length){case 1:Ht(n,u,this);break;case 2:Jt(n,u,this,arguments[1]);break;case 3:Zt(n,u,this,arguments[1],arguments[2]);break;case 4:Kt(n,u,this,arguments[1],arguments[2],arguments[3]);break;default:for(o=new Array(r-1),i=1;i0;)if(n[i]===t||n[i].listener&&n[i].listener===t){a=n[i].listener,o=i;break}if(o<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new zt,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,o=e.length;r0?Reflect.ownKeys(this._events):[]};var nn=function(e,t,n){var r="function"==typeof window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLDOM"):void 0;if(!r)return n(new Error("FlashURLHandler: Microsoft.XMLDOM format not supported"));r.async=!1,request.open("GET",e),request.timeout=t.timeout||0,request.withCredentials=t.withCredentials||!1,request.send(),request.onprogress=function(){},request.onload=function(){r.loadXML(request.responseText),n(null,r)}},rn=function(){return window.XDomainRequest&&(e=new XDomainRequest),!!e;var e},on=function(e,t,n){n(new Error("Please bundle the library for node to use the node urlHandler"))};function an(){try{var e=new window.XMLHttpRequest;return"withCredentials"in e?e:null}catch(e){return console.log("Error in XHRURLHandler support check:",e),null}}var An,sn,cn=function(e,t,n){if("https:"===window.location.protocol&&0===e.indexOf("http://"))return n(new Error("XHRURLHandler: Cannot go from HTTPS to HTTP."));try{var r=an();r.open("GET",e),r.timeout=t.timeout||0,r.withCredentials=t.withCredentials||!1,r.overrideMimeType&&r.overrideMimeType("text/xml"),r.onreadystatechange=function(){4===r.readyState&&(200===r.status?n(null,r.responseXML):n(new Error("XHRURLHandler: ".concat(r.statusText))))},r.send()}catch(e){n(new Error("XHRURLHandler: Unexpected error"))}},un=function(){return!!an()},ln={get:function(e,t,n){return n||("function"==typeof t&&(n=t),t={}),"undefined"==typeof window||null===window?on(e,t,n):un()?cn(e,t,n):rn()?nn(e,t,n):n(new Error("Current context is not supported by any of the default URLHandlers. Please provide a custom URLHandler"))}},fn=st((function e(){ct(this,e),this.ads=[],this.errorURLTemplates=[]})),pn={ERRORCODE:900,extensions:[]},dn=function(e){nt(n,e);var t=ot(n);function n(){var e;return ct(this,n),(e=t.call(this)).remainingAds=[],e.parentURLs=[],e.errorURLTemplates=[],e.rootErrorURLTemplates=[],e.maxWrapperDepth=null,e.URLTemplateFilters=[],e.fetchingOptions={},e}return st(n,[{key:"addURLTemplateFilter",value:function(e){"function"==typeof e&&this.URLTemplateFilters.push(e)}},{key:"removeURLTemplateFilter",value:function(){this.URLTemplateFilters.pop()}},{key:"countURLTemplateFilters",value:function(){return this.URLTemplateFilters.length}},{key:"clearURLTemplateFilters",value:function(){this.URLTemplateFilters=[]}},{key:"trackVastError",value:function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),o=2;o0&&void 0!==arguments[0]?arguments[0]:{};this.rootURL="",this.remainingAds=[],this.parentURLs=[],this.errorURLTemplates=[],this.rootErrorURLTemplates=[],this.maxWrapperDepth=e.wrapperLimit||10,this.fetchingOptions={timeout:e.timeout,withCredentials:e.withCredentials},this.urlHandler=e.urlhandler||ln}},{key:"getRemainingAds",value:function(e){var t=this;if(0===this.remainingAds.length)return Promise.reject(new Error("No more ads are available for the given VAST"));var n=e?yt.flatten(this.remainingAds):this.remainingAds.shift();return this.errorURLTemplates=[],this.parentURLs=[],this.resolveAds(n,{wrapperDepth:0,originalUrl:this.rootURL}).then((function(e){return t.buildVASTResponse(e)}))}},{key:"getAndParseVAST",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initParsingStatus(n),this.rootURL=e,this.fetchVAST(e).then((function(r){return n.originalUrl=e,n.isRootVAST=!0,t.parse(r,n).then((function(e){return t.buildVASTResponse(e)}))}))}},{key:"parseVAST",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initParsingStatus(n),n.isRootVAST=!0,this.parse(e,n).then((function(e){return t.buildVASTResponse(e)}))}},{key:"buildVASTResponse",value:function(e){var t=new fn;return t.ads=e,t.errorURLTemplates=this.getErrorURLTemplates(),this.completeWrapperResolving(t),t}},{key:"parse",value:function(e,t){var n=t.resolveAll,r=void 0===n||n,o=t.wrapperSequence,i=void 0===o?null:o,a=t.originalUrl,A=void 0===a?null:a,s=t.wrapperDepth,c=void 0===s?0:s,u=t.isRootVAST,l=void 0!==u&&u;if(!e||!e.documentElement||"VAST"!==e.documentElement.nodeName)return Promise.reject(new Error("Invalid VAST XMLDocument"));var f=[],p=e.documentElement.childNodes;for(var d in p){var g=p[d];if("Error"===g.nodeName){var h=xt(g);l?this.rootErrorURLTemplates.push(h):this.errorURLTemplates.push(h)}if("Ad"===g.nodeName){var v=Nt(g);v?f.push(v):this.trackVastError(this.getErrorURLTemplates(),{ERRORCODE:101})}}var m=f.length,C=f[m-1];return 1===m&&null!=i&&C&&!C.sequence&&(C.sequence=i),!1===r&&(this.remainingAds=St(f),f=this.remainingAds.shift()),this.resolveAds(f,{wrapperDepth:c,originalUrl:A})}},{key:"resolveAds",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1?arguments[1]:void 0,r=n.wrapperDepth,o=n.originalUrl,i=[];return t.forEach((function(t){var n=e.resolveWrappers(t,r,o);i.push(n)})),Promise.all(i).then((function(t){var n=yt.flatten(t);if(!n&&e.remainingAds.length>0){var i=e.remainingAds.shift();return e.resolveAds(i,{wrapperDepth:r,originalUrl:o})}return n}))}},{key:"resolveWrappers",value:function(e,t,n){var r=this;return new Promise((function(o,i){if(t++,!e.nextWrapperURL)return delete e.nextWrapperURL,o(e);if(t>=r.maxWrapperDepth||-1!==r.parentURLs.indexOf(e.nextWrapperURL))return e.errorCode=302,delete e.nextWrapperURL,o(e);e.nextWrapperURL=Et(e.nextWrapperURL,n);var a=e.sequence;n=e.nextWrapperURL,r.fetchVAST(e.nextWrapperURL,t,n).then((function(i){return r.parse(i,{originalUrl:n,wrapperSequence:a,wrapperDepth:t}).then((function(t){if(delete e.nextWrapperURL,0===t.length)return e.creatives=[],o(e);t.forEach((function(t){t&&Tt(t,e)})),o(t)}))})).catch((function(t){e.errorCode=301,e.errorMessage=t.message,o(e)}))}))}},{key:"completeWrapperResolving",value:function(e){if(0===e.ads.length)this.trackVastError(e.errorURLTemplates,{ERRORCODE:303});else for(var t=e.ads.length-1;t>=0;t--){var n=e.ads[t];(n.errorCode||0===n.creatives.length)&&(this.trackVastError(n.errorURLTemplates.concat(e.errorURLTemplates),{ERRORCODE:n.errorCode||303},{ERRORMESSAGE:n.errorMessage||""},{extensions:n.extensions},{system:n.system}),e.ads.splice(t,1))}}}]),n}(_t),gn=null,hn={data:{},length:0,getItem:function(e){return this.data[e]},setItem:function(e,t){this.data[e]=t,this.length=Object.keys(this.data).length},removeItem:function(e){delete data[e],this.length=Object.keys(this.data).length},clear:function(){this.data={},this.length=0}},vn=function(){function e(){ct(this,e),this.storage=this.initStorage()}return st(e,[{key:"initStorage",value:function(){if(gn)return gn;try{gn="undefined"!=typeof window&&null!==window?window.localStorage||window.sessionStorage:null}catch(e){gn=null}return gn&&!this.isStorageDisabled(gn)||(gn=hn).clear(),gn}},{key:"isStorageDisabled",value:function(e){var t="__VASTStorage__";try{if(e.setItem(t,t),e.getItem(t)!==t)return e.removeItem(t),!0}catch(e){return!0}return e.removeItem(t),!1}},{key:"getItem",value:function(e){return this.storage.getItem(e)}},{key:"setItem",value:function(e,t){return this.storage.setItem(e,t)}},{key:"removeItem",value:function(e){return this.storage.removeItem(e)}},{key:"clear",value:function(){return this.storage.clear()}}]),e}(),mn=function(){function e(t,n,r){ct(this,e),this.cappingFreeLunch=t||0,this.cappingMinimumTimeInterval=n||0,this.defaultOptions={withCredentials:!1,timeout:0},this.vastParser=new dn,this.storage=r||new vn,void 0===this.lastSuccessfulAd&&(this.lastSuccessfulAd=0),void 0===this.totalCalls&&(this.totalCalls=0),void 0===this.totalCallsTimeout&&(this.totalCallsTimeout=0)}return st(e,[{key:"getParser",value:function(){return this.vastParser}},{key:"lastSuccessfulAd",get:function(){return this.storage.getItem("vast-client-last-successful-ad")},set:function(e){this.storage.setItem("vast-client-last-successful-ad",e)}},{key:"totalCalls",get:function(){return this.storage.getItem("vast-client-total-calls")},set:function(e){this.storage.setItem("vast-client-total-calls",e)}},{key:"totalCallsTimeout",get:function(){return this.storage.getItem("vast-client-total-calls-timeout")},set:function(e){this.storage.setItem("vast-client-total-calls-timeout",e)}},{key:"hasRemainingAds",value:function(){return this.vastParser.remainingAds.length>0}},{key:"getNextAds",value:function(e){return this.vastParser.getRemainingAds(e)}},{key:"get",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=Date.now();return(n=Object.assign(this.defaultOptions,n)).hasOwnProperty("resolveAll")||(n.resolveAll=!1),this.totalCallsTimeout=t.totalCalls)return i(new Error("VAST call canceled – FreeLunch capping not reached yet ".concat(t.totalCalls,"/").concat(t.cappingFreeLunch)));var a=r-t.lastSuccessfulAd;if(a<0)t.lastSuccessfulAd=0;else if(a3&&void 0!==arguments[3]?arguments[3]:null;for(var A in ct(this,n),(i=t.call(this)).ad=r,i.creative=o,i.variation=a,i.muted=!1,i.impressed=!1,i.skippable=!1,i.trackingEvents={},i._alreadyTriggeredQuartiles={},i.emitAlwaysEvents=["creativeView","start","firstQuartile","midpoint","thirdQuartile","complete","resume","pause","rewind","skip","closeLinear","close"],i.creative.trackingEvents){var s=i.creative.trackingEvents[A];i.trackingEvents[A]=s.slice(0)}return i.creative instanceof Rt?i._initLinearTracking():i._initVariationTracking(),e&&i.on("start",(function(){e.lastSuccessfulAd=Date.now()})),i}return st(n,[{key:"_initLinearTracking",value:function(){this.linear=!0,this.skipDelay=this.creative.skipDelay,this.setDuration(this.creative.duration),this.clickThroughURLTemplate=this.creative.videoClickThroughURLTemplate,this.clickTrackingURLTemplates=this.creative.videoClickTrackingURLTemplates}},{key:"_initVariationTracking",value:function(){if(this.linear=!1,this.skipDelay=-1,this.variation){for(var e in this.variation.trackingEvents){var t=this.variation.trackingEvents[e];this.trackingEvents[e]?this.trackingEvents[e]=this.trackingEvents[e].concat(t.slice(0)):this.trackingEvents[e]=t.slice(0)}this.variation instanceof Ft?(this.clickThroughURLTemplate=this.variation.nonlinearClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.nonlinearClickTrackingURLTemplates,this.setDuration(this.variation.minSuggestedDuration)):this.variation instanceof pt&&(this.clickThroughURLTemplate=this.variation.companionClickThroughURLTemplate,this.clickTrackingURLTemplates=this.variation.companionClickTrackingURLTemplates)}}},{key:"setDuration",value:function(e){this.assetDuration=e,this.quartiles={firstQuartile:Math.round(25*this.assetDuration)/100,midpoint:Math.round(50*this.assetDuration)/100,thirdQuartile:Math.round(75*this.assetDuration)/100}}},{key:"setProgress",value:function(e){var t=this,n=this.skipDelay||-1;if(-1===n||this.skippable||(n>e?this.emit("skip-countdown",n-e):(this.skippable=!0,this.emit("skip-countdown",0))),this.assetDuration>0){var r=[];if(e>0){var o=Math.round(e/this.assetDuration*100);for(var i in r.push("start"),r.push("progress-".concat(o,"%")),r.push("progress-".concat(Math.round(e))),this.quartiles)this.isQuartileReached(i,this.quartiles[i],e)&&(r.push(i),this._alreadyTriggeredQuartiles[i]=!0)}r.forEach((function(e){t.track(e,!0)})),e0&&void 0!==arguments[0]?arguments[0]:null;this.clickTrackingURLTemplates&&this.clickTrackingURLTemplates.length&&this.trackURLs(this.clickTrackingURLTemplates);var t=this.clickThroughURLTemplate||e;if(t){var n=this.linear?{CONTENTPLAYHEAD:this.progressFormatted()}:{},r=yt.resolveURLTemplates([t],n)[0];this.emit("clickthrough",r)}}},{key:"track",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];"closeLinear"===e&&!this.trackingEvents[e]&&this.trackingEvents.close&&(e="close");var n=this.trackingEvents[e],r=this.emitAlwaysEvents.indexOf(e)>-1;n?(this.emit(e,""),this.trackURLs(n)):r&&this.emit(e,""),t&&(delete this.trackingEvents[e],r&&this.emitAlwaysEvents.splice(this.emitAlwaysEvents.indexOf(e),1))}},{key:"trackURLs",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.linear&&(this.creative&&this.creative.mediaFiles&&this.creative.mediaFiles[0]&&this.creative.mediaFiles[0].fileURL&&(t.ASSETURI=this.creative.mediaFiles[0].fileURL),t.CONTENTPLAYHEAD=this.progressFormatted()),yt.track(e,t)}},{key:"progressFormatted",value:function(){var e=parseInt(this.progress),t=e/3600;t.length<2&&(t="0".concat(t));var n=e/60%60;n.length<2&&(n="0".concat(n));var r=e%60;return r.length<2&&(r="0".concat(n)),"".concat(t,":").concat(n,":").concat(r,".").concat(parseInt(100*(this.progress-e)))}}]),n}(_t),yn=function(e,t,n,r){var o,i={},a={started:!1,active:!1,isVideoEnded:!1,lang:n.getLanguage()},A=null,s="",c=null,u="",l="",f=!1,p=n.getBrowser(),d="Android"===p.os||"iOS"===p.os;(o=document.createElement("div")).setAttribute("class","op-ads"),o.setAttribute("id","op-ads"),n.getContainer().append(o),(c=document.createElement("video")).setAttribute("playsinline","true"),c.setAttribute("title","Advertisement"),c.setAttribute("class","op-ads-vast-video"),(l=document.createElement("div")).setAttribute("class","op-ads-button"),(u=document.createElement("div")).setAttribute("class","op-ads-textview"),l.append(u),o.append(c),o.append(l),s=o;var g=new mn,h=null,v=null,m=function(e){console.log(e),c.style.display="none",t.trigger(se,{code:e.code,message:e.message}),a.active=!1,a.started=!0,t.play()};return i.isActive=function(){return a.active},i.started=function(){return a.started},i.play=function(){return a.started?c.play():new Promise((function(o,i){!function s(){t.metaLoaded()?(OvenPlayerConsole.log("VAST : main contents meta loaded."),function(){OvenPlayerConsole.log("VAST : checkAutoplaySupport() ");var n=document.createElement("video");n.setAttribute("playsinline","true"),n.src=Xe,n.load(),c.load(),d&&t.getName()!==le&&e.load();var r=function(e,t){f=e,n.pause(),n.remove()};return new Promise((function(e,t){if(n.play){var o=n.play();void 0!==o?o.then((function(){OvenPlayerConsole.log("VAST : auto play allowed."),r(!0),e()})).catch((function(t){OvenPlayerConsole.log("VAST : auto play failed",t.message),r(!1),e()})):(OvenPlayerConsole.log("VAST : promise not support"),r(!0),e())}else OvenPlayerConsole.log("VAST : !temporarySupportCheckVideo.play"),r(!0),e()}))}().then((function(){n.isAutoStart()&&!f?(OvenPlayerConsole.log("VAST : autoplayAllowed : false"),a.started=!1,i(new Error("autoplayNotAllowed"))):(g.get(r).then((function(n){if(OvenPlayerConsole.log("VAST : initRequest()"),!(v=n.ads[0]))throw{code:401,message:"File not found. Unable to find Linear/MediaFile from URI."};h=new Cn(g,v,v.creatives[0]),OvenPlayerConsole.log("VAST : created ad tracker."),A=function(e,t,n,r,o,i,a){var A={},s={},c=ze(i),u=ze(o),l=ze(e);n.on(Le,(function(t){t.mute?e.muted=!0:(e.muted=!1,e.volume=t.volume/100)}),s);var f=function(){r.active=!1,u.hide(),!r.started||0!==n.getPosition()&&r.isVideoEnded||(l.hide(),n.play()),n.trigger(Ae)},p=function(n){c.hasClass("videoAdUiAction")&&(t.skip(),e.pause(),f())};return i.addEventListener("click",p,!1),A.error=function(){OvenPlayerConsole.log("VAST : listener : error.",e.error),console.log("VAST : listener : error.",e.error);var n={},r=e.error&&e.error.code||0;2===r?(n.code=402,n.message="Timeout of MediaFile URI."):3===r?(n.code=405,n.message="Problem displaying MediaFile. Video player found a MediaFile with supported type but couldn’t display it. MediaFile may include: unsupported codecs, different MIME type than MediaFile@type, unsupported delivery method, etc."):4===r?(n.code=403,n.message="Couldn’t find MediaFile that is supported by this video player, based on the attributes of the MediaFile element."):(n.code=400,n.message="General Linear error. Video player is unable to display the Linear Ad."),t.errorWithCode(n.code),a("405")},A.canplay=function(){},A.ended=function(){t.complete(),f()},A.click=function(e){t.click()},A.play=function(){t.setPaused(!1)},A.pause=function(){t.setPaused(!0)},A.timeupdate=function(r){t.setProgress(r.target.currentTime),n.trigger(Ie,{duration:e.duration,position:e.currentTime})},A.volumechange=function(e){OvenPlayerConsole.log("VAST : listener : Ad Video Volumechange."),t.setMuted(e.target.muted)},A.loadedmetadata=function(){OvenPlayerConsole.log("VAST : listener : Ad CONTENT LOADED ."),ee===n.getState()&&n.pause(),t.trackImpression(),n.trigger(oe,{remaining:e.duration,isLinear:!0}),e.play()},t.on("skip",(function(){OvenPlayerConsole.log("VAST : listener : skipped")})),t.on("mute",(function(){OvenPlayerConsole.log("VAST : listener : muted")})),t.on("unmute",(function(){OvenPlayerConsole.log("VAST : listener : unmuted")})),t.on("resume",(function(){OvenPlayerConsole.log("VAST : listener : vastTracker resumed."),r.started&&n.setState(ie)})),t.on("pause",(function(){OvenPlayerConsole.log("VAST : listener : vastTracker paused."),n.setState(ae)})),t.on("clickthrough",(function(e){OvenPlayerConsole.log("VAST : listener : clickthrough :",e),window.open(e,"_blank")})),t.on("skip-countdown",(function(e){0===e?("ko"===r.lang?c.html("광고 건너뛰기"):c.html("Ad Skip"),c.addClass("videoAdUiAction")):"ko"===r.lang?c.html(parseInt(e)+1+"초 후에 이 광고를 건너뛸 수 있습니다."):c.html("You can skip this ad in "+(parseInt(e)+1))})),t.on("rewind",(function(){OvenPlayerConsole.log("VAST : listener : rewind")})),t.on("start",(function(){OvenPlayerConsole.log("VAST : listener : started"),r.started=!0,r.active=!0,l.show(),u.show(),n.trigger(ke,{isLinear:!0}),n.setState(ie)})),t.on("firstQuartile",(function(){OvenPlayerConsole.log("VAST : listener : firstQuartile")})),t.on("midpoint",(function(){OvenPlayerConsole.log("VAST : listener : midpoint")})),t.on("thirdQuartile",(function(){OvenPlayerConsole.log("VAST : listener : thirdQuartile")})),t.on("creativeView",(function(){OvenPlayerConsole.log("VAST : listener : creativeView")})),Object.keys(A).forEach((function(t){e.removeEventListener(t,A[t]),e.addEventListener(t,A[t])})),s.destroy=function(){OvenPlayerConsole.log("EventListener : destroy()"),i.removeEventListener("click",p,!1),Object.keys(A).forEach((function(t){e.removeEventListener(t,A[t])}))},s}(c,h,t,a,l,u,m);var r="";v.creatives&&v.creatives.length>0&&v.creatives[0].mediaFiles&&v.creatives[0].mediaFiles.length>0&&v.creatives[0].mediaFiles[0].fileURL&&(r=v.creatives[0].mediaFiles[0].fileURL,OvenPlayerConsole.log("VAST : media url : ",r)),c.src=r,c.volume=e.volume,c.muted=e.muted})).catch((function(e){m(e)})),o())}))):setTimeout(s,100)}()}))},i.pause=function(){c.pause()},i.videoEndedCallback=function(e){e(),a.isVideoEnded=!0},i.destroy=function(){A&&(A.destroy(),A=null),h=null,g=null,s.remove()},i},bn=function(e,t,n){OvenPlayerConsole.log("[Provider] loaded. ");var r={};Ge(r);var o=e.element,i=null,a=null;e.adTagUrl&&(OvenPlayerConsole.log("[Provider] Ad Client - ",t.getAdClient()),(i="vast"===t.getAdClient()?yn(o,r,t,e.adTagUrl):et(o,r,t,e.adTagUrl))||console.log("Can not load due to google ima for Ads.")),a=function(e,t,n,r){var o={};OvenPlayerConsole.log("EventListener loaded.",e,t);var i={},a=-1,A=e;return o.canplay=function(){t.setCanSeek(!0),t.trigger("bufferFull"),OvenPlayerConsole.log("EventListener : on canplay")},o.durationchange=function(){o.progress(),OvenPlayerConsole.log("EventListener : on durationchange"),t.trigger("durationChanged")},o.ended=function(){OvenPlayerConsole.log("EventListener : on ended"),A.pause(),t.getState()!==X&&t.getState()!==q&&t.getState()!==te&&(n?n((function(){t.setState(q)})):t.setState(q))},o.loadeddata=function(){},o.loadedmetadata=function(){var e=t.getSources(),n=t.getCurrentSource(),r=n>-1?e[n].type:"",o={duration:t.isLive()?1/0:A.duration,type:r};t.setMetaLoaded(),OvenPlayerConsole.log("EventListener : on loadedmetadata",o),t.trigger(Me,o)},o.pause=function(){return t.getState()!==q&&t.getState()!==te&&!A.ended&&!A.error&&A.currentTime!==A.duration&&(OvenPlayerConsole.log("EventListener : on pause"),void t.setState($))},o.loadstart=function(){r&&!r.getConfig().showBigPlayButton&&r.getConfig().autoStart&&t.setState(ne)},o.play=function(){a=-1,A.paused||t.getState()===ee||t.setState(ne)},o.playing=function(){OvenPlayerConsole.log("EventListener : on playing"),a<0&&t.setState(ee)},o.progress=function(){var e=A.buffered;if(!e)return!1;var n,r=A.duration,o=A.currentTime,i=(n=(e.length>0?e.end(e.length-1):0)/r,Math.max(Math.min(n,1),0));t.setBuffer(100*i),t.trigger(Se,{bufferPercent:100*i,position:o,duration:r}),OvenPlayerConsole.log("EventListener : on progress",100*i)},o.timeupdate=function(){var e=A.currentTime,n=A.duration;if(!isNaN(n)){if(e>n)return A.pause(),void t.setState(q);var r=t.getSources()[t.getCurrentSource()].sectionStart;r&&eo&&t.getState()===ee)return t.stop(),void t.setState(q);n>9e15&&(n=1/0),t.isSeeking()||A.paused||t.getState()!==re&&t.getState()!==ne&&t.getState()!==ie||function(e,t){return e.toFixed(2)===t.toFixed(2)}(a,e)||(a=-1,t.setState(ee)),r&&r>0&&(e-=r)<0&&(e=0),o&&(n=o),r&&(n-=r),(t.getState()===ee||t.isSeeking())&&t.trigger(Te,{position:e,duration:n})}},o.seeking=function(){t.setSeeking(!0),OvenPlayerConsole.log("EventListener : on seeking",A.currentTime),t.trigger("seek",{position:A.currentTime})},o.seeked=function(){t.isSeeking()&&(OvenPlayerConsole.log("EventListener : on seeked"),t.setSeeking(!1),t.trigger("seeked"))},o.stalled=function(){OvenPlayerConsole.log("EventListener : on stalled")},o.waiting=function(){OvenPlayerConsole.log("EventListener : on waiting",t.getState()),t.isSeeking()?t.setState(ne):t.getState()===ee&&(a=A.currentTime,t.setState(re))},o.volumechange=function(){OvenPlayerConsole.log("EventListener : on volumechange",Math.round(100*A.volume)),t.trigger(Le,{volume:Math.round(100*A.volume),mute:A.muted})},o.error=function(){var e={0:300,1:301,2:302,3:303,4:304}[A.error&&A.error.code||0]||0;OvenPlayerConsole.log("EventListener : on error",e),qe(We.codes[e],t)},Object.keys(o).forEach((function(e){A.removeEventListener(e,o[e]),A.addEventListener(e,o[e])})),i.destroy=function(){OvenPlayerConsole.log("EventListener : destroy()"),Object.keys(o).forEach((function(e){A.removeEventListener(e,o[e])}))},i}(o,r,i?i.videoEndedCallback:null,t),o.playbackRate=o.defaultPlaybackRate=t.getPlaybackRate();var A=function(i){var a=e.sources[e.currentSource];if(e.framerate=a.framerate,r.setVolume(t.getVolume()),e.framerate||t.setTimecodeMode(!0),n)n(a,i);else{OvenPlayerConsole.log("source loaded : ",a,"lastPlayPosition : "+i);var A=o.src;a.file!==A&&(o.src=a.file,(A||""===A)&&o.load()),r.on(Me,(function(){i>0&&r.seek(i)}))}};return r.getName=function(){return e.name},r.getMse=function(){return e.mse},r.getMediaElement=function(){return e.element},r.canSeek=function(){return e.canSeek},r.setCanSeek=function(t){e.canSeek=t},r.isSeeking=function(){return e.seeking},r.setSeeking=function(t){e.seeking=t},r.setMetaLoaded=function(){e.isLoaded=!0},r.metaLoaded=function(){return e.isLoaded},r.setState=function(t){if(e.state!==t){var n=e.state;if(OvenPlayerConsole.log("Provider : setState()",t),n===ie&&(t===te||t===X))return!1;switch(OvenPlayerConsole.log("Provider : triggerSatatus",t),t){case q:r.trigger("complete");break;case $:r.trigger(ye,{prevState:e.state,newstate:$});break;case ae:r.trigger(ye,{prevState:e.state,newstate:ae});break;case ee:r.trigger(be,{prevState:e.state,newstate:ee});break;case ie:r.trigger(be,{prevState:e.state,newstate:ie})}e.state=t,r.trigger(Ce,{prevstate:n,newstate:e.state})}},r.getState=function(){return e.state},r.setBuffer=function(t){e.buffer=t},r.getBuffer=function(){return e.buffer},r.isLive=function(){return!!e.isLive||o.duration===1/0},r.getDuration=function(){return r.isLive()?1/0:o.duration},r.getDvrWindow=function(){return e.dvrWindow},r.getPosition=function(){return o?o.currentTime:0},r.setVolume=function(e){if(!o)return!1;o.volume=e/100,t.setVolume(e)},r.getVolume=function(){return t.getVolume()},r.setMute=function(e){if(!o)return!1;if(void 0===e){var n=t.isMute();o.muted=!n,t.setMute(!n),r.trigger(Re,{mute:t.isMute()})}else o.muted=e,t.setMute(e),r.trigger(Re,{mute:t.isMute()});return o.muted},r.getMute=function(){return t.isMute()},r.preload=function(n,o){return e.sources=n,e.currentSource=$e(n,t),A(o||0),new Promise((function(e,n){t.isMute()&&r.setMute(!0),t.getVolume()&&r.setVolume(t.getVolume()),e()}))},r.load=function(n){e.sources=n,e.currentSource=$e(n,t),A(0)},r.play=function(){if(OvenPlayerConsole.log("Provider : play()"),!o)return!1;if(r.getState()!==ee)if(i&&i.isActive()||i&&!i.started())i.play().then((function(e){OvenPlayerConsole.log("Provider : ads play success")})).catch((function(e){OvenPlayerConsole.log("Provider : ads play fail",e)}));else{var e=o.play();void 0!==e?e.then((function(){OvenPlayerConsole.log("Provider : video play success")})).catch((function(e){OvenPlayerConsole.log("Provider : video play error",e.message)})):OvenPlayerConsole.log("Provider : video play success (ie)")}},r.pause=function(){if(OvenPlayerConsole.log("Provider : pause()"),!o)return!1;r.getState()===ee?o.pause():r.getState()===ie&&i.pause()},r.seek=function(e){if(!o)return!1;o.currentTime=e},r.setPlaybackRate=function(e){return!!o&&(r.trigger("playbackRateChanged",{playbackRate:e}),o.playbackRate=o.defaultPlaybackRate=e)},r.getPlaybackRate=function(){return o?o.playbackRate:0},r.getSources=function(){return o?e.sources.map((function(e,t){var n={file:e.file,type:e.type,label:e.label,index:t,sectionStart:e.sectionStart,sectionEnd:e.sectionEnd,gridThumbnail:e.gridThumbnail};return e.lowLatency&&(n.lowLatency=e.lowLatency),n})):[]},r.getCurrentSource=function(){return e.currentSource},r.setCurrentSource=function(n,i){if(n>-1&&e.sources&&e.sources.length>n)return OvenPlayerConsole.log("source changed : "+n),e.currentSource=n,t.setSourceIndex(n),r.setState(X),i&&A(o.currentTime||0),e.currentSource},r.getQualityLevels=function(){return o?e.qualityLevels:[]},r.getCurrentQuality=function(){return o?e.currentQuality:null},r.setCurrentQuality=function(e){},r.getAudioTracks=function(){return o?e.audioTracks:[]},r.getCurrentAudioTrack=function(){return o?e.currentAudioTrack:[]},r.setCurrentAudioTrack=function(e){},r.isAutoQuality=function(){},r.setAutoQuality=function(e){},r.getFramerate=function(){return e.framerate},r.setFramerate=function(t){return e.framerate=t},r.seekFrame=function(t){var n=e.framerate,i=(o.currentTime*n+t)/n;i+=1e-5,r.pause(),r.seek(i)},r.stop=function(){if(!o)return!1;for(OvenPlayerConsole.log("CORE : stop() "),o.removeAttribute("preload"),o.removeAttribute("src");o.firstChild;)o.removeChild(o.firstChild);r.pause(),r.setState(X)},r.destroy=function(){if(!o)return!1;r.stop(),a.destroy(),i&&(i.destroy(),i=null),r.off(),OvenPlayerConsole.log("CORE : destroy() player stop, listener, event destroied")},r.super=function(e){var t=r[e];return function(){return t.apply(r,arguments)}},r},wn=function(e,t,n){var r=bn({name:ce,element:e,mse:null,listener:null,isLoaded:!1,canSeek:!1,isLive:!1,seeking:!1,state:X,buffer:0,framerate:0,currentQuality:-1,qualityLevels:[],currentAudioTrack:-1,audioTracks:[],currentSource:-1,sources:[],adTagUrl:n},t,null),o=r.super("destroy");return OvenPlayerConsole.log("HTML5 PROVIDER LOADED."),r.destroy=function(){OvenPlayerConsole.log("HTML5 : PROVIDER DESTROYED."),o()},r},En=function(e,t,n,r,o,a,A,s){var c={},u={},l=null,f=!1,p=null,d=null,g={},h=!1,v=!1,m=null,C=!1;A.getConfig().webrtcConfig&&!0===A.getConfig().webrtcConfig.recoverPacketLoss&&(v=!0);var y=!0;A.getConfig().webrtcConfig&&!1===A.getConfig().webrtcConfig.generatePublicCandidate&&(y=A.getConfig().webrtcConfig.generatePublicCandidate);var b=Y(),w=null;function E(e){var t=null;return d&&e===d.id?t=d.peerConnection:g[e]&&(t=g[e].peerConnection),t}function B(e){e.statisticsTimer&&clearTimeout(e.statisticsTimer),e.status||(e.status={},e.status.lostPacketsArr=[],e.status.slotLength=8,e.status.prevPacketsLost=0,e.status.avg8Losses=0,e.status.avgMoreThanThresholdCount=0,e.status.threshold=40);var t=e.status.lostPacketsArr,n=e.status.slotLength,r=e.status.prevPacketsLost,o=e.status.avg8Losses,a=e.status.threshold;e.statisticsTimer=setTimeout((function(){if(!e.peerConnection)return!1;e.peerConnection.getStats().then((function(s){s&&A.getConfig().autoFallback&&s&&(s.forEach((function(A){if("inbound-rtp"===A.type&&"video"===A.kind&&!A.isRemote){var s=parseInt(A.packetsLost)-parseInt(r);t.push(parseInt(A.packetsLost)-parseInt(r)),t.length>n&&t.shift(),t.length===n&&(o=i().reduce(t,(function(e,t){return e+t}),0)/n,OvenPlayerConsole.log("Last8 LOST PACKET AVG : "+o,"Current Packet LOST: "+s,"Total Packet Lost: "+A.packetsLost,t),o>a?(e.status.avgMoreThanThresholdCount=e.status.avgMoreThanThresholdCount+1,e.status.avgMoreThanThresholdCount>=60&&(OvenPlayerConsole.log("NETWORK UNSTABLED!!! "),M(We.codes[510]))):e.status.avgMoreThanThresholdCount=0),e.status.prevPacketsLost=A.packetsLost}})),B(e))}))}),2e3)}function x(o,a,s,u,f){var g={};if(A.getConfig().webrtcConfig&&A.getConfig().webrtcConfig.iceServers)g.iceServers=A.getConfig().webrtcConfig.iceServers,A.getConfig().webrtcConfig.iceTransportPolicy&&(g.iceTransportPolicy=A.getConfig().webrtcConfig.iceTransportPolicy);else if(f){g.iceServers=[];for(var m=0;m-1){b=!0;break}if(!b&&y.urls.length>0){var x=i().clone(y.urls[0]),k=S(x);w&&k&&y.urls.push(x.replace(k,w))}y.username=C.username||C.user_name,y.credential=C.credential,g.iceServers.push(y)}g.iceTransportPolicy="relay"}else g=c;OvenPlayerConsole.log("Main Peer Connection Config : ",g);var T=null;try{T=new RTCPeerConnection(g),e.trigger("peerConnectionPrepared",T)}catch(e){var R=We.codes[506];return R.error=e,void M(R)}d={id:o,peerId:a,peerConnection:T},T.setRemoteDescription(new RTCSessionDescription(s)).then((function(){T.createAnswer().then((function(e){var t=function(e){for(var t=e.split("\r\n"),n=-1,r=0;r-1&&t[r].indexOf("opus")>-1){n=t[r].split(" ")[0].split(":")[1];break}return n}(s.sdp);t>-1&&function(e,t){for(var n=e.split("\r\n"),r=!1,o=0;o-1){n[o].indexOf("stereo=1")>-1&&(r=!0);break}return r}(s.sdp,t)&&(e.sdp=function(e,t){for(var n=e.split("\r\n"),r=0;r-1){-1===n[r].indexOf("stereo=1")&&(n[r]=n[r]+";stereo=1");break}return n.join("\r\n")}(e.sdp,t)),OvenPlayerConsole.log("Local SDP",e),O(l,{id:o,peer_id:a,command:"answer",sdp:e}),OvenPlayerConsole.log("create Host Answer : success"),T.setLocalDescription(e).then((function(){})).catch((function(e){var t=We.codes[505];t.error=e,M(t)}))})).catch((function(e){var t=We.codes[504];t.error=e,M(t)}))})).catch((function(e){var t=We.codes[503];t.error=e,M(t)})),u&&L(T,u),T.onicecandidate=function(e){e.candidate&&(OvenPlayerConsole.log("WebRTCLoader send candidate to server : ",e.candidate),O(l,{id:o,peer_id:a,command:"candidate",candidates:[e.candidate]}))},T.onconnectionstatechange=function(e){OvenPlayerConsole.log("[on connection state change]",T.connectionState,e),"connected"===T.connectionState&&r&&r()},T.onicecandidateerror=function(e){},T.onicegatheringstatechange=function(e){},T.oniceconnectionstatechange=function(e){OvenPlayerConsole.log("[on ice connection state change]",T.iceConnectionState,e),"connected"===T.iceConnectionState&&r&&r(),("disconnected"===T.iceConnectionState||"closed"===T.iceConnectionState)&&(h||d&&M(We.codes[511]))},T.ontrack=function(e){if(OvenPlayerConsole.log("stream received."),OvenPlayerConsole.log("Recovery On Packet Loss :",v),v&&B(d),p=e.streams[0],n(e.streams[0]),A.getConfig().webrtcConfig&&A.getConfig().webrtcConfig.playoutDelayHint)for(var t=A.getConfig().webrtcConfig.playoutDelayHint,r=d.peerConnection.getReceivers(),o=0;o0){for(var n in g){var r=g[n].peerConnection;r&&(OvenPlayerConsole.log("Closing client peer connection..."),r.close(),r=null)}g={}}l?(OvenPlayerConsole.log("Closing websocket connection..."),OvenPlayerConsole.log("Send Signaling : Stop."),1===l.readyState&&(h=!0,d&&O(l,{command:"stop",id:d.id}),l.close())):h=!1,l=null,t&&(o&&o(t),a(t,e))}function O(e,t){e&&e.send(JSON.stringify(t))}return w=window.onbeforeunload,window.onbeforeunload=function(e){w&&w(e),OvenPlayerConsole.log("This calls auto when browser closed."),M()},e.setCurrentQuality=function(e){if(!m)return-1;var t=m.renditions[e];return t?(O(l,{command:"change_rendition",id:d.id,rendition_name:t.name,auto:!1}),C=!1,s.currentQuality=e,s.currentQuality):s.currentQuality},e.isAutoQuality=function(){return C},e.setAutoQuality=function(e){O(l,{command:"change_rendition",id:d.id,auto:e}),C=e},u.connect=function(){OvenPlayerConsole.log("WebRTCLoader connecting..."),OvenPlayerConsole.log("WebRTCLoader url : "+t),R()},u.destroy=function(){h=!0,M(),window.onbeforeunload=w,w=null},u},Bn=function(e,t,n){var r={},o=null,i=null,a=null,A=null,s=null,c={name:ue,element:e,mse:null,listener:null,isLoaded:!1,canSeek:!1,isLive:!1,seeking:!1,state:X,buffer:0,framerate:0,currentQuality:-1,currentSource:-1,qualityLevels:[],sources:[],adTagUrl:n},u=1e4,l=0,f=null,p=!1;function d(){if(Ve(A.file,A.type)){clearTimeout(f),OvenPlayerConsole.log("WEBRTC : onBeforeLoad : ",A),o&&(o.destroy(),o=null);var n=null,i=null;l>0&&(n=function(){clearTimeout(f)},i=function(){clearTimeout(f),performance.now(),p=!0}),o=En(r,A.file,(function(t){if(e.srcObject&&(e.srcObject=null),s&&(s.close(),s=null),e.srcObject=t,t.getAudioTracks().length>0){var n=window.AudioContext||window.webkitAudioContext;(function(e){var t=/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent),n=(/iPhone|iPad|iPod/i.test(navigator.userAgent),!1);t&&"suspended"===e.state&&document.addEventListener("touchend",(function(){n||"running"===e.state||(e.resume(),n=!0)}))})(s=new n),s.createMediaStreamSource(t)}}),i,n,qe,t,c),performance.now(),o.connect(),l>0&&(r.once(Ce,(function(e){p||e.newstate===X&&(clearTimeout(f),g())})),r.once(me,(function(){p=!1})),f=setTimeout((function(){if(l>0)p||(g(),d());else{g();var e=We.codes[512];qe(e,r)}l--}),u))}}function g(){o&&(o.destroy(),o=null,e.srcObject=null)}return r=bn(c,t,(function(e){var n=t.getConfig();n.webrtcConfig&&("number"==typeof n.webrtcConfig.connectionTimeout&&n.webrtcConfig.connectionTimeout>0&&(u=n.webrtcConfig.connectionTimeout),"number"==typeof n.webrtcConfig.timeoutMaxRetry&&n.webrtcConfig.timeoutMaxRetry>0&&(l=n.webrtcConfig.timeoutMaxRetry)),A=e,d()})),i=r.super("destroy"),a=r.super("play"),OvenPlayerConsole.log("WEBRTC PROVIDER LOADED."),r.removeStream=function(){e.srcObject=null},r.destroy=function(){clearTimeout(f),g(),OvenPlayerConsole.log("WEBRTC : PROVIDER DESTROYED."),i()},r.play=function(){l>0&&!p&&d(),a()},r},xn=function(e,t,n){var r=t?1e3:1024;if(Math.abs(e)=r&&a=0&&r.seek(t)})),o.on(Hls.Events.LEVEL_SWITCHED,(function(e,t){f.currentQuality=t.level,r.trigger(Qe,{isAuto:o.autoLevelEnabled,currentQuality:f.currentQuality,type:"render"})})),o.on(Hls.Events.AUDIO_TRACK_SWITCHED,(function(e,t){f.currentAudioTrack=t.id,r.trigger(Ne,{currentAudioTrack:f.currentAudioTrack})})),o.on(Hls.Events.LEVEL_UPDATED,(function(e,t){t&&t.details&&(f.dvrWindow=t.details.totalduration)})),o.on(Hls.Events.ERROR,(function(t,n){if(n&&n.networkDetails&&202===n.networkDetails.status)return A&&(clearTimeout(A),A=null),r.setState(ne),void(A=setTimeout((function(){o&&(r.stop(),o.stopLoad(),o.loadSource(e.file))}),1e3));if(n.fatal){var i=302;n&&n.networkDetails&&400===n.networkDetails.status?i=306:n&&n.networkDetails&&403===n.networkDetails.status?i=307:n&&n.networkDetails&&406===n.networkDetails.status&&(i=308);var a=We.codes[i];a.error=n.details,qe(a,r)}})),r.on(Ce,(function(e){s||e.prevstate!==ne||e.newstate!==X||(A&&(clearTimeout(A),A=null),o&&o.stopLoad())}))})),r.setCurrentQuality=function(e){return o.currentLevel=e,f.currentQuality=e,f.currentQuality},r.isAutoQuality=function(){return o.autoLevelEnabled},r.setAutoQuality=function(e){o.currentLevel=e?-1:o.currentLevel},r.setCurrentAudioTrack=function(e){return o.audioTrack=e,f.currentAudioTrack=e,f.currentAudioTrack},r.getDuration=function(){return e.duration},i=r.super("stop"),r.stop=function(){A&&(clearTimeout(A),A=null),o&&o.stopLoad(),i()},a=r.super("destroy"),r.destroy=function(){A&&(clearTimeout(A),A=null),o&&(o.destroy(),r.trigger("hlsDestroyed")),o=null,OvenPlayerConsole.log("HLS : PROVIDER DESTROYED."),a()},OvenPlayerConsole.log("HLS PROVIDER LOADED.")}catch(e){var p=We.codes[106];throw p.error=e,p}return r},Sn=function(e){var t={};Ge(t),OvenPlayerConsole.log("API loaded.");var n=function(e){var t={},n={playlist:[],currentIndex:0},r=Ke();OvenPlayerConsole.log("PlaylistManager loaded.");var o=function(e){if(e&&(e.file||e.host||e.application||e.stream)){var t=Object.assign({},{default:!1},e);t.file=a(""+t.file),t.host&&t.application&&t.stream&&(t.file=t.host+"/"+t.application+"/stream/"+t.stream,delete t.host,delete t.application,delete t.stream);var n=/^[^/]+\/(?:x-)?([^/]+)$/;if(n.test(t.type)&&(t.mimeType=t.type,t.type=t.type.replace(n,"$1")),_e(t.file)?t.type="rtmp":Ve(t.file)?t.type="webrtc":He(t.file,t.type)?t.type="hls":Je(t.file,t.type)?t.type="dash":t.type||(t.type=A(t.file)),t.lowLatency&&(t.lowLatency=t.lowLatency),t.type){switch(t.type){case"m3u8":case"vnd.apple.mpegurl":t.type="hls";break;case"m4a":t.type="aac";break;case"smil":t.type="rtmp"}return Object.keys(t).forEach((function(e){""===t[e]&&delete t[e]})),t}}};return t.initPlaylist=function(e,t){OvenPlayerConsole.log("PlaylistManager setPlaylist() ",e);var a=(i().isArray(e)?e:[e]).map((function(e){i().isArray(e.tracks)||delete e.tracks;var n=Object.assign({},{sources:[],tracks:[],title:""},e);n.sources!==Object(n.sources)||i().isArray(n.sources)||(n.sources=[o(n.sources)]),i().isArray(n.sources)&&0!==n.sources.length||(n.sources=[o(n)]),i().isArray(n.sources)&&0!==n.sources.length||(e.levels?n.sources=e.levels:n.sources=[o(e)]);for(var a=0;a0}))||[];return n.playlist=a,a},t.getPlaylist=function(){return OvenPlayerConsole.log("PlaylistManager getPlaylist() ",n.playlist),n.playlist},t.getCurrentPlayList=function(){return n.playlist[n.currentIndex]?n.playlist[n.currentIndex]:[]},t.getCurrentPlaylistIndex=function(){return n.currentIndex},t.setCurrentPlaylist=function(t){return n.playlist[t]&&(n.currentIndex=t,e.trigger(ge,n.currentIndex)),n.currentIndex},t.getCurrentSources=function(){return n.playlist[n.currentIndex]?(OvenPlayerConsole.log("PlaylistManager getCurrentSources() ",n.playlist[n.currentIndex].sources),n.playlist[n.currentIndex].sources):null},t.getCurrentAdTag=function(){if(n.playlist[n.currentIndex])return n.playlist[n.currentIndex].adTagUrl||""},t}(t),o=function(){var e=Ke(),t={},n={};OvenPlayerConsole.log("ProviderController loaded.");var r=function(e,n){t[e]||(OvenPlayerConsole.log("ProviderController _registerProvider() ",e),t[e]=n)},o={html5:function(){var e=wn;return r(ce,e),{name:ce,provider:e}},webrtc:function(){var e=Bn;return r(ue,e),{name:ue,provider:e}},dash:function(){var e=kn;return r(le,e),{name:le,provider:e}},hls:function(){var e=In;return r(fe,e),{name:fe,provider:e}}};return n.loadProviders=function(t){var n=e.findProviderNamesByPlaylist(t);return OvenPlayerConsole.log("ProviderController loadProviders() ",n),n?Promise.all(n.filter((function(e){return!!o[e]})).map((function(e){return o[e]()}))):Promise.reject(We.codes[101])},n.findByName=function(e){return OvenPlayerConsole.log("ProviderController findByName() ",e),t[e]},n.getProviderBySource=function(t){var r=e.findProviderNameBySource(t);return OvenPlayerConsole.log("ProviderController getProviderBySource() ",r),n.findByName(r)},n.isSameProvider=function(t,n){return OvenPlayerConsole.log("ProviderController isSameProvider() ",e.findProviderNameBySource(t),e.findProviderNameBySource(n)),e.findProviderNameBySource(t)===e.findProviderNameBySource(n)},n}(),s=Y(),c=function(e,t){var n={},r=ze(e),o="";return OvenPlayerConsole.log("MediaManager loaded. browser : ",t),n.createMedia=function(e,t){return n.empty(),i=t.isLoop(),a=t.isAutoStart(),(o=document.createElement("video")).setAttribute("preload","auto"),o.setAttribute("disableremoteplayback",""),o.setAttribute("webkit-playsinline","true"),o.setAttribute("playsinline","true"),i&&o.setAttribute("loop",""),a&&o.setAttribute("autoplay",""),r.append(o),o;var i,a},n.createAdContainer=function(){var e=document.createElement("div");return e.setAttribute("class","op-ads"),r.append(e),e},n.empty=function(){OvenPlayerConsole.log("MediaManager removeElement()"),r.removeChild(o),o=null},n.destroy=function(){r.removeChild(),r=null,o.srcObject=null,o=null},n}(e,s),u="",l="",f="",p=function(e){OvenPlayerConsole.log("runNextPlaylist");var r=e,o=!!n.getPlaylist()[r];l.setSourceIndex(0),l.setVolume(u.getVolume()),o?(n.setCurrentPlaylist(r),d()):t.trigger(he,null)},d=function(e){return o.loadProviders(n.getCurrentPlayList()).then((function(e){if(e.length<1)throw We.codes[101];u&&(u.destroy(),u=null),f&&(f.destroy(),f=null),f=function(e,t){var n={},r=[],o=-1,a=K(),A=!0;OvenPlayerConsole.log("Caption Manager >> ",t);var s=function(e,t){return e.data=t||[],e.name=e.label||e.name||e.language,e.id=function(e,t){var n,o=e.kind||"cc";return n=e.default||e.defaulttrack?"default":e.id||o+t,A&&(c(r.length||0),A=!1),n}(e,r.length),r.push(e),e.id},c=function(t){o=t,e.trigger(Pe,o)};if(e.getConfig().playlist&&e.getConfig().playlist.length>0){var u=e.getConfig().playlist[t];if(u&&u.tracks&&u.tracks.length>0)for(var l=function(t){var n=u.tracks[t];Ye(n.kind)&&!i().findWhere(n,{file:n.file})&&a.load(n,n.lang,(function(e){e&&e.length>0&&s(n,e)}),(function(t){var n=We.codes[305];n.error=t,e.trigger(me,n)}))},f=0;f-1&&r[o]){var a=i().filter(r[o].data,(function(e){return n>=e.startTime&&(!e.endTime||n)<=e.endTime}));a&&a.length>0&&e.trigger(De,a[0])}})),n.flushCaptionList=function(e){r=[],c(e)},n.getCaptionList=function(){return r||[]},n.getCurrentCaption=function(){return o},n.setCurrentCaption=function(e){if(!(e>-2&&e0&&s(t,e)}),(function(t){var n=errors[305];n.error=t,e.trigger(me,n)}))},n.removeCaption=function(e){return e>-1&&e=.25&&e<=4})).map((function(e){return Math.round(4*e)/4}))).indexOf(1)<0&&a.push(1),a.sort(),t.playbackRates=a,t.rtmpBufferTime=t.rtmpBufferTime>10?10:t.rtmpBufferTime,t.rtmpBufferTimeMax=t.rtmpBufferTimeMax>50?50:t.rtmpBufferTimeMax,t.playbackRates.indexOf(t.playbackRate)<0&&(t.playbackRate=1);var A=t.playlist;if(A)i().isArray(A.playlist)&&(t.feedData=A,t.playlist=A.playlist);else{var s=i().pick(t,["title","description","type","image","file","sources","tracks","host","application","stream","adTagUrl"]);t.playlist=[s]}return delete t.duration,t}(e);return{getConfig:function(){return n},getAdClient:function(){return n.adClient},setConfig:function(e,t){n[e]=t},getContainer:function(){return n.mediaContainer},getPlaybackRate:function(){return n.playbackRate},setPlaybackRate:function(e){return n.playbackRate=e,e},getQualityLabel:function(){return n.qualityLabel},setQualityLabel:function(e){n.qualityLabel=e},isCurrentProtocolOnly:function(){return n.currentProtocolOnly},getSourceIndex:function(){return n.sourceIndex},setSourceIndex:function(e){n.sourceIndex=e},setTimecodeMode:function(e){n.timecode!==e&&(n.timecode=e,t.trigger(Fe,e))},isTimecodeMode:function(){return n.timecode},getRtmpBufferTime:function(){return n.rtmpBufferTime},getRtmpBufferTimeMax:function(){return n.rtmpBufferTimeMax},setMute:function(e){n.mute=e},isMute:function(){return n.mute},getVolume:function(){return n.volume},setVolume:function(e){n.volume=e},isLoop:function(){return n.loop},isAutoStart:function(){return n.autoStart},isControls:function(){return n.controls},getPlaybackRates:function(){return n.playbackRates},getBrowser:function(){return n.browser},getSystemText:function(){return n.systemText},getLanguage:function(){return n.lang},getPlaylist:function(){return n.playlist},setPlaylist:function(e){return i().isArray(e)?n.playlist=e:n.playlist=[e],n.playlist}}}(r,t),OvenPlayerConsole.log("API : init()"),OvenPlayerConsole.log("API : init() config : ",l),We.codes=l.getSystemText().api.error,n.initPlaylist(l.getPlaylist(),l),OvenPlayerConsole.log("API : init() sources : ",n.getCurrentSources()),d(),setTimeout((function(){t.trigger(pe)}))},t.getProviderName=function(){return u?u.getName():null},t.getProvider=function(){return u},t.getMseInstance=function(){return u?u.getMse():null},t.getConfig=function(){return OvenPlayerConsole.log("API : getConfig()",l.getConfig()),l.getConfig()},t.getBrowser=function(){return l.getBrowser()},t.setTimecodeMode=function(e){OvenPlayerConsole.log("API : setTimecodeMode()",e),l.setTimecodeMode(e)},t.isTimecodeMode=function(){return OvenPlayerConsole.log("API : isTimecodeMode()"),l.isTimecodeMode()},t.getFramerate=function(){if(OvenPlayerConsole.log("API : getFramerate()"),u)return u.getFramerate()},t.seekFrame=function(e){return u?(OvenPlayerConsole.log("API : seekFrame()",e),u.seekFrame(e)):null},t.getDuration=function(){return u?(OvenPlayerConsole.log("API : getDuration()",u.getDuration()),u.getDuration()):null},t.getDvrWindow=function(){return u?(OvenPlayerConsole.log("API : getDvrWindow()",u.getDvrWindow()),u.getDvrWindow()):null},t.getPosition=function(){return u?(OvenPlayerConsole.log("API : getPosition()",u.getPosition()),u.getPosition()):null},t.getVolume=function(){return u?(OvenPlayerConsole.log("API : getVolume()",u.getVolume()),u.getVolume()):null},t.setVolume=function(e){if(!u)return null;OvenPlayerConsole.log("API : setVolume() "+e),u.setVolume(e)},t.setMute=function(e){return u?(OvenPlayerConsole.log("API : setMute() "+e),u.setMute(e)):null},t.getMute=function(){return u?(OvenPlayerConsole.log("API : getMute() "+u.getMute()),u.getMute()):null},t.load=function(e){return OvenPlayerConsole.log("API : load() ",e),e&&(l.setSourceIndex(0),u&&u.getQualityLevels().length>0&&u.setCurrentQuality(0),"sources"in e?l.setPlaylist(e):l.setPlaylist({sources:e}),n.initPlaylist(l.getPlaylist(),l)),d()},t.play=function(){if(!u)return null;OvenPlayerConsole.log("API : play() "),u.metaLoaded()||l.isAutoStart()?u.play():t.once(Me,(function(){u.play()}))},t.pause=function(){if(!u)return null;OvenPlayerConsole.log("API : pause() "),u.pause()},t.seek=function(e){if(!u)return null;OvenPlayerConsole.log("API : seek() "+e),u.seek(e)},t.setPlaybackRate=function(e){return u?(OvenPlayerConsole.log("API : setPlaybackRate() ",e),u.setPlaybackRate(l.setPlaybackRate(e))):null},t.getPlaybackRate=function(){return u?(OvenPlayerConsole.log("API : getPlaybackRate() ",u.getPlaybackRate()),u.getPlaybackRate()):null},t.getPlaylist=function(){return OvenPlayerConsole.log("API : getPlaylist() ",n.getPlaylist()),n.getPlaylist()},t.getCurrentPlaylist=function(){return OvenPlayerConsole.log("API : getCurrentPlaylist() ",n.getCurrentPlaylistIndex()),n.getCurrentPlaylistIndex()},t.setCurrentPlaylist=function(e){OvenPlayerConsole.log("API : setCurrentPlaylist() ",e),p(e)},t.getSources=function(){return u?(OvenPlayerConsole.log("API : getSources() ",u.getSources()),u.getSources()):null},t.getCurrentSource=function(){return u?(OvenPlayerConsole.log("API : getCurrentSource() ",u.getCurrentSource()),u.getCurrentSource()):null},t.setCurrentSource=function(e){if(!u)return null;OvenPlayerConsole.log("API : setCurrentSource() ",e);var n=u.getPosition();return l.setSourceIndex(e),d(n).then((function(){t.trigger(Oe,{currentSource:e})})),e},t.getQualityLevels=function(){return u?(OvenPlayerConsole.log("API : getQualityLevels() ",u.getQualityLevels()),u.getQualityLevels()):null},t.getCurrentQuality=function(){return u?(OvenPlayerConsole.log("API : getCurrentQuality() ",u.getCurrentQuality()),u.getCurrentQuality()):null},t.setCurrentQuality=function(e){return u?(OvenPlayerConsole.log("API : setCurrentQuality() ",e),u.setCurrentQuality(e)):null},t.getAudioTracks=function(){return u?(OvenPlayerConsole.log("API : getAudioTracks() ",u.getAudioTracks()),u.getAudioTracks()):null},t.getCurrentAudioTrack=function(){return u?(OvenPlayerConsole.log("API : getCurrentAudioTrack() ",u.getCurrentAudioTrack()),u.getCurrentAudioTrack()):null},t.setCurrentAudioTrack=function(e){return u?(OvenPlayerConsole.log("API : setCurrentAudioTrack() ",e),u.setCurrentAudioTrack(e)):null},t.isAutoQuality=function(){return u?(OvenPlayerConsole.log("API : isAutoQuality()"),u.isAutoQuality()):null},t.setAutoQuality=function(e){return u?(OvenPlayerConsole.log("API : setAutoQuality() ",e),u.setAutoQuality(e)):null},t.getCaptionList=function(){return f?(OvenPlayerConsole.log("API : getCaptionList() ",f.getCaptionList()),f.getCaptionList()):null},t.getCurrentCaption=function(){return f?(OvenPlayerConsole.log("API : getCurrentCaption() ",f.getCurrentCaption()),f.getCurrentCaption()):null},t.setCurrentCaption=function(e){if(!f)return null;OvenPlayerConsole.log("API : setCurrentCaption() ",e),f.setCurrentCaption(e)},t.addCaption=function(e){return f?(OvenPlayerConsole.log("API : addCaption() "),f.addCaption(e)):null},t.removeCaption=function(e){return f?(OvenPlayerConsole.log("API : removeCaption() ",e),f.removeCaption(e)):null},t.getBuffer=function(){if(!u)return null;OvenPlayerConsole.log("API : getBuffer() ",u.getBuffer()),u.getBuffer()},t.getState=function(){return u?(OvenPlayerConsole.log("API : getState() ",u.getState()),u.getState()):null},t.stop=function(){if(!u)return null;OvenPlayerConsole.log("API : stop() "),u.stop()},t.remove=function(){OvenPlayerConsole.log("API : remove() "),f&&(f.destroy(),f=null),u&&(u.destroy(),u=null),c&&(c.destroy(),c=null),t.trigger(de),t.off(),o=null,n=null,l=null,OvenPlayerConsole.log("API : remove() - currentProvider, providerController, playlistManager, playerConfig, api event destroed. "),Tn.removePlayer(t)},t.getMediaElement=function(){return u.getMediaElement()},t.getVersion=function(){return r},t},Tn=(sn=(An={}).playerList=[],An.create=function(e,t){window.OvenPlayerConsole&&0!==Object.keys(window.OvenPlayerConsole).length||(window.OvenPlayerConsole={},OvenPlayerConsole.log=function(){});var n=Ze(e),r=Sn(n);return r.init(t),sn.push(r),r},An.getPlayerList=function(){return sn},An.getPlayerByContainerId=function(e){for(var t=0;t
'+(t.isRoot?"":'<')+''+t.title+'
';return i().forEach(t.body,(function(e){n+=Rn(e,t.useCheck)})),n+="
"},Rn=function(e,t){return'
'+(t?'':"")+''+e.title+""+(e.hasNext?'>'+e.description+"":"")+"
"},Mn=function(e,t){return'
')+'
').concat(e.image?""):''," ").concat(e.duration?''.concat(s(e.duration),""):"","
")+'
'.concat(e.title,"
")+"
"},On={TextViewTemplate:function(e){return'
'+"

".concat(e,"

")+'
'},ViewTemplate:function(e,t){return'
")+'
'},HelpersTemplate:function(e,t){return'
'},BigButtonTemplate:function(e,t){return'
'+"".concat(t===ee?'':"")+"".concat(t===$?'':"")+"".concat(t===X?'':"")+"".concat(t===q?'':"")+"
"},ThumbnailTemplate:function(e,t){return'
'+"".concat(t.title?'
'.concat(t.title,"
"):"")+"
"},WaterMarkTemplate:function(e,t){return'
'+"".concat(t.waterMark.image?''):"")+"".concat(t.waterMark.text?''.concat(t.waterMark.text,""):"")+"
"},MessageBoxTemplate:function(e,t){return'
')+'
'+'
'.concat(t.message)+"".concat(t.description?'
'.concat(t.description,"
"):"")+"
"+"".concat(t.iconClass?'
'):"")+"
"},SpinnerTemplate:function(e){return'
'},ContextPanelTemplate:function(e){return'
'+''.concat(e.context," ").concat(r,"")+"
"},CaptionViewerTemplate:function(e){return'
      
'},ControlsTemplate:function(e,t){return'
'+'
'.concat(t?'':"","
")+'
'},VolumeButtonTemplate:function(e){return'
'},ProgressBarTemplate:function(e){return'
00:00
'},PlayButtonTemplate:function(e){return'
'},SettingButtonTemplate:function(e){return''},FrameButtonsTemplate:function(e){return'
'},TimeDisplayTemplate:function(e,t){return'
'+(t.duration===1/0?''+("webrtc"===t.type?t.isP2P?''.concat(e.controls.low_latency_p2p,""):''.concat(e.controls.low_latency_live,""):''.concat(e.controls.live,""))+"":'00:00 / 00:00')+"
"},FullScreenButtonTemplate:function(e){return''},PanelsTemplate:Ln,SpeedPanelTemplate:Ln,SourcePanelTemplate:Ln,QualityPanelTemplate:Ln,AudioTrackPanelTemplate:Ln,CaptionPanelTemplate:Ln,TimeDisplayPanelTemplate:Ln,PlaylistPanelTemplate:function(e,t){return'
'+'
'.concat(e.playlist,'
')+'
'}},Qn=function(e,t,n,r,o,a,A,s){var c,u=i().isElement(e)?ze(e):e,l={},f=null,p={};p.data=r;var d=function(e){var t=document.createElement("div");return t.innerHTML=e,c=ze(t.firstChild),t.firstChild};return n&&n.systemText&&(f=n.systemText.ui),s?u.replace(d(On[t+"Template"](f,r))):u.append(d(On[t+"Template"](f,r))),a&&a(c,p),Object.keys(o).forEach((function(e){var t=e.split(" "),n=t[0].replace(/ /gi,""),r=t[1].replace(/ /gi,""),i="";if(i="document"===r||"window"===r||"body"===r?ze(r):c.find(r)||(c.hasClass(r.replace(".",""))?c:null),!(n&&r&&i))return!1;var a=Object.keys(l).length++,A=function(t){return o[e](t,c,p)};l[a]={name:n,target:r,callback:A};var s=null;n.indexOf("touch")>-1&&(s={passive:!0});var u=i.get().length;if(u>1)for(var f=i.get(),d=0;d1)for(var o=n.get(),i=0;i-1?o=!1:(o=!0,e.find(".op-caption-text").text(""))}),r),t.on(De,(function(t){if(!o&&t&&t.text){var n=t.endTime-t.startTime;i&&clearTimeout(i),e.find(".op-caption-text").html(t.text),n&&(i=setTimeout((function(){e.find(".op-caption-text").text("")}),1e3*n))}}),r)}),(function(n){e.find(".op-caption-text").text(""),t.off(Pe,null,n),t.off(De,null,n)}))}(e,t),t.on(pe,(function(){u&&v(),l&&(r&&r.destroy(),r=function(e,t,n){var r=null,o=null;return Qn(e,"WaterMark",t.getConfig(),n,{},(function(e,n){r=e.find(".op-watermark"),o=e.find(".op-watermark-text");var a=t.getConfig().waterMark,A=a.position||"top-right",s=a.y||"5%",c=a.x||"2.8125%";r.css(A.split("-")[0],s),r.css(A.split("-")[1],c);var u=a.width||"auto",l=a.height||"auto";r.css("width",u),r.css("height",l);var f=a.opacity||.7;r.css("opacity",f),a.text&&a.font&&i().each(a.font,(function(e,t){o.css(t,e)}))}),(function(){}))}(e,t,t.getConfig())),o||(h($),o=!0)}),p),t.on(xe,(function(n){n.message&&(a&&a.destroy(),A&&A.destroy(),c=Dn(e,t,n.message,null,n.timer,n.iconClass,n.onClickCallback,!1),t.once(Re,(function(e){!e.mute&&c&&c.destroy()}),p))}),p),t.on(Ce,(function(e){e&&e.newstate&&(e.newstate===X&&A&&A.destroy(),e.newstate===ee||e.newstate===ie?(f=!1,A&&A.destroy(),a&&a.destroy(),n&&n.destroy(),d||s.show(!1)):e.newstate===q?(s.show(!1),h(e.newstate)):e.newstate===re||e.newstate===ne||"adLoading"===e.newstate?(f=!1,A&&A.destroy(),a&&a.destroy(),s.show(!0)):d||s.show(!1))}),p),t.on(Oe,(function(){u&&v()})),t.on(Qe,(function(e){if(e.currentQuality<0)return!1;e.isAuto?(d=!1,s.show(!1)):"request"===e.type?(g=e.currentQuality,d=!0,s.show(!0)):"render"===e.type&&g===e.currentQuality&&(d=!1,s.show(!1))}),p),t.on(me,(function(n){if(510===n.code&&(f=!0),101===n.code&&0===t.getPlaylist().length&&(f=!0),!f){var r="",o="";a&&a.destroy(),n&&n.code&&n.code>=100&&n.code<1e3?(r=n.message,100===n.code&&(o=n.error.toString())):r="Can not play due to unknown reasons.",OvenPlayerConsole.log("error occured : ",n),function(n,r,o,i,s,c){a&&a.destroy(),A&&A.destroy(),A=Dn(e,t,n,r,null,"op-warning",null,!0)}(r,o)}}),p),t.on(ve,(function(e){var n="Because the network connection is unstable, the following media source will be played.";t.getCurrentSource()+1===t.getQualityLevels().length&&(n="Network connection is unstable. Check the network connection."),OvenPlayerConsole.log(n)}),p),t.on(he,(function(){u&&v()}),p)}),(function(e){t.off(pe,null,e),t.off(Ce,null,e),t.off(xe,null,e),t.off(me,null,e),t.off(ve,null,e),t.off(he,null,e),t.off(ge,null,e)}))},Fn=[],Un=function(){var e={},t=function(){for(var e=0;e1,!0===t.getConfig().hidePlaylistIcon&&(u=!1);var m={"mouseleave .op-controls":function(e,t,n){e.preventDefault(),r.setMouseDown(!1),t.find(".op-volume-slider-container").removeClass("active")},"click .op-playlist-button":function(e,n,r){e.preventDefault(),function(e,t){var n=ze(t.getContainerElement()),r="",o=t.getPlaylist(),i=o.length,a=6,A=0,s=[];function c(e){var n,A,c=Math.ceil(i/a),u=t.getCurrentPlaylist();s=o.slice(e*a,e*a+a),r.find(".op-playlist-body-row").removeChild(),r.find(".op-arrow-left").removeClass("disable"),r.find(".op-arrow-right").removeClass("disable");for(var l=0;l576?a=6:n.width()<=576&&(a=1);var l={"click .btn-close":function(e,t,n){e.preventDefault(),n.destroy()},"click .op-arrow-left":function(e,t,n){e.preventDefault(),ze(e.target).hasClass("disable")||c(--A)},"click .op-arrow-right":function(e,t,n){e.preventDefault(),ze(e.target).hasClass("disable")||c(++A)}};Qn(e,"PlaylistPanel",t.getConfig(),o,l,(function(e,n){r=e,c(A=u()),t.on(Ee,(function(e){"xsmall"===e&&6===a?(a=1,c(A=u())):"small"!==e&&"medium"!==e&&"large"!==e||1!==a||(a=6,c(A=u()))}),n),t.on(ge,(function(e){c(A=u())}),n),e.get().addEventListener("click",(function(e){for(var n=e.target;n;){if(ze(n).hasClass("op-playlist-card"))return void t.setCurrentPlaylist(parseInt(ze(n).attr("data-index")));n=n.parentElement}}),!0)}),(function(e){t.off(Ee,null,e),t.off(ge,null,e)}))}(n,t)}};return Qn(e,"Controls",t.getConfig(),u,m,(function(e,u){function p(n,r){a&&a.destroy(),a=function(e,t,n,r){var o=ze(t.getContainerElement());t.getConfig().disableSeekUI&&e.addClass("op-progressbar-container-disabled");var i=0,a=!1,A=Un(),c="",u=0,l="",f="",p="",d="",g="",h="",v=0,m="",C="",y=t.getBrowser().mobile,b=t.getMediaElement(),w=!1,E=!1;function B(e){var t=l.width(),n=t*e;p.css("width",n+"px"),d.css("left",n+"px");var r=(t-v)*e;g.css("left",r+"px"),i=n}function x(e){var t=l.width()*e;d.css("width",(0===e?e:t-i)+"px")}function k(e){var t=l.width(),n=l.offset().left,r=e.pageX;e.touches&&(r=e.pageX||e.touches[0].clientX);var o=(r-n)/t;return o<0?0:o>1?1:o}function I(){return b.seekable.end(b.seekable.length-1)-b.seekable.start(0)}function S(e,n){if(A.size()>0||-1===e)return m.hide(),void C.hide();if(m.show(),C.show(),w&&!E){var r=t.getDvrWindow()*(1-e);t.isTimecodeMode()?m.text("- "+s(r)):m.text("- "+Math.round(r*t.getFramerate()))}else if(w&&E){var o=I()*(1-e);t.isTimecodeMode()?m.text("- "+s(o)):m.text("- "+Math.round(o*t.getFramerate()))}else{var i=t.getDuration()*e;t.isTimecodeMode()?m.text(s(i)):m.text(Math.round(i*t.getFramerate()))}var a=m.width(),u=l.width(),f=u*e,p=n.pageX-l.offset().left;n.touches&&(p=(n.pageX||n.touches[0].clientX)-l.offset().left);var d=function(e){return p0&&(n+=i),t.seek(n)}r&&r.type===fe&&r.duration===1/0&&(w=!0,t.getProviderName()===ce&&(E=!0));var L={"touchstart .op-progressbar":function(e){if(n)return!1;a=!0;var t=k(e);if(-1===t)return!1;B(t),x(0),T(t)},"touchmove .op-progressbar":function(e){if(a){var t=k(e);if(-1===t)return!1;B(t),x(0),T(t),S(t,e)}},"touchend .op-progressbar":function(e){a&&(a=!1),o.removeClass("op-progressbar-hover"),m.hide(),C.hide()},"mouseenter .op-progressbar":function(e,t,r){e.preventDefault(),y||(n||m.show(),o.addClass("op-progressbar-hover"))},"mouseleave .op-progressbar":function(e,t,n){e.preventDefault(),a=!1,o.removeClass("op-progressbar-hover"),m.hide(),C.hide(),x(0)},"mousedown .op-progressbar":function(e,t,r){if(e.preventDefault(),n||y)return!1;a=!0;var o=k(e);if(-1===o)return!1;B(o),x(0),T(o)},"mousemove .op-progressbar":function(e,t,r){if(e.preventDefault(),!a&&!n&&!y){var o=k(e);x(o),S(o,e)}if(a&&!y){var i=k(e);if(-1===i)return!1;B(i),x(0),T(i),S(i,e)}},"mouseup .op-progressbar":function(e,t,n){e.preventDefault(),a&&!y&&(a=!1,o.removeClass("op-progressbar-hover"))}};return t.getConfig().disableSeekUI&&(L={}),Qn(e,"ProgressBar",t.getConfig(),null,L,(function(e,r){l=e,f=e.find(".op-load-progress"),p=e.find(".op-play-progress"),d=e.find(".op-hover-progress"),g=e.find(".op-progressbar-knob-container"),h=e.find(".op-progressbar-knob"),v=h.width(),m=e.find(".op-progressbar-time"),C=e.find(".op-progressbar-preview"),n?t.on(Ie,(function(e){e&&e.duration&&e.position&&(B(e.position/e.duration),e.duration)}),r):(t.on(Te,(function(e){if(e&&e.duration&&e.position){u=e.duration;var n=e.position/e.duration;if(w&&!E&&(n=(t.getDvrWindow()-(e.duration-e.position))/t.getDvrWindow()),w&&E){var r=I();u=r,n=(r-(r-Math.min(r,e.position)))/r}B(n)}}),r),t.on(Se,(function(e){var t,n;e&&e.bufferPercent&&(t=e.bufferPercent/100,n=l.width()*t,f.css("width",n+"px"))}),r))}),(function(e){n?t.off(Ie,null,e):(t.off(Te,null,e),t.off(Se,null,e))}))}(e.find(".op-progressbar-container"),t,n,r)}function m(){i&&i.destroy(),i=function(e,t){var n=Un(),r={"click .op-setting-button":function(e,r,o){e.preventDefault();var i=r.closest(".op-controls-container");if(n.size()>0)n.clear();else{var a=function(e){var t={id:"panel-"+(new Date).getTime(),title:"Settings",body:[],isRoot:!0,panelType:""},n=e.getConfig();n&&n.systemText&&(Object.keys(jn).forEach((function(e){jn[e]=n.systemText.ui.setting[e]})),t.title=n.systemText.ui.setting.title);var r=e.getSources(),o=r&&r.length>0?r[e.getCurrentSource()]:null,i=e.getQualityLevels(),a=i&&i.length>0?i[e.getCurrentQuality()]:null,A=e.getAudioTracks(),s=A&&A.length>0?A[e.getCurrentAudioTrack()]:null,c=e.getCaptionList(),u=e.getCurrentCaption(),l=e.getFramerate();if(o){var f={title:jn.speed,value:e.getPlaybackRate()+jn.speedUnit,description:e.getPlaybackRate()+jn.speedUnit,panelType:"speed",hasNext:!0};t.body.push(f)}if(r&&r.length>1){var p={title:jn.source,value:o?o.label:"Default",description:o?o.label:"Default",panelType:"source",hasNext:!0};t.body.push(p)}if(i&&i.length>0){var d={title:jn.quality,value:a?a.label:"Default",description:a?a.label:"Default",panelType:"quality",hasNext:!0};t.body.push(d)}if(A&&A.length>0){var g={title:jn.audioTrack,value:s?s.label:"Default",description:s?s.label:"Default",panelType:"audioTrack",hasNext:!0};t.body.push(g)}if(c&&c.length>0){var h={title:jn.caption,value:c[u]?c[u].label:"OFF",description:c[u]?c[u].label:"OFF",panelType:"caption",hasNext:!0};t.body.push(h)}if(l>0){var v={title:jn.display,value:e.isTimecodeMode()?"Play time":"Framecode",description:e.isTimecodeMode()?"Play time":"Framecode",panelType:"display",hasNext:!0};t.body.push(v)}return t}(t);n.add(Wn(i,t,a))}}};return Qn(e,"SettingButton",t.getConfig(),null,r,(function(e,t){}),(function(e){}))}(e.find(".setting-holder"),t)}function C(){c||(c=function(e,t){var n=ze(t.getContainerElement()),r="",o="",i=!1,a=(t.getConfig(),t.getBrowser()),A="iOS"===a.os,s=(a.os,""),c=!1,u={onfullscreenchange:"fullscreenchange",onmozfullscreenchange:"mozfullscreenchange",onwebkitfullscreenchange:"webkitfullscreenchange",MSFullscreenChange:"MSFullscreenChange"};function l(){var e=!1,t=document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement;return t&&n.get()===t&&(e=!0),e}function f(){OvenPlayerConsole.log("FULLSCREEN STATE : ",l()),l()?(n.addClass("op-fullscreen"),i=!0,r.hide(),o.show()):(n.removeClass("op-fullscreen"),i=!1,r.show(),o.hide())}function p(){OvenPlayerConsole.log("afterFullScreenChangedCallback () "),f(),t.trigger(Be,i)}function d(){i?(n.removeClass("op-fullscreen"),i=!1,r.show(),o.hide()):(n.addClass("op-fullscreen"),i=!0,r.hide(),o.show()),t.trigger(Be,i)}function g(){var e;!i||A&&!l()?function(){var e,r="",o=n.get(),a=n.find("video")?n.find("video").get():o,s=null;if(A){if(a.length>1)for(var u=0;u1)for(var o=0;o9e15&&(n.duration=1/0);var r=t.getSources()[t.getCurrentSource()].sectionStart,o=t.getSources()[t.getCurrentSource()].sectionEnd;o&&(n.duration=o),r&&(n.duration=n.duration-r),function(n){A&&A.destroy(),A=function(e,t,n){var r="",o="",i="",a=t.getMediaElement(),A=!1,c=!1;function u(e){return s(e)}var l={"click .op-live-text":function(e,n,r){e.preventDefault(),t.seek(Number.MAX_SAFE_INTEGER);var o=t.getConfig();if(o.hlsConfig){var i=o.hlsConfig;"number"==typeof i.liveSyncDuration&&(t.getMseInstance().config.liveSyncDuration=i.liveSyncDuration),"number"==typeof i.liveMaxLatencyDuration&&(t.getMseInstance().config.liveMaxLatencyDuration=i.liveMaxLatencyDuration),"number"==typeof i.maxLiveSyncPlaybackRate&&(t.getMseInstance().config.maxLiveSyncPlaybackRate=i.maxLiveSyncPlaybackRate)}}};return Qn(e,"TimeDisplay",t.getConfig(),n,l,(function(e,s){var l=t.isTimecodeMode();r=e.find(".op-time-current"),o=e.find(".op-time-duration"),i=e.find(".op-live-badge"),e.find(".op-live-text"),n&&n.type===fe&&n.duration===1/0&&(A=!0,t.getProviderName()===ce&&(c=!0)),n.duration!==1/0?(l?o.text(u(n.duration)):o.text(Math.round(n.duration*t.getFramerate())+" ("+t.getFramerate()+"fps)"),t.on(Fe,(function(e){(l=e)?o.text(u(n.duration)):o.text(Math.round(n.duration*t.getFramerate())+" ("+t.getFramerate()+"fps)")}),s),t.on(Te,(function(e){l?r.text(u(e.position)):r.text(Math.round(e.position*t.getFramerate()))}),s)):A&&!c?t.on(Te,(function(e){e.duration-e.position>3?i.addClass("op-live-badge-delayed"):i.removeClass("op-live-badge-delayed")}),s):A&&c&&t.on(Te,(function(e){a.seekable.end(a.seekable.length-1)-a.seekable.start(0)-e.position>3?i.addClass("op-live-badge-delayed"):i.removeClass("op-live-badge-delayed")}),s)}),(function(e){t.off(Fe,null,e),t.off(Te,null,e)}))}(e.find(".op-left-controls"),t,n)}(n),C(),t.getFramerate&&t.getFramerate(),n.duration===1/0?(OvenPlayerConsole.log("[[[[LIVE MODE]]]]"),n.type===fe?p(!1,n):a&&a.destroy()):p(!1),l=!0}function b(){A&&A.destroy(),a&&a.destroy(),m(),C(),h.removeClass("linear-ad")}o=function(e,t){var n="",r="",o="",i="",a="",A="",s="",c={"click .op-play-button":function(e,n,r){e.preventDefault();var o=t.getState(),i=t.getPlaylist(),a=t.getCurrentPlaylist();o===X?t.play():o===ee||o===ie?t.pause():o===ne||o===re?t.stop():o===$||o===ae?t.play():o===te?t.setCurrentSource(t.getCurrentSource()):o===q&&i.length===a+1&&(t.seek(0),t.play())},"click .op-seek-button-back":function(e,n,r){var o=t.getConfig().seekControlInterval;o||(o=10);var i=t.getPosition()-o;i<0&&(i=0),t.seek(i)},"click .op-seek-button-forward":function(e,n,r){var o=t.getConfig().seekControlInterval;o||(o=10);var i=t.getPosition()+o;i>t.getDuration()&&(i=t.getDuration()),t.seek(i)}};return Qn(e,"PlayButton",t.getConfig(),null,c,(function(e,c){n=e.find(".op-play-button .op-play"),r=e.find(".op-play-button .op-pause"),o=e.find(".op-play-button .op-replay"),i=e.find(".op-seek-button-back"),a=e.find(".op-seek-button-forward"),A=e.find(".op-seek-back-text"),s=e.find(".op-seek-forward-text"),t.on(Ce,(function(e){var t;e&&e.newstate&&(t=e.newstate,n.hide(),r.hide(),o.hide(),t===ee||t===ie||t===ne||t===re?r.show():t===$||t===ae?n.show():t===q?o.show():n.show())}),c),t.getConfig().showSeekControl||(i.hide(),a.hide());var u=t.getConfig().seekControlInterval;u?(A.text(u),s.text(u)):(A.text(10),s.text(10))}),(function(e){t.off(Ce,null,e)}))}(e.find(".op-left-controls"),t),r=function(e,t){var n="",r="",o="",i="",a="",A="",s="",c=!1,u=0,l="iOS"===t.getBrowser().os||"Android"===t.getBrowser().os;function f(e){t.getMute()&&(e=0),function(e){a.hide(),A.hide(),s.hide(),e>=70?a.show():e<70&&e>0?A.show():0==e?s.show():a.show()}(e);var n=u*e/100;o.css("left",n+"px"),i.css("width",n+"px")}function p(e){var t=((e.pageX||e.touches[0].clientX)-r.offset().left)/70*100;return t<0&&(t=0),t>100&&(t=100),t}var d={"click .op-volume-button":function(e,n,r){e.preventDefault(),l||(0===t.getVolume()?(t.setMute(!1),t.setVolume(100)):t.setMute())},"mouseenter .op-volume-button":function(e,t,r){e.preventDefault(),l||n.addClass("active")},"mouseleave .op-volume-silder":function(e,t,n){e.preventDefault(),c=!1},"mousedown .op-volume-silder":function(e,n,r){e.preventDefault(),c=!0,t.setMute(!1),t.setVolume(p(e))},"mouseup .op-volume-silder":function(e,t,n){e.preventDefault(),c=!1},"mousemove .op-volume-silder":function(e,n,r){if(e.preventDefault(),!c)return!1;t.setVolume(p(e))},"touchstart .op-volume-button":function(e){l&&(t.getMute()?t.setMute(!1):t.setMute(!0))}},g=Qn(e,"VolumeButton",t.getConfig(),null,d,(function(e,c){n=e.find(".op-volume-slider-container"),t.getBrowser().mobile&&n.hide(),r=e.find(".op-volume-silder"),o=e.find(".op-volume-slider-handle"),i=e.find(".op-volume-slider-value"),a=e.find(".op-volume-max"),A=e.find(".op-volume-small"),s=e.find(".op-volume-mute"),u=64,o.css("left",u+"px"),f(t.getVolume()),t.on(pe,(function(){f(t.getVolume())}),c),t.on(Le,(function(e){f(e.volume)}),c),t.on(Re,(function(e){e.mute?f(0):f(t.getVolume())}),c)}),(function(e){t.off(pe,null,e),t.off(Le,null,e),t.off(Re,null,e)}));return g.setMouseDown=function(e){c=e},g}(e.find(".op-left-controls"),t);var w=t.getPlaylist(),E=t.getCurrentPlaylist();w&&w[E]&&w[E].adTagUrl||m(),C(),t.on(pe,(function(){e.show()}),u),t.on(Me,(function(e){n=e.duration,v=e,e.isP2P=f,y(e)}),u),t.on(Te,(function(e){(d||t&&t.getProviderName&&"rtmp"===t.getProviderName())&&!n&&v&&v.duration!==e.duration&&(v=e,y(e))}),u),t.on(Ee,(function(e){h.find(".op-setting-panel")&&h.find(".op-setting-panel").css("max-height",h.height()-h.find(".op-bottom-panel").height()+"px")}),u),t.on(Ue,(function(e){f=e}),u),t.on(be,(function(){if(!l){var n="";t.getSources().length>0&&t.getSources()[t.getCurrentSource()]&&t.getSources()[t.getCurrentSource()].type&&(n=t.getSources()[t.getCurrentSource()].type),y({isP2P:f,duration:t.getDuration(),type:n})}e.show()}),u),t.on(me,(function(t){e.show()}),u),t.on(ke,(function(e){e.isLinear?(h.addClass("linear-ad"),p(!0),A&&A.destroy(),i&&i.destroy(),g&&c&&c.destroy()):h.removeClass("linear-ad")}),u),t.on(Ae,(function(){b()}),u),t.on(se,(function(){b()}),u),t.on(Oe,(function(){b()}),u)}),(function(e){t.off(Me,null,e),t.off(Te,null,e),t.off(Ae,null,e),t.off(ke,null,e),t.off(Ue,null,e),t.off(se,null,e),t.off(Ee,null,e),t.off(Oe,null,e),A&&A.destroy(),o&&o.destroy(),a&&a.destroy(),c&&c.destroy(),r&&r.destroy()}))},Gn=n(5655),zn=n.n(Gn),_n=n(3379),Vn=n.n(_n),Hn=n(7795),Jn=n.n(Hn),Zn=n(569),Kn=n.n(Zn),Xn=n(3565),qn=n.n(Xn),$n=n(9216),er=n.n($n),tr=n(4589),nr=n.n(tr),rr=n(2021),or={};or.styleTagTransform=nr(),or.setAttributes=qn(),or.insert=Kn().bind(null,"head"),or.domAPI=Jn(),or.insertStyleElement=er(),Vn()(rr.Z,or),rr.Z&&rr.Z.locals&&rr.Z.locals;var ir,ar=function(e){var t,n="",r="",o="",i="",a=null,A="",s=X,c=!1,u=Un(),l="",f="",p=null,d={};function g(e,n){if(A&&(clearTimeout(A),A=null),e){if(u.size()>0)return!1;t.addClass("op-autohide")}else t.removeClass("op-autohide"),n&&(A=setTimeout((function(){if(u.size()>0)return!1;t.addClass("op-autohide")}),3e3))}function h(){var e=s;e===X||e===$||e===q?(e===q&&a.seek(0),a.play()):e===ee&&a.pause()}function v(e,t){var n,r=a.getDuration(),o=a.getPosition();n=t?Math.max(o-e,0):Math.min(o+e,r),a.seek(n)}function m(e){var t,n=a.getVolume();t=e?Math.min(n+5,100):Math.max(n-5,0),a.setVolume(t)}function C(){var e=t.width();e<576?(l="xsmall",t.addClass("xsmall"),e<490&&t.addClass("xxsmall")):e<768?(l="small",t.addClass("small")):e<992?(l="medium",t.addClass("medium")):(l="large",t.addClass("large"))}var y={"click .ovenplayer":function(e,t,n){if(a&&a.trigger(we,e),i)return e.preventDefault(),i.destroy(),i=null,!1;if(!ze(e.target).closest(".op-controls-container")&&!ze(e.target).closest(".op-setting-panel")){if(u.size()>0)return e.preventDefault(),u.clear(),!1;a.getDuration()===1/0||a.getBrowser().mobile||h()}},"dblclick .ovenplayer":function(e,t,n){if(a){var r=function(e){var t=e.target.getBoundingClientRect();return e.offsetX>=2/3*t.width?"right":e.offsetX>=1/3*t.width?"middle":"left"}(e),o=a.getPosition(),i=a.getConfig().doubleTapToSeek;if(i&&"left"==r){var A=Math.max(o-10,0);OvenPlayerConsole.log("Seeking to ".concat(A)),a.seek(A)}if(i&&"right"===r){var s=Math.min(o+10,a.getDuration());OvenPlayerConsole.log("Seeking to ".concat(s)),a.seek(s)}"middle"!==r&&i||(OvenPlayerConsole.log("Toggling fullscreen"),a.getConfig().expandFullScreenUI&&a.toggleFullScreen&&(ze(e.target).closest(".op-controls-container")||ze(e.target).closest(".op-setting-panel")||a.toggleFullScreen()))}},"touchstart .ovenplayer":function(e,t,n){s===ee||s===X||s===ne||s===ie&&"xsmall"===l?g(!1,!0):g(!1)},"mouseenter .ovenplayer":function(e,t,n){e.preventDefault(),s===ee||s===X||s===ne||s===ie&&"xsmall"===l?g(!1,!0):g(!1)},"mousemove .ovenplayer":function(e,t,n){e.preventDefault(),s===ee||s===X||s===ne||s===ie&&"xsmall"===l?g(!1,!0):g(!1)},"mouseleave .ovenplayer":function(e,t,n){e.preventDefault(),(s===ee||s===X||s===ne||s===ie&&"xsmall"===l)&&g(!0)},"keydown .ovenplayer":function(e,t,n){var r=a.getFramerate();switch(e.keyCode){case 16:e.preventDefault(),c=!0;break;case 32:e.preventDefault(),h();break;case 37:e.preventDefault(),a.getConfig().disableSeekUI||(c&&r?a.seekFrame(-1):v(5,!0));break;case 39:e.preventDefault(),a.getConfig().disableSeekUI||(c&&r?a.seekFrame(1):v(5,!1));break;case 38:e.preventDefault(),m(!0);break;case 40:e.preventDefault(),m(!1)}},"keyup .ovenplayer":function(e,t,n){16===e.keyCode&&(e.preventDefault(),c=!1)},"contextmenu .ovenplayer":function(e,n,r){if(e.stopPropagation(),!ze(e.currentTarget).find("object"))return e.preventDefault(),o=e.pageX,A=e.pageY,i&&(i.destroy(),i=null),i=function(e,t,n){var r=ze(t.getContainerElement()),o={"click .op-context-item":function(e,t,n){e.preventDefault(),window.open("https://github.com/AirenSoft/OvenPlayer","_blank")}};return Qn(e,"ContextPanel",t.getConfig(),n,o,(function(e,t){var o=e.width(),i=e.height(),a=Math.min(n.pageX-r.offset().left,r.width()-o),A=Math.min(n.pageY-r.offset().top,r.height()-i);e.css("left",a+"px"),e.css("top",A+"px")}),(function(){}))}(t,a,{pageX:o,pageY:A}),!1;var o,A}};return(d=Qn(e,"View",null,e.id,y,(function(e,r){t=e,n=r,C(),f=l,p=new(zn())(t.get(),(function(){t.removeClass("large"),t.removeClass("medium"),t.removeClass("small"),t.removeClass("xsmall"),t.removeClass("xxsmall"),C(),l!==f&&(f=l,a&&a.trigger(Ee,f))}))}),(function(){p&&(p.detach(),p=null),o&&(o.destroy(),o=null),r&&(r.destroy(),r=null)}),!0)).getMediaElementContainer=function(){return t.find(".op-media-element-container").get()},d.setApi=function(e){(a=e).getContainerElement=function(){return t.get()},a.getContainerId=function(){return t.get().id},a.on(pe,(function(n){r||(r=Yn(t.find(".op-ui"),e)),i||t.addClass("op-no-controls")})),a.on(me,(function(e){if(a){var t=a.getSources()||[];r&&t.length}})),a.on(de,(function(e){n.destroy()})),a.on(be,(function(n){!r&&i&&(r=Yn(t.find(".op-ui"),e))})),a.on(Ce,(function(e){e&&e.newstate&&(s=e.newstate,e.newstate===ee||e.newstate===ie&&"xsmall"===l?g(!1,!0):g(!1))}));var i=a.getConfig()&&a.getConfig().controls;o=Pn(t.find(".op-ui"),e),r=Yn(t.find(".op-ui"),e);var A=a.getConfig().aspectRatio;if(A&&2===A.split(":").length){var c=1*A.split(":")[0],u=1*A.split(":")[1]/c*100;t.find(".op-ratio").css("padding-bottom",u+"%")}a.showControls=function(e){e?(t.removeClass("op-no-controls"),g(!1,!0)):t.addClass("op-no-controls")}},d},Ar=(ir={},Object.assign(ir,Tn),ir.create=function(e,t){var n=Ze(e),r=ar(n),o=Tn.create(r.getMediaElementContainer(),t);return r.setApi(o),OvenPlayerConsole.log("[OvenPlayer] v.0.10.32"),o},ir)},1001:function(){!function(e){"use strict";if("window"in e&&"document"in e){document.querySelectorAll||(document.querySelectorAll=function(e){var t,n=document.createElement("style"),r=[];for(document.documentElement.firstChild.appendChild(n),document._qsa=[],n.styleSheet.cssText=e+"{x-qsa:expression(document._qsa && document._qsa.push(this))}",window.scrollBy(0,0),n.parentNode.removeChild(n);document._qsa.length;)(t=document._qsa.shift()).style.removeAttribute("x-qsa"),r.push(t);return document._qsa=null,r}),document.querySelector||(document.querySelector=function(e){var t=document.querySelectorAll(e);return t.length?t[0]:null}),document.getElementsByClassName||(document.getElementsByClassName=function(e){return e=String(e).replace(/^|\s+/g,"."),document.querySelectorAll(e)}),e.Node=e.Node||function(){throw TypeError("Illegal constructor")},[["ELEMENT_NODE",1],["ATTRIBUTE_NODE",2],["TEXT_NODE",3],["CDATA_SECTION_NODE",4],["ENTITY_REFERENCE_NODE",5],["ENTITY_NODE",6],["PROCESSING_INSTRUCTION_NODE",7],["COMMENT_NODE",8],["DOCUMENT_NODE",9],["DOCUMENT_TYPE_NODE",10],["DOCUMENT_FRAGMENT_NODE",11],["NOTATION_NODE",12]].forEach((function(t){t[0]in e.Node||(e.Node[t[0]]=t[1])})),e.DOMException=e.DOMException||function(){throw TypeError("Illegal constructor")},[["INDEX_SIZE_ERR",1],["DOMSTRING_SIZE_ERR",2],["HIERARCHY_REQUEST_ERR",3],["WRONG_DOCUMENT_ERR",4],["INVALID_CHARACTER_ERR",5],["NO_DATA_ALLOWED_ERR",6],["NO_MODIFICATION_ALLOWED_ERR",7],["NOT_FOUND_ERR",8],["NOT_SUPPORTED_ERR",9],["INUSE_ATTRIBUTE_ERR",10],["INVALID_STATE_ERR",11],["SYNTAX_ERR",12],["INVALID_MODIFICATION_ERR",13],["NAMESPACE_ERR",14],["INVALID_ACCESS_ERR",15]].forEach((function(t){t[0]in e.DOMException||(e.DOMException[t[0]]=t[1])})),function(){function t(e,t,n){if("function"==typeof t){"DOMContentLoaded"===e&&(e="load");var r=this,o=function(e){e._timeStamp=Date.now(),e._currentTarget=r,t.call(this,e),e._currentTarget=null};this["_"+e+t]=o,this.attachEvent("on"+e,o)}}function n(e,t,n){if("function"==typeof t){"DOMContentLoaded"===e&&(e="load");var r=this["_"+e+t];r&&(this.detachEvent("on"+e,r),this["_"+e+t]=null)}}"Element"in e&&!Element.prototype.addEventListener&&Object.defineProperty&&(Event.CAPTURING_PHASE=1,Event.AT_TARGET=2,Event.BUBBLING_PHASE=3,Object.defineProperties(Event.prototype,{CAPTURING_PHASE:{get:function(){return 1}},AT_TARGET:{get:function(){return 2}},BUBBLING_PHASE:{get:function(){return 3}},target:{get:function(){return this.srcElement}},currentTarget:{get:function(){return this._currentTarget}},eventPhase:{get:function(){return this.srcElement===this.currentTarget?Event.AT_TARGET:Event.BUBBLING_PHASE}},bubbles:{get:function(){switch(this.type){case"click":case"dblclick":case"mousedown":case"mouseup":case"mouseover":case"mousemove":case"mouseout":case"mousewheel":case"keydown":case"keypress":case"keyup":case"resize":case"scroll":case"select":case"change":case"submit":case"reset":return!0}return!1}},cancelable:{get:function(){switch(this.type){case"click":case"dblclick":case"mousedown":case"mouseup":case"mouseover":case"mouseout":case"mousewheel":case"keydown":case"keypress":case"keyup":case"submit":return!0}return!1}},timeStamp:{get:function(){return this._timeStamp}},stopPropagation:{value:function(){this.cancelBubble=!0}},preventDefault:{value:function(){this.returnValue=!1}},defaultPrevented:{get:function(){return!1===this.returnValue}}}),[Window,HTMLDocument,Element].forEach((function(e){e.prototype.addEventListener=t,e.prototype.removeEventListener=n})))}(),function(){function t(e,t){t=t||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(e,t.bubbles,t.cancelable,t.detail),n}"CustomEvent"in e&&"function"==typeof e.CustomEvent||(t.prototype=e.Event.prototype,e.CustomEvent=t)}(),window.addEvent=function(e,t,n){e.addEventListener?e.addEventListener(t,n,!1):e.attachEvent&&(e["e"+t+n]=n,e[t+n]=function(){var r=window.event;r.currentTarget=e,r.preventDefault=function(){r.returnValue=!1},r.stopPropagation=function(){r.cancelBubble=!0},r.target=r.srcElement,r.timeStamp=Date.now(),e["e"+t+n].call(this,r)},e.attachEvent("on"+t,e[t+n]))},window.removeEvent=function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent&&(e.detachEvent("on"+t,e[t+n]),e[t+n]=null,e["e"+t+n]=null)},function(){function t(e,t){function n(e){return e.length?e.split(/\s+/g):[]}function r(e,t){var r=n(t),o=r.indexOf(e);return-1!==o&&r.splice(o,1),r.join(" ")}if(Object.defineProperties(this,{length:{get:function(){return n(e[t]).length}},item:{value:function(r){var o=n(e[t]);return 0<=r&&r=0&&t.item(n)!==this;);return n>-1})),window.Element&&!Element.prototype.closest&&(Element.prototype.closest=function(e){var t,n=(this.document||this.ownerDocument).querySelectorAll(e),r=this;do{for(t=n.length;--t>=0&&n.item(t)!==r;);}while(t<0&&(r=r.parentElement));return r});var t={prepend:function(){var e=[].slice.call(arguments);e=o(e),this.insertBefore(e,this.firstChild)},append:function(){var e=[].slice.call(arguments);e=o(e),this.appendChild(e)}};r(e.Document||e.HTMLDocument,t),r(e.DocumentFragment,t),r(e.Element,t);var n={before:function(){var e=[].slice.call(arguments),t=this.parentNode;if(t){for(var n=this.previousSibling;-1!==e.indexOf(n);)n=n.previousSibling;var r=o(e);t.insertBefore(r,n?n.nextSibling:t.firstChild)}},after:function(){var e=[].slice.call(arguments),t=this.parentNode;if(t){for(var n=this.nextSibling;-1!==e.indexOf(n);)n=n.nextSibling;var r=o(e);t.insertBefore(r,n)}},replaceWith:function(){var e=[].slice.call(arguments),t=this.parentNode;if(t){for(var n=this.nextSibling;-1!==e.indexOf(n);)n=n.nextSibling;var r=o(e);this.parentNode===t?t.replaceChild(r,this):t.insertBefore(r,n)}},remove:function(){this.parentNode&&this.parentNode.removeChild(this)}};r(e.DocumentType,n),r(e.Element,n),r(e.CharacterData,n)}function r(e,t){e&&Object.keys(t).forEach((function(n){if(!(n in e)&&!(n in e.prototype))try{Object.defineProperty(e.prototype,n,Object.getOwnPropertyDescriptor(t,n))}catch(r){e[n]=t[n]}}))}function o(e){var t=null;return e=e.map((function(e){return e instanceof Node?e:document.createTextNode(e)})),1===e.length?t=e[0]:(t=document.createDocumentFragment(),e.forEach((function(e){t.appendChild(e)}))),t}}(self)},5655:function(e,t){var n,r;r=this,void 0===(n=function(){return r.returnExportsGlobal=function(){"use strict";var e=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||function(e){return window.setTimeout(e,20)};function t(){var e,t;this.q=[],this.add=function(e){this.q.push(e)},this.call=function(){for(e=0,t=this.q.length;e
',n.appendChild(n.resizeSensor),"static"==function(e,t){return e.currentStyle?e.currentStyle[t]:window.getComputedStyle?window.getComputedStyle(e,null).getPropertyValue(t):e.style[t]}(n,"position")&&(n.style.position="relative");var a=n.resizeSensor.childNodes[0],A=a.childNodes[0],s=n.resizeSensor.childNodes[1],c=function(){A.style.width="100000px",A.style.height="100000px",a.scrollLeft=1e5,a.scrollTop=1e5,s.scrollLeft=1e5,s.scrollTop=1e5};c();var u,l,f,p,d=!1;e((function t(){n.resizedAttached&&(d&&(n.resizedAttached.call(),d=!1),e(t))}));var g=function(){(f=n.offsetWidth)==u&&(p=n.offsetHeight)==l||(d=!0,u=f,l=p),c()},h=function(e,t,n){e.attachEvent?e.attachEvent("on"+t,n):e.addEventListener(t,n)};h(a,"scroll",g),h(s,"scroll",g)}var r=function(e,t){var r=Object.prototype.toString.call(e),o=this._isCollectionTyped="[object Array]"===r||"[object NodeList]"===r||"[object HTMLCollection]"===r||"undefined"!=typeof jQuery&&e instanceof window.jQuery||"undefined"!=typeof Elements&&e instanceof window.Elements;if(this._element=e,o)for(var i=0,a=e.length;i=0&&n<=b}}function Z(e){return function(t){return null==t?void 0:t[e]}}var K=Z("byteLength"),X=J(K),q=/\[object ((I|Ui)nt(8|16|32)|Float(32|64)|Uint8Clamped|Big(I|Ui)nt64)Array\]/,$=l?function(e){return h?h(e)&&!j(e):X(e)&&q.test(c.call(e))}:H(!1),ee=Z("length");function te(e,t){t=function(e){for(var t={},n=e.length,r=0;r":">",'"':""","'":"'","`":"`"},_e=Ge(ze),Ve=Ge(be(ze)),He=oe.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g},Je=/(.)^/,Ze={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},Ke=/\\|'|\r|\n|\u2028|\u2029/g;function Xe(e){return"\\"+Ze[e]}var qe=/^\s*(\w|\$)+\s*$/,$e=0;function et(e,t,n,r,o){if(!(r instanceof t))return e.apply(n,o);var i=Ie(e.prototype),a=e.apply(i,o);return E(a)?a:i}var tt=w((function(e,t){var n=tt.placeholder;return function r(){for(var o=0,i=t.length,a=Array(i),A=0;A1)ot(A,t-1,n,r),o=r.length;else for(var s=0,c=A.length;s0&&(n=t.apply(this,arguments)),e<=1&&(t=null),n}}var ut=tt(ct,2);function lt(e,t,n){t=Ne(t,n);for(var r,o=ne(e),i=0,a=o.length;i0?0:o-1;i>=0&&i0?a=i>=0?i:Math.max(i+A,a):A=i>=0?Math.min(i+1,A):i+A+1;else if(n&&i&&A)return r[i=n(r,o)]===o?i:-1;if(o!=o)return(i=t(s.call(r,a,A),V))>=0?i+a:-1;for(i=e>0?a:A-1;i>=0&&i0?0:a-1;for(o||(r=t[i?i[A]:A],A+=e);A>=0&&A=3;return t(e,Pe(n,o,4),r,i)}}var Et=wt(1),Bt=wt(-1);function xt(e,t,n){var r=[];return t=Ne(t,n),yt(e,(function(e,n,o){t(e,n,o)&&r.push(e)})),r}function kt(e,t,n){t=Ne(t,n);for(var r=!rt(e)&&ne(e),o=(r||e).length,i=0;i=0}var Tt=w((function(e,t,n){var r,o;return P(t)?o=t:(t=Le(t),r=t.slice(0,-1),t=t[t.length-1]),bt(e,(function(e){var i=o;if(!i){if(r&&r.length&&(e=Re(e,r)),null==e)return;i=e[t]}return null==i?i:i.apply(e,n)}))}));function Lt(e,t){return bt(e,De(t))}function Rt(e,t,n){var r,o,i=-1/0,A=-1/0;if(null==t||"number"==typeof t&&"object"!=a(e[0])&&null!=e)for(var s=0,c=(e=rt(e)?e:ye(e)).length;si&&(i=r);else t=Ne(t,n),yt(e,(function(e,n,r){((o=t(e,n,r))>A||o===-1/0&&i===-1/0)&&(i=e,A=o)}));return i}function Mt(e,t,n){if(null==t||n)return rt(e)||(e=ye(e)),e[je(e.length-1)];var r=rt(e)?Se(e):ye(e),o=ee(r);t=Math.max(Math.min(t,o),0);for(var i=o-1,a=0;a1&&(r=Pe(r,t[1])),t=se(e)):(r=Nt,t=ot(t,!1,!1),e=Object(e));for(var o=0,i=t.length;o1&&(n=t[1])):(t=bt(ot(t,!1,!1),String),r=function(e,n){return!St(t,n)}),Wt(e,r,n)}));function Yt(e,t,n){return s.call(e,0,Math.max(0,e.length-(null==t||n?1:t)))}function Gt(e,t,n){return null==e||e.length<1?null==t||n?void 0:[]:null==t||n?e[0]:Yt(e,e.length-t)}function zt(e,t,n){return s.call(e,null==t||n?1:t)}var _t=w((function(e,t){return t=ot(t,!0,!0),xt(e,(function(e){return!St(t,e)}))})),Vt=w((function(e,t){return _t(e,t)}));function Ht(e,t,n,r){x(t)||(r=n,n=t,t=!1),null!=n&&(n=Ne(n,r));for(var o=[],i=[],a=0,A=ee(e);at?(r&&(clearTimeout(r),r=null),A=c,a=e.apply(o,i),r||(o=i=null)):r||!1===n.trailing||(r=setTimeout(s,u)),a};return c.cancel=function(){clearTimeout(r),A=0,r=o=i=null},c},debounce:function(e,t,n){var r,o,i,a,A,s=function s(){var c=Ye()-o;t>c?r=setTimeout(s,t-c):(r=null,n||(a=e.apply(A,i)),r||(i=A=null))},c=w((function(c){return A=this,i=c,o=Ye(),r||(r=setTimeout(s,t),n&&(a=e.apply(A,i))),a}));return c.cancel=function(){clearTimeout(r),r=i=A=null},c},wrap:function(e,t){return tt(t,e)},negate:st,compose:function(){var e=arguments,t=e.length-1;return function(){for(var n=t,r=e[t].apply(this,arguments);n--;)r=e[n].call(this,r);return r}},after:function(e,t){return function(){if(--e<1)return t.apply(this,arguments)}},before:ct,once:ut,findKey:lt,findIndex:pt,findLastIndex:dt,sortedIndex:gt,indexOf:vt,lastIndexOf:mt,find:Ct,detect:Ct,findWhere:function(e,t){return Ct(e,Qe(t))},each:yt,forEach:yt,map:bt,collect:bt,reduce:Et,foldl:Et,inject:Et,reduceRight:Bt,foldr:Bt,filter:xt,select:xt,reject:function(e,t,n){return xt(e,st(Ne(t)),n)},every:kt,all:kt,some:It,any:It,contains:St,includes:St,include:St,invoke:Tt,pluck:Lt,where:function(e,t){return xt(e,Qe(t))},max:Rt,min:function(e,t,n){var r,o,i=1/0,A=1/0;if(null==t||"number"==typeof t&&"object"!=a(e[0])&&null!=e)for(var s=0,c=(e=rt(e)?e:ye(e)).length;sr||void 0===n)return 1;if(n>8&255]},z=function(e){return[255&e,e>>8&255,e>>16&255,e>>24&255]},_=function(e){return e[3]<<24|e[2]<<16|e[1]<<8|e[0]},V=function(e){return W(e,23,4)},H=function(e){return W(e,52,8)},J=function(e,t){C(e.prototype,t,{get:function(){return k(this)[t]}})},Z=function(e,t,n,r){var o=d(n),i=k(e);if(o+t>i.byteLength)throw F(T);var a=k(i.buffer).bytes,A=o+i.byteOffset,s=b(a,A,A+t);return r?s:N(s)},K=function(e,t,n,r,o,i){var a=d(n),A=k(e);if(a+t>A.byteLength)throw F(T);for(var s=k(A.buffer).bytes,c=a+A.byteOffset,u=r(+o),l=0;lee;)(q=$[ee++])in R||s(R,q,L[q]);M.constructor=R}v&&h(Q)!==D&&v(Q,D);var te=new O(new R(2)),ne=o(Q.setInt8);te.setInt8(0,2147483648),te.setInt8(1,2147483649),!te.getInt8(0)&&te.getInt8(1)||c(Q,{setInt8:function(e,t){ne(this,e,t<<24>>24)},setUint8:function(e,t){ne(this,e,t<<24>>24)}},{unsafe:!0})}else M=(R=function(e){l(this,M);var t=d(e);I(this,{bytes:U(P(t),0),byteLength:t}),i||(this.byteLength=t)}).prototype,Q=(O=function(e,t,n){l(this,Q),l(e,M);var r=k(e).byteLength,o=f(t);if(o<0||o>r)throw F("Wrong offset");if(o+(n=void 0===n?r-o:p(n))>r)throw F("Wrong length");I(this,{buffer:e,byteLength:n,byteOffset:o}),i||(this.buffer=e,this.byteLength=n,this.byteOffset=o)}).prototype,i&&(J(R,"byteLength"),J(O,"buffer"),J(O,"byteLength"),J(O,"byteOffset")),c(Q,{getInt8:function(e){return Z(this,1,e)[0]<<24>>24},getUint8:function(e){return Z(this,1,e)[0]},getInt16:function(e){var t=Z(this,2,e,arguments.length>1?arguments[1]:void 0);return(t[1]<<8|t[0])<<16>>16},getUint16:function(e){var t=Z(this,2,e,arguments.length>1?arguments[1]:void 0);return t[1]<<8|t[0]},getInt32:function(e){return _(Z(this,4,e,arguments.length>1?arguments[1]:void 0))},getUint32:function(e){return _(Z(this,4,e,arguments.length>1?arguments[1]:void 0))>>>0},getFloat32:function(e){return j(Z(this,4,e,arguments.length>1?arguments[1]:void 0),23)},getFloat64:function(e){return j(Z(this,8,e,arguments.length>1?arguments[1]:void 0),52)},setInt8:function(e,t){K(this,1,e,Y,t)},setUint8:function(e,t){K(this,1,e,Y,t)},setInt16:function(e,t){K(this,2,e,G,t,arguments.length>2?arguments[2]:void 0)},setUint16:function(e,t){K(this,2,e,G,t,arguments.length>2?arguments[2]:void 0)},setInt32:function(e,t){K(this,4,e,z,t,arguments.length>2?arguments[2]:void 0)},setUint32:function(e,t){K(this,4,e,z,t,arguments.length>2?arguments[2]:void 0)},setFloat32:function(e,t){K(this,4,e,V,t,arguments.length>2?arguments[2]:void 0)},setFloat64:function(e,t){K(this,8,e,H,t,arguments.length>2?arguments[2]:void 0)}});w(R,S),w(O,"DataView"),e.exports={ArrayBuffer:R,DataView:O}},1048:function(e,t,n){"use strict";var r=n(7908),o=n(1400),i=n(6244),a=Math.min;e.exports=[].copyWithin||function(e,t){var n=r(this),A=i(n),s=o(e,A),c=o(t,A),u=arguments.length>2?arguments[2]:void 0,l=a((void 0===u?A:o(u,A))-c,A-s),f=1;for(c0;)c in n?n[s]=n[c]:delete n[s],s+=f,c+=f;return n}},1285:function(e,t,n){"use strict";var r=n(7908),o=n(1400),i=n(6244);e.exports=function(e){for(var t=r(this),n=i(t),a=arguments.length,A=o(a>1?arguments[1]:void 0,n),s=a>2?arguments[2]:void 0,c=void 0===s?n:o(s,n);c>A;)t[A++]=e;return t}},8533:function(e,t,n){"use strict";var r=n(2092).forEach,o=n(2133)("forEach");e.exports=o?[].forEach:function(e){return r(this,e,arguments.length>1?arguments[1]:void 0)}},7745:function(e,t,n){var r=n(6244);e.exports=function(e,t){for(var n=0,o=r(t),i=new e(o);o>n;)i[n]=t[n++];return i}},8457:function(e,t,n){"use strict";var r=n(7854),o=n(9974),i=n(6916),a=n(7908),A=n(3411),s=n(7659),c=n(4411),u=n(6244),l=n(6135),f=n(8554),p=n(1246),d=r.Array;e.exports=function(e){var t=a(e),n=c(this),r=arguments.length,g=r>1?arguments[1]:void 0,h=void 0!==g;h&&(g=o(g,r>2?arguments[2]:void 0));var v,m,C,y,b,w,E=p(t),B=0;if(!E||this==d&&s(E))for(v=u(t),m=n?new this(v):d(v);v>B;B++)w=h?g(t[B],B):t[B],l(m,B,w);else for(b=(y=f(t,E)).next,m=n?new this:[];!(C=i(b,y)).done;B++)w=h?A(y,g,[C.value,B],!0):C.value,l(m,B,w);return m.length=B,m}},1318:function(e,t,n){var r=n(5656),o=n(1400),i=n(6244),a=function(e){return function(t,n,a){var A,s=r(t),c=i(s),u=o(a,c);if(e&&n!=n){for(;c>u;)if((A=s[u++])!=A)return!0}else for(;c>u;u++)if((e||u in s)&&s[u]===n)return e||u||0;return!e&&-1}};e.exports={includes:a(!0),indexOf:a(!1)}},2092:function(e,t,n){var r=n(9974),o=n(1702),i=n(8361),a=n(7908),A=n(6244),s=n(5417),c=o([].push),u=function(e){var t=1==e,n=2==e,o=3==e,u=4==e,l=6==e,f=7==e,p=5==e||l;return function(d,g,h,v){for(var m,C,y=a(d),b=i(y),w=r(g,h),E=A(b),B=0,x=v||s,k=t?x(d,E):n||f?x(d,0):void 0;E>B;B++)if((p||B in b)&&(C=w(m=b[B],B,y),e))if(t)k[B]=C;else if(C)switch(e){case 3:return!0;case 5:return m;case 6:return B;case 2:c(k,m)}else switch(e){case 4:return!1;case 7:c(k,m)}return l?-1:o||u?u:k}};e.exports={forEach:u(0),map:u(1),filter:u(2),some:u(3),every:u(4),find:u(5),findIndex:u(6),filterReject:u(7)}},6583:function(e,t,n){"use strict";var r=n(2104),o=n(5656),i=n(9303),a=n(6244),A=n(2133),s=Math.min,c=[].lastIndexOf,u=!!c&&1/[1].lastIndexOf(1,-0)<0,l=A("lastIndexOf"),f=u||!l;e.exports=f?function(e){if(u)return r(c,this,arguments)||0;var t=o(this),n=a(t),A=n-1;for(arguments.length>1&&(A=s(A,i(arguments[1]))),A<0&&(A=n+A);A>=0;A--)if(A in t&&t[A]===e)return A||0;return-1}:c},1194:function(e,t,n){var r=n(7293),o=n(5112),i=n(7392),a=o("species");e.exports=function(e){return i>=51||!r((function(){var t=[];return(t.constructor={})[a]=function(){return{foo:1}},1!==t[e](Boolean).foo}))}},2133:function(e,t,n){"use strict";var r=n(7293);e.exports=function(e,t){var n=[][e];return!!n&&r((function(){n.call(null,t||function(){throw 1},1)}))}},3671:function(e,t,n){var r=n(7854),o=n(9662),i=n(7908),a=n(8361),A=n(6244),s=r.TypeError,c=function(e){return function(t,n,r,c){o(n);var u=i(t),l=a(u),f=A(u),p=e?f-1:0,d=e?-1:1;if(r<2)for(;;){if(p in l){c=l[p],p+=d;break}if(p+=d,e?p<0:f<=p)throw s("Reduce of empty array with no initial value")}for(;e?p>=0:f>p;p+=d)p in l&&(c=n(c,l[p],p,u));return c}};e.exports={left:c(!1),right:c(!0)}},1589:function(e,t,n){var r=n(7854),o=n(1400),i=n(6244),a=n(6135),A=r.Array,s=Math.max;e.exports=function(e,t,n){for(var r=i(e),c=o(t,r),u=o(void 0===n?r:n,r),l=A(s(u-c,0)),f=0;c0;)e[r]=e[--r];r!==i++&&(e[r]=n)}return e},A=function(e,t,n,r){for(var o=t.length,i=n.length,a=0,A=0;a1?arguments[1]:void 0);t=t?t.next:n.first;)for(r(t.value,t.key,this);t&&t.removed;)t=t.previous},has:function(e){return!!m(this,e)}}),i(p,n?{get:function(e){var t=m(this,e);return t&&t.value},set:function(e,t){return v(this,0===e?0:e,t)}}:{add:function(e){return v(this,e=0===e?0:e,e)}}),l&&r(p,"size",{get:function(){return h(this).size}}),u},setStrong:function(e,t,n){var r=t+" Iterator",o=g(t),i=g(r);c(e,t,(function(e,t){d(this,{type:r,target:e,state:o(e),kind:t,last:void 0})}),(function(){for(var e=i(this),t=e.kind,n=e.last;n&&n.removed;)n=n.previous;return e.target&&(e.last=n=n?n.next:e.state.first)?"keys"==t?{value:n.key,done:!1}:"values"==t?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(e.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),u(t)}}},9320:function(e,t,n){"use strict";var r=n(1702),o=n(2248),i=n(2423).getWeakData,a=n(9670),A=n(111),s=n(5787),c=n(408),u=n(2092),l=n(2597),f=n(9909),p=f.set,d=f.getterFor,g=u.find,h=u.findIndex,v=r([].splice),m=0,C=function(e){return e.frozen||(e.frozen=new y)},y=function(){this.entries=[]},b=function(e,t){return g(e.entries,(function(e){return e[0]===t}))};y.prototype={get:function(e){var t=b(this,e);if(t)return t[1]},has:function(e){return!!b(this,e)},set:function(e,t){var n=b(this,e);n?n[1]=t:this.entries.push([e,t])},delete:function(e){var t=h(this.entries,(function(t){return t[0]===e}));return~t&&v(this.entries,t,1),!!~t}},e.exports={getConstructor:function(e,t,n,r){var u=e((function(e,o){s(e,f),p(e,{type:t,id:m++,frozen:void 0}),null!=o&&c(o,e[r],{that:e,AS_ENTRIES:n})})),f=u.prototype,g=d(t),h=function(e,t,n){var r=g(e),o=i(a(t),!0);return!0===o?C(r).set(t,n):o[r.id]=n,e};return o(f,{delete:function(e){var t=g(this);if(!A(e))return!1;var n=i(e);return!0===n?C(t).delete(e):n&&l(n,t.id)&&delete n[t.id]},has:function(e){var t=g(this);if(!A(e))return!1;var n=i(e);return!0===n?C(t).has(e):n&&l(n,t.id)}}),o(f,n?{get:function(e){var t=g(this);if(A(e)){var n=i(e);return!0===n?C(t).get(e):n?n[t.id]:void 0}},set:function(e,t){return h(this,e,t)}}:{add:function(e){return h(this,e,!0)}}),u}}},7710:function(e,t,n){"use strict";var r=n(2109),o=n(7854),i=n(1702),a=n(4705),A=n(1320),s=n(2423),c=n(408),u=n(5787),l=n(614),f=n(111),p=n(7293),d=n(7072),g=n(8003),h=n(9587);e.exports=function(e,t,n){var v=-1!==e.indexOf("Map"),m=-1!==e.indexOf("Weak"),C=v?"set":"add",y=o[e],b=y&&y.prototype,w=y,E={},B=function(e){var t=i(b[e]);A(b,e,"add"==e?function(e){return t(this,0===e?0:e),this}:"delete"==e?function(e){return!(m&&!f(e))&&t(this,0===e?0:e)}:"get"==e?function(e){return m&&!f(e)?void 0:t(this,0===e?0:e)}:"has"==e?function(e){return!(m&&!f(e))&&t(this,0===e?0:e)}:function(e,n){return t(this,0===e?0:e,n),this})};if(a(e,!l(y)||!(m||b.forEach&&!p((function(){(new y).entries().next()})))))w=n.getConstructor(t,e,v,C),s.enable();else if(a(e,!0)){var x=new w,k=x[C](m?{}:-0,1)!=x,I=p((function(){x.has(1)})),S=d((function(e){new y(e)})),T=!m&&p((function(){for(var e=new y,t=5;t--;)e[C](t,t);return!e.has(-0)}));S||((w=t((function(e,t){u(e,b);var n=h(new y,e,w);return null!=t&&c(t,n[C],{that:n,AS_ENTRIES:v}),n}))).prototype=b,b.constructor=w),(I||T)&&(B("delete"),B("has"),v&&B("get")),(T||k)&&B(C),m&&b.clear&&delete b.clear}return E[e]=w,r({global:!0,forced:w!=y},E),g(w,e),m||n.setStrong(w,e,v),w}},9920:function(e,t,n){var r=n(2597),o=n(3887),i=n(1236),a=n(3070);e.exports=function(e,t,n){for(var A=o(t),s=a.f,c=i.f,u=0;u"+s+""}},4994:function(e,t,n){"use strict";var r=n(3383).IteratorPrototype,o=n(30),i=n(9114),a=n(8003),A=n(7497),s=function(){return this};e.exports=function(e,t,n,c){var u=t+" Iterator";return e.prototype=o(r,{next:i(+!c,n)}),a(e,u,!1,!0),A[u]=s,e}},8880:function(e,t,n){var r=n(9781),o=n(3070),i=n(9114);e.exports=r?function(e,t,n){return o.f(e,t,i(1,n))}:function(e,t,n){return e[t]=n,e}},9114:function(e){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},6135:function(e,t,n){"use strict";var r=n(4948),o=n(3070),i=n(9114);e.exports=function(e,t,n){var a=r(t);a in e?o.f(e,a,i(0,n)):e[a]=n}},5573:function(e,t,n){"use strict";var r=n(7854),o=n(1702),i=n(7293),a=n(6650).start,A=r.RangeError,s=Math.abs,c=Date.prototype,u=c.toISOString,l=o(c.getTime),f=o(c.getUTCDate),p=o(c.getUTCFullYear),d=o(c.getUTCHours),g=o(c.getUTCMilliseconds),h=o(c.getUTCMinutes),v=o(c.getUTCMonth),m=o(c.getUTCSeconds);e.exports=i((function(){return"0385-07-25T07:06:39.999Z"!=u.call(new Date(-50000000000001))}))||!i((function(){u.call(new Date(NaN))}))?function(){if(!isFinite(l(this)))throw A("Invalid time value");var e=this,t=p(e),n=g(e),r=t<0?"-":t>9999?"+":"";return r+a(s(t),r?6:4,0)+"-"+a(v(e)+1,2,0)+"-"+a(f(e),2,0)+"T"+a(d(e),2,0)+":"+a(h(e),2,0)+":"+a(m(e),2,0)+"."+a(n,3,0)+"Z"}:u},8709:function(e,t,n){"use strict";var r=n(7854),o=n(9670),i=n(2140),a=r.TypeError;e.exports=function(e){if(o(this),"string"===e||"default"===e)e="string";else if("number"!==e)throw a("Incorrect hint");return i(this,e)}},654:function(e,t,n){"use strict";var r=n(2109),o=n(6916),i=n(1913),a=n(6530),A=n(614),s=n(4994),c=n(9518),u=n(7674),l=n(8003),f=n(8880),p=n(1320),d=n(5112),g=n(7497),h=n(3383),v=a.PROPER,m=a.CONFIGURABLE,C=h.IteratorPrototype,y=h.BUGGY_SAFARI_ITERATORS,b=d("iterator"),w="keys",E="values",B="entries",x=function(){return this};e.exports=function(e,t,n,a,d,h,k){s(n,t,a);var I,S,T,L=function(e){if(e===d&&D)return D;if(!y&&e in O)return O[e];switch(e){case w:case E:case B:return function(){return new n(this,e)}}return function(){return new n(this)}},R=t+" Iterator",M=!1,O=e.prototype,Q=O[b]||O["@@iterator"]||d&&O[d],D=!y&&Q||L(d),P="Array"==t&&O.entries||Q;if(P&&(I=c(P.call(new e)))!==Object.prototype&&I.next&&(i||c(I)===C||(u?u(I,C):A(I[b])||p(I,b,x)),l(I,R,!0,!0),i&&(g[R]=x)),v&&d==E&&Q&&Q.name!==E&&(!i&&m?f(O,"name",E):(M=!0,D=function(){return o(Q,this)})),d)if(S={values:L(E),keys:h?D:L(w),entries:L(B)},k)for(T in S)(y||M||!(T in O))&&p(O,T,S[T]);else r({target:t,proto:!0,forced:y||M},S);return i&&!k||O[b]===D||p(O,b,D,{name:d}),g[t]=D,S}},7235:function(e,t,n){var r=n(857),o=n(2597),i=n(6061),a=n(3070).f;e.exports=function(e){var t=r.Symbol||(r.Symbol={});o(t,e)||a(t,e,{value:i.f(e)})}},9781:function(e,t,n){var r=n(7293);e.exports=!r((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},317:function(e,t,n){var r=n(7854),o=n(111),i=r.document,a=o(i)&&o(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},3678:function(e){e.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},8324:function(e){e.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},8509:function(e,t,n){var r=n(317)("span").classList,o=r&&r.constructor&&r.constructor.prototype;e.exports=o===Object.prototype?void 0:o},8886:function(e,t,n){var r=n(8113).match(/firefox\/(\d+)/i);e.exports=!!r&&+r[1]},7871:function(e){e.exports="object"==typeof window},256:function(e,t,n){var r=n(8113);e.exports=/MSIE|Trident/.test(r)},1528:function(e,t,n){var r=n(8113),o=n(7854);e.exports=/ipad|iphone|ipod/i.test(r)&&void 0!==o.Pebble},8334:function(e,t,n){var r=n(8113);e.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(r)},5268:function(e,t,n){var r=n(4326),o=n(7854);e.exports="process"==r(o.process)},1036:function(e,t,n){var r=n(8113);e.exports=/web0s(?!.*chrome)/i.test(r)},8113:function(e,t,n){var r=n(5005);e.exports=r("navigator","userAgent")||""},7392:function(e,t,n){var r,o,i=n(7854),a=n(8113),A=i.process,s=i.Deno,c=A&&A.versions||s&&s.version,u=c&&c.v8;u&&(o=(r=u.split("."))[0]>0&&r[0]<4?1:+(r[0]+r[1])),!o&&a&&(!(r=a.match(/Edge\/(\d+)/))||r[1]>=74)&&(r=a.match(/Chrome\/(\d+)/))&&(o=+r[1]),e.exports=o},8008:function(e,t,n){var r=n(8113).match(/AppleWebKit\/(\d+)\./);e.exports=!!r&&+r[1]},748:function(e){e.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},2914:function(e,t,n){var r=n(7293),o=n(9114);e.exports=!r((function(){var e=Error("a");return!("stack"in e)||(Object.defineProperty(e,"stack",o(1,7)),7!==e.stack)}))},7762:function(e,t,n){"use strict";var r=n(9781),o=n(7293),i=n(9670),a=n(30),A=n(6277),s=Error.prototype.toString,c=o((function(){if(r){var e=a(Object.defineProperty({},"name",{get:function(){return this===e}}));if("true"!==s.call(e))return!0}return"2: 1"!==s.call({message:1,name:2})||"Error"!==s.call({})}));e.exports=c?function(){var e=i(this),t=A(e.name,"Error"),n=A(e.message);return t?n?t+": "+n:t:n}:s},2109:function(e,t,n){var r=n(7854),o=n(1236).f,i=n(8880),a=n(1320),A=n(3505),s=n(9920),c=n(4705);e.exports=function(e,t){var n,u,l,f,p,d=e.target,g=e.global,h=e.stat;if(n=g?r:h?r[d]||A(d,{}):(r[d]||{}).prototype)for(u in t){if(f=t[u],l=e.noTargetGet?(p=o(n,u))&&p.value:n[u],!c(g?u:d+(h?".":"#")+u,e.forced)&&void 0!==l){if(typeof f==typeof l)continue;s(f,l)}(e.sham||l&&l.sham)&&i(f,"sham",!0),a(n,u,f,e)}}},7293:function(e){e.exports=function(e){try{return!!e()}catch(e){return!0}}},7007:function(e,t,n){"use strict";n(4916);var r=n(1702),o=n(1320),i=n(2261),a=n(7293),A=n(5112),s=n(8880),c=A("species"),u=RegExp.prototype;e.exports=function(e,t,n,l){var f=A(e),p=!a((function(){var t={};return t[f]=function(){return 7},7!=""[e](t)})),d=p&&!a((function(){var t=!1,n=/a/;return"split"===e&&((n={}).constructor={},n.constructor[c]=function(){return n},n.flags="",n[f]=/./[f]),n.exec=function(){return t=!0,null},n[f](""),!t}));if(!p||!d||n){var g=r(/./[f]),h=t(f,""[e],(function(e,t,n,o,a){var A=r(e),s=t.exec;return s===i||s===u.exec?p&&!a?{done:!0,value:g(t,n,o)}:{done:!0,value:A(n,t,o)}:{done:!1}}));o(String.prototype,e,h[0]),o(u,f,h[1])}l&&s(u[f],"sham",!0)}},6790:function(e,t,n){"use strict";var r=n(7854),o=n(3157),i=n(6244),a=n(9974),A=r.TypeError,s=function(e,t,n,r,c,u,l,f){for(var p,d,g=c,h=0,v=!!l&&a(l,f);h0&&o(p))d=i(p),g=s(e,t,p,d,g,u-1)-1;else{if(g>=9007199254740991)throw A("Exceed the acceptable array length");e[g]=p}g++}h++}return g};e.exports=s},6677:function(e,t,n){var r=n(7293);e.exports=!r((function(){return Object.isExtensible(Object.preventExtensions({}))}))},2104:function(e,t,n){var r=n(4374),o=Function.prototype,i=o.apply,a=o.call;e.exports="object"==typeof Reflect&&Reflect.apply||(r?a.bind(i):function(){return a.apply(i,arguments)})},9974:function(e,t,n){var r=n(1702),o=n(9662),i=n(4374),a=r(r.bind);e.exports=function(e,t){return o(e),void 0===t?e:i?a(e,t):function(){return e.apply(t,arguments)}}},4374:function(e,t,n){var r=n(7293);e.exports=!r((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))},7065:function(e,t,n){"use strict";var r=n(7854),o=n(1702),i=n(9662),a=n(111),A=n(2597),s=n(206),c=n(4374),u=r.Function,l=o([].concat),f=o([].join),p={},d=function(e,t,n){if(!A(p,t)){for(var r=[],o=0;o]*>)/g,u=/\$([$&'`]|\d{1,2})/g;e.exports=function(e,t,n,r,l,f){var p=n+e.length,d=r.length,g=u;return void 0!==l&&(l=o(l),g=c),A(f,g,(function(o,A){var c;switch(a(A,0)){case"$":return"$";case"&":return e;case"`":return s(t,0,n);case"'":return s(t,p);case"<":c=l[s(A,1,-1)];break;default:var u=+A;if(0===u)return o;if(u>d){var f=i(u/10);return 0===f?o:f<=d?void 0===r[f-1]?a(A,1):r[f-1]+a(A,1):o}c=r[u-1]}return void 0===c?"":c}))}},7854:function(e,t,n){var r=function(e){return e&&e.Math==Math&&e};e.exports=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof n.g&&n.g)||function(){return this}()||Function("return this")()},2597:function(e,t,n){var r=n(1702),o=n(7908),i=r({}.hasOwnProperty);e.exports=Object.hasOwn||function(e,t){return i(o(e),t)}},3501:function(e){e.exports={}},842:function(e,t,n){var r=n(7854);e.exports=function(e,t){var n=r.console;n&&n.error&&(1==arguments.length?n.error(e):n.error(e,t))}},490:function(e,t,n){var r=n(5005);e.exports=r("document","documentElement")},4664:function(e,t,n){var r=n(9781),o=n(7293),i=n(317);e.exports=!r&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},1179:function(e,t,n){var r=n(7854).Array,o=Math.abs,i=Math.pow,a=Math.floor,A=Math.log,s=Math.LN2;e.exports={pack:function(e,t,n){var c,u,l,f=r(n),p=8*n-t-1,d=(1<>1,h=23===t?i(2,-24)-i(2,-77):0,v=e<0||0===e&&1/e<0?1:0,m=0;for((e=o(e))!=e||e===1/0?(u=e!=e?1:0,c=d):(c=a(A(e)/s),e*(l=i(2,-c))<1&&(c--,l*=2),(e+=c+g>=1?h/l:h*i(2,1-g))*l>=2&&(c++,l/=2),c+g>=d?(u=0,c=d):c+g>=1?(u=(e*l-1)*i(2,t),c+=g):(u=e*i(2,g-1)*i(2,t),c=0));t>=8;)f[m++]=255&u,u/=256,t-=8;for(c=c<0;)f[m++]=255&c,c/=256,p-=8;return f[--m]|=128*v,f},unpack:function(e,t){var n,r=e.length,o=8*r-t-1,a=(1<>1,s=o-7,c=r-1,u=e[c--],l=127&u;for(u>>=7;s>0;)l=256*l+e[c--],s-=8;for(n=l&(1<<-s)-1,l>>=-s,s+=t;s>0;)n=256*n+e[c--],s-=8;if(0===l)l=1-A;else{if(l===a)return n?NaN:u?-1/0:1/0;n+=i(2,t),l-=A}return(u?-1:1)*n*i(2,l-t)}}},8361:function(e,t,n){var r=n(7854),o=n(1702),i=n(7293),a=n(4326),A=r.Object,s=o("".split);e.exports=i((function(){return!A("z").propertyIsEnumerable(0)}))?function(e){return"String"==a(e)?s(e,""):A(e)}:A},9587:function(e,t,n){var r=n(614),o=n(111),i=n(7674);e.exports=function(e,t,n){var a,A;return i&&r(a=t.constructor)&&a!==n&&o(A=a.prototype)&&A!==n.prototype&&i(e,A),e}},2788:function(e,t,n){var r=n(1702),o=n(614),i=n(5465),a=r(Function.toString);o(i.inspectSource)||(i.inspectSource=function(e){return a(e)}),e.exports=i.inspectSource},8340:function(e,t,n){var r=n(111),o=n(8880);e.exports=function(e,t){r(t)&&"cause"in t&&o(e,"cause",t.cause)}},2423:function(e,t,n){var r=n(2109),o=n(1702),i=n(3501),a=n(111),A=n(2597),s=n(3070).f,c=n(8006),u=n(1156),l=n(2050),f=n(9711),p=n(6677),d=!1,g=f("meta"),h=0,v=function(e){s(e,g,{value:{objectID:"O"+h++,weakData:{}}})},m=e.exports={enable:function(){m.enable=function(){},d=!0;var e=c.f,t=o([].splice),n={};n[g]=1,e(n).length&&(c.f=function(n){for(var r=e(n),o=0,i=r.length;om;m++)if((y=T(e[m]))&&u(h,y))return y;return new g(!1)}r=l(e,v)}for(b=r.next;!(w=i(b,r)).done;){try{y=T(w.value)}catch(e){p(r,"throw",e)}if("object"==typeof y&&y&&u(h,y))return y}return new g(!1)}},9212:function(e,t,n){var r=n(6916),o=n(9670),i=n(8173);e.exports=function(e,t,n){var a,A;o(e);try{if(!(a=i(e,"return"))){if("throw"===t)throw n;return n}a=r(a,e)}catch(e){A=!0,a=e}if("throw"===t)throw n;if(A)throw a;return o(a),n}},3383:function(e,t,n){"use strict";var r,o,i,a=n(7293),A=n(614),s=n(30),c=n(9518),u=n(1320),l=n(5112),f=n(1913),p=l("iterator"),d=!1;[].keys&&("next"in(i=[].keys())?(o=c(c(i)))!==Object.prototype&&(r=o):d=!0),null==r||a((function(){var e={};return r[p].call(e)!==e}))?r={}:f&&(r=s(r)),A(r[p])||u(r,p,(function(){return this})),e.exports={IteratorPrototype:r,BUGGY_SAFARI_ITERATORS:d}},7497:function(e){e.exports={}},6244:function(e,t,n){var r=n(7466);e.exports=function(e){return r(e.length)}},6736:function(e){var t=Math.expm1,n=Math.exp;e.exports=!t||t(10)>22025.465794806718||t(10)<22025.465794806718||-2e-17!=t(-2e-17)?function(e){return 0==(e=+e)?e:e>-1e-6&&e<1e-6?e+e*e/2:n(e)-1}:t},6130:function(e,t,n){var r=n(4310),o=Math.abs,i=Math.pow,a=i(2,-52),A=i(2,-23),s=i(2,127)*(2-A),c=i(2,-126);e.exports=Math.fround||function(e){var t,n,i=o(e),u=r(e);return is||n!=n?u*(1/0):u*n}},202:function(e){var t=Math.log,n=Math.LOG10E;e.exports=Math.log10||function(e){return t(e)*n}},6513:function(e){var t=Math.log;e.exports=Math.log1p||function(e){return(e=+e)>-1e-8&&e<1e-8?e-e*e/2:t(1+e)}},4310:function(e){e.exports=Math.sign||function(e){return 0==(e=+e)||e!=e?e:e<0?-1:1}},5948:function(e,t,n){var r,o,i,a,A,s,c,u,l=n(7854),f=n(9974),p=n(1236).f,d=n(261).set,g=n(8334),h=n(1528),v=n(1036),m=n(5268),C=l.MutationObserver||l.WebKitMutationObserver,y=l.document,b=l.process,w=l.Promise,E=p(l,"queueMicrotask"),B=E&&E.value;B||(r=function(){var e,t;for(m&&(e=b.domain)&&e.exit();o;){t=o.fn,o=o.next;try{t()}catch(e){throw o?a():i=void 0,e}}i=void 0,e&&e.enter()},g||m||v||!C||!y?!h&&w&&w.resolve?((c=w.resolve(void 0)).constructor=w,u=f(c.then,c),a=function(){u(r)}):m?a=function(){b.nextTick(r)}:(d=f(d,l),a=function(){d(r)}):(A=!0,s=y.createTextNode(""),new C(r).observe(s,{characterData:!0}),a=function(){s.data=A=!A})),e.exports=B||function(e){var t={fn:e,next:void 0};i&&(i.next=t),o||(o=t,a()),i=t}},3366:function(e,t,n){var r=n(7854);e.exports=r.Promise},133:function(e,t,n){var r=n(7392),o=n(7293);e.exports=!!Object.getOwnPropertySymbols&&!o((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&r&&r<41}))},590:function(e,t,n){var r=n(7293),o=n(5112),i=n(1913),a=o("iterator");e.exports=!r((function(){var e=new URL("b?a=1&b=2&c=3","http://a"),t=e.searchParams,n="";return e.pathname="c%20d",t.forEach((function(e,r){t.delete("b"),n+=r+e})),i&&!e.toJSON||!t.sort||"http://a/c%20d?a=1&c=3"!==e.href||"3"!==t.get("c")||"a=1"!==String(new URLSearchParams("?a=1"))||!t[a]||"a"!==new URL("https://a@b").username||"b"!==new URLSearchParams(new URLSearchParams("a=b")).get("a")||"xn--e1aybc"!==new URL("http://тест").host||"#%D0%B1"!==new URL("http://a#б").hash||"a1c3"!==n||"x"!==new URL("http://x",void 0).host}))},8536:function(e,t,n){var r=n(7854),o=n(614),i=n(2788),a=r.WeakMap;e.exports=o(a)&&/native code/.test(i(a))},8523:function(e,t,n){"use strict";var r=n(9662),o=function(e){var t,n;this.promise=new e((function(e,r){if(void 0!==t||void 0!==n)throw TypeError("Bad Promise constructor");t=e,n=r})),this.resolve=r(t),this.reject=r(n)};e.exports.f=function(e){return new o(e)}},6277:function(e,t,n){var r=n(1340);e.exports=function(e,t){return void 0===e?arguments.length<2?"":t:r(e)}},3929:function(e,t,n){var r=n(7854),o=n(7850),i=r.TypeError;e.exports=function(e){if(o(e))throw i("The method doesn't accept regular expressions");return e}},7023:function(e,t,n){var r=n(7854).isFinite;e.exports=Number.isFinite||function(e){return"number"==typeof e&&r(e)}},2814:function(e,t,n){var r=n(7854),o=n(7293),i=n(1702),a=n(1340),A=n(3111).trim,s=n(1361),c=i("".charAt),u=r.parseFloat,l=r.Symbol,f=l&&l.iterator,p=1/u(s+"-0")!=-1/0||f&&!o((function(){u(Object(f))}));e.exports=p?function(e){var t=A(a(e)),n=u(t);return 0===n&&"-"==c(t,0)?-0:n}:u},3009:function(e,t,n){var r=n(7854),o=n(7293),i=n(1702),a=n(1340),A=n(3111).trim,s=n(1361),c=r.parseInt,u=r.Symbol,l=u&&u.iterator,f=/^[+-]?0x/i,p=i(f.exec),d=8!==c(s+"08")||22!==c(s+"0x16")||l&&!o((function(){c(Object(l))}));e.exports=d?function(e,t){var n=A(a(e));return c(n,t>>>0||(p(f,n)?16:10))}:c},1574:function(e,t,n){"use strict";var r=n(9781),o=n(1702),i=n(6916),a=n(7293),A=n(1956),s=n(5181),c=n(5296),u=n(7908),l=n(8361),f=Object.assign,p=Object.defineProperty,d=o([].concat);e.exports=!f||a((function(){if(r&&1!==f({b:1},f(p({},"a",{enumerable:!0,get:function(){p(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var e={},t={},n=Symbol(),o="abcdefghijklmnopqrst";return e[n]=7,o.split("").forEach((function(e){t[e]=e})),7!=f({},e)[n]||A(f({},t)).join("")!=o}))?function(e,t){for(var n=u(e),o=arguments.length,a=1,f=s.f,p=c.f;o>a;)for(var g,h=l(arguments[a++]),v=f?d(A(h),f(h)):A(h),m=v.length,C=0;m>C;)g=v[C++],r&&!i(p,h,g)||(n[g]=h[g]);return n}:f},30:function(e,t,n){var r,o=n(9670),i=n(6048),a=n(748),A=n(3501),s=n(490),c=n(317),u=n(6200)("IE_PROTO"),l=function(){},f=function(e){return"