@flowplayer/player 3.5.2 → 3.5.3

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.subtitles=t())}(this,(function(){"use strict";function e(e,t,n){const i=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;i.length;){if(null==e)return n;const t=i.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}function t(e,t){e.innerHTML="",t.forEach((function(t){const n=document.createElement("pre");n.classList.add("fp-cue"),function(e,t){const n=e.style,i=t.size;n.setProperty("--caption-size",i.toString());const s=t.position;s&&"auto"!==s&&t?n.setProperty("--caption-position",s.toString()):n.removeProperty("--caption-position");const o="captions-align-"+t.align;Array.from(e.classList).forEach((function(n){n!=o&&("captions-vertical"==n&&t.vertical||n.startsWith("captions")&&e.classList.remove(n))})),e.classList.add(o),e.classList.toggle("captions-vertical",!!t.vertical)}(e,t),n.appendChild(t.getCueAsHTML()),e.appendChild(n)}))}function n(){}var i;function s(e,t){if(function(e){return Object.values(i).includes(e)}(t=t||i.Anonymous))return e instanceof HTMLVideoElement&&(e.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in e?e.crossOrigin=t:e.setAttribute("crossorigin",t),e}function o(e){const t=document.createElement("a");return t.href=e,t.origin}function r(e,t){const i=document.createElement("track");i.className="fp-track renderable",i.kind=t.kind||"captions",i.label=t.label||t.lang||"",i.lang=t.lang||"",i.id=["fp",t.lang].join("-");const r=i.track;return r.removeCue=n,"string"!=typeof t.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),o(e.src)!==o(t)}catch(e){return console.error(e),!0}}(e,t.src)&&(s(e),t.crossorigin=e.getAttribute("crossorigin")),"crossorigin"in t&&s(e,t.crossorigin),Object.keys(t).forEach(e=>{"default"!==e&&(i[e]=t[e])}),r.mode=t.default?"hidden":"disabled",i.onload=function(){},r.oncuechange=function(t){e.emit(t.type,{track:t.target})},e.appendChild(i),i}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(i||(i={}));const l="is-source-processing",a=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const i=window.customElements.get(t);if(!i)throw new Error(`no default flowplayer component with the name ${t} exists`);const s=window.customElements.get(n);return"function"!=typeof s?i:s})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const c="fp-on",u="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.olEle.id=m(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menu.classList.add("fp-menu"),this.menu.append(this.closeEle,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",t=>{t.preventDefault();const n=this.menuContainer.open;n||(d(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,e.root.classList.toggle("has-menu-opened",!n),this.olEle.setAttribute("aria-expanded",n?"false":"true")}),this.append(this.menuContainer),this.summaryEle.setAttribute("aria-haspopup","true"),this.summaryEle.setAttribute("aria-controls",this.olEle.id),this.summaryEle.setAttribute("tabindex","0"),this.summaryEle.setAttribute("role","button")}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.summaryEle.id||(this.summaryEle.id=e.id||m()),this.className=e.class,this.menuContainer.classList.add("fp-menu-container"),this.toggle_visibility(!0),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=a(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}if(e.menuTitle){const t=document.createElement("h3");t.textContent=e.menuTitle,this.menu.prepend(t)}this.menu.classList.toggle("fp-icons",!!e.icons),this.addEventListener(e.options_event,e=>{this.render(e.data)}),e.item_selected_event&&this.addEventListener(e.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.toggle_visibility(!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("role","menuitem"),n.setAttribute("tabindex","0"),e.icon&&n.append(e.icon);const i=document.createElement("span");i.textContent=e.text,n.append(i),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n)}select_item(e){this.options.forEach((t,n)=>{t.classList.toggle(c,n===e&&("flowplayer-subtitles-menu"!==this.localName||!t.classList.contains(c)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(c)})}toggle_visibility(e){this.classList.toggle(u,e),this.menu.style.setProperty("display",e?"none":"block")}}function d(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function m(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function f(e,t,n){const i=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(i),e}function p(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(d(),this.active_menu=void 0)})),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 FlowplayerSubtitlesMenu extends FlowplayerMenu{constructor(e){super(e),e.on(Subtitles.events.TRACK_UPDATED,e=>this.summaryEle.classList.toggle("fp-color-text",!!e.detail))}}class Subtitles{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-subtitles-menu",FlowplayerSubtitlesMenu)}init(i,s,o){const c=a(o,"flowplayer-subtitles-menu");c instanceof FlowplayerMenu&&c.setMenuAttrs({class:"fp-cc",summaryTitle:o.i18n("cc.button","CC"),menuTitle:o.i18n("cc.menu_title","Subtitles"),options_event:Subtitles.events.TRACKS,item_selected_event:Subtitles.events.SWITCH});const u=function(e){const t=document.createElement("div");return t.classList.add("fp-captions"),t.ontouchend=t=>e.emit(t.type),t.onclick=t=>e.emit(t.type),t}(o);let d,m,h=[],y=[];function b(){return Array.from(o.textTracks).filter(e=>~["captions","subtitles","descriptions"].indexOf(e.kind)&&!e.removed&&e.label)}function g(e){Array.from(e.querySelectorAll("track")).forEach(t=>{["captions","subtitles","descriptions"].includes(t.kind)&&e.removeChild(t)})}function v(e,t,n){if(f(t,Subtitles.events.TRACKS,n.map((function(t){return{text:t.label,onclick:E.bind(0,e,t)}}))),d)return b().find(e=>e===d)?void f(t,Subtitles.events.SWITCH,{selected_index:n.indexOf(d)}):A()}function E(e,t){if(t==d)return A();A(),t.is_hls_embedded&&"number"==typeof t.track_id&&e.hls&&(e.hls.subtitleTrack=t.track_id),t.mode="hidden",d=t,e.emit("cuechange",{track:t}),e.emit("tracks:text:updated",d)}function A(){d&&(o.emit("tracks:text:updated"),d.mode="disabled",d=void 0,t(u,[]))}!function(e){if(!function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",n=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),i=/Android/.test(t)&&!/Firefox/.test(t),s=/^((?!chrome|android).)*safari/i.test(t),o=/SamsungBrowser/.test(t),r=o&&/SMART-TV/.test(t);return{controls:!n,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:i,iphone:n,safari:s,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:o,samsung_tv:o&&r,touch:"ontouchstart"in window,tizen:"tizen"in window,webOS:"webos"in window}}().ios)return;e.on("webkitbeginfullscreen",()=>{d&&(d.mode="showing")}),e.on("webkitendfullscreen",()=>{const t=y.find(e=>"showing"===e.mode);if(t&&(t.mode="hidden"),t!==d){if(!t)return A();E(e,t),f(c,Subtitles.events.SWITCH,{selected_index:y.indexOf(t)})}})}(o),o.on("mount",(function(){var e,t;const n=p(o,"flowplayer-control");if(!n)return null===(e=p(o,"flowplayer-ui"))||void 0===e?void 0:e.appendChild(u);n.insertAdjacentElement("beforebegin",u),null===(t=o.hasState("is-tv")?p(o,"flowplayer-tv-menu"):n)||void 0===t||t.append(c)})),o.on("config",(function(e){var t,n;const i=null===(n=null===(t=e.data)||void 0===t?void 0:t.subtitles)||void 0===n?void 0:n.tracks;i&&h!==i&&(h=i,g(o),y=b(),v(o,c,y),h.forEach(e=>r(o,e)))})),o.on("tracks:text:all",e=>{const t=e.detail.subtitleTracks;t!==m&&(m=t,y=y.flatMap(e=>e.is_hls_embedded?(e.removed=!0,[]):e),v(o,c,y),t.filter(e=>~["SUBTITLES","CLOSED-CAPTIONS"].indexOf(e.type)).forEach(e=>{const t=o.addTextTrack("CLOSED-CAPTIONS"===e.type?"captions":"subtitles",e.name,e.lang);t.is_hls_embedded=!0,t.default=e.default,t.track_id=e.id,t.mode=e.default?"hidden":"disabled",t.removeCue=n}))}),o.on("cues:parsed",e=>{const t=e.detail,n=y.find(e=>e.is_hls_embedded&&!e.removed&&(e.default&&"default"===t.track||"subtitles"+e.track_id===t.track));n&&t.cues.forEach(e=>n.addCue(e))}),o.textTracks.addEventListener("addtrack",()=>{const e=b();if(y.length===e.length&&y.every((t,n)=>t===e[n]))return;let t=d;if(e.map((function(e){return~["showing","hidden"].indexOf(e.mode)&&(t="hidden"===e.mode&&e!==d?e:t,e.mode="disabled"),e.oncuechange=e.oncuechange||function(e){o.emit(e.type,{track:e.target})},e})),f(c,Subtitles.events.TRACKS,e.map((function(e){return{text:e.label,onclick:E.bind(0,o,e)}}))),y=e,d=void 0,!t)return A();E(o,t),f(c,Subtitles.events.SWITCH,{selected_index:y.indexOf(t)})}),o.on("cuechange",(function(n){var i;const s=null===(i=n.data)||void 0===i?void 0:i.track;if(!s||!["captions","subtitles","descriptions"].includes(s.kind))return;const o=Array.from(e(s,"activeCues",[])).filter((e,t,n)=>t===n.findIndex(t=>e.id===t.id)).sort((e,t)=>"number"!=typeof e.line||"number"!=typeof t.line?0:e.line-t.line);t(u,o)})),o.on(["playlist/advance","src"],e=>{o.currentSrc&&("src"===e.type&&["is-playlist",l].some(e=>o.root.classList.contains(e))||(delete o.opts.subtitles,g(o),h=[],A(),y=[],m=[],b().forEach(e=>e.removed=!0),f(c,Subtitles.events.TRACKS,[])))})}}return Subtitles.events={TRACKS:"subs:tracks",SWITCH:"subs:change",TRACK_UPDATED:"tracks:text:updated"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)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,Subtitles),Subtitles}));
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.subtitles=t())}(this,(function(){"use strict";function e(e,t,n){const i=function(e){return Array.isArray(e)?e.slice(0):e.split(".")}(t);for(;i.length;){if(null==e)return n;const t=i.shift();if("string"!=typeof t)return n;e=e[t]}return null==e?n:e}function t(e,t){e.innerHTML="",t.forEach((function(t){const n=document.createElement("pre");n.classList.add("fp-cue"),function(e,t){const n=e.style,i=t.size;n.setProperty("--caption-size",i.toString());const s=t.position;s&&"auto"!==s&&t?n.setProperty("--caption-position",s.toString()):n.removeProperty("--caption-position");const o="captions-align-"+t.align;Array.from(e.classList).forEach((function(n){n!=o&&("captions-vertical"==n&&t.vertical||n.startsWith("captions")&&e.classList.remove(n))})),e.classList.add(o),e.classList.toggle("captions-vertical",!!t.vertical)}(e,t),n.appendChild(t.getCueAsHTML()),e.appendChild(n)}))}function n(){}var i;function s(e,t){if(function(e){return Object.values(i).includes(e)}(t=t||i.Anonymous))return e instanceof HTMLVideoElement&&(e.poster="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII="),"crossOrigin"in e?e.crossOrigin=t:e.setAttribute("crossorigin",t),e}function o(e){const t=document.createElement("a");return t.href=e,t.origin}function r(e,t){const i=document.createElement("track");i.className="fp-track renderable",i.kind=t.kind||"captions",i.label=t.label||t.lang||"",i.lang=t.lang||"",i.id=["fp",t.lang].join("-");const r=i.track;return r.removeCue=n,"string"!=typeof t.crossorigin&&function(e,t){try{return e.src.startsWith("blob:"),o(e.src)!==o(t)}catch(e){return console.error(e),!0}}(e,t.src)&&(s(e),t.crossorigin=e.getAttribute("crossorigin")),"crossorigin"in t&&s(e,t.crossorigin),Object.keys(t).forEach(e=>{"default"!==e&&(i[e]=t[e])}),r.mode=t.default?"hidden":"disabled",i.onload=function(){},r.oncuechange=function(t){e.emit(t.type,{track:t.target})},e.appendChild(i),i}!function(e){e.Anonymous="anonymous",e.UseCredentials="use-credentials",e.Empty=""}(i||(i={}));const l="is-source-processing",a=(e,t)=>new(((e,t)=>{const n=e.get(t);if(!n)throw new Error(`no flowplayer component with the name ${t} exists`);const i=window.customElements.get(t);if(!i)throw new Error(`no default flowplayer component with the name ${t} exists`);const s=window.customElements.get(n);return"function"!=typeof s?i:s})(e._customElements,t))(e);class FlowplayerComponent extends HTMLElement{constructor(e){super(),this.player=e}}const c="fp-on",u="fp-invis";class FlowplayerMenu extends FlowplayerComponent{constructor(e){super(e),this.player=e,this.menuContainer=document.createElement("details"),this.summaryEle=document.createElement("summary"),this.olEle=document.createElement("ol"),this.olEle.id=m(),this.menu=document.createElement("div"),this.closeEle=document.createElement("span"),this.menu.classList.add("fp-menu"),this.menu.append(this.closeEle,this.olEle),this.closeEle.classList.add("fp-close"),this.closeEle.textContent="×",this.menuContainer.append(this.summaryEle,this.menu),this.menuContainer.addEventListener("click",t=>{t.preventDefault();const n=this.menuContainer.open;n||(d(),document.active_menu=this.menuContainer),this.menuContainer.open=!n,e.root.classList.toggle("has-menu-opened",!n),this.olEle.setAttribute("aria-expanded",n?"false":"true")}),this.append(this.menuContainer),this.summaryEle.setAttribute("aria-haspopup","true"),this.summaryEle.setAttribute("aria-controls",this.olEle.id),this.summaryEle.setAttribute("tabindex","0"),this.summaryEle.setAttribute("role","button")}get options(){return this.olEle.querySelectorAll("li")}setMenuAttrs(e){if(this.summaryEle.id||(this.summaryEle.id=e.id||m()),this.className=e.class,this.menuContainer.classList.add("fp-menu-container"),this.toggle_visibility(!0),this.olEle.setAttribute("aria-labelledby",this.summaryEle.id),this.olEle.setAttribute("role","menu"),this.summaryEle.setAttribute("aria-label",e.menuTitle||"Menu"),e.summaryTitle&&(this.summaryEle.textContent=e.summaryTitle),e.summaryIcon){const t=a(this.player,e.summaryIcon);t.setAttribute("tabindex",""),this.summaryEle.append(t)}if(e.menuTitle){const t=document.createElement("h3");t.textContent=e.menuTitle,this.menu.prepend(t)}this.menu.classList.toggle("fp-icons",!!e.icons),this.addEventListener(e.options_event,e=>{this.render(e.data)}),e.item_selected_event&&this.addEventListener(e.item_selected_event,e=>{void 0!==e.data&&this.select_item(e.data.selected_index)})}render(e){this.olEle&&(this.olEle.innerHTML="",e&&e.forEach(this.menuOption,this),this.toggle_visibility(!(null==e?void 0:e.length)))}menuOption(e,t){const n=document.createElement("li");n.setAttribute("role","menuitem"),n.setAttribute("tabindex","0"),e.icon&&n.append(e.icon);const i=document.createElement("span");i.textContent=e.text,n.append(i),n.addEventListener("click",()=>{this.select_item(t),"function"==typeof e.onclick&&e.onclick()}),this.olEle.appendChild(n)}select_item(e){this.options.forEach((t,n)=>{t.classList.toggle(c,n===e&&("flowplayer-subtitles-menu"!==this.localName||!t.classList.contains(c)))})}unselect_item(){this.options.forEach(e=>{e.classList.remove(c)})}toggle_visibility(e){this.classList.toggle(u,e),this.menu.style.setProperty("display",e?"none":"block")}}function d(){Array.from(document.querySelectorAll(".fp-engine")).forEach(e=>{var t;const n=e.root.querySelector("details[open].fp-menu-container");n&&(n.open=!1,null===(t=n.querySelector("summary"))||void 0===t||t.removeAttribute("aria-expanded"),e.root.classList.toggle("has-menu-opened",!1))})}function m(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function f(e,t,n){const i=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(i),e}function p(e,t){const n=e._customElements.get(t);return n&&e.root.querySelector(n)||void 0}document.addEventListener("click",(function(e){this.active_menu&&!e.composedPath().includes(this.active_menu)&&(d(),this.active_menu=void 0)})),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 FlowplayerSubtitlesMenu extends FlowplayerMenu{constructor(e){super(e),e.on(Subtitles.events.TRACK_UPDATED,e=>this.summaryEle.classList.toggle("fp-color-text",!!e.detail))}}class Subtitles{constructor(e){((e,t,n)=>{window.customElements.get(t)||window.customElements.define(t,n),e.customElements.get(t)||e.customElements.set(t,t)})(e,"flowplayer-subtitles-menu",FlowplayerSubtitlesMenu)}init(i,s,o){const c=a(o,"flowplayer-subtitles-menu");c instanceof FlowplayerMenu&&c.setMenuAttrs({class:"fp-cc",summaryTitle:o.i18n("cc.button","CC"),menuTitle:o.i18n("cc.menu_title","Subtitles"),options_event:Subtitles.events.TRACKS,item_selected_event:Subtitles.events.SWITCH});const u=function(e){const t=document.createElement("div");return t.classList.add("fp-captions"),t.ontouchend=t=>e.emit(t.type),t.onclick=t=>e.emit(t.type),t}(o);let d,m,h=[],y=[];function b(){return Array.from(o.textTracks).filter(e=>~["captions","subtitles","descriptions"].indexOf(e.kind)&&!e.removed&&e.label)}function v(e){Array.from(e.querySelectorAll("track")).forEach(t=>{["captions","subtitles","descriptions"].includes(t.kind)&&e.removeChild(t)})}function g(e,t,n){if(f(t,Subtitles.events.TRACKS,n.map((function(t){return{text:t.label,onclick:E.bind(0,e,t)}}))),d)return b().find(e=>e===d)?void f(t,Subtitles.events.SWITCH,{selected_index:n.indexOf(d)}):A()}function E(e,t){if(t==d)return A();A(),t.is_hls_embedded&&"number"==typeof t.track_id&&e.hls&&(e.hls.subtitleTrack=t.track_id),t.mode="hidden",d=t,e.emit("cuechange",{track:t}),e.emit("tracks:text:updated",d)}function A(){d&&(o.emit("tracks:text:updated"),d.mode="disabled",d=void 0,t(u,[]))}!function(e){if(!function(){const e="undefined"!=typeof document&&"undefined"!=typeof window,t=e?navigator.userAgent:"",n=/iP(hone|od)/i.test(t)&&!/iPad/.test(t)&&!/IEMobile/i.test(t),i=/Android/.test(t)&&!/Firefox/.test(t),s=/^((?!chrome|android).)*safari/i.test(t),o=/SamsungBrowser/.test(t),r=o&&/SMART-TV/.test(t);return{controls:!n,video:function(t){return e&&document.createElement("video").canPlayType(t)},lang:e&&window.navigator.language,android:i,iphone:n,safari:s,ios:e&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,samsung:o,samsung_tv:o&&r,touch:"ontouchstart"in window,tizen:"tizen"in window,webOS:"webos"in window}}().ios)return;e.on("webkitbeginfullscreen",()=>{d&&(d.mode="showing")}),e.on("webkitendfullscreen",()=>{const t=y.find(e=>"showing"===e.mode);if(t&&(t.mode="hidden"),t!==d){if(!t)return A();E(e,t),f(c,Subtitles.events.SWITCH,{selected_index:y.indexOf(t)})}})}(o),o.on("mount",(function(){var e,t;const n=p(o,"flowplayer-control");if(!n)return null===(e=p(o,"flowplayer-ui"))||void 0===e?void 0:e.appendChild(u);n.insertAdjacentElement("beforebegin",u),null===(t=o.hasState("is-tv")?p(o,"flowplayer-tv-menu"):n)||void 0===t||t.append(c)})),o.on("config",(function(e){var t,n;const i=null===(n=null===(t=e.data)||void 0===t?void 0:t.subtitles)||void 0===n?void 0:n.tracks;i&&h!==i&&(h=i,v(o),y=b(),g(o,c,y),h.forEach(e=>r(o,e)))})),o.on("tracks:text:all",e=>{const t=e.detail.tracks;t!==m&&(m=t,y=y.flatMap(e=>e.is_hls_embedded?(e.removed=!0,[]):e),g(o,c,y),t.filter(e=>~["subtitles","captions"].indexOf(e.kind)).forEach(e=>{var t,i,s;const r=o.addTextTrack("captions"===e.kind?"captions":"subtitles",e.label,null===(t=e.subtitleTrack)||void 0===t?void 0:t.lang);r.is_hls_embedded=!0,r.default=e.default,r.track_id=null!==(s=null===(i=e.subtitleTrack)||void 0===i?void 0:i.id)&&void 0!==s?s:e._id,r.mode=e.default?"hidden":"disabled",r.removeCue=n}))}),o.on("cues:parsed",e=>{const t=e.detail,n=y.find(e=>e.is_hls_embedded&&!e.removed&&(e.default&&"default"===t.track||e.track_id===t.track||"subtitles"+e.track_id===t.track||"captions"+e.track_id===t.track));n&&t.cues.forEach(e=>n.addCue(e))}),o.textTracks.addEventListener("addtrack",()=>{const e=b();if(y.length===e.length&&y.every((t,n)=>t===e[n]))return;let t=d;if(e.map((function(e){return~["showing","hidden"].indexOf(e.mode)&&(t="hidden"===e.mode&&e!==d?e:t,e.mode="disabled"),e.oncuechange=e.oncuechange||function(e){o.emit(e.type,{track:e.target})},e})),f(c,Subtitles.events.TRACKS,e.map((function(e){return{text:e.label,onclick:E.bind(0,o,e)}}))),y=e,d=void 0,!t)return A();E(o,t),f(c,Subtitles.events.SWITCH,{selected_index:y.indexOf(t)})}),o.on("cuechange",(function(n){var i;const s=null===(i=n.data)||void 0===i?void 0:i.track;if(!s||!["captions","subtitles","descriptions"].includes(s.kind))return;const o=Array.from(e(s,"activeCues",[])).filter((e,t,n)=>t===n.findIndex(t=>e.id===t.id)).sort((e,t)=>"number"!=typeof e.line||"number"!=typeof t.line?0:e.line-t.line);t(u,o)})),o.on(["playlist/advance","src"],e=>{o.currentSrc&&("src"===e.type&&["is-playlist",l].some(e=>o.root.classList.contains(e))||(delete o.opts.subtitles,v(o),h=[],A(),y=[],m=[],b().forEach(e=>e.removed=!0),f(c,Subtitles.events.TRACKS,[])))})}}return Subtitles.events={TRACKS:"subs:tracks",SWITCH:"subs:change",TRACK_UPDATED:"tracks:text:updated"},function(e,t){if("object"==typeof exports&&"undefined"!=typeof module)return t;if(null===document.currentScript)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,Subtitles),Subtitles}));