cloudinary-video-player 3.12.1 → 3.12.2-edge.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.
Files changed (86) hide show
  1. package/dist/134.min.js +8 -0
  2. package/dist/309.min.js +6 -0
  3. package/dist/adaptive-streaming.js +9 -9
  4. package/dist/adaptive-streaming.min.js +2 -2
  5. package/dist/chapters.js +4 -4
  6. package/dist/chapters.min.js +3 -3
  7. package/dist/cld-player-core.js +37 -0
  8. package/dist/cld-player-core.min.js +6 -0
  9. package/dist/cld-video-player-lazy.js +494 -0
  10. package/dist/cld-video-player-lazy.min.js +6 -0
  11. package/dist/cld-video-player.css +2 -2
  12. package/dist/cld-video-player.js +366 -332
  13. package/dist/cld-video-player.light.js +366 -332
  14. package/dist/cld-video-player.light.min.js +4 -4
  15. package/dist/cld-video-player.min.css +2 -2
  16. package/dist/cld-video-player.min.js +4 -4
  17. package/dist/colors.js +4 -4
  18. package/dist/colors.min.js +2 -2
  19. package/dist/dash.js +6 -6
  20. package/dist/dash.min.js +2 -2
  21. package/dist/debug.js +8 -8
  22. package/dist/debug.min.js +3 -3
  23. package/dist/ima.js +9 -9
  24. package/dist/ima.min.js +2 -2
  25. package/dist/interaction-areas.js +11 -11
  26. package/dist/interaction-areas.min.js +2 -2
  27. package/dist/node_modules_lodash_throttle_js.js +8 -8
  28. package/dist/playlist.js +31 -31
  29. package/dist/playlist.min.js +3 -3
  30. package/dist/recommendations-overlay.js +10 -10
  31. package/dist/recommendations-overlay.min.js +2 -2
  32. package/dist/schema.json +19 -0
  33. package/dist/share.js +5 -5
  34. package/dist/share.min.js +3 -3
  35. package/dist/shoppable.js +12 -12
  36. package/dist/shoppable.min.js +2 -2
  37. package/dist/utils_fetch-config_js.js +81 -0
  38. package/dist/video-player_js.js +3111 -0
  39. package/dist/visual-search.js +7 -7
  40. package/dist/visual-search.min.js +2 -2
  41. package/lib/_commonjsHelpers.js +7 -0
  42. package/lib/_videojs-proxy.js +30294 -0
  43. package/lib/abr-strategies.js +31 -0
  44. package/lib/adaptive-streaming.js +468 -2
  45. package/lib/all.js +25 -2
  46. package/lib/chapters.js +205 -1
  47. package/lib/cld-video-player.min.css +5 -22
  48. package/lib/colors.js +59 -1
  49. package/lib/{schema.json → config/configSchema.json} +19 -0
  50. package/lib/dash.js +69943 -2
  51. package/lib/debug.js +322 -1
  52. package/lib/document.js +770 -0
  53. package/lib/download-button.js +48 -0
  54. package/lib/fetch-config.js +93 -0
  55. package/lib/ima.js +6851 -1
  56. package/lib/index.js +27 -0
  57. package/lib/interaction-areas.const.js +24 -0
  58. package/lib/interaction-areas.service.js +469 -0
  59. package/lib/lazy.js +20 -0
  60. package/lib/noop.js +33 -0
  61. package/lib/player-api.js +469 -0
  62. package/lib/player.js +7 -2
  63. package/lib/playlist-panel.js +602 -0
  64. package/lib/playlist.js +637 -1
  65. package/lib/querystring.js +81 -0
  66. package/lib/recommendations-overlay.js +320 -1
  67. package/lib/share.js +129 -1
  68. package/lib/shoppable-post-widget.js +572 -0
  69. package/lib/shoppable-widget.js +77 -0
  70. package/lib/throttle.js +318 -0
  71. package/lib/toNumber.js +134 -0
  72. package/lib/validators-functions.js +485 -0
  73. package/lib/video-player.js +16241 -0
  74. package/lib/videoPlayer.js +7 -2
  75. package/lib/videojs-contrib-hlsjs.js +37638 -0
  76. package/lib/visual-search.js +235 -1
  77. package/package.json +31 -15
  78. package/lib/adaptive-streaming.js.LICENSE.txt +0 -3
  79. package/lib/all.js.LICENSE.txt +0 -25
  80. package/lib/cld-video-player.js +0 -2
  81. package/lib/cld-video-player.js.LICENSE.txt +0 -21
  82. package/lib/dash.js.LICENSE.txt +0 -1842
  83. package/lib/interaction-areas.js +0 -1
  84. package/lib/player.js.LICENSE.txt +0 -21
  85. package/lib/shoppable.js +0 -1
  86. package/lib/videoPlayer.js.LICENSE.txt +0 -21
package/lib/all.js CHANGED
@@ -1,2 +1,25 @@
1
- /*! For license information please see all.js.LICENSE.txt */
2
- var t,e,s={7878:t=>{const e=t=>{t.style.display="none"},s=t=>{t.style.display=""};t.exports={hide:e,show:s,setText:(t,i)=>{if(!i||i.length<=0)return t.innerText="",void e(t);t.innerText=i,s(t)}}},7604:(t,e,s)=>{s.r(e),s.d(e,{default:()=>A});var i=s(6673),r=s.n(i);const n=r().getComponent("ClickableComponent"),a=class extends n{setItem(t){const{action:e,source:s}=t;this.source=s;const i=s.info();this.setTitle(i.title||s.publicId()),this.setPoster(this.source.poster().url({transformation:{aspect_ratio:"16:9",crop:"pad",background:"black"}})),this.setAction(e)}setTitle(t){this.title.innerText=t}setAction(t){this.action=t}handleClick(){super.handleClick(),this.player().trigger("recommendationshide"),this.action()}};var o=s(7878),l=s.n(o);const h=r().dom||r(),c=class extends a{setItem(t){super.setItem(t);const e=this.source.info();if(this.setTitle(e.title),this.setSubtitle(e.subtitle),e.description){const t=300,s=e.description.length>t?e.description.substring(0,t)+"...":e.description;this.setDescription(s)}}setPoster(t){this.poster.style.backgroundImage=`url('${t}')`}setTitle(t){l().setText(this.title,t),this.setAriaCheck(this.title,!!t)}setSubtitle(t){l().setText(this.subtitle,t),this.setAriaCheck(this.subtitle,!!t)}setDescription(t){l().setText(this.description,t),this.setAriaCheck(this.description,!!t)}setAriaCheck(t){arguments.length>1&&void 0!==arguments[1]&&!arguments[1]?t.setAttribute("aria-hidden","true"):t.removeAttribute("aria-hidden")}clearItem(){this.setTitle(""),this.setSubtitle(""),this.setDescription(""),this.poster.style.backgroundImage=null}createEl(){const t=super.createEl("div",{className:"vjs-recommendations-overlay-item vjs-recommendations-overlay-item-primary"});return this.poster=h.createEl("div",{className:"vjs-recommendations-overlay-item-primary-image"}),this.title=h.createEl("h2",{ariaLabel:"Recmmendation Title"}),this.setAriaCheck(this.title,!1),this.title.innerHTML="",this.subtitle=h.createEl("h3",{ariaLabel:"Recmmendation Subtitle"}),this.setAriaCheck(this.subtitle,!1),this.subtitle.innerHTML="",this.description=h.createEl("p"),this.setAriaCheck(this.description,!1),this.description.innerHTML="",this.content=h.createEl("div",{className:"vjs-recommendations-overlay-item-info vjs-recommendations-overlay-item-primary-content"}),this.content.appendChild(this.title),this.content.appendChild(this.subtitle),this.content.appendChild(this.description),t.appendChild(this.poster),t.appendChild(this.content),t}},d=r().dom||r(),u=class extends a{setItem(t){super.setItem(t),this.setDuration("")}setPoster(t){this.el().style.backgroundImage=`url('${t}')`}setDuration(t){this.duration.innerText=t}createEl(){const t=super.createEl("div",{className:"vjs-recommendations-overlay-item vjs-recommendations-overlay-item-secondary"});this.title=d.createEl("span",{className:"vjs-recommendations-overlay-item-secondary-title"}),this.title.innerHTML="",this.duration=d.createEl("span",{className:"vjs-recommendations-overlay-item-secondary-duration"}),this.duration.innerHTML="";const e=d.createEl("div",{className:"vjs-recommendations-overlay-item-info"});return e.appendChild(this.title),e.appendChild(this.duration),t.appendChild(e),t}handleClick(){super.handleClick(),this.action()}},p=r().getComponent("Component"),f=class extends p{setItems(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];this.clearItems(),e&&e.forEach(t=>{const e=new u(this.player());e.setItem(t),this.addChild(e)})}clearItems(){this.children().forEach(()=>{this.removeChild(this.children()[0])})}createEl(){return super.createEl("div",{className:"vjs-recommendations-overlay-item-secondary-container"})}},g=r().getComponent("Component");class m extends g{constructor(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];super(t,...s),this._primary=new c(t),this._secondaryContainer=new f(t),this.addChild(this._primary),this.addChild(this._secondaryContainer)}setItems(t){this._primary.setItem(t);for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];this._secondaryContainer.setItems(...s)}createEl(){return super.createEl("div",{className:"aspect-ratio-content"})}}const y=class extends g{constructor(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];super(t,...s),this._content=new m(t),this.addChild(this._content)}setItems(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];this._content.setItems(t,...s)}clearItems(){this._content._primary.clearItem(),this._content._secondaryContainer.clearItems()}createEl(){return super.createEl("div",{className:"vjs-recommendations-overlay-content"})}},v=r().getComponent("ClickableComponent"),b=class extends v{createEl(){return super.createEl("span",{className:"vjs-recommendations-overlay-hide vjs-icon-close"})}handleClick(){this.options_.clickHandler()}},_=r().getComponent("Component");class T extends _{constructor(t,e){for(var s=arguments.length,i=new Array(s>2?s-2:0),r=2;r<s;r++)i[r-2]=arguments[r];super(t,...i),this._content=new y(t),this.addChild(this._content),this.addChild(new b(t,{clickHandler:()=>{this.close()}},...i)),this.setEvents(t),this.doNotOpen=!1}setEvents(t){this.on(t,"recommendationschanged",(t,e)=>{this.setItems(...e.items)}),this.on(t,"recommendationsnoshow",this.setDoNotOpen),this.on(t,"recommendationsshow",this.open),this.on(t,"recommendationshide",this.close),this.on(t,"cldsourcechanged",()=>{this.clearItems(),this.close()})}setDoNotOpen(){this.doNotOpen=!0}open(){this.doNotOpen||(this._showControlsOnClose=this.player().controls(),this.player().controls(!1),this.el().style.visibility="visible")}clearItems(){this._content.clearItems()}close(){this.el().style.visibility="hidden",this._showControlsOnClose&&this.player().controls(!0)}createEl(){const t="vjs-recommendations-overlay",e=super.createEl("div",{className:t});return r().dom.addClass(e,t),e}setItems(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];this.doNotOpen=!1,s=s.slice(0,3),this._content.setItems(t,...s)}handleClick(){this.stopPropagation()}dispose(){super.dispose()}}r().registerComponent("recommendationsOverlay",T);const A=T},9987:(t,e,s)=>{s.d(e,{default:()=>q});var i=s(6673),r=s.n(i);const n=function(t){const[e,s,i]=t.split(":").reverse();let r=null;return isNaN(e)||(r=60*(+i||0)*60+60*(+s||0)+ +e),r};var a=s(9339);const o={location:"right",toggleIcon:"",width:"20%",startState:"openOnPlay",autoClose:2,transformation:{quality:"auto",width:"auto",fetch_format:"auto",crop:"scale"},products:[],showPostPlayOverlay:!1},l="goto",h="seek",c="shoppable-panel-visible",d="shoppable-panel-hidden",u="shoppable-products-overlay",p="cld-spbl-panel",f="cld-spbl-toggle",g="cld-spbl-toggle-icon",m="cld-spbl-bar-inner",y="animate",v="cld-spbl-item",b="cld-spbl-img";var _=s(1104);const T=r().dom||r(),A=r().getComponent("Component");class E extends A{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,e),this.options_=e,this.player_=t,this.player_.on(_.f.SHOW_PRODUCTS_OVERLAY,this.renderProducts),this.dispose=()=>{this.layout_.dispose()}}renderProducts=()=>{this.player_.removeClass(c),this.player_.addClass(d),this.player_.addClass(u),this.layout_.innerHTML="";const t=this.player_.currentTime();this.options_.products.filter(e=>e.hotspots&&e.hotspots.some(e=>n(e.time)===t)).forEach(e=>{const s=(0,a.I)(e.hotspots,e=>n(e.time)===t),i=T.createEl("div",{className:"cld-spbl-product-hotspot-name"},{},e.productName),r=T.createEl("div",{className:"cld-spbl-product-tooltip cld-spbl-product-tooltip-"+s.tooltipPosition},{},i),o=T.createEl("a",{className:"cld-spbl-product-hotspot accent-color-text",href:s.clickUrl,target:"_blank"},{style:"left:"+s.x+"; top:"+s.y+";"},r);this.layout_.appendChild(o)}),this.player_.one(_.f.SEEKING,this.clearLayout),this.player_.one(_.f.PLAY,this.clearLayout)};clearLayout=()=>{this.layout_.innerHTML="",this.player_.removeClass(u)};createEl(){const t=this.player_.currentDimensions();return this.layout_=T.createEl("div",{className:"cld-spbl-products-overlay",style:`padding-top: ${t.height/t.width*100}%;`}),this.layout_}}r().registerComponent("ShoppableProductsOverlay",E);const S=E,C=r().dom||r(),k=r().getComponent("ClickableComponent");class w extends k{constructor(t,e){super(t,e),this.options_=e}handleClick(t){t.preventDefault(),t.stopPropagation(),this.options_.clickHandler()}createEl(){let t={},e={};this.options_.toggleIcon?(t={className:`${g} cld-spbl-toggle-custom-icon vjs-icon-close`},e={style:`background-image: url(${this.options_.toggleIcon})`}):t={className:`${g} vjs-icon-cart`};const s=C.createEl("span",t,e),i=super.createEl("a",{className:`${f} base-color-bg`});return i.appendChild(s),this.player_.on(_.f.PRODUCT_BAR_MIN,()=>{setTimeout(()=>{s.classList.add(y),setTimeout(()=>{s.classList.remove(y)},1e3)},500)}),i}}r().registerComponent("shoppablePanelToggle",w);const L=w,I=r().dom||r(),P=r().getComponent("Component");class x extends P{constructor(t,e){super(t,e),this.player_=t,this.player().addClass("cld-shoppable-panel"),this.player().addClass(d),this.contentWrpEl_=I.createEl("div",{className:"cld-spbl-bar"}),this.contentBannerEl_=I.createEl("div",{className:"cld-spbl-banner-msg base-color-text"},{},this.options_.bannerMsg||"Shop the Video"),this.contentWrpEl_.appendChild(this.contentBannerEl_);const s=new S(this.player_,this.options_);this.contentWrpEl_.appendChild(s.el_),this.contentEl_=I.createEl("div",{className:m}),this.contentWrpEl_.appendChild(this.contentEl_),this.player().el().appendChild(this.contentWrpEl_),this.addChild(new L(this.player_,{toggleIcon:this.options_.toggleIcon,clickHandler:()=>{this.togglePanel()}})),this.addChild("ShoppablePanel",this.options_),this.dispose=()=>{this.removeLayout(),super.dispose()},this.togglePanel=t=>{!0===t?(this.player().removeClass(d),this.player().addClass(c)):!1===t?(this.player().removeClass(c),this.player().addClass(d)):(this.player().toggleClass(d),this.player().toggleClass(c));let e=this.player().hasClass(c)?"productBarMax":"productBarMin";this.player().trigger(e)},"open"===this.options_.startState&&this.togglePanel(!0),this.player_.on(_.f.PLAY,()=>{this.player_.currentTime()<.01&&("openOnPlay"===this.options_.startState&&this.togglePanel(!0,this.options_.autoClose),this.options_.autoClose&&-1!==this.options_.startState.indexOf("open")&&setTimeout(()=>{this.contentEl_.matches(":hover")?this.contentEl_.addEventListener("mouseleave",()=>{this.togglePanel(!1)},{once:!0}):this.togglePanel(!1)},1e3*this.options_.autoClose))})}createEl(){return super.createEl("div")}}r().registerComponent("shoppableBarLayout",x);const R=x;var D=s(2858),O=s.n(D),M=s(4650);const F=r().getComponent("ClickableComponent"),N=r().dom||r(),B={width:132};class j extends F{constructor(t,e){super(t,e),this.options_=e,this.isDragged=!1}handleClick(t){t.preventDefault(),t.stopPropagation(),this.el_.matches(`.dragged .${v}`)||this.options_.clickHandler(t),this.isDragged=!1}getTitle(){return this.options_.conf.title}createEl(){const t=super.createEl("a",{className:`${v} base-color-bg accent-color-text`,href:"#"});t.setAttribute("data-product-id",this.options_.conf.productId||""),t.setAttribute("data-product-name",this.options_.conf.productName||""),this.options_.conf.onHover&&$(t,this.options_.conf.onHover,this.options_.item.cloudinaryConfig()),this.options_.conf.onClick&&U(t,this.options_.conf.onClick);const e=super.createEl("img",{className:b},{src:this.options_.item.url(B)});if(t.appendChild(e),this.getTitle()){const e=N.createEl("div",{className:"cld-spbl-item-info base-color-semi-bg text-color-text"}),s=N.createEl("span",{className:"cld-spbl-item-title"},{},this.getTitle());e.appendChild(s),t.appendChild(e)}return t}}const $=(t,e,s)=>{if(t.setAttribute("data-hover-action",e.action),"overlay"===e.action){const s=N.createEl("span",{className:"cld-spbl-overlay-text base-color-text"},{},e.args),i=N.createEl("span",{className:"cld-spbl-overlay text-color-semi-bg base-color-text"},{title:e.args},s);t.appendChild(i)}else{const i=new M.A(e.args.publicId,{cloudinaryConfig:s,transformation:e.args.transformation}),r=N.createEl("img",{className:`${b} cld-spbl-hover-img`},{src:i.url(B)});t.appendChild(r)}},U=(t,e)=>{t.setAttribute("data-click-action",e.action),t.setAttribute("data-pause",e.pause),e.action===h?t.setAttribute("data-seek",e.args.time):e.action===l&&t.setAttribute("data-goto-url",e.args.url)};r().registerComponent("shoppablePanelItem",j);const H=j,V=r().getComponent("Component");class G extends V{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,e),this.options=e;const s=()=>{this.render()};t.on(_.f.SHOPPABLE_ITEM_CHANGED,s),this.render(),this.dispose=()=>{super.dispose(),t.off(_.f.SHOPPABLE_ITEM_CHANGED,s)}}createEl(){const t=super.createEl();return[p,"base-color-bg"].map(e=>t.classList.add(e)),t}removeAll(){const t=this.children();for(let e=t.length-1;e>=0;--e)this.removeChild(t[e])}getItems(){const t=this.player_.cloudinary.cloudinaryConfig();return this.options.products.map(e=>{e.onHover&&"object"==typeof e.onHover.args&&(e.onHover.args.transformation=Object.assign({},this.options.transformation,e.onHover.args.transformation));const s={productId:e.productId,productName:e.productName,title:e.title,onHover:e.onHover,onClick:e.onClick,startTime:e.startTime,endTime:e.endTime};return{imageSrc:new M.A(e.publicId,{cloudinaryConfig:t,transformation:Object.assign({},this.options.transformation,e.transformation)}),conf:s}})}scrollToActiveItem(){const t=this.el_.getElementsByClassName("active");if(t.length>0){const e=t[0].offsetTop-12;"scrollBehavior"in document.documentElement.style?this.el_.scrollTo({top:e,behavior:"smooth"}):this.el_.scrollTop=e}}render(){this.removeAll();const t=this.getItems(),e=O()(()=>this.scrollToActiveItem(),1e3);t.forEach((t,s)=>{const i=new H(this.player(),{item:t.imageSrc,conf:t.conf,next:1===s,current:0===s,clickHandler:t=>{let e=t.currentTarget||t.target,s=this.player_.ended()?"productClickPost":"productClick";if(this.player_.trigger(s,{productId:e.dataset.productId,productName:e.dataset.productName}),e.dataset.clickAction===l)window.open(e.dataset.gotoUrl,"_blank");else if(e.dataset.clickAction===h){const t=n(e.dataset.seek);null!==t&&(this.player_.addClass("vjs-has-started"),this.player_.postModal&&this.player_.postModal.close(),this.player_.currentTime(t),this.player_.removeClass(c),this.player_.addClass(d),this.player_.addClass(u),this.player_.one("seeked",()=>this.player_.trigger("showProductsOverlay")))}"false"!==e.dataset.pause&&(this.player_.pause(),n(e.dataset.pause)&&setTimeout(()=>{this.player_.play()},1e3*n(e.dataset.pause)))}});i.on("mouseover",t=>{let e=t.currentTarget||t.target,s=this.player_.ended()?"productHoverPost":"productHover";this.player_.trigger(s,{productId:e.dataset.productId,productName:e.dataset.productName})}),void 0!==t.conf.startTime&&void 0!==t.conf.endTime&&this.player_.on(_.f.TIME_UPDATE,()=>{const s=this.player_.currentTime();s>=t.conf.startTime&&s<t.conf.endTime?(i.el_.classList.add("active"),e()):i.el_.classList.contains("active")&&i.el_.classList.remove("active")}),this.addChild(i)})}}r().registerComponent("shoppablePanel",G);const W=G,K=r().dom||r(),z=class{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.options_={...e,postPlay:!0},this.player_=t,this.render(),this.handleDragToScroll(),this.dispose=()=>{this.layout_.dispose()}}handleDragToScroll(){const t=this.player_.postModal.el_.querySelector(`.${p}`);let e=!1,s=0,i=0;t.addEventListener("mousedown",r=>{e=!0,s=r.pageX-t.offsetLeft,i=t.scrollLeft}),document.addEventListener("mouseup",i=>{e=!1,setTimeout(()=>{t.classList.remove("dragged")},300);const r=i.pageX-t.offsetLeft-s;Math.abs(r)>5&&i.preventDefault()}),document.addEventListener("mousemove",r=>{if(!e)return;r.preventDefault();const n=r.pageX-t.offsetLeft-s;t.scrollLeft=i-n,Math.abs(n)>5&&!t.classList.contains("dragged")&&t.classList.add("dragged")})}render(){this.player_.postModal=null;const t=K.createEl("div",{className:"cld-spbl-post-play"}),e=new W(this.player_,this.options_),s=K.createEl("div",{className:"cld-spbl-post-title base-color-text"},{},this.options_.bannerMsg||"Shop the Video"),i=this.player_.cloudinary.currentPoster();i.transformation([i.transformation().toOptions?i.transformation().toOptions():{},{effect:"blur:3000"}]);const r=K.createEl("div",{className:"cld-spbl-post-play-bg",style:`background-image: url("${i.url()}")`}),n=K.createEl("button",{className:"cld-spbl-replay-btn base-color-bg vjs-icon-replay",onclick:()=>{this.player_.trigger("replay"),this.player_.postModal.close(),this.player_.play()}},{},"Replay");t.appendChild(r),t.appendChild(s),t.appendChild(e.el()),t.appendChild(n),this.player_.postModal=this.player_.createModal(t,{name:"postModal",uncloseable:!0}),this.player_.addClass("cld-spbl-post-modal"),this.player_.postModal.on("beforemodalclose",()=>{this.player_.removeClass("cld-spbl-post-modal")})}},q=class{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.options_=r().obj.merge(o,e),this.player_=t,this.options_.showPostPlayOverlay&&this.player_.on(_.f.ENDED,()=>{this.player_.addChild(new z(this.player_,this.options_))});const s=this.options_.width;this._injectCSS(`\n .${m} {\n transform: translateX(${s});\n }\n .${c} .vjs-control-bar {\n width: calc(100% - ${s});\n }\n .${f} {\n right: ${s};\n }\n .${p}{\n width: ${s};\n }\n `),this._setListeners()}_setListeners(){const t=this._resizeHandler.bind(this);this.player_.on(_.f.RESIZE,t),window.addEventListener("resize",t),this.dispose=()=>{this.player_.off(_.f.RESIZE,t),window.removeEventListener("resize",t),this.layout_.dispose()}}_injectCSS(t){const e=document.createElement("style");e.innerHTML=t,this.player_.el_.appendChild(e)}_resizeHandler(){const t=[["sm",0,80],["md",81,110],["lg",111,170]],e=parseFloat(this.options_.width)/100*this.player_.el_.clientWidth;let s=!1;if(e){for(const[i,r,n]of t)e>r&&e<=n&&(this.layout_.contentWrpEl_.setAttribute("size",i),s=i);s||this.layout_.contentWrpEl_.removeAttribute("size")}}init(){this.render()}render(){this.layout_=new R(this.player_,this.options_)}}},7668:(t,e,s)=>{s.d(e,{A:()=>a});var i=s(6673),r=s.n(i);var n=s(608);const a={logoOnclickUrl:"https://cloudinary.com/",showLogo:!0,showJumpControls:!1,playsinline:r().browser.IS_IOS,skin:"dark",controls:!1,chaptersButton:!1,pictureInPictureToggle:!1,seekThumbnails:!0,aiHighlightsGraph:!1,visualSearch:!1,download:!1,preload:n.Am.AUTO,textTrackSettings:!1,loop:!1,muted:!1,posterOptions:{},sourceTypes:["auto"],breakpoints:!1,contextMenu:{content:t=>{const e=t.loop(),s=t.paused(),i=t.muted(),r=t.isFullscreen(),n={class:"player-version",label:"Cloudinary Player v3.12.1"};return t.controls()?[{label:e?"Unloop":"Loop",listener:()=>{t.loop(!e)}},{label:s?"Play":"Pause",listener:()=>{s?t.play():t.pause()}},{label:i?"Unmute":"Mute",listener:()=>{t.muted(!i)}},{label:r?"Exit Fullscreen":"Fullscreen",listener:()=>{r?t.exitFullscreen():t.requestFullscreen()}},n]:[n]}},floatingWhenNotVisible:n.rT.NONE,hideContextMenu:!1,analytics:!1,cloudinaryAnalytics:!0,allowUsageReport:!0,videoConfig:!0,playedEventPercents:[25,50,75,100],adaptiveStreaming:{strategy:"balanced"},html5:{handlePartialData:!1,nativeTextTracks:!1},disableSeekWhileScrubbingOnMobile:!0}},8537:(t,e,s)=>{s.d(e,{Ay:()=>r,Fk:()=>i.Fk,Iy:()=>i.Iy,OC:()=>i.OC,xY:()=>i.xY});var i=s(4956);s(833),s(9234),s(9454),s(2650),s(5826),s(1066),s(9148),s(2130),s(9987),s(7604);const r=i.Ay},4956:(t,e,s)=>{s.d(e,{Ay:()=>we,OC:()=>Se,Fk:()=>Ce,xY:()=>Ae,Iy:()=>Ee});var i=s(6673),r=s.n(i);const n={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let a;const o=new Uint8Array(16),l=[];for(let t=0;t<256;++t)l.push((t+256).toString(16).slice(1));const h=function(t,e,s){if(n.randomUUID&&!e&&!t)return n.randomUUID();const i=(t=t||{}).random??t.rng?.()??function(){if(!a){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");a=crypto.getRandomValues.bind(crypto)}return a(o)}();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e){if((s=s||0)<0||s+16>e.length)throw new RangeError(`UUID byte range ${s}:${s+15} is out of buffer bounds`);for(let t=0;t<16;++t)e[s+t]=i[t];return e}return function(t,e=0){return(l[t[e+0]]+l[t[e+1]]+l[t[e+2]]+l[t[e+3]]+"-"+l[t[e+4]]+l[t[e+5]]+"-"+l[t[e+6]]+l[t[e+7]]+"-"+l[t[e+8]]+l[t[e+9]]+"-"+l[t[e+10]]+l[t[e+11]]+l[t[e+12]]+l[t[e+13]]+l[t[e+14]]+l[t[e+15]]).toLowerCase()}(i)};var c=s(5685),d=s.n(c),u=s(2832),p=s.n(u),f=s(7171),g=s.n(f),m=s(8446),y=s.n(m),v=s(8953),b=s.n(v),_=s(7571),T=s.n(_),A=s(1104);const E=r().getComponent("ErrorDisplay"),S=r().getComponent("ClickableComponent");r().registerComponent("JumpForwardButton",class extends S{handleClick(t){super.handleClick(t),this.player().currentTime(this.player().currentTime()+10)}createEl(){return r().dom.createEl("button",{className:"vjs-control vjs-icon-skip-10-plus vjs-icon-forward-10 vjs-button",ariaLabel:"Jump forward 10 seconds"})}});const C=r().getComponent("ClickableComponent");r().registerComponent("JumpBackButton",class extends C{handleClick(t){super.handleClick(t),this.player().currentTime(this.player().currentTime()-10)}createEl(){return r().dom.createEl("button",{className:"vjs-control vjs-icon-skip-10-min vjs-icon-replay-10 vjs-button",ariaLabel:"Jump back 10 seconds"})}});const k=r().getComponent("ClickableComponent");r().registerComponent("logoButton",class extends k{createEl(){const t=this.options_.playerOptions,e=t.showLogo?"block":"none",s=t.logoImageUrl?`background-image: url(${t.logoImageUrl})`:"";return r().dom.createEl("a",{},{class:"vjs-control vjs-cloudinary-button vjs-button",href:t.logoOnclickUrl,target:"_blank",style:`display: ${e}; ${s}`,"aria-label":"Logo link"})}});const w=r().getComponent("Component");r().registerComponent("progressControlEventsBlocker",class extends w{constructor(t){super(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}createEl(){return super.createEl("div",{className:"vjs-progress-control-events-blocker"})}});var L=s(7878),I=s.n(L),P=s(2415),x=s(1865),R=s(7311);const D=r().dom||r(),O=r().getComponent("Component");r().registerComponent("titleBar",class extends O{constructor(t){super(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}),this.on(t,"cldsourcechanged",(t,e)=>{let{source:s}=e;return this.setItem(s)})}setItem(t){if(!t)return this.setTitle(""),void this.setDescription("");const e=t.info();this.setTitle(e.title),this.setDescription(e.subtitle);const s=t.title&&!0===t.title(),i=t.description&&!0===t.description();(s||i)&&this.fetchAutoMetadata(t,s,i)}fetchAutoMetadata(t,e,s){if(t.isRawUrl)return;const i=t.cloudinaryConfig(),r=t.publicId();if(!i?.cloud_name||!r)return;const n=(0,x.k$)(i),a=t.getInitOptions().type||"upload",o=(0,R.N)(`${n}/_applet_/video_service/video_metadata/${a}/${(0,P.G)(r)}.json`,t.queryParams());fetch(o,{headers:{"X-Cld-Video-Player-Version":"3.12.1"}}).then(t=>{if(!t.ok)throw new Error(`HTTP ${t.status}`);return t.json()}).then(t=>{e&&t.title&&this.setTitle(t.title),s&&t.description&&this.setDescription(t.description)}).catch(t=>{console.warn(`Failed to fetch metadata for ${r}:`,t)})}setTitle(t){const e="string"==typeof t?t:"";return I().setText(this.titleEl,e),this.refresh(),e}setDescription(t){const e="string"==typeof t?t:"";return I().setText(this.descriptionEl,e),this.refresh(),e}refresh(){(()=>this.titleEl.innerText)()||(()=>this.descriptionEl.innerText)()?this.show():this.hide()}createEl(){this.titleEl=D.createEl("div",{className:"vjs-title-bar-title"}),this.descriptionEl=D.createEl("div",{className:"vjs-title-bar-subtitle"});const t=super.createEl("div",{append:this.titleEl,className:"vjs-title-bar"});return t.appendChild(this.titleEl),t.appendChild(this.descriptionEl),t}});const M=r().getComponent("MenuItem");class F extends M{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,{...e,selectable:!0,multiSelectable:!1,selected:!!e.selected,label:e.label}),this.value=e.value,this._ssIndex=e.index,this._onSelect="function"==typeof e.onSelect?e.onSelect:null}handleClick(t){super.handleClick(t),this._onSelect&&this._onSelect({index:this._ssIndex,value:this.value,label:this.options_.label})}}r().registerComponent("SourceMenuItem",F);const N=F,B=r().getComponent("MenuButton"),j=r().getComponent("MenuItem");r().registerComponent("sourceSwitcherButton",class extends B{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(t,e),this.controlText(e.tooltip||"Sources"),this._emptyLabel=e.emptyLabel||"No sources",this._items=Array.isArray(e.items)?e.items:[],this._selectedIndex=Number.isInteger(e.defaultIndex)?e.defaultIndex:void 0,this._onSelected="function"==typeof e.onSelected?e.onSelected:null,this._setEnabled(this._items.length>0);const s=this.el().querySelector(".vjs-icon-placeholder");s&&s.classList.add("vjs-icon-source-switcher")}buildCSSClass(){return`vjs-source-switcher-button${Array.isArray(this._items)&&0!==this._items.length?"":" vjs-source-switcher-disabled"} ${super.buildCSSClass()}`}createItems(){if(!Array.isArray(this._items)||0===this._items.length){const t=new j(this.player_,{label:this._emptyLabel,selectable:!1});return t.addClass("vjs-source-switcher-empty"),t.disable(),[t]}return this._items.map((t,e)=>{let{label:s,value:i}=t;return new N(this.player_,{label:s,value:i,index:e,selected:e===this._selectedIndex,onSelect:t=>this._handleItemSelect(t)})})}_handleItemSelect(t){let{index:e}=t;this._selectedIndex!==e&&this.setSelected(e)}setItems(t){this._items=Array.isArray(t)?t:[],this._selectedIndex=this._items.length?0:void 0,this._setEnabled(this._items.length>0),this._rebuildMenu()}setSelected(t){if(!Array.isArray(this._items)||null==t||t<0||t>=this._items.length)return;this._selectedIndex=t,this.menu&&"function"==typeof this.menu.children&&this.menu.children().forEach(e=>{e instanceof j&&e.selected(e._ssIndex===t)});const{value:e}=this._items[t];this._onSelected&&this._onSelected({index:t,value:e},this.player_)}setOnSelected(t){this._onSelected="function"==typeof t?t:null}_rebuildMenu(){if(!this.menu)return;this.menu.children().slice().forEach(t=>this.menu.removeChild(t)),this.createItems().forEach(t=>this.menu.addItem(t));const t=this.el&&this.el();if(t){const e=0===this._items.length;t.classList.toggle("vjs-source-switcher-disabled",e),t.setAttribute("aria-disabled",String(e))}}_setEnabled(t){const e=this.el&&this.el();e&&(e.classList.toggle("vjs-source-switcher-disabled",!t),e.setAttribute("aria-disabled",String(!t)))}});const $=r().getComponent("BigPlayButton");r().registerComponent("BigPauseButton",class extends ${constructor(t,e){super(t,e),this.boundUpdate=this.handleUpdate.bind(this);const s=this.player();s.on("play",this.boundUpdate),s.on("pause",this.boundUpdate),this.handleUpdate()}buildCSSClass(){return`${super.buildCSSClass()} vjs-big-pause-button`}handleClick(){const t=this.player();!t.paused()&&t.pause()}handleUpdate(){const t=this.player();if(!t)return;const e=t.paused();!e&&t.hasStarted()?this.show():this.hide(),this[e?"removeClass":"addClass"]("vjs-playing"),this.controlText("Pause")}dispose(){if(this.boundUpdate){const t=this.player();t.off("play",this.boundUpdate),t.off("pause",this.boundUpdate)}super.dispose()}}),r().registerComponent("ErrorDisplay",class extends E{content(){const t=this.player().error();if(!t)return"";const e=r().dom.createEl("div",{className:"cld-error-display-content"}),s=r().dom.createEl("span",{className:"cld-error-message"});t.isHtml?s.innerHTML=this.localize(t.message):s.textContent=this.localize(t.message),e.appendChild(s);const i=s.querySelector(".cld-error-refresh");return i&&(i.onclick=t=>{t.preventDefault(),this.player().trigger(A.f.REFRESH)}),e}});var U="3.0.1";const H=r().getTech("Html5"),V=r().registerPlugin||r().plugin,G=["abort","emptied","loadstart","play"],W=["abort","emptied"],K=["ad-playback","ads-ready?","postroll?","preroll?"];let z=0;const q=function(){const t=[];let e,s,i=!1,r=!0;const n=e=>function(s,i){if(this.perSourceBehaviors.disabled())return;const r=2===arguments.length,n=this.currentSrc(),a=[s],o=arguments[arguments.length-1],l=r?this:s,h=o.bind(l),c=(...t)=>{const s=this.currentSrc()!==n;this.perSourceBehaviors.disabled()||((s||e)&&this.off(...a),s||h(...t))};return c.guid=h.guid=o.guid="psb-"+ ++z,r||a.push(i),a.push(c),t.push(a),this.on(...a)};this.perSourceBehaviors={disable:function(){return this.clearTimeout(s),s=null,i=!0,i}.bind(this),disabled:()=>i,enable:()=>(i=!1,i),enabled:()=>!i,isSrcStable:()=>r,VERSION:U},this.onPerSrc=n(),this.onePerSrc=n(!0),this.on("dispose",()=>{t.length=0}),this.on(G,i=>{if(this.perSourceBehaviors.disabled()||s||((t,e)=>{return!!t.usingPlugin("ads")&&((t=>t.usingPlugin("ads")&&"function"==typeof t.ads.inAdBreak)(t)?t.ads.isInAdMode()&&"loadstart"!==e.type:(s=t.ads.state,K.indexOf(s)>-1));var s})(this,i))return;r&&W.indexOf(i.type)>-1&&(r=!1,this.trigger("sourceunstable"));const n=[],a=t=>n.push({time:Date.now(),event:t});a(i),this.on(H.Events,a),s=this.setTimeout(()=>{const i=this.currentSrc();r=!0,s=null,this.off(H.Events,a),i&&i!==e&&(t.forEach(t=>this.off(...t)),t.length=0,this.trigger("sourcechanged",{interimEvents:n,from:e,to:i}),e=i)},1)})};q.VERSION=U,V("perSourceBehaviors",q);let Y={};const X=function(){function t(t,e){return this.player=t,this.options=e,this.initializeHighlightsGraph(),this}return t.prototype.src=function(t){this.resetPlugin(),this.options.src=t,this.initializeHighlightsGraph()},t.prototype.detach=function(){this.resetPlugin()},t.prototype.resetPlugin=function(){this.graphHolder&&this.graphHolder.parentNode.removeChild(this.graphHolder),delete this.progressBar,delete this.graphHolder,delete this.lastStyle},t.prototype.initializeHighlightsGraph=function(){this.options.src&&fetch(this.options.src,{credentials:this.player.cloudinary.source?.().withCredentials?"include":"omit"}).then(t=>t.json()).then(t=>{this.setupHighlightsGraphElement(),this.graphHolder&&this.createHighlightsGraph(t)})},t.prototype.setupHighlightsGraphElement=function(){if(this.progressBar=this.player.$(".vjs-progress-control"),!this.progressBar)return;const t=this.player.$(".vjs-highlights-graph-display")||document.createElement("div");t.setAttribute("class","vjs-highlights-graph-display"),this.progressBar.appendChild(t),this.graphHolder=t},t.prototype.createPath=function(t,e,s){const i=e/(t.length-1),r=t.map((t,e)=>({x:e*i,y:s-t*s})),n=document.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("fill","lightblue");let a=`M ${r[0].x},${r[0].y}`;for(let t=0;t<r.length-1;t++){const e=(r[t].x+r[t+1].x)/2,s=(r[t].y+r[t+1].y)/2;a+=` Q ${r[t].x},${r[t].y} ${e},${s}`}return a+=` Q ${r[r.length-1].x},${r[r.length-1].y} ${r[r.length-1].x},${r[r.length-1].y}`,a+=` L ${r[r.length-1].x},${s} L ${r[0].x},${s} Z`,n.setAttribute("d",a),n},t.prototype.createHighlightsGraph=function(t){const e=t.data,s=this.player.$(".vjs-highlights-graph-display > svg")||document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("viewBox","0 0 600 20"),s.setAttribute("preserveAspectRatio","none"),s.setAttribute("width",600),s.setAttribute("height",20),s.innerHTML="";const i=this.createPath(e,600,20);s.appendChild(i),this.graphHolder.appendChild(s)},t}();var Q=s(6827),Z=s.n(Q);const J={percentsplayed:{percents:[25,50,75,100]}},tt=[A.f.PLAYER_LOAD,A.f.VIDEO_LOAD,A.f.START,A.f.PAUSE_NO_SEEK,A.f.SEEK,A.f.MUTE,A.f.UNMUTE,A.f.QUALITY_CHANGED,A.f.PERCENTS_PLAYED],et={events:tt};class st extends(Z()){constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(),this.player=t;const s=r().obj.merge(et,e);e.events&&(s.events=[...tt,...e.events]);let i={lastState:void 0},n=0,a=0,o=!1,l=[],h=[],c=null,d=!1,u=!1;const p=()=>{l=[],h=[],u=!1};this.events=it(s.events,J),i={lastState:void 0},n=a=0,o=!1,u=!1,p(),this.emit(A.f.PLAYER_LOAD,null,{url:window.location.href}),this.player.on(A.f.PLAYING,(()=>{u||(u=!0,this.emit(A.f.START))}).bind(this)),this.player.on(A.f.PLAY,(()=>{d&&(this.player.trigger("replay"),d=!1)}).bind(this)),this.player.on(A.f.ENDED,(()=>{d=!0}).bind(this)),(this.events.percentsplayed||this.events.timeplayed||this.events.seek||this.events.totaltimeplayed)&&this.player.on(A.f.TIME_UPDATE,(t=>{const e=this.player.currentTime(),s=this.player.duration(),i=(e,s)=>{s.originalType="timeupdate",this.emit(e,t,s)};if(this.events.percentsplayed&&this.events.percentsplayed.percents.forEach(t=>{rt(e,s,t)&&-1===l.indexOf(t)&&(l.push(t),i(A.f.PERCENTS_PLAYED,{percent:t}))}),this.events.timeplayed){const t=this.events.timeplayed;(t.interval?[Math.floor(e/t.interval)*t.interval]:t.times).forEach(t=>{nt(e,t)&&-1===h.indexOf(t)&&(h.push(t),i(A.f.TIME_PLAYED,{time:t}))})}this.events.seek&&(n=a,a=e,Math.abs(n-a)>1&&(o=!0,p(),i(A.f.SEEK,{seekStart:n,seekEnd:a})))}).bind(this)),(this.events.mute||this.events.unmute)&&this.player.on(A.f.VOLUME_CHANGE,(t=>{this.player.muted()&&"muted"!==i.lastState?(i.lastState="muted",this.emit(A.f.MUTE,t)):this.player.muted()||"unmuted"===i.lastState||(i.lastState="unmuted",this.emit(A.f.UNMUTE,t))}).bind(this)),this.events.pausenoseek&&(this.player.on(A.f.PAUSE,(t=>{Math.round(this.player.currentTime())===Math.round(this.player.duration())||o||this.emit(A.f.PAUSE_NO_SEEK,t)}).bind(this)),this.player.on(A.f.PLAY,(()=>{o=!1}).bind(this))),this.player.on(A.f.LOADED_METADATA,(()=>{const t=this.player.currentSource().src;t!==c&&(p(),c=t,this.emit(A.f.VIDEO_LOAD,null,{src:t}))}).bind(this)),this.player.on(A.f.LOADED_DATA,(t=>{let e=this,s=this.player.textTracks(),i=null;for(let t=0;t<s.length;t++)"segment-metadata"===s[t].label&&(i=s[t]);let r=null;i&&i.on("cuechange",function(){let s=i.activeCues[0];if(s){let i=s.value.resolution;if(r!==i){let s={from:r,to:i};e.emit(A.f.QUALITY_CHANGED,t,s)}r=i}})}).bind(this))}}const it=(t,e)=>{let s=t;return"Array"===t.constructor.name&&(s=t.reduce((t,s)=>{const i=e[s]||{};return b()(s)?t[s.type]=Object.assign({},i,s):t[s]=i,t},{})),s},rt=function(t,e,s){return nt(t,e*s/100,arguments.length>3&&void 0!==arguments[3]?arguments[3]:.5)},nt=function(t,e){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:.5;return t<=e+s&&t>=e-s},at=st,ot=[A.f.PLAY,A.f.PAUSE,A.f.ENDED,A.f.VOLUME_CHANGE,A.f.RESIZE,A.f.ERROR,A.f.FULL_SCREEN_CHANGE,A.f.START,A.f.VIDEO_LOAD,A.f.PERCENTS_PLAYED,A.f.SEEK,A.f.PLAYER_LOAD],lt={percentsplayed:{percents:[25,50,75,100]}},ht={events:ot,category:"Video",defaultLabel:t=>t.cloudinary?.currentPublicId()||t.currentSource().src};class ct{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.player=t,this.options=r().obj.merge(ht,e),this.events=it(this.options.events,lt),this._startTracked=null,this._endTracked=null,this.resetState()}init(){this.events.shoppable&&(this.player.on("productHover",((t,e)=>{this.track({action:"productHover",label:e.productName})}).bind(this)),this.player.on("productClick",((t,e)=>{this.track({action:"productClick",label:e.productName})}).bind(this)),this.player.on("productHoverPost",((t,e)=>{this.track({action:"productHoverPostPlay",label:e.productName})}).bind(this)),this.player.on("productClickPost",((t,e)=>{this.track({action:"productClickPostPlay",label:e.productName})}).bind(this)),this.player.on("productBarMin",(()=>{this.track({action:"shoppableBar",label:"closed"})}).bind(this)),this.player.on("productBarMax",(()=>{this.track({action:"shoppableBar",label:"opened"})}).bind(this)),this.player.on("replay",(()=>{this.track({action:"replay"})}).bind(this))),this.events.play&&this.player.on(A.f.PLAY,(()=>{this.track({action:"Play"})}).bind(this)),this.events.ended&&this.player.on(A.f.ENDED,(()=>{this._endTracked||(this.track({action:"Ended",nonInteraction:!0}),this._endTracked=!0)}).bind(this)),this.events.volumechange&&this.player.on(A.f.VOLUME_CHANGE,(()=>{const t=this.player.muted()?0:this.player.volume();this.track({action:"Volume Change",value:t})}).bind(this)),this.events.resize&&this.player.on(A.f.RESIZE,(()=>{const t=`Resize - ${this.player.width()}x${this.player.height()}}`;this.track({action:t})}).bind(this)),this.events.error&&this.player.on(A.f.ERROR,(()=>{this.track({action:"Error",nonInteraction:!0})}).bind(this)),this.events.start&&this.player.on(A.f.START,(()=>{this.track({action:"Start"})}).bind(this)),this.events.fullscreenchange&&this.player.on(A.f.FULL_SCREEN_CHANGE,(()=>{const t=this.player.isFullscreen()?"Enter Fullscreen":"Exit Fullscreen";this.track({action:t})}).bind(this)),this.events.percentsplayed&&this.player.on(A.f.PERCENTS_PLAYED,((t,e)=>{const{percent:s}=e;this.track({action:`${s} Percents Played`,nonInteraction:!0})}).bind(this)),this.events.timeplayed&&this.player.on(A.f.TIME_PLAYED,((t,e)=>{const{time:s}=e;this.track({action:`${s} Seconds Played`,value:s,nonInteraction:!0})}).bind(this)),this.events.pause&&this.player.on(A.f.PAUSE_NO_SEEK,(()=>{this.track({action:"Pause"})}).bind(this)),this.events.seek&&this.player.on(A.f.SEEK,((t,e)=>{const{seekStart:s,seekEnd:i}=e;this.track({action:"Seek Start",value:s}),this.track({action:"Seek End",value:i})}).bind(this)),this.events.playerload&&this.player.on(A.f.PLAYER_LOAD,((t,e)=>{const s=e?.url||window.location.href;this.track({action:"Player Load",label:s,nonInteraction:!0})}).bind(this)),this.events.videoload&&this.player.on(A.f.VIDEO_LOAD,this.videoload.bind(this))}track(t){let{action:e,label:s,value:i=null,nonInteraction:r=!1}=t;const n={event_category:this.options.category,event_label:s||this.options.defaultLabel(this.player),value:i||Math.round(this.player.currentTime()),non_interaction:r};window.gtag("event",e,n)}videoload(){this.track({action:"Video Load",nonInteraction:!0})}resetState(){this._startTracked=!1,this._endTracked=!1}}var dt=s(3171),ut=s(5871);const pt={fraction:.5,isMuted:!0};class ft{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e=Object.assign({},pt,e),this.player=t;let s=(0,ut.sliceProperties)(e,"fraction"),i=!1,r=!1,n=null,a=null;this.init=()=>{d(),c()};const o=()=>{window.removeEventListener("DOMContentLoaded",c,!1),window.removeEventListener("load",c,!1),window.removeEventListener("scroll",c,!1),window.removeEventListener("resize",c,!1),this.player.off("pause",n),this.player.off("play",a)},l=()=>{i=!0,r=!1,this.player.pause()},h=()=>{i=!1,r=!0,this.player.play()},c=()=>{(0,dt.isElementInViewport)(this.player.el(),{fraction:s.fraction})?this.player.paused()&&h():this.player.paused()||this.player.activePlugins_.floatingPlayer||l()},d=()=>{n=()=>{this.player.waiting||i||o()},a=()=>{r||o()},window.addEventListener("DOMContentLoaded",c,!1),window.addEventListener("load",c,!1),window.addEventListener("scroll",c,!1),window.addEventListener("resize",c,!1),this.player.on("pause",n),this.player.on("play",a)}}}var gt=s(5004),mt=s(608),yt=s(5381);const vt=class{constructor(t){this._emitter=t,this._eventHandlers=[]}on(t,e){this._eventHandlers.push({type:t,handler:e}),this._emitter.on(t,e)}one(t,e){var s=this;this._eventHandlers.push({type:t,handler:e,wrapper:function(){e(...arguments),s.off(t,e)}}),this._emitter.one(t,e)}off(t,e){const s=this._eventHandlers?.findIndex(s=>s.type===t&&s.handler===e);if(-1===s)return;const i=this._eventHandlers[s];this._emitter.off(t,i.wrapper||i.handler),this._eventHandlers.splice(s,1)}removeAllListeners(){this._eventHandlers.forEach(t=>{this.off(t)})}};var bt=s(4650);const _t={format:"jpg",resource_type:"video",transformation:{flags:"waveform"}},Tt=RegExp(`\\.(${["mp3","ogg","wav","mp4"].join("|")})$$`),At={resource_type:"video",type:"upload",transformation:[]};class Et extends yt.A{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};({publicId:t,options:e}=(0,x.a5)(t,e)),t=t.replace(Tt,""),e=Object.assign({},At,e);const{poster:s}=(0,ut.sliceAndUnsetProperties)(e,"poster");super(t,e),this._poster=null,this._type=A.x.AUDIO,this.poster(s)}getPoster(){return this._poster}poster(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t?t instanceof bt.A?(this._poster=t,this):(!0===t?(t=this.publicId(),e=Object.assign({},e,_t)):(({publicId:t,options:e}=(0,x.a5)(t,e,{tolerateMissingId:!0})),t||(t=this.publicId(),e=Object.assign({},e,_t))),e.cloudinaryConfig=e.cloudinaryConfig||this.cloudinaryConfig(),this._poster=new bt.A(t,e),this):this._poster}generateSources(){return this.sourceTypes().map(t=>{if("audio"===t){const e="mp3",s={},i=this.sourceTransformation()[t]||[this.transformation()];return i&&(s.transformation=i),Object.assign(s,{resource_type:"video",format:e}),{type:"video/mp4",src:(0,R.N)(this.config().url(this.publicId(),s),this.queryParams()),cldSrc:this,poster:this.getPoster().url()}}return null},this)}}const St=Et;var Ct=s(5226);const kt=t=>{const e="undefined"!=typeof window&&null!=window.devicePixelRatio?window.devicePixelRatio:Ct.VX;return Math.min(t??Ct.VX,e,Ct.VX)},wt={transformation:{},sourceTypes:[],sourceTransformation:[],posterOptions:{}},Lt=["cloudinaryConfig","transformation","sourceTypes","sourceTransformation","posterOptions","autoShowRecommendations"];class It{constructor(t){var e=this;let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};(0,x.M6)(),this.player=t,i=Object.assign({},wt,i);let r=null,n=null,a=null,o=null,l=null,h=null,c=null,u=null,p=null,f=i.chainTarget,g=null,m=null,v=!1;this.source=function(i){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(n=Object.assign({},n),!i)return r;let a=null;if(i instanceof yt.A)a=i;else{let{publicId:t,options:s}=(0,x.a5)(i,n);a=e.buildSource(t,s)}const o=a.recommendations();if(o&&o.length){let e=null,i=!1;n.recommendationOptions&&({disableAutoShow:i,itemBuilder:e}=(0,ut.sliceAndUnsetProperties)(n.recommendationOptions,"disableAutoShow","itemBuilder")),async function(t){try{return t.getChild("recommendationsOverlay")||(await Promise.all([s.e(869),s.e(410)]).then(s.bind(s,7604)),t.addChild("recommendationsOverlay")),t}catch(t){console.error("Failed to load plugin:",t)}}(t).then(()=>{b(o,{disableAutoShow:i,itemBuilder:e})})}else _();r=a,c=a.transformation();const l=n.sourceTypes&&n.sourceTypes.some(t=>t.includes("dash"))||"string"==typeof i&&i.endsWith(".mpd"),h=n.sourceTypes&&n.sourceTypes.some(t=>t.includes("hls"))||"string"==typeof i&&i.endsWith(".m3u8");return!l&&!h||e.player.adaptiveStreamingLoaded?n.skipRefresh||T():s.e(26).then(s.bind(s,7707)).then(()=>{e.player.adaptiveStreaming({...n.adaptiveStreaming,isDash:l,debug:n.debug,withCredentials:n.withCredentials}).then(()=>{T()})}).catch(t=>{console.error("Failed to load adaptive streaming plugin:",t),T()}),e.player.trigger("cldsourcechanged",{source:a,sourceOptions:n}),f},this.buildSource=function(t){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null;if(({publicId:t,options:s}=(0,x.a5)(t,s)),s.breakpoints&&e.player){const t=e.player.el(),i=t?.clientWidth,r=i*kt(s.maxDpr),n=Ct.o7.find(t=>t>=r)||Ct.o7[Ct.o7.length-1];s.breakpointTransformation={width:n,...!(0,gt.isKeyInTransformation)(s.transformation,"crop")&&{crop:"limit"}}}s=(t=>{const{aspectRatio:e,cropMode:s,cropPadColor:i,transformation:r,breakpointTransformation:n,...a}=t;if(!e&&!s&&!n)return t;const o={};e&&(o.aspect_ratio=e),s&&(s===mt.hN.SMART?(o.crop=mt.hN.FILL,o.gravity="auto"):(o.crop=s,s===mt.hN.PAD&&i&&(o.background=i)));const l={...n||{},...o};return{...a,transformation:Array.isArray(r)?[...r,l]:(0,x.N7)(r||{},l)}})(s),s.cloudinaryConfig=(0,x.lP)(e.cloudinaryConfig(),s.cloudinaryConfig||{}),s.transformation=(0,x.N7)(e.transformation(),s.transformation||{}),s.sourceTransformation=s.sourceTransformation||e.sourceTransformation(),s.sourceTypes=s.sourceTypes||e.sourceTypes();const r=E(s),n=s.transformation;if(n&&!d()(n)){const t=(0,x.hS)(n),e=(0,x.N7)(r.transformation||{},t);e.aspect_ratio&&delete e.height,r.transformation=e}const a=!d()(s.posterOptions);return void 0===s.poster&&((0,x.iT)(t)?s.poster=!1:s.poster=!a||r),s.posterOptions=Object.assign({},r,{hasUserPosterOptions:a||null}),s.queryParams=Object.assign(s.queryParams||{},s.allowUsageReport?{_s:"vp-3.12.1"}:{}),i=s.sourceTypes.indexOf("audio")>-1?new St(t,s):new yt.A(t,s),i},this.posterOptions=t=>t?(l=t,f):l,this.disablePoster=t=>{this.player.poster(" "),this.player.posterImage.el().style.backgroundColor=t},this.cloudinaryConfig=t=>t?(h=t,f):h,this.transformation=t=>t?(c=t,f):c,this.sourceTypes=t=>t?(u=t,f):u,this.getCurrentSources=()=>n,this.sourceTransformation=t=>t?(p=t,f):p,this.on=function(){return g.on(...arguments)},this.one=function(){return g.one(...arguments)},this.off=function(){return g.off(...arguments)},this.autoShowRecommendations=t=>void 0===t?v:(v=t,f),this.dispose=()=>{this.playlist&&this.playlist()&&this.disposePlaylist(),_(),r=void 0,g.removeAllListeners()};const b=(t,e)=>{let{disableAutoShow:s=!1,itemBuilder:i=null}=e;if(_(),!Array.isArray(t)&&"function"!=typeof t&&!t.then)throw new Error('"recommendations" must be either an array or a function');m={},i=i||(t=>({source:t instanceof yt.A?t:this.buildSource(t),action:()=>this.source(t)})),m.sourceChangedHandler=()=>{const e=t=>{if(void 0!==t&&t.length>0){const e=t.map(t=>i(t));this.player.trigger("recommendationschanged",{items:e})}else this.player.trigger("recommendationsnoshow");m.sources=t};y()(t)?e(t()):t.then?t.then(e):e(t)},m.sourceChangedHandler(),m.endedHandler=()=>{!s&&this.autoShowRecommendations()&&this.player.trigger("recommendationsshow")},this.on("ended",m.endedHandler)},_=()=>{m&&(this.off("cldsourcechanged",m.sourceChangedHandler),this.off("ended",m.endedHandler),delete m.endedHandler,delete m.sourceChangedHandler),m=null},T=()=>{const t=this.source();if(!t)return;const e=Object.assign({},this.player.cloudinary.posterOptions(),t.getInitOptions().poster);e.posterColor?this.disablePoster(e.posterColor):t.poster()&&this.player.poster(t.poster().url()),n=t.generateSources().reduce((t,e)=>{if(e.isAdaptive)if(e.type.split("; ")[1]&&"MediaSource"in window){let s=`video/mp4; ${e.type.split("; ")[1]||""}`;A(s)&&t.push(e)}else t.push(e);else t.push(e);return t},[]),this.player.src(n),a=t,this.playlist&&(o=this.playlist())},A=t=>document.createElement("video").canPlayType(t)||"MediaSource"in window&&MediaSource.isTypeSupported(t),E=t=>{const e=Object.assign({},this.posterOptions());e.transformation=e.transformation||{},!e.transformation.width&&!e.transformation.height||e.transformation.crop||(e.transformation.crop="scale");const s=(0,gt.isKeyInTransformation)(t.transformation,"width")||(0,gt.isKeyInTransformation)(t.transformation,"aspect_ratio"),i=this.player.el();if(!s&&i?.clientWidth&&i?.clientHeight){const s=t=>100*Math.ceil(t/100),r=kt(t.maxDpr);e.transformation=(0,x.N7)(e.transformation,{width:s(i.clientWidth*r),height:s(i.clientHeight*r),crop:"limit"})}return e};g=new vt(this.player);const S=(0,ut.sliceAndUnsetProperties)(i,...Lt);var C,k;C=this,k=S,Object.entries(k).forEach(t=>{let[e,s]=t;C[e]&&"function"==typeof C[e]&&C[e](s)}),this.on("sourcechanged",(t,e)=>{let s=e.to;a&&a.contains(s)?this.source()||(this.playlist&&o&&this.playlist(o),this.source(a,{skipRefresh:!0})):(this.player.trigger("cldsourcechanged",{}),this.dispose())})}currentSourceType(){return this.source().getType()}currentPublicId(){return this.source()&&this.source().publicId()}currentPoster(){return this.source()&&this.source().poster()}}var Pt=s(4679),xt=s.n(Pt),Rt=s(4138);class Dt{constructor(t,e){this.player=t,this.cloudinaryAnalytics=(0,Rt.connectCloudinaryAnalytics)(this.player.videoElement,{playerAdapter:this.getCloudinaryVideoPlayerAdapter()}),this.currentVideoMetadata={cloudName:null,publicId:null},this.analyticsOptions=e}getMetadata=()=>({cloudName:this.player.cloudinary.cloudinaryConfig().cloud_name,publicId:this.player.cloudinary.currentPublicId()});sourceChanged=(t,e)=>{let{source:s}=e;const i=this.getMetadata();if(i.cloudName&&i.publicId){const t="live"===s?.resourceConfig().type;this.currentVideoMetadata=i,this.cloudinaryAnalytics.startManualTracking({...i,...t?{type:"live"}:{}},{...xt()(this.analyticsOptions)?this.analyticsOptions:{},videoPlayerType:"cloudinary video player",videoPlayerVersion:"3.12.1"})}else this.currentVideoMetadata.cloudName===i.cloudName&&this.currentVideoMetadata.publicId===i.publicId||this.cloudinaryAnalytics.stopManualTracking()};getCloudinaryVideoPlayerAdapter=()=>{const t=(t,e)=>(this.player.on(t,e),()=>{this.player.off(t,e)});return{onCanPlay:e=>t("canplay",e),onCanPlayThrough:e=>t("canplaythrough",e),onComplete:e=>t("complete",e),onDurationChange:e=>t("durationchange",e),onEmptied:e=>t("emptied",e),onEnded:e=>t("ended",e),onError:e=>t("error",e),onLoadedData:e=>t("loadeddata",e),onLoadedMetadata:e=>t("loadedmetadata",e),onLoadStart:e=>t("loadstart",e),onPause:e=>t("pause",e),onPlay:e=>t("play",e),onPlaying:e=>t("playing",e),onProgress:e=>t("progress",e),onRateChange:e=>t("ratechange",e),onSeeked:e=>t("seeked",e),onSeeking:e=>t("seeking",e),onStalled:e=>t("stalled",e),onSuspend:e=>t("suspend",e),onTimeUpdate:e=>t("timeupdate",e),onVolumeChange:e=>t("volumechange",e),onWaiting:e=>t("waiting",e),getCurrentSrc:()=>this.player.videoElement.currentSrc,getCurrentTime:()=>this.player.currentTime(),getReadyState:()=>this.player.videoElement.readyState,getDuration:()=>this.player.duration()}};init(){this.player.on(A.f.CLD_SOURCE_CHANGED,this.sourceChanged)}}var Ot=s(7134);const Mt=r().getComponent("MenuItem"),Ft=class extends Mt{handleClick(){super.handleClick(),this.options_.listener()}createEl(){const t=(0,Ot.n)("span",{class:"vjs-menu-item-text"+(this.options_.class?` ${this.options_.class}`:"")});return t.appendChild(document.createTextNode(this.localize(this.options_.label))),(0,Ot.n)("li",{class:"vjs-menu-item",tabIndex:-1},t)}},Nt=r().getComponent("Menu"),Bt=class extends Nt{constructor(t,e){var s;super(t,e),s=this,e.content.forEach(e=>{let i=null;i=y()(e.listener)?e.listener:"string"==typeof e.href?()=>window.open(e.href):()=>!0,this.addItem(new Ft(t,{label:e.label,class:e.class,listener:function(){i(...arguments),s.dispose()}}))})}setPosition(t,e){(0,dt.setPosition)(this.el(),t,e)}createEl(){const t=super.createEl();if(r().dom.addClass(t,"vjs-context-menu-ui"),this.options_.position){const{left:t,top:e}=this.options_.position;this.setPosition(t,e)}return t}},jt={cancel:!0,sensitivity:10,wait:500,disabled:!1},$t="vjs-contextmenu";function Ut(t,e){if(t.contextmenu.options.disabled)return t;const s={target:t,type:$t};return["clientX","clientY","pageX","pageY","screenX","screenY"].forEach(t=>{s[t]=e[t]}),t.trigger(s)}function Ht(t){const e=this.contextmenu.current;if(!e)return;const s=this.contextmenu.options.wait;"touchend"===t.type&&(new Date).getTime()-e.time>=s&&Ut(this,t),this.contextmenu.current=null}function Vt(t){const e=this.contextmenu.current;if(!e)return;const s=t.touches[0],i=this.contextmenu.options.sensitivity;(s.screenX-e.screenX>i||s.screenY-e.screenY>i)&&(this.contextmenu.current=null)}function Gt(t){if(this.contextmenu.current)return;const e=t.touches[0];this.contextmenu.current={screenX:e.screenX,screenY:e.screenY,time:(new Date).getTime()}}function Wt(t){this.contextmenu.options.cancel&&!this.contextmenu.options.disabled&&t.preventDefault(),Ut(this,t),this.off(["touchcancel","touchend"],Ht),this.off("touchmove",Vt),this.off("touchstart",Gt)}r().registerPlugin("contextmenu",function(t){this.contextmenu.options=r().obj.merge(jt,t),this.on("contextmenu",Wt),this.on(["touchcancel","touchend"],Ht),this.on("touchmove",Vt),this.on("touchstart",Gt),this.ready(()=>this.addClass($t))});const Kt={showNativeOnRecurringEvent:!1};class zt{constructor(t,e){if(!Array.isArray(e.content)&&!y()(e.content))throw new Error('"content" required');const s=Object.assign({},Kt,e);this.player=t;const i=(0,ut.sliceProperties)(s,"content","showNativeOnRecurringEvent");this.init=()=>{this.player.contextmenu(),this.player.on("vjs-contextmenu",a),this.player.ready(()=>this.player.addClass("vjs-context-menu"))};const n=t=>{const e=this.menu.el();e.style.visibility="hidden",this.player.el().appendChild(e);const s=e.getBoundingClientRect();this.player.el().removeChild(e),e.style.visibility="visible";const i=(0,dt.getPointerPosition)(this.player.el(),t),r=this.player.el().getBoundingClientRect();let n=r.height-r.height*i.y+1,a=Math.round(r.width*i.x)+1,o=n,l=a;return n+s.height>r.height&&(o=n+s.height-r.height>s.height/2?n-s.height-1:r.height-s.height),a+s.width>r.width&&(l=a+s.width-r.width>s.width/2?a-s.width-1:r.width-s.width),o<n&&l<a&&(o=n-s.height-1,l=a-s.width-1),o=Math.max(0,o),l=Math.max(0,l),{left:l,top:o}},a=t=>{if(this.menu&&(this.menu.dispose(),i.showNativeOnRecurringEvent))return;i.showNativeOnRecurringEvent&&(this.player.contextmenu.options.cancel=!1),t.preventDefault();let e=i.content;y()(e)&&(e=e(this.player)),this.menu=new Bt(this.player,{content:e});const{left:s,top:a}=n(t);this.menu.setPosition(s,a);const o=t=>{("click"!==t.type||3!==t.which&&2!==t.button)&&this.menu.dispose()};this.menu.on("dispose",()=>{this.player.contextmenu.options.cancel=!0,this.player.removeChild(this.menu),r().off(document,["click","tap"],o),delete this.menu}),this.player.addChild(this.menu),r().on(document,["click","tap"],o)}}}const qt={fraction:.5,collapsedWidth:300,floatTo:"right"};class Yt{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e=Object.assign({},qt,e),e.floatTo&&e.floatTo!==mt.rT.LEFT&&e.floatTo!==mt.rT.RIGHT&&(e.floatTo=qt.floatTo),this.player=t;const s=this.player.el();let i=(0,ut.sliceProperties)(e,"fraction"),r=null,n=!1,a=!1;this.init=()=>{c(),"object"==typeof this.player.ima&&d()};const o=t=>{const e=document.createElement("div");for(t.appendChild(e);t.firstChild!==e;)e.appendChild(t.firstChild);return e},l=()=>{window.removeEventListener("DOMContentLoaded",g,!1),window.removeEventListener("load",g,!1),window.removeEventListener("scroll",g,!1),window.removeEventListener("resize",g,!1)},h=()=>{window.addEventListener("DOMContentLoaded",g,!1),window.addEventListener("load",g,!1),window.addEventListener("scroll",g,!1),window.addEventListener("resize",g,!1)},c=()=>{this.player.on("play",g),this.player.on("play",h),this.player.on("dispose",l)},d=()=>{const t=s.getBoundingClientRect();r=o(s);const e=o(r);e.setAttribute("class","cld-video-player-floater-inner"),e.setAttribute("style","padding-bottom: "+100*t.height/t.width+"%;");const i=document.createElement("button");i.setAttribute("class","cld-video-player-floater-close"),i.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12"><polygon fill-rule="evenodd" points="370 7.41 368.59 6 364 10.59 359.41 6 358 7.41 362.59 12 358 16.59 359.41 18 364 13.41 368.59 18 370 16.59 365.41 12" transform="translate(-358 -6)"/></svg>',i.onclick=()=>{p(),f()},r.appendChild(i)},u=()=>{const{ima:t}=this.player;t&&t.adsActive&&t.getAdsManager().resize(n?r.clientWidth:s.clientWidth,n?r.clientHeight:s.clientHeight)},p=()=>{r.classList.remove("cld-video-player-floating"),n=!1,u()},f=()=>{l(),this.player.off("play",g),this.player.off("play",h)},g=()=>{(0,dt.isElementInViewport)(this.player.el(),{fraction:i.fraction})?n&&p():n||(r||d(),a||(()=>{const t=s.getBoundingClientRect();r.setAttribute("class",`cld-video-player-floater cld-video-player-floater-bottom-${e.floatTo}`),r.setAttribute("style",["width: "+e.collapsedWidth+"px;","top: "+t.top+"px;","left: "+t.left+"px;","right: "+(document.documentElement.clientWidth-t.right)+"px;","bottom: "+(document.documentElement.clientHeight-t.bottom)+"px;"].join("")),a=!0})(),n=!0,setTimeout(()=>{r.classList.add("cld-video-player-floating"),u()}))}}}var Xt=s(7588),Qt=s(3066);let Zt={},Jt={};const te=function(){function t(t,e){return this.player=t,this.options=e,this.initializeThumbnails(),this}return t.prototype.src=function(t){this.resetPlugin(),this.options.src=t,this.initializeThumbnails()},t.prototype.detach=function(){this.resetPlugin()},t.prototype.resetPlugin=function(){this.thumbnailHolder&&this.thumbnailHolder.parentNode.removeChild(this.thumbnailHolder),delete this.vttData,delete this.thumbnailHolder,delete this.lastStyle},t.prototype.initializeThumbnails=function(){this.options.src&&fetch(this.options.src,{credentials:this.player.cloudinary.source?.().withCredentials?"include":"omit"}).then(t=>t.text()).then(t=>{this.vttData=this.processVtt(t),this.setupThumbnailElement()})},t.prototype.setupThumbnailElement=function(){if(!this.vttData[0])return;const t=this.player.$(".vjs-progress-holder .vjs-mouse-display");this.thumbnailHolder=this.player.$(".vjs-vtt-thumbnail-display")||r().dom.createEl("div",void 0,{class:"vjs-vtt-thumbnail-display",style:`width: ${this.vttData[0].css.width}`}),this.thumbnailHolder.innerHTML="",this.thumbnailHolder.setAttribute("class","vjs-vtt-thumbnail-display"),t.appendChild(this.thumbnailHolder);const e=parseInt(this.vttData[0].css.width,10)/2,s=this.updateThumbnailStyle.bind(this);this.player.getDescendant(["controlBar","progressControl","seekBar","mouseTimeDisplay"]).update=function(t,i){const n=i*this.player_.duration(),a=t.width;s(n),this.getChild("timeTooltip").updateTime(t,i,n,()=>{t.width*i<e?this.el_.style.left=`${e}px`:t.width*i+e>a?this.el_.style.left=t.width-e+"px":this.el_.style.left=t.width*i+"px"}),this.getChild("timeTooltip").write(r().time.formatTime(n))}},t.prototype.getStyleForTime=function(t){for(let e=0;e<this.vttData.length;++e){let s=this.vttData[e];if(t>=s.start&&t<s.end){if(s.css.url&&!Jt[s.css.url]){let t=new Image;t.src=s.css.url,Jt[s.css.url]=t}return s.css}}},t.prototype.updateThumbnailStyle=function(t){let e=this.getStyleForTime(t);if(e){if(this.thumbnailHolder.style.opacity="1",!this.lastStyle||this.lastStyle!==e){this.lastStyle=e;for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(this.thumbnailHolder.style[t]=e[t])}}else this.thumbnailHolder.style.opacity="0"},t.prototype.processVtt=function(t){let e=[];return t.split(/[\r\n][\r\n]/i).forEach(t=>{if(t.match(/([0-9]{2}:)?([0-9]{2}:)?[0-9]{2}(.[0-9]{3})?( ?--> ?)([0-9]{2}:)?([0-9]{2}:)?[0-9]{2}(.[0-9]{3})?[\r\n]{1}.*/gi)){let s=t.split(/[\r\n]/i),i=s[0].split(/ ?--> ?/i),r=i[0],n=i[1],a=s[1].split("/").pop(),o=this.getVttCss(a);e.push({start:this.getSecondsFromTimestamp(r),end:this.getSecondsFromTimestamp(n),css:o})}}),e},t.prototype.getPropsFromDef=function(t){let e=t.split(/#xywh=/i),s=e[0],i=e[1].match(/[0-9]+/gi);return{x:i[0],y:i[1],w:i[2],h:i[3],image:s}},t.prototype.getVttCss=function(t){let e={};t=[this.options.src.split(/([^\/]*)$/gi).shift().trim(),t.trim()].join("/");let s=this.getPropsFromDef(t);return e.background='url("'+s.image+'") no-repeat -'+s.x+"px -"+s.y+"px",e.width=s.w+"px",e.height=s.h+"px",e.url=s.image,e},t.prototype.getSecondsFromTimestamp=function(t){const[e,s,i]=t.split(":").map(parseFloat);return 60*e*60+60*s+i},t}();var ee=s(7707);const se=class{seperator=",";timestampToSeconds(t){const[e,s]=t.split(","),i=parseInt(s),[r,n,a]=e.split(":").map(t=>parseInt(t)),o=.001*i+a+60*n+3600*r;return Math.round(1e3*o)/1e3}correctFormat(t){let e=t.replace(".",",");var s,[i,r]=e.split(",");s=this.fixed_str_digit(3,r);var[n,a,o]=i.split(":");return`${this.fixed_str_digit(2,n,!1)}:${this.fixed_str_digit(2,a,!1)}:${this.fixed_str_digit(2,o,!1)},${s}`}fixed_str_digit(t,e,s=!0){return e.length==t?e:e.length>t?e.slice(0,t):e.length<t?s?e.padEnd(t,"0"):e.padStart(t,"0"):void 0}tryComma(t){let e=(t=t.replace(/\r/g,"")).split(/(\d+)\n(\d{1,2}:\d{2}:\d{2},\d{1,3}) --> (\d{1,2}:\d{2}:\d{2},\d{1,3})/g);return e.shift(),e}tryDot(t){let e=(t=t.replace(/\r/g,"")).split(/(\d+)\n(\d{1,2}:\d{2}:\d{2}\.\d{1,3}) --> (\d{1,2}:\d{2}:\d{2}\.\d{1,3})/g);return e.shift(),this.seperator=".",e}fromSrt(t){var e=t,s=this.tryComma(e);0==s.length&&(s=this.tryDot(e));for(var i=[],r=0;r<s.length;r+=4){const t=this.correctFormat(s[r+1].trim()),e=this.correctFormat(s[r+2].trim());var n={id:s[r].trim(),startTime:t,startSeconds:this.timestampToSeconds(t),endTime:e,endSeconds:this.timestampToSeconds(e),text:s[r+3].trim()};i.push(n)}return i}toSrt(t){var e="";const s="\r\n";for(var i=0;i<t.length;i++){var r=t[i];e+=r.id+s,e+=r.startTime+" --\x3e "+r.endTime+s,e+=r.text.replace("\n",s)+s+s}return e}},ie=async t=>(new se).fromSrt(t).filter(t=>t).map(t=>({startTime:t.startSeconds,endTime:t.endSeconds,text:t.text})),re=function(t,e,s){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;return`${t}/_applet_/video_service/transcription/${e}/${i?`${i}/`:""}${(0,P.G)(s)}.transcript`},ne={aiHighlightsGraph:function(t){this.ready(()=>{!function(t,e){t.addClass("vjs-ai-highlights-graph"),t.aiHighlightsGraph=new X(t,e)}(this,r().obj.merge(Y,t))})},analytics:function(){new ct(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).init()},autoplayOnScroll:function(){new ft(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).init()},cloudinary:function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.chainTarget=t.chainTarget||this,this.cloudinary=new It(this,t)},cloudinaryAnalytics:function(){new Dt(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).init()},contextMenu:function(){new zt(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).init()},floatingPlayer:function(){new Yt(this,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).init()},sourceSwitcher:function(){const t=this;return{reInit:e=>{const s=t.getChild("controlBar").getChild("sourceSwitcherButton");if(!s)return void r().log.warn("SourceSwitcherButton not found in controlBar.");const i=e.sources.map(t=>({value:t.publicId,label:t.label||t.publicId}));s.setItems(i),s.setOnSelected(()=>{}),s.setSelected(e.selectedIndex),s.setOnSelected(t=>{let{index:s}=t;e.onSourceChange(e.sources[s])})}}},styledTextTracks:async function(t){const e=this;try{e.ready(()=>((t,e)=>{const s={theme:t.theme||"default",fontFace:t.fontFace,fontSize:t.fontSize,gravity:t.gravity||"bottom",box:t.box,style:t.style,wordHighlightStyle:t.wordHighlightStyle},i=document.createElement("style");e.el_.appendChild(i);const r=e.textTrackDisplay.el().classList;r.forEach(t=>{t.startsWith("cld-styled-text-tracks")&&r.remove(t)}),r.add("cld-styled-text-tracks"),r.add(`cld-styled-text-tracks-theme-${s.theme}`),s.gravity.split("-").forEach(t=>{r.add(`cld-styled-text-tracks-gravity-${t}`)});const n=(t,e)=>{if(Object.entries(t)){const s=Object.entries(t).reduce((t,e)=>{let[s,i]=e;return t+`${s}: ${i} !important; `},"");i.innerHTML+=`${e} { ${s} } `}},a=t=>{const s=`\n .${(0,Qt.playerClassPrefix)(e)} .vjs-text-track-cue > div,\n .${(0,Qt.playerClassPrefix)(e)} ::cue\n `;n(t,s)};if(s.fontFace&&((0,Xt.fontFace)(e.textTrackDisplay.el(),s.fontFace),a({"font-family":s.fontFace})),s.box){const{x:t,y:i,width:r,height:a}=s.box;(t=>{const s=`\n .${(0,Qt.playerClassPrefix)(e)} .vjs-text-track-display.cld-styled-text-tracks,\n .${(0,Qt.playerClassPrefix)(e)} ::-webkit-media-text-track-display\n `;n(t,s)})({translate:`${t||0} ${i||0}`,...r?{width:r}:void 0,...a?{height:a}:void 0})}s.fontSize&&a({"font-size":s.fontSize}),s.style&&a(s.style),s.wordHighlightStyle&&(n(s.wordHighlightStyle,`.${(0,Qt.playerClassPrefix)(e)} .cld-paced-text-tracks .vjs-text-track-cue b`),n(s.wordHighlightStyle,"video::cue(b)"))})(t,e))}catch(t){console.error("Failed to load plugin:",t)}},vttThumbnails:function(t){this.ready(()=>{!function(t,e){t.addClass("vjs-vtt-thumbnails"),t.vttThumbnails=new te(t,e)}(this,r().obj.merge(Zt,t))})},chapters:async function(t){const e=this;try{const{default:i}=await Promise.all([s.e(869),s.e(625)]).then(s.bind(s,9234));e.ready(()=>i(t,e))}catch(t){console.error("Failed to load plugin:",t)}},colors:async function(t){const e=this;try{const{default:i}=await Promise.all([s.e(869),s.e(691)]).then(s.bind(s,9454)),r=i(e,t);return e.cloudinary.colors=r,r}catch(t){console.error("Failed to load colors plugin:",t)}},imaPlugin:async function(t,e){await Promise.all([s.e(869),s.e(330)]).then(s.bind(s,2650));const i=y()(t.ads),r="object"==typeof google&&"object"==typeof google.ima;if(e.ads&&(!i||!r))return i||console.warn("contribAds is not loaded"),r||console.warn("imaSdk is not loaded"),!1;t.ima({id:t.el().id,adTagUrl:e.ads.adTagUrl,disableFlashAds:!0,prerollTimeout:e.ads.prerollTimeout||5e3,postrollTimeout:e.ads.postrollTimeout||5e3,showCountdown:!1!==e.ads.showCountdown,adLabel:e.ads.adLabel||"Advertisement",locale:e.ads.locale||"en",autoPlayAdBreaks:!1!==e.ads.autoPlayAdBreaks,debug:e.ads.denug}),Object.keys(e.ads).length>0&&"object"==typeof t.ima&&("first-video"===e.ads.adsInPlaylist?t.one(A.f.SOURCE_CHANGED,()=>{t.ima.playAdBreak()}):t.on(A.f.SOURCE_CHANGED,()=>{t.ima.playAdBreak()}))},playlist:async function(t){const e=this;try{const{default:i}=await Promise.all([s.e(869),s.e(33)]).then(s.bind(s,5826)),r=i(e,t);return e.cloudinary.playlist=r,r}catch(t){console.error("Failed to load plugin:",t)}},shoppable:async function(t,e){const{default:i}=await Promise.all([s.e(869),s.e(525)]).then(s.bind(s,9987));new i(t,e.shoppable).init()},interactionAreas:async function(t,e,i){try{const{interactionAreasService:r}=await Promise.all([s.e(869),s.e(404)]).then(s.bind(s,1066));r(t,e,i)}catch(t){console.error("Failed to load plugin:",t)}},visualSearch:async function(t){const e=this;try{const{default:i}=await Promise.all([s.e(869),s.e(728)]).then(s.bind(s,9148));e.ready(()=>i(t,e))}catch(t){console.error("Failed to load plugin:",t)}},share:async function(t){const e=this;try{const{default:i}=await Promise.all([s.e(869),s.e(976)]).then(s.bind(s,2130));e.ready(()=>i(t,e))}catch(t){console.error("Failed to load share plugin:",t)}},adaptiveStreaming:ee.default,textTracksManager:function(){const t=this,e=new WeakMap;let s=null;const i=(t,s)=>{const i=e.get(t);e.set(t,{...i,...s})},r=(s,r)=>{const{kind:n=("transcript"===s?"captions":"subtitles"),label:a=("transcript"===s?"Captions":"Subtitles"),default:o,srclang:l,src:h}=r;"transcript"===s&&t.textTrackDisplay.el().classList.add("cld-paced-text-tracks");const{track:c}=t.addRemoteTextTrack({kind:n,label:a,srclang:l,default:o,mode:o?"showing":"disabled"});((t,s)=>{const i=new AbortController;e.set(t,{status:"idle",load:async()=>{const{status:r}=e.get(t);"idle"===r&&(await s(i.signal),(t=>{if(!t||"string"!=typeof t.mode)return;const e=t.mode;t.mode="showing"===e?"hidden":"showing",setTimeout(()=>{t.mode=e},0)})(t))},abortLoading:()=>{const{status:s}=e.get(t);"pending"===s&&i.abort()}})})(c,async e=>{i(c,{status:"pending"});const n=(()=>{if(h)return h;if("transcript"!==s)return;const e=t.cloudinary.source(),i=e.publicId(),r=e.resourceConfig().type,n=(0,x.k$)(t.cloudinary.cloudinaryConfig()),a=e.queryParams(),o=(0,R.N)(re(n,r,i),a);return(l?(0,R.N)(re(n,r,i,l),a):null)||o})(),a=await async function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{polling:s=!1,interval:i=3e3,maxAttempts:r=10,signal:n,onSuccess:a,onError:o,onAttempt:l}=e;let h=0;const c=async()=>{if(n?.aborted)throw new DOMException("Aborted","AbortError");h++,l?.(h);const e=await fetch(t,{signal:n});if(202===e.status&&s){if(h<r)return new Promise((t,e)=>{const s=setTimeout(()=>{c().then(t).catch(e)},i);n?.addEventListener("abort",()=>{clearTimeout(s),e(new DOMException("Aborted","AbortError"))},{once:!0})});throw new Error(`Polling max attempts reached (${r}) for ${t}`)}if(!e.ok)throw new Error(`Failed fetching from ${t} with status code ${e.status}`);const o=await e.text();return a?.(o),o};try{return await c()}catch(t){"AbortError"===t.name?console.warn("Polling aborted"):console.error(t),o?.(t)}}(n,{signal:e,polling:"transcript"===s&&!h,interval:2e3,maxAttempts:10,responseStatusAsPending:202,onSuccess:()=>i(c,{status:"success"}),onError:t=>{((t,e)=>{i(t,{status:"error",error:e})})(c,t),console.warn(`[${c.label}] Text track could not be loaded`)}});if(a){const t="srt"===s?ie:t=>(async(t,e)=>((t,e)=>{const s=[],i=t=>{let{startTime:i,endTime:r,text:n}=t;s.push({startTime:i+e.timeOffset,endTime:r+e.timeOffset,text:n})};return t.forEach(t=>{const r=t.words;if(r){const t=e.maxWords||r.length;for(let n=0;n<r.length;n+=t)e.wordHighlight?r.slice(n,Math.min(n+t,r.length)).forEach((e,s)=>{i({startTime:e.start_time,endTime:e.end_time,text:r.slice(n,n+t).map(t=>t===e?`<b>${t.word}</b>`:t.word).join(" ")}),r[s+1]&&e.end_time<r[s+1].start_time&&i({startTime:e.end_time,endTime:r[s+1].start_time,text:r.slice(n,n+t).map(t=>t.word).join(" ")})}):s.push({startTime:r[n].start_time,endTime:r[Math.min(n+t-1,r.length-1)].end_time,text:r.slice(n,n+t).map(t=>t.word).join(" ")})}else i({startTime:t.start_time,endTime:t.end_time,text:t.transcript})}),s})(JSON.parse(t),e))(t,{maxWords:r.maxWords,wordHighlight:r.wordHighlight,timeOffset:r.timeOffset??0}),e=await t(a);(o=c)&&o.cues&&Array.from(o.cues).forEach(t=>{try{o.removeCue(t)}catch(e){console.warn("Failed to remove cue:",t,e)}}),((t,e)=>{e.forEach(e=>{let{startTime:s,endTime:i,text:r,settings:n}=e;const a=new VTTCue(s,i,r);n&&n.split(/\s+/).forEach(t=>{const[e,s]=t.split(":");if(e&&s)switch(e){case"line":a.line=isNaN(s)?s:parseFloat(s);break;case"position":a.position=parseFloat(s);break;case"size":a.size=parseFloat(s);break;case"align":a.align=s}}),t.addCue(a)})})(c,e),(t=>{i(t,{status:"applied"})})(c)}var o})},n=t=>{const i=s;s=t;const r=e.get(i);r&&r.abortLoading();const n=e.get(s);n&&n.load()};return t.on("texttrackchange",()=>{const e=t.textTracks();let i=null;for(let t=0;t<e.length;t++){const s=e[t];if("showing"===s.mode){i=s;break}}s!==i&&n(i)}),{removeAllTextTracks:()=>{const e=t.remoteTextTracks();if(e)for(let s=e.tracks_.length-1;s>=0;s--)t.removeRemoteTextTrack(e.tracks_[s])},addTextTracks:function(){for(var e=arguments.length,s=new Array(e),i=0;i<e;i++)s[i]=arguments[i];t.one("loadedmetadata",()=>{(e=>{e.forEach(e=>{e.src&&e.src.endsWith(".vtt")?(e=>{const{kind:s="subtitles",label:i="Subtitles",default:r,srclang:n,src:a}=e;t.addRemoteTextTrack({kind:s,label:i,srclang:n,src:a,default:r,mode:r?"showing":"disabled"})})(e):e.src&&e.src.endsWith(".srt")?r("srt",e):e.src&&!e.src.endsWith(".transcript")||r("transcript",e)});const s=Array.from(t.remoteTextTracks()).find(t=>t.default);s&&n(s)})(...s)})}}}},ae=ne;var oe=s(5104),le=s(7668);var he=s(7764),ce=s(5779);const de=t=>!d()(t)||null,ue=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{poster:!0===t.poster?"auto":"string"==typeof t.poster?"url":void 0,posterOptions:t.posterOptions?.hasUserPosterOptions,posterOptionsPublicId:t.posterOptions&&de(t.posterOptions.publicId),autoShowRecommendations:t.autoShowRecommendations,fontFace:t.fontFace,sourceTypes:t.sourceTypes,resourceType:t.resourceType,chapters:!0===t.chapters?"auto":t.chapters&&t.chapters.url?"url":t.chapters?"inline-chapters":void 0,visualSearch:t.visualSearch,download:de(t.download),hdr:de(t.hdr),recommendations:t.recommendations&&t.recommendations.length,...de(t.adaptiveStreaming)?{abrStrategy:t?.adaptiveStreaming?.strategy===le.A.adaptiveStreaming.strategy?void 0:t?.adaptiveStreaming?.strategy}:{},shoppable:de(t.shoppable),shoppableProductsLength:de(t.shoppable)&&t.shoppable.products.length,...t.title||t.description||t.info?{sourceInfo:de(t.info),sourceTitle:"string"==typeof t.title?t.title:t.info?.title,sourceDescription:"string"==typeof t.description?t.description:t.info?.subtitle||t.info?.description}:{},...de(t.textTracks)?pe(t.textTracks):{},interactionAreas:de(t.interactionAreas),videoSources:de(t.videoSources),breakpoints:t.breakpoints,maxDpr:t.maxDpr,aspectRatio:t.aspectRatio,cropMode:t.cropMode,cropPadColor:de(t.cropPadColor)?t.cropPadColor:void 0}},pe=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=[t.captions,...t.subtitles||[]].filter(Boolean);return{textTracks:de(t),textTracksLength:e.length,textTracksOptions:de(t.options)&&Object.keys(t.options).join(","),pacedTextTracks:de(t)&&JSON.stringify(t||{}).includes('"maxWords":')||null,wordHighlight:de(t)&&JSON.stringify(t||{}).includes('"wordHighlight":')||null,transcriptLanguages:e.filter(t=>!t.url).map(t=>t.language||"").join(",")||null,transcriptAutoLoaded:e.some(t=>!t.url)||null,transcriptFromURl:e.some(t=>t.url?.endsWith(".transcript"))||null,vttFromUrl:e.some(t=>t.url?.endsWith(".vtt"))||null,srtFromUrl:e.some(t=>t.url?.endsWith(".srt"))||null,...t.options?{styledTextTracksTheme:t.options.theme,styledTextTracksFont:t.options.fontFace,styledTextTracksFontSize:t.options.fontSize,styledTextTracksGravity:t.options.gravity,styledTextTracksBox:de(t.options.box),styledTextTracksStyle:de(t.options.style),styledTextTracksWordHighlightStyle:de(t.options.wordHighlightStyle)}:{}}},fe=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{adsAdTagUrl:t.adTagUrl,adsShowCountdown:t.showCountdown,adsAdLabel:t.adLabel,adsLocale:t.locale,adsPrerollTimeout:t.prerollTimeout,adsPostrollTimeout:t.postrollTimeout,adsAdsInPlaylist:t.adsInPlaylist}},ge=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{playlist:t.playlist,playlistByTag:t.playlistByTag,playlistWidgetDirection:t.direction,playlistWidgetTotal:t.total}};Object.keys(ae).forEach(t=>{r().registerPlugin(t,ae[t])}),(0,he.go)();class me{static all(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];return[...document.querySelectorAll(t)].map(t=>new me(t,...s))}get playerOptions(){return this.options.playerOptions}constructor(t,e,s){this.videoElement=t,this.options=(0,he.DS)(e),this._videojsOptions=this.options.videojsOptions,this.videoElement.classList.add("video-js"),oe.A.fontFace(this.videoElement,this.playerOptions.fontFace),"init"===this._videojsOptions.bigPlayButton&&(this.videoElement.classList.add("vjs-big-play-button-init-only"),this._videojsOptions.bigPlayButton=!0),this.videojs=r()(this.videoElement,this._videojsOptions),((t,e)=>{const s={};t.on=function(){for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];const a=r.length-1,o=r[a];return s[o]=function(e){e.Player=t;for(var s=arguments.length,i=new Array(s>1?s-1:0),r=1;r<s;r++)i[r-1]=arguments[r];o(e,...i)},r[a]=s[o],e.on(...r)},t.one=function(){for(var i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];const a=r.length-1,o=r[a];return s[o]=function(e){e.Player=t;for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;n<i;n++)r[n-1]=arguments[n];o(e,...r),delete s[o]},r[a]=s[o],e.one(...r)},t.off=function(){for(var t=arguments.length,i=new Array(t),r=0;r<t;r++)i[r]=arguments[r];const n=i.length-1,a=i[n];i[n]=s[a];const o=e.off(...i);return delete s[a],o},t.trigger=function(){e.trigger(...arguments)}})(this,this.videojs),this._isPlayerConfigValid=!0,this.playerOptions.debug&&(0,ce.I6)(this.options).then(t=>{if(!t)return this._isPlayerConfigValid=!1,void this.videojs.error("invalid player configuration")}),this._videojsOptions.muted&&this.videojs.volume(.4),this.playerOptions.fluid&&this.fluid(this.playerOptions.fluid),this._setCssClasses(),this._initPlugins(),this._initJumpButtons(),this._initPictureInPicture(),this._initBigPauseButton(),this._setVideoJsListeners(s)}getVPInstanceId(){return this.vpInstanceId||(this.vpInstanceId=h()),this.vpInstanceId}_sendInternalAnalytics(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=Object.assign({},this.playerOptions,this.options.videojsOptions,t);if(e.sourceOptions?.allowUsageReport)try{const t=e._internalAnalyticsMetadata??{},r=(i={aiHighlightsGraph:(s=e).aiHighlightsGraph,analytics:de(s.analytics),autoplay:s.autoplay,autoplayMode:s.autoplayMode,bigPlayButton:s.bigPlayButton,className:s.class,cloudinaryAnalytics:de(s.cloudinaryAnalytics),controls:s.controls,floatingWhenNotVisible:s.floatingWhenNotVisible,fluid:s.fluid,height:s.height,hideContextMenu:s.hideContextMenu,logoImageUrl:s.logoImageUrl,logoOnclickUrl:s.logoOnclickUrl,loop:s.loop,maxTries:s.maxTries,muted:s.muted,playbackRates:s.playbackRates,playedEventPercents:s.playedEventPercents,playedEventTimes:s.playedEventTimes,playsinline:s.playsinline,preload:s.preload,videoTimeout:s.videoTimeout,seekThumbnails:s.seekThumbnails,showJumpControls:s.showJumpControls,chaptersButton:s.chaptersButton,pictureInPictureToggle:s.pictureInPictureToggle,showLogo:s.showLogo,skin:s.skin,videoJS:de(s.videoJS),width:s.width,withCredentials:s.withCredentials,debug:s.debug,type:s.type,colors:de(s.colors),controlBar:de(s.controlBar),...ue(s.sourceOptions||{}),...fe(s.ads),...ge(s.playlistWidget)},Object.entries(i).reduce((t,e)=>{let[s,i]=e;return i!==le.A[s]&&null!=i&&(t[s]=i),t},{})),n=new URLSearchParams(r).toString(),a=new URLSearchParams({vpVersion:"3.12.1",vpInstanceId:this.getVPInstanceId(),cloudName:e.cloudinary.cloud_name,...t}).toString();fetch(`https://analytics-api-s.cloudinary.com/video_player_source?${n}&${a}`)}catch(t){console.warn(t)}var s,i}_resetReTryVideoState=()=>{this.reTryVideoStateRetriesCount=0,this.videojs.clearTimeout(this.reTryVideoStateTimeoutId)};_handleRefresh=()=>{this.videojs.error(null);const t=this.currentPublicId()||this.currentSourceUrl();t&&this.source(t,this.playerOptions.sourceOptions||{})};_setVideoJsListeners(t){this.videojs.on(A.f.ERROR,()=>{const t=this.videojs.error();if(t){const e=this._isPlayerConfigValid&&this.videojs.cloudinary.currentSourceType();[3===t.code&&r().browser.IS_SAFARI,4===t.code].includes(!0)&&[A.x.AUDIO,A.x.VIDEO].includes(e)?this.isLiveStream?(this.videojs.error({code:x.bo.CUSTOM,message:"Live Stream not started"}),this.reloadVideoUntilAvailable()):(this.videojs.error(null),oe.A.handleCldError(this,this.playerOptions)):this._resetReTryVideoState()}}),this.videojs.tech_.on(A.f.RETRY_PLAYLIST,()=>{p()(this.videojs,"hls.stats.mediaRequestsErrored",0)>0&&(this._resetReTryVideoState(),oe.A.handleCldError(this,this.playerOptions))}),this.videojs.on(A.f.PLAY,this._resetReTryVideoState),this.videojs.on(A.f.CAN_PLAY_THROUGH,this._resetReTryVideoState),this.videojs.on(A.f.CLD_SOURCE_CHANGED,this._onSourceChange.bind(this)),this.videojs.on(A.f.REFRESH,this._handleRefresh.bind(this)),this.videojs.ready(()=>{this._onReady(),this._applyVolumeBarAriaLiveFix(),t&&t(this)})}_initPlugins(){this._initIma(),this._initAutoplay(),this._initContextMenu(),this._initPerSrcBehaviors(),this._initCloudinary(),this._initAnalytics(),this._initCloudinaryAnalytics(),this._initFloatingPlayer(),this._initVisualSearch(),this._initShare(),this._initColors(),this._initTextTracks(),this._initHighlightsGraph(),this._initSeekThumbs(),this._initChapters(),this._initInteractionAreas(),this._initSourceSwitcher()}_isFullScreen(){return this.videojs.player().isFullscreen()}_initIma(){this.playerOptions.ads&&0!==Object.keys(this.playerOptions.ads).length&&ae.imaPlugin(this.videojs,this.playerOptions)}setTextTracks(t){if(this.textTracksManager.removeAllTextTracks(),t){const e=Object.keys(t),s=[];for(const i of e)if("options"!==i){const e=Array.isArray(t[i])?t[i]:[t[i]];for(const t of e)s.push({...t,kind:i,label:t.label,srclang:t.language,default:!!t.default,src:t.url})}this.textTracksManager.addTextTracks(s),t.options&&this.videojs.styledTextTracks&&this.videojs.styledTextTracks(t.options)}}_initSeekThumbs(){this.playerOptions.seekThumbnails&&this.videojs.on(A.f.CLD_SOURCE_CHANGED,(t,e)=>{let{source:s}=e;if(!s||s.getType()===A.x.AUDIO||"live"===s.resourceConfig().type||(0,x.iT)(s.publicId())||this.videojs.activePlugins_&&this.videojs.activePlugins_.vr)return;const i=s.publicId(),r=(0,x.hS)(Object.assign({},s.transformation())),n=[...Array.isArray(r)?r:[r],{flags:["sprite"]}],a=s.config().url(`${i}.vtt`,{transformation:n}).replace(/\.json$/,""),o=(0,R.N)(a,s.queryParams());y()(this.videojs.vttThumbnails)?this.videojs.vttThumbnails({src:o}):this.videojs.vttThumbnails.src(o)})}_initHighlightsGraph(){this.playerOptions.aiHighlightsGraph&&this.videojs.on(A.f.CLD_SOURCE_CHANGED,(t,e)=>{let{source:s}=e;if(!s||s.getType()===A.x.AUDIO||(0,x.iT)(s.publicId()))return;const i=s.publicId(),r=g()(s.transformation(),["start_offset","end_offset","duration"]),n=Object.assign({},r);n.effect="preview",n.flags=n.flags||[],n.flags.push("getinfo");const a=s.config().url(`${i}`,{transformation:n}).replace(/\.json$/,""),o=(0,R.N)(a,s.queryParams());y()(this.videojs.aiHighlightsGraph)?this.videojs.aiHighlightsGraph({src:o}):this.videojs.aiHighlightsGraph.src(o)})}_initChapters(){!this.playerOptions.chaptersButton&&this.videojs.controlBar&&this.videojs.controlBar.removeChild("chaptersButton"),this.videojs.on(A.f.CLD_SOURCE_CHANGED,(t,e)=>{let{source:s}=e;d()(s?._chapters)&&!0!==s?._chapters||!this.videojs.chapters?this.videojs.chapters?.resetPlugin&&this.videojs.chapters.resetPlugin():y()(this.videojs.chapters)?this.videojs.chapters(s._chapters):this.videojs.chapters.src(s._chapters)})}_initInteractionAreas(){this.videojs.on(A.f.READY,async()=>{this.options.videojsOptions.interactionDisplay&&this.videojs.interactionAreas&&this.videojs.interactionAreas(this,this.playerOptions,this._videojsOptions)})}_initVisualSearch(){this.videojs.on(A.f.CLD_SOURCE_CHANGED,(t,e)=>{let{source:s}=e;s?._visualSearch&&this.videojs.visualSearch?y()(this.videojs.visualSearch)?this.videojs.visualSearch(s._visualSearch):this.videojs.visualSearch.createSearchUI(s._visualSearch):!s?._visualSearch&&this.videojs.visualSearch?.clearUI&&this.videojs.visualSearch.clearUI()})}_initShare(){this.videojs.on(A.f.CLD_SOURCE_CHANGED,(t,e)=>{let{source:s}=e;this.videojs.share&&(s?._download&&y()(this.videojs.share)&&this.videojs.share({download:!0}),y()(this.videojs.share)||(s?._download?this.videojs.share.addDownloadButton?.():this.videojs.share.removeDownloadButton?.()))})}_initColors(){this.playerOptions.colors&&this.videojs.colors({colors:this.playerOptions.colors})}_initTextTracks(){this.textTracksManager=this.videojs.textTracksManager(),this.videojs.on(A.f.CLD_SOURCE_CHANGED,(t,e)=>{let{source:s}=e;s?._textTracks&&this.setTextTracks(s._textTracks)})}_initPerSrcBehaviors(){this.videojs.perSourceBehaviors&&this.videojs.perSourceBehaviors()}_initJumpButtons(){!this.playerOptions.showJumpControls&&this.videojs.controlBar&&(this.videojs.controlBar.removeChild("JumpForwardButton"),this.videojs.controlBar.removeChild("JumpBackButton"))}_initPictureInPicture(){!this.playerOptions.pictureInPictureToggle&&this.videojs.controlBar&&this.videojs.controlBar.removeChild("pictureInPictureToggle")}_initBigPauseButton(){(r().browser.IS_IOS||r().browser.IS_ANDROID)&&this.videojs.addChild("BigPauseButton")}_initCloudinary(){const t=this.playerOptions.cloudinary;t.chainTarget=this,!1!==t.secure&&(0,x.lP)(t,{secure:!0});const e={cloudinaryConfig:t,...this.playerOptions.sourceOptions};this.videojs.cloudinary(e)}_initAnalytics(){const t=this.playerOptions.analytics;if(window.gtag||!t){if(t){const e="object"==typeof t?t:{};this.videojs.analytics(e)}}else console.error("Google Analytics script (gtag) is missing.")}_initCloudinaryAnalytics(){if(this.playerOptions.cloudinaryAnalytics){this.videojs.videoElement=this.videoElement;const t=b()(this.playerOptions.cloudinaryAnalytics)?this.playerOptions.cloudinaryAnalytics:{};this.videojs.cloudinaryAnalytics(t)}}_initSourceSwitcher(){if(this.sourceSwitcher=this.videojs.sourceSwitcher(),this.videojs.on(A.f.CLD_SOURCE_CHANGED,(t,e)=>{let{source:s}=e;const i=s.videoSources?.(),r=!!Array.isArray(i)&&!!i.length;if(this.videojs.controlBar){const t=r?"show":"hide",e=this.videojs.controlBar.getChild("sourceSwitcherButton");e&&"function"==typeof e?.[t]&&e[t]()}if(r){const t=i.findIndex(t=>{let{publicId:e}=t;return e===s.publicId()});this.sourceSwitcher.reInit({sources:i,selectedIndex:-1===t?0:t,onSourceChange:t=>{let{publicId:e,...s}=t;return this.source(e,{...s,videoSources:i})}})}}),Array.isArray(this.playerOptions.sourceOptions?.videoSources)&&this.playerOptions.sourceOptions?.videoSources.length){const{publicId:t,label:e,...s}=this.playerOptions.sourceOptions.videoSources[0];this.source(t,{...s,videoSources:this.playerOptions.sourceOptions.videoSources})}}reTryVideoStateUntilAvailable(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Number.POSITIVE_INFINITY,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3;if("number"!=typeof this.reTryVideoStateRetriesCount&&(this.reTryVideoStateRetriesCount=0),this.videojs.readyState()>=(/iPad|iPhone|iPod/.test(navigator.userAgent)?1:4))this.reTryVideoStateRetriesCount=0;else if(this.reTryVideoStateRetriesCount<t)this.reTryVideoStateRetriesCount++,this.reTryVideoStateTimeoutId=this.videojs.setTimeout(()=>this.reTryVideoStateUntilAvailable(t,e),e);else{let t=new Error("Video is not ready please try later");this.videojs.trigger("error",t)}}_resetReloadVideo=()=>{this.reloadVideoRetriesCount=0,this.videojs.clearTimeout(this.reloadVideoTimeoutId)};reloadVideoUntilAvailable(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Number.POSITIVE_INFINITY,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3;"number"!=typeof this.reloadVideoRetriesCount&&(this.reloadVideoRetriesCount=0),this.reloadVideoRetriesCount<t?(this.reloadVideoRetriesCount++,this.reloadVideoTimeoutId=this.videojs.setTimeout(()=>{const s=this.currentSourceUrl();(function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"default";return new Promise((s,i)=>{const r=document.createElement("video");r.setAttribute("crossorigin","anonymous");const n="live"===e?"onprogress":"canplay";r[n]=()=>{r.onerror=null,r[n]=null,s()},r.onerror=()=>i(),r.src=t,r.load()})})(s,this.isLiveStream?"live":"default").then(()=>this.source(s)).catch(()=>this.reloadVideoUntilAvailable(t,e))},e)):this.videojs.trigger("error",new Error("Sorry, we could not load your video"))}_initAutoplay(){"on-scroll"===this.playerOptions.autoplayMode&&this.videojs.autoplayOnScroll()}_initContextMenu(){this.playerOptions.hideContextMenu||this.videojs.contextMenu(le.A.contextMenu)}_initFloatingPlayer(){this.playerOptions.floatingWhenNotVisible!==mt.rT.NONE&&this.videojs.floatingPlayer({floatTo:this.playerOptions.floatingWhenNotVisible})}_setCssClasses(){this.videojs.addClass(oe.A.CLASS_PREFIX),this.videojs.addClass(oe.A.playerClassPrefix(this.videojs)),oe.A.setSkinClassPrefix(this.videojs,oe.A.skinClassPrefix(this.videojs))}_onReady(){this._setExtendedEvents();const t=this.playerOptions.sourceOptions.source||this.playerOptions.sourceOptions.publicId;if(t){const e=Object.assign({},this.playerOptions.sourceOptions);this.source(t,e)}}_applyVolumeBarAriaLiveFix(){const t=this.videojs.$(".vjs-volume-bar");t&&t.removeAttribute("aria-live")}_onSourceChange(t,e){let{source:s,sourceOptions:i}=e;this._sendInternalAnalytics({...i&&{sourceOptions:i}}),this.isLiveStream="live"===s?.resourceConfig()?.type}_setExtendedEvents(){const t=[];this.playerOptions.playedEventPercents&&t.push({type:A.f.PERCENTS_PLAYED,percents:this.playerOptions.playedEventPercents}),this.playerOptions.playedEventTimes&&t.push({type:A.f.TIME_PLAYED,times:this.playerOptions.playedEventTimes});const e=new at(this.videojs,{events:t});Object.keys(e.events).forEach(t=>{e.on(t,(e,s)=>{this.videojs.trigger({type:t,eventData:s})})})}cloudinaryConfig(t){return this.videojs.cloudinary.cloudinaryConfig(t)}currentPublicId(){return this.videojs.cloudinary.currentPublicId()}currentSourceUrl(){return this.videojs.currentSource().src}currentPoster(){return this.videojs.cloudinary.currentPoster()}source(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(({publicId:t,options:e}=(0,x.a5)(t,e)),!this._isPlayerConfigValid)return;if(this.playerOptions.debug&&(e.debug=!0,(0,ce.Is)(e).then(t=>{t||this.videojs.error("invalid source configuration")})),t instanceof yt.A)return this.videojs.cloudinary.source(t,e);e={...this.playerOptions.sourceOptions||{},...e},e.shoppable&&this.videojs.shoppable&&this.videojs.shoppable(this.videojs,e),this._resetReloadVideo(),this._resetReTryVideoState();const s=this.videojs.options_.maxTries||3,i=this.videojs.options_.videoTimeout||55e3;return this.reTryVideoStateUntilAvailable(s,i),this.videojs.cloudinary.source(t,e)}posterOptions(t){return this.videojs.cloudinary.posterOptions(t)}skin(t){return void 0!==t&&T()(t)&&oe.A.setSkinClassPrefix(this.videojs,t),oe.A.skinClassPrefix(this.videojs)}playlist(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.playerOptions.playlistWidget={...this.playerOptions.playlistWidget||{show:!1},playlist:!0},e=Object.assign({},e,{playlistWidget:this.playerOptions.playlistWidget}),this.videojs.one(A.f.READY,async()=>{(await this.videojs.playlist(e))(t,e)}),this.videojs.cloudinary.playlist?this.videojs.cloudinary.playlist(t,e):this}playlistByTag(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.playerOptions.playlistWidget={...this.playerOptions.playlistWidget||{show:!1},playlistByTag:!0},e=Object.assign({},e,{playlistWidget:this.playerOptions.playlistWidget}),new Promise(s=>{this.videojs.one(A.f.READY,async()=>{(await this.videojs.playlist(e))(await this.sourcesByTag(t,e),e),s(this)})})}sourcesByTag(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.videojs.cloudinary.sourcesByTag(t,e)}fluid(t){return void 0===t?this.videojs.fluid():(t?this.videojs.addClass(mt.gi):this.videojs.removeClass(mt.gi),this.videojs.fluid(t),this.videojs.trigger(A.f.FLUID,t),this)}play(){return this.playWasCalled=!0,this.videojs.play(),this}stop(){return this.pause(),this.currentTime(0),this}playPrevious(){return this.playlist().playPrevious(),this}playNext(){return this.playlist().playNext(),this}transformation(t){return this.videojs.cloudinary.transformation(t)}sourceTypes(t){return this.videojs.cloudinary.sourceTypes(t)}sourceTransformation(t){return this.videojs.cloudinary.sourceTransformation(t)}autoShowRecommendations(t){return this.videojs.cloudinary.autoShowRecommendations(t)}duration(){return this.videojs.duration()}height(t){return t?(this.videojs.height(t),this):this.videojs.height()}width(t){return t?(this.videojs.width(t),this):this.videojs.width()}volume(t){return t?(this.videojs.volume(t),this):this.videojs.volume()}mute(){return this.isMuted()||this.videojs.muted(!0),this}unmute(){return this.isMuted()&&this.videojs.muted(!1),this}isMuted(){return this.videojs.muted()}pause(){return this.videojs.pause(),this}currentTime(t){return t||0===t?(this.videojs.currentTime(t),this):this.videojs.currentTime()}maximize(){return this.isMaximized()||this.videojs.requestFullscreen(),this}exitMaximize(){return this.isMaximized()&&this.videojs.exitFullscreen(),this}isMaximized(){return this.videojs.isFullscreen()}dispose(){this.videojs.dispose()}controls(t){return void 0===t?this.videojs.controls():(this.videojs.controls(t),this)}ima(){return{playAd:this.videojs.ima.playAd}}loop(t){return void 0===t?this.videojs.loop():(this.videojs.loop(t),this)}el(){return this.videojs.el()}}const ye=me;var ve=s(6606);const be=t=>!!ve.defaultProfiles.find(e=>{let{name:s}=e;return t===s}),_e=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=(0,he.iG)(t);return{videoElement:s,options:(0,he.Wi)(s,e)}},Te=t=>r().obj.merge({},le.A,t),Ae=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;const{videoElement:i,options:r}=_e(t,e);return r.profile&&console.warn("Profile option requires async initialization. Use cloudinary.player() instead of cloudinary.videoPlayer()"),new ye(i,Te(r),s)},Ee=(t,e,s)=>[...document.querySelectorAll(t)].map(t=>Ae(t,e,s)),Se=async(t,e,s)=>{const{videoElement:i,options:r}=_e(t,e);try{const t=await(async t=>{const e=await(async t=>{const{profile:e,publicId:s,cloudinaryConfig:i,type:r="upload",videoConfig:n,allowUsageReport:a=!0}=t;if(e&&be(e))return(t=>{const e=ve.defaultProfiles.find(e=>{let{name:s}=e;return t===s});if(!e)throw new Error(`Default profile with name ${t} does not exist`);return e.config})(e);const o=(0,x.k$)(i)+"/_applet_/video_service",l=a?{_s:"vp-3.12.1"}:null;let h;if(e)h=(0,x.iT)(e)?e:(0,R.N)(`${o}/video_player_profiles/${e.replaceAll(" ","+")}.json`,l);else{if(!s||!1===n)return{};h=(0,R.N)(`${o}/video_player_config/video/${r}/${(0,P.G)(s)}.json`,l)}return fetch(h,{method:"GET"}).then(t=>t.ok?t.json():{})})(t),s=e.playerOptions?Object.keys(e.playerOptions):[],i={_internalAnalyticsMetadata:{newPlayerMethod:!0,...t.profile?{profile:!be(t.profile)||t.profile}:{},...!t.profile&&!1!==t.videoConfig&&t.publicId?{videoConfig:!0}:{},...s.length>0?{fetchedConfig:s.join(",")}:{}}};return Object.assign({},e.playerOptions||{},e.sourceOptions||{},t,i)})(r);return new ye(i,Te(t),s)}catch(t){throw new ye(i,Te(r)).videojs.error("Invalid profile"),t}},Ce=async(t,e,s)=>{const i=document.querySelectorAll(t);return Promise.all([...i].map(t=>Se(t,e,s)))},ke={...window.cloudinary||{},videoPlayer:Ae,videoPlayers:Ee,player:Se,players:Ce,Cloudinary:{new:()=>(console.warn("Cloudinary.new() is deprecated and will be removed. Please use cloudinary.videoPlayer() instead."),{videoPlayer:Ae,videoPlayers:Ee})}};window.cloudinary=ke;const we=ke},8592:(t,e,s)=>{s.d(e,{$n:()=>i,Lp:()=>n,mM:()=>r});const i={fastStart:{capLevelToPlayerSize:!0,ignoreDevicePixelRatio:!0,maxDevicePixelRatio:2,abrEwmaDefaultEstimate:4194304,abrEwmaDefaultEstimateMax:4194304,enableWorker:!1,startLevel:0},balanced:{capLevelToPlayerSize:!0,ignoreDevicePixelRatio:!0,maxDevicePixelRatio:2,abrEwmaDefaultEstimate:4194304,abrEwmaDefaultEstimateMax:4194304,enableWorker:!1},highQuality:{capLevelToPlayerSize:!0,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:2,abrEwmaDefaultEstimate:4194304,abrEwmaDefaultEstimateMax:4194304,enableWorker:!1}},r=Object.keys(i),n=window.matchMedia&&window.matchMedia("(dynamic-range: high)").matches},833:(t,e,s)=>{s.d(e,{default:()=>dl});const i=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},r=Number.isSafeInteger||function(t){return"number"==typeof t&&Math.abs(t)<=n},n=Number.MAX_SAFE_INTEGER||9007199254740991;let a=function(t){return t.NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError",t}({}),o=function(t){return t.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",t.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",t.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",t.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",t.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR="keySystemDestroyMediaKeysError",t.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR="keySystemDestroyCloseSessionError",t.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR="keySystemDestroyRemoveSessionError",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_PARSING_ERROR="levelParsingError",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.FRAG_GAP="fragGap",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.ASSET_LIST_LOAD_ERROR="assetListLoadError",t.ASSET_LIST_LOAD_TIMEOUT="assetListLoadTimeout",t.ASSET_LIST_PARSING_ERROR="assetListParsingError",t.INTERSTITIAL_ASSET_ITEM_ERROR="interstitialAssetItemError",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.ATTACH_MEDIA_ERROR="attachMediaError",t.UNKNOWN="unknown",t}({}),l=function(t){return t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.MEDIA_ENDED="hlsMediaEnded",t.STALL_RESOLVED="hlsStallResolved",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFERED_TO_END="hlsBufferedToEnd",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.AUDIO_TRACK_UPDATED="hlsAudioTrackUpdated",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_TRACK_UPDATED="hlsSubtitleTrackUpdated",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached",t.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",t.ASSET_LIST_LOADING="hlsAssetListLoading",t.ASSET_LIST_LOADED="hlsAssetListLoaded",t.INTERSTITIALS_UPDATED="hlsInterstitialsUpdated",t.INTERSTITIALS_BUFFERED_TO_BOUNDARY="hlsInterstitialsBufferedToBoundary",t.INTERSTITIAL_ASSET_PLAYER_CREATED="hlsInterstitialAssetPlayerCreated",t.INTERSTITIAL_STARTED="hlsInterstitialStarted",t.INTERSTITIAL_ASSET_STARTED="hlsInterstitialAssetStarted",t.INTERSTITIAL_ASSET_ENDED="hlsInterstitialAssetEnded",t.INTERSTITIAL_ASSET_ERROR="hlsInterstitialAssetError",t.INTERSTITIAL_ENDED="hlsInterstitialEnded",t.INTERSTITIALS_PRIMARY_RESUMED="hlsInterstitialsPrimaryResumed",t.PLAYOUT_LIMIT_REACHED="hlsPlayoutLimitReached",t.EVENT_CUE_ENTER="hlsEventCueEnter",t}({});var h="manifest",c="level",d="audioTrack",u="subtitleTrack",p="main",f="audio",g="subtitle";class m{constructor(t,e=0,s=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=s}sample(t,e){const s=Math.pow(this.alpha_,t);this.estimate_=e*(1-s)+s*this.estimate_,this.totalWeight_+=t}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_}}class y{constructor(t,e,s,i=100){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=s,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new m(t),this.fast_=new m(e),this.defaultTTFB_=i,this.ttfb_=new m(t)}update(t,e){const{slow_:s,fast_:i,ttfb_:r}=this;s.halfLife!==t&&(this.slow_=new m(t,s.getEstimate(),s.getTotalWeight())),i.halfLife!==e&&(this.fast_=new m(e,i.getEstimate(),i.getTotalWeight())),r.halfLife!==t&&(this.ttfb_=new m(t,r.getEstimate(),r.getTotalWeight()))}sample(t,e){const s=(t=Math.max(t,this.minDelayMs_))/1e3,i=8*e/s;this.fast_.sample(s,i),this.slow_.sample(s,i)}sampleTTFB(t){const e=t/1e3,s=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(s,Math.max(t,5))}canEstimate(){return this.fast_.getTotalWeight()>=this.minWeight_}getEstimate(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_}getEstimateTTFB(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_}get defaultEstimate(){return this.defaultEstimate_}destroy(){}}function v(t,e,s){return(e=function(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var s=t[Symbol.toPrimitive];if(void 0!==s){var i=s.call(t,e);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function b(){return b=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)({}).hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},b.apply(null,arguments)}function _(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),s.push.apply(s,i)}return s}function T(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?_(Object(s),!0).forEach(function(e){v(t,e,s[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):_(Object(s)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))})}return t}class A{constructor(t,e){this.trace=void 0,this.debug=void 0,this.log=void 0,this.warn=void 0,this.info=void 0,this.error=void 0;const s=`[${t}]:`;this.trace=E,this.debug=e.debug.bind(null,s),this.log=e.log.bind(null,s),this.warn=e.warn.bind(null,s),this.info=e.info.bind(null,s),this.error=e.error.bind(null,s)}}const E=function(){},S={trace:E,debug:E,log:E,warn:E,info:E,error:E};function C(){return b({},S)}function k(t,e,s){return e[t]?e[t].bind(e):function(t,e){const s=self.console[t];return s?s.bind(self.console,`${e?"["+e+"] ":""}[${t}] >`):E}(t,s)}const w=C(),L=w;function I(t=!0){if("undefined"!=typeof self)return(t||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function P(t,e){const s=Object.keys(t),i=Object.keys(e),r=s.length,n=i.length;return!r||!n||r===n&&!s.some(t=>-1===i.indexOf(t))}function x(t,e=!1){if("undefined"!=typeof TextDecoder){const s=new TextDecoder("utf-8").decode(t);if(e){const t=s.indexOf("\0");return-1!==t?s.substring(0,t):s}return s.replace(/\0/g,"")}const s=t.length;let i,r,n,a="",o=0;for(;o<s;){if(i=t[o++],0===i&&e)return a;if(0!==i&&3!==i)switch(i>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:a+=String.fromCharCode(i);break;case 12:case 13:r=t[o++],a+=String.fromCharCode((31&i)<<6|63&r);break;case 14:r=t[o++],n=t[o++],a+=String.fromCharCode((15&i)<<12|(63&r)<<6|63&n)}}return a}function R(t){let e="";for(let s=0;s<t.length;s++){let i=t[s].toString(16);i.length<2&&(i="0"+i),e+=i}return e}function D(t){return Uint8Array.from(t.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}function O(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var M,F={exports:{}},N=(M||(M=1,function(t){var e,s,i,r,n;e=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,i=/(?:\/|^)\.(?=\/)/g,r=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,n={buildAbsoluteURL:function(t,e,i){if(i=i||{},t=t.trim(),!(e=e.trim())){if(!i.alwaysNormalize)return t;var r=n.parseURL(t);if(!r)throw new Error("Error trying to parse base URL.");return r.path=n.normalizePath(r.path),n.buildURLFromParts(r)}var a=n.parseURL(e);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return i.alwaysNormalize?(a.path=n.normalizePath(a.path),n.buildURLFromParts(a)):e;var o=n.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=s.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var h={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(h.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var c=o.path,d=c.substring(0,c.lastIndexOf("/")+1)+a.path;h.path=n.normalizePath(d)}else h.path=o.path,a.params||(h.params=o.params,a.query||(h.query=o.query));return null===h.path&&(h.path=i.alwaysNormalize?n.normalizePath(a.path):a.path),n.buildURLFromParts(h)},parseURL:function(t){var s=e.exec(t);return s?{scheme:s[1]||"",netLoc:s[2]||"",path:s[3]||"",params:s[4]||"",query:s[5]||"",fragment:s[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(i,"");t.length!==(t=t.replace(r,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}},t.exports=n}(F)),F.exports);class B{constructor(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}}}var j="audio",$="video",U="audiovideo";class H{constructor(t){this._byteRange=null,this._url=null,this._stats=null,this._streams=null,this.base=void 0,this.relurl=void 0,"string"==typeof t&&(t={url:t}),this.base=t,function(t,e){const s=K(t,e);s&&(s.enumerable=!0,Object.defineProperty(t,e,s))}(this,"stats")}setByteRange(t,e){const s=t.split("@",2);let i;i=1===s.length?(null==e?void 0:e.byteRangeEndOffset)||0:parseInt(s[1]),this._byteRange=[i,parseInt(s[0])+i]}get baseurl(){return this.base.url}get byteRange(){return null===this._byteRange?[]:this._byteRange}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get elementaryStreams(){return null===this._streams&&(this._streams={[j]:null,[$]:null,[U]:null}),this._streams}set elementaryStreams(t){this._streams=t}get hasStats(){return null!==this._stats}get hasStreams(){return null!==this._streams}get stats(){return null===this._stats&&(this._stats=new B),this._stats}set stats(t){this._stats=t}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=N.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(t){this._url=t}clearElementaryStreamInfo(){const{elementaryStreams:t}=this;t[j]=null,t[$]=null,t[U]=null}}function V(t){return"initSegment"!==t.sn}class G extends H{constructor(t,e){super(e),this._decryptdata=null,this._programDateTime=null,this._ref=null,this._bitrate=void 0,this.rawProgramDateTime=null,this.tagList=[],this.duration=0,this.sn=0,this.levelkeys=void 0,this.type=void 0,this.loader=null,this.keyLoader=null,this.level=-1,this.cc=0,this.startPTS=void 0,this.endPTS=void 0,this.startDTS=void 0,this.endDTS=void 0,this.start=0,this.playlistOffset=0,this.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.data=void 0,this.bitrateTest=!1,this.title=null,this.initSegment=null,this.endList=void 0,this.gap=void 0,this.urlId=0,this.type=t}get byteLength(){if(this.hasStats){const t=this.stats.total;if(t)return t}if(this.byteRange.length){const t=this.byteRange[0],e=this.byteRange[1];if(i(t)&&i(e))return e-t}return null}get bitrate(){return this.byteLength?8*this.byteLength/this.duration:this._bitrate?this._bitrate:null}set bitrate(t){this._bitrate=t}get decryptdata(){var t;const{levelkeys:e}=this;if(!e||e.NONE)return null;if(e.identity)this._decryptdata||(this._decryptdata=e.identity.getDecryptData(this.sn));else if(null==(t=this._decryptdata)||!t.keyId){const t=Object.keys(e);if(1===t.length){const s=this._decryptdata=e[t[0]]||null;s&&(this._decryptdata=s.getDecryptData(this.sn,e))}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(null===this.programDateTime)return null;const t=i(this.duration)?this.duration:0;return this.programDateTime+1e3*t}get encrypted(){var t;if(null!=(t=this._decryptdata)&&t.encrypted)return!0;if(this.levelkeys){var e;const t=Object.keys(this.levelkeys),s=t.length;if(s>1||1===s&&null!=(e=this.levelkeys[t[0]])&&e.encrypted)return!0}return!1}get programDateTime(){return null===this._programDateTime&&this.rawProgramDateTime&&(this.programDateTime=Date.parse(this.rawProgramDateTime)),this._programDateTime}set programDateTime(t){i(t)?this._programDateTime=t:this._programDateTime=this.rawProgramDateTime=null}get ref(){return V(this)?(this._ref||(this._ref={base:this.base,start:this.start,duration:this.duration,sn:this.sn,programDateTime:this.programDateTime}),this._ref):null}addStart(t){this.setStart(this.start+t)}setStart(t){this.start=t,this._ref&&(this._ref.start=t)}setDuration(t){this.duration=t,this._ref&&(this._ref.duration=t)}setKeyFormat(t){const e=this.levelkeys;if(e){var s;const i=e[t];!i||null!=(s=this._decryptdata)&&s.keyId||(this._decryptdata=i.getDecryptData(this.sn,e))}}abortRequests(){var t,e;null==(t=this.loader)||t.abort(),null==(e=this.keyLoader)||e.abort()}setElementaryStreamInfo(t,e,s,i,r,n=!1){const{elementaryStreams:a}=this,o=a[t];o?(o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,s),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,r)):a[t]={startPTS:e,endPTS:s,startDTS:i,endDTS:r,partial:n}}}class W extends H{constructor(t,e,s,i,r){super(s),this.fragOffset=0,this.duration=0,this.gap=!1,this.independent=!1,this.relurl=void 0,this.fragment=void 0,this.index=void 0,this.duration=t.decimalFloatingPoint("DURATION"),this.gap=t.bool("GAP"),this.independent=t.bool("INDEPENDENT"),this.relurl=t.enumeratedString("URI"),this.fragment=e,this.index=i;const n=t.enumeratedString("BYTERANGE");n&&this.setByteRange(n,r),r&&(this.fragOffset=r.fragOffset+r.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:t}=this;return!!(t.audio||t.video||t.audiovideo)}}function K(t,e){const s=Object.getPrototypeOf(t);if(s){return Object.getOwnPropertyDescriptor(s,e)||K(s,e)}}const z=Math.pow(2,32)-1,q=[].push,Y={video:1,audio:2,id3:3,text:4};function X(t){return String.fromCharCode.apply(null,t)}function Q(t,e){const s=t[e]<<8|t[e+1];return s<0?65536+s:s}function Z(t,e){const s=tt(t,e);return s<0?4294967296+s:s}function J(t,e){let s=Z(t,e);return s*=Math.pow(2,32),s+=Z(t,e+4),s}function tt(t,e){return t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}function et(t,e){const s=[];if(!e.length)return s;const i=t.byteLength;for(let r=0;r<i;){const n=Z(t,r),a=n>1?r+n:i;if(X(t.subarray(r+4,r+8))===e[0])if(1===e.length)s.push(t.subarray(r+8,a));else{const i=et(t.subarray(r+8,a),e.slice(1));i.length&&q.apply(s,i)}r=a}return s}function st(t){const e=[],s=t[0];let i=8;const r=Z(t,i);i+=4;let n=0,a=0;0===s?(n=Z(t,i),a=Z(t,i+4),i+=8):(n=J(t,i),a=J(t,i+8),i+=16),i+=2;let o=t.length+a;const l=Q(t,i);i+=2;for(let s=0;s<l;s++){let s=i;const n=Z(t,s);s+=4;const a=2147483647&n;if(1==(2147483648&n)>>>31)return L.warn("SIDX has hierarchical references (not supported)"),null;const l=Z(t,s);s+=4,e.push({referenceSize:a,subsegmentDuration:l,info:{duration:l/r,start:o,end:o+a-1}}),o+=a,s+=4,i=s}return{earliestPresentationTime:n,timescale:r,version:s,referencesCount:l,references:e}}function it(t){const e=[],s=et(t,["moov","trak"]);for(let t=0;t<s.length;t++){const i=s[t],r=et(i,["tkhd"])[0];if(r){let t=r[0];const s=Z(r,0===t?12:20),n=et(i,["mdia","mdhd"])[0];if(n){t=n[0];const r=Z(n,0===t?12:20),a=et(i,["mdia","hdlr"])[0];if(a){const t=X(a.subarray(8,12)),n={soun:j,vide:$}[t],o=rt(et(i,["mdia","minf","stbl","stsd"])[0]);n?(e[s]={timescale:r,type:n,stsd:o},e[n]=T({timescale:r,id:s},o)):e[s]={timescale:r,type:t,stsd:o}}}}}return et(t,["moov","mvex","trex"]).forEach(t=>{const s=Z(t,4),i=e[s];i&&(i.default={duration:Z(t,12),flags:Z(t,20)})}),e}function rt(t){const e=t.subarray(8),s=e.subarray(86),i=X(e.subarray(4,8));let r,n=i;const a="enca"===i||"encv"===i;if(a){const t=et(e,[i])[0];et(t.subarray("enca"===i?28:78),["sinf"]).forEach(t=>{const e=et(t,["schm"])[0];if(e){const s=X(e.subarray(4,8));if("cbcs"===s||"cenc"===s){const e=et(t,["frma"])[0];e&&(n=X(e))}}})}const o=n;switch(n){case"avc1":case"avc2":case"avc3":case"avc4":{const t=et(s,["avcC"])[0];t&&t.length>3&&(n+="."+ot(t[1])+ot(t[2])+ot(t[3]),r=nt("avc1"===o?"dva1":"dvav",s));break}case"mp4a":{const t=et(e,[i])[0],s=et(t.subarray(28),["esds"])[0];if(s&&s.length>7){let t=4;if(3!==s[t++])break;t=at(s,t),t+=2;const e=s[t++];if(128&e&&(t+=2),64&e&&(t+=s[t++]),4!==s[t++])break;t=at(s,t);const i=s[t++];if(64!==i)break;if(n+="."+ot(i),t+=12,5!==s[t++])break;t=at(s,t);const r=s[t++];let a=(248&r)>>3;31===a&&(a+=1+((7&r)<<3)+((224&s[t])>>5)),n+="."+a}break}case"hvc1":case"hev1":{const t=et(s,["hvcC"])[0];if(t&&t.length>12){const e=t[1],s=["","A","B","C"][e>>6],i=31&e,r=Z(t,2),a=(32&e)>>5?"H":"L",o=t[12],l=t.subarray(6,12);n+="."+s+i,n+="."+function(t){let e=0;for(let s=0;s<32;s++)e|=(t>>s&1)<<31-s;return e>>>0}(r).toString(16).toUpperCase(),n+="."+a+o;let h="";for(let t=l.length;t--;){const e=l[t];(e||h)&&(h="."+e.toString(16).toUpperCase()+h)}n+=h}r=nt("hev1"==o?"dvhe":"dvh1",s);break}case"dvh1":case"dvhe":case"dvav":case"dva1":case"dav1":n=nt(n,s)||n;break;case"vp09":{const t=et(s,["vpcC"])[0];if(t&&t.length>6){const e=t[4],s=t[5],i=t[6]>>4&15;n+="."+lt(e)+"."+lt(s)+"."+lt(i)}break}case"av01":{const t=et(s,["av1C"])[0];if(t&&t.length>2){const e=t[1]>>>5,i=31&t[1],a=t[2]>>>7?"H":"M",o=(64&t[2])>>6,l=(32&t[2])>>5,h=2===e&&o?l?12:10:o?10:8,c=(16&t[2])>>4,d=(8&t[2])>>3,u=(4&t[2])>>2,p=3&t[2],f=1,g=1,m=1,y=0;n+="."+e+"."+lt(i)+a+"."+lt(h)+"."+c+"."+d+u+p+"."+lt(f)+"."+lt(g)+"."+lt(m)+"."+y,r=nt("dav1",s)}break}}return{codec:n,encrypted:a,supplemental:r}}function nt(t,e){const s=et(e,["dvvC"]),i=s.length?s[0]:et(e,["dvcC"])[0];if(i){const e=i[2]>>1&127,s=i[2]<<5&32|i[3]>>3&31;return t+"."+lt(e)+"."+lt(s)}}function at(t,e){const s=e+5;for(;128&t[e++]&&e<s;);return e}function ot(t){return("0"+t.toString(16).toUpperCase()).slice(-2)}function lt(t){return(t<10?"0":"")+t}function ht(t,e){et(t,["moov","trak"]).forEach(t=>{const s=et(t,["mdia","minf","stbl","stsd"])[0];if(!s)return;const i=s.subarray(8);let r=et(i,["enca"]);const n=r.length>0;n||(r=et(i,["encv"])),r.forEach(t=>{et(n?t.subarray(28):t.subarray(78),["sinf"]).forEach(t=>{const s=ct(t);s&&e(s,n)})})})}function ct(t){const e=et(t,["schm"])[0];if(e){const s=X(e.subarray(4,8));if("cbcs"===s||"cenc"===s){const e=et(t,["schi","tenc"])[0];if(e)return e}}}function dt(t,e){const s=new Uint8Array(t.length+e.length);return s.set(t),s.set(e,t.length),s}function ut(t,e){const s=[],i=e.samples,r=e.timescale,n=e.id;let a=!1;return et(i,["moof"]).map(o=>{const l=o.byteOffset-8;et(o,["traf"]).map(o=>{const h=et(o,["tfdt"]).map(t=>{const e=t[0];let s=Z(t,4);return 1===e&&(s*=Math.pow(2,32),s+=Z(t,8)),s/r})[0];return void 0!==h&&(t=h),et(o,["tfhd"]).map(h=>{const c=Z(h,4),d=16777215&Z(h,0);let u=0;const p=!!(16&d);let f=0;const g=!!(32&d);let m=8;c===n&&(!!(1&d)&&(m+=8),!!(2&d)&&(m+=4),!!(8&d)&&(u=Z(h,m),m+=4),p&&(f=Z(h,m),m+=4),g&&(m+=4),"video"===e.type&&(a=pt(e.codec)),et(o,["trun"]).map(n=>{const o=n[0],h=16777215&Z(n,0),c=!!(1&h);let d=0;const p=!!(4&h),g=!!(256&h);let m=0;const y=!!(512&h);let v=0;const b=!!(1024&h),_=!!(2048&h);let T=0;const A=Z(n,4);let E=8;c&&(d=Z(n,E),E+=4),p&&(E+=4);let S=d+l;for(let l=0;l<A;l++){if(g?(m=Z(n,E),E+=4):m=u,y?(v=Z(n,E),E+=4):v=f,b&&(E+=4),_&&(T=0===o?Z(n,E):tt(n,E),E+=4),e.type===$){let e=0;for(;e<v;){const n=Z(i,S);S+=4,ft(a,i[S])&&gt(i.subarray(S,S+n),a?2:1,t+T/r,s),S+=n,e+=n+4}}t+=m/r}}))})})}),s}function pt(t){if(!t)return!1;const e=t.substring(0,4);return"hvc1"===e||"hev1"===e||"dvh1"===e||"dvhe"===e}function ft(t,e){if(t){const t=e>>1&63;return 39===t||40===t}return 6==(31&e)}function gt(t,e,s,i){const r=mt(t);let n=0;n+=e;let a=0,o=0,l=0;for(;n<r.length;){a=0;do{if(n>=r.length)break;l=r[n++],a+=l}while(255===l);o=0;do{if(n>=r.length)break;l=r[n++],o+=l}while(255===l);const t=r.length-n;let e=n;if(o<t)n+=o;else if(o>t){L.error(`Malformed SEI payload. ${o} is too small, only ${t} bytes left to parse.`);break}if(4===a){if(181===r[e++]){const t=Q(r,e);if(e+=2,49===t){const t=Z(r,e);if(e+=4,1195456820===t){const t=r[e++];if(3===t){const n=r[e++],o=64&n,l=o?2+3*(31&n):0,h=new Uint8Array(l);if(o){h[0]=n;for(let t=1;t<l;t++)h[t]=r[e++]}i.push({type:t,payloadType:a,pts:s,bytes:h})}}}}}else if(5===a&&o>16){const t=[];for(let s=0;s<16;s++){const i=r[e++].toString(16);t.push(1==i.length?"0"+i:i),3!==s&&5!==s&&7!==s&&9!==s||t.push("-")}const n=o-16,l=new Uint8Array(n);for(let t=0;t<n;t++)l[t]=r[e++];i.push({payloadType:a,pts:s,uuid:t.join(""),userData:x(l),userDataBytes:l})}}}function mt(t){const e=t.byteLength,s=[];let i=1;for(;i<e-2;)0===t[i]&&0===t[i+1]&&3===t[i+2]?(s.push(i+2),i+=2):i++;if(0===s.length)return t;const r=e-s.length,n=new Uint8Array(r);let a=0;for(i=0;i<r;a++,i++)a===s[0]&&(a++,s.shift()),n[i]=t[a];return n}function yt(t){const e=t.getUint32(0),s=t.byteOffset,i=t.byteLength;if(i<e)return{offset:s,size:i};if(1886614376!==t.getUint32(4))return{offset:s,size:e};const r=t.getUint32(8)>>>24;if(0!==r&&1!==r)return{offset:s,size:e};const n=t.buffer,a=R(new Uint8Array(n,s+12,16));let o=null,l=null,h=0;if(0===r)h=28;else{const r=t.getUint32(28);if(!r||i<32+16*r)return{offset:s,size:e};o=[];for(let t=0;t<r;t++)o.push(new Uint8Array(n,s+32+16*t,16));h=32+16*r}if(!h)return{offset:s,size:e};const c=t.getUint32(h);return e-32<c?{offset:s,size:e}:(l=new Uint8Array(n,s+h+4,c),{version:r,systemId:a,kids:o,data:l,offset:s,size:e})}const vt=()=>/\(Windows.+Firefox\//i.test(navigator.userAgent),bt={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,dav1:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function _t(t,e){const s=bt[e];return!!s&&!!s[t.slice(0,4)]}function Tt(t,e,s=!0){return!t.split(",").some(t=>!At(t,e,s))}function At(t,e,s=!0){var i;const r=I(s);return null!=(i=null==r?void 0:r.isTypeSupported(Et(t,e)))&&i}function Et(t,e){return`${e}/mp4;codecs=${t}`}function St(t){if(t){const e=t.substring(0,4);return bt.video[e]}return 2}function Ct(t){const e=vt();return t.split(",").reduce((t,s)=>{const i=e&&pt(s)?9:bt.video[s];return i?(2*i+t)/(t?3:2):(bt.audio[s]+t)/(t?2:1)},0)}const kt={},wt=/flac|opus|mp4a\.40\.34/i;function Lt(t,e=!0){return t.replace(wt,t=>function(t,e=!0){if(kt[t])return kt[t];const s={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"],"mp4a.40.34":["mp3"]}[t];for(let r=0;r<s.length;r++){var i;if(At(s[r],"audio",e))return kt[t]=s[r],s[r];if("mp3"===s[r]&&null!=(i=I(e))&&i.isTypeSupported("audio/mpeg"))return""}return t}(t.toLowerCase(),e))}function It(t,e){if(t&&(t.length>4||-1!==["ac-3","ec-3","alac","fLaC","Opus"].indexOf(t))&&(Pt(t,"audio")||Pt(t,"video")))return t;if(e){const s=e.split(",");if(s.length>1){if(t)for(let e=s.length;e--;)if(s[e].substring(0,4)===t.substring(0,4))return s[e];return s[0]}}return e||t}function Pt(t,e){return _t(t,e)&&At(t,e)}function xt(t){if(t.startsWith("av01.")){const e=t.split("."),s=["0","111","01","01","01","0"];for(let t=e.length;t>4&&t<10;t++)e[t]=s[t-4];return e.join(".")}return t}function Rt(t){const e=I(t)||{isTypeSupported:()=>!1};return{mpeg:e.isTypeSupported("audio/mpeg"),mp3:e.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:e.isTypeSupported('audio/mp4; codecs="ac-3"')}}function Dt(t){return t.replace(/^.+codecs=["']?([^"']+).*$/,"$1")}const Ot={supported:!1,smooth:!1,powerEfficient:!1},Mt={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]};function Ft(t,e){return{supported:!1,configurations:e,decodingInfoResults:[Ot],error:t}}function Nt(t,e,s,r,n,a){const o=t.videoCodec,l=t.audioCodec?t.audioGroups:null,h=null==a?void 0:a.audioCodec,c=null==a?void 0:a.channels,d=c?parseInt(c):h?1/0:2;let u=null;if(null!=l&&l.length)try{u=1===l.length&&l[0]?e.groups[l[0]].channels:l.reduce((t,s)=>{if(s){const i=e.groups[s];if(!i)throw new Error(`Audio track group ${s} not found`);Object.keys(i.channels).forEach(e=>{t[e]=(t[e]||0)+i.channels[e]})}return t},{2:0})}catch(t){return!0}return void 0!==o&&(o.split(",").some(t=>pt(t))||t.width>1920&&t.height>1088||t.height>1920&&t.width>1088||t.frameRate>Math.max(r,30)||"SDR"!==t.videoRange&&t.videoRange!==s||t.bitrate>Math.max(n,8e6))||!!u&&i(d)&&Object.keys(u).some(t=>parseInt(t)>d)}function Bt(t,e,s,i={}){const r=t.videoCodec;if(!r&&!t.audioCodec||!s)return Promise.resolve(Mt);const n=[],a=function(t){var e;const s=null==(e=t.videoCodec)?void 0:e.split(","),i=$t(t),r=t.width||640,n=t.height||480,a=t.frameRate||30,o=t.videoRange.toLowerCase();return s?s.map(t=>{const e={contentType:Et(xt(t),"video"),width:r,height:n,bitrate:i,framerate:a};return"sdr"!==o&&(e.transferFunction=o),e}):[]}(t),o=a.length,l=function(t,e,s){var i;const r=null==(i=t.audioCodec)?void 0:i.split(","),n=$t(t);return r&&t.audioGroups?t.audioGroups.reduce((t,i)=>{var a;const o=i?null==(a=e.groups[i])?void 0:a.tracks:null;return o?o.reduce((t,e)=>{if(e.groupId===i){const i=parseFloat(e.channels||"");r.forEach(e=>{const r={contentType:Et(e,"audio"),bitrate:s?jt(e,n):n};i&&(r.channels=""+i),t.push(r)})}return t},t):t},[]):[]}(t,e,o>0),h=l.length;for(let t=o||1*h||1;t--;){const e={type:"media-source"};if(o&&(e.video=a[t%o]),h){e.audio=l[t%h];const s=e.audio.bitrate;e.video&&s&&(e.video.bitrate-=s)}n.push(e)}if(r){const t=navigator.userAgent;if(r.split(",").some(t=>pt(t))&&vt())return Promise.resolve(Ft(new Error(`Overriding Windows Firefox HEVC MediaCapabilities result based on user-agent string: (${t})`),n))}return Promise.all(n.map(t=>{const e=function(t){let e="";const{audio:s,video:i}=t;return i&&(e+=`${Dt(i.contentType)}_r${i.height}x${i.width}f${Math.ceil(i.framerate)}${i.transferFunction||"sd"}_${Math.ceil(i.bitrate/1e5)}`),s&&(e+=`${i?"_":""}${Dt(s.contentType)}_c${s.channels}`),e}(t);return i[e]||(i[e]=s.decodingInfo(t))})).then(t=>({supported:!t.some(t=>!t.supported),configurations:n,decodingInfoResults:t})).catch(t=>({supported:!1,configurations:n,decodingInfoResults:[],error:t}))}function jt(t,e){if(e<=1)return 1;let s=128e3;return"ec-3"===t?s=768e3:"ac-3"===t&&(s=64e4),Math.min(e/2,s)}function $t(t){return 1e3*Math.ceil(Math.max(.9*t.bitrate,t.averageBitrate)/1e3)||1}const Ut=["NONE","TYPE-0","TYPE-1",null],Ht=["SDR","PQ","HLG"];function Vt(t){const{canSkipUntil:e,canSkipDateRanges:s,age:i}=t;return e&&i<e/2?s?"v2":"YES":""}class Gt{constructor(t,e,s){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=s}addDirectives(t){const e=new self.URL(t);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href}}class Wt{constructor(t){if(this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.supplemental=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=[t.videoCodec,t.audioCodec].filter(t=>!!t).map(t=>t.substring(0,4)).join(","),"supplemental"in t){var e;this.supplemental=t.supplemental;const s=null==(e=t.supplemental)?void 0:e.videoCodec;s&&s!==t.videoCodec&&(this.codecSet+=`,${s.substring(0,4)}`)}this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)}get maxBitrate(){return Math.max(this.realBitrate,this.bitrate)}get averageBitrate(){return this._avgBitrate||this.realBitrate||this.bitrate}get attrs(){return this._attrs[0]}get codecs(){return this.attrs.CODECS||""}get pathwayId(){return this.attrs["PATHWAY-ID"]||"."}get videoRange(){return this.attrs["VIDEO-RANGE"]||"SDR"}get score(){return this.attrs.optionalFloat("SCORE",0)}get uri(){return this.url[0]||""}hasAudioGroup(t){return Kt(this._audioGroups,t)}hasSubtitleGroup(t){return Kt(this._subtitleGroups,t)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(t,e){if(e)if("audio"===t){let t=this._audioGroups;t||(t=this._audioGroups=[]),-1===t.indexOf(e)&&t.push(e)}else if("text"===t){let t=this._subtitleGroups;t||(t=this._subtitleGroups=[]),-1===t.indexOf(e)&&t.push(e)}}get urlId(){return 0}set urlId(t){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var t;return null==(t=this.audioGroups)?void 0:t[0]}get textGroupId(){var t;return null==(t=this.subtitleGroups)?void 0:t[0]}addFallback(){}}function Kt(t,e){return!(!e||!t)&&-1!==t.indexOf(e)}const zt=(t,e)=>JSON.stringify(t,(t=>{const e=new WeakSet;return(s,i)=>{if(t&&(i=t(s,i)),"object"==typeof i&&null!==i){if(e.has(i))return;e.add(i)}return i}})(e));function qt(t,e){L.log(`[abr] start candidates with "${t}" ignored because ${e}`)}function Yt(t){return t.reduce((t,e)=>{let s=t.groups[e.groupId];s||(s=t.groups[e.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),s.tracks.push(e);const i=e.channels||"2";return s.channels[i]=(s.channels[i]||0)+1,s.hasDefault=s.hasDefault||e.default,s.hasAutoSelect=s.hasAutoSelect||e.autoselect,s.hasDefault&&(t.hasDefaultAudio=!0),s.hasAutoSelect&&(t.hasAutoSelectAudio=!0),t},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function Xt(t){if(!t)return t;const{lang:e,assocLang:s,characteristics:i,channels:r,audioCodec:n}=t;return{lang:e,assocLang:s,characteristics:i,channels:r,audioCodec:n}}function Qt(t,e,s){if("attrs"in t){const s=e.indexOf(t);if(-1!==s)return s}for(let i=0;i<e.length;i++)if(Zt(t,e[i],s))return i;return-1}function Zt(t,e,s){const{groupId:i,name:r,lang:n,assocLang:a,default:o}=t,l=t.forced;return(void 0===i||e.groupId===i)&&(void 0===r||e.name===r)&&(void 0===n||function(t,e="--"){return t.length===e.length?t===e:t.startsWith(e)||e.startsWith(t)}(n,e.lang))&&(void 0===n||e.assocLang===a)&&(void 0===o||e.default===o)&&(void 0===l||e.forced===l)&&(!("characteristics"in t)||function(t,e=""){const s=t.split(","),i=e.split(",");return s.length===i.length&&!s.some(t=>-1===i.indexOf(t))}(t.characteristics||"",e.characteristics))&&(void 0===s||s(t,e))}function Jt(t,e){const{audioCodec:s,channels:i}=t;return!(void 0!==s&&(e.audioCodec||"").substring(0,4)!==s.substring(0,4)||void 0!==i&&i!==(e.channels||"2"))}function te(t,e,s){for(let i=e;i>-1;i--)if(s(t[i]))return i;for(let i=e+1;i<t.length;i++)if(s(t[i]))return i;return-1}function ee(t,e){var s;return!!t&&t!==(null==(s=e.loadLevelObj)?void 0:s.uri)}const se=function(t,e){let s=0,i=t.length-1,r=null,n=null;for(;s<=i;){r=(s+i)/2|0,n=t[r];const a=e(n);if(a>0)s=r+1;else{if(!(a<0))return n;i=r-1}}return null};function ie(t,e,s=0,i=0,r=.005){let n=null;if(t){n=e[1+t.sn-e[0].sn]||null;const i=t.endDTS-s;i>0&&i<15e-7&&(s+=15e-7),n&&t.level!==n.level&&n.end<=t.end&&(n=e[2+t.sn-e[0].sn]||null)}else 0===s&&0===e[0].start&&(n=e[0]);if(n&&((!t||t.level===n.level)&&0===re(s,i,n)||function(t,e,s){if(e&&0===e.start&&e.level<t.level&&(e.endPTS||0)>0){const i=e.tagList.reduce((t,e)=>("INF"===e[0]&&(t+=parseFloat(e[1])),t),s);return t.start<=i}return!1}(n,t,Math.min(r,i))))return n;const a=se(e,re.bind(null,s,i));return!a||a===t&&n?n:a}function re(t=0,e=0,s){if(s.start<=t&&s.start+s.duration>t)return 0;const i=Math.min(e,s.duration+(s.deltaPTS?s.deltaPTS:0));return s.start+s.duration-i<=t?1:s.start-i>t&&s.start?-1:0}function ne(t,e,s){const i=1e3*Math.min(e,s.duration+(s.deltaPTS?s.deltaPTS:0));return(s.endProgramDateTime||0)-i>t}function ae(t,e,s){if(t&&t.startCC<=e&&t.endCC>=e){let i=t.fragments;const{fragmentHint:r}=t;let n;return r&&(i=i.concat(r)),se(i,t=>t.cc<e?1:t.cc>e?-1:(n=t,t.end<=s?1:t.start>s?-1:0)),n||null}return null}function oe(t){switch(t.details){case o.FRAG_LOAD_TIMEOUT:case o.KEY_LOAD_TIMEOUT:case o.LEVEL_LOAD_TIMEOUT:case o.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function le(t){return t.details.startsWith("key")}function he(t){return le(t)&&!!t.frag&&!t.frag.decryptdata}function ce(t,e){const s=oe(e);return t.default[(s?"timeout":"error")+"Retry"]}function de(t,e){const s="linear"===t.backoff?1:Math.pow(2,e);return Math.min(s*t.retryDelayMs,t.maxRetryDelayMs)}function ue(t){return T(T({},t),{errorRetry:null,timeoutRetry:null})}function pe(t,e,s,i){if(!t)return!1;const r=null==i?void 0:i.code,n=e<t.maxNumRetry&&(function(t){return fe(t)||!!t&&(t<400||t>499)}(r)||!!s);return t.shouldRetry?t.shouldRetry(t,e,s,i,n):n}function fe(t){return 0===t&&!1===navigator.onLine}function ge(t){const e={action:0,flags:0};return t&&(e.resolved=!0),e}var me="NOT_LOADED",ye="APPENDING",ve="PARTIAL",be="OK";class _e{constructor(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}_registerListeners(){const{hls:t}=this;t&&(t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.BUFFER_APPENDED,this.onBufferAppended,this),t.on(l.FRAG_BUFFERED,this.onFragBuffered,this),t.on(l.FRAG_LOADED,this.onFragLoaded,this))}_unregisterListeners(){const{hls:t}=this;t&&(t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.BUFFER_APPENDED,this.onBufferAppended,this),t.off(l.FRAG_BUFFERED,this.onFragBuffered,this),t.off(l.FRAG_LOADED,this.onFragLoaded,this))}destroy(){this._unregisterListeners(),this.hls=this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(t,e){const s=this.activePartLists[e];if(s)for(let e=s.length;e--;){const i=s[e];if(!i)break;if(i.start<=t&&t<=i.end&&i.loaded)return i}return this.getBufferedFrag(t,e)}getBufferedFrag(t,e){return this.getFragAtPos(t,e,!0)}getFragAtPos(t,e,s){const{fragments:i}=this,r=Object.keys(i);for(let n=r.length;n--;){const a=i[r[n]];if((null==a?void 0:a.body.type)===e&&(!s||a.buffered)){const e=a.body;if(e.start<=t&&t<=e.end)return e}}return null}detectEvictedFragments(t,e,s,i,r){this.timeRanges&&(this.timeRanges[t]=e);const n=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach(i=>{const a=this.fragments[i];if(!a)return;if(n>=a.body.sn)return;if(!a.buffered&&(!a.loaded||r))return void(a.body.type===s&&this.removeFragment(a.body));const o=a.range[t];o&&(0!==o.time.length?o.time.some(t=>{const s=!this.isTimeBuffered(t.startPTS,t.endPTS,e);return s&&this.removeFragment(a.body),s}):this.removeFragment(a.body))})}detectPartialFragments(t){const e=this.timeRanges;if(!e||"initSegment"===t.frag.sn)return;const s=t.frag,i=Ae(s),r=this.fragments[i];if(!r||r.buffered&&s.gap)return;const n=!s.relurl;Object.keys(e).forEach(i=>{const a=s.elementaryStreams[i];if(!a)return;const o=e[i],l=n||!0===a.partial;r.range[i]=this.getBufferedTimes(s,t.part,l,o)}),r.loaded=null,Object.keys(r.range).length?(this.bufferedEnd(r,s),Te(r)||this.removeParts(s.sn-1,s.type)):this.removeFragment(r.body)}bufferedEnd(t,e){t.buffered=!0,(t.body.endList=e.endList||t.body.endList)&&(this.endListFragments[t.body.type]=t)}removeParts(t,e){const s=this.activePartLists[e];s&&(this.activePartLists[e]=Ee(s,e=>e.fragment.sn>=t))}fragBuffered(t,e){const s=Ae(t);let i=this.fragments[s];!i&&e&&(i=this.fragments[s]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,this.bufferedEnd(i,t))}getBufferedTimes(t,e,s,i){const r={time:[],partial:s},n=t.start,a=t.end,o=t.minEndPTS||a,l=t.maxStartPTS||n;for(let t=0;t<i.length;t++){const e=i.start(t)-this.bufferPadding,s=i.end(t)+this.bufferPadding;if(l>=e&&o<=s){r.time.push({startPTS:Math.max(n,i.start(t)),endPTS:Math.min(a,i.end(t))});break}if(n<s&&a>e){const e=Math.max(n,i.start(t)),s=Math.min(a,i.end(t));s>e&&(r.partial=!0,r.time.push({startPTS:e,endPTS:s}))}else if(a<=e)break}return r}getPartialFragment(t){let e,s,i,r=null,n=0;const{bufferPadding:a,fragments:o}=this;return Object.keys(o).forEach(l=>{const h=o[l];h&&Te(h)&&(s=h.body.start-a,i=h.body.end+a,t>=s&&t<=i&&(e=Math.min(t-s,i-t),n<=e&&(r=h.body,n=e)))}),r}isEndListAppended(t){const e=this.endListFragments[t];return void 0!==e&&(e.buffered||Te(e))}getState(t){const e=Ae(t),s=this.fragments[e];return s?s.buffered?Te(s)?ve:be:ye:me}isTimeBuffered(t,e,s){let i,r;for(let n=0;n<s.length;n++){if(i=s.start(n)-this.bufferPadding,r=s.end(n)+this.bufferPadding,t>=i&&e<=r)return!0;if(e<=i)return!1}return!1}onManifestLoading(){this.removeAllFragments()}onFragLoaded(t,e){if("initSegment"===e.frag.sn||e.frag.bitrateTest)return;const s=e.frag,i=e.part?null:e,r=Ae(s);this.fragments[r]={body:s,appendedPTS:null,loaded:i,buffered:!1,range:Object.create(null)}}onBufferAppended(t,e){const{frag:s,part:i,timeRanges:r,type:n}=e;if("initSegment"===s.sn)return;const a=s.type;if(i){let t=this.activePartLists[a];t||(this.activePartLists[a]=t=[]),t.push(i)}this.timeRanges=r;const o=r[n];this.detectEvictedFragments(n,o,a,i)}onFragBuffered(t,e){this.detectPartialFragments(e)}hasFragment(t){const e=Ae(t);return!!this.fragments[e]}hasFragments(t){const{fragments:e}=this,s=Object.keys(e);if(!t)return s.length>0;for(let i=s.length;i--;){const r=e[s[i]];if((null==r?void 0:r.body.type)===t)return!0}return!1}hasParts(t){var e;return!(null==(e=this.activePartLists[t])||!e.length)}removeFragmentsInRange(t,e,s,i,r){i&&!this.hasGaps||Object.keys(this.fragments).forEach(n=>{const a=this.fragments[n];if(!a)return;const o=a.body;o.type!==s||i&&!o.gap||o.start<e&&o.end>t&&(a.buffered||r)&&this.removeFragment(o)})}removeFragment(t){const e=Ae(t);t.clearElementaryStreamInfo();const s=this.activePartLists[t.type];if(s){const e=t.sn;this.activePartLists[t.type]=Ee(s,t=>t.fragment.sn!==e)}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]}removeAllFragments(){var t;this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1;const e=null==(t=this.hls)||null==(t=t.latestLevelDetails)?void 0:t.partList;e&&e.forEach(t=>t.clearElementaryStreamInfo())}}function Te(t){var e,s,i;return t.buffered&&!!(t.body.gap||null!=(e=t.range.video)&&e.partial||null!=(s=t.range.audio)&&s.partial||null!=(i=t.range.audiovideo)&&i.partial)}function Ae(t){return`${t.type}_${t.level}_${t.sn}`}function Ee(t,e){return t.filter(t=>{const s=e(t);return s||t.clearElementaryStreamInfo(),s})}class Se{constructor(t,e,s){this.subtle=void 0,this.aesIV=void 0,this.aesMode=void 0,this.subtle=t,this.aesIV=e,this.aesMode=s}decrypt(t,e){switch(this.aesMode){case 0:return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},e,t);case 1:return this.subtle.decrypt({name:"AES-CTR",counter:this.aesIV,length:64},e,t);default:throw new Error(`[AESCrypto] invalid aes mode ${this.aesMode}`)}}}class Ce{constructor(){this.rcon=[0,1,2,4,8,16,32,64,128,27,54],this.subMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.invSubMix=[new Uint32Array(256),new Uint32Array(256),new Uint32Array(256),new Uint32Array(256)],this.sBox=new Uint32Array(256),this.invSBox=new Uint32Array(256),this.key=new Uint32Array(0),this.ksRows=0,this.keySize=0,this.keySchedule=void 0,this.invKeySchedule=void 0,this.initTable()}uint8ArrayToUint32Array_(t){const e=new DataView(t),s=new Uint32Array(4);for(let t=0;t<4;t++)s[t]=e.getUint32(4*t);return s}initTable(){const t=this.sBox,e=this.invSBox,s=this.subMix,i=s[0],r=s[1],n=s[2],a=s[3],o=this.invSubMix,l=o[0],h=o[1],c=o[2],d=o[3],u=new Uint32Array(256);let p=0,f=0,g=0;for(g=0;g<256;g++)u[g]=g<128?g<<1:g<<1^283;for(g=0;g<256;g++){let s=f^f<<1^f<<2^f<<3^f<<4;s=s>>>8^255&s^99,t[p]=s,e[s]=p;const o=u[p],g=u[o],m=u[g];let y=257*u[s]^16843008*s;i[p]=y<<24|y>>>8,r[p]=y<<16|y>>>16,n[p]=y<<8|y>>>24,a[p]=y,y=16843009*m^65537*g^257*o^16843008*p,l[s]=y<<24|y>>>8,h[s]=y<<16|y>>>16,c[s]=y<<8|y>>>24,d[s]=y,p?(p=o^u[u[u[m^o]]],f^=u[u[f]]):p=f=1}}expandKey(t){const e=this.uint8ArrayToUint32Array_(t);let s=!0,i=0;for(;i<e.length&&s;)s=e[i]===this.key[i],i++;if(s)return;this.key=e;const r=this.keySize=e.length;if(4!==r&&6!==r&&8!==r)throw new Error("Invalid aes key size="+r);const n=this.ksRows=4*(r+6+1);let a,o;const l=this.keySchedule=new Uint32Array(n),h=this.invKeySchedule=new Uint32Array(n),c=this.sBox,d=this.rcon,u=this.invSubMix,p=u[0],f=u[1],g=u[2],m=u[3];let y,v;for(a=0;a<n;a++)a<r?y=l[a]=e[a]:(v=y,a%r===0?(v=v<<8|v>>>24,v=c[v>>>24]<<24|c[v>>>16&255]<<16|c[v>>>8&255]<<8|c[255&v],v^=d[a/r|0]<<24):r>6&&a%r===4&&(v=c[v>>>24]<<24|c[v>>>16&255]<<16|c[v>>>8&255]<<8|c[255&v]),l[a]=y=(l[a-r]^v)>>>0);for(o=0;o<n;o++)a=n-o,v=3&o?l[a]:l[a-4],h[o]=o<4||a<=4?v:p[c[v>>>24]]^f[c[v>>>16&255]]^g[c[v>>>8&255]]^m[c[255&v]],h[o]=h[o]>>>0}networkToHostOrderSwap(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24}decrypt(t,e,s){const i=this.keySize+6,r=this.invKeySchedule,n=this.invSBox,a=this.invSubMix,o=a[0],l=a[1],h=a[2],c=a[3],d=this.uint8ArrayToUint32Array_(s);let u=d[0],p=d[1],f=d[2],g=d[3];const m=new Int32Array(t),y=new Int32Array(m.length);let v,b,_,T,A,E,S,C,k,w,L,I,P,x;const R=this.networkToHostOrderSwap;for(;e<m.length;){for(k=R(m[e]),w=R(m[e+1]),L=R(m[e+2]),I=R(m[e+3]),A=k^r[0],E=I^r[1],S=L^r[2],C=w^r[3],P=4,x=1;x<i;x++)v=o[A>>>24]^l[E>>16&255]^h[S>>8&255]^c[255&C]^r[P],b=o[E>>>24]^l[S>>16&255]^h[C>>8&255]^c[255&A]^r[P+1],_=o[S>>>24]^l[C>>16&255]^h[A>>8&255]^c[255&E]^r[P+2],T=o[C>>>24]^l[A>>16&255]^h[E>>8&255]^c[255&S]^r[P+3],A=v,E=b,S=_,C=T,P+=4;v=n[A>>>24]<<24^n[E>>16&255]<<16^n[S>>8&255]<<8^n[255&C]^r[P],b=n[E>>>24]<<24^n[S>>16&255]<<16^n[C>>8&255]<<8^n[255&A]^r[P+1],_=n[S>>>24]<<24^n[C>>16&255]<<16^n[A>>8&255]<<8^n[255&E]^r[P+2],T=n[C>>>24]<<24^n[A>>16&255]<<16^n[E>>8&255]<<8^n[255&S]^r[P+3],y[e]=R(v^u),y[e+1]=R(T^p),y[e+2]=R(_^f),y[e+3]=R(b^g),u=k,p=w,f=L,g=I,e+=4}return y.buffer}}class ke{constructor(t,e,s){this.subtle=void 0,this.key=void 0,this.aesMode=void 0,this.subtle=t,this.key=e,this.aesMode=s}expandKey(){const t=function(t){switch(t){case 0:return"AES-CBC";case 1:return"AES-CTR";default:throw new Error(`[FastAESKey] invalid aes mode ${t}`)}}(this.aesMode);return this.subtle.importKey("raw",this.key,{name:t},!1,["encrypt","decrypt"])}}class we{constructor(t,{removePKCS7Padding:e=!0}={}){if(this.logEnabled=!0,this.removePKCS7Padding=void 0,this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null,this.useSoftware=void 0,this.enableSoftwareAES=void 0,this.enableSoftwareAES=t.enableSoftwareAES,this.removePKCS7Padding=e,e)try{const t=self.crypto;t&&(this.subtle=t.subtle||t.webkitSubtle)}catch(t){}this.useSoftware=!this.subtle}destroy(){this.subtle=null,this.softwareDecrypter=null,this.key=null,this.fastAesKey=null,this.remainderData=null,this.currentIV=null,this.currentResult=null}isSync(){return this.useSoftware}flush(){const{currentResult:t,remainderData:e}=this;if(!t||e)return this.reset(),null;const s=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?function(t){const e=t.byteLength,s=e&&new DataView(t.buffer).getUint8(e-1);return s?t.slice(0,e-s):t}(s):s}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(t,e,s,i){return this.useSoftware?new Promise((r,n)=>{const a=ArrayBuffer.isView(t)?t:new Uint8Array(t);this.softwareDecrypt(a,e,s,i);const o=this.flush();o?r(o.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(t),e,s,i)}softwareDecrypt(t,e,s,i){const{currentIV:r,currentResult:n,remainderData:a}=this;if(0!==i||16!==e.byteLength)return L.warn("SoftwareDecrypt: can only handle AES-128-CBC"),null;this.logOnce("JS AES decrypt"),a&&(t=dt(a,t),this.remainderData=null);const o=this.getValidChunk(t);if(!o.length)return null;r&&(s=r);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Ce),l.expandKey(e);const h=n;return this.currentResult=l.decrypt(o.buffer,0,s),this.currentIV=o.slice(-16).buffer,h||null}webCryptoDecrypt(t,e,s,i){if(this.key!==e||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(t,e,s,i));this.key=e,this.fastAesKey=new ke(this.subtle,e,i)}return this.fastAesKey.expandKey().then(e=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new Se(this.subtle,new Uint8Array(s),i).decrypt(t.buffer,e)):Promise.reject(new Error("web crypto not initialized"))).catch(r=>(L.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${r.name}: ${r.message}`),this.onWebCryptoError(t,e,s,i)))}onWebCryptoError(t,e,s,i){const r=this.enableSoftwareAES;if(r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(t,e,s,i);const r=this.flush();if(r)return r.buffer}throw new Error("WebCrypto"+(r?" and softwareDecrypt":"")+": failed to decrypt data")}getValidChunk(t){let e=t;const s=t.length-t.length%16;return s!==t.length&&(e=t.slice(0,s),this.remainderData=t.slice(s)),e}logOnce(t){this.logEnabled&&(L.log(`[decrypter]: ${t}`),this.logEnabled=!1)}}const Le=Math.pow(2,17);class Ie{constructor(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(t,e){const s=t.url;if(!s)return Promise.reject(new Re({type:a.NETWORK_ERROR,details:o.FRAG_LOAD_ERROR,fatal:!1,frag:t,error:new Error("Fragment does not have a "+(s?"part list":"url")),networkDetails:null}));this.abort();const i=this.config,r=i.fLoader,n=i.loader;return new Promise((l,h)=>{if(this.loader&&this.loader.destroy(),t.gap){if(t.tagList.some(t=>"GAP"===t[0]))return void h(xe(t));t.gap=!1}const c=this.loader=r?new r(i):new n(i),d=Pe(t);t.loader=c;const u=ue(i.fragLoadPolicy.default),p={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:"initSegment"===t.sn?1/0:Le};t.stats=c.stats;const f={onSuccess:(e,s,i,r)=>{this.resetLoader(t,c);let n=e.data;i.resetIV&&t.decryptdata&&(t.decryptdata.iv=new Uint8Array(n.slice(0,16)),n=n.slice(16)),l({frag:t,part:null,payload:n,networkDetails:r})},onError:(e,i,r,n)=>{this.resetLoader(t,c),h(new Re({type:a.NETWORK_ERROR,details:o.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:T({url:s,data:void 0},e),error:new Error(`HTTP Error ${e.code} ${e.text}`),networkDetails:r,stats:n}))},onAbort:(e,s,i)=>{this.resetLoader(t,c),h(new Re({type:a.NETWORK_ERROR,details:o.INTERNAL_ABORTED,fatal:!1,frag:t,error:new Error("Aborted"),networkDetails:i,stats:e}))},onTimeout:(e,s,i)=>{this.resetLoader(t,c),h(new Re({type:a.NETWORK_ERROR,details:o.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,error:new Error(`Timeout after ${p.timeout}ms`),networkDetails:i,stats:e}))}};e&&(f.onProgress=(s,i,r,n)=>e({frag:t,part:null,payload:r,networkDetails:n})),c.load(d,p,f)})}loadPart(t,e,s){this.abort();const i=this.config,r=i.fLoader,n=i.loader;return new Promise((l,h)=>{if(this.loader&&this.loader.destroy(),t.gap||e.gap)return void h(xe(t,e));const c=this.loader=r?new r(i):new n(i),d=Pe(t,e);t.loader=c;const u=ue(i.fragLoadPolicy.default),p={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Le};e.stats=c.stats,c.load(d,p,{onSuccess:(i,r,n,a)=>{this.resetLoader(t,c),this.updateStatsFromPart(t,e);const o={frag:t,part:e,payload:i.data,networkDetails:a};s(o),l(o)},onError:(s,i,r,n)=>{this.resetLoader(t,c),h(new Re({type:a.NETWORK_ERROR,details:o.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:e,response:T({url:d.url,data:void 0},s),error:new Error(`HTTP Error ${s.code} ${s.text}`),networkDetails:r,stats:n}))},onAbort:(s,i,r)=>{t.stats.aborted=e.stats.aborted,this.resetLoader(t,c),h(new Re({type:a.NETWORK_ERROR,details:o.INTERNAL_ABORTED,fatal:!1,frag:t,part:e,error:new Error("Aborted"),networkDetails:r,stats:s}))},onTimeout:(s,i,r)=>{this.resetLoader(t,c),h(new Re({type:a.NETWORK_ERROR,details:o.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:e,error:new Error(`Timeout after ${p.timeout}ms`),networkDetails:r,stats:s}))}})})}updateStatsFromPart(t,e){const s=t.stats,i=e.stats,r=i.total;if(s.loaded+=i.loaded,r){const i=Math.round(t.duration/e.duration),n=Math.min(Math.round(s.loaded/r),i),a=(i-n)*Math.round(s.loaded/n);s.total=s.loaded+a}else s.total=Math.max(s.loaded,s.total);const n=s.loading,a=i.loading;n.start?n.first+=a.first-a.start:(n.start=a.start,n.first=a.first),n.end=a.end}resetLoader(t,e){t.loader=null,this.loader===e&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),e.destroy()}}function Pe(t,e=null){const s=e||t,r={frag:t,part:e,responseType:"arraybuffer",url:s.url,headers:{},rangeStart:0,rangeEnd:0},n=s.byteRangeStartOffset,a=s.byteRangeEndOffset;if(i(n)&&i(a)){var o;let e=n,s=a;if("initSegment"===t.sn&&("AES-128"===(l=null==(o=t.decryptdata)?void 0:o.method)||"AES-256"===l)){const t=a-n;t%16&&(s=a+(16-t%16)),0!==n&&(r.resetIV=!0,e=n-16)}r.rangeStart=e,r.rangeEnd=s}var l;return r}function xe(t,e){const s=new Error(`GAP ${t.gap?"tag":"attribute"} found`),i={type:a.MEDIA_ERROR,details:o.FRAG_GAP,fatal:!1,frag:t,error:s,networkDetails:null};return e&&(i.part=e),(e||t).stats.aborted=!0,new Re(i)}class Re extends Error{constructor(t){super(t.error.message),this.data=void 0,this.data=t}}class De extends A{constructor(t,e){super(t,e),this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}destroy(){this.onHandlerDestroying(),this.onHandlerDestroyed()}onHandlerDestroying(){this.clearNextTick(),this.clearInterval()}onHandlerDestroyed(){}hasInterval(){return!!this._tickInterval}hasNextTick(){return!!this._tickTimer}setInterval(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)}clearInterval(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)}clearNextTick(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)}tick(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}class Oe{constructor(t,e,s,i=0,r=-1,n=!1){this.level=void 0,this.sn=void 0,this.part=void 0,this.id=void 0,this.size=void 0,this.partial=void 0,this.transmuxing={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=e,this.id=s,this.size=i,this.part=r,this.partial=n}}const Me={length:0,start:()=>0,end:()=>0};class Fe{static isBuffered(t,e){if(t){const s=Fe.getBuffered(t);for(let t=s.length;t--;)if(e>=s.start(t)&&e<=s.end(t))return!0}return!1}static bufferedRanges(t){if(t){const e=Fe.getBuffered(t);return Fe.timeRangesToArray(e)}return[]}static timeRangesToArray(t){const e=[];for(let s=0;s<t.length;s++)e.push({start:t.start(s),end:t.end(s)});return e}static bufferInfo(t,e,s){if(t){const i=Fe.bufferedRanges(t);if(i.length)return Fe.bufferedInfo(i,e,s)}return{len:0,start:e,end:e,bufferedIndex:-1}}static bufferedInfo(t,e,s){e=Math.max(0,e),t.length>1&&t.sort((t,e)=>t.start-e.start||e.end-t.end);let i=-1,r=[];if(s)for(let n=0;n<t.length;n++){e>=t[n].start&&e<=t[n].end&&(i=n);const a=r.length;if(a){const e=r[a-1].end;t[n].start-e<s?t[n].end>e&&(r[a-1].end=t[n].end):r.push(t[n])}else r.push(t[n])}else r=t;let n,a=0,o=e,l=e;for(let t=0;t<r.length;t++){const h=r[t].start,c=r[t].end;if(-1===i&&e>=h&&e<=c&&(i=t),e+s>=h&&e<c)o=h,l=c,a=l-e;else if(e+s<h){n=h;break}}return{len:a,start:o||0,end:l||0,nextStart:n,buffered:t,bufferedIndex:i}}static getBuffered(t){try{return t.buffered||Me}catch(t){return L.log("failed to get media.buffered",t),Me}}}const Ne=/\{\$([a-zA-Z0-9-_]+)\}/g;function Be(t){return Ne.test(t)}function je(t,e){if(null!==t.variableList||t.hasVariableRefs){const s=t.variableList;return e.replace(Ne,e=>{const i=e.substring(2,e.length-1),r=null==s?void 0:s[i];return void 0===r?(t.playlistParsingError||(t.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${i}"`)),e):r})}return e}function $e(t,e,s){let i,r,n=t.variableList;if(n||(t.variableList=n={}),"QUERYPARAM"in e){i=e.QUERYPARAM;try{const t=new self.URL(s).searchParams;if(!t.has(i))throw new Error(`"${i}" does not match any query parameter in URI: "${s}"`);r=t.get(i)}catch(e){t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${e.message}`))}}else i=e.NAME,r=e.VALUE;i in n?t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${i}"`)):n[i]=r||""}function Ue(t,e,s){const i=e.IMPORT;if(s&&i in s){let e=t.variableList;e||(t.variableList=e={}),e[i]=s[i]}else t.playlistParsingError||(t.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${i}"`))}const He=/^(\d+)x(\d+)$/,Ve=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Ge{constructor(t,e){"string"==typeof t&&(t=Ge.parseAttrList(t,e)),b(this,t)}get clientAttrs(){return Object.keys(this).filter(t=>"X-"===t.substring(0,2))}decimalInteger(t){const e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e}hexadecimalInteger(t){if(this[t]){let e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;const s=new Uint8Array(e.length/2);for(let t=0;t<e.length/2;t++)s[t]=parseInt(e.slice(2*t,2*t+2),16);return s}return null}hexadecimalIntegerAsNumber(t){const e=parseInt(this[t],16);return e>Number.MAX_SAFE_INTEGER?1/0:e}decimalFloatingPoint(t){return parseFloat(this[t])}optionalFloat(t,e){const s=this[t];return s?parseFloat(s):e}enumeratedString(t){return this[t]}enumeratedStringList(t,e){const s=this[t];return(s?s.split(/[ ,]+/):[]).reduce((t,e)=>(t[e.toLowerCase()]=!0,t),e)}bool(t){return"YES"===this[t]}decimalResolution(t){const e=He.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}}static parseAttrList(t,e){let s;const i={};for(Ve.lastIndex=0;null!==(s=Ve.exec(t));){const r=s[1].trim();let n=s[2];const a=0===n.indexOf('"')&&n.lastIndexOf('"')===n.length-1;let o=!1;if(a)n=n.slice(1,-1);else switch(r){case"IV":case"SCTE35-CMD":case"SCTE35-IN":case"SCTE35-OUT":o=!0}if(e&&(a||o))n=je(e,n);else if(!o&&!a)switch(r){case"CLOSED-CAPTIONS":if("NONE"===n)break;case"ALLOWED-CPC":case"CLASS":case"ASSOC-LANGUAGE":case"AUDIO":case"BYTERANGE":case"CHANNELS":case"CHARACTERISTICS":case"CODECS":case"DATA-ID":case"END-DATE":case"GROUP-ID":case"ID":case"IMPORT":case"INSTREAM-ID":case"KEYFORMAT":case"KEYFORMATVERSIONS":case"LANGUAGE":case"NAME":case"PATHWAY-ID":case"QUERYPARAM":case"RECENTLY-REMOVED-DATERANGES":case"SERVER-URI":case"STABLE-RENDITION-ID":case"STABLE-VARIANT-ID":case"START-DATE":case"SUBTITLES":case"SUPPLEMENTAL-CODECS":case"URI":case"VALUE":case"VIDEO":case"X-ASSET-LIST":case"X-ASSET-URI":L.warn(`${t}: attribute ${r} is missing quotes`)}i[r]=n}return i}}function We(t){return"ID"!==t&&"CLASS"!==t&&"CUE"!==t&&"START-DATE"!==t&&"DURATION"!==t&&"END-DATE"!==t&&"END-ON-NEXT"!==t}function Ke(t){return"SCTE35-OUT"===t||"SCTE35-IN"===t||"SCTE35-CMD"===t}class ze{constructor(t,e,s=0){var r;if(this.attr=void 0,this.tagAnchor=void 0,this.tagOrder=void 0,this._startDate=void 0,this._endDate=void 0,this._dateAtEnd=void 0,this._cue=void 0,this._badValueForSameId=void 0,this.tagAnchor=(null==e?void 0:e.tagAnchor)||null,this.tagOrder=null!=(r=null==e?void 0:e.tagOrder)?r:s,e){const s=e.attr;for(const e in s)if(Object.prototype.hasOwnProperty.call(t,e)&&t[e]!==s[e]){L.warn(`DATERANGE tag attribute: "${e}" does not match for tags with ID: "${t.ID}"`),this._badValueForSameId=e;break}t=b(new Ge({}),s,t)}if(this.attr=t,e?(this._startDate=e._startDate,this._cue=e._cue,this._endDate=e._endDate,this._dateAtEnd=e._dateAtEnd):this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){const t=(null==e?void 0:e.endDate)||new Date(this.attr["END-DATE"]);i(t.getTime())&&(this._endDate=t)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get cue(){const t=this._cue;return void 0===t?this._cue=this.attr.enumeratedStringList(this.attr.CUE?"CUE":"X-CUE",{pre:!1,post:!1,once:!1}):t}get startTime(){const{tagAnchor:t}=this;return null===t||null===t.programDateTime?(L.warn(`Expected tagAnchor Fragment with PDT set for DateRange "${this.id}": ${t}`),NaN):t.start+(this.startDate.getTime()-t.programDateTime)/1e3}get startDate(){return this._startDate}get endDate(){const t=this._endDate||this._dateAtEnd;if(t)return t;const e=this.duration;return null!==e?this._dateAtEnd=new Date(this._startDate.getTime()+1e3*e):null}get duration(){if("DURATION"in this.attr){const t=this.attr.decimalFloatingPoint("DURATION");if(i(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}get plannedDuration(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}get endOnNext(){return this.attr.bool("END-ON-NEXT")}get isInterstitial(){return"com.apple.hls.interstitial"===this.class}get isValid(){return!!this.id&&!this._badValueForSameId&&i(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)&&(!this.attr.CUE||!this.cue.pre&&!this.cue.post||this.cue.pre!==this.cue.post)&&(!this.isInterstitial||"X-ASSET-URI"in this.attr||"X-ASSET-LIST"in this.attr)}}class qe{constructor(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.dateRangeTagCount=0,this.live=!0,this.requestScheduled=-1,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.appliedTimelineOffset=void 0,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}reloaded(t){if(!t)return this.advanced=!0,void(this.updated=!0);const e=this.lastPartSn-t.lastPartSn,s=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!s||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||0===e&&s>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1}hasKey(t){return this.encryptedFragments.some(e=>{let s=e.decryptdata;return s||(e.setKeyFormat(t.keyFormat),s=e.decryptdata),!!s&&t.matches(s)})}get hasProgramDateTime(){return!!this.fragments.length&&i(this.fragments[this.fragments.length-1].programDateTime)}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||10}get drift(){const t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){return this.fragments.length?this.fragments[this.fragments.length-1].end:0}get fragmentStart(){return this.fragments.length?this.fragments[0].start:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].index:-1}get maxPartIndex(){const t=this.partList;if(t){const e=this.lastPartIndex;if(-1!==e){for(let s=t.length;s--;)if(t[s].index>e)return t[s].index;return e}}return 0}get lastPartSn(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}get expired(){if(this.live&&this.age&&this.misses<3){const t=this.partEnd-this.fragmentStart;return this.age>Math.max(t,this.totalduration)+this.levelTargetDuration}return!1}}function Ye(t,e){return t.length===e.length&&!t.some((t,s)=>t!==e[s])}function Xe(t,e){return!t&&!e||!(!t||!e)&&Ye(t,e)}function Qe(t){return"AES-128"===t||"AES-256"===t||"AES-256-CTR"===t}function Ze(t){switch(t){case"AES-128":case"AES-256":return 0;case"AES-256-CTR":return 1;default:throw new Error(`invalid full segment method ${t}`)}}function Je(t){return Uint8Array.from(atob(t),t=>t.charCodeAt(0))}function ts(t){return Uint8Array.from(unescape(encodeURIComponent(t)),t=>t.charCodeAt(0))}function es(t){const e=function(t,e,s){const i=t[e];t[e]=t[s],t[s]=i};e(t,0,3),e(t,1,2),e(t,4,5),e(t,6,7)}function ss(t){const e=t.split(":");let s=null;if("data"===e[0]&&2===e.length){const t=e[1].split(";"),i=t[t.length-1].split(",");if(2===i.length){const e="base64"===i[0],r=i[1];e?(t.splice(-1,1),s=Je(r)):s=function(t){const e=ts(t).subarray(0,16),s=new Uint8Array(16);return s.set(e,16-e.length),s}(r)}}return s}const is="undefined"!=typeof self?self:void 0;var rs={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},ns="org.w3.clearkey",as="com.apple.streamingkeydelivery",os="com.microsoft.playready",ls="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function hs(t){switch(t){case as:return rs.FAIRPLAY;case os:return rs.PLAYREADY;case ls:return rs.WIDEVINE;case ns:return rs.CLEARKEY}}function cs(t){switch(t){case rs.FAIRPLAY:return as;case rs.PLAYREADY:return os;case rs.WIDEVINE:return ls;case rs.CLEARKEY:return ns}}function ds(t){const{drmSystems:e,widevineLicenseUrl:s}=t,i=e?[rs.FAIRPLAY,rs.WIDEVINE,rs.PLAYREADY,rs.CLEARKEY].filter(t=>!!e[t]):[];return!i[rs.WIDEVINE]&&s&&i.push(rs.WIDEVINE),i}const us=null!=is&&null!=(ps=is.navigator)&&ps.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;var ps;function fs(t){const e=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),s=String.fromCharCode.apply(null,Array.from(e)),i=s.substring(s.indexOf("<"),s.length),r=(new DOMParser).parseFromString(i,"text/xml").getElementsByTagName("KID")[0];if(r){const t=r.childNodes[0]?r.childNodes[0].nodeValue:r.getAttribute("VALUE");if(t){const e=Je(t).subarray(0,16);return es(e),e}}return null}let gs={};class ms{static clearKeyUriToKeyIdMap(){gs={}}static setKeyIdForUri(t,e){gs[t]=e}static addKeyIdForUri(t){const e=Object.keys(gs).length%Number.MAX_SAFE_INTEGER,s=new Uint8Array(16);return new DataView(s.buffer,12,4).setUint32(0,e),gs[t]=s,s}constructor(t,e,s,i=[1],r=null,n){this.uri=void 0,this.method=void 0,this.keyFormat=void 0,this.keyFormatVersions=void 0,this.encrypted=void 0,this.isCommonEncryption=void 0,this.iv=null,this.key=null,this.keyId=null,this.pssh=null,this.method=t,this.uri=e,this.keyFormat=s,this.keyFormatVersions=i,this.iv=r,this.encrypted=!!t&&"NONE"!==t,this.isCommonEncryption=this.encrypted&&!Qe(t),null!=n&&n.startsWith("0x")&&(this.keyId=new Uint8Array(D(n)))}matches(t){return t.uri===this.uri&&t.method===this.method&&t.encrypted===this.encrypted&&t.keyFormat===this.keyFormat&&Ye(t.keyFormatVersions,this.keyFormatVersions)&&Xe(t.iv,this.iv)&&Xe(t.keyId,this.keyId)}isSupported(){if(this.method){if(Qe(this.method)||"NONE"===this.method)return!0;if("identity"===this.keyFormat)return"SAMPLE-AES"===this.method;switch(this.keyFormat){case as:case ls:case os:case ns:return-1!==["SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)}}return!1}getDecryptData(t,e){if(!this.encrypted||!this.uri)return null;if(Qe(this.method)){let e=this.iv;return e||("number"!=typeof t&&(L.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),t=0),e=function(t){const e=new Uint8Array(16);for(let s=12;s<16;s++)e[s]=t>>8*(15-s)&255;return e}(t)),new ms(this.method,this.uri,"identity",this.keyFormatVersions,e)}if(this.keyId){const t=gs[this.uri];if(t&&!Ye(this.keyId,t)&&ms.setKeyIdForUri(this.uri,this.keyId),this.pssh)return this}const s=ss(this.uri);if(s)switch(this.keyFormat){case ls:if(this.pssh=s,!this.keyId){const t=function(t){const e=[];if(t instanceof ArrayBuffer){const s=t.byteLength;let i=0;for(;i+32<s;){const s=yt(new DataView(t,i));e.push(s),i+=s.size}}return e}(s.buffer);if(t.length){var i;const e=t[0];this.keyId=null!=(i=e.kids)&&i.length?e.kids[0]:null}}this.keyId||(this.keyId=ys(e));break;case os:{const t=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=function(t,e,s){if(16!==t.byteLength)throw new RangeError("Invalid system id");let i,r,n;i=0,r=new Uint8Array,n=new Uint8Array;const a=new Uint8Array(4);return s.byteLength>0&&new DataView(a.buffer).setUint32(0,s.byteLength,!1),function(t,...e){const s=e.length;let i=8,r=s;for(;r--;)i+=e[r].byteLength;const n=new Uint8Array(i);for(n[0]=i>>24&255,n[1]=i>>16&255,n[2]=i>>8&255,n[3]=255&i,n.set(t,4),r=0,i=8;r<s;r++)n.set(e[r],i),i+=e[r].byteLength;return n}([112,115,115,104],new Uint8Array([0,0,0,0]),t,n,r,a,s)}(t,0,s),this.keyId=fs(s);break}default:{let t=s.subarray(0,16);if(16!==t.length){const e=new Uint8Array(16);e.set(t,16-t.length),t=e}this.keyId=t;break}}if(!this.keyId||16!==this.keyId.byteLength){let t;t=function(t){const e=null==t?void 0:t[ls];return e?e.keyId:null}(e),t||(t=ys(e),t||(t=gs[this.uri])),t&&(this.keyId=t,ms.setKeyIdForUri(this.uri,t))}return this}}function ys(t){const e=null==t?void 0:t[os];if(e){const t=ss(e.uri);if(t)return fs(t)}return null}const vs=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-(SESSION-DATA|SESSION-KEY|DEFINE|CONTENT-STEERING|START):([^\r\n]*)[\r\n]+/g,bs=/#EXT-X-MEDIA:(.*)/g,_s=/^#EXT(?:INF|-X-TARGETDURATION):/m,Ts=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#.*/.source].join("|"),"g"),As=new RegExp([/#EXT-X-(PROGRAM-DATE-TIME|BYTERANGE|DATERANGE|DEFINE|KEY|MAP|PART|PART-INF|PLAYLIST-TYPE|PRELOAD-HINT|RENDITION-REPORT|SERVER-CONTROL|SKIP|START):(.+)/.source,/#EXT-X-(BITRATE|DISCONTINUITY-SEQUENCE|MEDIA-SEQUENCE|TARGETDURATION|VERSION): *(\d+)/.source,/#EXT-X-(DISCONTINUITY|ENDLIST|GAP|INDEPENDENT-SEGMENTS)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|"));class Es{static findGroup(t,e){for(let s=0;s<t.length;s++){const i=t[s];if(i.id===e)return i}}static resolve(t,e){return N.buildAbsoluteURL(e,t,{alwaysNormalize:!0})}static isMediaPlaylist(t){return _s.test(t)}static parseMasterPlaylist(t,e){const s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:Be(t)},i=[];if(vs.lastIndex=0,!t.startsWith("#EXTM3U"))return s.playlistParsingError=new Error("no EXTM3U delimiter"),s;let r;for(;null!=(r=vs.exec(t));)if(r[1]){var n;const t=new Ge(r[1],s),a=je(s,r[2]),o={attrs:t,bitrate:t.decimalInteger("BANDWIDTH")||t.decimalInteger("AVERAGE-BANDWIDTH"),name:t.NAME,url:Es.resolve(a,e)},l=t.decimalResolution("RESOLUTION");l&&(o.width=l.width,o.height=l.height),Ls(t.CODECS,o);const h=t["SUPPLEMENTAL-CODECS"];h&&(o.supplemental={},Ls(h,o.supplemental)),null!=(n=o.unknownCodecs)&&n.length||i.push(o),s.levels.push(o)}else if(r[3]){const t=r[3],i=r[4];switch(t){case"SESSION-DATA":{const t=new Ge(i,s),e=t["DATA-ID"];e&&(null===s.sessionData&&(s.sessionData={}),s.sessionData[e]=t);break}case"SESSION-KEY":{const t=ks(i,e,s);t.encrypted&&t.isSupported()?(null===s.sessionKeys&&(s.sessionKeys=[]),s.sessionKeys.push(t)):L.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${i}"`);break}case"DEFINE":$e(s,new Ge(i,s),e);break;case"CONTENT-STEERING":{const t=new Ge(i,s);s.contentSteering={uri:Es.resolve(t["SERVER-URI"],e),pathwayId:t["PATHWAY-ID"]||"."};break}case"START":s.startTimeOffset=ws(i)}}const a=i.length>0&&i.length<s.levels.length;return s.levels=a?i:s.levels,0===s.levels.length&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(t,e,s){let i;const r={},n=s.levels,a={AUDIO:n.map(t=>({id:t.attrs.AUDIO,audioCodec:t.audioCodec})),SUBTITLES:n.map(t=>({id:t.attrs.SUBTITLES,textCodec:t.textCodec})),"CLOSED-CAPTIONS":[]};let o=0;for(bs.lastIndex=0;null!==(i=bs.exec(t));){const t=new Ge(i[1],s),n=t.TYPE;if(n){const s=a[n],i=r[n]||[];r[n]=i;const l=t.LANGUAGE,h=t["ASSOC-LANGUAGE"],c=t.CHANNELS,d=t.CHARACTERISTICS,u=t["INSTREAM-ID"],p={attrs:t,bitrate:0,id:o++,groupId:t["GROUP-ID"]||"",name:t.NAME||l||"",type:n,default:t.bool("DEFAULT"),autoselect:t.bool("AUTOSELECT"),forced:t.bool("FORCED"),lang:l,url:t.URI?Es.resolve(t.URI,e):""};if(h&&(p.assocLang=h),c&&(p.channels=c),d&&(p.characteristics=d),u&&(p.instreamId=u),null!=s&&s.length){const t=Es.findGroup(s,p.groupId)||s[0];Is(p,t,"audioCodec"),Is(p,t,"textCodec")}i.push(p)}}return r}static parseLevelPlaylist(t,e,s,r,n,a){var o;const l={url:e},h=new qe(e),c=h.fragments,d=[];let u,p,f,g,m=null,y=0,v=0,_=0,T=0,A=0,E=null,S=new G(r,l),C=-1,k=!1,w=null;if(Ts.lastIndex=0,h.m3u8=t,h.hasVariableRefs=Be(t),"#EXTM3U"!==(null==(o=Ts.exec(t))?void 0:o[0]))return h.playlistParsingError=new Error("Missing format identifier #EXTM3U"),h;for(;null!==(u=Ts.exec(t));){k&&(k=!1,S=new G(r,l),S.playlistOffset=_,S.setStart(_),S.sn=y,S.cc=T,A&&(S.bitrate=A),S.level=s,m&&(S.initSegment=m,m.rawProgramDateTime&&(S.rawProgramDateTime=m.rawProgramDateTime,m.rawProgramDateTime=null),w&&(S.setByteRange(w),w=null)));const t=u[1];if(t){S.duration=parseFloat(t);const e=(" "+u[2]).slice(1);S.title=e||null,S.tagList.push(e?["INF",t,e]:["INF",t])}else if(u[3]){if(i(S.duration)){S.playlistOffset=_,S.setStart(_),f&&Rs(S,f,h),S.sn=y,S.level=s,S.cc=T,c.push(S);const t=(" "+u[3]).slice(1);S.relurl=je(h,t),Ps(S,E,d),E=S,_+=S.duration,y++,v=0,k=!0}}else{if(u=u[0].match(As),!u){L.warn("No matches on slow regex match for level playlist!");continue}for(p=1;p<u.length&&void 0===u[p];p++);const t=(" "+u[p]).slice(1),n=(" "+u[p+1]).slice(1),o=u[p+2]?(" "+u[p+2]).slice(1):null;switch(t){case"BYTERANGE":E?S.setByteRange(n,E):S.setByteRange(n);break;case"PROGRAM-DATE-TIME":S.rawProgramDateTime=n,S.tagList.push(["PROGRAM-DATE-TIME",n]),-1===C&&(C=c.length);break;case"PLAYLIST-TYPE":h.type&&Ds(h,t,u),h.type=n.toUpperCase();break;case"MEDIA-SEQUENCE":0!==h.startSN?Ds(h,t,u):c.length>0&&Os(h,t,u),y=h.startSN=parseInt(n);break;case"SKIP":{h.skippedSegments&&Ds(h,t,u);const e=new Ge(n,h),s=e.decimalInteger("SKIPPED-SEGMENTS");if(i(s)){h.skippedSegments+=s;for(let t=s;t--;)c.push(null);y+=s}const r=e.enumeratedString("RECENTLY-REMOVED-DATERANGES");r&&(h.recentlyRemovedDateranges=(h.recentlyRemovedDateranges||[]).concat(r.split("\t")));break}case"TARGETDURATION":0!==h.targetduration&&Ds(h,t,u),h.targetduration=Math.max(parseInt(n),1);break;case"VERSION":null!==h.version&&Ds(h,t,u),h.version=parseInt(n);break;case"INDEPENDENT-SEGMENTS":break;case"ENDLIST":h.live||Ds(h,t,u),h.live=!1;break;case"#":(n||o)&&S.tagList.push(o?[n,o]:[n]);break;case"DISCONTINUITY":T++,S.tagList.push(["DIS"]);break;case"GAP":S.gap=!0,S.tagList.push([t]);break;case"BITRATE":S.tagList.push([t,n]),A=1e3*parseInt(n),i(A)?S.bitrate=A:A=0;break;case"DATERANGE":{const t=new Ge(n,h),e=new ze(t,h.dateRanges[t.ID],h.dateRangeTagCount);h.dateRangeTagCount++,e.isValid||h.skippedSegments?h.dateRanges[e.id]=e:L.warn(`Ignoring invalid DATERANGE tag: "${n}"`),S.tagList.push(["EXT-X-DATERANGE",n]);break}case"DEFINE":{const t=new Ge(n,h);"IMPORT"in t?Ue(h,t,a):$e(h,t,e)}break;case"DISCONTINUITY-SEQUENCE":0!==h.startCC?Ds(h,t,u):c.length>0&&Os(h,t,u),h.startCC=T=parseInt(n);break;case"KEY":{const t=ks(n,e,h);if(t.isSupported()){if("NONE"===t.method){f=void 0;break}f||(f={});const e=f[t.keyFormat];null!=e&&e.matches(t)||(e&&(f=b({},f)),f[t.keyFormat]=t)}else L.warn(`[Keys] Ignoring unsupported EXT-X-KEY tag: "${n}"`);break}case"START":h.startTimeOffset=ws(n);break;case"MAP":{const t=new Ge(n,h);if(S.duration){const e=new G(r,l);xs(e,t,s,f),m=e,S.initSegment=m,m.rawProgramDateTime&&!S.rawProgramDateTime&&(S.rawProgramDateTime=m.rawProgramDateTime)}else{const e=S.byteRangeEndOffset;if(e){const t=S.byteRangeStartOffset;w=`${e-t}@${t}`}else w=null;xs(S,t,s,f),m=S,k=!0}m.cc=T;break}case"SERVER-CONTROL":g&&Ds(h,t,u),g=new Ge(n),h.canBlockReload=g.bool("CAN-BLOCK-RELOAD"),h.canSkipUntil=g.optionalFloat("CAN-SKIP-UNTIL",0),h.canSkipDateRanges=h.canSkipUntil>0&&g.bool("CAN-SKIP-DATERANGES"),h.partHoldBack=g.optionalFloat("PART-HOLD-BACK",0),h.holdBack=g.optionalFloat("HOLD-BACK",0);break;case"PART-INF":{h.partTarget&&Ds(h,t,u);const e=new Ge(n);h.partTarget=e.decimalFloatingPoint("PART-TARGET");break}case"PART":{let t=h.partList;t||(t=h.partList=[]);const e=v>0?t[t.length-1]:void 0,s=v++,i=new Ge(n,h),r=new W(i,S,l,s,e);t.push(r),S.duration+=r.duration;break}case"PRELOAD-HINT":{const t=new Ge(n,h);h.preloadHint=t;break}case"RENDITION-REPORT":{const t=new Ge(n,h);h.renditionReports=h.renditionReports||[],h.renditionReports.push(t);break}default:L.warn(`line parsed but not handled: ${u}`)}}}E&&!E.relurl?(c.pop(),_-=E.duration,h.partList&&(h.fragmentHint=E)):h.partList&&(Ps(S,E,d),S.cc=T,h.fragmentHint=S,f&&Rs(S,f,h)),h.targetduration||(h.playlistParsingError=new Error("Missing Target Duration"));const I=c.length,P=c[0],x=c[I-1];if(_+=h.skippedSegments*h.targetduration,_>0&&I&&x){h.averagetargetduration=_/I;const t=x.sn;h.endSN="initSegment"!==t?t:0,h.live||(x.endList=!0),C>0&&(function(t,e){let s=t[e];for(let i=e;i--;){const e=t[i];if(!e)return;e.programDateTime=s.programDateTime-1e3*e.duration,s=e}}(c,C),P&&d.unshift(P))}return h.fragmentHint&&(_+=h.fragmentHint.duration),h.totalduration=_,d.length&&h.dateRangeTagCount&&P&&Ss(d,h),h.endCC=T,h}}function Ss(t,e){let s=t.length;if(!s){if(!e.hasProgramDateTime)return;{const i=e.fragments[e.fragments.length-1];t.push(i),s++}}const i=t[s-1],r=e.live?1/0:e.totalduration,n=Object.keys(e.dateRanges);for(let o=n.length;o--;){const l=e.dateRanges[n[o]],h=l.startDate.getTime();l.tagAnchor=i.ref;for(let i=s;i--;){var a;if((null==(a=t[i])?void 0:a.sn)<e.startSN)break;const s=Cs(e,h,t,i,r);if(-1!==s){l.tagAnchor=e.fragments[s].ref;break}}}}function Cs(t,e,s,i,r){const n=s[i];if(n){const o=n.programDateTime;var a;if(e>=o||0===i)if(e<=o+1e3*(((null==(a=s[i+1])?void 0:a.start)||r)-n.start)){const r=s[i].sn-t.startSN;if(r<0)return-1;const n=t.fragments;if(n.length>s.length)for(let a=(s[i+1]||n[n.length-1]).sn-t.startSN;a>r;a--){const t=n[a].programDateTime;if(e>=t&&e<t+1e3*n[a].duration)return a}return r}}return-1}function ks(t,e,s){var i,r;const n=new Ge(t,s),a=null!=(i=n.METHOD)?i:"",o=n.URI,l=n.hexadecimalInteger("IV"),h=n.KEYFORMATVERSIONS,c=null!=(r=n.KEYFORMAT)?r:"identity";o&&n.IV&&!l&&L.error(`Invalid IV: ${n.IV}`);const d=o?Es.resolve(o,e):"",u=(h||"1").split("/").map(Number).filter(Number.isFinite);return new ms(a,d,c,u,l,n.KEYID)}function ws(t){const e=new Ge(t).decimalFloatingPoint("TIME-OFFSET");return i(e)?e:null}function Ls(t,e){let s=(t||"").split(/[ ,]+/).filter(t=>t);["video","audio","text"].forEach(t=>{const i=s.filter(e=>_t(e,t));i.length&&(e[`${t}Codec`]=i.map(t=>t.split("/")[0]).join(","),s=s.filter(t=>-1===i.indexOf(t)))}),e.unknownCodecs=s}function Is(t,e,s){const i=e[s];i&&(t[s]=i)}function Ps(t,e,s){t.rawProgramDateTime?s.push(t):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime)}function xs(t,e,s,i){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=s,t.sn="initSegment",i&&(t.levelkeys=i),t.initSegment=null}function Rs(t,e,s){t.levelkeys=e;const{encryptedFragments:i}=s;i.length&&i[i.length-1].levelkeys===e||!Object.keys(e).some(t=>e[t].isCommonEncryption)||i.push(t)}function Ds(t,e,s){t.playlistParsingError=new Error(`#EXT-X-${e} must not appear more than once (${s[0]})`)}function Os(t,e,s){t.playlistParsingError=new Error(`#EXT-X-${e} must appear before the first Media Segment (${s[0]})`)}function Ms(t,e){const s=e.startPTS;if(i(s)){let i,r=0;e.sn>t.sn?(r=s-t.start,i=t):(r=t.start-s,i=e),i.duration!==r&&i.setDuration(r)}else e.sn>t.sn?t.cc===e.cc&&t.minEndPTS?e.setStart(t.start+(t.minEndPTS-t.start)):e.setStart(t.start+t.duration):e.setStart(Math.max(t.start-e.duration,0))}function Fs(t,e,s,r,n,a,o){r-s<=0&&(o.warn("Fragment should have a positive duration",e),r=s+e.duration,a=n+e.duration);let l=s,h=r;const c=e.startPTS,d=e.endPTS;if(i(c)){const u=Math.abs(c-s);t&&u>t.totalduration?o.warn(`media timestamps and playlist times differ by ${u}s for level ${e.level} ${t.url}`):i(e.deltaPTS)?e.deltaPTS=Math.max(u,e.deltaPTS):e.deltaPTS=u,l=Math.max(s,c),s=Math.min(s,c),n=void 0!==e.startDTS?Math.min(n,e.startDTS):n,h=Math.min(r,d),r=Math.max(r,d),a=void 0!==e.endDTS?Math.max(a,e.endDTS):a}const u=s-e.start;0!==e.start&&e.setStart(s),e.setDuration(r-e.start),e.startPTS=s,e.maxStartPTS=l,e.startDTS=n,e.endPTS=r,e.minEndPTS=h,e.endDTS=a;const p=e.sn;if(!t||p<t.startSN||p>t.endSN)return 0;let f;const g=p-t.startSN,m=t.fragments;for(m[g]=e,f=g;f>0;f--)Ms(m[f],m[f-1]);for(f=g;f<m.length-1;f++)Ms(m[f],m[f+1]);return t.fragmentHint&&Ms(m[m.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,u}function Ns(t,e,s,i,r){return new Error(`${t} ${r.url}\nPlaylist starting @${e.startSN}\n${e.m3u8}\n\nPlaylist starting @${s.startSN}\n${s.m3u8}`)}function Bs(t,e,s=!0){const i=e.startSN+e.skippedSegments-t.startSN,r=t.fragments,n=i>=0;let a=0;if(n&&i<r.length)a=r[i].start;else if(n&&e.startSN===t.endSN+1)a=t.fragmentEnd;else if(n&&s)a=t.fragmentStart+i*e.levelTargetDuration;else{if(e.skippedSegments||0!==e.fragmentStart)return;a=t.fragmentStart}js(e,a)}function js(t,e){if(e){const s=t.fragments;for(let i=t.skippedSegments;i<s.length;i++)s[i].addStart(e);t.fragmentHint&&t.fragmentHint.addStart(e)}}function $s(t,e=1/0){let s=1e3*t.targetduration;if(t.updated){const i=t.fragments,r=4;if(i.length&&s*r>e){const t=1e3*i[i.length-1].duration;t<s&&(s=t)}}else s/=2;return Math.round(s)}function Us(t,e,s){if(!t)return null;let i=t.fragments[e-t.startSN];return i||(i=t.fragmentHint,i&&i.sn===e?i:e<t.startSN&&s&&s.sn===e?s:null)}function Hs(t,e,s){return t?Vs(t.partList,e,s):null}function Vs(t,e,s){if(t)for(let i=t.length;i--;){const r=t[i];if(r.index===s&&r.fragment.sn===e)return r}return null}function Gs(t){t.forEach((t,e)=>{var s;null==(s=t.details)||s.fragments.forEach(t=>{t.level=e,t.initSegment&&(t.initSegment.level=e)})})}function Ws(t,e){return!(t===e||!e)&&Ks(t)!==Ks(e)}function Ks(t){return t.replace(/\?[^?]*$/,"")}function zs(t,e){for(let i=0,r=t.length;i<r;i++){var s;if((null==(s=t[i])?void 0:s.cc)===e)return t[i]}return null}function qs(t,e){const s=t.start+e;t.startPTS=s,t.setStart(s),t.endPTS=s+t.duration}function Ys(t,e){const s=e.fragments;for(let e=0,i=s.length;e<i;e++)qs(s[e],t);e.fragmentHint&&qs(e.fragmentHint,t),e.alignedSliding=!0}function Xs(t,e){if(!function(t,e){return!!(t&&e.startCC<t.endCC&&e.endCC>t.startCC)}(e,t))return;const s=Math.min(e.endCC,t.endCC),i=zs(e.fragments,s),r=zs(t.fragments,s);i&&r&&(L.log(`Aligning playlist at start of dicontinuity sequence ${s}`),Ys(i.start-r.start,t))}function Qs(t,e){if(!t.hasProgramDateTime||!e.hasProgramDateTime)return;const s=t.fragments,i=e.fragments;if(!s.length||!i.length)return;let r,n;const a=Math.min(e.endCC,t.endCC);e.startCC<a&&t.startCC<a&&(r=zs(i,a),n=zs(s,a)),r&&n||(r=i[Math.floor(i.length/2)],n=zs(s,r.cc)||s[Math.floor(s.length/2)]);const o=r.programDateTime,l=n.programDateTime;o&&l&&Ys((l-o)/1e3-(n.start-r.start),t)}function Zs(t,e,s){Js(t,e,s),t.addEventListener(e,s)}function Js(t,e,s){t.removeEventListener(e,s)}const ti="STOPPED",ei="IDLE",si="KEY_LOADING",ii="FRAG_LOADING",ri="FRAG_LOADING_WAITING_RETRY",ni="WAITING_TRACK",ai="PARSING",oi="PARSED",li="ENDED",hi="ERROR",ci="WAITING_INIT_PTS",di="WAITING_LEVEL";class ui extends De{constructor(t,e,s,r,n){super(r,t.logger),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=ti,this.playlistType=void 0,this.media=null,this.mediaBuffer=null,this.config=void 0,this.bitrateTest=!1,this.lastCurrentTime=0,this.nextLoadPosition=0,this.startPosition=0,this.startTimeOffset=null,this.retryDate=0,this.levels=null,this.fragmentLoader=void 0,this.keyLoader=void 0,this.levelLastLoaded=null,this.startFragRequested=!1,this.decrypter=void 0,this.initPTS=[],this.buffering=!0,this.loadingParts=!1,this.loopSn=void 0,this.onMediaSeeking=()=>{const{config:t,fragCurrent:e,media:s,mediaBuffer:r,state:n}=this,a=s?s.currentTime:0,o=Fe.bufferInfo(r||s,a,t.maxBufferHole),l=!o.len;if(this.log(`Media seeking to ${i(a)?a.toFixed(3):a}, state: ${n}, ${l?"out of":"in"} buffer`),this.state===li)this.resetLoadingState();else if(e){const s=t.maxFragLookUpTolerance,i=e.start-s,r=e.start+e.duration+s;if(l||r<o.start||i>o.end){const t=a>r;(a<i||t)&&(t&&e.loader&&(this.log(`Cancelling fragment load for seek (sn: ${e.sn})`),e.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}if(s&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),a>this.lastCurrentTime&&(this.lastCurrentTime=a),!this.loadingParts)){const t=Math.max(o.end,a),e=this.shouldLoadParts(this.getLevelDetails(),t);e&&(this.log(`LL-Part loading ON after seeking to ${a.toFixed(2)} with buffer @${t.toFixed(2)}`),this.loadingParts=e)}this.hls.hasEnoughToStart||(this.log(`Setting ${l?"startPosition":"nextLoadPosition"} to ${a} for seek without enough to start`),this.nextLoadPosition=a,l&&(this.startPosition=a)),l&&this.state===ei&&this.tickImmediate()},this.onMediaEnded=()=>{this.log("setting startPosition to 0 because media ended"),this.startPosition=this.lastCurrentTime=0},this.playlistType=n,this.hls=t,this.fragmentLoader=new Ie(t.config),this.keyLoader=s,this.fragmentTracker=e,this.config=t.config,this.decrypter=new we(t.config)}registerListeners(){const{hls:t}=this;t.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(l.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(l.ERROR,this.onError,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(t){}stopLoad(){if(this.state===ti)return;this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const t=this.fragCurrent;null!=t&&t.loader&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=ti}get startPositionValue(){const{nextLoadPosition:t,startPosition:e}=this;return-1===e&&t?t:e}get bufferingEnabled(){return this.buffering}pauseBuffering(){this.buffering=!1}resumeBuffering(){this.buffering=!0}get inFlightFrag(){return{frag:this.fragCurrent,state:this.state}}_streamEnded(t,e){if(e.live||!this.media)return!1;const s=t.end||0,i=this.config.timelineOffset||0;if(s<=i)return!1;const r=t.buffered;this.config.maxBufferHole&&r&&r.length>1&&(t=Fe.bufferedInfo(r,t.start,0));const n=t.nextStart;if(n&&n>i&&n<e.edge)return!1;if(this.media.currentTime<t.start)return!1;const a=e.partList;if(null!=a&&a.length){const t=a[a.length-1];return Fe.isBuffered(this.media,t.start+t.duration/2)}const o=e.fragments[e.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(o)}getLevelDetails(){if(this.levels&&null!==this.levelLastLoaded)return this.levelLastLoaded.details}get timelineOffset(){const t=this.config.timelineOffset;var e;return t?(null==(e=this.getLevelDetails())?void 0:e.appliedTimelineOffset)||t:0}onMediaAttached(t,e){const s=this.media=this.mediaBuffer=e.media;Zs(s,"seeking",this.onMediaSeeking),Zs(s,"ended",this.onMediaEnded);const i=this.config;this.levels&&i.autoStartLoad&&this.state===ti&&this.startLoad(i.startPosition)}onMediaDetaching(t,e){const s=!!e.transferMedia,i=this.media;if(null!==i){if(i.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),Js(i,"seeking",this.onMediaSeeking),Js(i,"ended",this.onMediaEnded),this.keyLoader&&!s&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loopSn=void 0,s)return this.resetLoadingState(),void this.resetTransmuxer();this.loadingParts=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}}onManifestLoading(){this.initPTS=[],this.levels=this.levelLastLoaded=this.fragCurrent=null,this.lastCurrentTime=this.startPosition=0,this.startFragRequested=!1}onError(t,e){}onManifestLoaded(t,e){this.startTimeOffset=e.startTimeOffset}onHandlerDestroying(){this.stopLoad(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),super.onHandlerDestroying(),this.hls=this.onMediaSeeking=this.onMediaEnded=null}onHandlerDestroyed(){this.state=ti,this.fragmentLoader&&this.fragmentLoader.destroy(),this.keyLoader&&this.keyLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.keyLoader=this.fragmentLoader=this.fragmentTracker=null,super.onHandlerDestroyed()}loadFragment(t,e,s){this.startFragRequested=!0,this._loadFragForPlayback(t,e,s)}_loadFragForPlayback(t,e,s){this._doFragLoad(t,e,s,t=>{const e=t.frag;if(this.fragContextChanged(e))return this.warn(`${e.type} sn: ${e.sn}${t.part?" part: "+t.part.index:""} of ${this.fragInfo(e,!1,t.part)}) was dropped during download.`),void this.fragmentTracker.removeFragment(e);e.stats.chunkCount++,this._handleFragmentLoadProgress(t)}).then(t=>{if(!t)return;const e=this.state,s=t.frag;this.fragContextChanged(s)?(e===ii||!this.fragCurrent&&e===ai)&&(this.fragmentTracker.removeFragment(s),this.state=ei):("payload"in t&&(this.log(`Loaded ${s.type} sn: ${s.sn} of ${this.playlistLabel()} ${s.level}`),this.hls.trigger(l.FRAG_LOADED,t)),this._handleFragmentLoadComplete(t))}).catch(e=>{this.state!==ti&&this.state!==hi&&(this.warn(`Frag error: ${(null==e?void 0:e.message)||e}`),this.resetFragmentLoading(t))})}clearTrackerIfNeeded(t){var e;const{fragmentTracker:s}=this;if(s.getState(t)===ye){const e=t.type,i=this.getFwdBufferInfo(this.mediaBuffer,e),r=Math.max(t.duration,i?i.len:this.config.maxBufferLength),n=this.backtrackFragment;(1===(n?t.sn-n.sn:0)||this.reduceMaxBufferLength(r,t.duration))&&s.removeFragment(t)}else 0===(null==(e=this.mediaBuffer)?void 0:e.buffered.length)?s.removeAllFragments():s.hasParts(t.type)&&(s.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type}),s.getState(t)===ve&&s.removeFragment(t))}checkLiveUpdate(t){if(t.updated&&!t.live){const e=t.fragments[t.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type})}t.fragments[0]||(t.deltaUpdateFailed=!0)}waitForLive(t){const e=t.details;return(null==e?void 0:e.live)&&"EVENT"!==e.type&&(this.levelLastLoaded!==t||e.expired)}flushMainBuffer(t,e,s=null){if(!(t-e))return;const i={startOffset:t,endOffset:e,type:s};this.hls.trigger(l.BUFFER_FLUSHING,i)}_loadInitSegment(t,e){this._doFragLoad(t,e).then(t=>{const e=null==t?void 0:t.frag;if(!e||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return t}).then(t=>{const{hls:e}=this,{frag:s,payload:i}=t,r=s.decryptdata;if(i&&i.byteLength>0&&null!=r&&r.key&&r.iv&&Qe(r.method)){const n=self.performance.now();return this.decrypter.decrypt(new Uint8Array(i),r.key.buffer,r.iv.buffer,Ze(r.method)).catch(t=>{throw e.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:s}),t}).then(i=>{const r=self.performance.now();return e.trigger(l.FRAG_DECRYPTED,{frag:s,payload:i,stats:{tstart:n,tdecrypt:r}}),t.payload=i,this.completeInitSegmentLoad(t)})}return this.completeInitSegmentLoad(t)}).catch(e=>{this.state!==ti&&this.state!==hi&&(this.warn(e),this.resetFragmentLoading(t))})}completeInitSegmentLoad(t){const{levels:e}=this;if(!e)throw new Error("init load aborted, missing levels");const s=t.frag.stats;this.state!==ti&&(this.state=ei),t.frag.data=new Uint8Array(t.payload),s.parsing.start=s.buffering.start=self.performance.now(),s.parsing.end=s.buffering.end=self.performance.now(),this.tick()}unhandledEncryptionError(t,e){var s,i;const r=t.tracks;if(r&&!e.encrypted&&(null!=(s=r.audio)&&s.encrypted||null!=(i=r.video)&&i.encrypted)&&(!this.config.emeEnabled||!this.keyLoader.emeController)){const t=this.media,s=new Error(`Encrypted track with no key in ${this.fragInfo(e)} (media ${t?"attached mediaKeys: "+t.mediaKeys:"detached"})`);return this.warn(s.message),!(!t||t.mediaKeys)&&(this.hls.trigger(l.ERROR,{type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_NO_KEYS,fatal:!1,error:s,frag:e}),this.resetTransmuxer(),!0)}return!1}fragContextChanged(t){const{fragCurrent:e}=this;return!t||!e||t.sn!==e.sn||t.level!==e.level}fragBufferedComplete(t,e){const s=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.fragInfo(t,!1,e)} > buffer:${s?function(t){let e="";const s=t.length;for(let i=0;i<s;i++)e+=`[${t.start(i).toFixed(3)}-${t.end(i).toFixed(3)}]`;return e}(Fe.getBuffered(s)):"(detached)"})`),V(t)){var i;if(t.type!==g){const e=t.elementaryStreams;if(!Object.keys(e).some(t=>!!e[t]))return void(this.state=ei)}const e=null==(i=this.levels)?void 0:i[t.level];null!=e&&e.fragmentError&&(this.log(`Resetting level fragment error count of ${e.fragmentError} on frag buffered`),e.fragmentError=0)}this.state=ei}_handleFragmentLoadComplete(t){const{transmuxer:e}=this;if(!e)return;const{frag:s,part:i,partsLoaded:r}=t,n=!r||0===r.length||r.some(t=>!t),a=new Oe(s.level,s.sn,s.stats.chunkCount+1,0,i?i.index:-1,!n);e.flush(a)}_handleFragmentLoadProgress(t){}_doFragLoad(t,e,s=null,r){var n;this.fragCurrent=t;const a=e.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(!t.encrypted||null!=(n=t.decryptdata)&&n.key)t.encrypted||(o=this.keyLoader.loadClear(t,a.encryptedFragments,this.startFragRequested),o&&this.log("[eme] blocking frag load until media-keys acquired"));else if(this.log(`Loading key for ${t.sn} of [${a.startSN}-${a.endSN}], ${this.playlistLabel()} ${t.level}`),this.state=si,this.fragCurrent=t,o=this.keyLoader.load(t).then(t=>{if(!this.fragContextChanged(t.frag))return this.hls.trigger(l.KEY_LOADED,t),this.state===si&&(this.state=ei),t}),this.hls.trigger(l.KEY_LOADING,{frag:t}),null===this.fragCurrent)return this.log("context changed in KEY_LOADING"),Promise.resolve(null);const h=this.fragPrevious;if(V(t)&&(!h||t.sn!==h.sn)){const s=this.shouldLoadParts(e.details,t.end);s!==this.loadingParts&&(this.log(`LL-Part loading ${s?"ON":"OFF"} loading sn ${null==h?void 0:h.sn}->${t.sn}`),this.loadingParts=s)}if(s=Math.max(t.start,s||0),this.loadingParts&&V(t)){const i=a.partList;if(i&&r){s>a.fragmentEnd&&a.fragmentHint&&(t=a.fragmentHint);const n=this.getNextPart(i,t,s);if(n>-1){const h=i[n];let c;return t=this.fragCurrent=h.fragment,this.log(`Loading ${t.type} sn: ${t.sn} part: ${h.index} (${n}/${i.length-1}) of ${this.fragInfo(t,!1,h)}) cc: ${t.cc} [${a.startSN}-${a.endSN}], target: ${parseFloat(s.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=ii,c=o?o.then(s=>!s||this.fragContextChanged(s.frag)?null:this.doFragPartsLoad(t,h,e,r)).catch(t=>this.handleFragLoadError(t)):this.doFragPartsLoad(t,h,e,r).catch(t=>this.handleFragLoadError(t)),this.hls.trigger(l.FRAG_LOADING,{frag:t,part:h,targetBufferTime:s}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):c}if(!t.url||this.loadedEndOfParts(i,s))return Promise.resolve(null)}}var c;if(V(t)&&this.loadingParts)this.log(`LL-Part loading OFF after next part miss @${s.toFixed(2)} Check buffer at sn: ${t.sn} loaded parts: ${null==(c=a.partList)?void 0:c.filter(t=>t.loaded).map(t=>`[${t.start}-${t.end}]`)}`),this.loadingParts=!1;else if(!t.url)return Promise.resolve(null);this.log(`Loading ${t.type} sn: ${t.sn} of ${this.fragInfo(t,!1)}) cc: ${t.cc} ${"["+a.startSN+"-"+a.endSN+"]"}, target: ${parseFloat(s.toFixed(3))}`),i(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=ii;const d=this.config.progressive&&t.type!==g;let u;return u=d&&o?o.then(e=>!e||this.fragContextChanged(e.frag)?null:this.fragmentLoader.load(t,r)).catch(t=>this.handleFragLoadError(t)):Promise.all([this.fragmentLoader.load(t,d?r:void 0),o]).then(([t])=>(!d&&r&&r(t),t)).catch(t=>this.handleFragLoadError(t)),this.hls.trigger(l.FRAG_LOADING,{frag:t,targetBufferTime:s}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):u}doFragPartsLoad(t,e,s,i){return new Promise((r,n)=>{var a;const o=[],h=null==(a=s.details)?void 0:a.partList,c=e=>{this.fragmentLoader.loadPart(t,e,i).then(i=>{o[e.index]=i;const n=i.part;this.hls.trigger(l.FRAG_LOADED,i);const a=Hs(s.details,t.sn,e.index+1)||Vs(h,t.sn,e.index+1);if(!a)return r({frag:t,part:n,partsLoaded:o});c(a)}).catch(n)};c(e)})}handleFragLoadError(t){if("data"in t){const e=t.data;e.frag&&e.details===o.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):e.frag&&e.type===a.KEY_SYSTEM_ERROR?(e.frag.abortRequests(),this.resetStartWhenNotLoaded(),this.resetFragmentLoading(e.frag)):this.hls.trigger(l.ERROR,e)}else this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null}_handleTransmuxerFlush(t){const e=this.getCurrentContext(t);if(!e||this.state!==ai)return void(this.fragCurrent||this.state===ti||this.state===hi||(this.state=ei));const{frag:s,part:i,level:r}=e,n=self.performance.now();s.stats.parsing.end=n,i&&(i.stats.parsing.end=n);const a=this.getLevelDetails(),o=a&&s.sn>a.endSN||this.shouldLoadParts(a,s.end);o!==this.loadingParts&&(this.log(`LL-Part loading ${o?"ON":"OFF"} after parsing segment ending @${s.end.toFixed(2)}`),this.loadingParts=o),this.updateLevelTiming(s,i,r,t.partial)}shouldLoadParts(t,e){if(this.config.lowLatencyMode){if(!t)return this.loadingParts;if(t.partList){var s;const r=t.partList[0];if(r.fragment.type===g)return!1;var i;if(e>=r.end+((null==(s=t.fragmentHint)?void 0:s.duration)||0))if((this.hls.hasEnoughToStart?(null==(i=this.media)?void 0:i.currentTime)||this.lastCurrentTime:this.getLoadPosition())>r.start-r.fragment.duration)return!0}}return!1}getCurrentContext(t){const{levels:e,fragCurrent:s}=this,{level:i,sn:r,part:n}=t;if(null==e||!e[i])return this.warn(`Levels object was unset while buffering fragment ${r} of ${this.playlistLabel()} ${i}. The current chunk will not be buffered.`),null;const a=e[i],o=a.details,l=n>-1?Hs(o,r,n):null,h=l?l.fragment:Us(o,r,s);return h?(s&&s!==h&&(h.stats=s.stats),{frag:h,part:l,level:a}):null}bufferFragmentData(t,e,s,i,r){if(this.state!==ai)return;const{data1:n,data2:a}=t;let o=n;if(a&&(o=dt(n,a)),!o.length)return;const h=this.initPTS[e.cc],c=h?-h.baseTime/h.timescale:void 0,d={type:t.type,frag:e,part:s,chunkMeta:i,offset:c,parent:e.type,data:o};if(this.hls.trigger(l.BUFFER_APPENDING,d),t.dropped&&t.independent&&!s){if(r)return;this.flushBufferGap(e)}}flushBufferGap(t){const e=this.media;if(!e)return;if(!Fe.isBuffered(e,e.currentTime))return void this.flushMainBuffer(0,t.start);const s=e.currentTime,i=Fe.bufferInfo(e,s,0),r=t.duration,n=Math.min(2*this.config.maxFragLookUpTolerance,.25*r),a=Math.max(Math.min(t.start-n,i.end-n),s+n);t.start-a>n&&this.flushMainBuffer(a,t.start)}getFwdBufferInfo(t,e){var s;const r=this.getLoadPosition();if(!i(r))return null;const n=this.lastCurrentTime>r||null!=(s=this.media)&&s.paused?0:this.config.maxBufferHole;return this.getFwdBufferInfoAtPos(t,r,e,n)}getFwdBufferInfoAtPos(t,e,s,i){const r=Fe.bufferInfo(t,e,i);if(0===r.len&&void 0!==r.nextStart){const n=this.fragmentTracker.getBufferedFrag(e,s);if(n&&(r.nextStart<=n.end||n.gap)){const s=Math.max(Math.min(r.nextStart,n.end)-e,i);return Fe.bufferInfo(t,e,s)}}return r}getMaxBufferLength(t){const{config:e}=this;let s;return s=t?Math.max(8*e.maxBufferSize/t,e.maxBufferLength):e.maxBufferLength,Math.min(s,e.maxMaxBufferLength)}reduceMaxBufferLength(t,e){const s=this.config,i=Math.max(Math.min(t-e,s.maxBufferLength),e),r=Math.max(t-3*e,s.maxMaxBufferLength/2,i);return r>=i&&(s.maxMaxBufferLength=r,this.warn(`Reduce max buffer length to ${r}s`),!0)}getAppendedFrag(t,e=p){const s=this.fragmentTracker?this.fragmentTracker.getAppendedFrag(t,e):null;return s&&"fragment"in s?s.fragment:s}getNextFragment(t,e){const s=e.fragments,i=s.length;if(!i)return null;const{config:r}=this,n=s[0].start,a=r.lowLatencyMode&&!!e.partList;let o=null;if(e.live){const s=r.initialLiveManifestSize;if(i<s)return this.warn(`Not enough fragments to start playback (have: ${i}, need: ${s})`),null;if(!e.PTSKnown&&!this.startFragRequested&&-1===this.startPosition||t<n){var l;a&&!this.loadingParts&&(this.log("LL-Part loading ON for initial live fragment"),this.loadingParts=!0),o=this.getInitialLiveFragment(e);const s=this.hls.startPosition,i=this.hls.liveSyncPosition,r=o?(-1!==s&&s>=n?s:i)||o.start:t;this.log(`Setting startPosition to ${r} to match start frag at live edge. mainStart: ${s} liveSyncPosition: ${i} frag.start: ${null==(l=o)?void 0:l.start}`),this.startPosition=this.nextLoadPosition=r}}else t<=n&&(o=s[0]);if(!o){const s=this.loadingParts?e.partEnd:e.fragmentEnd;o=this.getFragmentAtPosition(t,s,e)}let h=this.filterReplacedPrimary(o,e);if(!h&&o){const t=o.sn-e.startSN;h=this.filterReplacedPrimary(s[t+1]||null,e)}return this.mapToInitFragWhenRequired(h)}isLoopLoading(t,e){const s=this.fragmentTracker.getState(t);return(s===be||s===ve&&!!t.gap)&&this.nextLoadPosition>e}getNextFragmentLoopLoading(t,e,s,i,r){let n=null;if(t.gap&&(n=this.getNextFragment(this.nextLoadPosition,e),n&&!n.gap&&s.nextStart)){const t=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,s.nextStart,i,0);if(null!==t&&s.len+t.len>=r){const t=n.sn;return this.loopSn!==t&&(this.log(`buffer full after gaps in "${i}" playlist starting at sn: ${t}`),this.loopSn=t),null}}return this.loopSn=void 0,n}get primaryPrefetch(){var t;if(pi(this.config)&&(null==(t=this.hls.interstitialsManager)||null==(t=t.playingItem)?void 0:t.event))return!0;return!1}filterReplacedPrimary(t,e){if(!t)return t;if(pi(this.config)&&t.type!==g){const s=this.hls.interstitialsManager,i=null==s?void 0:s.bufferingItem;if(i){const s=i.event;if(s){if(s.appendInPlace||Math.abs(t.start-i.start)>1||0===i.start)return null}else{if(t.end<=i.start&&!1===(null==e?void 0:e.live))return null;if(t.start>i.end&&i.nextEvent&&(i.nextEvent.appendInPlace||t.start-i.end>1))return null}}const r=null==s?void 0:s.playerQueue;if(r)for(let e=r.length;e--;){const s=r[e].interstitial;if(s.appendInPlace&&t.start>=s.startTime&&t.end<=s.resumeTime)return null}}return t}mapToInitFragWhenRequired(t){return null==t||!t.initSegment||t.initSegment.data||this.bitrateTest?t:t.initSegment}getNextPart(t,e,s){let i=-1,r=!1,n=!0;for(let a=0,o=t.length;a<o;a++){const o=t[a];if(n=n&&!o.independent,i>-1&&s<o.start)break;const l=o.loaded;l?i=-1:(r||(o.independent||n)&&o.fragment===e)&&(o.fragment!==e&&this.warn(`Need buffer at ${s} but next unloaded part starts at ${o.start}`),i=a),r=l}return i}loadedEndOfParts(t,e){let s;for(let i=t.length;i--;){if(s=t[i],!s.loaded)return!1;if(e>s.start)return!0}return!1}getInitialLiveFragment(t){const e=t.fragments,s=this.fragPrevious;let r=null;if(s){if(t.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${s.programDateTime}`),r=function(t,e,s){if(null===e||!Array.isArray(t)||!t.length||!i(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;for(let i=0;i<t.length;++i){const r=t[i];if(ne(e,s,r))return r}return null}(e,s.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){const i=s.sn+1;if(i>=t.startSN&&i<=t.endSN){const n=e[i-t.startSN];s.cc===n.cc&&(r=n,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}r||(r=ae(t,s.cc,s.end),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`))}}else{const e=this.hls.liveSyncPosition;null!==e&&(r=this.getFragmentAtPosition(e,this.bitrateTest?t.fragmentEnd:t.edge,t))}return r}getFragmentAtPosition(t,e,s){const{config:i}=this;let{fragPrevious:r}=this,{fragments:n,endSN:a}=s;const{fragmentHint:o}=s,{maxFragLookUpTolerance:l}=i,h=s.partList,c=!!(this.loadingParts&&null!=h&&h.length&&o);let d;var u;(c&&!this.bitrateTest&&h[h.length-1].fragment.sn===o.sn&&(n=n.concat(o),a=o.sn),t<e)?d=ie(r,n,t,t<this.lastCurrentTime||t>e-l||null!=(u=this.media)&&u.paused||!this.startFragRequested?0:l):d=n[n.length-1];if(d){const t=d.sn-s.startSN,e=this.fragmentTracker.getState(d);if((e===be||e===ve&&d.gap)&&(r=d),r&&d.sn===r.sn&&(!c||h[0].fragment.sn>d.sn||!s.live)&&d.level===r.level){const e=n[t+1];d=d.sn<a&&this.fragmentTracker.getState(e)!==be?e:null}}return d}alignPlaylists(t,e,s){const r=t.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;const n=t.fragmentStart,a=!e,o=t.alignedSliding&&i(n);if(a||!o&&!n){!function(t,e){t&&(Xs(e,t),e.alignedSliding||Qs(e,t),e.alignedSliding||e.skippedSegments||Bs(t,e,!1))}(s,t);const i=t.fragmentStart;return this.log(`Live playlist sliding: ${i.toFixed(2)} start-sn: ${e?e.startSN:"na"}->${t.startSN} fragments: ${r}`),i}return n}waitForCdnTuneIn(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)}setStartPosition(t,e){let s=this.startPosition;s<e&&(s=-1);const r=this.timelineOffset;if(-1===s){const n=null!==this.startTimeOffset,a=n?this.startTimeOffset:t.startTimeOffset;null!==a&&i(a)?(s=e+a,a<0&&(s+=t.edge),s=Math.min(Math.max(e,s),e+t.totalduration),this.log(`Setting startPosition to ${s} for start time offset ${a} found in ${n?"multivariant":"media"} playlist`),this.startPosition=s):t.live?(s=this.hls.liveSyncPosition||e,this.log(`Setting startPosition to -1 to start at live edge ${s}`),this.startPosition=-1):(this.log("setting startPosition to 0 by default"),this.startPosition=s=0),this.lastCurrentTime=s+r}this.nextLoadPosition=s+r}getLoadPosition(){var t;const{media:e}=this;let s=0;return null!=(t=this.hls)&&t.hasEnoughToStart&&e?s=e.currentTime:this.nextLoadPosition>=0&&(s=this.nextLoadPosition),s}handleFragLoadAborted(t,e){this.transmuxer&&t.type===this.playlistType&&V(t)&&t.stats.aborted&&(this.log(`Fragment ${t.sn}${e?" part "+e.index:""} of ${this.playlistLabel()} ${t.level} was aborted`),this.resetFragmentLoading(t))}resetFragmentLoading(t){this.fragCurrent&&(this.fragContextChanged(t)||this.state===ri)||(this.state=ei)}onFragmentOrKeyLoadError(t,e){var s;if(e.chunkMeta&&!e.frag){const t=this.getCurrentContext(e.chunkMeta);t&&(e.frag=t.frag)}const i=e.frag;if(!i||i.type!==t||!this.levels)return;var r;if(this.fragContextChanged(i))return void this.warn(`Frag load error must match current frag to retry ${i.url} > ${null==(r=this.fragCurrent)?void 0:r.url}`);const n=e.details===o.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(i,!0);const a=e.errorAction;if(!a)return void(this.state=hi);const{action:l,flags:h,retryCount:c=0,retryConfig:d}=a,u=!!d,p=u&&5===l,f=u&&!a.resolved&&1===h,g=null==(s=this.hls.latestLevelDetails)?void 0:s.live;if(!p&&f&&V(i)&&!i.endList&&g&&!he(e))this.resetFragmentErrors(t),this.treatAsGap(i),a.resolved=!0;else if((p||f)&&c<d.maxNumRetry){var m;const s=fe(null==(m=e.response)?void 0:m.code),r=de(d,c);if(this.resetStartWhenNotLoaded(),this.retryDate=self.performance.now()+r,this.state=ri,a.resolved=!0,s)return this.log("Waiting for connection (offline)"),this.retryDate=1/0,void(e.reason="offline");this.warn(`Fragment ${i.sn} of ${t} ${i.level} errored with ${e.details}, retrying loading ${c+1}/${d.maxNumRetry} in ${r}ms`)}else if(d){if(this.resetFragmentErrors(t),!(c<d.maxNumRetry))return void this.warn(`${e.details} reached or exceeded max retry (${c})`);n||3===l||(a.resolved=!0)}else this.state=2===l?di:hi;this.tickImmediate()}checkRetryDate(){const t=self.performance.now(),e=this.retryDate,s=e===1/0;(!e||t>=e||s&&!fe(0))&&(s&&this.log("Connection restored (online)"),this.resetStartWhenNotLoaded(),this.state=ei)}reduceLengthAndFlushBuffer(t){if(this.state===ai||this.state===oi){const e=t.frag,s=t.parent,i=this.getFwdBufferInfo(this.mediaBuffer,s),r=i&&i.len>.5;r&&this.reduceMaxBufferLength(i.len,(null==e?void 0:e.duration)||10);const n=!r;return n&&this.warn(`Buffer full error while media.currentTime (${this.getLoadPosition()}) is not buffered, flush ${s} buffer`),e&&(this.fragmentTracker.removeFragment(e),this.nextLoadPosition=e.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(t){t===f&&(this.fragCurrent=null),this.hls.hasEnoughToStart||(this.startFragRequested=!1),this.state!==ti&&(this.state=ei)}afterBufferFlushed(t,e,s){if(!t)return;const i=Fe.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,i,s),this.state===li&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state!==ti&&(this.state=ei)}resetStartWhenNotLoaded(){if(!this.hls.hasEnoughToStart){this.startFragRequested=!1;const t=this.levelLastLoaded,e=t?t.details:null;null!=e&&e.live?(this.log("resetting startPosition for live start"),this.startPosition=-1,this.setStartPosition(e,e.fragmentStart),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(t){this.log(`Loading context changed while buffering sn ${t.sn} of ${this.playlistLabel()} ${-1===t.level?"<removed>":t.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(),this.resetLoadingState()}removeUnbufferedFrags(t=0){this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)}updateLevelTiming(t,e,s,i){const r=s.details;if(r){if(!Object.keys(t.elementaryStreams).reduce((e,n)=>{const a=t.elementaryStreams[n];if(a){const o=a.endPTS-a.startPTS;if(o<=0)return this.warn(`Could not parse fragment ${t.sn} ${n} duration reliably (${o})`),e||!1;const h=i?0:Fs(r,t,a.startPTS,a.endPTS,a.startDTS,a.endDTS,this);return this.hls.trigger(l.LEVEL_PTS_UPDATED,{details:r,level:s,drift:h,type:n,frag:t,start:a.startPTS,end:a.endPTS}),!0}return e},!1)){var n;const e=null===(null==(n=this.transmuxer)?void 0:n.error);if((0===s.fragmentError||e&&(s.fragmentError<2||t.endList))&&this.treatAsGap(t,s),e){const e=new Error(`Found no media in fragment ${t.sn} of ${this.playlistLabel()} ${t.level} resetting transmuxer to fallback to playlist timing`);if(this.warn(e.message),this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_PARSING_ERROR,fatal:!1,error:e,frag:t,reason:`Found no media in msn ${t.sn} of ${this.playlistLabel()} "${s.url}"`}),!this.hls)return;this.resetTransmuxer()}}this.state=oi,this.log(`Parsed ${t.type} sn: ${t.sn}${e?" part: "+e.index:""} of ${this.fragInfo(t,!1,e)})`),this.hls.trigger(l.FRAG_PARSED,{frag:t,part:e})}else this.warn("level.details undefined")}playlistLabel(){return this.playlistType===p?"level":"track"}fragInfo(t,e=!0,s){var i,r;return`${this.playlistLabel()} ${t.level} (${s?"part":"frag"}:[${(null!=(i=e&&!s?t.startPTS:(s||t).start)?i:NaN).toFixed(3)}-${(null!=(r=e&&!s?t.endPTS:(s||t).end)?r:NaN).toFixed(3)}]${s&&"main"===t.type?"INDEPENDENT="+(s.independent?"YES":"NO"):""}`}treatAsGap(t,e){e&&e.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)}resetTransmuxer(){var t;null==(t=this.transmuxer)||t.reset()}recoverWorkerError(t){"demuxerWorker"===t.event&&(this.fragmentTracker.removeAllFragments(),this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null),this.resetStartWhenNotLoaded(),this.resetLoadingState())}set state(t){const e=this._state;e!==t&&(this._state=t,this.log(`${e}->${t}`))}get state(){return this._state}}function pi(t){return!!t.interstitialsController&&!1!==t.enableInterstitialPlayback}class fi{constructor(){this.chunks=[],this.dataLength=0}push(t){this.chunks.push(t),this.dataLength+=t.length}flush(){const{chunks:t,dataLength:e}=this;let s;return t.length?(s=1===t.length?t[0]:function(t,e){const s=new Uint8Array(e);let i=0;for(let e=0;e<t.length;e++){const r=t[e];s.set(r,i),i+=r.length}return s}(t,e),this.reset(),s):new Uint8Array(0)}reset(){this.chunks.length=0,this.dataLength=0}}var gi,mi={exports:{}},yi=(gi||(gi=1,function(t){var e=Object.prototype.hasOwnProperty,s="~";function i(){}function r(t,e,s){this.fn=t,this.context=e,this.once=s||!1}function n(t,e,i,n,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var o=new r(i,n||t,a),l=s?s+e:e;return t._events[l]?t._events[l].fn?t._events[l]=[t._events[l],o]:t._events[l].push(o):(t._events[l]=o,t._eventsCount++),t}function a(t,e){0===--t._eventsCount?t._events=new i:delete t._events[e]}function o(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(s=!1)),o.prototype.eventNames=function(){var t,i,r=[];if(0===this._eventsCount)return r;for(i in t=this._events)e.call(t,i)&&r.push(s?i.slice(1):i);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},o.prototype.listeners=function(t){var e=s?s+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,n=i.length,a=new Array(n);r<n;r++)a[r]=i[r].fn;return a},o.prototype.listenerCount=function(t){var e=s?s+t:t,i=this._events[e];return i?i.fn?1:i.length:0},o.prototype.emit=function(t,e,i,r,n,a){var o=s?s+t:t;if(!this._events[o])return!1;var l,h,c=this._events[o],d=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),d){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,i),!0;case 4:return c.fn.call(c.context,e,i,r),!0;case 5:return c.fn.call(c.context,e,i,r,n),!0;case 6:return c.fn.call(c.context,e,i,r,n,a),!0}for(h=1,l=new Array(d-1);h<d;h++)l[h-1]=arguments[h];c.fn.apply(c.context,l)}else{var u,p=c.length;for(h=0;h<p;h++)switch(c[h].once&&this.removeListener(t,c[h].fn,void 0,!0),d){case 1:c[h].fn.call(c[h].context);break;case 2:c[h].fn.call(c[h].context,e);break;case 3:c[h].fn.call(c[h].context,e,i);break;case 4:c[h].fn.call(c[h].context,e,i,r);break;default:if(!l)for(u=1,l=new Array(d-1);u<d;u++)l[u-1]=arguments[u];c[h].fn.apply(c[h].context,l)}}return!0},o.prototype.on=function(t,e,s){return n(this,t,e,s,!1)},o.prototype.once=function(t,e,s){return n(this,t,e,s,!0)},o.prototype.removeListener=function(t,e,i,r){var n=s?s+t:t;if(!this._events[n])return this;if(!e)return a(this,n),this;var o=this._events[n];if(o.fn)o.fn!==e||r&&!o.once||i&&o.context!==i||a(this,n);else{for(var l=0,h=[],c=o.length;l<c;l++)(o[l].fn!==e||r&&!o[l].once||i&&o[l].context!==i)&&h.push(o[l]);h.length?this._events[n]=1===h.length?h[0]:h:a(this,n)}return this},o.prototype.removeAllListeners=function(t){var e;return t?(e=s?s+t:t,this._events[e]&&a(this,e)):(this._events=new i,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=s,o.EventEmitter=o,t.exports=o}(mi)),mi.exports),vi=O(yi);const bi="1.6.15",_i={};function Ti(t,e){return e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128}function Ai(t,e){return e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128}function Ei(t,e){let s=0;return s=(127&t[e])<<21,s|=(127&t[e+1])<<14,s|=(127&t[e+2])<<7,s|=127&t[e+3],s}function Si(t,e){const s=e;let i=0;for(;Ai(t,e);)i+=10,i+=Ei(t,e+6),Ti(t,e+10)&&(i+=10),e+=i;if(i>0)return t.subarray(s,s+i)}function Ci(t,e){return 255===t[e]&&240==(246&t[e+1])}function ki(t,e){return 1&t[e+1]?7:9}function wi(t,e){return(3&t[e+3])<<11|t[e+4]<<3|(224&t[e+5])>>>5}function Li(t,e){return e+1<t.length&&Ci(t,e)}function Ii(t,e){if(Li(t,e)){const s=ki(t,e);if(e+s>=t.length)return!1;const i=wi(t,e);if(i<=s)return!1;const r=e+i;return r===t.length||Li(t,r)}return!1}function Pi(t,e,s,i,r){if(!t.samplerate){const n=function(t,e,s,i){const r=e[s+2],n=r>>2&15;if(n>12){const e=new Error(`invalid ADTS sampling index:${n}`);return void t.emit(l.ERROR,l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_PARSING_ERROR,fatal:!0,error:e,reason:e.message})}const h=1+(r>>6&3),c=e[s+3]>>6&3|(1&r)<<2,d="mp4a.40."+h,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350][n];let p=n;5!==h&&29!==h||(p-=3);const f=[h<<3|(14&p)>>1,(1&p)<<7|c<<3];return L.log(`manifest codec:${i}, parsed codec:${d}, channels:${c}, rate:${u} (ADTS object type:${h} sampling index:${n})`),{config:f,samplerate:u,channelCount:c,codec:d,parsedCodec:d,manifestCodec:i}}(e,s,i,r);if(!n)return;b(t,n)}}function xi(t){return 9216e4/t}function Ri(t,e,s,i,r){const n=i+r*xi(t.samplerate),a=function(t,e){const s=ki(t,e);if(e+s<=t.length){const i=wi(t,e)-s;if(i>0)return{headerLength:s,frameLength:i}}}(e,s);let o;if(a){const{frameLength:i,headerLength:r}=a,l=r+i,h=Math.max(0,s+l-e.length);h?(o=new Uint8Array(l-r),o.set(e.subarray(s+r,e.length),0)):o=e.subarray(s+r,s+l);const c={unit:o,pts:n};return h||t.samples.push(c),{sample:c,length:l,missing:h}}const l=e.length-s;return o=new Uint8Array(l),o.set(e.subarray(s,e.length),0),{sample:{unit:o,pts:n},length:l,missing:-1}}function Di(t,e){return Ai(t,e)&&Ei(t,e+6)+10<=t.length-e}function Oi(t,e=0,s=1/0){return function(t,e,s,i){const r=(n=t)instanceof ArrayBuffer?n:n.buffer;var n;let a=1;"BYTES_PER_ELEMENT"in i&&(a=i.BYTES_PER_ELEMENT);const o=(d=t)&&d.buffer instanceof ArrayBuffer&&void 0!==d.byteLength&&void 0!==d.byteOffset?t.byteOffset:0,l=(o+t.byteLength)/a,h=(o+e)/a,c=Math.floor(Math.max(0,Math.min(h,l)));var d;return new i(r,c,Math.floor(Math.min(c+Math.max(s,0),l))-c)}(t,e,s,Uint8Array)}function Mi(t){return"PRIV"===t.type?function(t){if(t.size<2)return;const e=x(t.data,!0),s=new Uint8Array(t.data.subarray(e.length+1));return{key:t.type,info:e,data:s.buffer}}(t):"W"===t.type[0]?function(t){if("WXXX"===t.type){if(t.size<2)return;let e=1;const s=x(t.data.subarray(e),!0);e+=s.length+1;const i=x(t.data.subarray(e));return{key:t.type,info:s,data:i}}const e=x(t.data);return{key:t.type,info:"",data:e}}(t):"APIC"===t.type?function(t){const e={key:t.type,description:"",data:"",mimeType:null,pictureType:null};if(t.size<2)return;if(3!==t.data[0])return void console.log("Ignore frame with unrecognized character encoding");const s=t.data.subarray(1).indexOf(0);if(-1===s)return;const i=x(Oi(t.data,1,s)),r=t.data[2+s],n=t.data.subarray(3+s).indexOf(0);if(-1===n)return;const a=x(Oi(t.data,3+s,n));let o;return o="--\x3e"===i?x(Oi(t.data,4+s+n)):(l=t.data.subarray(4+s+n))instanceof ArrayBuffer?l:0==l.byteOffset&&l.byteLength==l.buffer.byteLength?l.buffer:new Uint8Array(l).buffer,e.mimeType=i,e.pictureType=r,e.description=a,e.data=o,e;var l}(t):function(t){if(t.size<2)return;if("TXXX"===t.type){let e=1;const s=x(t.data.subarray(e),!0);e+=s.length+1;const i=x(t.data.subarray(e));return{key:t.type,info:s,data:i}}const e=x(t.data.subarray(1));return{key:t.type,info:"",data:e}}(t)}function Fi(t){const e=String.fromCharCode(t[0],t[1],t[2],t[3]),s=Ei(t,4);return{type:e,size:s,data:t.subarray(10,10+s)}}function Ni(t){let e=0;const s=[];for(;Ai(t,e);){const i=Ei(t,e+6);t[e+5]>>6&1&&(e+=10),e+=10;const r=e+i;for(;e+10<r;){const i=Fi(t.subarray(e)),r=Mi(i);r&&s.push(r),e+=i.size+10}Ti(t,e)&&(e+=10)}return s}function Bi(t){return t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info}function ji(t){if(8===t.data.byteLength){const e=new Uint8Array(t.data),s=1&e[3];let i=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return i/=45,s&&(i+=47721858.84),Math.round(i)}}function $i(t){const e=Ni(t);for(let t=0;t<e.length;t++){const s=e[t];if(Bi(s))return ji(s)}}let Ui=function(t){return t.audioId3="org.id3",t.dateRange="com.apple.quicktime.HLS",t.emsg="https://aomedia.org/emsg/ID3",t.misbklv="urn:misb:KLV:bin:1910.1",t}({});function Hi(t="",e=9e4){return{type:t,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Vi{constructor(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.basePTS=null,this.initPTS=null,this.lastPTS=null}resetInitSegment(t,e,s,i){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(t){this.initPTS=t,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(t,e){return!1}appendFrame(t,e,s){}demux(t,e){this.cachedData&&(t=dt(this.cachedData,t),this.cachedData=null);let s,r=Si(t,0),n=r?r.length:0;const a=this._audioTrack,o=this._id3Track,l=r?$i(r):void 0,h=t.length;for((null===this.basePTS||0===this.frameIndex&&i(l))&&(this.basePTS=Gi(l,e,this.initPTS),this.lastPTS=this.basePTS),null===this.lastPTS&&(this.lastPTS=this.basePTS),r&&r.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Ui.audioId3,duration:Number.POSITIVE_INFINITY});n<h;){if(this.canParse(t,n)){const e=this.appendFrame(a,t,n);e?(this.frameIndex++,this.lastPTS=e.sample.pts,n+=e.length,s=n):n=h}else Di(t,n)?(r=Si(t,n),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Ui.audioId3,duration:Number.POSITIVE_INFINITY}),n+=r.length,s=n):n++;if(n===h&&s!==h){const e=t.slice(s);this.cachedData?this.cachedData=dt(this.cachedData,e):this.cachedData=e}}return{audioTrack:a,videoTrack:Hi(),id3Track:o,textTrack:Hi()}}demuxSampleAes(t,e,s){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(t){const e=this.cachedData;return e&&(this.cachedData=null,this.demux(e,0)),{audioTrack:this._audioTrack,videoTrack:Hi(),id3Track:this._id3Track,textTrack:Hi()}}destroy(){this.cachedData=null,this._audioTrack=this._id3Track=void 0}}const Gi=(t,e,s)=>i(t)?90*t:9e4*e+(s?9e4*s.baseTime/s.timescale:0);let Wi=null;const Ki=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],zi=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],qi=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Yi=[0,1,1,4];function Xi(t,e,s,i,r){if(s+24>e.length)return;const n=Qi(e,s);if(n&&s+n.frameLength<=e.length){const a=i+r*(9e4*n.samplesPerFrame/n.sampleRate),o={unit:e.subarray(s,s+n.frameLength),pts:a,dts:a};return t.config=[],t.channelCount=n.channelCount,t.samplerate=n.sampleRate,t.samples.push(o),{sample:o,length:n.frameLength,missing:0}}}function Qi(t,e){const s=t[e+1]>>3&3,i=t[e+1]>>1&3,r=t[e+2]>>4&15,n=t[e+2]>>2&3;if(1!==s&&0!==r&&15!==r&&3!==n){const a=t[e+2]>>1&1,o=t[e+3]>>6,l=1e3*Ki[14*(3===s?3-i:3===i?3:4)+r-1],h=zi[3*(3===s?0:2===s?1:2)+n],c=3===o?1:2,d=qi[s][i],u=Yi[i],p=8*d*u,f=Math.floor(d*l/h+a)*u;if(null===Wi){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Wi=t?parseInt(t[1]):0}return!!Wi&&Wi<=87&&2===i&&l>=224e3&&0===o&&(t[e+3]=128|t[e+3]),{sampleRate:h,channelCount:c,frameLength:f,samplesPerFrame:p}}}function Zi(t,e){return!(255!==t[e]||224&~t[e+1]||!(6&t[e+1]))}function Ji(t,e){return e+1<t.length&&Zi(t,e)}function tr(t,e){if(e+1<t.length&&Zi(t,e)){const s=4,i=Qi(t,e);let r=s;null!=i&&i.frameLength&&(r=i.frameLength);const n=e+r;return n===t.length||Ji(t,n)}return!1}const er=(t,e)=>{let s=0,i=5;e+=i;const r=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;i>0;){a[0]=t[e];const o=Math.min(i,8),l=8-o;n[0]=4278190080>>>24+l<<l,r[0]=(a[0]&n[0])>>l,s=s?s<<o|r[0]:r[0],e+=1,i-=o}return s};function sr(t,e,s,i,r){if(s+8>e.length)return-1;if(11!==e[s]||119!==e[s+1])return-1;const n=e[s+4]>>6;if(n>=3)return-1;const a=[48e3,44100,32e3][n],o=63&e[s+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+n];if(s+l>e.length)return-1;const h=e[s+6]>>5;let c=0;2===h?c+=2:(1&h&&1!==h&&(c+=2),4&h&&(c+=2));const d=(e[s+6]<<8|e[s+7])>>12-c&1,u=[2,1,2,3,3,4,4,5][h]+d,p=e[s+5]>>3,f=7&e[s+5],g=new Uint8Array([n<<6|p<<1|f>>2,(3&f)<<6|h<<3|d<<2|o>>4,o<<4&224]),m=i+r*(1536/a*9e4),y=e.subarray(s,s+l);return t.config=g,t.channelCount=u,t.samplerate=a,t.samples.push({unit:y,pts:m}),l}const ir=/\/emsg[-/]ID3/i;function rr(t,e){return i(t.presentationTime)?t.presentationTime/t.timeScale:e+t.presentationTimeDelta/t.timeScale}class nr{constructor(t,e,s){this.keyData=void 0,this.decrypter=void 0,this.keyData=s,this.decrypter=new we(e,{removePKCS7Padding:!1})}decryptBuffer(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer,0)}decryptAacSample(t,e,s){const i=t[e].unit;if(i.length<=16)return;const r=i.subarray(16,i.length-i.length%16),n=r.buffer.slice(r.byteOffset,r.byteOffset+r.length);this.decryptBuffer(n).then(r=>{const n=new Uint8Array(r);i.set(n,16),this.decrypter.isSync()||this.decryptAacSamples(t,e+1,s)}).catch(s)}decryptAacSamples(t,e,s){for(;;e++){if(e>=t.length)return void s();if(!(t[e].unit.length<32||(this.decryptAacSample(t,e,s),this.decrypter.isSync())))return}}getAvcEncryptedData(t){const e=16*Math.floor((t.length-48)/160)+16,s=new Int8Array(e);let i=0;for(let e=32;e<t.length-16;e+=160,i+=16)s.set(t.subarray(e,e+16),i);return s}getAvcDecryptedUnit(t,e){const s=new Uint8Array(e);let i=0;for(let e=32;e<t.length-16;e+=160,i+=16)t.set(s.subarray(i,i+16),e);return t}decryptAvcSample(t,e,s,i,r){const n=mt(r.data),a=this.getAvcEncryptedData(n);this.decryptBuffer(a.buffer).then(a=>{r.data=this.getAvcDecryptedUnit(n,a),this.decrypter.isSync()||this.decryptAvcSamples(t,e,s+1,i)}).catch(i)}decryptAvcSamples(t,e,s,i){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;e++,s=0){if(e>=t.length)return void i();const r=t[e].units;for(;!(s>=r.length);s++){const n=r[s];if(!(n.data.length<=48||1!==n.type&&5!==n.type||(this.decryptAvcSample(t,e,s,i,n),this.decrypter.isSync())))return}}}}class ar{constructor(){this.VideoSample=null}createVideoSample(t,e,s){return{key:t,frame:!1,pts:e,dts:s,units:[],length:0}}getLastNalUnit(t){var e;let s,i=this.VideoSample;if(i&&0!==i.units.length||(i=t[t.length-1]),null!=(e=i)&&e.units){const t=i.units;s=t[t.length-1]}return s}pushAccessUnit(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){const s=e.samples,i=s.length;if(!i)return void e.dropped++;{const e=s[i-1];t.pts=e.pts,t.dts=e.dts}}e.samples.push(t)}}parseNALu(t,e,s){const i=e.byteLength;let r=t.naluState||0;const n=r,a=[];let o,l,h,c=0,d=-1,u=0;for(-1===r&&(d=0,u=this.getNALuType(e,0),r=0,c=1);c<i;)if(o=e[c++],r)if(1!==r)if(o)if(1===o){if(l=c-r-1,d>=0){const t={data:e.subarray(d,l),type:u};a.push(t)}else{const s=this.getLastNalUnit(t.samples);s&&(n&&c<=4-n&&s.state&&(s.data=s.data.subarray(0,s.data.byteLength-n)),l>0&&(s.data=dt(s.data,e.subarray(0,l)),s.state=0))}c<i?(h=this.getNALuType(e,c),d=c,u=h,r=0):r=-1}else r=0;else r=3;else r=o?0:2;else r=o?0:1;if(d>=0&&r>=0){const t={data:e.subarray(d,i),type:u,state:r};a.push(t)}if(0===a.length){const s=this.getLastNalUnit(t.samples);s&&(s.data=dt(s.data,e))}return t.naluState=r,a}}class or{constructor(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const t=this.data,e=this.bytesAvailable,s=t.byteLength-e,i=new Uint8Array(4),r=Math.min(4,e);if(0===r)throw new Error("no bytes available");i.set(t.subarray(s,s+r)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*r,this.bytesAvailable-=r}skipBits(t){let e;t=Math.min(t,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(e=(t-=this.bitsAvailable)>>3,t-=e<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)}readBits(t){let e=Math.min(this.bitsAvailable,t);const s=this.word>>>32-e;if(t>32&&L.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return e=t-e,e>0&&this.bitsAvailable?s<<e|this.readBits(e):s}skipLZ(){let t;for(t=0;t<this.bitsAvailable;++t)if(this.word&2147483648>>>t)return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const t=this.skipLZ();return this.readBits(t+1)-1}readEG(){const t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)}readBoolean(){return 1===this.readBits(1)}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}}class lr extends ar{parsePES(t,e,s,i){const r=this.parseNALu(t,s.data,i);let n,a=this.VideoSample,o=!1;s.data=null,a&&r.length&&!t.audFound&&(this.pushAccessUnit(a,t),a=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts)),r.forEach(i=>{var r,l;switch(i.type){case 1:{let e=!1;n=!0;const r=i.data;if(o&&r.length>4){const t=this.readSliceType(r);2!==t&&4!==t&&7!==t&&9!==t||(e=!0)}var h;e&&null!=(h=a)&&h.frame&&!a.key&&(this.pushAccessUnit(a,t),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),a.frame=!0,a.key=e;break}case 5:n=!0,null!=(r=a)&&r.frame&&!a.key&&(this.pushAccessUnit(a,t),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),a.key=!0,a.frame=!0;break;case 6:n=!0,gt(i.data,1,s.pts,e.samples);break;case 7:{var c,d;n=!0,o=!0;const e=i.data,s=this.readSPS(e);if(!t.sps||t.width!==s.width||t.height!==s.height||(null==(c=t.pixelRatio)?void 0:c[0])!==s.pixelRatio[0]||(null==(d=t.pixelRatio)?void 0:d[1])!==s.pixelRatio[1]){t.width=s.width,t.height=s.height,t.pixelRatio=s.pixelRatio,t.sps=[e];const i=e.subarray(1,4);let r="avc1.";for(let t=0;t<3;t++){let e=i[t].toString(16);e.length<2&&(e="0"+e),r+=e}t.codec=r}break}case 8:n=!0,t.pps=[i.data];break;case 9:n=!0,t.audFound=!0,null!=(l=a)&&l.frame&&(this.pushAccessUnit(a,t),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts));break;case 12:n=!0;break;default:n=!1}a&&n&&a.units.push(i)}),i&&a&&(this.pushAccessUnit(a,t),this.VideoSample=null)}getNALuType(t,e){return 31&t[e]}readSliceType(t){const e=new or(t);return e.readUByte(),e.readUEG(),e.readUEG()}skipScalingList(t,e){let s,i=8,r=8;for(let n=0;n<t;n++)0!==r&&(s=e.readEG(),r=(i+s+256)%256),i=0===r?i:r}readSPS(t){const e=new or(t);let s,i,r,n=0,a=0,o=0,l=0;const h=e.readUByte.bind(e),c=e.readBits.bind(e),d=e.readUEG.bind(e),u=e.readBoolean.bind(e),p=e.skipBits.bind(e),f=e.skipEG.bind(e),g=e.skipUEG.bind(e),m=this.skipScalingList.bind(this);h();const y=h();if(c(5),p(3),h(),g(),100===y||110===y||122===y||244===y||44===y||83===y||86===y||118===y||128===y){const t=d();if(3===t&&p(1),g(),g(),p(1),u())for(i=3!==t?8:12,r=0;r<i;r++)u()&&m(r<6?16:64,e)}g();const v=d();if(0===v)d();else if(1===v)for(p(1),f(),f(),s=d(),r=0;r<s;r++)f();g(),p(1);const b=d(),_=d(),T=c(1);0===T&&p(1),p(1),u()&&(n=d(),a=d(),o=d(),l=d());let A=[1,1];if(u()&&u())switch(h()){case 1:A=[1,1];break;case 2:A=[12,11];break;case 3:A=[10,11];break;case 4:A=[16,11];break;case 5:A=[40,33];break;case 6:A=[24,11];break;case 7:A=[20,11];break;case 8:A=[32,11];break;case 9:A=[80,33];break;case 10:A=[18,11];break;case 11:A=[15,11];break;case 12:A=[64,33];break;case 13:A=[160,99];break;case 14:A=[4,3];break;case 15:A=[3,2];break;case 16:A=[2,1];break;case 255:A=[h()<<8|h(),h()<<8|h()]}return{width:Math.ceil(16*(b+1)-2*n-2*a),height:(2-T)*(_+1)*16-(T?2:4)*(o+l),pixelRatio:A}}}class hr extends ar{constructor(...t){super(...t),this.initVPS=null}parsePES(t,e,s,i){const r=this.parseNALu(t,s.data,i);let n,a=this.VideoSample,o=!1;s.data=null,a&&r.length&&!t.audFound&&(this.pushAccessUnit(a,t),a=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts)),r.forEach(i=>{var r,l;switch(i.type){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:a||(a=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts)),a.frame=!0,n=!0;break;case 16:case 17:case 18:case 21:var h;n=!0,o&&null!=(h=a)&&h.frame&&!a.key&&(this.pushAccessUnit(a,t),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),a.key=!0,a.frame=!0;break;case 19:case 20:n=!0,null!=(r=a)&&r.frame&&!a.key&&(this.pushAccessUnit(a,t),a=this.VideoSample=null),a||(a=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),a.key=!0,a.frame=!0;break;case 39:n=!0,gt(i.data,2,s.pts,e.samples);break;case 32:n=!0,t.vps||("object"!=typeof t.params&&(t.params={}),t.params=b(t.params,this.readVPS(i.data)),this.initVPS=i.data),t.vps=[i.data];break;case 33:if(n=!0,o=!0,void 0===t.vps||t.vps[0]===this.initVPS||void 0===t.sps||this.matchSPS(t.sps[0],i.data)||(this.initVPS=t.vps[0],t.sps=t.pps=void 0),!t.sps){const e=this.readSPS(i.data);t.width=e.width,t.height=e.height,t.pixelRatio=e.pixelRatio,t.codec=e.codecString,t.sps=[],"object"!=typeof t.params&&(t.params={});for(const s in e.params)t.params[s]=e.params[s]}this.pushParameterSet(t.sps,i.data,t.vps),a||(a=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts)),a.key=!0;break;case 34:if(n=!0,"object"==typeof t.params){if(!t.pps){t.pps=[];const e=this.readPPS(i.data);for(const s in e)t.params[s]=e[s]}this.pushParameterSet(t.pps,i.data,t.vps)}break;case 35:n=!0,t.audFound=!0,null!=(l=a)&&l.frame&&(this.pushAccessUnit(a,t),a=null),a||(a=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts));break;default:n=!1}a&&n&&a.units.push(i)}),i&&a&&(this.pushAccessUnit(a,t),this.VideoSample=null)}pushParameterSet(t,e,s){(s&&s[0]===this.initVPS||!s&&!t.length)&&t.push(e)}getNALuType(t,e){return(126&t[e])>>>1}ebsp2rbsp(t){const e=new Uint8Array(t.byteLength);let s=0;for(let i=0;i<t.byteLength;i++)i>=2&&3===t[i]&&0===t[i-1]&&0===t[i-2]||(e[s]=t[i],s++);return new Uint8Array(e.buffer,0,s)}pushAccessUnit(t,e){super.pushAccessUnit(t,e),this.initVPS&&(this.initVPS=null)}readVPS(t){const e=new or(t);return e.readUByte(),e.readUByte(),e.readBits(4),e.skipBits(2),e.readBits(6),{numTemporalLayers:e.readBits(3)+1,temporalIdNested:e.readBoolean()}}readSPS(t){const e=new or(this.ebsp2rbsp(t));e.readUByte(),e.readUByte(),e.readBits(4);const s=e.readBits(3);e.readBoolean();const i=e.readBits(2),r=e.readBoolean(),n=e.readBits(5),a=e.readUByte(),o=e.readUByte(),l=e.readUByte(),h=e.readUByte(),c=e.readUByte(),d=e.readUByte(),u=e.readUByte(),p=e.readUByte(),f=e.readUByte(),g=e.readUByte(),m=e.readUByte(),y=[],v=[];for(let t=0;t<s;t++)y.push(e.readBoolean()),v.push(e.readBoolean());if(s>0)for(let t=s;t<8;t++)e.readBits(2);for(let t=0;t<s;t++)y[t]&&(e.readUByte(),e.readUByte(),e.readUByte(),e.readUByte(),e.readUByte(),e.readUByte(),e.readUByte(),e.readUByte(),e.readUByte(),e.readUByte(),e.readUByte()),v[t]&&e.readUByte();e.readUEG();const b=e.readUEG();3==b&&e.skipBits(1);const _=e.readUEG(),T=e.readUEG(),A=e.readBoolean();let E=0,S=0,C=0,k=0;A&&(E+=e.readUEG(),S+=e.readUEG(),C+=e.readUEG(),k+=e.readUEG());const w=e.readUEG(),L=e.readUEG(),I=e.readUEG();for(let t=e.readBoolean()?0:s;t<=s;t++)e.skipUEG(),e.skipUEG(),e.skipUEG();if(e.skipUEG(),e.skipUEG(),e.skipUEG(),e.skipUEG(),e.skipUEG(),e.skipUEG(),e.readBoolean()&&e.readBoolean())for(let t=0;t<4;t++)for(let s=0;s<(3===t?2:6);s++)if(e.readBoolean()){const s=Math.min(64,1<<4+(t<<1));t>1&&e.readEG();for(let t=0;t<s;t++)e.readEG()}else e.readUEG();e.readBoolean(),e.readBoolean(),e.readBoolean()&&(e.readUByte(),e.skipUEG(),e.skipUEG(),e.readBoolean());const P=e.readUEG();let x=0;for(let t=0;t<P;t++){let s=!1;if(0!==t&&(s=e.readBoolean()),s){t===P&&e.readUEG(),e.readBoolean(),e.readUEG();let s=0;for(let t=0;t<=x;t++){const t=e.readBoolean();let i=!1;t||(i=e.readBoolean()),(t||i)&&s++}x=s}else{const t=e.readUEG(),s=e.readUEG();x=t+s;for(let s=0;s<t;s++)e.readUEG(),e.readBoolean();for(let t=0;t<s;t++)e.readUEG(),e.readBoolean()}}if(e.readBoolean()){const t=e.readUEG();for(let s=0;s<t;s++){for(let t=0;t<I+4;t++)e.readBits(1);e.readBits(1)}}let R=0,D=1,O=1,M=!0,F=1,N=0;e.readBoolean(),e.readBoolean();let B=!1;if(e.readBoolean()){if(e.readBoolean()){const t=e.readUByte();t>0&&t<16?(D=[1,12,10,16,40,24,20,32,80,18,15,64,160,4,3,2][t-1],O=[1,11,11,11,33,11,11,11,33,11,11,33,99,3,2,1][t-1]):255===t&&(D=e.readBits(16),O=e.readBits(16))}if(e.readBoolean()&&e.readBoolean(),e.readBoolean()&&(e.readBits(3),e.readBoolean(),e.readBoolean()&&(e.readUByte(),e.readUByte(),e.readUByte())),e.readBoolean()&&(e.readUEG(),e.readUEG()),e.readBoolean(),e.readBoolean(),e.readBoolean(),B=e.readBoolean(),B&&(e.skipUEG(),e.skipUEG(),e.skipUEG(),e.skipUEG()),e.readBoolean()&&(F=e.readBits(32),N=e.readBits(32),e.readBoolean()&&e.readUEG(),e.readBoolean())){const t=e.readBoolean(),i=e.readBoolean();let r=!1;(t||i)&&(r=e.readBoolean(),r&&(e.readUByte(),e.readBits(5),e.readBoolean(),e.readBits(5)),e.readBits(4),e.readBits(4),r&&e.readBits(4),e.readBits(5),e.readBits(5),e.readBits(5));for(let n=0;n<=s;n++){M=e.readBoolean();let s=!1;M||e.readBoolean()?e.readEG():s=e.readBoolean();const n=s?1:e.readUEG()+1;if(t)for(let t=0;t<n;t++)e.readUEG(),e.readUEG(),r&&(e.readUEG(),e.readUEG()),e.skipBits(1);if(i)for(let t=0;t<n;t++)e.readUEG(),e.readUEG(),r&&(e.readUEG(),e.readUEG()),e.skipBits(1)}}e.readBoolean()&&(e.readBoolean(),e.readBoolean(),e.readBoolean(),R=e.readUEG())}let j=_,$=T;if(A){let t=1,e=1;1===b?t=e=2:2==b&&(t=2),j=_-t*S-t*E,$=T-e*k-e*C}const U=i?["A","B","C"][i]:"",H=a<<24|o<<16|l<<8|h;let V=0;for(let t=0;t<32;t++)V=(V|(H>>t&1)<<31-t)>>>0;let G=V.toString(16);return 1===n&&"2"===G&&(G="6"),{codecString:`hvc1.${U}${n}.${G}.${r?"H":"L"}${m}.B0`,params:{general_tier_flag:r,general_profile_idc:n,general_profile_space:i,general_profile_compatibility_flags:[a,o,l,h],general_constraint_indicator_flags:[c,d,u,p,f,g],general_level_idc:m,bit_depth:w+8,bit_depth_luma_minus8:w,bit_depth_chroma_minus8:L,min_spatial_segmentation_idc:R,chroma_format_idc:b,frame_rate:{fixed:M,fps:N/F}},width:j,height:$,pixelRatio:[D,O]}}readPPS(t){const e=new or(this.ebsp2rbsp(t));e.readUByte(),e.readUByte(),e.skipUEG(),e.skipUEG(),e.skipBits(2),e.skipBits(3),e.skipBits(2),e.skipUEG(),e.skipUEG(),e.skipEG(),e.skipBits(2),e.readBoolean()&&e.skipUEG(),e.skipEG(),e.skipEG(),e.skipBits(4);const s=e.readBoolean(),i=e.readBoolean();let r=1;return i&&s?r=0:i?r=3:s&&(r=2),{parallelismType:r}}matchSPS(t,e){return String.fromCharCode.apply(null,t).substr(3)===String.fromCharCode.apply(null,e).substr(3)}}const cr=188;class dr{constructor(t,e,s,i){this.logger=void 0,this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=t,this.config=e,this.typeSupported=s,this.logger=i,this.videoParser=null}static probe(t,e){const s=dr.syncOffset(t);return s>0&&e.warn(`MPEG2-TS detected but first sync word found @ offset ${s}`),-1!==s}static syncOffset(t){const e=t.length;let s=Math.min(940,e-cr)+1,i=0;for(;i<s;){let r=!1,n=-1,a=0;for(let o=i;o<e;o+=cr){if(71!==t[o]||e-o!==cr&&71!==t[o+cr]){if(a)return-1;break}if(a++,-1===n&&(n=o,0!==n&&(s=Math.min(n+18612,t.length-cr)+1)),r||(r=0===ur(t,o)),r&&a>1&&(0===n&&a>2||o+cr>s))return n}i++}return-1}static createTrack(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:Y[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}}resetInitSegment(t,e,s,i){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=dr.createTrack("video"),this._videoTrack.duration=i,this._audioTrack=dr.createTrack("audio",i),this._id3Track=dr.createTrack("id3"),this._txtTrack=dr.createTrack("text"),this._audioTrack.segmentCodec="aac",this.videoParser=null,this.aacOverFlow=null,this.remainderData=null,this.audioCodec=e,this.videoCodec=s}resetTimeStamp(){}resetContiguity(){const{_audioTrack:t,_videoTrack:e,_id3Track:s}=this;t&&(t.pesData=null),e&&(e.pesData=null),s&&(s.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(t,e,s=!1,i=!1){let r;s||(this.sampleAes=null);const n=this._videoTrack,a=this._audioTrack,o=this._id3Track,l=this._txtTrack;let h=n.pid,c=n.pesData,d=a.pid,u=o.pid,p=a.pesData,f=o.pesData,g=null,m=this.pmtParsed,y=this._pmtId,v=t.length;if(this.remainderData&&(v=(t=dt(this.remainderData,t)).length,this.remainderData=null),v<cr&&!i)return this.remainderData=t,{audioTrack:a,videoTrack:n,id3Track:o,textTrack:l};const b=Math.max(0,dr.syncOffset(t));v-=(v-b)%cr,v<t.byteLength&&!i&&(this.remainderData=new Uint8Array(t.buffer,v,t.buffer.byteLength-v));let _=0;for(let e=b;e<v;e+=cr)if(71===t[e]){const i=!!(64&t[e+1]),v=ur(t,e);let _;if((48&t[e+3])>>4>1){if(_=e+5+t[e+4],_===e+cr)continue}else _=e+4;switch(v){case h:i&&(c&&(r=yr(c,this.logger))&&(this.readyVideoParser(n.segmentCodec),null!==this.videoParser&&this.videoParser.parsePES(n,l,r,!1)),c={data:[],size:0}),c&&(c.data.push(t.subarray(_,e+cr)),c.size+=e+cr-_);break;case d:if(i){if(p&&(r=yr(p,this.logger)))switch(a.segmentCodec){case"aac":this.parseAACPES(a,r);break;case"mp3":this.parseMPEGPES(a,r);break;case"ac3":this.parseAC3PES(a,r)}p={data:[],size:0}}p&&(p.data.push(t.subarray(_,e+cr)),p.size+=e+cr-_);break;case u:i&&(f&&(r=yr(f,this.logger))&&this.parseID3PES(o,r),f={data:[],size:0}),f&&(f.data.push(t.subarray(_,e+cr)),f.size+=e+cr-_);break;case 0:i&&(_+=t[_]+1),y=this._pmtId=pr(t,_);break;case y:{i&&(_+=t[_]+1);const r=fr(t,_,this.typeSupported,s,this.observer,this.logger);h=r.videoPid,h>0&&(n.pid=h,n.segmentCodec=r.segmentVideoCodec),d=r.audioPid,d>0&&(a.pid=d,a.segmentCodec=r.segmentAudioCodec),u=r.id3Pid,u>0&&(o.pid=u),null===g||m||(this.logger.warn(`MPEG-TS PMT found at ${e} after unknown PID '${g}'. Backtracking to sync byte @${b} to parse all TS packets.`),g=null,e=b-188),m=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=v}}else _++;_>0&&gr(this.observer,new Error(`Found ${_} TS packet/s that do not start with 0x47`),void 0,this.logger),n.pesData=c,a.pesData=p,o.pesData=f;const T={audioTrack:a,videoTrack:n,id3Track:o,textTrack:l};return i&&this.extractRemainingSamples(T),T}flush(){const{remainderData:t}=this;let e;return this.remainderData=null,e=t?this.demux(t,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(e),this.sampleAes?this.decrypt(e,this.sampleAes):e}extractRemainingSamples(t){const{audioTrack:e,videoTrack:s,id3Track:i,textTrack:r}=t,n=s.pesData,a=e.pesData,o=i.pesData;let l;if(n&&(l=yr(n,this.logger))?(this.readyVideoParser(s.segmentCodec),null!==this.videoParser&&(this.videoParser.parsePES(s,r,l,!0),s.pesData=null)):s.pesData=n,a&&(l=yr(a,this.logger))){switch(e.segmentCodec){case"aac":this.parseAACPES(e,l);break;case"mp3":this.parseMPEGPES(e,l);break;case"ac3":this.parseAC3PES(e,l)}e.pesData=null}else null!=a&&a.size&&this.logger.log("last AAC PES packet truncated,might overlap between fragments"),e.pesData=a;o&&(l=yr(o,this.logger))?(this.parseID3PES(i,l),i.pesData=null):i.pesData=o}demuxSampleAes(t,e,s){const i=this.demux(t,s,!0,!this.config.progressive),r=this.sampleAes=new nr(this.observer,this.config,e);return this.decrypt(i,r)}readyVideoParser(t){null===this.videoParser&&("avc"===t?this.videoParser=new lr:"hevc"===t&&(this.videoParser=new hr))}decrypt(t,e){return new Promise(s=>{const{audioTrack:i,videoTrack:r}=t;i.samples&&"aac"===i.segmentCodec?e.decryptAacSamples(i.samples,0,()=>{r.samples?e.decryptAvcSamples(r.samples,0,0,()=>{s(t)}):s(t)}):r.samples&&e.decryptAvcSamples(r.samples,0,0,()=>{s(t)})})}destroy(){this.observer&&this.observer.removeAllListeners(),this.config=this.logger=this.observer=null,this.aacOverFlow=this.videoParser=this.remainderData=this.sampleAes=null,this._videoTrack=this._audioTrack=this._id3Track=this._txtTrack=void 0}parseAACPES(t,e){let s=0;const i=this.aacOverFlow;let r,n,a,o=e.data;if(i){this.aacOverFlow=null;const e=i.missing,r=i.sample.unit.byteLength;if(-1===e)o=dt(i.sample.unit,o);else{const n=r-e;i.sample.unit.set(o.subarray(0,e),n),t.samples.push(i.sample),s=i.missing}}for(r=s,n=o.length;r<n-1&&!Li(o,r);r++);if(r!==s){let t;const e=r<n-1;if(t=e?`AAC PES did not start with ADTS header,offset:${r}`:"No ADTS header found in AAC PES",gr(this.observer,new Error(t),e,this.logger),!e)return}if(Pi(t,this.observer,o,r,this.audioCodec),void 0!==e.pts)a=e.pts;else{if(!i)return void this.logger.warn("[tsdemuxer]: AAC PES unknown PTS");{const e=xi(t.samplerate);a=i.sample.pts+e}}let l,h=0;for(;r<n;){if(l=Ri(t,o,r,a,h),r+=l.length,l.missing){this.aacOverFlow=l;break}for(h++;r<n-1&&!Li(o,r);r++);}}parseMPEGPES(t,e){const s=e.data,i=s.length;let r=0,n=0;const a=e.pts;if(void 0!==a)for(;n<i;)if(Ji(s,n)){const e=Xi(t,s,n,a,r);if(!e)break;n+=e.length,r++}else n++;else this.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")}parseAC3PES(t,e){{const s=e.data,i=e.pts;if(void 0===i)return void this.logger.warn("[tsdemuxer]: AC3 PES unknown PTS");const r=s.length;let n,a=0,o=0;for(;o<r&&(n=sr(t,s,o,i,a++))>0;)o+=n}}parseID3PES(t,e){if(void 0===e.pts)return void this.logger.warn("[tsdemuxer]: ID3 PES unknown PTS");const s=b({},e,{type:this._videoTrack?Ui.emsg:Ui.audioId3,duration:Number.POSITIVE_INFINITY});t.samples.push(s)}}function ur(t,e){return((31&t[e+1])<<8)+t[e+2]}function pr(t,e){return(31&t[e+10])<<8|t[e+11]}function fr(t,e,s,i,r,n){const a={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},o=e+3+((15&t[e+1])<<8|t[e+2])-4;for(e+=12+((15&t[e+10])<<8|t[e+11]);e<o;){const o=ur(t,e),l=(15&t[e+3])<<8|t[e+4];switch(t[e]){case 207:if(!i){mr("ADTS AAC",n);break}case 15:-1===a.audioPid&&(a.audioPid=o);break;case 21:-1===a.id3Pid&&(a.id3Pid=o);break;case 219:if(!i){mr("H.264",n);break}case 27:-1===a.videoPid&&(a.videoPid=o);break;case 3:case 4:s.mpeg||s.mp3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="mp3"):n.log("MPEG audio found, not supported in this browser");break;case 193:if(!i){mr("AC-3",n);break}case 129:s.ac3?-1===a.audioPid&&(a.audioPid=o,a.segmentAudioCodec="ac3"):n.log("AC-3 audio found, not supported in this browser");break;case 6:if(-1===a.audioPid&&l>0){let i=e+5,r=l;for(;r>2;){106===t[i]&&(!0!==s.ac3?n.log("AC-3 audio found, not supported in this browser for now"):(a.audioPid=o,a.segmentAudioCodec="ac3"));const e=t[i+1]+2;i+=e,r-=e}}break;case 194:case 135:return gr(r,new Error("Unsupported EC-3 in M2TS found"),void 0,n),a;case 36:-1===a.videoPid&&(a.videoPid=o,a.segmentVideoCodec="hevc",n.log("HEVC in M2TS found"))}e+=l+5}return a}function gr(t,e,s,i){i.warn(`parsing error: ${e.message}`),t.emit(l.ERROR,l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_PARSING_ERROR,fatal:!1,levelRetry:s,error:e,reason:e.message})}function mr(t,e){e.log(`${t} with AES-128-CBC encryption found in unencrypted stream`)}function yr(t,e){let s,i,r,n,a,o=0;const l=t.data;if(!t||0===t.size)return null;for(;l[0].length<19&&l.length>1;)l[0]=dt(l[0],l[1]),l.splice(1,1);if(s=l[0],1===(s[0]<<16)+(s[1]<<8)+s[2]){if(i=(s[4]<<8)+s[5],i&&i>t.size-6)return null;const h=s[7];192&h&&(n=536870912*(14&s[9])+4194304*(255&s[10])+16384*(254&s[11])+128*(255&s[12])+(254&s[13])/2,64&h?(a=536870912*(14&s[14])+4194304*(255&s[15])+16384*(254&s[16])+128*(255&s[17])+(254&s[18])/2,n-a>54e5&&(e.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),r=s[8];let c=r+9;if(t.size<=c)return null;t.size-=c;const d=new Uint8Array(t.size);for(let t=0,e=l.length;t<e;t++){s=l[t];let e=s.byteLength;if(c){if(c>e){c-=e;continue}s=s.subarray(c),e-=c,c=0}d.set(s,o),o+=e}return i&&(i-=r+3),{data:d,pts:n,dts:a,len:i}}return null}class vr{static getSilentFrame(t,e){if("mp4a.40.2"===t){if(1===e)return new Uint8Array([0,200,0,128,35,128]);if(2===e)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,56]);if(6===e)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,130,48,4,153,0,33,144,2,0,178,0,32,8,224])}else{if(1===e)return new Uint8Array([1,64,34,128,163,78,230,128,186,8,0,0,0,28,6,241,193,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(2===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94]);if(3===e)return new Uint8Array([1,64,34,128,163,94,230,128,186,8,0,0,0,0,149,0,6,241,161,10,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,90,94])}}}const br=Math.pow(2,32)-1;class _r{static init(){let t;for(t in _r.types={avc1:[],avcC:[],hvc1:[],hvcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],dac3:[],"ac-3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]},_r.types)_r.types.hasOwnProperty(t)&&(_r.types[t]=[t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2),t.charCodeAt(3)]);const e=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),s=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]);_r.HDLR_TYPES={video:e,audio:s};const i=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),r=new Uint8Array([0,0,0,0,0,0,0,0]);_r.STTS=_r.STSC=_r.STCO=r,_r.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),_r.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),_r.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),_r.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const n=new Uint8Array([105,115,111,109]),a=new Uint8Array([97,118,99,49]),o=new Uint8Array([0,0,0,1]);_r.FTYP=_r.box(_r.types.ftyp,n,o,n,a),_r.DINF=_r.box(_r.types.dinf,_r.box(_r.types.dref,i))}static box(t,...e){let s=8,i=e.length;const r=i;for(;i--;)s+=e[i].byteLength;const n=new Uint8Array(s);for(n[0]=s>>24&255,n[1]=s>>16&255,n[2]=s>>8&255,n[3]=255&s,n.set(t,4),i=0,s=8;i<r;i++)n.set(e[i],s),s+=e[i].byteLength;return n}static hdlr(t){return _r.box(_r.types.hdlr,_r.HDLR_TYPES[t])}static mdat(t){return _r.box(_r.types.mdat,t)}static mdhd(t,e){e*=t;const s=Math.floor(e/(br+1)),i=Math.floor(e%(br+1));return _r.box(_r.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,s>>24,s>>16&255,s>>8&255,255&s,i>>24,i>>16&255,i>>8&255,255&i,85,196,0,0]))}static mdia(t){return _r.box(_r.types.mdia,_r.mdhd(t.timescale||0,t.duration||0),_r.hdlr(t.type),_r.minf(t))}static mfhd(t){return _r.box(_r.types.mfhd,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,255&t]))}static minf(t){return"audio"===t.type?_r.box(_r.types.minf,_r.box(_r.types.smhd,_r.SMHD),_r.DINF,_r.stbl(t)):_r.box(_r.types.minf,_r.box(_r.types.vmhd,_r.VMHD),_r.DINF,_r.stbl(t))}static moof(t,e,s){return _r.box(_r.types.moof,_r.mfhd(t),_r.traf(s,e))}static moov(t){let e=t.length;const s=[];for(;e--;)s[e]=_r.trak(t[e]);return _r.box.apply(null,[_r.types.moov,_r.mvhd(t[0].timescale||0,t[0].duration||0)].concat(s).concat(_r.mvex(t)))}static mvex(t){let e=t.length;const s=[];for(;e--;)s[e]=_r.trex(t[e]);return _r.box.apply(null,[_r.types.mvex,...s])}static mvhd(t,e){e*=t;const s=Math.floor(e/(br+1)),i=Math.floor(e%(br+1)),r=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,t>>24&255,t>>16&255,t>>8&255,255&t,s>>24,s>>16&255,s>>8&255,255&s,i>>24,i>>16&255,i>>8&255,255&i,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return _r.box(_r.types.mvhd,r)}static sdtp(t){const e=t.samples||[],s=new Uint8Array(4+e.length);let i,r;for(i=0;i<e.length;i++)r=e[i].flags,s[i+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return _r.box(_r.types.sdtp,s)}static stbl(t){return _r.box(_r.types.stbl,_r.stsd(t),_r.box(_r.types.stts,_r.STTS),_r.box(_r.types.stsc,_r.STSC),_r.box(_r.types.stsz,_r.STSZ),_r.box(_r.types.stco,_r.STCO))}static avc1(t){let e,s,i,r=[],n=[];for(e=0;e<t.sps.length;e++)s=t.sps[e],i=s.byteLength,r.push(i>>>8&255),r.push(255&i),r=r.concat(Array.prototype.slice.call(s));for(e=0;e<t.pps.length;e++)s=t.pps[e],i=s.byteLength,n.push(i>>>8&255),n.push(255&i),n=n.concat(Array.prototype.slice.call(s));const a=_r.box(_r.types.avcC,new Uint8Array([1,r[3],r[4],r[5],255,224|t.sps.length].concat(r).concat([t.pps.length]).concat(n))),o=t.width,l=t.height,h=t.pixelRatio[0],c=t.pixelRatio[1];return _r.box(_r.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,o>>8&255,255&o,l>>8&255,255&l,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),a,_r.box(_r.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),_r.box(_r.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,c>>24,c>>16&255,c>>8&255,255&c])))}static esds(t){const e=t.config;return new Uint8Array([0,0,0,0,3,25,0,1,0,4,17,64,21,0,0,0,0,0,0,0,0,0,0,0,5,2,...e,6,1,2])}static audioStsd(t){const e=t.samplerate||0;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount||0,0,16,0,0,0,0,e>>8&255,255&e,0,0])}static mp4a(t){return _r.box(_r.types.mp4a,_r.audioStsd(t),_r.box(_r.types.esds,_r.esds(t)))}static mp3(t){return _r.box(_r.types[".mp3"],_r.audioStsd(t))}static ac3(t){return _r.box(_r.types["ac-3"],_r.audioStsd(t),_r.box(_r.types.dac3,t.config))}static stsd(t){const{segmentCodec:e}=t;if("audio"===t.type){if("aac"===e)return _r.box(_r.types.stsd,_r.STSD,_r.mp4a(t));if("ac3"===e&&t.config)return _r.box(_r.types.stsd,_r.STSD,_r.ac3(t));if("mp3"===e&&"mp3"===t.codec)return _r.box(_r.types.stsd,_r.STSD,_r.mp3(t))}else{if(!t.pps||!t.sps)throw new Error("video track missing pps or sps");if("avc"===e)return _r.box(_r.types.stsd,_r.STSD,_r.avc1(t));if("hevc"===e&&t.vps)return _r.box(_r.types.stsd,_r.STSD,_r.hvc1(t))}throw new Error(`unsupported ${t.type} segment codec (${e}/${t.codec})`)}static tkhd(t){const e=t.id,s=(t.duration||0)*(t.timescale||0),i=t.width||0,r=t.height||0,n=Math.floor(s/(br+1)),a=Math.floor(s%(br+1));return _r.box(_r.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,a>>24,a>>16&255,a>>8&255,255&a,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,i>>8&255,255&i,0,0,r>>8&255,255&r,0,0]))}static traf(t,e){const s=_r.sdtp(t),i=t.id,r=Math.floor(e/(br+1)),n=Math.floor(e%(br+1));return _r.box(_r.types.traf,_r.box(_r.types.tfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i])),_r.box(_r.types.tfdt,new Uint8Array([1,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,n>>24,n>>16&255,n>>8&255,255&n])),_r.trun(t,s.length+16+20+8+16+8+8),s)}static trak(t){return t.duration=t.duration||4294967295,_r.box(_r.types.trak,_r.tkhd(t),_r.mdia(t))}static trex(t){const e=t.id;return _r.box(_r.types.trex,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(t,e){const s=t.samples||[],i=s.length,r=12+16*i,n=new Uint8Array(r);let a,o,l,h,c,d;for(e+=8+r,n.set(["video"===t.type?1:0,0,15,1,i>>>24&255,i>>>16&255,i>>>8&255,255&i,e>>>24&255,e>>>16&255,e>>>8&255,255&e],0),a=0;a<i;a++)o=s[a],l=o.duration,h=o.size,c=o.flags,d=o.cts,n.set([l>>>24&255,l>>>16&255,l>>>8&255,255&l,h>>>24&255,h>>>16&255,h>>>8&255,255&h,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,61440&c.degradPrio,15&c.degradPrio,d>>>24&255,d>>>16&255,d>>>8&255,255&d],12+16*a);return _r.box(_r.types.trun,n)}static initSegment(t){_r.types||_r.init();const e=_r.moov(t);return dt(_r.FTYP,e)}static hvc1(t){const e=t.params,s=[t.vps,t.sps,t.pps],i=new Uint8Array([1,e.general_profile_space<<6|(e.general_tier_flag?32:0)|e.general_profile_idc,e.general_profile_compatibility_flags[0],e.general_profile_compatibility_flags[1],e.general_profile_compatibility_flags[2],e.general_profile_compatibility_flags[3],e.general_constraint_indicator_flags[0],e.general_constraint_indicator_flags[1],e.general_constraint_indicator_flags[2],e.general_constraint_indicator_flags[3],e.general_constraint_indicator_flags[4],e.general_constraint_indicator_flags[5],e.general_level_idc,240|e.min_spatial_segmentation_idc>>8,255&e.min_spatial_segmentation_idc,252|e.parallelismType,252|e.chroma_format_idc,248|e.bit_depth_luma_minus8,248|e.bit_depth_chroma_minus8,0,parseInt(e.frame_rate.fps),3|e.temporal_id_nested<<2|e.num_temporal_layers<<3|(e.frame_rate.fixed?64:0),s.length]);let r=i.length;for(let t=0;t<s.length;t+=1){r+=3;for(let e=0;e<s[t].length;e+=1)r+=2+s[t][e].length}const n=new Uint8Array(r);n.set(i,0),r=i.length;const a=s.length-1;for(let t=0;t<s.length;t+=1){n.set(new Uint8Array([32+t|(t===a?128:0),0,s[t].length]),r),r+=3;for(let e=0;e<s[t].length;e+=1)n.set(new Uint8Array([s[t][e].length>>8,255&s[t][e].length]),r),r+=2,n.set(s[t][e],r),r+=s[t][e].length}const o=_r.box(_r.types.hvcC,n),l=t.width,h=t.height,c=t.pixelRatio[0],d=t.pixelRatio[1];return _r.box(_r.types.hvc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,h>>8&255,255&h,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,_r.box(_r.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),_r.box(_r.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,d>>24,d>>16&255,d>>8&255,255&d])))}}function Tr(t,e,s=1,i=!1){const r=t*e*s;return i?Math.round(r):r}function Ar(t,e=!1){return Tr(t,1e3,1/9e4,e)}function Er(t){const{baseTime:e,timescale:s,trackId:i}=t;return`${e/s} (${e}/${s}) trackId: ${i}`}_r.types=void 0,_r.HDLR_TYPES=void 0,_r.STTS=void 0,_r.STSC=void 0,_r.STCO=void 0,_r.STSZ=void 0,_r.VMHD=void 0,_r.SMHD=void 0,_r.STSD=void 0,_r.FTYP=void 0,_r.DINF=void 0;let Sr,Cr=null,kr=null;function wr(t,e,s,i){return{duration:e,size:s,cts:i,flags:{isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:t?2:1,isNonSync:t?0:1}}}class Lr extends A{constructor(t,e,s,i){if(super("mp4-remuxer",i),this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextVideoTs=null,this.nextAudioTs=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=t,this.config=e,this.typeSupported=s,this.ISGenerated=!1,null===Cr){const t=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Cr=t?parseInt(t[1]):0}if(null===kr){const t=navigator.userAgent.match(/Safari\/(\d+)/i);kr=t?parseInt(t[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(t){const e=this._initPTS;e&&t&&t.trackId===e.trackId&&t.baseTime===e.baseTime&&t.timescale===e.timescale||this.log(`Reset initPTS: ${e?Er(e):e} > ${t?Er(t):t}`),this._initPTS=this._initDTS=t}resetNextTimestamp(){this.log("reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){this.log("ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(t){let e=!1;const s=t[0].pts,i=t.reduce((t,i)=>{let r=i.pts,n=r-t;return n<-4294967296&&(e=!0,r=Ir(r,s),n=r-t),n>0?t:r},s);return e&&this.debug("PTS rollover detected"),i}remux(t,e,s,i,r,n,a,o){let l,h,c,d,u,p,g=r,m=r;const y=t.pid>-1,v=e.pid>-1,b=e.samples.length,_=t.samples.length>0,T=a&&b>0||b>1;if((!y||_)&&(!v||T)||this.ISGenerated||a){if(this.ISGenerated){var A,E,S,C;const t=this.videoTrackConfig;(t&&(e.width!==t.width||e.height!==t.height||(null==(A=e.pixelRatio)?void 0:A[0])!==(null==(E=t.pixelRatio)?void 0:E[0])||(null==(S=e.pixelRatio)?void 0:S[1])!==(null==(C=t.pixelRatio)?void 0:C[1]))||!t&&T||null===this.nextAudioTs&&_)&&this.resetInitSegment()}this.ISGenerated||(c=this.generateIS(t,e,r,n));const s=this.isVideoContiguous;let i,a=-1;if(T&&(a=function(t){for(let e=0;e<t.length;e++)if(t[e].key)return e;return-1}(e.samples),!s&&this.config.forceKeyFrameOnDiscontinuity))if(p=!0,a>0){this.warn(`Dropped ${a} out of ${b} video samples due to a missing keyframe`);const t=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(a),e.dropped+=a,m+=(e.samples[0].pts-t)/e.inputTimeScale,i=m}else-1===a&&(this.warn(`No keyframe found out of ${b} video samples`),p=!1);if(this.ISGenerated){if(_&&T){const s=this.getVideoStartPts(e.samples),i=(Ir(t.samples[0].pts,s)-s)/e.inputTimeScale;g+=Math.max(0,i),m+=Math.max(0,-i)}if(_){if(t.samplerate||(this.warn("regenerate InitSegment as audio detected"),c=this.generateIS(t,e,r,n)),h=this.remuxAudio(t,g,this.isAudioContiguous,n,v||T||o===f?m:void 0),T){const i=h?h.endPTS-h.startPTS:0;e.inputTimeScale||(this.warn("regenerate InitSegment as video detected"),c=this.generateIS(t,e,r,n)),l=this.remuxVideo(e,m,s,i)}}else T&&(l=this.remuxVideo(e,m,s,0));l&&(l.firstKeyFrame=a,l.independent=-1!==a,l.firstKeyFramePTS=i)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(s.samples.length&&(u=Pr(s,r,this._initPTS,this._initDTS)),i.samples.length&&(d=xr(i,r,this._initPTS))),{audio:h,video:l,initSegment:c,independent:p,text:d,id3:u}}computeInitPts(t,e,s,i){const r=Math.round(s*e);let n=Ir(t,r);if(n<r+e)for(this.log(`Adjusting PTS for rollover in timeline near ${(r-n)/e} ${i}`);n<r+e;)n+=8589934592;return n-r}generateIS(t,e,s,i){const r=t.samples,n=e.samples,a=this.typeSupported,o={},l=this._initPTS;let h,c,d,u=!l||i,p="audio/mp4",f=-1;if(u&&(h=c=1/0),t.config&&r.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":a.mpeg?(p="audio/mpeg",t.codec=""):a.mp3&&(t.codec="mp3");break;case"ac3":t.codec="ac-3"}o.audio={id:"audio",container:p,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&a.mpeg?new Uint8Array(0):_r.initSegment([t]),metadata:{channelCount:t.channelCount}},u&&(f=t.id,d=t.inputTimeScale,l&&d===l.timescale?u=!1:h=c=this.computeInitPts(r[0].pts,d,s,"audio"))}if(e.sps&&e.pps&&n.length){if(e.timescale=e.inputTimeScale,o.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:_r.initSegment([e]),metadata:{width:e.width,height:e.height}},u)if(f=e.id,d=e.inputTimeScale,l&&d===l.timescale)u=!1;else{const t=this.getVideoStartPts(n),e=Ir(n[0].dts,t),i=this.computeInitPts(e,d,s,"video"),r=this.computeInitPts(t,d,s,"video");c=Math.min(c,i),h=Math.min(h,r)}this.videoTrackConfig={width:e.width,height:e.height,pixelRatio:e.pixelRatio}}if(Object.keys(o).length)return this.ISGenerated=!0,u?(l&&this.warn(`Timestamps at playlist time: ${i?"":"~"}${s} ${h/d} != initPTS: ${l.baseTime/l.timescale} (${l.baseTime}/${l.timescale}) trackId: ${l.trackId}`),this.log(`Found initPTS at playlist time: ${s} offset: ${h/d} (${h}/${d}) trackId: ${f}`),this._initPTS={baseTime:h,timescale:d,trackId:f},this._initDTS={baseTime:c,timescale:d,trackId:f}):h=d=void 0,{tracks:o,initPTS:h,timescale:d,trackId:f}}remuxVideo(t,e,s,i){const r=t.inputTimeScale,n=t.samples,h=[],c=n.length,d=this._initPTS,u=d.baseTime*r/d.timescale;let p,f,g=this.nextVideoTs,m=8,y=this.videoSampleDuration,v=Number.POSITIVE_INFINITY,_=Number.NEGATIVE_INFINITY,T=!1;if(!s||null===g){const t=u+e*r,i=n[0].pts-Ir(n[0].dts,n[0].pts);Cr&&null!==g&&Math.abs(t-i-(g+u))<15e3?s=!0:g=t-i-u}const A=g+u;for(let t=0;t<c;t++){const e=n[t];e.pts=Ir(e.pts,A),e.dts=Ir(e.dts,A),e.dts<n[t>0?t-1:t].dts&&(T=!0)}T&&n.sort(function(t,e){const s=t.dts-e.dts,i=t.pts-e.pts;return s||i}),p=n[0].dts,f=n[n.length-1].dts;const E=f-p,S=E?Math.round(E/(c-1)):y||t.inputTimeScale/30;if(s){const s=p-A,i=s>S,r=s<-1;if((i||r)&&(i?this.warn(`${(t.segmentCodec||"").toUpperCase()}: ${Ar(s,!0)} ms (${s}dts) hole between fragments detected at ${e.toFixed(3)}`):this.warn(`${(t.segmentCodec||"").toUpperCase()}: ${Ar(-s,!0)} ms (${s}dts) overlapping between fragments detected at ${e.toFixed(3)}`),!r||A>=n[0].pts||Cr)){p=A;const t=n[0].pts-s;if(i)n[0].dts=p,n[0].pts=t;else{let e=!0;for(let i=0;i<n.length&&!(n[i].dts>t&&e);i++){const t=n[i].pts;if(n[i].dts-=s,n[i].pts-=s,i<n.length-1){const s=n[i+1].pts;e=s<=n[i].pts==s<=t}}}this.log(`Video: Initial PTS/DTS adjusted: ${Ar(t,!0)}/${Ar(p,!0)}, delta: ${Ar(s,!0)} ms`)}}p=Math.max(0,p);let C=0,k=0,w=p;for(let t=0;t<c;t++){const e=n[t],s=e.units,i=s.length;let r=0;for(let t=0;t<i;t++)r+=s[t].data.length;k+=r,C+=i,e.length=r,e.dts<w?(e.dts=w,w+=S/4|0||1):w=e.dts,v=Math.min(e.pts,v),_=Math.max(e.pts,_)}f=n[c-1].dts;const L=k+4*C+8;let I;try{I=new Uint8Array(L)}catch(t){return void this.observer.emit(l.ERROR,l.ERROR,{type:a.MUX_ERROR,details:o.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:L,reason:`fail allocating video mdat ${L}`})}const P=new DataView(I.buffer);P.setUint32(0,L),I.set(_r.types.mdat,4);let x=!1,R=Number.POSITIVE_INFINITY,D=Number.POSITIVE_INFINITY,O=Number.NEGATIVE_INFINITY,M=Number.NEGATIVE_INFINITY;for(let t=0;t<c;t++){const e=n[t],s=e.units;let a,o=0;for(let t=0,e=s.length;t<e;t++){const e=s[t],i=e.data,r=e.data.byteLength;P.setUint32(m,r),m+=4,I.set(i,m),m+=r,o+=4+r}if(t<c-1)y=n[t+1].dts-e.dts,a=n[t+1].pts-e.pts;else{const s=this.config,o=t>0?e.dts-n[t-1].dts:S;if(a=t>0?e.pts-n[t-1].pts:S,s.stretchShortVideoTrack&&null!==this.nextAudioTs){const t=Math.floor(s.maxBufferHole*r),n=(i?v+i*r:this.nextAudioTs+u)-e.pts;n>t?(y=n-o,y<0?y=o:x=!0,this.log(`It is approximately ${n/90} ms to the next segment; using duration ${y/90} ms for the last video frame.`)):y=o}else y=o}const l=Math.round(e.pts-e.dts);R=Math.min(R,y),O=Math.max(O,y),D=Math.min(D,a),M=Math.max(M,a),h.push(wr(e.key,y,o,l))}if(h.length)if(Cr){if(Cr<70){const t=h[0].flags;t.dependsOn=2,t.isNonSync=0}}else if(kr&&M-D<O-R&&S/O<.025&&0===h[0].cts){this.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let t=p;for(let e=0,s=h.length;e<s;e++){const i=t+h[e].duration,r=t+h[e].cts;if(e<s-1){const t=i+h[e+1].cts;h[e].duration=t-r}else h[e].duration=e?h[e-1].duration:S;h[e].cts=0,t=i}}y=x||!y?S:y;const F=f+y;this.nextVideoTs=g=F-u,this.videoSampleDuration=y,this.isVideoContiguous=!0;const N={data1:_r.moof(t.sequenceNumber++,p,b(t,{samples:h})),data2:I,startPTS:(v-u)/r,endPTS:(_+y-u)/r,startDTS:(p-u)/r,endDTS:g/r,type:"video",hasAudio:!1,hasVideo:!0,nb:h.length,dropped:t.dropped};return t.samples=[],t.dropped=0,N}getSamplesPerFrame(t){switch(t.segmentCodec){case"mp3":return 1152;case"ac3":return 1536;default:return 1024}}remuxAudio(t,e,s,i,r){const n=t.inputTimeScale,h=n/(t.samplerate?t.samplerate:n),c=this.getSamplesPerFrame(t),d=c*h,u=this._initPTS,p="mp3"===t.segmentCodec&&this.typeSupported.mpeg,f=[],g=void 0!==r;let m=t.samples,y=p?0:8,v=this.nextAudioTs||-1;const _=u.baseTime*n/u.timescale,T=_+e*n;if(this.isAudioContiguous=s=s||m.length&&v>0&&(i&&Math.abs(T-(v+_))<9e3||Math.abs(Ir(m[0].pts,T)-(v+_))<20*d),m.forEach(function(t){t.pts=Ir(t.pts,T)}),!s||v<0){const t=m.length;if(m=m.filter(t=>t.pts>=0),t!==m.length&&this.warn(`Removed ${m.length-t} of ${t} samples (initPTS ${_} / ${n})`),!m.length)return;v=0===r?0:i&&!g?Math.max(0,T-_):m[0].pts-_}if("aac"===t.segmentCodec){const e=this.config.maxAudioFramesDrift;for(let s=0,i=v+_;s<m.length;s++){const r=m[s],a=r.pts,o=a-i,l=Math.abs(1e3*o/n);if(o<=-e*d&&g)0===s&&(this.warn(`Audio frame @ ${(a/n).toFixed(3)}s overlaps marker by ${Math.round(1e3*o/n)} ms.`),this.nextAudioTs=v=a-_,i=a);else if(o>=e*d&&l<1e4&&g){let e=Math.round(o/d);for(i=a-e*d;i<0&&e&&d;)e--,i+=d;0===s&&(this.nextAudioTs=v=i-_),this.warn(`Injecting ${e} audio frames @ ${((i-_)/n).toFixed(3)}s due to ${Math.round(1e3*o/n)} ms gap.`);for(let n=0;n<e;n++){let e=vr.getSilentFrame(t.parsedCodec||t.manifestCodec||t.codec,t.channelCount);e||(this.log("Unable to get silent frame for given audio codec; duplicating last frame instead."),e=r.unit.subarray()),m.splice(s,0,{unit:e,pts:i}),i+=d,s++}}r.pts=i,i+=d}}let A,E=null,S=null,C=0,k=m.length;for(;k--;)C+=m[k].unit.byteLength;for(let e=0,i=m.length;e<i;e++){const i=m[e],r=i.unit;let n=i.pts;if(null!==S)f[e-1].duration=Math.round((n-S)/h);else{if(s&&"aac"===t.segmentCodec&&(n=v+_),E=n,!(C>0))return;C+=y;try{A=new Uint8Array(C)}catch(t){return void this.observer.emit(l.ERROR,l.ERROR,{type:a.MUX_ERROR,details:o.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:C,reason:`fail allocating audio mdat ${C}`})}p||(new DataView(A.buffer).setUint32(0,C),A.set(_r.types.mdat,4))}A.set(r,y);const d=r.byteLength;y+=d,f.push(wr(!0,c,d,0)),S=n}const w=f.length;if(!w)return;const L=f[f.length-1];v=S-_,this.nextAudioTs=v+h*L.duration;const I=p?new Uint8Array(0):_r.moof(t.sequenceNumber++,E/h,b({},t,{samples:f}));t.samples=[];const P=(E-_)/n,x=this.nextAudioTs/n,R={data1:I,data2:A,startPTS:P,endPTS:x,startDTS:P,endDTS:x,type:"audio",hasAudio:!0,hasVideo:!1,nb:w};return this.isAudioContiguous=!0,R}}function Ir(t,e){let s;if(null===e)return t;for(s=e<t?-8589934592:8589934592;Math.abs(t-e)>4294967296;)t+=s;return t}function Pr(t,e,s,i){const r=t.samples.length;if(!r)return;const n=t.inputTimeScale;for(let a=0;a<r;a++){const r=t.samples[a];r.pts=Ir(r.pts-s.baseTime*n/s.timescale,e*n)/n,r.dts=Ir(r.dts-i.baseTime*n/i.timescale,e*n)/n}const a=t.samples;return t.samples=[],{samples:a}}function xr(t,e,s){const i=t.samples.length;if(!i)return;const r=t.inputTimeScale;for(let n=0;n<i;n++){const i=t.samples[n];i.pts=Ir(i.pts-s.baseTime*r/s.timescale,e*r)/r}t.samples.sort((t,e)=>t.pts-e.pts);const n=t.samples;return t.samples=[],{samples:n}}function Rr(t,e,s=!1){return void 0!==(null==t?void 0:t.start)?(t.start+(s?t.duration:0))/t.timescale:e}function Dr(t,e,s){const i=t.codec;return i&&i.length>4?i:e===j?"ec-3"===i||"ac-3"===i||"alac"===i?i:"fLaC"===i||"Opus"===i?Lt(i,!1):(s.warn(`Unhandled audio codec "${i}" in mp4 MAP`),i||"mp4a"):(s.warn(`Unhandled video codec "${i}" in mp4 MAP`),i||"avc1")}try{Sr=self.performance.now.bind(self.performance)}catch(t){Sr=Date.now}const Or=[{demux:class{constructor(t,e){this.remainderData=null,this.timeOffset=0,this.config=void 0,this.videoTrack=void 0,this.audioTrack=void 0,this.id3Track=void 0,this.txtTrack=void 0,this.config=e}resetTimeStamp(){}resetInitSegment(t,e,s,i){const r=this.videoTrack=Hi("video",1),n=this.audioTrack=Hi("audio",1),a=this.txtTrack=Hi("text",1);if(this.id3Track=Hi("id3",1),this.timeOffset=0,null==t||!t.byteLength)return;const o=it(t);if(o.video){const{id:t,timescale:e,codec:s,supplemental:i}=o.video;r.id=t,r.timescale=a.timescale=e,r.codec=s,r.supplemental=i}if(o.audio){const{id:t,timescale:e,codec:s}=o.audio;n.id=t,n.timescale=e,n.codec=s}a.id=Y.text,r.sampleDuration=0,r.duration=n.duration=i}resetContiguity(){this.remainderData=null}static probe(t){return function(t){const e=t.byteLength;for(let s=0;s<e;){const i=Z(t,s);if(i>8&&109===t[s+4]&&111===t[s+5]&&111===t[s+6]&&102===t[s+7])return!0;s=i>1?s+i:e}return!1}(t)}demux(t,e){this.timeOffset=e;let s=t;const i=this.videoTrack,r=this.txtTrack;if(this.config.progressive){this.remainderData&&(s=dt(this.remainderData,t));const e=function(t){const e={valid:null,remainder:null},s=et(t,["moof"]);if(s.length<2)return e.remainder=t,e;const i=s[s.length-1];return e.valid=t.slice(0,i.byteOffset-8),e.remainder=t.slice(i.byteOffset-8),e}(s);this.remainderData=e.remainder,i.samples=e.valid||new Uint8Array}else i.samples=s;const n=this.extractID3Track(i,e);return r.samples=ut(e,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:n,textTrack:this.txtTrack}}flush(){const t=this.timeOffset,e=this.videoTrack,s=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;const i=this.extractID3Track(e,this.timeOffset);return s.samples=ut(t,e),{videoTrack:e,audioTrack:Hi(),id3Track:i,textTrack:Hi()}}extractID3Track(t,e){const s=this.id3Track;if(t.samples.length){const i=et(t.samples,["emsg"]);i&&i.forEach(t=>{const i=function(t){const e=t[0];let s="",i="",n=0,a=0,o=0,l=0,h=0,c=0;if(0===e){for(;"\0"!==X(t.subarray(c,c+1));)s+=X(t.subarray(c,c+1)),c+=1;for(s+=X(t.subarray(c,c+1)),c+=1;"\0"!==X(t.subarray(c,c+1));)i+=X(t.subarray(c,c+1)),c+=1;i+=X(t.subarray(c,c+1)),c+=1,n=Z(t,12),a=Z(t,16),l=Z(t,20),h=Z(t,24),c=28}else if(1===e){c+=4,n=Z(t,c),c+=4;const e=Z(t,c);c+=4;const a=Z(t,c);for(c+=4,o=2**32*e+a,r(o)||(o=Number.MAX_SAFE_INTEGER,L.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),l=Z(t,c),c+=4,h=Z(t,c),c+=4;"\0"!==X(t.subarray(c,c+1));)s+=X(t.subarray(c,c+1)),c+=1;for(s+=X(t.subarray(c,c+1)),c+=1;"\0"!==X(t.subarray(c,c+1));)i+=X(t.subarray(c,c+1)),c+=1;i+=X(t.subarray(c,c+1)),c+=1}return{schemeIdUri:s,value:i,timeScale:n,presentationTime:o,presentationTimeDelta:a,eventDuration:l,id:h,payload:t.subarray(c,t.byteLength)}}(t);if(ir.test(i.schemeIdUri)){const t=rr(i,e);let r=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;r<=.001&&(r=Number.POSITIVE_INFINITY);const n=i.payload;s.samples.push({data:n,len:n.byteLength,dts:t,pts:t,type:Ui.emsg,duration:r})}else if(this.config.enableEmsgKLVMetadata&&i.schemeIdUri.startsWith("urn:misb:KLV:bin:1910.1")){const t=rr(i,e);s.samples.push({data:i.payload,len:i.payload.byteLength,dts:t,pts:t,type:Ui.misbklv,duration:Number.POSITIVE_INFINITY})}})}return s}demuxSampleAes(t,e,s){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){this.config=null,this.remainderData=null,this.videoTrack=this.audioTrack=this.id3Track=this.txtTrack=void 0}},remux:class extends A{constructor(t,e,s,i){super("passthrough-remuxer",i),this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=null,this.initTracks=void 0,this.lastEndTime=null,this.isVideoContiguous=!1}destroy(){}resetTimeStamp(t){this.lastEndTime=null;const e=this.initPTS;e&&t&&e.baseTime===t.baseTime&&e.timescale===t.timescale||(this.initPTS=t)}resetNextTimestamp(){this.isVideoContiguous=!1,this.lastEndTime=null}resetInitSegment(t,e,s,i){this.audioCodec=e,this.videoCodec=s,this.generateInitSegment(t,i),this.emitInitSegment=!0}generateInitSegment(t,e){let{audioCodec:s,videoCodec:i}=this;if(null==t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);const{audio:r,video:n}=this.initData=it(t);if(e)!function(t,e){if(!t||!e)return;const s=e.keyId;s&&e.isCommonEncryption&&ht(t,(t,e)=>{const i=t.subarray(8,24);i.some(t=>0!==t)||(L.log(`[eme] Patching keyId in 'enc${e?"a":"v"}>sinf>>tenc' box: ${R(i)} -> ${R(s)}`),t.set(s,8))})}(t,e);else{const t=r||n;null!=t&&t.encrypted&&this.warn(`Init segment with encrypted track with has no key ("${t.codec}")!`)}r&&(s=Dr(r,j,this)),n&&(i=Dr(n,$,this));const a={};r&&n?a.audiovideo={container:"video/mp4",codec:s+","+i,supplemental:n.supplemental,encrypted:n.encrypted,initSegment:t,id:"main"}:r?a.audio={container:"audio/mp4",codec:s,encrypted:r.encrypted,initSegment:t,id:"audio"}:n?a.video={container:"video/mp4",codec:i,supplemental:n.supplemental,encrypted:n.encrypted,initSegment:t,id:"main"}:this.warn("initSegment does not contain moov or trak boxes."),this.initTracks=a}remux(t,e,s,r,n,a){var o,l;let{initPTS:h,lastEndTime:c}=this;const d={audio:void 0,video:void 0,text:r,id3:s,initSegment:void 0};i(c)||(c=this.lastEndTime=n||0);const u=e.samples;if(!u.length)return d;const p={initPTS:void 0,timescale:void 0,trackId:void 0};let f=this.initData;if(null!=(o=f)&&o.length||(this.generateInitSegment(u),f=this.initData),null==(l=f)||!l.length)return this.warn("Failed to generate initSegment."),d;this.emitInitSegment&&(p.tracks=this.initTracks,this.emitInitSegment=!1);const g=function(t,e,s){const r={},n=et(t,["moof","traf"]);for(let t=0;t<n.length;t++){const a=n[t],o=et(a,["tfhd"])[0],l=Z(o,4),h=e[l];if(!h)continue;r[l]||(r[l]={start:NaN,duration:0,sampleCount:0,timescale:h.timescale,type:h.type});const c=r[l],d=et(a,["tfdt"])[0];if(d){const t=d[0];let e=Z(d,4);1===t&&(e===z?s.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"):(e*=z+1,e+=Z(d,8))),i(e)&&(!i(c.start)||e<c.start)&&(c.start=e)}const u=h.default,p=Z(o,0)|(null==u?void 0:u.flags);let f=(null==u?void 0:u.duration)||0;8&p&&(f=Z(o,2&p?12:8));const g=et(a,["trun"]);let m=c.start||0,y=0,v=f;for(let t=0;t<g.length;t++){const e=g[t],s=Z(e,4),i=c.sampleCount;c.sampleCount+=s;const r=1&e[3],n=4&e[3],a=1&e[2],o=2&e[2],l=4&e[2],h=8&e[2];let d=8,u=s;for(r&&(d+=4),n&&s&&(1&e[d+1]||void 0!==c.keyFrameIndex||(c.keyFrameIndex=i),d+=4,a?(v=Z(e,d),d+=4):v=f,o&&(d+=4),h&&(d+=4),m+=v,y+=v,u--);u--;)a?(v=Z(e,d),d+=4):v=f,o&&(d+=4),l&&(1&e[d+1]||void 0===c.keyFrameIndex&&(c.keyFrameIndex=c.sampleCount-(u+1),c.keyFrameStart=m),d+=4),h&&(d+=4),m+=v,y+=v;!y&&f&&(y+=f*s)}c.duration+=y}if(!Object.keys(r).some(t=>r[t].duration)){let e=1/0,s=0;const n=et(t,["sidx"]);for(let t=0;t<n.length;t++){const i=st(n[t]);if(null!=i&&i.references){e=Math.min(e,i.earliestPresentationTime/i.timescale);const t=i.references.reduce((t,e)=>t+e.info.duration||0,0);s=Math.max(s,t+i.earliestPresentationTime/i.timescale)}}s&&i(s)&&Object.keys(r).forEach(t=>{r[t].duration||(r[t].duration=s*r[t].timescale-r[t].start)})}return r}(u,f,this),m=f.audio?g[f.audio.id]:null,y=f.video?g[f.video.id]:null,v=Rr(y,1/0),b=Rr(m,1/0),_=Rr(y,0,!0),T=Rr(m,0,!0);let A=n,E=0;const S=m&&(!y||!h&&b<v||h&&h.trackId===f.audio.id),C=S?m:y;if(C){const t=C.timescale,e=C.start-n*t,s=S?f.audio.id:f.video.id;A=C.start/t,E=S?T-b:_-v,!a&&h||!function(t,e,s,i){if(null===t)return!0;const r=Math.max(i,1),n=e-t.baseTime/t.timescale;return Math.abs(n-s)>r}(h,A,n,E)&&t===h.timescale||(h&&this.warn(`Timestamps at playlist time: ${a?"":"~"}${n} ${e/t} != initPTS: ${h.baseTime/h.timescale} (${h.baseTime}/${h.timescale}) trackId: ${h.trackId}`),this.log(`Found initPTS at playlist time: ${n} offset: ${A-n} (${e}/${t}) trackId: ${s}`),h=null,p.initPTS=e,p.timescale=t,p.trackId=s)}else this.warn(`No audio or video samples found for initPTS at playlist time: ${n}`);h?(p.initPTS=h.baseTime,p.timescale=h.timescale,p.trackId=h.trackId):(p.timescale&&void 0!==p.trackId&&void 0!==p.initPTS||(this.warn("Could not set initPTS"),p.initPTS=A,p.timescale=1,p.trackId=-1),this.initPTS=h={baseTime:p.initPTS,timescale:p.timescale,trackId:p.trackId});const k=A-h.baseTime/h.timescale,w=k+E;E>0?this.lastEndTime=w:(this.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const L=!!f.audio,I=!!f.video;let P="";L&&(P+="audio"),I&&(P+="video");const x={data1:u,startPTS:k,startDTS:k,endPTS:w,endDTS:w,type:P,hasAudio:L,hasVideo:I,nb:1,dropped:0,encrypted:!!f.audio&&f.audio.encrypted||!!f.video&&f.video.encrypted};d.audio=L&&!I?x:void 0,d.video=I?x:void 0;const R=null==y?void 0:y.sampleCount;if(R){const t=y.keyFrameIndex,e=-1!==t;x.nb=R,x.dropped=0===t||this.isVideoContiguous?0:e?t:R,x.independent=e,x.firstKeyFrame=t,e&&y.keyFrameStart&&(x.firstKeyFramePTS=(y.keyFrameStart-h.baseTime)/h.timescale),this.isVideoContiguous||(d.independent=e),this.isVideoContiguous||(this.isVideoContiguous=e),x.dropped&&this.warn(`fmp4 does not start with IDR: firstIDR ${t}/${R} dropped: ${x.dropped} start: ${x.firstKeyFramePTS||"NA"}`)}return d.initSegment=p,d.id3=Pr(s,n,h,h),r.samples.length&&(d.text=xr(r,n,h)),d}}},{demux:dr,remux:Lr},{demux:class extends Vi{constructor(t,e){super(),this.observer=void 0,this.config=void 0,this.observer=t,this.config=e}resetInitSegment(t,e,s,i){super.resetInitSegment(t,e,s,i),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}}static probe(t,e){if(!t)return!1;const s=Si(t,0);let i=(null==s?void 0:s.length)||0;if(tr(t,i))return!1;for(let s=t.length;i<s;i++)if(Ii(t,i))return e.log("ADTS sync word found !"),!0;return!1}canParse(t,e){return function(t,e){return function(t,e){return e+5<t.length}(t,e)&&Ci(t,e)&&wi(t,e)<=t.length-e}(t,e)}appendFrame(t,e,s){Pi(t,this.observer,e,s,t.manifestCodec);const i=Ri(t,e,s,this.basePTS,this.frameIndex);if(i&&0===i.missing)return i}},remux:Lr},{demux:class extends Vi{resetInitSegment(t,e,s,i){super.resetInitSegment(t,e,s,i),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}}static probe(t){if(!t)return!1;const e=Si(t,0);let s=(null==e?void 0:e.length)||0;if(e&&11===t[s]&&119===t[s+1]&&void 0!==$i(e)&&er(t,s)<=16)return!1;for(let e=t.length;s<e;s++)if(tr(t,s))return L.log("MPEG Audio sync word found !"),!0;return!1}canParse(t,e){return function(t,e){return Zi(t,e)&&4<=t.length-e}(t,e)}appendFrame(t,e,s){if(null!==this.basePTS)return Xi(t,e,s,this.basePTS,this.frameIndex)}},remux:Lr}];Or.splice(2,0,{demux:class extends Vi{constructor(t){super(),this.observer=void 0,this.observer=t}resetInitSegment(t,e,s,i){super.resetInitSegment(t,e,s,i),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:e,duration:i,inputTimeScale:9e4,dropped:0}}canParse(t,e){return e+64<t.length}appendFrame(t,e,s){const i=sr(t,e,s,this.basePTS,this.frameIndex);if(-1!==i)return{sample:t.samples[t.samples.length-1],length:i,missing:0}}static probe(t){if(!t)return!1;const e=Si(t,0);if(!e)return!1;const s=e.length;return 11===t[s]&&119===t[s+1]&&void 0!==$i(e)&&er(t,s)<16}},remux:Lr});class Mr{constructor(t,e,s,i,r,n){this.asyncResult=!1,this.logger=void 0,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=e,this.config=s,this.id=r,this.logger=n}configure(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()}push(t,e,s,i){const r=s.transmuxing;r.executeStart=Sr();let n=new Uint8Array(t);const{currentTransmuxState:h,transmuxConfig:c}=this;i&&(this.currentTransmuxState=i);const{contiguous:d,discontinuity:u,trackSwitch:p,accurateTimeOffset:f,timeOffset:g,initSegmentChange:m}=i||h,{audioCodec:y,videoCodec:v,defaultInitPts:b,duration:_,initSegmentData:T}=c,A=function(t,e){let s=null;return t.byteLength>0&&null!=(null==e?void 0:e.key)&&null!==e.iv&&null!=e.method&&(s=e),s}(n,e);if(A&&Qe(A.method)){const t=this.getDecrypter(),e=Ze(A.method);if(!t.isSync())return this.asyncResult=!0,this.decryptionPromise=t.webCryptoDecrypt(n,A.key.buffer,A.iv.buffer,e).then(t=>{const e=this.push(t,null,s);return this.decryptionPromise=null,e}),this.decryptionPromise;{let i=t.softwareDecrypt(n,A.key.buffer,A.iv.buffer,e);if(s.part>-1){const e=t.flush();i=e?e.buffer:e}if(!i)return r.executeEnd=Sr(),Fr(s);n=new Uint8Array(i)}}const E=this.needsProbing(u,p);if(E){const t=this.configureTransmuxer(n);if(t)return this.logger.warn(`[transmuxer] ${t.message}`),this.observer.emit(l.ERROR,l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_PARSING_ERROR,fatal:!1,error:t,reason:t.message}),r.executeEnd=Sr(),Fr(s)}(u||p||m||E)&&this.resetInitSegment(T,y,v,_,e),(u||m||E)&&this.resetInitialTimestamp(b),d||this.resetContiguity();const S=this.transmux(n,A,g,f,s);this.asyncResult=Nr(S);const C=this.currentTransmuxState;return C.contiguous=!0,C.discontinuity=!1,C.trackSwitch=!1,r.executeEnd=Sr(),S}flush(t){const e=t.transmuxing;e.executeStart=Sr();const{decrypter:s,currentTransmuxState:i,decryptionPromise:r}=this;if(r)return this.asyncResult=!0,r.then(()=>this.flush(t));const n=[],{timeOffset:a}=i;if(s){const e=s.flush();e&&n.push(this.push(e.buffer,null,t))}const{demuxer:o,remuxer:l}=this;if(!o||!l){e.executeEnd=Sr();const s=[Fr(t)];return this.asyncResult?Promise.resolve(s):s}const h=o.flush(a);return Nr(h)?(this.asyncResult=!0,h.then(e=>(this.flushRemux(n,e,t),n))):(this.flushRemux(n,h,t),this.asyncResult?Promise.resolve(n):n)}flushRemux(t,e,s){const{audioTrack:i,videoTrack:r,id3Track:n,textTrack:a}=e,{accurateTimeOffset:o,timeOffset:l}=this.currentTransmuxState;this.logger.log(`[transmuxer.ts]: Flushed ${this.id} sn: ${s.sn}${s.part>-1?" part: "+s.part:""} of ${this.id===p?"level":"track"} ${s.level}`);const h=this.remuxer.remux(i,r,n,a,l,o,!0,this.id);t.push({remuxResult:h,chunkMeta:s}),s.transmuxing.executeEnd=Sr()}resetInitialTimestamp(t){const{demuxer:e,remuxer:s}=this;e&&s&&(e.resetTimeStamp(t),s.resetTimeStamp(t))}resetContiguity(){const{demuxer:t,remuxer:e}=this;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())}resetInitSegment(t,e,s,i,r){const{demuxer:n,remuxer:a}=this;n&&a&&(n.resetInitSegment(t,e,s,i),a.resetInitSegment(t,e,s,r))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(t,e,s,i,r){let n;return n=e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,s,i,r):this.transmuxUnencrypted(t,s,i,r),n}transmuxUnencrypted(t,e,s,i){const{audioTrack:r,videoTrack:n,id3Track:a,textTrack:o}=this.demuxer.demux(t,e,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(r,n,a,o,e,s,!1,this.id),chunkMeta:i}}transmuxSampleAes(t,e,s,i,r){return this.demuxer.demuxSampleAes(t,e,s).then(t=>({remuxResult:this.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,s,i,!1,this.id),chunkMeta:r}))}configureTransmuxer(t){const{config:e,observer:s,typeSupported:i}=this;let r;for(let e=0,s=Or.length;e<s;e++){var n;if(null!=(n=Or[e].demux)&&n.probe(t,this.logger)){r=Or[e];break}}if(!r)return new Error("Failed to find demuxer by probing fragment data");const a=this.demuxer,o=this.remuxer,l=r.remux,h=r.demux;o&&o instanceof l||(this.remuxer=new l(s,e,i,this.logger)),a&&a instanceof h||(this.demuxer=new h(s,e,i,this.logger),this.probe=h.probe)}needsProbing(t,e){return!this.demuxer||!this.remuxer||t||e}getDecrypter(){let t=this.decrypter;return t||(t=this.decrypter=new we(this.config)),t}}const Fr=t=>({remuxResult:{},chunkMeta:t});function Nr(t){return"then"in t&&t.then instanceof Function}class Br{constructor(t,e,s,i,r){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=e,this.initSegmentData=s,this.duration=i,this.defaultInitPts=r||null}}class jr{constructor(t,e,s,i,r,n){this.discontinuity=void 0,this.contiguous=void 0,this.accurateTimeOffset=void 0,this.trackSwitch=void 0,this.timeOffset=void 0,this.initSegmentChange=void 0,this.discontinuity=t,this.contiguous=e,this.accurateTimeOffset=s,this.trackSwitch=i,this.timeOffset=r,this.initSegmentChange=n}}let $r=0;class Ur{constructor(t,e,s,i){this.error=null,this.hls=void 0,this.id=void 0,this.instanceNo=$r++,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.onWorkerMessage=t=>{const e=t.data,s=this.hls;if(s&&null!=e&&e.event&&e.instanceNo===this.instanceNo)switch(e.event){case"init":{var i;const t=null==(i=this.workerContext)?void 0:i.objectURL;t&&self.URL.revokeObjectURL(t);break}case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;case"workerLog":s.logger[e.data.logType]&&s.logger[e.data.logType](e.data.message);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.part=this.part,e.data.id=this.id,s.trigger(e.event,e.data)}},this.onWorkerError=t=>{if(!this.hls)return;const e=new Error(`${t.message} (${t.filename}:${t.lineno})`);this.hls.config.enableWorker=!1,this.hls.logger.warn(`Error in "${this.id}" Web Worker, fallback to inline`),this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:e})};const r=t.config;this.hls=t,this.id=e,this.useWorker=!!r.enableWorker,this.onTransmuxComplete=s,this.onFlush=i;const n=(t,e)=>{(e=e||{}).frag=this.frag||void 0,t===l.ERROR&&(e.parent=this.id,e.part=this.part,this.error=e.error),this.hls.trigger(t,e)};this.observer=new vi,this.observer.on(l.FRAG_DECRYPTED,n),this.observer.on(l.ERROR,n);const h=Rt(r.preferManagedMediaSource);if(this.useWorker&&"undefined"!=typeof Worker){const s=this.hls.logger;if(r.workerPath||"function"==typeof __HLS_WORKER_BUNDLE__){try{r.workerPath?(s.log(`loading Web Worker ${r.workerPath} for "${e}"`),this.workerContext=function(t){const e=_i[t];if(e)return e.clientCount++,e;const s=new self.URL(t,self.location.href).href,i={worker:new self.Worker(s),scriptURL:s,clientCount:1};return _i[t]=i,i}(r.workerPath)):(s.log(`injecting Web Worker for "${e}"`),this.workerContext=function(){const t=_i[bi];if(t)return t.clientCount++,t;const e=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),s=self.URL.createObjectURL(e),i={worker:new self.Worker(s),objectURL:s,clientCount:1};return _i[bi]=i,i}());const{worker:t}=this.workerContext;t.addEventListener("message",this.onWorkerMessage),t.addEventListener("error",this.onWorkerError),t.postMessage({instanceNo:this.instanceNo,cmd:"init",typeSupported:h,id:e,config:zt(r)})}catch(i){s.warn(`Error setting up "${e}" Web Worker, fallback to inline`,i),this.terminateWorker(),this.error=null,this.transmuxer=new Mr(this.observer,h,r,"",e,t.logger)}return}}this.transmuxer=new Mr(this.observer,h,r,"",e,t.logger)}reset(){if(this.frag=null,this.part=null,this.workerContext){const t=this.instanceNo;this.instanceNo=$r++;const e=this.hls.config,s=Rt(e.preferManagedMediaSource);this.workerContext.worker.postMessage({instanceNo:this.instanceNo,cmd:"reset",resetNo:t,typeSupported:s,id:this.id,config:zt(e)})}}terminateWorker(){if(this.workerContext){const{worker:t}=this.workerContext;this.workerContext=null,t.removeEventListener("message",this.onWorkerMessage),t.removeEventListener("error",this.onWorkerError),function(t){const e=_i[t||bi];if(e&&1===e.clientCount--){const{worker:s,objectURL:i}=e;delete _i[t||bi],i&&self.URL.revokeObjectURL(i),s.terminate()}}(this.hls.config.workerPath)}}destroy(){if(this.workerContext)this.terminateWorker(),this.onWorkerMessage=this.onWorkerError=null;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const t=this.observer;t&&t.removeAllListeners(),this.frag=null,this.part=null,this.observer=null,this.hls=null}push(t,e,s,i,r,n,a,o,l,h){var c,d;l.transmuxing.start=self.performance.now();const{instanceNo:u,transmuxer:f}=this,g=n?n.start:r.start,m=r.decryptdata,y=this.frag,v=!(y&&r.cc===y.cc),b=!(y&&l.level===y.level),_=y?l.sn-y.sn:-1,T=this.part?l.part-this.part.index:-1,A=0===_&&l.id>1&&l.id===(null==y?void 0:y.stats.chunkCount),E=!b&&(1===_||0===_&&(1===T||A&&T<=0)),S=self.performance.now();(b||_||0===r.stats.parsing.start)&&(r.stats.parsing.start=S),!n||!T&&E||(n.stats.parsing.start=S);const C=!(y&&(null==(c=r.initSegment)?void 0:c.url)===(null==(d=y.initSegment)?void 0:d.url)),k=new jr(v,E,o,b,g,C);if(!E||v||C){this.hls.logger.log(`[transmuxer-interface]: Starting new transmux session for ${r.type} sn: ${l.sn}${l.part>-1?" part: "+l.part:""} ${this.id===p?"level":"track"}: ${l.level} id: ${l.id}\n discontinuity: ${v}\n trackSwitch: ${b}\n contiguous: ${E}\n accurateTimeOffset: ${o}\n timeOffset: ${g}\n initSegmentChange: ${C}`);const t=new Br(s,i,e,a,h);this.configureTransmuxer(t)}if(this.frag=r,this.part=n,this.workerContext)this.workerContext.worker.postMessage({instanceNo:u,cmd:"demux",data:t,decryptdata:m,chunkMeta:l,state:k},t instanceof ArrayBuffer?[t]:[]);else if(f){const e=f.push(t,m,l,k);Nr(e)?e.then(t=>{this.handleTransmuxComplete(t)}).catch(t=>{this.transmuxerError(t,l,"transmuxer-interface push error")}):this.handleTransmuxComplete(e)}}flush(t){t.transmuxing.start=self.performance.now();const{instanceNo:e,transmuxer:s}=this;if(this.workerContext)this.workerContext.worker.postMessage({instanceNo:e,cmd:"flush",chunkMeta:t});else if(s){const e=s.flush(t);Nr(e)?e.then(e=>{this.handleFlushResult(e,t)}).catch(e=>{this.transmuxerError(e,t,"transmuxer-interface flush error")}):this.handleFlushResult(e,t)}}transmuxerError(t,e,s){this.hls&&(this.error=t,this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_PARSING_ERROR,chunkMeta:e,frag:this.frag||void 0,part:this.part||void 0,fatal:!1,error:t,err:t,reason:s}))}handleFlushResult(t,e){t.forEach(t=>{this.handleTransmuxComplete(t)}),this.onFlush(e)}configureTransmuxer(t){const{instanceNo:e,transmuxer:s}=this;this.workerContext?this.workerContext.worker.postMessage({instanceNo:e,cmd:"configure",config:t}):s&&s.configure(t)}handleTransmuxComplete(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)}}class Hr extends A{constructor(t,e){super(e,t.logger),this.hls=void 0,this.canLoad=!1,this.timer=-1,this.hls=t}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(t,e,s){const i=null==e?void 0:e.renditionReports;if(i){let r=-1;for(let s=0;s<i.length;s++){const n=i[s];let a;try{a=new self.URL(n.URI,e.url).href}catch(t){this.warn(`Could not construct new URL for Rendition Report: ${t}`),a=n.URI||""}if(a===t){r=s;break}a===t.substring(0,a.length)&&(r=s)}if(-1!==r){const t=i[r],n=parseInt(t["LAST-MSN"])||e.lastPartSn;let a=parseInt(t["LAST-PART"])||e.lastPartIndex;if(this.hls.config.lowLatencyMode){const t=Math.min(e.age-e.partTarget,e.targetduration);a>=0&&t>e.partTarget&&(a+=1)}const o=s&&Vt(s);return new Gt(n,a>=0?a:void 0,o)}}}loadPlaylist(t){this.clearTimer()}loadingPlaylist(t,e){this.clearTimer()}shouldLoadPlaylist(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)}getUrlWithDirectives(t,e){if(e)try{return e.addDirectives(t)}catch(t){this.warn(`Could not construct new URL with HLS Delivery Directives: ${t}`)}return t}playlistLoaded(t,e,s){const{details:r,stats:n}=e,h=self.performance.now(),c=n.loading.first?Math.max(0,h-n.loading.first):0;r.advancedDateTime=Date.now()-c;const d=this.hls.config.timelineOffset;if(d!==r.appliedTimelineOffset){const t=Math.max(d||0,0);r.appliedTimelineOffset=t,r.fragments.forEach(e=>{e.setStart(e.playlistOffset+t)})}if(r.live||null!=s&&s.live){const d="levelInfo"in e?e.levelInfo:e.track;if(r.reloaded(s),s&&r.fragments.length>0){!function(t,e,s){if(t===e)return;let r=null;const n=t.fragments;for(let t=n.length-1;t>=0;t--){const e=n[t].initSegment;if(e){r=e;break}}let a;t.fragmentHint&&delete t.fragmentHint.endPTS,function(t,e,s){const i=e.skippedSegments,r=Math.max(t.startSN,e.startSN)-e.startSN,n=(t.fragmentHint?1:0)+(i?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,a=e.startSN-t.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments;for(let h=r;h<=n;h++){const r=l[a+h];let n=o[h];if(i&&!n&&r&&(n=e.fragments[h]=r),r&&n){s(r,n,h,o);const i=r.relurl,a=n.relurl;if(i&&Ws(i,a))return void(e.playlistParsingError=Ns(`media sequence mismatch ${n.sn}:`,t,e,0,n));if(r.cc!==n.cc)return void(e.playlistParsingError=Ns(`discontinuity sequence mismatch (${r.cc}!=${n.cc})`,t,e,0,n))}}}(t,e,(t,s,n,o)=>{if((!e.startCC||e.skippedSegments)&&s.cc!==t.cc){const i=t.cc-s.cc;for(let t=n;t<o.length;t++)o[t].cc+=i;e.endCC=o[o.length-1].cc}i(t.startPTS)&&i(t.endPTS)&&(s.setStart(s.startPTS=t.startPTS),s.startDTS=t.startDTS,s.maxStartPTS=t.maxStartPTS,s.endPTS=t.endPTS,s.endDTS=t.endDTS,s.minEndPTS=t.minEndPTS,s.setDuration(t.endPTS-t.startPTS),s.duration&&(a=s),e.PTSKnown=e.alignedSliding=!0),t.hasStreams&&(s.elementaryStreams=t.elementaryStreams),s.loader=t.loader,t.hasStats&&(s.stats=t.stats),t.initSegment&&(s.initSegment=t.initSegment,r=t.initSegment)});const o=e.fragments,l=e.fragmentHint?o.concat(e.fragmentHint):o;if(r&&l.forEach(t=>{var e;!t||t.initSegment&&t.initSegment.relurl!==(null==(e=r)?void 0:e.relurl)||(t.initSegment=r)}),e.skippedSegments){if(e.deltaUpdateFailed=o.some(t=>!t),e.deltaUpdateFailed){s.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let t=e.skippedSegments;t--;)o.shift();e.startSN=o[0].sn}else{e.canSkipDateRanges&&(e.dateRanges=function(t,e,s){const{dateRanges:i,recentlyRemovedDateranges:r}=e,n=b({},t);r&&r.forEach(t=>{delete n[t]});const a=Object.keys(n).length;return a?(Object.keys(i).forEach(t=>{const e=n[t],r=new ze(i[t].attr,e);r.isValid?(n[t]=r,e||(r.tagOrder+=a)):s.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${zt(i[t].attr)}"`)}),n):i}(t.dateRanges,e,s));const i=t.fragments.filter(t=>t.rawProgramDateTime);if(t.hasProgramDateTime&&!e.hasProgramDateTime)for(let t=1;t<l.length;t++)null===l[t].programDateTime&&Ps(l[t],l[t-1],i);Ss(i,e)}e.endCC=o[o.length-1].cc}if(!e.startCC){var h;const s=Us(t,e.startSN-1);e.startCC=null!=(h=null==s?void 0:s.cc)?h:o[0].cc}!function(t,e,s){if(t&&e){let i=0;for(let r=0,n=t.length;r<=n;r++){const n=t[r],a=e[r+i];n&&a&&n.index===a.index&&n.fragment.sn===a.fragment.sn?s(n,a):i--}}}(t.partList,e.partList,(t,e)=>{e.elementaryStreams=t.elementaryStreams,e.stats=t.stats}),a?Fs(e,a,a.startPTS,a.endPTS,a.startDTS,a.endDTS,s):Bs(t,e),o.length&&(e.totalduration=e.edge-o[0].start),e.driftStartTime=t.driftStartTime,e.driftStart=t.driftStart;const c=e.advancedDateTime;if(e.advanced&&c){const t=e.edge;e.driftStart||(e.driftStartTime=c,e.driftStart=t),e.driftEndTime=c,e.driftEnd=t}else e.driftEndTime=t.driftEndTime,e.driftEnd=t.driftEnd,e.advancedDateTime=t.advancedDateTime;-1===e.requestScheduled&&(e.requestScheduled=t.requestScheduled)}(s,r,this);const t=r.playlistParsingError;if(t){this.warn(t);const s=this.hls;if(!s.config.ignorePlaylistParsingErrors){var u;const{networkDetails:i}=e;return void s.trigger(l.ERROR,{type:a.NETWORK_ERROR,details:o.LEVEL_PARSING_ERROR,fatal:!1,url:r.url,error:t,reason:t.message,level:e.level||void 0,parent:null==(u=r.fragments[0])?void 0:u.type,networkDetails:i,stats:n})}r.playlistParsingError=null}}-1===r.requestScheduled&&(r.requestScheduled=n.loading.start);const p=this.hls.mainForwardBufferInfo,f=p?p.end-p.len:0,g=$s(r,1e3*(r.edge-f));if(r.requestScheduled+g<h?r.requestScheduled=h:r.requestScheduled+=g,this.log(`live playlist ${t} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:r.updated?"UPDATED":"MISSED"}`),!this.canLoad||!r.live)return;let m,y,v;if(r.canBlockReload&&r.endSN&&r.advanced){const t=this.hls.config.lowLatencyMode,i=r.lastPartSn,n=r.endSN,a=r.lastPartIndex,o=i===n;-1!==a?o?(y=n+1,v=t?0:a):(y=i,v=t?a+1:r.maxPartIndex):y=n+1;const l=r.age,c=l+r.ageHeader;let u=Math.min(c-r.partTarget,1.5*r.targetduration);if(u>0){if(c>3*r.targetduration)this.log(`Playlist last advanced ${l.toFixed(2)}s ago. Omitting segment and part directives.`),y=void 0,v=void 0;else if(null!=s&&s.tuneInGoal&&c-r.partTarget>s.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${s.tuneInGoal} to: ${u} with playlist age: ${r.age}`),u=0;else{const t=Math.floor(u/r.targetduration);y+=t,void 0!==v&&(v+=Math.round(u%r.targetduration/r.partTarget)),this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${l.toFixed(2)}s goal: ${u} skip sn ${t} to part ${v}`)}r.tuneInGoal=u}if(m=this.getDeliveryDirectives(r,e.deliveryDirectives,y,v),t||!o)return r.requestScheduled=h,void this.loadingPlaylist(d,m)}else(r.canBlockReload||r.canSkipUntil)&&(m=this.getDeliveryDirectives(r,e.deliveryDirectives,y,v));m&&void 0!==y&&r.canBlockReload&&(r.requestScheduled=n.loading.first+Math.max(g-2*c,g/2)),this.scheduleLoading(d,m,r)}else this.clearTimer()}scheduleLoading(t,e,s){const i=s||t.details;if(!i)return void this.loadingPlaylist(t,e);const r=self.performance.now(),n=i.requestScheduled;if(r>=n)return void this.loadingPlaylist(t,e);const a=n-r;this.log(`reload live playlist ${t.name||t.bitrate+"bps"} in ${Math.round(a)} ms`),this.clearTimer(),this.timer=self.setTimeout(()=>this.loadingPlaylist(t,e),a)}getDeliveryDirectives(t,e,s,i){let r=Vt(t);return null!=e&&e.skip&&t.deltaUpdateFailed&&(s=e.msn,i=e.part,r=""),new Gt(s,i,r)}checkRetry(t){const e=t.details,s=oe(t),i=t.errorAction,{action:r,retryCount:n=0,retryConfig:a}=i||{},o=!!i&&!!a&&(5===r||!i.resolved&&2===r);if(o){var l;if(n>=a.maxNumRetry)return!1;if(s&&null!=(l=t.context)&&l.deliveryDirectives)this.warn(`Retrying playlist loading ${n+1}/${a.maxNumRetry} after "${e}" without delivery-directives`),this.loadPlaylist();else{const t=de(a,n);this.clearTimer(),this.timer=self.setTimeout(()=>this.loadPlaylist(),t),this.warn(`Retrying playlist loading ${n+1}/${a.maxNumRetry} after "${e}" in ${t}ms`)}t.levelRetry=!0,i.resolved=!0}return o}}function Vr(t,e){if(t.length!==e.length)return!1;for(let s=0;s<t.length;s++)if(!Gr(t[s].attrs,e[s].attrs))return!1;return!0}function Gr(t,e,s){const i=t["STABLE-RENDITION-ID"];return i&&!s?i===e["STABLE-RENDITION-ID"]:!(s||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(s=>t[s]!==e[s])}function Wr(t,e){return e.label.toLowerCase()===t.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(t.lang||"").toLowerCase())}class Kr{constructor(t){this.tracks=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.tracks=t}destroy(){this.tracks=this.queues=null}append(t,e,s){if(null===this.queues||null===this.tracks)return;const i=this.queues[e];i.push(t),1!==i.length||s||this.executeNext(e)}appendBlocker(t){return new Promise(e=>{const s={label:"async-blocker",execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.append(s,t)})}prependBlocker(t){return new Promise(e=>{if(this.queues){const s={label:"async-blocker-prepend",execute:e,onStart:()=>{},onComplete:()=>{},onError:()=>{}};this.queues[t].unshift(s)}})}removeBlockers(){null!==this.queues&&[this.queues.video,this.queues.audio,this.queues.audiovideo].forEach(t=>{var e;const s=null==(e=t[0])?void 0:e.label;"async-blocker"!==s&&"async-blocker-prepend"!==s||(t[0].execute(),t.splice(0,1))})}unblockAudio(t){null!==this.queues&&this.queues.audio[0]===t&&this.shiftAndExecuteNext("audio")}executeNext(t){if(null===this.queues||null===this.tracks)return;const e=this.queues[t];if(e.length){const i=e[0];try{i.execute()}catch(e){var s;if(i.onError(e),null===this.queues||null===this.tracks)return;const r=null==(s=this.tracks[t])?void 0:s.buffer;null!=r&&r.updating||this.shiftAndExecuteNext(t)}}}shiftAndExecuteNext(t){null!==this.queues&&(this.queues[t].shift(),this.executeNext(t))}current(t){var e;return(null==(e=this.queues)?void 0:e[t][0])||null}toString(){const{queues:t,tracks:e}=this;return null===t||null===e?"<destroyed>":`\n${this.list("video")}\n${this.list("audio")}\n${this.list("audiovideo")}}`}list(t){var e,s;return null!=(e=this.queues)&&e[t]||null!=(s=this.tracks)&&s[t]?`${t}: (${this.listSbInfo(t)}) ${this.listOps(t)}`:""}listSbInfo(t){var e;const s=null==(e=this.tracks)?void 0:e[t],i=null==s?void 0:s.buffer;return i?`SourceBuffer${i.updating?" updating":""}${s.ended?" ended":""}${s.ending?" ending":""}`:"none"}listOps(t){var e;return(null==(e=this.queues)?void 0:e[t].map(t=>t.label).join(", "))||""}}const zr=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,qr="HlsJsTrackRemovedError";class Yr extends Error{constructor(t){super(t),this.name=qr}}function Xr(t){const e=t.querySelectorAll("source");[].slice.call(e).forEach(e=>{t.removeChild(e)})}function Qr(t){return"audio"===t?1:0}class Zr{constructor(t){this.hls=void 0,this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.clientRect=void 0,this.streamController=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(t){this.streamController=t}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:t}=this;t.on(l.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(l.MANIFEST_PARSED,this.onManifestParsed,this),t.on(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(l.BUFFER_CODECS,this.onBufferCodecs,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:t}=this;t.off(l.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(l.MANIFEST_PARSED,this.onManifestParsed,this),t.off(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(l.BUFFER_CODECS,this.onBufferCodecs,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(t,e){const s=this.hls.levels[e.droppedLevel];this.isLevelAllowed(s)&&this.restrictedLevels.push({bitrate:s.bitrate,height:s.height,width:s.width})}onMediaAttaching(t,e){this.media=e.media instanceof HTMLVideoElement?e.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(t,e){const s=this.hls;this.restrictedLevels=[],this.firstLevel=e.firstLevel,s.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onLevelsUpdated(t,e){this.timer&&i(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(t,e){this.hls.config.capLevelToPlayerSize&&e.video&&this.startCapping()}onMediaDetaching(){this.stopCapping(),this.media=null}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0)return void(this.clientRect=null);const t=this.hls.levels;if(t.length){const e=this.hls,s=this.getMaxLevel(t.length-1);s!==this.autoLevelCapping&&e.logger.log(`Setting autoLevelCapping to ${s}: ${t[s].height}p@${t[s].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),e.autoLevelCapping=s,e.autoLevelEnabled&&e.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}}getMaxLevel(t){const e=this.hls.levels;if(!e.length)return-1;const s=e.filter((e,s)=>this.isLevelAllowed(e)&&s<=t);return this.clientRect=null,Zr.getMaxLevelByMediaSize(s,this.mediaWidth,this.mediaHeight)}startCapping(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())}stopCapping(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)}getDimensions(){if(this.clientRect)return this.clientRect;const t=this.media,e={width:0,height:0};if(t){const s=t.getBoundingClientRect();e.width=s.width,e.height=s.height,e.width||e.height||(e.width=s.right-s.left||t.width||0,e.height=s.bottom-s.top||t.height||0)}return this.clientRect=e,e}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch(t){}return Math.min(t,this.hls.config.maxDevicePixelRatio)}isLevelAllowed(t){return!this.restrictedLevels.some(e=>t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height)}static getMaxLevelByMediaSize(t,e,s){if(null==t||!t.length)return-1;const i=(t,e)=>!e||t.width!==e.width||t.height!==e.height;let r=t.length-1;const n=Math.max(e,s);for(let e=0;e<t.length;e+=1){const s=t[e];if((s.width>=n||s.height>=n)&&i(s,t[e+1])){r=e;break}}return r}}const Jr="m",tn="a",en="v",sn="av",rn="i",nn="tt",an="h";class on{constructor(t,e){Array.isArray(t)&&(t=t.map(t=>t instanceof on?t:new on(t))),this.value=t,this.params=e}}function ln(t,e,s){return function(t,e,s,i){return new Error(`failed to ${t} "${r=e,Array.isArray(r)?JSON.stringify(r):r instanceof Map?"Map{}":r instanceof Set?"Set{}":"object"==typeof r?JSON.stringify(r):String(r)}" as ${s}`,{cause:i});var r}("serialize",t,e,s)}class hn{constructor(t){this.description=t}}const cn="Bare Item";function dn(t){if(function(t){return t<-999999999999999||999999999999999<t}(t))throw ln(t,"Integer");return t.toString()}function un(t,e){if(t<0)return-un(-t,e);const s=Math.pow(10,e);if(Math.abs(t*s%1-.5)<Number.EPSILON){const e=Math.floor(t*s);return(e%2==0?e:e+1)/s}return Math.round(t*s)/s}function pn(t){const e=un(t,3);if(Math.floor(Math.abs(e)).toString().length>12)throw ln(t,"Decimal");const s=e.toString();return s.includes(".")?s:`${s}.0`}const fn=/[\x00-\x1f\x7f]+/;function gn(t){const e=(s=t).description||s.toString().slice(7,-1);var s;if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e))throw ln(e,"Token");return e}function mn(t){switch(typeof t){case"number":if(!i(t))throw ln(t,cn);return Number.isInteger(t)?dn(t):pn(t);case"string":return function(t){if(fn.test(t))throw ln(t,"String");return`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}(t);case"symbol":return gn(t);case"boolean":return function(t){if("boolean"!=typeof t)throw ln(t,"Boolean");return t?"?1":"?0"}(t);case"object":if(t instanceof Date)return function(t){return`@${dn(t.getTime()/1e3)}`}(t);if(t instanceof Uint8Array)return function(t){if(!1===ArrayBuffer.isView(t))throw ln(t,"Byte Sequence");return`:${e=t,btoa(String.fromCharCode(...e))}:`;var e}(t);if(t instanceof hn)return gn(t);default:throw ln(t,cn)}}function yn(t){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(t))throw ln(t,"Key");return t}function vn(t){return null==t?"":Object.entries(t).map(([t,e])=>!0===e?`;${yn(t)}`:`;${yn(t)}=${mn(e)}`).join("")}function bn(t){return t instanceof on?`${mn(t.value)}${vn(t.params)}`:mn(t)}function _n(t,e){return function(t,e={whitespace:!0}){if("object"!=typeof t||null==t)throw ln(t,"Dict");const s=t instanceof Map?t.entries():Object.entries(t),i=(null==e?void 0:e.whitespace)?" ":"";return Array.from(s).map(([t,e])=>{e instanceof on==0&&(e=new on(e));let s=yn(t);var i;return!0===e.value?s+=vn(e.params):(s+="=",Array.isArray(e.value)?s+=`(${(i=e).value.map(bn).join(" ")})${vn(i.params)}`:s+=bn(e)),s}).join(`,${i}`)}(t,e)}const Tn="CMCD-Object",An="CMCD-Request",En="CMCD-Session",Sn="CMCD-Status",Cn={br:Tn,ab:Tn,d:Tn,ot:Tn,tb:Tn,tpb:Tn,lb:Tn,tab:Tn,lab:Tn,url:Tn,pb:An,bl:An,tbl:An,dl:An,ltc:An,mtp:An,nor:An,nrr:An,rc:An,sn:An,sta:An,su:An,ttfb:An,ttfbb:An,ttlb:An,cmsdd:An,cmsds:An,smrt:An,df:An,cs:An,ts:An,cid:En,pr:En,sf:En,sid:En,st:En,v:En,msd:En,bs:Sn,bsd:Sn,cdn:Sn,rtp:Sn,bg:Sn,pt:Sn,ec:Sn,e:Sn},kn=An;const wn="event",Ln=t=>Math.round(t),In=(t,e)=>Array.isArray(t)?t.map(t=>In(t,e)):t instanceof on&&"string"==typeof t.value?new on(In(t.value,e),t.params):(e.baseUrl&&(t=function(t,e){const s=new URL(t),i=new URL(e);if(s.origin!==i.origin)return t;const r=s.pathname.split("/").slice(1),n=i.pathname.split("/").slice(1,-1);for(;r[0]===n[0];)r.shift(),n.shift();for(;n.length;)n.shift(),r.unshift("..");return r.join("/")+s.search+s.hash}(t,e.baseUrl)),1===e.version?encodeURIComponent(t):t),Pn=t=>100*Ln(t/100),xn={br:Ln,d:Ln,bl:Pn,dl:Pn,mtp:Pn,nor:(t,e)=>{let s=t;return e.version>=2&&(t instanceof on&&"string"==typeof t.value?s=new on([t]):"string"==typeof t&&(s=[t])),In(s,e)},rtp:Pn,tb:Ln},Rn="request",Dn="response",On=["ab","bg","bl","br","bs","bsd","cdn","cid","cs","df","ec","lab","lb","ltc","msd","mtp","pb","pr","pt","sf","sid","sn","st","sta","tab","tb","tbl","tpb","ts","v"],Mn=["e"],Fn=/^[a-zA-Z0-9-.]+-[a-zA-Z0-9-.]+$/;function Nn(t){return Fn.test(t)}const Bn=["d","dl","nor","ot","rtp","su"],jn=["cmsdd","cmsds","rc","smrt","ttfb","ttfbb","ttlb","url"],$n=["bl","br","bs","cid","d","dl","mtp","nor","nrr","ot","pr","rtp","sf","sid","st","su","tb","v"];function Un(t){return $n.includes(t)||Nn(t)}const Hn={[Dn]:function(t){return On.includes(t)||Bn.includes(t)||jn.includes(t)||Nn(t)},[wn]:function(t){return On.includes(t)||Mn.includes(t)||Nn(t)},[Rn]:function(t){return On.includes(t)||Bn.includes(t)||Nn(t)}};function Vn(t,e={}){const s={};if(null==t||"object"!=typeof t)return s;const r=e.version||t.v||1,n=e.reportingMode||Rn,a=1===r?Un:Hn[n];let o=Object.keys(t).filter(a);const l=e.filter;"function"==typeof l&&(o=o.filter(l));const h=n===Dn||n===wn;h&&!o.includes("ts")&&o.push("ts"),r>1&&!o.includes("v")&&o.push("v");const c=b({},xn,e.formatters),d={version:r,reportingMode:n,baseUrl:e.baseUrl};return o.sort().forEach(e=>{let n=t[e];const a=c[e];if("function"==typeof a&&(n=a(n,d)),"v"===e){if(1===r)return;n=r}"pr"==e&&1===n||(h&&"ts"===e&&!i(n)&&(n=Date.now()),function(t){return"number"==typeof t?i(t):null!=t&&""!==t&&!1!==t}(n)&&(function(t){return["ot","sf","st","e","sta"].includes(t)}(e)&&"string"==typeof n&&(n=new hn(n)),s[e]=n))}),s}function Gn(t,e,s){return b(t,function(t,e={}){const s={};if(!t)return s;const i=function(t,e){const s={};if(!t)return s;const i=Object.keys(t),r=e?(n=e,Object.keys(n).reduce((t,e)=>{var s;return null===(s=n[e])||void 0===s||s.forEach(s=>t[s]=e),t},{})):{};var n;return i.reduce((e,s)=>{var i;const n=Cn[s]||r[s]||kn;return(null!==(i=e[n])&&void 0!==i?i:e[n]={})[s]=t[s],e},s)}(Vn(t,e),null==e?void 0:e.customHeaderMap);return Object.entries(i).reduce((t,[e,s])=>{const i=_n(s,{whitespace:!1});return i&&(t[e]=i),t},s)}(e,s))}const Wn=/CMCD=[^&#]+/;function Kn(t,e,s){const i=function(t,e={}){return t?`CMCD=${function(t,e={}){if(!t)return"";const s=function(t,e={}){return t?_n(Vn(t,e),{whitespace:!1}):""}(t,e);return encodeURIComponent(s)}(t,e)}`:""}(e,s);if(!i)return t;if(Wn.test(t))return t.replace(Wn,i);const r=t.includes("?")?"&":"?";return`${t}${r}${i}`}function zn(t,e,s,i){t&&Object.keys(e).forEach(r=>{const n=t.filter(t=>t.groupId===r).map(t=>{const n=b({},t);return n.details=void 0,n.attrs=new Ge(n.attrs),n.url=n.attrs.URI=qn(t.url,t.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",s),n.groupId=n.attrs["GROUP-ID"]=e[r],n.attrs["PATHWAY-ID"]=i,n});t.push(...n)})}function qn(t,e,s,i){const{HOST:r,PARAMS:n,[s]:a}=i;let o;e&&(o=null==a?void 0:a[e],o&&(t=o));const l=new self.URL(t);return r&&!o&&(l.host=r),n&&Object.keys(n).sort().forEach(t=>{t&&l.searchParams.set(t,n[t])}),l.href}class Yn extends A{constructor(t){super("eme",t.logger),this.hls=void 0,this.config=void 0,this.media=null,this.mediaResolved=void 0,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.mediaKeys=null,this.setMediaKeysQueue=Yn.CDMCleanupPromise?[Yn.CDMCleanupPromise]:[],this.bannedKeyIds={},this.onMediaEncrypted=t=>{const{initDataType:e,initData:s}=t,i=`"${t.type}" event: init data type: "${e}"`;if(this.debug(i),null!==s){if(!this.keyFormatPromise){let t=Object.keys(this.keySystemAccessPromises);t.length||(t=ds(this.config));const e=t.map(cs).filter(t=>!!t);this.keyFormatPromise=this.getKeyFormatPromise(e)}this.keyFormatPromise.then(r=>{const n=hs(r);if("sinf"!==e||n!==rs.FAIRPLAY)return void this.log(`Ignoring "${t.type}" event with init data type: "${e}" for selected key-system ${n}`);let a;try{const t=X(new Uint8Array(s)),e=ct(Je(JSON.parse(t).sinf));if(!e)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");a=new Uint8Array(e.subarray(8,24))}catch(t){return void this.warn(`${i} Failed to parse sinf: ${t}`)}const o=R(a),{keyIdToKeySessionPromise:l,mediaKeySessions:h}=this;let c=l[o];for(let t=0;t<h.length;t++){const i=h[t],r=i.decryptdata;if(!r.keyId)continue;const n=R(r.keyId);if(Ye(a,r.keyId)||-1!==r.uri.replace(/-/g,"").indexOf(o)){if(c=l[n],!c)continue;if(r.pssh)break;delete l[n],r.pssh=new Uint8Array(s),r.keyId=a,c=l[o]=c.then(()=>this.generateRequestWithPreferredKeySession(i,e,s,"encrypted-event-key-match")),c.catch(t=>this.handleError(t));break}}c||this.handleError(new Error(`Key ID ${o} not encountered in playlist. Key-system sessions ${h.length}.`))}).catch(t=>this.handleError(t))}},this.onWaitingForKey=t=>{this.log(`"${t.type}" event`)},this.hls=t,this.config=t.config,this.registerListeners()}destroy(){this.onDestroying(),this.onMediaDetached();const t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.config=this.keyIdToKeySessionPromise=null,this.onMediaEncrypted=this.onWaitingForKey=null}registerListeners(){this.hls.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(l.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(l.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(l.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.on(l.DESTROYING,this.onDestroying,this)}unregisterListeners(){this.hls.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(l.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(l.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(l.MANIFEST_LOADED,this.onManifestLoaded,this),this.hls.off(l.DESTROYING,this.onDestroying,this)}getLicenseServerUrl(t){const{drmSystems:e,widevineLicenseUrl:s}=this.config,i=null==e?void 0:e[t];return i?i.licenseUrl:t===rs.WIDEVINE&&s?s:void 0}getLicenseServerUrlOrThrow(t){const e=this.getLicenseServerUrl(t);if(void 0===e)throw new Error(`no license server URL configured for key-system "${t}"`);return e}getServerCertificateUrl(t){const{drmSystems:e}=this.config,s=null==e?void 0:e[t];if(s)return s.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${t}"]`)}attemptKeySystemAccess(t){const e=this.hls.levels,s=(t,e,s)=>!!t&&s.indexOf(t)===e,i=e.map(t=>t.audioCodec).filter(s),r=e.map(t=>t.videoCodec).filter(s);return i.length+r.length===0&&r.push("avc1.42e01e"),new Promise((e,s)=>{const n=t=>{const l=t.shift();this.getMediaKeysPromise(l,i,r).then(t=>e({keySystem:l,mediaKeys:t})).catch(e=>{t.length?n(t):s(e instanceof Zn?e:new Zn({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_NO_ACCESS,error:e,fatal:!0},e.message))})};n(t)})}requestMediaKeySystemAccess(t,e){const{requestMediaKeySystemAccessFunc:s}=this.config;if("function"!=typeof s){let t=`Configured requestMediaKeySystemAccess is not a function ${s}`;return null===us&&"http:"===self.location.protocol&&(t=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(t))}return s(t,e)}getMediaKeysPromise(t,e,s){var i;const r=function(t,e,s,i){let r;switch(t){case rs.FAIRPLAY:r=["cenc","sinf"];break;case rs.WIDEVINE:case rs.PLAYREADY:r=["cenc"];break;case rs.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${t}`)}return function(t,e,s,i){return[{initDataTypes:t,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map(t=>({contentType:`audio/mp4; codecs=${t}`,robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null})),videoCapabilities:s.map(t=>({contentType:`video/mp4; codecs=${t}`,robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}))}]}(r,e,s,i)}(t,e,s,this.config.drmSystemOptions||{});let n=this.keySystemAccessPromises[t],a=null==(i=n)?void 0:i.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${t}" key-system access with config: ${zt(r)}`),a=this.requestMediaKeySystemAccess(t,r);const e=n=this.keySystemAccessPromises[t]={keySystemAccess:a};return a.catch(e=>{this.log(`Failed to obtain access to key-system "${t}": ${e}`)}),a.then(s=>{this.log(`Access for key-system "${s.keySystem}" obtained`);const i=this.fetchServerCertificate(t);this.log(`Create media-keys for "${t}"`);const r=e.mediaKeys=s.createMediaKeys().then(s=>(this.log(`Media-keys created for "${t}"`),e.hasMediaKeys=!0,i.then(e=>e?this.setMediaKeysServerCertificate(s,t,e):s)));return r.catch(e=>{this.error(`Failed to create media-keys for "${t}"}: ${e}`)}),r})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:t,keySystem:e,mediaKeys:s}){this.log(`Creating key-system session "${e}" keyId: ${R(t.keyId||[])} keyUri: ${t.uri}`);const i=s.createSession(),r={decryptdata:t,keySystem:e,mediaKeys:s,mediaKeysSession:i,keyStatus:"status-pending"};return this.mediaKeySessions.push(r),r}renewKeySession(t){const e=t.decryptdata;if(e.pssh){const s=this.createMediaKeySessionContext(t),i=Xn(e),r="cenc";this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(s,r,e.pssh.buffer,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)}updateKeySession(t,e){const s=t.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyId ${R(t.decryptdata.keyId||[])}\n } (data length: ${e.byteLength})`),s.update(e)}getSelectedKeySystemFormats(){return Object.keys(this.keySystemAccessPromises).map(t=>({keySystem:t,hasMediaKeys:this.keySystemAccessPromises[t].hasMediaKeys})).filter(({hasMediaKeys:t})=>!!t).map(({keySystem:t})=>cs(t)).filter(t=>!!t)}getKeySystemAccess(t){return this.getKeySystemSelectionPromise(t).then(({keySystem:t,mediaKeys:e})=>this.attemptSetMediaKeys(t,e))}selectKeySystem(t){return new Promise((e,s)=>{this.getKeySystemSelectionPromise(t).then(({keySystem:t})=>{const i=cs(t);i?e(i):s(new Error(`Unable to find format for key-system "${t}"`))}).catch(s)})}selectKeySystemFormat(t){const e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${t.sn} ${t.type}: ${t.level}) key formats ${e.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise}getKeyFormatPromise(t){const e=ds(this.config),s=t.map(hs).filter(t=>!!t&&-1!==e.indexOf(t));return this.selectKeySystem(s)}getKeyStatus(t){const{mediaKeySessions:e}=this;for(let s=0;s<e.length;s++){const i=Qn(t,e[s]);if(i)return i}}loadKey(t){const e=t.keyInfo.decryptdata,s=Xn(e),i=this.bannedKeyIds[s];if(i||"internal-error"===this.getKeyStatus(e)){const s=Jn(i||"internal-error",e);return this.handleError(s,t.frag),Promise.reject(s)}const r=`(keyId: ${s} format: "${e.keyFormat}" method: ${e.method} uri: ${e.uri})`;this.log(`Starting session for key ${r}`);const n=this.keyIdToKeySessionPromise[s];if(!n){const i=this.getKeySystemForKeyPromise(e).then(({keySystem:s,mediaKeys:i})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${t.frag.sn} ${t.frag.type}: ${t.frag.level} using key ${r}`),this.attemptSetMediaKeys(s,i).then(()=>(this.throwIfDestroyed(),this.createMediaKeySessionContext({keySystem:s,mediaKeys:i,decryptdata:e}))))).then(t=>{const s=e.pssh?e.pssh.buffer:null;return this.generateRequestWithPreferredKeySession(t,"cenc",s,"playlist-key")});return i.catch(e=>this.handleError(e,t.frag)),this.keyIdToKeySessionPromise[s]=i,i}return n.catch(s=>{if(s instanceof Zn){const i=T({},s.data);"internal-error"===this.getKeyStatus(e)&&(i.decryptdata=e);const r=new Zn(i,s.message);this.handleError(r,t.frag)}}),n}throwIfDestroyed(t="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(t,e){if(this.hls)if(t instanceof Zn){e&&(t.data.frag=e);const s=t.data.decryptdata;this.error(`${t.message}${s?` (${R(s.keyId||[])})`:""}`),this.hls.trigger(l.ERROR,t.data)}else this.error(t.message),this.hls.trigger(l.ERROR,{type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0})}getKeySystemForKeyPromise(t){const e=Xn(t),s=this.keyIdToKeySessionPromise[e];if(!s){const e=hs(t.keyFormat),s=e?[e]:ds(this.config);return this.attemptKeySystemAccess(s)}return s}getKeySystemSelectionPromise(t){if(t.length||(t=ds(this.config)),0===t.length)throw new Zn({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${zt({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(t)}attemptSetMediaKeys(t,e){if(this.mediaResolved=void 0,this.mediaKeys===e)return Promise.resolve();const s=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${t}"`);const i=Promise.all(s).then(()=>this.media?this.media.setMediaKeys(e):new Promise((t,s)=>{this.mediaResolved=()=>{if(this.mediaResolved=void 0,!this.media)return s(new Error("Attempted to set mediaKeys without media element attached"));this.mediaKeys=e,this.media.setMediaKeys(e).then(t).catch(s)}}));return this.mediaKeys=e,this.setMediaKeysQueue.push(i),i.then(()=>{this.log(`Media-keys set for "${t}"`),s.push(i),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(t=>-1===s.indexOf(t))})}generateRequestWithPreferredKeySession(t,e,s,i){var r;const n=null==(r=this.config.drmSystems)||null==(r=r[t.keySystem])?void 0:r.generateRequest;if(n)try{const i=n.call(this.hls,e,s,t);if(!i)throw new Error("Invalid response from configured generateRequest filter");e=i.initDataType,s=i.initData?i.initData:null,t.decryptdata.pssh=s?new Uint8Array(s):null}catch(t){if(this.warn(t.message),this.hls&&this.hls.config.debug)throw t}if(null===s)return this.log(`Skipping key-session request for "${i}" (no initData)`),Promise.resolve(t);const l=Xn(t.decryptdata),h=t.decryptdata.uri;this.log(`Generating key-session request for "${i}" keyId: ${l} URI: ${h} (init data type: ${e} length: ${s.byteLength})`);const c=new vi,d=t._onmessage=e=>{const s=t.mediaKeysSession;if(!s)return void c.emit("error",new Error("invalid state"));const{messageType:i,message:r}=e;this.log(`"${i}" message event for session "${s.sessionId}" message size: ${r.byteLength}`),"license-request"===i||"license-renewal"===i?this.renewLicense(t,r).catch(t=>{c.eventNames().length?c.emit("error",t):this.handleError(t)}):"license-release"===i?t.keySystem===rs.FAIRPLAY&&this.updateKeySession(t,ts("acknowledged")).then(()=>this.removeSession(t)).catch(t=>this.handleError(t)):this.warn(`unhandled media key message type "${i}"`)},u=(t,e)=>{let s;e.keyStatus=t,t.startsWith("usable")?c.emit("resolved"):"internal-error"===t||"output-restricted"===t||"output-downscaled"===t?s=Jn(t,e.decryptdata):"expired"===t?s=new Error(`key expired (keyId: ${l})`):"released"===t?s=new Error("key released"):"status-pending"===t||this.warn(`unhandled key status change "${t}" (keyId: ${l})`),s&&(c.eventNames().length?c.emit("error",s):this.handleError(s))},p=t._onkeystatuseschange=e=>{if(!t.mediaKeysSession)return void c.emit("error",new Error("invalid state"));const s=this.getKeyStatuses(t);if(!Object.keys(s).some(t=>"status-pending"!==s[t]))return;if("expired"===s[l])return this.log(`Expired key ${zt(s)} in key-session "${t.mediaKeysSession.sessionId}"`),void this.renewKeySession(t);let i=s[l];if(i)u(i,t);else{var r;const e=1e3;t.keyStatusTimeouts||(t.keyStatusTimeouts={}),(r=t.keyStatusTimeouts)[l]||(r[l]=self.setTimeout(()=>{if(!t.mediaKeysSession||!this.mediaKeys)return;const s=this.getKeyStatus(t.decryptdata);if(s&&"status-pending"!==s)return this.log(`No status for keyId ${l} in key-session "${t.mediaKeysSession.sessionId}". Using session key-status ${s} from other session.`),u(s,t);this.log(`key status for ${l} in key-session "${t.mediaKeysSession.sessionId}" timed out after ${e}ms`),i="internal-error",u(i,t)},e)),this.log(`No status for keyId ${l} (${zt(s)}).`)}};Zs(t.mediaKeysSession,"message",d),Zs(t.mediaKeysSession,"keystatuseschange",p);const f=new Promise((t,e)=>{c.on("error",e),c.on("resolved",t)});return t.mediaKeysSession.generateRequest(e,s).then(()=>{this.log(`Request generated for key-session "${t.mediaKeysSession.sessionId}" keyId: ${l} URI: ${h}`)}).catch(e=>{throw new Zn({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_NO_SESSION,error:e,decryptdata:t.decryptdata,fatal:!1},`Error generating key-session request: ${e}`)}).then(()=>f).catch(e=>(c.removeAllListeners(),this.removeSession(t).then(()=>{throw e}))).then(()=>(c.removeAllListeners(),t))}getKeyStatuses(t){const e={};return t.mediaKeysSession.keyStatuses.forEach((s,i)=>{if("string"==typeof i&&"object"==typeof s){const t=i;i=s,s=t}const r="buffer"in i?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):new Uint8Array(i);if(t.keySystem===rs.PLAYREADY&&16===r.length){const t=R(r);e[t]=s,es(r)}const n=R(r);"internal-error"===s&&(this.bannedKeyIds[n]=s),this.log(`key status change "${s}" for keyStatuses keyId: ${n} key-session "${t.mediaKeysSession.sessionId}"`),e[n]=s}),e}fetchServerCertificate(t){const e=this.config,s=new(0,e.loader)(e),i=this.getServerCertificateUrl(t);return i?(this.log(`Fetching server certificate for "${t}"`),new Promise((r,n)=>{const l={responseType:"arraybuffer",url:i},h=e.certLoadPolicy.default,c={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(t,e,s,i)=>{r(t.data)},onError:(e,s,r,h)=>{n(new Zn({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:T({url:l.url,data:void 0},e)},`"${t}" certificate request failed (${i}). Status: ${e.code} (${e.text})`))},onTimeout:(e,s,r)=>{n(new Zn({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:r,response:{url:l.url,data:void 0}},`"${t}" certificate request timed out (${i})`))},onAbort:(t,e,s)=>{n(new Error("aborted"))}};s.load(l,c,d)})):Promise.resolve()}setMediaKeysServerCertificate(t,e,s){return new Promise((i,r)=>{t.setServerCertificate(s).then(r=>{this.log(`setServerCertificate ${r?"success":"not supported by CDM"} (${s.byteLength}) on "${e}"`),i(t)}).catch(t=>{r(new Zn({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:t,fatal:!0},t.message))})})}renewLicense(t,e){return this.requestLicense(t,new Uint8Array(e)).then(e=>this.updateKeySession(t,new Uint8Array(e)).catch(e=>{throw new Zn({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_SESSION_UPDATE_FAILED,decryptdata:t.decryptdata,error:e,fatal:!1},e.message)}))}unpackPlayReadyKeyMessage(t,e){const s=String.fromCharCode.apply(null,new Uint16Array(e.buffer));if(!s.includes("PlayReadyKeyMessage"))return t.setRequestHeader("Content-Type","text/xml; charset=utf-8"),e;const i=(new DOMParser).parseFromString(s,"application/xml"),r=i.querySelectorAll("HttpHeader");if(r.length>0){let e;for(let s=0,i=r.length;s<i;s++){var n,a;e=r[s];const i=null==(n=e.querySelector("name"))?void 0:n.textContent,o=null==(a=e.querySelector("value"))?void 0:a.textContent;i&&o&&t.setRequestHeader(i,o)}}const o=i.querySelector("Challenge"),l=null==o?void 0:o.textContent;if(!l)throw new Error("Cannot find <Challenge> in key message");return ts(atob(l))}setupLicenseXHR(t,e,s,i){const r=this.config.licenseXhrSetup;return r?Promise.resolve().then(()=>{if(!s.decryptdata)throw new Error("Key removed");return r.call(this.hls,t,e,s,i)}).catch(n=>{if(!s.decryptdata)throw n;return t.open("POST",e,!0),r.call(this.hls,t,e,s,i)}).then(s=>(t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:s||i})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:i}))}requestLicense(t,e){const s=this.config.keyLoadPolicy.default;return new Promise((i,r)=>{const n=this.getLicenseServerUrlOrThrow(t.keySystem);this.log(`Sending license request to URL: ${n}`);const l=new XMLHttpRequest;l.responseType="arraybuffer",l.onreadystatechange=()=>{if(!this.hls||!t.mediaKeysSession)return r(new Error("invalid state"));if(4===l.readyState)if(200===l.status){this._requestLicenseFailureCount=0;let e=l.response;this.log(`License received ${e instanceof ArrayBuffer?e.byteLength:e}`);const s=this.config.licenseResponseCallback;if(s)try{e=s.call(this.hls,l,n,t)}catch(t){this.error(t)}i(e)}else{const h=s.errorRetry,c=h?h.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>c||l.status>=400&&l.status<500)r(new Zn({type:a.KEY_SYSTEM_ERROR,details:o.KEY_SYSTEM_LICENSE_REQUEST_FAILED,decryptdata:t.decryptdata,fatal:!0,networkDetails:l,response:{url:n,data:void 0,code:l.status,text:l.statusText}},`License Request XHR failed (${n}). Status: ${l.status} (${l.statusText})`));else{const s=c-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${s} attempts left`),this.requestLicense(t,e).then(i,r)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=l,this.setupLicenseXHR(l,n,t,e).then(({xhr:e,licenseChallenge:s})=>{t.keySystem==rs.PLAYREADY&&(s=this.unpackPlayReadyKeyMessage(e,s)),e.send(s)}).catch(r)})}onDestroying(){this.unregisterListeners(),this._clear()}onMediaAttached(t,e){if(!this.config.emeEnabled)return;const s=e.media;this.media=s,Zs(s,"encrypted",this.onMediaEncrypted),Zs(s,"waitingforkey",this.onWaitingForKey);const i=this.mediaResolved;i?i():this.mediaKeys=s.mediaKeys}onMediaDetached(){const t=this.media;t&&(Js(t,"encrypted",this.onMediaEncrypted),Js(t,"waitingforkey",this.onWaitingForKey),this.media=null,this.mediaKeys=null)}_clear(){var t;this._requestLicenseFailureCount=0,this.keyIdToKeySessionPromise={},this.bannedKeyIds={};const e=this.mediaResolved;if(e&&e(),!this.mediaKeys&&!this.mediaKeySessions.length)return;const s=this.media,i=this.mediaKeySessions.slice();this.mediaKeySessions=[],this.mediaKeys=null,ms.clearKeyUriToKeyIdMap();const r=i.length;Yn.CDMCleanupPromise=Promise.all(i.map(t=>this.removeSession(t)).concat((null==s||null==(t=s.setMediaKeys(null))?void 0:t.catch(t=>{this.log(`Could not clear media keys: ${t}`),this.hls&&this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.KEY_SYSTEM_DESTROY_MEDIA_KEYS_ERROR,fatal:!1,error:new Error(`Could not clear media keys: ${t}`)})}))||Promise.resolve())).catch(t=>{this.log(`Could not close sessions and clear media keys: ${t}`),this.hls&&this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close sessions and clear media keys: ${t}`)})}).then(()=>{r&&this.log("finished closing key sessions and clearing media keys")})}onManifestLoading(){this._clear()}onManifestLoaded(t,{sessionKeys:e}){if(e&&this.config.emeEnabled&&!this.keyFormatPromise){const t=e.reduce((t,e)=>(-1===t.indexOf(e.keyFormat)&&t.push(e.keyFormat),t),[]);this.log(`Selecting key-system from session-keys ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)}}removeSession(t){const{mediaKeysSession:e,licenseXhr:s,decryptdata:i}=t;if(e){this.log(`Remove licenses and keys and close session "${e.sessionId}" keyId: ${R((null==i?void 0:i.keyId)||[])}`),t._onmessage&&(e.removeEventListener("message",t._onmessage),t._onmessage=void 0),t._onkeystatuseschange&&(e.removeEventListener("keystatuseschange",t._onkeystatuseschange),t._onkeystatuseschange=void 0),s&&s.readyState!==XMLHttpRequest.DONE&&s.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;const r=this.mediaKeySessions.indexOf(t);r>-1&&this.mediaKeySessions.splice(r,1);const{keyStatusTimeouts:n}=t;n&&Object.keys(n).forEach(t=>self.clearTimeout(n[t]));const{drmSystemOptions:h}=this.config,c=function(t){var e;return!(!t||"persistent-license"!==t.sessionType&&(null==(e=t.sessionTypes)||!e.some(t=>"persistent-license"===t)))}(h)?new Promise((t,s)=>{self.setTimeout(()=>s(new Error("MediaKeySession.remove() timeout")),8e3),e.remove().then(t).catch(s)}):Promise.resolve();return c.catch(t=>{this.log(`Could not remove session: ${t}`),this.hls&&this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.KEY_SYSTEM_DESTROY_REMOVE_SESSION_ERROR,fatal:!1,error:new Error(`Could not remove session: ${t}`)})}).then(()=>e.close()).catch(t=>{this.log(`Could not close session: ${t}`),this.hls&&this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.KEY_SYSTEM_DESTROY_CLOSE_SESSION_ERROR,fatal:!1,error:new Error(`Could not close session: ${t}`)})})}return Promise.resolve()}}function Xn(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(null===t.keyId)throw new Error("keyId is null");return R(t.keyId)}function Qn(t,e){return t.keyId&&e.mediaKeysSession.keyStatuses.has(t.keyId)?e.mediaKeysSession.keyStatuses.get(t.keyId):t.matches(e.decryptdata)?e.keyStatus:void 0}Yn.CDMCleanupPromise=void 0;class Zn extends Error{constructor(t,e){super(e),this.data=void 0,t.error||(t.error=new Error(e)),this.data=t,t.err=t.error}}function Jn(t,e){const s="output-restricted"===t,i=s?o.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:o.KEY_SYSTEM_STATUS_INTERNAL_ERROR;return new Zn({type:a.KEY_SYSTEM_ERROR,details:i,fatal:!1,decryptdata:e},s?"HDCP level output restricted":`key status changed to "${t}"`)}function ta(t,e){let s;try{s=new Event("addtrack")}catch(t){s=document.createEvent("Event"),s.initEvent("addtrack",!1,!1)}s.track=t,e.dispatchEvent(s)}function ea(t,e){const s=t.mode;if("disabled"===s&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(s){L.debug(`[texttrack-utils]: ${s}`);try{const s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,t.addCue(s)}catch(t){L.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${t}`)}}"disabled"===s&&(t.mode=s)}function sa(t,e){const s=t.mode;if("disabled"===s&&(t.mode="hidden"),t.cues)for(let s=t.cues.length;s--;)e&&t.cues[s].removeEventListener("enter",e),t.removeCue(t.cues[s]);"disabled"===s&&(t.mode=s)}function ia(t,e,s,i){const r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&t.cues.length>0){const r=function(t,e,s){const i=[],r=function(t,e){if(e<=t[0].startTime)return 0;const s=t.length-1;if(e>t[s].endTime)return-1;let i,r=0,n=s;for(;r<=n;)if(i=Math.floor((n+r)/2),e<t[i].startTime)n=i-1;else{if(!(e>t[i].startTime&&r<s))return i;r=i+1}return t[r].startTime-e<e-t[n].startTime?r:n}(t,e);if(r>-1)for(let n=r,a=t.length;n<a;n++){const r=t[n];if(r.startTime>=e&&r.endTime<=s)i.push(r);else if(r.startTime>s)return i}return i}(t.cues,e,s);for(let e=0;e<r.length;e++)i&&!i(r[e])||t.removeCue(r[e])}"disabled"===r&&(t.mode=r)}function ra(t){const e=[];for(let s=0;s<t.length;s++){const i=t[s];"subtitles"!==i.kind&&"captions"!==i.kind||!i.label||e.push(t[s])}return e}function na(t){let e=5381,s=t.length;for(;s;)e=33*e^t.charCodeAt(--s);return(e>>>0).toString()}const aa=.025;let oa=function(t){return t[t.Point=0]="Point",t[t.Range=1]="Range",t}({});function la(t,e,s){return`${t.identifier}-${s+1}-${na(e)}`}class ha{constructor(t,e){this.base=void 0,this._duration=null,this._timelineStart=null,this.appendInPlaceDisabled=void 0,this.appendInPlaceStarted=void 0,this.dateRange=void 0,this.hasPlayed=!1,this.cumulativeDuration=0,this.resumeOffset=NaN,this.playoutLimit=NaN,this.restrictions={skip:!1,jump:!1},this.snapOptions={out:!1,in:!1},this.assetList=[],this.assetListLoader=void 0,this.assetListResponse=null,this.resumeAnchor=void 0,this.error=void 0,this.resetOnResume=void 0,this.base=e,this.dateRange=t,this.setDateRange(t)}setDateRange(t){this.dateRange=t,this.resumeOffset=t.attr.optionalFloat("X-RESUME-OFFSET",this.resumeOffset),this.playoutLimit=t.attr.optionalFloat("X-PLAYOUT-LIMIT",this.playoutLimit),this.restrictions=t.attr.enumeratedStringList("X-RESTRICT",this.restrictions),this.snapOptions=t.attr.enumeratedStringList("X-SNAP",this.snapOptions)}reset(){var t;this.appendInPlaceStarted=!1,null==(t=this.assetListLoader)||t.destroy(),this.assetListLoader=void 0,this.supplementsPrimary||(this.assetListResponse=null,this.assetList=[],this._duration=null)}isAssetPastPlayoutLimit(t){var e;if(t>0&&t>=this.assetList.length)return!0;const s=this.playoutLimit;return!(t<=0||isNaN(s))&&(0===s||((null==(e=this.assetList[t])?void 0:e.startOffset)||0)>s)}findAssetIndex(t){return this.assetList.indexOf(t)}get identifier(){return this.dateRange.id}get startDate(){return this.dateRange.startDate}get startTime(){const t=this.dateRange.startTime;if(this.snapOptions.out){const e=this.dateRange.tagAnchor;if(e)return ca(t,e)}return t}get startOffset(){return this.cue.pre?0:this.startTime}get startIsAligned(){if(0===this.startTime||this.snapOptions.out)return!0;const t=this.dateRange.tagAnchor;if(t){const e=this.dateRange.startTime;return e-ca(e,t)<.1}return!1}get resumptionOffset(){const t=this.resumeOffset,e=i(t)?t:this.duration;return this.cumulativeDuration+e}get resumeTime(){const t=this.startOffset+this.resumptionOffset;if(this.snapOptions.in){const e=this.resumeAnchor;if(e)return ca(t,e)}return t}get appendInPlace(){return!!this.appendInPlaceStarted||!this.appendInPlaceDisabled&&!(this.cue.once||this.cue.pre||!this.startIsAligned||!(isNaN(this.playoutLimit)&&isNaN(this.resumeOffset)||this.resumeOffset&&this.duration&&Math.abs(this.resumeOffset-this.duration)<aa))}set appendInPlace(t){this.appendInPlaceStarted?this.resetOnResume=!t:this.appendInPlaceDisabled=!t}get timelineStart(){return null!==this._timelineStart?this._timelineStart:this.startTime}set timelineStart(t){this._timelineStart=t}get duration(){const t=this.playoutLimit;let e;return e=null!==this._duration?this._duration:this.dateRange.duration?this.dateRange.duration:this.dateRange.plannedDuration||0,!isNaN(t)&&t<e&&(e=t),e}set duration(t){this._duration=t}get cue(){return this.dateRange.cue}get timelineOccupancy(){return"RANGE"===this.dateRange.attr["X-TIMELINE-OCCUPIES"]?oa.Range:oa.Point}get supplementsPrimary(){return"PRIMARY"===this.dateRange.attr["X-TIMELINE-STYLE"]}get contentMayVary(){return"NO"!==this.dateRange.attr["X-CONTENT-MAY-VARY"]}get assetUrl(){return this.dateRange.attr["X-ASSET-URI"]}get assetListUrl(){return this.dateRange.attr["X-ASSET-LIST"]}get baseUrl(){return this.base.url}get assetListLoaded(){return this.assetList.length>0||null!==this.assetListResponse}toString(){return`["${(t=this).identifier}" ${t.cue.pre?"<pre>":t.cue.post?"<post>":""}${t.timelineStart.toFixed(2)}-${t.resumeTime.toFixed(2)}]`;var t}}function ca(t,e){return t-e.start<e.duration/2&&!(Math.abs(t-(e.start+e.duration))<aa)?e.start:e.start+e.duration}function da(t,e,s){const i=new self.URL(t,s);return"data:"!==i.protocol&&i.searchParams.set("_HLS_primary_id",e),i}function ua(t,e){for(;null!=(s=t.assetList[++e])&&s.error;)var s;return e}function pa(t){const e=t.timelineStart,s=t.duration||0;return`["${t.identifier}" ${e.toFixed(2)}-${(e+s).toFixed(2)}]`}class fa{constructor(t,e,s,i){this.hls=void 0,this.interstitial=void 0,this.assetItem=void 0,this.tracks=null,this.hasDetails=!1,this.mediaAttached=null,this._currentTime=void 0,this._bufferedEosTime=void 0,this.checkPlayout=()=>{this.reachedPlayout(this.currentTime)&&this.hls&&this.hls.trigger(l.PLAYOUT_LIMIT_REACHED,{})};const r=this.hls=new t(e);this.interstitial=s,this.assetItem=i;const n=()=>{this.hasDetails=!0};r.once(l.LEVEL_LOADED,n),r.once(l.AUDIO_TRACK_LOADED,n),r.once(l.SUBTITLE_TRACK_LOADED,n),r.on(l.MEDIA_ATTACHING,(t,{media:e})=>{this.removeMediaListeners(),this.mediaAttached=e,this.interstitial.playoutLimit&&(e.addEventListener("timeupdate",this.checkPlayout),this.appendInPlace&&r.on(l.BUFFER_APPENDED,()=>{const t=this.bufferedEnd;this.reachedPlayout(t)&&(this._bufferedEosTime=t,r.trigger(l.BUFFERED_TO_END,void 0))}))})}get appendInPlace(){return this.interstitial.appendInPlace}loadSource(){const t=this.hls;if(t)if(t.url)t.levels.length&&!t.started&&t.startLoad(-1,!0);else{let e=this.assetItem.uri;try{e=da(e,t.config.primarySessionId||"").href}catch(t){}t.loadSource(e)}}bufferedInPlaceToEnd(t){var e;if(!this.appendInPlace)return!1;if(null!=(e=this.hls)&&e.bufferedToEnd)return!0;if(!t)return!1;const s=Math.min(this._bufferedEosTime||1/0,this.duration),i=this.timelineOffset,r=Fe.bufferInfo(t,i,0);return this.getAssetTime(r.end)>=s-.02}reachedPlayout(t){const e=this.interstitial.playoutLimit;return this.startOffset+t>=e}get destroyed(){var t;return!(null!=(t=this.hls)&&t.userConfig)}get assetId(){return this.assetItem.identifier}get interstitialId(){return this.assetItem.parentIdentifier}get media(){var t;return(null==(t=this.hls)?void 0:t.media)||null}get bufferedEnd(){const t=this.media||this.mediaAttached;if(!t)return this._bufferedEosTime?this._bufferedEosTime:this.currentTime;const e=Fe.bufferInfo(t,t.currentTime,.001);return this.getAssetTime(e.end)}get currentTime(){const t=this.media||this.mediaAttached;return t?this.getAssetTime(t.currentTime):this._currentTime||0}get duration(){const t=this.assetItem.duration;if(!t)return 0;const e=this.interstitial.playoutLimit;if(e){const s=e-this.startOffset;if(s>0&&s<t)return s}return t}get remaining(){const t=this.duration;return t?Math.max(0,t-this.currentTime):0}get startOffset(){return this.assetItem.startOffset}get timelineOffset(){var t;return(null==(t=this.hls)?void 0:t.config.timelineOffset)||0}set timelineOffset(t){const e=this.timelineOffset;if(t!==e){const s=t-e;if(Math.abs(s)>1/9e4&&this.hls){if(this.hasDetails)throw new Error("Cannot set timelineOffset after playlists are loaded");this.hls.config.timelineOffset=t}}}getAssetTime(t){const e=this.timelineOffset,s=this.duration;return Math.min(Math.max(0,t-e),s)}removeMediaListeners(){const t=this.mediaAttached;t&&(this._currentTime=t.currentTime,this.bufferSnapShot(),t.removeEventListener("timeupdate",this.checkPlayout))}bufferSnapShot(){var t;this.mediaAttached&&null!=(t=this.hls)&&t.bufferedToEnd&&(this._bufferedEosTime=this.bufferedEnd)}destroy(){this.removeMediaListeners(),this.hls&&this.hls.destroy(),this.hls=null,this.tracks=this.mediaAttached=this.checkPlayout=null}attachMedia(t){var e;this.loadSource(),null==(e=this.hls)||e.attachMedia(t)}detachMedia(){var t;this.removeMediaListeners(),this.mediaAttached=null,null==(t=this.hls)||t.detachMedia()}resumeBuffering(){var t;null==(t=this.hls)||t.resumeBuffering()}pauseBuffering(){var t;null==(t=this.hls)||t.pauseBuffering()}transferMedia(){var t;return this.bufferSnapShot(),(null==(t=this.hls)?void 0:t.transferMedia())||null}resetDetails(){const t=this.hls;if(t&&this.hasDetails){t.stopLoad();const e=t=>delete t.details;t.levels.forEach(e),t.allAudioTracks.forEach(e),t.allSubtitleTracks.forEach(e),this.hasDetails=!1}}on(t,e,s){var i;null==(i=this.hls)||i.on(t,e)}once(t,e,s){var i;null==(i=this.hls)||i.once(t,e)}off(t,e,s){var i;null==(i=this.hls)||i.off(t,e)}toString(){var t;return`HlsAssetPlayer: ${pa(this.assetItem)} ${null==(t=this.hls)?void 0:t.sessionId} ${this.appendInPlace?"append-in-place":""}`}}class ga extends A{constructor(t,e){super("interstitials-sched",e),this.onScheduleUpdate=void 0,this.eventMap={},this.events=null,this.items=null,this.durations={primary:0,playout:0,integrated:0},this.onScheduleUpdate=t}destroy(){this.reset(),this.onScheduleUpdate=null}reset(){this.eventMap={},this.setDurations(0,0,0),this.events&&this.events.forEach(t=>t.reset()),this.events=this.items=null}resetErrorsInRange(t,e){return this.events?this.events.reduce((s,i)=>t<=i.startOffset&&e>i.startOffset?(delete i.error,s+1):s,0):0}get duration(){const t=this.items;return t?t[t.length-1].end:0}get length(){return this.items?this.items.length:0}getEvent(t){return t&&this.eventMap[t]||null}hasEvent(t){return t in this.eventMap}findItemIndex(t,e){if(t.event)return this.findEventIndex(t.event.identifier);let s=-1;t.nextEvent?s=this.findEventIndex(t.nextEvent.identifier)-1:t.previousEvent&&(s=this.findEventIndex(t.previousEvent.identifier)+1);const i=this.items;if(i)for(i[s]||(void 0===e&&(e=t.start),s=this.findItemIndexAtTime(e));s>=0&&null!=(r=i[s])&&r.event;){var r;s--}return s}findItemIndexAtTime(t,e){const s=this.items;if(s)for(let i=0;i<s.length;i++){let r=s[i];if(e&&"primary"!==e&&(r=r[e]),t===r.start||t>r.start&&t<r.end)return i}return-1}findJumpRestrictedIndex(t,e){const s=this.items;if(s)for(let i=t;i<=e&&s[i];i++){const t=s[i].event;if(null!=t&&t.restrictions.jump&&!t.appendInPlace)return i}return-1}findEventIndex(t){const e=this.items;if(e)for(let i=e.length;i--;){var s;if((null==(s=e[i].event)?void 0:s.identifier)===t)return i}return-1}findAssetIndex(t,e){const s=t.assetList,i=s.length;if(i>1)for(let t=0;t<i;t++){const r=s[t];if(!r.error){const s=r.timelineStart;if(e===s||e>s&&(e<s+(r.duration||0)||t===i-1))return t}}return 0}get assetIdAtEnd(){var t;const e=null==(t=this.items)||null==(t=t[this.length-1])?void 0:t.event;if(e){const t=e.assetList,s=t[t.length-1];if(s)return s.identifier}return null}parseInterstitialDateRanges(t,e){const s=t.main.details,{dateRanges:i}=s,r=this.events,n=this.parseDateRanges(i,{url:s.url},e),a=Object.keys(i),o=r?r.filter(t=>!a.includes(t.identifier)):[];n.length&&n.sort((t,e)=>{const s=t.cue.pre,i=t.cue.post,r=e.cue.pre,n=e.cue.post;if(s&&!r)return-1;if(r&&!s)return 1;if(i&&!n)return 1;if(n&&!i)return-1;if(!(s||r||i||n)){const s=t.startTime,i=e.startTime;if(s!==i)return s-i}return t.dateRange.tagOrder-e.dateRange.tagOrder}),this.events=n,o.forEach(t=>{this.removeEvent(t)}),this.updateSchedule(t,o)}updateSchedule(t,e=[],s=!1){const i=this.events||[];if(i.length||e.length||this.length<2){const r=this.items,n=this.parseSchedule(i,t);(s||e.length||(null==r?void 0:r.length)!==n.length||n.some((t,e)=>Math.abs(t.playout.start-r[e].playout.start)>.005||Math.abs(t.playout.end-r[e].playout.end)>.005))&&(this.items=n,this.onScheduleUpdate(e,r))}}parseDateRanges(t,e,s){const i=[],r=Object.keys(t);for(let n=0;n<r.length;n++){const a=r[n],o=t[a];if(o.isInterstitial){let t=this.eventMap[a];t?t.setDateRange(o):(t=new ha(o,e),this.eventMap[a]=t,!1===s&&(t.appendInPlace=s)),i.push(t)}}return i}parseSchedule(t,e){const s=[],i=e.main.details,r=i.live?1/0:i.edge;let n=0;if((t=t.filter(t=>!(t.error||t.cue.once&&t.hasPlayed))).length){this.resolveOffsets(t,e);let i=0,o=0;if(t.forEach((e,a)=>{const l=e.cue.pre,h=e.cue.post,c=t[a-1]||null,d=e.appendInPlace,u=h?r:e.startOffset,p=e.duration,f=e.timelineOccupancy===oa.Range?p:0,g=e.resumptionOffset,m=(null==c?void 0:c.startTime)===u,y=u+e.cumulativeDuration;let v=d?y+p:u+g;if(l||!h&&u<=0){const t=o;o+=f,e.timelineStart=y;const i=n;n+=p,s.push({event:e,start:y,end:v,playout:{start:i,end:n},integrated:{start:t,end:o}})}else{if(!(u<=r))return;{if(!m){const r=u-i;if(r>.033){const l=i,h=o;o+=r;const c=n;n+=r;const d={previousEvent:t[a-1]||null,nextEvent:e,start:l,end:l+r,playout:{start:c,end:n},integrated:{start:h,end:o}};s.push(d)}else r>0&&c&&(c.cumulativeDuration+=r,s[s.length-1].end=u)}h&&(v=y),e.timelineStart=y;const r=o;o+=f;const l=n;n+=p,s.push({event:e,start:y,end:v,playout:{start:l,end:n},integrated:{start:r,end:o}})}}const b=e.resumeTime;i=h||b>r?r:b}),i<r){var a;const t=i,e=o,l=r-i;o+=l;const h=n;n+=l,s.push({previousEvent:(null==(a=s[s.length-1])?void 0:a.event)||null,nextEvent:null,start:i,end:t+l,playout:{start:h,end:n},integrated:{start:e,end:o}})}this.setDurations(r,n,o)}else{const t=0;s.push({previousEvent:null,nextEvent:null,start:t,end:r,playout:{start:t,end:r},integrated:{start:t,end:r}}),this.setDurations(r,r,r)}return s}setDurations(t,e,s){this.durations={primary:t,playout:e,integrated:s}}resolveOffsets(t,e){const s=e.main.details,r=s.live?1/0:s.edge;let n=0,a=-1;t.forEach((o,l)=>{const h=o.cue.pre,c=o.cue.post,d=h?0:c?r:o.startTime;this.updateAssetDurations(o),a===d?o.cumulativeDuration=n:(n=0,a=d),!c&&o.snapOptions.in&&(o.resumeAnchor=ie(null,s.fragments,o.startOffset+o.resumptionOffset,0,0)||void 0),o.appendInPlace&&!o.appendInPlaceStarted&&(this.primaryCanResumeInPlaceAt(o,e)||(o.appendInPlace=!1)),!o.appendInPlace&&l+1<t.length&&t[l+1].startTime-t[l].resumeTime<.033&&(t[l+1].appendInPlace=!1,t[l+1].appendInPlace&&this.warn(`Could not change append strategy for abutting event ${o}`));const u=i(o.resumeOffset)?o.resumeOffset:o.duration;n+=u})}primaryCanResumeInPlaceAt(t,e){const s=t.resumeTime,i=t.startTime+t.resumptionOffset;return Math.abs(s-i)>aa?(this.log(`"${t.identifier}" resumption ${s} not aligned with estimated timeline end ${i}`),!1):!Object.keys(e).some(i=>{const r=e[i].details,n=r.edge;if(s>=n)return this.log(`"${t.identifier}" resumption ${s} past ${i} playlist end ${n}`),!1;const a=ie(null,r.fragments,s);if(!a)return this.log(`"${t.identifier}" resumption ${s} does not align with any fragments in ${i} playlist (${r.fragStart}-${r.fragmentEnd})`),!0;const o="audio"===i?.175:0;return!(Math.abs(a.start-s)<aa+o||Math.abs(a.end-s)<aa+o||(this.log(`"${t.identifier}" resumption ${s} not aligned with ${i} fragment bounds (${a.start}-${a.end} sn: ${a.sn} cc: ${a.cc})`),0))})}updateAssetDurations(t){if(!t.assetListLoaded)return;const e=t.timelineStart;let s=0,i=!1,r=!1;for(let n=0;n<t.assetList.length;n++){const a=t.assetList[n],o=e+s;a.startOffset=s,a.timelineStart=o,i||(i=null===a.duration),r||(r=!!a.error),s+=a.error?0:a.duration||0}t.duration=i&&!r?Math.max(s,t.duration):s}removeEvent(t){t.reset(),delete this.eventMap[t.identifier]}}function ma(t){return`[${t.event?'"'+t.event.identifier+'"':"primary"}: ${t.start.toFixed(2)}-${t.end.toFixed(2)}]`}class ya{constructor(t){this.hls=void 0,this.hls=t}destroy(){this.hls=null}loadAssetList(t,e){const s=t.assetListUrl;let i;try{i=da(s,this.hls.sessionId,t.baseUrl)}catch(e){const i=this.assignAssetListError(t,o.ASSET_LIST_LOAD_ERROR,e,s);return void this.hls.trigger(l.ERROR,i)}e&&"data:"!==i.protocol&&i.searchParams.set("_HLS_start_offset",""+e);const r=this.hls.config,n=new(0,r.loader)(r),a={responseType:"json",url:i.href},h=r.interstitialAssetListLoadPolicy.default,c={loadPolicy:h,timeout:h.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},d={onSuccess:(e,s,i,r)=>{const n=e.data,a=null==n?void 0:n.ASSETS;if(!Array.isArray(a)){const e=this.assignAssetListError(t,o.ASSET_LIST_PARSING_ERROR,new Error("Invalid interstitial asset list"),i.url,s,r);return void this.hls.trigger(l.ERROR,e)}t.assetListResponse=n,this.hls.trigger(l.ASSET_LIST_LOADED,{event:t,assetListResponse:n,networkDetails:r})},onError:(e,s,i,r)=>{const n=this.assignAssetListError(t,o.ASSET_LIST_LOAD_ERROR,new Error(`Error loading X-ASSET-LIST: HTTP status ${e.code} ${e.text} (${s.url})`),s.url,r,i);this.hls.trigger(l.ERROR,n)},onTimeout:(e,s,i)=>{const r=this.assignAssetListError(t,o.ASSET_LIST_LOAD_TIMEOUT,new Error(`Timeout loading X-ASSET-LIST (${s.url})`),s.url,e,i);this.hls.trigger(l.ERROR,r)}};return n.load(a,c,d),this.hls.trigger(l.ASSET_LIST_LOADING,{event:t}),n}assignAssetListError(t,e,s,i,r,n){return t.error=s,{type:a.NETWORK_ERROR,details:e,fatal:!1,interstitial:t,url:i,error:s,networkDetails:n,stats:r}}}function va(t){var e;null==t||null==(e=t.play())||e.catch(()=>{})}function ba(t,e){return`[${t}] Advancing timeline position to ${e}`}class _a{constructor(t){this.buffered=void 0;const e=(e,s,i)=>{if((s>>>=0)>i-1)throw new DOMException(`Failed to execute '${e}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${i})`);return t[s][e]};this.buffered={get length(){return t.length},end:s=>e("end",s,t.length),start:s=>e("start",s,t.length)}}}const Ta={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},Aa=t=>String.fromCharCode(Ta[t]||t),Ea=15,Sa=100,Ca={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},ka={17:2,18:4,21:6,22:8,23:10,19:13,20:15},wa={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},La={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Ia=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Pa{constructor(){this.time=null,this.verboseLevel=0}log(t,e){if(this.verboseLevel>=t){const s="function"==typeof e?e():e;L.log(`${this.time} [${t}] ${s}`)}}}const xa=function(t){const e=[];for(let s=0;s<t.length;s++)e.push(t[s].toString(16));return e};class Ra{constructor(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}reset(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1}setStyles(t){const e=["foreground","underline","italics","background","flash"];for(let s=0;s<e.length;s++){const i=e[s];t.hasOwnProperty(i)&&(this[i]=t[i])}}isDefault(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash}equals(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash}copy(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class Da{constructor(){this.uchar=" ",this.penState=new Ra}reset(){this.uchar=" ",this.penState.reset()}setChar(t,e){this.uchar=t,this.penState.copy(e)}setPenState(t){this.penState.copy(t)}equals(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)}copy(t){this.uchar=t.uchar,this.penState.copy(t.penState)}isEmpty(){return" "===this.uchar&&this.penState.isDefault()}}class Oa{constructor(t){this.chars=[],this.pos=0,this.currPenState=new Ra,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Sa;t++)this.chars.push(new Da);this.logger=t}equals(t){for(let e=0;e<Sa;e++)if(!this.chars[e].equals(t.chars[e]))return!1;return!0}copy(t){for(let e=0;e<Sa;e++)this.chars[e].copy(t.chars[e])}isEmpty(){let t=!0;for(let e=0;e<Sa;e++)if(!this.chars[e].isEmpty()){t=!1;break}return t}setCursor(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>Sa&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Sa)}moveCursor(t){const e=this.pos+t;if(t>1)for(let t=this.pos+1;t<e+1;t++)this.chars[t].setPenState(this.currPenState);this.setCursor(e)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(t){t>=144&&this.backSpace();const e=Aa(t);this.pos>=Sa?this.logger.log(0,()=>"Cannot insert "+t.toString(16)+" ("+e+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(e,this.currPenState),this.moveCursor(1))}clearFromPos(t){let e;for(e=t;e<Sa;e++)this.chars[e].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const t=[];let e=!0;for(let s=0;s<Sa;s++){const i=this.chars[s].uchar;" "!==i&&(e=!1),t.push(i)}return e?"":t.join("")}setPenStyles(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)}}class Ma{constructor(t){this.rows=[],this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let e=0;e<Ea;e++)this.rows.push(new Oa(t));this.logger=t}reset(){for(let t=0;t<Ea;t++)this.rows[t].clear();this.currRow=14}equals(t){let e=!0;for(let s=0;s<Ea;s++)if(!this.rows[s].equals(t.rows[s])){e=!1;break}return e}copy(t){for(let e=0;e<Ea;e++)this.rows[e].copy(t.rows[e])}isEmpty(){let t=!0;for(let e=0;e<Ea;e++)if(!this.rows[e].isEmpty()){t=!1;break}return t}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(t){this.rows[this.currRow].insertChar(t)}setPen(t){this.rows[this.currRow].setPenStyles(t)}moveCursor(t){this.rows[this.currRow].moveCursor(t)}setCursor(t){this.logger.log(2,"setCursor: "+t),this.rows[this.currRow].setCursor(t)}setPAC(t){this.logger.log(2,()=>"pacData = "+zt(t));let e=t.row-1;if(this.nrRollUpRows&&e<this.nrRollUpRows-1&&(e=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==e){for(let t=0;t<Ea;t++)this.rows[t].clear();const t=this.currRow+1-this.nrRollUpRows,s=this.lastOutputScreen;if(s){const i=s.rows[t].cueStartTime,r=this.logger.time;if(null!==i&&null!==r&&i<r)for(let i=0;i<this.nrRollUpRows;i++)this.rows[e-this.nrRollUpRows+i+1].copy(s.rows[t+i])}}this.currRow=e;const s=this.rows[this.currRow];if(null!==t.indent){const e=t.indent,i=Math.max(e-1,0);s.setCursor(t.indent),t.color=s.chars[i].penState.foreground}const i={foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1};this.setPen(i)}setBkgData(t){this.logger.log(2,()=>"bkgData = "+zt(t)),this.backSpace(),this.setPen(t),this.insertChar(32)}setRollUpRows(t){this.nrRollUpRows=t}rollUp(){if(null===this.nrRollUpRows)return void this.logger.log(3,"roll_up but nrRollUpRows not set yet");this.logger.log(1,()=>this.getDisplayText());const t=this.currRow+1-this.nrRollUpRows,e=this.rows.splice(t,1)[0];e.clear(),this.rows.splice(this.currRow,0,e),this.logger.log(2,"Rolling up")}getDisplayText(t){t=t||!1;const e=[];let s="",i=-1;for(let s=0;s<Ea;s++){const r=this.rows[s].getTextString();r&&(i=s+1,t?e.push("Row "+i+": '"+r+"'"):e.push(r.trim()))}return e.length>0&&(s=t?"["+e.join(" | ")+"]":e.join("\n")),s}getTextAndFormat(){return this.rows}}class Fa{constructor(t,e,s){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new Ma(s),this.nonDisplayedMemory=new Ma(s),this.lastOutputScreen=new Ma(s),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=s}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(t){this.outputFilter=t}setPAC(t){this.writeScreen.setPAC(t)}setBkgData(t){this.writeScreen.setBkgData(t)}setMode(t){t!==this.mode&&(this.mode=t,this.logger.log(2,()=>"MODE="+t),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)}insertChars(t){for(let e=0;e<t.length;e++)this.writeScreen.insertChar(t[e]);const e=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>e+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(1,()=>"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())}ccRCL(){this.logger.log(2,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")}ccBS(){this.logger.log(2,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())}ccAOF(){}ccAON(){}ccDER(){this.logger.log(2,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()}ccRU(t){this.logger.log(2,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)}ccFON(){this.logger.log(2,"FON - Flash On"),this.writeScreen.setPen({flash:!0})}ccRDC(){this.logger.log(2,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")}ccTR(){this.logger.log(2,"TR"),this.setMode("MODE_TEXT")}ccRTD(){this.logger.log(2,"RTD"),this.setMode("MODE_TEXT")}ccEDM(){this.logger.log(2,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)}ccCR(){this.logger.log(2,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)}ccENM(){this.logger.log(2,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()}ccEOC(){if(this.logger.log(2,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){const t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(t){this.logger.log(2,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)}ccMIDROW(t){const e={flash:!1};if(e.underline=t%2==1,e.italics=t>=46,e.italics)e.foreground="white";else{const s=Math.floor(t/2)-16,i=["white","green","blue","cyan","red","yellow","magenta"];e.foreground=i[s]}this.logger.log(2,"MIDROW: "+zt(e)),this.writeScreen.setPen(e)}outputDataUpdate(t=!1){const e=this.logger.time;null!==e&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))}}class Na{constructor(t,e,s){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;const i=this.logger=new Pa;this.channels=[null,new Fa(t,e,i),new Fa(t+1,s,i)]}getHandler(t){return this.channels[t].getHandler()}setHandler(t,e){this.channels[t].setHandler(e)}addData(t,e){this.logger.time=t;for(let t=0;t<e.length;t+=2){const s=127&e[t],i=127&e[t+1];let r=!1,n=null;if(0===s&&0===i)continue;this.logger.log(3,()=>"["+xa([e[t],e[t+1]])+"] -> ("+xa([s,i])+")");const a=this.cmdHistory;if(s>=16&&s<=31){if(ja(s,i,a)){Ba(null,null,a),this.logger.log(3,()=>"Repeated command ("+xa([s,i])+") is dropped");continue}Ba(s,i,this.cmdHistory),r=this.parseCmd(s,i),r||(r=this.parseMidrow(s,i)),r||(r=this.parsePAC(s,i)),r||(r=this.parseBackgroundAttributes(s,i))}else Ba(null,null,a);if(!r&&(n=this.parseChars(s,i),n)){const t=this.currentChannel;t&&t>0?this.channels[t].insertChars(n):this.logger.log(2,"No channel found yet. TEXT-MODE?")}r||n||this.logger.log(2,()=>"Couldn't parse cleaned data "+xa([s,i])+" orig: "+xa([e[t],e[t+1]]))}}parseCmd(t,e){if(!((20===t||28===t||21===t||29===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=33&&e<=35))return!1;const s=20===t||21===t||23===t?1:2,i=this.channels[s];return 20===t||21===t||28===t||29===t?32===e?i.ccRCL():33===e?i.ccBS():34===e?i.ccAOF():35===e?i.ccAON():36===e?i.ccDER():37===e?i.ccRU(2):38===e?i.ccRU(3):39===e?i.ccRU(4):40===e?i.ccFON():41===e?i.ccRDC():42===e?i.ccTR():43===e?i.ccRTD():44===e?i.ccEDM():45===e?i.ccCR():46===e?i.ccENM():47===e&&i.ccEOC():i.ccTO(e-32),this.currentChannel=s,!0}parseMidrow(t,e){let s=0;if((17===t||25===t)&&e>=32&&e<=47){if(s=17===t?1:2,s!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const i=this.channels[s];return!!i&&(i.ccMIDROW(e),this.logger.log(3,()=>"MIDROW ("+xa([t,e])+")"),!0)}return!1}parsePAC(t,e){let s;if(!((t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127||(16===t||24===t)&&e>=64&&e<=95))return!1;const i=t<=23?1:2;s=e>=64&&e<=95?1===i?Ca[t]:wa[t]:1===i?ka[t]:La[t];const r=this.channels[i];return!!r&&(r.setPAC(this.interpretPAC(s,e)),this.currentChannel=i,!0)}interpretPAC(t,e){let s;const i={color:null,italics:!1,indent:null,underline:!1,row:t};return s=e>95?e-96:e-64,i.underline=!(1&~s),s<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(s/2)]:s<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((s-16)/2),i}parseChars(t,e){let s,i=null,r=null;if(t>=25?(s=2,r=t-8):(s=1,r=t),r>=17&&r<=19){let t;t=17===r?e+80:18===r?e+112:e+144,this.logger.log(2,()=>"Special char '"+Aa(t)+"' in channel "+s),i=[t]}else t>=32&&t<=127&&(i=0===e?[t]:[t,e]);return i&&this.logger.log(3,()=>"Char codes = "+xa(i).join(",")),i}parseBackgroundAttributes(t,e){if(!((16===t||24===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=45&&e<=47))return!1;let s;const i={};16===t||24===t?(s=Math.floor((e-32)/2),i.background=Ia[s],e%2==1&&(i.background=i.background+"_semi")):45===e?i.background="transparent":(i.foreground="black",47===e&&(i.underline=!0));const r=t<=23?1:2;return this.channels[r].setBkgData(i),!0}reset(){for(let t=0;t<Object.keys(this.channels).length;t++){const e=this.channels[t];e&&e.reset()}Ba(null,null,this.cmdHistory)}cueSplitAtTime(t){for(let e=0;e<this.channels.length;e++){const s=this.channels[e];s&&s.cueSplitAtTime(t)}}}function Ba(t,e,s){s.a=t,s.b=e}function ja(t,e,s){return s.a===t&&s.b===e}var $a=function(){if(null!=is&&is.VTTCue)return self.VTTCue;const t=["","lr","rl"],e=["start","middle","end","left","right"];function s(t,e){if("string"!=typeof e)return!1;if(!Array.isArray(t))return!1;const s=e.toLowerCase();return!!~t.indexOf(s)&&s}function i(t){return s(e,t)}function r(t,...e){let s=1;for(;s<arguments.length;s++){const e=arguments[s];for(const s in e)t[s]=e[s]}return t}function n(e,n,a){const o=this,l={enumerable:!0};o.hasBeenReset=!1;let h="",c=!1,d=e,u=n,p=a,f=null,g="",m=!0,y="auto",v="start",b=50,_="middle",T=50,A="middle";Object.defineProperty(o,"id",r({},l,{get:function(){return h},set:function(t){h=""+t}})),Object.defineProperty(o,"pauseOnExit",r({},l,{get:function(){return c},set:function(t){c=!!t}})),Object.defineProperty(o,"startTime",r({},l,{get:function(){return d},set:function(t){if("number"!=typeof t)throw new TypeError("Start time must be set to a number.");d=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",r({},l,{get:function(){return u},set:function(t){if("number"!=typeof t)throw new TypeError("End time must be set to a number.");u=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",r({},l,{get:function(){return p},set:function(t){p=""+t,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",r({},l,{get:function(){return f},set:function(t){f=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",r({},l,{get:function(){return g},set:function(e){const i=function(e){return s(t,e)}(e);if(!1===i)throw new SyntaxError("An invalid or illegal string was specified.");g=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",r({},l,{get:function(){return m},set:function(t){m=!!t,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",r({},l,{get:function(){return y},set:function(t){if("number"!=typeof t&&"auto"!==t)throw new SyntaxError("An invalid number or illegal string was specified.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",r({},l,{get:function(){return v},set:function(t){const e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");v=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",r({},l,{get:function(){return b},set:function(t){if(t<0||t>100)throw new Error("Position must be between 0 and 100.");b=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",r({},l,{get:function(){return _},set:function(t){const e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");_=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",r({},l,{get:function(){return T},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");T=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",r({},l,{get:function(){return A},set:function(t){const e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");A=e,this.hasBeenReset=!0}})),o.displayState=void 0}return n.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},n}();class Ua{decode(t,e){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}function Ha(t){function e(t,e,s,i){return 3600*(0|t)+60*(0|e)+(0|s)+parseFloat(i||0)}const s=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return s?parseFloat(s[2])>59?e(s[2],s[3],0,s[4]):e(s[1],s[2],s[3],s[4]):null}class Va{constructor(){this.values=Object.create(null)}set(t,e){this.get(t)||""===e||(this.values[t]=e)}get(t,e,s){return s?this.has(t)?this.values[t]:e[s]:this.has(t)?this.values[t]:e}has(t){return t in this.values}alt(t,e,s){for(let i=0;i<s.length;++i)if(e===s[i]){this.set(t,e);break}}integer(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))}percent(t,e){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(e)){const s=parseFloat(e);if(s>=0&&s<=100)return this.set(t,s),!0}return!1}}function Ga(t,e,s,i){const r=i?t.split(i):[t];for(const t in r){if("string"!=typeof r[t])continue;const i=r[t].split(s);2===i.length&&e(i[0],i[1])}}const Wa=new $a(0,0,""),Ka="middle"===Wa.align?"middle":"center";function za(t,e,s){const i=t;function r(){const e=Ha(t);if(null===e)throw new Error("Malformed timestamp: "+i);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function n(){t=t.replace(/^\s+/,"")}if(n(),e.startTime=r(),n(),"--\x3e"!==t.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);t=t.slice(3),n(),e.endTime=r(),n(),function(t,e){const i=new Va;Ga(t,function(t,e){let r;switch(t){case"region":for(let r=s.length-1;r>=0;r--)if(s[r].id===e){i.set(t,s[r].region);break}break;case"vertical":i.alt(t,e,["rl","lr"]);break;case"line":r=e.split(","),i.integer(t,r[0]),i.percent(t,r[0])&&i.set("snapToLines",!1),i.alt(t,r[0],["auto"]),2===r.length&&i.alt("lineAlign",r[1],["start",Ka,"end"]);break;case"position":r=e.split(","),i.percent(t,r[0]),2===r.length&&i.alt("positionAlign",r[1],["start",Ka,"end","line-left","line-right","auto"]);break;case"size":i.percent(t,e);break;case"align":i.alt(t,e,["start",Ka,"end","left","right"])}},/:/,/\s/),e.region=i.get("region",null),e.vertical=i.get("vertical","");let r=i.get("line","auto");"auto"===r&&-1===Wa.line&&(r=-1),e.line=r,e.lineAlign=i.get("lineAlign","start"),e.snapToLines=i.get("snapToLines",!0),e.size=i.get("size",100),e.align=i.get("align",Ka);let n=i.get("position","auto");"auto"===n&&50===Wa.position&&(n="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=n}(t,e)}function qa(t){return t.replace(/<br(?: \/)?>/gi,"\n")}class Ya{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Ua,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(t){const e=this;function s(){let t=e.buffer,s=0;for(t=qa(t);s<t.length&&"\r"!==t[s]&&"\n"!==t[s];)++s;const i=t.slice(0,s);return"\r"===t[s]&&++s,"\n"===t[s]&&++s,e.buffer=t.slice(s),i}function i(t){Ga(t,function(t,e){},/:/)}t&&(e.buffer+=e.decoder.decode(t,{stream:!0}));try{let t="";if("INITIAL"===e.state){if(!/\r\n|\n/.test(e.buffer))return this;t=s();const i=t.match(/^()?WEBVTT([ \t].*)?$/);if(null==i||!i[0])throw new Error("Malformed WebVTT signature.");e.state="HEADER"}let r=!1;for(;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(r?r=!1:t=s(),e.state){case"HEADER":/:/.test(t)?i(t):t||(e.state="ID");continue;case"NOTE":t||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(t)){e.state="NOTE";break}if(!t)continue;if(e.cue=new $a(0,0,""),e.state="CUE",-1===t.indexOf("--\x3e")){e.cue.id=t;continue}case"CUE":if(!e.cue){e.state="BADCUE";continue}try{za(t,e.cue,e.regionList)}catch(t){e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":{const s=-1!==t.indexOf("--\x3e");if(!t||s&&(r=!0)){e.oncue&&e.cue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}if(null===e.cue)continue;e.cue.text&&(e.cue.text+="\n"),e.cue.text+=t}continue;case"BADCUE":t||(e.state="ID")}}}catch(t){"CUETEXT"===e.state&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state="INITIAL"===e.state?"BADWEBVTT":"BADCUE"}return this}flush(){const t=this;try{if((t.cue||"HEADER"===t.state)&&(t.buffer+="\n\n",t.parse()),"INITIAL"===t.state||"BADWEBVTT"===t.state)throw new Error("Malformed WebVTT signature.")}catch(e){t.onparsingerror&&t.onparsingerror(e)}return t.onflush&&t.onflush(),this}}const Xa=/\r\n|\n\r|\n|\r/g,Qa=function(t,e,s=0){return t.slice(s,s+e.length)===e};function Za(t,e,s){return na(t.toString())+na(e.toString())+na(s)}const Ja="stpp.ttml.im1t",to=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,eo=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,so={left:"start",center:"center",right:"end",start:"start",end:"end"};function io(t,e,s,i){const r=et(new Uint8Array(t),["mdat"]);if(0===r.length)return void i(new Error("Could not parse IMSC1 mdat"));const n=r.map(t=>x(t)),a=function(t,e,s=1,i=!1){return Tr(t,e,1/s,i)}(e.baseTime,1,e.timescale);try{n.forEach(t=>s(function(t,e){const s=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");const i={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},r=Object.keys(i).reduce((t,e)=>(t[e]=s.getAttribute(`ttp:${e}`)||i[e],t),{}),n="preserve"!==s.getAttribute("xml:space"),a=no(ro(s,"styling","style")),o=no(ro(s,"layout","region")),l=ro(s,"body","[begin]");return[].map.call(l,t=>{const s=ao(t,n);if(!s||!t.hasAttribute("begin"))return null;const i=ho(t.getAttribute("begin"),r),l=ho(t.getAttribute("dur"),r);let h=ho(t.getAttribute("end"),r);if(null===i)throw lo(t);if(null===h){if(null===l)throw lo(t);h=i+l}const c=new $a(i-e,h-e,s);c.id=Za(c.startTime,c.endTime,c.text);const d=function(t,e,s){const i="http://www.w3.org/ns/ttml#styling";let r=null;const n=null!=t&&t.hasAttribute("style")?t.getAttribute("style"):null;return n&&s.hasOwnProperty(n)&&(r=s[n]),["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((s,n)=>{const a=oo(e,i,n)||oo(t,i,n)||oo(r,i,n);return a&&(s[n]=a),s},{})}(o[t.getAttribute("region")],a[t.getAttribute("style")],a),{textAlign:u}=d;if(u){const t=so[u];t&&(c.lineAlign=t),c.align=u}return b(c,d),c}).filter(t=>null!==t)}(t,a)))}catch(t){i(t)}}function ro(t,e,s){const i=t.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(s)):[]}function no(t){return t.reduce((t,e)=>{const s=e.getAttribute("xml:id");return s&&(t[s]=e),t},{})}function ao(t,e){return[].slice.call(t.childNodes).reduce((t,s,i)=>{var r;return"br"===s.nodeName&&i?t+"\n":null!=(r=s.childNodes)&&r.length?ao(s,e):e?t+s.textContent.trim().replace(/\s+/g," "):t+s.textContent},"")}function oo(t,e,s){return t&&t.hasAttributeNS(e,s)?t.getAttributeNS(e,s):null}function lo(t){return new Error(`Could not parse ttml timestamp ${t}`)}function ho(t,e){if(!t)return null;let s=Ha(t);return null===s&&(to.test(t)?s=function(t,e){const s=to.exec(t),i=(0|s[4])+(0|s[5])/e.subFrameRate;return 3600*(0|s[1])+60*(0|s[2])+(0|s[3])+i/e.frameRate}(t,e):eo.test(t)&&(s=function(t,e){const s=eo.exec(t),i=Number(s[1]);switch(s[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}(t,e))),s}class co{constructor(t,e){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=e}dispatchCue(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(t,e,s){(null===this.startTime||this.startTime>t)&&(this.startTime=t),this.endTime=e,this.screen=s,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}function uo(t){return t.characteristics&&/transcribes-spoken-dialog/gi.test(t.characteristics)&&/describes-music-and-sound/gi.test(t.characteristics)?"captions":"subtitles"}function po(t,e){return!!t&&t.kind===uo(e)&&Wr(e,t)}function fo(t,e,s,i){return Math.min(e,i)-Math.max(t,s)}const go=/\s/,mo={newCue(t,e,s,i){const r=[];let n,a,o,l,h;const c=self.VTTCue||self.TextTrackCue;for(let u=0;u<i.rows.length;u++)if(n=i.rows[u],o=!0,l=0,h="",!n.isEmpty()){var d;for(let t=0;t<n.chars.length;t++)go.test(n.chars[t].uchar)&&o?l++:(h+=n.chars[t].uchar,o=!1);n.cueStartTime=e,e===s&&(s+=1e-4),l>=16?l--:l++;const i=qa(h.trim()),p=Za(e,s,i);null!=t&&null!=(d=t.cues)&&d.getCueById(p)||(a=new c(e,s,i),a.id=p,a.line=u+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*l/32)),r.push(a))}return t&&r.length&&(r.sort((t,e)=>"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line),r.forEach(e=>ea(t,e))),r}},yo=/(\d+)-(\d+)\/(\d+)/;class vo{constructor(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||bo,this.controller=new self.AbortController,this.stats=new B}destroy(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null}abortInternal(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())}abort(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(t,e,s){const r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();const n=function(t,e){const s={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(b({},t.headers))};return t.rangeEnd&&s.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),s}(t,this.controller.signal),a="arraybuffer"===t.responseType,o=a?"byteLength":"length",{maxTimeToFirstByteMs:l,maxLoadTimeMs:h}=e.loadPolicy;this.context=t,this.config=e,this.callbacks=s,this.request=this.fetchSetup(t,n),self.clearTimeout(this.requestTimeout),e.timeout=l&&i(l)?l:h,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,t,this.response))},e.timeout),(Nr(this.request)?this.request.then(self.fetch):self.fetch(this.request)).then(s=>{var n;this.response=this.loader=s;const o=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),e.timeout=h,this.requestTimeout=self.setTimeout(()=>{this.callbacks&&(this.abortInternal(),this.callbacks.onTimeout(r,t,this.response))},h-(o-r.loading.start)),!s.ok){const{status:t,statusText:e}=s;throw new _o(e||"fetch, bad network response",t,s)}r.loading.first=o,r.total=function(t){const e=t.get("Content-Range");if(e){const t=function(t){const e=yo.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}(e);if(i(t))return t}const s=t.get("Content-Length");if(s)return parseInt(s)}(s.headers)||r.total;const l=null==(n=this.callbacks)?void 0:n.onProgress;return l&&i(e.highWaterMark)?this.loadProgressively(s,r,t,e.highWaterMark,l):a?s.arrayBuffer():"json"===t.responseType?s.json():s.text()}).then(s=>{var n,a;const l=this.response;if(!l)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);const h=s[o];h&&(r.loaded=r.total=h);const c={url:l.url,data:s,code:l.status},d=null==(n=this.callbacks)?void 0:n.onProgress;d&&!i(e.highWaterMark)&&d(r,t,s,l),null==(a=this.callbacks)||a.onSuccess(c,r,t,l)}).catch(e=>{var s;if(self.clearTimeout(this.requestTimeout),r.aborted)return;const i=e&&e.code||0,n=e?e.message:null;null==(s=this.callbacks)||s.onError({code:i,text:n},t,e?e.details:null,r)})}getCacheAge(){let t=null;if(this.response){const e=this.response.headers.get("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.response?this.response.headers.get(t):null}loadProgressively(t,e,s,i=0,r){const n=new fi,a=t.body.getReader(),o=()=>a.read().then(a=>{if(a.done)return n.dataLength&&r(e,s,n.flush().buffer,t),Promise.resolve(new ArrayBuffer(0));const l=a.value,h=l.length;return e.loaded+=h,h<i||n.dataLength?(n.push(l),n.dataLength>=i&&r(e,s,n.flush().buffer,t)):r(e,s,l.buffer,t),o()}).catch(()=>Promise.reject());return o()}}function bo(t,e){return new self.Request(t.url,e)}class _o extends Error{constructor(t,e,s){super(t),this.code=void 0,this.details=void 0,this.code=e,this.details=s}}const To=/^age:\s*[\d.]+\s*$/im;class Ao{constructor(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=null,this.loader=null,this.stats=void 0,this.xhrSetup=t&&t.xhrSetup||null,this.stats=new B,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))}abort(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(t,e,s){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=e,this.callbacks=s,this.loadInternal()}loadInternal(){const{config:t,context:e}=this;if(!t||!e)return;const s=this.loader=new self.XMLHttpRequest,i=this.stats;i.loading.first=0,i.loaded=0,i.aborted=!1;const r=this.xhrSetup;r?Promise.resolve().then(()=>{if(this.loader===s&&!this.stats.aborted)return r(s,e.url)}).catch(t=>{if(this.loader===s&&!this.stats.aborted)return s.open("GET",e.url,!0),r(s,e.url)}).then(()=>{this.loader!==s||this.stats.aborted||this.openAndSendXhr(s,e,t)}).catch(t=>{var r;null==(r=this.callbacks)||r.onError({code:s.status,text:t.message},e,s,i)}):this.openAndSendXhr(s,e,t)}openAndSendXhr(t,e,s){t.readyState||t.open("GET",e.url,!0);const r=e.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=s.loadPolicy;if(r)for(const e in r)t.setRequestHeader(e,r[e]);e.rangeEnd&&t.setRequestHeader("Range","bytes="+e.rangeStart+"-"+(e.rangeEnd-1)),t.onreadystatechange=this.readystatechange.bind(this),t.onprogress=this.loadprogress.bind(this),t.responseType=e.responseType,self.clearTimeout(this.requestTimeout),s.timeout=n&&i(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout),t.send()}readystatechange(){const{context:t,loader:e,stats:s}=this;if(!t||!e)return;const i=e.readyState,r=this.config;if(!s.aborted&&i>=2&&(0===s.loading.first&&(s.loading.first=Math.max(self.performance.now(),s.loading.start),r.timeout!==r.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),r.timeout=r.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.loadPolicy.maxLoadTimeMs-(s.loading.first-s.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;const i=e.status,l="text"===e.responseType?e.responseText:null;if(i>=200&&i<300){const r=null!=l?l:e.response;if(null!=r){var n,a;s.loading.end=Math.max(self.performance.now(),s.loading.first);const o="arraybuffer"===e.responseType?r.byteLength:r.length;s.loaded=s.total=o,s.bwEstimate=8e3*s.total/(s.loading.end-s.loading.first);const l=null==(n=this.callbacks)?void 0:n.onProgress;l&&l(s,t,r,e);const h={url:e.responseURL,data:r,code:i};return void(null==(a=this.callbacks)||a.onSuccess(h,s,t,e))}}const h=r.loadPolicy.errorRetry;var o;pe(h,s.retry,!1,{url:t.url,data:void 0,code:i})?this.retry(h):(L.error(`${i} while loading ${t.url}`),null==(o=this.callbacks)||o.onError({code:i,text:e.statusText},t,e,s))}}loadtimeout(){if(!this.config)return;const t=this.config.loadPolicy.timeoutRetry;if(pe(t,this.stats.retry,!0))this.retry(t);else{var e;L.warn(`timeout while loading ${null==(e=this.context)?void 0:e.url}`);const t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))}}retry(t){const{context:e,stats:s}=this;this.retryDelay=de(t,s.retry),s.retry++,L.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${null==e?void 0:e.url}, retrying ${s.retry}/${t.maxNumRetry} in ${this.retryDelay}ms`),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)}loadprogress(t){const e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)}getCacheAge(){let t=null;if(this.loader&&To.test(this.loader.getAllResponseHeaders())){const e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t}getResponseHeader(t){return this.loader&&new RegExp(`^${t}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null}}const Eo=T(T({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,maxDevicePixelRatio:Number.POSITIVE_INFINITY,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,startOnSegmentBoundary:!1,maxBufferSize:6e7,maxFragLookUpTolerance:.25,maxBufferHole:.1,detectStallWithCurrentTimeMs:1250,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,nudgeOnVideoHole:!0,liveSyncMode:"edge",liveSyncDurationCount:3,liveSyncOnStallIncrease:1,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,ignorePlaylistParsingErrors:!1,loader:Ao,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:class extends A{constructor(t){super("abr",t.logger),this.hls=void 0,this.lastLevelLoadSec=0,this.lastLoadedFragLevel=-1,this.firstSelection=-1,this._nextAutoLevel=-1,this.nextAutoLevelKey="",this.audioTracksByGroup=null,this.codecTiers=null,this.timer=-1,this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.rebufferNotice=-1,this.supportedCache={},this.bwEstimator=void 0,this._abandonRulesCheck=t=>{var e;const{fragCurrent:s,partCurrent:r,hls:n}=this,{autoLevelEnabled:a,media:o}=n;if(!s||!o)return;const h=performance.now(),c=r?r.stats:s.stats,d=r?r.duration:s.duration,u=h-c.loading.start,p=n.minAutoLevel,f=s.level,g=this._nextAutoLevel;if(c.aborted||c.loaded&&c.loaded===c.total||f<=p)return this.clearTimer(),void(this._nextAutoLevel=-1);if(!a)return;const m=g>-1&&g!==f,y=!!t||m;if(!y&&(o.paused||!o.playbackRate||!o.readyState))return;const v=n.mainForwardBufferInfo;if(!y&&null===v)return;const b=this.bwEstimator.getEstimateTTFB(),_=Math.abs(o.playbackRate);if(u<=Math.max(b,d/(2*_)*1e3))return;const T=v?v.len/_:0,A=c.loading.first?c.loading.first-c.loading.start:-1,E=c.loaded&&A>-1,S=this.getBwEstimate(),C=n.levels,k=C[f],w=Math.max(c.loaded,Math.round(d*(s.bitrate||k.averageBitrate)/8));let L=E?u-A:u;L<1&&E&&(L=Math.min(u,8*c.loaded/S));const I=E?1e3*c.loaded/L:0,P=b/1e3,x=I?(w-c.loaded)/I:8*w/S+P;if(x<=T)return;const R=I?8*I:S,D=!0===(null==(e=(null==t?void 0:t.details)||this.hls.latestLevelDetails)?void 0:e.live),O=this.hls.config.abrBandWidthUpFactor;let M,F=Number.POSITIVE_INFINITY;for(M=f-1;M>p;M--){const t=C[M].maxBitrate,e=!C[M].details||D;if(F=this.getTimeToLoadFrag(P,R,d*t,e),F<Math.min(T,d+P))break}if(F>=x)return;if(F>10*d)return;E?this.bwEstimator.sample(u-Math.min(b,A),c.loaded):this.bwEstimator.sampleTTFB(u);const N=C[M].maxBitrate;this.getBwEstimate()*O>N&&this.resetEstimator(N);const B=this.findBestLevel(N,p,M,0,T,1,1);B>-1&&(M=B),this.warn(`Fragment ${s.sn}${r?" part "+r.index:""} of level ${f} is loading too slowly;\n Fragment duration: ${s.duration.toFixed(3)}\n Time to underbuffer: ${T.toFixed(3)} s\n Estimated load time for current fragment: ${x.toFixed(3)} s\n Estimated load time for down switch fragment: ${F.toFixed(3)} s\n TTFB estimate: ${0|A} ms\n Current BW estimate: ${i(S)?0|S:"Unknown"} bps\n New BW estimate: ${0|this.getBwEstimate()} bps\n Switching to level ${M} @ ${0|N} bps`),n.nextLoadLevel=n.nextAutoLevel=M,this.clearTimer();const j=()=>{if(this.clearTimer(),this.fragCurrent===s&&this.hls.loadLevel===M&&M>0){const t=this.getStarvationDelay();if(this.warn(`Aborting inflight request ${M>0?"and switching down":""}\n Fragment duration: ${s.duration.toFixed(3)} s\n Time to underbuffer: ${t.toFixed(3)} s`),s.abortRequests(),this.fragCurrent=this.partCurrent=null,M>p){let e=this.findBestLevel(this.hls.levels[p].bitrate,p,M,0,t,1,1);-1===e&&(e=p),this.hls.nextLoadLevel=this.hls.nextAutoLevel=e,this.resetEstimator(this.hls.levels[e].bitrate)}}};m||x>2*F?j():this.timer=self.setInterval(j,1e3*F),n.trigger(l.FRAG_LOAD_EMERGENCY_ABORTED,{frag:s,part:r,stats:c})},this.hls=t,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(t){t&&(this.log(`setting initial bwe to ${t}`),this.hls.config.abrEwmaDefaultEstimate=t),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const t=this.hls.config;return new y(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate)}registerListeners(){const{hls:t}=this;t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.FRAG_LOADING,this.onFragLoading,this),t.on(l.FRAG_LOADED,this.onFragLoaded,this),t.on(l.FRAG_BUFFERED,this.onFragBuffered,this),t.on(l.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(l.LEVEL_LOADED,this.onLevelLoaded,this),t.on(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(l.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.on(l.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t&&(t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.FRAG_LOADING,this.onFragLoading,this),t.off(l.FRAG_LOADED,this.onFragLoaded,this),t.off(l.FRAG_BUFFERED,this.onFragBuffered,this),t.off(l.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(l.LEVEL_LOADED,this.onLevelLoaded,this),t.off(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(l.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.off(l.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=this.supportedCache=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(t,e){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.supportedCache={},this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()}onLevelsUpdated(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null}onMaxAutoLevelUpdated(){this.firstSelection=-1,this.nextAutoLevelKey=""}onFragLoading(t,e){const s=e.frag;var i;this.ignoreFragment(s)||(s.bitrateTest||(this.fragCurrent=s,this.partCurrent=null!=(i=e.part)?i:null),this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100))}onLevelSwitching(t,e){this.clearTimer()}onError(t,e){if(!e.fatal)switch(e.details){case o.BUFFER_ADD_CODEC_ERROR:case o.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case o.FRAG_LOAD_TIMEOUT:{const t=e.frag,{fragCurrent:s,partCurrent:i}=this;if(t&&s&&t.sn===s.sn&&t.level===s.level){const e=performance.now(),s=i?i.stats:t.stats,r=e-s.loading.start,n=s.loading.first?s.loading.first-s.loading.start:-1;if(s.loaded&&n>-1){const t=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(r-Math.min(t,n),s.loaded)}else this.bwEstimator.sampleTTFB(r)}break}}}getTimeToLoadFrag(t,e,s,i){return t+s/e+(i?t+this.lastLevelLoadSec:0)}onLevelLoaded(t,e){const s=this.hls.config,{loading:r}=e.stats,n=r.end-r.first;i(n)&&(this.lastLevelLoadSec=n/1e3),e.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD),this.timer>-1&&this._abandonRulesCheck(e.levelInfo)}onFragLoaded(t,{frag:e,part:s}){const i=s?s.stats:e.stats;if(e.type===p&&this.bwEstimator.sampleTTFB(i.loading.first-i.loading.start),!this.ignoreFragment(e)){if(this.clearTimer(),e.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const t=s?s.duration:e.duration,r=this.hls.levels[e.level],n=(r.loaded?r.loaded.bytes:0)+i.loaded,a=(r.loaded?r.loaded.duration:0)+t;r.loaded={bytes:n,duration:a},r.realBitrate=Math.round(8*n/a)}if(e.bitrateTest){const t={stats:i,frag:e,part:s,id:e.type};this.onFragBuffered(l.FRAG_BUFFERED,t),e.bitrateTest=!1}else this.lastLoadedFragLevel=e.level}}onFragBuffered(t,e){const{frag:s,part:i}=e,r=null!=i&&i.stats.loaded?i.stats:s.stats;if(r.aborted)return;if(this.ignoreFragment(s))return;const n=r.parsing.end-r.loading.start-Math.min(r.loading.first-r.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(n,r.loaded),r.bwEstimate=this.getBwEstimate(),s.bitrateTest?this.bitrateTestDelay=n/1e3:this.bitrateTestDelay=0}ignoreFragment(t){return t.type!==p||"initSegment"===t.sn}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:t,minAutoLevel:e}=this.hls,s=this.getBwEstimate(),i=this.hls.config.maxStarvationDelay,r=this.findBestLevel(s,e,t,0,i,1,1);if(r>-1)return r;const n=this.hls.firstLevel,a=Math.min(Math.max(n,e),t);return this.warn(`Could not find best starting auto level. Defaulting to first in playlist ${n} clamped to ${a}`),a}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const t=this.forcedAutoLevel,e=this.bwEstimator.canEstimate(),s=this.lastLoadedFragLevel>-1;if(!(-1===t||e&&s&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return t;const i=e&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==t){const e=this.hls.levels;if(e.length>Math.max(t,i)&&e[t].loadError<=e[i].loadError)return t}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:t,partCurrent:e,hls:s}=this;if(s.levels.length<=1)return s.loadLevel;const{maxAutoLevel:i,config:r,minAutoLevel:n}=s,a=e?e.duration:t?t.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay();let h=r.abrBandWidthFactor,c=r.abrBandWidthUpFactor;if(l){const t=this.findBestLevel(o,n,i,l,0,h,c);if(t>=0)return this.rebufferNotice=-1,t}let d=a?Math.min(a,r.maxStarvationDelay):r.maxStarvationDelay;if(!l){const t=this.bitrateTestDelay;t&&(d=(a?Math.min(a,r.maxLoadingDelay):r.maxLoadingDelay)-t,this.info(`bitrate test took ${Math.round(1e3*t)}ms, set first fragment max fetchDuration to ${Math.round(1e3*d)} ms`),h=c=1)}const u=this.findBestLevel(o,n,i,l,d,h,c);if(this.rebufferNotice!==u&&(this.rebufferNotice=u,this.info(`${l?"rebuffering expected":"buffer is empty"}, optimal quality level ${u}`)),u>-1)return u;const p=s.levels[n],f=s.loadLevelObj;return f&&(null==p?void 0:p.bitrate)<f.bitrate?n:s.loadLevel}getStarvationDelay(){const t=this.hls,e=t.media;if(!e)return 1/0;const s=e&&0!==e.playbackRate?Math.abs(e.playbackRate):1,i=t.mainForwardBufferInfo;return(i?i.len:0)/s}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(t,e,s,r,n,a,o){var l;const h=r+n,c=this.lastLoadedFragLevel,d=-1===c?this.hls.firstLevel:c,{fragCurrent:u,partCurrent:p}=this,{levels:f,allAudioTracks:g,loadLevel:m,config:y}=this.hls;if(1===f.length)return 0;const v=f[d],b=!(null==(l=this.hls.latestLevelDetails)||!l.live),_=-1===m||-1===c;let T,A="SDR",E=(null==v?void 0:v.frameRate)||0;const{audioPreference:S,videoPreference:C}=y,k=this.audioTracksByGroup||(this.audioTracksByGroup=Yt(g));let w=-1;if(_){if(-1!==this.firstSelection)return this.firstSelection;const r=this.codecTiers||(this.codecTiers=function(t,e,s,i){return t.slice(s,i+1).reduce((t,s,i)=>{if(!s.codecSet)return t;const r=s.audioGroups;let n=t[s.codecSet];n||(t[s.codecSet]=n={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,minIndex:i,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!r,fragmentError:0}),n.minBitrate=Math.min(n.minBitrate,s.bitrate);const a=Math.min(s.height,s.width);return n.minHeight=Math.min(n.minHeight,a),n.minFramerate=Math.min(n.minFramerate,s.frameRate),n.minIndex=Math.min(n.minIndex,i),n.maxScore=Math.max(n.maxScore,s.score),n.fragmentError+=s.fragmentError,n.videoRanges[s.videoRange]=(n.videoRanges[s.videoRange]||0)+1,r&&r.forEach(t=>{if(!t)return;const s=e.groups[t];s&&(n.hasDefaultAudio=n.hasDefaultAudio||e.hasDefaultAudio?s.hasDefault:s.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(s.channels).forEach(t=>{n.channels[t]=(n.channels[t]||0)+s.channels[t]}))}),t},{})}(f,k,e,s)),n=function(t,e,s,r,n){const a=Object.keys(t),o=null==r?void 0:r.channels,l=null==r?void 0:r.audioCodec,h=null==n?void 0:n.videoCodec,c=o&&2===parseInt(o);let d=!1,u=!1,p=1/0,f=1/0,g=1/0,m=1/0,y=0,v=[];const{preferHDR:b,allowedVideoRanges:_}=function(t,e){let s=!1,i=[];if(t&&(s="SDR"!==t,i=[t]),e){i=e.allowedVideoRanges||Ht.slice(0);const t="SDR"!==i.join("")&&!e.videoCodec;s=void 0!==e.preferHDR?e.preferHDR:t&&function(){if("function"==typeof matchMedia){const t=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(t.media!==e.media)return!0===t.matches}return!1}(),s||(i=["SDR"])}return{preferHDR:s,allowedVideoRanges:i}}(e,n);for(let e=a.length;e--;){const s=t[a[e]];d||(d=s.channels[2]>0),p=Math.min(p,s.minHeight),f=Math.min(f,s.minFramerate),g=Math.min(g,s.minBitrate),_.filter(t=>s.videoRanges[t]>0).length>0&&(u=!0)}p=i(p)?p:0,f=i(f)?f:0;const T=Math.max(1080,p),A=Math.max(30,f);g=i(g)?g:s,s=Math.max(g,s),u||(e=void 0);const E=a.length>1;return{codecSet:a.reduce((e,i)=>{const r=t[i];if(i===e)return e;if(v=u?_.filter(t=>r.videoRanges[t]>0):[],E){if(r.minBitrate>s)return qt(i,`min bitrate of ${r.minBitrate} > current estimate of ${s}`),e;if(!r.hasDefaultAudio)return qt(i,"no renditions with default or auto-select sound found"),e;if(l&&i.indexOf(l.substring(0,4))%5!=0)return qt(i,`audio codec preference "${l}" not found`),e;if(o&&!c){if(!r.channels[o])return qt(i,`no renditions with ${o} channel sound found (channels options: ${Object.keys(r.channels)})`),e}else if((!l||c)&&d&&0===r.channels[2])return qt(i,"no renditions with stereo sound found"),e;if(r.minHeight>T)return qt(i,`min resolution of ${r.minHeight} > maximum of ${T}`),e;if(r.minFramerate>A)return qt(i,`min framerate of ${r.minFramerate} > maximum of ${A}`),e;if(!v.some(t=>r.videoRanges[t]>0))return qt(i,`no variants with VIDEO-RANGE of ${zt(v)} found`),e;if(h&&i.indexOf(h.substring(0,4))%5!=0)return qt(i,`video codec preference "${h}" not found`),e;if(r.maxScore<y)return qt(i,`max score of ${r.maxScore} < selected max of ${y}`),e}return e&&(Ct(i)>=Ct(e)||r.fragmentError>t[e].fragmentError)?e:(m=r.minIndex,y=r.maxScore,i)},void 0),videoRanges:v,preferHDR:b,minFramerate:f,minBitrate:g,minIndex:m}}(r,A,t,S,C),{codecSet:a,videoRanges:o,minFramerate:l,minBitrate:h,minIndex:c,preferHDR:d}=n;w=c,T=a,A=d?o[o.length-1]:o[0],E=l,t=Math.max(t,h),this.log(`picked start tier ${zt(n)}`)}else T=null==v?void 0:v.codecSet,A=null==v?void 0:v.videoRange;const L=p?p.duration:u?u.duration:0,I=this.bwEstimator.getEstimateTTFB()/1e3,P=[];for(let l=s;l>=e;l--){var x;const e=f[l],u=l>d;if(!e)continue;if(y.useMediaCapabilities&&!e.supportedResult&&!e.supportedPromise){const s=navigator.mediaCapabilities;"function"==typeof(null==s?void 0:s.decodingInfo)&&Nt(e,k,A,E,t,S)?(e.supportedPromise=Bt(e,k,s,this.supportedCache),e.supportedPromise.then(t=>{if(!this.hls)return;e.supportedResult=t;const s=this.hls.levels,i=s.indexOf(e);t.error?this.warn(`MediaCapabilities decodingInfo error: "${t.error}" for level ${i} ${zt(t)}`):t.supported?t.decodingInfoResults.some(t=>!1===t.smooth||!1===t.powerEfficient)&&this.log(`MediaCapabilities decodingInfo for level ${i} not smooth or powerEfficient: ${zt(t)}`):(this.warn(`Unsupported MediaCapabilities decodingInfo result for level ${i} ${zt(t)}`),i>-1&&s.length>1&&(this.log(`Removing unsupported level ${i}`),this.hls.removeLevel(i),-1===this.hls.loadLevel&&(this.hls.nextLoadLevel=0)))}).catch(t=>{this.warn(`Error handling MediaCapabilities decodingInfo: ${t}`)})):e.supportedResult=Mt}if((T&&e.codecSet!==T||A&&e.videoRange!==A||u&&E>e.frameRate||!u&&E>0&&E<e.frameRate||null!=(x=e.supportedResult)&&null!=(x=x.decodingInfoResults)&&x.some(t=>!1===t.smooth))&&(!_||l!==w)){P.push(l);continue}const g=e.details,v=(p?null==g?void 0:g.partTarget:null==g?void 0:g.averagetargetduration)||L;let C;C=u?o*t:a*t;const R=L&&r>=2*L&&0===n?e.averageBitrate:e.maxBitrate,D=this.getTimeToLoadFrag(I,C,R*v,void 0===g);if(C>=R&&(l===c||0===e.loadError&&0===e.fragmentError)&&(D<=I||!i(D)||b&&!this.bitrateTestDelay||D<h)){const t=this.forcedAutoLevel;return l===m||-1!==t&&t===m||(P.length&&this.trace(`Skipped level(s) ${P.join(",")} of ${s} max with CODECS and VIDEO-RANGE:"${f[P[0]].codecs}" ${f[P[0]].videoRange}; not compatible with "${T}" ${A}`),this.info(`switch candidate:${d}->${l} adjustedbw(${Math.round(C)})-bitrate=${Math.round(C-R)} ttfb:${I.toFixed(1)} avgDuration:${v.toFixed(1)} maxFetchDuration:${h.toFixed(1)} fetchDuration:${D.toFixed(1)} firstSelection:${_} codecSet:${e.codecSet} videoRange:${e.videoRange} hls.loadLevel:${m}`)),_&&(this.firstSelection=l),l}}return-1}set nextAutoLevel(t){const e=this.deriveNextAutoLevel(t);this._nextAutoLevel!==e&&(this.nextAutoLevelKey="",this._nextAutoLevel=e)}deriveNextAutoLevel(t){const{maxAutoLevel:e,minAutoLevel:s}=this.hls;return Math.min(Math.max(t,s),e)}},bufferController:class extends A{constructor(t,e){var s;super("buffer-controller",t.logger),this.hls=void 0,this.fragmentTracker=void 0,this.details=null,this._objectUrl=null,this.operationQueue=null,this.bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.blockedAudioAppend=null,this.lastVideoAppendEnd=0,this.appendSource=void 0,this.transferData=void 0,this.overrides=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.sourceBuffers=[[null,null],[null,null]],this._onEndStreaming=t=>{var e;this.hls&&"open"===(null==(e=this.mediaSource)?void 0:e.readyState)&&this.hls.pauseBuffering()},this._onStartStreaming=t=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=t=>{const{media:e,mediaSource:s}=this;t&&this.log("Media source opened"),e&&s&&(s.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("emptied",this._onMediaEmptied),this.updateDuration(),this.hls.trigger(l.MEDIA_ATTACHED,{media:e,mediaSource:s}),null!==this.mediaSource&&this.checkPendingTracks())},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:t,_objectUrl:e}=this;t!==e&&this.error(`Media element src was set while attaching MediaSource (${e} > ${t})`)},this.hls=t,this.fragmentTracker=e,this.appendSource=(s=I(t.config.preferManagedMediaSource),"undefined"!=typeof self&&s===self.ManagedMediaSource),this.initTracks(),this.registerListeners()}hasSourceTypes(){return Object.keys(this.tracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.transferData=this.overrides=void 0,this.operationQueue&&(this.operationQueue.destroy(),this.operationQueue=null),this.hls=this.fragmentTracker=null,this._onMediaSourceOpen=this._onMediaSourceClose=null,this._onMediaSourceEnded=null,this._onStartStreaming=this._onEndStreaming=null}registerListeners(){const{hls:t}=this;t.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.MANIFEST_PARSED,this.onManifestParsed,this),t.on(l.BUFFER_RESET,this.onBufferReset,this),t.on(l.BUFFER_APPENDING,this.onBufferAppending,this),t.on(l.BUFFER_CODECS,this.onBufferCodecs,this),t.on(l.BUFFER_EOS,this.onBufferEos,this),t.on(l.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(l.FRAG_PARSED,this.onFragParsed,this),t.on(l.FRAG_CHANGED,this.onFragChanged,this),t.on(l.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.MANIFEST_PARSED,this.onManifestParsed,this),t.off(l.BUFFER_RESET,this.onBufferReset,this),t.off(l.BUFFER_APPENDING,this.onBufferAppending,this),t.off(l.BUFFER_CODECS,this.onBufferCodecs,this),t.off(l.BUFFER_EOS,this.onBufferEos,this),t.off(l.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(l.FRAG_PARSED,this.onFragParsed,this),t.off(l.FRAG_CHANGED,this.onFragChanged,this),t.off(l.ERROR,this.onError,this)}transferMedia(){const{media:t,mediaSource:e}=this;if(!t)return null;const s={};if(this.operationQueue){const t=this.isUpdating();t||this.operationQueue.removeBlockers();const e=this.isQueued();(t||e)&&this.warn(`Transfering MediaSource with${e?" operations in queue":""}${t?" updating SourceBuffer(s)":""} ${this.operationQueue}`),this.operationQueue.destroy()}const i=this.transferData;return!this.sourceBufferCount&&i&&i.mediaSource===e?b(s,i.tracks):this.sourceBuffers.forEach(t=>{const[e]=t;e&&(s[e]=b({},this.tracks[e]),this.removeBuffer(e)),t[0]=t[1]=null}),{media:t,mediaSource:e,tracks:s}}initTracks(){this.sourceBuffers=[[null,null],[null,null]],this.tracks={},this.resetQueue(),this.resetAppendErrors(),this.lastMpegAudioChunk=this.blockedAudioAppend=null,this.lastVideoAppendEnd=0}onManifestLoading(){this.bufferCodecEventsTotal=0,this.details=null}onManifestParsed(t,e){var s;let i=2;(e.audio&&!e.video||!e.altAudio)&&(i=1),this.bufferCodecEventsTotal=i,this.log(`${i} bufferCodec event(s) expected.`),null!=(s=this.transferData)&&s.mediaSource&&this.sourceBufferCount&&i&&this.bufferCreated()}onMediaAttaching(t,e){const s=this.media=e.media;this.transferData=this.overrides=void 0;const i=I(this.appendSource);if(i){const t=!!e.mediaSource;(t||e.overrides)&&(this.transferData=e,this.overrides=e.overrides);const r=this.mediaSource=e.mediaSource||new i;if(this.assignMediaSource(r),t)this._objectUrl=s.src,this.attachTransferred();else{const t=this._objectUrl=self.URL.createObjectURL(r);if(this.appendSource)try{s.removeAttribute("src");const e=self.ManagedMediaSource;s.disableRemotePlayback=s.disableRemotePlayback||e&&r instanceof e,Xr(s),function(t,e){const s=self.document.createElement("source");s.type="video/mp4",s.src=e,t.appendChild(s)}(s,t),s.load()}catch(e){s.src=t}else s.src=t}s.addEventListener("emptied",this._onMediaEmptied)}}assignMediaSource(t){var e,s;this.log(`${(null==(e=this.transferData)?void 0:e.mediaSource)===t?"transferred":"created"} media source: ${null==(s=t.constructor)?void 0:s.name}`),t.addEventListener("sourceopen",this._onMediaSourceOpen),t.addEventListener("sourceended",this._onMediaSourceEnded),t.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.addEventListener("startstreaming",this._onStartStreaming),t.addEventListener("endstreaming",this._onEndStreaming))}attachTransferred(){const t=this.media,e=this.transferData;if(!e||!t)return;const s=this.tracks,i=e.tracks,r=i?Object.keys(i):null,n=r?r.length:0,a=()=>{Promise.resolve().then(()=>{this.media&&this.mediaSourceOpenOrEnded&&this._onMediaSourceOpen()})};if(i&&r&&n){if(!this.tracksReady)return this.hls.config.startFragPrefetch=!0,void this.log("attachTransferred: waiting for SourceBuffer track info");if(this.log(`attachTransferred: (bufferCodecEventsTotal ${this.bufferCodecEventsTotal})\nrequired tracks: ${zt(s,(t,e)=>"initSegment"===t?void 0:e)};\ntransfer tracks: ${zt(i,(t,e)=>"initSegment"===t?void 0:e)}}`),!P(i,s)){e.mediaSource=null,e.tracks=void 0;const r=t.currentTime,n=this.details,a=Math.max(r,(null==n?void 0:n.fragments[0].start)||0);return a-r>1?void this.log(`attachTransferred: waiting for playback to reach new tracks start time ${r} -> ${a}`):(this.warn(`attachTransferred: resetting MediaSource for incompatible tracks ("${Object.keys(i)}"->"${Object.keys(s)}") start time: ${a} currentTime: ${r}`),this.onMediaDetaching(l.MEDIA_DETACHING,{}),this.onMediaAttaching(l.MEDIA_ATTACHING,e),void(t.currentTime=a))}this.transferData=void 0,r.forEach(t=>{const e=t,s=i[e];if(s){const t=s.buffer;if(t){const i=this.fragmentTracker,r=s.id;if(i.hasFragments(r)||i.hasParts(r)){const s=Fe.getBuffered(t);i.detectEvictedFragments(e,s,r,null,!0)}const n=Qr(e),a=[e,t];this.sourceBuffers[n]=a,t.updating&&this.operationQueue&&this.operationQueue.prependBlocker(e),this.trackSourceBuffer(e,s)}}}),a(),this.bufferCreated()}else this.log("attachTransferred: MediaSource w/o SourceBuffers"),a()}get mediaSourceOpenOrEnded(){var t;const e=null==(t=this.mediaSource)?void 0:t.readyState;return"open"===e||"ended"===e}onMediaDetaching(t,e){const s=!!e.transferMedia;this.transferData=this.overrides=void 0;const{media:i,mediaSource:r,_objectUrl:n}=this;if(r){if(this.log("media source "+(s?"transferring":"detaching")),s)this.sourceBuffers.forEach(([t])=>{t&&this.removeBuffer(t)}),this.resetQueue();else{if(this.mediaSourceOpenOrEnded){const t="open"===r.readyState;try{const e=r.sourceBuffers;for(let s=e.length;s--;)t&&e[s].abort(),r.removeSourceBuffer(e[s]);t&&r.endOfStream()}catch(t){this.warn(`onMediaDetaching: ${t.message} while calling endOfStream`)}}this.sourceBufferCount&&this.onBufferReset()}r.removeEventListener("sourceopen",this._onMediaSourceOpen),r.removeEventListener("sourceended",this._onMediaSourceEnded),r.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(r.removeEventListener("startstreaming",this._onStartStreaming),r.removeEventListener("endstreaming",this._onEndStreaming)),this.mediaSource=null,this._objectUrl=null}i&&(i.removeEventListener("emptied",this._onMediaEmptied),s||(n&&self.URL.revokeObjectURL(n),this.mediaSrc===n?(i.removeAttribute("src"),this.appendSource&&Xr(i),i.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.media=null),this.hls.trigger(l.MEDIA_DETACHED,e)}onBufferReset(){this.sourceBuffers.forEach(([t])=>{t&&this.resetBuffer(t)}),this.initTracks()}resetBuffer(t){var e;const s=null==(e=this.tracks[t])?void 0:e.buffer;if(this.removeBuffer(t),s)try{var i;null!=(i=this.mediaSource)&&i.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(s)}catch(e){this.warn(`onBufferReset ${t}`,e)}delete this.tracks[t]}removeBuffer(t){this.removeBufferListeners(t),this.sourceBuffers[Qr(t)]=[null,null];const e=this.tracks[t];e&&(e.buffer=void 0)}resetQueue(){this.operationQueue&&this.operationQueue.destroy(),this.operationQueue=new Kr(this.tracks)}onBufferCodecs(t,e){var s;const i=this.tracks,r=Object.keys(e);this.log(`BUFFER_CODECS: "${r}" (current SB count ${this.sourceBufferCount})`);const n="audiovideo"in e&&(i.audio||i.video)||i.audiovideo&&("audio"in e||"video"in e),a=!n&&this.sourceBufferCount&&this.media&&r.some(t=>!i[t]);n||a?this.warn(`Unsupported transition between "${Object.keys(i)}" and "${r}" SourceBuffers`):(r.forEach(t=>{var s,r;const n=e[t],{id:a,codec:o,levelCodec:l,container:h,metadata:c,supplemental:d}=n;let u=i[t];const p=null==(s=this.transferData)||null==(s=s.tracks)?void 0:s[t],f=null!=p&&p.buffer?p:u,g=(null==f?void 0:f.pendingCodec)||(null==f?void 0:f.codec),m=null==f?void 0:f.levelCodec;u||(u=i[t]={buffer:void 0,listeners:[],codec:o,supplemental:d,container:h,levelCodec:l,metadata:c,id:a});const y=It(g,m),v=null==y?void 0:y.replace(zr,"$1");let b=It(o,l);const _=null==(r=b)?void 0:r.replace(zr,"$1");b&&y&&v!==_&&("audio"===t.slice(0,5)&&(b=Lt(b,this.appendSource)),this.log(`switching codec ${g} to ${b}`),b!==(u.pendingCodec||u.codec)&&(u.pendingCodec=b),u.container=h,this.appendChangeType(t,h,b))}),(this.tracksReady||this.sourceBufferCount)&&(e.tracks=this.sourceBufferTracks),this.sourceBufferCount||(this.bufferCodecEventsTotal>1&&!this.tracks.video&&!e.video&&"main"===(null==(s=e.audio)?void 0:s.id)&&(this.log("Main audio-only"),this.bufferCodecEventsTotal=1),this.mediaSourceOpenOrEnded&&this.checkPendingTracks()))}get sourceBufferTracks(){return Object.keys(this.tracks).reduce((t,e)=>{const s=this.tracks[e];return t[e]={id:s.id,container:s.container,codec:s.codec,levelCodec:s.levelCodec},t},{})}appendChangeType(t,e,s){const i=`${e};codecs=${s}`,r={label:`change-type=${i}`,execute:()=>{const r=this.tracks[t];if(r){const n=r.buffer;null!=n&&n.changeType&&(this.log(`changing ${t} sourceBuffer type to ${i}`),n.changeType(i),r.codec=s,r.container=e)}this.shiftAndExecuteNext(t)},onStart:()=>{},onComplete:()=>{},onError:e=>{this.warn(`Failed to change ${t} SourceBuffer type`,e)}};this.append(r,t,this.isPending(this.tracks[t]))}blockAudio(t){var e;const s=t.start,i=s+.05*t.duration;if(!0===(null==(e=this.fragmentTracker.getAppendedFrag(s,p))?void 0:e.gap))return;const r={label:"block-audio",execute:()=>{var t;const e=this.tracks.video;(this.lastVideoAppendEnd>i||null!=e&&e.buffer&&Fe.isBuffered(e.buffer,i)||!0===(null==(t=this.fragmentTracker.getAppendedFrag(i,p))?void 0:t.gap))&&(this.blockedAudioAppend=null,this.shiftAndExecuteNext("audio"))},onStart:()=>{},onComplete:()=>{},onError:t=>{this.warn("Error executing block-audio operation",t)}};this.blockedAudioAppend={op:r,frag:t},this.append(r,"audio",!0)}unblockAudio(){const{blockedAudioAppend:t,operationQueue:e}=this;t&&e&&(this.blockedAudioAppend=null,e.unblockAudio(t.op))}onBufferAppending(t,e){const{tracks:s}=this,{data:r,type:n,parent:h,frag:c,part:d,chunkMeta:u,offset:f}=e,g=u.buffering[n],{sn:m,cc:y}=c,v=self.performance.now();g.start=v;const b=c.stats.buffering,_=d?d.stats.buffering:null;0===b.start&&(b.start=v),_&&0===_.start&&(_.start=v);const T=s.audio;let A=!1;"audio"===n&&"audio/mpeg"===(null==T?void 0:T.container)&&(A=!this.lastMpegAudioChunk||1===u.id||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);const E=s.video,S=null==E?void 0:E.buffer;if(S&&"initSegment"!==m){const t=d||c,e=this.blockedAudioAppend;if("audio"!==n||"main"===h||this.blockedAudioAppend||E.ending||E.ended){if("video"===n){const s=t.end;if(e){const t=e.frag.start;(s>t||s<this.lastVideoAppendEnd||Fe.isBuffered(S,t))&&this.unblockAudio()}this.lastVideoAppendEnd=s}}else{const e=t.start+.05*t.duration,s=S.buffered,i=this.currentOp("video");s.length||i?!i&&!Fe.isBuffered(S,e)&&this.lastVideoAppendEnd<e&&this.blockAudio(t):this.blockAudio(t)}}const C=(d||c).start,k={label:`append-${n}`,execute:()=>{var t;g.executeStart=self.performance.now();const e=null==(t=this.tracks[n])?void 0:t.buffer;e&&(A?this.updateTimestampOffset(e,C,.1,n,m,y):void 0!==f&&i(f)&&this.updateTimestampOffset(e,f,1e-6,n,m,y)),this.appendExecutor(r,n)},onStart:()=>{},onComplete:()=>{const t=self.performance.now();g.executeEnd=g.end=t,0===b.first&&(b.first=t),_&&0===_.first&&(_.first=t);const e={};this.sourceBuffers.forEach(([t,s])=>{t&&(e[t]=Fe.getBuffered(s))}),this.appendErrors[n]=0,"audio"===n||"video"===n?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(l.BUFFER_APPENDED,{type:n,frag:c,part:d,chunkMeta:u,parent:c.type,timeRanges:e})},onError:t=>{var e;const s={type:a.MEDIA_ERROR,parent:c.type,details:o.BUFFER_APPEND_ERROR,sourceBufferName:n,frag:c,part:d,chunkMeta:u,error:t,err:t,fatal:!1},i=null==(e=this.media)?void 0:e.error;if(t.code===DOMException.QUOTA_EXCEEDED_ERR||"QuotaExceededError"==t.name||"quota"in t)s.details=o.BUFFER_FULL_ERROR;else if(t.code===DOMException.INVALID_STATE_ERR&&this.mediaSourceOpenOrEnded&&!i)s.errorAction=ge(!0);else if(t.name===qr&&0===this.sourceBufferCount)s.errorAction=ge(!0);else{const t=++this.appendErrors[n];this.warn(`Failed ${t}/${this.hls.config.appendErrorMaxRetry} times to append segment in "${n}" sourceBuffer (${i||"no media error"})`),(t>=this.hls.config.appendErrorMaxRetry||i)&&(s.fatal=!0)}this.hls.trigger(l.ERROR,s)}};this.log(`queuing "${n}" append sn: ${m}${d?" p: "+d.index:""} of ${c.type===p?"level":"track"} ${c.level} cc: ${y}`),this.append(k,n,this.isPending(this.tracks[n]))}getFlushOp(t,e,s){return this.log(`queuing "${t}" remove ${e}-${s}`),{label:"remove",execute:()=>{this.removeExecutor(t,e,s)},onStart:()=>{},onComplete:()=>{this.hls.trigger(l.BUFFER_FLUSHED,{type:t})},onError:i=>{this.warn(`Failed to remove ${e}-${s} from "${t}" SourceBuffer`,i)}}}onBufferFlushing(t,e){const{type:s,startOffset:i,endOffset:r}=e;s?this.append(this.getFlushOp(s,i,r),s):this.sourceBuffers.forEach(([t])=>{t&&this.append(this.getFlushOp(t,i,r),t)})}onFragParsed(t,e){const{frag:s,part:i}=e,r=[],n=i?i.elementaryStreams:s.elementaryStreams;n[U]?r.push("audiovideo"):(n[j]&&r.push("audio"),n[$]&&r.push("video")),0===r.length&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${s.type} level: ${s.level} sn: ${s.sn}`),this.blockBuffers(()=>{const t=self.performance.now();s.stats.buffering.end=t,i&&(i.stats.buffering.end=t);const e=i?i.stats:s.stats;this.hls.trigger(l.FRAG_BUFFERED,{frag:s,part:i,stats:e,id:s.type})},r).catch(t=>{this.warn(`Fragment buffered callback ${t}`),this.stepOperationQueue(this.sourceBufferTypes)})}onFragChanged(t,e){this.trimBuffers()}get bufferedToEnd(){return this.sourceBufferCount>0&&!this.sourceBuffers.some(([t])=>{if(t){const e=this.tracks[t];if(e)return!e.ended||e.ending}return!1})}onBufferEos(t,e){var s;this.sourceBuffers.forEach(([t])=>{if(t){const s=this.tracks[t];e.type&&e.type!==t||(s.ending=!0,s.ended||(s.ended=!0,this.log(`${t} buffer reached EOS`)))}});const i=!1!==(null==(s=this.overrides)?void 0:s.endOfStream);this.sourceBufferCount>0&&!this.sourceBuffers.some(([t])=>{var e;return t&&!(null!=(e=this.tracks[t])&&e.ended)})?i?(this.log("Queueing EOS"),this.blockUntilOpen(()=>{this.tracksEnded();const{mediaSource:t}=this;t&&"open"===t.readyState?(this.log("Calling mediaSource.endOfStream()"),t.endOfStream(),this.hls.trigger(l.BUFFERED_TO_END,void 0)):t&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${t.readyState}`)})):(this.tracksEnded(),this.hls.trigger(l.BUFFERED_TO_END,void 0)):"video"===e.type&&this.unblockAudio()}tracksEnded(){this.sourceBuffers.forEach(([t])=>{if(null!==t){const e=this.tracks[t];e&&(e.ending=!1)}})}onLevelUpdated(t,{details:e}){e.fragments.length&&(this.details=e,this.updateDuration())}updateDuration(){this.blockUntilOpen(()=>{const t=this.getDurationAndRange();t&&this.updateMediaSource(t)})}onError(t,e){if(e.details===o.BUFFER_APPEND_ERROR&&e.frag){var s;const t=null==(s=e.errorAction)?void 0:s.nextAutoLevel;i(t)&&t!==e.frag.level&&this.resetAppendErrors()}}resetAppendErrors(){this.appendErrors={audio:0,video:0,audiovideo:0}}trimBuffers(){const{hls:t,details:e,media:s}=this;if(!s||null===e)return;if(!this.sourceBufferCount)return;const r=t.config,n=s.currentTime,a=e.levelTargetDuration,o=e.live&&null!==r.liveBackBufferLength?r.liveBackBufferLength:r.backBufferLength;if(i(o)&&o>=0){const t=Math.max(o,a),e=Math.floor(n/a)*a-t;this.flushBackBuffer(n,a,e)}const l=r.frontBufferFlushThreshold;if(i(l)&&l>0){const t=Math.max(r.maxBufferLength,l),e=Math.max(t,a),s=Math.floor(n/a)*a+e;this.flushFrontBuffer(n,a,s)}}flushBackBuffer(t,e,s){this.sourceBuffers.forEach(([t,e])=>{if(e){const r=Fe.getBuffered(e);if(r.length>0&&s>r.start(0)){var i;this.hls.trigger(l.BACK_BUFFER_REACHED,{bufferEnd:s});const e=this.tracks[t];if(null!=(i=this.details)&&i.live)this.hls.trigger(l.LIVE_BACK_BUFFER_REACHED,{bufferEnd:s});else if(null!=e&&e.ended)return void this.log(`Cannot flush ${t} back buffer while SourceBuffer is in ended state`);this.hls.trigger(l.BUFFER_FLUSHING,{startOffset:0,endOffset:s,type:t})}}})}flushFrontBuffer(t,e,s){this.sourceBuffers.forEach(([e,i])=>{if(i){const r=Fe.getBuffered(i),n=r.length;if(n<2)return;const a=r.start(n-1),o=r.end(n-1);if(s>a||t>=a&&t<=o)return;this.hls.trigger(l.BUFFER_FLUSHING,{startOffset:a,endOffset:1/0,type:e})}})}getDurationAndRange(){var t;const{details:e,mediaSource:s}=this;if(!e||!this.media||"open"!==(null==s?void 0:s.readyState))return null;const r=e.edge;if(e.live&&this.hls.config.liveDurationInfinity){if(e.fragments.length&&s.setLiveSeekableRange){const t=Math.max(0,e.fragmentStart);return{duration:1/0,start:t,end:Math.max(t,r)}}return{duration:1/0}}const n=null==(t=this.overrides)?void 0:t.duration;if(n)return i(n)?{duration:n}:null;const a=this.media.duration;return r>(i(s.duration)?s.duration:0)&&r>a||!i(a)?{duration:r}:null}updateMediaSource({duration:t,start:e,end:s}){const r=this.mediaSource;this.media&&r&&"open"===r.readyState&&(r.duration!==t&&(i(t)&&this.log(`Updating MediaSource duration to ${t.toFixed(3)}`),r.duration=t),void 0!==e&&void 0!==s&&(this.log(`MediaSource duration is set to ${r.duration}. Setting seekable range to ${e}-${s}.`),r.setLiveSeekableRange(e,s)))}get tracksReady(){const t=this.pendingTrackCount;return t>0&&(t>=this.bufferCodecEventsTotal||this.isPending(this.tracks.audiovideo))}checkPendingTracks(){const{bufferCodecEventsTotal:t,pendingTrackCount:e,tracks:s}=this;if(this.log(`checkPendingTracks (pending: ${e} codec events expected: ${t}) ${zt(s)}`),this.tracksReady){var i;const t=null==(i=this.transferData)?void 0:i.tracks;t&&Object.keys(t).length?this.attachTransferred():this.createSourceBuffers()}}bufferCreated(){if(this.sourceBufferCount){const t={};this.sourceBuffers.forEach(([e,s])=>{if(e){const i=this.tracks[e];t[e]={buffer:s,container:i.container,codec:i.codec,supplemental:i.supplemental,levelCodec:i.levelCodec,id:i.id,metadata:i.metadata}}}),this.hls.trigger(l.BUFFER_CREATED,{tracks:t}),this.log(`SourceBuffers created. Running queue: ${this.operationQueue}`),this.sourceBuffers.forEach(([t])=>{this.executeNext(t)})}else{const t=new Error("could not create source buffer for media codec(s)");this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:t,reason:t.message})}}createSourceBuffers(){const{tracks:t,sourceBuffers:e,mediaSource:s}=this;if(!s)throw new Error("createSourceBuffers called when mediaSource was null");for(const r in t){const n=r,h=t[n];if(this.isPending(h)){const t=this.getTrackCodec(h,n),r=`${h.container};codecs=${t}`;h.codec=t,this.log(`creating sourceBuffer(${r})${this.currentOp(n)?" Queued":""} ${zt(h)}`);try{const t=s.addSourceBuffer(r),i=Qr(n),a=[n,t];e[i]=a,h.buffer=t}catch(t){var i;return this.error(`error while trying to add sourceBuffer: ${t.message}`),this.shiftAndExecuteNext(n),null==(i=this.operationQueue)||i.removeBlockers(),delete this.tracks[n],void this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,sourceBufferName:n,mimeType:r,parent:h.id})}this.trackSourceBuffer(n,h)}}this.bufferCreated()}getTrackCodec(t,e){const s=t.supplemental;let i=t.codec;s&&("video"===e||"audiovideo"===e)&&Tt(s,"video")&&(i=function(t,e){const s=[];if(t){const e=t.split(",");for(let t=0;t<e.length;t++)_t(e[t],"video")||s.push(e[t])}return e&&s.push(e),s.join(",")}(i,s));const r=It(i,t.levelCodec);return r?"audio"===e.slice(0,5)?Lt(r,this.appendSource):r:""}trackSourceBuffer(t,e){const s=e.buffer;if(!s)return;const i=this.getTrackCodec(e,t);this.tracks[t]={buffer:s,codec:i,container:e.container,levelCodec:e.levelCodec,supplemental:e.supplemental,metadata:e.metadata,id:e.id,listeners:[]},this.removeBufferListeners(t),this.addBufferListener(t,"updatestart",this.onSBUpdateStart),this.addBufferListener(t,"updateend",this.onSBUpdateEnd),this.addBufferListener(t,"error",this.onSBUpdateError),this.appendSource&&this.addBufferListener(t,"bufferedchange",(t,e)=>{const s=e.removedRanges;null!=s&&s.length&&this.hls.trigger(l.BUFFER_FLUSHED,{type:t})})}get mediaSrc(){var t,e;const s=(null==(t=this.media)||null==(e=t.querySelector)?void 0:e.call(t,"source"))||this.media;return null==s?void 0:s.src}onSBUpdateStart(t){const e=this.currentOp(t);e&&e.onStart()}onSBUpdateEnd(t){var e;if("closed"===(null==(e=this.mediaSource)?void 0:e.readyState))return void this.resetBuffer(t);const s=this.currentOp(t);s&&(s.onComplete(),this.shiftAndExecuteNext(t))}onSBUpdateError(t,e){var s;const i=new Error(`${t} SourceBuffer error. MediaSource readyState: ${null==(s=this.mediaSource)?void 0:s.readyState}`);this.error(`${i}`,e),this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_APPENDING_ERROR,sourceBufferName:t,error:i,fatal:!1});const r=this.currentOp(t);r&&r.onError(i)}updateTimestampOffset(t,e,s,i,r,n){const a=e-t.timestampOffset;Math.abs(a)>=s&&(this.log(`Updating ${i} SourceBuffer timestampOffset to ${e} (sn: ${r} cc: ${n})`),t.timestampOffset=e)}removeExecutor(t,e,s){const{media:r,mediaSource:n}=this,a=this.tracks[t],o=null==a?void 0:a.buffer;if(!r||!n||!o)return this.warn(`Attempting to remove from the ${t} SourceBuffer, but it does not exist`),void this.shiftAndExecuteNext(t);const l=i(r.duration)?r.duration:1/0,h=i(n.duration)?n.duration:1/0,c=Math.max(0,e),d=Math.min(s,l,h);d>c&&(!a.ending||a.ended)?(a.ended=!1,this.log(`Removing [${c},${d}] from the ${t} SourceBuffer`),o.remove(c,d)):this.shiftAndExecuteNext(t)}appendExecutor(t,e){const s=this.tracks[e],i=null==s?void 0:s.buffer;if(!i)throw new Yr(`Attempting to append to the ${e} SourceBuffer, but it does not exist`);s.ending=!1,s.ended=!1,i.appendBuffer(t)}blockUntilOpen(t){if(this.isUpdating()||this.isQueued())this.blockBuffers(t).catch(t=>{this.warn(`SourceBuffer blocked callback ${t}`),this.stepOperationQueue(this.sourceBufferTypes)});else try{t()}catch(t){this.warn(`Callback run without blocking ${this.operationQueue} ${t}`)}}isUpdating(){return this.sourceBuffers.some(([t,e])=>t&&e.updating)}isQueued(){return this.sourceBuffers.some(([t])=>t&&!!this.currentOp(t))}isPending(t){return!!t&&!t.buffer}blockBuffers(t,e=this.sourceBufferTypes){if(!e.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(t);const{operationQueue:s}=this,i=e.map(t=>this.appendBlocker(t));return e.length>1&&!!this.blockedAudioAppend&&this.unblockAudio(),Promise.all(i).then(e=>{s===this.operationQueue&&(t(),this.stepOperationQueue(this.sourceBufferTypes))})}stepOperationQueue(t){t.forEach(t=>{var e;const s=null==(e=this.tracks[t])?void 0:e.buffer;s&&!s.updating&&this.shiftAndExecuteNext(t)})}append(t,e,s){this.operationQueue&&this.operationQueue.append(t,e,s)}appendBlocker(t){if(this.operationQueue)return this.operationQueue.appendBlocker(t)}currentOp(t){return this.operationQueue?this.operationQueue.current(t):null}executeNext(t){t&&this.operationQueue&&this.operationQueue.executeNext(t)}shiftAndExecuteNext(t){this.operationQueue&&this.operationQueue.shiftAndExecuteNext(t)}get pendingTrackCount(){return Object.keys(this.tracks).reduce((t,e)=>t+(this.isPending(this.tracks[e])?1:0),0)}get sourceBufferCount(){return this.sourceBuffers.reduce((t,[e])=>t+(e?1:0),0)}get sourceBufferTypes(){return this.sourceBuffers.map(([t])=>t).filter(t=>!!t)}addBufferListener(t,e,s){const i=this.tracks[t];if(!i)return;const r=i.buffer;if(!r)return;const n=s.bind(this,t);i.listeners.push({event:e,listener:n}),r.addEventListener(e,n)}removeBufferListeners(t){const e=this.tracks[t];if(!e)return;const s=e.buffer;s&&(e.listeners.forEach(t=>{s.removeEventListener(t.event,t.listener)}),e.listeners.length=0)}},capLevelController:Zr,errorController:class extends A{constructor(t){super("error-controller",t.logger),this.hls=void 0,this.playlistError=0,this.hls=t,this.registerListeners()}registerListeners(){const t=this.hls;t.on(l.ERROR,this.onError,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const t=this.hls;t&&(t.off(l.ERROR,this.onError,this),t.off(l.ERROR,this.onErrorOut,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null}startLoad(t){}stopLoad(){this.playlistError=0}getVariantLevelIndex(t){return(null==t?void 0:t.type)===p?t.level:this.getVariantIndex()}getVariantIndex(){var t;const e=this.hls,s=e.currentLevel;return null!=(t=e.loadLevelObj)&&t.details||-1===s?e.loadLevel:s}variantHasKey(t,e){if(t){var s;if(null!=(s=t.details)&&s.hasKey(e))return!0;const i=t.audioGroups;if(i)return this.hls.allAudioTracks.filter(t=>i.indexOf(t.groupId)>=0).some(t=>{var s;return null==(s=t.details)?void 0:s.hasKey(e)})}return!1}onManifestLoading(){this.playlistError=0}onLevelUpdated(){this.playlistError=0}onError(t,e){var s;if(e.fatal)return;const i=this.hls,r=e.context;switch(e.details){case o.FRAG_LOAD_ERROR:case o.FRAG_LOAD_TIMEOUT:case o.KEY_LOAD_ERROR:case o.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case o.FRAG_PARSING_ERROR:if(null!=(s=e.frag)&&s.gap)return void(e.errorAction=ge());case o.FRAG_GAP:case o.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=2);case o.LEVEL_EMPTY_ERROR:case o.LEVEL_PARSING_ERROR:{var n;const t=e.parent===p?e.level:i.loadLevel;e.details===o.LEVEL_EMPTY_ERROR&&null!=(n=e.context)&&null!=(n=n.levelDetails)&&n.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,t):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t))}return;case o.LEVEL_LOAD_ERROR:case o.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==r?void 0:r.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,r.level)));case o.AUDIO_TRACK_LOAD_ERROR:case o.AUDIO_TRACK_LOAD_TIMEOUT:case o.SUBTITLE_LOAD_ERROR:case o.SUBTITLE_TRACK_LOAD_TIMEOUT:if(r){const t=i.loadLevelObj;if(t&&(r.type===d&&t.hasAudioGroup(r.groupId)||r.type===u&&t.hasSubtitleGroup(r.groupId)))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,i.loadLevel),e.errorAction.action=2,void(e.errorAction.flags=1)}return;case o.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:return void(e.errorAction={action:2,flags:2});case o.KEY_SYSTEM_SESSION_UPDATE_FAILED:case o.KEY_SYSTEM_STATUS_INTERNAL_ERROR:case o.KEY_SYSTEM_NO_SESSION:return void(e.errorAction={action:2,flags:4});case o.BUFFER_ADD_CODEC_ERROR:case o.REMUX_ALLOC_ERROR:case o.BUFFER_APPEND_ERROR:var l;return void(e.errorAction||(e.errorAction=this.getLevelSwitchAction(e,null!=(l=e.level)?l:i.loadLevel)));case o.INTERNAL_EXCEPTION:case o.BUFFER_APPENDING_ERROR:case o.BUFFER_FULL_ERROR:case o.LEVEL_SWITCH_ERROR:case o.BUFFER_STALLED_ERROR:case o.BUFFER_SEEK_OVER_HOLE:case o.BUFFER_NUDGE_ON_STALL:return void(e.errorAction=ge())}e.type===a.KEY_SYSTEM_ERROR&&(e.levelRetry=!1,e.errorAction=ge())}getPlaylistRetryOrSwitchAction(t,e){const s=ce(this.hls.config.playlistLoadPolicy,t),i=this.playlistError++;if(pe(s,i,oe(t),t.response))return{action:5,flags:0,retryConfig:s,retryCount:i};const r=this.getLevelSwitchAction(t,e);return s&&(r.retryConfig=s,r.retryCount=i),r}getFragRetryOrSwitchAction(t){const e=this.hls,s=this.getVariantLevelIndex(t.frag),i=e.levels[s],{fragLoadPolicy:r,keyLoadPolicy:n}=e.config,a=ce(le(t)?n:r,t),l=e.levels.reduce((t,e)=>t+e.fragmentError,0);if(i&&(t.details!==o.FRAG_GAP&&i.fragmentError++,!he(t))&&pe(a,l,oe(t),t.response))return{action:5,flags:0,retryConfig:a,retryCount:l};const h=this.getLevelSwitchAction(t,s);return a&&(h.retryConfig=a,h.retryCount=l),h}getLevelSwitchAction(t,e){const s=this.hls;null==e&&(e=s.loadLevel);const i=this.hls.levels[e];if(i){var r,n;const e=t.details;i.loadError++,e===o.BUFFER_APPEND_ERROR&&i.fragmentError++;let h=-1;const{levels:c,loadLevel:m,minAutoLevel:y,maxAutoLevel:v}=s;s.autoLevelEnabled||s.config.preserveManualLevelOnError||(s.loadLevel=-1);const b=null==(r=t.frag)?void 0:r.type,_=(b===f&&e===o.FRAG_PARSING_ERROR||"audio"===t.sourceBufferName&&(e===o.BUFFER_ADD_CODEC_ERROR||e===o.BUFFER_APPEND_ERROR))&&c.some(({audioCodec:t})=>i.audioCodec!==t),T="video"===t.sourceBufferName&&(e===o.BUFFER_ADD_CODEC_ERROR||e===o.BUFFER_APPEND_ERROR)&&c.some(({codecSet:t,audioCodec:e})=>i.codecSet!==t&&i.audioCodec===e),{type:A,groupId:E}=null!=(n=t.context)?n:{};for(let s=c.length;s--;){const r=(s+m)%c.length;if(r!==m&&r>=y&&r<=v&&0===c[r].loadError){var a,l;const s=c[r];if(e===o.FRAG_GAP&&b===p&&t.frag){const e=c[r].details;if(e){const s=ie(t.frag,e.fragments,t.frag.start);if(null!=s&&s.gap)continue}}else{if(A===d&&s.hasAudioGroup(E)||A===u&&s.hasSubtitleGroup(E))continue;if(b===f&&null!=(a=i.audioGroups)&&a.some(t=>s.hasAudioGroup(t))||b===g&&null!=(l=i.subtitleGroups)&&l.some(t=>s.hasSubtitleGroup(t))||_&&i.audioCodec===s.audioCodec||T&&i.codecSet===s.codecSet||!_&&i.codecSet!==s.codecSet)continue}h=r;break}}if(h>-1&&s.loadLevel!==h)return t.levelRetry=!0,this.playlistError=0,{action:2,flags:0,nextAutoLevel:h}}return{action:2,flags:1}}onErrorOut(t,e){var s;switch(null==(s=e.errorAction)?void 0:s.action){case 0:break;case 2:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===o.FRAG_GAP?/MediaSource readyState: ended/.test(e.error.message)&&(this.warn(`MediaSource ended after "${e.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError()):e.fatal=!0}e.fatal&&this.hls.stopLoad()}sendAlternateToPenaltyBox(t){const e=this.hls,s=t.errorAction;if(!s)return;const{flags:i}=s,r=s.nextAutoLevel;switch(i){case 0:this.switchLevel(t,r);break;case 2:{const i=this.getVariantLevelIndex(t.frag),r=e.levels[i],n=null==r?void 0:r.attrs["HDCP-LEVEL"];if(s.hdcpLevel=n,"NONE"===n)this.warn("HDCP policy resticted output with HDCP-LEVEL=NONE");else if(n){e.maxHdcpLevel=Ut[Ut.indexOf(n)-1],s.resolved=!0,this.warn(`Restricting playback to HDCP-LEVEL of "${e.maxHdcpLevel}" or lower`);break}}case 4:{const e=t.decryptdata;if(e){const i=this.hls.levels,r=i.length;for(let s=r;s--;){var n,a;this.variantHasKey(i[s],e)&&(this.log(`Banned key found in level ${s} (${i[s].bitrate}bps) or audio group "${null==(n=i[s].audioGroups)?void 0:n.join(",")}" (${null==(a=t.frag)?void 0:a.type} fragment) ${R(e.keyId||[])}`),i[s].fragmentError++,i[s].loadError++,this.log(`Removing level ${s} with key error (${t.error})`),this.hls.removeLevel(s))}const o=t.frag;if(this.hls.levels.length<r)s.resolved=!0;else if(o&&o.type!==p){const t=o.decryptdata;t&&!e.matches(t)&&(s.resolved=!0)}}break}}s.resolved||this.switchLevel(t,r)}switchLevel(t,e){if(void 0!==e&&t.errorAction&&(this.warn(`switching to level ${e} after ${t.details}`),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel,t.details===o.BUFFER_ADD_CODEC_ERROR&&t.mimeType&&"audiovideo"!==t.sourceBufferName)){const e=Dt(t.mimeType),s=this.hls.levels;for(let i=s.length;i--;)s[i][`${t.sourceBufferName}Codec`]===e&&(this.log(`Removing level ${i} for ${t.details} ("${e}" not supported)`),this.hls.removeLevel(i))}}},fpsController:class{constructor(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}setStreamController(t){this.streamController=t}registerListeners(){this.hls.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.on(l.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListeners(){this.hls.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),this.hls.off(l.MEDIA_DETACHING,this.onMediaDetaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(t,e){const s=this.hls.config;if(s.capLevelOnFPSDrop){const t=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=t,t&&"function"==typeof t.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),s.fpsDroppedMonitoringPeriod)}}onMediaDetaching(){this.media=null}checkFPS(t,e,s){const i=performance.now();if(e){if(this.lastTime){const t=i-this.lastTime,r=s-this.lastDroppedFrames,n=e-this.lastDecodedFrames,a=1e3*r/t,o=this.hls;if(o.trigger(l.FPS_DROP,{currentDropped:r,currentDecoded:n,totalDroppedFrames:s}),a>0&&r>o.config.fpsDroppedMonitoringThreshold*n){let t=o.currentLevel;o.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+t),t>0&&(-1===o.autoLevelCapping||o.autoLevelCapping>=t)&&(t-=1,o.trigger(l.FPS_DROP_LEVEL_CAPPING,{level:t,droppedLevel:o.currentLevel}),o.autoLevelCapping=t,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=s,this.lastDecodedFrames=e}}checkFPSInterval(){const t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){const e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)}},stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:us,requireKeySystemAccessOnStart:!1,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableEmsgKLVMetadata:!1,enableID3MetadataCues:!0,enableInterstitialPlayback:!0,interstitialAppendInPlace:!0,interstitialLiveLookAhead:10,useMediaCapabilities:!0,preserveManualLevelOnError:!1,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},interstitialAssetListLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:3e4,timeoutRetry:{maxNumRetry:0,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:0,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:mo,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:class extends ui{constructor(t,e,s){super(t,e,s,"subtitle-stream-controller",g),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}registerListeners(){super.registerListeners();const{hls:t}=this;t.on(l.LEVEL_LOADED,this.onLevelLoaded,this),t.on(l.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(l.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(l.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(l.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(l.BUFFER_FLUSHING,this.onBufferFlushing,this)}unregisterListeners(){super.unregisterListeners();const{hls:t}=this;t.off(l.LEVEL_LOADED,this.onLevelLoaded,this),t.off(l.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(l.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(l.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(l.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(l.BUFFER_FLUSHING,this.onBufferFlushing,this)}startLoad(t,e){this.stopLoad(),this.state=ei,this.setInterval(500),this.nextLoadPosition=this.lastCurrentTime=t+this.timelineOffset,this.startPosition=e?-1:t,this.tick()}onManifestLoading(){super.onManifestLoading(),this.mainDetails=null}onMediaDetaching(t,e){this.tracksBuffered=[],super.onMediaDetaching(t,e)}onLevelLoaded(t,e){this.mainDetails=e.details}onSubtitleFragProcessed(t,e){const{frag:s,success:i}=e;if(this.fragContextChanged(s)||(V(s)&&(this.fragPrevious=s),this.state=ei),!i)return;const r=this.tracksBuffered[this.currentTrackId];if(!r)return;let n;const a=s.start;for(let t=0;t<r.length;t++)if(a>=r[t].start&&a<=r[t].end){n=r[t];break}const o=s.start+s.duration;n?n.end=o:(n={start:a,end:o},r.push(n)),this.fragmentTracker.fragBuffered(s),this.fragBufferedComplete(s,null),this.media&&this.tick()}onBufferFlushing(t,e){const{startOffset:s,endOffset:i}=e;if(0===s&&i!==Number.POSITIVE_INFINITY){const t=i-1;if(t<=0)return;e.endOffsetSubtitles=Math.max(0,t),this.tracksBuffered.forEach(e=>{for(let s=0;s<e.length;)if(e[s].end<=t)e.shift();else{if(!(e[s].start<t))break;e[s].start=t,s++}}),this.fragmentTracker.removeFragmentsInRange(s,t,g)}}onError(t,e){const s=e.frag;(null==s?void 0:s.type)===g&&(e.details===o.FRAG_GAP&&this.fragmentTracker.fragBuffered(s,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==ti&&(this.state=ei))}onSubtitleTracksUpdated(t,{subtitleTracks:e}){this.levels&&Vr(this.levels,e)?this.levels=e.map(t=>new Wt(t)):(this.tracksBuffered=[],this.levels=e.map(t=>{const e=new Wt(t);return this.tracksBuffered[e.id]=[],e}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,g),this.fragPrevious=null,this.mediaBuffer=null)}onSubtitleTrackSwitch(t,e){var s;if(this.currentTrackId=e.id,null==(s=this.levels)||!s.length||-1===this.currentTrackId)return void this.clearInterval();const i=this.levels[this.currentTrackId];null!=i&&i.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,i&&this.state!==ti&&this.setInterval(500)}onSubtitleTrackLoaded(t,e){var s;const{currentTrackId:i,levels:r}=this,{details:n,id:a}=e;if(!r)return void this.warn(`Subtitle tracks were reset while loading level ${a}`);const o=r[a];if(a>=r.length||!o)return;this.log(`Subtitle track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let h=0;if(n.live||null!=(s=o.details)&&s.live){if(n.deltaUpdateFailed)return;const t=this.mainDetails;if(!t)return void(this.startFragRequested=!1);const e=t.fragments[0];var c;o.details?(h=this.alignPlaylists(n,o.details,null==(c=this.levelLastLoaded)?void 0:c.details),0===h&&e&&(h=e.start,js(n,h))):n.hasProgramDateTime&&t.hasProgramDateTime?(Qs(n,t),h=n.fragmentStart):e&&(h=e.start,js(n,h)),t&&!this.startFragRequested&&this.setStartPosition(t,h)}o.details=n,this.levelLastLoaded=o,a===i&&(this.hls.trigger(l.SUBTITLE_TRACK_UPDATED,{details:n,id:a,groupId:e.groupId}),this.tick(),n.live&&!this.fragCurrent&&this.media&&this.state===ei)&&(ie(null,n.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0))}_handleFragmentLoadComplete(t){const{frag:e,payload:s}=t,i=e.decryptdata,r=this.hls;if(!this.fragContextChanged(e)&&s&&s.byteLength>0&&null!=i&&i.key&&i.iv&&Qe(i.method)){const t=performance.now();this.decrypter.decrypt(new Uint8Array(s),i.key.buffer,i.iv.buffer,Ze(i.method)).catch(t=>{throw r.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:e}),t}).then(s=>{const i=performance.now();r.trigger(l.FRAG_DECRYPTED,{frag:e,payload:s,stats:{tstart:t,tdecrypt:i}})}).catch(t=>{this.warn(`${t.name}: ${t.message}`),this.state=ei})}}doTick(){if(this.media){if(this.state===ei){const{currentTrackId:t,levels:e}=this,s=null==e?void 0:e[t];if(!s||!e.length||!s.details)return;if(this.waitForLive(s))return;const{config:i}=this,r=this.getLoadPosition(),n=Fe.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],r,i.maxBufferHole),{end:a,len:o}=n,l=s.details;if(o>this.hls.maxBufferLength+l.levelTargetDuration)return;const h=l.fragments,c=h.length,d=l.edge;let u=null;const p=this.fragPrevious;if(a<d){const t=i.maxFragLookUpTolerance,e=a>d-t?0:t;u=ie(p,h,Math.max(h[0].start,a),e),!u&&p&&p.start<h[0].start&&(u=h[0])}else u=h[c-1];if(u=this.filterReplacedPrimary(u,s.details),!u)return;const f=h[u.sn-l.startSN-1];if(f&&f.cc===u.cc&&this.fragmentTracker.getState(f)===me&&(u=f),this.fragmentTracker.getState(u)===me){const t=this.mapToInitFragWhenRequired(u);t&&this.loadFragment(t,s,a)}}}else this.state=ei}loadFragment(t,e,s){V(t)?super.loadFragment(t,e,s):this._loadInitSegment(t,e)}get mediaBufferTimeRanges(){return new _a(this.tracksBuffered[this.currentTrackId]||[])}},subtitleTrackController:class extends Hr{constructor(t){super(t,"subtitle-track-controller"),this.media=null,this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.queuedDefaultTrack=-1,this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.asyncPollTrackChange=()=>this.pollTrackChange(0),this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const e=ra(this.media.textTracks);for(let s=0;s<e.length;s++)if("hidden"===e[s].mode)t=e[s];else if("showing"===e[s].mode){t=e[s];break}const s=this.findTrackForTextTrack(t);this.subtitleTrack!==s&&this.setSubtitleTrack(s)},this.registerListeners()}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,this.onTextTracksChanged=this.asyncPollTrackChange=null,super.destroy()}get subtitleDisplay(){return this._subtitleDisplay}set subtitleDisplay(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:t}=this;t.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.MANIFEST_PARSED,this.onManifestParsed,this),t.on(l.LEVEL_LOADING,this.onLevelLoading,this),t.on(l.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(l.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(l.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.MANIFEST_PARSED,this.onManifestParsed,this),t.off(l.LEVEL_LOADING,this.onLevelLoading,this),t.off(l.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(l.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(l.ERROR,this.onError,this)}onMediaAttached(t,e){this.media=e.media,this.media&&(this.queuedDefaultTrack>-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))}pollTrackChange(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,t)}onMediaDetaching(t,e){const s=this.media;if(!s)return;const i=!!e.transferMedia;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||s.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),this.subtitleTrack=-1,this.media=null,i||ra(s.textTracks).forEach(t=>{sa(t)})}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.subtitleTracks}onSubtitleTrackLoaded(t,e){const{id:s,groupId:i,details:r}=e,n=this.tracksInGroup[s];if(!n||n.groupId!==i)return void this.warn(`Subtitle track with id:${s} and group:${i} not found in active group ${null==n?void 0:n.groupId}`);const a=n.details;n.details=e.details,this.log(`Subtitle track ${s} "${n.name}" lang:${n.lang} group:${i} loaded [${r.startSN}-${r.endSN}]`),s===this.trackId&&this.playlistLoaded(s,e,a)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!e)return;const s=e.subtitleGroups||null,i=this.groupIds;let r=this.currentTrack;if(!s||(null==i?void 0:i.length)!==(null==s?void 0:s.length)||null!=s&&s.some(t=>-1===(null==i?void 0:i.indexOf(t)))){this.groupIds=s,this.trackId=-1,this.currentTrack=null;const t=this.tracks.filter(t=>!s||-1!==s.indexOf(t.groupId));if(t.length)this.selectDefaultTrack&&!t.some(t=>t.default)&&(this.selectDefaultTrack=!1),t.forEach((t,e)=>{t.id=e});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=t;const e=this.hls.config.subtitlePreference;if(!r&&e){this.selectDefaultTrack=!1;const s=Qt(e,t);if(s>-1)r=t[s];else{const t=Qt(e,this.tracks);r=this.tracks[t]}}let i=this.findTrackId(r);-1===i&&r&&(i=this.findTrackId(null));const n={subtitleTracks:t};this.log(`Updating subtitle tracks, ${t.length} track(s) found in "${null==s?void 0:s.join(",")}" group-id`),this.hls.trigger(l.SUBTITLE_TRACKS_UPDATED,n),-1!==i&&-1===this.trackId&&this.setSubtitleTrack(i)}}findTrackId(t){const e=this.tracksInGroup,s=this.selectDefaultTrack;for(let i=0;i<e.length;i++){const r=e[i];if((!s||r.default)&&(s||t)&&(!t||Zt(r,t)))return i}if(t){for(let s=0;s<e.length;s++){const i=e[s];if(Gr(t.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<e.length;s++){const i=e[s];if(Gr(t.attrs,i.attrs,["LANGUAGE"]))return s}}return-1}findTrackForTextTrack(t){if(t){const e=this.tracksInGroup;for(let s=0;s<e.length;s++)if(Wr(e[s],t))return s}return-1}onError(t,e){!e.fatal&&e.context&&(e.context.type!==u||e.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(e.context.groupId)||this.checkRetry(e))}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(t){this.selectDefaultTrack=!1,this.setSubtitleTrack(t)}setSubtitleOption(t){if(this.hls.config.subtitlePreference=t,t){if(-1===t.id)return this.setSubtitleTrack(-1),null;const e=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,e.length){const s=this.currentTrack;if(s&&Zt(t,s))return s;const i=Qt(t,this.tracksInGroup);if(i>-1){const t=this.tracksInGroup[i];return this.setSubtitleTrack(i),t}if(s)return null;{const s=Qt(t,e);if(s>-1)return e[s]}}}return null}loadPlaylist(t){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentTrack)&&this.scheduleLoading(this.currentTrack,t)}loadingPlaylist(t,e){super.loadingPlaylist(t,e);const s=t.id,i=t.groupId,r=this.getUrlWithDirectives(t.url,e),n=t.details,a=null==n?void 0:n.age;this.log(`Loading subtitle ${s} "${t.name}" lang:${t.lang} group:${i}${void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:""}${a&&n.live?" age "+a.toFixed(1)+(n.type?" "+n.type||0:""):""} ${r}`),this.hls.trigger(l.SUBTITLE_TRACK_LOADING,{url:r,id:s,groupId:i,deliveryDirectives:e||null,track:t})}toggleTrackModes(){const{media:t}=this;if(!t)return;const e=ra(t.textTracks),s=this.currentTrack;let i;if(s&&(i=e.filter(t=>Wr(s,t))[0],i||this.warn(`Unable to find subtitle TextTrack with name "${s.name}" and language "${s.lang}"`)),[].slice.call(e).forEach(t=>{"disabled"!==t.mode&&t!==i&&(t.mode="disabled")}),i){const t=this.subtitleDisplay?"showing":"hidden";i.mode!==t&&(i.mode=t)}}setSubtitleTrack(t){const e=this.tracksInGroup;if(!this.media)return void(this.queuedDefaultTrack=t);if(t<-1||t>=e.length||!i(t))return void this.warn(`Invalid subtitle track id: ${t}`);this.selectDefaultTrack=!1;const s=this.currentTrack,r=e[t]||null;if(this.trackId=t,this.currentTrack=r,this.toggleTrackModes(),!r)return void this.hls.trigger(l.SUBTITLE_TRACK_SWITCH,{id:t});const n=!!r.details&&!r.details.live;if(t===this.trackId&&r===s&&n)return;this.log(`Switching to subtitle-track ${t}`+(r?` "${r.name}" lang:${r.lang} group:${r.groupId}`:""));const{id:a,groupId:o="",name:h,type:c,url:d}=r;this.hls.trigger(l.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:h,type:c,url:d});const u=this.switchParams(r.url,null==s?void 0:s.details,r.details);this.loadPlaylist(u)}},timelineController:class{constructor(t){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},t.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(l.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(l.FRAG_LOADING,this.onFragLoading,this),t.on(l.FRAG_LOADED,this.onFragLoaded,this),t.on(l.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(l.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(l.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(l.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(l.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:t}=this;t.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(l.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(l.FRAG_LOADING,this.onFragLoading,this),t.off(l.FRAG_LOADED,this.onFragLoaded,this),t.off(l.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(l.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(l.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(l.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(l.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.media=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){const t=new co(this,"textTrack1"),e=new co(this,"textTrack2"),s=new co(this,"textTrack3"),i=new co(this,"textTrack4");this.cea608Parser1=new Na(1,t,e),this.cea608Parser2=new Na(3,s,i)}addCues(t,e,s,i,r){let n=!1;for(let t=r.length;t--;){const i=r[t],a=fo(i[0],i[1],e,s);if(a>=0&&(i[0]=Math.min(i[0],e),i[1]=Math.max(i[1],s),n=!0,a/(s-e)>.5))return}if(n||r.push([e,s]),this.config.renderTextTracksNatively){const r=this.captionsTracks[t];this.Cues.newCue(r,e,s,i)}else{const r=this.Cues.newCue(null,e,s,i);this.hls.trigger(l.CUES_PARSED,{type:"captions",cues:r,track:t})}}onInitPtsFound(t,{frag:e,id:s,initPTS:i,timescale:r,trackId:n}){const{unparsedVttFrags:a}=this;s===p&&(this.initPTS[e.cc]={baseTime:i,timescale:r,trackId:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(t=>{this.initPTS[t.frag.cc]?this.onFragLoaded(l.FRAG_LOADED,t):this.hls.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t.frag,error:new Error("Subtitle discontinuity domain does not match main")})}))}getExistingTrack(t,e){const{media:s}=this;if(s)for(let i=0;i<s.textTracks.length;i++){const r=s.textTracks[i];if(po(r,{name:t,lang:e,characteristics:"transcribes-spoken-dialog,describes-music-and-sound"}))return r}return null}createCaptionsTrack(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)}createNativeTrack(t){if(this.captionsTracks[t])return;const{captionsProperties:e,captionsTracks:s,media:i}=this,{label:r,languageCode:n}=e[t],a=this.getExistingTrack(r,n);if(a)s[t]=a,sa(s[t]),ta(s[t],i);else{const e=this.createTextTrack("captions",r,n);e&&(e[t]=!0,s[t]=e)}}createNonNativeTrack(t){if(this.nonNativeCaptionsTracks[t])return;const e=this.captionsProperties[t];if(!e)return;const s={_id:t,label:e.label,kind:"captions",default:!!e.media&&!!e.media.default,closedCaptions:e.media};this.nonNativeCaptionsTracks[t]=s,this.hls.trigger(l.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(t,e,s){const i=this.media;if(i)return i.addTextTrack(t,e,s)}onMediaAttaching(t,e){this.media=e.media,e.mediaSource||this._cleanTracks()}onMediaDetaching(t,e){const s=!!e.transferMedia;if(this.media=null,s)return;const{captionsTracks:i}=this;Object.keys(i).forEach(t=>{sa(i[t]),delete i[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=[],this.initPTS=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())}_cleanTracks(){const{media:t}=this;if(!t)return;const e=t.textTracks;if(e)for(let t=0;t<e.length;t++)sa(e[t])}onSubtitleTracksUpdated(t,e){const s=e.subtitleTracks||[],i=s.some(t=>t.textCodec===Ja);if(this.config.enableWebVTT||i&&this.config.enableIMSC1){if(Vr(this.tracks,s))return void(this.tracks=s);if(this.textTracks=[],this.tracks=s,this.config.renderTextTracksNatively){const t=this.media,e=t?ra(t.textTracks):null;if(this.tracks.forEach((t,s)=>{let i;if(e){let s=null;for(let i=0;i<e.length;i++)if(e[i]&&po(e[i],t)){s=e[i],e[i]=null;break}s&&(i=s)}if(i)sa(i);else{const e=uo(t);i=this.createTextTrack(e,t.name,t.lang),i&&(i.mode="disabled")}i&&this.textTracks.push(i)}),null!=e&&e.length){const t=e.filter(t=>null!==t).map(t=>t.label);t.length&&this.hls.logger.warn(`Media element contains unused subtitle tracks: ${t.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const t=this.tracks.map(t=>({label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t}));this.hls.trigger(l.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:t})}}}onManifestLoaded(t,e){this.config.enableCEA708Captions&&e.captions&&e.captions.forEach(t=>{const e=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(!e)return;const s=`textTrack${e[1]}`,i=this.captionsProperties[s];i&&(i.label=t.name,t.lang&&(i.languageCode=t.lang),i.media=t)})}closedCaptionsForLevel(t){const e=this.hls.levels[t.level];return null==e?void 0:e.attrs["CLOSED-CAPTIONS"]}onFragLoading(t,e){if(this.enabled&&e.frag.type===p){var s,i;const{cea608Parser1:t,cea608Parser2:r,lastSn:n}=this,{cc:a,sn:o}=e.frag,l=null!=(s=null==(i=e.part)?void 0:i.index)?s:-1;t&&r&&(o!==n+1||o===n&&l!==this.lastPartIndex+1||a!==this.lastCc)&&(t.reset(),r.reset()),this.lastCc=a,this.lastSn=o,this.lastPartIndex=l}}onFragLoaded(t,e){const{frag:s,payload:i}=e;if(s.type===g)if(i.byteLength){const t=s.decryptdata,r="stats"in e;if(null==t||!t.encrypted||r){const t=this.tracks[s.level],r=this.vttCCs;r[s.cc]||(r[s.cc]={start:s.start,prevCC:this.prevCC,new:!0},this.prevCC=s.cc),t&&t.textCodec===Ja?this._parseIMSC1(s,i):this._parseVTTs(e)}}else this.hls.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:new Error("Empty subtitle payload")})}_parseIMSC1(t,e){const s=this.hls;io(e,this.initPTS[t.cc],e=>{this._appendCues(e,t.level),s.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})},e=>{s.logger.log(`Failed to parse IMSC1: ${e}`),s.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:e})})}_parseVTTs(t){var e;const{frag:s,payload:r}=t,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[s.cc]&&-1===o)return void a.push(t);const h=this.hls;!function(t,e,s,r,n,a,o){const l=new Ya,h=x(new Uint8Array(t)).trim().replace(Xa,"\n").split("\n"),c=[],d=e?function(t,e=1){return Tr(t,9e4,1/e)}(e.baseTime,e.timescale):0;let u,p="00:00.000",f=0,g=0,m=!0;l.oncue=function(t){const i=s[r];let a=s.ccOffset;const o=(f-d)/9e4;if(null!=i&&i.new&&(void 0!==g?a=s.ccOffset=i.start:function(t,e,s){let i=t[e],r=t[i.prevCC];if(!r||!r.new&&i.new)return t.ccOffset=t.presentationOffset=i.start,void(i.new=!1);for(;null!=(n=r)&&n.new;){var n;t.ccOffset+=i.start-r.start,i.new=!1,i=r,r=t[i.prevCC]}t.presentationOffset=s}(s,r,o)),o){if(!e)return void(u=new Error("Missing initPTS for VTT MPEGTS"));a=o-s.presentationOffset}const l=t.endTime-t.startTime,h=Ir(9e4*(t.startTime+a-g),9e4*n)/9e4;t.startTime=Math.max(h,0),t.endTime=Math.max(h+l,0);const p=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(p)),t.id||(t.id=Za(t.startTime,t.endTime,p)),t.endTime>0&&c.push(t)},l.onparsingerror=function(t){u=t},l.onflush=function(){u?o(u):a(c)},h.forEach(t=>{if(m){if(Qa(t,"X-TIMESTAMP-MAP=")){m=!1,t.slice(16).split(",").forEach(t=>{Qa(t,"LOCAL:")?p=t.slice(6):Qa(t,"MPEGTS:")&&(f=parseInt(t.slice(7)))});try{g=function(t){let e=parseInt(t.slice(-3));const s=parseInt(t.slice(-6,-4)),r=parseInt(t.slice(-9,-7)),n=t.length>9?parseInt(t.substring(0,t.indexOf(":"))):0;if(!(i(e)&&i(s)&&i(r)&&i(n)))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${t}`);return e+=1e3*s,e+=6e4*r,e+=36e5*n,e}(p)/1e3}catch(t){u=t}return}""===t&&(m=!1)}l.parse(t+"\n")}),l.flush()}(null!=(e=s.initSegment)&&e.data?dt(s.initSegment.data,new Uint8Array(r)).buffer:r,this.initPTS[s.cc],this.vttCCs,s.cc,s.start,t=>{this._appendCues(t,s.level),h.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:s})},e=>{const i="Missing initPTS for VTT MPEGTS"===e.message;i?a.push(t):this._fallbackToIMSC1(s,r),h.logger.log(`Failed to parse VTT cue: ${e}`),i&&o>s.cc||h.trigger(l.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:e})})}_fallbackToIMSC1(t,e){const s=this.tracks[t.level];s.textCodec||io(e,this.initPTS[t.cc],()=>{s.textCodec=Ja,this._parseIMSC1(t,e)},()=>{s.textCodec="wvtt"})}_appendCues(t,e){const s=this.hls;if(this.config.renderTextTracksNatively){const s=this.textTracks[e];if(!s||"disabled"===s.mode)return;t.forEach(t=>ea(s,t))}else{const i=this.tracks[e];if(!i)return;const r=i.default?"default":"subtitles"+e;s.trigger(l.CUES_PARSED,{type:"subtitles",cues:t,track:r})}}onFragDecrypted(t,e){const{frag:s}=e;s.type===g&&this.onFragLoaded(l.FRAG_LOADED,e)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(t,e){if(!this.enabled||!this.config.enableCEA708Captions)return;const{frag:s,samples:i}=e;if(s.type!==p||"NONE"!==this.closedCaptionsForLevel(s))for(let t=0;t<i.length;t++){const e=i[t].bytes;if(e){this.cea608Parser1||this.initCea608Parsers();const s=this.extractCea608Data(e);this.cea608Parser1.addData(i[t].pts,s[0]),this.cea608Parser2.addData(i[t].pts,s[1])}}}onBufferFlushing(t,{startOffset:e,endOffset:s,endOffsetSubtitles:i,type:r}){const{media:n}=this;if(n&&!(n.currentTime<s)){if(!r||"video"===r){const{captionsTracks:t}=this;Object.keys(t).forEach(i=>ia(t[i],e,s))}if(this.config.renderTextTracksNatively&&0===e&&void 0!==i){const{textTracks:t}=this;Object.keys(t).forEach(s=>ia(t[s],e,i))}}}extractCea608Data(t){const e=[[],[]],s=31&t[0];let i=2;for(let r=0;r<s;r++){const s=t[i++],r=127&t[i++],n=127&t[i++];if((0!==r||0!==n)&&4&s){const t=3&s;0!==t&&1!==t||(e[t].push(r),e[t].push(n))}}return e}},audioStreamController:class extends ui{constructor(t,e,s){super(t,e,s,"audio-stream-controller",f),this.mainAnchor=null,this.mainFragLoading=null,this.audioOnly=!1,this.bufferedTrack=null,this.switchingTrack=null,this.trackId=-1,this.waitingData=null,this.mainDetails=null,this.flushing=!1,this.bufferFlushed=!1,this.cachedTrackLoadedData=null,this.registerListeners()}onHandlerDestroying(){this.unregisterListeners(),super.onHandlerDestroying(),this.resetItem()}resetItem(){this.mainDetails=this.mainAnchor=this.mainFragLoading=this.bufferedTrack=this.switchingTrack=this.waitingData=this.cachedTrackLoadedData=null}registerListeners(){super.registerListeners();const{hls:t}=this;t.on(l.LEVEL_LOADED,this.onLevelLoaded,this),t.on(l.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(l.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(l.BUFFER_RESET,this.onBufferReset,this),t.on(l.BUFFER_CREATED,this.onBufferCreated,this),t.on(l.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(l.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(l.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(l.FRAG_LOADING,this.onFragLoading,this),t.on(l.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){const{hls:t}=this;t&&(super.unregisterListeners(),t.off(l.LEVEL_LOADED,this.onLevelLoaded,this),t.off(l.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(l.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(l.BUFFER_RESET,this.onBufferReset,this),t.off(l.BUFFER_CREATED,this.onBufferCreated,this),t.off(l.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(l.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(l.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(l.FRAG_LOADING,this.onFragLoading,this),t.off(l.FRAG_BUFFERED,this.onFragBuffered,this))}onInitPtsFound(t,{frag:e,id:s,initPTS:i,timescale:r,trackId:n}){if(s===p){const t=e.cc,s=this.fragCurrent;if(this.initPTS[t]={baseTime:i,timescale:r,trackId:n},this.log(`InitPTS for cc: ${t} found from main: ${i/r} (${i}/${r}) trackId: ${n}`),this.mainAnchor=e,this.state===ci){const s=this.waitingData;(!s&&!this.loadingParts||s&&s.frag.cc!==t)&&this.syncWithAnchor(e,null==s?void 0:s.frag)}else!this.hls.hasEnoughToStart&&s&&s.cc!==t?(s.abortRequests(),this.syncWithAnchor(e,s)):this.state===ei&&this.tick()}}getLoadPosition(){return!this.startFragRequested&&this.nextLoadPosition>=0?this.nextLoadPosition:super.getLoadPosition()}syncWithAnchor(t,e){var s;const i=(null==(s=this.mainFragLoading)?void 0:s.frag)||null;if(e&&(null==i?void 0:i.cc)===e.cc)return;const r=(i||t).cc,n=ae(this.getLevelDetails(),r,this.getLoadPosition());n&&(this.log(`Syncing with main frag at ${n.start} cc ${n.cc}`),this.startFragRequested=!1,this.nextLoadPosition=n.start,this.resetLoadingState(),this.state===ei&&this.doTickIdle())}startLoad(t,e){if(!this.levels)return this.startPosition=t,void(this.state=ti);const s=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),s>0&&-1===t?(this.log(`Override startPosition with lastCurrentTime @${s.toFixed(3)}`),t=s,this.state=ei):this.state=ni,this.nextLoadPosition=this.lastCurrentTime=t+this.timelineOffset,this.startPosition=e?-1:t,this.tick()}doTick(){switch(this.state){case ei:this.doTickIdle();break;case ni:{const{levels:t,trackId:e}=this,s=null==t?void 0:t[e],i=null==s?void 0:s.details;if(i&&!this.waitForLive(s)){if(this.waitForCdnTuneIn(i))break;this.state=ci}break}case ri:this.checkRetryDate();break;case ci:{const t=this.waitingData;if(t){const{frag:e,part:s,cache:i,complete:r}=t,n=this.mainAnchor;if(void 0!==this.initPTS[e.cc]){this.waitingData=null,this.state=ii;const t={frag:e,part:s,payload:i.flush().buffer,networkDetails:null};this._handleFragmentLoadProgress(t),r&&super._handleFragmentLoadComplete(t)}else n&&n.cc!==t.frag.cc&&this.syncWithAnchor(n,t.frag)}else this.state=ei}}this.onTickEnd()}resetLoadingState(){const t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null),super.resetLoadingState()}onTickEnd(){const{media:t}=this;null!=t&&t.readyState&&(this.lastCurrentTime=t.currentTime)}doTickIdle(){var t;const{hls:e,levels:s,media:i,trackId:r}=this,n=e.config;if(!this.buffering||!i&&!this.primaryPrefetch&&(this.startFragRequested||!n.startFragPrefetch)||null==s||!s[r])return;const a=s[r],o=a.details;if(!o||this.waitForLive(a)||this.waitForCdnTuneIn(o))return this.state=ni,void(this.startFragRequested=!1);const h=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&h&&(this.bufferFlushed=!1,this.afterBufferFlushed(h,j,f));const c=this.getFwdBufferInfo(h,f);if(null===c)return;if(!this.switchingTrack&&this._streamEnded(c,o))return e.trigger(l.BUFFER_EOS,{type:"audio"}),void(this.state=li);const d=c.len,u=e.maxBufferLength,g=o.fragments,m=g[0].start,y=this.getLoadPosition(),v=this.flushing?y:c.end;if(this.switchingTrack&&i){const t=y;o.PTSKnown&&t<m&&(c.end>m||c.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),i.currentTime=m+.05)}if(d>=u&&!this.switchingTrack&&v<g[g.length-1].start)return;let b=this.getNextFragment(v,o);if(b&&this.isLoopLoading(b,v)&&(b=this.getNextFragmentLoopLoading(b,o,c,p,u)),!b)return void(this.bufferFlushed=!0);let _=(null==(t=this.mainFragLoading)?void 0:t.frag)||null;if(!this.audioOnly&&this.startFragRequested&&_&&V(b)&&!b.endList&&(!o.live||!this.loadingParts&&v<this.hls.liveSyncPosition)&&(this.fragmentTracker.getState(_)===be&&(this.mainFragLoading=_=null),_&&V(_))){if(b.start>_.end){const t=this.fragmentTracker.getFragAtPos(v,p);t&&t.end>_.end&&(_=t,this.mainFragLoading={frag:t,targetBufferTime:null})}if(b.start>_.end)return}this.loadFragment(b,a,v)}onMediaDetaching(t,e){this.bufferFlushed=this.flushing=!1,super.onMediaDetaching(t,e)}onAudioTracksUpdated(t,{audioTracks:e}){this.resetTransmuxer(),this.levels=e.map(t=>new Wt(t))}onAudioTrackSwitching(t,e){const s=!!e.url;this.trackId=e.id;const{fragCurrent:i}=this;i&&(i.abortRequests(),this.removeUnbufferedFrags(i.start)),this.resetLoadingState(),s?(this.switchingTrack=e,this.flushAudioIfNeeded(e),this.state!==ti&&(this.setInterval(100),this.state=ei,this.tick())):(this.resetTransmuxer(),this.switchingTrack=null,this.bufferedTrack=e,this.clearInterval())}onManifestLoading(){super.onManifestLoading(),this.bufferFlushed=this.flushing=this.audioOnly=!1,this.resetItem(),this.trackId=-1}onLevelLoaded(t,e){this.mainDetails=e.details;const s=this.cachedTrackLoadedData;s&&(this.cachedTrackLoadedData=null,this.onAudioTrackLoaded(l.AUDIO_TRACK_LOADED,s))}onAudioTrackLoaded(t,e){var s;const{levels:i}=this,{details:r,id:n,groupId:a,track:o}=e;if(!i)return void this.warn(`Audio tracks reset while loading track ${n} "${o.name}" of "${a}"`);const h=this.mainDetails;if(!h||r.endCC>h.endCC||h.expired)return this.cachedTrackLoadedData=e,void(this.state!==ti&&(this.state=ni));this.cachedTrackLoadedData=null,this.log(`Audio track ${n} "${o.name}" of "${a}" loaded [${r.startSN},${r.endSN}]${r.lastPartSn?`[part-${r.lastPartSn}-${r.lastPartIndex}]`:""},duration:${r.totalduration}`);const c=i[n];let d=0;if(r.live||null!=(s=c.details)&&s.live){if(this.checkLiveUpdate(r),r.deltaUpdateFailed)return;var u;c.details&&(d=this.alignPlaylists(r,c.details,null==(u=this.levelLastLoaded)?void 0:u.details)),r.alignedSliding||(Xs(r,h),r.alignedSliding||Qs(r,h),d=r.fragmentStart)}c.details=r,this.levelLastLoaded=c,this.startFragRequested||this.setStartPosition(h,d),this.hls.trigger(l.AUDIO_TRACK_UPDATED,{details:r,id:n,groupId:e.groupId}),this.state!==ni||this.waitForCdnTuneIn(r)||(this.state=ei),this.tick()}_handleFragmentLoadProgress(t){var e;const s=t.frag,{part:i,payload:r}=t,{config:n,trackId:a,levels:o}=this;if(!o)return void this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);const l=o[a];if(!l)return void this.warn("Audio track is undefined on fragment load progress");const h=l.details;if(!h)return this.warn("Audio track details undefined on fragment load progress"),void this.removeUnbufferedFrags(s.start);const c=n.defaultAudioCodec||l.audioCodec||"mp4a.40.2";let d=this.transmuxer;d||(d=this.transmuxer=new Ur(this.hls,f,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const u=this.initPTS[s.cc],p=null==(e=s.initSegment)?void 0:e.data;if(void 0!==u){const t=!1,e=i?i.index:-1,n=-1!==e,a=new Oe(s.level,s.sn,s.stats.chunkCount,r.byteLength,e,n);d.push(r,p,c,"",s,i,h.totalduration,t,a,u)}else{this.log(`Unknown video PTS for cc ${s.cc}, waiting for video PTS before demuxing audio frag ${s.sn} of [${h.startSN} ,${h.endSN}],track ${a}`);const{cache:t}=this.waitingData=this.waitingData||{frag:s,part:i,cache:new fi,complete:!1};t.push(new Uint8Array(r)),this.state!==ti&&(this.state=ci)}}_handleFragmentLoadComplete(t){this.waitingData?this.waitingData.complete=!0:super._handleFragmentLoadComplete(t)}onBufferReset(){this.mediaBuffer=null}onBufferCreated(t,e){this.bufferFlushed=this.flushing=!1;const s=e.tracks.audio;s&&(this.mediaBuffer=s.buffer||null)}onFragLoading(t,e){!this.audioOnly&&e.frag.type===p&&V(e.frag)&&(this.mainFragLoading=e,this.state===ei&&this.tick())}onFragBuffered(t,e){const{frag:s,part:i}=e;if(s.type===f)if(this.fragContextChanged(s))this.warn(`Fragment ${s.sn}${i?" p: "+i.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);else{if(V(s)){this.fragPrevious=s;const t=this.switchingTrack;t&&(this.bufferedTrack=t,this.switchingTrack=null,this.hls.trigger(l.AUDIO_TRACK_SWITCHED,T({},t)))}this.fragBufferedComplete(s,i),this.media&&this.tick()}else this.audioOnly||s.type!==p||s.elementaryStreams.video||s.elementaryStreams.audiovideo||(this.audioOnly=!0,this.mainFragLoading=null)}onError(t,e){var s;if(e.fatal)this.state=hi;else switch(e.details){case o.FRAG_GAP:case o.FRAG_PARSING_ERROR:case o.FRAG_DECRYPT_ERROR:case o.FRAG_LOAD_ERROR:case o.FRAG_LOAD_TIMEOUT:case o.KEY_LOAD_ERROR:case o.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(f,e);break;case o.AUDIO_TRACK_LOAD_ERROR:case o.AUDIO_TRACK_LOAD_TIMEOUT:case o.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==ni||(null==(s=e.context)?void 0:s.type)!==d||(this.state=ei);break;case o.BUFFER_ADD_CODEC_ERROR:case o.BUFFER_APPEND_ERROR:if("audio"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)||this.resetLoadingState();break;case o.BUFFER_FULL_ERROR:if("audio"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case o.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}onBufferFlushing(t,{type:e}){e!==$&&(this.flushing=!0)}onBufferFlushed(t,{type:e}){if(e!==$){this.flushing=!1,this.bufferFlushed=!0,this.state===li&&(this.state=ei);const t=this.mediaBuffer||this.media;t&&(this.afterBufferFlushed(t,e,f),this.tick())}}_handleTransmuxComplete(t){var e;const s="audio",{hls:i}=this,{remuxResult:r,chunkMeta:n}=t,a=this.getCurrentContext(n);if(!a)return void this.resetWhenMissingContext(n);const{frag:o,part:h,level:c}=a,{details:d}=c,{audio:u,text:p,id3:f,initSegment:g}=r;if(!this.fragContextChanged(o)&&d){if(this.state=ai,this.switchingTrack&&u&&this.completeAudioSwitch(this.switchingTrack),null!=g&&g.tracks){const t=o.initSegment||o;if(this.unhandledEncryptionError(g,o))return;this._bufferInitSegment(c,g.tracks,t,n),i.trigger(l.FRAG_PARSING_INIT_SEGMENT,{frag:t,id:s,tracks:g.tracks})}if(u){const{startPTS:t,endPTS:e,startDTS:s,endDTS:i}=u;h&&(h.elementaryStreams[j]={startPTS:t,endPTS:e,startDTS:s,endDTS:i}),o.setElementaryStreamInfo(j,t,e,s,i),this.bufferFragmentData(u,o,h,n)}if(null!=f&&null!=(e=f.samples)&&e.length){const t=b({id:s,frag:o,details:d},f);i.trigger(l.FRAG_PARSING_METADATA,t)}if(p){const t=b({id:s,frag:o,details:d},p);i.trigger(l.FRAG_PARSING_USERDATA,t)}}else this.fragmentTracker.removeFragment(o)}_bufferInitSegment(t,e,s,i){if(this.state!==ai)return;if(e.video&&delete e.video,e.audiovideo&&delete e.audiovideo,!e.audio)return;const r=e.audio;r.id=f;const n=t.audioCodec;this.log(`Init audio buffer, container:${r.container}, codecs[level/parsed]=[${n}/${r.codec}]`),n&&1===n.split(",").length&&(r.levelCodec=n),this.hls.trigger(l.BUFFER_CODECS,e);const a=r.initSegment;if(null!=a&&a.byteLength){const t={type:"audio",frag:s,part:null,chunkMeta:i,parent:s.type,data:a};this.hls.trigger(l.BUFFER_APPENDING,t)}this.tickImmediate()}loadFragment(t,e,s){const i=this.fragmentTracker.getState(t);var r;if(this.switchingTrack||i===me||i===ve)if(V(t))if(null!=(r=e.details)&&r.live&&!this.initPTS[t.cc]){this.log(`Waiting for video PTS in continuity counter ${t.cc} of live stream before loading audio fragment ${t.sn} of level ${this.trackId}`),this.state=ci;const s=this.mainDetails;s&&s.fragmentStart!==e.details.fragmentStart&&Qs(e.details,s)}else super.loadFragment(t,e,s);else this._loadInitSegment(t,e);else this.clearTrackerIfNeeded(t)}flushAudioIfNeeded(t){if(this.media&&this.bufferedTrack){const{name:e,lang:s,assocLang:i,characteristics:r,audioCodec:n,channels:a}=this.bufferedTrack;Zt({name:e,lang:s,assocLang:i,characteristics:r,audioCodec:n,channels:a},t,Jt)||(ee(t.url,this.hls)?(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null):this.bufferedTrack=t)}}completeAudioSwitch(t){const{hls:e}=this;this.flushAudioIfNeeded(t),this.bufferedTrack=t,this.switchingTrack=null,e.trigger(l.AUDIO_TRACK_SWITCHED,T({},t))}},audioTrackController:class extends Hr{constructor(t){super(t,"audio-track-controller"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:t}=this;t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.MANIFEST_PARSED,this.onManifestParsed,this),t.on(l.LEVEL_LOADING,this.onLevelLoading,this),t.on(l.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(l.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(l.ERROR,this.onError,this)}unregisterListeners(){const{hls:t}=this;t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.MANIFEST_PARSED,this.onManifestParsed,this),t.off(l.LEVEL_LOADING,this.onLevelLoading,this),t.off(l.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(l.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(l.ERROR,this.onError,this)}destroy(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.currentTrack=null,super.destroy()}onManifestLoading(){this.tracks=[],this.tracksInGroup=[],this.groupIds=null,this.currentTrack=null,this.trackId=-1,this.selectDefaultTrack=!0}onManifestParsed(t,e){this.tracks=e.audioTracks||[]}onAudioTrackLoaded(t,e){const{id:s,groupId:i,details:r}=e,n=this.tracksInGroup[s];if(!n||n.groupId!==i)return void this.warn(`Audio track with id:${s} and group:${i} not found in active group ${null==n?void 0:n.groupId}`);const a=n.details;n.details=e.details,this.log(`Audio track ${s} "${n.name}" lang:${n.lang} group:${i} loaded [${r.startSN}-${r.endSN}]`),s===this.trackId&&this.playlistLoaded(s,e,a)}onLevelLoading(t,e){this.switchLevel(e.level)}onLevelSwitching(t,e){this.switchLevel(e.level)}switchLevel(t){const e=this.hls.levels[t];if(!e)return;const s=e.audioGroups||null,i=this.groupIds;let r=this.currentTrack;if(!s||(null==i?void 0:i.length)!==(null==s?void 0:s.length)||null!=s&&s.some(t=>-1===(null==i?void 0:i.indexOf(t)))){this.groupIds=s,this.trackId=-1,this.currentTrack=null;const t=this.tracks.filter(t=>!s||-1!==s.indexOf(t.groupId));if(t.length)this.selectDefaultTrack&&!t.some(t=>t.default)&&(this.selectDefaultTrack=!1),t.forEach((t,e)=>{t.id=e});else if(!r&&!this.tracksInGroup.length)return;this.tracksInGroup=t;const e=this.hls.config.audioPreference;if(!r&&e){const s=Qt(e,t,Jt);if(s>-1)r=t[s];else{const t=Qt(e,this.tracks);r=this.tracks[t]}}let i=this.findTrackId(r);-1===i&&r&&(i=this.findTrackId(null));const h={audioTracks:t};this.log(`Updating audio tracks, ${t.length} track(s) found in group(s): ${null==s?void 0:s.join(",")}`),this.hls.trigger(l.AUDIO_TRACKS_UPDATED,h);const c=this.trackId;if(-1!==i&&-1===c)this.setAudioTrack(i);else if(t.length&&-1===c){var n;const e=new Error(`No audio track selected for current audio group-ID(s): ${null==(n=this.groupIds)?void 0:n.join(",")} track count: ${t.length}`);this.warn(e.message),this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:e})}}}onError(t,e){!e.fatal&&e.context&&(e.context.type!==d||e.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(e.context.groupId)||this.checkRetry(e))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}setAudioOption(t){const e=this.hls;if(e.config.audioPreference=t,t){const s=this.allAudioTracks;if(this.selectDefaultTrack=!1,s.length){const i=this.currentTrack;if(i&&Zt(t,i,Jt))return i;const r=Qt(t,this.tracksInGroup,Jt);if(r>-1){const t=this.tracksInGroup[r];return this.setAudioTrack(r),t}if(i){let i=e.loadLevel;-1===i&&(i=e.firstAutoLevel);const r=function(t,e,s,i,r){const n=e[i],a=e.reduce((t,e,s)=>{const i=e.uri;return(t[i]||(t[i]=[])).push(s),t},{})[n.uri];a.length>1&&(i=Math.max.apply(Math,a));const o=n.videoRange,l=n.frameRate,h=n.codecSet.substring(0,4),c=te(e,i,e=>{if(e.videoRange!==o||e.frameRate!==l||e.codecSet.substring(0,4)!==h)return!1;const i=e.audioGroups,n=s.filter(t=>!i||-1!==i.indexOf(t.groupId));return Qt(t,n,r)>-1});return c>-1?c:te(e,i,e=>{const i=e.audioGroups,n=s.filter(t=>!i||-1!==i.indexOf(t.groupId));return Qt(t,n,r)>-1})}(t,e.levels,s,i,Jt);if(-1===r)return null;e.nextLoadLevel=r}if(t.channels||t.audioCodec){const e=Qt(t,s);if(e>-1)return s[e]}}}return null}setAudioTrack(t){const e=this.tracksInGroup;if(t<0||t>=e.length)return void this.warn(`Invalid audio track id: ${t}`);this.selectDefaultTrack=!1;const s=this.currentTrack,i=e[t],r=i.details&&!i.details.live;if(t===this.trackId&&i===s&&r)return;if(this.log(`Switching to audio-track ${t} "${i.name}" lang:${i.lang} group:${i.groupId} channels:${i.channels}`),this.trackId=t,this.currentTrack=i,this.hls.trigger(l.AUDIO_TRACK_SWITCHING,T({},i)),r)return;const n=this.switchParams(i.url,null==s?void 0:s.details,i.details);this.loadPlaylist(n)}findTrackId(t){const e=this.tracksInGroup;for(let s=0;s<e.length;s++){const i=e[s];if((!this.selectDefaultTrack||i.default)&&(!t||Zt(t,i,Jt)))return s}if(t){const{name:s,lang:i,assocLang:r,characteristics:n,audioCodec:a,channels:o}=t;for(let t=0;t<e.length;t++)if(Zt({name:s,lang:i,assocLang:r,characteristics:n,audioCodec:a,channels:o},e[t],Jt))return t;for(let s=0;s<e.length;s++){const i=e[s];if(Gr(t.attrs,i.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<e.length;s++){const i=e[s];if(Gr(t.attrs,i.attrs,["LANGUAGE"]))return s}}return-1}loadPlaylist(t){super.loadPlaylist();const e=this.currentTrack;this.shouldLoadPlaylist(e)&&ee(e.url,this.hls)&&this.scheduleLoading(e,t)}loadingPlaylist(t,e){super.loadingPlaylist(t,e);const s=t.id,i=t.groupId,r=this.getUrlWithDirectives(t.url,e),n=t.details,a=null==n?void 0:n.age;this.log(`Loading audio-track ${s} "${t.name}" lang:${t.lang} group:${i}${void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:""}${a&&n.live?" age "+a.toFixed(1)+(n.type?" "+n.type||0:""):""} ${r}`),this.hls.trigger(l.AUDIO_TRACK_LOADING,{url:r,id:s,groupId:i,deliveryDirectives:e||null,track:t})}},emeController:Yn,cmcdController:class{constructor(t){this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=()=>{this.initialized&&(this.starved=!0),this.buffering=!0},this.onPlaying=()=>{this.initialized||(this.initialized=!0),this.buffering=!1},this.applyPlaylistData=t=>{try{this.apply(t,{ot:Jr,su:!this.initialized})}catch(t){this.hls.logger.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=t=>{try{const{frag:e,part:s}=t,i=this.hls.levels[e.level],r=this.getObjectType(e),n={d:1e3*(s||e).duration,ot:r};r!==en&&r!==tn&&r!=sn||(n.br=i.bitrate/1e3,n.tb=this.getTopBandwidth(r)/1e3,n.bl=this.getBufferLength(r));const a=s?this.getNextPart(s):this.getNextFrag(e);null!=a&&a.url&&a.url!==e.url&&(n.nor=a.url),this.apply(t,n)}catch(t){this.hls.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=t;const e=this.config=t.config,{cmcd:s}=e;null!=s&&(e.pLoader=this.createPlaylistLoader(),e.fLoader=this.createFragmentLoader(),this.sid=s.sessionId||t.sessionId,this.cid=s.contentId,this.useHeaders=!0===s.useHeaders,this.includeKeys=s.includeKeys,this.registerListeners())}registerListeners(){const t=this.hls;t.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(l.MEDIA_DETACHED,this.onMediaDetached,this),t.on(l.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const t=this.hls;t.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(l.MEDIA_DETACHED,this.onMediaDetached,this),t.off(l.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=this.media=null}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)}onMediaDetached(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)}onBufferCreated(t,e){var s,i;this.audioBuffer=null==(s=e.tracks.audio)?void 0:s.buffer,this.videoBuffer=null==(i=e.tracks.video)?void 0:i.buffer}createData(){var t;return{v:1,sf:an,sid:this.sid,cid:this.cid,pr:null==(t=this.media)?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(t,e={}){b(e,this.createData());const s=e.ot===rn||e.ot===en||e.ot===sn;this.starved&&s&&(e.bs=!0,e.su=!0,this.starved=!1),null==e.su&&(e.su=this.buffering);const{includeKeys:i}=this;i&&(e=Object.keys(e).reduce((t,s)=>(i.includes(s)&&(t[s]=e[s]),t),{}));const r={baseUrl:t.url};this.useHeaders?(t.headers||(t.headers={}),Gn(t.headers,e,r)):t.url=Kn(t.url,e,r)}getNextFrag(t){var e;const s=null==(e=this.hls.levels[t.level])?void 0:e.details;if(s){const e=t.sn-s.startSN;return s.fragments[e+1]}}getNextPart(t){var e;const{index:s,fragment:i}=t,r=null==(e=this.hls.levels[i.level])||null==(e=e.details)?void 0:e.partList;if(r){const{sn:t}=i;for(let e=r.length-1;e>=0;e--){const i=r[e];if(i.index===s&&i.fragment.sn===t)return r[e+1]}}}getObjectType(t){const{type:e}=t;return"subtitle"===e?nn:"initSegment"===t.sn?rn:"audio"===e?tn:"main"===e?this.hls.audioTracks.length?en:sn:void 0}getTopBandwidth(t){let e,s=0;const i=this.hls;if(t===tn)e=i.audioTracks;else{const t=i.maxAutoLevel,s=t>-1?t+1:i.levels.length;e=i.levels.slice(0,s)}return e.forEach(t=>{t.bitrate>s&&(s=t.bitrate)}),s>0?s:NaN}getBufferLength(t){const e=this.media,s=t===tn?this.audioBuffer:this.videoBuffer;return s&&e?1e3*Fe.bufferInfo(s,e.currentTime,this.config.maxBufferHole).len:NaN}createPlaylistLoader(){const{pLoader:t}=this.config,e=this.applyPlaylistData,s=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new s(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,s,i){e(t),this.loader.load(t,s,i)}}}createFragmentLoader(){const{fLoader:t}=this.config,e=this.applyFragmentData,s=t||this.config.loader;return class{constructor(t){this.loader=void 0,this.loader=new s(t)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(t,s,i){e(t),this.loader.load(t,s,i)}}}},contentSteeringController:class extends A{constructor(t){super("content-steering",t.logger),this.hls=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this._pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=t,this.registerListeners()}registerListeners(){const t=this.hls;t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(l.MANIFEST_PARSED,this.onManifestParsed,this),t.on(l.ERROR,this.onError,this)}unregisterListeners(){const t=this.hls;t&&(t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(l.MANIFEST_PARSED,this.onManifestParsed,this),t.off(l.ERROR,this.onError,this))}pathways(){return(this.levels||[]).reduce((t,e)=>(-1===t.indexOf(e.pathwayId)&&t.push(e.pathwayId),t),[])}get pathwayPriority(){return this._pathwayPriority}set pathwayPriority(t){this.updatePathwayPriority(t)}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const t=1e3*this.timeToLoad-(performance.now()-this.updated);if(t>0)return void this.scheduleRefresh(this.uri,t)}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(t){const e=this.levels;e&&(this.levels=e.filter(e=>e!==t))}onManifestLoading(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null}onManifestLoaded(t,e){const{contentSteering:s}=e;null!==s&&(this.pathwayId=s.pathwayId,this.uri=s.uri,this.started&&this.startLoad())}onManifestParsed(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks}onError(t,e){const{errorAction:s}=e;if(2===(null==s?void 0:s.action)&&1===s.flags){const t=this.levels;let i=this._pathwayPriority,r=this.pathwayId;if(e.context){const{groupId:s,pathwayId:i,type:n}=e.context;s&&t?r=this.getPathwayForGroupId(s,n,r):i&&(r=i)}r in this.penalizedPathways||(this.penalizedPathways[r]=performance.now()),!i&&t&&(i=this.pathways()),i&&i.length>1&&(this.updatePathwayPriority(i),s.resolved=this.pathwayId!==r),e.details!==o.BUFFER_APPEND_ERROR||e.fatal?s.resolved||this.warn(`Could not resolve ${e.details} ("${e.error.message}") with content-steering for Pathway: ${r} levels: ${t?t.length:t} priorities: ${zt(i)} penalized: ${zt(this.penalizedPathways)}`):s.resolved=!0}}filterParsedLevels(t){this.levels=t;let e=this.getLevelsForPathway(this.pathwayId);if(0===e.length){const s=t[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${s}"`),e=this.getLevelsForPathway(s),this.pathwayId=s}return e.length!==t.length&&this.log(`Found ${e.length}/${t.length} levels in Pathway "${this.pathwayId}"`),e}getLevelsForPathway(t){return null===this.levels?[]:this.levels.filter(e=>t===e.pathwayId)}updatePathwayPriority(t){let e;this._pathwayPriority=t;const s=this.penalizedPathways,i=performance.now();Object.keys(s).forEach(t=>{i-s[t]>3e5&&delete s[t]});for(let i=0;i<t.length;i++){const r=t[i];if(r in s)continue;if(r===this.pathwayId)return;const n=this.hls.nextLoadLevel,a=this.hls.levels[n];if(e=this.getLevelsForPathway(r),e.length>0){this.log(`Setting Pathway to "${r}"`),this.pathwayId=r,Gs(e),this.hls.trigger(l.LEVELS_UPDATED,{levels:e});const t=this.hls.levels[n];a&&t&&this.levels&&(t.attrs["STABLE-VARIANT-ID"]!==a.attrs["STABLE-VARIANT-ID"]&&t.bitrate!==a.bitrate&&this.log(`Unstable Pathways change from bitrate ${a.bitrate} to ${t.bitrate}`),this.hls.nextLoadLevel=n);break}}}getPathwayForGroupId(t,e,s){const i=this.getLevelsForPathway(s).concat(this.levels||[]);for(let s=0;s<i.length;s++)if(e===d&&i[s].hasAudioGroup(t)||e===u&&i[s].hasSubtitleGroup(t))return i[s].pathwayId;return s}clonePathways(t){const e=this.levels;if(!e)return;const s={},i={};t.forEach(t=>{const{ID:r,"BASE-ID":n,"URI-REPLACEMENT":a}=t;if(e.some(t=>t.pathwayId===r))return;const o=this.getLevelsForPathway(n).map(t=>{const e=new Ge(t.attrs);e["PATHWAY-ID"]=r;const n=e.AUDIO&&`${e.AUDIO}_clone_${r}`,o=e.SUBTITLES&&`${e.SUBTITLES}_clone_${r}`;n&&(s[e.AUDIO]=n,e.AUDIO=n),o&&(i[e.SUBTITLES]=o,e.SUBTITLES=o);const l=qn(t.uri,e["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",a),h=new Wt({attrs:e,audioCodec:t.audioCodec,bitrate:t.bitrate,height:t.height,name:t.name,url:l,videoCodec:t.videoCodec,width:t.width});if(t.audioGroups)for(let e=1;e<t.audioGroups.length;e++)h.addGroupId("audio",`${t.audioGroups[e]}_clone_${r}`);if(t.subtitleGroups)for(let e=1;e<t.subtitleGroups.length;e++)h.addGroupId("text",`${t.subtitleGroups[e]}_clone_${r}`);return h});e.push(...o),zn(this.audioTracks,s,a,r),zn(this.subtitleTracks,i,a,r)})}loadSteeringManifest(t){const e=this.hls.config,s=e.loader;let i;this.loader&&this.loader.destroy(),this.loader=new s(e);try{i=new self.URL(t)}catch(e){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest URI: ${t}`)}if("data:"!==i.protocol){const t=0|(this.hls.bandwidthEstimate||e.abrEwmaDefaultEstimate);i.searchParams.set("_HLS_pathway",this.pathwayId),i.searchParams.set("_HLS_throughput",""+t)}const r={responseType:"json",url:i.href},n=e.steeringManifestLoadPolicy.default,a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},h={onSuccess:(t,e,s,r)=>{this.log(`Loaded steering manifest: "${i}"`);const n=t.data;if(1!==(null==n?void 0:n.VERSION))return void this.log(`Steering VERSION ${n.VERSION} not supported!`);this.updated=performance.now(),this.timeToLoad=n.TTL;const{"RELOAD-URI":a,"PATHWAY-CLONES":o,"PATHWAY-PRIORITY":h}=n;if(a)try{this.uri=new self.URL(a,i).href}catch(t){return this.enabled=!1,void this.log(`Failed to parse Steering Manifest RELOAD-URI: ${a}`)}this.scheduleRefresh(this.uri||s.url),o&&this.clonePathways(o);const c={steeringManifest:n,url:i.toString()};this.hls.trigger(l.STEERING_MANIFEST_LOADED,c),h&&this.updatePathwayPriority(h)},onError:(t,e,s,i)=>{if(this.log(`Error loading steering manifest: ${t.code} ${t.text} (${e.url})`),this.stopLoad(),410===t.code)return this.enabled=!1,void this.log(`Steering manifest ${e.url} no longer available`);let r=1e3*this.timeToLoad;if(429===t.code){const t=this.loader;if("function"==typeof(null==t?void 0:t.getResponseHeader)){const e=t.getResponseHeader("Retry-After");e&&(r=1e3*parseFloat(e))}return void this.log(`Steering manifest ${e.url} rate limited`)}this.scheduleRefresh(this.uri||e.url,r)},onTimeout:(t,e,s)=>{this.log(`Timeout loading steering manifest (${e.url})`),this.scheduleRefresh(this.uri||e.url)}};this.log(`Requesting steering manifest: ${i}`),this.loader.load(r,o,h)}scheduleRefresh(t,e=1e3*this.timeToLoad){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var e;const s=null==(e=this.hls)?void 0:e.media;!s||s.ended?this.scheduleRefresh(t,1e3*this.timeToLoad):this.loadSteeringManifest(t)},e)}},interstitialsController:class extends A{constructor(t,e){super("interstitials",t.logger),this.HlsPlayerClass=void 0,this.hls=void 0,this.assetListLoader=void 0,this.mediaSelection=null,this.altSelection=null,this.media=null,this.detachedData=null,this.requiredTracks=null,this.manager=null,this.playerQueue=[],this.bufferedPos=-1,this.timelinePos=-1,this.schedule=void 0,this.playingItem=null,this.bufferingItem=null,this.waitingItem=null,this.endedItem=null,this.playingAsset=null,this.endedAsset=null,this.bufferingAsset=null,this.shouldPlay=!1,this.onPlay=()=>{this.shouldPlay=!0},this.onPause=()=>{this.shouldPlay=!1},this.onSeeking=()=>{const t=this.currentTime;if(void 0===t||this.playbackDisabled||!this.schedule)return;const e=t-this.timelinePos;if(Math.abs(e)<1/7056e5)return;const s=e<=-.01;this.timelinePos=t,this.bufferedPos=t;const i=this.playingItem;if(!i)return void this.checkBuffer();if(s&&this.schedule.resetErrorsInRange(t,t-e)&&this.updateSchedule(!0),this.checkBuffer(),s&&t<i.start||t>=i.end){var r;const e=this.findItemIndex(i);let n=this.schedule.findItemIndexAtTime(t);if(-1===n&&(n=e+(s?-1:1),this.log(`seeked ${s?"back ":""}to position not covered by schedule ${t} (resolving from ${e} to ${n})`)),!this.isInterstitial(i)&&null!=(r=this.media)&&r.paused&&(this.shouldPlay=!1),!s&&n>e){const t=this.schedule.findJumpRestrictedIndex(e+1,n);if(t>e)return void this.setSchedulePosition(t)}return void this.setSchedulePosition(n)}const n=this.playingAsset;if(!n){if(this.playingLastItem&&this.isInterstitial(i)){const e=i.event.assetList[0];e&&(this.endedItem=this.playingItem,this.playingItem=null,this.setScheduleToAssetAtTime(t,e))}return}const a=n.timelineStart,o=n.duration||0;var l;(s&&t<a||t>=a+o)&&(null!=(l=i.event)&&l.appendInPlace&&(this.clearAssetPlayers(i.event,i),this.flushFrontBuffer(t)),this.setScheduleToAssetAtTime(t,n))},this.onTimeupdate=()=>{const t=this.currentTime;if(void 0===t||this.playbackDisabled)return;if(!(t>this.timelinePos))return;this.timelinePos=t,t>this.bufferedPos&&this.checkBuffer();const e=this.playingItem;if(!e||this.playingLastItem)return;if(t>=e.end){this.timelinePos=e.end;const t=this.findItemIndex(e);this.setSchedulePosition(t+1)}const s=this.playingAsset;s&&t>=s.timelineStart+(s.duration||0)&&this.setScheduleToAssetAtTime(t,s)},this.onScheduleUpdate=(t,e)=>{const s=this.schedule;if(!s)return;const i=this.playingItem,r=s.events||[],n=s.items||[],a=s.durations,o=t.map(t=>t.identifier),h=!(!r.length&&!o.length);(h||e)&&this.log(`INTERSTITIALS_UPDATED (${r.length}): ${r}\nSchedule: ${n.map(t=>ma(t))} pos: ${this.timelinePos}`),o.length&&this.log(`Removed events ${o}`);let c=null,d=null;i&&(c=this.updateItem(i,this.timelinePos),this.itemsMatch(i,c)?this.playingItem=c:this.waitingItem=this.endedItem=null),this.waitingItem=this.updateItem(this.waitingItem),this.endedItem=this.updateItem(this.endedItem);const u=this.bufferingItem;if(u&&(d=this.updateItem(u,this.bufferedPos),this.itemsMatch(u,d)?this.bufferingItem=d:u.event&&(this.bufferingItem=this.playingItem,this.clearInterstitial(u.event,null))),t.forEach(t=>{t.assetList.forEach(t=>{this.clearAssetPlayer(t.identifier,null)})}),this.playerQueue.forEach(t=>{if(t.interstitial.appendInPlace){const e=t.assetItem.timelineStart,s=t.timelineOffset-e;if(s)try{t.timelineOffset=e}catch(i){Math.abs(s)>aa&&this.warn(`${i} ("${t.assetId}" ${t.timelineOffset}->${e})`)}}}),h||e){if(this.hls.trigger(l.INTERSTITIALS_UPDATED,{events:r.slice(0),schedule:n.slice(0),durations:a,removedIds:o}),this.isInterstitial(i)&&o.includes(i.event.identifier))return this.warn(`Interstitial "${i.event.identifier}" removed while playing`),void this.primaryFallback(i.event);i&&this.trimInPlace(c,i),u&&d!==c&&this.trimInPlace(d,u),this.checkBuffer()}},this.hls=t,this.HlsPlayerClass=e,this.assetListLoader=new ya(t),this.schedule=new ga(this.onScheduleUpdate,t.logger),this.registerListeners()}registerListeners(){const t=this.hls;t&&(t.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(l.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),t.on(l.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(l.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),t.on(l.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),t.on(l.ASSET_LIST_LOADED,this.onAssetListLoaded,this),t.on(l.BUFFER_APPENDED,this.onBufferAppended,this),t.on(l.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(l.BUFFERED_TO_END,this.onBufferedToEnd,this),t.on(l.MEDIA_ENDED,this.onMediaEnded,this),t.on(l.ERROR,this.onError,this),t.on(l.DESTROYING,this.onDestroying,this))}unregisterListeners(){const t=this.hls;t&&(t.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(l.AUDIO_TRACK_UPDATED,this.onAudioTrackUpdated,this),t.off(l.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(l.SUBTITLE_TRACK_UPDATED,this.onSubtitleTrackUpdated,this),t.off(l.EVENT_CUE_ENTER,this.onInterstitialCueEnter,this),t.off(l.ASSET_LIST_LOADED,this.onAssetListLoaded,this),t.off(l.BUFFER_CODECS,this.onBufferCodecs,this),t.off(l.BUFFER_APPENDED,this.onBufferAppended,this),t.off(l.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(l.BUFFERED_TO_END,this.onBufferedToEnd,this),t.off(l.MEDIA_ENDED,this.onMediaEnded,this),t.off(l.ERROR,this.onError,this),t.off(l.DESTROYING,this.onDestroying,this))}startLoad(){this.resumeBuffering()}stopLoad(){this.pauseBuffering()}resumeBuffering(){var t;null==(t=this.getBufferingPlayer())||t.resumeBuffering()}pauseBuffering(){var t;null==(t=this.getBufferingPlayer())||t.pauseBuffering()}destroy(){this.unregisterListeners(),this.stopLoad(),this.assetListLoader&&this.assetListLoader.destroy(),this.emptyPlayerQueue(),this.clearScheduleState(),this.schedule&&this.schedule.destroy(),this.media=this.detachedData=this.mediaSelection=this.requiredTracks=this.altSelection=this.schedule=this.manager=null,this.hls=this.HlsPlayerClass=this.log=null,this.assetListLoader=null,this.onPlay=this.onPause=this.onSeeking=this.onTimeupdate=null,this.onScheduleUpdate=null}onDestroying(){const t=this.primaryMedia||this.media;t&&this.removeMediaListeners(t)}removeMediaListeners(t){Js(t,"play",this.onPlay),Js(t,"pause",this.onPause),Js(t,"seeking",this.onSeeking),Js(t,"timeupdate",this.onTimeupdate)}onMediaAttaching(t,e){const s=this.media=e.media;Zs(s,"seeking",this.onSeeking),Zs(s,"timeupdate",this.onTimeupdate),Zs(s,"play",this.onPlay),Zs(s,"pause",this.onPause)}onMediaAttached(t,e){const s=this.effectivePlayingItem,i=this.detachedData;if(this.detachedData=null,null===s)this.checkStart();else if(!i){this.clearScheduleState();const t=this.findItemIndex(s);this.setSchedulePosition(t)}}clearScheduleState(){this.log("clear schedule state"),this.playingItem=this.bufferingItem=this.waitingItem=this.endedItem=this.playingAsset=this.endedAsset=this.bufferingAsset=null}onMediaDetaching(t,e){const s=!!e.transferMedia,i=this.media;if(this.media=null,!s&&(i&&this.removeMediaListeners(i),this.detachedData)){const t=this.getBufferingPlayer();t&&(this.log(`Removing schedule state for detachedData and ${t}`),this.playingAsset=this.endedAsset=this.bufferingAsset=this.bufferingItem=this.waitingItem=this.detachedData=null,t.detachMedia()),this.shouldPlay=!1}}get interstitialsManager(){if(!this.hls)return null;if(this.manager)return this.manager;const t=this,e=()=>t.bufferingItem||t.waitingItem,s=e=>e?t.getAssetPlayer(e.identifier):e,i=(e,i,n,a,o)=>{if(e){let l=e[i].start;const h=e.event;if(h){if("playout"===i||h.timelineOccupancy!==oa.Point){const t=s(n);(null==t?void 0:t.interstitial)===h&&(l+=t.assetItem.startOffset+t[o])}}else l+=("bufferedPos"===a?r():t[a])-e.start;return l}return 0},r=()=>{const e=t.bufferedPos;return e===Number.MAX_VALUE?n("primary"):Math.max(e,0)},n=e=>{var s,i;return null!=(s=t.primaryDetails)&&s.live?t.primaryDetails.edge:(null==(i=t.schedule)?void 0:i.durations[e])||0},a=(e,r)=>{var n,a;const o=t.effectivePlayingItem;if(null!=o&&null!=(n=o.event)&&n.restrictions.skip||!t.schedule)return;t.log(`seek to ${e} "${r}"`);const l=t.effectivePlayingItem,h=t.schedule.findItemIndexAtTime(e,r),c=null==(a=t.schedule.items)?void 0:a[h],d=t.getBufferingPlayer(),u=null==d?void 0:d.interstitial,p=null==u?void 0:u.appendInPlace,f=l&&t.itemsMatch(l,c);if(l&&(p||f)){const n=s(t.playingAsset),a=(null==n?void 0:n.media)||t.primaryMedia;if(a){const s="primary"===r?a.currentTime:i(l,r,t.playingAsset,"timelinePos","currentTime"),o=e-s,h=(p?s:a.currentTime)+o;if(h>=0&&(!n||p||h<=n.duration))return void(a.currentTime=h)}}if(c){let s=e;if("primary"!==r){const t=e-c[r].start;s=c.start+t}const i=!t.isInterstitial(c);if(t.isInterstitial(l)&&!l.event.appendInPlace||!i&&!c.event.appendInPlace){if(l){const n=t.findItemIndex(l);if(h>n){const e=t.schedule.findJumpRestrictedIndex(n+1,h);if(e>n)return void t.setSchedulePosition(e)}let a=0;if(i)t.timelinePos=s,t.checkBuffer();else{const t=c.event.assetList,s=e-(c[r]||c).start;for(let e=t.length;e--;){const i=t[e];if(i.duration&&s>=i.startOffset&&s<i.startOffset+i.duration){a=e;break}}}t.setSchedulePosition(h,a)}}else{const e=t.media||(p?null==d?void 0:d.media:null);e&&(e.currentTime=s)}}},o=()=>{const s=t.effectivePlayingItem;if(t.isInterstitial(s))return s;const i=e();return t.isInterstitial(i)?i:null},l={get bufferedEnd(){const s=e(),r=t.bufferingItem;var n;return r&&r===s&&(i(r,"playout",t.bufferingAsset,"bufferedPos","bufferedEnd")-r.playout.start||(null==(n=t.bufferingAsset)?void 0:n.startOffset))||0},get currentTime(){const e=o(),s=t.effectivePlayingItem;return s&&s===e?i(s,"playout",t.effectivePlayingAsset,"timelinePos","currentTime")-s.playout.start:0},set currentTime(e){const s=o(),i=t.effectivePlayingItem;i&&i===s&&a(e+i.playout.start,"playout")},get duration(){const t=o();return t?t.playout.end-t.playout.start:0},get assetPlayers(){var e;const s=null==(e=o())?void 0:e.event.assetList;return s?s.map(e=>t.getAssetPlayer(e.identifier)):[]},get playingIndex(){var e;const s=null==(e=o())?void 0:e.event;return s&&t.effectivePlayingAsset?s.findAssetIndex(t.effectivePlayingAsset):-1},get scheduleItem(){return o()}};return this.manager={get events(){var e;return(null==(e=t.schedule)||null==(e=e.events)?void 0:e.slice(0))||[]},get schedule(){var e;return(null==(e=t.schedule)||null==(e=e.items)?void 0:e.slice(0))||[]},get interstitialPlayer(){return o()?l:null},get playerQueue(){return t.playerQueue.slice(0)},get bufferingAsset(){return t.bufferingAsset},get bufferingItem(){return e()},get bufferingIndex(){const s=e();return t.findItemIndex(s)},get playingAsset(){return t.effectivePlayingAsset},get playingItem(){return t.effectivePlayingItem},get playingIndex(){const e=t.effectivePlayingItem;return t.findItemIndex(e)},primary:{get bufferedEnd(){return r()},get currentTime(){const e=t.timelinePos;return e>0?e:0},set currentTime(t){a(t,"primary")},get duration(){return n("primary")},get seekableStart(){var e;return(null==(e=t.primaryDetails)?void 0:e.fragmentStart)||0}},integrated:{get bufferedEnd(){return i(e(),"integrated",t.bufferingAsset,"bufferedPos","bufferedEnd")},get currentTime(){return i(t.effectivePlayingItem,"integrated",t.effectivePlayingAsset,"timelinePos","currentTime")},set currentTime(t){a(t,"integrated")},get duration(){return n("integrated")},get seekableStart(){var e;return((e,s)=>{var i;if(0!==e&&null!=(i=t.schedule)&&i.length){var r;const i=t.schedule.findItemIndexAtTime(e),n=null==(r=t.schedule.items)?void 0:r[i];if(n)return e+(n[s].start-n.start)}return e})((null==(e=t.primaryDetails)?void 0:e.fragmentStart)||0,"integrated")}},skip:()=>{const e=t.effectivePlayingItem,s=null==e?void 0:e.event;if(s&&!s.restrictions.skip){const i=t.findItemIndex(e);if(s.appendInPlace){const t=e.playout.start+e.event.duration;a(t+.001,"playout")}else t.advanceAfterAssetEnded(s,i,1/0)}}}}get effectivePlayingItem(){return this.waitingItem||this.playingItem||this.endedItem}get effectivePlayingAsset(){return this.playingAsset||this.endedAsset}get playingLastItem(){var t;const e=this.playingItem,s=null==(t=this.schedule)?void 0:t.items;return!!(this.playbackStarted&&e&&s)&&this.findItemIndex(e)===s.length-1}get playbackStarted(){return null!==this.effectivePlayingItem}get currentTime(){var t,e;if(null===this.mediaSelection)return;const s=this.waitingItem||this.playingItem;if(this.isInterstitial(s)&&!s.event.appendInPlace)return;let r=this.media;!r&&null!=(t=this.bufferingItem)&&null!=(t=t.event)&&t.appendInPlace&&(r=this.primaryMedia);const n=null==(e=r)?void 0:e.currentTime;return void 0!==n&&i(n)?n:void 0}get primaryMedia(){var t;return this.media||(null==(t=this.detachedData)?void 0:t.media)||null}isInterstitial(t){return!(null==t||!t.event)}retreiveMediaSource(t,e){const s=this.getAssetPlayer(t);s&&this.transferMediaFromPlayer(s,e)}transferMediaFromPlayer(t,e){const s=t.interstitial.appendInPlace,i=t.media;if(s&&i===this.primaryMedia){if(this.bufferingAsset=null,(!e||this.isInterstitial(e)&&!e.event.appendInPlace)&&e&&i)return void(this.detachedData={media:i});const s=t.transferMedia();this.log(`transfer MediaSource from ${t} ${zt(s)}`),this.detachedData=s}else e&&i&&(this.shouldPlay||(this.shouldPlay=!i.paused))}transferMediaTo(t,e){var s,i;if(t.media===e)return;let r=null;const n=this.hls,a=t!==n,o=a&&t.interstitial.appendInPlace,l=null==(s=this.detachedData)?void 0:s.mediaSource;let h;if(n.media)o&&(r=n.transferMedia(),this.detachedData=r),h="Primary";else if(l){const t=this.getBufferingPlayer();t?(r=t.transferMedia(),h=`${t}`):h="detached MediaSource"}else h="detached media";if(!r)if(l)r=this.detachedData,this.log(`using detachedData: MediaSource ${zt(r)}`);else if(!this.detachedData||n.media===e){const t=this.playerQueue;t.length>1&&t.forEach(t=>{if(a&&t.interstitial.appendInPlace!==o){const e=t.interstitial;this.clearInterstitial(t.interstitial,null),e.appendInPlace=!1,e.appendInPlace&&this.warn(`Could not change append strategy for queued assets ${e}`)}}),this.hls.detachMedia(),this.detachedData={media:e}}const c=r&&"mediaSource"in r&&"closed"!==(null==(i=r.mediaSource)?void 0:i.readyState),d=c&&r?r:e;this.log(`${c?"transfering MediaSource":"attaching media"} to ${a?t:"Primary"} from ${h} (media.currentTime: ${e.currentTime})`);const u=this.schedule;if(d===r&&u){const e=a&&t.assetId===u.assetIdAtEnd;d.overrides={duration:u.duration,endOfStream:!a||e,cueRemoval:!a}}t.attachMedia(d)}onInterstitialCueEnter(){this.onTimeupdate()}checkStart(){const t=this.schedule,e=null==t?void 0:t.events;if(!e||this.playbackDisabled||!this.media)return;-1===this.bufferedPos&&(this.bufferedPos=0);const s=this.timelinePos,i=this.effectivePlayingItem;if(-1===s){const s=this.hls.startPosition;if(this.log(ba("checkStart",s)),this.timelinePos=s,e.length&&e[0].cue.pre){const s=t.findEventIndex(e[0].identifier);this.setSchedulePosition(s)}else if(s>=0||!this.primaryLive){const e=this.timelinePos=s>0?s:0,i=t.findItemIndexAtTime(e);this.setSchedulePosition(i)}}else if(i&&!this.playingItem){const e=t.findItemIndex(i);this.setSchedulePosition(e)}}advanceAssetBuffering(t,e){const s=t.event,i=s.findAssetIndex(e),r=ua(s,i);if(s.isAssetPastPlayoutLimit(r)){if(this.schedule){var n;const e=null==(n=this.schedule.items)?void 0:n[this.findItemIndex(t)+1];e&&this.bufferedToItem(e)}}else this.bufferedToEvent(t,r)}advanceAfterAssetEnded(t,e,s){const i=ua(t,s);if(t.isAssetPastPlayoutLimit(i)){if(this.schedule){const s=this.schedule.items;if(s){const i=e+1;if(i>=s.length)return void this.setSchedulePosition(-1);const r=t.resumeTime;this.timelinePos<r&&(this.log(ba("advanceAfterAssetEnded",r)),this.timelinePos=r,t.appendInPlace&&this.advanceInPlace(r),this.checkBuffer(this.bufferedPos<r)),this.setSchedulePosition(i)}}}else{if(t.appendInPlace){const e=t.assetList[i];e&&this.advanceInPlace(e.timelineStart)}this.setSchedulePosition(e,i)}}setScheduleToAssetAtTime(t,e){const s=this.schedule;if(!s)return;const i=e.parentIdentifier,r=s.getEvent(i);if(r){const e=s.findEventIndex(i),n=s.findAssetIndex(r,t);this.advanceAfterAssetEnded(r,e,n-1)}}setSchedulePosition(t,e){var s;const i=null==(s=this.schedule)?void 0:s.items;if(!i||this.playbackDisabled)return;const r=t>=0?i[t]:null;this.log(`setSchedulePosition ${t}, ${e} (${r?ma(r):r}) pos: ${this.timelinePos}`);const n=this.waitingItem||this.playingItem,a=this.playingLastItem;if(this.isInterstitial(n)){const s=n.event,c=this.playingAsset,d=null==c?void 0:c.identifier,u=d?this.getAssetPlayer(d):null;if(u&&d&&(!this.eventItemsMatch(n,r)||void 0!==e&&d!==s.assetList[e].identifier)){var o;const e=s.findAssetIndex(c);if(this.log(`INTERSTITIAL_ASSET_ENDED ${e+1}/${s.assetList.length} ${pa(c)}`),this.endedAsset=c,this.playingAsset=null,this.hls.trigger(l.INTERSTITIAL_ASSET_ENDED,{asset:c,assetListIndex:e,event:s,schedule:i.slice(0),scheduleIndex:t,player:u}),n!==this.playingItem)return void(this.itemsMatch(n,this.playingItem)&&!this.playingAsset&&this.advanceAfterAssetEnded(s,this.findItemIndex(this.playingItem),e));this.retreiveMediaSource(d,r),!u.media||null!=(o=this.detachedData)&&o.mediaSource||u.detachMedia()}if(!this.eventItemsMatch(n,r)&&(this.endedItem=n,this.playingItem=null,this.log(`INTERSTITIAL_ENDED ${s} ${ma(n)}`),s.hasPlayed=!0,this.hls.trigger(l.INTERSTITIAL_ENDED,{event:s,schedule:i.slice(0),scheduleIndex:t}),s.cue.once)){var h;this.updateSchedule();const t=null==(h=this.schedule)?void 0:h.items;if(r&&t){const s=this.findItemIndex(r);this.advanceSchedule(s,t,e,n,a)}return}}this.advanceSchedule(t,i,e,n,a)}advanceSchedule(t,e,s,i,r){const n=this.schedule;if(!n)return;const a=e[t]||null,o=this.primaryMedia,h=this.playerQueue;if(h.length&&h.forEach(e=>{const s=e.interstitial,i=n.findEventIndex(s.identifier);(i<t||i>t+1)&&this.clearInterstitial(s,a)}),this.isInterstitial(a)){this.timelinePos=Math.min(Math.max(this.timelinePos,a.start),a.end);const r=a.event;if(void 0===s){const e=ua(r,(s=n.findAssetIndex(r,this.timelinePos))-1);if(r.isAssetPastPlayoutLimit(e)||r.appendInPlace&&this.timelinePos===a.end)return void this.advanceAfterAssetEnded(r,t,s);s=e}const h=this.waitingItem;this.assetsBuffered(a,o)||this.setBufferingItem(a);let c=this.preloadAssets(r,s);if(this.eventItemsMatch(a,h||i)||(this.waitingItem=a,this.log(`INTERSTITIAL_STARTED ${ma(a)} ${r.appendInPlace?"append in place":""}`),this.hls.trigger(l.INTERSTITIAL_STARTED,{event:r,schedule:e.slice(0),scheduleIndex:t})),!r.assetListLoaded)return void this.log(`Waiting for ASSET-LIST to complete loading ${r}`);if(r.assetListLoader&&(r.assetListLoader.destroy(),r.assetListLoader=void 0),!o)return void this.log(`Waiting for attachMedia to start Interstitial ${r}`);this.waitingItem=this.endedItem=null,this.playingItem=a;const d=r.assetList[s];if(!d)return void this.advanceAfterAssetEnded(r,t,s||0);if(c||(c=this.getAssetPlayer(d.identifier)),null===c||c.destroyed){const t=r.assetList.length;this.warn(`asset ${s+1}/${t} player destroyed ${r}`),c=this.createAssetPlayer(r,d,s),c.loadSource()}if(!this.eventItemsMatch(a,this.bufferingItem)&&r.appendInPlace&&this.isAssetBuffered(d))return;this.startAssetPlayer(c,s,e,t,o),this.shouldPlay&&va(c.media)}else a?(this.resumePrimary(a,t,i),this.shouldPlay&&va(this.hls.media)):r&&this.isInterstitial(i)&&(this.endedItem=null,this.playingItem=i,i.event.appendInPlace||this.attachPrimary(n.durations.primary,null))}get playbackDisabled(){return!1===this.hls.config.enableInterstitialPlayback}get primaryDetails(){var t;return null==(t=this.mediaSelection)?void 0:t.main.details}get primaryLive(){var t;return!(null==(t=this.primaryDetails)||!t.live)}resumePrimary(t,e,s){var i,r;if(this.playingItem=t,this.playingAsset=this.endedAsset=null,this.waitingItem=this.endedItem=null,this.bufferedToItem(t),this.log(`resuming ${ma(t)}`),null==(i=this.detachedData)||!i.mediaSource){let s=this.timelinePos;(s<t.start||s>=t.end)&&(s=this.getPrimaryResumption(t,e),this.log(ba("resumePrimary",s)),this.timelinePos=s),this.attachPrimary(s,t)}if(!s)return;const n=null==(r=this.schedule)?void 0:r.items;n&&(this.log(`INTERSTITIALS_PRIMARY_RESUMED ${ma(t)}`),this.hls.trigger(l.INTERSTITIALS_PRIMARY_RESUMED,{schedule:n.slice(0),scheduleIndex:e}),this.checkBuffer())}getPrimaryResumption(t,e){const s=t.start;if(this.primaryLive){const t=this.primaryDetails;if(0===e)return this.hls.startPosition;if(t&&(s<t.fragmentStart||s>t.edge))return this.hls.liveSyncPosition||-1}return s}isAssetBuffered(t){const e=this.getAssetPlayer(t.identifier);return null!=e&&e.hls?e.hls.bufferedToEnd:Fe.bufferInfo(this.primaryMedia,this.timelinePos,0).end+1>=t.timelineStart+(t.duration||0)}attachPrimary(t,e,s){e?this.setBufferingItem(e):this.bufferingItem=this.playingItem,this.bufferingAsset=null;const i=this.primaryMedia;if(!i)return;const r=this.hls;r.media?this.checkBuffer():(this.transferMediaTo(r,i),s&&this.startLoadingPrimaryAt(t,s)),s||(this.log(ba("attachPrimary",t)),this.timelinePos=t,this.startLoadingPrimaryAt(t,s))}startLoadingPrimaryAt(t,e){var s;const i=this.hls;!i.loadingEnabled||!i.media||Math.abs(((null==(s=i.mainForwardBufferInfo)?void 0:s.start)||i.media.currentTime)-t)>.5?i.startLoad(t,e):i.bufferingEnabled||i.resumeBuffering()}onManifestLoading(){var t;this.stopLoad(),null==(t=this.schedule)||t.reset(),this.emptyPlayerQueue(),this.clearScheduleState(),this.shouldPlay=!1,this.bufferedPos=this.timelinePos=-1,this.mediaSelection=this.altSelection=this.manager=this.requiredTracks=null,this.hls.off(l.BUFFER_CODECS,this.onBufferCodecs,this),this.hls.on(l.BUFFER_CODECS,this.onBufferCodecs,this)}onLevelUpdated(t,e){if(-1===e.level||!this.schedule)return;const s=this.hls.levels[e.level];if(!s.details)return;const i=T(T({},this.mediaSelection||this.altSelection),{},{main:s});this.mediaSelection=i,this.schedule.parseInterstitialDateRanges(i,this.hls.config.interstitialAppendInPlace),!this.effectivePlayingItem&&this.schedule.items&&this.checkStart()}onAudioTrackUpdated(t,e){const s=this.hls.audioTracks[e.id],i=this.mediaSelection;if(!i)return void(this.altSelection=T(T({},this.altSelection),{},{audio:s}));const r=T(T({},i),{},{audio:s});this.mediaSelection=r}onSubtitleTrackUpdated(t,e){const s=this.hls.subtitleTracks[e.id],i=this.mediaSelection;if(!i)return void(this.altSelection=T(T({},this.altSelection),{},{subtitles:s}));const r=T(T({},i),{},{subtitles:s});this.mediaSelection=r}onAudioTrackSwitching(t,e){const s=Xt(e);this.playerQueue.forEach(({hls:t})=>t&&(t.setAudioOption(e)||t.setAudioOption(s)))}onSubtitleTrackSwitch(t,e){const s=Xt(e);this.playerQueue.forEach(({hls:t})=>t&&(t.setSubtitleOption(e)||-1!==e.id&&t.setSubtitleOption(s)))}onBufferCodecs(t,e){const s=e.tracks;s&&(this.requiredTracks=s)}onBufferAppended(t,e){this.checkBuffer()}onBufferFlushed(t,e){const s=this.playingItem;if(s&&!this.itemsMatch(s,this.bufferingItem)&&!this.isInterstitial(s)){const t=this.timelinePos;this.bufferedPos=t,this.checkBuffer()}}onBufferedToEnd(t){if(!this.schedule)return;const e=this.schedule.events;if(this.bufferedPos<Number.MAX_VALUE&&e){for(let t=0;t<e.length;t++){const i=e[t];if(i.cue.post){var s;const t=this.schedule.findEventIndex(i.identifier),e=null==(s=this.schedule.items)?void 0:s[t];this.isInterstitial(e)&&this.eventItemsMatch(e,this.bufferingItem)&&this.bufferedToItem(e,0);break}}this.bufferedPos=Number.MAX_VALUE}}onMediaEnded(t){const e=this.playingItem;if(!this.playingLastItem&&e){const t=this.findItemIndex(e);this.setSchedulePosition(t+1)}else this.shouldPlay=!1}updateItem(t,e){var s;const i=null==(s=this.schedule)?void 0:s.items;return t&&i&&i[this.findItemIndex(t,e)]||null}trimInPlace(t,e){if(this.isInterstitial(t)&&t.event.appendInPlace&&e.end-t.end>.25){t.event.assetList.forEach((e,s)=>{t.event.isAssetPastPlayoutLimit(s)&&this.clearAssetPlayer(e.identifier,null)});const s=t.end+.25,i=Fe.bufferInfo(this.primaryMedia,s,0);if(i.end>s||(i.nextStart||0)>s){this.log(`trim buffered interstitial ${ma(t)} (was ${ma(e)})`);const i=!0;this.attachPrimary(s,null,i),this.flushFrontBuffer(s)}}}itemsMatch(t,e){return!!e&&(t===e||t.event&&e.event&&this.eventItemsMatch(t,e)||!t.event&&!e.event&&this.findItemIndex(t)===this.findItemIndex(e))}eventItemsMatch(t,e){var s;return!!e&&(t===e||t.event.identifier===(null==(s=e.event)?void 0:s.identifier))}findItemIndex(t,e){return t&&this.schedule?this.schedule.findItemIndex(t,e):-1}updateSchedule(t=!1){var e;const s=this.mediaSelection;s&&(null==(e=this.schedule)||e.updateSchedule(s,[],t))}checkBuffer(t){var e;const s=null==(e=this.schedule)?void 0:e.items;if(!s)return;const i=Fe.bufferInfo(this.primaryMedia,this.timelinePos,0);t&&(this.bufferedPos=this.timelinePos),t||(t=i.len<1),this.updateBufferedPos(i.end,s,t)}updateBufferedPos(t,e,s){const i=this.schedule,r=this.bufferingItem;if(this.bufferedPos>t||!i)return;if(1===e.length&&this.itemsMatch(e[0],r))return void(this.bufferedPos=t);const n=this.playingItem,a=this.findItemIndex(n);let o=i.findItemIndexAtTime(t);if(this.bufferedPos<t){var l;const s=this.findItemIndex(r),i=Math.min(s+1,e.length-1),n=e[i];if((-1===o&&r&&t>=r.end||null!=(l=n.event)&&l.appendInPlace&&t+.01>=n.start)&&(o=i),this.isInterstitial(r)){const t=r.event;if(i-a>1&&!1===t.appendInPlace)return;if(0===t.assetList.length&&t.assetListLoader)return}if(this.bufferedPos=t,o>s&&o>a)this.bufferedToItem(n);else{const e=this.primaryDetails;this.primaryLive&&e&&t>e.edge-e.targetduration&&n.start<e.edge+this.hls.config.interstitialLiveLookAhead&&this.isInterstitial(n)&&this.preloadAssets(n.event,0)}}else s&&n&&!this.itemsMatch(n,r)&&(o===a?this.bufferedToItem(n):o===a+1&&this.bufferedToItem(e[o]))}assetsBuffered(t,e){return 0!==t.event.assetList.length&&!t.event.assetList.some(t=>{const s=this.getAssetPlayer(t.identifier);return!(null!=s&&s.bufferedInPlaceToEnd(e))})}setBufferingItem(t){const e=this.bufferingItem,s=this.schedule;if(!this.itemsMatch(t,e)&&s){const{items:i,events:r}=s;if(!i||!r)return e;const n=this.isInterstitial(t),a=this.getBufferingPlayer();this.bufferingItem=t,this.bufferedPos=Math.max(t.start,Math.min(t.end,this.timelinePos));const o=a?a.remaining:e?e.end-this.timelinePos:0;if(this.log(`INTERSTITIALS_BUFFERED_TO_BOUNDARY ${ma(t)}`+(e?` (${o.toFixed(2)} remaining)`:"")),!this.playbackDisabled)if(n){const e=s.findAssetIndex(t.event,this.bufferedPos);t.event.assetList.forEach((t,s)=>{const i=this.getAssetPlayer(t.identifier);i&&(s===e&&i.loadSource(),i.resumeBuffering())})}else this.hls.resumeBuffering(),this.playerQueue.forEach(t=>t.pauseBuffering());this.hls.trigger(l.INTERSTITIALS_BUFFERED_TO_BOUNDARY,{events:r.slice(0),schedule:i.slice(0),bufferingIndex:this.findItemIndex(t),playingIndex:this.findItemIndex(this.playingItem)})}else this.bufferingItem!==t&&(this.bufferingItem=t);return e}bufferedToItem(t,e=0){const s=this.setBufferingItem(t);if(!this.playbackDisabled)if(this.isInterstitial(t))this.bufferedToEvent(t,e);else if(null!==s){this.bufferingAsset=null;const e=this.detachedData;if(e)if(e.mediaSource){const e=!0;this.attachPrimary(t.start,t,e)}else this.preloadPrimary(t);else this.preloadPrimary(t)}}preloadPrimary(t){const e=this.findItemIndex(t),s=this.getPrimaryResumption(t,e);this.startLoadingPrimaryAt(s)}bufferedToEvent(t,e){const s=t.event,i=0===s.assetList.length&&!s.assetListLoader,r=s.cue.once;if(i||!r){const t=this.preloadAssets(s,e);if(null!=t&&t.interstitial.appendInPlace){const e=this.primaryMedia;e&&this.bufferAssetPlayer(t,e)}}}preloadAssets(t,e){const s=t.assetUrl,i=t.assetList.length,r=0===i&&!t.assetListLoader,n=t.cue.once;if(r){const r=t.timelineStart;if(t.appendInPlace){var a;const e=this.playingItem;this.isInterstitial(e)||(null==e||null==(a=e.nextEvent)?void 0:a.identifier)!==t.identifier||this.flushFrontBuffer(r+.25)}let n,o=0;if(!this.playingItem&&this.primaryLive&&(o=this.hls.startPosition,-1===o&&(o=this.hls.liveSyncPosition||0)),o&&!t.cue.pre&&!t.cue.post){const t=o-r;t>0&&(n=Math.round(1e3*t)/1e3)}if(this.log(`Load interstitial asset ${e+1}/${s?1:i} ${t}${n?` live-start: ${o} start-offset: ${n}`:""}`),s)return this.createAsset(t,0,0,r,t.duration,s);const l=this.assetListLoader.loadAssetList(t,n);l&&(t.assetListLoader=l)}else if(!n&&i){for(let s=e;s<i;s++){const e=t.assetList[s],i=this.getAssetPlayerQueueIndex(e.identifier);-1!==i&&!this.playerQueue[i].destroyed||e.error||this.createAssetPlayer(t,e,s)}const s=t.assetList[e];if(s){const t=this.getAssetPlayer(s.identifier);return t&&t.loadSource(),t}}return null}flushFrontBuffer(t){const e=this.requiredTracks;e&&(this.log(`Removing front buffer starting at ${t}`),Object.keys(e).forEach(e=>{this.hls.trigger(l.BUFFER_FLUSHING,{startOffset:t,endOffset:1/0,type:e})}))}getAssetPlayerQueueIndex(t){const e=this.playerQueue;for(let s=0;s<e.length;s++)if(t===e[s].assetId)return s;return-1}getAssetPlayer(t){const e=this.getAssetPlayerQueueIndex(t);return this.playerQueue[e]||null}getBufferingPlayer(){const{playerQueue:t,primaryMedia:e}=this;if(e)for(let s=0;s<t.length;s++)if(t[s].media===e)return t[s];return null}createAsset(t,e,s,i,r,n){const a={parentIdentifier:t.identifier,identifier:la(t,n,e),duration:r,startOffset:s,timelineStart:i,uri:n};return this.createAssetPlayer(t,a,e)}createAssetPlayer(t,e,s){const i=this.hls,r=i.userConfig;let n=r.videoPreference;const h=i.loadLevelObj||i.levels[i.currentLevel];(n||h)&&(n=b({},n),h.videoCodec&&(n.videoCodec=h.videoCodec),h.videoRange&&(n.allowedVideoRanges=[h.videoRange]));const c=i.audioTracks[i.audioTrack],d=i.subtitleTracks[i.subtitleTrack];let u=0;if(this.primaryLive||t.appendInPlace){const t=this.timelinePos-e.timelineStart;if(t>1){const s=e.duration;s&&t<s&&(u=t)}}const p=e.identifier,f=T(T({},r),{},{maxMaxBufferLength:Math.min(180,i.config.maxMaxBufferLength),autoStartLoad:!0,startFragPrefetch:!0,primarySessionId:i.sessionId,assetPlayerId:p,abrEwmaDefaultEstimate:i.bandwidthEstimate,interstitialsController:void 0,startPosition:u,liveDurationInfinity:!1,testBandwidth:!1,videoPreference:n,audioPreference:c||r.audioPreference,subtitlePreference:d||r.subtitlePreference});t.appendInPlace&&(t.appendInPlaceStarted=!0,e.timelineStart&&(f.timelineOffset=e.timelineStart));const g=f.cmcd;null!=g&&g.sessionId&&g.contentId&&(f.cmcd=b({},g,{contentId:na(e.uri)})),this.getAssetPlayer(p)&&this.warn(`Duplicate date range identifier ${t} and asset ${p}`);const m=new fa(this.HlsPlayerClass,f,t,e);this.playerQueue.push(m),t.assetList[s]=e;let y=!0;const v=i=>{if(i.live){var r;const e=new Error(`Interstitials MUST be VOD assets ${t}`),i={fatal:!0,type:a.OTHER_ERROR,details:o.INTERSTITIAL_ASSET_ITEM_ERROR,error:e},n=(null==(r=this.schedule)?void 0:r.findEventIndex(t.identifier))||-1;return void this.handleAssetItemError(i,t,n,s,e.message)}const n=i.edge-i.fragmentStart,l=e.duration;(y||null===l||n>l)&&(y=!1,this.log(`Interstitial asset "${p}" duration change ${l} > ${n}`),e.duration=n,this.updateSchedule())};m.on(l.LEVEL_UPDATED,(t,{details:e})=>v(e)),m.on(l.LEVEL_PTS_UPDATED,(t,{details:e})=>v(e)),m.on(l.EVENT_CUE_ENTER,()=>this.onInterstitialCueEnter());const _=(t,e)=>{const s=this.getAssetPlayer(p);if(s&&e.tracks){s.off(l.BUFFER_CODECS,_),s.tracks=e.tracks;const t=this.primaryMedia;this.bufferingAsset===s.assetItem&&t&&!s.media&&this.bufferAssetPlayer(s,t)}};m.on(l.BUFFER_CODECS,_),m.on(l.BUFFERED_TO_END,()=>{var s;const i=this.getAssetPlayer(p);if(this.log(`buffered to end of asset ${i}`),!i||!this.schedule)return;const r=this.schedule.findEventIndex(t.identifier),n=null==(s=this.schedule.items)?void 0:s[r];this.isInterstitial(n)&&this.advanceAssetBuffering(n,e)});const A=e=>()=>{if(!this.getAssetPlayer(p)||!this.schedule)return;this.shouldPlay=!0;const s=this.schedule.findEventIndex(t.identifier);this.advanceAfterAssetEnded(t,s,e)};return m.once(l.MEDIA_ENDED,A(s)),m.once(l.PLAYOUT_LIMIT_REACHED,A(1/0)),m.on(l.ERROR,(e,i)=>{if(!this.schedule)return;const r=this.getAssetPlayer(p);if(i.details===o.BUFFER_STALLED_ERROR)return null!=r&&r.appendInPlace?void this.handleInPlaceStall(t):(this.onTimeupdate(),void this.checkBuffer(!0));this.handleAssetItemError(i,t,this.schedule.findEventIndex(t.identifier),s,`Asset player error ${i.error} ${t}`)}),m.on(l.DESTROYING,()=>{if(!this.getAssetPlayer(p)||!this.schedule)return;const e=new Error(`Asset player destroyed unexpectedly ${p}`),i={fatal:!0,type:a.OTHER_ERROR,details:o.INTERSTITIAL_ASSET_ITEM_ERROR,error:e};this.handleAssetItemError(i,t,this.schedule.findEventIndex(t.identifier),s,e.message)}),this.log(`INTERSTITIAL_ASSET_PLAYER_CREATED ${pa(e)}`),this.hls.trigger(l.INTERSTITIAL_ASSET_PLAYER_CREATED,{asset:e,assetListIndex:s,event:t,player:m}),m}clearInterstitial(t,e){this.clearAssetPlayers(t,e),t.reset()}clearAssetPlayers(t,e){t.assetList.forEach(t=>{this.clearAssetPlayer(t.identifier,e)})}resetAssetPlayer(t){const e=this.getAssetPlayerQueueIndex(t);if(-1!==e){this.log(`reset asset player "${t}" after error`);const s=this.playerQueue[e];this.transferMediaFromPlayer(s,null),s.resetDetails()}}clearAssetPlayer(t,e){const s=this.getAssetPlayerQueueIndex(t);if(-1!==s){const t=this.playerQueue[s];this.log(`clear ${t} toSegment: ${e?ma(e):e}`),this.transferMediaFromPlayer(t,e),this.playerQueue.splice(s,1),t.destroy()}}emptyPlayerQueue(){let t;for(;t=this.playerQueue.pop();)t.destroy();this.playerQueue=[]}startAssetPlayer(t,e,s,i,r){const{interstitial:n,assetItem:a,assetId:o}=t,h=n.assetList.length,c=this.playingAsset;this.endedAsset=null,this.playingAsset=a,c&&c.identifier===o||(c&&(this.clearAssetPlayer(c.identifier,s[i]),delete c.error),this.log(`INTERSTITIAL_ASSET_STARTED ${e+1}/${h} ${pa(a)}`),this.hls.trigger(l.INTERSTITIAL_ASSET_STARTED,{asset:a,assetListIndex:e,event:n,schedule:s.slice(0),scheduleIndex:i,player:t})),this.bufferAssetPlayer(t,r)}bufferAssetPlayer(t,e){var s,i;if(!this.schedule)return;const{interstitial:r,assetItem:n}=t,l=this.schedule.findEventIndex(r.identifier),h=null==(s=this.schedule.items)?void 0:s[l];if(!h)return;t.loadSource(),this.setBufferingItem(h),this.bufferingAsset=n;const c=this.getBufferingPlayer();if(c===t)return;const d=r.appendInPlace;if(d&&!1===(null==c?void 0:c.interstitial.appendInPlace))return;const u=(null==c?void 0:c.tracks)||(null==(i=this.detachedData)?void 0:i.tracks)||this.requiredTracks;if(d&&n!==this.playingAsset){if(!t.tracks)return void this.log(`Waiting for track info before buffering ${t}`);if(u&&!P(u,t.tracks)){const e=new Error(`Asset ${pa(n)} SourceBuffer tracks ('${Object.keys(t.tracks)}') are not compatible with primary content tracks ('${Object.keys(u)}')`),s={fatal:!0,type:a.OTHER_ERROR,details:o.INTERSTITIAL_ASSET_ITEM_ERROR,error:e},i=r.findAssetIndex(n);return void this.handleAssetItemError(s,r,l,i,e.message)}}this.transferMediaTo(t,e)}handleInPlaceStall(t){const e=this.schedule,s=this.primaryMedia;if(!e||!s)return;const i=s.currentTime,r=e.findAssetIndex(t,i),n=t.assetList[r];if(n){const a=this.getAssetPlayer(n.identifier);if(a){const o=a.currentTime||i-n.timelineStart,l=a.duration-o;if(this.warn(`Stalled at ${o} of ${o+l} in ${a} ${t} (media.currentTime: ${i})`),o&&(l/s.playbackRate<.5||a.bufferedInPlaceToEnd(s))&&a.hls){const s=e.findEventIndex(t.identifier);this.advanceAfterAssetEnded(t,s,r)}}}}advanceInPlace(t){const e=this.primaryMedia;e&&e.currentTime<t&&(e.currentTime=t)}handleAssetItemError(t,e,s,i,r){if(t.details===o.BUFFER_STALLED_ERROR)return;const n=e.assetList[i]||null;if(this.warn(`INTERSTITIAL_ASSET_ERROR ${n?pa(n):n} ${t.error}`),!this.schedule)return;const a=(null==n?void 0:n.identifier)||"",h=this.getAssetPlayerQueueIndex(a),c=this.playerQueue[h]||null,d=this.schedule.items,u=b({},t,{fatal:!1,errorAction:ge(!0),asset:n,assetListIndex:i,event:e,schedule:d,scheduleIndex:s,player:c});if(this.hls.trigger(l.INTERSTITIAL_ASSET_ERROR,u),!t.fatal)return;const p=this.playingAsset,f=this.bufferingAsset,g=new Error(r);if(n&&(this.clearAssetPlayer(a,null),n.error=g),e.assetList.some(t=>!t.error))for(let t=i;t<e.assetList.length;t++)this.resetAssetPlayer(e.assetList[t].identifier);else e.error=g;this.updateSchedule(!0),e.error?this.primaryFallback(e):p&&p.identifier===a?this.advanceAfterAssetEnded(e,s,i):f&&f.identifier===a&&this.isInterstitial(this.bufferingItem)&&this.advanceAssetBuffering(this.bufferingItem,f)}primaryFallback(t){const e=t.timelineStart,s=this.effectivePlayingItem;let i=this.timelinePos;if(s){this.log(`Fallback to primary from event "${t.identifier}" start: ${e} pos: ${i} playing: ${ma(s)} error: ${t.error}`),-1===i&&(i=this.hls.startPosition);const r=this.updateItem(s,i);this.itemsMatch(s,r)&&this.clearInterstitial(t,null),t.appendInPlace&&(this.attachPrimary(e,null),this.flushFrontBuffer(e))}else if(-1===i)return void this.checkStart();if(!this.schedule)return;const r=this.schedule.findItemIndexAtTime(i);this.setSchedulePosition(r)}onAssetListLoaded(t,e){var s,i;const r=e.event,n=r.identifier,a=e.assetListResponse.ASSETS;if(null==(s=this.schedule)||!s.hasEvent(n))return;const o=r.timelineStart,l=r.duration;let h=0;a.forEach((t,e)=>{const s=parseFloat(t.DURATION);this.createAsset(r,e,h,o+h,s,t.URI),h+=s}),r.duration=h,this.log(`Loaded asset-list with duration: ${h} (was: ${l}) ${r}`);const c=this.waitingItem,d=(null==c?void 0:c.event.identifier)===n;this.updateSchedule();const u=null==(i=this.bufferingItem)?void 0:i.event;if(d){var p;const t=this.schedule.findEventIndex(n),e=null==(p=this.schedule.items)?void 0:p[t];if(e){if(!this.playingItem&&this.timelinePos>e.end&&this.schedule.findItemIndexAtTime(this.timelinePos)!==t)return r.error=new Error(`Interstitial ${a.length?"no longer within playback range":"asset-list is empty"} ${this.timelinePos} ${r}`),this.log(r.error.message),this.updateSchedule(!0),void this.primaryFallback(r);this.setBufferingItem(e)}this.setSchedulePosition(t)}else if((null==u?void 0:u.identifier)===n){const t=r.assetList[0];if(t){const e=this.getAssetPlayer(t.identifier);if(u.appendInPlace){const t=this.primaryMedia;e&&t&&this.bufferAssetPlayer(e,t)}else e&&e.loadSource()}}}onError(t,e){if(this.schedule)switch(e.details){case o.ASSET_LIST_PARSING_ERROR:case o.ASSET_LIST_LOAD_ERROR:case o.ASSET_LIST_LOAD_TIMEOUT:{const t=e.interstitial;t&&(this.updateSchedule(!0),this.primaryFallback(t));break}case o.BUFFER_STALLED_ERROR:{const t=this.endedItem||this.waitingItem||this.playingItem;if(this.isInterstitial(t)&&t.event.appendInPlace)return void this.handleInPlaceStall(t.event);this.log(`Primary player stall @${this.timelinePos} bufferedPos: ${this.bufferedPos}`),this.onTimeupdate(),this.checkBuffer(!0);break}}}}});function So(t){return t&&"object"==typeof t?Array.isArray(t)?t.map(So):Object.keys(t).reduce((e,s)=>(e[s]=So(t[s]),e),{}):t}class Co extends De{constructor(t,e){super("gap-controller",t.logger),this.hls=void 0,this.fragmentTracker=void 0,this.media=null,this.mediaSource=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.buffered={},this.lastCurrentTime=0,this.ended=0,this.waiting=0,this.onMediaPlaying=()=>{this.ended=0,this.waiting=0},this.onMediaWaiting=()=>{var t;null!=(t=this.media)&&t.seeking||(this.waiting=self.performance.now(),this.tick())},this.onMediaEnded=()=>{var t;this.hls&&(this.ended=(null==(t=this.media)?void 0:t.currentTime)||1,this.hls.trigger(l.MEDIA_ENDED,{stalled:!1}))},this.hls=t,this.fragmentTracker=e,this.registerListeners()}registerListeners(){const{hls:t}=this;t&&(t.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.BUFFER_APPENDED,this.onBufferAppended,this))}unregisterListeners(){const{hls:t}=this;t&&(t.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.BUFFER_APPENDED,this.onBufferAppended,this))}destroy(){super.destroy(),this.unregisterListeners(),this.media=this.hls=this.fragmentTracker=null,this.mediaSource=void 0}onMediaAttached(t,e){this.setInterval(100),this.mediaSource=e.mediaSource;const s=this.media=e.media;Zs(s,"playing",this.onMediaPlaying),Zs(s,"waiting",this.onMediaWaiting),Zs(s,"ended",this.onMediaEnded)}onMediaDetaching(t,e){this.clearInterval();const{media:s}=this;s&&(Js(s,"playing",this.onMediaPlaying),Js(s,"waiting",this.onMediaWaiting),Js(s,"ended",this.onMediaEnded),this.media=null),this.mediaSource=void 0}onBufferAppended(t,e){this.buffered=e.timeRanges}get hasBuffered(){return Object.keys(this.buffered).length>0}tick(){var t;if(null==(t=this.media)||!t.readyState||!this.hasBuffered)return;const e=this.media.currentTime;this.poll(e,this.lastCurrentTime),this.lastCurrentTime=e}poll(t,e){var s,i;const r=null==(s=this.hls)?void 0:s.config;if(!r)return;const n=this.media;if(!n)return;const{seeking:a}=n,o=this.seeking&&!a,h=!this.seeking&&a,c=n.paused&&!a||n.ended||0===n.playbackRate;if(this.seeking=a,t!==e)return e&&(this.ended=0),this.moved=!0,a||(this.nudgeRetry=0,r.nudgeOnVideoHole&&!c&&t>e&&this.nudgeOnVideoHole(t,e)),void(0===this.waiting&&this.stallResolved(t));if(h||o)return void(o&&this.stallResolved(t));if(c)return this.nudgeRetry=0,this.stallResolved(t),void(!this.ended&&n.ended&&this.hls&&(this.ended=t||1,this.hls.trigger(l.MEDIA_ENDED,{stalled:!1})));if(!Fe.getBuffered(n).length)return void(this.nudgeRetry=0);const d=Fe.bufferInfo(n,t,0),u=d.nextStart||0,p=this.fragmentTracker;if(a&&p&&this.hls){const e=ko(this.hls.inFlightFragments,t),s=d.len>2,i=!u||e||u-t>2&&!p.getPartialFragment(t);if(s||i)return;this.moved=!1}const f=null==(i=this.hls)?void 0:i.latestLevelDetails;if(!this.moved&&null!==this.stalled&&p){if(!(d.len>0||u))return;const e=Math.max(u,d.start||0)-t,s=null!=f&&f.live?2*f.targetduration:2,i=Lo(t,p);if(e>0&&(e<=s||i))return void(n.paused||this._trySkipBufferHole(i))}const g=r.detectStallWithCurrentTimeMs,m=self.performance.now(),y=this.waiting;let v=this.stalled;if(null===v){if(!(y>0&&m-y<g))return void(this.stalled=m);v=this.stalled=y}const b=m-v;if(!a&&(b>=g||y)&&this.hls){var _;if("ended"===(null==(_=this.mediaSource)?void 0:_.readyState)&&(null==f||!f.live)&&Math.abs(t-((null==f?void 0:f.edge)||0))<1){if(this.ended)return;return this.ended=t||1,void this.hls.trigger(l.MEDIA_ENDED,{stalled:!0})}if(this._reportStall(d),!this.media||!this.hls)return}const T=Fe.bufferInfo(n,t,r.maxBufferHole);this._tryFixBufferStall(T,b,t)}stallResolved(t){const e=this.stalled;if(e&&this.hls&&(this.stalled=null,this.stallReported)){const s=self.performance.now()-e;this.log(`playback not stuck anymore @${t}, after ${Math.round(s)}ms`),this.stallReported=!1,this.waiting=0,this.hls.trigger(l.STALL_RESOLVED,{})}}nudgeOnVideoHole(t,e){var s;const i=this.buffered.video;if(this.hls&&this.media&&this.fragmentTracker&&null!=(s=this.buffered.audio)&&s.length&&i&&i.length>1&&t>i.end(0)){const s=Fe.bufferedInfo(Fe.timeRangesToArray(this.buffered.audio),t,0);if(s.len>1&&e>=s.start){const s=Fe.timeRangesToArray(i),r=Fe.bufferedInfo(s,e,0).bufferedIndex;if(r>-1&&r<s.length-1){const e=Fe.bufferedInfo(s,t,0).bufferedIndex,i=s[r].end,n=s[r+1].start;if((-1===e||e>r)&&n-i<1&&t-i<2){const s=new Error(`nudging playhead to flush pipeline after video hole. currentTime: ${t} hole: ${i} -> ${n} buffered index: ${e}`);this.warn(s.message),this.media.currentTime+=1e-6;let r=Lo(t,this.fragmentTracker);r&&"fragment"in r?r=r.fragment:r||(r=void 0);const h=Fe.bufferInfo(this.media,t,0);this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:s,reason:s.message,frag:r,buffer:h.len,bufferInfo:h})}}}}}_tryFixBufferStall(t,e,s){var i,r;const{fragmentTracker:n,media:a}=this,o=null==(i=this.hls)?void 0:i.config;if(!a||!n||!o)return;const l=null==(r=this.hls)?void 0:r.latestLevelDetails,h=Lo(s,n);if((h||null!=l&&l.live&&s<l.fragmentStart)&&(this._trySkipBufferHole(h)||!this.media))return;const c=t.buffered,d=this.adjacentTraversal(t,s);(c&&c.length>1&&t.len>o.maxBufferHole||t.nextStart&&(t.nextStart-s<o.maxBufferHole||d))&&(e>1e3*o.highBufferWatchdogPeriod||this.waiting)&&(this.warn("Trying to nudge playhead over buffer-hole"),this._tryNudgeBuffer(t))}adjacentTraversal(t,e){const s=this.fragmentTracker,i=t.nextStart;if(s&&i){const t=s.getFragAtPos(e,p),r=s.getFragAtPos(i,p);if(t&&r)return r.sn-t.sn<2}return!1}_reportStall(t){const{hls:e,media:s,stallReported:i,stalled:r}=this;if(!i&&null!==r&&s&&e){this.stallReported=!0;const i=new Error(`Playback stalling at @${s.currentTime} due to low buffer (${zt(t)})`);this.warn(i.message),e.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:t.len,bufferInfo:t,stalled:{start:r}})}}_trySkipBufferHole(t){var e;const{fragmentTracker:s,media:i}=this,r=null==(e=this.hls)?void 0:e.config;if(!i||!s||!r)return 0;const n=i.currentTime,h=Fe.bufferInfo(i,n,0),c=n<h.start?h.start:h.nextStart;if(c&&this.hls){const e=h.len<=r.maxBufferHole,u=h.len>0&&h.len<1&&i.readyState<3,f=c-n;if(f>0&&(e||u)){if(f>r.maxBufferHole){let e=!1;if(0===n){const t=s.getAppendedFrag(0,p);t&&c<t.end&&(e=!0)}if(!e&&t){var d;if(null==(d=this.hls.loadLevelObj)||!d.details)return 0;if(ko(this.hls.inFlightFragments,c))return 0;let e=!1,i=t.end;for(;i<c;){const t=Lo(i,s);if(!t){e=!0;break}i+=t.duration}if(e)return 0}}const e=Math.max(c+.05,n+.1);if(this.warn(`skipping hole, adjusting currentTime from ${n} to ${e}`),this.moved=!0,i.currentTime=e,null==t||!t.gap){const s=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${e}`),i={type:a.MEDIA_ERROR,details:o.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:s,reason:s.message,buffer:h.len,bufferInfo:h};t&&("fragment"in t?i.part=t:i.frag=t),this.hls.trigger(l.ERROR,i)}return e}}return 0}_tryNudgeBuffer(t){const{hls:e,media:s,nudgeRetry:i}=this,r=null==e?void 0:e.config;if(!s||!r)return 0;const n=s.currentTime;if(this.nudgeRetry++,i<r.nudgeMaxRetry){const h=n+(i+1)*r.nudgeOffset,c=new Error(`Nudging 'currentTime' from ${n} to ${h}`);this.warn(c.message),s.currentTime=h,e.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_NUDGE_ON_STALL,error:c,fatal:!1,buffer:t.len,bufferInfo:t})}else{const s=new Error(`Playhead still not moving while enough data buffered @${n} after ${r.nudgeMaxRetry} nudges`);this.error(s.message),e.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.BUFFER_STALLED_ERROR,error:s,fatal:!0,buffer:t.len,bufferInfo:t})}}}function ko(t,e){const s=wo(t.main);if(s&&s.start<=e)return s;const i=wo(t.audio);return i&&i.start<=e?i:null}function wo(t){if(!t)return null;switch(t.state){case ei:case ti:case li:case hi:return null}return t.frag}function Lo(t,e){return e.getAppendedFrag(t,p)||e.getPartialFragment(t)}function Io(){if("undefined"!=typeof self)return self.VTTCue||self.TextTrackCue}function Po(t,e,s,i,r){let n=new t(e,s,"");try{n.value=i,r&&(n.type=r)}catch(a){n=new t(e,s,zt(r?T({type:r},i):i))}return n}const xo=(()=>{const t=Io();try{t&&new t(0,Number.POSITIVE_INFINITY,"")}catch(t){return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();class Ro{constructor(t){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.removeCues=!0,this.assetCue=void 0,this.onEventCueEnter=()=>{this.hls&&this.hls.trigger(l.EVENT_CUE_ENTER,{})},this.hls=t,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=this.onEventCueEnter=null}_registerListeners(){const{hls:t}=this;t&&(t.on(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(l.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(l.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}_unregisterListeners(){const{hls:t}=this;t&&(t.off(l.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(l.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(l.LEVEL_PTS_UPDATED,this.onLevelPtsUpdated,this))}onMediaAttaching(t,e){var s;this.media=e.media,!1===(null==(s=e.overrides)?void 0:s.cueRemoval)&&(this.removeCues=!1)}onMediaAttached(){var t;const e=null==(t=this.hls)?void 0:t.latestLevelDetails;e&&this.updateDateRangeCues(e)}onMediaDetaching(t,e){this.media=null,e.transferMedia||(this.id3Track&&(this.removeCues&&sa(this.id3Track,this.onEventCueEnter),this.id3Track=null),this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(t){const e=this.getID3Track(t.textTracks);return e.mode="hidden",e}getID3Track(t){if(this.media){for(let e=0;e<t.length;e++){const s=t[e];if("metadata"===s.kind&&"id3"===s.label)return ta(s,this.media),s}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(t,e){if(!this.media||!this.hls)return;const{enableEmsgMetadataCues:s,enableID3MetadataCues:i}=this.hls.config;if(!s&&!i)return;const{samples:r}=e;this.id3Track||(this.id3Track=this.createTrack(this.media));const n=Io();if(n)for(let t=0;t<r.length;t++){const e=r[t].type;if(e===Ui.emsg&&!s||!i)continue;const a=Ni(r[t].data),o=r[t].pts;let l=o+r[t].duration;l>xo&&(l=xo),l-o<=0&&(l=o+.25);for(let t=0;t<a.length;t++){const s=a[t];if(!Bi(s)){this.updateId3CueEnds(o,e);const t=Po(n,o,l,s,e);t&&this.id3Track.addCue(t)}}}}updateId3CueEnds(t,e){var s;const i=null==(s=this.id3Track)?void 0:s.cues;if(i)for(let s=i.length;s--;){const r=i[s];r.type===e&&r.startTime<t&&r.endTime===xo&&(r.endTime=t)}}onBufferFlushing(t,{startOffset:e,endOffset:s,type:i}){const{id3Track:r,hls:n}=this;if(!n)return;const{config:{enableEmsgMetadataCues:a,enableID3MetadataCues:o}}=n;if(r&&(a||o)){let t;t="audio"===i?t=>t.type===Ui.audioId3&&o:"video"===i?t=>t.type===Ui.emsg&&a:t=>t.type===Ui.audioId3&&o||t.type===Ui.emsg&&a,ia(r,e,s,t)}}onLevelUpdated(t,{details:e}){this.updateDateRangeCues(e,!0)}onLevelPtsUpdated(t,e){Math.abs(e.drift)>.01&&this.updateDateRangeCues(e.details)}updateDateRangeCues(t,e){if(!this.hls||!this.media)return;const{assetPlayerId:s,timelineOffset:r,enableDateRangeMetadataCues:n,interstitialsController:a}=this.hls.config;if(!n)return;const o=Io();if(s&&r&&!a){const{fragmentStart:e,fragmentEnd:i}=t;let r=this.assetCue;r?(r.startTime=e,r.endTime=i):o&&(r=this.assetCue=Po(o,e,i,{assetPlayerId:this.hls.config.assetPlayerId},"hlsjs.interstitial.asset"),r&&(r.id=s,this.id3Track||(this.id3Track=this.createTrack(this.media)),this.id3Track.addCue(r),r.addEventListener("enter",this.onEventCueEnter)))}if(!t.hasProgramDateTime)return;const{id3Track:l}=this,{dateRanges:h}=t,c=Object.keys(h);let d=this.dateRangeCuesAppended;var u;if(l&&e)if(null!=(u=l.cues)&&u.length){const t=Object.keys(d).filter(t=>!c.includes(t));for(let e=t.length;e--;){var p;const s=t[e],i=null==(p=d[s])?void 0:p.cues;delete d[s],i&&Object.keys(i).forEach(t=>{const e=i[t];if(e){e.removeEventListener("enter",this.onEventCueEnter);try{l.removeCue(e)}catch(t){}}})}}else d=this.dateRangeCuesAppended={};const f=t.fragments[t.fragments.length-1];if(0!==c.length&&i(null==f?void 0:f.programDateTime)){this.id3Track||(this.id3Track=this.createTrack(this.media));for(let t=0;t<c.length;t++){const e=c[t],s=h[e],i=s.startTime,r=d[e],n=(null==r?void 0:r.cues)||{};let l=(null==r?void 0:r.durationKnown)||!1,u=xo;const{duration:p,endDate:f}=s;if(f&&null!==p)u=i+p,l=!0;else if(s.endOnNext&&!l){const t=c.reduce((t,e)=>{if(e!==s.id){const i=h[e];if(i.class===s.class&&i.startDate>s.startDate&&(!t||s.startDate<t.startDate))return i}return t},null);t&&(u=t.startTime,l=!0)}const g=Object.keys(s.attr);for(let t=0;t<g.length;t++){const h=g[t];if(!We(h))continue;const c=n[h];if(c)!l||null!=r&&r.durationKnown?Math.abs(c.startTime-i)>.01&&(c.startTime=i,c.endTime=u):c.endTime=u;else if(o){let t=s.attr[h];Ke(h)&&(t=D(t));const r=Po(o,i,u,{key:h,data:t},Ui.dateRange);r&&(r.id=e,this.id3Track.addCue(r),n[h]=r,a&&("X-ASSET-LIST"!==h&&"X-ASSET-URL"!==h||r.addEventListener("enter",this.onEventCueEnter)))}}d[e]={cues:n,dateRange:s,durationKnown:l}}}}}class Do{constructor(t){this.hls=void 0,this.config=void 0,this.media=null,this.currentTime=0,this.stallCount=0,this._latency=null,this._targetLatencyUpdated=!1,this.onTimeupdate=()=>{const{media:t}=this,e=this.levelDetails;if(!t||!e)return;this.currentTime=t.currentTime;const s=this.computeLatency();if(null===s)return;this._latency=s;const{lowLatencyMode:i,maxLiveSyncPlaybackRate:r}=this.config;if(!i||1===r||!e.live)return;const n=this.targetLatency;if(null===n)return;const a=s-n;if(a<Math.min(this.maxLatency,n+e.targetduration)&&a>.05&&this.forwardBufferLength>1){const e=Math.min(2,Math.max(1,r)),s=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20,i=Math.min(e,Math.max(1,s));this.changeMediaPlaybackRate(t,i)}else 1!==t.playbackRate&&0!==t.playbackRate&&this.changeMediaPlaybackRate(t,1)},this.hls=t,this.config=t.config,this.registerListeners()}get levelDetails(){var t;return(null==(t=this.hls)?void 0:t.latestLevelDetails)||null}get latency(){return this._latency||0}get maxLatency(){const{config:t}=this;if(void 0!==t.liveMaxLatencyDuration)return t.liveMaxLatencyDuration;const e=this.levelDetails;return e?t.liveMaxLatencyDurationCount*e.targetduration:0}get targetLatency(){const t=this.levelDetails;if(null===t||null===this.hls)return null;const{holdBack:e,partHoldBack:s,targetduration:i}=t,{liveSyncDuration:r,liveSyncDurationCount:n,lowLatencyMode:a}=this.config,o=this.hls.userConfig;let l=a&&s||e;(this._targetLatencyUpdated||o.liveSyncDuration||o.liveSyncDurationCount||0===l)&&(l=void 0!==r?r:n*i);const h=i;return l+Math.min(this.stallCount*this.config.liveSyncOnStallIncrease,h)}set targetLatency(t){this.stallCount=0,this.config.liveSyncDuration=t,this._targetLatencyUpdated=!0}get liveSyncPosition(){const t=this.estimateLiveEdge(),e=this.targetLatency;if(null===t||null===e)return null;const s=this.levelDetails;if(null===s)return null;const i=s.edge,r=t-e-this.edgeStalled,n=i-s.totalduration,a=i-(this.config.lowLatencyMode&&s.partTarget||s.targetduration);return Math.min(Math.max(n,r),a)}get drift(){const t=this.levelDetails;return null===t?1:t.drift}get edgeStalled(){const t=this.levelDetails;if(null===t)return 0;const e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-e,0)}get forwardBufferLength(){const{media:t}=this,e=this.levelDetails;if(!t||!e)return 0;const s=t.buffered.length;return(s?t.buffered.end(s-1):e.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.hls=null}registerListeners(){const{hls:t}=this;t&&(t.on(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(l.ERROR,this.onError,this))}unregisterListeners(){const{hls:t}=this;t&&(t.off(l.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(l.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(l.ERROR,this.onError,this))}onMediaAttached(t,e){this.media=e.media,this.media.addEventListener("timeupdate",this.onTimeupdate)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.onTimeupdate),this.media=null)}onManifestLoading(){this._latency=null,this.stallCount=0}onLevelUpdated(t,{details:e}){e.advanced&&this.onTimeupdate(),!e.live&&this.media&&this.media.removeEventListener("timeupdate",this.onTimeupdate)}onError(t,e){var s;e.details===o.BUFFER_STALLED_ERROR&&(this.stallCount++,this.hls&&null!=(s=this.levelDetails)&&s.live&&this.hls.logger.warn("[latency-controller]: Stall detected, adjusting target latency"))}changeMediaPlaybackRate(t,e){var s,i;t.playbackRate!==e&&(null==(s=this.hls)||s.logger.debug(`[latency-controller]: latency=${this.latency.toFixed(3)}, targetLatency=${null==(i=this.targetLatency)?void 0:i.toFixed(3)}, forwardBufferLength=${this.forwardBufferLength.toFixed(3)}: adjusting playback rate from ${t.playbackRate} to ${e}`),t.playbackRate=e)}estimateLiveEdge(){const t=this.levelDetails;return null===t?null:t.edge+t.age}computeLatency(){const t=this.estimateLiveEdge();return null===t?null:t-this.currentTime}}class Oo extends Hr{constructor(t,e){super(t,"level-controller"),this._levels=[],this._firstLevel=-1,this._maxAutoLevel=-1,this._startLevel=void 0,this.currentLevel=null,this.currentLevelIndex=-1,this.manualLevelIndex=-1,this.steering=void 0,this.onParsedComplete=void 0,this.steering=e,this._registerListeners()}_registerListeners(){const{hls:t}=this;t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(l.LEVEL_LOADED,this.onLevelLoaded,this),t.on(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(l.FRAG_BUFFERED,this.onFragBuffered,this),t.on(l.ERROR,this.onError,this)}_unregisterListeners(){const{hls:t}=this;t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(l.LEVEL_LOADED,this.onLevelLoaded,this),t.off(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(l.FRAG_BUFFERED,this.onFragBuffered,this),t.off(l.ERROR,this.onError,this)}destroy(){this._unregisterListeners(),this.steering=null,this.resetLevels(),super.destroy()}stopLoad(){this._levels.forEach(t=>{t.loadError=0,t.fragmentError=0}),super.stopLoad()}resetLevels(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1}onManifestLoading(t,e){this.resetLevels()}onManifestLoaded(t,e){const s=this.hls.config.preferManagedMediaSource,i=[],r={},n={};let a=!1,o=!1,l=!1;e.levels.forEach(t=>{const e=t.attrs;let{audioCodec:h,videoCodec:c}=t;h&&(t.audioCodec=h=Lt(h,s)||void 0),c&&(c=t.videoCodec=function(t){const e=t.split(",");for(let t=0;t<e.length;t++){const s=e[t].split(".");s.length>2&&"avc1"===s[0]&&(e[t]=`avc1.${parseInt(s[1]).toString(16)}${("000"+parseInt(s[2]).toString(16)).slice(-4)}`)}return e.join(",")}(c));const{width:d,height:u,unknownCodecs:p}=t,f=(null==p?void 0:p.length)||0;if(a||(a=!(!d||!u)),o||(o=!!c),l||(l=!!h),f||h&&!this.isAudioSupported(h)||c&&!this.isVideoSupported(c))return void this.log(`Some or all CODECS not supported "${e.CODECS}"`);const{CODECS:g,"FRAME-RATE":m,"HDCP-LEVEL":y,"PATHWAY-ID":v,RESOLUTION:b,"VIDEO-RANGE":_}=e,T=`${v||"."}-${t.bitrate}-${b}-${m}-${g}-${_}-${y}`;if(r[T])if(r[T].uri===t.url||t.attrs["PATHWAY-ID"])r[T].addGroupId("audio",e.AUDIO),r[T].addGroupId("text",e.SUBTITLES);else{const e=n[T]+=1;t.attrs["PATHWAY-ID"]=new Array(e+1).join(".");const s=this.createLevel(t);r[T]=s,i.push(s)}else{const e=this.createLevel(t);r[T]=e,n[T]=1,i.push(e)}}),this.filterAndSortMediaOptions(i,e,a,o,l)}createLevel(t){const e=new Wt(t),s=t.supplemental;if(null!=s&&s.videoCodec&&!this.isVideoSupported(s.videoCodec)){const t=new Error(`SUPPLEMENTAL-CODECS not supported "${s.videoCodec}"`);this.log(t.message),e.supportedResult=Ft(t,[])}return e}isAudioSupported(t){return Tt(t,"audio",this.hls.config.preferManagedMediaSource)}isVideoSupported(t){return Tt(t,"video",this.hls.config.preferManagedMediaSource)}filterAndSortMediaOptions(t,e,s,i,r){var n;let h=[],c=[],d=t;const u=(null==(n=e.stats)?void 0:n.parsing)||{};if((s||i)&&r&&(d=d.filter(({videoCodec:t,videoRange:e,width:s,height:i})=>{return(!!t||!(!s||!i))&&!!(r=e)&&Ht.indexOf(r)>-1;var r})),0===d.length)return Promise.resolve().then(()=>{if(this.hls){let t="no level with compatible codecs found in manifest",s=t;e.levels.length&&(s=`one or more CODECS in variant not supported: ${zt(e.levels.map(t=>t.attrs.CODECS).filter((t,e,s)=>s.indexOf(t)===e))}`,this.warn(s),t+=` (${s})`);const i=new Error(t);this.hls.trigger(l.ERROR,{type:a.MEDIA_ERROR,details:o.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:i,reason:s})}}),void(u.end=performance.now());e.audioTracks&&(h=e.audioTracks.filter(t=>!t.audioCodec||this.isAudioSupported(t.audioCodec)),Mo(h)),e.subtitles&&(c=e.subtitles,Mo(c));const p=d.slice(0);d.sort((t,e)=>{if(t.attrs["HDCP-LEVEL"]!==e.attrs["HDCP-LEVEL"])return(t.attrs["HDCP-LEVEL"]||"")>(e.attrs["HDCP-LEVEL"]||"")?1:-1;if(s&&t.height!==e.height)return t.height-e.height;if(t.frameRate!==e.frameRate)return t.frameRate-e.frameRate;if(t.videoRange!==e.videoRange)return Ht.indexOf(t.videoRange)-Ht.indexOf(e.videoRange);if(t.videoCodec!==e.videoCodec){const s=St(t.videoCodec),i=St(e.videoCodec);if(s!==i)return i-s}if(t.uri===e.uri&&t.codecSet!==e.codecSet){const s=Ct(t.codecSet),i=Ct(e.codecSet);if(s!==i)return i-s}return t.averageBitrate!==e.averageBitrate?t.averageBitrate-e.averageBitrate:0});let f=p[0];if(this.steering&&(d=this.steering.filterParsedLevels(d),d.length!==p.length))for(let t=0;t<p.length;t++)if(p[t].pathwayId===d[0].pathwayId){f=p[t];break}this._levels=d;for(let t=0;t<d.length;t++)if(d[t]===f){var g;this._firstLevel=t;const e=f.bitrate,s=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${d.length} level(s) found, first bitrate: ${e}`),void 0===(null==(g=this.hls.userConfig)?void 0:g.abrEwmaDefaultEstimate)){const t=Math.min(e,this.hls.config.abrEwmaDefaultEstimateMax);t>s&&s===this.hls.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=t)}break}const m=r&&!i,y=this.hls.config,v=!(!y.audioStreamController||!y.audioTrackController),b={levels:d,audioTracks:h,subtitleTracks:c,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:r,video:i,altAudio:v&&!m&&h.some(t=>!!t.url)};u.end=performance.now(),this.hls.trigger(l.MANIFEST_PARSED,b)}get levels(){return 0===this._levels.length?null:this._levels}get loadLevelObj(){return this.currentLevel}get level(){return this.currentLevelIndex}set level(t){const e=this._levels;if(0===e.length)return;if(t<0||t>=e.length){const s=new Error("invalid level idx"),i=t<0;if(this.hls.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.LEVEL_SWITCH_ERROR,level:t,fatal:i,error:s,reason:s.message}),i)return;t=Math.min(t,e.length-1)}const s=this.currentLevelIndex,i=this.currentLevel,r=i?i.attrs["PATHWAY-ID"]:void 0,n=e[t],h=n.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=n,s===t&&i&&r===h)return;this.log(`Switching to level ${t} (${n.height?n.height+"p ":""}${n.videoRange?n.videoRange+" ":""}${n.codecSet?n.codecSet+" ":""}@${n.bitrate})${h?" with Pathway "+h:""} from level ${s}${r?" with Pathway "+r:""}`);const c={level:t,attrs:n.attrs,details:n.details,bitrate:n.bitrate,averageBitrate:n.averageBitrate,maxBitrate:n.maxBitrate,realBitrate:n.realBitrate,width:n.width,height:n.height,codecSet:n.codecSet,audioCodec:n.audioCodec,videoCodec:n.videoCodec,audioGroups:n.audioGroups,subtitleGroups:n.subtitleGroups,loaded:n.loaded,loadError:n.loadError,fragmentError:n.fragmentError,name:n.name,id:n.id,uri:n.uri,url:n.url,urlId:0,audioGroupIds:n.audioGroupIds,textGroupIds:n.textGroupIds};this.hls.trigger(l.LEVEL_SWITCHING,c);const d=n.details;if(!d||d.live){const t=this.switchParams(n.uri,null==i?void 0:i.details,d);this.loadPlaylist(t)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}get firstLevel(){return this._firstLevel}set firstLevel(t){this._firstLevel=t}get startLevel(){if(void 0===this._startLevel){const t=this.hls.config.startLevel;return void 0!==t?t:this.hls.firstAutoLevel}return this._startLevel}set startLevel(t){this._startLevel=t}get pathways(){return this.steering?this.steering.pathways():[]}get pathwayPriority(){return this.steering?this.steering.pathwayPriority:null}set pathwayPriority(t){if(this.steering){const e=this.steering.pathways(),s=t.filter(t=>-1!==e.indexOf(t));if(t.length<1)return void this.warn(`pathwayPriority ${t} should contain at least one pathway from list: ${e}`);this.steering.pathwayPriority=s}}onError(t,e){!e.fatal&&e.context&&e.context.type===c&&e.context.level===this.level&&this.checkRetry(e)}onFragBuffered(t,{frag:e}){if(void 0!==e&&e.type===p){const t=e.elementaryStreams;if(!Object.keys(t).some(e=>!!t[e]))return;const s=this._levels[e.level];null!=s&&s.loadError&&(this.log(`Resetting level error count of ${s.loadError} on frag buffered`),s.loadError=0)}}onLevelLoaded(t,e){var s;const{level:i,details:r}=e,n=e.levelInfo;var a;if(!n)return this.warn(`Invalid level index ${i}`),void(null!=(a=e.deliveryDirectives)&&a.skip&&(r.deltaUpdateFailed=!0));if(n===this.currentLevel||e.withoutMultiVariant){0===n.fragmentError&&(n.loadError=0);let t=n.details;t===e.details&&t.advanced&&(t=void 0),this.playlistLoaded(i,e,t)}else null!=(s=e.deliveryDirectives)&&s.skip&&(r.deltaUpdateFailed=!0)}loadPlaylist(t){super.loadPlaylist(),this.shouldLoadPlaylist(this.currentLevel)&&this.scheduleLoading(this.currentLevel,t)}loadingPlaylist(t,e){super.loadingPlaylist(t,e);const s=this.getUrlWithDirectives(t.uri,e),i=this.currentLevelIndex,r=t.attrs["PATHWAY-ID"],n=t.details,a=null==n?void 0:n.age;this.log(`Loading level index ${i}${void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:""}${r?" Pathway "+r:""}${a&&n.live?" age "+a.toFixed(1)+(n.type?" "+n.type||0:""):""} ${s}`),this.hls.trigger(l.LEVEL_LOADING,{url:s,level:i,levelInfo:t,pathwayId:t.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}get nextLoadLevel(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}removeLevel(t){var e;if(1===this._levels.length)return;const s=this._levels.filter((e,s)=>s!==t||(this.steering&&this.steering.removeLevel(e),e===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,e.details&&e.details.fragments.forEach(t=>t.level=-1)),!1));Gs(s),this._levels=s,this.currentLevelIndex>-1&&null!=(e=this.currentLevel)&&e.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.manualLevelIndex>-1&&(this.manualLevelIndex=this.currentLevelIndex);const i=s.length-1;this._firstLevel=Math.min(this._firstLevel,i),this._startLevel&&(this._startLevel=Math.min(this._startLevel,i)),this.hls.trigger(l.LEVELS_UPDATED,{levels:s})}onLevelsUpdated(t,{levels:e}){this._levels=e}checkMaxAutoUpdated(){const{autoLevelCapping:t,maxAutoLevel:e,maxHdcpLevel:s}=this.hls;this._maxAutoLevel!==e&&(this._maxAutoLevel=e,this.hls.trigger(l.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:t,levels:this.levels,maxAutoLevel:e,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:s}))}}function Mo(t){const e={};t.forEach(t=>{const s=t.groupId||"";t.id=e[s]=e[s]||0,e[s]++})}function Fo(){return self.SourceBuffer||self.WebKitSourceBuffer}function No(){if(!I())return!1;const t=Fo();return!t||t.prototype&&"function"==typeof t.prototype.appendBuffer&&"function"==typeof t.prototype.remove}class Bo extends ui{constructor(t,e,s){super(t,e,s,"stream-controller",p),this.audioCodecSwap=!1,this.level=-1,this._forceStartLoad=!1,this._hasEnoughToStart=!1,this.altAudio=0,this.audioOnly=!1,this.fragPlaying=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this.onMediaPlaying=()=>{this.tick()},this.onMediaSeeked=()=>{const t=this.media,e=t?t.currentTime:null;if(null===e||!i(e))return;if(this.log(`Media seeked to ${e.toFixed(3)}`),!this.getBufferedFrag(e))return;const s=this.getFwdBufferInfoAtPos(t,e,p,0);null!==s&&0!==s.len?this.tick():this.warn(`Main forward buffer length at ${e} on "seeked" event ${s?s.len:"empty"})`)},this.registerListeners()}registerListeners(){super.registerListeners();const{hls:t}=this;t.on(l.MANIFEST_PARSED,this.onManifestParsed,this),t.on(l.LEVEL_LOADING,this.onLevelLoading,this),t.on(l.LEVEL_LOADED,this.onLevelLoaded,this),t.on(l.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(l.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(l.BUFFER_CREATED,this.onBufferCreated,this),t.on(l.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(l.FRAG_BUFFERED,this.onFragBuffered,this)}unregisterListeners(){super.unregisterListeners();const{hls:t}=this;t.off(l.MANIFEST_PARSED,this.onManifestParsed,this),t.off(l.LEVEL_LOADED,this.onLevelLoaded,this),t.off(l.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(l.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(l.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(l.BUFFER_CREATED,this.onBufferCreated,this),t.off(l.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(l.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(l.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this.onMediaPlaying=this.onMediaSeeked=null,this.unregisterListeners(),super.onHandlerDestroying()}startLoad(t,e){if(this.levels){const{lastCurrentTime:s,hls:i}=this;if(this.stopLoad(),this.setInterval(100),this.level=-1,!this.startFragRequested){let t=i.startLevel;-1===t&&(i.config.testBandwidth&&this.levels.length>1?(t=0,this.bitrateTest=!0):t=i.firstAutoLevel),i.nextLoadLevel=t,this.level=i.loadLevel,this._hasEnoughToStart=!!e}s>0&&-1===t&&!e&&(this.log(`Override startPosition with lastCurrentTime @${s.toFixed(3)}`),t=s),this.state=ei,this.nextLoadPosition=this.lastCurrentTime=t+this.timelineOffset,this.startPosition=e?-1:t,this.tick()}else this._forceStartLoad=!0,this.state=ti}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case di:{const{levels:t,level:e}=this,s=null==t?void 0:t[e],i=null==s?void 0:s.details;if(i&&(!i.live||this.levelLastLoaded===s&&!this.waitForLive(s))){if(this.waitForCdnTuneIn(i))break;this.state=ei;break}if(this.hls.nextLoadLevel!==this.level){this.state=ei;break}break}case ri:this.checkRetryDate()}this.state===ei&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){var t;super.onTickEnd(),null!=(t=this.media)&&t.readyState&&!1===this.media.seeking&&(this.lastCurrentTime=this.media.currentTime),this.checkFragmentChanged()}doTickIdle(){const{hls:t,levelLastLoaded:e,levels:s,media:i}=this;if(null===e||!i&&!this.primaryPrefetch&&(this.startFragRequested||!t.config.startFragPrefetch))return;if(this.altAudio&&this.audioOnly)return;const r=this.buffering?t.nextLoadLevel:t.loadLevel;if(null==s||!s[r])return;const n=s[r],a=this.getMainFwdBufferInfo();if(null===a)return;const o=this.getLevelDetails();if(o&&this._streamEnded(a,o)){const t={};return 2===this.altAudio&&(t.type="video"),this.hls.trigger(l.BUFFER_EOS,t),void(this.state=li)}if(!this.buffering)return;t.loadLevel!==r&&-1===t.manualLevel&&this.log(`Adapting to level ${r} from level ${this.level}`),this.level=t.nextLoadLevel=r;const h=n.details;if(!h||this.state===di||this.waitForLive(n))return this.level=r,this.state=di,void(this.startFragRequested=!1);const c=a.len,d=this.getMaxBufferLength(n.maxBitrate);if(c>=d)return;this.backtrackFragment&&this.backtrackFragment.start>a.end&&(this.backtrackFragment=null);const u=this.backtrackFragment?this.backtrackFragment.start:a.end;let f=this.getNextFragment(u,h);if(this.couldBacktrack&&!this.fragPrevious&&f&&V(f)&&this.fragmentTracker.getState(f)!==be){var g;const t=(null!=(g=this.backtrackFragment)?g:f).sn-h.startSN,e=h.fragments[t-1];e&&f.cc===e.cc&&(f=e,this.fragmentTracker.removeFragment(e))}else this.backtrackFragment&&a.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,u)){if(!f.gap){const t=this.audioOnly&&!this.altAudio?j:$,e=(t===$?this.videoBuffer:this.mediaBuffer)||this.media;e&&this.afterBufferFlushed(e,t,p)}f=this.getNextFragmentLoopLoading(f,h,a,p,d)}f&&(!f.initSegment||f.initSegment.data||this.bitrateTest||(f=f.initSegment),this.loadFragment(f,n,u))}loadFragment(t,e,s){const i=this.fragmentTracker.getState(t);i===me||i===ve?V(t)?this.bitrateTest?(this.log(`Fragment ${t.sn} of level ${t.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(t,e)):super.loadFragment(t,e,s):this._loadInitSegment(t,e):this.clearTrackerIfNeeded(t)}getBufferedFrag(t){return this.fragmentTracker.getBufferedFrag(t,p)}followingBufferedFrag(t){return t?this.getBufferedFrag(t.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:t,media:e}=this;if(null!=e&&e.readyState){let s;const i=this.getAppendedFrag(e.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);const r=this.getLevelDetails();if(null!=r&&r.live){const t=this.getMainFwdBufferInfo();if(!t||t.len<2*r.targetduration)return}if(!e.paused&&t){const e=t[this.hls.nextLoadLevel],i=this.fragLastKbps;s=i&&this.fragCurrent?this.fragCurrent.duration*e.maxBitrate/(1e3*i)+1:0}else s=0;const n=this.getBufferedFrag(e.currentTime+s);if(n){const t=this.followingBufferedFrag(n);if(t){this.abortCurrentFrag();const e=t.maxStartPTS?t.maxStartPTS:t.start,s=t.duration,i=Math.max(n.end,e+Math.min(Math.max(s-this.config.maxFragLookUpTolerance,s*(this.couldBacktrack?.5:.125)),s*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(i,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case si:case ii:case ri:case ai:case oi:this.state=ei}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(t,e){super.flushMainBuffer(t,e,2===this.altAudio?"video":null)}onMediaAttached(t,e){super.onMediaAttached(t,e);const s=e.media;Zs(s,"playing",this.onMediaPlaying),Zs(s,"seeked",this.onMediaSeeked)}onMediaDetaching(t,e){const{media:s}=this;s&&(Js(s,"playing",this.onMediaPlaying),Js(s,"seeked",this.onMediaSeeked)),this.videoBuffer=null,this.fragPlaying=null,super.onMediaDetaching(t,e),e.transferMedia||(this._hasEnoughToStart=!1)}onManifestLoading(){super.onManifestLoading(),this.log("Trigger BUFFER_RESET"),this.hls.trigger(l.BUFFER_RESET,void 0),this.couldBacktrack=!1,this.fragLastKbps=0,this.fragPlaying=this.backtrackFragment=null,this.altAudio=0,this.audioOnly=!1}onManifestParsed(t,e){let s=!1,i=!1;for(let t=0;t<e.levels.length;t++){const r=e.levels[t].audioCodec;r&&(s=s||-1!==r.indexOf("mp4a.40.2"),i=i||-1!==r.indexOf("mp4a.40.5"))}this.audioCodecSwitch=s&&i&&!function(){var t;const e=Fo();return"function"==typeof(null==e||null==(t=e.prototype)?void 0:t.changeType)}(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1}onLevelLoading(t,e){const{levels:s}=this;if(!s||this.state!==ei)return;const i=e.levelInfo;(!i.details||i.details.live&&(this.levelLastLoaded!==i||i.details.expired)||this.waitForCdnTuneIn(i.details))&&(this.state=di)}onLevelLoaded(t,e){var s;const{levels:i,startFragRequested:r}=this,n=e.level,a=e.details,o=a.totalduration;if(!i)return void this.warn(`Levels were reset while loading level ${n}`);this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const h=e.levelInfo,c=this.fragCurrent;!c||this.state!==ii&&this.state!==ri||c.level!==e.level&&c.loader&&this.abortCurrentFrag();let d=0;if(a.live||null!=(s=h.details)&&s.live){var u;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;d=this.alignPlaylists(a,h.details,null==(u=this.levelLastLoaded)?void 0:u.details)}if(h.details=a,this.levelLastLoaded=h,r||this.setStartPosition(a,d),this.hls.trigger(l.LEVEL_UPDATED,{details:a,level:n}),this.state===di){if(this.waitForCdnTuneIn(a))return;this.state=ei}r&&a.live&&this.synchronizeToLiveEdge(a),this.tick()}synchronizeToLiveEdge(t){const{config:e,media:s}=this;if(!s)return;const i=this.hls.liveSyncPosition,r=this.getLoadPosition(),n=t.fragmentStart,a=t.edge,o=r>=n-e.maxFragLookUpTolerance&&r<=a;if(null!==i&&s.duration>i&&(r<i||!o)){const n=void 0!==e.liveMaxLatencyDuration?e.liveMaxLatencyDuration:e.liveMaxLatencyDurationCount*t.targetduration;if((!o&&s.readyState<4||r<a-n)&&(this._hasEnoughToStart||(this.nextLoadPosition=i),s.readyState))if(this.warn(`Playback: ${r.toFixed(3)} is located too far from the end of live sliding playlist: ${a}, reset currentTime to : ${i.toFixed(3)}`),"buffered"===this.config.liveSyncMode){var l;const t=Fe.bufferInfo(s,i,0);if(null==(l=t.buffered)||!l.length)return void(s.currentTime=i);if(t.start<=r)return void(s.currentTime=i);const{nextStart:e}=Fe.bufferedInfo(t.buffered,r,0);e&&(s.currentTime=e)}else s.currentTime=i}}_handleFragmentLoadProgress(t){var e;const s=t.frag,{part:i,payload:r}=t,{levels:n}=this;if(!n)return void this.warn(`Levels were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);const a=n[s.level];if(!a)return void this.warn(`Level ${s.level} not found on progress`);const o=a.details;if(!o)return this.warn(`Dropping fragment ${s.sn} of level ${s.level} after level details were reset`),void this.fragmentTracker.removeFragment(s);const l=a.videoCodec,h=o.PTSKnown||!o.live,c=null==(e=s.initSegment)?void 0:e.data,d=this._getAudioCodec(a),u=this.transmuxer=this.transmuxer||new Ur(this.hls,p,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,g=-1!==f,m=new Oe(s.level,s.sn,s.stats.chunkCount,r.byteLength,f,g),y=this.initPTS[s.cc];u.push(r,c,d,l,s,i,o.totalduration,h,m,y)}onAudioTrackSwitching(t,e){const s=this.hls,i=0!==this.altAudio;if(ee(e.url,s))this.altAudio=1;else{if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const t=this.fragCurrent;t&&(this.log("Switching to main audio track, cancel main fragment load"),t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();if(i)return this.altAudio=0,this.fragmentTracker.removeAllFragments(),s.once(l.BUFFER_FLUSHED,()=>{this.hls&&this.hls.trigger(l.AUDIO_TRACK_SWITCHED,e)}),void s.trigger(l.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null});s.trigger(l.AUDIO_TRACK_SWITCHED,e)}}onAudioTrackSwitched(t,e){const s=ee(e.url,this.hls);if(s){const t=this.videoBuffer;t&&this.mediaBuffer!==t&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=t)}this.altAudio=s?2:0,this.tick()}onBufferCreated(t,e){const s=e.tracks;let i,r,n=!1;for(const t in s){const e=s[t];if("main"===e.id){if(r=t,i=e,"video"===t){const e=s[t];e&&(this.videoBuffer=e.buffer)}}else n=!0}n&&i?(this.log(`Alternate track found, use ${r}.buffered to schedule main fragment loading`),this.mediaBuffer=i.buffer):this.mediaBuffer=this.media}onFragBuffered(t,e){const{frag:s,part:i}=e,r=s.type===p;if(r){if(this.fragContextChanged(s))return this.warn(`Fragment ${s.sn}${i?" p: "+i.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}`),void(this.state===oi&&(this.state=ei));const t=i?i.stats:s.stats;this.fragLastKbps=Math.round(8*t.total/(t.buffering.end-t.loading.first)),V(s)&&(this.fragPrevious=s),this.fragBufferedComplete(s,i)}const n=this.media;n&&(!this._hasEnoughToStart&&Fe.getBuffered(n).length&&(this._hasEnoughToStart=!0,this.seekToStartPos()),r&&this.tick())}get hasEnoughToStart(){return this._hasEnoughToStart}onError(t,e){var s;if(e.fatal)this.state=hi;else switch(e.details){case o.FRAG_GAP:case o.FRAG_PARSING_ERROR:case o.FRAG_DECRYPT_ERROR:case o.FRAG_LOAD_ERROR:case o.FRAG_LOAD_TIMEOUT:case o.KEY_LOAD_ERROR:case o.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(p,e);break;case o.LEVEL_LOAD_ERROR:case o.LEVEL_LOAD_TIMEOUT:case o.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==di||(null==(s=e.context)?void 0:s.type)!==c||(this.state=ei);break;case o.BUFFER_ADD_CODEC_ERROR:case o.BUFFER_APPEND_ERROR:if("main"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)&&this.resetLoadingState();break;case o.BUFFER_FULL_ERROR:if("main"!==e.parent)return;this.reduceLengthAndFlushBuffer(e)&&(!this.config.interstitialsController&&this.config.assetPlayerId?this._hasEnoughToStart=!0:this.flushMainBuffer(0,Number.POSITIVE_INFINITY));break;case o.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}}onFragLoadEmergencyAborted(){this.state=ei,this._hasEnoughToStart||(this.startFragRequested=!1,this.nextLoadPosition=this.lastCurrentTime),this.tickImmediate()}onBufferFlushed(t,{type:e}){if(e!==j||!this.altAudio){const t=(e===$?this.videoBuffer:this.mediaBuffer)||this.media;t&&(this.afterBufferFlushed(t,e,p),this.tick())}}onLevelsUpdated(t,e){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level,-1===this.level&&this.resetWhenMissingContext(this.fragCurrent)),this.levels=e.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:t}=this;if(!t)return;const e=t.currentTime;let s=this.startPosition;if(s>=0&&e<s){if(t.seeking)return void this.log(`could not seek to ${s}, already seeking at ${e}`);const i=this.timelineOffset;i&&s&&(s+=i);const r=this.getLevelDetails(),n=Fe.getBuffered(t),a=n.length?n.start(0):0,o=a-s,l=Math.max(this.config.maxBufferHole,this.config.maxFragLookUpTolerance);(this.config.startOnSegmentBoundary||o>0&&(o<l||this.loadingParts&&o<2*((null==r?void 0:r.partTarget)||0)))&&(this.log(`adjusting start position by ${o} to match buffer start`),s+=o,this.startPosition=s),e<s&&(this.log(`seek to target start position ${s} from current time ${e} buffer start ${a}`),t.currentTime=s)}}_getAudioCodec(t){let e=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&e&&(this.log("Swapping audio codec"),e=-1!==e.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),e}_loadBitrateTestFrag(t,e){t.bitrateTest=!0,this._doFragLoad(t,e).then(t=>{const{hls:s}=this,i=null==t?void 0:t.frag;if(!i||this.fragContextChanged(i))return;e.fragmentError=0,this.state=ei,this.startFragRequested=!1,this.bitrateTest=!1;const r=i.stats;r.parsing.start=r.parsing.end=r.buffering.start=r.buffering.end=self.performance.now(),s.trigger(l.FRAG_LOADED,t),i.bitrateTest=!1}).catch(e=>{this.state!==ti&&this.state!==hi&&(this.warn(e),this.resetFragmentLoading(t))})}_handleTransmuxComplete(t){const e=this.playlistType,{hls:s}=this,{remuxResult:r,chunkMeta:n}=t,a=this.getCurrentContext(n);if(!a)return void this.resetWhenMissingContext(n);const{frag:o,part:h,level:c}=a,{video:d,text:u,id3:p,initSegment:f}=r,{details:g}=c,m=this.altAudio?void 0:r.audio;if(this.fragContextChanged(o))this.fragmentTracker.removeFragment(o);else{if(this.state=ai,f){const t=f.tracks;if(t){const i=o.initSegment||o;if(this.unhandledEncryptionError(f,o))return;this._bufferInitSegment(c,t,i,n),s.trigger(l.FRAG_PARSING_INIT_SEGMENT,{frag:i,id:e,tracks:t})}const r=f.initPTS,a=f.timescale,h=this.initPTS[o.cc];if(i(r)&&(!h||h.baseTime!==r||h.timescale!==a)){const t=f.trackId;this.initPTS[o.cc]={baseTime:r,timescale:a,trackId:t},s.trigger(l.INIT_PTS_FOUND,{frag:o,id:e,initPTS:r,timescale:a,trackId:t})}}if(d&&g){m&&"audiovideo"===d.type&&this.logMuxedErr(o);const t=g.fragments[o.sn-1-g.startSN],e=o.sn===g.startSN,s=!t||o.cc>t.cc;if(!1!==r.independent){const{startPTS:t,endPTS:i,startDTS:r,endDTS:a}=d;if(h)h.elementaryStreams[d.type]={startPTS:t,endPTS:i,startDTS:r,endDTS:a};else if(d.firstKeyFrame&&d.independent&&1===n.id&&!s&&(this.couldBacktrack=!0),d.dropped&&d.independent){const r=this.getMainFwdBufferInfo(),n=(r?r.end:this.getLoadPosition())+this.config.maxBufferHole,l=d.firstKeyFramePTS?d.firstKeyFramePTS:t;if(!e&&n<l-this.config.maxBufferHole&&!s)return void this.backtrack(o);s&&(o.gap=!0),o.setElementaryStreamInfo(d.type,o.start,i,o.start,a,!0)}else e&&t-(g.appliedTimelineOffset||0)>2&&(o.gap=!0);o.setElementaryStreamInfo(d.type,t,i,r,a),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(d,o,h,n,e||s)}else{if(!e&&!s)return void this.backtrack(o);o.gap=!0}}if(m){const{startPTS:t,endPTS:e,startDTS:s,endDTS:i}=m;h&&(h.elementaryStreams[j]={startPTS:t,endPTS:e,startDTS:s,endDTS:i}),o.setElementaryStreamInfo(j,t,e,s,i),this.bufferFragmentData(m,o,h,n)}if(g&&null!=p&&p.samples.length){const t={id:e,frag:o,details:g,samples:p.samples};s.trigger(l.FRAG_PARSING_METADATA,t)}if(g&&u){const t={id:e,frag:o,details:g,samples:u.samples};s.trigger(l.FRAG_PARSING_USERDATA,t)}}}logMuxedErr(t){this.warn(`${V(t)?"Media":"Init"} segment with muxed audiovideo where only video expected: ${t.url}`)}_bufferInitSegment(t,e,s,i){if(this.state!==ai)return;this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&(delete e.audio,e.audiovideo&&this.logMuxedErr(s));const{audio:r,video:n,audiovideo:a}=e;if(r){const s=t.audioCodec;let i=It(r.codec,s);"mp4a"===i&&(i="mp4a.40.5");const n=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){i&&(i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5");const t=r.metadata;t&&"channelCount"in t&&1!==(t.channelCount||1)&&-1===n.indexOf("firefox")&&(i="mp4a.40.5")}i&&-1!==i.indexOf("mp4a.40.5")&&-1!==n.indexOf("android")&&"audio/mpeg"!==r.container&&(i="mp4a.40.2",this.log(`Android: force audio codec to ${i}`)),s&&s!==i&&this.log(`Swapping manifest audio codec "${s}" for "${i}"`),r.levelCodec=i,r.id=p,this.log(`Init audio buffer, container:${r.container}, codecs[selected/level/parsed]=[${i||""}/${s||""}/${r.codec}]`),delete e.audiovideo}if(n){n.levelCodec=t.videoCodec,n.id=p;const s=n.codec;if(4===(null==s?void 0:s.length))switch(s){case"hvc1":case"hev1":n.codec="hvc1.1.6.L120.90";break;case"av01":n.codec="av01.0.04M.08";break;case"avc1":n.codec="avc1.42e01e"}this.log(`Init video buffer, container:${n.container}, codecs[level/parsed]=[${t.videoCodec||""}/${s}]${n.codec!==s?" parsed-corrected="+n.codec:""}${n.supplemental?" supplemental="+n.supplemental:""}`),delete e.audiovideo}a&&(this.log(`Init audiovideo buffer, container:${a.container}, codecs[level/parsed]=[${t.codecs}/${a.codec}]`),delete e.video,delete e.audio);const o=Object.keys(e);if(o.length){if(this.hls.trigger(l.BUFFER_CODECS,e),!this.hls)return;o.forEach(t=>{const r=e[t].initSegment;null!=r&&r.byteLength&&this.hls.trigger(l.BUFFER_APPENDING,{type:t,data:r,frag:s,part:null,chunkMeta:i,parent:s.type})})}this.tickImmediate()}getMainFwdBufferInfo(){const t=this.mediaBuffer&&2===this.altAudio?this.mediaBuffer:this.media;return this.getFwdBufferInfo(t,p)}get maxBufferLength(){const{levels:t,level:e}=this,s=null==t?void 0:t[e];return s?this.getMaxBufferLength(s.maxBitrate):this.config.maxBufferLength}backtrack(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=ei}checkFragmentChanged(){const t=this.media;let e=null;if(t&&t.readyState>1&&!1===t.seeking){const s=t.currentTime;if(Fe.isBuffered(t,s)?e=this.getAppendedFrag(s):Fe.isBuffered(t,s+.1)&&(e=this.getAppendedFrag(s+.1)),e){this.backtrackFragment=null;const t=this.fragPlaying,s=e.level;t&&e.sn===t.sn&&t.level===s||(this.fragPlaying=e,this.hls.trigger(l.FRAG_CHANGED,{frag:e}),t&&t.level===s||this.hls.trigger(l.LEVEL_SWITCHED,{level:s}))}}}get nextLevel(){const t=this.nextBufferedFrag;return t?t.level:-1}get currentFrag(){var t;if(this.fragPlaying)return this.fragPlaying;const e=(null==(t=this.media)?void 0:t.currentTime)||this.lastCurrentTime;return i(e)?this.getAppendedFrag(e):null}get currentProgramDateTime(){var t;const e=(null==(t=this.media)?void 0:t.currentTime)||this.lastCurrentTime;if(i(e)){const t=this.getLevelDetails(),s=this.currentFrag||(t?ie(null,t.fragments,e):null);if(s){const t=s.programDateTime;if(null!==t){const i=t+1e3*(e-s.start);return new Date(i)}}}return null}get currentLevel(){const t=this.currentFrag;return t?t.level:-1}get nextBufferedFrag(){const t=this.currentFrag;return t?this.followingBufferedFrag(t):null}get forceStartLoad(){return this._forceStartLoad}}class jo extends A{constructor(t,e){super("key-loader",e),this.config=void 0,this.keyIdToKeyInfo={},this.emeController=null,this.config=t}abort(t){for(const s in this.keyIdToKeyInfo){const i=this.keyIdToKeyInfo[s].loader;if(i){var e;if(t&&t!==(null==(e=i.context)?void 0:e.frag.type))return;i.abort()}}}detach(){for(const t in this.keyIdToKeyInfo){const e=this.keyIdToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyIdToKeyInfo[t]}}destroy(){this.detach();for(const t in this.keyIdToKeyInfo){const e=this.keyIdToKeyInfo[t].loader;e&&e.destroy()}this.keyIdToKeyInfo={}}createKeyLoadError(t,e=o.KEY_LOAD_ERROR,s,i,r){return new Re({type:a.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:r,error:s,networkDetails:i})}loadClear(t,e,s){if(this.emeController&&this.config.emeEnabled&&!this.emeController.getSelectedKeySystemFormats().length){if(e.length)for(let i=0,r=e.length;i<r;i++){const n=e[i];if(t.cc<=n.cc&&(!V(t)||!V(n)||t.sn<n.sn)||!s&&i==r-1)return this.emeController.selectKeySystemFormat(n).then(t=>{if(!this.emeController)return;n.setKeyFormat(t);const e=hs(t);return e?this.emeController.getKeySystemAccess([e]):void 0})}if(this.config.requireKeySystemAccessOnStart){const t=ds(this.config);if(t.length)return this.emeController.getKeySystemAccess(t)}}return null}load(t){return!t.decryptdata&&t.encrypted&&this.emeController&&this.config.emeEnabled?this.emeController.selectKeySystemFormat(t).then(e=>this.loadInternal(t,e)):this.loadInternal(t)}loadInternal(t,e){var s,i;e&&t.setKeyFormat(e);const r=t.decryptdata;if(!r){const s=new Error(e?`Expected frag.decryptdata to be defined after setting format ${e}`:`Missing decryption data on fragment in onKeyLoading (emeEnabled with controller: ${this.emeController&&this.config.emeEnabled})`);return Promise.reject(this.createKeyLoadError(t,o.KEY_LOAD_ERROR,s))}const n=r.uri;if(!n)return Promise.reject(this.createKeyLoadError(t,o.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${n}"`)));const a=$o(r);let l=this.keyIdToKeyInfo[a];if(null!=(s=l)&&s.decryptdata.key)return r.key=l.decryptdata.key,Promise.resolve({frag:t,keyInfo:l});if(this.emeController&&null!=(i=l)&&i.keyLoadPromise)switch(this.emeController.getKeyStatus(l.decryptdata)){case"usable":case"usable-in-future":return l.keyLoadPromise.then(e=>{const{keyInfo:s}=e;return r.key=s.decryptdata.key,{frag:t,keyInfo:s}})}switch(this.log(`${this.keyIdToKeyInfo[a]?"Rel":"L"}oading${r.keyId?" keyId: "+R(r.keyId):""} URI: ${r.uri} from ${t.type} ${t.level}`),l=this.keyIdToKeyInfo[a]={decryptdata:r,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},r.method){case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return"identity"===r.keyFormat?this.loadKeyHTTP(l,t):this.loadKeyEME(l,t);case"AES-128":case"AES-256":case"AES-256-CTR":return this.loadKeyHTTP(l,t);default:return Promise.reject(this.createKeyLoadError(t,o.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${r.method}"`)))}}loadKeyEME(t,e){const s={frag:e,keyInfo:t};if(this.emeController&&this.config.emeEnabled){var i;if(!t.decryptdata.keyId&&null!=(i=e.initSegment)&&i.data){const s=function(t){const e=[];return ht(t,t=>e.push(t.subarray(8,24))),e}(e.initSegment.data);if(s.length){let e=s[0];e.some(t=>0!==t)?(this.log(`Using keyId found in init segment ${R(e)}`),ms.setKeyIdForUri(t.decryptdata.uri,e)):(e=ms.addKeyIdForUri(t.decryptdata.uri),this.log(`Generating keyId to patch media ${R(e)}`)),t.decryptdata.keyId=e}}if(!t.decryptdata.keyId&&!V(e))return Promise.resolve(s);const r=this.emeController.loadKey(s);return(t.keyLoadPromise=r.then(e=>(t.mediaKeySessionContext=e,s))).catch(s=>{throw t.keyLoadPromise=null,"data"in s&&(s.data.frag=e),s})}return Promise.resolve(s)}loadKeyHTTP(t,e){const s=this.config,i=new(0,s.loader)(s);return e.keyLoader=t.loader=i,t.keyLoadPromise=new Promise((r,n)=>{const a={keyInfo:t,frag:e,responseType:"arraybuffer",url:t.decryptdata.uri},l=s.keyLoadPolicy.default,h={loadPolicy:l,timeout:l.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(t,e,s,i)=>{const{frag:a,keyInfo:l}=s,h=$o(l.decryptdata);if(!a.decryptdata||l!==this.keyIdToKeyInfo[h])return n(this.createKeyLoadError(a,o.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),i));l.decryptdata.key=a.decryptdata.key=new Uint8Array(t.data),a.keyLoader=null,l.loader=null,r({frag:a,keyInfo:l})},onError:(t,s,i,r)=>{this.resetLoader(s),n(this.createKeyLoadError(e,o.KEY_LOAD_ERROR,new Error(`HTTP Error ${t.code} loading key ${t.text}`),i,T({url:a.url,data:void 0},t)))},onTimeout:(t,s,i)=>{this.resetLoader(s),n(this.createKeyLoadError(e,o.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),i))},onAbort:(t,s,i)=>{this.resetLoader(s),n(this.createKeyLoadError(e,o.INTERNAL_ABORTED,new Error("key loading aborted"),i))}};i.load(a,h,c)})}resetLoader(t){const{frag:e,keyInfo:s,url:i}=t,r=s.loader;e.keyLoader===r&&(e.keyLoader=null,s.loader=null);const n=$o(s.decryptdata)||i;delete this.keyIdToKeyInfo[n],r&&r.destroy()}}function $o(t){if(t.keyFormat!==as){const e=t.keyId;if(e)return R(e)}return t.uri}function Uo(t){const{type:e}=t;switch(e){case d:return f;case u:return g;default:return p}}function Ho(t,e){let s=t.url;return void 0!==s&&0!==s.indexOf("data:")||(s=e.url),s}class Vo{constructor(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.onManifestLoaded=this.checkAutostartLoad,this.hls=t,this.registerListeners()}startLoad(t){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:t}=this;t.on(l.MANIFEST_LOADING,this.onManifestLoading,this),t.on(l.LEVEL_LOADING,this.onLevelLoading,this),t.on(l.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(l.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),t.on(l.LEVELS_UPDATED,this.onLevelsUpdated,this)}unregisterListeners(){const{hls:t}=this;t.off(l.MANIFEST_LOADING,this.onManifestLoading,this),t.off(l.LEVEL_LOADING,this.onLevelLoading,this),t.off(l.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(l.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this),t.off(l.LEVELS_UPDATED,this.onLevelsUpdated,this)}createInternalLoader(t){const e=this.hls.config,s=e.pLoader,i=e.loader,r=new(s||i)(e);return this.loaders[t.type]=r,r}getInternalLoader(t){return this.loaders[t.type]}resetInternalLoader(t){this.loaders[t]&&delete this.loaders[t]}destroyInternalLoaders(){for(const t in this.loaders){const e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(t,e){const{url:s}=e;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:h,url:s,deliveryDirectives:null,levelOrTrack:null})}onLevelLoading(t,e){const{id:s,level:i,pathwayId:r,url:n,deliveryDirectives:a,levelInfo:o}=e;this.load({id:s,level:i,pathwayId:r,responseType:"text",type:c,url:n,deliveryDirectives:a,levelOrTrack:o})}onAudioTrackLoading(t,e){const{id:s,groupId:i,url:r,deliveryDirectives:n,track:a}=e;this.load({id:s,groupId:i,level:null,responseType:"text",type:d,url:r,deliveryDirectives:n,levelOrTrack:a})}onSubtitleTrackLoading(t,e){const{id:s,groupId:i,url:r,deliveryDirectives:n,track:a}=e;this.load({id:s,groupId:i,level:null,responseType:"text",type:u,url:r,deliveryDirectives:n,levelOrTrack:a})}onLevelsUpdated(t,e){const s=this.loaders[c];if(s){const t=s.context;t&&!e.levels.some(e=>e===t.levelOrTrack)&&(s.abort(),delete this.loaders[c])}}load(t){var e;const s=this.hls.config;let r,n=this.getInternalLoader(t);if(n){const e=this.hls.logger,s=n.context;if(s&&s.levelOrTrack===t.levelOrTrack&&(s.url===t.url||s.deliveryDirectives&&!t.deliveryDirectives))return void(s.url===t.url?e.log(`[playlist-loader]: ignore ${t.url} ongoing request`):e.log(`[playlist-loader]: ignore ${t.url} in favor of ${s.url}`));e.log(`[playlist-loader]: aborting previous loader for type: ${t.type}`),n.abort()}if(r=t.type===h?s.manifestLoadPolicy.default:b({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),n=this.createInternalLoader(t),i(null==(e=t.deliveryDirectives)?void 0:e.part)){let e;if(t.type===c&&null!==t.level?e=this.hls.levels[t.level].details:t.type===d&&null!==t.id?e=this.hls.audioTracks[t.id].details:t.type===u&&null!==t.id&&(e=this.hls.subtitleTracks[t.id].details),e){const t=e.partTarget,s=e.targetduration;if(t&&s){const e=1e3*Math.max(3*t,.8*s);r=b({},r,{maxTimeToFirstByteMs:Math.min(e,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(e,r.maxTimeToFirstByteMs)})}}}const a=r.errorRetry||r.timeoutRetry||{},o={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(t,e,s,i)=>{const r=this.getInternalLoader(s);this.resetInternalLoader(s.type);const n=t.data;e.parsing.start=performance.now(),Es.isMediaPlaylist(n)||s.type!==h?this.handleTrackOrLevelPlaylist(t,e,s,i||null,r):this.handleMasterPlaylist(t,e,s,i)},onError:(t,e,s,i)=>{this.handleNetworkError(e,s,!1,t,i)},onTimeout:(t,e,s)=>{this.handleNetworkError(e,s,!0,void 0,t)}};n.load(t,o,l)}checkAutostartLoad(){if(!this.hls)return;const{config:{autoStartLoad:t,startPosition:e},forceStartLoad:s}=this.hls;(t||s)&&(this.hls.logger.log(`${t?"auto":"force"} startLoad with configured startPosition ${e}`),this.hls.startLoad(e))}handleMasterPlaylist(t,e,s,i){const r=this.hls,n=t.data,a=Ho(t,s),o=Es.parseMasterPlaylist(n,a);if(o.playlistParsingError)return e.parsing.end=performance.now(),void this.handleManifestParsingError(t,s,o.playlistParsingError,i,e);const{contentSteering:h,levels:c,sessionData:d,sessionKeys:u,startTimeOffset:p,variableList:f}=o;this.variableList=f,c.forEach(t=>{const{unknownCodecs:e}=t;if(e){const{preferManagedMediaSource:s}=this.hls.config;let{audioCodec:i,videoCodec:r}=t;for(let n=e.length;n--;){const a=e[n];Tt(a,"audio",s)?(t.audioCodec=i=i?`${i},${a}`:a,bt.audio[i.substring(0,4)]=2,e.splice(n,1)):Tt(a,"video",s)&&(t.videoCodec=r=r?`${r},${a}`:a,bt.video[r.substring(0,4)]=2,e.splice(n,1))}}});const{AUDIO:g=[],SUBTITLES:m,"CLOSED-CAPTIONS":y}=Es.parseMasterPlaylistMedia(n,a,o);g.length&&(g.some(t=>!t.url)||!c[0].audioCodec||c[0].attrs.AUDIO||(this.hls.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Ge({}),bitrate:0,url:""}))),r.trigger(l.MANIFEST_LOADED,{levels:c,audioTracks:g,subtitles:m,captions:y,contentSteering:h,url:a,stats:e,networkDetails:i,sessionData:d,sessionKeys:u,startTimeOffset:p,variableList:f})}handleTrackOrLevelPlaylist(t,e,s,r,n){const a=this.hls,{id:o,level:c,type:d}=s,u=Ho(t,s),p=i(c)?c:i(o)?o:0,f=Uo(s),g=Es.parseLevelPlaylist(t.data,u,p,f,0,this.variableList);if(d===h){const t={attrs:new Ge({}),bitrate:0,details:g,name:"",url:u};g.requestScheduled=e.loading.start+$s(g,0),a.trigger(l.MANIFEST_LOADED,{levels:[t],audioTracks:[],url:u,stats:e,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),s.levelDetails=g,this.handlePlaylistLoaded(g,t,e,s,r,n)}handleManifestParsingError(t,e,s,i,r){this.hls.trigger(l.ERROR,{type:a.NETWORK_ERROR,details:o.MANIFEST_PARSING_ERROR,fatal:e.type===h,url:t.url,err:s,error:s,reason:s.message,response:t,context:e,networkDetails:i,stats:r})}handleNetworkError(t,e,s=!1,i,r){let n=`A network ${s?"timeout":"error"+(i?" (status "+i.code+")":"")} occurred while loading ${t.type}`;t.type===c?n+=`: ${t.level} id: ${t.id}`:t.type!==d&&t.type!==u||(n+=` id: ${t.id} group-id: "${t.groupId}"`);const p=new Error(n);this.hls.logger.warn(`[playlist-loader]: ${n}`);let f=o.UNKNOWN,g=!1;const m=this.getInternalLoader(t);switch(t.type){case h:f=s?o.MANIFEST_LOAD_TIMEOUT:o.MANIFEST_LOAD_ERROR,g=!0;break;case c:f=s?o.LEVEL_LOAD_TIMEOUT:o.LEVEL_LOAD_ERROR,g=!1;break;case d:f=s?o.AUDIO_TRACK_LOAD_TIMEOUT:o.AUDIO_TRACK_LOAD_ERROR,g=!1;break;case u:f=s?o.SUBTITLE_TRACK_LOAD_TIMEOUT:o.SUBTITLE_LOAD_ERROR,g=!1}m&&this.resetInternalLoader(t.type);const y={type:a.NETWORK_ERROR,details:f,fatal:g,url:t.url,loader:m,context:t,error:p,networkDetails:e,stats:r};if(i){const s=(null==e?void 0:e.url)||t.url;y.response=T({url:s,data:void 0},i)}this.hls.trigger(l.ERROR,y)}handlePlaylistLoaded(t,e,s,i,r,n){const f=this.hls,{type:g,level:m,levelOrTrack:y,id:v,groupId:b,deliveryDirectives:_}=i,T=Ho(e,i),A=Uo(i);let E="number"==typeof i.level&&A===p?m:void 0;const S=t.playlistParsingError;if(S){if(this.hls.logger.warn(`${S} ${t.url}`),!f.config.ignorePlaylistParsingErrors)return void f.trigger(l.ERROR,{type:a.NETWORK_ERROR,details:o.LEVEL_PARSING_ERROR,fatal:!1,url:T,error:S,reason:S.message,response:e,context:i,level:E,parent:A,networkDetails:r,stats:s});t.playlistParsingError=null}if(!t.fragments.length){const n=t.playlistParsingError=new Error("No Segments found in Playlist");return void f.trigger(l.ERROR,{type:a.NETWORK_ERROR,details:o.LEVEL_EMPTY_ERROR,fatal:!1,url:T,error:n,reason:n.message,response:e,context:i,level:E,parent:A,networkDetails:r,stats:s})}switch(t.live&&n&&(n.getCacheAge&&(t.ageHeader=n.getCacheAge()||0),n.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),g){case h:case c:if(E)if(y){if(y!==f.levels[E]){const t=f.levels.indexOf(y);t>-1&&(E=t)}}else E=0;f.trigger(l.LEVEL_LOADED,{details:t,levelInfo:y||f.levels[0],level:E||0,id:v||0,stats:s,networkDetails:r,deliveryDirectives:_,withoutMultiVariant:g===h});break;case d:f.trigger(l.AUDIO_TRACK_LOADED,{details:t,track:y,id:v||0,groupId:b||"",stats:s,networkDetails:r,deliveryDirectives:_});break;case u:f.trigger(l.SUBTITLE_TRACK_LOADED,{details:t,track:y,id:v||0,groupId:b||"",stats:s,networkDetails:r,deliveryDirectives:_})}}}class Go{static get version(){return bi}static isMSESupported(){return No()}static isSupported(){return function(){if(!No())return!1;const t=I();return"function"==typeof(null==t?void 0:t.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>t.isTypeSupported(Et(e,"video")))||["mp4a.40.2","fLaC"].some(e=>t.isTypeSupported(Et(e,"audio"))))}()}static getMediaSource(){return I()}static get Events(){return l}static get MetadataSchema(){return Ui}static get ErrorTypes(){return a}static get ErrorDetails(){return o}static get DefaultConfig(){return Go.defaultConfig?Go.defaultConfig:Eo}static set DefaultConfig(t){Go.defaultConfig=t}constructor(t={}){this.config=void 0,this.userConfig=void 0,this.logger=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new vi,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioStreamController=void 0,this.subtititleStreamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.interstitialsController=void 0,this.gapController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this._url=null,this._sessionId=void 0,this.triggeringException=void 0,this.started=!1;const e=this.logger=function(t,e,s){const i=C();if("object"==typeof console&&!0===t||"object"==typeof t){const e=["debug","log","info","warn","error"];e.forEach(e=>{i[e]=k(e,t,s)});try{i.log('Debug logs enabled for "Hls instance" in hls.js version 1.6.15')}catch(t){return C()}e.forEach(e=>{w[e]=k(e,t)})}else b(w,i);return i}(t.debug||!1,0,t.assetPlayerId),s=this.config=function(t,e,s){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const i=So(t),r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach(t=>{const n=`${"level"===t?"playlist":t}LoadPolicy`,a=void 0===e[n],o=[];r.forEach(s=>{const r=`${t}Loading${s}`,l=e[r];if(void 0!==l&&a){o.push(r);const t=i[n].default;switch(e[n]={default:t},s){case"TimeOut":t.maxLoadTimeMs=l,t.maxTimeToFirstByteMs=l;break;case"MaxRetry":t.errorRetry.maxNumRetry=l,t.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":t.errorRetry.retryDelayMs=l,t.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":t.errorRetry.maxRetryDelayMs=l,t.timeoutRetry.maxRetryDelayMs=l}}}),o.length&&s.warn(`hls.js config: "${o.join('", "')}" setting(s) are deprecated, use "${n}": ${zt(e[n])}`)}),T(T({},i),e)}(Go.DefaultConfig,t,e);this.userConfig=t,s.progressive&&function(t,e){const s=t.loader;s!==vo&&s!==Ao?(e.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}()&&(t.loader=vo,t.progressive=!0,t.enableSoftwareAES=!0,e.log("[config]: Progressive streaming enabled, using FetchLoader"))}(s,e);const{abrController:i,bufferController:r,capLevelController:n,errorController:a,fpsController:o}=s,h=new a(this),c=this.abrController=new i(this),d=new _e(this),u=s.interstitialsController,p=u?this.interstitialsController=new u(this,Go):null,f=this.bufferController=new r(this,d),g=this.capLevelController=new n(this),m=new o(this),y=new Vo(this),v=s.contentSteeringController,_=v?new v(this):null,A=this.levelController=new Oo(this,_),E=new Ro(this),S=new jo(this.config,this.logger),L=this.streamController=new Bo(this,d,S),I=this.gapController=new Co(this,d);g.setStreamController(L),m.setStreamController(L);const P=[y,A,L];p&&P.splice(1,0,p),_&&P.splice(1,0,_),this.networkControllers=P;const x=[c,f,I,g,m,E,d];this.audioTrackController=this.createController(s.audioTrackController,P);const R=s.audioStreamController;R&&P.push(this.audioStreamController=new R(this,d,S)),this.subtitleTrackController=this.createController(s.subtitleTrackController,P);const D=s.subtitleStreamController;D&&P.push(this.subtititleStreamController=new D(this,d,S)),this.createController(s.timelineController,x),S.emeController=this.emeController=this.createController(s.emeController,x),this.cmcdController=this.createController(s.cmcdController,x),this.latencyController=this.createController(Do,x),this.coreComponents=x,P.push(h);const O=h.onErrorOut;"function"==typeof O&&this.on(l.ERROR,O,h),this.on(l.MANIFEST_LOADED,y.onManifestLoaded,y)}createController(t,e){if(t){const s=new t(this);return e&&e.push(s),s}return null}on(t,e,s=this){this._emitter.on(t,e,s)}once(t,e,s=this){this._emitter.once(t,e,s)}removeAllListeners(t){this._emitter.removeAllListeners(t)}off(t,e,s=this,i){this._emitter.off(t,e,s,i)}listeners(t){return this._emitter.listeners(t)}emit(t,e,s){return this._emitter.emit(t,e,s)}trigger(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){if(this.logger.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),!this.triggeringException){this.triggeringException=!0;const s=t===l.ERROR;this.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.INTERNAL_EXCEPTION,fatal:s,event:t,error:e}),this.triggeringException=!1}}return!1}listenerCount(t){return this._emitter.listenerCount(t)}destroy(){this.logger.log("destroy"),this.trigger(l.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this._url=null,this.networkControllers.forEach(t=>t.destroy()),this.networkControllers.length=0,this.coreComponents.forEach(t=>t.destroy()),this.coreComponents.length=0;const t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null}attachMedia(t){if(!t||"media"in t&&!t.media){const e=new Error(`attachMedia failed: invalid argument (${t})`);return void this.trigger(l.ERROR,{type:a.OTHER_ERROR,details:o.ATTACH_MEDIA_ERROR,fatal:!0,error:e})}this.logger.log("attachMedia"),this._media&&(this.logger.warn("media must be detached before attaching"),this.detachMedia());const e="media"in t,s=e?t.media:t,i=e?t:{media:s};this._media=s,this.trigger(l.MEDIA_ATTACHING,i)}detachMedia(){this.logger.log("detachMedia"),this.trigger(l.MEDIA_DETACHING,{}),this._media=null}transferMedia(){this._media=null;const t=this.bufferController.transferMedia();return this.trigger(l.MEDIA_DETACHING,{transferMedia:t}),t}loadSource(t){this.stopLoad();const e=this.media,s=this._url,i=this._url=N.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.logger.log(`loadSource:${i}`),e&&s&&(s!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(l.MANIFEST_LOADING,{url:t})}get url(){return this._url}get hasEnoughToStart(){return this.streamController.hasEnoughToStart}get startPosition(){return this.streamController.startPositionValue}startLoad(t=-1,e){this.logger.log(`startLoad(${t+(e?", <skip seek to start>":"")})`),this.started=!0,this.resumeBuffering();for(let s=0;s<this.networkControllers.length&&(this.networkControllers[s].startLoad(t,e),this.started&&this.networkControllers);s++);}stopLoad(){this.logger.log("stopLoad"),this.started=!1;for(let t=0;t<this.networkControllers.length&&(this.networkControllers[t].stopLoad(),!this.started&&this.networkControllers);t++);}get loadingEnabled(){return this.started}get bufferingEnabled(){return this.streamController.bufferingEnabled}resumeBuffering(){this.bufferingEnabled||(this.logger.log("resume buffering"),this.networkControllers.forEach(t=>{t.resumeBuffering&&t.resumeBuffering()}))}pauseBuffering(){this.bufferingEnabled&&(this.logger.log("pause buffering"),this.networkControllers.forEach(t=>{t.pauseBuffering&&t.pauseBuffering()}))}get inFlightFragments(){const t={[p]:this.streamController.inFlightFrag};return this.audioStreamController&&(t[f]=this.audioStreamController.inFlightFrag),this.subtititleStreamController&&(t[g]=this.subtititleStreamController.inFlightFrag),t}swapAudioCodec(){this.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){this.logger.log("recoverMediaError");const t=this._media,e=null==t?void 0:t.currentTime;this.detachMedia(),t&&(this.attachMedia(t),e&&this.startLoad(e))}removeLevel(t){this.levelController.removeLevel(t)}get sessionId(){let t=this._sessionId;return t||(t=this._sessionId=function(){try{return crypto.randomUUID()}catch(t){try{const t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)}catch(t){let e=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const s=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?s:3&s|8).toString(16)})}}}()),t}get levels(){return this.levelController.levels||[]}get latestLevelDetails(){return this.streamController.getLevelDetails()||null}get loadLevelObj(){return this.levelController.loadLevelObj}get currentLevel(){return this.streamController.currentLevel}set currentLevel(t){this.logger.log(`set currentLevel:${t}`),this.levelController.manualLevel=t,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(t){this.logger.log(`set nextLevel:${t}`),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(t){this.logger.log(`set loadLevel:${t}`),this.levelController.manualLevel=t}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(t){this.levelController.nextLoadLevel=t}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(t){this.logger.log(`set firstLevel:${t}`),this.levelController.firstLevel=t}get startLevel(){const t=this.levelController.startLevel;return-1===t&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:t}set startLevel(t){this.logger.log(`set startLevel:${t}`),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(t){const e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimate():NaN}set bandwidthEstimate(t){this.abrController.resetEstimator(t)}get abrEwmaDefaultEstimate(){const{bwEstimator:t}=this.abrController;return t?t.defaultEstimate:NaN}get ttfbEstimate(){const{bwEstimator:t}=this.abrController;return t?t.getEstimateTTFB():NaN}set autoLevelCapping(t){this._autoLevelCapping!==t&&(this.logger.log(`set autoLevelCapping:${t}`),this._autoLevelCapping=t,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(t){(function(t){return Ut.indexOf(t)>-1})(t)&&this._maxHdcpLevel!==t&&(this._maxHdcpLevel=t,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return-1===this.levelController.manualLevel}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:t,config:{minAutoBitrate:e}}=this;if(!t)return 0;const s=t.length;for(let i=0;i<s;i++)if(t[i].maxBitrate>=e)return i;return 0}get maxAutoLevel(){const{levels:t,autoLevelCapping:e,maxHdcpLevel:s}=this;let i;if(i=-1===e&&null!=t&&t.length?t.length-1:e,s)for(let e=i;e--;){const i=t[e].attrs["HDCP-LEVEL"];if(i&&i<=s)return e}return i}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(t){this.abrController.nextAutoLevel=t}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}get maxBufferLength(){return this.streamController.maxBufferLength}setAudioOption(t){var e;return(null==(e=this.audioTrackController)?void 0:e.setAudioOption(t))||null}setSubtitleOption(t){var e;return(null==(e=this.subtitleTrackController)?void 0:e.setSubtitleOption(t))||null}get allAudioTracks(){const t=this.audioTrackController;return t?t.allAudioTracks:[]}get audioTracks(){const t=this.audioTrackController;return t?t.audioTracks:[]}get audioTrack(){const t=this.audioTrackController;return t?t.audioTrack:-1}set audioTrack(t){const e=this.audioTrackController;e&&(e.audioTrack=t)}get allSubtitleTracks(){const t=this.subtitleTrackController;return t?t.allSubtitleTracks:[]}get subtitleTracks(){const t=this.subtitleTrackController;return t?t.subtitleTracks:[]}get subtitleTrack(){const t=this.subtitleTrackController;return t?t.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(t){const e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}get subtitleDisplay(){const t=this.subtitleTrackController;return!!t&&t.subtitleDisplay}set subtitleDisplay(t){const e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(t){this.config.lowLatencyMode=t}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}set targetLatency(t){this.latencyController.targetLatency=t}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}get pathways(){return this.levelController.pathways}get pathwayPriority(){return this.levelController.pathwayPriority}set pathwayPriority(t){this.levelController.pathwayPriority=t}get bufferedToEnd(){var t;return!(null==(t=this.bufferController)||!t.bufferedToEnd)}get interstitialsManager(){var t;return(null==(t=this.interstitialsController)?void 0:t.interstitialsManager)||null}getMediaDecodingInfo(t,e=this.allAudioTracks){return Bt(t,Yt(e),navigator.mediaCapabilities)}}Go.defaultConfig=void 0,s(7884);var Wo=s(6673),Ko=s.n(Wo);const zo=Ko().getComponent("MenuItem"),qo=Ko().dom||Ko();class Yo extends zo{constructor(t,e={}){const s=e.selected;e.selected=e.active,super(t,e);const i=t.qualityLevels();this.levels_=e.levels,this.selected_=s,this.handleQualityChange=this.handleQualityChange.bind(this),this.controlText(e.controlText),this.on(i,"change",this.handleQualityChange),this.on("dispose",()=>{this.off(i,"change",this.handleQualityChange)})}createEl(t,e,s){const i=super.createEl(t,e,s),r=qo.createEl("span",{className:"vjs-quality-menu-item-sub-label",innerHTML:this.localize(this.options_.subLabel||"")});return this.subLabel_=r,i&&i.appendChild(r),i}handleClick(){this.updateSiblings_();const t=this.player().qualityLevels(),e=t.selectedIndex;for(let s=0,i=t.length;s<i;s++)s!==e&&(t[s].enabled=!1);for(let e=0,s=this.levels_.length;e<s;e++)t[this.levels_[e]].enabled=!0;-1!==e&&-1===this.levels_.indexOf(e)&&(t[e].enabled=!1)}handleQualityChange(){const t=this.player().qualityLevels(),e=this.levels_.indexOf(t.selectedIndex)>-1;this.selected(e)}selected(t){if(this.selectable)if(this.selected_){const e=this.options_.subLabel;this.addClass("vjs-selected"),this.el_.setAttribute("aria-checked","true"),this.controlText(this.localize(e?"selected,":"selected"));const s=this.player().controlBar.getChild("QualityMenuButton");t?s.removeClass("vjs-quality-menu-button-waiting"):s.addClass("vjs-quality-menu-button-waiting")}else this.removeClass("vjs-selected"),this.el_.setAttribute("aria-checked","false"),this.controlText(this.options_.controlText)}updateSiblings_(){const t=this.player().qualityLevels(),e=this.player().controlBar.getChild("QualityMenuButton").items;for(let s=0,i=e.length;s<i;s++){const i=e[s],r=i.levels_.indexOf(t.selectedIndex)>-1;i.selected_=i===this,i.selected(r)}}}const Xo=Ko().getComponent("MenuButton"),Qo=function(t){return Array.from(t).some(t=>t.height)},Zo=function(t){return t>=2160?"4K":t>=720?"HD":""};Ko().registerComponent("QualityMenuButton",class extends Xo{constructor(t,e={}){super(t,e),this.el_.setAttribute("aria-label",this.localize("Quality Levels")),this.controlText("Quality Levels"),t.options().experimentalSvgIcons||this.$(".vjs-icon-placeholder").classList.add("vjs-icon-cog"),this.setIcon("cog"),this.qualityLevels_=t.qualityLevels(),this.update=this.update.bind(this),this.hide=this.hide.bind(this),this.handleQualityChange_=this.handleQualityChange_.bind(this),this.firstChangeHandler_=this.firstChangeHandler_.bind(this),this.enableDefaultResolution_=this.enableDefaultResolution_.bind(this),this.on(this.qualityLevels_,"addqualitylevel",this.update),this.on(this.qualityLevels_,"removequalitylevel",this.update),this.on(this.qualityLevels_,"change",this.handleQualityChange_),this.one(this.qualityLevels_,"change",this.firstChangeHandler_),t.on("adstart",this.hide),t.on(["adend","adtimeout"],this.update),this.update(),this.on("dispose",()=>{this.off(this.qualityLevels_,"addqualitylevel",this.update),this.off(this.qualityLevels_,"removequalitylevel",this.update),this.off(this.qualityLevels_,"change",this.handleQualityChange_),this.off(this.qualityLevels_,"change",this.firstChangeHandler_),t.off("adstart",this.hide),t.off(["adend","adtimeout"],this.update),t.off("loadedmetadata",this.enableDefaultResolution_)})}buildWrapperCSSClass(){return`vjs-quality-menu-wrapper ${super.buildWrapperCSSClass()}`}buildCSSClass(){return`vjs-quality-menu-button ${super.buildCSSClass()}`}createItems(){const t=[];if(!this.qualityLevels_||!this.qualityLevels_.length)return t;let e;if(this.options_.useResolutionLabels&&Qo(this.qualityLevels_)?(e=this.groupByResolution_(),this.addClass("vjs-quality-menu-button-use-resolution")):(e=this.groupByBitrate_(),this.removeClass("vjs-quality-menu-button-use-resolution")),e.length<=1)return[];e.forEach(e=>{e.levels.length&&(e.selectable=!0,t.push(new Yo(this.player(),e)))});const s=new Yo(this.player(),{levels:Array.prototype.map.call(this.qualityLevels_,(t,e)=>e),label:this.localize("Auto"),controlText:"",active:!0,selected:!0,selectable:!0});return this.autoMenuItem_=s,t.push(s),t}groupByResolution_(){const t={},e=[];for(let s=0,i=this.qualityLevels_.length;s<i;s++){const i=this.qualityLevels_[s],r=this.qualityLevels_.selectedIndex===s,n=i.height;if(!n)continue;let a;if(a=this.options_.resolutionLabelBitrates?`${n}p @ ${Math.round(i.bitrate/1e3)} kbps`:n+"p",!t[a]){const s=Zo(n);t[a]={levels:[],label:a,controlText:"",subLabel:s},e.push({label:a,lines:n})}r&&(t[a].active=!0),t[a].levels.push(s)}e.sort((t,e)=>e.lines-t.lines);const s=[];return e.forEach(e=>{s.push(t[e.label])}),s}groupByBitrate_(){const t=[{levels:[],label:"HD",controlText:"High Definition"},{levels:[],label:"SD",controlText:"Standard Definition"}];for(let e=0,s=this.qualityLevels_.length;e<s;e++){const s=this.qualityLevels_[e],i=this.qualityLevels_.selectedIndex===e;let r;r=s.bitrate<this.options_.sdBitrateLimit?t[1]:t[0],i&&(r.active=!0),r.levels.push(e)}return t[0].levels.length&&t[1].levels.length?t:[]}handleQualityChange_(){const t=this.qualityLevels_[this.qualityLevels_.selectedIndex],e=this.options_.useResolutionLabels&&Qo(this.qualityLevels_);let s="";t&&(e?s=Zo(t.height):t.bitrate>=this.options_.sdBitrateLimit&&(s="HD")),"HD"===s?(this.addClass("vjs-quality-menu-button-HD-flag"),this.removeClass("vjs-quality-menu-button-4K-flag")):"4K"===s?(this.removeClass("vjs-quality-menu-button-HD-flag"),this.addClass("vjs-quality-menu-button-4K-flag")):(this.removeClass("vjs-quality-menu-button-HD-flag"),this.removeClass("vjs-quality-menu-button-4K-flag")),this.autoMenuItem_&&(this.autoMenuItem_.manuallySelected_&&t?this.autoMenuItem_.subLabel_.innerHTML=this.localize(s):this.autoMenuItem_.subLabel_.innerHTML="")}enableDefaultResolution_(){const t=this.options_.defaultResolution;for(let e=0;e<this.items.length;e++)-1!==this.items[e].options_.label.indexOf(t)&&this.items[e].handleClick()}firstChangeHandler_(){this.player_.readyState()<1&&"none"!==this.player_.preload()?this.player_.one("loadedmetadata",this.enableDefaultResolution_):this.enableDefaultResolution_()}});var Jo="1.0.4";const tl={sdBitrateLimit:2e6,useResolutionLabels:!0,resolutionLabelBitrates:!1,defaultResolution:"none"},el=(t,e)=>{t.addClass("vjs-quality-menu");const s=t.getChild("controlBar"),i=s.addChild("QualityMenuButton",e,s.children_.length-2);return function(){t.removeClass("vjs-quality-menu"),s.removeChild(i),i.dispose()}},sl=function(t){!function(t,e){if(void 0!==t.qualityLevels){t.qualityLevels();let s=()=>{};t.ready(()=>{s=el(t,e),t.on("loadstart",()=>{s(),s=el(t,e)})}),t.qualityMenu=()=>{},t.qualityMenu.VERSION=Jo}}(this,Ko().obj.merge(tl,t))};function il(t,e){var s=e.options_,i=e.el(),r=null,n=this.hls=new Go(s.hlsjsConfig);function a(){var t=null,e=null;return function(){var s=Date.now();!t||s-t>2e3?(t=s,n.recoverMediaError()):!e||s-e>2e3?(e=s,n.swapAudioCodec(),n.recoverMediaError()):console.error("Error loading media: File could not be played")}}var o=a(),l=a();i.addEventListener("error",function(t){var e=t.currentTarget.error;e.code===e.MEDIA_ERR_DECODE?l():console.error("Error loading media: File could not be played")}),this.dispose=function(){n.destroy()},this.duration=function(){return r||i.duration||0},n.on(Go.Events.LEVEL_LOADED,function(t,e){r=e.details.live?1/0:e.details.totalduration}),n.on(Go.Events.ERROR,function(t,e){if(e.fatal)switch(e.type){case Go.ErrorTypes.NETWORK_ERROR:n.startLoad();break;case Go.ErrorTypes.MEDIA_ERROR:o();break;default:console.error("Error loading media: File could not be played")}}),Object.keys(Go.Events).forEach(function(t){var s=Go.Events[t];n.on(s,function(t,i){e.trigger(s,i)})}),e.featuresNativeTextTracks||(Object.defineProperty(i,"textTracks",{get:function(){try{return"function"==typeof e.textTracks?e.textTracks():e.textTracks}catch{return[]}}}),i.addTextTrack=function(){return e.addTextTrack.apply(e,arguments)}),n.attachMedia(i),n.loadSource(t.src)}Ko().registerPlugin("qualityMenu",sl),sl.VERSION=Jo;var rl=/^application\/(x-mpegURL|vnd\.apple\.mpegURL)$/i,nl=/\.m3u8/i,al={canHandleSource:function(t){return t.skipContribHlsJs?"":rl.test(t.type)?"probably":nl.test(t.src)?"maybe":""},handleSource:function(t,e){return new il(t,e)},canPlayType:function(t){return rl.test(t)?"probably":""}};if(Go.isSupported()){var ol=window.videojs;if(ol=ol&&ol.default||ol){var ll=ol.getTech&&ol.getTech("Html5");(ll=ll||ol.getComponent&&ol.getComponent("Html5"))&&ll.registerSourceHandler(al,0)}else console.warn("videojs-contrib-hls.js: Couldn't find find window.videojs nor require('video.js')")}const hl=(t,e)=>{const s=e=>{let s=Array.isArray(e.url)&&e.url.length>1?e.url[e.urlId]:e.url;return{id:s,width:e.width,height:e.height,bandwidth:e.bitrate,frameRate:0,enabled:e=>{var i=t.tech({IWillNotUseThisInPlugins:!0});if(void 0!==i.sourceHandler_&&void 0!==i.sourceHandler_.hls&&null!=i.sourceHandler_.hls){const t=i.sourceHandler_.hls,r=t.levels.findIndex(t=>(Array.isArray(t.url)&&t.url.length>1?t.url[t.urlId]:t.url)===s);r>=0&&e&&(t.currentLevel=r)}return e}}},i=e=>({id:e.id,width:e.width,height:e.height,bandwidth:e.bandwidth,enabled:s=>{const i=t.dash;if(i&&i.mediaPlayer&&s){i.mediaPlayer.updateSettings({streaming:{abr:{autoSwitchBitrate:{video:!1,audio:!1}}}});const t=n(e.width,e.height);t>=0&&(i.mediaPlayer.setQualityFor("video",t),i.audioMapper&&void 0!==i.audioMapper[t]&&i.mediaPlayer.setQualityFor("audio",i.audioMapper[t]))}return s}}),r=()=>{var e=t.dash;if(void 0!==e&&null!=e&&void 0!==e.mediaPlayer&&null!=e.mediaPlayer){var s=e.mediaPlayer.getActiveStream().getStreamInfo(),i=e.mediaPlayer.getDashAdapter();if(i&&s){const t=s.index;var r=i.getAdaptationForType(t,"video",s)}return r.Representation_asArray}return[]},n=(e,s)=>{var i=t.dash;if(i&&i.mediaPlayer){const t=i.mediaPlayer.getBitrateInfoListFor("video").find(t=>t.width===e&&t.height===s);return t?t.qualityIndex:-1}return-1},a=(e,r)=>{(()=>{let e=t.qualityLevels;"function"==typeof e&&(e=t.qualityLevels(),e.dispose(),c("Quality levels cleaned up for new source"));const s=t.audioTracks();if(s&&s.length>0){for(let t=s.length-1;t>=0;t--)s.removeTrack(s[t]);c("Audio tracks cleaned up for new source")}const i=t.dash;i&&i.audioMapper&&(delete i.audioMapper,c("DASH audio mapper cleaned up for new source")),o=null})();let n=t.qualityLevels;if("function"==typeof n)switch(n=t.qualityLevels(),c("QualityLevels",n),r){case"hls":for(let t=0;t<e.length;t++){let i=e[t],r=s(i);n.addQualityLevel(r)}break;case"dash":{const s=t.dash;if(!s)break;const r=e,a=s.mediaPlayer.getBitrateInfoListFor("audio")||[],o=r.length>0?r[r.length-1].bandwidth:1;s.audioMapper=r.map(t=>Math.round(t.bandwidth/o*(a.length-1)));for(let t=0;t<e.length;t++){let s=e[t],r=i(s);n.addQualityLevel(r)}break}default:return}else console.warn("QualityLevels not supported")};let o=null;const l=e=>{let s=t.qualityLevels;if("function"==typeof s){if(s=t.qualityLevels(),0==s.length){console.warn("ERROR - no quality levels found! Patching populate levels first");var i=t.tech({IWillNotUseThisInPlugins:!0});if(void 0!==i.sourceHandler_&&void 0!==i.sourceHandler_.hls&&null!=i.sourceHandler_.hls){const t=i.sourceHandler_.hls;a(t.levels,"hls")}}s.selectedIndex_=e,s.trigger({type:"change",selectedIndex:e})}},h=e=>{if(e<0)return;let s=t.qualityLevels,i=null;if("function"==typeof s)s=t.qualityLevels(),i=s.levels_[e],c("Custom qualitychanged","using videojs-contrib-quality-levels");else{var n=t.tech({IWillNotUseThisInPlugins:!0});if(void 0!==n.sourceHandler_&&void 0!==n.sourceHandler_.hls&&null!=n.sourceHandler_.hls){const t=n.sourceHandler_.hls;i=t.levels[e],c("Custom qualitychanged","using hls.js directly"),e!==t.currentLevel&&c("ERROR - new level differs from hls.js")}else{var a=t.dash;void 0!==a&&null!=a&&void 0!==a.mediaPlayer&&null!=a.mediaPlayer&&(i=r()[e],c("Custom qualitychanged","using dash.js directly"))}}if(!i)return void c("Warning: Level is undefined in populateQualityChangedEvent",{currentLevel:e});let l={width:i.width,height:i.height};if(o!==l){let e={from:o,to:l};t.trigger({type:"qualitychanged",eventData:e})}o=l,c("Current Rendition",{index:e,resolution:`${i.width}x${i.height}`,bitrate:`${Math.round(i.bitrate/1e3)} kbps`,url:Array.isArray(i.url)?i.url[i.urlId]:i.url,details:i})},c=(t,s)=>{e.debug&&console.log(`%c ${t}`,"background: #3498db; color: white; padding: 2px 4px; border-radius: 2px;",s)},d=()=>{var e=t.tech({IWillNotUseThisInPlugins:!0});if(void 0!==e.sourceHandler_&&void 0!==e.sourceHandler_.hls&&null!=e.sourceHandler_.hls){const t=e.sourceHandler_.hls,s=t.audioTrack,i=t.audioTracks.length;for(let e=0;e<i;e++)c(s===e?`audio track [${e}] ${t.audioTracks[e].name} - enabled`:`audio track [${e}] ${t.audioTracks[e].name} - disabled`,t.audioTracks[e])}},u=()=>{try{const e=t.currentTime(),s=.5,i=Math.min(e+s,t.duration()-.1);t.currentTime(i),t.currentTime(e)}catch(t){c("Error while flushing buffered audio",t)}},p=e=>{var s=t.tech({IWillNotUseThisInPlugins:!0});if(void 0!==s.sourceHandler_&&void 0!==s.sourceHandler_.hls&&null!=s.sourceHandler_.hls){const t=s.sourceHandler_.hls;if(t.audioTrack===e)return;if(t.audioTrack=e,t.media)try{t.stopLoad(),t.startLoad(0)}catch(t){c("Error while reloading after audioTrack switch",t)}d(),t.once(Go.Events.AUDIO_TRACK_SWITCHED,()=>{u()})}},f=(e,s)=>{const i=new(Ko().AudioTrack)({id:`${e.type}-id_${e.id}-groupId_${e.groupId}-${e.name}`,kind:"translation",label:e.name,language:e.lang,enabled:s.audioTrack===s.audioTracks.indexOf(e),default:e.default});t.audioTracks().addTrack(i)};return{init:()=>{var e=t.tech({IWillNotUseThisInPlugins:!0});if(void 0===e&&console.warn("ERROR - tech not found!"),void 0!==e.sourceHandler_&&void 0!==e.sourceHandler_.hls&&null!=e.sourceHandler_.hls){const s=e.sourceHandler_.hls,i=(e,r)=>{c(`HLS event: ${e}`,r),a(s.levels,"hls"),(()=>{var e=t.tech({IWillNotUseThisInPlugins:!0});if(void 0!==e.sourceHandler_&&void 0!==e.sourceHandler_.hls&&null!=e.sourceHandler_.hls){const t=e.sourceHandler_.hls,s=t.audioTracks.length;for(let e=0;e<s;e++)f(t.audioTracks[e],t)}var s=t.audioTracks();s.addEventListener("change",function(){var e=t.tech({IWillNotUseThisInPlugins:!0});if(void 0!==e.sourceHandler_&&void 0!==e.sourceHandler_.hls&&null!=e.sourceHandler_.hls)for(var i=0;i<s.length;i++)if(s[i].enabled)return void p(i)})})(),s.off(Go.Events.MANIFEST_LOADED,i)};s.levels&&s.levels.length>0?i("MANUAL_MANIFEST_LOADED",{}):s.on(Go.Events.MANIFEST_LOADED,i),s.on(Go.Events.LEVEL_SWITCHED,(t,e)=>{c(`HLS event: ${t}`,e),l(e.level),h(e.level)}),s.on(Go.Events.AUDIO_TRACK_SWITCHED,(e,s)=>{c(`HLS event: ${e}`,s),void 0!==s.id&&(e=>{const s=t.audioTracks();if(s){for(let t=0;t<s.length;t++)s[t].enabled=t===e;d()}})(s.id),u()}),s.on(Go.Events.ERROR,(e,s)=>{c(`HLS event: ${e}`,s),s.fatal&&t.error({code:4,...s})})}else{var s=t.dash;if(void 0!==s&&null!=s&&void 0!==s.mediaPlayer&&null!=s.mediaPlayer){let t=r();a(t,"dash"),s.mediaPlayer.on("qualityChangeRendered",e=>{const i=s.mediaPlayer.getQualityFor("video"),r=s.mediaPlayer.getBitrateInfoListFor("video")[i],a=n(r.width,r.height);a>=0?(c(`DASH event: ${e.type}`,e,t[a]),l(a),h(a)):console.warn("Could not find matching rendition for DASH quality change")})}}}}};var cl=s(8592);async function dl(t,e){const s={...cl.$n[e.strategy],videoPreference:cl.Lp?{preferHDR:!0}:void 0};e.withCredentials&&(s.xhrSetup=function(t){t.withCredentials=!0}),t.tech_.options_.hlsjsConfig=s,t.on("loadstart",()=>hl(t,e).init()),t.qualityMenu(),t.adaptiveStreamingLoaded=!0}},7707:(t,e,s)=>{async function i(t){const e=this;try{t.isDash&&!window.dashjs&&await s.e(367).then(s.bind(s,6604));const{default:i}=await s.e(26).then(s.bind(s,833));i(e,t)}catch(t){console.error("Failed to load plugin:",t)}}s.r(e),s.d(e,{default:()=>i})},9234:(t,e,s)=>{s.d(e,{default:()=>h});var i=s(6673),r=s.n(i),n=s(1865),a=s(2415),o=s(7311);const l=function(){function t(t,e){return this.player=t,this.options=e,this.player.one("loadedmetadata",this.initializeChapters.bind(this)),this}return t.prototype.src=function(t){this.resetPlugin(),this.options=t,this.player.one("loadedmetadata",this.initializeChapters.bind(this))},t.prototype.detach=function(){this.resetPlugin()},t.prototype.resetPlugin=function(){this.chaptersTrack&&(this.player.$(".vjs-control-bar-chapter-display").remove(),this.player.$(".vjs-chapter-display").remove(),this.player.$$(".vjs-chapter-marker").forEach(t=>t.remove()),this.player.removeRemoteTextTrack(this.chaptersTrack),delete this.chaptersTrack)},t.prototype.getChaptersFileUrlByName=function(){const t=this.player.cloudinary.currentPublicId();if(!t)return null;const e=this.player.cloudinary.source(),{type:s}=e.resourceConfig(),i=`${(0,n.k$)(this.player.cloudinary.cloudinaryConfig())}/_applet_/video_service/chapters/${s}/${(0,a.G)(t)}.vtt`;return(0,o.N)(i,e.queryParams())},t.prototype.initializeChapters=async function(){const t=!0===this.options?this.getChaptersFileUrlByName():this.options.url;if(t){const e={kind:"chapters",src:t,default:!0},s=this.player.addRemoteTextTrack(e);s.addEventListener("load",()=>{this.chaptersTrack=s.track,this.setupChaptersDisplays()})}else if(Object.entries(this.options).length){const t=this.player.addRemoteTextTrack({kind:"chapters",default:!0}),e=this.player.duration();Object.entries(this.options).forEach((s,i,r)=>{const n=new VTTCue(parseFloat(s[0]),parseFloat(r[i+1]?r[i+1][0]:e),s[1]);t.track.addCue(n)}),this.chaptersTrack=t.track,this.setupChaptersDisplays(),this.player.controlBar.chaptersButton&&this.player.controlBar.chaptersButton.update()}},t.prototype.setupChaptersDisplays=function(){this.setupProgressBarMarkers(),this.setupProgressBarChapter(),this.setupControlBarChapter()},t.prototype.setupControlBarChapter=function(){const t=this.player.$(".vjs-control-bar-chapter-display")||document.createElement("div");t.setAttribute("class","vjs-control-bar-chapter-display");const e=this.player.$(".vjs-control-bar .vjs-spacer");e.innerHTML="",e.classList.add("vjs-control-bar-chapter-wrapper"),e.appendChild(t),this.chaptersTrack.addEventListener("cuechange",()=>{const e=Array.from(this.chaptersTrack.activeCues);t.innerText=e.length>0?e[0].text:""})},t.prototype.setupProgressBarMarkers=function(){const t=this.player.duration(),{seekBar:e}=this.player.controlBar.progressControl;Array.from(this.chaptersTrack.cues).forEach(s=>{if(0!==s.startTime){const i=s.startTime/t*100+"%",n=r().dom.createEl("div",void 0,{class:"vjs-chapter-marker",style:`left: ${i}`});e.el().append(n)}})},t.prototype.setupProgressBarChapter=function(){const t=r().dom.createEl("div",void 0,{class:"vjs-chapter-display",style:`max-width: ${this.player.$(".vjs-vtt-thumbnail-display")?this.player.$(".vjs-vtt-thumbnail-display").style.width:"160px"}`}),e=this.player.getDescendant(["controlBar","progressControl","seekBar","mouseTimeDisplay"]),s=e.getDescendant(["timeTooltip"]);s.el().parentElement.prepend(t);const i=t=>{const e=t*this.player.duration(),s=Array.from(this.chaptersTrack?.cues||[]).find(t=>e>=t.startTime&&e<=t.endTime);return s?s.text:""};s.update=function(e,s,r){Object.getPrototypeOf(this).update.call(this,e,s,r),t.innerText=i(s)},"object"!=typeof this.player.vttThumbnails&&(e.update=function(e,i){const n=i*this.player_.duration(),a=e.width,o=t.clientWidth/2;s.updateTime(e,i,n,()=>{e.width*i<o?this.el_.style.left=`${o}px`:e.width*i+o>a?this.el_.style.left=e.width-o+"px":this.el_.style.left=e.width*i+"px"}),s.write(r().time.formatTime(n))})},t}(),h=function(t,e){e.addClass("vjs-chapters"),e.chapters=new l(e,t)}},1865:(t,e,s)=>{s.d(e,{bo:()=>Y,dC:()=>Q,ww:()=>X,lP:()=>H,KA:()=>V,k$:()=>G,iT:()=>$,Nl:()=>U,N7:()=>W,a5:()=>j,hS:()=>q,M6:()=>Z});var i=s(6673),r=s.n(i),n=s(4319),a=s.n(n),o=s(5871),l=s(8953),h=s.n(l),c=s(7571),d=s.n(c),u=s(5226),p=s(2901),f=s(9914);const g={"=":"eq","!=":"ne","<":"lt",">":"gt","<=":"lte",">=":"gte","&&":"and","||":"or","*":"mul","/":"div","+":"add","-":"sub","^":"pow"},m="res.cloudinary.com",y={aspect_ratio:"ar",aspectRatio:"ar",current_page:"cp",currentPage:"cp",duration:"du",face_count:"fc",faceCount:"fc",height:"h",initial_aspect_ratio:"iar",initial_height:"ih",initial_width:"iw",initialAspectRatio:"iar",initialHeight:"ih",initialWidth:"iw",initial_duration:"idu",initialDuration:"idu",page_count:"pc",page_x:"px",page_y:"py",pageCount:"pc",pageX:"px",pageY:"py",tags:"tags",width:"w"},v="(([0-9]*)\\.([0-9]+)|([0-9]+))([%pP])?",b=RegExp(`^${v}$`),_=RegExp(`(${v})\\.\\.(${v})`),T={font_weight:"normal",font_style:"normal",text_decoration:"none",text_align:"",stroke:"none"};var A=s(2798),E=s(593),S=s(7704);function C(t){const e=[];let s="";if(Object.keys(T).forEach(s=>{let i=T[s],r=t[s]||i;r!==i&&e.push(r)}),Object.keys(t).forEach(s=>{"letter_spacing"!==s&&"line_spacing"!==s||e.push(`${s}_${t[s]}`),"font_hinting"===s&&e.push(`${s.split("_").pop()}_${t[s]}`),"font_antialiasing"===s&&e.push(`antialias_${t[s]}`)}),t.hasOwnProperty("font_size")||!e||0===e.length){if(!t.font_size)throw"Must supply font_size for text in overlay/underlay";if(!t.font_family)throw"Must supply font_family for text in overlay/underlay";e.unshift(t.font_size),e.unshift(t.font_family),s=e.filter(t=>t).join("_")}return s}function k(t){if(t instanceof E.A||t instanceof S.A)return t.toString();let e="";if((0,p.G)(t))if("fetch"===t.resource_type||null!=t.url)e=`fetch:${(0,f.K)(t.url)}`;else{let s=t.public_id,i=t.format,r=t.resource_type||"image",n=t.type||"upload",a=t.text,o=null,l=[];const h=!s||0===s.length;if(h||(s=s.replace(new RegExp("/","g"),":"),null!=i&&(s=`${s}.${i}`)),a&&0!==a.length||"text"===r){if(r="text",n=null,o=C(t),a&&a.length>=0){const t=!o;if(!h&&!t||h&&t)throw"Must supply either style parameters or a public_id when providing text parameter in a text overlay/underlay";let e=/\$\([a-zA-Z]\w*\)/g,s=0,i=(0,A.$)(decodeURIComponent(a),/[,\/]/g);a="";for(let t=e.exec(i);t;t=e.exec(i))a+=(0,A.$)(i.slice(s,t.index)),a+=t[0],s=t.index+t[0].length;a+=encodeURIComponent(i.slice(s))}}else{if(h)throw"Must supply public_id for resource_type layer_parameter";"subtitles"===r&&(o=C(t))}"image"!==r&&l.push(r),"upload"!==n&&l.push(n),l.push(o),l.push(s),l.push(a),e=l.filter(t=>t).join(":")}else e=/^fetch:.+/.test(t)?`fetch:${(0,f.K)(t.substr(6))}`:t;return e}function w(t){if("string"!=typeof t||0===t.length||t.match(/^!.+!$/))return t?t.toString():t;t=String(t);const e=new RegExp("((\\|\\||>=|<=|&&|!=|>|=|<|/|-|\\+|\\*|\\^)(?=[ _]))","g");t=t.replace(e,t=>g[t]);const s="("+Object.keys(y).join("|")+")",i=new RegExp(`(\\$_*[^_ ]+)|${s}`,"g");return(t=t.replace(i,t=>y[t]||t)).replace(/[ _]+/g,"_")}function L(t){switch(!0){case null==t:return[];case Array.isArray(t):return t;default:return[t]}}function I(t){if(!(0,p.G)(t))return t;if("remote"===t.function_type){const e=(0,f.K)(t.source).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"");return[t.function_type,e].join(":")}return[t.function_type,t.source].join(":")}function P(t){switch(t&&t.constructor){case String:return _.test(t)?t.split(".."):t;case Array:return[[t],t[t.length-1]];default:return[null,null]}}function x(t){const e=String(t).match(b);if(e){const t=e[5]?"p":"";return`${e[1]||e[4]}${t}`}return t}function R(t){switch(t&&t.constructor){case Object:{let e="";return"codec"in t&&(e=t.codec,"profile"in t&&(e+=":"+t.profile,"level"in t&&(e+=":"+t.level))),e}case String:return t;default:return null}}var D=s(9445),O=s(8586),M=s(9480);function F(t){if("string"==typeof t)return t;if(t instanceof D.A)return t.toString();if(Array.isArray(t))return t.map(t=>F(t)).filter(t=>t).join("/");let e,s;const i=t.size,r=t.overlay||t.underlay,n=t.crop,a=L(t.angle).join("."),o=(t.background||"").replace(/^#/,"rgb:"),l=(t.color||"").replace(/^#/,"rgb:"),h=L(t.flags||[]).join("."),c=void 0===t.dpr?t.dpr:function(t){let e=t.toString();return(null!=e?e.match(/^\d+$/):void 0)?e+".0":O.A.normalize(e)}(t.dpr),d=k(t.overlay),u=function(t){let e=t;if(!e)return e;if(Array.isArray(e)||(e=[e]),0===e.length||e.length>4)throw new Error("Radius array should contain between 1 and 4 values");if(e.findIndex(t=>null===t)>=0)throw new Error("Corner: Cannot be null");return e.map(w).join(":")}(t.radius),f=k(t.underlay),g=function(t){return t?"if_"+w(t):t}(t.if),m=I(t.custom_function),y=function(t){const e=I(t);return"string"==typeof e?`pre:${e}`:null}(t.custom_pre_function);let v=t.fps,b=[],_=L(t.transformation||[]),T=t.effect;const A=r||a||"fit"===n||"limit"===n;if(i){const[t,r]=i.split("x");e=t,s=r}else e=t.width,s=t.height;e&&(0===e.toString().indexOf("auto")||A||parseFloat(e.toString())<1)&&delete t.width,s&&(A||parseFloat(s.toString())<1)&&delete t.height;const E=_.some(t=>"object"==typeof t);E?_=_.map(t=>(0,p.G)(t)?F(t):F({transformation:t})).filter(t=>t):(b=_.join("."),_=[]),Array.isArray(T)?T=T.join(":"):(0,p.G)(T)&&(T=Object.entries(T).map(([t,e])=>`${t}:${e}`));let S=t.border;(0,p.G)(S)?S=`${null!=S.width?S.width:2}px_solid_${(null!=S.color?S.color:"black").replace(/^#/,"rgb:")}`:/^\d+$/.exec(S)&&(t.border=S,S=void 0),Array.isArray(v)&&(v=v.join("-"));const C={a:w(a),ar:w(t.aspect_ratio),b:o,bo:S,c:n,co:l,dpr:w(c),e:w(T),fl:h,fn:m||y,fps:v,h:w(s),ki:w(t.keyframe_interval),l:d,o:w(t.opacity),q:w(t.quality),r:u,t:b,u:f,w:w(e),x:w(t.x),y:w(t.y),z:w(t.zoom),ac:t.audio_codec,af:t.audio_frequency,br:t.bit_rate,cs:t.color_space,d:t.default_image,dl:t.delay,dn:t.density,du:x(t.duration),eo:x(t.end_offset||(0,M.t)(t.end_offset)?t.end_offset:P(t.offset)[1]),f:t.fetch_format,g:t.gravity,pg:t.page,p:t.prefix,so:x(t.start_offset||(0,M.t)(t.start_offset)?t.start_offset:P(t.offset)[0]),sp:t.streaming_profile,vc:R(t.video_codec),vs:t.video_sampling},N=[g,Object.entries(t).filter(([t,e])=>t.startsWith("$")).map(([t,e])=>`${t}_${w(e)}`).sort().concat((t.variables||[]).map(([t,e])=>`${t}_${w(e)}`)).join(","),Object.entries(C).filter(([t,e])=>!(null==e||"string"==typeof e&&0===e.length||Array.isArray(e)&&0===e.length)).map(([t,e])=>`${t}_${e}`).sort().join(","),t.raw_transformation].filter(t=>t).join(",");return N&&_.push(N),_.join("/")}function N(t,e,s,i,r,n,a,o){let l;if(0===e.indexOf("/"))return"/res"+e;let h=!s;return a?(null!=o&&"cloudinary-a.akamaihd.net"!==o||(o=s?e+"-res.cloudinary.com":m),null==h&&(h=o===m),l="https://"+o):l=n?"http://"+n:"http://"+[s?e+"-":"","res",".cloudinary.com"].join(""),h&&(l+="/"+e),l}var B=s(7648);const j=function(t,e){let{tolerateMissingId:s=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(h()(t)){const i=Object.assign({},t);if(t=(0,o.sliceAndUnsetProperties)(i,"publicId").publicId,!d()(t)&&!s)throw new Error("Source is missing 'publicId'.");e&&(e=Object.assign({},i,e))}return{publicId:t,options:e}},$=t=>u.P8.test(t),U=(t,e)=>{let s=t,i=e;return"object"==typeof t&&(s=t.src),"object"==typeof e&&(i=e.src),/^\/\//.test(s)&&(i=i.slice(i.indexOf("//"))),/^\/\//.test(i)&&(s=s.slice(s.indexOf("//"))),s===i},H=(t,e)=>Object.assign(t,e),V=(t,e)=>function(t,e){let s;"fetch"===e.type&&null==e.fetch_format&&(e.fetch_format=e.format);let i=e.type,r=e.resource_type||"image",n=e.version;const a="boolean"!=typeof e.force_version||e.force_version,o=(e.long_url_signature,e.format),l=e.cloud_name;if(!l)throw"cloud_name must be provided in the configuration";const h=e.private_cdn,c=e.secure_distribution,d=e.secure,u=(e.cdn_subdomain,e.secure_cdn_subdomain,e.cname),p=e.shorten,f=e.sign_url,g=(e.api_secret,e.url_suffix),m=e.use_root_path,y=e.auth_token,v=/^(image|raw)\/([a-z0-9_]+)\/v(\d+)\/([^#]+)$/.exec(t);v&&(r=v[1],i=v[2],n=v[3],t=v[4]);const b=t;if(null==t)return b;if(t=t.toString(),null===i&&t.match(/^https?:\//i))return b;[r,i]=function(t,e,s,i,r){if(null==e&&(e="upload"),null!=s)if("image"===t&&"upload"===e)t="images",e=null;else if("image"===t&&"private"===e)t="private_images",e=null;else if("image"===t&&"authenticated"===e)t="authenticated_images",e=null;else if("raw"===t&&"upload"===e)t="files",e=null;else{if("video"!==t||"upload"!==e)throw new Error("URL Suffix only supported for image/upload, image/private, image/authenticated, video/upload and raw/upload");t="videos",e=null}if(i){if(!("image"===t&&"upload"===e||"images"===t&&null==e))throw new Error("Root path only supported for image/upload");t=null,e=null}return r&&"image"===t&&"upload"===e&&(t="iu",e=null),[t,e]}(r,i,g,m,p),[t,s]=function(t,e,s){let i;if((t=t.replace(/([^:])\/\//g,"$1/")).match(/^https?:\//i))i=t=(0,A.$)(t);else{if(i=t=encodeURIComponent(decodeURIComponent(t)).replace(/%3A/g,":").replace(/%2F/g,"/"),s){if(s.match(/[\.\/]/))throw new Error("url_suffix should not include . or /");t=t+"/"+s}null!=e&&(t=t+"."+e,i=i+"."+e)}return[t,i]}(t,o,g),null==n&&a&&s.indexOf("/")>=0&&!s.match(/^v[0-9]+/)&&!s.match(/^https?:\//)&&(n=1),n=null!=n?`v${n}`:null;const _=F((0,B.m)(e)).replace(/([^:])\/\//g,"$1/");if(f&&!y){let t=[_,s].filter(function(t){return null!=t&&""!==t}).join("/");try{for(let e=0;t!==decodeURIComponent(t)&&e<10;e++)t=decodeURIComponent(t)}catch(t){}}return[N(0,l,h,0,0,u,d,c),r,i,_,n,t].filter(function(t){return null!=t&&""!==t}).join("/").replace(" ","%20")}(t,a()(e,["chainTarget"])),G=t=>N(0,t.cloud_name,t.private_cdn,t.cdn_subdomain,t.secure_cdn_subdomain,t.cname,t.secure??!0,t.secure_distribution),W=(t,e)=>{const s=(t=>"Transformation"===t.constructor.name&&t.toOptions)(t)?t.toOptions():t;return new D.A(s).fromOptions(e).toOptions()},K=["streaming_profile","video_codec"],z=t=>t.map(t=>a()(t,K)).filter(t=>Object.keys(t).length>0),q=t=>{if(!t||"object"!=typeof t)return t;if(Array.isArray(t))return z(t);if(Array.isArray(t?.transformation)){const e=a()(t,K);return e.transformation=z(t.transformation),e}return a()(t,K)},Y={NO_SUPPORTED_MEDIA:6,CUSTOM:10,UNKNOWN_CUSTOMER:11,RESOURCE_NOT_FOUND:12,PRIVATE_RESOURCE:13,UNAUTHENTICATED:14},X=t=>{let{errorMsg:e,publicId:s,cloudName:i,statusCode:r}=t;const n="Video cannot be played";let a={code:Y.CUSTOM,message:`${n}${e?"- "+e:""}`,statusCode:r},o=e.toLowerCase();return o.startsWith("unknown customer")&&(a.code=Y.UNKNOWN_CUSTOMER,a.message=`${n} Unknown cloud-name ${i}`),o.startsWith("resource not found")&&(a.code=Y.RESOURCE_NOT_FOUND,a.message=`${n} Public ID ${s} not found`),o.startsWith("private resource")&&(a.code=Y.PRIVATE_RESOURCE,a.message=`${n} Private video`),o.startsWith("unauthenticated access")&&(a.message=`${n} Requires authentication`,a.code=Y.UNAUTHENTICATED),423===r&&(a.message='Video is being processed. <br><a href="#" class="cld-error-refresh">Try again</a> in a moment.',a.isHtml=!0),a},Q={AV1:"av1",VP9:"vp9",HEV1:"hev1",H265:"h265",H264:"h264"},Z=()=>{r().use("video/auto",()=>({async setSource(t,e){const{headers:s}=await fetch(t.src,{method:"HEAD",credentials:t.withCredentials?"include":"omit"}),i=s.get("content-type").split(";")[0];return e(null,{src:t.src,type:i})}}))}},6770:(t,e,s)=>{s.d(e,{A:()=>a});var i=s(1865),r=s(5871),n=s(7311);const a=class{_transformation=null;constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{publicId:s,options:n}=(0,i.a5)(t,e),{cloudinaryConfig:a}=(0,r.sliceAndUnsetProperties)(n,"cloudinaryConfig"),{transformation:o}=(0,r.sliceAndUnsetProperties)(n,"transformation"),{queryParams:l}=(0,r.sliceAndUnsetProperties)(n,"queryParams");if(!a)throw new Error('Source is missing "cloudinaryConfig".');this.publicId=()=>s,this.cloudinaryConfig=()=>a,this.resourceConfig=()=>n,this.queryParams=()=>l,this.getType=()=>this._type,this.transformation(o)}transformation(t){return t&&(this._transformation=t),this._transformation}config(){const t=this.cloudinaryConfig();return{cloud_name:t.cloudName,url:(e,s)=>{if((0,i.iT)(e))return e;const r=(0,i.N7)(this.resourceConfig(),s);return(0,i.KA)(e,{...t,...r})}}}url(){let{transformation:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=this.config().url(this.publicId(),{transformation:t||this.transformation()});return(0,n.N)(e,this.queryParams())}}},4650:(t,e,s)=>{s.d(e,{A:()=>l});var i=s(6770),r=s(1865);const n=RegExp(`\\.(${["jpg","png","gif","webp"].join("|")})$$`),a={resource_type:"image",type:"upload",transformation:[]};class o extends i.A{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};({publicId:t,options:e}=(0,r.a5)(t,e)),t=t.replace(n,""),e=Object.assign({},a,e),super(t,e),this._type="ImageSource"}}const l=o},5226:(t,e,s)=>{s.d(e,{IH:()=>h,P8:()=>a,Tf:()=>r,VX:()=>c,XY:()=>o,cE:()=>n,o7:()=>d,uf:()=>l,vD:()=>i});const i={format:"jpg",resource_type:"video"},r={resource_type:"video",type:"upload",hdr:!1,transformation:[],sourceTransformation:{},sourceTypes:["auto"],recommendations:null,info:{},interactionAreas:{},chapters:{}},n=RegExp(`\\.(${["3g2","3gp","avi","flv","m3u8","ts","m2ts","mts","mov","mkv","mp4","mpeg","mpd","mxf","ogv","webm","wmv"].join("|")})$$`),a=RegExp("https?:\\/\\/(www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)"),o={hls:"application/x-mpegURL",dash:"application/dash+xml",opus:"video/ogg",ogv:"video/ogg",mp4:"video/mp4",mov:"video/mp4",m4v:"video/mp4",mkv:"video/x-matroska",m4a:"audio/mp4",mp3:"audio/mpeg",aac:"audio/aac",caf:"audio/x-caf",flac:"audio/flac",oga:"audio/ogg",wav:"audio/wav",m3u8:"application/x-mpegURL",mpd:"application/dash+xml",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",png:"image/png",svg:"image/svg+xml",webp:"image/webp"},l=["hls","dash","mpd","m3u8"],h={hls:"m3u8",dash:"mpd"},c=2,d=[640,848,1280,1920,2560,3840]},5381:(t,e,s)=>{s.d(e,{A:()=>_});var i=s(7311),r=s(2160),n=s.n(r),a=s(1104),o=s(608),l=s(5226),h=s(1865),c=s(7571),d=s.n(c),u=s(5004);const p=t=>{return!!t&&(d()(t)?(e=t)&&Object.values(h.dC).some(t=>e.includes(t)):!!(t=>["video_codec","streaming_profile"].some(e=>(0,u.isKeyInTransformation)(t,e)))(t)||!!t.some?.(t=>p(t)));var e};var f=s(2415),g=s(9445),m=s(6770),y=s(4650);let v=0;class b extends m.A{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=(0,h.iT)(t);let{publicId:i,options:r}=(0,h.a5)(t,e);s||(i=i.replace(l.cE,"")),r=Object.assign({},l.Tf,r),r.resourceType&&(r.resource_type=r.resourceType),void 0===r.poster&&(r.poster=Object.assign({publicId:i},l.vD)),super(i,r),this._type=a.x.VIDEO,this.isRawUrl=s,this.isLiveStream="live"===r.type,this.withCredentials=!!r.withCredentials,this.getInitOptions=()=>e;const n=["poster","withCredentials","publicId","cloudinaryConfig","transformation","queryParams","type","info"],c=o.LU.filter(t=>!n.includes(t));this._createGetterSetters(c),c.forEach(t=>{void 0!==r[t]&&this[t](r[t])}),this.poster(r.poster),this.objectId=v++}_createGetterSetters(t){t.forEach(t=>{const e=`_${t}`;this[t]=function(s){return void 0===s?"sourceTypes"===t&&void 0===this[e]?["auto"]:"sourceTransformation"===t&&void 0===this[e]?{}:this[e]:(this[e]=s,this)}})}poster(t){let e={type:this.getInitOptions().type};if(!t)return this._poster;if(t instanceof y.A)return this._poster=t,this;if(({publicId:t,options:e}=(0,h.a5)(t,e,{tolerateMissingId:!0})),!t&&this.isRawUrl)return null;if(this.isLiveStream)return null;if(t||(t=this.publicId(),e=Object.assign({},e,l.vD)),e.cloudinaryConfig=e.cloudinaryConfig||this.cloudinaryConfig(),e.resource_type=this.resourceType()||e.resource_type,e.queryParams=this.queryParams(),!0===t){let t=`${(0,h.k$)(e.cloudinaryConfig)}/_applet_/video_service/elements/${this.getInitOptions().type||"upload"}/${(0,f.G)(this.publicId())}/poster`;const s=this.getInitOptions().posterOptions?.transformation;return s&&(t+=`?tx=${new g.A(s).toString()}`),this._poster=new y.A(t,{cloudinaryConfig:e.cloudinaryConfig,queryParams:e.queryParams}),this}return this._poster=new y.A(t,e),this}contains(t){return this.generateSources().some(e=>(0,h.Nl)(e,t))}generateSources(){if(this.isRawUrl){const t="auto"===this.sourceTypes()[0]?null:this.sourceTypes()[0];return[this.generateRawSource(this.publicId(),t)]}return this.sourceTypes().map(t=>{const e=this.sourceTransformation()[t]||this.transformation(),s=function(t){t=t.toLowerCase().split("/").shift();let e=l.IH[t];return e||(e=t.split("/").shift()),e}(t),r=l.uf.includes(s),a={};e&&(a.transformation=n()(e)),Object.assign(a,{format:s});const[o,c]=function(t){const[e,s]=t.toLowerCase().split("/"),i=l.XY[e]||`video/${e}`;let r=[i];return s&&(r=[i,{video_codec:s}]),r}(t);return!c||p(a.transformation)||p(this.rawTransformation())||(a.transformation=(0,h.N7)(a.transformation,c)),"auto"===a.format&&(delete a.format,a.transformation=(0,h.N7)(a.transformation,{fetch_format:"auto:video"})),r&&(JSON.stringify(a.transformation||{}).includes('"streaming_profile":')||this.isLiveStream||(a.transformation=(0,h.N7)(a.transformation,{streaming_profile:"auto"}))),!0===this.hdr()&&window.matchMedia&&window.matchMedia("(dynamic-range: high)").matches&&(a.transformation=(0,h.N7)(a.transformation,{fetch_format:"mp4",video_codec:"h265",raw_transformation:"dr_high"})),{type:o,src:(0,i.N)(this.config().url(this.publicId(),a),this.queryParams()),cldSrc:this,isAdaptive:r,withCredentials:this.withCredentials}})}generateRawSource(t,e){e=e||t.split(".").pop();const s=l.uf.includes(e);return{type:e=l.XY[e]?l.XY[e]:e?`video/${e}`:null,src:t,cldSrc:this,isAdaptive:s,withCredentials:this.withCredentials}}info(t){if(void 0!==t)return this._info=t,this;const e=this._info||this.getInitOptions().info;return{title:this.title()||e?.title||"",subtitle:this.description()||e?.subtitle||"",description:this.description()||e?.subtitle||""}}}const _=b},9454:(t,e,s)=>{s.d(e,{default:()=>a,w:()=>n});var i=s(7764);const r={colorsDark:{base:"#000000",accent:"#0D9AFF",text:"#FFFFFF"},colorsLight:{base:"#FFFFFF",accent:"#0D9AFF",text:"#000000"}},n=t=>(0,i.T4)(t)?r.colorsLight:r.colorsDark,a=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=n(t.options_);e.colors=Object.assign({},s,e.colors);const i=t.el();return e.colors.base&&i.style.setProperty("--color-base",e.colors.base),e.colors.accent&&i.style.setProperty("--color-accent",e.colors.accent),e.colors.text&&i.style.setProperty("--color-text",e.colors.text),{updateColors:t=>{const s=Object.assign({},e.colors,t);s.base&&i.style.setProperty("--color-base",s.base),s.accent&&i.style.setProperty("--color-accent",s.accent),s.text&&i.style.setProperty("--color-text",s.text),e.colors=s},getColors:()=>e.colors}}},2650:(t,e,s)=>{var i=s(6673),r=s.n(i),n=s(5204),a=s.n(n),o=s(7509),l=s.n(o),h="7.5.2",c=function(t,e){e.isImmediatePropagationStopped=function(){return!0},e.cancelBubble=!0,e.isPropagationStopped=function(){return!0}},d=function(t,e,s){c(0,s),t.trigger({type:e+s.type,originalEvent:s})};function u(t){"playing"===t.type?function(t,e){t.ads.isInAdMode()&&(t.ads.isContentResuming()?t.ads._contentEnding&&d(t,"content",e):d(t,"ad",e))}(this,t):"ended"===t.type?function(t,e){t.ads.isInAdMode()?t.ads.isContentResuming()?(c(0,e),t.trigger("resumeended")):d(t,"ad",e):t.ads._contentHasEnded||t.ads.stitchedAds()||(d(t,"content",e),t.trigger("readyforpostroll"))}(this,t):"loadstart"===t.type||"loadeddata"===t.type||"loadedmetadata"===t.type?function(t,e){if(!("loadstart"===e.type&&!t.ads._hasThereBeenALoadStartDuringPlayerLife||"loadeddata"===e.type&&!t.ads._hasThereBeenALoadedData||"loadedmetadata"===e.type&&!t.ads._hasThereBeenALoadedMetaData))if(t.ads.inAdBreak())d(t,"ad",e);else{if(t.currentSrc()!==t.ads.contentSrc)return;d(t,"content",e)}}(this,t):"play"===t.type?function(t,e){t.ads.inAdBreak()?d(t,"ad",e):t.ads.isContentResuming()&&d(t,"content",e)}(this,t):this.ads.isInAdMode()&&(this.ads.isContentResuming()?d(this,"content",t):d(this,"ad",t))}function p(){return p=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)Object.prototype.hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},p.apply(this,arguments)}function f(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,g(t,e)}function g(t,e){return g=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},g(t,e)}var m={},y=function(){!function(){if(r().dom.isInFrame()&&"function"!=typeof a().__tcfapi){for(var t,e=a(),s={};e;){try{if(e.frames.__tcfapiLocator){t=e;break}}catch(t){}if(e===a().top)break;e=e.parent}if(!t)return;a().__tcfapi=function(e,i,r,n){var a=Math.random()+"",o={__tcfapiCall:{command:e,parameter:n,version:i,callId:a}};s[a]=r,t.postMessage(o,"*")},a().addEventListener("message",function(t){var e={};try{e="string"==typeof t.data?JSON.parse(t.data):t.data}catch(t){}var i=e.__tcfapiReturn;i&&"function"==typeof s[i.callId]&&(s[i.callId](i.returnValue,i.success),s[i.callId]=null)},!1)}}(),"function"==typeof a().__tcfapi&&a().__tcfapi("addEventListener",2,function(t,e){e&&(m=t)})},v="",b=function(t,e){if(void 0===e&&(e=a()),e.__uspapi)e.__uspapi("getUSPData",1,function(e,s){var i=s?e.uspString:null;v=i,t(i)});else{var s=function(t){for(var e=t.parent;e!==t.top;){try{if(e.frames&&e.frames.__uspapiLocator)return e}catch(t){}e=e.parent}try{if(t.top.frames&&t.top.frames.__uspapiLocator)return t.top}catch(t){}return null}(e);if(!s)return void t(null);var i=Math.random().toString(36).substring(2),r={__uspapiCall:{command:"getUSPData",version:1,callId:i}};e.addEventListener("message",function s(r){if(r&&r.data&&r.data.__uspapiReturn&&r.data.__uspapiReturn.callId===i){e.removeEventListener("message",s,!1);var n=r.data.__uspapiReturn,a=n.returnValue,o=n.success?a.uspString:null;v=o,t(o)}},!1),s.postMessage(r,"*")}},_={AdsBeforePrerollError:"ads-before-preroll-error",AdsPrerollError:"ads-preroll-error",AdsMidrollError:"ads-midroll-error",AdsPostrollError:"ads-postroll-error",AdsMacroReplacementFailed:"ads-macro-replacement-failed",AdsResumeContentFailed:"ads-resume-content-failed"},T=function(t,e){return e?encodeURIComponent(t):t},A=function(t,e,s,i,n){for(var a in void 0===i&&(i={}),e){var o=i.hasOwnProperty(a)?i[a]:a;if(o.startsWith("r:"))try{var l=new RegExp(o.slice(2),"g");t=t.replace(l,T(e[a],s))}catch(t){n.ads.error({errorType:_.AdsMacroReplacementFailed,macro:a,error:t}),r().log.warn('Unable to replace macro with regex "'+o+'". The provided regex may be invalid.')}else t=t.split(o).join(T(e[a],s))}return t};function E(t,e,s){void 0===e&&(e=!1),void 0===s&&(s={});var i=s.disableDefaultMacros||!1,n=s.macroNameOverrides||{};delete s.disableDefaultMacros,delete s.macroNameOverrides;var o=s;if(i)return A(t,o,e,n);var h,c,d,u=function(t){var e={},s=t.replace(/{([^}=]+)=([^}]*)}/g,function(t,s,i){return e["{"+s+"}"]=i,"{"+s+"}"});return{defaults:e,modifiedString:s}}(t),f=u.defaults,g=u.modifiedString;for(var y in t=g,p(o,{"{player.id}":(d=this).options_["data-player"]||d.id_,"{player.height}":d.currentHeight(),"{player.width}":d.currentWidth(),"{player.heightInt}":Math.round(d.currentHeight()),"{player.widthInt}":Math.round(d.currentWidth()),"{player.autoplay}":d.autoplay()?1:0,"{player.muted}":d.muted()?1:0,"{player.language}":d.language()||"","{mediainfo.id}":d.mediainfo?d.mediainfo.id:"","{mediainfo.name}":d.mediainfo?d.mediainfo.name:"","{mediainfo.duration}":d.mediainfo?d.mediainfo.duration:"","{player.duration}":d.duration(),"{player.durationInt}":Math.round(d.duration()),"{player.live}":d.duration()===1/0?1:0,"{player.pageUrl}":r().dom.isInFrame()?l().referrer:a().location.href,"{playlistinfo.id}":d.playlistinfo?d.playlistinfo.id:"","{playlistinfo.name}":d.playlistinfo?d.playlistinfo.name:"","{timestamp}":(new Date).getTime(),"{document.referrer}":l().referrer,"{window.location.href}":a().location.href,"{random}":Math.floor(1e12*Math.random())},function(t,e){var s={};return["description","tags","reference_id","ad_keys"].forEach(function(i){t&&t[i]?s["{mediainfo."+i+"}"]=t[i]:e["{mediainfo."+i+"}"]?s["{mediainfo."+i+"}"]=e["{mediainfo."+i+"}"]:s["{mediainfo."+i+"}"]=""}),["custom_fields","customFields"].forEach(function(e){!function(t,e,s){if(t&&t[s])for(var i=t[s],r=Object.keys(i),n=0;n<r.length;n++)e["{mediainfo."+s+"."+r[n]+"}"]=i[r[n]]}(t,s,e)}),s}(this.mediainfo,f),(h=m,c={},Object.keys(h).forEach(function(t){c["{tcf."+t+"}"]=h[t]}),c["{tcf.gdprAppliesInt}"]=h.gdprApplies?1:0,c),{"{usp.uspString}":v},function(t,e,s){var i=new RegExp("{pageVariable\\.([^}]+)}","g"),n={},o=(t.match(i)||[]).concat(Object.keys(s).filter(function(e){return i.test(e)&&t.includes(s[e])}));if(o)return o.forEach(function(t){for(var s,i=t,o=t.slice(14,-1),l=o.split("."),h=a(),c=0;c<l.length;c++)if(c===l.length-1)s=h[l[c]];else if(void 0===(h=h[l[c]]))break;var d=typeof s;null===s?n[i]="null":void 0===s?e[i]?n[i]=e[i]:(r().log.warn('Page variable "'+o+'" not found'),n[i]=""):"string"!==d&&"number"!==d&&"boolean"!==d?(r().log.warn('Page variable "'+o+'" is not a supported type'),n[i]=""):n[i]=s}),n}(t,f,n)),t=A(t,o,e,n,this),f)t=t.replace(y,f[y]);return t}var S={processMetadataTracks:function(t,e){for(var s=t.textTracks(),i=function(s){"metadata"===s.kind&&(t.ads.cueTextTracks.setMetadataTrackMode(s),e(t,s))},r=0;r<s.length;r++)i(s[r]);s.addEventListener("addtrack",function(t){i(t.track)})},setMetadataTrackMode:function(t){},getSupportedAdCue:function(t,e){return e},isSupportedAdCue:function(t,e){return!0},getCueId:function(t,e){return e.id}},C=function(t,e){return void 0!==e&&t.ads.includedCues[e]},k=function(t,e){void 0!==e&&""!==e&&(t.ads.includedCues[e]=!0)};function w(){!1!==this.ads._shouldBlockPlay&&(this.paused()||(this.ads.debug("Playback was canceled by cancelContentPlay"),this.pause()),this.ads._cancelledPlay=!0)}S.processAdTrack=function(t,e,s,i){t.ads.includedCues={};for(var n=0;n<e.length;n++){var a=e[n],o=this.getSupportedAdCue(t,a);if(!this.isSupportedAdCue(t,a))return void r().log.warn("Skipping as this is not a supported ad cue.",a);var l=this.getCueId(t,a),h=a.startTime;if(C(t,l))return void r().log("Skipping ad already seen with ID "+l);i&&i(t,o,l,h),s(t,o,l,h),k(t,l)}};var L={},I=r();L.isMiddlewareMediatorSupported=function(){return!I.browser.IS_IOS&&!I.browser.IS_ANDROID&&!!(I.use&&I.middleware&&I.middleware.TERMINATOR)},L.playMiddleware=function(t){return{setSource:function(t,e){e(null,t)},callPlay:function(){if(t.ads&&!0===t.ads._shouldBlockPlay)return t.ads.debug("Using playMiddleware to block content playback"),t.ads._playBlocked=!0,I.middleware.TERMINATOR},play:function(e,s){t.ads&&t.ads._playBlocked&&e?(t.ads.debug("Play call to Tech was terminated."),t.trigger("play"),t.addClass("vjs-has-started"),t.ads._playBlocked=!1):s&&s.catch&&s.catch(function(e){"NotAllowedError"!==e.name||r().browser.IS_SAFARI||t.trigger("pause")})}}},L.testHook=function(t){I=t};var P=L.playMiddleware,x=L.isMiddlewareMediatorSupported,R={src:"data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAAxJtZGF03ABMYXZjNjEuMy4xMDAAQiAIwRg4AAACrgYF//+q3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlIDE2NCByMzEwOCAzMWUxOWY5IC0gSC4yNjQvTVBFRy00IEFWQyBjb2RlYyAtIENvcHlsZWZ0IDIwMDMtMjAyMyAtIGh0dHA6Ly93d3cudmlkZW9sYW4ub3JnL3gyNjQuaHRtbCAtIG9wdGlvbnM6IGNhYmFjPTEgcmVmPTMgZGVibG9jaz0xOjA6MCBhbmFseXNlPTB4MzoweDExMyBtZT1oZXggc3VibWU9NyBwc3k9MSBwc3lfcmQ9MS4wMDowLjAwIG1peGVkX3JlZj0xIG1lX3JhbmdlPTE2IGNocm9tYV9tZT0xIHRyZWxsaXM9MSA4eDhkY3Q9MSBjcW09MCBkZWFkem9uZT0yMSwxMSBmYXN0X3Bza2lwPTEgY2hyb21hX3FwX29mZnNldD0tMiB0aHJlYWRzPTcgbG9va2FoZWFkX3RocmVhZHM9MSBzbGljZWRfdGhyZWFkcz0wIG5yPTAgZGVjaW1hdGU9MSBpbnRlcmxhY2VkPTAgYmx1cmF5X2NvbXBhdD0wIGNvbnN0cmFpbmVkX2ludHJhPTAgYmZyYW1lcz0zIGJfcHlyYW1pZD0yIGJfYWRhcHQ9MSBiX2JpYXM9MCBkaXJlY3Q9MSB3ZWlnaHRiPTEgb3Blbl9nb3A9MCB3ZWlnaHRwPTIga2V5aW50PTI1MCBrZXlpbnRfbWluPTI1IHNjZW5lY3V0PTQwIGludHJhX3JlZnJlc2g9MCByY19sb29rYWhlYWQ9NDAgcmM9Y3JmIG1idHJlZT0xIGNyZj0yMy4wIHFjb21wPTAuNjAgcXBtaW49MCBxcG1heD02OSBxcHN0ZXA9NCBpcF9yYXRpbz0xLjQwIGFxPTE6MS4wMACAAAAAOWWIhAAn//71sXwKaunqigzoMi7hlyTJrrYi4m0AwABFxzcqWKGahTaoBcQAAMWK4AlcFlIICBeldSEQBGCMHAAABVNtb292AAAAbG12aGQAAAAAAAAAAAAAAAAAAAPoAAAAIgABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAACQXRyYWsAAABcdGtoZAAAAAMAAAAAAAAAAAAAAAEAAAAAAAAAIgAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAABQAAAAPAAAAAAACRlZHRzAAAAHGVsc3QAAAAAAAAAAQAAACIAAAAAAAEAAAAAAbltZGlhAAAAIG1kaGQAAAAAAAAAAAAAAAAAADwAAAACAFXEAAAAAAAtaGRscgAAAAAAAAAAdmlkZQAAAAAAAAAAAAAAAFZpZGVvSGFuZGxlcgAAAAFkbWluZgAAABR2bWhkAAAAAQAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAABJHN0YmwAAADAc3RzZAAAAAAAAAABAAAAsGF2YzEAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAABQADwAEgAAABIAAAAAAAAAAEUTGF2YzYxLjMuMTAwIGxpYngyNjQAAAAAAAAAAAAAAAAY//8AAAA2YXZjQwFkAA3/4QAZZ2QADazZQUH7ARAAAAMAEAAAAwPA8UKZYAEABmjr48siwP34+AAAAAAQcGFzcAAAAAEAAAABAAAAFGJ0cnQAAAAAAALAEAACwBAAAAAYc3R0cwAAAAAAAAABAAAAAQAAAgAAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAEAAAABAAAAFHN0c3oAAAAAAAAC7wAAAAEAAAAUc3RjbwAAAAAAAAABAAAARQAAAj10cmFrAAAAXHRraGQAAAADAAAAAAAAAAAAAAACAAAAAAAAABgAAAAAAAAAAAAAAAEBAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAAAXAAAEAAABAAAAAAG1bWRpYQAAACBtZGhkAAAAAAAAAAAAAAAAAACsRAAACABVxAAAAAAALWhkbHIAAAAAAAAAAHNvdW4AAAAAAAAAAAAAAABTb3VuZEhhbmRsZXIAAAABYG1pbmYAAAAQc21oZAAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAABJHN0YmwAAAB+c3RzZAAAAAAAAAABAAAAbm1wNGEAAAAAAAAAAQAAAAAAAAAAAAIAEAAAAACsRAAAAAAANmVzZHMAAAAAA4CAgCUAAgAEgICAF0AVAAAAAAH0AAAAEisFgICABRIQVuUABoCAgAECAAAAFGJ0cnQAAAAAAAH0AAAAEisAAAAYc3R0cwAAAAAAAAABAAAAAgAABAAAAAAcc3RzYwAAAAAAAAABAAAAAQAAAAEAAAABAAAAHHN0c3oAAAAAAAAAAAAAAAIAAAAVAAAABgAAABhzdGNvAAAAAAAAAAIAAAAwAAADNAAAABpzZ3BkAQAAAHJvbGwAAAACAAAAAf//AAAAHHNiZ3AAAAAAcm9sbAAAAAEAAAACAAAAAQAAAGF1ZHRhAAAAWW1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAALGlsc3QAAAAkqXRvbwAAABxkYXRhAAAAAQAAAABMYXZmNjEuMS4xMDA=",type:"video/mp4"},D=function(){function t(){}return t.getState=function(e){if(e)return t.states_&&t.states_[e]?t.states_[e]:void 0},t.registerState=function(e,s){if("string"!=typeof e||!e)throw new Error('Illegal state name, "'+e+'"; must be a non-empty string.');return t.states_||(t.states_={}),t.states_[e]=s,s},t}(),O=function(){function t(t){this.player=t}t._getName=function(){return"Anonymous State"};var e=t.prototype;return e.transitionTo=function(t){var e=this.player;this.cleanup(e);var s=new t(e);e.ads._state=s,e.ads.debug(this.constructor._getName()+" -> "+s.constructor._getName());for(var i=arguments.length,r=new Array(i>1?i-1:0),n=1;n<i;n++)r[n-1]=arguments[n];s.init.apply(s,[e].concat(r))},e.init=function(){},e.cleanup=function(){},e.onPlay=function(){},e.onPlaying=function(){},e.onEnded=function(){},e.onAdEnded=function(){},e.onAdsReady=function(){r().log.warn("Unexpected adsready event")},e.onAdsError=function(){},e.onAdsCanceled=function(){},e.onAdTimeout=function(){},e.onAdStarted=function(){},e.onAdSkipped=function(){},e.onContentChanged=function(){},e.onContentResumed=function(){},e.onReadyForPostroll=function(){r().log.warn("Unexpected readyforpostroll event")},e.onNoPreroll=function(){},e.onNoPostroll=function(){},e.startLinearAdMode=function(){r().log.warn("Unexpected startLinearAdMode invocation (State via "+this.constructor._getName()+")")},e.endLinearAdMode=function(){r().log.warn("Unexpected endLinearAdMode invocation (State via "+this.constructor._getName()+")")},e.skipLinearAdMode=function(){r().log.warn("Unexpected skipLinearAdMode invocation (State via "+this.constructor._getName()+")")},e.isAdState=function(){throw new Error("isAdState unimplemented for "+this.constructor._getName())},e.isWaitingForAdBreak=function(){return!1},e.isContentResuming=function(){return!1},e.inAdBreak=function(){return!1},e.handleEvent=function(t){var e=this.player;"play"===t?this.onPlay(e):"adsready"===t?this.onAdsReady(e):"adserror"===t?this.onAdsError(e):"adscanceled"===t?this.onAdsCanceled(e):"adtimeout"===t?this.onAdTimeout(e):"ads-ad-started"===t?this.onAdStarted(e):"ads-ad-skipped"===t?this.onAdSkipped(e):"contentchanged"===t?this.onContentChanged(e):"contentresumed"===t?this.onContentResumed(e):"readyforpostroll"===t?this.onReadyForPostroll(e):"playing"===t?this.onPlaying(e):"ended"===t?this.onEnded(e):"nopreroll"===t?this.onNoPreroll(e):"nopostroll"===t?this.onNoPostroll(e):"adended"===t&&this.onAdEnded(e)},t}();D.registerState("State",O);var M=function(t){function e(e){var s;return(s=t.call(this,e)||this).contentResuming=!1,s.waitingForAdBreak=!1,s}f(e,t);var s=e.prototype;return s.isAdState=function(){return!0},s.onPlaying=function(){var t=D.getState("ContentPlayback");this.contentResuming&&this.transitionTo(t)},s.onContentResumed=function(){var t=D.getState("ContentPlayback");this.contentResuming&&this.transitionTo(t)},s.isWaitingForAdBreak=function(){return this.waitingForAdBreak},s.isContentResuming=function(){return this.contentResuming},s.inAdBreak=function(){return!0===this.player.ads._inLinearAdMode},e}(O);D.registerState("AdState",M);var F=function(t){function e(){return t.apply(this,arguments)||this}f(e,t);var s=e.prototype;return s.isAdState=function(){return!1},s.onContentChanged=function(t){var e=D.getState("BeforePreroll"),s=D.getState("Preroll");t.ads.debug("Received contentchanged event (ContentState)"),t.paused()?this.transitionTo(e):(this.transitionTo(s,!1),t.pause(),t.ads._pausedOnContentupdate=!0)},e}(O);D.registerState("ContentState",F);var N,B=function(t){function e(){return t.apply(this,arguments)||this}f(e,t),e._getName=function(){return"AdsDone"};var s=e.prototype;return s.init=function(t){t.ads._contentHasEnded=!0,t.trigger("ended")},s.startLinearAdMode=function(){r().log.warn("Unexpected startLinearAdMode invocation (AdsDone)")},e}(D.getState("ContentState"));D.registerState("AdsDone",B);var j=function(t){t.ads.debug("Starting ad break"),t.ads._inLinearAdMode=!0,t.trigger("adstart"),t.ads.shouldTakeSnapshots()&&(t.ads.snapshot=function(t){var e;e=r().browser.IS_IOS&&t.ads.isLive(t)&&t.seekable().length>0?t.currentTime()-t.seekable().end(0):t.currentTime();var s=t.$(".vjs-tech"),i=t.textTracks?t.textTracks():[],n=[],a={ended:t.ended(),currentSrc:t.currentSrc(),sources:t.currentSources(),src:t.tech_.src(),currentTime:e,type:t.currentType()};s&&(a.style=s.getAttribute("style"));for(var o=0;o<i.length;o++){var l=i[o];n.push({track:l,mode:l.mode}),l.mode="disabled"}return a.suppressedTracks=n,a}(t)),t.ads.shouldPlayContentBehindAd(t)&&!t.ads.settings.stitchedAds&&(t.ads.preAdVolume_=t.volume(),t.volume(0)),t.addClass("vjs-ad-playing"),t.hasClass("vjs-live")&&t.removeClass("vjs-live"),t.ads.removeNativePoster(),t.ads.preAdPlaybackRate_=t.playbackRate(),t.playbackRate(1),t.controlBar&&t.controlBar.playbackRateMenuButton&&t.controlBar.playbackRateMenuButton.playbackRateSupported&&!t.controlBar.playbackRateMenuButton.hasClass("vjs-hidden")?(t.controlBar.playbackRateMenuButton.hide(),t.ads.showPlaybackMenuOnAdEnd_=!0):t.ads.showPlaybackMenuOnAdEnd_=!1},$=function(t,e){t.ads.debug("Ending ad break"),void 0===e&&(e=function(){}),t.ads.adType=null,t.ads._inLinearAdMode=!1,t.trigger("adend"),t.removeClass("vjs-ad-playing"),t.ads.isLive(t)&&t.addClass("vjs-live"),t.ads.shouldTakeSnapshots()?function(t,e){var s=t.ads.snapshot;if(void 0===e&&(e=function(){}),!0===t.ads.disableNextSnapshotRestore)return t.ads.disableNextSnapshotRestore=!1,delete t.ads.snapshot,void e();var i,n=t.$(".vjs-tech"),a=20,o=s.suppressedTracks,l=function(){for(var t=0;t<o.length;t++)(i=o[t]).track.mode=i.mode},h=function(){var e;if(r().browser.IS_IOS&&t.ads.isLive(t)){if(s.currentTime<0&&(e=t.seekable().length>0?t.seekable().end(0)+s.currentTime:t.currentTime(),t.currentTime(e)),t.paused()){var i=t.play();i&&i.catch&&i.catch(function(t){r().log.warn("Play promise rejected in IOS snapshot resume",t)})}}else if(s.ended)t.currentTime(t.duration());else{t.currentTime(s.currentTime);var n=t.play();n&&n.catch&&n.catch(function(t){r().log.warn("Play promise rejected in snapshot resume",t)})}t.ads.shouldRemoveAutoplay_&&(t.autoplay(!1),t.ads.shouldRemoveAutoplay_=!1)},c=function e(){if(t.off("contentcanplay",e),N&&t.clearTimeout(N),(n=t.el().querySelector(".vjs-tech")).readyState>1)return h();if(void 0===n.seekable)return h();if(n.seekable.length>0)return h();if(a--)t.setTimeout(e,50);else try{h()}catch(e){t.ads.error({errorType:_.AdsResumeContentFailed,error:e}),r().log.warn("Failed to resume the content after an advertisement",e)}};if("style"in s&&n.setAttribute("style",s.style||""),t.ads.videoElementRecycled())t.one("resumeended",function(){delete t.ads.snapshot,e()}),t.one("contentloadedmetadata",l),r().browser.IS_IOS&&!t.autoplay()&&"function"==typeof t.techCall_&&(t.techCall_("setAutoplay",!0),t.ads.shouldRemoveAutoplay_=!0),t.src(s.sources),t.one("contentcanplay",c),N=t.setTimeout(c,2e3);else{if(l(),!t.ended()){var d=t.play();d&&d.catch&&d.catch(function(t){r().log.warn("Play promise rejected in snapshot restore",t)})}delete t.ads.snapshot,e()}}(t,e):(t.ads.preAdVolume_&&t.volume(t.ads.preAdVolume_),e()),t.playbackRate(t.ads.preAdPlaybackRate_),t.ads.showPlaybackMenuOnAdEnd_&&t.controlBar.playbackRateMenuButton.show()},U=function(t){function e(){return t.apply(this,arguments)||this}f(e,t),e._getName=function(){return"Preroll"};var s=e.prototype;return s.init=function(t,e,s){if(this.waitingForAdBreak=!0,t.addClass("vjs-ad-loading"),s||t.ads.nopreroll_)return this.resumeAfterNoPreroll(t);var i=t.ads.settings.timeout;"number"==typeof t.ads.settings.prerollTimeout&&(i=t.ads.settings.prerollTimeout),this._timeout=t.setTimeout(function(){t.trigger("adtimeout")},i),e?this.handleAdsReady():this.adsReady=!1},s.onAdsReady=function(t){t.ads.inAdBreak()?r().log.warn("Unexpected adsready event (Preroll)"):(t.ads.debug("Received adsready event (Preroll)"),this.handleAdsReady())},s.handleAdsReady=function(){this.adsReady=!0,this.readyForPreroll()},s.afterLoadStart=function(t){var e=this.player;e.ads._hasThereBeenALoadStartDuringPlayerLife?t():(e.ads.debug("Waiting for loadstart..."),e.one("loadstart",function(){e.ads.debug("Received loadstart event"),t()}))},s.noPreroll=function(){var t=this;this.afterLoadStart(function(){t.player.ads.debug("Skipping prerolls due to nopreroll event (Preroll)"),t.resumeAfterNoPreroll(t.player)})},s.readyForPreroll=function(){var t=this.player;this.afterLoadStart(function(){t.ads.debug("Triggered readyforpreroll event (Preroll)"),t.trigger("readyforpreroll")})},s.onAdsCanceled=function(t){var e=this;t.ads.debug("adscanceled (Preroll)"),this.afterLoadStart(function(){e.resumeAfterNoPreroll(t)})},s.onAdsError=function(t){var e=this;r().log("adserror (Preroll)"),t.ads.error({errorType:_.AdsPrerollError}),this.inAdBreak()?t.ads.endLinearAdMode():this.afterLoadStart(function(){e.resumeAfterNoPreroll(t)})},s.startLinearAdMode=function(){var t=this.player;!this.adsReady||t.ads.inAdBreak()||this.isContentResuming()?r().log.warn("Unexpected startLinearAdMode invocation (Preroll)"):(this.clearTimeout(t),t.ads.adType="preroll",this.waitingForAdBreak=!1,j(t),t.ads._shouldBlockPlay=!1)},s.onAdStarted=function(t){t.removeClass("vjs-ad-loading")},s.endLinearAdMode=function(){var t=this.player;this.inAdBreak()&&(t.removeClass("vjs-ad-loading"),t.addClass("vjs-ad-content-resuming"),this.contentResuming=!0,$(t))},s.skipLinearAdMode=function(){var t=this,e=this.player;e.ads.inAdBreak()||this.isContentResuming()?r().log.warn("Unexpected skipLinearAdMode invocation"):this.afterLoadStart(function(){e.trigger("adskip"),e.ads.debug("skipLinearAdMode (Preroll)"),t.resumeAfterNoPreroll(e)})},s.onAdTimeout=function(t){var e=this;this.afterLoadStart(function(){t.ads.debug("adtimeout (Preroll)"),e.resumeAfterNoPreroll(t)})},s.onNoPreroll=function(t){t.ads.inAdBreak()||this.isContentResuming()?r().log.warn("Unexpected nopreroll event (Preroll)"):this.noPreroll()},s.resumeAfterNoPreroll=function(t){if(this.contentResuming=!0,t.ads._shouldBlockPlay=!1,this.cleanupPartial(t),t.ads._playRequested||t.ads._pausedOnContentupdate)if(t.paused()){t.ads.debug("resumeAfterNoPreroll: attempting to resume playback (Preroll)");var e=t.play();e&&e.then&&e.then(null,function(t){})}else t.ads.debug("resumeAfterNoPreroll: already playing (Preroll)"),t.trigger("play"),t.trigger("playing")},s.cleanup=function(t){t.ads._hasThereBeenALoadStartDuringPlayerLife||r().log.warn("Leaving Preroll state before loadstart event can cause issues."),this.cleanupPartial(t)},s.cleanupPartial=function(t){t.removeClass("vjs-ad-loading"),t.removeClass("vjs-ad-content-resuming"),this.clearTimeout(t)},s.clearTimeout=function(t){t.clearTimeout(this._timeout),this._timeout=null},e}(D.getState("AdState"));D.registerState("Preroll",U);var H=function(t){function e(){return t.apply(this,arguments)||this}f(e,t),e._getName=function(){return"BeforePreroll"};var s=e.prototype;return s.init=function(t){this.adsReady=!1,this.shouldResumeToContent=!1,t.ads._shouldBlockPlay=!t.ads.settings.allowVjsAutoplay||!t.autoplay()},s.onAdsReady=function(t){t.ads.debug("Received adsready event (BeforePreroll)"),this.adsReady=!0},s.onPlay=function(t){var e=D.getState("Preroll");t.ads.debug("Received play event (BeforePreroll)"),this.transitionTo(e,this.adsReady,this.shouldResumeToContent)},s.onAdsCanceled=function(t){t.ads.debug("adscanceled (BeforePreroll)"),this.shouldResumeToContent=!0},s.onAdsError=function(){this.player.ads.debug("adserror (BeforePreroll)"),this.player.ads.error({errorType:_.AdsBeforePrerollError}),this.shouldResumeToContent=!0},s.onNoPreroll=function(){this.player.ads.debug("Skipping prerolls due to nopreroll event (BeforePreroll)"),this.shouldResumeToContent=!0},s.skipLinearAdMode=function(){var t=this.player;t.trigger("adskip"),t.ads.debug("skipLinearAdMode (BeforePreroll)"),this.shouldResumeToContent=!0},s.onContentChanged=function(){this.init(this.player)},e}(D.getState("ContentState"));D.registerState("BeforePreroll",H);var V=function(t){function e(){return t.apply(this,arguments)||this}f(e,t),e._getName=function(){return"Midroll"};var s=e.prototype;return s.init=function(t){t.ads.adType="midroll",j(t),t.addClass("vjs-ad-loading")},s.onAdStarted=function(t){t.removeClass("vjs-ad-loading")},s.endLinearAdMode=function(){var t=this.player;this.inAdBreak()&&(this.contentResuming=!0,t.addClass("vjs-ad-content-resuming"),t.removeClass("vjs-ad-loading"),$(t))},s.onAdsError=function(t){t.ads.error({errorType:_.AdsMidrollError}),this.inAdBreak()&&t.ads.endLinearAdMode()},s.cleanup=function(t){t.removeClass("vjs-ad-loading"),t.removeClass("vjs-ad-content-resuming")},e}(D.getState("AdState"));D.registerState("Midroll",V);var G=function(t){function e(){return t.apply(this,arguments)||this}f(e,t),e._getName=function(){return"Postroll"};var s=e.prototype;return s.init=function(t){if(this.waitingForAdBreak=!0,t.ads._contentEnding=!0,t.ads.nopostroll_){this.resumeContent(t);var e=D.getState("AdsDone");this.transitionTo(e)}else{t.addClass("vjs-ad-loading");var s=t.ads.settings.timeout;"number"==typeof t.ads.settings.postrollTimeout&&(s=t.ads.settings.postrollTimeout),this._postrollTimeout=t.setTimeout(function(){t.trigger("adtimeout")},s)}},s.startLinearAdMode=function(){var t=this.player;t.ads.inAdBreak()||this.isContentResuming()?r().log.warn("Unexpected startLinearAdMode invocation (Postroll)"):(t.ads.adType="postroll",t.clearTimeout(this._postrollTimeout),this.waitingForAdBreak=!1,j(t))},s.onAdStarted=function(t){t.removeClass("vjs-ad-loading")},s.endLinearAdMode=function(){var t=this,e=this.player,s=D.getState("AdsDone");this.inAdBreak()&&(e.removeClass("vjs-ad-loading"),this.resumeContent(e),$(e,function(){t.transitionTo(s)}))},s.skipLinearAdMode=function(){var t=this.player;t.ads.inAdBreak()||this.isContentResuming()?r().log.warn("Unexpected skipLinearAdMode invocation"):(t.ads.debug("Postroll abort (skipLinearAdMode)"),t.trigger("adskip"),this.abort(t))},s.onAdTimeout=function(t){t.ads.debug("Postroll abort (adtimeout)"),this.abort(t)},s.onAdsError=function(t){t.ads.debug("Postroll abort (adserror)"),t.ads.error({errorType:_.AdsPostrollError}),t.ads.inAdBreak()?t.ads.endLinearAdMode():this.abort(t)},s.onContentChanged=function(t){if(this.isContentResuming()){var e=D.getState("BeforePreroll");this.transitionTo(e)}else if(!this.inAdBreak()){var s=D.getState("Preroll");this.transitionTo(s)}},s.onNoPostroll=function(t){this.isContentResuming()||this.inAdBreak()?r().log.warn("Unexpected nopostroll event (Postroll)"):this.abort(t)},s.resumeContent=function(t){this.contentResuming=!0,t.addClass("vjs-ad-content-resuming")},s.abort=function(t){var e=D.getState("AdsDone");this.resumeContent(t),t.removeClass("vjs-ad-loading"),this.transitionTo(e)},s.cleanup=function(t){t.removeClass("vjs-ad-content-resuming"),t.clearTimeout(this._postrollTimeout),t.ads._contentEnding=!1},e}(D.getState("AdState"));D.registerState("Postroll",G);var W=function(t){function e(){return t.apply(this,arguments)||this}f(e,t),e._getName=function(){return"ContentPlayback"};var s=e.prototype;return s.init=function(t){t.ads._shouldBlockPlay=!1},s.onAdsReady=function(t){t.ads.debug("Received adsready event (ContentPlayback)"),t.ads.nopreroll_||(t.ads.debug("Triggered readyforpreroll event (ContentPlayback)"),t.trigger("readyforpreroll"))},s.onReadyForPostroll=function(t){var e=D.getState("Postroll");t.ads.debug("Received readyforpostroll event"),this.transitionTo(e)},s.startLinearAdMode=function(){var t=D.getState("Midroll");this.transitionTo(t)},e}(D.getState("ContentState"));D.registerState("ContentPlayback",W);var K=function(t){function e(){return t.apply(this,arguments)||this}f(e,t),e._getName=function(){return"StitchedContentPlayback"};var s=e.prototype;return s.init=function(){this.player.ads._shouldBlockPlay=!1},s.onContentChanged=function(){this.player.ads.debug("Received contentchanged event ("+this.constructor._getName()+")")},s.startLinearAdMode=function(){var t=D.getState("StitchedAdRoll");this.transitionTo(t)},e}(D.getState("ContentState"));D.registerState("StitchedContentPlayback",K);var z=function(t){function e(){return t.apply(this,arguments)||this}f(e,t),e._getName=function(){return"StitchedAdRoll"};var s=e.prototype;return s.init=function(){this.waitingForAdBreak=!1,this.contentResuming=!1,this.player.ads.adType="stitched",j(this.player)},s.onPlaying=function(){},s.onContentResumed=function(){},s.onAdEnded=function(){this.endLinearAdMode(),this.player.trigger("ended")},s.endLinearAdMode=function(){var t=D.getState("StitchedContentPlayback");$(this.player),this.transitionTo(t)},e}(D.getState("AdState"));D.registerState("StitchedAdRoll",z);var q=function(t){function e(){return t.apply(this,arguments)||this}f(e,t),e._getName=function(){return"OutstreamPending"};var s=e.prototype;return s.init=function(t){this.adsReady=!1},s.onPlay=function(t){var e=D.getState("OutstreamPlayback");t.ads.debug("Received play event (OutstreamPending)"),this.transitionTo(e,this.adsReady)},s.onAdsReady=function(t){t.ads.debug("Received adsready event (OutstreamPending)"),this.adsReady=!0},s.onAdsError=function(){this.player.ads.debug("adserror (OutstreamPending)"),this.adsReady=!1},e}(D.getState("AdState"));D.registerState("OutstreamPending",q);var Y=function(t){function e(){return t.apply(this,arguments)||this}f(e,t),e._getName=function(){return"OutstreamPlayback"};var s=e.prototype;return s.init=function(t,e){t.addClass("vjs-ad-loading"),e?this.handleAdsReady():this.abort(t)},s.onAdsReady=function(t){t.ads.inAdBreak()?r().log.warn("Unexpected adsready event (Preroll)"):(t.ads.debug("Received adsready event (Preroll)"),this.handleAdsReady())},s.abort=function(t){var e=D.getState("OutstreamDone");t.removeClass("vjs-ad-loading"),this.transitionTo(e)},s.onAdStarted=function(t){t.removeClass("vjs-ad-loading")},s.handleAdsReady=function(){this.adsReady=!0,this.readyForOutstreamPlayback()},s.readyForOutstreamPlayback=function(){var t=this.player;this.afterLoadStart(function(){t.trigger("readyforoutstream")})},s.startLinearAdMode=function(){var t=this.player;this.adsReady&&!t.ads.inAdBreak()&&j(t)},s.cleanup=function(t){t.ads._hasThereBeenALoadStartDuringPlayerLife||r().log.warn("Leaving OutstreamPlayback state before loadstart event can cause issues."),this.cleanupPartial(t)},s.cleanupPartial=function(t){t.removeClass("vjs-ad-loading"),t.removeClass("vjs-ad-content-resuming"),this.clearTimeout(t)},s.clearTimeout=function(t){t.clearTimeout(this._timeout),this._timeout=null},s.onAdStarted=function(t){t.removeClass("vjs-ad-loading")},s.onAdsError=function(t){var e=this;r().log("adserror (OutstreamPlayback)"),this.inAdBreak()?t.ads.endLinearAdMode():this.afterLoadStart(function(){e.abort(t)})},s.onAdTimeout=function(t){var e=this;this.afterLoadStart(function(){t.ads.debug("adtimeout (OutstreamPlayback)"),e.abort(t)})},s.onAdsCanceled=function(t){var e=this;t.ads.debug("adscanceled (OutstreamPlaybac)"),this.afterLoadStart(function(){e.abort(t)})},s.endLinearAdMode=function(){var t=this;if(this.inAdBreak()){this.player.removeClass("vjs-ad-loading");var e=D.getState("OutstreamDone");$(this.player,function(){t.transitionTo(e)})}},s.afterLoadStart=function(t){var e=this.player;e.ads._hasThereBeenALoadStartDuringPlayerLife?t():(e.ads.debug("Waiting for loadstart..."),e.one("loadstart",function(){e.ads.debug("Received loadstart event"),t()}))},s.skipLinearAdMode=function(){var t=this,e=this.player,s=D.getState("OutstreamDone");this.inAdBreak()?r().log.warn("Unexpected skipLinearAdMode invocation"):this.afterLoadStart(function(){e.trigger("adskip"),e.ads.debug("skipLinearAdMode (OutstreamPlayback)"),t.transitionTo(s)})},e}(D.getState("AdState"));D.registerState("OutstreamPlayback",Y);var X=function(t){function e(){return t.apply(this,arguments)||this}f(e,t),e._getName=function(){return"OutstreamDone"};var s=e.prototype;return s.init=function(t){t.trigger("ended")},s.startLinearAdMode=function(){r().log.warn("Unexpected startLinearAdMode invocation (OutstreamDone)")},e}(D.getState("AdState"));D.registerState("OutstreamDone",X);var Q=L.isMiddlewareMediatorSupported,Z=r().getTech("Html5").Events,J={timeout:5e3,prerollTimeout:void 0,postrollTimeout:void 0,debug:!1,stitchedAds:!1,contentIsLive:void 0,liveCuePoints:!0,allowVjsAutoplay:r().options.normalizeAutoplay||!1},tt=function(t){var e=this,s=r().obj.merge(J,t),i=[];Z.concat(["firstplay","loadedalldata"]).forEach(function(t){-1===i.indexOf(t)&&i.push(t)}),e.on(i,u),Q()||function(t,e){e&&r().log("Using cancelContentPlay to block content playback"),t.on("play",w)}(e,s.debug),e.setTimeout(function(){e.ads._hasThereBeenALoadStartDuringPlayerLife||""===e.src()||r().log.error("videojs-contrib-ads has not seen a loadstart event 5 seconds after being initialized, but a source is present. This indicates that videojs-contrib-ads was initialized too late. It must be initialized immediately after video.js in the same tick. As a result, some ads will not play and some media events will be incorrect. For more information, see http://videojs.github.io/videojs-contrib-ads/integrator/getting-started.html")},5e3),e.on("ended",function(){e.hasClass("vjs-has-started")||e.addClass("vjs-has-started")}),e.on("contenttimeupdate",function(){e.removeClass("vjs-waiting")}),e.on(["addurationchange","adcanplay"],function(){if(!e.ads.settings.stitchedAds&&!e.hasStarted()&&(!e.ads.snapshot||e.currentSrc()!==e.ads.snapshot.currentSrc)&&e.ads.inAdBreak()){var t=e.play();t&&t.catch&&t.catch(function(t){r().log.warn("Play promise rejected when playing ad",t)})}}),e.on("nopreroll",function(){e.ads.debug("Received nopreroll event"),e.ads.nopreroll_=!0}),e.on("nopostroll",function(){e.ads.debug("Received nopostroll event"),e.ads.nopostroll_=!0}),e.on("playing",function(){e.ads._cancelledPlay=!1,e.ads._pausedOnContentupdate=!1}),e.on("play",function(){e.ads._playRequested=!0}),e.one("loadstart",function(){e.ads._hasThereBeenALoadStartDuringPlayerLife=!0}),e.on("loadeddata",function(){e.ads._hasThereBeenALoadedData=!0}),e.on("loadedmetadata",function(){e.ads._hasThereBeenALoadedMetaData=!0}),e.ads=function(t){return{disableNextSnapshotRestore:!1,_contentEnding:!1,_contentHasEnded:!1,_hasThereBeenALoadStartDuringPlayerLife:!1,_hasThereBeenALoadedData:!1,_hasThereBeenALoadedMetaData:!1,_inLinearAdMode:!1,_shouldBlockPlay:!1,_playBlocked:!1,_playRequested:!1,_error:null,adType:null,VERSION:h,reset:function(){t.ads.disableNextSnapshotRestore=!1,t.ads._contentEnding=!1,t.ads._contentHasEnded=!1,t.ads.snapshot=null,t.ads.adType=null,t.ads._hasThereBeenALoadedData=!1,t.ads._hasThereBeenALoadedMetaData=!1,t.ads._cancelledPlay=!1,t.ads._shouldBlockPlay=!1,t.ads._playBlocked=!1,t.ads.nopreroll_=!1,t.ads.nopostroll_=!1,t.ads._playRequested=!1,t.ads._error=null},startLinearAdMode:function(){t.ads._state.startLinearAdMode()},endLinearAdMode:function(){t.ads._state.endLinearAdMode()},skipLinearAdMode:function(){t.ads._state.skipLinearAdMode()},stitchedAds:function(t){return void 0!==t&&(r().log.warn("Using player.ads.stitchedAds() as a setter is deprecated, it should be set as an option upon initialization of contrib-ads."),this.settings.stitchedAds=!!t),this.settings.stitchedAds},videoElementRecycled:function(){if(t.ads.shouldPlayContentBehindAd(t))return!1;if(!this.snapshot)throw new Error("You cannot use videoElementRecycled while there is no snapshot.");var e=t.tech_.src()!==this.snapshot.src,s=t.currentSrc()!==this.snapshot.currentSrc;return e||s},isLive:function(e){return void 0===e&&(e=t),"boolean"==typeof e.ads.settings.contentIsLive?e.ads.settings.contentIsLive:e.duration()===1/0||"8"===r().browser.IOS_VERSION&&0===e.duration()},shouldPlayContentBehindAd:function(e){if(void 0===e&&(e=t),e)return!!e.ads.settings.liveCuePoints&&!r().browser.IS_IOS&&!r().browser.IS_ANDROID&&e.duration()===1/0;throw new Error("shouldPlayContentBehindAd requires a player as a param")},shouldTakeSnapshots:function(e){return void 0===e&&(e=t),!this.shouldPlayContentBehindAd(e)&&!this.stitchedAds()},isInAdMode:function(){return this._state.isAdState()},isWaitingForAdBreak:function(){return this._state.isWaitingForAdBreak()},isContentResuming:function(){return this._state.isContentResuming()},isAdPlaying:function(){return this._state.inAdBreak()},inAdBreak:function(){return this._state.inAdBreak()},removeNativePoster:function(){var e=t.$(".vjs-tech");e&&e.removeAttribute("poster")},debug:function(){if(this.settings.debug){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];1===e.length&&"string"==typeof e[0]?r().log("ADS: "+e[0]):r().log.apply(r(),["ADS:"].concat(e))}},error:function(e){if(void 0===e)return this._error||null;null!==e&&e.errorType?(this._error=e,r().log.error("An error with Ads occured. Type: "+e.errorType+"."),t.trigger({type:"vjsadserror",error:this._error})):this._error=null}}}(e),e.ads.settings=s,s.stitchedAds=!!s.stitchedAds,"outstream"===s.playerMode?(e.src(R),e.ads._state=new(D.getState("OutstreamPending"))(e)):s.stitchedAds?e.ads._state=new(D.getState("StitchedContentPlayback"))(e):e.ads._state=new(D.getState("BeforePreroll"))(e),e.ads._state.init(e),e.ads.cueTextTracks=S,e.ads.adMacroReplacement=E.bind(e),function(t){t.ads.contentSrc=t.currentSrc(),t.ads._seenInitialLoadstart=!1,t.on("loadstart",function(){if(!t.ads.inAdBreak()){var e=t.currentSrc();e!==t.ads.contentSrc&&(t.ads._seenInitialLoadstart&&t.trigger({type:"contentchanged"}),t.trigger({type:"contentupdate",oldValue:t.ads.contentSrc,newValue:e}),t.ads.contentSrc=e),t.ads._seenInitialLoadstart=!0}})}(e),e.on("contentchanged",e.ads.reset);var n=function(){var t=e.textTracks();if(!e.ads.shouldPlayContentBehindAd(e)&&e.ads.inAdBreak()&&e.tech_.featuresNativeTextTracks&&r().browser.IS_IOS&&!Array.isArray(e.textTracks()))for(var s=0;s<t.length;s++){var i=t[s];"showing"===i.mode&&(i.mode="disabled")}};e.ready(function(){e.textTracks().addEventListener("change",n)}),e.on(["play","playing","ended","adsready","adscanceled","adskip","adserror","adtimeout","adended","ads-ad-started","ads-ad-skipped","contentchanged","dispose","contentresumed","readyforpostroll","nopreroll","nopostroll"],function(t){e.ads._state.handleEvent(t.type)}),e.on("dispose",function(){e.ads.reset(),e.textTracks().removeEventListener("change",n)}),y(),b(function(){}),e.ads.listenToTcf=y,e.ads.updateUsPrivacyString=function(t){return b(t)}};function et(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,i=Array(e);s<e;s++)i[s]=t[s];return i}function st(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function it(t,e,s){return Object.defineProperty(t,"prototype",{writable:!1}),t}function rt(t){return rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rt(t)}tt.Error=_,tt.VERSION=h,function(t){!function(){if(r().getPlugin)return Boolean(r().getPlugin("ads"));var t=r().getComponent("Player");return Boolean(t&&t.prototype.ads)}(r())&&((r().registerPlugin||r().plugin)("ads",t),x()&&!r().usingContribAdsMiddleware_&&(r().use("*",P),r().usingContribAdsMiddleware_=!0,r().log.debug("Play middleware has been registered with videojs")))}(tt);var nt=function(t,e,s){this.vjsPlayer=t,this.controller=s,this.contentTrackingTimer=null,this.contentComplete=!1,this.updateTimeIntervalHandle=null,this.updateTimeInterval=1e3,this.seekCheckIntervalHandle=null,this.seekCheckInterval=1e3,this.resizeCheckIntervalHandle=null,this.resizeCheckInterval=250,this.seekThreshold=100,this.contentEndedListeners=[],this.contentSource="",this.contentSourceType="",this.contentPlayheadTracker={currentTime:0,previousTime:0,seeking:!1,duration:0},this.vjsPlayerDimensions={width:this.getPlayerWidth(),height:this.getPlayerHeight()},this.vjsControls=this.vjsPlayer.getChild("controlBar"),this.h5Player=null,this.vjsPlayer.one("play",this.setUpPlayerIntervals.bind(this)),this.boundContentEndedListener=this.localContentEndedListener.bind(this),this.vjsPlayer.on("readyforpostroll",this.boundContentEndedListener),this.vjsPlayer.on("dispose",this.playerDisposedListener.bind(this)),this.vjsPlayer.on("readyforpreroll",this.onReadyForPreroll.bind(this)),this.vjsPlayer.on("adtimeout",this.onAdTimeout.bind(this)),this.vjsPlayer.ready(this.onPlayerReady.bind(this)),"onPlay"===this.controller.getSettings().requestMode&&this.vjsPlayer.one("play",this.controller.requestAds.bind(this.controller)),this.vjsPlayer.ads||window.console.warn("You may be using a version of videojs-contrib-ads that is not compatible with your version of video.js."),this.vjsPlayer.ads(e)};nt.prototype.setUpPlayerIntervals=function(){this.updateTimeIntervalHandle&&clearInterval(this.updateTimeIntervalHandle),this.seekCheckIntervalHandle&&clearInterval(this.seekCheckIntervalHandle),this.resizeCheckIntervalHandle&&clearInterval(this.resizeCheckIntervalHandle),this.updateTimeIntervalHandle=setInterval(this.updateCurrentTime.bind(this),this.updateTimeInterval),this.seekCheckIntervalHandle=setInterval(this.checkForSeeking.bind(this),this.seekCheckInterval),this.resizeCheckIntervalHandle=setInterval(this.checkForResize.bind(this),this.resizeCheckInterval)},nt.prototype.updateCurrentTime=function(){this.contentPlayheadTracker.seeking||(this.contentPlayheadTracker.currentTime=this.vjsPlayer.currentTime())},nt.prototype.checkForSeeking=function(){var t=1e3*(this.vjsPlayer.currentTime()-this.contentPlayheadTracker.previousTime);Math.abs(t)>this.seekCheckInterval+this.seekThreshold?this.contentPlayheadTracker.seeking=!0:this.contentPlayheadTracker.seeking=!1,this.contentPlayheadTracker.previousTime=this.vjsPlayer.currentTime()},nt.prototype.checkForResize=function(){var t=this.getPlayerWidth(),e=this.getPlayerHeight();t==this.vjsPlayerDimensions.width&&e==this.vjsPlayerDimensions.height||(this.vjsPlayerDimensions.width=t,this.vjsPlayerDimensions.height=e,this.controller.onPlayerResize(t,e))},nt.prototype.localContentEndedListener=function(){for(var t in this.contentComplete||(this.contentComplete=!0,this.controller.onContentComplete()),this.contentEndedListeners)"function"==typeof this.contentEndedListeners[t]&&this.contentEndedListeners[t]();this.vjsPlayer.el()&&this.vjsPlayer.one("play",this.setUpPlayerIntervals.bind(this))},nt.prototype.onNoPostroll=function(){this.vjsPlayer.trigger("nopostroll")},nt.prototype.playerDisposedListener=function(){this.contentEndedListeners=[],this.controller.onPlayerDisposed(),this.contentComplete=!0,this.vjsPlayer.off("readyforpostroll",this.boundContentEndedListener),this.vjsPlayer.ads.adTimeoutTimeout&&clearTimeout(this.vjsPlayer.ads.adTimeoutTimeout);var t=[this.updateTimeIntervalHandle,this.seekCheckIntervalHandle,this.resizeCheckIntervalHandle];for(var e in t)t[e]&&clearInterval(t[e])},nt.prototype.onReadyForPreroll=function(){this.controller.onPlayerReadyForPreroll()},nt.prototype.onAdTimeout=function(){this.controller.onAdTimeout()},nt.prototype.onPlayerReady=function(){this.h5Player=document.getElementById(this.getPlayerId()).getElementsByClassName("vjs-tech")[0],this.h5Player.hasAttribute("autoplay")&&this.controller.setSetting("adWillAutoPlay",!0),this.onVolumeChange(),this.vjsPlayer.on("fullscreenchange",this.onFullscreenChange.bind(this)),this.vjsPlayer.on("volumechange",this.onVolumeChange.bind(this)),this.controller.onPlayerReady()},nt.prototype.onFullscreenChange=function(){this.vjsPlayer.isFullscreen()?this.controller.onPlayerEnterFullscreen():this.controller.onPlayerExitFullscreen()},nt.prototype.onVolumeChange=function(){var t=this.vjsPlayer.muted()?0:this.vjsPlayer.volume();this.controller.onPlayerVolumeChanged(t)},nt.prototype.injectAdContainerDiv=function(t){this.vjsControls.el().parentNode.appendChild(t)},nt.prototype.getContentPlayer=function(){return this.h5Player},nt.prototype.getVolume=function(){return this.vjsPlayer.muted()?0:this.vjsPlayer.volume()},nt.prototype.setVolume=function(t){this.vjsPlayer.volume(t),0==t?this.vjsPlayer.muted(!0):this.vjsPlayer.muted(!1)},nt.prototype.unmute=function(){this.vjsPlayer.muted(!1)},nt.prototype.mute=function(){this.vjsPlayer.muted(!0)},nt.prototype.play=function(){this.vjsPlayer.play()},nt.prototype.togglePlayback=function(){this.vjsPlayer.paused()?this.vjsPlayer.play():this.vjsPlayer.pause()},nt.prototype.getPlayerWidth=function(){var t=(getComputedStyle(this.vjsPlayer.el())||{}).width;return t&&0!==parseFloat(t)||(t=(this.vjsPlayer.el().getBoundingClientRect()||{}).width),parseFloat(t)||this.vjsPlayer.width()},nt.prototype.getPlayerHeight=function(){var t=(getComputedStyle(this.vjsPlayer.el())||{}).height;return t&&0!==parseFloat(t)||(t=(this.vjsPlayer.el().getBoundingClientRect()||{}).height),parseFloat(t)||this.vjsPlayer.height()},nt.prototype.getPlayerOptions=function(){return this.vjsPlayer.options_},nt.prototype.getPlayerId=function(){return this.vjsPlayer.id()},nt.prototype.toggleFullscreen=function(){this.vjsPlayer.isFullscreen()?this.vjsPlayer.exitFullscreen():this.vjsPlayer.requestFullscreen()},nt.prototype.getContentPlayheadTracker=function(){return this.contentPlayheadTracker},nt.prototype.onAdError=function(t){this.vjsControls.show();var e=void 0!==t.getError?t.getError():t.stack;this.vjsPlayer.trigger({type:"adserror",data:{AdError:e,AdErrorEvent:t}})},nt.prototype.onAdLog=function(t){var e=t.getAdData(),s=void 0!==e.adError?e.adError.getMessage():void 0;this.vjsPlayer.trigger({type:"adslog",data:{AdError:s,AdEvent:t}})},nt.prototype.onAdBreakStart=function(){this.contentSource=this.vjsPlayer.currentSrc(),this.contentSourceType=this.vjsPlayer.currentType(),this.vjsPlayer.off("readyforpostroll",this.boundContentEndedListener),this.vjsPlayer.ads.startLinearAdMode(),this.vjsControls.hide(),this.vjsPlayer.pause()},nt.prototype.onAdBreakEnd=function(){this.vjsPlayer.on("readyforpostroll",this.boundContentEndedListener),this.vjsPlayer.ads.inAdBreak()&&this.vjsPlayer.ads.endLinearAdMode(),this.vjsControls.show()},nt.prototype.onAdStart=function(){this.vjsPlayer.trigger("ads-ad-started")},nt.prototype.onAllAdsCompleted=function(){1==this.contentComplete&&(this.contentSource&&this.vjsPlayer.currentSrc()!=this.contentSource&&this.vjsPlayer.src({src:this.contentSource,type:this.contentSourceType}),this.controller.onContentAndAdsCompleted())},nt.prototype.onAdsReady=function(){this.vjsPlayer.trigger("adsready")},nt.prototype.changeSource=function(t){this.vjsPlayer.currentSrc()&&(this.vjsPlayer.currentTime(0),this.vjsPlayer.pause()),t&&this.vjsPlayer.src(t),this.vjsPlayer.one("loadedmetadata",this.seekContentToZero.bind(this))},nt.prototype.seekContentToZero=function(){this.vjsPlayer.currentTime(0)},nt.prototype.triggerPlayerEvent=function(t,e){this.vjsPlayer.trigger(t,e)},nt.prototype.addContentEndedListener=function(t){this.contentEndedListeners.push(t)},nt.prototype.reset=function(){this.vjsPlayer.off("readyforpostroll",this.boundContentEndedListener),this.vjsPlayer.on("readyforpostroll",this.boundContentEndedListener),this.vjsControls.show(),this.vjsPlayer.ads.inAdBreak()&&this.vjsPlayer.ads.endLinearAdMode(),this.contentPlayheadTracker.currentTime=0,this.contentComplete=!1};var at=function(t){this.controller=t,this.adContainerDiv=document.createElement("div"),this.controlsDiv=document.createElement("div"),this.countdownDiv=document.createElement("div"),this.seekBarDiv=document.createElement("div"),this.progressDiv=document.createElement("div"),this.playPauseDiv=document.createElement("div"),this.muteDiv=document.createElement("div"),this.sliderDiv=document.createElement("div"),this.sliderLevelDiv=document.createElement("div"),this.fullscreenDiv=document.createElement("div"),this.boundOnMouseUp=this.onMouseUp.bind(this),this.boundOnMouseMove=this.onMouseMove.bind(this),this.adPlayheadTracker={currentTime:0,duration:0,isPod:!1,adPosition:0,totalAds:0},this.controlPrefix=this.controller.getPlayerId()+"_",this.showCountdown=!0,!1===this.controller.getSettings().showCountdown&&(this.showCountdown=!1),this.isAdNonlinear=!1,this.createAdContainer()};at.prototype.createAdContainer=function(){this.assignControlAttributes(this.adContainerDiv,"ima-ad-container"),this.adContainerDiv.classList.add("hide-ad-container"),this.adContainerDiv.addEventListener("mouseenter",this.showAdControls.bind(this),!1),this.adContainerDiv.addEventListener("mouseleave",this.hideAdControls.bind(this),!1),this.adContainerDiv.addEventListener("click",this.onAdContainerClick.bind(this),!1),this.createControls(),this.controller.injectAdContainerDiv(this.adContainerDiv)},at.prototype.createControls=function(){this.assignControlAttributes(this.controlsDiv,"ima-controls-div"),this.controlsDiv.style.width="100%",this.controller.getIsMobile()?this.countdownDiv.style.display="none":(this.assignControlAttributes(this.countdownDiv,"ima-countdown-div"),this.countdownDiv.innerHTML=this.controller.getSettings().adLabel,this.countdownDiv.style.display=this.showCountdown?"block":"none"),this.assignControlAttributes(this.seekBarDiv,"ima-seek-bar-div"),this.seekBarDiv.style.width="100%",this.assignControlAttributes(this.progressDiv,"ima-progress-div"),this.assignControlAttributes(this.playPauseDiv,"ima-play-pause-div"),this.addClass(this.playPauseDiv,"ima-playing"),this.playPauseDiv.addEventListener("click",this.onAdPlayPauseClick.bind(this),!1),this.assignControlAttributes(this.muteDiv,"ima-mute-div"),this.addClass(this.muteDiv,"ima-non-muted"),this.muteDiv.addEventListener("click",this.onAdMuteClick.bind(this),!1),this.assignControlAttributes(this.sliderDiv,"ima-slider-div"),this.sliderDiv.addEventListener("mousedown",this.onAdVolumeSliderMouseDown.bind(this),!1),this.controller.getIsIos()&&(this.sliderDiv.style.display="none"),this.assignControlAttributes(this.sliderLevelDiv,"ima-slider-level-div"),this.assignControlAttributes(this.fullscreenDiv,"ima-fullscreen-div"),this.addClass(this.fullscreenDiv,"ima-non-fullscreen"),this.fullscreenDiv.addEventListener("click",this.onAdFullscreenClick.bind(this),!1),this.adContainerDiv.appendChild(this.controlsDiv),this.controlsDiv.appendChild(this.countdownDiv),this.controlsDiv.appendChild(this.seekBarDiv),this.controlsDiv.appendChild(this.playPauseDiv),this.controlsDiv.appendChild(this.muteDiv),this.controlsDiv.appendChild(this.sliderDiv),this.controlsDiv.appendChild(this.fullscreenDiv),this.seekBarDiv.appendChild(this.progressDiv),this.sliderDiv.appendChild(this.sliderLevelDiv)},at.prototype.onAdPlayPauseClick=function(){this.controller.onAdPlayPauseClick()},at.prototype.onAdMuteClick=function(){this.controller.onAdMuteClick()},at.prototype.onAdFullscreenClick=function(){this.controller.toggleFullscreen()},at.prototype.onAdsPaused=function(){this.controller.sdkImpl.adPlaying=!1,this.addClass(this.playPauseDiv,"ima-paused"),this.removeClass(this.playPauseDiv,"ima-playing"),this.showAdControls()},at.prototype.onAdsResumed=function(){this.onAdsPlaying(),this.showAdControls()},at.prototype.onAdsPlaying=function(){this.controller.sdkImpl.adPlaying=!0,this.addClass(this.playPauseDiv,"ima-playing"),this.removeClass(this.playPauseDiv,"ima-paused")},at.prototype.updateAdUi=function(t,e,s,i,r){var n=Math.floor(e/60),a=Math.floor(e%60);a.toString().length<2&&(a="0"+a);var o=": ";r>1&&(o=" ("+i+" "+this.controller.getSettings().adLabelNofN+" "+r+"): "),this.countdownDiv.innerHTML=this.controller.getSettings().adLabel+o+n+":"+a;var l=t/s*100;this.progressDiv.style.width=l+"%"},at.prototype.unmute=function(){this.addClass(this.muteDiv,"ima-non-muted"),this.removeClass(this.muteDiv,"ima-muted"),this.sliderLevelDiv.style.width=100*this.controller.getPlayerVolume()+"%"},at.prototype.mute=function(){this.addClass(this.muteDiv,"ima-muted"),this.removeClass(this.muteDiv,"ima-non-muted"),this.sliderLevelDiv.style.width="0%"},at.prototype.onAdVolumeSliderMouseDown=function(){document.addEventListener("mouseup",this.boundOnMouseUp,!1),document.addEventListener("mousemove",this.boundOnMouseMove,!1)},at.prototype.onMouseMove=function(t){this.changeVolume(t)},at.prototype.onMouseUp=function(t){this.changeVolume(t),document.removeEventListener("mouseup",this.boundOnMouseUp),document.removeEventListener("mousemove",this.boundOnMouseMove)},at.prototype.changeVolume=function(t){var e=(t.clientX-this.sliderDiv.getBoundingClientRect().left)/this.sliderDiv.offsetWidth;e*=100,e=Math.min(Math.max(e,0),100),this.sliderLevelDiv.style.width=e+"%",0==this.percent?(this.addClass(this.muteDiv,"ima-muted"),this.removeClass(this.muteDiv,"ima-non-muted")):(this.addClass(this.muteDiv,"ima-non-muted"),this.removeClass(this.muteDiv,"ima-muted")),this.controller.setVolume(e/100)},at.prototype.showAdContainer=function(){this.adContainerDiv.classList.remove("hide-ad-container")},at.prototype.hideAdContainer=function(){this.adContainerDiv.classList.add("hide-ad-container")},at.prototype.onAdContainerClick=function(){this.isAdNonlinear&&this.controller.togglePlayback()},at.prototype.reset=function(){this.hideAdContainer()},at.prototype.onAdError=function(){this.hideAdContainer()},at.prototype.onAdBreakStart=function(t){this.showAdContainer(),"application/javascript"!==t.getAd().getContentType()||this.controller.getSettings().showControlsForJSAds?this.controlsDiv.style.display="block":this.controlsDiv.style.display="none",this.onAdsPlaying(),this.hideAdControls()},at.prototype.onAdBreakEnd=function(){var t=this.controller.getCurrentAd();(null==t||t.isLinear())&&this.hideAdContainer(),this.controlsDiv.style.display="none",this.countdownDiv.innerHTML=""},at.prototype.onAllAdsCompleted=function(){this.hideAdContainer()},at.prototype.onLinearAdStart=function(){this.removeClass(this.adContainerDiv,"bumpable-ima-ad-container"),this.isAdNonlinear=!1},at.prototype.onNonLinearAdLoad=function(){this.addClass(this.adContainerDiv,"bumpable-ima-ad-container"),this.isAdNonlinear=!0},at.prototype.onPlayerEnterFullscreen=function(){this.addClass(this.fullscreenDiv,"ima-fullscreen"),this.removeClass(this.fullscreenDiv,"ima-non-fullscreen")},at.prototype.onPlayerExitFullscreen=function(){this.addClass(this.fullscreenDiv,"ima-non-fullscreen"),this.removeClass(this.fullscreenDiv,"ima-fullscreen")},at.prototype.onPlayerVolumeChanged=function(t){0==t?(this.addClass(this.muteDiv,"ima-muted"),this.removeClass(this.muteDiv,"ima-non-muted"),this.sliderLevelDiv.style.width="0%"):(this.addClass(this.muteDiv,"ima-non-muted"),this.removeClass(this.muteDiv,"ima-muted"),this.sliderLevelDiv.style.width=100*t+"%")},at.prototype.showAdControls=function(){this.controller.getSettings().disableAdControls||this.addClass(this.controlsDiv,"ima-controls-div-showing")},at.prototype.hideAdControls=function(){this.removeClass(this.controlsDiv,"ima-controls-div-showing")},at.prototype.assignControlAttributes=function(t,e){t.id=this.controlPrefix+e,t.className=this.controlPrefix+e+" "+e},at.prototype.getClassRegexp=function(t){return new RegExp("(^|[^A-Za-z-])"+t+"((?![A-Za-z-])|$)","gi")},at.prototype.elementHasClass=function(t,e){return this.getClassRegexp(e).test(t.className)},at.prototype.addClass=function(t,e){t.className=t.className.trim()+" "+e},at.prototype.removeClass=function(t,e){var s=this.getClassRegexp(e);t.className=t.className.trim().replace(s,"")},at.prototype.getAdContainerDiv=function(){return this.adContainerDiv},at.prototype.setShowCountdown=function(t){this.showCountdown=t,this.countdownDiv.style.display=this.showCountdown?"block":"none"};var ot=function(t){this.controller=t,this.adDisplayContainer=null,this.adDisplayContainerInitialized=!1,this.adsLoader=null,this.adsManager=null,this.adsRenderingSettings=null,this.adsResponse=null,this.currentAd=null,this.adTrackingTimer=null,this.allAdsCompleted=!1,this.adsActive=!1,this.adPlaying=!1,this.adMuted=!1,this.adBreakReadyListener=void 0,this.contentCompleteCalled=!1,this.isAdTimedOut=!1,this.adsManagerDimensions={width:0,height:0},this.autoPlayAdBreaks=!0,!1===this.controller.getSettings().autoPlayAdBreaks&&(this.autoPlayAdBreaks=!1),this.controller.getSettings().locale&&google.ima.settings.setLocale(this.controller.getSettings().locale),this.controller.getSettings().disableFlashAds&&google.ima.settings.setDisableFlashAds(this.controller.getSettings().disableFlashAds),this.controller.getSettings().disableCustomPlaybackForIOS10Plus&&google.ima.settings.setDisableCustomPlaybackForIOS10Plus(this.controller.getSettings().disableCustomPlaybackForIOS10Plus),this.controller.getSettings().ppid&&google.ima.settings.setPpid(this.controller.getSettings().ppid),this.controller.getSettings().featureFlags&&google.ima.settings.setFeatureFlags(this.controller.getSettings().featureFlags)};ot.prototype.initAdObjects=function(){this.adDisplayContainer=new google.ima.AdDisplayContainer(this.controller.getAdContainerDiv(),this.controller.getContentPlayer()),this.adsLoader=new google.ima.AdsLoader(this.adDisplayContainer),this.adsLoader.getSettings().setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.ENABLED),0==this.controller.getSettings().vpaidAllowed&&this.adsLoader.getSettings().setVpaidMode(google.ima.ImaSdkSettings.VpaidMode.DISABLED),void 0!==this.controller.getSettings().vpaidMode&&this.adsLoader.getSettings().setVpaidMode(this.controller.getSettings().vpaidMode),this.controller.getSettings().locale&&this.adsLoader.getSettings().setLocale(this.controller.getSettings().locale),this.controller.getSettings().numRedirects&&this.adsLoader.getSettings().setNumRedirects(this.controller.getSettings().numRedirects),this.controller.getSettings().sessionId&&this.adsLoader.getSettings().setSessionId(this.controller.getSettings().sessionId),this.adsLoader.getSettings().setPlayerType("videojs-ima"),this.adsLoader.getSettings().setPlayerVersion("2.5.0"),this.adsLoader.getSettings().setAutoPlayAdBreaks(this.autoPlayAdBreaks),this.adsLoader.addEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,this.onAdsManagerLoaded.bind(this),!1),this.adsLoader.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdsLoaderError.bind(this),!1),this.controller.playerWrapper.vjsPlayer.trigger({type:"ads-loader",adsLoader:this.adsLoader})},ot.prototype.requestAds=function(){var t=new google.ima.AdsRequest;if(this.controller.getSettings().adTagUrl?t.adTagUrl=this.controller.getSettings().adTagUrl:t.adsResponse=this.controller.getSettings().adsResponse,this.controller.getSettings().forceNonLinearFullSlot&&(t.forceNonLinearFullSlot=!0),this.controller.getSettings().vastLoadTimeout&&(t.vastLoadTimeout=this.controller.getSettings().vastLoadTimeout),this.controller.getSettings().omidMode&&window.console.warn("The additional setting `omidMode` has been removed. Use `omidVendorAccess` instead."),this.controller.getSettings().omidVendorAccess){t.omidAccessModeRules={};var e=this.controller.getSettings().omidVendorAccess;Object.keys(e).forEach(function(s){t.omidAccessModeRules[s]=e[s]})}t.linearAdSlotWidth=this.controller.getPlayerWidth(),t.linearAdSlotHeight=this.controller.getPlayerHeight(),t.nonLinearAdSlotWidth=this.controller.getSettings().nonLinearWidth||this.controller.getPlayerWidth(),t.nonLinearAdSlotHeight=this.controller.getSettings().nonLinearHeight||this.controller.getPlayerHeight(),t.setAdWillAutoPlay(this.controller.adsWillAutoplay()),t.setAdWillPlayMuted(this.controller.adsWillPlayMuted());var s=this.controller.getSettings().adsRequest;s&&"object"===rt(s)&&Object.keys(s).forEach(function(e){t[e]=s[e]}),this.adsLoader.requestAds(t),this.controller.playerWrapper.vjsPlayer.trigger({type:"ads-request",AdsRequest:t})},ot.prototype.onAdsManagerLoaded=function(t){this.createAdsRenderingSettings(),this.adsManager=t.getAdsManager(this.controller.getContentPlayheadTracker(),this.adsRenderingSettings),this.adsManager.addEventListener(google.ima.AdErrorEvent.Type.AD_ERROR,this.onAdError.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.AD_BREAK_READY,this.onAdBreakReady.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,this.onContentPauseRequested.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,this.onContentResumeRequested.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.ALL_ADS_COMPLETED,this.onAllAdsCompleted.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.LOADED,this.onAdLoaded.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.STARTED,this.onAdStarted.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.COMPLETE,this.onAdComplete.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.SKIPPED,this.onAdComplete.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.LOG,this.onAdLog.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.PAUSED,this.onAdPaused.bind(this)),this.adsManager.addEventListener(google.ima.AdEvent.Type.RESUMED,this.onAdResumed.bind(this)),this.controller.playerWrapper.vjsPlayer.trigger({type:"ads-manager",adsManager:this.adsManager}),this.autoPlayAdBreaks||this.initAdsManager();var e=this.controller.getSettings().preventLateAdStart;e?e&&!this.isAdTimedOut&&this.controller.onAdsReady():this.controller.onAdsReady(),this.controller.getSettings().adsManagerLoadedCallback&&this.controller.getSettings().adsManagerLoadedCallback()},ot.prototype.onAdsLoaderError=function(t){window.console.warn("AdsLoader error: "+t.getError()),this.controller.onErrorLoadingAds(t),this.adsManager&&this.adsManager.destroy()},ot.prototype.initAdsManager=function(){try{var t=this.controller.getPlayerWidth(),e=this.controller.getPlayerHeight();this.adsManagerDimensions.width=t,this.adsManagerDimensions.height=e,this.adsManager.init(t,e),this.adsManager.setVolume(this.controller.getPlayerVolume()),this.initializeAdDisplayContainer()}catch(t){this.onAdError(t)}},ot.prototype.createAdsRenderingSettings=function(){if(this.adsRenderingSettings=new google.ima.AdsRenderingSettings,this.adsRenderingSettings.restoreCustomPlaybackStateOnAdBreakComplete=!0,this.controller.getSettings().adsRenderingSettings)for(var t in this.controller.getSettings().adsRenderingSettings)""!==t&&(this.adsRenderingSettings[t]=this.controller.getSettings().adsRenderingSettings[t])},ot.prototype.onAdError=function(t){var e=void 0!==t.getError?t.getError():t.stack;window.console.warn("Ad error: "+e),this.adsManager.destroy(),this.controller.onAdError(t),this.adsActive=!1,this.adPlaying=!1},ot.prototype.onAdBreakReady=function(t){this.adBreakReadyListener(t)},ot.prototype.onContentPauseRequested=function(t){this.adsActive=!0,this.adPlaying=!0,this.controller.onAdBreakStart(t)},ot.prototype.onContentResumeRequested=function(t){this.adsActive=!1,this.adPlaying=!1,this.controller.onAdBreakEnd()},ot.prototype.onAllAdsCompleted=function(t){this.allAdsCompleted=!0,this.controller.onAllAdsCompleted()},ot.prototype.onAdLoaded=function(t){t.getAd().isLinear()||(this.controller.onNonLinearAdLoad(),this.controller.playContent())},ot.prototype.onAdStarted=function(t){this.currentAd=t.getAd(),this.currentAd.isLinear()?(this.adTrackingTimer=setInterval(this.onAdPlayheadTrackerInterval.bind(this),250),this.controller.onLinearAdStart()):this.controller.onNonLinearAdStart()},ot.prototype.onAdPaused=function(){this.controller.onAdsPaused()},ot.prototype.onAdResumed=function(t){this.controller.onAdsResumed()},ot.prototype.onAdComplete=function(){this.currentAd.isLinear()&&clearInterval(this.adTrackingTimer)},ot.prototype.onAdLog=function(t){this.controller.onAdLog(t)},ot.prototype.onAdPlayheadTrackerInterval=function(){if(null!==this.adsManager){var t=this.adsManager.getRemainingTime(),e=this.currentAd.getDuration(),s=e-t;s=s>0?s:0;var i,r=0;this.currentAd.getAdPodInfo()&&(i=this.currentAd.getAdPodInfo().getAdPosition(),r=this.currentAd.getAdPodInfo().getTotalAds()),this.controller.onAdPlayheadUpdated(s,t,e,i,r)}},ot.prototype.onContentComplete=function(){this.adsLoader&&(this.adsLoader.contentComplete(),this.contentCompleteCalled=!0),(this.adsManager&&this.adsManager.getCuePoints()&&!this.adsManager.getCuePoints().includes(-1)||!this.adsManager)&&this.controller.onNoPostroll(),this.allAdsCompleted&&this.controller.onContentAndAdsCompleted()},ot.prototype.onPlayerDisposed=function(){this.adTrackingTimer&&clearInterval(this.adTrackingTimer),this.adsManager&&(this.adsManager.destroy(),this.adsManager=null)},ot.prototype.onPlayerReadyForPreroll=function(){if(this.autoPlayAdBreaks){this.initAdsManager();try{this.controller.showAdContainer(),this.adsManager.setVolume(this.controller.getPlayerVolume()),this.adsManager.start()}catch(t){this.onAdError(t)}}},ot.prototype.onAdTimeout=function(){this.isAdTimedOut=!0},ot.prototype.onPlayerReady=function(){this.initAdObjects(),(this.controller.getSettings().adTagUrl||this.controller.getSettings().adsResponse)&&"onLoad"===this.controller.getSettings().requestMode&&this.requestAds()},ot.prototype.onPlayerEnterFullscreen=function(){this.adsManager&&this.adsManager.resize(window.screen.width,window.screen.height)},ot.prototype.onPlayerExitFullscreen=function(){this.adsManager&&this.adsManager.resize(this.controller.getPlayerWidth(),this.controller.getPlayerHeight())},ot.prototype.onPlayerVolumeChanged=function(t){this.adsManager&&this.adsManager.setVolume(t),this.adMuted=0==t},ot.prototype.onPlayerResize=function(t,e){this.adsManager&&(this.adsManagerDimensions.width=t,this.adsManagerDimensions.height=e,this.adsManager.resize(t,e))},ot.prototype.getCurrentAd=function(){return this.currentAd},ot.prototype.setAdBreakReadyListener=function(t){this.adBreakReadyListener=t},ot.prototype.isAdPlaying=function(){return this.adPlaying},ot.prototype.isAdMuted=function(){return this.adMuted},ot.prototype.pauseAds=function(){this.adsManager.pause(),this.adPlaying=!1},ot.prototype.resumeAds=function(){this.adsManager.resume(),this.adPlaying=!0},ot.prototype.unmute=function(){this.adsManager.setVolume(1),this.adMuted=!1},ot.prototype.mute=function(){this.adsManager.setVolume(0),this.adMuted=!0},ot.prototype.setVolume=function(t){this.adsManager.setVolume(t),this.adMuted=0==t},ot.prototype.initializeAdDisplayContainer=function(){this.adDisplayContainer&&(this.adDisplayContainerInitialized||(this.adDisplayContainer.initialize(),this.adDisplayContainerInitialized=!0))},ot.prototype.playAdBreak=function(){this.autoPlayAdBreaks||(this.controller.showAdContainer(),this.adsManager.setVolume(this.controller.getPlayerVolume()),this.adsManager.start())},ot.prototype.addEventListener=function(t,e){this.adsManager&&this.adsManager.addEventListener(t,e)},ot.prototype.getAdsManager=function(){return this.adsManager},ot.prototype.reset=function(){this.adsActive=!1,this.adPlaying=!1,this.adTrackingTimer&&clearInterval(this.adTrackingTimer),this.adsManager&&(this.adsManager.destroy(),this.adsManager=null),this.adsLoader&&!this.contentCompleteCalled&&this.adsLoader.contentComplete(),this.contentCompleteCalled=!1,this.allAdsCompleted=!1};var lt=function(t,e){this.settings={},this.contentAndAdsEndedListeners=[],this.isMobile=navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/Android/i),this.isIos=navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i),this.initWithSettings(e);var s={debug:this.settings.debug,timeout:this.settings.timeout,prerollTimeout:this.settings.prerollTimeout},i=Object.assign({},s,e.contribAdsSettings||{});this.playerWrapper=new nt(t,i,this),this.adUi=new at(this),this.sdkImpl=new ot(this)};lt.IMA_DEFAULTS={adLabel:"Advertisement",adLabelNofN:"of",debug:!1,disableAdControls:!1,prerollTimeout:1e3,preventLateAdStart:!1,requestMode:"onLoad",showControlsForJSAds:!0,timeout:5e3},lt.prototype.initWithSettings=function(t){this.settings=Object.assign({},lt.IMA_DEFAULTS,t||{}),this.warnAboutDeprecatedSettings(),this.showCountdown=!0,!1===this.settings.showCountdown&&(this.showCountdown=!1)},lt.prototype.warnAboutDeprecatedSettings=function(){var t=this;["adWillAutoplay","adsWillAutoplay","adWillPlayMuted","adsWillPlayMuted"].forEach(function(e){void 0!==t.settings[e]&&console.warn("WARNING: videojs.ima setting "+e+" is deprecated")})},lt.prototype.getSettings=function(){return this.settings},lt.prototype.getIsMobile=function(){return this.isMobile},lt.prototype.getIsIos=function(){return this.isIos},lt.prototype.injectAdContainerDiv=function(t){this.playerWrapper.injectAdContainerDiv(t)},lt.prototype.getAdContainerDiv=function(){return this.adUi.getAdContainerDiv()},lt.prototype.getContentPlayer=function(){return this.playerWrapper.getContentPlayer()},lt.prototype.getContentPlayheadTracker=function(){return this.playerWrapper.getContentPlayheadTracker()},lt.prototype.requestAds=function(){this.sdkImpl.requestAds()},lt.prototype.setSetting=function(t,e){this.settings[t]=e},lt.prototype.onErrorLoadingAds=function(t){this.adUi.onAdError(),this.playerWrapper.onAdError(t)},lt.prototype.onAdPlayPauseClick=function(){this.sdkImpl.isAdPlaying()?(this.adUi.onAdsPaused(),this.sdkImpl.pauseAds()):(this.adUi.onAdsPlaying(),this.sdkImpl.resumeAds())},lt.prototype.onAdMuteClick=function(){this.sdkImpl.isAdMuted()?(this.playerWrapper.unmute(),this.adUi.unmute(),this.sdkImpl.unmute()):(this.playerWrapper.mute(),this.adUi.mute(),this.sdkImpl.mute())},lt.prototype.setVolume=function(t){this.playerWrapper.setVolume(t),this.sdkImpl.setVolume(t)},lt.prototype.getPlayerVolume=function(){return this.playerWrapper.getVolume()},lt.prototype.toggleFullscreen=function(){this.playerWrapper.toggleFullscreen()},lt.prototype.onAdError=function(t){this.adUi.onAdError(),this.playerWrapper.onAdError(t)},lt.prototype.onAdBreakStart=function(t){this.playerWrapper.onAdBreakStart(),this.adUi.onAdBreakStart(t)},lt.prototype.showAdContainer=function(){this.adUi.showAdContainer()},lt.prototype.onAdBreakEnd=function(){this.playerWrapper.onAdBreakEnd(),this.adUi.onAdBreakEnd()},lt.prototype.onAllAdsCompleted=function(){this.adUi.onAllAdsCompleted(),this.playerWrapper.onAllAdsCompleted()},lt.prototype.onAdsPaused=function(){this.adUi.onAdsPaused()},lt.prototype.onAdsResumed=function(){this.adUi.onAdsResumed()},lt.prototype.onAdPlayheadUpdated=function(t,e,s,i,r){this.adUi.updateAdUi(t,e,s,i,r)},lt.prototype.onAdLog=function(t){this.playerWrapper.onAdLog(t)},lt.prototype.getCurrentAd=function(){return this.sdkImpl.getCurrentAd()},lt.prototype.playContent=function(){this.playerWrapper.play()},lt.prototype.onLinearAdStart=function(){this.adUi.onLinearAdStart(),this.playerWrapper.onAdStart()},lt.prototype.onNonLinearAdLoad=function(){this.adUi.onNonLinearAdLoad()},lt.prototype.onNonLinearAdStart=function(){this.adUi.onNonLinearAdLoad(),this.playerWrapper.onAdStart()},lt.prototype.getPlayerWidth=function(){return this.playerWrapper.getPlayerWidth()},lt.prototype.getPlayerHeight=function(){return this.playerWrapper.getPlayerHeight()},lt.prototype.onAdsReady=function(){this.playerWrapper.onAdsReady()},lt.prototype.onPlayerResize=function(t,e){this.sdkImpl.onPlayerResize(t,e)},lt.prototype.onContentComplete=function(){this.sdkImpl.onContentComplete()},lt.prototype.onNoPostroll=function(){this.playerWrapper.onNoPostroll()},lt.prototype.onContentAndAdsCompleted=function(){for(var t in this.contentAndAdsEndedListeners)"function"==typeof this.contentAndAdsEndedListeners[t]&&this.contentAndAdsEndedListeners[t]()},lt.prototype.onPlayerDisposed=function(){this.contentAndAdsEndedListeners=[],this.sdkImpl.onPlayerDisposed()},lt.prototype.onPlayerReadyForPreroll=function(){this.sdkImpl.onPlayerReadyForPreroll()},lt.prototype.onAdTimeout=function(){this.sdkImpl.onAdTimeout()},lt.prototype.onPlayerReady=function(){this.sdkImpl.onPlayerReady()},lt.prototype.onPlayerEnterFullscreen=function(){this.adUi.onPlayerEnterFullscreen(),this.sdkImpl.onPlayerEnterFullscreen()},lt.prototype.onPlayerExitFullscreen=function(){this.adUi.onPlayerExitFullscreen(),this.sdkImpl.onPlayerExitFullscreen()},lt.prototype.onPlayerVolumeChanged=function(t){this.adUi.onPlayerVolumeChanged(t),this.sdkImpl.onPlayerVolumeChanged(t)},lt.prototype.setContentWithAdTag=function(t,e){this.reset(),this.settings.adTagUrl=e||this.settings.adTagUrl,this.playerWrapper.changeSource(t)},lt.prototype.setContentWithAdsResponse=function(t,e){this.reset(),this.settings.adsResponse=e||this.settings.adsResponse,this.playerWrapper.changeSource(t)},lt.prototype.setContentWithAdsRequest=function(t,e){this.reset(),this.settings.adsRequest=e||this.settings.adsRequest,this.playerWrapper.changeSource(t)},lt.prototype.reset=function(){this.sdkImpl.reset(),this.playerWrapper.reset(),this.adUi.reset()},lt.prototype.addContentEndedListener=function(t){this.playerWrapper.addContentEndedListener(t)},lt.prototype.addContentAndAdsEndedListener=function(t){this.contentAndAdsEndedListeners.push(t)},lt.prototype.setAdBreakReadyListener=function(t){this.sdkImpl.setAdBreakReadyListener(t)},lt.prototype.setShowCountdown=function(t){this.adUi.setShowCountdown(t),this.showCountdown=t,this.adUi.countdownDiv.style.display=this.showCountdown?"block":"none"},lt.prototype.initializeAdDisplayContainer=function(){this.sdkImpl.initializeAdDisplayContainer()},lt.prototype.playAdBreak=function(){this.sdkImpl.playAdBreak()},lt.prototype.addEventListener=function(t,e){this.sdkImpl.addEventListener(t,e)},lt.prototype.getAdsManager=function(){return this.sdkImpl.getAdsManager()},lt.prototype.getPlayerId=function(){return this.playerWrapper.getPlayerId()},lt.prototype.changeAdTag=function(t){this.reset(),this.settings.adTagUrl=t},lt.prototype.pauseAd=function(){this.adUi.onAdsPaused(),this.sdkImpl.pauseAds()},lt.prototype.resumeAd=function(){this.adUi.onAdsPlaying(),this.sdkImpl.resumeAds()},lt.prototype.togglePlayback=function(){this.playerWrapper.togglePlayback()},lt.prototype.adsWillAutoplay=function(){return void 0!==this.settings.adsWillAutoplay?this.settings.adsWillAutoplay:void 0!==this.settings.adWillAutoplay?this.settings.adWillAutoplay:!!this.playerWrapper.getPlayerOptions().autoplay},lt.prototype.adsWillPlayMuted=function(){return void 0!==this.settings.adsWillPlayMuted?this.settings.adsWillPlayMuted:void 0!==this.settings.adWillPlayMuted?this.settings.adWillPlayMuted:void 0!==this.playerWrapper.getPlayerOptions().muted?this.playerWrapper.getPlayerOptions().muted:0==this.playerWrapper.getVolume()},lt.prototype.triggerPlayerEvent=function(t,e){this.playerWrapper.triggerPlayerEvent(t,e)};var ht=function(t,e,s){this.vjsPlayer=t,this.daiController=s,this.vjsControls=this.vjsPlayer.getChild("controlBar"),this.h5Player=null,this.vjsPlayer.on("dispose",this.playerDisposedListener.bind(this)),this.vjsPlayer.on("pause",this.onPause.bind(this)),this.vjsPlayer.on("play",this.onPlay.bind(this)),this.vjsPlayer.on("seeked",this.onSeekEnd.bind(this)),this.vjsPlayer.ready(this.onPlayerReady.bind(this)),this.vjsPlayer.ads||window.console.warn("You may be using a version of videojs-contrib-ads that is not compatible with your version of video.js."),this.vjsPlayer.ads(e)};ht.prototype.playerDisposedListener=function(){this.contentEndedListeners=[],this.daiController.onPlayerDisposed()},ht.prototype.onPause=function(){this.daiController.isInAdBreak()&&this.vjsControls.show()},ht.prototype.onPlay=function(){this.daiController.isInAdBreak()&&this.vjsControls.hide()},ht.prototype.onSeekEnd=function(){this.daiController.onSeekEnd(this.vjsPlayer.currentTime())},ht.prototype.onPlayerReady=function(){this.h5Player=document.getElementById(this.getPlayerId()).getElementsByClassName("vjs-tech")[0],this.daiController.onPlayerReady()},ht.prototype.getStreamPlayer=function(){return this.h5Player},ht.prototype.getVjsPlayer=function(){return this.vjsPlayer},ht.prototype.getPlayerOptions=function(){return this.vjsPlayer.options_},ht.prototype.getPlayerId=function(){return this.vjsPlayer.id()},ht.prototype.onAdError=function(t){this.vjsControls.show();var e=void 0!==t.getError?t.getError():t.stack;this.vjsPlayer.trigger({type:"adserror",data:{AdError:e,AdErrorEvent:t}})},ht.prototype.onAdBreakStart=function(){this.vjsControls.hide()},ht.prototype.onAdBreakEnd=function(){this.vjsControls.show()},ht.prototype.reset=function(){this.vjsControls.show()};var ct=function(t){this.daiController=t,this.streamPlayer=null,this.vjsPlayer=null,this.streamManager=null,this.uiSettings=new google.ima.dai.api.UiSettings,this.isAdBreak=!1,this.isSnapback=!1,this.snapForwardTime=0,this.timedMetadata,this.metadataLoaded={},this.SOURCE_TYPES={hls:"application/x-mpegURL",dash:"application/dash+xml"}};ct.prototype.initImaDai=function(){var t=this;this.streamPlayer=this.daiController.getStreamPlayer(),this.vjsPlayer=this.daiController.getVjsPlayer(),this.createAdUiDiv(),this.daiController.getSettings().locale&&this.uiSettings.setLocale(this.daiController.getSettings().locale),this.streamManager=new google.ima.dai.api.StreamManager(this.streamPlayer,this.adUiDiv,this.uiSettings),this.streamPlayer.addEventListener("pause",this.onStreamPause),this.streamPlayer.addEventListener("play",this.onStreamPlay),[google.ima.dai.api.StreamEvent.Type.LOADED,google.ima.dai.api.StreamEvent.Type.ERROR,google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED,google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED].forEach(function(e){t.streamManager.addEventListener(e,t.onStreamEvent.bind(t))}),this.vjsPlayer.textTracks().onaddtrack=this.onAddTrack.bind(this),this.vjsPlayer.trigger({type:"stream-manager",StreamManager:this.streamManager}),this.requestStream()},ct.prototype.onAddTrack=function(t){var e=this,s=t.track;"metadata"===s.kind&&(s.mode="hidden",s.addEventListener("cuechange",function(t){var i,r=function(t,e){var s="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!s){if(Array.isArray(t)||(s=function(t,e){if(t){if("string"==typeof t)return et(t,e);var s={}.toString.call(t).slice(8,-1);return"Object"===s&&t.constructor&&(s=t.constructor.name),"Map"===s||"Set"===s?Array.from(t):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?et(t,e):void 0}}(t))||e){s&&(t=s);var i=0,r=function(){};return{s:r,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var n,a=!0,o=!1;return{s:function(){s=s.call(t)},n:function(){var t=s.next();return a=t.done,t},e:function(t){o=!0,n=t},f:function(){try{a||null==s.return||s.return()}finally{if(o)throw n}}}}(s.activeCues);try{for(r.s();!(i=r.n()).done;){var n=i.value,a={};a[n.value.key]=n.value.data,e.streamManager.onTimedMetadata(a)}}catch(t){r.e(t)}finally{r.f()}}))},ct.prototype.createAdUiDiv=function(){var t=document.createElement("div");t.id="ad-ui",t.style.height="calc(100% - 3em)",this.streamPlayer.parentNode.appendChild(t),this.adUiDiv=t},ct.prototype.onStreamPause=function(){this.isAdBreak&&(this.adUiDiv.style.display="none")},ct.prototype.onStreamPlay=function(){this.isAdBreak&&(this.adUiDiv.style.display="block")},ct.prototype.onSeekEnd=function(t){if("live"!==this.daiController.getSettings().streamType)if(this.isSnapback)this.isSnapback=!1;else{var e=this.streamManager.previousCuePointForStreamTime(t);e&&!e.played&&(this.isSnapback=!0,this.snapForwardTime=t,this.vjsPlayer.currentTime(e.start))}},ct.prototype.onStreamEvent=function(t){switch(t.type){case google.ima.dai.api.StreamEvent.Type.LOADED:this.loadUrl(t.getStreamData().url);break;case google.ima.dai.api.StreamEvent.Type.ERROR:window.console.warn("Error loading stream, attempting to play backup stream. "+t.getStreamData().errorMessage),this.daiController.onErrorLoadingAds(t),this.daiController.getSettings().fallbackStreamUrl&&this.loadUrl(this.daiController.getSettings().fallbackStreamUrl);break;case google.ima.dai.api.StreamEvent.Type.AD_BREAK_STARTED:this.isAdBreak=!0,this.adUiDiv.style.display="block",this.daiController.onAdBreakStart();break;case google.ima.dai.api.StreamEvent.Type.AD_BREAK_ENDED:this.isAdBreak=!1,this.adUiDiv.style.display="none",this.daiController.onAdBreakEnd(),this.snapForwardTime&&this.snapForwardTime>this.vjsPlayer.currentTime()&&(this.vjsPlayer.currentTime(this.snapForwardTime),this.snapForwardTime=0)}},ct.prototype.loadUrl=function(t){this.vjsPlayer.ready(function(){var e=this.daiController.getSettings().streamFormat;this.vjsPlayer.src({src:t,type:this.SOURCE_TYPES[e]});var s=this.daiController.getSettings().bookmarkTime;if(s){var i=this.streamManager.streamTimeForContentTime(s);this.isSnapback=!0,this.vjsPlayer.currentTime(i)}}.bind(this))},ct.prototype.requestStream=function(){var t,e=this.daiController.getSettings().streamType;if("vod"===e?((t=new google.ima.dai.api.VODStreamRequest).contentSourceId=this.daiController.getSettings().cmsId,t.videoId=this.daiController.getSettings().videoId):"live"===e?(t=new google.ima.dai.api.LiveStreamRequest).assetKey=this.daiController.getSettings().assetKey:window.console.warn("No valid stream type selected"),t.format=this.daiController.getSettings().streamFormat,this.daiController.getSettings().apiKey&&(t.apiKey=this.daiController.getSettings().apiKey),this.daiController.getSettings().authToken&&(t.authToken=this.daiController.getSettings().authToken),this.daiController.getSettings().adTagParameters&&(t.adTagParameters=this.daiController.getSettings().adTagParameters),this.daiController.getSettings().streamActivityMonitorId&&(t.streamActivityMonitorId=this.daiController.getSettings().streamActivityMonitorId),this.daiController.getSettings().omidMode){t.omidAccessModeRules={};var s=this.daiController.getSettings().omidMode;s.FULL&&(t.omidAccessModeRules[google.ima.OmidAccessMode.FULL]=s.FULL),s.DOMAIN&&(t.omidAccessModeRules[google.ima.OmidAccessMode.DOMAIN]=s.DOMAIN),s.LIMITED&&(t.omidAccessModeRules[google.ima.OmidAccessMode.LIMITED]=s.LIMITED)}this.streamManager.requestStream(t),this.vjsPlayer.trigger({type:"stream-request",StreamRequest:t})},ct.prototype.onPlayerReady=function(){this.initImaDai()},ct.prototype.onPlayerDisposed=function(){this.streamManager&&this.streamManager.reset()},ct.prototype.addEventListener=function(t,e){this.streamManager&&this.streamManager.addEventListener(t,e)},ct.prototype.getStreamManager=function(){return this.streamManager},ct.prototype.reset=function(){this.streamManager&&this.streamManager.reset()};var dt=function(t,e){this.inAdBreak=!1,this.settings={},this.isMobile=navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)||navigator.userAgent.match(/Android/i),this.isIos=navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i),this.initWithSettings(e);var s={debug:this.settings.debug,timeout:this.settings.timeout,prerollTimeout:this.settings.prerollTimeout},i=Object.assign({},s,e.contribAdsSettings||{});this.playerWrapper=new ht(t,i,this),this.sdkImpl=new ct(this)};dt.IMA_DEFAULTS={adLabel:"Advertisement",adLabelNofN:"of",debug:!1,disableAdControls:!1,showControlsForJSAds:!0},dt.prototype.initWithSettings=function(t){this.settings=Object.assign({},dt.IMA_DEFAULTS,t||{}),this.warnAboutDeprecatedSettings(),this.showCountdown=!0,!1===this.settings.showCountdown&&(this.showCountdown=!1)},dt.prototype.warnAboutDeprecatedSettings=function(){var t=this;[].forEach(function(e){void 0!==t.settings[e]&&console.warn("WARNING: videojs.imaDai setting "+e+" is deprecated")})},dt.prototype.getSettings=function(){return this.settings},dt.prototype.getIsMobile=function(){return this.isMobile},dt.prototype.getIsIos=function(){return this.isIos},dt.prototype.getStreamPlayer=function(){return this.playerWrapper.getStreamPlayer()},dt.prototype.getVjsPlayer=function(){return this.playerWrapper.getVjsPlayer()},dt.prototype.requestStream=function(){this.sdkImpl.requestStream()},dt.prototype.setSetting=function(t,e){this.settings[t]=e},dt.prototype.onErrorLoadingAds=function(t){this.playerWrapper.onAdError(t)},dt.prototype.onAdError=function(t){this.playerWrapper.onAdError(t)},dt.prototype.onAdBreakStart=function(){this.inAdBreak=!0,this.playerWrapper.onAdBreakStart()},dt.prototype.onAdBreakEnd=function(){this.inAdBreak=!1,this.playerWrapper.onAdBreakEnd()},dt.prototype.onPlayerDisposed=function(){this.contentAndAdsEndedListeners=[],this.sdkImpl.onPlayerDisposed()},dt.prototype.isInAdBreak=function(){return this.inAdBreak},dt.prototype.onSeekEnd=function(t){this.sdkImpl.onSeekEnd(t)},dt.prototype.onPlayerReady=function(){this.sdkImpl.onPlayerReady()},dt.prototype.reset=function(){this.sdkImpl.reset(),this.playerWrapper.reset()},dt.prototype.addEventListener=function(t,e){this.sdkImpl.addEventListener(t,e)},dt.prototype.getStreamManager=function(){return this.sdkImpl.getStreamManager()},dt.prototype.getPlayerId=function(){return this.playerWrapper.getPlayerId()},dt.prototype.streamWillAutoplay=function(){return void 0!==this.settings.streamWillAutoplay?this.settings.streamWillAutoplay:!!this.playerWrapper.getPlayerOptions().autoplay},dt.prototype.triggerPlayerEvent=function(t,e){this.playerWrapper.triggerPlayerEvent(t,e)};var ut=function(t,e){this.controller=new lt(t,e),this.addContentAndAdsEndedListener=function(t){this.controller.addContentAndAdsEndedListener(t)}.bind(this),this.addContentEndedListener=function(t){this.controller.addContentEndedListener(t)}.bind(this),this.addEventListener=function(t,e){this.controller.addEventListener(t,e)}.bind(this),this.changeAdTag=function(t){this.controller.changeAdTag(t)}.bind(this),this.getAdsManager=function(){return this.controller.getAdsManager()}.bind(this),this.initializeAdDisplayContainer=function(){this.controller.initializeAdDisplayContainer()}.bind(this),this.pauseAd=function(){this.controller.pauseAd()}.bind(this),this.playAdBreak=function(){this.controller.playAdBreak()}.bind(this),this.requestAds=function(){this.controller.requestAds()}.bind(this),this.resumeAd=function(){this.controller.resumeAd()}.bind(this),this.setAdBreakReadyListener=function(t){this.controller.setAdBreakReadyListener(t)}.bind(this),this.setContentWithAdTag=function(t,e){this.controller.setContentWithAdTag(t,e)}.bind(this),this.setContentWithAdsResponse=function(t,e){this.controller.setContentWithAdsResponse(t,e)}.bind(this),this.setContentWithAdsRequest=function(t,e){this.controller.setContentWithAdsRequest(t,e)}.bind(this),this.setShowCountdown=function(t){this.controller.setShowCountdown(t)}.bind(this)},pt=function(t,e){this.controller=new dt(t,e),this.streamEndedListener=function(t){this.controller.addStreamEndedListener(t)}.bind(this),this.addEventListener=function(t,e){this.controller.addEventListener(t,e)}.bind(this),this.getStreamManager=function(){return this.controller.getStreamManager()}.bind(this)},ft=it(function t(e,s){st(this,t),"hls"===(e=e.toLowerCase())||"dash"===e?"dash"!==e?"string"==typeof s?(this.streamFormat=e,this.assetKey=s):window.console.error("assetKey error: value must be string."):window.console.error("streamFormat error: DASH streams are notcurrently supported by this plugin."):window.console.error("VodStream error: incorrect streamFormat.")}),gt=it(function t(e,s,i){st(this,t),"hls"===(e=e.toLowerCase())||"dash"===e?"dash"!==e?"string"==typeof s?"string"==typeof i?(this.streamFormat=e,this.cmsId=s,this.videoId=i):window.console.error("videoId error: value must be string."):window.console.error("cmsId error: value must be string."):window.console.error("streamFormat error: DASH streams are notcurrently supported by this plugin."):window.console.error("VodStream error: incorrect streamFormat.")}),mt=r().registerPlugin||r().plugin;mt("ima",function(t){this.ima=new ut(this,t)}),mt("imaDai",function(t,e){if(t instanceof ft)e.streamType="live",e.assetKey=t.assetKey;else{if(!(t instanceof gt))return void window.console.error("initDai() first parameter must be an instance of LiveStream or VodStream.");e.streamType="vod",e.cmsId=t.cmsId,e.videoId=t.videoId}e.streamFormat=t.streamFormat,this.imaDai=new pt(this,e)})},9017:(t,e,s)=>{s.d(e,{F0:()=>a,Fg:()=>n,IT:()=>o,T$:()=>h,Vv:()=>c,Yx:()=>l,be:()=>r,q3:()=>d,sb:()=>i});const i="cld-ia-layout-state",r="vp-ia",n="interaction-areas-container",a={PORTRAIT:"portrait",LANDSCAPE:"landscape",All:"all",CENTER:"center"},o={PULSING:"pulsing",SHADOWED:"shadowed"},l={[a.PORTRAIT]:"https://res.cloudinary.com/prod/raw/upload/v1623772481/video-player/vtts/portrait.vtt",[a.LANDSCAPE]:"https://res.cloudinary.com/prod/raw/upload/v1623772303/video-player/vtts/landscape.vtt",[a.All]:"https://res.cloudinary.com/prod/raw/upload/v1623250266/video-player/vtts/all.vtt",[a.CENTER]:"https://res.cloudinary.com/prod/raw/upload/v1623250265/video-player/vtts/center.vtt"},h="https://res.cloudinary.com/prod/image/upload/v1626764643/video-player/interaction-area-hand.svg",c=4500,d=250},1066:(t,e,s)=>{s.d(e,{interactionAreasService:()=>C});var i=s(6673),r=s.n(i),n=s(2832),a=s.n(n),o=s(2858),l=s.n(o),h=s(5114),c=s.n(h),d=s(9017),u=s(7134),p=s(9454);const f=t=>{let{text:e,onClick:s,theme:i="",loadingDelay:r=0}=t;return(0,u.It)({tag:"button",attr:{class:`vp-theme-button theme-${i}`},onClick:s,children:[{tag:"div",attr:{class:"vp-loading-bar"},style:{"animation-duration":`${r}ms`}},{tag:"div",attr:{class:"content"},children:e}]})},g=(t,e)=>t.id||t.type||`id_${e}`,m=(t,e,s,i,r)=>{let{playerOptions:n,videojsOptions:o}=t;const l=(0,p.w)(o),h=n&&n.colors?n.colors.accent:l.accent,c=a()(o,"interactionDisplay.theme.template",d.IT.PULSING);return(0,u.It)({tag:"div",attr:{class:`${d.be}-item theme-${c}`,"data-id":g(e,s)},style:{left:`${e.left}%`,top:`${e.top}%`,width:`${e.width}%`,height:`${e.height}%`,transitionDuration:`${i}ms`},event:{name:"click",callback:r},children:[{tag:"div",attr:{class:`${d.be}-area-marker`},children:[{tag:"div",attr:{class:`${d.be}-marker-shadow`},style:{[c===d.IT.SHADOWED?"backgroundColor":"borderColor"]:h}},{tag:"div",attr:{class:`${d.be}-marker-main`},style:{borderColor:h}}]}]})},y=(t,e)=>t/(100/+e),v=(t,e)=>{const s=T(t);s?s.replaceWith(e):t.el().appendChild(e)},b=(t,e,s)=>t.querySelector(`[data-id=${g(e,s)}]`),_=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c();localStorage.setItem(d.sb,JSON.parse(t)),e()},T=t=>t.el().querySelector(`.${d.Fg}`),A=t=>{const e=T(t);e&&e.parentNode.removeChild(e)};var E=s(7764),S=s(1104);const C=(t,e,s)=>{let i=!1,n=null,o=null,h=c();function p(){let t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const e=k();return t||e&&e.enable}function C(){o&&t.videojs.removeRemoteTextTrack(o);const e=p(),s=k();if(!e||i)return null;if(Array.isArray(s.template))P(s.template),x();else{const e=s.vttUrl||d.Yx[s.template];e&&(o=(0,E.eo)(t.videojs,e),function(e){if(!e)return;let s=null;e.addEventListener("cuechange",()=>{const i=e.activeCues&&e.activeCues[0];if(i){const t=Math.max(Math.floor(1e3*(i.endTime-i.startTime)),d.q3),e=JSON.parse(i.text);P(e,s,t),!s&&x(),s=e}else A(t.videojs),s=null})}(o))}}function k(){const{cldSrc:t}=n;return t&&t.interactionAreas()}function w(){A(t.videojs),C(),t.play()}function L(){if(p())if(e=s.interactionDisplay,a()(e,"layout.enable",!0)&&"true"!==localStorage.getItem(d.sb)){let e=null;const i=a()(s,"interactionDisplay.layout.showAgain",!1);t.pause(),function(t,e){let s=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=!1;const r=`checkbox_${Math.round(1e4*Math.random())}`,n=(0,u.It)({tag:"div",attr:{class:`${d.Fg} ${d.be}-layout-message ${s?"":"clickable"}`},onClick:s?null:()=>_(i,e),children:[{tag:"img",attr:{class:`${d.be}-layout-icon`,src:d.T$}},{tag:"h3",attr:{class:`${d.be}-layout-message-title`},children:"Tap on dots to zoom for a product."},f({text:"Got it",theme:"transparent-white",loadingDelay:s?0:d.Vv,onClick:s?()=>_(i,e):null}),s&&{tag:"div",attr:{class:`${d.be}-layout-message-do-not-show`},children:[{tag:"input",attr:{type:"checkbox",class:`${d.be}-layout-message-checkbox`,id:r},event:{name:"input",callback:t=>{i=t.target.checked}}},{tag:"label",attr:{class:`${d.be}-layout-message-checkbox-title`,for:r},children:"Don׳t show it again"}]}].filter(t=>t)});v(t,n)}(t.videojs,()=>{clearTimeout(e),w()},i),i||(e=setTimeout(w,d.Vv))}else w();var e}function I(e){let{event:s,item:a,index:o}=e;const l=k();l.onClick&&l.onClick({item:a,index:o,event:s,zoom:(e,s)=>{!function(e,s,a){const o=t.currentTime(),l=(()=>{const t=k();return!(!t||void 0===t.syncOffsetTime)&&t.syncOffsetTime})(),{cldSrc:c}=n,p=c.getInitOptions(),f=s||{transformation:p.transformation},g=!e&&((t,e)=>{const{videoHeight:s,videoWidth:i}=t,r=y(i,e.left),n=y(s,e.top),a=y(i,e.width),o=y(s,e.height),l=i/s,h=a/o,c=Math.round(h>1||l>1?o*h:a),d=Math.round(c/l),u=Math.round(r-(c-a)/2),p=Math.round(n-(d-o)/2);return{width:c,height:d,x:Math.min(Math.max(u,0),i-c),y:Math.min(Math.max(p,0),s-d),crop:"crop"}})(t.videoElement,a),m=g?r().obj.merge({transformation:g},f):f,b=c.isRawUrl?n.src:{publicId:c.publicId()};t.source(g?{publicId:c.publicId()}:e,m).play(),l&&t.currentTime(o),i=!0,function(){const e=(0,u.n)("div",{class:"go-back-button"});e.addEventListener("click",()=>{h()},!1);const s=(0,u.n)("div",{class:d.Fg},e);v(t.videojs,s)}(),h=()=>{if(i){i=!1;const e=t.currentTime(),s=t.duration();t.source(b,p).play(),l&&e<s&&t.currentTime(e),C()}}}(e,s,a)}})}function P(i,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const a={playerOptions:e,videojsOptions:s};if(r)((t,e,s,i,r,n)=>{const a=T(t);s.forEach((t,s)=>{const o=b(a,t,s),l=g(t),h=i.some(t=>g(t)===l);h&&o?(0,u.cu)(o,{left:`${t.left}%`,top:`${t.top}%`,width:`${t.width}%`,height:`${t.height}%`,transitionDuration:`${r}ms`}):h||o||a.appendChild(m(e,t,s,r,e=>{n({event:e,item:t,index:s})}))}),i.forEach((t,e)=>{const i=b(a,t,e),r=g(t),n=!s.some(t=>g(t)===r);i&&n&&i.parentNode.removeChild(i)})})(t.videojs,a,i,r,n,I);else{const e=i.map((t,e)=>m(a,t,e,n,s=>{I({event:s,item:t,index:e})}));v(t.videojs,(0,u.n)("div",{class:d.Fg},e))}}function x(){p()&&((t,e)=>{const s=T(t);if(!s)return;const{videoHeight:i,videoWidth:r}=e,n=r/i,a=n*e.clientHeight;s.style.width=`${e.clientWidth<a?"100%":a}px`,s.style.height=e.clientWidth<a?e.clientWidth/n+"px":"100%"})(t.videojs,t.videoElement)}!function(){if(n=n||t.videojs.currentSource(),p()){t.videojs.el().classList.add("interaction-areas"),t.videojs.one(S.f.PLAY,()=>{"object"==typeof t.videojs.ima?t.on("adsready",()=>{t.videojs.ima.addEventListener(window.google.ima.AdEvent.Type.ALL_ADS_COMPLETED,L)}):L()});const e=l()(x,100);t.videojs.on(S.f.FULL_SCREEN_CHANGE,()=>{setTimeout(e,100)});const s=(0,u.q2)(window,"resize",x,!1);t.videojs.on(S.f.DISPOSE,s)}t.videojs.on(S.f.ENDED,()=>{h()}),t.videojs.on(S.f.ERROR,()=>{t.pause()})}()}},5826:(t,e,s)=>{s.d(e,{default:()=>q});var i=s(5871),r=s(1104),n=s(1865),a=s(3686),o=s.n(a),l=s(4679),h=s.n(l);const c=[1,4,5,6,7,10,11],d=["created_at","updated_at"],u=t=>{const e={};return h()(t)?(Object.keys(t).reduce((e,s)=>{const i=o()(s);return-1!==d.indexOf(s)?e[i]=new Date(function(t){let e=0,s=0,i=0;if(s=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(t)){for(let t,e=0;t=c[e];++e)s[t]=+s[t]||0;s[2]=(+s[2]||1)-1,s[3]=+s[3]||1,"Z"!==s[8]&&void 0!==s[9]&&(i=60*s[10]+s[11],"+"===s[9]&&(i=0-i)),e=Date.UTC(s[1],s[2],s[3],s[4],s[5]+i,s[6],s[7])}else e=NaN;return e}(t[s])):e[i]=u(t[s]),e},e),e):Array.isArray(t)?t.map(t=>u(t)):t};var p=s(5381),f=s(4466),g=s.n(f),m=s(6673),y=s.n(m);const v=y().dom||y(),b=y().getComponent("Component"),_=y().getComponent("ClickableComponent");class T extends _{static DISABLE_TRANSITION_CLASS="disable-transition";static VJS_UPCOMING_VIDEO_SHOW="vjs-upcoming-video-show";constructor(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;i<e;i++)s[i-1]=arguments[i];super(t,...s),this._setEvents(t)}_setEvents(t){t.on(r.f.UP_COMING_VIDEO_SHOW,this._show),t.on(r.f.UP_COMING_VIDEO_HIDE,this._hide),t.on(r.f.PLAYLIST_ITEM_CHANGED,this._onPlaylistItemChange)}_hide=()=>{this.removeClass(T.VJS_UPCOMING_VIDEO_SHOW)};_disableTransition(t){this.addClass(T.DISABLE_TRANSITION_CLASS),t(),this.removeClass(T.DISABLE_TRANSITION_CLASS)}_onPlaylistItemChange=(t,e)=>{this._hide(),this._disableTransition(()=>{e.next&&this.setItem(e.next)})};_show=()=>{const t=this.player().ima,e="object"===t&&t.getAdsManager();e&&e.getCurrentAd()&&!e.getCurrentAd().isLinear()||this.addClass(T.VJS_UPCOMING_VIDEO_SHOW)};setTitle(t){this.getChild("upcomingVideoOverlayContent").getChild("upcomingVideoOverlayBar").getChild("upcomingVideoOverlayTitle").setContent(t.info().title||t.publicId())}setItem(t){this._source=t;const e=parseInt(window.getComputedStyle(this.el(),null).getPropertyValue("max-width"),10),s={crop:"pad",background:"auto:predominant",width:e,height:Math.round(e*(9/16))},i=this.getChild("upcomingVideoOverlayContent");this.setTitle(t),i.el().style.backgroundImage=`url("${this._source.poster().url({transformation:s})}")`}handleClick(){super.handleClick(event),this.player().cloudinary.playlist().playNext()}createEl(){return super.createEl("div",{className:"vjs-upcoming-video"})}}class A extends b{createEl(){return super.createEl("div",{className:"upcoming-video-overlay aspect-ratio-content"})}}class E extends b{createEl(){return super.createEl("div",{className:"vjs-upcoming-video-bar"})}}T.prototype.options_={children:["upcomingVideoOverlayContent"]},y().registerComponent("upcomingVideoOverlay",T),A.prototype.options_={children:["upcomingVideoOverlayBar"]},y().registerComponent("upcomingVideoOverlayContent",A),E.prototype.options_={children:["upcomingVideoOverlayTitle","playlistNextButton"]},y().registerComponent("upcomingVideoOverlayBar",E),y().registerComponent("upcomingVideoOverlayTitle",class extends b{setContent(t){this._contentSpan.innerText=t}createEl(){const t=super.createEl("div",{className:"vjs-control vjs-upcoming-video-title"}),e=v.createEl("div",{className:"vjs-upcoming-video-title-display",innerHTML:'<span class="vjs-control-text">Next up</span>Next up: '});return this._contentSpan=v.createEl("span",{className:"vjs-upcoming-video-title-display-label"}),e.appendChild(this._contentSpan),t.appendChild(e),t}});const S=y().getComponent("ClickableComponent"),C=class extends S{constructor(t,e){super(t,e);const s=e.type;if(!s&&"previous"!==s&&"next"!==s)throw new Error("Type must be either 'previous' or 'next'")}createEl(){const t=this.options_.type,e=`vjs-icon-${t}-item`;return y().dom.createEl("button",{className:`vjs-control vjs-playlist-button vjs-button ${e}`,ariaLabel:`Playlist ${t} item`})}};y().registerComponent("PlaylistNextButton",class extends C{constructor(t){super(t,{type:"next"})}handleClick(t){t.stopPropagation(),super.handleClick(t),this.player().cloudinary.playlist().playNext()}});y().registerComponent("PlaylistPreviousButton",class extends C{constructor(t){super(t,{type:"previous"})}handleClick(t){super.handleClick(t),this.player().cloudinary.playlist().playPrevious()}});const k={fluid:!1,show:!0,direction:"vertical",total:4,selector:!1,renderTo:[]},w=class{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],{repeat:s=!1,autoAdvance:i=!1,presentUpcoming:r=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this._context=t,this._sources=[],this._defaultRecResolverCache={},this._currentIndex=null,this._recommendationsHandler=null,this._autoAdvance=null,this._presentUpcoming=null,this.addUiComponents(),this.resetState=()=>{this.repeat(s),this.autoAdvance(i),this.presentUpcoming(r)},e.forEach(t=>this.enqueue(t)),this.resetState()}list(){return this._sources}player(){return this._context.player}addUiComponents(){const t=this.player().getChild("ControlBar"),e=t.children();t.addChild("playlistPreviousButton",{},e.findIndex(t=>"PlayToggle"===t.name_)),t.addChild("playlistNextButton",{},e.findIndex(t=>"PlayToggle"===t.name_)+1),this.player().addChild("upcomingVideoOverlay")}presentUpcoming(t){if(this._presentUpcoming=this._presentUpcoming||{},void 0===t)return this._presentUpcoming.delay;if(!0===t)t=10;else if(!1===t)t=!1;else if(!g()(t)||t<0)throw new Error("presentUpcoming 'delay' must be either a boolean or a positive integer.");return this._presentUpcoming.delay=t,this._setupPresentUpcoming(),this._presentUpcoming.delay}autoAdvance(t){if(this._autoAdvance=this._autoAdvance||{},void 0===t)return this._autoAdvance.delay;if(!0===t)t=0;else if(!1===t)t=!1;else if(!g()(t)||t<0)throw new Error("Auto advance 'delay' must be either a boolean or a positive integer.");return this._autoAdvance.delay=t,this._setupAutoAdvance(),this._autoAdvance.delay}_setupAutoAdvance(){this._resetAutoAdvance();const t=this._autoAdvance.delay;!1!==t&&(this._autoAdvance={delay:t,trigger:()=>{this.player().ended()&&(this._autoAdvance.timeout=setTimeout(()=>{this.playNext()},1e3*t))}},this._context.on("ended",this._autoAdvance.trigger))}dispose(){this._resetAutoAdvance(),this._resetPresentUpcoming(),this._resetRecommendations()}_resetPresentUpcoming(){this.player().trigger("upcomingvideohide"),this._presentUpcoming||(this._presentUpcoming={}),this._presentUpcoming.trigger&&this._context.off("timeupdate",this._presentUpcoming.trigger),this._presentUpcoming.trigger=null,this._presentUpcoming.showTriggered=!1}_setupPresentUpcoming(){this._resetPresentUpcoming(),!1!==this._presentUpcoming.delay&&(this._presentUpcoming.trigger=()=>{const t=this.player().currentTime(),e=this.player().duration()-t;e<1.5?this._presentUpcoming.showTriggered&&(this.player().trigger("upcomingvideohide"),this._presentUpcoming.showTriggered=!1):e<=this._presentUpcoming.delay&&!this._presentUpcoming.showTriggered&&!this.player().loop()?(this.player().trigger("upcomingvideoshow"),this._presentUpcoming.showTriggered=!0):this._presentUpcoming.showTriggered&&(e>this._presentUpcoming.delay||this.player().loop())&&(this.player().trigger("upcomingvideohide"),this._presentUpcoming.showTriggered=!1)},this._context.on("timeupdate",this._presentUpcoming.trigger))}_resetAutoAdvance(){this._autoAdvance||(this._autoAdvance={}),this._autoAdvance.timeout&&clearTimeout(this._autoAdvance.timeout),this._autoAdvance.trigger&&this._context.off("ended",this._autoAdvance.trigger),this._autoAdvance.timeout=null,this._autoAdvance.trigger=null}_resetRecommendations(){this._recommendationsHandler&&this._context.off("ended",this._recommendationsHandler)}_refreshRecommendations(){this._resetRecommendations(),this._recommendationsHandler=()=>{!1===this.autoAdvance()&&this._context.autoShowRecommendations()&&this.player().trigger("recommendationsshow")},this._context.on("ended",this._recommendationsHandler)}_refreshTextTracks(){this.player().trigger("refreshTextTracks",this.currentSource().textTracks())}_recommendationItemBuilder(t){const e=this._defaultRecResolverCache[t.objectId];if(!t.recommendations()||e&&t.recommendations()===e)return t=>({source:t,action:()=>this.playItem(t)})}currentIndex(t){if(void 0===t)return this._currentIndex;if(t>=this.length()||t<0)throw new Error("Invalid playlist index.");this._currentIndex=t;const e=this.currentSource(),s=this._recommendationItemBuilder(e);e.recommendations()||e.recommendations(this._defaultRecommendationsResolver(e));const i=e.getInitOptions?e.getInitOptions():{};this._context.source(e,{...i,recommendationOptions:{disableAutoShow:!0,itemBuilder:s}});const r={playlist:this,current:e,next:this.next()};return this.player().trigger("playlistitemchanged",r),this._refreshRecommendations(),this._refreshTextTracks(),e}_defaultRecommendationsResolver(t){return this._defaultRecResolverCache[t.objectId]||(this._defaultRecResolverCache[t.objectId]=()=>{let e=this.list().indexOf(t);const s=[],i=Math.min(4,this.length()-1);for(;s.length<i&&(e=this.nextIndex(e),-1!==e);){const t=this.list()[e];s.push(t)}return s},this._defaultRecResolverCache[t.objectId])}buildSource(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this._context.buildSource(t,e)}enqueue(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=t instanceof p.A?t:this.buildSource(t,e);return this._sources.push(s),s}playItem(t){let e=this.list().indexOf(t);if(-1===e)throw new Error("Invalid playlist item.");this.playAtIndex(e)}playAtIndex(t){return this.currentIndex(t),this.player().play(),this.currentSource()}currentSource(){return this.list()[this.currentIndex()]}removeAt(t){if(t>=this.length()||t<0)throw new Error("Invalid playlist index.");return this._sources.splice(t,1),this}repeat(t){return void 0===t||(this._repeat=!!t),this._repeat}first(){return this.list()[0]}last(){return this.list()[this.length()-1]}next(){const t=this.nextIndex();return-1===t?null:this.list()[t]}nextIndex(t){if((t=void 0!==t?t:this.currentIndex())>=this.length()||t<0)throw new Error("Invalid playlist index.");let e=t+1;if(t===this.length()-1){if(!this.repeat())return-1;e=0}return e}previousIndex(){return this.isFirst()?-1:this.currentIndex()-1}playFirst(){return this.playAtIndex(0)}playLast(){const t=this.list().length-1;return this.playAtIndex(t)}isLast(){return this.currentIndex()>=this.length()-1}isFirst(){return 0===this.currentIndex()}length(){return this.list().length}playNext(){let t=this.nextIndex();return-1===t?null:this.playAtIndex(t)}playPrevious(){let t=this.previousIndex();return-1===t?null:this.playAtIndex(t)}playlistByTag=(()=>{var t=this;return function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t.player().sourcesByTag(e,s).then(e=>t.player().playlist(e,s))}})()},L=(t,e)=>(t.parentNode.insertBefore(e,t),e.appendChild(t),e);var I=s(3066);const P=y().dom||y(),x=y().getComponent("Component"),R={wrap:!1};class D extends x{constructor(t,e){const s={...R,...e};super(t,s),this.player_=t;const i=(t,e)=>{this.options_.fluid=e,this.removeCls(),this.setCls()};s.wrap&&(()=>{const t=this.el();this.videoWrap_=P.createEl("div",{className:"cld-plw-col-player"}),this.contentEl_=this.contentEl_=P.createEl("div",{className:"cld-plw-col-list"}),L(this.player().el(),t),t.appendChild(this.videoWrap_),t.appendChild(this.contentEl_),L(this.player().el(),this.videoWrap_)})(),t.on(r.f.FLUID,i),this.addChild(r.f.PLAYLIST_PANEL,this.options_),this.setCls(),this.dispose=()=>{this.removeLayout(),super.dispose(),t.off(r.f.FLUID,i)}}getCls(){let t=["cld-video-player","cld-plw-layout"];return t.push((0,I.skinClassPrefix)(this.player())),t.push((0,I.playerClassPrefix)(this.player())),this.options_.fluid&&t.push("cld-plw-layout-fluid"),t}setCls(){this.removeClass((0,I.skinClassPrefix)(this.player())),this.getCls().forEach(t=>{this.addClass(t)})}removeCls(){this.getCls().forEach(t=>{this.removeClass(t)})}update(t,e){this.options(e),this.removeChild("PlaylistPanel"),this.addChild("PlaylistPanel",this.options_),this.trigger("playlistlayoutupdate")}removeLayout(){const t=this.el().parentElement;t&&t.appendChild(this.player().el())}createEl(){const t=super.createEl("div");return t.style.fontFamily=this.player().el().style.fontFamily,t}}y().registerComponent("playlistLayout",D);const O=D,M=class extends O{constructor(t,e){e.wrap=!0,super(t,e)}getCls(){const t=super.getCls();return t.push("cld-plw-horizontal"),t}},F=class extends O{constructor(t,e){e.wrap=!0,super(t,e)}getCls(){const t=super.getCls();return t.push("cld-plw-vertical"),t}},N=class extends O{getCls(){let t=super.getCls();return t.push("cld-plw-custom"),t}createEl(){const t=super.createEl();return this.options_.renderTo.appendChild(t),t}},B=class{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e=((t,e)=>{const s={...k,...e};if(s.show&&"string"==typeof s.selector&&(s.useDefaultLayout=!1,s.useCustomLayout=!0,s.renderTo=document.querySelector(s.selector),s.showAll=!0,0===!s.renderTo.length))throw new Error(`Couldn't find element(s) by selector '${s.selector}' for playlist`);return s.show&&!s.selector&&(s.useDefaultLayout=!0,s.useCustomLayout=!1),s.direction="horizontal"===s.direction.toLowerCase()?"horizontal":"vertical",s.skin=t.options_.skin,s})(t,e),this.options_=e,this.player_=t,this.render();const s=(t,e)=>{this.options_.fluid=e};t.on(r.f.FLUID,s),this.options=e=>e?(this.options_=y().obj.merge(this.options_,e),t.trigger("playlistwidgetoption",this.options_.playlistWidget),this.options_):this.options_,this.dispose=()=>{this.layout_.dispose(),t.off(r.f.FLUID,s)}}render(){this.options_.useDefaultLayout&&("horizontal"===this.options_.direction?this.layout_=new M(this.player_,this.options_):this.layout_=new F(this.player_,this.options_)),this.options_.useCustomLayout&&(this.layout_=new N(this.player_,this.options_))}getLayout(){return this.layout_}update(t,e){this.options(e),"direction"===t?(this.layout_.removeLayout(),this.layout_.dispose(),this.render()):this.layout_.update(t,this.options_)}setSkin(){this.layout_.setCls()}total(){const t=parseInt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:k.total,10);return t!==this.options_.total&&"number"==typeof t&&t>0&&this.update("total",{total:t}),this}direction(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:k.direction;return"horizontal"!==t&&"vertical"!==t||this.update("direction",{direction:t}),this}},j=y().getComponent("ClickableComponent"),$={item:null,transformation:{width:300,aspect_ratio:"16:9",crop:"pad",background:"black"}},U=class extends j{constructor(t,e){super(t,y().obj.merge($,e))}getItem(){return this.options_.item}getTitle(){return this.getItem().info().title}getDuration(){return" "}getThumbnail(){return this.getItem().poster().url({transformation:this.options_.transformation})}handleClick(t){t.preventDefault()}createControlTextEl(){}createEl(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"a";const e=super.createEl(t,{className:"cld-thumbnail",href:"#"}),s=super.createEl("img",{className:"cld-thumbnail-img",src:this.getThumbnail()});return e.appendChild(s),e.style.backgroundImage=`url('${this.getThumbnail()}')`,e}},H=y().dom||y(),V={source:null,next:!1};class G extends U{constructor(t,e){super(t,y().obj.merge(V,e))}handleClick(t){super.handleClick(t),this.play()}play(){const t=this.getItem(),e=this.player().cloudinary.playlist().list().indexOf(t);if(-1===e)throw new Error("Invalid playlist item...");this.player().cloudinary.playlist().playAtIndex(e)}isCurrent(){return this.options_.current}getTitle(){return super.getTitle()}getDuration(){return super.getDuration()}createEl(){const t=super.createEl();t.classList.add("cld-plw-panel-item");const e=H.createEl("div",{className:"cld-plw-item-info-wrap"}),s=H.createEl("div",{className:"cld-plw-item-title"});if(this.isCurrent()){t.classList.add("cld-plw-panel-item-active");const e=H.createEl("span",{className:"cld-plw-item-title-curr"},{},"Now Playing: ");s.appendChild(e)}const i=H.createEl("span",{className:"cld-plw-item-title"},{},this.getTitle());s.appendChild(i);const r=H.createEl("div",{className:"cld-plw-item-duration"},{},this.getDuration());return e.appendChild(s),e.appendChild(r),t&&t.appendChild(e),t.appendChild(e),t}}y().registerComponent("playlistPanelItem",G);const W=G,K=y().getComponent("Component");y().registerComponent("playlistPanel",class extends K{constructor(t){super(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{});const e=()=>{this.render()};t.on(r.f.PLAYLIST_ITEM_CHANGED,e),this.render(),this.dispose=()=>{super.dispose(),t.off(r.f.PLAYLIST_ITEM_CHANGED,e)}}createEl(){const t=super.createEl();return t.classList.add("cld-plw-panel"),t}removeAll(){const t=this.children();for(let e=t.length-1;e>=0;--e)this.removeChild(t[e])}getItems(){const t=this.player().cloudinary.playlist(),e=t._repeat;if(this.options_.showAll)return t.list();const s=[],i=this.options_.total;let r=t.currentIndex(),n=t.list()[r];for(s.push(n);s.length<i;){if(r=t.nextIndex(r),-1===r){if(!e&&s.length>0)break;r=0}n=t.list()[r],s.push(n)}return s}render(){const t=this.getItems();this.removeAll(),t.forEach((t,e)=>{const s=new W(this.player(),y().obj.merge(this.options_,{item:t,next:1===e,current:0===e}));this.addChild(s)})}});const z={format:"json",resource_type:"video",type:"list"},q=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=(0,i.sliceProperties)(e,"chainTarget").chainTarget;let a=null,o=null,l=null;const h=()=>{t.on(r.f.PLAYLIST_CREATED,()=>{l&&l.dispose(),0!=e.playlistWidget?.show&&(t.fluid_&&(e.playlistWidget.fluid=!0),t.cloudinary.fontFace&&(e.playlistWidget.fontFace=t.cloudinary.fontFace),l=new B(t,e.playlistWidget))})};return t.cloudinary.sourcesByTag=async function(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=(0,n.KA)(e,Object.assign({},t.cloudinary.cloudinaryConfig(),z)),r=await fetch(i),a=await r.json(),o=u(a.resources);return s.sorter&&o.sort(s.sorter),o.map(e=>{let i=s.sourceParams||{};"function"==typeof i&&(i=i(e));const r=e.context&&e.context.custom||{},n=Object.assign({info:r},i,{publicId:e.publicId});return t.cloudinary.buildSource(n)})},function(e){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return void 0===e?a:(a&&(t.removeClass("vjs-playlist"),a=void 0,t.playlist().dispose(),t.off("cldsourcechanged",o)),((e,s)=>{e instanceof w?(a=e,a.resetState(),a.currentIndex(a.currentIndex())):(a=new w(t.cloudinary,e,s),a.currentIndex(0)),h(),o=(()=>{const e=()=>{a&&!a.currentSource().contains(t.currentSource())&&t.disposePlaylist()};return t.on("cldsourcechanged",e),e})(),t.addClass("vjs-playlist")})(e,i),t.trigger("playlistcreated"),s)}}},2130:(t,e,s)=>{s.d(e,{default:()=>h});var i=s(6673),r=s.n(i);const n=r().getComponent("ClickableComponent");r().registerComponent("ShareDownloadButton",class extends n{constructor(t){super(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{})}handleClick(t){super.handleClick(t),this.player().share&&"function"==typeof this.player().share.download&&this.player().share.download()}createEl(){const t=r().dom.createEl("button",{className:"vjs-control vjs-share-download-button vjs-button",ariaLabel:"Download video",title:"Download video"}),e=r().dom.createEl("span",{className:"vjs-icon-file-download vjs-icon-placeholder"});t.appendChild(e);const s=r().dom.createEl("span",{className:"vjs-loading-spinner"});return t.appendChild(s),t}setPreparing(t){const e=this.el();t?(e.classList.add("vjs-waiting"),e.setAttribute("title","Download is being prepared")):(e.classList.remove("vjs-waiting"),e.setAttribute("title","Download video"))}});var a=s(1865),o=s(4319),l=s.n(o);const h=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=(arguments.length>1?arguments[1]:void 0)||this;e.addClass("vjs-share");const s=()=>{const t=e.getChild("ControlBar");if(!t||t.getChild("ShareDownloadButton"))return;const s=t.children().findIndex(t=>"FullscreenToggle"===t.name_);t.addChild("ShareDownloadButton",{},-1!==s?s:void 0)};t.download&&s(),e.share={download:()=>{const t=(()=>{const t=e.currentSource?.();if(!t)return null;const s=["format","video_codec","streaming_profile"],i=t=>{if(Array.isArray(t))return t.map(i);if(t&&"object"==typeof t){const e=l()(t,s);return Object.keys(e).forEach(t=>{e[t]=i(e[t])}),e}return t},r=i(e.cloudinary.transformation()||{}),n=e.cloudinary.currentPublicId()?.split("/")?.pop(),o={...e.cloudinary.cloudinaryConfig(),...r,resource_type:"video",format:"mp4",video_codec:"h264",flags:`streaming_attachment:${n}`};return t.isAdaptive&&Object.assign(o,{crop:"limit",width:1920,height:1920}),"AudioSource"===e.cloudinary.source()?.getType()&&Object.assign(o,{format:"mp3",video_codec:void 0}),(0,a.KA)(e.cloudinary.currentPublicId(),o)})();if(!t)return void console.warn("Share plugin: Unable to resolve download URL.");const s=[423],i=e.controlBar?.getChild("ShareDownloadButton"),r=t=>{i?.setPreparing?.(t)},n=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;const i=await fetch(t,{method:"HEAD"});if(s.includes(i.status)&&e<60)return await new Promise(t=>setTimeout(t,1e4)),n(e+1);r(!1),(()=>{const e=document.createElement("a");e.href=t,e.download="",document.body.appendChild(e),e.click(),document.body.removeChild(e)})()};r(!0),n()},addDownloadButton:s,removeDownloadButton:()=>{if(!e.controlBar)return;const t=e.controlBar.getChild("ShareDownloadButton");t&&e.controlBar.removeChild(t)}}}},9148:(t,e,s)=>{s.d(e,{default:()=>n});var i=s(6673),r=s.n(i);const n=(t,e)=>{e.addClass("vjs-visual-search");let s=!1;const i=(t=>{const e=()=>{t.$$(".vjs-visual-search-marker").forEach(t=>t.remove()),t.$$(".vjs-visual-search-results-wrapper").forEach(t=>t.remove()),t.removeClass("vjs-visual-search-results-active")};return{displayResults:s=>{e();const i=t.duration(),n=t.controlBar.progressControl.seekBar,a=r().dom.createEl("div",{className:"vjs-visual-search-results-wrapper",role:"presentation"});s.forEach(e=>{const{start_time:s,end_time:n}=e,o=s/i*100,l=(n-s)/i*100,h=`${Math.floor(s/60)}:${Math.floor(s%60).toString().padStart(2,"0")}`,c=r().dom.createEl("div",{className:"vjs-control vjs-visual-search-marker",style:`left: ${o}%; width: ${l}%`,tabIndex:0,role:"button",title:`Search result at ${h}`,ariaLabel:`Search result at ${h}`});a.appendChild(c),c.addEventListener("click",()=>{t.currentTime(s)}),c.addEventListener("keydown",e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),t.currentTime(s))})}),n.el().appendChild(a),s.length>0&&t.addClass("vjs-visual-search-results-active")},clearMarkers:e}})(e),n=async t=>{const s=e.$(".vjs-visual-search-button");s.classList.add("vjs-waiting");try{const s=e.cloudinary.source(),r=s.publicId(),n=Object.assign({},s.transformation());n.flags=n.flags||[],n.flags.push(`getinfo:search_b64_${btoa(t)}`);const a=s.config().url(`${r}`,{transformation:n}),o=await fetch(a,{method:"GET",headers:{"Content-Type":"application/json"}});if(!o.ok)throw new Error(`Search request failed with status: ${o.status}`);const l=await o.json();i.displayResults(l.timestamps),l&&!e.hasStarted()&&e.play().then(()=>e.pause())}catch(t){console.error("Error performing visual search:",t)}finally{s.classList.remove("vjs-waiting")}},a=()=>{s=!1,i.clearMarkers(),e.$(".vjs-visual-search-wrapper")?.remove()},o=()=>{a();const t=e.$(".vjs-title-bar");t&&t.classList.remove("vjs-hidden");const o=r().dom.createEl("div",{className:"vjs-visual-search-wrapper"}),l=()=>{s&&(s=!1,o.classList.remove("vjs-visual-search-active"),c.input.value="",c.input.tabIndex=-1,c.closeButton.tabIndex=-1,i.clearMarkers())},h=(()=>{const t=r().dom.createEl("button",{className:"vjs-control vjs-button vjs-visual-search-button",title:"Search video content",ariaLabel:"Search video content"}),e=r().dom.createEl("span",{className:"vjs-icon-search"});t.appendChild(e);const i=r().dom.createEl("span",{className:"vjs-loading-spinner"});return t.appendChild(i),t.addEventListener("click",()=>{if(s){const t=c.input.value.trim();t&&n(t)}else s=!0,o.classList.add("vjs-visual-search-active"),c.input.tabIndex=0,c.closeButton.tabIndex=0,c.input.focus()}),t})(),c=((t,e)=>{const s=r().dom.createEl("form",{className:"vjs-visual-search-form"}),i=r().dom.createEl("input",{className:"vjs-visual-search-input",type:"text",ariaLabel:"Search input",tabIndex:-1}),n=r().dom.createEl("button",{className:"vjs-control vjs-button vjs-visual-search-close",type:"button",title:"Close search",ariaLabel:"Close search",tabIndex:-1}),a=r().dom.createEl("span",{className:"vjs-icon-close"});return n.appendChild(a),s.appendChild(i),s.appendChild(n),s.addEventListener("submit",e=>{e.preventDefault();const s=i.value.trim();s&&t(s)}),n.addEventListener("click",t=>{t.preventDefault(),e&&e()}),{element:s,input:i,closeButton:n}})(n,l);o.appendChild(h),o.appendChild(c.element),t.prepend(o),e.on("keydown",t=>{"Escape"===t.key&&s&&l()})};o(),e.visualSearch={createSearchUI:o,clearUI:a}}},5004:(t,e,s)=>{s.r(e),s.d(e,{GET_ERROR_DEFAULT_REQUEST:()=>n,handleCldError:()=>o,isKeyInTransformation:()=>l});var i=s(1865),r=s(9339);const n={method:"head"},a={method:"get",credentials:"include",headers:{"Content-Range":"bytes=0-0"}},o=(t,e)=>{const s=t.videojs.cloudinary.getCurrentSources(),r=e.fetchErrorUsingGet?a:n;r.credentials=e.sourceOptions.withCredentials?"include":"omit",s.length>0?Promise.all(s.map(t=>fetch(t.src,r))).then(e=>{const r=(t=>t.reduce((t,e)=>{if(e.status>=200&&e.status<399&&""!==e.url){const s=new URL(e.url);t.push(s.host+s.pathname)}return t},[]))(e),n=e[0];if(r.length){const n=((t,e)=>t.filter(t=>{const s=new URL(t.src);return-1!==e.indexOf(s.host+s.pathname)&&!0!==t.try}))(s,r);n&&n.length?((t,e)=>{t.options.playerOptions.debug&&console.log("Trying sources: ",e),e.forEach(t=>{t.try=!0}),t.videojs.autoplay(t.videojs.autoplay()||t.playWasCalled),t.videojs.src(e)})(t,n):t.videojs.error({code:i.bo.NO_SUPPORTED_MEDIA,message:"No supported media sources",statusCode:e.status})}else((t,e)=>{t.videojs.error((0,i.ww)({errorMsg:e.headers.get("x-cld-error")||"",publicId:t.currentPublicId(),cloudName:t.cloudinaryConfig().cloud_name,error:e,statusCode:e.status}))})(t,n)}).catch(e=>{t.videojs.error({code:7,message:e&&e.message?e.message:"Failed to test sources"})}):t.videojs.error({code:i.bo.NO_SUPPORTED_MEDIA,message:"No supported media sources"})},l=(t,e)=>!!(t&&e&&(Array.isArray(t)?(0,r.I)(t,t=>l(t,e)):t.getValue?t.getValue(e):Array.isArray(t.transformation)?(0,r.I)(t.transformation,t=>l(t,e)):t[e]))},1104:(t,e,s)=>{s.d(e,{f:()=>i,x:()=>r});const i={READY:"ready",PLAY:"play",PLAYING:"playing",PAUSE:"pause",SEEK:"seek",SEEKING:"seeking",MUTE:"mute",UNMUTE:"unmute",PAUSE_NO_SEEK:"pausenoseek",ERROR:"error",TIME_UPDATE:"timeupdate",EMPTIED:"emptied",RETRY_PLAYLIST:"retryplaylist",REFRESH:"refresh",CAN_PLAY_THROUGH:"canplaythrough",CLD_SOURCE_CHANGED:"cldsourcechanged",SOURCE_CHANGED:"sourcechanged",LOADED_METADATA:"loadedmetadata",LOADED_DATA:"loadeddata",REFRESH_TEXT_TRACKS:"refreshTextTracks",PLAYLIST_CREATED:"playlistcreated",UP_COMING_VIDEO_SHOW:"upcomingvideoshow",UP_COMING_VIDEO_HIDE:"upcomingvideohide",PLAYLIST_ITEM_CHANGED:"playlistitemchanged",VOLUME_CHANGE:"volumechange",FLUID:"fluid",PLAYLIST_PANEL:"PlaylistPanel",ENDED:"ended",RESIZE:"resize",START:"start",VIDEO_LOAD:"videoload",PRODUCT_BAR_MIN:"productBarMin",SHOW_PRODUCTS_OVERLAY:"showProductsOverlay",SHOPPABLE_ITEM_CHANGED:"shoppableitemchanged",FULL_SCREEN_CHANGE:"fullscreenchange",PERCENTS_PLAYED:"percentsplayed",TIME_PLAYED:"timeplayed",PLAYER_LOAD:"playerload",DISPOSE:"dispose",QUALITY_CHANGED:"qualitychanged"},r={AUDIO:"AudioSource",VIDEO:"VideoSource"}},3066:(t,e,s)=>{s.r(e),s.d(e,{CLASS_PREFIX:()=>n,playerClassPrefix:()=>o,setSkinClassPrefix:()=>c,skinClass:()=>l,skinClassPrefix:()=>h});var i=s(7668),r=s(9339);const n="cld-video-player",a=`${n}-skin-`,o=t=>`${n}-${t.id_}`,l=t=>`${a}${t}`,h=t=>(0,r.I)(t.el().classList,t=>t.startsWith(a)),c=(t,e)=>{const s=h(t),r=!!e&&e.replace(a,"");let n="";n=r?l(r):t.options_.skin?l(t.options_.skin):l(i.A.skin),n!==s&&(s&&t.removeClass(s),t.addClass(n)),r&&t.options_.skin!==r&&(t.options_.skin=r)}},7134:(t,e,s)=>{s.d(e,{It:()=>c,cu:()=>h,n:()=>o,q2:()=>d});var i=s(2160),r=s.n(i),n=s(9040),a=s.n(n);const o=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;const i=document.createElement(t);for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&i.setAttribute(t,e[t]);return r()(s).forEach(t=>l(t,i)),i},l=(t,e)=>{if(a()(t))e.appendChild(t);else if(t&&"object"!=typeof t){const s=document.createTextNode(t);e.appendChild(s)}},h=(t,e)=>{for(let s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t.style[s]=e[s]);return t},c=t=>{const e=Array.isArray(t.children)?t.children.map(c):t.children,s=a()(t)?t:o(t.tag,t.attr,e);return t.onClick&&(t.event={name:"click",callback:t.onClick}),t.event&&s.addEventListener(t.event.name,t.event.callback,!1),t.style&&h(s,t.style),s},d=(t,e,s)=>(t.addEventListener(e,s,!1),()=>{t.removeEventListener(e,s,!1)})},9339:(t,e,s)=>{function i(t,e){return Array.prototype.find&&Array.isArray(t)?t.find(e):function(t,e){for(let s=0;s<t.length;s++){const i=t[s];if(e(i,s,t))return[i,s]}return[void 0,-1]}(t,e)[0]}s.d(e,{I:()=>i})},7588:(t,e,s)=>{s.r(e),s.d(e,{fontFace:()=>n});var i=s(5303),r=s.n(i);const n=(t,e)=>{void 0===e&&(e="Inter"),e&&"inherit"!==e?(r().load({google:{families:[e]}}),t.style.fontFamily=e):"inherit"===e&&(t.style.fontFamily="inherit")}},5104:(t,e,s)=>{s.d(e,{A:()=>y});var i={};s.r(i),s.d(i,{mixin:()=>l});var r={};s.r(r),s.d(r,{normalizeAttributes:()=>m});var n=s(5871),a=s(3171),o=s(5004);function l(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];return e.reduce((t,e)=>e(t),class{})}var h=s(7588),c=s(3066),d=s(3686),u=s.n(d);const p=/^(data-cld-)(\w+)/,f={},g=t=>function(t){let e=null;if(""===t)return!0;try{e=JSON.parse(t)}catch(t){}return e||(e=Number(t),e||t)}(t),m=t=>{const e={};if(t&&t.attributes&&t.attributes.length>0){const s=t.attributes;for(let i=s.length-1;i>=0;i--){let r=s[i].name,n=s[i].value;r.match(p)&&(r=u()(r.replace(p,"$2"))),n="boolean"==typeof t[r]?null!==n:(f[r]||g)(n),e[r]=n}}return e},y=Object.assign({},n,a,o,h,i,c,r)},3171:(t,e,s)=>{function i(t){const e=t.getBoundingClientRect(),s=document.body,i=document.documentElement,r=window.pageYOffset||i.scrollTop||s.scrollTop,n=window.pageXOffset||i.scrollLeft||s.scrollLeft,a=i.clientTop||s.clientTop||0,o=i.clientLeft||s.clientLeft||0,l=e.top+r-a,h=e.left+n-o;return{top:Math.round(l),left:Math.round(h)}}function r(t,e){const s={},r=i(t),n=t.offsetWidth,a=t.offsetHeight,o=r.top,l=r.left;let h=e.pageY,c=e.pageX;return e.changedTouches&&(c=e.changedTouches[0].pageX,h=e.changedTouches[0].pageY),s.y=Math.max(0,Math.min(1,(o-h+a)/a)),s.x=Math.max(0,Math.min(1,(c-l)/n)),s}function n(t,e){let{fraction:s}=e;const r=i(t),n=r.left,a=r.top,o=t.offsetHeight,l=t.offsetWidth,h=n+l,c=a+o;return Math.max(0,Math.min(l,window.pageXOffset+window.innerWidth-n,h-window.pageXOffset))*Math.max(0,Math.min(l,window.pageYOffset+window.innerHeight-a,c-window.pageYOffset))/(l*o)>s}function a(t,e,s){t.style.left=`${e}px`,t.style.top=`${s}px`}s.r(e),s.d(e,{getPointerPosition:()=>r,isElementInViewport:()=>n,setPosition:()=>a})},7311:(t,e,s)=>{s.d(e,{N:()=>i});const i=(t,e)=>{if(!e||!Object.keys(e).length)return t;const s=new URL(t);return Object.entries(e).forEach(t=>{let[e,i]=t;null!=i&&s.searchParams.append(e,i)}),s.href}},5871:(t,e,s)=>{function i(t,e){for(var s=arguments.length,i=new Array(s>2?s-2:0),r=2;r<s;r++)i[r-2]=arguments[r];return i.reduce((s,i)=>(Object.prototype.hasOwnProperty.call(t,i)&&(s[i]=t[i],e&&delete t[i]),s),{})}function r(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),r=1;r<e;r++)s[r-1]=arguments[r];return i(t,!1,...s)}function n(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),r=1;r<e;r++)s[r-1]=arguments[r];return i(t,!0,...s)}s.r(e),s.d(e,{sliceAndUnsetProperties:()=>n,sliceProperties:()=>r})},2415:(t,e,s)=>{function i(t){const e=(new TextEncoder).encode(t),s=String.fromCharCode(...e);return btoa(s)}s.d(e,{G:()=>i})},5779:(t,e,s)=>{s.d(e,{I6:()=>c,Is:()=>d,O6:()=>o,QF:()=>l});var i=s(8446),r=s.n(i),n=s(8953),a=s.n(n);const o=t=>r()(t)?t():t,l=(t,e,s)=>{const i=o(t),r=i.value(e);return r||console.error(`cloudinary video player: ${i.message(s)}`),r},h=(t,e)=>{if(a()(e))for(let s in t)if(Object.prototype.hasOwnProperty.call(e,s)){const i=t[s],r=e[s],n=a()(i);if(n&&!h(i,r))return!1;if(!n&&!l(r,i,s))return!1}return!0},c=async t=>s.e(40).then(s.bind(s,9754)).then(e=>{let{playerValidators:s}=e;return h(t,s)}),d=t=>s.e(40).then(s.bind(s,9754)).then(e=>{let{sourceValidators:s}=e;return h(t,s)})},608:(t,e,s)=>{s.d(e,{Am:()=>c,HJ:()=>o,KE:()=>h,LU:()=>i,_V:()=>n,gi:()=>a,hN:()=>d,jK:()=>r,rT:()=>l});const i=["adaptiveStreaming","allowUsageReport","aspectRatio","autoShowRecommendations","breakpoints","chapters","cropMode","cropPadColor","cloudinaryConfig","description","download","hdr","info","interactionAreas","maxDpr","poster","posterOptions","publicId","rawTransformation","recommendations","resourceType","shoppable","source","sourceTransformation","sourceTypes","textTracks","title","transformation","type","visualSearch","withCredentials","videoSources"],r=i.concat(["_internalAnalyticsMetadata","ads","aiHighlightsGraph","analytics","autoplayMode","chaptersButton","cloudinaryAnalytics","colors","debug","fetchErrorUsingGet","floatingWhenNotVisible","fluid","fontFace","hideContextMenu","ima","pictureInPictureToggle","playedEventPercents","playedEventTimes","playlistWidget","profile","qualitySelector","queryParams","seekThumbnails","showJumpControls","videoConfig"]),n=["api_secret","auth_token","cdn_subdomain","cloud_name","cname","private_cdn","secure","secure_cdn_subdomain","secure_distribution","shorten","sign_url","url_suffix","use_root_path"],a="cld-fluid",o={ALWAYS:"always",ON_SCROLL:"on-scroll",NEVER:"never"},l={LEFT:"left",RIGHT:"right",NONE:"none"},h={FIRST_VIDEO:"first-video",EVERY_VIDEO:"every-video"},c={AUTO:"auto",METADATA:"metadata",NONE:"none"},d={FILL:"fill",PAD:"pad",SMART:"smart"}},7764:(t,e,s)=>{s.d(e,{eo:()=>g,Wi:()=>v,iG:()=>y,T4:()=>m,go:()=>_,DS:()=>b});var i=s(6673),r=s.n(i),n=s(7171),a=s.n(n),o=s(5104),l=s(608),h=s(7571),c=s.n(h),d=s(5072),u=s.n(d),p=s(3337),f=s.n(p);const g=(t,e)=>t.addRemoteTextTrack({kind:"metadata",srclang:"en",src:e,default:!0},!0).track,m=t=>t.class.indexOf("cld-video-player-skin-light")>-1||"light"===t.skin,y=t=>{if(c()(t)){let e=t;0===e.indexOf("#")&&(e=e.slice(1));try{t=document.querySelector(`#${f()(e)}`)||r().getPlayer(e)}catch(e){t=null}if(!t)throw new Error(`Could not find element with id ${e}`)}if(!t.tagName)throw new Error("Must specify either an element or an element id.");if("VIDEO"!==t.tagName)throw new Error("Element is not a video tag.");return t},v=(t,e)=>{const s=o.A.normalizeAttributes(t);if((r().dom.hasClass(t,l.gi)||r().dom.hasClass(t,"vjs-fluid"))&&(e.fluid=!0),!e.cloudinaryConfig){const t=a()((t=>{let e={};for(const s of Object.keys(t))e[u()(s)]=t[s];return e})(e),l._V);Object.keys(t).length>0&&(e.cloudinaryConfig=t)}return r().obj.merge({},s,e)},b=t=>{const e=Object.assign({},t);(t=>{const e=t.autoplayMode;if(e)switch(e){case l.HJ.ALWAYS:t.autoplay=!0;break;case l.HJ.ON_SCROLL:case l.HJ.NEVER:default:t.autoplay=!1}})(e);const s=o.A.sliceAndUnsetProperties(e,...l.jK);return s.cloudinary=o.A.sliceAndUnsetProperties(s,...l._V),s.cloudinaryConfig&&(Object.assign(s.cloudinary,s.cloudinaryConfig),delete s.cloudinaryConfig),s.sourceOptions=o.A.sliceAndUnsetProperties(s,...l.LU),e.videojs&&(Object.assign(e,e.videojs),delete e.videojs),s.sourceOptions?.aspectRatio&&(e.aspectRatio=s.sourceOptions.aspectRatio),{playerOptions:s,videojsOptions:e}},_=()=>{let t=r().getComponent("Player").prototype.options_.children;-1===t.indexOf("titleBar")&&t.push("titleBar");const e=r().getComponent("ControlBar");e&&(t=e.prototype.options_.children,t.splice(t.indexOf("progressControl"),0,"spacer","progressControlEventsBlocker"),t.splice(t.indexOf("playToggle"),1,"playToggle","JumpBackButton","JumpForwardButton"),t.splice(t.indexOf("chaptersButton"),1,"sourceSwitcherButton","chaptersButton"),t.push("logoButton"),t.splice(t.indexOf("skipForward"),1),t.splice(t.indexOf("skipBackward"),1))}},4138:t=>{self,t.exports=(()=>{var t={805:t=>{t.exports=r,t.exports.isMobile=r,t.exports.default=r;const e=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,s=/CrOS/,i=/android|ipad|playbook|silk/i;function r(t){t||(t={});let r=t.ua;if(r||"undefined"==typeof navigator||(r=navigator.userAgent),r&&r.headers&&"string"==typeof r.headers["user-agent"]&&(r=r.headers["user-agent"]),"string"!=typeof r)return!1;let n=e.test(r)&&!s.test(r)||!!t.tablet&&i.test(r);return!n&&t.tablet&&t.featureDetect&&navigator&&navigator.maxTouchPoints>1&&-1!==r.indexOf("Macintosh")&&-1!==r.indexOf("Safari")&&(n=!0),n}}},e={};function s(i){var r=e[i];if(void 0!==r)return r.exports;var n=e[i]={exports:{}};return t[i](n,n.exports,s),n.exports}s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{s.r(i),s.d(i,{connectCloudinaryAnalytics:()=>G});var t=s(805),e="pause",r="viewStart",n="viewEnd";function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}var o=function(t){return null!==t&&"object"===a(t)&&"string"==typeof t.cloudName&&t.cloudName&&"string"==typeof t.publicId&&t.publicId?{cloudName:t.cloudName,publicId:t.publicId}:null},l=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,h="native",c=[h,"cloudinary video player"],d=function(t){return c.includes(t)?t:h},u=function(t){return"string"==typeof t&&l.test(t)?t:null};function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,i=Array(e);s<e;s++)i[s]=t[s];return i}function g(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),s.push.apply(s,i)}return s}function m(t){for(var e=1;e<arguments.length;e++){var s=null!=arguments[e]?arguments[e]:{};e%2?g(Object(s),!0).forEach(function(e){y(t,e,s[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):g(Object(s)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(s,e))})}return t}function y(t,e,s){return(e=function(t){var e=function(t){if("object"!=p(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var s=e.call(t,"string");if("object"!=p(s))return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==p(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}var v=function(t,e){var s=function(t){var e="function"==typeof t?t():t;if("object"===a(e)&&null!==e&&!Array.isArray(e)){var s=function(t){return Array.from({length:5}).reduce(function(e,s,i){var r="customData".concat(i+1);return"string"==typeof t[r]&&(e[r]=t[r]),e},{})}(e);return Object.keys(s).length>0?s:null}return null}(null==e?void 0:e.customData),i=function(t){return null!==t&&JSON.stringify(t).length<=1e3}(s),n=null!=e&&e.customVideoUrlFallback?function(t,e){try{var s=e(t);return{cloudName:s.cloudName,publicId:s.publicId}}catch(t){return null}}(t.videoUrl,e.customVideoUrlFallback):null,l=o(n);return _(r,m(m({},t),{},{analyticsModuleVersion:"1.8.2",videoPlayer:{type:d(null==e?void 0:e.videoPlayerType),version:u(null==e?void 0:e.videoPlayerVersion)},customerData:m(m({},i?{providedData:s}:{}),l?{videoData:l}:{})}))},b=function(){return _(n,m({},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}))},_=function(t,e){return{eventName:t,eventTime:Date.now(),eventDetails:e}},T=function(t){var e=function(t){return function(t){if(Array.isArray(t))return f(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return f(t,e);var s={}.toString.call(t).slice(8,-1);return"Object"===s&&t.constructor&&(s=t.constructor.name),"Map"===s||"Set"===s?Array.from(t):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?f(t,e):void 0}}(t)||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.")}()}(t);return JSON.stringify(e)};function A(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,i=Array(e);s<e;s++)i[s]=t[s];return i}var E=function(t){var s={},i={};return function(){var r=null,n=[],a=function(t,e){if(!r)throw new Error("Events collector session not started");i[r].push(_(t,e))};return{flushEvents:function(){var t;if(!r)throw new Error("Events collector session not started");var e=i[r].splice(0,i[r].length);return(t=s[r]).splice.apply(t,[s[r].length,0].concat(function(t){return function(t){if(Array.isArray(t))return A(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return A(t,e);var s={}.toString.call(t).slice(8,-1);return"Object"===s&&t.constructor&&(s=t.constructor.name),"Map"===s||"Set"===s?Array.from(t):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?A(t,e):void 0}}(t)||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.")}()}(e))),e},getCollectedEventsCount:function(){var t;return r&&(null===(t=i[r])||void 0===t?void 0:t.length)||0},addEvent:function(t){var e=t.eventName,s=t.eventDetails;return a(e,s)},start:function(o){if(r)throw new Error("Events collector session already started");s[r=o]=[],i[r]=[],n.push(function(t,e){var s=t.onPlay(function(){e("play",{})});return function(){s()}}(t,a),function(t,s){var i=t.onPause(function(){s(e,{})}),r=t.onEmptied(function(){s(e,{})});return function(){i(),r()}}(t,a),function(t,e){var s=function(){var s,i;e("loadMetadata",{videoDuration:(s=t.getDuration(),i=Number.isNaN(s)?null:s,Number.POSITIVE_INFINITY===i?"Infinity":i),videoUrl:t.getCurrentSrc()})},i=t.onLoadedMetadata(function(){return s()});return t.getReadyState()>0&&setTimeout(function(){return s()},0),function(){i()}}(t,a))},destroy:function(){if(!r)throw new Error("Events collector session not started");n.forEach(function(t){return t()}),r=null}}}};const S={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let C;const k=new Uint8Array(16);function w(){if(!C&&(C="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!C))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return C(k)}const L=[];for(let t=0;t<256;++t)L.push((t+256).toString(16).slice(1));const I=function(t,e,s){if(S.randomUUID&&!e&&!t)return S.randomUUID();const i=(t=t||{}).random||(t.rng||w)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,e){s=s||0;for(let t=0;t<16;++t)e[s+t]=i[t];return e}return function(t,e=0){return(L[t[e+0]]+L[t[e+1]]+L[t[e+2]]+L[t[e+3]]+"-"+L[t[e+4]]+L[t[e+5]]+"-"+L[t[e+6]]+L[t[e+7]]+"-"+L[t[e+8]]+L[t[e+9]]+"-"+L[t[e+10]]+L[t[e+11]]+L[t[e+12]]+L[t[e+13]]+L[t[e+14]]+L[t[e+15]]).toLowerCase()}(i)};var P="cld-analytics-user-id",x=function(){return I().replace(/-/g,"")},R=function(t,e){var s=Object.keys(e).reduce(function(t,s){return t.append(s,e[s]),t},new FormData);return"function"!=typeof window.navigator.sendBeacon?window.fetch(t,{method:"POST",mode:"no-cors",body:s,keepalive:!0}):window.navigator.sendBeacon(t,s)};function D(t){return D="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},D(t)}var O=function(t,e){if(!t.isValid)throw e?"".concat(e,":")+"\n\n"+t.errorMessage:t.errorMessage},M=function(t){return t&&"object"!==D(t)?{isValid:!1,errorMessage:"Options property must be an object"}:{isValid:!0}},F=function(t,e,s){return t.addEventListener(e,s),function(){t.removeEventListener(e,s)}},N=function(t,e){return e?B(t):j(t)},B=function(t){var e=t.onPageViewStart,s=t.onPageViewEnd,i=function(){"visible"===document.visibilityState?null==e||e():"hidden"===document.visibilityState&&(null==s||s())};return document.addEventListener("visibilitychange",i),"visible"===document.visibilityState&&(null==e||e()),function(){document.removeEventListener("visibilitychange",i)}},j=function(t){var e=t.onPageViewStart,s=t.onPageViewEnd,i=function(){return null==e?void 0:e()},r=function(){return null==s?void 0:s()};return"complete"===document.readyState?i():window.addEventListener("load",i),window.addEventListener("beforeunload",r),function(){window.removeEventListener("load",i),window.removeEventListener("beforeunload",r)}};function $(t){return function(t){if(Array.isArray(t))return U(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return U(t,e);var s={}.toString.call(t).slice(8,-1);return"Object"===s&&t.constructor&&(s=t.constructor.name),"Map"===s||"Set"===s?Array.from(t):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?U(t,e):void 0}}(t)||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 U(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,i=Array(e);s<e;s++)i[s]=t[s];return i}var H="https://video-analytics-api.cloudinary.com/v1/video-analytics",V="https://video-analytics-api.cloudinary.com/v1/live-streams",G=function(e){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};O(function(t){return t&&"object"!==D(t)?{isValid:!1,errorMessage:"Options property must be an object"}:{isValid:!0}}(s),"Cloudinary video analytics requires proper options object"),s.playerAdapter||(s.playerAdapter=function(t){return{onCanPlay:function(e){return F(t,"canplay",e)},onCanPlayThrough:function(e){return F(t,"canplaythrough",e)},onComplete:function(e){return F(t,"complete",e)},onDurationChange:function(e){return F(t,"durationchange",e)},onEmptied:function(e){return F(t,"emptied",e)},onEnded:function(e){return F(t,"ended",e)},onError:function(e){return F(t,"error",e)},onLoadedData:function(e){return F(t,"loadeddata",e)},onLoadedMetadata:function(e){return F(t,"loadedmetadata",e)},onLoadStart:function(e){return F(t,"loadstart",e)},onPause:function(e){return F(t,"pause",e)},onPlay:function(e){return F(t,"play",e)},onPlaying:function(e){return F(t,"playing",e)},onProgress:function(e){return F(t,"progress",e)},onRateChange:function(e){return F(t,"ratechange",e)},onSeeked:function(e){return F(t,"seeked",e)},onSeeking:function(e){return F(t,"seeking",e)},onStalled:function(e){return F(t,"stalled",e)},onSuspend:function(e){return F(t,"suspend",e)},onTimeUpdate:function(e){return F(t,"timeupdate",e)},onVolumeChange:function(e){return F(t,"volumechange",e)},onWaiting:function(e){return F(t,"waiting",e)},getCurrentSrc:function(){return t.currentSrc},getCurrentTime:function(){return t.currentTime},getReadyState:function(){return t.readyState},getDuration:function(){return t.duration}}}(e));var i=null,a=function(){var t=window.localStorage.getItem(P);if(t)return t;var e=I().replace(/-/g,"");return window.localStorage.setItem(P,e),e}(),l=s.playerAdapter,h=(0,t.isMobile)({tablet:!0,featureDetect:!0}),c=E(l),p=function(){i&&(i.clear(),i=null)},f={_value:x(),getValue:function(){return f._value},regenerateValue:function(){return f._value=x(),i&&(i.viewId=f._value),f._value}};return{startManualTracking:function(t){var e,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("auto"===(null===(e=i)||void 0===e?void 0:e.type))throw"Cloudinary video analytics auto tracking is already connected with this HTML Video Element, to start manual tracking you need to stop auto tracking";O(function(t){return"object"!==D(t)?{isValid:!1,errorMessage:"Metadata param needs to be an object"}:"string"!=typeof t.cloudName?{isValid:!1,errorMessage:"You need to provide proper cloud name of your Cloudinary account [cloudName: string]"}:"string"==typeof t.type&&"live"!==t.type?{isValid:!1,errorMessage:'Property "type" can be either undefined or "live" value'}:"string"!=typeof t.publicId?"live"===t.type?{isValid:!1,errorMessage:"You need to provide proper public ID of your Live Stream output"}:{isValid:!1,errorMessage:"You need to provide proper video public ID of your video on your Cloudinary cloud [videoPublicId: string]"}:{isValid:!0}}(t),"Cloudinary video analytics manual tracking called without necessary data"),O(M(s),"Cloudinary video analytics manual tracking called with invalid options"),p(),"live"===t.type?function(t,e){var s=o(t),l=function(t){R(V,{userId:a,viewId:f.getValue(),events:T([t])})},c=N({onPageViewStart:function(){var t;f.regenerateValue(),l((t=e,_(r,m(m({},{liveStreamData:s}),{},{analyticsModuleVersion:"1.8.2",videoPlayer:{type:d(null==t?void 0:t.videoPlayerType),version:u(null==t?void 0:t.videoPlayerVersion)}}))))},onPageViewEnd:function(){l(_(n,m({},{liveStreamData:s})))}},h);i={viewId:f.getValue(),type:"manual",subtype:"live-stream",clear:function(){c()}}}(t,s):(s.customVideoUrlFallback=s.customVideoUrlFallback||function(){return t},function(t,e){var s=c(),r=function(){if(s.getCollectedEventsCount()>0){s.addEvent(b());var t=T($(s.flushEvents()));e={userId:a,viewId:f.getValue(),events:t},R(H,e)}var e},n=N({onPageViewStart:function(){f.regenerateValue(),s.start(f.getValue()),s.addEvent(v({videoUrl:l.getCurrentSrc(),trackingType:"manual"},e))},onPageViewEnd:function(){r(),s.destroy()}},h);i={viewId:f,type:"manual",subtype:"default",clear:function(){r(),s.destroy(),n()}}}(0,s))},stopManualTracking:p,startAutoTracking:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(i)throw"Cloudinary video analytics tracking is already connected with this HTML Video Element";O(M(t),"Cloudinary video analytics auto tracking called with invalid options");var e=c(),s=function(){if(e.getCollectedEventsCount()>0){e.addEvent(b());var t=T($(e.flushEvents()));s={userId:a,viewId:f.getValue(),events:t},R(H,s)}var s},r=function(){var r=l.getCurrentSrc();if(r===window.location.href||!r)return null;f.regenerateValue(),e.start(f.getValue()),e.addEvent(v({videoUrl:r,trackingType:"auto"},t)),i={viewId:f,type:"auto",clear:function(){s(),e.destroy()}}};N({onPageViewStart:function(){return r()},onPageViewEnd:function(){s(),e.destroy()}},h),l.onLoadStart(function(){return!i&&r()}),l.onEmptied(function(){return p()})}}}})(),i})()},3337:function(t,e,s){var i;i=void 0!==s.g?s.g:this,t.exports=function(t){if(t.CSS&&t.CSS.escape)return t.CSS.escape;var e=function(t){if(0==arguments.length)throw new TypeError("`CSS.escape` requires an argument.");for(var e,s=String(t),i=s.length,r=-1,n="",a=s.charCodeAt(0);++r<i;)0!=(e=s.charCodeAt(r))?n+=e>=1&&e<=31||127==e||0==r&&e>=48&&e<=57||1==r&&e>=48&&e<=57&&45==a?"\\"+e.toString(16)+" ":0==r&&1==i&&45==e||!(e>=128||45==e||95==e||e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122)?"\\"+s.charAt(r):s.charAt(r):n+="�";return n};return t.CSS||(t.CSS={}),t.CSS.escape=e,e}(i)},6827:t=>{var e,s="object"==typeof Reflect?Reflect:null,i=s&&"function"==typeof s.apply?s.apply:function(t,e,s){return Function.prototype.apply.call(t,e,s)};e=s&&"function"==typeof s.ownKeys?s.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var r=Number.isNaN||function(t){return t!=t};function n(){n.init.call(this)}t.exports=n,t.exports.once=function(t,e){return new Promise(function(s,i){function r(s){t.removeListener(e,n),i(s)}function n(){"function"==typeof t.removeListener&&t.removeListener("error",r),s([].slice.call(arguments))}g(t,e,n,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&g(t,"error",e,{once:!0})}(t,r)})},n.EventEmitter=n,n.prototype._events=void 0,n.prototype._eventsCount=0,n.prototype._maxListeners=void 0;var a=10;function o(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function l(t){return void 0===t._maxListeners?n.defaultMaxListeners:t._maxListeners}function h(t,e,s,i){var r,n,a,h;if(o(s),void 0===(n=t._events)?(n=t._events=Object.create(null),t._eventsCount=0):(void 0!==n.newListener&&(t.emit("newListener",e,s.listener?s.listener:s),n=t._events),a=n[e]),void 0===a)a=n[e]=s,++t._eventsCount;else if("function"==typeof a?a=n[e]=i?[s,a]:[a,s]:i?a.unshift(s):a.push(s),(r=l(t))>0&&a.length>r&&!a.warned){a.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=t,c.type=e,c.count=a.length,h=c,console&&console.warn&&console.warn(h)}return t}function c(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,s){var i={fired:!1,wrapFn:void 0,target:t,type:e,listener:s},r=c.bind(i);return r.listener=s,i.wrapFn=r,r}function u(t,e,s){var i=t._events;if(void 0===i)return[];var r=i[e];return void 0===r?[]:"function"==typeof r?s?[r.listener||r]:[r]:s?function(t){for(var e=new Array(t.length),s=0;s<e.length;++s)e[s]=t[s].listener||t[s];return e}(r):f(r,r.length)}function p(t){var e=this._events;if(void 0!==e){var s=e[t];if("function"==typeof s)return 1;if(void 0!==s)return s.length}return 0}function f(t,e){for(var s=new Array(e),i=0;i<e;++i)s[i]=t[i];return s}function g(t,e,s,i){if("function"==typeof t.on)i.once?t.once(e,s):t.on(e,s);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function r(n){i.once&&t.removeEventListener(e,r),s(n)})}}Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return a},set:function(t){if("number"!=typeof t||t<0||r(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");a=t}}),n.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},n.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||r(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},n.prototype.getMaxListeners=function(){return l(this)},n.prototype.emit=function(t){for(var e=[],s=1;s<arguments.length;s++)e.push(arguments[s]);var r="error"===t,n=this._events;if(void 0!==n)r=r&&void 0===n.error;else if(!r)return!1;if(r){var a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var o=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw o.context=a,o}var l=n[t];if(void 0===l)return!1;if("function"==typeof l)i(l,this,e);else{var h=l.length,c=f(l,h);for(s=0;s<h;++s)i(c[s],this,e)}return!0},n.prototype.addListener=function(t,e){return h(this,t,e,!1)},n.prototype.on=n.prototype.addListener,n.prototype.prependListener=function(t,e){return h(this,t,e,!0)},n.prototype.once=function(t,e){return o(e),this.on(t,d(this,t,e)),this},n.prototype.prependOnceListener=function(t,e){return o(e),this.prependListener(t,d(this,t,e)),this},n.prototype.removeListener=function(t,e){var s,i,r,n,a;if(o(e),void 0===(i=this._events))return this;if(void 0===(s=i[t]))return this;if(s===e||s.listener===e)0===--this._eventsCount?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,s.listener||e));else if("function"!=typeof s){for(r=-1,n=s.length-1;n>=0;n--)if(s[n]===e||s[n].listener===e){a=s[n].listener,r=n;break}if(r<0)return this;0===r?s.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(s,r),1===s.length&&(i[t]=s[0]),void 0!==i.removeListener&&this.emit("removeListener",t,a||e)}return this},n.prototype.off=n.prototype.removeListener,n.prototype.removeAllListeners=function(t){var e,s,i;if(void 0===(s=this._events))return this;if(void 0===s.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==s[t]&&(0===--this._eventsCount?this._events=Object.create(null):delete s[t]),this;if(0===arguments.length){var r,n=Object.keys(s);for(i=0;i<n.length;++i)"removeListener"!==(r=n[i])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=s[t]))this.removeListener(t,e);else if(void 0!==e)for(i=e.length-1;i>=0;i--)this.removeListener(t,e[i]);return this},n.prototype.listeners=function(t){return u(this,t,!0)},n.prototype.rawListeners=function(t){return u(this,t,!1)},n.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},n.prototype.listenerCount=p,n.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},6673:(t,e,s)=>{var i=s(9228);s(8364).videojs=i,t.exports=i},8364:(t,e,s)=>{t.exports=function(){if("object"==typeof globalThis)return globalThis;var t;try{t=this||new Function("return this")()}catch(t){if("object"==typeof window)return window;if("object"==typeof self)return self;if(void 0!==s.g)return s.g}return t}()},7509:(t,e,s)=>{var i,r=void 0!==s.g?s.g:"undefined"!=typeof window?window:{},n=s(4626);"undefined"!=typeof document?i=document:(i=r["__GLOBAL_DOCUMENT_CACHE@4"])||(i=r["__GLOBAL_DOCUMENT_CACHE@4"]=n),t.exports=i},5204:(t,e,s)=>{var i;i="undefined"!=typeof window?window:void 0!==s.g?s.g:"undefined"!=typeof self?self:{},t.exports=i},1416:(t,e,s)=>{var i=s(9138)(s(1433),"DataView");t.exports=i},9073:(t,e,s)=>{var i=s(2316),r=s(6458),n=s(2149),a=s(4297),o=s(3121);function l(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}l.prototype.clear=i,l.prototype.delete=r,l.prototype.get=n,l.prototype.has=a,l.prototype.set=o,t.exports=l},2707:(t,e,s)=>{var i=s(9714),r=s(3812),n=s(4727),a=s(8379),o=s(8291);function l(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}l.prototype.clear=i,l.prototype.delete=r,l.prototype.get=n,l.prototype.has=a,l.prototype.set=o,t.exports=l},1955:(t,e,s)=>{var i=s(9138)(s(1433),"Map");t.exports=i},369:(t,e,s)=>{var i=s(2092),r=s(9626),n=s(9925),a=s(6809),o=s(4385);function l(t){var e=-1,s=null==t?0:t.length;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}l.prototype.clear=i,l.prototype.delete=r,l.prototype.get=n,l.prototype.has=a,l.prototype.set=o,t.exports=l},2616:(t,e,s)=>{var i=s(9138)(s(1433),"Promise");t.exports=i},157:(t,e,s)=>{var i=s(9138)(s(1433),"Set");t.exports=i},6469:(t,e,s)=>{var i=s(2707),r=s(1848),n=s(7406),a=s(8569),o=s(3109),l=s(3389);function h(t){var e=this.__data__=new i(t);this.size=e.size}h.prototype.clear=r,h.prototype.delete=n,h.prototype.get=a,h.prototype.has=o,h.prototype.set=l,t.exports=h},2781:(t,e,s)=>{var i=s(1433).Symbol;t.exports=i},8944:(t,e,s)=>{var i=s(1433).Uint8Array;t.exports=i},8499:(t,e,s)=>{var i=s(9138)(s(1433),"WeakMap");t.exports=i},6701:t=>{t.exports=function(t,e,s){switch(s.length){case 0:return t.call(e);case 1:return t.call(e,s[0]);case 2:return t.call(e,s[0],s[1]);case 3:return t.call(e,s[0],s[1],s[2])}return t.apply(e,s)}},149:t=>{t.exports=function(t,e){for(var s=-1,i=null==t?0:t.length;++s<i&&!1!==e(t[s],s,t););return t}},1414:t=>{t.exports=function(t,e){for(var s=-1,i=null==t?0:t.length,r=0,n=[];++s<i;){var a=t[s];e(a,s,t)&&(n[r++]=a)}return n}},1163:(t,e,s)=>{var i=s(6204),r=s(1256),n=s(6397),a=s(492),o=s(2845),l=s(7995),h=Object.prototype.hasOwnProperty;t.exports=function(t,e){var s=n(t),c=!s&&r(t),d=!s&&!c&&a(t),u=!s&&!c&&!d&&l(t),p=s||c||d||u,f=p?i(t.length,String):[],g=f.length;for(var m in t)!e&&!h.call(t,m)||p&&("length"==m||d&&("offset"==m||"parent"==m)||u&&("buffer"==m||"byteLength"==m||"byteOffset"==m)||o(m,g))||f.push(m);return f}},4272:t=>{t.exports=function(t,e){for(var s=-1,i=null==t?0:t.length,r=Array(i);++s<i;)r[s]=e(t[s],s,t);return r}},8740:t=>{t.exports=function(t,e){for(var s=-1,i=e.length,r=t.length;++s<i;)t[r+s]=e[s];return t}},2814:t=>{t.exports=function(t,e,s,i){var r=-1,n=null==t?0:t.length;for(i&&n&&(s=t[++r]);++r<n;)s=e(s,t[r],r,t);return s}},9174:t=>{t.exports=function(t){return t.split("")}},8273:t=>{var e=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;t.exports=function(t){return t.match(e)||[]}},2863:(t,e,s)=>{var i=s(4772),r=s(9316),n=Object.prototype.hasOwnProperty;t.exports=function(t,e,s){var a=t[e];n.call(t,e)&&r(a,s)&&(void 0!==s||e in t)||i(t,e,s)}},8301:(t,e,s)=>{var i=s(9316);t.exports=function(t,e){for(var s=t.length;s--;)if(i(t[s][0],e))return s;return-1}},1145:(t,e,s)=>{var i=s(2083),r=s(1178);t.exports=function(t,e){return t&&i(e,r(e),t)}},4306:(t,e,s)=>{var i=s(2083),r=s(5405);t.exports=function(t,e){return t&&i(e,r(e),t)}},4772:(t,e,s)=>{var i=s(8559);t.exports=function(t,e,s){"__proto__"==e&&i?i(t,e,{configurable:!0,enumerable:!0,value:s,writable:!0}):t[e]=s}},2931:(t,e,s)=>{var i=s(6469),r=s(149),n=s(2863),a=s(1145),o=s(4306),l=s(7030),h=s(8835),c=s(859),d=s(6728),u=s(966),p=s(9697),f=s(1201),g=s(6785),m=s(3283),y=s(9181),v=s(6397),b=s(492),_=s(422),T=s(8953),A=s(3764),E=s(1178),S=s(5405),C="[object Arguments]",k="[object Function]",w="[object Object]",L={};L[C]=L["[object Array]"]=L["[object ArrayBuffer]"]=L["[object DataView]"]=L["[object Boolean]"]=L["[object Date]"]=L["[object Float32Array]"]=L["[object Float64Array]"]=L["[object Int8Array]"]=L["[object Int16Array]"]=L["[object Int32Array]"]=L["[object Map]"]=L["[object Number]"]=L[w]=L["[object RegExp]"]=L["[object Set]"]=L["[object String]"]=L["[object Symbol]"]=L["[object Uint8Array]"]=L["[object Uint8ClampedArray]"]=L["[object Uint16Array]"]=L["[object Uint32Array]"]=!0,L["[object Error]"]=L[k]=L["[object WeakMap]"]=!1,t.exports=function t(e,s,I,P,x,R){var D,O=1&s,M=2&s,F=4&s;if(I&&(D=x?I(e,P,x,R):I(e)),void 0!==D)return D;if(!T(e))return e;var N=v(e);if(N){if(D=g(e),!O)return h(e,D)}else{var B=f(e),j=B==k||"[object GeneratorFunction]"==B;if(b(e))return l(e,O);if(B==w||B==C||j&&!x){if(D=M||j?{}:y(e),!O)return M?d(e,o(D,e)):c(e,a(D,e))}else{if(!L[B])return x?e:{};D=m(e,B,O)}}R||(R=new i);var $=R.get(e);if($)return $;R.set(e,D),A(e)?e.forEach(function(i){D.add(t(i,s,I,i,e,R))}):_(e)&&e.forEach(function(i,r){D.set(r,t(i,s,I,r,e,R))});var U=N?void 0:(F?M?p:u:M?S:E)(e);return r(U||e,function(i,r){U&&(i=e[r=i]),n(D,r,t(i,s,I,r,e,R))}),D}},3508:(t,e,s)=>{var i=s(8953),r=Object.create,n=function(){function t(){}return function(e){if(!i(e))return{};if(r)return r(e);t.prototype=e;var s=new t;return t.prototype=void 0,s}}();t.exports=n},1044:(t,e,s)=>{var i=s(8740),r=s(8031);t.exports=function t(e,s,n,a,o){var l=-1,h=e.length;for(n||(n=r),o||(o=[]);++l<h;){var c=e[l];s>0&&n(c)?s>1?t(c,s-1,n,a,o):i(o,c):a||(o[o.length]=c)}return o}},7722:(t,e,s)=>{var i=s(7181),r=s(6729);t.exports=function(t,e){for(var s=0,n=(e=i(e,t)).length;null!=t&&s<n;)t=t[r(e[s++])];return s&&s==n?t:void 0}},4403:(t,e,s)=>{var i=s(8740),r=s(6397);t.exports=function(t,e,s){var n=e(t);return r(t)?n:i(n,s(t))}},7148:(t,e,s)=>{var i=s(2781),r=s(7903),n=s(1738),a=i?i.toStringTag:void 0;t.exports=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":a&&a in Object(t)?r(t):n(t)}},809:t=>{t.exports=function(t,e){return null!=t&&e in Object(t)}},9250:(t,e,s)=>{var i=s(7148),r=s(2934);t.exports=function(t){return r(t)&&"[object Arguments]"==i(t)}},4800:(t,e,s)=>{var i=s(1201),r=s(2934);t.exports=function(t){return r(t)&&"[object Map]"==i(t)}},6567:(t,e,s)=>{var i=s(8446),r=s(8092),n=s(8953),a=s(1485),o=/^\[object .+?Constructor\]$/,l=Function.prototype,h=Object.prototype,c=l.toString,d=h.hasOwnProperty,u=RegExp("^"+c.call(d).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=function(t){return!(!n(t)||r(t))&&(i(t)?u:o).test(a(t))}},7866:(t,e,s)=>{var i=s(1201),r=s(2934);t.exports=function(t){return r(t)&&"[object Set]"==i(t)}},7129:(t,e,s)=>{var i=s(7148),r=s(3330),n=s(2934),a={};a["[object Float32Array]"]=a["[object Float64Array]"]=a["[object Int8Array]"]=a["[object Int16Array]"]=a["[object Int32Array]"]=a["[object Uint8Array]"]=a["[object Uint8ClampedArray]"]=a["[object Uint16Array]"]=a["[object Uint32Array]"]=!0,a["[object Arguments]"]=a["[object Array]"]=a["[object ArrayBuffer]"]=a["[object Boolean]"]=a["[object DataView]"]=a["[object Date]"]=a["[object Error]"]=a["[object Function]"]=a["[object Map]"]=a["[object Number]"]=a["[object Object]"]=a["[object RegExp]"]=a["[object Set]"]=a["[object String]"]=a["[object WeakMap]"]=!1,t.exports=function(t){return n(t)&&r(t.length)&&!!a[i(t)]}},1452:(t,e,s)=>{var i=s(7499),r=s(9566),n=Object.prototype.hasOwnProperty;t.exports=function(t){if(!i(t))return r(t);var e=[];for(var s in Object(t))n.call(t,s)&&"constructor"!=s&&e.push(s);return e}},1491:(t,e,s)=>{var i=s(8953),r=s(7499),n=s(8201),a=Object.prototype.hasOwnProperty;t.exports=function(t){if(!i(t))return n(t);var e=r(t),s=[];for(var o in t)("constructor"!=o||!e&&a.call(t,o))&&s.push(o);return s}},6733:(t,e,s)=>{var i=s(5576),r=s(8235);t.exports=function(t,e){return i(t,e,function(e,s){return r(t,s)})}},5576:(t,e,s)=>{var i=s(7722),r=s(8230),n=s(7181);t.exports=function(t,e,s){for(var a=-1,o=e.length,l={};++a<o;){var h=e[a],c=i(t,h);s(c,h)&&r(l,n(h,t),c)}return l}},6764:t=>{t.exports=function(t){return function(e){return null==t?void 0:t[e]}}},8230:(t,e,s)=>{var i=s(2863),r=s(7181),n=s(2845),a=s(8953),o=s(6729);t.exports=function(t,e,s,l){if(!a(t))return t;for(var h=-1,c=(e=r(e,t)).length,d=c-1,u=t;null!=u&&++h<c;){var p=o(e[h]),f=s;if("__proto__"===p||"constructor"===p||"prototype"===p)return t;if(h!=d){var g=u[p];void 0===(f=l?l(g,p,u):void 0)&&(f=a(g)?g:n(e[h+1])?[]:{})}i(u,p,f),u=u[p]}return t}},7310:(t,e,s)=>{var i=s(3122),r=s(8559),n=s(4796),a=r?function(t,e){return r(t,"toString",{configurable:!0,enumerable:!1,value:i(e),writable:!0})}:n;t.exports=a},9772:t=>{t.exports=function(t,e,s){var i=-1,r=t.length;e<0&&(e=-e>r?0:r+e),(s=s>r?r:s)<0&&(s+=r),r=e>s?0:s-e>>>0,e>>>=0;for(var n=Array(r);++i<r;)n[i]=t[i+e];return n}},6204:t=>{t.exports=function(t,e){for(var s=-1,i=Array(t);++s<t;)i[s]=e(s);return i}},6584:(t,e,s)=>{var i=s(2781),r=s(4272),n=s(6397),a=s(5414),o=i?i.prototype:void 0,l=o?o.toString:void 0;t.exports=function t(e){if("string"==typeof e)return e;if(n(e))return r(e,t)+"";if(a(e))return l?l.call(e):"";var s=e+"";return"0"==s&&1/e==-1/0?"-0":s}},8812:(t,e,s)=>{var i=s(2140),r=/^\s+/;t.exports=function(t){return t?t.slice(0,i(t)+1).replace(r,""):t}},41:t=>{t.exports=function(t){return function(e){return t(e)}}},5263:(t,e,s)=>{var i=s(7181),r=s(5342),n=s(8549),a=s(6729);t.exports=function(t,e){return e=i(e,t),null==(t=n(t,e))||delete t[a(r(e))]}},7181:(t,e,s)=>{var i=s(6397),r=s(3726),n=s(3614),a=s(3506);t.exports=function(t,e){return i(t)?t:r(t,e)?[t]:n(a(t))}},9270:(t,e,s)=>{var i=s(9772);t.exports=function(t,e,s){var r=t.length;return s=void 0===s?r:s,!e&&s>=r?t:i(t,e,s)}},7177:(t,e,s)=>{var i=s(8944);t.exports=function(t){var e=new t.constructor(t.byteLength);return new i(e).set(new i(t)),e}},7030:(t,e,s)=>{t=s.nmd(t);var i=s(1433),r=e&&!e.nodeType&&e,n=r&&t&&!t.nodeType&&t,a=n&&n.exports===r?i.Buffer:void 0,o=a?a.allocUnsafe:void 0;t.exports=function(t,e){if(e)return t.slice();var s=t.length,i=o?o(s):new t.constructor(s);return t.copy(i),i}},4893:(t,e,s)=>{var i=s(7177);t.exports=function(t,e){var s=e?i(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.byteLength)}},4021:t=>{var e=/\w*$/;t.exports=function(t){var s=new t.constructor(t.source,e.exec(t));return s.lastIndex=t.lastIndex,s}},1548:(t,e,s)=>{var i=s(2781),r=i?i.prototype:void 0,n=r?r.valueOf:void 0;t.exports=function(t){return n?Object(n.call(t)):{}}},9114:(t,e,s)=>{var i=s(7177);t.exports=function(t,e){var s=e?i(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.length)}},8835:t=>{t.exports=function(t,e){var s=-1,i=t.length;for(e||(e=Array(i));++s<i;)e[s]=t[s];return e}},2083:(t,e,s)=>{var i=s(2863),r=s(4772);t.exports=function(t,e,s,n){var a=!s;s||(s={});for(var o=-1,l=e.length;++o<l;){var h=e[o],c=n?n(s[h],t[h],h,s,t):void 0;void 0===c&&(c=t[h]),a?r(s,h,c):i(s,h,c)}return s}},859:(t,e,s)=>{var i=s(2083),r=s(8876);t.exports=function(t,e){return i(t,r(t),e)}},6728:(t,e,s)=>{var i=s(2083),r=s(8355);t.exports=function(t,e){return i(t,r(t),e)}},8109:(t,e,s)=>{var i=s(1433)["__core-js_shared__"];t.exports=i},7383:(t,e,s)=>{var i=s(9270),r=s(654),n=s(4092),a=s(3506);t.exports=function(t){return function(e){e=a(e);var s=r(e)?n(e):void 0,o=s?s[0]:e.charAt(0),l=s?i(s,1).join(""):e.slice(1);return o[t]()+l}}},6983:(t,e,s)=>{var i=s(2814),r=s(3768),n=s(7385),a=RegExp("['’]","g");t.exports=function(t){return function(e){return i(n(r(e).replace(a,"")),t,"")}}},7222:(t,e,s)=>{var i=s(4679);t.exports=function(t){return i(t)?void 0:t}},8795:(t,e,s)=>{var i=s(6764)({À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"});t.exports=i},8559:(t,e,s)=>{var i=s(9138),r=function(){try{var t=i(Object,"defineProperty");return t({},"",{}),t}catch(t){}}();t.exports=r},9820:(t,e,s)=>{var i=s(3406),r=s(5265),n=s(6805);t.exports=function(t){return n(r(t,void 0,i),t+"")}},5380:(t,e,s)=>{var i="object"==typeof s.g&&s.g&&s.g.Object===Object&&s.g;t.exports=i},966:(t,e,s)=>{var i=s(4403),r=s(8876),n=s(1178);t.exports=function(t){return i(t,n,r)}},9697:(t,e,s)=>{var i=s(4403),r=s(8355),n=s(5405);t.exports=function(t){return i(t,n,r)}},5535:(t,e,s)=>{var i=s(5662);t.exports=function(t,e){var s=t.__data__;return i(e)?s["string"==typeof e?"string":"hash"]:s.map}},9138:(t,e,s)=>{var i=s(6567),r=s(6772);t.exports=function(t,e){var s=r(t,e);return i(s)?s:void 0}},3347:(t,e,s)=>{var i=s(1019)(Object.getPrototypeOf,Object);t.exports=i},7903:(t,e,s)=>{var i=s(2781),r=Object.prototype,n=r.hasOwnProperty,a=r.toString,o=i?i.toStringTag:void 0;t.exports=function(t){var e=n.call(t,o),s=t[o];try{t[o]=void 0;var i=!0}catch(t){}var r=a.call(t);return i&&(e?t[o]=s:delete t[o]),r}},8876:(t,e,s)=>{var i=s(1414),r=s(3629),n=Object.prototype.propertyIsEnumerable,a=Object.getOwnPropertySymbols,o=a?function(t){return null==t?[]:(t=Object(t),i(a(t),function(e){return n.call(t,e)}))}:r;t.exports=o},8355:(t,e,s)=>{var i=s(8740),r=s(3347),n=s(8876),a=s(3629),o=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)i(e,n(t)),t=r(t);return e}:a;t.exports=o},1201:(t,e,s)=>{var i=s(1416),r=s(1955),n=s(2616),a=s(157),o=s(8499),l=s(7148),h=s(1485),c="[object Map]",d="[object Promise]",u="[object Set]",p="[object WeakMap]",f="[object DataView]",g=h(i),m=h(r),y=h(n),v=h(a),b=h(o),_=l;(i&&_(new i(new ArrayBuffer(1)))!=f||r&&_(new r)!=c||n&&_(n.resolve())!=d||a&&_(new a)!=u||o&&_(new o)!=p)&&(_=function(t){var e=l(t),s="[object Object]"==e?t.constructor:void 0,i=s?h(s):"";if(i)switch(i){case g:return f;case m:return c;case y:return d;case v:return u;case b:return p}return e}),t.exports=_},6772:t=>{t.exports=function(t,e){return null==t?void 0:t[e]}},6866:(t,e,s)=>{var i=s(7181),r=s(1256),n=s(6397),a=s(2845),o=s(3330),l=s(6729);t.exports=function(t,e,s){for(var h=-1,c=(e=i(e,t)).length,d=!1;++h<c;){var u=l(e[h]);if(!(d=null!=t&&s(t,u)))break;t=t[u]}return d||++h!=c?d:!!(c=null==t?0:t.length)&&o(c)&&a(u,c)&&(n(t)||r(t))}},654:t=>{var e=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");t.exports=function(t){return e.test(t)}},5854:t=>{var e=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;t.exports=function(t){return e.test(t)}},2316:(t,e,s)=>{var i=s(4558);t.exports=function(){this.__data__=i?i(null):{},this.size=0}},6458:t=>{t.exports=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}},2149:(t,e,s)=>{var i=s(4558),r=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;if(i){var s=e[t];return"__lodash_hash_undefined__"===s?void 0:s}return r.call(e,t)?e[t]:void 0}},4297:(t,e,s)=>{var i=s(4558),r=Object.prototype.hasOwnProperty;t.exports=function(t){var e=this.__data__;return i?void 0!==e[t]:r.call(e,t)}},3121:(t,e,s)=>{var i=s(4558);t.exports=function(t,e){var s=this.__data__;return this.size+=this.has(t)?0:1,s[t]=i&&void 0===e?"__lodash_hash_undefined__":e,this}},6785:t=>{var e=Object.prototype.hasOwnProperty;t.exports=function(t){var s=t.length,i=new t.constructor(s);return s&&"string"==typeof t[0]&&e.call(t,"index")&&(i.index=t.index,i.input=t.input),i}},3283:(t,e,s)=>{var i=s(7177),r=s(4893),n=s(4021),a=s(1548),o=s(9114);t.exports=function(t,e,s){var l=t.constructor;switch(e){case"[object ArrayBuffer]":return i(t);case"[object Boolean]":case"[object Date]":return new l(+t);case"[object DataView]":return r(t,s);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return o(t,s);case"[object Map]":case"[object Set]":return new l;case"[object Number]":case"[object String]":return new l(t);case"[object RegExp]":return n(t);case"[object Symbol]":return a(t)}}},9181:(t,e,s)=>{var i=s(3508),r=s(3347),n=s(7499);t.exports=function(t){return"function"!=typeof t.constructor||n(t)?{}:i(r(t))}},8031:(t,e,s)=>{var i=s(2781),r=s(1256),n=s(6397),a=i?i.isConcatSpreadable:void 0;t.exports=function(t){return n(t)||r(t)||!!(a&&t&&t[a])}},2845:t=>{var e=/^(?:0|[1-9]\d*)$/;t.exports=function(t,s){var i=typeof t;return!!(s=null==s?9007199254740991:s)&&("number"==i||"symbol"!=i&&e.test(t))&&t>-1&&t%1==0&&t<s}},3726:(t,e,s)=>{var i=s(6397),r=s(5414),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,a=/^\w*$/;t.exports=function(t,e){if(i(t))return!1;var s=typeof t;return!("number"!=s&&"symbol"!=s&&"boolean"!=s&&null!=t&&!r(t))||a.test(t)||!n.test(t)||null!=e&&t in Object(e)}},5662:t=>{t.exports=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}},8092:(t,e,s)=>{var i,r=s(8109),n=(i=/[^.]+$/.exec(r&&r.keys&&r.keys.IE_PROTO||""))?"Symbol(src)_1."+i:"";t.exports=function(t){return!!n&&n in t}},7499:t=>{var e=Object.prototype;t.exports=function(t){var s=t&&t.constructor;return t===("function"==typeof s&&s.prototype||e)}},9714:t=>{t.exports=function(){this.__data__=[],this.size=0}},3812:(t,e,s)=>{var i=s(8301),r=Array.prototype.splice;t.exports=function(t){var e=this.__data__,s=i(e,t);return!(s<0||(s==e.length-1?e.pop():r.call(e,s,1),--this.size,0))}},4727:(t,e,s)=>{var i=s(8301);t.exports=function(t){var e=this.__data__,s=i(e,t);return s<0?void 0:e[s][1]}},8379:(t,e,s)=>{var i=s(8301);t.exports=function(t){return i(this.__data__,t)>-1}},8291:(t,e,s)=>{var i=s(8301);t.exports=function(t,e){var s=this.__data__,r=i(s,t);return r<0?(++this.size,s.push([t,e])):s[r][1]=e,this}},2092:(t,e,s)=>{var i=s(9073),r=s(2707),n=s(1955);t.exports=function(){this.size=0,this.__data__={hash:new i,map:new(n||r),string:new i}}},9626:(t,e,s)=>{var i=s(5535);t.exports=function(t){var e=i(this,t).delete(t);return this.size-=e?1:0,e}},9925:(t,e,s)=>{var i=s(5535);t.exports=function(t){return i(this,t).get(t)}},6809:(t,e,s)=>{var i=s(5535);t.exports=function(t){return i(this,t).has(t)}},4385:(t,e,s)=>{var i=s(5535);t.exports=function(t,e){var s=i(this,t),r=s.size;return s.set(t,e),this.size+=s.size==r?0:1,this}},9268:(t,e,s)=>{var i=s(4556);t.exports=function(t){var e=i(t,function(t){return 500===s.size&&s.clear(),t}),s=e.cache;return e}},4558:(t,e,s)=>{var i=s(9138)(Object,"create");t.exports=i},9566:(t,e,s)=>{var i=s(1019)(Object.keys,Object);t.exports=i},8201:t=>{t.exports=function(t){var e=[];if(null!=t)for(var s in Object(t))e.push(s);return e}},3685:(t,e,s)=>{t=s.nmd(t);var i=s(5380),r=e&&!e.nodeType&&e,n=r&&t&&!t.nodeType&&t,a=n&&n.exports===r&&i.process,o=function(){try{return n&&n.require&&n.require("util").types||a&&a.binding&&a.binding("util")}catch(t){}}();t.exports=o},1738:t=>{var e=Object.prototype.toString;t.exports=function(t){return e.call(t)}},1019:t=>{t.exports=function(t,e){return function(s){return t(e(s))}}},5265:(t,e,s)=>{var i=s(6701),r=Math.max;t.exports=function(t,e,s){return e=r(void 0===e?t.length-1:e,0),function(){for(var n=arguments,a=-1,o=r(n.length-e,0),l=Array(o);++a<o;)l[a]=n[e+a];a=-1;for(var h=Array(e+1);++a<e;)h[a]=n[a];return h[e]=s(l),i(t,this,h)}}},8549:(t,e,s)=>{var i=s(7722),r=s(9772);t.exports=function(t,e){return e.length<2?t:i(t,r(e,0,-1))}},1433:(t,e,s)=>{var i=s(5380),r="object"==typeof self&&self&&self.Object===Object&&self,n=i||r||Function("return this")();t.exports=n},6805:(t,e,s)=>{var i=s(7310),r=s(3983)(i);t.exports=r},3983:t=>{var e=Date.now;t.exports=function(t){var s=0,i=0;return function(){var r=e(),n=16-(r-i);if(i=r,n>0){if(++s>=800)return arguments[0]}else s=0;return t.apply(void 0,arguments)}}},1848:(t,e,s)=>{var i=s(2707);t.exports=function(){this.__data__=new i,this.size=0}},7406:t=>{t.exports=function(t){var e=this.__data__,s=e.delete(t);return this.size=e.size,s}},8569:t=>{t.exports=function(t){return this.__data__.get(t)}},3109:t=>{t.exports=function(t){return this.__data__.has(t)}},3389:(t,e,s)=>{var i=s(2707),r=s(1955),n=s(369);t.exports=function(t,e){var s=this.__data__;if(s instanceof i){var a=s.__data__;if(!r||a.length<199)return a.push([t,e]),this.size=++s.size,this;s=this.__data__=new n(a)}return s.set(t,e),this.size=s.size,this}},4092:(t,e,s)=>{var i=s(9174),r=s(654),n=s(4082);t.exports=function(t){return r(t)?n(t):i(t)}},3614:(t,e,s)=>{var i=s(9268),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,a=i(function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(r,function(t,s,i,r){e.push(i?r.replace(n,"$1"):s||t)}),e});t.exports=a},6729:(t,e,s)=>{var i=s(5414);t.exports=function(t){if("string"==typeof t||i(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}},1485:t=>{var e=Function.prototype.toString;t.exports=function(t){if(null!=t){try{return e.call(t)}catch(t){}try{return t+""}catch(t){}}return""}},2140:t=>{var e=/\s/;t.exports=function(t){for(var s=t.length;s--&&e.test(t.charAt(s)););return s}},4082:t=>{var e="\\ud800-\\udfff",s="["+e+"]",i="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",r="\\ud83c[\\udffb-\\udfff]",n="[^"+e+"]",a="(?:\\ud83c[\\udde6-\\uddff]){2}",o="[\\ud800-\\udbff][\\udc00-\\udfff]",l="(?:"+i+"|"+r+")?",h="[\\ufe0e\\ufe0f]?",c=h+l+"(?:\\u200d(?:"+[n,a,o].join("|")+")"+h+l+")*",d="(?:"+[n+i+"?",i,a,o,s].join("|")+")",u=RegExp(r+"(?="+r+")|"+d+c,"g");t.exports=function(t){return t.match(u)||[]}},5701:t=>{var e="\\ud800-\\udfff",s="\\u2700-\\u27bf",i="a-z\\xdf-\\xf6\\xf8-\\xff",r="A-Z\\xc0-\\xd6\\xd8-\\xde",n="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",a="["+n+"]",o="\\d+",l="["+s+"]",h="["+i+"]",c="[^"+e+n+o+s+i+r+"]",d="(?:\\ud83c[\\udde6-\\uddff]){2}",u="[\\ud800-\\udbff][\\udc00-\\udfff]",p="["+r+"]",f="(?:"+h+"|"+c+")",g="(?:"+p+"|"+c+")",m="(?:['’](?:d|ll|m|re|s|t|ve))?",y="(?:['’](?:D|LL|M|RE|S|T|VE))?",v="(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?",b="[\\ufe0e\\ufe0f]?",_=b+v+"(?:\\u200d(?:"+["[^"+e+"]",d,u].join("|")+")"+b+v+")*",T="(?:"+[l,d,u].join("|")+")"+_,A=RegExp([p+"?"+h+"+"+m+"(?="+[a,p,"$"].join("|")+")",g+"+"+y+"(?="+[a,p+f,"$"].join("|")+")",p+"?"+f+"+"+m,p+"+"+y,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",o,T].join("|"),"g");t.exports=function(t){return t.match(A)||[]}},3686:(t,e,s)=>{var i=s(8756),r=s(6983)(function(t,e,s){return e=e.toLowerCase(),t+(s?i(e):e)});t.exports=r},8756:(t,e,s)=>{var i=s(3506),r=s(8580);t.exports=function(t){return r(i(t).toLowerCase())}},2160:(t,e,s)=>{var i=s(6397);t.exports=function(){if(!arguments.length)return[];var t=arguments[0];return i(t)?t:[t]}},3122:t=>{t.exports=function(t){return function(){return t}}},6177:(t,e,s)=>{var i=s(8953),r=s(3664),n=s(5378),a=Math.max,o=Math.min;t.exports=function(t,e,s){var l,h,c,d,u,p,f=0,g=!1,m=!1,y=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function v(e){var s=l,i=h;return l=h=void 0,f=e,d=t.apply(i,s)}function b(t){var s=t-p;return void 0===p||s>=e||s<0||m&&t-f>=c}function _(){var t=r();if(b(t))return T(t);u=setTimeout(_,function(t){var s=e-(t-p);return m?o(s,c-(t-f)):s}(t))}function T(t){return u=void 0,y&&l?v(t):(l=h=void 0,d)}function A(){var t=r(),s=b(t);if(l=arguments,h=this,p=t,s){if(void 0===u)return function(t){return f=t,u=setTimeout(_,e),g?v(t):d}(p);if(m)return clearTimeout(u),u=setTimeout(_,e),v(p)}return void 0===u&&(u=setTimeout(_,e)),d}return e=n(e)||0,i(s)&&(g=!!s.leading,c=(m="maxWait"in s)?a(n(s.maxWait)||0,e):c,y="trailing"in s?!!s.trailing:y),A.cancel=function(){void 0!==u&&clearTimeout(u),f=0,l=p=h=u=void 0},A.flush=function(){return void 0===u?d:T(r())},A}},3768:(t,e,s)=>{var i=s(8795),r=s(3506),n=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,a=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g");t.exports=function(t){return(t=r(t))&&t.replace(n,i).replace(a,"")}},9316:t=>{t.exports=function(t,e){return t===e||t!=t&&e!=e}},3406:(t,e,s)=>{var i=s(1044);t.exports=function(t){return null!=t&&t.length?i(t,1):[]}},2832:(t,e,s)=>{var i=s(7722);t.exports=function(t,e,s){var r=null==t?void 0:i(t,e);return void 0===r?s:r}},8235:(t,e,s)=>{var i=s(809),r=s(6866);t.exports=function(t,e){return null!=t&&r(t,e,i)}},4796:t=>{t.exports=function(t){return t}},1256:(t,e,s)=>{var i=s(9250),r=s(2934),n=Object.prototype,a=n.hasOwnProperty,o=n.propertyIsEnumerable,l=i(function(){return arguments}())?i:function(t){return r(t)&&a.call(t,"callee")&&!o.call(t,"callee")};t.exports=l},6397:t=>{var e=Array.isArray;t.exports=e},8330:(t,e,s)=>{var i=s(8446),r=s(3330);t.exports=function(t){return null!=t&&r(t.length)&&!i(t)}},492:(t,e,s)=>{t=s.nmd(t);var i=s(1433),r=s(659),n=e&&!e.nodeType&&e,a=n&&t&&!t.nodeType&&t,o=a&&a.exports===n?i.Buffer:void 0,l=(o?o.isBuffer:void 0)||r;t.exports=l},9040:(t,e,s)=>{var i=s(2934),r=s(4679);t.exports=function(t){return i(t)&&1===t.nodeType&&!r(t)}},5685:(t,e,s)=>{var i=s(1452),r=s(1201),n=s(1256),a=s(6397),o=s(8330),l=s(492),h=s(7499),c=s(7995),d=Object.prototype.hasOwnProperty;t.exports=function(t){if(null==t)return!0;if(o(t)&&(a(t)||"string"==typeof t||"function"==typeof t.splice||l(t)||c(t)||n(t)))return!t.length;var e=r(t);if("[object Map]"==e||"[object Set]"==e)return!t.size;if(h(t))return!i(t).length;for(var s in t)if(d.call(t,s))return!1;return!0}},8446:(t,e,s)=>{var i=s(7148),r=s(8953);t.exports=function(t){if(!r(t))return!1;var e=i(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}},4466:(t,e,s)=>{var i=s(1826);t.exports=function(t){return"number"==typeof t&&t==i(t)}},3330:t=>{t.exports=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}},422:(t,e,s)=>{var i=s(4800),r=s(41),n=s(3685),a=n&&n.isMap,o=a?r(a):i;t.exports=o},8953:t=>{t.exports=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}},2934:t=>{t.exports=function(t){return null!=t&&"object"==typeof t}},4679:(t,e,s)=>{var i=s(7148),r=s(3347),n=s(2934),a=Function.prototype,o=Object.prototype,l=a.toString,h=o.hasOwnProperty,c=l.call(Object);t.exports=function(t){if(!n(t)||"[object Object]"!=i(t))return!1;var e=r(t);if(null===e)return!0;var s=h.call(e,"constructor")&&e.constructor;return"function"==typeof s&&s instanceof s&&l.call(s)==c}},3764:(t,e,s)=>{var i=s(7866),r=s(41),n=s(3685),a=n&&n.isSet,o=a?r(a):i;t.exports=o},7571:(t,e,s)=>{var i=s(7148),r=s(6397),n=s(2934);t.exports=function(t){return"string"==typeof t||!r(t)&&n(t)&&"[object String]"==i(t)}},5414:(t,e,s)=>{var i=s(7148),r=s(2934);t.exports=function(t){return"symbol"==typeof t||r(t)&&"[object Symbol]"==i(t)}},7995:(t,e,s)=>{var i=s(7129),r=s(41),n=s(3685),a=n&&n.isTypedArray,o=a?r(a):i;t.exports=o},1178:(t,e,s)=>{var i=s(1163),r=s(1452),n=s(8330);t.exports=function(t){return n(t)?i(t):r(t)}},5405:(t,e,s)=>{var i=s(1163),r=s(1491),n=s(8330);t.exports=function(t){return n(t)?i(t,!0):r(t)}},5342:t=>{t.exports=function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}},4556:(t,e,s)=>{var i=s(369);function r(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var s=function(){var i=arguments,r=e?e.apply(this,i):i[0],n=s.cache;if(n.has(r))return n.get(r);var a=t.apply(this,i);return s.cache=n.set(r,a)||n,a};return s.cache=new(r.Cache||i),s}r.Cache=i,t.exports=r},5114:t=>{t.exports=function(){}},3664:(t,e,s)=>{var i=s(1433);t.exports=function(){return i.Date.now()}},4319:(t,e,s)=>{var i=s(4272),r=s(2931),n=s(5263),a=s(7181),o=s(2083),l=s(7222),h=s(9820),c=s(9697),d=h(function(t,e){var s={};if(null==t)return s;var h=!1;e=i(e,function(e){return e=a(e,t),h||(h=e.length>1),e}),o(t,c(t),s),h&&(s=r(s,7,l));for(var d=e.length;d--;)n(s,e[d]);return s});t.exports=d},7171:(t,e,s)=>{var i=s(6733),r=s(9820)(function(t,e){return null==t?{}:i(t,e)});t.exports=r},5072:(t,e,s)=>{var i=s(6983)(function(t,e,s){return t+(s?"_":"")+e.toLowerCase()});t.exports=i},3629:t=>{t.exports=function(){return[]}},659:t=>{t.exports=function(){return!1}},2858:(t,e,s)=>{var i=s(6177),r=s(8953);t.exports=function(t,e,s){var n=!0,a=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return r(s)&&(n="leading"in s?!!s.leading:n,a="trailing"in s?!!s.trailing:a),i(t,e,{leading:n,maxWait:e,trailing:a})}},4764:(t,e,s)=>{var i=s(5378),r=1/0;t.exports=function(t){return t?(t=i(t))===r||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}},1826:(t,e,s)=>{var i=s(4764);t.exports=function(t){var e=i(t),s=e%1;return e==e?s?e-s:e:0}},5378:(t,e,s)=>{var i=s(8812),r=s(8953),n=s(5414),a=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,l=/^0o[0-7]+$/i,h=parseInt;t.exports=function(t){if("number"==typeof t)return t;if(n(t))return NaN;if(r(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=r(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=i(t);var s=o.test(t);return s||l.test(t)?h(t.slice(2),s?2:8):a.test(t)?NaN:+t}},3506:(t,e,s)=>{var i=s(6584);t.exports=function(t){return null==t?"":i(t)}},8580:(t,e,s)=>{var i=s(7383)("toUpperCase");t.exports=i},7385:(t,e,s)=>{var i=s(8273),r=s(5854),n=s(3506),a=s(5701);t.exports=function(t,e,s){return t=n(t),void 0===(e=s?void 0:e)?r(t)?a(t):i(t):t.match(e)||[]}},9228:function(t,e,s){t.exports=function(){var t="8.23.4";const e={},i=function(t,s){return e[t]=e[t]||[],s&&(e[t]=e[t].concat(s)),e[t]},r=function(t,s){const r=i(t).indexOf(s);return!(r<=-1||(e[t]=e[t].slice(),e[t].splice(r,1),0))},n={prefixed:!0},a=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror","fullscreen"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror","-webkit-full-screen"]],o=a[0];let l;for(let t=0;t<a.length;t++)if(a[t][1]in document){l=a[t];break}if(l){for(let t=0;t<l.length;t++)n[o[t]]=l[t];n.prefixed=l[0]!==o[0]}let h=[];const c=function t(e,s=":",i=""){let r,n="info";function a(...t){r("log",n,t)}return r=((t,e,s)=>(i,r,n)=>{const a=e.levels[r],o=new RegExp(`^(${a})$`);let l=t;if("log"!==i&&n.unshift(i.toUpperCase()+":"),s&&(l=`%c${t}`,n.unshift(s)),n.unshift(l+":"),h){h.push([].concat(n));const t=h.length-1e3;h.splice(0,t>0?t:0)}if(!window.console)return;let c=window.console[i];c||"debug"!==i||(c=window.console.info||window.console.log),c&&a&&o.test(i)&&c[Array.isArray(n)?"apply":"call"](window.console,n)})(e,a,i),a.createLogger=(r,n,a)=>{const o=void 0!==n?n:s;return t(`${e} ${o} ${r}`,o,void 0!==a?a:i)},a.createNewLogger=(e,s,i)=>t(e,s,i),a.levels={all:"debug|log|warn|error",off:"",debug:"debug|log|warn|error",info:"log|warn|error",warn:"warn|error",error:"error",DEFAULT:n},a.level=t=>{if("string"==typeof t){if(!a.levels.hasOwnProperty(t))throw new Error(`"${t}" in not a valid log level`);n=t}return n},a.history=()=>h?[].concat(h):[],a.history.filter=t=>(h||[]).filter(e=>new RegExp(`.*${t}.*`).test(e[0])),a.history.clear=()=>{h&&(h.length=0)},a.history.disable=()=>{null!==h&&(h.length=0,h=null)},a.history.enable=()=>{null===h&&(h=[])},a.error=(...t)=>r("error",n,t),a.warn=(...t)=>r("warn",n,t),a.debug=(...t)=>r("debug",n,t),a}("VIDEOJS"),d=c.createLogger,u=Object.prototype.toString,p=function(t){return m(t)?Object.keys(t):[]};function f(t,e){p(t).forEach(s=>e(t[s],s))}function g(t,e,s=0){return p(t).reduce((s,i)=>e(s,t[i],i),s)}function m(t){return!!t&&"object"==typeof t}function y(t){return m(t)&&"[object Object]"===u.call(t)&&t.constructor===Object}function v(...t){const e={};return t.forEach(t=>{t&&f(t,(t,s)=>{y(t)?(y(e[s])||(e[s]={}),e[s]=v(e[s],t)):e[s]=t})}),e}function b(t={}){const e=[];for(const s in t)if(t.hasOwnProperty(s)){const i=t[s];e.push(i)}return e}function _(t,e,s,i=!0){const r=s=>Object.defineProperty(t,e,{value:s,enumerable:!0,writable:!0}),n={configurable:!0,enumerable:!0,get(){const t=s();return r(t),t}};return i&&(n.set=r),Object.defineProperty(t,e,n)}var T=Object.freeze({__proto__:null,each:f,reduce:g,isObject:m,isPlain:y,merge:v,values:b,defineLazyProperty:_});let A,E=!1,S=null,C=!1,k=!1,w=!1,L=!1,I=!1,P=null,x=null;const R=Boolean(window.cast&&window.cast.framework&&window.cast.framework.CastReceiverContext);let D=null,O=!1,M=!1,F=!1,N=!1,B=!1,j=!1,$=!1;const U=Boolean(z()&&("ontouchstart"in window||window.navigator.maxTouchPoints||window.DocumentTouch&&window.document instanceof window.DocumentTouch)),H=window.navigator&&window.navigator.userAgentData;if(H&&H.platform&&H.brands&&(C="Android"===H.platform,w=Boolean(H.brands.find(t=>"Microsoft Edge"===t.brand)),L=Boolean(H.brands.find(t=>"Chromium"===t.brand)),I=!w&&L,P=x=(H.brands.find(t=>"Chromium"===t.brand)||{}).version||null,M="Windows"===H.platform),!L){const t=window.navigator&&window.navigator.userAgent||"";E=/iPod/i.test(t),S=function(){const e=t.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),C=/Android/i.test(t),A=function(){const e=t.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);if(!e)return null;const s=e[1]&&parseFloat(e[1]),i=e[2]&&parseFloat(e[2]);return s&&i?parseFloat(e[1]+"."+e[2]):s||null}(),k=/Firefox/i.test(t),w=/Edg/i.test(t),L=/Chrome/i.test(t)||/CriOS/i.test(t),I=!w&&L,P=x=function(){const e=t.match(/(Chrome|CriOS)\/(\d+)/);return e&&e[2]?parseFloat(e[2]):null}(),D=function(){const e=/MSIE\s(\d+)\.\d/.exec(t);let s=e&&parseFloat(e[1]);return!s&&/Trident\/7.0/i.test(t)&&/rv:11.0/.test(t)&&(s=11),s}(),B=/Tizen/i.test(t),j=/Web0S/i.test(t),$=B||j,O=/Safari/i.test(t)&&!I&&!C&&!w&&!$,M=/Windows/i.test(t),F=/iPad/i.test(t)||O&&U&&!/iPhone/i.test(t),N=/iPhone/i.test(t)&&!F}const V=N||F||E,G=(O||V)&&!I;var W=Object.freeze({__proto__:null,get IS_IPOD(){return E},get IOS_VERSION(){return S},get IS_ANDROID(){return C},get ANDROID_VERSION(){return A},get IS_FIREFOX(){return k},get IS_EDGE(){return w},get IS_CHROMIUM(){return L},get IS_CHROME(){return I},get CHROMIUM_VERSION(){return P},get CHROME_VERSION(){return x},IS_CHROMECAST_RECEIVER:R,get IE_VERSION(){return D},get IS_SAFARI(){return O},get IS_WINDOWS(){return M},get IS_IPAD(){return F},get IS_IPHONE(){return N},get IS_TIZEN(){return B},get IS_WEBOS(){return j},get IS_SMART_TV(){return $},TOUCH_ENABLED:U,IS_IOS:V,IS_ANY_SAFARI:G});function K(t){return"string"==typeof t&&Boolean(t.trim())}function z(){return document===window.document}function q(t){return m(t)&&1===t.nodeType}function Y(){try{return window.parent!==window.self}catch(t){return!0}}function X(t){return function(e,s){if(!K(e))return document[t](null);K(s)&&(s=document.querySelector(s));const i=q(s)?s:document;return i[t]&&i[t](e)}}function Q(t="div",e={},s={},i){const r=document.createElement(t);return Object.getOwnPropertyNames(e).forEach(function(t){const s=e[t];"textContent"===t?Z(r,s):r[t]===s&&"tabIndex"!==t||(r[t]=s)}),Object.getOwnPropertyNames(s).forEach(function(t){r.setAttribute(t,s[t])}),i&&yt(r,i),r}function Z(t,e){return void 0===t.textContent?t.innerText=e:t.textContent=e,t}function J(t,e){e.firstChild?e.insertBefore(t,e.firstChild):e.appendChild(t)}function tt(t,e){return function(t){if(t.indexOf(" ")>=0)throw new Error("class has illegal whitespace characters")}(e),t.classList.contains(e)}function et(t,...e){return t.classList.add(...e.reduce((t,e)=>t.concat(e.split(/\s+/)),[])),t}function st(t,...e){return t?(t.classList.remove(...e.reduce((t,e)=>t.concat(e.split(/\s+/)),[])),t):(c.warn("removeClass was called with an element that doesn't exist"),null)}function it(t,e,s){return"function"==typeof s&&(s=s(t,e)),"boolean"!=typeof s&&(s=void 0),e.split(/\s+/).forEach(e=>t.classList.toggle(e,s)),t}function rt(t,e){Object.getOwnPropertyNames(e).forEach(function(s){const i=e[s];null==i||!1===i?t.removeAttribute(s):t.setAttribute(s,!0===i?"":i)})}function nt(t){const e={},s=["autoplay","controls","playsinline","loop","muted","default","defaultMuted"];if(t&&t.attributes&&t.attributes.length>0){const i=t.attributes;for(let t=i.length-1;t>=0;t--){const r=i[t].name;let n=i[t].value;s.includes(r)&&(n=null!==n),e[r]=n}}return e}function at(t,e){return t.getAttribute(e)}function ot(t,e,s){t.setAttribute(e,s)}function lt(t,e){t.removeAttribute(e)}function ht(){document.body.focus(),document.onselectstart=function(){return!1}}function ct(){document.onselectstart=function(){return!0}}function dt(t){if(t&&t.getBoundingClientRect&&t.parentNode){const e=t.getBoundingClientRect(),s={};return["bottom","height","left","right","top","width"].forEach(t=>{void 0!==e[t]&&(s[t]=e[t])}),s.height||(s.height=parseFloat(At(t,"height"))),s.width||(s.width=parseFloat(At(t,"width"))),s}}function ut(t){if(!t||t&&!t.offsetParent)return{left:0,top:0,width:0,height:0};const e=t.offsetWidth,s=t.offsetHeight;let i=0,r=0;for(;t.offsetParent&&t!==document[n.fullscreenElement];)i+=t.offsetLeft,r+=t.offsetTop,t=t.offsetParent;return{left:i,top:r,width:e,height:s}}function pt(t,e){const s={x:0,y:0};if(V){let e=t;for(;e&&"html"!==e.nodeName.toLowerCase();){const t=At(e,"transform");if(/^matrix/.test(t)){const e=t.slice(7,-1).split(/,\s/).map(Number);s.x+=e[4],s.y+=e[5]}else if(/^matrix3d/.test(t)){const e=t.slice(9,-1).split(/,\s/).map(Number);s.x+=e[12],s.y+=e[13]}if(e.assignedSlot&&e.assignedSlot.parentElement&&window.WebKitCSSMatrix){const t=window.getComputedStyle(e.assignedSlot.parentElement).transform,i=new window.WebKitCSSMatrix(t);s.x+=i.m41,s.y+=i.m42}e=e.parentNode||e.host}}const i={},r=ut(e.target),n=ut(t),a=n.width,o=n.height;let l=e.offsetY-(n.top-r.top),h=e.offsetX-(n.left-r.left);return e.changedTouches&&(h=e.changedTouches[0].pageX-n.left,l=e.changedTouches[0].pageY+n.top,V&&(h-=s.x,l-=s.y)),i.y=1-Math.max(0,Math.min(1,l/o)),i.x=Math.max(0,Math.min(1,h/a)),i}function ft(t){return m(t)&&3===t.nodeType}function gt(t){for(;t.firstChild;)t.removeChild(t.firstChild);return t}function mt(t){return"function"==typeof t&&(t=t()),(Array.isArray(t)?t:[t]).map(t=>("function"==typeof t&&(t=t()),q(t)||ft(t)?t:"string"==typeof t&&/\S/.test(t)?document.createTextNode(t):void 0)).filter(t=>t)}function yt(t,e){return mt(e).forEach(e=>t.appendChild(e)),t}function vt(t,e){return yt(gt(t),e)}function bt(t){return void 0===t.button&&void 0===t.buttons||0===t.button&&void 0===t.buttons||"mouseup"===t.type&&0===t.button&&0===t.buttons||"mousedown"===t.type&&0===t.button&&0===t.buttons||0===t.button&&1===t.buttons}const _t=X("querySelector"),Tt=X("querySelectorAll");function At(t,e){if(!t||!e)return"";if("function"==typeof window.getComputedStyle){let s;try{s=window.getComputedStyle(t)}catch(t){return""}return s?s.getPropertyValue(e)||s[e]:""}return""}function Et(t){[...document.styleSheets].forEach(e=>{try{const s=[...e.cssRules].map(t=>t.cssText).join(""),i=document.createElement("style");i.textContent=s,t.document.head.appendChild(i)}catch(s){const i=document.createElement("link");i.rel="stylesheet",i.type=e.type,i.media=e.media.mediaText,i.href=e.href,t.document.head.appendChild(i)}})}var St=Object.freeze({__proto__:null,isReal:z,isEl:q,isInFrame:Y,createEl:Q,textContent:Z,prependTo:J,hasClass:tt,addClass:et,removeClass:st,toggleClass:it,setAttributes:rt,getAttributes:nt,getAttribute:at,setAttribute:ot,removeAttribute:lt,blockTextSelection:ht,unblockTextSelection:ct,getBoundingClientRect:dt,findPosition:ut,getPointerPosition:pt,isTextNode:ft,emptyEl:gt,normalizeContent:mt,appendContent:yt,insertContent:vt,isSingleLeftClick:bt,$:_t,$$:Tt,computedStyle:At,copyStyleSheetsToWindow:Et});let Ct,kt=!1;const wt=function(){if(!1===Ct.options.autoSetup)return;const t=Array.prototype.slice.call(document.getElementsByTagName("video")),e=Array.prototype.slice.call(document.getElementsByTagName("audio")),s=Array.prototype.slice.call(document.getElementsByTagName("video-js")),i=t.concat(e,s);if(i&&i.length>0)for(let t=0,e=i.length;t<e;t++){const e=i[t];if(!e||!e.getAttribute){Lt(1);break}void 0===e.player&&null!==e.getAttribute("data-setup")&&Ct(e)}else kt||Lt(1)};function Lt(t,e){z()&&(e&&(Ct=e),window.setTimeout(wt,t))}function It(){kt=!0,window.removeEventListener("load",It)}z()&&("complete"===document.readyState?It():window.addEventListener("load",It));const Pt=function(t){const e=document.createElement("style");return e.className=t,e},xt=function(t,e){t.styleSheet?t.styleSheet.cssText=e:t.textContent=e};var Rt=new WeakMap;let Dt,Ot=3;function Mt(){return Ot++}function Ft(t,e){if(!Rt.has(t))return;const s=Rt.get(t);0===s.handlers[e].length&&(delete s.handlers[e],t.removeEventListener?t.removeEventListener(e,s.dispatcher,!1):t.detachEvent&&t.detachEvent("on"+e,s.dispatcher)),Object.getOwnPropertyNames(s.handlers).length<=0&&(delete s.handlers,delete s.dispatcher,delete s.disabled),0===Object.getOwnPropertyNames(s).length&&Rt.delete(t)}function Nt(t,e,s,i){s.forEach(function(s){t(e,s,i)})}function Bt(t){if(t.fixed_)return t;function e(){return!0}function s(){return!1}if(!t||!t.isPropagationStopped||!t.isImmediatePropagationStopped){const i=t||window.event;t={};const r=["layerX","layerY","keyLocation","path","webkitMovementX","webkitMovementY","mozPressure","mozInputSource"];for(const e in i)r.includes(e)||"returnValue"===e&&i.preventDefault||(t[e]=i[e]);if(t.target||(t.target=t.srcElement||document),t.relatedTarget||(t.relatedTarget=t.fromElement===t.target?t.toElement:t.fromElement),t.preventDefault=function(){i.preventDefault&&i.preventDefault(),t.returnValue=!1,i.returnValue=!1,t.defaultPrevented=!0},t.defaultPrevented=!1,t.stopPropagation=function(){i.stopPropagation&&i.stopPropagation(),t.cancelBubble=!0,i.cancelBubble=!0,t.isPropagationStopped=e},t.isPropagationStopped=s,t.stopImmediatePropagation=function(){i.stopImmediatePropagation&&i.stopImmediatePropagation(),t.isImmediatePropagationStopped=e,t.stopPropagation()},t.isImmediatePropagationStopped=s,null!==t.clientX&&void 0!==t.clientX){const e=document.documentElement,s=document.body;t.pageX=t.clientX+(e&&e.scrollLeft||s&&s.scrollLeft||0)-(e&&e.clientLeft||s&&s.clientLeft||0),t.pageY=t.clientY+(e&&e.scrollTop||s&&s.scrollTop||0)-(e&&e.clientTop||s&&s.clientTop||0)}t.which=t.charCode||t.keyCode,null!==t.button&&void 0!==t.button&&(t.button=1&t.button?0:4&t.button?1:2&t.button?2:0)}return t.fixed_=!0,t}const jt=["touchstart","touchmove"];function $t(t,e,s){if(Array.isArray(e))return Nt($t,t,e,s);Rt.has(t)||Rt.set(t,{});const i=Rt.get(t);if(i.handlers||(i.handlers={}),i.handlers[e]||(i.handlers[e]=[]),s.guid||(s.guid=Mt()),i.handlers[e].push(s),i.dispatcher||(i.disabled=!1,i.dispatcher=function(e,s){if(i.disabled)return;e=Bt(e);const r=i.handlers[e.type];if(r){const i=r.slice(0);for(let r=0,n=i.length;r<n&&!e.isImmediatePropagationStopped();r++)try{i[r].call(t,e,s)}catch(t){c.error(t)}}}),1===i.handlers[e].length)if(t.addEventListener){let s=!1;(function(){if("boolean"!=typeof Dt){Dt=!1;try{const t=Object.defineProperty({},"passive",{get(){Dt=!0}});window.addEventListener("test",null,t),window.removeEventListener("test",null,t)}catch(t){}}return Dt})()&&jt.indexOf(e)>-1&&(s={passive:!0}),t.addEventListener(e,i.dispatcher,s)}else t.attachEvent&&t.attachEvent("on"+e,i.dispatcher)}function Ut(t,e,s){if(!Rt.has(t))return;const i=Rt.get(t);if(!i.handlers)return;if(Array.isArray(e))return Nt(Ut,t,e,s);const r=function(t,e){i.handlers[e]=[],Ft(t,e)};if(void 0===e){for(const e in i.handlers)Object.prototype.hasOwnProperty.call(i.handlers||{},e)&&r(t,e);return}const n=i.handlers[e];if(n)if(s){if(s.guid)for(let t=0;t<n.length;t++)n[t].guid===s.guid&&n.splice(t--,1);Ft(t,e)}else r(t,e)}function Ht(t,e,s){const i=Rt.has(t)?Rt.get(t):{},r=t.parentNode||t.ownerDocument;if("string"==typeof e?e={type:e,target:t}:e.target||(e.target=t),e=Bt(e),i.dispatcher&&i.dispatcher.call(t,e,s),r&&!e.isPropagationStopped()&&!0===e.bubbles)Ht.call(null,r,e,s);else if(!r&&!e.defaultPrevented&&e.target&&e.target[e.type]){Rt.has(e.target)||Rt.set(e.target,{});const t=Rt.get(e.target);e.target[e.type]&&(t.disabled=!0,"function"==typeof e.target[e.type]&&e.target[e.type](),t.disabled=!1)}return!e.defaultPrevented}function Vt(t,e,s){if(Array.isArray(e))return Nt(Vt,t,e,s);const i=function(){Ut(t,e,i),s.apply(this,arguments)};i.guid=s.guid=s.guid||Mt(),$t(t,e,i)}function Gt(t,e,s){const i=function(){Ut(t,e,i),s.apply(this,arguments)};i.guid=s.guid=s.guid||Mt(),$t(t,e,i)}var Wt=Object.freeze({__proto__:null,fixEvent:Bt,on:$t,off:Ut,trigger:Ht,one:Vt,any:Gt});const Kt=30,zt=function(t,e,s){e.guid||(e.guid=Mt());const i=e.bind(t);return i.guid=s?s+"_"+e.guid:e.guid,i},qt=function(t,e){let s=window.performance.now();return function(...i){const r=window.performance.now();r-s>=e&&(t(...i),s=r)}},Yt=function(t,e,s,i=window){let r;const n=function(){const n=this,a=arguments;let o=function(){r=null,o=null,s||t.apply(n,a)};!r&&s&&t.apply(n,a),i.clearTimeout(r),r=i.setTimeout(o,e)};return n.cancel=()=>{i.clearTimeout(r),r=null},n};var Xt=Object.freeze({__proto__:null,UPDATE_REFRESH_INTERVAL:Kt,bind_:zt,throttle:qt,debounce:Yt});let Qt;class Zt{on(t,e){const s=this.addEventListener;this.addEventListener=()=>{},$t(this,t,e),this.addEventListener=s}off(t,e){Ut(this,t,e)}one(t,e){const s=this.addEventListener;this.addEventListener=()=>{},Vt(this,t,e),this.addEventListener=s}any(t,e){const s=this.addEventListener;this.addEventListener=()=>{},Gt(this,t,e),this.addEventListener=s}trigger(t){const e=t.type||t;"string"==typeof t&&(t={type:e}),t=Bt(t),this.allowedEvents_[e]&&this["on"+e]&&this["on"+e](t),Ht(this,t)}queueTrigger(t){Qt||(Qt=new Map);const e=t.type||t;let s=Qt.get(this);s||(s=new Map,Qt.set(this,s));const i=s.get(e);s.delete(e),window.clearTimeout(i);const r=window.setTimeout(()=>{s.delete(e),0===s.size&&(s=null,Qt.delete(this)),this.trigger(t)},0);s.set(e,r)}}Zt.prototype.allowedEvents_={},Zt.prototype.addEventListener=Zt.prototype.on,Zt.prototype.removeEventListener=Zt.prototype.off,Zt.prototype.dispatchEvent=Zt.prototype.trigger;const Jt=t=>"function"==typeof t.name?t.name():"string"==typeof t.name?t.name:t.name_?t.name_:t.constructor&&t.constructor.name?t.constructor.name:typeof t,te=t=>t instanceof Zt||!!t.eventBusEl_&&["on","one","off","trigger"].every(e=>"function"==typeof t[e]),ee=t=>"string"==typeof t&&/\S/.test(t)||Array.isArray(t)&&!!t.length,se=(t,e,s)=>{if(!t||!t.nodeName&&!te(t))throw new Error(`Invalid target for ${Jt(e)}#${s}; must be a DOM node or evented object.`)},ie=(t,e,s)=>{if(!ee(t))throw new Error(`Invalid event type for ${Jt(e)}#${s}; must be a non-empty string or array.`)},re=(t,e,s)=>{if("function"!=typeof t)throw new Error(`Invalid listener for ${Jt(e)}#${s}; must be a function.`)},ne=(t,e,s)=>{const i=e.length<3||e[0]===t||e[0]===t.eventBusEl_;let r,n,a;return i?(r=t.eventBusEl_,e.length>=3&&e.shift(),[n,a]=e):(r=e[0],n=e[1],a=e[2]),se(r,t,s),ie(n,t,s),re(a,t,s),a=zt(t,a),{isTargetingSelf:i,target:r,type:n,listener:a}},ae=(t,e,s,i)=>{se(t,t,e),t.nodeName?Wt[e](t,s,i):t[e](s,i)},oe={on(...t){const{isTargetingSelf:e,target:s,type:i,listener:r}=ne(this,t,"on");if(ae(s,"on",i,r),!e){const t=()=>this.off(s,i,r);t.guid=r.guid;const e=()=>this.off("dispose",t);e.guid=r.guid,ae(this,"on","dispose",t),ae(s,"on","dispose",e)}},one(...t){const{isTargetingSelf:e,target:s,type:i,listener:r}=ne(this,t,"one");if(e)ae(s,"one",i,r);else{const t=(...e)=>{this.off(s,i,t),r.apply(null,e)};t.guid=r.guid,ae(s,"one",i,t)}},any(...t){const{isTargetingSelf:e,target:s,type:i,listener:r}=ne(this,t,"any");if(e)ae(s,"any",i,r);else{const t=(...e)=>{this.off(s,i,t),r.apply(null,e)};t.guid=r.guid,ae(s,"any",i,t)}},off(t,e,s){if(!t||ee(t))Ut(this.eventBusEl_,t,e);else{const i=t,r=e;se(i,this,"off"),ie(r,this,"off"),re(s,this,"off"),s=zt(this,s),this.off("dispose",s),i.nodeName?(Ut(i,r,s),Ut(i,"dispose",s)):te(i)&&(i.off(r,s),i.off("dispose",s))}},trigger(t,e){se(this.eventBusEl_,this,"trigger");const s=t&&"string"!=typeof t?t.type:t;if(!ee(s))throw new Error(`Invalid event type for ${Jt(this)}#trigger; must be a non-empty string or object with a type key that has a non-empty value.`);return Ht(this.eventBusEl_,t,e)}};function le(t,e={}){const{eventBusKey:s}=e;if(s){if(!t[s].nodeName)throw new Error(`The eventBusKey "${s}" does not refer to an element.`);t.eventBusEl_=t[s]}else t.eventBusEl_=Q("span",{className:"vjs-event-bus"});return Object.assign(t,oe),t.eventedCallbacks&&t.eventedCallbacks.forEach(t=>{t()}),t.on("dispose",()=>{t.off(),[t,t.el_,t.eventBusEl_].forEach(function(t){t&&Rt.has(t)&&Rt.delete(t)}),window.setTimeout(()=>{t.eventBusEl_=null},0)}),t}const he={state:{},setState(t){let e;return"function"==typeof t&&(t=t()),f(t,(t,s)=>{this.state[s]!==t&&(e=e||{},e[s]={from:this.state[s],to:t}),this.state[s]=t}),e&&te(this)&&this.trigger({changes:e,type:"statechanged"}),e}};function ce(t,e){return Object.assign(t,he),t.state=Object.assign({},t.state,e),"function"==typeof t.handleStateChanged&&te(t)&&t.on("statechanged",t.handleStateChanged),t}const de=function(t){return"string"!=typeof t?t:t.replace(/./,t=>t.toLowerCase())},ue=function(t){return"string"!=typeof t?t:t.replace(/./,t=>t.toUpperCase())},pe=function(t,e){return ue(t)===ue(e)};var fe=Object.freeze({__proto__:null,toLowerCase:de,toTitleCase:ue,titleCaseEquals:pe});class ge{constructor(t,e,s){if(!t&&this.play?this.player_=t=this:this.player_=t,this.isDisposed_=!1,this.parentComponent_=null,this.options_=v({},this.options_),e=this.options_=v(this.options_,e),this.id_=e.id||e.el&&e.el.id,!this.id_){const e=t&&t.id&&t.id()||"no_player";this.id_=`${e}_component_${Mt()}`}this.name_=e.name||null,e.el?this.el_=e.el:!1!==e.createEl&&(this.el_=this.createEl()),e.className&&this.el_&&e.className.split(" ").forEach(t=>this.addClass(t)),["on","off","one","any","trigger"].forEach(t=>{this[t]=void 0}),!1!==e.evented&&(le(this,{eventBusKey:this.el_?"el_":null}),this.handleLanguagechange=this.handleLanguagechange.bind(this),this.on(this.player_,"languagechange",this.handleLanguagechange)),ce(this,this.constructor.defaultState),this.children_=[],this.childIndex_={},this.childNameIndex_={},this.setTimeoutIds_=new Set,this.setIntervalIds_=new Set,this.rafIds_=new Set,this.namedRafs_=new Map,this.clearingTimersOnDispose_=!1,!1!==e.initChildren&&this.initChildren(),this.ready(s),!1!==e.reportTouchActivity&&this.enableTouchActivity()}dispose(t={}){if(!this.isDisposed_){if(this.readyQueue_&&(this.readyQueue_.length=0),this.trigger({type:"dispose",bubbles:!1}),this.isDisposed_=!0,this.children_)for(let t=this.children_.length-1;t>=0;t--)this.children_[t].dispose&&this.children_[t].dispose();this.children_=null,this.childIndex_=null,this.childNameIndex_=null,this.parentComponent_=null,this.el_&&(this.el_.parentNode&&(t.restoreEl?this.el_.parentNode.replaceChild(t.restoreEl,this.el_):this.el_.parentNode.removeChild(this.el_)),this.el_=null),this.player_=null}}isDisposed(){return Boolean(this.isDisposed_)}player(){return this.player_}options(t){return t?(this.options_=v(this.options_,t),this.options_):this.options_}el(){return this.el_}createEl(t,e,s){return Q(t,e,s)}localize(t,e,s=t){const i=this.player_.language&&this.player_.language(),r=this.player_.languages&&this.player_.languages(),n=r&&r[i],a=i&&i.split("-")[0],o=r&&r[a];let l=s;return n&&n[t]?l=n[t]:o&&o[t]&&(l=o[t]),e&&(l=l.replace(/\{(\d+)\}/g,function(t,s){const i=e[s-1];let r=i;return void 0===i&&(r=t),r})),l}handleLanguagechange(){}contentEl(){return this.contentEl_||this.el_}id(){return this.id_}name(){return this.name_}children(){return this.children_}getChildById(t){return this.childIndex_[t]}getChild(t){if(t)return this.childNameIndex_[t]}getDescendant(...t){t=t.reduce((t,e)=>t.concat(e),[]);let e=this;for(let s=0;s<t.length;s++)if(e=e.getChild(t[s]),!e||!e.getChild)return;return e}setIcon(t,e=this.el()){if(!this.player_.options_.experimentalSvgIcons)return;const s="http://www.w3.org/2000/svg",i=Q("span",{className:"vjs-icon-placeholder vjs-svg-icon"},{"aria-hidden":"true"}),r=document.createElementNS(s,"svg");r.setAttributeNS(null,"viewBox","0 0 512 512");const n=document.createElementNS(s,"use");return r.appendChild(n),n.setAttributeNS(null,"href",`#vjs-icon-${t}`),i.appendChild(r),this.iconIsSet_?e.replaceChild(i,e.querySelector(".vjs-icon-placeholder")):e.appendChild(i),this.iconIsSet_=!0,i}addChild(t,e={},s=this.children_.length){let i,r;if("string"==typeof t){r=ue(t);const s=e.componentClass||r;e.name=r;const n=ge.getComponent(s);if(!n)throw new Error(`Component ${s} does not exist`);if("function"!=typeof n)return null;i=new n(this.player_||this,e)}else i=t;if(i.parentComponent_&&i.parentComponent_.removeChild(i),this.children_.splice(s,0,i),i.parentComponent_=this,"function"==typeof i.id&&(this.childIndex_[i.id()]=i),r=r||i.name&&ue(i.name()),r&&(this.childNameIndex_[r]=i,this.childNameIndex_[de(r)]=i),"function"==typeof i.el&&i.el()){let t=null;this.children_[s+1]&&(this.children_[s+1].el_?t=this.children_[s+1].el_:q(this.children_[s+1])&&(t=this.children_[s+1])),this.contentEl().insertBefore(i.el(),t)}return i}removeChild(t){if("string"==typeof t&&(t=this.getChild(t)),!t||!this.children_)return;let e=!1;for(let s=this.children_.length-1;s>=0;s--)if(this.children_[s]===t){e=!0,this.children_.splice(s,1);break}if(!e)return;t.parentComponent_=null,this.childIndex_[t.id()]=null,this.childNameIndex_[ue(t.name())]=null,this.childNameIndex_[de(t.name())]=null;const s=t.el();s&&s.parentNode===this.contentEl()&&this.contentEl().removeChild(t.el())}initChildren(){const t=this.options_.children;if(t){const e=this.options_,s=t=>{const s=t.name;let i=t.opts;if(void 0!==e[s]&&(i=e[s]),!1===i)return;!0===i&&(i={}),i.playerOptions=this.options_.playerOptions;const r=this.addChild(s,i);r&&(this[s]=r)};let i;const r=ge.getComponent("Tech");i=Array.isArray(t)?t:Object.keys(t),i.concat(Object.keys(this.options_).filter(function(t){return!i.some(function(e){return"string"==typeof e?t===e:t===e.name})})).map(e=>{let s,i;return"string"==typeof e?(s=e,i=t[s]||this.options_[s]||{}):(s=e.name,i=e),{name:s,opts:i}}).filter(t=>{const e=ge.getComponent(t.opts.componentClass||ue(t.name));return e&&!r.isTech(e)}).forEach(s)}}buildCSSClass(){return""}ready(t,e=!1){if(t)return this.isReady_?void(e?t.call(this):this.setTimeout(t,1)):(this.readyQueue_=this.readyQueue_||[],void this.readyQueue_.push(t))}triggerReady(){this.isReady_=!0,this.setTimeout(function(){const t=this.readyQueue_;this.readyQueue_=[],t&&t.length>0&&t.forEach(function(t){t.call(this)},this),this.trigger("ready")},1)}$(t,e){return _t(t,e||this.contentEl())}$$(t,e){return Tt(t,e||this.contentEl())}hasClass(t){return tt(this.el_,t)}addClass(...t){et(this.el_,...t)}removeClass(...t){st(this.el_,...t)}toggleClass(t,e){it(this.el_,t,e)}show(){this.removeClass("vjs-hidden")}hide(){this.addClass("vjs-hidden")}lockShowing(){this.addClass("vjs-lock-showing")}unlockShowing(){this.removeClass("vjs-lock-showing")}getAttribute(t){return at(this.el_,t)}setAttribute(t,e){ot(this.el_,t,e)}removeAttribute(t){lt(this.el_,t)}width(t,e){return this.dimension("width",t,e)}height(t,e){return this.dimension("height",t,e)}dimensions(t,e){this.width(t,!0),this.height(e)}dimension(t,e,s){if(void 0!==e)return null!==e&&e==e||(e=0),-1!==(""+e).indexOf("%")||-1!==(""+e).indexOf("px")?this.el_.style[t]=e:this.el_.style[t]="auto"===e?"":e+"px",void(s||this.trigger("componentresize"));if(!this.el_)return 0;const i=this.el_.style[t],r=i.indexOf("px");return-1!==r?parseInt(i.slice(0,r),10):parseInt(this.el_["offset"+ue(t)],10)}currentDimension(t){let e=0;if("width"!==t&&"height"!==t)throw new Error("currentDimension only accepts width or height value");if(e=At(this.el_,t),e=parseFloat(e),0===e||isNaN(e)){const s=`offset${ue(t)}`;e=this.el_[s]}return e}currentDimensions(){return{width:this.currentDimension("width"),height:this.currentDimension("height")}}currentWidth(){return this.currentDimension("width")}currentHeight(){return this.currentDimension("height")}getPositions(){const t=this.el_.getBoundingClientRect();return{boundingClientRect:{x:t.x,y:t.y,width:t.width,height:t.height,top:t.top,right:t.right,bottom:t.bottom,left:t.left},center:{x:t.left+t.width/2,y:t.top+t.height/2,width:0,height:0,top:t.top+t.height/2,right:t.left+t.width/2,bottom:t.top+t.height/2,left:t.left+t.width/2}}}focus(){this.el_.focus()}blur(){this.el_.blur()}handleKeyDown(t){this.player_&&("Tab"===t.key||this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled||t.stopPropagation(),this.player_.handleKeyDown(t))}handleKeyPress(t){this.handleKeyDown(t)}emitTapEvents(){let t=0,e=null;let s;this.on("touchstart",function(i){1===i.touches.length&&(e={pageX:i.touches[0].pageX,pageY:i.touches[0].pageY},t=window.performance.now(),s=!0)}),this.on("touchmove",function(t){if(t.touches.length>1)s=!1;else if(e){const i=t.touches[0].pageX-e.pageX,r=t.touches[0].pageY-e.pageY;Math.sqrt(i*i+r*r)>10&&(s=!1)}});const i=function(){s=!1};this.on("touchleave",i),this.on("touchcancel",i),this.on("touchend",function(i){e=null,!0===s&&window.performance.now()-t<200&&(i.preventDefault(),this.trigger("tap"))})}enableTouchActivity(){if(!this.player()||!this.player().reportUserActivity)return;const t=zt(this.player(),this.player().reportUserActivity);let e;this.on("touchstart",function(){t(),this.clearInterval(e),e=this.setInterval(t,250)});const s=function(s){t(),this.clearInterval(e)};this.on("touchmove",t),this.on("touchend",s),this.on("touchcancel",s)}setTimeout(t,e){var s;return t=zt(this,t),this.clearTimersOnDispose_(),s=window.setTimeout(()=>{this.setTimeoutIds_.has(s)&&this.setTimeoutIds_.delete(s),t()},e),this.setTimeoutIds_.add(s),s}clearTimeout(t){return this.setTimeoutIds_.has(t)&&(this.setTimeoutIds_.delete(t),window.clearTimeout(t)),t}setInterval(t,e){t=zt(this,t),this.clearTimersOnDispose_();const s=window.setInterval(t,e);return this.setIntervalIds_.add(s),s}clearInterval(t){return this.setIntervalIds_.has(t)&&(this.setIntervalIds_.delete(t),window.clearInterval(t)),t}requestAnimationFrame(t){var e;return this.clearTimersOnDispose_(),t=zt(this,t),e=window.requestAnimationFrame(()=>{this.rafIds_.has(e)&&this.rafIds_.delete(e),t()}),this.rafIds_.add(e),e}requestNamedAnimationFrame(t,e){this.namedRafs_.has(t)&&this.cancelNamedAnimationFrame(t),this.clearTimersOnDispose_(),e=zt(this,e);const s=this.requestAnimationFrame(()=>{e(),this.namedRafs_.has(t)&&this.namedRafs_.delete(t)});return this.namedRafs_.set(t,s),t}cancelNamedAnimationFrame(t){this.namedRafs_.has(t)&&(this.cancelAnimationFrame(this.namedRafs_.get(t)),this.namedRafs_.delete(t))}cancelAnimationFrame(t){return this.rafIds_.has(t)&&(this.rafIds_.delete(t),window.cancelAnimationFrame(t)),t}clearTimersOnDispose_(){this.clearingTimersOnDispose_||(this.clearingTimersOnDispose_=!0,this.one("dispose",()=>{[["namedRafs_","cancelNamedAnimationFrame"],["rafIds_","cancelAnimationFrame"],["setTimeoutIds_","clearTimeout"],["setIntervalIds_","clearInterval"]].forEach(([t,e])=>{this[t].forEach((t,s)=>this[e](s))}),this.clearingTimersOnDispose_=!1}))}getIsDisabled(){return Boolean(this.el_.disabled)}getIsExpresslyInert(){return this.el_.inert&&!this.el_.ownerDocument.documentElement.inert}getIsFocusable(t){return(t||this.el_).tabIndex>=0&&!(this.getIsDisabled()||this.getIsExpresslyInert())}getIsAvailableToBeFocused(t){function e(t){const e=window.getComputedStyle(t,null),s=e.getPropertyValue("visibility");return"none"!==e.getPropertyValue("display")&&!["hidden","collapse"].includes(s)}return t||(t=this.el()),!(!function(t){if(t.offsetWidth+t.offsetHeight+t.getBoundingClientRect().height+t.getBoundingClientRect().width===0)return!1;const e={x:t.getBoundingClientRect().left+t.offsetWidth/2,y:t.getBoundingClientRect().top+t.offsetHeight/2};if(e.x<0)return!1;if(e.x>(document.documentElement.clientWidth||window.innerWidth))return!1;if(e.y<0)return!1;if(e.y>(document.documentElement.clientHeight||window.innerHeight))return!1;let s=document.elementFromPoint(e.x,e.y);for(;s;){if(s===t)return!0;if(!s.parentNode)return!1;s=s.parentNode}}(t)||(s=t,!e(s.parentElement)||!e(s)||"0"===s.style.opacity||"0px"===window.getComputedStyle(s).height||"0px"===window.getComputedStyle(s).width)||t.parentElement&&!(t.tabIndex>=0));var s}static registerComponent(t,e){if("string"!=typeof t||!t)throw new Error(`Illegal component name, "${t}"; must be a non-empty string.`);const s=ge.getComponent("Tech"),i=s&&s.isTech(e),r=ge===e||ge.prototype.isPrototypeOf(e.prototype);if(i||!r){let e;throw e=i?"techs must be registered using Tech.registerTech()":"must be a Component subclass",new Error(`Illegal component, "${t}"; ${e}.`)}t=ue(t),ge.components_||(ge.components_={});const n=ge.getComponent("Player");if("Player"===t&&n&&n.players){const t=n.players,e=Object.keys(t);if(t&&e.length>0)for(let s=0;s<e.length;s++)if(null!==t[e[s]])throw new Error("Can not register Player component after player has been created.")}return ge.components_[t]=e,ge.components_[de(t)]=e,e}static getComponent(t){if(t&&ge.components_)return ge.components_[t]}}function me(t,e,s,i){return function(t,e,s){if("number"!=typeof e||e<0||e>s)throw new Error(`Failed to execute '${t}' on 'TimeRanges': The index provided (${e}) is non-numeric or out of bounds (0-${s}).`)}(t,i,s.length-1),s[i][e]}function ye(t){let e;return e=void 0===t||0===t.length?{length:0,start(){throw new Error("This TimeRanges object is empty")},end(){throw new Error("This TimeRanges object is empty")}}:{length:t.length,start:me.bind(null,"start",0,t),end:me.bind(null,"end",1,t)},window.Symbol&&window.Symbol.iterator&&(e[window.Symbol.iterator]=()=>(t||[]).values()),e}function ve(t,e){return Array.isArray(t)?ye(t):void 0===t||void 0===e?ye():ye([[t,e]])}ge.registerComponent("Component",ge);const be=function(t,e){t=t<0?0:t;let s=Math.floor(t%60),i=Math.floor(t/60%60),r=Math.floor(t/3600);const n=Math.floor(e/60%60),a=Math.floor(e/3600);return(isNaN(t)||t===1/0)&&(r=i=s="-"),r=r>0||a>0?r+":":"",i=((r||n>=10)&&i<10?"0"+i:i)+":",s=s<10?"0"+s:s,r+i+s};let _e=be;function Te(t){_e=t}function Ae(){_e=be}function Ee(t,e=t){return _e(t,e)}var Se=Object.freeze({__proto__:null,createTimeRanges:ve,createTimeRange:ve,setFormatTime:Te,resetFormatTime:Ae,formatTime:Ee});function Ce(t,e){let s,i,r=0;if(!e)return 0;t&&t.length||(t=ve(0,0));for(let n=0;n<t.length;n++)s=t.start(n),i=t.end(n),i>e&&(i=e),r+=i-s;return r/e}function ke(t){if(t instanceof ke)return t;"number"==typeof t?this.code=t:"string"==typeof t?this.message=t:m(t)&&("number"==typeof t.code&&(this.code=t.code),Object.assign(this,t)),this.message||(this.message=ke.defaultMessages[this.code]||"")}function we(t){return null!=t&&"function"==typeof t.then}function Le(t){we(t)&&t.then(null,t=>{})}ke.prototype.code=0,ke.prototype.message="",ke.prototype.status=null,ke.prototype.metadata=null,ke.errorTypes=["MEDIA_ERR_CUSTOM","MEDIA_ERR_ABORTED","MEDIA_ERR_NETWORK","MEDIA_ERR_DECODE","MEDIA_ERR_SRC_NOT_SUPPORTED","MEDIA_ERR_ENCRYPTED"],ke.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail part-way.",3:"The media playback was aborted due to a corruption problem or because the media used features your browser did not support.",4:"The media could not be loaded, either because the server or network failed or because the format is not supported.",5:"The media is encrypted and we do not have the keys to decrypt it."},ke.MEDIA_ERR_CUSTOM=0,ke.prototype.MEDIA_ERR_CUSTOM=0,ke.MEDIA_ERR_ABORTED=1,ke.prototype.MEDIA_ERR_ABORTED=1,ke.MEDIA_ERR_NETWORK=2,ke.prototype.MEDIA_ERR_NETWORK=2,ke.MEDIA_ERR_DECODE=3,ke.prototype.MEDIA_ERR_DECODE=3,ke.MEDIA_ERR_SRC_NOT_SUPPORTED=4,ke.prototype.MEDIA_ERR_SRC_NOT_SUPPORTED=4,ke.MEDIA_ERR_ENCRYPTED=5,ke.prototype.MEDIA_ERR_ENCRYPTED=5;const Ie=function(t){return["kind","label","language","id","inBandMetadataTrackDispatchType","mode","src"].reduce((e,s,i)=>(t[s]&&(e[s]=t[s]),e),{cues:t.cues&&Array.prototype.map.call(t.cues,function(t){return{startTime:t.startTime,endTime:t.endTime,text:t.text,id:t.id}})})};var Pe=function(t){const e=t.$$("track"),s=Array.prototype.map.call(e,t=>t.track);return Array.prototype.map.call(e,function(t){const e=Ie(t.track);return t.src&&(e.src=t.src),e}).concat(Array.prototype.filter.call(t.textTracks(),function(t){return-1===s.indexOf(t)}).map(Ie))},xe=function(t,e){return t.forEach(function(t){const s=e.addRemoteTextTrack(t).track;!t.src&&t.cues&&t.cues.forEach(t=>s.addCue(t))}),e.textTracks()},Re=Ie;const De="vjs-modal-dialog";class Oe extends ge{constructor(t,e){super(t,e),this.handleKeyDown_=t=>this.handleKeyDown(t),this.close_=t=>this.close(t),this.opened_=this.hasBeenOpened_=this.hasBeenFilled_=!1,this.closeable(!this.options_.uncloseable),this.content(this.options_.content),this.contentEl_=Q("div",{className:`${De}-content`},{role:"document"}),this.descEl_=Q("p",{className:`${De}-description vjs-control-text`,id:this.el().getAttribute("aria-describedby")}),Z(this.descEl_,this.description()),this.el_.appendChild(this.descEl_),this.el_.appendChild(this.contentEl_)}createEl(){return super.createEl("div",{className:this.buildCSSClass(),tabIndex:-1},{"aria-describedby":`${this.id()}_description`,"aria-hidden":"true","aria-label":this.label(),role:"dialog","aria-live":"polite"})}dispose(){this.contentEl_=null,this.descEl_=null,this.previouslyActiveEl_=null,super.dispose()}buildCSSClass(){return`${De} vjs-hidden ${super.buildCSSClass()}`}label(){return this.localize(this.options_.label||"Modal Window")}description(){let t=this.options_.description||this.localize("This is a modal window.");return this.closeable()&&(t+=" "+this.localize("This modal can be closed by pressing the Escape key or activating the close button.")),t}open(){if(this.opened_)return void(this.options_.fillAlways&&this.fill());const t=this.player();this.trigger("beforemodalopen"),this.opened_=!0,(this.options_.fillAlways||!this.hasBeenOpened_&&!this.hasBeenFilled_)&&this.fill(),this.wasPlaying_=!t.paused(),this.options_.pauseOnOpen&&this.wasPlaying_&&t.pause(),this.on("keydown",this.handleKeyDown_),this.hadControls_=t.controls(),t.controls(!1),this.show(),this.conditionalFocus_(),this.el().setAttribute("aria-hidden","false"),this.trigger("modalopen"),this.hasBeenOpened_=!0}opened(t){return"boolean"==typeof t&&this[t?"open":"close"](),this.opened_}close(){if(!this.opened_)return;const t=this.player();this.trigger("beforemodalclose"),this.opened_=!1,this.wasPlaying_&&this.options_.pauseOnOpen&&t.play(),this.off("keydown",this.handleKeyDown_),this.hadControls_&&t.controls(!0),this.hide(),this.el().setAttribute("aria-hidden","true"),this.trigger({type:"modalclose",bubbles:!0}),this.conditionalBlur_(),this.options_.temporary&&this.dispose()}closeable(t){if("boolean"==typeof t){const e=this.closeable_=!!t;let s=this.getChild("closeButton");if(e&&!s){const t=this.contentEl_;this.contentEl_=this.el_,s=this.addChild("closeButton",{controlText:"Close Modal Dialog"}),this.contentEl_=t,this.on(s,"close",this.close_)}!e&&s&&(this.off(s,"close",this.close_),this.removeChild(s),s.dispose())}return this.closeable_}fill(){this.fillWith(this.content())}fillWith(t){const e=this.contentEl(),s=e.parentNode,i=e.nextSibling;this.trigger("beforemodalfill"),this.hasBeenFilled_=!0,s.removeChild(e),this.empty(),vt(e,t),this.trigger("modalfill"),i?s.insertBefore(e,i):s.appendChild(e);const r=this.getChild("closeButton");r&&s.appendChild(r.el_),this.trigger("aftermodalfill")}empty(){this.trigger("beforemodalempty"),gt(this.contentEl()),this.trigger("modalempty")}content(t){return void 0!==t&&(this.content_=t),this.content_}conditionalFocus_(){const t=document.activeElement,e=this.player_.el_;this.previouslyActiveEl_=null,(e.contains(t)||e===t)&&(this.previouslyActiveEl_=t,this.focus())}conditionalBlur_(){this.previouslyActiveEl_&&(this.previouslyActiveEl_.focus(),this.previouslyActiveEl_=null)}handleKeyDown(t){if(this.trigger({type:"modalKeydown",originalEvent:t,target:this,bubbles:!0}),t.stopPropagation(),"Escape"===t.key&&this.closeable())return t.preventDefault(),void this.close();if("Tab"!==t.key)return;const e=this.focusableEls_(),s=this.el_.querySelector(":focus");let i;for(let t=0;t<e.length;t++)if(s===e[t]){i=t;break}document.activeElement===this.el_&&(i=0),t.shiftKey&&0===i?(e[e.length-1].focus(),t.preventDefault()):t.shiftKey||i!==e.length-1||(e[0].focus(),t.preventDefault())}focusableEls_(){const t=this.el_.querySelectorAll("*");return Array.prototype.filter.call(t,t=>(t instanceof window.HTMLAnchorElement||t instanceof window.HTMLAreaElement)&&t.hasAttribute("href")||(t instanceof window.HTMLInputElement||t instanceof window.HTMLSelectElement||t instanceof window.HTMLTextAreaElement||t instanceof window.HTMLButtonElement)&&!t.hasAttribute("disabled")||t instanceof window.HTMLIFrameElement||t instanceof window.HTMLObjectElement||t instanceof window.HTMLEmbedElement||t.hasAttribute("tabindex")&&-1!==t.getAttribute("tabindex")||t.hasAttribute("contenteditable"))}}Oe.prototype.options_={pauseOnOpen:!0,temporary:!0},ge.registerComponent("ModalDialog",Oe);class Me extends Zt{constructor(t=[]){super(),this.tracks_=[],Object.defineProperty(this,"length",{get(){return this.tracks_.length}});for(let e=0;e<t.length;e++)this.addTrack(t[e])}addTrack(t){const e=this.tracks_.length;""+e in this||Object.defineProperty(this,e,{get(){return this.tracks_[e]}}),-1===this.tracks_.indexOf(t)&&(this.tracks_.push(t),this.trigger({track:t,type:"addtrack",target:this})),t.labelchange_=()=>{this.trigger({track:t,type:"labelchange",target:this})},te(t)&&t.addEventListener("labelchange",t.labelchange_)}removeTrack(t){let e;for(let s=0,i=this.length;s<i;s++)if(this[s]===t){e=this[s],e.off&&e.off(),this.tracks_.splice(s,1);break}e&&this.trigger({track:e,type:"removetrack",target:this})}getTrackById(t){let e=null;for(let s=0,i=this.length;s<i;s++){const i=this[s];if(i.id===t){e=i;break}}return e}}Me.prototype.allowedEvents_={change:"change",addtrack:"addtrack",removetrack:"removetrack",labelchange:"labelchange"};for(const t in Me.prototype.allowedEvents_)Me.prototype["on"+t]=null;const Fe=function(t,e){for(let s=0;s<t.length;s++)Object.keys(t[s]).length&&e.id!==t[s].id&&(t[s].enabled=!1)};class Ne extends Me{constructor(t=[]){for(let e=t.length-1;e>=0;e--)if(t[e].enabled){Fe(t,t[e]);break}super(t),this.changing_=!1}addTrack(t){t.enabled&&Fe(this,t),super.addTrack(t),t.addEventListener&&(t.enabledChange_=()=>{this.changing_||(this.changing_=!0,Fe(this,t),this.changing_=!1,this.trigger("change"))},t.addEventListener("enabledchange",t.enabledChange_))}removeTrack(t){super.removeTrack(t),t.removeEventListener&&t.enabledChange_&&(t.removeEventListener("enabledchange",t.enabledChange_),t.enabledChange_=null)}}const Be=function(t,e){for(let s=0;s<t.length;s++)Object.keys(t[s]).length&&e.id!==t[s].id&&(t[s].selected=!1)};class je extends Me{constructor(t=[]){for(let e=t.length-1;e>=0;e--)if(t[e].selected){Be(t,t[e]);break}super(t),this.changing_=!1,Object.defineProperty(this,"selectedIndex",{get(){for(let t=0;t<this.length;t++)if(this[t].selected)return t;return-1},set(){}})}addTrack(t){t.selected&&Be(this,t),super.addTrack(t),t.addEventListener&&(t.selectedChange_=()=>{this.changing_||(this.changing_=!0,Be(this,t),this.changing_=!1,this.trigger("change"))},t.addEventListener("selectedchange",t.selectedChange_))}removeTrack(t){super.removeTrack(t),t.removeEventListener&&t.selectedChange_&&(t.removeEventListener("selectedchange",t.selectedChange_),t.selectedChange_=null)}}class $e extends Me{addTrack(t){super.addTrack(t),this.queueChange_||(this.queueChange_=()=>this.queueTrigger("change")),this.triggerSelectedlanguagechange||(this.triggerSelectedlanguagechange_=()=>this.trigger("selectedlanguagechange")),t.addEventListener("modechange",this.queueChange_),-1===["metadata","chapters"].indexOf(t.kind)&&t.addEventListener("modechange",this.triggerSelectedlanguagechange_)}removeTrack(t){super.removeTrack(t),t.removeEventListener&&(this.queueChange_&&t.removeEventListener("modechange",this.queueChange_),this.selectedlanguagechange_&&t.removeEventListener("modechange",this.triggerSelectedlanguagechange_))}toJSON(){return this.tracks_.map(t=>t.toJSON())}}class Ue{constructor(t){Ue.prototype.setCues_.call(this,t),Object.defineProperty(this,"length",{get(){return this.length_}})}setCues_(t){const e=this.length||0;let s=0;const i=t.length;this.cues_=t,this.length_=t.length;const r=function(t){""+t in this||Object.defineProperty(this,""+t,{get(){return this.cues_[t]}})};if(e<i)for(s=e;s<i;s++)r.call(this,s)}getCueById(t){let e=null;for(let s=0,i=this.length;s<i;s++){const i=this[s];if(i.id===t){e=i;break}}return e}}const He={alternative:"alternative",captions:"captions",main:"main",sign:"sign",subtitles:"subtitles",commentary:"commentary"},Ve={alternative:"alternative",descriptions:"descriptions",main:"main","main-desc":"main-desc",translation:"translation",commentary:"commentary"},Ge={subtitles:"subtitles",captions:"captions",descriptions:"descriptions",chapters:"chapters",metadata:"metadata"},We={disabled:"disabled",hidden:"hidden",showing:"showing"};class Ke extends Zt{constructor(t={}){super();const e={id:t.id||"vjs_track_"+Mt(),kind:t.kind||"",language:t.language||""};let s=t.label||"";for(const t in e)Object.defineProperty(this,t,{get:()=>e[t],set(){}});Object.defineProperty(this,"label",{get:()=>s,set(t){t!==s&&(s=t,this.trigger("labelchange"))}})}}const ze=function(t){return new URL(t,document.baseURI)},qe=function(t){return new URL(t,document.baseURI).href},Ye=function(t){if("string"==typeof t){const e=t.split("?")[0].replace(/\/+$/,"").match(/\.([^.\/]+)$/);return e?e[1].toLowerCase():""}return""},Xe=function(t,e=window.location){return ze(t).origin!==e.origin};var Qe=Object.freeze({__proto__:null,parseUrl:ze,getAbsoluteURL:qe,getFileExtension:Ye,isCrossOrigin:Xe}),Ze="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==s.g?s.g:"undefined"!=typeof self?self:{};function Je(t,e){return t(e={exports:{}},e.exports),e.exports}var ts,es="undefined"!=typeof window?window:void 0!==Ze?Ze:"undefined"!=typeof self?self:{},ss=Je(function(t){function e(){return t.exports=e=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)({}).hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},t.exports.__esModule=!0,t.exports.default=t.exports,e.apply(null,arguments)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports});(ts=ss)&&ts.__esModule&&Object.prototype.hasOwnProperty.call(ts,"default")&&ts.default;var is=function(t){if(!t)return!1;var e=rs.call(t);return"[object Function]"===e||"function"==typeof t&&"[object RegExp]"!==e||"undefined"!=typeof window&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)},rs=Object.prototype.toString;function ns(t,e){var s="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(s)return(s=s.call(t)).next.bind(s);if(Array.isArray(t)||(s=function(t,e){if(t){if("string"==typeof t)return as(t,e);var s=Object.prototype.toString.call(t).slice(8,-1);return"Object"===s&&t.constructor&&(s=t.constructor.name),"Map"===s||"Set"===s?Array.from(t):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?as(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){s&&(t=s);var i=0;return function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function as(t,e){(null==e||e>t.length)&&(e=t.length);for(var s=0,i=new Array(e);s<e;s++)i[s]=t[s];return i}var os=function(){function t(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1}var e=t.prototype;return e.getIsEnabled=function(){return this.enabled_},e.enable=function(){this.enabled_=!0},e.disable=function(){this.enabled_=!1},e.reset=function(){this.typeToInterceptorsMap_=new Map,this.enabled_=!1},e.addInterceptor=function(t,e){this.typeToInterceptorsMap_.has(t)||this.typeToInterceptorsMap_.set(t,new Set);var s=this.typeToInterceptorsMap_.get(t);return!s.has(e)&&(s.add(e),!0)},e.removeInterceptor=function(t,e){var s=this.typeToInterceptorsMap_.get(t);return!(!s||!s.has(e)||(s.delete(e),0))},e.clearInterceptorsByType=function(t){return!!this.typeToInterceptorsMap_.get(t)&&(this.typeToInterceptorsMap_.delete(t),this.typeToInterceptorsMap_.set(t,new Set),!0)},e.clear=function(){return!!this.typeToInterceptorsMap_.size&&(this.typeToInterceptorsMap_=new Map,!0)},e.getForType=function(t){return this.typeToInterceptorsMap_.get(t)||new Set},e.execute=function(t,e){for(var s,i=ns(this.getForType(t));!(s=i()).done;){var r=s.value;try{e=r(e)}catch(t){}}return e},t}(),ls=function(){function t(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1}var e=t.prototype;return e.getIsEnabled=function(){return this.enabled_},e.enable=function(){this.enabled_=!0},e.disable=function(){this.enabled_=!1},e.reset=function(){this.maxAttempts_=1,this.delayFactor_=.1,this.fuzzFactor_=.1,this.initialDelay_=1e3,this.enabled_=!1},e.getMaxAttempts=function(){return this.maxAttempts_},e.setMaxAttempts=function(t){this.maxAttempts_=t},e.getDelayFactor=function(){return this.delayFactor_},e.setDelayFactor=function(t){this.delayFactor_=t},e.getFuzzFactor=function(){return this.fuzzFactor_},e.setFuzzFactor=function(t){this.fuzzFactor_=t},e.getInitialDelay=function(){return this.initialDelay_},e.setInitialDelay=function(t){this.initialDelay_=t},e.createRetry=function(t){var e=void 0===t?{}:t,s=e.maxAttempts,i=e.delayFactor,r=e.fuzzFactor,n=e.initialDelay;return new hs({maxAttempts:s||this.maxAttempts_,delayFactor:i||this.delayFactor_,fuzzFactor:r||this.fuzzFactor_,initialDelay:n||this.initialDelay_})},t}(),hs=function(){function t(t){this.maxAttempts_=t.maxAttempts,this.delayFactor_=t.delayFactor,this.fuzzFactor_=t.fuzzFactor,this.currentDelay_=t.initialDelay,this.currentAttempt_=1}var e=t.prototype;return e.moveToNextAttempt=function(){this.currentAttempt_++;var t=this.currentDelay_*this.delayFactor_;this.currentDelay_=this.currentDelay_+t},e.shouldRetry=function(){return this.currentAttempt_<this.maxAttempts_},e.getCurrentDelay=function(){return this.currentDelay_},e.getCurrentMinPossibleDelay=function(){return(1-this.fuzzFactor_)*this.currentDelay_},e.getCurrentMaxPossibleDelay=function(){return(1+this.fuzzFactor_)*this.currentDelay_},e.getCurrentFuzzedDelay=function(){var t=this.getCurrentMinPossibleDelay(),e=this.getCurrentMaxPossibleDelay();return t+Math.random()*(e-t)},t}(),cs=ls;gs.httpHandler=function(t,e){return void 0===e&&(e=!1),function(s,i,r){if(s)t(s);else if(i.statusCode>=400&&i.statusCode<=599){var n=r;if(e)if(es.TextDecoder){var a=(void 0===(o=i.headers&&i.headers["content-type"])&&(o=""),o.toLowerCase().split(";").reduce(function(t,e){var s=e.split("="),i=s[0],r=s[1];return"charset"===i.trim()?r.trim():t},"utf-8"));try{n=new TextDecoder(a).decode(r)}catch(t){}}else n=String.fromCharCode.apply(null,new Uint8Array(r));t({cause:n})}else t(null,r);var o}},gs.requestInterceptorsStorage=new os,gs.responseInterceptorsStorage=new os,gs.retryManager=new cs;var ds=function(t){var e={};return t?(t.trim().split("\n").forEach(function(t){var s=t.indexOf(":"),i=t.slice(0,s).trim().toLowerCase(),r=t.slice(s+1).trim();void 0===e[i]?e[i]=r:Array.isArray(e[i])?e[i].push(r):e[i]=[e[i],r]}),e):e},us=gs,ps=gs;function fs(t,e,s){var i=t;return is(e)?(s=e,"string"==typeof t&&(i={uri:t})):i=ss({},e,{uri:t}),i.callback=s,i}function gs(t,e,s){return ms(e=fs(t,e,s))}function ms(t){if(void 0===t.callback)throw new Error("callback argument missing");if(t.requestType&&gs.requestInterceptorsStorage.getIsEnabled()){var e={uri:t.uri||t.url,headers:t.headers||{},body:t.body,metadata:t.metadata||{},retry:t.retry,timeout:t.timeout},s=gs.requestInterceptorsStorage.execute(t.requestType,e);t.uri=s.uri,t.headers=s.headers,t.body=s.body,t.metadata=s.metadata,t.retry=s.retry,t.timeout=s.timeout}var i=!1,r=function(e,s,r){i||(i=!0,t.callback(e,s,r))};function n(){var t=void 0;if(t=c.response?c.response:c.responseText||function(t){try{if("document"===t.responseType)return t.responseXML;var e=t.responseXML&&"parsererror"===t.responseXML.documentElement.nodeName;if(""===t.responseType&&!e)return t.responseXML}catch(t){}return null}(c),y)try{t=JSON.parse(t)}catch(t){}return t}function a(e){if(clearTimeout(d),clearTimeout(t.retryTimeout),e instanceof Error||(e=new Error(""+(e||"Unknown XMLHttpRequest Error"))),e.statusCode=0,h||!gs.retryManager.getIsEnabled()||!t.retry||!t.retry.shouldRetry()){if(t.requestType&&gs.responseInterceptorsStorage.getIsEnabled()){var s={headers:v.headers||{},body:v.body,responseUrl:c.responseURL,responseType:c.responseType},i=gs.responseInterceptorsStorage.execute(t.requestType,s);v.body=i.body,v.headers=i.headers}return r(e,v)}t.retryTimeout=setTimeout(function(){t.retry.moveToNextAttempt(),t.xhr=c,ms(t)},t.retry.getCurrentFuzzedDelay())}function o(){if(!h){var e;clearTimeout(d),clearTimeout(t.retryTimeout),e=t.useXDR&&void 0===c.status?200:1223===c.status?204:c.status;var s=v,i=null;if(0!==e?(s={body:n(),statusCode:e,method:p,headers:{},url:u,rawRequest:c},c.getAllResponseHeaders&&(s.headers=ds(c.getAllResponseHeaders()))):i=new Error("Internal XMLHttpRequest Error"),t.requestType&&gs.responseInterceptorsStorage.getIsEnabled()){var a={headers:s.headers||{},body:s.body,responseUrl:c.responseURL,responseType:c.responseType},o=gs.responseInterceptorsStorage.execute(t.requestType,a);s.body=o.body,s.headers=o.headers}return r(i,s,s.body)}}var l,h,c=t.xhr||null;c||(c=t.cors||t.useXDR?new gs.XDomainRequest:new gs.XMLHttpRequest);var d,u=c.url=t.uri||t.url,p=c.method=t.method||"GET",f=t.body||t.data,g=c.headers=t.headers||{},m=!!t.sync,y=!1,v={body:void 0,headers:{},statusCode:0,method:p,url:u,rawRequest:c};if("json"in t&&!1!==t.json&&(y=!0,g.accept||g.Accept||(g.Accept="application/json"),"GET"!==p&&"HEAD"!==p&&(g["content-type"]||g["Content-Type"]||(g["Content-Type"]="application/json"),f=JSON.stringify(!0===t.json?f:t.json))),c.onreadystatechange=function(){4!==c.readyState||gs.responseInterceptorsStorage.getIsEnabled()||setTimeout(o,0)},c.onload=o,c.onerror=a,c.onprogress=function(){},c.onabort=function(){h=!0,clearTimeout(t.retryTimeout)},c.ontimeout=a,c.open(p,u,!m,t.username,t.password),m||(c.withCredentials=!!t.withCredentials),!m&&t.timeout>0&&(d=setTimeout(function(){if(!h){h=!0,c.abort("timeout");var t=new Error("XMLHttpRequest timeout");t.code="ETIMEDOUT",a(t)}},t.timeout)),c.setRequestHeader)for(l in g)g.hasOwnProperty(l)&&c.setRequestHeader(l,g[l]);else if(t.headers&&!function(t){for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}(t.headers))throw new Error("Headers cannot be set on an XDomainRequest object");return"responseType"in t&&(c.responseType=t.responseType),"beforeSend"in t&&"function"==typeof t.beforeSend&&t.beforeSend(c),c.send(f||null),c}gs.XMLHttpRequest=es.XMLHttpRequest||function(){},gs.XDomainRequest="withCredentials"in new gs.XMLHttpRequest?gs.XMLHttpRequest:es.XDomainRequest,function(t,e){for(var s=0;s<t.length;s++)e(t[s])}(["get","put","post","patch","head","delete"],function(t){gs["delete"===t?"del":t]=function(e,s,i){return(s=fs(e,s,i)).method=t.toUpperCase(),ms(s)}}),us.default=ps;const ys=function(t,e){const s=new window.WebVTT.Parser(window,window.vttjs,window.WebVTT.StringDecoder()),i=[];s.oncue=function(t){e.addCue(t)},s.onparsingerror=function(t){i.push(t)},s.onflush=function(){e.trigger({type:"loadeddata",target:e})},s.parse(t),i.length>0&&(window.console&&window.console.groupCollapsed&&window.console.groupCollapsed(`Text Track parsing errors for ${e.src}`),i.forEach(t=>c.error(t)),window.console&&window.console.groupEnd&&window.console.groupEnd()),s.flush()},vs=function(t,e){const s={uri:t},i=Xe(t);i&&(s.cors=i);const r="use-credentials"===e.tech_.crossOrigin();r&&(s.withCredentials=r),us(s,zt(this,function(t,s,i){if(t)return c.error(t,s);e.loaded_=!0,"function"!=typeof window.WebVTT?e.tech_&&e.tech_.any(["vttjsloaded","vttjserror"],t=>{if("vttjserror"!==t.type)return ys(i,e);c.error(`vttjs failed to load, stopping trying to process ${e.src}`)}):ys(i,e)}))};class bs extends Ke{constructor(t={}){if(!t.tech)throw new Error("A tech was not provided.");const e=v(t,{kind:Ge[t.kind]||"subtitles",language:t.language||t.srclang||""});let s=We[e.mode]||"disabled";const i=e.default;"metadata"!==e.kind&&"chapters"!==e.kind||(s="hidden"),super(e),this.tech_=e.tech,this.cues_=[],this.activeCues_=[],this.preload_=!1!==this.tech_.preloadTextTracks;const r=new Ue(this.cues_),n=new Ue(this.activeCues_);let a=!1;this.timeupdateHandler=zt(this,function(t={}){this.tech_.isDisposed()||(this.tech_.isReady_?(this.activeCues=this.activeCues,a&&(this.trigger("cuechange"),a=!1),"timeupdate"!==t.type&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler))):"timeupdate"!==t.type&&(this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler)))});this.tech_.one("dispose",()=>{this.stopTracking()}),"disabled"!==s&&this.startTracking(),Object.defineProperties(this,{default:{get:()=>i,set(){}},mode:{get:()=>s,set(t){We[t]&&s!==t&&(s=t,this.preload_||"disabled"===s||0!==this.cues.length||vs(this.src,this),this.stopTracking(),"disabled"!==s&&this.startTracking(),this.trigger("modechange"))}},cues:{get(){return this.loaded_?r:null},set(){}},activeCues:{get(){if(!this.loaded_)return null;if(0===this.cues.length)return n;const t=this.tech_.currentTime(),e=[];for(let s=0,i=this.cues.length;s<i;s++){const i=this.cues[s];i.startTime<=t&&i.endTime>=t&&e.push(i)}if(a=!1,e.length!==this.activeCues_.length)a=!0;else for(let t=0;t<e.length;t++)-1===this.activeCues_.indexOf(e[t])&&(a=!0);return this.activeCues_=e,n.setCues_(this.activeCues_),n},set(){}}}),e.src?(this.src=e.src,this.preload_||(this.loaded_=!0),(this.preload_||"subtitles"!==e.kind&&"captions"!==e.kind)&&vs(this.src,this)):this.loaded_=!0}startTracking(){this.rvf_=this.tech_.requestVideoFrameCallback(this.timeupdateHandler),this.tech_.on("timeupdate",this.timeupdateHandler)}stopTracking(){this.rvf_&&(this.tech_.cancelVideoFrameCallback(this.rvf_),this.rvf_=void 0),this.tech_.off("timeupdate",this.timeupdateHandler)}addCue(t){let e=t;if(!("getCueAsHTML"in e)){e=new window.vttjs.VTTCue(t.startTime,t.endTime,t.text);for(const s in t)s in e||(e[s]=t[s]);e.id=t.id,e.originalCue_=t}const s=this.tech_.textTracks();for(let t=0;t<s.length;t++)s[t]!==this&&s[t].removeCue(e);this.cues_.push(e),this.cues.setCues_(this.cues_)}toJSON(){return Re(this)}removeCue(t){let e=this.cues_.length;for(;e--;){const s=this.cues_[e];if(s===t||s.originalCue_&&s.originalCue_===t){this.cues_.splice(e,1),this.cues.setCues_(this.cues_);break}}}}bs.prototype.allowedEvents_={cuechange:"cuechange"};class _s extends Ke{constructor(t={}){const e=v(t,{kind:Ve[t.kind]||""});super(e);let s=!1;Object.defineProperty(this,"enabled",{get:()=>s,set(t){"boolean"==typeof t&&t!==s&&(s=t,this.trigger("enabledchange"))}}),e.enabled&&(this.enabled=e.enabled),this.loaded_=!0}}class Ts extends Ke{constructor(t={}){const e=v(t,{kind:He[t.kind]||""});super(e);let s=!1;Object.defineProperty(this,"selected",{get:()=>s,set(t){"boolean"==typeof t&&t!==s&&(s=t,this.trigger("selectedchange"))}}),e.selected&&(this.selected=e.selected)}}class As extends Zt{constructor(t={}){let e;super();const s=new bs(t);this.kind=s.kind,this.src=s.src,this.srclang=s.language,this.label=s.label,this.default=s.default,Object.defineProperties(this,{readyState:{get:()=>e},track:{get:()=>s}}),e=As.NONE,s.addEventListener("loadeddata",()=>{e=As.LOADED,this.trigger({type:"load",target:this})})}}As.prototype.allowedEvents_={load:"load"},As.NONE=0,As.LOADING=1,As.LOADED=2,As.ERROR=3;const Es={audio:{ListClass:Ne,TrackClass:_s,capitalName:"Audio"},video:{ListClass:je,TrackClass:Ts,capitalName:"Video"},text:{ListClass:$e,TrackClass:bs,capitalName:"Text"}};Object.keys(Es).forEach(function(t){Es[t].getterName=`${t}Tracks`,Es[t].privateName=`${t}Tracks_`});const Ss={remoteText:{ListClass:$e,TrackClass:bs,capitalName:"RemoteText",getterName:"remoteTextTracks",privateName:"remoteTextTracks_"},remoteTextEl:{ListClass:class{constructor(t=[]){this.trackElements_=[],Object.defineProperty(this,"length",{get(){return this.trackElements_.length}});for(let e=0,s=t.length;e<s;e++)this.addTrackElement_(t[e])}addTrackElement_(t){const e=this.trackElements_.length;""+e in this||Object.defineProperty(this,e,{get(){return this.trackElements_[e]}}),-1===this.trackElements_.indexOf(t)&&this.trackElements_.push(t)}getTrackElementByTrack_(t){let e;for(let s=0,i=this.trackElements_.length;s<i;s++)if(t===this.trackElements_[s].track){e=this.trackElements_[s];break}return e}removeTrackElement_(t){for(let e=0,s=this.trackElements_.length;e<s;e++)if(t===this.trackElements_[e]){this.trackElements_[e].track&&"function"==typeof this.trackElements_[e].track.off&&this.trackElements_[e].track.off(),"function"==typeof this.trackElements_[e].off&&this.trackElements_[e].off(),this.trackElements_.splice(e,1);break}}},TrackClass:As,capitalName:"RemoteTextTrackEls",getterName:"remoteTextTrackEls",privateName:"remoteTextTrackEls_"}},Cs=Object.assign({},Es,Ss);Ss.names=Object.keys(Ss),Es.names=Object.keys(Es),Cs.names=[].concat(Ss.names).concat(Es.names);var ks,ws=void 0!==Ze?Ze:"undefined"!=typeof window?window:{};"undefined"!=typeof document?ks=document:(ks=ws["__GLOBAL_DOCUMENT_CACHE@4"])||(ks=ws["__GLOBAL_DOCUMENT_CACHE@4"]={});var Ls=ks,Is=Object.create||function(){function t(){}return function(e){if(1!==arguments.length)throw new Error("Object.create shim only accepts one parameter.");return t.prototype=e,new t}}();function Ps(t,e){this.name="ParsingError",this.code=t.code,this.message=e||t.message}function xs(t){function e(t,e,s,i){return 3600*(0|t)+60*(0|e)+(0|s)+(0|i)/1e3}var s=t.match(/^(\d+):(\d{1,2})(:\d{1,2})?\.(\d{3})/);return s?s[3]?e(s[1],s[2],s[3].replace(":",""),s[4]):s[1]>59?e(s[1],s[2],0,s[4]):e(0,s[1],s[2],s[4]):null}function Rs(){this.values=Is(null)}function Ds(t,e,s,i){var r=i?t.split(i):[t];for(var n in r)if("string"==typeof r[n]){var a=r[n].split(s);2===a.length&&e(a[0].trim(),a[1].trim())}}function Os(t,e,s){var i=t;function r(){var e=xs(t);if(null===e)throw new Ps(Ps.Errors.BadTimeStamp,"Malformed timestamp: "+i);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function n(){t=t.replace(/^\s+/,"")}if(n(),e.startTime=r(),n(),"--\x3e"!==t.substr(0,3))throw new Ps(Ps.Errors.BadTimeStamp,"Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);t=t.substr(3),n(),e.endTime=r(),n(),function(t,e){var i=new Rs;Ds(t,function(t,e){switch(t){case"region":for(var r=s.length-1;r>=0;r--)if(s[r].id===e){i.set(t,s[r].region);break}break;case"vertical":i.alt(t,e,["rl","lr"]);break;case"line":var n=e.split(","),a=n[0];i.integer(t,a),i.percent(t,a)&&i.set("snapToLines",!1),i.alt(t,a,["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start","center","end"]);break;case"position":n=e.split(","),i.percent(t,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start","center","end"]);break;case"size":i.percent(t,e);break;case"align":i.alt(t,e,["start","center","end","left","right"])}},/:/,/\s/),e.region=i.get("region",null),e.vertical=i.get("vertical","");try{e.line=i.get("line","auto")}catch(t){}e.lineAlign=i.get("lineAlign","start"),e.snapToLines=i.get("snapToLines",!0),e.size=i.get("size",100);try{e.align=i.get("align","center")}catch(t){e.align=i.get("align","middle")}try{e.position=i.get("position","auto")}catch(t){e.position=i.get("position",{start:0,left:0,center:50,middle:50,end:100,right:100},e.align)}e.positionAlign=i.get("positionAlign",{start:"start",left:"start",center:"center",middle:"center",end:"end",right:"end"},e.align)}(t,e)}Ps.prototype=Is(Error.prototype),Ps.prototype.constructor=Ps,Ps.Errors={BadSignature:{code:0,message:"Malformed WebVTT signature."},BadTimeStamp:{code:1,message:"Malformed time stamp."}},Rs.prototype={set:function(t,e){this.get(t)||""===e||(this.values[t]=e)},get:function(t,e,s){return s?this.has(t)?this.values[t]:e[s]:this.has(t)?this.values[t]:e},has:function(t){return t in this.values},alt:function(t,e,s){for(var i=0;i<s.length;++i)if(e===s[i]){this.set(t,e);break}},integer:function(t,e){/^-?\d+$/.test(e)&&this.set(t,parseInt(e,10))},percent:function(t,e){return!!(e.match(/^([\d]{1,3})(\.[\d]*)?%$/)&&(e=parseFloat(e))>=0&&e<=100)&&(this.set(t,e),!0)}};var Ms=Ls.createElement&&Ls.createElement("textarea"),Fs={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},Ns={white:"rgba(255,255,255,1)",lime:"rgba(0,255,0,1)",cyan:"rgba(0,255,255,1)",red:"rgba(255,0,0,1)",yellow:"rgba(255,255,0,1)",magenta:"rgba(255,0,255,1)",blue:"rgba(0,0,255,1)",black:"rgba(0,0,0,1)"},Bs={v:"title",lang:"lang"},js={rt:"ruby"};function $s(t,e){function s(){if(!e)return null;var t,s=e.match(/^([^<]*)(<[^>]*>?)?/);return t=s[1]?s[1]:s[2],e=e.substr(t.length),t}function i(t){return Ms.innerHTML=t,t=Ms.textContent,Ms.textContent="",t}function r(t,e){return!js[e.localName]||js[e.localName]===t.localName}function n(e,s){var i=Fs[e];if(!i)return null;var r=t.document.createElement(i),n=Bs[e];return n&&s&&(r[n]=s.trim()),r}for(var a,o=t.document.createElement("div"),l=o,h=[];null!==(a=s());)if("<"!==a[0])l.appendChild(t.document.createTextNode(i(a)));else{if("/"===a[1]){h.length&&h[h.length-1]===a.substr(2).replace(">","")&&(h.pop(),l=l.parentNode);continue}var c,d=xs(a.substr(1,a.length-2));if(d){c=t.document.createProcessingInstruction("timestamp",d),l.appendChild(c);continue}var u=a.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!u)continue;if(!(c=n(u[1],u[3])))continue;if(!r(l,c))continue;if(u[2]){var p=u[2].split(".");p.forEach(function(t){var e=/^bg_/.test(t),s=e?t.slice(3):t;if(Ns.hasOwnProperty(s)){var i=e?"background-color":"color",r=Ns[s];c.style[i]=r}}),c.className=p.join(" ")}h.push(u[1]),l.appendChild(c),l=c}return o}var Us=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function Hs(t){for(var e=0;e<Us.length;e++){var s=Us[e];if(t>=s[0]&&t<=s[1])return!0}return!1}function Vs(t){var e=[],s="";if(!t||!t.childNodes)return"ltr";function i(t,e){for(var s=e.childNodes.length-1;s>=0;s--)t.push(e.childNodes[s])}function r(t){if(!t||!t.length)return null;var e=t.pop(),s=e.textContent||e.innerText;if(s){var n=s.match(/^.*(\n|\r)/);return n?(t.length=0,n[0]):s}return"ruby"===e.tagName?r(t):e.childNodes?(i(t,e),r(t)):void 0}for(i(e,t);s=r(e);)for(var n=0;n<s.length;n++)if(Hs(s.charCodeAt(n)))return"rtl";return"ltr"}function Gs(){}function Ws(t,e,s){Gs.call(this),this.cue=e,this.cueDiv=$s(t,e.text);var i={color:"rgba(255, 255, 255, 1)",backgroundColor:"rgba(0, 0, 0, 0.8)",position:"relative",left:0,right:0,top:0,bottom:0,display:"inline",writingMode:""===e.vertical?"horizontal-tb":"lr"===e.vertical?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(i,this.cueDiv),this.div=t.document.createElement("div"),i={direction:Vs(this.cueDiv),writingMode:""===e.vertical?"horizontal-tb":"lr"===e.vertical?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext",textAlign:"middle"===e.align?"center":e.align,font:s.font,whiteSpace:"pre-line",position:"absolute"},this.applyStyles(i),this.div.appendChild(this.cueDiv);var r=0;switch(e.positionAlign){case"start":case"line-left":r=e.position;break;case"center":r=e.position-e.size/2;break;case"end":case"line-right":r=e.position-e.size}""===e.vertical?this.applyStyles({left:this.formatStyle(r,"%"),width:this.formatStyle(e.size,"%")}):this.applyStyles({top:this.formatStyle(r,"%"),height:this.formatStyle(e.size,"%")}),this.move=function(t){this.applyStyles({top:this.formatStyle(t.top,"px"),bottom:this.formatStyle(t.bottom,"px"),left:this.formatStyle(t.left,"px"),right:this.formatStyle(t.right,"px"),height:this.formatStyle(t.height,"px"),width:this.formatStyle(t.width,"px")})}}function Ks(t){var e,s,i,r;if(t.div){s=t.div.offsetHeight,i=t.div.offsetWidth,r=t.div.offsetTop;var n=(n=t.div.childNodes)&&(n=n[0])&&n.getClientRects&&n.getClientRects();t=t.div.getBoundingClientRect(),e=n?Math.max(n[0]&&n[0].height||0,t.height/n.length):0}this.left=t.left,this.right=t.right,this.top=t.top||r,this.height=t.height||s,this.bottom=t.bottom||r+(t.height||s),this.width=t.width||i,this.lineHeight=void 0!==e?e:t.lineHeight}function zs(t,e,s,i){var r=new Ks(e),n=e.cue,a=function(t){if("number"==typeof t.line&&(t.snapToLines||t.line>=0&&t.line<=100))return t.line;if(!t.track||!t.track.textTrackList||!t.track.textTrackList.mediaElement)return-1;for(var e=t.track,s=e.textTrackList,i=0,r=0;r<s.length&&s[r]!==e;r++)"showing"===s[r].mode&&i++;return-1*++i}(n),o=[];if(n.snapToLines){var l;switch(n.vertical){case"":o=["+y","-y"],l="height";break;case"rl":o=["+x","-x"],l="width";break;case"lr":o=["-x","+x"],l="width"}var h=r.lineHeight,c=h*Math.round(a),d=s[l]+h,u=o[0];Math.abs(c)>d&&(c=c<0?-1:1,c*=Math.ceil(d/h)*h),a<0&&(c+=""===n.vertical?s.height:s.width,o=o.reverse()),r.move(u,c)}else{var p=r.lineHeight/s.height*100;switch(n.lineAlign){case"center":a-=p/2;break;case"end":a-=p}switch(n.vertical){case"":e.applyStyles({top:e.formatStyle(a,"%")});break;case"rl":e.applyStyles({left:e.formatStyle(a,"%")});break;case"lr":e.applyStyles({right:e.formatStyle(a,"%")})}o=["+y","-x","+x","-y"],r=new Ks(e)}var f=function(t,e){for(var r,n=new Ks(t),a=1,o=0;o<e.length;o++){for(;t.overlapsOppositeAxis(s,e[o])||t.within(s)&&t.overlapsAny(i);)t.move(e[o]);if(t.within(s))return t;var l=t.intersectPercentage(s);a>l&&(r=new Ks(t),a=l),t=new Ks(n)}return r||n}(r,o);e.move(f.toCSSCompatValues(s))}function qs(){}Gs.prototype.applyStyles=function(t,e){for(var s in e=e||this.div,t)t.hasOwnProperty(s)&&(e.style[s]=t[s])},Gs.prototype.formatStyle=function(t,e){return 0===t?0:t+e},Ws.prototype=Is(Gs.prototype),Ws.prototype.constructor=Ws,Ks.prototype.move=function(t,e){switch(e=void 0!==e?e:this.lineHeight,t){case"+x":this.left+=e,this.right+=e;break;case"-x":this.left-=e,this.right-=e;break;case"+y":this.top+=e,this.bottom+=e;break;case"-y":this.top-=e,this.bottom-=e}},Ks.prototype.overlaps=function(t){return this.left<t.right&&this.right>t.left&&this.top<t.bottom&&this.bottom>t.top},Ks.prototype.overlapsAny=function(t){for(var e=0;e<t.length;e++)if(this.overlaps(t[e]))return!0;return!1},Ks.prototype.within=function(t){return this.top>=t.top&&this.bottom<=t.bottom&&this.left>=t.left&&this.right<=t.right},Ks.prototype.overlapsOppositeAxis=function(t,e){switch(e){case"+x":return this.left<t.left;case"-x":return this.right>t.right;case"+y":return this.top<t.top;case"-y":return this.bottom>t.bottom}},Ks.prototype.intersectPercentage=function(t){return Math.max(0,Math.min(this.right,t.right)-Math.max(this.left,t.left))*Math.max(0,Math.min(this.bottom,t.bottom)-Math.max(this.top,t.top))/(this.height*this.width)},Ks.prototype.toCSSCompatValues=function(t){return{top:this.top-t.top,bottom:t.bottom-this.bottom,left:this.left-t.left,right:t.right-this.right,height:this.height,width:this.width}},Ks.getSimpleBoxPosition=function(t){var e=t.div?t.div.offsetHeight:t.tagName?t.offsetHeight:0,s=t.div?t.div.offsetWidth:t.tagName?t.offsetWidth:0,i=t.div?t.div.offsetTop:t.tagName?t.offsetTop:0;return{left:(t=t.div?t.div.getBoundingClientRect():t.tagName?t.getBoundingClientRect():t).left,right:t.right,top:t.top||i,height:t.height||e,bottom:t.bottom||i+(t.height||e),width:t.width||s}},qs.StringDecoder=function(){return{decode:function(t){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}},qs.convertCueToDOMTree=function(t,e){return t&&e?$s(t,e):null};qs.processCues=function(t,e,s){if(!t||!e||!s)return null;for(;s.firstChild;)s.removeChild(s.firstChild);var i=t.document.createElement("div");if(i.style.position="absolute",i.style.left="0",i.style.right="0",i.style.top="0",i.style.bottom="0",i.style.margin="1.5%",s.appendChild(i),function(t){for(var e=0;e<t.length;e++)if(t[e].hasBeenReset||!t[e].displayState)return!0;return!1}(e)){var r=[],n=Ks.getSimpleBoxPosition(i),a={font:Math.round(.05*n.height*100)/100+"px sans-serif"};!function(){for(var s,o,l=0;l<e.length;l++)o=e[l],s=new Ws(t,o,a),i.appendChild(s.div),zs(0,s,n,r),o.displayState=s.div,r.push(Ks.getSimpleBoxPosition(s))}()}else for(var o=0;o<e.length;o++)i.appendChild(e[o].displayState)},qs.Parser=function(t,e,s){s||(s=e,e={}),e||(e={}),this.window=t,this.vttjs=e,this.state="INITIAL",this.buffer="",this.decoder=s||new TextDecoder("utf8"),this.regionList=[]},qs.Parser.prototype={reportOrThrowError:function(t){if(!(t instanceof Ps))throw t;this.onparsingerror&&this.onparsingerror(t)},parse:function(t){var e=this;function s(){for(var t=e.buffer,s=0;s<t.length&&"\r"!==t[s]&&"\n"!==t[s];)++s;var i=t.substr(0,s);return"\r"===t[s]&&++s,"\n"===t[s]&&++s,e.buffer=t.substr(s),i}function i(t){t.match(/X-TIMESTAMP-MAP/)?Ds(t,function(t,s){"X-TIMESTAMP-MAP"===t&&function(t){var s=new Rs;Ds(t,function(t,e){switch(t){case"MPEGT":s.integer(t+"S",e);break;case"LOCA":s.set(t+"L",xs(e))}},/[^\d]:/,/,/),e.ontimestampmap&&e.ontimestampmap({MPEGTS:s.get("MPEGTS"),LOCAL:s.get("LOCAL")})}(s)},/=/):Ds(t,function(t,s){"Region"===t&&function(t){var s=new Rs;if(Ds(t,function(t,e){switch(t){case"id":s.set(t,e);break;case"width":s.percent(t,e);break;case"lines":s.integer(t,e);break;case"regionanchor":case"viewportanchor":var i=e.split(",");if(2!==i.length)break;var r=new Rs;if(r.percent("x",i[0]),r.percent("y",i[1]),!r.has("x")||!r.has("y"))break;s.set(t+"X",r.get("x")),s.set(t+"Y",r.get("y"));break;case"scroll":s.alt(t,e,["up"])}},/=/,/\s/),s.has("id")){var i=new(e.vttjs.VTTRegion||e.window.VTTRegion);i.width=s.get("width",100),i.lines=s.get("lines",3),i.regionAnchorX=s.get("regionanchorX",0),i.regionAnchorY=s.get("regionanchorY",100),i.viewportAnchorX=s.get("viewportanchorX",0),i.viewportAnchorY=s.get("viewportanchorY",100),i.scroll=s.get("scroll",""),e.onregion&&e.onregion(i),e.regionList.push({id:s.get("id"),region:i})}}(s)},/:/)}t&&(e.buffer+=e.decoder.decode(t,{stream:!0}));try{var r;if("INITIAL"===e.state){if(!/\r\n|\n/.test(e.buffer))return this;var n=(r=s()).match(/^WEBVTT([ \t].*)?$/);if(!n||!n[0])throw new Ps(Ps.Errors.BadSignature);e.state="HEADER"}for(var a=!1;e.buffer;){if(!/\r\n|\n/.test(e.buffer))return this;switch(a?a=!1:r=s(),e.state){case"HEADER":/:/.test(r)?i(r):r||(e.state="ID");continue;case"NOTE":r||(e.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(r)){e.state="NOTE";break}if(!r)continue;e.cue=new(e.vttjs.VTTCue||e.window.VTTCue)(0,0,"");try{e.cue.align="center"}catch(t){e.cue.align="middle"}if(e.state="CUE",-1===r.indexOf("--\x3e")){e.cue.id=r;continue}case"CUE":try{Os(r,e.cue,e.regionList)}catch(t){e.reportOrThrowError(t),e.cue=null,e.state="BADCUE";continue}e.state="CUETEXT";continue;case"CUETEXT":var o=-1!==r.indexOf("--\x3e");if(!r||o&&(a=!0)){e.oncue&&e.oncue(e.cue),e.cue=null,e.state="ID";continue}e.cue.text&&(e.cue.text+="\n"),e.cue.text+=r.replace(/\u2028/g,"\n").replace(/u2029/g,"\n");continue;case"BADCUE":r||(e.state="ID");continue}}}catch(t){e.reportOrThrowError(t),"CUETEXT"===e.state&&e.cue&&e.oncue&&e.oncue(e.cue),e.cue=null,e.state="INITIAL"===e.state?"BADWEBVTT":"BADCUE"}return this},flush:function(){var t=this;try{if(t.buffer+=t.decoder.decode(),(t.cue||"HEADER"===t.state)&&(t.buffer+="\n\n",t.parse()),"INITIAL"===t.state)throw new Ps(Ps.Errors.BadSignature)}catch(e){t.reportOrThrowError(e)}return t.onflush&&t.onflush(),this}};var Ys=qs,Xs={"":1,lr:1,rl:1},Qs={start:1,center:1,end:1,left:1,right:1,auto:1,"line-left":1,"line-right":1};function Zs(t){return"string"==typeof t&&!!Qs[t.toLowerCase()]&&t.toLowerCase()}function Js(t,e,s){this.hasBeenReset=!1;var i="",r=!1,n=t,a=e,o=s,l=null,h="",c=!0,d="auto",u="start",p="auto",f="auto",g=100,m="center";Object.defineProperties(this,{id:{enumerable:!0,get:function(){return i},set:function(t){i=""+t}},pauseOnExit:{enumerable:!0,get:function(){return r},set:function(t){r=!!t}},startTime:{enumerable:!0,get:function(){return n},set:function(t){if("number"!=typeof t)throw new TypeError("Start time must be set to a number.");n=t,this.hasBeenReset=!0}},endTime:{enumerable:!0,get:function(){return a},set:function(t){if("number"!=typeof t)throw new TypeError("End time must be set to a number.");a=t,this.hasBeenReset=!0}},text:{enumerable:!0,get:function(){return o},set:function(t){o=""+t,this.hasBeenReset=!0}},region:{enumerable:!0,get:function(){return l},set:function(t){l=t,this.hasBeenReset=!0}},vertical:{enumerable:!0,get:function(){return h},set:function(t){var e=function(t){return"string"==typeof t&&!!Xs[t.toLowerCase()]&&t.toLowerCase()}(t);if(!1===e)throw new SyntaxError("Vertical: an invalid or illegal direction string was specified.");h=e,this.hasBeenReset=!0}},snapToLines:{enumerable:!0,get:function(){return c},set:function(t){c=!!t,this.hasBeenReset=!0}},line:{enumerable:!0,get:function(){return d},set:function(t){if("number"!=typeof t&&"auto"!==t)throw new SyntaxError("Line: an invalid number or illegal string was specified.");d=t,this.hasBeenReset=!0}},lineAlign:{enumerable:!0,get:function(){return u},set:function(t){var e=Zs(t);e?(u=e,this.hasBeenReset=!0):console.warn("lineAlign: an invalid or illegal string was specified.")}},position:{enumerable:!0,get:function(){return p},set:function(t){if(t<0||t>100)throw new Error("Position must be between 0 and 100.");p=t,this.hasBeenReset=!0}},positionAlign:{enumerable:!0,get:function(){return f},set:function(t){var e=Zs(t);e?(f=e,this.hasBeenReset=!0):console.warn("positionAlign: an invalid or illegal string was specified.")}},size:{enumerable:!0,get:function(){return g},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");g=t,this.hasBeenReset=!0}},align:{enumerable:!0,get:function(){return m},set:function(t){var e=Zs(t);if(!e)throw new SyntaxError("align: an invalid or illegal alignment string was specified.");m=e,this.hasBeenReset=!0}}}),this.displayState=void 0}Js.prototype.getCueAsHTML=function(){return WebVTT.convertCueToDOMTree(window,this.text)};var ti=Js,ei={"":!0,up:!0};function si(t){return"number"==typeof t&&t>=0&&t<=100}var ii=function(){var t=100,e=3,s=0,i=100,r=0,n=100,a="";Object.defineProperties(this,{width:{enumerable:!0,get:function(){return t},set:function(e){if(!si(e))throw new Error("Width must be between 0 and 100.");t=e}},lines:{enumerable:!0,get:function(){return e},set:function(t){if("number"!=typeof t)throw new TypeError("Lines must be set to a number.");e=t}},regionAnchorY:{enumerable:!0,get:function(){return i},set:function(t){if(!si(t))throw new Error("RegionAnchorX must be between 0 and 100.");i=t}},regionAnchorX:{enumerable:!0,get:function(){return s},set:function(t){if(!si(t))throw new Error("RegionAnchorY must be between 0 and 100.");s=t}},viewportAnchorY:{enumerable:!0,get:function(){return n},set:function(t){if(!si(t))throw new Error("ViewportAnchorY must be between 0 and 100.");n=t}},viewportAnchorX:{enumerable:!0,get:function(){return r},set:function(t){if(!si(t))throw new Error("ViewportAnchorX must be between 0 and 100.");r=t}},scroll:{enumerable:!0,get:function(){return a},set:function(t){var e=function(t){return"string"==typeof t&&!!ei[t.toLowerCase()]&&t.toLowerCase()}(t);!1===e?console.warn("Scroll: an invalid or illegal string was specified."):a=e}}})},ri=Je(function(t){var e=t.exports={WebVTT:Ys,VTTCue:ti,VTTRegion:ii};es.vttjs=e,es.WebVTT=e.WebVTT;var s=e.VTTCue,i=e.VTTRegion,r=es.VTTCue,n=es.VTTRegion;e.shim=function(){es.VTTCue=s,es.VTTRegion=i},e.restore=function(){es.VTTCue=r,es.VTTRegion=n},es.VTTCue||e.shim()});ri.WebVTT,ri.VTTCue,ri.VTTRegion;class ni extends ge{constructor(t={},e=function(){}){t.reportTouchActivity=!1,super(null,t,e),this.onDurationChange_=t=>this.onDurationChange(t),this.trackProgress_=t=>this.trackProgress(t),this.trackCurrentTime_=t=>this.trackCurrentTime(t),this.stopTrackingCurrentTime_=t=>this.stopTrackingCurrentTime(t),this.disposeSourceHandler_=t=>this.disposeSourceHandler(t),this.queuedHanders_=new Set,this.hasStarted_=!1,this.on("playing",function(){this.hasStarted_=!0}),this.on("loadstart",function(){this.hasStarted_=!1}),Cs.names.forEach(e=>{const s=Cs[e];t&&t[s.getterName]&&(this[s.privateName]=t[s.getterName])}),this.featuresProgressEvents||this.manualProgressOn(),this.featuresTimeupdateEvents||this.manualTimeUpdatesOn(),["Text","Audio","Video"].forEach(e=>{!1===t[`native${e}Tracks`]&&(this[`featuresNative${e}Tracks`]=!1)}),!1===t.nativeCaptions||!1===t.nativeTextTracks?this.featuresNativeTextTracks=!1:!0!==t.nativeCaptions&&!0!==t.nativeTextTracks||(this.featuresNativeTextTracks=!0),this.featuresNativeTextTracks||this.emulateTextTracks(),this.preloadTextTracks=!1!==t.preloadTextTracks,this.autoRemoteTextTracks_=new Cs.text.ListClass,this.initTrackListeners(),t.nativeControlsForTouch||this.emitTapEvents(),this.constructor&&(this.name_=this.constructor.name||"Unknown Tech")}triggerSourceset(t){this.isReady_||this.one("ready",()=>this.setTimeout(()=>this.triggerSourceset(t),1)),this.trigger({src:t,type:"sourceset"})}manualProgressOn(){this.on("durationchange",this.onDurationChange_),this.manualProgress=!0,this.one("ready",this.trackProgress_)}manualProgressOff(){this.manualProgress=!1,this.stopTrackingProgress(),this.off("durationchange",this.onDurationChange_)}trackProgress(t){this.stopTrackingProgress(),this.progressInterval=this.setInterval(zt(this,function(){const t=this.bufferedPercent();this.bufferedPercent_!==t&&this.trigger("progress"),this.bufferedPercent_=t,1===t&&this.stopTrackingProgress()}),500)}onDurationChange(t){this.duration_=this.duration()}buffered(){return ve(0,0)}bufferedPercent(){return Ce(this.buffered(),this.duration_)}stopTrackingProgress(){this.clearInterval(this.progressInterval)}manualTimeUpdatesOn(){this.manualTimeUpdates=!0,this.on("play",this.trackCurrentTime_),this.on("pause",this.stopTrackingCurrentTime_)}manualTimeUpdatesOff(){this.manualTimeUpdates=!1,this.stopTrackingCurrentTime(),this.off("play",this.trackCurrentTime_),this.off("pause",this.stopTrackingCurrentTime_)}trackCurrentTime(){this.currentTimeInterval&&this.stopTrackingCurrentTime(),this.currentTimeInterval=this.setInterval(function(){this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})},250)}stopTrackingCurrentTime(){this.clearInterval(this.currentTimeInterval),this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}dispose(){this.clearTracks(Es.names),this.manualProgress&&this.manualProgressOff(),this.manualTimeUpdates&&this.manualTimeUpdatesOff(),super.dispose()}clearTracks(t){(t=[].concat(t)).forEach(t=>{const e=this[`${t}Tracks`]()||[];let s=e.length;for(;s--;){const i=e[s];"text"===t&&this.removeRemoteTextTrack(i),e.removeTrack(i)}})}cleanupAutoTextTracks(){const t=this.autoRemoteTextTracks_||[];let e=t.length;for(;e--;){const s=t[e];this.removeRemoteTextTrack(s)}}reset(){}crossOrigin(){}setCrossOrigin(){}error(t){return void 0!==t&&(this.error_=new ke(t),this.trigger("error")),this.error_}played(){return this.hasStarted_?ve(0,0):ve()}play(){}setScrubbing(t){}scrubbing(){}setCurrentTime(t){this.manualTimeUpdates&&this.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}initTrackListeners(){Es.names.forEach(t=>{const e=Es[t],s=()=>{this.trigger(`${t}trackchange`)},i=this[e.getterName]();i.addEventListener("removetrack",s),i.addEventListener("addtrack",s),this.on("dispose",()=>{i.removeEventListener("removetrack",s),i.removeEventListener("addtrack",s)})})}addWebVttScript_(){if(!window.WebVTT)if(document.body.contains(this.el())){if(!this.options_["vtt.js"]&&y(ri)&&Object.keys(ri).length>0)return void this.trigger("vttjsloaded");const t=document.createElement("script");t.src=this.options_["vtt.js"]||"https://vjs.zencdn.net/vttjs/0.14.1/vtt.min.js",t.onload=()=>{this.trigger("vttjsloaded")},t.onerror=()=>{this.trigger("vttjserror")},this.on("dispose",()=>{t.onload=null,t.onerror=null}),window.WebVTT=!0,this.el().parentNode.appendChild(t)}else this.ready(this.addWebVttScript_)}emulateTextTracks(){const t=this.textTracks(),e=this.remoteTextTracks(),s=e=>t.addTrack(e.track),i=e=>t.removeTrack(e.track);e.on("addtrack",s),e.on("removetrack",i),this.addWebVttScript_();const r=()=>this.trigger("texttrackchange"),n=()=>{r();for(let e=0;e<t.length;e++){const s=t[e];s.removeEventListener("cuechange",r),"showing"===s.mode&&s.addEventListener("cuechange",r)}};n(),t.addEventListener("change",n),t.addEventListener("addtrack",n),t.addEventListener("removetrack",n),this.on("dispose",function(){e.off("addtrack",s),e.off("removetrack",i),t.removeEventListener("change",n),t.removeEventListener("addtrack",n),t.removeEventListener("removetrack",n);for(let e=0;e<t.length;e++)t[e].removeEventListener("cuechange",r)})}addTextTrack(t,e,s){if(!t)throw new Error("TextTrack kind is required but was not provided");return function(t,e,s,i,r={}){const n=t.textTracks();r.kind=e,s&&(r.label=s),i&&(r.language=i),r.tech=t;const a=new Cs.text.TrackClass(r);return n.addTrack(a),a}(this,t,e,s)}createRemoteTextTrack(t){const e=v(t,{tech:this});return new Ss.remoteTextEl.TrackClass(e)}addRemoteTextTrack(t={},e){const s=this.createRemoteTextTrack(t);return"boolean"!=typeof e&&(e=!1),this.remoteTextTrackEls().addTrackElement_(s),this.remoteTextTracks().addTrack(s.track),!1===e&&this.ready(()=>this.autoRemoteTextTracks_.addTrack(s.track)),s}removeRemoteTextTrack(t){const e=this.remoteTextTrackEls().getTrackElementByTrack_(t);this.remoteTextTrackEls().removeTrackElement_(e),this.remoteTextTracks().removeTrack(t),this.autoRemoteTextTracks_.removeTrack(t)}getVideoPlaybackQuality(){return{}}requestPictureInPicture(){return Promise.reject()}disablePictureInPicture(){return!0}setDisablePictureInPicture(){}requestVideoFrameCallback(t){const e=Mt();return!this.isReady_||this.paused()?(this.queuedHanders_.add(e),this.one("playing",()=>{this.queuedHanders_.has(e)&&(this.queuedHanders_.delete(e),t())})):this.requestNamedAnimationFrame(e,t),e}cancelVideoFrameCallback(t){this.queuedHanders_.has(t)?this.queuedHanders_.delete(t):this.cancelNamedAnimationFrame(t)}setPoster(){}playsinline(){}setPlaysinline(){}overrideNativeAudioTracks(t){}overrideNativeVideoTracks(t){}canPlayType(t){return""}static canPlayType(t){return""}static canPlaySource(t,e){return ni.canPlayType(t.type)}static isTech(t){return t.prototype instanceof ni||t instanceof ni||t===ni}static registerTech(t,e){if(ni.techs_||(ni.techs_={}),!ni.isTech(e))throw new Error(`Tech ${t} must be a Tech`);if(!ni.canPlayType)throw new Error("Techs must have a static canPlayType method on them");if(!ni.canPlaySource)throw new Error("Techs must have a static canPlaySource method on them");return t=ue(t),ni.techs_[t]=e,ni.techs_[de(t)]=e,"Tech"!==t&&ni.defaultTechOrder_.push(t),e}static getTech(t){if(t)return ni.techs_&&ni.techs_[t]?ni.techs_[t]:(t=ue(t),window&&window.videojs&&window.videojs[t]?(c.warn(`The ${t} tech was added to the videojs object when it should be registered using videojs.registerTech(name, tech)`),window.videojs[t]):void 0)}}Cs.names.forEach(function(t){const e=Cs[t];ni.prototype[e.getterName]=function(){return this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName]}}),ni.prototype.featuresVolumeControl=!0,ni.prototype.featuresMuteControl=!0,ni.prototype.featuresFullscreenResize=!1,ni.prototype.featuresPlaybackRate=!1,ni.prototype.featuresProgressEvents=!1,ni.prototype.featuresSourceset=!1,ni.prototype.featuresTimeupdateEvents=!1,ni.prototype.featuresNativeTextTracks=!1,ni.prototype.featuresVideoFrameCallback=!1,ni.withSourceHandlers=function(t){t.registerSourceHandler=function(e,s){let i=t.sourceHandlers;i||(i=t.sourceHandlers=[]),void 0===s&&(s=i.length),i.splice(s,0,e)},t.canPlayType=function(e){const s=t.sourceHandlers||[];let i;for(let t=0;t<s.length;t++)if(i=s[t].canPlayType(e),i)return i;return""},t.selectSourceHandler=function(e,s){const i=t.sourceHandlers||[];let r;for(let t=0;t<i.length;t++)if(r=i[t].canHandleSource(e,s),r)return i[t];return null},t.canPlaySource=function(e,s){const i=t.selectSourceHandler(e,s);return i?i.canHandleSource(e,s):""},["seekable","seeking","duration"].forEach(function(t){const e=this[t];"function"==typeof e&&(this[t]=function(){return this.sourceHandler_&&this.sourceHandler_[t]?this.sourceHandler_[t].apply(this.sourceHandler_,arguments):e.apply(this,arguments)})},t.prototype),t.prototype.setSource=function(e){let s=t.selectSourceHandler(e,this.options_);s||(t.nativeSourceHandler?s=t.nativeSourceHandler:c.error("No source handler found for the current source.")),this.disposeSourceHandler(),this.off("dispose",this.disposeSourceHandler_),s!==t.nativeSourceHandler&&(this.currentSource_=e),this.sourceHandler_=s.handleSource(e,this,this.options_),this.one("dispose",this.disposeSourceHandler_)},t.prototype.disposeSourceHandler=function(){this.currentSource_&&(this.clearTracks(["audio","video"]),this.currentSource_=null),this.cleanupAutoTextTracks(),this.sourceHandler_&&(this.sourceHandler_.dispose&&this.sourceHandler_.dispose(),this.sourceHandler_=null)}},ge.registerComponent("Tech",ni),ni.registerTech("Tech",ni),ni.defaultTechOrder_=[];const ai={},oi={},li={};function hi(t,e,s){t.setTimeout(()=>gi(e,ai[e.type],s,t),1)}function ci(t,e,s,i=null){const r="call"+ue(s),n=t.reduce(fi(r),i),a=n===li,o=a?null:e[s](n);return function(t,e,s,i){for(let r=t.length-1;r>=0;r--){const n=t[r];n[e]&&n[e](i,s)}}(t,s,o,a),o}const di={buffered:1,currentTime:1,duration:1,muted:1,played:1,paused:1,seekable:1,volume:1,ended:1},ui={setCurrentTime:1,setMuted:1,setVolume:1},pi={play:1,pause:1};function fi(t){return(e,s)=>e===li?li:s[t]?s[t](e):e}function gi(t={},e=[],s,i,r=[],n=!1){const[a,...o]=e;if("string"==typeof a)gi(t,ai[a],s,i,r,n);else if(a){const e=function(t,e){const s=oi[t.id()];let i=null;if(null==s)return i=e(t),oi[t.id()]=[[e,i]],i;for(let t=0;t<s.length;t++){const[r,n]=s[t];r===e&&(i=n)}return null===i&&(i=e(t),s.push([e,i])),i}(i,a);if(!e.setSource)return r.push(e),gi(t,o,s,i,r,n);e.setSource(Object.assign({},t),function(a,l){if(a)return gi(t,o,s,i,r,n);r.push(e),gi(l,t.type===l.type?o:ai[l.type],s,i,r,n)})}else o.length?gi(t,o,s,i,r,n):n?s(t,r):gi(t,ai["*"],s,i,r,!0)}const mi={opus:"video/ogg",ogv:"video/ogg",mp4:"video/mp4",mov:"video/mp4",m4v:"video/mp4",mkv:"video/x-matroska",m4a:"audio/mp4",mp3:"audio/mpeg",aac:"audio/aac",caf:"audio/x-caf",flac:"audio/flac",oga:"audio/ogg",wav:"audio/wav",m3u8:"application/x-mpegURL",mpd:"application/dash+xml",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",png:"image/png",svg:"image/svg+xml",webp:"image/webp"},yi=function(t=""){const e=Ye(t);return mi[e.toLowerCase()]||""},vi=function(t){if(Array.isArray(t)){let e=[];t.forEach(function(t){t=vi(t),Array.isArray(t)?e=e.concat(t):m(t)&&e.push(t)}),t=e}else t="string"==typeof t&&t.trim()?[bi({src:t})]:m(t)&&"string"==typeof t.src&&t.src&&t.src.trim()?[bi(t)]:[];return t};function bi(t){if(!t.type){const e=yi(t.src);e&&(t.type=e)}return t}const _i=B?10009:j?461:8,Ti={codes:{play:415,pause:19,ff:417,rw:412,back:_i},names:{415:"play",19:"pause",417:"ff",412:"rw",[_i]:"back"},isEventKey(t,e){return e=e.toLowerCase(),!(!this.names[t.keyCode]||this.names[t.keyCode]!==e)},getEventName(t){if(this.names[t.keyCode])return this.names[t.keyCode];if(this.codes[t.code]){const e=this.codes[t.code];return this.names[e]}return null}};class Ai extends Zt{constructor(t){super(),this.player_=t,this.focusableComponents=[],this.isListening_=!1,this.isPaused_=!1,this.onKeyDown_=this.onKeyDown_.bind(this),this.lastFocusedComponent_=null}start(){this.isListening_||(this.player_.on("keydown",this.onKeyDown_),this.player_.on("modalKeydown",this.onKeyDown_),this.player_.on("loadedmetadata",()=>{this.focus(this.updateFocusableComponents()[0])}),this.player_.on("modalclose",()=>{this.refocusComponent()}),this.player_.on("focusin",this.handlePlayerFocus_.bind(this)),this.player_.on("focusout",this.handlePlayerBlur_.bind(this)),this.isListening_=!0,this.player_.errorDisplay&&this.player_.errorDisplay.on("aftermodalfill",()=>{this.updateFocusableComponents(),this.focusableComponents.length&&(this.focusableComponents.length>1?this.focusableComponents[1].focus():this.focusableComponents[0].focus())}))}stop(){this.player_.off("keydown",this.onKeyDown_),this.isListening_=!1}onKeyDown_(t){const e=t.originalEvent?t.originalEvent:t;if(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(e.key)){if(this.isPaused_)return;e.preventDefault();const t=e.key.substring(5).toLowerCase();this.move(t)}else if(Ti.isEventKey(e,"play")||Ti.isEventKey(e,"pause")||Ti.isEventKey(e,"ff")||Ti.isEventKey(e,"rw")){e.preventDefault();const t=Ti.getEventName(e);this.performMediaAction_(t)}else Ti.isEventKey(e,"Back")&&t.target&&"function"==typeof t.target.closeable&&t.target.closeable()&&(e.preventDefault(),t.target.close())}performMediaAction_(t){if(this.player_)switch(t){case"play":this.player_.paused()&&this.player_.play();break;case"pause":this.player_.paused()||this.player_.pause();break;case"ff":this.userSeek_(this.player_.currentTime()+5);break;case"rw":this.userSeek_(this.player_.currentTime()-5)}}userSeek_(t){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(t)}pause(){this.isPaused_=!0}resume(){this.isPaused_=!1}handlePlayerBlur_(t){const e=t.relatedTarget;let s=null;const i=this.getCurrentComponent(t.target);e&&(s=Boolean(e.closest(".video-js")),e.classList.contains("vjs-text-track-settings")&&!this.isPaused_&&this.searchForTrackSelect_()),(t.currentTarget.contains(t.relatedTarget)||s)&&e||(i&&"CloseButton"===i.name()?this.refocusComponent():(this.pause(),i&&i.el()&&(this.lastFocusedComponent_=i)))}handlePlayerFocus_(){this.getCurrentComponent()&&this.getCurrentComponent().getIsFocusable()&&this.resume()}updateFocusableComponents(){const t=this.player_,e=[];function s(t){for(const i of t)i.hasOwnProperty("el_")&&i.getIsFocusable()&&i.getIsAvailableToBeFocused(i.el())&&e.push(i),i.hasOwnProperty("children_")&&i.children_.length>0&&s(i.children_)}return t.children_.forEach(t=>{if(t.hasOwnProperty("el_")){if(t.getIsFocusable&&t.getIsAvailableToBeFocused&&t.getIsFocusable()&&t.getIsAvailableToBeFocused(t.el()))return void e.push(t);t.hasOwnProperty("children_")&&t.children_.length>0?s(t.children_):t.hasOwnProperty("items")&&t.items.length>0?s(t.items):this.findSuitableDOMChild(t)&&e.push(t)}if("ErrorDisplay"===t.name_&&t.opened_){const s=t.el_.querySelector(".vjs-errors-ok-button-container");s&&s.querySelectorAll("button").forEach((t,s)=>{e.push({name:()=>"ModalButton"+(s+1),el:()=>t,getPositions:()=>{const e=t.getBoundingClientRect();return{boundingClientRect:{x:e.x,y:e.y,width:e.width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left},center:{x:e.left+e.width/2,y:e.top+e.height/2,width:0,height:0,top:e.top+e.height/2,right:e.left+e.width/2,bottom:e.top+e.height/2,left:e.left+e.width/2}}},getIsAvailableToBeFocused:()=>!0,getIsFocusable:t=>!0,focus:()=>t.focus()})})}}),this.focusableComponents=e,this.focusableComponents}findSuitableDOMChild(t){return t.el()?function e(s){if(t.getIsFocusable(s)&&t.getIsAvailableToBeFocused(s))return s;for(let t=0;t<s.children.length;t++){const i=e(s.children[t]);if(i)return i}return null}(t.el()):null}getCurrentComponent(t){this.updateFocusableComponents();const e=t||document.activeElement;if(this.focusableComponents.length)for(const t of this.focusableComponents)if(t.el()===e)return t}add(t){const e=[...this.focusableComponents];t.hasOwnProperty("el_")&&t.getIsFocusable()&&t.getIsAvailableToBeFocused(t.el())&&e.push(t),this.focusableComponents=e,this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents})}remove(t){for(let e=0;e<this.focusableComponents.length;e++)if(this.focusableComponents[e].name()===t.name())return this.focusableComponents.splice(e,1),void this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents})}clear(){this.focusableComponents.length>0&&(this.focusableComponents=[],this.trigger({type:"focusableComponentsChanged",focusableComponents:this.focusableComponents}))}move(t){const e=this.getCurrentComponent();if(!e)return;const s=e.getPositions(),i=this.focusableComponents.filter(i=>i!==e&&this.isInDirection_(s.boundingClientRect,i.getPositions().boundingClientRect,t)),r=this.findBestCandidate_(s.center,i,t);r?this.focus(r):this.trigger({type:"endOfFocusableComponents",direction:t,focusedComponent:e})}findBestCandidate_(t,e,s){let i=1/0,r=null;for(const n of e){const e=n.getPositions().center,a=this.calculateDistance_(t,e,s);a<i&&(i=a,r=n)}return r}isInDirection_(t,e,s){switch(s){case"right":return e.left>=t.right;case"left":return e.right<=t.left;case"down":return e.top>=t.bottom;case"up":return e.bottom<=t.top;default:return!1}}refocusComponent(){if(this.lastFocusedComponent_){this.player_.userActive()||this.player_.userActive(!0),this.updateFocusableComponents();for(let t=0;t<this.focusableComponents.length;t++)if(this.focusableComponents[t].name()===this.lastFocusedComponent_.name())return void this.focus(this.focusableComponents[t])}else this.focus(this.updateFocusableComponents()[0])}focus(t){"object"==typeof t&&(t.getIsAvailableToBeFocused(t.el())?t.focus():this.findSuitableDOMChild(t)&&this.findSuitableDOMChild(t).focus())}calculateDistance_(t,e,s){const i=Math.abs(t.x-e.x),r=Math.abs(t.y-e.y);let n;switch(s){case"right":case"left":n=i+100*r;break;case"up":n=2*r+.5*i;break;case"down":n=5*r+i;break;default:n=i+r}return n}searchForTrackSelect_(){const t=this;for(const e of t.updateFocusableComponents())if("TextTrackSelect"===e.constructor.name){t.focus(e);break}}}ge.registerComponent("MediaLoader",class extends ge{constructor(t,e,s){if(super(t,v({createEl:!1},e),s),e.playerOptions.sources&&0!==e.playerOptions.sources.length)t.src(e.playerOptions.sources);else for(let s=0,i=e.playerOptions.techOrder;s<i.length;s++){const e=ue(i[s]);let r=ni.getTech(e);if(e||(r=ge.getComponent(e)),r&&r.isSupported()){t.loadTech_(e);break}}}});class Ei extends ge{constructor(t,e){super(t,e),this.options_.controlText&&this.controlText(this.options_.controlText),this.handleMouseOver_=t=>this.handleMouseOver(t),this.handleMouseOut_=t=>this.handleMouseOut(t),this.handleClick_=t=>this.handleClick(t),this.handleKeyDown_=t=>this.handleKeyDown(t),this.emitTapEvents(),this.enable()}createEl(t="div",e={},s={}){e=Object.assign({className:this.buildCSSClass(),tabIndex:0},e),"button"===t&&c.error(`Creating a ClickableComponent with an HTML element of ${t} is not supported; use a Button instead.`),s=Object.assign({role:"button"},s),this.tabIndex_=e.tabIndex;const i=Q(t,e,s);return this.player_.options_.experimentalSvgIcons||i.appendChild(Q("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(i),i}dispose(){this.controlTextEl_=null,super.dispose()}createControlTextEl(t){return this.controlTextEl_=Q("span",{className:"vjs-control-text"},{"aria-live":"polite"}),t&&t.appendChild(this.controlTextEl_),this.controlText(this.controlText_,t),this.controlTextEl_}controlText(t,e=this.el()){if(void 0===t)return this.controlText_||"Need Text";const s=this.localize(t);this.controlText_=t,Z(this.controlTextEl_,s),this.nonIconControl||this.player_.options_.noUITitleAttributes||e.setAttribute("title",s)}buildCSSClass(){return`vjs-control vjs-button ${super.buildCSSClass()}`}enable(){this.enabled_||(this.enabled_=!0,this.removeClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","false"),void 0!==this.tabIndex_&&this.el_.setAttribute("tabIndex",this.tabIndex_),this.on(["tap","click"],this.handleClick_),this.on("keydown",this.handleKeyDown_))}disable(){this.enabled_=!1,this.addClass("vjs-disabled"),this.el_.setAttribute("aria-disabled","true"),void 0!==this.tabIndex_&&this.el_.removeAttribute("tabIndex"),this.off("mouseover",this.handleMouseOver_),this.off("mouseout",this.handleMouseOut_),this.off(["tap","click"],this.handleClick_),this.off("keydown",this.handleKeyDown_)}handleLanguagechange(){this.controlText(this.controlText_)}handleClick(t){this.options_.clickHandler&&this.options_.clickHandler.call(this,arguments)}handleKeyDown(t){" "===t.key||"Enter"===t.key?(t.preventDefault(),t.stopPropagation(),this.trigger("click")):super.handleKeyDown(t)}}ge.registerComponent("ClickableComponent",Ei);class Si extends Ei{constructor(t,e){super(t,e),this.update(),this.update_=t=>this.update(t),t.on("posterchange",this.update_)}dispose(){this.player().off("posterchange",this.update_),super.dispose()}createEl(){return Q("div",{className:"vjs-poster"})}crossOrigin(t){if(void 0===t)return this.$("img")?this.$("img").crossOrigin:this.player_.tech_&&this.player_.tech_.isReady_?this.player_.crossOrigin():this.player_.options_.crossOrigin||this.player_.options_.crossorigin||null;null===t||"anonymous"===t||"use-credentials"===t?this.$("img")&&(this.$("img").crossOrigin=t):this.player_.log.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${t}"`)}update(t){const e=this.player().poster();this.setSrc(e),e?this.show():this.hide()}setSrc(t){t?(this.$("img")||this.el_.appendChild(Q("picture",{className:"vjs-poster",tabIndex:-1},{},Q("img",{loading:"lazy",crossOrigin:this.crossOrigin()},{alt:""}))),this.$("img").src=t):this.el_.textContent=""}handleClick(t){this.player_.controls()&&(this.player_.tech(!0)&&this.player_.tech(!0).focus(),this.player_.paused()?Le(this.player_.play()):this.player_.pause())}}Si.prototype.crossorigin=Si.prototype.crossOrigin,ge.registerComponent("PosterImage",Si);const Ci="#222",ki="#ccc",wi={monospace:"monospace",sansSerif:"sans-serif",serif:"serif",monospaceSansSerif:'"Andale Mono", "Lucida Console", monospace',monospaceSerif:'"Courier New", monospace',proportionalSansSerif:"sans-serif",proportionalSerif:"serif",casual:'"Comic Sans MS", Impact, fantasy',script:'"Monotype Corsiva", cursive',smallcaps:'"Andale Mono", "Lucida Console", monospace, sans-serif'};function Li(t,e){let s;if(4===t.length)s=t[1]+t[1]+t[2]+t[2]+t[3]+t[3];else{if(7!==t.length)throw new Error("Invalid color code provided, "+t+"; must be formatted as e.g. #f0e or #f604e2.");s=t.slice(1)}return"rgba("+parseInt(s.slice(0,2),16)+","+parseInt(s.slice(2,4),16)+","+parseInt(s.slice(4,6),16)+","+e+")"}function Ii(t,e,s){try{t.style[e]=s}catch(t){return}}function Pi(t){return t?`${t}px`:""}ge.registerComponent("TextTrackDisplay",class extends ge{constructor(t,e,s){super(t,e,s);const i=t=>this.updateDisplay(t),r=t=>{this.updateDisplayOverlay(),this.updateDisplay(t)};t.on("loadstart",t=>this.toggleDisplay(t)),t.on("useractive",i),t.on("userinactive",i),t.on("texttrackchange",i),t.on("loadedmetadata",t=>{this.updateDisplayOverlay(),this.preselectTrack(t)}),t.ready(zt(this,function(){if(t.tech_&&t.tech_.featuresNativeTextTracks)return void this.hide();t.on("fullscreenchange",r),t.on("playerresize",r);const e=window.screen.orientation||window,s=window.screen.orientation?"change":"orientationchange";e.addEventListener(s,r),t.on("dispose",()=>e.removeEventListener(s,r));const i=this.options_.playerOptions.tracks||[];for(let t=0;t<i.length;t++)this.player_.addRemoteTextTrack(i[t],!0);this.preselectTrack()}))}preselectTrack(){const t={captions:1,subtitles:1},e=this.player_.textTracks(),s=this.player_.cache_.selectedLanguage;let i,r,n;for(let a=0;a<e.length;a++){const o=e[a];s&&s.enabled&&s.language&&s.language===o.language&&o.kind in t?o.kind===s.kind?n=o:n||(n=o):s&&!s.enabled?(n=null,i=null,r=null):o.default&&("descriptions"!==o.kind||i?o.kind in t&&!r&&(r=o):i=o)}n?n.mode="showing":r?r.mode="showing":i&&(i.mode="showing")}toggleDisplay(){this.player_.tech_&&this.player_.tech_.featuresNativeTextTracks?this.hide():this.show()}createEl(){return super.createEl("div",{className:"vjs-text-track-display"},{translate:"yes","aria-live":"off","aria-atomic":"true"})}clearDisplay(){"function"==typeof window.WebVTT&&window.WebVTT.processCues(window,[],this.el_)}updateDisplay(){const t=this.player_.textTracks(),e=this.options_.allowMultipleShowingTracks;if(this.clearDisplay(),e){const e=[];for(let s=0;s<t.length;++s){const i=t[s];"showing"===i.mode&&e.push(i)}return void this.updateForTrack(e)}let s=null,i=null,r=t.length;for(;r--;){const e=t[r];"showing"===e.mode&&("descriptions"===e.kind?s=e:i=e)}if(i?("off"!==this.getAttribute("aria-live")&&this.setAttribute("aria-live","off"),this.updateForTrack(i)):s&&("assertive"!==this.getAttribute("aria-live")&&this.setAttribute("aria-live","assertive"),this.updateForTrack(s)),!window.CSS.supports("inset","10px")){const t=this.el_,e=t.querySelectorAll(".vjs-text-track-cue"),s=this.player_.controlBar.el_.getBoundingClientRect().height,i=this.player_.el_.getBoundingClientRect().height;t.style="",Ii(t,"position","relative"),Ii(t,"height",i-s+"px"),Ii(t,"top","unset"),Ii(t,"bottom",$?i+"px":"0px"),e.length>0&&e.forEach(t=>{if(t.style.inset){const e=t.style.inset.split(" ");3===e.length&&Object.assign(t.style,{top:e[0],right:e[1],bottom:e[2],left:"unset"})}})}}updateDisplayOverlay(){if(!this.player_.videoHeight()||!window.CSS.supports("inset-inline: 10px"))return;const t=this.player_.currentWidth(),e=this.player_.currentHeight(),s=t/e,i=this.player_.videoWidth()/this.player_.videoHeight();let r=0,n=0;Math.abs(s-i)>.1&&(s>i?r=Math.round((t-e*i)/2):n=Math.round((e-t/i)/2)),Ii(this.el_,"insetInline",Pi(r)),Ii(this.el_,"insetBlock",Pi(n))}updateDisplayState(t){const e=this.player_.textTrackSettings.getValues(),s=t.activeCues;let i=s.length;for(;i--;){const t=s[i];if(!t)continue;const r=t.displayState;if(e.color&&(r.firstChild.style.color=e.color),e.textOpacity&&Ii(r.firstChild,"color",Li(e.color||"#fff",e.textOpacity)),e.backgroundColor&&(r.firstChild.style.backgroundColor=e.backgroundColor),e.backgroundOpacity&&Ii(r.firstChild,"backgroundColor",Li(e.backgroundColor||"#000",e.backgroundOpacity)),e.windowColor&&(e.windowOpacity?Ii(r,"backgroundColor",Li(e.windowColor,e.windowOpacity)):r.style.backgroundColor=e.windowColor),e.edgeStyle&&("dropshadow"===e.edgeStyle?r.firstChild.style.textShadow=`2px 2px 3px ${Ci}, 2px 2px 4px ${Ci}, 2px 2px 5px ${Ci}`:"raised"===e.edgeStyle?r.firstChild.style.textShadow=`1px 1px ${Ci}, 2px 2px ${Ci}, 3px 3px ${Ci}`:"depressed"===e.edgeStyle?r.firstChild.style.textShadow=`1px 1px ${ki}, 0 1px ${ki}, -1px -1px ${Ci}, 0 -1px ${Ci}`:"uniform"===e.edgeStyle&&(r.firstChild.style.textShadow=`0 0 4px ${Ci}, 0 0 4px ${Ci}, 0 0 4px ${Ci}, 0 0 4px ${Ci}`)),e.fontPercent&&1!==e.fontPercent){const t=window.parseFloat(r.style.fontSize);r.style.fontSize=t*e.fontPercent+"px",r.style.height="auto",r.style.top="auto"}e.fontFamily&&"default"!==e.fontFamily&&("small-caps"===e.fontFamily?r.firstChild.style.fontVariant="small-caps":r.firstChild.style.fontFamily=wi[e.fontFamily])}}updateForTrack(t){if(Array.isArray(t)||(t=[t]),"function"!=typeof window.WebVTT||t.every(t=>!t.activeCues))return;const e=[];for(let s=0;s<t.length;++s){const i=t[s];for(let t=0;t<i.activeCues.length;++t)e.push(i.activeCues[t])}window.WebVTT.processCues(window,e,this.el_);for(let e=0;e<t.length;++e){const s=t[e];for(let t=0;t<s.activeCues.length;++t){const i=s.activeCues[t].displayState;et(i,"vjs-text-track-cue","vjs-text-track-cue-"+(s.language?s.language:e)),s.language&&ot(i,"lang",s.language)}this.player_.textTrackSettings&&this.updateDisplayState(s)}}});ge.registerComponent("LoadingSpinner",class extends ge{createEl(){const t=this.player_.isAudio(),e=this.localize(t?"Audio Player":"Video Player"),s=Q("span",{className:"vjs-control-text",textContent:this.localize("{1} is loading.",[e])}),i=super.createEl("div",{className:"vjs-loading-spinner",dir:"ltr"});return i.appendChild(s),i}handleLanguagechange(){this.$(".vjs-control-text").textContent=this.localize("{1} is loading.",[this.player_.isAudio()?"Audio Player":"Video Player"])}});class xi extends Ei{createEl(t,e={},s={}){const i=Q("button",e=Object.assign({className:this.buildCSSClass()},e),s=Object.assign({type:"button"},s));return this.player_.options_.experimentalSvgIcons||i.appendChild(Q("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),this.createControlTextEl(i),i}addChild(t,e={}){const s=this.constructor.name;return c.warn(`Adding an actionable (user controllable) child to a Button (${s}) is not supported; use a ClickableComponent instead.`),ge.prototype.addChild.call(this,t,e)}enable(){super.enable(),this.el_.removeAttribute("disabled")}disable(){super.disable(),this.el_.setAttribute("disabled","disabled")}handleKeyDown(t){" "!==t.key&&"Enter"!==t.key?super.handleKeyDown(t):t.stopPropagation()}}ge.registerComponent("Button",xi);class Ri extends xi{constructor(t,e){super(t,e),this.mouseused_=!1,this.setIcon("play"),this.on("mousedown",t=>this.handleMouseDown(t))}buildCSSClass(){return"vjs-big-play-button"}handleClick(t){const e=this.player_.play();if("tap"===t.type||this.mouseused_&&"clientX"in t&&"clientY"in t)return Le(e),void(this.player_.tech(!0)&&this.player_.tech(!0).focus());const s=this.player_.getChild("controlBar"),i=s&&s.getChild("playToggle");if(!i)return void this.player_.tech(!0).focus();const r=()=>i.focus();we(e)?e.then(r,()=>{}):this.setTimeout(r,1)}handleKeyDown(t){this.mouseused_=!1,super.handleKeyDown(t)}handleMouseDown(t){this.mouseused_=!0}}Ri.prototype.controlText_="Play Video",ge.registerComponent("BigPlayButton",Ri);ge.registerComponent("CloseButton",class extends xi{constructor(t,e){super(t,e),this.setIcon("cancel"),this.controlText(e&&e.controlText||this.localize("Close"))}buildCSSClass(){return`vjs-close-button ${super.buildCSSClass()}`}handleClick(t){this.trigger({type:"close",bubbles:!1})}handleKeyDown(t){"Escape"===t.key?(t.preventDefault(),t.stopPropagation(),this.trigger("click")):super.handleKeyDown(t)}});class Di extends xi{constructor(t,e={}){super(t,e),e.replay=void 0===e.replay||e.replay,this.setIcon("play"),this.on(t,"play",t=>this.handlePlay(t)),this.on(t,"pause",t=>this.handlePause(t)),e.replay&&this.on(t,"ended",t=>this.handleEnded(t))}buildCSSClass(){return`vjs-play-control ${super.buildCSSClass()}`}handleClick(t){this.player_.paused()?Le(this.player_.play()):this.player_.pause()}handleSeeked(t){this.removeClass("vjs-ended"),this.player_.paused()?this.handlePause(t):this.handlePlay(t)}handlePlay(t){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.setIcon("pause"),this.controlText("Pause")}handlePause(t){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.setIcon("play"),this.controlText("Play")}handleEnded(t){this.removeClass("vjs-playing"),this.addClass("vjs-ended"),this.setIcon("replay"),this.controlText("Replay"),this.one(this.player_,"seeked",t=>this.handleSeeked(t))}}Di.prototype.controlText_="Play",ge.registerComponent("PlayToggle",Di);class Oi extends ge{constructor(t,e){super(t,e),this.on(t,["timeupdate","ended","seeking"],t=>this.update(t)),this.updateTextNode_()}createEl(){const t=this.buildCSSClass(),e=super.createEl("div",{className:`${t} vjs-time-control vjs-control`}),s=Q("span",{className:"vjs-control-text",textContent:`${this.localize(this.labelText_)} `},{role:"presentation"});return e.appendChild(s),this.contentEl_=Q("span",{className:`${t}-display`},{role:"presentation"}),e.appendChild(this.contentEl_),e}dispose(){this.contentEl_=null,this.textNode_=null,super.dispose()}update(t){(this.player_.options_.enableSmoothSeeking||"seeking"!==t.type)&&this.updateContent(t)}updateTextNode_(t=0){t=Ee(t),this.formattedTime_!==t&&(this.formattedTime_=t,this.requestNamedAnimationFrame("TimeDisplay#updateTextNode_",()=>{if(!this.contentEl_)return;let t=this.textNode_;t&&this.contentEl_.firstChild!==t&&(t=null,c.warn("TimeDisplay#updateTextnode_: Prevented replacement of text node element since it was no longer a child of this node. Appending a new node instead.")),this.textNode_=document.createTextNode(this.formattedTime_),this.textNode_&&(t?this.contentEl_.replaceChild(this.textNode_,t):this.contentEl_.appendChild(this.textNode_))}))}updateContent(t){}}Oi.prototype.labelText_="Time",Oi.prototype.controlText_="Time",ge.registerComponent("TimeDisplay",Oi);class Mi extends Oi{buildCSSClass(){return"vjs-current-time"}updateContent(t){let e;e=this.player_.ended()?this.player_.duration():t&&t.target&&"function"==typeof t.target.pendingSeekTime?t.target.pendingSeekTime():this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime(),this.updateTextNode_(e)}}Mi.prototype.labelText_="Current Time",Mi.prototype.controlText_="Current Time",ge.registerComponent("CurrentTimeDisplay",Mi);class Fi extends Oi{constructor(t,e){super(t,e);const s=t=>this.updateContent(t);this.on(t,"durationchange",s),this.on(t,"loadstart",s),this.on(t,"loadedmetadata",s)}buildCSSClass(){return"vjs-duration"}updateContent(t){const e=this.player_.duration();this.updateTextNode_(e)}}Fi.prototype.labelText_="Duration",Fi.prototype.controlText_="Duration",ge.registerComponent("DurationDisplay",Fi);ge.registerComponent("TimeDivider",class extends ge{createEl(){const t=super.createEl("div",{className:"vjs-time-control vjs-time-divider"},{"aria-hidden":!0}),e=super.createEl("div"),s=super.createEl("span",{textContent:"/"});return e.appendChild(s),t.appendChild(e),t}});class Ni extends Oi{constructor(t,e){super(t,e),this.on(t,"durationchange",t=>this.updateContent(t))}buildCSSClass(){return"vjs-remaining-time"}createEl(){const t=super.createEl();return!1!==this.options_.displayNegative&&t.insertBefore(Q("span",{},{"aria-hidden":!0},"-"),this.contentEl_),t}updateContent(t){if("number"!=typeof this.player_.duration())return;let e;e=this.player_.ended()?0:this.player_.remainingTimeDisplay?this.player_.remainingTimeDisplay():this.player_.remainingTime(),this.updateTextNode_(e)}}Ni.prototype.labelText_="Remaining Time",Ni.prototype.controlText_="Remaining Time",ge.registerComponent("RemainingTimeDisplay",Ni);ge.registerComponent("LiveDisplay",class extends ge{constructor(t,e){super(t,e),this.updateShowing(),this.on(this.player(),"durationchange",t=>this.updateShowing(t))}createEl(){const t=super.createEl("div",{className:"vjs-live-control vjs-control"});return this.contentEl_=Q("div",{className:"vjs-live-display"},{"aria-live":"off"}),this.contentEl_.appendChild(Q("span",{className:"vjs-control-text",textContent:`${this.localize("Stream Type")} `})),this.contentEl_.appendChild(document.createTextNode(this.localize("LIVE"))),t.appendChild(this.contentEl_),t}dispose(){this.contentEl_=null,super.dispose()}updateShowing(t){this.player().duration()===1/0?this.show():this.hide()}});class Bi extends xi{constructor(t,e){super(t,e),this.updateLiveEdgeStatus(),this.player_.liveTracker&&(this.updateLiveEdgeStatusHandler_=t=>this.updateLiveEdgeStatus(t),this.on(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_))}createEl(){const t=super.createEl("button",{className:"vjs-seek-to-live-control vjs-control"});return this.setIcon("circle",t),this.textEl_=Q("span",{className:"vjs-seek-to-live-text",textContent:this.localize("LIVE")},{"aria-hidden":"true"}),t.appendChild(this.textEl_),t}updateLiveEdgeStatus(){!this.player_.liveTracker||this.player_.liveTracker.atLiveEdge()?(this.setAttribute("aria-disabled",!0),this.addClass("vjs-at-live-edge"),this.controlText("Seek to live, currently playing live")):(this.setAttribute("aria-disabled",!1),this.removeClass("vjs-at-live-edge"),this.controlText("Seek to live, currently behind live"))}handleClick(){this.player_.liveTracker.seekToLiveEdge()}dispose(){this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.updateLiveEdgeStatusHandler_),this.textEl_=null,super.dispose()}}function ji(t,e,s){return t=Number(t),Math.min(s,Math.max(e,isNaN(t)?e:t))}Bi.prototype.controlText_="Seek to live, currently playing live",ge.registerComponent("SeekToLive",Bi);var $i=Object.freeze({__proto__:null,clamp:ji});class Ui extends ge{constructor(t,e){super(t,e),this.handleMouseDown_=t=>this.handleMouseDown(t),this.handleMouseUp_=t=>this.handleMouseUp(t),this.handleKeyDown_=t=>this.handleKeyDown(t),this.handleClick_=t=>this.handleClick(t),this.handleMouseMove_=t=>this.handleMouseMove(t),this.update_=t=>this.update(t),this.bar=this.getChild(this.options_.barName),this.vertical(!!this.options_.vertical),this.enable()}enabled(){return this.enabled_}enable(){this.enabled()||(this.on("mousedown",this.handleMouseDown_),this.on("touchstart",this.handleMouseDown_),this.on("keydown",this.handleKeyDown_),this.on("click",this.handleClick_),this.on(this.player_,"controlsvisible",this.update),this.playerEvent&&this.on(this.player_,this.playerEvent,this.update),this.removeClass("disabled"),this.setAttribute("tabindex",0),this.enabled_=!0)}disable(){if(!this.enabled())return;const t=this.bar.el_.ownerDocument;this.off("mousedown",this.handleMouseDown_),this.off("touchstart",this.handleMouseDown_),this.off("keydown",this.handleKeyDown_),this.off("click",this.handleClick_),this.off(this.player_,"controlsvisible",this.update_),this.off(t,"mousemove",this.handleMouseMove_),this.off(t,"mouseup",this.handleMouseUp_),this.off(t,"touchmove",this.handleMouseMove_),this.off(t,"touchend",this.handleMouseUp_),this.removeAttribute("tabindex"),this.addClass("disabled"),this.playerEvent&&this.off(this.player_,this.playerEvent,this.update),this.enabled_=!1}createEl(t,e={},s={}){return e.className=e.className+" vjs-slider",e=Object.assign({tabIndex:0},e),s=Object.assign({role:"slider","aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100},s),super.createEl(t,e,s)}handleMouseDown(t){const e=this.bar.el_.ownerDocument;"mousedown"===t.type&&t.preventDefault(),"touchstart"!==t.type||I||t.preventDefault(),ht(),this.addClass("vjs-sliding"),this.trigger("slideractive"),this.on(e,"mousemove",this.handleMouseMove_),this.on(e,"mouseup",this.handleMouseUp_),this.on(e,"touchmove",this.handleMouseMove_),this.on(e,"touchend",this.handleMouseUp_),this.handleMouseMove(t,!0)}handleMouseMove(t){}handleMouseUp(t){const e=this.bar.el_.ownerDocument;ct(),this.removeClass("vjs-sliding"),this.trigger("sliderinactive"),this.off(e,"mousemove",this.handleMouseMove_),this.off(e,"mouseup",this.handleMouseUp_),this.off(e,"touchmove",this.handleMouseMove_),this.off(e,"touchend",this.handleMouseUp_),this.update()}update(){if(!this.el_||!this.bar)return;const t=this.getProgress();return t===this.progress_||(this.progress_=t,this.requestNamedAnimationFrame("Slider#update",()=>{const e=this.vertical()?"height":"width";this.bar.el().style[e]=(100*t).toFixed(2)+"%"})),t}getProgress(){return Number(ji(this.getPercent(),0,1).toFixed(4))}calculateDistance(t){const e=pt(this.el_,t);return this.vertical()?e.y:e.x}handleKeyDown(t){const e=this.options_.playerOptions.spatialNavigation,s=e&&e.enabled,i=e&&e.horizontalSeek;s?i&&"ArrowLeft"===t.key||!i&&"ArrowDown"===t.key?(t.preventDefault(),t.stopPropagation(),this.stepBack()):i&&"ArrowRight"===t.key||!i&&"ArrowUp"===t.key?(t.preventDefault(),t.stopPropagation(),this.stepForward()):(this.pendingSeekTime()&&(this.pendingSeekTime(null),this.userSeek_(this.player_.currentTime())),super.handleKeyDown(t)):"ArrowLeft"===t.key||"ArrowDown"===t.key?(t.preventDefault(),t.stopPropagation(),this.stepBack()):"ArrowUp"===t.key||"ArrowRight"===t.key?(t.preventDefault(),t.stopPropagation(),this.stepForward()):super.handleKeyDown(t)}handleClick(t){t.stopPropagation(),t.preventDefault()}vertical(t){if(void 0===t)return this.vertical_||!1;this.vertical_=!!t,this.vertical_?this.addClass("vjs-slider-vertical"):this.addClass("vjs-slider-horizontal")}}ge.registerComponent("Slider",Ui);const Hi=(t,e)=>ji(t/e*100,0,100).toFixed(2)+"%";ge.registerComponent("LoadProgressBar",class extends ge{constructor(t,e){super(t,e),this.partEls_=[],this.on(t,"progress",t=>this.update(t))}createEl(){const t=super.createEl("div",{className:"vjs-load-progress"}),e=Q("span",{className:"vjs-control-text"}),s=Q("span",{textContent:this.localize("Loaded")}),i=document.createTextNode(": ");return this.percentageEl_=Q("span",{className:"vjs-control-text-loaded-percentage",textContent:"0%"}),t.appendChild(e),e.appendChild(s),e.appendChild(i),e.appendChild(this.percentageEl_),t}dispose(){this.partEls_=null,this.percentageEl_=null,super.dispose()}update(t){this.requestNamedAnimationFrame("LoadProgressBar#update",()=>{const t=this.player_.liveTracker,e=this.player_.buffered(),s=t&&t.isLive()?t.seekableEnd():this.player_.duration(),i=this.player_.bufferedEnd(),r=this.partEls_,n=Hi(i,s);this.percent_!==n&&(this.el_.style.width=n,Z(this.percentageEl_,n),this.percent_=n);for(let t=0;t<e.length;t++){const s=e.start(t),n=e.end(t);let a=r[t];a||(a=this.el_.appendChild(Q()),r[t]=a),a.dataset.start===s&&a.dataset.end===n||(a.dataset.start=s,a.dataset.end=n,a.style.left=Hi(s,i),a.style.width=Hi(n-s,i))}for(let t=r.length;t>e.length;t--)this.el_.removeChild(r[t-1]);r.length=e.length})}});ge.registerComponent("TimeTooltip",class extends ge{constructor(t,e){super(t,e),this.update=qt(zt(this,this.update),Kt)}createEl(){return super.createEl("div",{className:"vjs-time-tooltip"},{"aria-hidden":"true"})}update(t,e,s){const i=ut(this.el_),r=dt(this.player_.el()),n=t.width*e;if(!r||!i)return;let a=t.left-r.left+n,o=t.width-n+(r.right-t.right);o||(o=t.width-n,a=n);let l=i.width/2;a<l?l+=l-a:o<l&&(l=o),l<0?l=0:l>i.width&&(l=i.width),l=Math.round(l),this.el_.style.right=`-${l}px`,this.write(s)}write(t){Z(this.el_,t)}updateTime(t,e,s,i){this.requestNamedAnimationFrame("TimeTooltip#updateTime",()=>{let r;const n=this.player_.duration();if(this.player_.liveTracker&&this.player_.liveTracker.isLive()){const t=this.player_.liveTracker.liveWindow(),s=t-e*t;r=(s<1?"":"-")+Ee(s,t)}else r=Ee(s,n);this.update(t,e,r),i&&i()})}});class Vi extends ge{constructor(t,e){super(t,e),this.setIcon("circle"),this.update=qt(zt(this,this.update),Kt)}createEl(){return super.createEl("div",{className:"vjs-play-progress vjs-slider-bar"},{"aria-hidden":"true"})}update(t,e,s){const i=this.getChild("timeTooltip");if(!i)return;const r=s&&s.target&&"function"==typeof s.target.pendingSeekTime?s.target.pendingSeekTime():this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();i.updateTime(t,e,r)}}Vi.prototype.options_={children:[]},V||C||Vi.prototype.options_.children.push("timeTooltip"),ge.registerComponent("PlayProgressBar",Vi);class Gi extends ge{constructor(t,e){super(t,e),this.update=qt(zt(this,this.update),Kt)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(t,e){const s=e*this.player_.duration();this.getChild("timeTooltip").updateTime(t,e,s,()=>{this.el_.style.left=t.width*e+"px"})}}Gi.prototype.options_={children:["timeTooltip"]},ge.registerComponent("MouseTimeDisplay",Gi);class Wi extends Ui{constructor(t,e){(e=v(Wi.prototype.options_,e)).children=[...e.children];const s=t.options_.disableSeekWhileScrubbingOnMobile&&(V||C)||t.options_.disableSeekWhileScrubbingOnSTV;(!V&&!C||s)&&e.children.splice(1,0,"mouseTimeDisplay"),super(t,e),this.shouldDisableSeekWhileScrubbing_=s,this.pendingSeekTime_=null,this.setEventHandlers_()}setEventHandlers_(){this.update_=zt(this,this.update),this.update=qt(this.update_,Kt),this.on(this.player_,["durationchange","timeupdate"],this.update),this.on(this.player_,["ended"],this.update_),this.player_.liveTracker&&this.on(this.player_.liveTracker,"liveedgechange",this.update),this.updateInterval=null,this.enableIntervalHandler_=t=>this.enableInterval_(t),this.disableIntervalHandler_=t=>this.disableInterval_(t),this.on(this.player_,["playing"],this.enableIntervalHandler_),this.on(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in document&&"visibilityState"in document&&this.on(document,"visibilitychange",this.toggleVisibility_)}toggleVisibility_(t){"hidden"===document.visibilityState?(this.cancelNamedAnimationFrame("SeekBar#update"),this.cancelNamedAnimationFrame("Slider#update"),this.disableInterval_(t)):(this.player_.ended()||this.player_.paused()||this.enableInterval_(),this.update())}enableInterval_(){this.updateInterval||(this.updateInterval=this.setInterval(this.update,Kt))}disableInterval_(t){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&t&&"ended"!==t.type||this.updateInterval&&(this.clearInterval(this.updateInterval),this.updateInterval=null)}createEl(){return super.createEl("div",{className:"vjs-progress-holder"},{"aria-label":this.localize("Progress Bar")})}update(t){if("hidden"===document.visibilityState)return;const e=super.update();return this.requestNamedAnimationFrame("SeekBar#update",()=>{const s=this.player_.ended()?this.player_.duration():this.getCurrentTime_(),i=this.player_.liveTracker;let r=this.player_.duration();i&&i.isLive()&&(r=this.player_.liveTracker.liveCurrentTime()),this.percent_!==e&&(this.el_.setAttribute("aria-valuenow",(100*e).toFixed(2)),this.percent_=e),this.currentTime_===s&&this.duration_===r||(this.el_.setAttribute("aria-valuetext",this.localize("progress bar timing: currentTime={1} duration={2}",[Ee(s,r),Ee(r,r)],"{1} of {2}")),this.currentTime_=s,this.duration_=r),this.bar&&this.bar.update(dt(this.el()),this.getProgress(),t)}),e}userSeek_(t){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(t)}getCurrentTime_(){return this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime()}pendingSeekTime(t){if(void 0!==t)if(null!==t){const e=this.player_.duration();this.pendingSeekTime_=Math.max(0,Math.min(t,e))}else this.pendingSeekTime_=null;return this.pendingSeekTime_}getPercent(){if(null!==this.pendingSeekTime())return this.pendingSeekTime()/this.player_.duration();const t=this.getCurrentTime_();let e;const s=this.player_.liveTracker;return s&&s.isLive()?(e=(t-s.seekableStart())/s.liveWindow(),s.atLiveEdge()&&(e=1)):e=t/this.player_.duration(),e}handleMouseDown(t){bt(t)&&(t.stopPropagation(),this.videoWasPlaying=!this.player_.paused(),this.shouldDisableSeekWhileScrubbing_||this.player_.pause(),super.handleMouseDown(t))}handleMouseMove(t,e=!1){if(!bt(t)||isNaN(this.player_.duration()))return;let s;e||this.player_.scrubbing()||this.player_.scrubbing(!0);const i=this.calculateDistance(t),r=this.player_.liveTracker;if(r&&r.isLive()){if(i>=.99)return void r.seekToLiveEdge();const t=r.seekableStart(),e=r.liveCurrentTime();if(s=t+i*r.liveWindow(),s>=e&&(s=e),s<=t&&(s=t+.1),s===1/0)return}else s=i*this.player_.duration(),s===this.player_.duration()&&(s-=.1);this.shouldDisableSeekWhileScrubbing_?this.pendingSeekTime(s):this.userSeek_(s),this.player_.options_.enableSmoothSeeking&&this.update()}enable(){super.enable();const t=this.getChild("mouseTimeDisplay");t&&t.show()}disable(){super.disable();const t=this.getChild("mouseTimeDisplay");t&&t.hide()}handleMouseUp(t){super.handleMouseUp(t),t&&t.stopPropagation(),this.player_.scrubbing(!1),null!==this.pendingSeekTime()&&(this.userSeek_(this.pendingSeekTime()),this.pendingSeekTime(null)),this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:!0}),this.videoWasPlaying?Le(this.player_.play()):this.update_()}handlePendingSeek_(t){this.player_.paused()||this.player_.pause();const e=null!==this.pendingSeekTime()?this.pendingSeekTime():this.player_.currentTime();this.pendingSeekTime(e+t),this.player_.trigger({type:"timeupdate",target:this,manuallyTriggered:!0})}stepForward(){this.shouldDisableSeekWhileScrubbing_?this.handlePendingSeek_(this.options().stepSeconds):this.userSeek_(this.player_.currentTime()+this.options().stepSeconds)}stepBack(){this.shouldDisableSeekWhileScrubbing_?this.handlePendingSeek_(-this.options().stepSeconds):this.userSeek_(this.player_.currentTime()-this.options().stepSeconds)}handleAction(t){null!==this.pendingSeekTime()&&(this.userSeek_(this.pendingSeekTime()),this.pendingSeekTime(null)),this.player_.paused()?this.player_.play():this.player_.pause()}handleKeyDown(t){const e=this.player_.liveTracker;if(" "===t.key||"Enter"===t.key)t.preventDefault(),t.stopPropagation(),this.handleAction(t);else if("Home"===t.key)t.preventDefault(),t.stopPropagation(),this.userSeek_(0);else if("End"===t.key)t.preventDefault(),t.stopPropagation(),e&&e.isLive()?this.userSeek_(e.liveCurrentTime()):this.userSeek_(this.player_.duration());else if(/^[0-9]$/.test(t.key)){t.preventDefault(),t.stopPropagation();const s=.1*parseInt(t.key,10);e&&e.isLive()?this.userSeek_(e.seekableStart()+e.liveWindow()*s):this.userSeek_(this.player_.duration()*s)}else"PageDown"===t.key?(t.preventDefault(),t.stopPropagation(),this.userSeek_(this.player_.currentTime()-this.options().stepSeconds*this.options().pageMultiplier)):"PageUp"===t.key?(t.preventDefault(),t.stopPropagation(),this.userSeek_(this.player_.currentTime()+this.options().stepSeconds*this.options().pageMultiplier)):super.handleKeyDown(t)}dispose(){this.disableInterval_(),this.off(this.player_,["durationchange","timeupdate"],this.update),this.off(this.player_,["ended"],this.update_),this.player_.liveTracker&&this.off(this.player_.liveTracker,"liveedgechange",this.update),this.off(this.player_,["playing"],this.enableIntervalHandler_),this.off(this.player_,["ended","pause","waiting"],this.disableIntervalHandler_),"hidden"in document&&"visibilityState"in document&&this.off(document,"visibilitychange",this.toggleVisibility_),super.dispose()}}Wi.prototype.options_={children:["loadProgressBar","playProgressBar"],barName:"playProgressBar",stepSeconds:5,pageMultiplier:12},ge.registerComponent("SeekBar",Wi);class Ki extends ge{constructor(t,e){super(t,e),this.handleMouseMove=qt(zt(this,this.handleMouseMove),Kt),this.throttledHandleMouseSeek=qt(zt(this,this.handleMouseSeek),Kt),this.handleMouseUpHandler_=t=>this.handleMouseUp(t),this.handleMouseDownHandler_=t=>this.handleMouseDown(t),this.enable()}createEl(){return super.createEl("div",{className:"vjs-progress-control vjs-control"})}handleMouseMove(t){const e=this.getChild("seekBar");if(!e)return;const s=e.getChild("playProgressBar"),i=e.getChild("mouseTimeDisplay");if(!s&&!i)return;const r=e.el(),n=ut(r);let a=pt(r,t).x;a=ji(a,0,1),i&&i.update(n,a),s&&s.update(n,e.getProgress())}handleMouseSeek(t){const e=this.getChild("seekBar");e&&e.handleMouseMove(t)}enabled(){return this.enabled_}disable(){if(this.children().forEach(t=>t.disable&&t.disable()),this.enabled()&&(this.off(["mousedown","touchstart"],this.handleMouseDownHandler_),this.off(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeListenersAddedOnMousedownAndTouchstart(),this.addClass("disabled"),this.enabled_=!1,this.player_.scrubbing())){const t=this.getChild("seekBar");this.player_.scrubbing(!1),t.videoWasPlaying&&Le(this.player_.play())}}enable(){this.children().forEach(t=>t.enable&&t.enable()),this.enabled()||(this.on(["mousedown","touchstart"],this.handleMouseDownHandler_),this.on(this.el_,["mousemove","touchmove"],this.handleMouseMove),this.removeClass("disabled"),this.enabled_=!0)}removeListenersAddedOnMousedownAndTouchstart(){const t=this.el_.ownerDocument;this.off(t,"mousemove",this.throttledHandleMouseSeek),this.off(t,"touchmove",this.throttledHandleMouseSeek),this.off(t,"mouseup",this.handleMouseUpHandler_),this.off(t,"touchend",this.handleMouseUpHandler_)}handleMouseDown(t){const e=this.el_.ownerDocument,s=this.getChild("seekBar");s&&s.handleMouseDown(t),this.on(e,"mousemove",this.throttledHandleMouseSeek),this.on(e,"touchmove",this.throttledHandleMouseSeek),this.on(e,"mouseup",this.handleMouseUpHandler_),this.on(e,"touchend",this.handleMouseUpHandler_)}handleMouseUp(t){const e=this.getChild("seekBar");e&&e.handleMouseUp(t),this.removeListenersAddedOnMousedownAndTouchstart()}}Ki.prototype.options_={children:["seekBar"]},ge.registerComponent("ProgressControl",Ki);class zi extends xi{constructor(t,e){super(t,e),this.setIcon("picture-in-picture-enter"),this.on(t,["enterpictureinpicture","leavepictureinpicture"],t=>this.handlePictureInPictureChange(t)),this.on(t,["disablepictureinpicturechanged","loadedmetadata"],t=>this.handlePictureInPictureEnabledChange(t)),this.on(t,["loadedmetadata","audioonlymodechange","audiopostermodechange"],()=>this.handlePictureInPictureAudioModeChange()),this.disable()}buildCSSClass(){return`vjs-picture-in-picture-control vjs-hidden ${super.buildCSSClass()}`}handlePictureInPictureAudioModeChange(){"audio"===this.player_.currentType().substring(0,5)||this.player_.audioPosterMode()||this.player_.audioOnlyMode()?(this.player_.isInPictureInPicture()&&this.player_.exitPictureInPicture(),this.hide()):this.show()}handlePictureInPictureEnabledChange(){document.pictureInPictureEnabled&&!1===this.player_.disablePictureInPicture()||this.player_.options_.enableDocumentPictureInPicture&&"documentPictureInPicture"in window?this.enable():this.disable()}handlePictureInPictureChange(t){this.player_.isInPictureInPicture()?(this.setIcon("picture-in-picture-exit"),this.controlText("Exit Picture-in-Picture")):(this.setIcon("picture-in-picture-enter"),this.controlText("Picture-in-Picture")),this.handlePictureInPictureEnabledChange()}handleClick(t){this.player_.isInPictureInPicture()?this.player_.exitPictureInPicture():this.player_.requestPictureInPicture()}show(){"function"==typeof document.exitPictureInPicture&&super.show()}}zi.prototype.controlText_="Picture-in-Picture",ge.registerComponent("PictureInPictureToggle",zi);class qi extends xi{constructor(t,e){super(t,e),this.setIcon("fullscreen-enter"),this.on(t,"fullscreenchange",t=>this.handleFullscreenChange(t)),!1===document[t.fsApi_.fullscreenEnabled]&&this.disable()}buildCSSClass(){return`vjs-fullscreen-control ${super.buildCSSClass()}`}handleFullscreenChange(t){this.player_.isFullscreen()?(this.controlText("Exit Fullscreen"),this.setIcon("fullscreen-exit")):(this.controlText("Fullscreen"),this.setIcon("fullscreen-enter"))}handleClick(t){this.player_.isFullscreen()?this.player_.exitFullscreen():this.player_.requestFullscreen()}}qi.prototype.controlText_="Fullscreen",ge.registerComponent("FullscreenToggle",qi);ge.registerComponent("VolumeLevel",class extends ge{createEl(){const t=super.createEl("div",{className:"vjs-volume-level"});return this.setIcon("circle",t),t.appendChild(super.createEl("span",{className:"vjs-control-text"})),t}});ge.registerComponent("VolumeLevelTooltip",class extends ge{constructor(t,e){super(t,e),this.update=qt(zt(this,this.update),Kt)}createEl(){return super.createEl("div",{className:"vjs-volume-tooltip"},{"aria-hidden":"true"})}update(t,e,s,i){if(!s){const s=dt(this.el_),i=dt(this.player_.el()),r=t.width*e;if(!i||!s)return;const n=t.left-i.left+r,a=t.width-r+(i.right-t.right);let o=s.width/2;n<o?o+=o-n:a<o&&(o=a),o<0?o=0:o>s.width&&(o=s.width),this.el_.style.right=`-${o}px`}this.write(`${i}%`)}write(t){Z(this.el_,t)}updateVolume(t,e,s,i,r){this.requestNamedAnimationFrame("VolumeLevelTooltip#updateVolume",()=>{this.update(t,e,s,i.toFixed(0)),r&&r()})}});class Yi extends ge{constructor(t,e){super(t,e),this.update=qt(zt(this,this.update),Kt)}createEl(){return super.createEl("div",{className:"vjs-mouse-display"})}update(t,e,s){const i=100*e;this.getChild("volumeLevelTooltip").updateVolume(t,e,s,i,()=>{s?this.el_.style.bottom=t.height*e+"px":this.el_.style.left=t.width*e+"px"})}}Yi.prototype.options_={children:["volumeLevelTooltip"]},ge.registerComponent("MouseVolumeLevelDisplay",Yi);class Xi extends Ui{constructor(t,e){super(t,e),this.on("slideractive",t=>this.updateLastVolume_(t)),this.on(t,"volumechange",t=>this.updateARIAAttributes(t)),t.ready(()=>this.updateARIAAttributes())}createEl(){return super.createEl("div",{className:"vjs-volume-bar vjs-slider-bar"},{"aria-label":this.localize("Volume Level"),"aria-live":"polite"})}handleMouseDown(t){bt(t)&&super.handleMouseDown(t)}handleMouseMove(t){const e=this.getChild("mouseVolumeLevelDisplay");if(e){const s=this.el(),i=dt(s),r=this.vertical();let n=pt(s,t);n=r?n.y:n.x,n=ji(n,0,1),e.update(i,n,r)}bt(t)&&(this.checkMuted(),this.player_.volume(this.calculateDistance(t)))}checkMuted(){this.player_.muted()&&this.player_.muted(!1)}getPercent(){return this.player_.muted()?0:this.player_.volume()}stepForward(){this.checkMuted(),this.player_.volume(this.player_.volume()+.1)}stepBack(){this.checkMuted(),this.player_.volume(this.player_.volume()-.1)}updateARIAAttributes(t){const e=this.player_.muted()?0:this.volumeAsPercentage_();this.el_.setAttribute("aria-valuenow",e),this.el_.setAttribute("aria-valuetext",e+"%")}volumeAsPercentage_(){return Math.round(100*this.player_.volume())}updateLastVolume_(){const t=this.player_.volume();this.one("sliderinactive",()=>{0===this.player_.volume()&&this.player_.lastVolume_(t)})}}Xi.prototype.options_={children:["volumeLevel"],barName:"volumeLevel"},V||C||Xi.prototype.options_.children.splice(0,0,"mouseVolumeLevelDisplay"),Xi.prototype.playerEvent="volumechange",ge.registerComponent("VolumeBar",Xi);class Qi extends ge{constructor(t,e={}){e.vertical=e.vertical||!1,(void 0===e.volumeBar||y(e.volumeBar))&&(e.volumeBar=e.volumeBar||{},e.volumeBar.vertical=e.vertical),super(t,e),function(t,e){e.tech_&&!e.tech_.featuresVolumeControl&&t.addClass("vjs-hidden"),t.on(e,"loadstart",function(){e.tech_.featuresVolumeControl?t.removeClass("vjs-hidden"):t.addClass("vjs-hidden")})}(this,t),this.throttledHandleMouseMove=qt(zt(this,this.handleMouseMove),Kt),this.handleMouseUpHandler_=t=>this.handleMouseUp(t),this.on("mousedown",t=>this.handleMouseDown(t)),this.on("touchstart",t=>this.handleMouseDown(t)),this.on("mousemove",t=>this.handleMouseMove(t)),this.on(this.volumeBar,["focus","slideractive"],()=>{this.volumeBar.addClass("vjs-slider-active"),this.addClass("vjs-slider-active"),this.trigger("slideractive")}),this.on(this.volumeBar,["blur","sliderinactive"],()=>{this.volumeBar.removeClass("vjs-slider-active"),this.removeClass("vjs-slider-active"),this.trigger("sliderinactive")})}createEl(){let t="vjs-volume-horizontal";return this.options_.vertical&&(t="vjs-volume-vertical"),super.createEl("div",{className:`vjs-volume-control vjs-control ${t}`})}handleMouseDown(t){const e=this.el_.ownerDocument;this.on(e,"mousemove",this.throttledHandleMouseMove),this.on(e,"touchmove",this.throttledHandleMouseMove),this.on(e,"mouseup",this.handleMouseUpHandler_),this.on(e,"touchend",this.handleMouseUpHandler_)}handleMouseUp(t){const e=this.el_.ownerDocument;this.off(e,"mousemove",this.throttledHandleMouseMove),this.off(e,"touchmove",this.throttledHandleMouseMove),this.off(e,"mouseup",this.handleMouseUpHandler_),this.off(e,"touchend",this.handleMouseUpHandler_)}handleMouseMove(t){this.volumeBar.handleMouseMove(t)}}Qi.prototype.options_={children:["volumeBar"]},ge.registerComponent("VolumeControl",Qi);class Zi extends xi{constructor(t,e){super(t,e),function(t,e){e.tech_&&!e.tech_.featuresMuteControl&&t.addClass("vjs-hidden"),t.on(e,"loadstart",function(){e.tech_.featuresMuteControl?t.removeClass("vjs-hidden"):t.addClass("vjs-hidden")})}(this,t),this.on(t,["loadstart","volumechange"],t=>this.update(t))}buildCSSClass(){return`vjs-mute-control ${super.buildCSSClass()}`}handleClick(t){const e=this.player_.volume(),s=this.player_.lastVolume_();if(0===e){const t=s<.1?.1:s;this.player_.volume(t),this.player_.muted(!1)}else this.player_.muted(!this.player_.muted())}update(t){this.updateIcon_(),this.updateControlText_()}updateIcon_(){const t=this.player_.volume();let e=3;this.setIcon("volume-high"),V&&this.player_.tech_&&this.player_.tech_.el_&&this.player_.muted(this.player_.tech_.el_.muted),0===t||this.player_.muted()?(this.setIcon("volume-mute"),e=0):t<.33?(this.setIcon("volume-low"),e=1):t<.67&&(this.setIcon("volume-medium"),e=2),st(this.el_,[0,1,2,3].reduce((t,e)=>t+`${e?" ":""}vjs-vol-${e}`,"")),et(this.el_,`vjs-vol-${e}`)}updateControlText_(){const t=this.player_.muted()||0===this.player_.volume()?"Unmute":"Mute";this.controlText()!==t&&this.controlText(t)}}Zi.prototype.controlText_="Mute",ge.registerComponent("MuteToggle",Zi);class Ji extends ge{constructor(t,e={}){void 0!==e.inline?e.inline=e.inline:e.inline=!0,(void 0===e.volumeControl||y(e.volumeControl))&&(e.volumeControl=e.volumeControl||{},e.volumeControl.vertical=!e.inline),super(t,e),this.handleKeyPressHandler_=t=>this.handleKeyPress(t),this.on(t,["loadstart"],t=>this.volumePanelState_(t)),this.on(this.muteToggle,"keyup",t=>this.handleKeyPress(t)),this.on(this.volumeControl,"keyup",t=>this.handleVolumeControlKeyUp(t)),this.on("keydown",t=>this.handleKeyPress(t)),this.on("mouseover",t=>this.handleMouseOver(t)),this.on("mouseout",t=>this.handleMouseOut(t)),this.on(this.volumeControl,["slideractive"],this.sliderActive_),this.on(this.volumeControl,["sliderinactive"],this.sliderInactive_)}sliderActive_(){this.addClass("vjs-slider-active")}sliderInactive_(){this.removeClass("vjs-slider-active")}volumePanelState_(){this.volumeControl.hasClass("vjs-hidden")&&this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-hidden"),this.volumeControl.hasClass("vjs-hidden")&&!this.muteToggle.hasClass("vjs-hidden")&&this.addClass("vjs-mute-toggle-only")}createEl(){let t="vjs-volume-panel-horizontal";return this.options_.inline||(t="vjs-volume-panel-vertical"),super.createEl("div",{className:`vjs-volume-panel vjs-control ${t}`})}dispose(){this.handleMouseOut(),super.dispose()}handleVolumeControlKeyUp(t){"Escape"===t.key&&this.muteToggle.focus()}handleMouseOver(t){this.addClass("vjs-hover"),$t(document,"keyup",this.handleKeyPressHandler_)}handleMouseOut(t){this.removeClass("vjs-hover"),Ut(document,"keyup",this.handleKeyPressHandler_)}handleKeyPress(t){"Escape"===t.key&&this.handleMouseOut()}}Ji.prototype.options_={children:["muteToggle","volumeControl"]},ge.registerComponent("VolumePanel",Ji);class tr extends xi{constructor(t,e){super(t,e),this.validOptions=[5,10,30],this.skipTime=this.getSkipForwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`forward-${this.skipTime}`),this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime.toLocaleString(t.language())])),this.show()):this.hide()}getSkipForwardTime(){const t=this.options_.playerOptions;return t.controlBar&&t.controlBar.skipButtons&&t.controlBar.skipButtons.forward}buildCSSClass(){return`vjs-skip-forward-${this.getSkipForwardTime()} ${super.buildCSSClass()}`}handleClick(t){if(isNaN(this.player_.duration()))return;const e=this.player_.currentTime(),s=this.player_.liveTracker,i=s&&s.isLive()?s.seekableEnd():this.player_.duration();let r;r=e+this.skipTime<=i?e+this.skipTime:i,this.player_.currentTime(r)}handleLanguagechange(){this.controlText(this.localize("Skip forward {1} seconds",[this.skipTime]))}}tr.prototype.controlText_="Skip Forward",ge.registerComponent("SkipForward",tr);class er extends xi{constructor(t,e){super(t,e),this.validOptions=[5,10,30],this.skipTime=this.getSkipBackwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`replay-${this.skipTime}`),this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime.toLocaleString(t.language())])),this.show()):this.hide()}getSkipBackwardTime(){const t=this.options_.playerOptions;return t.controlBar&&t.controlBar.skipButtons&&t.controlBar.skipButtons.backward}buildCSSClass(){return`vjs-skip-backward-${this.getSkipBackwardTime()} ${super.buildCSSClass()}`}handleClick(t){const e=this.player_.currentTime(),s=this.player_.liveTracker,i=s&&s.isLive()&&s.seekableStart();let r;r=i&&e-this.skipTime<=i?i:e>=this.skipTime?e-this.skipTime:0,this.player_.currentTime(r)}handleLanguagechange(){this.controlText(this.localize("Skip backward {1} seconds",[this.skipTime]))}}er.prototype.controlText_="Skip Backward",ge.registerComponent("SkipBackward",er);class sr extends ge{constructor(t,e){super(t,e),e&&(this.menuButton_=e.menuButton),this.focusedChild_=-1,this.on("keydown",t=>this.handleKeyDown(t)),this.boundHandleBlur_=t=>this.handleBlur(t),this.boundHandleTapClick_=t=>this.handleTapClick(t)}addEventListenerForItem(t){t instanceof ge&&(this.on(t,"blur",this.boundHandleBlur_),this.on(t,["tap","click"],this.boundHandleTapClick_))}removeEventListenerForItem(t){t instanceof ge&&(this.off(t,"blur",this.boundHandleBlur_),this.off(t,["tap","click"],this.boundHandleTapClick_))}removeChild(t){"string"==typeof t&&(t=this.getChild(t)),this.removeEventListenerForItem(t),super.removeChild(t)}addItem(t){const e=this.addChild(t);e&&this.addEventListenerForItem(e)}createEl(){const t=this.options_.contentElType||"ul";this.contentEl_=Q(t,{className:"vjs-menu-content"}),this.contentEl_.setAttribute("role","menu");const e=super.createEl("div",{append:this.contentEl_,className:"vjs-menu"});return e.appendChild(this.contentEl_),$t(e,"click",function(t){t.preventDefault(),t.stopImmediatePropagation()}),e}dispose(){this.contentEl_=null,this.boundHandleBlur_=null,this.boundHandleTapClick_=null,super.dispose()}handleBlur(t){const e=t.relatedTarget||document.activeElement;if(!this.children().some(t=>t.el()===e)){const t=this.menuButton_;t&&t.buttonPressed_&&e!==t.el().firstChild&&t.unpressButton()}}handleTapClick(t){if(this.menuButton_){this.menuButton_.unpressButton();const e=this.children();if(!Array.isArray(e))return;const s=e.filter(e=>e.el()===t.target)[0];if(!s)return;"CaptionSettingsMenuItem"!==s.name()&&this.menuButton_.focus()}}handleKeyDown(t){"ArrowLeft"===t.key||"ArrowDown"===t.key?(t.preventDefault(),t.stopPropagation(),this.stepForward()):"ArrowRight"!==t.key&&"ArrowUp"!==t.key||(t.preventDefault(),t.stopPropagation(),this.stepBack())}stepForward(){let t=0;void 0!==this.focusedChild_&&(t=this.focusedChild_+1),this.focus(t)}stepBack(){let t=0;void 0!==this.focusedChild_&&(t=this.focusedChild_-1),this.focus(t)}focus(t=0){const e=this.children().slice();e.length&&e[0].hasClass("vjs-menu-title")&&e.shift(),e.length>0&&(t<0?t=0:t>=e.length&&(t=e.length-1),this.focusedChild_=t,e[t].el_.focus())}}ge.registerComponent("Menu",sr);class ir extends ge{constructor(t,e={}){super(t,e),this.menuButton_=new xi(t,e),this.menuButton_.controlText(this.controlText_),this.menuButton_.el_.setAttribute("aria-haspopup","true");const s=xi.prototype.buildCSSClass();this.menuButton_.el_.className=this.buildCSSClass()+" "+s,this.menuButton_.removeClass("vjs-control"),this.addChild(this.menuButton_),this.update(),this.enabled_=!0;const i=t=>this.handleClick(t);this.handleMenuKeyUp_=t=>this.handleMenuKeyUp(t),this.on(this.menuButton_,"tap",i),this.on(this.menuButton_,"click",i),this.on(this.menuButton_,"keydown",t=>this.handleKeyDown(t)),this.on(this.menuButton_,"mouseenter",()=>{this.addClass("vjs-hover"),this.menu.show(),$t(document,"keyup",this.handleMenuKeyUp_)}),this.on("mouseleave",t=>this.handleMouseLeave(t)),this.on("keydown",t=>this.handleSubmenuKeyDown(t))}update(){const t=this.createMenu();this.menu&&(this.menu.dispose(),this.removeChild(this.menu)),this.menu=t,this.addChild(t),this.buttonPressed_=!1,this.menuButton_.el_.setAttribute("aria-expanded","false"),this.items&&this.items.length<=this.hideThreshold_?(this.hide(),this.menu.contentEl_.removeAttribute("role")):(this.show(),this.menu.contentEl_.setAttribute("role","menu"))}createMenu(){const t=new sr(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title){const e=Q("li",{className:"vjs-menu-title",textContent:ue(this.options_.title),tabIndex:-1}),s=new ge(this.player_,{el:e});t.addItem(s)}if(this.items=this.createItems(),this.items)for(let e=0;e<this.items.length;e++)t.addItem(this.items[e]);return t}createItems(){}createEl(){return super.createEl("div",{className:this.buildWrapperCSSClass()},{})}setIcon(t){super.setIcon(t,this.menuButton_.el_)}buildWrapperCSSClass(){let t="vjs-menu-button";return!0===this.options_.inline?t+="-inline":t+="-popup",`vjs-menu-button ${t} ${xi.prototype.buildCSSClass()} ${super.buildCSSClass()}`}buildCSSClass(){let t="vjs-menu-button";return!0===this.options_.inline?t+="-inline":t+="-popup",`vjs-menu-button ${t} ${super.buildCSSClass()}`}controlText(t,e=this.menuButton_.el()){return this.menuButton_.controlText(t,e)}dispose(){this.handleMouseLeave(),super.dispose()}handleClick(t){this.buttonPressed_?this.unpressButton():this.pressButton()}handleMouseLeave(t){this.removeClass("vjs-hover"),Ut(document,"keyup",this.handleMenuKeyUp_)}focus(){this.menuButton_.focus()}blur(){this.menuButton_.blur()}handleKeyDown(t){"Escape"===t.key||"Tab"===t.key?(this.buttonPressed_&&this.unpressButton(),"Tab"===!t.key&&(t.preventDefault(),this.menuButton_.focus())):"Up"!==t.key&&("Down"!==t.key||this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled)||this.buttonPressed_||(t.preventDefault(),this.pressButton())}handleMenuKeyUp(t){"Escape"!==t.key&&"Tab"!==t.key||this.removeClass("vjs-hover")}handleSubmenuKeyPress(t){this.handleSubmenuKeyDown(t)}handleSubmenuKeyDown(t){"Escape"!==t.key&&"Tab"!==t.key||(this.buttonPressed_&&this.unpressButton(),"Tab"===!t.key&&(t.preventDefault(),this.menuButton_.focus()))}pressButton(){if(this.enabled_){if(this.buttonPressed_=!0,this.menu.show(),this.menu.lockShowing(),this.menuButton_.el_.setAttribute("aria-expanded","true"),V&&Y())return;this.menu.focus()}}unpressButton(){this.enabled_&&(this.buttonPressed_=!1,this.menu.unlockShowing(),this.menu.hide(),this.menuButton_.el_.setAttribute("aria-expanded","false"))}disable(){this.unpressButton(),this.enabled_=!1,this.addClass("vjs-disabled"),this.menuButton_.disable()}enable(){this.enabled_=!0,this.removeClass("vjs-disabled"),this.menuButton_.enable()}}ge.registerComponent("MenuButton",ir);class rr extends ir{constructor(t,e){const s=e.tracks;if(super(t,e),this.items.length<=1&&this.hide(),!s)return;const i=zt(this,this.update);s.addEventListener("removetrack",i),s.addEventListener("addtrack",i),s.addEventListener("labelchange",i),this.player_.on("ready",i),this.player_.on("dispose",function(){s.removeEventListener("removetrack",i),s.removeEventListener("addtrack",i),s.removeEventListener("labelchange",i)})}}ge.registerComponent("TrackButton",rr);class nr extends Ei{constructor(t,e){super(t,e),this.selectable=e.selectable,this.isSelected_=e.selected||!1,this.multiSelectable=e.multiSelectable,this.selected(this.isSelected_),this.selectable?this.multiSelectable?this.el_.setAttribute("role","menuitemcheckbox"):this.el_.setAttribute("role","menuitemradio"):this.el_.setAttribute("role","menuitem")}createEl(t,e,s){this.nonIconControl=!0;const i=super.createEl("li",Object.assign({className:"vjs-menu-item",tabIndex:-1},e),s),r=Q("span",{className:"vjs-menu-item-text",textContent:this.localize(this.options_.label)});return this.player_.options_.experimentalSvgIcons?i.appendChild(r):i.replaceChild(r,i.querySelector(".vjs-icon-placeholder")),i}handleKeyDown(t){["Tab","Escape","ArrowUp","ArrowLeft","ArrowRight","ArrowDown"].includes(t.key)||super.handleKeyDown(t)}handleClick(t){this.selected(!0)}selected(t){this.selectable&&(t?(this.addClass("vjs-selected"),this.el_.setAttribute("aria-checked","true"),this.controlText(", selected"),this.isSelected_=!0):(this.removeClass("vjs-selected"),this.el_.setAttribute("aria-checked","false"),this.controlText(""),this.isSelected_=!1))}}ge.registerComponent("MenuItem",nr);class ar extends nr{constructor(t,e){const s=e.track,i=t.textTracks();e.label=s.label||s.language||"Unknown",e.selected="showing"===s.mode,super(t,e),this.track=s,this.kinds=(e.kinds||[e.kind||this.track.kind]).filter(Boolean);const r=(...t)=>{this.handleTracksChange.apply(this,t)},n=(...t)=>{this.handleSelectedLanguageChange.apply(this,t)};if(t.on(["loadstart","texttrackchange"],r),i.addEventListener("change",r),i.addEventListener("selectedlanguagechange",n),this.on("dispose",function(){t.off(["loadstart","texttrackchange"],r),i.removeEventListener("change",r),i.removeEventListener("selectedlanguagechange",n)}),void 0===i.onchange){let t;this.on(["tap","click"],function(){if("object"!=typeof window.Event)try{t=new window.Event("change")}catch(t){}t||(t=document.createEvent("Event"),t.initEvent("change",!0,!0)),i.dispatchEvent(t)})}this.handleTracksChange()}handleClick(t){const e=this.track,s=this.player_.textTracks();if(super.handleClick(t),s)for(let t=0;t<s.length;t++){const i=s[t];-1!==this.kinds.indexOf(i.kind)&&(i===e?"showing"!==i.mode&&(i.mode="showing"):"disabled"!==i.mode&&(i.mode="disabled"))}}handleTracksChange(t){const e="showing"===this.track.mode;e!==this.isSelected_&&this.selected(e)}handleSelectedLanguageChange(t){if("showing"===this.track.mode){const t=this.player_.cache_.selectedLanguage;if(t&&t.enabled&&t.language===this.track.language&&t.kind!==this.track.kind)return;this.player_.cache_.selectedLanguage={enabled:!0,language:this.track.language,kind:this.track.kind}}}dispose(){this.track=null,super.dispose()}}ge.registerComponent("TextTrackMenuItem",ar);class or extends ar{constructor(t,e){e.track={player:t,kind:e.kind,kinds:e.kinds,default:!1,mode:"disabled"},e.kinds||(e.kinds=[e.kind]),e.label?e.track.label=e.label:e.track.label=e.kinds.join(" and ")+" off",e.selectable=!0,e.multiSelectable=!1,super(t,e)}handleTracksChange(t){const e=this.player().textTracks();let s=!0;for(let t=0,i=e.length;t<i;t++){const i=e[t];if(this.options_.kinds.indexOf(i.kind)>-1&&"showing"===i.mode){s=!1;break}}s!==this.isSelected_&&this.selected(s)}handleSelectedLanguageChange(t){const e=this.player().textTracks();let s=!0;for(let t=0,i=e.length;t<i;t++){const i=e[t];if(["captions","descriptions","subtitles"].indexOf(i.kind)>-1&&"showing"===i.mode){s=!1;break}}s&&(this.player_.cache_.selectedLanguage={enabled:!1})}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.label),super.handleLanguagechange()}}ge.registerComponent("OffTextTrackMenuItem",or);class lr extends rr{constructor(t,e={}){e.tracks=t.textTracks(),super(t,e)}createItems(t=[],e=ar){let s;this.label_&&(s=`${this.label_} off`),t.push(new or(this.player_,{kinds:this.kinds_,kind:this.kind_,label:s})),this.hideThreshold_+=1;const i=this.player_.textTracks();Array.isArray(this.kinds_)||(this.kinds_=[this.kind_]);for(let s=0;s<i.length;s++){const r=i[s];if(this.kinds_.indexOf(r.kind)>-1){const s=new e(this.player_,{track:r,kinds:this.kinds_,kind:this.kind_,selectable:!0,multiSelectable:!1});s.addClass(`vjs-${r.kind}-menu-item`),t.push(s)}}return t}}ge.registerComponent("TextTrackButton",lr);class hr extends nr{constructor(t,e){const s=e.track,i=e.cue,r=t.currentTime();e.selectable=!0,e.multiSelectable=!1,e.label=i.text,e.selected=i.startTime<=r&&r<i.endTime,super(t,e),this.track=s,this.cue=i}handleClick(t){super.handleClick(),this.player_.currentTime(this.cue.startTime)}}ge.registerComponent("ChaptersTrackMenuItem",hr);class cr extends lr{constructor(t,e,s){super(t,e,s),this.setIcon("chapters"),this.selectCurrentItem_=()=>{this.items.forEach(t=>{t.selected(this.track_.activeCues[0]===t.cue)})}}buildCSSClass(){return`vjs-chapters-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-chapters-button ${super.buildWrapperCSSClass()}`}update(t){if(t&&t.track&&"chapters"!==t.track.kind)return;const e=this.findChaptersTrack();e!==this.track_?(this.setTrack(e),super.update()):(!this.items||e&&e.cues&&e.cues.length!==this.items.length)&&super.update()}setTrack(t){if(this.track_!==t){if(this.updateHandler_||(this.updateHandler_=this.update.bind(this)),this.track_){const t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);t&&t.removeEventListener("load",this.updateHandler_),this.track_.removeEventListener("cuechange",this.selectCurrentItem_),this.track_=null}if(this.track_=t,this.track_){this.track_.mode="hidden";const t=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);t&&t.addEventListener("load",this.updateHandler_),this.track_.addEventListener("cuechange",this.selectCurrentItem_)}}}findChaptersTrack(){const t=this.player_.textTracks()||[];for(let e=t.length-1;e>=0;e--){const s=t[e];if(s.kind===this.kind_)return s}}getMenuCaption(){return this.track_&&this.track_.label?this.track_.label:this.localize(ue(this.kind_))}createMenu(){return this.options_.title=this.getMenuCaption(),super.createMenu()}createItems(){const t=[];if(!this.track_)return t;const e=this.track_.cues;if(!e)return t;for(let s=0,i=e.length;s<i;s++){const i=e[s],r=new hr(this.player_,{track:this.track_,cue:i});t.push(r)}return t}}cr.prototype.kind_="chapters",cr.prototype.controlText_="Chapters",ge.registerComponent("ChaptersButton",cr);class dr extends lr{constructor(t,e,s){super(t,e,s),this.setIcon("audio-description");const i=t.textTracks(),r=zt(this,this.handleTracksChange);i.addEventListener("change",r),this.on("dispose",function(){i.removeEventListener("change",r)})}handleTracksChange(t){const e=this.player().textTracks();let s=!1;for(let t=0,i=e.length;t<i;t++){const i=e[t];if(i.kind!==this.kind_&&"showing"===i.mode){s=!0;break}}s?this.disable():this.enable()}buildCSSClass(){return`vjs-descriptions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-descriptions-button ${super.buildWrapperCSSClass()}`}}dr.prototype.kind_="descriptions",dr.prototype.controlText_="Descriptions",ge.registerComponent("DescriptionsButton",dr);class ur extends lr{constructor(t,e,s){super(t,e,s),this.setIcon("subtitles")}buildCSSClass(){return`vjs-subtitles-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subtitles-button ${super.buildWrapperCSSClass()}`}}ur.prototype.kind_="subtitles",ur.prototype.controlText_="Subtitles",ge.registerComponent("SubtitlesButton",ur);class pr extends ar{constructor(t,e){e.track={player:t,kind:e.kind,label:e.kind+" settings",selectable:!1,default:!1,mode:"disabled"},e.selectable=!1,e.name="CaptionSettingsMenuItem",super(t,e),this.addClass("vjs-texttrack-settings"),this.controlText(", opens "+e.kind+" settings dialog")}handleClick(t){this.player().getChild("textTrackSettings").open()}handleLanguagechange(){this.$(".vjs-menu-item-text").textContent=this.player_.localize(this.options_.kind+" settings"),super.handleLanguagechange()}}ge.registerComponent("CaptionSettingsMenuItem",pr);class fr extends lr{constructor(t,e,s){super(t,e,s),this.setIcon("captions")}buildCSSClass(){return`vjs-captions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-captions-button ${super.buildWrapperCSSClass()}`}createItems(){const t=[];return this.player().tech_&&this.player().tech_.featuresNativeTextTracks||!this.player().getChild("textTrackSettings")||(t.push(new pr(this.player_,{kind:this.kind_})),this.hideThreshold_+=1),super.createItems(t)}}fr.prototype.kind_="captions",fr.prototype.controlText_="Captions",ge.registerComponent("CaptionsButton",fr);class gr extends ar{createEl(t,e,s){const i=super.createEl(t,e,s),r=i.querySelector(".vjs-menu-item-text");return"captions"===this.options_.track.kind&&(this.player_.options_.experimentalSvgIcons?this.setIcon("captions",i):r.appendChild(Q("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(Q("span",{className:"vjs-control-text",textContent:` ${this.localize("Captions")}`}))),i}}ge.registerComponent("SubsCapsMenuItem",gr);class mr extends lr{constructor(t,e={}){super(t,e),this.label_="subtitles",this.setIcon("subtitles"),["en","en-us","en-ca","fr-ca"].indexOf(this.player_.language_)>-1&&(this.label_="captions",this.setIcon("captions")),this.menuButton_.controlText(ue(this.label_))}buildCSSClass(){return`vjs-subs-caps-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subs-caps-button ${super.buildWrapperCSSClass()}`}createItems(){let t=[];return this.player().tech_&&this.player().tech_.featuresNativeTextTracks||!this.player().getChild("textTrackSettings")||(t.push(new pr(this.player_,{kind:this.label_})),this.hideThreshold_+=1),t=super.createItems(t,gr),t}}mr.prototype.kinds_=["captions","subtitles"],mr.prototype.controlText_="Subtitles",ge.registerComponent("SubsCapsButton",mr);class yr extends nr{constructor(t,e){const s=e.track,i=t.audioTracks();e.label=s.label||s.language||"Unknown",e.selected=s.enabled,super(t,e),this.track=s,this.addClass(`vjs-${s.kind}-menu-item`);const r=(...t)=>{this.handleTracksChange.apply(this,t)};i.addEventListener("change",r),this.on("dispose",()=>{i.removeEventListener("change",r)})}createEl(t,e,s){const i=super.createEl(t,e,s),r=i.querySelector(".vjs-menu-item-text");return["main-desc","descriptions"].indexOf(this.options_.track.kind)>=0&&(r.appendChild(Q("span",{className:"vjs-icon-placeholder"},{"aria-hidden":!0})),r.appendChild(Q("span",{className:"vjs-control-text",textContent:" "+this.localize("Descriptions")}))),i}handleClick(t){if(super.handleClick(t),this.track.enabled=!0,this.player_.tech_.featuresNativeAudioTracks){const t=this.player_.audioTracks();for(let e=0;e<t.length;e++){const s=t[e];s!==this.track&&(s.enabled=s===this.track)}}}handleTracksChange(t){this.selected(this.track.enabled)}}ge.registerComponent("AudioTrackMenuItem",yr);class vr extends rr{constructor(t,e={}){e.tracks=t.audioTracks(),super(t,e),this.setIcon("audio")}buildCSSClass(){return`vjs-audio-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-audio-button ${super.buildWrapperCSSClass()}`}createItems(t=[]){this.hideThreshold_=1;const e=this.player_.audioTracks();for(let s=0;s<e.length;s++){const i=e[s];t.push(new yr(this.player_,{track:i,selectable:!0,multiSelectable:!1}))}return t}}vr.prototype.controlText_="Audio Track",ge.registerComponent("AudioTrackButton",vr);class br extends nr{constructor(t,e){const s=e.rate,i=parseFloat(s,10);e.label=s,e.selected=i===t.playbackRate(),e.selectable=!0,e.multiSelectable=!1,super(t,e),this.label=s,this.rate=i,this.on(t,"ratechange",t=>this.update(t))}handleClick(t){super.handleClick(),this.player().playbackRate(this.rate)}update(t){this.selected(this.player().playbackRate()===this.rate)}}br.prototype.contentElType="button",ge.registerComponent("PlaybackRateMenuItem",br);class _r extends ir{constructor(t,e){super(t,e),this.menuButton_.el_.setAttribute("aria-describedby",this.labelElId_),this.updateVisibility(),this.updateLabel(),this.on(t,"loadstart",t=>this.updateVisibility(t)),this.on(t,"ratechange",t=>this.updateLabel(t)),this.on(t,"playbackrateschange",t=>this.handlePlaybackRateschange(t))}createEl(){const t=super.createEl();return this.labelElId_="vjs-playback-rate-value-label-"+this.id_,this.labelEl_=Q("div",{className:"vjs-playback-rate-value",id:this.labelElId_,textContent:"1x"}),t.appendChild(this.labelEl_),t}dispose(){this.labelEl_=null,super.dispose()}buildCSSClass(){return`vjs-playback-rate ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-playback-rate ${super.buildWrapperCSSClass()}`}createItems(){const t=this.playbackRates(),e=[];for(let s=t.length-1;s>=0;s--)e.push(new br(this.player(),{rate:t[s]+"x"}));return e}handlePlaybackRateschange(t){this.update()}playbackRates(){const t=this.player();return t.playbackRates&&t.playbackRates()||[]}playbackRateSupported(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&this.playbackRates().length>0}updateVisibility(t){this.playbackRateSupported()?this.removeClass("vjs-hidden"):this.addClass("vjs-hidden")}updateLabel(t){this.playbackRateSupported()&&(this.labelEl_.textContent=this.player().playbackRate()+"x")}}_r.prototype.controlText_="Playback Rate",ge.registerComponent("PlaybackRateMenuButton",_r);class Tr extends ge{buildCSSClass(){return`vjs-spacer ${super.buildCSSClass()}`}createEl(t="div",e={},s={}){return e.className||(e.className=this.buildCSSClass()),super.createEl(t,e,s)}}ge.registerComponent("Spacer",Tr);ge.registerComponent("CustomControlSpacer",class extends Tr{buildCSSClass(){return`vjs-custom-control-spacer ${super.buildCSSClass()}`}createEl(){return super.createEl("div",{className:this.buildCSSClass(),textContent:" "})}});class Ar extends ge{createEl(){return super.createEl("div",{className:"vjs-control-bar",dir:"ltr"})}}Ar.prototype.options_={children:["playToggle","skipBackward","skipForward","volumePanel","currentTimeDisplay","timeDivider","durationDisplay","progressControl","liveDisplay","seekToLive","remainingTimeDisplay","customControlSpacer","playbackRateMenuButton","chaptersButton","descriptionsButton","subsCapsButton","audioTrackButton","pictureInPictureToggle","fullscreenToggle"]},ge.registerComponent("ControlBar",Ar);class Er extends Oe{constructor(t,e){super(t,e),this.on(t,"error",t=>{this.open(t)})}buildCSSClass(){return`vjs-error-display ${super.buildCSSClass()}`}content(){const t=this.player().error();return t?this.localize(t.message):""}}Er.prototype.options_=Object.assign({},Oe.prototype.options_,{pauseOnOpen:!1,fillAlways:!0,temporary:!1,uncloseable:!0}),ge.registerComponent("ErrorDisplay",Er);class Sr extends ge{constructor(t,e={}){super(t,e),this.el_.setAttribute("aria-labelledby",this.selectLabelledbyIds)}createEl(){return this.selectLabelledbyIds=[this.options_.legendId,this.options_.labelId].join(" ").trim(),Q("select",{id:this.options_.id},{},this.options_.SelectOptions.map(t=>{const e=(this.options_.labelId?this.options_.labelId:`vjs-track-option-${Mt()}`)+"-"+t[1].replace(/\W+/g,""),s=Q("option",{id:e,value:this.localize(t[0]),textContent:this.localize(t[1])});return s.setAttribute("aria-labelledby",`${this.selectLabelledbyIds} ${e}`),s}))}}ge.registerComponent("TextTrackSelect",Sr);class Cr extends ge{constructor(t,e={}){super(t,e);const s=Q("legend",{textContent:this.localize(this.options_.legendText),id:this.options_.legendId});this.el().appendChild(s);const i=this.options_.selects;for(const e of i){const s=this.options_.selectConfigs[e],i=s.className,r=s.id.replace("%s",this.options_.id_);let n=null;const a=`vjs_select_${Mt()}`;if("colors"===this.options_.type){n=Q("span",{className:i});const t=Q("label",{id:r,className:"vjs-label",textContent:this.localize(s.label)});t.setAttribute("for",a),n.appendChild(t)}const o=new Sr(t,{SelectOptions:s.options,legendId:this.options_.legendId,id:a,labelId:r});this.addChild(o),"colors"===this.options_.type&&(n.appendChild(o.el()),this.el().appendChild(n))}}createEl(){return Q("fieldset",{className:this.options_.className})}}ge.registerComponent("TextTrackFieldset",Cr);class kr extends ge{constructor(t,e={}){super(t,e);const s=this.options_.textTrackComponentid,i=new Cr(t,{id_:s,legendId:`captions-text-legend-${s}`,legendText:this.localize("Text"),className:"vjs-fg vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(i);const r=new Cr(t,{id_:s,legendId:`captions-background-${s}`,legendText:this.localize("Text Background"),className:"vjs-bg vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(r);const n=new Cr(t,{id_:s,legendId:`captions-window-${s}`,legendText:this.localize("Caption Area Background"),className:"vjs-window vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"colors"});this.addChild(n)}createEl(){return Q("div",{className:"vjs-track-settings-colors"})}}ge.registerComponent("TextTrackSettingsColors",kr);class wr extends ge{constructor(t,e={}){super(t,e);const s=this.options_.textTrackComponentid,i=new Cr(t,{id_:s,legendId:`captions-font-size-${s}`,legendText:"Font Size",className:"vjs-font-percent vjs-track-setting",selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(i);const r=new Cr(t,{id_:s,legendId:`captions-edge-style-${s}`,legendText:this.localize("Text Edge Style"),className:"vjs-edge-style vjs-track-setting",selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(r);const n=new Cr(t,{id_:s,legendId:`captions-font-family-${s}`,legendText:this.localize("Font Family"),className:"vjs-font-family vjs-track-setting",selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:"font"});this.addChild(n)}createEl(){return Q("div",{className:"vjs-track-settings-font"})}}ge.registerComponent("TextTrackSettingsFont",wr);class Lr extends ge{constructor(t,e={}){super(t,e);const s=new xi(t,{controlText:this.localize("restore all settings to the default values"),className:"vjs-default-button"});s.el().classList.remove("vjs-control","vjs-button"),s.el().textContent=this.localize("Reset"),this.addChild(s);const i=this.localize("Done"),r=new xi(t,{controlText:i,className:"vjs-done-button"});r.el().classList.remove("vjs-control","vjs-button"),r.el().textContent=i,this.addChild(r)}createEl(){return Q("div",{className:"vjs-track-settings-controls"})}}ge.registerComponent("TrackSettingsControls",Lr);const Ir="vjs-text-track-settings",Pr=["#000","Black"],xr=["#00F","Blue"],Rr=["#0FF","Cyan"],Dr=["#0F0","Green"],Or=["#F0F","Magenta"],Mr=["#F00","Red"],Fr=["#FFF","White"],Nr=["#FF0","Yellow"],Br=["1","Opaque"],jr=["0.5","Semi-Transparent"],$r=["0","Transparent"],Ur={backgroundColor:{selector:".vjs-bg-color > select",id:"captions-background-color-%s",label:"Color",options:[Pr,Fr,Mr,Dr,xr,Nr,Or,Rr],className:"vjs-bg-color"},backgroundOpacity:{selector:".vjs-bg-opacity > select",id:"captions-background-opacity-%s",label:"Opacity",options:[Br,jr,$r],className:"vjs-bg-opacity vjs-opacity"},color:{selector:".vjs-text-color > select",id:"captions-foreground-color-%s",label:"Color",options:[Fr,Pr,Mr,Dr,xr,Nr,Or,Rr],className:"vjs-text-color"},edgeStyle:{selector:".vjs-edge-style > select",id:"",label:"Text Edge Style",options:[["none","None"],["raised","Raised"],["depressed","Depressed"],["uniform","Uniform"],["dropshadow","Drop shadow"]]},fontFamily:{selector:".vjs-font-family > select",id:"",label:"Font Family",options:[["proportionalSansSerif","Proportional Sans-Serif"],["monospaceSansSerif","Monospace Sans-Serif"],["proportionalSerif","Proportional Serif"],["monospaceSerif","Monospace Serif"],["casual","Casual"],["script","Script"],["small-caps","Small Caps"]]},fontPercent:{selector:".vjs-font-percent > select",id:"",label:"Font Size",options:[["0.50","50%"],["0.75","75%"],["1.00","100%"],["1.25","125%"],["1.50","150%"],["1.75","175%"],["2.00","200%"],["3.00","300%"],["4.00","400%"]],default:2,parser:t=>"1.00"===t?null:Number(t)},textOpacity:{selector:".vjs-text-opacity > select",id:"captions-foreground-opacity-%s",label:"Opacity",options:[Br,jr],className:"vjs-text-opacity vjs-opacity"},windowColor:{selector:".vjs-window-color > select",id:"captions-window-color-%s",label:"Color",className:"vjs-window-color"},windowOpacity:{selector:".vjs-window-opacity > select",id:"captions-window-opacity-%s",label:"Opacity",options:[$r,jr,Br],className:"vjs-window-opacity vjs-opacity"}};function Hr(t,e){if(e&&(t=e(t)),t&&"none"!==t)return t}Ur.windowColor.options=Ur.backgroundColor.options;ge.registerComponent("TextTrackSettings",class extends Oe{constructor(t,e){e.temporary=!1,super(t,e),this.updateDisplay=this.updateDisplay.bind(this),this.fill(),this.hasBeenOpened_=this.hasBeenFilled_=!0,this.renderModalComponents(t),this.endDialog=Q("p",{className:"vjs-control-text",textContent:this.localize("End of dialog window.")}),this.el().appendChild(this.endDialog),this.setDefaults(),void 0===e.persistTextTrackSettings&&(this.options_.persistTextTrackSettings=this.options_.playerOptions.persistTextTrackSettings),this.bindFunctionsToSelectsAndButtons(),this.options_.persistTextTrackSettings&&this.restoreSettings()}renderModalComponents(t){const e=new kr(t,{textTrackComponentid:this.id_,selectConfigs:Ur,fieldSets:[["color","textOpacity"],["backgroundColor","backgroundOpacity"],["windowColor","windowOpacity"]]});this.addChild(e);const s=new wr(t,{textTrackComponentid:this.id_,selectConfigs:Ur,fieldSets:[["fontPercent"],["edgeStyle"],["fontFamily"]]});this.addChild(s);const i=new Lr(t);this.addChild(i)}bindFunctionsToSelectsAndButtons(){this.on(this.$(".vjs-done-button"),["click","tap"],()=>{this.saveSettings(),this.close()}),this.on(this.$(".vjs-default-button"),["click","tap"],()=>{this.setDefaults(),this.updateDisplay()}),f(Ur,t=>{this.on(this.$(t.selector),"change",this.updateDisplay)})}dispose(){this.endDialog=null,super.dispose()}label(){return this.localize("Caption Settings Dialog")}description(){return this.localize("Beginning of dialog window. Escape will cancel and close the window.")}buildCSSClass(){return super.buildCSSClass()+" vjs-text-track-settings"}getValues(){return g(Ur,(t,e,s)=>{const i=(r=this.$(e.selector),n=e.parser,Hr(r.options[r.options.selectedIndex].value,n));var r,n;return void 0!==i&&(t[s]=i),t},{})}setValues(t){f(Ur,(e,s)=>{!function(t,e,s){if(e)for(let i=0;i<t.options.length;i++)if(Hr(t.options[i].value,s)===e){t.selectedIndex=i;break}}(this.$(e.selector),t[s],e.parser)})}setDefaults(){f(Ur,t=>{const e=t.hasOwnProperty("default")?t.default:0;this.$(t.selector).selectedIndex=e})}restoreSettings(){let t;try{t=JSON.parse(window.localStorage.getItem(Ir))}catch(t){c.warn(t)}t&&this.setValues(t)}saveSettings(){if(!this.options_.persistTextTrackSettings)return;const t=this.getValues();try{Object.keys(t).length?window.localStorage.setItem(Ir,JSON.stringify(t)):window.localStorage.removeItem(Ir)}catch(t){c.warn(t)}}updateDisplay(){const t=this.player_.getChild("textTrackDisplay");t&&t.updateDisplay()}handleLanguagechange(){this.fill(),this.renderModalComponents(this.player_),this.bindFunctionsToSelectsAndButtons()}});ge.registerComponent("ResizeManager",class extends ge{constructor(t,e){let s=e.ResizeObserver||window.ResizeObserver;null===e.ResizeObserver&&(s=!1),super(t,v({createEl:!s,reportTouchActivity:!1},e)),this.ResizeObserver=e.ResizeObserver||window.ResizeObserver,this.loadListener_=null,this.resizeObserver_=null,this.debouncedHandler_=Yt(()=>{this.resizeHandler()},100,!1,this),s?(this.resizeObserver_=new this.ResizeObserver(this.debouncedHandler_),this.resizeObserver_.observe(t.el())):(this.loadListener_=()=>{if(!this.el_||!this.el_.contentWindow)return;const t=this.debouncedHandler_;let e=this.unloadListener_=function(){Ut(this,"resize",t),Ut(this,"unload",e),e=null};$t(this.el_.contentWindow,"unload",e),$t(this.el_.contentWindow,"resize",t)},this.one("load",this.loadListener_))}createEl(){return super.createEl("iframe",{className:"vjs-resize-manager",tabIndex:-1,title:this.localize("No content")},{"aria-hidden":"true"})}resizeHandler(){this.player_&&this.player_.trigger&&this.player_.trigger("playerresize")}dispose(){this.debouncedHandler_&&this.debouncedHandler_.cancel(),this.resizeObserver_&&(this.player_.el()&&this.resizeObserver_.unobserve(this.player_.el()),this.resizeObserver_.disconnect()),this.loadListener_&&this.off("load",this.loadListener_),this.el_&&this.el_.contentWindow&&this.unloadListener_&&this.unloadListener_.call(this.el_.contentWindow),this.ResizeObserver=null,this.resizeObserver=null,this.debouncedHandler_=null,this.loadListener_=null,super.dispose()}});const Vr={trackingThreshold:20,liveTolerance:15};ge.registerComponent("LiveTracker",class extends ge{constructor(t,e){super(t,v(Vr,e,{createEl:!1})),this.trackLiveHandler_=()=>this.trackLive_(),this.handlePlay_=t=>this.handlePlay(t),this.handleFirstTimeupdate_=t=>this.handleFirstTimeupdate(t),this.handleSeeked_=t=>this.handleSeeked(t),this.seekToLiveEdge_=t=>this.seekToLiveEdge(t),this.reset_(),this.on(this.player_,"durationchange",t=>this.handleDurationchange(t)),this.on(this.player_,"canplay",()=>this.toggleTracking())}trackLive_(){const t=this.player_.seekable();if(!t||!t.length)return;const e=Number(window.performance.now().toFixed(4)),s=-1===this.lastTime_?0:(e-this.lastTime_)/1e3;this.lastTime_=e,this.pastSeekEnd_=this.pastSeekEnd()+s;const i=this.liveCurrentTime(),r=this.player_.currentTime();let n=this.player_.paused()||this.seekedBehindLive_||Math.abs(i-r)>this.options_.liveTolerance;this.timeupdateSeen_&&i!==1/0||(n=!1),n!==this.behindLiveEdge_&&(this.behindLiveEdge_=n,this.trigger("liveedgechange"))}handleDurationchange(){this.toggleTracking()}toggleTracking(){this.player_.duration()===1/0&&this.liveWindow()>=this.options_.trackingThreshold?(this.player_.options_.liveui&&this.player_.addClass("vjs-liveui"),this.startTracking()):(this.player_.removeClass("vjs-liveui"),this.stopTracking())}startTracking(){this.isTracking()||(this.timeupdateSeen_||(this.timeupdateSeen_=this.player_.hasStarted()),this.trackingInterval_=this.setInterval(this.trackLiveHandler_,Kt),this.trackLive_(),this.on(this.player_,["play","pause"],this.trackLiveHandler_),this.timeupdateSeen_?this.on(this.player_,"seeked",this.handleSeeked_):(this.one(this.player_,"play",this.handlePlay_),this.one(this.player_,"timeupdate",this.handleFirstTimeupdate_)))}handleFirstTimeupdate(){this.timeupdateSeen_=!0,this.on(this.player_,"seeked",this.handleSeeked_)}handleSeeked(){const t=Math.abs(this.liveCurrentTime()-this.player_.currentTime());this.seekedBehindLive_=this.nextSeekedFromUser_&&t>2,this.nextSeekedFromUser_=!1,this.trackLive_()}handlePlay(){this.one(this.player_,"timeupdate",this.seekToLiveEdge_)}reset_(){this.lastTime_=-1,this.pastSeekEnd_=0,this.lastSeekEnd_=-1,this.behindLiveEdge_=!0,this.timeupdateSeen_=!1,this.seekedBehindLive_=!1,this.nextSeekedFromUser_=!1,this.clearInterval(this.trackingInterval_),this.trackingInterval_=null,this.off(this.player_,["play","pause"],this.trackLiveHandler_),this.off(this.player_,"seeked",this.handleSeeked_),this.off(this.player_,"play",this.handlePlay_),this.off(this.player_,"timeupdate",this.handleFirstTimeupdate_),this.off(this.player_,"timeupdate",this.seekToLiveEdge_)}nextSeekedFromUser(){this.nextSeekedFromUser_=!0}stopTracking(){this.isTracking()&&(this.reset_(),this.trigger("liveedgechange"))}seekableEnd(){const t=this.player_.seekable(),e=[];let s=t?t.length:0;for(;s--;)e.push(t.end(s));return e.length?e.sort()[e.length-1]:1/0}seekableStart(){const t=this.player_.seekable(),e=[];let s=t?t.length:0;for(;s--;)e.push(t.start(s));return e.length?e.sort()[0]:0}liveWindow(){const t=this.liveCurrentTime();return t===1/0?0:t-this.seekableStart()}isLive(){return this.isTracking()}atLiveEdge(){return!this.behindLiveEdge()}liveCurrentTime(){return this.pastSeekEnd()+this.seekableEnd()}pastSeekEnd(){const t=this.seekableEnd();return-1!==this.lastSeekEnd_&&t!==this.lastSeekEnd_&&(this.pastSeekEnd_=0),this.lastSeekEnd_=t,this.pastSeekEnd_}behindLiveEdge(){return this.behindLiveEdge_}isTracking(){return"number"==typeof this.trackingInterval_}seekToLiveEdge(){this.seekedBehindLive_=!1,this.atLiveEdge()||(this.nextSeekedFromUser_=!1,this.player_.currentTime(this.liveCurrentTime()))}dispose(){this.stopTracking(),super.dispose()}});ge.registerComponent("TitleBar",class extends ge{constructor(t,e){super(t,e),this.on("statechanged",t=>this.updateDom_()),this.updateDom_()}createEl(){return this.els={title:Q("div",{className:"vjs-title-bar-title",id:`vjs-title-bar-title-${Mt()}`}),description:Q("div",{className:"vjs-title-bar-description",id:`vjs-title-bar-description-${Mt()}`})},Q("div",{className:"vjs-title-bar"},{},b(this.els))}updateDom_(){const t=this.player_.tech_,e=t&&t.el_,s={title:"aria-labelledby",description:"aria-describedby"};["title","description"].forEach(t=>{const i=this.state[t],r=this.els[t],n=s[t];gt(r),i&&Z(r,i),e&&(e.removeAttribute(n),i&&e.setAttribute(n,r.id))}),this.state.title||this.state.description?this.show():this.hide()}update(t){this.setState(t)}dispose(){const t=this.player_.tech_,e=t&&t.el_;e&&(e.removeAttribute("aria-labelledby"),e.removeAttribute("aria-describedby")),super.dispose(),this.els=null}});const Gr={initialDisplay:4e3,position:[],takeFocus:!1};ge.registerComponent("TransientButton",class extends xi{constructor(t,e){super(t,e=v(Gr,e)),this.controlText(e.controlText),this.hide(),this.on(this.player_,["useractive","userinactive"],t=>{this.removeClass("force-display")})}buildCSSClass(){return`vjs-transient-button focus-visible ${this.options_.position.map(t=>`vjs-${t}`).join(" ")}`}createEl(){const t=Q("button",{},{type:"button",class:this.buildCSSClass()},Q("span"));return this.controlTextEl_=t.querySelector("span"),t}show(){super.show(),this.addClass("force-display"),this.options_.takeFocus&&this.el().focus({preventScroll:!0}),this.forceDisplayTimeout=this.player_.setTimeout(()=>{this.removeClass("force-display")},this.options_.initialDisplay)}hide(){this.removeClass("force-display"),super.hide()}dispose(){this.player_.clearTimeout(this.forceDisplayTimeout),super.dispose()}});const Wr=t=>{const e=t.el();if(e.hasAttribute("src"))return t.triggerSourceset(e.src),!0;const s=t.$$("source"),i=[];let r="";if(!s.length)return!1;for(let t=0;t<s.length;t++){const e=s[t].src;e&&-1===i.indexOf(e)&&i.push(e)}return!!i.length&&(1===i.length&&(r=i[0]),t.triggerSourceset(r),!0)},Kr=Object.defineProperty({},"innerHTML",{get(){return this.cloneNode(!0).innerHTML},set(t){const e=document.createElement(this.nodeName.toLowerCase());e.innerHTML=t;const s=document.createDocumentFragment();for(;e.childNodes.length;)s.appendChild(e.childNodes[0]);return this.innerText="",window.Element.prototype.appendChild.call(this,s),this.innerHTML}}),zr=(t,e)=>{let s={};for(let i=0;i<t.length&&(s=Object.getOwnPropertyDescriptor(t[i],e),!(s&&s.set&&s.get));i++);return s.enumerable=!0,s.configurable=!0,s},qr=function(t){const e=t.el();if(e.resetSourceWatch_)return;const s={},i=(t=>zr([t.el(),window.HTMLMediaElement.prototype,window.Element.prototype,Kr],"innerHTML"))(t),r=s=>(...i)=>{const r=s.apply(e,i);return Wr(t),r};["append","appendChild","insertAdjacentHTML"].forEach(t=>{e[t]&&(s[t]=e[t],e[t]=r(s[t]))}),Object.defineProperty(e,"innerHTML",v(i,{set:r(i.set)})),e.resetSourceWatch_=()=>{e.resetSourceWatch_=null,Object.keys(s).forEach(t=>{e[t]=s[t]}),Object.defineProperty(e,"innerHTML",i)},t.one("sourceset",e.resetSourceWatch_)},Yr=Object.defineProperty({},"src",{get(){return this.hasAttribute("src")?qe(window.Element.prototype.getAttribute.call(this,"src")):""},set(t){return window.Element.prototype.setAttribute.call(this,"src",t),t}}),Xr=function(t){if(!t.featuresSourceset)return;const e=t.el();if(e.resetSourceset_)return;const s=(t=>zr([t.el(),window.HTMLMediaElement.prototype,Yr],"src"))(t),i=e.setAttribute,r=e.load;Object.defineProperty(e,"src",v(s,{set:i=>{const r=s.set.call(e,i);return t.triggerSourceset(e.src),r}})),e.setAttribute=(s,r)=>{const n=i.call(e,s,r);return/src/i.test(s)&&t.triggerSourceset(e.src),n},e.load=()=>{const s=r.call(e);return Wr(t)||(t.triggerSourceset(""),qr(t)),s},e.currentSrc?t.triggerSourceset(e.currentSrc):Wr(t)||qr(t),e.resetSourceset_=()=>{e.resetSourceset_=null,e.load=r,e.setAttribute=i,Object.defineProperty(e,"src",s),e.resetSourceWatch_&&e.resetSourceWatch_()}};class Qr extends ni{constructor(t,e){super(t,e);const s=t.source;let i=!1;if(this.featuresVideoFrameCallback=this.featuresVideoFrameCallback&&"VIDEO"===this.el_.tagName,s&&(this.el_.currentSrc!==s.src||t.tag&&3===t.tag.initNetworkState_)?this.setSource(s):this.handleLateInit_(this.el_),t.enableSourceset&&this.setupSourcesetHandling_(),this.isScrubbing_=!1,this.el_.hasChildNodes()){const t=this.el_.childNodes;let e=t.length;const s=[];for(;e--;){const r=t[e];"track"===r.nodeName.toLowerCase()&&(this.featuresNativeTextTracks?(this.remoteTextTrackEls().addTrackElement_(r),this.remoteTextTracks().addTrack(r.track),this.textTracks().addTrack(r.track),i||this.el_.hasAttribute("crossorigin")||!Xe(r.src)||(i=!0)):s.push(r))}for(let t=0;t<s.length;t++)this.el_.removeChild(s[t])}this.proxyNativeTracks_(),this.featuresNativeTextTracks&&i&&c.warn("Text Tracks are being loaded from another origin but the crossorigin attribute isn't used.\nThis may prevent text tracks from loading."),this.restoreMetadataTracksInIOSNativePlayer_(),(U||N)&&!0===t.nativeControlsForTouch&&this.setControls(!0),this.proxyWebkitFullscreen_(),this.triggerReady()}dispose(){this.el_&&this.el_.resetSourceset_&&this.el_.resetSourceset_(),Qr.disposeMediaElement(this.el_),this.options_=null,super.dispose()}setupSourcesetHandling_(){Xr(this)}restoreMetadataTracksInIOSNativePlayer_(){const t=this.textTracks();let e;const s=()=>{e=[];for(let s=0;s<t.length;s++){const i=t[s];"metadata"===i.kind&&e.push({track:i,storedMode:i.mode})}};s(),t.addEventListener("change",s),this.on("dispose",()=>t.removeEventListener("change",s));const i=()=>{for(let t=0;t<e.length;t++){const s=e[t];"disabled"===s.track.mode&&s.track.mode!==s.storedMode&&(s.track.mode=s.storedMode)}t.removeEventListener("change",i)};this.on("webkitbeginfullscreen",()=>{t.removeEventListener("change",s),t.removeEventListener("change",i),t.addEventListener("change",i)}),this.on("webkitendfullscreen",()=>{t.removeEventListener("change",s),t.addEventListener("change",s),t.removeEventListener("change",i)})}overrideNative_(t,e){if(e!==this[`featuresNative${t}Tracks`])return;const s=t.toLowerCase();this[`${s}TracksListeners_`]&&Object.keys(this[`${s}TracksListeners_`]).forEach(t=>{this.el()[`${s}Tracks`].removeEventListener(t,this[`${s}TracksListeners_`][t])}),this[`featuresNative${t}Tracks`]=!e,this[`${s}TracksListeners_`]=null,this.proxyNativeTracksForType_(s)}overrideNativeAudioTracks(t){this.overrideNative_("Audio",t)}overrideNativeVideoTracks(t){this.overrideNative_("Video",t)}proxyNativeTracksForType_(t){const e=Es[t],s=this.el()[e.getterName],i=this[e.getterName]();if(!this[`featuresNative${e.capitalName}Tracks`]||!s||!s.addEventListener)return;const r={change:e=>{const s={type:"change",target:i,currentTarget:i,srcElement:i};i.trigger(s),"text"===t&&this[Ss.remoteText.getterName]().trigger(s)},addtrack(t){i.addTrack(t.track)},removetrack(t){i.removeTrack(t.track)}},n=function(){const t=[];for(let e=0;e<i.length;e++){let r=!1;for(let t=0;t<s.length;t++)if(s[t]===i[e]){r=!0;break}r||t.push(i[e])}for(;t.length;)i.removeTrack(t.shift())};this[e.getterName+"Listeners_"]=r,Object.keys(r).forEach(t=>{const e=r[t];s.addEventListener(t,e),this.on("dispose",i=>s.removeEventListener(t,e))}),this.on("loadstart",n),this.on("dispose",t=>this.off("loadstart",n))}proxyNativeTracks_(){Es.names.forEach(t=>{this.proxyNativeTracksForType_(t)})}createEl(){let t=this.options_.tag;if(!t||!this.options_.playerElIngest&&!this.movingMediaElementInDOM){if(t){const e=t.cloneNode(!0);t.parentNode&&t.parentNode.insertBefore(e,t),Qr.disposeMediaElement(t),t=e}else{t=document.createElement("video");const e=v({},this.options_.tag&&nt(this.options_.tag));U&&!0===this.options_.nativeControlsForTouch||delete e.controls,rt(t,Object.assign(e,{id:this.options_.techId,class:"vjs-tech"}))}t.playerId=this.options_.playerId}void 0!==this.options_.preload&&ot(t,"preload",this.options_.preload),void 0!==this.options_.disablePictureInPicture&&(t.disablePictureInPicture=this.options_.disablePictureInPicture);const e=["loop","muted","playsinline","autoplay"];for(let s=0;s<e.length;s++){const i=e[s],r=this.options_[i];void 0!==r&&(r?ot(t,i,i):lt(t,i),t[i]=r)}return t}handleLateInit_(t){if(0===t.networkState||3===t.networkState)return;if(0===t.readyState){let t=!1;const e=function(){t=!0};this.on("loadstart",e);const s=function(){t||this.trigger("loadstart")};return this.on("loadedmetadata",s),void this.ready(function(){this.off("loadstart",e),this.off("loadedmetadata",s),t||this.trigger("loadstart")})}const e=["loadstart"];e.push("loadedmetadata"),t.readyState>=2&&e.push("loadeddata"),t.readyState>=3&&e.push("canplay"),t.readyState>=4&&e.push("canplaythrough"),this.ready(function(){e.forEach(function(t){this.trigger(t)},this)})}setScrubbing(t){this.isScrubbing_=t}scrubbing(){return this.isScrubbing_}setCurrentTime(t){try{this.isScrubbing_&&this.el_.fastSeek&&G?this.el_.fastSeek(t):this.el_.currentTime=t}catch(t){c(t,"Video is not ready. (Video.js)")}}duration(){if(this.el_.duration===1/0&&C&&I&&0===this.el_.currentTime){const t=()=>{this.el_.currentTime>0&&(this.el_.duration===1/0&&this.trigger("durationchange"),this.off("timeupdate",t))};return this.on("timeupdate",t),NaN}return this.el_.duration||NaN}width(){return this.el_.offsetWidth}height(){return this.el_.offsetHeight}proxyWebkitFullscreen_(){if(!("webkitDisplayingFullscreen"in this.el_))return;const t=function(){this.trigger("fullscreenchange",{isFullscreen:!1}),this.el_.controls&&!this.options_.nativeControlsForTouch&&this.controls()&&(this.el_.controls=!1)},e=function(){"webkitPresentationMode"in this.el_&&"picture-in-picture"!==this.el_.webkitPresentationMode&&(this.one("webkitendfullscreen",t),this.trigger("fullscreenchange",{isFullscreen:!0,nativeIOSFullscreen:!0}))};this.on("webkitbeginfullscreen",e),this.on("dispose",()=>{this.off("webkitbeginfullscreen",e),this.off("webkitendfullscreen",t)})}supportsFullScreen(){return"function"==typeof this.el_.webkitEnterFullScreen}enterFullScreen(){const t=this.el_;if(t.paused&&t.networkState<=t.HAVE_METADATA)Le(this.el_.play()),this.setTimeout(function(){t.pause();try{t.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}},0);else try{t.webkitEnterFullScreen()}catch(t){this.trigger("fullscreenerror",t)}}exitFullScreen(){this.el_.webkitDisplayingFullscreen?this.el_.webkitExitFullScreen():this.trigger("fullscreenerror",new Error("The video is not fullscreen"))}requestPictureInPicture(){return this.el_.requestPictureInPicture()}requestVideoFrameCallback(t){return this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.requestVideoFrameCallback(t):super.requestVideoFrameCallback(t)}cancelVideoFrameCallback(t){this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.cancelVideoFrameCallback(t):super.cancelVideoFrameCallback(t)}src(t){if(void 0===t)return this.el_.src;this.setSrc(t)}addSourceElement(t,e){if(!t)return c.error("Invalid source URL."),!1;const s={src:t};e&&(s.type=e);const i=Q("source",{},s);return this.el_.appendChild(i),!0}removeSourceElement(t){if(!t)return c.error("Source URL is required to remove the source element."),!1;const e=this.el_.querySelectorAll("source");for(const s of e)if(s.src===t)return this.el_.removeChild(s),!0;return c.warn(`No matching source element found with src: ${t}`),!1}reset(){Qr.resetMediaElement(this.el_)}currentSrc(){return this.currentSource_?this.currentSource_.src:this.el_.currentSrc}setControls(t){this.el_.controls=!!t}addTextTrack(t,e,s){return this.featuresNativeTextTracks?this.el_.addTextTrack(t,e,s):super.addTextTrack(t,e,s)}createRemoteTextTrack(t){if(!this.featuresNativeTextTracks)return super.createRemoteTextTrack(t);const e=document.createElement("track");return t.kind&&(e.kind=t.kind),t.label&&(e.label=t.label),(t.language||t.srclang)&&(e.srclang=t.language||t.srclang),t.default&&(e.default=t.default),t.id&&(e.id=t.id),t.src&&(e.src=t.src),e}addRemoteTextTrack(t,e){const s=super.addRemoteTextTrack(t,e);return this.featuresNativeTextTracks&&this.el().appendChild(s),s}removeRemoteTextTrack(t){if(super.removeRemoteTextTrack(t),this.featuresNativeTextTracks){const e=this.$$("track");let s=e.length;for(;s--;)t!==e[s]&&t!==e[s].track||this.el().removeChild(e[s])}}getVideoPlaybackQuality(){if("function"==typeof this.el().getVideoPlaybackQuality)return this.el().getVideoPlaybackQuality();const t={};return void 0!==this.el().webkitDroppedFrameCount&&void 0!==this.el().webkitDecodedFrameCount&&(t.droppedVideoFrames=this.el().webkitDroppedFrameCount,t.totalVideoFrames=this.el().webkitDecodedFrameCount),window.performance&&(t.creationTime=window.performance.now()),t}}_(Qr,"TEST_VID",function(){if(!z())return;const t=document.createElement("video"),e=document.createElement("track");return e.kind="captions",e.srclang="en",e.label="English",t.appendChild(e),t}),Qr.isSupported=function(){try{Qr.TEST_VID.volume=.5}catch(t){return!1}return!(!Qr.TEST_VID||!Qr.TEST_VID.canPlayType)},Qr.canPlayType=function(t){return Qr.TEST_VID.canPlayType(t)},Qr.canPlaySource=function(t,e){return Qr.canPlayType(t.type)},Qr.canControlVolume=function(){try{const t=Qr.TEST_VID.volume;Qr.TEST_VID.volume=t/2+.1;const e=t!==Qr.TEST_VID.volume;return e&&V?(window.setTimeout(()=>{Qr&&Qr.prototype&&(Qr.prototype.featuresVolumeControl=t!==Qr.TEST_VID.volume)}),!1):e}catch(t){return!1}},Qr.canMuteVolume=function(){try{const t=Qr.TEST_VID.muted;return Qr.TEST_VID.muted=!t,Qr.TEST_VID.muted?ot(Qr.TEST_VID,"muted","muted"):lt(Qr.TEST_VID,"muted"),t!==Qr.TEST_VID.muted}catch(t){return!1}},Qr.canControlPlaybackRate=function(){if(C&&I&&x<58)return!1;try{const t=Qr.TEST_VID.playbackRate;return Qr.TEST_VID.playbackRate=t/2+.1,t!==Qr.TEST_VID.playbackRate}catch(t){return!1}},Qr.canOverrideAttributes=function(){try{const t=()=>{};Object.defineProperty(document.createElement("video"),"src",{get:t,set:t}),Object.defineProperty(document.createElement("audio"),"src",{get:t,set:t}),Object.defineProperty(document.createElement("video"),"innerHTML",{get:t,set:t}),Object.defineProperty(document.createElement("audio"),"innerHTML",{get:t,set:t})}catch(t){return!1}return!0},Qr.supportsNativeTextTracks=function(){return G||V&&I},Qr.supportsNativeVideoTracks=function(){return!(!Qr.TEST_VID||!Qr.TEST_VID.videoTracks)},Qr.supportsNativeAudioTracks=function(){return!(!Qr.TEST_VID||!Qr.TEST_VID.audioTracks)},Qr.Events=["loadstart","suspend","abort","error","emptied","stalled","loadedmetadata","loadeddata","canplay","canplaythrough","playing","waiting","seeking","seeked","ended","durationchange","timeupdate","progress","play","pause","ratechange","resize","volumechange"],[["featuresMuteControl","canMuteVolume"],["featuresPlaybackRate","canControlPlaybackRate"],["featuresSourceset","canOverrideAttributes"],["featuresNativeTextTracks","supportsNativeTextTracks"],["featuresNativeVideoTracks","supportsNativeVideoTracks"],["featuresNativeAudioTracks","supportsNativeAudioTracks"]].forEach(function([t,e]){_(Qr.prototype,t,()=>Qr[e](),!0)}),Qr.prototype.featuresVolumeControl=Qr.canControlVolume(),Qr.prototype.movingMediaElementInDOM=!V,Qr.prototype.featuresFullscreenResize=!0,Qr.prototype.featuresProgressEvents=!0,Qr.prototype.featuresTimeupdateEvents=!0,Qr.prototype.featuresVideoFrameCallback=!(!Qr.TEST_VID||!Qr.TEST_VID.requestVideoFrameCallback),Qr.disposeMediaElement=function(t){if(t){for(t.parentNode&&t.parentNode.removeChild(t);t.hasChildNodes();)t.removeChild(t.firstChild);t.removeAttribute("src"),"function"==typeof t.load&&function(){try{t.load()}catch(t){}}()}},Qr.resetMediaElement=function(t){if(!t)return;const e=t.querySelectorAll("source");let s=e.length;for(;s--;)t.removeChild(e[s]);t.removeAttribute("src"),"function"==typeof t.load&&function(){try{t.load()}catch(t){}}()},["muted","defaultMuted","autoplay","controls","loop","playsinline"].forEach(function(t){Qr.prototype[t]=function(){return this.el_[t]||this.el_.hasAttribute(t)}}),["muted","defaultMuted","autoplay","loop","playsinline"].forEach(function(t){Qr.prototype["set"+ue(t)]=function(e){this.el_[t]=e,e?this.el_.setAttribute(t,t):this.el_.removeAttribute(t)}}),["paused","currentTime","buffered","volume","poster","preload","error","seeking","seekable","ended","playbackRate","defaultPlaybackRate","disablePictureInPicture","played","networkState","readyState","videoWidth","videoHeight","crossOrigin"].forEach(function(t){Qr.prototype[t]=function(){return this.el_[t]}}),["volume","src","poster","preload","playbackRate","defaultPlaybackRate","disablePictureInPicture","crossOrigin"].forEach(function(t){Qr.prototype["set"+ue(t)]=function(e){this.el_[t]=e}}),["pause","load","play"].forEach(function(t){Qr.prototype[t]=function(){return this.el_[t]()}}),ni.withSourceHandlers(Qr),Qr.nativeSourceHandler={},Qr.nativeSourceHandler.canPlayType=function(t){try{return Qr.TEST_VID.canPlayType(t)}catch(t){return""}},Qr.nativeSourceHandler.canHandleSource=function(t,e){if(t.type)return Qr.nativeSourceHandler.canPlayType(t.type);if(t.src){const e=Ye(t.src);return Qr.nativeSourceHandler.canPlayType(`video/${e}`)}return""},Qr.nativeSourceHandler.handleSource=function(t,e,s){e.setSrc(t.src)},Qr.nativeSourceHandler.dispose=function(){},Qr.registerSourceHandler(Qr.nativeSourceHandler),ni.registerTech("Html5",Qr);const Zr=["progress","abort","suspend","emptied","stalled","loadedmetadata","loadeddata","timeupdate","resize","volumechange","texttrackchange"],Jr={canplay:"CanPlay",canplaythrough:"CanPlayThrough",playing:"Playing",seeked:"Seeked"},tn=["tiny","xsmall","small","medium","large","xlarge","huge"],en={};tn.forEach(t=>{const e="x"===t.charAt(0)?`x-${t.substring(1)}`:t;en[t]=`vjs-layout-${e}`});const sn={tiny:210,xsmall:320,small:425,medium:768,large:1440,xlarge:2560,huge:1/0};class rn extends ge{constructor(e,s,i){if(e.id=e.id||s.id||`vjs_video_${Mt()}`,(s=Object.assign(rn.getTagSettings(e),s)).initChildren=!1,s.createEl=!1,s.evented=!1,s.reportTouchActivity=!1,!s.language){const t=e.closest("[lang]");t&&(s.language=t.getAttribute("lang"))}if(super(null,s,i),this.boundDocumentFullscreenChange_=t=>this.documentFullscreenChange_(t),this.boundFullWindowOnEscKey_=t=>this.fullWindowOnEscKey(t),this.boundUpdateStyleEl_=t=>this.updateStyleEl_(t),this.boundApplyInitTime_=t=>this.applyInitTime_(t),this.boundUpdateCurrentBreakpoint_=t=>this.updateCurrentBreakpoint_(t),this.boundHandleTechClick_=t=>this.handleTechClick_(t),this.boundHandleTechDoubleClick_=t=>this.handleTechDoubleClick_(t),this.boundHandleTechTouchStart_=t=>this.handleTechTouchStart_(t),this.boundHandleTechTouchMove_=t=>this.handleTechTouchMove_(t),this.boundHandleTechTouchEnd_=t=>this.handleTechTouchEnd_(t),this.boundHandleTechTap_=t=>this.handleTechTap_(t),this.boundUpdatePlayerHeightOnAudioOnlyMode_=t=>this.updatePlayerHeightOnAudioOnlyMode_(t),this.isFullscreen_=!1,this.log=d(this.id_),this.fsApi_=n,this.isPosterFromTech_=!1,this.queuedCallbacks_=[],this.isReady_=!1,this.hasStarted_=!1,this.userActive_=!1,this.debugEnabled_=!1,this.audioOnlyMode_=!1,this.audioPosterMode_=!1,this.audioOnlyCache_={controlBarHeight:null,playerHeight:null,hiddenChildren:[]},!this.options_||!this.options_.techOrder||!this.options_.techOrder.length)throw new Error("No techOrder specified. Did you overwrite videojs.options instead of just changing the properties you want to override?");if(this.tag=e,this.tagAttributes=e&&nt(e),this.language(this.options_.language),s.languages){const t={};Object.getOwnPropertyNames(s.languages).forEach(function(e){t[e.toLowerCase()]=s.languages[e]}),this.languages_=t}else this.languages_=rn.prototype.options_.languages;this.resetCache_(),this.poster_=s.poster||"",this.controls_=!!s.controls,e.controls=!1,e.removeAttribute("controls"),this.changingSrc_=!1,this.playCallbacks_=[],this.playTerminatedQueue_=[],e.hasAttribute("autoplay")?this.autoplay(!0):this.autoplay(this.options_.autoplay),s.plugins&&Object.keys(s.plugins).forEach(t=>{if("function"!=typeof this[t])throw new Error(`plugin "${t}" does not exist`)}),this.scrubbing_=!1,this.el_=this.createEl(),le(this,{eventBusKey:"el_"}),this.fsApi_.requestFullscreen&&($t(document,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),this.on(this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_)),this.fluid_&&this.on(["playerreset","resize"],this.boundUpdateStyleEl_);const r=v(this.options_);if(s.plugins&&Object.keys(s.plugins).forEach(t=>{this[t](s.plugins[t])}),s.debug&&this.debug(!0),this.options_.playerOptions=r,this.middleware_=[],this.playbackRates(s.playbackRates),s.experimentalSvgIcons){const t=(new window.DOMParser).parseFromString('<svg xmlns="http://www.w3.org/2000/svg">\n <defs>\n <symbol viewBox="0 0 48 48" id="vjs-icon-play">\n <path d="M16 10v28l22-14z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-pause">\n <path d="M12 38h8V10h-8v28zm16-28v28h8V10h-8z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-audio">\n <path d="M24 2C14.06 2 6 10.06 6 20v14c0 3.31 2.69 6 6 6h6V24h-8v-4c0-7.73 6.27-14 14-14s14 6.27 14 14v4h-8v16h6c3.31 0 6-2.69 6-6V20c0-9.94-8.06-18-18-18z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-captions">\n <path d="M38 8H10c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h28c2.21 0 4-1.79 4-4V12c0-2.21-1.79-4-4-4zM22 22h-3v-1h-4v6h4v-1h3v2a2 2 0 0 1-2 2h-6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2zm14 0h-3v-1h-4v6h4v-1h3v2a2 2 0 0 1-2 2h-6a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h6a2 2 0 0 1 2 2v2z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-subtitles">\n <path d="M40 8H8c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h32c2.21 0 4-1.79 4-4V12c0-2.21-1.79-4-4-4zM8 24h8v4H8v-4zm20 12H8v-4h20v4zm12 0h-8v-4h8v4zm0-8H20v-4h20v4z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-fullscreen-enter">\n <path d="M14 28h-4v10h10v-4h-6v-6zm-4-8h4v-6h6v-4H10v10zm24 14h-6v4h10V28h-4v6zm-6-24v4h6v6h4V10H28z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-fullscreen-exit">\n <path d="M10 32h6v6h4V28H10v4zm6-16h-6v4h10V10h-4v6zm12 22h4v-6h6v-4H28v10zm4-22v-6h-4v10h10v-4h-6z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-play-circle">\n <path d="M20 33l12-9-12-9v18zm4-29C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4zm0 36c-8.82 0-16-7.18-16-16S15.18 8 24 8s16 7.18 16 16-7.18 16-16 16z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-volume-mute">\n <path d="M33 24c0-3.53-2.04-6.58-5-8.05v4.42l4.91 4.91c.06-.42.09-.85.09-1.28zm5 0c0 1.88-.41 3.65-1.08 5.28l3.03 3.03C41.25 29.82 42 27 42 24c0-8.56-5.99-15.72-14-17.54v4.13c5.78 1.72 10 7.07 10 13.41zM8.55 6L6 8.55 15.45 18H6v12h8l10 10V26.55l8.51 8.51c-1.34 1.03-2.85 1.86-4.51 2.36v4.13a17.94 17.94 0 0 0 7.37-3.62L39.45 42 42 39.45l-18-18L8.55 6zM24 8l-4.18 4.18L24 16.36V8z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-volume-low">\n <path d="M14 18v12h8l10 10V8L22 18h-8z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-volume-medium">\n <path d="M37 24c0-3.53-2.04-6.58-5-8.05v16.11c2.96-1.48 5-4.53 5-8.06zm-27-6v12h8l10 10V8L18 18h-8z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-volume-high">\n <path d="M6 18v12h8l10 10V8L14 18H6zm27 6c0-3.53-2.04-6.58-5-8.05v16.11c2.96-1.48 5-4.53 5-8.06zM28 6.46v4.13c5.78 1.72 10 7.07 10 13.41s-4.22 11.69-10 13.41v4.13c8.01-1.82 14-8.97 14-17.54S36.01 8.28 28 6.46z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-spinner">\n <path d="M18.8 21l9.53-16.51C26.94 4.18 25.49 4 24 4c-4.8 0-9.19 1.69-12.64 4.51l7.33 12.69.11-.2zm24.28-3c-1.84-5.85-6.3-10.52-11.99-12.68L23.77 18h19.31zm.52 2H28.62l.58 1 9.53 16.5C41.99 33.94 44 29.21 44 24c0-1.37-.14-2.71-.4-4zm-26.53 4l-7.8-13.5C6.01 14.06 4 18.79 4 24c0 1.37.14 2.71.4 4h14.98l-2.31-4zM4.92 30c1.84 5.85 6.3 10.52 11.99 12.68L24.23 30H4.92zm22.54 0l-7.8 13.51c1.4.31 2.85.49 4.34.49 4.8 0 9.19-1.69 12.64-4.51L29.31 26.8 27.46 30z"></path>\n </symbol>\n <symbol viewBox="0 0 24 24" id="vjs-icon-hd">\n <path d="M19 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-8 12H9.5v-2h-2v2H6V9h1.5v2.5h2V9H11v6zm2-6h4c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1h-4V9zm1.5 4.5h2v-3h-2v3z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-chapters">\n <path d="M6 26h4v-4H6v4zm0 8h4v-4H6v4zm0-16h4v-4H6v4zm8 8h28v-4H14v4zm0 8h28v-4H14v4zm0-20v4h28v-4H14z"></path>\n </symbol>\n <symbol viewBox="0 0 40 40" id="vjs-icon-downloading">\n <path d="M18.208 36.875q-3.208-.292-5.979-1.729-2.771-1.438-4.812-3.729-2.042-2.292-3.188-5.229-1.146-2.938-1.146-6.23 0-6.583 4.334-11.416 4.333-4.834 10.833-5.5v3.166q-5.167.75-8.583 4.646Q6.25 14.75 6.25 19.958q0 5.209 3.396 9.104 3.396 3.896 8.562 4.646zM20 28.417L11.542 20l2.083-2.083 4.917 4.916v-11.25h2.916v11.25l4.875-4.916L28.417 20zm1.792 8.458v-3.167q1.833-.25 3.541-.958 1.709-.708 3.167-1.875l2.333 2.292q-1.958 1.583-4.25 2.541-2.291.959-4.791 1.167zm6.791-27.792q-1.541-1.125-3.25-1.854-1.708-.729-3.541-1.021V3.042q2.5.25 4.77 1.208 2.271.958 4.271 2.5zm4.584 21.584l-2.25-2.25q1.166-1.5 1.854-3.209.687-1.708.937-3.541h3.209q-.292 2.5-1.229 4.791-.938 2.292-2.521 4.209zm.541-12.417q-.291-1.833-.958-3.562-.667-1.73-1.833-3.188l2.375-2.208q1.541 1.916 2.458 4.208.917 2.292 1.167 4.75z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-file-download">\n <path d="M10.8 40.55q-1.35 0-2.375-1T7.4 37.15v-7.7h3.4v7.7h26.35v-7.7h3.4v7.7q0 1.4-1 2.4t-2.4 1zM24 32.1L13.9 22.05l2.45-2.45 5.95 5.95V7.15h3.4v18.4l5.95-5.95 2.45 2.45z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-file-download-done">\n <path d="M9.8 40.5v-3.45h28.4v3.45zm9.2-9.05L7.4 19.85l2.45-2.35L19 26.65l19.2-19.2 2.4 2.4z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-file-download-off">\n <path d="M4.9 4.75L43.25 43.1 41 45.3l-4.75-4.75q-.05.05-.075.025-.025-.025-.075-.025H10.8q-1.35 0-2.375-1T7.4 37.15v-7.7h3.4v7.7h22.05l-7-7-1.85 1.8L13.9 21.9l1.85-1.85L2.7 7zm26.75 14.7l2.45 2.45-3.75 3.8-2.45-2.5zM25.7 7.15V21.1l-3.4-3.45V7.15z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-share">\n <path d="M36 32.17c-1.52 0-2.89.59-3.93 1.54L17.82 25.4c.11-.45.18-.92.18-1.4s-.07-.95-.18-1.4l14.1-8.23c1.07 1 2.5 1.62 4.08 1.62 3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6c0 .48.07.95.18 1.4l-14.1 8.23c-1.07-1-2.5-1.62-4.08-1.62-3.31 0-6 2.69-6 6s2.69 6 6 6c1.58 0 3.01-.62 4.08-1.62l14.25 8.31c-.1.42-.16.86-.16 1.31A5.83 5.83 0 1 0 36 32.17z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-cog">\n <path d="M38.86 25.95c.08-.64.14-1.29.14-1.95s-.06-1.31-.14-1.95l4.23-3.31c.38-.3.49-.84.24-1.28l-4-6.93c-.25-.43-.77-.61-1.22-.43l-4.98 2.01c-1.03-.79-2.16-1.46-3.38-1.97L29 4.84c-.09-.47-.5-.84-1-.84h-8c-.5 0-.91.37-.99.84l-.75 5.3a14.8 14.8 0 0 0-3.38 1.97L9.9 10.1a1 1 0 0 0-1.22.43l-4 6.93c-.25.43-.14.97.24 1.28l4.22 3.31C9.06 22.69 9 23.34 9 24s.06 1.31.14 1.95l-4.22 3.31c-.38.3-.49.84-.24 1.28l4 6.93c.25.43.77.61 1.22.43l4.98-2.01c1.03.79 2.16 1.46 3.38 1.97l.75 5.3c.08.47.49.84.99.84h8c.5 0 .91-.37.99-.84l.75-5.3a14.8 14.8 0 0 0 3.38-1.97l4.98 2.01a1 1 0 0 0 1.22-.43l4-6.93c.25-.43.14-.97-.24-1.28l-4.22-3.31zM24 31c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-square">\n <path d="M36 8H12c-2.21 0-4 1.79-4 4v24c0 2.21 1.79 4 4 4h24c2.21 0 4-1.79 4-4V12c0-2.21-1.79-4-4-4zm0 28H12V12h24v24z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-circle">\n <circle cx="24" cy="24" r="20"></circle>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-circle-outline">\n <path d="M24 4C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4zm0 36c-8.82 0-16-7.18-16-16S15.18 8 24 8s16 7.18 16 16-7.18 16-16 16z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-circle-inner-circle">\n <path d="M24 4C12.97 4 4 12.97 4 24s8.97 20 20 20 20-8.97 20-20S35.03 4 24 4zm0 36c-8.82 0-16-7.18-16-16S15.18 8 24 8s16 7.18 16 16-7.18 16-16 16zm6-16c0 3.31-2.69 6-6 6s-6-2.69-6-6 2.69-6 6-6 6 2.69 6 6z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-cancel">\n <path d="M24 4C12.95 4 4 12.95 4 24s8.95 20 20 20 20-8.95 20-20S35.05 4 24 4zm10 27.17L31.17 34 24 26.83 16.83 34 14 31.17 21.17 24 14 16.83 16.83 14 24 21.17 31.17 14 34 16.83 26.83 24 34 31.17z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-replay">\n <path d="M24 10V2L14 12l10 10v-8c6.63 0 12 5.37 12 12s-5.37 12-12 12-12-5.37-12-12H8c0 8.84 7.16 16 16 16s16-7.16 16-16-7.16-16-16-16z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-repeat">\n <path d="M14 14h20v6l8-8-8-8v6H10v12h4v-8zm20 20H14v-6l-8 8 8 8v-6h24V26h-4v8z"></path>\n </symbol>\n <symbol viewBox="0 96 48 48" id="vjs-icon-replay-5">\n <path d="M17.689 98l-8.697 8.696 8.697 8.697 2.486-2.485-4.32-4.319h1.302c4.93 0 9.071 1.722 12.424 5.165 3.352 3.443 5.029 7.638 5.029 12.584h3.55c0-2.958-.553-5.73-1.658-8.313-1.104-2.583-2.622-4.841-4.555-6.774-1.932-1.932-4.19-3.45-6.773-4.555-2.584-1.104-5.355-1.657-8.313-1.657H15.5l4.615-4.615zm-8.08 21.659v13.861h11.357v5.008H9.609V143h12.7c.834 0 1.55-.298 2.146-.894.596-.597.895-1.31.895-2.145v-7.781c0-.835-.299-1.55-.895-2.147a2.929 2.929 0 0 0-2.147-.894h-8.227v-5.096H25.35v-4.384z"></path>\n </symbol>\n <symbol viewBox="0 96 48 48" id="vjs-icon-replay-10">\n <path d="M42.315 125.63c0-4.997-1.694-9.235-5.08-12.713-3.388-3.479-7.571-5.218-12.552-5.218h-1.315l4.363 4.363-2.51 2.51-8.787-8.786L25.221 97l2.45 2.45-4.662 4.663h1.375c2.988 0 5.788.557 8.397 1.673 2.61 1.116 4.892 2.65 6.844 4.602 1.953 1.953 3.487 4.234 4.602 6.844 1.116 2.61 1.674 5.41 1.674 8.398zM8.183 142v-19.657H3.176V117.8h9.643V142zm13.63 0c-1.156 0-2.127-.393-2.912-1.178-.778-.778-1.168-1.746-1.168-2.902v-16.04c0-1.156.393-2.127 1.178-2.912.779-.779 1.746-1.168 2.902-1.168h7.696c1.156 0 2.126.392 2.911 1.177.779.78 1.168 1.747 1.168 2.903v16.04c0 1.156-.392 2.127-1.177 2.912-.779.779-1.746 1.168-2.902 1.168zm.556-4.636h6.583v-15.02H22.37z"></path>\n </symbol>\n <symbol viewBox="0 96 48 48" id="vjs-icon-replay-30">\n <path d="M26.047 97l-8.733 8.732 8.733 8.733 2.496-2.494-4.336-4.338h1.307c4.95 0 9.108 1.73 12.474 5.187 3.367 3.458 5.051 7.668 5.051 12.635h3.565c0-2.97-.556-5.751-1.665-8.346-1.109-2.594-2.633-4.862-4.574-6.802-1.94-1.941-4.208-3.466-6.803-4.575-2.594-1.109-5.375-1.664-8.345-1.664H23.85l4.634-4.634zM2.555 117.531v4.688h10.297v5.25H5.873v4.687h6.979v5.156H2.555V142H13.36c1.061 0 1.95-.395 2.668-1.186.718-.79 1.076-1.772 1.076-2.94v-16.218c0-1.168-.358-2.149-1.076-2.94-.717-.79-1.607-1.185-2.668-1.185zm22.482.14c-1.149 0-2.11.39-2.885 1.165-.78.78-1.172 1.744-1.172 2.893v15.943c0 1.149.388 2.11 1.163 2.885.78.78 1.745 1.172 2.894 1.172h7.649c1.148 0 2.11-.388 2.884-1.163.78-.78 1.17-1.745 1.17-2.894v-15.943c0-1.15-.386-2.111-1.16-2.885-.78-.78-1.746-1.172-2.894-1.172zm.553 4.518h6.545v14.93H25.59z"></path>\n </symbol>\n <symbol viewBox="0 96 48 48" id="vjs-icon-forward-5">\n <path d="M29.508 97l-2.431 2.43 4.625 4.625h-1.364c-2.965 0-5.742.554-8.332 1.66-2.589 1.107-4.851 2.629-6.788 4.566-1.937 1.937-3.458 4.2-4.565 6.788-1.107 2.59-1.66 5.367-1.66 8.331h3.557c0-4.957 1.68-9.16 5.04-12.611 3.36-3.45 7.51-5.177 12.451-5.177h1.304l-4.326 4.33 2.49 2.49 8.715-8.716zm-9.783 21.61v13.89h11.382v5.018H19.725V142h12.727a2.93 2.93 0 0 0 2.15-.896 2.93 2.93 0 0 0 .896-2.15v-7.798c0-.837-.299-1.554-.896-2.152a2.93 2.93 0 0 0-2.15-.896h-8.245V123h11.29v-4.392z"></path>\n </symbol>\n <symbol viewBox="0 96 48 48" id="vjs-icon-forward-10">\n <path d="M23.119 97l-2.386 2.383 4.538 4.538h-1.339c-2.908 0-5.633.543-8.173 1.63-2.54 1.085-4.76 2.577-6.66 4.478-1.9 1.9-3.392 4.12-4.478 6.66-1.085 2.54-1.629 5.264-1.629 8.172h3.49c0-4.863 1.648-8.986 4.944-12.372 3.297-3.385 7.368-5.078 12.216-5.078h1.279l-4.245 4.247 2.443 2.442 8.55-8.55zm-9.52 21.45v4.42h4.871V142h4.513v-23.55zm18.136 0c-1.125 0-2.066.377-2.824 1.135-.764.764-1.148 1.709-1.148 2.834v15.612c0 1.124.38 2.066 1.139 2.824.764.764 1.708 1.145 2.833 1.145h7.489c1.125 0 2.066-.378 2.824-1.136.764-.764 1.145-1.709 1.145-2.833v-15.612c0-1.125-.378-2.067-1.136-2.825-.764-.764-1.708-1.145-2.833-1.145zm.54 4.42h6.408v14.617h-6.407z"></path>\n </symbol>\n <symbol viewBox="0 96 48 48" id="vjs-icon-forward-30">\n <path d="M25.549 97l-2.437 2.434 4.634 4.635H26.38c-2.97 0-5.753.555-8.347 1.664-2.594 1.109-4.861 2.633-6.802 4.574-1.94 1.94-3.465 4.207-4.574 6.802-1.109 2.594-1.664 5.377-1.664 8.347h3.565c0-4.967 1.683-9.178 5.05-12.636 3.366-3.458 7.525-5.187 12.475-5.187h1.307l-4.335 4.338 2.495 2.494 8.732-8.732zm-11.553 20.53v4.689h10.297v5.249h-6.978v4.688h6.978v5.156H13.996V142h10.808c1.06 0 1.948-.395 2.666-1.186.718-.79 1.077-1.771 1.077-2.94v-16.217c0-1.169-.36-2.15-1.077-2.94-.718-.79-1.605-1.186-2.666-1.186zm21.174.168c-1.149 0-2.11.389-2.884 1.163-.78.78-1.172 1.745-1.172 2.894v15.942c0 1.15.388 2.11 1.162 2.885.78.78 1.745 1.17 2.894 1.17h7.649c1.149 0 2.11-.386 2.885-1.16.78-.78 1.17-1.746 1.17-2.895v-15.942c0-1.15-.387-2.11-1.161-2.885-.78-.78-1.745-1.172-2.894-1.172zm.552 4.516h6.542v14.931h-6.542z"></path>\n </symbol>\n <symbol viewBox="0 0 512 512" id="vjs-icon-audio-description">\n <g fill-rule="evenodd"><path d="M227.29 381.351V162.993c50.38-1.017 89.108-3.028 117.631 17.126 27.374 19.342 48.734 56.965 44.89 105.325-4.067 51.155-41.335 94.139-89.776 98.475-24.085 2.155-71.972 0-71.972 0s-.84-1.352-.773-2.568m48.755-54.804c31.43 1.26 53.208-16.633 56.495-45.386 4.403-38.51-21.188-63.552-58.041-60.796v103.612c-.036 1.466.575 2.22 1.546 2.57"></path><path d="M383.78 381.328c13.336 3.71 17.387-11.06 23.215-21.408 12.722-22.571 22.294-51.594 22.445-84.774.221-47.594-18.343-82.517-35.6-106.182h-8.51c-.587 3.874 2.226 7.315 3.865 10.276 13.166 23.762 25.367 56.553 25.54 94.194.2 43.176-14.162 79.278-30.955 107.894"></path><path d="M425.154 381.328c13.336 3.71 17.384-11.061 23.215-21.408 12.721-22.571 22.291-51.594 22.445-84.774.221-47.594-18.343-82.517-35.6-106.182h-8.511c-.586 3.874 2.226 7.315 3.866 10.276 13.166 23.762 25.367 56.553 25.54 94.194.2 43.176-14.162 79.278-30.955 107.894"></path><path d="M466.26 381.328c13.337 3.71 17.385-11.061 23.216-21.408 12.722-22.571 22.292-51.594 22.445-84.774.221-47.594-18.343-82.517-35.6-106.182h-8.51c-.587 3.874 2.225 7.315 3.865 10.276 13.166 23.762 25.367 56.553 25.54 94.194.2 43.176-14.162 79.278-30.955 107.894M4.477 383.005H72.58l18.573-28.484 64.169-.135s.065 19.413.065 28.62h48.756V160.307h-58.816c-5.653 9.537-140.85 222.697-140.85 222.697zm152.667-145.282v71.158l-40.453-.27 40.453-70.888z"></path></g>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-next-item">\n <path d="M12 36l17-12-17-12v24zm20-24v24h4V12h-4z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-previous-item">\n <path d="M12 12h4v24h-4zm7 12l17 12V12z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-shuffle">\n <path d="M21.17 18.34L10.83 8 8 10.83l10.34 10.34 2.83-2.83zM29 8l4.09 4.09L8 37.17 10.83 40l25.09-25.09L40 19V8H29zm.66 18.83l-2.83 2.83 6.26 6.26L29 40h11V29l-4.09 4.09-6.25-6.26z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-cast">\n <path d="M42 6H6c-2.21 0-4 1.79-4 4v6h4v-6h36v28H28v4h14c2.21 0 4-1.79 4-4V10c0-2.21-1.79-4-4-4zM2 36v6h6c0-3.31-2.69-6-6-6zm0-8v4c5.52 0 10 4.48 10 10h4c0-7.73-6.27-14-14-14zm0-8v4c9.94 0 18 8.06 18 18h4c0-12.15-9.85-22-22-22z"></path>\n </symbol>\n <symbol viewBox="0 0 48 48" id="vjs-icon-picture-in-picture-enter">\n <path d="M38 22H22v11.99h16V22zm8 16V9.96C46 7.76 44.2 6 42 6H6C3.8 6 2 7.76 2 9.96V38c0 2.2 1.8 4 4 4h36c2.2 0 4-1.8 4-4zm-4 .04H6V9.94h36v28.1z"></path>\n </symbol>\n <symbol viewBox="0 0 22 18" id="vjs-icon-picture-in-picture-exit">\n <path d="M18 4H4v10h14V4zm4 12V1.98C22 .88 21.1 0 20 0H2C.9 0 0 .88 0 1.98V16c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2zm-2 .02H2V1.97h18v14.05z"></path>\n <path fill="none" d="M-1-3h24v24H-1z"></path>\n </symbol>\n <symbol viewBox="0 0 1792 1792" id="vjs-icon-facebook">\n <path d="M1343 12v264h-157q-86 0-116 36t-30 108v189h293l-39 296h-254v759H734V905H479V609h255V391q0-186 104-288.5T1115 0q147 0 228 12z"></path>\n </symbol>\n <symbol viewBox="0 0 1792 1792" id="vjs-icon-linkedin">\n <path d="M477 625v991H147V625h330zm21-306q1 73-50.5 122T312 490h-2q-82 0-132-49t-50-122q0-74 51.5-122.5T314 148t133 48.5T498 319zm1166 729v568h-329v-530q0-105-40.5-164.5T1168 862q-63 0-105.5 34.5T999 982q-11 30-11 81v553H659q2-399 2-647t-1-296l-1-48h329v144h-2q20-32 41-56t56.5-52 87-43.5T1285 602q171 0 275 113.5t104 332.5z"></path>\n </symbol>\n <symbol viewBox="0 0 1200 1227" id="vjs-icon-twitter">\n <path d="M714.163 519.284L1160.89 0H1055.03L667.137 450.887L357.328 0H0L468.492 681.821L0 1226.37H105.866L515.491 750.218L842.672 1226.37H1200L714.137 519.284H714.163ZM569.165 687.828L521.697 619.934L144.011 79.6944H306.615L611.412 515.685L658.88 583.579L1055.08 1150.3H892.476L569.165 687.854V687.828Z"/>\n </symbol>\n <symbol viewBox="0 0 1792 1792" id="vjs-icon-tumblr">\n <path d="M1328 1329l80 237q-23 35-111 66t-177 32q-104 2-190.5-26T787 1564t-95-106-55.5-120-16.5-118V676H452V461q72-26 129-69.5t91-90 58-102 34-99T779 12q1-5 4.5-8.5T791 0h244v424h333v252h-334v518q0 30 6.5 56t22.5 52.5 49.5 41.5 81.5 14q78-2 134-29z"></path>\n </symbol>\n <symbol viewBox="0 0 1792 1792" id="vjs-icon-pinterest">\n <path d="M1664 896q0 209-103 385.5T1281.5 1561 896 1664q-111 0-218-32 59-93 78-164 9-34 54-211 20 39 73 67.5t114 28.5q121 0 216-68.5t147-188.5 52-270q0-114-59.5-214T1180 449t-255-63q-105 0-196 29t-154.5 77-109 110.5-67 129.5T377 866q0 104 40 183t117 111q30 12 38-20 2-7 8-31t8-30q6-23-11-43-51-61-51-151 0-151 104.5-259.5T904 517q151 0 235.5 82t84.5 213q0 170-68.5 289T980 1220q-61 0-98-43.5T859 1072q8-35 26.5-93.5t30-103T927 800q0-50-27-83t-77-33q-62 0-105 57t-43 142q0 73 25 122l-99 418q-17 70-13 177-206-91-333-281T128 896q0-209 103-385.5T510.5 231 896 128t385.5 103T1561 510.5 1664 896z"></path>\n </symbol>\n </defs>\n</svg>',"image/svg+xml");if(t.querySelector("parsererror"))c.warn("Failed to load SVG Icons. Falling back to Font Icons."),this.options_.experimentalSvgIcons=null;else{const e=t.documentElement;e.style.display="none",this.el_.appendChild(e),this.addClass("vjs-svg-icons-enabled")}}this.initChildren(),this.isAudio("audio"===e.nodeName.toLowerCase()),this.controls()?this.addClass("vjs-controls-enabled"):this.addClass("vjs-controls-disabled"),this.el_.setAttribute("role","region"),this.isAudio()?this.el_.setAttribute("aria-label",this.localize("Audio Player")):this.el_.setAttribute("aria-label",this.localize("Video Player")),this.isAudio()&&this.addClass("vjs-audio"),s.spatialNavigation&&s.spatialNavigation.enabled&&(this.spatialNavigation=new Ai(this),this.addClass("vjs-spatial-navigation-enabled")),U&&this.addClass("vjs-touch-enabled"),V||this.addClass("vjs-workinghover"),rn.players[this.id_]=this;const a=t.split(".")[0];this.addClass(`vjs-v${a}`),this.userActive(!0),this.reportUserActivity(),this.one("play",t=>this.listenForUserActivity_(t)),this.on("keydown",t=>this.handleKeyDown(t)),this.on("languagechange",t=>this.handleLanguagechange(t)),this.breakpoints(this.options_.breakpoints),this.responsive(this.options_.responsive),this.on("ready",()=>{this.audioPosterMode(this.options_.audioPosterMode),this.audioOnlyMode(this.options_.audioOnlyMode)})}dispose(){var t;this.trigger("dispose"),this.off("dispose"),Ut(document,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),Ut(document,"keydown",this.boundFullWindowOnEscKey_),this.styleEl_&&this.styleEl_.parentNode&&(this.styleEl_.parentNode.removeChild(this.styleEl_),this.styleEl_=null),rn.players[this.id_]=null,this.tag&&this.tag.player&&(this.tag.player=null),this.el_&&this.el_.player&&(this.el_.player=null),this.tech_&&(this.tech_.dispose(),this.isPosterFromTech_=!1,this.poster_=""),this.playerElIngest_&&(this.playerElIngest_=null),this.tag&&(this.tag=null),t=this,oi.hasOwnProperty(t.id())&&delete oi[t.id()],Cs.names.forEach(t=>{const e=this[Cs[t].getterName]();e&&e.off&&e.off()}),super.dispose({restoreEl:this.options_.restoreEl})}createEl(){let t,e=this.tag,s=this.playerElIngest_=e.parentNode&&e.parentNode.hasAttribute&&e.parentNode.hasAttribute("data-vjs-player");const i="video-js"===this.tag.tagName.toLowerCase();s?t=this.el_=e.parentNode:i||(t=this.el_=super.createEl("div"));const r=nt(e);if(i){for(t=this.el_=e,e=this.tag=document.createElement("video");t.children.length;)e.appendChild(t.firstChild);tt(t,"video-js")||et(t,"video-js"),t.appendChild(e),s=this.playerElIngest_=t,Object.keys(t).forEach(s=>{try{e[s]=t[s]}catch(t){}})}e.setAttribute("tabindex","-1"),r.tabindex="-1",I&&M&&(e.setAttribute("role","application"),r.role="application"),e.removeAttribute("width"),e.removeAttribute("height"),"width"in r&&delete r.width,"height"in r&&delete r.height,Object.getOwnPropertyNames(r).forEach(function(s){i&&"class"===s||t.setAttribute(s,r[s]),i&&e.setAttribute(s,r[s])}),e.playerId=e.id,e.id+="_html5_api",e.className="vjs-tech",e.player=t.player=this,this.addClass("vjs-paused");const n=["IS_SMART_TV","IS_TIZEN","IS_WEBOS","IS_ANDROID","IS_IPAD","IS_IPHONE","IS_CHROMECAST_RECEIVER"].filter(t=>W[t]).map(t=>"vjs-device-"+t.substring(3).toLowerCase().replace(/\_/g,"-"));if(this.addClass(...n),!0!==window.VIDEOJS_NO_DYNAMIC_STYLE){this.styleEl_=Pt("vjs-styles-dimensions");const t=_t(".vjs-styles-defaults"),e=_t("head");e.insertBefore(this.styleEl_,t?t.nextSibling:e.firstChild)}this.fill_=!1,this.fluid_=!1,this.width(this.options_.width),this.height(this.options_.height),this.fill(this.options_.fill),this.fluid(this.options_.fluid),this.aspectRatio(this.options_.aspectRatio),this.crossOrigin(this.options_.crossOrigin||this.options_.crossorigin);const a=e.getElementsByTagName("a");for(let t=0;t<a.length;t++){const e=a.item(t);et(e,"vjs-hidden"),e.setAttribute("hidden","hidden")}return e.initNetworkState_=e.networkState,e.parentNode&&!s&&e.parentNode.insertBefore(t,e),J(e,t),this.children_.unshift(e),this.el_.setAttribute("lang",this.language_),this.el_.setAttribute("translate","no"),this.el_=t,t}crossOrigin(t){if(void 0===t)return this.techGet_("crossOrigin");null===t||"anonymous"===t||"use-credentials"===t?(this.techCall_("setCrossOrigin",t),this.posterImage&&this.posterImage.crossOrigin(t)):c.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${t}"`)}width(t){return this.dimension("width",t)}height(t){return this.dimension("height",t)}dimension(t,e){const s=t+"_";if(void 0===e)return this[s]||0;if(""===e||"auto"===e)return this[s]=void 0,void this.updateStyleEl_();const i=parseFloat(e);isNaN(i)?c.error(`Improper value "${e}" supplied for for ${t}`):(this[s]=i,this.updateStyleEl_())}fluid(t){if(void 0===t)return!!this.fluid_;var e,s;this.fluid_=!!t,te(this)&&this.off(["playerreset","resize"],this.boundUpdateStyleEl_),t?(this.addClass("vjs-fluid"),this.fill(!1),s=()=>{this.on(["playerreset","resize"],this.boundUpdateStyleEl_)},te(e=this)?s():(e.eventedCallbacks||(e.eventedCallbacks=[]),e.eventedCallbacks.push(s))):this.removeClass("vjs-fluid"),this.updateStyleEl_()}fill(t){if(void 0===t)return!!this.fill_;this.fill_=!!t,t?(this.addClass("vjs-fill"),this.fluid(!1)):this.removeClass("vjs-fill")}aspectRatio(t){if(void 0===t)return this.aspectRatio_;if(!/^\d+\:\d+$/.test(t))throw new Error("Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.");this.aspectRatio_=t,this.fluid(!0),this.updateStyleEl_()}updateStyleEl_(){if(!0===window.VIDEOJS_NO_DYNAMIC_STYLE){const t="number"==typeof this.width_?this.width_:this.options_.width,e="number"==typeof this.height_?this.height_:this.options_.height,s=this.tech_&&this.tech_.el();return void(s&&(t>=0&&(s.width=t),e>=0&&(s.height=e)))}let t,e,s,i;s=void 0!==this.aspectRatio_&&"auto"!==this.aspectRatio_?this.aspectRatio_:this.videoWidth()>0?this.videoWidth()+":"+this.videoHeight():"16:9";const r=s.split(":"),n=r[1]/r[0];t=void 0!==this.width_?this.width_:void 0!==this.height_?this.height_/n:this.videoWidth()||300,e=void 0!==this.height_?this.height_:t*n,i=/^[^a-zA-Z]/.test(this.id())?"dimensions-"+this.id():this.id()+"-dimensions",this.addClass(i),xt(this.styleEl_,`\n .${i} {\n width: ${t}px;\n height: ${e}px;\n }\n\n .${i}.vjs-fluid:not(.vjs-audio-only-mode) {\n padding-top: ${100*n}%;\n }\n `)}loadTech_(t,e){this.tech_&&this.unloadTech_();const s=ue(t),i=t.charAt(0).toLowerCase()+t.slice(1);"Html5"!==s&&this.tag&&(ni.getTech("Html5").disposeMediaElement(this.tag),this.tag.player=null,this.tag=null),this.techName_=s,this.isReady_=!1;let r=this.autoplay();("string"==typeof this.autoplay()||!0===this.autoplay()&&this.options_.normalizeAutoplay)&&(r=!1);const n={source:e,autoplay:r,nativeControlsForTouch:this.options_.nativeControlsForTouch,playerId:this.id(),techId:`${this.id()}_${i}_api`,playsinline:this.options_.playsinline,preload:this.options_.preload,loop:this.options_.loop,disablePictureInPicture:this.options_.disablePictureInPicture,muted:this.options_.muted,poster:this.poster(),language:this.language(),playerElIngest:this.playerElIngest_||!1,"vtt.js":this.options_["vtt.js"],canOverridePoster:!!this.options_.techCanOverridePoster,enableSourceset:this.options_.enableSourceset};Cs.names.forEach(t=>{const e=Cs[t];n[e.getterName]=this[e.privateName]}),Object.assign(n,this.options_[s]),Object.assign(n,this.options_[i]),Object.assign(n,this.options_[t.toLowerCase()]),this.tag&&(n.tag=this.tag),e&&e.src===this.cache_.src&&this.cache_.currentTime>0&&(n.startTime=this.cache_.currentTime);const a=ni.getTech(t);if(!a)throw new Error(`No Tech named '${s}' exists! '${s}' should be registered using videojs.registerTech()'`);this.tech_=new a(n),this.tech_.ready(zt(this,this.handleTechReady_),!0),xe(this.textTracksJson_||[],this.tech_),Zr.forEach(t=>{this.on(this.tech_,t,e=>this[`handleTech${ue(t)}_`](e))}),Object.keys(Jr).forEach(t=>{this.on(this.tech_,t,e=>{0===this.tech_.playbackRate()&&this.tech_.seeking()?this.queuedCallbacks_.push({callback:this[`handleTech${Jr[t]}_`].bind(this),event:e}):this[`handleTech${Jr[t]}_`](e)})}),this.on(this.tech_,"loadstart",t=>this.handleTechLoadStart_(t)),this.on(this.tech_,"sourceset",t=>this.handleTechSourceset_(t)),this.on(this.tech_,"waiting",t=>this.handleTechWaiting_(t)),this.on(this.tech_,"ended",t=>this.handleTechEnded_(t)),this.on(this.tech_,"seeking",t=>this.handleTechSeeking_(t)),this.on(this.tech_,"play",t=>this.handleTechPlay_(t)),this.on(this.tech_,"pause",t=>this.handleTechPause_(t)),this.on(this.tech_,"durationchange",t=>this.handleTechDurationChange_(t)),this.on(this.tech_,"fullscreenchange",(t,e)=>this.handleTechFullscreenChange_(t,e)),this.on(this.tech_,"fullscreenerror",(t,e)=>this.handleTechFullscreenError_(t,e)),this.on(this.tech_,"enterpictureinpicture",t=>this.handleTechEnterPictureInPicture_(t)),this.on(this.tech_,"leavepictureinpicture",t=>this.handleTechLeavePictureInPicture_(t)),this.on(this.tech_,"error",t=>this.handleTechError_(t)),this.on(this.tech_,"posterchange",t=>this.handleTechPosterChange_(t)),this.on(this.tech_,"textdata",t=>this.handleTechTextData_(t)),this.on(this.tech_,"ratechange",t=>this.handleTechRateChange_(t)),this.on(this.tech_,"loadedmetadata",this.boundUpdateStyleEl_),this.usingNativeControls(this.techGet_("controls")),this.controls()&&!this.usingNativeControls()&&this.addTechControlsListeners_(),this.tech_.el().parentNode===this.el()||"Html5"===s&&this.tag||J(this.tech_.el(),this.el()),this.tag&&(this.tag.player=null,this.tag=null)}unloadTech_(){Cs.names.forEach(t=>{const e=Cs[t];this[e.privateName]=this[e.getterName]()}),this.textTracksJson_=Pe(this.tech_),this.isReady_=!1,this.tech_.dispose(),this.tech_=!1,this.isPosterFromTech_&&(this.poster_="",this.trigger("posterchange")),this.isPosterFromTech_=!1}tech(t){return void 0===t&&c.warn("Using the tech directly can be dangerous. I hope you know what you're doing.\nSee https://github.com/videojs/video.js/issues/2617 for more info.\n"),this.tech_}version(){return{"video.js":t}}addTechControlsListeners_(){this.removeTechControlsListeners_(),this.on(this.tech_,"click",this.boundHandleTechClick_),this.on(this.tech_,"dblclick",this.boundHandleTechDoubleClick_),this.on(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.on(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.on(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.on(this.tech_,"tap",this.boundHandleTechTap_)}removeTechControlsListeners_(){this.off(this.tech_,"tap",this.boundHandleTechTap_),this.off(this.tech_,"touchstart",this.boundHandleTechTouchStart_),this.off(this.tech_,"touchmove",this.boundHandleTechTouchMove_),this.off(this.tech_,"touchend",this.boundHandleTechTouchEnd_),this.off(this.tech_,"click",this.boundHandleTechClick_),this.off(this.tech_,"dblclick",this.boundHandleTechDoubleClick_)}handleTechReady_(){this.triggerReady(),this.cache_.volume&&this.techCall_("setVolume",this.cache_.volume),this.handleTechPosterChange_(),this.handleTechDurationChange_()}handleTechLoadStart_(){this.removeClass("vjs-ended","vjs-seeking"),this.error(null),this.handleTechDurationChange_(),this.paused()?(this.hasStarted(!1),this.trigger("loadstart")):this.trigger("loadstart"),this.manualAutoplay_(!0===this.autoplay()&&this.options_.normalizeAutoplay?"play":this.autoplay())}manualAutoplay_(t){if(!this.tech_||"string"!=typeof t)return;const e=()=>{const t=this.muted();this.muted(!0);const e=()=>{this.muted(t)};this.playTerminatedQueue_.push(e);const s=this.play();if(we(s))return s.catch(t=>{throw e(),new Error(`Rejection at manualAutoplay. Restoring muted value. ${t||""}`)})};let s;return"any"!==t||this.muted()?s="muted"!==t||this.muted()?this.play():e():(s=this.play(),we(s)&&(s=s.catch(e))),we(s)?s.then(()=>{this.trigger({type:"autoplay-success",autoplay:t})}).catch(()=>{this.trigger({type:"autoplay-failure",autoplay:t})}):void 0}updateSourceCaches_(t=""){let e=t,s="";"string"!=typeof e&&(e=t.src,s=t.type),this.cache_.source=this.cache_.source||{},this.cache_.sources=this.cache_.sources||[],e&&!s&&(s=((t,e)=>{if(!e)return"";if(t.cache_.source.src===e&&t.cache_.source.type)return t.cache_.source.type;const s=t.cache_.sources.filter(t=>t.src===e);if(s.length)return s[0].type;const i=t.$$("source");for(let t=0;t<i.length;t++){const s=i[t];if(s.type&&s.src&&s.src===e)return s.type}return yi(e)})(this,e)),this.cache_.source=v({},t,{src:e,type:s});const i=this.cache_.sources.filter(t=>t.src&&t.src===e),r=[],n=this.$$("source"),a=[];for(let t=0;t<n.length;t++){const s=nt(n[t]);r.push(s),s.src&&s.src===e&&a.push(s.src)}a.length&&!i.length?this.cache_.sources=r:i.length||(this.cache_.sources=[this.cache_.source]),this.cache_.src=e}handleTechSourceset_(t){if(!this.changingSrc_){let e=t=>this.updateSourceCaches_(t);const s=this.currentSource().src,i=t.src;s&&!/^blob:/.test(s)&&/^blob:/.test(i)&&(!this.lastSource_||this.lastSource_.tech!==i&&this.lastSource_.player!==s)&&(e=()=>{}),e(i),t.src||this.tech_.any(["sourceset","loadstart"],t=>{if("sourceset"===t.type)return;const e=this.techGet_("currentSrc");this.lastSource_.tech=e,this.updateSourceCaches_(e)})}this.lastSource_={player:this.currentSource().src,tech:t.src},this.trigger({src:t.src,type:"sourceset"})}hasStarted(t){if(void 0===t)return this.hasStarted_;t!==this.hasStarted_&&(this.hasStarted_=t,this.hasStarted_?this.addClass("vjs-has-started"):this.removeClass("vjs-has-started"))}handleTechPlay_(){this.removeClass("vjs-ended","vjs-paused"),this.addClass("vjs-playing"),this.hasStarted(!0),this.trigger("play")}handleTechRateChange_(){this.tech_.playbackRate()>0&&0===this.cache_.lastPlaybackRate&&(this.queuedCallbacks_.forEach(t=>t.callback(t.event)),this.queuedCallbacks_=[]),this.cache_.lastPlaybackRate=this.tech_.playbackRate(),this.trigger("ratechange")}handleTechWaiting_(){this.addClass("vjs-waiting"),this.trigger("waiting");const t=this.currentTime(),e=()=>{t!==this.currentTime()&&(this.removeClass("vjs-waiting"),this.off("timeupdate",e))};this.on("timeupdate",e)}handleTechCanPlay_(){this.removeClass("vjs-waiting"),this.trigger("canplay")}handleTechCanPlayThrough_(){this.removeClass("vjs-waiting"),this.trigger("canplaythrough")}handleTechPlaying_(){this.removeClass("vjs-waiting"),this.trigger("playing")}handleTechSeeking_(){this.addClass("vjs-seeking"),this.trigger("seeking")}handleTechSeeked_(){this.removeClass("vjs-seeking","vjs-ended"),this.trigger("seeked")}handleTechPause_(){this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.trigger("pause")}handleTechEnded_(){this.addClass("vjs-ended"),this.removeClass("vjs-waiting"),this.options_.loop?(this.currentTime(0),this.play()):this.paused()||this.pause(),this.trigger("ended")}handleTechDurationChange_(){this.duration(this.techGet_("duration"))}handleTechClick_(t){this.controls_&&(void 0!==this.options_&&void 0!==this.options_.userActions&&void 0!==this.options_.userActions.click&&!1===this.options_.userActions.click||(void 0!==this.options_&&void 0!==this.options_.userActions&&"function"==typeof this.options_.userActions.click?this.options_.userActions.click.call(this,t):this.paused()?Le(this.play()):this.pause()))}handleTechDoubleClick_(t){this.controls_&&(Array.prototype.some.call(this.$$(".vjs-control-bar, .vjs-modal-dialog"),e=>e.contains(t.target))||void 0!==this.options_&&void 0!==this.options_.userActions&&void 0!==this.options_.userActions.doubleClick&&!1===this.options_.userActions.doubleClick||(void 0!==this.options_&&void 0!==this.options_.userActions&&"function"==typeof this.options_.userActions.doubleClick?this.options_.userActions.doubleClick.call(this,t):this.isInPictureInPicture()&&!document.pictureInPictureElement?this.exitPictureInPicture():this.isFullscreen()?this.exitFullscreen():this.requestFullscreen()))}handleTechTap_(){this.userActive(!this.userActive())}handleTechTouchStart_(){this.userWasActive=this.userActive()}handleTechTouchMove_(){this.userWasActive&&this.reportUserActivity()}handleTechTouchEnd_(t){t.cancelable&&t.preventDefault()}toggleFullscreenClass_(){this.isFullscreen()?this.addClass("vjs-fullscreen"):this.removeClass("vjs-fullscreen")}documentFullscreenChange_(t){const e=t.target.player;if(e&&e!==this)return;const s=this.el();let i=document[this.fsApi_.fullscreenElement]===s;!i&&s.matches&&(i=s.matches(":"+this.fsApi_.fullscreen)),this.isFullscreen(i)}handleTechFullscreenChange_(t,e){e&&(e.nativeIOSFullscreen&&(this.addClass("vjs-ios-native-fs"),this.tech_.one("webkitendfullscreen",()=>{this.removeClass("vjs-ios-native-fs")})),this.isFullscreen(e.isFullscreen))}handleTechFullscreenError_(t,e){this.trigger("fullscreenerror",e)}togglePictureInPictureClass_(){this.isInPictureInPicture()?this.addClass("vjs-picture-in-picture"):this.removeClass("vjs-picture-in-picture")}handleTechEnterPictureInPicture_(t){this.isInPictureInPicture(!0)}handleTechLeavePictureInPicture_(t){this.isInPictureInPicture(!1)}handleTechError_(){const t=this.tech_.error();t&&this.error(t)}handleTechTextData_(){let t=null;arguments.length>1&&(t=arguments[1]),this.trigger("textdata",t)}getCache(){return this.cache_}resetCache_(){this.cache_={currentTime:0,initTime:0,inactivityTimeout:this.options_.inactivityTimeout,duration:NaN,lastVolume:1,lastPlaybackRate:this.defaultPlaybackRate(),media:null,src:"",source:{},sources:[],playbackRates:[],volume:1}}techCall_(t,e){this.ready(function(){if(t in ui)return function(t,e,s,i){return e[s](t.reduce(fi(s),i))}(this.middleware_,this.tech_,t,e);if(t in pi)return ci(this.middleware_,this.tech_,t,e);try{this.tech_&&this.tech_[t](e)}catch(t){throw c(t),t}},!0)}techGet_(t){if(this.tech_&&this.tech_.isReady_){if(t in di)return function(t,e,s){return t.reduceRight(fi(s),e[s]())}(this.middleware_,this.tech_,t);if(t in pi)return ci(this.middleware_,this.tech_,t);try{return this.tech_[t]()}catch(e){if(void 0===this.tech_[t])throw c(`Video.js: ${t} method not defined for ${this.techName_} playback technology.`,e),e;if("TypeError"===e.name)throw c(`Video.js: ${t} unavailable on ${this.techName_} playback technology element.`,e),this.tech_.isReady_=!1,e;throw c(e),e}}}play(){return new Promise(t=>{this.play_(t)})}play_(t=Le){this.playCallbacks_.push(t);const e=Boolean(!this.changingSrc_&&(this.src()||this.currentSrc())),s=Boolean(G||V);if(this.waitToPlay_&&(this.off(["ready","loadstart"],this.waitToPlay_),this.waitToPlay_=null),!this.isReady_||!e)return this.waitToPlay_=t=>{this.play_()},this.one(["ready","loadstart"],this.waitToPlay_),void(!e&&s&&this.load());const i=this.techGet_("play");s&&this.hasClass("vjs-ended")&&this.resetProgressBar_(),null===i?this.runPlayTerminatedQueue_():this.runPlayCallbacks_(i)}runPlayTerminatedQueue_(){const t=this.playTerminatedQueue_.slice(0);this.playTerminatedQueue_=[],t.forEach(function(t){t()})}runPlayCallbacks_(t){const e=this.playCallbacks_.slice(0);this.playCallbacks_=[],this.playTerminatedQueue_=[],e.forEach(function(e){e(t)})}pause(){this.techCall_("pause")}paused(){return!1!==this.techGet_("paused")}played(){return this.techGet_("played")||ve(0,0)}scrubbing(t){if(void 0===t)return this.scrubbing_;this.scrubbing_=!!t,this.techCall_("setScrubbing",this.scrubbing_),t?this.addClass("vjs-scrubbing"):this.removeClass("vjs-scrubbing")}currentTime(t){return void 0===t?(this.cache_.currentTime=this.techGet_("currentTime")||0,this.cache_.currentTime):(t<0&&(t=0),this.isReady_&&!this.changingSrc_&&this.tech_&&this.tech_.isReady_?(this.techCall_("setCurrentTime",t),this.cache_.initTime=0,void(isFinite(t)&&(this.cache_.currentTime=Number(t)))):(this.cache_.initTime=t,this.off("canplay",this.boundApplyInitTime_),void this.one("canplay",this.boundApplyInitTime_)))}applyInitTime_(){this.currentTime(this.cache_.initTime)}duration(t){if(void 0===t)return void 0!==this.cache_.duration?this.cache_.duration:NaN;(t=parseFloat(t))<0&&(t=1/0),t!==this.cache_.duration&&(this.cache_.duration=t,t===1/0?this.addClass("vjs-live"):this.removeClass("vjs-live"),isNaN(t)||this.trigger("durationchange"))}remainingTime(){return this.duration()-this.currentTime()}remainingTimeDisplay(){return Math.floor(this.duration())-Math.floor(this.currentTime())}buffered(){let t=this.techGet_("buffered");return t&&t.length||(t=ve(0,0)),t}seekable(){let t=this.techGet_("seekable");return t&&t.length||(t=ve(0,0)),t}seeking(){return this.techGet_("seeking")}ended(){return this.techGet_("ended")}networkState(){return this.techGet_("networkState")}readyState(){return this.techGet_("readyState")}bufferedPercent(){return Ce(this.buffered(),this.duration())}bufferedEnd(){const t=this.buffered(),e=this.duration();let s=t.end(t.length-1);return s>e&&(s=e),s}volume(t){let e;return void 0!==t?(e=Math.max(0,Math.min(1,t)),this.cache_.volume=e,this.techCall_("setVolume",e),void(e>0&&this.lastVolume_(e))):(e=parseFloat(this.techGet_("volume")),isNaN(e)?1:e)}muted(t){if(void 0===t)return this.techGet_("muted")||!1;this.techCall_("setMuted",t)}defaultMuted(t){return void 0!==t&&this.techCall_("setDefaultMuted",t),this.techGet_("defaultMuted")||!1}lastVolume_(t){if(void 0===t||0===t)return this.cache_.lastVolume;this.cache_.lastVolume=t}supportsFullScreen(){return this.techGet_("supportsFullScreen")||!1}isFullscreen(t){if(void 0!==t){const e=this.isFullscreen_;return this.isFullscreen_=Boolean(t),this.isFullscreen_!==e&&this.fsApi_.prefixed&&this.trigger("fullscreenchange"),void this.toggleFullscreenClass_()}return this.isFullscreen_}requestFullscreen(t){this.isInPictureInPicture()&&this.exitPictureInPicture();const e=this;return new Promise((s,i)=>{function r(){e.off("fullscreenerror",a),e.off("fullscreenchange",n)}function n(){r(),s()}function a(t,e){r(),i(e)}e.one("fullscreenchange",n),e.one("fullscreenerror",a);const o=e.requestFullscreenHelper_(t);o&&(o.then(r,r),o.then(s,i))})}requestFullscreenHelper_(t){let e;if(this.fsApi_.prefixed||(e=this.options_.fullscreen&&this.options_.fullscreen.options||{},void 0!==t&&(e=t)),this.fsApi_.requestFullscreen){const t=this.el_[this.fsApi_.requestFullscreen](e);return t&&t.then(()=>this.isFullscreen(!0),()=>this.isFullscreen(!1)),t}this.tech_.supportsFullScreen()&&1==!this.options_.preferFullWindow?this.techCall_("enterFullScreen"):this.enterFullWindow()}exitFullscreen(){const t=this;return new Promise((e,s)=>{function i(){t.off("fullscreenerror",n),t.off("fullscreenchange",r)}function r(){i(),e()}function n(t,e){i(),s(e)}t.one("fullscreenchange",r),t.one("fullscreenerror",n);const a=t.exitFullscreenHelper_();a&&(a.then(i,i),a.then(e,s))})}exitFullscreenHelper_(){if(this.fsApi_.requestFullscreen){const t=document[this.fsApi_.exitFullscreen]();return t&&Le(t.then(()=>this.isFullscreen(!1))),t}this.tech_.supportsFullScreen()&&1==!this.options_.preferFullWindow?this.techCall_("exitFullScreen"):this.exitFullWindow()}enterFullWindow(){this.isFullscreen(!0),this.isFullWindow=!0,this.docOrigOverflow=document.documentElement.style.overflow,$t(document,"keydown",this.boundFullWindowOnEscKey_),document.documentElement.style.overflow="hidden",et(document.body,"vjs-full-window"),this.trigger("enterFullWindow")}fullWindowOnEscKey(t){"Escape"===t.key&&!0===this.isFullscreen()&&(this.isFullWindow?this.exitFullWindow():this.exitFullscreen())}exitFullWindow(){this.isFullscreen(!1),this.isFullWindow=!1,Ut(document,"keydown",this.boundFullWindowOnEscKey_),document.documentElement.style.overflow=this.docOrigOverflow,st(document.body,"vjs-full-window"),this.trigger("exitFullWindow")}disablePictureInPicture(t){if(void 0===t)return this.techGet_("disablePictureInPicture");this.techCall_("setDisablePictureInPicture",t),this.options_.disablePictureInPicture=t,this.trigger("disablepictureinpicturechanged")}isInPictureInPicture(t){return void 0!==t?(this.isInPictureInPicture_=!!t,void this.togglePictureInPictureClass_()):!!this.isInPictureInPicture_}requestPictureInPicture(){if(this.options_.enableDocumentPictureInPicture&&window.documentPictureInPicture){const t=document.createElement(this.el().tagName);return t.classList=this.el().classList,t.classList.add("vjs-pip-container"),this.posterImage&&t.appendChild(this.posterImage.el().cloneNode(!0)),this.titleBar&&t.appendChild(this.titleBar.el().cloneNode(!0)),t.appendChild(Q("p",{className:"vjs-pip-text"},{},this.localize("Playing in picture-in-picture"))),window.documentPictureInPicture.requestWindow({width:this.videoWidth(),height:this.videoHeight()}).then(e=>(Et(e),this.el_.parentNode.insertBefore(t,this.el_),e.document.body.appendChild(this.el_),e.document.body.classList.add("vjs-pip-window"),this.player_.isInPictureInPicture(!0),this.player_.trigger({type:"enterpictureinpicture",pipWindow:e}),e.addEventListener("pagehide",e=>{const s=e.target.querySelector(".video-js");t.parentNode.replaceChild(s,t),this.player_.isInPictureInPicture(!1),this.player_.trigger("leavepictureinpicture")}),e))}return"pictureInPictureEnabled"in document&&!1===this.disablePictureInPicture()?this.techGet_("requestPictureInPicture"):Promise.reject("No PiP mode is available")}exitPictureInPicture(){return window.documentPictureInPicture&&window.documentPictureInPicture.window?(window.documentPictureInPicture.window.close(),Promise.resolve()):"pictureInPictureEnabled"in document?document.exitPictureInPicture():void 0}handleKeyDown(t){const{userActions:e}=this.options_;e&&e.hotkeys&&((t=>{const e=t.tagName.toLowerCase();return!!t.isContentEditable||("input"===e?-1===["button","checkbox","hidden","radio","reset","submit"].indexOf(t.type):-1!==["textarea"].indexOf(e))})(this.el_.ownerDocument.activeElement)||("function"==typeof e.hotkeys?e.hotkeys.call(this,t):this.handleHotkeys(t)))}handleHotkeys(t){const e=this.options_.userActions?this.options_.userActions.hotkeys:{},{fullscreenKey:s=e=>"f"===t.key.toLowerCase(),muteKey:i=e=>"m"===t.key.toLowerCase(),playPauseKey:r=e=>"k"===t.key.toLowerCase()||" "===t.key.toLowerCase()}=e;if(s.call(this,t)){t.preventDefault(),t.stopPropagation();const e=ge.getComponent("FullscreenToggle");!1!==document[this.fsApi_.fullscreenEnabled]&&e.prototype.handleClick.call(this,t)}else i.call(this,t)?(t.preventDefault(),t.stopPropagation(),ge.getComponent("MuteToggle").prototype.handleClick.call(this,t)):r.call(this,t)&&(t.preventDefault(),t.stopPropagation(),ge.getComponent("PlayToggle").prototype.handleClick.call(this,t))}canPlayType(t){let e;for(let s=0,i=this.options_.techOrder;s<i.length;s++){const r=i[s];let n=ni.getTech(r);if(n||(n=ge.getComponent(r)),n){if(n.isSupported()&&(e=n.canPlayType(t),e))return e}else c.error(`The "${r}" tech is undefined. Skipped browser support check for that tech.`)}return""}selectSource(t){const e=this.options_.techOrder.map(t=>[t,ni.getTech(t)]).filter(([t,e])=>e?e.isSupported():(c.error(`The "${t}" tech is undefined. Skipped browser support check for that tech.`),!1)),s=function(t,e,s){let i;return t.some(t=>e.some(e=>{if(i=s(t,e),i)return!0})),i};let i;const r=([t,e],s)=>{if(e.canPlaySource(s,this.options_[t.toLowerCase()]))return{source:s,tech:t}};return i=this.options_.sourceOrder?s(t,e,(n=r,(t,e)=>n(e,t))):s(e,t,r),i||!1;var n}handleSrc_(t,e){if(void 0===t)return this.cache_.src||"";this.resetRetryOnError_&&this.resetRetryOnError_();const s=vi(t);if(s.length){if(this.changingSrc_=!0,e||(this.cache_.sources=s),this.updateSourceCaches_(s[0]),hi(this,s[0],(t,i)=>{if(this.middleware_=i,e||(this.cache_.sources=s),this.updateSourceCaches_(t),this.src_(t))return s.length>1?this.handleSrc_(s.slice(1)):(this.changingSrc_=!1,this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0),void this.triggerReady());var r,n;r=i,n=this.tech_,r.forEach(t=>t.setTech&&t.setTech(n))}),s.length>1){const t=()=>{this.error(null),this.handleSrc_(s.slice(1),!0)},e=()=>{this.off("error",t)};this.one("error",t),this.one("playing",e),this.resetRetryOnError_=()=>{this.off("error",t),this.off("playing",e)}}}else this.setTimeout(function(){this.error({code:4,message:this.options_.notSupportedMessage})},0)}src(t){return this.handleSrc_(t,!1)}src_(t){const e=this.selectSource([t]);return!e||(pe(e.tech,this.techName_)?(this.ready(function(){this.tech_.constructor.prototype.hasOwnProperty("setSource")?this.techCall_("setSource",t):this.techCall_("src",t.src),this.changingSrc_=!1},!0),!1):(this.changingSrc_=!0,this.loadTech_(e.tech,e.source),this.tech_.ready(()=>{this.changingSrc_=!1}),!1))}addSourceElement(t,e){return!!this.tech_&&this.tech_.addSourceElement(t,e)}removeSourceElement(t){return!!this.tech_&&this.tech_.removeSourceElement(t)}load(){this.tech_&&this.tech_.vhs?this.src(this.currentSource()):this.techCall_("load")}reset(){this.paused()?this.doReset_():Le(this.play().then(()=>this.doReset_()))}doReset_(){this.tech_&&this.tech_.clearTracks("text"),this.removeClass("vjs-playing"),this.addClass("vjs-paused"),this.resetCache_(),this.poster(""),this.loadTech_(this.options_.techOrder[0],null),this.techCall_("reset"),this.resetControlBarUI_(),this.error(null),this.titleBar&&this.titleBar.update({title:void 0,description:void 0}),te(this)&&this.trigger("playerreset")}resetControlBarUI_(){this.resetProgressBar_(),this.resetPlaybackRate_(),this.resetVolumeBar_()}resetProgressBar_(){this.currentTime(0);const{currentTimeDisplay:t,durationDisplay:e,progressControl:s,remainingTimeDisplay:i}=this.controlBar||{},{seekBar:r}=s||{};t&&t.updateContent(),e&&e.updateContent(),i&&i.updateContent(),r&&(r.update(),r.loadProgressBar&&r.loadProgressBar.update())}resetPlaybackRate_(){this.playbackRate(this.defaultPlaybackRate()),this.handleTechRateChange_()}resetVolumeBar_(){this.volume(1),this.trigger("volumechange")}currentSources(){const t=this.currentSource(),e=[];return 0!==Object.keys(t).length&&e.push(t),this.cache_.sources||e}currentSource(){return this.cache_.source||{}}currentSrc(){return this.currentSource()&&this.currentSource().src||""}currentType(){return this.currentSource()&&this.currentSource().type||""}preload(t){return void 0!==t?(this.techCall_("setPreload",t),void(this.options_.preload=t)):this.techGet_("preload")}autoplay(t){if(void 0===t)return this.options_.autoplay||!1;let e;"string"==typeof t&&/(any|play|muted)/.test(t)||!0===t&&this.options_.normalizeAutoplay?(this.options_.autoplay=t,this.manualAutoplay_("string"==typeof t?t:"play"),e=!1):this.options_.autoplay=!!t,e=void 0===e?this.options_.autoplay:e,this.tech_&&this.techCall_("setAutoplay",e)}playsinline(t){return void 0!==t&&(this.techCall_("setPlaysinline",t),this.options_.playsinline=t),this.techGet_("playsinline")}loop(t){return void 0!==t?(this.techCall_("setLoop",t),void(this.options_.loop=t)):this.techGet_("loop")}poster(t){if(void 0===t)return this.poster_;t||(t=""),t!==this.poster_&&(this.poster_=t,this.techCall_("setPoster",t),this.isPosterFromTech_=!1,this.trigger("posterchange"))}handleTechPosterChange_(){if((!this.poster_||this.options_.techCanOverridePoster)&&this.tech_&&this.tech_.poster){const t=this.tech_.poster()||"";t!==this.poster_&&(this.poster_=t,this.isPosterFromTech_=!0,this.trigger("posterchange"))}}controls(t){if(void 0===t)return!!this.controls_;t=!!t,this.controls_!==t&&(this.controls_=t,this.usingNativeControls()&&this.techCall_("setControls",t),this.controls_?(this.removeClass("vjs-controls-disabled"),this.addClass("vjs-controls-enabled"),this.trigger("controlsenabled"),this.usingNativeControls()||this.addTechControlsListeners_()):(this.removeClass("vjs-controls-enabled"),this.addClass("vjs-controls-disabled"),this.trigger("controlsdisabled"),this.usingNativeControls()||this.removeTechControlsListeners_()))}usingNativeControls(t){if(void 0===t)return!!this.usingNativeControls_;t=!!t,this.usingNativeControls_!==t&&(this.usingNativeControls_=t,this.usingNativeControls_?(this.addClass("vjs-using-native-controls"),this.trigger("usingnativecontrols")):(this.removeClass("vjs-using-native-controls"),this.trigger("usingcustomcontrols")))}error(t){if(void 0===t)return this.error_||null;if(i("beforeerror").forEach(e=>{const s=e(this,t);m(s)&&!Array.isArray(s)||"string"==typeof s||"number"==typeof s||null===s?t=s:this.log.error("please return a value that MediaError expects in beforeerror hooks")}),this.options_.suppressNotSupportedError&&t&&4===t.code){const e=function(){this.error(t)};return this.options_.suppressNotSupportedError=!1,this.any(["click","touchstart"],e),void this.one("loadstart",function(){this.off(["click","touchstart"],e)})}if(null===t)return this.error_=null,this.removeClass("vjs-error"),void(this.errorDisplay&&this.errorDisplay.close());this.error_=new ke(t),this.addClass("vjs-error"),c.error(`(CODE:${this.error_.code} ${ke.errorTypes[this.error_.code]})`,this.error_.message,this.error_),this.trigger("error"),i("error").forEach(t=>t(this,this.error_))}reportUserActivity(t){this.userActivity_=!0}userActive(t){if(void 0===t)return this.userActive_;if((t=!!t)!==this.userActive_){if(this.userActive_=t,this.userActive_)return this.userActivity_=!0,this.removeClass("vjs-user-inactive"),this.addClass("vjs-user-active"),void this.trigger("useractive");this.tech_&&this.tech_.one("mousemove",function(t){t.stopPropagation(),t.preventDefault()}),this.userActivity_=!1,this.removeClass("vjs-user-active"),this.addClass("vjs-user-inactive"),this.trigger("userinactive")}}listenForUserActivity_(){let t,e,s;const i=zt(this,this.reportUserActivity),r=function(e){i(),this.clearInterval(t)};this.on("mousedown",function(){i(),this.clearInterval(t),t=this.setInterval(i,250)}),this.on("mousemove",function(t){t.screenX===e&&t.screenY===s||(e=t.screenX,s=t.screenY,i())}),this.on("mouseup",r),this.on("mouseleave",r);const n=this.getChild("controlBar");let a;!n||V||C||(n.on("mouseenter",function(t){0!==this.player().options_.inactivityTimeout&&(this.player().cache_.inactivityTimeout=this.player().options_.inactivityTimeout),this.player().options_.inactivityTimeout=0}),n.on("mouseleave",function(t){this.player().options_.inactivityTimeout=this.player().cache_.inactivityTimeout})),this.on("keydown",i),this.on("keyup",i);this.setInterval(function(){if(!this.userActivity_)return;this.userActivity_=!1,this.userActive(!0),this.clearTimeout(a);const t=this.options_.inactivityTimeout;t<=0||(a=this.setTimeout(function(){this.userActivity_||this.userActive(!1)},t))},250)}playbackRate(t){if(void 0===t)return this.tech_&&this.tech_.featuresPlaybackRate?this.cache_.lastPlaybackRate||this.techGet_("playbackRate"):1;this.techCall_("setPlaybackRate",t)}defaultPlaybackRate(t){return void 0!==t?this.techCall_("setDefaultPlaybackRate",t):this.tech_&&this.tech_.featuresPlaybackRate?this.techGet_("defaultPlaybackRate"):1}isAudio(t){if(void 0===t)return!!this.isAudio_;this.isAudio_=!!t}updatePlayerHeightOnAudioOnlyMode_(){const t=this.getChild("ControlBar");t&&this.audioOnlyCache_.controlBarHeight!==t.currentHeight()&&(this.audioOnlyCache_.controlBarHeight=t.currentHeight(),this.height(this.audioOnlyCache_.controlBarHeight))}enableAudioOnlyUI_(){this.addClass("vjs-audio-only-mode");const t=this.children(),e=this.getChild("ControlBar"),s=e&&e.currentHeight();t.forEach(t=>{t!==e&&t.el_&&!t.hasClass("vjs-hidden")&&(t.hide(),this.audioOnlyCache_.hiddenChildren.push(t))}),this.audioOnlyCache_.playerHeight=this.currentHeight(),this.audioOnlyCache_.controlBarHeight=s,this.on("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.height(s),this.trigger("audioonlymodechange")}disableAudioOnlyUI_(){this.removeClass("vjs-audio-only-mode"),this.off("playerresize",this.boundUpdatePlayerHeightOnAudioOnlyMode_),this.audioOnlyCache_.hiddenChildren.forEach(t=>t.show()),this.height(this.audioOnlyCache_.playerHeight),this.trigger("audioonlymodechange")}audioOnlyMode(t){if("boolean"!=typeof t||t===this.audioOnlyMode_)return this.audioOnlyMode_;if(this.audioOnlyMode_=t,t){const t=[];return this.isInPictureInPicture()&&t.push(this.exitPictureInPicture()),this.isFullscreen()&&t.push(this.exitFullscreen()),this.audioPosterMode()&&t.push(this.audioPosterMode(!1)),Promise.all(t).then(()=>this.enableAudioOnlyUI_())}return Promise.resolve().then(()=>this.disableAudioOnlyUI_())}enablePosterModeUI_(){(this.tech_&&this.tech_).hide(),this.addClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}disablePosterModeUI_(){(this.tech_&&this.tech_).show(),this.removeClass("vjs-audio-poster-mode"),this.trigger("audiopostermodechange")}audioPosterMode(t){return"boolean"!=typeof t||t===this.audioPosterMode_?this.audioPosterMode_:(this.audioPosterMode_=t,t?this.audioOnlyMode()?this.audioOnlyMode(!1).then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.enablePosterModeUI_()}):Promise.resolve().then(()=>{this.disablePosterModeUI_()}))}addTextTrack(t,e,s){if(this.tech_)return this.tech_.addTextTrack(t,e,s)}addRemoteTextTrack(t,e){if(this.tech_)return this.tech_.addRemoteTextTrack(t,e)}removeRemoteTextTrack(t={}){let{track:e}=t;if(e||(e=t),this.tech_)return this.tech_.removeRemoteTextTrack(e)}getVideoPlaybackQuality(){return this.techGet_("getVideoPlaybackQuality")}videoWidth(){return this.tech_&&this.tech_.videoWidth&&this.tech_.videoWidth()||0}videoHeight(){return this.tech_&&this.tech_.videoHeight&&this.tech_.videoHeight()||0}language(t){if(void 0===t)return this.language_;this.language_!==String(t).toLowerCase()&&(this.language_=String(t).toLowerCase(),te(this)&&this.trigger("languagechange"))}languages(){return v(rn.prototype.options_.languages,this.languages_)}toJSON(){const t=v(this.options_),e=t.tracks;t.tracks=[];for(let s=0;s<e.length;s++){let i=e[s];i=v(i),i.player=void 0,t.tracks[s]=i}return t}createModal(t,e){(e=e||{}).content=t||"";const s=new Oe(this,e);return this.addChild(s),s.on("dispose",()=>{this.removeChild(s)}),s.open(),s}updateCurrentBreakpoint_(){if(!this.responsive())return;const t=this.currentBreakpoint(),e=this.currentWidth();for(let s=0;s<tn.length;s++){const i=tn[s];if(e<=this.breakpoints_[i]){if(t===i)return;t&&this.removeClass(en[t]),this.addClass(en[i]),this.breakpoint_=i;break}}}removeCurrentBreakpoint_(){const t=this.currentBreakpointClass();this.breakpoint_="",t&&this.removeClass(t)}breakpoints(t){return void 0===t||(this.breakpoint_="",this.breakpoints_=Object.assign({},sn,t),this.updateCurrentBreakpoint_()),Object.assign(this.breakpoints_)}responsive(t){return void 0===t?this.responsive_:(t=Boolean(t))!==this.responsive_?(this.responsive_=t,t?(this.on("playerresize",this.boundUpdateCurrentBreakpoint_),this.updateCurrentBreakpoint_()):(this.off("playerresize",this.boundUpdateCurrentBreakpoint_),this.removeCurrentBreakpoint_()),t):void 0}currentBreakpoint(){return this.breakpoint_}currentBreakpointClass(){return en[this.breakpoint_]||""}loadMedia(t,e){if(!t||"object"!=typeof t)return;const s=this.crossOrigin();this.reset(),this.cache_.media=v(t);const{artist:i,artwork:r,description:n,poster:a,src:o,textTracks:l,title:h}=this.cache_.media;!r&&a&&(this.cache_.media.artwork=[{src:a,type:yi(a)}]),s&&this.crossOrigin(s),o&&this.src(o),a&&this.poster(a),Array.isArray(l)&&l.forEach(t=>this.addRemoteTextTrack(t,!1)),this.titleBar&&this.titleBar.update({title:h,description:n||i||""}),this.ready(e)}getMedia(){if(!this.cache_.media){const t=this.poster(),e={src:this.currentSources(),textTracks:Array.prototype.map.call(this.remoteTextTracks(),t=>({kind:t.kind,label:t.label,language:t.language,src:t.src}))};return t&&(e.poster=t,e.artwork=[{src:e.poster,type:yi(e.poster)}]),e}return v(this.cache_.media)}static getTagSettings(t){const e={sources:[],tracks:[]},s=nt(t),i=s["data-setup"];if(tt(t,"vjs-fill")&&(s.fill=!0),tt(t,"vjs-fluid")&&(s.fluid=!0),null!==i)try{Object.assign(s,JSON.parse(i||"{}"))}catch(t){c.error("data-setup",t)}if(Object.assign(e,s),t.hasChildNodes()){const s=t.childNodes;for(let t=0,i=s.length;t<i;t++){const i=s[t],r=i.nodeName.toLowerCase();"source"===r?e.sources.push(nt(i)):"track"===r&&e.tracks.push(nt(i))}}return e}debug(t){if(void 0===t)return this.debugEnabled_;t?(this.trigger("debugon"),this.previousLogLevel_=this.log.level,this.log.level("debug"),this.debugEnabled_=!0):(this.trigger("debugoff"),this.log.level(this.previousLogLevel_),this.previousLogLevel_=void 0,this.debugEnabled_=!1)}playbackRates(t){if(void 0===t)return this.cache_.playbackRates;Array.isArray(t)&&t.every(t=>"number"==typeof t)&&(this.cache_.playbackRates=t,this.trigger("playbackrateschange"))}}rn.prototype.videoTracks=()=>{},rn.prototype.audioTracks=()=>{},rn.prototype.textTracks=()=>{},rn.prototype.remoteTextTracks=()=>{},rn.prototype.remoteTextTrackEls=()=>{},Cs.names.forEach(function(t){const e=Cs[t];rn.prototype[e.getterName]=function(){return this.tech_?this.tech_[e.getterName]():(this[e.privateName]=this[e.privateName]||new e.ListClass,this[e.privateName])}}),rn.prototype.crossorigin=rn.prototype.crossOrigin,rn.players={};const nn=window.navigator;rn.prototype.options_={techOrder:ni.defaultTechOrder_,html5:{},enableSourceset:!0,inactivityTimeout:2e3,playbackRates:[],liveui:!1,children:["mediaLoader","posterImage","titleBar","textTrackDisplay","loadingSpinner","bigPlayButton","liveTracker","controlBar","errorDisplay","textTrackSettings","resizeManager"],language:nn&&(nn.languages&&nn.languages[0]||nn.userLanguage||nn.language)||"en",languages:{},notSupportedMessage:"No compatible source was found for this media.",normalizeAutoplay:!1,fullscreen:{options:{navigationUI:"hide"}},breakpoints:{},responsive:!1,audioOnlyMode:!1,audioPosterMode:!1,spatialNavigation:{enabled:!1,horizontalSeek:!1},enableSmoothSeeking:!1,disableSeekWhileScrubbingOnMobile:!1,disableSeekWhileScrubbingOnSTV:!1},Zr.forEach(function(t){rn.prototype[`handleTech${ue(t)}_`]=function(){return this.trigger(t)}}),ge.registerComponent("Player",rn);const an="plugin",on="activePlugins_",ln={},hn=t=>ln.hasOwnProperty(t),cn=t=>hn(t)?ln[t]:void 0,dn=(t,e)=>{t[on]=t[on]||{},t[on][e]=!0},un=(t,e,s)=>{const i=(s?"before":"")+"pluginsetup";t.trigger(i,e),t.trigger(i+":"+e.name,e)},pn=(t,e)=>(e.prototype.name=t,function(...s){un(this,{name:t,plugin:e,instance:null},!0);const i=new e(...[this,...s]);return this[t]=()=>i,un(this,i.getEventHash()),i});class fn{constructor(t){if(this.constructor===fn)throw new Error("Plugin must be sub-classed; not directly instantiated.");this.player=t,this.log||(this.log=this.player.log.createLogger(this.name)),le(this),delete this.trigger,ce(this,this.constructor.defaultState),dn(t,this.name),this.dispose=this.dispose.bind(this),t.on("dispose",this.dispose)}version(){return this.constructor.VERSION}getEventHash(t={}){return t.name=this.name,t.plugin=this.constructor,t.instance=this,t}trigger(t,e={}){return Ht(this.eventBusEl_,t,this.getEventHash(e))}handleStateChanged(t){}dispose(){const{name:t,player:e}=this;this.trigger("dispose"),this.off(),e.off("dispose",this.dispose),e[on][t]=!1,this.player=this.state=null,e[t]=pn(t,ln[t])}static isBasic(t){const e="string"==typeof t?cn(t):t;return"function"==typeof e&&!fn.prototype.isPrototypeOf(e.prototype)}static registerPlugin(t,e){if("string"!=typeof t)throw new Error(`Illegal plugin name, "${t}", must be a string, was ${typeof t}.`);if(hn(t))c.warn(`A plugin named "${t}" already exists. You may want to avoid re-registering plugins!`);else if(rn.prototype.hasOwnProperty(t))throw new Error(`Illegal plugin name, "${t}", cannot share a name with an existing player method!`);if("function"!=typeof e)throw new Error(`Illegal plugin for "${t}", must be a function, was ${typeof e}.`);return ln[t]=e,t!==an&&(fn.isBasic(e)?rn.prototype[t]=function(t,e){const s=function(){un(this,{name:t,plugin:e,instance:null},!0);const s=e.apply(this,arguments);return dn(this,t),un(this,{name:t,plugin:e,instance:s}),s};return Object.keys(e).forEach(function(t){s[t]=e[t]}),s}(t,e):rn.prototype[t]=pn(t,e)),e}static deregisterPlugin(t){if(t===an)throw new Error("Cannot de-register base plugin.");hn(t)&&(delete ln[t],delete rn.prototype[t])}static getPlugins(t=Object.keys(ln)){let e;return t.forEach(t=>{const s=cn(t);s&&(e=e||{},e[t]=s)}),e}static getPluginVersion(t){const e=cn(t);return e&&e.VERSION||""}}function gn(t,e,s,i){return function(t,e){let s=!1;return function(...i){return s||c.warn(t),s=!0,e.apply(this,i)}}(`${e} is deprecated and will be removed in ${t}.0; please use ${s} instead.`,i)}fn.getPlugin=cn,fn.BASE_PLUGIN_NAME=an,fn.registerPlugin(an,fn),rn.prototype.usingPlugin=function(t){return!!this[on]&&!0===this[on][t]},rn.prototype.hasPlugin=function(t){return!!hn(t)};const mn=t=>0===t.indexOf("#")?t.slice(1):t;function yn(t,e,s){let r=yn.getPlayer(t);if(r)return e&&c.warn(`Player "${t}" is already initialised. Options will not be applied.`),s&&r.ready(s),r;const n="string"==typeof t?_t("#"+mn(t)):t;if(!q(n))throw new TypeError("The element or ID supplied is not valid. (videojs)");const a="getRootNode"in n&&n.getRootNode()instanceof window.ShadowRoot?n.getRootNode():n.ownerDocument.body;n.ownerDocument.defaultView&&a.contains(n)||c.warn("The element supplied is not included in the DOM"),!0===(e=e||{}).restoreEl&&(e.restoreEl=(n.parentNode&&n.parentNode.hasAttribute&&n.parentNode.hasAttribute("data-vjs-player")?n.parentNode:n).cloneNode(!0)),i("beforesetup").forEach(t=>{const s=t(n,v(e));m(s)&&!Array.isArray(s)?e=v(e,s):c.error("please return an object in beforesetup hooks")});const o=ge.getComponent("Player");return r=new o(n,e,s),i("setup").forEach(t=>t(r)),r}if(yn.hooks_=e,yn.hooks=i,yn.hook=function(t,e){i(t,e)},yn.hookOnce=function(t,e){i(t,[].concat(e).map(e=>{const s=(...i)=>(r(t,s),e(...i));return s}))},yn.removeHook=r,!0!==window.VIDEOJS_NO_DYNAMIC_STYLE&&z()){let t=_t(".vjs-styles-defaults");if(!t){t=Pt("vjs-styles-defaults");const e=_t("head");e&&e.insertBefore(t,e.firstChild),xt(t,"\n .video-js {\n width: 300px;\n height: 150px;\n }\n\n .vjs-fluid:not(.vjs-audio-only-mode) {\n padding-top: 56.25%\n }\n ")}}return Lt(1,yn),yn.VERSION=t,yn.options=rn.prototype.options_,yn.getPlayers=()=>rn.players,yn.getPlayer=t=>{const e=rn.players;let s;if("string"==typeof t){const i=mn(t),r=e[i];if(r)return r;s=_t("#"+i)}else s=t;if(q(s)){const{player:t,playerId:i}=s;if(t||e[i])return t||e[i]}},yn.getAllPlayers=()=>Object.keys(rn.players).map(t=>rn.players[t]).filter(Boolean),yn.players=rn.players,yn.getComponent=ge.getComponent,yn.registerComponent=(t,e)=>(ni.isTech(e)&&c.warn(`The ${t} tech was registered as a component. It should instead be registered using videojs.registerTech(name, tech)`),ge.registerComponent.call(ge,t,e)),yn.getTech=ni.getTech,yn.registerTech=ni.registerTech,yn.use=function(t,e){ai[t]=ai[t]||[],ai[t].push(e)},Object.defineProperty(yn,"middleware",{value:{},writeable:!1,enumerable:!0}),Object.defineProperty(yn.middleware,"TERMINATOR",{value:li,writeable:!1,enumerable:!0}),yn.browser=W,yn.obj=T,yn.mergeOptions=gn(9,"videojs.mergeOptions","videojs.obj.merge",v),yn.defineLazyProperty=gn(9,"videojs.defineLazyProperty","videojs.obj.defineLazyProperty",_),yn.bind=gn(9,"videojs.bind","native Function.prototype.bind",zt),yn.registerPlugin=fn.registerPlugin,yn.deregisterPlugin=fn.deregisterPlugin,yn.plugin=(t,e)=>(c.warn("videojs.plugin() is deprecated; use videojs.registerPlugin() instead"),fn.registerPlugin(t,e)),yn.getPlugins=fn.getPlugins,yn.getPlugin=fn.getPlugin,yn.getPluginVersion=fn.getPluginVersion,yn.addLanguage=function(t,e){return t=(""+t).toLowerCase(),yn.options.languages=v(yn.options.languages,{[t]:e}),yn.options.languages[t]},yn.log=c,yn.createLogger=d,yn.time=Se,yn.createTimeRange=gn(9,"videojs.createTimeRange","videojs.time.createTimeRanges",ve),yn.createTimeRanges=gn(9,"videojs.createTimeRanges","videojs.time.createTimeRanges",ve),yn.formatTime=gn(9,"videojs.formatTime","videojs.time.formatTime",Ee),yn.setFormatTime=gn(9,"videojs.setFormatTime","videojs.time.setFormatTime",Te),yn.resetFormatTime=gn(9,"videojs.resetFormatTime","videojs.time.resetFormatTime",Ae),yn.parseUrl=gn(9,"videojs.parseUrl","videojs.url.parseUrl",ze),yn.isCrossOrigin=gn(9,"videojs.isCrossOrigin","videojs.url.isCrossOrigin",Xe),yn.EventTarget=Zt,yn.any=Gt,yn.on=$t,yn.one=Vt,yn.off=Ut,yn.trigger=Ht,yn.xhr=us,yn.TrackList=Me,yn.TextTrack=bs,yn.TextTrackList=$e,yn.AudioTrack=_s,yn.AudioTrackList=Ne,yn.VideoTrack=Ts,yn.VideoTrackList=je,["isEl","isTextNode","createEl","hasClass","addClass","removeClass","toggleClass","setAttributes","getAttributes","emptyEl","appendContent","insertContent"].forEach(t=>{yn[t]=function(){return c.warn(`videojs.${t}() is deprecated; use videojs.dom.${t}() instead`),St[t].apply(null,arguments)}}),yn.computedStyle=gn(9,"videojs.computedStyle","videojs.dom.computedStyle",At),yn.dom=St,yn.fn=Xt,yn.num=$i,yn.str=fe,yn.url=Qe,yn.Error={NetworkBadStatus:"networkbadstatus",NetworkRequestFailed:"networkrequestfailed",NetworkRequestAborted:"networkrequestaborted",NetworkRequestTimeout:"networkrequesttimeout",NetworkBodyParserFailed:"networkbodyparserfailed",StreamingHlsPlaylistParserError:"streaminghlsplaylistparsererror",StreamingDashManifestParserError:"streamingdashmanifestparsererror",StreamingContentSteeringParserError:"streamingcontentsteeringparsererror",StreamingVttParserError:"streamingvttparsererror",StreamingFailedToSelectNextSegment:"streamingfailedtoselectnextsegment",StreamingFailedToDecryptSegment:"streamingfailedtodecryptsegment",StreamingFailedToTransmuxSegment:"streamingfailedtotransmuxsegment",StreamingFailedToAppendSegment:"streamingfailedtoappendsegment",StreamingCodecsChangeError:"streamingcodecschangeerror"},yn}()},7884:function(t,e,s){t.exports=function(t){function e(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var s=e(t);class i{constructor(t){let e=this;return e.id=t.id,e.label=e.id,e.width=t.width,e.height=t.height,e.bitrate=t.bandwidth,e.frameRate=t.frameRate,e.enabled_=t.enabled,Object.defineProperty(e,"enabled",{get:()=>e.enabled_(),set(t){e.enabled_(t)}}),e}}class r extends s.default.EventTarget{constructor(){super();let t=this;return t.levels_=[],t.selectedIndex_=-1,Object.defineProperty(t,"selectedIndex",{get:()=>t.selectedIndex_}),Object.defineProperty(t,"length",{get:()=>t.levels_.length}),t[Symbol.iterator]=()=>t.levels_.values(),t}addQualityLevel(t){let e=this.getQualityLevelById(t.id);if(e)return e;const s=this.levels_.length;return e=new i(t),""+s in this||Object.defineProperty(this,s,{get(){return this.levels_[s]}}),this.levels_.push(e),this.trigger({qualityLevel:e,type:"addqualitylevel"}),e}removeQualityLevel(t){let e=null;for(let s=0,i=this.length;s<i;s++)if(this[s]===t){e=this.levels_.splice(s,1)[0],this.selectedIndex_===s?this.selectedIndex_=-1:this.selectedIndex_>s&&this.selectedIndex_--;break}return e&&this.trigger({qualityLevel:t,type:"removequalitylevel"}),e}getQualityLevelById(t){for(let e=0,s=this.length;e<s;e++){const s=this[e];if(s.id===t)return s}return null}dispose(){this.selectedIndex_=-1,this.levels_.length=0}}r.prototype.allowedEvents_={change:"change",addqualitylevel:"addqualitylevel",removequalitylevel:"removequalitylevel"};for(const t in r.prototype.allowedEvents_)r.prototype["on"+t]=null;var n="4.1.0";const a=function(t){return function(t){const e=t.qualityLevels,s=new r,i=function(){s.dispose(),t.qualityLevels=e,t.off("dispose",i)};return t.on("dispose",i),t.qualityLevels=()=>s,t.qualityLevels.VERSION=n,s}(this,s.default.obj.merge({},t))};return s.default.registerPlugin("qualityLevels",a),a.VERSION=n,a}(s(6673))},5303:(t,e,s)=>{var i;!function(){function r(t,e,s){return t.call.apply(t.bind,arguments)}function n(t,e,s){if(!t)throw Error();if(2<arguments.length){var i=Array.prototype.slice.call(arguments,2);return function(){var s=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(s,i),t.apply(e,s)}}return function(){return t.apply(e,arguments)}}function a(t,e,s){return(a=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?r:n).apply(null,arguments)}var o=Date.now||function(){return+new Date};function l(t,e){this.a=t,this.o=e||t,this.c=this.o.document}var h=!!window.FontFace;function c(t,e,s,i){if(e=t.c.createElement(e),s)for(var r in s)s.hasOwnProperty(r)&&("style"==r?e.style.cssText=s[r]:e.setAttribute(r,s[r]));return i&&e.appendChild(t.c.createTextNode(i)),e}function d(t,e,s){(t=t.c.getElementsByTagName(e)[0])||(t=document.documentElement),t.insertBefore(s,t.lastChild)}function u(t){t.parentNode&&t.parentNode.removeChild(t)}function p(t,e,s){e=e||[],s=s||[];for(var i=t.className.split(/\s+/),r=0;r<e.length;r+=1){for(var n=!1,a=0;a<i.length;a+=1)if(e[r]===i[a]){n=!0;break}n||i.push(e[r])}for(e=[],r=0;r<i.length;r+=1){for(n=!1,a=0;a<s.length;a+=1)if(i[r]===s[a]){n=!0;break}n||e.push(i[r])}t.className=e.join(" ").replace(/\s+/g," ").replace(/^\s+|\s+$/,"")}function f(t,e){for(var s=t.className.split(/\s+/),i=0,r=s.length;i<r;i++)if(s[i]==e)return!0;return!1}function g(t,e,s){function i(){o&&r&&n&&(o(a),o=null)}e=c(t,"link",{rel:"stylesheet",href:e,media:"all"});var r=!1,n=!0,a=null,o=s||null;h?(e.onload=function(){r=!0,i()},e.onerror=function(){r=!0,a=Error("Stylesheet failed to load"),i()}):setTimeout(function(){r=!0,i()},0),d(t,"head",e)}function m(t,e,s,i){var r=t.c.getElementsByTagName("head")[0];if(r){var n=c(t,"script",{src:e}),a=!1;return n.onload=n.onreadystatechange=function(){a||this.readyState&&"loaded"!=this.readyState&&"complete"!=this.readyState||(a=!0,s&&s(null),n.onload=n.onreadystatechange=null,"HEAD"==n.parentNode.tagName&&r.removeChild(n))},r.appendChild(n),setTimeout(function(){a||(a=!0,s&&s(Error("Script load timeout")))},i||5e3),n}return null}function y(){this.a=0,this.c=null}function v(t){return t.a++,function(){t.a--,_(t)}}function b(t,e){t.c=e,_(t)}function _(t){0==t.a&&t.c&&(t.c(),t.c=null)}function T(t){this.a=t||"-"}function A(t,e){this.c=t,this.f=4,this.a="n";var s=(e||"n4").match(/^([nio])([1-9])$/i);s&&(this.a=s[1],this.f=parseInt(s[2],10))}function E(t){var e=[];t=t.split(/,\s*/);for(var s=0;s<t.length;s++){var i=t[s].replace(/['"]/g,"");-1!=i.indexOf(" ")||/^\d/.test(i)?e.push("'"+i+"'"):e.push(i)}return e.join(",")}function S(t){return t.a+t.f}function C(t){var e="normal";return"o"===t.a?e="oblique":"i"===t.a&&(e="italic"),e}function k(t){var e=4,s="n",i=null;return t&&((i=t.match(/(normal|oblique|italic)/i))&&i[1]&&(s=i[1].substr(0,1).toLowerCase()),(i=t.match(/([1-9]00|normal|bold)/i))&&i[1]&&(/bold/i.test(i[1])?e=7:/[1-9]00/.test(i[1])&&(e=parseInt(i[1].substr(0,1),10)))),s+e}function w(t,e){this.c=t,this.f=t.o.document.documentElement,this.h=e,this.a=new T("-"),this.j=!1!==e.events,this.g=!1!==e.classes}function L(t){if(t.g){var e=f(t.f,t.a.c("wf","active")),s=[],i=[t.a.c("wf","loading")];e||s.push(t.a.c("wf","inactive")),p(t.f,s,i)}I(t,"inactive")}function I(t,e,s){t.j&&t.h[e]&&(s?t.h[e](s.c,S(s)):t.h[e]())}function P(){this.c={}}function x(t,e){this.c=t,this.f=e,this.a=c(this.c,"span",{"aria-hidden":"true"},this.f)}function R(t){d(t.c,"body",t.a)}function D(t){return"display:block;position:absolute;top:-9999px;left:-9999px;font-size:300px;width:auto;height:auto;line-height:normal;margin:0;padding:0;font-variant:normal;white-space:nowrap;font-family:"+E(t.c)+";font-style:"+C(t)+";font-weight:"+t.f+"00;"}function O(t,e,s,i,r,n){this.g=t,this.j=e,this.a=i,this.c=s,this.f=r||3e3,this.h=n||void 0}function M(t,e,s,i,r,n,a){this.v=t,this.B=e,this.c=s,this.a=i,this.s=a||"BESbswy",this.f={},this.w=r||3e3,this.u=n||null,this.m=this.j=this.h=this.g=null,this.g=new x(this.c,this.s),this.h=new x(this.c,this.s),this.j=new x(this.c,this.s),this.m=new x(this.c,this.s),t=D(t=new A(this.a.c+",serif",S(this.a))),this.g.a.style.cssText=t,t=D(t=new A(this.a.c+",sans-serif",S(this.a))),this.h.a.style.cssText=t,t=D(t=new A("serif",S(this.a))),this.j.a.style.cssText=t,t=D(t=new A("sans-serif",S(this.a))),this.m.a.style.cssText=t,R(this.g),R(this.h),R(this.j),R(this.m)}T.prototype.c=function(t){for(var e=[],s=0;s<arguments.length;s++)e.push(arguments[s].replace(/[\W_]+/g,"").toLowerCase());return e.join(this.a)},O.prototype.start=function(){var t=this.c.o.document,e=this,s=o(),i=new Promise(function(i,r){!function n(){o()-s>=e.f?r():t.fonts.load(function(t){return C(t)+" "+t.f+"00 300px "+E(t.c)}(e.a),e.h).then(function(t){1<=t.length?i():setTimeout(n,25)},function(){r()})}()}),r=null,n=new Promise(function(t,s){r=setTimeout(s,e.f)});Promise.race([n,i]).then(function(){r&&(clearTimeout(r),r=null),e.g(e.a)},function(){e.j(e.a)})};var F={D:"serif",C:"sans-serif"},N=null;function B(){if(null===N){var t=/AppleWebKit\/([0-9]+)(?:\.([0-9]+))/.exec(window.navigator.userAgent);N=!!t&&(536>parseInt(t[1],10)||536===parseInt(t[1],10)&&11>=parseInt(t[2],10))}return N}function j(t,e,s){for(var i in F)if(F.hasOwnProperty(i)&&e===t.f[F[i]]&&s===t.f[F[i]])return!0;return!1}function $(t){var e,s=t.g.a.offsetWidth,i=t.h.a.offsetWidth;(e=s===t.f.serif&&i===t.f["sans-serif"])||(e=B()&&j(t,s,i)),e?o()-t.A>=t.w?B()&&j(t,s,i)&&(null===t.u||t.u.hasOwnProperty(t.a.c))?U(t,t.v):U(t,t.B):function(t){setTimeout(a(function(){$(this)},t),50)}(t):U(t,t.v)}function U(t,e){setTimeout(a(function(){u(this.g.a),u(this.h.a),u(this.j.a),u(this.m.a),e(this.a)},t),0)}function H(t,e,s){this.c=t,this.a=e,this.f=0,this.m=this.j=!1,this.s=s}M.prototype.start=function(){this.f.serif=this.j.a.offsetWidth,this.f["sans-serif"]=this.m.a.offsetWidth,this.A=o(),$(this)};var V=null;function G(t){0==--t.f&&t.j&&(t.m?((t=t.a).g&&p(t.f,[t.a.c("wf","active")],[t.a.c("wf","loading"),t.a.c("wf","inactive")]),I(t,"active")):L(t.a))}function W(t){this.j=t,this.a=new P,this.h=0,this.f=this.g=!0}function K(t,e,s,i,r){var n=0==--t.h;(t.f||t.g)&&setTimeout(function(){var t=r||null,o=i||{};if(0===s.length&&n)L(e.a);else{e.f+=s.length,n&&(e.j=n);var l,h=[];for(l=0;l<s.length;l++){var c=s[l],d=o[c.c],u=e.a,f=c;if(u.g&&p(u.f,[u.a.c("wf",f.c,S(f).toString(),"loading")]),I(u,"fontloading",f),u=null,null===V)if(window.FontFace){f=/Gecko.*Firefox\/(\d+)/.exec(window.navigator.userAgent);var g=/OS X.*Version\/10\..*Safari/.exec(window.navigator.userAgent)&&/Apple/.exec(window.navigator.vendor);V=f?42<parseInt(f[1],10):!g}else V=!1;u=V?new O(a(e.g,e),a(e.h,e),e.c,c,e.s,d):new M(a(e.g,e),a(e.h,e),e.c,c,e.s,t,d),h.push(u)}for(l=0;l<h.length;l++)h[l].start()}},0)}function z(t,e){this.c=t,this.a=e}function q(t,e){this.c=t,this.a=e}function Y(t,e){this.c=t||X,this.a=[],this.f=[],this.g=e||""}H.prototype.g=function(t){var e=this.a;e.g&&p(e.f,[e.a.c("wf",t.c,S(t).toString(),"active")],[e.a.c("wf",t.c,S(t).toString(),"loading"),e.a.c("wf",t.c,S(t).toString(),"inactive")]),I(e,"fontactive",t),this.m=!0,G(this)},H.prototype.h=function(t){var e=this.a;if(e.g){var s=f(e.f,e.a.c("wf",t.c,S(t).toString(),"active")),i=[],r=[e.a.c("wf",t.c,S(t).toString(),"loading")];s||i.push(e.a.c("wf",t.c,S(t).toString(),"inactive")),p(e.f,i,r)}I(e,"fontinactive",t),G(this)},W.prototype.load=function(t){this.c=new l(this.j,t.context||this.j),this.g=!1!==t.events,this.f=!1!==t.classes,function(t,e,s){var i=[],r=s.timeout;!function(t){t.g&&p(t.f,[t.a.c("wf","loading")]),I(t,"loading")}(e),i=function(t,e,s){var i,r=[];for(i in e)if(e.hasOwnProperty(i)){var n=t.c[i];n&&r.push(n(e[i],s))}return r}(t.a,s,t.c);var n=new H(t.c,e,r);for(t.h=i.length,e=0,s=i.length;e<s;e++)i[e].load(function(e,s,i){K(t,n,e,s,i)})}(this,new w(this.c,t),t)},z.prototype.load=function(t){function e(){if(n["__mti_fntLst"+i]){var s,r=n["__mti_fntLst"+i](),a=[];if(r)for(var o=0;o<r.length;o++){var l=r[o].fontfamily;null!=r[o].fontStyle&&null!=r[o].fontWeight?(s=r[o].fontStyle+r[o].fontWeight,a.push(new A(l,s))):a.push(new A(l))}t(a)}else setTimeout(function(){e()},50)}var s=this,i=s.a.projectId,r=s.a.version;if(i){var n=s.c.o;m(this.c,(s.a.api||"https://fast.fonts.net/jsapi")+"/"+i+".js"+(r?"?v="+r:""),function(r){r?t([]):(n["__MonotypeConfiguration__"+i]=function(){return s.a},e())}).id="__MonotypeAPIScript__"+i}else t([])},q.prototype.load=function(t){var e,s,i=this.a.urls||[],r=this.a.families||[],n=this.a.testStrings||{},a=new y;for(e=0,s=i.length;e<s;e++)g(this.c,i[e],v(a));var o=[];for(e=0,s=r.length;e<s;e++)if((i=r[e].split(":"))[1])for(var l=i[1].split(","),h=0;h<l.length;h+=1)o.push(new A(i[0],l[h]));else o.push(new A(i[0]));b(a,function(){t(o,n)})};var X="https://fonts.googleapis.com/css";function Q(t){this.f=t,this.a=[],this.c={}}var Z={latin:"BESbswy","latin-ext":"çöüğş",cyrillic:"йяЖ",greek:"αβΣ",khmer:"កខគ",Hanuman:"កខគ"},J={thin:"1",extralight:"2","extra-light":"2",ultralight:"2","ultra-light":"2",light:"3",regular:"4",book:"4",medium:"5","semi-bold":"6",semibold:"6","demi-bold":"6",demibold:"6",bold:"7","extra-bold":"8",extrabold:"8","ultra-bold":"8",ultrabold:"8",black:"9",heavy:"9",l:"3",r:"4",b:"7"},tt={i:"i",italic:"i",n:"n",normal:"n"},et=/^(thin|(?:(?:extra|ultra)-?)?light|regular|book|medium|(?:(?:semi|demi|extra|ultra)-?)?bold|black|heavy|l|r|b|[1-9]00)?(n|i|normal|italic)?$/;function st(t,e){this.c=t,this.a=e}var it={Arimo:!0,Cousine:!0,Tinos:!0};function rt(t,e){this.c=t,this.a=e}function nt(t,e){this.c=t,this.f=e,this.a=[]}st.prototype.load=function(t){var e=new y,s=this.c,i=new Y(this.a.api,this.a.text),r=this.a.families;!function(t,e){for(var s=e.length,i=0;i<s;i++){var r=e[i].split(":");3==r.length&&t.f.push(r.pop());var n="";2==r.length&&""!=r[1]&&(n=":"),t.a.push(r.join(n))}}(i,r);var n=new Q(r);!function(t){for(var e=t.f.length,s=0;s<e;s++){var i=t.f[s].split(":"),r=i[0].replace(/\+/g," "),n=["n4"];if(2<=i.length){var a;if(a=[],o=i[1])for(var o,l=(o=o.split(",")).length,h=0;h<l;h++){var c;if((c=o[h]).match(/^[\w-]+$/))if(null==(d=et.exec(c.toLowerCase())))c="";else{if(c=null==(c=d[2])||""==c?"n":tt[c],null==(d=d[1])||""==d)d="4";else var d=J[d]||(isNaN(d)?"4":d.substr(0,1));c=[c,d].join("")}else c="";c&&a.push(c)}0<a.length&&(n=a),3==i.length&&(a=[],0<(i=(i=i[2])?i.split(","):a).length&&(i=Z[i[0]])&&(t.c[r]=i))}for(t.c[r]||(i=Z[r])&&(t.c[r]=i),i=0;i<n.length;i+=1)t.a.push(new A(r,n[i]))}}(n),g(s,function(t){if(0==t.a.length)throw Error("No fonts to load!");if(-1!=t.c.indexOf("kit="))return t.c;for(var e=t.a.length,s=[],i=0;i<e;i++)s.push(t.a[i].replace(/ /g,"+"));return e=t.c+"?family="+s.join("%7C"),0<t.f.length&&(e+="&subset="+t.f.join(",")),0<t.g.length&&(e+="&text="+encodeURIComponent(t.g)),e}(i),v(e)),b(e,function(){t(n.a,n.c,it)})},rt.prototype.load=function(t){var e=this.a.id,s=this.c.o;e?m(this.c,(this.a.api||"https://use.typekit.net")+"/"+e+".js",function(e){if(e)t([]);else if(s.Typekit&&s.Typekit.config&&s.Typekit.config.fn){e=s.Typekit.config.fn;for(var i=[],r=0;r<e.length;r+=2)for(var n=e[r],a=e[r+1],o=0;o<a.length;o++)i.push(new A(n,a[o]));try{s.Typekit.load({events:!1,classes:!1,async:!0})}catch(t){}t(i)}},2e3):t([])},nt.prototype.load=function(t){var e=this.f.id,s=this.c.o,i=this;e?(s.__webfontfontdeckmodule__||(s.__webfontfontdeckmodule__={}),s.__webfontfontdeckmodule__[e]=function(e,s){for(var r=0,n=s.fonts.length;r<n;++r){var a=s.fonts[r];i.a.push(new A(a.name,k("font-weight:"+a.weight+";font-style:"+a.style)))}t(i.a)},m(this.c,(this.f.api||"https://f.fontdeck.com/s/css/js/")+function(t){return t.o.location.hostname||t.a.location.hostname}(this.c)+"/"+e+".js",function(e){e&&t([])})):t([])};var at=new W(window);at.a.c.custom=function(t,e){return new q(e,t)},at.a.c.fontdeck=function(t,e){return new nt(e,t)},at.a.c.monotype=function(t,e){return new z(e,t)},at.a.c.typekit=function(t,e){return new rt(e,t)},at.a.c.google=function(t,e){return new st(e,t)};var ot={load:a(at.load,at)};void 0===(i=function(){return ot}.call(e,s,e,t))||(t.exports=i)}()},4626:()=>{},6606:(t,e)=>{var s={607:function(t,e,s){var i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.defaultProfiles=e.cldLiveStreamingProfile=e.cldAdaptiveStreamProfile=e.cldLoopingProfile=e.cldDefaultProfile=void 0;const r=i(s(704)),n=i(s(83)),a=i(s(832)),o=i(s(877));e.cldDefaultProfile={name:"cld-default",isDefault:!0,config:r.default},e.cldLoopingProfile={name:"cld-looping",isDefault:!0,config:n.default},e.cldAdaptiveStreamProfile={name:"cld-adaptive-stream",isDefault:!0,config:a.default},e.cldLiveStreamingProfile={name:"cld-live-streaming",isDefault:!0,config:o.default},e.defaultProfiles=[e.cldDefaultProfile,e.cldLoopingProfile,e.cldAdaptiveStreamProfile,e.cldLiveStreamingProfile]},832:t=>{t.exports=JSON.parse('{"playerOptions":{"fluid":true,"controls":true,"controlBar":{"fullscreenToggle":false},"showJumpControls":true,"hideContextMenu":false,"floatingWhenNotVisible":"none"},"sourceOptions":{"chapters":true,"sourceTypes":["hls"]}}')},704:t=>{t.exports=JSON.parse('{"playerOptions":{},"sourceOptions":{}}')},877:t=>{t.exports=JSON.parse('{"playerOptions":{},"sourceOptions":{"type":"live","sourceTypes":["hls"]}}')},83:t=>{t.exports=JSON.parse('{"playerOptions":{"fluid":true,"controls":false,"muted":true,"floatingWhenNotVisible":"none","hideContextMenu":false,"autoplay":true,"loop":true},"sourceOptions":{}}')}},i={},r=function t(e){var r=i[e];if(void 0!==r)return r.exports;var n=i[e]={exports:{}};return s[e].call(n.exports,n,n.exports,t),n.exports}(607),n=e;for(var a in r)n[a]=r[a];r.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})},8586:(t,e,s)=>{s.d(e,{A:()=>a});class i{constructor(t){this.expressions=[],null!=t&&this.expressions.push(i.normalize(t))}static new(t){return new this(t)}static normalize(t){var e,s,i;return null==t?t:(t=String(t),e=new RegExp("((\\|\\||>=|<=|&&|!=|>|=|<|/|-|\\+|\\*|\\^)(?=[ _]))","g"),t=t.replace(e,t=>r[t]),s="("+Object.keys(n).join("|")+")",i=new RegExp(s,"g"),(t=t.replace(i,(e,s,i)=>"$"===t[i-1]?e:n[e])).replace(/[ _]+/g,"_"))}serialize(){return i.normalize(this.expressions.join("_"))}toString(){return this.serialize()}getParent(){return this.parent}setParent(t){return this.parent=t,this}predicate(t,e,s){return null!=r[e]&&(e=r[e]),this.expressions.push(`${t}_${e}_${s}`),this}and(){return this.expressions.push("and"),this}or(){return this.expressions.push("or"),this}then(){return this.getParent().if(this.toString())}height(t,e){return this.predicate("h",t,e)}width(t,e){return this.predicate("w",t,e)}aspectRatio(t,e){return this.predicate("ar",t,e)}pageCount(t,e){return this.predicate("pc",t,e)}faceCount(t,e){return this.predicate("fc",t,e)}value(t){return this.expressions.push(t),this}static variable(t,e){return new this(t).value(e)}static width(){return new this("width")}static height(){return new this("height")}static initialWidth(){return new this("initialWidth")}static initialHeight(){return new this("initialHeight")}static aspectRatio(){return new this("aspectRatio")}static initialAspectRatio(){return new this("initialAspectRatio")}static pageCount(){return new this("pageCount")}static faceCount(){return new this("faceCount")}static currentPage(){return new this("currentPage")}static tags(){return new this("tags")}static pageX(){return new this("pageX")}static pageY(){return new this("pageY")}}const r={"=":"eq","!=":"ne","<":"lt",">":"gt","<=":"lte",">=":"gte","&&":"and","||":"or","*":"mul","/":"div","+":"add","-":"sub","^":"pow"},n={aspect_ratio:"ar",aspectRatio:"ar",current_page:"cp",currentPage:"cp","preview:duration":"preview:duration",duration:"du",face_count:"fc",faceCount:"fc",height:"h",initial_aspect_ratio:"iar",initial_duration:"idu",initial_height:"ih",initial_width:"iw",initialAspectRatio:"iar",initialDuration:"idu",initialHeight:"ih",initialWidth:"iw",page_count:"pc",page_x:"px",page_y:"py",pageCount:"pc",pageX:"px",pageY:"py",tags:"tags",width:"w"},a=i},7704:(t,e,s)=>{s.d(e,{A:()=>n});var i=s(436);class r{constructor(t){this.options={},null!=t&&["resourceType","type","publicId","format"].forEach(e=>{var s;return this.options[e]=null!=(s=t[e])?s:t[(0,i.L)(e)]})}resourceType(t){return this.options.resourceType=t,this}type(t){return this.options.type=t,this}publicId(t){return this.options.publicId=t,this}getPublicId(){var t;return null!=(t=this.options.publicId)?t.replace(/\//g,":"):void 0}getFullPublicId(){return null!=this.options.format?this.getPublicId()+"."+this.options.format:this.getPublicId()}format(t){return this.options.format=t,this}toString(){let t=[];if(null==this.options.publicId)throw"Must supply publicId";return"image"!==this.options.resourceType&&t.push(this.options.resourceType),"upload"!==this.options.type&&t.push(this.options.type),t.push(this.getFullPublicId()),t.filter(t=>!!t).join(":")}clone(){return new r(this.options)}}const n=r},593:(t,e,s)=>{s.d(e,{A:()=>h});var i=s(7704),r=s(436),n=s(4345),a=s(2798),o=s(9480);class l extends i.A{constructor(t){let e;super(t),e=["resourceType","resourceType","fontFamily","fontSize","fontWeight","fontStyle","textDecoration","textAlign","stroke","letterSpacing","lineSpacing","fontHinting","fontAntialiasing","text"],null!=t&&e.forEach(e=>{var s;return this.options[e]=null!=(s=t[e])?s:t[(0,r.L)(e)]}),this.options.resourceType="text"}resourceType(t){throw"Cannot modify resourceType for text layers"}type(t){throw"Cannot modify type for text layers"}format(t){throw"Cannot modify format for text layers"}fontFamily(t){return this.options.fontFamily=t,this}fontSize(t){return this.options.fontSize=t,this}fontWeight(t){return this.options.fontWeight=t,this}fontStyle(t){return this.options.fontStyle=t,this}textDecoration(t){return this.options.textDecoration=t,this}textAlign(t){return this.options.textAlign=t,this}stroke(t){return this.options.stroke=t,this}letterSpacing(t){return this.options.letterSpacing=t,this}lineSpacing(t){return this.options.lineSpacing=t,this}fontHinting(t){return this.options.fontHinting=t,this}fontAntialiasing(t){return this.options.fontAntialiasing=t,this}text(t){return this.options.text=t,this}toString(){var t,e,s,i,r,o,l,h,c;if(l=this.textStyleIdentifier(),null!=this.options.publicId&&(s=this.getFullPublicId()),null!=this.options.text){if(t=!(0,n.I)(s),e=!(0,n.I)(l),t&&e||!t&&!e)throw"Must supply either style parameters or a public_id when providing text parameter in a text overlay/underlay, but not both!";for(i=/\$\([a-zA-Z]\w*\)/g,o=0,c=(0,a.$)(this.options.text,/[,\/]/g),h="";r=i.exec(c);)h+=(0,a.$)(c.slice(o,r.index)),h+=r[0],o=r.index+r[0].length;h+=(0,a.$)(c.slice(o))}return[this.options.resourceType,l,s,h].filter(t=>!!t).join(":")}textStyleIdentifier(){var t;if(t=[],"normal"!==this.options.fontWeight&&t.push(this.options.fontWeight),"normal"!==this.options.fontStyle&&t.push(this.options.fontStyle),"none"!==this.options.textDecoration&&t.push(this.options.textDecoration),t.push(this.options.textAlign),"none"!==this.options.stroke&&t.push(this.options.stroke),(0,n.I)(this.options.letterSpacing)&&!(0,o.t)(this.options.letterSpacing)||t.push("letter_spacing_"+this.options.letterSpacing),(0,n.I)(this.options.lineSpacing)&&!(0,o.t)(this.options.lineSpacing)||t.push("line_spacing_"+this.options.lineSpacing),(0,n.I)(this.options.fontAntialiasing)||t.push("antialias_"+this.options.fontAntialiasing),(0,n.I)(this.options.fontHinting)||t.push("hinting_"+this.options.fontHinting),!(0,n.I)(t.filter(t=>!!t))){if((0,n.I)(this.options.fontFamily))throw`Must supply fontFamily. ${t}`;if((0,n.I)(this.options.fontSize)&&!(0,o.t)(this.options.fontSize))throw"Must supply fontSize."}return t.unshift(this.options.fontFamily,this.options.fontSize),t.filter(t=>!!t).join("_")}}const h=l},9445:(t,e,s)=>{s.d(e,{A:()=>H});var i=s(8586);class r extends i.A{constructor(t){super(t)}height(t,e){return this.predicate("h",t,e)}width(t,e){return this.predicate("w",t,e)}aspectRatio(t,e){return this.predicate("ar",t,e)}pageCount(t,e){return this.predicate("pc",t,e)}faceCount(t,e){return this.predicate("fc",t,e)}duration(t,e){return this.predicate("du",t,e)}initialDuration(t,e){return this.predicate("idu",t,e)}}const n=r;"undefined"!=typeof window&&null!==window&&window.location&&window.location.protocol;var a=s(7648),o=s(4345);const l=function(t){let e=t.match(d);return e=e.map(t=>t.charAt(0).toLocaleUpperCase()+t.slice(1).toLocaleLowerCase()),e[0]=e[0].toLocaleLowerCase(),e.join("")};var h,c,d=(c="[A-Z]",h="[a-z]+",RegExp(c+"+(?="+c+h+")|"+c+"?"+h+"|"+c+"+|[0-9]+","g"));function u(t){return t}function p(t,e){for(let s=0;s<t.length;s++)if(t[s]===e)return!0;return!1}var f=s(436),g=s(7704),m=s(593);class y extends m.A{constructor(t){super(t),this.options.resourceType="subtitles"}}const v=y;function b(t){return"string"==typeof t||t instanceof String}var _=s(9914);class T extends g.A{constructor(t){super(t),b(t)?this.options.url=t:(null!=t?t.url:void 0)&&(this.options.url=t.url)}url(t){return this.options.url=t,this}toString(){return`fetch:${(0,_.K)(this.options.url)}`}}const A=T;var E=s(2901);function S(t){return t instanceof Function}const C=["accessibility","api_secret","auth_token","cdn_subdomain","cloud_name","cname","format","placeholder","private_cdn","resource_type","secure","secure_cdn_subdomain","secure_distribution","shorten","sign_url","signature","ssl_detected","type","url_suffix","use_root_path","version"];function k(t,...e){return e.forEach(e=>{Object.keys(e).forEach(s=>{null!=e[s]&&(t[s]=e[s])})}),t}class w{constructor(t,e,s=u){this.name=t,this.shortName=e,this.process=s}set(t){return this.origValue=t,this}serialize(){var t,e;return t=this.value(),e=Array.isArray(t)||(0,E.G)(t)||b(t)?!(0,o.I)(t):null!=t,null!=this.shortName&&e?`${this.shortName}_${t}`:""}value(){return this.process(this.origValue)}static norm_color(t){return null!=t?t.replace(/^#/,"rgb:"):void 0}static build_array(t){return null==t?[]:Array.isArray(t)?t:[t]}static process_video_params(t){var e;switch(t.constructor){case Object:return e="","codec"in t&&(e=t.codec,"profile"in t&&(e+=":"+t.profile,"level"in t&&(e+=":"+t.level))),e;case String:return t;default:return null}}}class L extends w{constructor(t,e,s=".",i=void 0){super(t,e,i),this.sep=s}serialize(){if(null!=this.shortName){let t=this.value();if((0,o.I)(t))return"";if(b(t))return`${this.shortName}_${t}`;{let e=t.map(t=>S(t.serialize)?t.serialize():t).join(this.sep);return`${this.shortName}_${e}`}}return""}value(){return Array.isArray(this.origValue)?this.origValue.map(t=>this.process(t)):this.process(this.origValue)}set(t){return null==t||Array.isArray(t)?super.set(t):super.set([t])}}class I extends w{constructor(t,e="t",s=".",i=void 0){super(t,e,i),this.sep=s}serialize(){let t="";const e=this.value();if((0,o.I)(e))return t;if((s=e).length&&s.every(b)){const s=e.join(this.sep);(0,o.I)(s)||(t=`${this.shortName}_${s}`)}else t=e.map(t=>b(t)&&!(0,o.I)(t)?`${this.shortName}_${t}`:S(t.serialize)?t.serialize():(0,E.G)(t)&&!(0,o.I)(t)?new j(t).serialize():void 0).filter(t=>t);var s;return t}set(t){return this.origValue=t,Array.isArray(this.origValue)?super.set(this.origValue):super.set([this.origValue])}}class P extends w{constructor(t,e,s=P.norm_range_value){super(t,e,s)}static norm_range_value(t){let e=String(t).match(new RegExp("^(([0-9]*)\\.([0-9]+)|([0-9]+))([%pP])?$"));if(e){let s=null!=e[5]?"p":"";t=(e[1]||e[4])+s}return t}}class x extends w{constructor(t,e,s=u){super(t,e,s)}serialize(){return this.value()}}class R extends w{value(){if(null==this.origValue)return"";let t;if(this.origValue instanceof g.A)t=this.origValue;else if((0,E.G)(this.origValue)){let e=function(t,e){var s,i;s={};for(let r in t)i=t[r],e&&(r=e(r)),(0,o.I)(r)||(s[r]=i);return s}(this.origValue,l);t="text"===e.resourceType||null!=e.text?new m.A(e):"subtitles"===e.resourceType?new v(e):"fetch"===e.resourceType||null!=e.url?new A(e):new g.A(e)}else t=b(this.origValue)?/^fetch:.+/.test(this.origValue)?new A(this.origValue.substr(6)):this.origValue:"";return t.toString()}static textStyle(t){return new m.A(t).textStyleIdentifier()}}class D{constructor(t){let e,s;e=void 0,s={},this.toOptions=t=>{let e={};if(null==t&&(t=!0),Object.keys(s).forEach(t=>e[t]=s[t].origValue),k(e,this.otherOptions),t&&!(0,o.I)(this.chained)){let t=this.chained.map(t=>t.toOptions());t.push(e),e={},k(e,this.otherOptions),e.transformation=t}return e},this.setParent=t=>(e=t,null!=t&&this.fromOptions("function"==typeof t.toOptions?t.toOptions():void 0),this),this.getParent=()=>e,this.param=(t,e,i,r,n)=>(null==n&&(n=S(r)?r:u),s[e]=new w(e,i,n).set(t),this),this.rawParam=function(t,e,i,r,n){return n=N(arguments),s[e]=new x(e,i,n).set(t),this},this.rangeParam=function(t,e,i,r,n){return n=N(arguments),s[e]=new P(e,i,n).set(t),this},this.arrayParam=function(t,e,i,r=":",n=[],a=void 0){return a=N(arguments),s[e]=new L(e,i,r,a).set(t),this},this.transformationParam=function(t,e,i,r=".",n=void 0,a=void 0){return a=N(arguments),s[e]=new I(e,i,r,a).set(t),this},this.layerParam=function(t,e,i){return s[e]=new R(e,i).set(t),this},this.getValue=function(t){let e=s[t]&&s[t].value();return null!=e?e:this.otherOptions[t]},this.get=function(t){return s[t]},this.remove=function(t){var e;switch(!1){case null==s[t]:return e=s[t],delete s[t],e.origValue;case null==this.otherOptions[t]:return e=this.otherOptions[t],delete this.otherOptions[t],e;default:return null}},this.keys=function(){var t;return function(){var e;for(t in e=[],s)null!=t&&e.push(t.match(O)?t:(0,f.L)(t));return e}().sort()},this.toPlainObject=function(){var t,e,i;for(e in t={},s)t[e]=s[e].value(),(0,E.G)(t[e])&&(t[e]=(0,a.m)(t[e]));return(0,o.I)(this.chained)||((i=this.chained.map(t=>t.toPlainObject())).push(t),t={transformation:i}),t},this.chain=function(){var t;return 0!==Object.getOwnPropertyNames(s).length&&(t=new this.constructor(this.toOptions(!1)),this.resetTransformations(),this.chained.push(t)),this},this.resetTransformations=function(){return s={},this},this.otherOptions={},this.chained=[],this.fromOptions(t)}fromOptions(t={}){if(t instanceof D)this.fromTransformation(t);else{(b(t)||Array.isArray(t))&&(t={transformation:t}),(t=(0,a.m)(t)).if&&(this.set("if",t.if),delete t.if);for(let e in t){let s=t[e];null!=s&&(e.match(O)?"$attr"!==e&&this.set("variable",e,s):this.set(e,s))}}return this}fromTransformation(t){return t instanceof D&&t.keys().forEach(e=>this.set(e,t.get(e).origValue)),this}set(t,...e){let s;return s=l(t),p($,s)?this[s].apply(this,e):this.otherOptions[t]=e[0],this}hasLayer(){return this.getValue("overlay")||this.getValue("underlay")}serialize(){var t,e,s,r,n,a,l,h,c,d,u,p,f,g,m,y,v,_;for(d=this.chained.map(t=>t.serialize()),r=this.keys(),g=null!=(n=this.get("transformation"))?n.serialize():void 0,t=null!=(a=this.get("if"))?a.serialize():void 0,y=function(t){var e,s,r,n,a;if(Array.isArray(t)){for(n=[],e=0,s=t.length;e<s;e++)[r,a]=t[e],n.push(`${r}_${i.A.normalize(a)}`);return n}return t}(null!=(l=this.get("variables"))?l.value():void 0),_=["transformation","if","variables"],r=r.filter(t=>!_.includes(t)),v=[],p=[],e=0,s=r.length;e<s;e++)(u=r[e]).match(O)?v.push(u+"_"+i.A.normalize(null!=(h=this.get(u))?h.value():void 0)):p.push(null!=(c=this.get(u))?c.serialize():void 0);switch(!1){case!b(g):p.push(g);break;case!Array.isArray(g):d=d.concat(g)}return p=function(){var t,e,s;for(s=[],t=0,e=p.length;t<e;t++)m=p[t],(Array.isArray(m)&&!(0,o.I)(m)||!Array.isArray(m)&&m)&&s.push(m);return s}(),p=v.sort().concat(y).concat(p.sort()),"if_end"===t?p.push(t):(0,o.I)(t)||p.unshift(t),f=p.filter(t=>!!t).join(F),(0,o.I)(f)||d.push(f),d.filter(t=>!!t).join(M)}static listNames(){return $}toHtmlAttributes(){let t,e,s,i,r,n,a,o;return s={},Object.keys(this.otherOptions).forEach(e=>{n=this.otherOptions[e],o=(0,f.L)(e),p(U,o)||p(C,o)||(t=/^html_/.test(e)?e.slice(5):e,s[t]=n)}),this.keys().forEach(t=>{/^html_/.test(t)&&(s[l(t.slice(5))]=this.getValue(t))}),this.hasLayer()||this.getValue("angle")||p(["fit","limit","lfill"],this.getValue("crop"))||(a=null!=(i=this.get("width"))?i.origValue:void 0,e=null!=(r=this.get("height"))?r.origValue:void 0,parseFloat(a)>=1&&null==s.width&&(s.width=a),parseFloat(e)>=1&&null==s.height&&(s.height=e)),s}static isValidParamName(t){return $.indexOf(l(t))>=0}toHtml(){var t;return null!=(t=this.getParent())&&"function"==typeof t.toHtml?t.toHtml():void 0}toString(){return this.serialize()}clone(){return new D(this.toOptions(!0))}}const O=/^\$[a-zA-Z0-9]+$/,M="/",F=",";function N(t){var e;return S(e=null!=t?t[t.length-1]:void 0)?e:void 0}function B({function_type:t,source:e}){return"remote"===t?[t,btoa(e)].join(":"):"wasm"===t?[t,e].join(":"):void 0}class j extends D{constructor(t){super(t)}static new(t){return new j(t)}angle(t){return this.arrayParam(t,"angle","a",".",i.A.normalize),this}audioCodec(t){return this.param(t,"audio_codec","ac"),this}audioFrequency(t){return this.param(t,"audio_frequency","af"),this}aspectRatio(t){return this.param(t,"aspect_ratio","ar",i.A.normalize),this}background(t){return this.param(t,"background","b",w.norm_color),this}bitRate(t){return this.param(t,"bit_rate","br"),this}border(t){return this.param(t,"border","bo",t=>(0,E.G)(t)?`${(t=Object.assign({},{color:"black",width:2},t)).width}px_solid_${w.norm_color(t.color)}`:t)}color(t){return this.param(t,"color","co",w.norm_color),this}colorSpace(t){return this.param(t,"color_space","cs"),this}crop(t){return this.param(t,"crop","c"),this}customFunction(t){return this.param(t,"custom_function","fn",()=>B(t))}customPreFunction(t){if(!this.get("custom_function"))return this.rawParam(t,"custom_function","",()=>(t=B(t))?`fn_pre:${t}`:t)}defaultImage(t){return this.param(t,"default_image","d"),this}delay(t){return this.param(t,"delay","dl"),this}density(t){return this.param(t,"density","dn"),this}duration(t){return this.rangeParam(t,"duration","du"),this}dpr(t){return this.param(t,"dpr","dpr",t=>(null!=(t=t.toString())?t.match(/^\d+$/):void 0)?t+".0":i.A.normalize(t))}effect(t){return this.arrayParam(t,"effect","e",":",i.A.normalize),this}else(){return this.if("else")}endIf(){return this.if("end")}endOffset(t){return this.rangeParam(t,"end_offset","eo"),this}fallbackContent(t){return this.param(t,"fallback_content"),this}fetchFormat(t){return this.param(t,"fetch_format","f"),this}format(t){return this.param(t,"format"),this}flags(t){return this.arrayParam(t,"flags","fl","."),this}gravity(t){return this.param(t,"gravity","g"),this}fps(t){return this.param(t,"fps","fps",t=>b(t)?t:Array.isArray(t)?t.join("-"):t)}height(t){return this.param(t,"height","h",()=>this.getValue("crop")||this.getValue("overlay")||this.getValue("underlay")?i.A.normalize(t):null)}htmlHeight(t){return this.param(t,"html_height"),this}htmlWidth(t){return this.param(t,"html_width"),this}if(t=""){var e,s,i,r,a;switch(t){case"else":return this.chain(),this.param(t,"if","if");case"end":for(this.chain(),e=i=this.chained.length-1;i>=0&&"end"!==(s=this.chained[e].getValue("if"))&&(null==s||(r=j.new().if(s),this.chained[e].remove("if"),a=this.chained[e],this.chained[e]=j.new().transformation([r,a]),"else"===s));e=i+=-1);return this.param(t,"if","if");case"":return n.new().setParent(this);default:return this.param(t,"if","if",t=>n.new(t).toString())}}keyframeInterval(t){return this.param(t,"keyframe_interval","ki"),this}ocr(t){return this.param(t,"ocr","ocr"),this}offset(t){var e,s;if([s,e]=S(null!=t?t.split:void 0)?t.split(".."):Array.isArray(t)?t:[null,null],null!=s&&this.startOffset(s),null!=e)return this.endOffset(e)}opacity(t){return this.param(t,"opacity","o",i.A.normalize),this}overlay(t){return this.layerParam(t,"overlay","l"),this}page(t){return this.param(t,"page","pg"),this}poster(t){return this.param(t,"poster"),this}prefix(t){return this.param(t,"prefix","p"),this}quality(t){return this.param(t,"quality","q",i.A.normalize),this}radius(t){return this.arrayParam(t,"radius","r",":",i.A.normalize),this}rawTransformation(t){return this.rawParam(t,"raw_transformation"),this}size(t){let e,s;if(S(null!=t?t.split:void 0))return[s,e]=t.split("x"),this.width(s),this.height(e)}sourceTypes(t){return this.param(t,"source_types"),this}sourceTransformation(t){return this.param(t,"source_transformation")}startOffset(t){return this.rangeParam(t,"start_offset","so"),this}streamingProfile(t){return this.param(t,"streaming_profile","sp"),this}transformation(t){return this.transformationParam(t,"transformation","t"),this}underlay(t){return this.layerParam(t,"underlay","u"),this}variable(t,e){return this.param(e,t,t),this}variables(t){return this.arrayParam(t,"variables"),this}videoCodec(t){return this.param(t,"video_codec","vc",w.process_video_params),this}videoSampling(t){return this.param(t,"video_sampling","vs"),this}width(t){return this.param(t,"width","w",()=>this.getValue("crop")||this.getValue("overlay")||this.getValue("underlay")?i.A.normalize(t):null),this}x(t){return this.param(t,"x","x",i.A.normalize),this}y(t){return this.param(t,"y","y",i.A.normalize),this}zoom(t){return this.param(t,"zoom","z",i.A.normalize),this}}const $=["angle","audioCodec","audioFrequency","aspectRatio","background","bitRate","border","color","colorSpace","crop","customFunction","customPreFunction","defaultImage","delay","density","duration","dpr","effect","else","endIf","endOffset","fallbackContent","fetchFormat","format","flags","gravity","fps","height","htmlHeight","htmlWidth","if","keyframeInterval","ocr","offset","opacity","overlay","page","poster","prefix","quality","radius","rawTransformation","size","sourceTypes","sourceTransformation","startOffset","streamingProfile","transformation","underlay","variable","variables","videoCodec","videoSampling","width","x","y","zoom"],U=$.map(f.L).concat(["api_key","api_secret","callback","cdn_subdomain","cloud_name","cname","private_cdn","protocol","resource_type","responsive","responsive_class","responsive_use_breakpoints","responsive_width","round_dpr","secure","secure_cdn_subdomain","secure_distribution","shorten","type","upload_preset","url_suffix","use_root_path","version","externalLibraries","max_timeout_ms"]),H=j},4345:(t,e,s)=>{function i(t){return null==t||"object"==typeof t&&0===Object.keys(t).length||"string"==typeof t&&0===t.trim().length}s.d(e,{I:()=>i})},9480:(t,e,s)=>{s.d(e,{t:()=>i});const i=function(t){return null!=t&&!isNaN(parseFloat(t))}},2901:(t,e,s)=>{function i(t){return"object"==typeof t&&null!==t}s.d(e,{G:()=>i})},2798:(t,e,s)=>{function i(t,e=/([^a-zA-Z0-9_.\-\/:]+)/g){return t.replace(e,function(t){return t.split("").map(function(t){return"%"+t.charCodeAt(0).toString(16).toUpperCase()}).join("")})}s.d(e,{$:()=>i})},436:(t,e,s)=>{s.d(e,{L:()=>i});const i=t=>t.replace(/[A-Z]/g,t=>`_${t.toLowerCase()}`)},9914:(t,e,s)=>{function i(t){let e="";return e="undefined"!=typeof window?btoa(encodeURI(decodeURI(t))):global.Buffer.from(t).toString("base64"),e.replace(/\+/g,"-").replace(/\//g,"_")}s.d(e,{K:()=>i})},7648:(t,e,s)=>{s.d(e,{m:()=>Ht});var i="__lodash_hash_undefined__",r=9007199254740991,n="[object Arguments]",a="[object Boolean]",o="[object Date]",l="[object Function]",h="[object GeneratorFunction]",c="[object Map]",d="[object Number]",u="[object Object]",p="[object Promise]",f="[object RegExp]",g="[object Set]",m="[object String]",y="[object Symbol]",v="[object WeakMap]",b="[object ArrayBuffer]",_="[object DataView]",T="[object Float32Array]",A="[object Float64Array]",E="[object Int8Array]",S="[object Int16Array]",C="[object Int32Array]",k="[object Uint8Array]",w="[object Uint8ClampedArray]",L="[object Uint16Array]",I="[object Uint32Array]",P=/\w*$/,x=/^\[object .+?Constructor\]$/,R=/^(?:0|[1-9]\d*)$/,D={};D[n]=D["[object Array]"]=D[b]=D[_]=D[a]=D[o]=D[T]=D[A]=D[E]=D[S]=D[C]=D[c]=D[d]=D[u]=D[f]=D[g]=D[m]=D[y]=D[k]=D[w]=D[L]=D[I]=!0,D["[object Error]"]=D[l]=D[v]=!1;var O="object"==typeof global&&global&&global.Object===Object&&global,M="object"==typeof self&&self&&self.Object===Object&&self,F=O||M||Function("return this")(),N="object"==typeof exports&&exports&&!exports.nodeType&&exports,B=N&&"object"==typeof module&&module&&!module.nodeType&&module,j=B&&B.exports===N;function $(t,e){return t.set(e[0],e[1]),t}function U(t,e){return t.add(e),t}function H(t,e,s,i){var r=-1,n=t?t.length:0;for(i&&n&&(s=t[++r]);++r<n;)s=e(s,t[r],r,t);return s}function V(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!`${t}`}catch(t){}return e}function G(t){var e=-1,s=Array(t.size);return t.forEach(function(t,i){s[++e]=[i,t]}),s}function W(t,e){return function(s){return t(e(s))}}function K(t){var e=-1,s=Array(t.size);return t.forEach(function(t){s[++e]=t}),s}var z,q=Array.prototype,Y=Function.prototype,X=Object.prototype,Q=F["__core-js_shared__"],Z=(z=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?`Symbol(src)_1.${z}`:"",J=Y.toString,tt=X.hasOwnProperty,et=X.toString,st=RegExp(`^${J.call(tt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")}$`),it=j?F.Buffer:void 0,rt=F.Symbol,nt=F.Uint8Array,at=W(Object.getPrototypeOf,Object),ot=Object.create,lt=X.propertyIsEnumerable,ht=q.splice,ct=Object.getOwnPropertySymbols,dt=it?it.isBuffer:void 0,ut=W(Object.keys,Object),pt=Ft(F,"DataView"),ft=Ft(F,"Map"),gt=Ft(F,"Promise"),mt=Ft(F,"Set"),yt=Ft(F,"WeakMap"),vt=Ft(Object,"create"),bt=Ut(pt),_t=Ut(ft),Tt=Ut(gt),At=Ut(mt),Et=Ut(yt),St=rt?rt.prototype:void 0,Ct=St?St.valueOf:void 0;function kt(t){var e=-1,s=t?t.length:0;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}function wt(t){var e=-1,s=t?t.length:0;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}function Lt(t){var e=-1,s=t?t.length:0;for(this.clear();++e<s;){var i=t[e];this.set(i[0],i[1])}}function It(t){this.__data__=new wt(t)}function Pt(t,e,s){var i=t[e];tt.call(t,e)&&Vt(i,s)&&(void 0!==s||e in t)||(t[e]=s)}function xt(t,e){for(var s=t.length;s--;)if(Vt(t[s][0],e))return s;return-1}function Rt(t,e,s,i,r,p,v){var x;if(i&&(x=p?i(t,r,p,v):i(t)),void 0!==x)return x;if(!qt(t))return t;var R=Gt(t);if(R){if(x=function(t){var e=t.length,s=t.constructor(e);return e&&"string"==typeof t[0]&&tt.call(t,"index")&&(s.index=t.index,s.input=t.input),s}(t),!e)return function(t,e){var s=-1,i=t.length;for(e||(e=Array(i));++s<i;)e[s]=t[s];return e}(t,x)}else{var O=Bt(t),M=O==l||O==h;if(Kt(t))return function(t,e){if(e)return t.slice();var s=new t.constructor(t.length);return t.copy(s),s}(t,e);if(O==u||O==n||M&&!p){if(V(t))return p?t:{};if(x=function(t){return"function"!=typeof t.constructor||$t(t)?{}:qt(e=at(t))?ot(e):{};var e}(M?{}:t),!e)return function(t,e){return Ot(t,Nt(t),e)}(t,function(t,e){return t&&Ot(e,Yt(e),t)}(x,t))}else{if(!D[O])return p?t:{};x=function(t,e,s,i){var r,n=t.constructor;switch(e){case b:return Dt(t);case a:case o:return new n(+t);case _:return function(t,e){var s=e?Dt(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.byteLength)}(t,i);case T:case A:case E:case S:case C:case k:case w:case L:case I:return function(t,e){var s=e?Dt(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.length)}(t,i);case c:return function(t,e,s){return H(e?s(G(t),!0):G(t),$,new t.constructor)}(t,i,s);case d:case m:return new n(t);case f:return function(t){var e=new t.constructor(t.source,P.exec(t));return e.lastIndex=t.lastIndex,e}(t);case g:return function(t,e,s){return H(e?s(K(t),!0):K(t),U,new t.constructor)}(t,i,s);case y:return r=t,Ct?Object(Ct.call(r)):{}}}(t,O,Rt,e)}}v||(v=new It);var F=v.get(t);if(F)return F;if(v.set(t,x),!R)var N=s?function(t){return function(t,e,s){var i=e(t);return Gt(t)?i:function(t,e){for(var s=-1,i=e.length,r=t.length;++s<i;)t[r+s]=e[s];return t}(i,s(t))}(t,Yt,Nt)}(t):Yt(t);return function(t,e){for(var s=-1,i=t?t.length:0;++s<i&&!1!==e(t[s],s););}(N||t,function(r,n){N&&(r=t[n=r]),Pt(x,n,Rt(r,e,s,i,n,t,v))}),x}function Dt(t){var e=new t.constructor(t.byteLength);return new nt(e).set(new nt(t)),e}function Ot(t,e,s,i){s||(s={});for(var r=-1,n=e.length;++r<n;){var a=e[r],o=i?i(s[a],t[a],a,s,t):void 0;Pt(s,a,void 0===o?t[a]:o)}return s}function Mt(t,e){var s,i,r=t.__data__;return("string"==(i=typeof(s=e))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==s:null===s)?r["string"==typeof e?"string":"hash"]:r.map}function Ft(t,e){var s=function(t,e){return null==t?void 0:t[e]}(t,e);return function(t){return!(!qt(t)||(e=t,Z&&Z in e))&&(zt(t)||V(t)?st:x).test(Ut(t));var e}(s)?s:void 0}kt.prototype.clear=function(){this.__data__=vt?vt(null):{}},kt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},kt.prototype.get=function(t){var e=this.__data__;if(vt){var s=e[t];return s===i?void 0:s}return tt.call(e,t)?e[t]:void 0},kt.prototype.has=function(t){var e=this.__data__;return vt?void 0!==e[t]:tt.call(e,t)},kt.prototype.set=function(t,e){return this.__data__[t]=vt&&void 0===e?i:e,this},wt.prototype.clear=function(){this.__data__=[]},wt.prototype.delete=function(t){var e=this.__data__,s=xt(e,t);return!(s<0||(s==e.length-1?e.pop():ht.call(e,s,1),0))},wt.prototype.get=function(t){var e=this.__data__,s=xt(e,t);return s<0?void 0:e[s][1]},wt.prototype.has=function(t){return xt(this.__data__,t)>-1},wt.prototype.set=function(t,e){var s=this.__data__,i=xt(s,t);return i<0?s.push([t,e]):s[i][1]=e,this},Lt.prototype.clear=function(){this.__data__={hash:new kt,map:new(ft||wt),string:new kt}},Lt.prototype.delete=function(t){return Mt(this,t).delete(t)},Lt.prototype.get=function(t){return Mt(this,t).get(t)},Lt.prototype.has=function(t){return Mt(this,t).has(t)},Lt.prototype.set=function(t,e){return Mt(this,t).set(t,e),this},It.prototype.clear=function(){this.__data__=new wt},It.prototype.delete=function(t){return this.__data__.delete(t)},It.prototype.get=function(t){return this.__data__.get(t)},It.prototype.has=function(t){return this.__data__.has(t)},It.prototype.set=function(t,e){var s=this.__data__;if(s instanceof wt){var i=s.__data__;if(!ft||i.length<199)return i.push([t,e]),this;s=this.__data__=new Lt(i)}return s.set(t,e),this};var Nt=ct?W(ct,Object):function(){return[]},Bt=function(t){return et.call(t)};function jt(t,e){return!!(e=null==e?r:e)&&("number"==typeof t||R.test(t))&&t>-1&&t%1==0&&t<e}function $t(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||X)}function Ut(t){if(null!=t){try{return J.call(t)}catch(t){}try{return`${t}`}catch(t){}}return""}function Ht(t){return Rt(t,!0,!0)}function Vt(t,e){return t===e||t!=t&&e!=e}(pt&&Bt(new pt(new ArrayBuffer(1)))!=_||ft&&Bt(new ft)!=c||gt&&Bt(gt.resolve())!=p||mt&&Bt(new mt)!=g||yt&&Bt(new yt)!=v)&&(Bt=function(t){var e=et.call(t),s=e==u?t.constructor:void 0,i=s?Ut(s):void 0;if(i)switch(i){case bt:return _;case _t:return c;case Tt:return p;case At:return g;case Et:return v}return e});var Gt=Array.isArray;function Wt(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=r}(t.length)&&!zt(t)}var Kt=dt||function(){return!1};function zt(t){var e=qt(t)?et.call(t):"";return e==l||e==h}function qt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Yt(t){return Wt(t)?function(t,e){var s=Gt(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Wt(t)}(t)&&tt.call(t,"callee")&&(!lt.call(t,"callee")||et.call(t)==n)}(t)?function(t,e){for(var s=-1,i=Array(t);++s<t;)i[s]=e(s);return i}(t.length,String):[],i=s.length,r=!!i;for(var a in t)!e&&!tt.call(t,a)||r&&("length"==a||jt(a,i))||s.push(a);return s}(t):function(t){if(!$t(t))return ut(t);var e=[];for(var s in Object(t))tt.call(t,s)&&"constructor"!=s&&e.push(s);return e}(t)}}},i={};function r(t){var e=i[t];if(void 0!==e)return e.exports;var n=i[t]={id:t,loaded:!1,exports:{}};return s[t].call(n.exports,n,n.exports,r),n.loaded=!0,n.exports}r.m=s,t=[],r.O=(e,s,i,n)=>{if(!s){var a=1/0;for(c=0;c<t.length;c++){for(var[s,i,n]=t[c],o=!0,l=0;l<s.length;l++)(!1&n||a>=n)&&Object.keys(r.O).every(t=>r.O[t](s[l]))?s.splice(l--,1):(o=!1,n<a&&(a=n));if(o){t.splice(c--,1);var h=i();void 0!==h&&(e=h)}}return e}n=n||0;for(var c=t.length;c>0&&t[c-1][2]>n;c--)t[c]=t[c-1];t[c]=[s,i,n]},r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var s in e)r.o(e,s)&&!r.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},r.f={},r.e=t=>Promise.all(Object.keys(r.f).reduce((e,s)=>(r.f[s](t,e),e),[])),r.u=t=>({26:"adaptive-streaming",33:"playlist",40:"debug",330:"ima",367:"dash",404:"interaction-areas",410:"recommendations-overlay",525:"shoppable",625:"chapters",691:"colors",728:"visual-search",976:"share"}[t]+".js"),r.miniCssF=t=>{},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),e={},r.l=(t,s,i,n)=>{if(e[t])e[t].push(s);else{var a,o;if(void 0!==i)for(var l=document.getElementsByTagName("script"),h=0;h<l.length;h++){var c=l[h];if(c.getAttribute("src")==t){a=c;break}}a||(o=!0,(a=document.createElement("script")).type="module",a.charset="utf-8",a.timeout=120,r.nc&&a.setAttribute("nonce",r.nc),a.src=t),e[t]=[s];var d=(s,i)=>{a.onerror=a.onload=null,clearTimeout(u);var r=e[t];if(delete e[t],a.parentNode&&a.parentNode.removeChild(a),r&&r.forEach(t=>t(i)),s)return s(i)},u=setTimeout(d.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=d.bind(null,a.onerror),a.onload=d.bind(null,a.onload),o&&document.head.appendChild(a)}},r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),r.p="",(()=>{var t={668:0,278:0,26:0,410:0,625:0,691:0,330:0,404:0,33:0,525:0,728:0,976:0,869:0};r.f.j=(e,s)=>{var i=r.o(t,e)?t[e]:void 0;if(0!==i)if(i)s.push(i[2]);else if(869!=e){var n=new Promise((s,r)=>i=t[e]=[s,r]);s.push(i[2]=n);var a=r.p+r.u(e),o=new Error;r.l(a,s=>{if(r.o(t,e)&&(0!==(i=t[e])&&(t[e]=void 0),i)){var n=s&&("load"===s.type?"missing":s.type),a=s&&s.target&&s.target.src;o.message="Loading chunk "+e+" failed.\n("+n+": "+a+")",o.name="ChunkLoadError",o.type=n,o.request=a,i[1](o)}},"chunk-"+e,e)}else t[e]=0},r.O.j=e=>0===t[e];var e=(e,s)=>{var i,n,[a,o,l]=s,h=0;if(a.some(e=>0!==t[e])){for(i in o)r.o(o,i)&&(r.m[i]=o[i]);if(l)var c=l(r)}for(e&&e(s);h<a.length;h++)n=a[h],r.o(t,n)&&t[n]&&t[n][0](),t[n]=0;return r.O(c)},s=self.cloudinaryVideoPlayerChunkLoading=self.cloudinaryVideoPlayerChunkLoading||[];s.forEach(e.bind(null,0)),s.push=e.bind(null,s.push.bind(s))})();var n=r.O(void 0,[869],()=>r(8537)),a=(n=r.O(n)).Ay,o=n.OC,l=n.Fk,h=n.xY,c=n.Iy;export{a as default,o as player,l as players,h as videoPlayer,c as videoPlayers};
1
+ import cloudinary from './index.js';
2
+ export { player, players, videoPlayer, videoPlayers } from './index.js';
3
+ import './videojs-contrib-hlsjs.js';
4
+ export { _ as videojs } from './_videojs-proxy.js';
5
+ import './abr-strategies.js';
6
+ import './chapters.js';
7
+ import './video-player.js';
8
+ import './validators-functions.js';
9
+ import './player-api.js';
10
+ import './ima.js';
11
+ import './playlist-panel.js';
12
+ import './throttle.js';
13
+ import './noop.js';
14
+ import './interaction-areas.const.js';
15
+ import './download-button.js';
16
+ import './shoppable-post-widget.js';
17
+ import './recommendations-overlay.js';
18
+ import './_commonjsHelpers.js';
19
+ import './querystring.js';
20
+ import './document.js';
21
+ import './toNumber.js';
22
+
23
+ // This file is bundled as `all.js` to be imported as a single module that includes all plugins.
24
+
25
+ export { cloudinary as default };