@vizbeetv/sdk-qa 7.8.40 → 7.8.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chromecast-v2/es5/index.js +1 -1
- package/chromecast-v2/es6/index.js +1 -1
- package/lg/es5/index.js +1 -1
- package/lg/es6/index.js +1 -1
- package/lg-el/es5/index.js +1 -0
- package/lg-el/es6/index.js +1 -0
- package/package.json +1 -1
- package/samsung/es5/index.js +1 -1
- package/samsung/es6/index.js +1 -1
- package/samsung-el/es5/index.js +1 -0
- package/samsung-el/es6/index.js +1 -0
- package/vizio/index.js +1 -1
- package/xbox/es5/index.js +1 -1
- package/xbox/es6/index.js +1 -1
- package/xbox-el/es5/index.js +1 -0
- package/xbox-el/es6/index.js +1 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
if(window.VizbeeSDK||(window.VizbeeSDK={}),!window.VizbeeSDK.logger){var e=function(){};window.VizbeeSDK.logger={debug:e,info:e,warn:e,error:e,d:e,i:e,w:e,e:e,critical:e,verbose:e}}function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function i(e,t,n,i,r,o,a){try{var s=e[o](a),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(i,r)}function r(e,t,n){return t=f(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,h()?Reflect.construct(t,n||[],f(e).constructor):t.apply(e,n))}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,S(i.key),i)}}function s(e,t,n){return t&&a(e.prototype,t),n&&a(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function u(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=k(e))||t){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}function l(e,t,n){return(t=S(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)({}).hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},c.apply(null,arguments)}function d(){return d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=f(e)););return e}(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},d.apply(null,arguments)}function f(e){return f=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},f(e)}function p(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&y(e,t)}function h(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(h=function(){return!!e})()}function v(){var e,t,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function o(n,i,r,o){var u=i&&i.prototype instanceof s?i:s,l=Object.create(u.prototype);return g(l,"_invoke",function(n,i,r){var o,s,u,l=0,c=r||[],d=!1,f={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return o=t,s=0,u=e,f.n=n,a}};function p(n,i){for(s=n,u=i,t=0;!d&&l&&!r&&t<c.length;t++){var r,o=c[t],p=f.p,h=o[2];n>3?(r=h===i)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=p&&((r=n<2&&p<o[1])?(s=0,f.v=i,f.n=o[1]):p<h&&(r=n<3||o[0]>i||i>h)&&(o[4]=n,o[5]=i,f.n=h,s=0))}if(r||n>1)return a;throw d=!0,i}return function(r,c,h){if(l>1)throw TypeError("Generator is already running");for(d&&1===c&&p(c,h),s=c,u=h;(t=s<2?e:u)||!d;){o||(s?s<3?(s>1&&(f.n=-1),p(s,u)):f.n=u:f.v=u);try{if(l=2,o){if(s||(r="next"),t=o[r]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+r+"' method"),s=1);o=e}else if((t=(d=f.n<0)?u:n.call(i,f))!==a)break}catch(t){o=e,s=1,u=t}finally{l=1}}return{value:t,done:d}}}(n,r,o),!0),l}var a={};function s(){}function u(){}function l(){}t=Object.getPrototypeOf;var c=[][i]?t(t([][i]())):(g(t={},i,function(){return this}),t),d=l.prototype=s.prototype=Object.create(c);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,g(e,r,"GeneratorFunction")),e.prototype=Object.create(d),e}return u.prototype=l,g(d,"constructor",l),g(l,"constructor",u),u.displayName="GeneratorFunction",g(l,r,"GeneratorFunction"),g(d),g(d,r,"Generator"),g(d,i,function(){return this}),g(d,"toString",function(){return"[object Generator]"}),(v=function(){return{w:o,m:f}})()}function g(e,t,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}g=function(e,t,n,i){function o(t,n){g(e,t,function(e){return this._invoke(t,n,e)})}t?r?r(e,t,{value:n,enumerable:!i,configurable:!i,writable:!i}):e[t]=n:(o("next",0),o("throw",1),o("return",2))},g(e,t,n,i)}function y(e,t){return y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},y(e,t)}function m(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,a,s=[],u=!0,l=!1;try{if(o=(n=n.call(e)).next,0===t);else for(;!(u=(i=o.call(n)).done)&&(s.push(i.value),s.length!==t);u=!0);}catch(e){l=!0,r=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(l)throw r}}return s}}(e,t)||k(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function b(e,t,n,i){var r=d(f(e.prototype),t,n);return"function"==typeof r?function(e){return r.apply(n,e)}:r}function S(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function _(e){return _="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},_(e)}function k(e,t){if(e){if("string"==typeof e)return n(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?n(e,t):void 0}}var T,P,I={exports:{}};T||(T=1,P=I,function(e){function t(){}function n(e){if("object"!=_(this))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],u(e,this)}function i(e,t){for(;3===e._state;)e=e._value;return 0===e._state?void e._deferreds.push(t):(e._handled=!0,void n._immediateFn(function(){var n=1===e._state?t.onFulfilled:t.onRejected;if(null!==n){var i;try{i=n(e._value)}catch(e){return void o(t.promise,e)}r(t.promise,i)}else(1===e._state?r:o)(t.promise,e._value)}))}function r(e,t){try{if(t===e)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"==_(t)||"function"==typeof t)){var i=t.then;if(t instanceof n)return e._state=3,e._value=t,void a(e);if("function"==typeof i)return void u(function(e,t){return function(){e.apply(t,arguments)}}(i,t),e)}e._state=1,e._value=t,a(e)}catch(t){o(e,t)}}function o(e,t){e._state=2,e._value=t,a(e)}function a(e){2===e._state&&0===e._deferreds.length&&n._immediateFn(function(){e._handled||n._unhandledRejectionFn(e._value)});for(var t=0,r=e._deferreds.length;t<r;t++)i(e,e._deferreds[t]);e._deferreds=null}function s(e,t,n){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=n}function u(e,t){var n=!1;try{e(function(e){n||(n=!0,r(t,e))},function(e){n||(n=!0,o(t,e))})}catch(e){if(n)return;n=!0,o(t,e)}}var l=setTimeout;n.prototype.catch=function(e){return this.then(null,e)},n.prototype.then=function(e,n){var r=new this.constructor(t);return i(this,new s(e,n,r)),r},n.all=function(e){var t=Array.prototype.slice.call(e);return new n(function(e,n){function i(o,a){try{if(a&&("object"==_(a)||"function"==typeof a)){var s=a.then;if("function"==typeof s)return void s.call(a,function(e){i(o,e)},n)}t[o]=a,0===--r&&e(t)}catch(e){n(e)}}if(0===t.length)return e([]);for(var r=t.length,o=0;o<t.length;o++)i(o,t[o])})},n.resolve=function(e){return e&&"object"==_(e)&&e.constructor===n?e:new n(function(t){t(e)})},n.reject=function(e){return new n(function(t,n){n(e)})},n.race=function(e){return new n(function(t,n){for(var i=0,r=e.length;i<r;i++)e[i].then(t,n)})},n._immediateFn="function"==typeof setImmediate&&function(e){setImmediate(e)}||function(e){l(e,0)},n._unhandledRejectionFn=function(e){"undefined"!=typeof console&&console},n._setImmediateFn=function(e){n._immediateFn=e},n._setUnhandledRejectionFn=function(e){n._unhandledRejectionFn=e},P.exports?P.exports=n:e.Promise||(e.Promise=n)}(I.exports));var E,V,A,C="UNKNOWN",D="onStart",w="onForeground",N="onBackground",M="subtitle",x="audio",O="bitmovin",z="videojs",L="theo",R="shaka",K=function(){return s(function e(t){if(o(this,e),"Platform"===this.constructor.name)throw new TypeError("Platform::constructor() - Abstract class.");this.config=t||{},this.launchParams=void 0,this.isAppExitInProgress=!1},[{key:"setConfig",value:function(e){this.config=e}},{key:"cloudPlatformName",get:function(){throw new TypeError("Platform::cloudPlatformName() - Abstract method.")}},{key:"uniqueDeviceID",value:function(e,t){this.deviceId.uniqueDeviceID(e,t)}},{key:"deviceIDAlgorithm",get:function(){return this.deviceId.algorithm},set:function(e){}},{key:"platformModel",get:function(){}},{key:"deviceInfo",get:function(){}},{key:"platformVersion",get:function(){}},{key:"networkInfo",get:function(){}},{key:"adId",get:function(){}},{key:"isAdTrackingDisabled",get:function(){}},{key:"createInputDevice",value:function(){throw new TypeError("Platform::createInputDevice() - Abstract method.")}},{key:"enableScreenSaver",value:function(e){}},{key:"defaultAppletAppId",get:function(){throw new TypeError("Platform::defaultAppletAppId() - Abstract method.")}},{key:"launchParamsDeferral",get:function(){return this.launchParams}},{key:"appLifeCycleManager",get:function(){}},{key:"exit",value:function(){VizbeeTV.logger.i("BasePlatform","exit"),this.appLifeCycleManager&&this.appLifeCycleManager.emit("onEnd")}},{key:"isAppExiting",get:function(){return this.isAppExitInProgress},set:function(e){this.isAppExitInProgress=e}},{key:"createPlayer",value:function(){throw new TypeError("Platform::createPlayer() - Abstract method.")}}])}(),U=s(function e(t,n){if(o(this,e),"BaseEvent"===this.constructor.name)throw new TypeError("BaseEvent::constructor() - Abstract class.");this.nativeEvent=t,this.source=n}),F=function(){function e(t,n){return o(this,e),r(this,e,[t,n])}return p(e,U),s(e)}(),B=function(){function e(t,n){var i;if(o(this,e),!(n instanceof ue))throw new TypeError("TVRemoteEvent::constructor() - source must be an instance of BaseTVRemote.");return(i=r(this,e,[t,n])).keyCode=n.keyCodeMap[t.keyCode],i.keyName=n.keyNameMap[i.keyCode],i}return p(e,F),s(e)}(),H=function(){return s(function e(){if(o(this,e),"BaseEventDispatcher"===this.constructor.name)throw new TypeError("BaseEventDispatcher::constructor() - Abstract class.");this.eventType=void 0,this._eventHandlers=[],this.registerListener()},[{key:"registerListener",value:function(){throw new TypeError("BaseEventDispatcher::registerListener() - Abstract method.")}},{key:"onevent",set:function(e){if(void 0===e)this._eventHandlers=[];else{if(!(e instanceof Function))throw new TypeError("BaseEventDispatcher::onevent setter - callback must be an instance of Function.");this._eventHandlers.push(e)}}},{key:"dispatchEvent",value:function(e){if(!(e instanceof U))throw new TypeError("BaseEventDispatcher::dispatchEvent() - event must be instance of BaseEvent.");this._eventHandlers.forEach(function(t){t instanceof Function&&t(e)})}},{key:"reset",value:function(){this._eventHandlers=[]}}])}(),G=function(){function e(){var t;if(o(this,e),"BaseInputDevice"===(t=r(this,e)).constructor.name)throw new TypeError("BaseInputDevice::constructor() - Abstract class.");return t}return p(e,H),s(e)}(),W={exports:{}},j=W.exports;function q(){return E||(E=1,function(e){!function(t){var n=setTimeout;function i(){}var r="function"==typeof setImmediate&&setImmediate||function(e){n(e,1)},o=function(e){"undefined"!=typeof console&&console},a=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function s(e){if("object"!==_(this))throw new TypeError("Promises must be constructed via new");if("function"!=typeof e)throw new TypeError("not a function");this._state=0,this._handled=!1,this._value=void 0,this._deferreds=[],p(e,this)}function u(e,t){for(;3===e._state;)e=e._value;0!==e._state?(e._handled=!0,r(function(){var n=1===e._state?t.onFulfilled:t.onRejected;if(null!==n){var i;try{i=n(e._value)}catch(e){return void c(t.promise,e)}l(t.promise,i)}else(1===e._state?l:c)(t.promise,e._value)})):e._deferreds.push(t)}function l(e,t){try{if(t===e)throw new TypeError("A promise cannot be resolved with itself.");if(t&&("object"===_(t)||"function"==typeof t)){var n=t.then;if(t instanceof s)return e._state=3,e._value=t,void d(e);if("function"==typeof n)return void p((i=n,r=t,function(){i.apply(r,arguments)}),e)}e._state=1,e._value=t,d(e)}catch(t){c(e,t)}var i,r}function c(e,t){e._state=2,e._value=t,d(e)}function d(e){2===e._state&&0===e._deferreds.length&&setTimeout(function(){e._handled||o(e._value)},1);for(var t=0,n=e._deferreds.length;t<n;t++)u(e,e._deferreds[t]);e._deferreds=null}function f(e,t,n){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.promise=n}function p(e,t){var n=!1;try{e(function(e){n||(n=!0,l(t,e))},function(e){n||(n=!0,c(t,e))})}catch(e){if(n)return;n=!0,c(t,e)}}s.prototype.catch=function(e){return this.then(null,e)},s.prototype.then=function(e,t){var n=new s(i);return u(this,new f(e,t,n)),n},s.all=function(){var e=Array.prototype.slice.call(1===arguments.length&&a(arguments[0])?arguments[0]:arguments);return new s(function(t,n){if(0===e.length)return t([]);var i=e.length;function r(o,a){try{if(a&&("object"===_(a)||"function"==typeof a)){var s=a.then;if("function"==typeof s)return void s.call(a,function(e){r(o,e)},n)}e[o]=a,0===--i&&t(e)}catch(e){n(e)}}for(var o=0;o<e.length;o++)r(o,e[o])})},s.resolve=function(e){return e&&"object"===_(e)&&e.constructor===s?e:new s(function(t){t(e)})},s.reject=function(e){return new s(function(t,n){n(e)})},s.race=function(e){return new s(function(t,n){for(var i=0,r=e.length;i<r;i++)e[i].then(t,n)})},s._setImmediateFn=function(e){r=e},s._setUnhandledRejectionFn=function(e){o=e},e.exports?e.exports=s:t.Promise||(t.Promise=s)}(j)}(W)),W.exports}function J(){if(A)return V;A=1;var e={get:function(e,t,n){for(var i=Array.isArray(t)?t:[t],r=e,o=0;o<i.length;o++){if(null==r)return n;r=r[i[o]]}return void 0===r?n:r},extend:function(e){if(null==e)return e;for(var t=1;t<arguments.length;t++){var n=arguments[t];if(null!=n)for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},isObject:function(e){return null!==e&&"object"===_(e)},find:function(e,t){if(null!=e){if(Array.isArray(e))return e.find(t);for(var n=Object.keys(e),i=0;i<n.length;i++){var r=e[n[i]];if(t(r,n[i],e))return r}}},keys:function(e){return Object.keys(e)},isString:function(e){return"string"==typeof e},filter:function(e,t){return Array.isArray(e)?e.filter(t):Object.keys(e).reduce(function(n,i){return t(e[i],i,e)&&n.push(e[i]),n},[])},omit:function(e){var t=Array.isArray(arguments[1])?arguments[1]:Array.prototype.slice.call(arguments,1),n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&-1===t.indexOf(i)&&(n[i]=e[i]);return n},isUndefined:function(e){return void 0===e},isNumber:function(e){return"number"==typeof e},isArray:function(e){return Array.isArray(e)},each:function(e,t){return Array.isArray(e)?e.forEach(t):null!=e&&Object.keys(e).forEach(function(n){t(e[n],n,e)}),e},contains:function(e,t){return-1!==e.indexOf(t)},values:function(e){return Object.keys(e).map(function(t){return e[t]})},isFunction:function(e){return"function"==typeof e},isEmpty:function(e){return null==e||(Array.isArray(e)||"string"==typeof e?0===e.length:0===Object.keys(e).length)},clone:function(t){return Array.isArray(t)?t.slice():e.extend({},t)},reject:function(e,t){return Array.isArray(e)?e.filter(function(e){return!t(e)}):Object.keys(e).reduce(function(n,i){return t(e[i],i,e)||n.push(e[i]),n},[])},reduce:function(e,t,n){return Array.isArray(e)?e.reduce(t,n):(Object.keys(e).forEach(function(i){n=t(n,e[i],i,e)}),n)},isBoolean:function(e){return!0===e||!1===e},isNaN:function(e){return"number"==typeof e&&e!=e},isEqual:function(e,t){return JSON.stringify(e)===JSON.stringify(t)},pluck:function(e,t){return e.map(function(e){return e[t]})},findIndex:function(e,t){var n="function"==typeof t?t:function(e){return null!=e&&Object.keys(t).every(function(n){return e[n]===t[n]})};return e.findIndex(n)},findLastIndex:function(e,t){for(var n="function"==typeof t?t:function(e){return null!=e&&Object.keys(t).every(function(n){return e[n]===t[n]})},i=e.length-1;i>=0;i--)if(n(e[i],i,e))return i;return-1},findWhere:function(e,t){return e.find(function(e){return null!=e&&Object.keys(t).every(function(n){return e[n]===t[n]})})},without:function(e){var t=Array.prototype.slice.call(arguments,1);return e.filter(function(e){return-1===t.indexOf(e)})},sortBy:function(e,t){var n="function"==typeof t?t:function(e){return e[t]};return e.slice().sort(function(e,t){var i=n(e),r=n(t);return i<r?-1:i>r?1:0})},rest:function(e,t){return e.slice(void 0===t?1:t)},indexOf:function(e,t){return e.indexOf(t)},intersection:function(){var e=Array.prototype.slice.call(arguments);return e[0].filter(function(t){return e.every(function(e){return-1!==e.indexOf(t)})})}};return V=e}var Y,X,Q,Z,$,ee,te=t(J()),ne=[],ie=[],re=[],oe=document.getElementsByTagName("HEAD")[0],ae=document.getElementsByTagName("BODY")[0],se=function(){function e(){o(this,e)}return s(e,null,[{key:"xchangeHLSUrl",value:function(e,t,n,i,r,o){var a="unknown",s="unknown";t&&(a=t),n&&(s=n);var u="https://hlsxchange.claspws.tv/"+a+"/"+s;return e&&e.indexOf(u)>=0?e:(i&&r&&o&&(u+="/"+i+"/"+r+"/"+o),u+="/x.m3u8?hlsurl="+e)}},{key:"getRandomIntInclusive",value:function(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}},{key:"buildErrorEvent",value:function(e,t,n){return{code:e,reason:t,data:n}}},{key:"loadStyleSheet",value:function(e){if(!e||!(e instanceof String||"string"==typeof e))throw new TypeError("Util::loadStyleSheet - Url must be a string.");var t=document.createElement("link");t.setAttribute("rel","stylesheet"),t.setAttribute("type","text/css"),oe.appendChild(t),re.push(t),t.setAttribute("href",e)}},{key:"loadSynchronousScripts",value:function(t){var n=n||void 0;if(n||(n=q()),void 0===e.loadSynchronousScripts.scripts&&(e.loadSynchronousScripts.scripts=[],e.loadSynchronousScripts.index=-1,e.loadSynchronousScripts.loading=!1,e.loadSynchronousScripts.next=function(){if(!e.loadSynchronousScripts.loading){e.loadSynchronousScripts.loading=!0;var t=e.loadSynchronousScripts.scripts[++e.loadSynchronousScripts.index],n=document.getElementsByTagName("head")[0],i=document.createElement("script");i.type="text/javascript",i.src=t.src,i.onload=function(){e.loadSynchronousScripts.loading=!1,e.loadSynchronousScripts.index<e.loadSynchronousScripts.scripts.length-1&&e.loadSynchronousScripts.next(),t.resolve()},n.appendChild(i)}}),t){for(var i=0;i<e.loadSynchronousScripts.scripts.length;i++)if(e.loadSynchronousScripts.scripts[i].src==t)return e.loadSynchronousScripts.scripts[i].promise;var r={src:t};r.promise=new n(function(e){r.resolve=e}),e.loadSynchronousScripts.scripts.push(r),e.loadSynchronousScripts.next()}return e.loadSynchronousScripts.scripts[e.loadSynchronousScripts.scripts.length-1].promise}},{key:"loadScript",value:function(e,t,n){if(!e||!(e instanceof String||"string"==typeof e))throw new TypeError("Util::loadScript - Url must be a string.");t=!(!t&&void 0!==t);var i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("async",t),i.onload=n||function(){},oe.appendChild(i),ne.push(i),i.setAttribute("src",e)}},{key:"loadScriptToBody",value:function(e,t,n){if(!e||!(e instanceof String||"string"==typeof e))throw new TypeError("Util::loadScript - Url must be a string.");t=!(!t&&void 0!==t);var i=document.createElement("script");i.setAttribute("type","text/javascript"),i.setAttribute("async",t),i.onload=n||function(){},ae.appendChild(i),ie.push(i),i.setAttribute("src",e)}},{key:"clearLoadedScripts",value:function(){for(var e=0;e<ne.length;e++)ne[e]&&ne[e]instanceof Node&&(oe.removeChild(ne[e]),delete ne[e])}},{key:"clearBodyLoadedScripts",value:function(){for(var e=0;e<ie.length;e++)ie[e]&&ie[e]instanceof Node&&(ae.removeChild(ie[e]),delete ie[e])}},{key:"clearLoadedStyleSheets",value:function(){for(var e=0;e<re.length;e++)re[e]&&re[e]instanceof Node&&(re[e].disabled=!0,oe.removeChild(re[e]),delete re[e])}},{key:"clearAllLoadedScriptsAndStyleSheets",value:function(){e.clearLoadedScripts(),e.clearLoadedStyleSheets()}},{key:"addClass",value:function(e,t){if(t){var n=t.className;if(-1!=n.indexOf(e))return;""!=n&&(e=" "+e),t.className=n+e}}},{key:"removeClass",value:function(e,t){if(t){var n=t.className,i=new RegExp(e,"g");n=n.replace(i,""),t.className=n}}},{key:"hasClass",value:function(e,t){return(" "+e.className+" ").indexOf(" "+t+" ")>-1}},{key:"elementInViewport",value:function(e,t,n){var i=e.getBoundingClientRect(),r=i.top,o=i.bottom,a=i.left,s=i.right,u=document.documentElement.clientHeight,l=document.documentElement.clientWidth,c=window.innerHeight,d=window.innerWidth;return n&&(r-=n),t?r>=0&&o<=window.innerHeight:r>=0&&r<=(c||u)&&a>=0&&a<=(d||l)||o>=0&&o<=(c||u)&&s>=0&&s<=(d||l)}},{key:"smoothScroll",value:function(t,n){var i=t,r=t;do{if(!(i=i.parentNode))return;i.scrollTop+=1}while(0==i.scrollTop);var o=0;do{if(t==i)break;o+=t.offsetTop}while(t=t.offsetParent);e.myscroll(r,n,i,i.scrollTop,o-n,0)}},{key:"myscroll",value:function(t,n,i,r,o,a){++a>10||t.children.length>0&&e.elementInViewport(t.children.item(0),!0,n)||(i.scrollTop=r+(o-r)/10*a,setTimeout(function(){e.myscroll(t,n,i,r,o,a)},20))}},{key:"xhr",value:function(e){var t=t||void 0;return t||(t=q()),new t(function(t,n){var i=0===e.retries?0:e.retries||3;!function r(){var o=new XMLHttpRequest;e.disableSSL||(e.url=e.url.replace(/^http:\/\//i,"https://")),o.open(e.method||"GET",e.url,!0),Object.keys(e.headers||{}).forEach(function(t){o.setRequestHeader(t,e.headers[t])});var a=void 0;o.onreadystatechange=function(s){var u,l;if(2==o.readyState&&(u=o.getAllResponseHeaders().trim().split(/[\r\n]+/),l={},u.forEach(function(e){var t=e.split(": "),n=t.shift(),i=t.join(": ");l[n]=i}),a=l),4===o.readyState)if(-1===[200,201,202,203,204,304].indexOf(o.status))i>0?(i--,r()):e.isFullResponse?n(o):n(new Error("Server responded with a status of "+o.status));else try{var d=s.target;e.format=e.format||"json","json"===e.format?(d=d.response?JSON.parse(d.response):{}).headers?c(d.headers,a):d.headers=a:"xml"===e.format&&(d=d.responseXML),e.isFullResponse?t({xhr:s.target,data:d,headers:a}):t(d)}catch(s){i>0?(i--,r()):e.isFullResponse?n(o):n("JSON parse error with Server response")}},e.timeout&&(o.timeout=e.timeout,o.ontimeout=function(t){i>0?(i--,r()):n(new Error("Server timeout "+e.timeout+"ms"))}),o.send(e.data)}()})}},{key:"timeSnapToMs",value:function(e){e.split(".").length<=1&&(e+=".000");var t=e.split(":"),n=t.pop().split("."),i=1e3*Number(n[0])+Number(n[1]);return(i+=1e3*Number(t.pop())*60)+1e3*Number(t.pop())*60*60}},{key:"millisecondsToString",value:function(e,t){var n="",i=Math.floor(e%31536e3%86400%3600%60);n=isNaN(i)||i<=0?":00":i<10?":0"+i:":"+i;var r=Math.floor(e%31536e3%86400%3600/60);n=isNaN(r)||r<=0?"00"+n:r<10?"0"+r+n:r+n;var o=Math.floor(e%31536e3%86400/3600);return t?n=isNaN(o)||o<=0?"00:"+n:o<10?"0"+o+":"+n:o+":"+n:o>0&&(n=o+":"+n),n}},{key:"getUrlVars",value:function(){for(var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.location.href,n={},i=t.slice(t.indexOf("?")+1).split("&"),r=0;r<i.length;r++)n[(e=i[r].split("="))[0]]=decodeURIComponent(e[1]);return n}},{key:"updateUrlQueryParams",value:function(e,t){if(!e)return VizbeeUtils.logger.warn("Util::updateUrlQueryParams - INVALID inputUrl, doing nothing"),e;if(te.isEmpty(t))return VizbeeUtils.logger.warn("Util::updateUrlQueryParams - INVALID inputParams, doing nothing"),e;try{var n=new URL(e),i=new URLSearchParams(n.search);Object.keys(t).forEach(function(e){return i.set(e,t[e])}),n.search=i.toString();var r=n.toString();return VizbeeUtils.logger.debug("Util::updateUrlQueryParams - updated url="+r),r}catch(t){return VizbeeUtils.logger.error("Util::updateUrlQueryParams - failed to update query params for url="+e),e}}},{key:"docCookies",get:function(){return{getItem:function(e){return e&&decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null},setItem:function(e,t,n,i,r,o){if(!e||/^(?:expires|max\-age|path|domain|secure)$/i.test(e))return!1;var a="";if(n)switch(n.constructor){case Number:a=n===1/0?"; expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+n;break;case String:a="; expires="+n;break;case Date:a="; expires="+n.toUTCString()}return document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(t)+a+(r?"; domain="+r:"")+(i?"; path="+i:"")+(o?"; secure":""),!0},removeItem:function(e,t,n){return!!this.hasItem(e)&&(document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT"+(n?"; domain="+n:"")+(t?"; path="+t:""),!0)},hasItem:function(e){return!!e&&new RegExp("(?:^|;\\s*)"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie)},keys:function(){for(var e=document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g,"").split(/\s*(?:\=[^;]*)?;\s*/),t=e.length,n=0;n<t;n++)e[n]=decodeURIComponent(e[n]);return e},eraseCookieFromAllPaths:function(e){var t=location.pathname.split("/"),n=" path=";document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT;";for(var i=0;i<t.length;i++)n+=("/"!=n.substr(-1)?"/":"")+t[i],document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT;"+n+";"}}}},{key:"invert",value:function(e){for(var t={},n=Object.keys(e),i=0,r=n.length;i<r;i++)t[e[n[i]]]=n[i];return t}},{key:"deepMerge",value:function(t,n){var i=Array.isArray(n),r=i&&[]||{};return i?(t=t||[],r=r.concat(t),n.forEach(function(n,i){void 0===r[i]?r[i]=n:"object"===_(n)?r[i]=e.deepMerge(t[i],n):-1===t.indexOf(n)&&r.push(n)})):("object"===_(t)&&null!==t&&Object.keys(t).forEach(function(e){r[e]=t[e]}),Object.keys(n).forEach(function(i){"object"===_(n[i])&&n[i]&&t[i]?r[i]=e.deepMerge(t[i],n[i]):r[i]=n[i]})),r}},{key:"isEqual",value:function(e,t){return te.isEqual(e,t)}},{key:"flatten",value:function(e){var t={};return function e(n,i){if(Object(n)!==n)t[i]=n;else if(Array.isArray(n)){for(var r=0,o=n.length;r<o;r++)e(n[r],i+"["+r+"]");0==o&&(t[i]=[])}else{var a=!0;for(var s in n)a=!1,e(n[s],i?i+"."+s:s);a&&i&&(t[i]={})}}(e,""),t}},{key:"unflatten",value:function(e){if(Object(e)!==e||Array.isArray(e))return e;var t=/\.?([^.\[\]]+)|\[(\d+)\]/g,n={};for(var i in e){for(var r,o=n,a="";r=t.exec(i);)o=o[a]||(o[a]=r[2]?[]:{}),a=r[2]||r[1];o[a]=e[i]}return n[""]||n}},{key:"decodeB64Recurse",value:function(t,n){if(!t||!n)return t;for(var i in t){var r=t[i];if("object"===_(r))e.decodeB64Recurse(r,n);else if(i.indexOf(n)>-1){var o=i.replace(n,"");if(t[o]=t[i],delete t[i],"string"==typeof t[o]){var a=decodeURIComponent(escape(atob(t[o])));t[o]=e.parseFunction(a)}}}return t}},{key:"parseFunction",value:function(e){var t=e.indexOf("{"),n=e.substring(t+1,e.lastIndexOf("}")),i=e.substring(0,t),r=i.substring(i.indexOf("(")+1,i.lastIndexOf(")")).split(",");function o(){return Function.apply(this,r)}return r.push(n),o.prototype=Function.prototype,new o}},{key:"padStart",value:function(t,n,i){return n|=0,i=String(void 0!==i?i:" "),t.length>n?String(t):((n-=t.length)>i.length&&(i+=e.repeat(i,n/i.length)),i.slice(0,n)+String(t))}},{key:"padEnd",value:function(t,n,i){return n|=0,i=String(void 0!==i?i:" "),t.length>n?String(t):((n-=t.length)>i.length&&(i+=e.repeat(i,n/i.length)),String(t)+i.slice(0,n))}},{key:"repeat",value:function(e,t){if(!e)throw new TypeError("can't convert "+e+" to object");var n=""+e;if((t=+t)!=t&&(t=0),t<0)throw new RangeError("repeat count must be non-negative");if(t==1/0)throw new RangeError("repeat count must be less than infinity");if(t=Math.floor(t),0==n.length||0==t)return"";if(n.length*t>=1<<28)throw new RangeError("repeat count must not overflow maximum string size");var i=n.length*t;for(t=Math.floor(Math.log(t)/Math.log(2));t;)n+=n,t--;return n+n.substring(0,i-n.length)}},{key:"getShortString",value:function(e,t){if(!te.isString(t))return e;if(!te.isString(e))return e;if(-1!=e.indexOf(t)){var n=e.trim().split(t);return te.reduce(n,function(e,t){return e+t.charAt(0)},"")}return e}},{key:"toCamelCase",value:function(e){return void 0===e?e:(e=e.replace(/([-_][a-z])/g,function(e){return e.toUpperCase().replace("-","").replace("_","")})).charAt(0).toLowerCase()+e.slice(1)}},{key:"matchStringWithRegex",value:function(e,t){return null!=t&&null!=e&&new RegExp(e,"i").test(t)}},{key:"isValidIPv4Address",value:function(t){return null!=t&&e.matchStringWithRegex(/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/,t)}},{key:"convertObjectsToString",value:function(e){if(!e)return e;if(!Array.isArray(e))return e;for(var t=0;t<e.length;t++){var n=e[t];try{"object"==_(n)&&(n=JSON.stringify(n))}catch(e){}e[t]=n}return e}},{key:"getUpdatedStringWithReplacedValues",value:function(e,t){return te.isString(e)?!t||Array.isArray(t)||"object"!=_(t)?(VizbeeUtils.logger.d("Util","getUpdatedStringWithReplacedValues","INVALID input json, NOT updating input string"),e):(Object.keys(t).forEach(function(n){e=e.replace(new RegExp(n,"gi"),t[n])}),e):(VizbeeUtils.logger.warn("Util::getUpdatedStringWithReplacedValues - INVALID inputString, NOT updating input string"),e)}},{key:"uuidv4",value:function(){return crypto&&crypto.getRandomValues?([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,function(e){return(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16)}):Math.floor(1e10*Math.random()).toString()}},{key:"checkIfImageExists",value:function(e){var t=t||void 0;return t||(t=q()),new t(function(t,n){var i=new Image;i.src=e,i.complete?t(!0):(i.onload=function(){t(!0)},i.onerror=function(){t(!1)})})}},{key:"getFormEncodedUriFormat",value:function(e){if(te.isObject(e)){var t=[];for(var n in e){var i=encodeURIComponent(n),r=encodeURIComponent(e[n]);t.push(i+"="+r)}return t.join("&")}}}])}(),ue=function(){function e(t){var n;if(o(this,e),n=r(this,e),VizbeeTV.logger.debug("constructing BaseTVRemote"),n.eventType=B,!(t&&t instanceof K))throw new Error("BaseTVRemote::constructor() -- platform cannot be empty or invalid.");return n.platform=t,n}return p(e,G),s(e,[{key:"keyNameMap",get:function(){return{1:"up",2:"down",3:"left",4:"right",5:"select",6:"play",7:"pause",8:"stop",9:"fast-forward",10:"rewind",11:"back",12:"exit",13:"play-pause",14:"alt_up",15:"alt_down",16:"alt_left",17:"alt_right",18:"skip_next",19:"skip_prev"}}},{key:"keyCodeMap",get:function(){throw new TypeError("Abstract method - BaseTVRemote::keyMap getter.")}},{key:"registerListener",value:function(){var e=this;try{document.addEventListener("keydown",function(t){e.dispatchEvent(new B(t,e))})}catch(e){VizbeeTV.logger.error("registerListener error - ",e.message,e)}}},{key:"sendKeyEvent",value:function(e){try{var t=se.invert(this.keyCodeMap)[e],n=new Event("keydown");n.keyCode=t,n.charCode=t,document.dispatchEvent(n)}catch(e){VizbeeTV.logger.error("sendKeyEvent error ",e.message,e)}}},{key:"sendPlay",value:function(){this.sendKeyEvent(e.keys.play)}},{key:"sendPause",value:function(){this.sendKeyEvent(e.keys.pause)}},{key:"sendStop",value:function(){this.sendKeyEvent(e.keys.stop)}}],[{key:"keys",get:function(){return{up:1,down:2,left:3,right:4,select:5,play:6,pause:7,stop:8,ffw:9,rw:10,back:11,exit:12,play_pause:13,alt_up:14,alt_down:15,alt_left:16,alt_right:17,skip_next:18,skip_prev:19}}}])}(),le=function(){function e(){return o(this,e),r(this,e,arguments)}return p(e,ue),s(e,[{key:"keyCodeMap",get:function(){return{203:ue.keys.up,204:ue.keys.down,205:ue.keys.left,206:ue.keys.right,195:ue.keys.select,197:ue.keys.play_pause,196:ue.keys.back,202:ue.keys.ffw,201:ue.keys.rw,211:ue.keys.alt_up,212:ue.keys.alt_down,213:ue.keys.alt_right,214:ue.keys.alt_left}}},{key:"sendPlay",value:function(){this.sendKeyEvent(ue.keys.play_pause)}},{key:"sendPause",value:function(){this.sendKeyEvent(ue.keys.play_pause)}},{key:"sendStop",value:function(){this.sendKeyEvent(ue.keys.back)}}])}(),ce=function(){return s(function e(){if(o(this,e),"BaseDeviceID"===this.constructor.name)throw new TypeError("BaseDeviceID::constructor() - Abstract class.");this.deviceIdAlgorithm="VTV_DEFAULT",this.deviceIdKey="deviceid"},[{key:"uniqueDeviceID",value:function(e,t){VizbeeTV.logger.error("BaseDeviceID::uniqueDeviceID - subclass did not override; no deviceId available"),t()}},{key:"algorithm",get:function(){return this.deviceIdAlgorithm}}])}(),de=function(){function e(){var t;return o(this,e),(t=r(this,e)).deviceIdAlgorithm="VTV_INTERNAL_IP",t}return p(e,ce),s(e)}(),fe=function(){function e(){return o(this,e),r(this,e)}return p(e,de),s(e,[{key:"uniqueDeviceID",value:function(e,t){try{var n;if(Windows.Networking.Connectivity.NetworkInformation.getHostNames().forEach(function(e){if(e.type===Windows.Networking.HostNameType.ipv4){var t=e.canonicalName;t&&"127.0.0.1"!==t&&(n=t)}}),!n)return VizbeeTV.logger.error("XboxDeviceID:uniqueDeviceID - no usable IPv4 host name found"),void t();e(n)}catch(e){VizbeeTV.logger.error("XboxDeviceID:uniqueDeviceID - error fetching IP info",e),t()}}}])}(),pe=function(){return s(function e(){o(this,e)},[{key:"isLaunchedbyVizbee",value:function(){throw new TypeError("BaseLaunchParams::isLaunchedbyVizbee() - Abstract method. This method must be implemented by derived classes.")}},{key:"getLaunchParams",value:function(e){}},{key:"setLaunchParams",value:function(e){}},{key:"waitUntilReady",value:function(){return this._readyPromise||Promise.resolve()}}])}(),he=function(){function e(){var t;return o(this,e),(t=r(this,e))._params=void 0,t}return p(e,pe),s(e,[{key:"isLaunchedbyVizbee",value:function(){var e=this.getLaunchParams();return e?(VizbeeTV.logger.debug("XboxLaunchParams::isLaunchedbyVizbee() - params present",e),!0):(VizbeeTV.logger.debug("XboxLaunchParams::isLaunchedbyVizbee() - params not present"),!1)}},{key:"getLaunchParams",value:function(){return this._params}},{key:"getLaunchParamsAsync",value:function(e){if("function"!=typeof e)throw new TypeError("XboxLaunchParams::getLaunchParamsAsync : Argument supplied is not of type function");this.asyncFunction=e,this._params&&this.asyncFunction(this._params)}},{key:"setLaunchParams",value:function(e){if(VizbeeTV.logger.info("XboxLaunchParams::setLaunchParams() - rawParamData: ",e),e.kind==Windows.ApplicationModel.Activation.ActivationKind.dialReceiver){var t=null;e&&e.arguments&&(t=e.arguments.split("&").reduce(function(e,t){var n=m(t.split("="),2),i=n[0],r=n[1];return e[i]=r,e},{})),VizbeeTV.logger.info("XboxLaunchParams::setLaunchParams() - dialParams: ",t),t&&(this._params=t),this.asyncFunction&&(VizbeeTV.logger.info("XboxLaunchParams::setLaunchParams() - calling asyncFunction: ",this._params),this.asyncFunction(this._params))}else VizbeeTV.logger.info("XboxLaunchParams::setLaunchParams() - not dial params: ",e)}}])}(),ve=function(){return s(function e(){if(o(this,e),"BaseAdID"===this.constructor.name)throw new TypeError("BaseAdID::constructor() - Abstract class.")},[{key:"adId",value:function(){return"UNKNOWN"}},{key:"isAdTrackingDisabled",value:function(){return!0}}])}(),ge=function(){function e(){return o(this,e),r(this,e)}return p(e,ve),s(e,[{key:"adId",value:function(){return Windows?Windows.System.UserProfile.AdvertisingManager.advertisingId:""}},{key:"isAdTrackingDisabled",value:function(){return this.adId().length<=0}}])}(),ye=function(){return s(function e(){o(this,e),this.eventMap={}},[{key:"addHandler",value:function(e,t){this.eventMap[e]||(this.eventMap[e]=[]),this.eventMap[e].push(t)}},{key:"removeHandler",value:function(e,t){var n=this;if(this.eventMap&&this.eventMap[e]){var i,r=this.eventMap[e];if(r&&r.length&&(i=r.reduce(function(e,i,r){return n._isFunction(i)&&i==t?e=r:e},-1))>-1)return r.splice(i,1),this.eventMap[e]=r,!0}return!1}},{key:"emit",value:function(e,t){e&&(VizbeeTV.logger.i("BaseAppLifeCycleManager","emit","eventName=",e,"; eventData=",t),this.eventMap&&this.eventMap[e]&&this.eventMap[e].forEach(function(n){VizbeeTV.logger.i("BaseAppLifeCycleManager","emit","calling handler for event=",e),n.apply({},t)}))}},{key:"reset",value:function(){this.eventMap={}}},{key:"_isFunction",value:function(e){return"function"==typeof e||!1}}])}(),me=function(){function e(){var t;return o(this,e),(t=r(this,e))._eventVsHandlerMap={activated:D,suspending:N,resuming:w},t}return p(e,ye),s(e,[{key:"init",value:function(){Windows&&this._listen()}},{key:"_listen",value:function(){var e=this,t=Object.keys(this._eventVsHandlerMap);(t||t.length)&&t.forEach(function(t){VizbeeTV.logger.debug("XboxAppLifeCycleManager::_listen - adding listener for event = ",t),Windows.UI.WebUI.WebUIApplication.addEventListener(t,function(){for(var n=arguments.length,i=new Array(n),r=0;r<n;r++)i[r]=arguments[r];var o=e._eventVsHandlerMap[t];o&&e.eventMap[o]&&e.eventMap[o].length&&e.eventMap[o].forEach(function(e){VizbeeTV.logger.debug("XboxAppLifeCycleManager::_listen - got event = ",t),VizbeeTV.logger.debug("XboxAppLifeCycleManager::_listen - allArguments = ",i),e.apply({},i)})},!1)})}}])}(),be=function(){return s(function e(){var t,n,i,r,a;o(this,e),this._uaParser=(t=navigator.userAgent,i={name:"",version:""},r={name:"",version:""},a={name:"",version:""},(n=/Windows\s*(?:NT\s*)?([\d.]+)?/i.exec(t))?(i.name="Windows",i.version=n[1]||""):(n=/Mac OS X\s*([\d_.]+)?/i.exec(t))?(i.name="Mac OS",i.version=(n[1]||"").replace(/_/g,".")):(n=/CrOS[\s/]*([\w.]+)?/i.exec(t))?(i.name="Chromium OS",i.version=n[1]||""):(n=/Android\s*([\d.]+)?/i.exec(t))?(i.name="Android",i.version=n[1]||""):(n=/(?:iPhone|iPad).*OS\s*([\d_]+)/i.exec(t))?(i.name="iOS",i.version=(n[1]||"").replace(/_/g,".")):(n=/Linux/i.exec(t))&&(i.name="Linux"),(n=/(?:Edg|EdgA|EdgIOS)\/([\d.]+)/i.exec(t))?(r.name="Edge",r.version=n[1]):(n=/OPR\/([\d.]+)/i.exec(t))?(r.name="Opera",r.version=n[1]):(n=/Firefox\/([\d.]+)/i.exec(t))?(r.name="Firefox",r.version=n[1]):(n=/Chrome\/([\d.]+)/i.exec(t))?(r.name="Chrome",r.version=n[1]):(n=/Safari\/([\d.]+)/i.exec(t))&&/Version\/([\d.]+)/.test(t)&&(r.name="Safari",r.version=/Version\/([\d.]+)/.exec(t)[1]),(n=/AppleWebKit\/([\d.]+)/i.exec(t))?(a.name="WebKit",a.version=n[1]):(n=/Gecko\/([\d.]+)/i.exec(t))?(a.name="Gecko",a.version=n[1]):(n=/Trident\/([\d.]+)/i.exec(t))&&(a.name="Trident",a.version=n[1]),{os:i,browser:r,engine:a})},[{key:"deviceId",get:function(){return C}},{key:"make",get:function(){return C}},{key:"model",get:function(){return C}},{key:"modelYear",get:function(){return C}},{key:"serialNumber",get:function(){return C}},{key:"friendlyName",get:function(){return C}},{key:"macAddress",get:function(){return C}},{key:"userAgent",get:function(){return navigator.userAgent}},{key:"os",get:function(){return{name:this._uaParser.os.name,sdkVersion:this._uaParser.os.version,version:this._uaParser.os.version}}},{key:"browser",get:function(){return{name:this._uaParser.browser.name,version:this._uaParser.browser.version,engine_name:this._uaParser.engine.name,engine_version:this._uaParser.engine.version}}},{key:"screen",get:function(){return{height:document.body.clientHeight,width:document.body.clientWidth}}}])}(),Se=function(){function e(){var t;o(this,e),(t=r(this,e))._info=void 0;try{t._info=Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation()}catch(e){VizbeeTV.logger.error("XboxDeviceInfo::constructor | Error in getting EasClientDeviceInformation()",e)}return t}return p(e,be),s(e,[{key:"deviceId",get:function(){return this._info&&this._info.id||C}},{key:"make",get:function(){return this._info&&this._info.systemManufacturer||C}},{key:"model",get:function(){return this._info&&this._info.systemProductName||C}},{key:"friendlyName",get:function(){return this._info&&this._info.friendlyName||C}}])}(),_e=function(){return s(function e(){o(this,e)},[{key:"internalIP",get:function(){return C}},{key:"externalIP",get:function(){return C}},{key:"isWifiConnected",get:function(){return!0}},{key:"connectionType",get:function(){return C}},{key:"bssid",get:function(){return C}},{key:"ssid",get:function(){return C}}])}(),ke=function(){function e(){return o(this,e),r(this,e)}return p(e,_e),s(e,[{key:"internalIP",get:function(){var e=C;try{Windows.Networking.Connectivity.NetworkInformation.getHostNames().forEach(function(t){t.type===Windows.Networking.HostNameType.ipv4&&(e=t.canonicalName)})}catch(e){VizbeeTV.logger.error("XboxDeviceInfo::internalIP | error fetching IP info",e)}return e}}])}(),Te=function(){return s(function e(){o(this,e)},[{key:"init",value:function(){this.player=void 0}},{key:"setPlayer",value:function(e){this.player=e}},{key:"getPlayer",value:function(){return this.player}},{key:"getTracks",value:function(e){return[]}},{key:"getEnabledTracks",value:function(e){return[]}},{key:"enableTracks",value:function(){}},{key:"disableTracks",value:function(e){}}])}(),Pe=function(){return s(function e(){o(this,e)},null,[{key:"getInstance",value:function(e,t){}}])}(),Ie=function(){function e(){var t;return o(this,e),(t=r(this,e)).init(),t}return p(e,Te),s(e,[{key:"init",value:function(){this.subtitleInstance=void 0,this.playerType=void 0,this.subtitleType=void 0,this.videoPlayer=void 0}},{key:"setPlayerWithType",value:function(e,t){e?t?(this.playerType=e,this.playerType==O?this.videoPlayer=t.bitmovinPlayer:this.playerType==z?this.videoPlayer=t.playerElement:this.playerType==L?this.videoPlayer=t.playerInstance:this.playerType==R?this.videoPlayer=t.shakaPlayer:this.videoPlayer=t,this._setSubtitleInstance()):VizbeeTV.logger.warn("VirtualSubtitle::setPlayer - invalid parameter 'videoPlayer'"):VizbeeTV.logger.warn("VirtualSubtitle::setPlayer - invalid parameter 'playerType'")}},{key:"getPlayer",value:function(){return this.videoPlayer}},{key:"setSubtitleType",value:function(e){this.subtitleType=e,this._setSubtitleInstance()}},{key:"_setSubtitleInstance",value:function(){this.playerType&&this.videoPlayer&&this.subtitleType&&(this.subtitleInstance=Pe.getInstance(this.playerType,this.subtitleType),this.subtitleInstance&&(this.subtitleInstance.init(),this.subtitleInstance.setPlayer(this.videoPlayer)))}},{key:"isReady",value:function(){return!!this.subtitleInstance}},{key:"getTracks",value:function(e){return VizbeeTV.logger.verbose("VirtualSubtitle::getTracks - trackType = ",e),this.subtitleInstance?this.subtitleInstance.getTracks(e):(VizbeeTV.logger.verbose("VirtualSubtitle::getTracks - sending empty data as there is no valid subtitle instance"),[])}},{key:"getEnabledTracks",value:function(e){return VizbeeTV.logger.verbose("VirtualSubtitle::getTracks - trackType = ",e),this.subtitleInstance?this.subtitleInstance.getEnabledTracks(e):(VizbeeTV.logger.verbose("VirtualSubtitle::getEnabledTracks - sending empty data as there is no valid subtitle instance"),[])}},{key:"enableTracks",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.subtitleInstance&&this.subtitleInstance.enableTracks(e)}},{key:"disableTracks",value:function(e){this.subtitleInstance&&this.subtitleInstance.disableTracks(e)}}])}(),Ee=l(l(l(l({en:"English","en-US":"English (United States)","en-GB":"English (United Kingdom)","en-CA":"English (Canada)","en-AU":"English (Australia)",es:"Spanish","es-ES":"Spanish (Spain)","es-MX":"Spanish (Mexico)",fr:"French","fr-FR":"French (France)","fr-CA":"French (Canada)","fr-BE":"French (Belgium)",de:"German","de-DE":"German (Germany)","de-AT":"German (Austria)","de-CH":"German (Switzerland)",it:"Italian","it-IT":"Italian (Italy)",pt:"Portuguese","pt-PT":"Portuguese (Portugal)","pt-BR":"Portuguese (Brazil)",ru:"Russian","ru-RU":"Russian (Russia)",zh:"Chinese","zh-CN":"Chinese (Simplified)","zh-TW":"Chinese (Traditional)",ja:"Japanese",ko:"Korean",ar:"Arabic","ar-SA":"Arabic (Saudi Arabia)","ar-EG":"Arabic (Egypt)",hi:"Hindi",bn:"Bengali",pa:"Punjabi",mr:"Marathi",te:"Telugu",tr:"Turkish",vi:"Vietnamese",th:"Thai",id:"Indonesian",ms:"Malay",tl:"Tagalog",sw:"Swahili",fi:"Finnish",sv:"Swedish",no:"Norwegian",da:"Danish",pl:"Polish",hu:"Hungarian",cs:"Czech",sk:"Slovak",el:"Greek",ro:"Romanian",bg:"Bulgarian",sr:"Serbian",hr:"Croatian",uk:"Ukrainian",he:"Hebrew",ur:"Urdu",fa:"Persian",gu:"Gujarati",kn:"Kannada",ml:"Malayalam",ta:"Tamil",si:"Sinhalese",cy:"Welsh",sq:"Albanian",mk:"Macedonian",bs:"Bosnian",et:"Estonian",lv:"Latvian",lt:"Lithuanian",ka:"Georgian",am:"Amharic",yo:"Yoruba",ig:"Igbo",zu:"Zulu",xh:"Xhosa",ne:"Nepali"},"ms","Malay"),"hi-IN","Hindi (India)"),"bn-IN","Bengali (India)"),"pa-IN","Punjabi (India)"),Ve=function(){return s(function e(){o(this,e)},[{key:"init",value:function(){this.player=void 0,this._reset()}},{key:"setPlayer",value:function(e){this.player=e}},{key:"getPlayer",value:function(){return this.player}},{key:"getTracks",value:function(e){return[]}},{key:"getEnabledTracks",value:function(e){return[]}},{key:"setActiveTrack",value:function(e){}},{key:"_setTrackIdStringToNumberMap",value:function(e){if(!this.trackIdStringToNumberMap[e]){var t=parseInt(e);te.isNaN(t)&&(t=Object.keys(this.trackIdStringToNumberMap).length+1),this.trackIdStringToNumberMap[e]=t,VizbeeTV.logger.verbose("BaseAudio::_setTrackIdStringToNumberMap - updated trackIdStringToNumberMap = ",this.trackIdStringToNumberMap)}}},{key:"_setTrackLanguageCodeToNameMap",value:function(e){!e&&this.trackLanguageCodeToNameMap[e]||(this.trackLanguageCodeToNameMap[e]=Ee[e]||e,VizbeeTV.logger.verbose("BaseAudio::_setTrackLanguageCodeToNameMap - updated _setTrackLanguageCodeToNameMap = ",this.trackLanguageCodeToNameMap))}},{key:"_reset",value:function(){this.trackIdStringToNumberMap={},this.trackLanguageCodeToNameMap={}}}])}(),Ae=function(){return s(function e(){o(this,e)},null,[{key:"getInstance",value:function(e){}}])}(),Ce=function(){function e(){var t;return o(this,e),(t=r(this,e)).init(),t}return p(e,Ve),s(e,[{key:"init",value:function(){this.audioInstance=void 0,this.playerType=void 0,this.videoPlayer=void 0}},{key:"setPlayerWithType",value:function(e,t){VizbeeTV.logger.debug("VirtualAudio::setPlayerWithType - playerType = ",e,", playerInstance = ",t),e?t?(this.playerType=e,this.playerType==O?this.videoPlayer=t.bitmovinPlayer:this.playerType==z?this.videoPlayer=t.playerElement:this.playerType==R?this.videoPlayer=t.shakaPlayer:this.videoPlayer=t,this._setAudioInstance()):VizbeeTV.logger.warn("VirtualAudio::setPlayerWithType - invalid parameter 'videoPlayer'"):VizbeeTV.logger.warn("VirtualAudio::setPlayerWithType - invalid parameter 'playerType'")}},{key:"getPlayer",value:function(){return this.videoPlayer}},{key:"_setAudioInstance",value:function(){this.playerType&&this.videoPlayer&&(VizbeeTV.logger.debug("VirtualAudio::_setAudioInstance - playerType = ",this.playerType),VizbeeTV.logger.debug("VirtualAudio::_setAudioInstance - videoPlayer = ",this.videoPlayer),this.audioInstance=Ae.getInstance(this.playerType),this.audioInstance&&(VizbeeTV.logger.debug("VirtualAudio::_setAudioInstance - setting audio instance"),this.audioInstance.init(),this.audioInstance.setPlayer(this.videoPlayer)))}},{key:"isReady",value:function(){return!!this.audioInstance}},{key:"getTracks",value:function(e){return VizbeeTV.logger.verbose("VirtualAudio::getTracks - trackType = ",e),this.audioInstance?this.audioInstance.getTracks(e):(VizbeeTV.logger.verbose("VirtualAudio::getTracks - sending empty data as there is no valid audio instance"),[])}},{key:"getEnabledTracks",value:function(e){return VizbeeTV.logger.verbose("VirtualAudio::getEnabledTracks - trackType = ",e),this.audioInstance?this.audioInstance.getEnabledTracks(e):(VizbeeTV.logger.verbose("VirtualAudio::getEnabledTracks - sending empty data as there is no valid audio instance"),[])}},{key:"setActiveTrack",value:function(e){this.audioInstance&&this.audioInstance.setActiveTrack(e)}}])}(),De=function(){return s(function e(){o(this,e),this.adPodStartedTimeInMs=0,this.adPodEndedTimeInMs=0,this.loadReceivedByAppTimeInMs=0,this.loadReceivedByPlayerTimeInMs=0,this.metadataLoadedTimeInMs=0,this.playerReadyToPlayTimeInMs=0,this.playbackStartedTimeInMs=0},[{key:"toJSON",value:function(){return{adPodStartedTimeInMs:this._adPodStartedTimeInMs,adPodEndedTimeInMs:this._adPodEndedTimeInMs,loadReceivedByAppTimeInMs:this._loadReceivedByAppTimeInMs,loadReceivedByPlayerTimeInMs:this._loadReceivedByPlayerTimeInMs,metadataLoadedTimeInMs:this._metadataLoadedTimeInMs,playerReadyToPlayTimeInMs:this._playerReadyToPlayTimeInMs,playbackStartedTimeInMs:this._playbackStartedTimeInMs}}},{key:"fromJSON",value:function(e){e&&(e.adPodStartedTimeInMs&&(this.adPodStartedTimeInMs=e.adPodStartedTimeInMs),e.adPodEndedTimeInMs&&(this.adPodEndedTimeInMs=e.adPodEndedTimeInMs),e.loadReceivedByAppTimeInMs&&(this.loadReceivedByAppTimeInMs=e.loadReceivedByAppTimeInMs),e.loadReceivedByPlayerTimeInMs&&(this.loadReceivedByPlayerTimeInMs=e.loadReceivedByPlayerTimeInMs),e.metadataLoadedTimeInMs&&(this.metadataLoadedTimeInMs=e.metadataLoadedTimeInMs),e.playerReadyToPlayTimeInMs&&(this.playerReadyToPlayTimeInMs=e.playerReadyToPlayTimeInMs),e.playbackStartedTimeInMs&&(this.playbackStartedTimeInMs=e.playbackStartedTimeInMs))}},{key:"reset",value:function(){this.adPodStartedTimeInMs=0,this.adPodEndedTimeInMs=0,this.loadReceivedByAppTimeInMs=0,this.loadReceivedByPlayerTimeInMs=0,this.metadataLoadedTimeInMs=0,this.playerReadyToPlayTimeInMs=0,this.playbackStartedTimeInMs=0}},{key:"adPodStartedTimeInMs",get:function(){return this._adPodStartedTimeInMs},set:function(e){this._adPodStartedTimeInMs=e}},{key:"adPodEndedTimeInMs",get:function(){return this._adPodEndedTimeInMs},set:function(e){this._adPodEndedTimeInMs=e}},{key:"loadReceivedByAppTimeInMs",get:function(){return this._loadReceivedByAppTimeInMs},set:function(e){this._loadReceivedByAppTimeInMs=e}},{key:"loadReceivedByPlayerTimeInMs",get:function(){return this._loadReceivedByPlayerTimeInMs},set:function(e){this._loadReceivedByPlayerTimeInMs=e}},{key:"metadataLoadedTimeInMs",get:function(){return this._metadataLoadedTimeInMs},set:function(e){this._metadataLoadedTimeInMs=e}},{key:"playerReadyToPlayTimeInMs",get:function(){return this._playerReadyToPlayTimeInMs},set:function(e){this._playerReadyToPlayTimeInMs=e}},{key:"playbackStartedTimeInMs",get:function(){return this._playbackStartedTimeInMs},set:function(e){this._playbackStartedTimeInMs=e}}])}(),we=function(){return s(function e(t){if(o(this,e),VizbeeTV.logger.debug("BasePlayer::constructor() platform =",t),"BasePlayer"===this.constructor.name)throw new TypeError("BasePlayer::constructor() -- Abstract class.");if(!(t&&t instanceof K))throw new Error("BasePlayer::constructor() -- platform cannot be empty or invalid.");this.playerState={IDLE:"idle",PREPARING:"preparing",LOADING:"loading",STARTED:"started",PLAYING:"playing",PAUSED:"paused",BUFFERING:"buffering",INTERRUPTED:"interrupted",ENDED:"ended",ERROR:"error"},this.currentState=this.playerState.IDLE,this.platform=t,this.platformConfig=t.config,this.videoInfo={},this.hlsxchange=!0,this.currentSrc="",this.startVideoTimestampInMS=0,this.onStartedTimestampInMS=0,this.resetListeners(),this.subtitlesDelegate=new Ie,this.audioDelegate=new Ce,this.streamQualityInfo=new De},[{key:"reconstruct",value:function(e){}},{key:"enableHLSExchange",set:function(e){this.hlsxchange=e}},{key:"onLoading",set:function(e){"function"==typeof e&&this._loadingListeners.push(e)}},{key:"dispatchOnLoading",value:function(){this.currentState=this.playerState.LOADING;for(var e=this._loadingListeners.length-1;e>-1;e--)if(this._loadingListeners[e]())return}},{key:"onStarted",set:function(e){"function"==typeof e&&this._startedListeners.push(e)}},{key:"dispatchOnStarted",value:function(){this.onStartedTimestampInMS=(new Date).getTime(),this.currentState=this.playerState.STARTED;for(var e=this._startedListeners.length-1;e>-1;e--)if(this._startedListeners[e]())return}},{key:"onPlaying",set:function(e){"function"==typeof e&&this._playingListeners.push(e)}},{key:"dispatchOnPlaying",value:function(){this.currentState=this.playerState.PLAYING;for(var e=this._playingListeners.length-1;e>-1;e--)if(this._playingListeners[e]())return}},{key:"onPaused",set:function(e){"function"==typeof e&&this._pausedListeners.push(e)}},{key:"dispatchOnPaused",value:function(){this.currentState=this.playerState.PAUSED;for(var e=this._pausedListeners.length-1;e>-1;e--)if(this._pausedListeners[e]())return}},{key:"onTimeUpdate",set:function(e){"function"==typeof e&&this._timeupdateListeners.push(e)}},{key:"dispatchOnTimeUpdate",value:function(e){this.currentState=this.playerState.PLAYING;for(var t=this._timeupdateListeners.length-1;t>-1;t--)if(this._timeupdateListeners[t](e))return}},{key:"onBuffering",set:function(e){"function"==typeof e&&this._bufferingListeners.push(e)}},{key:"dispatchOnBuffering",value:function(e){this.currentState=this.playerState.BUFFERING;for(var t=this._bufferingListeners.length-1;t>-1;t--)if(this._bufferingListeners[t](e))return}},{key:"onBufferingComplete",set:function(e){"function"==typeof e&&this._bufferingCompleteListeners.push(e)}},{key:"dispatchOnBufferingComplete",value:function(e){for(var t=this._bufferingCompleteListeners.length-1;t>-1;t--)if(this._bufferingCompleteListeners[t](e))return}},{key:"onEnded",set:function(e){"function"==typeof e&&this._endedListeners.push(e)}},{key:"dispatchOnEnded",value:function(){VizbeeTV.logger.info(this.constructor.name+"::dispatchOnEnded ["+this.currentState+"] sending ended"),this.currentState=this.playerState.ENDED;for(var e=this._endedListeners.length-1;e>-1;e--)if(this._endedListeners[e]())return;this.currentState=this.playerState.IDLE}},{key:"onInterrupted",set:function(e){"function"==typeof e&&this._interruptedListeners.push(e)}},{key:"dispatchOnInterrupted",value:function(e){if(!this._canBeInterrupted())return VizbeeTV.logger.warn(this.constructor.name+"::dispatchOnInterrupted ["+this.currentState+"] tried to send interrupted in wrong state ",e),!1;VizbeeTV.logger.info(this.constructor.name+"::dispatchOnInterrupted ["+this.currentState+"] sending interrupted ",e),this.currentState=this.playerState.INTERRUPTED;for(var t=this._interruptedListeners.length-1;t>-1;t--)if(this._interruptedListeners[t](e))return;return this.currentState=this.playerState.IDLE,!0}},{key:"_canBeInterrupted",value:function(){return this.currentState==this.playerState.STARTED||this.currentState==this.playerState.PLAYING||this.currentState==this.playerState.PAUSED||this.currentState==this.playerState.BUFFERING}},{key:"onError",set:function(e){"function"==typeof e&&this._errorListeners.push(e)}},{key:"dispatchOnError",value:function(e){if(!this._canBeErrored())return VizbeeTV.logger.warn(this.constructor.name+"::dispatchOnError ["+this.currentState+"] tried to send error in wrong state ",e),!1;VizbeeTV.logger.info(this.constructor.name+"::dispatchOnError ["+this.currentState+"] sending error ",e),this.currentState=this.playerState.ERROR;for(var t=this._errorListeners.length-1;t>-1;t--)if(this._errorListeners[t](e))return;return this.currentState=this.playerState.IDLE,!0}},{key:"_canBeErrored",value:function(){return this.currentState!=this.playerState.IDLE}},{key:"onEvent",set:function(e){"function"==typeof e&&this._eventListeners.push(e)}},{key:"dispatchOnEvent",value:function(e){for(var t=this._eventListeners.length-1;t>-1;t--)if(this._eventListeners[t](e))return}},{key:"resetListeners",value:function(){this._startedListeners=[],this._loadingListeners=[],this._playingListeners=[],this._pausedListeners=[],this._timeupdateListeners=[],this._bufferingListeners=[],this._bufferingCompleteListeners=[],this._endedListeners=[],this._interruptedListeners=[],this._errorListeners=[],this._eventListeners=[]}},{key:"start",value:function(e){VizbeeTV.logger.debug(this.constructor.name+"::Start() BEGINNING - CURRENT_PLAYER_STATE -- ",this.currentState),this.videoInfo=e,this.currentState=this.playerState.PREPARING,this.startVideoTimestampInMS=(new Date).getTime(),this.subtitlesDelegate.init();var t=this.getPlayerType();this.subtitlesDelegate.setPlayerWithType(t,this);var n=this.getSubtitleTypeFromVideoInfo(e);this.subtitlesDelegate.setSubtitleType(n),this.audioDelegate.init(),this.audioDelegate.setPlayerWithType(t,this),VizbeeTV.logger.debug(this.constructor.name+"::Start() ENDING - CURRENT_PLAYER_STATE -- ",this.currentState)}},{key:"play",value:function(){throw new TypeError(this.constructor.name+"::play() - Abstract method.")}},{key:"pause",value:function(){throw new TypeError(this.constructor.name+"::pause() - Abstract method.")}},{key:"togglePlayPause",value:function(){throw new TypeError(this.constructor.name+"::togglePlayPause() - Abstract method.")}},{key:"seek",value:function(e){throw new TypeError(this.constructor.name+"::seek() - Abstract method.")}},{key:"stop",value:function(e){throw new TypeError(this.constructor.name+"::stop() - Abstract method.")}},{key:"currentTime",value:function(){throw new TypeError(this.constructor.name+"::currentTime() - Abstract method.")}},{key:"getDuration",value:function(){throw new TypeError(this.constructor.name+"::getDuration() - Abstract method.")}},{key:"getStartTime",value:function(){return this.startVideoTimestampInMS>0&&this.onStartedTimestampInMS>this.startVideoTimestampInMS?this.onStartedTimestampInMS-this.startVideoTimestampInMS:0}},{key:"getBufferLevel",value:function(){return{current:0,target:0}}},{key:"getAudioBufferLevel",value:function(){return{current:0,target:0,didDetectSeparateAudio:!1}}},{key:"getCurrentState",value:function(){return this.currentState}},{key:"getName",value:function(){return this.constructor.name}},{key:"getPlayerType",value:function(){var e=void 0,t=this.getName().toLowerCase();return-1!=t.indexOf("bitmovin")?e=O:-1!=t.indexOf("videojs")?e=z:-1!=t.indexOf("theo")?e=L:-1!=t.indexOf("shaka")?e=R:-1!=t.indexOf("avplayer")&&(e="avplayer"),e}},{key:"getCurrentVersion",value:function(){return""}},{key:"getHlsxchangeUrl",value:function(){return this.hlsxchange&&(this.videoInfo.src.lastIndexOf(".m3u8")>=0||this.videoInfo.src.lastIndexOf("m3u")>=0)?se.xchangeHLSUrl(this.videoInfo.src,this.videoInfo.appID,this.platform.cloudPlatformName,this.videoInfo.minBitrate,this.videoInfo.maxBitrate,1):this.videoInfo.src}},{key:"getAppVideoStartErrorInfo",value:function(e,t){var n,i;if(this.videoInfo&&this.videoInfo.videourl&&-1!=this.videoInfo.videourl.indexOf("start_video_failure")){var r=se.getUrlVars(this.videoInfo.videourl);n=r.errorCode,i=r.errorReason}return n&&i?{errorCode:n,errorReason:i}:{errorCode:e,errorReason:t}}},{key:"buildErrorEvent",value:function(e,t,n){return{player:this.constructor.name,code:e,reason:t,data:n}}},{key:"doAction",value:function(e){}},{key:"reset",value:function(){this.resetListeners()}},{key:"destroy",value:function(){this.resetListeners()}},{key:"getTracks",value:function(e){return e==M?this.subtitlesDelegate&&this.subtitlesDelegate.isReady()?this.subtitlesDelegate.getTracks(e):[]:e==x&&this.audioDelegate&&this.audioDelegate.isReady()?this.audioDelegate.getTracks(e):[]}},{key:"getEnabledTracks",value:function(e){return e==M?this.subtitlesDelegate&&this.subtitlesDelegate.isReady()?this.subtitlesDelegate.getEnabledTracks(e):[]:e==x&&this.audioDelegate&&this.audioDelegate.isReady()?this.audioDelegate.getEnabledTracks(e):[]}},{key:"getSubtitleTypeFromVideoInfo",value:function(e){return"any"}},{key:"enableTracks",value:function(e){this.subtitlesDelegate.isReady()&&this.subtitlesDelegate.enableTracks(e)}},{key:"disableTracks",value:function(e){this.subtitlesDelegate.isReady()&&this.subtitlesDelegate.disableTracks(e)}},{key:"changeAudioTrack",value:function(e){this.audioDelegate.isReady()?this.audioDelegate.setActiveTrack(e):VizbeeTV.logger.warn(this.constructor.name+"::changeAudioTrack - audio delegate is not ready")}},{key:"getStreamQualityInfo",value:function(){return this.streamQualityInfo&&this.streamQualityInfo.toJSON()}},{key:"setStreamQualityInfo",value:function(e){this.streamQualityInfo&&this.streamQualityInfo.fromJSON(e)}},{key:"resetStreamQualityInfo",value:function(){this.streamQualityInfo&&this.streamQualityInfo.reset()}},{key:"setTracks",value:function(e){}},{key:"getCurrentTrack",value:function(){var e,t=this;return this.videoInfo.tracks&&this.videoInfo.tracks.length>0&&isFinite(this.videoInfo.activeTrackId)&&(e=this.videoInfo.tracks.find(function(e){return t.videoInfo.activeTrackId==e.trackId})),e}}])}(),Ne=function(){function e(t){var n;return o(this,e),(n=r(this,e,[t]))._positionMs=-1,n._durationMs=-1,n}return p(e,we),s(e,[{key:"setPositionMs",value:function(e){this._positionMs="number"==typeof e&&e>=0?e:-1}},{key:"setDurationMs",value:function(e){this._durationMs="number"==typeof e&&e>=0?e:-1}},{key:"currentTime",value:function(){return this._positionMs>=0?this._positionMs/1e3:0}},{key:"getDuration",value:function(){return this._durationMs>=0?this._durationMs/1e3:0}},{key:"getStartTime",value:function(){return 0}},{key:"dispatchOnTimeUpdate",value:function(e){for(var t=this._timeupdateListeners.length-1;t>-1;t--)if(this._timeupdateListeners[t](e))return}},{key:"_canBeInterrupted",value:function(){return!0}},{key:"_canBeErrored",value:function(){return!0}},{key:"start",value:function(e){this.videoInfo=e||{},this.currentState=this.playerState.PREPARING}},{key:"play",value:function(){}},{key:"pause",value:function(){}},{key:"togglePlayPause",value:function(){}},{key:"seek",value:function(){}},{key:"stop",value:function(){}},{key:"setTracks",value:function(){}},{key:"getTracks",value:function(){return[]}},{key:"getEnabledTracks",value:function(){return[]}},{key:"enableTracks",value:function(){}},{key:"disableTracks",value:function(){}},{key:"changeAudioTrack",value:function(){}},{key:"wrapAVPlayerListener",value:function(e){return e}},{key:"getName",value:function(){return this.platformConfig&&this.platformConfig.playerType||"VirtualPlayer"}},{key:"getCurrentVersion",value:function(){return""}},{key:"destroy",value:function(){b(e,"destroy",this)([]),this._positionMs=-1,this._durationMs=-1}}])}(),Me=null,xe=function(){function e(){return o(this,e),r(this,e,arguments)}return p(e,we),s(e,[{key:"extend",value:function(){throw new TypeError("BasePlayerExtensible::extend() - Abstract method.")}},{key:"beforeStart",value:function(){throw new TypeError("BasePlayerExtensible::beforeStart() - Abstract method.")}}])}(),Oe=function(){function e(t,n){var i;if(o(this,e),i=r(this,e,[t]),!n)throw ReferenceError("DynamicPlayerSelector::constructor | DefaultPlatformPlayer is not passed.");i.nativePlayerClass=n.nativePlayer,i.htmlPlayerClass=n.htmlPlayer,i.bitmovinPlayerClass=n.bitmovinPlayer,i.modularBitmovinPlayerClass=n.modularBitmovinPlayer,i.videoJSPlayerClass=n.videoJSPlayer,i.theoPlayerPlayerClass=n.theoPlayer,i.shakaPlayerClass=n.shakaPlayer,i.topPlayerClass=n.topPlayer,i.currentPlayer=void 0,i.nativePlayer=void 0,i.htmlPlayer=void 0,i.bitmovinPlayer=void 0,i.modularBitmovinPlayer=void 0,i.videoJSPlayer=void 0,i.theoPlayer=void 0,i.shakaPlayer=void 0,i.topPlayer=void 0,VizbeeTV.logger.info("DynamicPlayerSelector::constructor - creating and selecting player");var a=t.config.vtvPlayerListConfig||[{type:"native"}];return a.forEach(function(e){i._createPlayer(e)}),i._selectPlayer(a[0]),i}return p(e,xe),s(e,[{key:"reconstruct",value:function(e){var t=this;VizbeeTV.logger.info("DynamicPlayerSelector::reconstruct - newPlatformConfig",e),this.platform.config=e,e.standalone&&this._destroyAllPlayers();var n=[{type:"native"}];n=!e.vtvPlayerListConfig||te.isArray(e.vtvPlayerListConfig)&&0==e.vtvPlayerListConfig.length?[{type:"native"}]:e.vtvPlayerListConfig,VizbeeTV.logger.info("DynamicPlayerSelector::reconstruct - updated vtvPlayerListConfig",n),VizbeeTV.logger.info("DynamicPlayerSelector::reconstruct - creating and selecting player"),n.forEach(function(e){t._createPlayer(e)}),this._selectPlayer(n[0])}},{key:"_destroyAllPlayers",value:function(){VizbeeTV.logger.info("DynamicPlayerSelector::_destroyAllPlayers - destroying all players"),this.nativePlayer&&(this.nativePlayer.destroy(),this.nativePlayer=void 0),this.htmlPlayer&&(this.htmlPlayer.destroy(),this.htmlPlayer=void 0),this.bitmovinPlayer&&(this.bitmovinPlayer.destroy(),this.bitmovinPlayer=void 0),this.modularBitmovinPlayer&&(this.modularBitmovinPlayer.destroy(),this.modularBitmovinPlayer=void 0),this.videoJSPlayer&&(this.videoJSPlayer.destroy(),this.videoJSPlayer=void 0),this.theoPlayer&&(this.theoPlayer.destroy(),this.theoPlayer=void 0),this.shakaPlayer&&(this.shakaPlayer.destroy(),this.shakaPlayer=void 0),this.topPlayer&&(this.topPlayer.destroy(),this.topPlayer=void 0),this.currentPlayer=void 0}},{key:"_createPlayer",value:function(e){switch(e&&e.type){case"top":null==this.topPlayer?(VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - CREATING Top Player"),this.topPlayer=new this.topPlayerClass(this.platform)):VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - ALREADY CREATED Top Player");break;case"bitmovin":"modular"==e.subtype&&this.modularBitmovinPlayerClass?null==this.modularBitmovinPlayer?(VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - CREATING Modular Bitmovin Player"),this.modularBitmovinPlayer=new this.modularBitmovinPlayerClass(this.platform)):VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - ALREADY CREATED Modular Bitmovin Player"):null==this.bitmovinPlayer?(VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - CREATING Static Bitmovin Player"),this.bitmovinPlayer=new this.bitmovinPlayerClass(this.platform)):VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - ALREADY CREATED Static Bitmovin Player");break;case"videojs":null==this.videoJSPlayer?(VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - CREATING VideoJS Player"),this.videoJSPlayer=new this.videoJSPlayerClass(this.platform)):VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - ALREADY CREATED VideoJS Player");break;case"theo":null==this.theoPlayer?(VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - CREATING THEO Player"),this.theoPlayer=new this.theoPlayerPlayerClass(this.platform)):VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - ALREADY CREATED THEO Player");break;case"shaka":null==this.shakaPlayer?(VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - CREATING Shaka Player"),this.shakaPlayer=new this.shakaPlayerClass(this.platform)):VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - ALREADY CREATED Shaka Player");break;case"html":null==this.htmlPlayer?(VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - CREATING HTML Player"),this.htmlPlayer=new this.htmlPlayerClass(this.platform)):VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - ALREADY CREATED HTML Player");break;default:null==this.nativePlayer?(VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - CREATING Native Player"),this.nativePlayer=new this.nativePlayerClass(this.platform)):VizbeeTV.logger.info("DynamicPlayerSelector::_createPlayer - ALREADY CREATED Native Player")}}},{key:"_selectPlayer",value:function(e){if(e&&e.type)switch(e.type){case"top":VizbeeTV.logger.info("DynamicPlayerSelector::_selectPlayer - SELECTING Top Player"),this._preparePlayer(this.topPlayer);break;case"bitmovin":VizbeeTV.logger.info("DynamicPlayerSelector::_selectPlayer - SELECTING Bitmovin Player"),"modular"==e.subtype?this._preparePlayer(this.modularBitmovinPlayer):this._preparePlayer(this.bitmovinPlayer);break;case"videojs":VizbeeTV.logger.info("DynamicPlayerSelector::_selectPlayer - SELECTING VideoJS Player"),this._preparePlayer(this.videoJSPlayer);break;case"theo":VizbeeTV.logger.info("DynamicPlayerSelector::_selectPlayer - SELECTING THEO Player"),this._preparePlayer(this.theoPlayer);break;case"shaka":VizbeeTV.logger.info("DynamicPlayerSelector::_selectPlayer - SELECTING Shaka Player"),this._preparePlayer(this.shakaPlayer);break;case"html":VizbeeTV.logger.info("DynamicPlayerSelector::_selectPlayer - SELECTING HTML Player"),this._preparePlayer(this.htmlPlayer);break;default:VizbeeTV.logger.info("DynamicPlayerSelector::_selectPlayer - SELECTING Native Player"),this._preparePlayer(this.nativePlayer)}else null==this.currentPlayer?(VizbeeTV.logger.info("DynamicPlayerSelector::_selectPlayer - DEFAULTING to native player"),this._preparePlayer(this.nativePlayer)):VizbeeTV.logger.info("DynamicPlayerSelector::_selectPlayer - REUSING current player")}},{key:"_preparePlayer",value:function(e){e?this.currentPlayer&&this.currentPlayer.constructor.name==e.constructor.name?VizbeeTV.logger.info("DynamicPlayerSelector::_preparePlayer - NO CHANGE to already prepared player"):(VizbeeTV.logger.info("DynamicPlayerSelector::_preparePlayer - CHANGING player listeners"),this.currentPlayer&&this.currentPlayer.constructor.name!=e.constructor.name&&this._removePlayerListeners(this.currentPlayer),this.currentPlayer=e,this._addPlayerListeners(this.currentPlayer)):VizbeeTV.logger.info("DynamicPlayerSelector::_preparePlayer - INVALID player argument")}},{key:"beforeStart",value:function(t){b(e,"start",this)([t])}},{key:"start",value:function(e){this.beforeStart(e),VizbeeTV.logger.info("START TIME TRACKING [DynamicPlayerSelector Start Video] - player="+this.currentPlayer.constructor.name,e),VizbeeTV.logger.info("DynamicPlayerSelector::_start - current player="+this.currentPlayer.constructor.name),e.vtvPlayerConfig&&(VizbeeTV.logger.info("DynamicPlayerSelector::_start - playerType="+e.vtvPlayerConfig.type),this._createPlayer(e.vtvPlayerConfig),this._selectPlayer(e.vtvPlayerConfig)),this.currentPlayer.enableHLSExchange=e.useHLSExchange,this.currentPlayer.start(e)}},{key:"play",value:function(){this.currentPlayer&&this.currentPlayer.play()}},{key:"pause",value:function(){this.currentPlayer&&this.currentPlayer.pause()}},{key:"togglePlayPause",value:function(){this.currentPlayer&&this.currentPlayer.togglePlayPause()}},{key:"stop",value:function(e){this.currentPlayer&&this.currentPlayer.stop(e)}},{key:"seek",value:function(e){this.currentPlayer&&this.currentPlayer.seek(e)}},{key:"currentTime",value:function(){return this.currentPlayer?this.currentPlayer.currentTime():-1}},{key:"getDuration",value:function(){return this.currentPlayer?this.currentPlayer.getDuration():-1}},{key:"getStartTime",value:function(){return this.currentPlayer?this.currentPlayer.getStartTime():-1}},{key:"getBufferLevel",value:function(){return this.currentPlayer?this.currentPlayer.getBufferLevel():{current:0,target:0}}},{key:"getAudioBufferLevel",value:function(){return this.currentPlayer?this.currentPlayer.getAudioBufferLevel():{current:0,target:0,didDetectSeparateAudio:!1}}},{key:"getCurrentState",value:function(){return this.currentPlayer?this.currentPlayer.getCurrentState():"IDLE"}},{key:"setTracks",value:function(e){if(this.currentPlayer)return this.currentPlayer.setTracks(e)}},{key:"getTracks",value:function(e){return this.currentPlayer?this.currentPlayer.getTracks(e):[]}},{key:"getEnabledTracks",value:function(e){return this.currentPlayer?this.currentPlayer.getEnabledTracks(e):[]}},{key:"enableTracks",value:function(e){this.currentPlayer&&this.currentPlayer.enableTracks(e)}},{key:"disableTracks",value:function(e){this.currentPlayer&&this.currentPlayer.disableTracks(e)}},{key:"changeAudioTrack",value:function(e){this.currentPlayer&&this.currentPlayer.changeAudioTrack(e)}},{key:"getStreamQualityInfo",value:function(){return this.currentPlayer?this.currentPlayer.getStreamQualityInfo():{}}},{key:"setStreamQualityInfo",value:function(e){this.currentPlayer&&this.currentPlayer.setStreamQualityInfo(e)}},{key:"resetStreamQualityInfo",value:function(){this.currentPlayer&&this.currentPlayer.resetStreamQualityInfo()}},{key:"getName",value:function(){return this.currentPlayer.getName()}},{key:"getCurrentVersion",value:function(){return this.currentPlayer.getCurrentVersion()}},{key:"doAction",value:function(e){return this.currentPlayer.doAction(e)}},{key:"wrapAVPlayerListener",value:function(e){return this.currentPlayer.wrapAVPlayerListener(e)}},{key:"destroy",value:function(){b(e,"destroy",this)([]),this._destroyAllPlayers()}},{key:"_addPlayerListeners",value:function(e){var t=this;e.onLoading=function(e){t.dispatchOnLoading.call(t,e)},e.onStarted=function(e){t.dispatchOnStarted.call(t,e)},e.onPlaying=function(e){t.dispatchOnPlaying.call(t,e)},e.onPaused=function(e){t.dispatchOnPaused.call(t,e)},e.onBuffering=function(e){t.dispatchOnBuffering.call(t,e)},e.onBufferingComplete=function(e){t.dispatchOnBufferingComplete.call(t,e)},e.onTimeUpdate=function(e){t.dispatchOnTimeUpdate.call(t,e)},e.onInterrupted=function(e){t.dispatchOnInterrupted.call(t,e)},e.onEnded=function(e){t.dispatchOnEnded.call(t,e)},e.onError=function(e){t.dispatchOnError.call(t,e)},e.onEvent=function(e){t.dispatchOnEvent.call(t,e)}}},{key:"_removePlayerListeners",value:function(e){e.resetListeners()}}])}(),ze=function(){function e(t){var n;return o(this,e),(n=r(this,e,[t])).deviceId=new fe,n.launchParams=new he,n.xboxAdId=new ge,n._xboxInfo=new Se,n._xboxNetworkInfo=new ke,n.xboxAppLifeCycleManager=new me,n._setXboxLifeCyleHooks(),n.xboxAppLifeCycleManager.init(),n}return p(e,K),s(e,[{key:"createPlayer",value:function(){var e={nativePlayer:Ne,htmlPlayer:Ne,bitmovinPlayer:Me,modularBitmovinPlayer:Me,videoJSPlayer:null,theoPlayer:null,shakaPlayer:null,topPlayer:null};return this.player=new Oe(this,e),VizbeeTV.logger.d("Xbox","createPlayer","created html player instance"),this.player}},{key:"createInputDevice",value:function(){return this.inputDevice=new le(this),this.inputDevice}},{key:"exit",value:function(){b(e,"exit",this)([]),setTimeout(function(){VizbeeTV.logger.i("Xbox","exit","exiting the app"),window.close()},1e3)}},{key:"_setXboxLifeCyleHooks",value:function(){var e=this;this.xboxAppLifeCycleManager.addHandler("onStart",function(t){VizbeeTV.logger.i("Xbox","_setXboxLifeCyleHooks","rawDialParams = ",t),e.launchParams.setLaunchParams(t)})}},{key:"defaultAppletAppId",get:function(){return"vzb0000000"}},{key:"cloudPlatformName",get:function(){return"xbox_one"}},{key:"adId",get:function(){return this.xboxAdId.adId()}},{key:"isAdTrackingDisabled",get:function(){return this.xboxAdId.isAdTrackingDisabled()}},{key:"appLifeCycleManager",get:function(){return this.xboxAppLifeCycleManager}},{key:"deviceInfo",get:function(){return this._xboxInfo}},{key:"networkInfo",get:function(){return this._xboxNetworkInfo}}])}(),Le=function(){function e(){return o(this,e),r(this,e)}return p(e,de),s(e,[{key:"uniqueDeviceID",value:function(e,t){var n="UNKNOWN_DEVICE_ID";try{var i=window.vizbeeXboxHost;i&&i.deviceId?n=i.deviceId:VizbeeTV.logger.w("XboxWebView2DeviceID","uniqueDeviceID","vizbeeXboxHost.deviceId missing, using fallback"),e(n)}catch(t){VizbeeTV.logger.e("XboxWebView2DeviceID","uniqueDeviceID","error reading host bridge",t),e(n)}}}])}(),Re=function(){function e(){var t;o(this,e),(t=r(this,e))._params=void 0,t.asyncFunction=void 0;var n="undefined"!=typeof window&&window.vizbeeXboxHost||{};return t._parseAndSet(n.launchParams),t._listenForLaunchParamsChanges(),t}return p(e,pe),s(e,[{key:"_listenForLaunchParamsChanges",value:function(){var e=this;"undefined"!=typeof window&&window.chrome&&window.chrome.webview&&"function"==typeof window.chrome.webview.addEventListener&&window.chrome.webview.addEventListener("message",function(t){var n=t&&t.data;n&&"vizbeeXboxHost"===n.source&&"launchParamsChanged"===n.event&&(VizbeeTV.logger.i("XboxWebView2LaunchParams","_listenForLaunchParamsChanges","received launchParamsChanged",n.launchParams),e.setLaunchParams(n.launchParams))})}},{key:"isLaunchedbyVizbee",value:function(){var e=this.getLaunchParams();return e?(VizbeeTV.logger.d("XboxWebView2LaunchParams","isLaunchedbyVizbee","params present",e),!0):(VizbeeTV.logger.d("XboxWebView2LaunchParams","isLaunchedbyVizbee","params not present"),!1)}},{key:"getLaunchParams",value:function(){return this._params}},{key:"getLaunchParamsAsync",value:function(e){if("function"!=typeof e)throw new TypeError("XboxWebView2LaunchParams::getLaunchParamsAsync : Argument supplied is not of type function");this.asyncFunction=e,this._params&&this.asyncFunction(this._params)}},{key:"setLaunchParams",value:function(e){VizbeeTV.logger.i("XboxWebView2LaunchParams","setLaunchParams","rawParamData = ",e),this._params=void 0,this._parseAndSet(e),this.asyncFunction&&this._params&&this.asyncFunction(this._params)}},{key:"_parseAndSet",value:function(e){if(e&&"string"==typeof e){var t=e,n=e.indexOf("?");if(n>=0&&(t=e.substring(n+1)),t){var i=t.split("&").reduce(function(e,t){var n=m(t.split("="),2),i=n[0],r=n[1];return i&&(e[i]=null!=r?decodeURIComponent(r):""),e},{});Object.keys(i).length>0&&(this._params=i)}}}}])}(),Ke=function(){function e(){return o(this,e),r(this,e)}return p(e,ve),s(e,[{key:"adId",value:function(){return("undefined"!=typeof window&&window.vizbeeXboxHost||{}).advertisingId||""}},{key:"isAdTrackingDisabled",value:function(){var e="undefined"!=typeof window&&window.vizbeeXboxHost||{};return"boolean"==typeof e.isAdTrackingDisabled?e.isAdTrackingDisabled:this.adId().length<=0}}])}(),Ue=function(){function e(){var t;return o(this,e),(t=r(this,e))._host="undefined"!=typeof window&&window.vizbeeXboxHost||{},t}return p(e,be),s(e,[{key:"deviceId",get:function(){return this._host.internalDeviceId||C}},{key:"make",get:function(){return this._host.make||C}},{key:"model",get:function(){return this._host.model||C}},{key:"friendlyName",get:function(){return this._host.friendlyName||C}}])}(),Fe=function(){function e(){return o(this,e),r(this,e)}return p(e,_e),s(e,[{key:"internalIP",get:function(){return("undefined"!=typeof window&&window.vizbeeXboxHost||{}).internalIP||C}}])}(),Be=function(){function e(){var t;return o(this,e),(t=r(this,e))._eventVsHandlerMap={activated:D,suspending:N,resuming:w},t}return p(e,ye),s(e,[{key:"init",value:function(){"undefined"!=typeof window&&window.chrome&&window.chrome.webview&&"function"==typeof window.chrome.webview.addEventListener?this._listen():VizbeeTV.logger.w("XboxWebView2AppLifeCycleManager","init","window.chrome.webview not available, lifecycle events will not fire")}},{key:"_listen",value:function(){var e=this;window.chrome.webview.addEventListener("message",function(t){var n=t&&t.data;if(n&&"vizbeeXboxHost"===n.source&&n.event){var i=n.event,r=e._eventVsHandlerMap[i];VizbeeTV.logger.d("XboxWebView2AppLifeCycleManager","_listen","got event = "+i),r&&e.eventMap[r]&&e.eventMap[r].length&&e.eventMap[r].forEach(function(e){e.apply({},[n])})}})}}])}(),He=function(){function e(t){var n;return o(this,e),(n=r(this,e,[t])).deviceId=new Le,n.launchParams=new Re,n.xboxAdId=new Ke,n._xboxInfo=new Ue,n._xboxNetworkInfo=new Fe,n.xboxAppLifeCycleManager=new Be,n.xboxAppLifeCycleManager.init(),n}return p(e,K),s(e,[{key:"createPlayer",value:function(){var e={nativePlayer:Ne,htmlPlayer:Ne,bitmovinPlayer:Me,modularBitmovinPlayer:Me,videoJSPlayer:null,theoPlayer:null,shakaPlayer:null,topPlayer:null};return this.player=new Oe(this,e),VizbeeTV.logger.d("XboxWebView2","createPlayer","created html player instance"),this.player}},{key:"createInputDevice",value:function(){return this.inputDevice=new le(this),this.inputDevice}},{key:"exit",value:function(){b(e,"exit",this)([]),setTimeout(function(){VizbeeTV.logger.i("XboxWebView2","exit","exiting the app");try{if(window.chrome&&window.chrome.webview&&"function"==typeof window.chrome.webview.postMessage)return void window.chrome.webview.postMessage("EXIT_APP")}catch(e){VizbeeTV.logger.e("XboxWebView2","exit","error posting EXIT_APP",e)}window.close()},1e3)}},{key:"defaultAppletAppId",get:function(){return"vzb0000000"}},{key:"cloudPlatformName",get:function(){return"xbox_one"}},{key:"adId",get:function(){return this.xboxAdId.adId()}},{key:"isAdTrackingDisabled",get:function(){return this.xboxAdId.isAdTrackingDisabled()}},{key:"appLifeCycleManager",get:function(){return this.xboxAppLifeCycleManager}},{key:"deviceInfo",get:function(){return this._xboxInfo}},{key:"networkInfo",get:function(){return this._xboxNetworkInfo}}])}(),Ge={xbox:function(){function e(t){var n;o(this,e),n=r(this,e,[t]);var i=e.getPlatformType().toLowerCase();return n.__platform="xboxwebview2"==i?new He(t):new ze(t),VizbeeTV.logger.i("XboxVirtualPlatform","constructor","selected variant = "+i),n}return p(e,K),s(e,[{key:"cloudPlatformName",get:function(){return this.__platform.cloudPlatformName}},{key:"uniqueDeviceID",value:function(e,t){this.__platform.uniqueDeviceID(e,t)}},{key:"deviceIDAlgorithm",get:function(){return this.__platform.deviceIDAlgorithm},set:function(e){return this.__platform.deviceIDAlgorithm=e}},{key:"platformModel",get:function(){return this.__platform.platformModel}},{key:"deviceInfo",get:function(){return this.__platform.deviceInfo}},{key:"platformVersion",get:function(){return this.__platform.platformVersion}},{key:"networkInfo",get:function(){return this.__platform.networkInfo}},{key:"adId",get:function(){return this.__platform.adId}},{key:"isAdTrackingDisabled",get:function(){return this.__platform.isAdTrackingDisabled}},{key:"createInputDevice",value:function(){return this.__platform.createInputDevice()}},{key:"inputDevice",get:function(){return this.__platform.inputDevice}},{key:"screenSaverEnabled",set:function(e){e=e||!1,void 0!==this.__platform&&this.__platform.enableScreenSaver&&(VizbeeTV.logger.d("XboxVirtualPlatform","screenSaverEnabled","enabled = "+e),this.__platform.enableScreenSaver(e))}},{key:"defaultAppletAppId",get:function(){return this.__platform.defaultAppletAppId}},{key:"launchParamsDeferral",get:function(){return this.__platform.launchParamsDeferral}},{key:"appLifeCycleManager",get:function(){return this.__platform.appLifeCycleManager}},{key:"exit",value:function(){VizbeeTV.logger.d("XboxVirtualPlatform","exit","exiting the application"),void 0!==this.__platform&&this.__platform.exit&&this.__platform.exit()}},{key:"isAppExiting",get:function(){return this.__platform.isAppExiting},set:function(e){this.__platform.isAppExiting=e}},{key:"reset",value:function(){this.__platform&&this.__platform.reset&&this.__platform.reset()}},{key:"createPlayer",value:function(){return this.__platform.createPlayer()}},{key:"player",get:function(){return this.__platform.player},set:function(e){e&&(this.__platform.player=e)}},{key:"destroyPlayer",value:function(){this.__platform.destroyPlayer()}},{key:"enableHLSExchange",set:function(e){this.__platform.enableHLSExchange=e}}],[{key:"getPlatformType",value:function(){return"undefined"!=typeof window&&window.vizbeeXboxHost&&window.chrome&&window.chrome.webview?"XboxWebView2":"Xbox"}}])}()},We=function(){function e(t,n){var i;if(o(this,e),i=r(this,e,[n]),t=t.toLowerCase(),!Ge[t])throw new TypeError("XboxRootVirtualPlatform::constructor() - platform "+t+" does not exist.");return i.__platform=new Ge[t](n),i.player,i.inputDevice,i}return p(e,K),s(e,[{key:"reset",value:function(){Y&&(Y.stop(),VizbeeTV.logger.debug("player reset",Y)),X&&(X.reset(),X=void 0)}},{key:"uniqueDeviceID",value:function(e,t){this.__platform.uniqueDeviceID(e,t)}},{key:"enableHLSExchange",set:function(e){Y.enableHLSExchange=e}},{key:"deviceIDAlgorithm",get:function(){return this.__platform.deviceIDAlgorithm},set:function(e){return this.__platform.deviceIDAlgorithm=e}},{key:"player",get:function(){return void 0===Y&&(Y=this.__platform.createPlayer()),Y},set:function(e){e&&(Y=e)}},{key:"destroyPlayer",value:function(){Y.destroy().then(function(){Y=void 0})}},{key:"inputDevice",get:function(){return void 0===X&&(X=this.__platform.createInputDevice()),X}},{key:"screenSaverEnabled",set:function(e){e=e||!1,void 0!==this.__platform&&this.__platform.enableScreenSaver&&(VizbeeTV.logger.debug("XboxRootVirtualPlatform::screenSaverEnabled = "+e),this.__platform.enableScreenSaver(e))}},{key:"exit",value:function(){void 0!==this.__platform&&this.__platform.exit&&this.__platform.exit()}},{key:"isAppExiting",get:function(){return this.__platform.isAppExiting},set:function(e){this.__platform.isAppExiting=e}},{key:"defaultAppletAppId",get:function(){return this.__platform.defaultAppletAppId}},{key:"cloudPlatformName",get:function(){return this.__platform.cloudPlatformName}},{key:"platformModel",get:function(){return this.__platform.platformModel}},{key:"platformVersion",get:function(){return this.__platform.platformVersion}},{key:"adId",get:function(){return this.__platform.adId}},{key:"isAdTrackingDisabled",get:function(){return this.__platform.isAdTrackingDisabled}},{key:"appLifeCycleManager",get:function(){return this.__platform.appLifeCycleManager}},{key:"launchParamsDeferral",get:function(){return this.__platform.launchParamsDeferral}},{key:"deviceInfo",get:function(){return this.__platform.deviceInfo}},{key:"networkInfo",get:function(){return this.__platform.networkInfo}}],[{key:"getPlatformType",value:function(){return"undefined"!=typeof Windows&&Windows.System&&Windows.System.Profile&&Windows.System.Profile.AnalyticsInfo&&Windows.System.Profile.AnalyticsInfo.versionInfo&&Windows.System.Profile.AnalyticsInfo.versionInfo.deviceFamily&&-1!=Windows.System.Profile.AnalyticsInfo.versionInfo.deviceFamily.toLowerCase().indexOf("xbox")||"undefined"!=typeof window&&window.vizbeeXboxHost&&window.chrome&&window.chrome.webview?"Xbox":void 0}},{key:"detectPlatformWhenReady",value:function(t){t(e.getPlatformType())}}])}(),je=function(){function e(t,n){var i;return o(this,e),(i=r(this,e,[t,n])).setUIStyleConfig("transparent","white","black"),i}return p(e,We),s(e,[{key:"extendPlayer",value:function(e,t){VizbeeTV.logger.debug("ExtendPlayer - ",this.player.constructor.name),this.player=new e(this.player,t)}},{key:"unextendPlayer",value:function(){try{if(this.player.extendedPlayer){var e=this.player.extendedPlayer;this.player.reset(),this.player=e}}catch(e){VizbeeTV.logger.error("Error while unextending Player",e,this.player,this.player.extendedPlayer)}}},{key:"wrapExtension",value:function(e,t){this.extendPlayer(e,t)}},{key:"unwrapExtensionToBasePlayer",value:function(){for(;this.player.extendedPlayer;)this.unextendPlayer();this.player.reset()}},{key:"unwrapExtensionToStandardPlayerControls",value:function(){for(;!(this.player instanceof StandardPlayerControls);)this.unextendPlayer()}},{key:"setUIStyleConfig",value:function(e,t,n){this.config.primaryColor=e||this.config.primaryColor,this.config.secondaryColor=t||this.config.secondaryColor,this.config.tertiaryColor=n||this.config.tertiaryColor}}])}(),qe=function(){return s(function e(){o(this,e),this.currentLevel=this.LEVEL.CRITICAL,this.enableLogging=!0,this.logPrefix=""},[{key:"LEVEL",get:function(){return{CRITICAL:0,ERROR:1,WARN:2,INFO:3,DEBUG:4,VERBOSE:5}}},{key:"setLevel",value:function(e){this.currentLevel=e}},{key:"setPrefix",value:function(e){this.logPrefix=e}},{key:"enable",value:function(){this.enableLogging=!0}},{key:"disable",value:function(){this.enableLogging=!1}},{key:"c",value:function(){var e=this._getLogArguments.apply(this,arguments);e&&this.critical.apply(this,e)}},{key:"critical",value:function(){if(this.shouldLog(this.LEVEL.CRITICAL)){var e=Array.prototype.slice.call(arguments);e=se.convertObjectsToString(e);var t=[this.getCurrentTimeString()+" "+this.logPrefix+" [CRITICAL]:"];Array.prototype.push.apply(t,e),console.error.apply(console,t)}}},{key:"e",value:function(){var e=this._getLogArguments.apply(this,arguments);e&&this.error.apply(this,e)}},{key:"error",value:function(){if(this.shouldLog(this.LEVEL.ERROR)){var e=Array.prototype.slice.call(arguments);e=se.convertObjectsToString(e);var t=[this.getCurrentTimeString()+" "+this.logPrefix+" [ERROR]:"];Array.prototype.push.apply(t,e),console.error.apply(console,t)}}},{key:"w",value:function(){var e=this._getLogArguments.apply(this,arguments);e&&this.warn.apply(this,e)}},{key:"warn",value:function(){if(this.shouldLog(this.LEVEL.WARN)){var e=Array.prototype.slice.call(arguments);e=se.convertObjectsToString(e);var t=[this.getCurrentTimeString()+" "+this.logPrefix+" [WARN]:"];Array.prototype.push.apply(t,e),console.warn.apply(console,t)}}},{key:"i",value:function(){var e=this._getLogArguments.apply(this,arguments);e&&this.info.apply(this,e)}},{key:"info",value:function(){if(this.shouldLog(this.LEVEL.INFO)){var e=Array.prototype.slice.call(arguments);e=se.convertObjectsToString(e);var t=[this.getCurrentTimeString()+" "+this.logPrefix+" [INFO]:"];Array.prototype.push.apply(t,e),console.info.apply(console,t)}}},{key:"d",value:function(){var e=this._getLogArguments.apply(this,arguments);e&&this.debug.apply(this,e)}},{key:"debug",value:function(){if(this.shouldLog(this.LEVEL.DEBUG)){var e=Array.prototype.slice.call(arguments);e=se.convertObjectsToString(e);var t=[this.getCurrentTimeString()+" "+this.logPrefix+" [DEBUG]:"];Array.prototype.push.apply(t,e),console.log.apply(console,t)}}},{key:"v",value:function(){var e=this._getLogArguments.apply(this,arguments);e&&this.verbose.apply(this,e)}},{key:"verbose",value:function(){if(this.shouldLog(this.LEVEL.VERBOSE)){var e=Array.prototype.slice.call(arguments);e=se.convertObjectsToString(e);var t=[this.getCurrentTimeString()+" "+this.logPrefix+" [VERBOSE]:"];Array.prototype.push.apply(t,e),console.log.apply(console,t)}}},{key:"shouldLog",value:function(e){return!!this.enableLogging&&e<=this.currentLevel}},{key:"_getLogArguments",value:function(){var e=Array.prototype.slice.call(arguments);if(e&&e.length>=2){var t=[this._getClassAndMethodNamePrefix(e[0],e[1])],n=Array.prototype.slice.call(arguments,2);return Array.prototype.push.apply(t,n),t}}},{key:"_getClassAndMethodNamePrefix",value:function(e,t){return e&&t?se.padEnd(e+"::",40," ")+se.padEnd(t,30," ")+" - ":""}},{key:"getCurrentTimeString",value:function(){return"["+(new Date).toISOString()+"]"}}],[{key:"enableRemoteLogging",value:function(e,t){window.console.log=window.console.info=window.console.error=window.console.warn=window.console.debug=function(){var n=new XMLHttpRequest;try{var i=Array.prototype.slice.call(arguments);i=se.convertObjectsToString(i);var r=[t];Array.prototype.push.apply(r,i);var o=encodeURIComponent(JSON.stringify({data:r.join(" ")}));n.open("GET",e+o,!0),n.send(null)}catch(e){}}}}])}(),Je=function(){function e(){return o(this,e),r(this,e)}return p(e,qe),s(e,[{key:"critical",value:function(){try{b(e,"critical",this)(arguments);var t=Array.prototype.slice.call(arguments);if(t.length>0){var n=t[t.length-1],i=window.Raven||window.Sentry;this._shouldLogException()&&i&&(te.isObject(n)||te.isString(n))&&i.captureException(n)}}catch(e){}}},{key:"_shouldLogException",value:function(){return!0}}])}();function Ye(){if(Z)return Q;Z=1;var e,t={getItem:function(e){return e&&decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*([^;]*).*$)|^.*$"),"$1"))||null},setItem:function(e,t,n,i,r,o){if(!e||/^(?:expires|max\-age|path|domain|secure)$/i.test(e))return!1;var a="";if(n)switch(n.constructor){case Number:a=n===1/0?"; expires=Fri, 31 Dec 9999 23:59:59 GMT":"; max-age="+n;break;case String:a="; expires="+n;break;case Date:a="; expires="+n.toUTCString()}return document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(t)+a+(r?"; domain="+r:"")+(i?"; path="+i:"")+(o?"; secure":""),!0},removeItem:function(e,t,n){return!!this.hasItem(e)&&(document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT"+(n?"; domain="+n:"")+(t?"; path="+t:""),!0)},hasItem:function(e){return!!e&&new RegExp("(?:^|;\\s*)"+encodeURIComponent(e).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=").test(document.cookie)},keys:function(){for(var e=document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g,"").split(/\s*(?:\=[^;]*)?;\s*/),t=e.length,n=0;n<t;n++)e[n]=decodeURIComponent(e[n]);return e},eraseCookieFromAllPaths:function(e){var t=location.pathname.split("/"),n=" path=";document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT;";for(var i=0;i<t.length;i++)n+=("/"!=n.substr(-1)?"/":"")+t[i],document.cookie=encodeURIComponent(e)+"=; expires=Thu, 01-Jan-1970 00:00:01 GMT;"+n+";"}},n=(e=function(){for(var e,t={},n=decodeURIComponent(window.location.href),i=n.slice(n.indexOf("?")+1).split("&"),r=0;r<i.length;r++)t[(e=i[r].split("="))[0]]=e[1];return t}()||{},{getQueryParamForKey:function(t){return e[t]||!1},getQueryParams:function(){return e}});return Q={chain:function(e,t){return e?function(){e.call(this,arguments),t.call(this,arguments)}:t},xhr:function(e){return new Promise(function(t,n){var i=e.retries||2;!function r(){var o=new XMLHttpRequest;e.url=e.url.replace(/^http:\/\//i,"https://"),o.open(e.method||"GET",e.url,!0),Object.keys(e.headers||{}).forEach(function(t){o.setRequestHeader(t,e.headers[t])}),o.onreadystatechange=function(a){if(4===o.readyState)if(-1===[200,304].indexOf(o.status))VizbeeSDK.logger.error("xhr error",a),i>0?(i--,r()):n(new Error("Server responded with a status of "+o.status));else try{e.format=e.format||"json";var s=a.target;"json"===e.format?s=JSON.parse(s.response):"xml"===e.format&&(s=s.responseXML),VizbeeSDK.logger.debug("Util::xhr() -- response object --",s),t(s)}catch(a){i>0?(i--,r()):n("JSON parse error with Server response")}},e.timeout&&(o.timeout=e.timeout,o.ontimeout=function(t){i>0?(i--,r()):n(new Error("Server timeout "+e.timeout+"ms"))}),o.send(e.data)}()})},log:function(){var e=Array.prototype.slice.call(arguments);e.unshift("VIZBEE [LOG]"),console.log.apply(console,e)},docCookies:t,urlParser:n},Q}window.VizbeeTV={init:function(e,t,n){this.logger=new Je,this.logger.setPrefix("[VTVLIB]"),this.Util=se,n?this.tv instanceof je?this.tv.config=te.extend(this.tv.config,t):this.tv=new je(e,t):this.tv instanceof We?this.tv.config=te.extend(this.tv.config,t):this.tv=new We(e,t)}};var Xe,Qe,Ze,$e,et={getIpv6Address:function(e){se.xhr({url:"https://ip.claspws.tv",timeout:5e3,retries:3}).then(function(t){var n=t&&t.headers&&t.headers["x-vzb-client-ip"];n?(VizbeeSDK.logger.debug("Ipv6::getIpv6Address - ipv6Address=",n),e(n)):(VizbeeSDK.logger.warn("Ipv6::getIpv6Address - ipv6Address=empty"),e())}).catch(function(t){VizbeeSDK.logger.warn("Ipv6::getIpv6Address - failed",t),e()})}};function tt(){if(Qe)return Xe;function e(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function t(e){return"function"==typeof e}function n(e){return"object"===_(e)&&null!==e}function i(e){return void 0===e}return Qe=1,Xe=e,e.EventEmitter=e,e.prototype._events=void 0,e.prototype._maxListeners=void 0,e.defaultMaxListeners=10,e.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},e.prototype.emit=function(e){var r,o,a,s,u,l;if(this._events||(this._events={}),"error"===e&&(!this._events.error||n(this._events.error)&&!this._events.error.length)){if((r=arguments[1])instanceof Error)throw r;var c=new Error('Uncaught, unspecified "error" event. ('+r+")");throw c.context=r,c}if(i(o=this._events[e]))return!1;if(t(o))switch(arguments.length){case 1:o.call(this);break;case 2:o.call(this,arguments[1]);break;case 3:o.call(this,arguments[1],arguments[2]);break;default:s=Array.prototype.slice.call(arguments,1),o.apply(this,s)}else if(n(o))for(s=Array.prototype.slice.call(arguments,1),a=(l=o.slice()).length,u=0;u<a;u++)l[u].apply(this,s);return!0},e.prototype.addListener=function(r,o){var a;if(!t(o))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",r,t(o.listener)?o.listener:o),this._events[r]?n(this._events[r])?this._events[r].push(o):this._events[r]=[this._events[r],o]:this._events[r]=o,n(this._events[r])&&!this._events[r].warned&&(a=i(this._maxListeners)?e.defaultMaxListeners:this._maxListeners)&&a>0&&this._events[r].length>a&&(this._events[r].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[r].length),"function"==typeof console.trace&&console.trace()),this},e.prototype.on=e.prototype.addListener,e.prototype.once=function(e,n){if(!t(n))throw TypeError("listener must be a function");var i=!1;function r(){this.removeListener(e,r),i||(i=!0,n.apply(this,arguments))}return r.listener=n,this.on(e,r),this},e.prototype.removeListener=function(e,i){var r,o,a,s;if(!t(i))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(r=this._events[e]).length,o=-1,r===i||t(r.listener)&&r.listener===i)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,i);else if(n(r)){for(s=a;s-- >0;)if(r[s]===i||r[s].listener&&r[s].listener===i){o=s;break}if(o<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(o,1),this._events.removeListener&&this.emit("removeListener",e,i)}return this},e.prototype.removeAllListeners=function(e){var n,i;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(n in this._events)"removeListener"!==n&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events={},this}if(t(i=this._events[e]))this.removeListener(e,i);else if(i)for(;i.length;)this.removeListener(e,i[i.length-1]);return delete this._events[e],this},e.prototype.listeners=function(e){return this._events&&this._events[e]?t(this._events[e])?[this._events[e]]:this._events[e].slice():[]},e.prototype.listenerCount=function(e){if(this._events){var n=this._events[e];if(t(n))return 1;if(n)return n.length}return 0},e.listenerCount=function(e,t){return e.listenerCount(t)},Xe}function nt(){if($e)return Ze;$e=1;var e,t=new(0,tt().EventEmitter);return Ze={reset:function(){e=void 0},getApp:function(){return e},setApp:function(n){n&&(e=n,VizbeeSDK.logger.debug("AppAdapter::setApp in setApp"),t.emit("app",{type:"app",obj:n}))},isAppSet:function(){return!!e},preInit:function(){VizbeeSDK.logger.debug("AppAdapter::preInit() called"),e&&e.preInit?e.preInit():VizbeeSDK.logger.error("AppAdapter::preInit() - app.preInit() callback not provided by host app")},willStartVideo:function(t,n){e&&e.willStartVideo?e.willStartVideo(t,n):VizbeeSDK.logger.info("AppAdapter::willStartVideo() - app.willStartVideo() callback not provided by host app")},startVideo:function(t){e&&e.startVideo?e.startVideo(t):VizbeeSDK.logger.info("AppAdapter::StartVideo() - app.startVideo() callback not provided by host app")},playVideo:function(){return VizbeeSDK.logger.info("AppAdapter::PlayVideo() called"),e&&e.playVideo?e.playVideo():(VizbeeSDK.logger.info("AppAdapter::PlayVideo() - app.playVideo() callback not provided by host app"),!1)},pauseVideo:function(){return VizbeeSDK.logger.info("AppAdapter::PauseVideo() called"),e&&e.pauseVideo?e.pauseVideo():(VizbeeSDK.logger.info("AppAdapter::PauseVideo() - app.pauseVideo() callback not provided by host app"),!1)},stopVideo:function(t){return VizbeeSDK.logger.info("AppAdapter::StopVideo() called",t,e),VizbeeSDK.logger.debug("AppAdapter::StopVideo() called"),e&&e.stopVideo?(VizbeeSDK.logger.info("AppAdapter::StopVideo() called",t),e.stopVideo(t)):(VizbeeSDK.logger.info("AppAdapter::StopVideo() - app.stopVideo() callback not provided by host app"),!1)},seekVideo:function(t){return VizbeeSDK.logger.info("AppAdapter::SeekVideo() called",t),e&&e.seekVideo?e.seekVideo(t):(VizbeeSDK.logger.info("AppAdapter::SeekVideo() - app.seekVideo() callback not provided by host app"),!1)},getVideoInfo:function(){if(e&&e.getVideoInfo)return e.getVideoInfo()},getTracks:function(){return e&&e.getTracks?e.getTracks():(VizbeeSDK.logger.verbose("AppAdapter::getTracks() - app.getTracks() callback not provided by host app"),!1)},getEnabledTracks:function(){return e&&e.getEnabledTracks?e.getEnabledTracks():(VizbeeSDK.logger.verbose("AppAdapter::getEnabledTracks() - app.getEnabledTracks() callback not provided by host app"),!1)},enableTracks:function(t){return VizbeeSDK.logger.verbose("AppAdapter::enableTracks() called"),e&&e.enableTracks?e.enableTracks(t):(VizbeeSDK.logger.verbose("AppAdapter::enableTracks() - app.enableTracks() callback not provided by host app"),!1)},disableTracks:function(t){return VizbeeSDK.logger.verbose("AppAdapter::disableTracks() called"),e&&e.disableTracks?e.disableTracks(t):(VizbeeSDK.logger.verbose("AppAdapter::disableTracks() - app.disableTracks() callback not provided by host app"),!1)},getAudioTracks:function(){return e&&e.getAudioTracks?e.getAudioTracks():(VizbeeSDK.logger.verbose("AppAdapter::getAudioTracks() - app.getAudioTracks() callback not provided by host app"),!1)},getActiveAudioTrack:function(){return e&&e.getActiveAudioTrack?e.getActiveAudioTrack():(VizbeeSDK.logger.verbose("AppAdapter::getActiveAudioTrack() - app.getActiveAudioTrack() callback not provided by host app"),!1)},changeAudioTrack:function(t){return VizbeeSDK.logger.info("AppAdapter::changeAudioTrack() called"),e&&e.changeAudioTrack?e.changeAudioTrack(t):(VizbeeSDK.logger.info("AppAdapter::changeAudioTrack() - app.changeAudioTrack() callback not provided by host app"),!1)},onEvent:function(t){VizbeeSDK.logger.debug("AppAdapter::onEvent() called"),e&&e.onEvent?e.onEvent(t):VizbeeSDK.logger.info("AppAdapter::onEvent() - callback not provided by host app")},updatePresence:function(t){VizbeeSDK.logger.debug("AppAdapter::updatePresence() called"),e&&e.updatePresence?e.updatePresence(t):VizbeeSDK.logger.info("AppAdapter::updatePresence() - callback not provided by host app")},addListener:function(e){t.addListener("app",e)}},Ze}var it,rt,ot=J(),at=new(0,tt().EventEmitter),st=nt(),ut=void 0,lt={isInProgress:!1},ct=!1,dt="videoadapter_video",ft="videoadapter_ad";function pt(e){var t,n,i=!ot.contains(["timeupdate"],e.type);lt.isInProgress||(ut&&"app"!==ut.app.state?(t=new vt,e.type,"loading"===e.type&&(n="BUFFERING"),"playing"===e.type&&(n="PLAYING"),"paused"===e.type&&(n="PAUSED_BY_USER"),"ended"==e.type&&(n="FINISHED"),"interrupted"==e.type&&(n="INTERRUPTED"),"error"===e.type&&(n="INTERRUPTED",e.data&&e.data.reason&&"stop_by_user"!=e.data.reason.toLowerCase()&&(n="FAILED",t.error=e.data,t.error.data={})),n&&(t.state=n),at.emit(dt,t,i)):VizbeeSDK.logger.verbose('VideoAdapter::videoEventHandler - app.state = "app"'))}function ht(e,t){var n=e.playing||e.preparing;(n||!n&<.isInProgress)&&at.emit(ft,e,t),lt.isInProgress=n||!1,lt.isInProgress||(ct=!1),"FINISHED"==e.state||e.state}function vt(e){var t={type:"video",position:-1,duration:-1,cc:{},tr:{}};return rt?(t.position=1e3*rt.currentTime(),t.duration=1e3*rt.getDuration(),t.startTime=rt.getStartTime(),t.videoBufferLevel=rt.getBufferLevel(),t.audioBufferLevel=rt.getAudioBufferLevel(),t.qos=rt.getStreamQualityInfo(),t.volume=100,t.muted=!1):(t.position=-1,t.duration=-1,t.startTime=0,t.videoBufferLevel=0,t.audioBufferLevel=0,t.volume=1,t.muted=!1),t.qos||(t.qos={adPodStartedTimeInMs:0,adPodEndedTimeInMs:0,loadReceivedByAppTimeInMs:0,loadReceivedByPlayerTimeInMs:0,metadataLoadedTimeInMs:0,playerReadyToPlayTimeInMs:0,playbackStartedTimeInMs:0}),ot.extend(t,e)}function gt(){lt.isInProgress&&it.reset()}var yt,mt,bt,St,_t,kt,Tt,Pt,It,Et,Vt,At,Ct={setVideo:function(e){var t;(t=e).onLoading=function(e){lt.isInProgress||(pt({type:"loading"}),ct=!1)},t.onPlaying=function(e){lt.isInProgress||(pt({type:"playing"}),ct=!0)},t.onPaused=function(e){lt.isInProgress||(pt({type:"paused"}),ct=!1)},t.onBuffering=function(e){lt.isInProgress||(pt({type:"loading"}),ct=!1)},t.onError=function(e){lt.isInProgress||(pt({type:"error",data:e}),ct=!1)},t.onInterrupted=function(e){lt.isInProgress||(pt({type:"interrupted",data:e}),ct=!1)},t.onEnded=function(){lt.isInProgress||(pt({type:"ended"}),ct=!1)},t.onTimeUpdate=function(e){lt.isInProgress||(ct?pt({type:"timeupdate"}):(ct=!0,pt({type:"playing"})))},rt=e},setVideoInfo:function(e){e&&ut&&ut.setCurrentVideoInfo(e)},setId:function(e,t){if(ut){if(ut.video&&ut.video.id&&e&&ut.video.id!=e){VizbeeSDK.logger.debug("VideoAdapter::setId - SENDING INTERRUPTED");var n=new vt({id:ut.video.id,state:"INTERRUPTED"});at.emit(dt,n,!0)}var i=new vt({id:e});i.position=i.duration=-1,i.state="UNKNOWN",at.emit(dt,i,!0),VizbeeSDK.logger.debug("VideoAdapter::setId - setting currentGUID = "+e),ut.setCurrentVideoInfo(ot.extend(ut.getCurrentVideoInfo()||{},{id:e,islive:t}))}},setVideoStop:function(){lt&<.isInProgress&&it&&(lt.isInProgress=!1,it.reset()),pt({type:"error"})},willStart:function(e,t){st.willStartVideo(e,t)},start:function(e){pt({type:"loadedmetadata"}),gt(),st.startVideo(e)},play:function(){st.playVideo()||VizbeeTV.tv.inputDevice.sendPlay()},pause:function(){st.pauseVideo()||VizbeeTV.tv.inputDevice.sendPause()},seek:function(e){st.seekVideo(e)||ot.isNumber(e)&&rt.seek(e)},stop:function(e){if(!st.stopVideo(e)){VizbeeTV.tv.inputDevice.sendStop(),VizbeeSDK.logger.debug("VideoAdapter::stop - sending INTERRUPTED state");var t=new vt({state:"INTERRUPTED"});at.emit(dt,t,!0),gt()}},exit:function(){var e=new vt({state:"INTERRUPTED"});at.emit(dt,e,!0)},setTracks:function(e){rt.setTracks(e)},getTracks:function(e){e=e||M;var t=st.getTracks();return!1!==t?t:rt.getTracks(e)},getEnabledTracks:function(e){e=e||M;var t=st.getEnabledTracks();return!1!==t?t:rt.getEnabledTracks(e)},enableTracks:function(e){st.enableTracks(e)||rt.enableTracks(e)},disableTracks:function(e){st.disableTracks(e)||rt.disableTracks(e)},getAudioTracks:function(e){e=e||x;var t=st.getAudioTracks();return!1!==t?t:rt.getTracks(e)},getActiveAudioTrack:function(e){e=e||x;var t=st.getActiveAudioTrack();return!1!==t?t:(rt.getEnabledTracks(e)||[])[0]},changeAudioTrack:function(e){st.changeAudioTrack(e)||rt.changeAudioTrack(e)},mute:function(e){},volumeUp:function(){at.emit(dt,new vt,!0)},volumeDown:function(){at.emit(dt,new vt,!0)},onEvent:function(e){st.onEvent(e)},setAdAdapter:function(e){it&&it.removeListener(ht),(it=e)&&it.addListener(ht)},setAppStateManager:function(e){ut=e},reset:function(){rt=void 0,lt={playing:!1}},addListener:function(e){at.addListener(dt,e),at.addListener(ft,e)},removeListener:function(e){at.removeListener(dt,e),at.removeListener(ft,e)}};function Dt(){if(mt)return yt;mt=1;var e,t=J();return yt={reset:function(){e=void 0},setVideoAdapter:function(t){e=t},isAdapterSet:function(){return!!e},getCurrentTime:function(){var n=0;return e&&t.isFunction(e.getCurrentTime)&&(n=e.getCurrentTime()),n},getDuration:function(){var n=0;return e&&t.isFunction(e.getDuration)&&(n=e.getDuration()),n}}}function wt(){if(St)return bt;St=1;var e=new(0,tt().EventEmitter),t=Ct,n=Dt(),i=void 0;function r(t,r){"video"==t.type&&(t=function(e,t){return t||e.position<=-1||e.duration<=-1||e.position>e.duration||n.isAdapterSet()&&(e.position=n.getCurrentTime(),e.duration=n.getDuration(),VizbeeSDK.logger.debug("ssaivideoadapater::modifyStatus",e.position,e.duration)),e}(t,i&&i.getSyncVideoInfo().islive)),function(t,n){e.emit("ssaivideoadapter_video",t,n)}(t,r)}return bt={init:function(){t.addListener(r)},setVideo:t.setVideo,setVideoInfo:t.setVideoInfo,setId:t.setId,setVideoStop:t.setVideoStop,willStart:t.willStart,start:t.start,play:t.play,pause:t.pause,seek:t.seek,stop:t.stop,exit:t.exit,setTracks:t.setTracks,getTracks:t.getTracks,getEnabledTracks:t.getEnabledTracks,enableTracks:t.enableTracks,disableTracks:t.disableTracks,getAudioTracks:t.getAudioTracks,getActiveAudioTrack:t.getActiveAudioTrack,changeAudioTrack:t.changeAudioTrack,mute:t.mute,volumeUp:t.volumeUp,volumeDown:t.volumeDown,onEvent:t.onEvent,setAppStateManager:function(e){i=e,t.setAppStateManager(e)},setAdAdapter:t.setAdAdapter,reset:function(){i=void 0,t.removeListener(r),t.reset()},addListener:function(t){e.addListener("ssaivideoadapter_video",t)},removeListener:function(t){e.removeListener("ssaivideoadapter_video",t)}}}function Nt(){if(kt)return _t;kt=1;var e=J(),t=new(0,tt().EventEmitter),n=wt(),i=nt(),r={state:"app"},o={},a={},s="default",u={},l={};function c(e){u=e}function d(t,n){"app"===t.type&&f(),"video"===t.type&&function(t,n){e.extend(o,t),["FINISHED","INTERRUPTED","FAILED"].indexOf(o.state)>-1?(VizbeeSDK.logger.debug("AppStateManager::videoEventHanlder() -- setting app.state to 'app'."),p(),r.state="app",h()):(r.state="video",n&&p())}(t,n),"ad"===t.type&&function(t,n){var i=n;t.playing||t.preparing?(r.state="ad",o.state="PAUSED_BY_AD",e.extend(a,t)):(a.preparing=!1,a.playing=!1,"INTERRUPTED"==t.state?(r.state="app",o.state="INTERRUPTED",i=!0):"PAUSED_BY_AD"==o.state&&(o.state="UNKNOWN"),o.duration<=o.position&&o.duration>0&&(r.state="app",o.state="FINISHED",i=!0)),i&&p()}(t,n)}function f(){VizbeeSDK.logger.debug("AppStateManager:appEventHandler appIsSet is TRUE"),t.emit("state",{type:"appIsSet"})}function p(){t.emit("state",{})}function h(){VizbeeSDK.logger.debug("AppStateManager:reset() previous video and ad objects = ",o,a,u),o.id="",o.state="UNKNOWN",o.position=-1,o.duration=-1,o.elapsedTime=0,o.tr={},o.error={},a.id="",a.state="UNKNOWN",a.position=-1,a.duration=-1,s={},VizbeeSDK.logger.debug("AppStateManager:reset() complete : current video and ad objects = ",o,a,u)}return h(),n.addListener(d),i.addListener(d),i.isAppSet()&&f(),_t={type:"AppStateManager",app:r,video:o,ad:a,reset:h,syncStartVideoSource:s,syncVideoInfo:u,setSyncVideoInfo:c,getSyncVideoInfo:function(){return u},currentVideoInfo:l,setCurrentVideoInfo:function(e){l=e,u&&e&&u.id!=e.id&&c({})},getCurrentVideoInfo:function(){return l},wasVideoStartedByVizbee:function(){return!!(l&&l.senderInfo&&l.senderInfo.st)||!(!u||!l||u.id!=l.id)},addListener:function(e){t.addListener("state",e)},removeListener:function(e){t.removeListener("state",e)}}}function Mt(){return Et?It:(Et=1,It={setVGA:function(t){t&&(e=t,VizbeeSDK.logger.debug("VGAAdapter::setVGA in setVGA"))},onSubscribedToSync:function(){VizbeeSDK.logger.debug("VGAAdapter::subscribedToSync in subscribedToSync"),e&&e.onSubscribedToSync&&e.onSubscribedToSync()},reset:function(){e=void 0}});var e}function xt(){if(At)return Vt;At=1;var e=new(0,tt().EventEmitter),t="sync_proxy_video_cmds";return Vt={send:function(n){e.emit(t,n)},reset:function(){e.removeAllListeners(t)},addListener:function(n){e.addListener(t,n)}}}var Ot,zt,Lt,Rt,Kt,Ut,Ft=function(){return s(function e(t){o(this,e),this.appConfig=t||{},this._eventListeners=[]},[{key:"connect",value:function(e){throw new TypeError("BaseSync::connect() - Abstract method.")}},{key:"disconnect",value:function(){this._eventListeners=[]}},{key:"send",value:function(e){}},{key:"onReceive",set:function(e){"function"==typeof e&&this._eventListeners.push(e)}},{key:"dispatchReceive",value:function(e){for(var t=this._eventListeners.length-1;t>-1;t--)this._eventListeners[t](e)}}])}(),Bt=s(function e(t,n){o(this,e),this.type=t,this.data=n}),Ht=function(){return s(function e(){o(this,e)},null,[{key:"SYNC_CONNECT",get:function(){return"sync-connect"}},{key:"SYNC_MESSAGE",get:function(){return"sync-message"}},{key:"SYNC_PRESENCE",get:function(){return"sync-presence"}}])}(),Gt=t(function(){if(zt)return Ot;zt=1;var e=Ye().docCookies,t="screen_device_id",n="should_verify_screen_device_id",i="screen_device_id_verified_intermediate",r="screen_device_id_verified",o=e.getItem(r),a=e.getItem(t);return Ot={getDeviceId:function(){return a},getDeviceIdFromStorage:function(){return e.getItem(t)},isDeviceIdVerified:function(){return o},isDeviceIdVerifiedFlagStored:function(){return e.getItem(r)},isIntermediateVerifcationCookieSet:function(){return e.getItem(i)},isShouldVerifyDeviceIdFlagSet:function(){return e.getItem(n)},setDeviceId:function(r){o||(a!==r&&this.isIntermediateVerifcationCookieSet()&&e.eraseCookieFromAllPaths(i),a=r,e.setItem(t,a,1/0,"/"),e.setItem(n,"yes",1/0,"/"))},verifyDeviceId:function(){e.getItem(n)&&(e.getItem(r)||(e.getItem(i)?(o="yes",e.setItem(r,o,1/0,"/"),VizbeeSDK.logger.debug("SETTING VERIFIED COOKIE *** ",e.getItem(r))):(e.setItem(i,"yes",1/0,"/"),VizbeeSDK.logger.debug("SETTING INTERMEDIATE COOKIE *** ",e.getItem(i)))),e.eraseCookieFromAllPaths(n))},reset:function(){for(var s=[t,r,n,i],u=0;u<s.length;u++)e.eraseCookieFromAllPaths(s[u]);o=null,a=null}}}()),Wt={exports:{}},jt={exports:{}};function qt(){return Lt||(Lt=1,e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&t.rotl(e,8)|4278255360&t.rotl(e,24);for(var n=0;n<e.length;n++)e[n]=t.endian(e[n]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,i=0;n<e.length;n++,i+=8)t[i>>>5]|=e[n]<<24-i%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(t){for(var n=[],i=0;i<t.length;i+=3)for(var r=t[i]<<16|t[i+1]<<8|t[i+2],o=0;o<4;o++)8*i+6*o<=8*t.length?n.push(e.charAt(r>>>6*(3-o)&63)):n.push("=");return n.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/gi,"");for(var n=[],i=0,r=0;i<t.length;r=++i%4)0!=r&&n.push((e.indexOf(t.charAt(i-1))&Math.pow(2,-2*r+8)-1)<<2*r|e.indexOf(t.charAt(i))>>>6-2*r);return n}},jt.exports=t),jt.exports;var e,t}function Jt(){if(Kt)return Rt;Kt=1;var e={utf8:{stringToBytes:function(t){return e.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(e.bin.bytesToString(t)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};return Rt=e}var Yt,Xt,Qt,Zt=(Ut||(Ut=1,function(){var e=qt(),t=Jt().utf8,n=Jt().bin,i=function(r,o){r.constructor==String?r=o&&"binary"===o.encoding?n.stringToBytes(r):t.stringToBytes(r):"undefined"!=typeof Buffer&&"function"==typeof Buffer.isBuffer&&Buffer.isBuffer(r)?r=Array.prototype.slice.call(r,0):Array.isArray(r)||(r=r.toString());for(var a=e.bytesToWords(r),s=8*r.length,u=1732584193,l=-271733879,c=-1732584194,d=271733878,f=0;f<a.length;f++)a[f]=16711935&(a[f]<<8|a[f]>>>24)|4278255360&(a[f]<<24|a[f]>>>8);a[s>>>5]|=128<<s%32,a[14+(s+64>>>9<<4)]=s;var p=i._ff,h=i._gg,v=i._hh,g=i._ii;for(f=0;f<a.length;f+=16){var y=u,m=l,b=c,S=d;u=p(u,l,c,d,a[f+0],7,-680876936),d=p(d,u,l,c,a[f+1],12,-389564586),c=p(c,d,u,l,a[f+2],17,606105819),l=p(l,c,d,u,a[f+3],22,-1044525330),u=p(u,l,c,d,a[f+4],7,-176418897),d=p(d,u,l,c,a[f+5],12,1200080426),c=p(c,d,u,l,a[f+6],17,-1473231341),l=p(l,c,d,u,a[f+7],22,-45705983),u=p(u,l,c,d,a[f+8],7,1770035416),d=p(d,u,l,c,a[f+9],12,-1958414417),c=p(c,d,u,l,a[f+10],17,-42063),l=p(l,c,d,u,a[f+11],22,-1990404162),u=p(u,l,c,d,a[f+12],7,1804603682),d=p(d,u,l,c,a[f+13],12,-40341101),c=p(c,d,u,l,a[f+14],17,-1502002290),u=h(u,l=p(l,c,d,u,a[f+15],22,1236535329),c,d,a[f+1],5,-165796510),d=h(d,u,l,c,a[f+6],9,-1069501632),c=h(c,d,u,l,a[f+11],14,643717713),l=h(l,c,d,u,a[f+0],20,-373897302),u=h(u,l,c,d,a[f+5],5,-701558691),d=h(d,u,l,c,a[f+10],9,38016083),c=h(c,d,u,l,a[f+15],14,-660478335),l=h(l,c,d,u,a[f+4],20,-405537848),u=h(u,l,c,d,a[f+9],5,568446438),d=h(d,u,l,c,a[f+14],9,-1019803690),c=h(c,d,u,l,a[f+3],14,-187363961),l=h(l,c,d,u,a[f+8],20,1163531501),u=h(u,l,c,d,a[f+13],5,-1444681467),d=h(d,u,l,c,a[f+2],9,-51403784),c=h(c,d,u,l,a[f+7],14,1735328473),u=v(u,l=h(l,c,d,u,a[f+12],20,-1926607734),c,d,a[f+5],4,-378558),d=v(d,u,l,c,a[f+8],11,-2022574463),c=v(c,d,u,l,a[f+11],16,1839030562),l=v(l,c,d,u,a[f+14],23,-35309556),u=v(u,l,c,d,a[f+1],4,-1530992060),d=v(d,u,l,c,a[f+4],11,1272893353),c=v(c,d,u,l,a[f+7],16,-155497632),l=v(l,c,d,u,a[f+10],23,-1094730640),u=v(u,l,c,d,a[f+13],4,681279174),d=v(d,u,l,c,a[f+0],11,-358537222),c=v(c,d,u,l,a[f+3],16,-722521979),l=v(l,c,d,u,a[f+6],23,76029189),u=v(u,l,c,d,a[f+9],4,-640364487),d=v(d,u,l,c,a[f+12],11,-421815835),c=v(c,d,u,l,a[f+15],16,530742520),u=g(u,l=v(l,c,d,u,a[f+2],23,-995338651),c,d,a[f+0],6,-198630844),d=g(d,u,l,c,a[f+7],10,1126891415),c=g(c,d,u,l,a[f+14],15,-1416354905),l=g(l,c,d,u,a[f+5],21,-57434055),u=g(u,l,c,d,a[f+12],6,1700485571),d=g(d,u,l,c,a[f+3],10,-1894986606),c=g(c,d,u,l,a[f+10],15,-1051523),l=g(l,c,d,u,a[f+1],21,-2054922799),u=g(u,l,c,d,a[f+8],6,1873313359),d=g(d,u,l,c,a[f+15],10,-30611744),c=g(c,d,u,l,a[f+6],15,-1560198380),l=g(l,c,d,u,a[f+13],21,1309151649),u=g(u,l,c,d,a[f+4],6,-145523070),d=g(d,u,l,c,a[f+11],10,-1120210379),c=g(c,d,u,l,a[f+2],15,718787259),l=g(l,c,d,u,a[f+9],21,-343485551),u=u+y>>>0,l=l+m>>>0,c=c+b>>>0,d=d+S>>>0}return e.endian([u,l,c,d])};i._ff=function(e,t,n,i,r,o,a){var s=e+(t&n|~t&i)+(r>>>0)+a;return(s<<o|s>>>32-o)+t},i._gg=function(e,t,n,i,r,o,a){var s=e+(t&i|n&~i)+(r>>>0)+a;return(s<<o|s>>>32-o)+t},i._hh=function(e,t,n,i,r,o,a){var s=e+(t^n^i)+(r>>>0)+a;return(s<<o|s>>>32-o)+t},i._ii=function(e,t,n,i,r,o,a){var s=e+(n^(t|~i))+(r>>>0)+a;return(s<<o|s>>>32-o)+t},i._blocksize=16,i._digestsize=16,Wt.exports=function(t,r){if(void 0!==t){var o=e.wordsToBytes(i(t,r));return r&&r.asBytes?o:r&&r.asString?n.bytesToString(o):e.bytesToHex(o)}}}()),Wt.exports),$t=t(Zt),en={exports:{}},tn={exports:{}},nn={exports:{}},rn={exports:{}},on={exports:{}};function an(){return Xt||(Xt=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n,i=(Yt||(Yt=1,function(e,t){!function(e){var t={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i};function n(){var e,t,n="";for(e=0;e<32;e++)t=16*Math.random()|0,8!==e&&12!==e&&16!==e&&20!==e||(n+="-"),n+=(12===e?4:16===e?3&t|8:t).toString(16);return n}function i(e,n){var i=t[n||"all"];return i&&i.test(e)||!1}n.isUUID=i,n.VERSION="0.1.0",e.uuid=n,e.isUUID=i}(t),null!==e&&(e.exports=t.uuid)}(on,on.exports)),on.exports),r=(n=i)&&n.__esModule?n:{default:n};t.default={createUUID:function(){return r.default.uuid?r.default.uuid():(0,r.default)()}},e.exports=t.default}(rn,rn.exports)),rn.exports}function sn(){return Qt||(Qt=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n,i=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),r=(n=an())&&n.__esModule?n:{default:n},o=function(){function e(t){var n=t.setup,i=t.db;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._db=i,this.instanceId="pn-"+r.default.createUUID(),this.secretKey=n.secretKey||n.secret_key,this.subscribeKey=n.subscribeKey||n.subscribe_key,this.publishKey=n.publishKey||n.publish_key,this.sdkName=n.sdkName,this.sdkFamily=n.sdkFamily,this.partnerId=n.partnerId,this.setAuthKey(n.authKey),this.setCipherKey(n.cipherKey),this.setFilterExpression(n.filterExpression),this.origin=n.origin||"pubsub.pndsn.com",this.secure=n.ssl||!1,this.restore=n.restore||!1,this.proxy=n.proxy,this.keepAlive=n.keepAlive,this.keepAliveSettings=n.keepAliveSettings,this.autoNetworkDetection=n.autoNetworkDetection||!1,this.dedupeOnSubscribe=n.dedupeOnSubscribe||!1,this.maximumCacheSize=n.maximumCacheSize||100,this.customEncrypt=n.customEncrypt,this.customDecrypt=n.customDecrypt,"undefined"!=typeof location&&"https:"===location.protocol&&(this.secure=!0),this.logVerbosity=n.logVerbosity||!1,this.suppressLeaveEvents=n.suppressLeaveEvents||!1,this.announceFailedHeartbeats=n.announceFailedHeartbeats||!0,this.announceSuccessfulHeartbeats=n.announceSuccessfulHeartbeats||!1,this.useInstanceId=n.useInstanceId||!1,this.useRequestId=n.useRequestId||!1,this.requestMessageCountThreshold=n.requestMessageCountThreshold,this.setTransactionTimeout(n.transactionalRequestTimeout||15e3),this.setSubscribeTimeout(n.subscribeRequestTimeout||31e4),this.setSendBeaconConfig(n.useSendBeacon||!0),this.setPresenceTimeout(n.presenceTimeout||300),null!=n.heartbeatInterval&&this.setHeartbeatInterval(n.heartbeatInterval),this.setUUID(this._decideUUID(n.uuid))}return i(e,[{key:"getAuthKey",value:function(){return this.authKey}},{key:"setAuthKey",value:function(e){return this.authKey=e,this}},{key:"setCipherKey",value:function(e){return this.cipherKey=e,this}},{key:"getUUID",value:function(){return this.UUID}},{key:"setUUID",value:function(e){return this._db&&this._db.set&&this._db.set(this.subscribeKey+"uuid",e),this.UUID=e,this}},{key:"getFilterExpression",value:function(){return this.filterExpression}},{key:"setFilterExpression",value:function(e){return this.filterExpression=e,this}},{key:"getPresenceTimeout",value:function(){return this._presenceTimeout}},{key:"setPresenceTimeout",value:function(e){return this._presenceTimeout=e,this.setHeartbeatInterval(this._presenceTimeout/2-1),this}},{key:"setProxy",value:function(e){this.proxy=e}},{key:"getHeartbeatInterval",value:function(){return this._heartbeatInterval}},{key:"setHeartbeatInterval",value:function(e){return this._heartbeatInterval=e,this}},{key:"getSubscribeTimeout",value:function(){return this._subscribeRequestTimeout}},{key:"setSubscribeTimeout",value:function(e){return this._subscribeRequestTimeout=e,this}},{key:"getTransactionTimeout",value:function(){return this._transactionalRequestTimeout}},{key:"setTransactionTimeout",value:function(e){return this._transactionalRequestTimeout=e,this}},{key:"isSendBeaconEnabled",value:function(){return this._useSendBeacon}},{key:"setSendBeaconConfig",value:function(e){return this._useSendBeacon=e,this}},{key:"getVersion",value:function(){return"4.20.3"}},{key:"_decideUUID",value:function(e){return e||(this._db&&this._db.get&&this._db.get(this.subscribeKey+"uuid")?this._db.get(this.subscribeKey+"uuid"):"pn-"+r.default.createUUID())}}]),e}();t.default=o,e.exports=t.default}(nn,nn.exports)),nn.exports}var un,ln={exports:{}};function cn(){return un||(un=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();r(sn());var i=r(null);function r(e){return e&&e.__esModule?e:{default:e}}var o=function(){function e(t){var n=t.config;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._config=n,this._iv="0123456789012345",this._allowedKeyEncodings=["hex","utf8","base64","binary"],this._allowedKeyLengths=[128,256],this._allowedModes=["ecb","cbc"],this._defaultOptions={encryptKey:!0,keyEncoding:"utf8",keyLength:256,mode:"cbc"}}return n(e,[{key:"HMACSHA256",value:function(e){return i.default.HmacSHA256(e,this._config.secretKey).toString(i.default.enc.Base64)}},{key:"SHA256",value:function(e){return i.default.SHA256(e).toString(i.default.enc.Hex)}},{key:"_parseOptions",value:function(e){var t=e||{};return t.hasOwnProperty("encryptKey")||(t.encryptKey=this._defaultOptions.encryptKey),t.hasOwnProperty("keyEncoding")||(t.keyEncoding=this._defaultOptions.keyEncoding),t.hasOwnProperty("keyLength")||(t.keyLength=this._defaultOptions.keyLength),t.hasOwnProperty("mode")||(t.mode=this._defaultOptions.mode),-1===this._allowedKeyEncodings.indexOf(t.keyEncoding.toLowerCase())&&(t.keyEncoding=this._defaultOptions.keyEncoding),-1===this._allowedKeyLengths.indexOf(parseInt(t.keyLength,10))&&(t.keyLength=this._defaultOptions.keyLength),-1===this._allowedModes.indexOf(t.mode.toLowerCase())&&(t.mode=this._defaultOptions.mode),t}},{key:"_decodeKey",value:function(e,t){return"base64"===t.keyEncoding?i.default.enc.Base64.parse(e):"hex"===t.keyEncoding?i.default.enc.Hex.parse(e):e}},{key:"_getPaddedKey",value:function(e,t){return e=this._decodeKey(e,t),t.encryptKey?i.default.enc.Utf8.parse(this.SHA256(e).slice(0,32)):e}},{key:"_getMode",value:function(e){return"ecb"===e.mode?i.default.mode.ECB:i.default.mode.CBC}},{key:"_getIV",value:function(e){return"cbc"===e.mode?i.default.enc.Utf8.parse(this._iv):null}},{key:"encrypt",value:function(e,t,n){return this._config.customEncrypt?this._config.customEncrypt(e):this.pnEncrypt(e,t,n)}},{key:"decrypt",value:function(e,t,n){return this._config.customDecrypt?this._config.customDecrypt(e):this.pnDecrypt(e,t,n)}},{key:"pnEncrypt",value:function(e,t,n){if(!t&&!this._config.cipherKey)return e;n=this._parseOptions(n);var r=this._getIV(n),o=this._getMode(n),a=this._getPaddedKey(t||this._config.cipherKey,n);return i.default.AES.encrypt(e,a,{iv:r,mode:o}).ciphertext.toString(i.default.enc.Base64)||e}},{key:"pnDecrypt",value:function(e,t,n){if(!t&&!this._config.cipherKey)return e;n=this._parseOptions(n);var r=this._getIV(n),o=this._getMode(n),a=this._getPaddedKey(t||this._config.cipherKey,n);try{var s=i.default.enc.Base64.parse(e),u=i.default.AES.decrypt({ciphertext:s},a,{iv:r,mode:o}).toString(i.default.enc.Utf8);return JSON.parse(u)}catch(e){return null}}}]),e}();t.default=o,e.exports=t.default}(ln,ln.exports)),ln.exports}var dn,fn,pn={exports:{}},hn={exports:{}},vn={exports:{}};function gn(){return dn||(dn=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default={PNNetworkUpCategory:"PNNetworkUpCategory",PNNetworkDownCategory:"PNNetworkDownCategory",PNNetworkIssuesCategory:"PNNetworkIssuesCategory",PNTimeoutCategory:"PNTimeoutCategory",PNBadRequestCategory:"PNBadRequestCategory",PNAccessDeniedCategory:"PNAccessDeniedCategory",PNUnknownCategory:"PNUnknownCategory",PNReconnectedCategory:"PNReconnectedCategory",PNConnectedCategory:"PNConnectedCategory",PNRequestMessageCountExceededCategory:"PNRequestMessageCountExceededCategory"},e.exports=t.default}(vn,vn.exports)),vn.exports}function yn(){return fn||(fn=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n,i=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),r=(n=gn())&&n.__esModule?n:{default:n},o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._listeners=[]}return i(e,[{key:"addListener",value:function(e){this._listeners.push(e)}},{key:"removeListener",value:function(e){var t=[];this._listeners.forEach(function(n){n!==e&&t.push(n)}),this._listeners=t}},{key:"removeAllListeners",value:function(){this._listeners=[]}},{key:"announcePresence",value:function(e){this._listeners.forEach(function(t){t.presence&&t.presence(e)})}},{key:"announceStatus",value:function(e){this._listeners.forEach(function(t){t.status&&t.status(e)})}},{key:"announceMessage",value:function(e){this._listeners.forEach(function(t){t.message&&t.message(e)})}},{key:"announceNetworkUp",value:function(){var e={};e.category=r.default.PNNetworkUpCategory,this.announceStatus(e)}},{key:"announceNetworkDown",value:function(){var e={};e.category=r.default.PNNetworkDownCategory,this.announceStatus(e)}}]),e}();t.default=o,e.exports=t.default}(hn,hn.exports)),hn.exports}var mn,bn,Sn,_n={exports:{}},kn={},Tn={exports:{}};function Pn(){return mn||(mn=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default={PNTimeOperation:"PNTimeOperation",PNHistoryOperation:"PNHistoryOperation",PNDeleteMessagesOperation:"PNDeleteMessagesOperation",PNFetchMessagesOperation:"PNFetchMessagesOperation",PNSubscribeOperation:"PNSubscribeOperation",PNUnsubscribeOperation:"PNUnsubscribeOperation",PNPublishOperation:"PNPublishOperation",PNPushNotificationEnabledChannelsOperation:"PNPushNotificationEnabledChannelsOperation",PNRemoveAllPushNotificationsOperation:"PNRemoveAllPushNotificationsOperation",PNWhereNowOperation:"PNWhereNowOperation",PNSetStateOperation:"PNSetStateOperation",PNHereNowOperation:"PNHereNowOperation",PNGetStateOperation:"PNGetStateOperation",PNHeartbeatOperation:"PNHeartbeatOperation",PNChannelGroupsOperation:"PNChannelGroupsOperation",PNRemoveGroupOperation:"PNRemoveGroupOperation",PNChannelsForGroupOperation:"PNChannelsForGroupOperation",PNAddChannelsToGroupOperation:"PNAddChannelsToGroupOperation",PNRemoveChannelsFromGroupOperation:"PNRemoveChannelsFromGroupOperation",PNAccessManagerGrant:"PNAccessManagerGrant",PNAccessManagerAudit:"PNAccessManagerAudit"},e.exports=t.default}(Tn,Tn.exports)),Tn.exports}function In(){if(bn)return kn;bn=1,Object.defineProperty(kn,"__esModule",{value:!0}),kn.getOperation=function(){return t.default.PNTimeOperation},kn.getURL=function(){return"/time/0"},kn.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},kn.prepareParams=function(){return{}},kn.isAuthSupported=function(){return!1},kn.handleResponse=function(e,t){return{timetoken:t[0]}},kn.validateParams=function(){};var e,t=(e=Pn())&&e.__esModule?e:{default:e};return kn}var En,Vn,An,Cn,Dn={exports:{}};function wn(){if(An)return Vn;function e(e){return encodeURIComponent(e).replace(/[!~*'()]/g,function(e){return"%"+e.charCodeAt(0).toString(16).toUpperCase()})}return An=1,Vn={signPamFromParams:function(t){return(n=t,function(e){var t=[];return Object.keys(e).forEach(function(e){return t.push(e)}),t}(n).sort()).map(function(n){return n+"="+e(t[n])}).join("&");var n},endsWith:function(e,t){return-1!==e.indexOf(t,this.length-t.length)},createPromise:function(){var e=void 0,t=void 0;return{promise:new Promise(function(n,i){e=n,t=i}),reject:t,fulfill:e}},encodeString:e}}function Nn(){return Cn||(Cn=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();s(cn()),s(sn()),s(yn());var i=s((Sn||(Sn=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n,i=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!(n=In())||n.__esModule;var r=function(){function e(t){var n=t.timeEndpoint;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._timeEndpoint=n}return i(e,[{key:"onReconnection",value:function(e){this._reconnectionCallback=e}},{key:"startPolling",value:function(){this._timeTimer=setInterval(this._performTimeLoop.bind(this),3e3)}},{key:"stopPolling",value:function(){clearInterval(this._timeTimer)}},{key:"_performTimeLoop",value:function(){var e=this;this._timeEndpoint(function(t){t.error||(clearInterval(e._timeTimer),e._reconnectionCallback())})}}]),e}();t.default=r,e.exports=t.default}(_n,_n.exports)),_n.exports)),r=s((En||(En=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n,i=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();!(n=sn())||n.__esModule;var r=function(){function e(t){var n=t.config;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.hashHistory=[],this._config=n}return i(e,[{key:"getKey",value:function(e){var t=function(e){var t=0;if(0===e.length)return t;for(var n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n),t&=t;return t}(JSON.stringify(e.payload)).toString();return e.publishMetaData.publishTimetoken+"-"+t}},{key:"isDuplicate",value:function(e){return this.hashHistory.includes(this.getKey(e))}},{key:"addEntry",value:function(e){this.hashHistory.length>=this._config.maximumCacheSize&&this.hashHistory.shift(),this.hashHistory.push(this.getKey(e))}},{key:"clearHistory",value:function(){this.hashHistory=[]}}]),e}();t.default=r,e.exports=t.default}(Dn,Dn.exports)),Dn.exports)),o=s(wn()),a=s(gn());function s(e){return e&&e.__esModule?e:{default:e}}var u=function(){function e(t){var n=t.subscribeEndpoint,o=t.leaveEndpoint,a=t.heartbeatEndpoint,s=t.setStateEndpoint,u=t.timeEndpoint,l=t.config,c=t.crypto,d=t.listenerManager;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._listenerManager=d,this._config=l,this._leaveEndpoint=o,this._heartbeatEndpoint=a,this._setStateEndpoint=s,this._subscribeEndpoint=n,this._crypto=c,this._channels={},this._presenceChannels={},this._heartbeatChannels={},this._heartbeatChannelGroups={},this._channelGroups={},this._presenceChannelGroups={},this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[],this._currentTimetoken=0,this._lastTimetoken=0,this._storedTimetoken=null,this._subscriptionStatusAnnounced=!1,this._isOnline=!0,this._reconnectionManager=new i.default({timeEndpoint:u}),this._dedupingManager=new r.default({config:l})}return n(e,[{key:"adaptStateChange",value:function(e,t){var n=this,i=e.state,r=e.channels,o=void 0===r?[]:r,a=e.channelGroups,s=void 0===a?[]:a;return o.forEach(function(e){e in n._channels&&(n._channels[e].state=i)}),s.forEach(function(e){e in n._channelGroups&&(n._channelGroups[e].state=i)}),this._setStateEndpoint({state:i,channels:o,channelGroups:s},t)}},{key:"adaptPresenceChange",value:function(e){var t=this,n=e.connected,i=e.channels,r=void 0===i?[]:i,o=e.channelGroups,a=void 0===o?[]:o;n?(r.forEach(function(e){t._heartbeatChannels[e]={state:{}}}),a.forEach(function(e){t._heartbeatChannelGroups[e]={state:{}}})):(r.forEach(function(e){e in t._heartbeatChannels&&delete t._heartbeatChannels[e]}),a.forEach(function(e){e in t._heartbeatChannelGroups&&delete t._heartbeatChannelGroups[e]}),!1===this._config.suppressLeaveEvents&&this._leaveEndpoint({channels:r,channelGroups:a},function(e){t._listenerManager.announceStatus(e)})),this.reconnect()}},{key:"adaptSubscribeChange",value:function(e){var t=this,n=e.timetoken,i=e.channels,r=void 0===i?[]:i,o=e.channelGroups,a=void 0===o?[]:o,s=e.withPresence,u=void 0!==s&&s;this._config.subscribeKey&&""!==this._config.subscribeKey?(n&&(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=n),"0"!==this._currentTimetoken&&0!==this._currentTimetoken&&(this._storedTimetoken=this._currentTimetoken,this._currentTimetoken=0),r.forEach(function(e){t._channels[e]={state:{}},u&&(t._presenceChannels[e]={}),t._pendingChannelSubscriptions.push(e)}),a.forEach(function(e){t._channelGroups[e]={state:{}},u&&(t._presenceChannelGroups[e]={}),t._pendingChannelGroupSubscriptions.push(e)}),this._subscriptionStatusAnnounced=!1,this.reconnect()):console&&console.log}},{key:"adaptUnsubscribeChange",value:function(e,t){var n=this,i=e.channels,r=void 0===i?[]:i,o=e.channelGroups,a=void 0===o?[]:o,s=[],u=[];r.forEach(function(e){e in n._channels&&(delete n._channels[e],s.push(e)),e in n._presenceChannels&&(delete n._presenceChannels[e],s.push(e))}),a.forEach(function(e){e in n._channelGroups&&(delete n._channelGroups[e],u.push(e)),e in n._presenceChannelGroups&&(delete n._channelGroups[e],u.push(e))}),0===s.length&&0===u.length||(!1!==this._config.suppressLeaveEvents||t||this._leaveEndpoint({channels:s,channelGroups:u},function(e){e.affectedChannels=s,e.affectedChannelGroups=u,e.currentTimetoken=n._currentTimetoken,e.lastTimetoken=n._lastTimetoken,n._listenerManager.announceStatus(e)}),0===Object.keys(this._channels).length&&0===Object.keys(this._presenceChannels).length&&0===Object.keys(this._channelGroups).length&&0===Object.keys(this._presenceChannelGroups).length&&(this._lastTimetoken=0,this._currentTimetoken=0,this._storedTimetoken=null,this._region=null,this._reconnectionManager.stopPolling()),this.reconnect())}},{key:"unsubscribeAll",value:function(e){this.adaptUnsubscribeChange({channels:this.getSubscribedChannels(),channelGroups:this.getSubscribedChannelGroups()},e)}},{key:"getHeartbeatChannels",value:function(){return Object.keys(this._heartbeatChannels)}},{key:"getHeartbeatChannelGroups",value:function(){return Object.keys(this._heartbeatChannelGroups)}},{key:"getSubscribedChannels",value:function(){return Object.keys(this._channels)}},{key:"getSubscribedChannelGroups",value:function(){return Object.keys(this._channelGroups)}},{key:"reconnect",value:function(){this._startSubscribeLoop(),this._registerHeartbeatTimer()}},{key:"disconnect",value:function(){this._stopSubscribeLoop(),this._stopHeartbeatTimer(),this._reconnectionManager.stopPolling()}},{key:"_registerHeartbeatTimer",value:function(){this._stopHeartbeatTimer(),0!==this._config.getHeartbeatInterval()&&(this._performHeartbeatLoop(),this._heartbeatTimer=setInterval(this._performHeartbeatLoop.bind(this),1e3*this._config.getHeartbeatInterval()))}},{key:"_stopHeartbeatTimer",value:function(){this._heartbeatTimer&&(clearInterval(this._heartbeatTimer),this._heartbeatTimer=null)}},{key:"_performHeartbeatLoop",value:function(){var e=this,t=[];t=(t=t.concat(this.getHeartbeatChannels())).concat(this.getSubscribedChannels());var n=[];n=(n=n.concat(this.getHeartbeatChannelGroups())).concat(this.getSubscribedChannelGroups());var i={};0===t.length&&0===n.length||(this.getSubscribedChannels().forEach(function(t){var n=e._channels[t].state;Object.keys(n).length&&(i[t]=n)}),this.getSubscribedChannelGroups().forEach(function(t){var n=e._channelGroups[t].state;Object.keys(n).length&&(i[t]=n)}),this._heartbeatEndpoint({channels:t,channelGroups:n,state:i},function(t){t.error&&e._config.announceFailedHeartbeats&&e._listenerManager.announceStatus(t),t.error&&e._config.autoNetworkDetection&&e._isOnline&&(e._isOnline=!1,e.disconnect(),e._listenerManager.announceNetworkDown(),e.reconnect()),!t.error&&e._config.announceSuccessfulHeartbeats&&e._listenerManager.announceStatus(t)}.bind(this)))}},{key:"_startSubscribeLoop",value:function(){this._stopSubscribeLoop();var e=[],t=[];if(Object.keys(this._channels).forEach(function(t){return e.push(t)}),Object.keys(this._presenceChannels).forEach(function(t){return e.push(t+"-pnpres")}),Object.keys(this._channelGroups).forEach(function(e){return t.push(e)}),Object.keys(this._presenceChannelGroups).forEach(function(e){return t.push(e+"-pnpres")}),0!==e.length||0!==t.length){var n={channels:e,channelGroups:t,timetoken:this._currentTimetoken,filterExpression:this._config.filterExpression,region:this._region};this._subscribeCall=this._subscribeEndpoint(n,this._processSubscribeResponse.bind(this))}}},{key:"_processSubscribeResponse",value:function(e,t){var n=this;if(e.error)e.category===a.default.PNTimeoutCategory?this._startSubscribeLoop():e.category===a.default.PNNetworkIssuesCategory?(this.disconnect(),e.error&&this._config.autoNetworkDetection&&this._isOnline&&(this._isOnline=!1,this._listenerManager.announceNetworkDown()),this._reconnectionManager.onReconnection(function(){n._config.autoNetworkDetection&&!n._isOnline&&(n._isOnline=!0,n._listenerManager.announceNetworkUp()),n.reconnect(),n._subscriptionStatusAnnounced=!0;var t={category:a.default.PNReconnectedCategory,operation:e.operation,lastTimetoken:n._lastTimetoken,currentTimetoken:n._currentTimetoken};n._listenerManager.announceStatus(t)}),this._reconnectionManager.startPolling(),this._listenerManager.announceStatus(e)):e.category===a.default.PNBadRequestCategory?(this._stopHeartbeatTimer(),this._listenerManager.announceStatus(e)):this._listenerManager.announceStatus(e);else{if(this._storedTimetoken?(this._currentTimetoken=this._storedTimetoken,this._storedTimetoken=null):(this._lastTimetoken=this._currentTimetoken,this._currentTimetoken=t.metadata.timetoken),!this._subscriptionStatusAnnounced){var i={};i.category=a.default.PNConnectedCategory,i.operation=e.operation,i.affectedChannels=this._pendingChannelSubscriptions,i.subscribedChannels=this.getSubscribedChannels(),i.affectedChannelGroups=this._pendingChannelGroupSubscriptions,i.lastTimetoken=this._lastTimetoken,i.currentTimetoken=this._currentTimetoken,this._subscriptionStatusAnnounced=!0,this._listenerManager.announceStatus(i),this._pendingChannelSubscriptions=[],this._pendingChannelGroupSubscriptions=[]}var r=t.messages||[],s=this._config,u=s.requestMessageCountThreshold,l=s.dedupeOnSubscribe;if(u&&r.length>=u){var c={};c.category=a.default.PNRequestMessageCountExceededCategory,c.operation=e.operation,this._listenerManager.announceStatus(c)}r.forEach(function(e){var t=e.channel,i=e.subscriptionMatch,r=e.publishMetaData;if(t===i&&(i=null),l){if(n._dedupingManager.isDuplicate(e))return;n._dedupingManager.addEntry(e)}if(o.default.endsWith(e.channel,"-pnpres")){var a={channel:null,subscription:null};a.actualChannel=null!=i?t:null,a.subscribedChannel=null!=i?i:t,t&&(a.channel=t.substring(0,t.lastIndexOf("-pnpres"))),i&&(a.subscription=i.substring(0,i.lastIndexOf("-pnpres"))),a.action=e.payload.action,a.state=e.payload.data,a.timetoken=r.publishTimetoken,a.occupancy=e.payload.occupancy,a.uuid=e.payload.uuid,a.timestamp=e.payload.timestamp,e.payload.join&&(a.join=e.payload.join),e.payload.leave&&(a.leave=e.payload.leave),e.payload.timeout&&(a.timeout=e.payload.timeout),n._listenerManager.announcePresence(a)}else{var s={channel:null,subscription:null};s.actualChannel=null!=i?t:null,s.subscribedChannel=null!=i?i:t,s.channel=t,s.subscription=i,s.timetoken=r.publishTimetoken,s.publisher=e.issuingClientId,e.userMetadata&&(s.userMetadata=e.userMetadata),n._config.cipherKey?s.message=n._crypto.decrypt(e.payload):s.message=e.payload,n._listenerManager.announceMessage(s)}}),this._region=t.metadata.region,this._startSubscribeLoop()}}},{key:"_stopSubscribeLoop",value:function(){this._subscribeCall&&("function"==typeof this._subscribeCall.abort&&this._subscribeCall.abort(),this._subscribeCall=null)}}]),e}();t.default=u,e.exports=t.default}(pn,pn.exports)),pn.exports}var Mn,xn={exports:{}};var On,zn,Ln,Rn,Kn,Un={},Fn={},Bn={},Hn={};function Gn(){return Kn||(Kn=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),i=U(sn()),r=U(cn()),o=U(Nn()),a=U(yn()),s=U((Mn||(Mn=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var o=e.networking,u=e.config,l=null,c=null,d={};t.getOperation()===r.default.PNTimeOperation||t.getOperation()===r.default.PNChannelGroupsOperation?l=arguments.length<=2?void 0:arguments[2]:(d=arguments.length<=2?void 0:arguments[2],l=arguments.length<=3?void 0:arguments[3]),"undefined"==typeof Promise||l||(c=i.default.createPromise());var f=t.validateParams(e,d);if(f)return l?l(s(f)):c?(c.reject(new a("Validation failed, check status for details",s(f))),c.promise):void 0;var p=t.prepareParams(e,d),h=function(e,t,n){return e.usePost&&e.usePost(t,n)?e.postURL(t,n):e.getURL(t,n)}(t,e,d),v=void 0,g={url:h,operation:t.getOperation(),timeout:t.getRequestTimeout(e)};p.uuid=u.UUID,p.pnsdk=function(e){if(e.sdkName)return e.sdkName;var t="PubNub-JS-"+e.sdkFamily;return e.partnerId&&(t+="-"+e.partnerId),t+"/"+e.getVersion()}(u),u.useInstanceId&&(p.instanceid=u.instanceId),u.useRequestId&&(p.requestid=n.default.createUUID()),t.isAuthSupported()&&u.getAuthKey()&&(p.auth=u.getAuthKey()),u.secretKey&&function(e,t,n){var r=e.config,o=e.crypto;n.timestamp=Math.floor((new Date).getTime()/1e3);var a=r.subscribeKey+"\n"+r.publishKey+"\n"+t+"\n";a+=i.default.signPamFromParams(n);var s=o.HMACSHA256(a);s=(s=s.replace(/\+/g,"-")).replace(/\//g,"_"),n.signature=s}(e,h,p);var y=function(n,i){if(n.error)l?l(n):c&&c.reject(new a("PubNub call failed, check status for details",n));else{var r=t.handleResponse(e,i,d);l?l(n,r):c&&c.fulfill(r)}};if(t.usePost&&t.usePost(e,d)){var m=t.postPayload(e,d);v=o.POST(p,m,g,y)}else v=t.useDelete&&t.useDelete()?o.DELETE(p,g,y):o.GET(p,g,y);return t.getOperation()===r.default.PNSubscribeOperation?v:c?c.promise:void 0};var n=o(an()),i=o(wn());o(sn());var r=o(Pn());function o(e){return e&&e.__esModule?e:{default:e}}var a=function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var i=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==_(t)&&"function"!=typeof t?e:t}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t));return i.name=i.constructor.name,i.status=n,i.message=t,i}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+_(t));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(e,Error),e}();function s(e){return(t={message:e}).type="validationError",t.error=!0,t;var t}e.exports=t.default}(xn,xn.exports)),xn.exports)),u=K(null),l=K(null),c=K(null),d=K(null),f=K(null),p=K(null),h=K(null),v=K(null),g=K(null),y=function(){if(On)return Un;On=1,Object.defineProperty(Un,"__esModule",{value:!0}),Un.getOperation=function(){return e.default.PNUnsubscribeOperation},Un.validateParams=function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},Un.getURL=function(e,n){var i=e.config,r=n.channels,o=void 0===r?[]:r,a=o.length>0?o.join(","):",";return"/v2/presence/sub-key/"+i.subscribeKey+"/channel/"+t.default.encodeString(a)+"/leave"},Un.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},Un.isAuthSupported=function(){return!0},Un.prepareParams=function(e,t){var n=t.channelGroups,i=void 0===n?[]:n,r={};return i.length>0&&(r["channel-group"]=i.join(",")),r},Un.handleResponse=function(){return{}};var e=n(Pn()),t=n(wn());function n(e){return e&&e.__esModule?e:{default:e}}return Un}(),m=K(y),b=K(null),S=function(){if(zn)return Fn;zn=1,Object.defineProperty(Fn,"__esModule",{value:!0}),Fn.getOperation=function(){return e.default.PNHeartbeatOperation},Fn.validateParams=function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},Fn.getURL=function(e,n){var i=e.config,r=n.channels,o=void 0===r?[]:r,a=o.length>0?o.join(","):",";return"/v2/presence/sub-key/"+i.subscribeKey+"/channel/"+t.default.encodeString(a)+"/heartbeat"},Fn.isAuthSupported=function(){return!0},Fn.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},Fn.prepareParams=function(e,t){var n=t.channelGroups,i=void 0===n?[]:n,r=t.state,o=void 0===r?{}:r,a=e.config,s={};return i.length>0&&(s["channel-group"]=i.join(",")),s.state=JSON.stringify(o),s.heartbeat=a.getPresenceTimeout(),s},Fn.handleResponse=function(){return{}};var e=n(Pn()),t=n(wn());function n(e){return e&&e.__esModule?e:{default:e}}return Fn}(),k=K(S),T=K(null),P=K(null),I=K(null),E=K(null),V=K(null),A=function(){if(Ln)return Bn;Ln=1,Object.defineProperty(Bn,"__esModule",{value:!0});var e="function"==typeof Symbol&&"symbol"===_(Symbol.iterator)?function(e){return _(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":_(e)};Bn.getOperation=function(){return t.default.PNPublishOperation},Bn.validateParams=function(e,t){var n=e.config,i=t.message;return t.channel?i?n.subscribeKey?void 0:"Missing Subscribe Key":"Missing Message":"Missing Channel"},Bn.usePost=function(e,t){var n=t.sendByPost;return void 0!==n&&n},Bn.getURL=function(e,t){var i=e.config,o=t.channel,a=r(e,t.message);return"/publish/"+i.publishKey+"/"+i.subscribeKey+"/0/"+n.default.encodeString(o)+"/0/"+n.default.encodeString(a)},Bn.postURL=function(e,t){var i=e.config,r=t.channel;return"/publish/"+i.publishKey+"/"+i.subscribeKey+"/0/"+n.default.encodeString(r)+"/0"},Bn.getRequestTimeout=function(e){return e.config.getTransactionTimeout()},Bn.isAuthSupported=function(){return!0},Bn.postPayload=function(e,t){return r(e,t.message)},Bn.prepareParams=function(t,n){var i=n.meta,r=n.replicate,o=void 0===r||r,a=n.storeInHistory,s=n.ttl,u={};return null!=a&&(u.store=a?"1":"0"),s&&(u.ttl=s),!1===o&&(u.norep="true"),i&&"object"===(void 0===i?"undefined":e(i))&&(u.meta=JSON.stringify(i)),u},Bn.handleResponse=function(e,t){return{timetoken:t[2]}};var t=i(Pn()),n=i(wn());function i(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var n=e.crypto,i=e.config,r=JSON.stringify(t);return i.cipherKey&&(r=n.encrypt(r),r=JSON.stringify(r)),r}return Bn}(),C=K(A),D=K(null),w=K(null),N=K(null),M=K(In()),x=function(){if(Rn)return Hn;Rn=1,Object.defineProperty(Hn,"__esModule",{value:!0}),Hn.getOperation=function(){return e.default.PNSubscribeOperation},Hn.validateParams=function(e){if(!e.config.subscribeKey)return"Missing Subscribe Key"},Hn.getURL=function(e,n){var i=e.config,r=n.channels,o=void 0===r?[]:r,a=o.length>0?o.join(","):",";return"/v2/subscribe/"+i.subscribeKey+"/"+t.default.encodeString(a)+"/0"},Hn.getRequestTimeout=function(e){return e.config.getSubscribeTimeout()},Hn.isAuthSupported=function(){return!0},Hn.prepareParams=function(e,t){var n=e.config,i=t.channelGroups,r=void 0===i?[]:i,o=t.timetoken,a=t.filterExpression,s=t.region,u={heartbeat:n.getPresenceTimeout()};return r.length>0&&(u["channel-group"]=r.join(",")),a&&a.length>0&&(u["filter-expr"]=a),o&&(u.tt=o),s&&(u.tr=s),u},Hn.handleResponse=function(e,t){var n=[];t.m.forEach(function(e){var t={publishTimetoken:e.p.t,region:e.p.r},i={shard:parseInt(e.a,10),subscriptionMatch:e.b,channel:e.c,payload:e.d,flags:e.f,issuingClientId:e.i,subscribeKey:e.k,originationTimetoken:e.o,userMetadata:e.u,publishMetaData:t};n.push(i)});var i={timetoken:t.t.t,region:t.t.r};return{messages:n,metadata:i}};var e=n(Pn()),t=n(wn());function n(e){return e&&e.__esModule?e:{default:e}}return Hn}(),O=K(x),z=U(Pn()),L=U(gn()),R=U(an());function K(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function U(e){return e&&e.__esModule?e:{default:e}}var F=function(){function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e);var y=t.db,S=t.networking,_=this._config=new i.default({setup:t,db:y}),A=new r.default({config:_});S.init(_);var x={config:_,networking:S,crypto:A},z=s.default.bind(this,x,M),L=s.default.bind(this,x,m),R=s.default.bind(this,x,k),K=s.default.bind(this,x,P),U=s.default.bind(this,x,O),F=this._listenerManager=new a.default,B=new o.default({timeEndpoint:z,leaveEndpoint:L,heartbeatEndpoint:R,setStateEndpoint:K,subscribeEndpoint:U,crypto:x.crypto,config:x.config,listenerManager:F});this.addListener=F.addListener.bind(F),this.removeListener=F.removeListener.bind(F),this.removeAllListeners=F.removeAllListeners.bind(F),this.channelGroups={listGroups:s.default.bind(this,x,d),listChannels:s.default.bind(this,x,f),addChannels:s.default.bind(this,x,u),removeChannels:s.default.bind(this,x,l),deleteGroup:s.default.bind(this,x,c)},this.push={addChannels:s.default.bind(this,x,p),removeChannels:s.default.bind(this,x,h),deleteDevice:s.default.bind(this,x,g),listChannels:s.default.bind(this,x,v)},this.hereNow=s.default.bind(this,x,I),this.whereNow=s.default.bind(this,x,b),this.getState=s.default.bind(this,x,T),this.setState=B.adaptStateChange.bind(B),this.grant=s.default.bind(this,x,V),this.audit=s.default.bind(this,x,E),this.publish=s.default.bind(this,x,C),this.fire=function(e,t){return e.replicate=!1,e.storeInHistory=!1,n.publish(e,t)},this.history=s.default.bind(this,x,D),this.deleteMessages=s.default.bind(this,x,w),this.fetchMessages=s.default.bind(this,x,N),this.time=z,this.subscribe=B.adaptSubscribeChange.bind(B),this.presence=B.adaptPresenceChange.bind(B),this.unsubscribe=B.adaptUnsubscribeChange.bind(B),this.disconnect=B.disconnect.bind(B),this.reconnect=B.reconnect.bind(B),this.destroy=function(e){B.unsubscribeAll(e),B.disconnect()},this.stop=this.destroy,this.unsubscribeAll=B.unsubscribeAll.bind(B),this.getSubscribedChannels=B.getSubscribedChannels.bind(B),this.getSubscribedChannelGroups=B.getSubscribedChannelGroups.bind(B),this.encrypt=A.encrypt.bind(A),this.decrypt=A.decrypt.bind(A),this.getAuthKey=x.config.getAuthKey.bind(x.config),this.setAuthKey=x.config.setAuthKey.bind(x.config),this.setCipherKey=x.config.setCipherKey.bind(x.config),this.getUUID=x.config.getUUID.bind(x.config),this.setUUID=x.config.setUUID.bind(x.config),this.getFilterExpression=x.config.getFilterExpression.bind(x.config),this.setFilterExpression=x.config.setFilterExpression.bind(x.config),this.setHeartbeatInterval=x.config.setHeartbeatInterval.bind(x.config),S.hasModule("proxy")&&(this.setProxy=function(e){x.config.setProxy(e),n.reconnect()})}return n(e,[{key:"getVersion",value:function(){return this._config.getVersion()}},{key:"networkDownDetected",value:function(){this._listenerManager.announceNetworkDown(),this._config.restore?this.disconnect():this.destroy(!0)}},{key:"networkUpDetected",value:function(){this._listenerManager.announceNetworkUp(),this.reconnect()}}],[{key:"generateUUID",value:function(){return R.default.createUUID()}}]),e}();F.OPERATIONS=z.default,F.CATEGORIES=L.default,t.default=F,e.exports=t.default}(tn,tn.exports)),tn.exports}var Wn,jn={exports:{}};var qn,Jn,Yn,Xn,Qn,Zn,$n,ei,ti,ni,ii,ri,oi,ai,si,ui,li,ci={exports:{}},di={},fi=(Yn||(Yn=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n=s(Gn()),i=s((Wn||(Wn=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}();r(sn());var i=r(gn());function r(e){return e&&e.__esModule?e:{default:e}}var o=function(){function e(t){var n=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._modules={},Object.keys(t).forEach(function(e){n._modules[e]=t[e].bind(n)})}return n(e,[{key:"init",value:function(e){this._config=e,this._maxSubDomain=20,this._currentSubDomain=Math.floor(Math.random()*this._maxSubDomain),this._providedFQDN=(this._config.secure?"https://":"http://")+this._config.origin,this._coreParams={},this.shiftStandardOrigin()}},{key:"nextOrigin",value:function(){return-1===this._providedFQDN.indexOf("pubsub.")?this._providedFQDN:(this._currentSubDomain=this._currentSubDomain+1,this._currentSubDomain>=this._maxSubDomain&&(this._currentSubDomain=1),e=this._currentSubDomain.toString(),this._providedFQDN.replace("pubsub","ps"+e));var e}},{key:"hasModule",value:function(e){return e in this._modules}},{key:"shiftStandardOrigin",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this._standardOrigin=this.nextOrigin(e),this._standardOrigin}},{key:"getStandardOrigin",value:function(){return this._standardOrigin}},{key:"POST",value:function(e,t,n,i){return this._modules.post(e,t,n,i)}},{key:"GET",value:function(e,t,n){return this._modules.get(e,t,n)}},{key:"DELETE",value:function(e,t,n){return this._modules.del(e,t,n)}},{key:"_detectErrorCategory",value:function(e){if("ENOTFOUND"===e.code)return i.default.PNNetworkIssuesCategory;if("ECONNREFUSED"===e.code)return i.default.PNNetworkIssuesCategory;if("ECONNRESET"===e.code)return i.default.PNNetworkIssuesCategory;if("EAI_AGAIN"===e.code)return i.default.PNNetworkIssuesCategory;if(0===e.status||e.hasOwnProperty("status")&&void 0===e.status)return i.default.PNNetworkIssuesCategory;if(e.timeout)return i.default.PNTimeoutCategory;if("ETIMEDOUT"===e.code)return i.default.PNNetworkIssuesCategory;if(e.response){if(e.response.badRequest)return i.default.PNBadRequestCategory;if(e.response.forbidden)return i.default.PNAccessDeniedCategory}return i.default.PNUnknownCategory}}]),e}();t.default=o,e.exports=t.default}(jn,jn.exports)),jn.exports)),r=(qn||(qn=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.default={get:function(e){try{return localStorage.getItem(e)}catch(e){return null}},set:function(e,t){try{return localStorage.setItem(e,t)}catch(e){return null}}},e.exports=t.default}(ci,ci.exports)),ci.exports),o=s(r),a=function(){if(Jn)return di;function e(e){var t=[];for(var n in e)if(e.hasOwnProperty(n)){var i=e[n];null!=i&&t.push(encodeURIComponent(n)+"="+encodeURIComponent(i))}return t.join("&")}function t(e,t,n,i,r,o){var a=this,s=new XMLHttpRequest,u=t+(n?(t.indexOf("?")>=0?"&":"?")+n:""),l=!1,c=!1;function d(e,t){if(!c&&!l){c=!0;var n={};return n.error=null!==e,n.operation=r.operation,s.status&&(n.statusCode=s.status),e?(n.errorData=e,n.category=a._detectErrorCategory(e),o(n,null)):o(n,t)}}s.open(e,u,!0),s.timeout=r.timeout,s.onreadystatechange=function(){if(4===s.readyState){var e=s.status;if(e>=200&&e<300){var t;try{t=JSON.parse(s.responseText)}catch(t){return d({status:e,response:{}},null)}return t&&1===t.error&&t.status&&t.message&&t.service?d({status:t.status,response:{}},null):d(null,t)}return d(0===e?{status:0}:{status:e,response:{badRequest:400===e,forbidden:403===e}},null)}},s.ontimeout=function(){d({timeout:!0},null)},s.onerror=function(){d({status:0},null)};var f=null;null!=i&&(f="string"==typeof i?i:JSON.stringify(i),s.setRequestHeader("Content-Type","application/json"));try{s.send(f)}catch(e){d({status:0},null)}return{abort:function(){l=!0;try{s.abort()}catch(e){}}}}return Jn=1,Object.defineProperty(di,"__esModule",{value:!0}),di.get=function(n,i,r){return t.call(this,"GET",this.getStandardOrigin()+i.url,e(n),null,i,r)},di.post=function(n,i,r,o){return t.call(this,"POST",this.getStandardOrigin()+r.url,e(n),i,r,o)},di.del=function(n,i,r){return t.call(this,"DELETE",this.getStandardOrigin()+i.url,e(n),null,i,r)},di}();function s(e){return e&&e.__esModule?e:{default:e}}function u(e){if(!navigator||!navigator.sendBeacon)return!1;navigator.sendBeacon(e)}var l=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=e.listenToBrowserNetworkEvents,r=void 0===n||n;e.db=o.default,e.sdkFamily="Web",e.networking=new i.default({del:a.del,get:a.get,post:a.post,sendBeacon:u});var s=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==_(t)&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return r&&(window.addEventListener("offline",function(){s.networkDownDetected()}),window.addEventListener("online",function(){s.networkUpDetected()})),s}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+_(t));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),t}(n.default);t.default=l,e.exports=t.default}(en,en.exports)),en.exports),pi=t(fi),hi=["PNAccessDeniedCategory","PNTimeoutCategory","PNNetworkIssuesCategory","PNBadRequestCategory","PNMalformedResponseCategory","PNDecryptionErrorCategory","PNTLSConnectionFailedCategory","PNTLSUntrustedCertificateCategory","PNUnexpectedDisconnectCategory","PNNetworkDownCategory","PNNetworkUpCategory"],vi=function(){function e(t){var n;return o(this,e),(n=r(this,e,[t])).pubnub=void 0,n.channelId=void 0,n._synchronousPublish=!1,n.generateChannel(),n}return p(e,Ft),s(e,[{key:"connect",value:function(e){var t=this;VizbeeSDK.logger.debug("PubnubSync::appId - "+this.appConfig.appId+" , deviceId - "+this.appConfig.deviceId),void 0===this.pubnub&&(VizbeeSDK.logger.debug("PubnubSync::connect - initializing pubnub ..."),this.pubnub=new pi({publishKey:this.appConfig.pub_key,subscribeKey:this.appConfig.sub_key,ssl:!0}),this.filterOwnMessages());var n=5;this.pubnub.addListener({status:function(i){"PNConnectedCategory"!==i.category&&"PNReconnectedCategory"!==i.category&&"PNNetworkUpCategory"!==i.category||(n=5),"PNConnectedCategory"===i.category?(t.dispatchReceive(new Bt(Ht.SYNC_CONNECT,{})),e(!0)):hi.indexOf(i.category)>=0&&(VizbeeSDK.logger.error("PubnubSync.Connect - PUBNUB.subscribe() error = ",i," with retries = ",n),n>0&&(n--,t.subscribePubnub()))},message:this.messageHandler.bind(this),presence:function(e){}}),this.subscribePubnub()}},{key:"disconnect",value:function(){this.pubnub&&this.channelId&&(VizbeeSDK.logger.debug("PubnubSync::disconnect - invoking disconnect"),this.pubnub.unsubscribe({channels:[this.channelId]}),this.pubnub=void 0,b(e,"disconnect",this)([]))}},{key:"send",value:function(e){if(this.pubnub&&this.channelId){if(this._synchronousPublish)return void this.sendSynchronously(e);this.pubnub.publish({message:e,channel:this.channelId,sendByPost:!1,storeInHistory:!1,meta:{uuid:this.pubnub.getUUID()}},function(e,t){e.error&&VizbeeSDK.logger.error("CommManager:CommManager - PUBNUB.publish() error")})}}},{key:"enableSynchronousPublish",value:function(){this._synchronousPublish=!0}},{key:"sendSynchronously",value:function(e){if(this.pubnub&&this.channelId)try{var t=this.appConfig.pub_key,n=this.appConfig.sub_key,i=this.pubnub.getUUID(),r="?uuid="+encodeURIComponent(i)+"&store=0&meta="+encodeURIComponent(JSON.stringify({uuid:i})),o="https://ps.pndsn.com/publish/"+t+"/"+n+"/0/"+this.channelId+"/0",a=JSON.stringify(e),s=o+"/"+encodeURIComponent(a)+r;if("function"==typeof fetch)return fetch(s,{method:"GET",keepalive:!0,mode:"no-cors"}).catch(function(){}),void VizbeeSDK.logger.debug("PubnubSync::sendSynchronously - sent via keepalive fetch");if("undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(o+r,a))return void VizbeeSDK.logger.debug("PubnubSync::sendSynchronously - sent via sendBeacon");var u=new XMLHttpRequest;u.open("GET",s,!1),u.send(),VizbeeSDK.logger.debug("PubnubSync::sendSynchronously - sent via synchronous XHR")}catch(e){VizbeeSDK.logger.error("PubnubSync::sendSynchronously - error publishing on teardown",e)}}},{key:"generateChannel",value:function(){this.appConfig&&(this.channelId=(""+$t(this.appConfig.appId+":"+this.appConfig.deviceId)).toLowerCase()),VizbeeSDK.logger.info("PubnubSync::generateChannel",this.channelId)}},{key:"subscribePubnub",value:function(){VizbeeSDK.logger.debug("PubnubSync::subscribePubnub - invoking pubnub subscribe"),this.pubnub&&this.channelId&&(VizbeeSDK.logger.debug("PubnubSync::subscribePubnub - subscribing..."),this.pubnub.subscribe({channels:[this.channelId]}))}},{key:"filterOwnMessages",value:function(){if(this.pubnub){var e="uuid != '";e=e.concat(this.pubnub.getUUID()).concat("'"),this.pubnub.setFilterExpression(e)}}},{key:"messageHandler",value:function(e,t,n){VizbeeSDK.logger.verbose("PubnubSync::messageHandler",e);var i=e?e.message:{};Gt.verifyDeviceId(),this.dispatchReceive(new Bt(Ht.SYNC_MESSAGE,i))}}])}(),gi=function(){function e(t){var n;return o(this,e),(n=r(this,e,[t])).syncInstances=[],n}return p(e,Ft),s(e,[{key:"connect",value:function(e){var t,n=u(this.syncInstances);try{for(n.s();!(t=n.n()).done;)t.value.connect(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"disconnect",value:function(){var e,t=u(this.syncInstances);try{for(t.s();!(e=t.n()).done;)e.value.disconnect()}catch(e){t.e(e)}finally{t.f()}}},{key:"send",value:function(e){var t,n=u(this.syncInstances);try{for(n.s();!(t=n.n()).done;)t.value.send(e)}catch(e){n.e(e)}finally{n.f()}}},{key:"addSyncInstance",value:function(e){this.syncInstances.push(e),this.setReceiveListener(e)}},{key:"setReceiveListener",value:function(e){var t=this;e.onReceive=function(e){t.dispatchReceive.call(t,e)}}}])}(),yi=function(){function e(t,n){var i;if(o(this,e),!(t instanceof Ft))throw new TypeError("BaseSyncExtension::constructor() - classToExtend must be instance of BaseSync.");return(i=r(this,e,[n])).extendedClass=t,i.extendedClass.onReceive=function(e){i.onReceiveHandler.call(i,e)},i}return p(e,Ft),s(e,[{key:"connect",value:function(e){this.extendedClass.connect(e)}},{key:"disconnect",value:function(){this.extendedClass.disconnect()}},{key:"send",value:function(e){VizbeeSDK.logger.verbose(this._getLogPrefix("send")+" - FORWARDING OUT send message",e),this.extendedClass.send(e)}},{key:"baseSync",get:function(){return this.extendedClass instanceof e?this.extendedClass.baseSync:this.extendedClass}},{key:"onReceiveHandler",value:function(e){if(e&&e.data){var t=void 0;e.type===Ht.SYNC_MESSAGE?(t=this.handleSyncReceiveEvent(e))?(VizbeeSDK.logger.verbose(this._getLogPrefix("onReceive")+" - FORWARDING IN sync receive event",t),this.dispatchReceive.call(this,t)):VizbeeSDK.logger.warn(this._getLogPrefix("onReceive")+" - DROPPING receive event",e):(t=this.handleNonSyncReceiveEvent(e))?(VizbeeSDK.logger.verbose(this._getLogPrefix("onReceive")+" - FORWARDING IN non-sync receive event",t),this.dispatchReceive.call(this,t)):VizbeeSDK.logger.warn(this._getLogPrefix("onReceive")+" - DROPPING non-sync receive event",e)}else VizbeeSDK.logger.warn(this._getLogPrefix("onReceive")+" - NULL receive event",e)}},{key:"handleSyncReceiveEvent",value:function(e){return e}},{key:"handleNonSyncReceiveEvent",value:function(e){return e}},{key:"getClassName",value:function(){return this.constructor.name}},{key:"_getLogPrefix",value:function(e){return(this.getClassName()+"::"+e+" ").slice(0,40)}}])}(),mi=function(){function e(t,n){var i;return o(this,e),(i=r(this,e,[t,n])).txIdMap={},i}return p(e,yi),s(e,[{key:"handleSyncReceiveEvent",value:function(e){if(this.isValidMessage(e.data))return e}},{key:"isValidMessage",value:function(e){var t,n,i,r,o=!1;if(!e)return VizbeeSDK.logger.warn("SanitizeHeaderRecvExtension:isValidMessage - invalid message",e),o;if(!te.isObject(e.h))return VizbeeSDK.logger.warn("SanitizeHeaderRecvExtension:isValidMessage - invalid message head",e),o;if(t=e.h.id,n=e.h.tx,i=e.h.ss,!te.isString(t))return VizbeeSDK.logger.error("SanitizeHeaderRecvExtension:isValidMessage - invalid message id",t,e),o;if(!te.isNumber(n))return VizbeeSDK.logger.error("SanitizeHeaderRecvExtension:isValidMessage - invalid message tx",n,e),o;if(r=t,i&&(r=i+r),0===n)this.txIdMap[r]=n;else{if(this.txIdMap[r]>=n)return VizbeeSDK.logger.warn("SanitizeHeaderRecvExtension:isValidMessage - duplicate message",n,this.txIdMap[r]),o;this.txIdMap[r]=n}return!0}}])}(),bi=function(){function e(t,n){return o(this,e),r(this,e,[t,n])}return p(e,yi),s(e,[{key:"handleSyncReceiveEvent",value:function(e){if(this.isValidMessage(e.data))return this.sanitize(e)}},{key:"isValidMessage",value:function(e){var t=!1,n=e.b;if(!te.isObject(n))return t;if(!te.isObject(n.cmd))return t;if(!te.isString(n.cmd.name)||!te.isString(n.cmd.ns))return t;if("start_video"==n.cmd.name){var i=n.vinfo;if(!te.isObject(i))return t;if(!te.isString(i.id)&&!te.isString(i.url))return t}return!0}},{key:"sanitize",value:function(e){var t=e.data,n=t.b.cmd;return n.name=n.name.toLowerCase(),n.ns=n.ns.toLowerCase(),n.type=n.type?n.type.toLowerCase():null,"exit"==n.name&&(n.param=n.param.toLowerCase()),t.b.cmd=n,e.data=t,e}}])}(),Si=function(){function e(t,n){return o(this,e),r(this,e,[t,n])}return p(e,yi),s(e,[{key:"getActiveSenders",value:function(){throw new TypeError("BaseSyncWithPresence::getSenders() - Abstract method.")}},{key:"getActiveSendersCount",value:function(){throw new TypeError("BaseSyncWithPresence::getActiveSendersCount() - Abstract method.")}}])}(),_i=function(){function e(t,n){if(o(this,e),!(t instanceof Si))throw new TypeError("BaseSyncWithPresenceExtension::constructor() - classToExtend must be instance of BaseSyncWithPresence.");return r(this,e,[t,n])}return p(e,Si),s(e,[{key:"getActiveSenders",value:function(){return this.extendedClass.getActiveSenders()}},{key:"getActiveSendersCount",value:function(){return this.extendedClass.getActiveSendersCount()}}])}(),ki=function(){function e(){o(this,e)}return s(e,null,[{key:"decodeVideoInfo",value:function(e){if(e&&e.vinfo){var t={islive:!1,starttime:0,isContinuedVideo:!1};if(t.id=e.vinfo.id,t.videourl=e.vinfo.url,e.vinfo.islive&&(t.islive=e.vinfo.islive),e.vinfo.deeplink&&(t.deeplink=e.vinfo.deeplink),!te.isUndefined(e.cmd)){var n=0;te.isUndefined(e.cmd.param)||(n=parseInt(e.cmd.param,10),isNaN(n)&&(n=0),n<0&&(n=0)),t.starttime=n}if(e.vinfoext){if(e.vinfoext.cuepoints&&(t.cuepoints=e.vinfoext.cuepoints),e.vinfoext.title&&(t.title=e.vinfoext.title),e.vinfoext.subtitle&&(t.subtitle=e.vinfoext.subtitle),e.vinfoext.tracks){var i=te.get(e,["vinfoext","tracks","currentAudioTrack"]);i&&(t.preferredTracks={},t.preferredTracks.currentAudioTrack={label:i.displayName,lang:i.languageCode,id:i.screenTrackId})}e.vinfoext.imgurl&&(t.imgurl=e.vinfoext.imgurl),e.vinfoext.desc&&(t.desc=e.vinfoext.desc),e.vinfoext.customstreaminfo&&(t.customstreaminfo=e.vinfoext.customstreaminfo),e.vinfoext.custommetadata&&(t.custommetadata=e.vinfoext.custommetadata),e.vinfoext.drmtype&&(t.drmtype=e.vinfoext.drmtype),e.vinfoext.protocoltype&&(t.protocoltype=e.vinfoext.protocoltype),e.vinfoext.drmlicenseurl&&(t.drmlicenseurl=e.vinfoext.drmlicenseurl),e.vinfoext.drmcustomdata&&(t.drmcustomdata=e.vinfoext.drmcustomdata)}return t}}},{key:"encodeVideoInfo",value:function(e){if(e){var t={};return t.vinfo={id:e.id,islive:e.islive,url:e.videourl},t.vinfoext={videostarttime:e.starttime||0,imgurl:e.imgurl?e.imgurl:"",title:e.title?e.title:"",subtitle:e.subtitle?e.subtitle:"",desc:e.desc?e.desc:"",isContinuedVideo:null!=e.isContinuedVideo&&e.isContinuedVideo,customstreaminfo:e.customstreaminfo?e.customstreaminfo:{},custommetadata:e.custommetadata?e.custommetadata:{},drmtype:e.drmtype?e.drmtype:"NONE",drmlicenseurl:e.drmlicenseurl?e.drmlicenseurl:"",drmcustomdata:e.drmcustomdata?e.drmcustomdata:{},cuepoints:e.cuepoints?e.cuepoints:[]},t}}},{key:"addInfoFromHeader",value:function(e,t){if(!e||!t)return e;var n=te.clone(t);return e.senderInfo=te.omit(n,["tx","ss"]),e}},{key:"encodeEventCmd",value:function(e){if(e){var t={cmd:{ns:"video",type:"req",name:"event",param:""},einfo:{type:e.type,data:e.data}};return{type:Ht.SYNC_MESSAGE,data:{h:{},b:t}}}}},{key:"encodeStartVideoCmd",value:function(e){if(e){e.starttime=e.starttime||0;var t={cmd:{ns:"video",type:"req",name:"start_video",param:e.starttime},internal:{videoInfo:e,startVideoSource:"queue_manager"}};return{type:Ht.SYNC_MESSAGE,data:{h:{},b:t}}}}},{key:"encodeVideoStatus",value:function(t){if(t){var n={cmd:{name:"status",ns:"video",type:"upd"},vstatus:{du:0,id:t.id,po:-1,st:"BUFFERING",vol:100,cc:0,tr:{},er:{}}};return te.extend(n,e.encodeVideoInfo(t))}}}])}(),Ti=function(){function e(t,n){return o(this,e),r(this,e,[t,n])}return p(e,_i),s(e,[{key:"handleSyncReceiveEvent",value:function(e){if("start_video"==e.data.b.cmd.name){var t=ki.decodeVideoInfo(e.data.b);t&&(t=ki.addInfoFromHeader(t,e.data.h)),e.data.b.internal={videoInfo:t,startVideoSource:"default",queueInfo:this._createQueueInfo(e.data)}}return e}},{key:"_createQueueInfo",value:function(e){var t={id:"default",name:"default",description:"default",startIndex:0,items:[]},n=ki.decodeVideoInfo(e.b);return n&&(n=ki.addInfoFromHeader(n,e.h)),t.items.push(n),t}}])}(),Pi=function(){function e(t,n){var i;return o(this,e),VizbeeSDK.logger.d("UpdatePresenceRecvExtension","constructor"),(i=r(this,e,[t,n])).currentAppId=n.appId,i._sentFirstHelloCheck=!1,i._sentSecondHelloCheck=!1,i._senderMap={},i._presenceIntervalTimer=void 0,i._previousSenderMapCount=0,i._startPresenceTimer(),i}return p(e,Si),s(e,[{key:"getActiveSenders",value:function(){return this._senderMap}},{key:"getActiveSendersCount",value:function(){return Object.keys(this._senderMap||{}).length}},{key:"disconnect",value:function(){VizbeeSDK.logger.d("UpdatePresenceRecvExtension","disconnect"),this._senderMap={},this._previousSenderMapCount=0,this._stopPresenceTimer(),b(e,"disconnect",this)([])}},{key:"handleSyncReceiveEvent",value:function(e){var t=e.data;return"exit"===t.b.cmd.name?this._senderMap=te.omit(this._senderMap,te.keys(this._senderMap).filter(function(e){return e===t.h.id})):(this._sentFirstHelloCheck=!1,this._sentSecondHelloCheck=!1,this._senderMap[t.h.id]=t.h,this._senderMap[t.h.id].appId=this.currentAppId,this._senderMap[t.h.id].lastMsgReceivedTimeInMs=Date.now(),this._startPresenceTimer()),e}},{key:"_startPresenceTimer",value:function(){var e=this;this._stopPresenceTimer(),this._presenceIntervalTimer=window.setInterval(function(){e._updatePresence()},1e3)}},{key:"_stopPresenceTimer",value:function(){window.clearInterval(this._presenceIntervalTimer),this._presenceIntervalTimer=void 0}},{key:"_checkForSenders",value:function(){!this._sentFirstHelloCheck&&this._shouldSendHelloCheckMessage(15e3)?(this._sendHelloCheckMessage(),this._sentFirstHelloCheck=!0):!this._sentSecondHelloCheck&&this._shouldSendHelloCheckMessage(25e3)&&(this._sendHelloCheckMessage(),this._sentSecondHelloCheck=!0)}},{key:"_shouldSendHelloCheckMessage",value:function(e){var t=this;if(0==Object.keys(this._senderMap||{}).length)return!1;var n=Date.now(),i=te.keys(this._senderMap).filter(function(i){return t._senderMap[i]&&null!=t._senderMap[i].lastMsgReceivedTimeInMs&&n-t._senderMap[i].lastMsgReceivedTimeInMs>e});return Object.keys(i).length>0}},{key:"_sendHelloCheckMessage",value:function(){this.dispatchReceive(new Bt(Ht.SYNC_MESSAGE,{b:{cmd:{ns:"video",name:"hello",type:"int"},hstatus:{id:this.appConfig.deviceId,type:"SCREEN",vip:"false"}}}))}},{key:"_updatePresence",value:function(){var e=this;this._checkForSenders();var t=Date.now();if(this._senderMap=te.omit(this._senderMap,te.keys(this._senderMap).filter(function(n){return e._senderMap[n]&&null!=e._senderMap[n].lastMsgReceivedTimeInMs&&t-e._senderMap[n].lastMsgReceivedTimeInMs>3e4})),0==Object.keys(this._senderMap||{}).length)return VizbeeSDK.logger.d("UpdatePresenceRecvExtension","_updatePresence","there are no senders now"),this._stopPresenceTimer(),this.dispatchReceive(new Bt(Ht.SYNC_PRESENCE,this._senderMap)),void(this._previousSenderMapCount=0);var n=Object.keys(this._senderMap).length;n!=this._previousSenderMapCount&&(VizbeeSDK.logger.d("UpdatePresenceRecvExtension","_updatePresence","there is a change in the senders connected"),this._previousSenderMapCount=n,this.dispatchReceive(new Bt(Ht.SYNC_PRESENCE,this._senderMap)))}}])}(),Ii=function(){function e(t,n){return o(this,e),VizbeeSDK.logger.debug("ExitOnLastMessageRecvExtension::constructor()"),r(this,e,[t,n])}return p(e,_i),s(e,[{key:"handleSyncReceiveEvent",value:function(e){var t=e.data;if(VizbeeSDK.logger.verbose("ExitOnLastMessageRecvExtension::onReceiveHandler() ".concat(this.appConfig.appId),t),VizbeeSDK.logger.verbose("ExitOnLastMessageRecvExtension::onReceiveHandler getActiveSendersCount - cmd ",this.getActiveSendersCount(),t.b?t.b.cmd.name:""),!t.b||"exit"!==t.b.cmd.name)return e;"user_invoked_disconnect"===t.b.cmd.param&&0==this.getActiveSendersCount()&&this.appConfig.features&&this.appConfig.features.shouldExitOnLastSender&&(VizbeeSDK.logger.debug("ExitOnLastMessageRecvExtension::onReceiveHandler getActiveSendersCount is zero - going to exit the receiver app"),VizbeeTV.tv.exit())}}])}(),Ei=function(){function e(t,n){var i;return o(this,e),(i=r(this,e,[t,n])).tx=0,i.sessionId=i.createTimestamp(),i}return p(e,_i),s(e,[{key:"send",value:function(t){b(e,"send",this)([this.createMessage(null,t)])}},{key:"createMessage",value:function(e,t){return(t=t||{}).vers=1,{h:e=te.extend(this.createHeader(),e),b:t}}},{key:"createHeader",value:function(){return this.tx++,{tx:this.tx,id:this.appConfig.senderId||this.appConfig.deviceId,ss:this.sessionId,app:this.appConfig.appId,ssinfo:this.getSenderSessionInfo()}}},{key:"createTimestamp",value:function(){var e=new Date;return e.getFullYear()+":"+("0"+(e.getMonth()+1)).slice(-2)+":"+("0"+e.getDate()).slice(-2)+":"+("0"+e.getHours()).slice(-2)+":"+("0"+e.getMinutes()).slice(-2)+":"+("0"+e.getSeconds()).slice(-2)+":"+("0"+e.getMilliseconds()).slice(-3)}},{key:"getSenderSessionInfo",value:function(){return{SCREEN_IDFA:this.appConfig.screenIdfa,SCREEN_IDFV:this.appConfig.screenIdfv,SCREEN_DEVICE_TYPE:this.appConfig.screenDeviceType,SCREEN_DEVICE_ID:this.appConfig.screenDeviceId,SCREEN_DEVICE_FRIENDLYNAME:this.appConfig.screenFriendlyName}}}])}(),Vi=function(){function e(t,n){var i;return o(this,e),VizbeeSDK.logger.debug("FilterMessageSendExtension::constructor()"),(i=r(this,e,[t,n])).shouldFilterAllMessagesOnLastSenderExit=n&&n.features&&n.features.shouldFilterAllMessagesOnLastSenderExit,i}return p(e,_i),s(e,[{key:"send",value:function(t){if(t&&t.cmd){var n=this.getActiveSendersCount();if(this.shouldFilterAllMessagesOnLastSenderExit&&n<=0)VizbeeSDK.logger.verbose("FilterMessageSendExtension::send filtering all messages as senders are not available and shouldFilterAllMessagesOnLastSenderExit is set");else{if("status"==t.cmd.name)return t.vstatus&&-1!=["FINISHED","INTERRUPTED","FAILED"].indexOf(t.vstatus.st)?(VizbeeSDK.logger.debug("FilterMessageSendExtension::send message.vstatus.st: ".concat(t.vstatus.st)),void b(e,"send",this)([t])):void(0!==n?b(e,"send",this)([t]):VizbeeSDK.logger.verbose("FilterMessageSendExtension::send senders not available: MESSAGE NOT SENT",this.getActiveSendersCount(),t));b(e,"send",this)([t])}}else b(e,"send",this)([t])}}])}(),Ai=["BUFFERING","PLAYING","PAUSED_BY_USER","INTERRUPTED","FINISHED","FAILED"],Ci=function(){function e(t,n){var i;return o(this,e),(i=r(this,e,[t,n])).appConfig=n,i.shouldSupportLiveDVR=te.get(n,["features","shouldSupportLiveDVR"],!1),i.liveDVRMinBufferInMs=te.get(n,["features","liveDVRMinBufferInMs"],3e5),i}return p(e,_i),s(e,[{key:"send",value:function(t){if(t&&t.cmd){var n=t;"status"==t.cmd.name&&(n=this.interceptVideoStatus(t)),b(e,"send",this)([n])}else b(e,"send",this)([t])}},{key:"interceptVideoStatus",value:function(e){return Ai.includes(e.vstatus.st)&&e.vinfo.islive&&(e.vinfoext||(e.vinfoext={}),!0===e.vinfoext.isdvrsupported||(!this.shouldSupportLiveDVR||e.vstatus.du<this.liveDVRMinBufferInMs?(e.vinfoext.isdvrsupported=!1,e.vstatus.po=-1,e.vstatus.du=0):e.vinfoext.isdvrsupported=!0)),e}}])}(),Di=function(){return s(function e(){o(this,e)},null,[{key:"setItem",value:function(e,t,n,i,r,o,a){if(e)if("undefined"!=typeof Storage)vizbee.logger.debug("StorageUtil::setItem - Storage supported!"),"session"==n?(vizbee.logger.debug("StorageUtil::setItem - storing in session!"),sessionStorage.setItem(e,t)):(vizbee.logger.debug("StorageUtil::setItem - storing in local!"),localStorage.setItem(e,t));else{if(vizbee.logger.debug("StorageUtil::setItem - Storage NOT supported!"),"session"==n)return;vizbee.logger.debug("StorageUtil::setItem - storing in cookies!"),se.docCookies.setItem(e,t,i,r,o,a)}}},{key:"getItem",value:function(e,t){if(e){if("undefined"!=typeof Storage)return vizbee.logger.debug("StorageUtil::getItem - Storage supported!"),"session"==t?(vizbee.logger.debug("StorageUtil::getItem - getting from session!"),sessionStorage.getItem(e)):(vizbee.logger.debug("StorageUtil::getItem - getting from local!"),localStorage.getItem(e)?sessionStorage.getItem(e):localStorage.getItem(e));if(vizbee.logger.debug("StorageUtil::getItem - Storage NOT supported!"),"session"!=t)return vizbee.logger.debug("StorageUtil::getItem - getting from cookies!"),se.docCookies.getItem(e)}}},{key:"removeItem",value:function(e,t,n,i){if(e)if("undefined"!=typeof Storage)"session"==t?sessionStorage.removeItem(e):localStorage.removeItem(e)||sessionStorage.removeItem(e);else{if("session"==t)return;se.docCookies.removeItem(e,n,i)}}}])}(),wi=function(){return s(function e(t){o(this,e),this.senderConfig=t},[{key:"track",value:function(e,t){var n=this;if(e&&t&&this.senderConfig.url&&(VizbeeSDK.logger.d("".concat(this.constructor.name),"track() - tracking event ".concat(e,", ").concat(JSON.stringify(t))),this.shouldTrack(e)&&(t=this.filterProperties(t),0!=Object.keys(t).length))){var i={event:e,properties:t},r=this._getBase64String(i),o=this._getURIEncodedString(r),a=void 0,s=void 0,u="GET";this._needPostRequest(o)?(a=this.senderConfig.url,u="POST",s=JSON.stringify({data:o})):(a=this.senderConfig.url+"?data="+o,u="GET",s=void 0),VizbeeSDK.logger.d("".concat(this.constructor.name),"track() - sending metrics request: URL ".concat(a,", Method ").concat(u,", Data ").concat(s)),se.xhr({url:a,method:u,data:s,timeout:1e4,retries:this.senderConfig.networkRetries}).then(function(e){e.error?VizbeeSDK.logger.e("".concat(n.constructor.name),"track - ERROR"):VizbeeSDK.logger.d("".concat(n.constructor.name),"track - SUCCESS: ".concat(e))}).catch(function(e){VizbeeSDK.logger.d("".concat(n.constructor.name),"track - ERROR=".concat(e))})}}},{key:"shouldTrack",value:function(e){return VizbeeSDK.logger.d("".concat(this.constructor.name),"shouldTrack - Filtering events with regex = ".concat(this.senderConfig.eventFilter)),!this.senderConfig.eventFilter||new RegExp(this.senderConfig.eventFilter,"i").test(e)}},{key:"filterProperties",value:function(e){if(VizbeeSDK.logger.d("".concat(this.constructor.name),"filterProperties - Filtering properties with regex = ".concat(this.senderConfig.attributeFilter)),!this.senderConfig.attributeFilter)return e;e=e||{},e=JSON.parse(JSON.stringify(e));for(var t=new RegExp(this.senderConfig.attributeFilter,"i"),n=Object.keys(e),i=0;i<n.length;i++){var r=n[i];t.test(r)||delete e[r]}return e}},{key:"_getBase64String",value:function(e){return btoa(unescape(encodeURIComponent(JSON.stringify(e))))}},{key:"_getURIEncodedString",value:function(e){return window.encodeURIComponent(e)}},{key:"_needPostRequest",value:function(e){return!!(e&&e.length>1e4)}}])}(),Ni=function(){function e(t){o(this,e);var n={};return t.mixpanel_url&&(n={eventFilter:t.mixpanel_filter,token:t.mixpanel_token,attributeFilter:t.attribute_filter,url:t.mixpanel_url,networkRetries:0}),r(this,e,[n])}return p(e,wi),s(e,[{key:"track",value:function(t,n){(n=n||{}).token=this.senderConfig.token,b(e,"track",this)([t,n])}}])}(),Mi=function(){function e(t){o(this,e);var n={};return t.vizbee_url&&(n={url:t.vizbee_url,attributeFilter:t.attribute_filter,eventFilter:t.vizbee_filter,networkRetries:0}),r(this,e,[n])}return p(e,wi),s(e)}(),xi=function(){return s(function e(t){o(this,e),this.senders=[],t&&t.vizbee_url&&this.senders.push(new Mi(t)),t&&t.mixpanel_url&&t.mixpanel_token&&this.senders.push(new Ni(t))},[{key:"track",value:function(e,t){VizbeeSDK.logger.d("".concat(this.constructor.name),"track",e,t),te.each(this.senders,function(n){n.track(e,te.clone(t))})}}])}(),Oi="UNKNOWN",zi="NOT_FOUND",Li=function(){return s(function e(){o(this,e),this.config={},this.commonProperties={},this.attributesProvidersList=[],this.isInitialized=!1,this.needToSetDistinctIdForVideoEvents=!0},[{key:"init",value:function(e){if(e&&this.commonProperties)if(VizbeeSDK.logger.d("MetricsManager","init",e.appId,this.commonProperties.APP_ID),this.isInitialized&&this.commonProperties.APP_ID==e.appId)VizbeeSDK.logger.d("MetricsManager","init","already initialized");else{this.config=e,this.metricsRouter=new xi(e.metricsParams),this.appSessionId=Math.floor(1e10*Math.random()).toString()+"_"+Date.now(),this.screenSdkId=Di.getItem("SCREEN_SDK_ID"),this.screenSdkId?VizbeeSDK.logger.d("MetricsManager::init","SCREEN_SDK_ID -> AVAILABLE -> REUSING IT"):(VizbeeSDK.logger.d("MetricsManager::init","SCREEN_SDK_ID -> NOT_AVAILABLE"),this.screenSdkId=Math.floor(1e10*Math.random()).toString()+"_"+Date.now(),Di.setItem("SCREEN_SDK_ID",this.screenSdkId,"local",31536e3,"/"));var t=this.prepareCommonProperties(e);this.setCommonProperties(t),e.customAttributesForMetrics&&this.setCustomProperties(e.customAttributesForMetrics),this.isInitialized=!0}else VizbeeSDK.logger.e("MetricsManager","init","called with empty config!")}},{key:"refreshLaunchParamProperties",value:function(){if(VizbeeTV.tv.launchParamsDeferral){var e=VizbeeTV.tv.launchParamsDeferral.isLaunchedbyVizbee()||!1;this.commonProperties.SCREEN_LAUNCHED_WITH_VIZBEE=e,this.commonProperties.SCREEN_VZB_LAUNCH_PARAM=e?"y":zi}}},{key:"prepareCommonProperties",value:function(e){var t,n,i,r={appId:e.appId,deviceId:e.deviceId,deviceType:VizbeeTV.tv.cloudPlatformName,distinctId:e.deviceId,externalIp:e.externalIp,ipv6Address:e.ipv6Address,sdkVersion:window.VZB?window.VZB.VERSION:"",appSessionId:this.appSessionId,screenSdkId:this.screenSdkId,timestamp:Date.now(),timezoneOffset:(t=-(new Date).getTimezoneOffset(),n=t>=0?"+":"-",i=Math.abs(t),"GMT"+n+("0"+Math.floor(i/60)).slice(-2)+":"+("0"+i%60).slice(-2))};return VizbeeTV.tv.deviceInfo&&(VizbeeTV.tv.deviceInfo.deviceId&&VizbeeTV.tv.deviceInfo.deviceId!=Oi&&(r.deviceId=VizbeeTV.tv.deviceInfo.deviceId,r.distinctId=VizbeeTV.tv.deviceInfo.deviceId),r.macAddress=VizbeeTV.tv.deviceInfo.macAddress,r.deviceMake=VizbeeTV.tv.deviceInfo.make,r.deviceModel=VizbeeTV.tv.deviceInfo.model,r.deviceSerialNumber=VizbeeTV.tv.deviceInfo.serialNumber,r.friendlyName=VizbeeTV.tv.deviceInfo.friendlyName,r.osVersion=te.get(VizbeeTV.tv.deviceInfo,["os","version"],Oi),r.osNativeVersion=te.get(VizbeeTV.tv.deviceInfo,["os","sdkVersion"],Oi)),VizbeeTV.tv.adId&&(r.adId=VizbeeTV.tv.adId),null!=VizbeeTV.tv.isAdTrackingDisabled&&(r.isAdTrackingDisabled=VizbeeTV.tv.isAdTrackingDisabled),VizbeeTV.tv.networkInfo&&(r.internalIp=VizbeeTV.tv.networkInfo.internalIP,r.bssid=VizbeeTV.tv.networkInfo.bssid,r.ssid=VizbeeTV.tv.networkInfo.ssid,r.isWifiConnected=VizbeeTV.tv.networkInfo.isWifiConnected,r.connectionType=VizbeeTV.tv.networkInfo.connectionType),VizbeeTV.tv.launchParamsDeferral&&(r.isLaunchedWithVizbee=VizbeeTV.tv.launchParamsDeferral.isLaunchedbyVizbee()||!1),r}},{key:"setCommonProperties",value:function(e){VizbeeSDK.logger.d("MetricsManager","setCommonProperties"),this.commonProperties.SCREEN_DEVICE_USERAGENT=Oi,this.commonProperties.SCREEN_IDFV=Oi,this.commonProperties.SCREEN_HOMESSO_USER_INFO={user_login:Oi,user_login_type:Oi,user_name:Oi,user_subscription_renewal_type:Oi,user_subscription_type:Oi,user_subscription_value:Oi},e.appId&&(this.commonProperties.APP_ID=e.appId),e.externalIp&&(this.commonProperties.EXTERNAL_IP_ADDRESS=e.externalIp),e.ipv6Address&&(this.commonProperties.IPV6_ADDRESS=e.ipv6Address),e.distinctId&&(this.commonProperties.distinct_id=e.distinctId),e.deviceId&&(this.commonProperties.SCREEN_DEVICE_ID=e.deviceId),e.appSessionId&&(this.commonProperties.SCREEN_APP_SESSION_ID=e.appSessionId),e.screenSdkId&&(this.commonProperties.SCREEN_SDK_ID=e.screenSdkId),e.internalIp&&(this.commonProperties.INTERNAL_IP_ADDRESS=e.internalIp,this.commonProperties.SCREEN_INTERNAL_IP=e.internalIp),"isWifiConnected"in e&&(this.commonProperties.WIFI_CONNECTED=e.isWifiConnected),e.connectionType&&(this.commonProperties.CONNECTION_TYPE=e.connectionType),e.bssid&&(this.commonProperties.WIFI_BSSID=e.bssid),e.ssid&&(this.commonProperties.WIFI_SSID=e.ssid),e.adId&&(this.commonProperties.SCREEN_IDFA=e.adId),null!=e.isAdTrackingDisabled&&(this.commonProperties.SCREEN_LIMIT_AD_TRACKING=e.isAdTrackingDisabled),e.macAddress&&(this.commonProperties.SCREEN_MAC_ADDRESS=e.macAddress),navigator&&navigator.userAgent&&(this.commonProperties.SCREEN_DEVICE_USERAGENT=navigator.userAgent),e.deviceType&&(this.commonProperties.SCREEN_DEVICE_TYPE=e.deviceType),e.deviceMake&&(this.commonProperties.SCREEN_DEVICE_MAKE=e.deviceMake),e.deviceModel&&(this.commonProperties.SCREEN_DEVICE_MODEL=e.deviceModel),e.deviceSerialNumber&&(this.commonProperties.SCREEN_SERIAL_NUMBER=e.deviceSerialNumber),e.friendlyName&&(this.commonProperties.SCREEN_FRIENDLY_NAME=e.friendlyName),e.osNativeVersion&&(this.commonProperties.SCREEN_NATIVE_OS_VERSION=e.osNativeVersion),e.osVersion&&(this.commonProperties.SCREEN_OS_VERSION=e.osVersion),null!=e.isLaunchedWithVizbee&&(this.commonProperties.SCREEN_LAUNCHED_WITH_VIZBEE=e.isLaunchedWithVizbee),this.commonProperties.SCREEN_LAUNCHED_WITH_VIZBEE?this.commonProperties.SCREEN_VZB_LAUNCH_PARAM="y":this.commonProperties.SCREEN_VZB_LAUNCH_PARAM=zi,e.sdkVersion&&(this.commonProperties.SCREEN_SDK_VERSION=e.sdkVersion),e.timestamp&&(this.commonProperties.VZB_TIMESTAMP=e.timestamp),e.timezoneOffset&&(this.commonProperties.TIMEZONE=e.timezoneOffset),e.SCREEN_HOMESSO_USER_INFO&&(this.commonProperties.SCREEN_HOMESSO_USER_INFO=e.SCREEN_HOMESSO_USER_INFO)}},{key:"setAttributesProviderProperties",value:function(e,t){if(0!=this.attributesProvidersList.length){var n=this.attributesProvidersList.map(function(e){return e.provider.getAttributes()});Promise.all(n).then(function(n){n.forEach(function(t){t&&(e=te.extend(e,t))}),t(e)}).catch(function(n){console.error("Error getting attributes:",n),t(e)})}else t(e)}},{key:"setCustomProperties",value:function(e){var t=this;VizbeeSDK.logger.d("MetricsManager","setCustomProperties"),te.each(e,function(e,n){t.commonProperties["CUSTOM_"+n]=e})}},{key:"addProvider",value:function(e,t){VizbeeSDK.logger.d("MetricsManager","addProvider"),this.attributesProvidersList.push({provider:e,filterRegEx:t})}},{key:"removeProvider",value:function(e){VizbeeSDK.logger.d("MetricsManager","removeProvider"),this.attributesProvidersList=te.reject(this.attributesProvidersList,function(t){return t.provider==e})}},{key:"trackEvent",value:function(e,t){var n=this;this.shouldTrack(e,t)&&this._setUpdatedCommonProperties(function(){VizbeeSDK.logger.d("MetricsManager","trackEvent",e);var i=te.extend({},n.commonProperties,t);n.track(e,i)})}},{key:"trackScreenLaunched",value:function(){var e=this;this.shouldTrack("SCREEN_LAUNCHED",this.commonProperties)&&this._setUpdatedCommonProperties(function(){VizbeeSDK.logger.d("MetricsManager","trackScreenLaunched");var t=te.extend({},e.commonProperties,e.buildPlayerProperties());e.track("SCREEN_LAUNCHED",t)})}},{key:"trackScreenTVViewLoad",value:function(e){var t=this;this.shouldTrack("SCREEN_TV_VIEW_LOAD",e)&&this._setUpdatedCommonProperties(function(){VizbeeSDK.logger.d("MetricsManager","trackScreenTVViewLoad"),t.commonProperties.distinct_id=t.commonProperties.APP_ID+":"+t.commonProperties.SCREEN_DEVICE_TYPE+":"+se.uuidv4()+":"+Date.now(),t.needToSetDistinctIdForVideoEvents=!1;var n=te.extend({},t.commonProperties,t.buildPlayerProperties(),t.buildNewScreenTVViewProperties(e),t.buildScreenTVViewQualityProperties(e),t.buildStreamInfoAndMetadataProperties(e));t.track("SCREEN_TV_VIEW_LOAD",n)})}},{key:"trackScreenTVViewStart",value:function(e){var t=this;this.shouldTrack("SCREEN_TV_VIEW_START",e)&&this._setUpdatedCommonProperties(function(){VizbeeSDK.logger.d("MetricsManager","trackScreenTVViewStart"),t.needToSetDistinctIdForVideoEvents&&(t.commonProperties.distinct_id&&-1==t.commonProperties.distinct_id.indexOf(t.commonProperties.SCREEN_DEVICE_TYPE)&&(t.commonProperties.APP_ID,t.commonProperties.SCREEN_DEVICE_TYPE,se.uuidv4(),Date.now()),t.needToSetDistinctIdForVideoEvents=!0);var n=te.extend({},t.commonProperties,t.buildPlayerProperties(),t.buildScreenTVViewStartProperties(e),t.buildScreenTVViewQualityProperties(e),t.buildScreenTVViewStartTimeQualityProperties(e),t.buildStreamInfoAndMetadataProperties(e));t.track("SCREEN_TV_VIEW_START",n)})}},{key:"trackScreenTVViewPause",value:function(e){var t=this;this.shouldTrack("SCREEN_TV_VIEW_PAUSE",e)&&this._setUpdatedCommonProperties(function(){VizbeeSDK.logger.d("MetricsManager","trackScreenTVViewPause");var n=te.extend({},t.commonProperties,t.buildPlayerProperties(),t.buildScreenTVViewDurationProperties(e),t.buildScreenTVViewQualityProperties(e),t.buildStreamInfoAndMetadataProperties(e));t.track("SCREEN_TV_VIEW_PAUSE",n)})}},{key:"trackScreenTVViewResume",value:function(e){var t=this;this.shouldTrack("SCREEN_TV_VIEW_RESUME",e)&&this._setUpdatedCommonProperties(function(){VizbeeSDK.logger.d("MetricsManager","trackScreenTVViewResume");var n=te.extend({},t.commonProperties,t.buildPlayerProperties(),t.buildScreenTVViewResumeProperties(e),t.buildScreenTVViewQualityProperties(e),t.buildStreamInfoAndMetadataProperties(e));t.track("SCREEN_TV_VIEW_RESUME",n)})}},{key:"trackScreenTVViewDuration",value:function(e){var t=this;this.shouldTrack("SCREEN_TV_VIEW_DURATION",e)&&this._setUpdatedCommonProperties(function(){VizbeeSDK.logger.d("MetricsManager","trackScreenTVViewDuration");var n=te.extend({},t.commonProperties,t.buildPlayerProperties(),t.buildScreenTVViewDurationProperties(e),t.buildScreenTVViewQualityProperties(e),t.buildStreamInfoAndMetadataProperties(e));n.SCREEN_HOMESSO_USER_INFO=void 0,t.track("SCREEN_TV_VIEW_DURATION",n)})}},{key:"trackScreenTVViewError",value:function(e){var t=this,n="SCREEN_TV_VIEW_ERROR";this.shouldTrack(n,e)&&this._setUpdatedCommonProperties(function(){VizbeeSDK.logger.d("MetricsManager","trackScreenTVViewError");var i=te.extend({},t.commonProperties,t.buildPlayerProperties(),t.buildScreenTVViewErrorProperties(e),t.buildScreenTVViewDurationProperties(e),t.buildScreenTVViewQualityProperties(e),t.buildStreamInfoAndMetadataProperties(e));t.track(n,i)})}},{key:"trackScreenAdView",value:function(e){var t=this;this.shouldTrack("SCREEN_AD_VIEW",e)&&this._setUpdatedCommonProperties(function(){VizbeeSDK.logger.d("MetricsManager","trackScreenAdView","tracking SCREEN_AD_VIEW");var n=te.extend({},t.commonProperties,t.buildPlayerProperties(),t.buildScreenAdViewProperties(e));t.track("SCREEN_AD_VIEW",n)})}},{key:"trackScreenRemoteConnected",value:function(e){var t=this;e&&this.shouldTrack("SCREEN_REMOTE_CONNECTED")&&this._setUpdatedCommonProperties(function(){VizbeeSDK.logger.d("MetricsManager","trackScreenRemoteConnected");var n=te.extend({},t.commonProperties,t.buildPlayerProperties(),t._buildSenderProperties(e));t.track("SCREEN_REMOTE_CONNECTED",n)})}},{key:"trackScreenTVSignin",value:function(e){var t=this;e&&this.shouldTrack("SCREEN_TV_SIGNIN")&&this._setUpdatedCommonProperties(function(){VizbeeSDK.logger.d("MetricsManager","trackScreenTVSignin");var n=te.extend({},t.commonProperties,t.buildScreenTVSigninProperties(e));t.track("SCREEN_TV_SIGNIN",n)})}},{key:"_buildSenderProperties",value:function(e){return e&&e.ssinfo?{CONNECTED_REMOTE:e.ssinfo}:{}}},{key:"metricsConfig",value:function(){return this.config.metricsParams}},{key:"isVideoEvent",value:function(e){return-1!=["SCREEN_TV_VIEW_LOAD","SCREEN_TV_VIEW_START","SCREEN_TV_VIEW_PAUSE","SCREEN_TV_VIEW_RESUME","SCREEN_TV_VIEW_DURATION","SCREEN_AD_VIEW"].indexOf(e)}},{key:"isValidContinuityEvent",value:function(e){return-1!=["SCREEN_LAUNCHED","SCREEN_REMOTE_CONNECTED","SCREEN_TV_SIGNIN","SCREEN_TV_VIEW_LOAD","SCREEN_TV_VIEW_START","SCREEN_TV_VIEW_PAUSE","SCREEN_TV_VIEW_RESUME","SCREEN_TV_VIEW_DURATION","SCREEN_TV_VIEW_ERROR","SCREEN_AD_VIEW"].indexOf(e)}},{key:"isValidHomeSSOEvent",value:function(e){return-1!=["SCREEN_HOMESSO_SIGNIN_RECEIVED","SCREEN_HOMESSO_SIGNIN_STATUS"].indexOf(e)}},{key:"shouldTrack",value:function(e,t){if(0!=Object.keys(this.config).length){var n=!0;return this.isValidContinuityEvent(e)?this.isVideoEvent(e)&&this.metricsConfig()&&this.metricsConfig().shouldSendViewEventsOnlyOnCast&&t&&!t.isVideoLaunchedFromPhone&&(n=!1):this.isValidHomeSSOEvent(e)||(n=!1),n}VizbeeSDK.logger.e("MetricsManager","shouldTrack","called with empty config!")}},{key:"track",value:function(e,t){this.metricsRouter.track(e,t)}},{key:"buildPlayerProperties",value:function(){var e={PLAYER_NAME:"UNKNOWN"};return VizbeeTV.tv.player&&(e.PLAYER_NAME=VizbeeTV.tv.player.getName()),e}},{key:"buildVideoProperties",value:function(e){return{VIDEO_ID:e.videoId,VIDEO_TITLE:e.videoTitle,VIDEO_START_TIME:e.videoStartTime,VIDEO_DURATION_MS:Math.round(e.videoDuration),IS_LIVE:e.isLive,IS_CONTINUED_VIEW:e.isContinuedView,IS_VIDEO_LAUNCHED_FROM_PHONE:e.isVideoLaunchedFromPhone}}},{key:"buildNewScreenTVViewProperties",value:function(e){return this.buildVideoProperties(e)}},{key:"buildScreenTVViewStartProperties",value:function(e){return this.buildVideoProperties(e)}},{key:"buildScreenTVViewResumeProperties",value:function(e){return te.extend({VIDEO_PAUSED_TIME_MS:Math.round(e.videoPausedTimeInMs)},this.buildScreenTVViewDurationProperties(e))}},{key:"buildScreenTVViewDurationProperties",value:function(e){return te.extend({VIDEO_POSITION_MS:Math.round(e.videoPosition),VIDEO_POSITION_MIN:e.videoPostitionMin,VIDEO_ELAPSED_TIME_MS:Math.round(e.videoElapsedTime),VIDEO_ELAPSED_TIME_MIN:e.videoElapsedTimeMin},this.buildVideoProperties(e))}},{key:"buildStreamInfoAndMetadataProperties",value:function(e){var t={};try{if(e.customStreamInfo&&e.customMetadata){var n={customStreamInfo:e.customStreamInfo,customMetadata:e.customMetadata};t=te.extend({},se.flatten(n))}}catch(e){}return t}},{key:"buildScreenTVViewQualityProperties",value:function(e){(!e.startTime||e.startTime<0)&&(e.startTime=0);var t=e.startTime/1e3,n=e.videoBufferLevel?e.videoBufferLevel.current:0,i=e.audioBufferLevel?e.audioBufferLevel.current:0,r=e.audioBufferLevel?e.audioBufferLevel.didDetectSeparateAudio:"UNKNOWN",o=2*Math.ceil(t/2),a=2*Math.ceil(n/2),s=2*Math.ceil(i/2);return te.extend({START_TIME_SEC:t||0,VIDEO_BUFFER_SEC:n||0,AUDIO_BUFFER_SEC:i||0,AUDIO_STREAM_DETECTED:r,START_TIME_2SEC_BIN:o||0,VIDEO_BUFFER_2SEC_BIN:a||0,AUDIO_BUFFER_2SEC_BIN:s||0},this.buildVideoProperties(e))}},{key:"buildScreenTVViewStartTimeQualityProperties",value:function(e){return e&&te.get(this.config,["features","sendStartTimeQualityInfo"])?{PRE_ROLL_AD_POD_START_TIME_MS:e.adPodStartedTimeInMs?e.adPodStartedTimeInMs:0,PRE_ROLL_AD_POD_END_TIME_MS:e.adPodEndedTimeInMs?e.adPodEndedTimeInMs:0,VIDEO_LOAD_RECEIVED_BY_APP_TIME_MS:e.loadReceivedByAppTimeInMs?e.loadReceivedByAppTimeInMs:0,VIDEO_LOAD_RECEIVED_BY_PLAYER_TIME_MS:e.loadReceivedByPlayerTimeInMs?e.loadReceivedByPlayerTimeInMs:0,VIDEO_METADATA_LOADED_TIME_MS:e.metadataLoadedTimeInMs?e.metadataLoadedTimeInMs:0,VIDEO_PLAYER_READY_TIME_MS:e.playerReadyToPlayTimeInMs?e.playerReadyToPlayTimeInMs:0,VIDEO_PLAYBACK_STARTED_TIME_MS:e.playbackStartedTimeInMs?e.playbackStartedTimeInMs:0}:{}}},{key:"buildScreenTVViewErrorProperties",value:function(e){return te.extend({VIDEO_POSITION_MS:Math.round(e.videoPosition),FAILURE_VALUE:e.failureValue,FAILURE_CODE:e.failureCode},this.buildVideoProperties(e))}},{key:"buildScreenAdViewProperties",value:function(e){return{SCREEN_AD_ID:e.adId,AD_DURATION:e.adDuration,VIDEO_ID:e.videoId,VIDEO_TITLE:e.videoTitle,VIDEO_DURATION_MS:Math.round(e.videoDuration),VIDEO_POSITION_MS:Math.round(e.videoPosition),IS_LIVE:e.isLive,IS_VIDEO_LAUNCHED_FROM_PHONE:e.isVideoLaunchedFromPhone}}},{key:"buildScreenTVSigninProperties",value:function(e){return{USER_ID:e.userId,USER_LOGIN:e.userLogin,USER_LOGIN_TYPE:e.userLoginType}}},{key:"_setUpdatedCommonProperties",value:function(e){var t=this,n={};this.commonProperties.adId&&this.commonProperties.adId!=Oi||(n.adId=VizbeeTV.tv.adId||Oi),this.commonProperties.isAdTrackingDisabled&&this.commonProperties.isAdTrackingDisabled!=Oi||(n.isAdTrackingDisabled=VizbeeTV.tv.isAdTrackingDisabled||Oi),VizbeeTV.tv.deviceInfo&&(VizbeeTV.tv.deviceInfo.deviceId&&VizbeeTV.tv.deviceInfo.deviceId!=Oi&&(n.deviceId=VizbeeTV.tv.deviceInfo.deviceId),VizbeeTV.tv.deviceInfo.model&&VizbeeTV.tv.deviceInfo.model!=Oi&&(n.deviceModel=VizbeeTV.tv.deviceInfo.model)),this.setAttributesProviderProperties(n,function(n){t.setCommonProperties(n),e()})}}])}(),Ri=new Li,Ki="receiver_with_applets",Ui=function(){function e(t,n){var i;return o(this,e),(i=r(this,e,[t,n])).appConfig=n,i.currentVideoId=void 0,i.didLogStartVideo=!1,i.lastLoggedVideoPostition2XMin=-1,i.elapsedLastPlayingTimestamp=void 0,i.elapsedPlayingTime=0,i.targetAppType=i.appConfig&&i.appConfig.features&&i.appConfig.features.targetAppType,i.senderMap={},i}return p(e,_i),s(e,[{key:"connect",value:function(t){Ri.init(this.appConfig);var n=VizbeeTV.tv.launchParamsDeferral;n&&"function"==typeof n.waitUntilReady?n.waitUntilReady().then(function(){Ri.refreshLaunchParamProperties(),Ri.trackScreenLaunched()}):Ri.trackScreenLaunched(),b(e,"connect",this)([t])}},{key:"send",value:function(t){if(t&&t.cmd){var n=t;"status"==t.cmd.name&&(n=this.interceptVideoStatus(t)),b(e,"send",this)([n])}else b(e,"send",this)([t])}},{key:"interceptVideoStatus",value:function(e){if(this.currentVideoId!=e.vstatus.id&&(this.currentVideoId=e.vstatus.id,this.didLogStartVideo=!1,this.lastLoggedVideoPostition2XMin=-1,this.elapsedLastPlayingTimestamp=Date.now(),this.elapsedPlayingTime=0,VizbeeSDK.logger.d("MetricsExtension","interceptVideoStatus","logging new video"),Ri.trackScreenTVViewLoad({videoId:e.vstatus.id,videoTitle:e.vinfoext.title||e.vinfo.url,videoStartTime:e.vinfoext.videostarttime,videoDuration:e.vstatus.du||-1,isLive:e.vinfo.islive,customStreamInfo:e.vinfoext.customstreaminfo,customMetadata:e.vinfoext.custommetadata,isContinuedView:!(!e.qstatus||!e.qstatus.prev),isVideoLaunchedFromPhone:e.vinfoext.wasVideoStartedByVizbee})),"PLAYING"==e.vstatus.st&&(e.vinfo.islive||!e.vinfo.islive&&e.vstatus.po>0)){if(!this.didLogStartVideo){VizbeeSDK.logger.d("MetricsExtension","interceptVideoStatus","logging start video");var t=e.vinfoext.qos||{};Ri.trackScreenTVViewStart({videoId:e.vstatus.id,videoTitle:e.vinfoext.title||e.vinfo.url,videoStartTime:e.vinfoext.videostarttime,videoDuration:e.vstatus.du,isLive:e.vinfo.islive,customStreamInfo:e.vinfoext.customstreaminfo,customMetadata:e.vinfoext.custommetadata,isContinuedView:!(!e.qstatus||!e.qstatus.prev),isVideoLaunchedFromPhone:e.vinfoext.wasVideoStartedByVizbee,startTime:t.starttime||0,audioBufferLevel:t.audiobufferlevel||{},videoBufferLevel:t.videobufferlevel||{},adPodStartedTimeInMs:t.adPodStartedTimeInMs||0,adPodEndedTimeInMs:t.adPodEndedTimeInMs||0,loadReceivedByAppTimeInMs:t.loadReceivedByAppTimeInMs||0,loadReceivedByPlayerTimeInMs:t.loadReceivedByPlayerTimeInMs||0,metadataLoadedTimeInMs:t.metadataLoadedTimeInMs||0,playerReadyToPlayTimeInMs:t.playerReadyToPlayTimeInMs||0,playbackStartedTimeInMs:t.playbackStartedTimeInMs||0}),this.didLogStartVideo=!0}this.elapsedPlayingTime=this.elapsedPlayingTime+(Date.now()-this.elapsedLastPlayingTimestamp),this.elapsedLastPlayingTimestamp=Date.now();var n=2*Math.floor(e.vstatus.po/12e4);n>this.lastLoggedVideoPostition2XMin&&(this.lastLoggedVideoPostition2XMin=n,Ri.trackScreenTVViewDuration({videoId:e.vstatus.id,videoTitle:e.vinfoext.title||e.vinfo.url,videoStartTime:e.vinfoext.videostarttime,videoDuration:e.vstatus.du,videoPosition:e.vstatus.po,videoPostitionMin:this.lastLoggedVideoPostition2XMin,videoElapsedTime:this.elapsedPlayingTime,videoElapsedTimeMin:2*Math.floor(this.elapsedPlayingTime/12e4),isLive:e.vinfo.islive,customStreamInfo:e.vinfoext.customstreaminfo,customMetadata:e.vinfoext.custommetadata,isContinuedView:!(!e.qstatus||!e.qstatus.prev),isVideoLaunchedFromPhone:e.vinfoext.wasVideoStartedByVizbee,startTime:e.vinfoext.qos.starttime,audioBufferLevel:e.vinfoext.qos.audiobufferlevel,videoBufferLevel:e.vinfoext.qos.videobufferlevel}))}return"FAILED"==e.vstatus.st&&Ri.trackScreenTVViewError({videoId:e.vstatus.id,videoTitle:e.vinfoext.title||e.vinfo.url,isLive:e.vinfo.islive,videoStartTime:e.vinfoext.videostarttime,videoDuration:e.vstatus.du,videoPosition:e.vstatus.po,videoPostitionMin:this.lastLoggedVideoPostition2XMin,videoElapsedTime:this.elapsedPlayingTime,videoElapsedTimeMin:2*Math.floor(this.elapsedPlayingTime/12e4),customStreamInfo:e.vinfoext.customstreaminfo,customMetadata:e.vinfoext.custommetadata,isContinuedView:!(!e.qstatus||!e.qstatus.prev),isVideoLaunchedFromPhone:e.vinfoext.wasVideoStartedByVizbee,failureValue:e.vstatus.er.reason,failureCode:e.vstatus.er.code,startTime:e.vinfoext.qos.starttime,audioBufferLevel:e.vinfoext.qos.audiobufferlevel,videoBufferLevel:e.vinfoext.qos.videobufferlevel}),["INTERRUPTED","FINISHED","FAILED"].indexOf(e.vstatus.st)>-1&&(this.currentVideoId=void 0),e}},{key:"handleSyncReceiveEvent",value:function(e){var t=e.data;if(t&&t.b&&t.b.cmd&&"video"===t.b.cmd.ns&&"event"===t.b.cmd.name&&t.b.einfo&&"tv.vizbee.homesign.signin"==t.b.einfo.type){var n=t.b.einfo.data&&t.b.einfo.data.authInfo;n&&Ri.trackScreenTVSignin(n)}return e}},{key:"handleNonSyncReceiveEvent",value:function(e){var t=this;if(e&&e.type==Ht.SYNC_PRESENCE){var n=e.data;if(n&&this.senderMap){var i=Object.keys(this.senderMap),r=Object.keys(n);r.length>i.length?r.forEach(function(e){t.senderMap[e]||(!n[e]||"vzb0000000"===n[e].appId&&t.targetAppType===Ki||(VizbeeSDK.logger.d("MetricsExtension","handleNonSyncReceiveEvent","new sender connected, id = "+e),Ri.trackScreenRemoteConnected(n[e])),t.senderMap[e]=n[e])}):r.length<i.length&&i.forEach(function(e){-1==r.indexOf(e)&&(VizbeeSDK.logger.d("MetricsExtension","handleNonSyncReceiveEvent","sender disconnected, id = "+e),delete t.senderMap[e])})}}return e}}])}(),Fi=function(){function e(t,n){var i;return o(this,e),(i=r(this,e,[t,n])).appConfig=n,i.currentVideoId=void 0,i.elapsedLastPlayingTimestamp=void 0,i.elapsedPlayingTime=0,i.videoPausedTimestamp=-1,i.didLogPauseVideo=!1,i}return p(e,_i),s(e,[{key:"connect",value:function(t){Ri.init(this.appConfig),b(e,"connect",this)([t])}},{key:"send",value:function(t){if(t&&t.cmd){var n=t;"status"==t.cmd.name&&(n=this.interceptVideoStatus(t)),b(e,"send",this)([n])}else b(e,"send",this)([t])}},{key:"interceptVideoStatus",value:function(e){return this.currentVideoId!=e.vstatus.id&&(this.currentVideoId=e.vstatus.id,this.elapsedLastPlayingTimestamp=Date.now(),this.elapsedPlayingTime=0,this.videoPausedTimestamp=-1,this.didLogPauseVideo=!1),"PLAYING"==e.vstatus.st&&(e.vinfo.islive||!e.vinfo.islive&&e.vstatus.po>0)&&(this.elapsedPlayingTime=this.elapsedPlayingTime+(Date.now()-this.elapsedLastPlayingTimestamp),this.elapsedLastPlayingTimestamp=Date.now(),this.didLogPauseVideo&&(VizbeeSDK.logger.debug("FilterPauseResumeEventsExtension::interceptVideoStatus - logging resume video"),Ri.trackScreenTVViewResume({videoId:e.vstatus.id,videoTitle:e.vinfoext.title||e.vinfo.url,videoStartTime:e.vinfoext.videostarttime,videoDuration:e.vstatus.du,videoPosition:e.vstatus.po,videoPostitionMin:2*Math.floor(e.vstatus.po/12e4),videoElapsedTime:this.elapsedPlayingTime,videoElapsedTimeMin:2*Math.floor(this.elapsedPlayingTime/12e4),videoPausedTimeInMs:Date.now()-this.videoPausedTimestamp,isLive:e.vinfo.islive,customStreamInfo:e.vinfoext.customstreaminfo,customMetadata:e.vinfoext.custommetadata,isContinuedView:!(!e.qstatus||!e.qstatus.prev),isVideoLaunchedFromPhone:e.vinfoext.wasVideoStartedByVizbee,startTime:e.vinfoext.qos.starttime,audioBufferLevel:e.vinfoext.qos.audiobufferlevel,videoBufferLevel:e.vinfoext.qos.videobufferlevel})),this.videoPausedTimestamp=-1,this.didLogPauseVideo=!1),"PAUSED_BY_USER"==e.vstatus.st&&(-1==this.videoPausedTimestamp&&(this.videoPausedTimestamp=Date.now()),!this.didLogPauseVideo&&Date.now()-this.videoPausedTimestamp>=15e3&&(VizbeeSDK.logger.debug("FilterPauseResumeEventsExtension::interceptVideoStatus - logging pause video"),Ri.trackScreenTVViewPause({videoId:e.vstatus.id,videoTitle:e.vinfoext.title||e.vinfo.url,videoStartTime:e.vinfoext.videostarttime,videoDuration:e.vstatus.du,videoPosition:e.vstatus.po,videoPostitionMin:2*Math.floor(e.vstatus.po/12e4),videoElapsedTime:this.elapsedPlayingTime,videoElapsedTimeMin:2*Math.floor(this.elapsedPlayingTime/12e4),isLive:e.vinfo.islive,customStreamInfo:e.vinfoext.customstreaminfo,customMetadata:e.vinfoext.custommetadata,isContinuedView:!(!e.qstatus||!e.qstatus.prev),isVideoLaunchedFromPhone:e.vinfoext.wasVideoStartedByVizbee,startTime:e.vinfoext.qos.starttime,audioBufferLevel:e.vinfoext.qos.audiobufferlevel,videoBufferLevel:e.vinfoext.qos.videobufferlevel}),this.didLogPauseVideo=!0)),["INTERRUPTED","FINISHED","FAILED"].indexOf(e.vstatus.st)>-1&&(this.currentVideoId=void 0),e}}])}(),Bi=function(){function e(t,n){var i;return o(this,e),VizbeeSDK.logger.debug("DisconnectSendersInBackgroundExtension::constructor()",t,n.appId),(i=r(this,e,[t,n]))._enable=!1,i._senderAliveTimeoutWithFGFlagInMs=6e4,i._senderAliveTimeoutWithoutFGFlagInMs=72e4,i._senderAliveCheckTimer=void 0,i._senderAliveTimerWithFGFlag=void 0,i._senderAlivetTimerWithoutFGFlag=void 0,i._androidSendersInBackgroundMap={},i._androidSendersWithoutFGFlagMap={},i._getExtensionConfigData(n),i}return p(e,_i),s(e,[{key:"_getExtensionConfigData",value:function(e){if(e&&e.features&&e.features.DisconnectSendersInBackgroundExtension){var t=e.features.DisconnectSendersInBackgroundExtension;1==t.enable&&(this._enable=!0,null!=t.senderAliveTimeoutWithFGFlagInMs&&(this._senderAliveTimeoutWithFGFlagInMs=t.senderAliveTimeoutWithFGFlagInMs),null!=t.senderAliveTimeoutWithoutFGFlagInMs&&(this._senderAliveTimeoutWithoutFGFlagInMs=t.senderAliveTimeoutWithoutFGFlagInMs))}}},{key:"disconnect",value:function(){VizbeeSDK.logger.debug("DisconnectSendersInBackgroundExtension::disconnect()"),this._stopAllTimers(),this._resetToDefault(),b(e,"disconnect",this)([])}},{key:"handleSyncReceiveEvent",value:function(e){if(!this._enable)return e;var t=e.data;if(t&&t.h){var n=t.h.ty&&t.h.ty.toLowerCase(),i=t.h.st&&t.h.st.toLowerCase();n&&"remote"==n&&i&&"android"==i&&(t.h.ssinfo&&null!=t.h.ssinfo.IS_IN_FOREGROUND?0==t.h.ssinfo.IS_IN_FOREGROUND?this._androidSendersInBackgroundMap[t.h.id]||(VizbeeSDK.logger.info("DisconnectSendersInBackgroundExtension::handleSyncReceiveEvent - adding new sender to the map"),this._androidSendersInBackgroundMap[t.h.id]=Date.now()):this._androidSendersInBackgroundMap={}:this._androidSendersWithoutFGFlagMap[t.h.id]||(this._androidSendersWithoutFGFlagMap[t.h.id]=Date.now(),VizbeeSDK.logger.info("DisconnectSendersInBackgroundExtension::handleSyncReceiveEvent - adding new sender to the map")))}return this._startSenderAliveCheckTimer(),e}},{key:"_startSenderAliveCheckTimer",value:function(){var e=this;this._stopSenderAliveCheckTimer(),this._senderAliveCheckTimer=window.setInterval(function(){e._checkSenderStatusAndSendOlleh()},1e3)}},{key:"_checkSenderStatusAndSendOlleh",value:function(){this._handleSendersInBackground(),this._handleSendersWithoutFGFlag()}},{key:"_handleSendersInBackground",value:function(){var e=this,t=Date.now();te.keys(this._androidSendersInBackgroundMap).filter(function(n){return t-e._androidSendersInBackgroundMap[n]>e._senderAliveTimeoutWithFGFlagInMs}).length>0&&(VizbeeSDK.logger.info("DisconnectSendersInBackgroundExtension::_handleSendersInBackground - sending olleh as there are no senders in foreground"),this._sendOllehMessage(),this._resetToDefault())}},{key:"_handleSendersWithoutFGFlag",value:function(){var e=this,t=Date.now(),n=te.keys(this._androidSendersWithoutFGFlagMap),i=te.keys(this._androidSendersWithoutFGFlagMap).filter(function(n){return t-e._androidSendersWithoutFGFlagMap[n]>e._senderAliveTimeoutWithoutFGFlagInMs});i.length>0&&n.length==i.length&&(VizbeeSDK.logger.info("DisconnectSendersInBackgroundExtension::_handleSendersWithoutFGFlag - sending olleh as there are no senders in foreground"),this._sendOllehMessage(),this._resetToDefault())}},{key:"_sendOllehMessage",value:function(){this.dispatchReceive(new Bt(Ht.SYNC_MESSAGE,{b:{cmd:{ns:"video",name:"olleh",type:"int"},hstatus:{id:this.appConfig.deviceId,type:"SCREEN",vip:"false"}}}))}},{key:"_resetToDefault",value:function(){this._stopAllTimers(),this._androidSendersInBackgroundMap={},this._androidSendersWithoutFGFlagMap={}}},{key:"_stopAllTimers",value:function(){this._stopSenderAliveCheckTimer(),this._stopDisconnetionTimerWithIsInFGFlag(),this._stopDisconnetionTimerWithoutIsInFGFlag()}},{key:"_stopSenderAliveCheckTimer",value:function(){this._senderAliveCheckTimer&&(window.clearInterval(this._senderAliveCheckTimer),this._senderAliveCheckTimer=void 0)}},{key:"_stopDisconnetionTimerWithIsInFGFlag",value:function(){this._senderAliveTimerWithFGFlag&&(window.clearTimeout(this._senderAliveTimerWithFGFlag),this._senderAliveTimerWithFGFlag=void 0)}},{key:"_stopDisconnetionTimerWithoutIsInFGFlag",value:function(){this._senderAliveWithoutFGFlagTimer&&(window.clearTimeout(this._senderAliveWithoutFGFlagTimer),this._senderAliveWithoutFGFlagTimer=void 0)}}])}(),Hi=t(wt()),Gi=function(){function e(t,n){var i;if(o(this,e),(i=r(this,e,[t,n])).enable=!0,n&&n.features&&n.features.SubtitlesExtension){var a=n.features.SubtitlesExtension;null!=a.enable&&(i.enable=a.enable)}return i}return p(e,_i),s(e,[{key:"_isEnabled",value:function(){return this.enable}},{key:"handleSyncReceiveEvent",value:function(e){var t=e.data;if(VizbeeSDK.logger.verbose("SubtitlesExtension::handleSyncReceiveEvent - received message data = ".concat(JSON.stringify(t))),!(t&&t.b&&t.b.cmd))return e;var n=t.b.cmd.name;if(!(n&&["enabletrack","disabletrack"].indexOf(n.toLowerCase())>-1))return e;if(this._isEnabled()){var i=Number(t.b.cmd.param);if(!isNaN(i)){var r=[i];"enabletrack"===t.b.cmd.name?Hi.enableTracks(r):Hi.disableTracks(r)}}}},{key:"send",value:function(t){if(t&&t.cmd){var n=t,i="status"==t.cmd.name,r="hello"==t.cmd.name&&"rsp"==t.cmd.type&&t.vstatus;(i||r)&&(n=this._interceptVideoStatus(t)),b(e,"send",this)([n])}else b(e,"send",this)([t])}},{key:"_interceptVideoStatus",value:function(e){return this._addTrackStatus(e)}},{key:"_addTrackStatus",value:function(e){if(!e||!e.vstatus)return e;if(e.vstatus.tr||(e.vstatus.tr={}),!this._isEnabled())return e;var t=this._getTextTrackStatus();return e.vstatus.tr.availableTextTracks=t.availableTextTracks,e.vstatus.tr.currentTextTrack=t.currentTextTrack,e}},{key:"_getTextTrackStatus",value:function(){var e={},t=Hi.getTracks(M),n=Hi.getEnabledTracks(M);if(t&&Array.isArray(t)&&t.length>0&&(t.forEach(function(t){var n=t.toJSON();n&&(e.availableTextTracks||(e={availableTextTracks:[],currentTextTrack:{}}),e.availableTextTracks.push({screenTrackId:n.id,languageCode:n.lang}))}),n&&Array.isArray(n)&&n.length>0)){var i=n[0].toJSON();i&&(e.currentTextTrack={screenTrackId:i.id,languageCode:i.lang})}return e}}])}(),Wi=function(){function e(t,n){var i;if(o(this,e),(i=r(this,e,[t,n])).enable=!0,n&&n.features&&n.features.AudioTracksExtension){var a=n.features.AudioTracksExtension;null!=a.enable&&(i.enable=a.enable)}return i}return p(e,_i),s(e,[{key:"_isEnabled",value:function(){return this.enable}},{key:"handleSyncReceiveEvent",value:function(e){if(!this._isEnabled())return e;var t=e.data;if(VizbeeSDK.logger.verbose("AudioTracksExtension::handleSyncReceiveEvent - received message data = ".concat(JSON.stringify(t))),!(t&&t.b&&t.b.cmd))return e;var n=t.b.cmd.name;if(!n||"string"!=typeof n||"changeaudiotrack"!==n.toLowerCase())return e;var i=Number(t.b.cmd.param);isNaN(i)?VizbeeSDK.logger.debug("AudioTracksExtension::handleSyncReceiveEvent - received changeAudioTrack command with invalid trackId = ".concat(i)):(VizbeeSDK.logger.debug("AudioTracksExtension::handleSyncReceiveEvent - received changeAudioTrack command with trackId = ".concat(i)),Hi.changeAudioTrack(i))}},{key:"send",value:function(t){if(t&&t.cmd){var n=t,i="status"==t.cmd.name,r="hello"==t.cmd.name&&"rsp"==t.cmd.type&&t.vstatus;(i||r)&&(n=this._interceptVideoStatus(t)),VizbeeSDK.logger.verbose("AudioTracksExtension::send - forwarding out message",n),b(e,"send",this)([n])}else b(e,"send",this)([t])}},{key:"_interceptVideoStatus",value:function(e){return this._addAudioTrackStatus(e)}},{key:"_addAudioTrackStatus",value:function(e){if(!e||!e.vstatus)return e;if(e.vstatus.tr||(e.vstatus.tr={}),!this._isEnabled())return e;var t=this._getAudioTrackStatus();return e.vstatus.tr.availableAudioTracks=t.availableAudioTracks,e.vstatus.tr.currentAudioTrack=t.currentAudioTrack,e}},{key:"_getAudioTrackStatus",value:function(){var e={},t=Hi.getAudioTracks(x),n=Hi.getActiveAudioTrack(x);return t&&Array.isArray(t)&&t.length>0&&(t.forEach(function(t){var n=t.toJSON();n&&(e.availableAudioTracks||(e={availableAudioTracks:[],currentAudioTrack:{}}),e.availableAudioTracks.push({screenTrackId:n.id,languageCode:n.lang,displayName:n.label}))}),n&&null!=n.id&&(e.currentAudioTrack={screenTrackId:n.id,languageCode:n.lang,displayName:n.label})),e}}])}(),ji=[mi,bi,Pi,Ti,Ii,Ei,Vi,Ci,Fi,Ui,Bi,Gi,Wi],qi=[mi,bi,Pi,Ti,Ei,Ci,Fi,Ui,Gi,Wi,null],Ji=function(){return s(function e(){o(this,e)},[{key:"createSync",value:function(e){var t=te.get(e,["syncInfo","syncMethod"],"pubnub").toLowerCase();return Xn="googlecustom"==t?this.getGoogleCustomSyncInstanceWitExtensions(e):"googledual"==t?this.getGoogleDualSyncInstanceWitExtensions(e):this.getDefaultSyncInstanceWitExtensions(e)}},{key:"getGoogleCustomSyncInstanceWitExtensions",value:function(e){return this.addExtensions(e,this.getGoogleCastSync(e),qi)}},{key:"getGoogleDualSyncInstanceWitExtensions",value:function(e){var t=this.addExtensions(e,new vi(e),ji),n=this.addExtensions(e,this.getGoogleCastSync(e),qi),i=new gi(e);return i.addSyncInstance(t),i.addSyncInstance(n),i}},{key:"getDefaultSyncInstanceWitExtensions",value:function(e){return this.addExtensions(e,new vi(e),ji)}},{key:"addExtensions",value:function(e,t,n){for(var i=0;i<n.length;i++)t=new(0,n[i])(t,e);return t}},{key:"getGoogleCastSync",value:function(e){return cast.framework,new null(e)}}],[{key:"getSync",value:function(){return Xn}}])}(),Yi=function(e){return e[e.NOT_CONNECTED=1]="NOT_CONNECTED",e[e.CONNECTING=2]="CONNECTING",e[e.CONNECTED=3]="CONNECTED",e}({}),Xi=J(),Qi=Nt(),Zi=function(){if(Pt)return Tt;Pt=1,J();var e={},t={};function n(){VizbeeSDK.logger.debug("VGAStateManager:reset() previous video and ad objects = ",e,t),e.id="",e.state="UNKNOWN",e.position=-1,e.duration=-1,t.id="",t.state="UNKNOWN",t.position=-1,t.duration=-1}return n(),Tt={type:"VGAStateManager",app:{state:"app"},video:e,ad:t,reset:n,addListener:function(e){},removeListener:function(){}}}(),$i=nt(),er=Mt(),tr=wt(),nr=xt(),ir=750,rr=void 0,or=function(){function e(){o(this,e)}return s(e,[{key:"getQueueManager",value:function(){return null==this.queueManager&&(this.queueManager=new null(null.getInstance())),VizbeeSDK.logger.debug("ContinuityContext::getQueueManager - returning queue manager",this.queueManager),this.queueManager}}],[{key:"getInstance",value:function(){return null==rr&&(rr=new e),rr}}])}(),ar=J(),sr=function(){if(ee)return $;ee=1;var e,t,n=Ye().xhr,i=J(),r={appId:null,config:null,pub_key:"pub-c-1e4f216f-168e-4fdc-8a2b-a29ffe05cb5b",sub_key:"sub-c-6da25f1b-58d7-4f17-bd10-21a30198a794"};return $={appConfig:r,getConfig:function(o,a){r.appId=o.appId,r.platform=o.platform,r.platformModel=o.platformModel,r.hostProxy=o.hostProxy,function(){var i="config.claspws.tv";r.hostProxy&&(i=r.hostProxy),e=r.platform,t=r.platformModel;var o="//"+i+"/api/v2/";o+="apps/"+r.appId+"/screen/"+e,t&&(o+="."+t);var a=!1;if(window&&window.navigator&&window.navigator.language){var s=window.navigator.language.split("-");s.length>1&&(o+="?country="+s[1],a=!0)}return o+=(a?"&":"?")+"seed="+Math.round(1e3*Math.random()),VizbeeSDK.logger.debug("Config:getAPIConfig - didn't find any saved config from local storage. Calling config server ..."),o="https:"+o,VizbeeSDK.logger.debug("Config:getAPIConfig - URL = "+o),n({url:o,retries:3,timeout:3e4,headers:{Accept:"application/json"}}).then(function(e){if(e&&e.error&&100==e.error.code)return VizbeeSDK.logger.error("Config:getAPIConfig - received error code and message = ",e.error.code,e.error.message),VizbeeSDK.logger.error("Config:getAPIConfig - screen device may not be allowed or setup. Screen device platform = ",r.platform),VizbeeSDK.logger.error("Config:getAPIConfig - SDK init FAILED!"),Promise.reject(e.error);if(e&&e.data&&e.data.items&&e.data.items[0]){if(e.data.items[0].channelKeys.pub_key&&e.data.items[0].channelKeys.sub_key){var t=e.data.items[0];return t.externalIp=e.externalIpAddress,VizbeeSDK.logger.debug("Config:getAPIConfig - valid config returned by API",t),VizbeeSDK.logger.debug("Config:getAPIConfig - SDK init SUCCESS!"),t}return VizbeeSDK.logger.error("Config:getAPIConfig - got config response but no channel pub keys or sub keys!"),VizbeeSDK.logger.error("Config:getAPIConfig - SDK init FAILED!"),Promise.reject("No pub sub keys for given appId")}return VizbeeSDK.logger.error("Config:getAPIConfig - invalid response (but no error!) returned by server"),VizbeeSDK.logger.error("Config:getAPIConfig - SDK init FAILED!"),Promise.reject("Invalid response")}).catch(function(e){return VizbeeSDK.logger.error("Config:getAPIConfig - XHR request to get config failed"),VizbeeSDK.logger.error("Config:getAPIConfig - SDK init FAILED!"),Promise.reject(e)})}().then(function(e){VizbeeSDK.logger.debug("Config:getConfig - got apiConfig",e),i.extend(r,e),e.channelKeys.pub_key&&e.channelKeys.sub_key&&(r.pub_key=e.channelKeys.pub_key,r.sub_key=e.channelKeys.sub_key),"function"==typeof a&&(VizbeeSDK.logger.debug("Config:getConfig - calling callback with extended config =",r),a(r))}).catch(function(e){var t="SDK CONFIG FETCH FAILED";null!=e&&(t+=" - "+e.message);var n=new Error(t);VizbeeSDK.logger.critical("Config::getConfig - SDK CONFIG FETCH FAILED",n),VizbeeSDK.logger.error("Config::getConfig - NOTE - could be a failure in the callback passed to getConfig!")})}},$}(),ur=et,lr=function(e,t){var n,i=e,r=void 0,o=void 0,a=!1,s=!1,u=!1,l=!1,c=i&&i.features&&i.features.syncSendIntervalInMs;isNaN(c)||(ir=c);var d=[],f=[],p={};return t?(a=!0,n=Zi):(a=!1,n=Qi,tr.setAppStateManager(Qi),nr.addListener(function(e){VizbeeSDK.logger.debug("synccontroller",e),"sync_proxy_video_cmds"==e.type&&("x"===e.cmd.name||"event"===e.cmd.name?(delete e.type,r.send(e)):g(e))})),{connect:function(e){VizbeeSDK.logger.debug("SyncController::connect - dumping appConfig = ",i);var t=new Ji;(r=t.createSync(i)).onReceive=function(t){if(t)switch(t.type){case Ht.SYNC_CONNECT:!function(e){s=!0,a&&(VizbeeSDK.logger.debug("SyncController::syncConnectHandler - setting isAppAdapterAvailable to TRUE (isVGA=true)"),u=!0),h(),e(!0)}(e);break;case Ht.SYNC_MESSAGE:var n=t.data.b,i=t.data.h;if(a&&n.cmd&&-1==["launch_applet","hello"].indexOf(n.cmd.name))return;o=i,"video"===(r=n).cmd.ns&&g(r,o),"x"===r.cmd.ns&&m((l=r).b.cmd.ns,y(l));break;case Ht.SYNC_PRESENCE:a||function(e){VizbeeSDK.logger.debug("SyncController::presenceHandler() - connected users count",e);var t=Xi.extend({},p);p=Xi.extend({},e),VizbeeSDK.logger.debug("SyncController::syncPresenceHandler - transition","from:",Object.keys(t),"to:",Object.keys(p)),function(e,t){var n=Object.keys(e||{}),i=Object.keys(t||{});VizbeeSDK.logger.debug("SyncController::notifyPresenceListeners - previousIds: ",n," newIds: ",i);var r=i.filter(function(e){return-1===n.indexOf(e)});VizbeeSDK.logger.debug("SyncController::notifyPresenceListeners - joinedIds: ",r);var o=n.filter(function(e){return-1===i.indexOf(e)});VizbeeSDK.logger.debug("SyncController::notifyPresenceListeners - leftIds: ",o),r.forEach(function(e){var n=t[e];if(n){VizbeeSDK.logger.debug("SyncController::notifyPresenceListeners - user joined: ",e);var i={event:"JOIN",member:n};f.forEach(function(e){try{e(i)}catch(e){VizbeeSDK.logger.error("SyncController::notifyPresenceListeners - Error calling listener",e)}})}}),o.forEach(function(t){VizbeeSDK.logger.debug("SyncController::notifyPresenceListeners - user left: ",t);var n=e[t];if(n){VizbeeSDK.logger.debug("SyncController::notifyPresenceListeners - user left: ",t);var i={event:"LEAVE",member:n};f.forEach(function(e){try{e(i)}catch(e){VizbeeSDK.logger.error("SyncController::notifyPresenceListeners - Error calling listener",e)}})}})}(t,p),$i.updatePresence(e)}(t.data)}var r,o,l},r.connect(e),n.addListener(S),$i.isAppSet()&&(VizbeeSDK.logger.debug("SyncController::connect appIsSet"),u=!0,h()),d.forEach(function(e){e(Yi.CONNECTED)}),o=window.setInterval(_,ir)},disconnect:function(){VizbeeSDK.logger.debug("SyncController::disconnect() called"),clearInterval(o),n.removeListener(S),d.forEach(function(e){e(Yi.NOT_CONNECTED)}),v(),r.disconnect(),s=!1},isConnected:function(){return s},addSessionStateListener:function(e){d.push(e)},sessionState:function(){return s?Yi.CONNECTED:Yi.NOT_CONNECTED},subscribeToPresence:function(e){"function"==typeof e&&(f.push(e),VizbeeSDK.logger.debug("SyncController::subscribeToPresence - listener added"))},unsubscribeFromPresence:function(e){var t=f.indexOf(e);t>-1&&(f.splice(t,1),VizbeeSDK.logger.debug("SyncController::unsubscribeFromPresence - listener removed"))},getActiveSenders:function(){return r&&"function"==typeof r.getActiveSenders?r.getActiveSenders():{}},enableSynchronousPublish:function(){try{var e=r&&r.baseSync;e&&"function"==typeof e.enableSynchronousPublish&&e.enableSynchronousPublish()}catch(e){VizbeeSDK.logger.error("SyncController::enableSynchronousPublish - error",e)}}};function h(){if(s&&u){a&&!l&&(l=!0,er.onSubscribedToSync()),VizbeeSDK.logger.debug("SyncController::sendJoin - sending initial JOIN HELLO UPD message");var e={cmd:{ns:"video",name:"hello",type:"upd"},hstatus:{id:i.deviceId,type:"SCREEN",vip:"false"}};r.send(e)}else VizbeeSDK.logger.debug("SyncController::sendJoin - NOT sending JOIN HELLO yet",s,u)}function v(){if(s&&u){VizbeeSDK.logger.debug("SyncController::sendOlleh - sending OLLEH UPD message");var e={cmd:{ns:"video",name:"olleh",type:"upd"},hstatus:{id:i.deviceId,type:"SCREEN",vip:"false"}};r.send(e)}else VizbeeSDK.logger.debug("SyncController::sendOlleh - NOT sending Olleh",s,u)}function g(e){var t,o,a,s,u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!("int"!==e.cmd.type&&e.hstatus&&"SCREEN"==e.hstatus.type||"req"!==e.cmd.type&&"int"!==e.cmd.type))switch(e.cmd.name){case"launch_applet":if(Xi.isUndefined(e.cmd.param))return;VizbeeSDK.logger.debug("SyncController::launch_applet - called",e.cmd.param),void 0!==window.VGA&&window.VGA.launch(e.cmd.param);break;case"hello":t={cmd:{ns:"video",name:"hello",type:"rsp"},hstatus:{id:i.deviceId,type:"SCREEN"}};try{"app"!==n.app.state?((s=k()).vstatus&&(t.vstatus=s.vstatus),s.vinfo&&(t.vinfo=s.vinfo),s.vinfoext&&(t.vinfoext=s.vinfoext),t.hstatus.vip="true"):t.hstatus.vip="false","int"==e.cmd.type&&(t.cmd.type="req"),r.send(t)}catch(e){VizbeeSDK.logger.error("SyncController::videoMessgaeHandler -- hello command. error ",e)}break;case"will_start_video":if(VizbeeSDK.logger.debug("SyncController::videoMessageHandler::will_start_video called",e),!(c=e.internal.videoInfo))return;var l=e.internal.videoStartsIn;l=l||0,tr.willStart(c,l);break;case"start_video":VizbeeSDK.logger.debug("SyncController::videoMessageHandler::start_video called",e);var c=e.internal.videoInfo,d=e.internal.startVideoSource?e.internal.startVideoSource:"default";if(!c)return;"app"!==n.app.state?(VizbeeSDK.logger.debug("SyncController::videoMessageHandler()::start_video -- CALLING VIDEOADAPTER.STOP()"),tr.stop("stop_reason_before_next_video"),setTimeout(function(){VizbeeSDK.logger.debug("SyncController::videoMessageHandler()::start_video -- CALLING START AFTER STOP"),b(c,d)},3e3)):b(c,d);break;case"pause":if("video"!==n.app.state)return void VizbeeSDK.logger.warn("pause requested when not in 'video' state",n.app.state);tr.pause();break;case"play":if("video"!==n.app.state)return void VizbeeSDK.logger.warn("play requested when not in 'video' state",n.app.state);tr.play();break;case"stop":if("app"==n.app.state)return void VizbeeSDK.logger.warn("stop requested when in 'app' state",n.app.state);VizbeeSDK.logger.info("syccontroller:: stop ",e.cmd.param);var f=e.cmd.param||"stop_reason_unknown";tr.stop(f);break;case"exit":t={cmd:{ns:"video",name:"olleh",type:"upd"},hstatus:{id:i.deviceId,type:"SCREEN",vip:"false"}},r.send(t),tr.exit();break;case"olleh":"int"==e.cmd.type&&v();break;case"status":_();break;case"seek":if(n.ad.playing)return VizbeeSDK.logger.debug("1",n.ad),void VizbeeSDK.logger.debug(n.video);if(Xi.isUndefined(e.cmd.param))return void VizbeeSDK.logger.debug("2",e);if(o=parseInt(e.cmd.param,10),isNaN(o))return void VizbeeSDK.logger.debug("3",o);if(n.video&&n.video.duration&&(a=n.video.duration,VizbeeSDK.logger.debug("4",o,a),o>a))return;if(o<0)return void VizbeeSDK.logger.debug("5",o);tr.seek(o);break;case"vol_up":"function"==typeof tr.volumeUp&&tr.volumeUp();break;case"vol_down":"function"==typeof tr.volumeDown&&tr.volumeDown();break;case"mute":"function"==typeof tr.mute&&tr.mute(!0);break;case"unmute":"function"==typeof tr.mute&&tr.mute(!1);break;case"set_tracks":"function"==typeof tr.setTracks&&tr.setTracks(e.cmd.param||[]);break;case"event":"function"==typeof tr.onEvent&&e.einfo&&e.einfo.data&&(tr.onEvent(e.einfo),"tv.vizbee.homesso.signin"===e.einfo.type&&function(e,t){m(e.type,y({h:t,b:{payload:e.data}}))}(e.einfo,u))}}function y(e){var t=e.h.ssinfo,n={deviceId:t.REMOTE_DEVICE_ID,deviceType:t.REMOTE_DEVICE_TYPE,friendlyName:t.REMOTE_FRIENDLY_NAME,networkSessionId:t.REMOTE_NETWORK_SESSION_ID};return{payload:e.b.payload,senderInfo:n}}function m(e,t){if(window.vizbee&&window.vizbee.continuity&&window.vizbee.continuity.xmessages)if(window.vizbee.continuity.xmessages.VizbeeBicastSessionManager){var n=new window.vizbee.continuity.xmessages.VizbeeBicastSessionManager;if(n){var i=n.getSession();if(i){var r=i.getMessagingClient();r?r.onReceive(e,t.payload,t.senderInfo):VizbeeSDK.logger.error("SyncController::sendMessageToMessagingClient - Failed to initialize Vizbee session: messaging client not found")}else VizbeeSDK.logger.error("SyncController::sendMessageToMessagingClient - Failed to initialize Vizbee session: session not found")}else VizbeeSDK.logger.error("SyncController::sendMessageToMessagingClient - Failed to initialize Vizbee session: unable to create session manager instance")}else VizbeeSDK.logger.error("SyncController::sendMessageToMessagingClient - Failed to initialize Vizbee session: session manager not found");else VizbeeSDK.logger.error("SyncController::sendMessageToMessagingClient - Failed to initialize Vizbee session: xmessages not found")}function b(e,t){VizbeeSDK.logger.debug("SyncController::doStartVideo -- called StateManager.reset()",n),n.reset(),VizbeeSDK.logger.debug("SyncController::doStartVideo -- calling setSyncVideoInfo",n,n.getSyncVideoInfo()),n.setSyncVideoInfo(e),n.syncStartVideoSource=t,VizbeeSDK.logger.debug("SyncController::doStartVideo -- calling VideoAdapter.start() with videoInfo",e),tr.start(e)}function S(e){"appIsSet"===e.type?(VizbeeSDK.logger.debug("SyncController::stateHandler appIsSet"),u=!0,h()):_()}function _(){if("app"!==n.app.state)if("UNKNOWN"!==n.video.state)if("PAUSED_BY_AD"!==n.video.state||"UNKNOWN"!==n.ad.state){var e=k();r&&r.send(e)}else VizbeeSDK.logger.debug("SyncController:sendUpdate - unknown video/ad state, not sending. app/video/ad.state: ",n.app.state,n.video.state,n.ad.state);else VizbeeSDK.logger.verbose("SyncController::sendUpdate - UNKNOWN video state, not sending");else"AppStateManager"==n.type&&VizbeeSDK.logger.verbose("SyncController::sendUpdate - in app state, not sending update",n)}function k(){var e,t=n.video,i=n.ad,r=n.getSyncVideoInfo(),o=n.getCurrentVideoInfo(),a={cmd:{name:"status",ns:"video",type:"upd"}};t&&(e=t.volume,t.muted&&(e=0),a.vinfo={id:t.id,url:""},r.id||(r=o),a.vinfo.islive=!1,a.vinfoext={title:"",subtitle:"",imgurl:"",desc:"",videostarttime:0,custommetadata:{},customstreaminfo:{},qos:{}},VizbeeSDK.logger.verbose("SyncController::createStatusMessage:: - ",r,o),o&&o.id&&r&&r.id&&r.id==o.id?(a.vinfo.url=r.videourl,a.vinfo.islive=r.islive,a.vinfoext={title:r.title||"",subtitle:r.subtitle||"",imgurl:r.imgurl||"",desc:r.desc||"",videostarttime:r.starttime||0,custommetadata:r.customMetadata||r.custommetadata,customstreaminfo:r.customStreamInfo||r.customstreaminfo,qos:T(t)}):o&&o.id&&(a.vinfo.url=o.videourl,a.vinfo.islive=o.islive,a.vinfoext={title:o.title||"",subtitle:o.subtitle||"",imgurl:o.imgurl||"",desc:o.desc||"",videostarttime:o.starttime||0,custommetadata:o.customMetadata||o.custommetadata,customstreaminfo:o.customStreamInfo||o.customstreaminfo,qos:T(t)}),a.vinfoext.wasVideoStartedByVizbee=n.wasVideoStartedByVizbee(),a.vstatus={du:parseInt(t.duration,10)||-1,id:t.id,po:parseInt(t.position,10)||-1,st:t.state,vol:parseInt(e),cc:t.cc,tr:t.tr,er:t.error||{}},"Infinity"!=t.duration&&"0"!=t.duration||(a.vstatus.du=0)),i&&t&&"PAUSED_BY_AD"==t.state&&(a.adstatus={du:parseInt(i.duration,10)||-1,id:i.id,po:parseInt(i.position,10)||-1,st:i.state});var s=$i.getVideoInfo();return s&&(s.id&&(a.vinfo=a.vinfo||{},a.vinfo.id=s.id,a.vstatus=a.vstatus||{},a.vstatus.id=s.id),void 0!==s.videourl&&(a.vinfo=a.vinfo||{},a.vinfo.url=s.videourl),void 0!==s.islive&&(a.vinfo=a.vinfo||{},a.vinfo.islive=s.islive),void 0!==s.title&&(a.vinfoext=a.vinfoext||{},a.vinfoext.title=s.title),void 0!==s.subtitle&&(a.vinfoext=a.vinfoext||{},a.vinfoext.subtitle=s.subtitle),void 0!==s.imgurl&&(a.vinfoext=a.vinfoext||{},a.vinfoext.imgurl=s.imgurl),void 0!==s.isdvrsupported&&(a.vinfoext=a.vinfoext||{},a.vinfoext.isdvrsupported=s.isdvrsupported),void 0!==s.state&&(a.vstatus=a.vstatus||{},a.vstatus.st=s.state),void 0!==s.position&&(a.vstatus=a.vstatus||{},a.vstatus.po=parseInt(s.position,10)),void 0!==s.duration&&(a.vstatus=a.vstatus||{},a.vstatus.du=parseInt(s.duration,10))),a}function T(e){if(!e)return{};var t=e.qos||{};return{starttime:e.startTime||0,audiobufferlevel:e.audioBufferLevel,videobufferlevel:e.videoBufferLevel,adPodStartedTimeInMs:t.adPodStartedTimeInMs||0,adPodEndedTimeInMs:t.adPodEndedTimeInMs||0,loadReceivedByAppTimeInMs:t.loadReceivedByAppTimeInMs||0,loadReceivedByPlayerTimeInMs:t.loadReceivedByPlayerTimeInMs||0,metadataLoadedTimeInMs:t.metadataLoadedTimeInMs||0,playerReadyToPlayTimeInMs:t.playerReadyToPlayTimeInMs||0,playbackStartedTimeInMs:t.playbackStartedTimeInMs||0}}},cr=Nt(),dr=nt(),fr=Mt(),pr=wt(),hr=Dt(),vr=function(){if(Zn)return Qn;Zn=1;var e,t,n=J(),i=new(0,tt().EventEmitter),r={preparing:!1,playing:!1,alladscomplete:!1},o=-1,a=-1,s=!1;function u(e){var i={type:"ad",position:-1,duration:-1,preparing:r.preparing,playing:r.playing,alladscomplete:r.alladscomplete};return r.playing&&(a>0?(i.position=o,i.duration=a,VizbeeSDK.logger.debug("[VZB-DEBUG] AdAdapter::Status using app ad timing — po:",o,"du:",a)):t&&(i.position=1e3*t.currentTime(),i.duration=1e3*t.getDuration(),VizbeeSDK.logger.debug("[VZB-DEBUG] AdAdapter::Status using videoEl — po:",i.position,"du:",i.duration))),n.extend(i,e)}function l(e){var o,a,s=!n.contains(["timeupdate"],e.type);(r.preparing||r.playing)&&(o=new u,"timeupdate"!==e.type&&VizbeeSDK.logger.debug("AdAdapter::handleAdEvent() - not a timeupdate event",e.type),"preparing"===e.type&&(a="LOADING",o.id="UNKNOWN"),"play"===e.type&&(a="LOADING"),"playing"===e.type&&(a="PLAYING",t&&t.basePlayer&&t.basePlayer.videoInfo&&t.basePlayer.videoInfo.src&&(o.id=t.basePlayer.videoInfo.src)),"error"===e.type&&(a="INTERRUPTED",r.playing=!1),"ended"===e.type&&(a="FINISHED",r.playing=!1),o.playing=r.playing,a&&(o.state=a),i.emit("ad",o,s))}function c(e){var t=e.type||"UNKNOWN";VizbeeSDK.logger.debug("[VZB-DEBUG] AdAdapter::adsManagerHandleStateChange state:",t,"data:",e.data),-1!=["ad-pod-start","ad-pod-end","ad-start","ad-playing"].indexOf(t)&&(r.preparing=!1,r.playing=!1,"ad-pod-start"===t?(s=!1,r.preparing=!0,l({type:"preparing"})):"ad-start"===t?(s=!1,l({type:"play"})):"ad-playing"===t?(r.playing=!0,e.data&&(void 0!==e.data.duration&&e.data.duration>0&&(a=e.data.duration),void 0!==e.data.position&&e.data.position>=0&&(o=e.data.position),VizbeeSDK.logger.debug("[VZB-DEBUG] AdAdapter::ad-playing stored timing — po:",o,"du:",a))):("ad-pod-end"===t&&(r.playing=!1,r.alladscomplete=!0,o=-1,a=-1),i.emit("ad",new u({position:-1,duration:-1,state:"UNKNOWN",preparing:r.preparing,playing:r.playing}),!1)))}function d(n){VizbeeSDK.logger.debug("VIZBEE: AdAdapter.setAdVideo()",n),n&&((t=n).onError=function(e){r.playing&&(l({type:"error"}),s=!1)},t.onEnded=function(){r.playing&&(l({type:"ended"}),s=!1)},t.onTimeUpdate=function(e){r.playing&&(s?l({type:"timeupdate"}):(s=!0,l({type:"playing"})))},e||f(t))}function f(t){VizbeeSDK.logger.debug("VIZBEE: AdAdapter.setAdsManager()",t),(e=t).onEvent=c,d(e)}return Qn={setAdVideo:d,setAdsManager:f,reset:function(){r.preparing=!1,r.playing=!1,r.alladscomplete=!1,o=-1,a=-1,i.emit("ad",new u({position:-1,duration:-1,state:"UNKNOWN"}),!1)},addListener:function(e){i.addListener("ad",e)},removeListener:function(e){i.removeListener("ad",e)}}}(),gr=function(){if(ei)return $n;ei=1;var e,t,n=J(),i=new(0,tt().EventEmitter),r={playing:!1,alladscomplete:!1};function o(e){var i={type:"ad",position:-1,duration:-1,playing:r.playing,alladscomplete:r.alladscomplete};return t&&(i.position=1e3*t.currentTime,i.duration=1e3*t.duration),n.extend(i,e)}function a(e){var a,s,u=!n.contains(["timeupdate","progress","suspend"],e.type);r.playing&&(a=new o,"timeupdate"!==e.type&&VizbeeSDK.logger.debug("handleAdEvent",e.type,t.currentTime),"loadedmetadata"===e.type&&(s="LOADING"),"play"===e.type&&(s="LOADING",a.id=t.src),"playing"===e.type&&(s="PLAYING"),"error"===e.type&&(s="FAILED"),"ended"===e.type&&(s="FINISHED"),t.ended&&(s="FINISHED"),s&&(a.state=s),i.emit("ad",a,u))}function s(e){r.playing=e.type===google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,r.alladscomplete=e.type===google.ima.AdEvent.Type.ALL_ADS_COMPLETED,VizbeeSDK.logger.debug("ADADAPTER:adsManagerHandler",e.type,"playing",r.playing,"(currentTime "+t.currentTime+")"),i.emit("ad",new o({position:-1,duration:-1,state:"UNKNOWN"}),!1)}return $n={setAdVideo:function(e){!function(e,t){["error","play","playing","ended","timeupdate","loadedmetadata"].forEach(function(n){e.addEventListener(n,a,!1),t&&t.removeEventListener(n,a,!1)})}(e,t),t=e},setAdsManager:function(t){!function(e,t){google&&google.ima&&[google.ima.AdErrorEvent.Type.AD_ERROR,google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,google.ima.AdEvent.Type.ALL_ADS_COMPLETED].forEach(function(n){e&&e.addEventListener(n,s),t&&t.removeEventListener(n,s)})}(t,e),e=t,VizbeeSDK.logger.debug("adsManager cue points,",e.getCuePoints())},reset:function(){r.playing=!1,r.alladscomplete=!1,i.emit("ad",new o({position:-1,duration:-1,state:"UNKNOWN"}),!1)},addListener:function(e){i.addListener("ad",e)},removeListener:function(e){i.removeListener("ad",e)}},$n}(),yr=function(){if(ri)return ii;ri=1,J();var e,t,n=function(){if(ni)return ti;ni=1;var e=tt().EventEmitter,t="ad",n=new e,i={type:t,state:"UNKNOWN",id:"UNKNOWN",position:-1,duration:-1,playing:!1,adPodStarted:!1,adPodsPlayedDuration:0,totalAdPodsDuration:0};return ti={adStatus:i,reset:function(){i.state="UNKNOWN",i.id="UNKNOWN",i.position=-1,i.duration=-1,i.playing=!1,i.adPodStarted=!1},resetTotalAdPodsDuration:function(){i.adPodsPlayedDuration=0,i.totalAdPodsDuration=0},addListener:function(e){n.addListener(t,e)},removeListener:function(e){n.removeListener(t,e)},notify:function(e){n.emit(t,i,e)}}}(),i=["loadedmetadata","play","playing","timeupdate","error","ended"];function r(i){if(n.adStatus.adPodStarted){var r="LOADING";"loadedmetadata"==i.type||"play"==i.type?r="LOADING":"playing"==i.type?(n.adStatus.id=e.src,r="PLAYING"):"timeupdate"==i.type?r="PLAYING":"error"==i.type?r="FAILED":("ended"==i.type||e.ended)&&(r="FINISHED");var o=!1;r!=n.adStatus.state&&(o=!0,n.adStatus.state=r),n.adStatus.playing&&n.adStatus.duration>0&&t>=0?n.adStatus.position=1e3*e.currentTime-t:n.adStatus.position=-1,n.notify(o)}}function o(){n.reset(),t=-1}function a(){o(),n.notify()}return ii={setAdVideo:function(t){!function(e){e&&i.forEach(function(t){e.removeEventListener(t,r,!1)})}(e),function(e){e&&i.forEach(function(t){e.addEventListener(t,r,!1)})}(e=t)},setAdPodStart:function(e,t,i){o(),n.adStatus.adPodStarted=!0},setAdPodEnd:function(){a()},setTotalAdPodsDuration:function(e){n.adStatus.totalAdPodsDuration=e||0,n.notify(!1)},setAdStart:function(e,i){n.adStatus.playing=!0,t=e,n.adStatus.duration=i,n.adStatus.adPodsPlayedDuration+=i},setAdEnd:function(){n.adStatus.state="FINISHED",n.notify(!0),n.adStatus.playing=!1,t=-1,n.adStatus.duration=-1},getAdStatus:function(){return n.adStatus},reset:a,resetTotalAdPodsDuration:function(){n.resetTotalAdPodsDuration()},addListener:function(e){n.addListener(e)},removeListener:function(e){n.removeListener(e)}}}(),mr=xt(),br=(ai||(ai=1,oi={getDeviceID:function(e,t,n){if(VizbeeTV&&VizbeeTV.tv)VizbeeTV.tv.uniqueDeviceID(function(n){switch(VizbeeSDK.logger.debug("Device::getDeviceID - DeviceIDAlgorithm = "+VizbeeTV.tv.deviceIDAlgorithm),VizbeeTV.tv.deviceIDAlgorithm){case"VTV_SESSION_ID":case"VTV_DEFAULT":case"VTV_URL_PARAMS":n=e.platform+":"+n;break;case"VTV_INTERNAL_IP":n=e.platform+":"+e.externalIp.toLowerCase()+":"+n}VizbeeSDK.logger.debug("Device::getDeviceID - deviceID = "+n),t(n)},function(e){VizbeeSDK.logger.error("PROD","C:001 failed to fetch deviceId, halting SDK initialization",e),n&&n(e)},e);else{var i="VizbeeTV framework not initialized yet, halting SDK initialization";VizbeeSDK.logger.error("PROD","C:002",i),n&&n(i)}}}),oi),Sr=void 0,_r=void 0,kr=!1,Tr=[],Pr="vzb0000000";function Ir(){if(li&&li.features&&li.features.shouldSyncDisconnectOnBackground){if(kr)return;Sr?Sr.isConnected()||(VizbeeSDK.logger.i("SDK","onForeground","connecting VGA"),kr=!0,Ar(Pr,function(){kr=!1,_r&&!_r.isConnected()&&(VizbeeSDK.logger.i("SDK","onForeground","connecting APPLET after VGA ",ui.id),kr=!0,Ar(ui.id,function(){kr=!1}))})):_r&&!_r.isConnected()&&(VizbeeSDK.logger.i("SDK","onForeground","connecting APPLET ",ui.id),kr=!0,Ar(ui.id,function(){kr=!1}))}}function Er(){return VizbeeSDK.logger.i("SDK","onBackground"),li&&li.features&&li.features.shouldExitOnBackground?(VizbeeSDK.logger.i("SDK","onBackground","exiting the app"),void VizbeeTV.tv.exit()):li&&li.features&&li.features.shouldSyncDisconnectOnBackground?(VizbeeSDK.logger.i("SDK","onBackground","disconnecting from sync"),Sr&&Sr.isConnected()&&(VizbeeSDK.logger.i("SDK","_disconnectFromSync","disconnecting VGA"),Sr.disconnect()),_r&&_r.isConnected()&&(VizbeeSDK.logger.i("SDK","_disconnectFromSync","disconnecting APPLET"),_r.disconnect()),void(kr=!1)):void Mr()}function Vr(e){VizbeeSDK.logger.i("SDK","onEnd","sending olleh"),e&&e.isTeardown&&(Sr&&Sr.enableSynchronousPublish(),_r&&_r.enableSynchronousPublish()),Mr()}function Ar(e,t){sr.getConfig({appId:e||ui.id,deviceId:"",platform:VizbeeTV.tv.cloudPlatformName,platformModel:VizbeeTV.tv.platformModel,hostProxy:ui.configServiceProxyHost},function(e){li=e,VizbeeSDK.logger.d("SDK","getConfig","got config=",li),li.customAttributesForMetrics=ui.customAttributesForMetrics,li.features&&li.features.enableIpv6Lookup?ur.getIpv6Address(function(e){VizbeeSDK.logger.d("SDK","getIpv6Address","got response=",e),li.ipv6Address=e,Cr(li,t)}):(VizbeeSDK.logger.d("SDK","getIpv6Address","skipped - enableIpv6Lookup not set in screen config"),Cr(li,t))})}function Cr(e,t){br.getDeviceID(e,function(n){if(VizbeeSDK.logger.d("SDK","onConfigReady","using deviceid="+n),!function(e){if(!e||"string"!=typeof e)return!1;var t=e.split(":"),n=t[t.length-1];if(!n)return!1;var i=n.toLowerCase();return"unknown_device_id"!==i&&"0.0.0.0"!==i&&"127.0.0.1"!==i&&"localhost"!==i&&"undefined"!==i&&"null"!==i}(n))return VizbeeSDK.logger.e("SDK","onConfigReady","PROD - SDK init aborted: deviceId is a default/sentinel value; sync will not be established",n),kr=!1,void(t&&t(void 0));e.deviceId=n,function(e,t){(function(e){if(e&&e.debug&&e.debug.clients&&e.debug.clients.length>0&&e.debug.server)for(var t=0;t<e.debug.clients.length;t++){var n=e.debug.clients[t];if(n.ip&&n.ip==e.externalIp){var i=e.appId+":"+e.platform+":"+e.externalIp,r=n.aka||i;r="["+r+"]",Je.enableRemoteLogging(e.debug.server,r),window.VizbeeSDK&&window.VizbeeSDK.logger.setLevel(window.VizbeeSDK.logger.LEVEL.DEBUG),window.VizbeeTV&&window.VizbeeTV.logger.setLevel(window.VizbeeTV.logger.LEVEL.DEBUG),window.VGA&&window.VGA.logger.setLevel(window.VGA.logger.LEVEL.DEBUG)}}})(e),e.appId==Pr||e.features&&e.features.targetAppType==Ki?(Pr=e.appId,Sr||(Sr=new lr(e,!0)),Sr.connect(function(e){e?VizbeeSDK.logger.d("SDK","onConfigAndDeviceIDReady","connected VGA"):VizbeeSDK.logger.e("SDK","onConfigAndDeviceIDReady","failed to connect VGA")})):(_r||(VizbeeSDK.logger.d("SDK","onConfigAndDeviceIDReady","creating appletSyncController"),_r=new lr(e,!1),ar.each(Tr,function(e){e()})),VizbeeSDK.logger.d("SDK","onConfigAndDeviceIDReady","connecting appletSyncController"),_r.connect(function(e){e?VizbeeSDK.logger.d("SDK","onConfigAndDeviceIDReady","connected APPLET"):VizbeeSDK.logger.e("SDK","onConfigAndDeviceIDReady","failed to connect APPLET")})),t&&t(e)}(e,t)},function(e){VizbeeSDK.logger.e("SDK","onConfigReady","PROD - SDK init aborted: deviceId fetch failed; sync will not be established",e),kr=!1,t&&t(void 0)})}function Dr(e){VizbeeSDK.logger.d("SDK","setApp"),dr.setApp(e)}function wr(e){VizbeeSDK.logger.d("SDK","setVideo","video=",e),pr.setVideo(e)}function Nr(e){si={vzb_ad_ima:gr,vzb_ad_ssai:yr,vzb_ad_ssai_avplay:null,vzb_ad_default:vr}[e.toLowerCase()],pr.setAdAdapter(si)}function Mr(){mr.send({type:"sync_proxy_video_cmds",cmd:{ns:"video",name:"olleh",type:"int"}})}var xr={ContinuityContext:or,QueueBase:null,QueueManager:null,QueueDelegate:null,QueueDelegateFactory:null},Or={VERSION:"7.8.41",wasVideoStartedByVizbee:function(){return cr&&cr.wasVideoStartedByVizbee()},init:function(e){VizbeeSDK.logger.i("SDK","init"),VizbeeTV.tv.appLifeCycleManager&&(VizbeeTV.tv.appLifeCycleManager.addHandler("onForeground",Ir),VizbeeTV.tv.appLifeCycleManager.addHandler("onBackground",Er),VizbeeTV.tv.appLifeCycleManager.addHandler("onEnd",Vr)),ui=e,VizbeeSDK.logger.i("SDK","onStart"),ui&&ui.id&&(function(e){var t;VizbeeSDK.logger.d("SDK","handleInitOptions"),e.video&&wr(e.video),e.app&&Dr(e.app),e.videoAdapter&&(t=e.videoAdapter,VizbeeSDK.logger.d("SDK","setHostVideoAdapter","video=",t),hr.setVideoAdapter(t)),e.adType&&Nr(e.adType),e.VGA&&e.isVGA&&fr.setVGA(e.VGA)}(ui),pr.init(),Ar())},setApp:Dr,setVideo:wr,setVideoGuid:function(e,t){pr.setId(e,t)},setVideoInfo:function(e){VizbeeSDK.logger.d("SDK","setVideoInfo","videoInfo=",e),pr.setVideoInfo(e)},setVideoStop:function(){pr.setVideoStop()},setAdsVideo:function(e){VizbeeSDK.logger.d("SDK","setAdsVideo","video=",e),si?si.setAdVideo(e):VizbeeSDK.logger.d("SDK","setAdsVideo","AdAdapter not configured; skipping")},getAdsAdapter:function(){return si},setAdType:Nr,sendXMessage:function(e,t,n){if(_r){if(ar.get(li,["features","useXMessagesFormat"])){var i={type:"sync_proxy_video_cmds",cmd:{type:"req",ns:t,name:"x",param:""},payload:e};return VizbeeSDK.logger.d("XMessages",this.constructor.name,"sendXMessage","sending message: ".concat(JSON.stringify(i)," in new format to sync controller")),void mr.send(i)}var r={type:"sync_proxy_video_cmds",cmd:{type:"req",ns:"video",name:"event",param:""},einfo:{type:t,data:e}};VizbeeSDK.logger.d("XMessages",this.constructor.name,"sendXMessage","sending message: ".concat(JSON.stringify(r)," in old format to sync controller")),mr.send(r)}else VizbeeSDK.logger.e("XMessages",this.constructor.name,"sendXMessage","appletSyncController not initialized")},syncProxy:mr,addSyncReadyListener:function(e){Tr.push(e)},removeSyncReadyListener:function(e){Tr=ar.without(Tr,e)},getSyncController:function(){return _r},getMetricsManager:function(){return Ri},wrapVideoCallbacks:pr.wrapCallbacks,addVideoEventListener:pr.addEventListener,removeVideoEventListener:pr.removeEventListener,reset:function(){VizbeeSDK.logger.d("SDK","reset");try{_r&&(_r.disconnect(),_r=void 0)}catch(e){VizbeeSDK.logger.e("SDK","reset","error disconnecting appletSyncController.",e)}try{cr.reset()}catch(e){VizbeeSDK.logger.e("SDK","reset","error resetting AppStateManager",e)}try{dr.reset()}catch(e){VizbeeSDK.logger.e("SDK","reset","error resetting AppAdapter",e)}try{si&&si.reset()}catch(e){VizbeeSDK.logger.e("SDK","reset","error resetting AdAdapter",e)}try{pr.reset()}catch(e){VizbeeSDK.logger.e("SDK","reset"," error resetting VideoAdapter",e)}try{hr.reset()}catch(e){VizbeeSDK.logger.e("SDK","reset","error resetting HostVideoAdapter",e)}try{mr.reset()}catch(e){VizbeeSDK.logger.e("SDK","reset","error resetting SyncProxy",e)}try{VizbeeTV.tv.appLifeCycleManager&&(VizbeeTV.tv.appLifeCycleManager.removeHandler("onForeground",Ir),VizbeeTV.tv.appLifeCycleManager.removeHandler("onBackground",Er),VizbeeTV.tv.appLifeCycleManager.removeHandler("onEnd",Vr))}catch(e){VizbeeSDK.logger.e("SDK","reset","error removing app lifecycle handlers",e)}},framework:xr};window.VizbeeSDK||(window.VizbeeSDK={},VizbeeSDK.logger||(VizbeeSDK.logger=new Je,VizbeeSDK.logger.setPrefix("[Vizbee]")));var zr=window.VZB;zr=Or,window.VZB=zr;var Lr=function(){return s(function e(){o(this,e),this.platformType="",this.platformConfig={},this.appAdapter=void 0,this.vgaAdapter=void 0,this.videoAdapter=void 0,this.adAdapter=void 0,this.vzbOptions={}},[{key:"setOptions",value:function(e){e||(e={}),this.vzbOptions=e}},{key:"getOptions",value:function(){return this.vzbOptions}},{key:"initAppOnPlatform",value:function(e,t,n,i){this.appAdapter=t.appAdapter||t,this.vgaAdapter=t.vgaAdapter,this.videoAdapter=t.videoAdapter,this.adAdapter=t.adAdapter,this.platformType=n,this.platformConfig=i,this.platformConfig.appId=e,null==this.platformConfig.standalone&&(this.platformConfig.standalone=!0),VizbeeTV.init(this.platformType,this.platformConfig);var r=this.appAdapter.startVideo||function(){},o=this;this.appAdapter.startVideo=function(e,t){t=t||0,o.platformConfig.standalone||o.setVideoGuid(e.id,e.isLive||e.islive),r(e,t)};var a={id:e,app:this.appAdapter,videoAdapter:this.videoAdapter,adAdapter:this.adAdapter,customAttributesForMetrics:{}};this.vgaAdapter?(a.isVGA=!0,a.VGA=this.vgaAdapter):a.video=VizbeeTV.tv.player,a.customAttributesForMetrics=c(a.customAttributesForMetrics,this.platformConfig.customAttributesForMetrics,this.vzbOptions.customAttributesForMetrics),this.vzbOptions.configServiceProxyHost&&(a.configServiceProxyHost=this.vzbOptions.configServiceProxyHost),VZB.init(a)}},{key:"setAdAdapterType",value:function(e){VZB.setAdType(e)}},{key:"getAdsAdapter",value:function(){return VZB.getAdsAdapter()}},{key:"setAdsVideo",value:function(e){VZB.setAdsVideo(e)}},{key:"setVideoElement",value:function(e){if(!e)return"undefined"!=typeof VizbeeSDK&&VizbeeSDK.logger&&VizbeeSDK.logger.warn("BaseAPIWrapper::setVideoElement - INVALID newVideoElement"),!1;if(!this.platformConfig)return"undefined"!=typeof VizbeeSDK&&VizbeeSDK.logger&&VizbeeSDK.logger.warn("BaseAPIWrapper::setVideoElement - SDK not initialized"),!1;if(this.platformConfig.videoElement===e)return!0;this.platformConfig.videoElement=e;var t=c({},this.platformConfig,{standalone:!0});return"undefined"!=typeof VizbeeTV&&VizbeeTV.tv&&VizbeeTV.tv.player&&"function"==typeof VizbeeTV.tv.player.reconstruct&&VizbeeTV.tv.player.reconstruct(t),this.setAdsVideo(e),!0}},{key:"setVideoGuid",value:function(e,t){VZB.setVideoGuid(e,t)}},{key:"setVideoInfo",value:function(e){VZB.setVideoInfo(e),this.setVideoGuid(e.id||e.videourl,e.islive)}},{key:"setVideoStop",value:function(){VZB.setVideoStop()}}])}(),Rr={},Kr=function(){function e(){return o(this,e),r(this,e,arguments)}return p(e,Lr),s(e,[{key:"VERSION",get:function(){return window.VZB?window.VZB.VERSION:""}},{key:"init",value:function(e,t,n,i){var r=We.getPlatformType();r&&this.initAppOnPlatform(e,t,r,n,t.mediaManagerAdapter,i)}},{key:"initAppOnPlatform",value:function(e,t,n,i,r,o){n=n.toLowerCase(),Rr[n]&&!t.vgaAdapter?(this._apiWrapper=new Rr[n],this._apiWrapper.setOptions(o),this._apiWrapper.initAppOnPlatform(e,t,n,i,r)):(this._apiWrapper=new Lr,this._apiWrapper.setOptions(o),this._apiWrapper.initAppOnPlatform(e,t,n,i))}},{key:"setVideoGuid",value:function(e,t){if(this._isAPIWrapperInitialized())return this._apiWrapper.setVideoGuid(e,t),!0}},{key:"setVideoInfo",value:function(e){if(this._isAPIWrapperInitialized())return this._apiWrapper.setVideoInfo(e),!0}},{key:"setVideoStop",value:function(){if(this._isAPIWrapperInitialized())return this._apiWrapper.setVideoStop(),!0}},{key:"getAdsManager",value:function(){if(this._isAPIWrapperInitialized())return this._apiWrapper.getAdsManager()}},{key:"setAdsVideo",value:function(e){if(this._isAPIWrapperInitialized())return this._apiWrapper.setAdsVideo(e),!0}},{key:"setVideoElement",value:function(e){if(this._isAPIWrapperInitialized())return this._apiWrapper.setVideoElement(e)}},{key:"setAdAdapterType",value:function(e){if(this._isAPIWrapperInitialized())return this._apiWrapper.setAdAdapterType(e),!0}},{key:"wrapAVPlayerListener",value:function(e){if(this._isAPIWrapperInitialized())return this._apiWrapper.wrapAVPlayerListener(e)}},{key:"_isAPIWrapperInitialized",value:function(){return null!=this._apiWrapper}}])}(),Ur=void 0,Fr=function(){function e(){o(this,e),this.virtualAPIWrapper=wo,this.vzbOptions={}}return s(e,[{key:"startWithOptions",value:function(e,t){this.vzbOptions=t||{},this.start(e)}},{key:"start",value:function(e){this.isValidAppId(e)&&this.virtualAPIWrapper.init(e,{},{},this.vzbOptions)}},{key:"isValidAppId",value:function(e){if("string"!=typeof e)return!1;var t=new RegExp("^vzb[0-9]+$"),n=new RegExp("^vzb(-[A-Za-z]+)+-[0-9]+$");return t.test(e)||n.test(e)}}],[{key:"getInstance",value:function(){return null==Ur&&(Ur=new e),Ur}}])}(),Br=function(){return s(function e(){o(this,e),this._configServiceProxyHost=void 0,this._customAttributesForMetrics=void 0},[{key:"configServiceProxyHost",get:function(){return this._configServiceProxyHost},set:function(e){this._configServiceProxyHost=e}},{key:"customAttributesForMetrics",get:function(){return this._customAttributesForMetrics},set:function(e){this._customAttributesForMetrics=e}}])}(),Hr=function(){return s(function e(){o(this,e)},[{key:"ContinuityContext",get:function(){return Fr}},{key:"ContinuityOptions",get:function(){return Br}}])}(),Gr=function(){return s(function e(){o(this,e),this.deeplinkHandler=void 0,this.vizbeeEventHandler=void 0,this.vizbeeSigninEventHandler=void 0},[{key:"setSignInHandler",value:function(e){"function"==typeof e?this.vizbeeSigninEventHandler=e:vizbee.logger.warn(this.constructor.name+"::setSignInHandler - NO SIGNIN Handler implemented by HostApp")}},{key:"setDeeplinkHandler",value:function(e){"function"==typeof e?this.deeplinkHandler=e:vizbee.logger.warn(this.constructor.name+"::setDeeplinkHandler - NO DEEPLINK Handler implemented by HostApp")}},{key:"setVizbeeEventHandler",value:function(e){"function"==typeof e?this.vizbeeEventHandler=e:vizbee.logger.warn(this.constructor.name+"::setVizbeeEventHandler - NO Event Handler implemented by HostApp")}},{key:"setVizbeeSigninEventHandler",value:function(e){"function"==typeof e?this.vizbeeSigninEventHandler=e:vizbee.logger.warn(this.constructor.name+"::setVizbeeSigninEventHandler - NO Event Handler implemented by HostApp")}}])}(),Wr=function(){return s(function e(){o(this,e)},null,[{key:"AD_POD_WAITING",get:function(){return"awaiting-ad-pod"}},{key:"AD_POD_START",get:function(){return"ad-pod-start"}},{key:"AD_PREPARING",get:function(){return"ad-preparing"}},{key:"AD_START",get:function(){return"ad-start"}},{key:"AD_PLAYING",get:function(){return"ad-playing"}},{key:"AD_PAUSED",get:function(){return"ad-paused"}},{key:"AD_END",get:function(){return"ad-end"}},{key:"AD_POD_END",get:function(){return"ad-pod-end"}},{key:"AD_ERROR",get:function(){return"ad-error"}}])}(),jr=function(){return s(function e(t,n){o(this,e),this._eventType=t,this._eventData=n},[{key:"eventType",get:function(){return this._eventType},set:function(e){this._eventType=e}},{key:"eventData",get:function(){return this._eventData},set:function(e){this._eventData=e}}])}(),qr=s(function e(t,n){o(this,e),this.type=t,this.data=n}),Jr=function(){return s(function e(t,n){o(this,e),this.adType=t,this.playerElement=n,this.vtvPlayerEvent=new qr},[{key:"updateAdStatus",value:function(e){this._isValidAdStatus(e)?this._handleAdStatus(e):vizbee.logger.verbose("AdAdapter::updateAdStatus - invalid ad status")}},{key:"_isValidAdStatus",value:function(e){return e instanceof jr?-1!=[Wr.AD_POD_WAITING,Wr.AD_PREPARING,Wr.AD_POD_START,Wr.AD_POD_END,Wr.AD_START,Wr.AD_PLAYING,Wr.AD_PAUSED,Wr.AD_END,Wr.AD_ERROR].indexOf(e.eventType)||(vizbee.logger.warn("AdAdapter::_isValidAdStatus - adStatus event type is invalid: ".concat(e.eventType)),!1):(vizbee.logger.warn("AdAdapter::_isValidAdStatus - adStatus is not an instance of vizbee.continuity.messages.AdStatus"),!1)}},{key:"_handleAdStatus",value:function(e){e?(vizbee.logger.verbose("AdAdapter::_handleAdStatus - eventType: ".concat(e.eventType)),this.vtvPlayerEvent.type=e.eventType,this.vtvPlayerEvent.data=e.eventData||{},VizbeeTV.tv.player.dispatchOnEvent(this.vtvPlayerEvent)):vizbee.logger.warn("AdAdapter::_handleAdStatus - invalid ad status")}}])}(),Yr=function(){return s(function e(t,n){o(this,e),this.playerType=t,this.playerElement=n,this.playHandler=void 0,this.pauseHandler=void 0,this.seekHandler=void 0,this.stopHandler=void 0,this.videoInfoGetter=void 0,this.tracksGetHandler=void 0,this.enabledTracksGetHandler=void 0,this.enableTracksHandler=void 0,this.disableTracksHandler=void 0,this.vizbeeEventHandler=void 0},[{key:"setPlayerType",value:function(e){e&&(this.playerType=e)}},{key:"setPlayerElement",value:function(e){e&&(this.playerElement=e)}},{key:"updateVideoInfo",value:function(e){window.vizbee&&vizbee.continuity.ContinuityContext.getInstance().setVideoInfo(e)}},{key:"setVideoInfoGetter",value:function(e){"function"==typeof e&&(this.videoInfoGetter=e)}},{key:"getVideoInfo",value:function(){if(this.videoInfoGetter)return this.videoInfoGetter()}},{key:"setPlayHandler",value:function(e){"function"==typeof e&&(this.playHandler=e)}},{key:"setPauseHandler",value:function(e){"function"==typeof e&&(this.pauseHandler=e)}},{key:"setSeekHandler",value:function(e){"function"==typeof e&&(this.seekHandler=e)}},{key:"setStopHandler",value:function(e){"function"==typeof e&&(this.stopHandler=e)}},{key:"getTracksHandler",value:function(e){"function"==typeof e&&(this.tracksGetHandler=e)}},{key:"getEnabledTracksHandler",value:function(e){"function"==typeof e&&(this.enabledTracksGetHandler=e)}},{key:"setAvailableTracksGetter",value:function(e){"function"==typeof e&&(this.tracksGetHandler=e)}},{key:"setEnabledTracksGetter",value:function(e){"function"==typeof e&&(this.enabledTracksGetHandler=e)}},{key:"setEnableTracksHandler",value:function(e){"function"==typeof e&&(this.enableTracksHandler=e)}},{key:"setDisableTracksHandler",value:function(e){"function"==typeof e&&(this.disableTracksHandler=e)}},{key:"setVizbeeEventHandler",value:function(e){"function"==typeof e&&(this.vizbeeEventHandler=e)}}])}(),Xr=function(){return s(function e(){o(this,e)},null,[{key:"UNKNOWN",get:function(){return"unknown"}},{key:"HTML",get:function(){return"html"}},{key:"AVPLAYER",get:function(){return"avplayer"}},{key:"BITMOVIN",get:function(){return"bitmovin"}},{key:"VIDEOJS",get:function(){return"videojs"}},{key:"THEO",get:function(){return"theo"}},{key:"SHAKA",get:function(){return"shaka"}}])}(),Qr=function(){return s(function e(){o(this,e)},null,[{key:"UNKNOWN",get:function(){return"unknown"}},{key:"SSAI",get:function(){return"ssai"}},{key:"CSAI",get:function(){return"csai"}}])}(),Zr=function(){return s(function e(){o(this,e),this._guid="",this._isLive=!1,this._startTime=0,this._videoUrl="",this._deeplink="",this._imgUrl="",this._title="",this._subtitle="",this._desc="",this._tracks=[],this._cuepoints=[],this._customStreamInfo=void 0,this._customMetadata=void 0},[{key:"toJson",value:function(){var e={};return e.id=this._guid,e.islive=this._isLive,e.starttime=this._startTime,e.videourl=this._videoUrl,e.deeplink=this._deeplink,e.imgurl=this._imgUrl,e.title=this._title,e.subtitle=this._subtitle,e.desc=this._desc,e.tracks=this._tracks,e.cuepoints=this._cuepoints,e.customstreaminfo=this._customStreamInfo,e.custommetadata=this._customMetadata,e}},{key:"fromJson",value:function(e){e?(this._guid=e.id,this._isLive=e.islive,this._startTime=e.starttime,this._videoUrl=e.videourl,this._deeplink=void 0!==e.deeplink&&null!==e.deeplink?e.deeplink:"",this._imgUrl=e.imgurl,this._title=e.title,this._subtitle=e.subtitle,this._desc=e.desc,this._tracks=e.tracks,this._cuepoints=e.cuepoints,this._customStreamInfo=e.customstreaminfo,this._customMetadata=e.custommetadata):vizbee.logger.debug(this.constructor.name+"::toJson - invalid syncVideoInfo")}},{key:"isLive",get:function(){return this._isLive},set:function(e){this._isLive=e}},{key:"guid",get:function(){return this._guid},set:function(e){this._guid=e}},{key:"videoUrl",get:function(){return this._videoUrl},set:function(e){this._videoUrl=e}},{key:"deeplink",get:function(){return this._deeplink},set:function(e){this._deeplink=e}},{key:"imgUrl",get:function(){return this._imgUrl},set:function(e){this._imgUrl=e}},{key:"title",get:function(){return this._title},set:function(e){this._title=e}},{key:"subtitle",get:function(){return this._subtitle},set:function(e){this._subtitle=e}},{key:"desc",get:function(){return this._desc},set:function(e){this._desc=e}},{key:"startTime",get:function(){return this._startTime},set:function(e){this._startTime=e}},{key:"tracks",get:function(){return this._tracks},set:function(e){this._tracks=e}},{key:"cuepoints",get:function(){return this._cuepoints},set:function(e){this._cuepoints=e}},{key:"customStreamInfo",get:function(){return this._customStreamInfo},set:function(e){this._customStreamInfo=e}},{key:"customMetadata",get:function(){return this._customMetadata},set:function(e){this._customMetadata=e}}])}(),$r=function(){return s(function e(){o(this,e)},null,[{key:"IDLE",get:function(){return"idle"}},{key:"PREPARING",get:function(){return"preparing"}},{key:"LOADING",get:function(){return"loading"}},{key:"STARTED",get:function(){return"started"}},{key:"PLAYING",get:function(){return"playing"}},{key:"PAUSED",get:function(){return"paused"}},{key:"BUFFERING",get:function(){return"buffering"}},{key:"INTERRUPTED",get:function(){return"interrupted"}},{key:"ENDED",get:function(){return"ended"}},{key:"ERROR",get:function(){return"error"}}])}(),eo=function(){return s(function e(){o(this,e),this._guid="",this._state=$r.IDLE,this._currentPosition=-1,this._duration=-1,this._isLive=!1,this._isDvrSupported=!1,this._title="",this._subtitle="",this._videoUrl="",this._imgUrl=""},[{key:"guid",get:function(){return this._guid},set:function(e){this._guid=e}},{key:"state",get:function(){return this._state},set:function(e){this._state=e}},{key:"currentPosition",get:function(){return this._currentPosition},set:function(e){this._currentPosition=e}},{key:"duration",get:function(){return this._duration},set:function(e){this._duration=e}},{key:"isLive",get:function(){return this._isLive},set:function(e){this._isLive=e}},{key:"isDvrSupported",get:function(){return this._isDvrSupported},set:function(e){this._isDvrSupported=e}},{key:"title",get:function(){return this._title},set:function(e){this._title=e}},{key:"subtitle",get:function(){return this._subtitle},set:function(e){this._subtitle=e}},{key:"videoUrl",get:function(){return this._videoUrl},set:function(e){this._videoUrl=e}},{key:"imgUrl",get:function(){return this._imgUrl},set:function(e){this._imgUrl=e}}])}(),to=function(){return s(function e(){o(this,e),this._type="",this._data=void 0},[{key:"type",get:function(){return this._type},set:function(e){this._type=e}},{key:"data",get:function(){return this._data},set:function(e){this._data=e}}])}(),no=void 0,io=function(){function e(){var t;return o(this,e),(t=r(this,e)).appAdapter=new Gr,t.playerAdapter=void 0,t.adAdapter=void 0,t.adType=void 0,t}return p(e,Fr),s(e,[{key:"getAppAdapter",value:function(){return this.appAdapter}},{key:"setAppAdapter",value:function(e){e instanceof Gr&&(this.appAdapter=e)}},{key:"getPlayerAdapter",value:function(){return this.playerAdapter}},{key:"setPlayerAdapter",value:function(e){if(!this._isPlatformPlayerInitialized())return vizbee.logger.w("DefaultContinuityContext::setPlayerAdapter - Vizbee platform player not initialized"),!1;if(!this._isValidPlayerAdapter(e))return vizbee.logger.w("DefaultContinuityContext::setPlayerAdapter - playerAdapter should be valid and of type vizbee.continuity.adapters.PlayerAdapter"),!1;this.playerAdapter=e;var t=this._buildPlatformConfig(e);return VizbeeTV.tv.player.reconstruct(t),this._setAdAdapter(),!0}},{key:"removePlayerAdapter",value:function(e){return this._isPlatformPlayerInitialized()?(this.stopVideo(),this.playerAdapter=void 0,!0):(vizbee.logger.w(this.constructor.name,"resetPlayerAdapter","Vizbee platform player not initialized"),!1)}},{key:"setPlayerAdapterWithVideoInfo",value:function(e,t){return!!this.setPlayerAdapter(e)&&this.setVideoInfo(t)}},{key:"setVideoInfo",value:function(e){return!!this._isValidVideoInfo(e)&&this.virtualAPIWrapper.setVideoInfo(e.toJson())}},{key:"getVideoInfo",value:function(){if(this.playerAdapter&&this.playerAdapter.getVideoInfo){var e=this.playerAdapter.getVideoInfo();if(e instanceof eo)return e}}},{key:"getAdAdapter",value:function(e){return this.adAdapter}},{key:"setAdAdapter",value:function(e){return e instanceof Jr?this._isValidAdType(e.adType)?(this.adAdapter=e,this.setAdType(Qr.CSAI),void this._setAdAdapter()):(vizbee.logger.w("DefaultContinuityContext::setAdAdapter - adAdapter.adType is INVALID"),!1):(vizbee.logger.w("DefaultContinuityContext::setAdAdapter - AdAdapter should be of type vizbee.continuity.adapters.AdAdapter"),!1)}},{key:"removeAdAdapter",value:function(e){this.adAdapter=void 0}},{key:"setAdType",value:function(e){this._isValidAdType(e)&&(this.adType=e,this._setAdAdapter())}},{key:"start",value:function(e){var t=this;if(this.isValidAppId(e)){var n={};n.appAdapter={startVideo:function(e){if(t.appAdapter&&t.appAdapter.deeplinkHandler){var n=new Zr;n.fromJson(e),t.appAdapter.deeplinkHandler(n)}else vizbee.logger.w(t.constructor.name,"startVideo","NO DEEPLINK HANDLER")},onEvent:function(e){if(t.appAdapter&&t.appAdapter.vizbeeSigninEventHandler&&e&&"tv.vizbee.homesign.signin"===e.type){var n=new to;n.type=e.type,n.data=e.data,t.appAdapter.vizbeeSigninEventHandler(n)}if(t.appAdapter&&t.appAdapter.vizbeeEventHandler&&e){var i=new to;i.type=e.type,i.data=e.data,t.appAdapter.vizbeeEventHandler(i)}if(t.playerAdapter&&t.playerAdapter.vizbeeEventHandler&&e){var r=new to;r.type=e.type,r.data=e.data,t.playerAdapter.vizbeeEventHandler(r)}},playVideo:function(){return!(!t.playerAdapter||!t.playerAdapter.playHandler||(t.playerAdapter.playHandler(),0))},pauseVideo:function(){return!(!t.playerAdapter||!t.playerAdapter.pauseHandler||(t.playerAdapter.pauseHandler(),0))},seekVideo:function(e){return!(!t.playerAdapter||!t.playerAdapter.seekHandler||(t.playerAdapter.seekHandler(e),0))},stopVideo:function(e){return!(!t.playerAdapter||!t.playerAdapter.stopHandler||(t.playerAdapter.stopHandler(e),0))},getTracks:function(){return!(!t.playerAdapter||!t.playerAdapter.tracksGetHandler)&&t.playerAdapter.tracksGetHandler()},getEnabledTracks:function(){return!(!t.playerAdapter||!t.playerAdapter.enabledTracksGetHandler)&&t.playerAdapter.enabledTracksGetHandler()},enableTracks:function(e){return!(!t.playerAdapter||!t.playerAdapter.enableTracksHandler||(t.playerAdapter.enableTracksHandler(e),0))},disableTracks:function(e){return!(!t.playerAdapter||!t.playerAdapter.disableTracksHandler||(t.playerAdapter.disableTracksHandler(e),0))},getVideoInfo:function(){return t._buildSyncVideoInfo()}},this.virtualAPIWrapper.init(e,n,{},this.vzbOptions)}}},{key:"stopVideo",value:function(){vizbee.logger.d(this.constructor.name,"stopVideo"),this.virtualAPIWrapper&&this.virtualAPIWrapper.setVideoStop&&(vizbee.logger.d(this.constructor.name,"stopVideo","calling setVideoStop"),this.virtualAPIWrapper.setVideoStop())}},{key:"_buildPlatformConfig",value:function(e){var t={standalone:!0,videoElement:e.playerElement,vtvPlayerListConfig:[{type:"native"}]};return e.playerType==Xr.BITMOVIN&&(t.vtvPlayerListConfig=[{type:"bitmovin"}]),e.playerType==Xr.VIDEOJS&&(t.vtvPlayerListConfig=[{type:"videojs"}]),e.playerType==Xr.THEO&&(t.vtvPlayerListConfig=[{type:"theo"}]),e.playerType==Xr.SHAKA&&(t.vtvPlayerListConfig=[{type:"shaka"}]),t}},{key:"_isValidVideoInfo",value:function(e){return e instanceof Zr||(vizbee.logger.w(this.constructor.name,"_isValidVideoInfo","videoInfo should be of type vizbee.continuity.messages.VideoInfo"),!1)}},{key:"_isValidPlayerAdapter",value:function(e){return e instanceof Yr?!(e&&!e.playerElement&&(vizbee.logger.d(this.constructor.name,"_isValidPlayerAdapter","playerAdapter should contain playerElement"),1)):(vizbee.logger.d(this.constructor.name,"_isValidPlayerAdapter","playerAdapter should be of type vizbee.continuity.adapters.PlayerAdapter"),!1)}},{key:"_isPlatformInitialized",value:function(){return VizbeeTV&&VizbeeTV.tv}},{key:"_isPlatformPlayerInitialized",value:function(){return this._isPlatformInitialized()&&VizbeeTV.tv.player}},{key:"_isValidAdType",value:function(e){return e?e==Qr.SSAI||e==Qr.CSAI||(vizbee.logger.w("DefaultContinuityContext::_isValidAdType - adType is invalid: ".concat(e)),!1):(vizbee.logger.w("DefaultContinuityContext::_isValidAdType - adType is undefined"),!1)}},{key:"_mapPlayerStateToSyncState",value:function(e){return{idle:"UNKNOWN",preparing:"UNKNOWN",loading:"BUFFERING",started:"PLAYING",playing:"PLAYING",paused:"PAUSED_BY_USER",buffering:"BUFFERING",interrupted:"INTERRUPTED",ended:"FINISHED",error:"FAILED"}[e]||e}},{key:"_getAdAdapterType",value:function(e){if(e&&e.playerType)return this.adType==Qr.CSAI?"vzb_ad_default":this.adType==Qr.SSAI?e.playerType==Xr.AVPLAYER?"vzb_ad_ssai_avplay":"vzb_ad_default":void 0;vizbee.logger.w(this.constructor.name,"_getAdAdapterType","INVALID playerAdapter")}},{key:"_buildSyncVideoInfo",value:function(){if(this.playerAdapter&&this.playerAdapter.getVideoInfo){var e=this.playerAdapter.getVideoInfo();if(e instanceof eo){var t={};return e.guid&&(t.id=e.guid),e.videoUrl&&(t.videourl=e.videoUrl),!1!==e.isLive&&(t.islive=e.isLive),!1!==e.isDvrSupported&&(t.isdvrsupported=e.isDvrSupported),e.title&&(t.title=e.title),e.subtitle&&(t.subtitle=e.subtitle),e.imgUrl&&(t.imgurl=e.imgUrl),e.currentPosition>=0&&(t.position=e.currentPosition),e.duration>=0&&(t.duration=e.duration),t}}}},{key:"_setAdAdapter",value:function(){var e=this._getAdAdapterType(this.playerAdapter);e&&this.virtualAPIWrapper&&VizbeeTV&&VizbeeTV.tv&&VizbeeTV.tv.player&&(this.virtualAPIWrapper.setAdAdapterType(e),this.virtualAPIWrapper.setAdsVideo(VizbeeTV.tv.player))}}],[{key:"getInstance",value:function(){return null==no&&(no=new e,vizbee.logger.d(this.constructor.name,"getInstance","created")),no}}])}(),ro=function(){return s(function e(t){o(this,e),t=t||{},this._getStatus=t.getStatus,this._getPlayer=t.getPlayer,this._setVideoGuid=t.setVideoGuid,this._intervalMs="number"==typeof t.intervalMs&&t.intervalMs>0?t.intervalMs:850,this._logger=t.logger||{debug:function(){},warn:function(){}},this._timer=void 0,this._lastGuid=void 0},[{key:"start",value:function(){var e=this;this._timer||(this._logger.debug("V2StatusPoller::start",this._intervalMs),this._timer=setInterval(function(){return e._onTick()},this._intervalMs))}},{key:"stop",value:function(){this._timer&&(clearInterval(this._timer),this._timer=void 0),this._lastGuid=void 0,this._logger.debug("V2StatusPoller::stop")}},{key:"_onTick",value:function(){var e;try{e=this._getStatus&&this._getStatus()}catch(e){return void this._logger.warn("V2StatusPoller::_onTick - getter threw",e)}if(e){var t=this._getPlayer&&this._getPlayer();if(t){var n=e.id;n&&n!==this._lastGuid&&("function"==typeof this._setVideoGuid&&this._setVideoGuid(n,!!e.islive),this._lastGuid=n),t.setPositionMs(e.position),t.setDurationMs(e.duration),t.dispatchOnTimeUpdate(t.currentTime())}}}}])}(),oo=void 0,ao=function(){function e(){var t;return o(this,e),(t=r(this,e))._statusPoller=void 0,t}return p(e,io),s(e,[{key:"setPlayerAdapter",value:function(t){var n=b(e,"setPlayerAdapter",this)([t]);return n&&this._updateStatusPoller(t),n}},{key:"removePlayerAdapter",value:function(t){return this.notifyPlayerState($r.INTERRUPTED),this._stopStatusPoller(),b(e,"removePlayerAdapter",this)([t])}},{key:"notifyPlayerState",value:function(e){var t=VizbeeTV&&VizbeeTV.tv&&VizbeeTV.tv.player?VizbeeTV.tv.player.currentPlayer:void 0;if(t&&e){var n=this._mapStateToEventType(e);n&&this._fireOnPlayer(t,n)}}},{key:"_mapStateToEventType",value:function(e){return{loading:"loading",buffering:"loading",started:"playing",playing:"playing",paused:"paused",interrupted:"interrupted",ended:"ended",error:"error"}[String(e).toLowerCase()]||null}},{key:"_fireOnPlayer",value:function(e,t){switch(t){case"loading":e.dispatchOnLoading();break;case"playing":e.dispatchOnPlaying();break;case"paused":e.dispatchOnPaused();break;case"ended":e.dispatchOnEnded();break;case"interrupted":e.dispatchOnInterrupted({reason:"host"});break;case"error":e.dispatchOnError({reason:"host"})}}},{key:"_isValidPlayerAdapter",value:function(e){return e instanceof Yr?!(!e.playerElement&&!e.videoInfoGetter&&(vizbee.logger.d(this.constructor.name,"_isValidPlayerAdapter","playerAdapter should contain a playerElement or a videoInfoGetter"),1)):(vizbee.logger.d(this.constructor.name,"_isValidPlayerAdapter","playerAdapter should be of type vizbee.continuity.adapters.PlayerAdapter"),!1)}},{key:"_buildPlatformConfig",value:function(t){return t&&t.playerElement?b(e,"_buildPlatformConfig",this)([t]):{standalone:!0,vtvPlayerListConfig:[{type:"native"}],playerType:t&&t.playerType}}},{key:"_updateStatusPoller",value:function(e){if(this._stopStatusPoller(),e&&e.videoInfoGetter){var t=this;this._statusPoller=new ro({intervalMs:this.vzbOptions&&this.vzbOptions.statusPollIntervalMs,logger:vizbee&&vizbee.logger,getStatus:function(){return t._buildSyncVideoInfo()},getPlayer:function(){return VizbeeTV&&VizbeeTV.tv&&VizbeeTV.tv.player?VizbeeTV.tv.player.currentPlayer:void 0},setVideoGuid:function(e,n){t.virtualAPIWrapper&&t.virtualAPIWrapper.setVideoGuid&&t.virtualAPIWrapper.setVideoGuid(e,n)}}),this._statusPoller.start()}}},{key:"_stopStatusPoller",value:function(){this._statusPoller&&(this._statusPoller.stop(),this._statusPoller=void 0)}}],[{key:"getInstance",value:function(){return null==oo&&(oo=new e,vizbee.logger.d("ElementlessContinuityContext","getInstance","created")),oo}}])}(),so=function(){return s(function e(){o(this,e),this.playHandler=void 0,this.pauseHandler=void 0,this.seekHandler=void 0,this.stopHandler=void 0,this.videoInfoGetter=void 0,this.enableTracksHandler=void 0,this.disableTracksHandler=void 0,this.availableTracksGetter=void 0,this.enabledTracksGetter=void 0,this.vizbeeEventHandler=void 0},[{key:"updateVideoInfo",value:function(e){window.vizbee&&vizbee.continuity.ContinuityContext.getInstance().setVideoInfo(e)}},{key:"setVideoInfoGetter",value:function(e){"function"==typeof e&&(this.videoInfoGetter=e)}},{key:"getVideoInfo",value:function(){if(this.videoInfoGetter)return this.videoInfoGetter()}},{key:"updateVideoStatus",value:function(e){}},{key:"setPlayHandler",value:function(e){"function"==typeof e&&(this.playHandler=e)}},{key:"setPauseHandler",value:function(e){"function"==typeof e&&(this.pauseHandler=e)}},{key:"setSeekHandler",value:function(e){"function"==typeof e&&(this.seekHandler=e)}},{key:"setStopHandler",value:function(e){"function"==typeof e&&(this.stopHandler=e)}},{key:"setAvailableTracksGetter",value:function(e){"function"==typeof e&&(this.availableTracksGetter=e)}},{key:"setEnabledTracksGetter",value:function(e){"function"==typeof e&&(this.enabledTracksGetter=e)}},{key:"setEnableTracksHandler",value:function(e){"function"==typeof e&&(this.enableTracksHandler=e)}},{key:"setDisableTracksHandler",value:function(e){"function"==typeof e&&(this.disableTracksHandler=e)}},{key:"setVizbeeEventHandler",value:function(e){"function"==typeof e&&(this.vizbeeEventHandler=e)}}])}(),uo=function(){function e(t){var n;if(o(this,e),!(t instanceof xe))throw new TypeError("BasePlayerExtension::constructor() - playerToExtend must be instance of BasePlayerExtensible.");return(n=r(this,e,[t.platform])).extendedPlayer=t,n.parentExtension=null,n.isExtendedPlayerBasePlayer()||(n.extendedPlayer.parentExtension=n),n.registerEvents(n.extendedPlayer,n),VizbeeTV.logger.debug(n.constructor.name+"::constructed"),n}return p(e,xe),s(e,[{key:"registerEvents",value:function(e,t){var n=this;e&&t?(e.onLoading=function(e){n.onLoadingHandler.call(t,e)},e.onStarted=function(e){n.onStartedHandler.call(t,e)},e.onPlaying=function(e){n.onPlayingHandler.call(t,e)},e.onPaused=function(e){n.onPausedHandler.call(t,e)},e.onBuffering=function(e){n.onBufferingHandler.call(t,e)},e.onBufferingComplete=function(e){n.onBufferingCompleteHandler.call(t,e)},e.onTimeUpdate=function(e){n.onTimeUpdateHandler.call(t,e)},e.onInterrupted=function(e){n.onInterruptedHandler.call(t,e)},e.onEnded=function(e){n.onEndedHandler.call(t,e)},e.onError=function(e){n.onErrorHandler.call(t,e)},e.onEvent=function(e){n.onEventHandler.call(t,e)}):VizbeeTV.logger.error(this.constructor.name+"::registerEvents - MISSING playerToExtend/currentPlayer")}},{key:"reconstruct",value:function(e){this.extendedPlayer.reconstruct(e)}},{key:"beforeStart",value:function(t){b(e,"start",this)([t])}},{key:"start",value:function(e){this.beforeStart(e),this.extendedPlayer.start(e)}},{key:"play",value:function(){this.extendedPlayer.play()}},{key:"pause",value:function(){this.extendedPlayer.pause()}},{key:"togglePlayPause",value:function(){VizbeeTV.logger.debug("BasePlayerExtension::togglePlayPause() -- called"),this.extendedPlayer.togglePlayPause()}},{key:"stop",value:function(e){this.extendedPlayer.stop(e)}},{key:"seek",value:function(e){this.extendedPlayer.seek(e)}},{key:"currentTime",value:function(){return this.extendedPlayer.currentTime()}},{key:"getDuration",value:function(){return this.extendedPlayer.getDuration()}},{key:"getStartTime",value:function(){return this.extendedPlayer.getStartTime()}},{key:"getBufferLevel",value:function(){return this.extendedPlayer.getBufferLevel()}},{key:"getAudioBufferLevel",value:function(){return this.extendedPlayer.getAudioBufferLevel()}},{key:"getCurrentState",value:function(){return this.extendedPlayer.getCurrentState()}},{key:"getCurrentVersion",value:function(){return this.extendedPlayer.getCurrentVersion()}},{key:"getTracks",value:function(e){return this.extendedPlayer.getTracks(e)}},{key:"getEnabledTracks",value:function(e){return this.extendedPlayer.getEnabledTracks(e)}},{key:"setTracks",value:function(e){return this.extendedPlayer.setTracks(e)}},{key:"enableTracks",value:function(e){this.extendedPlayer.enableTracks(e)}},{key:"disableTracks",value:function(e){this.extendedPlayer.disableTracks(e)}},{key:"changeAudioTrack",value:function(e){this.extendedPlayer.changeAudioTrack(e)}},{key:"doAction",value:function(e){return this.extendedPlayer.doAction(e)}},{key:"getName",value:function(){return this.extendedPlayer.getName()}},{key:"destroy",value:function(){this.resetListeners(),this.extendedPlayer.destroy()}},{key:"getStreamQualityInfo",value:function(){return this.extendedPlayer?this.extendedPlayer.getStreamQualityInfo():{}}},{key:"setStreamQualityInfo",value:function(e){this.extendedPlayer&&this.extendedPlayer.setStreamQualityInfo(e)}},{key:"resetStreamQualityInfo",value:function(){this.extendedPlayer&&this.extendedPlayer.resetStreamQualityInfo()}},{key:"basePlayer",get:function(){return this.isExtendedPlayerBasePlayer()?this.extendedPlayer.currentPlayer:this.extendedPlayer instanceof e?this.extendedPlayer.basePlayer:void 0}},{key:"isExtendedPlayerBasePlayer",value:function(){return this.extendedPlayer instanceof xe&&!(this.extendedPlayer instanceof e)}},{key:"parentPlayer",get:function(){return this.parentExtension}},{key:"onLoadingHandler",value:function(e){this.dispatchOnLoading.call(this,e)}},{key:"onStartedHandler",value:function(e){this.dispatchOnStarted.call(this,e)}},{key:"onPlayingHandler",value:function(e){this.dispatchOnPlaying.call(this,e)}},{key:"onPausedHandler",value:function(e){this.dispatchOnPaused.call(this,e)}},{key:"onBufferingHandler",value:function(e){this.dispatchOnBuffering.call(this,e)}},{key:"onBufferingCompleteHandler",value:function(e){this.dispatchOnBufferingComplete.call(this,e)}},{key:"onTimeUpdateHandler",value:function(e){this.dispatchOnTimeUpdate.call(this,e)}},{key:"onInterruptedHandler",value:function(e){this.dispatchOnInterrupted.call(this,e)}},{key:"onEndedHandler",value:function(e){this.dispatchOnEnded.call(this,e)}},{key:"onErrorHandler",value:function(e){this.dispatchOnError.call(this,e)}},{key:"onEventHandler",value:function(e){this.dispatchOnEvent.call(this,e)}}])}(),lo=function(){function e(){return o(this,e),r(this,e,[Xr.AVPLAYER,webapis.avplay])}return p(e,Yr),s(e,[{key:"setPlayerType",value:function(e){}},{key:"setPlayerElement",value:function(e){}},{key:"wrapListener",value:function(e){var t=this._getVTVAVPlayer();return null==t?(vizbee.logger.warn(this.constructor.name+"::wrapListener - can't get AVPlayer"),e):t.wrapAVPlayerListener(e)}},{key:"getListener",value:function(){var e=this._getVTVAVPlayer();if(null!=e)return e.getListener();vizbee.logger.warn(this.constructor.name+"::getListener - can't get AVPlayer")}},{key:"_getVTVAVPlayer",value:function(){var e;if(this.playerElement)if(VizbeeTV&&VizbeeTV.tv&&VizbeeTV.tv.player){var t;if(e=VizbeeTV.tv.player,Object.getPrototypeOf(e.constructor).name===uo.name?t=e.basePlayer:Object.getPrototypeOf(e.constructor).name===xe.name&&(t=e.currentPlayer),t&&"avplayer"==t.getName().toLowerCase())return t;vizbee.logger.warn(this.constructor.name+"::_getVTVAVPlayer - can't get AVPlayer")}else vizbee.logger.warn(this.constructor.name+"::_getVTVAVPlayer - can't get platform player")}}])}(),co=function(){return s(function e(){o(this,e)},null,[{key:"STOP_REASON_UNKNOWN",get:function(){return"stop_reason_unknown"}},{key:"STOP_BY_USER",get:function(){return"stop_by_user"}},{key:"STOP_IMPLICIT",get:function(){return"stop_implicit"}},{key:"STOP_REASON_BEFORE_NEXT_VIDEO",get:function(){return"stop_reason_before_next_video"}}])}(),fo=function(){return s(function e(){o(this,e)},[{key:"wasAppLaunchedByVizbee",value:function(){return!!VizbeeTV.tv.launchParamsDeferral&&VizbeeTV.tv.launchParamsDeferral.isLaunchedbyVizbee()}},{key:"wasVideoStartedByVizbee",value:function(){return VZB.wasVideoStartedByVizbee()}},{key:"addProvider",value:function(e,t){var n=VZB.getMetricsManager();n&&n.addProvider(e,t)}},{key:"removeProvider",value:function(e){var t=VZB.getMetricsManager();t&&t.removeProvider(e)}},{key:"logMetrics",value:function(e,t){var n=VZB.getMetricsManager();n&&n.trackEvent(e,t)}},{key:"setCustomAttributes",value:function(e){var t=VZB.getMetricsManager();t&&t.setCustomProperties(e)}}])}(),po=function(){return s(function e(){o(this,e),this._type="",this._id=-1},[{key:"toJSON",value:function(){return{type:this._type,id:this._id}}},{key:"fromJSON",value:function(e){e&&e.type&&!isNaN(e.id)?(this._type=e.type,this._id=e.id):VizbeeSDK.logger.verbose("Track::fromJSON - invalid trackInfo")}},{key:"type",get:function(){return this._type},set:function(e){this._type=e}},{key:"id",get:function(){return this._id},set:function(e){this._id=e}}])}(),ho=function(){function e(){var t;return o(this,e),(t=r(this,e)).type=M,t.subtype="",t._lang="",t}return p(e,po),s(e,[{key:"toJSON",value:function(){var t=b(e,"toJSON",this)([]);return t.lang=this._lang,t.subtype=this._subtype,t}},{key:"fromJSON",value:function(t){t?(t.type=t.type||this.type,b(e,"fromJSON",this)([t]),this._lang=t.lang,this._subtype=t.subtype):VizbeeSDK.logger.verbose("SubtitleTrack::fromJSON - invalid trackInfo")}},{key:"lang",get:function(){return this._lang},set:function(e){this._lang=e}},{key:"subtype",get:function(){return this._subtype},set:function(e){this._subtype=e}}])}(),vo=function(){return s(function e(){o(this,e),this.state={message:"This is vizbee snackbar!",theme:{color:"#FFFFFF",bgColor:"#7F98DE"},layout:{position:""},border:{color:"#FFFFFF"},font:{uri:"",family:"",size:24,weight:""},icon:{uri:"https://static.claspws.tv/screen/icons/common/user_icon_white.png"}},this.uiContainer=document.getElementsByTagName("body")[0],this.uiContainer&&(this._setupCSS(),this.render(this.uiContainer),this.isCurrentAnimationShowingUI=void 0)},[{key:"render",value:function(e){this.nodes||e&&(this.nodes={},this.nodes.popupMessageWithIconOverlay=document.createElement("div"),this.nodes.popupMessageWithIconOverlay.id="vizbeeSnackbarOverlay",this.nodes.popupMessageWithIconOverlay.className="opaqueBackground hidden",this.nodes.popupMessageWithIconContainer=document.createElement("div"),this.nodes.popupMessageWithIconContainer.id="popupTimedoutMessageWithIconUIContainer",this.nodes.popupMessageWithIconContainer.className="popupTimedoutMessageWithIconUIContainer",this.nodes.popupMessageWithIconContainer.style.color=this.state.theme.color,this.nodes.popupTimedoutIconEle=document.createElement("div"),this.nodes.popupTimedoutIconEle.id="popupTimedoutIconEle",this.nodes.popupTimedoutIconEle.className="popupTimedoutIconEle",this.nodes.popupTimedoutMessageEle=document.createElement("div"),this.nodes.popupTimedoutMessageEle.id="popupTimedoutMessageEle",this.nodes.popupTimedoutMessageEle.className="popupMessageEle",this.nodes.popupMessageWithIconContainer.appendChild(this.nodes.popupTimedoutIconEle),this.nodes.popupMessageWithIconContainer.appendChild(this.nodes.popupTimedoutMessageEle),this.nodes.popupMessageWithIconOverlay.appendChild(this.nodes.popupMessageWithIconContainer),e.appendChild(this.nodes.popupMessageWithIconOverlay),this._updateUI())}},{key:"setOptions",value:function(e){e&&(this.state.message=e.message||this.state.message,this.state.theme.color=e.theme.color||this.state.theme.color,this.state.theme.bgColor=e.theme.bgColor||this.state.theme.bgColor,this.state.layout.position=e.layout.position||this.state.layout.position,this.state.border.color=e.border.color||this.state.border.color,this.state.font.uri=e.font.uri||this.state.font.uri,this.state.font.family=e.font.family||this.state.font.family,this.state.font.size=this.screenRatio*(e.font.size||this.state.font.size),this.state.font.weight=e.font.weight||this.state.font.weight,this.state.icon.uri=e.icon.uri||this.state.icon.uri,this._updateUI(),this.show())}},{key:"show",value:function(){this.nodes&&this.nodes.popupMessageWithIconOverlay&&(this._showUIWithAnimation(),se.removeClass("hidden",this.nodes.popupMessageWithIconOverlay))}},{key:"hide",value:function(){this.nodes&&this.nodes.popupMessageWithIconOverlay&&this.nodes.popupMessageWithIconContainer&&(se.addClass("hidden",this.nodes.popupMessageWithIconOverlay),this.uiContainer&&this.uiContainer.contains(this.nodes.popupMessageWithIconOverlay)&&this.nodes.popupMessageWithIconOverlay.parentNode.removeChild(this.nodes.popupMessageWithIconOverlay))}},{key:"_updateUI",value:function(){if(this.nodes){var e=this.nodes.popupMessageWithIconContainer;if(e){e.style.color=this.state.theme.color,e.style.backgroundColor=this.state.theme.bgColor,null!=this.state.border.color&&(e.style.borderColor=this.state.border.color);var t=this.state.layout.position;if(t){delete e.style.top,delete e.style.right,delete e.style.bottom,delete e.style.left,e.style.position=t;var n=30*this.screenRatio+"px";t.indexOf("top")>-1?(e.style.top=n,t.indexOf("left")>-1?e.style.left=n:e.style.right=n):(e.style.bottom=n,t.indexOf("left")>-1?e.style.left=n:e.style.right=n)}}var i=this.nodes.popupTimedoutMessageEle;i&&(null!=this.state.font.uri&&(i.style.fontFamily=this.state.font.family),null!=this.state.font.size&&(i.style.fontSize=this.state.font.size+"px"),null!=this.state.font.weight&&(i.style.fontWeight=this.state.font.weight),null!=this.state.font.color&&(i.style.color=this.state.font.color),i.innerHTML=this.state.message);var r=this.nodes.popupTimedoutIconEle;r&&(this.state.icon.uri?(r.style.minWidth=36*this.screenRatio+"px",r.style.minHeight=36*this.screenRatio+"px",r.style.backgroundImage="url('"+this.state.icon.uri+"')",i&&(i.style.paddingLeft=12*this.screenRatio+"px")):(r.style.minWidth="0px",r.style.width="0px",i&&(i.style.paddingLeft="0px")))}}},{key:"_showUIWithAnimation",value:function(){this.isCurrentAnimationShowingUI=!0,te.get(this.state,["layout","position"],"").indexOf("top")>-1?this._showSlidingFromTopToBottom():this._showSlidingFromBottomToTop()}},{key:"_isAnimationSupported",value:function(e){return e&&"function"==typeof e.animate}},{key:"_showSlidingFromBottomToTop",value:function(){if(this.nodes&&this.nodes.popupMessageWithIconContainer)if(this._isAnimationSupported(this.nodes.popupMessageWithIconContainer)){var e=this.nodes.popupMessageWithIconContainer.offsetHeight+50,t=[{transform:"translateY("+e+"px)"},{transform:"translateY("+e/2+"px)"},{transform:"translateY(0px)"}];this.nodes.popupMessageWithIconContainer.animate(t,{duration:300,iterations:1})}else VizbeeTV.logger.i("PopupMessageWithIconView","_showSlidingFromBottomToTop","animation NOT supported!")}},{key:"_showSlidingFromTopToBottom",value:function(){if(this.nodes&&this.nodes.popupMessageWithIconContainer)if(this._isAnimationSupported(this.nodes.popupMessageWithIconContainer)){var e=this.nodes.popupMessageWithIconContainer.offsetHeight+50,t=[{transform:"translateY(-"+e+"px)"},{transform:"translateY(-"+e/2+"px)"},{transform:"translateY(0px)"}];this.nodes.popupMessageWithIconContainer.animate(t,{duration:300,iterations:1})}else VizbeeTV.logger.i("PopupMessageWithIconView","_showSlidingFromTopToBottom","animation NOT supported!")}},{key:"_setupCSS",value:function(){this.screenRatio=this._getScreenRatio();var e=this._processCSS(this.screenRatio,"\n #vizbeeSnackbarOverlay {\n position: absolute;\n top: 0px;\n left: 0px;\n width: $1280px;\n height: $720px;\n background: transparent !important;\n z-index: 9999;\n }\n\n #popupTimedoutMessageWithIconUIContainer {\n position: absolute;\n display: inline-flex;\n align-items: center;\n max-width: $420px;\n max-height: $80px;\n background: white;\n border-color: #FFFFFF;\n border: solid;\n border-width: $1px;\n border-radius: $45px;\n padding: $10px $24px;\n text-align: left !important;\n }\n\n #popupTimedoutIconEle {\n width: $36px;\n height: $36px;\n min-width: $36px;\n min-height: $36px;\n background-size: contain;\n background-repeat: no-repeat;\n }\n\n #popupTimedoutMessageEle {\n padding-left: $12px;\n }\n");this._appendToHEAD("vizbeeSnackbarCSS",e)}},{key:"_processCSS",value:function(e,t){if(t)return t.replace(/\$[0-9]+/gi,function(t){var n=t.split("$");return Math.ceil(e*n[1])})}},{key:"_getScreenRatio",value:function(){return document.body.clientWidth/1280}},{key:"_appendToHEAD",value:function(e,t){if(!this._isEmpty(e)&&!this._isEmpty(t)){var n=document.getElementById(e);if(!(null!==n&&n instanceof HTMLStyleElement)){var i=document.createElement("style");i.type="text/css",i.id=e,i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t)),document.getElementsByTagName("head")[0].appendChild(i)}}}},{key:"_isEmpty",value:function(e){return void 0===e||0==e.length||null==e}}])}(),go=function(){return s(function e(t){o(this,e),this.uiConfig=t,this.popupMessageWithIconView=void 0},[{key:"show",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8;this.hide(),this.uiConfig&&"function"==typeof this.uiConfig.toJSON?(this.popupMessageWithIconView=new vo,this.popupMessageWithIconView.setOptions(this.uiConfig.toJSON()),-1!==t&&setTimeout(function(){e.popupMessageWithIconView.hide()},1e3*t)):VizbeeTV.logger.e("PopupMessageWithIconView","show","Invalid uiConfig")}},{key:"hide",value:function(){this.popupMessageWithIconView&&this.popupMessageWithIconView.hide();var e=document.getElementById("vizbeeSnackbarOverlay");e&&(VizbeeTV.logger.i("PopupMessageWithIconView","hide","Removing vizbeeSnackbarEle"),e.parentNode.removeChild(e))}}])}(),yo={TOP_LEFT:"top-left",TOP_RIGHT:"top-right",BOTTOM_LEFT:"bottom-left",BOTTOM_RIGHT:"bottom-right"},mo=function(){return s(function e(){o(this,e),this._message="This is a vizbee snackbar message",this._theme={color:"#FFFFFF",bgColor:"#7F98DE"},this._layout={position:yo.BOTTOM_RIGHT},this._border={color:"#FFFFFF"},this._font={uri:"",family:"",size:24,weight:""},this._icon={uri:"https://s3.amazonaws.com/vga-videos/images/vsa/loading.gif"}},[{key:"message",get:function(){return this._message},set:function(e){this._message=e}},{key:"theme",get:function(){return this._theme},set:function(e){this._theme=e}},{key:"layout",get:function(){return this._layout},set:function(e){this._layout=e}},{key:"border",get:function(){return this._border},set:function(e){this._border=e}},{key:"font",get:function(){return this._font},set:function(e){this._font=e}},{key:"icon",get:function(){return this._icon},set:function(e){this._icon=e}},{key:"fromJSON",value:function(e){e&&(this._message=e.message,e.theme&&(this._theme.color=e.theme.color||this._theme.color,this._theme.bgColor=e.theme.bgColor||this._theme.bgColor),e.layout&&(this._layout=e.layout||this._layout),e.border&&(this._border=e.border||this._border),e.font&&(this._font.uri=e.font.uri||this._font.uri,this._font.family=e.font.family||this._font.family,this._font.size=e.font.size||this._font.size,this._font.weight=e.font.weight||this._font.weight),e.icon&&e.icon.uri&&(this._icon.uri=e.icon.uri||this._icon.uri))}},{key:"toJSON",value:function(){return{message:this._message,theme:this._theme,layout:this._layout,border:this._border,font:this._font,icon:this._icon}}}])}(),bo=function(){return s(function e(){o(this,e),l(this,"namespaceAndReceiverMap",new Map)},[{key:"send",value:(e=v().m(function e(t,n){return v().w(function(e){for(;;)if(0===e.n)return VizbeeSDK.logger.debug(this.constructor.name,"send","namespace: ".concat(n,", payload: ").concat(JSON.stringify(t))),e.a(2,new Promise(function(e,i){window.VZB.sendXMessage(t,n,{onSuccess:function(t){e()},onFailure:function(e){i(e)}})}))},e,this)}),t=function(){var t=this,n=arguments;return new Promise(function(r,o){var a=e.apply(t,n);function s(e){i(a,r,o,s,u,"next",e)}function u(e){i(a,r,o,s,u,"throw",e)}s(void 0)})},function(e,n){return t.apply(this,arguments)})},{key:"addReceiver",value:function(e,t){VizbeeSDK.logger.debug(this.constructor.name,"addReceiver","with namespace: ".concat(e)),this.namespaceAndReceiverMap.set(e,t)}},{key:"removeReceiver",value:function(e,t){VizbeeSDK.logger.debug(this.constructor.name,"removeReceiver","with namespace: ".concat(e)),this.namespaceAndReceiverMap.delete(e)}},{key:"onReceive",value:function(e,t,n){VizbeeSDK.logger.debug(this.constructor.name,"onReceive","namespace: ".concat(e,", payload: ").concat(JSON.stringify(t),", device: ").concat(n));var i=this.namespaceAndReceiverMap.get(e);i&&i(t,e,n)}}]);var e,t}(),So=function(e){return e.ANDROID_MOBILE="Android",e.IOS="iOS",e.UNKNOWN="Unknown",e}({}),_o=function(e){return e.ANDROID_MOBILE="ANDROID_MOBILE",e.IOS="IOS",e.UNKNOWN="UNKNOWN",e}({});function ko(e){switch(e){case So.ANDROID_MOBILE:return _o.ANDROID_MOBILE;case So.IOS:return _o.IOS;case So.UNKNOWN:default:return _o.UNKNOWN}}var To=function(e){return e.JOIN="JOIN",e.LEAVE="LEAVE",e}({}),Po=function(e){return e.JOIN="JOIN",e.LEAVE="LEAVE",e}({}),Io=function(){return s(function e(){o(this,e),l(this,"presenceCallbacks",[]),l(this,"syncController",null),this.init()},[{key:"init",value:function(){var e,t,n;this.syncController=null===(e=window.VZB)||void 0===e||null===(t=e.getSyncController)||void 0===t?void 0:t.call(e),this.syncController?this.listenForSyncControllerSessionState():(null===(n=window.VizbeeSDK)||void 0===n||null===(n=n.logger)||void 0===n||n.warn("VizbeeBicastMemberPresenceClientImpl","init","syncController is not available"),this.listenForSyncControllerAvailability())}},{key:"listenForSyncControllerAvailability",value:function(){var e,t,n=this;null===(e=window.VizbeeSDK)||void 0===e||null===(e=e.logger)||void 0===e||e.debug("VizbeeBicastMemberPresenceClientImpl","listenForSyncControllerAvailability","waiting for syncController to be available"),null===(t=window.VZB)||void 0===t||t.addSyncReadyListener(function(){var e,t,i;null===(e=window.VizbeeSDK)||void 0===e||null===(e=e.logger)||void 0===e||e.debug("VizbeeBicastMemberPresenceClientImpl","listenForSyncControllerAvailability","syncController is now available"),n.syncController=null===(t=window.VZB)||void 0===t||null===(i=t.getSyncController)||void 0===i?void 0:i.call(t),n.listenForSyncControllerSessionState()})}},{key:"listenForSyncControllerSessionState",value:function(){var e=this;VizbeeSDK.logger.debug("VizbeeBicastMemberPresenceClientImpl","listenForSyncControllerSessionState","subscribing to presence events"),this.syncController.subscribeToPresence(function(t){if(VizbeeSDK.logger.debug("VizbeeBicastMemberPresenceClientImpl","listenForSyncControllerSessionState","presence event received: ".concat(JSON.stringify(t))),null!==t){VizbeeSDK.logger.debug("VizbeeBicastMemberPresenceClientImpl","listenForSyncControllerSessionState","processing presence event: ".concat(JSON.stringify(t)));var n=e.toVizbeeDevice(t.member),i={event:t.event===Po.JOIN?To.JOIN:To.LEAVE,device:n};e.presenceCallbacks.forEach(function(e){return e(i)})}})}},{key:"subscribe",value:function(e){VizbeeSDK.logger.debug("VizbeeBicastMemberPresenceClientImpl","subscribe",e),this.presenceCallbacks.push(e)}},{key:"unsubscribe",value:function(e){VizbeeSDK.logger.debug("VizbeeBicastMemberPresenceClientImpl","unsubscribe","");var t=this.presenceCallbacks.indexOf(e);t>-1&&this.presenceCallbacks.splice(t,1)}},{key:"getMembers",value:function(){var e,t,n=this,i=(null===(e=this.syncController)||void 0===e||null===(t=e.getActiveSenders)||void 0===t?void 0:t.call(e))||{};return Object.values(i).map(function(e){return n.toVizbeeDevice(e)})}},{key:"toVizbeeDevice",value:function(e){var t,n,i,r,o,a,s,u,l,c,d;return{deviceId:null!==(t=null==e||null===(n=e.ssinfo)||void 0===n?void 0:n.REMOTE_DEVICE_ID)&&void 0!==t?t:"UNKNOWN",friendlyName:null!==(i=null==e||null===(r=e.ssinfo)||void 0===r?void 0:r.REMOTE_FRIENDLY_NAME)&&void 0!==i?i:"UNKNOWN",modelName:null!==(o=null==e||null===(a=e.ssinfo)||void 0===a?void 0:a.modelName)&&void 0!==o?o:"UNKNOWN",modelNumber:null!==(s=null==e||null===(u=e.ssinfo)||void 0===u?void 0:u.modelNumber)&&void 0!==s?s:"UNKNOWN",manufacturer:null!==(l=null==e||null===(c=e.ssinfo)||void 0===c?void 0:c.manufacturer)&&void 0!==l?l:"UNKNOWN",deviceType:ko(null==e||null===(d=e.ssinfo)||void 0===d?void 0:d.REMOTE_DEVICE_TYPE)}}}])}();l(Io,"LOG_TAG","VizbeeBicastMemberPresenceClientImpl");var Eo=function(){return s(function e(){o(this,e),l(this,"_messagingClient",null),l(this,"_presenceClient",null)},[{key:"getMessagingClient",value:function(){return this._messagingClient||(this._messagingClient=new bo),this._messagingClient}},{key:"getPresenceClient",value:function(){return this._presenceClient||(this._presenceClient=new Io),this._presenceClient}}])}(),Vo=function(){return s(function e(){var t=this;if(o(this,e),l(this,"session",null),l(this,"sessionState",Yi.NOT_CONNECTED),l(this,"sessionStateListeners",[]),l(this,"syncController",null),l(this,"onSessionStateChanged",function(e){var n,i;switch(t.sessionState=e,e){case Yi.CONNECTED:null===(n=window.VizbeeSDK)||void 0===n||null===(n=n.logger)||void 0===n||n.info("VizbeeBicastSessionManager","onSessionStateChanged","CONNECTED"),t.session=new Eo,t.sessionStateListeners.forEach(function(e){return e.onSessionStateChanged(Yi.CONNECTED)});break;case Yi.NOT_CONNECTED:null===(i=window.VizbeeSDK)||void 0===i||null===(i=i.logger)||void 0===i||i.info("VizbeeBicastSessionManager","onSessionStateChanged","NOT_CONNECTED"),t.session=null,t.sessionStateListeners.forEach(function(e){return e.onSessionStateChanged(Yi.NOT_CONNECTED)})}}),e.instance)return e.instance;this.init(),e.instance=this},[{key:"init",value:function(){var e,t,n,i;null===(e=window.VizbeeSDK)||void 0===e||null===(e=e.logger)||void 0===e||e.debug("VizbeeBicastSessionManager","init","initialize session manager"),this.syncController=null===(t=window.VZB)||void 0===t||null===(n=t.getSyncController)||void 0===n?void 0:n.call(t),this.syncController?this.listenForSyncControllerSessionState():(null===(i=window.VizbeeSDK)||void 0===i||null===(i=i.logger)||void 0===i||i.warn("VizbeeBicastSessionManager","init","syncController is not available"),this.listenForSyncControllerAvailability())}},{key:"listenForSyncControllerAvailability",value:function(){var e,t,n=this;null===(e=window.VizbeeSDK)||void 0===e||null===(e=e.logger)||void 0===e||e.debug("VizbeeBicastSessionManager","listenForSyncControllerAvailability","waiting for syncController to be available"),null===(t=window.VZB)||void 0===t||t.addSyncReadyListener(function(){var e,t,i;null===(e=window.VizbeeSDK)||void 0===e||null===(e=e.logger)||void 0===e||e.debug("VizbeeBicastSessionManager","listenForSyncControllerAvailability","syncController is now available"),n.syncController=null===(t=window.VZB)||void 0===t||null===(i=t.getSyncController)||void 0===i?void 0:i.call(t),n.listenForSyncControllerSessionState()})}},{key:"listenForSyncControllerSessionState",value:function(){var e,t,n,i;this.sessionState=null!==(e=null===(t=this.syncController)||void 0===t||null===(n=t.sessionState)||void 0===n?void 0:n.call(t))&&void 0!==e?e:Yi.NOT_CONNECTED,this.sessionState===Yi.CONNECTED&&(this.session=new Eo),null===(i=this.syncController)||void 0===i||i.addSessionStateListener(this.onSessionStateChanged)}},{key:"addSessionStateListener",value:function(e){var t;null===(t=window.VizbeeSDK)||void 0===t||null===(t=t.logger)||void 0===t||t.debug("VizbeeBicastSessionManager","addSessionStateListener","add session state listener"),"function"==typeof e?this.sessionStateListeners.push({onSessionStateChanged:e}):this.sessionStateListeners.push(e)}},{key:"removeSessionStateListener",value:function(e){var t;null===(t=window.VizbeeSDK)||void 0===t||null===(t=t.logger)||void 0===t||t.debug("VizbeeBicastSessionManager","removeSessionStateListener","remove session state listener");var n=this.sessionStateListeners.indexOf(e);n>-1&&this.sessionStateListeners.splice(n,1)}},{key:"getSession",value:function(){return this.session}},{key:"isConnecting",value:function(){return this.sessionState===Yi.CONNECTING}},{key:"isConnected",value:function(){return this.sessionState===Yi.CONNECTED}}])}(),Ao=function(){return s(function e(){if(o(this,e),l(this,"presenceCallbacks",[]),l(this,"vizbeeSession",null),e.instance)return e.instance;this.init(),e.instance=this},[{key:"init",value:function(){var e=this;try{var t;if(VizbeeSDK.logger.info("VizbeePresenceManager::init - Initializing Vizbee Presence Manager"),null===(t=window.vizbee)||void 0===t||null===(t=t.continuity)||void 0===t||!t.xmessages)throw new Error("Vizbee continuity or xmessages not initialized");var n=new window.vizbee.continuity.xmessages.VizbeeBicastSessionManager;if(!n)throw new Error("Session manager initialization failed");n.addSessionStateListener({onSessionStateChanged:function(t){if(VizbeeSDK.logger.info("VizbeePresenceManager::init - Session state changed:",t),t===Yi.CONNECTED){if(VizbeeSDK.logger.debug("VizbeePresenceManager::init - Session connected"),e.vizbeeSession=n.getSession(),!e.vizbeeSession)throw new Error("Failed to retrieve Vizbee session");if(e.vizbeePresenceClient=e.vizbeeSession.getPresenceClient(),!e.vizbeePresenceClient)throw new Error("Failed to retrieve Vizbee presence client");if(e.presenceCallbacks.length>0)for(var i=0;i<e.presenceCallbacks.length;i++){var r=e.presenceCallbacks[i];e.vizbeePresenceClient.subscribe(r)}}else{if(e.vizbeePresenceClient)for(var o=0;o<e.presenceCallbacks.length;o++){var a=e.presenceCallbacks[o];e.vizbeePresenceClient.unsubscribe(a)}e.vizbeeSession=null}}})}catch(e){throw VizbeeSDK.logger.warn("VizbeePresenceManager::init - Error initializing Vizbee session:",e),e}}},{key:"subscribe",value:function(e){"function"==typeof e?(this.presenceCallbacks.push(e),this.vizbeePresenceClient?this.vizbeePresenceClient.subscribe(e):VizbeeSDK.logger.warn("VizbeePresenceManager::subscribe - Presence client not initialized yet")):VizbeeSDK.logger.warn("VizbeePresenceManager::subscribe - Provided callback is not a function")}},{key:"unsubscribe",value:function(e){VizbeeSDK.logger.debug("VizbeePresenceManager::unsubscribe"),this.vizbeePresenceClient&&this.vizbeePresenceClient.unsubscribe(e);var t=this.presenceCallbacks.indexOf(e);t>-1&&this.presenceCallbacks.splice(t,1)}},{key:"getMembers",value:function(){return this.vizbeePresenceClient?this.vizbeePresenceClient.getMembers():[]}}])}(),Co=function(){function e(){return o(this,e),r(this,e)}return p(e,Hr),s(e,[{key:"ContinuityContext",get:function(){return ao}},{key:"adapters",get:function(){return{AppAdapter:Gr,PlayerAdapter:Yr,BasePlayerAdapter:so,AVPlayerAdapter:lo,PlayerType:Xr,AdAdapter:Jr,AdType:Qr,VideoStopReason:co}}},{key:"messages",get:function(){return{VizbeeEvent:to,VideoInfo:Zr,VideoStatus:eo,AdEventType:Wr,AdStatus:jr,PlayerState:$r,SubtitleTrack:ho}}},{key:"analytics",get:function(){return{AnalyticsProvider:fo}}},{key:"ui",get:function(){return{LayoutPosition:yo,Snackbar:go,SnackbarUIConfig:mo}}},{key:"xmessages",get:function(){return{VizbeeBicastSessionManager:Vo,VizbeeBicastSession:Eo,VizbeeMessagingClient:void 0,VizbeePresenceManager:Ao}}}])}(),Do=new(function(){function e(){return o(this,e),r(this,e)}return p(e,Co),s(e)}()),wo=new(function(){function e(){return o(this,e),r(this,e)}return p(e,Kr),s(e,[{key:"continuity",get:function(){return Do}},{key:"framework",get:function(){return Do}}])}());if(wo.logger=new Je,wo.logger.setPrefix("[Vizbee]"),"undefined"!=typeof window){if(window.VizbeeSDK=wo,window.vizbee){var No=window.vizbee;window.vizbee=window.VizbeeSDK,Object.keys(No).forEach(function(e){window.vizbee[e]=No[e]})}else window.vizbee=window.VizbeeSDK;"function"==typeof window.dispatchEvent&&window.dispatchEvent(new Event("VIZBEE_SDK_READY"))}
|