UNPKG

dm-unimmersive

Version:
939 lines (916 loc) 6.15 MB
import { jsx, Fragment, jsxs } from 'react/jsx-runtime'; import { useDispatch, useSelector, connect, Provider } from 'react-redux'; import { combineReducers, MiddlewareArray, configureStore } from '@reduxjs/toolkit'; import React$1, { useState, useRef, useEffect, Component as Component$3, PureComponent, isValidElement, Fragment as Fragment$1, memo, createContext, useCallback } from 'react'; /****************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } function __spreadArray(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); } var SEGMENT; (function (SEGMENT) { SEGMENT["SET_VOICE_RECOGNITION_ENABLED"] = "SET_VOICE_RECOGNITION_ENABLED"; SEGMENT["SET_CHOOSE_MOOD_ENABLED"] = "SET_CHOOSE_MOOD_ENABLED"; })(SEGMENT || (SEGMENT = {})); var PLAYER; (function (PLAYER) { PLAYER["SET_PAUSED"] = "SET_PAUSED"; PLAYER["SET_PROGRESS"] = "SET_PROGRESS"; PLAYER["UPDATE_PROGRESS"] = "UPDATE_PROGRESS"; PLAYER["SET_DISABLED_BUTTONS"] = "SET_DISABLED_BUTTONS"; PLAYER["SHOW_CONTROLBAR"] = "SHOW_COTNTROLBAR"; PLAYER["SET_VOLUME"] = "SET_VOLUME"; PLAYER["FULLSCREEN"] = "FULLSCREEN"; })(PLAYER || (PLAYER = {})); var GLOBAL; (function (GLOBAL) { GLOBAL["SET_SCNERATIO"] = "SET_SCENARIO"; GLOBAL["CHANGE_ACTIVE_PLAYER"] = "CHANGE_ACTIVE_PLAYER"; GLOBAL["SET_SEGMENT_FOR_ACTIVE_PLAYER"] = "SET_SEGMENT_FOR_ACTIVE_PLAYER"; GLOBAL["NEXT_SEGMENT"] = "NEXT_SEGMENT"; GLOBAL["PREV_SEGMENT"] = "PREV_SEGMENT"; GLOBAL["UPDATE_STATE"] = "UPDATE_STATE"; GLOBAL["SET_MODE"] = "SET_MODE"; GLOBAL["SET_VIEW_TYPE"] = "SET_VIEW_TYPE"; GLOBAL["REGISTER_PLAYER"] = "REGISTER_PLAYER"; GLOBAL["UNREGISTER_PLAYER"] = "UNREGISTER_PLAYER"; GLOBAL["SET_QUALITY_LEVEL"] = "SET_QUALITY_LEVEL"; GLOBAL["SET_RESERVED_PLAYER_STATE"] = "SET_RESERVED_PLAYER_STATE"; GLOBAL["SET_REWINDING"] = "SET_REWINDING"; GLOBAL["SET_FOUND_SEGMENT"] = "SET_FOUND_SEGMENT"; GLOBAL["SET_SHOW_BG"] = "SET_SHOW_BG"; GLOBAL["SHOW_POPUP"] = "SHOW_POPUP"; GLOBAL["SET_LANGUAGE"] = "SET_LANGUAGE"; GLOBAL["SHOW_SUBTITLES"] = "SHOW_SUBTITLES"; GLOBAL["SLOW_INTERNET_CONNECTION"] = "SLOW_INTERNET_CONNECTION"; GLOBAL["SET_TRANSITION_PLAYER"] = "SET_TRANSITION_PLAYER"; GLOBAL["FIRST_INTERACTION"] = "FIRST_INTERACTION"; })(GLOBAL || (GLOBAL = {})); var TIMELINE; (function (TIMELINE) { TIMELINE["SET_CURRENT_TIME"] = "SET_CURRENT_TIME"; TIMELINE["SET_TIMELINE"] = "SET_TIMELINE"; TIMELINE["SET_DURATION"] = "SET_DURATION"; TIMELINE["SET_SEKKED_TIME"] = "SET_SEEKED_TIME"; })(TIMELINE || (TIMELINE = {})); var DEVICE; (function (DEVICE) { DEVICE["SET_BROWSER"] = "SET_BROWSER"; DEVICE["SET_OS"] = "SET_OS"; DEVICE["SET_DEVICE"] = "SET_DEVICE"; DEVICE["IS_MOBILE"] = "IS_MOBILE"; })(DEVICE || (DEVICE = {})); var initial_state$2 = { watched: [], pool: [], players: [], active_player_id: '', splitting_players: [], scenario: [], mode: 'initial', view_type: 'movie', registered_players: [], quality_level: 'auto', show_bg: false, subtitles: { show: false, language: 'en' }, rewinding: { actual: false, seconds: 0 }, reserved_player: { id: '', label: '', segment: { duration: 0, id: '', linked_with: [], default: false, //@ts-ignore subtitles: { ru: '', en: '' }, src: '' } }, language: 'en' }; function RootReducer(state, action) { if (state === void 0) { state = initial_state$2; } switch (action.type) { case GLOBAL.FIRST_INTERACTION: return __assign(__assign({}, state), { first_interaction: action.payload }); case GLOBAL.SET_TRANSITION_PLAYER: return __assign(__assign({}, state), { transition_player: action.payload }); case GLOBAL.SHOW_SUBTITLES: return __assign(__assign({}, state), { subtitles: action.payload }); case GLOBAL.SET_LANGUAGE: return __assign(__assign({}, state), { language: action.payload }); case GLOBAL.SHOW_POPUP: return __assign(__assign({}, state), { popup: action.payload }); case GLOBAL.SET_SHOW_BG: return __assign(__assign({}, state), { show_bg: action.payload }); case GLOBAL.SET_FOUND_SEGMENT: return __assign(__assign({}, state), { found_segment: action.payload }); case GLOBAL.SET_REWINDING: return __assign(__assign({}, state), { rewinding: action.payload }); case GLOBAL.SET_RESERVED_PLAYER_STATE: return __assign(__assign({}, state), { reserved_player: action.payload }); case GLOBAL.SET_QUALITY_LEVEL: return __assign(__assign({}, state), { quality_level: action.payload }); case GLOBAL.UNREGISTER_PLAYER: return __assign(__assign({}, state), { registered_players: state.registered_players.filter(function (player) { return player.player_id !== action.payload; }) }); case GLOBAL.REGISTER_PLAYER: return __assign(__assign({}, state), { registered_players: Array.from(new Set(state.registered_players.concat(action.payload))) }); case GLOBAL.SET_VIEW_TYPE: return __assign(__assign({}, state), { view_type: action.payload }); case GLOBAL.SET_MODE: return __assign(__assign({}, state), { mode: action.payload }); case GLOBAL.UPDATE_STATE: return __assign(__assign({}, state), action.payload); case GLOBAL.NEXT_SEGMENT: return __assign(__assign({}, state), { //watched: state.watched.concat(state.scenario.find(scen => scen.id === state.active_player_id)), active_player_id: action.payload }); case GLOBAL.PREV_SEGMENT: return __assign(__assign({}, state), { //watched: state.watched.concat(state.scenario.find(scen => scen.id === state.active_player_id)), active_player_id: action.payload }); case GLOBAL.SET_SCNERATIO: return __assign(__assign({}, state), { scenario: action.payload }); case GLOBAL.CHANGE_ACTIVE_PLAYER: return __assign(__assign({}, state), { active_player_id: action.payload }); case GLOBAL.SET_SEGMENT_FOR_ACTIVE_PLAYER: return __assign(__assign({}, state), { active_player_id: action.payload }); default: return state; } } var init_state$1 = { duration: 0, current_time: 0, current_segment_time: 0 }; function Timeline(state, action) { if (state === void 0) { state = init_state$1; } switch (action.type) { case TIMELINE.SET_SEKKED_TIME: return __assign(__assign({}, state), { seeked_time: action.payload }); case TIMELINE.SET_DURATION: return __assign(__assign({}, state), { duration: Number(action.payload) }); case TIMELINE.SET_CURRENT_TIME: return __assign(__assign({}, state), { current_time: Number(action.payload.current_time), current_segment_time: Number(action.payload.current_segment_time) }); case TIMELINE.SET_TIMELINE: return __assign(__assign({}, state), { duration: Number(action.payload.duration), current_time: Number(action.payload.current_time), current_segment_time: Number(action.payload.current_segment_time) }); default: return state; } } var initial_state$1 = { voice_recognition_enabled: false, choose_mood_enabled: false, }; function segment(state, action) { if (state === void 0) { state = initial_state$1; } switch (action.type) { case SEGMENT.SET_CHOOSE_MOOD_ENABLED: return __assign(__assign({}, state), { choose_mood_enabled: action.payload }); case SEGMENT.SET_VOICE_RECOGNITION_ENABLED: return __assign(__assign({}, state), { voice_recognition_enabled: action.payload }); default: return state; } } var initial_state = { paused: true, loading_progress: [], volume: 0, disabled_buttons: { next_btn: true, prev_btn: true }, show_controlbar: { bottom: true, top: true }, fullscreen: false, }; function player(state, action) { if (state === void 0) { state = initial_state; } switch (action.type) { case PLAYER.FULLSCREEN: return __assign(__assign({}, state), { fullscreen: action.payload }); case PLAYER.SET_VOLUME: return __assign(__assign({}, state), { volume: action.payload }); case PLAYER.SHOW_CONTROLBAR: //@ts-ignore if (typeof action.payload === 'object' && action.payload.top === 'any') { return __assign(__assign({}, state), { show_controlbar: { bottom: !state.show_controlbar.bottom, top: !state.show_controlbar.top } }); } return __assign(__assign({}, state), { show_controlbar: __assign(__assign({}, state.show_controlbar), action.payload) }); case PLAYER.SET_DISABLED_BUTTONS: return __assign(__assign({}, state), { disabled_buttons: __assign(__assign({}, state.disabled_buttons), action.payload) }); case PLAYER.UPDATE_PROGRESS: return __assign(__assign({}, state), { loading_progress: action.payload }); case PLAYER.SET_PROGRESS: var index = state.loading_progress.findIndex(function (pr) { return pr.id === action.payload.id; }); return __assign(__assign({}, state), { loading_progress: index !== -1 ? state.loading_progress.map(function (progress) { if (progress.id === action.payload.id) { return action.payload; } return progress; }) : state.loading_progress.concat(action.payload) }); case PLAYER.SET_PAUSED: return __assign(__assign({}, state), { paused: action.payload }); default: return state; } } var init_state = { device: 'desktop', os: 'windows', browser: 'chrome' }; function device$1(state, action) { if (state === void 0) { state = init_state; } switch (action.type) { case DEVICE.IS_MOBILE: return __assign(__assign({}, state), { isMobile: action.payload }); case DEVICE.SET_OS: return __assign(__assign({}, state), { os: action.payload }); case DEVICE.SET_DEVICE: return __assign(__assign({}, state), { device: action.payload }); case DEVICE.SET_BROWSER: return __assign(__assign({}, state), { browser: action.payload }); default: return state; } } var reducer = combineReducers({ root: RootReducer, timeline: Timeline, segment: segment, player: player, device: device$1 }); var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; var reduxLogger = {exports: {}}; (function (module, exports) { !function(e,t){t(exports);}(commonjsGlobal,function(e){function t(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}});}function r(e,t){Object.defineProperty(this,"kind",{value:e,enumerable:!0}),t&&t.length&&Object.defineProperty(this,"path",{value:t,enumerable:!0});}function n(e,t,r){n.super_.call(this,"E",e),Object.defineProperty(this,"lhs",{value:t,enumerable:!0}),Object.defineProperty(this,"rhs",{value:r,enumerable:!0});}function o(e,t){o.super_.call(this,"N",e),Object.defineProperty(this,"rhs",{value:t,enumerable:!0});}function i(e,t){i.super_.call(this,"D",e),Object.defineProperty(this,"lhs",{value:t,enumerable:!0});}function a(e,t,r){a.super_.call(this,"A",e),Object.defineProperty(this,"index",{value:t,enumerable:!0}),Object.defineProperty(this,"item",{value:r,enumerable:!0});}function f(e,t,r){var n=e.slice((r||t)+1||e.length);return e.length=t<0?e.length+t:t,e.push.apply(e,n),e}function u(e){var t="undefined"==typeof e?"undefined":N(e);return "object"!==t?t:e===Math?"math":null===e?"null":Array.isArray(e)?"array":"[object Date]"===Object.prototype.toString.call(e)?"date":"function"==typeof e.toString&&/^\/.*\//.test(e.toString())?"regexp":"object"}function l(e,t,r,c,s,d,p){s=s||[],p=p||[];var g=s.slice(0);if("undefined"!=typeof d){if(c){if("function"==typeof c&&c(g,d))return;if("object"===("undefined"==typeof c?"undefined":N(c))){if(c.prefilter&&c.prefilter(g,d))return;if(c.normalize){var h=c.normalize(g,d,e,t);h&&(e=h[0],t=h[1]);}}}g.push(d);}"regexp"===u(e)&&"regexp"===u(t)&&(e=e.toString(),t=t.toString());var y="undefined"==typeof e?"undefined":N(e),v="undefined"==typeof t?"undefined":N(t),b="undefined"!==y||p&&p[p.length-1].lhs&&p[p.length-1].lhs.hasOwnProperty(d),m="undefined"!==v||p&&p[p.length-1].rhs&&p[p.length-1].rhs.hasOwnProperty(d);if(!b&&m)r(new o(g,t));else if(!m&&b)r(new i(g,e));else if(u(e)!==u(t))r(new n(g,e,t));else if("date"===u(e)&&e-t!==0)r(new n(g,e,t));else if("object"===y&&null!==e&&null!==t)if(p.filter(function(t){return t.lhs===e}).length)e!==t&&r(new n(g,e,t));else {if(p.push({lhs:e,rhs:t}),Array.isArray(e)){var w;e.length;for(w=0;w<e.length;w++)w>=t.length?r(new a(g,w,new i(void 0,e[w]))):l(e[w],t[w],r,c,g,w,p);for(;w<t.length;)r(new a(g,w,new o(void 0,t[w++])));}else {var x=Object.keys(e),S=Object.keys(t);x.forEach(function(n,o){var i=S.indexOf(n);i>=0?(l(e[n],t[n],r,c,g,n,p),S=f(S,i)):l(e[n],void 0,r,c,g,n,p);}),S.forEach(function(e){l(void 0,t[e],r,c,g,e,p);});}p.length=p.length-1;}else e!==t&&("number"===y&&isNaN(e)&&isNaN(t)||r(new n(g,e,t)));}function c(e,t,r,n){return n=n||[],l(e,t,function(e){e&&n.push(e);},r),n.length?n:void 0}function s(e,t,r){if(r.path&&r.path.length){var n,o=e[t],i=r.path.length-1;for(n=0;n<i;n++)o=o[r.path[n]];switch(r.kind){case"A":s(o[r.path[n]],r.index,r.item);break;case"D":delete o[r.path[n]];break;case"E":case"N":o[r.path[n]]=r.rhs;}}else switch(r.kind){case"A":s(e[t],r.index,r.item);break;case"D":e=f(e,t);break;case"E":case"N":e[t]=r.rhs;}return e}function d(e,t,r){if(e&&t&&r&&r.kind){for(var n=e,o=-1,i=r.path?r.path.length-1:0;++o<i;)"undefined"==typeof n[r.path[o]]&&(n[r.path[o]]="number"==typeof r.path[o]?[]:{}),n=n[r.path[o]];switch(r.kind){case"A":s(r.path?n[r.path[o]]:n,r.index,r.item);break;case"D":delete n[r.path[o]];break;case"E":case"N":n[r.path[o]]=r.rhs;}}}function p(e,t,r){if(r.path&&r.path.length){var n,o=e[t],i=r.path.length-1;for(n=0;n<i;n++)o=o[r.path[n]];switch(r.kind){case"A":p(o[r.path[n]],r.index,r.item);break;case"D":o[r.path[n]]=r.lhs;break;case"E":o[r.path[n]]=r.lhs;break;case"N":delete o[r.path[n]];}}else switch(r.kind){case"A":p(e[t],r.index,r.item);break;case"D":e[t]=r.lhs;break;case"E":e[t]=r.lhs;break;case"N":e=f(e,t);}return e}function g(e,t,r){if(e&&t&&r&&r.kind){var n,o,i=e;for(o=r.path.length-1,n=0;n<o;n++)"undefined"==typeof i[r.path[n]]&&(i[r.path[n]]={}),i=i[r.path[n]];switch(r.kind){case"A":p(i[r.path[n]],r.index,r.item);break;case"D":i[r.path[n]]=r.lhs;break;case"E":i[r.path[n]]=r.lhs;break;case"N":delete i[r.path[n]];}}}function h(e,t,r){if(e&&t){var n=function(n){r&&!r(e,t,n)||d(e,t,n);};l(e,t,n);}}function y(e){return "color: "+F[e].color+"; font-weight: bold"}function v(e){var t=e.kind,r=e.path,n=e.lhs,o=e.rhs,i=e.index,a=e.item;switch(t){case"E":return [r.join("."),n,"→",o];case"N":return [r.join("."),o];case"D":return [r.join(".")];case"A":return [r.join(".")+"["+i+"]",a];default:return []}}function b(e,t,r,n){var o=c(e,t);try{n?r.groupCollapsed("diff"):r.group("diff");}catch(e){r.log("diff");}o?o.forEach(function(e){var t=e.kind,n=v(e);r.log.apply(r,["%c "+F[t].text,y(t)].concat(P(n)));}):r.log("—— no diff ——");try{r.groupEnd();}catch(e){r.log("—— diff end —— ");}}function m(e,t,r,n){switch("undefined"==typeof e?"undefined":N(e)){case"object":return "function"==typeof e[n]?e[n].apply(e,P(r)):e[n];case"function":return e(t);default:return e}}function w(e){var t=e.timestamp,r=e.duration;return function(e,n,o){var i=["action"];return i.push("%c"+String(e.type)),t&&i.push("%c@ "+n),r&&i.push("%c(in "+o.toFixed(2)+" ms)"),i.join(" ")}}function x(e,t){var r=t.logger,n=t.actionTransformer,o=t.titleFormatter,i=void 0===o?w(t):o,a=t.collapsed,f=t.colors,u=t.level,l=t.diff,c="undefined"==typeof t.titleFormatter;e.forEach(function(o,s){var d=o.started,p=o.startedTime,g=o.action,h=o.prevState,y=o.error,v=o.took,w=o.nextState,x=e[s+1];x&&(w=x.prevState,v=x.started-d);var S=n(g),k="function"==typeof a?a(function(){return w},g,o):a,j=D(p),E=f.title?"color: "+f.title(S)+";":"",A=["color: gray; font-weight: lighter;"];A.push(E),t.timestamp&&A.push("color: gray; font-weight: lighter;"),t.duration&&A.push("color: gray; font-weight: lighter;");var O=i(S,j,v);try{k?f.title&&c?r.groupCollapsed.apply(r,["%c "+O].concat(A)):r.groupCollapsed(O):f.title&&c?r.group.apply(r,["%c "+O].concat(A)):r.group(O);}catch(e){r.log(O);}var N=m(u,S,[h],"prevState"),P=m(u,S,[S],"action"),C=m(u,S,[y,h],"error"),F=m(u,S,[w],"nextState");if(N)if(f.prevState){var L="color: "+f.prevState(h)+"; font-weight: bold";r[N]("%c prev state",L,h);}else r[N]("prev state",h);if(P)if(f.action){var T="color: "+f.action(S)+"; font-weight: bold";r[P]("%c action ",T,S);}else r[P]("action ",S);if(y&&C)if(f.error){var M="color: "+f.error(y,h)+"; font-weight: bold;";r[C]("%c error ",M,y);}else r[C]("error ",y);if(F)if(f.nextState){var _="color: "+f.nextState(w)+"; font-weight: bold";r[F]("%c next state",_,w);}else r[F]("next state",w);l&&b(h,w,r,k);try{r.groupEnd();}catch(e){r.log("—— log end ——");}});}function S(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Object.assign({},L,e),r=t.logger,n=t.stateTransformer,o=t.errorTransformer,i=t.predicate,a=t.logErrors,f=t.diffPredicate;if("undefined"==typeof r)return function(){return function(e){return function(t){return e(t)}}};if(e.getState&&e.dispatch)return console.error("[redux-logger] redux-logger not installed. Make sure to pass logger instance as middleware:\n// Logger with default options\nimport { logger } from 'redux-logger'\nconst store = createStore(\n reducer,\n applyMiddleware(logger)\n)\n// Or you can create your own logger with custom options http://bit.ly/redux-logger-options\nimport createLogger from 'redux-logger'\nconst logger = createLogger({\n // ...options\n});\nconst store = createStore(\n reducer,\n applyMiddleware(logger)\n)\n"),function(){return function(e){return function(t){return e(t)}}};var u=[];return function(e){var r=e.getState;return function(e){return function(l){if("function"==typeof i&&!i(r,l))return e(l);var c={};u.push(c),c.started=O.now(),c.startedTime=new Date,c.prevState=n(r()),c.action=l;var s=void 0;if(a)try{s=e(l);}catch(e){c.error=o(e);}else s=e(l);c.took=O.now()-c.started,c.nextState=n(r());var d=t.diff&&"function"==typeof f?f(r,l):t.diff;if(x(u,Object.assign({},t,{diff:d})),u.length=0,c.error)throw c.error;return s}}}}var k,j,E=function(e,t){return new Array(t+1).join(e)},A=function(e,t){return E("0",t-e.toString().length)+e},D=function(e){return A(e.getHours(),2)+":"+A(e.getMinutes(),2)+":"+A(e.getSeconds(),2)+"."+A(e.getMilliseconds(),3)},O="undefined"!=typeof performance&&null!==performance&&"function"==typeof performance.now?performance:Date,N="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},C=[];k="object"===("undefined"==typeof commonjsGlobal?"undefined":N(commonjsGlobal))&&commonjsGlobal?commonjsGlobal:"undefined"!=typeof window?window:{},j=k.DeepDiff,j&&C.push(function(){"undefined"!=typeof j&&k.DeepDiff===c&&(k.DeepDiff=j,j=void 0);}),t(n,r),t(o,r),t(i,r),t(a,r),Object.defineProperties(c,{diff:{value:c,enumerable:!0},observableDiff:{value:l,enumerable:!0},applyDiff:{value:h,enumerable:!0},applyChange:{value:d,enumerable:!0},revertChange:{value:g,enumerable:!0},isConflict:{value:function(){return "undefined"!=typeof j},enumerable:!0},noConflict:{value:function(){return C&&(C.forEach(function(e){e();}),C=null),c},enumerable:!0}});var F={E:{color:"#2196F3",text:"CHANGED:"},N:{color:"#4CAF50",text:"ADDED:"},D:{color:"#F44336",text:"DELETED:"},A:{color:"#2196F3",text:"ARRAY:"}},L={level:"log",logger:console,logErrors:!0,collapsed:void 0,predicate:void 0,duration:!1,timestamp:!0,stateTransformer:function(e){return e},actionTransformer:function(e){return e},errorTransformer:function(e){return e},colors:{title:function(){return "inherit"},prevState:function(){return "#9E9E9E"},action:function(){return "#03A9F4"},nextState:function(){return "#4CAF50"},error:function(){return "#F20404"}},diff:!1,diffPredicate:void 0,transformer:void 0},T=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.dispatch,r=e.getState;return "function"==typeof t||"function"==typeof r?S()({dispatch:t,getState:r}):void console.error("\n[redux-logger v3] BREAKING CHANGE\n[redux-logger v3] Since 3.0.0 redux-logger exports by default logger with default settings.\n[redux-logger v3] Change\n[redux-logger v3] import createLogger from 'redux-logger'\n[redux-logger v3] to\n[redux-logger v3] import { createLogger } from 'redux-logger'\n")};e.defaults=L,e.createLogger=S,e.logger=T,e.default=T,Object.defineProperty(e,"__esModule",{value:!0});}); } (reduxLogger, reduxLogger.exports)); var firstInteraction = function (payload) { return ({ type: GLOBAL.FIRST_INTERACTION, payload: payload }); }; var setVolume = function (payload) { return ({ type: PLAYER.SET_VOLUME, payload: payload }); }; var showSubtitles = function (payload) { return ({ type: GLOBAL.SHOW_SUBTITLES, payload: payload }); }; var setLanguage = function (payload) { return ({ type: GLOBAL.SET_LANGUAGE, payload: payload }); }; var isMobile = function (payload) { return ({ type: DEVICE.IS_MOBILE, payload: payload }); }; var showControlBar = function (payload) { return ({ type: PLAYER.SHOW_CONTROLBAR, payload: payload, }); }; var showPopup = function (payload) { return ({ type: GLOBAL.SHOW_POPUP, payload: payload }); }; var setFoundSegment = function (payload) { return ({ type: GLOBAL.SET_FOUND_SEGMENT, payload: payload }); }; var setPaused = function (payload) { return ({ type: PLAYER.SET_PAUSED, payload: payload }); }; var setSeekedTime = function (payload) { return ({ type: TIMELINE.SET_SEKKED_TIME, payload: payload, rate_limit: 100 }); }; var setRewinding = function (payload) { return ({ type: GLOBAL.SET_REWINDING, payload: payload, }); }; var setReservedPlayerState = function (payload) { return ({ type: GLOBAL.SET_RESERVED_PLAYER_STATE, payload: payload }); }; var setQualityLevel = function (payload) { return ({ type: GLOBAL.SET_QUALITY_LEVEL, payload: payload }); }; var setTimeline = function (payload) { return ({ type: TIMELINE.SET_TIMELINE, payload: payload }); }; var setCurrentTime = function (payload) { return ({ type: TIMELINE.SET_CURRENT_TIME, payload: payload, rate_limit: 300 }); }; var setActivePlayer = function (payload) { return ({ type: GLOBAL.CHANGE_ACTIVE_PLAYER, payload: payload, rate_limit: 500 }); }; var nextSegment = function (payload) { return ({ type: GLOBAL.NEXT_SEGMENT, payload: payload, rate_limit: 300 }); }; var prevSegment = function (payload) { return ({ type: GLOBAL.PREV_SEGMENT, payload: payload }); }; var updateState = function (payload) { return ({ type: GLOBAL.UPDATE_STATE, payload: payload }); }; var setMode = function (payload) { return ({ type: GLOBAL.SET_MODE, payload: payload }); }; var setViewType = function (payload) { return ({ type: GLOBAL.SET_VIEW_TYPE, payload: payload }); }; var splitting_files = { INTRO_SF_IMM1: { id: 'INTRO_SF_IMM1', duration: 5, subtitles: '', linked_with: [], default: false, src: 'https://d2ez8akk35wez5.cloudfront.net/videos_reborn/splitting_files/INTRO_SF_IMM1_1080.m3u8' }, INTRO_SF_IMM2: { id: 'INTRO_SF_IMM2', duration: 7, subtitles: '', linked_with: [], default: false, src: 'https://d2ez8akk35wez5.cloudfront.net/videos_reborn/splitting_files/INTRO_SF_IMM2_1080.m3u8' }, INTRO_SF_NORM1: { id: 'INTRO_SF_NORM1', duration: 9, subtitles: '', linked_with: [], default: false, src: 'https://d2ez8akk35wez5.cloudfront.net/videos_reborn/splitting_files/INTRO_SF_NORM1_1080.m3u8' }, INTRO_SF_NORM2: { id: 'INTRO_SF_NORM2', duration: 4, subtitles: '', linked_with: [], default: false, src: 'https://d2ez8akk35wez5.cloudfront.net/videos_reborn/splitting_files/INTRO_SF_NORM2_1080.m3u8' }, INTRO_SF_NORM3: { id: 'INTRO_SF_NORM3', duration: 6, subtitles: '', linked_with: [], default: false, src: 'https://d2ez8akk35wez5.cloudfront.net/videos_reborn/splitting_files/INTRO_SF_NORM3_1080.m3u8' } }; var SPLITTING_FILES = Object.keys(splitting_files).map(function (key) { return splitting_files[key].id; }); var to_immersive = [splitting_files.INTRO_SF_NORM2.id, splitting_files.INTRO_SF_NORM3.id]; var to_normal = [splitting_files.INTRO_SF_IMM1.id, splitting_files.INTRO_SF_IMM2.id]; var splitting_file_prefix = 'SPLIT_'; var name_in_local_storage = 'PLAYED_FRAGMENTS'; var SplittingFilesManager = /** @class */ (function () { function SplittingFilesManager(_a) { var played_fragments = _a.played_fragments; this.played_fragments = []; if (played_fragments) { this.played_fragments = played_fragments; } } /** * Get already watched fragments * @returns {Array.<string>} already watched fragments */ SplittingFilesManager.prototype.getAlreadyPlayedFragments = function () { return this.played_fragments.slice(); }; SplittingFilesManager.prototype.clearLocalStorage = function () { localStorage.setItem(name_in_local_storage, ''); }; SplittingFilesManager.prototype._isSplittingFIle = function (fragment_name) { return Object.keys(splitting_files).includes(fragment_name); }; /** * Add fragment_name to the localStorage * @param {string} fragment_name */ SplittingFilesManager.prototype.addPlayedFragment = function (fragment_name) { var fragment = fragment_name; var previous = this.getAlreadyPlayedFragments(); previous.push(fragment); this.played_fragments.push(fragment_name); }; /** * Choose what splitting file should user see based on * previous watched fragments * @param {string} chosen_mode that you r going to turn on * @returns {string} the name of splitting file */ SplittingFilesManager.prototype.chooseFragment = function (_a) { var chosen_mode = _a.chosen_mode, previous = _a.previous; var NI = 'NI'; var previous_keys = previous.map(function (segment) { return segment.id; }); var mode = chosen_mode === 'initial' ? 'immersive' : chosen_mode.slice(); var NI_played = previous_keys.some(function (fragment) { return typeof fragment !== 'string' ? //@ts-ignore false : fragment.includes(NI); }); if (mode === 'normal') { return this.oneOfTwoInTurn(previous_keys, to_normal); } if (mode === 'immersive') { if (NI_played) { if (previous_keys.filter(function (key) { return key === splitting_files.INTRO_SF_NORM1.id; }).length < 1) { return splitting_files.INTRO_SF_NORM1.id; } return this.oneOfTwoInTurn(previous_keys, to_immersive); } return splitting_files.INTRO_SF_NORM1.id; } }; /** * Select one of the two fragments each after other in turn * @param {Array.<string>} watched already watched fragments * @param {Array.<string>} fragments you need to show * @returns {string} the fragment that should be played */ SplittingFilesManager.prototype.oneOfTwoInTurn = function (watched, fragments) { var last_fragment = watched.reverse().slice().find(function (fragment) { return fragment === fragments[0] || fragment === fragments[1]; }); if (last_fragment && last_fragment === fragments[0]) { return fragments[1]; } if (last_fragment && last_fragment === fragments[1]) { return fragments[0]; } return fragments[0]; }; /** * @param {string} fragment * @returns string without prefix */ SplittingFilesManager.prototype._replacePrefix = function (fragment) { return fragment.replace(splitting_file_prefix, ''); }; /** * Choose what player to turn on to show splitting file * based on mode you transition to and previous watched * segments * @param {string} chosen_mode immersive or normal * @param {Array.<object>} players array of all players * @returns {number} index of target player */ SplittingFilesManager.prototype.choosePlayer = function (_a) { var _this = this; var chosen_mode = _a.chosen_mode, players = _a.players; var target_fragment = this.chooseFragment({ chosen_mode: chosen_mode, }); var fallback; // What player is ready to show required splitting file? var target_player = players.findIndex(function (player, index) { if (player.hasOwnProperty('segment')) { if (player.segment.model.id === target_fragment) { return true; } else { if (_this._isSplittingFIle(player.segment.model.id)) { fallback = index; } } } }); this.addPlayedFragment(target_fragment ? target_fragment : fallback); return target_player !== -1 ? target_player : fallback; }; /** * What video should play provided player next * @param {object} transitionPlayer what player should update it's sourse * to load next splitting file * @param {Array.<object>} transitionSegments all segments that are currently * exist in the state * @returns {object} the source with the segment that should be played next */ SplittingFilesManager.prototype.chooseSegmentForUpdate = function (_a) { var transitionPlayer = _a.transitionPlayer, transitionSegments = _a.transitionSegments; var previous = this.getAlreadyPlayedFragments(); var target_fragment_id; var target_segment; var id = transitionPlayer.segment.model.id; if (to_normal.includes(id)) { target_fragment_id = this.oneOfTwoInTurn(previous, to_normal); } else { target_fragment_id = this.oneOfTwoInTurn(previous, to_immersive); } transitionSegments.forEach(function (segment) { if (segment.segment.model.id === target_fragment_id) { target_segment = segment; target_segment.currentActiveSegment = target_fragment_id; } }); return target_segment; }; return SplittingFilesManager; }()); var BranchManager$1 = /** @class */ (function () { function BranchManager(scenario, mode) { this.previous_branches = []; this.scenario = scenario; if (mode && ['silent', 'prod'].includes(mode)) { this.mode = mode; } } BranchManager.prototype.init = function (_a) { var current_segment = _a.current_segment; this.current_branch = { beggining: current_segment, middle: undefined, end: this._findBranchItem(current_segment.branch.id, 'end') }; this.current_segment = current_segment; }; BranchManager.prototype.getNextSeekableSegment = function (seconds) { var previous_duration = this.getDurationOfPreviousBranchesWithCurrentPosition(); if (this._isSegmentTheBegginingOfTheBranch(this.current_segment) || this._isSegmentTheEndOfTheBranch(this.current_segment)) { var dropped_on = seconds - (previous_duration + this.current_segment.duration); return __assign(__assign({}, this.current_branch.end), { dropped_on: dropped_on }); } }; BranchManager.prototype.getPreviousSeekableSegment = function (seconds) { var previous_duration = this.getDurationOfPreviousBranchesWithCurrentPosition(); if (previous_duration < seconds) { throw 'Provided seconds not refer to the previous segments'; } var overal_duration = 0; var checked_branches = []; this.showState(); var branches_to_explore = this.previous_branches.length > 0 ? __spreadArray(__spreadArray([], this.previous_branches, true), [this.current_branch], false) : [this.current_branch]; for (var _i = 0, branches_to_explore_1 = branches_to_explore; _i < branches_to_explore_1.length; _i++) { var branch = branches_to_explore_1[_i]; overal_duration += branch.beggining.duration; checked_branches.push(branch.beggining.duration); if (overal_duration >= seconds) { var segment = this._copyObject(branch.beggining); segment.dropped_on = seconds - checked_branches.slice(0, checked_branches.length - 1) .reduce(function (acc, val) { return acc + val; }, 0); return segment; } if (this._isSegmentAutonomous(branch.beggining)) { continue; } overal_duration += branch.end.duration; checked_branches.push(branch.end.duration); if (overal_duration >= seconds) { var segment = this._copyObject(branch.end); segment.dropped_on = seconds - checked_branches.slice(0, checked_branches.length - 1) .reduce(function (acc, val) { return acc + val; }, 0); return segment; } } }; BranchManager.prototype.getNextSegment = function () { if (this.current_segment.branch.role === 'end') { //console.log('current_segment is the end of the current branch.'); return null; } return this.current_branch.end; }; BranchManager.prototype.goToNextSegment = function () { if (this._isSegmentTheBegginingOfTheBranch(this.current_segment) || this._isSegmentAutonomous(this.current_segment)) { return this.current_branch.end; } return undefined; }; BranchManager.prototype.goToPrevSegment = function () { if (this._isSegmentTheEndOfTheBranch(this.current_segment)) { this.current_segment = this.current_branch.beggining; return this.current_branch.beggining; } if (this._isSegmentTheBegginingOfTheBranch(this.current_segment) || this._isSegmentAutonomous(this.current_segment)) { var new_current_branch_1 = this._copyObject(this.previous_branches[this.previous_branches.length - 1]); this.current_branch = new_current_branch_1; this.previous_branches = this.previous_branches.filter(function (branch) { return branch.beggining.id !== new_current_branch_1.beggining.id; }); this.current_segment = new_current_branch_1.end; return new_current_branch_1.end; } }; BranchManager.prototype.getDurationOfTimeline = function () { if (!this.current_branch) { return 0; } var previous_duration = this.getDurationOfPreviousBranches(); if (this._isSegmentAutonomous(this.current_branch.beggining) || this._isSegmentAutonomous(this.current_branch.end)) { return previous_duration + this.current_branch.beggining.duration; } return previous_duration + this.current_branch.beggining.duration + this.current_branch.end.duration; }; BranchManager.prototype.getDurationOfPreviousBranches = function () { var acc = 0; for (var _i = 0, _a = this.previous_branches; _i < _a.length; _i++) { var branch = _a[_i]; if (this._isSegmentAutonomous(branch.beggining)) { acc += branch.beggining.duration; continue; } acc += branch.beggining.duration; acc += branch.end.duration; } return acc; }; BranchManager.prototype.getDurationOfPreviousBranchesWithCurrentPosition = function () { var previous_duration = this.getDurationOfPreviousBranches(); if (this._isSegmentTheBegginingOfTheBranch(this.current_segment) || this._isSegmentAutonomous(this.current_segment)) { return previous_duration; } if (this._isSegmentTheEndOfTheBranch(this.current_segment)) { return previous_duration + this.current_branch.beggining.duration; } }; BranchManager.prototype.update = function (current_segment) { if (!this.current_segment || !current_segment || !current_segment.branch) { return; } if (this._isSplittingOrNormalSegment(current_segment)) { //console.log('Splitting file recieved. Skipping...'); return; } if (this._isSegmentAlreadySeen(current_segment)) { this.updateBranches(current_segment); this.showState(); return; } if (this._isSegmentAutonomous(current_segment)) { this.previous_branches.push(this.current_branch); this.current_branch = { beggining: current_segment, middle: undefined, end: current_segment }; this.current_segment = this._copyObject(current_segment); this.showState(); return; } if (current_segment.id !== this.current_segment.id) { if (this._isSegmentTheEndOfTheBranch(current_segment)) { this.previous_branches.push(this.current_branch); this.current_branch = { beggining: this._findBranchItem(current_segment.branch.id, 'beggining'), middle: undefined, end: this._copyObject(current_segment) }; this.current_branch.end = current_segment; this.current_segment = this._copyObject(current_segment); } if (this._isSegmentTheBegginingOfTheBranch(current_segment)) { this.previous_branches.push(this.current_branch); this.current_branch = { beggining: current_segment, middle: undefined, end: this._findBranchItem(current_segment.branch.id, 'end') }; this.current_segment = this._copyObject(current_segment); } this.showState(); } }; BranchManager.prototype._findBranchItem = function (branch_id, role) { var id = branch_id; if (Array.isArray(branch_id)) { if (branch_id.length === 0) { return; } id = branch_id[0].slice(); } var found_segment = this.scenario.find(function (seg) { if (seg.branch) { if (seg.branch.id === id || seg.branch.id.includes(id)) { if (seg.branch.role === role) { return seg; } } } }); if (found_segment) { return found_segment; } if (this.mode === 'silent') { return this.scenario.find(function (s) { return s.id.includes('NI'); }); } throw "Segment with branch_id: ".concat(branch_id, " and role: ").concat(role, " not found"); }; BranchManager.prototype._isSegmentTheEndOfTheBranch = function (segment) { if (this.mode === 'silent') { return false; } if (!segment) { throw 'segment is undefined'; } if (segment.branch && segment.branch.role === 'end') { return true; } return false; }; BranchManager.prototype._isSegmentTheBegginingOfTheBranch = function (segment) { if (this.mode === 'silent') { return false; } if (!segment) { throw 'segment is undefined'; } if (segment.branch && segment.branch.role === 'beggining') { return true; } return false; }; BranchManager.prototype._copyObject = function (obj) { return JSON.parse(JSON.stringify(obj)); }; BranchManager.prototype._isSegmentAutonomous = function (segment) { if (this.mode === 'silent') { return false; } if (!segment) { throw 'segment is undefined'; } if (segment.branch && segment.branch.role === 'all') { return true; } return false; }; BranchManager.prototype.getPrevSegment = function (return_from_splitting_segment) { if (!this.current_segment) { return undefined; } if (return_from_splitting_segment) { //console.log('branchManager.return_from_splitting_segment'); return this.current_segment; } if (this._isSegmentTheEndOfTheBranch(this.current_segment)) { return this.current_branch.beggining; } if (this._isSegmentTheBegginingOfTheBranch(this.current_segment) || this._isSegmentAutonomous(this.current_segment)) { if (this.previous_branches.length) { return this.previous_branches[this.previous_branches.length - 1].end; } return undefined; } }; BranchManager.prototype._isSegmentAlreadySeen = function (segment) { for (var _i = 0, _a = __spreadArray(__spreadArray([], this.previous_branches, true), [this.current_branch], false); _i < _a.length; _i++) { var branch = _a[_i]; if (branch.beggining.id === segment.id || branch.end.id === segment.id) { return true; } } return false; }; BranchManager.prototype.updateBranches = function (new_current_segment) { var new_previous_branches = []; for (var _i = 0, _a = __spreadArray(__spreadArray([], this.previous_branches, true), [this.current_branch], false); _i < _a.length; _i++) { var branch = _a[_i]; var beggining = branch.beggining, end = branch.end; if (beggining.id === new_current_segment.id || end.id === new_current_segment.id) { this.current_branch = this._copyObject(branch); this.current_segment = this._copyObject(new_current_segment); break; } else { new_previous_branches.push(branch); } } this.previous_branches = new_previous_branches; }; BranchManager.prototype.testViewOfDuration = function () { return __spreadArray(__spreadArray([], this.previous_branches, true), [this.current_branch], false); }; BranchManager.prototype._isSplittingOrNormalSegment = function (segment) { if (SPLITTING_FILES.includes(segment.id)