@flowplayer/player 3.2.8 → 3.3.0

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.
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.endscreen=t())}(this,(function(){"use strict";var e="playlist:ended",t="interstitial/end",n="interstitial/cancel",s="interstitial/next_item";function i(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}const r=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e),o=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)};class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const l=(e,t)=>{const n=document.createElement("span");return n.classList.add(e),n.textContent=t,n};class InterstitialGrid extends FlowplayerComponent{constructor(e){super(e),this.classList.add("interstitial-grid"),this.addEventListener(InterstitialGrid.events.RENDER,t=>{this.prepare_endscreen(t.detail,e)}),e.on("resize",()=>{e.root.classList.contains("is-grid")&&this.items&&this.prepare_endscreen(this.items,e)}),this.previousButton=document.createElement("div"),this.previousButton.classList.add("fp-previous"),this.nextButton=document.createElement("div"),this.nextButton.classList.add("fp-next"),this.previousButton.addEventListener("click",this.navigation_buttons_listener.bind(this,!0)),this.nextButton.addEventListener("click",this.navigation_buttons_listener.bind(this,!1))}calculate_max_cells_number(e,t){const n=this.parentElement;if(!n)return;const s=window.getComputedStyle(n).padding,i=t.clientWidth-2*parseFloat(s),r=t.clientHeight-2*parseFloat(s);let o=e,l=0,d=0,a=0,c=0;e:for(;o>0;o-=1){if(1===o){l=i,d=Math.min(r,Math.max(l/1.5,l/1.8)),a=c=1;break}let e=1;for(;e<=o;e++){const t=Number.isInteger(o/e)?o/e:parseInt((o/e).toString())+1,n=i/e;let s=1.5;for(;s<=1.8;s+=.1){const i=n/s;if(i>=64&&i*t<=r&&n>=115){l=n,d=i,a=e,c=t;break e}}}}return this.style.setProperty("grid-template-columns",`repeat(${a}, ${l}px)`),this.style.setProperty("grid-template-rows",`repeat(${c}, ${d}px)`),o}prepare_endscreen(e,t){this.items=e,this.rendered_items=this.items.slice(0,this.calculate_max_cells_number(this.items.length,t)),this.populate_cells(this.rendered_items),this.hide_navigation_buttons(this.items.every((e,t)=>{var n;return e===(null===(n=this.rendered_items)||void 0===n?void 0:n[t])}))}populate_cells(e){this.innerHTML="",e.forEach(e=>{var t,n;const s=document.createElement("div");s.classList.add("grid-item"),e.poster&&(s.style.backgroundImage=`url(${e.poster})`);const i=document.createElement("div");i.classList.add("overlay");const r=l("title",null!==(t=e.title)&&void 0!==t?t:""),o=l("description",null!==(n=e.description)&&void 0!==n?n:"");i.append(r,o),s.append(i),s.addEventListener("click",()=>{const t=new CustomEvent(InterstitialGrid.events.SELECTION,{detail:e});this.dispatchEvent(t)}),this.append(s)})}hide_navigation_buttons(e){[this.previousButton,this.nextButton].forEach(t=>t.style.setProperty("display",e?"none":"block"))}connectedCallback(){var e;this.isConnected&&(null===(e=this.parentElement)||void 0===e||e.append(this.previousButton,this.nextButton))}navigation_buttons_listener(e){if(!this.rendered_items)return;const t=[];this.rendered_items.forEach(n=>{if(!this.items)return;const s=this.items.indexOf(n);if(void 0===s||-1===s)return;const i=this.calculate_index(e,s);void 0!==i&&t.push(this.items[i])}),this.rendered_items=t,this.populate_cells(this.rendered_items)}calculate_index(e,t){if(!this.items||!this.rendered_items)return;const n=this.items.length,s=this.rendered_items.length;let i=e?t-s:t+s;return i<0&&e&&(i=n+i),i>n-1&&!e&&(i-=n),i}}InterstitialGrid.events={SELECTION:"interstitial/grid/selection",RENDER:"interstitial/grid/render"};const d=["title","delay","description","poster","src"];class UpNext extends FlowplayerComponent{static get observedAttributes(){return d}constructor(e){super(e),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent(t))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent(n))}),this.addEventListener(s,this._setUpNext.bind(this))}getTitle(){return this.getAttribute("title")||""}getDescription(){return this.getAttribute("description")||""}getPoster(){return this.getAttribute("poster")||""}getDelay(){return this.getAttribute("delay")||""}connectedCallback(){this.isConnected&&this._render()}attributeChangedCallback(){this._render()}_render(){var e,n;this.innerHTML="",this.classList.remove("cancelled");const s=document.createDocumentFragment(),i=document.createElement("div");i.classList.add("pane","left");const r=document.createElement("div");r.classList.add("pane","right"),s.append(i,r);const o=document.createElement("div");o.classList.add("poster"),o.style.backgroundImage="url("+this.getPoster()+")",i.append(o),o.addEventListener("click",()=>this.dispatchEvent(new CustomEvent(t)));const l=document.createElement("span");l.classList.add("fp-icon","fp-play"),o.append(l);const d=document.createElement("span");d.classList.add("title"),d.textContent=this.getTitle();const a=document.createElement("span");a.classList.add("description"),a.textContent=this.getDescription();const c=document.createElement("span");c.classList.add("countdown"),this.getDelay()&&(c.style.setProperty("--up-next-delay",this.getDelay()+"s"),c.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(n=null===(e=this.player)||void 0===e?void 0:e.i18n("playlist.cancel"))&&void 0!==n?n:"cancel",p.addEventListener("click",()=>c.classList.remove("go")),r.append(d,a,p,c),this.append(s)}_setUpNext(e){var t,n,s;const i=e.detail.next,r=this.player.opt("playlist.delay",void 0)||10;this.setAttribute("title",null!==(t=i.title)&&void 0!==t?t:""),this.setAttribute("description",null!==(n=i.description)&&void 0!==n?n:""),this.setAttribute("poster",null!==(s=i.poster)&&void 0!==s?s:""),this.setAttribute("delay",r+"")}}function a(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),s=(s,...i)=>{const r=(null==t?void 0:t.debug)||n;r&&e.match(r)&&console.log(`${e} -- ${s}`,...i)};return s.log=s,s}function c(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class EndscreenInterstitial extends FlowplayerComponent{constructor(e){super(e),this.className="fp-endscreen",this.upNextEle=r(e,"flowplayer-endscreen-up-next"),this.gridEle=r(e,"flowplayer-endscreen-grid"),this.append(this.upNextEle,this.gridEle),this.addEventListener("recommendations:render",this.on_recommendations_render.bind(this)),this.upNextEle.addEventListener(n,this.on_next_cancel.bind(this)),this.upNextEle.addEventListener(t,this.on_next_end.bind(this)),this.gridEle.addEventListener(InterstitialGrid.events.SELECTION,this.on_grid_selection.bind(this))}on_recommendations_render(e){const t=e.detail;if(this.playlist=t.playlist,this.on_item_selected=t.on_item_selected,this.player.playlist||!1===this.player.opt("endscreen.auto_advance"))return this.gridEle.dispatchEvent(new CustomEvent(InterstitialGrid.events.RENDER,{detail:this.playlist})),this.player.root.classList.add("is-grid");this.gridEle.hide_navigation_buttons(!0),this.player.root.classList.add("is-up-next"),c(this.upNextEle,s,{next:this._nextVideo(this.playlist)})}on_next_cancel(){this.player.root.classList.contains("is-endscreen")&&this.playlist&&(this.gridEle.dispatchEvent(new CustomEvent(InterstitialGrid.events.RENDER,{detail:this.playlist})),this.player.root.classList.remove("is-up-next"),this.player.root.classList.add("is-grid"))}on_next_end(){if(!this.playlist||!this.on_item_selected)return;const e=this.current_video=this._nextVideo(this.playlist);this.on_item_selected(e)}on_grid_selection(e){this.on_item_selected&&this.on_item_selected(e.detail),this.current_video=e.detail,this.gridEle.hide_navigation_buttons(!0)}_nextVideo(e){if(!this.current_video)return e[0];const t=e.indexOf(this.current_video);return[-1,e.length-1].includes(t)?e[0]:e[t+1]}}class Endscreen{constructor(e,t){this.logger=a("flowplayer/endscreen"),o(e,"flowplayer-endscreen-interstitial",EndscreenInterstitial),o(e,"flowplayer-endscreen-up-next",class extends UpNext{}),o(e,"flowplayer-endscreen-grid",class extends InterstitialGrid{})}init(t,n,s){const o=r(s,"flowplayer-endscreen-interstitial");var l;s.on("mount",()=>{var e;return null===(e=i(s,"flowplayer-ui"))||void 0===e?void 0:e.prepend(o)}),s.on("recommendationsready",e=>{const t=e.detail;this.recommendations=t,this.logger.log(`loaded ${t.playlist.length} recommendations`)}),s.on(["ended",e],(l=e=>{var i;this.recommendations&&(e.prevented_from_ads||t.loop||(null===(i=null==t?void 0:t.playlist)||void 0===i?void 0:i.loop)||"ended"==e.type&&s.playlist||(c(o,"recommendations:render",{playlist:this.recommendations.playlist.slice(0,12),on_item_selected:this._setSrc.bind(this,s)}),n.classList.add("is-endscreen")))},e=>{setTimeout((function(){if(!e.defaultPrevented)return l(e)}),0)})),s.on(["seeking","loadstart","playing"],()=>{s.root.classList.contains("is-endscreen")&&this.hide_recommendations(s)})}_setSrc(e,t){var n;if(this.hide_recommendations(e),e.playlist)return e.playlist.push(t),null===(n=e.playlist)||void 0===n?void 0:n.next();e.setSrc(t.src),e.setOpts({title:t.title}),e.once("canplay",()=>e.togglePlay(!0))}hide_recommendations(e){e.root.classList.remove("is-endscreen","is-grid","is-up-next");const t=i(e,"flowplayer-endscreen-interstitial");t&&c(t,"recommendations:hide")}}return Endscreen.events={RECOMMENDATIONS_RENDER:"recommendations:render",RECOMMENDATIONS_READY:"recommendationsready",RECOMMENDATIONS_HIDE:"recommendations:hide"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,Endscreen)}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.endscreen=t())}(this,(function(){"use strict";var e="playlist:ended",t="interstitial/end",n="interstitial/cancel",s="interstitial/next_item";function i(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}const r=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const s=window.customElements.get(t);if(!s)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?s:i})(e._customElements,t))(e),o=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)};class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const l=(e,t)=>{const n=document.createElement("span");return n.classList.add(e),n.textContent=t,n};class InterstitialGrid extends FlowplayerComponent{constructor(e){super(e),this.classList.add("interstitial-grid"),this.addEventListener(InterstitialGrid.events.RENDER,t=>{this.prepare_endscreen(t.detail,e)}),e.on("resize",()=>{e.root.classList.contains("is-grid")&&this.items&&this.prepare_endscreen(this.items,e)}),this.previousButton=document.createElement("div"),this.previousButton.classList.add("fp-previous"),this.nextButton=document.createElement("div"),this.nextButton.classList.add("fp-next"),this.previousButton.addEventListener("click",this.navigation_buttons_listener.bind(this,!0)),this.nextButton.addEventListener("click",this.navigation_buttons_listener.bind(this,!1))}calculate_max_cells_number(e,t){const n=this.parentElement;if(!n)return;const s=window.getComputedStyle(n).padding,i=t.clientWidth-2*parseFloat(s),r=t.clientHeight-2*parseFloat(s);let o=e,l=0,d=0,a=0,c=0;e:for(;o>0;o-=1){if(1===o){l=i,d=Math.min(r,Math.max(l/1.5,l/1.8)),a=c=1;break}let e=1;for(;e<=o;e++){const t=Number.isInteger(o/e)?o/e:parseInt((o/e).toString())+1,n=i/e;let s=1.5;for(;s<=1.8;s+=.1){const i=n/s;if(i>=64&&i*t<=r&&n>=115){l=n,d=i,a=e,c=t;break e}}}}return this.style.setProperty("grid-template-columns",`repeat(${a}, ${l}px)`),this.style.setProperty("grid-template-rows",`repeat(${c}, ${d}px)`),o}prepare_endscreen(e,t){this.items=e,this.rendered_items=this.items.slice(0,this.calculate_max_cells_number(this.items.length,t)),this.populate_cells(this.rendered_items),this.hide_navigation_buttons(this.items.every((e,t)=>{var n;return e===(null===(n=this.rendered_items)||void 0===n?void 0:n[t])}))}populate_cells(e){this.innerHTML="",e.forEach(e=>{var t,n;const s=document.createElement("div");s.classList.add("grid-item"),e.poster&&(s.style.backgroundImage=`url(${e.poster})`);const i=document.createElement("div");i.classList.add("overlay");const r=l("title",null!==(t=e.title)&&void 0!==t?t:""),o=l("description",null!==(n=e.description)&&void 0!==n?n:"");i.append(r,o),s.append(i),s.addEventListener("click",()=>{const t=new CustomEvent(InterstitialGrid.events.SELECTION,{detail:e});this.dispatchEvent(t)}),this.append(s)})}hide_navigation_buttons(e){[this.previousButton,this.nextButton].forEach(t=>t.style.setProperty("display",e?"none":"block"))}connectedCallback(){var e;this.isConnected&&(null===(e=this.parentElement)||void 0===e||e.append(this.previousButton,this.nextButton))}navigation_buttons_listener(e){if(!this.rendered_items)return;const t=[];this.rendered_items.forEach(n=>{if(!this.items)return;const s=this.items.indexOf(n);if(void 0===s||-1===s)return;const i=this.calculate_index(e,s);void 0!==i&&t.push(this.items[i])}),this.rendered_items=t,this.populate_cells(this.rendered_items)}calculate_index(e,t){if(!this.items||!this.rendered_items)return;const n=this.items.length,s=this.rendered_items.length;let i=e?t-s:t+s;return i<0&&e&&(i=n+i),i>n-1&&!e&&(i-=n),i}}InterstitialGrid.events={SELECTION:"interstitial/grid/selection",RENDER:"interstitial/grid/render"};const d=["title","delay","description","poster","src"];class UpNext extends FlowplayerComponent{static get observedAttributes(){return d}constructor(e){super(e),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent(t))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent(n))}),this.addEventListener(s,this._setUpNext.bind(this))}getTitle(){return this.getAttribute("title")||""}getDescription(){return this.getAttribute("description")||""}getPoster(){return this.getAttribute("poster")||""}getDelay(){return this.getAttribute("delay")||""}connectedCallback(){this.isConnected&&this._render()}attributeChangedCallback(){this._render()}_render(){var e,n;this.innerHTML="",this.classList.remove("cancelled");const s=document.createDocumentFragment(),i=document.createElement("div");i.classList.add("pane","left");const r=document.createElement("div");r.classList.add("pane","right"),s.append(i,r);const o=document.createElement("div");o.classList.add("poster"),o.style.backgroundImage="url("+this.getPoster()+")",i.append(o),o.addEventListener("click",()=>this.dispatchEvent(new CustomEvent(t)));const l=document.createElement("span");l.classList.add("fp-icon","fp-play"),o.append(l);const d=document.createElement("span");d.classList.add("title"),d.textContent=this.getTitle();const a=document.createElement("span");a.classList.add("description"),a.textContent=this.getDescription();const c=document.createElement("span");c.classList.add("countdown"),this.getDelay()&&(c.style.setProperty("--up-next-delay",this.getDelay()+"s"),c.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(n=null===(e=this.player)||void 0===e?void 0:e.i18n("playlist.cancel"))&&void 0!==n?n:"cancel",p.addEventListener("click",()=>c.classList.remove("go")),r.append(d,a,p,c),this.append(s)}_setUpNext(e){var t,n,s;const i=e.detail.next,r=this.player.opt("playlist.delay",void 0)||10;this.setAttribute("title",null!==(t=i.title)&&void 0!==t?t:""),this.setAttribute("description",null!==(n=i.description)&&void 0!==n?n:""),this.setAttribute("poster",null!==(s=i.poster)&&void 0!==s?s:""),this.setAttribute("delay",r+"")}}function a(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),s=(s,...i)=>{const r=(null==t?void 0:t.debug)||n;r&&e.match(r)&&console.log(`flowplayer/${e} -- ${s}`,...i)};return s.log=s,s}function c(e,t,n){const s=function(e,t){const n=new CustomEvent(e,{detail:t,cancelable:!0});return t&&Object.defineProperty(n,"data",{get:()=>t}),n}(t,n);return e.dispatchEvent(s),e}!function(){let e=!1;try{const t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassive",null,t),window.removeEventListener("testPassive",null,t)}catch(e){}}();class EndscreenInterstitial extends FlowplayerComponent{constructor(e){super(e),this.className="fp-endscreen",this.upNextEle=r(e,"flowplayer-endscreen-up-next"),this.gridEle=r(e,"flowplayer-endscreen-grid"),this.append(this.upNextEle,this.gridEle),this.addEventListener("recommendations:render",this.on_recommendations_render.bind(this)),this.upNextEle.addEventListener(n,this.on_next_cancel.bind(this)),this.upNextEle.addEventListener(t,this.on_next_end.bind(this)),this.gridEle.addEventListener(InterstitialGrid.events.SELECTION,this.on_grid_selection.bind(this))}on_recommendations_render(e){const t=e.detail;if(this.playlist=t.playlist,this.on_item_selected=t.on_item_selected,this.player.playlist||!1===this.player.opt("endscreen.auto_advance"))return this.gridEle.dispatchEvent(new CustomEvent(InterstitialGrid.events.RENDER,{detail:this.playlist})),this.player.root.classList.add("is-grid");this.gridEle.hide_navigation_buttons(!0),this.player.root.classList.add("is-up-next"),c(this.upNextEle,s,{next:this._nextVideo(this.playlist)})}on_next_cancel(){this.player.root.classList.contains("is-endscreen")&&this.playlist&&(this.gridEle.dispatchEvent(new CustomEvent(InterstitialGrid.events.RENDER,{detail:this.playlist})),this.player.root.classList.remove("is-up-next"),this.player.root.classList.add("is-grid"))}on_next_end(){if(!this.playlist||!this.on_item_selected)return;const e=this.current_video=this._nextVideo(this.playlist);this.on_item_selected(e)}on_grid_selection(e){this.on_item_selected&&this.on_item_selected(e.detail),this.current_video=e.detail,this.gridEle.hide_navigation_buttons(!0)}_nextVideo(e){if(!this.current_video)return e[0];const t=e.indexOf(this.current_video);return[-1,e.length-1].includes(t)?e[0]:e[t+1]}}class Endscreen{constructor(e,t){this.logger=a("flowplayer/endscreen"),o(e,"flowplayer-endscreen-interstitial",EndscreenInterstitial),o(e,"flowplayer-endscreen-up-next",class extends UpNext{}),o(e,"flowplayer-endscreen-grid",class extends InterstitialGrid{})}init(t,n,s){const o=r(s,"flowplayer-endscreen-interstitial");var l;s.on("mount",()=>{var e;return null===(e=i(s,"flowplayer-ui"))||void 0===e?void 0:e.prepend(o)}),s.on("recommendationsready",e=>{const t=e.detail;this.recommendations=t,this.logger.log(`loaded ${t.playlist.length} recommendations`)}),s.on(["ended",e],(l=e=>{var i;this.recommendations&&(e.prevented_from_ads||t.loop||(null===(i=null==t?void 0:t.playlist)||void 0===i?void 0:i.loop)||"ended"==e.type&&s.playlist||(c(o,"recommendations:render",{playlist:this.recommendations.playlist.slice(0,12),on_item_selected:this._setSrc.bind(this,s)}),n.classList.add("is-endscreen")))},e=>{setTimeout((function(){if(!e.defaultPrevented)return l(e)}),0)})),s.on(["seeking","loadstart","playing"],()=>{s.root.classList.contains("is-endscreen")&&this.hide_recommendations(s)})}_setSrc(e,t){var n;if(this.hide_recommendations(e),e.playlist)return e.playlist.push(t),null===(n=e.playlist)||void 0===n?void 0:n.next();e.setSrc(t.src),e.setOpts({title:t.title}),e.once("canplay",()=>e.togglePlay(!0))}hide_recommendations(e){e.root.classList.remove("is-endscreen","is-grid","is-up-next");const t=i(e,"flowplayer-endscreen-interstitial");t&&c(t,"recommendations:hide")}}return Endscreen.events={RECOMMENDATIONS_RENDER:"recommendations:render",RECOMMENDATIONS_READY:"recommendationsready",RECOMMENDATIONS_HIDE:"recommendations:hide"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,Endscreen)}));
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.float_on_scroll=t())}(this,(function(){"use strict";const e="float:pop:in";var t=Object.freeze({__proto__:null,POP_IN:e,POP_OUT:"float:pop:out"});const n=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const o=window.customElements.get(t);if(!o)throw new Error(`no default flowplayer component with the name ${t} exists`);const l=window.customElements.get(n);return"function"!=typeof l?o:l})(e._customElements,t))(e),o=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)};function l(e){return function(e){const t=e.getBoundingClientRect(),n=window.innerHeight,o=t.y;return o>n||o+t.height<0?0:t.y<0?(t.height+o)/t.height:n-t.y>t.height?1:Math.abs((n-t.y)/t.height)}(e)>.8}function s(t,n,o){0!=o.reaper&&o.floating&&i(o,n,e)}function i(t,n,o){o&&t.emit(o),setTimeout((function(){const l=n.querySelector(".fp-float-wrapper"),s=n.clientWidth/n.clientHeight;if(!l)return;l.style.height=o===e?"auto":l.clientWidth/s+"px";const i=l.querySelector(".fp-ad-container > div");i&&(i.style.position=o==e?"absolute":"static"),t.emit("resize")}))}class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const r={translation_key:"core.mute",name:"fp-mute"},a={translation_key:"core.mute",name:"fp-unmute"},c={translation_key:"core.close",name:"fp-close"};class FloatOnScroll{constructor(e){this.flowplayer=e,o(this.flowplayer,"flowplayer-mute-icon",class extends FlowplayerIcon{constructor(e){super(e,r)}}),o(this.flowplayer,"flowplayer-unmute-icon",class extends FlowplayerIcon{constructor(e){super(e,a)}}),o(this.flowplayer,"flowplayer-close-icon",class extends FlowplayerIcon{constructor(e){super(e,c)}})}init(t,o,r){var a;if(t.multiplay||!1===t.float_on_scroll)return;if(function(){try{return window.self!==window.top}catch(e){return!0}}())return console.warn("iframe detected - floating player not supported in iframe");t.float_on_scroll="object"!=typeof t.float_on_scroll?{}:t.float_on_scroll,t.autopause&&r.setOpts({autopause:!1});const c={pop_out_container:(null===(a=t.float_on_scroll)||void 0===a?void 0:a.container)||function(e,t){const n=document.createElement("div");return n.classList.add("fp-float-wrapper"),e.appendChild(n),Array.from(e.childNodes).forEach((function(e){e instanceof Element&&(e===n||e.classList.contains("fp-ratio"))||n.appendChild(e)})),setTimeout(()=>{const t=e.querySelector("flowplayer-ad-ui");t&&n.appendChild(t)},0),t.getFullsceenTarget=()=>n,n}(o,r),was_user_toggled:!1};r.on("renderplugin",(function(e){e.preventDefault(),e.detail&&c.pop_out_container.append(e.detail)}));const u=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(r,"flowplayer-header");u&&function(e,t,o,l){const i=document.createElement("div");i.classList.add("fp-exit-float"),i.append(Object.assign(n(l,"flowplayer-close-icon"),{role:"button"}));const r=()=>{t.was_user_toggled=!0,l.togglePlay(!1),s(0,o,l)};i.addEventListener("click",r),e.append(i),setTimeout(()=>{const e=o.querySelector(".fp-ad-controls");if(!e)return;const t=i.cloneNode(!0);e.append(t),t.addEventListener("click",r)},0);const a=document.createElement("div");a.classList.add("fp-mute-float"),a.append(...Object.assign([n(l,"flowplayer-mute-icon"),n(l,"flowplayer-unmute-icon")],{role:"button"})),a.addEventListener("click",(function(){l.toggleMute()})),e.append(a)}(u,c,o,r);const f=function(e,t){const n=e||60,o=Math.ceil(1e3/n);let l=Date.now(),s=-1;return function(...e){return s>-1||Date.now()<l||(s=requestAnimationFrame((function(){s=-1,t(),l=Date.now()+o}))),s}}(0,(function(){if(l(o)){if(r.hasState("is-fullscreen"))return;s(0,o,r)}})),p=function(){i(r,o)};r.on("viewleave",e=>{(function(e){return!e.paused||!(!e.ads||!e.ads.adPlaying)})(r)&&!c.was_user_toggled&&(e.preventDefault(),function(e,t,n){0==n.reaper||n.floating||i(n,t,"float:pop:out")}(0,o,r))}),r.on("viewenter",(function(){c.was_user_toggled=!1})),r.on("float:pop:out",(function(){window.addEventListener("scroll",f),r.floating=!0,r.setState("is-popped-out",!0),window.addEventListener("resize",p)})),r.on(e,(function(){window.removeEventListener("scroll",f),r.floating=!1,r.setState("is-popped-out",!1),window.removeEventListener("resize",p)}))}}return FloatOnScroll.events=t,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,FloatOnScroll)}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.float_on_scroll=t())}(this,(function(){"use strict";const e="float:pop:in";var t=Object.freeze({__proto__:null,POP_IN:e,POP_OUT:"float:pop:out"});const n=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const o=window.customElements.get(t);if(!o)throw new Error(`no default flowplayer component with the name ${t} exists`);const i=window.customElements.get(n);return"function"!=typeof i?o:i})(e._customElements,t))(e),o=(e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)};function i(e){return function(e){const t=e.getBoundingClientRect(),n=window.innerHeight,o=t.y;return o>n||o+t.height<0?0:t.y<0?(t.height+o)/t.height:n-t.y>t.height?1:Math.abs((n-t.y)/t.height)}(e)>.8}function s(t,n,o){0!=o.reaper&&o.floating&&r(o,n,e)}function r(t,n,o){o&&t.emit(o),setTimeout((function(){const i=n.querySelector(".fp-float-wrapper"),s=n.clientWidth/n.clientHeight;if(!i)return;i.style.height=o===e?"auto":i.clientWidth/s+"px";const r=i.querySelector(".fp-ad-container > div");r&&(r.style.position=o==e?"absolute":"static"),t.emit("resize")}))}class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}class FlowplayerIcon extends FlowplayerComponent{constructor(e,t){super(e),this.classList.add("fp-icon",t.name),t.title&&this.setAttribute("title",t.title),t.title&&this.setAttribute("aria-label",t.title),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const l={translation_key:"core.mute",name:"fp-mute"},a={translation_key:"core.mute",name:"fp-unmute"},c={translation_key:"core.close",name:"fp-close"};class FloatOnScroll{constructor(e){this.flowplayer=e,o(this.flowplayer,"flowplayer-mute-icon",class extends FlowplayerIcon{constructor(e){super(e,l)}}),o(this.flowplayer,"flowplayer-unmute-icon",class extends FlowplayerIcon{constructor(e){super(e,a)}}),o(this.flowplayer,"flowplayer-close-icon",class extends FlowplayerIcon{constructor(e){super(e,c)}})}init(t,o,l){if(t.multiplay||!1===t.float_on_scroll)return;if(function(){try{return window.self!==window.top}catch(e){return!0}}())return console.warn("iframe detected - floating player not supported in iframe");t.autopause&&l.setOpts({autopause:!1});const a={pop_out_container:void 0,was_user_toggled:!1};l.on("mount",(function(){a.pop_out_container=function(e,t){const n=document.createElement("div");return n.classList.add("fp-float-wrapper"),e.appendChild(n),Array.from(e.childNodes).forEach((function(e){e instanceof Element&&(e===n||e.classList.contains("fp-ratio"))||n.appendChild(e)})),t.getFullsceenTarget=()=>n,n}(o,l)})),l.on("renderplugin",(function(e){var t;e.preventDefault(),e.detail&&(null===(t=a.pop_out_container)||void 0===t||t.append(e.detail))}));const c=function(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}(l,"flowplayer-header");c&&function(e,t,o,i){const r=document.createElement("div");r.classList.add("fp-exit-float"),r.append(Object.assign(n(i,"flowplayer-close-icon"),{role:"button"}));const l=()=>{t.was_user_toggled=!0,i.togglePlay(!1),s(0,o,i)};r.addEventListener("click",l),e.append(r),setTimeout(()=>{const e=o.querySelector(".fp-ad-controls");if(!e)return;const t=r.cloneNode(!0);e.append(t),t.addEventListener("click",l)},0);const a=document.createElement("div");a.classList.add("fp-mute-float"),a.append(...Object.assign([n(i,"flowplayer-mute-icon"),n(i,"flowplayer-unmute-icon")],{role:"button"})),a.addEventListener("click",(function(){i.toggleMute()})),e.append(a)}(c,a,o,l);const u=function(e,t){const n=e||60,o=Math.ceil(1e3/n);let i=Date.now(),s=-1;return function(...e){return s>-1||Date.now()<i||(s=requestAnimationFrame((function(){s=-1,t(),i=Date.now()+o}))),s}}(0,(function(){if(i(o)){if(l.hasState("is-fullscreen"))return;s(0,o,l)}})),p=function(){r(l,o)};l.on("viewleave",e=>{(function(e){return!e.paused||!(!e.ads||!e.ads.adPlaying)})(l)&&!a.was_user_toggled&&(e.preventDefault(),function(e,t,n){0==n.reaper||n.floating||r(n,t,"float:pop:out")}(0,o,l))}),l.on("viewenter",(function(){a.was_user_toggled=!1})),l.on("float:pop:out",(function(){window.addEventListener("scroll",u),l.floating=!0,l.setState("is-popped-out",!0),window.addEventListener("resize",p)})),l.on(e,(function(){window.removeEventListener("scroll",u),l.floating=!1,l.setState("is-popped-out",!1),window.removeEventListener("resize",p)}))}}return FloatOnScroll.events=t,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;return"function"==typeof n?(n(t),t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t),t)}(window,FloatOnScroll)}));
package/plugins/health.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.health=t())}(this,(function(){"use strict";const e="rebuffer";var t=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:e});const n="load",i="fullscreenenter",o="fullscreenexit",s="loadedmetadata",r="loadeddata",a="progress",d="loadstart",c="pause",l="playing",u="waiting",_="canplay",h="ended",f="seeked",p="seeking";function v(e){try{return!!new URL(e)}catch(e){return!1}}function E(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(i,...o)=>{const s=(null==t?void 0:t.debug)||n;s&&e.match(s)&&console.log(`${e} -- ${i}`,...o)};return i.log=i,i}const m=navigator;function g(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=m.connection)||void 0===n?void 0:n.downlink)||-1}function y(e,t){return function(e,t){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(e,t)}(e,JSON.stringify({events:t}))}const R="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),O=window,I=O._flowplayerTimekeeper||(O._flowplayerTimekeeper={});var w;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(w||(w={}));const D=e=>{switch(e){case!0:return w.ON;case!1:return w.OFF;default:return e}},N=[];function T(e){if(e.suspended)return;const t=N.slice(0);N.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),y("https://ihi.flowplayer.com/v1/health/events",t))}async function A(e,t,n){const i=await S();N.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),N.length<10&&!n||T(e)}const b=()=>{var e,t;try{const n=window;return null===(t=null===(e=null==n?void 0:n.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},S=async()=>{const e=Date.now();try{return{adjusted_time:e-await async function(){const e=I.cachedServerOffset;if(e)return e;const t=I.pendingRequest||(I.pendingRequest=fetch(R)),n=await t,i=parseInt(n.headers.get("age")||"0"),o=await n.json(),s=Date.now()-o.millisUtc-1e3*i;return I.cachedServerOffset=s,I.cachedServerOffset}(),client_time:e}}catch(t){return{client_time:e}}},U=(e,t)=>Object.assign(e,{detail:t}),k=(e,{event:t,media_session_id:n,session_id:i})=>({event:t,media_session_id:n,session_id:i,device_id:e.deviceId(),version:"3.2.8",commit:"7e733a5ef06816f5a96f8e27c1ef7927fc55599b",ima_sdk_version:b(),preload:e.opt("preload"),autoplay:D(e.opt("autoplay")),live:e.opt("live"),dvr:!!e.live_state.dvr,source:e.original_src,downlink_mbs:g(e),player_id:e.opt("metadata.player_id"),media_id:e.opt("metadata.media_id"),site_id:e.opt("metadata.site_id"),category_id:e.opt("metadata.category_id"),sitegroup_id:e.opt("metadata.sitegroup_id"),token:e.token,plugins:e.plugins.map(e=>e.constructor.name).sort((e,t)=>e.localeCompare(t)),current_time:e.currentTime,external_media_id:e.opt("external_media_id")}),C=e=>({bitrate:null==e?void 0:e.bitrate,resolution:null==e?void 0:e.attrs.RESOLUTION,frame_rate:null==e?void 0:e.attrs["FRAME-RATE"]});function L(e,t,n,i){const o=k(t,e.eventInfo(n)),{before:s,after:r}=i;A(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,C(s),C(r)))}const M=[1e7]+""+-1e3+-4e3+-8e3+-1e11,B=()=>"undefined"==typeof crypto?"":M.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var x;function F(e){switch(e){case x.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case x.MEDIA_ERR_NETWORK:return"a network error occurred";case x.MEDIA_ERR_DECODE:return"unable to decode media content";case x.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case x.NO_INTERNET:return"no internet connection detected";case x.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",e[e.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",e[e.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",e[e.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",e[e.MIXED_CONTENT=1001]="MIXED_CONTENT",e[e.NO_INTERNET=1002]="NO_INTERNET"}(x||(x={}));const j=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}},H=B();class Health{constructor(e,t){this.session_id=H,this.suspended=!1,this.logger=E("health",t.opts),this.media_session_id=B(),this.analyticsLoop=setInterval(()=>T(this),2e3),t.on("reap",()=>clearInterval(this.analyticsLoop));const n=this;if(t.health={get media_session_id(){return n.media_session_id},set media_session_id(e){n.media_session_id=e},get session_id(){return n.session_id},set session_id(e){n.session_id=e},toggle(e){e?n.resume():n.suspend()}},!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=t=>e.instances.forEach(e=>e.emit(t.type));document.addEventListener("visibilitychange",e=>{"hidden"==document.visibilityState&&t(e)}),window.addEventListener("pagehide",t)}}eventInfo(e){return{event:e,media_session_id:this.media_session_id,session_id:this.session_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>T(this),2e3)}init(t,E,m){!function(t){t.on(u,(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(e)}))}(m),m.on("health:record",({detail:e})=>{const t=k(m,this.eventInfo(e.event));Object.assign(t,e.detail||{}),A(this,t)}),[_,d,n,s,r,a,u,e].forEach(e=>{m.on(e,e=>{A(this,k(m,this.eventInfo(e.type)))})}),[l,c,p,f,h,i,o].forEach(e=>{m.on(e,e=>{A(this,k(m,this.eventInfo(e.type)))})}),m.on("volumechange",j(800,e=>{const t=k(m,this.eventInfo(e.type));A(this,U(t,{volume:parseFloat(m.volume.toFixed(2)),muted:m.muted}))})),m.on("resize",j(800,e=>{const t=k(m,this.eventInfo(e.type));A(this,U(t,{height:E.clientHeight,width:E.clientWidth}))})),m.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return L(this,m,e,t)}});let g=Date.now()+5e3;m.on("timeupdate",e=>{if(Date.now()<g)return;g=Date.now()+5e3;const t=k(m,this.eventInfo(e.type));var n;A(this,U(t,{duration:(n=m.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),m.addEventListener("error",e=>{const t=k(m,this.eventInfo(e.type)),n=e.error||m.error;if(!n)return A(this,t,!0);const i=n.code,o={error_message:n.message||F(i),error_code:i,error_stack:n.stack||""};return A(this,U(t,o),!0)}),m.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!v(m.original_src))return;if(!v(n))return;if(n==m.original_src)return;this.media_session_id=B();A(this,k(m,this.eventInfo(e.type))),T(this)}),m.on("visibilitychange",e=>{A(this,k(m,this.eventInfo(e.type))),T(this)})}}return Health.events=t,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Health),Health}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).flowplayer=e.flowplayer||{},e.flowplayer.health=t())}(this,(function(){"use strict";const e="rebuffer";var t=Object.freeze({__proto__:null,RECORD:"health:record",REBUFFER:e});const n="load",i="fullscreenenter",o="fullscreenexit",s="loadedmetadata",r="loadeddata",a="progress",d="loadstart",c="pause",l="playing",u="waiting",_="canplay",h="ended",f="seeked",p="seeking";function v(e){try{return!!new URL(e)}catch(e){return!1}}function E(e,t){const n=function(){try{return localStorage.getItem("flowplayer/debug")}catch(e){return""}}(),i=(i,...o)=>{const s=(null==t?void 0:t.debug)||n;s&&e.match(s)&&console.log(`flowplayer/${e} -- ${i}`,...o)};return i.log=i,i}const m=navigator;function g(e){var t,n;const i=null===(t=e.hls)||void 0===t?void 0:t.bandwidthEstimate;return i?1e-6*i:(null===(n=m.connection)||void 0===n?void 0:n.downlink)||-1}function y(e,t){return function(e,t){return"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(e,t)}(e,JSON.stringify({events:t}))}const R="https://ljsp.lwcdn.com".concat("/web/public/countdown/time.json"),O=window,I=O._flowplayerTimekeeper||(O._flowplayerTimekeeper={});var w;!function(e){e[e.OFF=0]="OFF",e[e.ON=1]="ON",e[e.AUDIO_REQUIRED=2]="AUDIO_REQUIRED"}(w||(w={}));const D=e=>{switch(e){case!0:return w.ON;case!1:return w.OFF;default:return e}},N=[];function T(e){if(e.suspended)return;const t=N.slice(0);N.length=0,0!=t.length&&(e.logger.log(`:dispatch events={${t.length}}`),y("https://ihi.flowplayer.com/v1/health/events",t))}async function A(e,t,n){const i=await S();N.push(Object.assign(t,i)),e.logger.log(":enqueue",t.event,t),N.length<10&&!n||T(e)}const b=()=>{var e,t;try{const n=window;return null===(t=null===(e=null==n?void 0:n.google)||void 0===e?void 0:e.ima)||void 0===t?void 0:t.VERSION}catch(e){return}},S=async()=>{const e=Date.now();try{return{adjusted_time:e-await async function(){const e=I.cachedServerOffset;if(e)return e;const t=I.pendingRequest||(I.pendingRequest=fetch(R)),n=await t,i=parseInt(n.headers.get("age")||"0"),o=await n.json(),s=Date.now()-o.millisUtc-1e3*i;return I.cachedServerOffset=s,I.cachedServerOffset}(),client_time:e}}catch(t){return{client_time:e}}},U=(e,t)=>Object.assign(e,{detail:t}),k=(e,{event:t,media_session_id:n,session_id:i})=>({event:t,media_session_id:n,session_id:i,device_id:e.deviceId(),version:"3.3.0",commit:"f9e32e728579b258d7c7eecf7455ed00fb67189f",ima_sdk_version:b(),preload:e.opt("preload"),autoplay:D(e.opt("autoplay")),live:e.opt("live"),dvr:!!e.live_state.dvr,source:e.original_src,downlink_mbs:g(e),player_id:e.opt("metadata.player_id"),media_id:e.opt("metadata.media_id"),site_id:e.opt("metadata.site_id"),category_id:e.opt("metadata.category_id"),sitegroup_id:e.opt("metadata.sitegroup_id"),token:e.token,plugins:e.plugins.map(e=>e.constructor.name).sort((e,t)=>e.localeCompare(t)),current_time:e.currentTime,external_media_id:e.opt("external_media_id")}),C=e=>({bitrate:null==e?void 0:e.bitrate,resolution:null==e?void 0:e.attrs.RESOLUTION,frame_rate:null==e?void 0:e.attrs["FRAME-RATE"]});function L(e,t,n,i){const o=k(t,e.eventInfo(n)),{before:s,after:r}=i;A(e,((e,t,n)=>Object.assign(e,{state:{before:t,after:n}}))(o,C(s),C(r)))}const M=[1e7]+""+-1e3+-4e3+-8e3+-1e11,B=()=>"undefined"==typeof crypto?"":M.replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16));var x;function F(e){switch(e){case x.MEDIA_PLAYBACK_ABORTED:return"media playback was aborted";case x.MEDIA_ERR_NETWORK:return"a network error occurred";case x.MEDIA_ERR_DECODE:return"unable to decode media content";case x.MEDIA_ERR_SRC_NOT_SUPPORTED:return"unsupported media type";case x.NO_INTERNET:return"no internet connection detected";case x.MIXED_CONTENT:return"cannot load insecure content in a secure context";default:return"an unknown error occurred"}}!function(e){e[e.UNKNOWN=-1]="UNKNOWN",e[e.MEDIA_PLAYBACK_ABORTED=1]="MEDIA_PLAYBACK_ABORTED",e[e.MEDIA_ERR_NETWORK=2]="MEDIA_ERR_NETWORK",e[e.MEDIA_ERR_DECODE=3]="MEDIA_ERR_DECODE",e[e.MEDIA_ERR_SRC_NOT_SUPPORTED=4]="MEDIA_ERR_SRC_NOT_SUPPORTED",e[e.MIXED_CONTENT=1001]="MIXED_CONTENT",e[e.NO_INTERNET=1002]="NO_INTERNET"}(x||(x={}));const j=(e,t)=>{let n=null;return(...i)=>{null!==n&&(clearTimeout(n),n=null),n=setTimeout(()=>t(...i),e)}},H=B();class Health{constructor(e,t){this.session_id=H,this.suspended=!1,this.logger=E("health",t.opts),this.media_session_id=B(),this.analyticsLoop=setInterval(()=>T(this),2e3),t.on("reap",()=>clearInterval(this.analyticsLoop));const n=this;if(t.health={get media_session_id(){return n.media_session_id},set media_session_id(e){n.media_session_id=e},get session_id(){return n.session_id},set session_id(e){n.session_id=e},toggle(e){e?n.resume():n.suspend()}},!Health._UNLOAD_SUBSCRIBED){Health._UNLOAD_SUBSCRIBED=!0;const t=t=>e.instances.forEach(e=>e.emit(t.type));document.addEventListener("visibilitychange",e=>{"hidden"==document.visibilityState&&t(e)}),window.addEventListener("pagehide",t)}}eventInfo(e){return{event:e,media_session_id:this.media_session_id,session_id:this.session_id}}suspend(){this.suspended=!0,clearInterval(this.analyticsLoop)}resume(){this.suspended=!1,this.analyticsLoop=setInterval(()=>T(this),2e3)}init(t,E,m){!function(t){t.on(u,(function(n){t.seeking||t.networkState===t.NETWORK_LOADING&&t.readyState!==t.HAVE_NOTHING&&t.emit(e)}))}(m),m.on("health:record",({detail:e})=>{const t=k(m,this.eventInfo(e.event));Object.assign(t,e.detail||{}),A(this,t)}),[_,d,n,s,r,a,u,e].forEach(e=>{m.on(e,e=>{A(this,k(m,this.eventInfo(e.type)))})}),[l,c,p,f,h,i,o].forEach(e=>{m.on(e,e=>{A(this,k(m,this.eventInfo(e.type)))})}),m.on("volumechange",j(800,e=>{const t=k(m,this.eventInfo(e.type));A(this,U(t,{volume:parseFloat(m.volume.toFixed(2)),muted:m.muted}))})),m.on("resize",j(800,e=>{const t=k(m,this.eventInfo(e.type));A(this,U(t,{height:E.clientHeight,width:E.clientWidth}))})),m.on("qualitychange",({type:e,detail:t})=>{switch(t.kind){case"hls":return L(this,m,e,t)}});let g=Date.now()+5e3;m.on("timeupdate",e=>{if(Date.now()<g)return;g=Date.now()+5e3;const t=k(m,this.eventInfo(e.type));var n;A(this,U(t,{duration:(n=m.duration,Number.isFinite(n)?n:n===1/0?-1:void 0)}))}),m.addEventListener("error",e=>{const t=k(m,this.eventInfo(e.type)),n=e.error||m.error;if(!n)return A(this,t,!0);const i=n.code,o={error_message:n.message||F(i),error_code:i,error_stack:n.stack||""};return A(this,U(t,o),!0)}),m.on("src",e=>{var t;const n=null===(t=e.detail)||void 0===t?void 0:t.src;if("string"!=typeof n)return;if(!v(m.original_src))return;if(!v(n))return;if(n==m.original_src)return;this.media_session_id=B();A(this,k(m,this.eventInfo(e.type))),T(this)}),m.on("visibilitychange",e=>{A(this,k(m,this.eventInfo(e.type))),T(this)})}}return Health.events=t,Health._UNLOAD_SUBSCRIBED=!1,function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;"flowplayer"in e||(e.flowplayer={extensions:[]});const n=e.flowplayer;"function"==typeof n?n(t):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(t)||n.extensions.push(t))}(window,Health),Health}));