Free javascript Hosting


redgalaxy-player-2-16-2-min.js

Uploaded on Nov 15 2021 22:12 by konrad.gawryluk

/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
/******/ function webpackJsonpCallback(data) {
/******/ var chunkIds = data[0];
/******/ var moreModules = data[1];
/******/
/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(Object.prototype.hasOwnProperty.call(installedChunks, chunkId) && installedChunks[chunkId]) {
/******/ resolves.push(installedChunks[chunkId][0]);
/******/ }
/******/ installedChunks[chunkId] = 0;
/******/ }
/******/ for(moduleId in moreModules) {
/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // object to store loaded and loading chunks
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
/******/ // Promise = chunk loading, 0 = chunk loaded
/******/ var installedChunks = {
/******/ 1: 0
/******/ };
/******/
/******/
/******/
/******/ // script path function
/******/ function jsonpScriptSrc(chunkId) {
/******/ return __webpack_require__.p + "js/" + ({"3":"renderer/hlsjs"}[chunkId]||chunkId) + ".module.js"
/******/ }
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
/******/ var promises = [];
/******/
/******/
/******/ // JSONP chunk loading for javascript
/******/
/******/ var installedChunkData = installedChunks[chunkId];
/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
/******/ // a Promise means "currently loading".
/******/ if(installedChunkData) {
/******/ promises.push(installedChunkData[2]);
/******/ } else {
/******/ // setup Promise in chunk cache
/******/ var promise = new Promise(function(resolve, reject) {
/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
/******/ });
/******/ promises.push(installedChunkData[2] = promise);
/******/
/******/ // start chunk loading
/******/ var script = document.createElement('script');
/******/ var onScriptComplete;
/******/
/******/ script.charset = 'utf-8';
/******/ script.timeout = 120;
/******/ if (__webpack_require__.nc) {
/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
/******/ script.src = jsonpScriptSrc(chunkId);
/******/
/******/ // create error before stack unwound to get useful stacktrace later
/******/ var error = new Error();
/******/ onScriptComplete = function (event) {
/******/ // avoid mem leaks in IE.
/******/ script.onerror = script.onload = null;
/******/ clearTimeout(timeout);
/******/ var chunk = installedChunks[chunkId];
/******/ if(chunk !== 0) {
/******/ if(chunk) {
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
/******/ var realSrc = event && event.target && event.target.src;
/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
/******/ error.name = 'ChunkLoadError';
/******/ error.type = errorType;
/******/ error.request = realSrc;
/******/ chunk[1](error);
/******/ }
/******/ installedChunks[chunkId] = undefined;
/******/ }
/******/ };
/******/ var timeout = setTimeout(function(){
/******/ onScriptComplete({ type: 'timeout', target: script });
/******/ }, 120000);
/******/ script.onerror = script.onload = onScriptComplete;
/******/ document.head.appendChild(script);
/******/ }
/******/ }
/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "//r.dcs.redcdn.pl/file/o2/web/player/redcdn/2.16.2/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
/******/ jsonpArray.push = webpackJsonpCallback;
/******/ jsonpArray = jsonpArray.slice();
/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
/******/ var parentJsonpFunction = oldJsonpFunction;
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 66);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ACQUIRING_LICENSE; });
/* unused harmony export AD_BREAK */
/* unused harmony export AD_BREAK_END */
/* unused harmony export AD_BREAK_START */
/* unused harmony export AD_BUFFERING */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return AD_COMPLETE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return AD_END; });
/* unused harmony export AD_ENDED */
/* unused harmony export AD_ERROR */
/* unused harmony export AD_PLAY */
/* unused harmony export AD_PLAYING */
/* unused harmony export AD_PAUSE */
/* unused harmony export AD_RESPONSE */
/* unused harmony export AD_REQUEST */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return AD_START; });
/* unused harmony export AD_TIME */
/* unused harmony export AUDIO_TRACK_CHANGE_REQUEST */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return AUDIO_TRACK_CHANGED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return AUDIO_TRACK_LIST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return BREAK_COMPLETE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return CAN_PLAY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return CHROMECAST_CONNECTED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return CHROMECAST_DISCONNECTED; });
/* unused harmony export CREATED */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return DESTROY; });
/* unused harmony export DRM_KEY_ERROR */
/* unused harmony export DURATION */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return ERROR; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return ENCRYPTED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return ENDED; });
/* unused harmony export FALLBACK */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return FULLSCREEN_CHANGE_REQUEST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return FULLSCREEN_CHANGED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return GUI_READY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return HEAD_TIME; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return INITIALIZED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return LICENSE_ACQUIRED; });
/* unused harmony export LOAD_METADATA */
/* unused harmony export LOAD_START */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return MANIFEST_LOADED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return MANIFEST_UPDATED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return MANIFEST_UPDATE_ERROR; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return DATA; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return METADATA; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "z", function() { return MONITOR; });
/* unused harmony export MUTED */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "A", function() { return NETWORK_METRIC; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "B", function() { return NETWORK_METRIC_UPDATED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "C", function() { return NEW_MEDIA; });
/* unused harmony export OFFLINE */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "D", function() { return ON_LIVE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "E", function() { return ON_SOURCE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return ON_TIMESHIFT; });
/* unused harmony export OPEN */
/* unused harmony export PAUSE */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "H", function() { return PAUSE_REQUEST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "G", function() { return PAUSED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "I", function() { return PERIOD; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "J", function() { return PERIOD_CHANGING; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "K", function() { return PERIOD_UPDATED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "L", function() { return PIP_SWITCHED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "M", function() { return PLAY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "N", function() { return PLAYBACK_RATE_CHANGED; });
/* unused harmony export PLAYER_READY */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "O", function() { return PLAYING; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "P", function() { return PLAYLIST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Q", function() { return PLAY_INTERRUPTED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "R", function() { return PLAY_PROMISE_RESOLVED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "S", function() { return PLAY_REQUEST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "V", function() { return PROFILE_CHANGE_REQUEST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "T", function() { return PROFILE_CHANGED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "U", function() { return PROFILE_CHANGED_LEGACY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "W", function() { return PROFILE_CHANGING; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "X", function() { return PROFILE_LIST; });
/* unused harmony export PROGRESS */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Y", function() { return READY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Z", function() { return RECONNECT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ab", function() { return RESIZE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bb", function() { return RESTART_REQUEST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "db", function() { return SEEK_REQUEST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fb", function() { return SEEK_TO_REQUEST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cb", function() { return SEEK_END; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "eb", function() { return SEEK_START; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gb", function() { return SESSION; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hb", function() { return SETUP; });
/* unused harmony export STALLED */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ib", function() { return STOPPED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "jb", function() { return STOP_REQUEST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kb", function() { return STREAM_EVENT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lb", function() { return STYLES; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ob", function() { return SUBTITLE_CUE_CHANGED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "qb", function() { return SUBTITLE_ENABLE_REQUEST; });
/* unused harmony export SUBTITLE_DISABLE_REQUEST */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rb", function() { return SUBTITLE_TOGGLE_REQUEST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mb", function() { return SUBTITLE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "nb", function() { return SUBTITLES; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pb", function() { return SUBTITLE_DISABLED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sb", function() { return SYNTHETIC_WAITING; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tb", function() { return TIME; });
/* unused harmony export TIME_UPDATE */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ub", function() { return TOGGLE_PLAY_PAUSE_REQUEST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vb", function() { return UNMUTED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "xb", function() { return VOLUME_CHANGE_REQUEST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "wb", function() { return VOLUME_CHANGED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yb", function() { return VOLUME_MUTE_REQUEST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "zb", function() { return WAITING; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ab", function() { return WAITING_END; });
var ACQUIRING_LICENSE = 'acquiringLicense';
var AD_BREAK = 'adBreak';
var AD_BREAK_END = 'adbreakend';
var AD_BREAK_START = 'adbreakstart';
var AD_BUFFERING = 'adbuffering';
var AD_COMPLETE = 'adComplete';
var AD_END = 'adEnd';
var AD_ENDED = 'adended';
var AD_ERROR = 'aderror';
var AD_PLAY = 'adplay';
var AD_PLAYING = 'adplaying';
var AD_PAUSE = 'adpause';
var AD_RESPONSE = 'adrequest';
var AD_REQUEST = 'adresponse';
var AD_START = 'adStart';
var AD_TIME = 'adtime';
var AUDIO_TRACK_CHANGE_REQUEST = 'audioTrackChangeRequest';
var AUDIO_TRACK_CHANGED = 'audioTrackChanged';
var AUDIO_TRACK_LIST = 'audioTracks';
var BREAK_COMPLETE = 'breakComplete';
var CAN_PLAY = 'canplay';
var CHROMECAST_CONNECTED = 'chromecastConnected';
var CHROMECAST_DISCONNECTED = 'chromecastDisconnected';
var CREATED = 'created';
var DESTROY = 'destroy';
var DRM_KEY_ERROR = 'drmKeyError';
var DURATION = 'duration';
var ERROR = 'error';
var ENCRYPTED = 'encrypted';
var ENDED = 'ended';
var FALLBACK = 'fallback';
var FULLSCREEN_CHANGE_REQUEST = 'fullscreenChangeRequest';
var FULLSCREEN_CHANGED = 'fullscreenChanged';
var GUI_READY = 'guiReady';
var HEAD_TIME = 'headTime';
var INITIALIZED = 'initialized';
var LICENSE_ACQUIRED = 'licenseAcquired';
var LOAD_METADATA = 'loadedmetadata';
var LOAD_START = 'loadstart';
var MANIFEST_LOADED = 'manifestLoaded';
var MANIFEST_UPDATED = 'manifestUpdated';
var MANIFEST_UPDATE_ERROR = 'manifestUpdateError';
var DATA = 'data';
var METADATA = 'metadata';
var MONITOR = 'monitor';
var MUTED = 'muted';
var NETWORK_METRIC = 'networkMetric';
var NETWORK_METRIC_UPDATED = 'networkMetricsUpdated';
var NEW_MEDIA = 'newMedia';
var OFFLINE = 'offline';
var ON_LIVE = 'live';
var ON_SOURCE = 'source';
var ON_TIMESHIFT = 'timeShift';
var OPEN = 'open';
var PAUSE = 'pause';
var PAUSE_REQUEST = 'pauseRequest';
var PAUSED = 'paused';
var PERIOD = 'period';
var PERIOD_CHANGING = 'periodChanging';
var PERIOD_UPDATED = 'periodUpdated';
var PIP_SWITCHED = 'pipSwitched';
var PLAY = 'play';
var PLAYBACK_RATE_CHANGED = 'playbackRateChange';
var PLAYER_READY = 'playerready';
var PLAYING = 'playing';
var PLAYLIST = 'playlist';
var PLAY_INTERRUPTED = 'playInterrupted';
var PLAY_PROMISE_RESOLVED = 'playPromiseResolved';
var PLAY_REQUEST = 'playRequest';
var PROFILE_CHANGE_REQUEST = 'profileChangeRequest';
var PROFILE_CHANGED = 'profileChanged';
var PROFILE_CHANGED_LEGACY = 'profile';
var PROFILE_CHANGING = 'profileChanging';
var PROFILE_LIST = 'profiles';
var PROGRESS = 'progress';
var READY = 'ready';
var RECONNECT = 'reconnect';
var RESIZE = 'resize';
var RESTART_REQUEST = 'restartRequest';
var SEEK_REQUEST = 'seekRequest';
var SEEK_TO_REQUEST = 'seekToRequest';
var SEEK_END = 'seeked';
var SEEK_START = 'seeking';
var SESSION = 'session';
var SETUP = 'setup';
var STALLED = 'stalled';
var STOPPED = 'stopped';
var STOP_REQUEST = 'stopRequest';
var STREAM_EVENT = 'streamEvent';
var STYLES = 'styles';
var SUBTITLE_CUE_CHANGED = 'subtitleCueChanged';
var SUBTITLE_ENABLE_REQUEST = 'subtitleEnableRequest';
var SUBTITLE_DISABLE_REQUEST = 'subtitleDisableRequest';
var SUBTITLE_TOGGLE_REQUEST = 'subtitleToggleRequest';
var SUBTITLE = 'subtitle';
var SUBTITLES = 'subtitles';
var SUBTITLE_DISABLED = 'subtitleDisabled';
var SYNTHETIC_WAITING = 'syntheticWaiting';
var TIME = 'time';
var TIME_UPDATE = 'timeupdate';
var TOGGLE_PLAY_PAUSE_REQUEST = 'togglePlayPauseRequest';
var UNMUTED = 'unmuted';
var VOLUME_CHANGE_REQUEST = 'volumeChangeRequest';
var VOLUME_CHANGED = 'volumeChanged';
var VOLUME_MUTE_REQUEST = 'volumeMuteRequest';
var WAITING = 'waiting';
var WAITING_END = 'waitingEnd';

/***/ }),
/* 1 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ADVERT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return ADVERT_CONTROLS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return ADVERT_LABEL; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return AUTOFOCUS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return AUTO_ADAPTATION; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return AUTO_ADAPTATION_BY_DROPPED_FRAMES; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return AUTO_ADAPTATION_BY_RESOLUTION; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return AUTO_ADAPTATION_MINIMUM_BUFFER_LENGTH; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return AUTOPLAY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return AUTOPLAY_BLOCKED_RULE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return ALLOWED_AUDIO_LANGUAGES; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return ALLOWED_SUBTITLE_LANGUAGES; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return BUFFER_BEHIND; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return BUFFER_TIME; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return CACHE_DRM_SESSION_BY_KEY_ID; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return CONSIDER_DROPPED_FRAMES; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return CONTROLS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return CONTROLS_LAYOUT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "s", function() { return CSS_PREFIX; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "t", function() { return DEBUG; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "w", function() { return DEFAULT_GUI_LANGUAGE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "u", function() { return DEFAULT_AUDIO_LANGUAGE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "v", function() { return DEFAULT_BITRATE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "x", function() { return DEFAULT_SUBTITLE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "y", function() { return DISABLE_NATIVE_CONTROLS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "z", function() { return DRM; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "A", function() { return DRM_SYSTEMS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "B", function() { return EXTRA; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "C", function() { return FAIRPLAY_CONTENT_TYPE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "D", function() { return FILE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "E", function() { return FILES; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "F", function() { return FIX_APPLE_SITE_SPECIFIC_HACKS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "G", function() { return FORCE_DASH; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "H", function() { return FULLSCREEN; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "I", function() { return FULLSCREEN_ELEMENT_ID; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "J", function() { return GSTREAM; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "K", function() { return HEIGHT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "L", function() { return HIDE_CONTROLS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "M", function() { return HOLDER; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "N", function() { return HTTP_CONFIG; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "O", function() { return I18N; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "P", function() { return IMMEDIATELY_SWITCH; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Q", function() { return KEYBOARD_EVENTS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "R", function() { return LANGUAGE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "S", function() { return LAST_BITRATE_CACHING; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "T", function() { return LAYOUT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "U", function() { return LIVE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "V", function() { return LIVE_DELAY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "W", function() { return MAX_AUTO_BITRATE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "X", function() { return MAX_BUFFER_LENGTH; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Z", function() { return MIN_AUTO_BITRATE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ab", function() { return MIN_BUFFER_TIME; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bb", function() { return MIN_LIVE_DELAY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Y", function() { return MINIMUM_UPDATE_PERIOD_ENABLED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cb", function() { return MODULES; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "db", function() { return NAME; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "eb", function() { return ON_LIVE_BUTTON_ACTION; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fb", function() { return PAUSE_ON_VIDEO_CLICK; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gb", function() { return PIP; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hb", function() { return PLAYBACK_RATES; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "jb", function() { return PLAYS_INLINE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ib", function() { return PLAYLIST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kb", function() { return POSTER; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lb", function() { return RECONNECT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mb", function() { return RENDERER_PRIORITY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "nb", function() { return ROOT_URL; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ob", function() { return SEEK_CHANGE_STEP; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pb", function() { return SEEK_PRECISION; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "qb", function() { return SESSION_HISTORY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sb", function() { return SHOW_BUTTONS_OVER_VIDEO; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tb", function() { return SHOW_BUTTONS_OVER_VIDEO_ON_HOVER; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ub", function() { return SHOW_JUMP_BUTTONS_OVER_VIDEO; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vb", function() { return SHOW_PAUSE_BUTTON_OVER_VIDEO; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "wb", function() { return SKIN; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rb", function() { return SETTINGS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "xb", function() { return SMART_TV; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yb", function() { return SPLASHSCREEN; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "zb", function() { return START_BUFFER_LENGTH; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ab", function() { return START_TIME; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bb", function() { return STREAM_WITH_CREDENTIALS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Cb", function() { return SUBTITLES; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Db", function() { return SUBTITLE_ENABLED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Eb", function() { return TIMESHIFT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Fb", function() { return TIMESHIFT_ENABLED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gb", function() { return TIMESHIFT_PARAMS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hb", function() { return TITLE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ib", function() { return TOOLTIPS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Jb", function() { return TRACKING; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Kb", function() { return UNMUTE_MESSAGE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Lb", function() { return USE_DOWNLINK_BITRATE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mb", function() { return UTC_TIME_SERVER; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Nb", function() { return UTC_TIME_SERVER_UPDATE_INTERVAL; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ob", function() { return VOLUME; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Pb", function() { return VOLUME_CHANGE_STEP; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Qb", function() { return VOLUME_LS_ENABLED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Rb", function() { return VOLUME_LS_KEY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sb", function() { return VOLUME_MUTED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tb", function() { return VOLUME_MUTED_LS_KEY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ub", function() { return VOLUME_TYPE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vb", function() { return WIDTH; });
var ADVERT = 'advert';
var ADVERT_CONTROLS = 'advertControls';
var ADVERT_LABEL = 'advertLabel';
var AUTOFOCUS = 'autofocus';
var AUTO_ADAPTATION = 'autoAdaptation';
var AUTO_ADAPTATION_BY_DROPPED_FRAMES = 'droppedFrames';
var AUTO_ADAPTATION_BY_RESOLUTION = 'resolution';
var AUTO_ADAPTATION_MINIMUM_BUFFER_LENGTH = 'bufferLength';
var AUTOPLAY = 'autoplay';
var AUTOPLAY_BLOCKED_RULE = 'autoplayBlockedRule';
var ALLOWED_AUDIO_LANGUAGES = 'allowedAudioLanguages';
var ALLOWED_SUBTITLE_LANGUAGES = 'allowedSubtitleLanguages';
var BUFFER_BEHIND = 'bufferBehind';
var BUFFER_TIME = 'bufferTime';
var CACHE_DRM_SESSION_BY_KEY_ID = 'cacheDrmSessionByKeyId';
var CONSIDER_DROPPED_FRAMES = 'considerDroppedFrames';
var CONTROLS = 'controls';
var CONTROLS_LAYOUT = 'controlsLayout';
var CSS_PREFIX = 'cssPrefix';
var DEBUG = 'debug';
var DEFAULT_GUI_LANGUAGE = 'defaultGuiLanguage';
var DEFAULT_AUDIO_LANGUAGE = 'defaultAudioLanguage';
var DEFAULT_BITRATE = 'defaultBitrate';
var DEFAULT_SUBTITLE = 'defaultSubtitle';
var DISABLE_NATIVE_CONTROLS = 'disableNativeControls';
var DRM = 'drm';
var DRM_SYSTEMS = 'drmSystems';
var EXTRA = 'extra';
var FAIRPLAY_CONTENT_TYPE = 'fairplayContentType';
var FILE = 'file';
var FILES = 'files';
var FIX_APPLE_SITE_SPECIFIC_HACKS = 'fixAppleSiteSpecificHacks';
var FORCE_DASH = 'forceDash';
var FULLSCREEN = 'fullscreen';
var FULLSCREEN_ELEMENT_ID = 'fullscreenElementId';
var GSTREAM = 'gstream';
var HEIGHT = 'height';
var HIDE_CONTROLS = 'hideControls';
var HOLDER = 'holder';
var HTTP_CONFIG = 'httpConfig';
var I18N = 'i18n';
var IMMEDIATELY_SWITCH = 'immediatelySwitch';
var KEYBOARD_EVENTS = 'keyboardEvents';
var LANGUAGE = 'language';
var LAST_BITRATE_CACHING = 'lastBitrateCaching';
var LAYOUT = 'layout';
var LIVE = 'live';
var LIVE_DELAY = 'liveDelay';
var MAX_AUTO_BITRATE = 'maxAutoBitrate';
var MAX_BUFFER_LENGTH = 'maxBufferLength';
var MIN_AUTO_BITRATE = 'minAutoBitrate';
var MIN_BUFFER_TIME = 'minBufferTime';
var MIN_LIVE_DELAY = 'minLiveDelay';
var MINIMUM_UPDATE_PERIOD_ENABLED = 'minimumUpdatePeriodEnabled';
var MODULES = 'modules';
var NAME = 'name';
var ON_LIVE_BUTTON_ACTION = 'onLiveButtonAction';
var PAUSE_ON_VIDEO_CLICK = 'pauseOnVideoClick';
var PIP = 'pip';
var PLAYBACK_RATES = 'playbackRates';
var PLAYS_INLINE = 'playsInline';
var PLAYLIST = 'playlist';
var POSTER = 'poster';
var RECONNECT = 'reconnect';
var RENDERER_PRIORITY = 'rendererPriority';
var ROOT_URL = 'rootUrl';
var SEEK_CHANGE_STEP = 'seekChangeStep';
var SEEK_PRECISION = 'seekPrecision';
var SESSION_HISTORY = 'sessionHistory';
var SHOW_BUTTONS_OVER_VIDEO = 'showButtonsOverVideo';
var SHOW_BUTTONS_OVER_VIDEO_ON_HOVER = 'showButtonsOverVideoOnHover';
var SHOW_JUMP_BUTTONS_OVER_VIDEO = 'showJumpButtonsOverVideo';
var SHOW_PAUSE_BUTTON_OVER_VIDEO = 'showPauseButtonOverVideo';
var SKIN = 'skin';
var SETTINGS = 'settings';
var SMART_TV = 'smartTV';
var SPLASHSCREEN = 'splashscreen';
var START_BUFFER_LENGTH = 'startBufferLength';
var START_TIME = 'startTime';
var STREAM_WITH_CREDENTIALS = 'streamWithCredentials';
var SUBTITLES = 'subtitles';
var SUBTITLE_ENABLED = 'subtitleEnabled';
var TIMESHIFT = 'timeShift';
var TIMESHIFT_ENABLED = 'timeShiftEnabled';
var TIMESHIFT_PARAMS = 'timeShiftParams';
var TITLE = 'title';
var TOOLTIPS = 'tooltips';
var TRACKING = 'tracking';
var UNMUTE_MESSAGE = 'unmuteMessage';
var USE_DOWNLINK_BITRATE = 'useDownlinkBitrate';
var UTC_TIME_SERVER = 'UTCTimeServer';
var UTC_TIME_SERVER_UPDATE_INTERVAL = 'UTCTimeServerUpdateInterval';
var VOLUME = 'volume';
var VOLUME_CHANGE_STEP = 'volumeChangeStep';
var VOLUME_LS_ENABLED = 'volumeLocalStorageEnabled';
var VOLUME_LS_KEY = 'volumeLocalStorageKey';
var VOLUME_MUTED = 'volumeMuted';
var VOLUME_MUTED_LS_KEY = 'volumeMutedLocalStorageKey';
var VOLUME_TYPE = 'volumeType';
var WIDTH = 'width';

/***/ }),
/* 2 */
/***/ (function(module, exports) {

function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}

return obj;
}

module.exports = _defineProperty;

/***/ }),
/* 3 */
/***/ (function(module, exports) {

function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}

module.exports = _classCallCheck;

/***/ }),
/* 4 */
/***/ (function(module, exports) {

function _getPrototypeOf(o) {
module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}

module.exports = _getPrototypeOf;

/***/ }),
/* 5 */
/***/ (function(module, exports) {

function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}

function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}

module.exports = _createClass;

/***/ }),
/* 6 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return BLUR; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return CLICK; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return FOCUS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return FOCUS_WITH_TAB; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return KEY_DOWN; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return MOUSE_DOWN; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return MOUSE_ENTER; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return MOUSE_LEAVE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return MOUSE_MOVE; });
/* unused harmony export MOUSE_OVER */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return MOUSE_UP; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return RESIZE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return TOUCH_END; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return TOUCH_MOVE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return TOUCH_START; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return TRANSITION_END; });
var BLUR = 'blur';
var CLICK = 'click';
var FOCUS = 'focus';
var FOCUS_WITH_TAB = 'focus-with-tab';
var KEY_DOWN = 'keydown';
var MOUSE_DOWN = 'mousedown';
var MOUSE_ENTER = 'mouseenter';
var MOUSE_LEAVE = 'mouseleave';
var MOUSE_MOVE = 'mousemove';
var MOUSE_OVER = 'mouseover';
var MOUSE_UP = 'mouseup';
var RESIZE = 'resize';
var TOUCH_END = 'touchend';
var TOUCH_MOVE = 'touchmove';
var TOUCH_START = 'touchstart';
var TRANSITION_END = 'transitionend';

/***/ }),
/* 7 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CONTROLS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return GUI; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return MANIFEST_MANAGER; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return MEDIA_ELEMENT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return MEDIA_SOURCE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return PIP; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return SETTINGS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return STREAM_MANAGER; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return VIDEO_WRAPPER; });
var CONTROLS = 'controls';
var GUI = 'gui';
var MANIFEST_MANAGER = 'manifest-manager';
var MEDIA_ELEMENT = 'media-element';
var MEDIA_SOURCE = 'media-source';
var PIP = 'pip';
var SETTINGS = 'settings';
var STREAM_MANAGER = 'stream-manager';
var VIDEO_WRAPPER = 'video-wrapper';

/***/ }),
/* 8 */
/***/ (function(module, exports, __webpack_require__) {

var arrayWithHoles = __webpack_require__(51);

var iterableToArrayLimit = __webpack_require__(52);

var unsupportedIterableToArray = __webpack_require__(45);

var nonIterableRest = __webpack_require__(53);

function _slicedToArray(arr, i) {
return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || unsupportedIterableToArray(arr, i) || nonIterableRest();
}

module.exports = _slicedToArray;

/***/ }),
/* 9 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
var MediaType = {
VIDEO: 'video',
AUDIO: 'audio',
TEXT: 'text'
};
/* harmony default export */ __webpack_exports__["a"] = (MediaType);

/***/ }),
/* 10 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
var PlayerError = {
DRM_GENERATE_LICENSE_CHALLENGE_FAILED: 'drm.generate.license.challenge.failed',
DRM_GENERATE_MEDIA_KEYS_FAILED: 'drm.generate.media.keys.failed',
DRM_SESSION_UPDATE_FAILED: 'drm.session.update.failed',
DRM_LOAD_CERTIFICATE_FAILED: 'drm.load.certificate.failed',
DRM_LOAD_LICENSE_KEY_FAILED: 'drm.load.license.key.failed',
DRM_NO_KEY_PROVIDED: 'drm.no.key.provided',
DRM_SESSION_KEY_ERROR: 'drm.session.key.error',
GENERIC_ERROR: 'generic.error',
LICENSE_RESPONSE_REJECTED: 'license.response.rejected',
LOAD_MANIFEST_ERROR: 'load.segment.manifest',
LOAD_SEGMENT_ERROR: 'load.segment.error',
MEDIA_ERR_ABORTED: 'media.err.aborted',
MEDIA_ERR_DECODE: 'media.err.decode',
MEDIA_ERR_NETWORK: 'media.err.network',
MEDIA_ERR_SRC_NOT_SUPPORTED: 'media.err.src.not.supported',
NO_SUPPORTED_RENDERER: 'no.supported.renderer',
NO_SUPPORTED_CODEC: 'no.supported.codec',
NOT_SECURE_CONTEXT: 'drm.not.secure.context.error',
PLAYBACK_ERROR: 'playback.error'
};
/* harmony default export */ __webpack_exports__["a"] = (PlayerError);

/***/ }),
/* 11 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return parseDuration; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return parseTime; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return parseDateTime; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return getChildren; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return getFirstChild; });
/* unused harmony export leftPad */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return fixNumberPrecision; });
/* unused harmony export replaceTokenInSegmentTemplate */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return buildInitializationUrl; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return buildSegmentUrl; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return getNodeContentType; });
/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8);
/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _renderer_dash_enum_media_type__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9);


var MEDIA_TYPES = Object.values(_renderer_dash_enum_media_type__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"]);
var MINUTE_TO_SECONDS = 60;
var HOUR_TO_SECONDS = MINUTE_TO_SECONDS * 60;
var DAY_TO_SECONDS = HOUR_TO_SECONDS * 24;
var YEAR_TO_SECONDS = DAY_TO_SECONDS * 365;
var SAFE_FLOAT_PRECISION = 12;
var SUPPORTED_TEXT_CODECS = ['stpp'];
var parseDuration = function parseDuration(durationString) {
if (!durationString) {
return null;
}

var regex = /^P(?:([0-9]*)Y)?(?:([0-9]*)D)?(?:T(?:([0-9]*)H)?(?:([0-9]*)M)?(?:([0-9.]*)S)?)?$/;
var matches = regex.exec(durationString);

if (!matches) {
return null;
}

var _matches$slice$map = matches.slice(1, 6).map(function (v) {
return parseInt(v, 10) || 0;
}),
_matches$slice$map2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(_matches$slice$map, 4),
years = _matches$slice$map2[0],
days = _matches$slice$map2[1],
hours = _matches$slice$map2[2],
minutes = _matches$slice$map2[3];

var seconds = parseFloat(matches[5] || 0);
return YEAR_TO_SECONDS * years + DAY_TO_SECONDS * days + HOUR_TO_SECONDS * hours + MINUTE_TO_SECONDS * minutes + seconds;
};
var parseTime = function parseTime(timeString) {
var timeParts = timeString.split(':').reverse();

var _timeParts$map = timeParts.map(function (v) {
return parseInt(v, 10) || 0;
}),
_timeParts$map2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(_timeParts$map, 4),
_ = _timeParts$map2[0],
minutes = _timeParts$map2[1],
hours = _timeParts$map2[2],
days = _timeParts$map2[3];

var seconds = parseFloat(timeParts[0] || 0);
return (days || 0) * DAY_TO_SECONDS + (hours || 0) * HOUR_TO_SECONDS + minutes * MINUTE_TO_SECONDS + seconds;
};
var parseDateTime = function parseDateTime(dateTimeString) {
if (!dateTimeString) {
return undefined;
}

var datetimeRegex = /^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2})(?::([0-9]*)(\.[0-9]*)?)?(?:([+\-])([0-9]{2})([0-9]{2}))?/;
var match = datetimeRegex.exec(dateTimeString);

var _match$slice$map = match.slice(1, 7).map(function (v) {
return parseInt(v, 10);
}),
_match$slice$map2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_0___default()(_match$slice$map, 6),
year = _match$slice$map2[0],
month = _match$slice$map2[1],
day = _match$slice$map2[2],
hour = _match$slice$map2[3],
minute = _match$slice$map2[4],
second = _match$slice$map2[5];

var ms = parseFloat(match[7] || 0);
var utcDate = Date.UTC(year, month - 1, day, hour, minute, second || 0, ms);
return new Date(utcDate).getTime() / 1000;
};
var getChildren = function getChildren(elm, tagName) {
return Array.from(elm.childNodes).filter(function (node) {
return node.tagName === tagName;
});
};
var getFirstChild = function getFirstChild(elm, tagNme) {
var _getChildren;

return ((_getChildren = getChildren(elm, tagNme)) === null || _getChildren === void 0 ? void 0 : _getChildren[0]) || null;
};
var leftPad = function leftPad(numStr, minStrLength) {
var replaceStr = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '0';

while (numStr.length < minStrLength) {
numStr = "".concat(replaceStr).concat(numStr);
}

return numStr;
};
var fixNumberPrecision = function fixNumberPrecision(number) {
return parseFloat(number.toPrecision(SAFE_FLOAT_PRECISION));
};
var replaceTokenInSegmentTemplate = function replaceTokenInSegmentTemplate(url, token, value) {
var tag = '%0';
var start = url.indexOf("$".concat(token));

if (start < 0) {
return url;
}

var end = url.indexOf('$', start + token.length);
var widthPos = url.indexOf(tag, start + token.length);
var width = 0;

if (widthPos >= 0) {
width = url.substring(widthPos + tag.length, end - 1);
var specifier = url.charAt(end - 1);

switch (specifier) {
case 'd':
case 'i':
case 'u':
value = leftPad(value.toString(), width, '0');
break;

case 'o':
value = leftPad(value.toString(8), width, '0');
break;

case 'x':
value = leftPad(value.toString(16), width, '0');
break;
}
}

return url.substring(0, start) + value + url.substring(end + 1);
};
var buildInitializationUrl = function buildInitializationUrl(representation) {
var bandwidth = representation.bandwidth,
id = representation.id,
segmentTemplate = representation.segmentTemplate,
url = representation.url;
return [url, segmentTemplate.initialization].join('').replace('$RepresentationID$', id).replace('$Bandwidth$', bandwidth);
};
var buildSegmentUrl = function buildSegmentUrl(representation, segment) {
var bandwidth = representation.bandwidth,
id = representation.id,
segmentTemplate = representation.segmentTemplate,
url = representation.url;
var index = segment.index,
startTime = segment.startTime;
var segmentUrl = [url, segmentTemplate.media].join('');
return replaceTokenInSegmentTemplate(segmentUrl, 'Number', index).replace('$Time$', startTime).replace('$RepresentationID$', id).replace('$Bandwidth$', bandwidth);
};
var getNodeContentType = function getNodeContentType(node) {
var codecs = node.getAttribute('codecs');
var contentType = node.getAttribute('contentType');
var mimeType = node.getAttribute('mimeType');

if (MEDIA_TYPES.includes(contentType)) {
return contentType;
}

if (SUPPORTED_TEXT_CODECS.includes(codecs)) {
return _renderer_dash_enum_media_type__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].TEXT;
}

if (mimeType) {
return MEDIA_TYPES.find(function (type) {
return mimeType.indexOf(type) !== -1;
});
}
};

/***/ }),
/* 12 */
/***/ (function(module, exports, __webpack_require__) {

var _typeof = __webpack_require__(26);

var assertThisInitialized = __webpack_require__(24);

function _possibleConstructorReturn(self, call) {
if (call && (_typeof(call) === "object" || typeof call === "function")) {
return call;
}

return assertThisInitialized(self);
}

module.exports = _possibleConstructorReturn;

/***/ }),
/* 13 */
/***/ (function(module, exports, __webpack_require__) {

var setPrototypeOf = __webpack_require__(48);

function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}

subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) setPrototypeOf(subClass, superClass);
}

module.exports = _inherits;

/***/ }),
/* 14 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ADAPTATION_CHANGED; });
/* unused harmony export DEADLOCK */
/* unused harmony export DOWNLOAD_ATTEMPTS_EXCEEDED */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return END_OF_STREAM; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return FAILED_TO_DOWNLOAD_MANIFEST; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return FAILED_TO_DOWNLOAD_SEGMENT; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return REPRESENTATION_CHANGED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return SEGMENT_APPENDED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return SEGMENT_DOWNLOAD_PROGRESS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return SEGMENT_DOWNLOADED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return SOURCE_BUFFER_CLEARED; });
/* unused harmony export SWITCH_PROFILE */
var ADAPTATION_CHANGED = 'adaptationChanged';
var DEADLOCK = 'deadlock';
var DOWNLOAD_ATTEMPTS_EXCEEDED = 'attemptsExceeded';
var END_OF_STREAM = 'endOfStream';
var FAILED_TO_DOWNLOAD_MANIFEST = 'failedToLoadManifest';
var FAILED_TO_DOWNLOAD_SEGMENT = 'failedToLoadSegment';
var REPRESENTATION_CHANGED = 'representationChanged';
var SEGMENT_APPENDED = 'segmentAppended';
var SEGMENT_DOWNLOAD_PROGRESS = 'segmentProgress';
var SEGMENT_DOWNLOADED = 'segmentDownloaded';
var SOURCE_BUFFER_CLEARED = 'sourceBufferCleared';
var SWITCH_PROFILE = 'switchProfile';

/***/ }),
/* 15 */
/***/ (function(module, exports, __webpack_require__) {

module.exports = __webpack_require__(54);


/***/ }),
/* 16 */
/***/ (function(module, exports, __webpack_require__) {

var arrayWithoutHoles = __webpack_require__(55);

var iterableToArray = __webpack_require__(56);

var unsupportedIterableToArray = __webpack_require__(45);

var nonIterableSpread = __webpack_require__(57);

function _toConsumableArray(arr) {
return arrayWithoutHoles(arr) || iterableToArray(arr) || unsupportedIterableToArray(arr) || nonIterableSpread();
}

module.exports = _toConsumableArray;

/***/ }),
/* 17 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return EventEmitter; });
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__);



var EventEmitter = /*#__PURE__*/function () {
function EventEmitter() {
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default()(this, EventEmitter);

this.callbacks = {};
}

_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default()(EventEmitter, [{
key: "on",
value: function on(eventName, callback) {
this.callbacks = this.callbacks || {};

if (!this.callbacks.hasOwnProperty(eventName)) {
this.callbacks[eventName] = [];
}

this.callbacks[eventName].push(callback);
}
}, {
key: "once",
value: function once(eventName, callback) {
function _callback() {
var args = Array.prototype.slice.call(arguments);
this.off(eventName, _callback);
callback.apply(this, args);
}

this.on(eventName, _callback);
}
}, {
key: "off",
value: function off(eventName, callback) {
this.callbacks = this.callbacks || {};

if (eventName === null || eventName === undefined || eventName === '') {
this.callbacks = {};
return;
}

if (!callback) {
delete this.callbacks[eventName];
} else if (this.callbacks[eventName] && this.callbacks[eventName].length) {
var index;

while ((index = this.callbacks[eventName].indexOf(callback)) !== -1) {
this.callbacks[eventName].splice(index, 1);
}
}
}
}, {
key: "trigger",
value: function trigger(eventName) {
var _callbacks,
args = Array.prototype.slice.call(arguments);

this.callbacks = this.callbacks || {};
args.shift();

if (this.callbacks.hasOwnProperty(eventName)) {
_callbacks = this.callbacks[eventName].slice();

for (var i = 0; i < _callbacks.length; i++) {
_callbacks[i].apply(this, args);
}
}
}
}]);

return EventEmitter;
}();



/***/ }),
/* 18 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CLICK", function() { return CLICK; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MOUSE_MOVE", function() { return MOUSE_MOVE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PLAY_BUTTON_CLICKED", function() { return PLAY_BUTTON_CLICKED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PAUSE_BUTTON_CLICKED", function() { return PAUSE_BUTTON_CLICKED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SEEK_TO_HEAD", function() { return SEEK_TO_HEAD; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PROGRESS_POSITION_CHANGING", function() { return PROGRESS_POSITION_CHANGING; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PROGRESS_POSITION_CHANGED", function() { return PROGRESS_POSITION_CHANGED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VOLUME_CHANGED", function() { return VOLUME_CHANGED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BANDWIDTH_CHANGED", function() { return BANDWIDTH_CHANGED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FULLSCREEN_BUTTON_CLICKED", function() { return FULLSCREEN_BUTTON_CLICKED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LIVE_BUTTON_CLICKED", function() { return LIVE_BUTTON_CLICKED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "REPLAY_BUTTON_CLICKED", function() { return REPLAY_BUTTON_CLICKED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONTROLS_SHOW", function() { return CONTROLS_SHOW; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONTROLS_HIDE", function() { return CONTROLS_HIDE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SEEK_FROM_TO", function() { return SEEK_FROM_TO; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PROGRESS_MOVE", function() { return PROGRESS_MOVE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SETTINGS_TOGGLE", function() { return SETTINGS_TOGGLE; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PLAY_BIG_BUTTON_CLICKED", function() { return PLAY_BIG_BUTTON_CLICKED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SUBTITLE_BUTTON_CLICKED", function() { return SUBTITLE_BUTTON_CLICKED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VOLUME_MUTE_STATE_CHANGED", function() { return VOLUME_MUTE_STATE_CHANGED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PAUSE_BIG_BUTTON_CLICKED", function() { return PAUSE_BIG_BUTTON_CLICKED; });
var CLICK = 0;
var MOUSE_MOVE = 1;
var PLAY_BUTTON_CLICKED = 5;
var PAUSE_BUTTON_CLICKED = 6;
var SEEK_TO_HEAD = 7;
var PROGRESS_POSITION_CHANGING = 8;
var PROGRESS_POSITION_CHANGED = 9;
var VOLUME_CHANGED = 10;
var BANDWIDTH_CHANGED = 11;
var FULLSCREEN_BUTTON_CLICKED = 12;
var LIVE_BUTTON_CLICKED = 13;
var REPLAY_BUTTON_CLICKED = 14;
var CONTROLS_SHOW = 15;
var CONTROLS_HIDE = 16;
var SEEK_FROM_TO = 17;
var PROGRESS_MOVE = 18;
var SETTINGS_TOGGLE = 19;
var PLAY_BIG_BUTTON_CLICKED = 20;
var SUBTITLE_BUTTON_CLICKED = 21;
var VOLUME_MUTE_STATE_CHANGED = 22;
var PAUSE_BIG_BUTTON_CLICKED = 23;

/***/ }),
/* 19 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16);
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8);
/* harmony import */ var _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(26);
/* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _core_util_date__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(43);
/* harmony import */ var _core_info__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(39);





var Core = {
extend: function extend(destination, source) {
var property;

for (property in source) {
if (source.hasOwnProperty(property)) {
destination[property] = source[property];
}
}

return destination;
},
extendDeep: function extendDeep(destination, source) {
var property,
arrayString = '[object Array]';
destination = destination || {};

for (property in source) {
if (source.hasOwnProperty(property)) {
if (_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_2___default()(source[property]) === 'object' && source[property] !== null) {
destination[property] = Object.prototype.toString.call(source[property]) === arrayString ? [] : {};
this.extendDeep(destination[property], source[property]);
} else {
destination[property] = source[property];
}
}
}

return destination;
},
generateRandomString: function generateRandomString(len) {
var text = '',
charset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
i;

for (i = 0; i < len; i++) {
text += charset.charAt(Math.floor(Math.random() * charset.length));
}

return text;
},
formatTime: function formatTime(seconds) {
if (isNaN(seconds)) {
seconds = 0;
}

var hh = Math.floor(seconds / 3600),
mm = Math.floor(seconds / 60) % 60,
ss = Math.floor(seconds) % 60;
return (hh ? Core.addLeadingZero(hh) + ':' : '') + Core.addLeadingZero(mm) + ':' + this.addLeadingZero(ss);
},
formatDateTime: function formatDateTime(date) {
var format = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'YYYY-MM-DD HH:mm:ss';
return _core_util_date__WEBPACK_IMPORTED_MODULE_3__[/* default */ "a"].format(date, format);
},
addLeadingZero: function addLeadingZero(num) {
if (num < 10) {
return '0' + num;
} else {
return '' + num;
}
},

/* from time format HH:MM:SS */
parseTime: function parseTime(timeStr) {
var p = timeStr.split(':'),
seconds = 0,
m = 2;

while (p.length > 0) {
seconds += Math.pow(60, m) * parseInt(p.shift(), 10);
m--;
}

return seconds;
},
isDST: function isDST(t) {
var jan = new Date(t.getFullYear(), 0, 1);
var jul = new Date(t.getFullYear(), 6, 1);
return Math.min(jan.getTimezoneOffset(), jul.getTimezoneOffset()) === t.getTimezoneOffset();
},

/* from date format YYYY-MM-DD */
parseDate: function parseDate(dateStr) {
var timeStr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '0:0:0';
var dateParts = dateStr.split('-');
dateParts[1]--;

var _timeStr$split = timeStr.split(':'),
_timeStr$split2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default()(_timeStr$split, 3),
hours = _timeStr$split2[0],
minutes = _timeStr$split2[1],
seconds = _timeStr$split2[2];

var _isDST = Core.isDST(new Date(dateParts[0], dateParts[1], dateParts[2], parseInt(hours), parseInt(minutes), parseInt(seconds)));

var offset = new Date(new Date(dateParts[0], dateParts[1], dateParts[2]).getTime()).getTimezoneOffset() + (_isDST ? 120 : 60);
offset = offset * 60;
return new Date(dateParts[0], dateParts[1], dateParts[2]).getTime() / 1000 - offset;
},
calculateBaseTime: function calculateBaseTime(dateTimeStr) {
var temp = dateTimeStr.split(' ');
return Core.parseDate(temp[0], temp[1]) + Core.parseTime(temp[1]);
},

/**
* Supported formats:
* YYYY-MM-DD[T]HH:MM:SS[.MMM]
* YYYY-MM-DD[T]HH:MM:SS[+/-hh:mm]
* YYYY-MM-DD[T]HH:MM:SS[Z]
*/
parseDateTime: function parseDateTime(dateTimeStr) {
var timeZoneSign,
timeZoneStr,
timeZone = 0;
var dateTimeSplitted = dateTimeStr.split(/([\+\-Z])(.{2,9})?$/);
var isUTC = /Z$/.test(dateTimeStr);
var isLocal = dateTimeSplitted.length <= 1;
var dateParts = dateTimeSplitted[0].split(/[T\s]/);

var _dateParts$0$split = dateParts[0].split('-'),
_dateParts$0$split2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default()(_dateParts$0$split, 3),
year = _dateParts$0$split2[0],
month = _dateParts$0$split2[1],
day = _dateParts$0$split2[2];

var _dateParts$1$split = dateParts[1].split(':'),
_dateParts$1$split2 = _babel_runtime_helpers_slicedToArray__WEBPACK_IMPORTED_MODULE_1___default()(_dateParts$1$split, 3),
hours = _dateParts$1$split2[0],
minutes = _dateParts$1$split2[1],
milliseconds = _dateParts$1$split2[2];

var _isDST = Core.isDST(new Date(year, month - 1, day, hours, minutes, milliseconds));

if (!isUTC && !isLocal) {
timeZoneSign = dateTimeSplitted[1];
timeZoneStr = dateTimeSplitted[2].split(/[:.]/);
timeZone = -1 * +(timeZoneSign + (timeZoneStr[0] * 3600 + timeZoneStr[1] * 60));
}

timeZone += 60 * (_isDST ? 120 : 60);
return this.calculateBaseTime(dateParts[0] + ' ' + dateParts[1]) + (isLocal ? 0 : timeZone);
},
getCssUrl: function getCssUrl(skin) {
var _skin$name = skin.name,
name = _skin$name === void 0 ? 'default' : _skin$name,
url = skin.url;
var stylesBaseUrl = "".concat(_core_info__WEBPACK_IMPORTED_MODULE_4__[/* default */ "a"].ROOT_URL).concat(_core_info__WEBPACK_IMPORTED_MODULE_4__[/* default */ "a"].VERSION, "/css/");

if (url) {
return url;
}

return "".concat(stylesBaseUrl).concat(name, ".css");
},
loadSkin: function loadSkin(skin) {
return this.loadCss(this.getCssUrl(skin));
},
loadCss: function loadCss(url) {
var link = document.createElement('link');

var links = _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(document.querySelectorAll('link'));

var exists = links.find(function (link) {
return link.getAttribute('href') === url;
});

if (exists) {
return Promise.resolve();
}

return new Promise(function (resolve, reject) {
link.setAttribute('rel', 'stylesheet');
link.setAttribute('type', 'text/css');
link.setAttribute('href', url);
document.querySelector('head').appendChild(link);

link.onload = function () {
return resolve();
};

link.onerror = function () {
return resolve();
};
});
},
getBrowserLanguage: function getBrowserLanguage() {
var _navigator, _navigator2, _navigator2$languages;

var language = ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.language) || ((_navigator2 = navigator) === null || _navigator2 === void 0 ? void 0 : (_navigator2$languages = _navigator2.languages) === null || _navigator2$languages === void 0 ? void 0 : _navigator2$languages[0]);
return language === null || language === void 0 ? void 0 : language.split('-')[0];
}
};
/* harmony default export */ __webpack_exports__["a"] = (Core);

/***/ }),
/* 20 */
/***/ (function(module, exports) {

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}

if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}

function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);

function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}

function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}

_next(undefined);
});
};
}

module.exports = _asyncToGenerator;

/***/ }),
/* 21 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
var userAgent = navigator.userAgent;

var match = function match(regexp) {
return !!userAgent.match(regexp);
};

var BrowserUtil = {
isMobile: function isMobile() {
return this.isAndroid() || this.isIOS() || this.isMobileOpera() || this.isMobileWindows();
},
isAndroid: function isAndroid() {
return match(/Android/i);
},
isIOS: function isIOS() {
return match(/iPhone|iPad|iPod/i);
},
isMobileOpera: function isMobileOpera() {
return match(/Opera Mini/i);
},
isMobileWindows: function isMobileWindows() {
return match(/IEMobile/i);
},
isFirefox: function isFirefox() {
return userAgent.indexOf('Firefox') > -1;
},
isOpera: function isOpera() {
return !!window.opera || userAgent.indexOf('OPR/') >= 0;
},
isSafari: function isSafari() {
return /^((?!chrome).)*safari/i.test(userAgent);
},
isSafariWithSiteSpecificHacks: function isSafariWithSiteSpecificHacks() {
return !this.isSafari() && (/constructor/i.test(window.HTMLElement) || function (p) {
return p.toString() === "[object SafariRemoteNotification]";
}(!window['safari'] || typeof safari !== 'undefined' && safari.pushNotification));
},
isTizen: function isTizen() {
return match(/Tizen/);
},
getFirefoxVersion: function getFirefoxVersion() {
var offset = userAgent.indexOf('Firefox');
return parseFloat(userAgent.substring(offset + 8));
},
isWidevineSupported: function isWidevineSupported() {
if (this.isFirefox() && (this.getFirefoxVersion() < 47 || userAgent.indexOf('Windows NT 5.1') !== -1)) {
return false;
}

if (userAgent.toLowerCase().indexOf('linux') !== -1 && this.getFirefoxVersion() < 47) {
return false;
}

return !!navigator.requestMediaKeySystemAccess;
},
getLanguage: function getLanguage() {
if (typeof navigator.language !== 'undefined') {
return navigator.language;
} else if (typeof navigator.languages !== 'undefined') {
return navigator.languages[0].split('-')[0];
} else {
return null;
}
}
};
/* harmony default export */ __webpack_exports__["a"] = (BrowserUtil);

/***/ }),
/* 22 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/slicedToArray.js
var slicedToArray = __webpack_require__(8);
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/defineProperty.js
var defineProperty = __webpack_require__(2);
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);

// CONCATENATED MODULE: ./src/core/util/http/cancel-token.js
function Cancel(message) {
this.message = message;
}

function CancelToken(executor) {
var token = this;
var resolvePromise;
this.promise = new Promise(function (resolve) {
return resolvePromise = resolve;
});
executor(function (message) {
if (token.reason) {
return;
}

token.reason = new Cancel(message);
resolvePromise(token.reason);
});
}

CancelToken.source = function () {
var cancel;
var token = new CancelToken(function (c) {
return cancel = c;
});
return {
cancel: cancel,
token: token
};
};

/* harmony default export */ var cancel_token = (CancelToken);
// EXTERNAL MODULE: ./src/core/util/http/http-status.js
var http_status = __webpack_require__(23);

// EXTERNAL MODULE: ./src/core/util/http/http-response-type.js
var http_response_type = __webpack_require__(29);

// CONCATENATED MODULE: ./src/core/util/http/index.js



function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }




var DEFAULT_OPTIONS = {
responseType: 'text',
method: 'GET',
retryAttempts: 3,
retryDelay: 1000,
timeout: 8000,
withCredentials: false,
cancelToken: null
};
var http = {
get: function get(url) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

if (options.responseType === http_response_type["c" /* XML */]) {
options.responseType = http_response_type["b" /* DOCUMENT */];
}

return request(url, _objectSpread({}, options));
},
getBinary: function getBinary(url) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return request(url, _objectSpread({
responseType: http_response_type["a" /* ARRAY_BUFFER */]
}, options));
},
head: function head(url) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return request(url, _objectSpread({
method: 'HEAD'
}, options));
},
post: function post(url) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return request(url, _objectSpread({
method: 'POST'
}, options));
},
put: function put(url) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return request(url, _objectSpread({
method: 'PUT'
}, options));
},
del: function del(url) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return request(url, _objectSpread({
method: 'DELETE'
}, options));
}
};

function request(url, opts) {
var start = Date.now();
var xhr;
var aborted = false;
var attempts = 1;
var timeout;
return new Promise(function (resolve, reject) {
var options = _objectSpread({}, DEFAULT_OPTIONS, {}, opts);

var headers = options.headers || {};
var progressCallback = options.onProgress;

if (opts.cancelToken) {
opts.cancelToken.promise.then(function () {
return abort();
});
}

var download = function download() {
xhr = new XMLHttpRequest();

if (options.withCredentials) {
xhr.withCredentials = true;
}

xhr.open(options.method, url);
xhr.responseType = options.responseType;

if (options.responseType === http_response_type["c" /* XML */]) {
xhr.overrideMimeType('text/xml');
}

Object.entries(headers).forEach(function (_ref) {
var _ref2 = slicedToArray_default()(_ref, 2),
key = _ref2[0],
value = _ref2[1];

return xhr.setRequestHeader(key, value);
});

if (progressCallback) {
xhr.onprogress = function (event) {
return onprogress(event);
};
}

xhr.onreadystatechange = function () {
return onreadystatechange();
};

xhr.send(options.data || null);
};

var onprogress = function onprogress(event) {
var timestamp = Date.now();
var bps = Math.round(event.loaded / ((timestamp - start) / 1000) * 8);
var info = {
bps: bps,
event: event,
timestamp: timestamp,
loaded: event.loaded,
started: start,
status: http_status["c" /* PROGRESS */]
};
progressCallback(info);
};

var onreadystatechange = function onreadystatechange() {
if (xhr.readyState !== 4) {
return;
}

var timestamp = Date.now();
var duration = timestamp - start;
var metric = {
duration: duration,
timestamp: timestamp,
url: url,
statusCode: xhr.status,
status: http_status["e" /* SUCCESS */]
};

if (xhr.status === 200) {
var data = getResponseData(xhr, options);
metric.bps = Math.round(data.length / (duration / 1000) * 8);
resolve({
metric: metric,
data: data,
url: url,
status: http_status["e" /* SUCCESS */],
responseUrl: xhr.responseURL,
xhr: xhr
});
} else {
if (aborted) {
metric.status = http_status["a" /* ABORTED */];
reject({
error: http_status["a" /* ABORTED */],
metric: metric,
xhr: xhr
});
} else if (attempts >= options.retryAttempts) {
metric.status = http_status["b" /* FAILED */];
reject({
error: http_status["b" /* FAILED */],
metric: metric,
xhr: xhr
});
} else {
attempts++;
metric.status = http_status["d" /* RETRY */];
timeout = setTimeout(download, options.retryDelay);

if (progressCallback) {
progressCallback(metric);
}
}
}
};

var abort = function abort() {
aborted = true;
clearTimeout(timeout);
xhr.abort();
reject(http_status["a" /* ABORTED */]);
};

download();
});
}

function getResponseData(xhr, options) {
switch (options.responseType) {
case http_response_type["c" /* XML */]:
case http_response_type["b" /* DOCUMENT */]:
return xhr.responseXML;

case http_response_type["a" /* ARRAY_BUFFER */]:
return new Uint8Array(xhr.response);

default:
return xhr.responseText;
}
}

http.CancelToken = cancel_token;
/* harmony default export */ var util_http = __webpack_exports__["a"] = (http);

/***/ }),
/* 23 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ABORTED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return FAILED; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return RETRY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return PROGRESS; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return SUCCESS; });
var ABORTED = 'aborted';
var FAILED = 'failed';
var RETRY = 'retry';
var PROGRESS = 'progress';
var SUCCESS = 'success';

/***/ }),
/* 24 */
/***/ (function(module, exports) {

function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}

return self;
}

module.exports = _assertThisInitialized;

/***/ }),
/* 25 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
function Timer(interval, callback) {
var immediateUpdate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
interval = interval || 250;
var intervalRef = null;
var counter = 0;
var initTime = 0;

var update = callback || function () {};

function start() {
clearInterval(intervalRef);

if (immediateUpdate) {
update();
}

initTime = new Date().getTime();
intervalRef = setInterval(function () {
counter++;
update();
}, interval);
}

function stop() {
clearInterval(intervalRef);
}

function restart() {
stop();
start();
}

function getDuration() {
return new Date().getTime() - initTime;
}

return {
getDuration: getDuration,
start: start,
restart: restart,
stop: stop
};
}

/* harmony default export */ __webpack_exports__["a"] = (Timer);

/***/ }),
/* 26 */
/***/ (function(module, exports) {

function _typeof(obj) {
"@babel/helpers - typeof";

if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
module.exports = _typeof = function _typeof(obj) {
return typeof obj;
};
} else {
module.exports = _typeof = function _typeof(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}

return _typeof(obj);
}

module.exports = _typeof;

/***/ }),
/* 27 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _player_error__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(10);


var _PlayerError$NO_SUPPO;


/* harmony default export */ __webpack_exports__["a"] = (_PlayerError$NO_SUPPO = {}, _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_PlayerError$NO_SUPPO, _player_error__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].NO_SUPPORTED_RENDERER, 200), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_PlayerError$NO_SUPPO, _player_error__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].NO_SUPPORTED_CODEC, 201), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_PlayerError$NO_SUPPO, _player_error__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].PLAYBACK_ERROR, 204), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_PlayerError$NO_SUPPO, _player_error__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].MEDIA_ERR_ABORTED, 205), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_PlayerError$NO_SUPPO, _player_error__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].MEDIA_ERR_DECODE, 206), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_PlayerError$NO_SUPPO, _player_error__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].MEDIA_ERR_NETWORK, 207), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_PlayerError$NO_SUPPO, _player_error__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].MEDIA_ERR_SRC_NOT_SUPPORTED, 208), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_PlayerError$NO_SUPPO, _player_error__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].LOAD_MANIFEST_ERROR, 400), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_PlayerError$NO_SUPPO, _player_error__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].LOAD_SEGMENT_ERROR, 401), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_0___default()(_PlayerError$NO_SUPPO, _player_error__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].GENERIC_ERROR, 900), _PlayerError$NO_SUPPO);

/***/ }),
/* 28 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return TimeShiftMode; });
/* harmony import */ var _util_core__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(19);
/* harmony import */ var _event_player_event__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
/* harmony import */ var _core_enum_option_name__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1);
/* harmony import */ var _core_util_url__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(31);
/* harmony import */ var _core_util_utc_time__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(36);





var TimeShiftMode = {
LIVE: 'live',
LIVE_DELAYED: 'liveDelayed',
VOD: 'vod',
VOD_SHIFTED: 'vodShifted'
};
var ATDS_BASE_TIMESTAMP = 978307200;

function TimeShift(player) {
var _params;

player.on(_event_player_event__WEBPACK_IMPORTED_MODULE_1__[/* INITIALIZED */ "t"], update);
player.on(_event_player_event__WEBPACK_IMPORTED_MODULE_1__[/* STYLES */ "lb"], update);
player.on(_event_player_event__WEBPACK_IMPORTED_MODULE_1__[/* MANIFEST_LOADED */ "v"], onManifestLoaded);
player.once(_event_player_event__WEBPACK_IMPORTED_MODULE_1__[/* METADATA */ "y"], setInitialStart);
var options = player.options;
var params = getParams();
var mode = null;
var hasDvrWindow = false;
var start = -1;
var dvrWindow = -1;
var initialStart = -1;
var stop = -1;
var play = -1;
var availabilityStartTime = 0;
var baseTimeStamp = ATDS_BASE_TIMESTAMP;
var unixTimestamp = (_params = params) === null || _params === void 0 ? void 0 : _params.unixTimestamp;
var timeShiftParams = options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_2__[/* TIMESHIFT_PARAMS */ "Gb"]);

if (unixTimestamp) {
baseTimeStamp = 0;
}

function update() {
params = getParams();

if (player.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_2__[/* TIMESHIFT_ENABLED */ "Fb"])) {
mode = TimeShiftMode.LIVE;
}

if (!params) {
return;
}

if (typeof params.baseTimeStamp !== 'undefined') {
baseTimeStamp = params.baseTimeStamp;
}

if (params.dvrWindow) {
hasDvrWindow = true;
dvrWindow = params.dvrWindow;
}

if (params.start) {
start = _util_core__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"].parseDateTime(params.start);
}

if (params.play) {
play = _util_core__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"].parseDateTime(params.play);
}

if (params.start && params.stop) {
stop = _util_core__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"].parseDateTime(params.stop);
}

if (mode === null) {
mode = TimeShiftMode.LIVE;

if (params.play) {
mode = TimeShiftMode.LIVE_DELAYED;
}

if (params.start && params.stop) {
mode = TimeShiftMode.VOD;
}
}

setTimeout(player.trigger.bind(player, _event_player_event__WEBPACK_IMPORTED_MODULE_1__[/* ON_TIMESHIFT */ "F"]), 0);
}

function onManifestLoaded(manifest) {
availabilityStartTime = manifest.availabilityStartTime || 0;

if (!manifest.presentationTimeOffset) {
baseTimeStamp = availabilityStartTime;
}
}

function setLive() {
mode = TimeShiftMode.LIVE;
}

function setDvrWindow(_dvrWindow) {
if (isEnabled()) {
hasDvrWindow = true;
dvrWindow = _dvrWindow;
}
}

function setStart(_start) {
start = _start;
}

function setPlay(time) {
play = time;
}

function setInitialStart() {
initialStart = getStart();
}

function isLive() {
return mode === TimeShiftMode.LIVE || mode === TimeShiftMode.LIVE_DELAYED;
}

function isVod() {
return mode === TimeShiftMode.VOD || mode === TimeShiftMode.VOD_SHIFTED;
}

function isEnabled() {
return mode !== null;
}

function getBaseTimeStamp() {
return baseTimeStamp;
}

function getDvrWindow() {
return dvrWindow;
}

function getMode() {
return mode;
}

function setMode(_mode) {
mode = _mode;
}

function getPlayStart() {
return play;
}

function getStop() {
return stop;
}
/*
Deprecated method
*/


function getHeadTime() {
return getLiveNowUTC;
}

function getLiveNowUTC() {
return _core_util_utc_time__WEBPACK_IMPORTED_MODULE_4__[/* default */ "a"].getTime();
}

function getParams() {
return player.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_2__[/* TIMESHIFT */ "Eb"]);
}

function getStart() {
var utcNow = getLiveNowUTC();

if (hasDvrWindow && dvrWindow > 0 && utcNow > 0) {
return utcNow - dvrWindow;
}

return start;
}

function getInitialStart() {
return initialStart;
}

function reset() {
if (mode === TimeShiftMode.LIVE_DELAYED) {
mode = TimeShiftMode.LIVE;
}

if (mode === TimeShiftMode.VOD_SHIFTED) {
mode = TimeShiftMode.VOD;
}
}

function generateUrl(url) {
if (timeShiftParams.disableUrlModification) {
return url;
}

var multiplier = unixTimestamp ? 1 : 1000;
var baseTimestamp = unixTimestamp ? 0 : getBaseTimeStamp();
var epoch = baseTimestamp * multiplier;
var start = getStart() * multiplier - epoch;
var stop = getStop() * multiplier - epoch;
var playStart = getPlayStart() * multiplier - epoch;
var dvrWindow = getDvrWindow();

if (url.endsWith('&')) {
url = url.slice(0, -1);
}

if (isLive() && start > 0 && getDvrWindow() <= 0) {
url = Object(_core_util_url__WEBPACK_IMPORTED_MODULE_3__[/* setUrlParam */ "c"])(url, timeShiftParams.startTime, start);
}

if (getDvrWindow() > 0) {
url = Object(_core_util_url__WEBPACK_IMPORTED_MODULE_3__[/* setUrlParam */ "c"])(url, timeShiftParams.dvr, dvrWindow * 1000);
}

if (mode === TimeShiftMode.VOD || mode === TimeShiftMode.VOD_SHIFTED) {
url = Object(_core_util_url__WEBPACK_IMPORTED_MODULE_3__[/* setUrlParam */ "c"])(url, timeShiftParams.startTime, start);
url = Object(_core_util_url__WEBPACK_IMPORTED_MODULE_3__[/* setUrlParam */ "c"])(url, timeShiftParams.stopTime, stop);
}

if (mode === TimeShiftMode.LIVE_DELAYED && !dvrWindow) {
url = Object(_core_util_url__WEBPACK_IMPORTED_MODULE_3__[/* setUrlParam */ "c"])(url, timeShiftParams.startTime, playStart);
}

return url;
}

function getAvailabilityStartTime() {
return availabilityStartTime;
}

function setAvailabilityStartTime(time) {
availabilityStartTime = time;
}

function isVodEnded(time) {
return time > stop;
}

return {
update: update,
setStart: setStart,
getStart: getStart,
getInitialStart: getInitialStart,
getPlayStart: getPlayStart,
getStop: getStop,
isLive: isLive,
isVod: isVod,
getDvrWindow: getDvrWindow,
getMode: getMode,
isEnabled: isEnabled,
generateUrl: generateUrl,
setDvrWindow: setDvrWindow,
getBaseTimeStamp: getBaseTimeStamp,
getAvailabilityStartTime: getAvailabilityStartTime,
setAvailabilityStartTime: setAvailabilityStartTime,
setMode: setMode,
reset: reset,
isVodEnded: isVodEnded,
getLiveNowUTC: getLiveNowUTC,
getHeadTime: getHeadTime,
setLive: setLive,
setPlay: setPlay
};
}


/* harmony default export */ __webpack_exports__["b"] = (TimeShift);

/***/ }),
/* 29 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* unused harmony export TEXT */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return XML; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return DOCUMENT; });
/* unused harmony export JSON */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ARRAY_BUFFER; });
var TEXT = 'text';
var XML = 'xml';
var DOCUMENT = 'document';
var JSON = 'json';
var ARRAY_BUFFER = 'arraybuffer';

/***/ }),
/* 30 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CLEARKEY", function() { return CLEARKEY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FAIRPLAY", function() { return FAIRPLAY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PLAYREADY", function() { return PLAYREADY; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WIDEVINE", function() { return WIDEVINE; });
var CLEARKEY = 'org.w3.clearkey';
var FAIRPLAY = 'com.apple.fps.1_0';
var PLAYREADY = 'com.microsoft.playready';
var WIDEVINE = 'com.widevine.alpha';

/***/ }),
/* 31 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return isUrlAbsolute; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return setUrlParam; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return removeUrlParam; });
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16);
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__);

var isUrlAbsolute = function isUrlAbsolute(url) {
return url.startsWith('http') || url.startsWith('//');
};

var updateUrlParam = function updateUrlParam(url, method) {
var isProtocolLessUrl = !url.startsWith('http');
var fullUrl = isProtocolLessUrl ? "https://".concat(url) : url;
var urlObject = new URL(fullUrl);
var existingSearchQuery = urlObject.searchParams,
existingHash = urlObject.hash;

for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
rest[_key - 2] = arguments[_key];
}

var paramName = rest[0];
urlObject.hash = '';

if (existingSearchQuery.has(paramName)) {
existingSearchQuery["delete"](paramName);
}

var notModifiedQueryString = urlObject.search.substring(1);
var newQueryParams = [notModifiedQueryString];

_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(existingSearchQuery.keys()).forEach(function (key) {
return existingSearchQuery["delete"](key);
});

existingSearchQuery[method].apply(existingSearchQuery, rest);
var newQueryParamValue = existingSearchQuery.has(paramName) && existingSearchQuery.get(paramName);

if (newQueryParamValue) {
existingSearchQuery["delete"](paramName);
newQueryParams.push("".concat(paramName, "=").concat(newQueryParamValue));
}

var baseUrl = urlObject.toString().replace(isProtocolLessUrl ? urlObject.protocol : '', '');
var newQueryParamsString = newQueryParams.filter(Boolean).join('&');
newQueryParamsString = newQueryParamsString ? "?".concat(newQueryParamsString) : '';
return "".concat(baseUrl).concat(newQueryParamsString).concat(existingHash);
};

var setUrlParam = function setUrlParam(url, paramName, paramValue) {
return updateUrlParam(url, 'set', paramName, paramValue);
};
var removeUrlParam = function removeUrlParam(url, paramName) {
return updateUrlParam(url, 'delete', paramName);
};

/***/ }),
/* 32 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/slicedToArray.js
var slicedToArray = __webpack_require__(8);
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/regenerator/index.js
var regenerator = __webpack_require__(15);
var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/asyncToGenerator.js
var asyncToGenerator = __webpack_require__(20);
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/typeof.js
var helpers_typeof = __webpack_require__(26);
var typeof_default = /*#__PURE__*/__webpack_require__.n(helpers_typeof);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/classCallCheck.js
var classCallCheck = __webpack_require__(3);
var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/assertThisInitialized.js
var assertThisInitialized = __webpack_require__(24);
var assertThisInitialized_default = /*#__PURE__*/__webpack_require__.n(assertThisInitialized);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/createClass.js
var createClass = __webpack_require__(5);
var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js
var possibleConstructorReturn = __webpack_require__(12);
var possibleConstructorReturn_default = /*#__PURE__*/__webpack_require__.n(possibleConstructorReturn);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/getPrototypeOf.js
var getPrototypeOf = __webpack_require__(4);
var getPrototypeOf_default = /*#__PURE__*/__webpack_require__.n(getPrototypeOf);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/inherits.js
var inherits = __webpack_require__(13);
var inherits_default = /*#__PURE__*/__webpack_require__.n(inherits);

// EXTERNAL MODULE: ./src/core/component.js
var component = __webpack_require__(37);

// EXTERNAL MODULE: ./src/core/event/control-event.js
var control_event = __webpack_require__(18);

// EXTERNAL MODULE: ./src/core/event/player-event.js
var player_event = __webpack_require__(0);

// EXTERNAL MODULE: ./src/core/enum/player-error.js
var player_error = __webpack_require__(10);

// EXTERNAL MODULE: ./src/core/enum/error-code.js
var error_code = __webpack_require__(27);

// EXTERNAL MODULE: ./src/core/enum/option-name.js
var option_name = __webpack_require__(1);

// EXTERNAL MODULE: ./src/core/enum/player-component.js
var player_component = __webpack_require__(7);

// CONCATENATED MODULE: ./src/core/util/get-supported-assets.js

/* harmony default export */ var get_supported_assets = (function (sources, renderers, options) {
var list = renderers.slice().sort(function (a, b) {
return a.priority > b.priority;
});
return list.reduce(function (acc, renderer) {
Object.entries(sources).forEach(function (entry) {
var _entry = slicedToArray_default()(entry, 2),
key = _entry[0],
files = _entry[1];

var _files = slicedToArray_default()(files, 1),
file = _files[0];

var url = file.src;
Object.entries(renderer.mediaTypes).forEach(function (entry) {
var _entry2 = slicedToArray_default()(entry, 2),
mediaType = _entry2[0],
mimeType = _entry2[1];

var canPlayType = renderer.canPlayType(mimeType, options);

if (key.toUpperCase() === mediaType && canPlayType) {
acc.push({
url: url,
renderer: renderer,
mimeType: mimeType,
mediaType: mediaType
});
}
});
});
return acc;
}, []);
});
// EXTERNAL MODULE: ./src/core/util/http/index.js + 1 modules
var http = __webpack_require__(22);

// EXTERNAL MODULE: ./src/core/util/core.js
var core = __webpack_require__(19);

// CONCATENATED MODULE: ./src/core/model/media-item.js


function MediaItem(data) {
var id = 'mediaItem_' + core["a" /* default */].generateRandomString(16);
var source = undefined;
var drm = undefined;
var subtitles = undefined;
var stripe = undefined;
var splashscreen = undefined;
var thumbnail = undefined;
var rating = undefined;

if (typeof data !== 'undefined') {
parseJson(data);
}

data = data = {};

function getId() {
return id;
}

function setDrm(_drm) {
drm = _drm;
}

function getDrm() {
return drm;
}

function setSource(value) {
data['source'] = value;
source = value;
}

function getSource() {
return source;
}

function getSubtitles() {
return subtitles;
}

function setSubtitles(_subtitles) {
subtitles = _subtitles;
}

function setStripe(_stripe) {
stripe = _stripe;
}

function getStripe() {
return stripe;
}

function getSplashscreen() {
return splashscreen;
}

function setSplashscreen(value) {
splashscreen = value;
}

function getThumbnail() {
return thumbnail;
}

function setThumbnail(value) {
thumbnail = value;
}

function getRating() {
return rating;
}

function setRating(value) {
rating = value;
}

function getByKey(key) {
return data[key];
}

function parseJson(data) {
setSource(data.sources);
setStripe(data.stripe);
setSubtitles(data.subtitles);
setThumbnail(data.thumbnail);
setSplashscreen(data.splashscreen);
setRating(data.rating);
var drm = data.drm;

if (drm) {
for (var i in drm) {
if (drm.hasOwnProperty(i)) {
if (typeof_default()(drm[i]) === 'object') {
if (i.toLowerCase() === 'fairplay') {
drm[i.toLowerCase()] = {
src: drm[i].src,
cert: drm[i].cert
};
} else {
drm[i.toLowerCase()] = drm[i].src;
}
} else {
drm[i.toLowerCase()] = drm[i];
}

delete drm[i];
}
}

setDrm(drm);
}
}

return {
getByKey: getByKey,
getId: getId,
getDrm: getDrm,
setDrm: setDrm,
getSource: getSource,
setSource: setSource,
getStripe: getStripe,
getSubtitles: getSubtitles,
setThumbnail: setThumbnail,
getThumbnail: getThumbnail,
getSplashscreen: getSplashscreen,
setSplashscreen: setSplashscreen,
getRating: getRating,
setRating: setRating
};
}
// CONCATENATED MODULE: ./src/core/playlist.js




function Playlist(player) {
var options = player.options;
var mediaItems = [];
var mediaItemsHashMap = {};

function fetch() {
var file = options.get(option_name["D" /* FILE */]);
var playlistUrl = options.get(option_name["ib" /* PLAYLIST */]) || options.get(option_name["E" /* FILES */]);

if (file) {
return loadFile(file);
} else if (playlistUrl) {
return loadFiles(playlistUrl);
} else {
return Promise.reject();
}
}

function list() {
return mediaItems;
}

function first() {
return mediaItems[0];
}

function getById(id) {
return mediaItemsHashMap[id];
}

function loadFile(urlOrObject) {
var mediaItem = new MediaItem();
var sources = {};
mediaItems = [];
mediaItemsHashMap = {};

if (typeof urlOrObject === 'string') {
var mediaType = 'mp4';

if (urlOrObject.indexOf('#') !== -1) {
mediaType = urlOrObject.split('#')[1];
}

sources[mediaType] = [{
src: urlOrObject
}];
} else {
for (var i in urlOrObject) {
if (urlOrObject.hasOwnProperty(i)) {
sources[i] = [{
src: urlOrObject[i]
}];
}
}
}

mediaItem.setSource(sources);
mediaItems.push(mediaItem);
var drm = options.get('drm');

if (drm) {
mediaItem.setDrm(drm);
}

mediaItemsHashMap[mediaItem.getId()] = mediaItem;
return Promise.resolve();
}

function loadFiles(urlOrObject) {
mediaItems = [];
mediaItemsHashMap = {};

if (typeof_default()(urlOrObject) === 'object') {
if (Array.isArray(urlOrObject)) {
for (var i = 0; i < urlOrObject.length; i++) {
mediaItems.push(urlOrObject[i]);
}
} else {
mediaItems.push(urlOrObject);
}

return Promise.resolve();
} else {
var _httpConfig$playlist, _httpConfig$playlist2;

var httpConfig = options.get(option_name["N" /* HTTP_CONFIG */]);
var headers = httpConfig === null || httpConfig === void 0 ? void 0 : (_httpConfig$playlist = httpConfig.playlist) === null || _httpConfig$playlist === void 0 ? void 0 : _httpConfig$playlist.headers;
return http["a" /* default */].get(urlOrObject, {
headers: headers,
withCredentials: !!(httpConfig === null || httpConfig === void 0 ? void 0 : (_httpConfig$playlist2 = httpConfig.playlist) === null || _httpConfig$playlist2 === void 0 ? void 0 : _httpConfig$playlist2.withCredentials)
}).then(function (response) {
var data = JSON.parse(response.data);

if (Array.isArray(data)) {
mediaItems = data.map(function (item) {
var mediaItem = new MediaItem(item);
mediaItemsHashMap[mediaItem.getId()] = mediaItem;
return mediaItem;
});
} else {
var mediaItem = new MediaItem(data);
mediaItemsHashMap[mediaItem.getId()] = mediaItem;
mediaItems.push(mediaItem);
}
});
}
}

return {
fetch: fetch,
list: list,
first: first,
getById: getById
};
}
// EXTERNAL MODULE: ./src/core/timeshift.js
var timeshift = __webpack_require__(28);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/defineProperty.js
var defineProperty = __webpack_require__(2);
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);

// EXTERNAL MODULE: ./src/core/util/browser.js
var browser = __webpack_require__(21);

// EXTERNAL MODULE: ./src/core/protection/key-system.js
var key_system = __webpack_require__(30);

// CONCATENATED MODULE: ./src/core/options.js




var _OptionName$AUTO_ADAP, _DEFAULT_SETUP;

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }





var drmSystems = Object.keys(key_system).map(function (drmSystem) {
return drmSystem.toLowerCase();
});
var DEFAULT_SETUP = (_DEFAULT_SETUP = {}, defineProperty_default()(_DEFAULT_SETUP, option_name["c" /* ADVERT_LABEL */], 'REKLAMA: '), defineProperty_default()(_DEFAULT_SETUP, option_name["i" /* AUTO_ADAPTATION */], (_OptionName$AUTO_ADAP = {}, defineProperty_default()(_OptionName$AUTO_ADAP, option_name["j" /* AUTO_ADAPTATION_BY_DROPPED_FRAMES */], false), defineProperty_default()(_OptionName$AUTO_ADAP, option_name["k" /* AUTO_ADAPTATION_BY_RESOLUTION */], false), defineProperty_default()(_OptionName$AUTO_ADAP, option_name["l" /* AUTO_ADAPTATION_MINIMUM_BUFFER_LENGTH */], 0), _OptionName$AUTO_ADAP)), defineProperty_default()(_DEFAULT_SETUP, option_name["f" /* AUTOFOCUS */], true), defineProperty_default()(_DEFAULT_SETUP, option_name["g" /* AUTOPLAY */], true), defineProperty_default()(_DEFAULT_SETUP, option_name["h" /* AUTOPLAY_BLOCKED_RULE */], 'resume'), defineProperty_default()(_DEFAULT_SETUP, option_name["m" /* BUFFER_BEHIND */], 30), defineProperty_default()(_DEFAULT_SETUP, option_name["n" /* BUFFER_TIME */], 2), defineProperty_default()(_DEFAULT_SETUP, option_name["o" /* CACHE_DRM_SESSION_BY_KEY_ID */], true), defineProperty_default()(_DEFAULT_SETUP, option_name["p" /* CONSIDER_DROPPED_FRAMES */], false), defineProperty_default()(_DEFAULT_SETUP, option_name["r" /* CONTROLS_LAYOUT */], 'classic'), defineProperty_default()(_DEFAULT_SETUP, option_name["s" /* CSS_PREFIX */], 'rgpl'), defineProperty_default()(_DEFAULT_SETUP, option_name["q" /* CONTROLS */], 'default'), defineProperty_default()(_DEFAULT_SETUP, option_name["t" /* DEBUG */], false), defineProperty_default()(_DEFAULT_SETUP, option_name["w" /* DEFAULT_GUI_LANGUAGE */], 'pl'), defineProperty_default()(_DEFAULT_SETUP, option_name["u" /* DEFAULT_AUDIO_LANGUAGE */], null), defineProperty_default()(_DEFAULT_SETUP, option_name["v" /* DEFAULT_BITRATE */], null), defineProperty_default()(_DEFAULT_SETUP, option_name["y" /* DISABLE_NATIVE_CONTROLS */], true), defineProperty_default()(_DEFAULT_SETUP, option_name["z" /* DRM */], null), defineProperty_default()(_DEFAULT_SETUP, option_name["A" /* DRM_SYSTEMS */], drmSystems), defineProperty_default()(_DEFAULT_SETUP, option_name["B" /* EXTRA */], {}), defineProperty_default()(_DEFAULT_SETUP, option_name["C" /* FAIRPLAY_CONTENT_TYPE */], 'application/octet-stream'), defineProperty_default()(_DEFAULT_SETUP, option_name["D" /* FILE */], undefined), defineProperty_default()(_DEFAULT_SETUP, option_name["E" /* FILES */], undefined), defineProperty_default()(_DEFAULT_SETUP, option_name["F" /* FIX_APPLE_SITE_SPECIFIC_HACKS */], false), defineProperty_default()(_DEFAULT_SETUP, option_name["H" /* FULLSCREEN */], true), defineProperty_default()(_DEFAULT_SETUP, option_name["J" /* GSTREAM */], undefined), defineProperty_default()(_DEFAULT_SETUP, option_name["K" /* HEIGHT */], 400), defineProperty_default()(_DEFAULT_SETUP, option_name["L" /* HIDE_CONTROLS */], true), defineProperty_default()(_DEFAULT_SETUP, option_name["M" /* HOLDER */], null), defineProperty_default()(_DEFAULT_SETUP, option_name["N" /* HTTP_CONFIG */], {}), defineProperty_default()(_DEFAULT_SETUP, option_name["P" /* IMMEDIATELY_SWITCH */], true), defineProperty_default()(_DEFAULT_SETUP, option_name["Q" /* KEYBOARD_EVENTS */], false), defineProperty_default()(_DEFAULT_SETUP, option_name["S" /* LAST_BITRATE_CACHING */], false), defineProperty_default()(_DEFAULT_SETUP, option_name["U" /* LIVE */], false), defineProperty_default()(_DEFAULT_SETUP, option_name["V" /* LIVE_DELAY */], 0), defineProperty_default()(_DEFAULT_SETUP, option_name["T" /* LAYOUT */], undefined), defineProperty_default()(_DEFAULT_SETUP, option_name["W" /* MAX_AUTO_BITRATE */], null), defineProperty_default()(_DEFAULT_SETUP, option_name["X" /* MAX_BUFFER_LENGTH */], 20), defineProperty_default()(_DEFAULT_SETUP, option_name["Z" /* MIN_AUTO_BITRATE */], null), defineProperty_default()(_DEFAULT_SETUP, option_name["ab" /* MIN_BUFFER_TIME */], null), defineProperty_default()(_DEFAULT_SETUP, option_name["bb" /* MIN_LIVE_DELAY */], 15), defineProperty_default()(_DEFAULT_SETUP, option_name["Y" /* MINIMUM_UPDATE_PERIOD_ENABLED */], true), defineProperty_default()(_DEFAULT_SETUP, option_name["cb" /* MODULES */], []), defineProperty_default()(_DEFAULT_SETUP, option_name["db" /* NAME */], undefined), defineProperty_default()(_DEFAULT_SETUP, option_name["hb" /* PLAYBACK_RATES */], [0.25, 0.5, 1, 1.5, 2]), defineProperty_default()(_DEFAULT_SETUP, option_name["jb" /* PLAYS_INLINE */], false), defineProperty_default()(_DEFAULT_SETUP, option_name["kb" /* POSTER */], undefined), defineProperty_default()(_DEFAULT_SETUP, option_name["fb" /* PAUSE_ON_VIDEO_CLICK */], true), defineProperty_default()(_DEFAULT_SETUP, option_name["lb" /* RECONNECT */], false), defineProperty_default()(_DEFAULT_SETUP, option_name["mb" /* RENDERER_PRIORITY */], ['dash', 'html5']), defineProperty_default()(_DEFAULT_SETUP, option_name["nb" /* ROOT_URL */], null), defineProperty_default()(_DEFAULT_SETUP, option_name["ob" /* SEEK_CHANGE_STEP */], 10), defineProperty_default()(_DEFAULT_SETUP, option_name["pb" /* SEEK_PRECISION */], 'time'), defineProperty_default()(_DEFAULT_SETUP, option_name["rb" /* SETTINGS */], ['profile', 'audio', 'subtitle', 'playbackRate']), defineProperty_default()(_DEFAULT_SETUP, option_name["sb" /* SHOW_BUTTONS_OVER_VIDEO */], true), defineProperty_default()(_DEFAULT_SETUP, option_name["tb" /* SHOW_BUTTONS_OVER_VIDEO_ON_HOVER */], true), defineProperty_default()(_DEFAULT_SETUP, option_name["ub" /* SHOW_JUMP_BUTTONS_OVER_VIDEO */], true), defineProperty_default()(_DEFAULT_SETUP, option_name["vb" /* SHOW_PAUSE_BUTTON_OVER_VIDEO */], true), defineProperty_default()(_DEFAULT_SETUP, option_name["wb" /* SKIN */], {
name: 'default',
url: null
}), defineProperty_default()(_DEFAULT_SETUP, option_name["xb" /* SMART_TV */], false), defineProperty_default()(_DEFAULT_SETUP, option_name["zb" /* START_BUFFER_LENGTH */], 0), defineProperty_default()(_DEFAULT_SETUP, option_name["Ab" /* START_TIME */], 0), defineProperty_default()(_DEFAULT_SETUP, option_name["Bb" /* STREAM_WITH_CREDENTIALS */], false), defineProperty_default()(_DEFAULT_SETUP, option_name["Fb" /* TIMESHIFT_ENABLED */], false), defineProperty_default()(_DEFAULT_SETUP, option_name["Gb" /* TIMESHIFT_PARAMS */], {
dvr: 'dvr',
startTime: 'startTime',
stopTime: 'stopTime'
}), defineProperty_default()(_DEFAULT_SETUP, option_name["Ib" /* TOOLTIPS */], true), defineProperty_default()(_DEFAULT_SETUP, option_name["Lb" /* USE_DOWNLINK_BITRATE */], false), defineProperty_default()(_DEFAULT_SETUP, option_name["Mb" /* UTC_TIME_SERVER */], '//r.dcs.redcdn.pl/utc'), defineProperty_default()(_DEFAULT_SETUP, option_name["Nb" /* UTC_TIME_SERVER_UPDATE_INTERVAL */], 60), defineProperty_default()(_DEFAULT_SETUP, option_name["Eb" /* TIMESHIFT */], null), defineProperty_default()(_DEFAULT_SETUP, option_name["Ob" /* VOLUME */], undefined), defineProperty_default()(_DEFAULT_SETUP, option_name["Pb" /* VOLUME_CHANGE_STEP */], 5), defineProperty_default()(_DEFAULT_SETUP, option_name["Qb" /* VOLUME_LS_ENABLED */], true), defineProperty_default()(_DEFAULT_SETUP, option_name["Rb" /* VOLUME_LS_KEY */], 'redgalaxy-player-volume'), defineProperty_default()(_DEFAULT_SETUP, option_name["Sb" /* VOLUME_MUTED */], undefined), defineProperty_default()(_DEFAULT_SETUP, option_name["Tb" /* VOLUME_MUTED_LS_KEY */], 'redgalaxy-player-volume-muted'), defineProperty_default()(_DEFAULT_SETUP, option_name["Ub" /* VOLUME_TYPE */], 'horizontal'), defineProperty_default()(_DEFAULT_SETUP, option_name["Vb" /* WIDTH */], 600), _DEFAULT_SETUP);

var options_Options = /*#__PURE__*/function () {
function Options() {
classCallCheck_default()(this, Options);

this.options = core["a" /* default */].extendDeep({}, DEFAULT_SETUP);
this.options.name = this.options.name || core["a" /* default */].generateRandomString(10);
}

createClass_default()(Options, [{
key: "get",
value: function get(key) {
if (key in this.options) {
return this.options[key];
}

return null;
}
}, {
key: "set",
value: function set(key, value) {
this.options[key] = value;
}
}, {
key: "update",
value: function update() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

if (options[option_name["i" /* AUTO_ADAPTATION */]] !== false) {
options[option_name["i" /* AUTO_ADAPTATION */]] = _objectSpread({}, DEFAULT_SETUP[option_name["i" /* AUTO_ADAPTATION */]], {}, options[option_name["i" /* AUTO_ADAPTATION */]]);
}

this.options = _objectSpread({}, this.options, {}, options);
this.options.name = "player_renderer_".concat(core["a" /* default */].generateRandomString(10));
this.options.deviceControls = false;

if (browser["a" /* default */].isMobile()) {
this.options.autoplay = true;
}

return this.options;
}
}, {
key: "getWidthWithUnit",
value: function getWidthWithUnit() {
return getValueWithUnit(this.options.width);
}
}, {
key: "getHeightWithUnit",
value: function getHeightWithUnit() {
return getValueWithUnit(this.options.height);
}
}]);

return Options;
}();



function getValueWithUnit(value, defaultUnit) {
var unit = value.toString().replace(/\d+/g, '');

if (!unit.length) {
unit = defaultUnit || 'px';
}

return parseInt(value, 10) + unit;
}
// CONCATENATED MODULE: ./src/core/video-wrapper.js



function VideoWrapper(holderId, options) {
var holder = document.querySelector('#' + holderId);
var cssPrefix = options.get(option_name["s" /* CSS_PREFIX */]);
var components = {};
var oldContainer = holder.querySelector('.' + cssPrefix + '-container');

if (oldContainer) {
holder.removeChild(oldContainer);
}

var container = document.createElement('div');
var rendererContainer = document.createElement('div');

if (!holder) {
return;
}

holder.appendChild(container);
container.appendChild(rendererContainer);
holder.classList.add(cssPrefix);
container.classList.add("".concat(cssPrefix, "-container"));
rendererContainer.classList.add("".concat(cssPrefix, "-renderers"));

if (browser["a" /* default */].isMobile()) {
container.classList.add("".concat(cssPrefix, "-container--mobile"));
}

container.style.background = '#000';
rendererContainer.style.width = '100%';
rendererContainer.style.height = '100%';
updateDims();

function addRenderer(renderer) {
var cleanup = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

if (cleanup) {
rendererContainer.innerHTML = '';
}

renderer.setAttribute('width', '100%');
renderer.setAttribute('height', '100%');
rendererContainer.appendChild(renderer);
}

function addComponent(component, id) {
components[id] = component;
container.appendChild(component.getElm());
}

function removeComponent(id) {
var component = typeof id === 'string' ? components[id] : id;

if (component) {
container.removeChild(component.getElm());
delete components[component.id];
component = null;
}
}

function getComponent(id) {
return components[id];
}

function getEl() {
return container;
}

function getHolderEl() {
return holder;
}

function updateDims() {
holder.style.width = options.getWidthWithUnit();
holder.style.height = options.getHeightWithUnit();
}

function getRendererContainer() {
return rendererContainer;
}

return {
addRenderer: addRenderer,
addComponent: addComponent,
updateDims: updateDims,
getEl: getEl,
getHolderEl: getHolderEl,
getComponent: getComponent,
getRendererContainer: getRendererContainer,
removeComponent: removeComponent
};
}

/* harmony default export */ var video_wrapper = (VideoWrapper);
// CONCATENATED MODULE: ./src/core/player.js
/* unused harmony export renderers */











function _createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }













var players = [];
var player_renderers = [];
var modules = [];

var player_Player = /*#__PURE__*/function (_Component) {
inherits_default()(Player, _Component);

var _super = _createSuper(Player);

createClass_default()(Player, [{
key: "renderers",
get: function get() {
return player_renderers.slice();
}
}], [{
key: "addModule",
value: function addModule(module) {
modules.push(module);
}
}, {
key: "addRenderer",
value: function addRenderer(renderer) {
player_renderers.push(renderer);
}
}, {
key: "players",
get: function get() {
return players.slice();
}
}, {
key: "renderers",
set: function set(_renderers) {
_renderers.forEach(function (renderer) {
return player_renderers.push(renderer);
});
},
get: function get() {
return player_renderers.slice();
}
}, {
key: "modules",
set: function set(_modules) {
_modules.forEach(function (module) {
if (modules.indexOf(module)) {
modules.push(module);
}
});
},
get: function get() {
return modules.slice();
}
}]);

function Player(param) {
var _this;

var autoLoad = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

classCallCheck_default()(this, Player);

_this = _super.call(this);
_this.holderId = undefined;
_this._rendererObj = null;
_this.components = {};
_this.destroyed = false;

switch (typeof_default()(param)) {
case 'object':
_this._rendererObj = param;
break;

case 'string':
autoLoad = true;
_this.holderId = param;
break;

default:
break;
}

_this.options = new options_Options();
_this.playlist = new Playlist(assertThisInitialized_default()(_this));
_this.autoLoad = autoLoad;
_this.renderer = null;
_this.mediaItem = null;
_this.frozen = false;
_this.timeShift = null;
players.push(assertThisInitialized_default()(_this));
return _this;
}

createClass_default()(Player, [{
key: "setup",
value: function setup(_options) {
this.options.update(_options);
this.trigger(player_event["hb" /* SETUP */]);

if (this.autoLoad) {
this.load();
}

return this;
}
}, {
key: "load",
value: function () {
var _load = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee(file) {
return regenerator_default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
this.destroyed = false;

if (this.renderer !== null) {
this.renderer.destroy();
}

if (file) {
this.options.set(option_name["D" /* FILE */], file);
}

return _context.abrupt("return", this._initialize());

case 4:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));

function load(_x) {
return _load.apply(this, arguments);
}

return load;
}()
}, {
key: "_initialize",
value: function () {
var _initialize2 = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee2() {
return regenerator_default.a.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
this.registerModules();
this.timeShift = new timeshift["b" /* default */](this);
this.trigger(player_event["t" /* INITIALIZED */]);
_context2.prev = 3;
_context2.next = 6;
return this.playlist.fetch();

case 6:
this.mediaItem = this.playlist.first();

if (this.mediaItem.getDrm()) {
this.options.set(option_name["z" /* DRM */], this.mediaItem.getDrm());
}

this.trigger(player_event["P" /* PLAYLIST */], this.playlist.list());
_context2.next = 14;
break;

case 11:
_context2.prev = 11;
_context2.t0 = _context2["catch"](3);
this.trigger(player_event["o" /* ERROR */], {
code: 220,
type: 'PLAYLIST_ERROR',
renderer: null,
message: 'Failed to load playlist.'
});

case 14:
if (!this.destroyed) {
_context2.next = 16;
break;
}

return _context2.abrupt("return");

case 16:
if (!this.mediaItem) {
_context2.next = 19;
break;
}

_context2.next = 19;
return this._create();

case 19:
case "end":
return _context2.stop();
}
}
}, _callee2, this, [[3, 11]]);
}));

function _initialize() {
return _initialize2.apply(this, arguments);
}

return _initialize;
}()
}, {
key: "_create",
value: function () {
var _create2 = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee3() {
var _this2 = this;

var _getSupportedAssets, _getSupportedAssets2, asset, create, videoWrapper;

return regenerator_default.a.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
if (!this.destroyed) {
_context3.next = 2;
break;
}

return _context3.abrupt("return");

case 2:
_getSupportedAssets = get_supported_assets(this.mediaItem.getSource(), player_renderers, this.options), _getSupportedAssets2 = slicedToArray_default()(_getSupportedAssets, 1), asset = _getSupportedAssets2[0];

if (asset) {
_context3.next = 5;
break;
}

return _context3.abrupt("return", this.throwNoSupportedRendererError());

case 5:
create = asset.renderer.create;

if (!create) {
_context3.next = 12;
break;
}

_context3.next = 9;
return create(this, this._rendererObj)["catch"](function () {
return _this2.throwNoSupportedRendererError();
});

case 9:
_context3.t0 = _context3.sent;
_context3.next = 13;
break;

case 12:
_context3.t0 = new asset.renderer(this, this._rendererObj);

case 13:
this.renderer = _context3.t0;

if (!(!this.renderer || this.destroyed)) {
_context3.next = 16;
break;
}

return _context3.abrupt("return");

case 16:
this.renderer.setMediaItem(asset);

this._registerEvents();

if (this.holderId) {
videoWrapper = new video_wrapper(this.holderId, this.options);
videoWrapper.addRenderer(this.renderer.getRendererElm());
this.addComponent(videoWrapper, player_component["i" /* VIDEO_WRAPPER */]);
}

this.trigger(player_event["Y" /* READY */], this.renderer);

case 20:
case "end":
return _context3.stop();
}
}
}, _callee3, this);
}));

function _create() {
return _create2.apply(this, arguments);
}

return _create;
}()
}, {
key: "freeze",
value: function freeze() {
this.frozen = true;
}
}, {
key: "unFreeze",
value: function unFreeze() {
this.frozen = false;
}
}, {
key: "addComponent",
value: function addComponent(component, id) {
this.components[id] = component;
}
}, {
key: "getComponent",
value: function getComponent(id) {
return this.components[id];
}
}, {
key: "removeComponent",
value: function removeComponent(component) {
this.components[component.id] = undefined;
delete this.components[component.id];
}
}, {
key: "getRendererObj",
value: function getRendererObj() {
return this._rendererObj;
}
}, {
key: "switchMedia",
value: function switchMedia(mediaItem) {
var _this3 = this;

if (this.renderer) {
this.renderer.destroy();
}

var videoWrapper = this.getComponent(player_component["i" /* VIDEO_WRAPPER */]);
this.renderer = new Renderer(mediaItem, this);
videoWrapper.addRenderer(this.renderer.getRendererElm(), true);
this.renderer.on(player_event["z" /* MONITOR */], function (time, duration) {
return _this3.trigger(player_event["tb" /* TIME */], time, duration);
});
this.renderer.on(player_event["z" /* MONITOR */], function (time, duration) {
return _this3.trigger(player_event["z" /* MONITOR */], time, duration);
});
}
}, {
key: "isIndexMode",
value: function isIndexMode() {
var _this$renderer, _this$renderer$isInde;

return (_this$renderer = this.renderer) === null || _this$renderer === void 0 ? void 0 : (_this$renderer$isInde = _this$renderer.isIndexMode) === null || _this$renderer$isInde === void 0 ? void 0 : _this$renderer$isInde.call(_this$renderer);
}
}, {
key: "getRendererElm",
value: function getRendererElm() {
var _this$renderer2;

return (_this$renderer2 = this.renderer) === null || _this$renderer2 === void 0 ? void 0 : _this$renderer2.getRendererElm();
}
}, {
key: "getMediaType",
value: function getMediaType() {
var _this$renderer3;

return (_this$renderer3 = this.renderer) === null || _this$renderer3 === void 0 ? void 0 : _this$renderer3.rendererType;
}
}, {
key: "getRenderer",
value: function getRenderer() {
return this.renderer;
}
}, {
key: "_registerEvents",
value: function _registerEvents() {
var _this4 = this;

this.renderer.on(player_event["z" /* MONITOR */], this.trigger.bind(this, player_event["tb" /* TIME */]));
this.renderer.on(player_event["z" /* MONITOR */], this.trigger.bind(this, player_event["z" /* MONITOR */]));
this.on(player_event["Y" /* READY */], this.ready.bind(this));
this.on(player_event["S" /* PLAY_REQUEST */], function () {
return _this4._play();
});
this.on(player_event["xb" /* VOLUME_CHANGE_REQUEST */], function (volume) {
return _this4._setVolume(volume);
});
this.on(player_event["yb" /* VOLUME_MUTE_REQUEST */], function (muted) {
return _this4._setMuted(muted);
});
this.on(control_event["SEEK_FROM_TO"], function (currentPosition, newPosition) {
return _this4.trigger(player_event["fb" /* SEEK_TO_REQUEST */], newPosition);
});
this.on(player_event["fb" /* SEEK_TO_REQUEST */], function (timePosition) {
return _this4._seekTo(timePosition);
});
this.on(player_event["db" /* SEEK_REQUEST */], function (percentPosition) {
return _this4._seek(percentPosition);
});
this.on(player_event["ub" /* TOGGLE_PLAY_PAUSE_REQUEST */], function () {
return _this4.togglePlayPause();
});
}
}, {
key: "registerModules",
value: function registerModules() {
var _this5 = this;

var options = this.options.get(option_name["cb" /* MODULES */]);
modules.forEach(function (module) {
if (module.enabled || options.indexOf(module.moduleId) !== -1) {
new module(_this5);
}
});
}
}, {
key: "ready",
value: function ready() {
if (this.options.get(option_name["g" /* AUTOPLAY */])) {
this.renderer.play();
}
}
}, {
key: "onVolumeChanged",
value: function onVolumeChanged(volume) {
if (this.options.get(option_name["Qb" /* VOLUME_LS_ENABLED */])) {
var _localStorage;

(_localStorage = localStorage) === null || _localStorage === void 0 ? void 0 : _localStorage.setItem(this.options.get(option_name["Rb" /* VOLUME_LS_KEY */]), volume);
}
}
}, {
key: "restart",
value: function restart() {
if (!this.frozen) {
if (this.timeShift.isEnabled()) {
this.timeShift.reset();
}

this.renderer.restart();
}

this.trigger(player_event["bb" /* RESTART_REQUEST */]);
}
}, {
key: "switchProfile",
value: function switchProfile(profile) {
var forceSwitch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var immediately = arguments.length > 2 ? arguments[2] : undefined;

if (this.renderer !== null) {
this.renderer.switchProfile(profile, forceSwitch, immediately);
}
}
}, {
key: "switchAudioTrack",
value: function switchAudioTrack(audioTrack, immediately) {
this.renderer.switchAudioTrack(audioTrack, immediately);
}
}, {
key: "getDroppedFrameCount",
value: function getDroppedFrameCount() {
return this.renderer.getDroppedFrameCount();
}
}, {
key: "getDecodedFrameCount",
value: function getDecodedFrameCount() {
return this.renderer.getDecodedFrameCount();
}
}, {
key: "getBuffered",
value: function getBuffered() {
return this.renderer.getBuffered();
}
}, {
key: "getPlayed",
value: function getPlayed() {
return this.renderer.getPlayed();
}
}, {
key: "getProfile",
value: function getProfile() {
return this.renderer.getProfile();
}
}, {
key: "_play",
value: function _play() {
if (!this.frozen) {
this.renderer.play();
}
}
}, {
key: "play",
value: function play() {
var _this6 = this;

return new Promise(function (resolve, reject) {
_this6.trigger(player_event["S" /* PLAY_REQUEST */]);

var removeListeners = function removeListeners() {
_this6.off(player_event["R" /* PLAY_PROMISE_RESOLVED */], resolve);

_this6.off(player_event["Q" /* PLAY_INTERRUPTED */], reject);
};

var _resolve = function _resolve() {
removeListeners();
resolve();
};

var _reject = function _reject(error) {
removeListeners();
reject(error);
};

_this6.once(player_event["R" /* PLAY_PROMISE_RESOLVED */], _resolve);

_this6.once(player_event["Q" /* PLAY_INTERRUPTED */], _reject);
});
}
}, {
key: "pause",
value: function pause() {
if (!this.frozen) {
this.renderer.pause();
}

this.trigger(player_event["H" /* PAUSE_REQUEST */]);
}
}, {
key: "stop",
value: function stop() {
var silent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
this.renderer.stop();

if (!silent) {
this.trigger(player_event["jb" /* STOP_REQUEST */]);
}
}
}, {
key: "head",
value: function head() {
this.seek(100);
}
}, {
key: "isPaused",
value: function isPaused() {
if (!this.renderer) {
return false;
}

return this.renderer.isPaused;
}
}, {
key: "resize",
value: function resize(width, height) {
this.trigger(player_event["ab" /* RESIZE */], width, height);
}
}, {
key: "setVolume",
value: function setVolume(volume) {
this.trigger(player_event["xb" /* VOLUME_CHANGE_REQUEST */], volume);
}
}, {
key: "_setVolume",
value: function _setVolume(volume) {
this.renderer.setVolume(volume);
}
}, {
key: "getVolume",
value: function getVolume() {
return this.renderer.getVolume();
}
}, {
key: "_setMuted",
value: function _setMuted(muted) {
var _this$renderer4;

(_this$renderer4 = this.renderer) === null || _this$renderer4 === void 0 ? void 0 : _this$renderer4.setMuted(muted);
}
}, {
key: "isMuted",
value: function isMuted() {
var _this$renderer5;

return (_this$renderer5 = this.renderer) === null || _this$renderer5 === void 0 ? void 0 : _this$renderer5.isMuted();
}
}, {
key: "mute",
value: function mute() {
return this._setMuted(true);
}
}, {
key: "unMute",
value: function unMute() {
return this._setMuted(false);
}
}, {
key: "volumeUp",
value: function volumeUp() {
var step = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
var volume = parseFloat(this.renderer.getVolume());
volume += step / 10;

if (volume > 1) {
volume = 1;
}

this.renderer.setVolume(volume * 100);
}
}, {
key: "volumeDown",
value: function volumeDown() {
var step = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
var volume = parseFloat(this.renderer.getVolume());
volume -= step / 10;

if (volume < 0) {
volume = 0;
}

this.renderer.setVolume(volume * 100);
}
}, {
key: "setDrm",
value: function setDrm(drm) {
this.options.set('drm', drm);
}
}, {
key: "isStreamStarted",
value: function isStreamStarted() {
var _this$renderer6;

return (_this$renderer6 = this.renderer) === null || _this$renderer6 === void 0 ? void 0 : _this$renderer6.isStarted;
}
}, {
key: "isStreamPaused",
value: function isStreamPaused() {
var _this$renderer7;

return (_this$renderer7 = this.renderer) === null || _this$renderer7 === void 0 ? void 0 : _this$renderer7.isPaused;
}
}, {
key: "isLive",
value: function isLive() {
return this.renderer.isLive();
}
}, {
key: "isLiveWithoutTimeShift",
value: function isLiveWithoutTimeShift() {
return this.isLive() && !this.timeShift.isEnabled();
}
}, {
key: "getMediaItem",
value: function getMediaItem() {
return this.mediaItem;
}
}, {
key: "getUrl",
value: function getUrl() {
var _this$renderer8;

return (_this$renderer8 = this.renderer) === null || _this$renderer8 === void 0 ? void 0 : _this$renderer8.url;
}
}, {
key: "getCurrentTime",
value: function getCurrentTime() {
return null === this.renderer ? NaN : this.renderer.getCurrentTime();
}
}, {
key: "getCurrentTimeUTC",
value: function getCurrentTimeUTC() {
var time = this.getCurrentTime();

if (this.isLive() && this.timeShift.isEnabled()) {
time += this.getLiveStartUTC();
}

return time;
}
}, {
key: "getDuration",
value: function getDuration() {
return null === this.renderer ? NaN : this.renderer.getDuration();
}
}, {
key: "getBufferLength",
value: function getBufferLength() {
return null === this.renderer ? NaN : this.renderer.getBufferLength();
}
}, {
key: "setMaxBufferLength",
value: function setMaxBufferLength(length) {
var _this$renderer9;

(_this$renderer9 = this.renderer) === null || _this$renderer9 === void 0 ? void 0 : _this$renderer9.setMaxBufferLength(length);
this.options.set('maxBufferLength', length);
}
}, {
key: "getCurrentProfile",
value: function getCurrentProfile() {
var _this$renderer10;

return (_this$renderer10 = this.renderer) === null || _this$renderer10 === void 0 ? void 0 : _this$renderer10.getCurrentProfile();
}
}, {
key: "getProfiles",
value: function getProfiles() {
return this.renderer.getProfiles();
}
}, {
key: "getAudioTracks",
value: function getAudioTracks() {
return this.renderer.getAudioTracks();
}
}, {
key: "getCurrentAudioTrack",
value: function getCurrentAudioTrack() {
return this.renderer.getCurrentAudioTrack();
}
}, {
key: "getTextTracks",
value: function getTextTracks() {
return this.renderer.getTextTracks();
}
}, {
key: "seek",
value: function seek() {
var _this7 = this;

for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

return this._createSeekPromise(function () {
return _this7.trigger.apply(_this7, [player_event["db" /* SEEK_REQUEST */]].concat(args));
});
}
}, {
key: "seekTo",
value: function seekTo() {
var _this8 = this;

for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}

return this._createSeekPromise(function () {
return _this8.trigger.apply(_this8, [player_event["fb" /* SEEK_TO_REQUEST */]].concat(args));
});
}
}, {
key: "seekToHead",
value: function seekToHead() {
var _this9 = this;

return this._createSeekPromise(function () {
return _this9.renderer.seekToHead();
});
}
}, {
key: "_createSeekPromise",
value: function _createSeekPromise(fn) {
var _this10 = this;

return new Promise(function (resolve) {
_this10.once(player_event["cb" /* SEEK_END */], resolve);

fn();
});
}
}, {
key: "_seek",
value: function _seek() {
if (!this.frozen) {
if (this.timeShift.isLive()) {
this.timeShift.setMode(timeshift["a" /* TimeShiftMode */].LIVE_DELAYED);
}

for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}

this.renderer.seek.apply(this.renderer, args);
}
}
}, {
key: "_seekTo",
value: function _seekTo() {
if (!this.frozen) {
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
args[_key4] = arguments[_key4];
}

this.renderer.seekTo.apply(this.renderer, args);
}
}
}, {
key: "updateTimeShift",
value: function updateTimeShift(timeShiftObj) {
this.options.set(option_name["Eb" /* TIMESHIFT */], timeShiftObj);
this.timeShift.update();
}
}, {
key: "togglePlayPause",
value: function togglePlayPause() {
if (this.isPaused()) {
if (!this.timeShift.isEnabled() && this.isLive()) {
this.seekToHead();
}

this.play();
} else {
this.pause();
}
}
}, {
key: "getTimeShift",
value: function getTimeShift() {
return this.timeShift;
}
/*
Deprecated method
*/

}, {
key: "getTimeShiftStart",
value: function getTimeShiftStart() {
return this.timeShift.getStart();
}
/*
Deprecated method
*/

}, {
key: "getTimeShiftHead",
value: function getTimeShiftHead() {
return this.timeShift.getLiveNowUTC();
}
}, {
key: "getLiveHeadUTC",
value: function getLiveHeadUTC() {
return this.timeShift.getLiveNowUTC() - this.getLiveDelay();
}
}, {
key: "getLiveNowUTC",
value: function getLiveNowUTC() {
return this.timeShift.getLiveNowUTC();
}
}, {
key: "getLiveStartUTC",
value: function getLiveStartUTC() {
return this.timeShift.getStart();
}
}, {
key: "getLiveDelay",
value: function getLiveDelay() {
return this.isLive() && this.renderer.getLiveDelay() || 0;
}
}, {
key: "getLiveLatency",
value: function getLiveLatency() {
var currentTime = this.getCurrentTime();
var liveStartUTC = this.isLive() && !this.timeShift.isEnabled() ? 0 : this.getLiveStartUTC();
var latency = this.getLiveNowUTC() - liveStartUTC - currentTime;

if (latency < 0 || currentTime <= 0) {
latency = 0;
}

return latency;
}
}, {
key: "getCurrentPeriod",
value: function getCurrentPeriod() {
var _this$renderer11;

return (_this$renderer11 = this.renderer) === null || _this$renderer11 === void 0 ? void 0 : _this$renderer11.getCurrentPeriod();
}
}, {
key: "getDownloadSpeed",
value: function getDownloadSpeed() {
return this.renderer.getDownloadSpeed();
}
}, {
key: "getPlaybackRate",
value: function getPlaybackRate() {
return this.renderer.getPlaybackRate();
}
}, {
key: "setPlaybackRate",
value: function setPlaybackRate(playbackRate) {
this.renderer.setPlaybackRate(playbackRate);
}
}, {
key: "getOptions",
value: function getOptions() {
return this.options.options;
}
}, {
key: "throwNoSupportedRendererError",
value: function throwNoSupportedRendererError() {
this.trigger(player_event["o" /* ERROR */], {
code: error_code["a" /* default */][player_error["a" /* default */].NO_SUPPORTED_RENDERER],
type: player_error["a" /* default */].NO_SUPPORTED_RENDERER,
renderer: null,
message: 'Given media file is not supported by any renderer.'
});
}
}, {
key: "destroy",
value: function destroy() {
this.destroyed = true;
this.trigger(player_event["l" /* DESTROY */], this.getCurrentTime());
this.off();

if (this.renderer) {
this.renderer.destroy();
}

if (players.indexOf(this) !== -1) {
players.splice(players.indexOf(this), 1);
}
}
}]);

return Player;
}(component["a" /* default */]);


/* harmony default export */ var core_player = __webpack_exports__["a"] = (player_Player);

/***/ }),
/* 33 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2);
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_2__);




var _LEVEL_TO_ALPHA;

var Level = {
ALL: 'all',
ERROR: 'error',
INFO: 'info',
TRACE: 'trace',
WARN: 'warn'
};
var LEVEL_TO_ALPHA = (_LEVEL_TO_ALPHA = {}, _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_2___default()(_LEVEL_TO_ALPHA, Level.INFO, '1'), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_2___default()(_LEVEL_TO_ALPHA, Level.WARN, '1'), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_2___default()(_LEVEL_TO_ALPHA, Level.ERROR, '1'), _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_2___default()(_LEVEL_TO_ALPHA, Level.TRACE, '0.5'), _LEVEL_TO_ALPHA);
var DEFAULT_BACKGROUND_COLOR = '#f0f';
var LABEL_TO_BACKGROUND_COLOR = {
'video-stream': '#109fff',
'audio-stream': '#33a700',
'manifest': '#ba0037',
'period': '#f3750f'
};

var hexToRGBA = function hexToRGBA(hex, alpha) {
var hexWithoutHash = hex.replace('#', '');
var isHash6CharsLong = hexWithoutHash.length === 6;
var r = parseInt(isHash6CharsLong ? hexWithoutHash.slice(0, 2) : hexWithoutHash.slice(0, 1), 16);
var g = parseInt(isHash6CharsLong ? hexWithoutHash.slice(2, 4) : hexWithoutHash.slice(1, 2), 16);
var b = parseInt(isHash6CharsLong ? hexWithoutHash.slice(4, 6) : hexWithoutHash.slice(2, 3), 16);
return "rgba(".concat(r, ",").concat(g, ",").concat(b, ",").concat(alpha, ")");
};

var Logger = /*#__PURE__*/function () {
function Logger(label, color) {
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default()(this, Logger);

this.label = label;
this.color = color;
this.enabledLevels = [];
}

_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default()(Logger, [{
key: "setLevel",
value: function setLevel() {
var _this = this;

for (var _len = arguments.length, levels = new Array(_len), _key = 0; _key < _len; _key++) {
levels[_key] = arguments[_key];
}

levels === null || levels === void 0 ? void 0 : levels.forEach(function (level) {
if (!_this.enabledLevels.includes(level)) {
_this.enabledLevels.push(level);
}
});
}
}, {
key: "removeLevel",
value: function removeLevel() {
var _this2 = this;

for (var _len2 = arguments.length, levels = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
levels[_key2] = arguments[_key2];
}

levels === null || levels === void 0 ? void 0 : levels.forEach(function (level) {
var index = _this2.enabledLevels.indexOf(level);

if (index !== -1) {
_this2.enabledLevels.splice(index, 1);
}
});
}
}, {
key: "info",
value: function info(msg) {
this._print('log', msg, Level.INFO);
}
}, {
key: "trace",
value: function trace(msg) {
this._print('log', msg, Level.TRACE);
}
}, {
key: "warn",
value: function warn(msg) {
this._print('warn', msg, Level.WARN);
}
}, {
key: "error",
value: function error(msg) {
this._print('error', msg, Level.ERROR);
}
}, {
key: "_print",
value: function _print(type, msg, level) {
if (!this.isEnabled(level)) {
return;
}

var color = this.color || LABEL_TO_BACKGROUND_COLOR[this.label] || DEFAULT_BACKGROUND_COLOR;
var rgbaColor = hexToRGBA(color, LEVEL_TO_ALPHA[level]);
console[type]("%c".concat(this.label), "background: ".concat(rgbaColor, "; color: #fff; padding: 1px 2px"), msg);
}
}, {
key: "isEnabled",
value: function isEnabled(level) {
return this.enabledLevels.includes(level) || this.enabledLevels.includes(Level.ALL);
}
}]);

return Logger;
}();

var LoggerManager = /*#__PURE__*/function () {
function LoggerManager() {
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default()(this, LoggerManager);

this.loggers = [];
this.Level = Level;
}

_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default()(LoggerManager, [{
key: "get",
value: function get(label, color) {
return this._find(label) || this._create(label, color);
}
}, {
key: "_create",
value: function _create(label, color) {
var logger = new Logger(label, color);
this.loggers.push(logger);
return logger;
}
}, {
key: "_find",
value: function _find(label) {
return this.loggers.find(function (logger) {
return logger.label === label;
});
}
}, {
key: "getLabels",
value: function getLabels() {
return this.loggers.map(function (_ref) {
var label = _ref.label;
return label;
});
}
}]);

return LoggerManager;
}();

var loggerManager = new LoggerManager();
Object.assign(loggerManager, Level);
/* harmony default export */ __webpack_exports__["a"] = (loggerManager);

/***/ }),
/* 34 */
/***/ (function(module, exports, __webpack_require__) {

var superPropBase = __webpack_require__(58);

function _get(target, property, receiver) {
if (typeof Reflect !== "undefined" && Reflect.get) {
module.exports = _get = Reflect.get;
} else {
module.exports = _get = function _get(target, property, receiver) {
var base = superPropBase(target, property);
if (!base) return;
var desc = Object.getOwnPropertyDescriptor(base, property);

if (desc.get) {
return desc.get.call(receiver);
}

return desc.value;
};
}

return _get(target, property, receiver || target);
}

module.exports = _get;

/***/ }),
/* 35 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* unused harmony export globals */
/* unused harmony export addModule */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return addGlobal; });
/* unused harmony export setPlayerInfo */
/* harmony import */ var _info__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(39);

var globals = [];
var Global = {};

var addModule = function addModule(module) {
globals.forEach(function (global) {
window[global] && window[global].Player && window[global].Player.addModule(module);
});
};

var setPlayerInfo = function setPlayerInfo(info) {
Object.assign(Global, info);
};

var addGlobal = function addGlobal(global) {
window[global] = window[global] || Global;
globals.push(global);
}; // todo: move to app


setPlayerInfo(_info__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"]);

/* harmony default export */ __webpack_exports__["b"] = (Global);

/***/ }),
/* 36 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony import */ var _core_enum_option_name__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
/* harmony import */ var _core_util_http__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(22);
/* harmony import */ var _core_util_timer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(25);



var localOffset = 0;

function UTCTimeManager(player) {
var options = player.options;
var updateInterval = options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_0__[/* UTC_TIME_SERVER_UPDATE_INTERVAL */ "Nb"]) * 1000;
var timer = new _core_util_timer__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"](updateInterval, updateTime, false);
var utcTime = -1;
var url;

function init(_url) {
url = (_url || options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_0__[/* UTC_TIME_SERVER */ "Mb"])).replace('http:', '');

if (updateInterval > 0) {
timer.start();
}

return _getUTCTime();
}

function stop() {
timer.stop();
}

function _getUTCTime() {
return new Promise(function (resolve) {
_core_util_http__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].get(url).then(function (response) {
var now = Date.now();
var utcTimeStamp = new Date(response.data).getTime() || now;
utcTime = new Date(utcTimeStamp).getTime();
localOffset = now - utcTime;
resolve(getTime());
})["catch"](function () {
utcTime = new Date().getTime();
localOffset = 0;
resolve(getTime());
});
});
}

function updateTime() {
_getUTCTime();
}

function getTime() {
if (utcTime < 0) {
return -1;
}

return UTCTimeManager.getTime();
}

return {
init: init,
stop: stop,
getTime: getTime
};
}

UTCTimeManager.getTime = function () {
return (Date.now() - localOffset) / 1000;
};

/* harmony default export */ __webpack_exports__["a"] = (UTCTimeManager);

/***/ }),
/* 37 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Component; });
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(12);
/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(13);
/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _util_event_emitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(17);





function _createSuper(Derived) { return function () { var Super = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_2___default()(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_2___default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_1___default()(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }



var Component = /*#__PURE__*/function (_EventEmitter) {
_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_3___default()(Component, _EventEmitter);

var _super = _createSuper(Component);

function Component() {
_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default()(this, Component);

return _super.apply(this, arguments);
}

return Component;
}(_util_event_emitter__WEBPACK_IMPORTED_MODULE_4__[/* default */ "a"]);



/***/ }),
/* 38 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AudioTrack; });
function AudioTrack(track) {
var accessibility = track.accessibility,
codecs = track.codecs,
enabled = track.enabled,
id = track.id,
kind = track.kind,
label = track.label,
lang = track.lang,
language = track.language,
mimeType = track.mimeType,
role = track.role;
this.accessibility = accessibility;
this.codecs = codecs;
this.enabled = enabled;
this.id = id;
this.kind = kind;
this.label = label;
this.lang = lang || language;
this.mimeType = mimeType;
this.role = role;
}

/***/ }),
/* 39 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
var PlayerInfo = {
VERSION: "2.16.2",
BUILD: "2021-11-15 16:11:32",
ROOT_URL: "//r.dcs.redcdn.pl/file/o2/web/player/redcdn/",
REVISION: "2fe2175"
};
PlayerInfo.INFO = "version: ".concat(PlayerInfo.VERSION, ", build: ").concat(PlayerInfo.BUILD, ", revision: ").concat(PlayerInfo.REVISION);
/* harmony default export */ __webpack_exports__["a"] = (PlayerInfo);

/***/ }),
/* 40 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* unused harmony export getBufferRange */
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return _getBufferLengthFromTime; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return VideoEvents; });
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16);
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _util_browser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(21);
/* harmony import */ var _util_event_emitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(17);
/* harmony import */ var _core_enum_option_name__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1);
/* harmony import */ var _event_player_event__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(0);





var VideoEvents = ['timeupdate', 'progress', 'seeking', 'play', 'playing', 'ended', 'waiting', 'pause', 'seeked', 'loadedmetadata', 'loadeddata', 'loadstart', 'stalled', 'error', 'canplay', 'ratechange', 'volumechange'];
MediaElement.prototype = Object.create(_util_event_emitter__WEBPACK_IMPORTED_MODULE_2__[/* default */ "a"].prototype);

function MediaElement(_video) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var ctx = this;

var video = _video || document.createElement('video');

var callbacks = [];
var busy = false;
video.setAttribute('width', '100%');
video.setAttribute('height', '100%');

if (options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_3__[/* AUTOPLAY */ "g"])) {
video.setAttribute('autoplay', 'autoplay');
}

if (options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_3__[/* PLAYS_INLINE */ "jb"])) {
video.setAttribute(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_3__[/* PLAYS_INLINE */ "jb"].toLowerCase(), '');
}

video.setAttribute('crossorigin', 'anonymous');
var poster = options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_3__[/* POSTER */ "kb"]);

if (poster) {
video.setAttribute('poster', poster);
}

if (_util_browser__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"].isMobile()) {
video.setAttribute('autoplay', 'autoplay');
}

if (options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_3__[/* DISABLE_NATIVE_CONTROLS */ "y"])) {
video.removeAttribute('controls');
}

function seek(time) {
video.currentTime = time;
}

function off() {
ctx.off();
unRegisterEvents();
}

function unRegisterEvents() {
ctx.off();
callbacks.forEach(function (callback) {
video.removeEventListener(callback.event, callback.fn);
});
}

function load() {
try {
video.load();
} catch (e) {}
}

function isPaused() {
return video.paused;
}

function getVolume() {
return video.volume;
}

function setVolume(_volume) {
video.volume = _volume;
}

function setMuted(muted) {
video.muted = muted;
}

function isMuted() {
return video.muted;
}

function getSource() {
return video.src;
}

function setSource(source) {
video.src = source;
}

function removeSource() {
video.removeAttribute('src');
}

function pause() {
if (busy) {
return;
}

video.pause();
}

function play() {
if (busy) {
return;
}

var playPromise = video.play();

if (playPromise === null || playPromise === void 0 ? void 0 : playPromise["catch"]) {
busy = true;
playPromise["catch"](function (error) {
return ctx.trigger(_event_player_event__WEBPACK_IMPORTED_MODULE_4__[/* PLAY_INTERRUPTED */ "Q"], error);
}).then(function (e) {
busy = false;
ctx.trigger(_event_player_event__WEBPACK_IMPORTED_MODULE_4__[/* PLAY_PROMISE_RESOLVED */ "R"]);
});
}

return playPromise;
}

function getDuration() {
return video.duration;
}

function getWidth() {
return video.offsetWidth;
}

function getHeight() {
return video.offsetHeight;
}

function getNativeAudioTracks() {
return Array.from(video.audioTracks || []);
}

function getNativeTextTracks() {
return video.textTracks;
}

function addNativeTextTracks(tracks) {
var override = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

// MacOS Safari provides extra empty TextTrack with empty label and language
var hasFilledTracks = _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(video.textTracks).some(function (track) {
return track.language || track.label;
});

if (override || !hasFilledTracks) {
tracks.forEach(function (track) {
var textTrack = video.addTextTrack('subtitles', track.language, track.language);
textTrack.customCreated = true;

if (track.trackId) {
textTrack.trackId = track.trackId;
}
});
}
}

function registerEvents() {
unRegisterEvents();
VideoEvents.forEach(function (event) {
var callback = {
fn: function fn(e) {
ctx.trigger.call(ctx, event, e);
},
name: event
};
video.addEventListener(callback.name, callback.fn);
callbacks.push(callback);
});
}

function setPlaybackRate(playbackRate) {
video.playbackRate = playbackRate;
}

function getPlaybackRate() {
return video.playbackRate;
}

registerEvents();
return {
on: this.on.bind(this),
once: this.once.bind(this),
off: off,
seek: seek,
load: load,
getVolume: getVolume,
setVolume: setVolume,
setMuted: setMuted,
getSource: getSource,
setSource: setSource,
removeSource: removeSource,
pause: pause,
play: play,
getDuration: getDuration,
getNativeAudioTracks: getNativeAudioTracks,
getNativeTextTracks: getNativeTextTracks,
addNativeTextTracks: addNativeTextTracks,
getWidth: getWidth,
getHeight: getHeight,
getPlaybackRate: getPlaybackRate,
setPlaybackRate: setPlaybackRate,
isPaused: isPaused,
isMuted: isMuted,
getVideo: function getVideo() {
return video;
},

get height() {
return video.offsetHeight;
},

getCurrentTime: function getCurrentTime() {
return video.currentTime;
},
getBufferLengthFromTime: function getBufferLengthFromTime(time) {
return _getBufferLengthFromTime(video, time);
},
getBufferLength: function getBufferLength() {
return _getBufferLengthFromTime(video, video.currentTime);
},
getBuffered: function getBuffered() {
return video.buffered;
},
getPlayed: function getPlayed() {
return video.played;
},
getBufferRange: function getBufferRange(startTime, endTime) {
return _getBufferRange(video, startTime, endTime);
},
getReadyState: function getReadyState() {
return video.readyState;
},
getDecodedFrameCount: function getDecodedFrameCount() {
if (HTMLVideoElement.prototype.getVideoPlaybackQuality) {
return video.getVideoPlaybackQuality().totalVideoFrames;
}

return 'webkitDecodedFrameCount' in video ? video.webkitDecodedFrameCount : -1;
},
getDroppedFrameCount: function getDroppedFrameCount() {
if (HTMLVideoElement.prototype.getVideoPlaybackQuality) {
return video.getVideoPlaybackQuality().droppedVideoFrames;
}

return 'webkitDroppedFrameCount' in video ? video.webkitDroppedFrameCount : -1;
},
hasBuffered: function hasBuffered() {
return !!video.buffered.length;
},
hasPlayed: function hasPlayed() {
return !!video.played.length;
},
isSeeking: function isSeeking() {
return video.seeking;
}
};
}

function _getBufferLengthFromTime(video, time) {
var length = 0;
var start;
var end;

if (video.buffered.length) {
for (var i = 0; i < video.buffered.length; i++) {
start = video.buffered.start(i);
end = video.buffered.end(i);

if (start <= time && end >= time) {
length = end - time;
}
}
}

return length;
}

function _getBufferRange(video, startTime) {
var endTime = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Number.MAX_VALUE;
var buffered = video.buffered || [];

for (var i = 0; i < buffered.length; i++) {
var start = buffered.start(i);
var end = buffered.end(i);

if (start >= startTime && start < endTime) {
return {
start: start,
end: end
};
}
}

return null;
}




/* harmony default export */ __webpack_exports__["b"] = (MediaElement);

/***/ }),
/* 41 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(24);
/* harmony import */ var _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(12);
/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(4);
/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(13);
/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var _core_util_event_emitter__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(17);
/* harmony import */ var _core_model_media_element__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(40);
/* harmony import */ var _core_enum_option_name__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1);
/* harmony import */ var _core_enum_player_component__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(7);
/* harmony import */ var _core_event_player_event__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(0);
/* harmony import */ var _core_enum_player_error__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(10);
/* harmony import */ var _core_enum_error_code__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(27);
/* harmony import */ var _core_util_timer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(25);







function _createSuper(Derived) { return function () { var Super = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4___default()(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_4___default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_3___default()(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }









var DEFAULT_VOLUME = 50;
var MONITOR_INTERVAL = 350; //[ms]

var PLAYBACK_RATE_MIN_LATENCY = 5;

var BaseRenderer = /*#__PURE__*/function (_EventEmitter) {
_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_5___default()(BaseRenderer, _EventEmitter);

var _super = _createSuper(BaseRenderer);

function BaseRenderer(player, video) {
var _this;

_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_0___default()(this, BaseRenderer);

_this = _super.call(this);
_this.player = player;
_this.options = player.options;
_this.timeShift = _this.player.timeShift;
_this.isStarted = false;
_this.isPaused = false;
_this.url = null;
_this.baseUrl = null;
_this.lastEvent = null;
_this.mediaItem = undefined;
_this.timer = new _core_util_timer__WEBPACK_IMPORTED_MODULE_13__[/* default */ "a"](MONITOR_INTERVAL, function () {
return _this.monitor();
});
_this.currentRenderer = _babel_runtime_helpers_assertThisInitialized__WEBPACK_IMPORTED_MODULE_2___default()(_this);
_this.protectionManger = undefined;
_this.initialLatency = undefined;
_this.volumeLocalStorageKey = _this.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_8__[/* VOLUME_LS_KEY */ "Rb"]);
_this.volumeMutedLocalStorageKey = _this.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_8__[/* VOLUME_MUTED_LS_KEY */ "Tb"]);
_this.mediaElement = new _core_model_media_element__WEBPACK_IMPORTED_MODULE_7__[/* default */ "b"](video || document.createElement('video'), _this.options);
player.addComponent(_this.mediaElement, _core_enum_player_component__WEBPACK_IMPORTED_MODULE_9__[/* MEDIA_ELEMENT */ "d"]);

_this.updateVolume();

return _this;
}

_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1___default()(BaseRenderer, [{
key: "monitor",
value: function monitor() {
this.guardLivePlaybackRate();
this.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* MONITOR */ "z"], this.getCurrentTime(), this.getDuration());
}
}, {
key: "guardLivePlaybackRate",
value: function guardLivePlaybackRate() {
if (!this.isLive() && this.getPlaybackRate() === 1) {
return;
}

if (this.player.getLiveLatency() < PLAYBACK_RATE_MIN_LATENCY || this.getCurrentTime() < 0) {
this.setPlaybackRate(1);
}
}
}, {
key: "setMediaItem",
value: function setMediaItem(mediaItem) {
this.mediaItem = mediaItem;
this.url = mediaItem.url;
}
}, {
key: "updateVolume",
value: function updateVolume() {
var lsVolume = 0;
var lsMuted = false;

if (this.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_8__[/* VOLUME_LS_ENABLED */ "Qb"])) {
var _localStorage, _localStorage2;

lsVolume = parseFloat((_localStorage = localStorage) === null || _localStorage === void 0 ? void 0 : _localStorage.getItem(this.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_8__[/* VOLUME_LS_KEY */ "Rb"])));
lsMuted = ((_localStorage2 = localStorage) === null || _localStorage2 === void 0 ? void 0 : _localStorage2.getItem(this.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_8__[/* VOLUME_MUTED_LS_KEY */ "Tb"]))) === 'true';
}

var optsVolume = this.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_8__[/* VOLUME */ "Ob"]);
var optsMuted = this.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_8__[/* VOLUME_MUTED */ "Sb"]);
var volume = optsVolume !== undefined ? optsVolume : lsVolume || DEFAULT_VOLUME;
this.setVolume(volume);
var muted = optsMuted !== undefined ? optsMuted : lsMuted;

if (muted) {
this.setMuted(muted);
}
}
}, {
key: "updateLocalStorage",
value: function updateLocalStorage() {
if (this.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_8__[/* VOLUME_LS_ENABLED */ "Qb"])) {
var _localStorage3, _localStorage4;

(_localStorage3 = localStorage) === null || _localStorage3 === void 0 ? void 0 : _localStorage3.setItem(this.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_8__[/* VOLUME_LS_KEY */ "Rb"]), this.getVolume());
(_localStorage4 = localStorage) === null || _localStorage4 === void 0 ? void 0 : _localStorage4.setItem(this.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_8__[/* VOLUME_MUTED_LS_KEY */ "Tb"]), this.isMuted());
}
}
}, {
key: "getRendererElm",
value: function getRendererElm() {
return this.mediaElement.getVideo();
} // todo: remove

}, {
key: "getVideo",
value: function getVideo() {
return this.mediaElement.getVideo();
}
}, {
key: "isMuted",
value: function isMuted() {
return this.mediaElement.isMuted();
}
}, {
key: "setMuted",
value: function setMuted(muted) {
this.mediaElement.setMuted(muted);

if (!muted && this.getVolume() === 0) {
this.setVolume(DEFAULT_VOLUME);
}
}
}, {
key: "getVolume",
value: function getVolume() {
return this.mediaElement.getVolume() * 100;
}
}, {
key: "getCurrentProfile",
value: function getCurrentProfile() {
return 0;
}
}, {
key: "setVolume",
value: function setVolume(volume) {
if (volume > 100) {
volume = 100;
}

if (volume < 0) {
volume = 0;
}

this.mediaElement.setVolume(volume / 100);

if (volume === 0) {
this.setMuted(true);
}
}
}, {
key: "seek",
value: function seek(percentPosition) {
this.seekTo(this.getDuration() / 100 * percentPosition);
}
}, {
key: "seekTo",
value: function seekTo(position) {
this.triggerOnSeekStartEvents();
this.mediaElement.seek(position);
}
}, {
key: "seekToHead",
value: function seekToHead() {
var duration = Math.min(this.getDuration(), Number.MAX_SAFE_INTEGER);
this.seekTo(duration - (this.isLive() ? this.getLiveDelay() : 0));
}
}, {
key: "getDroppedFrameCount",
value: function getDroppedFrameCount() {
return this.mediaElement.getDroppedFrameCount();
}
}, {
key: "getDecodedFrameCount",
value: function getDecodedFrameCount() {
return this.mediaElement.getDecodedFrameCount();
}
}, {
key: "getPlayed",
value: function getPlayed() {
return this.mediaElement.getPlayed();
}
}, {
key: "getBuffered",
value: function getBuffered() {
return this.mediaElement.getBuffered();
}
}, {
key: "getDownloadSpeed",
value: function getDownloadSpeed() {
return -1;
}
}, {
key: "getPlaybackRate",
value: function getPlaybackRate() {
return this.mediaElement.getPlaybackRate();
}
}, {
key: "setPlaybackRate",
value: function setPlaybackRate(playbackRate) {
return this.mediaElement.setPlaybackRate(playbackRate);
}
}, {
key: "getLiveDelay",
value: function getLiveDelay() {
return 0;
}
}, {
key: "getBufferLength",
value: function getBufferLength() {
return this.mediaElement.getBufferLength();
}
}, {
key: "getCurrentTime",
value: function getCurrentTime() {
return this.mediaElement.getCurrentTime();
}
}, {
key: "getDuration",
value: function getDuration() {
return this.mediaElement.getDuration();
}
}, {
key: "isLive",
value: function isLive() {
return this.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_8__[/* LIVE */ "U"]);
}
}, {
key: "registerEvents",
value: function registerEvents() {
var _this2 = this;

_core_model_media_element__WEBPACK_IMPORTED_MODULE_7__[/* VideoEvents */ "a"].forEach(function (eventName) {
var method = "on".concat(eventName.charAt(0).toUpperCase()).concat(eventName.slice(1));

if (typeof _this2[method] === 'function') {
_this2.mediaElement.on(eventName, _this2[method].bind(_this2));
}
});
this.mediaElement.on(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* PLAY_INTERRUPTED */ "Q"], function (error) {
return _this2.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* PLAY_INTERRUPTED */ "Q"], error);
});
this.mediaElement.on(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* PLAY_PROMISE_RESOLVED */ "R"], function () {
return _this2.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* PLAY_PROMISE_RESOLVED */ "R"]);
});
}
}, {
key: "unRegisterEvents",
value: function unRegisterEvents() {
this.mediaElement.off();
}
}, {
key: "setSource",
value: function setSource(url) {
this.playSource(url);
}
}, {
key: "playSource",
value: function playSource(url) {
this.mediaElement.setSource(url);
this.mediaElement.play();
}
}, {
key: "restart",
value: function restart() {
this.isStarted = false;
this.play();
}
}, {
key: "play",
value: function play() {
this.isPaused = false;

if (this.isStarted) {
this.mediaElement.play();
} else {
this.setSource(this.mediaItem.url);
}

this.timer.start();
this.isStarted = true;
}
}, {
key: "pause",
value: function pause() {
this.isPaused = true;
this.mediaElement.pause();
}
}, {
key: "stop",
value: function stop() {
this.mediaElement.pause();
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* STOPPED */ "ib"], this.mediaElement.getCurrentTime());
this.destroy();
}
}, {
key: "triggerOnSeekStartEvents",
value: function triggerOnSeekStartEvents() {
var currentTime = this.getCurrentTime();
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* SEEK_START */ "eb"], currentTime);

if (this.mediaElement.isPaused()) {
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* SYNTHETIC_WAITING */ "sb"], currentTime);
}
}
}, {
key: "destroy",
value: function destroy() {
var _this$timer;

(_this$timer = this.timer) === null || _this$timer === void 0 ? void 0 : _this$timer.stop();
this.isStarted = false;
this.isPaused = false;
this.unRegisterEvents();
this.mediaElement.pause();
this.mediaElement.off();

if (this.mediaElement.getSource()) {
this.mediaElement.removeSource();
}

this.mediaElement.load();
this.player.removeComponent(this.mediaElement);
}
}, {
key: "onPlay",
value: function onPlay() {
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* PLAY */ "M"], this.getCurrentTime());
}
}, {
key: "onPlaying",
value: function onPlaying() {
if (this.lastEvent === _core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* SEEK_END */ "cb"]) {
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* WAITING_END */ "Ab"], this.getCurrentTime());
}

if (this.lastEvent !== _core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* PLAYING */ "O"]) {
this.lastEvent = _core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* PLAYING */ "O"];
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* PLAYING */ "O"], this.getCurrentTime());

if (typeof this.initialLatency === 'undefined') {
this.initialLatency = this.player.getLiveLatency();
}
}
}
}, {
key: "onPause",
value: function onPause() {
this.lastEvent = _core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* PAUSED */ "G"];
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* PAUSED */ "G"], this.getCurrentTime());
}
}, {
key: "onWaiting",
value: function onWaiting() {
this.lastEvent = _core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* WAITING */ "zb"];
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* WAITING */ "zb"], this.getCurrentTime());
}
}, {
key: "onEnded",
value: function onEnded() {
this.lastEvent = _core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* ENDED */ "n"];
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* ENDED */ "n"], this.getCurrentTime());
}
}, {
key: "onCanplay",
value: function onCanplay() {
if (this.lastEvent !== _core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* WAITING_END */ "Ab"]) {
this.lastEvent = _core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* WAITING_END */ "Ab"];
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* WAITING_END */ "Ab"], this.getCurrentTime());
}

this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* CAN_PLAY */ "h"]);
}
}, {
key: "onSeeked",
value: function onSeeked() {
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* SEEK_END */ "cb"], this.getCurrentTime());

if (!this.mediaElement.isPaused() && this.lastEvent !== _core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* PLAYING */ "O"]) {
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* PLAYING */ "O"], this.getCurrentTime());
}

this.lastEvent = _core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* SEEK_END */ "cb"];
}
}, {
key: "onRatechange",
value: function onRatechange() {
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* PLAYBACK_RATE_CHANGED */ "N"], this.getPlaybackRate());
}
}, {
key: "onVolumechange",
value: function onVolumechange() {
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* VOLUME_CHANGED */ "wb"], this.getVolume(), this.isMuted());
this.updateLocalStorage();
}
}, {
key: "onError",
value: function onError(event) {
var videoError = this.mediaElement.getVideo().error;
var message = _core_enum_player_error__WEBPACK_IMPORTED_MODULE_11__[/* default */ "a"].PLAYBACK_ERROR;
var type = _core_enum_player_error__WEBPACK_IMPORTED_MODULE_11__[/* default */ "a"].PLAYBACK_ERROR;
var code = _core_enum_error_code__WEBPACK_IMPORTED_MODULE_12__[/* default */ "a"][_core_enum_player_error__WEBPACK_IMPORTED_MODULE_11__[/* default */ "a"].PLAYBACK_ERROR];

if (videoError) {
message = videoError.message;

switch (videoError.code) {
case 1:
code = _core_enum_error_code__WEBPACK_IMPORTED_MODULE_12__[/* default */ "a"][_core_enum_player_error__WEBPACK_IMPORTED_MODULE_11__[/* default */ "a"].MEDIA_ERR_ABORTED];
type = _core_enum_player_error__WEBPACK_IMPORTED_MODULE_11__[/* default */ "a"].MEDIA_ERR_ABORTED;
break;

case 2:
code = _core_enum_error_code__WEBPACK_IMPORTED_MODULE_12__[/* default */ "a"][_core_enum_player_error__WEBPACK_IMPORTED_MODULE_11__[/* default */ "a"].MEDIA_ERR_NETWORK];
type = _core_enum_player_error__WEBPACK_IMPORTED_MODULE_11__[/* default */ "a"].MEDIA_ERR_NETWORK;
break;

case 3:
code = _core_enum_error_code__WEBPACK_IMPORTED_MODULE_12__[/* default */ "a"][_core_enum_player_error__WEBPACK_IMPORTED_MODULE_11__[/* default */ "a"].MEDIA_ERR_DECODE];
type = _core_enum_player_error__WEBPACK_IMPORTED_MODULE_11__[/* default */ "a"].MEDIA_ERR_DECODE;
break;

case 4:
code = _core_enum_error_code__WEBPACK_IMPORTED_MODULE_12__[/* default */ "a"][_core_enum_player_error__WEBPACK_IMPORTED_MODULE_11__[/* default */ "a"].MEDIA_ERR_SRC_NOT_SUPPORTED];
type = _core_enum_player_error__WEBPACK_IMPORTED_MODULE_11__[/* default */ "a"].MEDIA_ERR_SRC_NOT_SUPPORTED;
break;
}
}

this.lastEvent = _core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* ERROR */ "o"];
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* ERROR */ "o"], {
code: code,
type: type,
message: message,
renderer: this.mediaType,
originalEvent: videoError || event
});
}
}, {
key: "mediaType",
get: function get() {
return this.rendererType.toUpperCase();
}
}]);

return BaseRenderer;
}(_core_util_event_emitter__WEBPACK_IMPORTED_MODULE_6__[/* default */ "a"]);

/* harmony default export */ __webpack_exports__["a"] = (BaseRenderer);

/***/ }),
/* 42 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
var key_system_id_namespaceObject = {};
__webpack_require__.r(key_system_id_namespaceObject);
__webpack_require__.d(key_system_id_namespaceObject, "CLEARKEY", function() { return CLEARKEY; });
__webpack_require__.d(key_system_id_namespaceObject, "FAIRPLAY", function() { return FAIRPLAY; });
__webpack_require__.d(key_system_id_namespaceObject, "PLAYREADY", function() { return PLAYREADY; });
__webpack_require__.d(key_system_id_namespaceObject, "WIDEVINE", function() { return WIDEVINE; });

// EXTERNAL MODULE: ./node_modules/@babel/runtime/regenerator/index.js
var regenerator = __webpack_require__(15);
var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/slicedToArray.js
var slicedToArray = __webpack_require__(8);
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/defineProperty.js
var defineProperty = __webpack_require__(2);
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/asyncToGenerator.js
var asyncToGenerator = __webpack_require__(20);
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);

// EXTERNAL MODULE: ./src/core/event/player-event.js
var player_event = __webpack_require__(0);

// EXTERNAL MODULE: ./src/core/enum/option-name.js
var option_name = __webpack_require__(1);

// EXTERNAL MODULE: ./src/core/util/http/index.js + 1 modules
var http = __webpack_require__(22);

// EXTERNAL MODULE: ./src/core/enum/player-error.js
var player_error = __webpack_require__(10);

// CONCATENATED MODULE: ./src/core/protection/error.js
var ErrorCode = {
NO_KEY_PROVIDED: 503,
FAILED_TO_GENERATE_MEDIA_KEYS: 504,
FAILED_TO_GENERATE_LICENSE_CHALLENGE: 505,
FAILED_TO_UPDATE_SESSION: 506,
FAILED_TO_LOAD_KEY: 507,
SESSION_KEY_ERROR: 508,
FAILED_TO_LOAD_CERTIFICATE: 509,
NOT_SECURE_CONTEXT: 510,
LICENSE_RESPONSE_REJECTED: 511
};
/* harmony default export */ var protection_error = (ErrorCode);
// EXTERNAL MODULE: ./src/core/util/http/http-response-type.js
var http_response_type = __webpack_require__(29);

// EXTERNAL MODULE: ./src/core/protection/key-system.js
var key_system = __webpack_require__(30);

// CONCATENATED MODULE: ./src/core/protection/key-system-id.js
var CLEARKEY = '1077efec-c0b2-4d02-ace3-3c1e52e2fb4b';
var FAIRPLAY = '94ce86fb-07ff-4f43-adb8-93d2fa968ca2';
var PLAYREADY = '9a04f079-9840-4286-ab92-e65be0885f95';
var WIDEVINE = 'edef8ba9-79d6-4ace-a3c8-27dcd51d21ed';
// CONCATENATED MODULE: ./src/core/protection/util.js



function parsePssh(data) {
if (data === null) {
return [];
}

var dv = new DataView(data),
done = false,
pssh = [],
byteCursor = 0;

while (!done) {
var size = void 0,
nextBox = void 0,
version = void 0,
systemID = void 0,
keyId = void 0,
psshDataSize = void 0,
boxStart = byteCursor;

if (byteCursor >= dv.buffer.byteLength) {
done = true;
break;
}

size = dv.getUint32(byteCursor);
nextBox = byteCursor + size;
byteCursor += 4;

if (dv.getUint32(byteCursor) !== 0x70737368) {
byteCursor = nextBox;
continue;
}

byteCursor += 4;
version = dv.getUint8(byteCursor);

if (version !== 0 && version !== 1) {
byteCursor = nextBox;
continue;
}

byteCursor++;
byteCursor += 3;
systemID = parseUUID(new Uint8Array(data, byteCursor, 16));
byteCursor += 16;
systemID = systemID.toLowerCase();

if (version === 0) {
keyId = parseUUID(new Uint8Array(data, byteCursor + 8, 16));
}

dv.getUint32(byteCursor);
byteCursor += 4;
pssh.push({
id: systemID,
data: dv.buffer.slice(boxStart, nextBox),
keyId: keyId
});
byteCursor = nextBox;
}

return pssh;
}

function parseUUID(data) {
var parts = [],
toHex = function toHex(arr) {
var hex = '';

for (var i = 0; i < arr.length; ++i) {
var value = arr[i].toString(16);
if (value.length == 1) value = '0' + value;
hex += value;
}

return hex;
};

parts.push(toHex(data.subarray(0, 4)));
parts.push(toHex(data.subarray(4, 6)));
parts.push(toHex(data.subarray(6, 8)));
parts.push(toHex(data.subarray(8, 10)));
parts.push(toHex(data.subarray(10, 16)));
return parts.join('-');
}

function getSessionByKeyId(sessions, keyId) {
for (var i = 0; i < sessions.length; i++) {
if (sessions[i].keyId === keyId) {
return sessions[i];
}
}

return null;
}

function getKeySystemName(name) {
var _Object$entries$find;

return (_Object$entries$find = Object.entries(key_system).find(function (_ref) {
var _ref2 = slicedToArray_default()(_ref, 2),
key = _ref2[0],
system = _ref2[1];

return name === system;
})) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0];
} // Found in https://github.com/Dash-Industry-Forum/dash.js/blob/756770254cebd1c2dc17f046c55a4b8c5b2b5e9b/src/streaming/protection/controllers/ProtectionKeyController.js#L171


function checkIfInitDataEquals(initData1, initData2) {
if (initData1.byteLength !== initData2.byteLength) {
return false;
}

var data1 = new Uint8Array(initData1);
var data2 = new Uint8Array(initData2);

for (var i = 0; i < data1.length; i++) {
if (data1[i] !== data2[i]) {
return false;
}
}

return true;
}





// CONCATENATED MODULE: ./src/core/protection/protection.js





function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }











function Protection(_x, _x2) {
return _Protection.apply(this, arguments);
}

function _Protection() {
_Protection = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee2(player, contentTypes) {
var _Object$entries$find;

var video, options, cacheDrmSessionByKeyId, drmConfig, drmSystems, providedDrmSystemsKeys, availableDrmSystems, sessionList, keySystemConfig, mediaKeyMediaSystemAccess, keySystem, keySystemName, mediaKeys, pendingSessions, cancelRequest, getMediaKeySystemAccess, _getMediaKeySystemAccess, checkKeySystem, throwError, throwGenerateKeysError, onEncrypted, isPendingSession, createChallenge, messageEventHandler, getLicense, updateSession, destroy;

return regenerator_default.a.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
destroy = function _destroy() {
pendingSessions = [];
sessionList.forEach(function (session) {
session.close()["catch"](function () {});
session.removeEventListener('message', messageEventHandler);
session = null;
});
sessionList = [];

if (cancelRequest) {
cancelRequest();
}

video.removeEventListener('encrypted', onEncrypted);
};

updateSession = function _updateSession(session, data) {
session.update(data).then(function () {
player.trigger(player_event["u" /* LICENSE_ACQUIRED */]);
})["catch"](function (error) {
var message = player_error["a" /* default */].DRM_SESSION_UPDATE_FAILED;
var code = protection_error.FAILED_TO_UPDATE_SESSION;

if (error.message === 'Rejected with system code (18)') {
message = player_error["a" /* default */].LICENSE_RESPONSE_REJECTED;
code = protection_error.LICENSE_RESPONSE_REJECTED;
}

throwError(code, message, error);
});
};

getLicense = function _getLicense(licenseUrl, message, headers) {
var _httpConfig$drm, _httpConfig$drm2;

player.trigger(player_event["a" /* ACQUIRING_LICENSE */], licenseUrl, getKeySystemName(mediaKeyMediaSystemAccess.keySystem));
var httpConfig = options.get(option_name["N" /* HTTP_CONFIG */]);
var customHeaders = httpConfig === null || httpConfig === void 0 ? void 0 : (_httpConfig$drm = httpConfig.drm) === null || _httpConfig$drm === void 0 ? void 0 : _httpConfig$drm.headers;

var requestHeaders = _objectSpread({}, headers, {}, customHeaders);

return http["a" /* default */].post(licenseUrl, {
cancelToken: new http["a" /* default */].CancelToken(function (c) {
return cancelRequest = c;
}),
data: message,
responseType: http_response_type["a" /* ARRAY_BUFFER */],
withCredentials: httpConfig === null || httpConfig === void 0 ? void 0 : (_httpConfig$drm2 = httpConfig.drm) === null || _httpConfig$drm2 === void 0 ? void 0 : _httpConfig$drm2.withCredentials,
headers: requestHeaders
}).then(function (_ref5) {
var data = _ref5.data,
metric = _ref5.metric,
xhr = _ref5.xhr;
player.trigger(player_event["A" /* NETWORK_METRIC */], {
duration: metric.duration,
type: 'LICENSE',
statusCode: xhr.status,
url: licenseUrl,
timestamp: Date.now()
});
return data;
})["catch"](function (_ref6) {
var metric = _ref6.metric,
xhr = _ref6.xhr;
throwError(protection_error.FAILED_TO_LOAD_KEY, player_error["a" /* default */].DRM_LOAD_LICENSE_KEY_FAILED);
player.trigger(player_event["A" /* NETWORK_METRIC */], {
duration: metric.duration,
type: 'LICENSE',
statusCode: xhr.status,
url: licenseUrl,
timestamp: Date.now
});
});
};

messageEventHandler = function _messageEventHandler(event) {
var session = event.target;
var challenge = event['message'];
var headers = [];

try {
var bytes = new Uint16Array(challenge),
msg = String.fromCharCode.apply(null, bytes),
parser = new DOMParser(),
xmlDoc = parser.parseFromString(msg, 'application/xml');

if (xmlDoc.getElementsByTagName('Challenge')[0]) {
challenge = xmlDoc.getElementsByTagName('Challenge')[0].childNodes[0].nodeValue;

if (challenge) {
challenge = atob(challenge);
}

var headerNameList = xmlDoc.getElementsByTagName('name');
var headerValueList = xmlDoc.getElementsByTagName('value');

for (var i = 0; i < headerNameList.length; i++) {
headers[headerNameList[i].childNodes[0].nodeValue] = headerValueList[i].childNodes[0].nodeValue;
}
}
} catch (e) {}

getLicense(drmConfig[keySystemName], challenge, headers).then(function (data) {
return updateSession(session, data);
});
};

createChallenge = function _createChallenge(mediaKeys, initDataType, initData, keyId) {
var session = mediaKeys.createSession();
session.keyId = keyId;
session.addEventListener('message', messageEventHandler);
session.generateRequest(initDataType, initData)["catch"](function () {
throwError(protection_error.FAILED_TO_GENERATE_LICENSE_CHALLENGE, player_error["a" /* default */].DRM_GENERATE_LICENSE_CHALLENGE_FAILED);
});
sessionList.push(session);
};

isPendingSession = function _isPendingSession(initData, keyId) {
if (cacheDrmSessionByKeyId) {
return !!getSessionByKeyId(pendingSessions, keyId);
}

return pendingSessions.some(function (session) {
return checkIfInitDataEquals(session.initData, initData);
});
};

onEncrypted = function _onEncrypted(event) {
if (!video.mediaKeys) {
return;
}

var psshList = parsePssh(new Uint8Array(event.initData).buffer);
var uuid = key_system_id_namespaceObject[keySystemName.toUpperCase()].toLowerCase();
var pssh = psshList.find(function (_ref4) {
var id = _ref4.id;
return id === uuid;
});
var keyId = (pssh === null || pssh === void 0 ? void 0 : pssh.keyId) || uuid;

if (isPendingSession(event.initData, keyId)) {
return;
}

player.trigger(player_event["m" /* ENCRYPTED */], event);
var sessionData = new SessionData();
sessionData.keyId = keyId;

if (!cacheDrmSessionByKeyId) {
sessionData.initData = event.initData;
}

pendingSessions.push(sessionData);
createChallenge(video.mediaKeys, event.initDataType, event.initData, keyId);
};

throwGenerateKeysError = function _throwGenerateKeysErr() {
throwError(protection_error.FAILED_TO_GENERATE_MEDIA_KEYS, player_error["a" /* default */].DRM_GENERATE_MEDIA_KEYS_FAILED);
};

throwError = function _throwError(code, message, originalMessage) {
player.trigger(player_event["o" /* ERROR */], {
code: code,
message: message,
type: 'DRM_ERROR',
renderer: 'DASH',
originalMessage: originalMessage
});
};

checkKeySystem = function _checkKeySystem(keySystem, keySystemConfig) {
return navigator.requestMediaKeySystemAccess(keySystem, keySystemConfig);
};

_getMediaKeySystemAccess = function _getMediaKeySystemAcc2() {
_getMediaKeySystemAccess = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee(availableKeySystems) {
var mediaKeySystemAccess, _keySystemName;

return regenerator_default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
mediaKeySystemAccess = undefined;

case 1:
if (!(availableKeySystems.length && !mediaKeySystemAccess)) {
_context.next = 8;
break;
}

_keySystemName = availableKeySystems.shift();
_context.next = 5;
return checkKeySystem(key_system[_keySystemName.toUpperCase()], keySystemConfig)["catch"](function () {});

case 5:
mediaKeySystemAccess = _context.sent;
_context.next = 1;
break;

case 8:
return _context.abrupt("return", mediaKeySystemAccess);

case 9:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _getMediaKeySystemAccess.apply(this, arguments);
};

getMediaKeySystemAccess = function _getMediaKeySystemAcc(_x3) {
return _getMediaKeySystemAccess.apply(this, arguments);
};

video = player.getRendererElm();
options = player.options;
cacheDrmSessionByKeyId = options.get(option_name["o" /* CACHE_DRM_SESSION_BY_KEY_ID */]);
player.on(player_event["l" /* DESTROY */], destroy);
player.on(player_event["ib" /* STOPPED */], destroy);
player.on(player_event["n" /* ENDED */], destroy);
drmConfig = options.get(option_name["z" /* DRM */]);
drmSystems = options.get(option_name["A" /* DRM_SYSTEMS */]);
providedDrmSystemsKeys = Object.keys(drmConfig);
availableDrmSystems = drmSystems.filter(function (key) {
return providedDrmSystemsKeys.includes(key);
});
sessionList = [];

if (!(availableDrmSystems.length === 0)) {
_context2.next = 26;
break;
}

throwError(protection_error.NO_KEY_PROVIDED, player_error["a" /* default */].DRM_NO_KEY_PROVIDED);
return _context2.abrupt("return", Promise.resolve());

case 26:
keySystemConfig = createKeySystemConfig(contentTypes);
_context2.next = 29;
return getMediaKeySystemAccess(availableDrmSystems.slice());

case 29:
mediaKeyMediaSystemAccess = _context2.sent;

if (mediaKeyMediaSystemAccess) {
_context2.next = 33;
break;
}

throwGenerateKeysError();
return _context2.abrupt("return", Promise.resolve());

case 33:
keySystem = mediaKeyMediaSystemAccess.keySystem;
keySystemName = (_Object$entries$find = Object.entries(key_system).find(function (_ref2) {
var _ref3 = slicedToArray_default()(_ref2, 2),
_ = _ref3[0],
value = _ref3[1];

return value === keySystem;
})) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0].toLowerCase();
_context2.t0 = video.mediaKeys;

if (_context2.t0) {
_context2.next = 40;
break;
}

_context2.next = 39;
return mediaKeyMediaSystemAccess.createMediaKeys()["catch"](throwGenerateKeysError);

case 39:
_context2.t0 = _context2.sent;

case 40:
mediaKeys = _context2.t0;
_context2.next = 43;
return video.setMediaKeys(mediaKeys)["catch"](throwGenerateKeysError);

case 43:
video.addEventListener('encrypted', onEncrypted);
pendingSessions = [];
cancelRequest = null;
return _context2.abrupt("return", {
destroy: destroy
});

case 47:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
return _Protection.apply(this, arguments);
}

function SessionData() {
this.keyId = null;
this.initData = null;
}

function createKeySystemConfig() {
var contentTypes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var initDataTypes = ['cenc'];
var capabilities = contentTypes.reduce(function (obj, _ref) {
var contentType = _ref.contentType,
type = _ref.type;
return _objectSpread({}, obj, defineProperty_default()({}, "".concat(type, "Capabilities"), [{
contentType: contentType
}]));
}, {});
return [_objectSpread({
initDataTypes: initDataTypes
}, capabilities)];
}

/* harmony default export */ var protection = (Protection);
// CONCATENATED MODULE: ./src/core/protection/protection-safari.js


function protection_safari_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function protection_safari_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { protection_safari_ownKeys(Object(source), true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { protection_safari_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }










function ProtectionSafari(player) {
var options = player.options;
var video = player.getRendererElm();
video.addEventListener('webkitneedkey', needKey);
var drmOptions = options.get(option_name["z" /* DRM */]);
var fairPlayOptions = drmOptions.fairplay;
var licenseUrl = fairPlayOptions && fairPlayOptions.src;
var certificateUrl = fairPlayOptions && fairPlayOptions.cert;
var keySession;
var certificate;

function needKey(event) {
var initData = event.initData;
var contentId = extractContentId(initData);
getCertificate().then(function (resp) {
certificate = new Uint8Array(resp);
initData = concatInitDataIdAndCertificate(initData, contentId, certificate);

if (!video.webkitKeys) {
video.webkitSetMediaKeys(new WebKitMediaKeys(key_system["FAIRPLAY"]));
}

keySession = video.webkitKeys.createSession('video/mp4', initData);
keySession.contentId = contentId;
player.trigger(player_event["m" /* ENCRYPTED */], event);
keySession.addEventListener('webkitkeymessage', licenseRequestReady);
})["catch"](function () {
player.trigger(player_event["o" /* ERROR */], {
code: protection_error.FAILED_TO_LOAD_CERTIFICATE,
type: 'DRM_ERROR',
renderer: 'HLS',
message: player_error["a" /* default */].DRM_LOAD_CERTIFICATE_FAILED
});
});
}

function licenseRequestReady(event) {
player.trigger(player_event["a" /* ACQUIRING_LICENSE */], licenseUrl, getKeySystemName(key_system["FAIRPLAY"]));
getLicense(licenseUrl, event.message);
}

function getLicense(url, message) {
var _httpConfig$drm, _httpConfig$drm2;

var httpConfig = options.get(option_name["N" /* HTTP_CONFIG */]);
var customHeaders = (httpConfig === null || httpConfig === void 0 ? void 0 : (_httpConfig$drm = httpConfig.drm) === null || _httpConfig$drm === void 0 ? void 0 : _httpConfig$drm.headers) || {};

var headers = protection_safari_objectSpread({
'Content-Type': options.get(option_name["C" /* FAIRPLAY_CONTENT_TYPE */])
}, customHeaders);

http["a" /* default */].post(url, {
data: message,
responseType: http_response_type["a" /* ARRAY_BUFFER */],
withCredentials: httpConfig === null || httpConfig === void 0 ? void 0 : (_httpConfig$drm2 = httpConfig.drm) === null || _httpConfig$drm2 === void 0 ? void 0 : _httpConfig$drm2.withCredentials,
headers: headers
}).then(function (res) {
return licenseRequestLoaded(res);
})["catch"](function (res) {
return licenseRequestFailed(res);
});
}

function licenseRequestLoaded(_ref) {
var data = _ref.data,
metric = _ref.metric,
xhr = _ref.xhr;
player.trigger(player_event["A" /* NETWORK_METRIC */], {
duration: metric.duration,
type: 'LICENSE',
statusCode: xhr.status,
url: licenseUrl,
timestamp: Date.now()
});
keySession.update(new Uint8Array(data));
player.trigger(player_event["u" /* LICENSE_ACQUIRED */]);
}

function licenseRequestFailed(_ref2) {
var metric = _ref2.metric,
xhr = _ref2.xhr;
player.trigger(player_event["o" /* ERROR */], {
code: protection_error.FAILED_TO_LOAD_KEY,
renderer: 'HLS',
type: 'DRM_ERROR',
message: player_error["a" /* default */].DRM_LOAD_LICENSE_KEY_FAILED
});
player.trigger(player_event["A" /* NETWORK_METRIC */], {
duration: metric.duration,
type: 'LICENSE',
statusCode: xhr.status,
url: url,
timestamp: Date.now()
});
}

function getCertificate() {
if (certificate) {
return Promise.resolve(certificate);
}

return http["a" /* default */].getBinary(certificateUrl).then(function (_ref3) {
var data = _ref3.data;
return data;
});
}
}

function arrayToString(array) {
var uint16array = new Uint16Array(array.buffer);
return String.fromCharCode.apply(null, uint16array);
}

function stringToArray(string) {
var buffer = new ArrayBuffer(string.length * 2);
var array = new Uint16Array(buffer);

for (var i = 0, strLen = string.length; i < strLen; i++) {
array[i] = string.charCodeAt(i);
}

return array;
}

function extractContentId(initData) {
var contentId = arrayToString(initData);
var link = document.createElement('a');
link.href = contentId;
return link.hostname;
}

function concatInitDataIdAndCertificate(initData, id, cert) {
if (typeof id === 'string') {
id = stringToArray(id);
} // layout is [initData][4 byte: idLength][idLength byte: id][4 byte:certLength][certLength byte: cert]


var offset = 0;
var buffer = new ArrayBuffer(initData.byteLength + 4 + id.byteLength + 4 + cert.byteLength);
var dataView = new DataView(buffer);
var initDataArray = new Uint8Array(buffer, offset, initData.byteLength);
initDataArray.set(initData);
offset += initData.byteLength;
dataView.setUint32(offset, id.byteLength, true);
offset += 4;
var idArray = new Uint16Array(buffer, offset, id.length);
idArray.set(id);
offset += idArray.byteLength;
dataView.setUint32(offset, cert.byteLength, true);
offset += 4;
var certArray = new Uint8Array(buffer, offset, cert.byteLength);
certArray.set(cert);
return new Uint8Array(buffer, 0, buffer.byteLength);
}

/* harmony default export */ var protection_safari = (ProtectionSafari);
// CONCATENATED MODULE: ./src/core/protection/protection-manager.js



function ProtectionManager(player, contentType) {
var ProtectionModel = detectProtectionModel(player.getRendererElm(), contentType);
return new ProtectionModel(player, contentType);
}

function detectProtectionModel(video, contentType, undefined) {
if (contentType === undefined) {
return protection_safari;
} else if (video.onencrypted !== undefined && video.mediaKeys !== undefined && navigator.requestMediaKeySystemAccess !== undefined && typeof navigator.requestMediaKeySystemAccess === 'function') {
return protection;
}
}

/* harmony default export */ var protection_manager = __webpack_exports__["a"] = (ProtectionManager);

/***/ }),
/* 43 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
var DateUtil = function () {
var DEFAULT_FORMAT = 'YYYY-MM-DD HH:mm:ss',
formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|X|zz?|ZZ?|.)/g;

function leftZeroFill(number, _targetLength) {
var output = '' + Math.abs(number),
targetLength = _targetLength || 2;

while (output.length < targetLength) {
output = '0' + output;
}

return output;
} //Available format tokens: YYYY, YY, MM, M, DD, D, HH, H, mm, m, ss, s


function format(date, _dateFormat) {
var dateFormat = _dateFormat || DEFAULT_FORMAT,
dateObj = new Date(date),
tokensArray = dateFormat.match(formattingTokens),
resultArray = [];

for (var i = 0, length = tokensArray.length; i < length; i++) {
var token = tokensArray[i];

switch (token) {
case 'YYYY':
resultArray.push(dateObj.getFullYear());
break;

case 'YY':
resultArray.push(dateObj.getFullYear() % 100);
break;

case 'MM':
case 'M':
resultArray.push(leftZeroFill(dateObj.getMonth() + 1));
break;

case 'DD':
case 'D':
resultArray.push(leftZeroFill(dateObj.getDate()));
break;

case 'HH':
case 'H':
resultArray.push(leftZeroFill(dateObj.getHours()));
break;

case 'mm':
case 'm':
resultArray.push(leftZeroFill(dateObj.getMinutes()));
break;

case 'ss':
case 's':
resultArray.push(leftZeroFill(dateObj.getSeconds()));
break;

case 'ms':
resultArray.push(dateObj.getMilliseconds);
break;

default:
resultArray.push(token);
}
}

return resultArray.join('');
}

return {
format: format
};
}();

/* harmony default export */ __webpack_exports__["a"] = (DateUtil);

/***/ }),
/* 44 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return SegmentManager; });
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15);
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
/* harmony import */ var _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(20);
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _core_util_event_emitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(17);
/* harmony import */ var _core_util_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(33);
/* harmony import */ var _core_util_http__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(22);
/* harmony import */ var _core_event_player_event__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(0);
/* harmony import */ var _core_util_http_http_status__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(23);
/* harmony import */ var _core_enum_option_name__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1);
/* harmony import */ var _core_enum_player_component__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(7);
/* harmony import */ var _renderer_dash_manifest_helper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(11);
/* harmony import */ var _renderer_dash_event_dash_event__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(14);
/* harmony import */ var _renderer_dash_enum_media_type__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(9);




function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _babel_runtime_helpers_defineProperty__WEBPACK_IMPORTED_MODULE_1___default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }












SegmentManager.prototype = Object.create(_core_util_event_emitter__WEBPACK_IMPORTED_MODULE_3__[/* default */ "a"].prototype);
var MINIMUM_LOADED_DATA = 5000; //[bytes]

function SegmentManager(player, mediaType, getCurrentTimeAndBufferLengthFn) {
var _httpConfig$fragment;

var ctx = this;
var optionManager = player.options;
var streamWithCredentials = optionManager.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_8__[/* STREAM_WITH_CREDENTIALS */ "Bb"]);
var manifest = player.getComponent(_core_enum_player_component__WEBPACK_IMPORTED_MODULE_9__[/* MANIFEST_MANAGER */ "c"]);
var mediaElement = player.getComponent(_core_enum_player_component__WEBPACK_IMPORTED_MODULE_9__[/* MEDIA_ELEMENT */ "d"]);
var segmentLogger = _core_util_logger__WEBPACK_IMPORTED_MODULE_4__[/* default */ "a"].get("".concat(mediaType, "-stream"));
var httpConfig = optionManager.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_8__[/* HTTP_CONFIG */ "N"]);
var headers = httpConfig === null || httpConfig === void 0 ? void 0 : (_httpConfig$fragment = httpConfig.fragment) === null || _httpConfig$fragment === void 0 ? void 0 : _httpConfig$fragment.headers;
var adaptation = null;
var representation = null;
var lastSegment = null;
var queue = [];
var cached = {};
var _isProcessingRequest = false;
var isInitialized = false;
var cancelRequest = null;
var paused = false;
var stopped = false;
var language = null;
var bandwidth = 0;
var currentPeriod = undefined;

function setAdaptation(_adaptation, isBufferInitialized) {
if (_adaptation) {
language = _adaptation.lang;
}

trace("START SWITCHING: ".concat(language));
adaptation = _adaptation;
representation = null;
stopped = false;

if (isBufferInitialized) {
reset();
next();
}
}

function switchProfile(_bandwidth, isBufferInitialized) {
trace("START SWITCHING PROFILE: ".concat(_bandwidth));
bandwidth = _bandwidth;

if (isBufferInitialized) {
reset();
next();
}
}

function reset() {
pause();
abort();
lastSegment = null;
queue = [];
cancelRequest = null;
isInitialized = false;
}

function start() {
isInitialized = false;
stopped = false;
next();
}

function findNextSegmentStart(time, sourceBufferLength) {
var _currentPeriod;

var downloadedBufferLength = getQueueLengthFromTime(time);

var _ref = lastSegment || {},
start = _ref.start,
duration = _ref.duration;

var nextSegmentStart = time + (downloadedBufferLength > sourceBufferLength ? downloadedBufferLength : sourceBufferLength);

if (lastSegment === null && (mediaType === _renderer_dash_enum_media_type__WEBPACK_IMPORTED_MODULE_12__[/* default */ "a"].AUDIO || mediaType === _renderer_dash_enum_media_type__WEBPACK_IMPORTED_MODULE_12__[/* default */ "a"].TEXT)) {
nextSegmentStart = time + sourceBufferLength;
}

if (lastSegment !== null && nextSegmentStart <= start + duration) {
nextSegmentStart = start + duration + 0.01;
}

if (((_currentPeriod = currentPeriod) === null || _currentPeriod === void 0 ? void 0 : _currentPeriod.end) && lastSegment) {
var _segmentList;

var segmentList = representation.segmentList;
var isSegmentIsLastInPeriod = ((_segmentList = segmentList[segmentList.length - 1]) === null || _segmentList === void 0 ? void 0 : _segmentList.start) === lastSegment.start;
var nextPeriod = manifest.getNextPeriod(currentPeriod);

if (isSegmentIsLastInPeriod && nextPeriod) {
nextSegmentStart = nextPeriod.start;
}
}

if (nextSegmentStart - time > manifest.maxBufferLength + 1) {
return;
}

return nextSegmentStart;
}

function next() {
return _next.apply(this, arguments);
}

function _next() {
_next = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_2___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.mark(function _callee() {
var _getCurrentTimeAndBuf, time, bufferLength, nextSegmentStart, period, _bandwidth, initializationSegment, segment;

return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_0___default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!(paused || stopped || _isProcessingRequest)) {
_context.next = 2;
break;
}

return _context.abrupt("return");

case 2:
_getCurrentTimeAndBuf = getCurrentTimeAndBufferLengthFn(), time = _getCurrentTimeAndBuf.time, bufferLength = _getCurrentTimeAndBuf.bufferLength;
nextSegmentStart = findNextSegmentStart(time, bufferLength);

if (!isNaN(nextSegmentStart)) {
_context.next = 6;
break;
}

return _context.abrupt("return");

case 6:
period = manifest.findPeriodByTime(nextSegmentStart);

if (currentPeriod && currentPeriod.id !== (period === null || period === void 0 ? void 0 : period.id)) {
stopped = true;
isInitialized = false;
trace("NEXT PERIOD: ".concat(period.id, ", PREV: ").concat(currentPeriod.id));
}

if (!(!isInitialized && period)) {
_context.next = 30;
break;
}

adaptation = manifest.getAdaptationSetByType(mediaType, period, language); // new period (e.g. ad) may not contain specified language

if (!adaptation && language) {
adaptation = manifest.getAdaptationSetByType(mediaType, period);
}

_bandwidth = bandwidth;

if (mediaType === _renderer_dash_enum_media_type__WEBPACK_IMPORTED_MODULE_12__[/* default */ "a"].VIDEO) {
_bandwidth = manifest.getVideoNearestBandwidth(bandwidth, period);
}

representation = adaptation.getRepresentation(_bandwidth);
ctx.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_6__[/* PERIOD_CHANGING */ "J"], period);
ctx.trigger(_renderer_dash_event_dash_event__WEBPACK_IMPORTED_MODULE_11__[/* ADAPTATION_CHANGED */ "a"], adaptation);
ctx.trigger(_renderer_dash_event_dash_event__WEBPACK_IMPORTED_MODULE_11__[/* REPRESENTATION_CHANGED */ "e"], representation);
trace("START LOADING INIT: ".concat(representation.bandwidth, ", PERIOD: ").concat(period.id));
_isProcessingRequest = true;
_context.next = 21;
return loadInitializationSegment(adaptation, representation, period);

case 21:
initializationSegment = _context.sent;
stopped = false;
cancelRequest = null;
_isProcessingRequest = false;

if (initializationSegment) {
_context.next = 27;
break;
}

return _context.abrupt("return");

case 27:
trace("LOADED INIT: ".concat(representation.bandwidth, ", PERIOD: ").concat(period.id));
isInitialized = true;
queue.push(initializationSegment);

case 30:
currentPeriod = period;
trace("LOOKING FOR SEGMENT: [".concat(representation.id, "]: start: ").concat(nextSegmentStart, ", bandwidth: ").concat(representation.bandwidth / 1000));
segment = findSegmentByPosition(nextSegmentStart, representation);

if (segment) {
_context.next = 35;
break;
}

return _context.abrupt("return");

case 35:
trace("FOUND SEGMENT: [".concat(representation.id, "]: start: ").concat(segment.start, ", id: ").concat(segment.index, ", bandwidth: ").concat(representation.bandwidth / 1000));

if (!(lastSegment !== null && lastSegment.start >= segment.start)) {
_context.next = 38;
break;
}

return _context.abrupt("return");

case 38:
return _context.abrupt("return", loadSegment(segment, representation, bufferLength).then(function () {
return segment;
}));

case 39:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _next.apply(this, arguments);
}

function resume() {
if (stopped) {
return false;
}

paused = false;

if (!isInitialized && !_isProcessingRequest) {
start();
}
}

function pause() {
paused = true;
}

function stop() {
stopped = true;
abort();
lastSegment = null;
queue = [];
isInitialized = false;
}

function abort() {
if (cancelRequest) {
cancelRequest();
} else {
_isProcessingRequest = false;
}
}

function update() {
abort();
flush(false);
lastSegment = null;
next();
}

function flush() {
var all = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;

if (all) {
queue = [];
} else {
var segments = [];
queue.forEach(function (segment) {
if (segment.index === -1) {
segments.push(segment);
}
});
queue = segments;
}
}

function getQueueLengthFromTime() {
var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
return queue.filter(function (_ref2) {
var start = _ref2.start,
duration = _ref2.duration;
return start >= time || start < time && start + duration > time;
}).reduce(function (acc, _ref3, index) {
var start = _ref3.start,
duration = _ref3.duration;

if (index === 0) {
acc -= time - start;
}

return acc + duration;
}, 0);
}

function findSegmentByPosition(position, representation) {
if (isNaN(position)) {
return null;
}

position = Object(_renderer_dash_manifest_helper__WEBPACK_IMPORTED_MODULE_10__[/* fixNumberPrecision */ "c"])(position);

if (!representation) {
var period = manifest.findPeriodByTime(position);
var adaptationSet = manifest.getAdaptationSetByType(mediaType, period, language);
var _bandwidth = bandwidth;

if (mediaType === _renderer_dash_enum_media_type__WEBPACK_IMPORTED_MODULE_12__[/* default */ "a"].VIDEO) {
_bandwidth = manifest.getVideoNearestBandwidth(bandwidth, period);
}

representation = adaptationSet.getRepresentation(_bandwidth);
}

var segments = representation.segmentList;

if (!segments.length) {
return null;
}

if (position === 0 || position < segments[0].start) {
position = Object(_renderer_dash_manifest_helper__WEBPACK_IMPORTED_MODULE_10__[/* fixNumberPrecision */ "c"])(segments[0].start);
}

var min = 0;
var max = segments.length - 1;
var mid;

while (min <= max) {
mid = (min + max) / 2 | 0;
var segment = segments[mid];
var _start = segment.start,
duration = segment.duration;
var fixedStart = Object(_renderer_dash_manifest_helper__WEBPACK_IMPORTED_MODULE_10__[/* fixNumberPrecision */ "c"])(_start);
var end = Object(_renderer_dash_manifest_helper__WEBPACK_IMPORTED_MODULE_10__[/* fixNumberPrecision */ "c"])(fixedStart + duration);

if (position >= fixedStart && position < end) {
return segment;
} else if (fixedStart > position) {
max = mid - 1;
} else {
min = mid + 1;
}
}

return null;
}

function getAllSegments() {
var _representation;

return (_representation = representation) === null || _representation === void 0 ? void 0 : _representation.segmentList;
}

function getQueue() {
return queue;
}

function getQueueStart() {
if (queue.length) {
return queue[0].start;
}

return null;
}

function isLastSegment(_ref4) {
var index = _ref4.index;

var _ref5 = representation || {},
period = _ref5.period,
lastSegment = _ref5.lastSegment;

return period === manifest.getLastPeriod() && (lastSegment === null || lastSegment === void 0 ? void 0 : lastSegment.index) === index;
}

function isProcessingRequest() {
return _isProcessingRequest;
}

function getNextSegment(segment) {
var segments = getAllSegments();
var index = segments.indexOf(segment) + 1;

if (index >= segments.length - 1) {
return segments[segments.length - 1];
}

return segments[index];
}

function getNextSegmentToSwitch(time) {
var currentSegmentStart = Math.round(time),
currentSegment = findSegmentByPosition(currentSegmentStart),
nextSegment,
diff = 0,
counter = 0;

if (currentSegment === null) {
return null;
}

while (diff < currentSegment.duration && counter < 4) {
nextSegment = getNextSegment(currentSegment);
diff = nextSegment.start - time;
currentSegment = nextSegment;
counter++;
}

return nextSegment;
}

function loadInitializationSegment(adaptation, representation, period) {
var id = "".concat(period.id, "_").concat(adaptation.id, "_").concat(representation.id);

if (cached[id]) {
return Promise.resolve(cached[id]);
}

var url = Object(_renderer_dash_manifest_helper__WEBPACK_IMPORTED_MODULE_10__[/* buildInitializationUrl */ "a"])(representation);
var start = period.start,
end = period.end;
var bandwidth = representation.bandwidth,
representationId = representation.id,
segmentTemplate = representation.segmentTemplate;
var presentationTimeOffset = segmentTemplate.presentationTimeOffset,
timescale = segmentTemplate.timescale;
var offset = start - (presentationTimeOffset / timescale || 0);
var segmentInfo = {
appendWindowStart: start,
appendWindowEnd: end || Infinity,
bandwidth: bandwidth,
duration: 0,
index: -1,
mediaType: mediaType,
offset: offset,
representationId: representationId,
periodId: period.id,
type: 'initialization'
};
return fetch(url).then(function (_ref6) {
var data = _ref6.data,
metric = _ref6.metric;

var segment = _objectSpread({}, segmentInfo, {
data: data
});

cached[id] = segment;
ctx.trigger(_renderer_dash_event_dash_event__WEBPACK_IMPORTED_MODULE_11__[/* SEGMENT_DOWNLOADED */ "g"], _objectSpread({}, metric, {
segmentInfo: segmentInfo
}));
return segment;
})["catch"](function (_ref7) {
var error = _ref7.error,
metric = _ref7.metric,
xhr = _ref7.xhr;

if (error !== _core_util_http_http_status__WEBPACK_IMPORTED_MODULE_7__[/* FAILED */ "b"]) {
return;
}

ctx.trigger(_renderer_dash_event_dash_event__WEBPACK_IMPORTED_MODULE_11__[/* FAILED_TO_DOWNLOAD_SEGMENT */ "d"], _objectSpread({}, metric, {
segmentInfo: segmentInfo
}), xhr);
});
}

function loadSegment(segment, representation, bufferLength) {
var url = Object(_renderer_dash_manifest_helper__WEBPACK_IMPORTED_MODULE_10__[/* buildSegmentUrl */ "b"])(representation, segment);
var start = segment.start,
duration = segment.duration,
index = segment.index;
var representationId = representation.id,
bandwidth = representation.bandwidth,
mediaType = representation.mediaType,
period = representation.period;
_isProcessingRequest = true;
var segmentInfo = {
bandwidth: bandwidth,
duration: duration,
index: index,
mediaType: mediaType,
representation: representation,
representationId: representationId,
start: start,
periodId: period.id
};

var onProgress = function onProgress(info) {
if (info.status === _core_util_http_http_status__WEBPACK_IMPORTED_MODULE_7__[/* RETRY */ "d"]) {
info.segmentInfo = segmentInfo;
ctx.trigger(_renderer_dash_event_dash_event__WEBPACK_IMPORTED_MODULE_11__[/* FAILED_TO_DOWNLOAD_SEGMENT */ "d"], info);
}

if (_core_util_http_http_status__WEBPACK_IMPORTED_MODULE_7__[/* PROGRESS */ "c"] && info.bps > 0 && info.loaded > MINIMUM_LOADED_DATA) {
ctx.trigger(_renderer_dash_event_dash_event__WEBPACK_IMPORTED_MODULE_11__[/* SEGMENT_DOWNLOAD_PROGRESS */ "h"], _objectSpread({}, info, {
status: _core_util_http_http_status__WEBPACK_IMPORTED_MODULE_7__[/* PROGRESS */ "c"],
buffer: bufferLength
}));
}
};

return fetch(url, {
onProgress: onProgress
}).then(function (_ref8) {
var data = _ref8.data,
metric = _ref8.metric;
lastSegment = segment;
metric.segmentInfo = segmentInfo;
segmentLogger.info("[".concat(mediaElement.getCurrentTime(), "] DOWNLOADED SEGMENT: [").concat(representationId, "]: start: ").concat(segmentInfo.start, ", id: ").concat(index, ", bandwidth: ").concat(bandwidth / 1000));
queue.push(_objectSpread({}, segmentInfo, {
data: data
}));
ctx.trigger(_renderer_dash_event_dash_event__WEBPACK_IMPORTED_MODULE_11__[/* SEGMENT_DOWNLOADED */ "g"], metric);
})["catch"](function (_ref9) {
var error = _ref9.error,
metric = _ref9.metric,
xhr = _ref9.xhr;

if (error === _core_util_http_http_status__WEBPACK_IMPORTED_MODULE_7__[/* FAILED */ "b"]) {
metric.segmentInfo = segmentInfo;
ctx.trigger(_renderer_dash_event_dash_event__WEBPACK_IMPORTED_MODULE_11__[/* FAILED_TO_DOWNLOAD_SEGMENT */ "d"], metric, xhr);
}
}).then(function () {
cancelRequest = null;
_isProcessingRequest = false;
});
}

function fetch(url) {
var _httpConfig$fragment2;

var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return _core_util_http__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].getBinary(url, _objectSpread({}, opts, {
cancelToken: new _core_util_http__WEBPACK_IMPORTED_MODULE_5__[/* default */ "a"].CancelToken(function (c) {
return cancelRequest = c;
}),
withCredentials: streamWithCredentials || !!(httpConfig === null || httpConfig === void 0 ? void 0 : (_httpConfig$fragment2 = httpConfig.fragment) === null || _httpConfig$fragment2 === void 0 ? void 0 : _httpConfig$fragment2.withCredentials),
headers: headers
}));
}

function getPeriod() {
var _representation2;

return (_representation2 = representation) === null || _representation2 === void 0 ? void 0 : _representation2.period;
}

function getRepresentation() {
return representation;
}

function getAdaptation() {
return adaptation;
}

function getBandwidth() {
return bandwidth;
}

function trace(info) {
segmentLogger.trace("[".concat(mediaElement.getCurrentTime(), "] ").concat(info));
}

function restart() {
cached = {};
reset();
}

return {
on: ctx.on.bind(ctx),
off: ctx.off.bind(ctx),
trigger: ctx.trigger.bind(ctx),
setAdaptation: setAdaptation,
switchProfile: switchProfile,
getAdaptation: getAdaptation,
getBandwidth: getBandwidth,
getPeriod: getPeriod,
getRepresentation: getRepresentation,
findSegmentByPosition: findSegmentByPosition,
getNextSegmentToSwitch: getNextSegmentToSwitch,
getQueue: getQueue,
getQueueStart: getQueueStart,
getAllSegments: getAllSegments,
getQueueLengthFromTime: getQueueLengthFromTime,
start: start,
stop: stop,
next: next,
pause: pause,
abort: abort,
update: update,
flush: flush,
resume: resume,
restart: restart,
isLastSegment: isLastSegment,
isProcessingRequest: isProcessingRequest
};
}

/***/ }),
/* 45 */
/***/ (function(module, exports, __webpack_require__) {

var arrayLikeToArray = __webpack_require__(46);

function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(n);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return arrayLikeToArray(o, minLen);
}

module.exports = _unsupportedIterableToArray;

/***/ }),
/* 46 */
/***/ (function(module, exports) {

function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;

for (var i = 0, arr2 = new Array(len); i < len; i++) {
arr2[i] = arr[i];
}

return arr2;
}

module.exports = _arrayLikeToArray;

/***/ }),
/* 47 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony default export */ __webpack_exports__["a"] = ({
ID: 'hlsjs',
OPTION_NAME: 'hlsjs',
PRIORITY: 100,
SUPPORTED_MEDIA_TYPES: {
HLS: 'application/x-mpegURL'
}
});

/***/ }),
/* 48 */
/***/ (function(module, exports) {

function _setPrototypeOf(o, p) {
module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};

return _setPrototypeOf(o, p);
}

module.exports = _setPrototypeOf;

/***/ }),
/* 49 */
/***/ (function(module, exports, __webpack_require__) {

var setPrototypeOf = __webpack_require__(48);

var isNativeReflectConstruct = __webpack_require__(64);

function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
module.exports = _construct = Reflect.construct;
} else {
module.exports = _construct = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) setPrototypeOf(instance, Class.prototype);
return instance;
};
}

return _construct.apply(null, arguments);
}

module.exports = _construct;

/***/ }),
/* 50 */
/***/ (function(module, exports, __webpack_require__) {

/*! codem-isoboxer v0.3.7 https://github.com/madebyhiro/codem-isoboxer/blob/master/LICENSE.txt */
var ISOBoxer = {};

ISOBoxer.parseBuffer = function(arrayBuffer) {
return new ISOFile(arrayBuffer).parse();
};

ISOBoxer.addBoxProcessor = function(type, parser) {
if (typeof type !== 'string' || typeof parser !== 'function') {
return;
}
ISOBox.prototype._boxProcessors[type] = parser;
};

ISOBoxer.createFile = function() {
return new ISOFile();
};

// See ISOBoxer.append() for 'pos' parameter syntax
ISOBoxer.createBox = function(type, parent, pos) {
var newBox = ISOBox.create(type);
if (parent) {
parent.append(newBox, pos);
}
return newBox;
};

// See ISOBoxer.append() for 'pos' parameter syntax
ISOBoxer.createFullBox = function(type, parent, pos) {
var newBox = ISOBoxer.createBox(type, parent, pos);
newBox.version = 0;
newBox.flags = 0;
return newBox;
};

ISOBoxer.Utils = {};
ISOBoxer.Utils.dataViewToString = function(dataView, encoding) {
var impliedEncoding = encoding || 'utf-8';
if (typeof TextDecoder !== 'undefined') {
return new TextDecoder(impliedEncoding).decode(dataView);
}
var a = [];
var i = 0;

if (impliedEncoding === 'utf-8') {
/* The following algorithm is essentially a rewrite of the UTF8.decode at
http://bannister.us/weblog/2007/simple-base64-encodedecode-javascript/
*/

while (i < dataView.byteLength) {
var c = dataView.getUint8(i++);
if (c < 0x80) {
// 1-byte character (7 bits)
} else if (c < 0xe0) {
// 2-byte character (11 bits)
c = (c & 0x1f) << 6;
c |= (dataView.getUint8(i++) & 0x3f);
} else if (c < 0xf0) {
// 3-byte character (16 bits)
c = (c & 0xf) << 12;
c |= (dataView.getUint8(i++) & 0x3f) << 6;
c |= (dataView.getUint8(i++) & 0x3f);
} else {
// 4-byte character (21 bits)
c = (c & 0x7) << 18;
c |= (dataView.getUint8(i++) & 0x3f) << 12;
c |= (dataView.getUint8(i++) & 0x3f) << 6;
c |= (dataView.getUint8(i++) & 0x3f);
}
a.push(String.fromCharCode(c));
}
} else { // Just map byte-by-byte (probably wrong)
while (i < dataView.byteLength) {
a.push(String.fromCharCode(dataView.getUint8(i++)));
}
}
return a.join('');
};

ISOBoxer.Utils.utf8ToByteArray = function(string) {
// Only UTF-8 encoding is supported by TextEncoder
var u, i;
if (typeof TextEncoder !== 'undefined') {
u = new TextEncoder().encode(string);
} else {
u = [];
for (i = 0; i < string.length; ++i) {
var c = string.charCodeAt(i);
if (c < 0x80) {
u.push(c);
} else if (c < 0x800) {
u.push(0xC0 | (c >> 6));
u.push(0x80 | (63 & c));
} else if (c < 0x10000) {
u.push(0xE0 | (c >> 12));
u.push(0x80 | (63 & (c >> 6)));
u.push(0x80 | (63 & c));
} else {
u.push(0xF0 | (c >> 18));
u.push(0x80 | (63 & (c >> 12)));
u.push(0x80 | (63 & (c >> 6)));
u.push(0x80 | (63 & c));
}
}
}
return u;
};

// Method to append a box in the list of child boxes
// The 'pos' parameter can be either:
// - (number) a position index at which to insert the new box
// - (string) the type of the box after which to insert the new box
// - (object) the box after which to insert the new box
ISOBoxer.Utils.appendBox = function(parent, box, pos) {
box._offset = parent._cursor.offset;
box._root = (parent._root ? parent._root : parent);
box._raw = parent._raw;
box._parent = parent;

if (pos === -1) {
// The new box is a sub-box of the parent but not added in boxes array,
// for example when the new box is set as an entry (see dref and stsd for example)
return;
}

if (pos === undefined || pos === null) {
parent.boxes.push(box);
return;
}

var index = -1,
type;

if (typeof pos === "number") {
index = pos;
} else {
if (typeof pos === "string") {
type = pos;
} else if (typeof pos === "object" && pos.type) {
type = pos.type;
} else {
parent.boxes.push(box);
return;
}

for (var i = 0; i < parent.boxes.length; i++) {
if (type === parent.boxes[i].type) {
index = i + 1;
break;
}
}
}
parent.boxes.splice(index, 0, box);
};

if (true) {
exports.parseBuffer = ISOBoxer.parseBuffer;
exports.addBoxProcessor = ISOBoxer.addBoxProcessor;
exports.createFile = ISOBoxer.createFile;
exports.createBox = ISOBoxer.createBox;
exports.createFullBox = ISOBoxer.createFullBox;
exports.Utils = ISOBoxer.Utils;
}

ISOBoxer.Cursor = function(initialOffset) {
this.offset = (typeof initialOffset == 'undefined' ? 0 : initialOffset);
};

var ISOFile = function(arrayBuffer) {
this._cursor = new ISOBoxer.Cursor();
this.boxes = [];
if (arrayBuffer) {
this._raw = new DataView(arrayBuffer);
}
};

ISOFile.prototype.fetch = function(type) {
var result = this.fetchAll(type, true);
return (result.length ? result[0] : null);
};

ISOFile.prototype.fetchAll = function(type, returnEarly) {
var result = [];
ISOFile._sweep.call(this, type, result, returnEarly);
return result;
};

ISOFile.prototype.parse = function() {
this._cursor.offset = 0;
this.boxes = [];
while (this._cursor.offset < this._raw.byteLength) {
var box = ISOBox.parse(this);

// Box could not be parsed
if (typeof box.type === 'undefined') break;

this.boxes.push(box);
}
return this;
};

ISOFile._sweep = function(type, result, returnEarly) {
if (this.type && this.type == type) result.push(this);
for (var box in this.boxes) {
if (result.length && returnEarly) return;
ISOFile._sweep.call(this.boxes[box], type, result, returnEarly);
}
};

ISOFile.prototype.write = function() {

var length = 0,
i;

for (i = 0; i < this.boxes.length; i++) {
length += this.boxes[i].getLength(false);
}

var bytes = new Uint8Array(length);
this._rawo = new DataView(bytes.buffer);
this.bytes = bytes;
this._cursor.offset = 0;

for (i = 0; i < this.boxes.length; i++) {
this.boxes[i].write();
}

return bytes.buffer;
};

ISOFile.prototype.append = function(box, pos) {
ISOBoxer.Utils.appendBox(this, box, pos);
};
var ISOBox = function() {
this._cursor = new ISOBoxer.Cursor();
};

ISOBox.parse = function(parent) {
var newBox = new ISOBox();
newBox._offset = parent._cursor.offset;
newBox._root = (parent._root ? parent._root : parent);
newBox._raw = parent._raw;
newBox._parent = parent;
newBox._parseBox();
parent._cursor.offset = newBox._raw.byteOffset + newBox._raw.byteLength;
return newBox;
};

ISOBox.create = function(type) {
var newBox = new ISOBox();
newBox.type = type;
newBox.boxes = [];
return newBox;
};

ISOBox.prototype._boxContainers = ['dinf', 'edts', 'mdia', 'meco', 'mfra', 'minf', 'moof', 'moov', 'mvex', 'stbl', 'strk', 'traf', 'trak', 'tref', 'udta', 'vttc', 'sinf', 'schi', 'encv', 'enca'];

ISOBox.prototype._boxProcessors = {};

///////////////////////////////////////////////////////////////////////////////////////////////////
// Generic read/write functions

ISOBox.prototype._procField = function (name, type, size) {
if (this._parsing) {
this[name] = this._readField(type, size);
}
else {
this._writeField(type, size, this[name]);
}
};

ISOBox.prototype._procFieldArray = function (name, length, type, size) {
var i;
if (this._parsing) {
this[name] = [];
for (i = 0; i < length; i++) {
this[name][i] = this._readField(type, size);
}
}
else {
for (i = 0; i < this[name].length; i++) {
this._writeField(type, size, this[name][i]);
}
}
};

ISOBox.prototype._procFullBox = function() {
this._procField('version', 'uint', 8);
this._procField('flags', 'uint', 24);
};

ISOBox.prototype._procEntries = function(name, length, fn) {
var i;
if (this._parsing) {
this[name] = [];
for (i = 0; i < length; i++) {
this[name].push({});
fn.call(this, this[name][i]);
}
}
else {
for (i = 0; i < length; i++) {
fn.call(this, this[name][i]);
}
}
};

ISOBox.prototype._procSubEntries = function(entry, name, length, fn) {
var i;
if (this._parsing) {
entry[name] = [];
for (i = 0; i < length; i++) {
entry[name].push({});
fn.call(this, entry[name][i]);
}
}
else {
for (i = 0; i < length; i++) {
fn.call(this, entry[name][i]);
}
}
};

ISOBox.prototype._procEntryField = function (entry, name, type, size) {
if (this._parsing) {
entry[name] = this._readField(type, size);
}
else {
this._writeField(type, size, entry[name]);
}
};

ISOBox.prototype._procSubBoxes = function(name, length) {
var i;
if (this._parsing) {
this[name] = [];
for (i = 0; i < length; i++) {
this[name].push(ISOBox.parse(this));
}
}
else {
for (i = 0; i < length; i++) {
if (this._rawo) {
this[name][i].write();
} else {
this.size += this[name][i].getLength();
}
}
}
};

///////////////////////////////////////////////////////////////////////////////////////////////////
// Read/parse functions

ISOBox.prototype._readField = function(type, size) {
switch (type) {
case 'uint':
return this._readUint(size);
case 'int':
return this._readInt(size);
case 'template':
return this._readTemplate(size);
case 'string':
return (size === -1) ? this._readTerminatedString() : this._readString(size);
case 'data':
return this._readData(size);
case 'utf8':
return this._readUTF8String();
default:
return -1;
}
};

ISOBox.prototype._readInt = function(size) {
var result = null,
offset = this._cursor.offset - this._raw.byteOffset;
switch(size) {
case 8:
result = this._raw.getInt8(offset);
break;
case 16:
result = this._raw.getInt16(offset);
break;
case 32:
result = this._raw.getInt32(offset);
break;
case 64:
// Warning: JavaScript cannot handle 64-bit integers natively.
// This will give unexpected results for integers >= 2^53
var s1 = this._raw.getInt32(offset);
var s2 = this._raw.getInt32(offset + 4);
result = (s1 * Math.pow(2,32)) + s2;
break;
}
this._cursor.offset += (size >> 3);
return result;
};

ISOBox.prototype._readUint = function(size) {
var result = null,
offset = this._cursor.offset - this._raw.byteOffset,
s1, s2;
switch(size) {
case 8:
result = this._raw.getUint8(offset);
break;
case 16:
result = this._raw.getUint16(offset);
break;
case 24:
s1 = this._raw.getUint16(offset);
s2 = this._raw.getUint8(offset + 2);
result = (s1 << 8) + s2;
break;
case 32:
result = this._raw.getUint32(offset);
break;
case 64:
// Warning: JavaScript cannot handle 64-bit integers natively.
// This will give unexpected results for integers >= 2^53
s1 = this._raw.getUint32(offset);
s2 = this._raw.getUint32(offset + 4);
result = (s1 * Math.pow(2,32)) + s2;
break;
}
this._cursor.offset += (size >> 3);
return result;
};

ISOBox.prototype._readString = function(length) {
var str = '';
for (var c = 0; c < length; c++) {
var char = this._readUint(8);
str += String.fromCharCode(char);
}
return str;
};

ISOBox.prototype._readTemplate = function(size) {
var pre = this._readUint(size / 2);
var post = this._readUint(size / 2);
return pre + (post / Math.pow(2, size / 2));
};

ISOBox.prototype._readTerminatedString = function() {
var str = '';
while (this._cursor.offset - this._offset < this._raw.byteLength) {
var char = this._readUint(8);
if (char === 0) break;
str += String.fromCharCode(char);
}
return str;
};

ISOBox.prototype._readData = function(size) {
var length = (size > 0) ? size : (this._raw.byteLength - (this._cursor.offset - this._offset));
if (length > 0) {
var data = new Uint8Array(this._raw.buffer, this._cursor.offset, length);

this._cursor.offset += length;
return data;
}
else {
return null;
}
};

ISOBox.prototype._readUTF8String = function() {
var length = this._raw.byteLength - (this._cursor.offset - this._offset);
var data = null;
if (length > 0) {
data = new DataView(this._raw.buffer, this._cursor.offset, length);
this._cursor.offset += length;
}

return data ? ISOBoxer.Utils.dataViewToString(data) : data;
};

ISOBox.prototype._parseBox = function() {
this._parsing = true;
this._cursor.offset = this._offset;

// return immediately if there are not enough bytes to read the header
if (this._offset + 8 > this._raw.buffer.byteLength) {
this._root._incomplete = true;
return;
}

this._procField('size', 'uint', 32);
this._procField('type', 'string', 4);

if (this.size === 1) { this._procField('largesize', 'uint', 64); }
if (this.type === 'uuid') { this._procFieldArray('usertype', 16, 'uint', 8); }

switch(this.size) {
case 0:
this._raw = new DataView(this._raw.buffer, this._offset, (this._raw.byteLength - this._cursor.offset + 8));
break;
case 1:
if (this._offset + this.size > this._raw.buffer.byteLength) {
this._incomplete = true;
this._root._incomplete = true;
} else {
this._raw = new DataView(this._raw.buffer, this._offset, this.largesize);
}
break;
default:
if (this._offset + this.size > this._raw.buffer.byteLength) {
this._incomplete = true;
this._root._incomplete = true;
} else {
this._raw = new DataView(this._raw.buffer, this._offset, this.size);
}
}

// additional parsing
if (!this._incomplete) {
if (this._boxProcessors[this.type]) {
this._boxProcessors[this.type].call(this);
}
if (this._boxContainers.indexOf(this.type) !== -1) {
this._parseContainerBox();
} else{
// Unknown box => read and store box content
this._data = this._readData();
}
}
};

ISOBox.prototype._parseFullBox = function() {
this.version = this._readUint(8);
this.flags = this._readUint(24);
};

ISOBox.prototype._parseContainerBox = function() {
this.boxes = [];
while (this._cursor.offset - this._raw.byteOffset < this._raw.byteLength) {
this.boxes.push(ISOBox.parse(this));
}
};

///////////////////////////////////////////////////////////////////////////////////////////////////
// Write functions

ISOBox.prototype.append = function(box, pos) {
ISOBoxer.Utils.appendBox(this, box, pos);
};

ISOBox.prototype.getLength = function() {
this._parsing = false;
this._rawo = null;

this.size = 0;
this._procField('size', 'uint', 32);
this._procField('type', 'string', 4);

if (this.size === 1) { this._procField('largesize', 'uint', 64); }
if (this.type === 'uuid') { this._procFieldArray('usertype', 16, 'uint', 8); }

if (this._boxProcessors[this.type]) {
this._boxProcessors[this.type].call(this);
}

if (this._boxContainers.indexOf(this.type) !== -1) {
for (var i = 0; i < this.boxes.length; i++) {
this.size += this.boxes[i].getLength();
}
}

if (this._data) {
this._writeData(this._data);
}

return this.size;
};

ISOBox.prototype.write = function() {
this._parsing = false;
this._cursor.offset = this._parent._cursor.offset;

switch(this.size) {
case 0:
this._rawo = new DataView(this._parent._rawo.buffer, this._cursor.offset, (this.parent._rawo.byteLength - this._cursor.offset));
break;
case 1:
this._rawo = new DataView(this._parent._rawo.buffer, this._cursor.offset, this.largesize);
break;
default:
this._rawo = new DataView(this._parent._rawo.buffer, this._cursor.offset, this.size);
}

this._procField('size', 'uint', 32);
this._procField('type', 'string', 4);

if (this.size === 1) { this._procField('largesize', 'uint', 64); }
if (this.type === 'uuid') { this._procFieldArray('usertype', 16, 'uint', 8); }

if (this._boxProcessors[this.type]) {
this._boxProcessors[this.type].call(this);
}

if (this._boxContainers.indexOf(this.type) !== -1) {
for (var i = 0; i < this.boxes.length; i++) {
this.boxes[i].write();
}
}

if (this._data) {
this._writeData(this._data);
}

this._parent._cursor.offset += this.size;

return this.size;
};

ISOBox.prototype._writeInt = function(size, value) {
if (this._rawo) {
var offset = this._cursor.offset - this._rawo.byteOffset;
switch(size) {
case 8:
this._rawo.setInt8(offset, value);
break;
case 16:
this._rawo.setInt16(offset, value);
break;
case 32:
this._rawo.setInt32(offset, value);
break;
case 64:
// Warning: JavaScript cannot handle 64-bit integers natively.
// This will give unexpected results for integers >= 2^53
var s1 = Math.floor(value / Math.pow(2,32));
var s2 = value - (s1 * Math.pow(2,32));
this._rawo.setUint32(offset, s1);
this._rawo.setUint32(offset + 4, s2);
break;
}
this._cursor.offset += (size >> 3);
} else {
this.size += (size >> 3);
}
};

ISOBox.prototype._writeUint = function(size, value) {

if (this._rawo) {
var offset = this._cursor.offset - this._rawo.byteOffset,
s1, s2;
switch(size) {
case 8:
this._rawo.setUint8(offset, value);
break;
case 16:
this._rawo.setUint16(offset, value);
break;
case 24:
s1 = (value & 0xFFFF00) >> 8;
s2 = (value & 0x0000FF);
this._rawo.setUint16(offset, s1);
this._rawo.setUint8(offset + 2, s2);
break;
case 32:
this._rawo.setUint32(offset, value);
break;
case 64:
// Warning: JavaScript cannot handle 64-bit integers natively.
// This will give unexpected results for integers >= 2^53
s1 = Math.floor(value / Math.pow(2,32));
s2 = value - (s1 * Math.pow(2,32));
this._rawo.setUint32(offset, s1);
this._rawo.setUint32(offset + 4, s2);
break;
}
this._cursor.offset += (size >> 3);
} else {
this.size += (size >> 3);
}
};

ISOBox.prototype._writeString = function(size, str) {
for (var c = 0; c < size; c++) {
this._writeUint(8, str.charCodeAt(c));
}
};

ISOBox.prototype._writeTerminatedString = function(str) {
if (str.length === 0) {
return;
}
for (var c = 0; c < str.length; c++) {
this._writeUint(8, str.charCodeAt(c));
}
this._writeUint(8, 0);
};

ISOBox.prototype._writeTemplate = function(size, value) {
var pre = Math.floor(value);
var post = (value - pre) * Math.pow(2, size / 2);
this._writeUint(size / 2, pre);
this._writeUint(size / 2, post);
};

ISOBox.prototype._writeData = function(data) {
var i;
//data to copy
if (data) {
if (this._rawo) {
//Array and Uint8Array has also to be managed
if (data instanceof Array) {
var offset = this._cursor.offset - this._rawo.byteOffset;
for (var i = 0; i < data.length; i++) {
this._rawo.setInt8(offset + i, data[i]);
}
this._cursor.offset += data.length;
}

if (data instanceof Uint8Array) {
this._root.bytes.set(data, this._cursor.offset);
this._cursor.offset += data.length;
}

} else {
//nothing to copy only size to compute
this.size += data.length;
}
}
};

ISOBox.prototype._writeUTF8String = function(string) {
var u = ISOBoxer.Utils.utf8ToByteArray(string);
if (this._rawo) {
var dataView = new DataView(this._rawo.buffer, this._cursor.offset, u.length);
for (var i = 0; i < u.length; i++) {
dataView.setUint8(i, u[i]);
}
} else {
this.size += u.length;
}
};

ISOBox.prototype._writeField = function(type, size, value) {
switch (type) {
case 'uint':
this._writeUint(size, value);
break;
case 'int':
this._writeInt(size, value);
break;
case 'template':
this._writeTemplate(size, value);
break;
case 'string':
if (size == -1) {
this._writeTerminatedString(value);
} else {
this._writeString(size, value);
}
break;
case 'data':
this._writeData(value);
break;
case 'utf8':
this._writeUTF8String(value);
break;
default:
break;
}
};

// ISO/IEC 14496-15:2014 - avc1/2/3/4, hev1, hvc1, encv
ISOBox.prototype._boxProcessors['avc1'] =
ISOBox.prototype._boxProcessors['avc2'] =
ISOBox.prototype._boxProcessors['avc3'] =
ISOBox.prototype._boxProcessors['avc4'] =
ISOBox.prototype._boxProcessors['hvc1'] =
ISOBox.prototype._boxProcessors['hev1'] =
ISOBox.prototype._boxProcessors['encv'] = function() {
// SampleEntry fields
this._procFieldArray('reserved1', 6, 'uint', 8);
this._procField('data_reference_index', 'uint', 16);
// VisualSampleEntry fields
this._procField('pre_defined1', 'uint', 16);
this._procField('reserved2', 'uint', 16);
this._procFieldArray('pre_defined2', 3, 'uint', 32);
this._procField('width', 'uint', 16);
this._procField('height', 'uint', 16);
this._procField('horizresolution', 'template', 32);
this._procField('vertresolution', 'template', 32);
this._procField('reserved3', 'uint', 32);
this._procField('frame_count', 'uint', 16);
this._procFieldArray('compressorname', 32,'uint', 8);
this._procField('depth', 'uint', 16);
this._procField('pre_defined3', 'int', 16);
// Codec-specific fields
this._procField('config', 'data', -1);
};

// ISO/IEC 14496-12:2012 - 8.7.2 Data Reference Box
ISOBox.prototype._boxProcessors['dref'] = function() {
this._procFullBox();
this._procField('entry_count', 'uint', 32);
this._procSubBoxes('entries', this.entry_count);
};

// ISO/IEC 14496-12:2012 - 8.6.6 Edit List Box
ISOBox.prototype._boxProcessors['elst'] = function() {
this._procFullBox();
this._procField('entry_count', 'uint', 32);
this._procEntries('entries', this.entry_count, function(entry) {
this._procEntryField(entry, 'segment_duration', 'uint', (this.version === 1) ? 64 : 32);
this._procEntryField(entry, 'media_time', 'int', (this.version === 1) ? 64 : 32);
this._procEntryField(entry, 'media_rate_integer', 'int', 16);
this._procEntryField(entry, 'media_rate_fraction', 'int', 16);
});
};

// ISO/IEC 23009-1:2014 - 5.10.3.3 Event Message Box
ISOBox.prototype._boxProcessors['emsg'] = function() {
this._procFullBox();
if (this.version == 1) {
this._procField('timescale', 'uint', 32);
this._procField('presentation_time', 'uint', 64);
this._procField('event_duration', 'uint', 32);
this._procField('id', 'uint', 32);
this._procField('scheme_id_uri', 'string', -1);
this._procField('value', 'string', -1);
} else {
this._procField('scheme_id_uri', 'string', -1);
this._procField('value', 'string', -1);
this._procField('timescale', 'uint', 32);
this._procField('presentation_time_delta', 'uint', 32);
this._procField('event_duration', 'uint', 32);
this._procField('id', 'uint', 32);
}
this._procField('message_data', 'data', -1);
};
// ISO/IEC 14496-12:2012 - 8.1.2 Free Space Box
ISOBox.prototype._boxProcessors['free'] = ISOBox.prototype._boxProcessors['skip'] = function() {
this._procField('data', 'data', -1);
};

// ISO/IEC 14496-12:2012 - 8.12.2 Original Format Box
ISOBox.prototype._boxProcessors['frma'] = function() {
this._procField('data_format', 'uint', 32);
};
// ISO/IEC 14496-12:2012 - 4.3 File Type Box / 8.16.2 Segment Type Box
ISOBox.prototype._boxProcessors['ftyp'] =
ISOBox.prototype._boxProcessors['styp'] = function() {
this._procField('major_brand', 'string', 4);
this._procField('minor_version', 'uint', 32);
var nbCompatibleBrands = -1;
if (this._parsing) {
nbCompatibleBrands = (this._raw.byteLength - (this._cursor.offset - this._raw.byteOffset)) / 4;
}
this._procFieldArray('compatible_brands', nbCompatibleBrands, 'string', 4);
};

// ISO/IEC 14496-12:2012 - 8.4.3 Handler Reference Box
ISOBox.prototype._boxProcessors['hdlr'] = function() {
this._procFullBox();
this._procField('pre_defined', 'uint', 32);
this._procField('handler_type', 'string', 4);
this._procFieldArray('reserved', 3, 'uint', 32);
this._procField('name', 'string', -1);
};

// ISO/IEC 14496-12:2012 - 8.1.1 Media Data Box
ISOBox.prototype._boxProcessors['mdat'] = function() {
this._procField('data', 'data', -1);
};

// ISO/IEC 14496-12:2012 - 8.4.2 Media Header Box
ISOBox.prototype._boxProcessors['mdhd'] = function() {
this._procFullBox();
this._procField('creation_time', 'uint', (this.version == 1) ? 64 : 32);
this._procField('modification_time', 'uint', (this.version == 1) ? 64 : 32);
this._procField('timescale', 'uint', 32);
this._procField('duration', 'uint', (this.version == 1) ? 64 : 32);
if (!this._parsing && typeof this.language === 'string') {
// In case of writing and language has been set as a string, then convert it into char codes array
this.language = ((this.language.charCodeAt(0) - 0x60) << 10) |
((this.language.charCodeAt(1) - 0x60) << 5) |
((this.language.charCodeAt(2) - 0x60));
}
this._procField('language', 'uint', 16);
if (this._parsing) {
this.language = String.fromCharCode(((this.language >> 10) & 0x1F) + 0x60,
((this.language >> 5) & 0x1F) + 0x60,
(this.language & 0x1F) + 0x60);
}
this._procField('pre_defined', 'uint', 16);
};

// ISO/IEC 14496-12:2012 - 8.8.2 Movie Extends Header Box
ISOBox.prototype._boxProcessors['mehd'] = function() {
this._procFullBox();
this._procField('fragment_duration', 'uint', (this.version == 1) ? 64 : 32);
};

// ISO/IEC 14496-12:2012 - 8.8.5 Movie Fragment Header Box
ISOBox.prototype._boxProcessors['mfhd'] = function() {
this._procFullBox();
this._procField('sequence_number', 'uint', 32);
};

// ISO/IEC 14496-12:2012 - 8.8.11 Movie Fragment Random Access Box
ISOBox.prototype._boxProcessors['mfro'] = function() {
this._procFullBox();
this._procField('mfra_size', 'uint', 32); // Called mfra_size to distinguish from the normal "size" attribute of a box
};


// ISO/IEC 14496-12:2012 - 8.5.2.2 mp4a box (use AudioSampleEntry definition and naming)
ISOBox.prototype._boxProcessors['mp4a'] = ISOBox.prototype._boxProcessors['enca'] = function() {
// SampleEntry fields
this._procFieldArray('reserved1', 6, 'uint', 8);
this._procField('data_reference_index', 'uint', 16);
// AudioSampleEntry fields
this._procFieldArray('reserved2', 2, 'uint', 32);
this._procField('channelcount', 'uint', 16);
this._procField('samplesize', 'uint', 16);
this._procField('pre_defined', 'uint', 16);
this._procField('reserved3', 'uint', 16);
this._procField('samplerate', 'template', 32);
// ESDescriptor fields
this._procField('esds', 'data', -1);
};

// ISO/IEC 14496-12:2012 - 8.2.2 Movie Header Box
ISOBox.prototype._boxProcessors['mvhd'] = function() {
this._procFullBox();
this._procField('creation_time', 'uint', (this.version == 1) ? 64 : 32);
this._procField('modification_time', 'uint', (this.version == 1) ? 64 : 32);
this._procField('timescale', 'uint', 32);
this._procField('duration', 'uint', (this.version == 1) ? 64 : 32);
this._procField('rate', 'template', 32);
this._procField('volume', 'template', 16);
this._procField('reserved1', 'uint', 16);
this._procFieldArray('reserved2', 2, 'uint', 32);
this._procFieldArray('matrix', 9, 'template', 32);
this._procFieldArray('pre_defined', 6,'uint', 32);
this._procField('next_track_ID', 'uint', 32);
};

// ISO/IEC 14496-30:2014 - WebVTT Cue Payload Box.
ISOBox.prototype._boxProcessors['payl'] = function() {
this._procField('cue_text', 'utf8');
};

//ISO/IEC 23001-7:2011 - 8.1 Protection System Specific Header Box
ISOBox.prototype._boxProcessors['pssh'] = function() {
this._procFullBox();

this._procFieldArray('SystemID', 16, 'uint', 8);
this._procField('DataSize', 'uint', 32);
this._procFieldArray('Data', this.DataSize, 'uint', 8);
};
// ISO/IEC 14496-12:2012 - 8.12.5 Scheme Type Box
ISOBox.prototype._boxProcessors['schm'] = function() {
this._procFullBox();

this._procField('scheme_type', 'uint', 32);
this._procField('scheme_version', 'uint', 32);

if (this.flags & 0x000001) {
this._procField('scheme_uri', 'string', -1);
}
};
// ISO/IEC 14496-12:2012 - 8.6.4.1 sdtp box
ISOBox.prototype._boxProcessors['sdtp'] = function() {
this._procFullBox();

var sample_count = -1;
if (this._parsing) {
sample_count = (this._raw.byteLength - (this._cursor.offset - this._raw.byteOffset));
}

this._procFieldArray('sample_dependency_table', sample_count, 'uint', 8);
};

// ISO/IEC 14496-12:2012 - 8.16.3 Segment Index Box
ISOBox.prototype._boxProcessors['sidx'] = function() {
this._procFullBox();
this._procField('reference_ID', 'uint', 32);
this._procField('timescale', 'uint', 32);
this._procField('earliest_presentation_time', 'uint', (this.version == 1) ? 64 : 32);
this._procField('first_offset', 'uint', (this.version == 1) ? 64 : 32);
this._procField('reserved', 'uint', 16);
this._procField('reference_count', 'uint', 16);
this._procEntries('references', this.reference_count, function(entry) {
if (!this._parsing) {
entry.reference = (entry.reference_type & 0x00000001) << 31;
entry.reference |= (entry.referenced_size & 0x7FFFFFFF);
entry.sap = (entry.starts_with_SAP & 0x00000001) << 31;
entry.sap |= (entry.SAP_type & 0x00000003) << 28;
entry.sap |= (entry.SAP_delta_time & 0x0FFFFFFF);
}
this._procEntryField(entry, 'reference', 'uint', 32);
this._procEntryField(entry, 'subsegment_duration', 'uint', 32);
this._procEntryField(entry, 'sap', 'uint', 32);
if (this._parsing) {
entry.reference_type = (entry.reference >> 31) & 0x00000001;
entry.referenced_size = entry.reference & 0x7FFFFFFF;
entry.starts_with_SAP = (entry.sap >> 31) & 0x00000001;
entry.SAP_type = (entry.sap >> 28) & 0x00000007;
entry.SAP_delta_time = (entry.sap & 0x0FFFFFFF);
}
});
};

// ISO/IEC 14496-12:2012 - 8.4.5.3 Sound Media Header Box
ISOBox.prototype._boxProcessors['smhd'] = function() {
this._procFullBox();
this._procField('balance', 'uint', 16);
this._procField('reserved', 'uint', 16);
};

// ISO/IEC 14496-12:2012 - 8.16.4 Subsegment Index Box
ISOBox.prototype._boxProcessors['ssix'] = function() {
this._procFullBox();
this._procField('subsegment_count', 'uint', 32);
this._procEntries('subsegments', this.subsegment_count, function(subsegment) {
this._procEntryField(subsegment, 'ranges_count', 'uint', 32);
this._procSubEntries(subsegment, 'ranges', subsegment.ranges_count, function(range) {
this._procEntryField(range, 'level', 'uint', 8);
this._procEntryField(range, 'range_size', 'uint', 24);
});
});
};

// ISO/IEC 14496-12:2012 - 8.5.2 Sample Description Box
ISOBox.prototype._boxProcessors['stsd'] = function() {
this._procFullBox();
this._procField('entry_count', 'uint', 32);
this._procSubBoxes('entries', this.entry_count);
};

// ISO/IEC 14496-12:2015 - 8.7.7 Sub-Sample Information Box
ISOBox.prototype._boxProcessors['subs'] = function () {
this._procFullBox();
this._procField('entry_count', 'uint', 32);
this._procEntries('entries', this.entry_count, function(entry) {
this._procEntryField(entry, 'sample_delta', 'uint', 32);
this._procEntryField(entry, 'subsample_count', 'uint', 16);
this._procSubEntries(entry, 'subsamples', entry.subsample_count, function(subsample) {
this._procEntryField(subsample, 'subsample_size', 'uint', (this.version === 1) ? 32 : 16);
this._procEntryField(subsample, 'subsample_priority', 'uint', 8);
this._procEntryField(subsample, 'discardable', 'uint', 8);
this._procEntryField(subsample, 'codec_specific_parameters', 'uint', 32);
});
});
};

//ISO/IEC 23001-7:2011 - 8.2 Track Encryption Box
ISOBox.prototype._boxProcessors['tenc'] = function() {
this._procFullBox();

this._procField('default_IsEncrypted', 'uint', 24);
this._procField('default_IV_size', 'uint', 8);
this._procFieldArray('default_KID', 16, 'uint', 8);
};

// ISO/IEC 14496-12:2012 - 8.8.12 Track Fragmnent Decode Time
ISOBox.prototype._boxProcessors['tfdt'] = function() {
this._procFullBox();
this._procField('baseMediaDecodeTime', 'uint', (this.version == 1) ? 64 : 32);
};

// ISO/IEC 14496-12:2012 - 8.8.7 Track Fragment Header Box
ISOBox.prototype._boxProcessors['tfhd'] = function() {
this._procFullBox();
this._procField('track_ID', 'uint', 32);
if (this.flags & 0x01) this._procField('base_data_offset', 'uint', 64);
if (this.flags & 0x02) this._procField('sample_description_offset', 'uint', 32);
if (this.flags & 0x08) this._procField('default_sample_duration', 'uint', 32);
if (this.flags & 0x10) this._procField('default_sample_size', 'uint', 32);
if (this.flags & 0x20) this._procField('default_sample_flags', 'uint', 32);
};

// ISO/IEC 14496-12:2012 - 8.8.10 Track Fragment Random Access Box
ISOBox.prototype._boxProcessors['tfra'] = function() {
this._procFullBox();
this._procField('track_ID', 'uint', 32);
if (!this._parsing) {
this.reserved = 0;
this.reserved |= (this.length_size_of_traf_num & 0x00000030) << 4;
this.reserved |= (this.length_size_of_trun_num & 0x0000000C) << 2;
this.reserved |= (this.length_size_of_sample_num & 0x00000003);
}
this._procField('reserved', 'uint', 32);
if (this._parsing) {
this.length_size_of_traf_num = (this.reserved & 0x00000030) >> 4;
this.length_size_of_trun_num = (this.reserved & 0x0000000C) >> 2;
this.length_size_of_sample_num = (this.reserved & 0x00000003);
}
this._procField('number_of_entry', 'uint', 32);
this._procEntries('entries', this.number_of_entry, function(entry) {
this._procEntryField(entry, 'time', 'uint', (this.version === 1) ? 64 : 32);
this._procEntryField(entry, 'moof_offset', 'uint', (this.version === 1) ? 64 : 32);
this._procEntryField(entry, 'traf_number', 'uint', (this.length_size_of_traf_num + 1) * 8);
this._procEntryField(entry, 'trun_number', 'uint', (this.length_size_of_trun_num + 1) * 8);
this._procEntryField(entry, 'sample_number', 'uint', (this.length_size_of_sample_num + 1) * 8);
});
};

// ISO/IEC 14496-12:2012 - 8.3.2 Track Header Box
ISOBox.prototype._boxProcessors['tkhd'] = function() {
this._procFullBox();
this._procField('creation_time', 'uint', (this.version == 1) ? 64 : 32);
this._procField('modification_time', 'uint', (this.version == 1) ? 64 : 32);
this._procField('track_ID', 'uint', 32);
this._procField('reserved1', 'uint', 32);
this._procField('duration', 'uint', (this.version == 1) ? 64 : 32);
this._procFieldArray('reserved2', 2, 'uint', 32);
this._procField('layer', 'uint', 16);
this._procField('alternate_group', 'uint', 16);
this._procField('volume', 'template', 16);
this._procField('reserved3', 'uint', 16);
this._procFieldArray('matrix', 9, 'template', 32);
this._procField('width', 'template', 32);
this._procField('height', 'template', 32);
};

// ISO/IEC 14496-12:2012 - 8.8.3 Track Extends Box
ISOBox.prototype._boxProcessors['trex'] = function() {
this._procFullBox();
this._procField('track_ID', 'uint', 32);
this._procField('default_sample_description_index', 'uint', 32);
this._procField('default_sample_duration', 'uint', 32);
this._procField('default_sample_size', 'uint', 32);
this._procField('default_sample_flags', 'uint', 32);
};

// ISO/IEC 14496-12:2012 - 8.8.8 Track Run Box
// Note: the 'trun' box has a direct relation to the 'tfhd' box for defaults.
// These defaults are not set explicitly here, but are left to resolve for the user.
ISOBox.prototype._boxProcessors['trun'] = function() {
this._procFullBox();
this._procField('sample_count', 'uint', 32);
if (this.flags & 0x1) this._procField('data_offset', 'int', 32);
if (this.flags & 0x4) this._procField('first_sample_flags', 'uint', 32);
this._procEntries('samples', this.sample_count, function(sample) {
if (this.flags & 0x100) this._procEntryField(sample, 'sample_duration', 'uint', 32);
if (this.flags & 0x200) this._procEntryField(sample, 'sample_size', 'uint', 32);
if (this.flags & 0x400) this._procEntryField(sample, 'sample_flags', 'uint', 32);
if (this.flags & 0x800) this._procEntryField(sample, 'sample_composition_time_offset', (this.version === 1) ? 'int' : 'uint', 32);
});
};

// ISO/IEC 14496-12:2012 - 8.7.2 Data Reference Box
ISOBox.prototype._boxProcessors['url '] = ISOBox.prototype._boxProcessors['urn '] = function() {
this._procFullBox();
if (this.type === 'urn ') {
this._procField('name', 'string', -1);
}
this._procField('location', 'string', -1);
};

// ISO/IEC 14496-30:2014 - WebVTT Source Label Box
ISOBox.prototype._boxProcessors['vlab'] = function() {
this._procField('source_label', 'utf8');
};

// ISO/IEC 14496-12:2012 - 8.4.5.2 Video Media Header Box
ISOBox.prototype._boxProcessors['vmhd'] = function() {
this._procFullBox();
this._procField('graphicsmode', 'uint', 16);
this._procFieldArray('opcolor', 3, 'uint', 16);
};

// ISO/IEC 14496-30:2014 - WebVTT Configuration Box
ISOBox.prototype._boxProcessors['vttC'] = function() {
this._procField('config', 'utf8');
};

// ISO/IEC 14496-30:2014 - WebVTT Empty Sample Box
ISOBox.prototype._boxProcessors['vtte'] = function() {
// Nothing should happen here.
};


/***/ }),
/* 51 */
/***/ (function(module, exports) {

function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}

module.exports = _arrayWithHoles;

/***/ }),
/* 52 */
/***/ (function(module, exports) {

function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;

try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);

if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}

return _arr;
}

module.exports = _iterableToArrayLimit;

/***/ }),
/* 53 */
/***/ (function(module, exports) {

function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

module.exports = _nonIterableRest;

/***/ }),
/* 54 */
/***/ (function(module, exports, __webpack_require__) {

/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

var runtime = (function (exports) {
"use strict";

var Op = Object.prototype;
var hasOwn = Op.hasOwnProperty;
var undefined; // More compressible than void 0.
var $Symbol = typeof Symbol === "function" ? Symbol : {};
var iteratorSymbol = $Symbol.iterator || "@@iterator";
var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";

function wrap(innerFn, outerFn, self, tryLocsList) {
// If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
var generator = Object.create(protoGenerator.prototype);
var context = new Context(tryLocsList || []);

// The ._invoke method unifies the implementations of the .next,
// .throw, and .return methods.
generator._invoke = makeInvokeMethod(innerFn, self, context);

return generator;
}
exports.wrap = wrap;

// Try/catch helper to minimize deoptimizations. Returns a completion
// record like context.tryEntries[i].completion. This interface could
// have been (and was previously) designed to take a closure to be
// invoked without arguments, but in all the cases we care about we
// already have an existing method we want to call, so there's no need
// to create a new function object. We can even get away with assuming
// the method takes exactly one argument, since that happens to be true
// in every case, so we don't have to touch the arguments object. The
// only additional allocation required is the completion record, which
// has a stable shape and so hopefully should be cheap to allocate.
function tryCatch(fn, obj, arg) {
try {
return { type: "normal", arg: fn.call(obj, arg) };
} catch (err) {
return { type: "throw", arg: err };
}
}

var GenStateSuspendedStart = "suspendedStart";
var GenStateSuspendedYield = "suspendedYield";
var GenStateExecuting = "executing";
var GenStateCompleted = "completed";

// Returning this object from the innerFn has the same effect as
// breaking out of the dispatch switch statement.
var ContinueSentinel = {};

// Dummy constructor functions that we use as the .constructor and
// .constructor.prototype properties for functions that return Generator
// objects. For full spec compliance, you may wish to configure your
// minifier not to mangle the names of these two functions.
function Generator() {}
function GeneratorFunction() {}
function GeneratorFunctionPrototype() {}

// This is a polyfill for %IteratorPrototype% for environments that
// don't natively support it.
var IteratorPrototype = {};
IteratorPrototype[iteratorSymbol] = function () {
return this;
};

var getProto = Object.getPrototypeOf;
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
if (NativeIteratorPrototype &&
NativeIteratorPrototype !== Op &&
hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
// This environment has a native %IteratorPrototype%; use it instead
// of the polyfill.
IteratorPrototype = NativeIteratorPrototype;
}

var Gp = GeneratorFunctionPrototype.prototype =
Generator.prototype = Object.create(IteratorPrototype);
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
GeneratorFunctionPrototype.constructor = GeneratorFunction;
GeneratorFunctionPrototype[toStringTagSymbol] =
GeneratorFunction.displayName = "GeneratorFunction";

// Helper for defining the .next, .throw, and .return methods of the
// Iterator interface in terms of a single ._invoke method.
function defineIteratorMethods(prototype) {
["next", "throw", "return"].forEach(function(method) {
prototype[method] = function(arg) {
return this._invoke(method, arg);
};
});
}

exports.isGeneratorFunction = function(genFun) {
var ctor = typeof genFun === "function" && genFun.constructor;
return ctor
? ctor === GeneratorFunction ||
// For the native GeneratorFunction constructor, the best we can
// do is to check its .name property.
(ctor.displayName || ctor.name) === "GeneratorFunction"
: false;
};

exports.mark = function(genFun) {
if (Object.setPrototypeOf) {
Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
} else {
genFun.__proto__ = GeneratorFunctionPrototype;
if (!(toStringTagSymbol in genFun)) {
genFun[toStringTagSymbol] = "GeneratorFunction";
}
}
genFun.prototype = Object.create(Gp);
return genFun;
};

// Within the body of any async function, `await x` is transformed to
// `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
// `hasOwn.call(value, "__await")` to determine if the yielded value is
// meant to be awaited.
exports.awrap = function(arg) {
return { __await: arg };
};

function AsyncIterator(generator, PromiseImpl) {
function invoke(method, arg, resolve, reject) {
var record = tryCatch(generator[method], generator, arg);
if (record.type === "throw") {
reject(record.arg);
} else {
var result = record.arg;
var value = result.value;
if (value &&
typeof value === "object" &&
hasOwn.call(value, "__await")) {
return PromiseImpl.resolve(value.__await).then(function(value) {
invoke("next", value, resolve, reject);
}, function(err) {
invoke("throw", err, resolve, reject);
});
}

return PromiseImpl.resolve(value).then(function(unwrapped) {
// When a yielded Promise is resolved, its final value becomes
// the .value of the Promise<{value,done}> result for the
// current iteration.
result.value = unwrapped;
resolve(result);
}, function(error) {
// If a rejected Promise was yielded, throw the rejection back
// into the async generator function so it can be handled there.
return invoke("throw", error, resolve, reject);
});
}
}

var previousPromise;

function enqueue(method, arg) {
function callInvokeWithMethodAndArg() {
return new PromiseImpl(function(resolve, reject) {
invoke(method, arg, resolve, reject);
});
}

return previousPromise =
// If enqueue has been called before, then we want to wait until
// all previous Promises have been resolved before calling invoke,
// so that results are always delivered in the correct order. If
// enqueue has not been called before, then it is important to
// call invoke immediately, without waiting on a callback to fire,
// so that the async generator function has the opportunity to do
// any necessary setup in a predictable way. This predictability
// is why the Promise constructor synchronously invokes its
// executor callback, and why async functions synchronously
// execute code before the first await. Since we implement simple
// async functions in terms of async generators, it is especially
// important to get this right, even though it requires care.
previousPromise ? previousPromise.then(
callInvokeWithMethodAndArg,
// Avoid propagating failures to Promises returned by later
// invocations of the iterator.
callInvokeWithMethodAndArg
) : callInvokeWithMethodAndArg();
}

// Define the unified helper method that is used to implement .next,
// .throw, and .return (see defineIteratorMethods).
this._invoke = enqueue;
}

defineIteratorMethods(AsyncIterator.prototype);
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
return this;
};
exports.AsyncIterator = AsyncIterator;

// Note that simple async functions are implemented on top of
// AsyncIterator objects; they just return a Promise for the value of
// the final result produced by the iterator.
exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {
if (PromiseImpl === void 0) PromiseImpl = Promise;

var iter = new AsyncIterator(
wrap(innerFn, outerFn, self, tryLocsList),
PromiseImpl
);

return exports.isGeneratorFunction(outerFn)
? iter // If outerFn is a generator, return the full iterator.
: iter.next().then(function(result) {
return result.done ? result.value : iter.next();
});
};

function makeInvokeMethod(innerFn, self, context) {
var state = GenStateSuspendedStart;

return function invoke(method, arg) {
if (state === GenStateExecuting) {
throw new Error("Generator is already running");
}

if (state === GenStateCompleted) {
if (method === "throw") {
throw arg;
}

// Be forgiving, per 25.3.3.3.3 of the spec:
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
return doneResult();
}

context.method = method;
context.arg = arg;

while (true) {
var delegate = context.delegate;
if (delegate) {
var delegateResult = maybeInvokeDelegate(delegate, context);
if (delegateResult) {
if (delegateResult === ContinueSentinel) continue;
return delegateResult;
}
}

if (context.method === "next") {
// Setting context._sent for legacy support of Babel's
// function.sent implementation.
context.sent = context._sent = context.arg;

} else if (context.method === "throw") {
if (state === GenStateSuspendedStart) {
state = GenStateCompleted;
throw context.arg;
}

context.dispatchException(context.arg);

} else if (context.method === "return") {
context.abrupt("return", context.arg);
}

state = GenStateExecuting;

var record = tryCatch(innerFn, self, context);
if (record.type === "normal") {
// If an exception is thrown from innerFn, we leave state ===
// GenStateExecuting and loop back for another invocation.
state = context.done
? GenStateCompleted
: GenStateSuspendedYield;

if (record.arg === ContinueSentinel) {
continue;
}

return {
value: record.arg,
done: context.done
};

} else if (record.type === "throw") {
state = GenStateCompleted;
// Dispatch the exception by looping back around to the
// context.dispatchException(context.arg) call above.
context.method = "throw";
context.arg = record.arg;
}
}
};
}

// Call delegate.iterator[context.method](context.arg) and handle the
// result, either by returning a { value, done } result from the
// delegate iterator, or by modifying context.method and context.arg,
// setting context.delegate to null, and returning the ContinueSentinel.
function maybeInvokeDelegate(delegate, context) {
var method = delegate.iterator[context.method];
if (method === undefined) {
// A .throw or .return when the delegate iterator has no .throw
// method always terminates the yield* loop.
context.delegate = null;

if (context.method === "throw") {
// Note: ["return"] must be used for ES3 parsing compatibility.
if (delegate.iterator["return"]) {
// If the delegate iterator has a return method, give it a
// chance to clean up.
context.method = "return";
context.arg = undefined;
maybeInvokeDelegate(delegate, context);

if (context.method === "throw") {
// If maybeInvokeDelegate(context) changed context.method from
// "return" to "throw", let that override the TypeError below.
return ContinueSentinel;
}
}

context.method = "throw";
context.arg = new TypeError(
"The iterator does not provide a 'throw' method");
}

return ContinueSentinel;
}

var record = tryCatch(method, delegate.iterator, context.arg);

if (record.type === "throw") {
context.method = "throw";
context.arg = record.arg;
context.delegate = null;
return ContinueSentinel;
}

var info = record.arg;

if (! info) {
context.method = "throw";
context.arg = new TypeError("iterator result is not an object");
context.delegate = null;
return ContinueSentinel;
}

if (info.done) {
// Assign the result of the finished delegate to the temporary
// variable specified by delegate.resultName (see delegateYield).
context[delegate.resultName] = info.value;

// Resume execution at the desired location (see delegateYield).
context.next = delegate.nextLoc;

// If context.method was "throw" but the delegate handled the
// exception, let the outer generator proceed normally. If
// context.method was "next", forget context.arg since it has been
// "consumed" by the delegate iterator. If context.method was
// "return", allow the original .return call to continue in the
// outer generator.
if (context.method !== "return") {
context.method = "next";
context.arg = undefined;
}

} else {
// Re-yield the result returned by the delegate method.
return info;
}

// The delegate iterator is finished, so forget it and continue with
// the outer generator.
context.delegate = null;
return ContinueSentinel;
}

// Define Generator.prototype.{next,throw,return} in terms of the
// unified ._invoke helper method.
defineIteratorMethods(Gp);

Gp[toStringTagSymbol] = "Generator";

// A Generator should always return itself as the iterator object when the
// @@iterator function is called on it. Some browsers' implementations of the
// iterator prototype chain incorrectly implement this, causing the Generator
// object to not be returned from this call. This ensures that doesn't happen.
// See https://github.com/facebook/regenerator/issues/274 for more details.
Gp[iteratorSymbol] = function() {
return this;
};

Gp.toString = function() {
return "[object Generator]";
};

function pushTryEntry(locs) {
var entry = { tryLoc: locs[0] };

if (1 in locs) {
entry.catchLoc = locs[1];
}

if (2 in locs) {
entry.finallyLoc = locs[2];
entry.afterLoc = locs[3];
}

this.tryEntries.push(entry);
}

function resetTryEntry(entry) {
var record = entry.completion || {};
record.type = "normal";
delete record.arg;
entry.completion = record;
}

function Context(tryLocsList) {
// The root entry object (effectively a try statement without a catch
// or a finally block) gives us a place to store values thrown from
// locations where there is no enclosing try statement.
this.tryEntries = [{ tryLoc: "root" }];
tryLocsList.forEach(pushTryEntry, this);
this.reset(true);
}

exports.keys = function(object) {
var keys = [];
for (var key in object) {
keys.push(key);
}
keys.reverse();

// Rather than returning an object with a next method, we keep
// things simple and return the next function itself.
return function next() {
while (keys.length) {
var key = keys.pop();
if (key in object) {
next.value = key;
next.done = false;
return next;
}
}

// To avoid creating an additional object, we just hang the .value
// and .done properties off the next function object itself. This
// also ensures that the minifier will not anonymize the function.
next.done = true;
return next;
};
};

function values(iterable) {
if (iterable) {
var iteratorMethod = iterable[iteratorSymbol];
if (iteratorMethod) {
return iteratorMethod.call(iterable);
}

if (typeof iterable.next === "function") {
return iterable;
}

if (!isNaN(iterable.length)) {
var i = -1, next = function next() {
while (++i < iterable.length) {
if (hasOwn.call(iterable, i)) {
next.value = iterable[i];
next.done = false;
return next;
}
}

next.value = undefined;
next.done = true;

return next;
};

return next.next = next;
}
}

// Return an iterator with no values.
return { next: doneResult };
}
exports.values = values;

function doneResult() {
return { value: undefined, done: true };
}

Context.prototype = {
constructor: Context,

reset: function(skipTempReset) {
this.prev = 0;
this.next = 0;
// Resetting context._sent for legacy support of Babel's
// function.sent implementation.
this.sent = this._sent = undefined;
this.done = false;
this.delegate = null;

this.method = "next";
this.arg = undefined;

this.tryEntries.forEach(resetTryEntry);

if (!skipTempReset) {
for (var name in this) {
// Not sure about the optimal order of these conditions:
if (name.charAt(0) === "t" &&
hasOwn.call(this, name) &&
!isNaN(+name.slice(1))) {
this[name] = undefined;
}
}
}
},

stop: function() {
this.done = true;

var rootEntry = this.tryEntries[0];
var rootRecord = rootEntry.completion;
if (rootRecord.type === "throw") {
throw rootRecord.arg;
}

return this.rval;
},

dispatchException: function(exception) {
if (this.done) {
throw exception;
}

var context = this;
function handle(loc, caught) {
record.type = "throw";
record.arg = exception;
context.next = loc;

if (caught) {
// If the dispatched exception was caught by a catch block,
// then let that catch block handle the exception normally.
context.method = "next";
context.arg = undefined;
}

return !! caught;
}

for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
var record = entry.completion;

if (entry.tryLoc === "root") {
// Exception thrown outside of any try block that could handle
// it, so set the completion value of the entire function to
// throw the exception.
return handle("end");
}

if (entry.tryLoc <= this.prev) {
var hasCatch = hasOwn.call(entry, "catchLoc");
var hasFinally = hasOwn.call(entry, "finallyLoc");

if (hasCatch && hasFinally) {
if (this.prev < entry.catchLoc) {
return handle(entry.catchLoc, true);
} else if (this.prev < entry.finallyLoc) {
return handle(entry.finallyLoc);
}

} else if (hasCatch) {
if (this.prev < entry.catchLoc) {
return handle(entry.catchLoc, true);
}

} else if (hasFinally) {
if (this.prev < entry.finallyLoc) {
return handle(entry.finallyLoc);
}

} else {
throw new Error("try statement without catch or finally");
}
}
}
},

abrupt: function(type, arg) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc <= this.prev &&
hasOwn.call(entry, "finallyLoc") &&
this.prev < entry.finallyLoc) {
var finallyEntry = entry;
break;
}
}

if (finallyEntry &&
(type === "break" ||
type === "continue") &&
finallyEntry.tryLoc <= arg &&
arg <= finallyEntry.finallyLoc) {
// Ignore the finally entry if control is not jumping to a
// location outside the try/catch block.
finallyEntry = null;
}

var record = finallyEntry ? finallyEntry.completion : {};
record.type = type;
record.arg = arg;

if (finallyEntry) {
this.method = "next";
this.next = finallyEntry.finallyLoc;
return ContinueSentinel;
}

return this.complete(record);
},

complete: function(record, afterLoc) {
if (record.type === "throw") {
throw record.arg;
}

if (record.type === "break" ||
record.type === "continue") {
this.next = record.arg;
} else if (record.type === "return") {
this.rval = this.arg = record.arg;
this.method = "return";
this.next = "end";
} else if (record.type === "normal" && afterLoc) {
this.next = afterLoc;
}

return ContinueSentinel;
},

finish: function(finallyLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.finallyLoc === finallyLoc) {
this.complete(entry.completion, entry.afterLoc);
resetTryEntry(entry);
return ContinueSentinel;
}
}
},

"catch": function(tryLoc) {
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
var entry = this.tryEntries[i];
if (entry.tryLoc === tryLoc) {
var record = entry.completion;
if (record.type === "throw") {
var thrown = record.arg;
resetTryEntry(entry);
}
return thrown;
}
}

// The context.catch method must only be called with a location
// argument that corresponds to a known catch block.
throw new Error("illegal catch attempt");
},

delegateYield: function(iterable, resultName, nextLoc) {
this.delegate = {
iterator: values(iterable),
resultName: resultName,
nextLoc: nextLoc
};

if (this.method === "next") {
// Deliberately forget the last sent value so that we don't
// accidentally pass it on to the delegate.
this.arg = undefined;
}

return ContinueSentinel;
}
};

// Regardless of whether this script is executing as a CommonJS module
// or not, return the runtime object so that we can declare the variable
// regeneratorRuntime in the outer scope, which allows this module to be
// injected easily by `bin/regenerator --include-runtime script.js`.
return exports;

}(
// If this script is executing as a CommonJS module, use module.exports
// as the regeneratorRuntime namespace. Otherwise create a new empty
// object. Either way, the resulting object will be used to initialize
// the regeneratorRuntime variable at the top of this file.
true ? module.exports : undefined
));

try {
regeneratorRuntime = runtime;
} catch (accidentalStrictMode) {
// This module should not be running in strict mode, so the above
// assignment should always work unless something is misconfigured. Just
// in case runtime.js accidentally runs in strict mode, we can escape
// strict mode using a global Function call. This could conceivably fail
// if a Content Security Policy forbids using Function, but in that case
// the proper solution is to fix the accidental strict mode problem. If
// you've misconfigured your bundler to force strict mode and applied a
// CSP to forbid Function, and you're not willing to fix either of those
// problems, please detail your unique predicament in a GitHub issue.
Function("r", "regeneratorRuntime = r")(runtime);
}


/***/ }),
/* 55 */
/***/ (function(module, exports, __webpack_require__) {

var arrayLikeToArray = __webpack_require__(46);

function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return arrayLikeToArray(arr);
}

module.exports = _arrayWithoutHoles;

/***/ }),
/* 56 */
/***/ (function(module, exports) {

function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
}

module.exports = _iterableToArray;

/***/ }),
/* 57 */
/***/ (function(module, exports) {

function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}

module.exports = _nonIterableSpread;

/***/ }),
/* 58 */
/***/ (function(module, exports, __webpack_require__) {

var getPrototypeOf = __webpack_require__(4);

function _superPropBase(object, property) {
while (!Object.prototype.hasOwnProperty.call(object, property)) {
object = getPrototypeOf(object);
if (object === null) break;
}

return object;
}

module.exports = _superPropBase;

/***/ }),
/* 59 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(16);
/* harmony import */ var _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(26);
/* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_1__);
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(15);
/* harmony import */ var _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__);
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(20);
/* harmony import */ var _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_3__);
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3);
/* harmony import */ var _babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_4__);
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5);
/* harmony import */ var _babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_5__);
/* harmony import */ var _babel_runtime_helpers_get__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(34);
/* harmony import */ var _babel_runtime_helpers_get__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_get__WEBPACK_IMPORTED_MODULE_6__);
/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(12);
/* harmony import */ var _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_7__);
/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(4);
/* harmony import */ var _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_8__);
/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(13);
/* harmony import */ var _babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_9__);
/* harmony import */ var _core_event_player_event__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(0);
/* harmony import */ var _core_enum_option_name__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(1);
/* harmony import */ var _core_model_audio_track__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(38);
/* harmony import */ var _core_protection_protection_manager__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(42);
/* harmony import */ var _core_util_http__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(22);
/* harmony import */ var _core_util_utc_time__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(36);
/* harmony import */ var _core_model_base_renderer__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(41);











function _createSuper(Derived) { return function () { var Super = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_8___default()(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_8___default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _babel_runtime_helpers_possibleConstructorReturn__WEBPACK_IMPORTED_MODULE_7___default()(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }









var Html5Player = /*#__PURE__*/function (_BaseRenderer) {
_babel_runtime_helpers_inherits__WEBPACK_IMPORTED_MODULE_9___default()(Html5Player, _BaseRenderer);

var _super = _createSuper(Html5Player);

function Html5Player(player, video) {
var _this;

_babel_runtime_helpers_classCallCheck__WEBPACK_IMPORTED_MODULE_4___default()(this, Html5Player);

_this = _super.call(this, player, video);
_this.rendererType = Html5Player.id;
_this.utcTime = new _core_util_utc_time__WEBPACK_IMPORTED_MODULE_15__[/* default */ "a"](_this.player);
_this.utcTimeStamp = 0;
_this.timeShiftStart = 0;
return _this;
}

_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_5___default()(Html5Player, [{
key: "setSource",
value: function () {
var _setSource = _babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_3___default()( /*#__PURE__*/_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.mark(function _callee(url) {
var protectionManager;
return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
this.registerEvents();

if (!this.timeShift.isEnabled()) {
_context.next = 5;
break;
}

_context.next = 4;
return this.utcTime.init();

case 4:
this.utcTimeStamp = _context.sent;

case 5:
if (this.baseUrl === null) {
this.baseUrl = url;
}

this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* ON_SOURCE */ "E"], url);

if (this.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_11__[/* DRM */ "z"])) {
protectionManager = new _core_protection_protection_manager__WEBPACK_IMPORTED_MODULE_13__[/* default */ "a"](this.player);
}

if (this.timeShift.isEnabled()) {
url = this.timeShift.generateUrl(url, true);
}

_context.next = 11;
return _core_util_http__WEBPACK_IMPORTED_MODULE_14__[/* default */ "a"].head(url).then(function (_ref) {
var responseUrl = _ref.responseUrl;
return responseUrl;
})["catch"](function () {
return url;
});

case 11:
url = _context.sent;

if (!this.timeShift.params && this.isLive()) {
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* ON_LIVE */ "D"]);
}

this.playSource(url);

case 14:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));

function setSource(_x) {
return _setSource.apply(this, arguments);
}

return setSource;
}()
}, {
key: "seek",
value: function seek(percentPosition) {
var position = this.getDuration() / 100 * percentPosition;
this.seekTo(position);
}
}, {
key: "seekTo",
value: function seekTo(position) {
this.triggerOnSeekStartEvents();

if (this.timeShift.getDvrWindow() > 0) {
position += this.timeShift.getLiveNowUTC() - this.utcTimeStamp;
}

this.mediaElement.seek(position);
}
}, {
key: "getCurrentTime",
value: function getCurrentTime() {
var currentTime = this.mediaElement.getCurrentTime();

if (this.timeShift.getDvrWindow() > 0) {
currentTime -= this.timeShift.getLiveNowUTC() - this.utcTimeStamp;
}

return currentTime;
}
}, {
key: "getDuration",
value: function getDuration() {
if (this.timeShift.getStart() >= 0 && this.timeShift.getStop() < 0) {
return this.timeShift.getLiveNowUTC() - this.timeShift.getStart();
}

if (this.timeShift.getStart() >= 0 && this.timeShift.getStop() >= 0) {
return this.timeShift.getStop() - this.timeShift.getStart();
}

return this.mediaElement.getDuration();
}
}, {
key: "isLive",
value: function isLive() {
return _babel_runtime_helpers_get__WEBPACK_IMPORTED_MODULE_6___default()(_babel_runtime_helpers_getPrototypeOf__WEBPACK_IMPORTED_MODULE_8___default()(Html5Player.prototype), "isLive", this).call(this) || this.getDuration() === Infinity;
}
}, {
key: "onLoadedmetadata",
value: function onLoadedmetadata() {
var _this2 = this;

this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* NEW_MEDIA */ "C"], this.isLive() ? -1 : this.getDuration());
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* METADATA */ "y"], {
duration: this.getDuration()
});

if (this.isLive()) {
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* ON_LIVE */ "D"]);
}

var startPosition;

if (this.timeShift.isEnabled() && this.timeShift.getDvrWindow() >= 0 && this.timeShift.getPlayStart() >= 0) {
startPosition = this.timeShift.getPlayStart() - this.timeShift.getStart();
}

if (this.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_11__[/* START_TIME */ "Ab"])) {
startPosition = this.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_11__[/* START_TIME */ "Ab"]);
this.options.set(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_11__[/* START_TIME */ "Ab"], null);
}

if (startPosition) {
this.mediaElement.once(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* PLAYING */ "O"], function () {
_this2.seekTo(startPosition);
});
}
}
}, {
key: "getProfile",
value: function getProfile() {
return '';
}
}, {
key: "onLoadeddata",
value: function onLoadeddata() {
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* DATA */ "k"]);
var audioTracks = this.getAudioTracks();

if (audioTracks.length) {
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* AUDIO_TRACK_LIST */ "f"], audioTracks);
var activeTrack = this.getActiveAudioTrack();
this.defaultAudioLanguage = this.options.get(_core_enum_option_name__WEBPACK_IMPORTED_MODULE_11__[/* DEFAULT_AUDIO_LANGUAGE */ "u"]);

if (this.defaultAudioLanguage) {
var track = this.getAudioTrackByLabel(this.defaultAudioLanguage);

if (track && activeTrack !== track) {
this.switchAudioTrack(track);
} else {
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* AUDIO_TRACK_CHANGED */ "e"], activeTrack);
}
} else {
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* AUDIO_TRACK_CHANGED */ "e"], activeTrack);
}
}
}
}, {
key: "switchAudioTrack",
value: function switchAudioTrack(audioTrack) {
var trackId = _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_1___default()(audioTrack) === 'object' ? audioTrack.id : audioTrack;
var nativeAudioTracks = this.mediaElement.getNativeAudioTracks();
var nativeAudioTrack = nativeAudioTracks.find(function (_ref2) {
var id = _ref2.id,
language = _ref2.language;
return id === trackId || language === trackId;
});

if (nativeAudioTrack) {
nativeAudioTracks.forEach(function (audioTrack) {
audioTrack.enabled = audioTrack === nativeAudioTrack;
});
this.player.trigger(_core_event_player_event__WEBPACK_IMPORTED_MODULE_10__[/* AUDIO_TRACK_CHANGED */ "e"], this.createAudioTrackDTO(nativeAudioTrack));
}
}
}, {
key: "getAudioTrackByLabel",
value: function getAudioTrackByLabel(_label) {
return this.getAudioTracks().find(function (_ref3) {
var label = _ref3.label;
return label === _label;
});
}
}, {
key: "getActiveAudioTrack",
value: function getActiveAudioTrack() {
return this.getAudioTracks().find(function (_ref4) {
var enabled = _ref4.enabled;
return enabled;
});
}
}, {
key: "getCurrentAudioTrack",
value: function getCurrentAudioTrack() {
return this.getActiveAudioTrack();
}
}, {
key: "getAudioTracks",
value: function getAudioTracks() {
var _this3 = this;

return this.mediaElement.getNativeAudioTracks().map(function (track) {
return _this3.createAudioTrackDTO(track);
});
}
}, {
key: "getTextTracks",
value: function getTextTracks() {
return _babel_runtime_helpers_toConsumableArray__WEBPACK_IMPORTED_MODULE_0___default()(this.mediaElement.getNativeTextTracks()).filter(function (_ref5) {
var id = _ref5.id,
language = _ref5.language,
label = _ref5.label;
return id || language || label;
});
}
}, {
key: "createAudioTrackDTO",
value: function createAudioTrackDTO(track) {
return new _core_model_audio_track__WEBPACK_IMPORTED_MODULE_12__[/* default */ "a"](track);
}
}], [{
key: "canPlayType",
value: function canPlayType(mimeType) {
return document.createElement('video').canPlayType(mimeType);
}
}]);

return Html5Player;
}(_core_model_base_renderer__WEBPACK_IMPORTED_MODULE_16__[/* default */ "a"]);

Html5Player.id = 'html5';
Html5Player.priority = 200;
Html5Player.mediaTypes = {
MP4: 'video/mp4',
HLS: 'application/x-mpegURL',
AAC: 'audio/mp4',
MP3: 'audio/mpeg',
MOV: 'video/mp4; codecs=\'avc1.42E01E, mp4a.40.2\'',
WEBM: 'video/webm',
OGG: 'video/ogg'
};
/* harmony default export */ __webpack_exports__["a"] = (Html5Player);

/***/ }),
/* 60 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";

// EXTERNAL MODULE: ./node_modules/@babel/runtime/regenerator/index.js
var regenerator = __webpack_require__(15);
var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/asyncToGenerator.js
var asyncToGenerator = __webpack_require__(20);
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/classCallCheck.js
var classCallCheck = __webpack_require__(3);
var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/createClass.js
var createClass = __webpack_require__(5);
var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/assertThisInitialized.js
var assertThisInitialized = __webpack_require__(24);
var assertThisInitialized_default = /*#__PURE__*/__webpack_require__.n(assertThisInitialized);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/get.js
var helpers_get = __webpack_require__(34);
var get_default = /*#__PURE__*/__webpack_require__.n(helpers_get);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js
var possibleConstructorReturn = __webpack_require__(12);
var possibleConstructorReturn_default = /*#__PURE__*/__webpack_require__.n(possibleConstructorReturn);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/getPrototypeOf.js
var getPrototypeOf = __webpack_require__(4);
var getPrototypeOf_default = /*#__PURE__*/__webpack_require__.n(getPrototypeOf);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/inherits.js
var inherits = __webpack_require__(13);
var inherits_default = /*#__PURE__*/__webpack_require__.n(inherits);

// CONCATENATED MODULE: ./src/core/enum/local-storage-key.js
var BITRATE = 'redgalaxy-player-bitrate';
// EXTERNAL MODULE: ./src/core/enum/option-name.js
var option_name = __webpack_require__(1);

// EXTERNAL MODULE: ./src/core/enum/player-component.js
var player_component = __webpack_require__(7);

// EXTERNAL MODULE: ./src/core/event/player-event.js
var player_event = __webpack_require__(0);

// EXTERNAL MODULE: ./src/core/enum/player-error.js
var player_error = __webpack_require__(10);

// EXTERNAL MODULE: ./src/core/enum/error-code.js
var error_code = __webpack_require__(27);

// EXTERNAL MODULE: ./src/core/protection/protection-manager.js + 5 modules
var protection_manager = __webpack_require__(42);

// EXTERNAL MODULE: ./src/core/util/browser.js
var browser = __webpack_require__(21);

// EXTERNAL MODULE: ./src/core/model/base-renderer.js
var base_renderer = __webpack_require__(41);

// EXTERNAL MODULE: ./src/renderer/dash/enum/media-type.js
var media_type = __webpack_require__(9);

// EXTERNAL MODULE: ./src/renderer/dash/event/dash-event.js
var dash_event = __webpack_require__(14);

// CONCATENATED MODULE: ./src/renderer/dash/event/media-source-event.js
var SOURCE_CLOSE = 'sourceclose';
var SOURCE_ENDED = 'sourceended';
var SOURCE_OPEN = 'sourceopen';
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/slicedToArray.js
var slicedToArray = __webpack_require__(8);
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);

// EXTERNAL MODULE: ./src/core/util/event-emitter.js
var event_emitter = __webpack_require__(17);

// EXTERNAL MODULE: ./src/core/util/timer.js
var util_timer = __webpack_require__(25);

// EXTERNAL MODULE: ./src/core/util/logger.js
var logger = __webpack_require__(33);

// EXTERNAL MODULE: ./src/core/util/http/http-status.js
var http_status = __webpack_require__(23);

// EXTERNAL MODULE: ./src/core/util/http/index.js + 1 modules
var http = __webpack_require__(22);

// EXTERNAL MODULE: ./src/core/util/url.js
var util_url = __webpack_require__(31);

// EXTERNAL MODULE: ./src/core/util/utc-time.js
var utc_time = __webpack_require__(36);

// EXTERNAL MODULE: ./src/core/model/audio-track.js
var audio_track = __webpack_require__(38);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/toConsumableArray.js
var toConsumableArray = __webpack_require__(16);
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);

// EXTERNAL MODULE: ./src/renderer/dash/manifest/helper.js
var helper = __webpack_require__(11);

// CONCATENATED MODULE: ./src/renderer/dash/model/period.js







function _createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }




var period_Period = /*#__PURE__*/function (_EventEmitter) {
inherits_default()(Period, _EventEmitter);

var _super = _createSuper(Period);

function Period() {
var _this;

classCallCheck_default()(this, Period);

_this = _super.call(this);
_this.id = null;
_this.segmentList = null;
_this.adaptationSets = [];
_this.timeline = null;
_this.baseUrl = null;
_this.start = null;
_this.end = null;
_this.duration = null;
_this.segmentTemplate = null;
_this.eventStreams = [];
return _this;
}

createClass_default()(Period, [{
key: "createEvents",
value: function createEvents(eventStreams) {
var _this2 = this;

this.eventStreams = eventStreams.map(function (eventStream) {
var events = Object(helper["d" /* getChildren */])(eventStream, 'Event');
var timescale = eventStream.getAttribute('timescale') || 1;
var schemeIdUri = eventStream.getAttribute('schemeIdUri');
return toConsumableArray_default()(events).map(function (event) {
var streamEvent = new period_EventStream();
var presentationTime = parseInt(event.getAttribute('presentationTime')) / timescale;
streamEvent.id = event.getAttribute('id');
streamEvent.presentationTime = presentationTime;
streamEvent.start = _this2.start + presentationTime;
streamEvent.messageData = event.getAttribute('messageData') || event.textContent;
streamEvent.eventData = event.textContent;
return streamEvent;
});
});
}
}]);

return Period;
}(event_emitter["a" /* default */]);

var period_EventStream = function EventStream() {
classCallCheck_default()(this, EventStream);

this.id = undefined;
this.start = undefined;
this.messageData = undefined;
this.eventData = undefined;
this.fired = false;
};

/* harmony default export */ var model_period = (period_Period);
// CONCATENATED MODULE: ./src/renderer/dash/model/segment-timeline.js



var segment_timeline_SegmentTimeline = /*#__PURE__*/function () {
function SegmentTimeline() {
classCallCheck_default()(this, SegmentTimeline);

this.timePoints = [];
}

createClass_default()(SegmentTimeline, [{
key: "parse",
value: function parse(data) {
this.timePoints = data.map(function (node, index) {
var segmentTimePoint = new SegmentTimePoint();
segmentTimePoint.index = index;
segmentTimePoint.duration = parseInt(node.getAttribute('d'));
segmentTimePoint.startTime = parseInt(node.getAttribute('t'));
segmentTimePoint.repeat = parseInt(node.getAttribute('r'));
return segmentTimePoint;
});
}
}]);

return SegmentTimeline;
}();

function SegmentTimePoint() {
this.index = null;
this.startTime = null;
this.duration = null;
this.repeat = null;
}

/* harmony default export */ var segment_timeline = (segment_timeline_SegmentTimeline);
// CONCATENATED MODULE: ./src/renderer/dash/model/segment-template.js


var segment_template_SegmentTemplate = function SegmentTemplate() {
classCallCheck_default()(this, SegmentTemplate);

this.timescale = 1;
this.presentationTimeOffset = 0;
this.segmentDuration = null;
this.initialization = null;
this.media = null;
this.duration = null;
this.startNumber = 1;
this.timeline = null;
this.hasIndex = false;
this.hasTimeline = false;
};

/* harmony default export */ var segment_template = (segment_template_SegmentTemplate);
// CONCATENATED MODULE: ./src/renderer/dash/model/mpd.js


var mpd_Mpd = function Mpd() {
classCallCheck_default()(this, Mpd);

this.duration = null;
this.maxSegmentDuration = 0;
this.minBufferTime = 6;
this.periods = [];
this.baseUrl = null;
this.location = null;
this.type = null;
this.minimumUpdatePeriod = null;
this.maxSegmentDuration = null;
this.publishTime = null;
this.startTime = 0;
this.availabilityStartTime = 0;
this.availabilityEndTime = 0;
this.UTCTiming = null;
this.timeShiftBufferDepth = null;
this.suggestedPresentationDelay = null;
};

/* harmony default export */ var model_mpd = (mpd_Mpd);
// CONCATENATED MODULE: ./src/renderer/dash/model/segment-item.js


var segment_item_SegmentItem = function SegmentItem() {
classCallCheck_default()(this, SegmentItem);

this.start = null;
this.startTime = null;
this.duration = null;
this.index = null;
};

/* harmony default export */ var segment_item = (segment_item_SegmentItem);
// CONCATENATED MODULE: ./src/renderer/dash/model/segment-list.js





var MAX_SEGMENTS = 100000;

var segment_list_SegmentList = /*#__PURE__*/function () {
function SegmentList() {
classCallCheck_default()(this, SegmentList);
}

createClass_default()(SegmentList, [{
key: "createSegmentList",
value: function createSegmentList() {
if (!this.hasOwnSegments) {
return;
}

var timescale = this.segmentTemplate.timescale;
var timePoints = this.segmentTemplate.timeline ? this.segmentTemplate.timeline.timePoints : null;
var segmentDuration = this.segmentTemplate.segmentDuration || null;
var segmentItem,
startTime = this.period.start * timescale,
repeat,
index = this.segmentTemplate.startNumber,
i,
length;
var isDynamic = this.isDynamic && !this.period.duration;

if (this.indexMode && isDynamic) {
this.segmentList = [];
this.segmentDuration = segmentDuration;
} else if (segmentDuration !== null) {
var duration = this.period.duration || this.duration;
var numberOfFragments = Math.ceil(duration / (segmentDuration / timescale));
this.segmentList = Array.from({
length: numberOfFragments
}).map(function (_, i) {
var segmentItem = new segment_item();
segmentItem.startTime = startTime + i * segmentDuration;
segmentItem.start = segmentItem.startTime / timescale;
segmentItem.duration = segmentDuration / timescale;
segmentItem.index = index + i;
return segmentItem;
});
} else if (timePoints !== null) {
var _timePoints$;

this.segmentList = [];
startTime = ((_timePoints$ = timePoints[0]) === null || _timePoints$ === void 0 ? void 0 : _timePoints$.startTime) || 0;
var streamTime = startTime - this.getPresentationTimeOffset() * timescale + this.period.start * timescale;

for (i = 0, length = timePoints.length; i < length; i++) {
repeat = timePoints[i].repeat || 0;
repeat++;

for (var j = 0; j < repeat; j++) {
segmentItem = new segment_item();
segmentItem.index = index;
segmentItem.startTime = startTime;
segmentItem.start = streamTime / timescale;
segmentItem.duration = timePoints[i].duration / timescale;
this.segmentList.push(segmentItem);
index++;
startTime += timePoints[i].duration;
streamTime += timePoints[i].duration;
}
}
}
}
}, {
key: "updateSegmentList",
value: function updateSegmentList(time) {
var _this$segmentList;

var _this$segmentTemplate = this.segmentTemplate,
timescale = _this$segmentTemplate.timescale,
startNumber = _this$segmentTemplate.startNumber;
var bufferLength = this.dvrWindow > 0 ? this.dvrWindow : this.timeShiftBufferDepth;
var presentationOffset = this.getPresentationTimeOffset();
var segmentDuration = this.segmentTemplate.segmentDuration / timescale;
var epoch = Math.max(0, Math.ceil(this.availabilityStartTime - presentationOffset));
var index = startNumber;
var duration = presentationOffset ? time - (presentationOffset + epoch) : bufferLength;
var startTime = presentationOffset;

if (!presentationOffset) {
startTime = time - epoch - bufferLength;
index = index + Math.floor(startTime / segmentDuration);
}

if (this.lastSegment) {
duration = time - (epoch + presentationOffset + this.lastSegment.start + segmentDuration);
startTime = this.lastSegment.start + segmentDuration + presentationOffset;
index = this.lastSegment.index + 1;
}

var numberOfFragments = Math.ceil(duration / segmentDuration);

if (!numberOfFragments) {
return;
}

var segmentList = Array.from({
length: Math.min(MAX_SEGMENTS, numberOfFragments)
}).map(function (_, i) {
var segmentItem = new segment_item();
var start = Object(helper["c" /* fixNumberPrecision */])(startTime + i * segmentDuration);
segmentItem.startTime = start + epoch;
segmentItem.start = start - presentationOffset;
segmentItem.duration = segmentDuration;
segmentItem.index = index + i;
return segmentItem;
});

(_this$segmentList = this.segmentList).push.apply(_this$segmentList, toConsumableArray_default()(segmentList));
}
}, {
key: "getPresentationTimeOffset",
value: function getPresentationTimeOffset() {
if (!this.segmentTemplate) {
return 0;
}

var _this$segmentTemplate2 = this.segmentTemplate,
presentationTimeOffset = _this$segmentTemplate2.presentationTimeOffset,
timescale = _this$segmentTemplate2.timescale;
return presentationTimeOffset / timescale;
}
}, {
key: "lastSegment",
get: function get() {
if (this.segmentList === null || !this.segmentList.length) {
return null;
}

return this.segmentList[this.segmentList.length - 1];
}
}, {
key: "endTime",
get: function get() {
var lastSegment = this.lastSegment;

if (lastSegment !== null) {
return lastSegment.start + lastSegment.duration;
}
}
}, {
key: "startTime",
get: function get() {
if (this.segmentList !== null && this.segmentList.length) {
return this.segmentList[0].start;
}

return 0;
}
}]);

return SegmentList;
}();

/* harmony default export */ var segment_list = (segment_list_SegmentList);
// CONCATENATED MODULE: ./src/renderer/dash/model/adaptation-set.js






function adaptation_set_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (adaptation_set_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function adaptation_set_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }



var adaptation_set_AdaptationSet = /*#__PURE__*/function (_SegmentList) {
inherits_default()(AdaptationSet, _SegmentList);

var _super = adaptation_set_createSuper(AdaptationSet);

function AdaptationSet() {
var _this;

classCallCheck_default()(this, AdaptationSet);

_this = _super.call(this);
_this.period = null;
_this.availabilityEndTime = null;
_this.url = null;
_this.minBufferTime = null;
_this.duration = 0;
_this.publishTime = null;
_this.suggestedPresentationDelay = null;
_this.presentationTimeOffset = 0;
_this.timeShiftBufferDepth = null;
_this.segmentTemplate = null;
_this.codecs = null;
_this.mimeType = null;
_this.contentType = null;
_this.type = null;
_this.segmentList = null;
_this.lang = null;
_this.representations = [];
_this.availabilityStartTime = null;
_this.UTCTiming = null;
_this.indexMode = false;
_this.dvrWindow = -1;
_this.hasOwnSegments = true;
_this.unsupportedCodecs = [];
return _this;
}

createClass_default()(AdaptationSet, [{
key: "getRepresentation",
value: function getRepresentation(_bandwidth) {
var bandwidth = _bandwidth || this.getAverageBandwidth();

return this.representations.find(function (representation) {
return representation.bandwidth === parseInt(bandwidth, 10);
});
}
}, {
key: "getAverageBandwidth",
value: function getAverageBandwidth() {
var bandwidths = this.representations.map(function (_ref) {
var bandwidth = _ref.bandwidth;
return bandwidth;
});
var middle = Math.floor(bandwidths.length / 2);
var index = middle - (bandwidths.length % 2 === 0 ? 1 : 0);
return bandwidths[index];
}
}]);

return AdaptationSet;
}(segment_list);


// CONCATENATED MODULE: ./src/renderer/dash/model/representation.js





function representation_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (representation_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function representation_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }



var representation_Representation = /*#__PURE__*/function (_SegmentList) {
inherits_default()(Representation, _SegmentList);

var _super = representation_createSuper(Representation);

function Representation() {
var _this;

classCallCheck_default()(this, Representation);

_this = _super.call(this);
_this.id = undefined;
_this.period = undefined;
_this.bandwidth = undefined;
_this.mimeType = undefined;
_this.width = undefined;
_this.height = undefined;
_this.codecs = undefined;
_this.mimeCodec = undefined;
_this.mediaType = undefined;
_this.url = undefined;
_this.segmentList = undefined;
_this.segmentTemplate = undefined;
_this.hasOwnSegments = true;
return _this;
}

return Representation;
}(segment_list);

/* harmony default export */ var model_representation = (representation_Representation);
// CONCATENATED MODULE: ./src/renderer/dash/manifest/parser.js














function ManifestParser(player) {
this.mpd = null;
this.options = player.options;
this.timeShift = player.timeShift;
}

ManifestParser.prototype = {
parse: function parse(data, url, responseUrl) {
var _getFirstChild,
_getFirstChild2,
_this = this;

this.mpd = new model_mpd();
this.mpd.dvrWindow = this.timeShift.getDvrWindow();
var parser = new DOMParser();
var xmlData = parser.parseFromString(data, 'text/xml');
var mpdNode = Object(helper["e" /* getFirstChild */])(xmlData, 'MPD');

if (mpdNode === null) {
return null;
}

if (!responseUrl) {
responseUrl = url;
}

responseUrl = responseUrl.split('?')[0];
this.mpd.timeStamp = new Date().getTime();
this.mpd.responseUrl = responseUrl;
this.mpd.type = mpdNode.getAttribute('type');
this.mpd.duration = Object(helper["h" /* parseDuration */])(mpdNode.getAttribute('mediaPresentationDuration'));
this.mpd.mediaPresentationDuration = Object(helper["h" /* parseDuration */])(mpdNode.getAttribute('mediaPresentationDuration'));
this.mpd.minBufferTime = Object(helper["h" /* parseDuration */])(mpdNode.getAttribute('minBufferTime')) || 0;
this.mpd.minimumUpdatePeriod = Object(helper["h" /* parseDuration */])(mpdNode.getAttribute('minimumUpdatePeriod'));
this.mpd.maxSegmentDuration = Object(helper["h" /* parseDuration */])(mpdNode.getAttribute('maxSegmentDuration'));
this.mpd.suggestedPresentationDelay = Object(helper["h" /* parseDuration */])(mpdNode.getAttribute('suggestedPresentationDelay')) || 0;
this.mpd.timeShiftBufferDepth = Object(helper["h" /* parseDuration */])(mpdNode.getAttribute('timeShiftBufferDepth')) || 0;
this.mpd.location = (_getFirstChild = Object(helper["e" /* getFirstChild */])(mpdNode, 'Location')) === null || _getFirstChild === void 0 ? void 0 : _getFirstChild.textContent;
this.mpd.periods = [];
this.mpd.availabilityStartTime = Object(helper["g" /* parseDateTime */])(mpdNode.getAttribute('availabilityStartTime')) || 0;
this.mpd.UTCTiming = (_getFirstChild2 = Object(helper["e" /* getFirstChild */])(mpdNode, 'UTCTiming')) === null || _getFirstChild2 === void 0 ? void 0 : _getFirstChild2.getAttribute('value');
var baseUrl = getBaseUrl(mpdNode, responseUrl);

if (this.mpd.duration === null) {
this.mpd.duration = Number.MAX_VALUE;
}

if (this.mpd.mediaPresentationDuration !== null) {
this.mpd.duration = this.mpd.mediaPresentationDuration;
}

this.mpd.availabilityStartTime = Object(helper["g" /* parseDateTime */])(mpdNode.getAttribute('availabilityStartTime')) || 0;
this.mpd.availabilityEndTime = Object(helper["g" /* parseDateTime */])(mpdNode.getAttribute('availabilityEndTime')) || 0;

if (this.mpd.availabilityStartTime && this.mpd.mediaPresentationDuration && !this.mpd.availabilityEndTime) {
this.mpd.availabilityEndTime = this.mpd.availabilityStartTime + this.mpd.mediaPresentationDuration;
}

this.mpd.startTime = 0;
this.mpd.publishTime = mpdNode.getAttribute('publishTime');
var periods = Array.from(Object(helper["d" /* getChildren */])(mpdNode, 'Period') || []).map(function (period) {
return _this.createPeriod(period, baseUrl, responseUrl);
});
periods.forEach(function (period, index) {
var prevPeriod = periods[index - 1] || {};

if (prevPeriod) {
prevPeriod.end = period.start;
prevPeriod.duration = period.start - prevPeriod.start;
}
});
this.mpd.periods = periods;
this.mpd.periods.forEach(function (period) {
period.adaptationSets.forEach(function (adaptationSet) {
adaptationSet.createSegmentList();
adaptationSet.representations.forEach(function (representation) {
representation.createSegmentList();

if (!representation.hasOwnSegments) {
representation.segmentList = adaptationSet.segmentList;
}
});
});
});
return this.mpd;
},
createPeriod: function createPeriod(node, baseUrl, responseUrl) {
var period = new model_period();
var adaptationSetsNode = Object(helper["d" /* getChildren */])(node, 'AdaptationSet');
var periodBaseUrl = getBaseUrl(node, responseUrl);

if (periodBaseUrl === null) {
periodBaseUrl = baseUrl;
}

period.id = node.getAttribute('id') || "period_".concat(Date.now());
period.start = Object(helper["h" /* parseDuration */])(node.getAttribute('start'));
period.baseUrl = periodBaseUrl || getRootUrl(responseUrl);
period.segmentTemplate = this.createSegmentTemplate(node);
this.createAdaptationSets(this.mpd, period, adaptationSetsNode);
var eventStreams = Object(helper["d" /* getChildren */])(node, 'EventStream');

if (eventStreams.length) {
period.createEvents(eventStreams);
}

return period;
},
createAdaptationSets: function createAdaptationSets(mpd, period, adaptationSetsNode) {
var trackId = 1;
var allAudioDiscarded = true;
var firstAudioNode = undefined;

for (var j = 0; j < adaptationSetsNode.length; j++) {
var node = adaptationSetsNode[j];
var type = this.getAdaptationSetType(node);
firstAudioNode = type === media_type["a" /* default */].AUDIO ? firstAudioNode || node : firstAudioNode;

if (this.shouldDiscardAdaptation(node, type)) {
continue;
}

if (type === media_type["a" /* default */].AUDIO) {
allAudioDiscarded = false;
}

var adaptationSet = this.createAdaptationSet(mpd, period, node, {
trackId: trackId,
type: type
});

if (adaptationSet.type !== media_type["a" /* default */].VIDEO) {
trackId++;
}

period.adaptationSets.push(adaptationSet);
}

if (allAudioDiscarded && firstAudioNode) {
var _adaptationSet = this.createAdaptationSet(mpd, period, firstAudioNode, {
trackId: trackId,
type: media_type["a" /* default */].AUDIO
});

period.adaptationSets.push(_adaptationSet);
}
},
createAdaptationSet: function createAdaptationSet(mpd, period, adaptationSetNode, params) {
var _getFirstChild3, _getFirstChild4;

var adaptationSet = new adaptation_set_AdaptationSet();
var trackId = params.trackId,
type = params.type;
adaptationSet.period = period;
adaptationSet.url = period.baseUrl;
adaptationSet.segmentTemplate = this.createSegmentTemplate(adaptationSetNode, period.segmentTemplate || {});

if (!adaptationSet.segmentTemplate) {
adaptationSet.hasOwnSegments = false;
}

adaptationSet.indexMode = adaptationSet.segmentTemplate && adaptationSet.segmentTemplate.duration && !adaptationSet.segmentTemplate.hasTimeline;
adaptationSet.publishTime = this.mpd.publishTime;
adaptationSet.dvrWindow = mpd.dvrWindow;
adaptationSet.timeShiftBufferDepth = this.mpd.timeShiftBufferDepth;
adaptationSet.suggestedPresentationDelay = this.mpd.suggestedPresentationDelay;
adaptationSet.availabilityStartTime = this.mpd.availabilityStartTime;
adaptationSet.suggestedPresentationDelay = this.mpd.suggestedPresentationDelay;
adaptationSet.availabilityEndTime = this.mpd.availabilityEndTime;
adaptationSet.UTCTiming = this.mpd.UTCTiming;
adaptationSet.duration = this.mpd.duration;
adaptationSet.minBufferTime = this.mpd.minBufferTime;
adaptationSet.isDynamic = this.mpd.type === 'dynamic';
mpd.indexMode = adaptationSet.indexMode;
adaptationSet.codecs = adaptationSetNode.getAttribute('codecs');
adaptationSet.lang = adaptationSetNode.getAttribute('lang');
adaptationSet.mimeType = adaptationSetNode.getAttribute('mimeType');
adaptationSet.type = type;
adaptationSet.accessibility = (_getFirstChild3 = Object(helper["e" /* getFirstChild */])(adaptationSetNode, 'Accessibility')) === null || _getFirstChild3 === void 0 ? void 0 : _getFirstChild3.getAttribute('value');
adaptationSet.role = (_getFirstChild4 = Object(helper["e" /* getFirstChild */])(adaptationSetNode, 'Role')) === null || _getFirstChild4 === void 0 ? void 0 : _getFirstChild4.getAttribute('value');

if (adaptationSetNode.getAttribute('id')) {
adaptationSet.id = parseInt(adaptationSetNode.getAttribute('id'));
}

if (adaptationSet.type !== media_type["a" /* default */].VIDEO && isNaN(adaptationSet.id)) {
adaptationSet.id = trackId;
}

var representationsNodes = Object(helper["d" /* getChildren */])(adaptationSetNode, 'Representation');

for (var k = 0; k < representationsNodes.length; k++) {
var representation = this.createRepresentation(adaptationSet, representationsNodes[k]);
var hasOwnSegments = representation.hasOwnSegments,
mediaType = representation.mediaType,
mimeCodec = representation.mimeCodec,
segmentTemplate = representation.segmentTemplate;
representation.period = period;

if (hasOwnSegments && segmentTemplate.hasIndex && !segmentTemplate.hasTimeline) {
mpd.indexMode = true;
}

if ([media_type["a" /* default */].AUDIO, media_type["a" /* default */].VIDEO].includes(mediaType) && mimeCodec && !window.MediaSource.isTypeSupported(mimeCodec)) {
adaptationSet.unsupportedCodecs.push(mimeCodec);
continue;
}

adaptationSet.representations.push(representation);
}

if (adaptationSet.representations && adaptationSet.representations.length) {
var _adaptationSet$repres = slicedToArray_default()(adaptationSet.representations, 1),
firstRepresentation = _adaptationSet$repres[0];

if (adaptationSet.mimeType === null && firstRepresentation.mimeType !== null) {
adaptationSet.mimeType = firstRepresentation.mimeType;
}

if (!adaptationSet.codecs) {
adaptationSet.codecs = firstRepresentation.codecs;
}

if (adaptationSet.codecs) {
adaptationSet.contentType = "".concat(adaptationSet.mimeType, ";codecs=\"").concat(adaptationSet.codecs, "\"");
}
}

adaptationSet.representations.sort(this.sortFn);
return adaptationSet;
},
getAdaptationSetType: function getAdaptationSetType(adaptationSetNode) {
var type = Object(helper["f" /* getNodeContentType */])(adaptationSetNode);

if (!type) {
var _getChildren = Object(helper["d" /* getChildren */])(adaptationSetNode, 'Representation'),
_getChildren2 = slicedToArray_default()(_getChildren, 1),
firstRepresentation = _getChildren2[0];

return Object(helper["f" /* getNodeContentType */])(firstRepresentation);
}

return type;
},
createRepresentation: function createRepresentation(adaptationSet, node) {
var representation = new model_representation();
representation.id = node.getAttribute('id');
representation.bandwidth = parseInt(node.getAttribute('bandwidth'));
representation.mimeType = node.getAttribute('mimeType');
representation.width = parseInt(node.getAttribute('width'));
representation.height = parseInt(node.getAttribute('height'));
representation.mediaType = adaptationSet.type;
representation.url = adaptationSet.url;
representation.segmentList = adaptationSet.segmentList;
representation.availabilityStartTime = adaptationSet.availabilityStartTime;
representation.timeShiftBufferDepth = adaptationSet.timeShiftBufferDepth;
representation.codecs = node.getAttribute('codecs');

if (representation.codecs === 'mp4a.40.1') {
representation.codecs = 'mp4a.40.2';
}

if (representation.codecs && adaptationSet.mimeType) {
representation.mimeCodec = "".concat(adaptationSet.mimeType, ";codecs=\"").concat(representation.codecs, "\"");
}

representation.segmentTemplate = this.createSegmentTemplate(node);

if (!representation.segmentTemplate && adaptationSet.segmentTemplate) {
representation.hasOwnSegments = false;
representation.segmentTemplate = adaptationSet.segmentTemplate;
}

return representation;
},
createSegmentTemplate: function createSegmentTemplate(node) {
var template = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var initialization = template.initialization,
media = template.media,
_template$startNumber = template.startNumber,
startNumber = _template$startNumber === void 0 ? 1 : _template$startNumber;
var templateNode = Object(helper["e" /* getFirstChild */])(node, 'SegmentTemplate');

if (!templateNode) {
return undefined;
}

var segmentTimelineNode = Object(helper["e" /* getFirstChild */])(templateNode, 'SegmentTimeline');
var segmentTemplate = new segment_template();
segmentTemplate.timeline = new segment_timeline();

if (segmentTimelineNode) {
var timePointNodes = Object(helper["d" /* getChildren */])(segmentTimelineNode, 'S');
segmentTemplate.timeline.parse(timePointNodes);
}

segmentTemplate.timescale = parseInt(templateNode.getAttribute('timescale')) || 1;
segmentTemplate.segmentDuration = parseInt(templateNode.getAttribute('duration'));
var startNumberValue = templateNode.getAttribute('startNumber');
segmentTemplate.hasIndex = !!startNumberValue;
segmentTemplate.hasTimeline = !!segmentTimelineNode;
segmentTemplate.startNumber = startNumberValue !== null ? parseInt(startNumberValue, 10) : startNumber;
segmentTemplate.duration = parseInt(templateNode.getAttribute('duration'));
segmentTemplate.presentationTimeOffset = parseInt(templateNode.getAttribute('presentationTimeOffset')) || 0;
segmentTemplate.initialization = templateNode.getAttribute('initialization') || initialization;
segmentTemplate.media = templateNode.getAttribute('media') || media;
return segmentTemplate;
},
shouldDiscardAdaptation: function shouldDiscardAdaptation(node, type) {
var allowedAudioLanguages = this.options.get(option_name["d" /* ALLOWED_AUDIO_LANGUAGES */]);
var allowedTextLanguages = this.options.get(option_name["e" /* ALLOWED_SUBTITLE_LANGUAGES */]);
var lang = node.getAttribute('lang');

if (!lang) {
return;
}

if (allowedAudioLanguages && type === media_type["a" /* default */].AUDIO) {
return !allowedAudioLanguages.includes(lang);
}

if (allowedTextLanguages && type === media_type["a" /* default */].TEXT) {
return !allowedTextLanguages.includes(lang);
}
},
sortFn: function sortFn(a, b) {
return b.bandwidth - a.bandwidth;
},
update: function update(manifest, data, timeShiftBufferDepth) {
var _this2 = this;

var bufferLength = this.timeShift.getDvrWindow() > 0 ? this.timeShift.getDvrWindow() : timeShiftBufferDepth;
data.periods.forEach(function (period) {
var exists = manifest.periods.find(function (_ref) {
var start = _ref.start;
return start === period.start;
});
var periodToUpdate = manifest.periods.find(function (_ref2) {
var start = _ref2.start,
end = _ref2.end;
return start === period.start && !end;
});

if (!exists) {
manifest.periods.push(period);
}

if (periodToUpdate) {
_this2.updatePeriod(periodToUpdate, period, timeShiftBufferDepth);
}
});
manifest.periods.sort(function (a, b) {
return a.start - b.start;
});

if (manifest.periods.length > 1) {
var _manifest$periods = slicedToArray_default()(manifest.periods, 1),
firstPeriod = _manifest$periods[0];

var _manifest$periods$sli = manifest.periods.slice(-1),
_manifest$periods$sli2 = slicedToArray_default()(_manifest$periods$sli, 1),
lastPeriod = _manifest$periods$sli2[0];

var duration = lastPeriod.start - firstPeriod.start;

if (bufferLength > 0 && duration > bufferLength) {
manifest.periods = manifest.periods.reduce(function (arr, period) {
if ((period.end || period.start) >= lastPeriod.start - bufferLength) {
arr.push(period);
}

return arr;
}, []);
}
}

this.updatePeriodsDuration(manifest.periods);
manifest.publishTime = data.publishTime;
manifest.baseUrl = data.baseUrl;
return manifest;
},
updatePeriod: function updatePeriod(period, source, timeShiftBufferDepth) {
var _this3 = this;

var _loop = function _loop(i) {
var oldAdaptationSet = period.adaptationSets[i];
var newAdaptationSet = source.adaptationSets[i];
var oList = oldAdaptationSet.segmentList;
var nList = newAdaptationSet.segmentList;
oldAdaptationSet.url = newAdaptationSet.url;

if ((nList === null || nList === void 0 ? void 0 : nList.length) > 0) {
oldAdaptationSet.segmentList = _this3.merge(oList, nList, timeShiftBufferDepth);
}

oldAdaptationSet.representations.forEach(function (representation, index) {
var newRepresentation = newAdaptationSet.representations[index];

if (newRepresentation === null || newRepresentation === void 0 ? void 0 : newRepresentation.segmentList) {
representation.segmentList = _this3.merge(representation.segmentList, newRepresentation.segmentList, timeShiftBufferDepth);
representation.url = newAdaptationSet.url;
}
});
};

for (var i = 0; i < source.adaptationSets.length; i++) {
_loop(i);
}
},
updatePeriodsDuration: function updatePeriodsDuration(periods) {
var prevPeriod;
periods.forEach(function (period) {
if (prevPeriod) {
var _prevPeriod = prevPeriod,
duration = _prevPeriod.duration,
start = _prevPeriod.start;
prevPeriod.end = period.start;
prevPeriod.duration = period.start - start;

if (!duration) {
prevPeriod.trigger(player_event["K" /* PERIOD_UPDATED */], prevPeriod);
}
}

prevPeriod = period;
});
},
merge: function merge(oldSegmentList, newSegmentList) {
var timeShiftBufferDepth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var segmentList = [];

var _newSegmentList = slicedToArray_default()(newSegmentList, 1),
firstSegment = _newSegmentList[0];

var tempList;

if (!firstSegment) {
return oldSegmentList;
}

oldSegmentList = oldSegmentList.filter(function (item) {
return firstSegment.start > item.start;
});
tempList = [].concat(toConsumableArray_default()(oldSegmentList), toConsumableArray_default()(newSegmentList));
var index = tempList[0].index;

var _tempList$slice = tempList.slice(-1),
_tempList$slice2 = slicedToArray_default()(_tempList$slice, 1),
last = _tempList$slice2[0];

var start = timeShiftBufferDepth === 0 ? 0 : last.start - timeShiftBufferDepth;
tempList.forEach(function (segment) {
if (segment.index > index) {
index = segment.index;
}

segment.index = index;

if (segment.start > start) {
segmentList.push(segment);
index++;
}
});
return segmentList;
}
};

function getBaseUrl(node, url) {
var baseUrlNode = Object(helper["e" /* getFirstChild */])(node, 'BaseURL');
var nodeUrl;
var baseUrl = null;

if (baseUrlNode !== null) {
nodeUrl = baseUrlNode.textContent;

if (nodeUrl !== null) {
if (Object(util_url["a" /* isUrlAbsolute */])(nodeUrl)) {
baseUrl = nodeUrl;
} else {
baseUrl = [url.slice(0, url.lastIndexOf('/')), nodeUrl].join('/');

if (nodeUrl.startsWith('/')) {
try {
baseUrl = "".concat(new URL(url).origin).concat(nodeUrl);
} catch (e) {}
}
}
}
}

return baseUrl;
}

function getRootUrl(url) {
var to = url.lastIndexOf('/');
to = to === -1 ? url.length : to + 1;
return url.substring(0, to);
}

/* harmony default export */ var manifest_parser = (ManifestParser);
// CONCATENATED MODULE: ./src/renderer/dash/manifest/manifest.js










function manifest_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (manifest_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function manifest_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
















var manifest_ManifestManager = /*#__PURE__*/function (_EventEmitter) {
inherits_default()(ManifestManager, _EventEmitter);

var _super = manifest_createSuper(ManifestManager);

function ManifestManager(video, player) {
var _this$httpConfig, _this$httpConfig$mani;

var _this;

classCallCheck_default()(this, ManifestManager);

_this = _super.call(this);
player.addComponent(assertThisInitialized_default()(_this), player_component["c" /* MANIFEST_MANAGER */]);
_this.video = video;
_this.player = player;
_this.logger = logger["a" /* default */].get("manifest");
_this.options = _this.player.options;
_this.httpConfig = _this.options.get(option_name["N" /* HTTP_CONFIG */]);
_this.headers = (_this$httpConfig = _this.httpConfig) === null || _this$httpConfig === void 0 ? void 0 : (_this$httpConfig$mani = _this$httpConfig.manifest) === null || _this$httpConfig$mani === void 0 ? void 0 : _this$httpConfig$mani.headers;
_this.streamWithCredentials = _this.options.get(option_name["Bb" /* STREAM_WITH_CREDENTIALS */]);
_this.minimumUpdatePeriodEnabled = _this.options.get(option_name["Y" /* MINIMUM_UPDATE_PERIOD_ENABLED */]);
_this.timeShift = _this.player.timeShift;
_this.utcTime = new utc_time["a" /* default */](player);
_this.manifest = null;
_this.UTCTimingUrl = null;
_this.parser = new manifest_parser(player);
_this.updating = false;
_this.adaptations = [];
_this.videoAdaptation = null;
_this.audioAdaptation = null;

_this.cancelRequest = function () {};

_this.monitorTimer = null;
_this.headSegmentIndex = -1;
_this.duration = -1;
_this.url = null;
_this.utcHeadTime = 0;
return _this;
}

createClass_default()(ManifestManager, [{
key: "monitor",
value: function monitor() {
var url = this.manifest.location || this.url;

if (this.isIndexMode()) {
var utcTime = this.utcTime.getTime();

if (utcTime > 0) {
this.updateTimeLine(utcTime);
this.utcHeadTime = utcTime - this.parser.mpd.availabilityStartTime;
var lastUpdate = (new Date().getTime() - this.parser.mpd.timeStamp) / 1000;

if (this.minimumUpdatePeriodEnabled && lastUpdate > this.manifest.minimumUpdatePeriod) {
this.update(Object(util_url["b" /* removeUrlParam */])(url, 'startTime'));
}
}

return;
}

if (this.updating) {
return;
}

this.update(url);
}
}, {
key: "load",
value: function load(url) {
var _this2 = this;

this.url = url;
this.updating = true;
this.abort();

if (this.monitorTimer) {
this.monitorTimer.stop();
}

return this.fetch(this.url).then( /*#__PURE__*/function () {
var _ref = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee(response) {
var metric, data, url, responseUrl, utcTime, interval;
return regenerator_default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
metric = response.metric, data = response.data, url = response.url, responseUrl = response.responseUrl;

_this2.sendMetric(metric);

_this2.manifest = _this2.parse(data, url, responseUrl);
_this2.UTCTimingUrl = _this2.manifest.UTCTiming;
_this2.adaptations = _this2.getAllAdaptationSets();
_this2.videoAdaptation = _this2.getAdaptationSetByType(media_type["a" /* default */].VIDEO);
_this2.audioAdaptation = _this2.getAdaptationSetByType(media_type["a" /* default */].AUDIO);
_this2.duration = _this2.manifest.duration;
_this2.updating = false;

if (!_this2.isLive()) {
_context.next = 19;
break;
}

_context.next = 12;
return _this2.utcTime.init();

case 12:
utcTime = _context.sent;

_this2.trigger(player_event["s" /* HEAD_TIME */], utcTime);

interval = _this2.manifest.minimumUpdatePeriod * 1000 || 2000;

if (_this2.isIndexMode()) {
interval = 1000;
}

_this2.monitorTimer = new util_timer["a" /* default */](interval, _this2.monitor.bind(_this2));

_this2.monitorTimer.start();

if (_this2.isIndexMode()) {
_this2.monitor();
}

case 19:
_this2.logger.info("MANIFEST LOADED: duration: ".concat(metric.duration / 1000, ", url: ").concat(_this2.url));

_this2.trigger(player_event["v" /* MANIFEST_LOADED */], _this2.manifest);

return _context.abrupt("return", _this2.manifest);

case 22:
case "end":
return _context.stop();
}
}
}, _callee);
}));

return function (_x) {
return _ref.apply(this, arguments);
};
}())["catch"](function (_ref2) {
var error = _ref2.error,
metric = _ref2.metric,
xhr = _ref2.xhr;
_this2.updating = false;

if (error === http_status["b" /* FAILED */]) {
_this2.sendMetric(metric);

_this2.logger.error("MANIFEST LOADED: duration: ".concat(metric.duration / 1000, ", url: ").concat(_this2.url));

return Promise.reject({
error: dash_event["c" /* FAILED_TO_DOWNLOAD_MANIFEST */],
url: url,
xhr: xhr
});
}
});
}
}, {
key: "update",
value: function update(manifestUrl) {
var _this3 = this;

this.updating = true;
var timeShiftBufferDepth = 0;

if (!this.timeShift.isEnabled()) {
timeShiftBufferDepth = 60;
}

if (!!this.parser.mpd.timeShiftBufferDepth) {
timeShiftBufferDepth = this.parser.mpd.timeShiftBufferDepth;
}

this.fetch(manifestUrl).then(function (response) {
var metric = response.metric,
data = response.data,
url = response.url,
responseUrl = response.responseUrl;

var newManifest = _this3.parse(data, url, responseUrl);

_this3.sendMetric(metric);

_this3.manifest = _this3.parser.update(_this3.manifest, newManifest, timeShiftBufferDepth);

_this3.trigger(player_event["s" /* HEAD_TIME */], _this3.utcTime.getTime());

_this3.trigger(player_event["w" /* MANIFEST_UPDATED */], _this3.manifest);

_this3.updating = false;

_this3.logger.info("MANIFEST UPDATED: duration: ".concat(metric.duration / 1000, ", url: ").concat(manifestUrl));

return _this3.manifest;
})["catch"](function (_ref3) {
var error = _ref3.error,
metric = _ref3.metric;

if (error === http_status["b" /* FAILED */]) {
_this3.trigger(player_event["x" /* MANIFEST_UPDATE_ERROR */]);

_this3.logger.error("MANIFEST LOADED: duration: ".concat(metric.duration / 1000, ", url: ").concat(manifestUrl));

_this3.sendMetric(metric);
}

_this3.updating = false;
});
}
}, {
key: "fetch",
value: function fetch(url) {
var _this4 = this,
_this$httpConfig2,
_this$httpConfig2$man;

return http["a" /* default */].get(url, {
cancelToken: new http["a" /* default */].CancelToken(function (c) {
return _this4.cancelRequest = c;
}),
withCredentials: this.streamWithCredentials || !!((_this$httpConfig2 = this.httpConfig) === null || _this$httpConfig2 === void 0 ? void 0 : (_this$httpConfig2$man = _this$httpConfig2.manifest) === null || _this$httpConfig2$man === void 0 ? void 0 : _this$httpConfig2$man.withCredentials),
headers: this.headers
});
}
}, {
key: "sendMetric",
value: function sendMetric(metric) {
this.player.trigger(player_event["A" /* NETWORK_METRIC */], {
duration: metric.duration,
status: metric.status,
statusCode: metric.statusCode,
timestamp: new Date().getTime(),
url: metric.url,
type: 'MANIFEST'
});
}
}, {
key: "destroy",
value: function destroy() {
if (this.monitorTimer) {
this.monitorTimer.stop();
}

this.utcTime.stop();
this.abort();
}
}, {
key: "abort",
value: function abort() {
this.cancelRequest();
}
}, {
key: "getPresentationTimeOffset",
value: function getPresentationTimeOffset() {
return this.manifest.presentationTimeOffset;
}
}, {
key: "parse",
value: function parse(data, url, responseURL) {
return this.parser.parse(data, url, responseURL);
}
}, {
key: "updateManifest",
value: function updateManifest(manifest, newManifest, newStart) {
return this.parser.update(manifest, newManifest, newStart);
}
}, {
key: "isIndexMode",
value: function isIndexMode() {
return this.manifest && this.manifest.indexMode;
}
}, {
key: "isLive",
value: function isLive() {
return this.manifest && this.manifest.type === 'dynamic';
}
}, {
key: "getLiveDelay",
value: function getLiveDelay() {
var delay = Math.max(this.options.get(option_name["bb" /* MIN_LIVE_DELAY */]), this.suggestedPresentationDelay);

if (this.startBufferLength) {
delay = this.startBufferLength;
}

return this.options.get(option_name["V" /* LIVE_DELAY */]) || delay;
}
}, {
key: "getAudioProfiles",
value: function getAudioProfiles(period) {
return this.getRepresentationsByType(media_type["a" /* default */].AUDIO, period);
}
}, {
key: "getVideoProfiles",
value: function getVideoProfiles(period) {
return this.getRepresentationsByType(media_type["a" /* default */].VIDEO, period);
}
}, {
key: "getVideoNearestBandwidth",
value: function getVideoNearestBandwidth(bandwidth, period) {
var bandwidths = this.getVideoProfiles(period).map(function (_ref4) {
var bandwidth = _ref4.bandwidth;
return bandwidth;
});
return bandwidths.find(function (profile) {
return bandwidth >= profile;
}) || bandwidths[bandwidths.length - 1];
}
}, {
key: "getTextAdaptations",
value: function getTextAdaptations() {
return this.getAdaptationsSetByType(media_type["a" /* default */].TEXT);
}
}, {
key: "getAudioAdaptations",
value: function getAudioAdaptations(period) {
return this.getAdaptations(media_type["a" /* default */].AUDIO, period);
}
}, {
key: "getAudioAdaptation",
value: function getAudioAdaptation(track, period) {
var adaptations = this.getAudioAdaptations(period);
var field = typeof track === 'string' ? 'lang' : 'id';
return adaptations.find(function (adaptation) {
return adaptation[field] === track;
});
}
}, {
key: "getAudioTracks",
value: function getAudioTracks() {
var adaptations = this.getAudioAdaptations();
return adaptations.map(function (adaptation) {
return new audio_track["a" /* default */](adaptation);
});
}
}, {
key: "updateTimeLine",
value: function updateTimeLine(time) {
var _this$getPeriods$slic = this.getPeriods().slice().reverse(),
_this$getPeriods$slic2 = slicedToArray_default()(_this$getPeriods$slic, 1),
period = _this$getPeriods$slic2[0];

this.getAllAdaptationSets(period).forEach(function (adaptation) {
if (adaptation.segmentTemplate) {
adaptation.updateSegmentList(time);
}

adaptation.representations.forEach(function (representation) {
if (representation.hasOwnSegments && representation.segmentTemplate.hasIndex) {
representation.updateSegmentList(time);
}
});
});
}
}, {
key: "getLastSegmentEndTimeByType",
value: function getLastSegmentEndTimeByType(type) {
var _this$getRepresentati = this.getRepresentationsByType(type),
_this$getRepresentati2 = slicedToArray_default()(_this$getRepresentati, 1),
representation = _this$getRepresentati2[0];

return representation === null || representation === void 0 ? void 0 : representation.endTime;
}
}, {
key: "getFirstSegmentStartTimeByType",
value: function getFirstSegmentStartTimeByType(type) {
var _this$getRepresentati3 = this.getRepresentationsByType(type),
_this$getRepresentati4 = slicedToArray_default()(_this$getRepresentati3, 1),
representation = _this$getRepresentati4[0];

return (representation === null || representation === void 0 ? void 0 : representation.startTime) || -1;
}
}, {
key: "getStartTime",
value: function getStartTime() {
return Math.max(this.getFirstSegmentStartTimeByType(media_type["a" /* default */].VIDEO), this.getFirstSegmentStartTimeByType(media_type["a" /* default */].AUDIO));
}
}, {
key: "getAdaptations",
value: function getAdaptations(type, period, language) {
return this.manifest && this.getAdaptationsSetByType(type, period, language);
}
}, {
key: "getAllAdaptationSets",
value: function getAllAdaptationSets(period) {
return this.getPeriod(period).adaptationSets;
}
}, {
key: "getAdaptationSetMimeType",
value: function getAdaptationSetMimeType(type) {
var _this$getAdaptations = this.getAdaptations(type),
_this$getAdaptations2 = slicedToArray_default()(_this$getAdaptations, 1),
adaptation = _this$getAdaptations2[0];

return adaptation && "".concat(adaptation.mimeType, "; codecs=").concat(adaptation.codecs);
}
}, {
key: "getPeriods",
value: function getPeriods() {
var _this$manifest;

return (_this$manifest = this.manifest) === null || _this$manifest === void 0 ? void 0 : _this$manifest.periods;
}
}, {
key: "getPeriod",
value: function getPeriod(period) {
var _this$getPeriods, _this$getPeriods2;

return ((_this$getPeriods = this.getPeriods()) === null || _this$getPeriods === void 0 ? void 0 : _this$getPeriods.find(function (_ref5) {
var id = _ref5.id,
start = _ref5.start;
return id === (period === null || period === void 0 ? void 0 : period.id) && start === (period === null || period === void 0 ? void 0 : period.start);
})) || ((_this$getPeriods2 = this.getPeriods()) === null || _this$getPeriods2 === void 0 ? void 0 : _this$getPeriods2[0]);
}
}, {
key: "getNextPeriod",
value: function getNextPeriod(period) {
var periods = this.getPeriods();
var index = periods.indexOf(period);
return index >= 0 && periods[index + 1];
}
}, {
key: "getLastPeriod",
value: function getLastPeriod() {
var periods = this.getPeriods();
return periods[periods.length - 1];
}
}, {
key: "getPeriodById",
value: function getPeriodById(_id) {
var _this$getPeriods3, _this$getPeriods4;

return ((_this$getPeriods3 = this.getPeriods()) === null || _this$getPeriods3 === void 0 ? void 0 : _this$getPeriods3.find(function (_ref6) {
var id = _ref6.id;
return id === _id;
})) || ((_this$getPeriods4 = this.getPeriods()) === null || _this$getPeriods4 === void 0 ? void 0 : _this$getPeriods4[0]);
}
}, {
key: "getAdaptationsSetByType",
value: function getAdaptationsSetByType(_type, period) {
var _this$getPeriod;

return (_this$getPeriod = this.getPeriod(period)) === null || _this$getPeriod === void 0 ? void 0 : _this$getPeriod.adaptationSets.filter(function (_ref7) {
var type = _ref7.type;
return type === _type;
});
}
}, {
key: "getAdaptationSetByType",
value: function getAdaptationSetByType(type, period, language) {
var adaptationSets = this.getAdaptationsSetByType(type, period);

if (language) {
adaptationSets = adaptationSets.filter(function (_ref8) {
var lang = _ref8.lang;
return lang === language;
});
}

if (adaptationSets.length) {
return adaptationSets[0];
}

return null;
}
}, {
key: "getRepresentationsByType",
value: function getRepresentationsByType(type, period) {
var adaptationSet = this.getAdaptationSetByType(type, period);

if (adaptationSet === null) {
return [];
}

return adaptationSet.representations;
}
}, {
key: "getRepresentationByBandwidth",
value: function getRepresentationByBandwidth(bandwidth, type, period) {
var _type = typeof type === 'undefined' ? 'video' : type;

var adaptationSet = this.getAdaptationSetByType(_type, period);

if (adaptationSet === null) {
return null;
}

return adaptationSet.getRepresentation(bandwidth);
}
}, {
key: "findPeriodByTime",
value: function findPeriodByTime(time) {
var periods = this.manifest.periods;
return (periods === null || periods === void 0 ? void 0 : periods.find(function (_ref9) {
var start = _ref9.start,
end = _ref9.end;
return time >= start && time < (end || Infinity);
})) || (periods === null || periods === void 0 ? void 0 : periods[0]);
}
}, {
key: "minBufferTime",
get: function get() {
return this.options.get(option_name["ab" /* MIN_BUFFER_TIME */]) || 0;
}
}, {
key: "maxBufferLength",
get: function get() {
var max = this.options.get(option_name["X" /* MAX_BUFFER_LENGTH */]);

if (this.startBufferLength >= max) {
return this.startBufferLength + 1;
}

return max;
},
set: function set(max) {
this.options.set(option_name["X" /* MAX_BUFFER_LENGTH */], max);
}
}, {
key: "startBufferLength",
get: function get() {
return this.options.get(option_name["zb" /* START_BUFFER_LENGTH */]);
}
}, {
key: "minAutoBitrate",
get: function get() {
return this.options.get(option_name["Z" /* MIN_AUTO_BITRATE */]);
}
}, {
key: "maxAutoBitrate",
get: function get() {
return this.options.get(option_name["W" /* MAX_AUTO_BITRATE */]);
}
}, {
key: "suggestedPresentationDelay",
get: function get() {
return this.manifest.suggestedPresentationDelay;
}
}, {
key: "segmentDuration",
get: function get() {
if (!this.videoAdaptation.segmentTemplate) {
return 0;
}

if (this.videoAdaptation.segmentTemplate.segmentDuration) {
return this.videoAdaptation.segmentTemplate.segmentDuration / this.videoAdaptation.segmentTemplate.timescale;
}

if (this.videoAdaptation.segmentList.length) {
return this.videoAdaptation.segmentList[0].duration;
}

return 0;
}
}]);

return ManifestManager;
}(event_emitter["a" /* default */]);


// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/defineProperty.js
var defineProperty = __webpack_require__(2);
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);

// EXTERNAL MODULE: ./src/core/timeshift.js
var timeshift = __webpack_require__(28);

// CONCATENATED MODULE: ./src/core/model/media-ready-state.js
/* harmony default export */ var media_ready_state = ({
HAVE_NOTHING: 0,
HAVE_METADATA: 1,
HAVE_CURRENT_DATA: 2,
HAVE_FUTURE_DATA: 3,
HAVE_ENOUGH_DATA: 4
});
// CONCATENATED MODULE: ./src/renderer/dash/event/source-buffer-event.js
var ABORT = 'abort';
var ERROR = 'error';
var UPDATE_END = 'updateend';
// CONCATENATED MODULE: ./src/core/util/source-buffer-queue.js




var source_buffer_queue_SourceBufferQueue = /*#__PURE__*/function () {
function SourceBufferQueue(sourceBuffer) {
classCallCheck_default()(this, SourceBufferQueue);

this.taskQueue = [];
this.sourceBuffer = sourceBuffer;
}

createClass_default()(SourceBufferQueue, [{
key: "addTask",
value: function addTask(fn) {
var resolve;
var reject;
var promise = new Promise(function (_resolve, _reject) {
resolve = _resolve;
reject = _reject;
});
var task = {
fn: fn,
p: {
resolve: resolve,
reject: reject
}
};
this.taskQueue.push(task);

if (this.taskQueue.length === 1) {
this.runTask();
}

return promise;
}
}, {
key: "runTask",
value: function runTask() {
var _this$taskQueue = slicedToArray_default()(this.taskQueue, 1),
task = _this$taskQueue[0];

if (!task || this.sourceBuffer.updating) {
return;
}

try {
task.result = task.fn();
} catch (e) {
this.taskQueue.shift();
task.p.reject(e);
this.runTask();
}
}
}, {
key: "onSuccess",
value: function onSuccess() {
var task = this.taskQueue.shift();
task.p.resolve(task.result);
this.runTask();
}
}, {
key: "onError",
value: function onError(e) {
var _this$taskQueue2 = slicedToArray_default()(this.taskQueue, 1),
task = _this$taskQueue2[0];

task.p.reject(e);
}
}, {
key: "empty",
value: function empty() {
var task;

while (task = this.taskQueue.shift()) {
task.p.reject();
}
}
}, {
key: "currentTask",
get: function get() {
return this.taskQueue[0];
}
}]);

return SourceBufferQueue;
}();

/* harmony default export */ var source_buffer_queue = (source_buffer_queue_SourceBufferQueue);
// CONCATENATED MODULE: ./src/renderer/dash/source-buffer.js



function SourceBuffer(mediaSource, mimeType) {
var sourceBuffer = mediaSource.addSourceBuffer(mimeType);
var sourceBufferQueue = new source_buffer_queue(sourceBuffer);
sourceBuffer.mimeType = mimeType;
sourceBuffer.addEventListener(UPDATE_END, onUpdateEnd);
sourceBuffer.addEventListener(ERROR, onUpdateError);
sourceBuffer.addEventListener(ABORT, onUpdateError);

function appendBuffer(segment) {
sourceBuffer.appendBuffer(segment.data);
return segment;
}

function remove() {
var start = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
var stop = arguments.length > 1 ? arguments[1] : undefined;
sourceBuffer.remove(start, stop || mediaSource.duration || Number.MAX_VALUE);
}

function abort() {
var _sourceBufferQueue$cu;

var isRemoveInProgress = (_sourceBufferQueue$cu = sourceBufferQueue.currentTask) === null || _sourceBufferQueue$cu === void 0 ? void 0 : _sourceBufferQueue$cu.fn.toString().includes('remove'); // Note: Using SourceBuffer.abort() to abort remove()'s asynchronous range removal is deprecated

if (isRemoveInProgress) {
return;
}

try {
sourceBuffer.abort();
} catch (e) {}
}

function setTimestampOffset(offset) {
sourceBuffer.timestampOffset = offset; // synchronous operation - fake updateend to resolve task

onUpdateEnd();
}

function setAppendWindow(start, stop) {
sourceBuffer.appendWindowStart = 0;
sourceBuffer.appendWindowEnd = stop;
sourceBuffer.appendWindowStart = start; // synchronous operation - fake updateend to resolve task

onUpdateEnd();
}

function getAppendWindow() {
var appendWindowStart = sourceBuffer.appendWindowStart,
appendWindowEnd = sourceBuffer.appendWindowEnd;
return {
appendWindowStart: appendWindowStart,
appendWindowEnd: appendWindowEnd
};
}

function getBufferLength(time) {
var range = getBufferRange(time);
return range ? range.end - time : 0;
}

function getBufferRange(time) {
var ranges = getBuffered() || [];

for (var i = 0; i < ranges.length; i++) {
var start = ranges.start(i);
var end = ranges.end(i);

if (time >= start && time < end) {
return {
start: start,
end: end
};
}
}

return null;
}

function getBufferRanges() {
var buffered = getBuffered() || [];
var ranges = [];

for (var i = 0; i < buffered.length; i++) {
var start = buffered.start(i);
var end = buffered.end(i);
ranges.push({
start: start,
end: end
});
}

return ranges;
}

function getBuffered() {
try {
return sourceBuffer.buffered;
} catch (e) {}
}

function queue(callback) {
return sourceBufferQueue.addTask(callback);
}

function onUpdateEnd() {
sourceBufferQueue.onSuccess();
}

function onUpdateError(e) {
sourceBufferQueue.onError(e);
}

function destroy() {
sourceBuffer.removeEventListener(UPDATE_END, onUpdateEnd);
sourceBuffer.removeEventListener(ERROR, onUpdateError);
sourceBuffer.removeEventListener(ABORT, onUpdateError);
sourceBufferQueue.empty();
}

return {
abort: abort,
appendBuffer: appendBuffer,
destroy: destroy,
getBufferRange: getBufferRange,
getBufferRanges: getBufferRanges,
getBufferLength: getBufferLength,
getAppendWindow: getAppendWindow,
queue: queue,
remove: remove,
setAppendWindow: setAppendWindow,
setTimestampOffset: setTimestampOffset
};
}

/* harmony default export */ var source_buffer = (SourceBuffer);
// EXTERNAL MODULE: ./src/renderer/dash/segment.js
var dash_segment = __webpack_require__(44);

// CONCATENATED MODULE: ./src/renderer/dash/enum/media-source-state.js
var CLOSED = 'closed';
var ENDED = 'ended';
var OPEN = 'open';
// CONCATENATED MODULE: ./src/renderer/dash/stream.js














var APPEND_WINDOW_START_FUDGE_FACTOR = 1;
var APPEND_WINDOW_END_FUDGE_FACTOR = .5;
var DEFAULT_SEGMENT_DURATION = 2; //[s]

var MAX_BUFFER = 120; //[s]

var MAX_BUFFER_DECREASE_BY_AFTER_QUOTA_EXCEEDED_ERROR = 5; //[s]

var MIN_DOWNLOAD_SPEED_MULTIPLIER = 1.25;
var MIN_REASONABLE_BUFFER_LENGTH = 10; //[s]

var UPDATE_INTERVAL = 500;
var SEGMENT_MARGIN = 0.1;
var QUOTA_EXCEEDED_ERROR_CODE = 22;
Stream.prototype = Object.create(event_emitter["a" /* default */].prototype);
function Stream(player, mediaType, mimeType) {
var ctx = this;
var segmentLogger = logger["a" /* default */].get("".concat(mediaType, "-stream"));
var manifest = player.getComponent(player_component["c" /* MANIFEST_MANAGER */]);
var mediaElement = player.getComponent(player_component["d" /* MEDIA_ELEMENT */]);
var mediaSource = player.getComponent(player_component["e" /* MEDIA_SOURCE */]);
var isSwitching = false;
var isImmediatelySwitching = false;
var switchingTime = -1;
var _isEndOfStream = false;
var sourceBuffer = null;
var started = false;
var playStarted = false;
var startTime = 0;
var paused = false;
var maxBufferLength = manifest.maxBufferLength;
var segmentManager = new dash_segment["a" /* default */](player, mediaType, getCurrentTimeAndBufferLength);
segmentManager.on(dash_event["d" /* FAILED_TO_DOWNLOAD_SEGMENT */], function (metric, xhr) {
ctx.trigger(dash_event["d" /* FAILED_TO_DOWNLOAD_SEGMENT */], metric, xhr);
});
segmentManager.on(dash_event["g" /* SEGMENT_DOWNLOADED */], function (metric) {
update();
ctx.trigger(dash_event["g" /* SEGMENT_DOWNLOADED */], metric);
});

if (mediaType === media_type["a" /* default */].AUDIO) {
segmentManager.on(dash_event["a" /* ADAPTATION_CHANGED */], function (adaptation) {
ctx.trigger(player_event["e" /* AUDIO_TRACK_CHANGED */], adaptation);
});
}

if (mediaType === media_type["a" /* default */].VIDEO) {
segmentManager.on(dash_event["h" /* SEGMENT_DOWNLOAD_PROGRESS */], function (info) {
ctx.trigger(dash_event["h" /* SEGMENT_DOWNLOAD_PROGRESS */], info);
});
segmentManager.on(dash_event["e" /* REPRESENTATION_CHANGED */], function (representation) {
ctx.trigger(player_event["W" /* PROFILE_CHANGING */], representation);
});
segmentManager.on(player_event["J" /* PERIOD_CHANGING */], function (period) {
player.trigger(player_event["J" /* PERIOD_CHANGING */], period);
});
}

player.once(player_event["O" /* PLAYING */], function () {
playStarted = true;
});
var timer = new util_timer["a" /* default */](UPDATE_INTERVAL, update);

function init() {
sourceBuffer = createSourceBuffer();
timer.start();
segmentManager.start();
}

function getAdaptation() {
return segmentManager.getAdaptation();
}

function abort() {
segmentManager.abort();
}

function getCurrentTimeAndBufferLength() {
var time = mediaElement.getReadyState() === media_ready_state.HAVE_NOTHING ? startTime : mediaElement.getCurrentTime();
var bufferLength = sourceBuffer.getBufferLength(time);
return {
time: time,
bufferLength: bufferLength
};
}

function update() {
return _update.apply(this, arguments);
}

function _update() {
_update = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee() {
var _getCurrentTimeAndBuf, time, bufferLength, duration, queueLength, minBuffer, maxBuffer, _switchingTime, _segmentManager$getQu, _segmentManager$getQu2, segment, result, info, ranges, queue, idx;

return regenerator_default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!(sourceBuffer === null || paused)) {
_context.next = 2;
break;
}

return _context.abrupt("return");

case 2:
_getCurrentTimeAndBuf = getCurrentTimeAndBufferLength(), time = _getCurrentTimeAndBuf.time, bufferLength = _getCurrentTimeAndBuf.bufferLength;
duration = mediaElement.getDuration();
queueLength = segmentManager.getQueueLengthFromTime(time);
detectEndOfStream();

if (queueLength + bufferLength > maxBufferLength) {
segmentManager.pause();
} else {
segmentManager.resume();
}

segmentManager.next();
minBuffer = getMinBuffer(time);
maxBuffer = Math.min(maxBufferLength, MAX_BUFFER);

if (!(minBuffer >= queueLength && time + queueLength < duration - SEGMENT_MARGIN && mediaType === media_type["a" /* default */].VIDEO)) {
_context.next = 12;
break;
}

return _context.abrupt("return");

case 12:
started = true;

if (!(isSwitching && switchingTime >= 0 && time + 1 > switchingTime && mediaType === media_type["a" /* default */].VIDEO)) {
_context.next = 22;
break;
}

isSwitching = false;
_isEndOfStream = false;
_switchingTime = switchingTime - 4;

if (!(_switchingTime > 0)) {
_context.next = 20;
break;
}

_context.next = 20;
return clearBuffer(0, _switchingTime);

case 20:
switchingTime = -1;
return _context.abrupt("return");

case 22:
_segmentManager$getQu = segmentManager.getQueue(), _segmentManager$getQu2 = slicedToArray_default()(_segmentManager$getQu, 1), segment = _segmentManager$getQu2[0];

if (!(segment && bufferLength < maxBuffer)) {
_context.next = 30;
break;
}

if (mediaType === media_type["a" /* default */].VIDEO && isSwitching && segment.index >= 0 && switchingTime === -1) {
switchingTime = segment.start;
}

if (segment.index === -1) {
sourceBuffer.queue(function () {
return sourceBuffer.setTimestampOffset(segment.offset);
})["catch"](function () {});
sourceBuffer.queue(function () {
return sourceBuffer.setAppendWindow(Math.max(0, segment.appendWindowStart - APPEND_WINDOW_START_FUDGE_FACTOR), segment.appendWindowEnd + APPEND_WINDOW_END_FUDGE_FACTOR);
}).then(function () {
var _sourceBuffer$getAppe = sourceBuffer.getAppendWindow(),
appendWindowStart = _sourceBuffer$getAppe.appendWindowStart,
appendWindowEnd = _sourceBuffer$getAppe.appendWindowEnd;

segmentLogger.info("[".concat(mediaElement.getCurrentTime(), "] APPEND WINDOW: start: ").concat(appendWindowStart, ", end: ").concat(appendWindowEnd, ", offset: ").concat(segment.offset));
})["catch"](function () {});
}

_context.next = 28;
return sourceBuffer.queue(function () {
return sourceBuffer.appendBuffer(segment);
})["catch"](function () {
var error = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

var _ref = (segment === null || segment === void 0 ? void 0 : segment.segmentInfo) || {},
index = _ref.index,
start = _ref.start,
representationId = _ref.representationId,
periodId = _ref.periodId;

var info = "[".concat(mediaElement.getCurrentTime(), "] ERROR APPEND ").concat(mediaType === null || mediaType === void 0 ? void 0 : mediaType.toUpperCase());
info += " ".concat(index, ", ").concat(start, ", ").concat(representationId, " ").concat(periodId, ", ERROR: ").concat(error.code, ", ").concat(error.message);
segmentLogger.error(info);

if (error.code === QUOTA_EXCEEDED_ERROR_CODE) {
maxBufferLength = Math.max(MIN_REASONABLE_BUFFER_LENGTH, maxBufferLength - MAX_BUFFER_DECREASE_BY_AFTER_QUOTA_EXCEEDED_ERROR);
} else {
segmentManager.restart();
}

return false;
});

case 28:
result = _context.sent;

if (result) {
if (mediaType === media_type["a" /* default */].VIDEO) {
ctx.trigger(dash_event["f" /* SEGMENT_APPENDED */], segment);
}

info = "APPENDED SEGMENT [".concat(segment.representationId, "]:");
info += " id: ".concat(segment.index, ", ");

if (segment.index >= 0) {
info += "start: ".concat(segment.start, ", ");
info += "end: ".concat(segment.start + segment.duration, ", ");
info += "duration: ".concat(segment.duration, ", ");
}

info += "bandwidth: ".concat((segment.bandwidth / 1000).toFixed(0));
segmentLogger.info("[".concat(mediaElement.getCurrentTime(), "] ").concat(info));
ranges = sourceBuffer.getBufferRanges().reduce(function (acc, _ref2) {
var start = _ref2.start,
end = _ref2.end;
acc += " | ".concat(start, " - ").concat(end, " ");
return acc;
}, '');
segmentLogger.info("[".concat(mediaElement.getCurrentTime(), "] BUFFER RANGES: ").concat(ranges));

if (segment.index >= 0 && isImmediatelySwitching) {
sync();
isImmediatelySwitching = false;
}

queue = segmentManager.getQueue();
idx = queue.indexOf(segment);

if (idx >= 0) {
queue.splice(idx, 1);
}

if (!manifest.isLive() && segmentManager.isLastSegment(segment)) {
signalEndOfStream();
}

update();
}

case 30:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _update.apply(this, arguments);
}

function getMinBuffer(time) {
var minBuffer = manifest.minBufferTime;

if (!playStarted) {
var _segmentManager$getRe;

if (!isNaN(manifest.startBufferLength)) {
minBuffer = manifest.startBufferLength;
}

var downloadSpeed = player.getDownloadSpeed();
var bandwidth = (_segmentManager$getRe = segmentManager.getRepresentation()) === null || _segmentManager$getRe === void 0 ? void 0 : _segmentManager$getRe.bandwidth;

if (bandwidth && downloadSpeed > 0 && downloadSpeed * MIN_DOWNLOAD_SPEED_MULTIPLIER < bandwidth) {
var _segmentManager$findS;

minBuffer = ((_segmentManager$findS = segmentManager.findSegmentByPosition(time)) === null || _segmentManager$findS === void 0 ? void 0 : _segmentManager$findS.duration) || DEFAULT_SEGMENT_DURATION;
}
}

return minBuffer;
}

function pause() {
paused = true;
}

function resume() {
paused = false;
}

function stop() {
isSwitching = false;
timer.stop();
abort();
mediaSource.endOfStream();
segmentManager.stop();

if (sourceBuffer !== null) {
if (mediaSource.getReadyState() === OPEN) {
sourceBuffer.abort();
}

sourceBuffer.destroy();
sourceBuffer = null;
}
}

function switchTrack(_x) {
return _switchTrack.apply(this, arguments);
}

function _switchTrack() {
_switchTrack = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee2(adaptation) {
var immediately,
_args2 = arguments;
return regenerator_default.a.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
immediately = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : false;

if (!adaptation) {
_context2.next = 7;
break;
}

isImmediatelySwitching = immediately;
segmentManager.setAdaptation(adaptation, !!sourceBuffer);
_context2.next = 6;
return clearBuffer(0);

case 6:
ctx.trigger(player_event["e" /* AUDIO_TRACK_CHANGED */], adaptation);

case 7:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
return _switchTrack.apply(this, arguments);
}

function switchProfile(_x2, _x3) {
return _switchProfile.apply(this, arguments);
}

function _switchProfile() {
_switchProfile = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee3(bandwidth, fastSwitch) {
var immediately,
next,
_args3 = arguments;
return regenerator_default.a.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
immediately = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : false;

if (!(bandwidth === segmentManager.getBandwidth())) {
_context3.next = 3;
break;
}

return _context3.abrupt("return");

case 3:
isSwitching = false;
segmentManager.switchProfile(bandwidth, !!sourceBuffer);

if (!(fastSwitch && sourceBuffer !== null)) {
_context3.next = 19;
break;
}

switchingTime = -1;
sourceBuffer.abort();

if (!immediately) {
_context3.next = 14;
break;
}

_context3.next = 11;
return clearBuffer();

case 11:
isImmediatelySwitching = true;
_context3.next = 19;
break;

case 14:
isSwitching = true;
next = segmentManager.getNextSegmentToSwitch(mediaElement.getCurrentTime());

if (!(next !== null)) {
_context3.next = 19;
break;
}

_context3.next = 19;
return clearBuffer(Math.max(next.start, 5) - SEGMENT_MARGIN);

case 19:
case "end":
return _context3.stop();
}
}
}, _callee3);
}));
return _switchProfile.apply(this, arguments);
}

function detectEndOfStream() {
if (manifest.isLive() || mediaSource.getReadyState() !== OPEN) {
return;
}

var segments = segmentManager.getAllSegments();

if (segments) {
var lastSegment = segments[segments.length - 1];
var currentTime = mediaElement.getCurrentTime();
var lastPeriod = manifest.getLastPeriod();

if (currentTime > (lastSegment === null || lastSegment === void 0 ? void 0 : lastSegment.start) && manifest.findPeriodByTime(currentTime) === lastPeriod && segmentManager.getPeriod() === lastPeriod) {
signalEndOfStream();
}
}
}

function signalEndOfStream() {
_isEndOfStream = true;
ctx.trigger(dash_event["b" /* END_OF_STREAM */]);
}

function clearBuffer(start, end) {
if (!sourceBuffer || end < start) {
return Promise.resolve();
}

if (mediaSource.getReadyState() === OPEN) {
sourceBuffer.abort();
}

return sourceBuffer.queue(function () {
return sourceBuffer.remove(start, end);
}).then(function () {
ctx.trigger(dash_event["i" /* SOURCE_BUFFER_CLEARED */], start, end);
segmentLogger.info("[".concat(mediaElement.getCurrentTime(), "] CLEAR BUFFER: ").concat(start, " - ").concat(end || 'Infinity'));
})["catch"](function () {});
}

function sync() {
mediaElement.seek(mediaElement.getCurrentTime() - 0.05);
}

function isEndOfStream() {
return _isEndOfStream;
}

function endOfStream(value) {
_isEndOfStream = value;
}

function isStreamStarted() {
return started;
}

function isProcessingRequest() {
return segmentManager.isProcessingRequest();
}

function setStartTime(_startTime) {
startTime = _startTime;
}

function setMaxBufferLength(length) {
manifest.maxBufferLength = length;
}

function updatePosition(time) {
startTime = time;
segmentManager.update();
update();
}

function getRepresentations() {
var _segmentManager$getAd;

return (_segmentManager$getAd = segmentManager.getAdaptation()) === null || _segmentManager$getAd === void 0 ? void 0 : _segmentManager$getAd.representations;
}

function getRepresentation() {
return segmentManager.getRepresentation();
}

function findSegmentByPosition(position) {
return segmentManager.findSegmentByPosition(position);
}

function getNearestSegmentPosition(position) {
var segment = findSegmentByPosition(position);

if (segment !== null) {
return segment.start;
}

return -1;
}

function sourceOpen() {
_isEndOfStream = false;
}

function createSourceBuffer() {
return new source_buffer(mediaSource, mimeType);
}

function getMediaType() {
return mediaType;
}

function getSegmentManager() {
return segmentManager;
}

return {
on: ctx.on.bind(ctx),
off: ctx.off.bind(ctx),
trigger: ctx.trigger.bind(ctx),
init: init,
abort: abort,
update: update,
pause: pause,
resume: resume,
stop: stop,
clearBuffer: clearBuffer,
getAdaptation: getAdaptation,
findSegmentByPosition: findSegmentByPosition,
getNearestSegmentPosition: getNearestSegmentPosition,
setStartTime: setStartTime,
isStreamStarted: isStreamStarted,
isProcessingRequest: isProcessingRequest,
switchProfile: switchProfile,
updatePosition: updatePosition,
switchTrack: switchTrack,
setMaxBufferLength: setMaxBufferLength,
getRepresentation: getRepresentation,
getRepresentations: getRepresentations,
sourceOpen: sourceOpen,
isEndOfStream: isEndOfStream,
endOfStream: endOfStream,
getMediaType: getMediaType,
getSegmentManager: getSegmentManager
};
}
// CONCATENATED MODULE: ./src/renderer/dash/stream-observer.js







function stream_observer_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (stream_observer_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function stream_observer_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }









var BUFFER_START_GAP = browser["a" /* default */].isTizen() ? 0.1 : 0;
var MICRO_SEEK_AFTER_DECODING_PROBLEM_TIMEOUT = 3000;
var MAX_NEXT_BUFFER_RANGE_DISTANCE = 2; //[s]

var MICRO_SEEK_VALUE = 0.1; //[s]

var MONITOR_INTERVAL = 250; //[ms]

var RECONNECT_TIMEOUT = 3000; //[ms]

var stream_observer_StreamObserver = /*#__PURE__*/function (_EventEmitter) {
inherits_default()(StreamObserver, _EventEmitter);

var _super = stream_observer_createSuper(StreamObserver);

function StreamObserver(player) {
var _this;

classCallCheck_default()(this, StreamObserver);

_this = _super.call(this, player);
_this.player = player;
_this.options = player.options;
_this.timeShift = player.timeShift;
_this.mediaElement = player.getComponent(player_component["d" /* MEDIA_ELEMENT */]);
_this.manifestManager = player.getComponent(player_component["c" /* MANIFEST_MANAGER */]);
_this.streamManager = null;
player.addComponent(assertThisInitialized_default()(_this), player_component["h" /* STREAM_MANAGER */]);
_this.isLive = false;
_this.liveDelay = 0;
_this.lastPosition = -1;
_this.deadlockTimeout = 0;
_this.decodedFrameCount = -1;
_this.frameDeadlockTimeout = null;
_this.hasFrameDeadlockTimeout = false;
_this.hasDeadlockTimeout = false;
_this.metric = {};
_this.segmentList = [];
_this.lastProfile = null;
_this.timer = new util_timer["a" /* default */](MONITOR_INTERVAL, function () {
return _this.monitor();
});

_this.player.on(player_event["l" /* DESTROY */], function () {
return _this.destroy();
});

_this.player.on(player_event["ib" /* STOPPED */], function () {
return _this.destroy();
});

_this.player.on(player_event["o" /* ERROR */], function () {
return _this.destroy();
});

_this.player.on(player_event["zb" /* WAITING */], function () {
return _this.seekToNextBufferRangeStart();
});

return _this;
}

createClass_default()(StreamObserver, [{
key: "observe",
value: function observe() {
var _this2 = this;

this.destroy();
this.isLive = this.manifestManager.isLive();
this.timer.start();
this.streamManager = this.player.getComponent(player_component["h" /* STREAM_MANAGER */]);
var videoStream = this.streamManager.getVideoStream();

if (videoStream) {
videoStream.on(dash_event["f" /* SEGMENT_APPENDED */], function (segment) {
return _this2.onSegmentAppended(segment);
});
videoStream.on(dash_event["i" /* SOURCE_BUFFER_CLEARED */], function (start, end) {
return _this2.onSourceBufferCleared(start, end);
});
}

if (this.isLive) {
this.liveDelay = this.manifestManager.getLiveDelay();
}
}
}, {
key: "seekToNextBufferRangeStart",
value: function seekToNextBufferRangeStart() {
var _this$mediaElement$ge;

var currentTime = this.mediaElement.getCurrentTime();
var playerStarted = (_this$mediaElement$ge = this.mediaElement.getPlayed()) === null || _this$mediaElement$ge === void 0 ? void 0 : _this$mediaElement$ge.length;
var bufferRangeEnd = playerStarted ? currentTime + MAX_NEXT_BUFFER_RANGE_DISTANCE : Number.MAX_SAFE_INTEGER;

if (this.mediaElement.hasBuffered()) {
var buffer = this.mediaElement.getBufferRange(currentTime, bufferRangeEnd);

if (buffer && buffer.start !== currentTime) {
this.mediaElement.seek(buffer.start + BUFFER_START_GAP);
}
}
}
}, {
key: "monitor",
value: function monitor() {
var _this$mediaElement$ge2,
_this3 = this;

var streamStartTime = this.streamManager.getStartTime();
var isProcessingRequest = this.streamManager.isProcessingRequest();
var currentTime = this.mediaElement.getCurrentTime();
var bufferLength = this.mediaElement.getBufferLengthFromTime(currentTime);
var readyState = this.mediaElement.getReadyState();
var playerStarted = (_this$mediaElement$ge2 = this.mediaElement.getPlayed()) === null || _this$mediaElement$ge2 === void 0 ? void 0 : _this$mediaElement$ge2.length;
var now = Date.now();
var isStreamStarted = this.streamManager.isStreamsStarted();
this.detectProfileChange(currentTime); // Fix problem with initial currentTime in SmartTV

if (this.options.get(option_name["xb" /* SMART_TV */]) && isStreamStarted && !playerStarted && currentTime === 0 && streamStartTime > 0) {
this.mediaElement.seek(streamStartTime);
}

if (bufferLength === 0 && readyState <= media_ready_state.HAVE_CURRENT_DATA) {
var manifestStartTime = this.manifestManager.getStartTime();

if (playerStarted && this.timeShift.isEnabled() && currentTime < manifestStartTime) {
this.mediaElement.seek(manifestStartTime);
} else {
this.seekToNextBufferRangeStart();
}
}

if (this.mediaElement.isPaused()) {
this.hasFrameDeadlockTimeout = false;
clearTimeout(this.frameDeadlockTimeout);
return;
}

if (readyState === media_ready_state.bufferLength && bufferLength < MAX_NEXT_BUFFER_RANGE_DISTANCE) {
this.seekToNextBufferRangeStart();
}

if (readyState === media_ready_state.HAVE_METADATA && streamStartTime > currentTime && Math.abs(streamStartTime - currentTime) < 2) {
this.mediaElement.seek(streamStartTime);
}

var decodedFrames = this.mediaElement.getDecodedFrameCount();

if (decodedFrames < this.decodedFrameCount) {
decodedFrames = this.decodedFrameCount;
}

if (bufferLength > 0 && this.decodedFrameCount >= 0 && decodedFrames === this.decodedFrameCount && !document.hidden) {
if (!this.hasFrameDeadlockTimeout) {
var timeout = MICRO_SEEK_AFTER_DECODING_PROBLEM_TIMEOUT;

if (this.options.get(option_name["xb" /* SMART_TV */])) {
timeout += MICRO_SEEK_AFTER_DECODING_PROBLEM_TIMEOUT;
}

this.decodedFrameCount = decodedFrames;
this.hasFrameDeadlockTimeout = true;
this.frameDeadlockTimeout = setTimeout(function () {
_this3.hasFrameDeadlockTimeout = false;

_this3.mediaElement.seek(_this3.mediaElement.getCurrentTime() + MICRO_SEEK_VALUE);
}, timeout);
}
} else {
this.hasFrameDeadlockTimeout = false;
clearTimeout(this.frameDeadlockTimeout);
}

if (readyState > media_ready_state.HAVE_METADATA && !isProcessingRequest && (this.lastPosition > 0 && this.lastPosition === currentTime || bufferLength === 0)) {
var range = this.mediaElement.getBufferRange(currentTime);

if (range !== null && currentTime + 5 > range.start) {
this.mediaElement.seek(range.start + 0.00001);
} else if (!this.hasDeadlockTimeout && this.isLive) {
this.hasDeadlockTimeout = true;
this.deadlockTimeout = setTimeout(function () {
var _this3$streamManager;

(_this3$streamManager = _this3.streamManager) === null || _this3$streamManager === void 0 ? void 0 : _this3$streamManager.reconnect(0);
_this3.hasDeadlockTimeout = false;
}, RECONNECT_TIMEOUT);
}
} else {
clearTimeout(this.deadlockTimeout);
this.hasDeadlockTimeout = false;
this.decodedFrameCount = decodedFrames;
}

if (readyState <= media_ready_state.HAVE_CURRENT_DATA) {
if (this.metric.time !== currentTime || this.metric.bufferLength !== bufferLength || this.metric.decodedFrameCount !== decodedFrames) {
this.metric.lastChange = now;
this.metric.time = currentTime;
this.metric.bufferLength = bufferLength;
this.metric.decodedFrameCount = decodedFrames;
} else {
var diff = (now - this.metric.lastChange) / 1000;

if (diff > 2 && isStreamStarted) {
this.metric.lastChange = now;

if (bufferLength > 0) {
var _this$streamManager$g;

var _ref = ((_this$streamManager$g = this.streamManager.getVideoStream()) === null || _this$streamManager$g === void 0 ? void 0 : _this$streamManager$g.findSegmentByPosition(currentTime)) || {},
start = _ref.start,
duration = _ref.duration;

if (start && duration) {
this.mediaElement.seek(start + duration);
}
}
}
}
}

this.lastPosition = currentTime;
}
}, {
key: "onSegmentAppended",
value: function onSegmentAppended(_ref2) {
var index = _ref2.index,
representation = _ref2.representation,
start = _ref2.start,
duration = _ref2.duration;

if (index < 0) {
return;
}

var stop = start + duration;
var segment = this.segmentList.find(function (info) {
return info.start === start;
});

if (segment) {
segment.representation = representation;
} else {
this.segmentList.push({
start: start,
stop: stop,
representation: representation
});
}
}
}, {
key: "onSourceBufferCleared",
value: function onSourceBufferCleared(start, end) {
this.segmentList = this.segmentList.reduce(function (acc, segment) {
if (start <= segment.start && end >= segment.stop) {
return acc;
}

acc.push(segment);
return acc;
}, []);
}
}, {
key: "detectProfileChange",
value: function detectProfileChange(time) {
var currentSegment = this.segmentList.find(function (_ref3) {
var start = _ref3.start,
stop = _ref3.stop;
return time >= start && time <= stop;
});

if (currentSegment) {
var representation = currentSegment.representation;
var bandwidth = representation.bandwidth;

if (bandwidth !== this.lastProfile) {
this.trigger(player_event["T" /* PROFILE_CHANGED */], representation);
}

this.lastProfile = bandwidth;
}
}
}, {
key: "destroy",
value: function destroy() {
clearTimeout(this.deadlockTimeout);
clearTimeout(this.frameDeadlockTimeout);
this.decodedFrameCount = -1;
this.lastPosition = 0;
this.hasDeadlockTimeout = false;
this.hasDeadlockTimeout = false;
this.hasFrameDeadlockTimeout = false;
this.timer.stop();
this.lastProfile = null;
this.segmentList = [];
}
}]);

return StreamObserver;
}(event_emitter["a" /* default */]);

/* harmony default export */ var stream_observer = (stream_observer_StreamObserver);
// CONCATENATED MODULE: ./src/renderer/dash/period-observer.js






var CHECK_INTERVAL = 500;

var serializePeriod = function serializePeriod(_ref) {
var id = _ref.id,
start = _ref.start,
end = _ref.end,
duration = _ref.duration;
return {
id: id,
start: start,
end: end,
duration: duration
};
};

var period_observer_PeriodObserver = /*#__PURE__*/function () {
function PeriodObserver(player) {
var _this = this;

classCallCheck_default()(this, PeriodObserver);

this.player = player;
this.currentPeriod = null;
this.manifestManager = player.getComponent(player_component["c" /* MANIFEST_MANAGER */]);
this.mediaElement = player.getComponent(player_component["d" /* MEDIA_ELEMENT */]);
this.logger = logger["a" /* default */].get("period");
this.timer = new util_timer["a" /* default */](CHECK_INTERVAL, function () {
return _this.onTimer();
}, true);
this.player.once(player_event["O" /* PLAYING */], function () {
return _this.init();
});
this.player.once(player_event["l" /* DESTROY */], function () {
return _this.timer.stop();
});
this.player.once(player_event["ib" /* STOPPED */], function () {
return _this.timer.stop();
});
this.player.once(player_event["o" /* ERROR */], function () {
return _this.timer.stop();
});
}

createClass_default()(PeriodObserver, [{
key: "init",
value: function init() {
this.timer.start();
}
}, {
key: "onTimer",
value: function onTimer() {
var _this$currentPeriod,
_this2 = this;

var currentTime = this.mediaElement.getCurrentTime();
var period = this.manifestManager.findPeriodByTime(currentTime);

if (this.currentPeriod !== period) {
if (this.currentPeriod) {
this.currentPeriod.off();
}

this.updatePeriod(period, currentTime);
}

if ((_this$currentPeriod = this.currentPeriod) === null || _this$currentPeriod === void 0 ? void 0 : _this$currentPeriod.eventStreams.length) {
var eventStreams = this.currentPeriod.eventStreams;
eventStreams.forEach(function (events) {
var event = events.find(function (_ref2) {
var start = _ref2.start;
return start >= currentTime;
});

if (event && (!event.fired || Math.abs(Date.now() - event.fired) > 2000)) {
_this2.player.trigger(player_event["kb" /* STREAM_EVENT */], event);

event.fired = Date.now();
}
});
}
}
}, {
key: "getCurrentPeriod",
value: function getCurrentPeriod() {
return serializePeriod(this.currentPeriod);
}
}, {
key: "updatePeriod",
value: function updatePeriod(period, time) {
var _this3 = this;

this.currentPeriod = period;
this.currentPeriod.on(player_event["K" /* PERIOD_UPDATED */], function (period) {
return _this3.player.trigger(player_event["K" /* PERIOD_UPDATED */], serializePeriod(period));
});
this.player.trigger(player_event["I" /* PERIOD */], serializePeriod(this.currentPeriod));
var _this$currentPeriod2 = this.currentPeriod,
id = _this$currentPeriod2.id,
start = _this$currentPeriod2.start,
duration = _this$currentPeriod2.duration;
this.logger.info("[".concat(time, "] PERIOD CHANGED: ").concat(this.currentPeriod.id, " ").concat(id, ", ").concat(start, " ").concat(duration));
}
}]);

return PeriodObserver;
}();

/* harmony default export */ var period_observer = (period_observer_PeriodObserver);
// CONCATENATED MODULE: ./src/renderer/dash/stream-manager.js



function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

















var BITS_IN_MBPS = 1000000;
var FLUSH_BUFFER_INTERVAL = 5000;
StreamManager.prototype = Object.create(event_emitter["a" /* default */].prototype);
function StreamManager(player) {
var ctx = this;
var mediaElement = player.getComponent(player_component["d" /* MEDIA_ELEMENT */]);
var manifest = player.getComponent(player_component["c" /* MANIFEST_MANAGER */]);
var timeShift = player.timeShift;
var options = player.options;
var seekPrecision = options.get(option_name["pb" /* SEEK_PRECISION */]);
var periodObserver = new period_observer(player);
var streamObserver = new stream_observer(player);
var flushTimer = new util_timer["a" /* default */](FLUSH_BUFFER_INTERVAL, flushBuffer);
var mediaSource = null;
var isLive = false;
var startTime = 0;
var activeStreams = [];
var videoStream = null;
var audioStream = null;
var selectedAudioLang = null;
var _isReconnecting = false;
flushTimer.immediateUpdate = false;
streamObserver.on(player_event["T" /* PROFILE_CHANGED */], function (profile) {
return onProfileChanged(profile);
});

function flushBuffer() {
var bufferBehind = options.get(option_name["m" /* BUFFER_BEHIND */]);

if (bufferBehind && !mediaElement.isSeeking()) {
var removeBefore = mediaElement.getCurrentTime() - bufferBehind;

if (removeBefore > 0) {
clearBuffer(0, removeBefore);
}
}
}

function createStreams(_mediaSource, _isLive) {
mediaSource = _mediaSource;
isLive = _isLive;
_isReconnecting = false;
var audioMimeType = manifest.getAdaptationSetMimeType(media_type["a" /* default */].AUDIO);
var videoMimeType = manifest.getAdaptationSetMimeType(media_type["a" /* default */].VIDEO);

if (audioMimeType) {
var defaultAudioLanguage = options.get(option_name["u" /* DEFAULT_AUDIO_LANGUAGE */]);
audioStream = createStream(media_type["a" /* default */].AUDIO, audioMimeType);
activeStreams.push(audioStream);
var language = selectedAudioLang || defaultAudioLanguage || browser["a" /* default */].getLanguage();
switchAudioTrack(language);
}

if (videoMimeType) {
videoStream = createStream(media_type["a" /* default */].VIDEO, videoMimeType);
activeStreams.push(videoStream);
}

startTime = calculateStartTime();

if (videoMimeType) {
var period = manifest.findPeriodByTime(startTime);
var videoAdaptation = manifest.getAdaptationSetByType(media_type["a" /* default */].VIDEO, period);

var _ref = (videoAdaptation === null || videoAdaptation === void 0 ? void 0 : videoAdaptation.getRepresentation()) || {},
bandwidth = _ref.bandwidth;

var initialBitrate = getInitialBitrate() || bandwidth;
switchProfile(initialBitrate);
ctx.trigger(player_event["T" /* PROFILE_CHANGED */], videoAdaptation === null || videoAdaptation === void 0 ? void 0 : videoAdaptation.getRepresentation(initialBitrate));
}

streamObserver.observe();
periodObserver.updatePeriod(manifest.findPeriodByTime(startTime), startTime);
}

function initStreams() {
activeStreams.forEach(function (stream) {
return stream.init();
});
flushTimer.start();
}

function createStream(mediaType, mimeType) {
var stream = new Stream(player, mediaType, mimeType);
stream.on(dash_event["b" /* END_OF_STREAM */], endOfStream);
stream.on(dash_event["h" /* SEGMENT_DOWNLOAD_PROGRESS */], function (downloadInfo) {
ctx.trigger(dash_event["h" /* SEGMENT_DOWNLOAD_PROGRESS */], downloadInfo);
});
stream.on(dash_event["g" /* SEGMENT_DOWNLOADED */], function (metric) {
sendMetric(metric);
});
stream.on(dash_event["d" /* FAILED_TO_DOWNLOAD_SEGMENT */], function (metric, xhr) {
if (_isReconnecting) {
return;
}

sendMetric(metric);

if (isLive && getBufferLength() < 1) {
reconnect(2000);
}

if (metric.status === http_status["b" /* FAILED */]) {
ctx.trigger(dash_event["d" /* FAILED_TO_DOWNLOAD_SEGMENT */], metric.url, xhr);
}
});
stream.on(player_event["e" /* AUDIO_TRACK_CHANGED */], function (_track) {
var track = createAudioTrackDTO(_track);
selectedAudioLang = track.lang;
player.trigger(player_event["e" /* AUDIO_TRACK_CHANGED */], track);
});
stream.on(player_event["W" /* PROFILE_CHANGING */], function (profile) {
return ctx.trigger(player_event["W" /* PROFILE_CHANGING */], profile);
});
return stream;
}

function getInitialBitrate() {
var _localStorage, _manifest$getAudioPro, _navigator, _navigator$connection;

var optionsBitrate = options.get(option_name["v" /* DEFAULT_BITRATE */]) * 1000;
var localStorageBitrate = options.get(option_name["S" /* LAST_BITRATE_CACHING */]) ? parseFloat((_localStorage = localStorage) === null || _localStorage === void 0 ? void 0 : _localStorage.getItem(BITRATE)) : 0;
var audioBitrate = ((_manifest$getAudioPro = manifest.getAudioProfiles()[0]) === null || _manifest$getAudioPro === void 0 ? void 0 : _manifest$getAudioPro.bandwidth) || 0;
var downlinkBitrate = options.get(option_name["Lb" /* USE_DOWNLINK_BITRATE */]) ? ((_navigator = navigator) === null || _navigator === void 0 ? void 0 : (_navigator$connection = _navigator.connection) === null || _navigator$connection === void 0 ? void 0 : _navigator$connection.downlink) * BITS_IN_MBPS - audioBitrate : 0;
var bitrate = optionsBitrate || downlinkBitrate || localStorageBitrate;
return bitrate && manifest.getVideoNearestBandwidth(bitrate);
}

function sendMetric(metric) {
player.trigger(player_event["A" /* NETWORK_METRIC */], _objectSpread({}, metric, {
downloadingBitrate: metric.bps,
type: 'SEGMENT'
}));
}

function onProfileChanged(profile) {
ctx.trigger(player_event["T" /* PROFILE_CHANGED */], profile);
}

function switchProfile(bandwidth, forceSwitch, immediately) {
var _videoStream;

var period = manifest.findPeriodByTime(mediaElement.getCurrentTime());
var representation = manifest.getRepresentationByBandwidth(bandwidth, media_type["a" /* default */].VIDEO, period);
flushTimer.restart();
(_videoStream = videoStream) === null || _videoStream === void 0 ? void 0 : _videoStream.switchProfile(bandwidth, forceSwitch, immediately);
}

function switchAudioTrack(audioTrack, immediately) {
var period = manifest.findPeriodByTime(mediaElement.getCurrentTime());
var adaptation = manifest.getAudioAdaptation(audioTrack, period);
audioStream.switchTrack(adaptation, immediately);
}

function hasActiveStreams() {
return activeStreams.length;
}

function isReconnecting() {
return _isReconnecting;
}

function setReconnecting() {
_isReconnecting = true;
}

function sourceOpen() {
activeStreams.forEach(function (stream) {
return stream.endOfStream(false);
});
}

function endOfStream() {
var allStreamsEnded = activeStreams.every(function (stream) {
return stream.isEndOfStream();
});

if (mediaSource.getReadyState() === OPEN && allStreamsEnded) {
mediaSource.endOfStream();
}
}

function reconnect() {
var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2000;
ctx.trigger(player_event["Z" /* RECONNECT */], timeout);
}

function destroy() {
flushTimer.stop();
activeStreams.forEach(function (stream) {
stream.stop();
stream = null;
});
activeStreams = [];
}

function clearBuffer(start, stop) {
if (mediaSource.getReadyState() === OPEN) {
activeStreams.forEach(function (stream) {
return stream.clearBuffer(start, stop);
});
}
}

function seek(percentPosition) {
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : seekPrecision;
var duration = getDuration() - player.getLiveDelay();
var position = duration * percentPosition / 100;

if (position > duration) {
position = duration;
}

if (timeShift.isEnabled()) {
var manifestStartTime = manifest.getStartTime();
position = Math.max(manifestStartTime, player.getLiveStartUTC() + position - timeShift.getBaseTimeStamp());
}

if (precision !== 'time') {
position = videoStream.getNearestSegmentPosition(position);
}

if (percentPosition === 100 && timeShift.isEnabled()) {
timeShift.setLive();
flushTimer.restart();
startTime = calculateStartTime();
mediaElement.seek(startTime);
return;
}

if (position >= 0) {
mediaElement.seek(position);
}
}

function seekToHead() {
mediaElement.seek(calculateHeadTime());
}

function updatePosition(time) {
activeStreams.forEach(function (stream) {
return stream.updatePosition(time);
});
}

function getDuration() {
if (timeShift.getDvrWindow() >= 0) {
return timeShift.getDvrWindow();
}

if (timeShift.getStart() >= 0 && timeShift.getStop() < 0) {
if (timeShift.getLiveNowUTC() < 0) {
return 0;
}

return timeShift.getLiveNowUTC() - timeShift.getStart();
}

if (timeShift.getStart() >= 0 && timeShift.getStop() >= 0) {
return timeShift.getStop() - timeShift.getStart();
}

if (!mediaElement) {
return 0;
}

return mediaElement.getDuration();
}

function getCurrentTime() {
var currentTime = (mediaElement === null || mediaElement === void 0 ? void 0 : mediaElement.getCurrentTime()) || 0;

if (currentTime === 0) {
return currentTime;
}

if (timeShift.isEnabled() && timeShift.isVod()) {
return currentTime;
}

if (isLive && !timeShift.isEnabled() && currentTime > 0) {
return currentTime + timeShift.getAvailabilityStartTime();
}

if (isLive && timeShift.isEnabled()) {
return timeShift.getBaseTimeStamp() + currentTime - timeShift.getStart();
}

return currentTime;
}

function getBufferLength() {
return (mediaElement === null || mediaElement === void 0 ? void 0 : mediaElement.getBufferLength()) || 0;
}

function isStreamsStarted() {
return activeStreams.every(function (stream) {
return stream.isStreamStarted();
});
}

function isProcessingRequest() {
return activeStreams.every(function (stream) {
return !stream.isProcessingRequest();
});
}

function setMaxBufferLength(length) {
activeStreams.forEach(function (stream) {
return stream.setMaxBufferLength(length);
});
}

function getStartTime() {
return startTime;
}

function calculateStartTime() {
var customStartTime = options.get(option_name["Ab" /* START_TIME */]);
var startTime = 0;

if (customStartTime) {
options.set(option_name["Ab" /* START_TIME */], null);
return customStartTime;
}

if (isLive) {
startTime = calculateHeadTime();
activeStreams.forEach(function (stream) {
return stream.setStartTime(startTime);
});
} else {
var startTimes = [];
activeStreams.forEach(function (stream) {
var _manifest$getAdaptati = manifest.getAdaptations(stream.getMediaType()),
_manifest$getAdaptati2 = slicedToArray_default()(_manifest$getAdaptati, 1),
adaptation = _manifest$getAdaptati2[0];

var start = stream.getNearestSegmentPosition(adaptation.startTime);
stream.setStartTime(start);
startTimes.push(start);
});
startTime = Math.max.apply(Math, startTimes);
}

return Math.round(startTime * 1000) / 1000;
}

function calculateHeadTime() {
var startTime = 0;
var baseTimeStamp = timeShift.getBaseTimeStamp();
var manifestStartTime = manifest.getStartTime();
var manifestEndTime = manifest.getLastSegmentEndTimeByType(media_type["a" /* default */].VIDEO) || manifest.getLastSegmentEndTimeByType(media_type["a" /* default */].AUDIO);
var headTime = manifestEndTime - manifest.getLiveDelay();
var playStart = timeShift.getPlayStart() - baseTimeStamp;
var start = timeShift.getStart() - baseTimeStamp;
var delayOffset = player.getLiveNowUTC() - baseTimeStamp - manifestEndTime;
startTime = headTime;

if (delayOffset > 0) {
startTime += delayOffset;
}

if (timeShift.getMode() === timeshift["a" /* TimeShiftMode */].LIVE_DELAYED && playStart >= 0 && start <= playStart && headTime >= playStart) {
startTime = playStart - start;

if (timeShift.getDvrWindow() > 0) {
startTime = playStart;
}
}

return Math.max(manifestStartTime, startTime);
}

function getCurrentProfile() {
return videoStream.getRepresentation();
}

function getProfiles() {
return videoStream.getRepresentations();
}

function getCurrentPeriod() {
return periodObserver === null || periodObserver === void 0 ? void 0 : periodObserver.getCurrentPeriod();
}

function createAudioTrackDTO(track) {
return new audio_track["a" /* default */](track);
}

function getCurrentAudioTrack() {
return createAudioTrackDTO(audioStream.getAdaptation());
}

function getVideoStream() {
return videoStream;
}

function getAudioStream() {
return audioStream;
}

return {
on: ctx.on.bind(ctx),
off: ctx.off.bind(ctx),
trigger: ctx.trigger.bind(ctx),
getCurrentTime: getCurrentTime,
getDuration: getDuration,
destroy: destroy,
reconnect: reconnect,
initStreams: initStreams,
createStreams: createStreams,
hasActiveStreams: hasActiveStreams,
getBufferLength: getBufferLength,
getStartTime: getStartTime,
clearBuffer: clearBuffer,
updatePosition: updatePosition,
seek: seek,
seekToHead: seekToHead,
switchProfile: switchProfile,
getProfiles: getProfiles,
getCurrentProfile: getCurrentProfile,
getCurrentAudioTrack: getCurrentAudioTrack,
getCurrentPeriod: getCurrentPeriod,
setMaxBufferLength: setMaxBufferLength,
isReconnecting: isReconnecting,
isStreamsStarted: isStreamsStarted,
isProcessingRequest: isProcessingRequest,
setReconnecting: setReconnecting,
switchAudioTrack: switchAudioTrack,
sourceOpen: sourceOpen,
getAudioStream: getAudioStream,
getVideoStream: getVideoStream
};
}
// EXTERNAL MODULE: ./src/core/event/dom-event.js
var dom_event = __webpack_require__(6);

// EXTERNAL MODULE: ./src/core/model/media-element.js
var media_element = __webpack_require__(40);

// CONCATENATED MODULE: ./src/renderer/dash/abr.js







function abr_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (abr_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function abr_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }








var BUFFER_FUDGE_FACTOR = 2; //[s]

var MIN_BUFFER_TO_SWITCH = 2; //[s]

var abr_DEFAULT_SEGMENT_DURATION = 4; //[s]

var MAX_DOWNLOAD_DURATION = 3000; //[ms]

var MIN_SWITCH_INTERVAL = 5000; //[ms]

var BANDWIDTH_MULTIPLIER = 0.15;
var VOD_FAST_SWITCH_MULTIPLIER = 0.5;
var LIVE_FAST_SWITCH_MULTIPLIER = 0.7;
var SEGMENTS_TO_COMPARE = 4;
var UPDATE_TIMER = 500;
var CHECK_DROPPED_FRAMES_UPDATE_TIMER = 5000;

var getBandwidths = function getBandwidths(representations) {
var maxWidth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Number.MAX_SAFE_INTEGER;
var sortedRepresentations = representations.sort(function (a, b) {
return b.bandwidth - a.bandwidth;
});

if (!sortedRepresentations.length) {
return [];
}

var filteredRepresentations = sortedRepresentations.filter(function (_ref) {
var width = _ref.width;
return maxWidth >= (width || Number.MAX_SAFE_INTEGER);
});

if (!filteredRepresentations.length) {
filteredRepresentations = [sortedRepresentations[sortedRepresentations.length - 1]];
}

return filteredRepresentations.map(function (_ref2) {
var bandwidth = _ref2.bandwidth;
return bandwidth;
});
};

var abr_Abr = /*#__PURE__*/function (_EventEmitter) {
inherits_default()(Abr, _EventEmitter);

var _super = abr_createSuper(Abr);

function Abr(player) {
var _this;

classCallCheck_default()(this, Abr);

_this = _super.call(this, player);
_this.mediaElement = player.getComponent(player_component["d" /* MEDIA_ELEMENT */]);
_this.manifest = player.getComponent(player_component["c" /* MANIFEST_MANAGER */]);
_this.options = player.options;
_this.timer = new util_timer["a" /* default */](UPDATE_TIMER, function () {
return _this.update();
});
_this.droppedFramesTimer = new util_timer["a" /* default */](CHECK_DROPPED_FRAMES_UPDATE_TIMER, function () {
return _this.checkDroppedFrames();
});
_this.representations = _this.manifest.getVideoProfiles();
_this.opts = _this.options.get(option_name["i" /* AUTO_ADAPTATION */]);
_this.supportResolution = _this.opts[option_name["k" /* AUTO_ADAPTATION_BY_RESOLUTION */]];
_this.minimumBufferLength = _this.opts[option_name["l" /* AUTO_ADAPTATION_MINIMUM_BUFFER_LENGTH */]];
_this.metrics = [];
_this.representation = null;
_this.bandwidths = getBandwidths(_this.representations);
_this.minBandwidth = parseFloat(_this.manifest.minAutoBitrate) * 1000 || null;
_this.maxBandwidth = parseFloat(_this.manifest.maxAutoBitrate) * 1000 || Number.POSITIVE_INFINITY;
_this.lastSwitch = 0;
_this.droppedFrames = 0;
_this.droppedFramesTimeoutId = 0;
_this.multiplier = _this.manifest.isLive() ? LIVE_FAST_SWITCH_MULTIPLIER : VOD_FAST_SWITCH_MULTIPLIER;

_this.updateMaxBandwidthHandler = function () {
return _this.updateMaxBandwidth();
};

player.on(player_event["J" /* PERIOD_CHANGING */], function (period) {
return _this.onPeriodChanging(period);
});
player.on(player_event["W" /* PROFILE_CHANGING */], function (profile) {
return _this.onProfileChanging(profile);
});

if (_this.supportResolution) {
window.addEventListener(dom_event["k" /* RESIZE */], _this.updateMaxBandwidthHandler);

_this.updateMaxBandwidth();
}

_this.timer.start();

if (_this.options.get(option_name["p" /* CONSIDER_DROPPED_FRAMES */])) {
_this.droppedFramesTimer.start();
}

return _this;
}

createClass_default()(Abr, [{
key: "addMetric",
value: function addMetric(metric) {
if (this.representation === null) {
return;
}

if (this.bandwidths.length < 2) {
return;
}

this.metrics.push(metric);

if (this.metrics.length > 10) {
this.metrics.shift();
}

this.update();
}
}, {
key: "update",
value: function update() {
var now = Date.now();
var avgBps = this.calculateAvgBps();
var fastSwitch = false;
var targetBandwidth;

if (this.representation === null) {
return;
}

if (avgBps >= 0) {
targetBandwidth = this.getTargetBandwidth(avgBps);
var buffer = Object(media_element["c" /* getBufferLengthFromTime */])(this.mediaElement.getVideo(), this.mediaElement.getCurrentTime());
var _this$representation = this.representation,
bandwidth = _this$representation.bandwidth,
segmentTemplate = _this$representation.segmentTemplate;
var upwardChange = targetBandwidth > bandwidth;

if (targetBandwidth !== bandwidth) {
if (upwardChange && buffer < MIN_BUFFER_TO_SWITCH) {
this.lastSwitch = 0;
return;
}

var duration = segmentTemplate.duration,
timescale = segmentTemplate.timescale;
var segmentDuration = duration / timescale || 0;
var minimumDesirableBufferLength = this.minimumBufferLength || Math.max(segmentDuration, abr_DEFAULT_SEGMENT_DURATION) + BUFFER_FUDGE_FACTOR;

if (!upwardChange) {
this.lastSwitch = 0;

if (buffer > minimumDesirableBufferLength && bandwidth < this.maxBandwidth) {
return;
}
}

var minBandwidthToFastSwitch = avgBps - avgBps * this.multiplier;

if (now - this.lastSwitch > MIN_SWITCH_INTERVAL) {
if (upwardChange && minBandwidthToFastSwitch > targetBandwidth) {
fastSwitch = true;
}

if (!fastSwitch && upwardChange && buffer < minimumDesirableBufferLength) {
return;
}

this.change(targetBandwidth, fastSwitch);
}
}
}
}
}, {
key: "change",
value: function change(targetBandwidth, fastSwitch) {
this.trigger(player_event["V" /* PROFILE_CHANGE_REQUEST */], targetBandwidth, fastSwitch);
this.metrics = [];
this.lastSwitch = Date.now();
}
}, {
key: "calculateAvgBps",
value: function calculateAvgBps() {
if (this.metrics.length <= SEGMENTS_TO_COMPARE) {
var _this$metrics$slice$r = this.metrics.slice().reverse(),
_this$metrics$slice$r2 = slicedToArray_default()(_this$metrics$slice$r, 1),
metric = _this$metrics$slice$r2[0];

if (metric && Date.now() - metric.started > MAX_DOWNLOAD_DURATION) {
return metric.bps;
}

return -1;
}

return parseInt(this.metrics.slice(this.metrics.length - SEGMENTS_TO_COMPARE, this.metrics.length).reduce(function (acc, metric, index) {
return acc += metric.bps;
}, 0) / SEGMENTS_TO_COMPARE);
}
}, {
key: "getDownloadSpeed",
value: function getDownloadSpeed() {
var _this$metrics = slicedToArray_default()(this.metrics, 1),
metric = _this$metrics[0];

return metric === null || metric === void 0 ? void 0 : metric.bps;
}
}, {
key: "checkDroppedFrames",
value: function checkDroppedFrames() {
var _this2 = this;

var totalDropped = this.mediaElement.getDroppedFrameCount();
var dropped = totalDropped - this.droppedFrames;

if (dropped > 20) {
if (this.bandwidths.length > 1 && this.representation) {
var _this$bandwidths$slic = this.bandwidths.slice().reverse().slice(1);

var _this$bandwidths$slic2 = slicedToArray_default()(_this$bandwidths$slic, 1);

this.maxBandwidth = _this$bandwidths$slic2[0];

if (this.representation.bandwidth > this.maxBandwidth) {
this.change(this.maxBandwidth, true);
this.droppedFramesTimer.stop();
this.droppedFramesTimeoutId = setTimeout(function () {
_this2.droppedFramesTimer.start();
}, 10000);
}
}
}

this.droppedFrames = totalDropped;
}
}, {
key: "getTargetBandwidth",
value: function getTargetBandwidth(avgBps) {
var _this$bandwidths = slicedToArray_default()(this.bandwidths, 1),
targetBandwidth = _this$bandwidths[0];

avgBps = avgBps - avgBps * BANDWIDTH_MULTIPLIER;

if (this.minBandwidth && avgBps < this.minBandwidth) {
avgBps = this.minBandwidth;
}

if (this.maxBandwidth && avgBps > this.maxBandwidth) {
avgBps = this.maxBandwidth;
}

return this.bandwidths.find(function (bandwidth) {
return avgBps >= bandwidth;
}) || targetBandwidth;
}
}, {
key: "updateMaxBandwidth",
value: function updateMaxBandwidth() {
var _this3 = this;

setTimeout(function () {
var _getBandwidths = getBandwidths(_this3.representations, _this3.mediaElement.getWidth());

var _getBandwidths2 = slicedToArray_default()(_getBandwidths, 1);

_this3.maxBandwidth = _getBandwidths2[0];
}, 0);
}
}, {
key: "onPeriodChanging",
value: function onPeriodChanging(period) {
this.representations = this.manifest.getVideoProfiles(period);
this.bandwidths = getBandwidths(this.representations);

if (this.supportResolution) {
this.updateMaxBandwidth();
}
}
}, {
key: "onProfileChanging",
value: function onProfileChanging(profile) {
this.metrics = [];
this.representation = profile;
}
}, {
key: "destroy",
value: function destroy() {
var _this$timer, _this$droppedFramesTi;

(_this$timer = this.timer) === null || _this$timer === void 0 ? void 0 : _this$timer.stop();
(_this$droppedFramesTi = this.droppedFramesTimer) === null || _this$droppedFramesTi === void 0 ? void 0 : _this$droppedFramesTi.stop();
clearTimeout(this.droppedFramesTimeoutId);
window.removeEventListener(dom_event["k" /* RESIZE */], this.updateMaxBandwidthHandler);
this.metrics = [];
}
}]);

return Abr;
}(event_emitter["a" /* default */]);

/* harmony default export */ var abr = (abr_Abr);
// CONCATENATED MODULE: ./src/renderer/dash/media-source.js




MediaSourceManager.prototype = Object.create(event_emitter["a" /* default */].prototype);

function MediaSourceManager(mediaElement) {
var ctx = this;
var mediaSource = new window.MediaSource();
mediaSource.addEventListener(SOURCE_CLOSE, onSourceClose);
mediaSource.addEventListener(SOURCE_OPEN, onSourceOpen);
mediaSource.addEventListener(SOURCE_ENDED, onSourceEnded);
mediaElement.setSource(URL.createObjectURL(mediaSource));

function setDuration(duration) {
mediaSource.duration = duration;
}

function destroy() {
toConsumableArray_default()(mediaSource.sourceBuffers).forEach(function (sourceBuffer) {
return removeSourceBuffer(sourceBuffer);
});

mediaSource.removeEventListener(SOURCE_CLOSE, onSourceClose);
mediaSource.removeEventListener(SOURCE_OPEN, onSourceOpen);
mediaSource.removeEventListener(SOURCE_ENDED, onSourceEnded);
ctx.off();
}

function addSourceBuffer(mimeType) {
return mediaSource.addSourceBuffer(mimeType);
}

function removeSourceBuffer(sourceBuffer) {
try {
mediaSource.removeSourceBuffer(sourceBuffer);
} catch (e) {}
}

function onSourceClose() {
ctx.trigger(SOURCE_CLOSE);
}

function onSourceOpen() {
ctx.trigger(SOURCE_OPEN);
}

function onSourceEnded() {
ctx.trigger(SOURCE_ENDED);
}

function endOfStream() {
if (getReadyState() === OPEN) {
try {
mediaSource.endOfStream();
} catch (e) {}
}
}

function getReadyState() {
return mediaSource.readyState;
}

function getActiveSourceBuffers() {
return mediaSource.activeSourceBuffers;
}

function setLiveSeekableRange(start, end) {
if (typeof mediaSource.setLiveSeekableRange === 'function' && typeof mediaSource.clearLiveSeekableRange === 'function' && mediaSource.readyState === OPEN) {
mediaSource.clearLiveSeekableRange();
mediaSource.setLiveSeekableRange(start, end);
}
}

return {
on: ctx.on.bind(ctx),
off: ctx.off.bind(ctx),
trigger: ctx.trigger.bind(ctx),
addSourceBuffer: addSourceBuffer,
destroy: destroy,
setDuration: setDuration,
endOfStream: endOfStream,
getReadyState: getReadyState,
getActiveSourceBuffers: getActiveSourceBuffers,
setLiveSeekableRange: setLiveSeekableRange
};
}

MediaSourceManager.isSupported = function (contentType) {
return window.MediaSource.isTypeSupported(contentType);
};

/* harmony default export */ var media_source = (MediaSourceManager);
// CONCATENATED MODULE: ./src/renderer/dash/index.js










function dash_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (dash_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function dash_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }


















var dash_DashPlayer = /*#__PURE__*/function (_BaseRenderer) {
inherits_default()(DashPlayer, _BaseRenderer);

var _super = dash_createSuper(DashPlayer);

function DashPlayer(player, video) {
var _this;

classCallCheck_default()(this, DashPlayer);

_this = _super.call(this, player, video);
_this.rendererType = DashPlayer.id;
_this.url = null;
_this.isAbr = true;
_this.streams = [];
_this.abr = null;
_this.currentBandwidth = null;
_this.seekingTimeout = 0;
_this.manifestManager = new manifest_ManifestManager(_this.mediaElement.getVideo(), _this.player);

_this.manifestManager.on(player_event["w" /* MANIFEST_UPDATED */], _this.onManifestUpdated.bind(assertThisInitialized_default()(_this)));

_this.manifestManager.on(player_event["x" /* MANIFEST_UPDATE_ERROR */], _this.onManifestUpdateError.bind(assertThisInitialized_default()(_this)));

_this.manifestManager.on(player_event["v" /* MANIFEST_LOADED */], _this.onManifestLoaded.bind(assertThisInitialized_default()(_this)));

_this.streamManager = new StreamManager(_this.player, _this.manifestManager);

_this.player.addComponent(_this.streamManager, player_component["h" /* STREAM_MANAGER */]);

_this.streamManager.on(dash_event["h" /* SEGMENT_DOWNLOAD_PROGRESS */], function (metric) {
return _this.abr.addMetric(metric);
});

_this.streamManager.on(player_event["T" /* PROFILE_CHANGED */], function (profile) {
return _this.onProfileChanged(profile);
});

_this.streamManager.on(player_event["W" /* PROFILE_CHANGING */], function (profile) {
return _this.onProfileChanging(profile);
});

_this.streamManager.on(player_event["Z" /* RECONNECT */], _this.reconnect.bind(assertThisInitialized_default()(_this)));

_this.streamManager.on(dash_event["d" /* FAILED_TO_DOWNLOAD_SEGMENT */], _this.onFailedToLoadSegment.bind(assertThisInitialized_default()(_this)));

_this.streamManager.on(player_event["n" /* ENDED */], _this.onEnded.bind(assertThisInitialized_default()(_this)));

_this.player.on(player_event["I" /* PERIOD */], function (period) {
return _this.onPeriod(period);
});

_this.player.on(player_event["ib" /* STOPPED */], function () {
_this.protectionManger = undefined;
});

_this.player.on(player_event["n" /* ENDED */], function () {
_this.protectionManger = undefined;
});

_this.reconnectTimeout = 0;
_this.currentProfile = null;
return _this;
}

createClass_default()(DashPlayer, [{
key: "onManifestLoaded",
value: function onManifestLoaded() {
var manifest = this.manifestManager.manifest;
this.player.trigger(player_event["v" /* MANIFEST_LOADED */], manifest);

if (this.manifestManager.isIndexMode() && manifest.availabilityStartTime && (isNaN(manifest.presentationTimeOffset) || manifest.presentationTimeOffset >= 0) && !manifest.availabilityEndTime) {
this.timeShift.setStart(manifest.availabilityStartTime);
}
}
}, {
key: "onManifestUpdated",
value: function onManifestUpdated() {
var manifest = this.manifestManager.manifest;
this.player.trigger(player_event["w" /* MANIFEST_UPDATED */], manifest);
this.streamManager.clearBuffer(0, this.mediaElement.getCurrentTime() - 60);
}
}, {
key: "onManifestUpdateError",
value: function onManifestUpdateError() {
this.reconnect();
}
}, {
key: "onProfileChanged",
value: function onProfileChanged(profile) {
if (!profile) {
return;
}

var bandwidth = profile.bandwidth;

if (this.currentProfile === profile) {
return;
}

this.currentBandwidth = bandwidth;
this.currentProfile = profile;
this.player.trigger(player_event["T" /* PROFILE_CHANGED */], profile, this.getCurrentTime(), this.isAbr);

if (this.options.get(option_name["S" /* LAST_BITRATE_CACHING */])) {
localStorage.setItem(BITRATE, bandwidth);
}
}
}, {
key: "onProfileChanging",
value: function onProfileChanging(profile) {
this.player.trigger(player_event["W" /* PROFILE_CHANGING */], profile, this.getCurrentTime(), this.isAbr);
this.player.trigger(player_event["U" /* PROFILE_CHANGED_LEGACY */], this.getCurrentTime(), profile, this.isAbr);
}
}, {
key: "onFailedToLoadSegment",
value: function onFailedToLoadSegment(url, xhr) {
this.trigger(dash_event["d" /* FAILED_TO_DOWNLOAD_SEGMENT */], url);
this.player.trigger(player_event["o" /* ERROR */], {
code: error_code["a" /* default */][player_error["a" /* default */].LOAD_SEGMENT_ERROR],
renderer: 'DASH',
message: player_error["a" /* default */].LOAD_SEGMENT_ERROR,
url: url,
xhr: xhr
});
}
}, {
key: "isIndexMode",
value: function isIndexMode() {
return this.manifestManager.isIndexMode();
}
}, {
key: "setSource",
value: function setSource(_url) {
var _this2 = this;

this.destroy();
this.isAbr = !!this.options.get(option_name["i" /* AUTO_ADAPTATION */]);
this.url = _url;

if (this.baseUrl === null) {
this.baseUrl = this.url;
}

this.player.trigger(player_event["E" /* ON_SOURCE */], this.url);

if (this.timeShift.isEnabled()) {
this.url = this.timeShift.generateUrl(this.url);
}

this.manifestManager.load(this.url).then(function () {
if (_this2.isLive()) {
_this2.player.trigger(player_event["D" /* ON_LIVE */]);
}

_this2.player.trigger(player_event["X" /* PROFILE_LIST */], _this2.manifestManager.getVideoProfiles());

_this2.player.trigger(player_event["f" /* AUDIO_TRACK_LIST */], _this2.manifestManager.getAudioTracks());

_this2.playSource();
})["catch"](function (_ref) {
var error = _ref.error,
url = _ref.url,
xhr = _ref.xhr;

if (error === dash_event["c" /* FAILED_TO_DOWNLOAD_MANIFEST */]) {
if (!_this2.isLive()) {
_this2.destroy();
} else {
if (_this2.timeShift.isLive()) {
_this2.reconnect(4000, _this2.baseUrl);
} else {
_this2.reconnect(4000);
}
}

_this2.player.trigger(player_event["o" /* ERROR */], {
code: error_code["a" /* default */][player_error["a" /* default */].LOAD_MANIFEST_ERROR],
renderer: 'DASH',
message: player_error["a" /* default */].LOAD_MANIFEST_ERROR,
url: url,
xhr: xhr
});
}
});
}
}, {
key: "isLive",
value: function isLive() {
var _this$manifestManager;

return get_default()(getPrototypeOf_default()(DashPlayer.prototype), "isLive", this).call(this) || ((_this$manifestManager = this.manifestManager) === null || _this$manifestManager === void 0 ? void 0 : _this$manifestManager.isLive());
}
}, {
key: "destroy",
value: function destroy() {
var _this$mediaSource, _this$abr;

clearTimeout(this.reconnectTimeout);
this.manifestManager.destroy();
this.streamManager.destroy();
(_this$mediaSource = this.mediaSource) === null || _this$mediaSource === void 0 ? void 0 : _this$mediaSource.destroy();
(_this$abr = this.abr) === null || _this$abr === void 0 ? void 0 : _this$abr.destroy();

get_default()(getPrototypeOf_default()(DashPlayer.prototype), "destroy", this).call(this);
}
}, {
key: "onPeriod",
value: function onPeriod(_ref2) {
var id = _ref2.id;
var period = this.manifestManager.getPeriodById(id);
var profiles = this.manifestManager.getVideoProfiles(period);
this.player.trigger(player_event["X" /* PROFILE_LIST */], profiles);
}
}, {
key: "onEnded",
value: function onEnded() {
get_default()(getPrototypeOf_default()(DashPlayer.prototype), "onEnded", this).call(this);

this.destroy();
}
}, {
key: "onSeeking",
value: function onSeeking() {
var _this3 = this;

clearTimeout(this.seekingTimeout);
this.seekingTimeout = setTimeout(function () {
_this3.streamManager.updatePosition(_this3.mediaElement.getCurrentTime());
}, 250);
}
}, {
key: "onLoadedmetadata",
value: function onLoadedmetadata() {
this.lastEvent = player_event["y" /* METADATA */];
this.mediaElement.seek(this.streamManager.getStartTime());
this.player.trigger(player_event["C" /* NEW_MEDIA */], this.manifestManager.isLive() ? -1 : this.manifestManager.duration);
this.player.trigger(player_event["y" /* METADATA */], {
duration: this.manifestManager.duration
});
}
}, {
key: "reconnect",
value: function reconnect(timeout, url, force) {
var _this4 = this;

if (this.streamManager && this.streamManager.getBufferLength() > 1 && !force) {
return;
}

timeout = timeout || 2000;
url = url || this.url;
this.streamManager.setReconnecting();
this.options.autoplay = true;
clearTimeout(this.reconnectTimeout);
this.player.trigger(player_event["zb" /* WAITING */], this.mediaElement.getCurrentTime()); //TODO: update live button in gui

if (this.timeShift.isEnabled() && this.timeShift.isLive()) {
this.timeShift.setLive();
}

this.reconnectTimeout = setTimeout(function () {
_this4.setSource(url);
}, timeout);
}
}, {
key: "switchProfile",
value: function switchProfile(_bandwidth, asap, immediately) {
var bandwidth = (_bandwidth === null || _bandwidth === void 0 ? void 0 : _bandwidth.bandwidth) || _bandwidth;

if (Math.round(this.getCurrentTime()) === 0) {
clearTimeout(this.seekingTimeout);
}

if (bandwidth === 'auto') {
this.isAbr = true;
this.player.trigger(player_event["T" /* PROFILE_CHANGED */], this.currentProfile, this.getCurrentTime(), this.isAbr);
} else {
this.isAbr = false;
this.streamManager.switchProfile(bandwidth, asap, immediately !== undefined ? immediately : this.options.get(option_name["P" /* IMMEDIATELY_SWITCH */]));
}
}
}, {
key: "switchAudioTrack",
value: function switchAudioTrack(audioTrack, immediately) {
this.streamManager.switchAudioTrack(audioTrack, immediately);
}
}, {
key: "playSource",
value: function () {
var _playSource = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee(_url) {
var _this5 = this;

var _this$manifestManager2, videoAdaptation, audioAdaptation, adaptation, contentTypes;

return regenerator_default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
clearTimeout(this.reconnectTimeout);
_this$manifestManager2 = this.manifestManager, videoAdaptation = _this$manifestManager2.videoAdaptation, audioAdaptation = _this$manifestManager2.audioAdaptation;
adaptation = videoAdaptation || audioAdaptation;

if (!(adaptation === null)) {
_context.next = 6;
break;
}

this.reconnect(5000);
return _context.abrupt("return");

case 6:
if (adaptation.representations.length) {
_context.next = 10;
break;
}

if (adaptation.unsupportedCodecs.length) {
this.player.trigger(player_event["o" /* ERROR */], {
code: error_code["a" /* default */][player_error["a" /* default */].NO_SUPPORTED_CODEC],
renderer: 'DASH',
message: player_error["a" /* default */].NO_SUPPORTED_CODEC,
data: adaptation.unsupportedCodecs
});
}

this.destroy();
return _context.abrupt("return");

case 10:
if (!(typeof _url !== 'undefined')) {
_context.next = 13;
break;
}

this.setSource(_url);
return _context.abrupt("return");

case 13:
if (!this.options.get(option_name["z" /* DRM */])) {
_context.next = 19;
break;
}

contentTypes = this.manifestManager.getAllAdaptationSets().filter(function (_ref3) {
var type = _ref3.type;
return [media_type["a" /* default */].AUDIO, media_type["a" /* default */].VIDEO].includes(type);
}).map(function (_ref4) {
var contentType = _ref4.contentType,
type = _ref4.type;
return {
contentType: contentType,
type: type
};
});

if (this.protectionManger) {
_context.next = 19;
break;
}

_context.next = 18;
return new protection_manager["a" /* default */](this.player, contentTypes);

case 18:
this.protectionManger = _context.sent;

case 19:
if (!this.player.destroyed) {
_context.next = 21;
break;
}

return _context.abrupt("return");

case 21:
this.abr = new abr(this.player);
this.mediaSource = new media_source(this.mediaElement);
this.player.addComponent(this.mediaSource, player_component["e" /* MEDIA_SOURCE */]);
this.mediaSource.on(SOURCE_OPEN, function () {
return _this5.onSourceOpen();
});
this.registerEvents();
this.abr.on(player_event["V" /* PROFILE_CHANGE_REQUEST */], function (bandwidth, forceSwitch) {
setTimeout(function () {
if (_this5.isAbr) {
_this5.streamManager.switchProfile(bandwidth, forceSwitch);
}
}, 0);
});

if (this.isPaused) {
this.mediaElement.pause();
this.player.trigger(player_event["G" /* PAUSED */], this.getCurrentTime());
} else {
this.mediaElement.play();
}

case 28:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));

function playSource(_x) {
return _playSource.apply(this, arguments);
}

return playSource;
}()
}, {
key: "seek",
value: function seek() {
this.triggerOnSeekStartEvents();

for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

this.streamManager.seek.apply(this.streamManager, args);
}
}, {
key: "seekTo",
value: function seekTo() {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}

var position = args[0];

if (this.timeShift.isEnabled()) {
this.triggerOnSeekStartEvents();
args[0] = position / (this.getDuration() - this.player.getLiveDelay()) * 100;
this.streamManager.seek.apply(this.streamManager, args);
return;
}

args[0] = position / this.getDuration() * 100;
this.seek.apply(this, args);
}
}, {
key: "seekToHead",
value: function seekToHead() {
this.triggerOnSeekStartEvents();
this.streamManager.seekToHead();
}
}, {
key: "getDuration",
value: function getDuration() {
return this.streamManager.getDuration();
}
}, {
key: "getCurrentTime",
value: function getCurrentTime() {
return this.streamManager.getCurrentTime();
}
}, {
key: "getBufferLength",
value: function getBufferLength() {
return this.streamManager.getBufferLength();
}
}, {
key: "getLiveDelay",
value: function getLiveDelay() {
return this.manifestManager.getLiveDelay();
}
}, {
key: "getDownloadSpeed",
value: function getDownloadSpeed() {
return this.abr.getDownloadSpeed();
}
}, {
key: "setMaxBufferLength",
value: function setMaxBufferLength(length) {
return this.streamManager.setMaxBufferLength(length);
}
}, {
key: "getCurrentProfile",
value: function getCurrentProfile() {
return this.streamManager.getCurrentProfile();
}
}, {
key: "getProfiles",
value: function getProfiles() {
return this.streamManager.getProfiles();
}
}, {
key: "getProfile",
value: function getProfile() {
return this.currentProfile;
}
}, {
key: "getAudioTracks",
value: function getAudioTracks() {
return this.manifestManager.getAudioTracks();
}
}, {
key: "getCurrentAudioTrack",
value: function getCurrentAudioTrack() {
return this.streamManager.getCurrentAudioTrack();
}
}, {
key: "getTextTracks",
value: function getTextTracks() {
return this.mediaElement.getNativeTextTracks();
}
}, {
key: "getCurrentPeriod",
value: function getCurrentPeriod() {
return this.streamManager.getCurrentPeriod();
}
}, {
key: "stop",
value: function stop() {
this.player.trigger(player_event["ib" /* STOPPED */], this.mediaElement.getCurrentTime());
this.isPaused = false;
this.destroy();
}
}, {
key: "resume",
value: function resume() {
this.isPaused = false;
this.mediaElement.play();
}
}, {
key: "onSourceOpen",
value: function onSourceOpen() {
if (this.streamManager.hasActiveStreams()) {
this.streamManager.sourceOpen();
return;
}

var duration = this.manifestManager.duration;

if (this.timeShift.isEnabled() && this.timeShift.isLive()) {
duration = Number.MAX_VALUE;
}

this.mediaSource.setDuration(duration);

if (this.manifestManager.isLive() && this.options.get(option_name["xb" /* SMART_TV */])) {
this.mediaSource.setLiveSeekableRange(0, Number.MAX_VALUE);
}

this.streamManager.createStreams(this.mediaSource, this.manifestManager.isLive() && !this.timeShift.isVod());

if (this.currentBandwidth !== null) {
this.streamManager.switchProfile(this.currentBandwidth);
}

this.streamManager.initStreams();
}
}], [{
key: "canPlayType",
value: function canPlayType(mimeType, options) {
if (options.get(option_name["G" /* FORCE_DASH */])) {
return true;
}

if (options.get(option_name["F" /* FIX_APPLE_SITE_SPECIFIC_HACKS */]) && browser["a" /* default */].isSafariWithSiteSpecificHacks()) {
return false;
}

if (browser["a" /* default */].isSafari() && !options.get(option_name["xb" /* SMART_TV */])) {
return false;
}

if (!browser["a" /* default */].isWidevineSupported() && browser["a" /* default */].isFirefox()) {
return false;
}

return typeof window.MediaSource !== 'undefined';
}
}]);

return DashPlayer;
}(base_renderer["a" /* default */]);

dash_DashPlayer.id = 'dash';
dash_DashPlayer.enabled = true;
dash_DashPlayer.priority = 100;
dash_DashPlayer.mediaTypes = {
DASH: 'application/dash+xml'
};
/* harmony default export */ var dash = __webpack_exports__["a"] = (dash_DashPlayer);

/***/ }),
/* 61 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/typeof.js
var helpers_typeof = __webpack_require__(26);
var typeof_default = /*#__PURE__*/__webpack_require__.n(helpers_typeof);

// EXTERNAL MODULE: ./src/core/player.js + 5 modules
var core_player = __webpack_require__(32);

// EXTERNAL MODULE: ./src/core/event/player-event.js
var player_event = __webpack_require__(0);

// EXTERNAL MODULE: ./src/core/enum/option-name.js
var option_name = __webpack_require__(1);

// EXTERNAL MODULE: ./src/core/global.js
var global = __webpack_require__(35);

// EXTERNAL MODULE: ./src/core/util/core.js
var core = __webpack_require__(19);

// CONCATENATED MODULE: ./src/module/report/video-metrics.js



var DEFAULT_OPTS = {
maxRetention: Number.POSITIVE_INFINITY,
maxSamples: 120,
interval: 10
};

function VideoMetrics(player) {
var metrics = [];
var opts = player.options.get(option_name["qb" /* SESSION_HISTORY */]).videoMetrics || DEFAULT_OPTS;
core["a" /* default */].extend(DEFAULT_OPTS, opts);

if (opts.interval <= 0) {
opts.interval = DEFAULT_OPTS.interval;
}

var maxRetention = opts.maxRetention;
var maxSamples = opts.maxSamples;
var isStarted = false;
player.on(player_event["O" /* PLAYING */], onPlaying);
player.on(player_event["ib" /* STOPPED */], stop);
player.on(player_event["l" /* DESTROY */], stop);
player.on(player_event["n" /* ENDED */], stop);

function onPlaying() {
if (isStarted) {
return;
}

start();
}

function start() {
isStarted = true;
var interval = opts.interval * 1000;
snapshot();
timeoutInt = setInterval(function () {
snapshot();
}, interval);
}

function stop() {
isStarted = false;
clearTimeout(timeoutInt);
}

function snapshot() {
var buffers = [];
var buffered = player.getBuffered();

if (buffered && buffered.length) {
for (var i = 0; i < buffered.length; i++) {
buffers.push({
start: buffered.start(i),
stop: buffered.end(i)
});
}
}

var played_times = [];
var played = player.getPlayed();

if (played && played.length) {
for (var _i = 0; _i < played.length; _i++) {
played_times.push({
start: played.start(_i),
stop: played.end(_i)
});
}
}

var profile = 0;

if (player.getProfile()) {
profile = player.getProfile().bandwidth;
}

var metric = {
videoTime: Number(player.getCurrentTime().toFixed(3)),
paused: player.isPaused(),
buffer: Number(player.getBufferLength().toFixed(3)),
buffered: buffers,
played: played_times,
profile: profile,
decodedFrames: player.getDecodedFrameCount(),
droppedFrames: player.getDroppedFrameCount(),
timestamp: new Date().getTime()
};
metrics.push(metric);
}

function getMetrics() {
cleanUp();
return metrics;
}

var timeoutInt = setInterval(function () {
cleanUp();
}, 10000);

function cleanUp() {
if (!metrics.length) {
return;
}

var now = new Date().getTime();

if (now > metrics[0].timestamp + maxRetention * 1000 || metrics.length > maxSamples) {
metrics.shift();
cleanUp();
}
}

return {
getMetrics: getMetrics
};
}

/* harmony default export */ var video_metrics = (VideoMetrics);
// CONCATENATED MODULE: ./src/module/report/network-metrics.js



var network_metrics_DEFAULT_OPTS = {
maxRetention: Number.POSITIVE_INFINITY,
maxSamples: 120
};

function NetworkMetrics(player) {
var metrics = [];
var opts = player.options.get(option_name["qb" /* SESSION_HISTORY */]).networkMetrics || network_metrics_DEFAULT_OPTS;
core["a" /* default */].extend(network_metrics_DEFAULT_OPTS, opts);
var maxRetention = opts.maxRetention;
var maxSamples = opts.maxSamples;
player.on(player_event["A" /* NETWORK_METRIC */], function (metric) {
metrics.push(metric);
player.trigger(player_event["B" /* NETWORK_METRIC_UPDATED */], metric);
});

function getMetrics() {
cleanUp();
return metrics;
}

function destroy() {
clearInterval(timeoutInt);
metrics = [];
}

var timeoutInt = setInterval(function () {
cleanUp();
}, 10000);

function cleanUp() {
if (!metrics.length) {
return;
}

var now = new Date().getTime();

if (now > metrics[0].timestamp + maxRetention * 1000 || metrics.length > maxSamples) {
metrics.shift();
cleanUp();
return;
}

metrics.slice();
}

return {
getMetrics: getMetrics,
destroy: destroy
};
}

/* harmony default export */ var network_metrics = (NetworkMetrics);
// CONCATENATED MODULE: ./src/module/report/session-events.js



var session_events_DEFAULT_OPTS = {
maxRetention: Number.POSITIVE_INFINITY,
maxSamples: 120
};
var EVENTS = [player_event["E" /* ON_SOURCE */], player_event["O" /* PLAYING */], player_event["zb" /* WAITING */], player_event["eb" /* SEEK_START */], player_event["G" /* PAUSED */], player_event["n" /* ENDED */], player_event["ib" /* STOPPED */], player_event["T" /* PROFILE_CHANGED */], player_event["o" /* ERROR */]];

function SessionEvents(player) {
var events = [];
var lastEvent = '';
var opts = player.options.get(option_name["qb" /* SESSION_HISTORY */]).sessionEvents || session_events_DEFAULT_OPTS;
core["a" /* default */].extend(session_events_DEFAULT_OPTS, opts);
var maxRetention = opts.maxRetention;
var maxSamples = opts.maxSamples;
EVENTS.forEach(function (event) {
player.on(event, function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

args.unshift(event);
addEvent.apply(null, args);
});
});

function addEvent(eventName, arg1, arg2) {
if (eventName !== player_event["T" /* PROFILE_CHANGED */] && eventName !== player_event["o" /* ERROR */] && lastEvent === eventName) {
return;
}

lastEvent = eventName;
var event = {
timestamp: new Date().getTime(),
event: eventName,
videoTime: arg1
};

if (eventName === player_event["E" /* ON_SOURCE */]) {
event.url = arg1;
event.videoTime = -1;
}

if (eventName === player_event["T" /* PROFILE_CHANGED */]) {
event.bandwidth = (arg1 === null || arg1 === void 0 ? void 0 : arg1.bandwidth) || -1;
}

if (eventName === player_event["o" /* ERROR */]) {
if (arg1 && arg1.code) {
event.videoTime = -1;
event.code = arg1.code;
} else {
return;
}
}

events.push(event);
}

function getEvents() {
cleanUp();
return events;
}

var timeoutInt = setInterval(function () {
cleanUp();
}, 10000);

function cleanUp() {
if (!events.length) {
return;
}

var now = new Date().getTime();

if (now > events[0].timestamp + maxRetention * 1000 || events.length > maxSamples) {
events.shift();
cleanUp();
}
}

return {
getEvents: getEvents
};
}

/* harmony default export */ var session_events = (SessionEvents);
// CONCATENATED MODULE: ./src/module/report/session-info.js
function Info() {
this.userAgent = undefined;
this.setup = undefined;
this.start = undefined;
this.mediaUrl = undefined;
}

/* harmony default export */ var session_info = (Info);
// CONCATENATED MODULE: ./src/module/report/session.js







function Session(player, opts) {
var sessionId = player.options.get(option_name["db" /* NAME */]);
var info = new session_info();
info.userAgent = navigator.userAgent;
info.setup = player.options.options;
info.start = new Date().getTime();
info.mediaUrl = '';
player.on(player_event["E" /* ON_SOURCE */], function (url) {
info.mediaUrl = url;
});
var networkMetrics = new network_metrics(player);
var videoMetrics = new video_metrics(player);
var sessionEvents = new session_events(player);

function getInfo() {
return info;
}

function getNetworkMetrics() {
return networkMetrics.getMetrics();
}

function getVideoMetrics() {
return videoMetrics.getMetrics();
}

function getEvents() {
return sessionEvents.getEvents();
}

function serialize() {
var data = {
info: getInfo(),
networkMetrics: getNetworkMetrics()
};
return JSON.stringify(data);
}

return {
sessionId: sessionId,
getInfo: getInfo,
getNetworkMetrics: getNetworkMetrics,
getVideoMetrics: getVideoMetrics,
getEvents: getEvents,
serialize: serialize
};
}

/* harmony default export */ var report_session = (Session);
// CONCATENATED MODULE: ./src/module/report/index.js






var sessions = [];
var DEFAULT_MAX_SESSIONS = 5;

function ReportModule(player) {
function onReady() {
var session = new report_session(player);

player.getSession = function () {
return session;
};

global["b" /* default */].addSession(session);
var maxSessions = player.options.get(option_name["qb" /* SESSION_HISTORY */]).maxSessions || DEFAULT_MAX_SESSIONS;

while (sessions.length > maxSessions) {
sessions.shift();
}

player.trigger(player_event["gb" /* SESSION */], session);
}

player.setSessionHistory = function (sessionHistory) {
if (typeof_default()(sessionHistory) !== 'object' || sessionHistory === null) {
return;
}

player.options.set(option_name["qb" /* SESSION_HISTORY */], sessionHistory);
onReady();
};

if (player.options.get(option_name["qb" /* SESSION_HISTORY */])) {
player.on(player_event["Y" /* READY */], onReady);
}
}

core_player["a" /* default */].addSession = function (session) {
return sessions.push(session);
};

core_player["a" /* default */].getSession = function (id) {
return sessions.find(function (session) {
return id === session.sessionId;
});
};

core_player["a" /* default */].getSessionList = function () {
return sessions;
};

global["b" /* default */].addSession = core_player["a" /* default */].addSession;
global["b" /* default */].getSession = core_player["a" /* default */].getSession;
global["b" /* default */].getSessionList = core_player["a" /* default */].getSessionList;
ReportModule.enabled = true;
ReportModule.moduleId = 'reports';
/* harmony default export */ var report = __webpack_exports__["a"] = (ReportModule);

/***/ }),
/* 62 */,
/* 63 */,
/* 64 */
/***/ (function(module, exports) {

function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;

try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}

module.exports = _isNativeReflectConstruct;

/***/ }),
/* 65 */,
/* 66 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);

// EXTERNAL MODULE: ./src/core/player.js + 5 modules
var core_player = __webpack_require__(32);

// EXTERNAL MODULE: ./src/renderer/dash/index.js + 23 modules
var renderer_dash = __webpack_require__(60);

// EXTERNAL MODULE: ./src/renderer/html5/index.js
var html5 = __webpack_require__(59);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/regenerator/index.js
var regenerator = __webpack_require__(15);
var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/construct.js
var construct = __webpack_require__(49);
var construct_default = /*#__PURE__*/__webpack_require__.n(construct);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/asyncToGenerator.js
var asyncToGenerator = __webpack_require__(20);
var asyncToGenerator_default = /*#__PURE__*/__webpack_require__.n(asyncToGenerator);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/classCallCheck.js
var classCallCheck = __webpack_require__(3);
var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/createClass.js
var createClass = __webpack_require__(5);
var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass);

// EXTERNAL MODULE: ./src/renderer/hls-js/config.js
var config = __webpack_require__(47);

// CONCATENATED MODULE: ./src/renderer/hls-js/index_async.js







var HlsJSRendererModule = function HlsJSRendererModule() {
return __webpack_require__.e(/* import() | renderer/hlsjs */ 3).then(__webpack_require__.bind(null, 68));
};

var index_async_HlsJsAsyncRenderer = /*#__PURE__*/function () {
function HlsJsAsyncRenderer() {
classCallCheck_default()(this, HlsJsAsyncRenderer);
}

createClass_default()(HlsJsAsyncRenderer, null, [{
key: "canPlayType",
value: function canPlayType(mimeType, options) {
return !!options.get(config["a" /* default */].OPTION_NAME);
}
}, {
key: "create",
value: function create() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

return new Promise( /*#__PURE__*/function () {
var _ref = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee(resolve, reject) {
return regenerator_default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return HlsJSRendererModule().then(function (module) {
return resolve(construct_default()(module["default"], args));
})["catch"](function () {
return reject();
});

case 2:
case "end":
return _context.stop();
}
}
}, _callee);
}));

return function (_x, _x2) {
return _ref.apply(this, arguments);
};
}());
}
}]);

return HlsJsAsyncRenderer;
}();

index_async_HlsJsAsyncRenderer.id = config["a" /* default */].ID;
index_async_HlsJsAsyncRenderer.priority = config["a" /* default */].PRIORITY;
index_async_HlsJsAsyncRenderer.mediaTypes = config["a" /* default */].SUPPORTED_MEDIA_TYPES;
/* harmony default export */ var index_async = (index_async_HlsJsAsyncRenderer);
// EXTERNAL MODULE: ./src/core/enum/option-name.js
var option_name = __webpack_require__(1);

// EXTERNAL MODULE: ./src/core/enum/player-component.js
var player_component = __webpack_require__(7);

// EXTERNAL MODULE: ./src/core/event/player-event.js
var player_event = __webpack_require__(0);

// EXTERNAL MODULE: ./src/core/util/core.js
var core = __webpack_require__(19);

// EXTERNAL MODULE: ./src/core/util/http/index.js + 1 modules
var http = __webpack_require__(22);

// CONCATENATED MODULE: ./src/module/advert/advert.js



var AdvertType = {
PREROLL: 'preroll',
MIDROLL: 'midroll',
POSTROLL: 'overlay',
OVERLAY: 'overlay'
};
var AdvertEvent = {
ERROR: 'error',
START: 'start',
FIRST_QUARTILE: 'firstQuartile',
MIDPOINT: 'midpoint',
THIRD_QUARTILE: 'thirdQuartile',
COMPLETE: 'complete',
PAUSE: 'pause',
RESUME: 'resume',
UNMUTE: 'unmute',
MUTE: 'mute',
FULLSCREEN: 'fullscreen',
EXIT_FULLSCREEN: 'exitFullscreen',
CREATIVE_VIEW: 'creativeView',
CLICK_TRACKING: 'ClickTracking',
IMPRESSION: 'Impression'
};

var advert_Advert = /*#__PURE__*/function () {
function Advert() {
classCallCheck_default()(this, Advert);

this.id = null;
this.adSystem = null;
this.files = [];
this.events = [];
this.clickThrough = '';
this.duration = NaN;
this.played = false;
}

createClass_default()(Advert, [{
key: "addEvent",
value: function addEvent(eventName, url) {
this.events.push({
name: eventName,
url: url,
fired: false
});
}
}, {
key: "track",
value: function track(eventName) {
this.events.forEach(function (event) {
if (event.url && event.name === eventName && !event.fired) {
http["a" /* default */].get(event.url, {
retryAttempts: 0
})["catch"](function () {});

switch (eventName) {
case AdvertEvent.START:
case AdvertEvent.CREATIVE_VIEW:
case AdvertEvent.IMPRESSION:
case AdvertEvent.COMPLETE:
case AdvertEvent.FIRST_QUARTILE:
case AdvertEvent.MIDPOINT:
case AdvertEvent.THIRD_QUARTILE:
event.fired = true;
break;
}
}
});
}
}]);

return Advert;
}();

/* harmony default export */ var advert_advert = (advert_Advert);

// CONCATENATED MODULE: ./src/module/advert/vast.js






var vast_VastParser = /*#__PURE__*/function () {
function VastParser() {
classCallCheck_default()(this, VastParser);

this.adverts = {
prerolls: []
};
}

createClass_default()(VastParser, [{
key: "fetch",
value: function fetch(url) {
var _this = this;

return VastParser.load(url).then(function (resp) {
return _this.parse(resp.data);
});
}
}, {
key: "parse",
value: function parse(data) {
var _this2 = this;

var advertList = toArray(data.getElementsByTagName('Ad'));
var itemsToParse = advertList.length;

if (itemsToParse === 0) {
return Promise.resolve(this.adverts);
}

return new Promise(function (resolve) {
advertList.forEach(function (advert) {
_this2.parseAdNode(advert).then(function () {
itemsToParse--;

if (itemsToParse <= 0) {
resolve(_this2.adverts);
}
});
});
});
}
}, {
key: "parseAdNode",
value: function parseAdNode(adNode, advert) {
var _this3 = this;

return new Promise(function (resolve, reject) {
if (typeof advert === 'undefined') {
advert = new advert_advert();
}

advert.id = adNode.getAttribute('id');
var type = getChildNodeContent(adNode, 'AdTitle') || adNode.getAttribute('id') || AdvertType.PREROLL;
type = type.toLowerCase();

if (type.indexOf(AdvertType.PREROLL) !== -1) {
advert.type = AdvertType.PREROLL;

_this3.adverts.prerolls.push(advert);
}

var mediaFileNodes = toArray(adNode.getElementsByTagName('MediaFile'));
mediaFileNodes.forEach(function (mediaFile) {
var url = mediaFile.textContent.trim();

if (url) {
advert.files.push({
url: url,
type: mediaFile.getAttribute('type')
});
}
});
var duration = getChildNodeContent(adNode, 'Duration');

if (duration) {
advert.duration = core["a" /* default */].parseTime(duration);
}

var clickThrough = getChildNodeContent(adNode, 'ClickThrough');

if (clickThrough) {
advert.clickThrough = fillUrl(clickThrough, advert);
}

var trackingEvents = toArray(adNode.getElementsByTagName('Tracking'));
trackingEvents.forEach(function (trackingEvent) {
var event = trackingEvent.getAttribute('event');
var url = trackingEvent.textContent.trim();
advert.addEvent(event, url);
});
var impressions = toArray(adNode.getElementsByTagName('Impression'));
impressions.forEach(function (impression) {
advert.addEvent('Impression', fillUrl(impression.textContent.trim(), advert));
});
var clickTracking = getChildNodeContent(adNode, 'ClickTracking');

if (clickTracking) {
advert.addEvent('ClickTracking', fillUrl(clickTracking, advert));
}

var VASTAdTagURI = getChildNodeContent(adNode, 'VASTAdTagURI');

if (VASTAdTagURI !== null) {
return VastParser.load(VASTAdTagURI).then(function (_ref) {
var data = _ref.data;

if (data.getElementsByTagName('Ad').length) {
var _adNode = data.getElementsByTagName('Ad')[0];
return _this3.parseAdNode(_adNode, advert);
} else {
return Promise.resolve();
}
})["catch"](function () {
resolve();
});
} else {
resolve();
}
});
}
}], [{
key: "load",
value: function load(url) {
function _load() {
var withCredentials = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
return http["a" /* default */].get(url, {
responseType: 'xml',
retryAttempts: 0,
withCredentials: withCredentials
})["catch"](function () {});
}

return _load()["catch"](function () {
return _load(false);
});
}
}]);

return VastParser;
}();

function getChildNodeContent(parentNode, childElementName) {
var nodeList = parentNode.getElementsByTagName(childElementName);

if (nodeList.length) {
return nodeList[0].textContent.trim();
}

return null;
}

function fillUrl(url, adItem) {
if (adItem.id !== null) {
url = url.replace('[AD_ID]', adItem.id);
}

if (adItem.adSystem !== null) {
url = url.replace('[AD_SYS]', adItem.adSystem);
}

return url;
}

function toArray(obj) {
return Array.prototype.slice.call(obj);
}

/* harmony default export */ var vast = (vast_VastParser);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/possibleConstructorReturn.js
var possibleConstructorReturn = __webpack_require__(12);
var possibleConstructorReturn_default = /*#__PURE__*/__webpack_require__.n(possibleConstructorReturn);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/getPrototypeOf.js
var getPrototypeOf = __webpack_require__(4);
var getPrototypeOf_default = /*#__PURE__*/__webpack_require__.n(getPrototypeOf);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/inherits.js
var inherits = __webpack_require__(13);
var inherits_default = /*#__PURE__*/__webpack_require__.n(inherits);

// EXTERNAL MODULE: ./src/core/component.js
var core_component = __webpack_require__(37);

// EXTERNAL MODULE: ./src/core/event/dom-event.js
var dom_event = __webpack_require__(6);

// CONCATENATED MODULE: ./src/module/advert/layout.js
/* harmony default export */ var layout = ({
advert: [[{
id: 'play-pause'
}, {
id: 'advert-label'
}, {
id: 'separator-left',
type: 'html-element'
}, {
id: 'live'
}, {
id: 'volume'
}, {
id: 'fullscreen'
}]]
});
// CONCATENATED MODULE: ./src/module/advert/counter.js




var counter_AdvertCounter = /*#__PURE__*/function () {
function AdvertCounter(id, options) {
classCallCheck_default()(this, AdvertCounter);

this.id = id;
this.elm = document.createElement('div');
this.elm.classList.add(options.get(option_name["s" /* CSS_PREFIX */]) + '-advert-counter');
this.elm.innerHTML = options.get(option_name["c" /* ADVERT_LABEL */]);
this.counterElm = document.createElement('span');
this.elm.appendChild(this.counterElm);
}

createClass_default()(AdvertCounter, [{
key: "hide",
value: function hide() {
this.elm.style.display = 'none';
}
}, {
key: "show",
value: function show() {
this.elm.style.display = 'block';
}
}, {
key: "getElm",
value: function getElm() {
return this.elm;
}
}, {
key: "update",
value: function update(str) {
this.counterElm.innerHTML = str + 's';
}
}]);

return AdvertCounter;
}();

/* harmony default export */ var advert_counter = (counter_AdvertCounter);
// CONCATENATED MODULE: ./src/module/advert/player.js






function _createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }










var player_AdvertVideo = /*#__PURE__*/function (_Component) {
inherits_default()(AdvertVideo, _Component);

var _super = _createSuper(AdvertVideo);

function AdvertVideo(player, options) {
var _this;

classCallCheck_default()(this, AdvertVideo);

_this = _super.call(this);
_this.playerConstructor = player.constructor;
_this.parentPlayer = player;
_this.options = options;
_this.advert = undefined;
_this.sequence = undefined;
_this.sequenceDuration = 0;
_this.gui = undefined;
_this.video = document.createElement('video');
_this.player = null;
_this.volume = _this.options.get(option_name["Ob" /* VOLUME */]);
_this.counter = new advert_counter('advert-counter', _this.options);
return _this;
}

createClass_default()(AdvertVideo, [{
key: "setGui",
value: function setGui(gui) {
this.gui = gui;
}
}, {
key: "getPlayer",
value: function getPlayer() {
return this.player;
}
}, {
key: "getVideo",
value: function getVideo() {
return this.video;
}
}, {
key: "registerEvents",
value: function registerEvents() {
this.player.on(player_event["O" /* PLAYING */], this.onPlaying.bind(this));
this.player.on(player_event["G" /* PAUSED */], this.onPaused.bind(this));
this.player.on(player_event["n" /* ENDED */], this.onEnded.bind(this));
this.player.on(player_event["tb" /* TIME */], this.onTime.bind(this));
this.player.on(player_event["Y" /* READY */], this.onReady.bind(this));
this.player.on(player_event["wb" /* VOLUME_CHANGED */], this.onVolumeChanged.bind(this));
this.player.on(player_event["o" /* ERROR */], this.onError.bind(this));
this.onVideoClick = this.onVideoClick.bind(this);
this.video.addEventListener(dom_event["b" /* CLICK */], this.onVideoClick);

if (this.gui) {
this.onFullScreenChanged = this.onFullScreenChanged.bind(this);
this.gui.on(player_event["p" /* FULLSCREEN_CHANGED */], this.onFullScreenChanged, this);
}
}
}, {
key: "track",
value: function track(event) {
if (this.advert) {
this.advert.track(event);
}
}
}, {
key: "getNext",
value: function getNext() {
for (var i = 0; i < this.sequence.length; i++) {
var advert = this.sequence[i];

if (!advert.played) {
return advert;
}
}
}
}, {
key: "playSequence",
value: function playSequence(sequence, autoplay) {
this.sequence = sequence;
this.advert = this.getNext();

if (this.advert) {
this.gui.addGuiComponent(this.counter, this.counter.id);
this.play(this.advert, autoplay);
}
}
}, {
key: "getSequenceDuration",
value: function getSequenceDuration() {
var duration = 0;
this.sequence.forEach(function (advert) {
if (!advert.played) {
duration += advert.duration;
}
});
return duration;
}
}, {
key: "play",
value: function play(advert) {
var autoplay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
this.sequenceDuration = this.getSequenceDuration();
this.advert = advert;
var url = advert.files[0].url;

if (this.player !== null) {
this.player.destroy();
}

this.video = document.createElement('video');
this.player = new this.playerConstructor(this.video);
this.registerEvents();
this.player.setup({
file: {
mp4: url
},
volume: this.options.get(option_name["Ob" /* VOLUME */]),
volumeType: this.options.get(option_name["Ub" /* VOLUME_TYPE */]),
autoplay: true
}).load();
this.player.addComponent(this.gui, player_component["b" /* GUI */]);
this.player.trigger(player_event["d" /* AD_START */]);
}
}, {
key: "stop",
value: function stop() {
var _this2 = this;

this.player.trigger(player_event["c" /* AD_END */]);
this.player.destroy();
setTimeout(function () {
_this2.gui.playBigButton.hide();
}, 0);
this.advert.played = true;
this.track(AdvertEvent.COMPLETE);
var next = this.getNext();
this.video.style.display = 'none';

try {
this.video.parentNode.removeChild(this.video);
} catch (e) {}

this.gui.removeGuiComponent('advert-controls');
this.gui.off(player_event["p" /* FULLSCREEN_CHANGED */], this.onFullScreenChanged);

if (next) {
this.play(next);
return;
}

this.trigger(player_event["l" /* DESTROY */]);
this.gui.removeGuiComponent('advert-counter');
this.advert = null;
}
}, {
key: "onReady",
value: function onReady() {
var _this3 = this;

this.video.style.display = '';
this.gui.setCurrentPlayer(this.player);
var controls = this.gui.getGuiComponent(player_component["a" /* CONTROLS */]);
controls.disable();
var advertControls = this.gui.getGuiComponent('advert-controls');

if (!advertControls) {
advertControls = this.gui.addControls('advert-controls', {
cssPrefix: this.options.get(option_name["s" /* CSS_PREFIX */]),
volumeType: this.options.get(option_name["Ub" /* VOLUME_TYPE */]),
hideControls: this.options.get(option_name["L" /* HIDE_CONTROLS */]),
layout: layout.advert,
hideAtStart: this.options.get(option_name["L" /* HIDE_CONTROLS */])
});
advertControls.updateVolumeProgress(this.options.get(option_name["Ob" /* VOLUME */]));
this.gui.registerPlayerEvents(this.player);
this.gui.appendRenderer(this.video);
advertControls.showPause();
}

advertControls.on(advertControls.ControlEvent.PAUSE_BUTTON_CLICKED, function () {
_this3.player.pause();
});
advertControls.on(advertControls.ControlEvent.PLAY_BUTTON_CLICKED, function () {
_this3.player.play();
});
advertControls.on(advertControls.ControlEvent.FULLSCREEN_BUTTON_CLICKED, function () {
_this3.gui.setFullscreen();
});
advertControls.on(advertControls.ControlEvent.VOLUME_CHANGED, function (value) {
_this3.player.setVolume(value);
});
this.gui.on(advertControls.ControlEvent.MOUSE_MOVE, function () {
advertControls.show();
});
this.trigger(player_event["Y" /* READY */]);
}
}, {
key: "destroy",
value: function destroy() {
this.sequence = [];
this.stop();
}
}, {
key: "onError",
value: function onError() {
this.stop();
}
}, {
key: "onEnded",
value: function onEnded() {
this.stop();
}
}, {
key: "onPlaying",
value: function onPlaying() {
this.track(AdvertEvent.START);
this.track(AdvertEvent.CREATIVE_VIEW);
this.track(AdvertEvent.IMPRESSION);
}
}, {
key: "onPaused",
value: function onPaused() {
this.track(AdvertEvent.PAUSE);
}
}, {
key: "onTime",
value: function onTime(time) {
var duration = this.advert.duration || this.player.getDuration();
var remain = Math.round(this.sequenceDuration - time);
this.counter.update(remain);

if (this.advert.duration && time > duration) {
this.stop();
}

var percent = time / duration;

if (this.advert) {
if (percent > 0.75) {
this.track(AdvertEvent.THIRD_QUARTILE);
} else if (percent > 0.5) {
this.track(AdvertEvent.MIDPOINT);
} else if (percent > 0.25) {
this.track(AdvertEvent.FIRST_QUARTILE);
}
}
}
}, {
key: "onVolumeChanged",
value: function onVolumeChanged(volume) {
if (this.volume !== volume) {
if (volume === 0 && this.volume !== 0) {
this.track(AdvertEvent.MUTE);
} else if (volume !== 0 && this.volume === 0) {
this.track(AdvertEvent.UNMUTE);
}
}

this.volume = volume;
this.trigger(player_event["wb" /* VOLUME_CHANGED */], this.volume);
}
}, {
key: "onFullScreenChanged",
value: function onFullScreenChanged(fulscreen) {
if (this.advert) {
if (fulscreen) {
this.track(AdvertEvent.FULLSCREEN);
} else {
this.track(AdvertEvent.EXIT_FULLSCREEN);
}
}
}
}, {
key: "onVideoClick",
value: function onVideoClick() {
if (this.advert.clickThrough) {
window.open(this.advert.clickThrough);
this.player.pause();
}

this.track(AdvertEvent.CLICK_TRACKING);
}
}]);

return AdvertVideo;
}(core_component["a" /* default */]);

/* harmony default export */ var advert_player = (player_AdvertVideo);
// CONCATENATED MODULE: ./src/module/advert/vpaid-ima.js





var AdEventList = ['ALL_ADS_COMPLETED', 'COMPLETE', 'AD_BREAK_READY', 'STARTED', 'PAUSED', 'RESUMED', 'LOADED', 'CONTENT_RESUME_REQUESTED', 'CONTENT_PAUSE_REQUESTED', 'SKIPPED'];

function VPaidIMA(player, url) {
var gui = player.getComponent(player_component["b" /* GUI */]);
var options = player.options;
var cssPrefix = options.get(option_name["s" /* CSS_PREFIX */]);
var playerContainer = gui.getContainer();
var hasControls = !!options.get(option_name["b" /* ADVERT_CONTROLS */]);
var counter = new advert_counter('advert-counter', options);
var contentPlayHeadTracker = {
currentTime: 0,
previousTime: 0,
seeking: false,
duration: 0
};
var adsManager;
var advertControls;
var currentPod;
var intervalTimer = 0;
var isPlayingAd = false;
var isEnded = false;
player.on(player_event["S" /* PLAY_REQUEST */], function () {
if (isPlayingAd && adsManager) {
var _advertControls;

adsManager.resume();
(_advertControls = advertControls) === null || _advertControls === void 0 ? void 0 : _advertControls.showPause();
}
});
player.on(player_event["H" /* PAUSE_REQUEST */], function () {
if (isPlayingAd && adsManager) {
var _advertControls2;

adsManager.pause();
(_advertControls2 = advertControls) === null || _advertControls2 === void 0 ? void 0 : _advertControls2.showPlay();
}
});
player.on(player_event["tb" /* TIME */], function (time, duration) {
contentPlayHeadTracker.currentTime = time;
contentPlayHeadTracker.duration = duration;
});
player.on(player_event["eb" /* SEEK_START */], function () {
contentPlayHeadTracker.seeking = true;
});
player.on(player_event["cb" /* SEEK_END */], function () {
contentPlayHeadTracker.seeking = false;
});
player.on(player_event["n" /* ENDED */], onEnded);
player.on(player_event["ib" /* STOPPED */], onEnded);
gui.on(player_event["p" /* FULLSCREEN_CHANGED */], resize);
var adContainer = new AdContainer('ad-container', cssPrefix);
gui.addGuiComponent(adContainer, 'ad-container');
gui.addGuiComponent(counter, counter.id);
counter.hide();
google.ima.settings.setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED);
var adDisplayContainer = new google.ima.AdDisplayContainer(adContainer.getElm(), player.getRendererElm());
adDisplayContainer.initialize();
var adsLoader = new google.ima.AdsLoader(adDisplayContainer);
var adsRequest = new google.ima.AdsRequest();
adsLoader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, onManagerLoaded);
adsLoader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, onAdsLoaderError);
adsRequest.adTagUrl = url;
adsLoader.requestAds(adsRequest);

function onAdsLoaderError() {
destroy();
player.trigger(player_event["b" /* AD_COMPLETE */]);
player.trigger(player_event["c" /* AD_END */]);
}

function onEnded() {
if (isEnded) {
return;
}

isEnded = true;
adsLoader === null || adsLoader === void 0 ? void 0 : adsLoader.contentComplete();
}

function onManagerLoaded(adsManagerLoadedEvent) {
if (hasControls) {
advertControls = gui.getGuiComponent('advert-controls');

if (!advertControls) {
advertControls = gui.addControls('advert-controls', {
cssPrefix: options.get(option_name["s" /* CSS_PREFIX */]),
volumeType: options.get(option_name["Ub" /* VOLUME_TYPE */]),
hideControls: options.get(option_name["L" /* HIDE_CONTROLS */]),
layout: layout.advert,
hideAtStart: options.get(option_name["L" /* HIDE_CONTROLS */])
});
advertControls.updateVolumeProgress(player.getVolume());
var ControlEvent = advertControls.ControlEvent;
advertControls.on(ControlEvent.PAUSE_BUTTON_CLICKED, function () {
return adsManager.pause();
});
advertControls.on(ControlEvent.PLAY_BUTTON_CLICKED, function () {
return adsManager.resume();
});
advertControls.on(ControlEvent.FULLSCREEN_BUTTON_CLICKED, function () {
return gui.setFullscreen();
});
advertControls.on(ControlEvent.VOLUME_CHANGED, function (volume) {
adsManager.setVolume(volume / 100);
player.setVolume(volume);
});
}

advertControls.setLayout(layout.advert);
}

var adsRenderingSettings = new google.ima.AdsRenderingSettings();
adsRenderingSettings.restoreCustomPlaybackStateOnAdBreakComplete = true;
adsManager = adsManagerLoadedEvent.getAdsManager(contentPlayHeadTracker, adsRenderingSettings);
AdEventList.forEach(function (event) {
adsManager.addEventListener(google.ima.AdEvent.Type[event], onAddEvent);
});
adsManager.addEventListener(google.ima.AdEvent.AD_ERROR, onAddError);
adsManager.init(playerContainer.offsetWidth, playerContainer.offsetHeight, google.ima.ViewMode.NORMAL);
adsManager.start();
}

function showControls() {
advertControls.show();
}

function resize(isFullscreen) {
if (adsManager) {
if (isFullscreen) {
adsManager.resize(window.screen.width, window.screen.height, google.ima.ViewMode.FULLSCREEN);
} else {
adsManager.resize(playerContainer.offsetWidth, playerContainer.offsetHeight, google.ima.ViewMode.NORMAL);
}
}
}

function pause() {
adsManager.pause();
}

function onAddError(error) {//console.log('onAddError: ', error);
}

function onAddEvent(adEvent) {
var ad = adEvent.getAd();
var adPodInfo;

switch (adEvent.type) {
case google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED:
adContainer.hide();
counter.hide();
player.trigger(player_event["c" /* AD_END */]);
player.unFreeze();
currentPod = undefined;

if (!isEnded) {
breakComplete();
} else {
gui.showPlayBigButton();
}

isPlayingAd = false;
break;

case google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED:
player.trigger(player_event["d" /* AD_START */]);
adContainer.show();
counter.show();
player.pause();
player.freeze();
var controls = gui.getGuiComponent(player_component["a" /* CONTROLS */]);

if (controls) {
controls.disable();
}

if (advertControls) {
advertControls.showPause();
advertControls.enable();
gui.on(advertControls.ControlEvent.MOUSE_MOVE, showControls);
showControls();
}

player.pause();
isPlayingAd = true;
gui.hidePlayBigButton();
break;

case google.ima.AdEvent.Type.RESUMED:
break;

case google.ima.AdEvent.Type.PAUSED:
if (advertControls) {
advertControls.showPlay();
}

break;

case google.ima.AdEvent.Type.LOADED:
adsManager.setVolume(player.getVolume() / 100);
break;

case google.ima.AdEvent.Type.SKIPPED:
breakComplete();
break;

case google.ima.AdEvent.Type.AD_BREAK_READY:
break;

case google.ima.AdEvent.Type.ALL_ADS_COMPLETED:
destroy();
player.unFreeze();
player.trigger(player_event["b" /* AD_COMPLETE */]);
break;

case google.ima.AdEvent.Type.COMPLETE:
clearInterval(intervalTimer);
adPodInfo = ad.getAdPodInfo();
break;

case google.ima.AdEvent.Type.STARTED:
counter.show();
gui.hidePlayBigButton();
adPodInfo = ad.getAdPodInfo();

if (typeof currentPod === 'undefined' || adPodInfo.getPodIndex() !== currentPod.index) {
currentPod = new Pod();
currentPod.index = adPodInfo.getPodIndex();
currentPod.duration = adPodInfo.getMaxDuration();
currentPod.remainingDuration = adPodInfo.getMaxDuration();
}

currentPod.duration = ad.getDuration() >= 0 ? currentPod.duration - ad.getDuration() : 0;
adsManager.setVolume(player.getVolume() / 100);
clearInterval(intervalTimer);
intervalTimer = setInterval(function () {
var remainingTime = adsManager.getRemainingTime();

if (remainingTime >= 0) {
counter.update(parseInt(currentPod.duration + remainingTime));
}
}, 300);
break;
}
}

function breakComplete() {
counter.hide();
clearInterval(intervalTimer);

if (advertControls) {
advertControls.disable();
gui.off(advertControls.ControlEvent.MOUSE_MOVE, showControls);
}

player.trigger(player_event["g" /* BREAK_COMPLETE */]);
}

function destroy() {
var _advertControls3, _adsManager;

isPlayingAd = false;
counter.hide();
clearInterval(intervalTimer);
(_advertControls3 = advertControls) === null || _advertControls3 === void 0 ? void 0 : _advertControls3.disable();
(_adsManager = adsManager) === null || _adsManager === void 0 ? void 0 : _adsManager.stop();
gui.removeGuiComponent(advertControls);
gui.removeGuiComponent(adContainer);
setTimeout(function () {
player.off(player_event["n" /* ENDED */], onEnded);
player.off(player_event["ib" /* STOPPED */], onEnded);
}, 1);
}

return {
destroy: destroy,
pause: pause
};
}

function AdContainer(id, cssPrefix) {
var container = document.createElement('div');
container.classList.add(cssPrefix + '-vpaid-container');
return {
id: id,
getElm: function getElm() {
return container;
},
hide: function hide() {
container.style.display = 'none';
},
show: function show() {
container.style.display = 'block';
}
};
}

function Pod() {
this.remainingDuration = -1;
this.duration = -1;
this.index = -1;
this.total = -1;
}

/* harmony default export */ var vpaid_ima = (VPaidIMA);
// CONCATENATED MODULE: ./src/module/advert/index.js










var advert_AdvertModule = /*#__PURE__*/function () {
function AdvertModule(player) {
var _this = this;

classCallCheck_default()(this, AdvertModule);

this.advertService = null;
this.player = player;
this.advertPlayer = null;
this.options = this.player.options;
this.initAutoplay = this.options.get(option_name["g" /* AUTOPLAY */]);
this.advertUrl = this.options.get(option_name["a" /* ADVERT */]);
this.vpaidIma = null;
this.autoplay = this.options.get(option_name["g" /* AUTOPLAY */]);

if (!this.advertUrl) {
return;
}

this.started = false;
this.player.freeze();
this.options.set(option_name["g" /* AUTOPLAY */], false);
this.advertPlayer = undefined;
this.player.on(player_event["r" /* GUI_READY */], function (gui) {
return _this.onGui(gui);
});
this.player.on(player_event["g" /* BREAK_COMPLETE */], function () {
return _this.resume();
});
this.player.on(player_event["b" /* AD_COMPLETE */], function () {
return _this.complete();
});
this.player.on(player_event["S" /* PLAY_REQUEST */], function () {
if (!_this.started) {
_this.init();
}
});
}

createClass_default()(AdvertModule, [{
key: "destroy",
value: function destroy() {
if (this.advertPlayer) {
this.cleanup();
this.advertPlayer.destroy();
this.advertPlayer = null;
this.gui.setCurrentPlayer(this.player);
this.player.stop();
}

if (this.vpaidIma) {
this.vpaidIma.destroy();
}
}
}, {
key: "onGui",
value: function onGui(gui) {
this.gui = gui;
this.volume = this.options.get(option_name["Ob" /* VOLUME */]);

if (!this.autoplay) {
this.gui.blockAutoPlay();
gui.on(gui.ControlEvent.PLAY_BIG_BUTTON_CLICKED, resume);
} else {
this.gui.hidePlayBigButton();
this.init();
}

var ctx = this;

function resume() {
gui.off(gui.ControlEvent.PLAY_BIG_BUTTON_CLICKED, resume);
ctx.init();
}
}
}, {
key: "init",
value: function init() {
var _this2 = this;

this.started = true;
this.gui.unBlockAutoPlay();
this.gui.hidePlayBigButton();
this.destroyFn = this.destroy.bind(this);
this.player.on(player_event["ib" /* STOPPED */], this.destroyFn);
this.player.on(player_event["l" /* DESTROY */], this.destroyFn);
this.options.set('autoplay', false);

if (window.google && window.google.ima && this.options.get('googleIma')) {
this.vpaidIma = new vpaid_ima(this.player, this.advertUrl);
return;
}

this.advertPlayer = new advert_player(this.player, this.options);
this.advertService = new vast();
this.advertService.fetch(this.advertUrl).then(function (adverts) {
return _this2.onLoad(adverts);
})["catch"](function () {
_this2.cleanup();

_this2.resume();
});
}
}, {
key: "onLoad",
value: function onLoad(adverts) {
this.adverts = adverts;
var sequence = this.getSequence(AdvertType.PREROLL);

if (sequence.length) {
this.playSequence(sequence);
} else {
this.cleanup();
this.resume();
}
}
}, {
key: "getSequence",
value: function getSequence(type) {
var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var sequence = [];

switch (type) {
case AdvertType.PREROLL:
sequence = this.adverts.prerolls;
break;
}

return sequence;
}
}, {
key: "playSequence",
value: function playSequence(sequence) {
var _this3 = this;

this.player.getRendererElm().style.display = 'none';
this.advertPlayer.setGui(this.gui);
var controls = this.gui.getGuiComponent(player_component["a" /* CONTROLS */]);
controls.disable();
this.advertPlayer.playSequence(sequence, this.initAutoplay);
this.advertPlayer.on(player_event["wb" /* VOLUME_CHANGED */], function (volume) {
return _this3.player.setVolume(volume);
});
this.advertPlayer.on(player_event["l" /* DESTROY */], function () {
_this3.complete();
});
}
}, {
key: "resume",
value: function resume() {
this.player.getRendererElm().style.display = '';
var controls = this.gui.getGuiComponent(player_component["a" /* CONTROLS */]);

if (controls) {
controls.enable();
controls.updateVolumeProgress(this.player.getVolume());
}

this.gui.setCurrentPlayer(this.player);
this.player.options.set('autoplay', true);
this.player.unFreeze();
this.player.play();
}
}, {
key: "complete",
value: function complete() {
this.cleanup();
this.resume();
}
}, {
key: "cleanup",
value: function cleanup() {
this.player.off(player_event["ib" /* STOPPED */], this.destroyFn);
this.player.off(player_event["l" /* DESTROY */], this.destroyFn);
}
}]);

return AdvertModule;
}();

advert_AdvertModule.enabled = true;
advert_AdvertModule.moduleId = 'advert';
/* harmony default export */ var module_advert = (advert_AdvertModule);
// CONCATENATED MODULE: ./src/module/gstream/index.js




function GStreamModule(player) {
var options = player.options;
var playerId = options.get(option_name["db" /* NAME */]);
var gStreamOpts = options.get(option_name["J" /* GSTREAM */]);

if (typeof gemiusStream === 'undefined' || typeof gStreamOpts === 'undefined') {
return;
}

var eventsQueue = [];
var isNewSent = false;
var isPlaying = false;
var isWaiting = false;
var isStopped = true;
var firstPlayTimestamp = 0;
var opts = core["a" /* default */].extend({
'identifier': '',
'hitcollector': 'https://pro.hit.gemius.pl/gstream.js',
'materialId': null,
'customPackage': [],
'additionalPackage': [],
'treeId': []
}, gStreamOpts);
player.on(player_event["y" /* METADATA */], function () {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
duration = _ref.duration;

var isLive = player.isLive();
eventsQueue.push({
name: 'new',
duration: duration && !isLive ? duration : -1
});

if (isLive && !firstPlayTimestamp) {
firstPlayTimestamp = player.getLiveNowUTC();
}

send();
});
player.on(player_event["O" /* PLAYING */], function (time) {
if (isPlaying) {
return;
}

isStopped = false;
isPlaying = true;
isWaiting = false;
eventsQueue.push({
name: player_event["O" /* PLAYING */],
time: getPlayingTime(time)
});
send();
});
player.on(player_event["G" /* PAUSED */], function (time) {
isPlaying = false;
eventsQueue.push({
name: player_event["G" /* PAUSED */],
time: getPlayingTime(time)
});
send();
});
player.on(player_event["zb" /* WAITING */], function (time) {
if (isWaiting) {
return;
}

isWaiting = true;
isPlaying = false;
eventsQueue.push({
name: 'buffering',
time: getPlayingTime(time)
});
send();
});
player.on(player_event["eb" /* SEEK_START */], function (time) {
isWaiting = false;
eventsQueue.push({
name: 'seekingStarted',
time: getPlayingTime(time)
});
send();
});
player.on(player_event["cb" /* SEEK_END */], function () {
isWaiting = false;
});
player.on(player_event["ib" /* STOPPED */], function (time) {
isPlaying = false;
isWaiting = false;

if (isStopped) {
return;
}

isStopped = true;
eventsQueue.push({
name: player_event["ib" /* STOPPED */],
time: getPlayingTime(time)
});
send();
isNewSent = false;
});
player.on(player_event["n" /* ENDED */], function (time) {
isPlaying = false;
isWaiting = false;

if (isStopped) {
return;
}

isStopped = true;
eventsQueue.push({
name: 'complete',
time: getPlayingTime(time)
});
send();
isNewSent = false;
});
player.on(player_event["l" /* DESTROY */], function () {
var time = 0;

try {
time = parseInt(player.getCurrentTime(), 10);
} catch (ignore) {}

gemiusStream['closeStream'](playerId, opts.materialId, parseInt(getPlayingTime(time), 10));
});

function send() {
var event;

if (!isNewSent) {
for (var i = 0; i < eventsQueue.length; i++) {
if (eventsQueue[i].name === 'new') {
event = eventsQueue[i];
eventsQueue.splice(i, 1);
gemiusStream['newStream'](playerId, opts.materialId, parseInt(event.duration, 10), opts.customPackage, opts.additionalPackage, opts.identifier, opts.hitcollector, opts.treeId);
isNewSent = true;
send();
break;
}
}
} else {
while (eventsQueue.length) {
event = eventsQueue.shift();
gemiusStream['event'](playerId, opts.materialId, parseInt(event.time, 10), event.name);
}
}
}

function getPlayingTime(time) {
if (!player.isLive()) {
return time;
}

var timeShift = player.getTimeShift();
var isTimeshiftEnabled = timeShift.isEnabled();
var initialStart = timeShift.getInitialStart();
var dvrWindow = timeShift.getDvrWindow();
var liveNowUTC = player.getLiveNowUTC();
var isDvr = isTimeshiftEnabled && initialStart > 0 && dvrWindow >= 0;

if (!isTimeshiftEnabled) {
return firstPlayTimestamp ? liveNowUTC - firstPlayTimestamp : 0;
} else if (isDvr) {
var buffer = liveNowUTC - initialStart - dvrWindow;
return time + buffer;
} else {
return time;
}
}
}

GStreamModule.enabled = true;
GStreamModule.moduleId = 'gstream';
/* harmony default export */ var gstream = (GStreamModule);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/toConsumableArray.js
var toConsumableArray = __webpack_require__(16);
var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/slicedToArray.js
var slicedToArray = __webpack_require__(8);
var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/assertThisInitialized.js
var assertThisInitialized = __webpack_require__(24);
var assertThisInitialized_default = /*#__PURE__*/__webpack_require__.n(assertThisInitialized);

// CONCATENATED MODULE: ./src/core/enum/button-name.js
var CAST = 'cast';
var FULLSCREEN = 'fullscreen';
var JUMP_BACKWARD = 'jump-backward';
var JUMP_FORWARD = 'jump-forward';
var LIVE = 'live';
var PAUSE = 'pause';
var PIP = 'pip';
var PLAY = 'play';
var PLAY_BIG = 'play-big';
var PLAY_PAUSE = 'play-pause';
var SETTINGS = 'settings';
var SETTINGS_ELEMENT = 'settings-element';
var SUBTITLE = 'subtitle';
var VOLUME = 'volume';
var VOLUME_PROGRESS = 'volume-progress';
// EXTERNAL MODULE: ./src/core/event/control-event.js
var control_event = __webpack_require__(18);

// EXTERNAL MODULE: ./src/core/util/browser.js
var browser = __webpack_require__(21);

// CONCATENATED MODULE: ./src/core/enum/fullscreen-api.js
var EXIT_FULLSCREEN = 'exitFullscreen';
var FULLSCREEN_CHANGE = 'fullscreenchange';
var FULLSCREEN_ELEMENT = 'fullscreenElement';
var FULLSCREEN_ENABLED = 'fullscreenEnabled';
var FULLSCREEN_ERROR = 'fullscreenerror';
var REQUEST_FULLSCREEN = 'requestFullscreen';
// CONCATENATED MODULE: ./src/core/util/fullscreen.js


var isIOS = browser["a" /* default */].isIOS();
var fullscreenApiMap = [[EXIT_FULLSCREEN, REQUEST_FULLSCREEN, FULLSCREEN_ELEMENT, FULLSCREEN_ENABLED, FULLSCREEN_CHANGE, FULLSCREEN_ERROR], ['webkitExitFullscreen', 'webkitRequestFullscreen', 'webkitFullscreenElement', 'webkitFullscreenEnabled', 'webkitfullscreenchange', 'webkitfullscreenerror'], ['webkitCancelFullScreen', 'webkitRequestFullScreen', 'webkitCurrentFullScreenElement', 'webkitCancelFullScreen', 'webkitfullscreenchange', 'webkitfullscreenerror'], ['mozCancelFullScreen', 'mozRequestFullScreen', 'mozFullScreenElement', 'mozFullScreenEnabled', 'mozfullscreenchange', 'mozfullscreenerror'], ['msExitFullscreen', 'msRequestFullscreen', 'msFullscreenElement', 'msFullscreenEnabled', 'MSFullscreenChange', 'MSFullscreenError']];

var getFullscreenApi = function getFullscreenApi() {
var browserApi;
var api = null;

for (var i = 0; i < fullscreenApiMap.length; i++) {
if (fullscreenApiMap[i][0] in document) {
browserApi = fullscreenApiMap[i];
break;
}
}

if (browserApi) {
api = {};

for (var _i = 0; _i < browserApi.length; _i++) {
api[fullscreenApiMap[0][_i]] = browserApi[_i];
}
}

return api;
};

var getFullscreenContainer = function getFullscreenContainer(container) {
return container.tagName !== 'VIDEO' ? container.querySelector('video') : container;
};

var fullscreen_toggleFullscreen = function toggleFullscreen(container) {
if (isIOS) {
var fullscreenContainer = getFullscreenContainer(container);

if (fullscreen_isFullscreen(container)) {
fullscreenContainer.webkitExitFullscreen();
} else {
fullscreenContainer.webkitEnterFullScreen();
}
}

if (fullscreenApi) {
if (fullscreen_isFullscreen(container)) {
document[fullscreenApi[EXIT_FULLSCREEN]]();
} else {
container[fullscreenApi[REQUEST_FULLSCREEN]]();
}
}
};
var fullscreen_isFullscreen = function isFullscreen(container) {
if (isIOS && container) {
var fullscreenContainer = getFullscreenContainer(container);
return !!fullscreenContainer.webkitDisplayingFullscreen;
}

if (fullscreenApi) {
return !!document[fullscreenApi[FULLSCREEN_ELEMENT]];
}
};
var fullscreenApi = getFullscreenApi();
// EXTERNAL MODULE: ./src/core/timeshift.js
var timeshift = __webpack_require__(28);

// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/defineProperty.js
var defineProperty = __webpack_require__(2);
var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);

// CONCATENATED MODULE: ./src/module/gui/i18n/i18n.en.js
/* harmony default export */ var i18n_en = ({
'en': 'English',
'eng': 'English',
'pol': 'Polish',
'und': 'Original',
'HELP_CHROMECAST': 'Play on TV',
'HELP_FULLSCREEN_OFF': 'Exit fullscreen',
'HELP_FULLSCREEN_ON': 'Fullscreen',
'HELP_PAUSE': 'Pause',
'HELP_PIP': 'Miniplayer',
'HELP_PLAY': 'Play',
'HELP_SEEK': 'Seek',
'HELP_SETTINGS': 'Settings',
'HELP_SPACE': 'space',
'HELP_SUBTITLE_OFF': 'Disable subtitle',
'HELP_SUBTITLE_ON': 'Enable subtitle',
'HELP_VOLUME': 'Volume',
'HELP_VOLUME_OFF': 'Mute',
'HELP_VOLUME_ON': 'Unmute',
'LIVE': 'LIVE',
'NONE': 'none',
'PLAYBACK_RATE': 'Playback rate',
'PROFILE': 'Profile',
'SETTINGS': 'Settings',
'SUBTITLES': 'Subtitles',
'UNMUTE_MESSAGE': 'Click to unmute'
});
// CONCATENATED MODULE: ./src/module/gui/i18n/i18n.pl.js
/* harmony default export */ var i18n_pl = ({
'en': 'Angielski',
'eng': 'Angielski',
'pol': 'Polski',
'und': 'Oryginalny',
'HELP_CHROMECAST': 'Odtwórz na telewizorze',
'HELP_FULLSCREEN_OFF': 'Wyłącz pełny ekran',
'HELP_FULLSCREEN_ON': 'Pełny ekran',
'HELP_PAUSE': 'Wstrzymaj',
'HELP_PIP': 'Miniodtwarzacz',
'HELP_PLAY': 'Odtwórz',
'HELP_SEEK': 'Suwak przewijania',
'HELP_SETTINGS': 'Ustawienia',
'HELP_SPACE': 'spacja',
'HELP_SUBTITLE_OFF': 'Wyłącz napisy',
'HELP_SUBTITLE_ON': 'Włącz napisy',
'HELP_VOLUME': 'Głośność',
'HELP_VOLUME_OFF': 'Wycisz',
'HELP_VOLUME_ON': 'Wyłącz wyciszenie',
'LIVE': 'LIVE',
'NONE': 'brak',
'PLAYBACK_RATE': 'Prędkość',
'PROFILE': 'Jakość',
'SETTINGS': 'Ustawienia',
'SUBTITLES': 'Napisy',
'UNMUTE_MESSAGE': 'Kliknij, aby włączyć dźwięk'
});
// CONCATENATED MODULE: ./src/module/gui/i18n/i18n.js


function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }




function I18n() {
var language = 'pl';
var i18n = {};

function set(language, keys) {
i18n[language] = _objectSpread({}, i18n[language], {}, keys);
}

function setLanguage(_language, defaultLanguage) {
language = _language;

if (!i18n[language]) {
language = i18n[defaultLanguage] ? defaultLanguage : Object.keys(i18n)[0];
}
}

function get(key, fallback) {
if (language in i18n && key in i18n[language]) {
return i18n[language][key];
}

return fallback !== undefined ? fallback : key;
}

function getLanguage() {
return language;
}

function getLanguages() {
return Object.keys(i18n);
}

return {
get: get,
set: set,
setLanguage: setLanguage,
getLanguage: getLanguage,
getLanguages: getLanguages
};
}

var i18n = new I18n();
i18n.set('en', i18n_en);
i18n.set('pl', i18n_pl);
/* harmony default export */ var i18n_i18n = (i18n);
// EXTERNAL MODULE: ./src/core/util/event-emitter.js
var event_emitter = __webpack_require__(17);

// CONCATENATED MODULE: ./src/core/util/dom.js
var Dom = {
createElm: function createElm(tag, cls) {
var elm = document.createElement(tag);

if (cls) {
elm.classList.add(cls);
}

return elm;
},
getPosition: function getPosition(elm) {
var xPosition = 0;
var yPosition = 0;

while (elm) {
xPosition += elm.offsetLeft - elm.scrollLeft + elm.clientLeft;
yPosition += elm.offsetTop - elm.scrollTop + elm.clientTop;
elm = elm.offsetParent;
}

xPosition += document.body.scrollLeft;
yPosition += document.body.scrollTop;
return {
x: xPosition,
y: yPosition
};
},
getStyle: function getStyle(elm, style) {
var value;

if (elm.currentStyle) {
value = elm.currentStyle[style];
} else if (window.getComputedStyle) {
value = document.defaultView.getComputedStyle(elm, null).getPropertyValue(style);
}

return value;
},
getIntegerStyle: function getIntegerStyle(elm, style, defaultValue) {
var value = parseInt(Dom.getStyle(elm, style));
defaultValue = defaultValue || 0;

if (isNaN(value)) {
return defaultValue;
}

return value;
}
};
/* harmony default export */ var dom = (Dom);
// CONCATENATED MODULE: ./src/core/enum/constants.js
var CONTROL_FOCUS_CLASS = 'rgpl-control-item-focused';
// CONCATENATED MODULE: ./src/module/gui/control/button/button.js







function button_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (button_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function button_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }





var TOOLTIP_MARGIN = 4;

var button_Button = /*#__PURE__*/function (_EventEmitter) {
inherits_default()(Button, _EventEmitter);

var _super = button_createSuper(Button);

function Button(id, cssPrefix) {
var _this;

var tag = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'div';

classCallCheck_default()(this, Button);

_this = _super.call(this);
_this.id = id;
_this.cssPrefix = cssPrefix;
_this.className = "".concat(_this.cssPrefix, "-btn-").concat(id);
_this.elm = dom.createElm(tag, _this.className);
_this.elm.dataset.button = id;
_this.isDisabled = false;
_this.stopPropagation = false;
_this.hideClass = undefined;
_this.ariaLabel = false;
_this.tooltipText = undefined;
_this.tooltipContainer = undefined;
_this.tooltipElm = document.createElement('div');
_this.tooltipClass = "".concat(_this.cssPrefix, "-btn-tooltip");

_this.tooltipElm.classList.add(_this.tooltipClass);

_this.tooltipElm.classList.add("".concat(_this.tooltipClass, "-").concat(_this.id));

_this.showTimeout = -1;

_this.registerClickEvent();

return _this;
}

createClass_default()(Button, [{
key: "registerClickEvent",
value: function registerClickEvent() {
var _this2 = this;

this.elm.addEventListener(dom_event["b" /* CLICK */], function (event) {
return _this2.onClick(event);
});
this.elm.addEventListener(dom_event["g" /* MOUSE_ENTER */], function () {
return _this2.onButtonMouseEnter();
});
this.elm.addEventListener(dom_event["h" /* MOUSE_LEAVE */], function () {
return _this2.onButtonMouseLeave();
});
this.elm.addEventListener(dom_event["a" /* BLUR */], function () {
return _this2.onBlur();
});
this.elm.addEventListener(dom_event["c" /* FOCUS */], function () {
return _this2.onFocus();
});
this.elm.addEventListener(dom_event["d" /* FOCUS_WITH_TAB */], function () {
return _this2.addClass(CONTROL_FOCUS_CLASS);
});
}
}, {
key: "onClick",
value: function onClick(event) {
if (this.isDisabled) {
return;
}

this.removeClass(CONTROL_FOCUS_CLASS);

if (this.stopPropagation) {
event.stopPropagation();
}

this.trigger(dom_event["b" /* CLICK */], event);
}
}, {
key: "onButtonMouseEnter",
value: function onButtonMouseEnter() {
if (this.tooltipText) {
var parent = this.tooltipContainer || this.elm.parentNode;
this.tooltipElm.innerHTML = this.tooltipText;
parent.appendChild(this.tooltipElm);
this.updateTooltipPosition();
}
}
}, {
key: "onButtonMouseLeave",
value: function onButtonMouseLeave() {
if (this.tooltipText) {
var parent = this.tooltipContainer || this.elm.parentNode;
parent === null || parent === void 0 ? void 0 : parent.removeChild(this.tooltipElm);
}
}
}, {
key: "onFocus",
value: function onFocus() {
this.trigger(dom_event["c" /* FOCUS */]);
}
}, {
key: "onBlur",
value: function onBlur() {
this.trigger(dom_event["a" /* BLUR */]);
this.removeClass(CONTROL_FOCUS_CLASS);
}
}, {
key: "handleKeyEvent",
value: function handleKeyEvent() {
this.addFocusClass();
return true;
}
}, {
key: "addFocusClass",
value: function addFocusClass() {
this.addClass(CONTROL_FOCUS_CLASS);
}
}, {
key: "updateTooltipPosition",
value: function updateTooltipPosition() {
var parent = this.tooltipContainer || this.elm.parentNode;
var position = this.elm.getBoundingClientRect().left - parent.getBoundingClientRect().left;
position -= this.tooltipElm.offsetWidth / 2 - this.elm.offsetWidth / 2;

if (position + this.tooltipElm.offsetWidth > parent.offsetWidth) {
position = parent.offsetWidth - this.tooltipElm.offsetWidth - TOOLTIP_MARGIN;
}

if (position < 0) {
position = TOOLTIP_MARGIN;
}

this.tooltipElm.style.left = "".concat(position, "px");
}
}, {
key: "enableTooltip",
value: function enableTooltip() {
this.tooltipElm.classList.remove("".concat(this.tooltipClass, "--disabled"));
}
}, {
key: "disableTooltip",
value: function disableTooltip() {
this.tooltipElm.classList.add("".concat(this.tooltipClass, "--disabled"));
}
}, {
key: "setTooltipText",
value: function setTooltipText(txt) {
this.tooltipText = txt;
this.updateAriaLabel(this.tooltipText);
}
}, {
key: "setTooltipContainer",
value: function setTooltipContainer(container) {
this.tooltipContainer = container;
}
}, {
key: "append",
value: function append(elm) {
this.elm.appendChild(elm.getElm());
}
}, {
key: "getElm",
value: function getElm() {
return this.elm;
}
}, {
key: "addClass",
value: function addClass() {
var _this$elm$classList;

(_this$elm$classList = this.elm.classList).add.apply(_this$elm$classList, arguments);
}
}, {
key: "removeClass",
value: function removeClass() {
var _this$elm$classList2;

(_this$elm$classList2 = this.elm.classList).remove.apply(_this$elm$classList2, arguments);
}
}, {
key: "removeAllClasses",
value: function removeAllClasses() {
var _this$elm$classList3;

(_this$elm$classList3 = this.elm.classList).remove.apply(_this$elm$classList3, toConsumableArray_default()(this.elm.classList));
}
}, {
key: "hasClass",
value: function hasClass(cls) {
return this.elm.classList.contains(cls);
}
}, {
key: "hide",
value: function hide() {
clearTimeout(this.showTimeout);

if (this.hideClass) {
this.addClass(this.hideClass);
} else {
this.elm.style.display = 'none';
}
}
}, {
key: "show",
value: function show() {
var _this3 = this;

var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;

if (timeout > 0) {
this.showTimeout = setTimeout(function () {
if (_this3.hideClass) {
_this3.removeClass(_this3.hideClass);
} else {
_this3.elm.style.display = 'block';
}
}, timeout);
} else {
if (this.hideClass) {
this.removeClass(this.hideClass);
} else {
this.elm.style.display = 'block';
}
}
}
}, {
key: "disable",
value: function disable() {
this.isDisabled = true;
this.addClass('button-disabled');
}
}, {
key: "enable",
value: function enable() {
this.isDisabled = false;
this.removeClass('button-disabled');
}
}, {
key: "setTabIndex",
value: function setTabIndex() {
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
this.elm.setAttribute('tabindex', index);
}
}, {
key: "enableAriaLabel",
value: function enableAriaLabel() {
this.ariaLabel = true;

if (this.tooltipText) {
this.updateAriaLabel(this.tooltipText);
}
}
}, {
key: "updateAriaLabel",
value: function updateAriaLabel(label) {
this.elm.setAttribute('aria-label', label);
}
}]);

return Button;
}(event_emitter["a" /* default */]);


// CONCATENATED MODULE: ./src/module/gui/control/button/fullscreen.js






function fullscreen_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (fullscreen_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function fullscreen_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }



var fullscreen_FullscreenButton = /*#__PURE__*/function (_Button) {
inherits_default()(FullscreenButton, _Button);

var _super = fullscreen_createSuper(FullscreenButton);

function FullscreenButton(id, cssPrefix) {
var _this;

classCallCheck_default()(this, FullscreenButton);

_this = _super.call(this, id, cssPrefix);
_this.fullscreenOnText = undefined;
_this.fullscreenOffText = undefined;
_this.btnClass = "".concat(cssPrefix, "-btn-").concat(_this.id);
return _this;
}

createClass_default()(FullscreenButton, [{
key: "update",
value: function update(isFullscreen) {
this.tooltipText = isFullscreen ? this.fullscreenOffText : this.fullscreenOnText;
this.removeClass("".concat(this.btnClass, "--on"), "".concat(this.btnClass, "--off"));
this.addClass("".concat(this.btnClass, "--").concat(isFullscreen ? 'off' : 'on'));
this.updateTooltipPosition();
this.updateAriaLabel(this.tooltipText);
}
}, {
key: "setTooltipText",
value: function setTooltipText(fullscreenOnText, fullscreenOffText) {
this.fullscreenOnText = fullscreenOnText;
this.fullscreenOffText = fullscreenOffText;
this.update(false);
}
}]);

return FullscreenButton;
}(button_Button);


// CONCATENATED MODULE: ./src/module/gui/control/button/play-pause.js






function play_pause_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (play_pause_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function play_pause_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }




var play_pause_PlayPause = /*#__PURE__*/function (_Button) {
inherits_default()(PlayPause, _Button);

var _super = play_pause_createSuper(PlayPause);

function PlayPause(id, cssPrefix) {
var _this;

classCallCheck_default()(this, PlayPause);

_this = _super.call(this, id, cssPrefix);
_this.elm.dataset.button = id;
_this.playButton = new button_Button(PLAY, cssPrefix);
_this.pauseButton = new button_Button(PAUSE, cssPrefix);

_this.elm.appendChild(_this.playButton.getElm());

_this.elm.appendChild(_this.pauseButton.getElm());

return _this;
}

createClass_default()(PlayPause, [{
key: "getPlay",
value: function getPlay() {
return this.playButton;
}
}, {
key: "getPause",
value: function getPause() {
return this.pauseButton;
}
}]);

return PlayPause;
}(button_Button);


// CONCATENATED MODULE: ./src/module/gui/control/button/volume.js







var _PropertyName;

function volume_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (volume_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function volume_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }







var Layout = {
HORIZONTAL: 'horizontal',
VERTICAL: 'vertical'
};
var PropertyName = (_PropertyName = {}, defineProperty_default()(_PropertyName, Layout.VERTICAL, {
OFFSET_SIZE: 'offsetHeight',
SIZE: 'height',
POSITION: 'bottom'
}), defineProperty_default()(_PropertyName, Layout.HORIZONTAL, {
OFFSET_SIZE: 'offsetWidth',
SIZE: 'width',
POSITION: 'left'
}), _PropertyName);

var volume_Volume = /*#__PURE__*/function (_Button) {
inherits_default()(Volume, _Button);

var _super = volume_createSuper(Volume);

function Volume(id, cssPrefix, volumeType) {
var _this;

classCallCheck_default()(this, Volume);

_this = _super.call(this, id, cssPrefix);
_this.volume = 0;
_this.level = 0;
_this.volumeType = volumeType || Layout.HORIZONTAL;
_this.propertyName = PropertyName[_this.volumeType];
_this.showTimeout = 0;
_this.hideTimeout = 0;
_this.isMute = false;
_this.elm = dom.createElm('div', "".concat(_this.cssPrefix, "-volume-control"));

_this.addClass("".concat(_this.cssPrefix, "-volume-control-").concat(_this.volumeType));

_this.volumeButton = new volume_VolumeButton(VOLUME, _this.cssPrefix);
_this.volumeButton.tooltipContainer = _this.tooltipContainer;

_this.elm.appendChild(_this.volumeButton.elm);

_this.controlBarButton = new button_Button(VOLUME_PROGRESS, _this.cssPrefix);

_this.controlBarButton.addClass("".concat(_this.cssPrefix, "-volume-control-bar"));

_this.controlBar = _this.controlBarButton.elm;

_this.elm.appendChild(_this.controlBar);

_this.controlBar.setAttribute('aria-valuemin', 0);

_this.controlBar.setAttribute('aria-valuemax', 100);

_this.controlBar.setAttribute('role', 'slider');

_this.controlBar.setAttribute('aria-label', i18n_i18n.get('HELP_VOLUME'));

_this.controlBarSlider = dom.createElm('div', "".concat(_this.cssPrefix, "-volume-control-slider"));
_this.controlActionArea = dom.createElm('div', "".concat(_this.cssPrefix, "-volume-control-action"));
_this.controlBarProgress = dom.createElm('div', "".concat(_this.cssPrefix, "-volume-control-progress"));
_this.controlDrag = dom.createElm('div', "".concat(_this.cssPrefix, "-volume-control-drag"));

_this.controlBar.appendChild(_this.controlBarSlider);

_this.controlBar.appendChild(_this.controlActionArea);

_this.controlBarSlider.appendChild(_this.controlBarProgress);

_this.controlBarSlider.appendChild(_this.controlDrag);

_this.onWindowMouseUpHandler = function () {
return _this.onWindowMouseUp();
};

_this.onWindowMouseMoveHandler = function (event) {
return _this.onWindowMouseMove(event);
};

_this.registerEvents();

return _this;
}

createClass_default()(Volume, [{
key: "setTabIndex",
value: function setTabIndex() {
var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
this.controlBarButton.setTabIndex();
this.volumeButton.setTabIndex();
}
}, {
key: "setTooltipText",
value: function setTooltipText() {
var _this$volumeButton;

(_this$volumeButton = this.volumeButton).setTooltipText.apply(_this$volumeButton, arguments);
}
}, {
key: "setTooltipContainer",
value: function setTooltipContainer(container) {
this.volumeButton.setTooltipContainer(container);
}
}, {
key: "registerEvents",
value: function registerEvents() {
var _this2 = this;

this.elm.addEventListener(dom_event["g" /* MOUSE_ENTER */], function () {
return _this2.onMouseEnter();
});
this.elm.addEventListener(dom_event["h" /* MOUSE_LEAVE */], function () {
return _this2.onMouseLeave();
});
this.elm.addEventListener(dom_event["i" /* MOUSE_MOVE */], function () {
return _this2.onMouseEnter();
});
this.controlActionArea.addEventListener(dom_event["f" /* MOUSE_DOWN */], function (event) {
return _this2.onControlActionAreaMouseDown(event);
});
this.volumeButton.elm.addEventListener(dom_event["f" /* MOUSE_DOWN */], function () {
return _this2.onVolumeButtonClick();
});
}
}, {
key: "show",
value: function show() {
var _this3 = this;

clearTimeout(this.hideTimeout);
clearTimeout(this.showTimeout);
this.showTimeout = setTimeout(function () {
_this3.controlBar.classList.add('visible');

_this3.controlBar.classList.remove('hidden');

_this3.updateVolumeProgress(_this3.volume, _this3.isMute);
}, 100);
}
}, {
key: "hide",
value: function hide() {
if (this.volumeType === Layout.VERTICAL) {
this.controlBar.classList.remove('visible');
this.controlBar.classList.add('hidden');
}
}
}, {
key: "onVolumeButtonClick",
value: function onVolumeButtonClick() {
this.isMute = !this.isMute;
this.setMuted(this.isMute);
}
}, {
key: "onControlActionAreaMouseDown",
value: function onControlActionAreaMouseDown(event) {
event.preventDefault();
this.handleMouseEvent(event);
window.addEventListener(dom_event["i" /* MOUSE_MOVE */], this.onWindowMouseMoveHandler);
window.addEventListener(dom_event["j" /* MOUSE_UP */], this.onWindowMouseUpHandler);
}
}, {
key: "onWindowMouseMove",
value: function onWindowMouseMove(event) {
this.handleMouseEvent(event);
}
}, {
key: "handleMouseEvent",
value: function handleMouseEvent(event) {
var _this$controlActionAr = this.controlActionArea.getBoundingClientRect(),
left = _this$controlActionAr.left,
top = _this$controlActionAr.top,
height = _this$controlActionAr.height;

var size = this.controlActionArea[this.propertyName.OFFSET_SIZE];
var position = this.volumeType === Layout.HORIZONTAL ? event.clientX - left : -(event.clientY - top - height);
var percentVolume = Math.max(0, Math.min(position / size * 100, 100));
this.isMute = percentVolume === 0;
this.volume = percentVolume;
this.setVolume(percentVolume);
this.updateVolumeProgress(percentVolume, this.isMute);
}
}, {
key: "onWindowMouseUp",
value: function onWindowMouseUp() {
window.removeEventListener(dom_event["i" /* MOUSE_MOVE */], this.onWindowMouseMoveHandler);
window.removeEventListener(dom_event["j" /* MOUSE_UP */], this.onWindowMouseUpHandler);
}
}, {
key: "setVolume",
value: function setVolume(volume) {
this.volume = volume;
this.trigger(control_event["VOLUME_MUTE_STATE_CHANGED"], volume === 0);
this.trigger(control_event["VOLUME_CHANGED"], this.volume);
this.updateVolumeProgress(volume, this.isMute);
}
}, {
key: "setMuted",
value: function setMuted(muted) {
this.trigger(control_event["VOLUME_MUTE_STATE_CHANGED"], muted);
}
}, {
key: "update",
value: function update() {
this.updateVolumeProgress(this.volume, this.isMute);
}
}, {
key: "updateVolumeProgress",
value: function updateVolumeProgress(value, muted) {
var level = muted ? 0 : value;
var position;
var areaSize;
this.volume = value;
this.isMute = muted;

if (this.isMute) {
this.updateGui(0);
this.volumeButton.update(level, this.isMute);
return;
}

if (typeof value === 'undefined') {
return;
}

areaSize = this.controlActionArea[this.propertyName.OFFSET_SIZE];
position = areaSize / 100 * level;

if (position > areaSize - 4) {
position = areaSize - 4;
}

this.volumeButton.update(level, this.isMute);
this.updateGui(position);
var volumeValue = parseInt(level, 10);
this.controlBar.setAttribute('aria-valuetext', "".concat(volumeValue, "%"));
this.controlBar.setAttribute('aria-valuenow', volumeValue);
}
}, {
key: "updateGui",
value: function updateGui(position) {
var dragRadius = this.controlDrag[this.propertyName.OFFSET_SIZE] / 2;
position = Math.max(position, dragRadius);
this.controlBarProgress.style[this.propertyName.SIZE] = "".concat(position, "px");
this.controlDrag.style[this.propertyName.POSITION] = "".concat(position - dragRadius, "px");
}
}, {
key: "onMouseEnter",
value: function onMouseEnter() {
this.show();
}
}, {
key: "onMouseLeave",
value: function onMouseLeave() {
var _this4 = this;

clearTimeout(this.showTimeout);
this.hideTimeout = setTimeout(function () {
return _this4.hide();
}, 600);
}
}]);

return Volume;
}(button_Button);



var volume_VolumeButton = /*#__PURE__*/function (_Button2) {
inherits_default()(VolumeButton, _Button2);

var _super2 = volume_createSuper(VolumeButton);

function VolumeButton(id, cssPrefix) {
var _this5;

classCallCheck_default()(this, VolumeButton);

_this5 = _super2.call(this, id, cssPrefix);
_this5.muted = false;
_this5.volumeOnTxt = undefined;
_this5.volumeOffTxt = undefined;
return _this5;
}

createClass_default()(VolumeButton, [{
key: "update",
value: function update(volume, muted) {
var className = "".concat(this.cssPrefix, "-btn-volume");
var classSuffix = 25;
this.muted = muted;
this.volume = volume;

if (volume === 0) {
classSuffix = 0;
} else if (volume > 50) {
classSuffix = 50;
}

if (muted) {
classSuffix = 0;
}

this.removeClass("".concat(className, "-0"), "".concat(className, "-25"), "".concat(className, "-50"));
this.addClass(className);
this.addClass("".concat(className, "-").concat(classSuffix));
this.updateTooltipText();
this.enableAriaLabel();
}
}, {
key: "updateTooltipText",
value: function updateTooltipText() {
this.tooltipText = this.muted || !this.volume ? this.volumeOnTxt : this.volumeOffTxt;
this.tooltipElm.innerHTML = this.tooltipText;
this.updateTooltipPosition();
}
}, {
key: "setTooltipText",
value: function setTooltipText(volumeOnTxt, volumeOffTxt) {
this.volumeOnTxt = volumeOnTxt;
this.volumeOffTxt = volumeOffTxt;
}
}]);

return VolumeButton;
}(button_Button);
// CONCATENATED MODULE: ./src/module/gui/control/button/live.js






function live_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (live_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function live_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }




var live_Stop = /*#__PURE__*/function (_Button) {
inherits_default()(Stop, _Button);

var _super = live_createSuper(Stop);

function Stop(id, player) {
var _this;

classCallCheck_default()(this, Stop);

_this = _super.call(this, id, player);
_this.hideClass = "".concat(_this.className, "--hidden");
_this.button = dom.createElm('button');
_this.button.innerHTML = 'LIVE';
_this.button.tabIndex = '-1';

_this.elm.appendChild(_this.button);

_this.hide();

return _this;
}

createClass_default()(Stop, [{
key: "getElm",
value: function getElm() {
return this.elm;
}
}, {
key: "disableLive",
value: function disableLive() {
this.addClass('timeshift-live-mode-off');
}
}, {
key: "enableLive",
value: function enableLive() {
this.removeClass('timeshift-live-mode-off');
}
}, {
key: "setLabel",
value: function setLabel(text) {
this.button.innerHTML = text;
}
}]);

return Stop;
}(button_Button);


// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/get.js
var get = __webpack_require__(34);
var get_default = /*#__PURE__*/__webpack_require__.n(get);

// CONCATENATED MODULE: ./src/module/gui/control/time-display.js







function time_display_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (time_display_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function time_display_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }





var time_display_TimeDisplay = /*#__PURE__*/function (_Button) {
inherits_default()(TimeDisplay, _Button);

var _super = time_display_createSuper(TimeDisplay);

function TimeDisplay(id, player) {
var _this;

classCallCheck_default()(this, TimeDisplay);

_this = _super.call(this, id, player);
_this.id = id;
_this.elm = dom.createElm('div', "".concat(_this.cssPrefix, "-controls-time"));
_this.currentElm = dom.createElm('span', "".concat(_this.cssPrefix, "-controls-time-current"));
_this.separatorElm = dom.createElm('span', "".concat(_this.cssPrefix, "-controls-time-separator"));
_this.durationElm = dom.createElm('span', "".concat(_this.cssPrefix, "-controls-time-duration"));
_this.currentElm.innerHTML = '00:00';
_this.separatorElm.innerHTML = ' / ';
_this.durationElm.innerHTML = '00:00';

_this.elm.appendChild(_this.currentElm);

_this.elm.appendChild(_this.separatorElm);

_this.elm.appendChild(_this.durationElm);

_this.width = _this.elm.offsetWidth;
return _this;
}

createClass_default()(TimeDisplay, [{
key: "setTabIndex",
value: function setTabIndex() {
get_default()(getPrototypeOf_default()(TimeDisplay.prototype), "setTabIndex", this).call(this, -1);
}
}, {
key: "update",
value: function update(time, duration) {
if (!isNaN(time) && !isNaN(duration)) {
this.currentElm.innerHTML = core["a" /* default */].formatTime(time);
this.durationElm.innerHTML = core["a" /* default */].formatTime(duration);
}

if (this.width !== this.elm.offsetWidth) {
this.width = this.elm.offsetWidth;
}
}
}, {
key: "updateDate",
value: function updateDate(time) {
this.separatorElm.style.display = 'none';
this.durationElm.style.display = 'none';

if (!isNaN(time)) {
this.currentElm.innerHTML = core["a" /* default */].formatDateTime(new Date(time)).split(' ')[1];
}
}
}]);

return TimeDisplay;
}(button_Button);


// CONCATENATED MODULE: ./src/module/gui/control/progress.js






function progress_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (progress_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function progress_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }









var progress_ProgressControl = /*#__PURE__*/function (_Button) {
inherits_default()(ProgressControl, _Button);

var _super = progress_createSuper(ProgressControl);

function ProgressControl(id, cssPrefix) {
var _this;

classCallCheck_default()(this, ProgressControl);

_this = _super.call(this, id, cssPrefix);
_this.id = id;
_this.elm = dom.createElm('div', "".concat(_this.cssPrefix, "-progress-control"));

_this.elm.addEventListener(dom_event["a" /* BLUR */], function () {
return _this.elm.classList.remove(CONTROL_FOCUS_CLASS);
});

_this.elm.addEventListener(dom_event["d" /* FOCUS_WITH_TAB */], function () {
return _this.elm.classList.add(CONTROL_FOCUS_CLASS);
});

_this.innerElm = dom.createElm('div', "".concat(_this.cssPrefix, "-progress-control-inner"));

_this.elm.appendChild(_this.innerElm);

_this.elm.setAttribute('aria-label', i18n_i18n.get('HELP_SEEK'));

_this.elm.setAttribute('role', 'slider');

_this.barElm = dom.createElm('div', "".concat(_this.cssPrefix, "-progress-bar"));

_this.innerElm.appendChild(_this.barElm);

_this.videoElm = dom.createElm('div', "".concat(_this.cssPrefix, "-progress-video"));

_this.barElm.appendChild(_this.videoElm);

_this.tooltip = dom.createElm('div', "".concat(_this.cssPrefix, "-progress-tooltip"));

_this.elm.appendChild(_this.tooltip);

_this.drag = dom.createElm('div', "".concat(_this.cssPrefix, "-progress-control-drag"));

_this.innerElm.appendChild(_this.drag);

_this.isSeeking = false;
_this.duration = 0;
_this.percentPosition = 0;

_this.onWindowMouseMoveHandler = function (event) {
return _this.onWindowMouseMove(event);
};

_this.onWindowMouseUpHandler = function (event) {
return _this.onWindowMouseUp(event);
};

_this.onMouseDownHandler = function (event) {
return _this.onMouseDown(event);
};

_this.onMouseMoveHandler = function (event) {
return _this.onMouseMove(event);
};

_this.onMouseLeaveHandler = function (event) {
return _this.onMouseLeave(event);
};

if (browser["a" /* default */].isMobile()) {
_this.onTouchStartHandler = function (event) {
return _this.onTouchStart(event);
};

_this.onTouchMoveHandler = function (event) {
return _this.onTouchMove(event);
};

_this.onTouchEndHandler = function (event) {
return _this.onTouchEnd(event);
};
}

_this.registerEvents();

return _this;
}

createClass_default()(ProgressControl, [{
key: "registerEvents",
value: function registerEvents() {
this.unregisterEvents();
this.innerElm.addEventListener(dom_event["f" /* MOUSE_DOWN */], this.onMouseDownHandler);
this.innerElm.addEventListener(dom_event["i" /* MOUSE_MOVE */], this.onMouseMoveHandler);
this.innerElm.addEventListener(dom_event["h" /* MOUSE_LEAVE */], this.onMouseLeaveHandler);

if (browser["a" /* default */].isMobile()) {
this.innerElm.addEventListener(dom_event["n" /* TOUCH_START */], this.onTouchStartHandler);
this.innerElm.addEventListener(dom_event["m" /* TOUCH_MOVE */], this.onTouchMoveHandler);
this.innerElm.addEventListener(dom_event["l" /* TOUCH_END */], this.onTouchEndHandler);
}
}
}, {
key: "unregisterEvents",
value: function unregisterEvents() {
this.innerElm.removeEventListener(dom_event["f" /* MOUSE_DOWN */], this.onMouseDownHandler);
this.innerElm.removeEventListener(dom_event["i" /* MOUSE_MOVE */], this.onMouseMoveHandler);
this.innerElm.removeEventListener(dom_event["h" /* MOUSE_LEAVE */], this.onMouseLeaveHandler);

if (browser["a" /* default */].isMobile()) {
this.innerElm.removeEventListener(dom_event["n" /* TOUCH_START */], this.onTouchStartHandler);
this.innerElm.removeEventListener(dom_event["m" /* TOUCH_MOVE */], this.onTouchMoveHandler);
this.innerElm.removeEventListener(dom_event["l" /* TOUCH_END */], this.onTouchEndHandler);
}
}
}, {
key: "onTouchStart",
value: function onTouchStart(event) {
event.preventDefault();
this.onWindowMouseMove(this.convertToMouseEvent(event));
}
}, {
key: "onTouchMove",
value: function onTouchMove(event) {
event.preventDefault();
this.onWindowMouseMove(this.convertToMouseEvent(event));
}
}, {
key: "onTouchEnd",
value: function onTouchEnd(event) {
this.onWindowMouseUp(this.convertToMouseEvent(event));
}
}, {
key: "onMouseDown",
value: function onMouseDown(event) {
event.preventDefault();
this.isSeeking = true;
var position = event.clientX - this.elm.getBoundingClientRect().left;
var percentPosition = position / this.elm.offsetWidth * 100;
this.drag.style.left = "".concat(percentPosition, "%");
this.videoElm.style.width = "".concat(percentPosition, "%");
window.addEventListener(dom_event["i" /* MOUSE_MOVE */], this.onWindowMouseMoveHandler);
window.addEventListener(dom_event["j" /* MOUSE_UP */], this.onWindowMouseUpHandler);
}
}, {
key: "onWindowMouseMove",
value: function onWindowMouseMove(event) {
event.preventDefault();
this.isSeeking = true;
var position = event.clientX - this.elm.getBoundingClientRect().left;
var percentPosition = position / this.elm.offsetWidth * 100;

if (percentPosition > 100) {
percentPosition = 99.9;
}

if (percentPosition < 0) {
percentPosition = 0;
}

this.videoElm.style.width = "".concat(percentPosition, "%");
this.drag.style.left = "".concat(percentPosition, "%");
}
}, {
key: "onWindowMouseUp",
value: function onWindowMouseUp(event) {
event.preventDefault();
window.removeEventListener(dom_event["i" /* MOUSE_MOVE */], this.onWindowMouseMoveHandler);
window.removeEventListener(dom_event["j" /* MOUSE_UP */], this.onWindowMouseUpHandler);
var position = event.clientX - this.elm.getBoundingClientRect().left;
var percentPosition = position / this.elm.offsetWidth * 100;

if (percentPosition > 100) {
percentPosition = 100;
}

if (percentPosition < 0) {
percentPosition = 0;
}

this.videoElm.style.width = "".concat(percentPosition, "%");
this.drag.style.left = "".concat(percentPosition, "%");
this.trigger(control_event["PROGRESS_POSITION_CHANGED"], percentPosition);
setTimeout(function () {
this.isSeeking = false;
}.bind(this), 1500);
}
}, {
key: "onMouseMove",
value: function onMouseMove(event) {
var positionTooltip = event.clientX - this.elm.getBoundingClientRect().left,
position = positionTooltip,
seconds = position / this.elm.offsetWidth * this.duration,
tooltipShift;
var percentPosition = position / this.elm.offsetWidth * 100;

if (isNaN(seconds)) {
this.tooltip.classList.remove('visible');
this.tooltip.classList.add('hidden');
return;
}

this.tooltip.style.left = "".concat(positionTooltip, "px");
tooltipShift = Math.floor(this.tooltip.offsetWidth / 2);

if (positionTooltip - tooltipShift < 0) {
positionTooltip = tooltipShift;
}

if (positionTooltip + tooltipShift > this.elm.offsetWidth) {
positionTooltip = this.elm.offsetWidth - tooltipShift;
}

this.tooltip.style.left = "".concat(positionTooltip, "px");
this.tooltip.classList.add('visible');
this.tooltip.classList.remove('hidden');
this.trigger(control_event["PROGRESS_MOVE"], percentPosition, positionTooltip, position);
}
}, {
key: "updateTooltip",
value: function updateTooltip(value) {
this.tooltip.innerHTML = value;
this.tooltip.style.marginLeft = "-".concat(Math.floor(this.tooltip.offsetWidth / 2), "px");
}
}, {
key: "onMouseLeave",
value: function onMouseLeave() {
this.tooltip.classList.remove('visible');
this.tooltip.classList.add('hidden');
}
}, {
key: "update",
value: function update(percentPosition, duration) {
var force = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

if (!force && (this.isSeeking || this.barElm.offsetWidth === 0)) {
return;
}

this.duration = duration;
this.percentPosition = percentPosition;
this.videoElm.style.width = "".concat(percentPosition, "%");
this.drag.style.left = "".concat(percentPosition, "%");
var dragPosition = dom.getIntegerStyle(this.drag, 'left');
var dragMarginLeft = Math.abs(dom.getIntegerStyle(this.drag, 'margin-left'));

if (dragPosition + dragMarginLeft > this.elm.offsetWidth) {
this.drag.style.left = "".concat(this.elm.offsetWidth - dragMarginLeft, "px");
}
}
}, {
key: "updateAriaAttrs",
value: function updateAriaAttrs(value, text) {
this.elm.setAttribute('aria-valuenow', value);
this.elm.setAttribute('aria-valuetext', text);
}
}, {
key: "freeze",
value: function freeze() {
this.videoElm.style.display = 'none';
this.drag.style.display = 'none';
this.isFrozen = true;
}
}, {
key: "unFreeze",
value: function unFreeze() {
this.videoElm.style.display = '';
this.drag.style.display = '';
this.isFrozen = false;
}
}, {
key: "reset",
value: function reset() {
this.videoElm.style.width = 0;
this.drag.style.left = 0;
}
}, {
key: "convertToMouseEvent",
value: function convertToMouseEvent(event) {
event.preventDefault();
var changedTouches = event.changedTouches;
var _changedTouches$ = changedTouches[0],
clientX = _changedTouches$.clientX,
clientY = _changedTouches$.clientY;
return {
clientX: clientX,
clientY: clientY,
preventDefault: function preventDefault() {}
};
}
}]);

return ProgressControl;
}(button_Button);


// CONCATENATED MODULE: ./src/module/gui/control/layout/classic.js
/* harmony default export */ var classic = ({
classic: [{
name: 'controls',
items: [{
id: 'play-pause'
}, {
id: 'stop'
}, {
id: 'separator-left',
type: 'html-element'
}, {
id: 'progress'
}, {
id: 'separator-right',
type: 'html-element'
}, {
id: 'live'
}, {
id: 'time'
}, {
id: 'subtitle'
}, {
id: 'volume'
}, {
id: 'settings'
}, {
id: 'cast'
}, {
id: 'pip'
}, {
id: 'fullscreen'
}]
}]
});
// CONCATENATED MODULE: ./src/core/event/key-event.js
var ArrowDown = 'arrowdown';
var ArrowLeft = 'arrowleft';
var ArrowRight = 'arrowright';
var ArrowUp = 'arrowup';
var ESCAPE = 'escape';
var F = 'f';
var M = 'm';
var S = 's';
var SPACE = ' ';
var TAB = 'tab';
// CONCATENATED MODULE: ./src/module/gui/control/button/settings.js







function settings_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (settings_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function settings_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }




var settings_SettingsButton = /*#__PURE__*/function (_Button) {
inherits_default()(SettingsButton, _Button);

var _super = settings_createSuper(SettingsButton);

function SettingsButton() {
classCallCheck_default()(this, SettingsButton);

return _super.apply(this, arguments);
}

createClass_default()(SettingsButton, [{
key: "handleKeyEvent",
value: function handleKeyEvent(event) {
if (event.key === SPACE) {
event.preventDefault();
this.onClick(event);
this.addFocusClass();
return false;
}

get_default()(getPrototypeOf_default()(SettingsButton.prototype), "handleKeyEvent", this).call(this, event);

return true;
}
}]);

return SettingsButton;
}(button_Button);


// CONCATENATED MODULE: ./src/module/gui/control/controls-bar.js








function controls_bar_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (controls_bar_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function controls_bar_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }

















var Layouts = {};

var controls_bar_ControlsBar = /*#__PURE__*/function (_EventEmitter) {
inherits_default()(ControlsBar, _EventEmitter);

var _super = controls_bar_createSuper(ControlsBar);

function ControlsBar(id, options) {
var _this;

classCallCheck_default()(this, ControlsBar);

_this = _super.call(this);
_this.id = id;
_this.extraControls = [];
_this.ControlEvent = control_event;
core["a" /* default */].extend(Layouts, classic);
_this.options = options;
_this.cssPrefix = _this.options.cssPrefix;

if (_this.options.controlsLayout !== null) {
_this.controlsLayout = _this.options.layout || Layouts[_this.options.controlsLayout];
}

if (!_this.controlsLayout) {
return possibleConstructorReturn_default()(_this);
}

_this.controlsTimeout = -1;
_this.disabled = false;
_this.elm = dom.createElm('div', _this.cssPrefix + '-controls-bar');
_this.innerElm = dom.createElm('div', _this.cssPrefix + '-controls-bar-inner');

_this.elm.appendChild(_this.innerElm);

_this.controlItemsMap = {};
_this.appendedRows = [];
_this.isLive = false;
_this.isMouseOver = false;

_this.elm.appendChild(_this.innerElm);

_this.playPauseButton = _this.createItem(play_pause_PlayPause, PLAY_PAUSE);
_this.playButton = _this.playPauseButton.getPlay();
_this.pauseButton = _this.playPauseButton.getPause();
_this.settingsButton = _this.createItem(settings_SettingsButton, SETTINGS);

_this.settingsButton.hide();

_this.settingsButton.stopPropagation = true;
_this.fullscreenButton = _this.createItem(fullscreen_FullscreenButton, FULLSCREEN);
_this.volumeButton = _this.createItem(volume_Volume, VOLUME, _this.options.volumeType);

_this.volumeButton.setTooltipContainer(_this.elm);

_this.timeDisplay = _this.createItem(time_display_TimeDisplay, 'time');
_this.liveButton = _this.createItem(live_Stop, LIVE);
_this.progressControl = _this.createItem(progress_ProgressControl, 'progress');
_this.progressControl.isSeeking = false;

_this.addExtraControls();

_this.appendControlItems();

_this.registerEvents();

_this.hideControls();

_this.disable();

_this.enable();

_this.visible = true;

if (options.hideAtStart) {
_this.getElm().classList.add('hidden-sudden');

_this.hide();
}

return _this;
}

createClass_default()(ControlsBar, [{
key: "setLayout",
value: function setLayout(layout) {
this.controlsLayout = layout;
this.rebuild();
}
}, {
key: "updateVolumeProgress",
value: function updateVolumeProgress(value, muted) {
this.volumeButton.updateVolumeProgress(value, muted);
}
}, {
key: "createButton",
value: function createButton(name) {
return new button_Button(name, this.cssPrefix);
}
}, {
key: "rebuild",
value: function rebuild() {
this.appendControlItems();
}
}, {
key: "registerEvents",
value: function registerEvents() {
var _this2 = this;

this.elm.addEventListener(dom_event["g" /* MOUSE_ENTER */], function () {
return _this2.onMouseEnter();
});
this.elm.addEventListener(dom_event["h" /* MOUSE_LEAVE */], function () {
return _this2.onMouseLeave();
});
this.progressControl.on(control_event["PROGRESS_POSITION_CHANGED"], this.onProgressPositionChanged.bind(this));
this.progressControl.on(control_event["PROGRESS_MOVE"], this.onProgressMove.bind(this));
this.volumeButton.on(control_event["VOLUME_CHANGED"], this.onControlsVolumeChanged.bind(this));
this.volumeButton.on(control_event["VOLUME_MUTE_STATE_CHANGED"], this.onControlsVolumeMuteStateChanged.bind(this));
this.playButton.on(dom_event["b" /* CLICK */], this.onPlayClicked.bind(this));
this.pauseButton.on(dom_event["b" /* CLICK */], this.onPauseClicked.bind(this));
this.liveButton.on(dom_event["b" /* CLICK */], this.onLiveClicked.bind(this));
this.fullscreenButton.on(dom_event["b" /* CLICK */], this.onFullScreenClicked.bind(this));
}
}, {
key: "onMouseEnter",
value: function onMouseEnter() {
clearTimeout(this.controlsTimeout);
this.isMouseOver = true;
}
}, {
key: "onMouseLeave",
value: function onMouseLeave() {
this.isMouseOver = false;
this.hideControls();
}
}, {
key: "onProgressPositionChanged",
value: function onProgressPositionChanged(percentPosition) {
this.progressControl.isSeeking = false;
this.trigger(control_event["PROGRESS_POSITION_CHANGED"], percentPosition);
}
}, {
key: "onProgressMove",
value: function onProgressMove(percentPosition, positionTooltip, cursorPosition) {
this.trigger(control_event["PROGRESS_MOVE"], percentPosition, positionTooltip, cursorPosition);
}
}, {
key: "onControlsVolumeChanged",
value: function onControlsVolumeChanged(volume) {
this.trigger(control_event["VOLUME_CHANGED"], volume);
}
}, {
key: "onControlsVolumeMuteStateChanged",
value: function onControlsVolumeMuteStateChanged(muted) {
this.trigger(control_event["VOLUME_MUTE_STATE_CHANGED"], muted);
}
}, {
key: "onPauseClicked",
value: function onPauseClicked() {
this.showPlay();
this.trigger(control_event["PAUSE_BUTTON_CLICKED"]);
}
}, {
key: "onPlayClicked",
value: function onPlayClicked() {
if (this.isLive) {
this.trigger(control_event["SEEK_TO_HEAD"]);
}

this.showPause();
this.trigger(control_event["PLAY_BUTTON_CLICKED"]);
}
}, {
key: "onLiveClicked",
value: function onLiveClicked() {
this.trigger(control_event["LIVE_BUTTON_CLICKED"]);
}
}, {
key: "onFullScreenClicked",
value: function onFullScreenClicked() {
this.trigger(control_event["FULLSCREEN_BUTTON_CLICKED"]);
}
}, {
key: "onMouseMove",
value: function onMouseMove() {
if (this.disabled) {
return;
}

if (this.getElm().classList.contains('hidden')) {
this.getElm().classList.add('visible');
this.getElm().classList.remove('hidden');
this.trigger(control_event["CONTROLS_SHOW"]);
}

this.hideControls();
}
}, {
key: "show",
value: function show() {
this.getElm().classList.remove('hidden-sudden');
this.onMouseMove();
this.visible = true;
}
}, {
key: "hide",
value: function hide() {
this.getElm().classList.remove('visible');
this.getElm().classList.add('hidden');
this.trigger(control_event["CONTROLS_HIDE"]);
this.visible = false;
}
}, {
key: "disable",
value: function disable() {
this.getElm().style.display = 'none';
this.getElm().classList.add('disabled');
}
}, {
key: "isVisible",
value: function isVisible() {
return !this.disabled && this.visible;
}
}, {
key: "enable",
value: function enable() {
this.disabled = false;
this.getElm().style.display = '';
this.getElm().classList.remove('disabled');
this.volumeButton.update();
}
}, {
key: "hideControls",
value: function hideControls() {
var _this3 = this;

var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4000;

if (!this.options.hideControls || this.isMouseOver) {
return;
}

clearTimeout(this.controlsTimeout);
this.controlsTimeout = setTimeout(function () {
_this3.hide();
}, timeout);
}
}, {
key: "addExtraControl",
value: function addExtraControl(control) {
this.extraControls.push(control);
this.controlItemsMap[control.id] = control;
control === null || control === void 0 ? void 0 : control.setTooltipContainer(this.elm);
}
}, {
key: "addExtraControls",
value: function addExtraControls() {
var _this4 = this;

this.extraControls.forEach(function (item) {
_this4.controlItemsMap[item.id] = item;
});
}
}, {
key: "getElm",
value: function getElm() {
return this.elm;
}
}, {
key: "getButton",
value: function getButton(name) {
var button = this.controlItemsMap[name];
return typeof button !== 'undefined' ? button : null;
}
}, {
key: "getButtonElm",
value: function getButtonElm(name) {
var button = this.getButton(name);
return button ? button.elm : null;
}
}, {
key: "appendControlItems",
value: function appendControlItems() {
var _this5 = this;

while (this.innerElm.firstChild) {
this.innerElm.removeChild(this.innerElm.firstChild);
}

var i, j;
this.controlsLayout.forEach(function (row) {
var rowElm = document.createElement('div');
rowElm.classList.add("".concat(_this5.cssPrefix, "-controls__group"));

if (row.name) {
rowElm.classList.add("".concat(_this5.cssPrefix, "-control-group-").concat(row.name));
}

_this5.innerElm.appendChild(rowElm);

var items = row.items || row;
items.forEach(function (rowItem) {
var _this5$controlItemsMa;

var item = (_this5$controlItemsMa = _this5.controlItemsMap[rowItem.id]) === null || _this5$controlItemsMa === void 0 ? void 0 : _this5$controlItemsMa.getElm();

if (rowItem.type === 'html-element') {
item = document.createElement('div');
item.classList.add("".concat(_this5.cssPrefix, "-controls__").concat(rowItem.id));
}

if (item) {
rowElm.appendChild(item);
}
});
});
}
}, {
key: "createItem",
value: function createItem(ItemClass, id) {
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
rest[_key - 2] = arguments[_key];
}

rest.unshift(this.cssPrefix);
rest.unshift(id);
rest.unshift(null);
var args = rest.slice(1);

var controlItem = construct_default()(ItemClass, toConsumableArray_default()(args));

controlItem.setTooltipContainer(this.elm);
this.addAccessibility(controlItem);
this.controlItemsMap[id] = controlItem;
return controlItem;
}
}, {
key: "addAccessibility",
value: function addAccessibility(controlItem) {
if (controlItem.setTabIndex) {
controlItem.setTabIndex(0);
controlItem.enableAriaLabel();
}
}
}, {
key: "onItemFocus",
value: function onItemFocus() {
this.show();
this.hideControls();
}
}, {
key: "removeItem",
value: function removeItem(id) {
this.controlItemsMap[id] = null;
}
}, {
key: "onStop",
value: function onStop() {
this.showPlay();
this.progressControl.reset();
this.disable();
}
}, {
key: "showPlay",
value: function showPlay() {
this.playButton.show();
this.pauseButton.hide();
}
}, {
key: "showPause",
value: function showPause() {
this.playButton.hide();
this.pauseButton.show();
}
}, {
key: "showLive",
value: function showLive() {
this.isLive = true;
this.progressControl.hide();
this.timeDisplay.hide();
}
}, {
key: "showTimeShift",
value: function showTimeShift(mode) {
this.progressControl.show();
this.playPauseButton.show();

if (mode === timeshift["a" /* TimeShiftMode */].VOD || mode === timeshift["a" /* TimeShiftMode */].VOD_SHIFTED) {
this.liveButton.hide();
this.timeDisplay.show();
} else {
this.liveButton.show();

if (mode === timeshift["a" /* TimeShiftMode */].LIVE_DELAYED) {
this.liveButton.disableLive();
}

this.timeDisplay.hide();
}
}
}, {
key: "onPaused",
value: function onPaused() {
this.showPlay();
}
}, {
key: "onSeekStart",
value: function onSeekStart() {
this.progressControl.isSeeking = true;
}
}]);

return ControlsBar;
}(event_emitter["a" /* default */]);


/* harmony default export */ var controls_bar = (controls_bar_ControlsBar);
// CONCATENATED MODULE: ./src/module/gui/control/spinner.js




var spinner_Spinner = /*#__PURE__*/function () {
function Spinner(cssPrefix) {
classCallCheck_default()(this, Spinner);

this._elm = dom.createElm('div', cssPrefix + '-spinner');
}

createClass_default()(Spinner, [{
key: "getElm",
value: function getElm() {
return this._elm;
}
}, {
key: "show",
value: function show() {
this._elm.style.display = 'block';
}
}, {
key: "hide",
value: function hide() {
this._elm.style.display = 'none';
}
}]);

return Spinner;
}();


// CONCATENATED MODULE: ./src/module/gui/control/unmute-overlay.js




/* harmony default export */ var unmute_overlay = (function (player) {
var options = player.options;
var elm = document.createElement('div');
var message = document.createElement('span');
var isActive = false;
message.innerHTML = options.get(option_name["Kb" /* UNMUTE_MESSAGE */]) || i18n_i18n.get('UNMUTE_MESSAGE');
elm.appendChild(message);
elm.classList.add("".concat(options.get(option_name["s" /* CSS_PREFIX */]), "-unmute-overlay"));
elm.addEventListener(dom_event["b" /* CLICK */], function () {
player.unMute();
player.trigger(player_event["vb" /* UNMUTED */]);
hide();
});

function disable() {
elm.classList.remove('active');
}

function enable() {
elm.classList.add('active');
}

function show() {
enable();
isActive = true;
}

function hide() {
disable();
isActive = false;
}

return {
show: show,
hide: hide,
enable: enable,
disable: disable,

get isActive() {
return isActive;
},

getElm: function getElm() {
return elm;
}
};
});
// CONCATENATED MODULE: ./src/module/gui/control/button/jump.js






function jump_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (jump_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function jump_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }



var jump_JumpButton = /*#__PURE__*/function (_Button) {
inherits_default()(JumpButton, _Button);

var _super = jump_createSuper(JumpButton);

function JumpButton(id, cssPrefix) {
var _this;

classCallCheck_default()(this, JumpButton);

_this = _super.call(this, id, cssPrefix);
_this.labelEl = document.createElement('span');

_this.elm.appendChild(_this.labelEl);

_this.hideClass = "".concat(_this.className, "--hidden");
return _this;
}

createClass_default()(JumpButton, [{
key: "setJumpLabel",
value: function setJumpLabel(value) {
this.labelEl.innerHTML = value;
}
}]);

return JumpButton;
}(button_Button);

/* harmony default export */ var jump = (jump_JumpButton);
// CONCATENATED MODULE: ./src/module/gui/control/overlay-buttons.js






function overlay_buttons_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (overlay_buttons_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function overlay_buttons_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }












var SHOW_TIMEOUT = 100; //[ms]

var HIDE_TIMEOUT = 1600; //[ms]

var overlay_buttons_OverlayButtons = /*#__PURE__*/function (_Component) {
inherits_default()(OverlayButtons, _Component);

var _super = overlay_buttons_createSuper(OverlayButtons);

function OverlayButtons(player) {
var _this;

classCallCheck_default()(this, OverlayButtons);

_this = _super.call(this);
_this.player = player;
_this.options = player.options;
_this.cssPrefix = _this.options.get(option_name["s" /* CSS_PREFIX */]);
_this.jumpStep = _this.options.get(option_name["ob" /* SEEK_CHANGE_STEP */]);
_this.elmClass = "".concat(_this.cssPrefix, "-overlay-buttons");
_this.elmClassVisible = "".concat(_this.elmClass, "--visible");
_this.elm = document.createElement('div');
_this.playPauseButton = new play_pause_PlayPause(PLAY_PAUSE, _this.cssPrefix);
_this.playButton = _this.playPauseButton.getPlay();
_this.pauseButton = _this.playPauseButton.getPause();
_this.jumpBackwardButton = undefined;
_this.jumpForwardButton = undefined;
_this.isPlaying = false;
_this.isStarted = false;
_this.isStopped = false;
_this.isHoverEnabled = _this.options.get(option_name["tb" /* SHOW_BUTTONS_OVER_VIDEO_ON_HOVER */]);
_this.hideTimeout = _this.isHoverEnabled ? HIDE_TIMEOUT : 0;
_this.hideTimeoutId = undefined;
_this.showTimeoutId = undefined;

_this.elm.classList.add(_this.elmClass);

_this.playPauseButton.updateAriaLabel(i18n_i18n.get('HELP_PLAY'));

_this.playPauseButton.setTabIndex();

_this.player.on(player_event["r" /* GUI_READY */], function (gui) {
return _this.init(gui);
});

_this.player.once(player_event["O" /* PLAYING */], function () {
return _this.onFirstPlaying();
});

_this.player.on(player_event["O" /* PLAYING */], function () {
return _this.onPlaying();
});

_this.player.on(player_event["G" /* PAUSED */], function () {
return _this.onPaused();
});

_this.player.on(player_event["n" /* ENDED */], function () {
return _this.onStopped();
});

_this.player.on(player_event["ib" /* STOPPED */], function () {
return _this.onStopped();
});

_this.player.on(player_event["l" /* DESTROY */], function () {
return _this.onStopped();
});

_this.player.on(player_event["zb" /* WAITING */], function () {
return _this.onWaiting();
});

_this.player.on(player_event["D" /* ON_LIVE */], function () {
return _this.onLive();
});

_this.hideOverlay();

return _this;
}

createClass_default()(OverlayButtons, [{
key: "init",
value: function init() {
var _this2 = this;

var controls = this.player.getComponent(player_component["a" /* CONTROLS */]);
this.jumpBackwardButton = controls.createItem(jump, JUMP_BACKWARD);
this.jumpBackwardButton.setJumpLabel("-".concat(this.jumpStep));

if (this.options.get(option_name["ub" /* SHOW_JUMP_BUTTONS_OVER_VIDEO */])) {
this.elm.appendChild(this.jumpBackwardButton.getElm());
}

this.elm.appendChild(this.playPauseButton.getElm());
this.jumpForwardButton = controls.createItem(jump, JUMP_FORWARD);
this.jumpForwardButton.setJumpLabel("+".concat(this.jumpStep));

if (this.options.get(option_name["ub" /* SHOW_JUMP_BUTTONS_OVER_VIDEO */])) {
this.elm.appendChild(this.jumpForwardButton.getElm());
}

this.jumpForwardButton.on(dom_event["b" /* CLICK */], function () {
return _this2.seekFromTo(_this2.jumpStep);
});
this.jumpBackwardButton.on(dom_event["b" /* CLICK */], function () {
return _this2.seekFromTo(-_this2.jumpStep);
});
this.playButton.on(dom_event["b" /* CLICK */], function () {
return _this2.play();
});
this.pauseButton.on(dom_event["b" /* CLICK */], function () {
return _this2.pause();
});
this.jumpBackwardButton.on(dom_event["c" /* FOCUS */], function () {
return _this2.showOverlay();
});
this.jumpForwardButton.on(dom_event["c" /* FOCUS */], function () {
return _this2.showOverlay();
});
this.playPauseButton.on(dom_event["c" /* FOCUS */], function () {
return _this2.showOverlay();
});
this.jumpBackwardButton.hide();
this.jumpForwardButton.hide();
this.pauseButton.hide();
this.playButton.hide();

if (this.options.get(option_name["tb" /* SHOW_BUTTONS_OVER_VIDEO_ON_HOVER */])) {
var rendererELm = this.player.getRendererElm();
rendererELm.addEventListener(dom_event["b" /* CLICK */], function (event) {
return _this2.preventPlayPauseEvent(event);
}, true);
rendererELm.addEventListener(dom_event["i" /* MOUSE_MOVE */], function (event) {
return _this2.showOverlay(event);
});
}

if (this.options.get(option_name["g" /* AUTOPLAY */])) {
this.playButton.addClass('inactive');
this.playButton.hide();
} else {
this.playButton.show();
this.showOverlay();
}
}
}, {
key: "play",
value: function play() {
var gui = this.player.getComponent(player_component["b" /* GUI */]);
var controls = this.player.getComponent(player_component["a" /* CONTROLS */]);
this.playButton.hide();

if (!gui.isBlockedAutoPlay) {
controls === null || controls === void 0 ? void 0 : controls.enable();
this.player.trigger(player_event["S" /* PLAY_REQUEST */]);
}

if (controls === null || controls === void 0 ? void 0 : controls.isLive) {
this.player.seekToHead();
}

this.trigger(control_event["PLAY_BIG_BUTTON_CLICKED"]);
}
}, {
key: "pause",
value: function pause() {
this.player.pause();
this.player.trigger(control_event["PAUSE_BIG_BUTTON_CLICKED"]);
}
}, {
key: "seekFromTo",
value: function seekFromTo(toTime) {
var currentTime = this.player.getCurrentTime();
this.player.trigger(control_event["SEEK_FROM_TO"], currentTime, currentTime + toTime);
this.showOverlay();
}
}, {
key: "getElm",
value: function getElm() {
return this.elm;
}
}, {
key: "showPause",
value: function showPause() {
if (this.options.get(option_name["vb" /* SHOW_PAUSE_BUTTON_OVER_VIDEO */])) {
this.pauseButton.show();
}
}
}, {
key: "showOverlay",
value: function showOverlay(event) {
var _this3 = this;

if (this.isStopped) {
return;
}

clearTimeout(this.hideTimeoutId);
clearTimeout(this.showTimeoutId);
this.showTimeoutId = setTimeout(function () {
_this3.elm.classList.add("".concat(_this3.elmClassVisible));

_this3.hideTimeoutId = setTimeout(function () {
return _this3.hideOverlay();
}, _this3.hideTimeout);
}, SHOW_TIMEOUT);
}
}, {
key: "showPlay",
value: function showPlay() {
this.onPaused();
this.showOverlay();
}
}, {
key: "showJumpButtons",
value: function showJumpButtons() {
if (!this.player.isLiveWithoutTimeShift()) {
this.jumpBackwardButton.show();
this.jumpForwardButton.show();
}
}
}, {
key: "preventPlayPauseEvent",
value: function preventPlayPauseEvent(event) {
if (this.options.get(option_name["vb" /* SHOW_PAUSE_BUTTON_OVER_VIDEO */]) && browser["a" /* default */].isMobile()) {
event.stopPropagation();
}
}
}, {
key: "hideOverlay",
value: function hideOverlay() {
var _document = document,
activeElement = _document.activeElement;

if (!this.isHoverEnabled && this.player.isPaused()) {
return;
}

if ((activeElement === null || activeElement === void 0 ? void 0 : activeElement.classList.contains("".concat(this.cssPrefix, "-control-item-focused"))) && this.elm.contains(activeElement)) {
this.showOverlay();
return;
}

this.elm.classList.remove("".concat(this.elmClassVisible));
}
}, {
key: "onFirstPlaying",
value: function onFirstPlaying() {
this.isStarted = true;
this.showJumpButtons();
this.onPlaying();
}
}, {
key: "onPlaying",
value: function onPlaying() {
this.isPlaying = true;
this.playButton.removeClass('inactive');
this.playButton.hide();
this.showPause();

if (!this.isHoverEnabled) {
this.hideOverlay();
}
}
}, {
key: "onPaused",
value: function onPaused() {
this.isPlaying = false;
this.playButton.show();
this.pauseButton.hide();
this.showOverlay();
}
}, {
key: "onWaiting",
value: function onWaiting() {
this.isPlaying = false;
this.playButton.hide();
}
}, {
key: "onStopped",
value: function onStopped() {
this.isPlaying = false;
this.hideOverlay();
this.isStopped = true;
}
}, {
key: "onLive",
value: function onLive() {
if (!this.player.isLiveWithoutTimeShift()) {
this.jumpBackwardButton.hide();
this.jumpForwardButton.hide();
}
}
}]);

return OverlayButtons;
}(core_component["a" /* default */]);

/* harmony default export */ var overlay_buttons = (overlay_buttons_OverlayButtons);
// CONCATENATED MODULE: ./src/module/gui/keyboard-events.js








var EXCLUDED_TAGS_FROM_KEY_EVENT = ['input', 'textarea'];
var keyboard_events_time;
var updatePositionTimeoutId = 0;
var UPDATE_POSITION_TIMEOUT = 600;

var keyboard_events_updateVolume = function updateVolume(player, event, step) {
var initVolume = player.isMuted() ? 0 : player.getVolume();
var volume = Math.min(100, Math.max(0, initVolume + step));
event.preventDefault();
player.trigger(player_event["xb" /* VOLUME_CHANGE_REQUEST */], volume);

if (step > 0) {
player.trigger(player_event["yb" /* VOLUME_MUTE_REQUEST */], false);
}
};

var keyboard_events_updatePosition = function updatePosition(player, step) {
var _player$getComponent;

var isLive = player.isLive() && !player.timeShift.isEnabled();

if (isLive) {
return;
}

var duration = player.getDuration();

if (keyboard_events_time !== undefined) {
keyboard_events_time += step;
} else {
keyboard_events_time = player.getCurrentTime() + step;
}

keyboard_events_time = Math.min(duration, Math.max(0, keyboard_events_time));
(_player$getComponent = player.getComponent(player_component["b" /* GUI */])) === null || _player$getComponent === void 0 ? void 0 : _player$getComponent.updateVideoProgress(keyboard_events_time, duration);
clearTimeout(updatePositionTimeoutId);
updatePositionTimeoutId = setTimeout(function () {
player.trigger(control_event["SEEK_FROM_TO"], player.getCurrentTime(), keyboard_events_time);
keyboard_events_time = undefined;
}, UPDATE_POSITION_TIMEOUT);
};

var keyboard_events_handleCustomControlEvent = function handleCustomControlEvent(player, event, eventKey) {
var _activeElement$datase, _controls$getButton;

var _document = document,
activeElement = _document.activeElement;
var buttonName = activeElement === null || activeElement === void 0 ? void 0 : (_activeElement$datase = activeElement.dataset) === null || _activeElement$datase === void 0 ? void 0 : _activeElement$datase.button;
var controlName = (activeElement === null || activeElement === void 0 ? void 0 : activeElement.classList.contains(CONTROL_FOCUS_CLASS)) || buttonName === SETTINGS_ELEMENT ? buttonName : 'generic';
var isLive = player.isLive() && !player.timeShift.isEnabled();

switch (controlName) {
case PLAY_PAUSE:
if (eventKey === SPACE) {
event.preventDefault();
player.getComponent(player_component["b" /* GUI */]).controlsBar[player.isPaused() ? 'onPlayClicked' : 'onPauseClicked']();
return false;
}

break;

case JUMP_BACKWARD:
if (eventKey === SPACE) {
event.preventDefault();
!isLive && keyboard_events_updatePosition(player, -player.options.get(option_name["ob" /* SEEK_CHANGE_STEP */]));
return false;
}

break;

case JUMP_FORWARD:
if (eventKey === SPACE) {
event.preventDefault();
!isLive && keyboard_events_updatePosition(player, player.options.get(option_name["ob" /* SEEK_CHANGE_STEP */]));
return false;
}

break;

case VOLUME:
if (eventKey === SPACE) {
event.preventDefault();
player.trigger(player_event["yb" /* VOLUME_MUTE_REQUEST */], !player.isMuted());
return false;
}

break;

case VOLUME_PROGRESS:
if (eventKey === ArrowRight) {
keyboard_events_updateVolume(player, event, player.options.get(option_name["Pb" /* VOLUME_CHANGE_STEP */]));
return false;
}

if (eventKey === ArrowLeft) {
keyboard_events_updateVolume(player, event, -player.options.get(option_name["Pb" /* VOLUME_CHANGE_STEP */]));
return false;
}

break;

case FULLSCREEN:
if (eventKey === SPACE) {
event.preventDefault();
player.trigger(player_event["q" /* FULLSCREEN_CHANGE_REQUEST */]);
return false;
}

break;

case LIVE:
if (eventKey === SPACE) {
event.preventDefault();
player.getComponent(player_component["b" /* GUI */]).controlsBar.trigger(control_event["LIVE_BUTTON_CLICKED"]);
return false;
}

break;

case SUBTITLE:
if (eventKey === SPACE) {
event.preventDefault();
player.trigger(player_event["rb" /* SUBTITLE_TOGGLE_REQUEST */]);
return false;
}

break;

case CAST:
if (eventKey === SPACE) {
event.preventDefault();
player.connect();
return false;
}

break;

case PLAY_BIG:
case 'generic':
return true;

case SETTINGS_ELEMENT:
return player.getComponent(player_component["b" /* GUI */]).settings.handleKeyEvent(event);

default:
var controls = player.getComponent(player_component["a" /* CONTROLS */]);
var button = (_controls$getButton = controls.getButton) === null || _controls$getButton === void 0 ? void 0 : _controls$getButton.call(controls, controlName);
return button === null || button === void 0 ? void 0 : button.handleKeyEvent(event);
}

return true;
};

var keyboard_events_handleKeyboardEvents = function handleKeyboardEvents(player, event) {
var _document$activeEleme, _document$activeEleme2, _document$activeEleme3, _player$listSubtitles;

var nodeName = (_document$activeEleme = document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.nodeName.toLowerCase();

if (EXCLUDED_TAGS_FROM_KEY_EVENT.includes(nodeName)) {
return;
}

var isLive = player.isLive() && !player.timeShift.isEnabled();
var buttonName = (_document$activeEleme2 = document.activeElement) === null || _document$activeEleme2 === void 0 ? void 0 : (_document$activeEleme3 = _document$activeEleme2.dataset) === null || _document$activeEleme3 === void 0 ? void 0 : _document$activeEleme3.button;
var eventKey = event.key.toLowerCase();

if (eventKey === TAB && buttonName !== SETTINGS_ELEMENT) {
setTimeout(function () {
return document.activeElement.dispatchEvent(new Event(dom_event["d" /* FOCUS_WITH_TAB */]));
}, 0);
}

if (buttonName) {
var eventPropagation = keyboard_events_handleCustomControlEvent(player, event, eventKey);

if (!eventPropagation) {
return;
}
}

switch (eventKey) {
case SPACE:
event.preventDefault();
player.trigger(player_event["ub" /* TOGGLE_PLAY_PAUSE_REQUEST */]);
break;

case F:
player.trigger(player_event["q" /* FULLSCREEN_CHANGE_REQUEST */]);
break;

case M:
player.trigger(player_event["yb" /* VOLUME_MUTE_REQUEST */], !player.isMuted());
break;

case ArrowUp:
keyboard_events_updateVolume(player, event, player.options.get(option_name["Pb" /* VOLUME_CHANGE_STEP */]));
break;

case ArrowDown:
keyboard_events_updateVolume(player, event, -player.options.get(option_name["Pb" /* VOLUME_CHANGE_STEP */]));
break;

case ArrowRight:
!isLive && keyboard_events_updatePosition(player, player.options.get(option_name["ob" /* SEEK_CHANGE_STEP */]));
break;

case ArrowLeft:
!isLive && keyboard_events_updatePosition(player, -player.options.get(option_name["ob" /* SEEK_CHANGE_STEP */]));
break;

case S:
if ((_player$listSubtitles = player.listSubtitles) === null || _player$listSubtitles === void 0 ? void 0 : _player$listSubtitles.call(player)) {
player.trigger(player_event["rb" /* SUBTITLE_TOGGLE_REQUEST */]);
}

break;
}
};
// CONCATENATED MODULE: ./src/module/gui/control/settings/item.js


SettingItem.prototype = Object.create(event_emitter["a" /* default */].prototype);

function SettingItem(prefix, name, labelText) {
var ctx = this;
var item = document.createElement('div');
var label = document.createElement('span');
var value = document.createElement('strong');
var wrapper = document.createElement('div');
var list = document.createElement('ul');
var header = document.createElement('div');
var headerButton = document.createElement('div');
var headerLabel = document.createElement('div');
var choice;
wrapper.appendChild(header);
wrapper.appendChild(list);
wrapper.dataset.list = name;
header.appendChild(headerButton);
header.appendChild(headerLabel);
header.classList.add("".concat(prefix, "-settings-header"));
headerButton.innerHTML = '×';
headerLabel.innerHTML = labelText;
item.appendChild(label);
item.appendChild(value);
item.setAttribute('data-name', name);
item.classList.add(prefix + '-settings-item');
label.innerHTML = '&nbsp;';
list.addEventListener(dom_event["b" /* CLICK */], onClick);
headerButton.addEventListener(dom_event["b" /* CLICK */], function () {
return ctx.trigger('hide');
});
headerButton.classList.add("".concat(prefix, "-settings-header-button"));
var choices = [];

function onClick(_ref) {
var target = _ref.target;

if ((target === null || target === void 0 ? void 0 : target.nodeName) === 'LI') {
ctx.trigger('select', target.getAttribute('data-id'));
}
}

function addChoices(_choices) {
choices = _choices;
}

function getList() {
list.innerHTML = '';
choices.forEach(function (choice) {
var el = document.createElement('li');
el.innerHTML = choice.label;
el.setAttribute('data-id', choice.id);
list.appendChild(el);
});
selectActive();
return wrapper;
}

function setLabel(_label) {
label.innerHTML = _label;
}

function setChoice(_choice, _label, _value) {
choice = _choice;
label.innerHTML = _label;
value.innerHTML = _value;
selectActive();
}

function selectActive() {
if (!choice) {
return;
}

var elms = list.querySelectorAll('li');

for (var i = 0; i < elms.length; i++) {
var id = elms[i].getAttribute('data-id').toString();

if (id === choice.id.toString()) {
elms[i].classList.add('selected');
} else {
elms[i].classList.remove('selected');
}
}
}

function hideItem() {
item.style.display = 'none';
}

function showItem() {
item.style.display = '';
}

return {
addChoices: addChoices,
setChoice: setChoice,
setLabel: setLabel,
on: this.on.bind(this),
onClick: onClick,
getEl: function getEl() {
return item;
},
getList: getList,
hideItem: hideItem,
showItem: showItem
};
}

/* harmony default export */ var settings_item = (SettingItem);
// CONCATENATED MODULE: ./src/module/gui/control/settings/audio.js





Audio.prototype = Object.create(event_emitter["a" /* default */].prototype);

function Audio(player) {
var ctx = this;
var options = player.options;
var prefix = options.get(option_name["s" /* CSS_PREFIX */]);
var name = 'audio';
var label = 'Audio';
var item = new settings_item(prefix, name, label);
var list;
var choices = [];
var active = false;
player.on(player_event["f" /* AUDIO_TRACK_LIST */], onChoiceList);
player.on(player_event["e" /* AUDIO_TRACK_CHANGED */], onChoiceChanged);
item.on('select', function (id) {
for (var i = 0; i < list.length; i++) {
var track = list[i];

if (track.id.toString() === id.toString()) {
player.switchAudioTrack(track.id);
}
}
});
item.on('hide', function () {
return ctx.trigger('hide');
});

function onChoiceList(_choices) {
if (_choices.length > 1) {
active = true;
ctx.trigger('active');
}

list = _choices;
choices = [];

_choices.forEach(function (choice) {
choices.push({
id: choice.id,
label: i18n_i18n.get(choice.lang)
});
});

item.setLabel(label);
item.addChoices(choices);
}

function onChoiceChanged(_choice) {
if (!_choice || choices.length === 0) {
return;
}

var choice = list.filter(function (obj) {
return obj.id === _choice.id;
})[0];

if (choice) {
var text = i18n_i18n.get(choice.lang);
item.setChoice(choice, label, text);
}
}

return {
on: this.on.bind(this),
onClick: item.onClick,
getEl: function getEl() {
return item.getEl();
},
getList: function getList() {
return item.getList();
},
getName: function getName() {
return name;
},
getChoices: function getChoices() {
return choices;
}
};
}

/* harmony default export */ var audio = (Audio);
// CONCATENATED MODULE: ./src/module/gui/control/settings/profiles.js






Profiles.prototype = Object.create(event_emitter["a" /* default */].prototype);

function Profiles(player) {
var ctx = this;
var options = player.options;
var prefix = options.get(option_name["s" /* CSS_PREFIX */]);
var name = 'profiles';
var label = i18n_i18n.get('PROFILE');
var item = new settings_item(prefix, name, label);
var profiles;
var choices = [];
var currentChoice;
player.on(player_event["X" /* PROFILE_LIST */], onChoiceList);
player.on(player_event["T" /* PROFILE_CHANGED */], onChoiceChanged);
player.on(player_event["i" /* CHROMECAST_CONNECTED */], function () {
return item.hideItem();
});
player.on(player_event["j" /* CHROMECAST_DISCONNECTED */], function () {
return item.showItem();
});
item.setLabel(label);
item.on('select', function (id) {
if (id === 'auto') {
player.switchProfile('auto');
return;
}

var profile = profiles.find(function (profile) {
return profile.id.toString() === id;
});

if (profile) {
player.switchProfile(profile.bandwidth);
onChoiceChanged(profile);
}
});
item.on('hide', function () {
return ctx.trigger('hide');
});

function onChoiceList(_profiles) {
profiles = _profiles;
ctx.trigger('choices', 'profiles', profiles);

if (profiles.length > 1) {
ctx.trigger('active');
}

choices = [];
profiles.forEach(function (profile) {
var label = parseInt(profile.bandwidth / 1000);

if (profile.height) {
label = "".concat(profile.height, "p (").concat(label, ")");
}

choices.push({
id: profile.id,
label: label
});
});
choices.push({
label: 'Auto',
id: 'auto'
});
item.addChoices(choices);

var _ref = currentChoice || {},
profile = _ref.profile,
isAbr = _ref.isAbr;

if (profile) {
onChoiceChanged(profile, undefined, isAbr);
}
}

function onChoiceChanged(profile, time, isAbr) {
currentChoice = {
profile: profile,
isAbr: isAbr
};

if (choices.length === 0) {
return;
}

var text = profile.bandwidth / 1000;

if (profile.height) {
text = profile.height + 'p' + (isAbr ? ' (auto)' : '');
}

item.setLabel(label + ' ' + text);
var id = isAbr ? 'auto' : profile.id.toString();

var _choices$filter = choices.filter(function (obj) {
return obj.id.toString() === id;
}),
_choices$filter2 = slicedToArray_default()(_choices$filter, 1),
choice = _choices$filter2[0];

if (choice) {
item.setChoice(choice, label, text);
}
}

return {
on: this.on.bind(this),
onClick: item.onClick,
getEl: function getEl() {
return item.getEl();
},
getList: function getList() {
return item.getList();
},
getChoices: function getChoices() {
return choices;
},
getName: function getName() {
return name;
}
};
}

/* harmony default export */ var settings_profiles = (Profiles);
// CONCATENATED MODULE: ./src/module/gui/control/settings/subtitles.js






Subtitles.prototype = Object.create(event_emitter["a" /* default */].prototype);

function Subtitles(player) {
var ctx = this;
var options = player.options;
var prefix = options.get(option_name["s" /* CSS_PREFIX */]);
var name = 'subtitles';
var label = i18n_i18n.get('SUBTITLES');
var item = new settings_item(prefix, name, label);
var list;
var choices = [];
player.on(player_event["mb" /* SUBTITLE */], onChoiceChanged);
player.on(player_event["nb" /* SUBTITLES */], init);
player.on(player_event["pb" /* SUBTITLE_DISABLED */], onDisabled);

if (player.listSubtitles && typeof player.listSubtitles === 'function') {
setTimeout(function () {
return init(player.listSubtitles());
}, 0);
}

function convertLang(_lang) {
var lang = _lang && _lang.toLowerCase();

if (lang === 'pl') {
lang = 'pol';
}

if (lang === 'en') {
lang = 'eng';
}

return lang;
}

function init(subs) {
if (!subs || list) {
return;
}

var subtitles = subs;

if (subtitles) {
onChoiceList(subtitles);
}

item.on('select', function (id) {
if (parseInt(id) === 0) {
player.trigger(player_event["pb" /* SUBTITLE_DISABLED */]);
return;
}

for (var i = 0; i < list.length; i++) {
var choice = list[i];

if (choice.language === id) {
player.trigger(player_event["mb" /* SUBTITLE */], choice);
}
}
});
var activeSubtitle = player.getActiveSubtitle();

if (activeSubtitle) {
onChoiceChanged(activeSubtitle);
}

item.on('hide', function () {
return ctx.trigger('hide');
});
}

function onChoiceList(_choices) {
if (!_choices) {
return;
}

if (_choices.length >= 1) {
ctx.trigger('active');
}

list = _choices;
choices = [];
var disabledChoice = {
label: i18n_i18n.get('NONE'),
id: 0
};
choices.push(disabledChoice);
item.setChoice(disabledChoice, label, disabledChoice.label);

_choices.forEach(function (choice) {
choices.push({
id: choice.language,
trackId: choice.trackId,
label: i18n_i18n.get(convertLang(choice.language))
});
});

item.addChoices(choices);
}

function onChoiceChanged(_choice) {
if (!_choice || choices.length === 0) {
return;
}

var _choices$filter = choices.filter(function (obj) {
return obj.id === _choice.language || obj.trackId && obj.trackId === _choice.trackId;
}),
_choices$filter2 = slicedToArray_default()(_choices$filter, 1),
choice = _choices$filter2[0];

if (choice) {
item.setChoice(choice, label, choice.label);
}
}

function onDisabled() {
var _choices$filter3 = choices.filter(function (obj) {
return obj.id === 0;
}),
_choices$filter4 = slicedToArray_default()(_choices$filter3, 1),
choice = _choices$filter4[0];

item.setChoice(choice, label, choice.label);
}

return {
on: this.on.bind(this),
onClick: item.onClick,
getEl: function getEl() {
return item.getEl();
},
getList: function getList() {
return item.getList();
},
getName: function getName() {
return name;
},
getChoices: function getChoices() {
return choices;
}
};
}

/* harmony default export */ var settings_subtitles = (Subtitles);
// CONCATENATED MODULE: ./src/module/gui/control/settings/playback-rate.js






function playback_rate_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (playback_rate_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function playback_rate_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }







var playback_rate_PlaybackRateSettings = /*#__PURE__*/function (_EventEmitter) {
inherits_default()(PlaybackRateSettings, _EventEmitter);

var _super = playback_rate_createSuper(PlaybackRateSettings);

function PlaybackRateSettings(player) {
var _this;

classCallCheck_default()(this, PlaybackRateSettings);

_this = _super.call(this);
var options = player.options;
var prefix = options.get(option_name["s" /* CSS_PREFIX */]);
_this.player = player;
_this.name = 'playbackRate';
_this.settingHeaderTitle = i18n_i18n.get('PLAYBACK_RATE');
_this.choices = options.get(option_name["hb" /* PLAYBACK_RATES */]).map(function (choice) {
return {
id: choice,
label: "".concat(choice, "x")
};
});
_this.item = new settings_item(prefix, _this.name, _this.settingHeaderTitle);

_this.item.setLabel(_this.settingHeaderTitle);

_this.item.addChoices(_this.choices);

_this.item.on('select', function (id) {
return _this.onSelect(id);
});

_this.item.on('hide', function () {
return _this.trigger('hide');
});

_this.update(player.getPlaybackRate());

_this.player.on(player_event["N" /* PLAYBACK_RATE_CHANGED */], function (playbackRate) {
return _this.update(playbackRate);
});

_this.player.on(player_event["y" /* METADATA */], function () {
return _this.update(player.getPlaybackRate());
});

_this.player.on(player_event["r" /* GUI_READY */], function () {
return _this.trigger('active');
});

return _this;
}

createClass_default()(PlaybackRateSettings, [{
key: "getChoices",
value: function getChoices() {
return this.choices;
}
}, {
key: "onClick",
value: function onClick() {
var _this$item;

(_this$item = this.item).onClick.apply(_this$item, arguments);
}
}, {
key: "getEl",
value: function getEl() {
return this.item.getEl();
}
}, {
key: "getName",
value: function getName() {
return this.name;
}
}, {
key: "getList",
value: function getList() {
return this.item.getList();
}
}, {
key: "update",
value: function update(id) {
if (this.player.isLive() && !this.player.timeShift.isEnabled()) {
this.item.hideItem();
return;
}

var label = "".concat(id, "x");
var choice = {
label: label,
id: id
};
this.item.setChoice(choice, this.settingHeaderTitle, label);
}
}, {
key: "onSelect",
value: function onSelect(id) {
this.update(id);
this.player.setPlaybackRate(parseFloat(id));
}
}]);

return PlaybackRateSettings;
}(event_emitter["a" /* default */]);

/* harmony default export */ var playback_rate = (playback_rate_PlaybackRateSettings);
// CONCATENATED MODULE: ./src/module/gui/control/settings/index.js














function Settings(player) {
var gui = player.getComponent(player_component["b" /* GUI */]);
var options = player.options;
var prefix = options.get(option_name["s" /* CSS_PREFIX */]);
var items = [];
var settingsButton = undefined;
player.on(control_event["CONTROLS_HIDE"], function () {
return hide(true);
});
var settingsOptions = options.get(option_name["rb" /* SETTINGS */]);
var settingsList = [settings_profiles, settings_subtitles, audio, playback_rate];
var hideTimeout = 0;

if (!settingsOptions) {
return;
}

if (Array.isArray(settingsOptions)) {
settingsList = [];
settingsOptions.forEach(function (setting) {
if (setting === 'profile') {
settingsList.push(settings_profiles);
}

if (setting === 'subtitle') {
settingsList.push(settings_subtitles);
}

if (setting === 'audio') {
settingsList.push(audio);
}

if (setting === 'playbackRate') {
settingsList.push(playback_rate);
}
});
}

var enabled = false;
settingsList.forEach(function (settingClass) {
var settingItem = new settingClass(player);
settingItem.on('active', onSettingItemActive);
settingItem.on('hide', function () {
return hideChoiceList(false);
});
items.push(settingItem);
});

function onSettingItemActive() {
if (!enabled) {
var controls = gui.getGuiComponent(player_component["a" /* CONTROLS */]);
settingsButton = controls.getButton(SETTINGS);
settingsButton.show();
settingsButton.on(dom_event["b" /* CLICK */], function (_ref) {
var key = _ref.key;
return toggle(key === SPACE);
});
}

enabled = true;
}

function isMainListActive() {
return container.classList.contains('active');
}

function isChoiceListActive() {
return container.classList.contains('active-child');
}

var container = document.createElement('div');
container.classList.add(prefix + '-settings');
var mainHeaderButton = document.createElement('div');
mainHeaderButton.innerHTML = '×';
mainHeaderButton.classList.add(prefix + '-settings-header-button');
var mainHeader = document.createElement('div');
mainHeader.classList.add(prefix + '-settings-header');
mainHeader.appendChild(mainHeaderButton);
var mainHeaderLabel = document.createElement('div');
mainHeaderLabel.innerHTML = i18n_i18n.get('SETTINGS');
mainHeader.appendChild(mainHeaderLabel);
var mainList = document.createElement('div');
mainList.classList.add(prefix + '-settings-main-list');
mainList.appendChild(mainHeader);
mainList.addEventListener(dom_event["b" /* CLICK */], function (event) {
var _event$target;

if ((_event$target = event.target) === null || _event$target === void 0 ? void 0 : _event$target.dataset.name) {
event.stopPropagation();
showChoiceList(event.target, false);
}
});
mainHeaderButton.addEventListener(dom_event["b" /* CLICK */], function () {
return hide(true, false);
});
var choiceList = document.createElement('div');
choiceList.classList.add(prefix + '-settings-choice-list');
container.appendChild(mainList);
container.appendChild(choiceList);
document.addEventListener(dom_event["b" /* CLICK */], function (_ref2) {
var target = _ref2.target;

if (target !== mainHeader) {
hide(false);
}
}, false);
container.addEventListener(dom_event["f" /* MOUSE_DOWN */], function (event) {
return event.stopPropagation();
});
choiceList.addEventListener(dom_event["b" /* CLICK */], function (event) {
return event.stopPropagation();
});
choiceList.addEventListener(dom_event["f" /* MOUSE_DOWN */], function (event) {
return event.stopPropagation();
});
registerEvents();

function registerEvents() {
mainList.addEventListener(dom_event["h" /* MOUSE_LEAVE */], function () {
return hideWithDelay();
});
mainList.addEventListener(dom_event["g" /* MOUSE_ENTER */], function () {
return clearTimeout(hideTimeout);
});
choiceList.addEventListener(dom_event["h" /* MOUSE_LEAVE */], function () {
return hideWithDelay();
});
choiceList.addEventListener(dom_event["g" /* MOUSE_ENTER */], function () {
return clearTimeout(hideTimeout);
});
}

function getItemByName(name) {
return items.find(function (item) {
return item.getName() === name;
});
}

function getItemVisibleForChoiceList() {
var _choiceList$childNode;

return getItemByName((_choiceList$childNode = choiceList.childNodes[0]) === null || _choiceList$childNode === void 0 ? void 0 : _choiceList$childNode.dataset.list);
}

function showChoiceList(element, withOutline) {
choiceList.innerHTML = '';
document.activeElement.blur();
disableTabbingForFocusableElements();
choiceList.appendChild(getItemByName(element.dataset.name).getList());
container.classList.add('active-child');
onElementTransitionEnd(choiceList, function () {
enableTabbingForFocusableElements();

if (isChoiceListActive()) {
focusElement(document.querySelector('li.selected'), withOutline);
}
});
}

function hideChoiceList(withOutline) {
document.activeElement.blur();
disableTabbingForFocusableElements();
container.classList.remove('active-child');
onElementTransitionEnd(choiceList, function () {
if (isChoiceListActive()) {
enableTabbingForFocusableElements();
} else {
var item = getItemVisibleForChoiceList();
choiceList.innerHTML = '';
enableTabbingForFocusableElements();
focusElement(item.getEl(), withOutline);
}
});
}

function toggle(withOutline) {
isMainListActive() ? hide(true, withOutline) : show(withOutline);
}

function emitToggleEvent(isSettingsListVisible) {
var controls = gui.getGuiComponent(player_component["a" /* CONTROLS */]);
controls.trigger(control_event["SETTINGS_TOGGLE"], isSettingsListVisible);
}

function show(withOutline) {
var _settingsButton;

hideWithDelay();
enableTabbingForFocusableElements();
var visibleItems = getVisibleItems();
visibleItems.forEach(function (item) {
return mainList.appendChild(item.getEl());
});
onElementTransitionEnd(mainList, function () {
if (isMainListActive()) {
focusElement(visibleItems[0].getEl(), withOutline);
}
});
container.classList.add('active');
(_settingsButton = settingsButton) === null || _settingsButton === void 0 ? void 0 : _settingsButton.disableTooltip();
emitToggleEvent(true);
}

function hide(focusSettingsButton, withOutline) {
var _settingsButton2;

if (!isMainListActive()) {
return;
}

if (isChoiceListActive()) {
onElementTransitionEnd(mainList, function () {
choiceList.innerHTML = '';
});
}

if (focusSettingsButton) {
focusElement(document.querySelector("[data-button=\"".concat(SETTINGS, "\"]")), withOutline);
}

(_settingsButton2 = settingsButton) === null || _settingsButton2 === void 0 ? void 0 : _settingsButton2.enableTooltip();
disableTabbingForFocusableElements();
container.classList.remove('active', 'active-child');
emitToggleEvent(false);
}

function onElementTransitionEnd(element, handler) {
var onTransitionEndHandler = function onTransitionEndHandler() {
element.removeEventListener(dom_event["o" /* TRANSITION_END */], onTransitionEndHandler);
handler();
};

element.addEventListener(dom_event["o" /* TRANSITION_END */], onTransitionEndHandler);
}

function hideWithDelay() {
clearTimeout(hideTimeout);
hideTimeout = setTimeout(function () {
return hide(true, false);
}, 4000);
}

function getVisibleItems() {
return items.filter(function (item) {
return item.getChoices().length > 1;
});
}

function getFocusableElements() {
return isChoiceListActive() ? [choiceList.querySelector(".".concat(prefix, "-settings-header-button"))].concat(toConsumableArray_default()(choiceList.querySelectorAll('li'))) : [mainHeaderButton].concat(toConsumableArray_default()(getVisibleItems().map(function (item) {
return item.getEl();
})));
}

function onBlur(_ref3) {
var target = _ref3.target;
target.classList.remove(CONTROL_FOCUS_CLASS);
}

function onFocusWithTab(_ref4) {
var target = _ref4.target;
target.classList.add(CONTROL_FOCUS_CLASS);
}

function enableTabbingForFocusableElements() {
getFocusableElements().forEach(function (element) {
element.addEventListener(dom_event["a" /* BLUR */], onBlur);
element.addEventListener(dom_event["d" /* FOCUS_WITH_TAB */], onFocusWithTab);
element.tabIndex = 0;
element.dataset.button = SETTINGS_ELEMENT;
});
}

function disableTabbingForFocusableElements() {
getFocusableElements().forEach(function (element) {
element.removeEventListener(dom_event["a" /* BLUR */], onBlur);
element.removeEventListener(dom_event["d" /* FOCUS_WITH_TAB */], onFocusWithTab);
element.tabIndex = -1;
});
}

function focusElement(element, withOutline) {
element.focus();

if (withOutline) {
setTimeout(function () {
return document.activeElement.dispatchEvent(new Event(dom_event["d" /* FOCUS_WITH_TAB */]));
}, 0);
}
}

function focusElementByIndexDiff(focusIndexDiff) {
var focusableElements = getFocusableElements();
var focusedElementIndex = focusableElements.findIndex(function (elements) {
return elements === document.activeElement;
});
var focusedElementIndexWithDiff = focusedElementIndex + focusIndexDiff;
var newFocusedElementIndex = focusedElementIndexWithDiff < 0 ? focusableElements.length - 1 : focusedElementIndexWithDiff === focusableElements.length ? 0 : focusedElementIndexWithDiff;
focusElement(focusableElements[newFocusedElementIndex], true);
}

function handleKeyEvent(event) {
var eventKey = event.key.toLowerCase();
var isMainListHeaderFocused = document.activeElement === mainHeaderButton;
var isChoiceListHeaderFocused = document.activeElement === choiceList.querySelector('i');

switch (eventKey) {
case ESCAPE:
event.preventDefault();
hide(true, true);
break;

case SPACE:
event.preventDefault();

if (isMainListHeaderFocused) {
hide(true, true);
} else if (isChoiceListHeaderFocused) {
hideWithDelay();
hideChoiceList(true);
} else if (isChoiceListActive()) {
hideWithDelay();
getItemVisibleForChoiceList().onClick(event);
hideChoiceList(true);
} else {
hideWithDelay();
showChoiceList(event.target, true);
}

break;

case ArrowUp:
event.preventDefault();
hideWithDelay();
focusElementByIndexDiff(-1);
break;

case ArrowDown:
event.preventDefault();
hideWithDelay();
focusElementByIndexDiff(1);
break;

case TAB:
event.preventDefault();
hideWithDelay();
focusElementByIndexDiff(event.shiftKey ? -1 : 1);
break;

case ArrowRight:
event.preventDefault();
hideWithDelay();

if (!isChoiceListActive() && !isMainListHeaderFocused) {
showChoiceList(event.target);
}

break;

case ArrowLeft:
event.preventDefault();
hideWithDelay();

if (isChoiceListActive() && !isChoiceListHeaderFocused) {
hideChoiceList(true);
}

break;
}

return false;
}

var component = {
toggle: toggle,
handleKeyEvent: handleKeyEvent,
getElm: function getElm() {
return container;
}
};
gui.addGuiComponent(component, player_component["g" /* SETTINGS */]);
return component;
}

/* harmony default export */ var settings = (Settings);
// CONCATENATED MODULE: ./src/module/gui/index.js











function gui_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (gui_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function gui_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }





















var LIVE_LATENCY_BUFFER = 5; // [s]

var gui_Gui = /*#__PURE__*/function (_Component) {
inherits_default()(Gui, _Component);

var _super = gui_createSuper(Gui);

function Gui(player) {
var _this;

classCallCheck_default()(this, Gui);

_this = _super.call(this);
_this.player = player;
_this.options = _this.player.options;

if (!_this.options.get(option_name["q" /* CONTROLS */])) {
return possibleConstructorReturn_default()(_this);
}

Object.entries(_this.options.get(option_name["O" /* I18N */]) || {}).forEach(function (_ref) {
var _ref2 = slicedToArray_default()(_ref, 2),
key = _ref2[0],
value = _ref2[1];

return i18n_i18n.set(key, value);
});

var defaultGuiLanguage = _this.options.get(option_name["w" /* DEFAULT_GUI_LANGUAGE */]);

var language = _this.options.get(option_name["R" /* LANGUAGE */]) || core["a" /* default */].getBrowserLanguage();
i18n_i18n.setLanguage(language, defaultGuiLanguage);
_this.components = {};
_this.ControlEvent = control_event;
_this.videoWrapper = undefined;

_this.setCurrentPlayer(_this.player);

if (typeof _this.player.holderId === 'undefined') {
return possibleConstructorReturn_default()(_this);
}

_this.player.addComponent(assertThisInitialized_default()(_this), player_component["b" /* GUI */]);

_this.holder = document.getElementById(_this.player.holderId);

var fullscreenElementId = _this.player.options.get(option_name["I" /* FULLSCREEN_ELEMENT_ID */]) || _this.player.holderId;

_this.fullscreenElement = document.getElementById(fullscreenElementId);

if (!_this.options.get(option_name["q" /* CONTROLS */])) {
return possibleConstructorReturn_default()(_this);
}

_this.controlsBar = undefined;
_this.multiClickRef = null;
_this.container = null;
_this.updateTimeout = -1;
_this.hideCursorTimeout = -1;
_this.isBlockedAutoPlay = false;
_this.player.setFullscreen = _this.setFullscreen.bind(assertThisInitialized_default()(_this));
_this.unmuteOverlay = new unmute_overlay(player);
_this.overlayButtons = undefined;

_this.player.on(player_event["Y" /* READY */], function (renderer) {
return _this.ready(renderer);
});

_this.player.on(player_event["xb" /* VOLUME_CHANGE_REQUEST */], function () {
return _this.showControlsBar();
});

_this.player.on(player_event["yb" /* VOLUME_MUTE_REQUEST */], function () {
return _this.showControlsBar();
});

_this.player.on(player_event["db" /* SEEK_REQUEST */], function () {
return _this.showControlsBar();
});

_this.player.on(player_event["fb" /* SEEK_TO_REQUEST */], function () {
return _this.showControlsBar();
});

_this.player.on(player_event["q" /* FULLSCREEN_CHANGE_REQUEST */], function () {
return _this.setFullscreen();
});

_this.onContainerClickedHandler = function () {
return _this.onContainerClicked();
};

_this.onMouseMoveHandler = function () {
return _this.onMouseMove();
};

_this.onFullScreenChangeHandler = function (event) {
return _this.onFullScreenChange(event);
};

_this.handleKeyboardEvents = function (event) {
return keyboard_events_handleKeyboardEvents(_this.player, event);
};

return _this;
}

createClass_default()(Gui, [{
key: "ready",
value: function () {
var _ready = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee(renderer) {
var _this2 = this;

var controlsOpts, skin;
return regenerator_default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
this.rendererObj = renderer.getRendererElm();
this.cssPrefix = this.options.get(option_name["s" /* CSS_PREFIX */]);
this.timeShift = this.player.timeShift;
this.videoWrapper = this.player.getComponent(player_component["i" /* VIDEO_WRAPPER */]);
this.container = this.videoWrapper.getEl();

if (this.options.get(option_name["sb" /* SHOW_BUTTONS_OVER_VIDEO */])) {
this.overlayButtons = new overlay_buttons(this.player);
this.addGuiComponent(this.overlayButtons, 'overlay-buttons');
}

this.settings = new settings(this.player);
this.player.addComponent(this.settings, player_component["g" /* SETTINGS */]);

if (this.options.get(option_name["f" /* AUTOFOCUS */])) {
setTimeout(function () {
return _this2.container.focus();
}, 0);
}

this.rendererObj.setAttribute('id', this.options.get(option_name["db" /* NAME */]));
controlsOpts = {
cssPrefix: this.options.get(option_name["s" /* CSS_PREFIX */]),
layout: this.options.get(option_name["T" /* LAYOUT */]),
controlsLayout: this.options.get(option_name["r" /* CONTROLS_LAYOUT */]),
volumeType: this.options.get(option_name["Ub" /* VOLUME_TYPE */]),
volume: this.player.getVolume(),
hideControls: this.options.get(option_name["L" /* HIDE_CONTROLS */])
};
this.controlsBar = this.addControls('controls', controlsOpts);
document.addEventListener(dom_event["c" /* FOCUS */], function () {
if (_this2.controlsBar.elm.contains(document.activeElement) || _this2.settings.getElm().contains(document.activeElement)) {
_this2.controlsBar.onItemFocus();
}
}, true);
this.controlsBar.getButton(LIVE).setLabel(i18n_i18n.get('LIVE'));
this.player.addComponent(this.controlsBar, player_component["a" /* CONTROLS */]);

if (!this.options.get(option_name["g" /* AUTOPLAY */])) {
this.controlsBar.disable();
}

this.registerControlEvents();
this.container.addEventListener(dom_event["b" /* CLICK */], this.onContainerClickedHandler);
this.registerPlayerEvents(this.player);
this.spinner = new spinner_Spinner(this.cssPrefix);
this.addGuiComponent(this.spinner, 'spinner');
this.addGuiComponent(this.unmuteOverlay, 'unmute-overlay');
this.player.trigger(player_event["r" /* GUI_READY */], this);

if (!this.options.get(option_name["q" /* CONTROLS */])) {
_context.next = 30;
break;
}

skin = this.options.get(option_name["wb" /* SKIN */]);

if (!skin) {
_context.next = 28;
break;
}

_context.next = 28;
return core["a" /* default */].loadSkin(skin);

case 28:
this.updateLayout();
this.player.trigger(player_event["lb" /* STYLES */]);

case 30:
this.captureMouseMove(this.holder, this.onMouseMove.bind(this));
this.addTooltipTexts();
this.registerGuiEvents();

case 33:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));

function ready(_x) {
return _ready.apply(this, arguments);
}

return ready;
}()
}, {
key: "getLanguage",
value: function getLanguage() {
return i18n_i18n.getLanguage();
}
}, {
key: "getLanguages",
value: function getLanguages() {
return i18n_i18n.getLanguages();
}
}, {
key: "addTooltipTexts",
value: function addTooltipTexts() {
if (this.options.get(option_name["Ib" /* TOOLTIPS */])) {
var _this$controlsBar, _this$controlsBar$ful, _this$controlsBar2, _this$controlsBar2$vo, _this$controlsBar3, _this$controlsBar3$pa, _this$controlsBar4, _this$controlsBar4$pl, _this$controlsBar5, _this$controlsBar5$se;

var fullscreenTooltipText = [i18n_i18n.get('HELP_FULLSCREEN_ON'), i18n_i18n.get('HELP_FULLSCREEN_OFF')];
var volumeButtonText = [i18n_i18n.get('HELP_VOLUME_ON'), i18n_i18n.get('HELP_VOLUME_OFF')];
var pauseTooltipText = i18n_i18n.get('HELP_PAUSE');
var playTooltipText = i18n_i18n.get('HELP_PLAY');

if (this.options.get(option_name["Q" /* KEYBOARD_EVENTS */])) {
fullscreenTooltipText = fullscreenTooltipText.map(function (text) {
return "".concat(text, " (f)");
});
volumeButtonText = volumeButtonText.map(function (text) {
return "".concat(text, " (m)");
});
var spaceShortcut = " (".concat(i18n_i18n.get('HELP_SPACE'), ")");
pauseTooltipText += spaceShortcut;
playTooltipText += spaceShortcut;
}

(_this$controlsBar = this.controlsBar) === null || _this$controlsBar === void 0 ? void 0 : (_this$controlsBar$ful = _this$controlsBar.fullscreenButton) === null || _this$controlsBar$ful === void 0 ? void 0 : _this$controlsBar$ful.setTooltipText.apply(_this$controlsBar$ful, toConsumableArray_default()(fullscreenTooltipText));
(_this$controlsBar2 = this.controlsBar) === null || _this$controlsBar2 === void 0 ? void 0 : (_this$controlsBar2$vo = _this$controlsBar2.volumeButton) === null || _this$controlsBar2$vo === void 0 ? void 0 : _this$controlsBar2$vo.setTooltipText.apply(_this$controlsBar2$vo, toConsumableArray_default()(volumeButtonText));
(_this$controlsBar3 = this.controlsBar) === null || _this$controlsBar3 === void 0 ? void 0 : (_this$controlsBar3$pa = _this$controlsBar3.pauseButton) === null || _this$controlsBar3$pa === void 0 ? void 0 : _this$controlsBar3$pa.setTooltipText(pauseTooltipText);
(_this$controlsBar4 = this.controlsBar) === null || _this$controlsBar4 === void 0 ? void 0 : (_this$controlsBar4$pl = _this$controlsBar4.playButton) === null || _this$controlsBar4$pl === void 0 ? void 0 : _this$controlsBar4$pl.setTooltipText(playTooltipText);
(_this$controlsBar5 = this.controlsBar) === null || _this$controlsBar5 === void 0 ? void 0 : (_this$controlsBar5$se = _this$controlsBar5.settingsButton) === null || _this$controlsBar5$se === void 0 ? void 0 : _this$controlsBar5$se.setTooltipText(i18n_i18n.get('HELP_SETTINGS'));
}
}
}, {
key: "showControlsBar",
value: function showControlsBar() {
if (this.controlsBar) {
this.controlsBar.show();
}
}
}, {
key: "blockAutoPlay",
value: function blockAutoPlay() {
this.isBlockedAutoPlay = true;
}
}, {
key: "unBlockAutoPlay",
value: function unBlockAutoPlay() {
this.isBlockedAutoPlay = false;
}
}, {
key: "addGuiComponent",
value: function addGuiComponent(component, id) {
this.videoWrapper.addComponent(component, id);
}
}, {
key: "getGuiComponent",
value: function getGuiComponent(id) {
return this.videoWrapper.getComponent(id);
}
}, {
key: "getContainer",
value: function getContainer() {
return this.videoWrapper.getEl();
}
}, {
key: "getRendererContainer",
value: function getRendererContainer() {
return this.videoWrapper.getRendererContainer();
}
}, {
key: "removeGuiComponent",
value: function removeGuiComponent(id) {
this.videoWrapper.removeComponent(id);
}
}, {
key: "setCurrentPlayer",
value: function setCurrentPlayer(player) {
this.currentPlayer = player;
}
}, {
key: "onDblClick",
value: function onDblClick() {
this.setFullscreen();
}
}, {
key: "addControls",
value: function addControls(id) {
var _this3 = this;

var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var controlsBar = new controls_bar(id, opts);

if (!controlsBar.getElm()) {
return;
}

this.addGuiComponent(controlsBar, id);
setTimeout(function () {
_this3.registerGuiEvents();
}, 10);
return controlsBar;
}
}, {
key: "registerControlEvents",
value: function registerControlEvents() {
var _this4 = this;

if (this.controlsBar) {
this.controlsBar.fullscreenButton.on(dom_event["b" /* CLICK */], this.onFullscreenClicked.bind(this));
this.controlsBar.on(control_event["PAUSE_BUTTON_CLICKED"], function () {
_this4.player.pause();
});
this.controlsBar.on(control_event["PLAY_BUTTON_CLICKED"], function () {
_this4.player.play();
});
this.controlsBar.on(control_event["PROGRESS_POSITION_CHANGED"], function (position) {
if (_this4.timeShift.getMode() === timeshift["a" /* TimeShiftMode */].LIVE) {
_this4.controlsBar.liveButton.disableLive();
}

if (_this4.timeShift.getMode() === timeshift["a" /* TimeShiftMode */].LIVE_DELAYED && position === 100) {
_this4.timeShift.setMode(timeshift["a" /* TimeShiftMode */].LIVE);

_this4.controlsBar.liveButton.enableLive();
}

if (position === 100 && !_this4.timeShift.isEnabled()) {
position = 99.9;
}

_this4.player.trigger(player_event["db" /* SEEK_REQUEST */], position);
});
this.controlsBar.on(control_event["PROGRESS_MOVE"], function (position, positionTooltip) {
var seconds = position / 100 * (_this4.player.getDuration() - _this4.player.getLiveDelay());

if (seconds >= 0) {
_this4.controlsBar.progressControl.updateTooltip(_this4.formatTooltip(seconds), positionTooltip);
}
});
this.controlsBar.on(control_event["VOLUME_CHANGED"], function (volume) {
_this4.player.trigger(player_event["xb" /* VOLUME_CHANGE_REQUEST */], volume);
});
this.controlsBar.on(control_event["VOLUME_MUTE_STATE_CHANGED"], function (muted) {
_this4.player.trigger(player_event["yb" /* VOLUME_MUTE_REQUEST */], muted);
});
this.controlsBar.on(control_event["LIVE_BUTTON_CLICKED"], function () {
if (_this4.timeShift.isEnabled()) {
_this4.timeShift.reset();

_this4.controlsBar.progressControl.isSeeking = false;

if (_this4.timeShift.isLive()) {
_this4.controlsBar.liveButton.enableLive();
}
}

var onLiveButtonAction = _this4.options.get(option_name["eb" /* ON_LIVE_BUTTON_ACTION */]);

if (onLiveButtonAction === 'seek') {
_this4.player.seekToHead();
} else {
_this4.player.restart();
}
});
this.controlsBar.on(control_event["SEEK_TO_HEAD"], function () {
_this4.player.seekToHead();
});
this.controlsBar.on(control_event["CONTROLS_HIDE"], function () {
_this4.player.trigger(control_event["CONTROLS_HIDE"]);
});
this.controlsBar.on(control_event["CONTROLS_SHOW"], function () {
_this4.player.trigger(control_event["CONTROLS_SHOW"]);
});
}
}
}, {
key: "formatTooltip",
value: function formatTooltip(seconds) {
var value = '';

if (this.timeShift.isEnabled() && (this.timeShift.dvrWindow >= 0 || this.timeShift.getStart() >= 0) && !this.timeShift.isVod()) {
value = core["a" /* default */].formatDateTime(new Date((this.timeShift.getStart() + seconds) * 1000), 'HH:mm:ss');
} else {
value = core["a" /* default */].formatTime(seconds);
}

return value;
}
}, {
key: "onFullscreenClicked",
value: function onFullscreenClicked() {
this.setFullscreen();
}
}, {
key: "unRegisterEvents",
value: function unRegisterEvents(player) {
player.off(player_event["E" /* ON_SOURCE */], this.onSource);
player.off(player_event["O" /* PLAYING */], this.onPlaying);
player.off(player_event["zb" /* WAITING */], this.onWaiting);
player.off(player_event["G" /* PAUSED */], this.onPaused);
player.off(player_event["ib" /* STOPPED */], this.onStopped);
player.off(player_event["n" /* ENDED */], this.onEnded);
player.off(player_event["ab" /* RESIZE */], this.onResize);
player.off(player_event["l" /* DESTROY */], this.onDestroy);
player.off(player_event["h" /* CAN_PLAY */], this.onCanplay);
}
}, {
key: "registerPlayerEvents",
value: function registerPlayerEvents(player) {
this.unRegisterEvents(player);
this.onSource = this.onSource.bind(this);
this.onPlaying = this.onPlaying.bind(this);
this.onWaiting = this.onWaiting.bind(this);
this.onPaused = this.onPaused.bind(this);
this.onStopped = this.onStopped.bind(this);
this.onEnded = this.onEnded.bind(this);
this.onResize = this.onResize.bind(this);
this.onDestroy = this.onDestroy.bind(this);
this.onMonitor = this.onMonitor.bind(this);
this.onLive = this.onLive.bind(this);
this.onVolumeChanged = this.onVolumeChanged.bind(this);
this.onTimeShift = this.onTimeShift.bind(this);
this.onProfileChanged = this.onProfileChanged.bind(this);
this.onProfileList = this.onProfileList.bind(this);
this.onSeekStart = this.onSeekStart.bind(this);
this.onSeekEnd = this.onSeekEnd.bind(this);
this.onPlayInterrupted = this.onPlayInterrupted.bind(this);
this.onCanplay = this.onCanplay.bind(this);
this.onTime = this.onTime.bind(this);
player.on(player_event["z" /* MONITOR */], this.onMonitor);
player.on(player_event["E" /* ON_SOURCE */], this.onSource);
player.on(player_event["O" /* PLAYING */], this.onPlaying);
player.on(player_event["zb" /* WAITING */], this.onWaiting);
player.on(player_event["G" /* PAUSED */], this.onPaused);
player.on(player_event["ib" /* STOPPED */], this.onStopped);
player.on(player_event["n" /* ENDED */], this.onEnded);
player.on(player_event["ab" /* RESIZE */], this.onResize);
player.on(player_event["l" /* DESTROY */], this.onDestroy);
player.on(player_event["D" /* ON_LIVE */], this.onLive);
player.on(player_event["wb" /* VOLUME_CHANGED */], this.onVolumeChanged);
player.on(player_event["F" /* ON_TIMESHIFT */], this.onTimeShift);
player.on(player_event["T" /* PROFILE_CHANGED */], this.onProfileChanged);
player.on(player_event["X" /* PROFILE_LIST */], this.onProfileList);
player.on(player_event["Q" /* PLAY_INTERRUPTED */], this.onPlayInterrupted);
player.on(player_event["h" /* CAN_PLAY */], this.onCanplay);
player.on(player_event["eb" /* SEEK_START */], this.onSeekStart);
player.on(player_event["cb" /* SEEK_END */], this.onSeekEnd);
player.on(player_event["tb" /* TIME */], this.onTime);
}
}, {
key: "onPlayInterrupted",
value: function onPlayInterrupted() {
var _this5 = this;

var policy = this.options.get(option_name["h" /* AUTOPLAY_BLOCKED_RULE */]);

if (policy === 'resume') {
this.onPaused(this.player.getCurrentTime(), true);
this.showPlayBigButton();
}

if (policy === 'mute') {
this.player.mute();
this.unmuteOverlay.show();
setTimeout(function () {
return _this5.player.play();
}, 0);
}
}
}, {
key: "getButton",
value: function getButton(name) {
return this.controlsBar.getButton(name);
}
}, {
key: "getButtonElm",
value: function getButtonElm(name) {
return this.controlsBar.getButtonElm(name);
}
}, {
key: "onMouseEnter",
value: function onMouseEnter() {}
}, {
key: "updateIfHolderVisible",
value: function updateIfHolderVisible(holder) {
var _this6 = this;

clearTimeout(this.updateTimeout);
this.updateTimeout = setTimeout(function () {
if (!holder || holder.offsetParent === null) {
_this6.updateIfHolderVisible();
}
}, 100);
}
}, {
key: "onRendererClicked",
value: function onRendererClicked() {
if (this.options.get(option_name["fb" /* PAUSE_ON_VIDEO_CLICK */])) {
this.player.trigger(player_event["ub" /* TOGGLE_PLAY_PAUSE_REQUEST */]);
}
}
}, {
key: "onContainerClicked",
value: function onContainerClicked() {
this.container.focus();
}
}, {
key: "onMouseMove",
value: function onMouseMove() {
this.trigger(control_event["MOUSE_MOVE"]);

if (this.controlsBar) {
this.controlsBar.show();
}

if (this.container.classList.contains('hide-cursor')) {
this.container.classList.remove('hide-cursor');
}

this.hideCursor();
}
}, {
key: "hideCursor",
value: function hideCursor() {
var _this$controlsBar6,
_this7 = this;

var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4000;

if ((_this$controlsBar6 = this.controlsBar) === null || _this$controlsBar6 === void 0 ? void 0 : _this$controlsBar6.isMouseOver) {
clearTimeout(this.hideCursorTimeout);
return;
}

clearTimeout(this.hideCursorTimeout);
this.hideCursorTimeout = setTimeout(function () {
_this7.container.classList.add('hide-cursor');
}, timeout);
}
}, {
key: "appendRenderer",
value: function appendRenderer(renderer) {
this.videoWrapper.addRenderer(renderer);
}
}, {
key: "updateLayout",
value: function updateLayout() {
this.videoWrapper.updateDims();
this.updateVolume();
}
}, {
key: "updateVideoProgress",
value: function updateVideoProgress(time, duration) {
var percentPosition = time / duration * 100;
this.controlsBar.progressControl.isSeeking = true;
this.controlsBar.progressControl.update(percentPosition, duration, true);
this.controlsBar.timeDisplay.update(time, duration);
this.controlsBar.show();
}
}, {
key: "updateVolume",
value: function updateVolume(volume) {
var _this$controlsBar7;

(_this$controlsBar7 = this.controlsBar) === null || _this$controlsBar7 === void 0 ? void 0 : _this$controlsBar7.updateVolumeProgress(volume || this.player.getVolume(), this.player.isMuted());
}
}, {
key: "registerGuiEvents",
value: function registerGuiEvents() {
this.removeRegisterGuiEvents();
this.holder.addEventListener(dom_event["g" /* MOUSE_ENTER */], this.onMouseMoveHandler);

if (fullscreenApi) {
document.addEventListener(fullscreenApi[FULLSCREEN_CHANGE], this.onFullScreenChangeHandler);
}

this.multiClickRef = onMultiClickHandler(this.onRendererClicked.bind(this), this.onDblClick.bind(this));
this.rendererObj.addEventListener(dom_event["b" /* CLICK */], this.multiClickRef);

if (this.options.get(option_name["Q" /* KEYBOARD_EVENTS */])) {
this.addKeyboardEvents();
}
}
}, {
key: "removeRegisterGuiEvents",
value: function removeRegisterGuiEvents() {
if (fullscreenApi) {
document.removeEventListener(fullscreenApi[FULLSCREEN_CHANGE], this.onFullScreenChangeHandler);
}

this.holder.removeEventListener(dom_event["g" /* MOUSE_ENTER */], this.onMouseMoveHandler);

if (this.rendererObj) {
this.rendererObj.removeEventListener(dom_event["b" /* CLICK */], this.multiClickRef);
}

this.removeKeyboardEvents();
}
}, {
key: "addKeyboardEvents",
value: function addKeyboardEvents() {
this.removeKeyboardEvents();
document.addEventListener(dom_event["e" /* KEY_DOWN */], this.handleKeyboardEvents);
}
}, {
key: "removeKeyboardEvents",
value: function removeKeyboardEvents() {
document.removeEventListener(dom_event["e" /* KEY_DOWN */], this.handleKeyboardEvents);
}
}, {
key: "onDestroy",
value: function onDestroy() {
this.removeRegisterGuiEvents();
clearTimeout(this.updateTimeout);
}
}, {
key: "onResize",
value: function onResize(width, height) {
this.options.set(option_name["Vb" /* WIDTH */], width);
this.options.set(option_name["K" /* HEIGHT */], height);
}
}, {
key: "onMonitor",
value: function onMonitor(time, duration) {
if (!this.controlsBar || this.controlsBar.progressControl.isSeeking) {
return;
}

if (time === 0) {
return;
}

if (time < 0) {
time = 0;
}

duration -= this.player.getLiveDelay();
var percentPosition = Math.min(Math.max(time / duration * 100, 0), 100);

if (this.timeShift.getMode() === timeshift["a" /* TimeShiftMode */].LIVE) {
percentPosition = 100;
}

this.controlsBar.timeDisplay.update(time, duration);
this.controlsBar.progressControl.update(percentPosition, duration);
var currentTime = parseInt(time, 10);
var formattedTime = this.timeShift.isEnabled() ? this.formatTooltip(time) : currentTime;
this.controlsBar.progressControl.updateAriaAttrs(currentTime, formattedTime);
}
}, {
key: "onSource",
value: function onSource() {
var _this$controlsBar8;

this.spinner.show();
this.registerGuiEvents();
this.updateVolume();
(_this$controlsBar8 = this.controlsBar) === null || _this$controlsBar8 === void 0 ? void 0 : _this$controlsBar8.showPause();
}
}, {
key: "onPlaying",
value: function onPlaying() {
this.spinner.hide();

if (this.controlsBar) {
this.controlsBar.enable();
this.controlsBar.showPause();
}
}
}, {
key: "onPaused",
value: function onPaused() {
this.spinner.hide();

if (!this.controlsBar) {
return;
}

this.controlsBar.onPaused();
}
}, {
key: "onCanplay",
value: function onCanplay() {
this.spinner.hide();
}
}, {
key: "onStopped",
value: function onStopped() {
this.spinner.hide();

if (this.controlsBar) {
this.controlsBar.onStop();
}
}
}, {
key: "onWaiting",
value: function onWaiting() {
if (!this.currentPlayer.isPaused()) {
this.spinner.show();
}
}
}, {
key: "onEnded",
value: function onEnded() {
this.spinner.hide();

if (this.controlsBar) {
this.controlsBar.showPlay();
this.controlsBar.disable();
}
}
}, {
key: "onLive",
value: function onLive() {
if (this.controlsBar && !this.timeShift.isEnabled()) {
this.controlsBar.showLive();
}
}
}, {
key: "onVolumeChanged",
value: function onVolumeChanged(volume) {
this.updateVolume(volume);
}
}, {
key: "onTimeShift",
value: function onTimeShift() {
if (this.controlsBar) {
this.controlsBar.showTimeShift(this.timeShift.getMode());
}
}
}, {
key: "onProfileChanged",
value: function onProfileChanged(profile, currentTime, adaptationEnabled) {
if (this.controlsBar && this.controlsBar.profileButton) {
this.controlsBar.profileButton.onProfile(currentTime, profile, adaptationEnabled);
}
}
}, {
key: "onProfileList",
value: function onProfileList(profiles) {
if (this.controlsBar) {
if (this.controlsBar.profileButton) {
this.controlsBar.profileButton.onProfiles(profiles);
}
}
}
}, {
key: "onSeekStart",
value: function onSeekStart() {
if (!this.controlsBar) {
return;
}

this.controlsBar.onSeekStart();
}
}, {
key: "onSeekEnd",
value: function onSeekEnd() {
if (!this.controlsBar) {
return;
}

this.controlsBar.progressControl.isSeeking = false;

if (this.player.isPaused()) {
this.controlsBar.showPlay();
}
}
}, {
key: "onTime",
value: function onTime() {
if (!this.timeShift.isLive()) {
return;
}

var mode = this.timeShift.getMode();
var initialLatency = this.player.renderer.initialLatency;
var headDelay = this.player.getLiveLatency() - initialLatency;

if (mode === timeshift["a" /* TimeShiftMode */].LIVE_DELAYED && headDelay <= LIVE_LATENCY_BUFFER) {
this.timeShift.setMode(timeshift["a" /* TimeShiftMode */].LIVE);
this.controlsBar.liveButton.enableLive();
}

if (mode === timeshift["a" /* TimeShiftMode */].LIVE && headDelay >= LIVE_LATENCY_BUFFER) {
this.timeShift.setMode(timeshift["a" /* TimeShiftMode */].LIVE_DELAYED);
this.controlsBar.liveButton.disableLive();
}
}
}, {
key: "setFullscreen",
value: function setFullscreen() {
fullscreen_toggleFullscreen(this.fullscreenElement);
}
}, {
key: "lockOrientation",
value: function lockOrientation() {
screen.orientation.lock('landscape');
}
}, {
key: "unLockOrientation",
value: function unLockOrientation() {
screen.orientation.unlock();
}
}, {
key: "isFullscreen",
value: function isFullscreen() {
return fullscreen_isFullscreen(this.fullscreenElement);
}
}, {
key: "showSpinner",
value: function showSpinner() {
this.hidePlayBigButton.hide();
this.spinner.show();
}
}, {
key: "hideSpinner",
value: function hideSpinner() {
this.spinner.hide();
}
}, {
key: "hidePlayBigButton",
value: function hidePlayBigButton() {
var _this$overlayButtons;

(_this$overlayButtons = this.overlayButtons) === null || _this$overlayButtons === void 0 ? void 0 : _this$overlayButtons.hideOverlay();
}
}, {
key: "showPlayBigButton",
value: function showPlayBigButton() {
var _this$overlayButtons2;

var timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
(_this$overlayButtons2 = this.overlayButtons) === null || _this$overlayButtons2 === void 0 ? void 0 : _this$overlayButtons2.showPlay();
}
}, {
key: "onFullScreenChange",
value: function onFullScreenChange(event) {
var _screen;

if (event.target !== this.fullscreenElement) {
return;
}

var isFullscreen = this.isFullscreen();

if (isFullscreen) {
this.holder.classList.add('mode-fullscreen');
this.container.style.width = '100%';
this.container.style.height = '100%';
} else {
this.holder.classList.remove('mode-fullscreen');
this.container.style.width = this.options.getWidthWithUnit();
this.container.style.height = this.options.getHeightWithUnit();
}

this.trigger(player_event["p" /* FULLSCREEN_CHANGED */], isFullscreen);
this.player.trigger(player_event["p" /* FULLSCREEN_CHANGED */], isFullscreen);
this.controlsBar.fullscreenButton.update(isFullscreen);

if (browser["a" /* default */].isMobile() && ((_screen = screen) === null || _screen === void 0 ? void 0 : _screen.orientation)) {
if (isFullscreen) {
this.lockOrientation();
} else {
this.unLockOrientation();
}
}
}
}, {
key: "captureMouseMove",
value: function captureMouseMove(target, callback) {
var threshold = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 12;
var lastCoordLeft;
var lastCoordTop;
var timeout;

var mouseMove = function mouseMove(event) {
var delta = {
left: event.clientX - lastCoordLeft,
top: event.clientY - lastCoordTop
};

if (Math.abs(delta.left) > threshold || Math.abs(delta.top) > threshold) {
callback();
}

clearTimeout(timeout);
timeout = setTimeout(function () {
lastCoordLeft = event.clientX;
lastCoordTop = event.clientY;
}, 100);
};

target.removeEventListener(dom_event["i" /* MOUSE_MOVE */], mouseMove);
target.addEventListener(dom_event["i" /* MOUSE_MOVE */], mouseMove);
return mouseMove;
}
}]);

return Gui;
}(core_component["a" /* default */]);

function onMultiClickHandler(onClick, onDblClick) {
var clicks = 0;
var clickTimeout;
return function () {
clicks++;
clearTimeout(clickTimeout);
clickTimeout = setTimeout(function () {
if (clicks === 1) {
onClick();
}

clicks = 0;
}, 350);

if (clicks > 1) {
onDblClick();
clicks = 0;
}
};
}

gui_Gui.enabled = true;
gui_Gui.moduleId = 'gui';










/* harmony default export */ var module_gui = (gui_Gui);
// EXTERNAL MODULE: ./src/core/util/date.js
var date = __webpack_require__(43);

// CONCATENATED MODULE: ./src/module/cast-sender/cast-api-available.js
var RESOLVE_TIMEOUT = 1000; // [ms]

var castApiAvailable = function castApiAvailable() {
var resolveTimeoutId;
var promise = new Promise(function (resolve, reject) {
if (window.cast) {
resolve();
} else {
window['__onGCastApiAvailable'] = function (isAvailable) {
if (isAvailable) {
if (document.readyState === 'complete') {
resolve();
} else {
var loadCb = function loadCb() {
resolve();
window.removeEventListener('load', loadCb);
};

window.addEventListener('load', loadCb);
}
} else {
reject();
}
};
}

resolveTimeoutId = setTimeout(function () {
return reject();
}, RESOLVE_TIMEOUT);
});
return promise["catch"](function () {
return clearTimeout(resolveTimeoutId);
}).then(function () {
return clearTimeout(resolveTimeoutId);
});
};

/* harmony default export */ var cast_api_available = (castApiAvailable()["catch"](function () {
return Promise.reject();
}));
// CONCATENATED MODULE: ./src/module/cast-sender/cast-service.js






function cast_service_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (cast_service_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function cast_service_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }



var instance;

var cast_service_CastService = /*#__PURE__*/function (_EventEmitter) {
inherits_default()(CastService, _EventEmitter);

var _super = cast_service_createSuper(CastService);

function CastService() {
var _this;

classCallCheck_default()(this, CastService);

_this = _super.call(this);
_this.castApiAvailablePromise = undefined;
return _this;
}

createClass_default()(CastService, [{
key: "initializeCastApi",
value: function initializeCastApi(appId) {
var _this2 = this;

if (this.castApiAvailablePromise) {
return this.castApiAvailablePromise;
}

var castContext = this.getCastContext();

if (castContext) {
this.setupContext(castContext, appId);
return Promise.resolve();
}

this.castApiAvailablePromise = cast_api_available.then(function () {
var castContext = _this2.getCastContext();

_this2.setupContext(castContext, appId);
});
return this.castApiAvailablePromise;
}
}, {
key: "setupContext",
value: function setupContext(castContext, appId) {
var _chrome,
_this3 = this;

if (!((_chrome = chrome) === null || _chrome === void 0 ? void 0 : _chrome.cast)) {
return;
}

castContext.setOptions({
receiverApplicationId: appId,
autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED
});
var _cast$framework$CastC = cast.framework.CastContextEventType,
CAST_STATE_CHANGED = _cast$framework$CastC.CAST_STATE_CHANGED,
SESSION_STATE_CHANGED = _cast$framework$CastC.SESSION_STATE_CHANGED;
castContext.addEventListener(SESSION_STATE_CHANGED, function (event) {
return _this3.trigger(SESSION_STATE_CHANGED, event.sessionState);
});
castContext.addEventListener(CAST_STATE_CHANGED, function (event) {
return _this3.trigger(CAST_STATE_CHANGED, event.castState);
});
}
}, {
key: "getCastSession",
value: function getCastSession() {
var castContext = this.getCastContext();
return castContext === null || castContext === void 0 ? void 0 : castContext.getCurrentSession();
}
}, {
key: "getCastDevice",
value: function getCastDevice() {
var _this$getCastSession;

return (_this$getCastSession = this.getCastSession()) === null || _this$getCastSession === void 0 ? void 0 : _this$getCastSession.getCastDevice();
}
}, {
key: "getSessionState",
value: function getSessionState() {
var _this$getCastSession2;

return (_this$getCastSession2 = this.getCastSession()) === null || _this$getCastSession2 === void 0 ? void 0 : _this$getCastSession2.getSessionState();
}
}, {
key: "getCastState",
value: function getCastState() {
var _this$getCastContext;

return (_this$getCastContext = this.getCastContext()) === null || _this$getCastContext === void 0 ? void 0 : _this$getCastContext.getCastState();
}
}, {
key: "getMediaSession",
value: function getMediaSession() {
var _this$getCastSession3;

return (_this$getCastSession3 = this.getCastSession()) === null || _this$getCastSession3 === void 0 ? void 0 : _this$getCastSession3.getMediaSession();
}
}, {
key: "getCastContext",
value: function getCastContext() {
var _window$cast;

return (_window$cast = window.cast) === null || _window$cast === void 0 ? void 0 : _window$cast.framework.CastContext.getInstance();
}
}, {
key: "connect",
value: function connect() {
var _this$getCastContext2;

return (_this$getCastContext2 = this.getCastContext()) === null || _this$getCastContext2 === void 0 ? void 0 : _this$getCastContext2.requestSession();
}
}, {
key: "endSession",
value: function endSession() {
var _this$getCastSession4;

(_this$getCastSession4 = this.getCastSession()) === null || _this$getCastSession4 === void 0 ? void 0 : _this$getCastSession4.endSession(true);
}
}, {
key: "loadMedia",
value: function loadMedia(request) {
var _this$getCastSession5;

return (_this$getCastSession5 = this.getCastSession()) === null || _this$getCastSession5 === void 0 ? void 0 : _this$getCastSession5.loadMedia(request);
}
}], [{
key: "getInstance",
value: function getInstance() {
instance = instance || new CastService();
return instance;
}
}]);

return CastService;
}(event_emitter["a" /* default */]);

/* harmony default export */ var cast_service = (cast_service_CastService);
// CONCATENATED MODULE: ./src/module/cast-sender/remote-player-service.js






function remote_player_service_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (remote_player_service_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function remote_player_service_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }


var remote_player_service_instance;

var remote_player_service_RemotePlayerService = /*#__PURE__*/function (_EventEmitter) {
inherits_default()(RemotePlayerService, _EventEmitter);

var _super = remote_player_service_createSuper(RemotePlayerService);

function RemotePlayerService() {
var _this;

classCallCheck_default()(this, RemotePlayerService);

_this = _super.call(this);
_this.remotePlayer = new window.cast.framework.RemotePlayer();
_this.remotePlayerController = new window.cast.framework.RemotePlayerController(_this.remotePlayer);
var _cast$framework$Remot = cast.framework.RemotePlayerEventType,
CURRENT_TIME_CHANGED = _cast$framework$Remot.CURRENT_TIME_CHANGED,
PLAYER_STATE_CHANGED = _cast$framework$Remot.PLAYER_STATE_CHANGED;

_this.remotePlayerController.addEventListener(CURRENT_TIME_CHANGED, function (event) {
return _this.onRemotePlayerTimeChanged(event);
});

_this.remotePlayerController.addEventListener(PLAYER_STATE_CHANGED, function (event) {
return _this.onRemotePlayerStateChanged(event);
});

return _this;
}

createClass_default()(RemotePlayerService, [{
key: "seek",
value: function seek(percentPosition) {
this.remotePlayer.currentTime = percentPosition * this.remotePlayer.duration / 100;
this.remotePlayerController.seek();
}
}, {
key: "seekTo",
value: function seekTo(timePosition) {
this.remotePlayer.currentTime = timePosition;
this.remotePlayerController.seek();
}
}, {
key: "setVolume",
value: function setVolume(volume) {
if (this.remotePlayerController) {
this.remotePlayer.volumeLevel = volume / 100;
this.remotePlayerController.setVolumeLevel();
}
}
}, {
key: "stop",
value: function stop() {
this.remotePlayerController.stop();
}
}, {
key: "playOrPause",
value: function playOrPause() {
this.remotePlayerController.playOrPause();
}
}, {
key: "onRemotePlayerTimeChanged",
value: function onRemotePlayerTimeChanged(event) {
var currentTime = this.remotePlayer.currentTime;
var duration = this.remotePlayer.duration;

if (this.remotePlayer.liveSeekableRange) {
duration = this.remotePlayer.liveSeekableRange.end;
}

this.trigger(cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED, currentTime, duration);
}
}, {
key: "onRemotePlayerStateChanged",
value: function onRemotePlayerStateChanged(event) {
this.trigger(cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED, event);
}
}, {
key: "getPlayerState",
value: function getPlayerState() {
var _this$remotePlayer;

return (_this$remotePlayer = this.remotePlayer) === null || _this$remotePlayer === void 0 ? void 0 : _this$remotePlayer.playerState;
}
}], [{
key: "getInstance",
value: function getInstance() {
remote_player_service_instance = remote_player_service_instance || new RemotePlayerService();
return remote_player_service_instance;
}
}]);

return RemotePlayerService;
}(event_emitter["a" /* default */]);

/* harmony default export */ var remote_player_service = (remote_player_service_RemotePlayerService);
// CONCATENATED MODULE: ./src/module/cast-sender/remote-player-status.js
var BUFFERING = 'BUFFERING';
var IDLE = 'IDLE';
var PAUSED = 'PAUSED';
var PLAYING = 'PLAYING';
// CONCATENATED MODULE: ./src/module/cast-sender/gui/info-bar.js





var info_bar_InfoBar = /*#__PURE__*/function () {
function InfoBar(player) {
var _this = this;

classCallCheck_default()(this, InfoBar);

this.player = player;
this.bar = undefined;
this.icon = undefined;
this.label = undefined;
this.created = false;
this.gui = this.player.getComponent(player_component["b" /* GUI */]);

if (!this.gui) {
return;
}

player.on(player_event["i" /* CHROMECAST_CONNECTED */], function (device) {
return _this.show(device);
});
player.on(player_event["j" /* CHROMECAST_DISCONNECTED */], function () {
return _this.hide();
});
}

createClass_default()(InfoBar, [{
key: "create",
value: function create() {
var container = this.gui.getContainer();
this.bar = document.createElement('div');
this.bar.classList.add("".concat(this.player.options.get('cssPrefix'), "-cast-bar"));
this.icon = document.createElement('span');
this.bar.appendChild(this.icon);
this.label = document.createElement('p');
this.bar.appendChild(this.label);
container.appendChild(this.bar);
}
}, {
key: "show",
value: function show(device) {
if (!this.created) {
this.create();
this.created = true;
}

if (this.bar) {
this.bar.classList.add('active');
this.label.innerHTML = device.friendlyName;
}
}
}, {
key: "hide",
value: function hide() {
if (this.bar) {
this.bar.classList.remove('active');
}
}
}]);

return InfoBar;
}();

/* harmony default export */ var info_bar = (info_bar_InfoBar);
// CONCATENATED MODULE: ./src/module/cast-sender/gui/index.js









var WAIT_FOR_RESUME_TIMEOUT = 100;

var gui_ChromecastGui = /*#__PURE__*/function () {
function ChromecastGui(player, isAutoplayEnabled) {
var _this = this;

classCallCheck_default()(this, ChromecastGui);

this.player = player;
this.gui = undefined;
this.isAutoplayEnabled = isAutoplayEnabled;
this.playerState = IDLE;
cast_api_available.then(function () {
_this.player.on(cast.framework.CastContextEventType.SESSION_STATE_CHANGED, function (state, session) {
return _this.onSessionStateChanged(state, session);
});

_this.player.on(cast.framework.CastContextEventType.CAST_STATE_CHANGED, function (state) {
return _this.onCastStateChanged(state);
});

_this.player.on(cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED, function (event) {
return _this.onPlayerStateChanged(event);
});

_this.player.on(cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED, function (time, duration) {
return _this.onPlayerTimeChanged(time, duration);
});
})["catch"](function () {});
this.init();
}

createClass_default()(ChromecastGui, [{
key: "init",
value: function init() {
var _this2 = this;

this.gui = this.player.getComponent(player_component["b" /* GUI */]);
this.controls = this.player.getComponent(player_component["a" /* CONTROLS */]);
cast_api_available.then(function () {
return _this2.initCastGui();
})["catch"](function () {});
}
}, {
key: "initCastGui",
value: function initCastGui() {
var _this3 = this;

new info_bar(this.player);
this.castButton = this.controls.createButton(CAST);
this.castButton.on(dom_event["b" /* CLICK */], function () {
return _this3.player.connect();
});
this.castButton.setTooltipText(i18n_i18n.get('HELP_CHROMECAST'));
this.controls.addAccessibility(this.castButton);
this.controls.addExtraControl(this.castButton);
this.controls.rebuild();

if (this.isAutoplayEnabled) {
this.gui.hidePlayBigButton();
}
}
}, {
key: "onSessionStateChanged",
value: function onSessionStateChanged(state, session) {
var _this4 = this;

switch (state) {
case cast.framework.SessionState.SESSION_RESUMED:
if (this.playerState === IDLE) {
this.gui.showPlayBigButton();
}

setTimeout(function () {
var playerOptions = session && session.customData && session.customData.options;

if (playerOptions && playerOptions.live) {
_this4.controls.showLive();
}
}, WAIT_FOR_RESUME_TIMEOUT);
break;
}
}
}, {
key: "onCastStateChanged",
value: function onCastStateChanged(state) {
var _this5 = this;

switch (state) {
case cast.framework.CastState.NO_DEVICES_AVAILABLE:
this.castButton.removeClass('active');
this.castButton.hide();
break;

case cast.framework.CastState.NOT_CONNECTED:
this.castButton.removeClass('active');
this.castButton.show();
break;

case cast.framework.CastState.CONNECTED:
this.castButton.addClass('active');
this.castButton.show();
setTimeout(function () {
if (_this5.playerState !== PLAYING) {
_this5.gui.showSpinner();
}
}, 0);
break;
}
}
}, {
key: "onPlayerStateChanged",
value: function onPlayerStateChanged(event) {
var _this6 = this;

this.playerState = event.value;

switch (event.value) {
case PLAYING:
setTimeout(function () {
return _this6.controls.showPause();
}, 0);
this.gui.hidePlayBigButton();
this.gui.hideSpinner();
this.controls.enable();
break;

case PAUSED:
this.gui.showPlayBigButton();
break;

case IDLE:
this.gui.showPlayBigButton();
this.controls.showPlay();
this.gui.showPlayBigButton();
break;
}
}
}, {
key: "onPlayerTimeChanged",
value: function onPlayerTimeChanged(time, duration) {
var percentPosition = time / duration * 100;
this.gui.controlsBar.progressControl.update(percentPosition, duration);
this.gui.controlsBar.timeDisplay.update(time, duration);
}
}]);

return ChromecastGui;
}();

/* harmony default export */ var cast_sender_gui = (gui_ChromecastGui);
// CONCATENATED MODULE: ./src/module/cast-sender/index.js





function cast_sender_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function cast_sender_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { cast_sender_ownKeys(Object(source), true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { cast_sender_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }









var cast_sender_WAIT_FOR_RESUME_TIMEOUT = 300;

var cast_sender_CastSenderModule = /*#__PURE__*/function () {
function CastSenderModule(player) {
var _this = this;

classCallCheck_default()(this, CastSenderModule);

this.player = player;
this.options = this.player.options;
this.id = this.options.get('id');
this.chromecastOpts = this.options.get('chromecast');

if (!this.chromecastOpts) {
return;
}

this.appId = this.chromecastOpts.appId;
this.chromecastOpts.resumeSession = true;
this.initAutoplay = this.options.get(option_name["g" /* AUTOPLAY */]);

if (this.chromecastOpts.resumeSession) {
this.options.set(option_name["g" /* AUTOPLAY */], false);
}

this.castService = cast_service.getInstance();
this.remotePlayerService = null;
this.currentTime = 0;
this.stopped = false;

this.player.connect = function () {
return _this.connect();
};

this.player.on(player_event["Y" /* READY */], function () {
return _this.init();
});
this.player.on(player_event["r" /* GUI_READY */], function () {
return new cast_sender_gui(_this.player, _this.initAutoplay);
});
}

createClass_default()(CastSenderModule, [{
key: "init",
value: function init() {
var _this2 = this;

var initCastState = this.castService.getCastState();
this.castService.initializeCastApi(this.appId).then(function () {
_this2.remotePlayerService = remote_player_service.getInstance();

var castState = _this2.castService.getCastState();

if (castState) {
_this2.player.trigger(cast.framework.CastContextEventType.CAST_STATE_CHANGED, castState);
}

if (_this2.chromecastOpts.resumeSession) {
setTimeout(function () {
var _mediaSession$customD, _mediaSession$customD2;

var mediaSession = _this2.castService.getMediaSession();

var videoId = mediaSession === null || mediaSession === void 0 ? void 0 : (_mediaSession$customD = mediaSession.customData) === null || _mediaSession$customD === void 0 ? void 0 : (_mediaSession$customD2 = _mediaSession$customD.options) === null || _mediaSession$customD2 === void 0 ? void 0 : _mediaSession$customD2.id;

var isSameVideoId = videoId && videoId === _this2.options.get('id');

var isSessionResumed = _this2.castService.getSessionState() === cast.framework.SessionState.SESSION_RESUMED;

if (isSessionResumed && (!isSameVideoId || initCastState === cast.framework.CastState.CONNECTED)) {
_this2.load();
}

if (_this2.initAutoplay && !isSessionResumed) {
_this2.player.play();
}
}, cast_sender_WAIT_FOR_RESUME_TIMEOUT);
}

_this2.registerCastEvents();

_this2.registerRemotePlayerEvents();

_this2.registerPlayerEvents();
})["catch"](function () {
if (_this2.initAutoplay) {
_this2.player.play();
}
});
}
}, {
key: "registerPlayerEvents",
value: function registerPlayerEvents() {
var _this3 = this;

this.player.on(player_event["H" /* PAUSE_REQUEST */], function () {
return _this3.pause();
});
this.player.on(player_event["S" /* PLAY_REQUEST */], function () {
return _this3.play();
});
this.player.on(player_event["fb" /* SEEK_TO_REQUEST */], function (position) {
return _this3.remotePlayerService.seekTo(position);
});
this.player.on(player_event["db" /* SEEK_REQUEST */], function (position) {
return _this3.remotePlayerService.seek(position);
});
this.player.on(player_event["jb" /* STOP_REQUEST */], function () {
return _this3.stop();
});
this.player.on(player_event["bb" /* RESTART_REQUEST */], function () {
return _this3.load();
});
this.player.on(player_event["xb" /* VOLUME_CHANGE_REQUEST */], function (volume) {
return _this3.remotePlayerService.setVolume(volume);
});
}
}, {
key: "registerRemotePlayerEvents",
value: function registerRemotePlayerEvents() {
var _this4 = this;

this.remotePlayerService.off();
var _cast$framework$Remot = cast.framework.RemotePlayerEventType,
CURRENT_TIME_CHANGED = _cast$framework$Remot.CURRENT_TIME_CHANGED,
PLAYER_STATE_CHANGED = _cast$framework$Remot.PLAYER_STATE_CHANGED;
this.remotePlayerService.on(CURRENT_TIME_CHANGED, function (position, duration) {
_this4.currentTime = position;

_this4.player.trigger(CURRENT_TIME_CHANGED, position, duration);
});
this.remotePlayerService.on(PLAYER_STATE_CHANGED, function (event) {
return _this4.player.trigger(PLAYER_STATE_CHANGED, event);
});
}
}, {
key: "registerCastEvents",
value: function registerCastEvents() {
var _this5 = this;

this.castService.off();
var _cast$framework$CastC = cast.framework.CastContextEventType,
CAST_STATE_CHANGED = _cast$framework$CastC.CAST_STATE_CHANGED,
SESSION_STATE_CHANGED = _cast$framework$CastC.SESSION_STATE_CHANGED;
this.castService.on(SESSION_STATE_CHANGED, function (sessionState) {
return _this5.onSessionStateChanged(sessionState);
});
this.castService.on(CAST_STATE_CHANGED, function (castState) {
return _this5.onCastStateChanged(castState);
});
}
}, {
key: "onCastStateChanged",
value: function onCastStateChanged(castState) {
this.player.trigger(cast.framework.CastContextEventType.CAST_STATE_CHANGED, castState);

switch (castState) {
case cast.framework.CastState.CONNECTED:
this.onConnected();
break;

case cast.framework.CastState.NOT_CONNECTED:
this.onDisconnected();
break;
}
}
}, {
key: "onSessionStateChanged",
value: function onSessionStateChanged(sessionState) {
this.player.trigger(cast.framework.CastContextEventType.SESSION_STATE_CHANGED, sessionState);

switch (sessionState) {
case cast.framework.SessionState.SESSION_STARTED:
this.onSessionStarted();
break;

case cast.framework.SessionState.SESSION_ENDED:
this.onSessionEnded();
break;

case cast.framework.SessionState.SESSION_RESUMED:
this.freezePlayer();
break;
}
}
}, {
key: "connect",
value: function connect() {
var _this$player$timeShif,
_this6 = this;

var timeShiftMode = (_this$player$timeShif = this.player.timeShift) === null || _this$player$timeShif === void 0 ? void 0 : _this$player$timeShif.getMode();
return this.castService.connect().then(function () {
var mediaSession = _this6.castService.getMediaSession();

if (!mediaSession) {
_this6.load(_this6.player.getCurrentTime(), timeShiftMode);

_this6.player.stop(true);
}
});
}
}, {
key: "onConnected",
value: function onConnected() {
this.player.trigger(player_event["i" /* CHROMECAST_CONNECTED */], this.castService.getCastDevice());
}
}, {
key: "onDisconnected",
value: function onDisconnected() {
this.player.trigger(player_event["j" /* CHROMECAST_DISCONNECTED */]);
}
}, {
key: "onSessionStarted",
value: function onSessionStarted() {
this.freezePlayer();
}
}, {
key: "onSessionEnded",
value: function onSessionEnded() {
this.player.unFreeze();

if (!this.stopped) {
if (!this.player.isLive()) {
this.options.set(option_name["Ab" /* START_TIME */], this.currentTime || 0);
}

if (this.player.timeShift.isEnabled()) {
this.player.timeShift.setPlay(this.player.getLiveStartUTC() + this.currentTime);
}

this.player.play();
}
}
}, {
key: "freezePlayer",
value: function freezePlayer() {
this.player.freeze();
}
}, {
key: "unFreezePlayer",
value: function unFreezePlayer() {
this.player.unFreeze();
}
}, {
key: "load",
value: function load(currentTime, timeShiftMode) {
var mediaItem = this.player.mediaItem;
var dash = mediaItem.getSource().dash || mediaItem.getSource().DASH || [{}];

var _dash = slicedToArray_default()(dash, 1),
item = _dash[0];

var drm = mediaItem.getDrm();
var timeShiftOpts = this.options.get(option_name["Eb" /* TIMESHIFT */]);
var timeShift = timeShiftOpts ? cast_sender_objectSpread({}, timeShiftOpts) : undefined;
var url = item.src;

if (!url) {
return;
}

if (this.player.timeShift && this.player.timeShift.isEnabled()) {
var tsMode = timeShiftMode || this.player.timeShift.getMode();
url = this.player.timeShift.generateUrl(url);

if (currentTime > 0 && tsMode !== timeshift["a" /* TimeShiftMode */].LIVE) {
timeShift.play = date["a" /* default */].format((this.player.getLiveStartUTC() + currentTime) * 1000);
}
}

var mediaInfo = new window.chrome.cast.media.MediaInfo(url, 'application/dash+xml');
mediaInfo.metadata = new chrome.cast.media.GenericMediaMetadata();
mediaInfo.metadata.title = this.chromecastOpts.title || '';
mediaInfo.metadata.subtitle = this.chromecastOpts.subtitle || '';
mediaInfo.customData = cast_sender_objectSpread({
debug: this.chromecastOpts.debug,
session: this.chromecastOpts.session,
options: this.player.getOptions()
}, timeShift && {
timeShift: timeShift
});

if (this.options.get(option_name["U" /* LIVE */])) {
mediaInfo.customData.live = true;
mediaInfo.streamType = chrome.cast.media.StreamType.LIVE;
}

if (this.chromecastOpts.image) {
mediaInfo.metadata.images = [{
url: this.chromecastOpts.image
}];
}

if (drm && drm.widevine) {
var licenseUrl = drm.widevine;

if (this.chromecastOpts.config && this.chromecastOpts.config.videoSessionId) {
licenseUrl += "&videoSessionId=".concat(this.chromecastOpts.config.videoSessionId);
mediaInfo.customData.videoSessionId = this.chromecastOpts.config.videoSessionId;
}

if (this.chromecastOpts.config && this.chromecastOpts.config.videoSession) {
mediaInfo.customData.videoSession = this.chromecastOpts.config.videoSession;
}

mediaInfo.customData.licenseUrl = licenseUrl;
}

var request = new window.chrome.cast.media.LoadRequest(mediaInfo);

if (currentTime) {
request.currentTime = currentTime;
}

this.castService.loadMedia(request);
}
}, {
key: "play",
value: function play() {
if (this.remotePlayerService.getPlayerState() !== PLAYING) {
this.playOrPause();
}
}
}, {
key: "pause",
value: function pause() {
if (this.remotePlayerService.getPlayerState() !== PAUSED) {
this.playOrPause();
}
}
}, {
key: "playOrPause",
value: function playOrPause() {
if (!this.player.frozen && !this.castService.getCastSession()) {
return;
}

if (this.remotePlayerService.getPlayerState() === IDLE) {
this.load();
} else {
this.remotePlayerService.playOrPause();
}
}
}, {
key: "stop",
value: function stop() {
if (!this.player.frozen && !this.castService.getCastSession()) {
return;
}

this.stopped = true;
this.player.stop(true);
this.remotePlayerService.stop();
this.castService.endSession();
}
}]);

return CastSenderModule;
}();

cast_sender_CastSenderModule.enabled = true;
cast_sender_CastSenderModule.moduleId = 'cast-sender';
/* harmony default export */ var cast_sender = (cast_sender_CastSenderModule);
// EXTERNAL MODULE: ./src/module/report/index.js + 5 modules
var report = __webpack_require__(61);

// CONCATENATED MODULE: ./src/module/splashscreen/index.js



function SplashscreenModule(player) {
var options = player.options;
var prefix = options.get(option_name["s" /* CSS_PREFIX */]);
var url = options.get(option_name["yb" /* SPLASHSCREEN */]);
var container;
var hideTimeoutId;

if (!url) {
return;
}

var splashscreenContainer = document.createElement('div');
splashscreenContainer.classList.add(prefix + '-splashscreen');
player.on(player_event["r" /* GUI_READY */], onGuiReady);
player.on(player_event["O" /* PLAYING */], onPlaying);
player.on(player_event["zb" /* WAITING */], onPlaying);
player.on(player_event["d" /* AD_START */], hide);
player.on(player_event["ib" /* STOPPED */], onStopped);
player.on(player_event["E" /* ON_SOURCE */], show);
player.on(player_event["l" /* DESTROY */], onDestroy);

function onGuiReady(gui) {
container = gui.getContainer();
container.appendChild(splashscreenContainer);
splashscreenContainer.style.backgroundImage = 'url(' + url + ')';
}

function show() {
splashscreenContainer.style.display = 'block';
}

function hide() {
splashscreenContainer.style.display = 'none';
}

function onPlaying() {
hide();
}

function onStopped() {
show();
}

function onDestroy() {}
}

SplashscreenModule.enabled = true;
SplashscreenModule.moduleId = 'splashscreen';
/* harmony default export */ var splashscreen = (SplashscreenModule);
// CONCATENATED MODULE: ./src/module/stripe/index.js




var DEFAULT_INTERVAL = 2;
var DEFAULT_COUNT = 16;
var DEFAULT_HEIGHT = 90;

function StripeModule(player) {
var options = player.options;
var prefix = options.get(option_name["s" /* CSS_PREFIX */]);
player.on(player_event["P" /* PLAYLIST */], init);
var sprites = {};
var url;
var active = false;
var interval;
var playing = false;
var count;
var frameHeight;
var spriteElm;

function init() {
var stripeOpts = player.getMediaItem().getStripe() || options.get('stripe');

if (stripeOpts === null) {
return;
}

url = typeof stripeOpts !== 'string' ? stripeOpts.url : stripeOpts;

if (!url) {
return;
}

interval = typeof stripeOpts !== 'string' ? stripeOpts.interval || DEFAULT_INTERVAL : DEFAULT_INTERVAL;
count = typeof stripeOpts !== 'string' ? stripeOpts.count || DEFAULT_COUNT : DEFAULT_COUNT;
frameHeight = typeof stripeOpts !== 'string' ? stripeOpts.height || DEFAULT_HEIGHT : DEFAULT_HEIGHT;
spriteElm = document.createElement('div');
spriteElm.classList.add(prefix + '-sprite');
registerEvents();
}

function registerEvents() {
player.on(player_event["r" /* GUI_READY */], onGuiReady);
player.on(player_event["ib" /* STOPPED */], onStopped);
player.on(player_event["n" /* ENDED */], onEnded);
player.on(player_event["C" /* NEW_MEDIA */], onNewMedia);
player.on(player_event["y" /* METADATA */], onMetaData);
}

function onGuiReady(gui) {
var videoPosition;
var controls = gui.getGuiComponent(player_component["a" /* CONTROLS */]);
var progressControl = controls.progressControl;
var controlsBar = controls.getElm();
progressControl.getElm().appendChild(spriteElm);
spriteElm.addEventListener(dom_event["f" /* MOUSE_DOWN */], function () {
return player.seekTo(videoPosition);
});
controls.on(controls.ControlEvent.PROGRESS_MOVE, function (percentPosition, tooltipPosition, cursorPosition) {
var spritePosition = Math.max(cursorPosition - spriteElm.offsetWidth / 2, 0);

if (active && playing) {
spriteElm.style.left = Math.min(spritePosition, controlsBar.offsetWidth - spriteElm.offsetWidth) + 'px';
videoPosition = percentPosition * player.getDuration() / 100;
showImage(videoPosition);
}
});
progressControl.getElm().addEventListener(dom_event["g" /* MOUSE_ENTER */], onProgressMouseEnter);
progressControl.getElm().addEventListener(dom_event["h" /* MOUSE_LEAVE */], onProgressMouseLeave);
}

function onNewMedia() {
playing = true;
}

function onMetaData() {
playing = true;
}

function onEnded() {
playing = false;
hide();
}

function onStopped() {
playing = false;
hide();
}

function onProgressMouseEnter() {
if (playing) {
show();
}
}

function onProgressMouseLeave() {
hide();
}

function show() {
active = true;
spriteElm.style.display = 'block';
}

function hide() {
active = false;
spriteElm.style.display = 'none';
}

function showImage(videoPosition) {
var index = parseInt(parseInt(videoPosition) / interval / count);
var framePosition = parseInt(parseInt(parseInt(videoPosition) / interval) % count * frameHeight);
var sprite = sprites[index];
var spriteUrl = url.replace('{index}', index);

var loadImage = function loadImage(spriteUrl) {
sprite.load(spriteUrl).then(function (_index) {
if (_index !== index) {
showFrame(spriteUrl, framePosition);
}
});
};

if (sprite) {
loadImage(spriteUrl);
return;
}

sprite = new Sprite(url, index);
sprites[index] = sprite;
loadImage(spriteUrl);
}

function showFrame(spriteUrl, framePosition) {
spriteElm.style.backgroundImage = "url(".concat(spriteUrl, ")");
spriteElm.style.backgroundPosition = "0 -".concat(framePosition, "px");
}
}

function Sprite(index) {
var image = new Image();
var ready = false;
var promise = undefined;

function load(spriteUrl) {
if (promise) {
return promise;
}

promise = new Promise(function (resolve, reject) {
image.src = spriteUrl;

image.onload = function () {
ready = true;
resolve(index);
};
});
return promise;
}

return {
load: load
};
}

StripeModule.enabled = true;
StripeModule.moduleId = 'sprite';
/* harmony default export */ var stripe = (StripeModule);
// CONCATENATED MODULE: ./src/module/subtitle/external/index.js




var TEXT_TRACKS_CHANGE_EVENT = 'change';

function SubtitleExternalModule(player) {
var _renderer$textTracks;

var renderer = player.getRendererElm();
var Cue = window.VTTCue || window.TextTrackCue;
var loaded = {};
player.on(player_event["mb" /* SUBTITLE */], onSubtitle);
(_renderer$textTracks = renderer.textTracks) === null || _renderer$textTracks === void 0 ? void 0 : _renderer$textTracks.addEventListener(TEXT_TRACKS_CHANGE_EVENT, fixTextTrackMode);

function onSubtitle(subtitle) {
load(subtitle.url).then(function (data) {
var track = findTextTrackByLanguage(subtitle.language);

if (track) {
track.cues && toConsumableArray_default()(track.cues).forEach(function (cue) {
return track.removeCue(cue);
});
data.forEach(function (item) {
track.addCue(new Cue(item.start, item.stop, item.lines.join('\n')));
});
}
})["catch"](function () {});
}

function fixTextTrackMode() {
var _player$getActiveSubt;

var activeLanguage = (_player$getActiveSubt = player.getActiveSubtitle()) === null || _player$getActiveSubt === void 0 ? void 0 : _player$getActiveSubt.language;

if (activeLanguage) {
findTextTrackByLanguage(activeLanguage).mode = 'hidden';
}
}

function findTextTrackByLanguage(lang) {
return toConsumableArray_default()(renderer.textTracks).find(function (_ref) {
var language = _ref.language;
return language === lang;
});
}

function load(url) {
if (loaded[url]) {
return Promise.resolve(loaded[url]);
}

return new Promise(function (resolve, reject) {
http["a" /* default */].get(url).then(function (resp) {
var data = parse(resp.data);

if (data) {
loaded[url] = data;
resolve(data);
} else {
reject();
}
});
});
}

function parse(data) {
var timePattern = /\s*(\d*:?[0-5]\d:[0-5]\d\.\d\d\d)\s*-->\s*(\d*:?[0-5]\d:[0-5]\d\.\d\d\d)\s*(.*)/;
var subtitles = [];
var lines,
line,
timestamp,
subtitle = null;

if (data[0] === "\uFEFF") {
data = data.slice(1, data.length - 1);
}

lines = data.split(/\r\n|\r|\n/);

for (var i = 0; i < lines.length; i++) {
line = lines[i];
timestamp = timePattern.exec(line);

if (timestamp) {
subtitle = {
start: parseFloat(parseTimestamp(timestamp[1])),
stop: parseFloat(parseTimestamp(timestamp[2])),
lines: []
};
subtitles.push(subtitle);
} else if (line.trim() === '') {
subtitle = null;
} else {
if (subtitle) {
subtitle.lines.push(line);
}
}
}

return subtitles;
}

function parseTimestamp(timestamp) {
var _timestamp$split$reve = timestamp.split(/[:.]/).reverse(),
_timestamp$split$reve2 = slicedToArray_default()(_timestamp$split$reve, 4),
fraction = _timestamp$split$reve2[0],
seconds = _timestamp$split$reve2[1],
minutes = _timestamp$split$reve2[2],
_timestamp$split$reve3 = _timestamp$split$reve2[3],
hours = _timestamp$split$reve3 === void 0 ? 0 : _timestamp$split$reve3;

return parseInt(hours) * 3600 + parseInt(minutes) * 60 + parseInt(seconds) + parseInt(fraction) / 1000;
}

function destroy() {
var _renderer$textTracks2;

(_renderer$textTracks2 = renderer.textTracks) === null || _renderer$textTracks2 === void 0 ? void 0 : _renderer$textTracks2.removeEventListener(TEXT_TRACKS_CHANGE_EVENT, fixTextTrackMode);
}

return {
destroy: destroy
};
}

/* harmony default export */ var external = (SubtitleExternalModule);
// EXTERNAL MODULE: ./src/core/util/timer.js
var util_timer = __webpack_require__(25);

// EXTERNAL MODULE: ./src/renderer/dash/segment.js
var dash_segment = __webpack_require__(44);

// EXTERNAL MODULE: ./src/renderer/dash/enum/media-type.js
var media_type = __webpack_require__(9);

// EXTERNAL MODULE: ./node_modules/codem-isoboxer/dist/iso_boxer.js
var iso_boxer = __webpack_require__(50);
var iso_boxer_default = /*#__PURE__*/__webpack_require__.n(iso_boxer);

// CONCATENATED MODULE: ./src/module/subtitle/fragmented/box-parser/iso-box.js



var iso_box_IsoBox = /*#__PURE__*/function () {
function IsoBox(data) {
classCallCheck_default()(this, IsoBox);

this.data = data;
this.type = this.data.type;
this.offset = this.data._offset;
}

createClass_default()(IsoBox, [{
key: "getChildBox",
value: function getChildBox(type) {
return this.boxes.find(function (box) {
return box.type === type;
});
}
}, {
key: "getChildBoxes",
value: function getChildBoxes(type) {
return this.boxes.reduce(function (acc, box) {
if (box.type === type) {
acc.push(box);
}

return acc;
}, []);
}
}, {
key: "boxes",
get: function get() {
return this.data.boxes && this.data.boxes.map(function (box) {
return new IsoBox(box);
}) || [];
}
}]);

return IsoBox;
}();


// CONCATENATED MODULE: ./src/module/subtitle/fragmented/box-parser/box-type.js
var MDHD = 'mdhd';
var MFHD = 'mfhd';
var MOOF = 'moof';
var TFDT = 'tfdt';
var TFHD = 'tfhd';
var TRAF = 'traf';
var TRUN = 'trun';
// CONCATENATED MODULE: ./src/module/subtitle/fragmented/box-parser/parser.js



var parser_getSamplesInfo = function getSamplesInfo(buffer) {
if (!buffer || buffer.byteLength === 0) {
return {
sampleList: [],
lastSequenceNumber: NaN,
totalDuration: NaN,
numSequences: NaN
};
}

var parsedFile = iso_boxer_default.a.parseBuffer(buffer);
var sampleList = [];
var moofBoxes = parsedFile.fetchAll(MOOF).map(function (box) {
return new iso_box_IsoBox(box);
});
var mfhdBoxes = parsedFile.fetchAll(MFHD).map(function (box) {
return new iso_box_IsoBox(box);
});
var mfhdBox = mfhdBoxes[mfhdBoxes.length - 1];
var lastSequenceNumber = mfhdBox && mfhdBox.data.sequence_number;
var numSequences = moofBoxes.length;
var totalDuration;
moofBoxes.forEach(function (moofBox) {
var trafBoxes = moofBox.getChildBoxes(TRAF);
trafBoxes.forEach(function (box) {
var trunBoxes = box.getChildBoxes(TRUN);
var tfhdBox = box.getChildBox(TFHD);
var tfdtBox = box.getChildBox(TFDT);
var sampleDts = tfdtBox.data.baseMediaDecodeTime;
trunBoxes.forEach(function (box) {
trunBoxes.forEach(function (box) {
var sampleCount = box.data.sample_count;
var dataOffset = (tfhdBox.data.base_data_offset || 0) + (box.data.data_offset || 0);

for (var i = 0; i < sampleCount; i++) {
var sample = box.data.samples[i];
var sampleCompositionTimeOffset = sample.sample_composition_time_offset !== undefined ? sample.sample_composition_time_offset : 0;
var sampleDuration = sample.sample_duration !== undefined ? sample.sample_duration : tfhdBox.data.default_sample_duration;
var sampleSize = sample.sample_size !== undefined ? sample.sample_size : tfhdBox.data.default_sample_size;
var sampleData = {
dts: sampleDts,
cts: sampleDts + sampleCompositionTimeOffset,
duration: sampleDuration,
offset: moofBox.offset + dataOffset,
size: sampleSize,
subSizes: [sampleSize]
};
sampleList.push(sampleData);
sampleDts += sampleDuration;
}
});
totalDuration = sampleDts - tfdtBox.data.baseMediaDecodeTime;
});
});
});
return {
numSequences: numSequences,
lastSequenceNumber: lastSequenceNumber,
sampleList: sampleList,
totalDuration: totalDuration
};
};
var parser_getMediaTimescale = function getMediaTimescale(buffer) {
var parsedFile = iso_boxer_default.a.parseBuffer(buffer);
var mdhdBox = parsedFile.fetch(MDHD);
return mdhdBox && mdhdBox.timescale || NaN;
};
var parser_dataViewToString = function dataViewToString(data) {
return iso_boxer_default.a.Utils.dataViewToString(data, 'utf-8');
};
// EXTERNAL MODULE: ./src/renderer/dash/manifest/helper.js
var helper = __webpack_require__(11);

// CONCATENATED MODULE: ./src/module/subtitle/fragmented/ttml-parser.js


var nsURI = 'http://www.w3.org/ns/ttml';
var prefixName = 'xmlns';
var serializer = new XMLSerializer();

var addNs = function addNs(value, ns) {
return ns ? "".concat(ns, ":").concat(value) : value;
};

/* harmony default export */ var ttml_parser = (function (ttml) {
var parser = new DOMParser();
var xmlData = parser.parseFromString(ttml, 'text/xml');

var ns = toConsumableArray_default()(xmlData.documentElement.attributes).reduce(function (acc, attr) {
return attr.value === nsURI && attr.prefix === prefixName && attr.localName ? attr.localName : acc;
}, '');

var tt = Object(helper["e" /* getFirstChild */])(xmlData, addNs('tt', ns));
var head = Object(helper["e" /* getFirstChild */])(tt, addNs('head', ns));
var body = Object(helper["e" /* getFirstChild */])(tt, addNs('body', ns));
var div = Object(helper["e" /* getFirstChild */])(body, addNs('div', ns));
var pList = Object(helper["d" /* getChildren */])(div, addNs('p', ns));
var list = [];

for (var i = 0; i < pList.length; i++) {
var p = pList[i];
var begin = Object(helper["i" /* parseTime */])(p.getAttribute(addNs('begin', ns)));
var end = Object(helper["i" /* parseTime */])(p.getAttribute(addNs('end', ns)));
var lines = [];
var clone = p.cloneNode(true);
clone.removeAttribute('xml:id');
clone.removeAttribute(addNs('begin', ns));
clone.removeAttribute(addNs('end', ns));

for (var _i = 0; _i < p.childNodes.length; _i++) {
var content = p.childNodes[_i].textContent;

if (content) {
lines.push(content.trim());
}
}

list.push({
line: lines.join('\n'),
data: serializer.serializeToString(clone),
lines: lines,
begin: begin,
end: end
});
}

return list;
});
// CONCATENATED MODULE: ./src/module/subtitle/fragmented/text-stream.js









var UPDATE_INTERVAL = 300;
function TextStream(player) {
var mediaElement = player.getComponent(player_component["d" /* MEDIA_ELEMENT */]);
var renderer = player.getRendererElm();
var timer = new util_timer["a" /* default */](UPDATE_INTERVAL, update);
var Cue = window.VTTCue || window.TextTrackCue;
var segmentManager = new dash_segment["a" /* default */](player, media_type["a" /* default */].TEXT, getCurrentTimeAndBufferLength);

var _renderer$textTracks = slicedToArray_default()(renderer.textTracks, 1),
track = _renderer$textTracks[0];

var offset = 0;
player.on(player_event["eb" /* SEEK_START */], onSeekStart);
player.on(player_event["cb" /* SEEK_END */], onSeekEnd);

function init() {
timer.start();
segmentManager.start();
}

function setAdaptationSet(adaptation) {
var representation = adaptation.getRepresentation();
var segmentTemplate = representation.segmentTemplate;
var presentationTimeOffset = segmentTemplate.presentationTimeOffset,
timescale = segmentTemplate.timescale;
segmentManager.setAdaptation(adaptation);

if (presentationTimeOffset) {
offset = presentationTimeOffset / timescale;
}

track = toConsumableArray_default()(renderer.textTracks).find(function (_ref) {
var language = _ref.language;
return language === adaptation.lang;
});

if (track) {
toConsumableArray_default()(track.cues).forEach(function (cue) {
return track.removeCue(cue);
});

removeActiveCues();
track.mode = 'hidden';
init();
}
}

function getCurrentTimeAndBufferLength() {
return {
time: mediaElement.getCurrentTime(),
bufferLength: 0
};
}

function update() {
segmentManager.resume();
segmentManager.next();
var queueLength = segmentManager.getQueue().length;

if (queueLength > 5) {
segmentManager.pause();
}

var _segmentManager$getQu = segmentManager.getQueue(),
_segmentManager$getQu2 = slicedToArray_default()(_segmentManager$getQu, 1),
segment = _segmentManager$getQu2[0];

if (segment) {
segmentManager.getQueue().shift();
var buffer = segment.data.buffer;

if (segment.index >= 0) {
var samplesInfo = parser_getSamplesInfo(buffer);
var sampleList = samplesInfo.sampleList;
sampleList.forEach(function (sample) {
var dataView = new DataView(buffer, sample.offset, sample.subSizes[0]);
var result = parser_dataViewToString(dataView);
var items = ttml_parser(result);
items.forEach(function (item) {
if (track) {
var cue = new Cue(item.begin - offset, item.end - offset, item.line);
cue.data = item.data;
track.addCue(cue);
}
});
});
}
}
}

function onSeekStart() {
segmentManager.pause();
}

function onSeekEnd() {
segmentManager.update();
removeActiveCues();
segmentManager.resume();
}

function destroy() {
timer.stop();
segmentManager.stop();
}

function removeActiveCues() {
if (track) {
track.cues && toConsumableArray_default()(track.cues).forEach(function (cue) {
return track.removeCue(cue);
});
}
}

return {
init: init,
destroy: destroy,
setAdaptationSet: setAdaptationSet
};
}
// CONCATENATED MODULE: ./src/module/subtitle/fragmented/index.js




function SubtitleFragmentedModule(player, subtitle) {
var manifestManager = player.getComponent(player_component["c" /* MANIFEST_MANAGER */]);
var currentAdaptation;
player.on(player_event["mb" /* SUBTITLE */], onSubtitle);
player.on(player_event["pb" /* SUBTITLE_DISABLED */], onDisableSubtitle);
player.on(player_event["v" /* MANIFEST_LOADED */], onManifest);
var textStream = new TextStream(player);

if (subtitle) {
onSubtitle(subtitle);
}

function onSubtitle(subtitle) {
var textAdaptations = manifestManager.getTextAdaptations();
currentAdaptation = textAdaptations.find(function (adaptation) {
return adaptation.lang === subtitle.language || adaptation.id === subtitle.trackId;
});

if (currentAdaptation) {
textStream.destroy();
textStream.setAdaptationSet(currentAdaptation);
textStream.init();
}
}

function onManifest() {
var subtitle = player.getActiveSubtitle();

if (subtitle) {
onSubtitle(subtitle);
}
}

function onDisableSubtitle() {
textStream.destroy();
}

function destroy() {
player.off(player_event["mb" /* SUBTITLE */], onSubtitle);
player.off(player_event["pb" /* SUBTITLE_DISABLED */], onDisableSubtitle);
textStream.destroy();
}

return {
destroy: destroy
};
}

/* harmony default export */ var fragmented = (SubtitleFragmentedModule);
// CONCATENATED MODULE: ./src/module/subtitle/index.js









var subtitle_Cue = window.VTTCue || window.TextTrackCue;
var SubtitleSource = {
EXTERNAL: 'external',
FRAGMENTED: 'fragmented',
NATIVE: 'native'
};

var subtitle_SubtitleModule = /*#__PURE__*/function () {
function SubtitleModule(player) {
var _this = this;

classCallCheck_default()(this, SubtitleModule);

this.options = player.options;
this.player = player;
this.active = !!this.options.get(option_name["Db" /* SUBTITLE_ENABLED */]);
this.subtitle = undefined;
this.subtitles = undefined;
this.initialized = false;
this.source = undefined;
this.subtitleManager = undefined;

this.onCueChangeRef = function () {
return _this.onCueChange();
};

this.registerEvents();
this.exposeApi();
}

createClass_default()(SubtitleModule, [{
key: "getDefault",
value: function getDefault() {
var language = this.options.get(option_name["x" /* DEFAULT_SUBTITLE */]) || core["a" /* default */].getBrowserLanguage();

if (language) {
language = language.toLowerCase();
}

return this.subtitles.find(function (sub) {
return sub.language.toLowerCase() === language;
}) || this.subtitles[0];
}
}, {
key: "registerEvents",
value: function registerEvents() {
var _this2 = this;

this.player.on(player_event["Y" /* READY */], function () {
return _this2.init();
});
this.player.on(player_event["y" /* METADATA */], function () {
return _this2.init();
});
this.player.on(player_event["k" /* DATA */], function () {
return _this2.init();
});
this.player.on(player_event["pb" /* SUBTITLE_DISABLED */], function () {
return _this2.disable();
});
this.player.on(player_event["nb" /* SUBTITLES */], function (subtitles) {
return _this2.onSubtitles(subtitles);
});
this.player.on(player_event["mb" /* SUBTITLE */], function (subtitle) {
return _this2.setSubtitle(subtitle);
});
this.player.on(player_event["qb" /* SUBTITLE_ENABLE_REQUEST */], function () {
return _this2.enableSubtitle();
});
this.player.on(player_event["rb" /* SUBTITLE_TOGGLE_REQUEST */], function () {
return _this2.toggleSubtitle();
});
this.player.on(player_event["ib" /* STOPPED */], function () {
return _this2.destroy();
});
this.player.on(player_event["n" /* ENDED */], function () {
return _this2.destroy();
});
this.player.on(player_event["l" /* DESTROY */], function () {
return _this2.destroy();
});
}
}, {
key: "onSubtitles",
value: function onSubtitles(subtitles) {
var mediaElement = this.player.getComponent(player_component["d" /* MEDIA_ELEMENT */]);

var textTracks = toConsumableArray_default()(mediaElement.getNativeTextTracks());

textTracks.forEach(function (t) {
t.mode = 'disabled';
});

if (textTracks.length) {
this.initialized = true;
}

this.subtitles = subtitles;

if (this.active) {
this.subtitle = this.getDefault();
}
}
}, {
key: "enableSubtitle",
value: function enableSubtitle() {
this.active = true;

if (!this.subtitle) {
this.subtitle = this.getDefault();
}

if (this.initialized) {
this.player.trigger(player_event["mb" /* SUBTITLE */], this.subtitle);
} else {
this.init();
}
}
}, {
key: "toggleSubtitle",
value: function toggleSubtitle() {
var subtitle = this.player.getActiveSubtitle();

if (subtitle) {
this.player.disableSubtitle();
} else {
this.player.enableSubtitle();
}
}
}, {
key: "setSubtitle",
value: function setSubtitle(subtitle) {
var renderer = this.player.getRendererElm();

var textTracks = toConsumableArray_default()(renderer.textTracks);

textTracks.forEach(function (track) {
return track.mode = 'disabled';
});
var track = textTracks.find(function (track) {
return track.language === subtitle.language || track.trackId && track.trackId === subtitle.trackId;
});

if (track) {
track.mode = 'hidden';
this.setActiveTrack(track);
}

this.active = true;

if (this.subtitle === subtitle) {
return;
}

this.subtitle = subtitle;

if (!this.initialized) {
this.init();
}
}
}, {
key: "setActiveTrack",
value: function setActiveTrack(track) {
this.disableActiveTrack();
this.activeTrack = track;
this.activeTrack.addEventListener('cuechange', this.onCueChangeRef);
}
}, {
key: "disableActiveTrack",
value: function disableActiveTrack() {
if (this.activeTrack) {
this.activeTrack.removeEventListener('cuechange', this.onCueChangeRef);
}
}
}, {
key: "onCueChange",
value: function onCueChange() {
var _this3 = this;

if (this.activeTrack && this.activeTrack.activeCues.length) {
var start = -1;

toConsumableArray_default()(this.activeTrack.activeCues).forEach(function (cue) {
if (start === cue.startTime) {
return;
}

start = cue.startTime;

_this3.player.trigger(player_event["ob" /* SUBTITLE_CUE_CHANGED */], cue);
});
} else {
this.player.trigger(player_event["ob" /* SUBTITLE_CUE_CHANGED */], new subtitle_Cue(0, 0, ''));
}
}
}, {
key: "disableSubtitle",
value: function disableSubtitle() {
this.disableActiveTrack();
this.player.trigger(player_event["pb" /* SUBTITLE_DISABLED */]);
}
}, {
key: "init",
value: function init() {
var _this$player$getCompo, _this$player$getCompo2;

if (this.initialized) {
return;
}

var subtitles;
var externalSubtitles = this.player.getMediaItem().getSubtitles() || this.options.get(option_name["Cb" /* SUBTITLES */]);
var fragmentedSubtitles = (_this$player$getCompo = this.player.getComponent(player_component["c" /* MANIFEST_MANAGER */])) === null || _this$player$getCompo === void 0 ? void 0 : (_this$player$getCompo2 = _this$player$getCompo.getTextAdaptations()) === null || _this$player$getCompo2 === void 0 ? void 0 : _this$player$getCompo2.map(function (_ref) {
var accessibility = _ref.accessibility,
id = _ref.id,
lang = _ref.lang,
role = _ref.role;
return {
accessibility: accessibility,
language: lang,
trackId: id,
role: role
};
});
var supportedTextTrackKinds = ['subtitles', 'captions', undefined];
var mediaPlayer = this.player.getComponent(player_component["d" /* MEDIA_ELEMENT */]);

var nativeSubtitles = toConsumableArray_default()(mediaPlayer.getNativeTextTracks()).filter(function (_ref2) {
var customCreated = _ref2.customCreated,
kind = _ref2.kind;
return !customCreated && supportedTextTrackKinds.includes(kind);
}).filter(function (_ref3) {
var id = _ref3.id,
language = _ref3.language,
label = _ref3.label;
return id || language || label;
});

if (externalSubtitles === null || externalSubtitles === void 0 ? void 0 : externalSubtitles.length) {
subtitles = externalSubtitles;
this.source = SubtitleSource.EXTERNAL;
} else if (fragmentedSubtitles === null || fragmentedSubtitles === void 0 ? void 0 : fragmentedSubtitles.length) {
subtitles = fragmentedSubtitles;
this.source = SubtitleSource.FRAGMENTED;
} else if (nativeSubtitles === null || nativeSubtitles === void 0 ? void 0 : nativeSubtitles.length) {
subtitles = nativeSubtitles;
this.source = SubtitleSource.NATIVE;
}

if (!this.subtitles && subtitles) {
this.player.trigger(player_event["nb" /* SUBTITLES */], subtitles);
}

if (this.active && subtitles) {
switch (this.source) {
case SubtitleSource.EXTERNAL:
this.initExternal();
break;

case SubtitleSource.FRAGMENTED:
this.initFragmented();
break;
}

if (this.subtitle) {
this.player.trigger(player_event["mb" /* SUBTITLE */], this.subtitle);
}

this.initialized = true;
}
}
}, {
key: "initExternal",
value: function initExternal() {
var mediaElement = this.player.getComponent(player_component["d" /* MEDIA_ELEMENT */]);
mediaElement.addNativeTextTracks(this.subtitles, true);
this.subtitleManager = new external(this.player);
}
}, {
key: "initFragmented",
value: function initFragmented() {
var mediaElement = this.player.getComponent(player_component["d" /* MEDIA_ELEMENT */]);
mediaElement.addNativeTextTracks(this.subtitles);
this.subtitleManager = new fragmented(this.player);
}
}, {
key: "exposeApi",
value: function exposeApi() {
var _this4 = this;

this.player.setActiveSubtitle = function (subtitle) {
return _this4.player.trigger(player_event["mb" /* SUBTITLE */], subtitle);
};

this.player.getActiveSubtitle = function () {
return _this4.active && _this4.subtitle;
};

this.player.disableSubtitle = function () {
return _this4.player.trigger(player_event["pb" /* SUBTITLE_DISABLED */]);
};

this.player.enableSubtitle = function () {
return _this4.player.trigger(player_event["qb" /* SUBTITLE_ENABLE_REQUEST */]);
};

this.player.listSubtitles = function () {
return _this4.subtitles;
};
}
}, {
key: "disable",
value: function disable() {
this.active = false;
this.disableActiveTrack();
}
}, {
key: "destroy",
value: function destroy() {
this.initialized = false;
this.subtitle = undefined;

if (this.subtitleManager) {
this.subtitleManager.destroy();
}
}
}]);

return SubtitleModule;
}();

subtitle_SubtitleModule.enabled = true;
subtitle_SubtitleModule.moduleId = 'subtitle';
/* harmony default export */ var module_subtitle = (subtitle_SubtitleModule);
// CONCATENATED MODULE: ./src/module/subtitle-gui/subtitle-button.js






function subtitle_button_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (subtitle_button_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function subtitle_button_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }



var subtitle_button_SubtitleButton = /*#__PURE__*/function (_Button) {
inherits_default()(SubtitleButton, _Button);

var _super = subtitle_button_createSuper(SubtitleButton);

function SubtitleButton(id, cssPrefix) {
var _this;

classCallCheck_default()(this, SubtitleButton);

_this = _super.call(this, id, cssPrefix);
_this.subtitleOnText = undefined;
_this.subtitleOffText = undefined;
_this.btnClassActive = "".concat(cssPrefix, "-btn-").concat(_this.id, "--active");
return _this;
}

createClass_default()(SubtitleButton, [{
key: "update",
value: function update(isEnabled) {
this.tooltipText = isEnabled ? this.subtitleOffText : this.subtitleOnText;
this.tooltipElm.innerHTML = this.tooltipText;
this.updateTooltipPosition();

if (isEnabled) {
this.addClass("".concat(this.btnClassActive));
} else {
this.removeClass("".concat(this.btnClassActive));
}
}
}, {
key: "setTooltipText",
value: function setTooltipText(subtitleOnText, subtitleOffText) {
this.subtitleOnText = subtitleOnText;
this.subtitleOffText = subtitleOffText;
this.update(false);
}
}]);

return SubtitleButton;
}(button_Button);


// CONCATENATED MODULE: ./src/module/subtitle-gui/index.js













var CONTROLS_ACTIVE_CLASS = 'controls-active';
var MAX_TEXT_DURATION = 4; //[s]

var MAX_DELTA_AFTER_SEEK = 10; //[s]

var ACTIVE_CLASS = 'active';

var subtitle_gui_SubtitleGui = /*#__PURE__*/function () {
function SubtitleGui(player) {
var _this = this;

classCallCheck_default()(this, SubtitleGui);

this.player = player;
this.cssPrefix = player.options.get(option_name["s" /* CSS_PREFIX */]);
this.active = !!player.options.get(option_name["Db" /* SUBTITLE_ENABLED */]);
this.container = null;
this.controls = null;
this.activeCue = null;
this.subtitleButton = null;
this.resetTimeoutId = 0;
player.on(player_event["nb" /* SUBTITLES */], function () {
return _this.init();
});
}

createClass_default()(SubtitleGui, [{
key: "init",
value: function () {
var _init = asyncToGenerator_default()( /*#__PURE__*/regenerator_default.a.mark(function _callee() {
var _this2 = this;

var gui, subtitlePromise, guiReadyPromise;
return regenerator_default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
gui = this.player.getComponent(player_component["b" /* GUI */]);
subtitlePromise = new Promise(function (resolve) {
return _this2.player.on(player_event["mb" /* SUBTITLE */], function () {
return resolve();
});
});
guiReadyPromise = new Promise(function (resolve) {
if (gui.rendererObj) {
resolve();
}

_this2.player.on(player_event["r" /* GUI_READY */], function () {
return resolve();
});
});
_context.next = 5;
return guiReadyPromise;

case 5:
this.controls = this.player.getComponent(player_component["a" /* CONTROLS */]);
this.createSubtitleButton();
this.createContainer();

if (this.controls && this.controls.isVisible()) {
this.container.classList.add(CONTROLS_ACTIVE_CLASS);
}

_context.next = 11;
return subtitlePromise;

case 11:
this.show();
this.player.on(player_event["mb" /* SUBTITLE */], function () {
return _this2.onSubtitle();
});
this.player.on(control_event["CONTROLS_SHOW"], function () {
return _this2.onControlShow();
});
this.player.on(control_event["CONTROLS_HIDE"], function () {
return _this2.onControlHide();
});
this.player.on(player_event["cb" /* SEEK_END */], function () {
return _this2.onSeekEnd();
});
this.player.on(player_event["ob" /* SUBTITLE_CUE_CHANGED */], function (cue) {
return _this2.onCueChange(cue);
});
this.player.on(player_event["pb" /* SUBTITLE_DISABLED */], function () {
return _this2.hide();
});
this.player.on(player_event["l" /* DESTROY */], function () {
return _this2.destroy();
});
this.player.on(player_event["n" /* ENDED */], function () {
return _this2.destroy();
});
this.player.on(player_event["ib" /* STOPPED */], function () {
return _this2.destroy();
});

case 21:
case "end":
return _context.stop();
}
}
}, _callee, this);
}));

function init() {
return _init.apply(this, arguments);
}

return init;
}()
}, {
key: "onSubtitle",
value: function onSubtitle() {
this.active = true;
this.show();
}
}, {
key: "createContainer",
value: function createContainer() {
var gui = this.player.getComponent(player_component["b" /* GUI */]);
this.container = document.createElement('div');
this.container.classList.add("".concat(this.cssPrefix, "-subtitle"));
var playerContainer = gui.getContainer();
playerContainer.appendChild(this.container);
}
}, {
key: "createSubtitleButton",
value: function createSubtitleButton() {
var _this3 = this,
_this$subtitleButton;

this.subtitleButton = new subtitle_button_SubtitleButton(SUBTITLE, this.cssPrefix);
this.controls.addAccessibility(this.subtitleButton);
this.controls.addExtraControl(this.subtitleButton);
this.subtitleButton.on(dom_event["b" /* CLICK */], function () {
return _this3.onSubtitleButtonClick();
});
this.controls.rebuild();
var subtitleButtonText = [i18n_i18n.get('HELP_SUBTITLE_ON'), i18n_i18n.get('HELP_SUBTITLE_OFF')];

if (this.player.options.get(option_name["Q" /* KEYBOARD_EVENTS */])) {
subtitleButtonText = subtitleButtonText.map(function (text) {
return "".concat(text, " (s)");
});
}

(_this$subtitleButton = this.subtitleButton).setTooltipText.apply(_this$subtitleButton, toConsumableArray_default()(subtitleButtonText));
}
}, {
key: "onControlShow",
value: function onControlShow() {
this.container.classList.add(CONTROLS_ACTIVE_CLASS);
}
}, {
key: "onControlHide",
value: function onControlHide() {
this.container.classList.remove(CONTROLS_ACTIVE_CLASS);
}
}, {
key: "onSeekEnd",
value: function onSeekEnd() {
if (!this.activeCue) {
return;
}

var delta = Math.abs(this.activeCue.startTime - this.player.getCurrentTime());

if (delta > MAX_DELTA_AFTER_SEEK) {
this.reset();
}
}
}, {
key: "show",
value: function show() {
var _this$subtitleButton2;

this.container.classList.add(ACTIVE_CLASS);
(_this$subtitleButton2 = this.subtitleButton) === null || _this$subtitleButton2 === void 0 ? void 0 : _this$subtitleButton2.update(true);
}
}, {
key: "hide",
value: function hide() {
var _this$subtitleButton3;

this.active = false;

if (this.container) {
this.container.classList.remove(ACTIVE_CLASS);
this.reset();
}

(_this$subtitleButton3 = this.subtitleButton) === null || _this$subtitleButton3 === void 0 ? void 0 : _this$subtitleButton3.update(false);
}
}, {
key: "reset",
value: function reset() {
while (this.container.firstChild) {
this.container.removeChild(this.container.firstChild);
}
}
}, {
key: "destroy",
value: function destroy() {
clearTimeout(this.resetTimeoutId);
this.hide();
}
}, {
key: "onCueChange",
value: function onCueChange(cue) {
var _this4 = this;

clearTimeout(this.resetTimeoutId);
this.activeCue = cue;
this.reset();
var text = cue.text.trim();

if (text) {
var lines = text.split('\n');
lines.forEach(function (line) {
var row = document.createElement('p');
row.innerHTML = line;

_this4.container.appendChild(row);
});
var duration = (cue.endTime || cue.startTime + MAX_TEXT_DURATION) - cue.startTime;
this.resetTimeoutId = setTimeout(function () {
if (_this4.player.getCurrentTime() >= cue.startTime + duration) {
_this4.reset();
}
}, duration * 1000);
}
}
}, {
key: "onSubtitleButtonClick",
value: function onSubtitleButtonClick() {
this.player.trigger(player_event["rb" /* SUBTITLE_TOGGLE_REQUEST */]);
}
}]);

return SubtitleGui;
}();

subtitle_gui_SubtitleGui.enabled = true;
subtitle_gui_SubtitleGui.moduleId = 'subtitle-gui';
/* harmony default export */ var subtitle_gui = (subtitle_gui_SubtitleGui);
// CONCATENATED MODULE: ./src/module/title/index.js




function TitleModule(player) {
var options = player.options;
var prefix = options.get(option_name["s" /* CSS_PREFIX */]);
var title = options.get(option_name["Hb" /* TITLE */]);
var container;
var hideTimeoutId;

if (!title) {
return;
}

var titleContainer = document.createElement('div');
titleContainer.classList.add(prefix + '-title');
player.on(player_event["r" /* GUI_READY */], onGuiReady);
player.on(player_event["E" /* ON_SOURCE */], show);
player.on(player_event["l" /* DESTROY */], onDestroy);

function onGuiReady(gui) {
container = gui.getContainer();
container.addEventListener(dom_event["i" /* MOUSE_MOVE */], onMouseMove);
titleContainer.innerHTML = title;
container.appendChild(titleContainer);
}

function show() {
titleContainer.classList.add('visible');
clearTimeout(hideTimeoutId);
hideTimeoutId = setTimeout(function () {
return hide();
}, 3000);
}

function hide() {
titleContainer.classList.remove('visible');
}

function onMouseMove() {
show();
}

function onDestroy() {
if (container) {
container.removeEventListener(dom_event["i" /* MOUSE_MOVE */], onMouseMove);
}

clearTimeout(hideTimeoutId);
}
}

TitleModule.enabled = true;
TitleModule.moduleId = 'title';
/* harmony default export */ var module_title = (TitleModule);
// EXTERNAL MODULE: ./src/core/global.js
var global = __webpack_require__(35);

// EXTERNAL MODULE: ./src/core/enum/error-code.js
var error_code = __webpack_require__(27);

// EXTERNAL MODULE: ./src/core/enum/player-error.js
var player_error = __webpack_require__(10);

// CONCATENATED MODULE: ./src/module/tracking/tracking-event.js
var CLOSED = 'closed';
var SUBTITLE_TRACK_CHANGED = 'subtitleTrackChanged';
var TRACK_CHANGED = 'trackChanged';
// CONCATENATED MODULE: ./src/module/tracking/index.js










var TRACKING_COLLECTOR_SCRIPT_MIN_VERSION = '2.0.0';

var tracking_TrackingModule = /*#__PURE__*/function () {
function TrackingModule(player) {
var _this = this;

classCallCheck_default()(this, TrackingModule);

this.trackingCollector = window.AtdsTracking;

if (this.trackingCollector === undefined) {
return;
}

if (parseFloat(this.trackingCollector.VERSION) < parseFloat(TRACKING_COLLECTOR_SCRIPT_MIN_VERSION)) {
console.error("Tracking module requires collector script in version ".concat(TRACKING_COLLECTOR_SCRIPT_MIN_VERSION, " or later"));
return;
}

this.player = player;
this.options = this.player.options;
this.eventsQueue = [];
this.config = null;
this.isNewSent = false;
this.playerId = this.trackingCollector.generatePlayerId();
this.rendererType = null;
this.mimeType = null;
this.currentBitrate = 0;
this.appendBitrateToEvent = false;
setTimeout(function () {
return _this.ready();
}, 0);
}

createClass_default()(TrackingModule, [{
key: "ready",
value: function ready() {
this.config = this.options.get(option_name["Jb" /* TRACKING */]);

if (!this.config) {
return;
}

this.appendBitrateToEvent = this.config.appendBitrateToEvent;
this.registerEvents();
}
}, {
key: "registerEvents",
value: function registerEvents() {
var _this2 = this;

var eventsToListen = [player_event["e" /* AUDIO_TRACK_CHANGED */], player_event["l" /* DESTROY */], player_event["n" /* ENDED */], player_event["o" /* ERROR */], player_event["C" /* NEW_MEDIA */], player_event["G" /* PAUSED */], player_event["O" /* PLAYING */], player_event["T" /* PROFILE_CHANGED */], player_event["Y" /* READY */], player_event["eb" /* SEEK_START */], player_event["ib" /* STOPPED */], player_event["mb" /* SUBTITLE */], player_event["pb" /* SUBTITLE_DISABLED */], player_event["zb" /* WAITING */]];
eventsToListen.forEach(function (eventName) {
_this2.player.on(eventName, function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}

return _this2.event.apply(_this2, [eventName].concat(args));
});
});
}
}, {
key: "event",
value: function event(eventName) {
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}

if (eventName === player_event["Y" /* READY */]) {
var renderer = args[0];
this.isNewSent = false;
this.url = renderer.url;
this.rendererType = renderer.rendererType.toUpperCase();
this.mimeType = this.rendererType;

switch (this.rendererType) {
case 'DASH':
this.mimeType = 'DASH';
this.rendererType = 'HTML5';
break;
}
}

var currentTime = this.normalizeTime(this.player.getCurrentTime()) || 0;

if (!this.isNewSent && eventName !== player_event["C" /* NEW_MEDIA */]) {
this.eventsQueue.push([eventName, currentTime].concat(args));
return;
}

this.sendEvent.apply(this, [eventName, currentTime].concat(args));
}
}, {
key: "normalizeTime",
value: function normalizeTime() {
var time = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;

if (this.player.timeShift.isEnabled()) {
time += this.player.getLiveStartUTC();
}

return parseInt(time, 10);
}
}, {
key: "prepareEventData",
value: function prepareEventData(eventName, currentTime) {
var data = [this.playerId, eventName, currentTime];

if (this.appendBitrateToEvent) {
data.push(this.currentBitrate);
}

return data;
}
}, {
key: "sendEvent",
value: function sendEvent(eventName, currentTime) {
var _this$trackingCollect, _this$trackingCollect2, _this$trackingCollect3, _args$, _args$2, _args$3;

for (var _len3 = arguments.length, args = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
args[_key3 - 2] = arguments[_key3];
}

var duration = args[0] || 0;

switch (eventName) {
case player_event["C" /* NEW_MEDIA */]:
if (this.isNewSent) {
return;
}

this.isNewSent = true;
var _this$config = this.config,
collector = _this$config.collector,
customData = _this$config.customData,
customerId = _this$config.customerId,
productId = _this$config.productId,
productTitle = _this$config.productTitle,
productType = _this$config.productType,
sessionId = _this$config.sessionId,
subscriberId = _this$config.subscriberId,
subscriberProfileId = _this$config.subscriberProfileId;
this.trackingCollector.newSession({
playerId: this.playerId,
collector: collector,
customData: customData,
customerId: customerId,
productId: productId,
productTitle: productTitle,
productType: productType,
subscriberId: subscriberId,
subscriberProfileId: subscriberProfileId,
sessionId: sessionId,
url: this.url,
terminal: browser["a" /* default */].isMobile() ? 'PHONE' : 'PC',
duration: parseInt(duration, 10),
rendererType: this.rendererType,
mimeType: this.mimeType,
platform: 'BROWSER',
referrer: encodeURIComponent(location.href),
playerVersion: global["b" /* default */].VERSION
});

while (this.eventsQueue.length) {
this.sendEvent.apply(this, toConsumableArray_default()(this.eventsQueue.shift()));
}

break;

case player_event["G" /* PAUSED */]:
case player_event["O" /* PLAYING */]:
case player_event["eb" /* SEEK_START */]:
case player_event["zb" /* WAITING */]:
(_this$trackingCollect = this.trackingCollector).event.apply(_this$trackingCollect, toConsumableArray_default()(this.prepareEventData(eventName, currentTime)));

break;

case player_event["l" /* DESTROY */]:
(_this$trackingCollect2 = this.trackingCollector).event.apply(_this$trackingCollect2, toConsumableArray_default()(this.prepareEventData(CLOSED, currentTime)));

break;

case player_event["ib" /* STOPPED */]:
case player_event["n" /* ENDED */]:
(_this$trackingCollect3 = this.trackingCollector).event.apply(_this$trackingCollect3, toConsumableArray_default()(this.prepareEventData(eventName, currentTime)));

this.isNewSent = false;
break;

case player_event["T" /* PROFILE_CHANGED */]:
this.currentBitrate = parseInt(args[0].bandwidth / 1000) || 0;
this.trackingCollector.event(this.playerId, TRACK_CHANGED, currentTime, this.currentBitrate);
break;

case player_event["e" /* AUDIO_TRACK_CHANGED */]:
var audioTrackLanguage = ((_args$ = args[0]) === null || _args$ === void 0 ? void 0 : _args$.lang) || 0;
this.trackingCollector.event(this.playerId, player_event["e" /* AUDIO_TRACK_CHANGED */], currentTime, audioTrackLanguage);
break;

case player_event["mb" /* SUBTITLE */]:
case player_event["pb" /* SUBTITLE_DISABLED */]:
var subtitleTrackLanguage = ((_args$2 = args[0]) === null || _args$2 === void 0 ? void 0 : _args$2.language) || -1;
this.trackingCollector.event(this.playerId, SUBTITLE_TRACK_CHANGED, currentTime, subtitleTrackLanguage);
break;

case player_event["o" /* ERROR */]:
this.trackingCollector.event(this.playerId, player_event["o" /* ERROR */], currentTime, ((_args$3 = args[0]) === null || _args$3 === void 0 ? void 0 : _args$3.code) || error_code["a" /* default */][player_error["a" /* default */].GENERIC_ERROR]);
break;
}
}
}]);

return TrackingModule;
}();

tracking_TrackingModule.enabled = true;
tracking_TrackingModule.moduleId = 'tracking';
/* harmony default export */ var tracking = (tracking_TrackingModule);
// CONCATENATED MODULE: ./src/module/pip/index.js









function pip_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

function pip_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { pip_ownKeys(Object(source), true).forEach(function (key) { defineProperty_default()(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { pip_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function pip_createSuper(Derived) { return function () { var Super = getPrototypeOf_default()(Derived), result; if (pip_isNativeReflectConstruct()) { var NewTarget = getPrototypeOf_default()(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return possibleConstructorReturn_default()(this, result); }; }

function pip_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }








var Mode = {
ALL: 'all',
AUTO: 'auto',
MANUAL: 'manual'
};
var DEFAULT_OPTS = {
available: false,
mode: Mode.MANUAL,
enableIfStopped: false,
enableIfPaused: true,
pauseOnClose: false,
threshold: 0.4
};

var pip_Pip = /*#__PURE__*/function (_Component) {
inherits_default()(Pip, _Component);

var _super = pip_createSuper(Pip);

function Pip(player) {
var _this;

classCallCheck_default()(this, Pip);

_this = _super.call(this);
_this.player = player;
_this.options = _this.player.options;
_this.pipOptions = pip_objectSpread({}, DEFAULT_OPTS, {}, _this.options.get(option_name["gb" /* PIP */]));
_this.isStopped = !_this.options.get(option_name["g" /* AUTOPLAY */]);
_this.isPipEnabledManually = false;

if (!_this.pipOptions.available) {
return possibleConstructorReturn_default()(_this);
}

_this.player.addComponent(assertThisInitialized_default()(_this), player_component["f" /* PIP */]);

_this.attachEventListeners();

return _this;
}

createClass_default()(Pip, [{
key: "attachEventListeners",
value: function attachEventListeners() {
var _this2 = this;

this.player.on(player_event["Y" /* READY */], this.ready.bind(this));
this.player.on(player_event["l" /* DESTROY */], this.onDestroy.bind(this));
this.player.on(player_event["O" /* PLAYING */], function () {
_this2.isStopped = false;
});
this.player.on(player_event["ib" /* STOPPED */], function () {
_this2.isStopped = true;
});
this.player.on(player_event["n" /* ENDED */], function () {
_this2.isStopped = true;
});
}
}, {
key: "ready",
value: function ready() {
var cssPrefix = this.options.get(option_name["s" /* CSS_PREFIX */]);
var videoWrapper = this.player.getComponent(player_component["i" /* VIDEO_WRAPPER */]);
var holderEl = videoWrapper.getHolderEl();
this.createPipInfo(cssPrefix, holderEl);
this.createPipCloseButton(cssPrefix, videoWrapper);

if ([Mode.ALL, Mode.MANUAL].includes(this.pipOptions.mode)) {
this.createPipDisableButton(cssPrefix, videoWrapper);
this.createPipEnableButton();
}

if ([Mode.ALL, Mode.AUTO].includes(this.pipOptions.mode)) {
this.attachIntersectionObserver(holderEl);
}
}
}, {
key: "onDestroy",
value: function onDestroy() {
var _this$pipDisableButto, _this$pipEnableButton, _this$intersectionObs;

this.pipCloseButton.removeEventListener(dom_event["b" /* CLICK */], this.pipCloseButtonEventListener);
(_this$pipDisableButto = this.pipDisableButton) === null || _this$pipDisableButto === void 0 ? void 0 : _this$pipDisableButto.removeEventListener(dom_event["b" /* CLICK */], this.pipDisableButtonEventListener);
(_this$pipEnableButton = this.pipEnableButton) === null || _this$pipEnableButton === void 0 ? void 0 : _this$pipEnableButton.off(dom_event["b" /* CLICK */], this.pipEnableButtonEventListener);
(_this$intersectionObs = this.intersectionObserver) === null || _this$intersectionObs === void 0 ? void 0 : _this$intersectionObs.disconnect();
}
}, {
key: "createPipInfo",
value: function createPipInfo(cssPrefix, holderEl) {
var pipInfo = document.createElement('div');
pipInfo.innerHTML = i18n_i18n.get('PIP_ACTIVE_INFO', '');
holderEl.appendChild(pipInfo);
pipInfo.classList.add("".concat(cssPrefix, "-pip-info"));
}
}, {
key: "createPipCloseButton",
value: function createPipCloseButton(cssPrefix, videoWrapper) {
this.pipCloseButton = document.createElement('div');
this.pipCloseButtonEventListener = this.onPipCloseButtonClick.bind(this);
videoWrapper.getEl().appendChild(this.pipCloseButton);
this.pipCloseButton.addEventListener(dom_event["b" /* CLICK */], this.pipCloseButtonEventListener);
this.pipCloseButton.classList.add("".concat(cssPrefix, "-pip-close"));
}
}, {
key: "createPipDisableButton",
value: function createPipDisableButton(cssPrefix, videoWrapper) {
this.pipDisableButton = document.createElement('div');
this.pipDisableButtonEventListener = this.onPipDisableButtonClick.bind(this);
videoWrapper.getEl().appendChild(this.pipDisableButton);
this.pipDisableButton.addEventListener(dom_event["b" /* CLICK */], this.pipDisableButtonEventListener);
this.pipDisableButton.classList.add("".concat(cssPrefix, "-pip-disable"));
}
}, {
key: "createPipEnableButton",
value: function createPipEnableButton() {
this.controls = this.player.getComponent(player_component["a" /* CONTROLS */]);
this.pipEnableButton = this.controls.createButton(PIP);
this.pipEnableButtonEventListener = this.onPipEnableButtonClick.bind(this);
this.pipEnableButton.on(dom_event["b" /* CLICK */], this.pipEnableButtonEventListener);
this.pipEnableButton.setTooltipText(i18n_i18n.get('HELP_PIP'));
this.controls.addAccessibility(this.pipEnableButton);
this.controls.addExtraControl(this.pipEnableButton);
this.controls.rebuild();
}
}, {
key: "attachIntersectionObserver",
value: function attachIntersectionObserver(holderEl) {
var _this3 = this;

this.intersectionObserver = new IntersectionObserver(function (_ref) {
var _ref2 = slicedToArray_default()(_ref, 1),
isIntersecting = _ref2[0].isIntersecting;

if (_this3.isPipEnabledManually) {
return;
}

var enablePip = !isIntersecting;

if (enablePip && _this3.player.isPaused() && !_this3.pipOptions.enableIfPaused) {
return;
}

if (enablePip && _this3.isStopped && !_this3.pipOptions.enableIfStopped) {
return;
}

_this3.switchPip(enablePip);
}, {
threshold: this.pipOptions.threshold
});
this.intersectionObserver.observe(holderEl);
}
}, {
key: "switchPip",
value: function switchPip(enable) {
var videoWrapper = this.player.getComponent(player_component["i" /* VIDEO_WRAPPER */]);
var holderEl = videoWrapper.getHolderEl();
var container = videoWrapper.getEl();
var cssPrefix = this.options.get(option_name["s" /* CSS_PREFIX */]);
var pipActiveClass = "".concat(cssPrefix, "-pip-active");

if (enable) {
var _holderEl$getBounding = holderEl.getBoundingClientRect(),
top = _holderEl$getBounding.top,
left = _holderEl$getBounding.left;

var _window = window,
innerWidth = _window.innerWidth,
innerHeight = _window.innerHeight;
container.style.bottom = "".concat(innerHeight - top, "px");
container.style.right = "".concat(innerWidth - left, "px");
container.style.position = 'fixed';
holderEl.classList.add(pipActiveClass);
} else {
container.style.bottom = null;
container.style.right = null;
container.style.position = null;
holderEl.classList.remove(pipActiveClass);
}

this.player.trigger(player_event["L" /* PIP_SWITCHED */], enable);
}
}, {
key: "onPipCloseButtonClick",
value: function onPipCloseButtonClick() {
this.isPipEnabledManually = false;
this.switchPip(false);

if (this.pipOptions.pauseOnClose) {
this.player.pause();
}
}
}, {
key: "onPipDisableButtonClick",
value: function onPipDisableButtonClick() {
this.isPipEnabledManually = false;
this.switchPip(false);
}
}, {
key: "onPipEnableButtonClick",
value: function onPipEnableButtonClick() {
this.isPipEnabledManually = true;
this.switchPip(true);
}
}]);

return Pip;
}(core_component["a" /* default */]);

pip_Pip.enabled = true;
pip_Pip.moduleId = 'pip';
/* harmony default export */ var pip = (pip_Pip);
// CONCATENATED MODULE: ./src/core/util/polyfill/text-track.js
function iteratorFunction() {
var elements = [];
var length = this.length;
var index = 0;

for (var prop in this) {
if (this.hasOwnProperty(prop)) {
elements.push(this[prop]);
}
}

return {
next: function next() {
return index < length ? {
value: elements[index++],
done: false
} : {
done: true
};
}
};
}

/* harmony default export */ var text_track = (function () {
// NOTE: old versions MS EDGE don't implement iterators for media elements
if (typeof TextTrackList.prototype[Symbol.iterator] !== 'function') {
TextTrackList.prototype[Symbol.iterator] = iteratorFunction;
}

if (typeof TextTrackCueList.prototype[Symbol.iterator] !== 'function') {
TextTrackCueList.prototype[Symbol.iterator] = iteratorFunction;
}
});
// EXTERNAL MODULE: ./src/core/util/logger.js
var logger = __webpack_require__(33);

// CONCATENATED MODULE: ./src/app/index.js

core_player["a" /* default */].renderers = [renderer_dash["a" /* default */], html5["a" /* default */], index_async];
core_player["a" /* default */].modules = [module_advert, gstream, module_gui, cast_sender, report["a" /* default */], splashscreen, stripe, module_subtitle, subtitle_gui, module_title, tracking, pip]; //apply polyfill

text_track();
global["b" /* default */].Player = core_player["a" /* default */];
global["b" /* default */].Logger = logger["a" /* default */];
core_player["a" /* default */].Logger = logger["a" /* default */];
Object(global["a" /* addGlobal */])('redcdnplayer');
Object(global["a" /* addGlobal */])('redGalaxy');

/***/ })
/******/ ]);
//# sourceMappingURL=redgalaxy-player-2.16.2.min.js.map

Back to list