@bbc/storyplayer
Version:
StoryPlayer - reference player for BBC Research & Development's object-based media schema (https://www.npmjs.com/package/@bbc/object-based-media-schema)
1 lines • 1.71 MB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Storyplayer=t():e.Storyplayer=t()}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=192)}([function(e,t,n){var r=n(117),i=n(38),a=n(196);r||i(Object.prototype,"toString",a,{unsafe:!0})},function(e,t,n){"use strict";var r=n(41),i=n(99),a=n(81),o=n(46),s=n(122),u=o.set,l=o.getterFor("Array Iterator");e.exports=s(Array,"Array",(function(e,t){u(this,{type:"Array Iterator",target:r(e),index:0,kind:t})}),(function(){var e=l(this),t=e.target,n=e.kind,r=e.index++;return!t||r>=t.length?(e.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:t[r],done:!1}:{value:[r,t[r]],done:!1}}),"values"),a.Arguments=a.Array,i("keys"),i("values"),i("entries")},function(e,t,n){"use strict";var r=n(121).charAt,i=n(46),a=n(122),o=i.set,s=i.getterFor("String Iterator");a(String,"String",(function(e){o(this,{type:"String Iterator",string:String(e),index:0})}),(function(){var e,t=s(this),n=t.string,i=t.index;return i>=n.length?{value:void 0,done:!0}:(e=r(n,i),t.index+=e.length,{value:e,done:!1})}))},function(e,t,n){var r=n(14),i=n(154),a=n(1),o=n(45),s=n(17),u=s("iterator"),l=s("toStringTag"),c=a.values;for(var d in i){var h=r[d],f=h&&h.prototype;if(f){if(f[u]!==c)try{o(f,u,c)}catch(e){f[u]=c}if(f[l]||o(f,l,d),i[d])for(var p in a)if(f[p]!==a[p])try{o(f,p,a[p])}catch(e){f[p]=a[p]}}}},function(e,t,n){var r=n(14),i=n(44).f,a=n(45),o=n(38),s=n(107),u=n(144),l=n(89);e.exports=function(e,t){var n,c,d,h,f,p=e.target,m=e.global,v=e.stat;if(n=m?r:v?r[p]||s(p,{}):(r[p]||{}).prototype)for(c in t){if(h=t[c],d=e.noTargetGet?(f=i(n,c))&&f.value:n[c],!l(m?c:p+(v?".":"#")+c,e.forced)&&void 0!==d){if(typeof h==typeof d)continue;u(h,d)}(e.sham||d&&d.sham)&&a(h,"sham",!0),o(n,c,h,e)}}},function(e,t,n){"use strict";var r=n(4),i=n(14),a=n(51),o=n(50),s=n(27),u=n(114),l=n(148),c=n(15),d=n(26),h=n(90),f=n(20),p=n(21),m=n(35),v=n(41),g=n(74),y=n(61),_=n(58),b=n(76),E=n(88),w=n(193),S=n(113),T=n(44),x=n(30),A=n(84),R=n(45),M=n(38),C=n(86),L=n(85),k=n(75),O=n(87),P=n(17),I=n(151),D=n(152),N=n(59),B=n(46),U=n(52).forEach,F=L("hidden"),j=P("toPrimitive"),H=B.set,G=B.getterFor("Symbol"),V=Object.prototype,z=i.Symbol,W=a("JSON","stringify"),K=T.f,q=x.f,Y=w.f,X=A.f,J=C("symbols"),Z=C("op-symbols"),$=C("string-to-symbol-registry"),Q=C("symbol-to-string-registry"),ee=C("wks"),te=i.QObject,ne=!te||!te.prototype||!te.prototype.findChild,re=s&&c((function(){return 7!=_(q({},"a",{get:function(){return q(this,"a",{value:7}).a}})).a}))?function(e,t,n){var r=K(V,t);r&&delete V[t],q(e,t,n),r&&e!==V&&q(V,t,r)}:q,ie=function(e,t){var n=J[e]=_(z.prototype);return H(n,{type:"Symbol",tag:e,description:t}),s||(n.description=t),n},ae=l?function(e){return"symbol"==typeof e}:function(e){return Object(e)instanceof z},oe=function(e,t,n){e===V&&oe(Z,t,n),p(e);var r=g(t,!0);return p(n),d(J,r)?(n.enumerable?(d(e,F)&&e[F][r]&&(e[F][r]=!1),n=_(n,{enumerable:y(0,!1)})):(d(e,F)||q(e,F,y(1,{})),e[F][r]=!0),re(e,r,n)):q(e,r,n)},se=function(e,t){p(e);var n=v(t),r=b(n).concat(de(n));return U(r,(function(t){s&&!ue.call(n,t)||oe(e,t,n[t])})),e},ue=function(e){var t=g(e,!0),n=X.call(this,t);return!(this===V&&d(J,t)&&!d(Z,t))&&(!(n||!d(this,t)||!d(J,t)||d(this,F)&&this[F][t])||n)},le=function(e,t){var n=v(e),r=g(t,!0);if(n!==V||!d(J,r)||d(Z,r)){var i=K(n,r);return!i||!d(J,r)||d(n,F)&&n[F][r]||(i.enumerable=!0),i}},ce=function(e){var t=Y(v(e)),n=[];return U(t,(function(e){d(J,e)||d(k,e)||n.push(e)})),n},de=function(e){var t=e===V,n=Y(t?Z:v(e)),r=[];return U(n,(function(e){!d(J,e)||t&&!d(V,e)||r.push(J[e])})),r};(u||(M((z=function(){if(this instanceof z)throw TypeError("Symbol is not a constructor");var e=arguments.length&&void 0!==arguments[0]?String(arguments[0]):void 0,t=O(e),n=function(e){this===V&&n.call(Z,e),d(this,F)&&d(this[F],t)&&(this[F][t]=!1),re(this,t,y(1,e))};return s&&ne&&re(V,t,{configurable:!0,set:n}),ie(t,e)}).prototype,"toString",(function(){return G(this).tag})),M(z,"withoutSetter",(function(e){return ie(O(e),e)})),A.f=ue,x.f=oe,T.f=le,E.f=w.f=ce,S.f=de,I.f=function(e){return ie(P(e),e)},s&&(q(z.prototype,"description",{configurable:!0,get:function(){return G(this).description}}),o||M(V,"propertyIsEnumerable",ue,{unsafe:!0}))),r({global:!0,wrap:!0,forced:!u,sham:!u},{Symbol:z}),U(b(ee),(function(e){D(e)})),r({target:"Symbol",stat:!0,forced:!u},{for:function(e){var t=String(e);if(d($,t))return $[t];var n=z(t);return $[t]=n,Q[n]=t,n},keyFor:function(e){if(!ae(e))throw TypeError(e+" is not a symbol");if(d(Q,e))return Q[e]},useSetter:function(){ne=!0},useSimple:function(){ne=!1}}),r({target:"Object",stat:!0,forced:!u,sham:!s},{create:function(e,t){return void 0===t?_(e):se(_(e),t)},defineProperty:oe,defineProperties:se,getOwnPropertyDescriptor:le}),r({target:"Object",stat:!0,forced:!u},{getOwnPropertyNames:ce,getOwnPropertySymbols:de}),r({target:"Object",stat:!0,forced:c((function(){S.f(1)}))},{getOwnPropertySymbols:function(e){return S.f(m(e))}}),W)&&r({target:"JSON",stat:!0,forced:!u||c((function(){var e=z();return"[null]"!=W([e])||"{}"!=W({a:e})||"{}"!=W(Object(e))}))},{stringify:function(e,t,n){for(var r,i=[e],a=1;arguments.length>a;)i.push(arguments[a++]);if(r=t,(f(t)||void 0!==e)&&!ae(e))return h(t)||(t=function(e,t){if("function"==typeof r&&(t=r.call(this,e,t)),!ae(t))return t}),i[1]=t,W.apply(null,i)}});z.prototype[j]||R(z.prototype,j,z.prototype.valueOf),N(z,"Symbol"),k[F]=!0},function(e,t,n){"use strict";var r=n(4),i=n(27),a=n(14),o=n(26),s=n(20),u=n(30).f,l=n(144),c=a.Symbol;if(i&&"function"==typeof c&&(!("description"in c.prototype)||void 0!==c().description)){var d={},h=function(){var e=arguments.length<1||void 0===arguments[0]?void 0:String(arguments[0]),t=this instanceof h?new c(e):void 0===e?c():c(e);return""===e&&(d[t]=!0),t};l(h,c);var f=h.prototype=c.prototype;f.constructor=h;var p=f.toString,m="Symbol(test)"==String(c("test")),v=/^Symbol\((.*)\)[^)]+$/;u(f,"description",{configurable:!0,get:function(){var e=s(this)?this.valueOf():this,t=p.call(e);if(o(d,e))return"";var n=m?t.slice(7,-1):t.replace(v,"$1");return""===n?void 0:n}}),r({global:!0,forced:!0},{Symbol:h})}},function(e,t,n){n(152)("iterator")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.isDebug=void 0;var r=n(209),i=n(19),a={css:{levels:{trace:"color: DeepPink",debug:"color: GoldenRod",info:"color: DarkTurquoise",warn:"color: Blue",error:"color: Crimson",fatal:"color: White"},def:"color: DimGray",msg:"color: SteelBlue",src:"color: DimGray; font-style: italic; font-size: 0.9em"},logByLevel:!0},o=function(){switch((0,i.getSetting)(i.DEBUG_PLAYOUT_FLAG)){case"trace":return r.TRACE;case"debug":return r.DEBUG;case"info":return r.INFO;case"warn":return r.WARN;case"error":return r.ERROR;case"fatal":return r.FATAL;default:return r.INFO}},s=(0,r.createLogger)({name:"storyplayer",streams:[{level:o(),stream:new r.ConsoleFormattedStream(a)}],serializers:r.stdSerializers,src:o()<r.INFO});t.isDebug=function(){return s.level()<r.INFO};var u=s;t.default=u},function(e,t,n){var r=n(4),i=n(51),a=n(53),o=n(21),s=n(20),u=n(58),l=n(217),c=n(15),d=i("Reflect","construct"),h=c((function(){function e(){}return!(d((function(){}),[],e)instanceof e)})),f=!c((function(){d((function(){}))})),p=h||f;r({target:"Reflect",stat:!0,forced:p,sham:p},{construct:function(e,t){a(e),o(t);var n=arguments.length<3?e:a(arguments[2]);if(f&&!h)return d(e,t,n);if(e==n){switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3])}var r=[null];return r.push.apply(r,t),new(l.apply(e,r))}var i=n.prototype,c=u(s(i)?i:Object.prototype),p=Function.apply.call(e,c,t);return s(p)?p:c}})},function(e,t,n){n(4)({target:"Object",stat:!0},{setPrototypeOf:n(91)})},function(e,t,n){var r=n(4),i=n(15),a=n(35),o=n(98),s=n(168);r({target:"Object",stat:!0,forced:i((function(){o(1)})),sham:!s},{getPrototypeOf:function(e){return o(a(e))}})},function(e,t,n){"use strict";var r=n(4),i=n(153);r({target:"Array",proto:!0,forced:[].forEach!=i},{forEach:i})},function(e,t,n){var r=n(14),i=n(154),a=n(153),o=n(45);for(var s in i){var u=r[s],l=u&&u.prototype;if(l&&l.forEach!==a)try{o(l,"forEach",a)}catch(e){l.forEach=a}}},function(e,t,n){(function(t){var n=function(e){return e&&e.Math==Math&&e};e.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof t&&t)||function(){return this}()||Function("return this")()}).call(this,n(141))},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},function(e,t,n){"use strict";var r,i,a,o,s=n(4),u=n(50),l=n(14),c=n(51),d=n(197),h=n(38),f=n(80),p=n(91),m=n(59),v=n(155),g=n(20),y=n(53),_=n(64),b=n(108),E=n(92),w=n(119),S=n(158),T=n(159).set,x=n(199),A=n(201),R=n(202),M=n(161),C=n(203),L=n(46),k=n(89),O=n(17),P=n(204),I=n(94),D=n(77),N=O("species"),B="Promise",U=L.get,F=L.set,j=L.getterFor(B),H=d&&d.prototype,G=d,V=H,z=l.TypeError,W=l.document,K=l.process,q=M.f,Y=q,X=!!(W&&W.createEvent&&l.dispatchEvent),J="function"==typeof PromiseRejectionEvent,Z=!1,$=k(B,(function(){var e=b(G)!==String(G);if(!e&&66===D)return!0;if(u&&!V.finally)return!0;if(D>=51&&/native code/.test(G))return!1;var t=new G((function(e){e(1)})),n=function(e){e((function(){}),(function(){}))};return(t.constructor={})[N]=n,!(Z=t.then((function(){}))instanceof n)||!e&&P&&!J})),Q=$||!w((function(e){G.all(e).catch((function(){}))})),ee=function(e){var t;return!(!g(e)||"function"!=typeof(t=e.then))&&t},te=function(e,t){if(!e.notified){e.notified=!0;var n=e.reactions;x((function(){for(var r=e.value,i=1==e.state,a=0;n.length>a;){var o,s,u,l=n[a++],c=i?l.ok:l.fail,d=l.resolve,h=l.reject,f=l.domain;try{c?(i||(2===e.rejection&&ae(e),e.rejection=1),!0===c?o=r:(f&&f.enter(),o=c(r),f&&(f.exit(),u=!0)),o===l.promise?h(z("Promise-chain cycle")):(s=ee(o))?s.call(o,d,h):d(o)):h(r)}catch(e){f&&!u&&f.exit(),h(e)}}e.reactions=[],e.notified=!1,t&&!e.rejection&&re(e)}))}},ne=function(e,t,n){var r,i;X?((r=W.createEvent("Event")).promise=t,r.reason=n,r.initEvent(e,!1,!0),l.dispatchEvent(r)):r={promise:t,reason:n},!J&&(i=l["on"+e])?i(r):"unhandledrejection"===e&&R("Unhandled promise rejection",n)},re=function(e){T.call(l,(function(){var t,n=e.facade,r=e.value;if(ie(e)&&(t=C((function(){I?K.emit("unhandledRejection",r,n):ne("unhandledrejection",n,r)})),e.rejection=I||ie(e)?2:1,t.error))throw t.value}))},ie=function(e){return 1!==e.rejection&&!e.parent},ae=function(e){T.call(l,(function(){var t=e.facade;I?K.emit("rejectionHandled",t):ne("rejectionhandled",t,e.value)}))},oe=function(e,t,n){return function(r){e(t,r,n)}},se=function(e,t,n){e.done||(e.done=!0,n&&(e=n),e.value=t,e.state=2,te(e,!0))},ue=function(e,t,n){if(!e.done){e.done=!0,n&&(e=n);try{if(e.facade===t)throw z("Promise can't be resolved itself");var r=ee(t);r?x((function(){var n={done:!1};try{r.call(t,oe(ue,n,e),oe(se,n,e))}catch(t){se(n,t,e)}})):(e.value=t,e.state=1,te(e,!1))}catch(t){se({done:!1},t,e)}}};if($&&(V=(G=function(e){_(this,G,B),y(e),r.call(this);var t=U(this);try{e(oe(ue,t),oe(se,t))}catch(e){se(t,e)}}).prototype,(r=function(e){F(this,{type:B,done:!1,notified:!1,parent:!1,reactions:[],rejection:!1,state:0,value:void 0})}).prototype=f(V,{then:function(e,t){var n=j(this),r=q(S(this,G));return r.ok="function"!=typeof e||e,r.fail="function"==typeof t&&t,r.domain=I?K.domain:void 0,n.parent=!0,n.reactions.push(r),0!=n.state&&te(n,!1),r.promise},catch:function(e){return this.then(void 0,e)}}),i=function(){var e=new r,t=U(e);this.promise=e,this.resolve=oe(ue,t),this.reject=oe(se,t)},M.f=q=function(e){return e===G||e===a?new i(e):Y(e)},!u&&"function"==typeof d&&H!==Object.prototype)){o=H.then,Z||(h(H,"then",(function(e,t){var n=this;return new G((function(e,t){o.call(n,e,t)})).then(e,t)}),{unsafe:!0}),h(H,"catch",V.catch,{unsafe:!0}));try{delete H.constructor}catch(e){}p&&p(H,V)}s({global:!0,wrap:!0,forced:$},{Promise:G}),m(G,B,!1,!0),v(B),a=c(B),s({target:B,stat:!0,forced:$},{reject:function(e){var t=q(this);return t.reject.call(void 0,e),t.promise}}),s({target:B,stat:!0,forced:u||$},{resolve:function(e){return A(u&&this===a?G:this,e)}}),s({target:B,stat:!0,forced:Q},{all:function(e){var t=this,n=q(t),r=n.resolve,i=n.reject,a=C((function(){var n=y(t.resolve),a=[],o=0,s=1;E(e,(function(e){var u=o++,l=!1;a.push(void 0),s++,n.call(t,e).then((function(e){l||(l=!0,a[u]=e,--s||r(a))}),i)})),--s||r(a)}));return a.error&&i(a.value),n.promise},race:function(e){var t=this,n=q(t),r=n.reject,i=C((function(){var i=y(t.resolve);E(e,(function(e){i.call(t,e).then(n.resolve,r)}))}));return i.error&&r(i.value),n.promise}})},function(e,t,n){var r=n(14),i=n(86),a=n(26),o=n(87),s=n(114),u=n(148),l=i("wks"),c=r.Symbol,d=u?c:c&&c.withoutSetter||o;e.exports=function(e){return a(l,e)&&(s||"string"==typeof l[e])||(s&&a(c,e)?l[e]=c[e]:l[e]=d("Symbol."+e)),l[e]}},function(e,t,n){var r=n(4),i=n(15),a=n(41),o=n(44).f,s=n(27),u=i((function(){o(1)}));r({target:"Object",stat:!0,forced:!s||u,sham:!s},{getOwnPropertyDescriptor:function(e,t){return o(a(e),t)}})},function(e,t,n){"use strict";n(5),n(6),n(7),n(82),n(28),Object.defineProperty(t,"__esModule",{value:!0}),t.getControlHideList=t.replaceEscapedVariables=t.leftGreaterThanRight=t.precisionRound=t.handleButtonTouchEvent=t.preventEventDefault=t.LOOPING_AUDIO_AC_TYPE=t.AUDIO=t.VIDEO=t.SLIDER_CLASS=t.scrollToTop=t.addDetail=t.copySelection=t.getVariableOverrides=t.getCurrentUrl=t.getSetting=t.OVERRIDE_INACTIVE_BUFFERING=t.OVERRIDE_ACTIVE_BUFFERING=t.SHAKA_DEBUG_LEVEL=t.OVERRIDE_PLAYOUT_FORMAT=t.OVERRIDE_PLAYOUT=t.DISABLE_LOOKAHEAD_FLAG=t.UA_DEBUG_FLAG=t.WEBVIEW_DEBUG_FLAG=t.FACEBOOK_BLOCK_FLAG=t.DEBUG_PLAYOUT_FLAG=t.ADD_DETAILS_FLAG=t.getSMPInterface=t.inSMPWrapper=t.proxyWrapper=void 0,n(22),n(60),n(1),n(0),n(2),n(3),n(170),n(65),n(213),n(47),n(55),n(56),n(100),n(215),n(16),n(68),n(128);var r,i=(r=n(8))&&r.__esModule?r:{default:r},a=n(66);function o(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return s(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}t.proxyWrapper=function(e,t){return new Proxy(t,{get:function(t,n){return function(){var r=t[n].apply(t,arguments);try{i.default.trace.apply(i.default,["".concat(e," call: ").concat(n," with:")].concat(Array.prototype.slice.call(arguments),[r]))}catch(t){i.default.error("".concat(e," call: ").concat(n," logger failed"))}return r}}})};var u=function(){return!(!window.publicApi||!window.playerInterface)};t.inSMPWrapper=u;t.getSMPInterface=function(){return window.playerInterface};t.ADD_DETAILS_FLAG="addDetails";t.DEBUG_PLAYOUT_FLAG="debugPlayout";t.FACEBOOK_BLOCK_FLAG="overrideWebView";t.WEBVIEW_DEBUG_FLAG="debugWebview";t.UA_DEBUG_FLAG="debugUA";t.DISABLE_LOOKAHEAD_FLAG="disableLookahead";t.OVERRIDE_PLAYOUT="overrideEngine";t.OVERRIDE_PLAYOUT_FORMAT="overrideFormat";t.SHAKA_DEBUG_LEVEL="debugShaka";t.OVERRIDE_ACTIVE_BUFFERING="overrideActiveBuffering";t.OVERRIDE_INACTIVE_BUFFERING="overrideInactiveBuffering";var l=function(e){var t;switch(t=u()?new URLSearchParams(window.playerInterface.datastore.get("queryString")).get(e):new URLSearchParams(window.location.search).get(e),e){case"addDetails":case"overrideWebView":case"debugWebview":case"debugUA":case"disableLookahead":return"true"===t;case"debugPlayout":default:return t}};t.getSetting=l;t.getCurrentUrl=function(){return window.location.href};t.getVariableOverrides=function(){var e=new URLSearchParams(window.location.search).getAll("varName"),t=new URLSearchParams(window.location.search).getAll("varVal");return e.length!==t.length?(i.default.info("Query Parameter variable failed - number of name and value does not match"),[]):0===e.length?[]:e.map((function(e,n){return[e,t[n]]}))};var c=function(e){e.target.select(),document.execCommand("copy"),e.target.focus()};t.copySelection=c;t.addDetail=function(e,t,n){var r=document.createElement("div");r.className="detail",r.innerText="".concat(e,": ").concat(t||"");var i=document.createElement("input");return i.value="".concat(n||""),i.readOnly=!0,i.className="detail-input",i.onclick=c,r.appendChild(i),r};t.scrollToTop=function(){window.setTimeout((function(){window.scrollTo(0,0),document.getElementsByClassName("taster-offsite-panel").length>0&&document.getElementsByClassName("taster-offsite-panel")[0].scrollIntoView?document.getElementsByClassName("taster-offsite-panel")[0].scrollIntoView():document.getElementsByClassName("offsite-panel").length>0&&document.getElementsByClassName("offsite-panel")[0].scrollIntoView&&document.getElementsByClassName("offsite-panel")[0].scrollIntoView()}),100)};t.SLIDER_CLASS="slider-input";t.VIDEO="video";t.AUDIO="audio";t.LOOPING_AUDIO_AC_TYPE="urn:x-object-based-media:asset-collection-types:looping-audio/v1.0";t.preventEventDefault=function(e){e&&e.target&&e.target.classList&&(e.target.classList.includes("slider-input")||e.preventDefault())};t.handleButtonTouchEvent=function(e,t){return function(n){l("debugPlayout")&&(i.default.info("Event Captured:",n),i.default.info("Touch Event Captured:",t)),void 0!==n.touches&&n.touches&&n.touches.length>1||(n.stopPropagation(),n.preventDefault(),e())}};var d=function(e,t){return Number("".concat(Math.round("".concat(e,"e").concat(t)),"e-").concat(t))};t.precisionRound=d;t.leftGreaterThanRight=function(e,t){return d(e,2)>d(t,2)};t.replaceEscapedVariables=function(e,t){return e.match(/\$\{(.*?)\}/g)?t.getVariableState().then((function(t){return e.replace(/\$\{(.*?)\}/g,(function(e,n){return function(e){if(e===a.InternalVariableNames.DAY_OF_WEEK)return(0,a.getTodaysDay)();if(e===a.InternalVariableNames.PORTION_OF_DAY)return(0,a.getSegmentOfDay)();if(t[e]){var n=t[e],r=n.variable_type,i=n.value;switch(r){case"number":return i.toString();case"boolean":return i?"yes":"no";case"list":case"string":default:return encodeURI(i)}}return""}(n)}))})):Promise.resolve(e)};t.getControlHideList=function(e,t){var n=[];return e&&e.meta.storyplayer&&e.meta.storyplayer.hide_controls&&(n=n.concat(o(e.meta.storyplayer.hide_controls))),t&&t.meta.storyplayer&&t.meta.storyplayer.hide_controls&&(n=n.concat(o(t.meta.storyplayer.hide_controls))),n}},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,n){var r=n(20);e.exports=function(e){if(!r(e))throw TypeError(String(e)+" is not an object");return e}},function(e,t,n){"use strict";var r=n(4),i=n(15),a=n(90),o=n(20),s=n(35),u=n(31),l=n(79),c=n(116),d=n(78),h=n(17),f=n(77),p=h("isConcatSpreadable"),m=f>=51||!i((function(){var e=[];return e[p]=!1,e.concat()[0]!==e})),v=d("concat"),g=function(e){if(!o(e))return!1;var t=e[p];return void 0!==t?!!t:a(e)};r({target:"Array",proto:!0,forced:!m||!v},{concat:function(e){var t,n,r,i,a,o=s(this),d=c(o,0),h=0;for(t=-1,r=arguments.length;t<r;t++)if(g(a=-1===t?o:arguments[t])){if(h+(i=u(a.length))>9007199254740991)throw TypeError("Maximum allowed index exceeded");for(n=0;n<i;n++,h++)n in a&&l(d,h,a[n])}else{if(h>=9007199254740991)throw TypeError("Maximum allowed index exceeded");l(d,h++,a)}return d.length=h,d}})},function(e,t,n){"use strict";function r(e){return(r="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)}n(9),n(36),n(18),n(5),n(6),n(7),Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.RENDERER_PHASES=void 0,n(39),n(12),n(13),n(25),n(22),n(28),n(175),n(32),n(1),n(0),n(16),n(2),n(3),n(47),n(70),n(129),n(10),n(11);var i=b(n(29)),a=b(n(224)),o=b(n(227)),s=b(n(177)),u=b(n(178)),l=b(n(83)),c=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!==r(e)&&"function"!=typeof e)return{default:e};var n=_(t);if(n&&n.has(e))return n.get(e);var i={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var s=a?Object.getOwnPropertyDescriptor(e,o):null;s&&(s.get||s.set)?Object.defineProperty(i,o,s):i[o]=e[o]}i.default=e,n&&n.set(e,i);return i}(n(24)),d=(b(n(40)),b(n(33))),h=(b(n(43)),b(n(8))),f=n(19),p=n(48),m=n(239),v=n(240),g=n(241),y=n(243);b(n(104));function _(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,n=new WeakMap;return(_=function(e){return e?n:t})(e)}function b(e){return e&&e.__esModule?e:{default:e}}function E(e,t,n,r,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void n(e)}s.done?t(u):Promise.resolve(u).then(r,i)}function w(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var a=e.apply(t,n);function o(e){E(a,r,i,o,s,"next",e)}function s(e){E(a,r,i,o,s,"throw",e)}o(void 0)}))}}function S(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function T(e,t){return(T=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function x(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=M(e);if(t){var i=M(this).constructor;n=Reflect.construct(r,arguments,i)}else n=r.apply(this,arguments);return A(this,n)}}function A(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?R(e):t}function R(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function M(e){return(M=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var C={CONSTRUCTING:"CONSTRUCTING",CONSTRUCTED:"CONSTRUCTED",START:"START",MAIN:"MAIN",COMPLETING:"COMPLETING",ENDED:"ENDED",DESTROYED:"DESTROYED",BG_FADE_IN:"BG_FADE_IN",BG_FADE_OUT:"BG_FADE_OUT",MEDIA_FINISHED:"MEDIA_FINISHED"};t.RENDERER_PHASES=C;var L=function(e){!function(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}}),t&&T(e,t)}(E,e);var t,n,r,i,_,b=x(E);function E(e,t,n,r,i,a){var o;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,E),(o=b.call(this))._representation=e,o._rendererId=o._representation.id,o._fetchAssetCollection=t,o._fetchMedia=n,o._player=r,o._playoutEngine=r.playoutEngine,o._target=r.mediaTarget,o._controller=a,o._applyColourOverlayBehaviour=o._applyColourOverlayBehaviour.bind(R(o)),o._applyShowImageBehaviour=o._applyShowImageBehaviour.bind(R(o)),o._applyShowVariablePanelBehaviour=o._applyShowVariablePanelBehaviour.bind(R(o)),o._applyShowChoiceBehaviour=o._applyShowChoiceBehaviour.bind(R(o)),o._renderLinkChoices=o._renderLinkChoices.bind(R(o)),o._handleLinkChoiceEvent=o._handleLinkChoiceEvent.bind(R(o)),o._applySocialSharePanelBehaviour=o._applySocialSharePanelBehaviour.bind(R(o)),o._applyLinkOutBehaviour=o._applyLinkOutBehaviour.bind(R(o)),o._applyTextOverlayBehaviour=o._applyTextOverlayBehaviour.bind(R(o)),o._seekBack=o._seekBack.bind(R(o)),o._seekForward=o._seekForward.bind(R(o)),o._handlePlayPauseButtonClicked=o._handlePlayPauseButtonClicked.bind(R(o)),o._setBehaviourElementAttribute=o._setBehaviourElementAttribute.bind(R(o)),o._willHideControls=o._willHideControls.bind(R(o)),o._hideControls=o._hideControls.bind(R(o)),o._showControls=o._showControls.bind(R(o)),o._runDuringBehaviours=o._runDuringBehaviours.bind(R(o)),o._runStartBehaviours=o._runStartBehaviours.bind(R(o)),o._runSingleDuringBehaviour=o._runSingleDuringBehaviour.bind(R(o)),o.addTimeEventListener=o.addTimeEventListener.bind(R(o)),o._behaviourRendererMap={"urn:x-object-based-media:representation-behaviour:colouroverlay/v1.0":o._applyColourOverlayBehaviour,"urn:x-object-based-media:representation-behaviour:showimage/v1.0":o._applyShowImageBehaviour,"urn:x-object-based-media:representation-behaviour:showvariablepanel/v1.0":o._applyShowVariablePanelBehaviour,"urn:x-object-based-media:representation-behaviour:showlinkchoices/v1.0":o._applyShowChoiceBehaviour,"urn:x-object-based-media:representation-behaviour:socialmodal/v1.0":o._applySocialSharePanelBehaviour,"urn:x-object-based-media:representation-behaviour:linkoutmodal/v1.0":o._applyLinkOutBehaviour,"urn:x-object-based-media:representation-behaviour:textoverlay/v1.0":o._applyTextOverlayBehaviour},o._behaviourClassMap={"urn:x-object-based-media:representation-behaviour:pause/v1.0":s.default,"urn:x-object-based-media:representation-behaviour:manipulatevariable/v1.0":u.default},o._behaviourElements=[],o._destroyed=!1,o._analytics=i,o.inVariablePanel=!1,o._preloadedBehaviourAssets=[],o._preloadIconAssets().catch((function(e){return h.default.warn(e,"Could not preload icon assets")})),o._setPhase(C.CONSTRUCTING),o._inPauseBehaviourState=!1,o._serviceTimedEvents=o._serviceTimedEvents.bind(R(o)),o._timedEvents={},o}return t=E,(n=[{key:"_serviceTimedEvents",value:function(){var e=this;Object.keys(this._timedEvents).forEach((function(t){var n=e._timedEvents[t],r=n.startTime,i=n.startCallback,a=n.isRunning,o=n.endTime,s=n.clearCallback,u=e.getCurrentTime().currentTime;if(u>=r&&u<=o&&!a&&(h.default.info("TimeManager: ".concat(e._rendererId," timer running timed event ").concat(t)),e._timedEvents[t].isRunning=!0,i()),(u<r||u>o)&&a){try{s&&s()}catch(n){h.default.warn("TimeManager: ".concat(e._rendererId," couldn't clear up behaviour ").concat(t))}e._timedEvents[t].isRunning=!1}}))}},{key:"addTimeEventListener",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1/0,i=arguments.length>4?arguments[4]:void 0;h.default.debug("timer: Added event for ".concat(e," at ").concat(t)),this._timedEvents[e]={startTime:t,endTime:r,startCallback:n,isRunning:!1,clearCallback:i}}},{key:"deleteTimeEventListener",value:function(e){e in this._timedEvents&&delete this._timedEvents[e]}},{key:"init",value:(_=w(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("Need to override this class to run async code and set renderer phase to CONSTRUCTED");case 1:case"end":return e.stop()}}),e)}))),function(){return _.apply(this,arguments)})},{key:"willStart",value:function(e,t){var n=this;if(this.phase===C.CONSTRUCTING)return setTimeout((function(){return n.willStart(e,t)}),100),!1;if(this._setPhase(C.START),this.inVariablePanel=!1,this.emit(l.default.CONSTRUCTED),this._runStartBehaviours(),this._player.on(c.PlayerEvents.SEEK_BACKWARD_BUTTON_CLICKED,this._seekBack),this._player.on(c.PlayerEvents.SEEK_FORWARD_BUTTON_CLICKED,this._seekForward),(0,f.getSetting)(f.ADD_DETAILS_FLAG)){var r=this._representation,i=r.name,a=r.id;this._player.addDetails(e,t,i,a)}return!0}},{key:"_runStartBehaviours",value:function(){this._behaviourRunner=this._representation.behaviours?new a.default(this._representation.behaviours,this):null,this._behaviourRunner&&this._behaviourRunner.runBehaviours(o.default.started,l.default.COMPLETE_START_BEHAVIOURS)?(this._player.enterStartBehaviourPhase(this),this._playoutEngine.setPlayoutVisible(this._rendererId)):(this._player.enterStartBehaviourPhase(this),this.emit(l.default.COMPLETE_START_BEHAVIOURS))}},{key:"start",value:function(){this._setPhase(C.MAIN),this._player.exitStartBehaviourPhase(),clearInterval(this._timedEventsInterval),this._timedEventsInterval=setInterval(this._serviceTimedEvents,10),this.emit(l.default.STARTED),this._clearBehaviourElements(),this._player.connectScrubBar(this),this._player.on(c.PlayerEvents.PLAY_PAUSE_BUTTON_CLICKED,this._handlePlayPauseButtonClicked),this._runDuringBehaviours(),this._player.hideSeekButtons()}},{key:"end",value:function(){switch(this.phase){case C.ENDED:case C.DESTROYED:return h.default.debug("PHASE base ended already",this._representation.id,this.phase),!1}h.default.debug("PHASE base ending",this._representation.id,this.phase),this._player.disconnectScrubBar(this);try{this._clearBehaviourElements()}catch(e){h.default.warn(e,"error clearing behaviour elements")}return clearInterval(this._timedEventsInterval),this._reapplyLinkConditions(),this._player.exitCompleteBehaviourPhase(),this._player.removeListener(c.PlayerEvents.LINK_CHOSEN,this._handleLinkChoiceEvent),this._player.removeListener(c.PlayerEvents.SEEK_BACKWARD_BUTTON_CLICKED,this._seekBack),this._player.removeListener(c.PlayerEvents.SEEK_FORWARD_BUTTON_CLICKED,this._seekForward),this._controller.off(p.VARIABLE_EVENTS.CONTROLLER_CHANGED_VARIABLE,this._renderLinkChoices),this._player.removeListener(c.PlayerEvents.PLAY_PAUSE_BUTTON_CLICKED,this._handlePlayPauseButtonClicked),this._setPhase(C.ENDED),!0}},{key:"hasMediaEnded",value:function(){return this.phase===C.MEDIA_FINISHED||this.phase===C.COMPLETING||this.phase===C.ENDED||this.phase===C.DESTROYED}},{key:"exitStartPauseBehaviour",value:function(){this._behaviourRunner&&0!==this._behaviourRunner.eventCounters.started&&(this._behaviourRunner.behaviours.forEach((function(e){e instanceof s.default&&e.handleTimeout()})),this.setInPause(!1))}},{key:"exitCompletePauseBehaviour",value:function(){this._behaviourRunner&&0!==this._behaviourRunner.eventCounters.completed&&this._behaviourRunner.behaviours.forEach((function(e){e instanceof s.default&&e.handleTimeout()}))}},{key:"hasVariablePanelBehaviour",value:function(){var e=!1;return this._representation.behaviours&&this._representation.behaviours.completed&&this._representation.behaviours.completed.forEach((function(t){"urn:x-object-based-media:representation-behaviour:showvariablepanel/v1.0"===t.type&&(e=!0)})),e}},{key:"logRendererAction",value:function(e){var t={type:d.default.types.RENDERER_ACTION,name:d.default.names[e],from:"not_set",to:"not_set"};this._analytics(t)}},{key:"logUserInteraction",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"not_set",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"not_set",r={type:d.default.types.USER_ACTION,name:d.default.names[e],from:null===t?"not_set":t,to:null===n?"not_set":n};this._analytics(r)}},{key:"getRepresentation",value:function(){return this._representation}},{key:"getDuration",value:function(){var e=this._representation.duration;return(null==e||e<0)&&(e=1/0),e}},{key:"getCurrentTime",value:function(){throw new Error("getCurrentTime not implemented.")}},{key:"setCurrentTime",value:function(e){throw new Error("setCurrentTime not implemented.")}},{key:"_handlePlayPauseButtonClicked",value:function(e){e&&e.playButtonClicked?this.play():e&&e.pauseButtonClicked&&this.pause(),this._playoutEngine.getPlayoutActive(this._rendererId)&&(this._playoutEngine.isPlaying()?this.logRendererAction(d.default.names.VIDEO_UNPAUSE):this.logRendererAction(d.default.names.VIDEO_PAUSE))}},{key:"pause",value:function(){this._playoutEngine.pause()}},{key:"play",value:function(){this._playoutEngine.play()}},{key:"_seekBack",value:function(){if(this.phase!==C.START&&this.phase!==C.COMPLETING){var e=this.getCurrentTime(),t=e.timeBased,n=e.currentTime;if(t){var r=n-10;r<0&&(r=0),this.logUserInteraction(d.default.names.SEEK_BACKWARD_BUTTON_CLICKED,n,"".concat(r)),this.setCurrentTime(r)}}else h.default.info("Seek backward button clicked during behaviours - ignoring")}},{key:"_seekForward",value:function(){if(this.phase===C.START)return h.default.info("Seek forward button clicked during infinite start pause - starting element"),void this.exitStartPauseBehaviour();if(this.phase===C.COMPLETING)return h.default.info("Seek forward button clicked during infinite end pause - ending element"),void this.exitCompletePauseBehaviour();var e=this.getCurrentTime(),t=e.timeBased,n=e.currentTime,r=e.duration;if(t){var i=Math.min(n+10,r),a=this.getChoiceTime();a>0&&a<i&&(i=a),this.setCurrentTime(i),this.logUserInteraction(d.default.names.SEEK_FORWARD_BUTTON_CLICKED,n,"".concat(i))}}},{key:"getChoiceTime",value:function(){if(this._representation.behaviours&&this._representation.behaviours.during){var e=this._representation.behaviours.during.filter((function(e){return"urn:x-object-based-media:representation-behaviour:showlinkchoices/v1.0"===e.behaviour.type})).sort((function(e,t){return e.start_time-t.start_time}));if(e.length>0)return e[0].start_time}return-1}},{key:"complete",value:function(){this._linkFadeTimeout||(this._setPhase(C.COMPLETING),(!this._linkBehaviour||this._linkBehaviour&&!this._linkBehaviour.forceChoice)&&(this._player.enterCompleteBehavourPhase(),this.emit(l.default.STARTED_COMPLETE_BEHAVIOURS),this._behaviourRunner&&this._behaviourRunner.runBehaviours(o.default.completed,l.default.COMPLETED)||this.emit(l.default.COMPLETED)))}},{key:"switchFrom",value:function(){this.end()}},{key:"cueUp",value:function(){}},{key:"switchTo",value:function(){this.start()}},{key:"_preloadBehaviourAssets",value:(i=w(regeneratorRuntime.mark((function e(){var t,n=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._preloadedBehaviourAssets=[],t=this._representation.asset_collections.behaviours?this._representation.asset_collections.behaviours:[],e.next=4,Promise.all(t.map(function(){var e=w(regeneratorRuntime.mark((function e(t){var r,i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,n._fetchAssetCollection(t.asset_collection_id);case 3:if(!(r=e.sent).assets.image_src){e.next=9;break}return e.next=7,n._fetchMedia(r.assets.image_src);case 7:(i=e.sent)&&((a=new Image).src=i,n._preloadedBehaviourAssets.push(a));case 9:e.next=14;break;case 11:e.prev=11,e.t0=e.catch(0),h.default.error(e.t0,"could not preload behaviour asset ".concat(t.asset_collection_id));case 14:case"end":return e.stop()}}),e,null,[[0,11]])})));return function(t){return e.apply(this,arguments)}}()));case 4:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"_preloadIconAssets",value:function(){var e=this;this._preloadedIconAssets=[];var t=[];return this._representation.asset_collections.icon&&(this._representation.asset_collections.icon.default_id&&t.push(this._representation.asset_collections.icon.default_id),this._representation.asset_collections.icon.active_id&&t.push(this._representation.asset_collections.icon.active_id)),Promise.all(t.map((function(t){return e._fetchAssetCollection(t).then((function(t){return t.assets.image_src?e._fetchMedia(t.assets.image_src):Promise.resolve()})).then((function(t){if(t){var n=new Image;n.src=t,h.default.info("Preloading icon ".concat(t)),e._preloadedIconAssets.push(n)}})).catch((function(e){h.default.error(e,"could not preload icon asset ".concat(t))}))})))}},{key:"getBehaviourRenderer",value:function(e){var t=this,n=this._behaviourRendererMap[e];if(n)return n;var r=this._behaviourClassMap[e];return r?function(e,n){new r(e,n).start(t)}:(h.default.warn("Unable to handle behaviour of type &{behaviourUrn}"),null)}},{key:"hasShowIconBehaviour",value:function(){if(this._representation.behaviours){if(this._representation.behaviours.started&&this._representation.behaviours.started.filter((function(e){return"urn:x-object-based-media:representation-behaviour:showlinkchoices/v1.0"===e.type})).length>0)return!0;if(this._representation.behaviours.completed&&this._representation.behaviours.completed.filter((function(e){return"urn:x-object-based-media:representation-behaviour:showlinkchoices/v1.0"===e.type})).length>0)return!0;if(this._representation.behaviours.during&&this._representation.behaviours.during.filter((function(e){return"urn:x-object-based-media:representation-behaviour:showlinkchoices/v1.0"===e.behaviour.type})).length>0)return!0}return!1}},{key:"resetPlayer",value:function(){this._player.resetControls(),this._player.removeListener(c.PlayerEvents.LINK_CHOSEN,this._handleLinkChoiceEvent)}},{key:"_willHideControls",value:function(e){return"urn:x-object-based-media:representation-behaviour:showlinkchoices/v1.0"===e.type&&e.disable_controls}},{key:"_hideControls",value:function(e){var t=this,n=function(){t._player.disableControls(),t._player._hideRomperButtons()};e>1?this.addTimeEventListener("prechoice-control-hide",e-.4,n):n()}},{key:"_showControls",value:function(){this._player.enableControls()}},{key:"_runDuringBehaviours",value:function(){var e=this;this._representation.behaviours&&this._representation.behaviours.during&&this._representation.behaviours.during.forEach((function(t){e._runSingleDuringBehaviour(t)}))}},{key:"_runSingleDuringBehaviour",value:function(e){var t=this,n=this.getBehaviourRenderer(e.behaviour.type);if(n){var r=function(){h.default.info("started during behaviour ".concat(e.behaviour.type)),t._analytics({type:d.default.types.RENDERER_ACTION,name:d.default.names.DURING_BEHAVIOUR_STARTED,from:e.behaviour.type,to:""}),n(e.behaviour,(function(){return h.default.info("completed during behaviour ".concat(e.behaviour.type))}))};this._willHideControls(e.behaviour)&&this._hideControls(e.start_time);var i=e.start_time,a=function(e){if(void 0!==e.duration)return e.start_time+e.duration}(e),o=function(){var n=document.getElementById(e.behaviour.id);n&&n.parentNode&&n.parentNode.removeChild(n),t._showControls()},s=e.behaviour.id;0===i?(r(),this.addTimeEventListener(s,a,o)):this.addTimeEventListener(s,i,r,a,o)}else h.default.warn("".concat(this.constructor.name," does not support ")+"".concat(e.behaviour.type," - ignoring"))}},{key:"_applyShowChoiceBehaviour",value:function(e,t){return this._player.on(c.PlayerEvents.LINK_CHOSEN,this._handleLinkChoiceEvent),this._linkChoiceBehaviourOverlay=this._player.createBehaviourOverlay(e),this._setBehaviourElementAttribute(this._linkChoiceBehaviourOverlay.getOverlay(),"link-choice"),this._choiceBehaviourData={choiceIconNEObjects:null,behaviour:e,callback:t},this._controller.on(p.VARIABLE_EVENTS.CONTROLLER_CHANGED_VARIABLE,this._renderLinkChoices),this._renderLinkChoices()}},{key:"_choicesHaveChanged",value:function(e){var t=this._choiceBehaviourData.choiceIconNEObjects;if(t.length!==e.length)return!0;var n=!0;return e.forEach((function(e){t.find((function(t){return t.targetNeId===e.targetNeId}))||(n=!1)})),!n}},{key:"_renderLinkChoices",value:function(){var e=this,t=this._choiceBehaviourData,n=t.behaviour,r=t.callback,i=t.choiceIconNEObjects,a=this._getLinkChoiceBehaviours(n),o=a.showNeToEnd,s=a.countdown,u=a.disableControls,l=a.iconOverlayClass,c=a.forceChoice,d=a.oneShot,f=a.showIfOneLink;this._linkBehaviour={showNeToEnd:o,oneShot:d,forceChoice:c,callback:c?r:function(){}};var p=this._linkChoiceBehaviourOverlay;return u&&this._player.disableControls(),this._controller.getValidNextSteps().then((function(t){if(null!==i){if(!e._choicesHaveChanged(t))return h.default.info("Variable state has changed, but same link options valid"),Promise.resolve();h.default.info("Variable state has changed valid links - need to refresh icons"),e._clearChoices(),p.clearAll()}if(e._choiceBehaviourData.choiceIconNEObjects=t,0===t.length)return h.default.warn("Show link icons behaviour run, but no links are currently valid"),e._player.enableControls(),r(),Promise.resolve();if(1===t.length&&!f)return h.default.info("Link Choice behaviour ignored - only one link"),e._player.enableControls(),r(),Promise.resolve();var a=e._getDefaultLink(t);return e._getIconSourceUrls(t,n).then((function(t){e._clearChoices(),t.forEach((function(t){e._buildLinkIcon(t,p.getOverlay())})),t.length>1||f?(e._showChoiceIcons({defaultLinkId:a,forceChoice:c,disableControls:u,countdown:s,iconOverlayClass:l,behaviourOverlay:p,choiceCount:t.length}),c||r()):(h.default.info("Link Choice behaviour ignored - only one link"),e._linkBehaviour.forceChoice=!1,r())})).catch((function(e){h.default.error(e,"could not get assets for rendering link icons"),r()}))})).catch((function(e){h.default.error(e,"Could not get next steps for rendering links"),r()}))}},{key:"_handleLinkChoiceEvent",value:function(e){this._followLink(e.id,e.behaviourId)}},{key:"_getLinkChoiceBehaviours",value:function(e){var t=!1,n=!0,r=null,i=!1,a=!1,o=!0,s=!1;return e.hasOwnProperty("show_ne_to_end")&&(o=e.show_ne_to_end),e.hasOwnProperty("one_shot")&&(a=e.one_shot),e.hasOwnProperty("show_if_one_choice")&&(s=e.show_if_one_choice),e.hasOwnProperty("show_time_remaining")&&(t=e.show_time_remaining),e.hasOwnProperty("disable_controls")&&(n=e.disable_controls),e.hasOwnProperty("overlay_class")&&(r=e.overlay_class),e.hasOwnProperty("force_choice")&&(i=e.force_choice),{showNeToEnd:o,countdown:t,disableControls:n,iconOverlayClass:r,forceChoice:i,oneShot:a,showIfOneLink:s}}},{key:"_getIconSourceUrls",value:function(e,t){var n=this,r=[];return e.forEach((function(e,i){h.default.info("choice ".concat(i+1,": ").concat(e.ne.id));var a={choiceId:i,acId:null,ac:null,resolvedUrl:null,targetNarrativeElementId:e.targetNeId,iconText:null};t.link_icons&&t.link_icons.forEach((function(t){t.target_narrative_element_id===e.targetNeId&&(t.image&&(a.acId=n.resolveBehaviourAssetCollectionMappingId(t.image),Object.keys(t).forEach((function(e){"image"!==e&&(a[e]=t[e])}))),t.text&&(a.iconText=t.text))})),r.push(Promise.resolve(a))})),Promise.all(r).then((function(e){var t=[];return e.forEach((function(e){e.acId?t.push(n._fetchAssetCollection(e.acId)):t.push(Promise.resolve(null))})),Promise.all(t).then((function(t){return t.forEach((function(t,n){e[n].ac=t})),Promise.resolve(e)}))})).then((function(e){var t=[];return e.forEach((function(e){e&&e.ac&&e.ac.assets.image_src?t.push(n._fetchMedia(e.ac.assets.image_src)):t.push(Promise.resolve(""))})),Promise.all(t).then((function(t){var n=[];return t.forEach((function(t,r){var i=e[r];i.resolvedUrl=t,n.push(i)})),n}))}))}},{key:"_buildLinkIcon",value:function(e,t){var n,r=e.targetNarrativeElementId;if(e.iconText&&e.resolvedUrl?n=this._player.addTextLinkIconChoice(t,r,e.iconText,e.resolvedUrl,e.iconText):e.iconText?n=this._player.addTextLinkChoice(t,r,e.iconText,e.iconText):e.resolvedUrl?n=this._player.addLinkChoiceControl(t,r,e.resolvedUrl,"Option ".concat(e.choiceId+1)):h.default.warn("No icon specified for link to ".concat(r," - not rendering")),n&&e.position&&e.position.two_d){var i=e.position.two_d,a=i.left,o=i.top,s=e.position.two_d,u=s.width,l=s.height;void 0===a||void 0===o||void 0===u&&void 0===l||(void 0===u?u=l:void 0===l&&(l=u),n.style.position="absolute",n.style.top="".concat(o,"%"),n.style.left="".concat(a,"%"),n.style.width="".concat(u,"%"),n.style.height="".concat(l,"%"))}}},{key:"_showChoiceIcons",value:function(e){var t=this,n=e.defaultLinkId,r=e.forceChoice,i=e.disableControls,a=e.countdown,o=e.iconOverlayClass,s=e.behaviourOverlay,u=e.choiceCount;this._player.showChoiceIcons(r?null:n,o,s,u).then((function(){i&&t._player.disableControls(),a&&t._player.startChoiceCountdown(t),t._player.enableLinkChoiceControl()})).catch((function(e){h.default.error(e,"could not render link choice icons")}))}},{key:"_followLink",value:function(e,t){this._playoutEngine.isPlaying()||this.play(),this._controller.off(p.VARIABLE_EVENTS.CONTROLLER_CHANGED_VARIABLE,this._renderLinkChoices),this._linkBehaviour&&(this._linkBehaviour.forceChoice=!1);var n=this._controller.getCurrentNarrativeElement();this._linkBehaviour&&this._linkBehaviour.showNeToEnd?(n.links.forEach((function(t){t.target_narrative_element_id===e?t.override_as_chosen=!0:t.hasOwnProperty("override_as_chosen")&&(t.override_as_chosen=!1)})),this.hasMediaEnded()?this._hideChoiceIcons(e,t):this._linkBehaviour&&this._linkBehaviour.oneShot&&(this._hideChoiceIcons(null,t),this._controller.refreshPlayerControls(),this._player.enableControls(),this._player.showSeekButtons())):this._hideChoiceIcons(e,t)}},{key:"_getDefaultLink",value:function(e){var t=this._controller.getCurrentNarrativeElement().links.filter((function(t){return e.filter((function(e){return e.targetNeId===t.target_narrative_element_id})).length>0}))[0];return t&&t.target_narrative_element_id}},{key:"_reapplyLinkConditions",value:function(){this._controller.getCurrentNarrativeElement().links.forEach((function(e){e.hasOwnProperty("override_as_chosen")&&(e.override_as_chosen=!1)}))}},{key:"_hideChoiceIcons",value:function(e,t){var n=this;e&&this._reapplyLinkConditions();var r=document.getElementById(t);this._linkFadeTimeout&&clearTimeout(this._linkFadeTimeout),r&&(this._linkFadeTimeout=setTimeout((function(){r.classList.remove("romper-icon-fade"),n._clearChoices(),e?n._controller.followLink(e):n._linkBehaviour.callback()}),1500),r.classList.add("romper-icon-fade"))}},{key:"_clearChoices",value:function(){this._player.clearLinkChoices(),this._linkFadeTimeout&&clearTimeout(this._linkFadeTimeout),this._linkFadeTimeout=null}},{key:"_applyColourOverlayBehaviour",value:function(e,t){var n=e.colour,r=document.createElement("div");this._setBehaviourElementAttribute(r,"colour-overlay"),r.style.background=n,r.className="romper-image-overlay",this._target.appendChild(r),this._behaviourElements.push(r),t()}},{key:"_applyShowImageBehaviour",value:function(e,t){var n=this,r=e.image,i=this.resolveBehaviourAssetCollectionMappingId(r);i?this._fetchAssetCollection(i).then((function(e){return e.assets.image_src?n._fetchMedia(e.assets.image_src):Promise.resolve()})).then((function(r){r&&n._overlayImage(r,e.id),t()})).catch((function(e){h.default.error(e,"could not get image for show image behaviour")})):h.default.error("No asset collection id for show image behaviour")}},{key:"_overlayImage",value:function(e,t){var n=document.createElement("img");n.setAttribute("draggable","false"),n.id=t,this._setBehaviourElementAttribute(n,"image-overlay"),n.src=e,n.className="romper-image-overlay notInteractiveContent",this._target.appendChild(n),this._behaviourElements.push(n)}},{key:"_applySocialSharePanelBehaviour",value:function(e,t){var n=(0,v.renderSocialPopup)(e,this._player.getOverlayElement(),t,this._analytics);this._setBehaviourElementAttribute(n,"social-share"),this._behaviourElements.push(n)}},{key:"_applyLinkOutBehaviour",value:function(e,t){var n=(0,g.renderLinkoutPopup)(e,this._player.getOverlayElement(),t,this._analytics);this._setBehaviourElementAttribute(n,"link-out"),this._behaviourElements.push(n)}},{key:"_applyTextOverlayBehaviour",value:function(e,t){var n=(0,y.renderTextOverlay)(e,this._player.getOverlayElement(),t,this._controller);this._setBehaviourElementAttribute(n,"text-overlay"),this._behaviourElements.push(n)}},{key:"_setBehaviourElementAttribute",value:function(e,t){e.setAttribute("data-behaviour",t),e.setAttribute("behaviour-renderer",this._rendererId)}},{key:"_setVariableValue",value:function(e,t){var n=this;this._controller.getVariableValue(e).then((function(r){n._controller.setVariableValue(e,t);var i={type:d.default.types.USER_ACTION,name:d.default.names.USER_SET_VARIABLE,from:"".concat(e,": ").concat(r),to:"".concat(e,": ").concat(t)};n._analytics(i)}))}},{key:"_applyShowVariablePanelBehaviour",value:function(e,t){(0,m.buildPanel)(e,this._controller.getVariableState.bind(this._controller),this._controller.getVariableValue.bind(this._controller),this._setVariableValue.bind(this),t,this._target,this._player,this,this._analytics)}},{key:"_clearBehaviourElements",value:function(){document.querySelectorAll('[behaviour-renderer="'.concat(this._rendererId,'"]')).forEach((function(e){try{e&&e.parentNode&&e.parentNode.removeChild(e)}catch(t){h.default.warn("could not remove behaviour element ".concat(e.id," from Renderer"))}}))}},{key:"resolveBehaviourAssetCollectionMappingId",value:function(e){if(this._representation.asset_collections.behaviours){var t=null;return this._representation.asset_collections.behaviours.some((function(n){return n.behaviour_asset_collection_mapping_id===e&&(t=n.asset_collection_id,!0)})),t}return null}},{key:"isVRViewable",value:function(){return!1}},{key:"setInPause",value:function(e){this._inPauseBehaviourState=e}},{key:"getInPause",value:function(){return this._inPauseBehaviourState}},{key:"destroy",value:function(){return h.default.debug("PHASE destroying",this._representation.id,this.phase),this.phase===C.DESTROYED?(h.default.debug("PHASE destroying - already destroyed",this._representation.id,this.phase),!1):(this.phase!==C.ENDED&&(h.default.debug("PHASE destroying need to end first"),this.end()),this._clearBehaviourElements(),this._behaviourRunner&&this._behaviourRunner.destroyBehaviours(),this.emit(l.default.DESTROYED),this._destroyed=!0,!0)}},{key:"getController",value:function(){return this