@epic-web/workshop-app 5.5.0 → 5.7.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 (137) hide show
  1. package/build/client/assets/{_-BrkpfnBb.js → _-CjjFMNGC.js} +2 -2
  2. package/build/client/assets/{_-BrkpfnBb.js.map → _-CjjFMNGC.js.map} +1 -1
  3. package/build/client/assets/_exerciseNumber-CqkGzsgV.js +2 -0
  4. package/build/client/assets/{_exerciseNumber-DCSM0NCG.js.map → _exerciseNumber-CqkGzsgV.js.map} +1 -1
  5. package/build/client/assets/{_exerciseNumber_._stepNumber-BIMJh_sg.js → _exerciseNumber_._stepNumber-BNWGPi9m.js} +2 -2
  6. package/build/client/assets/{_exerciseNumber_._stepNumber-BIMJh_sg.js.map → _exerciseNumber_._stepNumber-BNWGPi9m.js.map} +1 -1
  7. package/build/client/assets/_exerciseNumber_.finished-CdNhLhKg.js +2 -0
  8. package/build/client/assets/{_exerciseNumber_.finished-nbpk1ToO.js.map → _exerciseNumber_.finished-CdNhLhKg.js.map} +1 -1
  9. package/build/client/assets/_layout-BMa5nZcJ.js +2 -0
  10. package/build/client/assets/{_layout-DTAM9xh5.js.map → _layout-BMa5nZcJ.js.map} +1 -1
  11. package/build/client/assets/{_layout-88n0To1b.js → _layout-CwTidn3v.js} +2 -2
  12. package/build/client/assets/{_layout-88n0To1b.js.map → _layout-CwTidn3v.js.map} +1 -1
  13. package/build/client/assets/{_layout-Dfmv2zcn.js → _layout-DV29dlKr.js} +2 -2
  14. package/build/client/assets/{_layout-Dfmv2zcn.js.map → _layout-DV29dlKr.js.map} +1 -1
  15. package/build/client/assets/{_layout-B8j0pWoF.js → _layout-Muw3ERYT.js} +3 -3
  16. package/build/client/assets/{_layout-B8j0pWoF.js.map → _layout-Muw3ERYT.js.map} +1 -1
  17. package/build/client/assets/{accordion-D9-D-n9p.js → accordion-C-sW--in.js} +2 -2
  18. package/build/client/assets/{accordion-D9-D-n9p.js.map → accordion-C-sW--in.js.map} +1 -1
  19. package/build/client/assets/account-Cc968svU.js +2 -0
  20. package/build/client/assets/account-Cc968svU.js.map +1 -0
  21. package/build/client/assets/app-BOqXK9hi.js +2 -0
  22. package/build/client/assets/{app-DgTXXO8s.js.map → app-BOqXK9hi.js.map} +1 -1
  23. package/build/client/assets/{button-_qPvcoqR.js → button-BS845Tjo.js} +2 -2
  24. package/build/client/assets/{button-_qPvcoqR.js.map → button-BS845Tjo.js.map} +1 -1
  25. package/build/client/assets/{components-Be92gVxW.js → components-DrvY4pal.js} +4 -4
  26. package/build/client/assets/{components-Be92gVxW.js.map → components-DrvY4pal.js.map} +1 -1
  27. package/build/client/assets/diff-D0e_PrB7.js +2 -0
  28. package/build/client/assets/{diff-BhRAIPKc.js.map → diff-D0e_PrB7.js.map} +1 -1
  29. package/build/client/assets/{diff-8nlDkmpc.js → diff-DtvfyjPI.js} +2 -2
  30. package/build/client/assets/{diff-8nlDkmpc.js.map → diff-DtvfyjPI.js.map} +1 -1
  31. package/build/client/assets/{discord-BUWZUTEC.js → discord-BfP_Rny5.js} +2 -2
  32. package/build/client/assets/{discord-BUWZUTEC.js.map → discord-BfP_Rny5.js.map} +1 -1
  33. package/build/client/assets/discord-DILzAZN8.js +2 -0
  34. package/build/client/assets/discord-DILzAZN8.js.map +1 -0
  35. package/build/client/assets/{entry.client-DqIWuxf8.js → entry.client-CQusg5Iz.js} +2 -2
  36. package/build/client/assets/{entry.client-DqIWuxf8.js.map → entry.client-CQusg5Iz.js.map} +1 -1
  37. package/build/client/assets/{epic-video-Bp4BOD2R.js → epic-video-qHKPWPt1.js} +130 -130
  38. package/build/client/assets/{epic-video-Bp4BOD2R.js.map → epic-video-qHKPWPt1.js.map} +1 -1
  39. package/build/client/assets/{error-boundary-BZA-ffa8.js → error-boundary-Beul7lrT.js} +2 -2
  40. package/build/client/assets/{error-boundary-BZA-ffa8.js.map → error-boundary-Beul7lrT.js.map} +1 -1
  41. package/build/client/assets/finished-DUKfL220.js +2 -0
  42. package/build/client/assets/{finished-C0cpfAFL.js.map → finished-DUKfL220.js.map} +1 -1
  43. package/build/client/assets/{index-BCTr8uu6.js → index-BHwOR8R1.js} +2 -2
  44. package/build/client/assets/{index-BCTr8uu6.js.map → index-BHwOR8R1.js.map} +1 -1
  45. package/build/client/assets/index-BOQWfIQC.js +36 -0
  46. package/build/client/assets/index-BOQWfIQC.js.map +1 -0
  47. package/build/client/assets/{index-DZDhtMuq.js → index-BPegC-d3.js} +2 -2
  48. package/build/client/assets/{index-DZDhtMuq.js.map → index-BPegC-d3.js.map} +1 -1
  49. package/build/client/assets/{index-C9Hx0Dey.js → index-CB8bjE90.js} +2 -2
  50. package/build/client/assets/{index-C9Hx0Dey.js.map → index-CB8bjE90.js.map} +1 -1
  51. package/build/client/assets/{index-BFGhCX_U.js → index-CGzylDPY.js} +2 -2
  52. package/build/client/assets/{index-BFGhCX_U.js.map → index-CGzylDPY.js.map} +1 -1
  53. package/build/client/assets/index-DbCT6N5p.js +2 -0
  54. package/build/client/assets/{index-Bi1TbRTj.js.map → index-DbCT6N5p.js.map} +1 -1
  55. package/build/client/assets/{index-pkiQppkK.js → index-cZQeGrqL.js} +2 -2
  56. package/build/client/assets/{index-pkiQppkK.js.map → index-cZQeGrqL.js.map} +1 -1
  57. package/build/client/assets/{index-BCxBKsqT.js → index-egcHQOpF.js} +2 -2
  58. package/build/client/assets/{index-BCxBKsqT.js.map → index-egcHQOpF.js.map} +1 -1
  59. package/build/client/assets/index-oED4uZLa.js +2 -0
  60. package/build/client/assets/{index-Ca4vBON4.js.map → index-oED4uZLa.js.map} +1 -1
  61. package/build/client/assets/{loading-XhMtj4mp.js → loading-C2wPVvQw.js} +2 -2
  62. package/build/client/assets/{loading-XhMtj4mp.js.map → loading-C2wPVvQw.js.map} +1 -1
  63. package/build/client/assets/login-DoU7gifi.js +2 -0
  64. package/build/client/assets/{login-C1oOgi98.js.map → login-DoU7gifi.js.map} +1 -1
  65. package/build/client/assets/manifest-93f34003.js +1 -0
  66. package/build/client/assets/mdx-CsS30JUo.js +2 -0
  67. package/build/client/assets/{mdx-CEjzXoEx.js.map → mdx-CsS30JUo.js.map} +1 -1
  68. package/build/client/assets/{misc-DUy_whwE.js → misc-BtjCSy-T.js} +2 -2
  69. package/build/client/assets/{misc-DUy_whwE.js.map → misc-BtjCSy-T.js.map} +1 -1
  70. package/build/client/assets/{nav-chevrons-DnR25VLp.js → nav-chevrons-2hLTwAZb.js} +2 -2
  71. package/build/client/assets/{nav-chevrons-DnR25VLp.js.map → nav-chevrons-2hLTwAZb.js.map} +1 -1
  72. package/build/client/assets/onboarding-Cu6eD7KS.js +2 -0
  73. package/build/client/assets/{onboarding-C2YNq60k.js.map → onboarding-Cu6eD7KS.js.map} +1 -1
  74. package/build/client/assets/{pe-ChIwTk8v.js → pe-DXT2FOp1.js} +2 -2
  75. package/build/client/assets/{pe-ChIwTk8v.js.map → pe-DXT2FOp1.js.map} +1 -1
  76. package/build/client/assets/preferences-br0VSK51.js +2 -0
  77. package/build/client/assets/preferences-br0VSK51.js.map +1 -0
  78. package/build/client/assets/{presence-8FPJKg_8.js → presence-CrYBA3ta.js} +3 -3
  79. package/build/client/assets/{presence-8FPJKg_8.js.map → presence-CrYBA3ta.js.map} +1 -1
  80. package/build/client/assets/preview-C2y4Z0qO.js +2 -0
  81. package/build/client/assets/{preview-DaZd0wMb.js.map → preview-C2y4Z0qO.js.map} +1 -1
  82. package/build/client/assets/{product-DIAmCwmZ.js → product-gqq_YQBW.js} +2 -2
  83. package/build/client/assets/{product-DIAmCwmZ.js.map → product-gqq_YQBW.js.map} +1 -1
  84. package/build/client/assets/{progress-DQt_Bn9o.js → progress-D-HsH4j3.js} +2 -2
  85. package/build/client/assets/{progress-DQt_Bn9o.js.map → progress-D-HsH4j3.js.map} +1 -1
  86. package/build/client/assets/{progress-bar-BaTU3Yx_.js → progress-bar-CTPCfvDi.js} +2 -2
  87. package/build/client/assets/{progress-bar-BaTU3Yx_.js.map → progress-bar-CTPCfvDi.js.map} +1 -1
  88. package/build/client/assets/revalidation-ws-DYaJNyw1.js +2 -0
  89. package/build/client/assets/{revalidation-ws-dUa9CAqr.js.map → revalidation-ws-DYaJNyw1.js.map} +1 -1
  90. package/build/client/assets/{root-D12XnE1S.js → root-DGY0y7_0.js} +3 -3
  91. package/build/client/assets/{root-D12XnE1S.js.map → root-DGY0y7_0.js.map} +1 -1
  92. package/build/client/assets/{set-playground-CBHBA46B.js → set-playground-DQzAhC0t.js} +2 -2
  93. package/build/client/assets/{set-playground-CBHBA46B.js.map → set-playground-DQzAhC0t.js.map} +1 -1
  94. package/build/client/assets/{support-CIz02V_r.js → support-lgEG2piy.js} +2 -2
  95. package/build/client/assets/{support-CIz02V_r.js.map → support-lgEG2piy.js.map} +1 -1
  96. package/build/client/assets/tailwind-CRGTilRc.css +1 -0
  97. package/build/client/assets/test-CDWRwwO-.js +2 -0
  98. package/build/client/assets/{test-DoKJvNug.js.map → test-CDWRwwO-.js.map} +1 -1
  99. package/build/client/assets/{tests-DbuyD2cI.js → tests-LWW8wCYZ.js} +3 -3
  100. package/build/client/assets/{tests-DbuyD2cI.js.map → tests-LWW8wCYZ.js.map} +1 -1
  101. package/build/client/assets/{tooltip-DO9uwurQ.js → tooltip-Bp9KHnLy.js} +2 -2
  102. package/build/client/assets/{tooltip-DO9uwurQ.js.map → tooltip-Bp9KHnLy.js.map} +1 -1
  103. package/build/client/assets/{use-event-source-x59d4R2Z.js → use-event-source-AZJtQsFX.js} +2 -2
  104. package/build/client/assets/{use-event-source-x59d4R2Z.js.map → use-event-source-AZJtQsFX.js.map} +1 -1
  105. package/build/client/assets/{user-Bv6wYhQP.js → user-C0j04V55.js} +2 -2
  106. package/build/client/assets/{user-Bv6wYhQP.js.map → user-C0j04V55.js.map} +1 -1
  107. package/build/client/assets/{version-lxUUxt3s.js → version-D61Qvt0X.js} +2 -2
  108. package/build/client/assets/{version-lxUUxt3s.js.map → version-D61Qvt0X.js.map} +1 -1
  109. package/build/client/assets/{workshop-config-WVltG_BV.js → workshop-config-oL_FWDKq.js} +2 -2
  110. package/build/client/assets/{workshop-config-WVltG_BV.js.map → workshop-config-oL_FWDKq.js.map} +1 -1
  111. package/build/server/index.js +308 -148
  112. package/build/server/index.js.map +1 -1
  113. package/package.json +8 -8
  114. package/build/client/assets/_exerciseNumber-DCSM0NCG.js +0 -2
  115. package/build/client/assets/_exerciseNumber_.finished-nbpk1ToO.js +0 -2
  116. package/build/client/assets/_layout-DTAM9xh5.js +0 -2
  117. package/build/client/assets/account-DPP4rKOb.js +0 -2
  118. package/build/client/assets/account-DPP4rKOb.js.map +0 -1
  119. package/build/client/assets/app-DgTXXO8s.js +0 -2
  120. package/build/client/assets/diff-BhRAIPKc.js +0 -2
  121. package/build/client/assets/discord-Bdnx7fu-.js +0 -2
  122. package/build/client/assets/discord-Bdnx7fu-.js.map +0 -1
  123. package/build/client/assets/finished-C0cpfAFL.js +0 -2
  124. package/build/client/assets/index-Bdg3v8tC.js +0 -36
  125. package/build/client/assets/index-Bdg3v8tC.js.map +0 -1
  126. package/build/client/assets/index-Bi1TbRTj.js +0 -2
  127. package/build/client/assets/index-Ca4vBON4.js +0 -2
  128. package/build/client/assets/login-C1oOgi98.js +0 -2
  129. package/build/client/assets/manifest-a8336fab.js +0 -1
  130. package/build/client/assets/mdx-CEjzXoEx.js +0 -2
  131. package/build/client/assets/onboarding-C2YNq60k.js +0 -2
  132. package/build/client/assets/preview-DaZd0wMb.js +0 -2
  133. package/build/client/assets/request-info-ByUEfOil.js +0 -2
  134. package/build/client/assets/request-info-ByUEfOil.js.map +0 -1
  135. package/build/client/assets/revalidation-ws-dUa9CAqr.js +0 -2
  136. package/build/client/assets/tailwind-B5AAMtGC.css +0 -1
  137. package/build/client/assets/test-DoKJvNug.js +0 -2
@@ -1,6 +1,6 @@
1
- import{R as Gl,r as ft,j as H}from"./index-BFGhCX_U.js";import{u as Ib}from"./index-Bdg3v8tC.js";import{z as Vd}from"./request-info-ByUEfOil.js";import{f as Rb,a as wb,I as Cb}from"./misc-DUy_whwE.js";import{a as Db,c as Mb,A as Pb,L as ja}from"./components-Be92gVxW.js";import{L as Oh}from"./loading-XhMtj4mp.js";import{c as Ob}from"./user-Bv6wYhQP.js";import{u as Nb}from"./workshop-config-WVltG_BV.js";var Fb=Object.create,$0=Object.defineProperty,Ub=Object.getOwnPropertyDescriptor,$b=Object.getOwnPropertyNames,Bb=Object.getPrototypeOf,Gb=Object.prototype.hasOwnProperty,B0=function(i,e){return function(){return i&&(e=i(i=0)),e}},xt=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}},Hb=function(i,e,t,r){if(e&&typeof e=="object"||typeof e=="function")for(var s=$b(e),n=0,a=s.length,o;n<a;n++)o=s[n],!Gb.call(i,o)&&o!==t&&$0(i,o,{get:(function(l){return e[l]}).bind(null,o),enumerable:!(r=Ub(e,o))||r.enumerable});return i},Qt=function(i,e,t){return t=i!=null?Fb(Bb(i)):{},Hb(!i||!i.__esModule?$0(t,"default",{value:i,enumerable:!0}):t,i)},Li=xt(function(i,e){var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t={},e.exports=t});function hs(i,e){return e!=null&&typeof Symbol<"u"&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](i):hs(i,e)}var fs=B0(function(){fs()});function Nh(i){"@swc/helpers - typeof";return i&&typeof Symbol<"u"&&i.constructor===Symbol?"symbol":typeof i}var Fh=B0(function(){}),G0=xt(function(i,e){var t=Array.prototype.slice;e.exports=r;function r(s,n){for(("length"in s)||(s=[s]),s=t.call(s);s.length;){var a=s.shift(),o=n(a);if(o)return o;a.childNodes&&a.childNodes.length&&(s=t.call(a.childNodes).concat(s))}}}),Wb=xt(function(i,e){fs(),e.exports=t;function t(r,s){if(!hs(this,t))return new t(r,s);this.data=r,this.nodeValue=r,this.length=r.length,this.ownerDocument=s||null}t.prototype.nodeType=8,t.prototype.nodeName="#comment",t.prototype.toString=function(){return"[object Comment]"}}),Kb=xt(function(i,e){fs(),e.exports=t;function t(r,s){if(!hs(this,t))return new t(r);this.data=r||"",this.length=this.data.length,this.ownerDocument=s||null}t.prototype.type="DOMTextNode",t.prototype.nodeType=3,t.prototype.nodeName="#text",t.prototype.toString=function(){return this.data},t.prototype.replaceData=function(r,s,n){var a=this.data,o=a.substring(0,r),l=a.substring(r+s,a.length);this.data=o+n+l,this.length=this.data.length}}),H0=xt(function(i,e){e.exports=t;function t(r){var s=this,n=r.type;r.target||(r.target=s),s.listeners||(s.listeners={});var a=s.listeners[n];if(a)return a.forEach(function(o){r.currentTarget=s,typeof o=="function"?o(r):o.handleEvent(r)});s.parentNode&&s.parentNode.dispatchEvent(r)}}),W0=xt(function(i,e){e.exports=t;function t(r,s){var n=this;n.listeners||(n.listeners={}),n.listeners[r]||(n.listeners[r]=[]),n.listeners[r].indexOf(s)===-1&&n.listeners[r].push(s)}}),K0=xt(function(i,e){e.exports=t;function t(r,s){var n=this;if(n.listeners&&n.listeners[r]){var a=n.listeners[r],o=a.indexOf(s);o!==-1&&a.splice(o,1)}}}),Vb=xt(function(i,e){Fh(),e.exports=r;var t=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function r(h){switch(h.nodeType){case 3:return u(h.data);case 8:return"<!--"+h.data+"-->";default:return s(h)}}function s(h){var f=[],m=h.tagName;return h.namespaceURI==="http://www.w3.org/1999/xhtml"&&(m=m.toLowerCase()),f.push("<"+m+d(h)+o(h)),t.indexOf(m)>-1?f.push(" />"):(f.push(">"),h.childNodes.length?f.push.apply(f,h.childNodes.map(r)):h.textContent||h.innerText?f.push(u(h.textContent||h.innerText)):h.innerHTML&&f.push(h.innerHTML),f.push("</"+m+">")),f.join("")}function n(h,f){var m=Nh(h[f]);return f==="style"&&Object.keys(h.style).length>0?!0:h.hasOwnProperty(f)&&(m==="string"||m==="boolean"||m==="number")&&f!=="nodeName"&&f!=="className"&&f!=="tagName"&&f!=="textContent"&&f!=="innerText"&&f!=="namespaceURI"&&f!=="innerHTML"}function a(h){if(typeof h=="string")return h;var f="";return Object.keys(h).forEach(function(m){var p=h[m];m=m.replace(/[A-Z]/g,function(g){return"-"+g.toLowerCase()}),f+=m+":"+p+";"}),f}function o(h){var f=h.dataset,m=[];for(var p in f)m.push({name:"data-"+p,value:f[p]});return m.length?l(m):""}function l(h){var f=[];return h.forEach(function(m){var p=m.name,g=m.value;p==="style"&&(g=a(g)),f.push(p+'="'+c(g)+'"')}),f.length?" "+f.join(" "):""}function d(h){var f=[];for(var m in h)n(h,m)&&f.push({name:m,value:h[m]});for(var p in h._attributes)for(var g in h._attributes[p]){var E=h._attributes[p][g],y=(E.prefix?E.prefix+":":"")+g;f.push({name:y,value:E.value})}return h.className&&f.push({name:"class",value:h.className}),f.length?l(f):""}function u(h){var f="";return typeof h=="string"?f=h:h&&(f=h.toString()),f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function c(h){return u(h).replace(/"/g,"&quot;")}}),V0=xt(function(i,e){fs();var t=G0(),r=H0(),s=W0(),n=K0(),a=Vb(),o="http://www.w3.org/1999/xhtml";e.exports=l;function l(d,u,c){if(!hs(this,l))return new l(d);var h=c===void 0?o:c||null;this.tagName=h===o?String(d).toUpperCase():d,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=u||null,this.namespaceURI=h,this._attributes={},this.tagName==="INPUT"&&(this.type="text")}l.prototype.type="DOMElement",l.prototype.nodeType=1,l.prototype.appendChild=function(d){return d.parentNode&&d.parentNode.removeChild(d),this.childNodes.push(d),d.parentNode=this,d},l.prototype.replaceChild=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=this.childNodes.indexOf(u);return u.parentNode=null,this.childNodes[c]=d,d.parentNode=this,u},l.prototype.removeChild=function(d){var u=this.childNodes.indexOf(d);return this.childNodes.splice(u,1),d.parentNode=null,d},l.prototype.insertBefore=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=u==null?-1:this.childNodes.indexOf(u);return c>-1?this.childNodes.splice(c,0,d):this.childNodes.push(d),d.parentNode=this,d},l.prototype.setAttributeNS=function(d,u,c){var h=null,f=u,m=u.indexOf(":");if(m>-1&&(h=u.substr(0,m),f=u.substr(m+1)),this.tagName==="INPUT"&&u==="type")this.type=c;else{var p=this._attributes[d]||(this._attributes[d]={});p[f]={value:c,prefix:h}}},l.prototype.getAttributeNS=function(d,u){var c=this._attributes[d],h=c&&c[u]&&c[u].value;return this.tagName==="INPUT"&&u==="type"?this.type:typeof h!="string"?null:h},l.prototype.removeAttributeNS=function(d,u){var c=this._attributes[d];c&&delete c[u]},l.prototype.hasAttributeNS=function(d,u){var c=this._attributes[d];return!!c&&u in c},l.prototype.setAttribute=function(d,u){return this.setAttributeNS(null,d,u)},l.prototype.getAttribute=function(d){return this.getAttributeNS(null,d)},l.prototype.removeAttribute=function(d){return this.removeAttributeNS(null,d)},l.prototype.hasAttribute=function(d){return this.hasAttributeNS(null,d)},l.prototype.removeEventListener=n,l.prototype.addEventListener=s,l.prototype.dispatchEvent=r,l.prototype.focus=function(){},l.prototype.toString=function(){return a(this)},l.prototype.getElementsByClassName=function(d){var u=d.split(" "),c=[];return t(this,function(h){if(h.nodeType===1){var f=h.className||"",m=f.split(" ");u.every(function(p){return m.indexOf(p)!==-1})&&c.push(h)}}),c},l.prototype.getElementsByTagName=function(d){d=d.toLowerCase();var u=[];return t(this.childNodes,function(c){c.nodeType===1&&(d==="*"||c.tagName.toLowerCase()===d)&&u.push(c)}),u},l.prototype.contains=function(d){return t(this,function(u){return d===u})||!1}}),qb=xt(function(i,e){fs();var t=V0();e.exports=r;function r(s){if(!hs(this,r))return new r;this.childNodes=[],this.parentNode=null,this.ownerDocument=s||null}r.prototype.type="DocumentFragment",r.prototype.nodeType=11,r.prototype.nodeName="#document-fragment",r.prototype.appendChild=t.prototype.appendChild,r.prototype.replaceChild=t.prototype.replaceChild,r.prototype.removeChild=t.prototype.removeChild,r.prototype.toString=function(){return this.childNodes.map(function(s){return String(s)}).join("")}}),Yb=xt(function(i,e){e.exports=t;function t(r){}t.prototype.initEvent=function(r,s,n){this.type=r,this.bubbles=s,this.cancelable=n},t.prototype.preventDefault=function(){}}),jb=xt(function(i,e){fs();var t=G0(),r=Wb(),s=Kb(),n=V0(),a=qb(),o=Yb(),l=H0(),d=W0(),u=K0();e.exports=c;function c(){if(!hs(this,c))return new c;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var h=c.prototype;h.createTextNode=function(f){return new s(f,this)},h.createElementNS=function(f,m){var p=f===null?null:String(f);return new n(m,this,p)},h.createElement=function(f){return new n(f,this)},h.createDocumentFragment=function(){return new a(this)},h.createEvent=function(f){return new o(f)},h.createComment=function(f){return new r(f,this)},h.getElementById=function(f){f=String(f);var m=t(this.childNodes,function(p){if(String(p.id)===f)return p});return m||null},h.getElementsByClassName=n.prototype.getElementsByClassName,h.getElementsByTagName=n.prototype.getElementsByTagName,h.contains=n.prototype.contains,h.removeEventListener=u,h.addEventListener=d,h.dispatchEvent=l}),zb=xt(function(i,e){var t=jb();e.exports=new t}),Xb=xt(function(i,e){var t=typeof global<"u"?global:typeof window<"u"?window:{},r=zb(),s;typeof document<"u"?s=document:(s=t["__GLOBAL_DOCUMENT_CACHE@4"],s||(s=t["__GLOBAL_DOCUMENT_CACHE@4"]=r)),e.exports=s});function Qb(i){if(Array.isArray(i))return i}function Zb(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var r=[],s=!0,n=!1,a,o;try{for(t=t.call(i);!(s=(a=t.next()).done)&&(r.push(a.value),!(e&&r.length===e));s=!0);}catch(l){n=!0,o=l}finally{try{!s&&t.return!=null&&t.return()}finally{if(n)throw o}}return r}}function Jb(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Bu(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=i[t];return r}function q0(i,e){if(i){if(typeof i=="string")return Bu(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Bu(i,e)}}function Wi(i,e){return Qb(i)||Zb(i,e)||q0(i,e)||Jb()}var pa=Qt(Li()),xa=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var e=Math.random()*16|0,t=i==="x"?e:e&3|8;return t.toString(16)})},Y0=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},xr=function(i){if(i&&typeof i.nodeName<"u")return i.muxId||(i.muxId=Y0()),i.muxId;var e;try{e=document.querySelector(i)}catch{}return e&&!e.muxId&&(e.muxId=i),(e==null?void 0:e.muxId)||i},Gu=function(i){var e;i&&typeof i.nodeName<"u"?(e=i,i=xr(e)):e=document.querySelector(i);var t=e&&e.nodeName?e.nodeName.toLowerCase():"";return[e,i,t]};function eT(i){if(Array.isArray(i))return Bu(i)}function tT(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function iT(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
3
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zt(i){return eT(i)||tT(i)||q0(i)||iT()}var Yr={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},rT=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,t,r,s,n,a,o=[console,i],l=(t=console.trace).bind.apply(t,Zt(o)),d=(r=console.info).bind.apply(r,Zt(o)),u=(s=console.debug).bind.apply(s,Zt(o)),c=(n=console.warn).bind.apply(n,Zt(o)),h=(a=console.error).bind.apply(a,Zt(o)),f=e;return{trace:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Yr.TRACE))return l.apply(void 0,Zt(p))},debug:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Yr.DEBUG))return u.apply(void 0,Zt(p))},info:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Yr.INFO))return d.apply(void 0,Zt(p))},warn:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Yr.WARN))return c.apply(void 0,Zt(p))},error:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Yr.ERROR))return h.apply(void 0,Zt(p))},get level(){return f},set level(m){m!==this.level&&(f=m??e)}}},Pe=rT("[mux]"),qd=Qt(Li());function Hu(){var i=qd.default.doNotTrack||qd.default.navigator&&qd.default.navigator.doNotTrack;return i==="1"}var sT=Qt(Li()),nT={now:function(){var i=sT.default.performance,e=i&&i.timing,t=e&&e.navigationStart,r=typeof t=="number"&&typeof i.now=="function"?t+i.now():Date.now();return Math.round(r)}},Xe=nT;function se(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}fs();function ut(i,e){if(!hs(i,e))throw new TypeError("Cannot call a class as a function")}function aT(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function Ii(i,e,t){return e&&aT(i.prototype,e),i}function B(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Wu(i,e){return Wu=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},Wu(i,e)}function oT(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&Wu(i,e)}function Hl(i){return Hl=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Hl(i)}function lT(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Fh();function dT(i,e){return e&&(Nh(e)==="object"||typeof e=="function")?e:se(i)}function uT(i){var e=lT();return function(){var t=Hl(i),r;if(e){var s=Hl(this).constructor;r=Reflect.construct(t,arguments,s)}else r=t.apply(this,arguments);return dT(this,r)}}var qt=function(i){return ka(i)[0]},ka=function(i){if(typeof i!="string"||i==="")return["localhost"];var e=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,t=i.match(e)||[],r=t[4],s;return r&&(s=(r.match(/[^\.]+\.[^\.]+$/)||[])[0]),[r,s]},Yd=Qt(Li()),cT={exists:function(){var i=Yd.default.performance,e=i&&i.timing;return e!==void 0},domContentLoadedEventEnd:function(){var i=Yd.default.performance,e=i&&i.timing;return e&&e.domContentLoadedEventEnd},navigationStart:function(){var i=Yd.default.performance,e=i&&i.timing;return e&&e.navigationStart}},Wl=cT;function He(i,e,t){t=t===void 0?1:t,i[e]=i[e]||0,i[e]+=t}function Kl(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{},r=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(r=r.concat(Object.getOwnPropertySymbols(t).filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable}))),r.forEach(function(s){B(i,s,t[s])})}return i}function hT(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);t.push.apply(t,r)}return t}function Uh(i,e){return e=e??{},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):hT(Object(e)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(e,t))}),i}var fT=["x-cdn","content-type"],j0=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],mT=fT.concat(j0);function $h(i){i=i||"";var e={},t=i.trim().split(/[\r\n]+/);return t.forEach(function(r){if(r){var s=r.split(": "),n=s.shift();n&&(mT.indexOf(n.toLowerCase())>=0||n.toLowerCase().indexOf("x-litix-")===0)&&(e[n]=s.join(": "))}}),e}function Vl(i){if(i){var e=j0.find(function(t){return i[t]!==void 0});return e?i[e]:void 0}}var pT=function(i){var e={};for(var t in i){var r=i[t],s=r["DATA-ID"].search("io.litix.data.");if(s!==-1){var n=r["DATA-ID"].replace("io.litix.data.","");e[n]=r.VALUE}}return e},z0=pT,za=function(i){if(!i)return{};var e=Wl.navigationStart(),t=i.loading,r=t?t.start:i.trequest,s=t?t.first:i.tfirst,n=t?t.end:i.tload;return{bytesLoaded:i.total,requestStart:Math.round(e+r),responseStart:Math.round(e+s),responseEnd:Math.round(e+n)}},kn=function(i){if(!(!i||typeof i.getAllResponseHeaders!="function"))return $h(i.getAllResponseHeaders())},gT=function(i,e,t){var r=arguments.length>4?arguments[4]:void 0,s=i.log,n=i.utils.secondsToMs,a=function(g){var E=parseInt(r.version),y;return E===1&&g.programDateTime!==null&&(y=g.programDateTime),E===0&&g.pdt!==null&&(y=g.pdt),y};if(!Wl.exists()){s.warn("performance timing not supported. Not tracking HLS.js.");return}var o=function(g,E){return i.emit(e,g,E)},l=function(g,E){var y=E.levels,b=E.audioTracks,S=E.url,_=E.stats,x=E.networkDetails,A=E.sessionData,C={},O={};y.forEach(function(V,q){C[q]={width:V.width,height:V.height,bitrate:V.bitrate,attrs:V.attrs}}),b.forEach(function(V,q){O[q]={name:V.name,language:V.lang,bitrate:V.bitrate}});var L=za(_),M=L.bytesLoaded,K=L.requestStart,U=L.responseStart,z=L.responseEnd;o("requestcompleted",Uh(Kl({},z0(A)),{request_event_type:g,request_bytes_loaded:M,request_start:K,request_response_start:U,request_response_end:z,request_type:"manifest",request_hostname:qt(S),request_response_headers:kn(x),request_rendition_lists:{media:C,audio:O,video:{}}}))};t.on(r.Events.MANIFEST_LOADED,l);var d=function(g,E){var y=E.details,b=E.level,S=E.networkDetails,_=E.stats,x=za(_),A=x.bytesLoaded,C=x.requestStart,O=x.responseStart,L=x.responseEnd,M=y.fragments[y.fragments.length-1],K=a(M)+n(M.duration);o("requestcompleted",{request_event_type:g,request_bytes_loaded:A,request_start:C,request_response_start:O,request_response_end:L,request_current_level:b,request_type:"manifest",request_hostname:qt(y.url),request_response_headers:kn(S),video_holdback:y.holdBack&&n(y.holdBack),video_part_holdback:y.partHoldBack&&n(y.partHoldBack),video_part_target_duration:y.partTarget&&n(y.partTarget),video_target_duration:y.targetduration&&n(y.targetduration),video_source_is_live:y.live,player_manifest_newest_program_time:isNaN(K)?void 0:K})};t.on(r.Events.LEVEL_LOADED,d);var u=function(g,E){var y=E.details,b=E.networkDetails,S=E.stats,_=za(S),x=_.bytesLoaded,A=_.requestStart,C=_.responseStart,O=_.responseEnd;o("requestcompleted",{request_event_type:g,request_bytes_loaded:x,request_start:A,request_response_start:C,request_response_end:O,request_type:"manifest",request_hostname:qt(y.url),request_response_headers:kn(b)})};t.on(r.Events.AUDIO_TRACK_LOADED,u);var c=function(g,E){var y=E.stats,b=E.networkDetails,S=E.frag;y=y||S.stats;var _=za(y),x=_.bytesLoaded,A=_.requestStart,C=_.responseStart,O=_.responseEnd,L=b?kn(b):void 0,M={request_event_type:g,request_bytes_loaded:x,request_start:A,request_response_start:C,request_response_end:O,request_hostname:b?qt(b.responseURL):void 0,request_id:L?Vl(L):void 0,request_response_headers:L,request_media_duration:S.duration,request_url:b==null?void 0:b.responseURL};S.type==="main"?(M.request_type="media",M.request_current_level=S.level,M.request_video_width=(t.levels[S.level]||{}).width,M.request_video_height=(t.levels[S.level]||{}).height,M.request_labeled_bitrate=(t.levels[S.level]||{}).bitrate):M.request_type=S.type,o("requestcompleted",M)};t.on(r.Events.FRAG_LOADED,c);var h=function(g,E){var y=E.frag,b=y.start,S=a(y),_={currentFragmentPDT:S,currentFragmentStart:n(b)};o("fragmentchange",_)};t.on(r.Events.FRAG_CHANGED,h);var f=function(g,E){var y=E.type,b=E.details,S=E.response,_=E.fatal,x=E.frag,A=E.networkDetails,C=(x==null?void 0:x.url)||E.url||"",O=A?kn(A):void 0;if((b===r.ErrorDetails.MANIFEST_LOAD_ERROR||b===r.ErrorDetails.MANIFEST_LOAD_TIMEOUT||b===r.ErrorDetails.FRAG_LOAD_ERROR||b===r.ErrorDetails.FRAG_LOAD_TIMEOUT||b===r.ErrorDetails.LEVEL_LOAD_ERROR||b===r.ErrorDetails.LEVEL_LOAD_TIMEOUT||b===r.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||b===r.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT||b===r.ErrorDetails.SUBTITLE_LOAD_ERROR||b===r.ErrorDetails.SUBTITLE_LOAD_TIMEOUT||b===r.ErrorDetails.KEY_LOAD_ERROR||b===r.ErrorDetails.KEY_LOAD_TIMEOUT)&&o("requestfailed",{request_error:b,request_url:C,request_hostname:qt(C),request_id:O?Vl(O):void 0,request_type:b===r.ErrorDetails.FRAG_LOAD_ERROR||b===r.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":b===r.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||b===r.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":b===r.ErrorDetails.SUBTITLE_LOAD_ERROR||b===r.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":b===r.ErrorDetails.KEY_LOAD_ERROR||b===r.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:S==null?void 0:S.code,request_error_text:S==null?void 0:S.text}),_){var L,M="".concat(C?"url: ".concat(C,`
1
+ import{R as Wl,r as ft,j as H}from"./index-CGzylDPY.js";import{z as Yd,u as wb}from"./index-BOQWfIQC.js";import{f as Cb,a as Db,I as Mb}from"./misc-BtjCSy-T.js";import{a as Pb,b as Ob,A as Nb,L as za}from"./components-DrvY4pal.js";import{L as Fh}from"./loading-C2wPVvQw.js";import{c as Fb}from"./user-C0j04V55.js";import{u as Ub}from"./workshop-config-oL_FWDKq.js";var $b=Object.create,G0=Object.defineProperty,Bb=Object.getOwnPropertyDescriptor,Gb=Object.getOwnPropertyNames,Hb=Object.getPrototypeOf,Wb=Object.prototype.hasOwnProperty,H0=function(i,e){return function(){return i&&(e=i(i=0)),e}},xt=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}},Kb=function(i,e,t,r){if(e&&typeof e=="object"||typeof e=="function")for(var s=Gb(e),n=0,a=s.length,o;n<a;n++)o=s[n],!Wb.call(i,o)&&o!==t&&G0(i,o,{get:(function(l){return e[l]}).bind(null,o),enumerable:!(r=Bb(e,o))||r.enumerable});return i},Qt=function(i,e,t){return t=i!=null?$b(Hb(i)):{},Kb(!i||!i.__esModule?G0(t,"default",{value:i,enumerable:!0}):t,i)},Li=xt(function(i,e){var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t={},e.exports=t});function hs(i,e){return e!=null&&typeof Symbol<"u"&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](i):hs(i,e)}var fs=H0(function(){fs()});function Uh(i){"@swc/helpers - typeof";return i&&typeof Symbol<"u"&&i.constructor===Symbol?"symbol":typeof i}var $h=H0(function(){}),W0=xt(function(i,e){var t=Array.prototype.slice;e.exports=r;function r(s,n){for(("length"in s)||(s=[s]),s=t.call(s);s.length;){var a=s.shift(),o=n(a);if(o)return o;a.childNodes&&a.childNodes.length&&(s=t.call(a.childNodes).concat(s))}}}),Vb=xt(function(i,e){fs(),e.exports=t;function t(r,s){if(!hs(this,t))return new t(r,s);this.data=r,this.nodeValue=r,this.length=r.length,this.ownerDocument=s||null}t.prototype.nodeType=8,t.prototype.nodeName="#comment",t.prototype.toString=function(){return"[object Comment]"}}),qb=xt(function(i,e){fs(),e.exports=t;function t(r,s){if(!hs(this,t))return new t(r);this.data=r||"",this.length=this.data.length,this.ownerDocument=s||null}t.prototype.type="DOMTextNode",t.prototype.nodeType=3,t.prototype.nodeName="#text",t.prototype.toString=function(){return this.data},t.prototype.replaceData=function(r,s,n){var a=this.data,o=a.substring(0,r),l=a.substring(r+s,a.length);this.data=o+n+l,this.length=this.data.length}}),K0=xt(function(i,e){e.exports=t;function t(r){var s=this,n=r.type;r.target||(r.target=s),s.listeners||(s.listeners={});var a=s.listeners[n];if(a)return a.forEach(function(o){r.currentTarget=s,typeof o=="function"?o(r):o.handleEvent(r)});s.parentNode&&s.parentNode.dispatchEvent(r)}}),V0=xt(function(i,e){e.exports=t;function t(r,s){var n=this;n.listeners||(n.listeners={}),n.listeners[r]||(n.listeners[r]=[]),n.listeners[r].indexOf(s)===-1&&n.listeners[r].push(s)}}),q0=xt(function(i,e){e.exports=t;function t(r,s){var n=this;if(n.listeners&&n.listeners[r]){var a=n.listeners[r],o=a.indexOf(s);o!==-1&&a.splice(o,1)}}}),Yb=xt(function(i,e){$h(),e.exports=r;var t=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function r(h){switch(h.nodeType){case 3:return u(h.data);case 8:return"<!--"+h.data+"-->";default:return s(h)}}function s(h){var f=[],m=h.tagName;return h.namespaceURI==="http://www.w3.org/1999/xhtml"&&(m=m.toLowerCase()),f.push("<"+m+d(h)+o(h)),t.indexOf(m)>-1?f.push(" />"):(f.push(">"),h.childNodes.length?f.push.apply(f,h.childNodes.map(r)):h.textContent||h.innerText?f.push(u(h.textContent||h.innerText)):h.innerHTML&&f.push(h.innerHTML),f.push("</"+m+">")),f.join("")}function n(h,f){var m=Uh(h[f]);return f==="style"&&Object.keys(h.style).length>0?!0:h.hasOwnProperty(f)&&(m==="string"||m==="boolean"||m==="number")&&f!=="nodeName"&&f!=="className"&&f!=="tagName"&&f!=="textContent"&&f!=="innerText"&&f!=="namespaceURI"&&f!=="innerHTML"}function a(h){if(typeof h=="string")return h;var f="";return Object.keys(h).forEach(function(m){var p=h[m];m=m.replace(/[A-Z]/g,function(g){return"-"+g.toLowerCase()}),f+=m+":"+p+";"}),f}function o(h){var f=h.dataset,m=[];for(var p in f)m.push({name:"data-"+p,value:f[p]});return m.length?l(m):""}function l(h){var f=[];return h.forEach(function(m){var p=m.name,g=m.value;p==="style"&&(g=a(g)),f.push(p+'="'+c(g)+'"')}),f.length?" "+f.join(" "):""}function d(h){var f=[];for(var m in h)n(h,m)&&f.push({name:m,value:h[m]});for(var p in h._attributes)for(var g in h._attributes[p]){var E=h._attributes[p][g],y=(E.prefix?E.prefix+":":"")+g;f.push({name:y,value:E.value})}return h.className&&f.push({name:"class",value:h.className}),f.length?l(f):""}function u(h){var f="";return typeof h=="string"?f=h:h&&(f=h.toString()),f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function c(h){return u(h).replace(/"/g,"&quot;")}}),Y0=xt(function(i,e){fs();var t=W0(),r=K0(),s=V0(),n=q0(),a=Yb(),o="http://www.w3.org/1999/xhtml";e.exports=l;function l(d,u,c){if(!hs(this,l))return new l(d);var h=c===void 0?o:c||null;this.tagName=h===o?String(d).toUpperCase():d,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=u||null,this.namespaceURI=h,this._attributes={},this.tagName==="INPUT"&&(this.type="text")}l.prototype.type="DOMElement",l.prototype.nodeType=1,l.prototype.appendChild=function(d){return d.parentNode&&d.parentNode.removeChild(d),this.childNodes.push(d),d.parentNode=this,d},l.prototype.replaceChild=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=this.childNodes.indexOf(u);return u.parentNode=null,this.childNodes[c]=d,d.parentNode=this,u},l.prototype.removeChild=function(d){var u=this.childNodes.indexOf(d);return this.childNodes.splice(u,1),d.parentNode=null,d},l.prototype.insertBefore=function(d,u){d.parentNode&&d.parentNode.removeChild(d);var c=u==null?-1:this.childNodes.indexOf(u);return c>-1?this.childNodes.splice(c,0,d):this.childNodes.push(d),d.parentNode=this,d},l.prototype.setAttributeNS=function(d,u,c){var h=null,f=u,m=u.indexOf(":");if(m>-1&&(h=u.substr(0,m),f=u.substr(m+1)),this.tagName==="INPUT"&&u==="type")this.type=c;else{var p=this._attributes[d]||(this._attributes[d]={});p[f]={value:c,prefix:h}}},l.prototype.getAttributeNS=function(d,u){var c=this._attributes[d],h=c&&c[u]&&c[u].value;return this.tagName==="INPUT"&&u==="type"?this.type:typeof h!="string"?null:h},l.prototype.removeAttributeNS=function(d,u){var c=this._attributes[d];c&&delete c[u]},l.prototype.hasAttributeNS=function(d,u){var c=this._attributes[d];return!!c&&u in c},l.prototype.setAttribute=function(d,u){return this.setAttributeNS(null,d,u)},l.prototype.getAttribute=function(d){return this.getAttributeNS(null,d)},l.prototype.removeAttribute=function(d){return this.removeAttributeNS(null,d)},l.prototype.hasAttribute=function(d){return this.hasAttributeNS(null,d)},l.prototype.removeEventListener=n,l.prototype.addEventListener=s,l.prototype.dispatchEvent=r,l.prototype.focus=function(){},l.prototype.toString=function(){return a(this)},l.prototype.getElementsByClassName=function(d){var u=d.split(" "),c=[];return t(this,function(h){if(h.nodeType===1){var f=h.className||"",m=f.split(" ");u.every(function(p){return m.indexOf(p)!==-1})&&c.push(h)}}),c},l.prototype.getElementsByTagName=function(d){d=d.toLowerCase();var u=[];return t(this.childNodes,function(c){c.nodeType===1&&(d==="*"||c.tagName.toLowerCase()===d)&&u.push(c)}),u},l.prototype.contains=function(d){return t(this,function(u){return d===u})||!1}}),jb=xt(function(i,e){fs();var t=Y0();e.exports=r;function r(s){if(!hs(this,r))return new r;this.childNodes=[],this.parentNode=null,this.ownerDocument=s||null}r.prototype.type="DocumentFragment",r.prototype.nodeType=11,r.prototype.nodeName="#document-fragment",r.prototype.appendChild=t.prototype.appendChild,r.prototype.replaceChild=t.prototype.replaceChild,r.prototype.removeChild=t.prototype.removeChild,r.prototype.toString=function(){return this.childNodes.map(function(s){return String(s)}).join("")}}),zb=xt(function(i,e){e.exports=t;function t(r){}t.prototype.initEvent=function(r,s,n){this.type=r,this.bubbles=s,this.cancelable=n},t.prototype.preventDefault=function(){}}),Xb=xt(function(i,e){fs();var t=W0(),r=Vb(),s=qb(),n=Y0(),a=jb(),o=zb(),l=K0(),d=V0(),u=q0();e.exports=c;function c(){if(!hs(this,c))return new c;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var h=c.prototype;h.createTextNode=function(f){return new s(f,this)},h.createElementNS=function(f,m){var p=f===null?null:String(f);return new n(m,this,p)},h.createElement=function(f){return new n(f,this)},h.createDocumentFragment=function(){return new a(this)},h.createEvent=function(f){return new o(f)},h.createComment=function(f){return new r(f,this)},h.getElementById=function(f){f=String(f);var m=t(this.childNodes,function(p){if(String(p.id)===f)return p});return m||null},h.getElementsByClassName=n.prototype.getElementsByClassName,h.getElementsByTagName=n.prototype.getElementsByTagName,h.contains=n.prototype.contains,h.removeEventListener=u,h.addEventListener=d,h.dispatchEvent=l}),Qb=xt(function(i,e){var t=Xb();e.exports=new t}),Zb=xt(function(i,e){var t=typeof global<"u"?global:typeof window<"u"?window:{},r=Qb(),s;typeof document<"u"?s=document:(s=t["__GLOBAL_DOCUMENT_CACHE@4"],s||(s=t["__GLOBAL_DOCUMENT_CACHE@4"]=r)),e.exports=s});function Jb(i){if(Array.isArray(i))return i}function eT(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var r=[],s=!0,n=!1,a,o;try{for(t=t.call(i);!(s=(a=t.next()).done)&&(r.push(a.value),!(e&&r.length===e));s=!0);}catch(l){n=!0,o=l}finally{try{!s&&t.return!=null&&t.return()}finally{if(n)throw o}}return r}}function tT(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Hu(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=i[t];return r}function j0(i,e){if(i){if(typeof i=="string")return Hu(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Hu(i,e)}}function Wi(i,e){return Jb(i)||eT(i,e)||j0(i,e)||tT()}var ga=Qt(Li()),ka=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var e=Math.random()*16|0,t=i==="x"?e:e&3|8;return t.toString(16)})},z0=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},xr=function(i){if(i&&typeof i.nodeName<"u")return i.muxId||(i.muxId=z0()),i.muxId;var e;try{e=document.querySelector(i)}catch{}return e&&!e.muxId&&(e.muxId=i),(e==null?void 0:e.muxId)||i},Wu=function(i){var e;i&&typeof i.nodeName<"u"?(e=i,i=xr(e)):e=document.querySelector(i);var t=e&&e.nodeName?e.nodeName.toLowerCase():"";return[e,i,t]};function iT(i){if(Array.isArray(i))return Hu(i)}function rT(i){if(typeof Symbol<"u"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function sT(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
3
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zt(i){return iT(i)||rT(i)||j0(i)||sT()}var Yr={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},nT=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:3,t,r,s,n,a,o=[console,i],l=(t=console.trace).bind.apply(t,Zt(o)),d=(r=console.info).bind.apply(r,Zt(o)),u=(s=console.debug).bind.apply(s,Zt(o)),c=(n=console.warn).bind.apply(n,Zt(o)),h=(a=console.error).bind.apply(a,Zt(o)),f=e;return{trace:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Yr.TRACE))return l.apply(void 0,Zt(p))},debug:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Yr.DEBUG))return u.apply(void 0,Zt(p))},info:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Yr.INFO))return d.apply(void 0,Zt(p))},warn:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Yr.WARN))return c.apply(void 0,Zt(p))},error:function(){for(var m=arguments.length,p=new Array(m),g=0;g<m;g++)p[g]=arguments[g];if(!(f>Yr.ERROR))return h.apply(void 0,Zt(p))},get level(){return f},set level(m){m!==this.level&&(f=m??e)}}},Pe=nT("[mux]"),jd=Qt(Li());function Ku(){var i=jd.default.doNotTrack||jd.default.navigator&&jd.default.navigator.doNotTrack;return i==="1"}var aT=Qt(Li()),oT={now:function(){var i=aT.default.performance,e=i&&i.timing,t=e&&e.navigationStart,r=typeof t=="number"&&typeof i.now=="function"?t+i.now():Date.now();return Math.round(r)}},Xe=oT;function se(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}fs();function ut(i,e){if(!hs(i,e))throw new TypeError("Cannot call a class as a function")}function lT(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,r.key,r)}}function Ii(i,e,t){return e&&lT(i.prototype,e),i}function B(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Vu(i,e){return Vu=Object.setPrototypeOf||function(t,r){return t.__proto__=r,t},Vu(i,e)}function dT(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&Vu(i,e)}function Kl(i){return Kl=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Kl(i)}function uT(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}$h();function cT(i,e){return e&&(Uh(e)==="object"||typeof e=="function")?e:se(i)}function hT(i){var e=uT();return function(){var t=Kl(i),r;if(e){var s=Kl(this).constructor;r=Reflect.construct(t,arguments,s)}else r=t.apply(this,arguments);return cT(this,r)}}var qt=function(i){return La(i)[0]},La=function(i){if(typeof i!="string"||i==="")return["localhost"];var e=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,t=i.match(e)||[],r=t[4],s;return r&&(s=(r.match(/[^\.]+\.[^\.]+$/)||[])[0]),[r,s]},zd=Qt(Li()),fT={exists:function(){var i=zd.default.performance,e=i&&i.timing;return e!==void 0},domContentLoadedEventEnd:function(){var i=zd.default.performance,e=i&&i.timing;return e&&e.domContentLoadedEventEnd},navigationStart:function(){var i=zd.default.performance,e=i&&i.timing;return e&&e.navigationStart}},Vl=fT;function He(i,e,t){t=t===void 0?1:t,i[e]=i[e]||0,i[e]+=t}function ql(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{},r=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(r=r.concat(Object.getOwnPropertySymbols(t).filter(function(s){return Object.getOwnPropertyDescriptor(t,s).enumerable}))),r.forEach(function(s){B(i,s,t[s])})}return i}function mT(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);t.push.apply(t,r)}return t}function Bh(i,e){return e=e??{},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):mT(Object(e)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(e,t))}),i}var pT=["x-cdn","content-type"],X0=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],gT=pT.concat(X0);function Gh(i){i=i||"";var e={},t=i.trim().split(/[\r\n]+/);return t.forEach(function(r){if(r){var s=r.split(": "),n=s.shift();n&&(gT.indexOf(n.toLowerCase())>=0||n.toLowerCase().indexOf("x-litix-")===0)&&(e[n]=s.join(": "))}}),e}function Yl(i){if(i){var e=X0.find(function(t){return i[t]!==void 0});return e?i[e]:void 0}}var vT=function(i){var e={};for(var t in i){var r=i[t],s=r["DATA-ID"].search("io.litix.data.");if(s!==-1){var n=r["DATA-ID"].replace("io.litix.data.","");e[n]=r.VALUE}}return e},Q0=vT,Xa=function(i){if(!i)return{};var e=Vl.navigationStart(),t=i.loading,r=t?t.start:i.trequest,s=t?t.first:i.tfirst,n=t?t.end:i.tload;return{bytesLoaded:i.total,requestStart:Math.round(e+r),responseStart:Math.round(e+s),responseEnd:Math.round(e+n)}},Ln=function(i){if(!(!i||typeof i.getAllResponseHeaders!="function"))return Gh(i.getAllResponseHeaders())},ET=function(i,e,t){var r=arguments.length>4?arguments[4]:void 0,s=i.log,n=i.utils.secondsToMs,a=function(g){var E=parseInt(r.version),y;return E===1&&g.programDateTime!==null&&(y=g.programDateTime),E===0&&g.pdt!==null&&(y=g.pdt),y};if(!Vl.exists()){s.warn("performance timing not supported. Not tracking HLS.js.");return}var o=function(g,E){return i.emit(e,g,E)},l=function(g,E){var y=E.levels,b=E.audioTracks,S=E.url,_=E.stats,x=E.networkDetails,A=E.sessionData,C={},O={};y.forEach(function(V,q){C[q]={width:V.width,height:V.height,bitrate:V.bitrate,attrs:V.attrs}}),b.forEach(function(V,q){O[q]={name:V.name,language:V.lang,bitrate:V.bitrate}});var L=Xa(_),M=L.bytesLoaded,K=L.requestStart,U=L.responseStart,z=L.responseEnd;o("requestcompleted",Bh(ql({},Q0(A)),{request_event_type:g,request_bytes_loaded:M,request_start:K,request_response_start:U,request_response_end:z,request_type:"manifest",request_hostname:qt(S),request_response_headers:Ln(x),request_rendition_lists:{media:C,audio:O,video:{}}}))};t.on(r.Events.MANIFEST_LOADED,l);var d=function(g,E){var y=E.details,b=E.level,S=E.networkDetails,_=E.stats,x=Xa(_),A=x.bytesLoaded,C=x.requestStart,O=x.responseStart,L=x.responseEnd,M=y.fragments[y.fragments.length-1],K=a(M)+n(M.duration);o("requestcompleted",{request_event_type:g,request_bytes_loaded:A,request_start:C,request_response_start:O,request_response_end:L,request_current_level:b,request_type:"manifest",request_hostname:qt(y.url),request_response_headers:Ln(S),video_holdback:y.holdBack&&n(y.holdBack),video_part_holdback:y.partHoldBack&&n(y.partHoldBack),video_part_target_duration:y.partTarget&&n(y.partTarget),video_target_duration:y.targetduration&&n(y.targetduration),video_source_is_live:y.live,player_manifest_newest_program_time:isNaN(K)?void 0:K})};t.on(r.Events.LEVEL_LOADED,d);var u=function(g,E){var y=E.details,b=E.networkDetails,S=E.stats,_=Xa(S),x=_.bytesLoaded,A=_.requestStart,C=_.responseStart,O=_.responseEnd;o("requestcompleted",{request_event_type:g,request_bytes_loaded:x,request_start:A,request_response_start:C,request_response_end:O,request_type:"manifest",request_hostname:qt(y.url),request_response_headers:Ln(b)})};t.on(r.Events.AUDIO_TRACK_LOADED,u);var c=function(g,E){var y=E.stats,b=E.networkDetails,S=E.frag;y=y||S.stats;var _=Xa(y),x=_.bytesLoaded,A=_.requestStart,C=_.responseStart,O=_.responseEnd,L=b?Ln(b):void 0,M={request_event_type:g,request_bytes_loaded:x,request_start:A,request_response_start:C,request_response_end:O,request_hostname:b?qt(b.responseURL):void 0,request_id:L?Yl(L):void 0,request_response_headers:L,request_media_duration:S.duration,request_url:b==null?void 0:b.responseURL};S.type==="main"?(M.request_type="media",M.request_current_level=S.level,M.request_video_width=(t.levels[S.level]||{}).width,M.request_video_height=(t.levels[S.level]||{}).height,M.request_labeled_bitrate=(t.levels[S.level]||{}).bitrate):M.request_type=S.type,o("requestcompleted",M)};t.on(r.Events.FRAG_LOADED,c);var h=function(g,E){var y=E.frag,b=y.start,S=a(y),_={currentFragmentPDT:S,currentFragmentStart:n(b)};o("fragmentchange",_)};t.on(r.Events.FRAG_CHANGED,h);var f=function(g,E){var y=E.type,b=E.details,S=E.response,_=E.fatal,x=E.frag,A=E.networkDetails,C=(x==null?void 0:x.url)||E.url||"",O=A?Ln(A):void 0;if((b===r.ErrorDetails.MANIFEST_LOAD_ERROR||b===r.ErrorDetails.MANIFEST_LOAD_TIMEOUT||b===r.ErrorDetails.FRAG_LOAD_ERROR||b===r.ErrorDetails.FRAG_LOAD_TIMEOUT||b===r.ErrorDetails.LEVEL_LOAD_ERROR||b===r.ErrorDetails.LEVEL_LOAD_TIMEOUT||b===r.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||b===r.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT||b===r.ErrorDetails.SUBTITLE_LOAD_ERROR||b===r.ErrorDetails.SUBTITLE_LOAD_TIMEOUT||b===r.ErrorDetails.KEY_LOAD_ERROR||b===r.ErrorDetails.KEY_LOAD_TIMEOUT)&&o("requestfailed",{request_error:b,request_url:C,request_hostname:qt(C),request_id:O?Yl(O):void 0,request_type:b===r.ErrorDetails.FRAG_LOAD_ERROR||b===r.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":b===r.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||b===r.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":b===r.ErrorDetails.SUBTITLE_LOAD_ERROR||b===r.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":b===r.ErrorDetails.KEY_LOAD_ERROR||b===r.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:S==null?void 0:S.code,request_error_text:S==null?void 0:S.text}),_){var L,M="".concat(C?"url: ".concat(C,`
4
4
  `):"")+"".concat(S&&(S.code||S.text)?"response: ".concat(S.code,", ").concat(S.text,`
5
5
  `):"")+"".concat(E.reason?"failure reason: ".concat(E.reason,`
6
6
  `):"")+"".concat(E.level?"level: ".concat(E.level,`
@@ -9,51 +9,51 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
9
9
  `):"")+"".concat(E.error?"error: ".concat(E.error,`
10
10
  `):"")+"".concat(E.event?"event: ".concat(E.event,`
11
11
  `):"")+"".concat(E.err?"error message: ".concat((L=E.err)===null||L===void 0?void 0:L.message,`
12
- `):"");o("error",{player_error_code:y,player_error_message:b,player_error_context:M})}};t.on(r.Events.ERROR,f);var m=function(g,E){var y=E.frag,b=y&&y._url||"";o("requestcanceled",{request_event_type:g,request_url:b,request_type:"media",request_hostname:qt(b)})};t.on(r.Events.FRAG_LOAD_EMERGENCY_ABORTED,m);var p=function(g,E){var y=E.level,b=t.levels[y];if(b&&b.attrs&&b.attrs.BANDWIDTH){var S=b.attrs.BANDWIDTH,_,x=parseFloat(b.attrs["FRAME-RATE"]);isNaN(x)||(_=x),S?o("renditionchange",{video_source_fps:_,video_source_bitrate:S,video_source_width:b.width,video_source_height:b.height,video_source_rendition_name:b.name,video_source_codec:b==null?void 0:b.videoCodec}):s.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};t.on(r.Events.LEVEL_SWITCHED,p),t._stopMuxMonitor=function(){t.off(r.Events.MANIFEST_LOADED,l),t.off(r.Events.LEVEL_LOADED,d),t.off(r.Events.AUDIO_TRACK_LOADED,u),t.off(r.Events.FRAG_LOADED,c),t.off(r.Events.FRAG_CHANGED,h),t.off(r.Events.ERROR,f),t.off(r.Events.FRAG_LOAD_EMERGENCY_ABORTED,m),t.off(r.Events.LEVEL_SWITCHED,p),t.off(r.Events.DESTROYING,t._stopMuxMonitor),delete t._stopMuxMonitor},t.on(r.Events.DESTROYING,t._stopMuxMonitor)},vT=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},lm=function(i,e){if(!i||!i.requestEndDate)return{};var t=qt(i.url),r=i.url,s=i.bytesLoaded,n=new Date(i.requestStartDate).getTime(),a=new Date(i.firstByteDate).getTime(),o=new Date(i.requestEndDate).getTime(),l=isNaN(i.duration)?0:i.duration,d=typeof e.getMetricsFor=="function"?e.getMetricsFor(i.mediaType).HttpList:e.getDashMetrics().getHttpRequests(i.mediaType),u;d.length>0&&(u=$h(d[d.length-1]._responseHeaders||""));var c=u?Vl(u):void 0;return{requestStart:n,requestResponseStart:a,requestResponseEnd:o,requestBytesLoaded:s,requestResponseHeaders:u,requestMediaDuration:l,requestHostname:t,requestUrl:r,requestId:c}},ET=function(i,e){var t=e.getQualityFor(i),r=e.getCurrentTrackFor(i).bitrateList;return r?{currentLevel:t,renditionWidth:r[t].width||null,renditionHeight:r[t].height||null,renditionBitrate:r[t].bandwidth}:{}},yT=function(i){var e;return(e=i.match(/.*codecs\*?="(.*)"/))===null||e===void 0?void 0:e[1]},bT=function(i){try{var e,t,r=(t=i.getVersion)===null||t===void 0||(e=t.call(i))===null||e===void 0?void 0:e.split(".").map(function(s){return parseInt(s)})[0];return r}catch{return!1}},TT=function(i,e,t){var r=i.log;if(!t||!t.on){r.warn("Invalid dash.js player reference. Monitoring blocked.");return}var s=bT(t),n=function(y,b){return i.emit(e,y,b)},a=function(y){var b=y.type,S=y.data,_=(S||{}).url;n("requestcompleted",{request_event_type:b,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:qt(_),request_url:_})};t.on("manifestLoaded",a);var o={},l=function(y){if(typeof y.getRequests!="function")return null;var b=y.getRequests({state:"executed"});return b.length===0?null:b[b.length-1]},d=function(y){var b=y.type,S=y.fragmentModel,_=y.chunk,x=l(S);u({type:b,request:x,chunk:_})},u=function(y){var b=y.type,S=y.chunk,_=y.request,x=(S||{}).mediaInfo,A=x||{},C=A.type,O=A.bitrateList;O=O||[];var L={};O.forEach(function($,te){L[te]={},L[te].width=$.width,L[te].height=$.height,L[te].bitrate=$.bandwidth,L[te].attrs={}}),C==="video"?o.video=L:C==="audio"?o.audio=L:o.media=L;var M=lm(_,t),K=M.requestStart,U=M.requestResponseStart,z=M.requestResponseEnd,V=M.requestResponseHeaders,q=M.requestMediaDuration,ae=M.requestHostname,ne=M.requestUrl,G=M.requestId;n("requestcompleted",{request_event_type:b,request_start:K,request_response_start:U,request_response_end:z,request_bytes_loaded:-1,request_type:C+"_init",request_response_headers:V,request_hostname:ae,request_id:G,request_url:ne,request_media_duration:q,request_rendition_lists:o})};s>=4?t.on("initFragmentLoaded",u):t.on("initFragmentLoaded",d);var c=function(y){var b=y.type,S=y.fragmentModel,_=y.chunk,x=l(S);h({type:b,request:x,chunk:_})},h=function(y){var b=y.type,S=y.chunk,_=y.request,x=S||{},A=x.mediaInfo,C=x.start,O=A||{},L=O.type,M=lm(_,t),K=M.requestStart,U=M.requestResponseStart,z=M.requestResponseEnd,V=M.requestBytesLoaded,q=M.requestResponseHeaders,ae=M.requestMediaDuration,ne=M.requestHostname,G=M.requestUrl,$=M.requestId,te=ET(L,t),re=te.currentLevel,oe=te.renditionWidth,pe=te.renditionHeight,Re=te.renditionBitrate;n("requestcompleted",{request_event_type:b,request_start:K,request_response_start:U,request_response_end:z,request_bytes_loaded:V,request_type:L,request_response_headers:q,request_hostname:ne,request_id:$,request_url:G,request_media_start_time:C,request_media_duration:ae,request_current_level:re,request_labeled_bitrate:Re,request_video_width:oe,request_video_height:pe})};s>=4?t.on("mediaFragmentLoaded",h):t.on("mediaFragmentLoaded",c);var f={video:void 0,audio:void 0,totalBitrate:void 0},m=function(){if(f.video&&typeof f.video.bitrate=="number"){if(!(f.video.width&&f.video.height)){r.warn("have bitrate info for video but missing width/height");return}var y=f.video.bitrate;if(f.audio&&typeof f.audio.bitrate=="number"&&(y+=f.audio.bitrate),y!==f.totalBitrate)return f.totalBitrate=y,{video_source_bitrate:y,video_source_height:f.video.height,video_source_width:f.video.width,video_source_codec:yT(f.video.codec)}}},p=function(y,b,S){if(typeof y.newQuality!="number"){r.warn("missing evt.newQuality in qualityChangeRendered event",y);return}var _=y.mediaType;if(_==="audio"||_==="video"){var x=t.getBitrateInfoListFor(_).find(function(C){var O=C.qualityIndex;return O===y.newQuality});if(!(x&&typeof x.bitrate=="number")){r.warn("missing bitrate info for ".concat(_));return}f[_]=Uh(Kl({},x),{codec:t.getCurrentTrackFor(_).codec});var A=m();A&&n("renditionchange",A)}};t.on("qualityChangeRendered",p);var g=function(y){var b=y.request,S=y.mediaType;b=b||{},n("requestcanceled",{request_event_type:b.type+"_"+b.action,request_url:b.url,request_type:S,request_hostname:qt(b.url)})};t.on("fragmentLoadingAbandoned",g);var E=function(y){var b=y.error,S,_,x=(b==null||(S=b.data)===null||S===void 0?void 0:S.request)||{},A=(b==null||(_=b.data)===null||_===void 0?void 0:_.response)||{};(b==null?void 0:b.code)===27&&n("requestfailed",{request_error:x.type+"_"+x.action,request_url:x.url,request_hostname:qt(x.url),request_type:x.mediaType,request_error_code:A.status,request_error_text:A.statusText});var C="".concat(x!=null&&x.url?"url: ".concat(x.url,`
12
+ `):"");o("error",{player_error_code:y,player_error_message:b,player_error_context:M})}};t.on(r.Events.ERROR,f);var m=function(g,E){var y=E.frag,b=y&&y._url||"";o("requestcanceled",{request_event_type:g,request_url:b,request_type:"media",request_hostname:qt(b)})};t.on(r.Events.FRAG_LOAD_EMERGENCY_ABORTED,m);var p=function(g,E){var y=E.level,b=t.levels[y];if(b&&b.attrs&&b.attrs.BANDWIDTH){var S=b.attrs.BANDWIDTH,_,x=parseFloat(b.attrs["FRAME-RATE"]);isNaN(x)||(_=x),S?o("renditionchange",{video_source_fps:_,video_source_bitrate:S,video_source_width:b.width,video_source_height:b.height,video_source_rendition_name:b.name,video_source_codec:b==null?void 0:b.videoCodec}):s.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};t.on(r.Events.LEVEL_SWITCHED,p),t._stopMuxMonitor=function(){t.off(r.Events.MANIFEST_LOADED,l),t.off(r.Events.LEVEL_LOADED,d),t.off(r.Events.AUDIO_TRACK_LOADED,u),t.off(r.Events.FRAG_LOADED,c),t.off(r.Events.FRAG_CHANGED,h),t.off(r.Events.ERROR,f),t.off(r.Events.FRAG_LOAD_EMERGENCY_ABORTED,m),t.off(r.Events.LEVEL_SWITCHED,p),t.off(r.Events.DESTROYING,t._stopMuxMonitor),delete t._stopMuxMonitor},t.on(r.Events.DESTROYING,t._stopMuxMonitor)},yT=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},um=function(i,e){if(!i||!i.requestEndDate)return{};var t=qt(i.url),r=i.url,s=i.bytesLoaded,n=new Date(i.requestStartDate).getTime(),a=new Date(i.firstByteDate).getTime(),o=new Date(i.requestEndDate).getTime(),l=isNaN(i.duration)?0:i.duration,d=typeof e.getMetricsFor=="function"?e.getMetricsFor(i.mediaType).HttpList:e.getDashMetrics().getHttpRequests(i.mediaType),u;d.length>0&&(u=Gh(d[d.length-1]._responseHeaders||""));var c=u?Yl(u):void 0;return{requestStart:n,requestResponseStart:a,requestResponseEnd:o,requestBytesLoaded:s,requestResponseHeaders:u,requestMediaDuration:l,requestHostname:t,requestUrl:r,requestId:c}},bT=function(i,e){var t=e.getQualityFor(i),r=e.getCurrentTrackFor(i).bitrateList;return r?{currentLevel:t,renditionWidth:r[t].width||null,renditionHeight:r[t].height||null,renditionBitrate:r[t].bandwidth}:{}},TT=function(i){var e;return(e=i.match(/.*codecs\*?="(.*)"/))===null||e===void 0?void 0:e[1]},_T=function(i){try{var e,t,r=(t=i.getVersion)===null||t===void 0||(e=t.call(i))===null||e===void 0?void 0:e.split(".").map(function(s){return parseInt(s)})[0];return r}catch{return!1}},AT=function(i,e,t){var r=i.log;if(!t||!t.on){r.warn("Invalid dash.js player reference. Monitoring blocked.");return}var s=_T(t),n=function(y,b){return i.emit(e,y,b)},a=function(y){var b=y.type,S=y.data,_=(S||{}).url;n("requestcompleted",{request_event_type:b,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:qt(_),request_url:_})};t.on("manifestLoaded",a);var o={},l=function(y){if(typeof y.getRequests!="function")return null;var b=y.getRequests({state:"executed"});return b.length===0?null:b[b.length-1]},d=function(y){var b=y.type,S=y.fragmentModel,_=y.chunk,x=l(S);u({type:b,request:x,chunk:_})},u=function(y){var b=y.type,S=y.chunk,_=y.request,x=(S||{}).mediaInfo,A=x||{},C=A.type,O=A.bitrateList;O=O||[];var L={};O.forEach(function($,te){L[te]={},L[te].width=$.width,L[te].height=$.height,L[te].bitrate=$.bandwidth,L[te].attrs={}}),C==="video"?o.video=L:C==="audio"?o.audio=L:o.media=L;var M=um(_,t),K=M.requestStart,U=M.requestResponseStart,z=M.requestResponseEnd,V=M.requestResponseHeaders,q=M.requestMediaDuration,ae=M.requestHostname,ne=M.requestUrl,G=M.requestId;n("requestcompleted",{request_event_type:b,request_start:K,request_response_start:U,request_response_end:z,request_bytes_loaded:-1,request_type:C+"_init",request_response_headers:V,request_hostname:ae,request_id:G,request_url:ne,request_media_duration:q,request_rendition_lists:o})};s>=4?t.on("initFragmentLoaded",u):t.on("initFragmentLoaded",d);var c=function(y){var b=y.type,S=y.fragmentModel,_=y.chunk,x=l(S);h({type:b,request:x,chunk:_})},h=function(y){var b=y.type,S=y.chunk,_=y.request,x=S||{},A=x.mediaInfo,C=x.start,O=A||{},L=O.type,M=um(_,t),K=M.requestStart,U=M.requestResponseStart,z=M.requestResponseEnd,V=M.requestBytesLoaded,q=M.requestResponseHeaders,ae=M.requestMediaDuration,ne=M.requestHostname,G=M.requestUrl,$=M.requestId,te=bT(L,t),re=te.currentLevel,oe=te.renditionWidth,pe=te.renditionHeight,Re=te.renditionBitrate;n("requestcompleted",{request_event_type:b,request_start:K,request_response_start:U,request_response_end:z,request_bytes_loaded:V,request_type:L,request_response_headers:q,request_hostname:ne,request_id:$,request_url:G,request_media_start_time:C,request_media_duration:ae,request_current_level:re,request_labeled_bitrate:Re,request_video_width:oe,request_video_height:pe})};s>=4?t.on("mediaFragmentLoaded",h):t.on("mediaFragmentLoaded",c);var f={video:void 0,audio:void 0,totalBitrate:void 0},m=function(){if(f.video&&typeof f.video.bitrate=="number"){if(!(f.video.width&&f.video.height)){r.warn("have bitrate info for video but missing width/height");return}var y=f.video.bitrate;if(f.audio&&typeof f.audio.bitrate=="number"&&(y+=f.audio.bitrate),y!==f.totalBitrate)return f.totalBitrate=y,{video_source_bitrate:y,video_source_height:f.video.height,video_source_width:f.video.width,video_source_codec:TT(f.video.codec)}}},p=function(y,b,S){if(typeof y.newQuality!="number"){r.warn("missing evt.newQuality in qualityChangeRendered event",y);return}var _=y.mediaType;if(_==="audio"||_==="video"){var x=t.getBitrateInfoListFor(_).find(function(C){var O=C.qualityIndex;return O===y.newQuality});if(!(x&&typeof x.bitrate=="number")){r.warn("missing bitrate info for ".concat(_));return}f[_]=Bh(ql({},x),{codec:t.getCurrentTrackFor(_).codec});var A=m();A&&n("renditionchange",A)}};t.on("qualityChangeRendered",p);var g=function(y){var b=y.request,S=y.mediaType;b=b||{},n("requestcanceled",{request_event_type:b.type+"_"+b.action,request_url:b.url,request_type:S,request_hostname:qt(b.url)})};t.on("fragmentLoadingAbandoned",g);var E=function(y){var b=y.error,S,_,x=(b==null||(S=b.data)===null||S===void 0?void 0:S.request)||{},A=(b==null||(_=b.data)===null||_===void 0?void 0:_.response)||{};(b==null?void 0:b.code)===27&&n("requestfailed",{request_error:x.type+"_"+x.action,request_url:x.url,request_hostname:qt(x.url),request_type:x.mediaType,request_error_code:A.status,request_error_text:A.statusText});var C="".concat(x!=null&&x.url?"url: ".concat(x.url,`
13
13
  `):"")+"".concat(A!=null&&A.status||A!=null&&A.statusText?"response: ".concat(A==null?void 0:A.status,", ").concat(A==null?void 0:A.statusText,`
14
- `):"");n("error",{player_error_code:b==null?void 0:b.code,player_error_message:b==null?void 0:b.message,player_error_context:C})};t.on("error",E),t._stopMuxMonitor=function(){t.off("manifestLoaded",a),t.off("initFragmentLoaded",u),t.off("mediaFragmentLoaded",h),t.off("qualityChangeRendered",p),t.off("error",E),t.off("fragmentLoadingAbandoned",g),delete t._stopMuxMonitor}},_T=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},dm=0,AT=function(){function i(){ut(this,i),B(this,"_listeners",void 0)}return Ii(i,[{key:"on",value:function(e,t,r){return t._eventEmitterGuid=t._eventEmitterGuid||++dm,this._listeners=this._listeners||{},this._listeners[e]=this._listeners[e]||[],r&&(t=t.bind(r)),this._listeners[e].push(t),t}},{key:"off",value:function(e,t){var r=this._listeners&&this._listeners[e];r&&r.forEach(function(s,n){s._eventEmitterGuid===t._eventEmitterGuid&&r.splice(n,1)})}},{key:"one",value:function(e,t,r){var s=this;t._eventEmitterGuid=t._eventEmitterGuid||++dm;var n=function(){s.off(e,n),t.apply(r||this,arguments)};n._eventEmitterGuid=t._eventEmitterGuid,this.on(e,n)}},{key:"emit",value:function(e,t){var r=this;if(this._listeners){t=t||{};var s=this._listeners["before*"]||[],n=this._listeners[e]||[],a=this._listeners["after"+e]||[],o=function(l,d){l=l.slice(),l.forEach(function(u){u.call(r,{type:e},d)})};o(s,t),o(n,t),o(a,t)}}}]),i}(),ST=AT,jd=Qt(Li()),xT=function(){function i(e){var t=this;ut(this,i),B(this,"_playbackHeartbeatInterval",void 0),B(this,"_playheadShouldBeProgressing",void 0),B(this,"pm",void 0),this.pm=e,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,e.on("playing",function(){t._playheadShouldBeProgressing=!0}),e.on("play",this._startPlaybackHeartbeatInterval.bind(this)),e.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),e.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),e.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("seeked",function(){e.data.player_is_paused?t._stopPlaybackHeartbeatInterval():t._startPlaybackHeartbeatInterval()}),e.on("timeupdate",function(){t._playbackHeartbeatInterval!==null&&e.emit("playbackheartbeat")}),e.on("devicesleep",function(r,s){t._playbackHeartbeatInterval!==null&&(jd.default.clearInterval(t._playbackHeartbeatInterval),e.emit("playbackheartbeatend",{viewer_time:s.viewer_time}),t._playbackHeartbeatInterval=null)})}return Ii(i,[{key:"_startPlaybackHeartbeatInterval",value:function(){var e=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=jd.default.setInterval(function(){e.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(jd.default.clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}]),i}(),kT=xT,LT=function i(e){var t=this;ut(this,i),B(this,"viewErrored",void 0),e.on("viewinit",function(){t.viewErrored=!1}),e.on("error",function(r,s){try{var n=e.errorTranslator({player_error_code:s.player_error_code,player_error_message:s.player_error_message,player_error_context:s.player_error_context,player_error_severity:s.player_error_severity,player_error_business_exception:s.player_error_business_exception});n&&(e.data.player_error_code=n.player_error_code||s.player_error_code,e.data.player_error_message=n.player_error_message||s.player_error_message,e.data.player_error_context=n.player_error_context||s.player_error_context,e.data.player_error_severity=n.player_error_severity||s.player_error_severity,e.data.player_error_business_exception=n.player_error_business_exception||s.player_error_business_exception,t.viewErrored=!0)}catch(a){e.mux.log.warn("Exception in error translator callback.",a),t.viewErrored=!0}}),e.on("aftererror",function(){var r,s,n,a,o;(r=e.data)===null||r===void 0||delete r.player_error_code,(s=e.data)===null||s===void 0||delete s.player_error_message,(n=e.data)===null||n===void 0||delete n.player_error_context,(a=e.data)===null||a===void 0||delete a.player_error_severity,(o=e.data)===null||o===void 0||delete o.player_error_business_exception})},IT=LT,RT=function(){function i(e){ut(this,i),B(this,"_watchTimeTrackerLastCheckedTime",void 0),B(this,"pm",void 0),this.pm=e,this._watchTimeTrackerLastCheckedTime=null,e.on("playbackheartbeat",this._updateWatchTime.bind(this)),e.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}return Ii(i,[{key:"_updateWatchTime",value:function(e,t){var r=t.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=r),He(this.pm.data,"view_watch_time",r-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=r}},{key:"_clearWatchTimeState",value:function(e,t){this._updateWatchTime(e,t),this._watchTimeTrackerLastCheckedTime=null}}]),i}(),wT=RT,CT=function(){function i(e){var t=this;ut(this,i),B(this,"_playbackTimeTrackerLastPlayheadPosition",void 0),B(this,"_lastTime",void 0),B(this,"_isAdPlaying",void 0),B(this,"_callbackUpdatePlaybackTime",void 0),B(this,"pm",void 0),this.pm=e,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=Xe.now(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null;var r=this._startPlaybackTimeTracking.bind(this);e.on("playing",r),e.on("adplaying",r),e.on("seeked",r);var s=this._stopPlaybackTimeTracking.bind(this);e.on("playbackheartbeatend",s),e.on("seeking",s),e.on("adplaying",function(){t._isAdPlaying=!0}),e.on("adended",function(){t._isAdPlaying=!1}),e.on("adpause",function(){t._isAdPlaying=!1}),e.on("adbreakstart",function(){t._isAdPlaying=!1}),e.on("adbreakend",function(){t._isAdPlaying=!1}),e.on("adplay",function(){t._isAdPlaying=!1}),e.on("viewinit",function(){t._playbackTimeTrackerLastPlayheadPosition=-1,t._lastTime=Xe.now(),t._isAdPlaying=!1,t._callbackUpdatePlaybackTime=null})}return Ii(i,[{key:"_startPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime===null&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this.pm.on("playbackheartbeat",this._callbackUpdatePlaybackTime))}},{key:"_stopPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime&&(this._updatePlaybackTime(),this.pm.off("playbackheartbeat",this._callbackUpdatePlaybackTime),this._callbackUpdatePlaybackTime=null,this._playbackTimeTrackerLastPlayheadPosition=-1)}},{key:"_updatePlaybackTime",value:function(){var e=this.pm.data.player_playhead_time,t=Xe.now(),r=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&e>this._playbackTimeTrackerLastPlayheadPosition?r=e-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(r=t-this._lastTime),r>0&&r<=1e3&&He(this.pm.data,"view_content_playback_time",r),this._playbackTimeTrackerLastPlayheadPosition=e,this._lastTime=t}}]),i}(),DT=CT,MT=function(){function i(e){ut(this,i),B(this,"pm",void 0),this.pm=e;var t=this._updatePlayheadTime.bind(this);e.on("playbackheartbeat",t),e.on("playbackheartbeatend",t),e.on("timeupdate",t),e.on("destroy",function(){e.off("timeupdate",t)})}return Ii(i,[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=typeof this.pm.data.view_max_playhead_position>"u"?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(e,t){var r=this,s=function(){r.pm.currentFragmentPDT&&r.pm.currentFragmentStart&&(r.pm.data.player_program_time=r.pm.currentFragmentPDT+r.pm.data.player_playhead_time-r.pm.currentFragmentStart)};if(t&&t.player_playhead_time)this.pm.data.player_playhead_time=t.player_playhead_time,s(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var n=this.pm.getPlayheadTime();typeof n<"u"&&(this.pm.data.player_playhead_time=n,s(),this._updateMaxPlayheadPosition())}}}]),i}(),PT=MT,um=5*60*1e3,OT=function i(e){if(ut(this,i),!e.disableRebufferTracking){var t,r=function(n,a){s(a),t=void 0},s=function(n){if(t){var a=n.viewer_time-t;He(e.data,"view_rebuffer_duration",a),t=n.viewer_time,e.data.view_rebuffer_duration>um&&(e.emit("viewend"),e.send("viewend"),e.mux.log.warn("Ending view after rebuffering for longer than ".concat(um,"ms, future events will be ignored unless a programchange or videochange occurs.")))}e.data.view_watch_time>=0&&e.data.view_rebuffer_count>0&&(e.data.view_rebuffer_frequency=e.data.view_rebuffer_count/e.data.view_watch_time,e.data.view_rebuffer_percentage=e.data.view_rebuffer_duration/e.data.view_watch_time)};e.on("playbackheartbeat",function(n,a){return s(a)}),e.on("rebufferstart",function(n,a){t||(He(e.data,"view_rebuffer_count",1),t=a.viewer_time,e.one("rebufferend",r))}),e.on("viewinit",function(){t=void 0,e.off("rebufferend",r)})}},NT=OT,FT=function(){function i(e){var t=this;ut(this,i),B(this,"_lastCheckedTime",void 0),B(this,"_lastPlayheadTime",void 0),B(this,"_lastPlayheadTimeUpdatedTime",void 0),B(this,"_rebuffering",void 0),B(this,"pm",void 0),this.pm=e,!(e.disableRebufferTracking||e.disablePlayheadRebufferTracking)&&(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,e.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),e.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),e.on("seeking",function(){t._cleanupRebufferTracker(null,{viewer_time:Xe.now()})}))}return Ii(i,[{key:"_checkIfRebuffering",value:function(e,t){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing){this._cleanupRebufferTracker(e,t);return}if(this._lastCheckedTime===null){this._prepareRebufferTrackerState(t.viewer_time);return}if(this._lastPlayheadTime!==this.pm.data.player_playhead_time){this._cleanupRebufferTracker(e,t,!0);return}var r=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&r>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=t.viewer_time}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(e){this._lastCheckedTime=e,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=e}},{key:"_cleanupRebufferTracker",value:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:t.viewer_time});else{if(this._lastCheckedTime===null)return;var s=this.pm.data.player_playhead_time-this._lastPlayheadTime,n=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&s>0&&n-s>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+n-s}))}r?this._prepareRebufferTrackerState(t.viewer_time):this._clearRebufferTrackerState()}}]),i}(),UT=FT,$T=function(){function i(e){var t=this;ut(this,i),B(this,"NAVIGATION_START",void 0),B(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){var r=e.data,s=r.view_id;if(!r.view_program_changed){var n=function(a,o){var l=o.viewer_time;(a.type==="playing"&&typeof e.data.view_time_to_first_frame>"u"||a.type==="adplaying"&&(typeof e.data.view_time_to_first_frame>"u"||t._inPrerollPosition()))&&t.calculateTimeToFirstFrame(l||Xe.now(),s)};e.one("playing",n),e.one("adplaying",n),e.one("viewend",function(){e.off("playing",n),e.off("adplaying",n)})}})}return Ii(i,[{key:"_inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time>"u"||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(e,t){t===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:e}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}]),i}(),BT=$T,GT=function i(e){var t=this;ut(this,i),B(this,"_lastPlayerHeight",void 0),B(this,"_lastPlayerWidth",void 0),B(this,"_lastPlayheadPosition",void 0),B(this,"_lastSourceHeight",void 0),B(this,"_lastSourceWidth",void 0),e.on("viewinit",function(){t._lastPlayheadPosition=-1});var r=["pause","rebufferstart","seeking","error","adbreakstart","hb"],s=["playing","hb"];r.forEach(function(n){e.on(n,function(){if(t._lastPlayheadPosition>=0&&e.data.player_playhead_time>=0&&t._lastPlayerWidth>=0&&t._lastSourceWidth>0&&t._lastPlayerHeight>=0&&t._lastSourceHeight>0){var a=e.data.player_playhead_time-t._lastPlayheadPosition;if(a<0){t._lastPlayheadPosition=-1;return}var o=Math.min(t._lastPlayerWidth/t._lastSourceWidth,t._lastPlayerHeight/t._lastSourceHeight),l=Math.max(0,o-1),d=Math.max(0,1-o);e.data.view_max_upscale_percentage=Math.max(e.data.view_max_upscale_percentage||0,l),e.data.view_max_downscale_percentage=Math.max(e.data.view_max_downscale_percentage||0,d),He(e.data,"view_total_content_playback_time",a),He(e.data,"view_total_upscaling",l*a),He(e.data,"view_total_downscaling",d*a)}t._lastPlayheadPosition=-1})}),s.forEach(function(n){e.on(n,function(){t._lastPlayheadPosition=e.data.player_playhead_time,t._lastPlayerWidth=e.data.player_width,t._lastPlayerHeight=e.data.player_height,t._lastSourceWidth=e.data.video_source_width,t._lastSourceHeight=e.data.video_source_height})})},HT=GT,WT=2e3,KT=function i(e){var t=this;ut(this,i),B(this,"isSeeking",void 0),this.isSeeking=!1;var r=-1,s=function(){var n=Xe.now(),a=(e.data.viewer_time||n)-(r||n);He(e.data,"view_seek_duration",a),e.data.view_max_seek_time=Math.max(e.data.view_max_seek_time||0,a),t.isSeeking=!1,r=-1};e.on("seeking",function(n,a){if(Object.assign(e.data,a),t.isSeeking&&a.viewer_time-r<=WT){r=a.viewer_time;return}t.isSeeking&&s(),t.isSeeking=!0,r=a.viewer_time,He(e.data,"view_seek_count",1),e.send("seeking")}),e.on("seeked",function(){s()}),e.on("viewend",function(){t.isSeeking&&(s(),e.send("seeked")),t.isSeeking=!1,r=-1})},VT=KT,cm=function(i,e){i.push(e),i.sort(function(t,r){return t.viewer_time-r.viewer_time})},qT=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],YT=function(){function i(e){var t=this;ut(this,i),B(this,"_adHasPlayed",void 0),B(this,"_adRequests",void 0),B(this,"_adResponses",void 0),B(this,"_currentAdRequestNumber",void 0),B(this,"_currentAdResponseNumber",void 0),B(this,"_prerollPlayTime",void 0),B(this,"_wouldBeNewAdPlay",void 0),B(this,"isAdBreak",void 0),B(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){t.isAdBreak=!1,t._currentAdRequestNumber=0,t._currentAdResponseNumber=0,t._adRequests=[],t._adResponses=[],t._adHasPlayed=!1,t._wouldBeNewAdPlay=!0,t._prerollPlayTime=void 0}),qT.forEach(function(s){return e.on(s,t._updateAdData.bind(t))});var r=function(){t.isAdBreak=!1};e.on("adbreakstart",function(){t.isAdBreak=!0}),e.on("play",r),e.on("playing",r),e.on("viewend",r),e.on("adrequest",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdRequestNumber++},n),cm(t._adRequests,n),He(e.data,"view_ad_request_count"),t.inPrerollPosition()&&(e.data.view_preroll_requested=!0,t._adHasPlayed||He(e.data,"view_preroll_request_count"))}),e.on("adresponse",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdResponseNumber++},n),cm(t._adResponses,n);var a=t.findAdRequest(n.ad_request_id);a&&He(e.data,"view_ad_request_time",Math.max(0,n.viewer_time-a.viewer_time))}),e.on("adplay",function(s,n){t._adHasPlayed=!0,t._wouldBeNewAdPlay&&(t._wouldBeNewAdPlay=!1,He(e.data,"view_ad_played_count")),t.inPrerollPosition()&&!e.data.view_preroll_played&&(e.data.view_preroll_played=!0,t._adRequests.length>0&&(e.data.view_preroll_request_time=Math.max(0,n.viewer_time-t._adRequests[0].viewer_time)),e.data.view_start&&(e.data.view_startup_preroll_request_time=Math.max(0,n.viewer_time-e.data.view_start)),t._prerollPlayTime=n.viewer_time)}),e.on("adplaying",function(s,n){t.inPrerollPosition()&&typeof e.data.view_preroll_load_time>"u"&&typeof t._prerollPlayTime<"u"&&(e.data.view_preroll_load_time=n.viewer_time-t._prerollPlayTime,e.data.view_startup_preroll_load_time=n.viewer_time-t._prerollPlayTime)}),e.on("adclicked",function(s,n){t._wouldBeNewAdPlay||He(e.data,"view_ad_clicked_count")}),e.on("adskipped",function(s,n){t._wouldBeNewAdPlay||He(e.data,"view_ad_skipped_count")}),e.on("adended",function(){t._wouldBeNewAdPlay=!0}),e.on("aderror",function(){t._wouldBeNewAdPlay=!0})}return Ii(i,[{key:"inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time>"u"||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(e){for(var t=0;t<this._adRequests.length;t++)if(this._adRequests[t].ad_request_id===e)return this._adRequests[t]}},{key:"_updateAdData",value:function(e,t){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&t.ad_tag_url){var r=Wi(ka(t.ad_tag_url),2),s=r[0],n=r[1];this.pm.data.view_preroll_ad_tag_domain=n,this.pm.data.view_preroll_ad_tag_hostname=s}if(!this.pm.data.view_preroll_ad_asset_hostname&&t.ad_asset_url){var a=Wi(ka(t.ad_asset_url),2),o=a[0],l=a[1];this.pm.data.view_preroll_ad_asset_domain=l,this.pm.data.view_preroll_ad_asset_hostname=o}}this.pm.data.ad_asset_url=t==null?void 0:t.ad_asset_url,this.pm.data.ad_tag_url=t==null?void 0:t.ad_tag_url,this.pm.data.ad_creative_id=t==null?void 0:t.ad_creative_id,this.pm.data.ad_id=t==null?void 0:t.ad_id,this.pm.data.ad_universal_id=t==null?void 0:t.ad_universal_id}}]),i}(),jT=YT,hm=Qt(Li()),zT=function i(e){ut(this,i);var t,r,s=function(){e.disableRebufferTracking||(He(e.data,"view_waiting_rebuffer_count",1),t=Xe.now(),r=hm.default.setInterval(function(){if(t){var d=Xe.now();He(e.data,"view_waiting_rebuffer_duration",d-t),t=d}},250))},n=function(){e.disableRebufferTracking||t&&(He(e.data,"view_waiting_rebuffer_duration",Xe.now()-t),t=!1,hm.default.clearInterval(r))},a=!1,o=function(){a=!0},l=function(){a=!1,n()};e.on("waiting",function(){a&&s()}),e.on("playing",function(){n(),o()}),e.on("pause",l),e.on("seeking",l)},XT=zT,QT=function i(e){var t=this;ut(this,i),B(this,"lastWallClockTime",void 0);var r=function(){t.lastWallClockTime=Xe.now(),e.on("before*",s)},s=function(n){var a=Xe.now(),o=t.lastWallClockTime;t.lastWallClockTime=a,a-o>3e4&&(e.emit("devicesleep",{viewer_time:o}),Object.assign(e.data,{viewer_time:o}),e.send("devicesleep"),e.emit("devicewake",{viewer_time:a}),Object.assign(e.data,{viewer_time:a}),e.send("devicewake"))};e.one("playbackheartbeat",r),e.on("playbackheartbeatend",function(){e.off("before*",s),e.one("playbackheartbeat",r)})},ZT=QT,zd=Qt(Li()),X0=function(i){return i()}(function(){var i=function(){for(var t=0,r={};t<arguments.length;t++){var s=arguments[t];for(var n in s)r[n]=s[n]}return r};function e(t){function r(s,n,a){var o;if(typeof document<"u"){if(arguments.length>1){if(a=i({path:"/"},r.defaults,a),typeof a.expires=="number"){var l=new Date;l.setMilliseconds(l.getMilliseconds()+a.expires*864e5),a.expires=l}try{o=JSON.stringify(n),/^[\{\[]/.test(o)&&(n=o)}catch{}return t.write?n=t.write(n,s):n=encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),s=encodeURIComponent(String(s)),s=s.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),s=s.replace(/[\(\)]/g,escape),document.cookie=[s,"=",n,a.expires?"; expires="+a.expires.toUTCString():"",a.path?"; path="+a.path:"",a.domain?"; domain="+a.domain:"",a.secure?"; secure":""].join("")}s||(o={});for(var d=document.cookie?document.cookie.split("; "):[],u=/(%[0-9A-Z]{2})+/g,c=0;c<d.length;c++){var h=d[c].split("="),f=h.slice(1).join("=");f.charAt(0)==='"'&&(f=f.slice(1,-1));try{var m=h[0].replace(u,decodeURIComponent);if(f=t.read?t.read(f,m):t(f,m)||f.replace(u,decodeURIComponent),this.json)try{f=JSON.parse(f)}catch{}if(s===m){o=f;break}s||(o[m]=f)}catch{}}return o}}return r.set=r,r.get=function(s){return r.call(r,s)},r.getJSON=function(){return r.apply({json:!0},[].slice.call(arguments))},r.defaults={},r.remove=function(s,n){r(s,"",i(n,{expires:-1}))},r.withConverter=e,r}return e(function(){})}),Q0="muxData",JT=function(i){return Object.entries(i).map(function(e){var t=Wi(e,2),r=t[0],s=t[1];return"".concat(r,"=").concat(s)}).join("&")},e_=function(i){return i.split("&").reduce(function(e,t){var r=Wi(t.split("="),2),s=r[0],n=r[1],a=+n,o=n&&a==n?a:n;return e[s]=o,e},{})},Z0=function(){var i;try{i=e_(X0.get(Q0)||"")}catch{i={}}return i},J0=function(i){try{X0.set(Q0,JT(i),{expires:365})}catch{}},t_=function(){var i=Z0();return i.mux_viewer_id=i.mux_viewer_id||xa(),i.msn=i.msn||Math.random(),J0(i),{mux_viewer_id:i.mux_viewer_id,mux_sample_number:i.msn}},i_=function(){var i=Z0(),e=Xe.now();return i.session_start&&(i.sst=i.session_start,delete i.session_start),i.session_id&&(i.sid=i.session_id,delete i.session_id),i.session_expires&&(i.sex=i.session_expires,delete i.session_expires),(!i.sex||i.sex<e)&&(i.sid=xa(),i.sst=e),i.sex=e+25*60*1e3,J0(i),{session_id:i.sid,session_start:i.sst,session_expires:i.sex}};function r_(i,e){var t=e.beaconCollectionDomain,r=e.beaconDomain;if(t)return"https://"+t;i=i||"inferred";var s=r||"litix.io";return i.match(/^[a-z0-9]+$/)?"https://"+i+"."+s:"https://img.litix.io/a.gif"}var s_=Qt(Li()),eg=function(){var i;switch(tg()){case"cellular":i="cellular";break;case"ethernet":i="wired";break;case"wifi":i="wifi";break;case void 0:break;default:i="other"}return i},tg=function(){var i=s_.default.navigator,e=i&&(i.connection||i.mozConnection||i.webkitConnection);return e&&e.type};eg.getConnectionFromAPI=tg;var n_=eg,a_={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},o_=ig(a_),l_={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",bz:"business",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",ck:"clicked",cl:"canceled",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",ep:"experiments",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ez:"exception",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",sd:"skipped",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",sy:"severity",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},fm=ig(l_);function ig(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function Ku(i){var e={},t={};return Object.keys(i).forEach(function(r){var s=!1;if(i.hasOwnProperty(r)&&i[r]!==void 0){var n=r.split("_"),a=n[0],o=o_[a];o||(Pe.info("Data key word `"+n[0]+"` not expected in "+r),o=a+"_"),n.splice(1).forEach(function(l){l==="url"&&(s=!0),fm[l]?o+=fm[l]:Number(l)&&Math.floor(Number(l))===Number(l)?o+=l:(Pe.info("Data key word `"+l+"` not expected in "+r),o+="_"+l+"_")}),s?t[o]=i[r]:e[o]=i[r]}}),Object.assign(e,t)}var jr=Qt(Li()),d_={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},u_=56*1024,c_=["hb","requestcompleted","requestfailed","requestcanceled"],h_="https://img.litix.io",Ki=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=i||h_,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},d_,e)};Ki.prototype.queueEvent=function(i,e){var t=Object.assign({},e);return this._eventQueue.length<=this._options.maxQueueLength||i==="eventrateexceeded"?(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):!1};Ki.prototype.flushEvents=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;if(i&&this._eventQueue.length===1){this._eventQueue.pop();return}this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()};Ki.prototype.destroy=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.destroyed=!0,i?this._clearBeaconQueue():this.flushEvents(),jr.default.clearTimeout(this._sendTimeout)};Ki.prototype._clearBeaconQueue=function(){var i=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,e=this._eventQueue.slice(i);i>0&&Object.assign(e[e.length-1],Ku({mux_view_message:"event queue truncated"}));var t=this._createPayload(e);rg(this._beaconUrl,t,!0,function(){})};Ki.prototype._sendBeaconQueue=function(){var i=this;if(!this._postInFlight){var e=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var t=this._createPayload(e),r=Xe.now();rg(this._beaconUrl,t,!1,function(s,n){n?(i._eventQueue=e.concat(i._eventQueue),i._failureCount+=1,Pe.info("Error sending beacon: "+n)):i._failureCount=0,i._roundTripTime=Xe.now()-r,i._postInFlight=!1})}};Ki.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var i=Math.pow(2,this._failureCount-1);return i=i*Math.random(),(1+i)*this._options.baseTimeBetweenBeacons};Ki.prototype._startBeaconSending=function(){var i=this;jr.default.clearTimeout(this._sendTimeout),!this.destroyed&&(this._sendTimeout=jr.default.setTimeout(function(){i._eventQueue.length&&i._sendBeaconQueue(),i._startBeaconSending()},this._getNextBeaconTime()))};Ki.prototype._createPayload=function(i){var e=this,t={transmission_timestamp:Math.round(Xe.now())};this._roundTripTime&&(t.rtt_ms=Math.round(this._roundTripTime));var r,s,n,a=function(){r=JSON.stringify({metadata:t,events:s||i}),n=r.length/1024},o=function(){return n<=e._options.maxPayloadKBSize};return a(),o()||(Pe.info("Payload size is too big ("+n+" kb). Removing unnecessary events."),s=i.filter(function(l){return c_.indexOf(l.e)===-1}),a()),o()||(Pe.info("Payload size still too big ("+n+" kb). Cropping fields.."),s.forEach(function(l){for(var d in l){var u=l[d],c=50*1024;typeof u=="string"&&u.length>c&&(l[d]=u.substring(0,c))}}),a()),r};var f_=function(i){return i.length<=u_},rg=function(i,e,t,r){if(t&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(i,e)){r();return}if(jr.default.fetch){jr.default.fetch(i,{method:"POST",body:e,headers:{"Content-Type":"text/plain"},keepalive:f_(e)}).then(function(n){return r(null,n.ok?null:"Error")}).catch(function(n){return r(null,n)});return}if(jr.default.XMLHttpRequest){var s=new jr.default.XMLHttpRequest;s.onreadystatechange=function(){if(s.readyState===4)return r(null,s.status!==200?"error":void 0)},s.open("POST",i),s.setRequestHeader("Content-Type","text/plain"),s.send(e);return}r()},m_=Ki,p_=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id","player_error_code","player_error_message","player_error_context","player_error_severity","player_error_business_exception"],g_=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],v_=["ad_id","ad_creative_id","ad_universal_id"],E_=["viewstart","error","ended","viewend"],y_=10*60*1e3,b_=function(){function i(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};ut(this,i);var s,n,a,o,l,d,u,c,h,f,m,p;B(this,"mux",void 0),B(this,"envKey",void 0),B(this,"options",void 0),B(this,"eventQueue",void 0),B(this,"sampleRate",void 0),B(this,"disableCookies",void 0),B(this,"respectDoNotTrack",void 0),B(this,"previousBeaconData",void 0),B(this,"lastEventTime",void 0),B(this,"rateLimited",void 0),B(this,"pageLevelData",void 0),B(this,"viewerData",void 0),this.mux=e,this.envKey=t,this.options=r,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.eventQueue=new m_(r_(this.envKey,this.options));var g;this.sampleRate=(g=this.options.sampleRate)!==null&&g!==void 0?g:1;var E;this.disableCookies=(E=this.options.disableCookies)!==null&&E!==void 0?E:!1;var y;this.respectDoNotTrack=(y=this.options.respectDoNotTrack)!==null&&y!==void 0?y:!1,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(s=this.options.platform)===null||s===void 0?void 0:s.name,viewer_application_version:(n=this.options.platform)===null||n===void 0?void 0:n.version,viewer_application_engine:(a=this.options.platform)===null||a===void 0?void 0:a.layout,viewer_device_name:(o=this.options.platform)===null||o===void 0?void 0:o.product,viewer_device_category:"",viewer_device_manufacturer:(l=this.options.platform)===null||l===void 0?void 0:l.manufacturer,viewer_os_family:(u=this.options.platform)===null||u===void 0||(d=u.os)===null||d===void 0?void 0:d.family,viewer_os_architecture:(h=this.options.platform)===null||h===void 0||(c=h.os)===null||c===void 0?void 0:c.architecture,viewer_os_version:(m=this.options.platform)===null||m===void 0||(f=m.os)===null||f===void 0?void 0:f.version,viewer_connection_type:n_(),page_url:zd.default===null||zd.default===void 0||(p=zd.default.location)===null||p===void 0?void 0:p.href},this.viewerData=this.disableCookies?{}:t_()}return Ii(i,[{key:"send",value:function(e,t){if(!(!e||!(t!=null&&t.view_id))){if(this.respectDoNotTrack&&Hu())return Pe.info("Not sending `"+e+"` because Do Not Track is enabled");if(!t||typeof t!="object")return Pe.error("A data object was expected in send() but was not provided");var r=this.disableCookies?{}:i_(),s=Uh(Kl({},this.pageLevelData,t,r,this.viewerData),{event:e,env_key:this.envKey});s.user_id&&(s.viewer_user_id=s.user_id,delete s.user_id);var n,a=((n=s.mux_sample_number)!==null&&n!==void 0?n:0)>=this.sampleRate,o=this._deduplicateBeaconData(e,s),l=Ku(o);if(this.lastEventTime=this.mux.utils.now(),a)return Pe.info("Not sending event due to sample rate restriction",e,s,l);if(this.envKey||Pe.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",e,s,l),!this.rateLimited){if(Pe.info("Sending event",e,s,l),this.rateLimited=!this.eventQueue.queueEvent(e,l),this.mux.WINDOW_UNLOADING&&e==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&e==="hb"?this.eventQueue.flushEvents(!0):E_.indexOf(e)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return s.event="eventrateexceeded",l=Ku(s),this.eventQueue.queueEvent(s.event,l),Pe.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(e,t){var r=this,s={},n=t.view_id;if(n==="-1"||e==="viewstart"||e==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=y_)s=Kl({},t),n&&(this.previousBeaconData=s),n&&e==="viewend"&&(this.previousBeaconData=null);else{var a=e.indexOf("request")===0;Object.entries(t).forEach(function(o){var l=Wi(o,2),d=l[0],u=l[1];r.previousBeaconData&&(u!==r.previousBeaconData[d]||p_.indexOf(d)>-1||r.objectHasChanged(a,d,u,r.previousBeaconData[d])||r.eventRequiresKey(e,d))&&(s[d]=u,r.previousBeaconData[d]=u)})}return s}},{key:"objectHasChanged",value:function(e,t,r,s){return!e||t.indexOf("request_")!==0?!1:t==="request_response_headers"||typeof r!="object"||typeof s!="object"?!0:Object.keys(r||{}).length!==Object.keys(s||{}).length}},{key:"eventRequiresKey",value:function(e,t){return!!(e==="renditionchange"&&t.indexOf("video_source_")===0||v_.includes(t)&&g_.includes(e))}}]),i}(),T_=function i(e){ut(this,i);var t=0,r=0,s=0,n=0,a=0,o=0,l=0,d=function(h,f){var m=f.request_start,p=f.request_response_start,g=f.request_response_end,E=f.request_bytes_loaded;n++;var y,b;if(p?(y=p-(m??0),b=(g??0)-p):b=(g??0)-(m??0),b>0&&E&&E>0){var S=E/b*8e3;a++,r+=E,s+=b,e.data.view_min_request_throughput=Math.min(e.data.view_min_request_throughput||1/0,S),e.data.view_average_request_throughput=r/s*8e3,e.data.view_request_count=n,y>0&&(t+=y,e.data.view_max_request_latency=Math.max(e.data.view_max_request_latency||0,y),e.data.view_average_request_latency=t/a)}},u=function(h,f){n++,o++,e.data.view_request_count=n,e.data.view_request_failed_count=o},c=function(h,f){n++,l++,e.data.view_request_count=n,e.data.view_request_canceled_count=l};e.on("requestcompleted",d),e.on("requestfailed",u),e.on("requestcanceled",c)},__=T_,A_=60*60*1e3,S_=function i(e){var t=this;ut(this,i),B(this,"_lastEventTime",void 0),e.on("before*",function(r,s){var n=s.viewer_time,a=Xe.now(),o=t._lastEventTime;if(t._lastEventTime=a,o&&a-o>A_){var l=Object.keys(e.data).reduce(function(d,u){return u.indexOf("video_")===0?Object.assign(d,B({},u,e.data[u])):d},{});e.mux.log.info("Received event after at least an hour inactivity, creating a new view"),e.emit("viewinit",Object.assign({viewer_time:n},l)),e.playbackHeartbeat._playheadShouldBeProgressing&&r.type!=="play"&&r.type!=="adbreakstart"&&(e.emit("play",{viewer_time:n}),r.type!=="playing"&&e.emit("playing",{viewer_time:n}))}})},x_=S_,k_=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],L_=new Set(["requestcompleted","requestfailed","requestcanceled"]),I_=function(i){oT(t,i);var e=uT(t);function t(r,s,n){ut(this,t);var a;a=e.call(this),B(se(a),"DOM_CONTENT_LOADED_EVENT_END",void 0),B(se(a),"NAVIGATION_START",void 0),B(se(a),"_destroyed",void 0),B(se(a),"_heartBeatTimeout",void 0),B(se(a),"adTracker",void 0),B(se(a),"dashjs",void 0),B(se(a),"data",void 0),B(se(a),"disablePlayheadRebufferTracking",void 0),B(se(a),"disableRebufferTracking",void 0),B(se(a),"errorTracker",void 0),B(se(a),"errorTranslator",void 0),B(se(a),"getAdData",void 0),B(se(a),"getPlayheadTime",void 0),B(se(a),"getStateData",void 0),B(se(a),"hlsjs",void 0),B(se(a),"id",void 0),B(se(a),"longResumeTracker",void 0),B(se(a),"minimumRebufferDuration",void 0),B(se(a),"mux",void 0),B(se(a),"oldEmit",void 0),B(se(a),"playbackEventDispatcher",void 0),B(se(a),"playbackHeartbeat",void 0),B(se(a),"playbackHeartbeatTime",void 0),B(se(a),"playheadTime",void 0),B(se(a),"seekingTracker",void 0),B(se(a),"sustainedRebufferThreshold",void 0),B(se(a),"watchTimeTracker",void 0),B(se(a),"currentFragmentPDT",void 0),B(se(a),"currentFragmentStart",void 0),a.DOM_CONTENT_LOADED_EVENT_END=Wl.domContentLoadedEventEnd(),a.NAVIGATION_START=Wl.navigationStart();var o={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(f){return f}};a.mux=r,a.id=s,n!=null&&n.beaconDomain&&a.mux.log.warn("The `beaconDomain` setting has been deprecated in favor of `beaconCollectionDomain`. Please change your integration to use `beaconCollectionDomain` instead of `beaconDomain`."),n=Object.assign(o,n),n.data=n.data||{},n.data.property_key&&(n.data.env_key=n.data.property_key,delete n.data.property_key),Pe.level=n.debug?Yr.DEBUG:Yr.WARN,a.getPlayheadTime=n.getPlayheadTime,a.getStateData=n.getStateData||function(){return{}},a.getAdData=n.getAdData||function(){},a.minimumRebufferDuration=n.minimumRebufferDuration,a.sustainedRebufferThreshold=n.sustainedRebufferThreshold,a.playbackHeartbeatTime=n.playbackHeartbeatTime,a.disableRebufferTracking=n.disableRebufferTracking,a.disableRebufferTracking&&a.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),a.disablePlayheadRebufferTracking=n.disablePlayheadRebufferTracking,a.errorTranslator=n.errorTranslator,a.playbackEventDispatcher=new b_(r,n.data.env_key,n),a.data={player_instance_id:xa(),mux_sample_rate:n.sampleRate,beacon_domain:n.beaconCollectionDomain||n.beaconDomain},a.data.view_sequence_number=1,a.data.player_sequence_number=1,a.oldEmit=a.emit,a.emit=function(f,m){m=Object.assign({viewer_time:this.mux.utils.now()},m),this.oldEmit(f,m)};var l=(function(){typeof this.data.view_start>"u"&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}).bind(se(a));a.on("viewinit",function(f,m){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,m),this._initializeViewData(),this.one("play",l),this.one("adbreakstart",l)});var d=(function(f){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",f)}).bind(se(a));if(a.on("videochange",function(f,m){d(m)}),a.on("programchange",function(f,m){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),d(Object.assign(m,{view_program_changed:!0})),l(),this.emit("play"),this.emit("playing")}),a.on("fragmentchange",function(f,m){this.currentFragmentPDT=m.currentFragmentPDT,this.currentFragmentStart=m.currentFragmentStart}),a.on("destroy",a.destroy),typeof window<"u"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var u=function(){var f=typeof a.data.view_start<"u";a.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",f&&a.mux.WINDOW_HIDDEN&&(a.data.player_is_paused||a.emit("hb"))};window.addEventListener("visibilitychange",u,!1);var c=function(f){f.persisted||a.destroy()};window.addEventListener("pagehide",c,!1),a.on("destroy",function(){window.removeEventListener("visibilitychange",u),window.removeEventListener("pagehide",c)})}a.on("playerready",function(f,m){Object.assign(this.data,m)}),k_.forEach(function(f){a.on(f,function(m,p){f.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,p),this._sanitizeData()}),a.on("after"+f,function(){(f!=="error"||this.errorTracker.viewErrored)&&this.send(f)})}),a.on("viewend",function(f,m){Object.assign(a.data,m)});var h=function(f){var m=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=m-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};return a.one("playerready",h),a.longResumeTracker=new x_(se(a)),a.errorTracker=new IT(se(a)),new ZT(se(a)),a.seekingTracker=new VT(se(a)),a.playheadTime=new PT(se(a)),a.playbackHeartbeat=new kT(se(a)),new HT(se(a)),a.watchTimeTracker=new wT(se(a)),new DT(se(a)),a.adTracker=new jT(se(a)),new UT(se(a)),new NT(se(a)),new BT(se(a)),new XT(se(a)),new __(se(a)),n.hlsjs&&a.addHLSJS(n),n.dashjs&&a.addDashJS(n),a.emit("viewinit",n.data),a}return Ii(t,[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,typeof this.data.view_start<"u"&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(r){if(this.data.view_id){var s=Object.assign({},this.data),n=["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if(s.video_source_is_live===void 0&&(s.player_source_duration===1/0||s.video_source_duration===1/0?s.video_source_is_live=!0:(s.player_source_duration>0||s.video_source_duration>0)&&(s.video_source_is_live=!1)),s.video_source_is_live||n.forEach(function(d){s[d]=void 0}),s.video_source_url=s.video_source_url||s.player_source_url,s.video_source_url){var a=Wi(ka(s.video_source_url),2),o=a[0],l=a[1];s.video_source_domain=l,s.video_source_hostname=o}delete s.ad_request_id,this.playbackEventDispatcher.send(r,s),this.data.view_sequence_number++,this.data.player_sequence_number++,L_.has(r)||this._restartHeartBeat(),r==="viewend"&&delete this.data.view_id}}},{key:"_updateStateData",value:function(){Object.assign(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var r=this,s=["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"];s.forEach(function(a){var o=parseInt(r.data[a],10);r.data[a]=isNaN(o)?void 0:o});var n=["player_source_url","video_source_url"];n.forEach(function(a){if(r.data[a]){var o=r.data[a].toLowerCase();(o.indexOf("data:")===0||o.indexOf("blob:")===0)&&(r.data[a]="MSE style URL")}})}},{key:"_resetVideoData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("video_")===0&&delete r.data[s]})}},{key:"_resetViewData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("view_")===0&&delete r.data[s]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(){delete this.data.player_error_code,delete this.data.player_error_message,delete this.data.player_error_context,delete this.data.player_error_severity,delete this.data.player_error_business_exception}},{key:"_initializeViewData",value:function(){var r=this,s=this.data.view_id=xa(),n=function(){s===r.data.view_id&&He(r.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",n):n()}},{key:"_restartHeartBeat",value:function(){var r=this;window.clearTimeout(this._heartBeatTimeout),this._heartBeatTimeout=window.setTimeout(function(){r.data.player_is_paused||r.emit("hb")},1e4)}},{key:"addHLSJS",value:function(r){if(!r.hlsjs){this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.");return}if(this.hlsjs){this.mux.log.warn("An instance of HLS.js is already being monitored for this player.");return}this.hlsjs=r.hlsjs,gT(this.mux,this.id,r.hlsjs,{},r.Hls||window.Hls)}},{key:"removeHLSJS",value:function(){this.hlsjs&&(vT(this.hlsjs),this.hlsjs=void 0)}},{key:"addDashJS",value:function(r){if(!r.dashjs){this.mux.log.warn("You must pass a valid dashjs instance in order to track it.");return}if(this.dashjs){this.mux.log.warn("An instance of Dash.js is already being monitored for this player.");return}this.dashjs=r.dashjs,TT(this.mux,this.id,r.dashjs)}},{key:"removeDashJS",value:function(){this.dashjs&&(_T(this.dashjs),this.dashjs=void 0)}}]),t}(ST),R_=I_;Fh();var Ln=Qt(Xb());function w_(){return Ln.default&&!!(Ln.default.fullscreenElement||Ln.default.webkitFullscreenElement||Ln.default.mozFullScreenElement||Ln.default.msFullscreenElement)}var C_=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],D_={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};function M_(i,e,t){var r=Wi(Gu(e),3),s=r[0],n=r[1],a=r[2],o=i.log,l=i.utils.getComputedStyle,d=i.utils.secondsToMs,u={automaticErrorTracking:!0};if(s){if(a!=="video"&&a!=="audio")return o.error("The element of `"+n+"` was not a media element.")}else return o.error("No element was found with the `"+n+"` query selector.");s.mux&&(s.mux.destroy(),delete s.mux,o.warn("Already monitoring this video element, replacing existing event listeners")),t=Object.assign(u,t),t.data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:i.VERSION},t.data),t.getPlayheadTime=function(){return d(s.currentTime)},t.getStateData=function(){var h,f=this.hlsjs&&this.hlsjs.url,m=this.dashjs&&Nh(this.dashjs.getSource==="function")&&this.dashjs.getSource(),p={player_is_paused:s.paused,player_playhead_time:d(s.currentTime),player_width:parseInt(l(s,"width")),player_height:parseInt(l(s,"height")),player_autoplay_on:s.autoplay,player_preload_on:s.preload,player_language_code:s.lang,player_is_fullscreen:w_(),video_poster_url:s.poster,video_source_url:f||m||s.currentSrc,video_source_duration:d(s.duration),video_source_height:s.videoHeight,video_source_width:s.videoWidth,view_dropped_frame_count:s==null||(h=s.getVideoPlaybackQuality)===null||h===void 0?void 0:h.call(s).droppedVideoFrames},g=t.getPlayheadTime();if(s.getStartDate&&g>0){var E=s.getStartDate();if(E&&typeof E.getTime=="function"&&E.getTime()){var y=E.getTime();if(p.player_program_time=y+g,s.seekable.length>0){var b=y+s.seekable.end(s.seekable.length-1);p.player_live_edge_program_time=b}}}return p},s.mux=s.mux||{},s.mux.deleted=!1,s.mux.emit=function(h,f){i.emit(n,h,f)};var c=function(){o.error("The monitor for this video element has already been destroyed.")};s.mux.destroy=function(){Object.keys(s.mux.listeners).forEach(function(h){s.removeEventListener(h,s.mux.listeners[h],!1)}),delete s.mux.listeners,s.mux.destroy=c,s.mux.swapElement=c,s.mux.emit=c,s.mux.addHLSJS=c,s.mux.addDashJS=c,s.mux.removeHLSJS=c,s.mux.removeDashJS=c,s.mux.deleted=!0,i.emit(n,"destroy")},s.mux.swapElement=function(h){var f=Wi(Gu(h),3),m=f[0],p=f[1],g=f[2];if(m){if(g!=="video"&&g!=="audio")return i.log.error("The element of `"+p+"` was not a media element.")}else return i.log.error("No element was found with the `"+p+"` query selector.");m.muxId=s.muxId,delete s.muxId,m.mux=m.mux||{},m.mux.listeners=Object.assign({},s.mux.listeners),delete s.mux.listeners,Object.keys(m.mux.listeners).forEach(function(E){s.removeEventListener(E,m.mux.listeners[E],!1),m.addEventListener(E,m.mux.listeners[E],!1)}),m.mux.swapElement=s.mux.swapElement,m.mux.destroy=s.mux.destroy,delete s.mux,s=m},s.mux.addHLSJS=function(h){i.addHLSJS(n,h)},s.mux.addDashJS=function(h){i.addDashJS(n,h)},s.mux.removeHLSJS=function(){i.removeHLSJS(n)},s.mux.removeDashJS=function(){i.removeDashJS(n)},i.init(n,t),i.emit(n,"playerready"),s.paused||(i.emit(n,"play"),s.readyState>2&&i.emit(n,"playing")),s.mux.listeners={},C_.forEach(function(h){h==="error"&&!t.automaticErrorTracking||(s.mux.listeners[h]=function(){var f={};if(h==="error"){if(!s.error||s.error.code===1)return;f.player_error_code=s.error.code,f.player_error_message=D_[s.error.code]||s.error.message}i.emit(n,h,f)},s.addEventListener(h,s.mux.listeners[h],!1))})}function P_(i,e,t,r){var s=r;if(i&&typeof i[e]=="function")try{s=i[e].apply(i,t)}catch(n){Pe.info("safeCall error",n)}return s}var ga=Qt(Li()),ks;ga.default&&ga.default.WeakMap&&(ks=new WeakMap);function O_(i,e){if(!i||!e||!ga.default||typeof ga.default.getComputedStyle!="function")return"";var t;return ks&&ks.has(i)&&(t=ks.get(i)),t||(t=ga.default.getComputedStyle(i,null),ks&&ks.set(i,t)),t.getPropertyValue(e)}function N_(i){return Math.floor(i*1e3)}var yr={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},Ld=function(i){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(i),this.manifest};Ld.prototype.process=function(i){var e;for(this.buffer+=i,e=this.buffer.indexOf(`
14
+ `):"");n("error",{player_error_code:b==null?void 0:b.code,player_error_message:b==null?void 0:b.message,player_error_context:C})};t.on("error",E),t._stopMuxMonitor=function(){t.off("manifestLoaded",a),t.off("initFragmentLoaded",u),t.off("mediaFragmentLoaded",h),t.off("qualityChangeRendered",p),t.off("error",E),t.off("fragmentLoadingAbandoned",g),delete t._stopMuxMonitor}},ST=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},cm=0,xT=function(){function i(){ut(this,i),B(this,"_listeners",void 0)}return Ii(i,[{key:"on",value:function(e,t,r){return t._eventEmitterGuid=t._eventEmitterGuid||++cm,this._listeners=this._listeners||{},this._listeners[e]=this._listeners[e]||[],r&&(t=t.bind(r)),this._listeners[e].push(t),t}},{key:"off",value:function(e,t){var r=this._listeners&&this._listeners[e];r&&r.forEach(function(s,n){s._eventEmitterGuid===t._eventEmitterGuid&&r.splice(n,1)})}},{key:"one",value:function(e,t,r){var s=this;t._eventEmitterGuid=t._eventEmitterGuid||++cm;var n=function(){s.off(e,n),t.apply(r||this,arguments)};n._eventEmitterGuid=t._eventEmitterGuid,this.on(e,n)}},{key:"emit",value:function(e,t){var r=this;if(this._listeners){t=t||{};var s=this._listeners["before*"]||[],n=this._listeners[e]||[],a=this._listeners["after"+e]||[],o=function(l,d){l=l.slice(),l.forEach(function(u){u.call(r,{type:e},d)})};o(s,t),o(n,t),o(a,t)}}}]),i}(),kT=xT,Xd=Qt(Li()),LT=function(){function i(e){var t=this;ut(this,i),B(this,"_playbackHeartbeatInterval",void 0),B(this,"_playheadShouldBeProgressing",void 0),B(this,"pm",void 0),this.pm=e,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,e.on("playing",function(){t._playheadShouldBeProgressing=!0}),e.on("play",this._startPlaybackHeartbeatInterval.bind(this)),e.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),e.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),e.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("seeked",function(){e.data.player_is_paused?t._stopPlaybackHeartbeatInterval():t._startPlaybackHeartbeatInterval()}),e.on("timeupdate",function(){t._playbackHeartbeatInterval!==null&&e.emit("playbackheartbeat")}),e.on("devicesleep",function(r,s){t._playbackHeartbeatInterval!==null&&(Xd.default.clearInterval(t._playbackHeartbeatInterval),e.emit("playbackheartbeatend",{viewer_time:s.viewer_time}),t._playbackHeartbeatInterval=null)})}return Ii(i,[{key:"_startPlaybackHeartbeatInterval",value:function(){var e=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=Xd.default.setInterval(function(){e.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(Xd.default.clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}]),i}(),IT=LT,RT=function i(e){var t=this;ut(this,i),B(this,"viewErrored",void 0),e.on("viewinit",function(){t.viewErrored=!1}),e.on("error",function(r,s){try{var n=e.errorTranslator({player_error_code:s.player_error_code,player_error_message:s.player_error_message,player_error_context:s.player_error_context,player_error_severity:s.player_error_severity,player_error_business_exception:s.player_error_business_exception});n&&(e.data.player_error_code=n.player_error_code||s.player_error_code,e.data.player_error_message=n.player_error_message||s.player_error_message,e.data.player_error_context=n.player_error_context||s.player_error_context,e.data.player_error_severity=n.player_error_severity||s.player_error_severity,e.data.player_error_business_exception=n.player_error_business_exception||s.player_error_business_exception,t.viewErrored=!0)}catch(a){e.mux.log.warn("Exception in error translator callback.",a),t.viewErrored=!0}}),e.on("aftererror",function(){var r,s,n,a,o;(r=e.data)===null||r===void 0||delete r.player_error_code,(s=e.data)===null||s===void 0||delete s.player_error_message,(n=e.data)===null||n===void 0||delete n.player_error_context,(a=e.data)===null||a===void 0||delete a.player_error_severity,(o=e.data)===null||o===void 0||delete o.player_error_business_exception})},wT=RT,CT=function(){function i(e){ut(this,i),B(this,"_watchTimeTrackerLastCheckedTime",void 0),B(this,"pm",void 0),this.pm=e,this._watchTimeTrackerLastCheckedTime=null,e.on("playbackheartbeat",this._updateWatchTime.bind(this)),e.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}return Ii(i,[{key:"_updateWatchTime",value:function(e,t){var r=t.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=r),He(this.pm.data,"view_watch_time",r-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=r}},{key:"_clearWatchTimeState",value:function(e,t){this._updateWatchTime(e,t),this._watchTimeTrackerLastCheckedTime=null}}]),i}(),DT=CT,MT=function(){function i(e){var t=this;ut(this,i),B(this,"_playbackTimeTrackerLastPlayheadPosition",void 0),B(this,"_lastTime",void 0),B(this,"_isAdPlaying",void 0),B(this,"_callbackUpdatePlaybackTime",void 0),B(this,"pm",void 0),this.pm=e,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=Xe.now(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null;var r=this._startPlaybackTimeTracking.bind(this);e.on("playing",r),e.on("adplaying",r),e.on("seeked",r);var s=this._stopPlaybackTimeTracking.bind(this);e.on("playbackheartbeatend",s),e.on("seeking",s),e.on("adplaying",function(){t._isAdPlaying=!0}),e.on("adended",function(){t._isAdPlaying=!1}),e.on("adpause",function(){t._isAdPlaying=!1}),e.on("adbreakstart",function(){t._isAdPlaying=!1}),e.on("adbreakend",function(){t._isAdPlaying=!1}),e.on("adplay",function(){t._isAdPlaying=!1}),e.on("viewinit",function(){t._playbackTimeTrackerLastPlayheadPosition=-1,t._lastTime=Xe.now(),t._isAdPlaying=!1,t._callbackUpdatePlaybackTime=null})}return Ii(i,[{key:"_startPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime===null&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this.pm.on("playbackheartbeat",this._callbackUpdatePlaybackTime))}},{key:"_stopPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime&&(this._updatePlaybackTime(),this.pm.off("playbackheartbeat",this._callbackUpdatePlaybackTime),this._callbackUpdatePlaybackTime=null,this._playbackTimeTrackerLastPlayheadPosition=-1)}},{key:"_updatePlaybackTime",value:function(){var e=this.pm.data.player_playhead_time,t=Xe.now(),r=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&e>this._playbackTimeTrackerLastPlayheadPosition?r=e-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(r=t-this._lastTime),r>0&&r<=1e3&&He(this.pm.data,"view_content_playback_time",r),this._playbackTimeTrackerLastPlayheadPosition=e,this._lastTime=t}}]),i}(),PT=MT,OT=function(){function i(e){ut(this,i),B(this,"pm",void 0),this.pm=e;var t=this._updatePlayheadTime.bind(this);e.on("playbackheartbeat",t),e.on("playbackheartbeatend",t),e.on("timeupdate",t),e.on("destroy",function(){e.off("timeupdate",t)})}return Ii(i,[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=typeof this.pm.data.view_max_playhead_position>"u"?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(e,t){var r=this,s=function(){r.pm.currentFragmentPDT&&r.pm.currentFragmentStart&&(r.pm.data.player_program_time=r.pm.currentFragmentPDT+r.pm.data.player_playhead_time-r.pm.currentFragmentStart)};if(t&&t.player_playhead_time)this.pm.data.player_playhead_time=t.player_playhead_time,s(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var n=this.pm.getPlayheadTime();typeof n<"u"&&(this.pm.data.player_playhead_time=n,s(),this._updateMaxPlayheadPosition())}}}]),i}(),NT=OT,hm=5*60*1e3,FT=function i(e){if(ut(this,i),!e.disableRebufferTracking){var t,r=function(n,a){s(a),t=void 0},s=function(n){if(t){var a=n.viewer_time-t;He(e.data,"view_rebuffer_duration",a),t=n.viewer_time,e.data.view_rebuffer_duration>hm&&(e.emit("viewend"),e.send("viewend"),e.mux.log.warn("Ending view after rebuffering for longer than ".concat(hm,"ms, future events will be ignored unless a programchange or videochange occurs.")))}e.data.view_watch_time>=0&&e.data.view_rebuffer_count>0&&(e.data.view_rebuffer_frequency=e.data.view_rebuffer_count/e.data.view_watch_time,e.data.view_rebuffer_percentage=e.data.view_rebuffer_duration/e.data.view_watch_time)};e.on("playbackheartbeat",function(n,a){return s(a)}),e.on("rebufferstart",function(n,a){t||(He(e.data,"view_rebuffer_count",1),t=a.viewer_time,e.one("rebufferend",r))}),e.on("viewinit",function(){t=void 0,e.off("rebufferend",r)})}},UT=FT,$T=function(){function i(e){var t=this;ut(this,i),B(this,"_lastCheckedTime",void 0),B(this,"_lastPlayheadTime",void 0),B(this,"_lastPlayheadTimeUpdatedTime",void 0),B(this,"_rebuffering",void 0),B(this,"pm",void 0),this.pm=e,!(e.disableRebufferTracking||e.disablePlayheadRebufferTracking)&&(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,e.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),e.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),e.on("seeking",function(){t._cleanupRebufferTracker(null,{viewer_time:Xe.now()})}))}return Ii(i,[{key:"_checkIfRebuffering",value:function(e,t){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing){this._cleanupRebufferTracker(e,t);return}if(this._lastCheckedTime===null){this._prepareRebufferTrackerState(t.viewer_time);return}if(this._lastPlayheadTime!==this.pm.data.player_playhead_time){this._cleanupRebufferTracker(e,t,!0);return}var r=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&r>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=t.viewer_time}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(e){this._lastCheckedTime=e,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=e}},{key:"_cleanupRebufferTracker",value:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:t.viewer_time});else{if(this._lastCheckedTime===null)return;var s=this.pm.data.player_playhead_time-this._lastPlayheadTime,n=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&s>0&&n-s>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+n-s}))}r?this._prepareRebufferTrackerState(t.viewer_time):this._clearRebufferTrackerState()}}]),i}(),BT=$T,GT=function(){function i(e){var t=this;ut(this,i),B(this,"NAVIGATION_START",void 0),B(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){var r=e.data,s=r.view_id;if(!r.view_program_changed){var n=function(a,o){var l=o.viewer_time;(a.type==="playing"&&typeof e.data.view_time_to_first_frame>"u"||a.type==="adplaying"&&(typeof e.data.view_time_to_first_frame>"u"||t._inPrerollPosition()))&&t.calculateTimeToFirstFrame(l||Xe.now(),s)};e.one("playing",n),e.one("adplaying",n),e.one("viewend",function(){e.off("playing",n),e.off("adplaying",n)})}})}return Ii(i,[{key:"_inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time>"u"||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(e,t){t===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:e}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}]),i}(),HT=GT,WT=function i(e){var t=this;ut(this,i),B(this,"_lastPlayerHeight",void 0),B(this,"_lastPlayerWidth",void 0),B(this,"_lastPlayheadPosition",void 0),B(this,"_lastSourceHeight",void 0),B(this,"_lastSourceWidth",void 0),e.on("viewinit",function(){t._lastPlayheadPosition=-1});var r=["pause","rebufferstart","seeking","error","adbreakstart","hb"],s=["playing","hb"];r.forEach(function(n){e.on(n,function(){if(t._lastPlayheadPosition>=0&&e.data.player_playhead_time>=0&&t._lastPlayerWidth>=0&&t._lastSourceWidth>0&&t._lastPlayerHeight>=0&&t._lastSourceHeight>0){var a=e.data.player_playhead_time-t._lastPlayheadPosition;if(a<0){t._lastPlayheadPosition=-1;return}var o=Math.min(t._lastPlayerWidth/t._lastSourceWidth,t._lastPlayerHeight/t._lastSourceHeight),l=Math.max(0,o-1),d=Math.max(0,1-o);e.data.view_max_upscale_percentage=Math.max(e.data.view_max_upscale_percentage||0,l),e.data.view_max_downscale_percentage=Math.max(e.data.view_max_downscale_percentage||0,d),He(e.data,"view_total_content_playback_time",a),He(e.data,"view_total_upscaling",l*a),He(e.data,"view_total_downscaling",d*a)}t._lastPlayheadPosition=-1})}),s.forEach(function(n){e.on(n,function(){t._lastPlayheadPosition=e.data.player_playhead_time,t._lastPlayerWidth=e.data.player_width,t._lastPlayerHeight=e.data.player_height,t._lastSourceWidth=e.data.video_source_width,t._lastSourceHeight=e.data.video_source_height})})},KT=WT,VT=2e3,qT=function i(e){var t=this;ut(this,i),B(this,"isSeeking",void 0),this.isSeeking=!1;var r=-1,s=function(){var n=Xe.now(),a=(e.data.viewer_time||n)-(r||n);He(e.data,"view_seek_duration",a),e.data.view_max_seek_time=Math.max(e.data.view_max_seek_time||0,a),t.isSeeking=!1,r=-1};e.on("seeking",function(n,a){if(Object.assign(e.data,a),t.isSeeking&&a.viewer_time-r<=VT){r=a.viewer_time;return}t.isSeeking&&s(),t.isSeeking=!0,r=a.viewer_time,He(e.data,"view_seek_count",1),e.send("seeking")}),e.on("seeked",function(){s()}),e.on("viewend",function(){t.isSeeking&&(s(),e.send("seeked")),t.isSeeking=!1,r=-1})},YT=qT,fm=function(i,e){i.push(e),i.sort(function(t,r){return t.viewer_time-r.viewer_time})},jT=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],zT=function(){function i(e){var t=this;ut(this,i),B(this,"_adHasPlayed",void 0),B(this,"_adRequests",void 0),B(this,"_adResponses",void 0),B(this,"_currentAdRequestNumber",void 0),B(this,"_currentAdResponseNumber",void 0),B(this,"_prerollPlayTime",void 0),B(this,"_wouldBeNewAdPlay",void 0),B(this,"isAdBreak",void 0),B(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){t.isAdBreak=!1,t._currentAdRequestNumber=0,t._currentAdResponseNumber=0,t._adRequests=[],t._adResponses=[],t._adHasPlayed=!1,t._wouldBeNewAdPlay=!0,t._prerollPlayTime=void 0}),jT.forEach(function(s){return e.on(s,t._updateAdData.bind(t))});var r=function(){t.isAdBreak=!1};e.on("adbreakstart",function(){t.isAdBreak=!0}),e.on("play",r),e.on("playing",r),e.on("viewend",r),e.on("adrequest",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdRequestNumber++},n),fm(t._adRequests,n),He(e.data,"view_ad_request_count"),t.inPrerollPosition()&&(e.data.view_preroll_requested=!0,t._adHasPlayed||He(e.data,"view_preroll_request_count"))}),e.on("adresponse",function(s,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdResponseNumber++},n),fm(t._adResponses,n);var a=t.findAdRequest(n.ad_request_id);a&&He(e.data,"view_ad_request_time",Math.max(0,n.viewer_time-a.viewer_time))}),e.on("adplay",function(s,n){t._adHasPlayed=!0,t._wouldBeNewAdPlay&&(t._wouldBeNewAdPlay=!1,He(e.data,"view_ad_played_count")),t.inPrerollPosition()&&!e.data.view_preroll_played&&(e.data.view_preroll_played=!0,t._adRequests.length>0&&(e.data.view_preroll_request_time=Math.max(0,n.viewer_time-t._adRequests[0].viewer_time)),e.data.view_start&&(e.data.view_startup_preroll_request_time=Math.max(0,n.viewer_time-e.data.view_start)),t._prerollPlayTime=n.viewer_time)}),e.on("adplaying",function(s,n){t.inPrerollPosition()&&typeof e.data.view_preroll_load_time>"u"&&typeof t._prerollPlayTime<"u"&&(e.data.view_preroll_load_time=n.viewer_time-t._prerollPlayTime,e.data.view_startup_preroll_load_time=n.viewer_time-t._prerollPlayTime)}),e.on("adclicked",function(s,n){t._wouldBeNewAdPlay||He(e.data,"view_ad_clicked_count")}),e.on("adskipped",function(s,n){t._wouldBeNewAdPlay||He(e.data,"view_ad_skipped_count")}),e.on("adended",function(){t._wouldBeNewAdPlay=!0}),e.on("aderror",function(){t._wouldBeNewAdPlay=!0})}return Ii(i,[{key:"inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time>"u"||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(e){for(var t=0;t<this._adRequests.length;t++)if(this._adRequests[t].ad_request_id===e)return this._adRequests[t]}},{key:"_updateAdData",value:function(e,t){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&t.ad_tag_url){var r=Wi(La(t.ad_tag_url),2),s=r[0],n=r[1];this.pm.data.view_preroll_ad_tag_domain=n,this.pm.data.view_preroll_ad_tag_hostname=s}if(!this.pm.data.view_preroll_ad_asset_hostname&&t.ad_asset_url){var a=Wi(La(t.ad_asset_url),2),o=a[0],l=a[1];this.pm.data.view_preroll_ad_asset_domain=l,this.pm.data.view_preroll_ad_asset_hostname=o}}this.pm.data.ad_asset_url=t==null?void 0:t.ad_asset_url,this.pm.data.ad_tag_url=t==null?void 0:t.ad_tag_url,this.pm.data.ad_creative_id=t==null?void 0:t.ad_creative_id,this.pm.data.ad_id=t==null?void 0:t.ad_id,this.pm.data.ad_universal_id=t==null?void 0:t.ad_universal_id}}]),i}(),XT=zT,mm=Qt(Li()),QT=function i(e){ut(this,i);var t,r,s=function(){e.disableRebufferTracking||(He(e.data,"view_waiting_rebuffer_count",1),t=Xe.now(),r=mm.default.setInterval(function(){if(t){var d=Xe.now();He(e.data,"view_waiting_rebuffer_duration",d-t),t=d}},250))},n=function(){e.disableRebufferTracking||t&&(He(e.data,"view_waiting_rebuffer_duration",Xe.now()-t),t=!1,mm.default.clearInterval(r))},a=!1,o=function(){a=!0},l=function(){a=!1,n()};e.on("waiting",function(){a&&s()}),e.on("playing",function(){n(),o()}),e.on("pause",l),e.on("seeking",l)},ZT=QT,JT=function i(e){var t=this;ut(this,i),B(this,"lastWallClockTime",void 0);var r=function(){t.lastWallClockTime=Xe.now(),e.on("before*",s)},s=function(n){var a=Xe.now(),o=t.lastWallClockTime;t.lastWallClockTime=a,a-o>3e4&&(e.emit("devicesleep",{viewer_time:o}),Object.assign(e.data,{viewer_time:o}),e.send("devicesleep"),e.emit("devicewake",{viewer_time:a}),Object.assign(e.data,{viewer_time:a}),e.send("devicewake"))};e.one("playbackheartbeat",r),e.on("playbackheartbeatend",function(){e.off("before*",s),e.one("playbackheartbeat",r)})},e_=JT,Qd=Qt(Li()),Z0=function(i){return i()}(function(){var i=function(){for(var t=0,r={};t<arguments.length;t++){var s=arguments[t];for(var n in s)r[n]=s[n]}return r};function e(t){function r(s,n,a){var o;if(typeof document<"u"){if(arguments.length>1){if(a=i({path:"/"},r.defaults,a),typeof a.expires=="number"){var l=new Date;l.setMilliseconds(l.getMilliseconds()+a.expires*864e5),a.expires=l}try{o=JSON.stringify(n),/^[\{\[]/.test(o)&&(n=o)}catch{}return t.write?n=t.write(n,s):n=encodeURIComponent(String(n)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),s=encodeURIComponent(String(s)),s=s.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),s=s.replace(/[\(\)]/g,escape),document.cookie=[s,"=",n,a.expires?"; expires="+a.expires.toUTCString():"",a.path?"; path="+a.path:"",a.domain?"; domain="+a.domain:"",a.secure?"; secure":""].join("")}s||(o={});for(var d=document.cookie?document.cookie.split("; "):[],u=/(%[0-9A-Z]{2})+/g,c=0;c<d.length;c++){var h=d[c].split("="),f=h.slice(1).join("=");f.charAt(0)==='"'&&(f=f.slice(1,-1));try{var m=h[0].replace(u,decodeURIComponent);if(f=t.read?t.read(f,m):t(f,m)||f.replace(u,decodeURIComponent),this.json)try{f=JSON.parse(f)}catch{}if(s===m){o=f;break}s||(o[m]=f)}catch{}}return o}}return r.set=r,r.get=function(s){return r.call(r,s)},r.getJSON=function(){return r.apply({json:!0},[].slice.call(arguments))},r.defaults={},r.remove=function(s,n){r(s,"",i(n,{expires:-1}))},r.withConverter=e,r}return e(function(){})}),J0="muxData",t_=function(i){return Object.entries(i).map(function(e){var t=Wi(e,2),r=t[0],s=t[1];return"".concat(r,"=").concat(s)}).join("&")},i_=function(i){return i.split("&").reduce(function(e,t){var r=Wi(t.split("="),2),s=r[0],n=r[1],a=+n,o=n&&a==n?a:n;return e[s]=o,e},{})},eg=function(){var i;try{i=i_(Z0.get(J0)||"")}catch{i={}}return i},tg=function(i){try{Z0.set(J0,t_(i),{expires:365})}catch{}},r_=function(){var i=eg();return i.mux_viewer_id=i.mux_viewer_id||ka(),i.msn=i.msn||Math.random(),tg(i),{mux_viewer_id:i.mux_viewer_id,mux_sample_number:i.msn}},s_=function(){var i=eg(),e=Xe.now();return i.session_start&&(i.sst=i.session_start,delete i.session_start),i.session_id&&(i.sid=i.session_id,delete i.session_id),i.session_expires&&(i.sex=i.session_expires,delete i.session_expires),(!i.sex||i.sex<e)&&(i.sid=ka(),i.sst=e),i.sex=e+25*60*1e3,tg(i),{session_id:i.sid,session_start:i.sst,session_expires:i.sex}};function n_(i,e){var t=e.beaconCollectionDomain,r=e.beaconDomain;if(t)return"https://"+t;i=i||"inferred";var s=r||"litix.io";return i.match(/^[a-z0-9]+$/)?"https://"+i+"."+s:"https://img.litix.io/a.gif"}var a_=Qt(Li()),ig=function(){var i;switch(rg()){case"cellular":i="cellular";break;case"ethernet":i="wired";break;case"wifi":i="wifi";break;case void 0:break;default:i="other"}return i},rg=function(){var i=a_.default.navigator,e=i&&(i.connection||i.mozConnection||i.webkitConnection);return e&&e.type};ig.getConnectionFromAPI=rg;var o_=ig,l_={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},d_=sg(l_),u_={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",bz:"business",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",ck:"clicked",cl:"canceled",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",ep:"experiments",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ez:"exception",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",sd:"skipped",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",sy:"severity",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},pm=sg(u_);function sg(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function qu(i){var e={},t={};return Object.keys(i).forEach(function(r){var s=!1;if(i.hasOwnProperty(r)&&i[r]!==void 0){var n=r.split("_"),a=n[0],o=d_[a];o||(Pe.info("Data key word `"+n[0]+"` not expected in "+r),o=a+"_"),n.splice(1).forEach(function(l){l==="url"&&(s=!0),pm[l]?o+=pm[l]:Number(l)&&Math.floor(Number(l))===Number(l)?o+=l:(Pe.info("Data key word `"+l+"` not expected in "+r),o+="_"+l+"_")}),s?t[o]=i[r]:e[o]=i[r]}}),Object.assign(e,t)}var jr=Qt(Li()),c_={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},h_=56*1024,f_=["hb","requestcompleted","requestfailed","requestcanceled"],m_="https://img.litix.io",Ki=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=i||m_,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},c_,e)};Ki.prototype.queueEvent=function(i,e){var t=Object.assign({},e);return this._eventQueue.length<=this._options.maxQueueLength||i==="eventrateexceeded"?(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):!1};Ki.prototype.flushEvents=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;if(i&&this._eventQueue.length===1){this._eventQueue.pop();return}this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()};Ki.prototype.destroy=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.destroyed=!0,i?this._clearBeaconQueue():this.flushEvents(),jr.default.clearTimeout(this._sendTimeout)};Ki.prototype._clearBeaconQueue=function(){var i=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,e=this._eventQueue.slice(i);i>0&&Object.assign(e[e.length-1],qu({mux_view_message:"event queue truncated"}));var t=this._createPayload(e);ng(this._beaconUrl,t,!0,function(){})};Ki.prototype._sendBeaconQueue=function(){var i=this;if(!this._postInFlight){var e=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var t=this._createPayload(e),r=Xe.now();ng(this._beaconUrl,t,!1,function(s,n){n?(i._eventQueue=e.concat(i._eventQueue),i._failureCount+=1,Pe.info("Error sending beacon: "+n)):i._failureCount=0,i._roundTripTime=Xe.now()-r,i._postInFlight=!1})}};Ki.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var i=Math.pow(2,this._failureCount-1);return i=i*Math.random(),(1+i)*this._options.baseTimeBetweenBeacons};Ki.prototype._startBeaconSending=function(){var i=this;jr.default.clearTimeout(this._sendTimeout),!this.destroyed&&(this._sendTimeout=jr.default.setTimeout(function(){i._eventQueue.length&&i._sendBeaconQueue(),i._startBeaconSending()},this._getNextBeaconTime()))};Ki.prototype._createPayload=function(i){var e=this,t={transmission_timestamp:Math.round(Xe.now())};this._roundTripTime&&(t.rtt_ms=Math.round(this._roundTripTime));var r,s,n,a=function(){r=JSON.stringify({metadata:t,events:s||i}),n=r.length/1024},o=function(){return n<=e._options.maxPayloadKBSize};return a(),o()||(Pe.info("Payload size is too big ("+n+" kb). Removing unnecessary events."),s=i.filter(function(l){return f_.indexOf(l.e)===-1}),a()),o()||(Pe.info("Payload size still too big ("+n+" kb). Cropping fields.."),s.forEach(function(l){for(var d in l){var u=l[d],c=50*1024;typeof u=="string"&&u.length>c&&(l[d]=u.substring(0,c))}}),a()),r};var p_=function(i){return i.length<=h_},ng=function(i,e,t,r){if(t&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(i,e)){r();return}if(jr.default.fetch){jr.default.fetch(i,{method:"POST",body:e,headers:{"Content-Type":"text/plain"},keepalive:p_(e)}).then(function(n){return r(null,n.ok?null:"Error")}).catch(function(n){return r(null,n)});return}if(jr.default.XMLHttpRequest){var s=new jr.default.XMLHttpRequest;s.onreadystatechange=function(){if(s.readyState===4)return r(null,s.status!==200?"error":void 0)},s.open("POST",i),s.setRequestHeader("Content-Type","text/plain"),s.send(e);return}r()},g_=Ki,v_=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id","player_error_code","player_error_message","player_error_context","player_error_severity","player_error_business_exception"],E_=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],y_=["ad_id","ad_creative_id","ad_universal_id"],b_=["viewstart","error","ended","viewend"],T_=10*60*1e3,__=function(){function i(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};ut(this,i);var s,n,a,o,l,d,u,c,h,f,m,p;B(this,"mux",void 0),B(this,"envKey",void 0),B(this,"options",void 0),B(this,"eventQueue",void 0),B(this,"sampleRate",void 0),B(this,"disableCookies",void 0),B(this,"respectDoNotTrack",void 0),B(this,"previousBeaconData",void 0),B(this,"lastEventTime",void 0),B(this,"rateLimited",void 0),B(this,"pageLevelData",void 0),B(this,"viewerData",void 0),this.mux=e,this.envKey=t,this.options=r,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.eventQueue=new g_(n_(this.envKey,this.options));var g;this.sampleRate=(g=this.options.sampleRate)!==null&&g!==void 0?g:1;var E;this.disableCookies=(E=this.options.disableCookies)!==null&&E!==void 0?E:!1;var y;this.respectDoNotTrack=(y=this.options.respectDoNotTrack)!==null&&y!==void 0?y:!1,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(s=this.options.platform)===null||s===void 0?void 0:s.name,viewer_application_version:(n=this.options.platform)===null||n===void 0?void 0:n.version,viewer_application_engine:(a=this.options.platform)===null||a===void 0?void 0:a.layout,viewer_device_name:(o=this.options.platform)===null||o===void 0?void 0:o.product,viewer_device_category:"",viewer_device_manufacturer:(l=this.options.platform)===null||l===void 0?void 0:l.manufacturer,viewer_os_family:(u=this.options.platform)===null||u===void 0||(d=u.os)===null||d===void 0?void 0:d.family,viewer_os_architecture:(h=this.options.platform)===null||h===void 0||(c=h.os)===null||c===void 0?void 0:c.architecture,viewer_os_version:(m=this.options.platform)===null||m===void 0||(f=m.os)===null||f===void 0?void 0:f.version,viewer_connection_type:o_(),page_url:Qd.default===null||Qd.default===void 0||(p=Qd.default.location)===null||p===void 0?void 0:p.href},this.viewerData=this.disableCookies?{}:r_()}return Ii(i,[{key:"send",value:function(e,t){if(!(!e||!(t!=null&&t.view_id))){if(this.respectDoNotTrack&&Ku())return Pe.info("Not sending `"+e+"` because Do Not Track is enabled");if(!t||typeof t!="object")return Pe.error("A data object was expected in send() but was not provided");var r=this.disableCookies?{}:s_(),s=Bh(ql({},this.pageLevelData,t,r,this.viewerData),{event:e,env_key:this.envKey});s.user_id&&(s.viewer_user_id=s.user_id,delete s.user_id);var n,a=((n=s.mux_sample_number)!==null&&n!==void 0?n:0)>=this.sampleRate,o=this._deduplicateBeaconData(e,s),l=qu(o);if(this.lastEventTime=this.mux.utils.now(),a)return Pe.info("Not sending event due to sample rate restriction",e,s,l);if(this.envKey||Pe.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",e,s,l),!this.rateLimited){if(Pe.info("Sending event",e,s,l),this.rateLimited=!this.eventQueue.queueEvent(e,l),this.mux.WINDOW_UNLOADING&&e==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&e==="hb"?this.eventQueue.flushEvents(!0):b_.indexOf(e)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return s.event="eventrateexceeded",l=qu(s),this.eventQueue.queueEvent(s.event,l),Pe.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(e,t){var r=this,s={},n=t.view_id;if(n==="-1"||e==="viewstart"||e==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=T_)s=ql({},t),n&&(this.previousBeaconData=s),n&&e==="viewend"&&(this.previousBeaconData=null);else{var a=e.indexOf("request")===0;Object.entries(t).forEach(function(o){var l=Wi(o,2),d=l[0],u=l[1];r.previousBeaconData&&(u!==r.previousBeaconData[d]||v_.indexOf(d)>-1||r.objectHasChanged(a,d,u,r.previousBeaconData[d])||r.eventRequiresKey(e,d))&&(s[d]=u,r.previousBeaconData[d]=u)})}return s}},{key:"objectHasChanged",value:function(e,t,r,s){return!e||t.indexOf("request_")!==0?!1:t==="request_response_headers"||typeof r!="object"||typeof s!="object"?!0:Object.keys(r||{}).length!==Object.keys(s||{}).length}},{key:"eventRequiresKey",value:function(e,t){return!!(e==="renditionchange"&&t.indexOf("video_source_")===0||y_.includes(t)&&E_.includes(e))}}]),i}(),A_=function i(e){ut(this,i);var t=0,r=0,s=0,n=0,a=0,o=0,l=0,d=function(h,f){var m=f.request_start,p=f.request_response_start,g=f.request_response_end,E=f.request_bytes_loaded;n++;var y,b;if(p?(y=p-(m??0),b=(g??0)-p):b=(g??0)-(m??0),b>0&&E&&E>0){var S=E/b*8e3;a++,r+=E,s+=b,e.data.view_min_request_throughput=Math.min(e.data.view_min_request_throughput||1/0,S),e.data.view_average_request_throughput=r/s*8e3,e.data.view_request_count=n,y>0&&(t+=y,e.data.view_max_request_latency=Math.max(e.data.view_max_request_latency||0,y),e.data.view_average_request_latency=t/a)}},u=function(h,f){n++,o++,e.data.view_request_count=n,e.data.view_request_failed_count=o},c=function(h,f){n++,l++,e.data.view_request_count=n,e.data.view_request_canceled_count=l};e.on("requestcompleted",d),e.on("requestfailed",u),e.on("requestcanceled",c)},S_=A_,x_=60*60*1e3,k_=function i(e){var t=this;ut(this,i),B(this,"_lastEventTime",void 0),e.on("before*",function(r,s){var n=s.viewer_time,a=Xe.now(),o=t._lastEventTime;if(t._lastEventTime=a,o&&a-o>x_){var l=Object.keys(e.data).reduce(function(d,u){return u.indexOf("video_")===0?Object.assign(d,B({},u,e.data[u])):d},{});e.mux.log.info("Received event after at least an hour inactivity, creating a new view"),e.emit("viewinit",Object.assign({viewer_time:n},l)),e.playbackHeartbeat._playheadShouldBeProgressing&&r.type!=="play"&&r.type!=="adbreakstart"&&(e.emit("play",{viewer_time:n}),r.type!=="playing"&&e.emit("playing",{viewer_time:n}))}})},L_=k_,I_=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],R_=new Set(["requestcompleted","requestfailed","requestcanceled"]),w_=function(i){dT(t,i);var e=hT(t);function t(r,s,n){ut(this,t);var a;a=e.call(this),B(se(a),"DOM_CONTENT_LOADED_EVENT_END",void 0),B(se(a),"NAVIGATION_START",void 0),B(se(a),"_destroyed",void 0),B(se(a),"_heartBeatTimeout",void 0),B(se(a),"adTracker",void 0),B(se(a),"dashjs",void 0),B(se(a),"data",void 0),B(se(a),"disablePlayheadRebufferTracking",void 0),B(se(a),"disableRebufferTracking",void 0),B(se(a),"errorTracker",void 0),B(se(a),"errorTranslator",void 0),B(se(a),"getAdData",void 0),B(se(a),"getPlayheadTime",void 0),B(se(a),"getStateData",void 0),B(se(a),"hlsjs",void 0),B(se(a),"id",void 0),B(se(a),"longResumeTracker",void 0),B(se(a),"minimumRebufferDuration",void 0),B(se(a),"mux",void 0),B(se(a),"oldEmit",void 0),B(se(a),"playbackEventDispatcher",void 0),B(se(a),"playbackHeartbeat",void 0),B(se(a),"playbackHeartbeatTime",void 0),B(se(a),"playheadTime",void 0),B(se(a),"seekingTracker",void 0),B(se(a),"sustainedRebufferThreshold",void 0),B(se(a),"watchTimeTracker",void 0),B(se(a),"currentFragmentPDT",void 0),B(se(a),"currentFragmentStart",void 0),a.DOM_CONTENT_LOADED_EVENT_END=Vl.domContentLoadedEventEnd(),a.NAVIGATION_START=Vl.navigationStart();var o={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(f){return f}};a.mux=r,a.id=s,n!=null&&n.beaconDomain&&a.mux.log.warn("The `beaconDomain` setting has been deprecated in favor of `beaconCollectionDomain`. Please change your integration to use `beaconCollectionDomain` instead of `beaconDomain`."),n=Object.assign(o,n),n.data=n.data||{},n.data.property_key&&(n.data.env_key=n.data.property_key,delete n.data.property_key),Pe.level=n.debug?Yr.DEBUG:Yr.WARN,a.getPlayheadTime=n.getPlayheadTime,a.getStateData=n.getStateData||function(){return{}},a.getAdData=n.getAdData||function(){},a.minimumRebufferDuration=n.minimumRebufferDuration,a.sustainedRebufferThreshold=n.sustainedRebufferThreshold,a.playbackHeartbeatTime=n.playbackHeartbeatTime,a.disableRebufferTracking=n.disableRebufferTracking,a.disableRebufferTracking&&a.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),a.disablePlayheadRebufferTracking=n.disablePlayheadRebufferTracking,a.errorTranslator=n.errorTranslator,a.playbackEventDispatcher=new __(r,n.data.env_key,n),a.data={player_instance_id:ka(),mux_sample_rate:n.sampleRate,beacon_domain:n.beaconCollectionDomain||n.beaconDomain},a.data.view_sequence_number=1,a.data.player_sequence_number=1,a.oldEmit=a.emit,a.emit=function(f,m){m=Object.assign({viewer_time:this.mux.utils.now()},m),this.oldEmit(f,m)};var l=(function(){typeof this.data.view_start>"u"&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}).bind(se(a));a.on("viewinit",function(f,m){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,m),this._initializeViewData(),this.one("play",l),this.one("adbreakstart",l)});var d=(function(f){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",f)}).bind(se(a));if(a.on("videochange",function(f,m){d(m)}),a.on("programchange",function(f,m){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),d(Object.assign(m,{view_program_changed:!0})),l(),this.emit("play"),this.emit("playing")}),a.on("fragmentchange",function(f,m){this.currentFragmentPDT=m.currentFragmentPDT,this.currentFragmentStart=m.currentFragmentStart}),a.on("destroy",a.destroy),typeof window<"u"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var u=function(){var f=typeof a.data.view_start<"u";a.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",f&&a.mux.WINDOW_HIDDEN&&(a.data.player_is_paused||a.emit("hb"))};window.addEventListener("visibilitychange",u,!1);var c=function(f){f.persisted||a.destroy()};window.addEventListener("pagehide",c,!1),a.on("destroy",function(){window.removeEventListener("visibilitychange",u),window.removeEventListener("pagehide",c)})}a.on("playerready",function(f,m){Object.assign(this.data,m)}),I_.forEach(function(f){a.on(f,function(m,p){f.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,p),this._sanitizeData()}),a.on("after"+f,function(){(f!=="error"||this.errorTracker.viewErrored)&&this.send(f)})}),a.on("viewend",function(f,m){Object.assign(a.data,m)});var h=function(f){var m=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=m-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};return a.one("playerready",h),a.longResumeTracker=new L_(se(a)),a.errorTracker=new wT(se(a)),new e_(se(a)),a.seekingTracker=new YT(se(a)),a.playheadTime=new NT(se(a)),a.playbackHeartbeat=new IT(se(a)),new KT(se(a)),a.watchTimeTracker=new DT(se(a)),new PT(se(a)),a.adTracker=new XT(se(a)),new BT(se(a)),new UT(se(a)),new HT(se(a)),new ZT(se(a)),new S_(se(a)),n.hlsjs&&a.addHLSJS(n),n.dashjs&&a.addDashJS(n),a.emit("viewinit",n.data),a}return Ii(t,[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,typeof this.data.view_start<"u"&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(r){if(this.data.view_id){var s=Object.assign({},this.data),n=["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if(s.video_source_is_live===void 0&&(s.player_source_duration===1/0||s.video_source_duration===1/0?s.video_source_is_live=!0:(s.player_source_duration>0||s.video_source_duration>0)&&(s.video_source_is_live=!1)),s.video_source_is_live||n.forEach(function(d){s[d]=void 0}),s.video_source_url=s.video_source_url||s.player_source_url,s.video_source_url){var a=Wi(La(s.video_source_url),2),o=a[0],l=a[1];s.video_source_domain=l,s.video_source_hostname=o}delete s.ad_request_id,this.playbackEventDispatcher.send(r,s),this.data.view_sequence_number++,this.data.player_sequence_number++,R_.has(r)||this._restartHeartBeat(),r==="viewend"&&delete this.data.view_id}}},{key:"_updateStateData",value:function(){Object.assign(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var r=this,s=["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"];s.forEach(function(a){var o=parseInt(r.data[a],10);r.data[a]=isNaN(o)?void 0:o});var n=["player_source_url","video_source_url"];n.forEach(function(a){if(r.data[a]){var o=r.data[a].toLowerCase();(o.indexOf("data:")===0||o.indexOf("blob:")===0)&&(r.data[a]="MSE style URL")}})}},{key:"_resetVideoData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("video_")===0&&delete r.data[s]})}},{key:"_resetViewData",value:function(){var r=this;Object.keys(this.data).forEach(function(s){s.indexOf("view_")===0&&delete r.data[s]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(){delete this.data.player_error_code,delete this.data.player_error_message,delete this.data.player_error_context,delete this.data.player_error_severity,delete this.data.player_error_business_exception}},{key:"_initializeViewData",value:function(){var r=this,s=this.data.view_id=ka(),n=function(){s===r.data.view_id&&He(r.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",n):n()}},{key:"_restartHeartBeat",value:function(){var r=this;window.clearTimeout(this._heartBeatTimeout),this._heartBeatTimeout=window.setTimeout(function(){r.data.player_is_paused||r.emit("hb")},1e4)}},{key:"addHLSJS",value:function(r){if(!r.hlsjs){this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.");return}if(this.hlsjs){this.mux.log.warn("An instance of HLS.js is already being monitored for this player.");return}this.hlsjs=r.hlsjs,ET(this.mux,this.id,r.hlsjs,{},r.Hls||window.Hls)}},{key:"removeHLSJS",value:function(){this.hlsjs&&(yT(this.hlsjs),this.hlsjs=void 0)}},{key:"addDashJS",value:function(r){if(!r.dashjs){this.mux.log.warn("You must pass a valid dashjs instance in order to track it.");return}if(this.dashjs){this.mux.log.warn("An instance of Dash.js is already being monitored for this player.");return}this.dashjs=r.dashjs,AT(this.mux,this.id,r.dashjs)}},{key:"removeDashJS",value:function(){this.dashjs&&(ST(this.dashjs),this.dashjs=void 0)}}]),t}(kT),C_=w_;$h();var In=Qt(Zb());function D_(){return In.default&&!!(In.default.fullscreenElement||In.default.webkitFullscreenElement||In.default.mozFullScreenElement||In.default.msFullscreenElement)}var M_=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],P_={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};function O_(i,e,t){var r=Wi(Wu(e),3),s=r[0],n=r[1],a=r[2],o=i.log,l=i.utils.getComputedStyle,d=i.utils.secondsToMs,u={automaticErrorTracking:!0};if(s){if(a!=="video"&&a!=="audio")return o.error("The element of `"+n+"` was not a media element.")}else return o.error("No element was found with the `"+n+"` query selector.");s.mux&&(s.mux.destroy(),delete s.mux,o.warn("Already monitoring this video element, replacing existing event listeners")),t=Object.assign(u,t),t.data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:i.VERSION},t.data),t.getPlayheadTime=function(){return d(s.currentTime)},t.getStateData=function(){var h,f=this.hlsjs&&this.hlsjs.url,m=this.dashjs&&Uh(this.dashjs.getSource==="function")&&this.dashjs.getSource(),p={player_is_paused:s.paused,player_playhead_time:d(s.currentTime),player_width:parseInt(l(s,"width")),player_height:parseInt(l(s,"height")),player_autoplay_on:s.autoplay,player_preload_on:s.preload,player_language_code:s.lang,player_is_fullscreen:D_(),video_poster_url:s.poster,video_source_url:f||m||s.currentSrc,video_source_duration:d(s.duration),video_source_height:s.videoHeight,video_source_width:s.videoWidth,view_dropped_frame_count:s==null||(h=s.getVideoPlaybackQuality)===null||h===void 0?void 0:h.call(s).droppedVideoFrames},g=t.getPlayheadTime();if(s.getStartDate&&g>0){var E=s.getStartDate();if(E&&typeof E.getTime=="function"&&E.getTime()){var y=E.getTime();if(p.player_program_time=y+g,s.seekable.length>0){var b=y+s.seekable.end(s.seekable.length-1);p.player_live_edge_program_time=b}}}return p},s.mux=s.mux||{},s.mux.deleted=!1,s.mux.emit=function(h,f){i.emit(n,h,f)};var c=function(){o.error("The monitor for this video element has already been destroyed.")};s.mux.destroy=function(){Object.keys(s.mux.listeners).forEach(function(h){s.removeEventListener(h,s.mux.listeners[h],!1)}),delete s.mux.listeners,s.mux.destroy=c,s.mux.swapElement=c,s.mux.emit=c,s.mux.addHLSJS=c,s.mux.addDashJS=c,s.mux.removeHLSJS=c,s.mux.removeDashJS=c,s.mux.deleted=!0,i.emit(n,"destroy")},s.mux.swapElement=function(h){var f=Wi(Wu(h),3),m=f[0],p=f[1],g=f[2];if(m){if(g!=="video"&&g!=="audio")return i.log.error("The element of `"+p+"` was not a media element.")}else return i.log.error("No element was found with the `"+p+"` query selector.");m.muxId=s.muxId,delete s.muxId,m.mux=m.mux||{},m.mux.listeners=Object.assign({},s.mux.listeners),delete s.mux.listeners,Object.keys(m.mux.listeners).forEach(function(E){s.removeEventListener(E,m.mux.listeners[E],!1),m.addEventListener(E,m.mux.listeners[E],!1)}),m.mux.swapElement=s.mux.swapElement,m.mux.destroy=s.mux.destroy,delete s.mux,s=m},s.mux.addHLSJS=function(h){i.addHLSJS(n,h)},s.mux.addDashJS=function(h){i.addDashJS(n,h)},s.mux.removeHLSJS=function(){i.removeHLSJS(n)},s.mux.removeDashJS=function(){i.removeDashJS(n)},i.init(n,t),i.emit(n,"playerready"),s.paused||(i.emit(n,"play"),s.readyState>2&&i.emit(n,"playing")),s.mux.listeners={},M_.forEach(function(h){h==="error"&&!t.automaticErrorTracking||(s.mux.listeners[h]=function(){var f={};if(h==="error"){if(!s.error||s.error.code===1)return;f.player_error_code=s.error.code,f.player_error_message=P_[s.error.code]||s.error.message}i.emit(n,h,f)},s.addEventListener(h,s.mux.listeners[h],!1))})}function N_(i,e,t,r){var s=r;if(i&&typeof i[e]=="function")try{s=i[e].apply(i,t)}catch(n){Pe.info("safeCall error",n)}return s}var va=Qt(Li()),Ls;va.default&&va.default.WeakMap&&(Ls=new WeakMap);function F_(i,e){if(!i||!e||!va.default||typeof va.default.getComputedStyle!="function")return"";var t;return Ls&&Ls.has(i)&&(t=Ls.get(i)),t||(t=va.default.getComputedStyle(i,null),Ls&&Ls.set(i,t)),t.getPropertyValue(e)}function U_(i){return Math.floor(i*1e3)}var yr={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},Rd=function(i){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(i),this.manifest};Rd.prototype.process=function(i){var e;for(this.buffer+=i,e=this.buffer.indexOf(`
15
15
  `);e>-1;e=this.buffer.indexOf(`
16
- `))this.processLine(this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)};Ld.prototype.processLine=function(i){var e=i.indexOf(":"),t=B_(i,e),r=t[0],s=t.length===2?Bh(t[1]):void 0;if(r[0]!=="#")this.currentUri.uri=r,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(r){case yr.TARGET_DURATION:{if(!isFinite(s)||s<0)return;this.manifest.targetDuration=s,this.setHoldBack();break}case yr.PART_INF:{Xd(this.manifest,t),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break}case yr.SERVER_CONTROL:{Xd(this.manifest,t),this.setHoldBack();break}case yr.INF:{s===0?this.currentUri.duration=.01:s>0&&(this.currentUri.duration=s);break}case yr.PROGRAM_DATE_TIME:{var n=s,a=new Date(n);this.manifest.dateTimeString||(this.manifest.dateTimeString=n,this.manifest.dateTimeObject=a),this.currentUri.dateTimeString=n,this.currentUri.dateTimeObject=a;break}case yr.VERSION:{Xd(this.manifest,t);break}case yr.SESSION_DATA:{var o=G_(t[1]),l=z0(o);Object.assign(this.manifest.sessionData,l)}}};Ld.prototype.setHoldBack=function(){var i=this.manifest,e=i.serverControl,t=i.targetDuration,r=i.partTargetDuration;if(e){var s="holdBack",n="partHoldBack",a=t&&t*3,o=r&&r*2;t&&!e.hasOwnProperty(s)&&(e[s]=a),a&&e[s]<a&&(e[s]=a),r&&!e.hasOwnProperty(n)&&(e[n]=r*3),r&&e[n]<o&&(e[n]=o)}};var Xd=function(i,e){var t=sg(e[0].replace("#EXT-X-","")),r;$_(e[1])?(r={},r=Object.assign(U_(e[1]),r)):r=Bh(e[1]),i[t]=r},sg=function(i){return i.toLowerCase().replace(/-(\w)/g,function(e){return e[1].toUpperCase()})},Bh=function(i){if(i.toLowerCase()==="yes"||i.toLowerCase()==="no")return i.toLowerCase()==="yes";var e=i.indexOf(":")!==-1?i:parseFloat(i);return isNaN(e)?i:e},F_=function(i){var e={},t=i.split("=");if(t.length>1){var r=sg(t[0]);e[r]=Bh(t[1])}return e},U_=function(i){for(var e=i.split(","),t={},r=0;e.length>r;r++){var s=e[r],n=F_(s);t=Object.assign(n,t)}return t},$_=function(i){return i.indexOf("=")>-1},B_=function(i,e){return e===-1?[i]:[i.substring(0,e),i.substring(e+1)]},G_=function(i){var e={};if(i){var t=i.search(","),r=i.slice(0,t),s=i.slice(t+1),n=[r,s];return n.forEach(function(a,o){for(var l=a.replace(/['"]+/g,"").split("="),d=0;d<l.length;d++)l[d]==="DATA-ID"&&(e["DATA-ID"]=l[1-d]),l[d]==="VALUE"&&(e.VALUE=l[1-d])}),{data:e}}},H_=Ld,W_={safeCall:P_,safeIncrement:He,getComputedStyle:O_,secondsToMs:N_,assign:Object.assign,headersStringToObject:$h,cdnHeadersToRequestId:Vl,extractHostnameAndDomain:ka,extractHostname:qt,manifestParser:H_,generateShortID:Y0,generateUUID:xa,now:Xe.now},K_=W_,V_={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled"},q_=V_,Y_="mux-embed",j_="5.3.1",z_="2.1",Ct={},mr=function(i){var e=arguments;typeof i=="string"?mr.hasOwnProperty(i)?pa.default.setTimeout(function(){e=Array.prototype.splice.call(e,1),mr[i].apply(null,e)},0):Pe.warn("`"+i+"` is an unknown task"):typeof i=="function"?pa.default.setTimeout(function(){i(mr)},0):Pe.warn("`"+i+"` is invalid.")},X_={loaded:Xe.now(),NAME:Y_,VERSION:j_,API_VERSION:z_,PLAYER_TRACKED:!1,monitor:function(i,e){return M_(mr,i,e)},destroyMonitor:function(i){var e=Wi(Gu(i),1),t=e[0];t&&t.mux&&typeof t.mux.destroy=="function"?t.mux.destroy():Pe.error("A video element monitor for `"+i+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(i,e){var t=xr(i);Ct[t]?Ct[t].addHLSJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},addDashJS:function(i,e){var t=xr(i);Ct[t]?Ct[t].addDashJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},removeHLSJS:function(i){var e=xr(i);Ct[e]?Ct[e].removeHLSJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},removeDashJS:function(i){var e=xr(i);Ct[e]?Ct[e].removeDashJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},init:function(i,e){Hu()&&e&&e.respectDoNotTrack&&Pe.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var t=xr(i);Ct[t]=new R_(mr,t,e)},emit:function(i,e,t){var r=xr(i);Ct[r]?(Ct[r].emit(e,t),e==="destroy"&&delete Ct[r]):Pe.error("A monitor for `"+r+"` has not been initialized.")},checkDoNotTrack:Hu,log:Pe,utils:K_,events:q_,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(mr,X_);typeof pa.default<"u"&&typeof pa.default.addEventListener=="function"&&pa.default.addEventListener("pagehide",function(i){i.persisted||(mr.WINDOW_UNLOADING=!0)},!1);var Gh=mr;/*!
16
+ `))this.processLine(this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)};Rd.prototype.processLine=function(i){var e=i.indexOf(":"),t=H_(i,e),r=t[0],s=t.length===2?Hh(t[1]):void 0;if(r[0]!=="#")this.currentUri.uri=r,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(r){case yr.TARGET_DURATION:{if(!isFinite(s)||s<0)return;this.manifest.targetDuration=s,this.setHoldBack();break}case yr.PART_INF:{Zd(this.manifest,t),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break}case yr.SERVER_CONTROL:{Zd(this.manifest,t),this.setHoldBack();break}case yr.INF:{s===0?this.currentUri.duration=.01:s>0&&(this.currentUri.duration=s);break}case yr.PROGRAM_DATE_TIME:{var n=s,a=new Date(n);this.manifest.dateTimeString||(this.manifest.dateTimeString=n,this.manifest.dateTimeObject=a),this.currentUri.dateTimeString=n,this.currentUri.dateTimeObject=a;break}case yr.VERSION:{Zd(this.manifest,t);break}case yr.SESSION_DATA:{var o=W_(t[1]),l=Q0(o);Object.assign(this.manifest.sessionData,l)}}};Rd.prototype.setHoldBack=function(){var i=this.manifest,e=i.serverControl,t=i.targetDuration,r=i.partTargetDuration;if(e){var s="holdBack",n="partHoldBack",a=t&&t*3,o=r&&r*2;t&&!e.hasOwnProperty(s)&&(e[s]=a),a&&e[s]<a&&(e[s]=a),r&&!e.hasOwnProperty(n)&&(e[n]=r*3),r&&e[n]<o&&(e[n]=o)}};var Zd=function(i,e){var t=ag(e[0].replace("#EXT-X-","")),r;G_(e[1])?(r={},r=Object.assign(B_(e[1]),r)):r=Hh(e[1]),i[t]=r},ag=function(i){return i.toLowerCase().replace(/-(\w)/g,function(e){return e[1].toUpperCase()})},Hh=function(i){if(i.toLowerCase()==="yes"||i.toLowerCase()==="no")return i.toLowerCase()==="yes";var e=i.indexOf(":")!==-1?i:parseFloat(i);return isNaN(e)?i:e},$_=function(i){var e={},t=i.split("=");if(t.length>1){var r=ag(t[0]);e[r]=Hh(t[1])}return e},B_=function(i){for(var e=i.split(","),t={},r=0;e.length>r;r++){var s=e[r],n=$_(s);t=Object.assign(n,t)}return t},G_=function(i){return i.indexOf("=")>-1},H_=function(i,e){return e===-1?[i]:[i.substring(0,e),i.substring(e+1)]},W_=function(i){var e={};if(i){var t=i.search(","),r=i.slice(0,t),s=i.slice(t+1),n=[r,s];return n.forEach(function(a,o){for(var l=a.replace(/['"]+/g,"").split("="),d=0;d<l.length;d++)l[d]==="DATA-ID"&&(e["DATA-ID"]=l[1-d]),l[d]==="VALUE"&&(e.VALUE=l[1-d])}),{data:e}}},K_=Rd,V_={safeCall:N_,safeIncrement:He,getComputedStyle:F_,secondsToMs:U_,assign:Object.assign,headersStringToObject:Gh,cdnHeadersToRequestId:Yl,extractHostnameAndDomain:La,extractHostname:qt,manifestParser:K_,generateShortID:z0,generateUUID:ka,now:Xe.now},q_=V_,Y_={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled"},j_=Y_,z_="mux-embed",X_="5.3.1",Q_="2.1",Ct={},mr=function(i){var e=arguments;typeof i=="string"?mr.hasOwnProperty(i)?ga.default.setTimeout(function(){e=Array.prototype.splice.call(e,1),mr[i].apply(null,e)},0):Pe.warn("`"+i+"` is an unknown task"):typeof i=="function"?ga.default.setTimeout(function(){i(mr)},0):Pe.warn("`"+i+"` is invalid.")},Z_={loaded:Xe.now(),NAME:z_,VERSION:X_,API_VERSION:Q_,PLAYER_TRACKED:!1,monitor:function(i,e){return O_(mr,i,e)},destroyMonitor:function(i){var e=Wi(Wu(i),1),t=e[0];t&&t.mux&&typeof t.mux.destroy=="function"?t.mux.destroy():Pe.error("A video element monitor for `"+i+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(i,e){var t=xr(i);Ct[t]?Ct[t].addHLSJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},addDashJS:function(i,e){var t=xr(i);Ct[t]?Ct[t].addDashJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},removeHLSJS:function(i){var e=xr(i);Ct[e]?Ct[e].removeHLSJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},removeDashJS:function(i){var e=xr(i);Ct[e]?Ct[e].removeDashJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},init:function(i,e){Ku()&&e&&e.respectDoNotTrack&&Pe.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var t=xr(i);Ct[t]=new C_(mr,t,e)},emit:function(i,e,t){var r=xr(i);Ct[r]?(Ct[r].emit(e,t),e==="destroy"&&delete Ct[r]):Pe.error("A monitor for `"+r+"` has not been initialized.")},checkDoNotTrack:Ku,log:Pe,utils:q_,events:j_,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(mr,Z_);typeof ga.default<"u"&&typeof ga.default.addEventListener=="function"&&ga.default.addEventListener("pagehide",function(i){i.persisted||(mr.WINDOW_UNLOADING=!0)},!1);var Wh=mr;/*!
17
17
  * JavaScript Cookie v2.1.3
18
18
  * https://github.com/js-cookie/js-cookie
19
19
  *
20
20
  * Copyright 2006, 2015 Klaus Hartl & Fagner Brack
21
21
  * Released under the MIT license
22
- */function Q_(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var ng={exports:{}};(function(i,e){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,u){if(u=u||{},l=l.trim(),d=d.trim(),!d){if(!u.alwaysNormalize)return l;var c=o.parseURL(l);if(!c)throw new Error("Error trying to parse base URL.");return c.path=o.normalizePath(c.path),o.buildURLFromParts(c)}var h=o.parseURL(d);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return u.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var m=s.exec(f.path);f.netLoc=m[1],f.path=m[2]}f.netLoc&&!f.path&&(f.path="/");var p={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(p.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)p.path=f.path,h.params||(p.params=f.params,h.query||(p.query=f.query));else{var g=f.path,E=g.substring(0,g.lastIndexOf("/")+1)+h.path;p.path=o.normalizePath(E)}return p.path===null&&(p.path=u.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(p)},parseURL:function(l){var d=r.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};i.exports=o})()})(ng);var Hh=ng.exports;function mm(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function dt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?mm(Object(t),!0).forEach(function(r){e1(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):mm(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function Z_(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function J_(i){var e=Z_(i,"string");return typeof e=="symbol"?e:String(e)}function e1(i,e,t){return e=J_(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function We(){return We=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},We.apply(this,arguments)}const Y=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)},t1=Number.isSafeInteger||function(i){return typeof i=="number"&&Math.abs(i)<=i1},i1=Number.MAX_SAFE_INTEGER||9007199254740991;let v=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",i}({}),ie=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),D=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({});const kr=function(){},Vu={trace:kr,debug:kr,log:kr,warn:kr,info:kr,error:kr};let va=Vu;function r1(i){const e=self.console[i];return e?e.bind(self.console,`[${i}] >`):kr}function s1(i,...e){e.forEach(function(t){va[t]=i[t]?i[t].bind(i):r1(t)})}function n1(i,e){if(typeof console=="object"&&i===!0||typeof i=="object"){s1(i,"debug","log","info","warn","error");try{va.log(`Debug logs enabled for "${e}" in hls.js version 1.5.15`)}catch{va=Vu}}else va=Vu}const I=va,a1=/^(\d+)x(\d+)$/,pm=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Me{constructor(e){typeof e=="string"&&(e=Me.parseAttrList(e)),We(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;const r=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){const t=a1.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const r={},s='"';for(pm.lastIndex=0;(t=pm.exec(e))!==null;){let n=t[2];n.indexOf(s)===0&&n.lastIndexOf(s)===n.length-1&&(n=n.slice(1,-1));const a=t[1].trim();r[a]=n}return r}}function o1(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function l1(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}class ag{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const r=t.attr;for(const s in r)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==r[s]){I.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=We(new Me({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const r=new Date(this.attr["END-DATE"]);Y(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(Y(e))return e}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 isValid(){return!!this.id&&!this._badValueForSameId&&Y(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class Id{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 ye={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class og{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[ye.AUDIO]:null,[ye.VIDEO]:null,[ye.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){const r=e.split("@",2);let s;r.length===1?s=(t==null?void 0:t.byteRangeEndOffset)||0:s=parseInt(r[1]),this._byteRange=[s,parseInt(r[0])+s]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Hh.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class Qd extends og{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=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.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new Id,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=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!Y(this.programDateTime))return null;const e=Y(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){const t=Object.keys(this.levelkeys),r=t.length;if(r>1||r===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,r,s,n,a=!1){const{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:r,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,r),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[ye.AUDIO]=null,e[ye.VIDEO]=null,e[ye.AUDIOVIDEO]=null}}let d1=class extends og{constructor(e,t,r,s,n){super(r),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.stats=new Id,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}};const u1=10;class c1{constructor(e){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.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 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.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?Y(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||u1}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function Wh(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function h1(i){const e=qu(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function f1(i){const e=function(r,s,n){const a=r[s];r[s]=r[n],r[n]=a};e(i,0,3),e(i,1,2),e(i,4,5),e(i,6,7)}function m1(i){const e=i.split(":");let t=null;if(e[0]==="data"&&e.length===2){const r=e[1].split(";"),s=r[r.length-1].split(",");if(s.length===2){const n=s[0]==="base64",a=s[1];n?(r.splice(-1,1),t=Wh(a)):t=h1(a)}}return t}function qu(i){return Uint8Array.from(unescape(encodeURIComponent(i)),e=>e.charCodeAt(0))}const fn=typeof self<"u"?self:void 0;var Ie={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},At={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function gm(i){switch(i){case At.FAIRPLAY:return Ie.FAIRPLAY;case At.PLAYREADY:return Ie.PLAYREADY;case At.WIDEVINE:return Ie.WIDEVINE;case At.CLEARKEY:return Ie.CLEARKEY}}var Hn={CENC:"1077efecc0b24d02ace33c1e52e2fb4b",CLEARKEY:"e2719d58a985b3c9781ab030af78d30e",FAIRPLAY:"94ce86fb07ff4f43adb893d2fa968ca2",PLAYREADY:"9a04f07998404286ab92e65be0885f95",WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function vm(i){if(i===Hn.WIDEVINE)return Ie.WIDEVINE;if(i===Hn.PLAYREADY)return Ie.PLAYREADY;if(i===Hn.CENC||i===Hn.CLEARKEY)return Ie.CLEARKEY}function Em(i){switch(i){case Ie.FAIRPLAY:return At.FAIRPLAY;case Ie.PLAYREADY:return At.PLAYREADY;case Ie.WIDEVINE:return At.WIDEVINE;case Ie.CLEARKEY:return At.CLEARKEY}}function Zd(i){const{drmSystems:e,widevineLicenseUrl:t}=i,r=e?[Ie.FAIRPLAY,Ie.WIDEVINE,Ie.PLAYREADY,Ie.CLEARKEY].filter(s=>!!e[s]):[];return!r[Ie.WIDEVINE]&&t&&r.push(Ie.WIDEVINE),r}const lg=function(i){return fn!=null&&(i=fn.navigator)!=null&&i.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function p1(i,e,t,r){let s;switch(i){case Ie.FAIRPLAY:s=["cenc","sinf"];break;case Ie.WIDEVINE:case Ie.PLAYREADY:s=["cenc"];break;case Ie.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return g1(s,e,t,r)}function g1(i,e,t,r){return[{initDataTypes:i,persistentState:r.persistentState||"optional",distinctiveIdentifier:r.distinctiveIdentifier||"optional",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}function is(i,e,t){return Uint8Array.prototype.slice?i.slice(e,t):new Uint8Array(Array.prototype.slice.call(i,e,t))}const Kh=(i,e)=>e+10<=i.length&&i[e]===73&&i[e+1]===68&&i[e+2]===51&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,dg=(i,e)=>e+10<=i.length&&i[e]===51&&i[e+1]===68&&i[e+2]===73&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,La=(i,e)=>{const t=e;let r=0;for(;Kh(i,e);){r+=10;const s=Rd(i,e+6);r+=s,dg(i,e+10)&&(r+=10),e+=r}if(r>0)return i.subarray(t,t+r)},Rd=(i,e)=>{let t=0;return t=(i[e]&127)<<21,t|=(i[e+1]&127)<<14,t|=(i[e+2]&127)<<7,t|=i[e+3]&127,t},v1=(i,e)=>Kh(i,e)&&Rd(i,e+6)+10<=i.length-e,Vh=i=>{const e=cg(i);for(let t=0;t<e.length;t++){const r=e[t];if(ug(r))return A1(r)}},ug=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",E1=i=>{const e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=Rd(i,4),r=10;return{type:e,size:t,data:i.subarray(r,r+t)}},cg=i=>{let e=0;const t=[];for(;Kh(i,e);){const r=Rd(i,e+6);e+=10;const s=e+r;for(;e+8<s;){const n=E1(i.subarray(e)),a=y1(n);a&&t.push(a),e+=n.size+10}dg(i,e)&&(e+=10)}return t},y1=i=>i.type==="PRIV"?b1(i):i.type[0]==="W"?_1(i):T1(i),b1=i=>{if(i.size<2)return;const e=Si(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},T1=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1;const r=Si(i.data.subarray(t),!0);t+=r.length+1;const s=Si(i.data.subarray(t));return{key:i.type,info:r,data:s}}const e=Si(i.data.subarray(1));return{key:i.type,data:e}},_1=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1;const r=Si(i.data.subarray(t),!0);t+=r.length+1;const s=Si(i.data.subarray(t));return{key:i.type,info:r,data:s}}const e=Si(i.data);return{key:i.type,data:e}},A1=i=>{if(i.data.byteLength===8){const e=new Uint8Array(i.data),t=e[3]&1;let r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,t&&(r+=4772185884e-2),Math.round(r)}},Si=(i,e=!1)=>{const t=S1();if(t){const d=t.decode(i);if(e){const u=d.indexOf("\0");return u!==-1?d.substring(0,u):d}return d.replace(/\0/g,"")}const r=i.length;let s,n,a,o="",l=0;for(;l<r;){if(s=i[l++],s===0&&e)return o;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:n=i[l++],o+=String.fromCharCode((s&31)<<6|n&63);break;case 14:n=i[l++],a=i[l++],o+=String.fromCharCode((s&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o};let Jd;function S1(){if(!navigator.userAgent.includes("PlayStation 4"))return!Jd&&typeof self.TextDecoder<"u"&&(Jd=new self.TextDecoder("utf-8")),Jd}const mi={hexDump:function(i){let e="";for(let t=0;t<i.length;t++){let r=i[t].toString(16);r.length<2&&(r="0"+r),e+=r}return e}},ql=Math.pow(2,32)-1,x1=[].push,hg={video:1,audio:2,id3:3,text:4};function Ve(i){return String.fromCharCode.apply(null,i)}function fg(i,e){const t=i[e]<<8|i[e+1];return t<0?65536+t:t}function J(i,e){const t=mg(i,e);return t<0?4294967296+t:t}function ym(i,e){let t=J(i,e);return t*=Math.pow(2,32),t+=J(i,e+4),t}function mg(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function eu(i,e,t){i[e]=t>>24,i[e+1]=t>>16&255,i[e+2]=t>>8&255,i[e+3]=t&255}function k1(i){const e=i.byteLength;for(let t=0;t<e;){const r=J(i,t);if(r>8&&i[t+4]===109&&i[t+5]===111&&i[t+6]===111&&i[t+7]===102)return!0;t=r>1?t+r:e}return!1}function le(i,e){const t=[];if(!e.length)return t;const r=i.byteLength;for(let s=0;s<r;){const n=J(i,s),a=Ve(i.subarray(s+4,s+8)),o=n>1?s+n:r;if(a===e[0])if(e.length===1)t.push(i.subarray(s+8,o));else{const l=le(i.subarray(s+8,o),e.slice(1));l.length&&x1.apply(t,l)}s=o}return t}function L1(i){const e=[],t=i[0];let r=8;const s=J(i,r);r+=4;let n=0,a=0;t===0?(n=J(i,r),a=J(i,r+4),r+=8):(n=ym(i,r),a=ym(i,r+8),r+=16),r+=2;let o=i.length+a;const l=fg(i,r);r+=2;for(let d=0;d<l;d++){let u=r;const c=J(i,u);u+=4;const h=c&2147483647;if((c&2147483648)>>>31===1)return I.warn("SIDX has hierarchical references (not supported)"),null;const m=J(i,u);u+=4,e.push({referenceSize:h,subsegmentDuration:m,info:{duration:m/s,start:o,end:o+h-1}}),o+=h,u+=4,r=u}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function pg(i){const e=[],t=le(i,["moov","trak"]);for(let s=0;s<t.length;s++){const n=t[s],a=le(n,["tkhd"])[0];if(a){let o=a[0];const l=J(a,o===0?12:20),d=le(n,["mdia","mdhd"])[0];if(d){o=d[0];const u=J(d,o===0?12:20),c=le(n,["mdia","hdlr"])[0];if(c){const h=Ve(c.subarray(8,12)),f={soun:ye.AUDIO,vide:ye.VIDEO}[h];if(f){const m=le(n,["mdia","minf","stbl","stsd"])[0],p=I1(m);e[l]={timescale:u,type:f},e[f]=dt({timescale:u,id:l},p)}}}}}return le(i,["moov","mvex","trex"]).forEach(s=>{const n=J(s,4),a=e[n];a&&(a.default={duration:J(s,12),flags:J(s,20)})}),e}function I1(i){const e=i.subarray(8),t=e.subarray(86),r=Ve(e.subarray(4,8));let s=r;const n=r==="enca"||r==="encv";if(n){const o=le(e,[r])[0].subarray(r==="enca"?28:78);le(o,["sinf"]).forEach(d=>{const u=le(d,["schm"])[0];if(u){const c=Ve(u.subarray(4,8));if(c==="cbcs"||c==="cenc"){const h=le(d,["frma"])[0];h&&(s=Ve(h))}}})}switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const a=le(t,["avcC"])[0];s+="."+Xa(a[1])+Xa(a[2])+Xa(a[3]);break}case"mp4a":{const a=le(e,[r])[0],o=le(a.subarray(28),["esds"])[0];if(o&&o.length>12){let l=4;if(o[l++]!==3)break;l=tu(o,l),l+=2;const d=o[l++];if(d&128&&(l+=2),d&64&&(l+=o[l++]),o[l++]!==4)break;l=tu(o,l);const u=o[l++];if(u===64)s+="."+Xa(u);else break;if(l+=12,o[l++]!==5)break;l=tu(o,l);const c=o[l++];let h=(c&248)>>3;h===31&&(h+=1+((c&7)<<3)+((o[l]&224)>>5)),s+="."+h}break}case"hvc1":case"hev1":{const a=le(t,["hvcC"])[0],o=a[1],l=["","A","B","C"][o>>6],d=o&31,u=J(a,2),c=(o&32)>>5?"H":"L",h=a[12],f=a.subarray(6,12);s+="."+l+d,s+="."+u.toString(16).toUpperCase(),s+="."+c+h;let m="";for(let p=f.length;p--;){const g=f[p];(g||m)&&(m="."+g.toString(16).toUpperCase()+m)}s+=m;break}case"dvh1":case"dvhe":{const a=le(t,["dvcC"])[0],o=a[2]>>1&127,l=a[2]<<5&32|a[3]>>3&31;s+="."+Jt(o)+"."+Jt(l);break}case"vp09":{const a=le(t,["vpcC"])[0],o=a[4],l=a[5],d=a[6]>>4&15;s+="."+Jt(o)+"."+Jt(l)+"."+Jt(d);break}case"av01":{const a=le(t,["av1C"])[0],o=a[1]>>>5,l=a[1]&31,d=a[2]>>>7?"H":"M",u=(a[2]&64)>>6,c=(a[2]&32)>>5,h=o===2&&u?c?12:10:u?10:8,f=(a[2]&16)>>4,m=(a[2]&8)>>3,p=(a[2]&4)>>2,g=a[2]&3;s+="."+o+"."+Jt(l)+d+"."+Jt(h)+"."+f+"."+m+p+g+"."+Jt(1)+"."+Jt(1)+"."+Jt(1)+"."+0;break}}return{codec:s,encrypted:n}}function tu(i,e){const t=e+5;for(;i[e++]&128&&e<t;);return e}function Xa(i){return("0"+i.toString(16).toUpperCase()).slice(-2)}function Jt(i){return(i<10?"0":"")+i}function R1(i,e){if(!i||!e)return i;const t=e.keyId;return t&&e.isCommonEncryption&&le(i,["moov","trak"]).forEach(s=>{const a=le(s,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=le(a,["enca"]);const l=o.length>0;l||(o=le(a,["encv"])),o.forEach(d=>{const u=l?d.subarray(28):d.subarray(78);le(u,["sinf"]).forEach(h=>{const f=gg(h);if(f){const m=f.subarray(8,24);m.some(p=>p!==0)||(I.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${mi.hexDump(m)} -> ${mi.hexDump(t)}`),f.set(t,8))}})})}),i}function gg(i){const e=le(i,["schm"])[0];if(e){const t=Ve(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return le(i,["schi","tenc"])[0]}return null}function w1(i,e){return le(e,["moof","traf"]).reduce((t,r)=>{const s=le(r,["tfdt"])[0],n=s[0],a=le(r,["tfhd"]).reduce((o,l)=>{const d=J(l,4),u=i[d];if(u){let c=J(s,4);if(n===1){if(c===ql)return I.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;c*=ql+1,c+=J(s,8)}const h=u.timescale||9e4,f=c/h;if(Y(f)&&(o===null||f<o))return f}return o},null);return a!==null&&Y(a)&&(t===null||a<t)?a:t},null)}function C1(i,e){let t=0,r=0,s=0;const n=le(i,["moof","traf"]);for(let a=0;a<n.length;a++){const o=n[a],l=le(o,["tfhd"])[0],d=J(l,4),u=e[d];if(!u)continue;const c=u.default,h=J(l,0)|(c==null?void 0:c.flags);let f=c==null?void 0:c.duration;h&8&&(h&2?f=J(l,12):f=J(l,8));const m=u.timescale||9e4,p=le(o,["trun"]);for(let g=0;g<p.length;g++){if(t=D1(p[g]),!t&&f){const E=J(p[g],4);t=f*E}u.type===ye.VIDEO?r+=t/m:u.type===ye.AUDIO&&(s+=t/m)}}if(r===0&&s===0){let a=1/0,o=0,l=0;const d=le(i,["sidx"]);for(let u=0;u<d.length;u++){const c=L1(d[u]);if(c!=null&&c.references){a=Math.min(a,c.earliestPresentationTime/c.timescale);const h=c.references.reduce((f,m)=>f+m.info.duration||0,0);o=Math.max(o,h+c.earliestPresentationTime/c.timescale),l=o-a}}if(l&&Y(l))return l}return r||s}function D1(i){const e=J(i,0);let t=8;e&1&&(t+=4),e&4&&(t+=4);let r=0;const s=J(i,4);for(let n=0;n<s;n++){if(e&256){const a=J(i,t);r+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return r}function M1(i,e,t){le(e,["moof","traf"]).forEach(r=>{le(r,["tfhd"]).forEach(s=>{const n=J(s,4),a=i[n];if(!a)return;const o=a.timescale||9e4;le(r,["tfdt"]).forEach(l=>{const d=l[0],u=t*o;if(u){let c=J(l,4);if(d===0)c-=u,c=Math.max(c,0),eu(l,4,c);else{c*=Math.pow(2,32),c+=J(l,8),c-=u,c=Math.max(c,0);const h=Math.floor(c/(ql+1)),f=Math.floor(c%(ql+1));eu(l,4,h),eu(l,8,f)}}})})})}function P1(i){const e={valid:null,remainder:null},t=le(i,["moof"]);if(t.length<2)return e.remainder=i,e;const r=t[t.length-1];return e.valid=is(i,0,r.byteOffset-8),e.remainder=is(i,r.byteOffset-8),e}function Ut(i,e){const t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function bm(i,e){const t=[],r=e.samples,s=e.timescale,n=e.id;let a=!1;return le(r,["moof"]).map(l=>{const d=l.byteOffset-8;le(l,["traf"]).map(c=>{const h=le(c,["tfdt"]).map(f=>{const m=f[0];let p=J(f,4);return m===1&&(p*=Math.pow(2,32),p+=J(f,8)),p/s})[0];return h!==void 0&&(i=h),le(c,["tfhd"]).map(f=>{const m=J(f,4),p=J(f,0)&16777215,g=(p&1)!==0,E=(p&2)!==0,y=(p&8)!==0;let b=0;const S=(p&16)!==0;let _=0;const x=(p&32)!==0;let A=8;m===n&&(g&&(A+=8),E&&(A+=4),y&&(b=J(f,A),A+=4),S&&(_=J(f,A),A+=4),x&&(A+=4),e.type==="video"&&(a=O1(e.codec)),le(c,["trun"]).map(C=>{const O=C[0],L=J(C,0)&16777215,M=(L&1)!==0;let K=0;const U=(L&4)!==0,z=(L&256)!==0;let V=0;const q=(L&512)!==0;let ae=0;const ne=(L&1024)!==0,G=(L&2048)!==0;let $=0;const te=J(C,4);let re=8;M&&(K=J(C,re),re+=4),U&&(re+=4);let oe=K+d;for(let pe=0;pe<te;pe++){if(z?(V=J(C,re),re+=4):V=b,q?(ae=J(C,re),re+=4):ae=_,ne&&(re+=4),G&&(O===0?$=J(C,re):$=mg(C,re),re+=4),e.type===ye.VIDEO){let Re=0;for(;Re<ae;){const $e=J(r,oe);if(oe+=4,N1(a,r[oe])){const yt=r.subarray(oe,oe+$e);vg(yt,a?2:1,i+$/s,t)}oe+=$e,Re+=$e+4}}i+=V/s}}))})})}),t}function O1(i){if(!i)return!1;const e=i.indexOf("."),t=e<0?i:i.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function N1(i,e){if(i){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function vg(i,e,t,r){const s=Eg(i);let n=0;n+=e;let a=0,o=0,l=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;l=s[n++],a+=l}while(l===255);o=0;do{if(n>=s.length)break;l=s[n++],o+=l}while(l===255);const d=s.length-n;let u=n;if(o<d)n+=o;else if(o>d){I.error(`Malformed SEI payload. ${o} is too small, only ${d} bytes left to parse.`);break}if(a===4){if(s[u++]===181){const h=fg(s,u);if(u+=2,h===49){const f=J(s,u);if(u+=4,f===1195456820){const m=s[u++];if(m===3){const p=s[u++],g=31&p,E=64&p,y=E?2+g*3:0,b=new Uint8Array(y);if(E){b[0]=p;for(let S=1;S<y;S++)b[S]=s[u++]}r.push({type:m,payloadType:a,pts:t,bytes:b})}}}}}else if(a===5&&o>16){const c=[];for(let m=0;m<16;m++){const p=s[u++].toString(16);c.push(p.length==1?"0"+p:p),(m===3||m===5||m===7||m===9)&&c.push("-")}const h=o-16,f=new Uint8Array(h);for(let m=0;m<h;m++)f[m]=s[u++];r.push({payloadType:a,pts:t,uuid:c.join(""),userData:Si(f),userDataBytes:f})}}}function Eg(i){const e=i.byteLength,t=[];let r=1;for(;r<e-2;)i[r]===0&&i[r+1]===0&&i[r+2]===3?(t.push(r+2),r+=2):r++;if(t.length===0)return i;const s=e-t.length,n=new Uint8Array(s);let a=0;for(r=0;r<s;a++,r++)a===t[0]&&(a++,t.shift()),n[r]=i[a];return n}function F1(i){const e=i[0];let t="",r="",s=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;Ve(i.subarray(d,d+1))!=="\0";)t+=Ve(i.subarray(d,d+1)),d+=1;for(t+=Ve(i.subarray(d,d+1)),d+=1;Ve(i.subarray(d,d+1))!=="\0";)r+=Ve(i.subarray(d,d+1)),d+=1;r+=Ve(i.subarray(d,d+1)),d+=1,s=J(i,12),n=J(i,16),o=J(i,20),l=J(i,24),d=28}else if(e===1){d+=4,s=J(i,d),d+=4;const c=J(i,d);d+=4;const h=J(i,d);for(d+=4,a=2**32*c+h,t1(a)||(a=Number.MAX_SAFE_INTEGER,I.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=J(i,d),d+=4,l=J(i,d),d+=4;Ve(i.subarray(d,d+1))!=="\0";)t+=Ve(i.subarray(d,d+1)),d+=1;for(t+=Ve(i.subarray(d,d+1)),d+=1;Ve(i.subarray(d,d+1))!=="\0";)r+=Ve(i.subarray(d,d+1)),d+=1;r+=Ve(i.subarray(d,d+1)),d+=1}const u=i.subarray(d,i.byteLength);return{schemeIdUri:t,value:r,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:u}}function U1(i,...e){const t=e.length;let r=8,s=t;for(;s--;)r+=e[s].byteLength;const n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=r&255,n.set(i,4),s=0,r=8;s<t;s++)n.set(e[s],r),r+=e[s].byteLength;return n}function $1(i,e,t){if(i.byteLength!==16)throw new RangeError("Invalid system id");let r,s;r=0,s=new Uint8Array;let n;r>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;const a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),U1([112,115,115,104],new Uint8Array([r,0,0,0]),i,n,s,a,t||new Uint8Array)}function B1(i){const e=[];if(i instanceof ArrayBuffer){const t=i.byteLength;let r=0;for(;r+32<t;){const s=new DataView(i,r),n=G1(s);e.push(n),r+=n.size}}return e}function G1(i){const e=i.getUint32(0),t=i.byteOffset,r=i.byteLength;if(r<e)return{offset:t,size:r};if(i.getUint32(4)!==1886614376)return{offset:t,size:e};const n=i.getUint32(8)>>>24;if(n!==0&&n!==1)return{offset:t,size:e};const a=i.buffer,o=mi.hexDump(new Uint8Array(a,t+12,16)),l=i.getUint32(28);let d=null,u=null;if(n===0){if(e-32<l||l<22)return{offset:t,size:e};u=new Uint8Array(a,t+32,l)}else if(n===1){if(!l||r<t+32+l*16+16)return{offset:t,size:e};d=[];for(let c=0;c<l;c++)d.push(new Uint8Array(a,t+32+c*16,16))}return{version:n,systemId:o,kids:d,data:u,offset:t,size:e}}let Qa={};class Ia{static clearKeyUriToKeyIdMap(){Qa={}}constructor(e,t,r,s=[1],n=null){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=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=s,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case At.FAIRPLAY:case At.WIDEVINE:case At.PLAYREADY:case At.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&I.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const r=H1(e);return new Ia(this.method,this.uri,"identity",this.keyFormatVersions,r)}const t=m1(this.uri);if(t)switch(this.keyFormat){case At.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case At.PLAYREADY:{const r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=$1(r,null,t);const s=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),n=String.fromCharCode.apply(null,Array.from(s)),a=n.substring(n.indexOf("<"),n.length),d=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(d){const u=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(u){const c=Wh(u).subarray(0,16);f1(c),this.keyId=c}}break}default:{let r=t.subarray(0,16);if(r.length!==16){const s=new Uint8Array(16);s.set(r,16-r.length),r=s}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r=Qa[this.uri];if(!r){const s=Object.keys(Qa).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,s),Qa[this.uri]=r}this.keyId=r}return this}}function H1(i){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}const yg=/\{\$([a-zA-Z0-9-_]+)\}/g;function Tm(i){return yg.test(i)}function bt(i,e,t){if(i.variableList!==null||i.hasVariableRefs)for(let r=t.length;r--;){const s=t[r],n=e[s];n&&(e[s]=Yu(i,n))}}function Yu(i,e){if(i.variableList!==null||i.hasVariableRefs){const t=i.variableList;return e.replace(yg,r=>{const s=r.substring(2,r.length-1),n=t==null?void 0:t[s];return n===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),r):n})}return e}function _m(i,e,t){let r=i.variableList;r||(i.variableList=r={});let s,n;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{const a=new self.URL(t).searchParams;if(a.has(s))n=a.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(a){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=e.NAME,n=e.VALUE;s in r?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):r[s]=n||""}function W1(i,e,t){const r=e.IMPORT;if(t&&r in t){let s=i.variableList;s||(i.variableList=s={}),s[r]=t[r]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function ds(i=!0){return typeof self>"u"?void 0:(i||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function K1(i){return typeof self<"u"&&i===self.ManagedMediaSource}const Yl={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,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 V1(i,e){const t=Yl[e];return!!t&&!!t[i.slice(0,4)]}function iu(i,e,t=!0){return!i.split(",").some(r=>!bg(r,e,t))}function bg(i,e,t=!0){var r;const s=ds(t);return(r=s==null?void 0:s.isTypeSupported(Ra(i,e)))!=null?r:!1}function Ra(i,e){return`${e}/mp4;codecs="${i}"`}function Am(i){if(i){const e=i.substring(0,4);return Yl.video[e]}return 2}function jl(i){return i.split(",").reduce((e,t)=>{const r=Yl.video[t];return r?(r*2+e)/(e?3:2):(Yl.audio[t]+e)/(e?2:1)},0)}const ru={};function q1(i,e=!0){if(ru[i])return ru[i];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[i];for(let r=0;r<t.length;r++)if(bg(t[r],"audio",e))return ru[i]=t[r],t[r];return i}const Y1=/flac|opus/i;function zl(i,e=!0){return i.replace(Y1,t=>q1(t.toLowerCase(),e))}function Sm(i,e){return i&&i!=="mp4a"?i:e&&e.split(",")[0]}function j1(i){const e=i.split(",");for(let t=0;t<e.length;t++){const r=e[t].split(".");if(r.length>2){let s=r.shift()+".";s+=parseInt(r.shift()).toString(16),s+=("000"+parseInt(r.shift()).toString(16)).slice(-4),e[t]=s}}return e.join(",")}const xm=/#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,km=/#EXT-X-MEDIA:(.*)/g,z1=/^#EXT(?:INF|-X-TARGETDURATION):/m,Lm=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),X1=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(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 yi{static findGroup(e,t){for(let r=0;r<e.length;r++){const s=e[r];if(s.id===t)return s}}static resolve(e,t){return Hh.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return z1.test(e)}static parseMasterPlaylist(e,t){const r=Tm(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},n=[];xm.lastIndex=0;let a;for(;(a=xm.exec(e))!=null;)if(a[1]){var o;const d=new Me(a[1]);bt(s,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const u=Yu(s,a[2]),c={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:yi.resolve(u,t)},h=d.decimalResolution("RESOLUTION");h&&(c.width=h.width,c.height=h.height),Q1(d.CODECS,c),(o=c.unknownCodecs)!=null&&o.length||n.push(c),s.levels.push(c)}else if(a[3]){const d=a[3],u=a[4];switch(d){case"SESSION-DATA":{const c=new Me(u);bt(s,c,["DATA-ID","LANGUAGE","VALUE","URI"]);const h=c["DATA-ID"];h&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[h]=c);break}case"SESSION-KEY":{const c=Im(u,t,s);c.encrypted&&c.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(c)):I.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${u}"`);break}case"DEFINE":{{const c=new Me(u);bt(s,c,["NAME","VALUE","QUERYPARAM"]),_m(s,c,t)}break}case"CONTENT-STEERING":{const c=new Me(u);bt(s,c,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:yi.resolve(c["SERVER-URI"],t),pathwayId:c["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=Rm(u);break}}}const l=n.length>0&&n.length<s.levels.length;return s.levels=l?n:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,r){let s;const n={},a=r.levels,o={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]};let l=0;for(km.lastIndex=0;(s=km.exec(e))!==null;){const d=new Me(s[1]),u=d.TYPE;if(u){const c=o[u],h=n[u]||[];n[u]=h,bt(r,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const f=d.LANGUAGE,m=d["ASSOC-LANGUAGE"],p=d.CHANNELS,g=d.CHARACTERISTICS,E=d["INSTREAM-ID"],y={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",name:d.NAME||f||"",type:u,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:f,url:d.URI?yi.resolve(d.URI,t):""};if(m&&(y.assocLang=m),p&&(y.channels=p),g&&(y.characteristics=g),E&&(y.instreamId=E),c!=null&&c.length){const b=yi.findGroup(c,y.groupId)||c[0];wm(y,b,"audioCodec"),wm(y,b,"textCodec")}h.push(y)}}return n}static parseLevelPlaylist(e,t,r,s,n,a){const o=new c1(t),l=o.fragments;let d=null,u=0,c=0,h=0,f=0,m=null,p=new Qd(s,t),g,E,y,b=-1,S=!1,_=null;for(Lm.lastIndex=0,o.m3u8=e,o.hasVariableRefs=Tm(e);(g=Lm.exec(e))!==null;){S&&(S=!1,p=new Qd(s,t),p.start=h,p.sn=u,p.cc=f,p.level=r,d&&(p.initSegment=d,p.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null,_&&(p.setByteRange(_),_=null)));const O=g[1];if(O){p.duration=parseFloat(O);const L=(" "+g[2]).slice(1);p.title=L||null,p.tagList.push(L?["INF",O,L]:["INF",O])}else if(g[3]){if(Y(p.duration)){p.start=h,y&&Mm(p,y,o),p.sn=u,p.level=r,p.cc=f,l.push(p);const L=(" "+g[3]).slice(1);p.relurl=Yu(o,L),Cm(p,m),m=p,h+=p.duration,u++,c=0,S=!0}}else if(g[4]){const L=(" "+g[4]).slice(1);m?p.setByteRange(L,m):p.setByteRange(L)}else if(g[5])p.rawProgramDateTime=(" "+g[5]).slice(1),p.tagList.push(["PROGRAM-DATE-TIME",p.rawProgramDateTime]),b===-1&&(b=l.length);else{if(g=g[0].match(X1),!g){I.warn("No matches on slow regex match for level playlist!");continue}for(E=1;E<g.length&&!(typeof g[E]<"u");E++);const L=(" "+g[E]).slice(1),M=(" "+g[E+1]).slice(1),K=g[E+2]?(" "+g[E+2]).slice(1):"";switch(L){case"PLAYLIST-TYPE":o.type=M.toUpperCase();break;case"MEDIA-SEQUENCE":u=o.startSN=parseInt(M);break;case"SKIP":{const U=new Me(M);bt(o,U,["RECENTLY-REMOVED-DATERANGES"]);const z=U.decimalInteger("SKIPPED-SEGMENTS");if(Y(z)){o.skippedSegments=z;for(let q=z;q--;)l.unshift(null);u+=z}const V=U.enumeratedString("RECENTLY-REMOVED-DATERANGES");V&&(o.recentlyRemovedDateranges=V.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(M),1);break;case"VERSION":o.version=parseInt(M);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(M||K)&&p.tagList.push(K?[M,K]:[M]);break;case"DISCONTINUITY":f++,p.tagList.push(["DIS"]);break;case"GAP":p.gap=!0,p.tagList.push([L]);break;case"BITRATE":p.tagList.push([L,M]);break;case"DATERANGE":{const U=new Me(M);bt(o,U,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),bt(o,U,U.clientAttrs);const z=new ag(U,o.dateRanges[U.ID]);z.isValid||o.skippedSegments?o.dateRanges[z.id]=z:I.warn(`Ignoring invalid DATERANGE tag: "${M}"`),p.tagList.push(["EXT-X-DATERANGE",M]);break}case"DEFINE":{{const U=new Me(M);bt(o,U,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in U?W1(o,U,a):_m(o,U,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(M);break;case"KEY":{const U=Im(M,t,o);if(U.isSupported()){if(U.method==="NONE"){y=void 0;break}y||(y={}),y[U.keyFormat]&&(y=We({},y)),y[U.keyFormat]=U}else I.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${M}"`);break}case"START":o.startTimeOffset=Rm(M);break;case"MAP":{const U=new Me(M);if(bt(o,U,["BYTERANGE","URI"]),p.duration){const z=new Qd(s,t);Dm(z,U,r,y),d=z,p.initSegment=d,d.rawProgramDateTime&&!p.rawProgramDateTime&&(p.rawProgramDateTime=d.rawProgramDateTime)}else{const z=p.byteRangeEndOffset;if(z){const V=p.byteRangeStartOffset;_=`${z-V}@${V}`}else _=null;Dm(p,U,r,y),d=p,S=!0}break}case"SERVER-CONTROL":{const U=new Me(M);o.canBlockReload=U.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=U.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&U.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=U.optionalFloat("PART-HOLD-BACK",0),o.holdBack=U.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const U=new Me(M);o.partTarget=U.decimalFloatingPoint("PART-TARGET");break}case"PART":{let U=o.partList;U||(U=o.partList=[]);const z=c>0?U[U.length-1]:void 0,V=c++,q=new Me(M);bt(o,q,["BYTERANGE","URI"]);const ae=new d1(q,p,t,V,z);U.push(ae),p.duration+=ae.duration;break}case"PRELOAD-HINT":{const U=new Me(M);bt(o,U,["URI"]),o.preloadHint=U;break}case"RENDITION-REPORT":{const U=new Me(M);bt(o,U,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(U);break}default:I.warn(`line parsed but not handled: ${g}`);break}}}m&&!m.relurl?(l.pop(),h-=m.duration,o.partList&&(o.fragmentHint=m)):o.partList&&(Cm(p,m),p.cc=f,o.fragmentHint=p,y&&Mm(p,y,o));const x=l.length,A=l[0],C=l[x-1];if(h+=o.skippedSegments*o.targetduration,h>0&&x&&C){o.averagetargetduration=h/x;const O=C.sn;o.endSN=O!=="initSegment"?O:0,o.live||(C.endList=!0),A&&(o.startCC=A.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(h+=o.fragmentHint.duration),o.totalduration=h,o.endCC=f,b>0&&Z1(l,b),o}}function Im(i,e,t){var r,s;const n=new Me(i);bt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const a=(r=n.METHOD)!=null?r:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,u=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&I.error(`Invalid IV: ${n.IV}`);const c=o?yi.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Ia(a,c,u,h,l)}function Rm(i){const t=new Me(i).decimalFloatingPoint("TIME-OFFSET");return Y(t)?t:null}function Q1(i,e){let t=(i||"").split(/[ ,]+/).filter(r=>r);["video","audio","text"].forEach(r=>{const s=t.filter(n=>V1(n,r));s.length&&(e[`${r}Codec`]=s.join(","),t=t.filter(n=>s.indexOf(n)===-1))}),e.unknownCodecs=t}function wm(i,e,t){const r=e[t];r&&(i[t]=r)}function Z1(i,e){let t=i[e];for(let r=e;r--;){const s=i[r];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function Cm(i,e){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):e!=null&&e.programDateTime&&(i.programDateTime=e.endProgramDateTime),Y(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function Dm(i,e,t,r){i.relurl=e.URI,e.BYTERANGE&&i.setByteRange(e.BYTERANGE),i.level=t,i.sn="initSegment",r&&(i.levelkeys=r),i.initSegment=null}function Mm(i,e,t){i.levelkeys=e;const{encryptedFragments:r}=t;(!r.length||r[r.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&r.push(i)}var fe={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},ee={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Pm(i){const{type:e}=i;switch(e){case fe.AUDIO_TRACK:return ee.AUDIO;case fe.SUBTITLE_TRACK:return ee.SUBTITLE;default:return ee.MAIN}}function su(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class J1{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,r=t.pLoader,s=t.loader,n=r||s,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:fe.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){const{id:r,level:s,pathwayId:n,url:a,deliveryDirectives:o}=t;this.load({id:r,level:s,pathwayId:n,responseType:"text",type:fe.LEVEL,url:a,deliveryDirectives:o})}onAudioTrackLoading(e,t){const{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:fe.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){const{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:fe.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;const r=this.hls.config;let s=this.getInternalLoader(e);if(s){const d=s.context;if(d&&d.url===e.url&&d.level===e.level){I.trace("[playlist-loader]: playlist request ongoing");return}I.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===fe.MANIFEST?n=r.manifestLoadPolicy.default:n=We({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),Y((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===fe.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===fe.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===fe.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){const u=d.partTarget,c=d.targetduration;if(u&&c){const h=Math.max(u*3,c*.8)*1e3;n=We({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}const a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,u,c,h)=>{const f=this.getInternalLoader(c);this.resetInternalLoader(c.type);const m=d.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,c,new Error("no EXTM3U delimiter"),h||null,u);return}u.parsing.start=performance.now(),yi.isMediaPlaylist(m)?this.handleTrackOrLevelPlaylist(d,u,c,h||null,f):this.handleMasterPlaylist(d,u,c,h)},onError:(d,u,c,h)=>{this.handleNetworkError(u,c,!1,d,h)},onTimeout:(d,u,c)=>{this.handleNetworkError(u,c,!0,void 0,d)}};s.load(e,o,l)}handleMasterPlaylist(e,t,r,s){const n=this.hls,a=e.data,o=su(e,r),l=yi.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,r,l.playlistParsingError,s,t);return}const{contentSteering:d,levels:u,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m}=l;this.variableList=m;const{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":E}=yi.parseMasterPlaylistMedia(a,o,l);p.length&&!p.some(b=>!b.url)&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(I.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Me({}),bitrate:0,url:""})),n.trigger(v.MANIFEST_LOADED,{levels:u,audioTracks:p,subtitles:g,captions:E,contentSteering:d,url:o,stats:t,networkDetails:s,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m})}handleTrackOrLevelPlaylist(e,t,r,s,n){const a=this.hls,{id:o,level:l,type:d}=r,u=su(e,r),c=0,h=Y(l)?l:Y(o)?o:0,f=Pm(r),m=yi.parseLevelPlaylist(e.data,u,h,f,c,this.variableList);if(d===fe.MANIFEST){const p={attrs:new Me({}),bitrate:0,details:m,name:"",url:u};a.trigger(v.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:u,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=m,this.handlePlaylistLoaded(m,e,t,r,s,n)}handleManifestParsingError(e,t,r,s,n){this.hls.trigger(v.ERROR,{type:ie.NETWORK_ERROR,details:D.MANIFEST_PARSING_ERROR,fatal:t.type===fe.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,r=!1,s,n){let a=`A network ${r?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===fe.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===fe.AUDIO_TRACK||e.type===fe.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(a);I.warn(`[playlist-loader]: ${a}`);let l=D.UNKNOWN,d=!1;const u=this.getInternalLoader(e);switch(e.type){case fe.MANIFEST:l=r?D.MANIFEST_LOAD_TIMEOUT:D.MANIFEST_LOAD_ERROR,d=!0;break;case fe.LEVEL:l=r?D.LEVEL_LOAD_TIMEOUT:D.LEVEL_LOAD_ERROR,d=!1;break;case fe.AUDIO_TRACK:l=r?D.AUDIO_TRACK_LOAD_TIMEOUT:D.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case fe.SUBTITLE_TRACK:l=r?D.SUBTITLE_TRACK_LOAD_TIMEOUT:D.SUBTITLE_LOAD_ERROR,d=!1;break}u&&this.resetInternalLoader(e.type);const c={type:ie.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:u,context:e,error:o,networkDetails:t,stats:n};if(s){const h=(t==null?void 0:t.url)||e.url;c.response=dt({url:h,data:void 0},s)}this.hls.trigger(v.ERROR,c)}handlePlaylistLoaded(e,t,r,s,n,a){const o=this.hls,{type:l,level:d,id:u,groupId:c,deliveryDirectives:h}=s,f=su(t,s),m=Pm(s),p=typeof s.level=="number"&&m===ee.MAIN?d:void 0;if(!e.fragments.length){const E=new Error("No Segments found in Playlist");o.trigger(v.ERROR,{type:ie.NETWORK_ERROR,details:D.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:E,reason:E.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const g=e.playlistParsingError;if(g){o.trigger(v.ERROR,{type:ie.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case fe.MANIFEST:case fe.LEVEL:o.trigger(v.LEVEL_LOADED,{details:e,level:p||0,id:u||0,stats:r,networkDetails:n,deliveryDirectives:h});break;case fe.AUDIO_TRACK:o.trigger(v.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case fe.SUBTITLE_TRACK:o.trigger(v.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break}}}function Tg(i,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=i,e.dispatchEvent(t)}function _g(i,e){const t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(r){I.debug(`[texttrack-utils]: ${r}`);try{const s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,i.addCue(s)}catch(s){I.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(i.mode=t)}function zs(i){const e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues)for(let t=i.cues.length;t--;)i.removeCue(i.cues[t]);e==="disabled"&&(i.mode=e)}function ju(i,e,t,r){const s=i.mode;if(s==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){const n=tA(i.cues,e,t);for(let a=0;a<n.length;a++)(!r||r(n[a]))&&i.removeCue(n[a])}s==="disabled"&&(i.mode=s)}function eA(i,e){if(e<i[0].startTime)return 0;const t=i.length-1;if(e>i[t].endTime)return-1;let r=0,s=t;for(;r<=s;){const n=Math.floor((s+r)/2);if(e<i[n].startTime)s=n-1;else if(e>i[n].startTime&&r<t)r=n+1;else return n}return i[r].startTime-e<e-i[s].startTime?r:s}function tA(i,e,t){const r=[],s=eA(i,e);if(s>-1)for(let n=s,a=i.length;n<a;n++){const o=i[n];if(o.startTime>=e&&o.endTime<=t)r.push(o);else if(o.startTime>t)return r}return r}function Lo(i){const e=[];for(let t=0;t<i.length;t++){const r=i[t];(r.kind==="subtitles"||r.kind==="captions")&&r.label&&e.push(i[t])}return e}var Yt={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const iA=.25;function zu(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Om(i,e,t,r,s){let n=new i(e,t,"");try{n.value=r,s&&(n.type=s)}catch{n=new i(e,t,JSON.stringify(s?dt({type:s},r):r))}return n}const Za=(()=>{const i=zu();try{i&&new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function nu(i,e){return i.getTime()/1e3-e}function rA(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class sA{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(zs(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const r=e[t];if(r.kind==="metadata"&&r.label==="id3")return Tg(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:s}}}=this;if(!r&&!s)return;const{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=zu();if(a)for(let o=0;o<n.length;o++){const l=n[o].type;if(l===Yt.emsg&&!r||!s)continue;const d=cg(n[o].data);if(d){const u=n[o].pts;let c=u+n[o].duration;c>Za&&(c=Za),c-u<=0&&(c=u+iA);for(let f=0;f<d.length;f++){const m=d[f];if(!ug(m)){this.updateId3CueEnds(u,l);const p=Om(a,u,c,m,l);p&&this.id3Track.addCue(p)}}}}}updateId3CueEnds(e,t){var r;const s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(let n=s.length;n--;){const a=s[n];a.type===t&&a.startTime<e&&a.endTime===Za&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:s}){const{id3Track:n,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let d;s==="audio"?d=u=>u.type===Yt.audioId3&&l:s==="video"?d=u=>u.type===Yt.emsg&&o:d=u=>u.type===Yt.audioId3&&l||u.type===Yt.emsg&&o,ju(n,t,r,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:r,id3Track:s}=this,{dateRanges:n}=t,a=Object.keys(n);if(s){const u=Object.keys(r).filter(c=>!a.includes(c));for(let c=u.length;c--;){const h=u[c];Object.keys(r[h].cues).forEach(f=>{s.removeCue(r[h].cues[f])}),delete r[h]}}const o=t.fragments[t.fragments.length-1];if(a.length===0||!Y(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=o.programDateTime/1e3-o.start,d=zu();for(let u=0;u<a.length;u++){const c=a[u],h=n[c],f=nu(h.startDate,l),m=r[c],p=(m==null?void 0:m.cues)||{};let g=(m==null?void 0:m.durationKnown)||!1,E=Za;const y=h.endDate;if(y)E=nu(y,l),g=!0;else if(h.endOnNext&&!g){const S=a.reduce((_,x)=>{if(x!==h.id){const A=n[x];if(A.class===h.class&&A.startDate>h.startDate&&(!_||h.startDate<_.startDate))return A}return _},null);S&&(E=nu(S.startDate,l),g=!0)}const b=Object.keys(h.attr);for(let S=0;S<b.length;S++){const _=b[S];if(!o1(_))continue;const x=p[_];if(x)g&&!m.durationKnown&&(x.endTime=E);else if(d){let A=h.attr[_];l1(_)&&(A=rA(A));const C=Om(d,f,E,{key:_,data:A},Yt.dateRange);C&&(C.id=c,this.id3Track.addCue(C),p[_]=C)}}r[c]={cues:p,dateRange:h,durationKnown:g}}}}class nA{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(e===null)return null;const{holdBack:t,partHoldBack:r,targetduration:s}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig;let d=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*s);const u=s;return d+Math.min(this.stallCount*1,u)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;const s=r.edge,n=e-t-this.edgeStalled,a=s-r.totalduration,o=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),o)}get drift(){const{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e,levelDetails:t}=this;if(!e||!t)return 0;const r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(v.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(v.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===D.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&I.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;const r=this.computeLatency();if(r===null)return;this._latency=r;const{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||n===1||!t.live)return;const a=this.targetLatency;if(a===null)return;const o=r-a,l=Math.min(this.maxLatency,a+t.targetduration);if(o<l&&o>.05&&this.forwardBufferLength>1){const u=Math.min(2,Math.max(1,n)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}const Xu=["NONE","TYPE-0","TYPE-1",null];function aA(i){return Xu.indexOf(i)>-1}const Xl=["SDR","PQ","HLG"];function oA(i){return!!i&&Xl.indexOf(i)>-1}var Io={No:"",Yes:"YES",v2:"v2"};function Nm(i){const{canSkipUntil:e,canSkipDateRanges:t,age:r}=i,s=r<e/2;return e&&s?t?Io.v2:Io.Yes:Io.No}class Fm{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class mn{constructor(e){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.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=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>!!t).map(t=>t.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.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(e){return Um(this._audioGroups,e)}hasSubtitleGroup(e){return Um(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){let r=this._subtitleGroups;r||(r=this._subtitleGroups=[]),r.indexOf(t)===-1&&r.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function Um(i,e){return!e||!i?!1:i.indexOf(e)!==-1}function au(i,e){const t=e.startPTS;if(Y(t)){let r=0,s;e.sn>i.sn?(r=t-i.start,s=i):(r=i.start-t,s=e),s.duration!==r&&(s.duration=r)}else e.sn>i.sn?i.cc===e.cc&&i.minEndPTS?e.start=i.start+(i.minEndPTS-i.start):e.start=i.start+i.duration:e.start=Math.max(i.start-e.duration,0)}function Ag(i,e,t,r,s,n){r-t<=0&&(I.warn("Fragment should have a positive duration",e),r=t+e.duration,n=s+e.duration);let o=t,l=r;const d=e.startPTS,u=e.endPTS;if(Y(d)){const g=Math.abs(d-t);Y(e.deltaPTS)?e.deltaPTS=Math.max(g,e.deltaPTS):e.deltaPTS=g,o=Math.max(t,d),t=Math.min(t,d),s=Math.min(s,e.startDTS),l=Math.min(r,u),r=Math.max(r,u),n=Math.max(n,e.endDTS)}const c=t-e.start;e.start!==0&&(e.start=t),e.duration=r-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=r,e.minEndPTS=l,e.endDTS=n;const h=e.sn;if(!i||h<i.startSN||h>i.endSN)return 0;let f;const m=h-i.startSN,p=i.fragments;for(p[m]=e,f=m;f>0;f--)au(p[f],p[f-1]);for(f=m;f<p.length-1;f++)au(p[f],p[f+1]);return i.fragmentHint&&au(p[p.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,c}function lA(i,e){let t=null;const r=i.fragments;for(let l=r.length-1;l>=0;l--){const d=r[l].initSegment;if(d){t=d;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let s=0,n;if(cA(i,e,(l,d)=>{l.relurl&&(s=l.cc-d.cc),Y(l.startPTS)&&Y(l.endPTS)&&(d.start=d.startPTS=l.startPTS,d.startDTS=l.startDTS,d.maxStartPTS=l.maxStartPTS,d.endPTS=l.endPTS,d.endDTS=l.endDTS,d.minEndPTS=l.minEndPTS,d.duration=l.endPTS-l.startPTS,d.duration&&(n=d),e.PTSKnown=e.alignedSliding=!0),d.elementaryStreams=l.elementaryStreams,d.loader=l.loader,d.stats=l.stats,l.initSegment&&(d.initSegment=l.initSegment,t=l.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(d=>{var u;d&&(!d.initSegment||d.initSegment.relurl===((u=t)==null?void 0:u.relurl))&&(d.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){I.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=dA(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const a=e.fragments;if(s){I.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<a.length;l++)a[l].cc+=s}e.skippedSegments&&(e.startCC=e.fragments[0].cc),uA(i.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats}),n?Ag(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):Sg(i,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=i.driftStartTime,e.driftStart=i.driftStart;const o=e.advancedDateTime;if(e.advanced&&o){const l=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=l),e.driftEndTime=o,e.driftEnd=l}else e.driftEndTime=i.driftEndTime,e.driftEnd=i.driftEnd,e.advancedDateTime=i.advancedDateTime}function dA(i,e,t){const r=We({},i);return t&&t.forEach(s=>{delete r[s]}),Object.keys(e).forEach(s=>{const n=new ag(e[s].attr,r[s]);n.isValid?r[s]=n:I.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),r}function uA(i,e,t){if(i&&e){let r=0;for(let s=0,n=i.length;s<=n;s++){const a=i[s],o=e[s+r];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):r--}}}function cA(i,e,t){const r=e.skippedSegments,s=Math.max(i.startSN,e.startSN)-e.startSN,n=(i.fragmentHint?1:0)+(r?e.endSN:Math.min(i.endSN,e.endSN))-e.startSN,a=e.startSN-i.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let d=s;d<=n;d++){const u=l[a+d];let c=o[d];r&&!c&&d<r&&(c=e.fragments[d]=u),u&&c&&t(u,c)}}function Sg(i,e){const t=e.startSN+e.skippedSegments-i.startSN,r=i.fragments;t<0||t>=r.length||Qu(e,r[t].start)}function Qu(i,e){if(e){const t=i.fragments;for(let r=i.skippedSegments;r<t.length;r++)t[r].start+=e;i.fragmentHint&&(i.fragmentHint.start+=e)}}function hA(i,e=1/0){let t=1e3*i.targetduration;if(i.updated){const r=i.fragments;if(r.length&&t*4>e){const n=r[r.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function fA(i,e,t){if(!(i!=null&&i.details))return null;const r=i.details;let s=r.fragments[e-r.startSN];return s||(s=r.fragmentHint,s&&s.sn===e)?s:e<r.startSN&&t&&t.sn===e?t:null}function $m(i,e,t){var r;return i!=null&&i.details?xg((r=i.details)==null?void 0:r.partList,e,t):null}function xg(i,e,t){if(i)for(let r=i.length;r--;){const s=i[r];if(s.index===t&&s.fragment.sn===e)return s}return null}function kg(i){i.forEach((e,t)=>{const{details:r}=e;r!=null&&r.fragments&&r.fragments.forEach(s=>{s.level=t})})}function Ql(i){switch(i.details){case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_TIMEOUT:case D.LEVEL_LOAD_TIMEOUT:case D.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Bm(i,e){const t=Ql(e);return i.default[`${t?"timeout":"error"}Retry`]}function qh(i,e){const t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function Gm(i){return dt(dt({},i),{errorRetry:null,timeoutRetry:null})}function Zl(i,e,t,r){if(!i)return!1;const s=r==null?void 0:r.code,n=e<i.maxNumRetry&&(mA(s)||!!t);return i.shouldRetry?i.shouldRetry(i,e,t,r,n):n}function mA(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}const Lg={search:function(i,e){let t=0,r=i.length-1,s=null,n=null;for(;t<=r;){s=(t+r)/2|0,n=i[s];const a=e(n);if(a>0)t=s+1;else if(a<0)r=s-1;else return n}return null}};function pA(i,e,t){if(e===null||!Array.isArray(i)||!i.length||!Y(e))return null;const r=i[0].programDateTime;if(e<(r||0))return null;const s=i[i.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let n=0;n<i.length;++n){const a=i[n];if(vA(e,t,a))return a}return null}function Jl(i,e,t=0,r=0,s=.005){let n=null;if(i){n=e[i.sn-e[0].sn+1]||null;const o=i.endDTS-t;o>0&&o<15e-7&&(t+=15e-7)}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!i||i.level===n.level)&&Zu(t,r,n)===0||gA(n,i,Math.min(s,r))))return n;const a=Lg.search(e,Zu.bind(null,t,r));return a&&(a!==i||!n)?a:n}function gA(i,e,t){if(e&&e.start===0&&e.level<i.level&&(e.endPTS||0)>0){const r=e.tagList.reduce((s,n)=>(n[0]==="INF"&&(s+=parseFloat(n[1])),s),t);return i.start<=r}return!1}function Zu(i=0,e=0,t){if(t.start<=i&&t.start+t.duration>i)return 0;const r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-r<=i?1:t.start-r>i&&t.start?-1:0}function vA(i,e,t){const r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-r>i}function EA(i,e){return Lg.search(i,t=>t.cc<e?1:t.cc>e?-1:0)}var ht={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Gt={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class yA{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=I.log.bind(I,"[info]:"),this.warn=I.warn.bind(I,"[warning]:"),this.error=I.error.bind(I,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(v.ERROR,this.onError,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(v.ERROR,this.onError,this),e.off(v.ERROR,this.onErrorOut,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===ee.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,s;if(t.fatal)return;const n=this.hls,a=t.context;switch(t.details){case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case D.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:ht.DoNothing,flags:Gt.None};return}case D.FRAG_GAP:case D.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=ht.SendAlternateToPenaltyBox;return}case D.LEVEL_EMPTY_ERROR:case D.LEVEL_PARSING_ERROR:{var o,l;const d=t.parent===ee.MAIN?t.level:n.loadLevel;t.details===D.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.SUBTITLE_LOAD_ERROR:case D.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){const d=n.levels[n.loadLevel];if(d&&(a.type===fe.AUDIO_TRACK&&d.hasAudioGroup(a.groupId)||a.type===fe.SUBTITLE_TRACK&&d.hasSubtitleGroup(a.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=ht.SendAlternateToPenaltyBox,t.errorAction.flags=Gt.MoveAllAlternatesMatchingHost;return}}return;case D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const d=n.levels[n.loadLevel],u=d==null?void 0:d.attrs["HDCP-LEVEL"];u?t.errorAction={action:ht.SendAlternateToPenaltyBox,flags:Gt.MoveAllAlternatesMatchingHDCP,hdcpLevel:u}:this.keySystemError(t)}return;case D.BUFFER_ADD_CODEC_ERROR:case D.REMUX_ALLOC_ERROR:case D.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:n.loadLevel);return;case D.INTERNAL_EXCEPTION:case D.BUFFER_APPENDING_ERROR:case D.BUFFER_FULL_ERROR:case D.LEVEL_SWITCH_ERROR:case D.BUFFER_STALLED_ERROR:case D.BUFFER_SEEK_OVER_HOLE:case D.BUFFER_NUDGE_ON_STALL:t.errorAction={action:ht.DoNothing,flags:Gt.None};return}t.type===ie.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){const t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){const r=this.hls,s=Bm(r.config.playlistLoadPolicy,e),n=this.playlistError++;if(Zl(s,n,Ql(e),e.response))return{action:ht.RetryRequest,flags:Gt.None,retryConfig:s,retryCount:n};const o=this.getLevelSwitchAction(e,t);return s&&(o.retryConfig=s,o.retryCount=n),o}getFragRetryOrSwitchAction(e){const t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=Bm(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((u,c)=>u+c.fragmentError,0);if(s&&(e.details!==D.FRAG_GAP&&s.fragmentError++,Zl(o,l,Ql(e),e.response)))return{action:ht.RetryRequest,flags:Gt.None,retryConfig:o,retryCount:l};const d=this.getLevelSwitchAction(e,r);return o&&(d.retryConfig=o,d.retryCount=l),d}getLevelSwitchAction(e,t){const r=this.hls;t==null&&(t=r.loadLevel);const s=this.hls.levels[t];if(s){var n,a;const d=e.details;s.loadError++,d===D.BUFFER_APPEND_ERROR&&s.fragmentError++;let u=-1;const{levels:c,loadLevel:h,minAutoLevel:f,maxAutoLevel:m}=r;r.autoLevelEnabled||(r.loadLevel=-1);const p=(n=e.frag)==null?void 0:n.type,E=(p===ee.AUDIO&&d===D.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===D.BUFFER_ADD_CODEC_ERROR||d===D.BUFFER_APPEND_ERROR))&&c.some(({audioCodec:x})=>s.audioCodec!==x),b=e.sourceBufferName==="video"&&(d===D.BUFFER_ADD_CODEC_ERROR||d===D.BUFFER_APPEND_ERROR)&&c.some(({codecSet:x,audioCodec:A})=>s.codecSet!==x&&s.audioCodec===A),{type:S,groupId:_}=(a=e.context)!=null?a:{};for(let x=c.length;x--;){const A=(x+h)%c.length;if(A!==h&&A>=f&&A<=m&&c[A].loadError===0){var o,l;const C=c[A];if(d===D.FRAG_GAP&&p===ee.MAIN&&e.frag){const O=c[A].details;if(O){const L=Jl(e.frag,O.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else{if(S===fe.AUDIO_TRACK&&C.hasAudioGroup(_)||S===fe.SUBTITLE_TRACK&&C.hasSubtitleGroup(_))continue;if(p===ee.AUDIO&&(o=s.audioGroups)!=null&&o.some(O=>C.hasAudioGroup(O))||p===ee.SUBTITLE&&(l=s.subtitleGroups)!=null&&l.some(O=>C.hasSubtitleGroup(O))||E&&s.audioCodec===C.audioCodec||!E&&s.audioCodec!==C.audioCodec||b&&s.codecSet===C.codecSet)continue}u=A;break}}if(u>-1&&r.loadLevel!==u)return e.levelRetry=!0,this.playlistError=0,{action:ht.SendAlternateToPenaltyBox,flags:Gt.None,nextAutoLevel:u}}return{action:ht.SendAlternateToPenaltyBox,flags:Gt.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case ht.DoNothing:break;case ht.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==D.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,r=e.errorAction;if(!r)return;const{flags:s,hdcpLevel:n,nextAutoLevel:a}=r;switch(s){case Gt.None:this.switchLevel(e,a);break;case Gt.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=Xu[Xu.indexOf(n)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(e,a)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}}class Yh{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=I.log.bind(I,`${t}:`),this.warn=I.warn.bind(I,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,r){const s=t==null?void 0:t.renditionReports;if(s){let n=-1;for(let a=0;a<s.length;a++){const o=s[a];let l;try{l=new self.URL(o.URI,t.url).href}catch(d){I.warn(`Could not construct new URL for Rendition Report: ${d}`),l=o.URI||""}if(l===e){n=a;break}else l===e.substring(0,l.length)&&(n=a)}if(n!==-1){const a=s[n],o=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn);let l=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){const u=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&u>t.partTarget&&(l+=1)}const d=r&&Nm(r);return new Fm(o,l>=0?l:void 0,d)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){const{details:s,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||r!=null&&r.live){if(s.reloaded(r),r&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),r&&s.fragments.length>0&&lA(r,s),!this.canLoad||!s.live)return;let l,d,u;if(s.canBlockReload&&s.endSN&&s.advanced){const g=this.hls.config.lowLatencyMode,E=s.lastPartSn,y=s.endSN,b=s.lastPartIndex,S=b!==-1,_=E===y,x=g?0:b;S?(d=_?y+1:E,u=_?x:b+1):d=y+1;const A=s.age,C=A+s.ageHeader;let O=Math.min(C-s.partTarget,s.targetduration*1.5);if(O>0){if(r&&O>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${O} with playlist age: ${s.age}`),O=0;else{const L=Math.floor(O/s.targetduration);if(d+=L,u!==void 0){const M=Math.round(O%s.targetduration/s.partTarget);u+=M}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${A.toFixed(2)}s goal: ${O} skip sn ${L} to part ${u}`)}s.tuneInGoal=O}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u),g||!_){this.loadPlaylist(l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u));const c=this.hls.mainForwardBufferInfo,h=c?c.end-c.len:0,f=(s.edge-h)*1e3,m=hA(s,f);s.updated&&a>this.requestScheduled+m&&(this.requestScheduled=n.loading.start),d!==void 0&&s.canBlockReload?this.requestScheduled=n.loading.first+m-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+m<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=m);let p=this.requestScheduled-a;p=Math.max(0,p),this.log(`reload live playlist ${e} in ${Math.round(p)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),p)}else this.clearTimer()}getDeliveryDirectives(e,t,r,s){let n=Nm(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,n=Io.No),new Fm(r,s,n)}checkRetry(e){const t=e.details,r=Ql(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===ht.RetryRequest||!s.resolved&&n===ht.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(r&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const u=qh(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),u),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${u}ms`)}e.levelRetry=!0,s.resolved=!0}return l}}class vs{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){const r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class bA{constructor(e,t,r,s=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_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new vs(e),this.fast_=new vs(t),this.defaultTTFB_=s,this.ttfb_=new vs(e)}update(e,t){const{slow_:r,fast_:s,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new vs(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new vs(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new vs(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const r=8*t,s=e/1e3,n=r/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(e){const t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,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_}destroy(){}}const Ig={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},Hm={};function TA(i,e,t,r,s,n){const a=i.audioCodec?i.audioGroups:null,o=n==null?void 0:n.audioCodec,l=n==null?void 0:n.channels,d=l?parseInt(l):o?1/0:2;let u=null;if(a!=null&&a.length)try{a.length===1&&a[0]?u=e.groups[a[0]].channels:u=a.reduce((c,h)=>{if(h){const f=e.groups[h];if(!f)throw new Error(`Audio track group ${h} not found`);Object.keys(f.channels).forEach(m=>{c[m]=(c[m]||0)+f.channels[m]})}return c},{2:0})}catch{return!0}return i.videoCodec!==void 0&&(i.width>1920&&i.height>1088||i.height>1920&&i.width>1088||i.frameRate>Math.max(r,30)||i.videoRange!=="SDR"&&i.videoRange!==t||i.bitrate>Math.max(s,8e6))||!!u&&Y(d)&&Object.keys(u).some(c=>parseInt(c)>d)}function _A(i,e,t){const r=i.videoCodec,s=i.audioCodec;if(!r||!s||!t)return Promise.resolve(Ig);const n={width:i.width,height:i.height,bitrate:Math.ceil(Math.max(i.bitrate*.9,i.averageBitrate)),framerate:i.frameRate||30},a=i.videoRange;a!=="SDR"&&(n.transferFunction=a.toLowerCase());const o=r.split(",").map(l=>({type:"media-source",video:dt(dt({},n),{},{contentType:Ra(l,"video")})}));return s&&i.audioGroups&&i.audioGroups.forEach(l=>{var d;l&&((d=e.groups[l])==null||d.tracks.forEach(u=>{if(u.groupId===l){const c=u.channels||"",h=parseFloat(c);Y(h)&&h>2&&o.push.apply(o,s.split(",").map(f=>({type:"media-source",audio:{contentType:Ra(f,"audio"),channels:""+h}})))}}))}),Promise.all(o.map(l=>{const d=AA(l);return Hm[d]||(Hm[d]=t.decodingInfo(l))})).then(l=>({supported:!l.some(d=>!d.supported),configurations:o,decodingInfoResults:l})).catch(l=>({supported:!1,configurations:o,decodingInfoResults:[],error:l}))}function AA(i){const{audio:e,video:t}=i,r=t||e;if(r){const s=r.contentType.split('"')[1];if(t)return`r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${s}_${Math.ceil(t.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${s}`}return""}function SA(){if(typeof matchMedia=="function"){const i=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(i.media!==e.media)return i.matches===!0}return!1}function xA(i,e){let t=!1,r=[];return i&&(t=i!=="SDR",r=[i]),e&&(r=e.allowedVideoRanges||Xl.slice(0),t=e.preferHDR!==void 0?e.preferHDR:SA(),t?r=r.filter(s=>s!=="SDR"):r=["SDR"]),{preferHDR:t,allowedVideoRanges:r}}function kA(i,e,t,r,s){const n=Object.keys(i),a=r==null?void 0:r.channels,o=r==null?void 0:r.audioCodec,l=a&&parseInt(a)===2;let d=!0,u=!1,c=1/0,h=1/0,f=1/0,m=0,p=[];const{preferHDR:g,allowedVideoRanges:E}=xA(e,s);for(let _=n.length;_--;){const x=i[n[_]];d=x.channels[2]>0,c=Math.min(c,x.minHeight),h=Math.min(h,x.minFramerate),f=Math.min(f,x.minBitrate);const A=E.filter(C=>x.videoRanges[C]>0);A.length>0&&(u=!0,p=A)}c=Y(c)?c:0,h=Y(h)?h:0;const y=Math.max(1080,c),b=Math.max(30,h);return f=Y(f)?f:t,t=Math.max(f,t),u||(e=void 0,p=[]),{codecSet:n.reduce((_,x)=>{const A=i[x];if(x===_)return _;if(A.minBitrate>t)return Ri(x,`min bitrate of ${A.minBitrate} > current estimate of ${t}`),_;if(!A.hasDefaultAudio)return Ri(x,"no renditions with default or auto-select sound found"),_;if(o&&x.indexOf(o.substring(0,4))%5!==0)return Ri(x,`audio codec preference "${o}" not found`),_;if(a&&!l){if(!A.channels[a])return Ri(x,`no renditions with ${a} channel sound found (channels options: ${Object.keys(A.channels)})`),_}else if((!o||l)&&d&&A.channels[2]===0)return Ri(x,"no renditions with stereo sound found"),_;return A.minHeight>y?(Ri(x,`min resolution of ${A.minHeight} > maximum of ${y}`),_):A.minFramerate>b?(Ri(x,`min framerate of ${A.minFramerate} > maximum of ${b}`),_):p.some(C=>A.videoRanges[C]>0)?A.maxScore<m?(Ri(x,`max score of ${A.maxScore} < selected max of ${m}`),_):_&&(jl(x)>=jl(_)||A.fragmentError>i[_].fragmentError)?_:(m=A.maxScore,x):(Ri(x,`no variants with VIDEO-RANGE of ${JSON.stringify(p)} found`),_)},void 0),videoRanges:p,preferHDR:g,minFramerate:h,minBitrate:f}}function Ri(i,e){I.log(`[abr] start candidates with "${i}" ignored because ${e}`)}function LA(i){return i.reduce((e,t)=>{let r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);const s=t.channels||"2";return r.channels[s]=(r.channels[s]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function IA(i,e,t,r){return i.slice(t,r+1).reduce((s,n)=>{if(!n.codecSet)return s;const a=n.audioGroups;let o=s[n.codecSet];o||(s[n.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,n.bitrate);const l=Math.min(n.height,n.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,n.frameRate),o.maxScore=Math.max(o.maxScore,n.score),o.fragmentError+=n.fragmentError,o.videoRanges[n.videoRange]=(o.videoRanges[n.videoRange]||0)+1,a&&a.forEach(d=>{if(!d)return;const u=e.groups[d];u&&(o.hasDefaultAudio=o.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(c=>{o.channels[c]=(o.channels[c]||0)+u.channels[c]}))}),s},{})}function bi(i,e,t){if("attrs"in i){const r=e.indexOf(i);if(r!==-1)return r}for(let r=0;r<e.length;r++){const s=e[r];if(en(i,s,t))return r}return-1}function en(i,e,t){const{groupId:r,name:s,lang:n,assocLang:a,characteristics:o,default:l}=i,d=i.forced;return(r===void 0||e.groupId===r)&&(s===void 0||e.name===s)&&(n===void 0||e.lang===n)&&(n===void 0||e.assocLang===a)&&(l===void 0||e.default===l)&&(d===void 0||e.forced===d)&&(o===void 0||RA(o,e.characteristics))&&(t===void 0||t(i,e))}function RA(i,e=""){const t=i.split(","),r=e.split(",");return t.length===r.length&&!t.some(s=>r.indexOf(s)===-1)}function Es(i,e){const{audioCodec:t,channels:r}=i;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(r===void 0||r===(e.channels||"2"))}function wA(i,e,t,r,s){const n=e[r],o=e.reduce((h,f,m)=>{const p=f.uri;return(h[p]||(h[p]=[])).push(m),h},{})[n.uri];o.length>1&&(r=Math.max.apply(Math,o));const l=n.videoRange,d=n.frameRate,u=n.codecSet.substring(0,4),c=Wm(e,r,h=>{if(h.videoRange!==l||h.frameRate!==d||h.codecSet.substring(0,4)!==u)return!1;const f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return bi(i,m,s)>-1});return c>-1?c:Wm(e,r,h=>{const f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return bi(i,m,s)>-1})}function Wm(i,e,t){for(let r=e;r;r--)if(t(i[r]))return r;for(let r=e+1;r<i.length;r++)if(t(i[r]))return r;return-1}class CA{constructor(e){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.bwEstimator=void 0,this._abandonRulesCheck=()=>{const{fragCurrent:t,partCurrent:r,hls:s}=this,{autoLevelEnabled:n,media:a}=s;if(!t||!a)return;const o=performance.now(),l=r?r.stats:t.stats,d=r?r.duration:t.duration,u=o-l.loading.start,c=s.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||t.level<=c){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||a.paused||!a.playbackRate||!a.readyState)return;const h=s.mainForwardBufferInfo;if(h===null)return;const f=this.bwEstimator.getEstimateTTFB(),m=Math.abs(a.playbackRate);if(u<=Math.max(f,1e3*(d/(m*2))))return;const p=h.len/m,g=l.loading.first?l.loading.first-l.loading.start:-1,E=l.loaded&&g>-1,y=this.getBwEstimate(),b=s.levels,S=b[t.level],_=l.total||Math.max(l.loaded,Math.round(d*S.averageBitrate/8));let x=E?u-g:u;x<1&&E&&(x=Math.min(u,l.loaded*8/y));const A=E?l.loaded*1e3/x:0,C=A?(_-l.loaded)/A:_*8/y+f/1e3;if(C<=p)return;const O=A?A*8:y;let L=Number.POSITIVE_INFINITY,M;for(M=t.level-1;M>c;M--){const U=b[M].maxBitrate;if(L=this.getTimeToLoadFrag(f/1e3,O,d*U,!b[M].details),L<p)break}if(L>=C||L>d*10)return;s.nextLoadLevel=s.nextAutoLevel=M,E?this.bwEstimator.sample(u-Math.min(f,g),l.loaded):this.bwEstimator.sampleTTFB(u);const K=b[M].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>K&&this.resetEstimator(K),this.clearTimer(),I.warn(`[abr] Fragment ${t.sn}${r?" part "+r.index:""} of level ${t.level} is loading too slowly;
22
+ */function J_(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var og={exports:{}};(function(i,e){(function(t){var r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,s=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,u){if(u=u||{},l=l.trim(),d=d.trim(),!d){if(!u.alwaysNormalize)return l;var c=o.parseURL(l);if(!c)throw new Error("Error trying to parse base URL.");return c.path=o.normalizePath(c.path),o.buildURLFromParts(c)}var h=o.parseURL(d);if(!h)throw new Error("Error trying to parse relative URL.");if(h.scheme)return u.alwaysNormalize?(h.path=o.normalizePath(h.path),o.buildURLFromParts(h)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var m=s.exec(f.path);f.netLoc=m[1],f.path=m[2]}f.netLoc&&!f.path&&(f.path="/");var p={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(p.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)p.path=f.path,h.params||(p.params=f.params,h.query||(p.query=f.query));else{var g=f.path,E=g.substring(0,g.lastIndexOf("/")+1)+h.path;p.path=o.normalizePath(E)}return p.path===null&&(p.path=u.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(p)},parseURL:function(l){var d=r.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};i.exports=o})()})(og);var Kh=og.exports;function gm(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function dt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?gm(Object(t),!0).forEach(function(r){i1(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):gm(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function e1(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function t1(i){var e=e1(i,"string");return typeof e=="symbol"?e:String(e)}function i1(i,e,t){return e=t1(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function We(){return We=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},We.apply(this,arguments)}const Y=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)},r1=Number.isSafeInteger||function(i){return typeof i=="number"&&Math.abs(i)<=s1},s1=Number.MAX_SAFE_INTEGER||9007199254740991;let v=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",i}({}),ie=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),D=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({});const kr=function(){},Yu={trace:kr,debug:kr,log:kr,warn:kr,info:kr,error:kr};let Ea=Yu;function n1(i){const e=self.console[i];return e?e.bind(self.console,`[${i}] >`):kr}function a1(i,...e){e.forEach(function(t){Ea[t]=i[t]?i[t].bind(i):n1(t)})}function o1(i,e){if(typeof console=="object"&&i===!0||typeof i=="object"){a1(i,"debug","log","info","warn","error");try{Ea.log(`Debug logs enabled for "${e}" in hls.js version 1.5.15`)}catch{Ea=Yu}}else Ea=Yu}const I=Ea,l1=/^(\d+)x(\d+)$/,vm=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Me{constructor(e){typeof e=="string"&&(e=Me.parseAttrList(e)),We(this,e)}get clientAttrs(){return Object.keys(this).filter(e=>e.substring(0,2)==="X-")}decimalInteger(e){const t=parseInt(this[e],10);return t>Number.MAX_SAFE_INTEGER?1/0:t}hexadecimalInteger(e){if(this[e]){let t=(this[e]||"0x").slice(2);t=(t.length&1?"0":"")+t;const r=new Uint8Array(t.length/2);for(let s=0;s<t.length/2;s++)r[s]=parseInt(t.slice(s*2,s*2+2),16);return r}else return null}hexadecimalIntegerAsNumber(e){const t=parseInt(this[e],16);return t>Number.MAX_SAFE_INTEGER?1/0:t}decimalFloatingPoint(e){return parseFloat(this[e])}optionalFloat(e,t){const r=this[e];return r?parseFloat(r):t}enumeratedString(e){return this[e]}bool(e){return this[e]==="YES"}decimalResolution(e){const t=l1.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const r={},s='"';for(vm.lastIndex=0;(t=vm.exec(e))!==null;){let n=t[2];n.indexOf(s)===0&&n.lastIndexOf(s)===n.length-1&&(n=n.slice(1,-1));const a=t[1].trim();r[a]=n}return r}}function d1(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function u1(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}class lg{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const r=t.attr;for(const s in r)if(Object.prototype.hasOwnProperty.call(e,s)&&e[s]!==r[s]){I.warn(`DATERANGE tag attribute: "${s}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=s;break}e=We(new Me({}),r,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const r=new Date(this.attr["END-DATE"]);Y(r.getTime())&&(this._endDate=r)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(Y(e))return e}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 isValid(){return!!this.id&&!this._badValueForSameId&&Y(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class wd{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 ye={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class dg{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[ye.AUDIO]:null,[ye.VIDEO]:null,[ye.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){const r=e.split("@",2);let s;r.length===1?s=(t==null?void 0:t.byteRangeEndOffset)||0:s=parseInt(r[1]),this._byteRange=[s,parseInt(r[0])+s]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Kh.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class Jd extends dg{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=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.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new wd,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=e}get decryptdata(){const{levelkeys:e}=this;if(!e&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){const t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{const r=Object.keys(this.levelkeys);if(r.length===1)return this._decryptdata=this.levelkeys[r[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!Y(this.programDateTime))return null;const e=Y(this.duration)?this.duration:0;return this.programDateTime+e*1e3}get encrypted(){var e;if((e=this._decryptdata)!=null&&e.encrypted)return!0;if(this.levelkeys){const t=Object.keys(this.levelkeys),r=t.length;if(r>1||r===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}setKeyFormat(e){if(this.levelkeys){const t=this.levelkeys[e];t&&!this._decryptdata&&(this._decryptdata=t.getDecryptData(this.sn))}}abortRequests(){var e,t;(e=this.loader)==null||e.abort(),(t=this.keyLoader)==null||t.abort()}setElementaryStreamInfo(e,t,r,s,n,a=!1){const{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:r,startDTS:s,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,r),l.startDTS=Math.min(l.startDTS,s),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[ye.AUDIO]=null,e[ye.VIDEO]=null,e[ye.AUDIOVIDEO]=null}}let c1=class extends dg{constructor(e,t,r,s,n){super(r),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.stats=new wd,this.duration=e.decimalFloatingPoint("DURATION"),this.gap=e.bool("GAP"),this.independent=e.bool("INDEPENDENT"),this.relurl=e.enumeratedString("URI"),this.fragment=t,this.index=s;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.duration)}get start(){return this.fragment.start+this.fragOffset}get end(){return this.start+this.duration}get loaded(){const{elementaryStreams:e}=this;return!!(e.audio||e.video||e.audiovideo)}};const h1=10;class f1{constructor(e){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.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 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.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=e}reloaded(e){if(!e){this.advanced=!0,this.updated=!0;return}const t=this.lastPartSn-e.lastPartSn,r=this.lastPartIndex-e.lastPartIndex;this.updated=this.endSN!==e.endSN||!!r||!!t||!this.live,this.advanced=this.endSN>e.endSN||t>0||t===0&&r>0,this.updated||this.advanced?this.misses=Math.floor(e.misses*.6):this.misses=e.misses+1,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?Y(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||h1}get drift(){const e=this.driftEndTime-this.driftStartTime;return e>0?(this.driftEnd-this.driftStart)*1e3/e:1}get edge(){return this.partEnd||this.fragmentEnd}get partEnd(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].end:this.fragmentEnd}get fragmentEnd(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end:0}get age(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}get lastPartIndex(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].index:-1}get lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function Vh(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function m1(i){const e=ju(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function p1(i){const e=function(r,s,n){const a=r[s];r[s]=r[n],r[n]=a};e(i,0,3),e(i,1,2),e(i,4,5),e(i,6,7)}function g1(i){const e=i.split(":");let t=null;if(e[0]==="data"&&e.length===2){const r=e[1].split(";"),s=r[r.length-1].split(",");if(s.length===2){const n=s[0]==="base64",a=s[1];n?(r.splice(-1,1),t=Vh(a)):t=m1(a)}}return t}function ju(i){return Uint8Array.from(unescape(encodeURIComponent(i)),e=>e.charCodeAt(0))}const mn=typeof self<"u"?self:void 0;var Ie={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},At={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Em(i){switch(i){case At.FAIRPLAY:return Ie.FAIRPLAY;case At.PLAYREADY:return Ie.PLAYREADY;case At.WIDEVINE:return Ie.WIDEVINE;case At.CLEARKEY:return Ie.CLEARKEY}}var Wn={CENC:"1077efecc0b24d02ace33c1e52e2fb4b",CLEARKEY:"e2719d58a985b3c9781ab030af78d30e",FAIRPLAY:"94ce86fb07ff4f43adb893d2fa968ca2",PLAYREADY:"9a04f07998404286ab92e65be0885f95",WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function ym(i){if(i===Wn.WIDEVINE)return Ie.WIDEVINE;if(i===Wn.PLAYREADY)return Ie.PLAYREADY;if(i===Wn.CENC||i===Wn.CLEARKEY)return Ie.CLEARKEY}function bm(i){switch(i){case Ie.FAIRPLAY:return At.FAIRPLAY;case Ie.PLAYREADY:return At.PLAYREADY;case Ie.WIDEVINE:return At.WIDEVINE;case Ie.CLEARKEY:return At.CLEARKEY}}function eu(i){const{drmSystems:e,widevineLicenseUrl:t}=i,r=e?[Ie.FAIRPLAY,Ie.WIDEVINE,Ie.PLAYREADY,Ie.CLEARKEY].filter(s=>!!e[s]):[];return!r[Ie.WIDEVINE]&&t&&r.push(Ie.WIDEVINE),r}const ug=function(i){return mn!=null&&(i=mn.navigator)!=null&&i.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function v1(i,e,t,r){let s;switch(i){case Ie.FAIRPLAY:s=["cenc","sinf"];break;case Ie.WIDEVINE:case Ie.PLAYREADY:s=["cenc"];break;case Ie.CLEARKEY:s=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return E1(s,e,t,r)}function E1(i,e,t,r){return[{initDataTypes:i,persistentState:r.persistentState||"optional",distinctiveIdentifier:r.distinctiveIdentifier||"optional",sessionTypes:r.sessionTypes||[r.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:r.audioRobustness||"",encryptionScheme:r.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:r.videoRobustness||"",encryptionScheme:r.videoEncryptionScheme||null}))}]}function is(i,e,t){return Uint8Array.prototype.slice?i.slice(e,t):new Uint8Array(Array.prototype.slice.call(i,e,t))}const qh=(i,e)=>e+10<=i.length&&i[e]===73&&i[e+1]===68&&i[e+2]===51&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,cg=(i,e)=>e+10<=i.length&&i[e]===51&&i[e+1]===68&&i[e+2]===73&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Ia=(i,e)=>{const t=e;let r=0;for(;qh(i,e);){r+=10;const s=Cd(i,e+6);r+=s,cg(i,e+10)&&(r+=10),e+=r}if(r>0)return i.subarray(t,t+r)},Cd=(i,e)=>{let t=0;return t=(i[e]&127)<<21,t|=(i[e+1]&127)<<14,t|=(i[e+2]&127)<<7,t|=i[e+3]&127,t},y1=(i,e)=>qh(i,e)&&Cd(i,e+6)+10<=i.length-e,Yh=i=>{const e=fg(i);for(let t=0;t<e.length;t++){const r=e[t];if(hg(r))return x1(r)}},hg=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",b1=i=>{const e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=Cd(i,4),r=10;return{type:e,size:t,data:i.subarray(r,r+t)}},fg=i=>{let e=0;const t=[];for(;qh(i,e);){const r=Cd(i,e+6);e+=10;const s=e+r;for(;e+8<s;){const n=b1(i.subarray(e)),a=T1(n);a&&t.push(a),e+=n.size+10}cg(i,e)&&(e+=10)}return t},T1=i=>i.type==="PRIV"?_1(i):i.type[0]==="W"?S1(i):A1(i),_1=i=>{if(i.size<2)return;const e=Si(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},A1=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1;const r=Si(i.data.subarray(t),!0);t+=r.length+1;const s=Si(i.data.subarray(t));return{key:i.type,info:r,data:s}}const e=Si(i.data.subarray(1));return{key:i.type,data:e}},S1=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1;const r=Si(i.data.subarray(t),!0);t+=r.length+1;const s=Si(i.data.subarray(t));return{key:i.type,info:r,data:s}}const e=Si(i.data);return{key:i.type,data:e}},x1=i=>{if(i.data.byteLength===8){const e=new Uint8Array(i.data),t=e[3]&1;let r=(e[4]<<23)+(e[5]<<15)+(e[6]<<7)+e[7];return r/=45,t&&(r+=4772185884e-2),Math.round(r)}},Si=(i,e=!1)=>{const t=k1();if(t){const d=t.decode(i);if(e){const u=d.indexOf("\0");return u!==-1?d.substring(0,u):d}return d.replace(/\0/g,"")}const r=i.length;let s,n,a,o="",l=0;for(;l<r;){if(s=i[l++],s===0&&e)return o;if(s===0||s===3)continue;switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(s);break;case 12:case 13:n=i[l++],o+=String.fromCharCode((s&31)<<6|n&63);break;case 14:n=i[l++],a=i[l++],o+=String.fromCharCode((s&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o};let tu;function k1(){if(!navigator.userAgent.includes("PlayStation 4"))return!tu&&typeof self.TextDecoder<"u"&&(tu=new self.TextDecoder("utf-8")),tu}const mi={hexDump:function(i){let e="";for(let t=0;t<i.length;t++){let r=i[t].toString(16);r.length<2&&(r="0"+r),e+=r}return e}},jl=Math.pow(2,32)-1,L1=[].push,mg={video:1,audio:2,id3:3,text:4};function Ve(i){return String.fromCharCode.apply(null,i)}function pg(i,e){const t=i[e]<<8|i[e+1];return t<0?65536+t:t}function J(i,e){const t=gg(i,e);return t<0?4294967296+t:t}function Tm(i,e){let t=J(i,e);return t*=Math.pow(2,32),t+=J(i,e+4),t}function gg(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function iu(i,e,t){i[e]=t>>24,i[e+1]=t>>16&255,i[e+2]=t>>8&255,i[e+3]=t&255}function I1(i){const e=i.byteLength;for(let t=0;t<e;){const r=J(i,t);if(r>8&&i[t+4]===109&&i[t+5]===111&&i[t+6]===111&&i[t+7]===102)return!0;t=r>1?t+r:e}return!1}function le(i,e){const t=[];if(!e.length)return t;const r=i.byteLength;for(let s=0;s<r;){const n=J(i,s),a=Ve(i.subarray(s+4,s+8)),o=n>1?s+n:r;if(a===e[0])if(e.length===1)t.push(i.subarray(s+8,o));else{const l=le(i.subarray(s+8,o),e.slice(1));l.length&&L1.apply(t,l)}s=o}return t}function R1(i){const e=[],t=i[0];let r=8;const s=J(i,r);r+=4;let n=0,a=0;t===0?(n=J(i,r),a=J(i,r+4),r+=8):(n=Tm(i,r),a=Tm(i,r+8),r+=16),r+=2;let o=i.length+a;const l=pg(i,r);r+=2;for(let d=0;d<l;d++){let u=r;const c=J(i,u);u+=4;const h=c&2147483647;if((c&2147483648)>>>31===1)return I.warn("SIDX has hierarchical references (not supported)"),null;const m=J(i,u);u+=4,e.push({referenceSize:h,subsegmentDuration:m,info:{duration:m/s,start:o,end:o+h-1}}),o+=h,u+=4,r=u}return{earliestPresentationTime:n,timescale:s,version:t,referencesCount:l,references:e}}function vg(i){const e=[],t=le(i,["moov","trak"]);for(let s=0;s<t.length;s++){const n=t[s],a=le(n,["tkhd"])[0];if(a){let o=a[0];const l=J(a,o===0?12:20),d=le(n,["mdia","mdhd"])[0];if(d){o=d[0];const u=J(d,o===0?12:20),c=le(n,["mdia","hdlr"])[0];if(c){const h=Ve(c.subarray(8,12)),f={soun:ye.AUDIO,vide:ye.VIDEO}[h];if(f){const m=le(n,["mdia","minf","stbl","stsd"])[0],p=w1(m);e[l]={timescale:u,type:f},e[f]=dt({timescale:u,id:l},p)}}}}}return le(i,["moov","mvex","trex"]).forEach(s=>{const n=J(s,4),a=e[n];a&&(a.default={duration:J(s,12),flags:J(s,20)})}),e}function w1(i){const e=i.subarray(8),t=e.subarray(86),r=Ve(e.subarray(4,8));let s=r;const n=r==="enca"||r==="encv";if(n){const o=le(e,[r])[0].subarray(r==="enca"?28:78);le(o,["sinf"]).forEach(d=>{const u=le(d,["schm"])[0];if(u){const c=Ve(u.subarray(4,8));if(c==="cbcs"||c==="cenc"){const h=le(d,["frma"])[0];h&&(s=Ve(h))}}})}switch(s){case"avc1":case"avc2":case"avc3":case"avc4":{const a=le(t,["avcC"])[0];s+="."+Qa(a[1])+Qa(a[2])+Qa(a[3]);break}case"mp4a":{const a=le(e,[r])[0],o=le(a.subarray(28),["esds"])[0];if(o&&o.length>12){let l=4;if(o[l++]!==3)break;l=ru(o,l),l+=2;const d=o[l++];if(d&128&&(l+=2),d&64&&(l+=o[l++]),o[l++]!==4)break;l=ru(o,l);const u=o[l++];if(u===64)s+="."+Qa(u);else break;if(l+=12,o[l++]!==5)break;l=ru(o,l);const c=o[l++];let h=(c&248)>>3;h===31&&(h+=1+((c&7)<<3)+((o[l]&224)>>5)),s+="."+h}break}case"hvc1":case"hev1":{const a=le(t,["hvcC"])[0],o=a[1],l=["","A","B","C"][o>>6],d=o&31,u=J(a,2),c=(o&32)>>5?"H":"L",h=a[12],f=a.subarray(6,12);s+="."+l+d,s+="."+u.toString(16).toUpperCase(),s+="."+c+h;let m="";for(let p=f.length;p--;){const g=f[p];(g||m)&&(m="."+g.toString(16).toUpperCase()+m)}s+=m;break}case"dvh1":case"dvhe":{const a=le(t,["dvcC"])[0],o=a[2]>>1&127,l=a[2]<<5&32|a[3]>>3&31;s+="."+Jt(o)+"."+Jt(l);break}case"vp09":{const a=le(t,["vpcC"])[0],o=a[4],l=a[5],d=a[6]>>4&15;s+="."+Jt(o)+"."+Jt(l)+"."+Jt(d);break}case"av01":{const a=le(t,["av1C"])[0],o=a[1]>>>5,l=a[1]&31,d=a[2]>>>7?"H":"M",u=(a[2]&64)>>6,c=(a[2]&32)>>5,h=o===2&&u?c?12:10:u?10:8,f=(a[2]&16)>>4,m=(a[2]&8)>>3,p=(a[2]&4)>>2,g=a[2]&3;s+="."+o+"."+Jt(l)+d+"."+Jt(h)+"."+f+"."+m+p+g+"."+Jt(1)+"."+Jt(1)+"."+Jt(1)+"."+0;break}}return{codec:s,encrypted:n}}function ru(i,e){const t=e+5;for(;i[e++]&128&&e<t;);return e}function Qa(i){return("0"+i.toString(16).toUpperCase()).slice(-2)}function Jt(i){return(i<10?"0":"")+i}function C1(i,e){if(!i||!e)return i;const t=e.keyId;return t&&e.isCommonEncryption&&le(i,["moov","trak"]).forEach(s=>{const a=le(s,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=le(a,["enca"]);const l=o.length>0;l||(o=le(a,["encv"])),o.forEach(d=>{const u=l?d.subarray(28):d.subarray(78);le(u,["sinf"]).forEach(h=>{const f=Eg(h);if(f){const m=f.subarray(8,24);m.some(p=>p!==0)||(I.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${mi.hexDump(m)} -> ${mi.hexDump(t)}`),f.set(t,8))}})})}),i}function Eg(i){const e=le(i,["schm"])[0];if(e){const t=Ve(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return le(i,["schi","tenc"])[0]}return null}function D1(i,e){return le(e,["moof","traf"]).reduce((t,r)=>{const s=le(r,["tfdt"])[0],n=s[0],a=le(r,["tfhd"]).reduce((o,l)=>{const d=J(l,4),u=i[d];if(u){let c=J(s,4);if(n===1){if(c===jl)return I.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;c*=jl+1,c+=J(s,8)}const h=u.timescale||9e4,f=c/h;if(Y(f)&&(o===null||f<o))return f}return o},null);return a!==null&&Y(a)&&(t===null||a<t)?a:t},null)}function M1(i,e){let t=0,r=0,s=0;const n=le(i,["moof","traf"]);for(let a=0;a<n.length;a++){const o=n[a],l=le(o,["tfhd"])[0],d=J(l,4),u=e[d];if(!u)continue;const c=u.default,h=J(l,0)|(c==null?void 0:c.flags);let f=c==null?void 0:c.duration;h&8&&(h&2?f=J(l,12):f=J(l,8));const m=u.timescale||9e4,p=le(o,["trun"]);for(let g=0;g<p.length;g++){if(t=P1(p[g]),!t&&f){const E=J(p[g],4);t=f*E}u.type===ye.VIDEO?r+=t/m:u.type===ye.AUDIO&&(s+=t/m)}}if(r===0&&s===0){let a=1/0,o=0,l=0;const d=le(i,["sidx"]);for(let u=0;u<d.length;u++){const c=R1(d[u]);if(c!=null&&c.references){a=Math.min(a,c.earliestPresentationTime/c.timescale);const h=c.references.reduce((f,m)=>f+m.info.duration||0,0);o=Math.max(o,h+c.earliestPresentationTime/c.timescale),l=o-a}}if(l&&Y(l))return l}return r||s}function P1(i){const e=J(i,0);let t=8;e&1&&(t+=4),e&4&&(t+=4);let r=0;const s=J(i,4);for(let n=0;n<s;n++){if(e&256){const a=J(i,t);r+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return r}function O1(i,e,t){le(e,["moof","traf"]).forEach(r=>{le(r,["tfhd"]).forEach(s=>{const n=J(s,4),a=i[n];if(!a)return;const o=a.timescale||9e4;le(r,["tfdt"]).forEach(l=>{const d=l[0],u=t*o;if(u){let c=J(l,4);if(d===0)c-=u,c=Math.max(c,0),iu(l,4,c);else{c*=Math.pow(2,32),c+=J(l,8),c-=u,c=Math.max(c,0);const h=Math.floor(c/(jl+1)),f=Math.floor(c%(jl+1));iu(l,4,h),iu(l,8,f)}}})})})}function N1(i){const e={valid:null,remainder:null},t=le(i,["moof"]);if(t.length<2)return e.remainder=i,e;const r=t[t.length-1];return e.valid=is(i,0,r.byteOffset-8),e.remainder=is(i,r.byteOffset-8),e}function Ut(i,e){const t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function _m(i,e){const t=[],r=e.samples,s=e.timescale,n=e.id;let a=!1;return le(r,["moof"]).map(l=>{const d=l.byteOffset-8;le(l,["traf"]).map(c=>{const h=le(c,["tfdt"]).map(f=>{const m=f[0];let p=J(f,4);return m===1&&(p*=Math.pow(2,32),p+=J(f,8)),p/s})[0];return h!==void 0&&(i=h),le(c,["tfhd"]).map(f=>{const m=J(f,4),p=J(f,0)&16777215,g=(p&1)!==0,E=(p&2)!==0,y=(p&8)!==0;let b=0;const S=(p&16)!==0;let _=0;const x=(p&32)!==0;let A=8;m===n&&(g&&(A+=8),E&&(A+=4),y&&(b=J(f,A),A+=4),S&&(_=J(f,A),A+=4),x&&(A+=4),e.type==="video"&&(a=F1(e.codec)),le(c,["trun"]).map(C=>{const O=C[0],L=J(C,0)&16777215,M=(L&1)!==0;let K=0;const U=(L&4)!==0,z=(L&256)!==0;let V=0;const q=(L&512)!==0;let ae=0;const ne=(L&1024)!==0,G=(L&2048)!==0;let $=0;const te=J(C,4);let re=8;M&&(K=J(C,re),re+=4),U&&(re+=4);let oe=K+d;for(let pe=0;pe<te;pe++){if(z?(V=J(C,re),re+=4):V=b,q?(ae=J(C,re),re+=4):ae=_,ne&&(re+=4),G&&(O===0?$=J(C,re):$=gg(C,re),re+=4),e.type===ye.VIDEO){let Re=0;for(;Re<ae;){const $e=J(r,oe);if(oe+=4,U1(a,r[oe])){const yt=r.subarray(oe,oe+$e);yg(yt,a?2:1,i+$/s,t)}oe+=$e,Re+=$e+4}}i+=V/s}}))})})}),t}function F1(i){if(!i)return!1;const e=i.indexOf("."),t=e<0?i:i.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function U1(i,e){if(i){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function yg(i,e,t,r){const s=bg(i);let n=0;n+=e;let a=0,o=0,l=0;for(;n<s.length;){a=0;do{if(n>=s.length)break;l=s[n++],a+=l}while(l===255);o=0;do{if(n>=s.length)break;l=s[n++],o+=l}while(l===255);const d=s.length-n;let u=n;if(o<d)n+=o;else if(o>d){I.error(`Malformed SEI payload. ${o} is too small, only ${d} bytes left to parse.`);break}if(a===4){if(s[u++]===181){const h=pg(s,u);if(u+=2,h===49){const f=J(s,u);if(u+=4,f===1195456820){const m=s[u++];if(m===3){const p=s[u++],g=31&p,E=64&p,y=E?2+g*3:0,b=new Uint8Array(y);if(E){b[0]=p;for(let S=1;S<y;S++)b[S]=s[u++]}r.push({type:m,payloadType:a,pts:t,bytes:b})}}}}}else if(a===5&&o>16){const c=[];for(let m=0;m<16;m++){const p=s[u++].toString(16);c.push(p.length==1?"0"+p:p),(m===3||m===5||m===7||m===9)&&c.push("-")}const h=o-16,f=new Uint8Array(h);for(let m=0;m<h;m++)f[m]=s[u++];r.push({payloadType:a,pts:t,uuid:c.join(""),userData:Si(f),userDataBytes:f})}}}function bg(i){const e=i.byteLength,t=[];let r=1;for(;r<e-2;)i[r]===0&&i[r+1]===0&&i[r+2]===3?(t.push(r+2),r+=2):r++;if(t.length===0)return i;const s=e-t.length,n=new Uint8Array(s);let a=0;for(r=0;r<s;a++,r++)a===t[0]&&(a++,t.shift()),n[r]=i[a];return n}function $1(i){const e=i[0];let t="",r="",s=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;Ve(i.subarray(d,d+1))!=="\0";)t+=Ve(i.subarray(d,d+1)),d+=1;for(t+=Ve(i.subarray(d,d+1)),d+=1;Ve(i.subarray(d,d+1))!=="\0";)r+=Ve(i.subarray(d,d+1)),d+=1;r+=Ve(i.subarray(d,d+1)),d+=1,s=J(i,12),n=J(i,16),o=J(i,20),l=J(i,24),d=28}else if(e===1){d+=4,s=J(i,d),d+=4;const c=J(i,d);d+=4;const h=J(i,d);for(d+=4,a=2**32*c+h,r1(a)||(a=Number.MAX_SAFE_INTEGER,I.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=J(i,d),d+=4,l=J(i,d),d+=4;Ve(i.subarray(d,d+1))!=="\0";)t+=Ve(i.subarray(d,d+1)),d+=1;for(t+=Ve(i.subarray(d,d+1)),d+=1;Ve(i.subarray(d,d+1))!=="\0";)r+=Ve(i.subarray(d,d+1)),d+=1;r+=Ve(i.subarray(d,d+1)),d+=1}const u=i.subarray(d,i.byteLength);return{schemeIdUri:t,value:r,timeScale:s,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:u}}function B1(i,...e){const t=e.length;let r=8,s=t;for(;s--;)r+=e[s].byteLength;const n=new Uint8Array(r);for(n[0]=r>>24&255,n[1]=r>>16&255,n[2]=r>>8&255,n[3]=r&255,n.set(i,4),s=0,r=8;s<t;s++)n.set(e[s],r),r+=e[s].byteLength;return n}function G1(i,e,t){if(i.byteLength!==16)throw new RangeError("Invalid system id");let r,s;r=0,s=new Uint8Array;let n;r>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;const a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),B1([112,115,115,104],new Uint8Array([r,0,0,0]),i,n,s,a,t||new Uint8Array)}function H1(i){const e=[];if(i instanceof ArrayBuffer){const t=i.byteLength;let r=0;for(;r+32<t;){const s=new DataView(i,r),n=W1(s);e.push(n),r+=n.size}}return e}function W1(i){const e=i.getUint32(0),t=i.byteOffset,r=i.byteLength;if(r<e)return{offset:t,size:r};if(i.getUint32(4)!==1886614376)return{offset:t,size:e};const n=i.getUint32(8)>>>24;if(n!==0&&n!==1)return{offset:t,size:e};const a=i.buffer,o=mi.hexDump(new Uint8Array(a,t+12,16)),l=i.getUint32(28);let d=null,u=null;if(n===0){if(e-32<l||l<22)return{offset:t,size:e};u=new Uint8Array(a,t+32,l)}else if(n===1){if(!l||r<t+32+l*16+16)return{offset:t,size:e};d=[];for(let c=0;c<l;c++)d.push(new Uint8Array(a,t+32+c*16,16))}return{version:n,systemId:o,kids:d,data:u,offset:t,size:e}}let Za={};class Ra{static clearKeyUriToKeyIdMap(){Za={}}constructor(e,t,r,s=[1],n=null){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=e,this.uri=t,this.keyFormat=r,this.keyFormatVersions=s,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case At.FAIRPLAY:case At.WIDEVINE:case At.PLAYREADY:case At.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&I.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const r=K1(e);return new Ra(this.method,this.uri,"identity",this.keyFormatVersions,r)}const t=g1(this.uri);if(t)switch(this.keyFormat){case At.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case At.PLAYREADY:{const r=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=G1(r,null,t);const s=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),n=String.fromCharCode.apply(null,Array.from(s)),a=n.substring(n.indexOf("<"),n.length),d=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(d){const u=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(u){const c=Vh(u).subarray(0,16);p1(c),this.keyId=c}}break}default:{let r=t.subarray(0,16);if(r.length!==16){const s=new Uint8Array(16);s.set(r,16-r.length),r=s}this.keyId=r;break}}if(!this.keyId||this.keyId.byteLength!==16){let r=Za[this.uri];if(!r){const s=Object.keys(Za).length%Number.MAX_SAFE_INTEGER;r=new Uint8Array(16),new DataView(r.buffer,12,4).setUint32(0,s),Za[this.uri]=r}this.keyId=r}return this}}function K1(i){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}const Tg=/\{\$([a-zA-Z0-9-_]+)\}/g;function Am(i){return Tg.test(i)}function bt(i,e,t){if(i.variableList!==null||i.hasVariableRefs)for(let r=t.length;r--;){const s=t[r],n=e[s];n&&(e[s]=zu(i,n))}}function zu(i,e){if(i.variableList!==null||i.hasVariableRefs){const t=i.variableList;return e.replace(Tg,r=>{const s=r.substring(2,r.length-1),n=t==null?void 0:t[s];return n===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${s}"`)),r):n})}return e}function Sm(i,e,t){let r=i.variableList;r||(i.variableList=r={});let s,n;if("QUERYPARAM"in e){s=e.QUERYPARAM;try{const a=new self.URL(t).searchParams;if(a.has(s))n=a.get(s);else throw new Error(`"${s}" does not match any query parameter in URI: "${t}"`)}catch(a){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else s=e.NAME,n=e.VALUE;s in r?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${s}"`)):r[s]=n||""}function V1(i,e,t){const r=e.IMPORT;if(t&&r in t){let s=i.variableList;s||(i.variableList=s={}),s[r]=t[r]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${r}"`))}function ds(i=!0){return typeof self>"u"?void 0:(i||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function q1(i){return typeof self<"u"&&i===self.ManagedMediaSource}const zl={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,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 Y1(i,e){const t=zl[e];return!!t&&!!t[i.slice(0,4)]}function su(i,e,t=!0){return!i.split(",").some(r=>!_g(r,e,t))}function _g(i,e,t=!0){var r;const s=ds(t);return(r=s==null?void 0:s.isTypeSupported(wa(i,e)))!=null?r:!1}function wa(i,e){return`${e}/mp4;codecs="${i}"`}function xm(i){if(i){const e=i.substring(0,4);return zl.video[e]}return 2}function Xl(i){return i.split(",").reduce((e,t)=>{const r=zl.video[t];return r?(r*2+e)/(e?3:2):(zl.audio[t]+e)/(e?2:1)},0)}const nu={};function j1(i,e=!0){if(nu[i])return nu[i];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[i];for(let r=0;r<t.length;r++)if(_g(t[r],"audio",e))return nu[i]=t[r],t[r];return i}const z1=/flac|opus/i;function Ql(i,e=!0){return i.replace(z1,t=>j1(t.toLowerCase(),e))}function km(i,e){return i&&i!=="mp4a"?i:e&&e.split(",")[0]}function X1(i){const e=i.split(",");for(let t=0;t<e.length;t++){const r=e[t].split(".");if(r.length>2){let s=r.shift()+".";s+=parseInt(r.shift()).toString(16),s+=("000"+parseInt(r.shift()).toString(16)).slice(-4),e[t]=s}}return e.join(",")}const Lm=/#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,Im=/#EXT-X-MEDIA:(.*)/g,Q1=/^#EXT(?:INF|-X-TARGETDURATION):/m,Rm=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),Z1=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(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 yi{static findGroup(e,t){for(let r=0;r<e.length;r++){const s=e[r];if(s.id===t)return s}}static resolve(e,t){return Kh.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return Q1.test(e)}static parseMasterPlaylist(e,t){const r=Am(e),s={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:r},n=[];Lm.lastIndex=0;let a;for(;(a=Lm.exec(e))!=null;)if(a[1]){var o;const d=new Me(a[1]);bt(s,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const u=zu(s,a[2]),c={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:yi.resolve(u,t)},h=d.decimalResolution("RESOLUTION");h&&(c.width=h.width,c.height=h.height),J1(d.CODECS,c),(o=c.unknownCodecs)!=null&&o.length||n.push(c),s.levels.push(c)}else if(a[3]){const d=a[3],u=a[4];switch(d){case"SESSION-DATA":{const c=new Me(u);bt(s,c,["DATA-ID","LANGUAGE","VALUE","URI"]);const h=c["DATA-ID"];h&&(s.sessionData===null&&(s.sessionData={}),s.sessionData[h]=c);break}case"SESSION-KEY":{const c=wm(u,t,s);c.encrypted&&c.isSupported()?(s.sessionKeys===null&&(s.sessionKeys=[]),s.sessionKeys.push(c)):I.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${u}"`);break}case"DEFINE":{{const c=new Me(u);bt(s,c,["NAME","VALUE","QUERYPARAM"]),Sm(s,c,t)}break}case"CONTENT-STEERING":{const c=new Me(u);bt(s,c,["SERVER-URI","PATHWAY-ID"]),s.contentSteering={uri:yi.resolve(c["SERVER-URI"],t),pathwayId:c["PATHWAY-ID"]||"."};break}case"START":{s.startTimeOffset=Cm(u);break}}}const l=n.length>0&&n.length<s.levels.length;return s.levels=l?n:s.levels,s.levels.length===0&&(s.playlistParsingError=new Error("no levels found in manifest")),s}static parseMasterPlaylistMedia(e,t,r){let s;const n={},a=r.levels,o={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]};let l=0;for(Im.lastIndex=0;(s=Im.exec(e))!==null;){const d=new Me(s[1]),u=d.TYPE;if(u){const c=o[u],h=n[u]||[];n[u]=h,bt(r,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const f=d.LANGUAGE,m=d["ASSOC-LANGUAGE"],p=d.CHANNELS,g=d.CHARACTERISTICS,E=d["INSTREAM-ID"],y={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",name:d.NAME||f||"",type:u,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:f,url:d.URI?yi.resolve(d.URI,t):""};if(m&&(y.assocLang=m),p&&(y.channels=p),g&&(y.characteristics=g),E&&(y.instreamId=E),c!=null&&c.length){const b=yi.findGroup(c,y.groupId)||c[0];Dm(y,b,"audioCodec"),Dm(y,b,"textCodec")}h.push(y)}}return n}static parseLevelPlaylist(e,t,r,s,n,a){const o=new f1(t),l=o.fragments;let d=null,u=0,c=0,h=0,f=0,m=null,p=new Jd(s,t),g,E,y,b=-1,S=!1,_=null;for(Rm.lastIndex=0,o.m3u8=e,o.hasVariableRefs=Am(e);(g=Rm.exec(e))!==null;){S&&(S=!1,p=new Jd(s,t),p.start=h,p.sn=u,p.cc=f,p.level=r,d&&(p.initSegment=d,p.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null,_&&(p.setByteRange(_),_=null)));const O=g[1];if(O){p.duration=parseFloat(O);const L=(" "+g[2]).slice(1);p.title=L||null,p.tagList.push(L?["INF",O,L]:["INF",O])}else if(g[3]){if(Y(p.duration)){p.start=h,y&&Om(p,y,o),p.sn=u,p.level=r,p.cc=f,l.push(p);const L=(" "+g[3]).slice(1);p.relurl=zu(o,L),Mm(p,m),m=p,h+=p.duration,u++,c=0,S=!0}}else if(g[4]){const L=(" "+g[4]).slice(1);m?p.setByteRange(L,m):p.setByteRange(L)}else if(g[5])p.rawProgramDateTime=(" "+g[5]).slice(1),p.tagList.push(["PROGRAM-DATE-TIME",p.rawProgramDateTime]),b===-1&&(b=l.length);else{if(g=g[0].match(Z1),!g){I.warn("No matches on slow regex match for level playlist!");continue}for(E=1;E<g.length&&!(typeof g[E]<"u");E++);const L=(" "+g[E]).slice(1),M=(" "+g[E+1]).slice(1),K=g[E+2]?(" "+g[E+2]).slice(1):"";switch(L){case"PLAYLIST-TYPE":o.type=M.toUpperCase();break;case"MEDIA-SEQUENCE":u=o.startSN=parseInt(M);break;case"SKIP":{const U=new Me(M);bt(o,U,["RECENTLY-REMOVED-DATERANGES"]);const z=U.decimalInteger("SKIPPED-SEGMENTS");if(Y(z)){o.skippedSegments=z;for(let q=z;q--;)l.unshift(null);u+=z}const V=U.enumeratedString("RECENTLY-REMOVED-DATERANGES");V&&(o.recentlyRemovedDateranges=V.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(M),1);break;case"VERSION":o.version=parseInt(M);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(M||K)&&p.tagList.push(K?[M,K]:[M]);break;case"DISCONTINUITY":f++,p.tagList.push(["DIS"]);break;case"GAP":p.gap=!0,p.tagList.push([L]);break;case"BITRATE":p.tagList.push([L,M]);break;case"DATERANGE":{const U=new Me(M);bt(o,U,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),bt(o,U,U.clientAttrs);const z=new lg(U,o.dateRanges[U.ID]);z.isValid||o.skippedSegments?o.dateRanges[z.id]=z:I.warn(`Ignoring invalid DATERANGE tag: "${M}"`),p.tagList.push(["EXT-X-DATERANGE",M]);break}case"DEFINE":{{const U=new Me(M);bt(o,U,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in U?V1(o,U,a):Sm(o,U,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(M);break;case"KEY":{const U=wm(M,t,o);if(U.isSupported()){if(U.method==="NONE"){y=void 0;break}y||(y={}),y[U.keyFormat]&&(y=We({},y)),y[U.keyFormat]=U}else I.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${M}"`);break}case"START":o.startTimeOffset=Cm(M);break;case"MAP":{const U=new Me(M);if(bt(o,U,["BYTERANGE","URI"]),p.duration){const z=new Jd(s,t);Pm(z,U,r,y),d=z,p.initSegment=d,d.rawProgramDateTime&&!p.rawProgramDateTime&&(p.rawProgramDateTime=d.rawProgramDateTime)}else{const z=p.byteRangeEndOffset;if(z){const V=p.byteRangeStartOffset;_=`${z-V}@${V}`}else _=null;Pm(p,U,r,y),d=p,S=!0}break}case"SERVER-CONTROL":{const U=new Me(M);o.canBlockReload=U.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=U.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&U.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=U.optionalFloat("PART-HOLD-BACK",0),o.holdBack=U.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const U=new Me(M);o.partTarget=U.decimalFloatingPoint("PART-TARGET");break}case"PART":{let U=o.partList;U||(U=o.partList=[]);const z=c>0?U[U.length-1]:void 0,V=c++,q=new Me(M);bt(o,q,["BYTERANGE","URI"]);const ae=new c1(q,p,t,V,z);U.push(ae),p.duration+=ae.duration;break}case"PRELOAD-HINT":{const U=new Me(M);bt(o,U,["URI"]),o.preloadHint=U;break}case"RENDITION-REPORT":{const U=new Me(M);bt(o,U,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(U);break}default:I.warn(`line parsed but not handled: ${g}`);break}}}m&&!m.relurl?(l.pop(),h-=m.duration,o.partList&&(o.fragmentHint=m)):o.partList&&(Mm(p,m),p.cc=f,o.fragmentHint=p,y&&Om(p,y,o));const x=l.length,A=l[0],C=l[x-1];if(h+=o.skippedSegments*o.targetduration,h>0&&x&&C){o.averagetargetduration=h/x;const O=C.sn;o.endSN=O!=="initSegment"?O:0,o.live||(C.endList=!0),A&&(o.startCC=A.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(h+=o.fragmentHint.duration),o.totalduration=h,o.endCC=f,b>0&&eA(l,b),o}}function wm(i,e,t){var r,s;const n=new Me(i);bt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const a=(r=n.METHOD)!=null?r:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,u=(s=n.KEYFORMAT)!=null?s:"identity";o&&n.IV&&!l&&I.error(`Invalid IV: ${n.IV}`);const c=o?yi.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new Ra(a,c,u,h,l)}function Cm(i){const t=new Me(i).decimalFloatingPoint("TIME-OFFSET");return Y(t)?t:null}function J1(i,e){let t=(i||"").split(/[ ,]+/).filter(r=>r);["video","audio","text"].forEach(r=>{const s=t.filter(n=>Y1(n,r));s.length&&(e[`${r}Codec`]=s.join(","),t=t.filter(n=>s.indexOf(n)===-1))}),e.unknownCodecs=t}function Dm(i,e,t){const r=e[t];r&&(i[t]=r)}function eA(i,e){let t=i[e];for(let r=e;r--;){const s=i[r];if(!s)return;s.programDateTime=t.programDateTime-s.duration*1e3,t=s}}function Mm(i,e){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):e!=null&&e.programDateTime&&(i.programDateTime=e.endProgramDateTime),Y(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function Pm(i,e,t,r){i.relurl=e.URI,e.BYTERANGE&&i.setByteRange(e.BYTERANGE),i.level=t,i.sn="initSegment",r&&(i.levelkeys=r),i.initSegment=null}function Om(i,e,t){i.levelkeys=e;const{encryptedFragments:r}=t;(!r.length||r[r.length-1].levelkeys!==e)&&Object.keys(e).some(s=>e[s].isCommonEncryption)&&r.push(i)}var fe={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},ee={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function Nm(i){const{type:e}=i;switch(e){case fe.AUDIO_TRACK:return ee.AUDIO;case fe.SUBTITLE_TRACK:return ee.SUBTITLE;default:return ee.MAIN}}function au(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class tA{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(v.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,r=t.pLoader,s=t.loader,n=r||s,a=new n(t);return this.loaders[e.type]=a,a}getInternalLoader(e){return this.loaders[e.type]}resetInternalLoader(e){this.loaders[e]&&delete this.loaders[e]}destroyInternalLoaders(){for(const e in this.loaders){const t=this.loaders[e];t&&t.destroy(),this.resetInternalLoader(e)}}destroy(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()}onManifestLoading(e,t){const{url:r}=t;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:fe.MANIFEST,url:r,deliveryDirectives:null})}onLevelLoading(e,t){const{id:r,level:s,pathwayId:n,url:a,deliveryDirectives:o}=t;this.load({id:r,level:s,pathwayId:n,responseType:"text",type:fe.LEVEL,url:a,deliveryDirectives:o})}onAudioTrackLoading(e,t){const{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:fe.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){const{id:r,groupId:s,url:n,deliveryDirectives:a}=t;this.load({id:r,groupId:s,level:null,responseType:"text",type:fe.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;const r=this.hls.config;let s=this.getInternalLoader(e);if(s){const d=s.context;if(d&&d.url===e.url&&d.level===e.level){I.trace("[playlist-loader]: playlist request ongoing");return}I.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),s.abort()}let n;if(e.type===fe.MANIFEST?n=r.manifestLoadPolicy.default:n=We({},r.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(e),Y((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===fe.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===fe.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===fe.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){const u=d.partTarget,c=d.targetduration;if(u&&c){const h=Math.max(u*3,c*.8)*1e3;n=We({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}const a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,u,c,h)=>{const f=this.getInternalLoader(c);this.resetInternalLoader(c.type);const m=d.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,c,new Error("no EXTM3U delimiter"),h||null,u);return}u.parsing.start=performance.now(),yi.isMediaPlaylist(m)?this.handleTrackOrLevelPlaylist(d,u,c,h||null,f):this.handleMasterPlaylist(d,u,c,h)},onError:(d,u,c,h)=>{this.handleNetworkError(u,c,!1,d,h)},onTimeout:(d,u,c)=>{this.handleNetworkError(u,c,!0,void 0,d)}};s.load(e,o,l)}handleMasterPlaylist(e,t,r,s){const n=this.hls,a=e.data,o=au(e,r),l=yi.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,r,l.playlistParsingError,s,t);return}const{contentSteering:d,levels:u,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m}=l;this.variableList=m;const{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":E}=yi.parseMasterPlaylistMedia(a,o,l);p.length&&!p.some(b=>!b.url)&&u[0].audioCodec&&!u[0].attrs.AUDIO&&(I.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Me({}),bitrate:0,url:""})),n.trigger(v.MANIFEST_LOADED,{levels:u,audioTracks:p,subtitles:g,captions:E,contentSteering:d,url:o,stats:t,networkDetails:s,sessionData:c,sessionKeys:h,startTimeOffset:f,variableList:m})}handleTrackOrLevelPlaylist(e,t,r,s,n){const a=this.hls,{id:o,level:l,type:d}=r,u=au(e,r),c=0,h=Y(l)?l:Y(o)?o:0,f=Nm(r),m=yi.parseLevelPlaylist(e.data,u,h,f,c,this.variableList);if(d===fe.MANIFEST){const p={attrs:new Me({}),bitrate:0,details:m,name:"",url:u};a.trigger(v.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:u,stats:t,networkDetails:s,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),r.levelDetails=m,this.handlePlaylistLoaded(m,e,t,r,s,n)}handleManifestParsingError(e,t,r,s,n){this.hls.trigger(v.ERROR,{type:ie.NETWORK_ERROR,details:D.MANIFEST_PARSING_ERROR,fatal:t.type===fe.MANIFEST,url:e.url,err:r,error:r,reason:r.message,response:e,context:t,networkDetails:s,stats:n})}handleNetworkError(e,t,r=!1,s,n){let a=`A network ${r?"timeout":"error"+(s?" (status "+s.code+")":"")} occurred while loading ${e.type}`;e.type===fe.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===fe.AUDIO_TRACK||e.type===fe.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(a);I.warn(`[playlist-loader]: ${a}`);let l=D.UNKNOWN,d=!1;const u=this.getInternalLoader(e);switch(e.type){case fe.MANIFEST:l=r?D.MANIFEST_LOAD_TIMEOUT:D.MANIFEST_LOAD_ERROR,d=!0;break;case fe.LEVEL:l=r?D.LEVEL_LOAD_TIMEOUT:D.LEVEL_LOAD_ERROR,d=!1;break;case fe.AUDIO_TRACK:l=r?D.AUDIO_TRACK_LOAD_TIMEOUT:D.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case fe.SUBTITLE_TRACK:l=r?D.SUBTITLE_TRACK_LOAD_TIMEOUT:D.SUBTITLE_LOAD_ERROR,d=!1;break}u&&this.resetInternalLoader(e.type);const c={type:ie.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:u,context:e,error:o,networkDetails:t,stats:n};if(s){const h=(t==null?void 0:t.url)||e.url;c.response=dt({url:h,data:void 0},s)}this.hls.trigger(v.ERROR,c)}handlePlaylistLoaded(e,t,r,s,n,a){const o=this.hls,{type:l,level:d,id:u,groupId:c,deliveryDirectives:h}=s,f=au(t,s),m=Nm(s),p=typeof s.level=="number"&&m===ee.MAIN?d:void 0;if(!e.fragments.length){const E=new Error("No Segments found in Playlist");o.trigger(v.ERROR,{type:ie.NETWORK_ERROR,details:D.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:E,reason:E.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const g=e.playlistParsingError;if(g){o.trigger(v.ERROR,{type:ie.NETWORK_ERROR,details:D.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:s,level:p,parent:m,networkDetails:n,stats:r});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case fe.MANIFEST:case fe.LEVEL:o.trigger(v.LEVEL_LOADED,{details:e,level:p||0,id:u||0,stats:r,networkDetails:n,deliveryDirectives:h});break;case fe.AUDIO_TRACK:o.trigger(v.AUDIO_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break;case fe.SUBTITLE_TRACK:o.trigger(v.SUBTITLE_TRACK_LOADED,{details:e,id:u||0,groupId:c||"",stats:r,networkDetails:n,deliveryDirectives:h});break}}}function Ag(i,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=i,e.dispatchEvent(t)}function Sg(i,e){const t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(r){I.debug(`[texttrack-utils]: ${r}`);try{const s=new self.TextTrackCue(e.startTime,e.endTime,e.text);s.id=e.id,i.addCue(s)}catch(s){I.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${s}`)}}t==="disabled"&&(i.mode=t)}function Xs(i){const e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues)for(let t=i.cues.length;t--;)i.removeCue(i.cues[t]);e==="disabled"&&(i.mode=e)}function Xu(i,e,t,r){const s=i.mode;if(s==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){const n=rA(i.cues,e,t);for(let a=0;a<n.length;a++)(!r||r(n[a]))&&i.removeCue(n[a])}s==="disabled"&&(i.mode=s)}function iA(i,e){if(e<i[0].startTime)return 0;const t=i.length-1;if(e>i[t].endTime)return-1;let r=0,s=t;for(;r<=s;){const n=Math.floor((s+r)/2);if(e<i[n].startTime)s=n-1;else if(e>i[n].startTime&&r<t)r=n+1;else return n}return i[r].startTime-e<e-i[s].startTime?r:s}function rA(i,e,t){const r=[],s=iA(i,e);if(s>-1)for(let n=s,a=i.length;n<a;n++){const o=i[n];if(o.startTime>=e&&o.endTime<=t)r.push(o);else if(o.startTime>t)return r}return r}function Ro(i){const e=[];for(let t=0;t<i.length;t++){const r=i[t];(r.kind==="subtitles"||r.kind==="captions")&&r.label&&e.push(i[t])}return e}var Yt={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const sA=.25;function Qu(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function Fm(i,e,t,r,s){let n=new i(e,t,"");try{n.value=r,s&&(n.type=s)}catch{n=new i(e,t,JSON.stringify(s?dt({type:s},r):r))}return n}const Ja=(()=>{const i=Qu();try{i&&new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function ou(i,e){return i.getTime()/1e3-e}function nA(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class aA{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(Xs(this.id3Track),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={})}onManifestLoading(){this.dateRangeCuesAppended={}}createTrack(e){const t=this.getID3Track(e.textTracks);return t.mode="hidden",t}getID3Track(e){if(this.media){for(let t=0;t<e.length;t++){const r=e[t];if(r.kind==="metadata"&&r.label==="id3")return Ag(r,this.media),r}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:r,enableID3MetadataCues:s}}}=this;if(!r&&!s)return;const{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=Qu();if(a)for(let o=0;o<n.length;o++){const l=n[o].type;if(l===Yt.emsg&&!r||!s)continue;const d=fg(n[o].data);if(d){const u=n[o].pts;let c=u+n[o].duration;c>Ja&&(c=Ja),c-u<=0&&(c=u+sA);for(let f=0;f<d.length;f++){const m=d[f];if(!hg(m)){this.updateId3CueEnds(u,l);const p=Fm(a,u,c,m,l);p&&this.id3Track.addCue(p)}}}}}updateId3CueEnds(e,t){var r;const s=(r=this.id3Track)==null?void 0:r.cues;if(s)for(let n=s.length;n--;){const a=s[n];a.type===t&&a.startTime<e&&a.endTime===Ja&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:r,type:s}){const{id3Track:n,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let d;s==="audio"?d=u=>u.type===Yt.audioId3&&l:s==="video"?d=u=>u.type===Yt.emsg&&o:d=u=>u.type===Yt.audioId3&&l||u.type===Yt.emsg&&o,Xu(n,t,r,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:r,id3Track:s}=this,{dateRanges:n}=t,a=Object.keys(n);if(s){const u=Object.keys(r).filter(c=>!a.includes(c));for(let c=u.length;c--;){const h=u[c];Object.keys(r[h].cues).forEach(f=>{s.removeCue(r[h].cues[f])}),delete r[h]}}const o=t.fragments[t.fragments.length-1];if(a.length===0||!Y(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=o.programDateTime/1e3-o.start,d=Qu();for(let u=0;u<a.length;u++){const c=a[u],h=n[c],f=ou(h.startDate,l),m=r[c],p=(m==null?void 0:m.cues)||{};let g=(m==null?void 0:m.durationKnown)||!1,E=Ja;const y=h.endDate;if(y)E=ou(y,l),g=!0;else if(h.endOnNext&&!g){const S=a.reduce((_,x)=>{if(x!==h.id){const A=n[x];if(A.class===h.class&&A.startDate>h.startDate&&(!_||h.startDate<_.startDate))return A}return _},null);S&&(E=ou(S.startDate,l),g=!0)}const b=Object.keys(h.attr);for(let S=0;S<b.length;S++){const _=b[S];if(!d1(_))continue;const x=p[_];if(x)g&&!m.durationKnown&&(x.endTime=E);else if(d){let A=h.attr[_];u1(_)&&(A=nA(A));const C=Fm(d,f,E,{key:_,data:A},Yt.dateRange);C&&(C.id=c,this.id3Track.addCue(C),p[_]=C)}}r[c]={cues:p,dateRange:h,durationKnown:g}}}}class oA{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(e===null)return null;const{holdBack:t,partHoldBack:r,targetduration:s}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig;let d=o&&r||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*s);const u=s;return d+Math.min(this.stallCount*1,u)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency,r=this.levelDetails;if(e===null||t===null||r===null)return null;const s=r.edge,n=e-t-this.edgeStalled,a=s-r.totalduration,o=s-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),o)}get drift(){const{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;if(e===null)return 0;const t=(this.config.lowLatencyMode&&e.partTarget||e.targetduration)*3;return Math.max(e.age-t,0)}get forwardBufferLength(){const{media:e,levelDetails:t}=this;if(!e||!t)return 0;const r=e.buffered.length;return(r?e.buffered.end(r-1):t.edge)-this.currentTime}destroy(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(v.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(v.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var r;t.details===D.BUFFER_STALLED_ERROR&&(this.stallCount++,(r=this.levelDetails)!=null&&r.live&&I.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;const r=this.computeLatency();if(r===null)return;this._latency=r;const{lowLatencyMode:s,maxLiveSyncPlaybackRate:n}=this.config;if(!s||n===1||!t.live)return;const a=this.targetLatency;if(a===null)return;const o=r-a,l=Math.min(this.maxLatency,a+t.targetduration);if(o<l&&o>.05&&this.forwardBufferLength>1){const u=Math.min(2,Math.max(1,n)),c=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(u,Math.max(1,c))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}const Zu=["NONE","TYPE-0","TYPE-1",null];function lA(i){return Zu.indexOf(i)>-1}const Zl=["SDR","PQ","HLG"];function dA(i){return!!i&&Zl.indexOf(i)>-1}var wo={No:"",Yes:"YES",v2:"v2"};function Um(i){const{canSkipUntil:e,canSkipDateRanges:t,age:r}=i,s=r<e/2;return e&&s?t?wo.v2:wo.Yes:wo.No}class $m{constructor(e,t,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=e,this.part=t,this.skip=r}addDirectives(e){const t=new self.URL(e);return this.msn!==void 0&&t.searchParams.set("_HLS_msn",this.msn.toString()),this.part!==void 0&&t.searchParams.set("_HLS_part",this.part.toString()),this.skip&&t.searchParams.set("_HLS_skip",this.skip),t.href}}class pn{constructor(e){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.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=[e.url],this._attrs=[e.attrs],this.bitrate=e.bitrate,e.details&&(this.details=e.details),this.id=e.id||0,this.name=e.name,this.width=e.width||0,this.height=e.height||0,this.frameRate=e.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=e.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=e.audioCodec,this.videoCodec=e.videoCodec,this.codecSet=[e.videoCodec,e.audioCodec].filter(t=>!!t).map(t=>t.substring(0,4)).join(","),this.addGroupId("audio",e.attrs.AUDIO),this.addGroupId("text",e.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(e){return Bm(this._audioGroups,e)}hasSubtitleGroup(e){return Bm(this._subtitleGroups,e)}get audioGroups(){return this._audioGroups}get subtitleGroups(){return this._subtitleGroups}addGroupId(e,t){if(t){if(e==="audio"){let r=this._audioGroups;r||(r=this._audioGroups=[]),r.indexOf(t)===-1&&r.push(t)}else if(e==="text"){let r=this._subtitleGroups;r||(r=this._subtitleGroups=[]),r.indexOf(t)===-1&&r.push(t)}}}get urlId(){return 0}set urlId(e){}get audioGroupIds(){return this.audioGroups?[this.audioGroupId]:void 0}get textGroupIds(){return this.subtitleGroups?[this.textGroupId]:void 0}get audioGroupId(){var e;return(e=this.audioGroups)==null?void 0:e[0]}get textGroupId(){var e;return(e=this.subtitleGroups)==null?void 0:e[0]}addFallback(){}}function Bm(i,e){return!e||!i?!1:i.indexOf(e)!==-1}function lu(i,e){const t=e.startPTS;if(Y(t)){let r=0,s;e.sn>i.sn?(r=t-i.start,s=i):(r=i.start-t,s=e),s.duration!==r&&(s.duration=r)}else e.sn>i.sn?i.cc===e.cc&&i.minEndPTS?e.start=i.start+(i.minEndPTS-i.start):e.start=i.start+i.duration:e.start=Math.max(i.start-e.duration,0)}function xg(i,e,t,r,s,n){r-t<=0&&(I.warn("Fragment should have a positive duration",e),r=t+e.duration,n=s+e.duration);let o=t,l=r;const d=e.startPTS,u=e.endPTS;if(Y(d)){const g=Math.abs(d-t);Y(e.deltaPTS)?e.deltaPTS=Math.max(g,e.deltaPTS):e.deltaPTS=g,o=Math.max(t,d),t=Math.min(t,d),s=Math.min(s,e.startDTS),l=Math.min(r,u),r=Math.max(r,u),n=Math.max(n,e.endDTS)}const c=t-e.start;e.start!==0&&(e.start=t),e.duration=r-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=s,e.endPTS=r,e.minEndPTS=l,e.endDTS=n;const h=e.sn;if(!i||h<i.startSN||h>i.endSN)return 0;let f;const m=h-i.startSN,p=i.fragments;for(p[m]=e,f=m;f>0;f--)lu(p[f],p[f-1]);for(f=m;f<p.length-1;f++)lu(p[f],p[f+1]);return i.fragmentHint&&lu(p[p.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,c}function uA(i,e){let t=null;const r=i.fragments;for(let l=r.length-1;l>=0;l--){const d=r[l].initSegment;if(d){t=d;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let s=0,n;if(fA(i,e,(l,d)=>{l.relurl&&(s=l.cc-d.cc),Y(l.startPTS)&&Y(l.endPTS)&&(d.start=d.startPTS=l.startPTS,d.startDTS=l.startDTS,d.maxStartPTS=l.maxStartPTS,d.endPTS=l.endPTS,d.endDTS=l.endDTS,d.minEndPTS=l.minEndPTS,d.duration=l.endPTS-l.startPTS,d.duration&&(n=d),e.PTSKnown=e.alignedSliding=!0),d.elementaryStreams=l.elementaryStreams,d.loader=l.loader,d.stats=l.stats,l.initSegment&&(d.initSegment=l.initSegment,t=l.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(d=>{var u;d&&(!d.initSegment||d.initSegment.relurl===((u=t)==null?void 0:u.relurl))&&(d.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){I.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=cA(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const a=e.fragments;if(s){I.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<a.length;l++)a[l].cc+=s}e.skippedSegments&&(e.startCC=e.fragments[0].cc),hA(i.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats}),n?xg(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):kg(i,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=i.driftStartTime,e.driftStart=i.driftStart;const o=e.advancedDateTime;if(e.advanced&&o){const l=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=l),e.driftEndTime=o,e.driftEnd=l}else e.driftEndTime=i.driftEndTime,e.driftEnd=i.driftEnd,e.advancedDateTime=i.advancedDateTime}function cA(i,e,t){const r=We({},i);return t&&t.forEach(s=>{delete r[s]}),Object.keys(e).forEach(s=>{const n=new lg(e[s].attr,r[s]);n.isValid?r[s]=n:I.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[s].attr)}"`)}),r}function hA(i,e,t){if(i&&e){let r=0;for(let s=0,n=i.length;s<=n;s++){const a=i[s],o=e[s+r];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):r--}}}function fA(i,e,t){const r=e.skippedSegments,s=Math.max(i.startSN,e.startSN)-e.startSN,n=(i.fragmentHint?1:0)+(r?e.endSN:Math.min(i.endSN,e.endSN))-e.startSN,a=e.startSN-i.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let d=s;d<=n;d++){const u=l[a+d];let c=o[d];r&&!c&&d<r&&(c=e.fragments[d]=u),u&&c&&t(u,c)}}function kg(i,e){const t=e.startSN+e.skippedSegments-i.startSN,r=i.fragments;t<0||t>=r.length||Ju(e,r[t].start)}function Ju(i,e){if(e){const t=i.fragments;for(let r=i.skippedSegments;r<t.length;r++)t[r].start+=e;i.fragmentHint&&(i.fragmentHint.start+=e)}}function mA(i,e=1/0){let t=1e3*i.targetduration;if(i.updated){const r=i.fragments;if(r.length&&t*4>e){const n=r[r.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function pA(i,e,t){if(!(i!=null&&i.details))return null;const r=i.details;let s=r.fragments[e-r.startSN];return s||(s=r.fragmentHint,s&&s.sn===e)?s:e<r.startSN&&t&&t.sn===e?t:null}function Gm(i,e,t){var r;return i!=null&&i.details?Lg((r=i.details)==null?void 0:r.partList,e,t):null}function Lg(i,e,t){if(i)for(let r=i.length;r--;){const s=i[r];if(s.index===t&&s.fragment.sn===e)return s}return null}function Ig(i){i.forEach((e,t)=>{const{details:r}=e;r!=null&&r.fragments&&r.fragments.forEach(s=>{s.level=t})})}function Jl(i){switch(i.details){case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_TIMEOUT:case D.LEVEL_LOAD_TIMEOUT:case D.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function Hm(i,e){const t=Jl(e);return i.default[`${t?"timeout":"error"}Retry`]}function jh(i,e){const t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function Wm(i){return dt(dt({},i),{errorRetry:null,timeoutRetry:null})}function ed(i,e,t,r){if(!i)return!1;const s=r==null?void 0:r.code,n=e<i.maxNumRetry&&(gA(s)||!!t);return i.shouldRetry?i.shouldRetry(i,e,t,r,n):n}function gA(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}const Rg={search:function(i,e){let t=0,r=i.length-1,s=null,n=null;for(;t<=r;){s=(t+r)/2|0,n=i[s];const a=e(n);if(a>0)t=s+1;else if(a<0)r=s-1;else return n}return null}};function vA(i,e,t){if(e===null||!Array.isArray(i)||!i.length||!Y(e))return null;const r=i[0].programDateTime;if(e<(r||0))return null;const s=i[i.length-1].endProgramDateTime;if(e>=(s||0))return null;t=t||0;for(let n=0;n<i.length;++n){const a=i[n];if(yA(e,t,a))return a}return null}function td(i,e,t=0,r=0,s=.005){let n=null;if(i){n=e[i.sn-e[0].sn+1]||null;const o=i.endDTS-t;o>0&&o<15e-7&&(t+=15e-7)}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!i||i.level===n.level)&&ec(t,r,n)===0||EA(n,i,Math.min(s,r))))return n;const a=Rg.search(e,ec.bind(null,t,r));return a&&(a!==i||!n)?a:n}function EA(i,e,t){if(e&&e.start===0&&e.level<i.level&&(e.endPTS||0)>0){const r=e.tagList.reduce((s,n)=>(n[0]==="INF"&&(s+=parseFloat(n[1])),s),t);return i.start<=r}return!1}function ec(i=0,e=0,t){if(t.start<=i&&t.start+t.duration>i)return 0;const r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-r<=i?1:t.start-r>i&&t.start?-1:0}function yA(i,e,t){const r=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-r>i}function bA(i,e){return Rg.search(i,t=>t.cc<e?1:t.cc>e?-1:0)}var ht={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Gt={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class TA{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=I.log.bind(I,"[info]:"),this.warn=I.warn.bind(I,"[warning]:"),this.error=I.error.bind(I,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(v.ERROR,this.onError,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(v.ERROR,this.onError,this),e.off(v.ERROR,this.onErrorOut,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===ee.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var r,s;if(t.fatal)return;const n=this.hls,a=t.context;switch(t.details){case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case D.FRAG_PARSING_ERROR:if((r=t.frag)!=null&&r.gap){t.errorAction={action:ht.DoNothing,flags:Gt.None};return}case D.FRAG_GAP:case D.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=ht.SendAlternateToPenaltyBox;return}case D.LEVEL_EMPTY_ERROR:case D.LEVEL_PARSING_ERROR:{var o,l;const d=t.parent===ee.MAIN?t.level:n.loadLevel;t.details===D.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.SUBTITLE_LOAD_ERROR:case D.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){const d=n.levels[n.loadLevel];if(d&&(a.type===fe.AUDIO_TRACK&&d.hasAudioGroup(a.groupId)||a.type===fe.SUBTITLE_TRACK&&d.hasSubtitleGroup(a.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=ht.SendAlternateToPenaltyBox,t.errorAction.flags=Gt.MoveAllAlternatesMatchingHost;return}}return;case D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const d=n.levels[n.loadLevel],u=d==null?void 0:d.attrs["HDCP-LEVEL"];u?t.errorAction={action:ht.SendAlternateToPenaltyBox,flags:Gt.MoveAllAlternatesMatchingHDCP,hdcpLevel:u}:this.keySystemError(t)}return;case D.BUFFER_ADD_CODEC_ERROR:case D.REMUX_ALLOC_ERROR:case D.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(s=t.level)!=null?s:n.loadLevel);return;case D.INTERNAL_EXCEPTION:case D.BUFFER_APPENDING_ERROR:case D.BUFFER_FULL_ERROR:case D.LEVEL_SWITCH_ERROR:case D.BUFFER_STALLED_ERROR:case D.BUFFER_SEEK_OVER_HOLE:case D.BUFFER_NUDGE_ON_STALL:t.errorAction={action:ht.DoNothing,flags:Gt.None};return}t.type===ie.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){const t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){const r=this.hls,s=Hm(r.config.playlistLoadPolicy,e),n=this.playlistError++;if(ed(s,n,Jl(e),e.response))return{action:ht.RetryRequest,flags:Gt.None,retryConfig:s,retryCount:n};const o=this.getLevelSwitchAction(e,t);return s&&(o.retryConfig=s,o.retryCount=n),o}getFragRetryOrSwitchAction(e){const t=this.hls,r=this.getVariantLevelIndex(e.frag),s=t.levels[r],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=Hm(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((u,c)=>u+c.fragmentError,0);if(s&&(e.details!==D.FRAG_GAP&&s.fragmentError++,ed(o,l,Jl(e),e.response)))return{action:ht.RetryRequest,flags:Gt.None,retryConfig:o,retryCount:l};const d=this.getLevelSwitchAction(e,r);return o&&(d.retryConfig=o,d.retryCount=l),d}getLevelSwitchAction(e,t){const r=this.hls;t==null&&(t=r.loadLevel);const s=this.hls.levels[t];if(s){var n,a;const d=e.details;s.loadError++,d===D.BUFFER_APPEND_ERROR&&s.fragmentError++;let u=-1;const{levels:c,loadLevel:h,minAutoLevel:f,maxAutoLevel:m}=r;r.autoLevelEnabled||(r.loadLevel=-1);const p=(n=e.frag)==null?void 0:n.type,E=(p===ee.AUDIO&&d===D.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===D.BUFFER_ADD_CODEC_ERROR||d===D.BUFFER_APPEND_ERROR))&&c.some(({audioCodec:x})=>s.audioCodec!==x),b=e.sourceBufferName==="video"&&(d===D.BUFFER_ADD_CODEC_ERROR||d===D.BUFFER_APPEND_ERROR)&&c.some(({codecSet:x,audioCodec:A})=>s.codecSet!==x&&s.audioCodec===A),{type:S,groupId:_}=(a=e.context)!=null?a:{};for(let x=c.length;x--;){const A=(x+h)%c.length;if(A!==h&&A>=f&&A<=m&&c[A].loadError===0){var o,l;const C=c[A];if(d===D.FRAG_GAP&&p===ee.MAIN&&e.frag){const O=c[A].details;if(O){const L=td(e.frag,O.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else{if(S===fe.AUDIO_TRACK&&C.hasAudioGroup(_)||S===fe.SUBTITLE_TRACK&&C.hasSubtitleGroup(_))continue;if(p===ee.AUDIO&&(o=s.audioGroups)!=null&&o.some(O=>C.hasAudioGroup(O))||p===ee.SUBTITLE&&(l=s.subtitleGroups)!=null&&l.some(O=>C.hasSubtitleGroup(O))||E&&s.audioCodec===C.audioCodec||!E&&s.audioCodec!==C.audioCodec||b&&s.codecSet===C.codecSet)continue}u=A;break}}if(u>-1&&r.loadLevel!==u)return e.levelRetry=!0,this.playlistError=0,{action:ht.SendAlternateToPenaltyBox,flags:Gt.None,nextAutoLevel:u}}return{action:ht.SendAlternateToPenaltyBox,flags:Gt.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var r;switch((r=t.errorAction)==null?void 0:r.action){case ht.DoNothing:break;case ht.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==D.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${t.sourceBufferName}" sourceBuffer append error. Attempting to recover from media error.`),this.hls.recoverMediaError());break}if(t.fatal){this.hls.stopLoad();return}}sendAlternateToPenaltyBox(e){const t=this.hls,r=e.errorAction;if(!r)return;const{flags:s,hdcpLevel:n,nextAutoLevel:a}=r;switch(s){case Gt.None:this.switchLevel(e,a);break;case Gt.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=Zu[Zu.indexOf(n)-1],r.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}r.resolved||this.switchLevel(e,a)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}}class zh{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=I.log.bind(I,`${t}:`),this.warn=I.warn.bind(I,`${t}:`),this.hls=e}destroy(){this.clearTimer(),this.hls=this.log=this.warn=null}clearTimer(){this.timer!==-1&&(self.clearTimeout(this.timer),this.timer=-1)}startLoad(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,r){const s=t==null?void 0:t.renditionReports;if(s){let n=-1;for(let a=0;a<s.length;a++){const o=s[a];let l;try{l=new self.URL(o.URI,t.url).href}catch(d){I.warn(`Could not construct new URL for Rendition Report: ${d}`),l=o.URI||""}if(l===e){n=a;break}else l===e.substring(0,l.length)&&(n=a)}if(n!==-1){const a=s[n],o=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn);let l=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){const u=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&u>t.partTarget&&(l+=1)}const d=r&&Um(r);return new $m(o,l>=0?l:void 0,d)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,r){const{details:s,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(s.advancedDateTime=Date.now()-o,s.live||r!=null&&r.live){if(s.reloaded(r),r&&this.log(`live playlist ${e} ${s.advanced?"REFRESHED "+s.lastPartSn+"-"+s.lastPartIndex:s.updated?"UPDATED":"MISSED"}`),r&&s.fragments.length>0&&uA(r,s),!this.canLoad||!s.live)return;let l,d,u;if(s.canBlockReload&&s.endSN&&s.advanced){const g=this.hls.config.lowLatencyMode,E=s.lastPartSn,y=s.endSN,b=s.lastPartIndex,S=b!==-1,_=E===y,x=g?0:b;S?(d=_?y+1:E,u=_?x:b+1):d=y+1;const A=s.age,C=A+s.ageHeader;let O=Math.min(C-s.partTarget,s.targetduration*1.5);if(O>0){if(r&&O>r.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${r.tuneInGoal} to: ${O} with playlist age: ${s.age}`),O=0;else{const L=Math.floor(O/s.targetduration);if(d+=L,u!==void 0){const M=Math.round(O%s.targetduration/s.partTarget);u+=M}this.log(`CDN Tune-in age: ${s.ageHeader}s last advanced ${A.toFixed(2)}s goal: ${O} skip sn ${L} to part ${u}`)}s.tuneInGoal=O}if(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u),g||!_){this.loadPlaylist(l);return}}else(s.canBlockReload||s.canSkipUntil)&&(l=this.getDeliveryDirectives(s,t.deliveryDirectives,d,u));const c=this.hls.mainForwardBufferInfo,h=c?c.end-c.len:0,f=(s.edge-h)*1e3,m=mA(s,f);s.updated&&a>this.requestScheduled+m&&(this.requestScheduled=n.loading.start),d!==void 0&&s.canBlockReload?this.requestScheduled=n.loading.first+m-(s.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+m<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=m);let p=this.requestScheduled-a;p=Math.max(0,p),this.log(`reload live playlist ${e} in ${Math.round(p)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),p)}else this.clearTimer()}getDeliveryDirectives(e,t,r,s){let n=Um(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(r=t.msn,s=t.part,n=wo.No),new $m(r,s,n)}checkRetry(e){const t=e.details,r=Jl(e),s=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=s||{},l=!!s&&!!o&&(n===ht.RetryRequest||!s.resolved&&n===ht.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(r&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const u=jh(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),u),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${u}ms`)}e.levelRetry=!0,s.resolved=!0}return l}}class vs{constructor(e,t=0,r=0){this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=e,this.alpha_=e?Math.exp(Math.log(.5)/e):0,this.estimate_=t,this.totalWeight_=r}sample(e,t){const r=Math.pow(this.alpha_,e);this.estimate_=t*(1-r)+r*this.estimate_,this.totalWeight_+=e}getTotalWeight(){return this.totalWeight_}getEstimate(){if(this.alpha_){const e=1-Math.pow(this.alpha_,this.totalWeight_);if(e)return this.estimate_/e}return this.estimate_}}class _A{constructor(e,t,r,s=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_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new vs(e),this.fast_=new vs(t),this.defaultTTFB_=s,this.ttfb_=new vs(e)}update(e,t){const{slow_:r,fast_:s,ttfb_:n}=this;r.halfLife!==e&&(this.slow_=new vs(e,r.getEstimate(),r.getTotalWeight())),s.halfLife!==t&&(this.fast_=new vs(t,s.getEstimate(),s.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new vs(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const r=8*t,s=e/1e3,n=r/s;this.fast_.sample(s,n),this.slow_.sample(s,n)}sampleTTFB(e){const t=e/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(t,2)/2);this.ttfb_.sample(r,Math.max(e,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_}destroy(){}}const wg={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},Km={};function AA(i,e,t,r,s,n){const a=i.audioCodec?i.audioGroups:null,o=n==null?void 0:n.audioCodec,l=n==null?void 0:n.channels,d=l?parseInt(l):o?1/0:2;let u=null;if(a!=null&&a.length)try{a.length===1&&a[0]?u=e.groups[a[0]].channels:u=a.reduce((c,h)=>{if(h){const f=e.groups[h];if(!f)throw new Error(`Audio track group ${h} not found`);Object.keys(f.channels).forEach(m=>{c[m]=(c[m]||0)+f.channels[m]})}return c},{2:0})}catch{return!0}return i.videoCodec!==void 0&&(i.width>1920&&i.height>1088||i.height>1920&&i.width>1088||i.frameRate>Math.max(r,30)||i.videoRange!=="SDR"&&i.videoRange!==t||i.bitrate>Math.max(s,8e6))||!!u&&Y(d)&&Object.keys(u).some(c=>parseInt(c)>d)}function SA(i,e,t){const r=i.videoCodec,s=i.audioCodec;if(!r||!s||!t)return Promise.resolve(wg);const n={width:i.width,height:i.height,bitrate:Math.ceil(Math.max(i.bitrate*.9,i.averageBitrate)),framerate:i.frameRate||30},a=i.videoRange;a!=="SDR"&&(n.transferFunction=a.toLowerCase());const o=r.split(",").map(l=>({type:"media-source",video:dt(dt({},n),{},{contentType:wa(l,"video")})}));return s&&i.audioGroups&&i.audioGroups.forEach(l=>{var d;l&&((d=e.groups[l])==null||d.tracks.forEach(u=>{if(u.groupId===l){const c=u.channels||"",h=parseFloat(c);Y(h)&&h>2&&o.push.apply(o,s.split(",").map(f=>({type:"media-source",audio:{contentType:wa(f,"audio"),channels:""+h}})))}}))}),Promise.all(o.map(l=>{const d=xA(l);return Km[d]||(Km[d]=t.decodingInfo(l))})).then(l=>({supported:!l.some(d=>!d.supported),configurations:o,decodingInfoResults:l})).catch(l=>({supported:!1,configurations:o,decodingInfoResults:[],error:l}))}function xA(i){const{audio:e,video:t}=i,r=t||e;if(r){const s=r.contentType.split('"')[1];if(t)return`r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${s}_${Math.ceil(t.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${s}`}return""}function kA(){if(typeof matchMedia=="function"){const i=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(i.media!==e.media)return i.matches===!0}return!1}function LA(i,e){let t=!1,r=[];return i&&(t=i!=="SDR",r=[i]),e&&(r=e.allowedVideoRanges||Zl.slice(0),t=e.preferHDR!==void 0?e.preferHDR:kA(),t?r=r.filter(s=>s!=="SDR"):r=["SDR"]),{preferHDR:t,allowedVideoRanges:r}}function IA(i,e,t,r,s){const n=Object.keys(i),a=r==null?void 0:r.channels,o=r==null?void 0:r.audioCodec,l=a&&parseInt(a)===2;let d=!0,u=!1,c=1/0,h=1/0,f=1/0,m=0,p=[];const{preferHDR:g,allowedVideoRanges:E}=LA(e,s);for(let _=n.length;_--;){const x=i[n[_]];d=x.channels[2]>0,c=Math.min(c,x.minHeight),h=Math.min(h,x.minFramerate),f=Math.min(f,x.minBitrate);const A=E.filter(C=>x.videoRanges[C]>0);A.length>0&&(u=!0,p=A)}c=Y(c)?c:0,h=Y(h)?h:0;const y=Math.max(1080,c),b=Math.max(30,h);return f=Y(f)?f:t,t=Math.max(f,t),u||(e=void 0,p=[]),{codecSet:n.reduce((_,x)=>{const A=i[x];if(x===_)return _;if(A.minBitrate>t)return Ri(x,`min bitrate of ${A.minBitrate} > current estimate of ${t}`),_;if(!A.hasDefaultAudio)return Ri(x,"no renditions with default or auto-select sound found"),_;if(o&&x.indexOf(o.substring(0,4))%5!==0)return Ri(x,`audio codec preference "${o}" not found`),_;if(a&&!l){if(!A.channels[a])return Ri(x,`no renditions with ${a} channel sound found (channels options: ${Object.keys(A.channels)})`),_}else if((!o||l)&&d&&A.channels[2]===0)return Ri(x,"no renditions with stereo sound found"),_;return A.minHeight>y?(Ri(x,`min resolution of ${A.minHeight} > maximum of ${y}`),_):A.minFramerate>b?(Ri(x,`min framerate of ${A.minFramerate} > maximum of ${b}`),_):p.some(C=>A.videoRanges[C]>0)?A.maxScore<m?(Ri(x,`max score of ${A.maxScore} < selected max of ${m}`),_):_&&(Xl(x)>=Xl(_)||A.fragmentError>i[_].fragmentError)?_:(m=A.maxScore,x):(Ri(x,`no variants with VIDEO-RANGE of ${JSON.stringify(p)} found`),_)},void 0),videoRanges:p,preferHDR:g,minFramerate:h,minBitrate:f}}function Ri(i,e){I.log(`[abr] start candidates with "${i}" ignored because ${e}`)}function RA(i){return i.reduce((e,t)=>{let r=e.groups[t.groupId];r||(r=e.groups[t.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(t);const s=t.channels||"2";return r.channels[s]=(r.channels[s]||0)+1,r.hasDefault=r.hasDefault||t.default,r.hasAutoSelect=r.hasAutoSelect||t.autoselect,r.hasDefault&&(e.hasDefaultAudio=!0),r.hasAutoSelect&&(e.hasAutoSelectAudio=!0),e},{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}function wA(i,e,t,r){return i.slice(t,r+1).reduce((s,n)=>{if(!n.codecSet)return s;const a=n.audioGroups;let o=s[n.codecSet];o||(s[n.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,n.bitrate);const l=Math.min(n.height,n.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,n.frameRate),o.maxScore=Math.max(o.maxScore,n.score),o.fragmentError+=n.fragmentError,o.videoRanges[n.videoRange]=(o.videoRanges[n.videoRange]||0)+1,a&&a.forEach(d=>{if(!d)return;const u=e.groups[d];u&&(o.hasDefaultAudio=o.hasDefaultAudio||e.hasDefaultAudio?u.hasDefault:u.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(u.channels).forEach(c=>{o.channels[c]=(o.channels[c]||0)+u.channels[c]}))}),s},{})}function bi(i,e,t){if("attrs"in i){const r=e.indexOf(i);if(r!==-1)return r}for(let r=0;r<e.length;r++){const s=e[r];if(tn(i,s,t))return r}return-1}function tn(i,e,t){const{groupId:r,name:s,lang:n,assocLang:a,characteristics:o,default:l}=i,d=i.forced;return(r===void 0||e.groupId===r)&&(s===void 0||e.name===s)&&(n===void 0||e.lang===n)&&(n===void 0||e.assocLang===a)&&(l===void 0||e.default===l)&&(d===void 0||e.forced===d)&&(o===void 0||CA(o,e.characteristics))&&(t===void 0||t(i,e))}function CA(i,e=""){const t=i.split(","),r=e.split(",");return t.length===r.length&&!t.some(s=>r.indexOf(s)===-1)}function Es(i,e){const{audioCodec:t,channels:r}=i;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(r===void 0||r===(e.channels||"2"))}function DA(i,e,t,r,s){const n=e[r],o=e.reduce((h,f,m)=>{const p=f.uri;return(h[p]||(h[p]=[])).push(m),h},{})[n.uri];o.length>1&&(r=Math.max.apply(Math,o));const l=n.videoRange,d=n.frameRate,u=n.codecSet.substring(0,4),c=Vm(e,r,h=>{if(h.videoRange!==l||h.frameRate!==d||h.codecSet.substring(0,4)!==u)return!1;const f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return bi(i,m,s)>-1});return c>-1?c:Vm(e,r,h=>{const f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return bi(i,m,s)>-1})}function Vm(i,e,t){for(let r=e;r;r--)if(t(i[r]))return r;for(let r=e+1;r<i.length;r++)if(t(i[r]))return r;return-1}class MA{constructor(e){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.bwEstimator=void 0,this._abandonRulesCheck=()=>{const{fragCurrent:t,partCurrent:r,hls:s}=this,{autoLevelEnabled:n,media:a}=s;if(!t||!a)return;const o=performance.now(),l=r?r.stats:t.stats,d=r?r.duration:t.duration,u=o-l.loading.start,c=s.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||t.level<=c){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||a.paused||!a.playbackRate||!a.readyState)return;const h=s.mainForwardBufferInfo;if(h===null)return;const f=this.bwEstimator.getEstimateTTFB(),m=Math.abs(a.playbackRate);if(u<=Math.max(f,1e3*(d/(m*2))))return;const p=h.len/m,g=l.loading.first?l.loading.first-l.loading.start:-1,E=l.loaded&&g>-1,y=this.getBwEstimate(),b=s.levels,S=b[t.level],_=l.total||Math.max(l.loaded,Math.round(d*S.averageBitrate/8));let x=E?u-g:u;x<1&&E&&(x=Math.min(u,l.loaded*8/y));const A=E?l.loaded*1e3/x:0,C=A?(_-l.loaded)/A:_*8/y+f/1e3;if(C<=p)return;const O=A?A*8:y;let L=Number.POSITIVE_INFINITY,M;for(M=t.level-1;M>c;M--){const U=b[M].maxBitrate;if(L=this.getTimeToLoadFrag(f/1e3,O,d*U,!b[M].details),L<p)break}if(L>=C||L>d*10)return;s.nextLoadLevel=s.nextAutoLevel=M,E?this.bwEstimator.sample(u-Math.min(f,g),l.loaded):this.bwEstimator.sampleTTFB(u);const K=b[M].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>K&&this.resetEstimator(K),this.clearTimer(),I.warn(`[abr] Fragment ${t.sn}${r?" part "+r.index:""} of level ${t.level} is loading too slowly;
23
23
  Time to underbuffer: ${p.toFixed(3)} s
24
24
  Estimated load time for current fragment: ${C.toFixed(3)} s
25
25
  Estimated load time for down switch fragment: ${L.toFixed(3)} s
26
26
  TTFB estimate: ${g|0} ms
27
27
  Current BW estimate: ${Y(y)?y|0:"Unknown"} bps
28
28
  New BW estimate: ${this.getBwEstimate()|0} bps
29
- Switching to level ${M} @ ${K|0} bps`),s.trigger(v.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(I.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new bA(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(v.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,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(e,t){const r=t.frag;if(!this.ignoreFragment(r)){if(!r.bitrateTest){var s;this.fragCurrent=r,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case D.FRAG_LOAD_TIMEOUT:{const r=t.frag,{fragCurrent:s,partCurrent:n}=this;if(r&&s&&r.sn===s.sn&&r.level===s.level){const a=performance.now(),o=n?n.stats:r.stats,l=a-o.loading.start,d=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&d>-1){const c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(c,d),o.loaded)}else this.bwEstimator.sampleTTFB(l)}break}}}getTimeToLoadFrag(e,t,r,s){const n=e+r/t,a=s?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){const r=this.hls.config,{loading:s}=t.stats,n=s.end-s.start;Y(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}onFragLoaded(e,{frag:t,part:r}){const s=r?r.stats:t.stats;if(t.type===ee.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const n=r?r.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+s.loaded,l=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){const n={stats:s,frag:t,part:r,id:t.type};this.onFragBuffered(v.FRAG_BUFFERED,n),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:r,part:s}=t,n=s!=null&&s.stats.loaded?s.stats:r.stats;if(n.aborted||this.ignoreFragment(r))return;const a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==ee.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,r=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,n=this.findBestLevel(r,t,e,0,s,1,1);if(n>-1)return n;const a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return I.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,r=this.bwEstimator.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!r||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const n=r&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:s,config:n,minAutoLevel:a}=r,o=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),d=this.getStarvationDelay();let u=n.abrBandWidthFactor,c=n.abrBandWidthUpFactor;if(d){const g=this.findBestLevel(l,a,s,d,0,u,c);if(g>=0)return g}let h=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!d){const g=this.bitrateTestDelay;g&&(h=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-g,I.info(`[abr] bitrate test took ${Math.round(1e3*g)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),u=c=1)}const f=this.findBestLevel(l,a,s,d,h,u,c);if(I.info(`[abr] ${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`),f>-1)return f;const m=r.levels[a],p=r.levels[r.loadLevel];return(m==null?void 0:m.bitrate)<(p==null?void 0:p.bitrate)?a:r.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/r}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,r,s,n,a,o){var l;const d=s+n,u=this.lastLoadedFragLevel,c=u===-1?this.hls.firstLevel:u,{fragCurrent:h,partCurrent:f}=this,{levels:m,allAudioTracks:p,loadLevel:g,config:E}=this.hls;if(m.length===1)return 0;const y=m[c],b=!!(y!=null&&(l=y.details)!=null&&l.live),S=g===-1||u===-1;let _,x="SDR",A=(y==null?void 0:y.frameRate)||0;const{audioPreference:C,videoPreference:O}=E,L=this.audioTracksByGroup||(this.audioTracksByGroup=LA(p));if(S){if(this.firstSelection!==-1)return this.firstSelection;const V=this.codecTiers||(this.codecTiers=IA(m,L,t,r)),q=kA(V,x,e,C,O),{codecSet:ae,videoRanges:ne,minFramerate:G,minBitrate:$,preferHDR:te}=q;_=ae,x=te?ne[ne.length-1]:ne[0],A=G,e=Math.max(e,$),I.log(`[abr] picked start tier ${JSON.stringify(q)}`)}else _=y==null?void 0:y.codecSet,x=y==null?void 0:y.videoRange;const M=f?f.duration:h?h.duration:0,K=this.bwEstimator.getEstimateTTFB()/1e3,U=[];for(let V=r;V>=t;V--){var z;const q=m[V],ae=V>c;if(!q)continue;if(E.useMediaCapabilities&&!q.supportedResult&&!q.supportedPromise){const pe=navigator.mediaCapabilities;typeof(pe==null?void 0:pe.decodingInfo)=="function"&&TA(q,L,x,A,e,C)?(q.supportedPromise=_A(q,L,pe),q.supportedPromise.then(Re=>{if(!this.hls)return;q.supportedResult=Re;const $e=this.hls.levels,yt=$e.indexOf(q);Re.error?I.warn(`[abr] MediaCapabilities decodingInfo error: "${Re.error}" for level ${yt} ${JSON.stringify(Re)}`):Re.supported||(I.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${yt} ${JSON.stringify(Re)}`),yt>-1&&$e.length>1&&(I.log(`[abr] Removing unsupported level ${yt}`),this.hls.removeLevel(yt)))})):q.supportedResult=Ig}if(_&&q.codecSet!==_||x&&q.videoRange!==x||ae&&A>q.frameRate||!ae&&A>0&&A<q.frameRate||q.supportedResult&&!((z=q.supportedResult.decodingInfoResults)!=null&&z[0].smooth)){U.push(V);continue}const ne=q.details,G=(f?ne==null?void 0:ne.partTarget:ne==null?void 0:ne.averagetargetduration)||M;let $;ae?$=o*e:$=a*e;const te=M&&s>=M*2&&n===0?m[V].averageBitrate:m[V].maxBitrate,re=this.getTimeToLoadFrag(K,$,te*G,ne===void 0);if($>=te&&(V===u||q.loadError===0&&q.fragmentError===0)&&(re<=K||!Y(re)||b&&!this.bitrateTestDelay||re<d)){const pe=this.forcedAutoLevel;return V!==g&&(pe===-1||pe!==g)&&(U.length&&I.trace(`[abr] Skipped level(s) ${U.join(",")} of ${r} max with CODECS and VIDEO-RANGE:"${m[U[0]].codecs}" ${m[U[0]].videoRange}; not compatible with "${y.codecs}" ${x}`),I.info(`[abr] switch candidate:${c}->${V} adjustedbw(${Math.round($)})-bitrate=${Math.round($-te)} ttfb:${K.toFixed(1)} avgDuration:${G.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${re.toFixed(1)} firstSelection:${S} codecSet:${_} videoRange:${x} hls.loadLevel:${g}`)),S&&(this.firstSelection=V),V}}return-1}set nextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:r}=this.hls,s=Math.min(Math.max(e,r),t);this._nextAutoLevel!==s&&(this.nextAutoLevelKey="",this._nextAutoLevel=s)}}class DA{constructor(){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(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}var nt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class MA{constructor(e){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=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(v.BUFFER_APPENDED,this.onBufferAppended,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(v.BUFFER_APPENDED,this.onBufferAppended,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const r=this.activePartLists[t];if(r)for(let s=r.length;s--;){const n=r[s];if(!n)break;const a=n.end;if(n.start<=e&&a!==null&&e<=a)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:r}=this,s=Object.keys(r);for(let n=s.length;n--;){const a=r[s[n]];if((a==null?void 0:a.body.type)===t&&a.buffered){const o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,r,s){this.timeRanges&&(this.timeRanges[e]=t);const n=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===r&&this.removeFragment(o.body);return}const l=o.range[e];l&&l.time.some(d=>{const u=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return u&&this.removeFragment(o.body),u})})}detectPartialFragments(e){const t=this.timeRanges,{frag:r,part:s}=e;if(!t||r.sn==="initSegment")return;const n=ys(r),a=this.fragments[n];if(!a||a.buffered&&r.gap)return;const o=!r.relurl;Object.keys(t).forEach(l=>{const d=r.elementaryStreams[l];if(!d)return;const u=t[l],c=o||d.partial===!0;a.range[l]=this.getBufferedTimes(r,s,c,u)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=r.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),Ja(a)||this.removeParts(r.sn-1,r.type)):this.removeFragment(a.body)}removeParts(e,t){const r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){const r=ys(e);let s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,r,s){const n={time:[],partial:r},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let u=0;u<s.length;u++){const c=s.start(u)-this.bufferPadding,h=s.end(u)+this.bufferPadding;if(d>=c&&l<=h){n.time.push({startPTS:Math.max(a,s.start(u)),endPTS:Math.min(o,s.end(u))});break}else if(a<h&&o>c){const f=Math.max(a,s.start(u)),m=Math.min(o,s.end(u));m>f&&(n.partial=!0,n.time.push({startPTS:f,endPTS:m}))}else if(o<=c)break}return n}getPartialFragment(e){let t=null,r,s,n,a=0;const{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{const u=l[d];u&&Ja(u)&&(s=u.body.start-o,n=u.body.end+o,e>=s&&e<=n&&(r=Math.min(e-s,n-e),a<=r&&(t=u.body,a=r)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||Ja(t))}getState(e){const t=ys(e),r=this.fragments[t];return r?r.buffered?Ja(r)?nt.PARTIAL:nt.OK:nt.APPENDING:nt.NOT_LOADED}isTimeBuffered(e,t,r){let s,n;for(let a=0;a<r.length;a++){if(s=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){const{frag:r,part:s}=t;if(r.sn==="initSegment"||r.bitrateTest)return;const n=s?null:t,a=ys(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:r,part:s,timeRanges:n}=t;if(r.sn==="initSegment")return;const a=r.type;if(s){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(s)}this.timeRanges=n,Object.keys(n).forEach(o=>{const l=n[o];this.detectEvictedFragments(o,l,a,s)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=ys(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,r,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o)return;const l=o.body;l.type!==r||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){const t=ys(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const r=this.activePartLists[e.type];if(r){const s=e.sn;this.activePartLists[e.type]=r.filter(n=>n.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function Ja(i){var e,t,r;return i.buffered&&(i.body.gap||((e=i.range.video)==null?void 0:e.partial)||((t=i.range.audio)==null?void 0:t.partial)||((r=i.range.audiovideo)==null?void 0:r.partial))}function ys(i){return`${i.type}_${i.level}_${i.sn}`}const PA={length:0,start:()=>0,end:()=>0};class Le{static isBuffered(e,t){try{if(e){const r=Le.getBuffered(e);for(let s=0;s<r.length;s++)if(t>=r.start(s)&&t<=r.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,r){try{if(e){const s=Le.getBuffered(e),n=[];let a;for(a=0;a<s.length;a++)n.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(n,t,r)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.sort(function(d,u){const c=d.start-u.start;return c||u.end-d.end});let s=[];if(r)for(let d=0;d<e.length;d++){const u=s.length;if(u){const c=s[u-1].end;e[d].start-c<r?e[d].end>c&&(s[u-1].end=e[d].end):s.push(e[d])}else s.push(e[d])}else s=e;let n=0,a,o=t,l=t;for(let d=0;d<s.length;d++){const u=s[d].start,c=s[d].end;if(t+r>=u&&t<c)o=u,l=c,n=l-t;else if(t+r<u){a=u;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return I.log("failed to get media.buffered",t),PA}}}class jh{constructor(e,t,r,s=0,n=-1,a=!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=eo(),this.buffering={audio:eo(),video:eo(),audiovideo:eo()},this.level=e,this.sn=t,this.id=r,this.size=s,this.part=n,this.partial=a}}function eo(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Ro(i,e){for(let r=0,s=i.length;r<s;r++){var t;if(((t=i[r])==null?void 0:t.cc)===e)return i[r]}return null}function OA(i,e,t){return!!(e&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function NA(i,e){const t=i.fragments,r=e.fragments;if(!r.length||!t.length){I.log("No fragments to align");return}const s=Ro(t,r[0].cc);if(!s||s&&!s.startPTS){I.log("No frag in previous level to align on");return}return s}function Km(i,e){if(i){const t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function Rg(i,e){const t=e.fragments;for(let r=0,s=t.length;r<s;r++)Km(t[r],i);e.fragmentHint&&Km(e.fragmentHint,i),e.alignedSliding=!0}function FA(i,e,t){e&&(UA(i,t,e),!t.alignedSliding&&e&&ed(t,e),!t.alignedSliding&&e&&!t.skippedSegments&&Sg(e,t))}function UA(i,e,t){if(OA(i,t,e)){const r=NA(t,e);r&&Y(r.start)&&(I.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),Rg(r.start,e))}}function ed(i,e){if(!i.hasProgramDateTime||!e.hasProgramDateTime)return;const t=i.fragments,r=e.fragments;if(!t.length||!r.length)return;let s,n;const a=Math.min(e.endCC,i.endCC);e.startCC<a&&i.startCC<a&&(s=Ro(r,a),n=Ro(t,a)),(!s||!n)&&(s=r[Math.floor(r.length/2)],n=Ro(t,s.cc)||t[Math.floor(t.length/2)]);const o=s.programDateTime,l=n.programDateTime;if(!o||!l)return;const d=(l-o)/1e3-(n.start-s.start);Rg(d,i)}const Vm=Math.pow(2,17);class $A{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const r=e.url;if(!r)return Promise.reject(new Fi({type:ie.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();const s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(Ym(e));return}else e.gap=!1;const d=this.loader=e.loader=n?new n(s):new a(s),u=qm(e),c=Gm(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Vm};e.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d);let E=f.data;p.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(E.slice(0,16)),E=E.slice(16)),o({frag:e,part:null,payload:E,networkDetails:g})},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new Fi({type:ie.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:dt({url:r,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{this.resetLoader(e,d),l(new Fi({type:ie.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new Fi({type:ie.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))},onProgress:(f,m,p,g)=>{t&&t({frag:e,part:null,payload:p,networkDetails:g})}})})}loadPart(e,t,r){this.abort();const s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(Ym(e,t));return}const d=this.loader=e.loader=n?new n(s):new a(s),u=qm(e,t),c=Gm(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Vm};t.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);const E={frag:e,part:t,payload:f.data,networkDetails:g};r(E),o(E)},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new Fi({type:ie.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:dt({url:u.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new Fi({type:ie.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new Fi({type:ie.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))}})})}updateStatsFromPart(e,t){const r=e.stats,s=t.stats,n=s.total;if(r.loaded+=s.loaded,n){const l=Math.round(e.duration/t.duration),d=Math.min(Math.round(r.loaded/n),l),c=(l-d)*Math.round(r.loaded/d);r.total=r.loaded+c}else r.total=Math.max(r.loaded,r.total);const a=r.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function qm(i,e=null){const t=e||i,r={frag:i,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(Y(s)&&Y(n)){var a;let o=s,l=n;if(i.sn==="initSegment"&&((a=i.decryptdata)==null?void 0:a.method)==="AES-128"){const d=n-s;d%16&&(l=n+(16-d%16)),s!==0&&(r.resetIV=!0,o=s-16)}r.rangeStart=o,r.rangeEnd=l}return r}function Ym(i,e){const t=new Error(`GAP ${i.gap?"tag":"attribute"} found`),r={type:ie.MEDIA_ERROR,details:D.FRAG_GAP,fatal:!1,frag:i,error:t,networkDetails:null};return e&&(r.part=e),(e||i).stats.aborted=!0,new Fi(r)}class Fi extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class BA{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class GA{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function HA(i){const e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?is(i,0,e-t):i}class WA{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_(e){const t=new DataView(e),r=new Uint32Array(4);for(let s=0;s<4;s++)r[s]=t.getUint32(s*4);return r}initTable(){const e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],n=r[1],a=r[2],o=r[3],l=this.invSubMix,d=l[0],u=l[1],c=l[2],h=l[3],f=new Uint32Array(256);let m=0,p=0,g=0;for(g=0;g<256;g++)g<128?f[g]=g<<1:f[g]=g<<1^283;for(g=0;g<256;g++){let E=p^p<<1^p<<2^p<<3^p<<4;E=E>>>8^E&255^99,e[m]=E,t[E]=m;const y=f[m],b=f[y],S=f[b];let _=f[E]*257^E*16843008;s[m]=_<<24|_>>>8,n[m]=_<<16|_>>>16,a[m]=_<<8|_>>>24,o[m]=_,_=S*16843009^b*65537^y*257^m*16843008,d[E]=_<<24|_>>>8,u[E]=_<<16|_>>>16,c[E]=_<<8|_>>>24,h[E]=_,m?(m=y^f[f[f[S^y]]],p^=f[f[p]]):m=p=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let r=!0,s=0;for(;s<t.length&&r;)r=t[s]===this.key[s],s++;if(r)return;this.key=t;const n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);const a=this.ksRows=(n+6+1)*4;let o,l;const d=this.keySchedule=new Uint32Array(a),u=this.invKeySchedule=new Uint32Array(a),c=this.sBox,h=this.rcon,f=this.invSubMix,m=f[0],p=f[1],g=f[2],E=f[3];let y,b;for(o=0;o<a;o++){if(o<n){y=d[o]=t[o];continue}b=y,o%n===0?(b=b<<8|b>>>24,b=c[b>>>24]<<24|c[b>>>16&255]<<16|c[b>>>8&255]<<8|c[b&255],b^=h[o/n|0]<<24):n>6&&o%n===4&&(b=c[b>>>24]<<24|c[b>>>16&255]<<16|c[b>>>8&255]<<8|c[b&255]),d[o]=y=(d[o-n]^b)>>>0}for(l=0;l<a;l++)o=a-l,l&3?b=d[o]:b=d[o-4],l<4||o<=4?u[l]=b:u[l]=m[c[b>>>24]]^p[c[b>>>16&255]]^g[c[b>>>8&255]]^E[c[b&255]],u[l]=u[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,r){const s=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],u=o[2],c=o[3],h=this.uint8ArrayToUint32Array_(r);let f=h[0],m=h[1],p=h[2],g=h[3];const E=new Int32Array(e),y=new Int32Array(E.length);let b,S,_,x,A,C,O,L,M,K,U,z,V,q;const ae=this.networkToHostOrderSwap;for(;t<E.length;){for(M=ae(E[t]),K=ae(E[t+1]),U=ae(E[t+2]),z=ae(E[t+3]),A=M^n[0],C=z^n[1],O=U^n[2],L=K^n[3],V=4,q=1;q<s;q++)b=l[A>>>24]^d[C>>16&255]^u[O>>8&255]^c[L&255]^n[V],S=l[C>>>24]^d[O>>16&255]^u[L>>8&255]^c[A&255]^n[V+1],_=l[O>>>24]^d[L>>16&255]^u[A>>8&255]^c[C&255]^n[V+2],x=l[L>>>24]^d[A>>16&255]^u[C>>8&255]^c[O&255]^n[V+3],A=b,C=S,O=_,L=x,V=V+4;b=a[A>>>24]<<24^a[C>>16&255]<<16^a[O>>8&255]<<8^a[L&255]^n[V],S=a[C>>>24]<<24^a[O>>16&255]<<16^a[L>>8&255]<<8^a[A&255]^n[V+1],_=a[O>>>24]<<24^a[L>>16&255]<<16^a[A>>8&255]<<8^a[C&255]^n[V+2],x=a[L>>>24]<<24^a[A>>16&255]<<16^a[C>>8&255]<<8^a[O&255]^n[V+3],y[t]=ae(b^f),y[t+1]=ae(x^m),y[t+2]=ae(_^p),y[t+3]=ae(S^g),f=M,m=K,p=U,g=z,t=t+4}return y.buffer}}const KA=16;class zh{constructor(e,{removePKCS7Padding:t=!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.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}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:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?HA(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((s,n)=>{this.softwareDecrypt(new Uint8Array(e),t,r);const a=this.flush();a?s(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){const{currentIV:s,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=Ut(a,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;s&&(r=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new WA),l.expandKey(t);const d=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=is(o,-16).buffer,d||null}webCryptoDecrypt(e,t,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new GA(this.subtle,t)}return this.fastAesKey.expandKey().then(s=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new BA(this.subtle,new Uint8Array(r)).decrypt(e.buffer,s)):Promise.reject(new Error("web crypto not initialized"))).catch(s=>(I.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${s.name}: ${s.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);const s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;const r=e.length-e.length%KA;return r!==e.length&&(t=is(e,0,r),this.remainderData=is(e,r)),t}logOnce(e){this.logEnabled&&(I.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const VA={toString:function(i){let e="";const t=i.length;for(let r=0;r<t;r++)e+=`[${i.start(r).toFixed(3)}-${i.end(r).toFixed(3)}]`;return e}},N={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class Xh extends DA{constructor(e,t,r,s,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=N.STOPPED,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.loadedmetadata=!1,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.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=s,this.log=I.log.bind(I,`${s}:`),this.warn=I.warn.bind(I,`${s}:`),this.hls=e,this.fragmentLoader=new $A(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new zh(e.config),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=N.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;const r=t.partList;if(r!=null&&r.length){const n=r[r.length-1];return Le.isBuffered(this.media,n.start+n.duration/2)}const s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}}onMediaAttached(e,t){const r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);const s=this.config;this.levels&&s.autoStartLoad&&this.state===N.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){const e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:r,mediaBuffer:s,state:n}=this,a=r?r.currentTime:0,o=Le.bufferInfo(s||r,a,e.maxBufferHole);if(this.log(`media seeking to ${Y(a)?a.toFixed(3):a}, state: ${n}`),this.state===N.ENDED)this.resetLoadingState();else if(t){const l=e.maxFragLookUpTolerance,d=t.start-l,u=t.start+t.duration+l;if(!o.len||u<o.start||d>o.end){const c=a>u;(a<d||c)&&(c&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=N.STOPPED,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(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){const s=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,r,s).then(n=>{if(!n)return;const a=this.state;if(this.fragContextChanged(e)){(a===N.FRAG_LOADING||!this.fragCurrent&&a===N.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=N.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(v.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(`Frag error: ${(n==null?void 0:n.message)||n}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:r}=this;if(r.getState(e)===nt.APPENDING){const n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),l=this.backtrackFragment;((l?e.sn-l.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&r.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===nt.PARTIAL&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){if(!(e-t))return;const s={startOffset:e,endOffset:t,type:r};this.hls.trigger(v.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(r=>{if(!r||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return r}).then(r=>{const{hls:s}=this,{payload:n}=r,a=e.decryptdata;if(n&&n.byteLength>0&&a!=null&&a.key&&a.iv&&a.method==="AES-128"){const o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw s.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{const d=self.performance.now();return s.trigger(v.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),r.payload=l,this.completeInitSegmentLoad(r)})}return this.completeInitSegmentLoad(r)}).catch(r=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const r=e.frag.stats;this.state=N.IDLE,e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var r,s,n,a;const o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===ee.MAIN?"level":"track"} ${e.level} (frag:[${((r=e.startPTS)!=null?r:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?VA.toString(Le.getBuffered(o)):"(detached)"})`),e.sn!=="initSegment"){var l;if(e.type!==ee.SUBTITLE){const u=e.elementaryStreams;if(!Object.keys(u).some(c=>!!u[c])){this.state=N.IDLE;return}}const d=(l=this.levels)==null?void 0:l[e.level];d!=null&&d.fragmentError&&(this.log(`Resetting level fragment error count of ${d.fragmentError} on frag buffered`),d.fragmentError=0)}this.state=N.IDLE,o&&(!this.loadedmetadata&&e.type==ee.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:r,part:s,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new jh(r.level,r.sn,r.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,s){var n;const a=t==null?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=N.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(u=>{if(!this.fragContextChanged(u.frag))return this.hls.trigger(v.KEY_LOADED,u),this.state===N.KEY_LOADING&&(this.state=N.IDLE),u}),this.hls.trigger(v.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){const u=a.partList;if(u&&s){r>e.end&&a.fragmentHint&&(e=a.fragmentHint);const c=this.getNextPart(u,e,r);if(c>-1){const h=u[c];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${c}-${u.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=N.FRAG_LOADING;let f;return o?f=o.then(m=>!m||this.fragContextChanged(m.frag)?null:this.doFragPartsLoad(e,h,t,s)).catch(m=>this.handleFragLoadError(m)):f=this.doFragPartsLoad(e,h,t,s).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(v.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),Y(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=N.FRAG_LOADING;const l=this.config.progressive;let d;return l&&o?d=o.then(u=>!u||this.fragContextChanged(u==null?void 0:u.frag)?null:this.fragmentLoader.load(e,s)).catch(u=>this.handleFragLoadError(u)):d=Promise.all([this.fragmentLoader.load(e,l?s:void 0),o]).then(([u])=>(!l&&u&&s&&s(u),u)).catch(u=>this.handleFragLoadError(u)),this.hls.trigger(v.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,s){return new Promise((n,a)=>{var o;const l=[],d=(o=r.details)==null?void 0:o.partList,u=c=>{this.fragmentLoader.loadPart(e,c,s).then(h=>{l[c.index]=h;const f=h.part;this.hls.trigger(v.FRAG_LOADED,h);const m=$m(r,e.sn,c.index+1)||xg(d,e.sn,c.index+1);if(m)u(m);else return n({frag:e,part:f,partsLoaded:l})}).catch(a)};u(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===D.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(v.ERROR,t)}else this.hls.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==N.PARSING){!this.fragCurrent&&this.state!==N.STOPPED&&this.state!==N.ERROR&&(this.state=N.IDLE);return}const{frag:r,part:s,level:n}=t,a=self.performance.now();r.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(r,s,n,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:r}=this,{level:s,sn:n,part:a}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${s}. The current chunk will not be buffered.`),null;const o=t[s],l=a>-1?$m(o,n,a):null,d=l?l.fragment:fA(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,r,s,n){var a;if(!e||this.state!==N.PARSING)return;const{data1:o,data2:l}=e;let d=o;if(o&&l&&(d=Ut(o,l)),!((a=d)!=null&&a.length))return;const u={type:e.type,frag:t,part:r,chunkMeta:s,parent:t.type,data:d};if(this.hls.trigger(v.BUFFER_APPENDING,u),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Le.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const r=t.currentTime,s=Le.bufferInfo(t,r,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,s.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){const r=this.getLoadPosition();return Y(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){const{config:{maxBufferHole:s}}=this,n=Le.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){const a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&n.nextStart<a.end)return Le.bufferInfo(e,t,Math.max(n.nextStart,s))}return n}getMaxBufferLength(e){const{config:t}=this;let r;return e?r=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):r=t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const r=this.config,s=Math.max(Math.min(e-t,r.maxBufferLength),t),n=Math.max(e-t*3,r.maxMaxBufferLength/2,s);return n>=s?(r.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),!0):!1}getAppendedFrag(e,t=ee.MAIN){const r=this.fragmentTracker.getAppendedFrag(e,ee.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){const r=t.fragments,s=r.length;if(!s)return null;const{config:n}=this,a=r[0].start;let o;if(t.live){const l=n.initialLiveManifestSize;if(s<l)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${l})`),null;(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a)&&(o=this.getInitialLiveFragment(t,r),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=r[0]);if(!o){const l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){const r=this.fragmentTracker.getState(e);return(r===nt.OK||r===nt.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,s,n){const a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&r.nextStart){const l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,s);if(l!==null&&r.len+l.len>=n)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,r){let s=-1,n=!1,a=!0;for(let o=0,l=e.length;o<l;o++){const d=e[o];if(a=a&&!d.independent,s>-1&&r<d.start)break;const u=d.loaded;u?s=-1:(n||d.independent||a)&&d.fragment===t&&(s=o),n=u}return s}loadedEndOfParts(e,t){const r=e[e.length-1];return r&&t>r.start&&r.loaded}getInitialLiveFragment(e,t){const r=this.fragPrevious;let s=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),s=pA(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){const n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){const a=t[n-e.startSN];r.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=EA(t,r.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const n=this.hls.liveSyncPosition;n!==null&&(s=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,r){const{config:s}=this;let{fragPrevious:n}=this,{fragments:a,endSN:o}=r;const{fragmentHint:l}=r,{maxFragLookUpTolerance:d}=s,u=r.partList,c=!!(s.lowLatencyMode&&u!=null&&u.length&&l);c&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let h;if(e<t){const f=e>t-d?0:d;h=Jl(n,a,e,f)}else h=a[a.length-1];if(h){const f=h.sn-r.startSN,m=this.fragmentTracker.getState(h);if((m===nt.OK||m===nt.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!c||u[0].fragment.sn>h.sn)&&n&&h.level===n.level){const g=a[f+1];h.sn<o&&this.fragmentTracker.getState(g)!==nt.OK?h=g:h=null}}return h}synchronizeToLiveEdge(e){const{config:t,media:r}=this;if(!r)return;const s=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&r.duration>s&&(n<s||!l)){const d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&r.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=s),r.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),r.currentTime=s))}}alignPlaylists(e,t,r){const s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;const n=e.fragments[0].start,a=!t,o=e.alignedSliding&&Y(n);if(a||!o&&!n){const{fragPrevious:l}=this;FA(l,r,e);const d=e.fragments[0].start;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${l?l.sn:"na"} fragments: ${s}`),d}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let r=this.startPosition;if(r<t&&(r=-1),r===-1||this.lastCurrentTime===-1){const s=this.startTimeOffset!==null,n=s?this.startTimeOffset:e.startTimeOffset;n!==null&&Y(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${n} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){const{media:e}=this;let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==N.FRAG_LOADING_WAITING_RETRY)&&(this.state=N.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const u=this.getCurrentContext(t.chunkMeta);u&&(t.frag=u.frag)}const r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var s;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}const n=t.details===D.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(r,!0);const a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===ht.RetryRequest&&d){this.resetStartWhenNotLoaded(this.levelLastLoaded);const u=qh(d,l);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${u}ms`),a.resolved=!0,this.retryDate=self.performance.now()+u,this.state=N.FRAG_LOADING_WAITING_RETRY}else if(d&&a)if(this.resetFragmentErrors(e),l<d.maxNumRetry)!n&&o!==ht.RemoveAlternatePermanently&&(a.resolved=!0);else{I.warn(`${t.details} reached or exceeded max retry (${l})`);return}else(a==null?void 0:a.action)===ht.SendAlternateToPenaltyBox?this.state=N.WAITING_LEVEL:this.state=N.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===N.PARSING||this.state===N.PARSED){const t=e.frag,r=e.parent,s=this.getFwdBufferInfo(this.mediaBuffer,r),n=s&&s.len>.5;n&&this.reduceMaxBufferLength(s.len,(t==null?void 0:t.duration)||10);const a=!n;return a&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${r} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===ee.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==N.STOPPED&&(this.state=N.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;const s=Le.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,r),this.state===N.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=N.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=e?e.details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,s){var n;const a=r.details;if(!a){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((l,d)=>{const u=e.elementaryStreams[d];if(u){const c=u.endPTS-u.startPTS;if(c<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${c})`),l||!1;const h=s?0:Ag(a,e,u.startPTS,u.endPTS,u.startDTS,u.endDTS);return this.hls.trigger(v.LEVEL_PTS_UPDATED,{details:a,level:r,drift:h,type:d,frag:e,start:u.startPTS,end:u.endPTS}),!0}return l},!1)&&((n=this.transmuxer)==null?void 0:n.error)===null){const l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(r.fragmentError===0&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=N.PARSED,this.hls.trigger(v.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}class wg{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let r;if(e.length)e.length===1?r=e[0]:r=qA(e,t);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}}function qA(i,e){const t=new Uint8Array(e);let r=0;for(let s=0;s<i.length;s++){const n=i[s];t.set(n,r),r+=n.length}return t}function YA(){return typeof __HLS_WORKER_BUNDLE__=="function"}function jA(){const i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(i);return{worker:new self.Worker(e),objectURL:e}}function zA(i){const e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function gi(i="",e=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Qh{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(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=Ut(this.cachedData,e),this.cachedData=null);let r=La(e,0),s=r?r.length:0,n;const a=this._audioTrack,o=this._id3Track,l=r?Vh(r):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&Y(l))&&(this.basePTS=XA(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Yt.audioId3,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(e,s)){const u=this.appendFrame(a,e,s);u?(this.frameIndex++,this.lastPTS=u.sample.pts,s+=u.length,n=s):s=d}else v1(e,s)?(r=La(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Yt.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,n=s):s++;if(s===d&&n!==d){const u=is(e,n);this.cachedData?this.cachedData=Ut(this.cachedData,u):this.cachedData=u}}return{audioTrack:a,videoTrack:gi(),id3Track:o,textTrack:gi()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:gi(),id3Track:this._id3Track,textTrack:gi()}}destroy(){}}const XA=(i,e,t)=>{if(Y(i))return i*90;const r=t?t.baseTime*9e4/t.timescale:0;return e*9e4+r};function QA(i,e,t,r){let s,n,a,o;const l=navigator.userAgent.toLowerCase(),d=r,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((e[t+2]&192)>>>6)+1;const c=(e[t+2]&60)>>>2;if(c>u.length-1){const h=new Error(`invalid ADTS sampling index:${c}`);i.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,I.log(`manifest codec:${r}, ADTS type:${s}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(s=5,o=new Array(4),n=c-3):(s=2,o=new Array(2),n=c):l.indexOf("android")!==-1?(s=2,o=new Array(2),n=c):(s=5,o=new Array(4),r&&(r.indexOf("mp4a.40.29")!==-1||r.indexOf("mp4a.40.5")!==-1)||!r&&c>=6?n=c-3:((r&&r.indexOf("mp4a.40.2")!==-1&&(c>=6&&a===1||/vivaldi/i.test(l))||!r&&a===1)&&(s=2,o=new Array(2)),n=c)),o[0]=s<<3,o[0]|=(c&14)>>1,o[1]|=(c&1)<<7,o[1]|=a<<3,s===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:u[c],channelCount:a,codec:"mp4a.40."+s,manifestCodec:d}}function Cg(i,e){return i[e]===255&&(i[e+1]&246)===240}function Dg(i,e){return i[e+1]&1?7:9}function Zh(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function ZA(i,e){return e+5<i.length}function td(i,e){return e+1<i.length&&Cg(i,e)}function JA(i,e){return ZA(i,e)&&Cg(i,e)&&Zh(i,e)<=i.length-e}function eS(i,e){if(td(i,e)){const t=Dg(i,e);if(e+t>=i.length)return!1;const r=Zh(i,e);if(r<=t)return!1;const s=e+r;return s===i.length||td(i,s)}return!1}function Mg(i,e,t,r,s){if(!i.samplerate){const n=QA(e,t,r,s);if(!n)return;i.config=n.config,i.samplerate=n.samplerate,i.channelCount=n.channelCount,i.codec=n.codec,i.manifestCodec=n.manifestCodec,I.log(`parsed codec:${i.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function Pg(i){return 1024*9e4/i}function tS(i,e){const t=Dg(i,e);if(e+t<=i.length){const r=Zh(i,e)-t;if(r>0)return{headerLength:t,frameLength:r}}}function Og(i,e,t,r,s){const n=Pg(i.samplerate),a=r+s*n,o=tS(e,t);let l;if(o){const{frameLength:c,headerLength:h}=o,f=h+c,m=Math.max(0,t+f-e.length);m?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);const p={unit:l,pts:a};return m||i.samples.push(p),{sample:p,length:f,missing:m}}const d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:d,missing:-1}}let to=null;const iS=[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],rS=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],sS=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],nS=[0,1,1,4];function Ng(i,e,t,r,s){if(t+24>e.length)return;const n=Fg(e,t);if(n&&t+n.frameLength<=e.length){const a=n.samplesPerFrame*9e4/n.sampleRate,o=r+s*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return i.config=[],i.channelCount=n.channelCount,i.samplerate=n.sampleRate,i.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function Fg(i,e){const t=i[e+1]>>3&3,r=i[e+1]>>1&3,s=i[e+2]>>4&15,n=i[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){const a=i[e+2]>>1&1,o=i[e+3]>>6,l=t===3?3-r:r===3?3:4,d=iS[l*14+s-1]*1e3,c=rS[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=sS[t][r],m=nS[r],p=f*8*m,g=Math.floor(f*d/c+a)*m;if(to===null){const b=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);to=b?parseInt(b[1]):0}return!!to&&to<=87&&r===2&&d>=224e3&&o===0&&(i[e+3]=i[e+3]|128),{sampleRate:c,channelCount:h,frameLength:g,samplesPerFrame:p}}}function Jh(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function Ug(i,e){return e+1<i.length&&Jh(i,e)}function aS(i,e){return Jh(i,e)&&4<=i.length-e}function $g(i,e){if(e+1<i.length&&Jh(i,e)){const r=Fg(i,e);let s=4;r!=null&&r.frameLength&&(s=r.frameLength);const n=e+s;return n===i.length||Ug(i,n)}return!1}class oS extends Qh{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=La(e,0);let r=(t==null?void 0:t.length)||0;if($g(e,r))return!1;for(let s=e.length;r<s;r++)if(eS(e,r))return I.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return JA(e,t)}appendFrame(e,t,r){Mg(e,this.observer,t,r,e.manifestCodec);const s=Og(e,t,r,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}}const lS=/\/emsg[-/]ID3/i;class dS{constructor(e,t){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=t}resetTimeStamp(){}resetInitSegment(e,t,r,s){const n=this.videoTrack=gi("video",1),a=this.audioTrack=gi("audio",1),o=this.txtTrack=gi("text",1);if(this.id3Track=gi("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const l=pg(e);if(l.video){const{id:d,timescale:u,codec:c}=l.video;n.id=d,n.timescale=o.timescale=u,n.codec=c}if(l.audio){const{id:d,timescale:u,codec:c}=l.audio;a.id=d,a.timescale=u,a.codec=c}o.id=hg.text,n.sampleDuration=0,n.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return k1(e)}demux(e,t){this.timeOffset=t;let r=e;const s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Ut(this.remainderData,e));const o=P1(r);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=r;const a=this.extractID3Track(s,t);return n.samples=bm(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const s=this.extractID3Track(t,this.timeOffset);return r.samples=bm(e,t),{videoTrack:t,audioTrack:gi(),id3Track:s,textTrack:gi()}}extractID3Track(e,t){const r=this.id3Track;if(e.samples.length){const s=le(e.samples,["emsg"]);s&&s.forEach(n=>{const a=F1(n);if(lS.test(a.schemeIdUri)){const o=Y(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale;let l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);const d=a.payload;r.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:Yt.emsg,duration:l})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}const Bg=(i,e)=>{let t=0,r=5;e+=r;const s=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;r>0;){a[0]=i[e];const o=Math.min(r,8),l=8-o;n[0]=4278190080>>>24+l<<l,s[0]=(a[0]&n[0])>>l,t=t?t<<o|s[0]:s[0],e+=1,r-=o}return t};class uS extends Qh{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,r){const s=Gg(e,t,r,this.basePTS,this.frameIndex);if(s!==-1)return{sample:e.samples[e.samples.length-1],length:s,missing:0}}static probe(e){if(!e)return!1;const t=La(e,0);if(!t)return!1;const r=t.length;return e[r]===11&&e[r+1]===119&&Vh(t)!==void 0&&Bg(e,r)<16}}function Gg(i,e,t,r,s){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const n=e[t+4]>>6;if(n>=3)return-1;const o=[48e3,44100,32e3][n],l=e[t+4]&63,u=[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][l*3+n]*2;if(t+u>e.length)return-1;const c=e[t+6]>>5;let h=0;c===2?h+=2:(c&1&&c!==1&&(h+=2),c&4&&(h+=2));const f=(e[t+6]<<8|e[t+7])>>12-h&1,p=[2,1,2,3,3,4,4,5][c]+f,g=e[t+5]>>3,E=e[t+5]&7,y=new Uint8Array([n<<6|g<<1|E>>2,(E&3)<<6|c<<3|f<<2|l>>4,l<<4&224]),b=1536/o*9e4,S=r+s*b,_=e.subarray(t,t+u);return i.config=y,i.channelCount=p,i.samplerate=o,i.samples.push({unit:_,pts:S}),u}class cS{constructor(){this.VideoSample=null}createVideoSample(e,t,r,s){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:s,length:0}}getLastNalUnit(e){var t;let r=this.VideoSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){const n=r.units;s=n[n.length-1]}return s}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const r=t.samples,s=r.length;if(s){const n=r[s-1];e.pts=n.pts,e.dts=n.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&I.log(e.pts+"/"+e.dts+":"+e.debug)}}class jm{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");s.set(e.subarray(r,r+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const r=this.word>>>32-t;if(e>32&&I.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,r=8,s;for(let n=0;n<e;n++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r}readSPS(){let e=0,t=0,r=0,s=0,n,a,o;const l=this.readUByte.bind(this),d=this.readBits.bind(this),u=this.readUEG.bind(this),c=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),m=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);l();const g=l();if(d(5),h(3),l(),m(),g===100||g===110||g===122||g===244||g===44||g===83||g===86||g===118||g===128){const x=u();if(x===3&&h(1),m(),m(),h(1),c())for(a=x!==3?8:12,o=0;o<a;o++)c()&&(o<6?p(16):p(64))}m();const E=u();if(E===0)u();else if(E===1)for(h(1),f(),f(),n=u(),o=0;o<n;o++)f();m(),h(1);const y=u(),b=u(),S=d(1);S===0&&h(1),h(1),c()&&(e=u(),t=u(),r=u(),s=u());let _=[1,1];if(c()&&c())switch(l()){case 1:_=[1,1];break;case 2:_=[12,11];break;case 3:_=[10,11];break;case 4:_=[16,11];break;case 5:_=[40,33];break;case 6:_=[24,11];break;case 7:_=[20,11];break;case 8:_=[32,11];break;case 9:_=[80,33];break;case 10:_=[18,11];break;case 11:_=[15,11];break;case 12:_=[64,33];break;case 13:_=[160,99];break;case 14:_=[4,3];break;case 15:_=[3,2];break;case 16:_=[2,1];break;case 255:{_=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((y+1)*16-e*2-t*2),height:(2-S)*(b+1)*16-(S?2:4)*(r+s),pixelRatio:_}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class hS extends cS{parseAVCPES(e,t,r,s,n){const a=this.parseAVCNALu(e,r.data);let o=this.VideoSample,l,d=!1;r.data=null,o&&a.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),a.forEach(u=>{var c;switch(u.type){case 1:{let p=!1;l=!0;const g=u.data;if(d&&g.length>4){const E=new jm(g).readSliceType();(E===2||E===4||E===7||E===9)&&(p=!0)}if(p){var h;(h=o)!=null&&h.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.frame=!0,o.key=p;break}case 5:l=!0,(c=o)!=null&&c.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:{l=!0,vg(u.data,1,r.pts,t.samples);break}case 7:{var f,m;l=!0,d=!0;const p=u.data,E=new jm(p).readSPS();if(!e.sps||e.width!==E.width||e.height!==E.height||((f=e.pixelRatio)==null?void 0:f[0])!==E.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==E.pixelRatio[1]){e.width=E.width,e.height=E.height,e.pixelRatio=E.pixelRatio,e.sps=[p],e.duration=n;const y=p.subarray(1,4);let b="avc1.";for(let S=0;S<3;S++){let _=y[S].toString(16);_.length<2&&(_="0"+_),b+=_}e.codec=b}break}case 8:l=!0,e.pps=[u.data];break;case 9:l=!0,e.audFound=!0,o&&this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"");break;case 12:l=!0;break;default:l=!1,o&&(o.debug+="unknown NAL "+u.type+" ");break}o&&l&&o.units.push(u)}),s&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}parseAVCNALu(e,t){const r=t.byteLength;let s=e.naluState||0;const n=s,a=[];let o=0,l,d,u,c=-1,h=0;for(s===-1&&(c=0,h=t[0]&31,s=0,o=1);o<r;){if(l=t[o++],!s){s=l?0:1;continue}if(s===1){s=l?0:2;continue}if(!l)s=3;else if(l===1){if(d=o-s-1,c>=0){const f={data:t.subarray(c,d),type:h};a.push(f)}else{const f=this.getLastNalUnit(e.samples);f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),d>0&&(f.data=Ut(f.data,t.subarray(0,d)),f.state=0))}o<r?(u=t[o]&31,c=o,h=u,s=0):s=-1}else s=0}if(c>=0&&s>=0){const f={data:t.subarray(c,r),type:h,state:s};a.push(f)}if(a.length===0){const f=this.getLastNalUnit(e.samples);f&&(f.data=Ut(f.data,t))}return e.naluState=s,a}}class fS{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new zh(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){const s=e[t].unit;if(s.length<=16)return;const n=s.subarray(16,s.length-s.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{const l=new Uint8Array(o);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t);let s=0;for(let n=32;n<e.length-16;n+=160,s+=16)r.set(e.subarray(n,n+16),s);return r}getAvcDecryptedUnit(e,t){const r=new Uint8Array(t);let s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(r.subarray(s,s+16),n);return e}decryptAvcSample(e,t,r,s,n){const a=Eg(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,s)})}decryptAvcSamples(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}const n=e[t].units;for(;!(r>=n.length);r++){const a=n[r];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,r,s,a),!this.decrypter.isSync()))return}}}}const et=188;class nr{constructor(e,t,r){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._duration=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=e,this.config=t,this.typeSupported=r,this.videoParser=new hS}static probe(e){const t=nr.syncOffset(e);return t>0&&I.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){const t=e.length;let r=Math.min(et*5,t-et)+1,s=0;for(;s<r;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=et)if(e[l]===71&&(t-l===et||e[l+et]===71)){if(o++,a===-1&&(a=l,a!==0&&(r=Math.min(a+et*99,e.length-et)+1)),n||(n=Ju(e,l)===0),n&&o>1&&(a===0&&o>2||l+et>r))return a}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:hg[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=nr.createTrack("video"),this._audioTrack=nr.createTrack("audio",s),this._id3Track=nr.createTrack("id3"),this._txtTrack=nr.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,r=!1,s=!1){r||(this.sampleAes=null);let n;const a=this._videoTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack;let u=a.pid,c=a.pesData,h=o.pid,f=l.pid,m=o.pesData,p=l.pesData,g=null,E=this.pmtParsed,y=this._pmtId,b=e.length;if(this.remainderData&&(e=Ut(this.remainderData,e),b=e.length,this.remainderData=null),b<et&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};const S=Math.max(0,nr.syncOffset(e));b-=(b-S)%et,b<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,b,e.buffer.byteLength-b));let _=0;for(let A=S;A<b;A+=et)if(e[A]===71){const C=!!(e[A+1]&64),O=Ju(e,A),L=(e[A+3]&48)>>4;let M;if(L>1){if(M=A+5+e[A+4],M===A+et)continue}else M=A+4;switch(O){case u:C&&(c&&(n=bs(c))&&this.videoParser.parseAVCPES(a,d,n,!1,this._duration),c={data:[],size:0}),c&&(c.data.push(e.subarray(M,A+et)),c.size+=A+et-M);break;case h:if(C){if(m&&(n=bs(m)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break;case"ac3":this.parseAC3PES(o,n);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(M,A+et)),m.size+=A+et-M);break;case f:C&&(p&&(n=bs(p))&&this.parseID3PES(l,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(M,A+et)),p.size+=A+et-M);break;case 0:C&&(M+=e[M]+1),y=this._pmtId=mS(e,M);break;case y:{C&&(M+=e[M]+1);const K=pS(e,M,this.typeSupported,r,this.observer);u=K.videoPid,u>0&&(a.pid=u,a.segmentCodec=K.segmentVideoCodec),h=K.audioPid,h>0&&(o.pid=h,o.segmentCodec=K.segmentAudioCodec),f=K.id3Pid,f>0&&(l.pid=f),g!==null&&!E&&(I.warn(`MPEG-TS PMT found at ${A} after unknown PID '${g}'. Backtracking to sync byte @${S} to parse all TS packets.`),g=null,A=S-188),E=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=O;break}}else _++;_>0&&id(this.observer,new Error(`Found ${_} TS packet/s that do not start with 0x47`)),a.pesData=c,o.pesData=m,l.pesData=p;const x={audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};return s&&this.extractRemainingSamples(x),x}flush(){const{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:r,id3Track:s,textTrack:n}=e,a=r.pesData,o=t.pesData,l=s.pesData;let d;if(a&&(d=bs(a))?(this.videoParser.parseAVCPES(r,n,d,!0,this._duration),r.pesData=null):r.pesData=a,o&&(d=bs(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break;case"ac3":this.parseAC3PES(t,d);break}t.pesData=null}else o!=null&&o.size&&I.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=bs(l))?(this.parseID3PES(s,d),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,r){const s=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new fS(this.observer,this.config,t);return this.decrypt(s,n)}decrypt(e,t){return new Promise(r=>{const{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAACPES(e,t){let r=0;const s=this.aacOverFlow;let n=t.data;if(s){this.aacOverFlow=null;const c=s.missing,h=s.sample.unit.byteLength;if(c===-1)n=Ut(s.sample.unit,n);else{const f=h-c;s.sample.unit.set(n.subarray(0,c),f),e.samples.push(s.sample),r=s.missing}}let a,o;for(a=r,o=n.length;a<o-1&&!td(n,a);a++);if(a!==r){let c;const h=a<o-1;if(h?c=`AAC PES did not start with ADTS header,offset:${a}`:c="No ADTS header found in AAC PES",id(this.observer,new Error(c),h),!h)return}Mg(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){const c=Pg(e.samplerate);l=s.sample.pts+c}else{I.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,u;for(;a<o;)if(u=Og(e,n,a,l,d),a+=u.length,u.missing){this.aacOverFlow=u;break}else for(d++;a<o-1&&!td(n,a);a++);}parseMPEGPES(e,t){const r=t.data,s=r.length;let n=0,a=0;const o=t.pts;if(o===void 0){I.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(Ug(r,a)){const l=Ng(e,r,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseAC3PES(e,t){{const r=t.data,s=t.pts;if(s===void 0){I.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const n=r.length;let a=0,o=0,l;for(;o<n&&(l=Gg(e,r,o,s,a++))>0;)o+=l}}parseID3PES(e,t){if(t.pts===void 0){I.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const r=We({},t,{type:this._videoTrack?Yt.emsg:Yt.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}}function Ju(i,e){return((i[e+1]&31)<<8)+i[e+2]}function mS(i,e){return(i[e+10]&31)<<8|i[e+11]}function pS(i,e,t,r,s){const n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},a=(i[e+1]&15)<<8|i[e+2],o=e+3+a-4,l=(i[e+10]&15)<<8|i[e+11];for(e+=12+l;e<o;){const d=Ju(i,e),u=(i[e+3]&15)<<8|i[e+4];switch(i[e]){case 207:if(!r){ou("ADTS AAC");break}case 15:n.audioPid===-1&&(n.audioPid=d);break;case 21:n.id3Pid===-1&&(n.id3Pid=d);break;case 219:if(!r){ou("H.264");break}case 27:n.videoPid===-1&&(n.videoPid=d,n.segmentVideoCodec="avc");break;case 3:case 4:!t.mpeg&&!t.mp3?I.log("MPEG audio found, not supported in this browser"):n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="mp3");break;case 193:if(!r){ou("AC-3");break}case 129:t.ac3?n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="ac3"):I.log("AC-3 audio found, not supported in this browser");break;case 6:if(n.audioPid===-1&&u>0){let c=e+5,h=u;for(;h>2;){switch(i[c]){case 106:t.ac3!==!0?I.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=d,n.segmentAudioCodec="ac3");break}const m=i[c+1]+2;c+=m,h-=m}}break;case 194:case 135:return id(s,new Error("Unsupported EC-3 in M2TS found")),n;case 36:return id(s,new Error("Unsupported HEVC in M2TS found")),n}e+=u+5}return n}function id(i,e,t){I.warn(`parsing error: ${e.message}`),i.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function ou(i){I.log(`${i} with AES-128-CBC encryption found in unencrypted stream`)}function bs(i){let e=0,t,r,s,n,a;const o=i.data;if(!i||i.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=Ut(o[0],o[1]),o.splice(1,1);if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(r=(t[4]<<8)+t[5],r&&r>i.size-6)return null;const d=t[7];d&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-a>60*9e4&&(I.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=t[8];let u=s+9;if(i.size<=u)return null;i.size-=u;const c=new Uint8Array(i.size);for(let h=0,f=o.length;h<f;h++){t=o[h];let m=t.byteLength;if(u)if(u>m){u-=m;continue}else t=t.subarray(u),m-=u,u=0;c.set(t,e),e+=m}return r&&(r-=s+3),{data:c,pts:n,dts:a,len:r}}return null}class gS extends Qh{resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=La(e,0);let r=(t==null?void 0:t.length)||0;if(t&&e[r]===11&&e[r+1]===119&&Vh(t)!==void 0&&Bg(e,r)<=16)return!1;for(let s=e.length;r<s;r++)if($g(e,r))return I.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return aS(e,t)}appendFrame(e,t,r){if(this.basePTS!==null)return Ng(e,t,r,this.basePTS,this.frameIndex)}}class zm{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)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(t===6)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]);break;default:if(t===1)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(t===2)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(t===3)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]);break}}}const ji=Math.pow(2,32)-1;class w{static init(){w.types={avc1:[],avcC:[],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:[]};let e;for(e in w.types)w.types.hasOwnProperty(e)&&(w.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=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]),r=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]);w.HDLR_TYPES={video:t,audio:r};const s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);w.STTS=w.STSC=w.STCO=n,w.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),w.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),w.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),w.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);w.FTYP=w.box(w.types.ftyp,a,l,a,o),w.DINF=w.box(w.types.dinf,w.box(w.types.dref,s))}static box(e,...t){let r=8,s=t.length;const n=s;for(;s--;)r+=t[s].byteLength;const a=new Uint8Array(r);for(a[0]=r>>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=r&255,a.set(e,4),s=0,r=8;s<n;s++)a.set(t[s],r),r+=t[s].byteLength;return a}static hdlr(e){return w.box(w.types.hdlr,w.HDLR_TYPES[e])}static mdat(e){return w.box(w.types.mdat,e)}static mdhd(e,t){t*=e;const r=Math.floor(t/(ji+1)),s=Math.floor(t%(ji+1));return w.box(w.types.mdhd,new Uint8Array([1,0,0,0,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,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return w.box(w.types.mdia,w.mdhd(e.timescale,e.duration),w.hdlr(e.type),w.minf(e))}static mfhd(e){return w.box(w.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?w.box(w.types.minf,w.box(w.types.smhd,w.SMHD),w.DINF,w.stbl(e)):w.box(w.types.minf,w.box(w.types.vmhd,w.VMHD),w.DINF,w.stbl(e))}static moof(e,t,r){return w.box(w.types.moof,w.mfhd(e),w.traf(r,t))}static moov(e){let t=e.length;const r=[];for(;t--;)r[t]=w.trak(e[t]);return w.box.apply(null,[w.types.moov,w.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(w.mvex(e)))}static mvex(e){let t=e.length;const r=[];for(;t--;)r[t]=w.trex(e[t]);return w.box.apply(null,[w.types.mvex,...r])}static mvhd(e,t){t*=e;const r=Math.floor(t/(ji+1)),s=Math.floor(t%(ji+1)),n=new Uint8Array([1,0,0,0,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,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,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 w.box(w.types.mvhd,n)}static sdtp(e){const t=e.samples||[],r=new Uint8Array(4+t.length);let s,n;for(s=0;s<t.length;s++)n=t[s].flags,r[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return w.box(w.types.sdtp,r)}static stbl(e){return w.box(w.types.stbl,w.stsd(e),w.box(w.types.stts,w.STTS),w.box(w.types.stsc,w.STSC),w.box(w.types.stsz,w.STSZ),w.box(w.types.stco,w.STCO))}static avc1(e){let t=[],r=[],s,n,a;for(s=0;s<e.sps.length;s++)n=e.sps[s],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(s=0;s<e.pps.length;s++)n=e.pps[s],a=n.byteLength,r.push(a>>>8&255),r.push(a&255),r=r.concat(Array.prototype.slice.call(n));const o=w.box(w.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(r))),l=e.width,d=e.height,u=e.pixelRatio[0],c=e.pixelRatio[1];return w.box(w.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,l>>8&255,l&255,d>>8&255,d&255,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,w.box(w.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),w.box(w.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,c>>24,c>>16&255,c>>8&255,c&255])))}static esds(e){const t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){const t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return w.box(w.types.mp4a,w.audioStsd(e),w.box(w.types.esds,w.esds(e)))}static mp3(e){return w.box(w.types[".mp3"],w.audioStsd(e))}static ac3(e){return w.box(w.types["ac-3"],w.audioStsd(e),w.box(w.types.dac3,e.config))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?w.box(w.types.stsd,w.STSD,w.mp3(e)):e.segmentCodec==="ac3"?w.box(w.types.stsd,w.STSD,w.ac3(e)):w.box(w.types.stsd,w.STSD,w.mp4a(e)):w.box(w.types.stsd,w.STSD,w.avc1(e))}static tkhd(e){const t=e.id,r=e.duration*e.timescale,s=e.width,n=e.height,a=Math.floor(r/(ji+1)),o=Math.floor(r%(ji+1));return w.box(w.types.tkhd,new Uint8Array([1,0,0,7,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,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,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,s>>8&255,s&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){const r=w.sdtp(e),s=e.id,n=Math.floor(t/(ji+1)),a=Math.floor(t%(ji+1));return w.box(w.types.traf,w.box(w.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),w.box(w.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),w.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,w.box(w.types.trak,w.tkhd(e),w.mdia(e))}static trex(e){const t=e.id;return w.box(w.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const r=e.samples||[],s=r.length,n=12+16*s,a=new Uint8Array(n);let o,l,d,u,c,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)l=r[o],d=l.duration,u=l.size,c=l.flags,h=l.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,c.degradPrio&61440,c.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return w.box(w.types.trun,a)}static initSegment(e){w.types||w.init();const t=w.moov(e);return Ut(w.FTYP,t)}}w.types=void 0;w.HDLR_TYPES=void 0;w.STTS=void 0;w.STSC=void 0;w.STCO=void 0;w.STSZ=void 0;w.VMHD=void 0;w.SMHD=void 0;w.STSD=void 0;w.FTYP=void 0;w.DINF=void 0;const Hg=9e4;function ef(i,e,t=1,r=!1){const s=i*e*t;return r?Math.round(s):s}function vS(i,e,t=1,r=!1){return ef(i,e,1/t,r)}function In(i,e=!1){return ef(i,1e3,1/Hg,e)}function ES(i,e=1){return ef(i,Hg,1/e)}const yS=10*1e3,Xm=1024,bS=1152,TS=1536;let Ts=null,lu=null;class wo{constructor(e,t,r,s=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,Ts===null){const a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ts=a?parseInt(a[1]):0}if(lu===null){const n=navigator.userAgent.match(/Safari\/(\d+)/i);lu=n?parseInt(n[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){I.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){I.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){I.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const r=e.reduce((s,n)=>{const a=n.pts-s;return a<-4294967296?(t=!0,Nt(s,n.pts)):a>0?s:n.pts},e[0].pts);return t&&I.debug("PTS rollover detected"),r}remux(e,t,r,s,n,a,o,l){let d,u,c,h,f,m,p=n,g=n;const E=e.pid>-1,y=t.pid>-1,b=t.samples.length,S=e.samples.length>0,_=o&&b>0||b>1;if((!E||S)&&(!y||_)||this.ISGenerated||o){if(this.ISGenerated){var A,C,O,L;const z=this.videoTrackConfig;z&&(t.width!==z.width||t.height!==z.height||((A=t.pixelRatio)==null?void 0:A[0])!==((C=z.pixelRatio)==null?void 0:C[0])||((O=t.pixelRatio)==null?void 0:O[1])!==((L=z.pixelRatio)==null?void 0:L[1]))&&this.resetInitSegment()}else c=this.generateIS(e,t,n,a);const M=this.isVideoContiguous;let K=-1,U;if(_&&(K=_S(t.samples),!M&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,K>0){I.warn(`[mp4-remuxer]: Dropped ${K} out of ${b} video samples due to a missing keyframe`);const z=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(K),t.dropped+=K,g+=(t.samples[0].pts-z)/t.inputTimeScale,U=g}else K===-1&&(I.warn(`[mp4-remuxer]: No keyframe found out of ${b} video samples`),m=!1);if(this.ISGenerated){if(S&&_){const z=this.getVideoStartPts(t.samples),q=(Nt(e.samples[0].pts,z)-z)/t.inputTimeScale;p+=Math.max(0,q),g+=Math.max(0,-q)}if(S){if(e.samplerate||(I.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,p,this.isAudioContiguous,a,y||_||l===ee.AUDIO?g:void 0),_){const z=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(I.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,g,M,z)}}else _&&(d=this.remuxVideo(t,g,M,0));d&&(d.firstKeyFrame=K,d.independent=K!==-1,d.firstKeyFramePTS=U)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=Wg(r,n,this._initPTS,this._initDTS)),s.samples.length&&(h=Kg(s,n,this._initPTS))),{audio:u,video:d,initSegment:c,independent:m,text:h,id3:f}}generateIS(e,t,r,s){const n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS;let u=!d||s,c="audio/mp4",h,f,m;if(u&&(h=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(c="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}l.audio={id:"audio",container:c,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):w.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(m=e.inputTimeScale,!d||m!==d.timescale?h=f=n[0].pts-Math.round(m*r):u=!1)}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:w.initSegment([t]),metadata:{width:t.width,height:t.height}},u)if(m=t.inputTimeScale,!d||m!==d.timescale){const p=this.getVideoStartPts(a),g=Math.round(m*r);f=Math.min(f,Nt(a[0].dts,p)-g),h=Math.min(h,p-g)}else u=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(l).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:h,timescale:m},this._initDTS={baseTime:f,timescale:m}):h=m=void 0,{tracks:l,initPTS:h,timescale:m}}remuxVideo(e,t,r,s){const n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS;let u=this.nextAvcDts,c=8,h=this.videoSampleDuration,f,m,p=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,E=!1;if(!r||u===null){const G=t*n,$=a[0].pts-Nt(a[0].dts,a[0].pts);Ts&&u!==null&&Math.abs(G-$-u)<15e3?r=!0:u=G-$}const y=d.baseTime*n/d.timescale;for(let G=0;G<l;G++){const $=a[G];$.pts=Nt($.pts-y,u),$.dts=Nt($.dts-y,u),$.dts<a[G>0?G-1:G].dts&&(E=!0)}E&&a.sort(function(G,$){const te=G.dts-$.dts,re=G.pts-$.pts;return te||re}),f=a[0].dts,m=a[a.length-1].dts;const b=m-f,S=b?Math.round(b/(l-1)):h||e.inputTimeScale/30;if(r){const G=f-u,$=G>S,te=G<-1;if(($||te)&&($?I.warn(`AVC: ${In(G,!0)} ms (${G}dts) hole between fragments detected at ${t.toFixed(3)}`):I.warn(`AVC: ${In(-G,!0)} ms (${G}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!te||u>=a[0].pts||Ts)){f=u;const re=a[0].pts-G;if($)a[0].dts=f,a[0].pts=re;else for(let oe=0;oe<a.length&&!(a[oe].dts>re);oe++)a[oe].dts-=G,a[oe].pts-=G;I.log(`Video: Initial PTS/DTS adjusted: ${In(re,!0)}/${In(f,!0)}, delta: ${In(G,!0)} ms`)}}f=Math.max(0,f);let _=0,x=0,A=f;for(let G=0;G<l;G++){const $=a[G],te=$.units,re=te.length;let oe=0;for(let pe=0;pe<re;pe++)oe+=te[pe].data.length;x+=oe,_+=re,$.length=oe,$.dts<A?($.dts=A,A+=S/4|0||1):A=$.dts,p=Math.min($.pts,p),g=Math.max($.pts,g)}m=a[l-1].dts;const C=x+4*_+8;let O;try{O=new Uint8Array(C)}catch(G){this.observer.emit(v.ERROR,v.ERROR,{type:ie.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:G,bytes:C,reason:`fail allocating video mdat ${C}`});return}const L=new DataView(O.buffer);L.setUint32(0,C),O.set(w.types.mdat,4);let M=!1,K=Number.POSITIVE_INFINITY,U=Number.POSITIVE_INFINITY,z=Number.NEGATIVE_INFINITY,V=Number.NEGATIVE_INFINITY;for(let G=0;G<l;G++){const $=a[G],te=$.units;let re=0;for(let Re=0,$e=te.length;Re<$e;Re++){const yt=te[Re],Yi=yt.data,ps=yt.data.byteLength;L.setUint32(c,ps),c+=4,O.set(Yi,c),c+=ps,re+=4+ps}let oe;if(G<l-1)h=a[G+1].dts-$.dts,oe=a[G+1].pts-$.pts;else{const Re=this.config,$e=G>0?$.dts-a[G-1].dts:S;if(oe=G>0?$.pts-a[G-1].pts:S,Re.stretchShortVideoTrack&&this.nextAudioPts!==null){const yt=Math.floor(Re.maxBufferHole*n),Yi=(s?p+s*n:this.nextAudioPts)-$.pts;Yi>yt?(h=Yi-$e,h<0?h=$e:M=!0,I.log(`[mp4-remuxer]: It is approximately ${Yi/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=$e}else h=$e}const pe=Math.round($.pts-$.dts);K=Math.min(K,h),z=Math.max(z,h),U=Math.min(U,oe),V=Math.max(V,oe),o.push(new Qm($.key,h,re,pe))}if(o.length){if(Ts){if(Ts<70){const G=o[0].flags;G.dependsOn=2,G.isNonSync=0}}else if(lu&&V-U<z-K&&S/z<.025&&o[0].cts===0){I.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let G=f;for(let $=0,te=o.length;$<te;$++){const re=G+o[$].duration,oe=G+o[$].cts;if($<te-1){const pe=re+o[$+1].cts;o[$].duration=pe-oe}else o[$].duration=$?o[$-1].duration:S;o[$].cts=0,G=re}}}h=M||!h?S:h,this.nextAvcDts=u=m+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;const ne={data1:w.moof(e.sequenceNumber++,f,We({},e,{samples:o})),data2:O,startPTS:p/n,endPTS:(g+h)/n,startDTS:f/n,endDTS:u/n,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ne}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return bS;case"ac3":return TS;default:return Xm}}remuxAudio(e,t,r,s,n){const a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=this.getSamplesPerFrame(e),u=d*l,c=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=n!==void 0;let p=e.samples,g=h?0:8,E=this.nextAudioPts||-1;const y=t*a,b=c.baseTime*a/c.timescale;if(this.isAudioContiguous=r=r||p.length&&E>0&&(s&&Math.abs(y-E)<9e3||Math.abs(Nt(p[0].pts-b,y)-E)<20*u),p.forEach(function(q){q.pts=Nt(q.pts-b,y)}),!r||E<0){if(p=p.filter(q=>q.pts>=0),!p.length)return;n===0?E=0:s&&!m?E=Math.max(0,y):E=p[0].pts}if(e.segmentCodec==="aac"){const q=this.config.maxAudioFramesDrift;for(let ae=0,ne=E;ae<p.length;ae++){const G=p[ae],$=G.pts,te=$-ne,re=Math.abs(1e3*te/a);if(te<=-q*u&&m)ae===0&&(I.warn(`Audio frame @ ${($/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*te/a)} ms.`),this.nextAudioPts=E=ne=$);else if(te>=q*u&&re<yS&&m){let oe=Math.round(te/u);ne=$-oe*u,ne<0&&(oe--,ne+=u),ae===0&&(this.nextAudioPts=E=ne),I.warn(`[mp4-remuxer]: Injecting ${oe} audio frame @ ${(ne/a).toFixed(3)}s due to ${Math.round(1e3*te/a)} ms gap.`);for(let pe=0;pe<oe;pe++){const Re=Math.max(ne,0);let $e=zm.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);$e||(I.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),$e=G.unit.subarray()),p.splice(ae,0,{unit:$e,pts:Re}),ne+=u,ae++}}G.pts=ne,ne+=u}}let S=null,_=null,x,A=0,C=p.length;for(;C--;)A+=p[C].unit.byteLength;for(let q=0,ae=p.length;q<ae;q++){const ne=p[q],G=ne.unit;let $=ne.pts;if(_!==null){const re=f[q-1];re.duration=Math.round(($-_)/l)}else if(r&&e.segmentCodec==="aac"&&($=E),S=$,A>0){A+=g;try{x=new Uint8Array(A)}catch(re){this.observer.emit(v.ERROR,v.ERROR,{type:ie.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:re,bytes:A,reason:`fail allocating audio mdat ${A}`});return}h||(new DataView(x.buffer).setUint32(0,A),x.set(w.types.mdat,4))}else return;x.set(G,g);const te=G.byteLength;g+=te,f.push(new Qm(!0,d,te,0)),_=$}const O=f.length;if(!O)return;const L=f[f.length-1];this.nextAudioPts=E=_+l*L.duration;const M=h?new Uint8Array(0):w.moof(e.sequenceNumber++,S/l,We({},e,{samples:f}));e.samples=[];const K=S/a,U=E/a,V={data1:M,data2:x,startPTS:K,endPTS:U,startDTS:K,endDTS:U,type:"audio",hasAudio:!0,hasVideo:!1,nb:O};return this.isAudioContiguous=!0,V}remuxEmptyAudio(e,t,r,s){const n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,u=d.baseTime*9e4/d.timescale,c=(l!==null?l:s.startDTS*n)+u,h=s.endDTS*n+u,f=o*Xm,m=Math.ceil((h-c)/f),p=zm.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(I.warn("[mp4-remuxer]: remux empty Audio"),!p){I.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const g=[];for(let E=0;E<m;E++){const y=c+E*f;g.push({unit:p,pts:y,dts:y})}return e.samples=g,this.remuxAudio(e,t,r,!1)}}function Nt(i,e){let t;if(e===null)return i;for(e<i?t=-8589934592:t=8589934592;Math.abs(i-e)>4294967296;)i+=t;return i}function _S(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function Wg(i,e,t,r){const s=i.samples.length;if(!s)return;const n=i.inputTimeScale;for(let o=0;o<s;o++){const l=i.samples[o];l.pts=Nt(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=Nt(l.dts-r.baseTime*n/r.timescale,e*n)/n}const a=i.samples;return i.samples=[],{samples:a}}function Kg(i,e,t){const r=i.samples.length;if(!r)return;const s=i.inputTimeScale;for(let a=0;a<r;a++){const o=i.samples[a];o.pts=Nt(o.pts-t.baseTime*s/t.timescale,e*s)/s}i.samples.sort((a,o)=>a.pts-o.pts);const n=i.samples;return i.samples=[],{samples:n}}class Qm{constructor(e,t,r,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=s,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}class AS{constructor(){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}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(R1(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const s=this.initData=pg(e);s.audio&&(t=Zm(s.audio,ye.AUDIO)),s.video&&(r=Zm(s.video,ye.VIDEO));const n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:I.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,r,s,n,a){var o,l;let{initPTS:d,lastEndTime:u}=this;const c={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};Y(u)||(u=this.lastEndTime=n||0);const h=t.samples;if(!(h!=null&&h.length))return c;const f={initPTS:void 0,timescale:1};let m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(h),m=this.initData),!((l=m)!=null&&l.length))return I.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const p=C1(h,m),g=w1(m,h),E=g===null?n:g;(SS(d,E,n,p)||f.timescale!==d.timescale&&a)&&(f.initPTS=E-n,d&&d.timescale===1&&I.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});const y=e?E-d.baseTime/d.timescale:u,b=y+p;M1(m,h,d.baseTime/d.timescale),p>0?this.lastEndTime=b:(I.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const S=!!m.audio,_=!!m.video;let x="";S&&(x+="audio"),_&&(x+="video");const A={data1:h,startPTS:y,startDTS:y,endPTS:b,endDTS:b,type:x,hasAudio:S,hasVideo:_,nb:1,dropped:0};return c.audio=A.type==="audio"?A:void 0,c.video=A.type!=="audio"?A:void 0,c.initSegment=f,c.id3=Wg(r,n,d,d),s.samples.length&&(c.text=Kg(s,n,d)),c}}function SS(i,e,t,r){if(i===null)return!0;const s=Math.max(r,1),n=e-i.baseTime/i.timescale;return Math.abs(n-t)>s}function Zm(i,e){const t=i==null?void 0:i.codec;if(t&&t.length>4)return t;if(e===ye.AUDIO){if(t==="ec-3"||t==="ac-3"||t==="alac")return t;if(t==="fLaC"||t==="Opus")return zl(t,!1);const r="mp4a.40.5";return I.info(`Parsed audio codec "${t}" or audio object type not handled. Using "${r}"`),r}return I.warn(`Unhandled video codec "${t}"`),t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":"avc1.42e01e"}let Ui;try{Ui=self.performance.now.bind(self.performance)}catch{I.debug("Unable to use Performance API on this environment"),Ui=fn==null?void 0:fn.Date.now}const Co=[{demux:dS,remux:AS},{demux:nr,remux:wo},{demux:oS,remux:wo},{demux:gS,remux:wo}];Co.splice(2,0,{demux:uS,remux:wo});class Jm{constructor(e,t,r,s,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=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=e,this.typeSupported=t,this.config=r,this.vendor=s,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,s){const n=r.transmuxing;n.executeStart=Ui();let a=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);const{contiguous:d,discontinuity:u,trackSwitch:c,accurateTimeOffset:h,timeOffset:f,initSegmentChange:m}=s||o,{audioCodec:p,videoCodec:g,defaultInitPts:E,duration:y,initSegmentData:b}=l,S=xS(a,t);if(S&&S.method==="AES-128"){const C=this.getDecrypter();if(C.isSync()){let O=C.softwareDecrypt(a,S.key.buffer,S.iv.buffer);if(r.part>-1&&(O=C.flush()),!O)return n.executeEnd=Ui(),du(r);a=new Uint8Array(O)}else return this.decryptionPromise=C.webCryptoDecrypt(a,S.key.buffer,S.iv.buffer).then(O=>{const L=this.push(O,null,r);return this.decryptionPromise=null,L}),this.decryptionPromise}const _=this.needsProbing(u,c);if(_){const C=this.configureTransmuxer(a);if(C)return I.warn(`[transmuxer] ${C.message}`),this.observer.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:C,reason:C.message}),n.executeEnd=Ui(),du(r)}(u||c||m||_)&&this.resetInitSegment(b,p,g,y,t),(u||m||_)&&this.resetInitialTimestamp(E),d||this.resetContiguity();const x=this.transmux(a,S,f,h,r),A=this.currentTransmuxState;return A.contiguous=!0,A.discontinuity=!1,A.trackSwitch=!1,n.executeEnd=Ui(),x}flush(e){const t=e.transmuxing;t.executeStart=Ui();const{decrypter:r,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));const a=[],{timeOffset:o}=s;if(r){const c=r.flush();c&&a.push(this.push(c,null,e))}const{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=Ui(),[du(e)];const u=l.flush(o);return Do(u)?u.then(c=>(this.flushRemux(a,c,e),a)):(this.flushRemux(a,u,e),a)}flushRemux(e,t,r){const{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;I.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);const u=this.remuxer.remux(s,n,a,o,d,l,!0,this.id);e.push({remuxResult:u,chunkMeta:r}),r.transmuxing.executeEnd=Ui()}resetInitialTimestamp(e){const{demuxer:t,remuxer:r}=this;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,s,n){const{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,r,s),o.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,s,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,r,s,n):a=this.transmuxUnencrypted(e,r,s,n),a}transmuxUnencrypted(e,t,r,s){const{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,t,r,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,r,s,n){return this.demuxer.demuxSampleAes(e,t,r).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,r,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){const{config:t,observer:r,typeSupported:s,vendor:n}=this;let a;for(let h=0,f=Co.length;h<f;h++){var o;if((o=Co[h].demux)!=null&&o.probe(e)){a=Co[h];break}}if(!a)return new Error("Failed to find demuxer by probing fragment data");const l=this.demuxer,d=this.remuxer,u=a.remux,c=a.demux;(!d||!(d instanceof u))&&(this.remuxer=new u(r,t,s,n)),(!l||!(l instanceof c))&&(this.demuxer=new c(r,t,s),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new zh(this.config)),e}}function xS(i,e){let t=null;return i.byteLength>0&&(e==null?void 0:e.key)!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const du=i=>({remuxResult:{},chunkMeta:i});function Do(i){return"then"in i&&i.then instanceof Function}class kS{constructor(e,t,r,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=s,this.defaultInitPts=n||null}}class LS{constructor(e,t,r,s,n,a){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=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}}var Vg={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(l,d,u){this.fn=l,this.context=d,this.once=u||!1}function n(l,d,u,c,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new s(u,c||l,h),m=t?t+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new r:delete l._events[d]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],u,c;if(this._eventsCount===0)return d;for(c in u=this._events)e.call(u,c)&&d.push(t?c.slice(1):c);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(u)):d},o.prototype.listeners=function(d){var u=t?t+d:d,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var h=0,f=c.length,m=new Array(f);h<f;h++)m[h]=c[h].fn;return m},o.prototype.listenerCount=function(d){var u=t?t+d:d,c=this._events[u];return c?c.fn?1:c.length:0},o.prototype.emit=function(d,u,c,h,f,m){var p=t?t+d:d;if(!this._events[p])return!1;var g=this._events[p],E=arguments.length,y,b;if(g.fn){switch(g.once&&this.removeListener(d,g.fn,void 0,!0),E){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,u),!0;case 3:return g.fn.call(g.context,u,c),!0;case 4:return g.fn.call(g.context,u,c,h),!0;case 5:return g.fn.call(g.context,u,c,h,f),!0;case 6:return g.fn.call(g.context,u,c,h,f,m),!0}for(b=1,y=new Array(E-1);b<E;b++)y[b-1]=arguments[b];g.fn.apply(g.context,y)}else{var S=g.length,_;for(b=0;b<S;b++)switch(g[b].once&&this.removeListener(d,g[b].fn,void 0,!0),E){case 1:g[b].fn.call(g[b].context);break;case 2:g[b].fn.call(g[b].context,u);break;case 3:g[b].fn.call(g[b].context,u,c);break;case 4:g[b].fn.call(g[b].context,u,c,h);break;default:if(!y)for(_=1,y=new Array(E-1);_<E;_++)y[_-1]=arguments[_];g[b].fn.apply(g[b].context,y)}}return!0},o.prototype.on=function(d,u,c){return n(this,d,u,c,!1)},o.prototype.once=function(d,u,c){return n(this,d,u,c,!0)},o.prototype.removeListener=function(d,u,c,h){var f=t?t+d:d;if(!this._events[f])return this;if(!u)return a(this,f),this;var m=this._events[f];if(m.fn)m.fn===u&&(!h||m.once)&&(!c||m.context===c)&&a(this,f);else{for(var p=0,g=[],E=m.length;p<E;p++)(m[p].fn!==u||h&&!m[p].once||c&&m[p].context!==c)&&g.push(m[p]);g.length?this._events[f]=g.length===1?g[0]:g:a(this,f)}return this},o.prototype.removeAllListeners=function(d){var u;return d?(u=t?t+d:d,this._events[u]&&a(this,u)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,i.exports=o})(Vg);var IS=Vg.exports,tf=Q_(IS);class qg{constructor(e,t,r,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=s;const a=(d,u)=>{u=u||{},u.frag=this.frag,u.id=this.id,d===v.ERROR&&(this.error=u.error),this.hls.trigger(d,u)};this.observer=new tf,this.observer.on(v.FRAG_DECRYPTED,a),this.observer.on(v.ERROR,a);const o=ds(n.preferManagedMediaSource)||{isTypeSupported:()=>!1},l={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:o.isTypeSupported('audio/mp4; codecs="ac-3"')};if(this.useWorker&&typeof Worker<"u"&&(n.workerPath||YA())){try{n.workerPath?(I.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=zA(n.workerPath)):(I.log(`injecting Web Worker for "${t}"`),this.workerContext=jA()),this.onwmsg=c=>this.onWorkerMessage(c);const{worker:u}=this.workerContext;u.addEventListener("message",this.onwmsg),u.onerror=c=>{const h=new Error(`${c.message} (${c.filename}:${c.lineno})`);n.enableWorker=!1,I.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},u.postMessage({cmd:"init",typeSupported:l,vendor:"",id:t,config:JSON.stringify(n)})}catch(u){I.warn(`Error setting up "${t}" Web Worker, fallback to inline`,u),this.resetWorker(),this.error=null,this.transmuxer=new Jm(this.observer,l,n,"",t)}return}this.transmuxer=new Jm(this.observer,l,n,"",t)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,s,n,a,o,l,d,u){var c,h;d.transmuxing.start=self.performance.now();const{transmuxer:f}=this,m=a?a.start:n.start,p=n.decryptdata,g=this.frag,E=!(g&&n.cc===g.cc),y=!(g&&d.level===g.level),b=g?d.sn-g.sn:-1,S=this.part?d.part-this.part.index:-1,_=b===0&&d.id>1&&d.id===(g==null?void 0:g.stats.chunkCount),x=!y&&(b===1||b===0&&(S===1||_&&S<=0)),A=self.performance.now();(y||b||n.stats.parsing.start===0)&&(n.stats.parsing.start=A),a&&(S||!x)&&(a.stats.parsing.start=A);const C=!(g&&((c=n.initSegment)==null?void 0:c.url)===((h=g.initSegment)==null?void 0:h.url)),O=new LS(E,x,l,y,m,C);if(!x||E||C){I.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
29
+ Switching to level ${M} @ ${K|0} bps`),s.trigger(v.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(I.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new _A(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(v.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,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(e,t){const r=t.frag;if(!this.ignoreFragment(r)){if(!r.bitrateTest){var s;this.fragCurrent=r,this.partCurrent=(s=t.part)!=null?s:null}this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100)}}onLevelSwitching(e,t){this.clearTimer()}onError(e,t){if(!t.fatal)switch(t.details){case D.BUFFER_ADD_CODEC_ERROR:case D.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case D.FRAG_LOAD_TIMEOUT:{const r=t.frag,{fragCurrent:s,partCurrent:n}=this;if(r&&s&&r.sn===s.sn&&r.level===s.level){const a=performance.now(),o=n?n.stats:r.stats,l=a-o.loading.start,d=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&d>-1){const c=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(c,d),o.loaded)}else this.bwEstimator.sampleTTFB(l)}break}}}getTimeToLoadFrag(e,t,r,s){const n=e+r/t,a=s?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){const r=this.hls.config,{loading:s}=t.stats,n=s.end-s.start;Y(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)}onFragLoaded(e,{frag:t,part:r}){const s=r?r.stats:t.stats;if(t.type===ee.MAIN&&this.bwEstimator.sampleTTFB(s.loading.first-s.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const n=r?r.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+s.loaded,l=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){const n={stats:s,frag:t,part:r,id:t.type};this.onFragBuffered(v.FRAG_BUFFERED,n),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:r,part:s}=t,n=s!=null&&s.stats.loaded?s.stats:r.stats;if(n.aborted||this.ignoreFragment(r))return;const a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==ee.MAIN||e.sn==="initSegment"}clearTimer(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)}get firstAutoLevel(){const{maxAutoLevel:e,minAutoLevel:t}=this.hls,r=this.getBwEstimate(),s=this.hls.config.maxStarvationDelay,n=this.findBestLevel(r,t,e,0,s,1,1);if(n>-1)return n;const a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return I.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,r=this.bwEstimator.canEstimate(),s=this.lastLoadedFragLevel>-1;if(e!==-1&&(!r||!s||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const n=r&&s?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:r}=this,{maxAutoLevel:s,config:n,minAutoLevel:a}=r,o=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),d=this.getStarvationDelay();let u=n.abrBandWidthFactor,c=n.abrBandWidthUpFactor;if(d){const g=this.findBestLevel(l,a,s,d,0,u,c);if(g>=0)return g}let h=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!d){const g=this.bitrateTestDelay;g&&(h=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-g,I.info(`[abr] bitrate test took ${Math.round(1e3*g)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),u=c=1)}const f=this.findBestLevel(l,a,s,d,h,u,c);if(I.info(`[abr] ${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`),f>-1)return f;const m=r.levels[a],p=r.levels[r.loadLevel];return(m==null?void 0:m.bitrate)<(p==null?void 0:p.bitrate)?a:r.loadLevel}getStarvationDelay(){const e=this.hls,t=e.media;if(!t)return 1/0;const r=t&&t.playbackRate!==0?Math.abs(t.playbackRate):1,s=e.mainForwardBufferInfo;return(s?s.len:0)/r}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,r,s,n,a,o){var l;const d=s+n,u=this.lastLoadedFragLevel,c=u===-1?this.hls.firstLevel:u,{fragCurrent:h,partCurrent:f}=this,{levels:m,allAudioTracks:p,loadLevel:g,config:E}=this.hls;if(m.length===1)return 0;const y=m[c],b=!!(y!=null&&(l=y.details)!=null&&l.live),S=g===-1||u===-1;let _,x="SDR",A=(y==null?void 0:y.frameRate)||0;const{audioPreference:C,videoPreference:O}=E,L=this.audioTracksByGroup||(this.audioTracksByGroup=RA(p));if(S){if(this.firstSelection!==-1)return this.firstSelection;const V=this.codecTiers||(this.codecTiers=wA(m,L,t,r)),q=IA(V,x,e,C,O),{codecSet:ae,videoRanges:ne,minFramerate:G,minBitrate:$,preferHDR:te}=q;_=ae,x=te?ne[ne.length-1]:ne[0],A=G,e=Math.max(e,$),I.log(`[abr] picked start tier ${JSON.stringify(q)}`)}else _=y==null?void 0:y.codecSet,x=y==null?void 0:y.videoRange;const M=f?f.duration:h?h.duration:0,K=this.bwEstimator.getEstimateTTFB()/1e3,U=[];for(let V=r;V>=t;V--){var z;const q=m[V],ae=V>c;if(!q)continue;if(E.useMediaCapabilities&&!q.supportedResult&&!q.supportedPromise){const pe=navigator.mediaCapabilities;typeof(pe==null?void 0:pe.decodingInfo)=="function"&&AA(q,L,x,A,e,C)?(q.supportedPromise=SA(q,L,pe),q.supportedPromise.then(Re=>{if(!this.hls)return;q.supportedResult=Re;const $e=this.hls.levels,yt=$e.indexOf(q);Re.error?I.warn(`[abr] MediaCapabilities decodingInfo error: "${Re.error}" for level ${yt} ${JSON.stringify(Re)}`):Re.supported||(I.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${yt} ${JSON.stringify(Re)}`),yt>-1&&$e.length>1&&(I.log(`[abr] Removing unsupported level ${yt}`),this.hls.removeLevel(yt)))})):q.supportedResult=wg}if(_&&q.codecSet!==_||x&&q.videoRange!==x||ae&&A>q.frameRate||!ae&&A>0&&A<q.frameRate||q.supportedResult&&!((z=q.supportedResult.decodingInfoResults)!=null&&z[0].smooth)){U.push(V);continue}const ne=q.details,G=(f?ne==null?void 0:ne.partTarget:ne==null?void 0:ne.averagetargetduration)||M;let $;ae?$=o*e:$=a*e;const te=M&&s>=M*2&&n===0?m[V].averageBitrate:m[V].maxBitrate,re=this.getTimeToLoadFrag(K,$,te*G,ne===void 0);if($>=te&&(V===u||q.loadError===0&&q.fragmentError===0)&&(re<=K||!Y(re)||b&&!this.bitrateTestDelay||re<d)){const pe=this.forcedAutoLevel;return V!==g&&(pe===-1||pe!==g)&&(U.length&&I.trace(`[abr] Skipped level(s) ${U.join(",")} of ${r} max with CODECS and VIDEO-RANGE:"${m[U[0]].codecs}" ${m[U[0]].videoRange}; not compatible with "${y.codecs}" ${x}`),I.info(`[abr] switch candidate:${c}->${V} adjustedbw(${Math.round($)})-bitrate=${Math.round($-te)} ttfb:${K.toFixed(1)} avgDuration:${G.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${re.toFixed(1)} firstSelection:${S} codecSet:${_} videoRange:${x} hls.loadLevel:${g}`)),S&&(this.firstSelection=V),V}}return-1}set nextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:r}=this.hls,s=Math.min(Math.max(e,r),t);this._nextAutoLevel!==s&&(this.nextAutoLevelKey="",this._nextAutoLevel=s)}}class PA{constructor(){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(e){return this._tickInterval?!1:(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,e),!0)}clearInterval(){return this._tickInterval?(self.clearInterval(this._tickInterval),this._tickInterval=null,!0):!1}clearNextTick(){return this._tickTimer?(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0):!1}tick(){this._tickCallCount++,this._tickCallCount===1&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)}tickImmediate(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)}doTick(){}}var nt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class OA{constructor(e){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=e,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(v.BUFFER_APPENDED,this.onBufferAppended,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(v.BUFFER_APPENDED,this.onBufferAppended,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const r=this.activePartLists[t];if(r)for(let s=r.length;s--;){const n=r[s];if(!n)break;const a=n.end;if(n.start<=e&&a!==null&&e<=a)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:r}=this,s=Object.keys(r);for(let n=s.length;n--;){const a=r[s[n]];if((a==null?void 0:a.body.type)===t&&a.buffered){const o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,r,s){this.timeRanges&&(this.timeRanges[e]=t);const n=(s==null?void 0:s.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===r&&this.removeFragment(o.body);return}const l=o.range[e];l&&l.time.some(d=>{const u=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return u&&this.removeFragment(o.body),u})})}detectPartialFragments(e){const t=this.timeRanges,{frag:r,part:s}=e;if(!t||r.sn==="initSegment")return;const n=ys(r),a=this.fragments[n];if(!a||a.buffered&&r.gap)return;const o=!r.relurl;Object.keys(t).forEach(l=>{const d=r.elementaryStreams[l];if(!d)return;const u=t[l],c=o||d.partial===!0;a.range[l]=this.getBufferedTimes(r,s,c,u)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=r.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),eo(a)||this.removeParts(r.sn-1,r.type)):this.removeFragment(a.body)}removeParts(e,t){const r=this.activePartLists[t];r&&(this.activePartLists[t]=r.filter(s=>s.fragment.sn>=e))}fragBuffered(e,t){const r=ys(e);let s=this.fragments[r];!s&&t&&(s=this.fragments[r]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),s&&(s.loaded=null,s.buffered=!0)}getBufferedTimes(e,t,r,s){const n={time:[],partial:r},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let u=0;u<s.length;u++){const c=s.start(u)-this.bufferPadding,h=s.end(u)+this.bufferPadding;if(d>=c&&l<=h){n.time.push({startPTS:Math.max(a,s.start(u)),endPTS:Math.min(o,s.end(u))});break}else if(a<h&&o>c){const f=Math.max(a,s.start(u)),m=Math.min(o,s.end(u));m>f&&(n.partial=!0,n.time.push({startPTS:f,endPTS:m}))}else if(o<=c)break}return n}getPartialFragment(e){let t=null,r,s,n,a=0;const{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{const u=l[d];u&&eo(u)&&(s=u.body.start-o,n=u.body.end+o,e>=s&&e<=n&&(r=Math.min(e-s,n-e),a<=r&&(t=u.body,a=r)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||eo(t))}getState(e){const t=ys(e),r=this.fragments[t];return r?r.buffered?eo(r)?nt.PARTIAL:nt.OK:nt.APPENDING:nt.NOT_LOADED}isTimeBuffered(e,t,r){let s,n;for(let a=0;a<r.length;a++){if(s=r.start(a)-this.bufferPadding,n=r.end(a)+this.bufferPadding,e>=s&&t<=n)return!0;if(t<=s)return!1}return!1}onFragLoaded(e,t){const{frag:r,part:s}=t;if(r.sn==="initSegment"||r.bitrateTest)return;const n=s?null:t,a=ys(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:r,part:s,timeRanges:n}=t;if(r.sn==="initSegment")return;const a=r.type;if(s){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(s)}this.timeRanges=n,Object.keys(n).forEach(o=>{const l=n[o];this.detectEvictedFragments(o,l,a,s)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=ys(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,r,s,n){s&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o)return;const l=o.body;l.type!==r||s&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){const t=ys(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const r=this.activePartLists[e.type];if(r){const s=e.sn;this.activePartLists[e.type]=r.filter(n=>n.fragment.sn!==s)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function eo(i){var e,t,r;return i.buffered&&(i.body.gap||((e=i.range.video)==null?void 0:e.partial)||((t=i.range.audio)==null?void 0:t.partial)||((r=i.range.audiovideo)==null?void 0:r.partial))}function ys(i){return`${i.type}_${i.level}_${i.sn}`}const NA={length:0,start:()=>0,end:()=>0};class Le{static isBuffered(e,t){try{if(e){const r=Le.getBuffered(e);for(let s=0;s<r.length;s++)if(t>=r.start(s)&&t<=r.end(s))return!0}}catch{}return!1}static bufferInfo(e,t,r){try{if(e){const s=Le.getBuffered(e),n=[];let a;for(a=0;a<s.length;a++)n.push({start:s.start(a),end:s.end(a)});return this.bufferedInfo(n,t,r)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,r){t=Math.max(0,t),e.sort(function(d,u){const c=d.start-u.start;return c||u.end-d.end});let s=[];if(r)for(let d=0;d<e.length;d++){const u=s.length;if(u){const c=s[u-1].end;e[d].start-c<r?e[d].end>c&&(s[u-1].end=e[d].end):s.push(e[d])}else s.push(e[d])}else s=e;let n=0,a,o=t,l=t;for(let d=0;d<s.length;d++){const u=s[d].start,c=s[d].end;if(t+r>=u&&t<c)o=u,l=c,n=l-t;else if(t+r<u){a=u;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return I.log("failed to get media.buffered",t),NA}}}class Xh{constructor(e,t,r,s=0,n=-1,a=!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=to(),this.buffering={audio:to(),video:to(),audiovideo:to()},this.level=e,this.sn=t,this.id=r,this.size=s,this.part=n,this.partial=a}}function to(){return{start:0,executeStart:0,executeEnd:0,end:0}}function Co(i,e){for(let r=0,s=i.length;r<s;r++){var t;if(((t=i[r])==null?void 0:t.cc)===e)return i[r]}return null}function FA(i,e,t){return!!(e&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function UA(i,e){const t=i.fragments,r=e.fragments;if(!r.length||!t.length){I.log("No fragments to align");return}const s=Co(t,r[0].cc);if(!s||s&&!s.startPTS){I.log("No frag in previous level to align on");return}return s}function qm(i,e){if(i){const t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function Cg(i,e){const t=e.fragments;for(let r=0,s=t.length;r<s;r++)qm(t[r],i);e.fragmentHint&&qm(e.fragmentHint,i),e.alignedSliding=!0}function $A(i,e,t){e&&(BA(i,t,e),!t.alignedSliding&&e&&id(t,e),!t.alignedSliding&&e&&!t.skippedSegments&&kg(e,t))}function BA(i,e,t){if(FA(i,t,e)){const r=UA(t,e);r&&Y(r.start)&&(I.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),Cg(r.start,e))}}function id(i,e){if(!i.hasProgramDateTime||!e.hasProgramDateTime)return;const t=i.fragments,r=e.fragments;if(!t.length||!r.length)return;let s,n;const a=Math.min(e.endCC,i.endCC);e.startCC<a&&i.startCC<a&&(s=Co(r,a),n=Co(t,a)),(!s||!n)&&(s=r[Math.floor(r.length/2)],n=Co(t,s.cc)||t[Math.floor(t.length/2)]);const o=s.programDateTime,l=n.programDateTime;if(!o||!l)return;const d=(l-o)/1e3-(n.start-s.start);Cg(d,i)}const Ym=Math.pow(2,17);class GA{constructor(e){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=e}destroy(){this.loader&&(this.loader.destroy(),this.loader=null)}abort(){this.loader&&this.loader.abort()}load(e,t){const r=e.url;if(!r)return Promise.reject(new Fi({type:ie.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${r?"part list":"url"}`),networkDetails:null}));this.abort();const s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(zm(e));return}else e.gap=!1;const d=this.loader=e.loader=n?new n(s):new a(s),u=jm(e),c=Wm(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:Ym};e.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d);let E=f.data;p.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(E.slice(0,16)),E=E.slice(16)),o({frag:e,part:null,payload:E,networkDetails:g})},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new Fi({type:ie.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:dt({url:r,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{this.resetLoader(e,d),l(new Fi({type:ie.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new Fi({type:ie.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))},onProgress:(f,m,p,g)=>{t&&t({frag:e,part:null,payload:p,networkDetails:g})}})})}loadPart(e,t,r){this.abort();const s=this.config,n=s.fLoader,a=s.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(zm(e,t));return}const d=this.loader=e.loader=n?new n(s):new a(s),u=jm(e,t),c=Wm(s.fragLoadPolicy.default),h={loadPolicy:c,timeout:c.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:Ym};t.stats=d.stats,d.load(u,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);const E={frag:e,part:t,payload:f.data,networkDetails:g};r(E),o(E)},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new Fi({type:ie.NETWORK_ERROR,details:D.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:dt({url:u.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new Fi({type:ie.NETWORK_ERROR,details:D.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new Fi({type:ie.NETWORK_ERROR,details:D.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))}})})}updateStatsFromPart(e,t){const r=e.stats,s=t.stats,n=s.total;if(r.loaded+=s.loaded,n){const l=Math.round(e.duration/t.duration),d=Math.min(Math.round(r.loaded/n),l),c=(l-d)*Math.round(r.loaded/d);r.total=r.loaded+c}else r.total=Math.max(r.loaded,r.total);const a=r.loading,o=s.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function jm(i,e=null){const t=e||i,r={frag:i,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},s=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(Y(s)&&Y(n)){var a;let o=s,l=n;if(i.sn==="initSegment"&&((a=i.decryptdata)==null?void 0:a.method)==="AES-128"){const d=n-s;d%16&&(l=n+(16-d%16)),s!==0&&(r.resetIV=!0,o=s-16)}r.rangeStart=o,r.rangeEnd=l}return r}function zm(i,e){const t=new Error(`GAP ${i.gap?"tag":"attribute"} found`),r={type:ie.MEDIA_ERROR,details:D.FRAG_GAP,fatal:!1,frag:i,error:t,networkDetails:null};return e&&(r.part=e),(e||i).stats.aborted=!0,new Fi(r)}class Fi extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class HA{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class WA{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function KA(i){const e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?is(i,0,e-t):i}class VA{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_(e){const t=new DataView(e),r=new Uint32Array(4);for(let s=0;s<4;s++)r[s]=t.getUint32(s*4);return r}initTable(){const e=this.sBox,t=this.invSBox,r=this.subMix,s=r[0],n=r[1],a=r[2],o=r[3],l=this.invSubMix,d=l[0],u=l[1],c=l[2],h=l[3],f=new Uint32Array(256);let m=0,p=0,g=0;for(g=0;g<256;g++)g<128?f[g]=g<<1:f[g]=g<<1^283;for(g=0;g<256;g++){let E=p^p<<1^p<<2^p<<3^p<<4;E=E>>>8^E&255^99,e[m]=E,t[E]=m;const y=f[m],b=f[y],S=f[b];let _=f[E]*257^E*16843008;s[m]=_<<24|_>>>8,n[m]=_<<16|_>>>16,a[m]=_<<8|_>>>24,o[m]=_,_=S*16843009^b*65537^y*257^m*16843008,d[E]=_<<24|_>>>8,u[E]=_<<16|_>>>16,c[E]=_<<8|_>>>24,h[E]=_,m?(m=y^f[f[f[S^y]]],p^=f[f[p]]):m=p=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let r=!0,s=0;for(;s<t.length&&r;)r=t[s]===this.key[s],s++;if(r)return;this.key=t;const n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);const a=this.ksRows=(n+6+1)*4;let o,l;const d=this.keySchedule=new Uint32Array(a),u=this.invKeySchedule=new Uint32Array(a),c=this.sBox,h=this.rcon,f=this.invSubMix,m=f[0],p=f[1],g=f[2],E=f[3];let y,b;for(o=0;o<a;o++){if(o<n){y=d[o]=t[o];continue}b=y,o%n===0?(b=b<<8|b>>>24,b=c[b>>>24]<<24|c[b>>>16&255]<<16|c[b>>>8&255]<<8|c[b&255],b^=h[o/n|0]<<24):n>6&&o%n===4&&(b=c[b>>>24]<<24|c[b>>>16&255]<<16|c[b>>>8&255]<<8|c[b&255]),d[o]=y=(d[o-n]^b)>>>0}for(l=0;l<a;l++)o=a-l,l&3?b=d[o]:b=d[o-4],l<4||o<=4?u[l]=b:u[l]=m[c[b>>>24]]^p[c[b>>>16&255]]^g[c[b>>>8&255]]^E[c[b&255]],u[l]=u[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,r){const s=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],u=o[2],c=o[3],h=this.uint8ArrayToUint32Array_(r);let f=h[0],m=h[1],p=h[2],g=h[3];const E=new Int32Array(e),y=new Int32Array(E.length);let b,S,_,x,A,C,O,L,M,K,U,z,V,q;const ae=this.networkToHostOrderSwap;for(;t<E.length;){for(M=ae(E[t]),K=ae(E[t+1]),U=ae(E[t+2]),z=ae(E[t+3]),A=M^n[0],C=z^n[1],O=U^n[2],L=K^n[3],V=4,q=1;q<s;q++)b=l[A>>>24]^d[C>>16&255]^u[O>>8&255]^c[L&255]^n[V],S=l[C>>>24]^d[O>>16&255]^u[L>>8&255]^c[A&255]^n[V+1],_=l[O>>>24]^d[L>>16&255]^u[A>>8&255]^c[C&255]^n[V+2],x=l[L>>>24]^d[A>>16&255]^u[C>>8&255]^c[O&255]^n[V+3],A=b,C=S,O=_,L=x,V=V+4;b=a[A>>>24]<<24^a[C>>16&255]<<16^a[O>>8&255]<<8^a[L&255]^n[V],S=a[C>>>24]<<24^a[O>>16&255]<<16^a[L>>8&255]<<8^a[A&255]^n[V+1],_=a[O>>>24]<<24^a[L>>16&255]<<16^a[A>>8&255]<<8^a[C&255]^n[V+2],x=a[L>>>24]<<24^a[A>>16&255]<<16^a[C>>8&255]<<8^a[O&255]^n[V+3],y[t]=ae(b^f),y[t+1]=ae(x^m),y[t+2]=ae(_^p),y[t+3]=ae(S^g),f=M,m=K,p=U,g=z,t=t+4}return y.buffer}}const qA=16;class Qh{constructor(e,{removePKCS7Padding:t=!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.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const r=self.crypto;r&&(this.subtle=r.subtle||r.webkitSubtle)}catch{}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:e,remainderData:t}=this;if(!e||t)return this.reset(),null;const r=new Uint8Array(e);return this.reset(),this.removePKCS7Padding?KA(r):r}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,r){return this.useSoftware?new Promise((s,n)=>{this.softwareDecrypt(new Uint8Array(e),t,r);const a=this.flush();a?s(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,r)}softwareDecrypt(e,t,r){const{currentIV:s,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=Ut(a,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;s&&(r=s);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new VA),l.expandKey(t);const d=n;return this.currentResult=l.decrypt(o.buffer,0,r),this.currentIV=is(o,-16).buffer,d||null}webCryptoDecrypt(e,t,r){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,r));this.key=t,this.fastAesKey=new WA(this.subtle,t)}return this.fastAesKey.expandKey().then(s=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new HA(this.subtle,new Uint8Array(r)).decrypt(e.buffer,s)):Promise.reject(new Error("web crypto not initialized"))).catch(s=>(I.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${s.name}: ${s.message}`),this.onWebCryptoError(e,t,r)))}onWebCryptoError(e,t,r){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,r);const s=this.flush();if(s)return s.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;const r=e.length-e.length%qA;return r!==e.length&&(t=is(e,0,r),this.remainderData=is(e,r)),t}logOnce(e){this.logEnabled&&(I.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const YA={toString:function(i){let e="";const t=i.length;for(let r=0;r<t;r++)e+=`[${i.start(r).toFixed(3)}-${i.end(r).toFixed(3)}]`;return e}},N={STOPPED:"STOPPED",IDLE:"IDLE",KEY_LOADING:"KEY_LOADING",FRAG_LOADING:"FRAG_LOADING",FRAG_LOADING_WAITING_RETRY:"FRAG_LOADING_WAITING_RETRY",WAITING_TRACK:"WAITING_TRACK",PARSING:"PARSING",PARSED:"PARSED",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"};class Zh extends PA{constructor(e,t,r,s,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=N.STOPPED,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.loadedmetadata=!1,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.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=s,this.log=I.log.bind(I,`${s}:`),this.warn=I.warn.bind(I,`${s}:`),this.hls=e,this.fragmentLoader=new GA(e.config),this.keyLoader=r,this.fragmentTracker=t,this.config=e.config,this.decrypter=new Qh(e.config),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){this.fragmentLoader.abort(),this.keyLoader.abort(this.playlistType);const e=this.fragCurrent;e!=null&&e.loader&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=N.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;const r=t.partList;if(r!=null&&r.length){const n=r[r.length-1];return Le.isBuffered(this.media,n.start+n.duration/2)}const s=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(s)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}}onMediaAttached(e,t){const r=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),r.addEventListener("seeking",this.onvseeking),r.addEventListener("ended",this.onvended);const s=this.config;this.levels&&s.autoStartLoad&&this.state===N.STOPPED&&this.startLoad(s.startPosition)}onMediaDetaching(){const e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:r,mediaBuffer:s,state:n}=this,a=r?r.currentTime:0,o=Le.bufferInfo(s||r,a,e.maxBufferHole);if(this.log(`media seeking to ${Y(a)?a.toFixed(3):a}, state: ${n}`),this.state===N.ENDED)this.resetLoadingState();else if(t){const l=e.maxFragLookUpTolerance,d=t.start-l,u=t.start+t.duration+l;if(!o.len||u<o.start||d>o.end){const c=a>u;(a<d||c)&&(c&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}r&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=N.STOPPED,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(e,t,r){this._loadFragForPlayback(e,t,r)}_loadFragForPlayback(e,t,r){const s=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,r,s).then(n=>{if(!n)return;const a=this.state;if(this.fragContextChanged(e)){(a===N.FRAG_LOADING||!this.fragCurrent&&a===N.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=N.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(v.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(`Frag error: ${(n==null?void 0:n.message)||n}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:r}=this;if(r.getState(e)===nt.APPENDING){const n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),l=this.backtrackFragment;((l?e.sn-l.sn:0)===1||this.reduceMaxBufferLength(o,e.duration))&&r.removeFragment(e)}else((t=this.mediaBuffer)==null?void 0:t.buffered.length)===0?r.removeAllFragments():r.hasParts(e.type)&&(r.detectPartialFragments({frag:e,part:null,stats:e.stats,id:e.type}),r.getState(e)===nt.PARTIAL&&r.removeFragment(e))}checkLiveUpdate(e){if(e.updated&&!e.live){const t=e.fragments[e.fragments.length-1];this.fragmentTracker.detectPartialFragments({frag:t,part:null,stats:t.stats,id:t.type})}e.fragments[0]||(e.deltaUpdateFailed=!0)}flushMainBuffer(e,t,r=null){if(!(e-t))return;const s={startOffset:e,endOffset:t,type:r};this.hls.trigger(v.BUFFER_FLUSHING,s)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(r=>{if(!r||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return r}).then(r=>{const{hls:s}=this,{payload:n}=r,a=e.decryptdata;if(n&&n.byteLength>0&&a!=null&&a.key&&a.iv&&a.method==="AES-128"){const o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw s.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{const d=self.performance.now();return s.trigger(v.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),r.payload=l,this.completeInitSegmentLoad(r)})}return this.completeInitSegmentLoad(r)}).catch(r=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(r),this.resetFragmentLoading(e))})}completeInitSegmentLoad(e){const{levels:t}=this;if(!t)throw new Error("init load aborted, missing levels");const r=e.frag.stats;this.state=N.IDLE,e.frag.data=new Uint8Array(e.payload),r.parsing.start=r.buffering.start=self.performance.now(),r.parsing.end=r.buffering.end=self.performance.now(),this.tick()}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var r,s,n,a;const o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===ee.MAIN?"level":"track"} ${e.level} (frag:[${((r=e.startPTS)!=null?r:NaN).toFixed(3)}-${((s=e.endPTS)!=null?s:NaN).toFixed(3)}] > buffer:${o?YA.toString(Le.getBuffered(o)):"(detached)"})`),e.sn!=="initSegment"){var l;if(e.type!==ee.SUBTITLE){const u=e.elementaryStreams;if(!Object.keys(u).some(c=>!!u[c])){this.state=N.IDLE;return}}const d=(l=this.levels)==null?void 0:l[e.level];d!=null&&d.fragmentError&&(this.log(`Resetting level fragment error count of ${d.fragmentError} on frag buffered`),d.fragmentError=0)}this.state=N.IDLE,o&&(!this.loadedmetadata&&e.type==ee.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:r,part:s,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new Xh(r.level,r.sn,r.stats.chunkCount+1,0,s?s.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,r=null,s){var n;const a=t==null?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=N.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(u=>{if(!this.fragContextChanged(u.frag))return this.hls.trigger(v.KEY_LOADED,u),this.state===N.KEY_LOADING&&(this.state=N.IDLE),u}),this.hls.trigger(v.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),r=Math.max(e.start,r||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){const u=a.partList;if(u&&s){r>e.end&&a.fragmentHint&&(e=a.fragmentHint);const c=this.getNextPart(u,e,r);if(c>-1){const h=u[c];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${c}-${u.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=N.FRAG_LOADING;let f;return o?f=o.then(m=>!m||this.fragContextChanged(m.frag)?null:this.doFragPartsLoad(e,h,t,s)).catch(m=>this.handleFragLoadError(m)):f=this.doFragPartsLoad(e,h,t,s).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(v.FRAG_LOADING,{frag:e,part:h,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(u,r))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(r.toFixed(3))}`),Y(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=N.FRAG_LOADING;const l=this.config.progressive;let d;return l&&o?d=o.then(u=>!u||this.fragContextChanged(u==null?void 0:u.frag)?null:this.fragmentLoader.load(e,s)).catch(u=>this.handleFragLoadError(u)):d=Promise.all([this.fragmentLoader.load(e,l?s:void 0),o]).then(([u])=>(!l&&u&&s&&s(u),u)).catch(u=>this.handleFragLoadError(u)),this.hls.trigger(v.FRAG_LOADING,{frag:e,targetBufferTime:r}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,r,s){return new Promise((n,a)=>{var o;const l=[],d=(o=r.details)==null?void 0:o.partList,u=c=>{this.fragmentLoader.loadPart(e,c,s).then(h=>{l[c.index]=h;const f=h.part;this.hls.trigger(v.FRAG_LOADED,h);const m=Gm(r,e.sn,c.index+1)||Lg(d,e.sn,c.index+1);if(m)u(m);else return n({frag:e,part:f,partsLoaded:l})}).catch(a)};u(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===D.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(v.ERROR,t)}else this.hls.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==N.PARSING){!this.fragCurrent&&this.state!==N.STOPPED&&this.state!==N.ERROR&&(this.state=N.IDLE);return}const{frag:r,part:s,level:n}=t,a=self.performance.now();r.stats.parsing.end=a,s&&(s.stats.parsing.end=a),this.updateLevelTiming(r,s,n,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:r}=this,{level:s,sn:n,part:a}=e;if(!(t!=null&&t[s]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${s}. The current chunk will not be buffered.`),null;const o=t[s],l=a>-1?Gm(o,n,a):null,d=l?l.fragment:pA(o,n,r);return d?(r&&r!==d&&(d.stats=r.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,r,s,n){var a;if(!e||this.state!==N.PARSING)return;const{data1:o,data2:l}=e;let d=o;if(o&&l&&(d=Ut(o,l)),!((a=d)!=null&&a.length))return;const u={type:e.type,frag:t,part:r,chunkMeta:s,parent:t.type,data:d};if(this.hls.trigger(v.BUFFER_APPENDING,u),e.dropped&&e.independent&&!r){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Le.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const r=t.currentTime,s=Le.bufferInfo(t,r,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,s.end-a),r+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){const r=this.getLoadPosition();return Y(r)?this.getFwdBufferInfoAtPos(e,r,t):null}getFwdBufferInfoAtPos(e,t,r){const{config:{maxBufferHole:s}}=this,n=Le.bufferInfo(e,t,s);if(n.len===0&&n.nextStart!==void 0){const a=this.fragmentTracker.getBufferedFrag(t,r);if(a&&n.nextStart<a.end)return Le.bufferInfo(e,t,Math.max(n.nextStart,s))}return n}getMaxBufferLength(e){const{config:t}=this;let r;return e?r=Math.max(8*t.maxBufferSize/e,t.maxBufferLength):r=t.maxBufferLength,Math.min(r,t.maxMaxBufferLength)}reduceMaxBufferLength(e,t){const r=this.config,s=Math.max(Math.min(e-t,r.maxBufferLength),t),n=Math.max(e-t*3,r.maxMaxBufferLength/2,s);return n>=s?(r.maxMaxBufferLength=n,this.warn(`Reduce max buffer length to ${n}s`),!0):!1}getAppendedFrag(e,t=ee.MAIN){const r=this.fragmentTracker.getAppendedFrag(e,ee.MAIN);return r&&"fragment"in r?r.fragment:r}getNextFragment(e,t){const r=t.fragments,s=r.length;if(!s)return null;const{config:n}=this,a=r[0].start;let o;if(t.live){const l=n.initialLiveManifestSize;if(s<l)return this.warn(`Not enough fragments to start playback (have: ${s}, need: ${l})`),null;(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a)&&(o=this.getInitialLiveFragment(t,r),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=r[0]);if(!o){const l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){const r=this.fragmentTracker.getState(e);return(r===nt.OK||r===nt.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,r,s,n){const a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&r.nextStart){const l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,s);if(l!==null&&r.len+l.len>=n)return this.log(`buffer full after gaps in "${s}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,r){let s=-1,n=!1,a=!0;for(let o=0,l=e.length;o<l;o++){const d=e[o];if(a=a&&!d.independent,s>-1&&r<d.start)break;const u=d.loaded;u?s=-1:(n||d.independent||a)&&d.fragment===t&&(s=o),n=u}return s}loadedEndOfParts(e,t){const r=e[e.length-1];return r&&t>r.start&&r.loaded}getInitialLiveFragment(e,t){const r=this.fragPrevious;let s=null;if(r){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${r.programDateTime}`),s=vA(t,r.endProgramDateTime,this.config.maxFragLookUpTolerance)),!s){const n=r.sn+1;if(n>=e.startSN&&n<=e.endSN){const a=t[n-e.startSN];r.cc===a.cc&&(s=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${s.sn}`))}s||(s=bA(t,r.cc),s&&this.log(`Live playlist, switching playlist, load frag with same CC: ${s.sn}`))}}else{const n=this.hls.liveSyncPosition;n!==null&&(s=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return s}getFragmentAtPosition(e,t,r){const{config:s}=this;let{fragPrevious:n}=this,{fragments:a,endSN:o}=r;const{fragmentHint:l}=r,{maxFragLookUpTolerance:d}=s,u=r.partList,c=!!(s.lowLatencyMode&&u!=null&&u.length&&l);c&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let h;if(e<t){const f=e>t-d?0:d;h=td(n,a,e,f)}else h=a[a.length-1];if(h){const f=h.sn-r.startSN,m=this.fragmentTracker.getState(h);if((m===nt.OK||m===nt.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!c||u[0].fragment.sn>h.sn)&&n&&h.level===n.level){const g=a[f+1];h.sn<o&&this.fragmentTracker.getState(g)!==nt.OK?h=g:h=null}}return h}synchronizeToLiveEdge(e){const{config:t,media:r}=this;if(!r)return;const s=this.hls.liveSyncPosition,n=r.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(s!==null&&r.duration>s&&(n<s||!l)){const d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&r.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=s),r.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${s.toFixed(3)}`),r.currentTime=s))}}alignPlaylists(e,t,r){const s=e.fragments.length;if(!s)return this.warn("No fragments in live playlist"),0;const n=e.fragments[0].start,a=!t,o=e.alignedSliding&&Y(n);if(a||!o&&!n){const{fragPrevious:l}=this;$A(l,r,e);const d=e.fragments[0].start;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${l?l.sn:"na"} fragments: ${s}`),d}return n}waitForCdnTuneIn(e){return e.live&&e.canBlockReload&&e.partTarget&&e.tuneInGoal>Math.max(e.partHoldBack,e.partTarget*3)}setStartPosition(e,t){let r=this.startPosition;if(r<t&&(r=-1),r===-1||this.lastCurrentTime===-1){const s=this.startTimeOffset!==null,n=s?this.startTimeOffset:e.startTimeOffset;n!==null&&Y(n)?(r=t+n,n<0&&(r+=e.totalduration),r=Math.min(Math.max(t,r),t+e.totalduration),this.log(`Start time offset ${n} found in ${s?"multivariant":"media"} playlist, adjust startPosition to ${r}`),this.startPosition=r):e.live?r=this.hls.liveSyncPosition||t:this.startPosition=r=0,this.lastCurrentTime=r}this.nextLoadPosition=r}getLoadPosition(){const{media:e}=this;let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==N.FRAG_LOADING_WAITING_RETRY)&&(this.state=N.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const u=this.getCurrentContext(t.chunkMeta);u&&(t.frag=u.frag)}const r=t.frag;if(!r||r.type!==e||!this.levels)return;if(this.fragContextChanged(r)){var s;this.warn(`Frag load error must match current frag to retry ${r.url} > ${(s=this.fragCurrent)==null?void 0:s.url}`);return}const n=t.details===D.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(r,!0);const a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===ht.RetryRequest&&d){this.resetStartWhenNotLoaded(this.levelLastLoaded);const u=jh(d,l);this.warn(`Fragment ${r.sn} of ${e} ${r.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${u}ms`),a.resolved=!0,this.retryDate=self.performance.now()+u,this.state=N.FRAG_LOADING_WAITING_RETRY}else if(d&&a)if(this.resetFragmentErrors(e),l<d.maxNumRetry)!n&&o!==ht.RemoveAlternatePermanently&&(a.resolved=!0);else{I.warn(`${t.details} reached or exceeded max retry (${l})`);return}else(a==null?void 0:a.action)===ht.SendAlternateToPenaltyBox?this.state=N.WAITING_LEVEL:this.state=N.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===N.PARSING||this.state===N.PARSED){const t=e.frag,r=e.parent,s=this.getFwdBufferInfo(this.mediaBuffer,r),n=s&&s.len>.5;n&&this.reduceMaxBufferLength(s.len,(t==null?void 0:t.duration)||10);const a=!n;return a&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${r} buffer`),t&&(this.fragmentTracker.removeFragment(t),this.nextLoadPosition=t.start),this.resetLoadingState(),a}return!1}resetFragmentErrors(e){e===ee.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==N.STOPPED&&(this.state=N.IDLE)}afterBufferFlushed(e,t,r){if(!e)return;const s=Le.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,s,r),this.state===N.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=N.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=e?e.details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,r,s){var n;const a=r.details;if(!a){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((l,d)=>{const u=e.elementaryStreams[d];if(u){const c=u.endPTS-u.startPTS;if(c<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${c})`),l||!1;const h=s?0:xg(a,e,u.startPTS,u.endPTS,u.startDTS,u.endDTS);return this.hls.trigger(v.LEVEL_PTS_UPDATED,{details:a,level:r,drift:h,type:d,frag:e,start:u.startPTS,end:u.endPTS}),!0}return l},!1)&&((n=this.transmuxer)==null?void 0:n.error)===null){const l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(r.fragmentError===0&&(r.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${r.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=N.PARSED,this.hls.trigger(v.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}class Dg{constructor(){this.chunks=[],this.dataLength=0}push(e){this.chunks.push(e),this.dataLength+=e.length}flush(){const{chunks:e,dataLength:t}=this;let r;if(e.length)e.length===1?r=e[0]:r=jA(e,t);else return new Uint8Array(0);return this.reset(),r}reset(){this.chunks.length=0,this.dataLength=0}}function jA(i,e){const t=new Uint8Array(e);let r=0;for(let s=0;s<i.length;s++){const n=i[s];t.set(n,r),r+=n.length}return t}function zA(){return typeof __HLS_WORKER_BUNDLE__=="function"}function XA(){const i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(i);return{worker:new self.Worker(e),objectURL:e}}function QA(i){const e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function gi(i="",e=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Jh{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(e,t,r,s){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}}resetTimeStamp(e){this.initPTS=e,this.resetContiguity()}resetContiguity(){this.basePTS=null,this.lastPTS=null,this.frameIndex=0}canParse(e,t){return!1}appendFrame(e,t,r){}demux(e,t){this.cachedData&&(e=Ut(this.cachedData,e),this.cachedData=null);let r=Ia(e,0),s=r?r.length:0,n;const a=this._audioTrack,o=this._id3Track,l=r?Yh(r):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&Y(l))&&(this.basePTS=ZA(l,t,this.initPTS),this.lastPTS=this.basePTS),this.lastPTS===null&&(this.lastPTS=this.basePTS),r&&r.length>0&&o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Yt.audioId3,duration:Number.POSITIVE_INFINITY});s<d;){if(this.canParse(e,s)){const u=this.appendFrame(a,e,s);u?(this.frameIndex++,this.lastPTS=u.sample.pts,s+=u.length,n=s):s=d}else y1(e,s)?(r=Ia(e,s),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:r,type:Yt.audioId3,duration:Number.POSITIVE_INFINITY}),s+=r.length,n=s):s++;if(s===d&&n!==d){const u=is(e,n);this.cachedData?this.cachedData=Ut(this.cachedData,u):this.cachedData=u}}return{audioTrack:a,videoTrack:gi(),id3Track:o,textTrack:gi()}}demuxSampleAes(e,t,r){return Promise.reject(new Error(`[${this}] This demuxer does not support Sample-AES decryption`))}flush(e){const t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),{audioTrack:this._audioTrack,videoTrack:gi(),id3Track:this._id3Track,textTrack:gi()}}destroy(){}}const ZA=(i,e,t)=>{if(Y(i))return i*90;const r=t?t.baseTime*9e4/t.timescale:0;return e*9e4+r};function JA(i,e,t,r){let s,n,a,o;const l=navigator.userAgent.toLowerCase(),d=r,u=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];s=((e[t+2]&192)>>>6)+1;const c=(e[t+2]&60)>>>2;if(c>u.length-1){const h=new Error(`invalid ADTS sampling index:${c}`);i.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,I.log(`manifest codec:${r}, ADTS type:${s}, samplingIndex:${c}`),/firefox/i.test(l)?c>=6?(s=5,o=new Array(4),n=c-3):(s=2,o=new Array(2),n=c):l.indexOf("android")!==-1?(s=2,o=new Array(2),n=c):(s=5,o=new Array(4),r&&(r.indexOf("mp4a.40.29")!==-1||r.indexOf("mp4a.40.5")!==-1)||!r&&c>=6?n=c-3:((r&&r.indexOf("mp4a.40.2")!==-1&&(c>=6&&a===1||/vivaldi/i.test(l))||!r&&a===1)&&(s=2,o=new Array(2)),n=c)),o[0]=s<<3,o[0]|=(c&14)>>1,o[1]|=(c&1)<<7,o[1]|=a<<3,s===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:u[c],channelCount:a,codec:"mp4a.40."+s,manifestCodec:d}}function Mg(i,e){return i[e]===255&&(i[e+1]&246)===240}function Pg(i,e){return i[e+1]&1?7:9}function ef(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function eS(i,e){return e+5<i.length}function rd(i,e){return e+1<i.length&&Mg(i,e)}function tS(i,e){return eS(i,e)&&Mg(i,e)&&ef(i,e)<=i.length-e}function iS(i,e){if(rd(i,e)){const t=Pg(i,e);if(e+t>=i.length)return!1;const r=ef(i,e);if(r<=t)return!1;const s=e+r;return s===i.length||rd(i,s)}return!1}function Og(i,e,t,r,s){if(!i.samplerate){const n=JA(e,t,r,s);if(!n)return;i.config=n.config,i.samplerate=n.samplerate,i.channelCount=n.channelCount,i.codec=n.codec,i.manifestCodec=n.manifestCodec,I.log(`parsed codec:${i.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function Ng(i){return 1024*9e4/i}function rS(i,e){const t=Pg(i,e);if(e+t<=i.length){const r=ef(i,e)-t;if(r>0)return{headerLength:t,frameLength:r}}}function Fg(i,e,t,r,s){const n=Ng(i.samplerate),a=r+s*n,o=rS(e,t);let l;if(o){const{frameLength:c,headerLength:h}=o,f=h+c,m=Math.max(0,t+f-e.length);m?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);const p={unit:l,pts:a};return m||i.samples.push(p),{sample:p,length:f,missing:m}}const d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:d,missing:-1}}let io=null;const sS=[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],nS=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],aS=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],oS=[0,1,1,4];function Ug(i,e,t,r,s){if(t+24>e.length)return;const n=$g(e,t);if(n&&t+n.frameLength<=e.length){const a=n.samplesPerFrame*9e4/n.sampleRate,o=r+s*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return i.config=[],i.channelCount=n.channelCount,i.samplerate=n.sampleRate,i.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function $g(i,e){const t=i[e+1]>>3&3,r=i[e+1]>>1&3,s=i[e+2]>>4&15,n=i[e+2]>>2&3;if(t!==1&&s!==0&&s!==15&&n!==3){const a=i[e+2]>>1&1,o=i[e+3]>>6,l=t===3?3-r:r===3?3:4,d=sS[l*14+s-1]*1e3,c=nS[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=aS[t][r],m=oS[r],p=f*8*m,g=Math.floor(f*d/c+a)*m;if(io===null){const b=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);io=b?parseInt(b[1]):0}return!!io&&io<=87&&r===2&&d>=224e3&&o===0&&(i[e+3]=i[e+3]|128),{sampleRate:c,channelCount:h,frameLength:g,samplesPerFrame:p}}}function tf(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function Bg(i,e){return e+1<i.length&&tf(i,e)}function lS(i,e){return tf(i,e)&&4<=i.length-e}function Gg(i,e){if(e+1<i.length&&tf(i,e)){const r=$g(i,e);let s=4;r!=null&&r.frameLength&&(s=r.frameLength);const n=e+s;return n===i.length||Bg(i,n)}return!1}class dS extends Jh{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Ia(e,0);let r=(t==null?void 0:t.length)||0;if(Gg(e,r))return!1;for(let s=e.length;r<s;r++)if(iS(e,r))return I.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return tS(e,t)}appendFrame(e,t,r){Og(e,this.observer,t,r,e.manifestCodec);const s=Fg(e,t,r,this.basePTS,this.frameIndex);if(s&&s.missing===0)return s}}const uS=/\/emsg[-/]ID3/i;class cS{constructor(e,t){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=t}resetTimeStamp(){}resetInitSegment(e,t,r,s){const n=this.videoTrack=gi("video",1),a=this.audioTrack=gi("audio",1),o=this.txtTrack=gi("text",1);if(this.id3Track=gi("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const l=vg(e);if(l.video){const{id:d,timescale:u,codec:c}=l.video;n.id=d,n.timescale=o.timescale=u,n.codec=c}if(l.audio){const{id:d,timescale:u,codec:c}=l.audio;a.id=d,a.timescale=u,a.codec=c}o.id=mg.text,n.sampleDuration=0,n.duration=a.duration=s}resetContiguity(){this.remainderData=null}static probe(e){return I1(e)}demux(e,t){this.timeOffset=t;let r=e;const s=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Ut(this.remainderData,e));const o=N1(r);this.remainderData=o.remainder,s.samples=o.valid||new Uint8Array}else s.samples=r;const a=this.extractID3Track(s,t);return n.samples=_m(t,s),{videoTrack:s,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,r=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const s=this.extractID3Track(t,this.timeOffset);return r.samples=_m(e,t),{videoTrack:t,audioTrack:gi(),id3Track:s,textTrack:gi()}}extractID3Track(e,t){const r=this.id3Track;if(e.samples.length){const s=le(e.samples,["emsg"]);s&&s.forEach(n=>{const a=$1(n);if(uS.test(a.schemeIdUri)){const o=Y(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale;let l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);const d=a.payload;r.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:Yt.emsg,duration:l})}})}return r}demuxSampleAes(e,t,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}const Hg=(i,e)=>{let t=0,r=5;e+=r;const s=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;r>0;){a[0]=i[e];const o=Math.min(r,8),l=8-o;n[0]=4278190080>>>24+l<<l,s[0]=(a[0]&n[0])>>l,t=t?t<<o|s[0]:s[0],e+=1,r-=o}return t};class hS extends Jh{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,r){const s=Wg(e,t,r,this.basePTS,this.frameIndex);if(s!==-1)return{sample:e.samples[e.samples.length-1],length:s,missing:0}}static probe(e){if(!e)return!1;const t=Ia(e,0);if(!t)return!1;const r=t.length;return e[r]===11&&e[r+1]===119&&Yh(t)!==void 0&&Hg(e,r)<16}}function Wg(i,e,t,r,s){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const n=e[t+4]>>6;if(n>=3)return-1;const o=[48e3,44100,32e3][n],l=e[t+4]&63,u=[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][l*3+n]*2;if(t+u>e.length)return-1;const c=e[t+6]>>5;let h=0;c===2?h+=2:(c&1&&c!==1&&(h+=2),c&4&&(h+=2));const f=(e[t+6]<<8|e[t+7])>>12-h&1,p=[2,1,2,3,3,4,4,5][c]+f,g=e[t+5]>>3,E=e[t+5]&7,y=new Uint8Array([n<<6|g<<1|E>>2,(E&3)<<6|c<<3|f<<2|l>>4,l<<4&224]),b=1536/o*9e4,S=r+s*b,_=e.subarray(t,t+u);return i.config=y,i.channelCount=p,i.samplerate=o,i.samples.push({unit:_,pts:S}),u}class fS{constructor(){this.VideoSample=null}createVideoSample(e,t,r,s){return{key:e,frame:!1,pts:t,dts:r,units:[],debug:s,length:0}}getLastNalUnit(e){var t;let r=this.VideoSample,s;if((!r||r.units.length===0)&&(r=e[e.length-1]),(t=r)!=null&&t.units){const n=r.units;s=n[n.length-1]}return s}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const r=t.samples,s=r.length;if(s){const n=r[s-1];e.pts=n.pts,e.dts=n.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&I.log(e.pts+"/"+e.dts+":"+e.debug)}}class Xm{constructor(e){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=e,this.bytesAvailable=e.byteLength,this.word=0,this.bitsAvailable=0}loadWord(){const e=this.data,t=this.bytesAvailable,r=e.byteLength-t,s=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");s.set(e.subarray(r,r+n)),this.word=new DataView(s.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}skipBits(e){let t;e=Math.min(e,this.bytesAvailable*8+this.bitsAvailable),this.bitsAvailable>e?(this.word<<=e,this.bitsAvailable-=e):(e-=this.bitsAvailable,t=e>>3,e-=t<<3,this.bytesAvailable-=t,this.loadWord(),this.word<<=e,this.bitsAvailable-=e)}readBits(e){let t=Math.min(this.bitsAvailable,e);const r=this.word>>>32-t;if(e>32&&I.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=t,this.bitsAvailable>0)this.word<<=t;else if(this.bytesAvailable>0)this.loadWord();else throw new Error("no bits available");return t=e-t,t>0&&this.bitsAvailable?r<<t|this.readBits(t):r}skipLZ(){let e;for(e=0;e<this.bitsAvailable;++e)if(this.word&2147483648>>>e)return this.word<<=e,this.bitsAvailable-=e,e;return this.loadWord(),e+this.skipLZ()}skipUEG(){this.skipBits(1+this.skipLZ())}skipEG(){this.skipBits(1+this.skipLZ())}readUEG(){const e=this.skipLZ();return this.readBits(e+1)-1}readEG(){const e=this.readUEG();return 1&e?1+e>>>1:-1*(e>>>1)}readBoolean(){return this.readBits(1)===1}readUByte(){return this.readBits(8)}readUShort(){return this.readBits(16)}readUInt(){return this.readBits(32)}skipScalingList(e){let t=8,r=8,s;for(let n=0;n<e;n++)r!==0&&(s=this.readEG(),r=(t+s+256)%256),t=r===0?t:r}readSPS(){let e=0,t=0,r=0,s=0,n,a,o;const l=this.readUByte.bind(this),d=this.readBits.bind(this),u=this.readUEG.bind(this),c=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),m=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);l();const g=l();if(d(5),h(3),l(),m(),g===100||g===110||g===122||g===244||g===44||g===83||g===86||g===118||g===128){const x=u();if(x===3&&h(1),m(),m(),h(1),c())for(a=x!==3?8:12,o=0;o<a;o++)c()&&(o<6?p(16):p(64))}m();const E=u();if(E===0)u();else if(E===1)for(h(1),f(),f(),n=u(),o=0;o<n;o++)f();m(),h(1);const y=u(),b=u(),S=d(1);S===0&&h(1),h(1),c()&&(e=u(),t=u(),r=u(),s=u());let _=[1,1];if(c()&&c())switch(l()){case 1:_=[1,1];break;case 2:_=[12,11];break;case 3:_=[10,11];break;case 4:_=[16,11];break;case 5:_=[40,33];break;case 6:_=[24,11];break;case 7:_=[20,11];break;case 8:_=[32,11];break;case 9:_=[80,33];break;case 10:_=[18,11];break;case 11:_=[15,11];break;case 12:_=[64,33];break;case 13:_=[160,99];break;case 14:_=[4,3];break;case 15:_=[3,2];break;case 16:_=[2,1];break;case 255:{_=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((y+1)*16-e*2-t*2),height:(2-S)*(b+1)*16-(S?2:4)*(r+s),pixelRatio:_}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class mS extends fS{parseAVCPES(e,t,r,s,n){const a=this.parseAVCNALu(e,r.data);let o=this.VideoSample,l,d=!1;r.data=null,o&&a.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"")),a.forEach(u=>{var c;switch(u.type){case 1:{let p=!1;l=!0;const g=u.data;if(d&&g.length>4){const E=new Xm(g).readSliceType();(E===2||E===4||E===7||E===9)&&(p=!0)}if(p){var h;(h=o)!=null&&h.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.frame=!0,o.key=p;break}case 5:l=!0,(c=o)!=null&&c.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,r.pts,r.dts,"")),o.key=!0,o.frame=!0;break;case 6:{l=!0,yg(u.data,1,r.pts,t.samples);break}case 7:{var f,m;l=!0,d=!0;const p=u.data,E=new Xm(p).readSPS();if(!e.sps||e.width!==E.width||e.height!==E.height||((f=e.pixelRatio)==null?void 0:f[0])!==E.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==E.pixelRatio[1]){e.width=E.width,e.height=E.height,e.pixelRatio=E.pixelRatio,e.sps=[p],e.duration=n;const y=p.subarray(1,4);let b="avc1.";for(let S=0;S<3;S++){let _=y[S].toString(16);_.length<2&&(_="0"+_),b+=_}e.codec=b}break}case 8:l=!0,e.pps=[u.data];break;case 9:l=!0,e.audFound=!0,o&&this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,r.pts,r.dts,"");break;case 12:l=!0;break;default:l=!1,o&&(o.debug+="unknown NAL "+u.type+" ");break}o&&l&&o.units.push(u)}),s&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}parseAVCNALu(e,t){const r=t.byteLength;let s=e.naluState||0;const n=s,a=[];let o=0,l,d,u,c=-1,h=0;for(s===-1&&(c=0,h=t[0]&31,s=0,o=1);o<r;){if(l=t[o++],!s){s=l?0:1;continue}if(s===1){s=l?0:2;continue}if(!l)s=3;else if(l===1){if(d=o-s-1,c>=0){const f={data:t.subarray(c,d),type:h};a.push(f)}else{const f=this.getLastNalUnit(e.samples);f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),d>0&&(f.data=Ut(f.data,t.subarray(0,d)),f.state=0))}o<r?(u=t[o]&31,c=o,h=u,s=0):s=-1}else s=0}if(c>=0&&s>=0){const f={data:t.subarray(c,r),type:h,state:s};a.push(f)}if(a.length===0){const f=this.getLastNalUnit(e.samples);f&&(f.data=Ut(f.data,t))}return e.naluState=s,a}}class pS{constructor(e,t,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new Qh(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,r){const s=e[t].unit;if(s.length<=16)return;const n=s.subarray(16,s.length-s.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{const l=new Uint8Array(o);s.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,r)})}decryptAacSamples(e,t,r){for(;;t++){if(t>=e.length){r();return}if(!(e[t].unit.length<32)&&(this.decryptAacSample(e,t,r),!this.decrypter.isSync()))return}}getAvcEncryptedData(e){const t=Math.floor((e.length-48)/160)*16+16,r=new Int8Array(t);let s=0;for(let n=32;n<e.length-16;n+=160,s+=16)r.set(e.subarray(n,n+16),s);return r}getAvcDecryptedUnit(e,t){const r=new Uint8Array(t);let s=0;for(let n=32;n<e.length-16;n+=160,s+=16)e.set(r.subarray(s,s+16),n);return e}decryptAvcSample(e,t,r,s,n){const a=bg(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,r+1,s)})}decryptAvcSamples(e,t,r,s){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,r=0){if(t>=e.length){s();return}const n=e[t].units;for(;!(r>=n.length);r++){const a=n[r];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,r,s,a),!this.decrypter.isSync()))return}}}}const et=188;class nr{constructor(e,t,r){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._duration=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=e,this.config=t,this.typeSupported=r,this.videoParser=new mS}static probe(e){const t=nr.syncOffset(e);return t>0&&I.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){const t=e.length;let r=Math.min(et*5,t-et)+1,s=0;for(;s<r;){let n=!1,a=-1,o=0;for(let l=s;l<t;l+=et)if(e[l]===71&&(t-l===et||e[l+et]===71)){if(o++,a===-1&&(a=l,a!==0&&(r=Math.min(a+et*99,e.length-et)+1)),n||(n=tc(e,l)===0),n&&o>1&&(a===0&&o>2||l+et>r))return a}else{if(o)return-1;break}s++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:mg[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,r,s){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=nr.createTrack("video"),this._audioTrack=nr.createTrack("audio",s),this._id3Track=nr.createTrack("id3"),this._txtTrack=nr.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=r,this._duration=s}resetTimeStamp(){}resetContiguity(){const{_audioTrack:e,_videoTrack:t,_id3Track:r}=this;e&&(e.pesData=null),t&&(t.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null}demux(e,t,r=!1,s=!1){r||(this.sampleAes=null);let n;const a=this._videoTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack;let u=a.pid,c=a.pesData,h=o.pid,f=l.pid,m=o.pesData,p=l.pesData,g=null,E=this.pmtParsed,y=this._pmtId,b=e.length;if(this.remainderData&&(e=Ut(this.remainderData,e),b=e.length,this.remainderData=null),b<et&&!s)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};const S=Math.max(0,nr.syncOffset(e));b-=(b-S)%et,b<e.byteLength&&!s&&(this.remainderData=new Uint8Array(e.buffer,b,e.buffer.byteLength-b));let _=0;for(let A=S;A<b;A+=et)if(e[A]===71){const C=!!(e[A+1]&64),O=tc(e,A),L=(e[A+3]&48)>>4;let M;if(L>1){if(M=A+5+e[A+4],M===A+et)continue}else M=A+4;switch(O){case u:C&&(c&&(n=bs(c))&&this.videoParser.parseAVCPES(a,d,n,!1,this._duration),c={data:[],size:0}),c&&(c.data.push(e.subarray(M,A+et)),c.size+=A+et-M);break;case h:if(C){if(m&&(n=bs(m)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break;case"ac3":this.parseAC3PES(o,n);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(M,A+et)),m.size+=A+et-M);break;case f:C&&(p&&(n=bs(p))&&this.parseID3PES(l,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(M,A+et)),p.size+=A+et-M);break;case 0:C&&(M+=e[M]+1),y=this._pmtId=gS(e,M);break;case y:{C&&(M+=e[M]+1);const K=vS(e,M,this.typeSupported,r,this.observer);u=K.videoPid,u>0&&(a.pid=u,a.segmentCodec=K.segmentVideoCodec),h=K.audioPid,h>0&&(o.pid=h,o.segmentCodec=K.segmentAudioCodec),f=K.id3Pid,f>0&&(l.pid=f),g!==null&&!E&&(I.warn(`MPEG-TS PMT found at ${A} after unknown PID '${g}'. Backtracking to sync byte @${S} to parse all TS packets.`),g=null,A=S-188),E=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=O;break}}else _++;_>0&&sd(this.observer,new Error(`Found ${_} TS packet/s that do not start with 0x47`)),a.pesData=c,o.pesData=m,l.pesData=p;const x={audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};return s&&this.extractRemainingSamples(x),x}flush(){const{remainderData:e}=this;this.remainderData=null;let t;return e?t=this.demux(e,-1,!1,!0):t={videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t}extractRemainingSamples(e){const{audioTrack:t,videoTrack:r,id3Track:s,textTrack:n}=e,a=r.pesData,o=t.pesData,l=s.pesData;let d;if(a&&(d=bs(a))?(this.videoParser.parseAVCPES(r,n,d,!0,this._duration),r.pesData=null):r.pesData=a,o&&(d=bs(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break;case"ac3":this.parseAC3PES(t,d);break}t.pesData=null}else o!=null&&o.size&&I.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=bs(l))?(this.parseID3PES(s,d),s.pesData=null):s.pesData=l}demuxSampleAes(e,t,r){const s=this.demux(e,r,!0,!this.config.progressive),n=this.sampleAes=new pS(this.observer,this.config,t);return this.decrypt(s,n)}decrypt(e,t){return new Promise(r=>{const{audioTrack:s,videoTrack:n}=e;s.samples&&s.segmentCodec==="aac"?t.decryptAacSamples(s.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{r(e)}):r(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{r(e)})})}destroy(){this._duration=0}parseAACPES(e,t){let r=0;const s=this.aacOverFlow;let n=t.data;if(s){this.aacOverFlow=null;const c=s.missing,h=s.sample.unit.byteLength;if(c===-1)n=Ut(s.sample.unit,n);else{const f=h-c;s.sample.unit.set(n.subarray(0,c),f),e.samples.push(s.sample),r=s.missing}}let a,o;for(a=r,o=n.length;a<o-1&&!rd(n,a);a++);if(a!==r){let c;const h=a<o-1;if(h?c=`AAC PES did not start with ADTS header,offset:${a}`:c="No ADTS header found in AAC PES",sd(this.observer,new Error(c),h),!h)return}Og(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(s){const c=Ng(e.samplerate);l=s.sample.pts+c}else{I.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,u;for(;a<o;)if(u=Fg(e,n,a,l,d),a+=u.length,u.missing){this.aacOverFlow=u;break}else for(d++;a<o-1&&!rd(n,a);a++);}parseMPEGPES(e,t){const r=t.data,s=r.length;let n=0,a=0;const o=t.pts;if(o===void 0){I.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<s;)if(Bg(r,a)){const l=Ug(e,r,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseAC3PES(e,t){{const r=t.data,s=t.pts;if(s===void 0){I.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const n=r.length;let a=0,o=0,l;for(;o<n&&(l=Wg(e,r,o,s,a++))>0;)o+=l}}parseID3PES(e,t){if(t.pts===void 0){I.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const r=We({},t,{type:this._videoTrack?Yt.emsg:Yt.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(r)}}function tc(i,e){return((i[e+1]&31)<<8)+i[e+2]}function gS(i,e){return(i[e+10]&31)<<8|i[e+11]}function vS(i,e,t,r,s){const n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},a=(i[e+1]&15)<<8|i[e+2],o=e+3+a-4,l=(i[e+10]&15)<<8|i[e+11];for(e+=12+l;e<o;){const d=tc(i,e),u=(i[e+3]&15)<<8|i[e+4];switch(i[e]){case 207:if(!r){du("ADTS AAC");break}case 15:n.audioPid===-1&&(n.audioPid=d);break;case 21:n.id3Pid===-1&&(n.id3Pid=d);break;case 219:if(!r){du("H.264");break}case 27:n.videoPid===-1&&(n.videoPid=d,n.segmentVideoCodec="avc");break;case 3:case 4:!t.mpeg&&!t.mp3?I.log("MPEG audio found, not supported in this browser"):n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="mp3");break;case 193:if(!r){du("AC-3");break}case 129:t.ac3?n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="ac3"):I.log("AC-3 audio found, not supported in this browser");break;case 6:if(n.audioPid===-1&&u>0){let c=e+5,h=u;for(;h>2;){switch(i[c]){case 106:t.ac3!==!0?I.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=d,n.segmentAudioCodec="ac3");break}const m=i[c+1]+2;c+=m,h-=m}}break;case 194:case 135:return sd(s,new Error("Unsupported EC-3 in M2TS found")),n;case 36:return sd(s,new Error("Unsupported HEVC in M2TS found")),n}e+=u+5}return n}function sd(i,e,t){I.warn(`parsing error: ${e.message}`),i.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function du(i){I.log(`${i} with AES-128-CBC encryption found in unencrypted stream`)}function bs(i){let e=0,t,r,s,n,a;const o=i.data;if(!i||i.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=Ut(o[0],o[1]),o.splice(1,1);if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(r=(t[4]<<8)+t[5],r&&r>i.size-6)return null;const d=t[7];d&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-a>60*9e4&&(I.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),s=t[8];let u=s+9;if(i.size<=u)return null;i.size-=u;const c=new Uint8Array(i.size);for(let h=0,f=o.length;h<f;h++){t=o[h];let m=t.byteLength;if(u)if(u>m){u-=m;continue}else t=t.subarray(u),m-=u,u=0;c.set(t,e),e+=m}return r&&(r-=s+3),{data:c,pts:n,dts:a,len:r}}return null}class ES extends Jh{resetInitSegment(e,t,r,s){super.resetInitSegment(e,t,r,s),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:s,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Ia(e,0);let r=(t==null?void 0:t.length)||0;if(t&&e[r]===11&&e[r+1]===119&&Yh(t)!==void 0&&Hg(e,r)<=16)return!1;for(let s=e.length;r<s;r++)if(Gg(e,r))return I.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return lS(e,t)}appendFrame(e,t,r){if(this.basePTS!==null)return Ug(e,t,r,this.basePTS,this.frameIndex)}}class Qm{static getSilentFrame(e,t){switch(e){case"mp4a.40.2":if(t===1)return new Uint8Array([0,200,0,128,35,128]);if(t===2)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(t===3)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(t===4)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(t===5)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(t===6)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]);break;default:if(t===1)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(t===2)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(t===3)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]);break}}}const ji=Math.pow(2,32)-1;class w{static init(){w.types={avc1:[],avcC:[],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:[]};let e;for(e in w.types)w.types.hasOwnProperty(e)&&(w.types[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);const t=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]),r=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]);w.HDLR_TYPES={video:t,audio:r};const s=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);w.STTS=w.STSC=w.STCO=n,w.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),w.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),w.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),w.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);w.FTYP=w.box(w.types.ftyp,a,l,a,o),w.DINF=w.box(w.types.dinf,w.box(w.types.dref,s))}static box(e,...t){let r=8,s=t.length;const n=s;for(;s--;)r+=t[s].byteLength;const a=new Uint8Array(r);for(a[0]=r>>24&255,a[1]=r>>16&255,a[2]=r>>8&255,a[3]=r&255,a.set(e,4),s=0,r=8;s<n;s++)a.set(t[s],r),r+=t[s].byteLength;return a}static hdlr(e){return w.box(w.types.hdlr,w.HDLR_TYPES[e])}static mdat(e){return w.box(w.types.mdat,e)}static mdhd(e,t){t*=e;const r=Math.floor(t/(ji+1)),s=Math.floor(t%(ji+1));return w.box(w.types.mdhd,new Uint8Array([1,0,0,0,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,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,85,196,0,0]))}static mdia(e){return w.box(w.types.mdia,w.mdhd(e.timescale,e.duration),w.hdlr(e.type),w.minf(e))}static mfhd(e){return w.box(w.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,e&255]))}static minf(e){return e.type==="audio"?w.box(w.types.minf,w.box(w.types.smhd,w.SMHD),w.DINF,w.stbl(e)):w.box(w.types.minf,w.box(w.types.vmhd,w.VMHD),w.DINF,w.stbl(e))}static moof(e,t,r){return w.box(w.types.moof,w.mfhd(e),w.traf(r,t))}static moov(e){let t=e.length;const r=[];for(;t--;)r[t]=w.trak(e[t]);return w.box.apply(null,[w.types.moov,w.mvhd(e[0].timescale,e[0].duration)].concat(r).concat(w.mvex(e)))}static mvex(e){let t=e.length;const r=[];for(;t--;)r[t]=w.trex(e[t]);return w.box.apply(null,[w.types.mvex,...r])}static mvhd(e,t){t*=e;const r=Math.floor(t/(ji+1)),s=Math.floor(t%(ji+1)),n=new Uint8Array([1,0,0,0,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,e&255,r>>24,r>>16&255,r>>8&255,r&255,s>>24,s>>16&255,s>>8&255,s&255,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 w.box(w.types.mvhd,n)}static sdtp(e){const t=e.samples||[],r=new Uint8Array(4+t.length);let s,n;for(s=0;s<t.length;s++)n=t[s].flags,r[s+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return w.box(w.types.sdtp,r)}static stbl(e){return w.box(w.types.stbl,w.stsd(e),w.box(w.types.stts,w.STTS),w.box(w.types.stsc,w.STSC),w.box(w.types.stsz,w.STSZ),w.box(w.types.stco,w.STCO))}static avc1(e){let t=[],r=[],s,n,a;for(s=0;s<e.sps.length;s++)n=e.sps[s],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(s=0;s<e.pps.length;s++)n=e.pps[s],a=n.byteLength,r.push(a>>>8&255),r.push(a&255),r=r.concat(Array.prototype.slice.call(n));const o=w.box(w.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(r))),l=e.width,d=e.height,u=e.pixelRatio[0],c=e.pixelRatio[1];return w.box(w.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,l>>8&255,l&255,d>>8&255,d&255,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,w.box(w.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),w.box(w.types.pasp,new Uint8Array([u>>24,u>>16&255,u>>8&255,u&255,c>>24,c>>16&255,c>>8&255,c&255])))}static esds(e){const t=e.config.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){const t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return w.box(w.types.mp4a,w.audioStsd(e),w.box(w.types.esds,w.esds(e)))}static mp3(e){return w.box(w.types[".mp3"],w.audioStsd(e))}static ac3(e){return w.box(w.types["ac-3"],w.audioStsd(e),w.box(w.types.dac3,e.config))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?w.box(w.types.stsd,w.STSD,w.mp3(e)):e.segmentCodec==="ac3"?w.box(w.types.stsd,w.STSD,w.ac3(e)):w.box(w.types.stsd,w.STSD,w.mp4a(e)):w.box(w.types.stsd,w.STSD,w.avc1(e))}static tkhd(e){const t=e.id,r=e.duration*e.timescale,s=e.width,n=e.height,a=Math.floor(r/(ji+1)),o=Math.floor(r%(ji+1));return w.box(w.types.tkhd,new Uint8Array([1,0,0,7,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,t&255,0,0,0,0,a>>24,a>>16&255,a>>8&255,a&255,o>>24,o>>16&255,o>>8&255,o&255,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,s>>8&255,s&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){const r=w.sdtp(e),s=e.id,n=Math.floor(t/(ji+1)),a=Math.floor(t%(ji+1));return w.box(w.types.traf,w.box(w.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,s&255])),w.box(w.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),w.trun(e,r.length+16+20+8+16+8+8),r)}static trak(e){return e.duration=e.duration||4294967295,w.box(w.types.trak,w.tkhd(e),w.mdia(e))}static trex(e){const t=e.id;return w.box(w.types.trex,new Uint8Array([0,0,0,0,t>>24,t>>16&255,t>>8&255,t&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))}static trun(e,t){const r=e.samples||[],s=r.length,n=12+16*s,a=new Uint8Array(n);let o,l,d,u,c,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,s>>>24&255,s>>>16&255,s>>>8&255,s&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<s;o++)l=r[o],d=l.duration,u=l.size,c=l.flags,h=l.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&255,u>>>24&255,u>>>16&255,u>>>8&255,u&255,c.isLeading<<2|c.dependsOn,c.isDependedOn<<6|c.hasRedundancy<<4|c.paddingValue<<1|c.isNonSync,c.degradPrio&61440,c.degradPrio&15,h>>>24&255,h>>>16&255,h>>>8&255,h&255],12+16*o);return w.box(w.types.trun,a)}static initSegment(e){w.types||w.init();const t=w.moov(e);return Ut(w.FTYP,t)}}w.types=void 0;w.HDLR_TYPES=void 0;w.STTS=void 0;w.STSC=void 0;w.STCO=void 0;w.STSZ=void 0;w.VMHD=void 0;w.SMHD=void 0;w.STSD=void 0;w.FTYP=void 0;w.DINF=void 0;const Kg=9e4;function rf(i,e,t=1,r=!1){const s=i*e*t;return r?Math.round(s):s}function yS(i,e,t=1,r=!1){return rf(i,e,1/t,r)}function Rn(i,e=!1){return rf(i,1e3,1/Kg,e)}function bS(i,e=1){return rf(i,Kg,1/e)}const TS=10*1e3,Zm=1024,_S=1152,AS=1536;let Ts=null,uu=null;class Do{constructor(e,t,r,s=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=e,this.config=t,this.typeSupported=r,this.ISGenerated=!1,Ts===null){const a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ts=a?parseInt(a[1]):0}if(uu===null){const n=navigator.userAgent.match(/Safari\/(\d+)/i);uu=n?parseInt(n[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){I.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){I.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){I.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const r=e.reduce((s,n)=>{const a=n.pts-s;return a<-4294967296?(t=!0,Nt(s,n.pts)):a>0?s:n.pts},e[0].pts);return t&&I.debug("PTS rollover detected"),r}remux(e,t,r,s,n,a,o,l){let d,u,c,h,f,m,p=n,g=n;const E=e.pid>-1,y=t.pid>-1,b=t.samples.length,S=e.samples.length>0,_=o&&b>0||b>1;if((!E||S)&&(!y||_)||this.ISGenerated||o){if(this.ISGenerated){var A,C,O,L;const z=this.videoTrackConfig;z&&(t.width!==z.width||t.height!==z.height||((A=t.pixelRatio)==null?void 0:A[0])!==((C=z.pixelRatio)==null?void 0:C[0])||((O=t.pixelRatio)==null?void 0:O[1])!==((L=z.pixelRatio)==null?void 0:L[1]))&&this.resetInitSegment()}else c=this.generateIS(e,t,n,a);const M=this.isVideoContiguous;let K=-1,U;if(_&&(K=SS(t.samples),!M&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,K>0){I.warn(`[mp4-remuxer]: Dropped ${K} out of ${b} video samples due to a missing keyframe`);const z=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(K),t.dropped+=K,g+=(t.samples[0].pts-z)/t.inputTimeScale,U=g}else K===-1&&(I.warn(`[mp4-remuxer]: No keyframe found out of ${b} video samples`),m=!1);if(this.ISGenerated){if(S&&_){const z=this.getVideoStartPts(t.samples),q=(Nt(e.samples[0].pts,z)-z)/t.inputTimeScale;p+=Math.max(0,q),g+=Math.max(0,-q)}if(S){if(e.samplerate||(I.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),c=this.generateIS(e,t,n,a)),u=this.remuxAudio(e,p,this.isAudioContiguous,a,y||_||l===ee.AUDIO?g:void 0),_){const z=u?u.endPTS-u.startPTS:0;t.inputTimeScale||(I.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),c=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,g,M,z)}}else _&&(d=this.remuxVideo(t,g,M,0));d&&(d.firstKeyFrame=K,d.independent=K!==-1,d.firstKeyFramePTS=U)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(f=Vg(r,n,this._initPTS,this._initDTS)),s.samples.length&&(h=qg(s,n,this._initPTS))),{audio:u,video:d,initSegment:c,independent:m,text:h,id3:f}}generateIS(e,t,r,s){const n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS;let u=!d||s,c="audio/mp4",h,f,m;if(u&&(h=f=1/0),e.config&&n.length){switch(e.timescale=e.samplerate,e.segmentCodec){case"mp3":o.mpeg?(c="audio/mpeg",e.codec=""):o.mp3&&(e.codec="mp3");break;case"ac3":e.codec="ac-3";break}l.audio={id:"audio",container:c,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):w.initSegment([e]),metadata:{channelCount:e.channelCount}},u&&(m=e.inputTimeScale,!d||m!==d.timescale?h=f=n[0].pts-Math.round(m*r):u=!1)}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:w.initSegment([t]),metadata:{width:t.width,height:t.height}},u)if(m=t.inputTimeScale,!d||m!==d.timescale){const p=this.getVideoStartPts(a),g=Math.round(m*r);f=Math.min(f,Nt(a[0].dts,p)-g),h=Math.min(h,p-g)}else u=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(l).length)return this.ISGenerated=!0,u?(this._initPTS={baseTime:h,timescale:m},this._initDTS={baseTime:f,timescale:m}):h=m=void 0,{tracks:l,initPTS:h,timescale:m}}remuxVideo(e,t,r,s){const n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS;let u=this.nextAvcDts,c=8,h=this.videoSampleDuration,f,m,p=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,E=!1;if(!r||u===null){const G=t*n,$=a[0].pts-Nt(a[0].dts,a[0].pts);Ts&&u!==null&&Math.abs(G-$-u)<15e3?r=!0:u=G-$}const y=d.baseTime*n/d.timescale;for(let G=0;G<l;G++){const $=a[G];$.pts=Nt($.pts-y,u),$.dts=Nt($.dts-y,u),$.dts<a[G>0?G-1:G].dts&&(E=!0)}E&&a.sort(function(G,$){const te=G.dts-$.dts,re=G.pts-$.pts;return te||re}),f=a[0].dts,m=a[a.length-1].dts;const b=m-f,S=b?Math.round(b/(l-1)):h||e.inputTimeScale/30;if(r){const G=f-u,$=G>S,te=G<-1;if(($||te)&&($?I.warn(`AVC: ${Rn(G,!0)} ms (${G}dts) hole between fragments detected at ${t.toFixed(3)}`):I.warn(`AVC: ${Rn(-G,!0)} ms (${G}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!te||u>=a[0].pts||Ts)){f=u;const re=a[0].pts-G;if($)a[0].dts=f,a[0].pts=re;else for(let oe=0;oe<a.length&&!(a[oe].dts>re);oe++)a[oe].dts-=G,a[oe].pts-=G;I.log(`Video: Initial PTS/DTS adjusted: ${Rn(re,!0)}/${Rn(f,!0)}, delta: ${Rn(G,!0)} ms`)}}f=Math.max(0,f);let _=0,x=0,A=f;for(let G=0;G<l;G++){const $=a[G],te=$.units,re=te.length;let oe=0;for(let pe=0;pe<re;pe++)oe+=te[pe].data.length;x+=oe,_+=re,$.length=oe,$.dts<A?($.dts=A,A+=S/4|0||1):A=$.dts,p=Math.min($.pts,p),g=Math.max($.pts,g)}m=a[l-1].dts;const C=x+4*_+8;let O;try{O=new Uint8Array(C)}catch(G){this.observer.emit(v.ERROR,v.ERROR,{type:ie.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:G,bytes:C,reason:`fail allocating video mdat ${C}`});return}const L=new DataView(O.buffer);L.setUint32(0,C),O.set(w.types.mdat,4);let M=!1,K=Number.POSITIVE_INFINITY,U=Number.POSITIVE_INFINITY,z=Number.NEGATIVE_INFINITY,V=Number.NEGATIVE_INFINITY;for(let G=0;G<l;G++){const $=a[G],te=$.units;let re=0;for(let Re=0,$e=te.length;Re<$e;Re++){const yt=te[Re],Yi=yt.data,ps=yt.data.byteLength;L.setUint32(c,ps),c+=4,O.set(Yi,c),c+=ps,re+=4+ps}let oe;if(G<l-1)h=a[G+1].dts-$.dts,oe=a[G+1].pts-$.pts;else{const Re=this.config,$e=G>0?$.dts-a[G-1].dts:S;if(oe=G>0?$.pts-a[G-1].pts:S,Re.stretchShortVideoTrack&&this.nextAudioPts!==null){const yt=Math.floor(Re.maxBufferHole*n),Yi=(s?p+s*n:this.nextAudioPts)-$.pts;Yi>yt?(h=Yi-$e,h<0?h=$e:M=!0,I.log(`[mp4-remuxer]: It is approximately ${Yi/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=$e}else h=$e}const pe=Math.round($.pts-$.dts);K=Math.min(K,h),z=Math.max(z,h),U=Math.min(U,oe),V=Math.max(V,oe),o.push(new Jm($.key,h,re,pe))}if(o.length){if(Ts){if(Ts<70){const G=o[0].flags;G.dependsOn=2,G.isNonSync=0}}else if(uu&&V-U<z-K&&S/z<.025&&o[0].cts===0){I.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let G=f;for(let $=0,te=o.length;$<te;$++){const re=G+o[$].duration,oe=G+o[$].cts;if($<te-1){const pe=re+o[$+1].cts;o[$].duration=pe-oe}else o[$].duration=$?o[$-1].duration:S;o[$].cts=0,G=re}}}h=M||!h?S:h,this.nextAvcDts=u=m+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;const ne={data1:w.moof(e.sequenceNumber++,f,We({},e,{samples:o})),data2:O,startPTS:p/n,endPTS:(g+h)/n,startDTS:f/n,endDTS:u/n,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ne}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return _S;case"ac3":return AS;default:return Zm}}remuxAudio(e,t,r,s,n){const a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=this.getSamplesPerFrame(e),u=d*l,c=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=n!==void 0;let p=e.samples,g=h?0:8,E=this.nextAudioPts||-1;const y=t*a,b=c.baseTime*a/c.timescale;if(this.isAudioContiguous=r=r||p.length&&E>0&&(s&&Math.abs(y-E)<9e3||Math.abs(Nt(p[0].pts-b,y)-E)<20*u),p.forEach(function(q){q.pts=Nt(q.pts-b,y)}),!r||E<0){if(p=p.filter(q=>q.pts>=0),!p.length)return;n===0?E=0:s&&!m?E=Math.max(0,y):E=p[0].pts}if(e.segmentCodec==="aac"){const q=this.config.maxAudioFramesDrift;for(let ae=0,ne=E;ae<p.length;ae++){const G=p[ae],$=G.pts,te=$-ne,re=Math.abs(1e3*te/a);if(te<=-q*u&&m)ae===0&&(I.warn(`Audio frame @ ${($/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*te/a)} ms.`),this.nextAudioPts=E=ne=$);else if(te>=q*u&&re<TS&&m){let oe=Math.round(te/u);ne=$-oe*u,ne<0&&(oe--,ne+=u),ae===0&&(this.nextAudioPts=E=ne),I.warn(`[mp4-remuxer]: Injecting ${oe} audio frame @ ${(ne/a).toFixed(3)}s due to ${Math.round(1e3*te/a)} ms gap.`);for(let pe=0;pe<oe;pe++){const Re=Math.max(ne,0);let $e=Qm.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);$e||(I.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),$e=G.unit.subarray()),p.splice(ae,0,{unit:$e,pts:Re}),ne+=u,ae++}}G.pts=ne,ne+=u}}let S=null,_=null,x,A=0,C=p.length;for(;C--;)A+=p[C].unit.byteLength;for(let q=0,ae=p.length;q<ae;q++){const ne=p[q],G=ne.unit;let $=ne.pts;if(_!==null){const re=f[q-1];re.duration=Math.round(($-_)/l)}else if(r&&e.segmentCodec==="aac"&&($=E),S=$,A>0){A+=g;try{x=new Uint8Array(A)}catch(re){this.observer.emit(v.ERROR,v.ERROR,{type:ie.MUX_ERROR,details:D.REMUX_ALLOC_ERROR,fatal:!1,error:re,bytes:A,reason:`fail allocating audio mdat ${A}`});return}h||(new DataView(x.buffer).setUint32(0,A),x.set(w.types.mdat,4))}else return;x.set(G,g);const te=G.byteLength;g+=te,f.push(new Jm(!0,d,te,0)),_=$}const O=f.length;if(!O)return;const L=f[f.length-1];this.nextAudioPts=E=_+l*L.duration;const M=h?new Uint8Array(0):w.moof(e.sequenceNumber++,S/l,We({},e,{samples:f}));e.samples=[];const K=S/a,U=E/a,V={data1:M,data2:x,startPTS:K,endPTS:U,startDTS:K,endDTS:U,type:"audio",hasAudio:!0,hasVideo:!1,nb:O};return this.isAudioContiguous=!0,V}remuxEmptyAudio(e,t,r,s){const n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,u=d.baseTime*9e4/d.timescale,c=(l!==null?l:s.startDTS*n)+u,h=s.endDTS*n+u,f=o*Zm,m=Math.ceil((h-c)/f),p=Qm.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(I.warn("[mp4-remuxer]: remux empty Audio"),!p){I.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const g=[];for(let E=0;E<m;E++){const y=c+E*f;g.push({unit:p,pts:y,dts:y})}return e.samples=g,this.remuxAudio(e,t,r,!1)}}function Nt(i,e){let t;if(e===null)return i;for(e<i?t=-8589934592:t=8589934592;Math.abs(i-e)>4294967296;)i+=t;return i}function SS(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function Vg(i,e,t,r){const s=i.samples.length;if(!s)return;const n=i.inputTimeScale;for(let o=0;o<s;o++){const l=i.samples[o];l.pts=Nt(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=Nt(l.dts-r.baseTime*n/r.timescale,e*n)/n}const a=i.samples;return i.samples=[],{samples:a}}function qg(i,e,t){const r=i.samples.length;if(!r)return;const s=i.inputTimeScale;for(let a=0;a<r;a++){const o=i.samples[a];o.pts=Nt(o.pts-t.baseTime*s/t.timescale,e*s)/s}i.samples.sort((a,o)=>a.pts-o.pts);const n=i.samples;return i.samples=[],{samples:n}}class Jm{constructor(e,t,r,s){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=r,this.cts=s,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}class xS{constructor(){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}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,r,s){this.audioCodec=t,this.videoCodec=r,this.generateInitSegment(C1(e,s)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:r}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const s=this.initData=vg(e);s.audio&&(t=ep(s.audio,ye.AUDIO)),s.video&&(r=ep(s.video,ye.VIDEO));const n={};s.audio&&s.video?n.audiovideo={container:"video/mp4",codec:t+","+r,initSegment:e,id:"main"}:s.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:s.video?n.video={container:"video/mp4",codec:r,initSegment:e,id:"main"}:I.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,r,s,n,a){var o,l;let{initPTS:d,lastEndTime:u}=this;const c={audio:void 0,video:void 0,text:s,id3:r,initSegment:void 0};Y(u)||(u=this.lastEndTime=n||0);const h=t.samples;if(!(h!=null&&h.length))return c;const f={initPTS:void 0,timescale:1};let m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(h),m=this.initData),!((l=m)!=null&&l.length))return I.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),c;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const p=M1(h,m),g=D1(m,h),E=g===null?n:g;(kS(d,E,n,p)||f.timescale!==d.timescale&&a)&&(f.initPTS=E-n,d&&d.timescale===1&&I.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});const y=e?E-d.baseTime/d.timescale:u,b=y+p;O1(m,h,d.baseTime/d.timescale),p>0?this.lastEndTime=b:(I.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const S=!!m.audio,_=!!m.video;let x="";S&&(x+="audio"),_&&(x+="video");const A={data1:h,startPTS:y,startDTS:y,endPTS:b,endDTS:b,type:x,hasAudio:S,hasVideo:_,nb:1,dropped:0};return c.audio=A.type==="audio"?A:void 0,c.video=A.type!=="audio"?A:void 0,c.initSegment=f,c.id3=Vg(r,n,d,d),s.samples.length&&(c.text=qg(s,n,d)),c}}function kS(i,e,t,r){if(i===null)return!0;const s=Math.max(r,1),n=e-i.baseTime/i.timescale;return Math.abs(n-t)>s}function ep(i,e){const t=i==null?void 0:i.codec;if(t&&t.length>4)return t;if(e===ye.AUDIO){if(t==="ec-3"||t==="ac-3"||t==="alac")return t;if(t==="fLaC"||t==="Opus")return Ql(t,!1);const r="mp4a.40.5";return I.info(`Parsed audio codec "${t}" or audio object type not handled. Using "${r}"`),r}return I.warn(`Unhandled video codec "${t}"`),t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":"avc1.42e01e"}let Ui;try{Ui=self.performance.now.bind(self.performance)}catch{I.debug("Unable to use Performance API on this environment"),Ui=mn==null?void 0:mn.Date.now}const Mo=[{demux:cS,remux:xS},{demux:nr,remux:Do},{demux:dS,remux:Do},{demux:ES,remux:Do}];Mo.splice(2,0,{demux:hS,remux:Do});class tp{constructor(e,t,r,s,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=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=e,this.typeSupported=t,this.config=r,this.vendor=s,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,r,s){const n=r.transmuxing;n.executeStart=Ui();let a=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:l}=this;s&&(this.currentTransmuxState=s);const{contiguous:d,discontinuity:u,trackSwitch:c,accurateTimeOffset:h,timeOffset:f,initSegmentChange:m}=s||o,{audioCodec:p,videoCodec:g,defaultInitPts:E,duration:y,initSegmentData:b}=l,S=LS(a,t);if(S&&S.method==="AES-128"){const C=this.getDecrypter();if(C.isSync()){let O=C.softwareDecrypt(a,S.key.buffer,S.iv.buffer);if(r.part>-1&&(O=C.flush()),!O)return n.executeEnd=Ui(),cu(r);a=new Uint8Array(O)}else return this.decryptionPromise=C.webCryptoDecrypt(a,S.key.buffer,S.iv.buffer).then(O=>{const L=this.push(O,null,r);return this.decryptionPromise=null,L}),this.decryptionPromise}const _=this.needsProbing(u,c);if(_){const C=this.configureTransmuxer(a);if(C)return I.warn(`[transmuxer] ${C.message}`),this.observer.emit(v.ERROR,v.ERROR,{type:ie.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,fatal:!1,error:C,reason:C.message}),n.executeEnd=Ui(),cu(r)}(u||c||m||_)&&this.resetInitSegment(b,p,g,y,t),(u||m||_)&&this.resetInitialTimestamp(E),d||this.resetContiguity();const x=this.transmux(a,S,f,h,r),A=this.currentTransmuxState;return A.contiguous=!0,A.discontinuity=!1,A.trackSwitch=!1,n.executeEnd=Ui(),x}flush(e){const t=e.transmuxing;t.executeStart=Ui();const{decrypter:r,currentTransmuxState:s,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));const a=[],{timeOffset:o}=s;if(r){const c=r.flush();c&&a.push(this.push(c,null,e))}const{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=Ui(),[cu(e)];const u=l.flush(o);return Po(u)?u.then(c=>(this.flushRemux(a,c,e),a)):(this.flushRemux(a,u,e),a)}flushRemux(e,t,r){const{audioTrack:s,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;I.log(`[transmuxer.ts]: Flushed fragment ${r.sn}${r.part>-1?" p: "+r.part:""} of level ${r.level}`);const u=this.remuxer.remux(s,n,a,o,d,l,!0,this.id);e.push({remuxResult:u,chunkMeta:r}),r.transmuxing.executeEnd=Ui()}resetInitialTimestamp(e){const{demuxer:t,remuxer:r}=this;!t||!r||(t.resetTimeStamp(e),r.resetTimeStamp(e))}resetContiguity(){const{demuxer:e,remuxer:t}=this;!e||!t||(e.resetContiguity(),t.resetNextTimestamp())}resetInitSegment(e,t,r,s,n){const{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,r,s),o.resetInitSegment(e,t,r,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,r,s,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,r,s,n):a=this.transmuxUnencrypted(e,r,s,n),a}transmuxUnencrypted(e,t,r,s){const{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,t,r,!1,this.id),chunkMeta:s}}transmuxSampleAes(e,t,r,s,n){return this.demuxer.demuxSampleAes(e,t,r).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,r,s,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){const{config:t,observer:r,typeSupported:s,vendor:n}=this;let a;for(let h=0,f=Mo.length;h<f;h++){var o;if((o=Mo[h].demux)!=null&&o.probe(e)){a=Mo[h];break}}if(!a)return new Error("Failed to find demuxer by probing fragment data");const l=this.demuxer,d=this.remuxer,u=a.remux,c=a.demux;(!d||!(d instanceof u))&&(this.remuxer=new u(r,t,s,n)),(!l||!(l instanceof c))&&(this.demuxer=new c(r,t,s),this.probe=c.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new Qh(this.config)),e}}function LS(i,e){let t=null;return i.byteLength>0&&(e==null?void 0:e.key)!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const cu=i=>({remuxResult:{},chunkMeta:i});function Po(i){return"then"in i&&i.then instanceof Function}class IS{constructor(e,t,r,s,n){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=e,this.videoCodec=t,this.initSegmentData=r,this.duration=s,this.defaultInitPts=n||null}}class RS{constructor(e,t,r,s,n,a){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=e,this.contiguous=t,this.accurateTimeOffset=r,this.trackSwitch=s,this.timeOffset=n,this.initSegmentChange=a}}var Yg={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(t=!1));function s(l,d,u){this.fn=l,this.context=d,this.once=u||!1}function n(l,d,u,c,h){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new s(u,c||l,h),m=t?t+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new r:delete l._events[d]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],u,c;if(this._eventsCount===0)return d;for(c in u=this._events)e.call(u,c)&&d.push(t?c.slice(1):c);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(u)):d},o.prototype.listeners=function(d){var u=t?t+d:d,c=this._events[u];if(!c)return[];if(c.fn)return[c.fn];for(var h=0,f=c.length,m=new Array(f);h<f;h++)m[h]=c[h].fn;return m},o.prototype.listenerCount=function(d){var u=t?t+d:d,c=this._events[u];return c?c.fn?1:c.length:0},o.prototype.emit=function(d,u,c,h,f,m){var p=t?t+d:d;if(!this._events[p])return!1;var g=this._events[p],E=arguments.length,y,b;if(g.fn){switch(g.once&&this.removeListener(d,g.fn,void 0,!0),E){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,u),!0;case 3:return g.fn.call(g.context,u,c),!0;case 4:return g.fn.call(g.context,u,c,h),!0;case 5:return g.fn.call(g.context,u,c,h,f),!0;case 6:return g.fn.call(g.context,u,c,h,f,m),!0}for(b=1,y=new Array(E-1);b<E;b++)y[b-1]=arguments[b];g.fn.apply(g.context,y)}else{var S=g.length,_;for(b=0;b<S;b++)switch(g[b].once&&this.removeListener(d,g[b].fn,void 0,!0),E){case 1:g[b].fn.call(g[b].context);break;case 2:g[b].fn.call(g[b].context,u);break;case 3:g[b].fn.call(g[b].context,u,c);break;case 4:g[b].fn.call(g[b].context,u,c,h);break;default:if(!y)for(_=1,y=new Array(E-1);_<E;_++)y[_-1]=arguments[_];g[b].fn.apply(g[b].context,y)}}return!0},o.prototype.on=function(d,u,c){return n(this,d,u,c,!1)},o.prototype.once=function(d,u,c){return n(this,d,u,c,!0)},o.prototype.removeListener=function(d,u,c,h){var f=t?t+d:d;if(!this._events[f])return this;if(!u)return a(this,f),this;var m=this._events[f];if(m.fn)m.fn===u&&(!h||m.once)&&(!c||m.context===c)&&a(this,f);else{for(var p=0,g=[],E=m.length;p<E;p++)(m[p].fn!==u||h&&!m[p].once||c&&m[p].context!==c)&&g.push(m[p]);g.length?this._events[f]=g.length===1?g[0]:g:a(this,f)}return this},o.prototype.removeAllListeners=function(d){var u;return d?(u=t?t+d:d,this._events[u]&&a(this,u)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=t,o.EventEmitter=o,i.exports=o})(Yg);var wS=Yg.exports,sf=J_(wS);class jg{constructor(e,t,r,s){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=r,this.onFlush=s;const a=(d,u)=>{u=u||{},u.frag=this.frag,u.id=this.id,d===v.ERROR&&(this.error=u.error),this.hls.trigger(d,u)};this.observer=new sf,this.observer.on(v.FRAG_DECRYPTED,a),this.observer.on(v.ERROR,a);const o=ds(n.preferManagedMediaSource)||{isTypeSupported:()=>!1},l={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:o.isTypeSupported('audio/mp4; codecs="ac-3"')};if(this.useWorker&&typeof Worker<"u"&&(n.workerPath||zA())){try{n.workerPath?(I.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=QA(n.workerPath)):(I.log(`injecting Web Worker for "${t}"`),this.workerContext=XA()),this.onwmsg=c=>this.onWorkerMessage(c);const{worker:u}=this.workerContext;u.addEventListener("message",this.onwmsg),u.onerror=c=>{const h=new Error(`${c.message} (${c.filename}:${c.lineno})`);n.enableWorker=!1,I.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},u.postMessage({cmd:"init",typeSupported:l,vendor:"",id:t,config:JSON.stringify(n)})}catch(u){I.warn(`Error setting up "${t}" Web Worker, fallback to inline`,u),this.resetWorker(),this.error=null,this.transmuxer=new tp(this.observer,l,n,"",t)}return}this.transmuxer=new tp(this.observer,l,n,"",t)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,r,s,n,a,o,l,d,u){var c,h;d.transmuxing.start=self.performance.now();const{transmuxer:f}=this,m=a?a.start:n.start,p=n.decryptdata,g=this.frag,E=!(g&&n.cc===g.cc),y=!(g&&d.level===g.level),b=g?d.sn-g.sn:-1,S=this.part?d.part-this.part.index:-1,_=b===0&&d.id>1&&d.id===(g==null?void 0:g.stats.chunkCount),x=!y&&(b===1||b===0&&(S===1||_&&S<=0)),A=self.performance.now();(y||b||n.stats.parsing.start===0)&&(n.stats.parsing.start=A),a&&(S||!x)&&(a.stats.parsing.start=A);const C=!(g&&((c=n.initSegment)==null?void 0:c.url)===((h=g.initSegment)==null?void 0:h.url)),O=new RS(E,x,l,y,m,C);if(!x||E||C){I.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
30
30
  discontinuity: ${E}
31
31
  trackSwitch: ${y}
32
32
  contiguous: ${x}
33
33
  accurateTimeOffset: ${l}
34
34
  timeOffset: ${m}
35
- initSegmentChange: ${C}`);const L=new kS(r,s,t,o,u);this.configureTransmuxer(L)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:d,state:O},e instanceof ArrayBuffer?[e]:[]);else if(f){const L=f.push(e,p,d,O);Do(L)?(f.async=!0,L.then(M=>{this.handleTransmuxComplete(M)}).catch(M=>{this.transmuxerError(M,d,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(L))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);Do(r)||t.async?(Do(r)||(r=Promise.resolve(r)),r.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(r=>{this.handleTransmuxComplete(r)}),this.onFlush(t)}onWorkerMessage(e){const t=e.data;if(!(t!=null&&t.event)){I.warn(`worker message received with no ${t?"event name":"data"}`);return}const r=this.hls;if(this.hls)switch(t.event){case"init":{var s;const n=(s=this.workerContext)==null?void 0:s.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":I[t.data.logType]&&I[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}}configureTransmuxer(e){const{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}function Yg(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!pn(i[t].attrs,e[t].attrs))return!1;return!0}function pn(i,e,t){const r=i["STABLE-RENDITION-ID"];return r&&!t?r===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(s=>i[s]!==e[s])}function ec(i,e){return e.label.toLowerCase()===i.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(i.lang||"").toLowerCase())}const ep=100;class RS extends Xh{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",ee.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-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.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.ERROR,this.onError,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){if(r==="main"){const a=t.cc;this.initPTS[t.cc]={baseTime:s,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${s}`),this.videoTrackCC=a,this.state===N.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=N.STOPPED;return}const t=this.lastCurrentTime;this.stopLoad(),this.setInterval(ep),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=N.IDLE):(this.loadedmetadata=!1,this.state=N.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case N.IDLE:this.doTickIdle();break;case N.WAITING_TRACK:{var e;const{levels:r,trackId:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=N.WAITING_INIT_PTS}break}case N.FRAG_LOADING_WAITING_RETRY:{var t;const r=performance.now(),s=this.retryDate;if(!s||r>=s||(t=this.media)!=null&&t.seeking){const{levels:n,trackId:a}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((n==null?void 0:n[a])||null),this.state=N.IDLE}break}case N.WAITING_INIT_PTS:{const r=this.waitingData;if(r){const{frag:s,part:n,cache:a,complete:o}=r;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=N.FRAG_LOADING;const l=a.flush(),d={frag:s,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(d),o&&super._handleFragmentLoadComplete(d)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const l=this.getLoadPosition(),d=Le.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);Zu(d.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${d.end} is needed`),this.clearWaitingFragment())}}else this.state=N.IDLE}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=N.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:e,levels:t,media:r,trackId:s}=this,n=e.config;if(!r&&(this.startFragRequested||!n.startFragPrefetch)||!(t!=null&&t[s]))return;const a=t[s],o=a.details;if(!o||o.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(o)){this.state=N.WAITING_TRACK;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,ye.AUDIO,ee.AUDIO));const d=this.getFwdBufferInfo(l,ee.AUDIO);if(d===null)return;const{bufferedTrack:u,switchingTrack:c}=this;if(!c&&this._streamEnded(d,o)){e.trigger(v.BUFFER_EOS,{type:"audio"}),this.state=N.ENDED;return}const h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,ee.MAIN),f=d.len,m=this.getMaxBufferLength(h==null?void 0:h.len),p=o.fragments,g=p[0].start;let E=this.flushing?this.getLoadPosition():d.end;if(c&&r){const _=this.getLoadPosition();u&&!pn(c.attrs,u.attrs)&&(E=_),o.PTSKnown&&_<g&&(d.end>g||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=g+.05)}if(f>=m&&!c&&E<p[p.length-1].start)return;let y=this.getNextFragment(E,o),b=!1;if(y&&this.isLoopLoading(y,E)&&(b=!!y.gap,y=this.getNextFragmentLoopLoading(y,o,d,ee.MAIN,m)),!y){this.bufferFlushed=!0;return}const S=h&&y.start>h.end+o.targetduration;if(S||!(h!=null&&h.len)&&d.len){const _=this.getAppendedFrag(y.start,ee.MAIN);if(_===null||(b||(b=!!_.gap||!!S&&h.len===0),S&&!b||b&&d.nextStart&&d.nextStart<_.end))return}this.loadFragment(y,a,E)}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(r=>new mn(r))}onAudioTrackSwitching(e,t){const r=!!t.url;this.trackId=t.id;const{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),r?this.setInterval(ep):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=N.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=N.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(v.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}const{levels:s}=this,{details:n,id:a}=t;if(!s){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Audio track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const o=s[a];let l=0;if(n.live||(r=o.details)!=null&&r.live){this.checkLiveUpdate(n);const u=this.mainDetails;if(n.deltaUpdateFailed||!u)return;if(!o.details&&n.hasProgramDateTime&&u.hasProgramDateTime)ed(n,u),l=n.fragments[0].start;else{var d;l=this.alignPlaylists(n,o.details,(d=this.levelLastLoaded)==null?void 0:d.details)}}o.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(this.mainDetails||n,l),this.state===N.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=N.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:r,part:s,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}const d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}const u=d.details;if(!u){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}const c=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2";let h=this.transmuxer;h||(h=this.transmuxer=new qg(this.hls,ee.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const f=this.initPTS[r.cc],m=(t=r.initSegment)==null?void 0:t.data;if(f!==void 0){const g=s?s.index:-1,E=g!==-1,y=new jh(r.level,r.sn,r.stats.chunkCount,n.byteLength,g,E);h.push(n,m,c,"",r,s,u.totalduration,!1,y,f)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${u.startSN} ,${u.endSN}],track ${o}`);const{cache:p}=this.waitingData=this.waitingData||{frag:r,part:s,cache:new wg,complete:!1};p.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=N.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){const r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){const{frag:r,part:s}=t;if(r.type!==ee.AUDIO){if(!this.loadedmetadata&&r.type===ee.MAIN){const n=this.videoBuffer||this.media;n&&Le.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(r.sn!=="initSegment"){this.fragPrevious=r;const n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(v.AUDIO_TRACK_SWITCHED,dt({},n)))}this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=N.ERROR;return}switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ee.AUDIO,t);break;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_TRACK&&((r=t.context)==null?void 0:r.type)===fe.AUDIO_TRACK&&(this.state=N.IDLE);break;case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;if(t.details===D.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==ye.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==ye.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===N.ENDED&&(this.state=N.IDLE);const r=this.mediaBuffer||this.media;r&&(this.afterBufferFlushed(r,t,ee.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const r="audio",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:d,level:u}=o,{details:c}=u,{audio:h,text:f,id3:m,initSegment:p}=n;if(this.fragContextChanged(l)||!c){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),p!=null&&p.tracks){const g=l.initSegment||l;this._bufferInitSegment(u,p.tracks,g,a),s.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:r,tracks:p.tracks})}if(h){const{startPTS:g,endPTS:E,startDTS:y,endDTS:b}=h;d&&(d.elementaryStreams[ye.AUDIO]={startPTS:g,endPTS:E,startDTS:y,endDTS:b}),l.setElementaryStreamInfo(ye.AUDIO,g,E,y,b),this.bufferFragmentData(h,l,d,a)}if(m!=null&&(t=m.samples)!=null&&t.length){const g=We({id:r,frag:l,details:c},m);s.trigger(v.FRAG_PARSING_METADATA,g)}if(f){const g=We({id:r,frag:l,details:c},f);s.trigger(v.FRAG_PARSING_USERDATA,g)}}_bufferInitSegment(e,t,r,s){if(this.state!==N.PARSING)return;t.video&&delete t.video;const n=t.audio;if(!n)return;n.id="audio";const a=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${a}/${n.codec}]`),a&&a.split(",").length===1&&(n.levelCodec=a),this.hls.trigger(v.BUFFER_CODECS,t);const o=n.initSegment;if(o!=null&&o.byteLength){const l={type:"audio",frag:r,part:null,chunkMeta:s,parent:r.type,data:o};this.hls.trigger(v.BUFFER_APPENDING,l)}this.tickImmediate()}loadFragment(e,t,r){const s=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||s===nt.NOT_LOADED||s===nt.PARTIAL){var n;if(e.sn==="initSegment")this._loadInitSegment(e,t);else if((n=t.details)!=null&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=N.WAITING_INIT_PTS;const a=this.mainDetails;a&&a.fragments[0].start!==t.details.fragments[0].start&&ed(t.details,a)}else this.startFragRequested=!0,super.loadFragment(e,t,r)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){const{media:t,bufferedTrack:r}=this,s=r==null?void 0:r.attrs,n=e.attrs;t&&s&&(s.CHANNELS!==n.CHANNELS||r.name!==e.name||r.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(v.AUDIO_TRACK_SWITCHED,dt({},e))}}class wS extends Yh{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.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(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Audio track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Audio track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.audioGroups||null,s=this.groupIds;let n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(o=>(s==null?void 0:s.indexOf(o))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const o=this.tracks.filter(h=>!r||r.indexOf(h.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(h=>h.default)&&(this.selectDefaultTrack=!1),o.forEach((h,f)=>{h.id=f});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;const l=this.hls.config.audioPreference;if(!n&&l){const h=bi(l,o,Es);if(h>-1)n=o[h];else{const f=bi(l,this.tracks);n=this.tracks[f]}}let d=this.findTrackId(n);d===-1&&n&&(d=this.findTrackId(null));const u={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${r==null?void 0:r.join(",")}`),this.hls.trigger(v.AUDIO_TRACKS_UPDATED,u);const c=this.trackId;if(d!==-1&&c===-1)this.setAudioTrack(d);else if(o.length&&c===-1){var a;const h=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(h.message),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:h})}}else this.shouldReloadPlaylist(n)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===fe.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&(this.requestScheduled=-1,this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){const s=this.currentTrack;if(s&&en(e,s,Es))return s;const n=bi(e,this.tracksInGroup,Es);if(n>-1){const a=this.tracksInGroup[n];return this.setAudioTrack(n),a}else if(s){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);const o=wA(e,t.levels,r,a,Es);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){const a=bi(e,r);if(a>-1)return r[a]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;const r=this.currentTrack,s=t[e],n=s.details&&!s.details.live;if(e===this.trackId&&s===r&&n||(this.log(`Switching to audio-track ${e} "${s.name}" lang:${s.lang} group:${s.groupId} channels:${s.channels}`),this.trackId=e,this.currentTrack=s,this.hls.trigger(v.AUDIO_TRACK_SWITCHING,dt({},s)),n))return;const a=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(a)}findTrackId(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const s=t[r];if(!(this.selectDefaultTrack&&!s.default)&&(!e||en(e,s,Es)))return r}if(e){const{name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l}=e;for(let d=0;d<t.length;d++){const u=t[d];if(en({name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l},u,Es))return d}for(let d=0;d<t.length;d++){const u=t[d];if(pn(e.attrs,u.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){const u=t[d];if(pn(e.attrs,u.attrs,["LANGUAGE"]))return d}}return-1}loadPlaylist(e){const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();const r=t.id,s=t.groupId;let n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${r} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(v.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}}const tp=500;class CS extends Xh{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",ee.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.ERROR,this.onError,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.ERROR,this.onError,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=N.IDLE,this.setInterval(tp),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:r,success:s}=t;if(this.fragPrevious=r,this.state=N.IDLE,!s)return;const n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a;const o=r.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}const l=r.start+r.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null)}onBufferFlushing(e,t){const{startOffset:r,endOffset:s}=t;if(r===0&&s!==Number.POSITIVE_INFINITY){const n=s-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(r,n,ee.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===ee.MAIN){var r;(r=this.media)!=null&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){const r=t.frag;(r==null?void 0:r.type)===ee.SUBTITLE&&(t.details===D.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==N.STOPPED&&(this.state=N.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&Yg(this.levels,t)){this.levels=t.map(r=>new mn(r));return}this.tracksBuffered=[],this.levels=t.map(r=>{const s=new mn(r);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,ee.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var r;if(this.currentTrackId=t.id,!((r=this.levels)!=null&&r.length)||this.currentTrackId===-1){this.clearInterval();return}const s=this.levels[this.currentTrackId];s!=null&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.setInterval(tp)}onSubtitleTrackLoaded(e,t){var r;const{currentTrackId:s,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}const l=n[o];if(o>=n.length||!l)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(a.live||(r=l.details)!=null&&r.live){const c=this.mainDetails;if(a.deltaUpdateFailed||!c)return;const h=c.fragments[0];if(!l.details)a.hasProgramDateTime&&c.hasProgramDateTime?(ed(a,c),d=a.fragments[0].start):h&&(d=h.start,Qu(a,d));else{var u;d=this.alignPlaylists(a,l.details,(u=this.levelLastLoaded)==null?void 0:u.details),d===0&&h&&(d=h.start,Qu(a,d))}}l.details=a,this.levelLastLoaded=l,o===s&&(!this.startFragRequested&&(this.mainDetails||!a.live)&&this.setStartPosition(this.mainDetails||a,d),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===N.IDLE&&(Jl(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0)))}_handleFragmentLoadComplete(e){const{frag:t,payload:r}=e,s=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&s!=null&&s.key&&s.iv&&s.method==="AES-128"){const a=performance.now();this.decrypter.decrypt(new Uint8Array(r),s.key.buffer,s.iv.buffer).catch(o=>{throw n.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{const l=performance.now();n.trigger(v.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=N.IDLE})}}doTick(){if(!this.media){this.state=N.IDLE;return}if(this.state===N.IDLE){const{currentTrackId:e,levels:t}=this,r=t==null?void 0:t[e];if(!r||!t.length||!r.details)return;const{config:s}=this,n=this.getLoadPosition(),a=Le.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,ee.MAIN),u=r.details,c=this.getMaxBufferLength(d==null?void 0:d.len)+u.levelTargetDuration;if(l>c)return;const h=u.fragments,f=h.length,m=u.edge;let p=null;const g=this.fragPrevious;if(o<m){const E=s.maxFragLookUpTolerance,y=o>m-E?0:E;p=Jl(g,h,Math.max(h[0].start,o),y),!p&&g&&g.start<h[0].start&&(p=h[0])}else p=h[f-1];if(!p)return;if(p=this.mapToInitFragWhenRequired(p),p.sn!=="initSegment"){const E=p.sn-u.startSN,y=h[E-1];y&&y.cc===p.cc&&this.fragmentTracker.getState(y)===nt.NOT_LOADED&&(p=y)}this.fragmentTracker.getState(p)===nt.NOT_LOADED&&this.loadFragment(p,r,o)}}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new DS(this.tracksBuffered[this.currentTrackId]||[])}}class DS{constructor(e){this.buffered=void 0;const t=(r,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${r}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][r]};this.buffered={get length(){return e.length},end(r){return t("end",r,e.length)},start(r){return t("start",r,e.length)}}}}class MS extends Yh{constructor(e){super(e,"[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.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const r=Lo(this.media.textTracks);for(let n=0;n<r.length;n++)if(r[n].mode==="hidden")t=r[n];else if(r[n].mode==="showing"){t=r[n];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(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.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(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Lo(this.media.textTracks).forEach(t=>{zs(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Subtitle track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Subtitle track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.subtitleGroups||null,s=this.groupIds;let n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(a=>(s==null?void 0:s.indexOf(a))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const a=this.tracks.filter(u=>!r||r.indexOf(u.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(u=>u.default)&&(this.selectDefaultTrack=!1),a.forEach((u,c)=>{u.id=c});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;const o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=!1;const u=bi(o,a);if(u>-1)n=a[u];else{const c=bi(o,this.tracks);n=this.tracks[c]}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));const d={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${r==null?void 0:r.join(",")}" group-id`),this.hls.trigger(v.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.trackId===-1&&this.setSubtitleTrack(l)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){const t=this.tracksInGroup,r=this.selectDefaultTrack;for(let s=0;s<t.length;s++){const n=t[s];if(!(r&&!n.default||!r&&!e)&&(!e||en(n,e)))return s}if(e){for(let s=0;s<t.length;s++){const n=t[s];if(pn(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<t.length;s++){const n=t[s];if(pn(e.attrs,n.attrs,["LANGUAGE"]))return s}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const s=t[r];if(ec(s,e))return r}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===fe.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const r=this.currentTrack;if(r&&en(e,r))return r;const s=bi(e,this.tracksInGroup);if(s>-1){const n=this.tracksInGroup[s];return this.setSubtitleTrack(s),n}else{if(r)return null;{const n=bi(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){const r=t.id,s=t.groupId;let n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(v.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=Lo(e.textTracks),r=this.currentTrack;let s;if(r&&(s=t.filter(n=>ec(r,n))[0],s||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(t).forEach(n=>{n.mode!=="disabled"&&n!==s&&(n.mode="disabled")}),s){const n=this.subtitleDisplay?"showing":"hidden";s.mode!==n&&(s.mode=n)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!Y(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;const r=this.currentTrack,s=t[e]||null;if(this.trackId=e,this.currentTrack=s,this.toggleTrackModes(),!s){this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:e});return}const n=!!s.details&&!s.details.live;if(e===this.trackId&&s===r&&n)return;this.log(`Switching to subtitle-track ${e}`+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:""));const{id:a,groupId:o="",name:l,type:d,url:u}=s;this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:u});const c=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(c)}}class PS{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,r){const s=this.queues[t];s.push(e),s.length===1&&!r&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t;const r=new Promise(n=>{t=n}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),r}executeNext(e){const t=this.queues[e];if(t.length){const r=t[0];try{r.execute()}catch(s){I.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${s}`),r.onError(s);const n=this.buffers[e];n!=null&&n.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const ip=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;class OS{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=r=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=r=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{const{media:r,mediaSource:s}=this;this.log("Media source opened"),r&&(r.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(v.MEDIA_ATTACHED,{media:r,mediaSource:s})),s&&s.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:r,_objectUrl:s}=this;r!==s&&I.error(`Media element src was set while attaching MediaSource (${s} > ${r})`)},this.hls=e;const t="[buffer-controller]";this.appendSource=K1(ds(e.config.preferManagedMediaSource)),this.log=I.log.bind(I,t),this.warn=I.warn.bind(I,t),this.error=I.error.bind(I,t),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_APPENDING,this.onBufferAppending,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.BUFFER_EOS,this.onBufferEos,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(v.FRAG_PARSED,this.onFragParsed,this),e.on(v.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_APPENDING,this.onBufferAppending,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.BUFFER_EOS,this.onBufferEos,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(v.FRAG_PARSED,this.onFragParsed,this),e.off(v.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new PS(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){const r=this.media=t.media,s=ds(this.appendSource);if(r&&s){var n;const a=this.mediaSource=new s;this.log(`created media source: ${(n=a.constructor)==null?void 0:n.name}`),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));const o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");const l=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||l&&a instanceof l,rp(r),NS(r,o),r.load()}catch{r.src=o}else r.src=o;r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){this.warn(`onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&rp(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(v.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e)}),this._initSourceBuffer()}resetBuffer(e){const t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(s){this.warn(`onBufferReset ${e}`,s)}}onBufferCodecs(e,t){const r=this.getSourceBufferTypes().length,s=Object.keys(t);if(s.forEach(a=>{if(r){const l=this.tracks[a];if(l&&typeof l.buffer.changeType=="function"){var o;const{id:d,codec:u,levelCodec:c,container:h,metadata:f}=t[a],m=Sm(l.codec,l.levelCodec),p=m==null?void 0:m.replace(ip,"$1");let g=Sm(u,c);const E=(o=g)==null?void 0:o.replace(ip,"$1");if(g&&p!==E){a.slice(0,5)==="audio"&&(g=zl(g,this.appendSource));const y=`${h};codecs=${g}`;this.appendChangeType(a,y),this.log(`switching codec ${m} to ${g}`),this.tracks[a]={buffer:l.buffer,codec:u,container:h,levelCodec:c,metadata:f,id:d}}}}else this.pendingTracks[a]=t[a]}),r)return;const n=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==n&&(this.log(`${n} bufferCodec event(s) expected ${s.join(",")}`),this.bufferCodecEventsExpected=n),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}appendChangeType(e,t){const{operationQueue:r}=this,s={execute:()=>{const n=this.sourceBuffer[e];n&&(this.log(`changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{this.warn(`Failed to change ${e} SourceBuffer type`,n)}};r.append(s,e,!!this.pendingTracks[e])}onBufferAppending(e,t){const{hls:r,operationQueue:s,tracks:n}=this,{data:a,type:o,frag:l,part:d,chunkMeta:u}=t,c=u.buffering[o],h=self.performance.now();c.start=h;const f=l.stats.buffering,m=d?d.stats.buffering:null;f.start===0&&(f.start=h),m&&m.start===0&&(m.start=h);const p=n.audio;let g=!1;o==="audio"&&(p==null?void 0:p.container)==="audio/mpeg"&&(g=!this.lastMpegAudioChunk||u.id===1||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);const E=l.start,y={execute:()=>{if(c.executeStart=self.performance.now(),g){const b=this.sourceBuffer[o];if(b){const S=E-b.timestampOffset;Math.abs(S)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${E} (delta: ${S}) sn: ${l.sn})`),b.timestampOffset=E)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{const b=self.performance.now();c.executeEnd=c.end=b,f.first===0&&(f.first=b),m&&m.first===0&&(m.first=b);const{sourceBuffer:S}=this,_={};for(const x in S)_[x]=Le.getBuffered(S[x]);this.appendErrors[o]=0,o==="audio"||o==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(v.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:u,parent:l.type,timeRanges:_})},onError:b=>{const S={type:ie.MEDIA_ERROR,parent:l.type,details:D.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:d,chunkMeta:u,error:b,err:b,fatal:!1};if(b.code===DOMException.QUOTA_EXCEEDED_ERR)S.details=D.BUFFER_FULL_ERROR;else{const _=++this.appendErrors[o];S.details=D.BUFFER_APPEND_ERROR,this.warn(`Failed ${_}/${r.config.appendErrorMaxRetry} times to append segment in "${o}" sourceBuffer`),_>=r.config.appendErrorMaxRetry&&(S.fatal=!0)}r.trigger(v.ERROR,S)}};s.append(y,o,!!this.pendingTracks[o])}onBufferFlushing(e,t){const{operationQueue:r}=this,s=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(v.BUFFER_FLUSHED,{type:n})},onError:a=>{this.warn(`Failed to remove from ${n} SourceBuffer`,a)}});t.type?r.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{r.append(s(n),n)})}onFragParsed(e,t){const{frag:r,part:s}=t,n=[],a=s?s.elementaryStreams:r.elementaryStreams;a[ye.AUDIOVIDEO]?n.push("audiovideo"):(a[ye.AUDIO]&&n.push("audio"),a[ye.VIDEO]&&n.push("video"));const o=()=>{const l=self.performance.now();r.stats.buffering.end=l,s&&(s.stats.buffering.end=l);const d=s?s.stats:r.stats;this.hls.trigger(v.FRAG_BUFFERED,{frag:r,part:s,stats:d,id:r.type})};n.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(o,n)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((s,n)=>{const a=this.sourceBuffer[n];return a&&(!t.type||t.type===n)&&(a.ending=!0,a.ended||(a.ended=!0,this.log(`${n} sourceBuffer now EOS`))),s&&!!(!a||a.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{const a=this.sourceBuffer[n];a&&(a.ending=!1)});const{mediaSource:s}=this;if(!s||s.readyState!=="open"){s&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${s.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),s.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){const{hls:e,details:t,media:r}=this;if(!r||t===null||!this.getSourceBufferTypes().length)return;const n=e.config,a=r.currentTime,o=t.levelTargetDuration,l=t.live&&n.liveBackBufferLength!==null?n.liveBackBufferLength:n.backBufferLength;if(Y(l)&&l>0){const d=Math.max(l,o),u=Math.floor(a/o)*o-d;this.flushBackBuffer(a,o,u)}if(Y(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){const d=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),u=Math.max(d,o),c=Math.floor(a/o)*o+u;this.flushFrontBuffer(a,o,c)}}flushBackBuffer(e,t,r){const{details:s,sourceBuffer:n}=this;this.getSourceBufferTypes().forEach(o=>{const l=n[o];if(l){const d=Le.getBuffered(l);if(d.length>0&&r>d.start(0)){if(this.hls.trigger(v.BACK_BUFFER_REACHED,{bufferEnd:r}),s!=null&&s.live)this.hls.trigger(v.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(l.ended&&d.end(d.length-1)-e<t*2){this.log(`Cannot flush ${o} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:o})}}})}flushFrontBuffer(e,t,r){const{sourceBuffer:s}=this;this.getSourceBufferTypes().forEach(a=>{const o=s[a];if(o){const l=Le.getBuffered(o),d=l.length;if(d<2)return;const u=l.start(d-1),c=l.end(d-1);if(r>u||e>=u&&e<=c)return;if(o.ended&&e-c<2*t){this.log(`Cannot flush ${a} front buffer while SourceBuffer is in ended state`);return}this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:a})}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:e,hls:t,media:r,mediaSource:s}=this,n=e.fragments[0].start+e.totalduration,a=r.duration,o=Y(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(s.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!Y(a))&&(this.log(`Updating Media Source duration to ${n.toFixed(3)}`),s.duration=n)}updateSeekableRange(e){const t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){const n=Math.max(0,r[0].start),a=Math.max(n,n+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${n}-${a}.`),t.setLiveSeekableRange(n,a)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,s=Object.keys(r).length;if(s&&(!e||s===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};const n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(v.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{t.executeNext(a)});else{const a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){const{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(const n in e)if(!t[n]){var s;const a=e[n];if(!a)throw Error(`source buffer exists for track ${n}, however track does not`);let o=((s=a.levelCodec)==null?void 0:s.indexOf(","))===-1?a.levelCodec:a.codec;o&&n.slice(0,5)==="audio"&&(o=zl(o,this.appendSource));const l=`${a.container};codecs=${o}`;this.log(`creating sourceBuffer(${l})`);try{const d=t[n]=r.addSourceBuffer(l),u=n;this.addBufferListener(u,"updatestart",this._onSBUpdateStart),this.addBufferListener(u,"updateend",this._onSBUpdateEnd),this.addBufferListener(u,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(u,"bufferedchange",(c,h)=>{const f=h.removedRanges;f!=null&&f.length&&this.hls.trigger(v.BUFFER_FLUSHED,{type:n})}),this.tracks[n]={buffer:d,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(d){this.error(`error while trying to add sourceBuffer: ${d.message}`),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,sourceBufferName:n,mimeType:l})}}}get mediaSrc(){var e,t;const r=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return r==null?void 0:r.src}_onSBUpdateStart(e){const{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const{operationQueue:r}=this;r.current(e).onComplete(),r.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var r;const s=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(r=this.mediaSource)==null?void 0:r.readyState}`);this.error(`${s}`,t),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});const n=this.operationQueue.current(e);n&&n.onError(s)}removeExecutor(e,t,r){const{media:s,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!s||!n||!l){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}const d=Y(s.duration)?s.duration:1/0,u=Y(n.duration)?n.duration:1/0,c=Math.max(0,t),h=Math.min(r,d,u);h>c&&(!l.ending||l.ended)?(l.ended=!1,this.log(`Removing [${c},${h}] from the ${e} SourceBuffer`),l.remove(c,h)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){const r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);return}r.ended=!1,r.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}const{operationQueue:r}=this,s=t.map(n=>r.appendBlocker(n));Promise.all(s).then(()=>{e(),t.forEach(n=>{const a=this.sourceBuffer[n];a!=null&&a.updating||r.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){const s=this.sourceBuffer[e];if(!s)return;const n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),s.addEventListener(t,n)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(r=>{t.removeEventListener(r.event,r.listener)})}}function rp(i){const e=i.querySelectorAll("source");[].slice.call(e).forEach(t=>{i.removeChild(t)})}function NS(i,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,i.appendChild(t)}const FS={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},jg=i=>String.fromCharCode(FS[i]||i),Wt=15,wi=100,US={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},$S={17:2,18:4,21:6,22:8,23:10,19:13,20:15},BS={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},GS={25:2,26:4,29:6,30:8,31:10,27:13,28:15},HS=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class WS{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const r=typeof t=="function"?t():t;I.log(`${this.time} [${e}] ${r}`)}}}const br=function(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t};class zg{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(e){const t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){const s=t[r];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class KS{constructor(){this.uchar=" ",this.penState=new zg}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class VS{constructor(e){this.chars=[],this.pos=0,this.currPenState=new zg,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<wi;t++)this.chars.push(new KS);this.logger=e}equals(e){for(let t=0;t<wi;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<wi;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<wi;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>wi&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=wi)}moveCursor(e){const t=this.pos+e;if(e>1)for(let r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=jg(e);if(this.pos>=wi){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<wi;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let r=0;r<wi;r++){const s=this.chars[r].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class uu{constructor(e){this.rows=[],this.currRow=Wt-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Wt;t++)this.rows.push(new VS(e));this.logger=e}reset(){for(let e=0;e<Wt;e++)this.rows[e].clear();this.currRow=Wt-1}equals(e){let t=!0;for(let r=0;r<Wt;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<Wt;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Wt;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<Wt;o++)this.rows[o].clear();const n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){const o=a.rows[n].cueStartTime,l=this.logger.time;if(o!==null&&l!==null&&o<l)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[n+d])}}this.currRow=t;const r=this.rows[this.currRow];if(e.indent!==null){const n=e.indent,a=Math.max(n-1,0);r.setCursor(e.indent),e.color=r.chars[a].penState.foreground}const s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let r="",s=-1;for(let n=0;n<Wt;n++){const a=this.rows[n].getTextString();a&&(s=n+1,e?t.push("Row "+s+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?r="["+t.join(" | ")+"]":r=t.join(`
36
- `)),r}getTextAndFormat(){return this.rows}}class sp{constructor(e,t,r){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=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new uu(r),this.nonDisplayedMemory=new uu(r),this.lastOutputScreen=new uu(r),this.currRollUpRow=this.displayedMemory.rows[Wt-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[Wt-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(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"),this.mode!=="MODE_TEXT"&&(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(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}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"),this.mode==="MODE_POP-ON"){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const r=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class np{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=YS(),this.logger=void 0;const s=this.logger=new WS;this.channels=[null,new sp(e,t,s),new sp(e+1,r,s)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let r=0;r<t.length;r+=2){const s=t[r]&127,n=t[r+1]&127;let a=!1,o=null;if(s===0&&n===0)continue;this.logger.log(3,()=>"["+br([t[r],t[r+1]])+"] -> ("+br([s,n])+")");const l=this.cmdHistory;if(s>=16&&s<=31){if(qS(s,n,l)){io(null,null,l),this.logger.log(3,()=>"Repeated command ("+br([s,n])+") is dropped");continue}io(s,n,this.cmdHistory),a=this.parseCmd(s,n),a||(a=this.parseMidrow(s,n)),a||(a=this.parsePAC(s,n)),a||(a=this.parseBackgroundAttributes(s,n))}else io(null,null,l);if(!a&&(o=this.parseChars(s,n),o)){const u=this.currentChannel;u&&u>0?this.channels[u].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+br([s,n])+" orig: "+br([t[r],t[r+1]]))}}parseCmd(e,t){const r=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=33&&t<=35;if(!(r||s))return!1;const n=e===20||e===21||e===23?1:2,a=this.channels[n];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),this.currentChannel=n,!0}parseMidrow(e,t){let r=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?r=1:r=2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const s=this.channels[r];return s?(s.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+br([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let r;const s=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(s||n))return!1;const a=e<=23?1:2;t>=64&&t<=95?r=a===1?US[e]:BS[e]:r=a===1?$S[e]:GS[e];const o=this.channels[a];return o?(o.setPAC(this.interpretPAC(r,t)),this.currentChannel=a,!0):!1}interpretPAC(e,t){let r;const s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?r=t-96:r=t-64,s.underline=(r&1)===1,r<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((r-16)/2)*4,s}parseChars(e,t){let r,s=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,()=>"Special char '"+jg(a)+"' in channel "+r),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);return s&&this.logger.log(3,()=>"Char codes = "+br(s).join(",")),s}parseBackgroundAttributes(e,t){const r=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(r||s))return!1;let n;const a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=HS[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));const o=e<=23?1:2;return this.channels[o].setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}io(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const r=this.channels[t];r&&r.cueSplitAtTime(e)}}}function io(i,e,t){t.a=i,t.b=e}function qS(i,e,t){return t.a===i&&t.b===e}function YS(){return{a:null,b:null}}class ro{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var rf=function(){if(fn!=null&&fn.VTTCue)return self.VTTCue;const i=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;const d=l.toLowerCase();return~o.indexOf(d)?d:!1}function r(o){return t(i,o)}function s(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){const u=arguments[d];for(const c in u)o[c]=u[c]}return o}function a(o,l,d){const u=this,c={enumerable:!0};u.hasBeenReset=!1;let h="",f=!1,m=o,p=l,g=d,E=null,y="",b=!0,S="auto",_="start",x=50,A="middle",C=50,O="middle";Object.defineProperty(u,"id",n({},c,{get:function(){return h},set:function(L){h=""+L}})),Object.defineProperty(u,"pauseOnExit",n({},c,{get:function(){return f},set:function(L){f=!!L}})),Object.defineProperty(u,"startTime",n({},c,{get:function(){return m},set:function(L){if(typeof L!="number")throw new TypeError("Start time must be set to a number.");m=L,this.hasBeenReset=!0}})),Object.defineProperty(u,"endTime",n({},c,{get:function(){return p},set:function(L){if(typeof L!="number")throw new TypeError("End time must be set to a number.");p=L,this.hasBeenReset=!0}})),Object.defineProperty(u,"text",n({},c,{get:function(){return g},set:function(L){g=""+L,this.hasBeenReset=!0}})),Object.defineProperty(u,"region",n({},c,{get:function(){return E},set:function(L){E=L,this.hasBeenReset=!0}})),Object.defineProperty(u,"vertical",n({},c,{get:function(){return y},set:function(L){const M=r(L);if(M===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=M,this.hasBeenReset=!0}})),Object.defineProperty(u,"snapToLines",n({},c,{get:function(){return b},set:function(L){b=!!L,this.hasBeenReset=!0}})),Object.defineProperty(u,"line",n({},c,{get:function(){return S},set:function(L){if(typeof L!="number"&&L!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");S=L,this.hasBeenReset=!0}})),Object.defineProperty(u,"lineAlign",n({},c,{get:function(){return _},set:function(L){const M=s(L);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");_=M,this.hasBeenReset=!0}})),Object.defineProperty(u,"position",n({},c,{get:function(){return x},set:function(L){if(L<0||L>100)throw new Error("Position must be between 0 and 100.");x=L,this.hasBeenReset=!0}})),Object.defineProperty(u,"positionAlign",n({},c,{get:function(){return A},set:function(L){const M=s(L);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");A=M,this.hasBeenReset=!0}})),Object.defineProperty(u,"size",n({},c,{get:function(){return C},set:function(L){if(L<0||L>100)throw new Error("Size must be between 0 and 100.");C=L,this.hasBeenReset=!0}})),Object.defineProperty(u,"align",n({},c,{get:function(){return O},set:function(L){const M=s(L);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");O=M,this.hasBeenReset=!0}})),u.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}();class jS{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function Xg(i){function e(r,s,n,a){return(r|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}const t=i.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}class zS{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let s=0;s<r.length;++s)if(t===r[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}function Qg(i,e,t,r){const s=r?i.split(r):[i];for(const n in s){if(typeof s[n]!="string")continue;const a=s[n].split(t);if(a.length!==2)continue;const o=a[0],l=a[1];e(o,l)}}const tc=new rf(0,0,""),so=tc.align==="middle"?"middle":"center";function XS(i,e,t){const r=i;function s(){const o=Xg(i);if(o===null)throw new Error("Malformed timestamp: "+r);return i=i.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){const d=new zS;Qg(o,function(h,f){let m;switch(h){case"region":for(let p=t.length-1;p>=0;p--)if(t[p].id===f){d.set(h,t[p].region);break}break;case"vertical":d.alt(h,f,["rl","lr"]);break;case"line":m=f.split(","),d.integer(h,m[0]),d.percent(h,m[0])&&d.set("snapToLines",!1),d.alt(h,m[0],["auto"]),m.length===2&&d.alt("lineAlign",m[1],["start",so,"end"]);break;case"position":m=f.split(","),d.percent(h,m[0]),m.length===2&&d.alt("positionAlign",m[1],["start",so,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",so,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let u=d.get("line","auto");u==="auto"&&tc.line===-1&&(u=-1),l.line=u,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",so);let c=d.get("position","auto");c==="auto"&&tc.position===50&&(c=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=c}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);i=i.slice(3),a(),e.endTime=s(),a(),n(i,e)}function Zg(i){return i.replace(/<br(?: \/)?>/gi,`
37
- `)}class QS{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new jS,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function r(){let n=t.buffer,a=0;for(n=Zg(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
35
+ initSegmentChange: ${C}`);const L=new IS(r,s,t,o,u);this.configureTransmuxer(L)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:d,state:O},e instanceof ArrayBuffer?[e]:[]);else if(f){const L=f.push(e,p,d,O);Po(L)?(f.async=!0,L.then(M=>{this.handleTransmuxComplete(M)}).catch(M=>{this.transmuxerError(M,d,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(L))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let r=t.flush(e);Po(r)||t.async?(Po(r)||(r=Promise.resolve(r)),r.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(r,e)}}transmuxerError(e,t,r){this.hls&&(this.error=e,this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:r}))}handleFlushResult(e,t){e.forEach(r=>{this.handleTransmuxComplete(r)}),this.onFlush(t)}onWorkerMessage(e){const t=e.data;if(!(t!=null&&t.event)){I.warn(`worker message received with no ${t?"event name":"data"}`);return}const r=this.hls;if(this.hls)switch(t.event){case"init":{var s;const n=(s=this.workerContext)==null?void 0:s.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":I[t.data.logType]&&I[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,r.trigger(t.event,t.data);break}}}configureTransmuxer(e){const{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}function zg(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!gn(i[t].attrs,e[t].attrs))return!1;return!0}function gn(i,e,t){const r=i["STABLE-RENDITION-ID"];return r&&!t?r===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(s=>i[s]!==e[s])}function ic(i,e){return e.label.toLowerCase()===i.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(i.lang||"").toLowerCase())}const ip=100;class CS extends Zh{constructor(e,t,r){super(e,t,r,"[audio-stream-controller]",ee.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-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.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.ERROR,this.onError,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){if(r==="main"){const a=t.cc;this.initPTS[t.cc]={baseTime:s,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${s}`),this.videoTrackCC=a,this.state===N.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=N.STOPPED;return}const t=this.lastCurrentTime;this.stopLoad(),this.setInterval(ip),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=N.IDLE):(this.loadedmetadata=!1,this.state=N.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case N.IDLE:this.doTickIdle();break;case N.WAITING_TRACK:{var e;const{levels:r,trackId:s}=this,n=r==null||(e=r[s])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=N.WAITING_INIT_PTS}break}case N.FRAG_LOADING_WAITING_RETRY:{var t;const r=performance.now(),s=this.retryDate;if(!s||r>=s||(t=this.media)!=null&&t.seeking){const{levels:n,trackId:a}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((n==null?void 0:n[a])||null),this.state=N.IDLE}break}case N.WAITING_INIT_PTS:{const r=this.waitingData;if(r){const{frag:s,part:n,cache:a,complete:o}=r;if(this.initPTS[s.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=N.FRAG_LOADING;const l=a.flush(),d={frag:s,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(d),o&&super._handleFragmentLoadComplete(d)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${s.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const l=this.getLoadPosition(),d=Le.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);ec(d.end,this.config.maxFragLookUpTolerance,s)<0&&(this.log(`Waiting fragment cc (${s.cc}) @ ${s.start} cancelled because another fragment at ${d.end} is needed`),this.clearWaitingFragment())}}else this.state=N.IDLE}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=N.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:e,levels:t,media:r,trackId:s}=this,n=e.config;if(!r&&(this.startFragRequested||!n.startFragPrefetch)||!(t!=null&&t[s]))return;const a=t[s],o=a.details;if(!o||o.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(o)){this.state=N.WAITING_TRACK;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,ye.AUDIO,ee.AUDIO));const d=this.getFwdBufferInfo(l,ee.AUDIO);if(d===null)return;const{bufferedTrack:u,switchingTrack:c}=this;if(!c&&this._streamEnded(d,o)){e.trigger(v.BUFFER_EOS,{type:"audio"}),this.state=N.ENDED;return}const h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,ee.MAIN),f=d.len,m=this.getMaxBufferLength(h==null?void 0:h.len),p=o.fragments,g=p[0].start;let E=this.flushing?this.getLoadPosition():d.end;if(c&&r){const _=this.getLoadPosition();u&&!gn(c.attrs,u.attrs)&&(E=_),o.PTSKnown&&_<g&&(d.end>g||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=g+.05)}if(f>=m&&!c&&E<p[p.length-1].start)return;let y=this.getNextFragment(E,o),b=!1;if(y&&this.isLoopLoading(y,E)&&(b=!!y.gap,y=this.getNextFragmentLoopLoading(y,o,d,ee.MAIN,m)),!y){this.bufferFlushed=!0;return}const S=h&&y.start>h.end+o.targetduration;if(S||!(h!=null&&h.len)&&d.len){const _=this.getAppendedFrag(y.start,ee.MAIN);if(_===null||(b||(b=!!_.gap||!!S&&h.len===0),S&&!b||b&&d.nextStart&&d.nextStart<_.end))return}this.loadFragment(y,a,E)}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(r=>new pn(r))}onAudioTrackSwitching(e,t){const r=!!t.url;this.trackId=t.id;const{fragCurrent:s}=this;s&&(s.abortRequests(),this.removeUnbufferedFrags(s.start)),this.resetLoadingState(),r?this.setInterval(ip):this.resetTransmuxer(),r?(this.switchingTrack=t,this.state=N.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=N.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(v.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var r;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}const{levels:s}=this,{details:n,id:a}=t;if(!s){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Audio track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const o=s[a];let l=0;if(n.live||(r=o.details)!=null&&r.live){this.checkLiveUpdate(n);const u=this.mainDetails;if(n.deltaUpdateFailed||!u)return;if(!o.details&&n.hasProgramDateTime&&u.hasProgramDateTime)id(n,u),l=n.fragments[0].start;else{var d;l=this.alignPlaylists(n,o.details,(d=this.levelLastLoaded)==null?void 0:d.details)}}o.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(this.mainDetails||n,l),this.state===N.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=N.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:r,part:s,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}const d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}const u=d.details;if(!u){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(r.start);return}const c=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2";let h=this.transmuxer;h||(h=this.transmuxer=new jg(this.hls,ee.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const f=this.initPTS[r.cc],m=(t=r.initSegment)==null?void 0:t.data;if(f!==void 0){const g=s?s.index:-1,E=g!==-1,y=new Xh(r.level,r.sn,r.stats.chunkCount,n.byteLength,g,E);h.push(n,m,c,"",r,s,u.totalduration,!1,y,f)}else{this.log(`Unknown video PTS for cc ${r.cc}, waiting for video PTS before demuxing audio frag ${r.sn} of [${u.startSN} ,${u.endSN}],track ${o}`);const{cache:p}=this.waitingData=this.waitingData||{frag:r,part:s,cache:new Dg,complete:!1};p.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=N.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){const r=t.tracks.audio;r&&(this.mediaBuffer=r.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){const{frag:r,part:s}=t;if(r.type!==ee.AUDIO){if(!this.loadedmetadata&&r.type===ee.MAIN){const n=this.videoBuffer||this.media;n&&Le.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(r.sn!=="initSegment"){this.fragPrevious=r;const n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(v.AUDIO_TRACK_SWITCHED,dt({},n)))}this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=N.ERROR;return}switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ee.AUDIO,t);break;case D.AUDIO_TRACK_LOAD_ERROR:case D.AUDIO_TRACK_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_TRACK&&((r=t.context)==null?void 0:r.type)===fe.AUDIO_TRACK&&(this.state=N.IDLE);break;case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;if(t.details===D.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==ye.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==ye.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===N.ENDED&&(this.state=N.IDLE);const r=this.mediaBuffer||this.media;r&&(this.afterBufferFlushed(r,t,ee.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const r="audio",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:d,level:u}=o,{details:c}=u,{audio:h,text:f,id3:m,initSegment:p}=n;if(this.fragContextChanged(l)||!c){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),p!=null&&p.tracks){const g=l.initSegment||l;this._bufferInitSegment(u,p.tracks,g,a),s.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:r,tracks:p.tracks})}if(h){const{startPTS:g,endPTS:E,startDTS:y,endDTS:b}=h;d&&(d.elementaryStreams[ye.AUDIO]={startPTS:g,endPTS:E,startDTS:y,endDTS:b}),l.setElementaryStreamInfo(ye.AUDIO,g,E,y,b),this.bufferFragmentData(h,l,d,a)}if(m!=null&&(t=m.samples)!=null&&t.length){const g=We({id:r,frag:l,details:c},m);s.trigger(v.FRAG_PARSING_METADATA,g)}if(f){const g=We({id:r,frag:l,details:c},f);s.trigger(v.FRAG_PARSING_USERDATA,g)}}_bufferInitSegment(e,t,r,s){if(this.state!==N.PARSING)return;t.video&&delete t.video;const n=t.audio;if(!n)return;n.id="audio";const a=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${a}/${n.codec}]`),a&&a.split(",").length===1&&(n.levelCodec=a),this.hls.trigger(v.BUFFER_CODECS,t);const o=n.initSegment;if(o!=null&&o.byteLength){const l={type:"audio",frag:r,part:null,chunkMeta:s,parent:r.type,data:o};this.hls.trigger(v.BUFFER_APPENDING,l)}this.tickImmediate()}loadFragment(e,t,r){const s=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||s===nt.NOT_LOADED||s===nt.PARTIAL){var n;if(e.sn==="initSegment")this._loadInitSegment(e,t);else if((n=t.details)!=null&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=N.WAITING_INIT_PTS;const a=this.mainDetails;a&&a.fragments[0].start!==t.details.fragments[0].start&&id(t.details,a)}else this.startFragRequested=!0,super.loadFragment(e,t,r)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){const{media:t,bufferedTrack:r}=this,s=r==null?void 0:r.attrs,n=e.attrs;t&&s&&(s.CHANNELS!==n.CHANNELS||r.name!==e.name||r.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(v.AUDIO_TRACK_SWITCHED,dt({},e))}}class DS extends zh{constructor(e){super(e,"[audio-track-controller]"),this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0,this.registerListeners()}registerListeners(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(v.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(e,t){this.tracks=t.audioTracks||[]}onAudioTrackLoaded(e,t){const{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Audio track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Audio track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.audioGroups||null,s=this.groupIds;let n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(o=>(s==null?void 0:s.indexOf(o))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const o=this.tracks.filter(h=>!r||r.indexOf(h.groupId)!==-1);if(o.length)this.selectDefaultTrack&&!o.some(h=>h.default)&&(this.selectDefaultTrack=!1),o.forEach((h,f)=>{h.id=f});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;const l=this.hls.config.audioPreference;if(!n&&l){const h=bi(l,o,Es);if(h>-1)n=o[h];else{const f=bi(l,this.tracks);n=this.tracks[f]}}let d=this.findTrackId(n);d===-1&&n&&(d=this.findTrackId(null));const u={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${r==null?void 0:r.join(",")}`),this.hls.trigger(v.AUDIO_TRACKS_UPDATED,u);const c=this.trackId;if(d!==-1&&c===-1)this.setAudioTrack(d);else if(o.length&&c===-1){var a;const h=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(h.message),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:h})}}else this.shouldReloadPlaylist(n)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===fe.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&(this.requestScheduled=-1,this.checkRetry(t))}get allAudioTracks(){return this.tracks}get audioTracks(){return this.tracksInGroup}get audioTrack(){return this.trackId}set audioTrack(e){this.selectDefaultTrack=!1,this.setAudioTrack(e)}setAudioOption(e){const t=this.hls;if(t.config.audioPreference=e,e){const r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){const s=this.currentTrack;if(s&&tn(e,s,Es))return s;const n=bi(e,this.tracksInGroup,Es);if(n>-1){const a=this.tracksInGroup[n];return this.setAudioTrack(n),a}else if(s){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);const o=DA(e,t.levels,r,a,Es);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){const a=bi(e,r);if(a>-1)return r[a]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;const r=this.currentTrack,s=t[e],n=s.details&&!s.details.live;if(e===this.trackId&&s===r&&n||(this.log(`Switching to audio-track ${e} "${s.name}" lang:${s.lang} group:${s.groupId} channels:${s.channels}`),this.trackId=e,this.currentTrack=s,this.hls.trigger(v.AUDIO_TRACK_SWITCHING,dt({},s)),n))return;const a=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(a)}findTrackId(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const s=t[r];if(!(this.selectDefaultTrack&&!s.default)&&(!e||tn(e,s,Es)))return r}if(e){const{name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l}=e;for(let d=0;d<t.length;d++){const u=t[d];if(tn({name:r,lang:s,assocLang:n,characteristics:a,audioCodec:o,channels:l},u,Es))return d}for(let d=0;d<t.length;d++){const u=t[d];if(gn(e.attrs,u.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){const u=t[d];if(gn(e.attrs,u.attrs,["LANGUAGE"]))return d}}return-1}loadPlaylist(e){const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();const r=t.id,s=t.groupId;let n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${r} "${t.name}" lang:${t.lang} group:${s}`),this.clearTimer(),this.hls.trigger(v.AUDIO_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}}const rp=500;class MS extends Zh{constructor(e,t,r){super(e,t,r,"[subtitle-stream-controller]",ee.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.ERROR,this.onError,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.ERROR,this.onError,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=N.IDLE,this.setInterval(rp),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:r,success:s}=t;if(this.fragPrevious=r,this.state=N.IDLE,!s)return;const n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a;const o=r.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}const l=r.start+r.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null)}onBufferFlushing(e,t){const{startOffset:r,endOffset:s}=t;if(r===0&&s!==Number.POSITIVE_INFINITY){const n=s-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(r,n,ee.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===ee.MAIN){var r;(r=this.media)!=null&&r.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){const r=t.frag;(r==null?void 0:r.type)===ee.SUBTITLE&&(t.details===D.FRAG_GAP&&this.fragmentTracker.fragBuffered(r,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==N.STOPPED&&(this.state=N.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&zg(this.levels,t)){this.levels=t.map(r=>new pn(r));return}this.tracksBuffered=[],this.levels=t.map(r=>{const s=new pn(r);return this.tracksBuffered[s.id]=[],s}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,ee.SUBTITLE),this.fragPrevious=null,this.mediaBuffer=null}onSubtitleTrackSwitch(e,t){var r;if(this.currentTrackId=t.id,!((r=this.levels)!=null&&r.length)||this.currentTrackId===-1){this.clearInterval();return}const s=this.levels[this.currentTrackId];s!=null&&s.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,s&&this.setInterval(rp)}onSubtitleTrackLoaded(e,t){var r;const{currentTrackId:s,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}const l=n[o];if(o>=n.length||!l)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(a.live||(r=l.details)!=null&&r.live){const c=this.mainDetails;if(a.deltaUpdateFailed||!c)return;const h=c.fragments[0];if(!l.details)a.hasProgramDateTime&&c.hasProgramDateTime?(id(a,c),d=a.fragments[0].start):h&&(d=h.start,Ju(a,d));else{var u;d=this.alignPlaylists(a,l.details,(u=this.levelLastLoaded)==null?void 0:u.details),d===0&&h&&(d=h.start,Ju(a,d))}}l.details=a,this.levelLastLoaded=l,o===s&&(!this.startFragRequested&&(this.mainDetails||!a.live)&&this.setStartPosition(this.mainDetails||a,d),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===N.IDLE&&(td(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0)))}_handleFragmentLoadComplete(e){const{frag:t,payload:r}=e,s=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&r&&r.byteLength>0&&s!=null&&s.key&&s.iv&&s.method==="AES-128"){const a=performance.now();this.decrypter.decrypt(new Uint8Array(r),s.key.buffer,s.iv.buffer).catch(o=>{throw n.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{const l=performance.now();n.trigger(v.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=N.IDLE})}}doTick(){if(!this.media){this.state=N.IDLE;return}if(this.state===N.IDLE){const{currentTrackId:e,levels:t}=this,r=t==null?void 0:t[e];if(!r||!t.length||!r.details)return;const{config:s}=this,n=this.getLoadPosition(),a=Le.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,s.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,ee.MAIN),u=r.details,c=this.getMaxBufferLength(d==null?void 0:d.len)+u.levelTargetDuration;if(l>c)return;const h=u.fragments,f=h.length,m=u.edge;let p=null;const g=this.fragPrevious;if(o<m){const E=s.maxFragLookUpTolerance,y=o>m-E?0:E;p=td(g,h,Math.max(h[0].start,o),y),!p&&g&&g.start<h[0].start&&(p=h[0])}else p=h[f-1];if(!p)return;if(p=this.mapToInitFragWhenRequired(p),p.sn!=="initSegment"){const E=p.sn-u.startSN,y=h[E-1];y&&y.cc===p.cc&&this.fragmentTracker.getState(y)===nt.NOT_LOADED&&(p=y)}this.fragmentTracker.getState(p)===nt.NOT_LOADED&&this.loadFragment(p,r,o)}}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,r){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,r))}get mediaBufferTimeRanges(){return new PS(this.tracksBuffered[this.currentTrackId]||[])}}class PS{constructor(e){this.buffered=void 0;const t=(r,s,n)=>{if(s=s>>>0,s>n-1)throw new DOMException(`Failed to execute '${r}' on 'TimeRanges': The index provided (${s}) is greater than the maximum bound (${n})`);return e[s][r]};this.buffered={get length(){return e.length},end(r){return t("end",r,e.length)},start(r){return t("start",r,e.length)}}}}class OS extends zh{constructor(e){super(e,"[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.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const r=Ro(this.media.textTracks);for(let n=0;n<r.length;n++)if(r[n].mode==="hidden")t=r[n];else if(r[n].mode==="showing"){t=r[n];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(e){this._subtitleDisplay=e,this.trackId>-1&&this.toggleTrackModes()}registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADING,this.onLevelLoading,this),e.off(v.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(v.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(v.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.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(e){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,e)}onMediaDetaching(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Ro(this.media.textTracks).forEach(t=>{Xs(t)}),this.subtitleTrack=-1,this.media=null}onManifestLoading(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0}onManifestParsed(e,t){this.tracks=t.subtitleTracks}onSubtitleTrackLoaded(e,t){const{id:r,groupId:s,details:n}=t,a=this.tracksInGroup[r];if(!a||a.groupId!==s){this.warn(`Subtitle track with id:${r} and group:${s} not found in active group ${a==null?void 0:a.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Subtitle track ${r} "${a.name}" lang:${a.lang} group:${s} loaded [${n.startSN}-${n.endSN}]`),r===this.trackId&&this.playlistLoaded(r,t,o)}onLevelLoading(e,t){this.switchLevel(t.level)}onLevelSwitching(e,t){this.switchLevel(t.level)}switchLevel(e){const t=this.hls.levels[e];if(!t)return;const r=t.subtitleGroups||null,s=this.groupIds;let n=this.currentTrack;if(!r||(s==null?void 0:s.length)!==(r==null?void 0:r.length)||r!=null&&r.some(a=>(s==null?void 0:s.indexOf(a))===-1)){this.groupIds=r,this.trackId=-1,this.currentTrack=null;const a=this.tracks.filter(u=>!r||r.indexOf(u.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(u=>u.default)&&(this.selectDefaultTrack=!1),a.forEach((u,c)=>{u.id=c});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;const o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=!1;const u=bi(o,a);if(u>-1)n=a[u];else{const c=bi(o,this.tracks);n=this.tracks[c]}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));const d={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${r==null?void 0:r.join(",")}" group-id`),this.hls.trigger(v.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.trackId===-1&&this.setSubtitleTrack(l)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){const t=this.tracksInGroup,r=this.selectDefaultTrack;for(let s=0;s<t.length;s++){const n=t[s];if(!(r&&!n.default||!r&&!e)&&(!e||tn(n,e)))return s}if(e){for(let s=0;s<t.length;s++){const n=t[s];if(gn(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return s}for(let s=0;s<t.length;s++){const n=t[s];if(gn(e.attrs,n.attrs,["LANGUAGE"]))return s}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let r=0;r<t.length;r++){const s=t[r];if(ic(s,e))return r}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===fe.SUBTITLE_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&this.checkRetry(t)}get allSubtitleTracks(){return this.tracks}get subtitleTracks(){return this.tracksInGroup}get subtitleTrack(){return this.trackId}set subtitleTrack(e){this.selectDefaultTrack=!1,this.setSubtitleTrack(e)}setSubtitleOption(e){if(this.hls.config.subtitlePreference=e,e){const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const r=this.currentTrack;if(r&&tn(e,r))return r;const s=bi(e,this.tracksInGroup);if(s>-1){const n=this.tracksInGroup[s];return this.setSubtitleTrack(s),n}else{if(r)return null;{const n=bi(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){const r=t.id,s=t.groupId;let n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${r}`),this.hls.trigger(v.SUBTITLE_TRACK_LOADING,{url:n,id:r,groupId:s,deliveryDirectives:e||null})}}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=Ro(e.textTracks),r=this.currentTrack;let s;if(r&&(s=t.filter(n=>ic(r,n))[0],s||this.warn(`Unable to find subtitle TextTrack with name "${r.name}" and language "${r.lang}"`)),[].slice.call(t).forEach(n=>{n.mode!=="disabled"&&n!==s&&(n.mode="disabled")}),s){const n=this.subtitleDisplay?"showing":"hidden";s.mode!==n&&(s.mode=n)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!Y(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;const r=this.currentTrack,s=t[e]||null;if(this.trackId=e,this.currentTrack=s,this.toggleTrackModes(),!s){this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:e});return}const n=!!s.details&&!s.details.live;if(e===this.trackId&&s===r&&n)return;this.log(`Switching to subtitle-track ${e}`+(s?` "${s.name}" lang:${s.lang} group:${s.groupId}`:""));const{id:a,groupId:o="",name:l,type:d,url:u}=s;this.hls.trigger(v.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:u});const c=this.switchParams(s.url,r==null?void 0:r.details,s.details);this.loadPlaylist(c)}}class NS{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,r){const s=this.queues[t];s.push(e),s.length===1&&!r&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t;const r=new Promise(n=>{t=n}),s={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(s,e),r}executeNext(e){const t=this.queues[e];if(t.length){const r=t[0];try{r.execute()}catch(s){I.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${s}`),r.onError(s);const n=this.buffers[e];n!=null&&n.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const sp=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;class FS{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=r=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=r=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{const{media:r,mediaSource:s}=this;this.log("Media source opened"),r&&(r.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(v.MEDIA_ATTACHED,{media:r,mediaSource:s})),s&&s.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:r,_objectUrl:s}=this;r!==s&&I.error(`Media element src was set while attaching MediaSource (${s} > ${r})`)},this.hls=e;const t="[buffer-controller]";this.appendSource=q1(ds(e.config.preferManagedMediaSource)),this.log=I.log.bind(I,t),this.warn=I.warn.bind(I,t),this.error=I.error.bind(I,t),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.BUFFER_RESET,this.onBufferReset,this),e.on(v.BUFFER_APPENDING,this.onBufferAppending,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.BUFFER_EOS,this.onBufferEos,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(v.FRAG_PARSED,this.onFragParsed,this),e.on(v.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.BUFFER_RESET,this.onBufferReset,this),e.off(v.BUFFER_APPENDING,this.onBufferAppending,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.BUFFER_EOS,this.onBufferEos,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(v.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(v.FRAG_PARSED,this.onFragParsed,this),e.off(v.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new NS(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let r=2;(t.audio&&!t.video||!t.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){const r=this.media=t.media,s=ds(this.appendSource);if(r&&s){var n;const a=this.mediaSource=new s;this.log(`created media source: ${(n=a.constructor)==null?void 0:n.name}`),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));const o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");const l=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||l&&a instanceof l,np(r),US(r,o),r.load()}catch{r.src=o}else r.src=o;r.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:e,mediaSource:t,_objectUrl:r}=this;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(s){this.warn(`onMediaDetaching: ${s.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(e.removeAttribute("src"),this.appendSource&&np(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(v.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e)}),this._initSourceBuffer()}resetBuffer(e){const t=this.sourceBuffer[e];try{if(t){var r;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(r=this.mediaSource)!=null&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(s){this.warn(`onBufferReset ${e}`,s)}}onBufferCodecs(e,t){const r=this.getSourceBufferTypes().length,s=Object.keys(t);if(s.forEach(a=>{if(r){const l=this.tracks[a];if(l&&typeof l.buffer.changeType=="function"){var o;const{id:d,codec:u,levelCodec:c,container:h,metadata:f}=t[a],m=km(l.codec,l.levelCodec),p=m==null?void 0:m.replace(sp,"$1");let g=km(u,c);const E=(o=g)==null?void 0:o.replace(sp,"$1");if(g&&p!==E){a.slice(0,5)==="audio"&&(g=Ql(g,this.appendSource));const y=`${h};codecs=${g}`;this.appendChangeType(a,y),this.log(`switching codec ${m} to ${g}`),this.tracks[a]={buffer:l.buffer,codec:u,container:h,levelCodec:c,metadata:f,id:d}}}}else this.pendingTracks[a]=t[a]}),r)return;const n=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==n&&(this.log(`${n} bufferCodec event(s) expected ${s.join(",")}`),this.bufferCodecEventsExpected=n),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}appendChangeType(e,t){const{operationQueue:r}=this,s={execute:()=>{const n=this.sourceBuffer[e];n&&(this.log(`changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),r.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{this.warn(`Failed to change ${e} SourceBuffer type`,n)}};r.append(s,e,!!this.pendingTracks[e])}onBufferAppending(e,t){const{hls:r,operationQueue:s,tracks:n}=this,{data:a,type:o,frag:l,part:d,chunkMeta:u}=t,c=u.buffering[o],h=self.performance.now();c.start=h;const f=l.stats.buffering,m=d?d.stats.buffering:null;f.start===0&&(f.start=h),m&&m.start===0&&(m.start=h);const p=n.audio;let g=!1;o==="audio"&&(p==null?void 0:p.container)==="audio/mpeg"&&(g=!this.lastMpegAudioChunk||u.id===1||this.lastMpegAudioChunk.sn!==u.sn,this.lastMpegAudioChunk=u);const E=l.start,y={execute:()=>{if(c.executeStart=self.performance.now(),g){const b=this.sourceBuffer[o];if(b){const S=E-b.timestampOffset;Math.abs(S)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${E} (delta: ${S}) sn: ${l.sn})`),b.timestampOffset=E)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{const b=self.performance.now();c.executeEnd=c.end=b,f.first===0&&(f.first=b),m&&m.first===0&&(m.first=b);const{sourceBuffer:S}=this,_={};for(const x in S)_[x]=Le.getBuffered(S[x]);this.appendErrors[o]=0,o==="audio"||o==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(v.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:u,parent:l.type,timeRanges:_})},onError:b=>{const S={type:ie.MEDIA_ERROR,parent:l.type,details:D.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:d,chunkMeta:u,error:b,err:b,fatal:!1};if(b.code===DOMException.QUOTA_EXCEEDED_ERR)S.details=D.BUFFER_FULL_ERROR;else{const _=++this.appendErrors[o];S.details=D.BUFFER_APPEND_ERROR,this.warn(`Failed ${_}/${r.config.appendErrorMaxRetry} times to append segment in "${o}" sourceBuffer`),_>=r.config.appendErrorMaxRetry&&(S.fatal=!0)}r.trigger(v.ERROR,S)}};s.append(y,o,!!this.pendingTracks[o])}onBufferFlushing(e,t){const{operationQueue:r}=this,s=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(v.BUFFER_FLUSHED,{type:n})},onError:a=>{this.warn(`Failed to remove from ${n} SourceBuffer`,a)}});t.type?r.append(s(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{r.append(s(n),n)})}onFragParsed(e,t){const{frag:r,part:s}=t,n=[],a=s?s.elementaryStreams:r.elementaryStreams;a[ye.AUDIOVIDEO]?n.push("audiovideo"):(a[ye.AUDIO]&&n.push("audio"),a[ye.VIDEO]&&n.push("video"));const o=()=>{const l=self.performance.now();r.stats.buffering.end=l,s&&(s.stats.buffering.end=l);const d=s?s.stats:r.stats;this.hls.trigger(v.FRAG_BUFFERED,{frag:r,part:s,stats:d,id:r.type})};n.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${r.type} level: ${r.level} sn: ${r.sn}`),this.blockBuffers(o,n)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((s,n)=>{const a=this.sourceBuffer[n];return a&&(!t.type||t.type===n)&&(a.ending=!0,a.ended||(a.ended=!0,this.log(`${n} sourceBuffer now EOS`))),s&&!!(!a||a.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{const a=this.sourceBuffer[n];a&&(a.ending=!1)});const{mediaSource:s}=this;if(!s||s.readyState!=="open"){s&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${s.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),s.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){const{hls:e,details:t,media:r}=this;if(!r||t===null||!this.getSourceBufferTypes().length)return;const n=e.config,a=r.currentTime,o=t.levelTargetDuration,l=t.live&&n.liveBackBufferLength!==null?n.liveBackBufferLength:n.backBufferLength;if(Y(l)&&l>0){const d=Math.max(l,o),u=Math.floor(a/o)*o-d;this.flushBackBuffer(a,o,u)}if(Y(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){const d=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),u=Math.max(d,o),c=Math.floor(a/o)*o+u;this.flushFrontBuffer(a,o,c)}}flushBackBuffer(e,t,r){const{details:s,sourceBuffer:n}=this;this.getSourceBufferTypes().forEach(o=>{const l=n[o];if(l){const d=Le.getBuffered(l);if(d.length>0&&r>d.start(0)){if(this.hls.trigger(v.BACK_BUFFER_REACHED,{bufferEnd:r}),s!=null&&s.live)this.hls.trigger(v.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(l.ended&&d.end(d.length-1)-e<t*2){this.log(`Cannot flush ${o} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:o})}}})}flushFrontBuffer(e,t,r){const{sourceBuffer:s}=this;this.getSourceBufferTypes().forEach(a=>{const o=s[a];if(o){const l=Le.getBuffered(o),d=l.length;if(d<2)return;const u=l.start(d-1),c=l.end(d-1);if(r>u||e>=u&&e<=c)return;if(o.ended&&e-c<2*t){this.log(`Cannot flush ${a} front buffer while SourceBuffer is in ended state`);return}this.hls.trigger(v.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:a})}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:e,hls:t,media:r,mediaSource:s}=this,n=e.fragments[0].start+e.totalduration,a=r.duration,o=Y(s.duration)?s.duration:0;e.live&&t.config.liveDurationInfinity?(s.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!Y(a))&&(this.log(`Updating Media Source duration to ${n.toFixed(3)}`),s.duration=n)}updateSeekableRange(e){const t=this.mediaSource,r=e.fragments;if(r.length&&e.live&&t!=null&&t.setLiveSeekableRange){const n=Math.max(0,r[0].start),a=Math.max(n,n+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${n}-${a}.`),t.setLiveSeekableRange(n,a)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:r}=this,s=Object.keys(r).length;if(s&&(!e||s===2||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};const n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(v.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{t.executeNext(a)});else{const a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){const{sourceBuffer:t,mediaSource:r}=this;if(!r)throw Error("createSourceBuffers called when mediaSource was null");for(const n in e)if(!t[n]){var s;const a=e[n];if(!a)throw Error(`source buffer exists for track ${n}, however track does not`);let o=((s=a.levelCodec)==null?void 0:s.indexOf(","))===-1?a.levelCodec:a.codec;o&&n.slice(0,5)==="audio"&&(o=Ql(o,this.appendSource));const l=`${a.container};codecs=${o}`;this.log(`creating sourceBuffer(${l})`);try{const d=t[n]=r.addSourceBuffer(l),u=n;this.addBufferListener(u,"updatestart",this._onSBUpdateStart),this.addBufferListener(u,"updateend",this._onSBUpdateEnd),this.addBufferListener(u,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(u,"bufferedchange",(c,h)=>{const f=h.removedRanges;f!=null&&f.length&&this.hls.trigger(v.BUFFER_FLUSHED,{type:n})}),this.tracks[n]={buffer:d,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(d){this.error(`error while trying to add sourceBuffer: ${d.message}`),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,sourceBufferName:n,mimeType:l})}}}get mediaSrc(){var e,t;const r=((e=this.media)==null||(t=e.querySelector)==null?void 0:t.call(e,"source"))||this.media;return r==null?void 0:r.src}_onSBUpdateStart(e){const{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const{operationQueue:r}=this;r.current(e).onComplete(),r.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var r;const s=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(r=this.mediaSource)==null?void 0:r.readyState}`);this.error(`${s}`,t),this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:s,fatal:!1});const n=this.operationQueue.current(e);n&&n.onError(s)}removeExecutor(e,t,r){const{media:s,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!s||!n||!l){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}const d=Y(s.duration)?s.duration:1/0,u=Y(n.duration)?n.duration:1/0,c=Math.max(0,t),h=Math.min(r,d,u);h>c&&(!l.ending||l.ended)?(l.ended=!1,this.log(`Removing [${c},${h}] from the ${e} SourceBuffer`),l.remove(c,h)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){const r=this.sourceBuffer[t];if(!r){if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);return}r.ended=!1,r.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}const{operationQueue:r}=this,s=t.map(n=>r.appendBlocker(n));Promise.all(s).then(()=>{e(),t.forEach(n=>{const a=this.sourceBuffer[n];a!=null&&a.updating||r.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,r){const s=this.sourceBuffer[e];if(!s)return;const n=r.bind(this,e);this.listeners[e].push({event:t,listener:n}),s.addEventListener(t,n)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(r=>{t.removeEventListener(r.event,r.listener)})}}function np(i){const e=i.querySelectorAll("source");[].slice.call(e).forEach(t=>{i.removeChild(t)})}function US(i,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,i.appendChild(t)}const $S={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},Xg=i=>String.fromCharCode($S[i]||i),Wt=15,wi=100,BS={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},GS={17:2,18:4,21:6,22:8,23:10,19:13,20:15},HS={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},WS={25:2,26:4,29:6,30:8,31:10,27:13,28:15},KS=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class VS{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const r=typeof t=="function"?t():t;I.log(`${this.time} [${e}] ${r}`)}}}const br=function(e){const t=[];for(let r=0;r<e.length;r++)t.push(e[r].toString(16));return t};class Qg{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(e){const t=["foreground","underline","italics","background","flash"];for(let r=0;r<t.length;r++){const s=t[r];e.hasOwnProperty(s)&&(this[s]=e[s])}}isDefault(){return this.foreground==="white"&&!this.underline&&!this.italics&&this.background==="black"&&!this.flash}equals(e){return this.foreground===e.foreground&&this.underline===e.underline&&this.italics===e.italics&&this.background===e.background&&this.flash===e.flash}copy(e){this.foreground=e.foreground,this.underline=e.underline,this.italics=e.italics,this.background=e.background,this.flash=e.flash}toString(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash}}class qS{constructor(){this.uchar=" ",this.penState=new Qg}reset(){this.uchar=" ",this.penState.reset()}setChar(e,t){this.uchar=e,this.penState.copy(t)}setPenState(e){this.penState.copy(e)}equals(e){return this.uchar===e.uchar&&this.penState.equals(e.penState)}copy(e){this.uchar=e.uchar,this.penState.copy(e.penState)}isEmpty(){return this.uchar===" "&&this.penState.isDefault()}}class YS{constructor(e){this.chars=[],this.pos=0,this.currPenState=new Qg,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<wi;t++)this.chars.push(new qS);this.logger=e}equals(e){for(let t=0;t<wi;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<wi;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<wi;t++)if(!this.chars[t].isEmpty()){e=!1;break}return e}setCursor(e){this.pos!==e&&(this.pos=e),this.pos<0?(this.logger.log(3,"Negative cursor position "+this.pos),this.pos=0):this.pos>wi&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=wi)}moveCursor(e){const t=this.pos+e;if(e>1)for(let r=this.pos+1;r<t+1;r++)this.chars[r].setPenState(this.currPenState);this.setCursor(t)}backSpace(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)}insertChar(e){e>=144&&this.backSpace();const t=Xg(e);if(this.pos>=wi){this.logger.log(0,()=>"Cannot insert "+e.toString(16)+" ("+t+") at position "+this.pos+". Skipping it!");return}this.chars[this.pos].setChar(t,this.currPenState),this.moveCursor(1)}clearFromPos(e){let t;for(t=e;t<wi;t++)this.chars[t].reset()}clear(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()}clearToEndOfRow(){this.clearFromPos(this.pos)}getTextString(){const e=[];let t=!0;for(let r=0;r<wi;r++){const s=this.chars[r].uchar;s!==" "&&(t=!1),e.push(s)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class hu{constructor(e){this.rows=[],this.currRow=Wt-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Wt;t++)this.rows.push(new YS(e));this.logger=e}reset(){for(let e=0;e<Wt;e++)this.rows[e].clear();this.currRow=Wt-1}equals(e){let t=!0;for(let r=0;r<Wt;r++)if(!this.rows[r].equals(e.rows[r])){t=!1;break}return t}copy(e){for(let t=0;t<Wt;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Wt;t++)if(!this.rows[t].isEmpty()){e=!1;break}return e}backSpace(){this.rows[this.currRow].backSpace()}clearToEndOfRow(){this.rows[this.currRow].clearToEndOfRow()}insertChar(e){this.rows[this.currRow].insertChar(e)}setPen(e){this.rows[this.currRow].setPenStyles(e)}moveCursor(e){this.rows[this.currRow].moveCursor(e)}setCursor(e){this.logger.log(2,"setCursor: "+e),this.rows[this.currRow].setCursor(e)}setPAC(e){this.logger.log(2,()=>"pacData = "+JSON.stringify(e));let t=e.row-1;if(this.nrRollUpRows&&t<this.nrRollUpRows-1&&(t=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==t){for(let o=0;o<Wt;o++)this.rows[o].clear();const n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){const o=a.rows[n].cueStartTime,l=this.logger.time;if(o!==null&&l!==null&&o<l)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[n+d])}}this.currRow=t;const r=this.rows[this.currRow];if(e.indent!==null){const n=e.indent,a=Math.max(n-1,0);r.setCursor(e.indent),e.color=r.chars[a].penState.foreground}const s={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(s)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(e)),this.backSpace(),this.setPen(e),this.insertChar(32)}setRollUpRows(e){this.nrRollUpRows=e}rollUp(){if(this.nrRollUpRows===null){this.logger.log(3,"roll_up but nrRollUpRows not set yet");return}this.logger.log(1,()=>this.getDisplayText());const e=this.currRow+1-this.nrRollUpRows,t=this.rows.splice(e,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(2,"Rolling up")}getDisplayText(e){e=e||!1;const t=[];let r="",s=-1;for(let n=0;n<Wt;n++){const a=this.rows[n].getTextString();a&&(s=n+1,e?t.push("Row "+s+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?r="["+t.join(" | ")+"]":r=t.join(`
36
+ `)),r}getTextAndFormat(){return this.rows}}class ap{constructor(e,t,r){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=e,this.outputFilter=t,this.mode=null,this.verbose=0,this.displayedMemory=new hu(r),this.nonDisplayedMemory=new hu(r),this.lastOutputScreen=new hu(r),this.currRollUpRow=this.displayedMemory.rows[Wt-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}reset(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[Wt-1],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null}getHandler(){return this.outputFilter}setHandler(e){this.outputFilter=e}setPAC(e){this.writeScreen.setPAC(e)}setBkgData(e){this.writeScreen.setBkgData(e)}setMode(e){e!==this.mode&&(this.mode=e,this.logger.log(2,()=>"MODE="+e),this.mode==="MODE_POP-ON"?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),this.mode!=="MODE_ROLL-UP"&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=e)}insertChars(e){for(let r=0;r<e.length;r++)this.writeScreen.insertChar(e[r]);const t=this.writeScreen===this.displayedMemory?"DISP":"NON_DISP";this.logger.log(2,()=>t+": "+this.writeScreen.getDisplayText(!0)),(this.mode==="MODE_PAINT-ON"||this.mode==="MODE_ROLL-UP")&&(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"),this.mode!=="MODE_TEXT"&&(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(e){this.logger.log(2,"RU("+e+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(e)}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"),this.mode==="MODE_POP-ON"){const e=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=e,this.writeScreen=this.nonDisplayedMemory,this.logger.log(1,()=>"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)}ccTO(e){this.logger.log(2,"TO("+e+") - Tab Offset"),this.writeScreen.moveCursor(e)}ccMIDROW(e){const t={flash:!1};if(t.underline=e%2===1,t.italics=e>=46,t.italics)t.foreground="white";else{const r=Math.floor(e/2)-16,s=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=s[r]}this.logger.log(2,"MIDROW: "+JSON.stringify(t)),this.writeScreen.setPen(t)}outputDataUpdate(e=!1){const t=this.logger.time;t!==null&&this.outputFilter&&(this.cueStartTime===null&&!this.displayedMemory.isEmpty()?this.cueStartTime=t:this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,t,this.lastOutputScreen),e&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:t),this.lastOutputScreen.copy(this.displayedMemory))}cueSplitAtTime(e){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,e,this.displayedMemory),this.cueStartTime=e))}}class op{constructor(e,t,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory=zS(),this.logger=void 0;const s=this.logger=new VS;this.channels=[null,new ap(e,t,s),new ap(e+1,r,s)]}getHandler(e){return this.channels[e].getHandler()}setHandler(e,t){this.channels[e].setHandler(t)}addData(e,t){this.logger.time=e;for(let r=0;r<t.length;r+=2){const s=t[r]&127,n=t[r+1]&127;let a=!1,o=null;if(s===0&&n===0)continue;this.logger.log(3,()=>"["+br([t[r],t[r+1]])+"] -> ("+br([s,n])+")");const l=this.cmdHistory;if(s>=16&&s<=31){if(jS(s,n,l)){ro(null,null,l),this.logger.log(3,()=>"Repeated command ("+br([s,n])+") is dropped");continue}ro(s,n,this.cmdHistory),a=this.parseCmd(s,n),a||(a=this.parseMidrow(s,n)),a||(a=this.parsePAC(s,n)),a||(a=this.parseBackgroundAttributes(s,n))}else ro(null,null,l);if(!a&&(o=this.parseChars(s,n),o)){const u=this.currentChannel;u&&u>0?this.channels[u].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+br([s,n])+" orig: "+br([t[r],t[r+1]]))}}parseCmd(e,t){const r=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=33&&t<=35;if(!(r||s))return!1;const n=e===20||e===21||e===23?1:2,a=this.channels[n];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),this.currentChannel=n,!0}parseMidrow(e,t){let r=0;if((e===17||e===25)&&t>=32&&t<=47){if(e===17?r=1:r=2,r!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;const s=this.channels[r];return s?(s.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+br([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let r;const s=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(s||n))return!1;const a=e<=23?1:2;t>=64&&t<=95?r=a===1?BS[e]:HS[e]:r=a===1?GS[e]:WS[e];const o=this.channels[a];return o?(o.setPAC(this.interpretPAC(r,t)),this.currentChannel=a,!0):!1}interpretPAC(e,t){let r;const s={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?r=t-96:r=t-64,s.underline=(r&1)===1,r<=13?s.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(s.italics=!0,s.color="white"):s.indent=Math.floor((r-16)/2)*4,s}parseChars(e,t){let r,s=null,n=null;if(e>=25?(r=2,n=e-8):(r=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,()=>"Special char '"+Xg(a)+"' in channel "+r),s=[a]}else e>=32&&e<=127&&(s=t===0?[e]:[e,t]);return s&&this.logger.log(3,()=>"Char codes = "+br(s).join(",")),s}parseBackgroundAttributes(e,t){const r=(e===16||e===24)&&t>=32&&t<=47,s=(e===23||e===31)&&t>=45&&t<=47;if(!(r||s))return!1;let n;const a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=KS[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));const o=e<=23?1:2;return this.channels[o].setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}ro(null,null,this.cmdHistory)}cueSplitAtTime(e){for(let t=0;t<this.channels.length;t++){const r=this.channels[t];r&&r.cueSplitAtTime(e)}}}function ro(i,e,t){t.a=i,t.b=e}function jS(i,e,t){return t.a===i&&t.b===e}function zS(){return{a:null,b:null}}class so{constructor(e,t){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=e,this.trackName=t}dispatchCue(){this.startTime!==null&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)}newCue(e,t,r){(this.startTime===null||this.startTime>e)&&(this.startTime=e),this.endTime=t,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)}reset(){this.cueRanges=[],this.startTime=null}}var nf=function(){if(mn!=null&&mn.VTTCue)return self.VTTCue;const i=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;const d=l.toLowerCase();return~o.indexOf(d)?d:!1}function r(o){return t(i,o)}function s(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){const u=arguments[d];for(const c in u)o[c]=u[c]}return o}function a(o,l,d){const u=this,c={enumerable:!0};u.hasBeenReset=!1;let h="",f=!1,m=o,p=l,g=d,E=null,y="",b=!0,S="auto",_="start",x=50,A="middle",C=50,O="middle";Object.defineProperty(u,"id",n({},c,{get:function(){return h},set:function(L){h=""+L}})),Object.defineProperty(u,"pauseOnExit",n({},c,{get:function(){return f},set:function(L){f=!!L}})),Object.defineProperty(u,"startTime",n({},c,{get:function(){return m},set:function(L){if(typeof L!="number")throw new TypeError("Start time must be set to a number.");m=L,this.hasBeenReset=!0}})),Object.defineProperty(u,"endTime",n({},c,{get:function(){return p},set:function(L){if(typeof L!="number")throw new TypeError("End time must be set to a number.");p=L,this.hasBeenReset=!0}})),Object.defineProperty(u,"text",n({},c,{get:function(){return g},set:function(L){g=""+L,this.hasBeenReset=!0}})),Object.defineProperty(u,"region",n({},c,{get:function(){return E},set:function(L){E=L,this.hasBeenReset=!0}})),Object.defineProperty(u,"vertical",n({},c,{get:function(){return y},set:function(L){const M=r(L);if(M===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=M,this.hasBeenReset=!0}})),Object.defineProperty(u,"snapToLines",n({},c,{get:function(){return b},set:function(L){b=!!L,this.hasBeenReset=!0}})),Object.defineProperty(u,"line",n({},c,{get:function(){return S},set:function(L){if(typeof L!="number"&&L!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");S=L,this.hasBeenReset=!0}})),Object.defineProperty(u,"lineAlign",n({},c,{get:function(){return _},set:function(L){const M=s(L);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");_=M,this.hasBeenReset=!0}})),Object.defineProperty(u,"position",n({},c,{get:function(){return x},set:function(L){if(L<0||L>100)throw new Error("Position must be between 0 and 100.");x=L,this.hasBeenReset=!0}})),Object.defineProperty(u,"positionAlign",n({},c,{get:function(){return A},set:function(L){const M=s(L);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");A=M,this.hasBeenReset=!0}})),Object.defineProperty(u,"size",n({},c,{get:function(){return C},set:function(L){if(L<0||L>100)throw new Error("Size must be between 0 and 100.");C=L,this.hasBeenReset=!0}})),Object.defineProperty(u,"align",n({},c,{get:function(){return O},set:function(L){const M=s(L);if(!M)throw new SyntaxError("An invalid or illegal string was specified.");O=M,this.hasBeenReset=!0}})),u.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}();class XS{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function Zg(i){function e(r,s,n,a){return(r|0)*3600+(s|0)*60+(n|0)+parseFloat(a||0)}const t=i.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return t?parseFloat(t[2])>59?e(t[2],t[3],0,t[4]):e(t[1],t[2],t[3],t[4]):null}class QS{constructor(){this.values=Object.create(null)}set(e,t){!this.get(e)&&t!==""&&(this.values[e]=t)}get(e,t,r){return r?this.has(e)?this.values[e]:t[r]:this.has(e)?this.values[e]:t}has(e){return e in this.values}alt(e,t,r){for(let s=0;s<r.length;++s)if(t===r[s]){this.set(e,t);break}}integer(e,t){/^-?\d+$/.test(t)&&this.set(e,parseInt(t,10))}percent(e,t){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(t)){const r=parseFloat(t);if(r>=0&&r<=100)return this.set(e,r),!0}return!1}}function Jg(i,e,t,r){const s=r?i.split(r):[i];for(const n in s){if(typeof s[n]!="string")continue;const a=s[n].split(t);if(a.length!==2)continue;const o=a[0],l=a[1];e(o,l)}}const rc=new nf(0,0,""),no=rc.align==="middle"?"middle":"center";function ZS(i,e,t){const r=i;function s(){const o=Zg(i);if(o===null)throw new Error("Malformed timestamp: "+r);return i=i.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){const d=new QS;Jg(o,function(h,f){let m;switch(h){case"region":for(let p=t.length-1;p>=0;p--)if(t[p].id===f){d.set(h,t[p].region);break}break;case"vertical":d.alt(h,f,["rl","lr"]);break;case"line":m=f.split(","),d.integer(h,m[0]),d.percent(h,m[0])&&d.set("snapToLines",!1),d.alt(h,m[0],["auto"]),m.length===2&&d.alt("lineAlign",m[1],["start",no,"end"]);break;case"position":m=f.split(","),d.percent(h,m[0]),m.length===2&&d.alt("positionAlign",m[1],["start",no,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",no,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let u=d.get("line","auto");u==="auto"&&rc.line===-1&&(u=-1),l.line=u,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",no);let c=d.get("position","auto");c==="auto"&&rc.position===50&&(c=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=c}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=s(),a(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+r);i=i.slice(3),a(),e.endTime=s(),a(),n(i,e)}function ev(i){return i.replace(/<br(?: \/)?>/gi,`
37
+ `)}class JS{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new XS,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}parse(e){const t=this;e&&(t.buffer+=t.decoder.decode(e,{stream:!0}));function r(){let n=t.buffer,a=0;for(n=ev(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
38
38
  `;)++a;const o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
39
- `&&++a,t.buffer=n.slice(a),o}function s(n){Qg(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=r();const o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:n=r(),t.state){case"HEADER":/:/.test(n)?s(n):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new rf(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{XS(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const o=n.indexOf("-->")!==-1;if(!n||o&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
39
+ `&&++a,t.buffer=n.slice(a),o}function s(n){Jg(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=r();const o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:n=r(),t.state){case"HEADER":/:/.test(n)?s(n):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new nf(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{ZS(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const o=n.indexOf("-->")!==-1;if(!n||o&&(a=!0)){t.oncue&&t.cue&&t.oncue(t.cue),t.cue=null,t.state="ID";continue}if(t.cue===null)continue;t.cue.text&&(t.cue.text+=`
40
40
  `),t.cue.text+=n}continue;case"BADCUE":n||(t.state="ID")}}}catch{t.state==="CUETEXT"&&t.cue&&t.oncue&&t.oncue(t.cue),t.cue=null,t.state=t.state==="INITIAL"?"BADWEBVTT":"BADCUE"}return this}flush(){const e=this;try{if((e.cue||e.state==="HEADER")&&(e.buffer+=`
41
41
 
42
- `,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const ZS=/\r\n|\n\r|\n|\r/g,cu=function(e,t,r=0){return e.slice(r,r+t.length)===t},JS=function(e){let t=parseInt(e.slice(-3));const r=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!Y(t)||!Y(r)||!Y(s)||!Y(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=60*1e3*s,t+=60*60*1e3*n,t},hu=function(e){let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return(t>>>0).toString()};function sf(i,e,t){return hu(i.toString())+hu(e.toString())+hu(t)}const ex=function(e,t,r){let s=e[t],n=e[s.prevCC];if(!n||!n.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=s.start-n.start,s.new=!1,s=n,n=e[s.prevCC]}e.presentationOffset=r};function tx(i,e,t,r,s,n,a){const o=new QS,l=Si(new Uint8Array(i)).trim().replace(ZS,`
42
+ `,e.parse()),e.state==="INITIAL"||e.state==="BADWEBVTT")throw new Error("Malformed WebVTT signature.")}catch(t){e.onparsingerror&&e.onparsingerror(t)}return e.onflush&&e.onflush(),this}}const ex=/\r\n|\n\r|\n|\r/g,fu=function(e,t,r=0){return e.slice(r,r+t.length)===t},tx=function(e){let t=parseInt(e.slice(-3));const r=parseInt(e.slice(-6,-4)),s=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!Y(t)||!Y(r)||!Y(s)||!Y(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*r,t+=60*1e3*s,t+=60*60*1e3*n,t},mu=function(e){let t=5381,r=e.length;for(;r;)t=t*33^e.charCodeAt(--r);return(t>>>0).toString()};function af(i,e,t){return mu(i.toString())+mu(e.toString())+mu(t)}const ix=function(e,t,r){let s=e[t],n=e[s.prevCC];if(!n||!n.new&&s.new){e.ccOffset=e.presentationOffset=s.start,s.new=!1;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=s.start-n.start,s.new=!1,s=n,n=e[s.prevCC]}e.presentationOffset=r};function rx(i,e,t,r,s,n,a){const o=new JS,l=Si(new Uint8Array(i)).trim().replace(ex,`
43
43
  `).split(`
44
- `),d=[],u=e?ES(e.baseTime,e.timescale):0;let c="00:00.000",h=0,f=0,m,p=!0;o.oncue=function(g){const E=t[r];let y=t.ccOffset;const b=(h-u)/9e4;if(E!=null&&E.new&&(f!==void 0?y=t.ccOffset=E.start:ex(t,r,b)),b){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}y=b-t.presentationOffset}const S=g.endTime-g.startTime,_=Nt((g.startTime+y-f)*9e4,s*9e4)/9e4;g.startTime=Math.max(_,0),g.endTime=Math.max(_+S,0);const x=g.text.trim();g.text=decodeURIComponent(encodeURIComponent(x)),g.id||(g.id=sf(g.startTime,g.endTime,x)),g.endTime>0&&d.push(g)},o.onparsingerror=function(g){m=g},o.onflush=function(){if(m){a(m);return}n(d)},l.forEach(g=>{if(p)if(cu(g,"X-TIMESTAMP-MAP=")){p=!1,g.slice(16).split(",").forEach(E=>{cu(E,"LOCAL:")?c=E.slice(6):cu(E,"MPEGTS:")&&(h=parseInt(E.slice(7)))});try{f=JS(c)/1e3}catch(E){m=E}return}else g===""&&(p=!1);o.parse(g+`
45
- `)}),o.flush()}const fu="stpp.ttml.im1t",Jg=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,ev=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,ix={left:"start",center:"center",right:"end",start:"start",end:"end"};function ap(i,e,t,r){const s=le(new Uint8Array(i),["mdat"]);if(s.length===0){r(new Error("Could not parse IMSC1 mdat"));return}const n=s.map(o=>Si(o)),a=vS(e.baseTime,1,e.timescale);try{n.forEach(o=>t(rx(o,a)))}catch(o){r(o)}}function rx(i,e){const s=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");const n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((c,h)=>(c[h]=s.getAttribute(`ttp:${h}`)||n[h],c),{}),o=s.getAttribute("xml:space")!=="preserve",l=op(mu(s,"styling","style")),d=op(mu(s,"layout","region")),u=mu(s,"body","[begin]");return[].map.call(u,c=>{const h=tv(c,o);if(!h||!c.hasAttribute("begin"))return null;const f=gu(c.getAttribute("begin"),a),m=gu(c.getAttribute("dur"),a);let p=gu(c.getAttribute("end"),a);if(f===null)throw lp(c);if(p===null){if(m===null)throw lp(c);p=f+m}const g=new rf(f-e,p-e,h);g.id=sf(g.startTime,g.endTime,g.text);const E=d[c.getAttribute("region")],y=l[c.getAttribute("style")],b=sx(E,y,l),{textAlign:S}=b;if(S){const _=ix[S];_&&(g.lineAlign=_),g.align=S}return We(g,b),g}).filter(c=>c!==null)}function mu(i,e,t){const r=i.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(t)):[]}function op(i){return i.reduce((e,t)=>{const r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function tv(i,e){return[].slice.call(i.childNodes).reduce((t,r,s)=>{var n;return r.nodeName==="br"&&s?t+`
46
- `:(n=r.childNodes)!=null&&n.length?tv(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function sx(i,e,t){const r="http://www.w3.org/ns/ttml#styling";let s=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(s=t[a]),n.reduce((o,l)=>{const d=pu(e,r,l)||pu(i,r,l)||pu(s,r,l);return d&&(o[l]=d),o},{})}function pu(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function lp(i){return new Error(`Could not parse ttml timestamp ${i}`)}function gu(i,e){if(!i)return null;let t=Xg(i);return t===null&&(Jg.test(i)?t=nx(i,e):ev.test(i)&&(t=ax(i,e))),t}function nx(i,e){const t=Jg.exec(i),r=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+r/e.frameRate}function ax(i,e){const t=ev.exec(i),r=Number(t[1]);switch(t[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}class ox{constructor(e){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=up(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.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}},e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){const e=new ro(this,"textTrack1"),t=new ro(this,"textTrack2"),r=new ro(this,"textTrack3"),s=new ro(this,"textTrack4");this.cea608Parser1=new np(1,e,t),this.cea608Parser2=new np(3,r,s)}}addCues(e,t,r,s,n){let a=!1;for(let o=n.length;o--;){const l=n[o],d=lx(l[0],l[1],t,r);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],r),a=!0,d/(r-t)>.5))return}if(a||n.push([t,r]),this.config.renderTextTracksNatively){const o=this.captionsTracks[e];this.Cues.newCue(o,t,r,s)}else{const o=this.Cues.newCue(null,t,r,s);this.hls.trigger(v.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){const{unparsedVttFrags:a}=this;r==="main"&&(this.initPTS[t.cc]={baseTime:s,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(v.FRAG_LOADED,o)}))}getExistingTrack(e,t){const{media:r}=this;if(r)for(let s=0;s<r.textTracks.length;s++){const n=r.textTracks[s];if(dp(n,{name:e,lang:t,attrs:{}}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:r,media:s}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)r[e]=o,zs(r[e]),Tg(r[e],s);else{const l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,r[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const r=t.label,s={_id:e,label:r,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,r){const s=this.media;if(s)return s.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach(t=>{zs(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=up(),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:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let r=0;r<t.length;r++)zs(t[r])}onSubtitleTracksUpdated(e,t){const r=t.subtitleTracks||[],s=r.some(n=>n.textCodec===fu);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(Yg(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const a=this.media,o=a?Lo(a.textTracks):null;if(this.tracks.forEach((l,d)=>{let u;if(o){let c=null;for(let h=0;h<o.length;h++)if(o[h]&&dp(o[h],l)){c=o[h],o[h]=null;break}c&&(u=c)}if(u)zs(u);else{const c=iv(l);u=this.createTextTrack(c,l.name,l.lang),u&&(u.mode="disabled")}u&&this.textTracks.push(u)}),o!=null&&o.length){const l=o.filter(d=>d!==null).map(d=>d.label);l.length&&I.warn(`Media element contains unused subtitle tracks: ${l.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(r=>{const s=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!s)return;const n=`textTrack${s[1]}`,a=this.captionsProperties[n];a&&(a.label=r.name,r.lang&&(a.languageCode=r.lang),a.media=r)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===ee.MAIN){var r,s;const{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:l,sn:d}=t.frag,u=(r=(s=t.part)==null?void 0:s.index)!=null?r:-1;n&&a&&(d!==o+1||d===o&&u!==this.lastPartIndex+1||l!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=l,this.lastSn=d,this.lastPartIndex=u}}onFragLoaded(e,t){const{frag:r,payload:s}=t;if(r.type===ee.SUBTITLE)if(s.byteLength){const n=r.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){const o=this.tracks[r.level],l=this.vttCCs;l[r.cc]||(l[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),o&&o.textCodec===fu?this._parseIMSC1(r,s):this._parseVTTs(t)}}else this.hls.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;ap(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),r.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{I.log(`Failed to parse IMSC1: ${s}`),r.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;const{frag:r,payload:s}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[r.cc]&&o===-1){a.push(e);return}const l=this.hls,d=(t=r.initSegment)!=null&&t.data?Ut(r.initSegment.data,new Uint8Array(s)):s;tx(d,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,u=>{this._appendCues(u,r.level),l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},u=>{const c=u.message==="Missing initPTS for VTT MPEGTS";c?a.push(e):this._fallbackToIMSC1(r,s),I.log(`Failed to parse VTT cue: ${u}`),!(c&&o>r.cc)&&l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:u})})}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||ap(t,this.initPTS[e.cc],()=>{r.textCodec=fu,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){const r=this.hls;if(this.config.renderTextTracksNatively){const s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(n=>_g(s,n))}else{const s=this.tracks[t];if(!s)return;const n=s.default?"default":"subtitles"+t;r.trigger(v.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:r}=t;r.type===ee.SUBTITLE&&this.onFragLoaded(v.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();const{cea608Parser1:r,cea608Parser2:s}=this;if(!this.enabled||!r||!s)return;const{frag:n,samples:a}=t;if(!(n.type===ee.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){const l=a[o].bytes;if(l){const d=this.extractCea608Data(l);r.addData(a[o].pts,d[0]),s.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:s,type:n}){const{media:a}=this;if(!(!a||a.currentTime<r)){if(!n||n==="video"){const{captionsTracks:o}=this;Object.keys(o).forEach(l=>ju(o[l],t,r))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(l=>ju(o[l],t,s))}}}extractCea608Data(e){const t=[[],[]],r=e[0]&31;let s=2;for(let n=0;n<r;n++){const a=e[s++],o=127&e[s++],l=127&e[s++];if(o===0&&l===0)continue;if((4&a)!==0){const u=3&a;(u===0||u===1)&&(t[u].push(o),t[u].push(l))}}return t}}function iv(i){return i.characteristics&&/transcribes-spoken-dialog/gi.test(i.characteristics)&&/describes-music-and-sound/gi.test(i.characteristics)?"captions":"subtitles"}function dp(i,e){return!!i&&i.kind===iv(e)&&ec(e,i)}function lx(i,e,t,r){return Math.min(e,r)-Math.max(i,t)}function up(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class nf{constructor(e){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=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&Y(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}const e=this.hls.levels;if(e.length){const t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&I.log(`Setting autoLevelCapping to ${r}: ${e[r].height}p@${e[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const r=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.clientRect=null,nf.getMaxLevelByMediaSize(r,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 e=this.media,t={width:0,height:0};if(e){const r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,!t.width&&!t.height&&(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(r=>e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height)}static getMaxLevelByMediaSize(e,t,r){if(!(e!=null&&e.length))return-1;const s=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0;let n=e.length-1;const a=Math.max(t,r);for(let o=0;o<e.length;o+=1){const l=e[o];if((l.width>=a||l.height>=a)&&s(l,e[o+1])){n=o;break}}return n}}class dx{constructor(e){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=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const r=this.hls.config;if(r.capLevelOnFPSDrop){const s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){const s=performance.now();if(t){if(this.lastTime){const n=s-this.lastTime,a=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(v.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:r}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let u=d.currentLevel;I.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=u)&&(u=u-1,d.trigger(v.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:d.currentLevel}),d.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}const no="[eme]";class tn{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=tn.CDMCleanupPromise?[tn.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=I.debug.bind(I,no),this.log=I.log.bind(I,no),this.warn=I.warn.bind(I,no),this.error=I.error.bind(I,no),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:r}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===Ie.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){const{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,r=(a,o,l)=>!!a&&l.indexOf(a)===o,s=t.map(a=>a.audioCodec).filter(r),n=t.map(a=>a.videoCodec).filter(r);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{const l=d=>{const u=d.shift();this.getMediaKeysPromise(u,s,n).then(c=>a({keySystem:u,mediaKeys:c})).catch(c=>{d.length?l(d):c instanceof Dt?o(c):o(new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_ACCESS,error:c,fatal:!0},c.message))})};l(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:r}=this.config;if(typeof r!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${r}`;return lg===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return r(e,t)}getMediaKeysPromise(e,t,r){const s=p1(e,t,r,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e];let a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(s)}`),a=this.requestMediaKeySystemAccess(e,s);const o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);const d=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(u=>(this.log(`Media-keys created for "${e}"`),d.then(c=>c?this.setMediaKeysServerCertificate(u,e,c):u))),o.mediaKeys.catch(u=>{this.error(`Failed to create media-keys for "${e}"}: ${u}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${mi.hexDump(e.keyId||[])}`);const s=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const r=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(r,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return mi.hexDump(e.keyId)}updateKeySession(e,t){var r;const s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${mi.hexDump(((r=e.decryptdata)==null?void 0:r.keyId)||[])}
47
- } (data length: ${t&&t.byteLength})`),s.update(t)}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{const s=Zd(this.config),n=e.map(gm).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{const o=Em(a);o?t(o):r(new Error(`Unable to find format for key-system "${a}"`))}).catch(r)})}loadKey(e){const t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),s=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[r];return n||(n=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();const l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t});return this.generateRequestWithPreferredKeySession(l,"cenc",t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof Dt?this.hls.trigger(v.ERROR,e.data):this.hls.trigger(v.ERROR,{type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){const s=gm(e.keyFormat),n=s?[s]:Zd(this.config);return this.attemptKeySystemAccess(n)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=Zd(this.config)),e.length===0)throw new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:t,initData:r}=e,s=`"${e.type}" event: init data type: "${t}"`;if(this.debug(s),r===null)return;let n,a;if(t==="sinf"&&this.config.drmSystems[Ie.FAIRPLAY]){const c=Ve(new Uint8Array(r));try{const h=Wh(JSON.parse(c).sinf),f=gg(new Uint8Array(h));if(!f)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");n=f.subarray(8,24),a=Ie.FAIRPLAY}catch(h){this.warn(`${s} Failed to parse sinf: ${h}`);return}}else{const c=B1(r),h=c.filter(f=>f.systemId===Hn.WIDEVINE)[0];if(!h){c.length===0||c.some(f=>!f.systemId)?this.warn(`${s} contains incomplete or invalid pssh data`):this.log(`ignoring ${s} for ${c.map(f=>vm(f.systemId)).join(",")} pssh data in favor of playlist keys`);return}if(a=vm(h.systemId),h.version===0&&h.data){const f=h.data.length-22;n=h.data.subarray(f,f+16)}}if(!a||!n)return;const o=mi.hexDump(n),{keyIdToKeySessionPromise:l,mediaKeySessions:d}=this;let u=l[o];for(let c=0;c<d.length;c++){const h=d[c],f=h.decryptdata;if(!f.keyId)continue;const m=mi.hexDump(f.keyId);if(o===m||f.uri.replace(/-/g,"").indexOf(o)!==-1){if(u=l[m],f.pssh)break;delete l[m],f.pssh=new Uint8Array(r),f.keyId=n,u=l[o]=u.then(()=>this.generateRequestWithPreferredKeySession(h,t,r,"encrypted-event-key-match"));break}}u||(u=l[o]=this.getKeySystemSelectionPromise([a]).then(({keySystem:c,mediaKeys:h})=>{var f;this.throwIfDestroyed();const m=new Ia("ISO-23001-7",o,(f=Em(c))!=null?f:"");return m.pssh=new Uint8Array(r),m.keyId=n,this.attemptSetMediaKeys(c,h).then(()=>{this.throwIfDestroyed();const p=this.createMediaKeySessionContext({decryptdata:m,keySystem:c,mediaKeys:h});return this.generateRequestWithPreferredKeySession(p,t,r,"encrypted-event-no-match")})})),u.catch(c=>this.handleError(c))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const s=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>r.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,r,s){var n,a;const o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{const m=o.call(this.hls,t,r,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,r=e.decryptdata.pssh=m.initData?new Uint8Array(m.initData):null}catch(m){var l;if(this.warn(m.message),(l=this.hls)!=null&&l.config.debug)throw m}if(r===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);const d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${d} (init data type: ${t} length: ${r?r.byteLength:null})`);const u=new tf,c=e._onmessage=m=>{const p=e.mediaKeysSession;if(!p){u.emit("error",new Error("invalid state"));return}const{messageType:g,message:E}=m;this.log(`"${g}" message event for session "${p.sessionId}" message size: ${E.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,E).catch(y=>{this.handleError(y),u.emit("error",y)}):g==="license-release"?e.keySystem===Ie.FAIRPLAY&&(this.updateKeySession(e,qu("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);const g=e.keyStatus;u.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",c),e.mediaKeysSession.addEventListener("keystatuseschange",h);const f=new Promise((m,p)=>{u.on("error",p),u.on("keyStatus",g=>{g.startsWith("usable")?m():g==="output-restricted"?p(new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?p(new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?p(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var m;this.log(`Request generated for key-session "${(m=e.mediaKeysSession)==null?void 0:m.sessionId}" keyId: ${d}`)}).catch(m=>{throw new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_SESSION,error:m,fatal:!1},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>{throw u.removeAllListeners(),this.removeSession(e),m}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${mi.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${mi.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,r=t.loader,s=new r(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{const l={responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{a(h.data)},onError:(h,f,m,p)=>{o(new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:dt({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,m)=>{o(new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,m)=>{o(new Error("aborted"))}};s.load(l,u,c)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((s,n)=>{e.setServerCertificate(r).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${r==null?void 0:r.byteLength}) on "${t}"`),s(e)}).catch(a=>{n(new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(r=>this.updateKeySession(e,new Uint8Array(r)).catch(s=>{throw new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}unpackPlayReadyKeyMessage(e,t){const r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const s=new DOMParser().parseFromString(r,"application/xml"),n=s.querySelectorAll("HttpHeader");if(n.length>0){let u;for(let c=0,h=n.length;c<h;c++){var a,o;u=n[c];const f=(a=u.querySelector("name"))==null?void 0:a.textContent,m=(o=u.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m)}}const l=s.querySelector("Challenge"),d=l==null?void 0:l.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return qu(atob(d))}setupLicenseXHR(e,t,r,s){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,s)}).catch(a=>{if(!r.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,r,s)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){const r=this.config.keyLoadPolicy.default;return new Promise((s,n)=>{const a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);const d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e)}catch(u){this.error(u)}s(l)}else{const l=r.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{const u=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} attempts left`),this.requestLicense(e,t).then(s,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:d})=>{e.keySystem==Ie.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(l,d)),l.send(d)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Ia.clearKeyUriToKeyIdMap();const r=t.length;tn.CDMCleanupPromise=Promise.all(t.map(s=>this.removeSession(s)).concat(e==null?void 0:e.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const r=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${r.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(r)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}}tn.CDMCleanupPromise=void 0;class Dt extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}var pt;(function(i){i.MANIFEST="m",i.AUDIO="a",i.VIDEO="v",i.MUXED="av",i.INIT="i",i.CAPTION="c",i.TIMED_TEXT="tt",i.KEY="k",i.OTHER="o"})(pt||(pt={}));var ic;(function(i){i.DASH="d",i.HLS="h",i.SMOOTH="s",i.OTHER="o"})(ic||(ic={}));var zr;(function(i){i.OBJECT="CMCD-Object",i.REQUEST="CMCD-Request",i.SESSION="CMCD-Session",i.STATUS="CMCD-Status"})(zr||(zr={}));const ux={[zr.OBJECT]:["br","d","ot","tb"],[zr.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[zr.SESSION]:["cid","pr","sf","sid","st","v"],[zr.STATUS]:["bs","rtp"]};class gn{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(r=>r instanceof gn?r:new gn(r))),this.value=e,this.params=t}}class rv{constructor(e){this.description=void 0,this.description=e}}const cx="Dict";function hx(i){return Array.isArray(i)?JSON.stringify(i):i instanceof Map?"Map{}":i instanceof Set?"Set{}":typeof i=="object"?JSON.stringify(i):String(i)}function fx(i,e,t,r){return new Error(`failed to ${i} "${hx(e)}" as ${t}`,{cause:r})}const cp="Bare Item",mx="Boolean",px="Byte Sequence",gx="Decimal",vx="Integer";function Ex(i){return i<-999999999999999||999999999999999<i}const yx=/[\x00-\x1f\x7f]+/,bx="Token",Tx="Key";function ki(i,e,t){return fx("serialize",i,e,t)}function _x(i){if(typeof i!="boolean")throw ki(i,mx);return i?"?1":"?0"}function Ax(i){return btoa(String.fromCharCode(...i))}function Sx(i){if(ArrayBuffer.isView(i)===!1)throw ki(i,px);return`:${Ax(i)}:`}function sv(i){if(Ex(i))throw ki(i,vx);return i.toString()}function xx(i){return`@${sv(i.getTime()/1e3)}`}function nv(i,e){if(i<0)return-nv(-i,e);const t=Math.pow(10,e);if(Math.abs(i*t%1-.5)<Number.EPSILON){const s=Math.floor(i*t);return(s%2===0?s:s+1)/t}else return Math.round(i*t)/t}function kx(i){const e=nv(i,3);if(Math.floor(Math.abs(e)).toString().length>12)throw ki(i,gx);const t=e.toString();return t.includes(".")?t:`${t}.0`}const Lx="String";function Ix(i){if(yx.test(i))throw ki(i,Lx);return`"${i.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Rx(i){return i.description||i.toString().slice(7,-1)}function hp(i){const e=Rx(i);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw ki(e,bx);return e}function rc(i){switch(typeof i){case"number":if(!Y(i))throw ki(i,cp);return Number.isInteger(i)?sv(i):kx(i);case"string":return Ix(i);case"symbol":return hp(i);case"boolean":return _x(i);case"object":if(i instanceof Date)return xx(i);if(i instanceof Uint8Array)return Sx(i);if(i instanceof rv)return hp(i);default:throw ki(i,cp)}}function sc(i){if(/^[a-z*][a-z0-9\-_.*]*$/.test(i)===!1)throw ki(i,Tx);return i}function af(i){return i==null?"":Object.entries(i).map(([e,t])=>t===!0?`;${sc(e)}`:`;${sc(e)}=${rc(t)}`).join("")}function av(i){return i instanceof gn?`${rc(i.value)}${af(i.params)}`:rc(i)}function wx(i){return`(${i.value.map(av).join(" ")})${af(i.params)}`}function Cx(i,e={whitespace:!0}){if(typeof i!="object")throw ki(i,cx);const t=i instanceof Map?i.entries():Object.entries(i),r=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([s,n])=>{n instanceof gn||(n=new gn(n));let a=sc(s);return n.value===!0?a+=af(n.params):(a+="=",Array.isArray(n.value)?a+=wx(n):a+=av(n)),a}).join(`,${r}`)}function Dx(i,e){return Cx(i,e)}const Mx=i=>i==="ot"||i==="sf"||i==="st",Px=i=>typeof i=="number"?Y(i):i!=null&&i!==""&&i!==!1;function Ox(i,e){const t=new URL(i),r=new URL(e);if(t.origin!==r.origin)return i;const s=t.pathname.split("/").slice(1),n=r.pathname.split("/").slice(1,-1);for(;s[0]===n[0];)s.shift(),n.shift();for(;n.length;)n.shift(),s.unshift("..");return s.join("/")}function Nx(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(s=="x"?n:n&3|8).toString(16)})}}}const Mo=i=>Math.round(i),Fx=(i,e)=>(e!=null&&e.baseUrl&&(i=Ox(i,e.baseUrl)),encodeURIComponent(i)),ao=i=>Mo(i/100)*100,Ux={br:Mo,d:Mo,bl:ao,dl:ao,mtp:ao,nor:Fx,rtp:ao,tb:Mo};function $x(i,e){const t={};if(i==null||typeof i!="object")return t;const r=Object.keys(i).sort(),s=We({},Ux,e==null?void 0:e.formatters),n=e==null?void 0:e.filter;return r.forEach(a=>{if(n!=null&&n(a))return;let o=i[a];const l=s[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||Px(o)&&(Mx(a)&&typeof o=="string"&&(o=new rv(o)),t[a]=o))}),t}function ov(i,e={}){return i?Dx($x(i,e),We({whitespace:!1},e)):""}function Bx(i,e={}){if(!i)return{};const t=Object.entries(i),r=Object.entries(ux).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),s=t.reduce((n,a)=>{var o,l;const[d,u]=a,c=((o=r.find(h=>h[1].includes(d)))==null?void 0:o[0])||zr.REQUEST;return(l=n[c])!=null||(n[c]={}),n[c][d]=u,n},{});return Object.entries(s).reduce((n,[a,o])=>(n[a]=ov(o,e),n),{})}function Gx(i,e,t){return We(i,Bx(e,t))}const Hx="CMCD";function Wx(i,e={}){if(!i)return"";const t=ov(i,e);return`${Hx}=${encodeURIComponent(t)}`}const fp=/CMCD=[^&#]+/;function Kx(i,e,t){const r=Wx(e,t);if(!r)return i;if(fp.test(i))return i.replace(fp,r);const s=i.includes("?")?"&":"?";return`${i}${s}${r}`}class Vx{constructor(e){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=s=>{try{this.apply(s,{ot:pt.MANIFEST,su:!this.initialized})}catch(n){I.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{const n=s.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===pt.VIDEO||o===pt.AUDIO||o==pt.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(s,l)}catch(n){I.warn("Could not generate segment CMCD data.",n)}},this.hls=e;const t=this.config=e.config,{cmcd:r}=t;r!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||Nx(),this.cid=r.contentId,this.useHeaders=r.useHeaders===!0,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHED,this.onMediaDetached,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHED,this.onMediaDetached,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.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(e,t){var r,s;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:1,sf:ic.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){We(t,this.createData());const r=t.ot===pt.INIT||t.ot===pt.VIDEO||t.ot===pt.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:s}=this;s&&(t=Object.keys(t).reduce((n,a)=>(s.includes(a)&&(n[a]=t[a]),n),{})),this.useHeaders?(e.headers||(e.headers={}),Gx(e.headers,t)):e.url=Kx(e.url,t)}getObjectType(e){const{type:t}=e;if(t==="subtitle")return pt.TIMED_TEXT;if(e.sn==="initSegment")return pt.INIT;if(t==="audio")return pt.AUDIO;if(t==="main")return this.hls.audioTracks.length?pt.VIDEO:pt.MUXED}getTopBandwidth(e){let t=0,r;const s=this.hls;if(e===pt.AUDIO)r=s.audioTracks;else{const n=s.maxAutoLevel,a=n>-1?n+1:s.levels.length;r=s.levels.slice(0,a)}for(const n of r)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){const t=this.hls.media,r=e===pt.AUDIO?this.audioBuffer:this.videoBuffer;return!r||!t?NaN:Le.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}}const qx=3e5;class Yx{constructor(e){this.hls=void 0,this.log=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=e,this.log=I.log.bind(I,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(r=>r!==e))}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(e,t){const{contentSteering:r}=t;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:r}=t;if((r==null?void 0:r.action)===ht.SendAlternateToPenaltyBox&&r.flags===Gt.MoveAllAlternatesMatchingHost){const s=this.levels;let n=this.pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:o,pathwayId:l,type:d}=t.context;o&&s?a=this.getPathwayForGroupId(o,d,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&s&&(n=s.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==a),r.resolved||I.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${s&&s.length} priorities: ${JSON.stringify(n)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t;const r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(n=>{s-r[n]>qx&&delete r[n]});for(let n=0;n<e.length;n++){const a=e[n];if(a in r)continue;if(a===this.pathwayId)return;const o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,kg(t),this.hls.trigger(v.LEVELS_UPDATED,{levels:t});const d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,r){const s=this.getLevelsForPathway(r).concat(this.levels||[]);for(let n=0;n<s.length;n++)if(t===fe.AUDIO_TRACK&&s[n].hasAudioGroup(e)||t===fe.SUBTITLE_TRACK&&s[n].hasSubtitleGroup(e))return s[n].pathwayId;return r}clonePathways(e){const t=this.levels;if(!t)return;const r={},s={};e.forEach(n=>{const{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(u=>u.pathwayId===a))return;const d=this.getLevelsForPathway(o).map(u=>{const c=new Me(u.attrs);c["PATHWAY-ID"]=a;const h=c.AUDIO&&`${c.AUDIO}_clone_${a}`,f=c.SUBTITLES&&`${c.SUBTITLES}_clone_${a}`;h&&(r[c.AUDIO]=h,c.AUDIO=h),f&&(s[c.SUBTITLES]=f,c.SUBTITLES=f);const m=lv(u.uri,c["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),p=new mn({attrs:c,audioCodec:u.audioCodec,bitrate:u.bitrate,height:u.height,name:u.name,url:m,videoCodec:u.videoCodec,width:u.width});if(u.audioGroups)for(let g=1;g<u.audioGroups.length;g++)p.addGroupId("audio",`${u.audioGroups[g]}_clone_${a}`);if(u.subtitleGroups)for(let g=1;g<u.subtitleGroups.length;g++)p.addGroupId("text",`${u.subtitleGroups[g]}_clone_${a}`);return p});t.push(...d),mp(this.audioTracks,r,l,a),mp(this.subtitleTracks,s,l,a)})}loadSteeringManifest(e){const t=this.hls.config,r=t.loader;this.loader&&this.loader.destroy(),this.loader=new r(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){const u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+u)}const n={responseType:"json",url:s.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(u,c,h,f)=>{this.log(`Loaded steering manifest: "${s}"`);const m=u.data;if(m.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;const{"RELOAD-URI":p,"PATHWAY-CLONES":g,"PATHWAY-PRIORITY":E}=m;if(p)try{this.uri=new self.URL(p,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${p}`);return}this.scheduleRefresh(this.uri||h.url),g&&this.clonePathways(g);const y={steeringManifest:m,url:s.toString()};this.hls.trigger(v.STEERING_MANIFEST_LOADED,y),E&&this.updatePathwayPriority(E)},onError:(u,c,h,f)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${c.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${c.url} no longer available`);return}let m=this.timeToLoad*1e3;if(u.code===429){const p=this.loader;if(typeof(p==null?void 0:p.getResponseHeader)=="function"){const g=p.getResponseHeader("Retry-After");g&&(m=parseFloat(g)*1e3)}this.log(`Steering manifest ${c.url} rate limited`);return}this.scheduleRefresh(this.uri||c.url,m)},onTimeout:(u,c,h)=>{this.log(`Timeout loading steering manifest (${c.url})`),this.scheduleRefresh(this.uri||c.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var r;const s=(r=this.hls)==null?void 0:r.media;if(s&&!s.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function mp(i,e,t,r){i&&Object.keys(e).forEach(s=>{const n=i.filter(a=>a.groupId===s).map(a=>{const o=We({},a);return o.details=void 0,o.attrs=new Me(o.attrs),o.url=o.attrs.URI=lv(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=r,o});i.push(...n)})}function lv(i,e,t,r){const{HOST:s,PARAMS:n,[t]:a}=r;let o;e&&(o=a==null?void 0:a[e],o&&(i=o));const l=new self.URL(i);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}const jx=/^age:\s*[\d.]+\s*$/im;class dv{constructor(e){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=e&&e.xhrSetup||null,this.stats=new Id,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const r=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==r||this.stats.aborted))return n(r,t.url)}).catch(a=>{if(!(this.loader!==r||this.stats.aborted))return r.open("GET",t.url,!0),n(r,t.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(a=>{this.callbacks.onError({code:r.status,text:a.message},t,r,s)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);const s=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=r.loadPolicy;if(s)for(const o in s)e.setRequestHeader(o,s[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&Y(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:r}=this;if(!e||!t)return;const s=t.readyState,n=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const a=t.status,o=t.responseType!=="text";if(a>=200&&a<300&&(o&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);const l=o?t.response:t.responseText,d=t.responseType==="arraybuffer"?l.byteLength:l.length;if(r.loaded=r.total=d,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;const u=this.callbacks.onProgress;if(u&&u(r,e,l,t),!this.callbacks)return;const c={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(c,r,e,t)}else{const l=n.loadPolicy.errorRetry,d=r.retry,u={url:e.url,data:void 0,code:a};Zl(l,d,!1,u)?this.retry(l):(I.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(Zl(e,t,!0))this.retry(e);else{var r;I.warn(`timeout while loading ${(r=this.context)==null?void 0:r.url}`);const s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:r}=this;this.retryDelay=qh(e,r.retry),r.retry++,I.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${r.retry}/${e.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(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&jx.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}function zx(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const Xx=/(\d+)-(\d+)\/(\d+)/;class pp{constructor(e){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=e.fetchSetup||ek,this.controller=new self.AbortController,this.stats=new Id}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 e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();const n=Qx(e,this.controller.signal),a=r.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&Y(d)?d:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},t.timeout),self.fetch(this.request).then(c=>{this.response=this.loader=c;const h=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},u-(h-s.loading.start)),!c.ok){const{status:f,statusText:m}=c;throw new tk(m||"fetch, bad network response",f,c)}return s.loading.first=h,s.total=Jx(c.headers)||s.total,a&&Y(t.highWaterMark)?this.loadProgressively(c,s,e,t.highWaterMark,a):o?c.arrayBuffer():e.responseType==="json"?c.json():c.text()}).then(c=>{const h=this.response;if(!h)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const f=c[l];f&&(s.loaded=s.total=f);const m={url:h.url,data:c,code:h.status};a&&!Y(t.highWaterMark)&&a(s,e,c,h),r.onSuccess(m,s,e,h)}).catch(c=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;const h=c&&c.code||0,f=c?c.message:null;r.onError({code:h,text:f},e,c?c.details:null,s)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,s=0,n){const a=new wg,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));const u=d.value,c=u.length;return t.loaded+=c,c<s||a.dataLength?(a.push(u),a.dataLength>=s&&n(t,r,a.flush(),e)):n(t,r,u,e),l()}).catch(()=>Promise.reject());return l()}}function Qx(i,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(We({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function Zx(i){const e=Xx.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function Jx(i){const e=i.get("Content-Range");if(e){const r=Zx(e);if(Y(r))return r}const t=i.get("Content-Length");if(t)return parseInt(t)}function ek(i,e){return new self.Request(i.url,e)}class tk extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}}const ik=/\s/,rk={newCue(i,e,t,r){const s=[];let n,a,o,l,d;const u=self.VTTCue||self.TextTrackCue;for(let h=0;h<r.rows.length;h++)if(n=r.rows[h],o=!0,l=0,d="",!n.isEmpty()){var c;for(let p=0;p<n.chars.length;p++)ik.test(n.chars[p].uchar)&&o?l++:(d+=n.chars[p].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;const f=Zg(d.trim()),m=sf(e,t,f);i!=null&&(c=i.cues)!=null&&c.getCueById(m)||(a=new u(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),s.push(a))}return i&&s.length&&(s.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),s.forEach(h=>_g(i,h))),s}},sk={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},uv=dt(dt({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,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,loader:dv,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:CA,bufferController:OS,capLevelController:nf,errorController:yA,fpsController:dx,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:lg,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:sk},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}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},nk()),{},{subtitleStreamController:CS,subtitleTrackController:MS,timelineController:ox,audioStreamController:RS,audioTrackController:wS,emeController:tn,cmcdController:Vx,contentSteeringController:Yx});function nk(){return{cueHandler:rk,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function ak(i,e){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(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const t=nc(i),r=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(n=>{const a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];s.forEach(d=>{const u=`${n}Loading${d}`,c=e[u];if(c!==void 0&&o){l.push(u);const h=t[a].default;switch(e[a]={default:h},d){case"TimeOut":h.maxLoadTimeMs=c,h.maxTimeToFirstByteMs=c;break;case"MaxRetry":h.errorRetry.maxNumRetry=c,h.timeoutRetry.maxNumRetry=c;break;case"RetryDelay":h.errorRetry.retryDelayMs=c,h.timeoutRetry.retryDelayMs=c;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=c,h.timeoutRetry.maxRetryDelayMs=c;break}}}),l.length&&I.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),dt(dt({},t),e)}function nc(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(nc):Object.keys(i).reduce((e,t)=>(e[t]=nc(i[t]),e),{}):i}function ok(i){const e=i.loader;e!==pp&&e!==dv?(I.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):zx()&&(i.loader=pp,i.progressive=!0,i.enableSoftwareAES=!0,I.log("[config]: Progressive streaming enabled, using FetchLoader"))}let vu;class lk extends Yh{constructor(e,t){super(e,"[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=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.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(e,t){this.resetLevels()}onManifestLoaded(e,t){const r=this.hls.config.preferManagedMediaSource,s=[],n={},a={};let o=!1,l=!1,d=!1;t.levels.forEach(u=>{var c,h;const f=u.attrs;let{audioCodec:m,videoCodec:p}=u;((c=m)==null?void 0:c.indexOf("mp4a.40.34"))!==-1&&(vu||(vu=/chrome|firefox/i.test(navigator.userAgent)),vu&&(u.audioCodec=m=void 0)),m&&(u.audioCodec=m=zl(m,r)),((h=p)==null?void 0:h.indexOf("avc1"))===0&&(p=u.videoCodec=j1(p));const{width:g,height:E,unknownCodecs:y}=u;if(o||(o=!!(g&&E)),l||(l=!!p),d||(d=!!m),y!=null&&y.length||m&&!iu(m,"audio",r)||p&&!iu(p,"video",r))return;const{CODECS:b,"FRAME-RATE":S,"HDCP-LEVEL":_,"PATHWAY-ID":x,RESOLUTION:A,"VIDEO-RANGE":C}=f,L=`${`${x||"."}-`}${u.bitrate}-${A}-${S}-${b}-${C}-${_}`;if(n[L])if(n[L].uri!==u.url&&!u.attrs["PATHWAY-ID"]){const M=a[L]+=1;u.attrs["PATHWAY-ID"]=new Array(M+1).join(".");const K=new mn(u);n[L]=K,s.push(K)}else n[L].addGroupId("audio",f.AUDIO),n[L].addGroupId("text",f.SUBTITLES);else{const M=new mn(u);n[L]=M,a[L]=1,s.push(M)}}),this.filterAndSortMediaOptions(s,t,o,l,d)}filterAndSortMediaOptions(e,t,r,s,n){let a=[],o=[],l=e;if((r||s)&&n&&(l=l.filter(({videoCodec:m,videoRange:p,width:g,height:E})=>(!!m||!!(g&&E))&&oA(p))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);const m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:m,reason:m.message})}});return}if(t.audioTracks){const{preferManagedMediaSource:m}=this.hls.config;a=t.audioTracks.filter(p=>!p.audioCodec||iu(p.audioCodec,"audio",m)),gp(a)}t.subtitles&&(o=t.subtitles,gp(o));const d=l.slice(0);l.sort((m,p)=>{if(m.attrs["HDCP-LEVEL"]!==p.attrs["HDCP-LEVEL"])return(m.attrs["HDCP-LEVEL"]||"")>(p.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&m.height!==p.height)return m.height-p.height;if(m.frameRate!==p.frameRate)return m.frameRate-p.frameRate;if(m.videoRange!==p.videoRange)return Xl.indexOf(m.videoRange)-Xl.indexOf(p.videoRange);if(m.videoCodec!==p.videoCodec){const g=Am(m.videoCodec),E=Am(p.videoCodec);if(g!==E)return E-g}if(m.uri===p.uri&&m.codecSet!==p.codecSet){const g=jl(m.codecSet),E=jl(p.codecSet);if(g!==E)return E-g}return m.averageBitrate!==p.averageBitrate?m.averageBitrate-p.averageBitrate:0});let u=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let m=0;m<d.length;m++)if(d[m].pathwayId===l[0].pathwayId){u=d[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===u){var c;this._firstLevel=m;const p=u.bitrate,g=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${p}`),((c=this.hls.userConfig)==null?void 0:c.abrEwmaDefaultEstimate)===void 0){const E=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);E>g&&g===uv.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=E)}break}const h=n&&!s,f={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:s,altAudio:!h&&a.some(m=>!!m.url)};this.hls.trigger(v.MANIFEST_PARSED,f),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const u=new Error("invalid level idx"),c=e<0;if(this.hls.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:e,fatal:c,error:u,reason:u.message}),c)return;e=Math.min(e,t.length-1)}const r=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,r===e&&a.details&&s&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${r}${n?" with Pathway "+n:""}`);const l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(v.LEVEL_SWITCHING,l);const d=a.details;if(!d||d.live){const u=this.switchParams(a.uri,s==null?void 0:s.details,d);this.loadPlaylist(u)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===fe.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===ee.MAIN){const r=t.elementaryStreams;if(!Object.keys(r).some(n=>!!r[n]))return;const s=this._levels[t.level];s!=null&&s.loadError&&(this.log(`Resetting level error count of ${s.loadError} on frag buffered`),s.loadError=0)}}onLevelLoaded(e,t){var r;const{level:s,details:n}=t,a=this._levels[s];if(!a){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(s,t,a.details)):(r=t.deliveryDirectives)!=null&&r.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let s=r.uri;if(e)try{s=e.addDirectives(s)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}const n=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${n?" Pathway "+n:""} ${s}`),this.clearTimer(),this.hls.trigger(v.LEVEL_LOADING,{url:s,level:t,pathwayId:r.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;const r=this._levels.filter((s,n)=>n!==e?!0:(this.steering&&this.steering.removeLevel(s),s===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,s.details&&s.details.fragments.forEach(a=>a.level=-1)),!1));kg(r),this._levels=r,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(v.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(v.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function gp(i){const e={};i.forEach(t=>{const r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++})}class dk{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const r in this.keyUriToKeyInfo){const s=this.keyUriToKeyInfo[r].loader;if(s){var t;if(e&&e!==((t=s.context)==null?void 0:t.frag.type))return;s.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=D.KEY_LOAD_ERROR,r,s,n){return new Fi({type:ie.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:r,cc:s}=e;for(let n=0;n<t.length;n++){const a=t[n];if(s<=a.cc&&(r==="initSegment"||a.sn==="initSegment"||r<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,s;t&&e.setKeyFormat(t);const n=e.decryptdata;if(!n){const d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,d))}const a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((r=o)!=null&&r.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((s=o)!=null&&s.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(d=>(n.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){const r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(n=>(e.mediaKeySessionContext=n,r))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(r)}loadKeyHTTP(e,t){const r=this.config,s=r.loader,n=new s(r);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{const l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=r.keyLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{const{frag:g,keyInfo:E,url:y}=m;if(!g.decryptdata||E!==this.keyUriToKeyInfo[y])return o(this.createKeyLoadError(g,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),p));E.decryptdata.key=g.decryptdata.key=new Uint8Array(h.data),g.keyLoader=null,E.loader=null,a({frag:g,keyInfo:E})},onError:(h,f,m,p)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,dt({url:l.url,data:void 0},h)))},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};n.load(l,u,c)})}resetLoader(e){const{frag:t,keyInfo:r,url:s}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}}function cv(){return self.SourceBuffer||self.WebKitSourceBuffer}function hv(){if(!ds())return!1;const e=cv();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function uk(){if(!hv())return!1;const i=ds();return typeof(i==null?void 0:i.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>i.isTypeSupported(Ra(e,"video")))||["mp4a.40.2","fLaC"].some(e=>i.isTypeSupported(Ra(e,"audio"))))}function ck(){var i;const e=cv();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}const hk=250,Po=2,fk=.1,mk=.05;class pk{constructor(e,t,r,s){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:r,media:s,stalled:n}=this;if(s===null)return;const{currentTime:a,seeking:o}=s,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),n!==null){if(this.stallReported){const g=self.performance.now()-n;I.warn(`playback not stuck anymore @${a}, after ${Math.round(g)}ms`),this.stallReported=!1}this.stalled=null}return}if(d||l){this.stalled=null;return}if(s.paused&&!o||s.ended||s.playbackRate===0||!Le.getBuffered(s).length){this.nudgeRetry=0;return}const u=Le.bufferInfo(s,a,0),c=u.nextStart||0;if(o){const g=u.len>Po,E=!c||t&&t.start<=a||c-a>Po&&!this.fragmentTracker.getPartialFragment(a);if(g||E)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var h;if(!(u.len>0)&&!c)return;const E=Math.max(c,u.start||0)-a,y=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,S=(y==null||(h=y.details)==null?void 0:h.live)?y.details.targetduration*2:Po,_=this.fragmentTracker.getPartialFragment(a);if(E>0&&(E<=S||_)){s.paused||this._trySkipBufferHole(_);return}}const f=self.performance.now();if(n===null){this.stalled=f;return}const m=f-n;if(!o&&m>=hk&&(this._reportStall(u),!this.media))return;const p=Le.bufferInfo(s,a,r.maxBufferHole);this._tryFixBufferStall(p,m)}_tryFixBufferStall(e,t){const{config:r,fragmentTracker:s,media:n}=this;if(n===null)return;const a=n.currentTime,o=s.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(I.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:r,stallReported:s}=this;if(!s&&r){this.stallReported=!0;const n=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);I.warn(n.message),t.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:r,media:s}=this;if(s===null)return 0;const n=s.currentTime,a=Le.bufferInfo(s,n,0),o=n<a.start?a.start:a.nextStart;if(o){const l=a.len<=t.maxBufferHole,d=a.len>0&&a.len<1&&s.readyState<3,u=o-n;if(u>0&&(l||d)){if(u>t.maxBufferHole){const{fragmentTracker:h}=this;let f=!1;if(n===0){const m=h.getAppendedFrag(0,ee.MAIN);m&&o<m.end&&(f=!0)}if(!f){const m=e||h.getAppendedFrag(n,ee.MAIN);if(m){let p=!1,g=m.end;for(;g<o;){const E=h.getPartialFragment(g);if(E)g+=E.duration;else{p=!0;break}}if(p)return 0}}}const c=Math.max(o+mk,n+fk);if(I.warn(`skipping hole, adjusting currentTime from ${n} to ${c}`),this.moved=!0,this.stalled=null,s.currentTime=c,e&&!e.gap){const h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${c}`);r.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return c}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:r,nudgeRetry:s}=this;if(r===null)return;const n=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){const a=n+(s+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);I.warn(o.message),r.currentTime=a,t.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{const a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);I.error(a.message),t.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}}const gk=100;class vk extends Xh{constructor(e,t,r){super(e,t,r,"[stream-controller]",ee.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(v.ERROR,this.onError,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(v.ERROR,this.onError,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval(gk),this.level=-1,!this.startFragRequested){let s=r.startLevel;s===-1&&(r.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=r.firstAutoLevel),r.nextLoadLevel=s,this.level=r.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=N.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=N.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case N.WAITING_LEVEL:{const{levels:t,level:r}=this,s=t==null?void 0:t[r],n=s==null?void 0:s.details;if(n&&(!n.live||this.levelLastLoaded===s)){if(this.waitForCdnTuneIn(n))break;this.state=N.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=N.IDLE;break}break}case N.FRAG_LOADING_WAITING_RETRY:{var e;const t=self.performance.now(),r=this.retryDate;if(!r||t>=r||(e=this.media)!=null&&e.seeking){const{levels:s,level:n}=this,a=s==null?void 0:s[n];this.resetStartWhenNotLoaded(a||null),this.state=N.IDLE}}break}this.state===N.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:r,media:s}=this;if(t===null||!s&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const n=e.nextLoadLevel;if(!(r!=null&&r[n]))return;const a=r[n],o=this.getMainFwdBufferInfo();if(o===null)return;const l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){const p={};this.altAudio&&(p.type="video"),this.hls.trigger(v.BUFFER_EOS,p),this.state=N.ENDED;return}e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;const d=a.details;if(!d||this.state===N.WAITING_LEVEL||d.live&&this.levelLastLoaded!==a){this.level=n,this.state=N.WAITING_LEVEL;return}const u=o.len,c=this.getMaxBufferLength(a.maxBitrate);if(u>=c)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const h=this.backtrackFragment?this.backtrackFragment.start:o.end;let f=this.getNextFragment(h,d);if(this.couldBacktrack&&!this.fragPrevious&&f&&f.sn!=="initSegment"&&this.fragmentTracker.getState(f)!==nt.OK){var m;const g=((m=this.backtrackFragment)!=null?m:f).sn-d.startSN,E=d.fragments[g-1];E&&f.cc===E.cc&&(f=E,this.fragmentTracker.removeFragment(E))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){const g=this.audioOnly&&!this.altAudio?ye.AUDIO:ye.VIDEO,E=(g===ye.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,g,ee.MAIN)}f=this.getNextFragmentLoopLoading(f,d,o,ee.MAIN,c)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h))}loadFragment(e,t,r){const s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===nt.NOT_LOADED||s===nt.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,ee.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let r;const s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);const n=this.getLevelDetails();if(n!=null&&n.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?r=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:r=0}else r=0;const a=this.getBufferedFrag(t.currentTime+r);if(a){const o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();const l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,u=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case N.KEY_LOADING:case N.FRAG_LOADING:case N.FRAG_LOADING_WAITING_RETRY:case N.PARSING:case N.PARSED:this.state=N.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new pk(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;Y(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(v.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let r=!1,s=!1;t.levels.forEach(n=>{const a=n.audioCodec;a&&(r=r||a.indexOf("mp4a.40.2")!==-1,s=s||a.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=r&&s&&!ck(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:r}=this;if(!r||this.state!==N.IDLE)return;const s=r[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(s.details))&&(this.state=N.WAITING_LEVEL)}onLevelLoaded(e,t){var r;const{levels:s}=this,n=t.level,a=t.details,o=a.totalduration;if(!s){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const l=s[n],d=this.fragCurrent;d&&(this.state===N.FRAG_LOADING||this.state===N.FRAG_LOADING_WAITING_RETRY)&&d.level!==t.level&&d.loader&&this.abortCurrentFrag();let u=0;if(a.live||(r=l.details)!=null&&r.live){var c;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,l.details,(c=this.levelLastLoaded)==null?void 0:c.details)}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(v.LEVEL_UPDATED,{details:a,level:n}),this.state===N.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=N.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:r,part:s,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}const o=a[r.level],l=o.details;if(!l){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}const d=o.videoCodec,u=l.PTSKnown||!l.live,c=(t=r.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new qg(this.hls,ee.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=s?s.index:-1,p=m!==-1,g=new jh(r.level,r.sn,r.stats.chunkCount,n.byteLength,m,p),E=this.initPTS[r.cc];f.push(n,c,h,d,r,s,l.totalduration,u,g,E)}onAudioTrackSwitching(e,t){const r=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const n=this.hls;r&&(n.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(v.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const r=t.id,s=!!this.hls.audioTracks[r].url;if(s){const n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=s,this.tick()}onBufferCreated(e,t){const r=t.tracks;let s,n,a=!1;for(const o in r){const l=r[o];if(l.id==="main"){if(n=o,s=l,o==="video"){const d=r[o];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:r,part:s}=t;if(r&&r.type!==ee.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===N.PARSED&&(this.state=N.IDLE);return}const n=s?s.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),r.sn!=="initSegment"&&(this.fragPrevious=r),this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=N.ERROR;return}switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ee.MAIN,t);break;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_LEVEL&&((r=t.context)==null?void 0:r.type)===fe.LEVEL&&(this.state=N.IDLE);break;case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===D.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!Le.getBuffered(e).length){const r=this.state!==N.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=N.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==ye.AUDIO||this.audioOnly&&!this.altAudio){const r=(t===ye.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,t,ee.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let r=this.startPosition;if(r>=0&&t<r){if(e.seeking){this.log(`could not seek to ${r}, already seeking at ${t}`);return}const s=Le.getBuffered(e),a=(s.length?s.start(0):0)-r;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),r+=a,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(r=>{const{hls:s}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=N.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),s.trigger(v.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const r="main",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:d,level:u}=o,{video:c,text:h,id3:f,initSegment:m}=n,{details:p}=u,g=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,m){if(m!=null&&m.tracks){const b=l.initSegment||l;this._bufferInitSegment(u,m.tracks,b,a),s.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:r,tracks:m.tracks})}const E=m.initPTS,y=m.timescale;Y(E)&&(this.initPTS[l.cc]={baseTime:E,timescale:y},s.trigger(v.INIT_PTS_FOUND,{frag:l,id:r,initPTS:E,timescale:y}))}if(c&&p&&l.sn!=="initSegment"){const E=p.fragments[l.sn-1-p.startSN],y=l.sn===p.startSN,b=!E||l.cc>E.cc;if(n.independent!==!1){const{startPTS:S,endPTS:_,startDTS:x,endDTS:A}=c;if(d)d.elementaryStreams[c.type]={startPTS:S,endPTS:_,startDTS:x,endDTS:A};else if(c.firstKeyFrame&&c.independent&&a.id===1&&!b&&(this.couldBacktrack=!0),c.dropped&&c.independent){const C=this.getMainFwdBufferInfo(),O=(C?C.end:this.getLoadPosition())+this.config.maxBufferHole,L=c.firstKeyFramePTS?c.firstKeyFramePTS:S;if(!y&&O<L-this.config.maxBufferHole&&!b){this.backtrack(l);return}else b&&(l.gap=!0);l.setElementaryStreamInfo(c.type,l.start,_,l.start,A,!0)}else y&&S>Po&&(l.gap=!0);l.setElementaryStreamInfo(c.type,S,_,x,A),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(c,l,d,a,y||b)}else if(y||b)l.gap=!0;else{this.backtrack(l);return}}if(g){const{startPTS:E,endPTS:y,startDTS:b,endDTS:S}=g;d&&(d.elementaryStreams[ye.AUDIO]={startPTS:E,endPTS:y,startDTS:b,endDTS:S}),l.setElementaryStreamInfo(ye.AUDIO,E,y,b,S),this.bufferFragmentData(g,l,d,a)}if(p&&f!=null&&(t=f.samples)!=null&&t.length){const E={id:r,frag:l,details:p,samples:f.samples};s.trigger(v.FRAG_PARSING_METADATA,E)}if(p&&h){const E={id:r,frag:l,details:p,samples:h.samples};s.trigger(v.FRAG_PARSING_USERDATA,E)}}_bufferInitSegment(e,t,r,s){if(this.state!==N.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec;const d=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5");const u=n.metadata;u&&"channelCount"in u&&(u.channelCount||1)!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")}l&&l.indexOf("mp4a.40.5")!==-1&&d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(v.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{const u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(v.BUFFER_APPENDING,{type:l,data:u,frag:r,part:null,chunkMeta:s,parent:r.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,ee.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=N.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const r=e.currentTime;if(Le.isBuffered(e,r)?t=this.getAppendedFrag(r):Le.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;const s=this.fragPlaying,n=t.level;(!s||t.sn!==s.sn||s.level!==n)&&(this.fragPlaying=t,this.hls.trigger(v.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(v.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,r=this.currentFrag;if(r&&Y(t)&&Y(r.programDateTime)){const s=r.programDateTime+(t-r.start)*1e3;return new Date(s)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class Xr{static get version(){return"1.5.15"}static isMSESupported(){return hv()}static isSupported(){return uk()}static getMediaSource(){return ds()}static get Events(){return v}static get ErrorTypes(){return ie}static get ErrorDetails(){return D}static get DefaultConfig(){return Xr.defaultConfig?Xr.defaultConfig:uv}static set DefaultConfig(e){Xr.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new tf,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.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,n1(e.debug||!1,"Hls instance");const t=this.config=ak(Xr.DefaultConfig,e);this.userConfig=e,t.progressive&&ok(t);const{abrController:r,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new r(this),u=this.bufferController=new s(this),c=this.capLevelController=new n(this),h=new o(this),f=new J1(this),m=new sA(this),p=t.contentSteeringController,g=p?new p(this):null,E=this.levelController=new lk(this,g),y=new MA(this),b=new dk(this.config),S=this.streamController=new vk(this,y,b);c.setStreamController(S),h.setStreamController(S);const _=[f,E,S];g&&_.splice(1,0,g),this.networkControllers=_;const x=[d,u,c,h,m,y];this.audioTrackController=this.createController(t.audioTrackController,_);const A=t.audioStreamController;A&&_.push(new A(this,y,b)),this.subtitleTrackController=this.createController(t.subtitleTrackController,_);const C=t.subtitleStreamController;C&&_.push(new C(this,y,b)),this.createController(t.timelineController,x),b.emeController=this.emeController=this.createController(t.emeController,x),this.cmcdController=this.createController(t.cmcdController,x),this.latencyController=this.createController(nA,x),this.coreComponents=x,_.push(l);const O=l.onErrorOut;typeof O=="function"&&this.on(v.ERROR,O,l)}createController(e,t){if(e){const r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,s){this._emitter.off(e,t,r,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){if(I.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),!this.triggeringException){this.triggeringException=!0;const s=e===v.ERROR;this.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:s,event:e,error:r}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){I.log("destroy"),this.trigger(v.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 e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){I.log("attachMedia"),this._media=e,this.trigger(v.MEDIA_ATTACHING,{media:e})}detachMedia(){I.log("detachMedia"),this.trigger(v.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,r=this.url,s=this.url=Hh.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,I.log(`loadSource:${s}`),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(v.MANIFEST_LOADING,{url:e})}startLoad(e=-1){I.log(`startLoad(${e})`),this.started=!0,this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){I.log("stopLoad"),this.started=!1,this.networkControllers.forEach(e=>{e.stopLoad()})}resumeBuffering(){this.started&&this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.startLoad(-1)})}pauseBuffering(){this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.stopLoad()})}swapAudioCodec(){I.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){I.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){I.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){I.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){I.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){I.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){I.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(I.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){aA(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const r=e.length;for(let s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this;let s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,r)for(let n=s;n--;){const a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=r)return n}return s}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}Xr.defaultConfig=void 0;var Oe=Xr,Qi=class Wn extends Error{constructor(e,t=Wn.MEDIA_ERR_CUSTOM,r,s){var n;super(e),this.name="MediaError",this.code=t,this.context=s,this.fatal=r??(t>=Wn.MEDIA_ERR_NETWORK&&t<=Wn.MEDIA_ERR_ENCRYPTED),this.message||(this.message=(n=Wn.defaultMessages[this.code])!=null?n:"")}};Qi.MEDIA_ERR_ABORTED=1,Qi.MEDIA_ERR_NETWORK=2,Qi.MEDIA_ERR_DECODE=3,Qi.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Qi.MEDIA_ERR_ENCRYPTED=5,Qi.MEDIA_ERR_CUSTOM=100,Qi.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var St=Qi,Ek=i=>i==null,fv=(i,e)=>Ek(e)?!1:i in e,ac={ANY:"any",MUTED:"muted"},be={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},Ti={MSE:"mse",NATIVE:"native"},Oo={HEADER:"header",QUERY:"query",NONE:"none"},rd=Object.values(Oo),vr={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},vp={HLS:vr.M3U8};[...Object.values(vr)];var qe=(i,e,t,r,s=i)=>{s.addEventListener(e,t,r),i.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function yk(i,e,t){e&&t>e&&(t=e);for(let r=0;r<i.length;r++)if(i.start(r)<=t&&i.end(r)>=t)return!0;return!1}var bk=i=>{let e=i.indexOf("?");if(e<0)return[i];let t=i.slice(0,e),r=i.slice(e);return[t,r]},wd=i=>{let e=i.type;if(e){let r=e.toUpperCase();return fv(r,vp)?vp[r]:e}let{src:t}=i;return t?Tk(t):""},mv=i=>i==="VOD"?be.ON_DEMAND:be.LIVE,pv=i=>i==="EVENT"?Number.POSITIVE_INFINITY:i==="VOD"?Number.NaN:0,Tk=i=>{let e="";try{e=new URL(i).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let r=e.slice(t+1).toUpperCase();return fv(r,vr)?vr[r]:""},_k=Object.values(ac),Ep=i=>typeof i=="boolean"||typeof i=="string"&&_k.includes(i),Ak=(i,e,t)=>{let{autoplay:r}=i,s=!1,n=!1,a=Ep(r)?r:!!r,o=()=>{s||qe(e,"playing",()=>{s=!0},{once:!0})};if(o(),qe(e,"loadstart",()=>{s=!1,o(),Eu(e,a)},{once:!0}),qe(e,"loadstart",()=>{t||(i.streamType&&i.streamType!==be.UNKNOWN?n=i.streamType===be.LIVE:n=!Number.isFinite(e.duration)),Eu(e,a)},{once:!0}),t&&t.once(Oe.Events.LEVEL_LOADED,(l,d)=>{var u;i.streamType&&i.streamType!==be.UNKNOWN?n=i.streamType===be.LIVE:n=(u=d.details.live)!=null?u:!1}),!a){let l=()=>{!n||Number.isFinite(i.startTime)||(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&qe(e,"play",()=>{e.preload==="metadata"?t.once(Oe.Events.LEVEL_UPDATED,l):l()},{once:!0})}return l=>{s||(a=Ep(l)?l:!!l,Eu(e,a))}},Eu=(i,e)=>{if(!e)return;let t=i.muted,r=()=>i.muted=t;switch(e){case ac.ANY:i.play().catch(()=>{i.muted=!0,i.play().catch(r)});break;case ac.MUTED:i.muted=!0,i.play().catch(r);break;default:i.play().catch(()=>{});break}},Sk=({preload:i,src:e},t,r)=>{let s=c=>{c!=null&&["","none","metadata","auto"].includes(c)?t.setAttribute("preload",c):t.removeAttribute("preload")};if(!r)return s(i),s;let n=!1,a=!1,o=r.config.maxBufferLength,l=r.config.maxBufferSize,d=c=>{s(c);let h=c??t.preload;a||h==="none"||(h==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=o,r.config.maxBufferSize=l),u())},u=()=>{!n&&e&&(n=!0,r.loadSource(e))};return qe(t,"play",()=>{a=!0,r.config.maxBufferLength=o,r.config.maxBufferSize=l,u()},{once:!0}),d(i),d};function xk(i,e){var t;if(!("videoTracks"in i))return;let r=new WeakMap;e.on(Oe.Events.MANIFEST_PARSED,function(d,u){l();let c=i.addVideoTrack("main");c.selected=!0;for(let[h,f]of u.levels.entries()){let m=c.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);r.set(f,`${h}`),m.id=`${h}`}}),e.on(Oe.Events.AUDIO_TRACKS_UPDATED,function(d,u){o();for(let c of u.audioTracks){let h=c.default?"main":"alternative",f=i.addAudioTrack(h,c.name,c.lang);f.id=`${c.id}`,c.default&&(f.enabled=!0)}}),i.audioTracks.addEventListener("change",()=>{var d;let u=+((d=[...i.audioTracks].find(h=>h.enabled))==null?void 0:d.id),c=e.audioTracks.map(h=>h.id);u!=e.audioTrack&&c.includes(u)&&(e.audioTrack=u)}),e.on(Oe.Events.LEVELS_UPDATED,function(d,u){var c;let h=i.videoTracks[(c=i.videoTracks.selectedIndex)!=null?c:0];if(!h)return;let f=u.levels.map(m=>r.get(m));for(let m of i.videoRenditions)m.id&&!f.includes(m.id)&&h.removeRendition(m)});let s=d=>{let u=d.target.selectedIndex;u!=e.nextLevel&&n(u)},n=d=>{let u=i.currentTime,c=!1,h=(f,m)=>{c||(c=!Number.isFinite(m.endOffset))};e.on(Oe.Events.BUFFER_FLUSHING,h),e.nextLevel=d,e.off(Oe.Events.BUFFER_FLUSHING,h),c||e.trigger(Oe.Events.BUFFER_FLUSHING,{startOffset:u+10,endOffset:1/0,type:"video"})};(t=i.videoRenditions)==null||t.addEventListener("change",s);let a=()=>{for(let d of i.videoTracks)i.removeVideoTrack(d)},o=()=>{for(let d of i.audioTracks)i.removeAudioTrack(d)},l=()=>{a(),o()};e.once(Oe.Events.DESTROYING,l)}var yu=i=>"time"in i?i.time:i.startTime;function kk(i,e){e.on(Oe.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(s,{tracks:n})=>{n.forEach(a=>{var o;let l=(o=a.subtitleTrack)!=null?o:a.closedCaptions,d=e.subtitleTracks.findIndex(({lang:u,name:c,type:h})=>u==(l==null?void 0:l.lang)&&c===a.label&&h.toLowerCase()===a.kind);of(i,a.kind,a.label,l==null?void 0:l.lang,`${a.kind}${d}`)})});let t=()=>{var s;if(!e.subtitleTracks.length)return;let n=Array.from(i.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind)),a=`${(s=e.subtitleTracks[e.subtitleTrack])==null?void 0:s.type.toLowerCase()}${e.subtitleTrack}`;if(n&&(e.subtitleTrack<0||(n==null?void 0:n.id)!==a)){let o=e.subtitleTracks.findIndex(({lang:l,name:d,type:u})=>l==n.language&&d===n.label&&u.toLowerCase()===n.kind);e.subtitleTrack=o}n&&(n==null?void 0:n.id)===a&&n.cues&&Array.from(n.cues).forEach(o=>{n.addCue(o)})};i.textTracks.addEventListener("change",t),e.on(Oe.Events.CUES_PARSED,(s,{track:n,cues:a})=>{let o=i.textTracks.getTrackById(n);if(!o)return;let l=o.mode==="disabled";l&&(o.mode="hidden"),a.forEach(d=>{var u;(u=o.cues)!=null&&u.getCueById(d.id)||o.addCue(d)}),l&&(o.mode="disabled")}),e.once(Oe.Events.DESTROYING,()=>{i.textTracks.removeEventListener("change",t),i.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let r=()=>{Array.from(i.textTracks).forEach(s=>{var n,a;if(!["subtitles","caption"].includes(s.kind)&&s.label==="thumbnails"){if(!((n=s.cues)!=null&&n.length)){let o=i.querySelector('track[label="thumbnails"]'),l=(a=o==null?void 0:o.getAttribute("src"))!=null?a:"";o==null||o.removeAttribute("src"),setTimeout(()=>{o==null||o.setAttribute("src",l)},0)}s.mode!=="hidden"&&(s.mode="hidden")}})};e.once(Oe.Events.MANIFEST_LOADED,r),e.once(Oe.Events.MEDIA_ATTACHED,r)}function of(i,e,t,r,s){let n=document.createElement("track");return n.kind=e,n.label=t,r&&(n.srclang=r),s&&(n.id=s),n.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",n.setAttribute("data-removeondestroy",""),i.append(n),n.track}function Lk(i,e){let t=Array.prototype.find.call(i.querySelectorAll("track"),r=>r.track===e);t==null||t.remove()}function qa(i,e,t){var r;return(r=Array.from(i.querySelectorAll("track")).find(s=>s.track.label===e&&s.track.kind===t))==null?void 0:r.track}async function gv(i,e,t,r){let s=qa(i,t,r);return s||(s=of(i,r,t),s.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))),s.mode!=="hidden"&&(s.mode="hidden"),[...e].sort((n,a)=>yu(a)-yu(n)).forEach(n=>{var a,o;let l=n.value,d=yu(n);if("endTime"in n&&n.endTime!=null)s==null||s.addCue(new VTTCue(d,n.endTime,r==="chapters"?l:JSON.stringify(l??null)));else{let u=Array.prototype.findIndex.call(s==null?void 0:s.cues,m=>m.startTime>=d),c=(a=s==null?void 0:s.cues)==null?void 0:a[u],h=c?c.startTime:Number.isFinite(i.duration)?i.duration:Number.MAX_SAFE_INTEGER,f=(o=s==null?void 0:s.cues)==null?void 0:o[u-1];f&&(f.endTime=d),s==null||s.addCue(new VTTCue(d,h,r==="chapters"?l:JSON.stringify(l??null)))}}),i.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),s}var lf="cuepoints",vv=Object.freeze({label:lf});async function Ev(i,e,t=vv){return gv(i,e,t.label,"metadata")}var oc=i=>({time:i.startTime,value:JSON.parse(i.text)});function Ik(i,e={label:lf}){let t=qa(i,e.label,"metadata");return t!=null&&t.cues?Array.from(t.cues,r=>oc(r)):[]}function yv(i,e={label:lf}){var t,r;let s=qa(i,e.label,"metadata");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return oc(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return oc(a||s.activeCues[0])}async function Rk(i,e=vv){return new Promise(t=>{qe(i,"loadstart",async()=>{let r=await Ev(i,[],e);qe(i,"cuechange",()=>{let s=yv(i);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}var df="chapters",bv=Object.freeze({label:df}),lc=i=>({startTime:i.startTime,endTime:i.endTime,value:i.text});async function Tv(i,e,t=bv){return gv(i,e,t.label,"chapters")}function wk(i,e={label:df}){var t;let r=qa(i,e.label,"chapters");return(t=r==null?void 0:r.cues)!=null&&t.length?Array.from(r.cues,s=>lc(s)):[]}function _v(i,e={label:df}){var t,r;let s=qa(i,e.label,"chapters");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return lc(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return lc(a||s.activeCues[0])}async function Ck(i,e=bv){return new Promise(t=>{qe(i,"loadstart",async()=>{let r=await Tv(i,[],e);qe(i,"cuechange",()=>{let s=_v(i);if(s){let n=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}function Dk(i,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-i.currentTime*1e3)}return typeof i.getStartDate=="function"?i.getStartDate():new Date(NaN)}function Mk(i,e){if(e&&e.playingDate)return e.playingDate;if(typeof i.getStartDate=="function"){let t=i.getStartDate();return new Date(t.getTime()+i.currentTime*1e3)}return new Date(NaN)}var No={FAIRPLAY:"fairplay",PLAYREADY:"playready",WIDEVINE:"widevine"},Pk=i=>{if(i.includes("fps"))return No.FAIRPLAY;if(i.includes("playready"))return No.PLAYREADY;if(i.includes("widevine"))return No.WIDEVINE},Ok=async i=>fetch(i).then(e=>e.text()).then(e=>{let t=e.split(`
44
+ `),d=[],u=e?bS(e.baseTime,e.timescale):0;let c="00:00.000",h=0,f=0,m,p=!0;o.oncue=function(g){const E=t[r];let y=t.ccOffset;const b=(h-u)/9e4;if(E!=null&&E.new&&(f!==void 0?y=t.ccOffset=E.start:ix(t,r,b)),b){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}y=b-t.presentationOffset}const S=g.endTime-g.startTime,_=Nt((g.startTime+y-f)*9e4,s*9e4)/9e4;g.startTime=Math.max(_,0),g.endTime=Math.max(_+S,0);const x=g.text.trim();g.text=decodeURIComponent(encodeURIComponent(x)),g.id||(g.id=af(g.startTime,g.endTime,x)),g.endTime>0&&d.push(g)},o.onparsingerror=function(g){m=g},o.onflush=function(){if(m){a(m);return}n(d)},l.forEach(g=>{if(p)if(fu(g,"X-TIMESTAMP-MAP=")){p=!1,g.slice(16).split(",").forEach(E=>{fu(E,"LOCAL:")?c=E.slice(6):fu(E,"MPEGTS:")&&(h=parseInt(E.slice(7)))});try{f=tx(c)/1e3}catch(E){m=E}return}else g===""&&(p=!1);o.parse(g+`
45
+ `)}),o.flush()}const pu="stpp.ttml.im1t",tv=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,iv=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,sx={left:"start",center:"center",right:"end",start:"start",end:"end"};function lp(i,e,t,r){const s=le(new Uint8Array(i),["mdat"]);if(s.length===0){r(new Error("Could not parse IMSC1 mdat"));return}const n=s.map(o=>Si(o)),a=yS(e.baseTime,1,e.timescale);try{n.forEach(o=>t(nx(o,a)))}catch(o){r(o)}}function nx(i,e){const s=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!s)throw new Error("Invalid ttml");const n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((c,h)=>(c[h]=s.getAttribute(`ttp:${h}`)||n[h],c),{}),o=s.getAttribute("xml:space")!=="preserve",l=dp(gu(s,"styling","style")),d=dp(gu(s,"layout","region")),u=gu(s,"body","[begin]");return[].map.call(u,c=>{const h=rv(c,o);if(!h||!c.hasAttribute("begin"))return null;const f=Eu(c.getAttribute("begin"),a),m=Eu(c.getAttribute("dur"),a);let p=Eu(c.getAttribute("end"),a);if(f===null)throw up(c);if(p===null){if(m===null)throw up(c);p=f+m}const g=new nf(f-e,p-e,h);g.id=af(g.startTime,g.endTime,g.text);const E=d[c.getAttribute("region")],y=l[c.getAttribute("style")],b=ax(E,y,l),{textAlign:S}=b;if(S){const _=sx[S];_&&(g.lineAlign=_),g.align=S}return We(g,b),g}).filter(c=>c!==null)}function gu(i,e,t){const r=i.getElementsByTagName(e)[0];return r?[].slice.call(r.querySelectorAll(t)):[]}function dp(i){return i.reduce((e,t)=>{const r=t.getAttribute("xml:id");return r&&(e[r]=t),e},{})}function rv(i,e){return[].slice.call(i.childNodes).reduce((t,r,s)=>{var n;return r.nodeName==="br"&&s?t+`
46
+ `:(n=r.childNodes)!=null&&n.length?rv(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent},"")}function ax(i,e,t){const r="http://www.w3.org/ns/ttml#styling";let s=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(s=t[a]),n.reduce((o,l)=>{const d=vu(e,r,l)||vu(i,r,l)||vu(s,r,l);return d&&(o[l]=d),o},{})}function vu(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function up(i){return new Error(`Could not parse ttml timestamp ${i}`)}function Eu(i,e){if(!i)return null;let t=Zg(i);return t===null&&(tv.test(i)?t=ox(i,e):iv.test(i)&&(t=lx(i,e))),t}function ox(i,e){const t=tv.exec(i),r=(t[4]|0)+(t[5]|0)/e.subFrameRate;return(t[1]|0)*3600+(t[2]|0)*60+(t[3]|0)+r/e.frameRate}function lx(i,e){const t=iv.exec(i),r=Number(t[1]);switch(t[2]){case"h":return r*3600;case"m":return r*60;case"ms":return r*1e3;case"f":return r/e.frameRate;case"t":return r/e.tickRate}return r}class dx{constructor(e){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=hp(),this.captionsProperties=void 0,this.hls=e,this.config=e.config,this.Cues=e.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}},e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(v.FRAG_LOADING,this.onFragLoading,this),e.on(v.FRAG_LOADED,this.onFragLoaded,this),e.on(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(v.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(v.FRAG_LOADING,this.onFragLoading,this),e.off(v.FRAG_LOADED,this.onFragLoaded,this),e.off(v.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(v.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(v.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(v.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(v.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){const e=new so(this,"textTrack1"),t=new so(this,"textTrack2"),r=new so(this,"textTrack3"),s=new so(this,"textTrack4");this.cea608Parser1=new op(1,e,t),this.cea608Parser2=new op(3,r,s)}}addCues(e,t,r,s,n){let a=!1;for(let o=n.length;o--;){const l=n[o],d=ux(l[0],l[1],t,r);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],r),a=!0,d/(r-t)>.5))return}if(a||n.push([t,r]),this.config.renderTextTracksNatively){const o=this.captionsTracks[e];this.Cues.newCue(o,t,r,s)}else{const o=this.Cues.newCue(null,t,r,s);this.hls.trigger(v.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:r,initPTS:s,timescale:n}){const{unparsedVttFrags:a}=this;r==="main"&&(this.initPTS[t.cc]={baseTime:s,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(v.FRAG_LOADED,o)}))}getExistingTrack(e,t){const{media:r}=this;if(r)for(let s=0;s<r.textTracks.length;s++){const n=r.textTracks[s];if(cp(n,{name:e,lang:t,attrs:{}}))return n}return null}createCaptionsTrack(e){this.config.renderTextTracksNatively?this.createNativeTrack(e):this.createNonNativeTrack(e)}createNativeTrack(e){if(this.captionsTracks[e])return;const{captionsProperties:t,captionsTracks:r,media:s}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)r[e]=o,Xs(r[e]),Ag(r[e],s);else{const l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,r[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const r=t.label,s={_id:e,label:r,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=s,this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[s]})}createTextTrack(e,t,r){const s=this.media;if(s)return s.addTextTrack(e,t,r)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach(t=>{Xs(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=hp(),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:e}=this;if(!e)return;const t=e.textTracks;if(t)for(let r=0;r<t.length;r++)Xs(t[r])}onSubtitleTracksUpdated(e,t){const r=t.subtitleTracks||[],s=r.some(n=>n.textCodec===pu);if(this.config.enableWebVTT||s&&this.config.enableIMSC1){if(zg(this.tracks,r)){this.tracks=r;return}if(this.textTracks=[],this.tracks=r,this.config.renderTextTracksNatively){const a=this.media,o=a?Ro(a.textTracks):null;if(this.tracks.forEach((l,d)=>{let u;if(o){let c=null;for(let h=0;h<o.length;h++)if(o[h]&&cp(o[h],l)){c=o[h],o[h]=null;break}c&&(u=c)}if(u)Xs(u);else{const c=sv(l);u=this.createTextTrack(c,l.name,l.lang),u&&(u.mode="disabled")}u&&this.textTracks.push(u)}),o!=null&&o.length){const l=o.filter(d=>d!==null).map(d=>d.label);l.length&&I.warn(`Media element contains unused subtitle tracks: ${l.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(v.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(r=>{const s=/(?:CC|SERVICE)([1-4])/.exec(r.instreamId);if(!s)return;const n=`textTrack${s[1]}`,a=this.captionsProperties[n];a&&(a.label=r.name,r.lang&&(a.languageCode=r.lang),a.media=r)})}closedCaptionsForLevel(e){const t=this.hls.levels[e.level];return t==null?void 0:t.attrs["CLOSED-CAPTIONS"]}onFragLoading(e,t){if(this.enabled&&t.frag.type===ee.MAIN){var r,s;const{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:l,sn:d}=t.frag,u=(r=(s=t.part)==null?void 0:s.index)!=null?r:-1;n&&a&&(d!==o+1||d===o&&u!==this.lastPartIndex+1||l!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=l,this.lastSn=d,this.lastPartIndex=u}}onFragLoaded(e,t){const{frag:r,payload:s}=t;if(r.type===ee.SUBTITLE)if(s.byteLength){const n=r.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){const o=this.tracks[r.level],l=this.vttCCs;l[r.cc]||(l[r.cc]={start:r.start,prevCC:this.prevCC,new:!0},this.prevCC=r.cc),o&&o.textCodec===pu?this._parseIMSC1(r,s):this._parseVTTs(t)}}else this.hls.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const r=this.hls;lp(t,this.initPTS[e.cc],s=>{this._appendCues(s,e.level),r.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},s=>{I.log(`Failed to parse IMSC1: ${s}`),r.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:s})})}_parseVTTs(e){var t;const{frag:r,payload:s}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[r.cc]&&o===-1){a.push(e);return}const l=this.hls,d=(t=r.initSegment)!=null&&t.data?Ut(r.initSegment.data,new Uint8Array(s)):s;rx(d,this.initPTS[r.cc],this.vttCCs,r.cc,r.start,u=>{this._appendCues(u,r.level),l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:r})},u=>{const c=u.message==="Missing initPTS for VTT MPEGTS";c?a.push(e):this._fallbackToIMSC1(r,s),I.log(`Failed to parse VTT cue: ${u}`),!(c&&o>r.cc)&&l.trigger(v.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:r,error:u})})}_fallbackToIMSC1(e,t){const r=this.tracks[e.level];r.textCodec||lp(t,this.initPTS[e.cc],()=>{r.textCodec=pu,this._parseIMSC1(e,t)},()=>{r.textCodec="wvtt"})}_appendCues(e,t){const r=this.hls;if(this.config.renderTextTracksNatively){const s=this.textTracks[t];if(!s||s.mode==="disabled")return;e.forEach(n=>Sg(s,n))}else{const s=this.tracks[t];if(!s)return;const n=s.default?"default":"subtitles"+t;r.trigger(v.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:r}=t;r.type===ee.SUBTITLE&&this.onFragLoaded(v.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();const{cea608Parser1:r,cea608Parser2:s}=this;if(!this.enabled||!r||!s)return;const{frag:n,samples:a}=t;if(!(n.type===ee.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){const l=a[o].bytes;if(l){const d=this.extractCea608Data(l);r.addData(a[o].pts,d[0]),s.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:r,endOffsetSubtitles:s,type:n}){const{media:a}=this;if(!(!a||a.currentTime<r)){if(!n||n==="video"){const{captionsTracks:o}=this;Object.keys(o).forEach(l=>Xu(o[l],t,r))}if(this.config.renderTextTracksNatively&&t===0&&s!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(l=>Xu(o[l],t,s))}}}extractCea608Data(e){const t=[[],[]],r=e[0]&31;let s=2;for(let n=0;n<r;n++){const a=e[s++],o=127&e[s++],l=127&e[s++];if(o===0&&l===0)continue;if((4&a)!==0){const u=3&a;(u===0||u===1)&&(t[u].push(o),t[u].push(l))}}return t}}function sv(i){return i.characteristics&&/transcribes-spoken-dialog/gi.test(i.characteristics)&&/describes-music-and-sound/gi.test(i.characteristics)?"captions":"subtitles"}function cp(i,e){return!!i&&i.kind===sv(e)&&ic(e,i)}function ux(i,e,t,r){return Math.min(e,r)-Math.max(i,t)}function hp(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class of{constructor(e){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=e,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}setStreamController(e){this.streamController=e}destroy(){this.hls&&this.unregisterListener(),this.timer&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null}registerListeners(){const{hls:e}=this;e.on(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.BUFFER_CODECS,this.onBufferCodecs,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(v.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.BUFFER_CODECS,this.onBufferCodecs,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this)}onFpsDropLevelCapping(e,t){const r=this.hls.levels[t.droppedLevel];this.isLevelAllowed(r)&&this.restrictedLevels.push({bitrate:r.bitrate,height:r.height,width:r.width})}onMediaAttaching(e,t){this.media=t.media instanceof HTMLVideoElement?t.media:null,this.clientRect=null,this.timer&&this.hls.levels.length&&this.detectPlayerSize()}onManifestParsed(e,t){const r=this.hls;this.restrictedLevels=[],this.firstLevel=t.firstLevel,r.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onLevelsUpdated(e,t){this.timer&&Y(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}detectPlayerSize(){if(this.media){if(this.mediaHeight<=0||this.mediaWidth<=0){this.clientRect=null;return}const e=this.hls.levels;if(e.length){const t=this.hls,r=this.getMaxLevel(e.length-1);r!==this.autoLevelCapping&&I.log(`Setting autoLevelCapping to ${r}: ${e[r].height}p@${e[r].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=r,t.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=t.autoLevelCapping}}}getMaxLevel(e){const t=this.hls.levels;if(!t.length)return-1;const r=t.filter((s,n)=>this.isLevelAllowed(s)&&n<=e);return this.clientRect=null,of.getMaxLevelByMediaSize(r,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 e=this.media,t={width:0,height:0};if(e){const r=e.getBoundingClientRect();t.width=r.width,t.height=r.height,!t.width&&!t.height&&(t.width=r.right-r.left||e.width||0,t.height=r.bottom-r.top||e.height||0)}return this.clientRect=t,t}get mediaWidth(){return this.getDimensions().width*this.contentScaleFactor}get mediaHeight(){return this.getDimensions().height*this.contentScaleFactor}get contentScaleFactor(){let e=1;if(!this.hls.config.ignoreDevicePixelRatio)try{e=self.devicePixelRatio}catch{}return e}isLevelAllowed(e){return!this.restrictedLevels.some(r=>e.bitrate===r.bitrate&&e.width===r.width&&e.height===r.height)}static getMaxLevelByMediaSize(e,t,r){if(!(e!=null&&e.length))return-1;const s=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0;let n=e.length-1;const a=Math.max(t,r);for(let o=0;o<e.length;o+=1){const l=e[o];if((l.width>=a||l.height>=a)&&s(l,e[o+1])){n=o;break}}return n}}class cx{constructor(e){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=e,this.registerListeners()}setStreamController(e){this.streamController=e}registerListeners(){this.hls.on(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHING,this.onMediaAttaching,this)}destroy(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null}onMediaAttaching(e,t){const r=this.hls.config;if(r.capLevelOnFPSDrop){const s=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=s,s&&typeof s.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,r){const s=performance.now();if(t){if(this.lastTime){const n=s-this.lastTime,a=r-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(v.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:r}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let u=d.currentLevel;I.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=u)&&(u=u-1,d.trigger(v.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:d.currentLevel}),d.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=r,this.lastDecodedFrames=t}}checkFPSInterval(){const e=this.media;if(e)if(this.isVideoPlaybackQualityAvailable){const t=e.getVideoPlaybackQuality();this.checkFPS(e,t.totalVideoFrames,t.droppedVideoFrames)}else this.checkFPS(e,e.webkitDecodedFrameCount,e.webkitDroppedFrameCount)}}const ao="[eme]";class rn{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=rn.CDMCleanupPromise?[rn.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=I.debug.bind(I,ao),this.log=I.log.bind(I,ao),this.warn=I.warn.bind(I,ao),this.error=I.error.bind(I,ao),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(v.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(v.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(v.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(v.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:r}=this.config,s=t[e];if(s)return s.licenseUrl;if(e===Ie.WIDEVINE&&r)return r;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){const{drmSystems:t}=this.config,r=t[e];if(r)return r.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,r=(a,o,l)=>!!a&&l.indexOf(a)===o,s=t.map(a=>a.audioCodec).filter(r),n=t.map(a=>a.videoCodec).filter(r);return s.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{const l=d=>{const u=d.shift();this.getMediaKeysPromise(u,s,n).then(c=>a({keySystem:u,mediaKeys:c})).catch(c=>{d.length?l(d):c instanceof Dt?o(c):o(new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_ACCESS,error:c,fatal:!0},c.message))})};l(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:r}=this.config;if(typeof r!="function"){let s=`Configured requestMediaKeySystemAccess is not a function ${r}`;return ug===null&&self.location.protocol==="http:"&&(s=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(s))}return r(e,t)}getMediaKeysPromise(e,t,r){const s=v1(e,t,r,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e];let a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(s)}`),a=this.requestMediaKeySystemAccess(e,s);const o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);const d=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(u=>(this.log(`Media-keys created for "${e}"`),d.then(c=>c?this.setMediaKeysServerCertificate(u,e,c):u))),o.mediaKeys.catch(u=>{this.error(`Failed to create media-keys for "${e}"}: ${u}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:r}){this.log(`Creating key-system session "${t}" keyId: ${mi.hexDump(e.keyId||[])}`);const s=r.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:r,mediaKeysSession:s,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const r=this.createMediaKeySessionContext(e),s=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[s]=this.generateRequestWithPreferredKeySession(r,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return mi.hexDump(e.keyId)}updateKeySession(e,t){var r;const s=e.mediaKeysSession;return this.log(`Updating key-session "${s.sessionId}" for keyID ${mi.hexDump(((r=e.decryptdata)==null?void 0:r.keyId)||[])}
47
+ } (data length: ${t&&t.byteLength})`),s.update(t)}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,r)=>{const s=eu(this.config),n=e.map(Em).filter(a=>!!a&&s.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{const o=bm(a);o?t(o):r(new Error(`Unable to find format for key-system "${a}"`))}).catch(r)})}loadKey(e){const t=e.keyInfo.decryptdata,r=this.getKeyIdString(t),s=`(keyId: ${r} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${s}`);let n=this.keyIdToKeySessionPromise[r];return n||(n=this.keyIdToKeySessionPromise[r]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${s}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();const l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t});return this.generateRequestWithPreferredKeySession(l,"cenc",t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof Dt?this.hls.trigger(v.ERROR,e.data):this.hls.trigger(v.ERROR,{type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),r=this.keyIdToKeySessionPromise[t];if(!r){const s=Em(e.keyFormat),n=s?[s]:eu(this.config);return this.attemptKeySystemAccess(n)}return r}getKeySystemSelectionPromise(e){if(e.length||(e=eu(this.config)),e.length===0)throw new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:t,initData:r}=e,s=`"${e.type}" event: init data type: "${t}"`;if(this.debug(s),r===null)return;let n,a;if(t==="sinf"&&this.config.drmSystems[Ie.FAIRPLAY]){const c=Ve(new Uint8Array(r));try{const h=Vh(JSON.parse(c).sinf),f=Eg(new Uint8Array(h));if(!f)throw new Error("'schm' box missing or not cbcs/cenc with schi > tenc");n=f.subarray(8,24),a=Ie.FAIRPLAY}catch(h){this.warn(`${s} Failed to parse sinf: ${h}`);return}}else{const c=H1(r),h=c.filter(f=>f.systemId===Wn.WIDEVINE)[0];if(!h){c.length===0||c.some(f=>!f.systemId)?this.warn(`${s} contains incomplete or invalid pssh data`):this.log(`ignoring ${s} for ${c.map(f=>ym(f.systemId)).join(",")} pssh data in favor of playlist keys`);return}if(a=ym(h.systemId),h.version===0&&h.data){const f=h.data.length-22;n=h.data.subarray(f,f+16)}}if(!a||!n)return;const o=mi.hexDump(n),{keyIdToKeySessionPromise:l,mediaKeySessions:d}=this;let u=l[o];for(let c=0;c<d.length;c++){const h=d[c],f=h.decryptdata;if(!f.keyId)continue;const m=mi.hexDump(f.keyId);if(o===m||f.uri.replace(/-/g,"").indexOf(o)!==-1){if(u=l[m],f.pssh)break;delete l[m],f.pssh=new Uint8Array(r),f.keyId=n,u=l[o]=u.then(()=>this.generateRequestWithPreferredKeySession(h,t,r,"encrypted-event-key-match"));break}}u||(u=l[o]=this.getKeySystemSelectionPromise([a]).then(({keySystem:c,mediaKeys:h})=>{var f;this.throwIfDestroyed();const m=new Ra("ISO-23001-7",o,(f=bm(c))!=null?f:"");return m.pssh=new Uint8Array(r),m.keyId=n,this.attemptSetMediaKeys(c,h).then(()=>{this.throwIfDestroyed();const p=this.createMediaKeySessionContext({decryptdata:m,keySystem:c,mediaKeys:h});return this.generateRequestWithPreferredKeySession(p,t,r,"encrypted-event-no-match")})})),u.catch(c=>this.handleError(c))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const r=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const s=Promise.all(r).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(s),s.then(()=>{this.log(`Media-keys set for "${e}"`),r.push(s),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>r.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,r,s){var n,a;const o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{const m=o.call(this.hls,t,r,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,r=e.decryptdata.pssh=m.initData?new Uint8Array(m.initData):null}catch(m){var l;if(this.warn(m.message),(l=this.hls)!=null&&l.config.debug)throw m}if(r===null)return this.log(`Skipping key-session request for "${s}" (no initData)`),Promise.resolve(e);const d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${s}": ${d} (init data type: ${t} length: ${r?r.byteLength:null})`);const u=new sf,c=e._onmessage=m=>{const p=e.mediaKeysSession;if(!p){u.emit("error",new Error("invalid state"));return}const{messageType:g,message:E}=m;this.log(`"${g}" message event for session "${p.sessionId}" message size: ${E.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,E).catch(y=>{this.handleError(y),u.emit("error",y)}):g==="license-release"?e.keySystem===Ie.FAIRPLAY&&(this.updateKeySession(e,ju("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){u.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);const g=e.keyStatus;u.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",c),e.mediaKeysSession.addEventListener("keystatuseschange",h);const f=new Promise((m,p)=>{u.on("error",p),u.on("keyStatus",g=>{g.startsWith("usable")?m():g==="output-restricted"?p(new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?p(new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?p(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,r).then(()=>{var m;this.log(`Request generated for key-session "${(m=e.mediaKeysSession)==null?void 0:m.sessionId}" keyId: ${d}`)}).catch(m=>{throw new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_NO_SESSION,error:m,fatal:!1},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>{throw u.removeAllListeners(),this.removeSession(e),m}).then(()=>(u.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,r)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${mi.hexDump("buffer"in r?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):new Uint8Array(r))} session keyId: ${mi.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,r=t.loader,s=new r(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{const l={responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{a(h.data)},onError:(h,f,m,p)=>{o(new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:dt({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,m)=>{o(new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,m)=>{o(new Error("aborted"))}};s.load(l,u,c)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,r){return new Promise((s,n)=>{e.setServerCertificate(r).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${r==null?void 0:r.byteLength}) on "${t}"`),s(e)}).catch(a=>{n(new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(r=>this.updateKeySession(e,new Uint8Array(r)).catch(s=>{throw new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:s,fatal:!0},s.message)}))}unpackPlayReadyKeyMessage(e,t){const r=String.fromCharCode.apply(null,new Uint16Array(t.buffer));if(!r.includes("PlayReadyKeyMessage"))return e.setRequestHeader("Content-Type","text/xml; charset=utf-8"),t;const s=new DOMParser().parseFromString(r,"application/xml"),n=s.querySelectorAll("HttpHeader");if(n.length>0){let u;for(let c=0,h=n.length;c<h;c++){var a,o;u=n[c];const f=(a=u.querySelector("name"))==null?void 0:a.textContent,m=(o=u.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m)}}const l=s.querySelector("Challenge"),d=l==null?void 0:l.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return ju(atob(d))}setupLicenseXHR(e,t,r,s){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!r.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,r,s)}).catch(a=>{if(!r.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,r,s)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||s})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:s}))}requestLicense(e,t){const r=this.config.keyLoadPolicy.default;return new Promise((s,n)=>{const a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);const d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e)}catch(u){this.error(u)}s(l)}else{const l=r.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new Dt({type:ie.KEY_SYSTEM_ERROR,details:D.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{const u=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${u} attempts left`),this.requestLicense(e,t).then(s,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:d})=>{e.keySystem==Ie.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(l,d)),l.send(d)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const r=t.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Ra.clearKeyUriToKeyIdMap();const r=t.length;rn.CDMCleanupPromise=Promise.all(t.map(s=>this.removeSession(s)).concat(e==null?void 0:e.setMediaKeys(null).catch(s=>{this.log(`Could not clear media keys: ${s}`)}))).then(()=>{r&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(s=>{this.log(`Could not close sessions and clear media keys: ${s}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const r=t.reduce((s,n)=>(s.indexOf(n.keyFormat)===-1&&s.push(n.keyFormat),s),[]);this.log(`Selecting key-system from session-keys ${r.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(r)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:r}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),e._onmessage&&(t.removeEventListener("message",e._onmessage),e._onmessage=void 0),e._onkeystatuseschange&&(t.removeEventListener("keystatuseschange",e._onkeystatuseschange),e._onkeystatuseschange=void 0),r&&r.readyState!==XMLHttpRequest.DONE&&r.abort(),e.mediaKeysSession=e.decryptdata=e.licenseXhr=void 0;const s=this.mediaKeySessions.indexOf(e);return s>-1&&this.mediaKeySessions.splice(s,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}}rn.CDMCleanupPromise=void 0;class Dt extends Error{constructor(e,t){super(t),this.data=void 0,e.error||(e.error=new Error(t)),this.data=e,e.err=e.error}}var pt;(function(i){i.MANIFEST="m",i.AUDIO="a",i.VIDEO="v",i.MUXED="av",i.INIT="i",i.CAPTION="c",i.TIMED_TEXT="tt",i.KEY="k",i.OTHER="o"})(pt||(pt={}));var sc;(function(i){i.DASH="d",i.HLS="h",i.SMOOTH="s",i.OTHER="o"})(sc||(sc={}));var zr;(function(i){i.OBJECT="CMCD-Object",i.REQUEST="CMCD-Request",i.SESSION="CMCD-Session",i.STATUS="CMCD-Status"})(zr||(zr={}));const hx={[zr.OBJECT]:["br","d","ot","tb"],[zr.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[zr.SESSION]:["cid","pr","sf","sid","st","v"],[zr.STATUS]:["bs","rtp"]};class vn{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(r=>r instanceof vn?r:new vn(r))),this.value=e,this.params=t}}class nv{constructor(e){this.description=void 0,this.description=e}}const fx="Dict";function mx(i){return Array.isArray(i)?JSON.stringify(i):i instanceof Map?"Map{}":i instanceof Set?"Set{}":typeof i=="object"?JSON.stringify(i):String(i)}function px(i,e,t,r){return new Error(`failed to ${i} "${mx(e)}" as ${t}`,{cause:r})}const fp="Bare Item",gx="Boolean",vx="Byte Sequence",Ex="Decimal",yx="Integer";function bx(i){return i<-999999999999999||999999999999999<i}const Tx=/[\x00-\x1f\x7f]+/,_x="Token",Ax="Key";function ki(i,e,t){return px("serialize",i,e,t)}function Sx(i){if(typeof i!="boolean")throw ki(i,gx);return i?"?1":"?0"}function xx(i){return btoa(String.fromCharCode(...i))}function kx(i){if(ArrayBuffer.isView(i)===!1)throw ki(i,vx);return`:${xx(i)}:`}function av(i){if(bx(i))throw ki(i,yx);return i.toString()}function Lx(i){return`@${av(i.getTime()/1e3)}`}function ov(i,e){if(i<0)return-ov(-i,e);const t=Math.pow(10,e);if(Math.abs(i*t%1-.5)<Number.EPSILON){const s=Math.floor(i*t);return(s%2===0?s:s+1)/t}else return Math.round(i*t)/t}function Ix(i){const e=ov(i,3);if(Math.floor(Math.abs(e)).toString().length>12)throw ki(i,Ex);const t=e.toString();return t.includes(".")?t:`${t}.0`}const Rx="String";function wx(i){if(Tx.test(i))throw ki(i,Rx);return`"${i.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function Cx(i){return i.description||i.toString().slice(7,-1)}function mp(i){const e=Cx(i);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw ki(e,_x);return e}function nc(i){switch(typeof i){case"number":if(!Y(i))throw ki(i,fp);return Number.isInteger(i)?av(i):Ix(i);case"string":return wx(i);case"symbol":return mp(i);case"boolean":return Sx(i);case"object":if(i instanceof Date)return Lx(i);if(i instanceof Uint8Array)return kx(i);if(i instanceof nv)return mp(i);default:throw ki(i,fp)}}function ac(i){if(/^[a-z*][a-z0-9\-_.*]*$/.test(i)===!1)throw ki(i,Ax);return i}function lf(i){return i==null?"":Object.entries(i).map(([e,t])=>t===!0?`;${ac(e)}`:`;${ac(e)}=${nc(t)}`).join("")}function lv(i){return i instanceof vn?`${nc(i.value)}${lf(i.params)}`:nc(i)}function Dx(i){return`(${i.value.map(lv).join(" ")})${lf(i.params)}`}function Mx(i,e={whitespace:!0}){if(typeof i!="object")throw ki(i,fx);const t=i instanceof Map?i.entries():Object.entries(i),r=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([s,n])=>{n instanceof vn||(n=new vn(n));let a=ac(s);return n.value===!0?a+=lf(n.params):(a+="=",Array.isArray(n.value)?a+=Dx(n):a+=lv(n)),a}).join(`,${r}`)}function Px(i,e){return Mx(i,e)}const Ox=i=>i==="ot"||i==="sf"||i==="st",Nx=i=>typeof i=="number"?Y(i):i!=null&&i!==""&&i!==!1;function Fx(i,e){const t=new URL(i),r=new URL(e);if(t.origin!==r.origin)return i;const s=t.pathname.split("/").slice(1),n=r.pathname.split("/").slice(1,-1);for(;s[0]===n[0];)s.shift(),n.shift();for(;n.length;)n.shift(),s.unshift("..");return s.join("/")}function Ux(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,s=>{const n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(s=="x"?n:n&3|8).toString(16)})}}}const Oo=i=>Math.round(i),$x=(i,e)=>(e!=null&&e.baseUrl&&(i=Fx(i,e.baseUrl)),encodeURIComponent(i)),oo=i=>Oo(i/100)*100,Bx={br:Oo,d:Oo,bl:oo,dl:oo,mtp:oo,nor:$x,rtp:oo,tb:Oo};function Gx(i,e){const t={};if(i==null||typeof i!="object")return t;const r=Object.keys(i).sort(),s=We({},Bx,e==null?void 0:e.formatters),n=e==null?void 0:e.filter;return r.forEach(a=>{if(n!=null&&n(a))return;let o=i[a];const l=s[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||Nx(o)&&(Ox(a)&&typeof o=="string"&&(o=new nv(o)),t[a]=o))}),t}function dv(i,e={}){return i?Px(Gx(i,e),We({whitespace:!1},e)):""}function Hx(i,e={}){if(!i)return{};const t=Object.entries(i),r=Object.entries(hx).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),s=t.reduce((n,a)=>{var o,l;const[d,u]=a,c=((o=r.find(h=>h[1].includes(d)))==null?void 0:o[0])||zr.REQUEST;return(l=n[c])!=null||(n[c]={}),n[c][d]=u,n},{});return Object.entries(s).reduce((n,[a,o])=>(n[a]=dv(o,e),n),{})}function Wx(i,e,t){return We(i,Hx(e,t))}const Kx="CMCD";function Vx(i,e={}){if(!i)return"";const t=dv(i,e);return`${Kx}=${encodeURIComponent(t)}`}const pp=/CMCD=[^&#]+/;function qx(i,e,t){const r=Vx(e,t);if(!r)return i;if(pp.test(i))return i.replace(pp,r);const s=i.includes("?")?"&":"?";return`${i}${s}${r}`}class Yx{constructor(e){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=s=>{try{this.apply(s,{ot:pt.MANIFEST,su:!this.initialized})}catch(n){I.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=s=>{try{const n=s.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===pt.VIDEO||o===pt.AUDIO||o==pt.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(s,l)}catch(n){I.warn("Could not generate segment CMCD data.",n)}},this.hls=e;const t=this.config=e.config,{cmcd:r}=t;r!=null&&(t.pLoader=this.createPlaylistLoader(),t.fLoader=this.createFragmentLoader(),this.sid=r.sessionId||Ux(),this.cid=r.contentId,this.useHeaders=r.useHeaders===!0,this.includeKeys=r.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHED,this.onMediaDetached,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHED,this.onMediaDetached,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null}onMediaAttached(e,t){this.media=t.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(e,t){var r,s;this.audioBuffer=(r=t.tracks.audio)==null?void 0:r.buffer,this.videoBuffer=(s=t.tracks.video)==null?void 0:s.buffer}createData(){var e;return{v:1,sf:sc.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){We(t,this.createData());const r=t.ot===pt.INIT||t.ot===pt.VIDEO||t.ot===pt.MUXED;this.starved&&r&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:s}=this;s&&(t=Object.keys(t).reduce((n,a)=>(s.includes(a)&&(n[a]=t[a]),n),{})),this.useHeaders?(e.headers||(e.headers={}),Wx(e.headers,t)):e.url=qx(e.url,t)}getObjectType(e){const{type:t}=e;if(t==="subtitle")return pt.TIMED_TEXT;if(e.sn==="initSegment")return pt.INIT;if(t==="audio")return pt.AUDIO;if(t==="main")return this.hls.audioTracks.length?pt.VIDEO:pt.MUXED}getTopBandwidth(e){let t=0,r;const s=this.hls;if(e===pt.AUDIO)r=s.audioTracks;else{const n=s.maxAutoLevel,a=n>-1?n+1:s.levels.length;r=s.levels.slice(0,a)}for(const n of r)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){const t=this.hls.media,r=e===pt.AUDIO?this.audioBuffer:this.videoBuffer;return!r||!t?NaN:Le.bufferInfo(r,t.currentTime,this.config.maxBufferHole).len*1e3}createPlaylistLoader(){const{pLoader:e}=this.config,t=this.applyPlaylistData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,r=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new r(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}}const jx=3e5;class zx{constructor(e){this.hls=void 0,this.log=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=e,this.log=I.log.bind(I,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.ERROR,this.onError,this))}startLoad(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){const e=this.timeToLoad*1e3-(performance.now()-this.updated);if(e>0){this.scheduleRefresh(this.uri,e);return}}this.loadSteeringManifest(this.uri)}}stopLoad(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()}clearTimeout(){this.reloadTimer!==-1&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)}destroy(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null}removeLevel(e){const t=this.levels;t&&(this.levels=t.filter(r=>r!==e))}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(e,t){const{contentSteering:r}=t;r!==null&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())}onManifestParsed(e,t){this.audioTracks=t.audioTracks,this.subtitleTracks=t.subtitleTracks}onError(e,t){const{errorAction:r}=t;if((r==null?void 0:r.action)===ht.SendAlternateToPenaltyBox&&r.flags===Gt.MoveAllAlternatesMatchingHost){const s=this.levels;let n=this.pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:o,pathwayId:l,type:d}=t.context;o&&s?a=this.getPathwayForGroupId(o,d,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&s&&(n=s.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==a),r.resolved||I.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${s&&s.length} priorities: ${JSON.stringify(n)} penalized: ${JSON.stringify(this.penalizedPathways)}`)}}filterParsedLevels(e){this.levels=e;let t=this.getLevelsForPathway(this.pathwayId);if(t.length===0){const r=e[0].pathwayId;this.log(`No levels found in Pathway ${this.pathwayId}. Setting initial Pathway to "${r}"`),t=this.getLevelsForPathway(r),this.pathwayId=r}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t;const r=this.penalizedPathways,s=performance.now();Object.keys(r).forEach(n=>{s-r[n]>jx&&delete r[n]});for(let n=0;n<e.length;n++){const a=e[n];if(a in r)continue;if(a===this.pathwayId)return;const o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,Ig(t),this.hls.trigger(v.LEVELS_UPDATED,{levels:t});const d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,r){const s=this.getLevelsForPathway(r).concat(this.levels||[]);for(let n=0;n<s.length;n++)if(t===fe.AUDIO_TRACK&&s[n].hasAudioGroup(e)||t===fe.SUBTITLE_TRACK&&s[n].hasSubtitleGroup(e))return s[n].pathwayId;return r}clonePathways(e){const t=this.levels;if(!t)return;const r={},s={};e.forEach(n=>{const{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(u=>u.pathwayId===a))return;const d=this.getLevelsForPathway(o).map(u=>{const c=new Me(u.attrs);c["PATHWAY-ID"]=a;const h=c.AUDIO&&`${c.AUDIO}_clone_${a}`,f=c.SUBTITLES&&`${c.SUBTITLES}_clone_${a}`;h&&(r[c.AUDIO]=h,c.AUDIO=h),f&&(s[c.SUBTITLES]=f,c.SUBTITLES=f);const m=uv(u.uri,c["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),p=new pn({attrs:c,audioCodec:u.audioCodec,bitrate:u.bitrate,height:u.height,name:u.name,url:m,videoCodec:u.videoCodec,width:u.width});if(u.audioGroups)for(let g=1;g<u.audioGroups.length;g++)p.addGroupId("audio",`${u.audioGroups[g]}_clone_${a}`);if(u.subtitleGroups)for(let g=1;g<u.subtitleGroups.length;g++)p.addGroupId("text",`${u.subtitleGroups[g]}_clone_${a}`);return p});t.push(...d),gp(this.audioTracks,r,l,a),gp(this.subtitleTracks,s,l,a)})}loadSteeringManifest(e){const t=this.hls.config,r=t.loader;this.loader&&this.loader.destroy(),this.loader=new r(t);let s;try{s=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(s.protocol!=="data:"){const u=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;s.searchParams.set("_HLS_pathway",this.pathwayId),s.searchParams.set("_HLS_throughput",""+u)}const n={responseType:"json",url:s.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(u,c,h,f)=>{this.log(`Loaded steering manifest: "${s}"`);const m=u.data;if(m.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;const{"RELOAD-URI":p,"PATHWAY-CLONES":g,"PATHWAY-PRIORITY":E}=m;if(p)try{this.uri=new self.URL(p,s).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${p}`);return}this.scheduleRefresh(this.uri||h.url),g&&this.clonePathways(g);const y={steeringManifest:m,url:s.toString()};this.hls.trigger(v.STEERING_MANIFEST_LOADED,y),E&&this.updatePathwayPriority(E)},onError:(u,c,h,f)=>{if(this.log(`Error loading steering manifest: ${u.code} ${u.text} (${c.url})`),this.stopLoad(),u.code===410){this.enabled=!1,this.log(`Steering manifest ${c.url} no longer available`);return}let m=this.timeToLoad*1e3;if(u.code===429){const p=this.loader;if(typeof(p==null?void 0:p.getResponseHeader)=="function"){const g=p.getResponseHeader("Retry-After");g&&(m=parseFloat(g)*1e3)}this.log(`Steering manifest ${c.url} rate limited`);return}this.scheduleRefresh(this.uri||c.url,m)},onTimeout:(u,c,h)=>{this.log(`Timeout loading steering manifest (${c.url})`),this.scheduleRefresh(this.uri||c.url)}};this.log(`Requesting steering manifest: ${s}`),this.loader.load(n,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var r;const s=(r=this.hls)==null?void 0:r.media;if(s&&!s.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function gp(i,e,t,r){i&&Object.keys(e).forEach(s=>{const n=i.filter(a=>a.groupId===s).map(a=>{const o=We({},a);return o.details=void 0,o.attrs=new Me(o.attrs),o.url=o.attrs.URI=uv(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[s],o.attrs["PATHWAY-ID"]=r,o});i.push(...n)})}function uv(i,e,t,r){const{HOST:s,PARAMS:n,[t]:a}=r;let o;e&&(o=a==null?void 0:a[e],o&&(i=o));const l=new self.URL(i);return s&&!o&&(l.host=s),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}const Xx=/^age:\s*[\d.]+\s*$/im;class cv{constructor(e){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=e&&e.xhrSetup||null,this.stats=new wd,this.retryDelay=0}destroy(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null,this.context=null,this.xhrSetup=null}abortInternal(){const e=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),e&&(e.onreadystatechange=null,e.onprogress=null,e.readyState!==4&&(this.stats.aborted=!0,e.abort()))}abort(){var e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)}load(e,t,r){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=e,this.config=t,this.callbacks=r,this.loadInternal()}loadInternal(){const{config:e,context:t}=this;if(!e||!t)return;const r=this.loader=new self.XMLHttpRequest,s=this.stats;s.loading.first=0,s.loaded=0,s.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==r||this.stats.aborted))return n(r,t.url)}).catch(a=>{if(!(this.loader!==r||this.stats.aborted))return r.open("GET",t.url,!0),n(r,t.url)}).then(()=>{this.loader!==r||this.stats.aborted||this.openAndSendXhr(r,t,e)}).catch(a=>{this.callbacks.onError({code:r.status,text:a.message},t,r,s)}):this.openAndSendXhr(r,t,e)}openAndSendXhr(e,t,r){e.readyState||e.open("GET",t.url,!0);const s=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=r.loadPolicy;if(s)for(const o in s)e.setRequestHeader(o,s[o]);t.rangeEnd&&e.setRequestHeader("Range","bytes="+t.rangeStart+"-"+(t.rangeEnd-1)),e.onreadystatechange=this.readystatechange.bind(this),e.onprogress=this.loadprogress.bind(this),e.responseType=t.responseType,self.clearTimeout(this.requestTimeout),r.timeout=n&&Y(n)?n:a,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),r.timeout),e.send()}readystatechange(){const{context:e,loader:t,stats:r}=this;if(!e||!t)return;const s=t.readyState,n=this.config;if(!r.aborted&&s>=2&&(r.loading.first===0&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),s===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const a=t.status,o=t.responseType!=="text";if(a>=200&&a<300&&(o&&t.response||t.responseText!==null)){r.loading.end=Math.max(self.performance.now(),r.loading.first);const l=o?t.response:t.responseText,d=t.responseType==="arraybuffer"?l.byteLength:l.length;if(r.loaded=r.total=d,r.bwEstimate=r.total*8e3/(r.loading.end-r.loading.first),!this.callbacks)return;const u=this.callbacks.onProgress;if(u&&u(r,e,l,t),!this.callbacks)return;const c={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(c,r,e,t)}else{const l=n.loadPolicy.errorRetry,d=r.retry,u={url:e.url,data:void 0,code:a};ed(l,d,!1,u)?this.retry(l):(I.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,r))}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(ed(e,t,!0))this.retry(e);else{var r;I.warn(`timeout while loading ${(r=this.context)==null?void 0:r.url}`);const s=this.callbacks;s&&(this.abortInternal(),s.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:r}=this;this.retryDelay=jh(e,r.retry),r.retry++,I.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${r.retry}/${e.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(e){const t=this.stats;t.loaded=e.loaded,e.lengthComputable&&(t.total=e.total)}getCacheAge(){let e=null;if(this.loader&&Xx.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}function Qx(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const Zx=/(\d+)-(\d+)\/(\d+)/;class vp{constructor(e){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=e.fetchSetup||ik,this.controller=new self.AbortController,this.stats=new wd}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 e;this.abortInternal(),(e=this.callbacks)!=null&&e.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)}load(e,t,r){const s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();const n=Jx(e,this.controller.signal),a=r.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:u}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=r,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&Y(d)?d:u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},t.timeout),self.fetch(this.request).then(c=>{this.response=this.loader=c;const h=Math.max(self.performance.now(),s.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=u,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),r.onTimeout(s,e,this.response)},u-(h-s.loading.start)),!c.ok){const{status:f,statusText:m}=c;throw new rk(m||"fetch, bad network response",f,c)}return s.loading.first=h,s.total=tk(c.headers)||s.total,a&&Y(t.highWaterMark)?this.loadProgressively(c,s,e,t.highWaterMark,a):o?c.arrayBuffer():e.responseType==="json"?c.json():c.text()}).then(c=>{const h=this.response;if(!h)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first);const f=c[l];f&&(s.loaded=s.total=f);const m={url:h.url,data:c,code:h.status};a&&!Y(t.highWaterMark)&&a(s,e,c,h),r.onSuccess(m,s,e,h)}).catch(c=>{if(self.clearTimeout(this.requestTimeout),s.aborted)return;const h=c&&c.code||0,f=c?c.message:null;r.onError({code:h,text:f},e,c?c.details:null,s)})}getCacheAge(){let e=null;if(this.response){const t=this.response.headers.get("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.response?this.response.headers.get(e):null}loadProgressively(e,t,r,s=0,n){const a=new Dg,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,r,a.flush(),e),Promise.resolve(new ArrayBuffer(0));const u=d.value,c=u.length;return t.loaded+=c,c<s||a.dataLength?(a.push(u),a.dataLength>=s&&n(t,r,a.flush(),e)):n(t,r,u,e),l()}).catch(()=>Promise.reject());return l()}}function Jx(i,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(We({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function ek(i){const e=Zx.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function tk(i){const e=i.get("Content-Range");if(e){const r=ek(e);if(Y(r))return r}const t=i.get("Content-Length");if(t)return parseInt(t)}function ik(i,e){return new self.Request(i.url,e)}class rk extends Error{constructor(e,t,r){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=r}}const sk=/\s/,nk={newCue(i,e,t,r){const s=[];let n,a,o,l,d;const u=self.VTTCue||self.TextTrackCue;for(let h=0;h<r.rows.length;h++)if(n=r.rows[h],o=!0,l=0,d="",!n.isEmpty()){var c;for(let p=0;p<n.chars.length;p++)sk.test(n.chars[p].uchar)&&o?l++:(d+=n.chars[p].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;const f=ev(d.trim()),m=af(e,t,f);i!=null&&(c=i.cues)!=null&&c.getCueById(m)||(a=new u(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),s.push(a))}return i&&s.length&&(s.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),s.forEach(h=>Sg(i,h))),s}},ak={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},hv=dt(dt({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,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,loader:cv,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:MA,bufferController:FS,capLevelController:of,errorController:TA,fpsController:cx,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:ug,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:ak},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}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},ok()),{},{subtitleStreamController:MS,subtitleTrackController:OS,timelineController:dx,audioStreamController:CS,audioTrackController:DS,emeController:rn,cmcdController:Yx,contentSteeringController:zx});function ok(){return{cueHandler:nk,enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}}function lk(i,e){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(e.liveMaxLatencyDurationCount!==void 0&&(e.liveSyncDurationCount===void 0||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(e.liveMaxLatencyDuration!==void 0&&(e.liveSyncDuration===void 0||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');const t=oc(i),r=["manifest","level","frag"],s=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return r.forEach(n=>{const a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];s.forEach(d=>{const u=`${n}Loading${d}`,c=e[u];if(c!==void 0&&o){l.push(u);const h=t[a].default;switch(e[a]={default:h},d){case"TimeOut":h.maxLoadTimeMs=c,h.maxTimeToFirstByteMs=c;break;case"MaxRetry":h.errorRetry.maxNumRetry=c,h.timeoutRetry.maxNumRetry=c;break;case"RetryDelay":h.errorRetry.retryDelayMs=c,h.timeoutRetry.retryDelayMs=c;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=c,h.timeoutRetry.maxRetryDelayMs=c;break}}}),l.length&&I.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),dt(dt({},t),e)}function oc(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(oc):Object.keys(i).reduce((e,t)=>(e[t]=oc(i[t]),e),{}):i}function dk(i){const e=i.loader;e!==vp&&e!==cv?(I.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):Qx()&&(i.loader=vp,i.progressive=!0,i.enableSoftwareAES=!0,I.log("[config]: Progressive streaming enabled, using FetchLoader"))}let yu;class uk extends zh{constructor(e,t){super(e,"[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=t,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this),e.on(v.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this),e.off(v.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(e,t){this.resetLevels()}onManifestLoaded(e,t){const r=this.hls.config.preferManagedMediaSource,s=[],n={},a={};let o=!1,l=!1,d=!1;t.levels.forEach(u=>{var c,h;const f=u.attrs;let{audioCodec:m,videoCodec:p}=u;((c=m)==null?void 0:c.indexOf("mp4a.40.34"))!==-1&&(yu||(yu=/chrome|firefox/i.test(navigator.userAgent)),yu&&(u.audioCodec=m=void 0)),m&&(u.audioCodec=m=Ql(m,r)),((h=p)==null?void 0:h.indexOf("avc1"))===0&&(p=u.videoCodec=X1(p));const{width:g,height:E,unknownCodecs:y}=u;if(o||(o=!!(g&&E)),l||(l=!!p),d||(d=!!m),y!=null&&y.length||m&&!su(m,"audio",r)||p&&!su(p,"video",r))return;const{CODECS:b,"FRAME-RATE":S,"HDCP-LEVEL":_,"PATHWAY-ID":x,RESOLUTION:A,"VIDEO-RANGE":C}=f,L=`${`${x||"."}-`}${u.bitrate}-${A}-${S}-${b}-${C}-${_}`;if(n[L])if(n[L].uri!==u.url&&!u.attrs["PATHWAY-ID"]){const M=a[L]+=1;u.attrs["PATHWAY-ID"]=new Array(M+1).join(".");const K=new pn(u);n[L]=K,s.push(K)}else n[L].addGroupId("audio",f.AUDIO),n[L].addGroupId("text",f.SUBTITLES);else{const M=new pn(u);n[L]=M,a[L]=1,s.push(M)}}),this.filterAndSortMediaOptions(s,t,o,l,d)}filterAndSortMediaOptions(e,t,r,s,n){let a=[],o=[],l=e;if((r||s)&&n&&(l=l.filter(({videoCodec:m,videoRange:p,width:g,height:E})=>(!!m||!!(g&&E))&&dA(p))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);const m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:m,reason:m.message})}});return}if(t.audioTracks){const{preferManagedMediaSource:m}=this.hls.config;a=t.audioTracks.filter(p=>!p.audioCodec||su(p.audioCodec,"audio",m)),Ep(a)}t.subtitles&&(o=t.subtitles,Ep(o));const d=l.slice(0);l.sort((m,p)=>{if(m.attrs["HDCP-LEVEL"]!==p.attrs["HDCP-LEVEL"])return(m.attrs["HDCP-LEVEL"]||"")>(p.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&m.height!==p.height)return m.height-p.height;if(m.frameRate!==p.frameRate)return m.frameRate-p.frameRate;if(m.videoRange!==p.videoRange)return Zl.indexOf(m.videoRange)-Zl.indexOf(p.videoRange);if(m.videoCodec!==p.videoCodec){const g=xm(m.videoCodec),E=xm(p.videoCodec);if(g!==E)return E-g}if(m.uri===p.uri&&m.codecSet!==p.codecSet){const g=Xl(m.codecSet),E=Xl(p.codecSet);if(g!==E)return E-g}return m.averageBitrate!==p.averageBitrate?m.averageBitrate-p.averageBitrate:0});let u=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let m=0;m<d.length;m++)if(d[m].pathwayId===l[0].pathwayId){u=d[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===u){var c;this._firstLevel=m;const p=u.bitrate,g=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${p}`),((c=this.hls.userConfig)==null?void 0:c.abrEwmaDefaultEstimate)===void 0){const E=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);E>g&&g===hv.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=E)}break}const h=n&&!s,f={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:s,altAudio:!h&&a.some(m=>!!m.url)};this.hls.trigger(v.MANIFEST_PARSED,f),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}get level(){return this.currentLevelIndex}set level(e){const t=this._levels;if(t.length===0)return;if(e<0||e>=t.length){const u=new Error("invalid level idx"),c=e<0;if(this.hls.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:D.LEVEL_SWITCH_ERROR,level:e,fatal:c,error:u,reason:u.message}),c)return;e=Math.min(e,t.length-1)}const r=this.currentLevelIndex,s=this.currentLevel,n=s?s.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,r===e&&a.details&&s&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${r}${n?" with Pathway "+n:""}`);const l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(v.LEVEL_SWITCHING,l);const d=a.details;if(!d||d.live){const u=this.switchParams(a.uri,s==null?void 0:s.details,d);this.loadPlaylist(u)}}get manualLevel(){return this.manualLevelIndex}set manualLevel(e){this.manualLevelIndex=e,this._startLevel===void 0&&(this._startLevel=e),e!==-1&&(this.level=e)}get firstLevel(){return this._firstLevel}set firstLevel(e){this._firstLevel=e}get startLevel(){if(this._startLevel===void 0){const e=this.hls.config.startLevel;return e!==void 0?e:this.hls.firstAutoLevel}return this._startLevel}set startLevel(e){this._startLevel=e}onError(e,t){t.fatal||!t.context||t.context.type===fe.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===ee.MAIN){const r=t.elementaryStreams;if(!Object.keys(r).some(n=>!!r[n]))return;const s=this._levels[t.level];s!=null&&s.loadError&&(this.log(`Resetting level error count of ${s.loadError} on frag buffered`),s.loadError=0)}}onLevelLoaded(e,t){var r;const{level:s,details:n}=t,a=this._levels[s];if(!a){var o;this.warn(`Invalid level index ${s}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}s===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(s,t,a.details)):(r=t.deliveryDirectives)!=null&&r.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,r=this.currentLevel;if(r&&this.shouldLoadPlaylist(r)){let s=r.uri;if(e)try{s=e.addDirectives(s)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}const n=r.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${n?" Pathway "+n:""} ${s}`),this.clearTimer(),this.hls.trigger(v.LEVEL_LOADING,{url:s,level:t,pathwayId:r.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}}get nextLoadLevel(){return this.manualLevelIndex!==-1?this.manualLevelIndex:this.hls.nextAutoLevel}set nextLoadLevel(e){this.level=e,this.manualLevelIndex===-1&&(this.hls.nextAutoLevel=e)}removeLevel(e){var t;const r=this._levels.filter((s,n)=>n!==e?!0:(this.steering&&this.steering.removeLevel(s),s===this.currentLevel&&(this.currentLevel=null,this.currentLevelIndex=-1,s.details&&s.details.fragments.forEach(a=>a.level=-1)),!1));Ig(r),this._levels=r,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(v.LEVELS_UPDATED,{levels:r})}onLevelsUpdated(e,{levels:t}){this._levels=t}checkMaxAutoUpdated(){const{autoLevelCapping:e,maxAutoLevel:t,maxHdcpLevel:r}=this.hls;this._maxAutoLevel!==t&&(this._maxAutoLevel=t,this.hls.trigger(v.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:r}))}}function Ep(i){const e={};i.forEach(t=>{const r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++})}class ck{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const r in this.keyUriToKeyInfo){const s=this.keyUriToKeyInfo[r].loader;if(s){var t;if(e&&e!==((t=s.context)==null?void 0:t.frag.type))return;s.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=D.KEY_LOAD_ERROR,r,s,n){return new Fi({type:ie.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:r,networkDetails:s})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:r,cc:s}=e;for(let n=0;n<t.length;n++){const a=t[n];if(s<=a.cc&&(r==="initSegment"||a.sn==="initSegment"||r<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var r,s;t&&e.setKeyFormat(t);const n=e.decryptdata;if(!n){const d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,d))}const a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((r=o)!=null&&r.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((s=o)!=null&&s.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(d=>(n.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,D.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){const r={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const s=this.emeController.loadKey(r);if(s)return(e.keyLoadPromise=s.then(n=>(e.mediaKeySessionContext=n,r))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(r)}loadKeyHTTP(e,t){const r=this.config,s=r.loader,n=new s(r);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{const l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=r.keyLoadPolicy.default,u={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},c={onSuccess:(h,f,m,p)=>{const{frag:g,keyInfo:E,url:y}=m;if(!g.decryptdata||E!==this.keyUriToKeyInfo[y])return o(this.createKeyLoadError(g,D.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),p));E.decryptdata.key=g.decryptdata.key=new Uint8Array(h.data),g.keyLoader=null,E.loader=null,a({frag:g,keyInfo:E})},onError:(h,f,m,p)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,dt({url:l.url,data:void 0},h)))},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,D.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};n.load(l,u,c)})}resetLoader(e){const{frag:t,keyInfo:r,url:s}=e,n=r.loader;t.keyLoader===n&&(t.keyLoader=null,r.loader=null),delete this.keyUriToKeyInfo[s],n&&n.destroy()}}function fv(){return self.SourceBuffer||self.WebKitSourceBuffer}function mv(){if(!ds())return!1;const e=fv();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function hk(){if(!mv())return!1;const i=ds();return typeof(i==null?void 0:i.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>i.isTypeSupported(wa(e,"video")))||["mp4a.40.2","fLaC"].some(e=>i.isTypeSupported(wa(e,"audio"))))}function fk(){var i;const e=fv();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}const mk=250,No=2,pk=.1,gk=.05;class vk{constructor(e,t,r,s){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=r,this.hls=s}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:r,media:s,stalled:n}=this;if(s===null)return;const{currentTime:a,seeking:o}=s,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),n!==null){if(this.stallReported){const g=self.performance.now()-n;I.warn(`playback not stuck anymore @${a}, after ${Math.round(g)}ms`),this.stallReported=!1}this.stalled=null}return}if(d||l){this.stalled=null;return}if(s.paused&&!o||s.ended||s.playbackRate===0||!Le.getBuffered(s).length){this.nudgeRetry=0;return}const u=Le.bufferInfo(s,a,0),c=u.nextStart||0;if(o){const g=u.len>No,E=!c||t&&t.start<=a||c-a>No&&!this.fragmentTracker.getPartialFragment(a);if(g||E)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var h;if(!(u.len>0)&&!c)return;const E=Math.max(c,u.start||0)-a,y=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,S=(y==null||(h=y.details)==null?void 0:h.live)?y.details.targetduration*2:No,_=this.fragmentTracker.getPartialFragment(a);if(E>0&&(E<=S||_)){s.paused||this._trySkipBufferHole(_);return}}const f=self.performance.now();if(n===null){this.stalled=f;return}const m=f-n;if(!o&&m>=mk&&(this._reportStall(u),!this.media))return;const p=Le.bufferInfo(s,a,r.maxBufferHole);this._tryFixBufferStall(p,m)}_tryFixBufferStall(e,t){const{config:r,fragmentTracker:s,media:n}=this;if(n===null)return;const a=n.currentTime,o=s.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>r.maxBufferHole||e.nextStart&&e.nextStart-a<r.maxBufferHole)&&t>r.highBufferWatchdogPeriod*1e3&&(I.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:r,stallReported:s}=this;if(!s&&r){this.stallReported=!0;const n=new Error(`Playback stalling at @${r.currentTime} due to low buffer (${JSON.stringify(e)})`);I.warn(n.message),t.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:r,media:s}=this;if(s===null)return 0;const n=s.currentTime,a=Le.bufferInfo(s,n,0),o=n<a.start?a.start:a.nextStart;if(o){const l=a.len<=t.maxBufferHole,d=a.len>0&&a.len<1&&s.readyState<3,u=o-n;if(u>0&&(l||d)){if(u>t.maxBufferHole){const{fragmentTracker:h}=this;let f=!1;if(n===0){const m=h.getAppendedFrag(0,ee.MAIN);m&&o<m.end&&(f=!0)}if(!f){const m=e||h.getAppendedFrag(n,ee.MAIN);if(m){let p=!1,g=m.end;for(;g<o;){const E=h.getPartialFragment(g);if(E)g+=E.duration;else{p=!0;break}}if(p)return 0}}}const c=Math.max(o+gk,n+pk);if(I.warn(`skipping hole, adjusting currentTime from ${n} to ${c}`),this.moved=!0,this.stalled=null,s.currentTime=c,e&&!e.gap){const h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${c}`);r.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return c}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:r,nudgeRetry:s}=this;if(r===null)return;const n=r.currentTime;if(this.nudgeRetry++,s<e.nudgeMaxRetry){const a=n+(s+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);I.warn(o.message),r.currentTime=a,t.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{const a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);I.error(a.message),t.trigger(v.ERROR,{type:ie.MEDIA_ERROR,details:D.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}}const Ek=100;class yk extends Zh{constructor(e,t,r){super(e,t,r,"[stream-controller]",ee.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(v.MANIFEST_LOADING,this.onManifestLoading,this),e.on(v.MANIFEST_PARSED,this.onManifestParsed,this),e.on(v.LEVEL_LOADING,this.onLevelLoading,this),e.on(v.LEVEL_LOADED,this.onLevelLoaded,this),e.on(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(v.ERROR,this.onError,this),e.on(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(v.BUFFER_CREATED,this.onBufferCreated,this),e.on(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(v.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(v.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(v.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(v.MANIFEST_LOADING,this.onManifestLoading,this),e.off(v.MANIFEST_PARSED,this.onManifestParsed,this),e.off(v.LEVEL_LOADED,this.onLevelLoaded,this),e.off(v.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(v.ERROR,this.onError,this),e.off(v.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(v.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(v.BUFFER_CREATED,this.onBufferCreated,this),e.off(v.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(v.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(v.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:r}=this;if(this.stopLoad(),this.setInterval(Ek),this.level=-1,!this.startFragRequested){let s=r.startLevel;s===-1&&(r.config.testBandwidth&&this.levels.length>1?(s=0,this.bitrateTest=!0):s=r.firstAutoLevel),r.nextLoadLevel=s,this.level=r.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=N.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=N.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case N.WAITING_LEVEL:{const{levels:t,level:r}=this,s=t==null?void 0:t[r],n=s==null?void 0:s.details;if(n&&(!n.live||this.levelLastLoaded===s)){if(this.waitForCdnTuneIn(n))break;this.state=N.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=N.IDLE;break}break}case N.FRAG_LOADING_WAITING_RETRY:{var e;const t=self.performance.now(),r=this.retryDate;if(!r||t>=r||(e=this.media)!=null&&e.seeking){const{levels:s,level:n}=this,a=s==null?void 0:s[n];this.resetStartWhenNotLoaded(a||null),this.state=N.IDLE}}break}this.state===N.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:r,media:s}=this;if(t===null||!s&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const n=e.nextLoadLevel;if(!(r!=null&&r[n]))return;const a=r[n],o=this.getMainFwdBufferInfo();if(o===null)return;const l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){const p={};this.altAudio&&(p.type="video"),this.hls.trigger(v.BUFFER_EOS,p),this.state=N.ENDED;return}e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;const d=a.details;if(!d||this.state===N.WAITING_LEVEL||d.live&&this.levelLastLoaded!==a){this.level=n,this.state=N.WAITING_LEVEL;return}const u=o.len,c=this.getMaxBufferLength(a.maxBitrate);if(u>=c)return;this.backtrackFragment&&this.backtrackFragment.start>o.end&&(this.backtrackFragment=null);const h=this.backtrackFragment?this.backtrackFragment.start:o.end;let f=this.getNextFragment(h,d);if(this.couldBacktrack&&!this.fragPrevious&&f&&f.sn!=="initSegment"&&this.fragmentTracker.getState(f)!==nt.OK){var m;const g=((m=this.backtrackFragment)!=null?m:f).sn-d.startSN,E=d.fragments[g-1];E&&f.cc===E.cc&&(f=E,this.fragmentTracker.removeFragment(E))}else this.backtrackFragment&&o.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,h)){if(!f.gap){const g=this.audioOnly&&!this.altAudio?ye.AUDIO:ye.VIDEO,E=(g===ye.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;E&&this.afterBufferFlushed(E,g,ee.MAIN)}f=this.getNextFragmentLoopLoading(f,d,o,ee.MAIN,c)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h))}loadFragment(e,t,r){const s=this.fragmentTracker.getState(e);this.fragCurrent=e,s===nt.NOT_LOADED||s===nt.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,r)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,ee.MAIN)}followingBufferedFrag(e){return e?this.getBufferedFrag(e.end+.5):null}immediateLevelSwitch(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)}nextLevelSwitch(){const{levels:e,media:t}=this;if(t!=null&&t.readyState){let r;const s=this.getAppendedFrag(t.currentTime);s&&s.start>1&&this.flushMainBuffer(0,s.start-1);const n=this.getLevelDetails();if(n!=null&&n.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?r=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:r=0}else r=0;const a=this.getBufferedFrag(t.currentTime+r);if(a){const o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();const l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,u=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(u,Number.POSITIVE_INFINITY)}}}}abortCurrentFrag(){const e=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,e&&(e.abortRequests(),this.fragmentTracker.removeFragment(e)),this.state){case N.KEY_LOADING:case N.FRAG_LOADING:case N.FRAG_LOADING_WAITING_RETRY:case N.PARSING:case N.PARSED:this.state=N.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const r=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new vk(this.config,r,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;Y(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const r=this.getMainFwdBufferInfo();if(r===null||r.len===0){this.warn(`Main forward buffer length on "seeked" event ${r?r.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(v.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let r=!1,s=!1;t.levels.forEach(n=>{const a=n.audioCodec;a&&(r=r||a.indexOf("mp4a.40.2")!==-1,s=s||a.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=r&&s&&!fk(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=t.levels,this.startFragRequested=!1}onLevelLoading(e,t){const{levels:r}=this;if(!r||this.state!==N.IDLE)return;const s=r[t.level];(!s.details||s.details.live&&this.levelLastLoaded!==s||this.waitForCdnTuneIn(s.details))&&(this.state=N.WAITING_LEVEL)}onLevelLoaded(e,t){var r;const{levels:s}=this,n=t.level,a=t.details,o=a.totalduration;if(!s){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const l=s[n],d=this.fragCurrent;d&&(this.state===N.FRAG_LOADING||this.state===N.FRAG_LOADING_WAITING_RETRY)&&d.level!==t.level&&d.loader&&this.abortCurrentFrag();let u=0;if(a.live||(r=l.details)!=null&&r.live){var c;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,l.details,(c=this.levelLastLoaded)==null?void 0:c.details)}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(v.LEVEL_UPDATED,{details:a,level:n}),this.state===N.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=N.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:r,part:s,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${r.sn} of level ${r.level} will not be buffered`);return}const o=a[r.level],l=o.details;if(!l){this.warn(`Dropping fragment ${r.sn} of level ${r.level} after level details were reset`),this.fragmentTracker.removeFragment(r);return}const d=o.videoCodec,u=l.PTSKnown||!l.live,c=(t=r.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new jg(this.hls,ee.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=s?s.index:-1,p=m!==-1,g=new Xh(r.level,r.sn,r.stats.chunkCount,n.byteLength,m,p),E=this.initPTS[r.cc];f.push(n,c,h,d,r,s,l.totalduration,u,g,E)}onAudioTrackSwitching(e,t){const r=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const n=this.hls;r&&(n.trigger(v.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(v.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const r=t.id,s=!!this.hls.audioTracks[r].url;if(s){const n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=s,this.tick()}onBufferCreated(e,t){const r=t.tracks;let s,n,a=!1;for(const o in r){const l=r[o];if(l.id==="main"){if(n=o,s=l,o==="video"){const d=r[o];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&s?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=s.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:r,part:s}=t;if(r&&r.type!==ee.MAIN)return;if(this.fragContextChanged(r)){this.warn(`Fragment ${r.sn}${s?" p: "+s.index:""} of level ${r.level} finished buffering, but was aborted. state: ${this.state}`),this.state===N.PARSED&&(this.state=N.IDLE);return}const n=s?s.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),r.sn!=="initSegment"&&(this.fragPrevious=r),this.fragBufferedComplete(r,s)}onError(e,t){var r;if(t.fatal){this.state=N.ERROR;return}switch(t.details){case D.FRAG_GAP:case D.FRAG_PARSING_ERROR:case D.FRAG_DECRYPT_ERROR:case D.FRAG_LOAD_ERROR:case D.FRAG_LOAD_TIMEOUT:case D.KEY_LOAD_ERROR:case D.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(ee.MAIN,t);break;case D.LEVEL_LOAD_ERROR:case D.LEVEL_LOAD_TIMEOUT:case D.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_LEVEL&&((r=t.context)==null?void 0:r.type)===fe.LEVEL&&(this.state=N.IDLE);break;case D.BUFFER_APPEND_ERROR:case D.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===D.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case D.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!Le.getBuffered(e).length){const r=this.state!==N.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,r)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=N.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==ye.AUDIO||this.audioOnly&&!this.altAudio){const r=(t===ye.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(r,t,ee.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=t.levels}swapAudioCodec(){this.audioCodecSwap=!this.audioCodecSwap}seekToStartPos(){const{media:e}=this;if(!e)return;const t=e.currentTime;let r=this.startPosition;if(r>=0&&t<r){if(e.seeking){this.log(`could not seek to ${r}, already seeking at ${t}`);return}const s=Le.getBuffered(e),a=(s.length?s.start(0):0)-r;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),r+=a,this.startPosition=r),this.log(`seek to target start position ${r} from current time ${t}`),e.currentTime=r}}_getAudioCodec(e){let t=this.config.defaultAudioCodec||e.audioCodec;return this.audioCodecSwap&&t&&(this.log("Swapping audio codec"),t.indexOf("mp4a.40.5")!==-1?t="mp4a.40.2":t="mp4a.40.5"),t}_loadBitrateTestFrag(e,t){e.bitrateTest=!0,this._doFragLoad(e,t).then(r=>{const{hls:s}=this;if(!r||this.fragContextChanged(e))return;t.fragmentError=0,this.state=N.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),s.trigger(v.FRAG_LOADED,r),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const r="main",{hls:s}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:d,level:u}=o,{video:c,text:h,id3:f,initSegment:m}=n,{details:p}=u,g=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,m){if(m!=null&&m.tracks){const b=l.initSegment||l;this._bufferInitSegment(u,m.tracks,b,a),s.trigger(v.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:r,tracks:m.tracks})}const E=m.initPTS,y=m.timescale;Y(E)&&(this.initPTS[l.cc]={baseTime:E,timescale:y},s.trigger(v.INIT_PTS_FOUND,{frag:l,id:r,initPTS:E,timescale:y}))}if(c&&p&&l.sn!=="initSegment"){const E=p.fragments[l.sn-1-p.startSN],y=l.sn===p.startSN,b=!E||l.cc>E.cc;if(n.independent!==!1){const{startPTS:S,endPTS:_,startDTS:x,endDTS:A}=c;if(d)d.elementaryStreams[c.type]={startPTS:S,endPTS:_,startDTS:x,endDTS:A};else if(c.firstKeyFrame&&c.independent&&a.id===1&&!b&&(this.couldBacktrack=!0),c.dropped&&c.independent){const C=this.getMainFwdBufferInfo(),O=(C?C.end:this.getLoadPosition())+this.config.maxBufferHole,L=c.firstKeyFramePTS?c.firstKeyFramePTS:S;if(!y&&O<L-this.config.maxBufferHole&&!b){this.backtrack(l);return}else b&&(l.gap=!0);l.setElementaryStreamInfo(c.type,l.start,_,l.start,A,!0)}else y&&S>No&&(l.gap=!0);l.setElementaryStreamInfo(c.type,S,_,x,A),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(c,l,d,a,y||b)}else if(y||b)l.gap=!0;else{this.backtrack(l);return}}if(g){const{startPTS:E,endPTS:y,startDTS:b,endDTS:S}=g;d&&(d.elementaryStreams[ye.AUDIO]={startPTS:E,endPTS:y,startDTS:b,endDTS:S}),l.setElementaryStreamInfo(ye.AUDIO,E,y,b,S),this.bufferFragmentData(g,l,d,a)}if(p&&f!=null&&(t=f.samples)!=null&&t.length){const E={id:r,frag:l,details:p,samples:f.samples};s.trigger(v.FRAG_PARSING_METADATA,E)}if(p&&h){const E={id:r,frag:l,details:p,samples:h.samples};s.trigger(v.FRAG_PARSING_USERDATA,E)}}_bufferInitSegment(e,t,r,s){if(this.state!==N.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec;const d=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5");const u=n.metadata;u&&"channelCount"in u&&(u.channelCount||1)!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")}l&&l.indexOf("mp4a.40.5")!==-1&&d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(v.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{const u=t[l].initSegment;u!=null&&u.byteLength&&this.hls.trigger(v.BUFFER_APPENDING,{type:l,data:u,frag:r,part:null,chunkMeta:s,parent:r.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,ee.MAIN)}backtrack(e){this.couldBacktrack=!0,this.backtrackFragment=e,this.resetTransmuxer(),this.flushBufferGap(e),this.fragmentTracker.removeFragment(e),this.fragPrevious=null,this.nextLoadPosition=e.start,this.state=N.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const r=e.currentTime;if(Le.isBuffered(e,r)?t=this.getAppendedFrag(r):Le.isBuffered(e,r+.1)&&(t=this.getAppendedFrag(r+.1)),t){this.backtrackFragment=null;const s=this.fragPlaying,n=t.level;(!s||t.sn!==s.sn||s.level!==n)&&(this.fragPlaying=t,this.hls.trigger(v.FRAG_CHANGED,{frag:t}),(!s||s.level!==n)&&this.hls.trigger(v.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,r=this.currentFrag;if(r&&Y(t)&&Y(r.programDateTime)){const s=r.programDateTime+(t-r.start)*1e3;return new Date(s)}}return null}get currentLevel(){const e=this.currentFrag;return e?e.level:-1}get nextBufferedFrag(){const e=this.currentFrag;return e?this.followingBufferedFrag(e):null}get forceStartLoad(){return this._forceStartLoad}}class Xr{static get version(){return"1.5.15"}static isMSESupported(){return mv()}static isSupported(){return hk()}static getMediaSource(){return ds()}static get Events(){return v}static get ErrorTypes(){return ie}static get ErrorDetails(){return D}static get DefaultConfig(){return Xr.defaultConfig?Xr.defaultConfig:hv}static set DefaultConfig(e){Xr.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new sf,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.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,o1(e.debug||!1,"Hls instance");const t=this.config=lk(Xr.DefaultConfig,e);this.userConfig=e,t.progressive&&dk(t);const{abrController:r,bufferController:s,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new r(this),u=this.bufferController=new s(this),c=this.capLevelController=new n(this),h=new o(this),f=new tA(this),m=new aA(this),p=t.contentSteeringController,g=p?new p(this):null,E=this.levelController=new uk(this,g),y=new OA(this),b=new ck(this.config),S=this.streamController=new yk(this,y,b);c.setStreamController(S),h.setStreamController(S);const _=[f,E,S];g&&_.splice(1,0,g),this.networkControllers=_;const x=[d,u,c,h,m,y];this.audioTrackController=this.createController(t.audioTrackController,_);const A=t.audioStreamController;A&&_.push(new A(this,y,b)),this.subtitleTrackController=this.createController(t.subtitleTrackController,_);const C=t.subtitleStreamController;C&&_.push(new C(this,y,b)),this.createController(t.timelineController,x),b.emeController=this.emeController=this.createController(t.emeController,x),this.cmcdController=this.createController(t.cmcdController,x),this.latencyController=this.createController(oA,x),this.coreComponents=x,_.push(l);const O=l.onErrorOut;typeof O=="function"&&this.on(v.ERROR,O,l)}createController(e,t){if(e){const r=new e(this);return t&&t.push(r),r}return null}on(e,t,r=this){this._emitter.on(e,t,r)}once(e,t,r=this){this._emitter.once(e,t,r)}removeAllListeners(e){this._emitter.removeAllListeners(e)}off(e,t,r=this,s){this._emitter.off(e,t,r,s)}listeners(e){return this._emitter.listeners(e)}emit(e,t,r){return this._emitter.emit(e,t,r)}trigger(e,t){if(this.config.debug)return this.emit(e,e,t);try{return this.emit(e,e,t)}catch(r){if(I.error("An internal error happened while handling event "+e+'. Error message: "'+r.message+'". Here is a stacktrace:',r),!this.triggeringException){this.triggeringException=!0;const s=e===v.ERROR;this.trigger(v.ERROR,{type:ie.OTHER_ERROR,details:D.INTERNAL_EXCEPTION,fatal:s,event:e,error:r}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){I.log("destroy"),this.trigger(v.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 e=this.config;e.xhrSetup=e.fetchSetup=void 0,this.userConfig=null}attachMedia(e){I.log("attachMedia"),this._media=e,this.trigger(v.MEDIA_ATTACHING,{media:e})}detachMedia(){I.log("detachMedia"),this.trigger(v.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,r=this.url,s=this.url=Kh.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,I.log(`loadSource:${s}`),t&&r&&(r!==s||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(v.MANIFEST_LOADING,{url:e})}startLoad(e=-1){I.log(`startLoad(${e})`),this.started=!0,this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){I.log("stopLoad"),this.started=!1,this.networkControllers.forEach(e=>{e.stopLoad()})}resumeBuffering(){this.started&&this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.startLoad(-1)})}pauseBuffering(){this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.stopLoad()})}swapAudioCodec(){I.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){I.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){I.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){I.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){I.log(`set loadLevel:${e}`),this.levelController.manualLevel=e}get nextLoadLevel(){return this.levelController.nextLoadLevel}set nextLoadLevel(e){this.levelController.nextLoadLevel=e}get firstLevel(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)}set firstLevel(e){I.log(`set firstLevel:${e}`),this.levelController.firstLevel=e}get startLevel(){const e=this.levelController.startLevel;return e===-1&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:e}set startLevel(e){I.log(`set startLevel:${e}`),e!==-1&&(e=Math.max(e,this.minAutoLevel)),this.levelController.startLevel=e}get capLevelToPlayerSize(){return this.config.capLevelToPlayerSize}set capLevelToPlayerSize(e){const t=!!e;t!==this.config.capLevelToPlayerSize&&(t?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=t)}get autoLevelCapping(){return this._autoLevelCapping}get bandwidthEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimate():NaN}set bandwidthEstimate(e){this.abrController.resetEstimator(e)}get ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(I.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){lA(e)&&this._maxHdcpLevel!==e&&(this._maxHdcpLevel=e,this.levelController.checkMaxAutoUpdated())}get autoLevelEnabled(){return this.levelController.manualLevel===-1}get manualLevel(){return this.levelController.manualLevel}get minAutoLevel(){const{levels:e,config:{minAutoBitrate:t}}=this;if(!e)return 0;const r=e.length;for(let s=0;s<r;s++)if(e[s].maxBitrate>=t)return s;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:r}=this;let s;if(t===-1&&e!=null&&e.length?s=e.length-1:s=t,r)for(let n=s;n--;){const a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=r)return n}return s}get firstAutoLevel(){return this.abrController.firstAutoLevel}get nextAutoLevel(){return this.abrController.nextAutoLevel}set nextAutoLevel(e){this.abrController.nextAutoLevel=e}get playingDate(){return this.streamController.currentProgramDateTime}get mainForwardBufferInfo(){return this.streamController.getMainFwdBufferInfo()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||t.setSubtitleOption(e),null}get allAudioTracks(){const e=this.audioTrackController;return e?e.allAudioTracks:[]}get audioTracks(){const e=this.audioTrackController;return e?e.audioTracks:[]}get audioTrack(){const e=this.audioTrackController;return e?e.audioTrack:-1}set audioTrack(e){const t=this.audioTrackController;t&&(t.audioTrack=e)}get allSubtitleTracks(){const e=this.subtitleTrackController;return e?e.allSubtitleTracks:[]}get subtitleTracks(){const e=this.subtitleTrackController;return e?e.subtitleTracks:[]}get subtitleTrack(){const e=this.subtitleTrackController;return e?e.subtitleTrack:-1}get media(){return this._media}set subtitleTrack(e){const t=this.subtitleTrackController;t&&(t.subtitleTrack=e)}get subtitleDisplay(){const e=this.subtitleTrackController;return e?e.subtitleDisplay:!1}set subtitleDisplay(e){const t=this.subtitleTrackController;t&&(t.subtitleDisplay=e)}get lowLatencyMode(){return this.config.lowLatencyMode}set lowLatencyMode(e){this.config.lowLatencyMode=e}get liveSyncPosition(){return this.latencyController.liveSyncPosition}get latency(){return this.latencyController.latency}get maxLatency(){return this.latencyController.maxLatency}get targetLatency(){return this.latencyController.targetLatency}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}Xr.defaultConfig=void 0;var Oe=Xr,Qi=class Kn extends Error{constructor(e,t=Kn.MEDIA_ERR_CUSTOM,r,s){var n;super(e),this.name="MediaError",this.code=t,this.context=s,this.fatal=r??(t>=Kn.MEDIA_ERR_NETWORK&&t<=Kn.MEDIA_ERR_ENCRYPTED),this.message||(this.message=(n=Kn.defaultMessages[this.code])!=null?n:"")}};Qi.MEDIA_ERR_ABORTED=1,Qi.MEDIA_ERR_NETWORK=2,Qi.MEDIA_ERR_DECODE=3,Qi.MEDIA_ERR_SRC_NOT_SUPPORTED=4,Qi.MEDIA_ERR_ENCRYPTED=5,Qi.MEDIA_ERR_CUSTOM=100,Qi.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var St=Qi,bk=i=>i==null,pv=(i,e)=>bk(e)?!1:i in e,lc={ANY:"any",MUTED:"muted"},be={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},Ti={MSE:"mse",NATIVE:"native"},Fo={HEADER:"header",QUERY:"query",NONE:"none"},nd=Object.values(Fo),vr={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},yp={HLS:vr.M3U8};[...Object.values(vr)];var lo={upTo720p:"720p",upTo1080p:"1080p",upTo1440p:"1440p",upTo2160p:"2160p"},_s={noLessThan480p:"480p",noLessThan540p:"540p",noLessThan720p:"720p",noLessThan1080p:"1080p",noLessThan1440p:"1440p",noLessThan2160p:"2160p"},qe=(i,e,t,r,s=i)=>{s.addEventListener(e,t,r),i.addEventListener("teardown",()=>{s.removeEventListener(e,t)},{once:!0})};function Tk(i,e,t){e&&t>e&&(t=e);for(let r=0;r<i.length;r++)if(i.start(r)<=t&&i.end(r)>=t)return!0;return!1}var _k=i=>{let e=i.indexOf("?");if(e<0)return[i];let t=i.slice(0,e),r=i.slice(e);return[t,r]},Dd=i=>{let e=i.type;if(e){let r=e.toUpperCase();return pv(r,yp)?yp[r]:e}let{src:t}=i;return t?Ak(t):""},gv=i=>i==="VOD"?be.ON_DEMAND:be.LIVE,vv=i=>i==="EVENT"?Number.POSITIVE_INFINITY:i==="VOD"?Number.NaN:0,Ak=i=>{let e="";try{e=new URL(i).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let r=e.slice(t+1).toUpperCase();return pv(r,vr)?vr[r]:""},Sk=Object.values(lc),bp=i=>typeof i=="boolean"||typeof i=="string"&&Sk.includes(i),xk=(i,e,t)=>{let{autoplay:r}=i,s=!1,n=!1,a=bp(r)?r:!!r,o=()=>{s||qe(e,"playing",()=>{s=!0},{once:!0})};if(o(),qe(e,"loadstart",()=>{s=!1,o(),bu(e,a)},{once:!0}),qe(e,"loadstart",()=>{t||(i.streamType&&i.streamType!==be.UNKNOWN?n=i.streamType===be.LIVE:n=!Number.isFinite(e.duration)),bu(e,a)},{once:!0}),t&&t.once(Oe.Events.LEVEL_LOADED,(l,d)=>{var u;i.streamType&&i.streamType!==be.UNKNOWN?n=i.streamType===be.LIVE:n=(u=d.details.live)!=null?u:!1}),!a){let l=()=>{!n||Number.isFinite(i.startTime)||(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&qe(e,"play",()=>{e.preload==="metadata"?t.once(Oe.Events.LEVEL_UPDATED,l):l()},{once:!0})}return l=>{s||(a=bp(l)?l:!!l,bu(e,a))}},bu=(i,e)=>{if(!e)return;let t=i.muted,r=()=>i.muted=t;switch(e){case lc.ANY:i.play().catch(()=>{i.muted=!0,i.play().catch(r)});break;case lc.MUTED:i.muted=!0,i.play().catch(r);break;default:i.play().catch(()=>{});break}},kk=({preload:i,src:e},t,r)=>{let s=c=>{c!=null&&["","none","metadata","auto"].includes(c)?t.setAttribute("preload",c):t.removeAttribute("preload")};if(!r)return s(i),s;let n=!1,a=!1,o=r.config.maxBufferLength,l=r.config.maxBufferSize,d=c=>{s(c);let h=c??t.preload;a||h==="none"||(h==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=o,r.config.maxBufferSize=l),u())},u=()=>{!n&&e&&(n=!0,r.loadSource(e))};return qe(t,"play",()=>{a=!0,r.config.maxBufferLength=o,r.config.maxBufferSize=l,u()},{once:!0}),d(i),d};function Lk(i,e){var t;if(!("videoTracks"in i))return;let r=new WeakMap;e.on(Oe.Events.MANIFEST_PARSED,function(d,u){l();let c=i.addVideoTrack("main");c.selected=!0;for(let[h,f]of u.levels.entries()){let m=c.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);r.set(f,`${h}`),m.id=`${h}`}}),e.on(Oe.Events.AUDIO_TRACKS_UPDATED,function(d,u){o();for(let c of u.audioTracks){let h=c.default?"main":"alternative",f=i.addAudioTrack(h,c.name,c.lang);f.id=`${c.id}`,c.default&&(f.enabled=!0)}}),i.audioTracks.addEventListener("change",()=>{var d;let u=+((d=[...i.audioTracks].find(h=>h.enabled))==null?void 0:d.id),c=e.audioTracks.map(h=>h.id);u!=e.audioTrack&&c.includes(u)&&(e.audioTrack=u)}),e.on(Oe.Events.LEVELS_UPDATED,function(d,u){var c;let h=i.videoTracks[(c=i.videoTracks.selectedIndex)!=null?c:0];if(!h)return;let f=u.levels.map(m=>r.get(m));for(let m of i.videoRenditions)m.id&&!f.includes(m.id)&&h.removeRendition(m)});let s=d=>{let u=d.target.selectedIndex;u!=e.nextLevel&&n(u)},n=d=>{let u=i.currentTime,c=!1,h=(f,m)=>{c||(c=!Number.isFinite(m.endOffset))};e.on(Oe.Events.BUFFER_FLUSHING,h),e.nextLevel=d,e.off(Oe.Events.BUFFER_FLUSHING,h),c||e.trigger(Oe.Events.BUFFER_FLUSHING,{startOffset:u+10,endOffset:1/0,type:"video"})};(t=i.videoRenditions)==null||t.addEventListener("change",s);let a=()=>{for(let d of i.videoTracks)i.removeVideoTrack(d)},o=()=>{for(let d of i.audioTracks)i.removeAudioTrack(d)},l=()=>{a(),o()};e.once(Oe.Events.DESTROYING,l)}var Tu=i=>"time"in i?i.time:i.startTime;function Ik(i,e){e.on(Oe.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(s,{tracks:n})=>{n.forEach(a=>{var o;let l=(o=a.subtitleTrack)!=null?o:a.closedCaptions,d=e.subtitleTracks.findIndex(({lang:u,name:c,type:h})=>u==(l==null?void 0:l.lang)&&c===a.label&&h.toLowerCase()===a.kind);df(i,a.kind,a.label,l==null?void 0:l.lang,`${a.kind}${d}`)})});let t=()=>{var s;if(!e.subtitleTracks.length)return;let n=Array.from(i.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind)),a=`${(s=e.subtitleTracks[e.subtitleTrack])==null?void 0:s.type.toLowerCase()}${e.subtitleTrack}`;if(n&&(e.subtitleTrack<0||(n==null?void 0:n.id)!==a)){let o=e.subtitleTracks.findIndex(({lang:l,name:d,type:u})=>l==n.language&&d===n.label&&u.toLowerCase()===n.kind);e.subtitleTrack=o}n&&(n==null?void 0:n.id)===a&&n.cues&&Array.from(n.cues).forEach(o=>{n.addCue(o)})};i.textTracks.addEventListener("change",t),e.on(Oe.Events.CUES_PARSED,(s,{track:n,cues:a})=>{let o=i.textTracks.getTrackById(n);if(!o)return;let l=o.mode==="disabled";l&&(o.mode="hidden"),a.forEach(d=>{var u;(u=o.cues)!=null&&u.getCueById(d.id)||o.addCue(d)}),l&&(o.mode="disabled")}),e.once(Oe.Events.DESTROYING,()=>{i.textTracks.removeEventListener("change",t),i.querySelectorAll("track[data-removeondestroy]").forEach(s=>{s.remove()})});let r=()=>{Array.from(i.textTracks).forEach(s=>{var n,a;if(!["subtitles","caption"].includes(s.kind)&&s.label==="thumbnails"){if(!((n=s.cues)!=null&&n.length)){let o=i.querySelector('track[label="thumbnails"]'),l=(a=o==null?void 0:o.getAttribute("src"))!=null?a:"";o==null||o.removeAttribute("src"),setTimeout(()=>{o==null||o.setAttribute("src",l)},0)}s.mode!=="hidden"&&(s.mode="hidden")}})};e.once(Oe.Events.MANIFEST_LOADED,r),e.once(Oe.Events.MEDIA_ATTACHED,r)}function df(i,e,t,r,s){let n=document.createElement("track");return n.kind=e,n.label=t,r&&(n.srclang=r),s&&(n.id=s),n.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",n.setAttribute("data-removeondestroy",""),i.append(n),n.track}function Rk(i,e){let t=Array.prototype.find.call(i.querySelectorAll("track"),r=>r.track===e);t==null||t.remove()}function Ya(i,e,t){var r;return(r=Array.from(i.querySelectorAll("track")).find(s=>s.track.label===e&&s.track.kind===t))==null?void 0:r.track}async function Ev(i,e,t,r){let s=Ya(i,t,r);return s||(s=df(i,r,t),s.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))),s.mode!=="hidden"&&(s.mode="hidden"),[...e].sort((n,a)=>Tu(a)-Tu(n)).forEach(n=>{var a,o;let l=n.value,d=Tu(n);if("endTime"in n&&n.endTime!=null)s==null||s.addCue(new VTTCue(d,n.endTime,r==="chapters"?l:JSON.stringify(l??null)));else{let u=Array.prototype.findIndex.call(s==null?void 0:s.cues,m=>m.startTime>=d),c=(a=s==null?void 0:s.cues)==null?void 0:a[u],h=c?c.startTime:Number.isFinite(i.duration)?i.duration:Number.MAX_SAFE_INTEGER,f=(o=s==null?void 0:s.cues)==null?void 0:o[u-1];f&&(f.endTime=d),s==null||s.addCue(new VTTCue(d,h,r==="chapters"?l:JSON.stringify(l??null)))}}),i.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),s}var uf="cuepoints",yv=Object.freeze({label:uf});async function bv(i,e,t=yv){return Ev(i,e,t.label,"metadata")}var dc=i=>({time:i.startTime,value:JSON.parse(i.text)});function wk(i,e={label:uf}){let t=Ya(i,e.label,"metadata");return t!=null&&t.cues?Array.from(t.cues,r=>dc(r)):[]}function Tv(i,e={label:uf}){var t,r;let s=Ya(i,e.label,"metadata");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return dc(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return dc(a||s.activeCues[0])}async function Ck(i,e=yv){return new Promise(t=>{qe(i,"loadstart",async()=>{let r=await bv(i,[],e);qe(i,"cuechange",()=>{let s=Tv(i);if(s){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}var cf="chapters",_v=Object.freeze({label:cf}),uc=i=>({startTime:i.startTime,endTime:i.endTime,value:i.text});async function Av(i,e,t=_v){return Ev(i,e,t.label,"chapters")}function Dk(i,e={label:cf}){var t;let r=Ya(i,e.label,"chapters");return(t=r==null?void 0:r.cues)!=null&&t.length?Array.from(r.cues,s=>uc(s)):[]}function Sv(i,e={label:cf}){var t,r;let s=Ya(i,e.label,"chapters");if(!((t=s==null?void 0:s.activeCues)!=null&&t.length))return;if(s.activeCues.length===1)return uc(s.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((r=s.activeCues)!=null?r:[],({startTime:o,endTime:l})=>o<=n&&l>n);return uc(a||s.activeCues[0])}async function Mk(i,e=_v){return new Promise(t=>{qe(i,"loadstart",async()=>{let r=await Av(i,[],e);qe(i,"cuechange",()=>{let s=Sv(i);if(s){let n=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:s});i.dispatchEvent(n)}},{},r),t(r)})})}function Pk(i,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-i.currentTime*1e3)}return typeof i.getStartDate=="function"?i.getStartDate():new Date(NaN)}function Ok(i,e){if(e&&e.playingDate)return e.playingDate;if(typeof i.getStartDate=="function"){let t=i.getStartDate();return new Date(t.getTime()+i.currentTime*1e3)}return new Date(NaN)}var Uo={FAIRPLAY:"fairplay",PLAYREADY:"playready",WIDEVINE:"widevine"},Nk=i=>{if(i.includes("fps"))return Uo.FAIRPLAY;if(i.includes("playready"))return Uo.PLAYREADY;if(i.includes("widevine"))return Uo.WIDEVINE},Fk=async i=>fetch(i).then(e=>e.text()).then(e=>{let t=e.split(`
48
48
  `).find((r,s,n)=>s&&n[s-1].startsWith("#EXT-X-STREAM-INF"));return fetch(t).then(r=>r.text()).then(r=>r.split(`
49
- `))}),Nk=i=>{var e,t,r;let s=(t=((e=i.find(l=>l.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),n=mv(s),a=pv(s),o;if(n===be.LIVE){let l=i.find(d=>d.startsWith("#EXT-X-PART-INF"));if(l)o=+l.split(":")[1].split("=")[1]*2;else{let d=i.find(c=>c.startsWith("#EXT-X-TARGETDURATION")),u=(r=d==null?void 0:d.split(":"))==null?void 0:r[1];o=+(u??6)*3}}return{streamType:n,targetLiveWindow:a,liveEdgeStartOffset:o}},Fk=async(i,e)=>{if(e===vr.MP4)return{streamType:be.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===vr.M3U8){let t=await Ok(i);return Nk(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},bu=async(i,e,t=wd({src:i}))=>{var r,s,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await Fk(i,t);((r=mt.get(e))!=null?r:{}).liveEdgeStartOffset=l,((s=mt.get(e))!=null?s:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=mt.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},Uk=i=>{var e;let t=i.type,r=mv(t),s=pv(t),n,a=!!((e=i.partList)!=null&&e.length);return r===be.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:r,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},$k=(i,e,t)=>{var r,s,n,a,o,l,d,u;let{streamType:c,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:m}=Uk(i);if(c===be.LIVE){m?(t.config.backBufferLength=(r=t.userConfig.backBufferLength)!=null?r:4,t.config.maxFragLookUpTolerance=(s=t.userConfig.maxFragLookUpTolerance)!=null?s:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let p=Object.freeze({get length(){return e.seekable.length},start(g){return e.seekable.start(g)},end(g){var E;return g>this.length||g<0||Number.isFinite(e.duration)?e.seekable.end(g):(E=t.liveSyncPosition)!=null?E:e.seekable.end(g)}});((o=mt.get(e))!=null?o:{}).seekable=p}((l=mt.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=mt.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((u=mt.get(e))!=null?u:{}).streamType=c,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},yp,bp,Bk=(bp=(yp=globalThis==null?void 0:globalThis.navigator)==null?void 0:yp.userAgent)!=null?bp:"",Tp,_p,Ap,Gk=(Ap=(_p=(Tp=globalThis==null?void 0:globalThis.navigator)==null?void 0:Tp.userAgentData)==null?void 0:_p.platform)!=null?Ap:"",Hk=Bk.toLowerCase().includes("android")||["x11","android"].some(i=>Gk.toLowerCase().includes(i)),mt=new WeakMap,pr="mux.com",Sp,xp,Av=(xp=(Sp=Oe).isSupported)==null?void 0:xp.call(Sp),Wk=Hk,Kk=()=>Gh.utils.now(),Vk=Gh.utils.generateUUID,dc=({playbackId:i,customDomain:e=pr,maxResolution:t,minResolution:r,renditionOrder:s,programStartTime:n,programEndTime:a,tokens:{playback:o}={},extraSourceParams:l={}}={})=>{if(!i)return;let[d,u=""]=bk(i),c=new URL(`https://stream.${e}/${d}.m3u8${u}`);return o||c.searchParams.has("token")?(c.searchParams.forEach((h,f)=>{f!="token"&&c.searchParams.delete(f)}),o&&c.searchParams.set("token",o)):(t&&c.searchParams.set("max_resolution",t),r&&(c.searchParams.set("min_resolution",r),t&&+t.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",t)),s&&c.searchParams.set("rendition_order",s),n&&c.searchParams.set("program_start_time",`${n}`),a&&c.searchParams.set("program_end_time",`${a}`),Object.entries(l).forEach(([h,f])=>{f!=null&&c.searchParams.set(h,f)})),c.toString()},qk=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},uf=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(".m3u8");return e||void 0},Yk=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:wv(i)&&(r=(t=qk(i.playbackId))!=null?t:uf(i.src))!=null?r:i.src},jk=i=>{var e;return(e=mt.get(i))==null?void 0:e.error},uc=i=>{var e,t;return(t=(e=mt.get(i))==null?void 0:e.streamType)!=null?t:be.UNKNOWN},zk=i=>{var e,t;return(t=(e=mt.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},sd=i=>{var e,t;return(t=(e=mt.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},Xk=i=>{var e;let t=(e=mt.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=sd(i);return r.length?r.end(r.length-1)-t:Number.NaN},cf=.034,Qk=(i,e,t=cf)=>Math.abs(i-e)<=t,Sv=(i,e,t=cf)=>i>e||Qk(i,e,t),Zk=(i,e=cf)=>i.paused&&Sv(i.currentTime,i.duration,e),xv=(i,e)=>{var t,r,s;if(!e||!i.buffered.length)return;if(i.readyState>2)return!1;let n=e.currentLevel>=0?(r=(t=e.levels)==null?void 0:t[e.currentLevel])==null?void 0:r.details:(s=e.levels.find(c=>!!c.details))==null?void 0:s.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(i.currentTime<i.duration-(n.targetduration+.5))return!1;let o=a[a.length-1];if(i.currentTime<=o.start)return!1;let l=o.start+o.duration/2,d=i.buffered.start(i.buffered.length-1),u=i.buffered.end(i.buffered.length-1);return l>d&&l<u},kv=(i,e)=>i.ended||i.loop?i.ended:e&&xv(i,e)?!0:Zk(i),Jk=(i,e,t)=>{Lv(e,t);let{metadata:r={}}=i,{view_session_id:s=Vk()}=r,n=Yk(i);r.view_session_id=s,r.video_id=n,i.metadata=r;let a=u=>{var c;(c=e.mux)==null||c.emit("hb",{view_drm_type:u})};i.drmTypeCb=a,mt.set(e,{});let o=eL(i,e),l=Sk(i,e,o);aL(i,e,o),oL(i,e,o),Rk(e),Ck(e);let d=Ak(i,e,o);return{engine:o,setAutoplay:d,setPreload:l}},Lv=(i,e)=>{let t=e==null?void 0:e.engine;t&&(t.detachMedia(),t.destroy()),i!=null&&i.mux&&!i.mux.deleted&&(i.mux.destroy(),delete i.mux),i&&(i.removeAttribute("src"),i.load(),i.removeEventListener("error",Dv),i.removeEventListener("error",cc),i.removeEventListener("durationchange",Cv),mt.delete(i),i.dispatchEvent(new Event("teardown")))};function Iv(i,e){var t;let r=wd(i);if(r!==vr.M3U8)return!0;let s=!r||((t=e.canPlayType(r))!=null?t:!0),{preferPlayback:n}=i,a=n===Ti.MSE,o=n===Ti.NATIVE;return s&&(o||!(Av&&(a||Wk)))}var eL=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=wd(i)===vr.M3U8,d=Iv(i,e);if(l&&!d&&Av){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=tL(r),h=iL(i),f=a!==Oo.NONE?{useHeaders:a===Oo.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0;return new Oe({debug:t,startPosition:s,cmcd:f,xhrSetup:(m,p)=>{var g,E;if(a&&a!==Oo.QUERY)return;let y=new URL(p);if(!y.searchParams.has("CMCD"))return;let b=((E=(g=y.searchParams.get("CMCD"))==null?void 0:g.split(","))!=null?E:[]).filter(S=>S.startsWith("sid")||S.startsWith("cid")).join(",");y.searchParams.set("CMCD",b),m.open("GET",y)},...u,...c,...h,...o})}},tL=i=>i===be.LIVE?{backBufferLength:8}:{},iL=i=>{let{drmToken:e,src:t,playbackId:r=uf(t),drmTypeCb:s}=i;return!e||!r?{}:{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:Fo(i,"fairplay"),serverCertificateUrl:Rv(i,"fairplay")},"com.widevine.alpha":{licenseUrl:Fo(i,"widevine")},"com.microsoft.playready":{licenseUrl:Fo(i,"playready")}},requestMediaKeySystemAccessFunc:(n,a)=>(n==="com.widevine.alpha"&&(a=[...a.map(o=>{var l;let d=(l=o.videoCapabilities)==null?void 0:l.map(u=>({...u,robustness:"HW_SECURE_ALL"}));return{...o,videoCapabilities:d}}),...a]),navigator.requestMediaKeySystemAccess(n,a).then(o=>{let l=Pk(n);return s==null||s(l),o}))}},rL=async i=>await(await fetch(i)).arrayBuffer(),sL=async(i,e)=>{let t=await(await fetch(e,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:i})).arrayBuffer();return new Uint8Array(t)},nL=(i,e)=>{qe(e,"encrypted",async t=>{try{let r=t.initDataType;if(r!=="skd"){console.error(`Received unexpected initialization data type "${r}"`);return}if(!e.mediaKeys){let l=await(await navigator.requestMediaKeySystemAccess("com.apple.fps",[{initDataTypes:[r],videoCapabilities:[{contentType:"application/vnd.apple.mpegurl",robustness:""}],distinctiveIdentifier:"not-allowed",persistentState:"not-allowed",sessionTypes:["temporary"]}]).then(u=>{var c;return(c=i.drmTypeCb)==null||c.call(i,No.FAIRPLAY),u})).createMediaKeys(),d=await rL(Rv(i,"fairplay"));await l.setServerCertificate(d),await e.setMediaKeys(l)}let s=t.initData;if(s==null){console.error(`Could not start encrypted playback due to missing initData in ${t.type} event`);return}let n=e.mediaKeys.createSession();n.generateRequest(r,s);let a=await new Promise(l=>{n.addEventListener("message",d=>{l(d.message)},{once:!0})}),o=await sL(a,Fo(i,"fairplay"));return await n.update(o),n}catch(r){console.error(`Could not start encrypted playback due to exception "${r}"`)}})},Fo=({playbackId:i,drmToken:e,customDomain:t=pr},r)=>`https://license.${t.toLocaleLowerCase().endsWith(pr)?t:pr}/license/${r}/${i}?token=${e}`,Rv=({playbackId:i,drmToken:e,customDomain:t=pr},r)=>`https://license.${t.toLocaleLowerCase().endsWith(pr)?t:pr}/appcert/${r}/${i}?token=${e}`,wv=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let r=window==null?void 0:window.location.href,s=new URL(e,r).hostname.toLocaleLowerCase();return s.includes(pr)||!!t&&s.includes(t.toLocaleLowerCase())},aL=(i,e,t)=>{var r;let{envKey:s,disableTracking:n}=i,a=wv(i);if(!n&&(s||a)){let{playerInitTime:o,playerSoftwareName:l,playerSoftwareVersion:d,beaconCollectionDomain:u,debug:c,disableCookies:h}=i,f={...i.metadata,video_title:((r=i==null?void 0:i.metadata)==null?void 0:r.video_title)||void 0},m=p=>typeof p.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(p):p;Gh.monitor(e,{debug:c,beaconCollectionDomain:u,hlsjs:t,Hls:t?Oe:void 0,automaticErrorTracking:!1,errorTranslator:m,disableCookies:h,data:{...s?{env_key:s}:{},player_software_name:l,player_software:l,player_software_version:d,player_init_time:o,...f}})}},oL=(i,e,t)=>{var r;let s=Iv(i,e),{src:n}=i,a=()=>{e.ended||!kv(e,t)||(xv(e,t)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},o,l,d=()=>{var u,c;let h=(u=sd(e))==null?void 0:u.start(0),f=(c=sd(e))==null?void 0:c.end(0);(l!==f||o!==h)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),o=h,l=f};if(qe(e,"durationchange",d),e&&s){let u=wd(i);if(typeof n=="string"){let c=()=>{if(uc(e)!==be.LIVE||Number.isFinite(e.duration))return;let h=setInterval(d,1e3);e.addEventListener("teardown",()=>{clearInterval(h)},{once:!0}),qe(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(h)})};if(e.preload==="none"){let h=()=>{bu(n,e,u).then(c),e.removeEventListener("loadedmetadata",f)},f=()=>{bu(n,e,u).then(c),e.removeEventListener("play",h)};qe(e,"play",h,{once:!0}),qe(e,"loadedmetadata",f,{once:!0})}else bu(n,e,u).then(c);i.drmToken&&nL(i,e),e.setAttribute("src",n),i.startTime&&(((r=mt.get(e))!=null?r:{}).startTime=i.startTime,e.addEventListener("durationchange",Cv,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",Dv),e.addEventListener("error",cc),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(c=>{c.remove()})},{once:!0}),qe(e,"pause",a),qe(e,"seeked",a),qe(e,"play",()=>{e.ended||Sv(e.currentTime,e.duration)&&(e.currentTime=e.seekable.length?e.seekable.start(0):0)})}else t&&n?(t.once(Oe.Events.LEVEL_LOADED,(u,c)=>{$k(c.details,e,t),d(),uc(e)===be.LIVE&&!Number.isFinite(e.duration)&&(t.on(Oe.Events.LEVEL_UPDATED,d),qe(e,"durationchange",()=>{Number.isFinite(e.duration)&&t.off(Oe.Events.LEVELS_UPDATED,d)}))}),t.on(Oe.Events.ERROR,(u,c)=>{let h={[Oe.ErrorTypes.NETWORK_ERROR]:St.MEDIA_ERR_NETWORK,[Oe.ErrorTypes.MEDIA_ERROR]:St.MEDIA_ERR_DECODE},f=new St("",h[c.type]);f.fatal=c.fatal,f.data=c,e.dispatchEvent(new CustomEvent("error",{detail:f}))}),e.addEventListener("error",cc),qe(e,"waiting",a),xk(i,t),kk(e,t),t.attachMedia(e)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function Cv(i){var e;let t=i.target,r=(e=mt.get(t))==null?void 0:e.startTime;if(r&&yk(t.seekable,t.duration,r)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=r,s&&(t.preload="auto")}}async function Dv(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:r}=e.error,s=new St(t,r);if(e.src&&(r!==St.MEDIA_ERR_DECODE||r!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}e.dispatchEvent(new CustomEvent("error",{detail:s}))}function cc(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof St))return;let r=i.target,s=i.detail;!s||!s.fatal||(((e=mt.get(r))!=null?e:{}).error=s,(t=r.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}const j={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_TOGGLE_SUBTITLES_REQUEST:"mediatogglesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",MEDIA_RENDITION_REQUEST:"mediarenditionrequest",MEDIA_AUDIO_TRACK_REQUEST:"mediaaudiotrackrequest",MEDIA_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},Te={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},Mv={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_WIDTH:"mediaWidth",MEDIA_HEIGHT:"mediaHeight",MEDIA_PAUSED:"mediaPaused",MEDIA_HAS_PLAYED:"mediaHasPlayed",MEDIA_ENDED:"mediaEnded",MEDIA_MUTED:"mediaMuted",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_IS_PIP:"mediaIsPip",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_PREVIEW_CHAPTER:"mediaPreviewChapter",MEDIA_LOADING:"mediaLoading",MEDIA_BUFFERED:"mediaBuffered",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled",MEDIA_CHAPTERS_CUES:"mediaChaptersCues"},Pv=Object.entries(Mv),T=Pv.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{}),lL={USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"},ms=Pv.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{...lL});Object.entries(ms).reduce((i,[e,t])=>{const r=T[e];return r&&(i[t]=r),i},{userinactivechange:"userinactive"});const dL=Object.entries(T).reduce((i,[e,t])=>{const r=ms[e];return r&&(i[t]=r),i},{userinactive:"userinactivechange"}),xi={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},rn={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"},kp={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Mt={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},$i={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"},uL={INLINE:"inline",FULLSCREEN:"fullscreen",PICTURE_IN_PICTURE:"picture-in-picture"},Fe={ENTER_AIRPLAY:"Start airplay",EXIT_AIRPLAY:"Stop airplay",AUDIO_TRACK_MENU:"Audio",CAPTIONS:"Captions",ENABLE_CAPTIONS:"Enable captions",DISABLE_CAPTIONS:"Disable captions",START_CAST:"Start casting",STOP_CAST:"Stop casting",ENTER_FULLSCREEN:"Enter fullscreen mode",EXIT_FULLSCREEN:"Exit fullscreen mode",MUTE:"Mute",UNMUTE:"Unmute",ENTER_PIP:"Enter picture in picture mode",EXIT_PIP:"Enter picture in picture mode",PLAY:"Play",PAUSE:"Pause",PLAYBACK_RATE:"Playback rate",RENDITIONS:"Quality",SEEK_BACKWARD:"Seek backward",SEEK_FORWARD:"Seek forward",SETTINGS:"Settings"},Rt={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:i=1}={})=>`current playback rate ${i}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading",SETTINGS:()=>"settings",AUDIO_TRACKS:()=>"audio tracks",QUALITY:()=>"quality"},Et={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",ENTER_AIRPLAY:()=>"start airplay",EXIT_AIRPLAY:()=>"stop airplay",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:i=30}={})=>`seek forward ${i} seconds`,SEEK_BACK_N_SECS:({seekOffset:i=30}={})=>`seek back ${i} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"};function cL(i){return i==null?void 0:i.map(fL).join(" ")}function hL(i){return i==null?void 0:i.split(/\s+/).map(mL)}function fL(i){if(i){const{id:e,width:t,height:r}=i;return[e,t,r].filter(s=>s!=null).join(":")}}function mL(i){if(i){const[e,t,r]=i.split(":");return{id:e,width:+t,height:+r}}}function pL(i){return i==null?void 0:i.map(vL).join(" ")}function gL(i){return i==null?void 0:i.split(/\s+/).map(EL)}function vL(i){if(i){const{id:e,kind:t,language:r,label:s}=i;return[e,t,r,s].filter(n=>n!=null).join(":")}}function EL(i){if(i){const[e,t,r,s]=i.split(":");return{id:e,kind:t,language:r,label:s}}}function yL(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Ov(i){return typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i)}function Nv(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}const Fv=i=>new Promise(e=>setTimeout(e,i)),Lp=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],bL=(i,e)=>{const t=i===1?Lp[e].singular:Lp[e].plural;return`${i} ${t}`},Ea=i=>{if(!Ov(i))return"";const e=Math.abs(i),t=e!==i,r=new Date(0,0,0,0,0,e,0);return`${[r.getHours(),r.getMinutes(),r.getSeconds()].map((o,l)=>o&&bL(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function rs(i,e){let t=!1;i<0&&(t=!0,i=0-i),i=i<0?0:i;let r=Math.floor(i%60),s=Math.floor(i/60%60),n=Math.floor(i/3600);const a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(n=s=r="0"),n=n>0||o>0?n+":":"",s=((n||a>=10)&&s<10?"0"+s:s)+":",r=r<10?"0"+r:r,(t?"-":"")+n+s+r}let Uv=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}};class $v extends Uv{}let Ip=class extends $v{constructor(){super(...arguments),this.role=null}};class TL{observe(){}unobserve(){}disconnect(){}}const Bv={createElement:function(){return new wa.HTMLElement},createElementNS:function(){return new wa.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(i){return!1}},wa={ResizeObserver:TL,document:Bv,Node:$v,Element:Ip,HTMLElement:class extends Ip{constructor(){super(...arguments),this.innerHTML=""}get content(){return new wa.DocumentFragment}},DocumentFragment:class extends Uv{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},localStorage:{getItem(i){return null},setItem(i,e){},removeItem(i){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[],get userAgent(){return""}},matchMedia(i){return{matches:!1,media:i}}},Gv=typeof window>"u"||typeof window.customElements>"u",Hv=Object.keys(wa).every(i=>i in globalThis),R=Gv&&!Hv?wa:globalThis,Z=Gv&&!Hv?Bv:globalThis.document,Rp=new WeakMap,hf=i=>{let e=Rp.get(i);return e||Rp.set(i,e=new Set),e},Wv=new R.ResizeObserver(i=>{for(const e of i)for(const t of hf(e.target))t(e)});function vn(i,e){hf(i).add(e),Wv.observe(i)}function Ca(i,e){const t=hf(i);t.delete(e),t.size||Wv.unobserve(i)}function $t(i){var e;return(e=hc(i))!=null?e:_n(i,"media-controller")}function hc(i){var e;const{MEDIA_CONTROLLER:t}=Te,r=i.getAttribute(t);if(r)return(e=Cd(i))==null?void 0:e.getElementById(r)}const Kv=(i,e,t=".value")=>{const r=i.querySelector(t);r&&(r.textContent=e)},_L=(i,e)=>{const t=`slot[name="${e}"]`,r=i.shadowRoot.querySelector(t);return r?r.children:[]},Vv=(i,e)=>_L(i,e)[0],Vi=(i,e)=>!i||!e?!1:i!=null&&i.contains(e)?!0:Vi(i,e.getRootNode().host),_n=(i,e)=>{if(!i)return null;const t=i.closest(e);return t||_n(i.getRootNode().host,e)};function ff(i=document){var e;const t=i==null?void 0:i.activeElement;return t?(e=ff(t.shadowRoot))!=null?e:t:null}function Cd(i){var e;const t=(e=i==null?void 0:i.getRootNode)==null?void 0:e.call(i);return t instanceof ShadowRoot||t instanceof Document?t:null}function AL(i,e=3){if(i.checkVisibility)return i.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0});let t=i;for(;t&&e>0;){const r=getComputedStyle(t);if(r.opacity==="0"||r.visibility==="hidden"||r.display==="none")return!1;t=t.parentElement,e--}return!0}function SL(i,e,t,r){const s=Tu(t,r),n=Tu(t,{x:i,y:e}),a=Tu(r,{x:i,y:e});return n>s||a>s?n>a?1:0:n/s}function Tu(i,e){return Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2))}function je(i,e){const t=xL(i,r=>r===e);return t||mf(i,e)}function xL(i,e){var t,r;let s;for(s of(t=i.querySelectorAll("style:not([media])"))!=null?t:[]){let n;try{n=(r=s.sheet)==null?void 0:r.cssRules}catch{continue}for(const a of n??[])if(e(a.selectorText))return a}}function mf(i,e){var t,r;const s=(t=i.querySelectorAll("style:not([media])"))!=null?t:[],n=s==null?void 0:s[s.length-1];return n!=null&&n.sheet?(n==null||n.sheet.insertRule(`${e}{}`,n.sheet.cssRules.length),(r=n.sheet.cssRules)==null?void 0:r[n.sheet.cssRules.length-1]):(console.warn("Media Chrome: No style sheet found on style tag of",i),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}})}function Ne(i,e,t=Number.NaN){const r=i.getAttribute(e);return r!=null?+r:t}function ze(i,e,t){const r=+t;if(t==null||Number.isNaN(r)){i.hasAttribute(e)&&i.removeAttribute(e);return}Ne(i,e,void 0)!==r&&i.setAttribute(e,`${r}`)}function at(i,e){return i.hasAttribute(e)}function ot(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}at(i,e)!=t&&i.toggleAttribute(e,t)}function Qe(i,e,t=null){var r;return(r=i.getAttribute(e))!=null?r:t}function Ze(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}const r=`${t}`;Qe(i,e,void 0)!==r&&i.setAttribute(e,r)}var qv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},zi=(i,e,t)=>(qv(i,e,"read from private field"),t?t.call(i):e.get(i)),kL=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},oo=(i,e,t,r)=>(qv(i,e,"write to private field"),e.set(i,t),t),Tt;const Yv=Z.createElement("template");Yv.innerHTML=`
49
+ `))}),Uk=i=>{var e,t,r;let s=(t=((e=i.find(l=>l.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),n=gv(s),a=vv(s),o;if(n===be.LIVE){let l=i.find(d=>d.startsWith("#EXT-X-PART-INF"));if(l)o=+l.split(":")[1].split("=")[1]*2;else{let d=i.find(c=>c.startsWith("#EXT-X-TARGETDURATION")),u=(r=d==null?void 0:d.split(":"))==null?void 0:r[1];o=+(u??6)*3}}return{streamType:n,targetLiveWindow:a,liveEdgeStartOffset:o}},$k=async(i,e)=>{if(e===vr.MP4)return{streamType:be.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===vr.M3U8){let t=await Fk(i);return Uk(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},_u=async(i,e,t=Dd({src:i}))=>{var r,s,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await $k(i,t);((r=mt.get(e))!=null?r:{}).liveEdgeStartOffset=l,((s=mt.get(e))!=null?s:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=mt.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},Bk=i=>{var e;let t=i.type,r=gv(t),s=vv(t),n,a=!!((e=i.partList)!=null&&e.length);return r===be.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:r,targetLiveWindow:s,liveEdgeStartOffset:n,lowLatency:a}},Gk=(i,e,t)=>{var r,s,n,a,o,l,d,u;let{streamType:c,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:m}=Bk(i);if(c===be.LIVE){m?(t.config.backBufferLength=(r=t.userConfig.backBufferLength)!=null?r:4,t.config.maxFragLookUpTolerance=(s=t.userConfig.maxFragLookUpTolerance)!=null?s:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let p=Object.freeze({get length(){return e.seekable.length},start(g){return e.seekable.start(g)},end(g){var E;return g>this.length||g<0||Number.isFinite(e.duration)?e.seekable.end(g):(E=t.liveSyncPosition)!=null?E:e.seekable.end(g)}});((o=mt.get(e))!=null?o:{}).seekable=p}((l=mt.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=mt.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((u=mt.get(e))!=null?u:{}).streamType=c,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},Tp,_p,Hk=(_p=(Tp=globalThis==null?void 0:globalThis.navigator)==null?void 0:Tp.userAgent)!=null?_p:"",Ap,Sp,xp,Wk=(xp=(Sp=(Ap=globalThis==null?void 0:globalThis.navigator)==null?void 0:Ap.userAgentData)==null?void 0:Sp.platform)!=null?xp:"",Kk=Hk.toLowerCase().includes("android")||["x11","android"].some(i=>Wk.toLowerCase().includes(i)),mt=new WeakMap,pr="mux.com",kp,Lp,xv=(Lp=(kp=Oe).isSupported)==null?void 0:Lp.call(kp),Vk=Kk,qk=()=>Wh.utils.now(),Yk=Wh.utils.generateUUID,cc=({playbackId:i,customDomain:e=pr,maxResolution:t,minResolution:r,renditionOrder:s,programStartTime:n,programEndTime:a,tokens:{playback:o}={},extraSourceParams:l={}}={})=>{if(!i)return;let[d,u=""]=_k(i),c=new URL(`https://stream.${e}/${d}.m3u8${u}`);return o||c.searchParams.has("token")?(c.searchParams.forEach((h,f)=>{f!="token"&&c.searchParams.delete(f)}),o&&c.searchParams.set("token",o)):(t&&c.searchParams.set("max_resolution",t),r&&(c.searchParams.set("min_resolution",r),t&&+t.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",t)),s&&c.searchParams.set("rendition_order",s),n&&c.searchParams.set("program_start_time",`${n}`),a&&c.searchParams.set("program_end_time",`${a}`),Object.entries(l).forEach(([h,f])=>{f!=null&&c.searchParams.set(h,f)})),c.toString()},jk=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},hf=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(".m3u8");return e||void 0},zk=i=>{var e,t,r;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:Dv(i)&&(r=(t=jk(i.playbackId))!=null?t:hf(i.src))!=null?r:i.src},Xk=i=>{var e;return(e=mt.get(i))==null?void 0:e.error},hc=i=>{var e,t;return(t=(e=mt.get(i))==null?void 0:e.streamType)!=null?t:be.UNKNOWN},Qk=i=>{var e,t;return(t=(e=mt.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},ad=i=>{var e,t;return(t=(e=mt.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},Zk=i=>{var e;let t=(e=mt.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let r=ad(i);return r.length?r.end(r.length-1)-t:Number.NaN},ff=.034,Jk=(i,e,t=ff)=>Math.abs(i-e)<=t,kv=(i,e,t=ff)=>i>e||Jk(i,e,t),eL=(i,e=ff)=>i.paused&&kv(i.currentTime,i.duration,e),Lv=(i,e)=>{var t,r,s;if(!e||!i.buffered.length)return;if(i.readyState>2)return!1;let n=e.currentLevel>=0?(r=(t=e.levels)==null?void 0:t[e.currentLevel])==null?void 0:r.details:(s=e.levels.find(c=>!!c.details))==null?void 0:s.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(i.currentTime<i.duration-(n.targetduration+.5))return!1;let o=a[a.length-1];if(i.currentTime<=o.start)return!1;let l=o.start+o.duration/2,d=i.buffered.start(i.buffered.length-1),u=i.buffered.end(i.buffered.length-1);return l>d&&l<u},Iv=(i,e)=>i.ended||i.loop?i.ended:e&&Lv(i,e)?!0:eL(i),tL=(i,e,t)=>{Rv(e,t);let{metadata:r={}}=i,{view_session_id:s=Yk()}=r,n=zk(i);r.view_session_id=s,r.video_id=n,i.metadata=r;let a=u=>{var c;(c=e.mux)==null||c.emit("hb",{view_drm_type:u})};i.drmTypeCb=a,mt.set(e,{});let o=iL(i,e),l=kk(i,e,o);lL(i,e,o),dL(i,e,o),Ck(e),Mk(e);let d=xk(i,e,o);return{engine:o,setAutoplay:d,setPreload:l}},Rv=(i,e)=>{let t=e==null?void 0:e.engine;t&&(t.detachMedia(),t.destroy()),i!=null&&i.mux&&!i.mux.deleted&&(i.mux.destroy(),delete i.mux),i&&(i.removeAttribute("src"),i.load(),i.removeEventListener("error",Pv),i.removeEventListener("error",fc),i.removeEventListener("durationchange",Mv),mt.delete(i),i.dispatchEvent(new Event("teardown")))};function wv(i,e){var t;let r=Dd(i);if(r!==vr.M3U8)return!0;let s=!r||((t=e.canPlayType(r))!=null?t:!0),{preferPlayback:n}=i,a=n===Ti.MSE,o=n===Ti.NATIVE;return s&&(o||!(xv&&(a||Vk)))}var iL=(i,e)=>{let{debug:t,streamType:r,startTime:s=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=Dd(i)===vr.M3U8,d=wv(i,e);if(l&&!d&&xv){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},c=rL(r),h=sL(i),f=a!==Fo.NONE?{useHeaders:a===Fo.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0;return new Oe({debug:t,startPosition:s,cmcd:f,xhrSetup:(m,p)=>{var g,E;if(a&&a!==Fo.QUERY)return;let y=new URL(p);if(!y.searchParams.has("CMCD"))return;let b=((E=(g=y.searchParams.get("CMCD"))==null?void 0:g.split(","))!=null?E:[]).filter(S=>S.startsWith("sid")||S.startsWith("cid")).join(",");y.searchParams.set("CMCD",b),m.open("GET",y)},...u,...c,...h,...o})}},rL=i=>i===be.LIVE?{backBufferLength:8}:{},sL=i=>{let{drmToken:e,src:t,playbackId:r=hf(t),drmTypeCb:s}=i;return!e||!r?{}:{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:$o(i,"fairplay"),serverCertificateUrl:Cv(i,"fairplay")},"com.widevine.alpha":{licenseUrl:$o(i,"widevine")},"com.microsoft.playready":{licenseUrl:$o(i,"playready")}},requestMediaKeySystemAccessFunc:(n,a)=>(n==="com.widevine.alpha"&&(a=[...a.map(o=>{var l;let d=(l=o.videoCapabilities)==null?void 0:l.map(u=>({...u,robustness:"HW_SECURE_ALL"}));return{...o,videoCapabilities:d}}),...a]),navigator.requestMediaKeySystemAccess(n,a).then(o=>{let l=Nk(n);return s==null||s(l),o}))}},nL=async i=>await(await fetch(i)).arrayBuffer(),aL=async(i,e)=>{let t=await(await fetch(e,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:i})).arrayBuffer();return new Uint8Array(t)},oL=(i,e)=>{qe(e,"encrypted",async t=>{try{let r=t.initDataType;if(r!=="skd"){console.error(`Received unexpected initialization data type "${r}"`);return}if(!e.mediaKeys){let l=await(await navigator.requestMediaKeySystemAccess("com.apple.fps",[{initDataTypes:[r],videoCapabilities:[{contentType:"application/vnd.apple.mpegurl",robustness:""}],distinctiveIdentifier:"not-allowed",persistentState:"not-allowed",sessionTypes:["temporary"]}]).then(u=>{var c;return(c=i.drmTypeCb)==null||c.call(i,Uo.FAIRPLAY),u})).createMediaKeys(),d=await nL(Cv(i,"fairplay"));await l.setServerCertificate(d),await e.setMediaKeys(l)}let s=t.initData;if(s==null){console.error(`Could not start encrypted playback due to missing initData in ${t.type} event`);return}let n=e.mediaKeys.createSession();n.generateRequest(r,s);let a=await new Promise(l=>{n.addEventListener("message",d=>{l(d.message)},{once:!0})}),o=await aL(a,$o(i,"fairplay"));return await n.update(o),n}catch(r){console.error(`Could not start encrypted playback due to exception "${r}"`)}})},$o=({playbackId:i,drmToken:e,customDomain:t=pr},r)=>`https://license.${t.toLocaleLowerCase().endsWith(pr)?t:pr}/license/${r}/${i}?token=${e}`,Cv=({playbackId:i,drmToken:e,customDomain:t=pr},r)=>`https://license.${t.toLocaleLowerCase().endsWith(pr)?t:pr}/appcert/${r}/${i}?token=${e}`,Dv=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let r=window==null?void 0:window.location.href,s=new URL(e,r).hostname.toLocaleLowerCase();return s.includes(pr)||!!t&&s.includes(t.toLocaleLowerCase())},lL=(i,e,t)=>{var r;let{envKey:s,disableTracking:n}=i,a=Dv(i);if(!n&&(s||a)){let{playerInitTime:o,playerSoftwareName:l,playerSoftwareVersion:d,beaconCollectionDomain:u,debug:c,disableCookies:h}=i,f={...i.metadata,video_title:((r=i==null?void 0:i.metadata)==null?void 0:r.video_title)||void 0},m=p=>typeof p.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(p):p;Wh.monitor(e,{debug:c,beaconCollectionDomain:u,hlsjs:t,Hls:t?Oe:void 0,automaticErrorTracking:!1,errorTranslator:m,disableCookies:h,data:{...s?{env_key:s}:{},player_software_name:l,player_software:l,player_software_version:d,player_init_time:o,...f}})}},dL=(i,e,t)=>{var r;let s=wv(i,e),{src:n}=i,a=()=>{e.ended||!Iv(e,t)||(Lv(e,t)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},o,l,d=()=>{var u,c;let h=(u=ad(e))==null?void 0:u.start(0),f=(c=ad(e))==null?void 0:c.end(0);(l!==f||o!==h)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),o=h,l=f};if(qe(e,"durationchange",d),e&&s){let u=Dd(i);if(typeof n=="string"){let c=()=>{if(hc(e)!==be.LIVE||Number.isFinite(e.duration))return;let h=setInterval(d,1e3);e.addEventListener("teardown",()=>{clearInterval(h)},{once:!0}),qe(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(h)})};if(e.preload==="none"){let h=()=>{_u(n,e,u).then(c),e.removeEventListener("loadedmetadata",f)},f=()=>{_u(n,e,u).then(c),e.removeEventListener("play",h)};qe(e,"play",h,{once:!0}),qe(e,"loadedmetadata",f,{once:!0})}else _u(n,e,u).then(c);i.drmToken&&oL(i,e),e.setAttribute("src",n),i.startTime&&(((r=mt.get(e))!=null?r:{}).startTime=i.startTime,e.addEventListener("durationchange",Mv,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",Pv),e.addEventListener("error",fc),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(c=>{c.remove()})},{once:!0}),qe(e,"pause",a),qe(e,"seeked",a),qe(e,"play",()=>{e.ended||kv(e.currentTime,e.duration)&&(e.currentTime=e.seekable.length?e.seekable.start(0):0)})}else t&&n?(t.once(Oe.Events.LEVEL_LOADED,(u,c)=>{Gk(c.details,e,t),d(),hc(e)===be.LIVE&&!Number.isFinite(e.duration)&&(t.on(Oe.Events.LEVEL_UPDATED,d),qe(e,"durationchange",()=>{Number.isFinite(e.duration)&&t.off(Oe.Events.LEVELS_UPDATED,d)}))}),t.on(Oe.Events.ERROR,(u,c)=>{let h={[Oe.ErrorTypes.NETWORK_ERROR]:St.MEDIA_ERR_NETWORK,[Oe.ErrorTypes.MEDIA_ERROR]:St.MEDIA_ERR_DECODE},f=new St("",h[c.type]);f.fatal=c.fatal,f.data=c,e.dispatchEvent(new CustomEvent("error",{detail:f}))}),e.addEventListener("error",fc),qe(e,"waiting",a),Lk(i,t),Ik(e,t),t.attachMedia(e)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function Mv(i){var e;let t=i.target,r=(e=mt.get(t))==null?void 0:e.startTime;if(r&&Tk(t.seekable,t.duration,r)){let s=t.preload==="auto";s&&(t.preload="none"),t.currentTime=r,s&&(t.preload="auto")}}async function Pv(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:r}=e.error,s=new St(t,r);if(e.src&&(r!==St.MEDIA_ERR_DECODE||r!==void 0))try{let{status:n}=await fetch(e.src);s.data={response:{code:n}}}catch{}e.dispatchEvent(new CustomEvent("error",{detail:s}))}function fc(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof St))return;let r=i.target,s=i.detail;!s||!s.fatal||(((e=mt.get(r))!=null?e:{}).error=s,(t=r.mux)==null||t.emit("error",{player_error_code:s.code,player_error_message:s.message,player_error_context:s.context}))}const j={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_TOGGLE_SUBTITLES_REQUEST:"mediatogglesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",MEDIA_RENDITION_REQUEST:"mediarenditionrequest",MEDIA_AUDIO_TRACK_REQUEST:"mediaaudiotrackrequest",MEDIA_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},Te={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},Ov={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_WIDTH:"mediaWidth",MEDIA_HEIGHT:"mediaHeight",MEDIA_PAUSED:"mediaPaused",MEDIA_HAS_PLAYED:"mediaHasPlayed",MEDIA_ENDED:"mediaEnded",MEDIA_MUTED:"mediaMuted",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_IS_PIP:"mediaIsPip",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_PREVIEW_CHAPTER:"mediaPreviewChapter",MEDIA_LOADING:"mediaLoading",MEDIA_BUFFERED:"mediaBuffered",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled",MEDIA_CHAPTERS_CUES:"mediaChaptersCues"},Nv=Object.entries(Ov),T=Nv.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{}),uL={USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"},ms=Nv.reduce((i,[e,t])=>(i[e]=t.toLowerCase(),i),{...uL});Object.entries(ms).reduce((i,[e,t])=>{const r=T[e];return r&&(i[t]=r),i},{userinactivechange:"userinactive"});const cL=Object.entries(T).reduce((i,[e,t])=>{const r=ms[e];return r&&(i[t]=r),i},{userinactive:"userinactivechange"}),xi={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},sn={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"},Ip={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Mt={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},$i={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"},hL={INLINE:"inline",FULLSCREEN:"fullscreen",PICTURE_IN_PICTURE:"picture-in-picture"},Fe={ENTER_AIRPLAY:"Start airplay",EXIT_AIRPLAY:"Stop airplay",AUDIO_TRACK_MENU:"Audio",CAPTIONS:"Captions",ENABLE_CAPTIONS:"Enable captions",DISABLE_CAPTIONS:"Disable captions",START_CAST:"Start casting",STOP_CAST:"Stop casting",ENTER_FULLSCREEN:"Enter fullscreen mode",EXIT_FULLSCREEN:"Exit fullscreen mode",MUTE:"Mute",UNMUTE:"Unmute",ENTER_PIP:"Enter picture in picture mode",EXIT_PIP:"Enter picture in picture mode",PLAY:"Play",PAUSE:"Pause",PLAYBACK_RATE:"Playback rate",RENDITIONS:"Quality",SEEK_BACKWARD:"Seek backward",SEEK_FORWARD:"Seek forward",SETTINGS:"Settings"},Rt={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:i=1}={})=>`current playback rate ${i}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading",SETTINGS:()=>"settings",AUDIO_TRACKS:()=>"audio tracks",QUALITY:()=>"quality"},Et={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",ENTER_AIRPLAY:()=>"start airplay",EXIT_AIRPLAY:()=>"stop airplay",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:i=30}={})=>`seek forward ${i} seconds`,SEEK_BACK_N_SECS:({seekOffset:i=30}={})=>`seek back ${i} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"};function fL(i){return i==null?void 0:i.map(pL).join(" ")}function mL(i){return i==null?void 0:i.split(/\s+/).map(gL)}function pL(i){if(i){const{id:e,width:t,height:r}=i;return[e,t,r].filter(s=>s!=null).join(":")}}function gL(i){if(i){const[e,t,r]=i.split(":");return{id:e,width:+t,height:+r}}}function vL(i){return i==null?void 0:i.map(yL).join(" ")}function EL(i){return i==null?void 0:i.split(/\s+/).map(bL)}function yL(i){if(i){const{id:e,kind:t,language:r,label:s}=i;return[e,t,r,s].filter(n=>n!=null).join(":")}}function bL(i){if(i){const[e,t,r,s]=i.split(":");return{id:e,kind:t,language:r,label:s}}}function TL(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function Fv(i){return typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i)}function Uv(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}const $v=i=>new Promise(e=>setTimeout(e,i)),Rp=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],_L=(i,e)=>{const t=i===1?Rp[e].singular:Rp[e].plural;return`${i} ${t}`},ya=i=>{if(!Fv(i))return"";const e=Math.abs(i),t=e!==i,r=new Date(0,0,0,0,0,e,0);return`${[r.getHours(),r.getMinutes(),r.getSeconds()].map((o,l)=>o&&_L(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function rs(i,e){let t=!1;i<0&&(t=!0,i=0-i),i=i<0?0:i;let r=Math.floor(i%60),s=Math.floor(i/60%60),n=Math.floor(i/3600);const a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(n=s=r="0"),n=n>0||o>0?n+":":"",s=((n||a>=10)&&s<10?"0"+s:s)+":",r=r<10?"0"+r:r,(t?"-":"")+n+s+r}let Bv=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}};class Gv extends Bv{}let wp=class extends Gv{constructor(){super(...arguments),this.role=null}};class AL{observe(){}unobserve(){}disconnect(){}}const Hv={createElement:function(){return new Ca.HTMLElement},createElementNS:function(){return new Ca.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(i){return!1}},Ca={ResizeObserver:AL,document:Hv,Node:Gv,Element:wp,HTMLElement:class extends wp{constructor(){super(...arguments),this.innerHTML=""}get content(){return new Ca.DocumentFragment}},DocumentFragment:class extends Bv{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},localStorage:{getItem(i){return null},setItem(i,e){},removeItem(i){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[],get userAgent(){return""}},matchMedia(i){return{matches:!1,media:i}}},Wv=typeof window>"u"||typeof window.customElements>"u",Kv=Object.keys(Ca).every(i=>i in globalThis),R=Wv&&!Kv?Ca:globalThis,Z=Wv&&!Kv?Hv:globalThis.document,Cp=new WeakMap,mf=i=>{let e=Cp.get(i);return e||Cp.set(i,e=new Set),e},Vv=new R.ResizeObserver(i=>{for(const e of i)for(const t of mf(e.target))t(e)});function En(i,e){mf(i).add(e),Vv.observe(i)}function Da(i,e){const t=mf(i);t.delete(e),t.size||Vv.unobserve(i)}function $t(i){var e;return(e=mc(i))!=null?e:An(i,"media-controller")}function mc(i){var e;const{MEDIA_CONTROLLER:t}=Te,r=i.getAttribute(t);if(r)return(e=Md(i))==null?void 0:e.getElementById(r)}const qv=(i,e,t=".value")=>{const r=i.querySelector(t);r&&(r.textContent=e)},SL=(i,e)=>{const t=`slot[name="${e}"]`,r=i.shadowRoot.querySelector(t);return r?r.children:[]},Yv=(i,e)=>SL(i,e)[0],Vi=(i,e)=>!i||!e?!1:i!=null&&i.contains(e)?!0:Vi(i,e.getRootNode().host),An=(i,e)=>{if(!i)return null;const t=i.closest(e);return t||An(i.getRootNode().host,e)};function pf(i=document){var e;const t=i==null?void 0:i.activeElement;return t?(e=pf(t.shadowRoot))!=null?e:t:null}function Md(i){var e;const t=(e=i==null?void 0:i.getRootNode)==null?void 0:e.call(i);return t instanceof ShadowRoot||t instanceof Document?t:null}function xL(i,e=3){if(i.checkVisibility)return i.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0});let t=i;for(;t&&e>0;){const r=getComputedStyle(t);if(r.opacity==="0"||r.visibility==="hidden"||r.display==="none")return!1;t=t.parentElement,e--}return!0}function kL(i,e,t,r){const s=Au(t,r),n=Au(t,{x:i,y:e}),a=Au(r,{x:i,y:e});return n>s||a>s?n>a?1:0:n/s}function Au(i,e){return Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2))}function je(i,e){const t=LL(i,r=>r===e);return t||gf(i,e)}function LL(i,e){var t,r;let s;for(s of(t=i.querySelectorAll("style:not([media])"))!=null?t:[]){let n;try{n=(r=s.sheet)==null?void 0:r.cssRules}catch{continue}for(const a of n??[])if(e(a.selectorText))return a}}function gf(i,e){var t,r;const s=(t=i.querySelectorAll("style:not([media])"))!=null?t:[],n=s==null?void 0:s[s.length-1];return n!=null&&n.sheet?(n==null||n.sheet.insertRule(`${e}{}`,n.sheet.cssRules.length),(r=n.sheet.cssRules)==null?void 0:r[n.sheet.cssRules.length-1]):(console.warn("Media Chrome: No style sheet found on style tag of",i),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}})}function Ne(i,e,t=Number.NaN){const r=i.getAttribute(e);return r!=null?+r:t}function ze(i,e,t){const r=+t;if(t==null||Number.isNaN(r)){i.hasAttribute(e)&&i.removeAttribute(e);return}Ne(i,e,void 0)!==r&&i.setAttribute(e,`${r}`)}function at(i,e){return i.hasAttribute(e)}function ot(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}at(i,e)!=t&&i.toggleAttribute(e,t)}function Qe(i,e,t=null){var r;return(r=i.getAttribute(e))!=null?r:t}function Ze(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}const r=`${t}`;Qe(i,e,void 0)!==r&&i.setAttribute(e,r)}var jv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},zi=(i,e,t)=>(jv(i,e,"read from private field"),t?t.call(i):e.get(i)),IL=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},uo=(i,e,t,r)=>(jv(i,e,"write to private field"),e.set(i,t),t),Tt;const zv=Z.createElement("template");zv.innerHTML=`
50
50
  <style>
51
51
  :host {
52
52
  display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
53
53
  box-sizing: border-box;
54
54
  }
55
55
  </style>
56
- `;class LL extends R.HTMLElement{constructor(e={}){if(super(),kL(this,Tt,void 0),!this.shadowRoot){const t=this.attachShadow({mode:"open"}),r=Yv.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=Z.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),t.appendChild(r)}}static get observedAttributes(){return[Te.MEDIA_CONTROLLER,T.MEDIA_PAUSED]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===Te.MEDIA_CONTROLLER&&(t&&((n=(s=zi(this,Tt))==null?void 0:s.unassociateElement)==null||n.call(s,this),oo(this,Tt,null)),r&&this.isConnected&&(oo(this,Tt,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=zi(this,Tt))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r,s;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),oo(this,Tt,IL(this)),this.getAttribute(Te.MEDIA_CONTROLLER)&&((t=(e=zi(this,Tt))==null?void 0:e.associateElement)==null||t.call(e,this)),(r=zi(this,Tt))==null||r.addEventListener("pointerdown",this),(s=zi(this,Tt))==null||s.addEventListener("click",this)}disconnectedCallback(){var e,t,r,s;this.getAttribute(Te.MEDIA_CONTROLLER)&&((t=(e=zi(this,Tt))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(r=zi(this,Tt))==null||r.removeEventListener("pointerdown",this),(s=zi(this,Tt))==null||s.removeEventListener("click",this),oo(this,Tt,null)}handleEvent(e){var t;const r=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(r==null?void 0:r.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){const{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:u}=this.getBoundingClientRect(),c=n-o,h=a-l;if(c<0||h<0||c>d||h>u||d===0&&u===0)return;const{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===kp.TOUCH){this.handleTap(e);return}else if(f===kp.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){const t=this.mediaPaused?j.MEDIA_PLAY_REQUEST:j.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new R.CustomEvent(t,{composed:!0,bubbles:!0}))}}Tt=new WeakMap;function IL(i){var e;const t=i.getAttribute(Te.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):_n(i,"media-controller")}R.customElements.get("media-gesture-receiver")||R.customElements.define("media-gesture-receiver",LL);var pf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},fr=(i,e,t)=>(pf(i,e,"read from private field"),t?t.call(i):e.get(i)),Ci=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Kn=(i,e,t,r)=>(pf(i,e,"write to private field"),e.set(i,t),t),zt=(i,e,t)=>(pf(i,e,"access private method"),t),nd,Ls,Da,Xs,fc,jv,mc,zv,Ma,Dd,Md,gf,En,Pa;const me={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive"},Xv=Z.createElement("template");Xv.innerHTML=`
56
+ `;class RL extends R.HTMLElement{constructor(e={}){if(super(),IL(this,Tt,void 0),!this.shadowRoot){const t=this.attachShadow({mode:"open"}),r=zv.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=Z.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),t.appendChild(r)}}static get observedAttributes(){return[Te.MEDIA_CONTROLLER,T.MEDIA_PAUSED]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===Te.MEDIA_CONTROLLER&&(t&&((n=(s=zi(this,Tt))==null?void 0:s.unassociateElement)==null||n.call(s,this),uo(this,Tt,null)),r&&this.isConnected&&(uo(this,Tt,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=zi(this,Tt))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r,s;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),uo(this,Tt,wL(this)),this.getAttribute(Te.MEDIA_CONTROLLER)&&((t=(e=zi(this,Tt))==null?void 0:e.associateElement)==null||t.call(e,this)),(r=zi(this,Tt))==null||r.addEventListener("pointerdown",this),(s=zi(this,Tt))==null||s.addEventListener("click",this)}disconnectedCallback(){var e,t,r,s;this.getAttribute(Te.MEDIA_CONTROLLER)&&((t=(e=zi(this,Tt))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(r=zi(this,Tt))==null||r.removeEventListener("pointerdown",this),(s=zi(this,Tt))==null||s.removeEventListener("click",this),uo(this,Tt,null)}handleEvent(e){var t;const r=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(r==null?void 0:r.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){const{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:u}=this.getBoundingClientRect(),c=n-o,h=a-l;if(c<0||h<0||c>d||h>u||d===0&&u===0)return;const{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===Ip.TOUCH){this.handleTap(e);return}else if(f===Ip.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){const t=this.mediaPaused?j.MEDIA_PLAY_REQUEST:j.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new R.CustomEvent(t,{composed:!0,bubbles:!0}))}}Tt=new WeakMap;function wL(i){var e;const t=i.getAttribute(Te.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):An(i,"media-controller")}R.customElements.get("media-gesture-receiver")||R.customElements.define("media-gesture-receiver",RL);var vf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},fr=(i,e,t)=>(vf(i,e,"read from private field"),t?t.call(i):e.get(i)),Ci=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Vn=(i,e,t,r)=>(vf(i,e,"write to private field"),e.set(i,t),t),zt=(i,e,t)=>(vf(i,e,"access private method"),t),od,Is,Ma,Qs,pc,Xv,gc,Qv,Pa,Pd,Od,Ef,yn,Oa;const me={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive"},Zv=Z.createElement("template");Zv.innerHTML=`
57
57
  <style>
58
58
 
59
59
  :host([${T.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
@@ -190,7 +190,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
190
190
 
191
191
  <slot part="bottom chrome"></slot>
192
192
  </span>
193
- `;const RL=Object.values(T),wL="sm:384 md:576 lg:768 xl:960";function CL(i){DL(i.target,i.contentRect.width)}function DL(i,e){var t;if(!i.isConnected)return;const r=(t=i.getAttribute(me.BREAKPOINTS))!=null?t:wL,s=ML(r),n=PL(s,e);let a=!1;if(Object.keys(s).forEach(o=>{if(n.includes(o)){i.hasAttribute(`breakpoint${o}`)||(i.setAttribute(`breakpoint${o}`,""),a=!0);return}i.hasAttribute(`breakpoint${o}`)&&(i.removeAttribute(`breakpoint${o}`),a=!0)}),a){const o=new CustomEvent(ms.BREAKPOINTS_CHANGE,{detail:n});i.dispatchEvent(o)}}function ML(i){const e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function PL(i,e){return Object.keys(i).filter(t=>e>=parseInt(i[t]))}class Qv extends R.HTMLElement{constructor(){super(),Ci(this,fc),Ci(this,mc),Ci(this,Ma),Ci(this,Md),Ci(this,En),Ci(this,nd,0),Ci(this,Ls,null),Ci(this,Da,null),Ci(this,Xs,void 0),this.breakpointsComputed=!1,this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Xv.content.cloneNode(!0)));const e=a=>{const o=this.media;for(const l of a)l.type==="childList"&&(l.removedNodes.forEach(d=>{if(d.slot=="media"&&l.target==this){let u=l.previousSibling&&l.previousSibling.previousElementSibling;if(!u||!o)this.mediaUnsetCallback(d);else{let c=u.slot!=="media";for(;(u=u.previousSibling)!==null;)u.slot=="media"&&(c=!1);c&&this.mediaUnsetCallback(d)}}}),o&&l.addedNodes.forEach(d=>{d===o&&this.handleMediaUpdated(o)}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0});let r=!1;vn(this,a=>{r||(setTimeout(()=>{CL(a),r=!1,this.breakpointsComputed||(this.breakpointsComputed=!0,this.dispatchEvent(new CustomEvent(ms.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))},0),r=!0)});const n=this.querySelector(":scope > slot[slot=media]");n&&n.addEventListener("slotchange",()=>{if(!n.assignedElements({flatten:!0}).length){fr(this,Ls)&&this.mediaUnsetCallback(fr(this,Ls));return}this.handleMediaUpdated(this.media)})}static get observedAttributes(){return[me.AUTOHIDE,me.GESTURES_DISABLED].concat(RL).filter(e=>![T.MEDIA_RENDITION_LIST,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_CHAPTERS_CUES,T.MEDIA_WIDTH,T.MEDIA_HEIGHT].includes(e))}attributeChangedCallback(e,t,r){e.toLowerCase()==me.AUTOHIDE&&(this.autohide=r)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(Kn(this,Ls,e),e.localName.includes("-")&&await R.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;const r=this.getAttribute(me.AUDIO)!=null?Rt.AUDIO_PLAYER():Rt.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",r),this.handleMediaUpdated(this.media),this.setAttribute(me.USER_INACTIVE,""),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=R.window)==null||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;this.media&&this.mediaUnsetCallback(this.media),(e=R.window)==null||e.removeEventListener("mouseup",this)}mediaSetCallback(e){}mediaUnsetCallback(e){Kn(this,Ls,null)}handleEvent(e){switch(e.type){case"pointerdown":Kn(this,nd,e.timeStamp);break;case"pointermove":zt(this,fc,jv).call(this,e);break;case"pointerup":zt(this,mc,zv).call(this,e);break;case"mouseleave":zt(this,Ma,Dd).call(this);break;case"mouseup":this.removeAttribute(me.KEYBOARD_CONTROL);break;case"keyup":zt(this,En,Pa).call(this),this.setAttribute(me.KEYBOARD_CONTROL,"");break}}set autohide(e){const t=Number(e);Kn(this,Xs,isNaN(t)?0:t)}get autohide(){return(fr(this,Xs)===void 0?2:fr(this,Xs)).toString()}}nd=new WeakMap;Ls=new WeakMap;Da=new WeakMap;Xs=new WeakMap;fc=new WeakSet;jv=function(i){i.pointerType!=="mouse"&&i.timeStamp-fr(this,nd)<250||(zt(this,Md,gf).call(this),clearTimeout(fr(this,Da)),[this,this.media].includes(i.target)&&zt(this,En,Pa).call(this))};mc=new WeakSet;zv=function(i){if(i.pointerType==="touch"){const e=!this.hasAttribute(me.USER_INACTIVE);[this,this.media].includes(i.target)&&e?zt(this,Ma,Dd).call(this):zt(this,En,Pa).call(this)}else i.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e==null?void 0:e.localName))&&zt(this,En,Pa).call(this)};Ma=new WeakSet;Dd=function(){if(fr(this,Xs)<0||this.hasAttribute(me.USER_INACTIVE))return;this.setAttribute(me.USER_INACTIVE,"");const i=new R.CustomEvent(ms.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(i)};Md=new WeakSet;gf=function(){if(!this.hasAttribute(me.USER_INACTIVE))return;this.removeAttribute(me.USER_INACTIVE);const i=new R.CustomEvent(ms.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(i)};En=new WeakSet;Pa=function(){zt(this,Md,gf).call(this),clearTimeout(fr(this,Da));const i=parseInt(this.autohide);i<0||Kn(this,Da,setTimeout(()=>{zt(this,Ma,Dd).call(this)},i*1e3))};R.customElements.get("media-container")||R.customElements.define("media-container",Qv);var Zv=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},rt=(i,e,t)=>(Zv(i,e,"read from private field"),t?t.call(i):e.get(i)),Rn=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},lo=(i,e,t,r)=>(Zv(i,e,"write to private field"),e.set(i,t),t),Is,Rs,ad,Qr,Pi,Zi;class Pd{constructor(e,t,{defaultValue:r}={defaultValue:void 0}){Rn(this,Pi),Rn(this,Is,void 0),Rn(this,Rs,void 0),Rn(this,ad,void 0),Rn(this,Qr,new Set),lo(this,Is,e),lo(this,Rs,t),lo(this,ad,new Set(r))}[Symbol.iterator](){return rt(this,Pi,Zi).values()}get length(){return rt(this,Pi,Zi).size}get value(){var e;return(e=[...rt(this,Pi,Zi)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(lo(this,Qr,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...rt(this,Pi,Zi)][e]}values(){return rt(this,Pi,Zi).values()}forEach(e,t){rt(this,Pi,Zi).forEach(e,t)}add(...e){var t,r;e.forEach(s=>rt(this,Qr).add(s)),!(this.value===""&&!((t=rt(this,Is))!=null&&t.hasAttribute(`${rt(this,Rs)}`)))&&((r=rt(this,Is))==null||r.setAttribute(`${rt(this,Rs)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>rt(this,Qr).delete(r)),(t=rt(this,Is))==null||t.setAttribute(`${rt(this,Rs)}`,`${this.value}`)}contains(e){return rt(this,Pi,Zi).has(e)}toggle(e,t){return typeof t<"u"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}}Is=new WeakMap;Rs=new WeakMap;ad=new WeakMap;Qr=new WeakMap;Pi=new WeakSet;Zi=function(){return rt(this,Qr).size?rt(this,Qr):rt(this,ad)};const OL=(i="")=>i.split(/\s+/),Jv=(i="")=>{const[e,t,r]=i.split(":"),s=r?decodeURIComponent(r):void 0;return{kind:e==="cc"?xi.CAPTIONS:xi.SUBTITLES,language:t,label:s}},Od=(i="",e={})=>OL(i).map(t=>{const r=Jv(t);return{...e,...r}}),eE=i=>i?Array.isArray(i)?i.map(e=>typeof e=="string"?Jv(e):e):typeof i=="string"?Od(i):[i]:[],pc=({kind:i,label:e,language:t}={kind:"subtitles"})=>e?`${i==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,Oa=(i=[])=>Array.prototype.map.call(i,pc).join(" "),NL=(i,e)=>t=>t[i]===e,tE=i=>{const e=Object.entries(i).map(([t,r])=>NL(t,r));return t=>e.every(r=>r(t))},ya=(i,e=[],t=[])=>{const r=eE(t).map(tE),s=n=>r.some(a=>a(n));Array.from(e).filter(s).forEach(n=>{n.mode=i})},Nd=(i,e=()=>!0)=>{if(!(i!=null&&i.textTracks))return[];const t=typeof e=="function"?e:tE(e);return Array.from(i.textTracks).filter(t)},iE=i=>{var e;return!!((e=i.mediaSubtitlesShowing)!=null&&e.length)||i.hasAttribute(T.MEDIA_SUBTITLES_SHOWING)},FL=i=>{var e;const{media:t,fullscreenElement:r}=i,s=r&&"requestFullscreen"in r?"requestFullscreen":r&&"webkitRequestFullScreen"in r?"webkitRequestFullScreen":void 0;if(s){const n=(e=r[s])==null?void 0:e.call(r);if(n instanceof Promise)return n.catch(()=>{})}else t!=null&&t.webkitEnterFullscreen?t.webkitEnterFullscreen():t!=null&&t.requestFullscreen&&t.requestFullscreen()},wp="exitFullscreen"in Z?"exitFullscreen":"webkitExitFullscreen"in Z?"webkitExitFullscreen":"webkitCancelFullScreen"in Z?"webkitCancelFullScreen":void 0,UL=i=>{var e;const{documentElement:t}=i;if(wp){const r=(e=t==null?void 0:t[wp])==null?void 0:e.call(t);if(r instanceof Promise)return r.catch(()=>{})}},Vn="fullscreenElement"in Z?"fullscreenElement":"webkitFullscreenElement"in Z?"webkitFullscreenElement":void 0,$L=i=>{const{documentElement:e,media:t}=i,r=e==null?void 0:e[Vn];return!r&&"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t&&t.webkitDisplayingFullscreen&&t.webkitPresentationMode===uL.FULLSCREEN?t:r},BL=i=>{var e;const{media:t,documentElement:r,fullscreenElement:s=t}=i;if(!t||!r)return!1;const n=$L(i);if(!n)return!1;if(n===s||n===t)return!0;if(n.localName.includes("-")){let a=n.shadowRoot;if(!(Vn in a))return Vi(n,s);for(;a!=null&&a[Vn];){if(a[Vn]===s)return!0;a=(e=a[Vn])==null?void 0:e.shadowRoot}}return!1},GL="fullscreenEnabled"in Z?"fullscreenEnabled":"webkitFullscreenEnabled"in Z?"webkitFullscreenEnabled":void 0,HL=i=>{const{documentElement:e,media:t}=i;return!!(e!=null&&e[GL])||t&&"webkitSupportsFullscreen"in t};let uo;const vf=()=>{var i,e;return uo||(uo=(e=(i=Z)==null?void 0:i.createElement)==null?void 0:e.call(i,"video"),uo)},WL=async(i=vf())=>{if(!i)return!1;const e=i.volume;return i.volume=e/2+.1,await Fv(0),i.volume!==e},KL=/.*Version\/.*Safari\/.*/.test(R.navigator.userAgent),rE=(i=vf())=>R.matchMedia("(display-mode: standalone)").matches&&KL?!1:typeof(i==null?void 0:i.requestPictureInPicture)=="function",sE=(i=vf())=>HL({documentElement:Z,media:i}),VL=sE(),qL=rE(),YL=!!R.WebKitPlaybackTargetAvailabilityEvent,jL=!!R.chrome,od=i=>Nd(i.media,e=>[xi.SUBTITLES,xi.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),nE=i=>Nd(i.media,e=>e.mode===rn.SHOWING&&[xi.SUBTITLES,xi.CAPTIONS].includes(e.kind)),aE=(i,e)=>{const t=od(i),r=nE(i),s=!!r.length;if(t.length){if(e===!1||s&&e!==!0)ya(rn.DISABLED,t,r);else if(e===!0||!s&&e!==!1){let n=t[0];const{options:a}=i;if(!(a!=null&&a.noSubtitlesLangPref)){const u=globalThis.localStorage.getItem("media-chrome-pref-subtitles-lang"),c=u?[u,...globalThis.navigator.languages]:globalThis.navigator.languages,h=t.filter(f=>c.some(m=>f.language.toLowerCase().startsWith(m.split("-")[0]))).sort((f,m)=>{const p=c.findIndex(E=>f.language.toLowerCase().startsWith(E.split("-")[0])),g=c.findIndex(E=>m.language.toLowerCase().startsWith(E.split("-")[0]));return p-g});h[0]&&(n=h[0])}const{language:o,label:l,kind:d}=n;ya(rn.DISABLED,t,r),ya(rn.SHOWING,t,[{language:o,label:l,kind:d}])}}},Ef=(i,e)=>i===e?!0:typeof i!=typeof e?!1:typeof i=="number"&&Number.isNaN(i)&&Number.isNaN(e)?!0:typeof i!="object"?!1:Array.isArray(i)?zL(i,e):Object.entries(i).every(([t,r])=>t in e&&Ef(r,e[t])),zL=(i,e)=>{const t=Array.isArray(i),r=Array.isArray(e);return t!==r?!1:t||r?i.length!==e.length?!1:i.every((s,n)=>Ef(s,e[n])):!0},XL=Object.values($i);let ld;const QL=WL().then(i=>(ld=i,ld)),ZL=async(...i)=>{await Promise.all(i.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof R.HTMLElement))return;const t=e.localName;if(!t.includes("-"))return;const r=R.customElements.get(t);r&&e instanceof r||(await R.customElements.whenDefined(t),R.customElements.upgrade(e))}))},Uo={mediaWidth:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.videoWidth)!=null?e:0},mediaEvents:["resize"]},mediaHeight:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.videoHeight)!=null?e:0},mediaEvents:["resize"]},mediaPaused:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.paused)!=null?e:!0},set(i,e){var t;const{media:r}=e;r&&(i?r.pause():(t=r.play())==null||t.catch(()=>{}))},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(i,e){const{media:t}=i;return t?e?e.type==="playing":!t.paused:!1},mediaEvents:["playing","emptied"]},mediaEnded:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.ended)!=null?e:!1},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.playbackRate)!=null?e:1},set(i,e){const{media:t}=e;t&&Number.isFinite(+i)&&(t.playbackRate=+i)},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.muted)!=null?e:!1},set(i,e){const{media:t}=e;t&&(t.muted=i)},mediaEvents:["volumechange"]},mediaVolume:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.volume)!=null?e:1},set(i,e){const{media:t}=e;if(t){try{i==null?R.localStorage.removeItem("media-chrome-pref-volume"):R.localStorage.setItem("media-chrome-pref-volume",i.toString())}catch{}Number.isFinite(+i)&&(t.volume=+i)}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(i,e)=>{const{options:{noVolumePref:t}}=e;if(!t)try{const r=R.localStorage.getItem("media-chrome-pref-volume");if(r==null)return;Uo.mediaVolume.set(+r,e),i(+r)}catch(r){console.debug("Error getting volume pref",r)}}]},mediaVolumeLevel:{get(i){const{media:e}=i;return typeof(e==null?void 0:e.volume)>"u"?"high":e.muted||e.volume===0?"off":e.volume<.5?"low":e.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.currentTime)!=null?e:0},set(i,e){const{media:t}=e;!t||t.readyState===0||(t.currentTime=i)},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(i){const{media:e,options:{defaultDuration:t}={}}=i;return t&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?t:Number.isFinite(e==null?void 0:e.duration)?e.duration:Number.NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(i){const{media:e}=i;return(e==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(i){var e;const{media:t}=i;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;const r=t.seekable.start(0),s=t.seekable.end(t.seekable.length-1);if(!(!r&&!s))return[Number(r.toFixed(3)),Number(s.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(i){var e;const{media:t}=i,r=(e=t==null?void 0:t.buffered)!=null?e:[];return Array.from(r).map((s,n)=>[Number(r.start(n).toFixed(3)),Number(r.end(n).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(i){const{media:e,options:{defaultStreamType:t}={}}=i,r=[$i.LIVE,$i.ON_DEMAND].includes(t)?t:void 0;if(!e)return r;const{streamType:s}=e;if(XL.includes(s))return s===$i.UNKNOWN?r:s;const n=e.duration;return n===1/0?$i.LIVE:Number.isFinite(n)?$i.ON_DEMAND:r},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(i){const{media:e}=i;if(!e)return Number.NaN;const{targetLiveWindow:t}=e,r=Uo.mediaStreamType.get(i);return(t==null||Number.isNaN(t))&&r===$i.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(i){const{media:e,options:{liveEdgeOffset:t=10}={}}=i;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(Uo.mediaStreamType.get(i)===$i.LIVE))return!1;const s=e.seekable;if(!s)return!0;if(!s.length)return!1;const n=s.end(s.length-1)-t;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get(i){return od(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get(i){return nE(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t,r;const{media:s,options:n}=e;if(!s)return;const a=o=>{var l;!n.defaultSubtitles||o&&![xi.CAPTIONS,xi.SUBTITLES].includes((l=o==null?void 0:o.track)==null?void 0:l.kind)||aE(e,!0)};return(t=s.textTracks)==null||t.addEventListener("addtrack",a),(r=s.textTracks)==null||r.addEventListener("removetrack",a),a(),()=>{var o,l;(o=s.textTracks)==null||o.removeEventListener("addtrack",a),(l=s.textTracks)==null||l.removeEventListener("removetrack",a)}}]},mediaChaptersCues:{get(i){var e;const{media:t}=i;if(!t)return[];const[r]=Nd(t,{kind:xi.CHAPTERS});return Array.from((e=r==null?void 0:r.cues)!=null?e:[]).map(({text:s,startTime:n,endTime:a})=>({text:s,startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t;const{media:r}=e;if(!r)return;const s=r.querySelector('track[kind="chapters"][default][src]'),n=(t=r.shadowRoot)==null?void 0:t.querySelector(':is(video,audio) > track[kind="chapters"][default][src]');return s==null||s.addEventListener("load",i),n==null||n.addEventListener("load",i),()=>{s==null||s.removeEventListener("load",i),n==null||n.removeEventListener("load",i)}}]},mediaIsPip:{get(i){var e,t;const{media:r,documentElement:s}=i;if(!r||!s||!s.pictureInPictureElement)return!1;if(s.pictureInPictureElement===r)return!0;if(s.pictureInPictureElement instanceof HTMLMediaElement)return(e=r.localName)!=null&&e.includes("-")?Vi(r,s.pictureInPictureElement):!1;if(s.pictureInPictureElement.localName.includes("-")){let n=s.pictureInPictureElement.shadowRoot;for(;n!=null&&n.pictureInPictureElement;){if(n.pictureInPictureElement===r)return!0;n=(t=n.pictureInPictureElement)==null?void 0:t.shadowRoot}}return!1},set(i,e){const{media:t}=e;if(t)if(i){if(!Z.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!t.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}const r=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};t.requestPictureInPicture().catch(s=>{if(s.code===11){if(!t.src){console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.");return}if(t.readyState===0&&t.preload==="none"){const n=()=>{t.removeEventListener("loadedmetadata",a),t.preload="none"},a=()=>{t.requestPictureInPicture().catch(r),n()};t.addEventListener("loadedmetadata",a),t.preload="metadata",setTimeout(()=>{t.readyState===0&&r(),n()},1e3)}else throw s}else throw s})}else Z.pictureInPictureElement&&Z.exitPictureInPicture()},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(i){var e;const{media:t}=i;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]].map(r=>({...r}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(i){var e,t,r;const{media:s}=i;return(r=(t=s==null?void 0:s.videoRenditions)==null?void 0:t[(e=s.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:r.id},set(i,e){const{media:t}=e;if(!(t!=null&&t.videoRenditions)){console.warn("MediaController: Rendition selection not supported by this media.");return}const r=i,s=Array.prototype.findIndex.call(t.videoRenditions,n=>n.id==r);t.videoRenditions.selectedIndex!=s&&(t.videoRenditions.selectedIndex=s)},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(i){var e;const{media:t}=i;return[...(e=t==null?void 0:t.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(i){var e,t;const{media:r}=i;return(t=[...(e=r==null?void 0:r.audioTracks)!=null?e:[]].find(s=>s.enabled))==null?void 0:t.id},set(i,e){const{media:t}=e;if(!(t!=null&&t.audioTracks)){console.warn("MediaChrome: Audio track selection not supported by this media.");return}const r=i;for(const s of t.audioTracks)s.enabled=r==s.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get(i){return BL(i)},set(i,e){i?FL(e):UL(e)},rootEvents:["fullscreenchange","webkitfullscreenchange"],mediaEvents:["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"]},mediaIsCasting:{get(i){var e;const{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:!!t.remote.state},set(i,e){var t,r;const{media:s}=e;if(s&&!(i&&((t=s.remote)==null?void 0:t.state)!=="disconnected")&&!(!i&&((r=s.remote)==null?void 0:r.state)!=="connected")){if(typeof s.remote.prompt!="function"){console.warn("MediaChrome: Casting is not supported in this environment");return}s.remote.prompt().catch(()=>{})}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get(){return!1},set(i,e){const{media:t}=e;if(t){if(!(t.webkitShowPlaybackTargetPicker&&R.WebKitPlaybackTargetAvailabilityEvent)){console.warn("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker()}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(i){const{media:e}=i;if(!VL||!sE(e))return Mt.UNSUPPORTED}},mediaPipUnavailable:{get(i){const{media:e}=i;if(!qL||!rE(e))return Mt.UNSUPPORTED}},mediaVolumeUnavailable:{get(i){const{media:e}=i;if(ld===!1||(e==null?void 0:e.volume)==null)return Mt.UNSUPPORTED},stateOwnersUpdateHandlers:[i=>{ld==null&&QL.then(e=>i(e?void 0:Mt.UNSUPPORTED))}]},mediaCastUnavailable:{get(i,{availability:e="not-available"}={}){var t;const{media:r}=i;if(!jL||!((t=r==null?void 0:r.remote)!=null&&t.state))return Mt.UNSUPPORTED;if(!(e==null||e==="available"))return Mt.UNAVAILABLE},stateOwnersUpdateHandlers:[(i,e)=>{var t;const{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaAirplayUnavailable:{get(i,e){if(!YL)return Mt.UNSUPPORTED;if((e==null?void 0:e.availability)==="not-available")return Mt.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(i,e)=>{var t;const{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaRenditionUnavailable:{get(i){var e;const{media:t}=i;if(!(t!=null&&t.videoRenditions))return Mt.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return Mt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(i){var e,t;const{media:r}=i;if(!(r!=null&&r.audioTracks))return Mt.UNSUPPORTED;if(((t=(e=r.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return Mt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]}},JL={[j.MEDIA_PREVIEW_REQUEST](i,e,{detail:t}){var r,s,n;const{media:a}=e,o=t??void 0;let l,d;if(a&&o!=null){const[f]=Nd(a,{kind:xi.METADATA,label:"thumbnails"}),m=Array.prototype.find.call((r=f==null?void 0:f.cues)!=null?r:[],(p,g,E)=>g===0?p.endTime>o:g===E.length-1?p.startTime<=o:p.startTime<=o&&p.endTime>o);if(m){const p=/'^(?:[a-z]+:)?\/\//i.test(m.text)||(s=a==null?void 0:a.querySelector('track[label="thumbnails"]'))==null?void 0:s.src,g=new URL(m.text,p);d=new URLSearchParams(g.hash).get("#xywh").split(",").map(y=>+y),l=g.href}}const u=i.mediaDuration.get(e);let h=(n=i.mediaChaptersCues.get(e).find((f,m,p)=>m===p.length-1&&u===f.endTime?f.startTime<=o&&f.endTime>=o:f.startTime<=o&&f.endTime>o))==null?void 0:n.text;return t!=null&&h==null&&(h=""),{mediaPreviewTime:o,mediaPreviewImage:l,mediaPreviewCoords:d,mediaPreviewChapter:h}},[j.MEDIA_PAUSE_REQUEST](i,e){i["mediaPaused"].set(!0,e)},[j.MEDIA_PLAY_REQUEST](i,e){var t;const r="mediaPaused";if(i.mediaStreamType.get(e)===$i.LIVE){const a=!(i.mediaTargetLiveWindow.get(e)>0),o=(t=i.mediaSeekable.get(e))==null?void 0:t[1];a&&o&&i.mediaCurrentTime.set(o,e)}i[r].set(!1,e)},[j.MEDIA_PLAYBACK_RATE_REQUEST](i,e,{detail:t}){const r="mediaPlaybackRate",s=t;i[r].set(s,e)},[j.MEDIA_MUTE_REQUEST](i,e){i["mediaMuted"].set(!0,e)},[j.MEDIA_UNMUTE_REQUEST](i,e){const t="mediaMuted";i.mediaVolume.get(e)||i.mediaVolume.set(.25,e),i[t].set(!1,e)},[j.MEDIA_VOLUME_REQUEST](i,e,{detail:t}){const r="mediaVolume",s=t;s&&i.mediaMuted.get(e)&&i.mediaMuted.set(!1,e),i[r].set(s,e)},[j.MEDIA_SEEK_REQUEST](i,e,{detail:t}){const r="mediaCurrentTime",s=t;i[r].set(s,e)},[j.MEDIA_SEEK_TO_LIVE_REQUEST](i,e){var t;const r="mediaCurrentTime",s=(t=i.mediaSeekable.get(e))==null?void 0:t[1];Number.isNaN(Number(s))||i[r].set(s,e)},[j.MEDIA_SHOW_SUBTITLES_REQUEST](i,e,{detail:t}){var r;const{options:s}=e,n=od(e),a=eE(t),o=(r=a[0])==null?void 0:r.language;o&&!s.noSubtitlesLangPref&&R.localStorage.setItem("media-chrome-pref-subtitles-lang",o),ya(rn.SHOWING,n,a)},[j.MEDIA_DISABLE_SUBTITLES_REQUEST](i,e,{detail:t}){const r=od(e),s=t??[];ya(rn.DISABLED,r,s)},[j.MEDIA_TOGGLE_SUBTITLES_REQUEST](i,e,{detail:t}){aE(e,t)},[j.MEDIA_RENDITION_REQUEST](i,e,{detail:t}){const r="mediaRenditionSelected",s=t;i[r].set(s,e)},[j.MEDIA_AUDIO_TRACK_REQUEST](i,e,{detail:t}){const r="mediaAudioTrackEnabled",s=t;i[r].set(s,e)},[j.MEDIA_ENTER_PIP_REQUEST](i,e){const t="mediaIsPip";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[j.MEDIA_EXIT_PIP_REQUEST](i,e){i["mediaIsPip"].set(!1,e)},[j.MEDIA_ENTER_FULLSCREEN_REQUEST](i,e){const t="mediaIsFullscreen";i.mediaIsPip.get(e)&&i.mediaIsPip.set(!1,e),i[t].set(!0,e)},[j.MEDIA_EXIT_FULLSCREEN_REQUEST](i,e){i["mediaIsFullscreen"].set(!1,e)},[j.MEDIA_ENTER_CAST_REQUEST](i,e){const t="mediaIsCasting";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[j.MEDIA_EXIT_CAST_REQUEST](i,e){i["mediaIsCasting"].set(!1,e)},[j.MEDIA_AIRPLAY_REQUEST](i,e){i["mediaIsAirplaying"].set(!0,e)}},eI=({media:i,fullscreenElement:e,documentElement:t,stateMediator:r=Uo,requestMap:s=JL,options:n={},monitorStateOwnersOnlyWithSubscriptions:a=!0})=>{const o=[],l={options:{...n}};let d=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0});const u=p=>{p!=null&&(Ef(p,d)||(d=Object.freeze({...d,...p}),o.forEach(g=>g(d))))},c=()=>{const p=Object.entries(r).reduce((g,[E,{get:y}])=>(g[E]=y(l),g),{});u(p)},h={};let f;const m=async(p,g)=>{var E,y,b,S,_,x,A,C,O,L,M,K,U,z,V,q;const ae=!!f;if(f={...l,...f??{},...p},ae)return;await ZL(...Object.values(p));const ne=o.length>0&&g===0&&a,G=l.media!==f.media,$=((E=l.media)==null?void 0:E.textTracks)!==((y=f.media)==null?void 0:y.textTracks),te=((b=l.media)==null?void 0:b.videoRenditions)!==((S=f.media)==null?void 0:S.videoRenditions),re=((_=l.media)==null?void 0:_.audioTracks)!==((x=f.media)==null?void 0:x.audioTracks),oe=((A=l.media)==null?void 0:A.remote)!==((C=f.media)==null?void 0:C.remote),pe=l.documentElement!==f.documentElement,Re=!!l.media&&(G||ne),$e=!!((O=l.media)!=null&&O.textTracks)&&($||ne),yt=!!((L=l.media)!=null&&L.videoRenditions)&&(te||ne),Yi=!!((M=l.media)!=null&&M.audioTracks)&&(re||ne),ps=!!((K=l.media)!=null&&K.remote)&&(oe||ne),Zf=!!l.documentElement&&(pe||ne),Jf=Re||$e||yt||Yi||ps||Zf,gs=o.length===0&&g===1&&a,em=!!f.media&&(G||gs),tm=!!((U=f.media)!=null&&U.textTracks)&&($||gs),im=!!((z=f.media)!=null&&z.videoRenditions)&&(te||gs),rm=!!((V=f.media)!=null&&V.audioTracks)&&(re||gs),sm=!!((q=f.media)!=null&&q.remote)&&(oe||gs),nm=!!f.documentElement&&(pe||gs),am=em||tm||im||rm||sm||nm;if(!(Jf||am)){Object.entries(f).forEach(([_e,xn])=>{l[_e]=xn}),c(),f=void 0;return}Object.entries(r).forEach(([_e,{get:xn,mediaEvents:Tb=[],textTracksEvents:_b=[],videoRenditionsEvents:Ab=[],audioTracksEvents:Sb=[],remoteEvents:xb=[],rootEvents:kb=[],stateOwnersUpdateHandlers:Lb=[]}])=>{h[_e]||(h[_e]={});const kt=Ue=>{const Lt=xn(l,Ue);u({[_e]:Lt})};let Je;Je=h[_e].mediaEvents,Tb.forEach(Ue=>{Je&&Re&&(l.media.removeEventListener(Ue,Je),h[_e].mediaEvents=void 0),em&&(f.media.addEventListener(Ue,kt),h[_e].mediaEvents=kt)}),Je=h[_e].textTracksEvents,_b.forEach(Ue=>{var Lt,Bt;Je&&$e&&((Lt=l.media.textTracks)==null||Lt.removeEventListener(Ue,Je),h[_e].textTracksEvents=void 0),tm&&((Bt=f.media.textTracks)==null||Bt.addEventListener(Ue,kt),h[_e].textTracksEvents=kt)}),Je=h[_e].videoRenditionsEvents,Ab.forEach(Ue=>{var Lt,Bt;Je&&yt&&((Lt=l.media.videoRenditions)==null||Lt.removeEventListener(Ue,Je),h[_e].videoRenditionsEvents=void 0),im&&((Bt=f.media.videoRenditions)==null||Bt.addEventListener(Ue,kt),h[_e].videoRenditionsEvents=kt)}),Je=h[_e].audioTracksEvents,Sb.forEach(Ue=>{var Lt,Bt;Je&&Yi&&((Lt=l.media.audioTracks)==null||Lt.removeEventListener(Ue,Je),h[_e].audioTracksEvents=void 0),rm&&((Bt=f.media.audioTracks)==null||Bt.addEventListener(Ue,kt),h[_e].audioTracksEvents=kt)}),Je=h[_e].remoteEvents,xb.forEach(Ue=>{var Lt,Bt;Je&&ps&&((Lt=l.media.remote)==null||Lt.removeEventListener(Ue,Je),h[_e].remoteEvents=void 0),sm&&((Bt=f.media.remote)==null||Bt.addEventListener(Ue,kt),h[_e].remoteEvents=kt)}),Je=h[_e].rootEvents,kb.forEach(Ue=>{Je&&Zf&&(l.documentElement.removeEventListener(Ue,Je),h[_e].rootEvents=void 0),nm&&(f.documentElement.addEventListener(Ue,kt),h[_e].rootEvents=kt)});const om=h[_e].stateOwnersUpdateHandlers;Lb.forEach(Ue=>{om&&Jf&&om(),am&&(h[_e].stateOwnersUpdateHandlers=Ue(kt,f))})}),Object.entries(f).forEach(([_e,xn])=>{l[_e]=xn}),c(),f=void 0};return m({media:i,fullscreenElement:e,documentElement:t,options:n}),{dispatch(p){const{type:g,detail:E}=p;if(s[g]){u(s[g](r,l,p));return}g==="mediaelementchangerequest"?m({media:E}):g==="fullscreenelementchangerequest"?m({fullscreenElement:E}):g==="documentelementchangerequest"?m({documentElement:E}):g==="optionschangerequest"&&Object.entries(E??{}).forEach(([y,b])=>{l.options[y]=b})},getState(){return d},subscribe(p){return m({},o.length+1),o.push(p),p(d),()=>{const g=o.indexOf(p);g>=0&&(m({},o.length-1),o.splice(g,1))}}}};var tI=eI,yf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ue=(i,e,t)=>(yf(i,e,"read from private field"),t?t.call(i):e.get(i)),Di=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Xi=(i,e,t,r)=>(yf(i,e,"write to private field"),e.set(i,t),t),dr=(i,e,t)=>(yf(i,e,"access private method"),t),ur,qn,we,Yn,ri,$o,Bo,gc,yn,Na,Go,vc;const oE=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],Cp=10,he={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_HOTKEYS:"nohotkeys",NO_VOLUME_PREF:"novolumepref",NO_SUBTITLES_LANG_PREF:"nosubtitleslangpref",NO_DEFAULT_STORE:"nodefaultstore",KEYBOARD_FORWARD_SEEK_OFFSET:"keyboardforwardseekoffset",KEYBOARD_BACKWARD_SEEK_OFFSET:"keyboardbackwardseekoffset"};class lE extends Qv{constructor(){super(),Di(this,Bo),Di(this,yn),Di(this,Go),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,Di(this,ur,new Pd(this,he.HOTKEYS)),Di(this,qn,void 0),Di(this,we,void 0),Di(this,Yn,void 0),Di(this,ri,void 0),Di(this,$o,t=>{var r;(r=ue(this,we))==null||r.dispatch(t)}),this.associateElement(this);let e={};Xi(this,Yn,t=>{Object.entries(t).forEach(([r,s])=>{if(r in e&&e[r]===s)return;this.propagateMediaState(r,s);const n=r.toLowerCase(),a=new R.CustomEvent(dL[n],{composed:!0,detail:s});this.dispatchEvent(a)}),e=t}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(he.NO_HOTKEYS,he.HOTKEYS,he.DEFAULT_STREAM_TYPE,he.DEFAULT_SUBTITLES,he.DEFAULT_DURATION)}get mediaStore(){return ue(this,we)}set mediaStore(e){var t,r;if(ue(this,we)&&((t=ue(this,ri))==null||t.call(this),Xi(this,ri,void 0)),Xi(this,we,e),!ue(this,we)&&!this.hasAttribute(he.NO_DEFAULT_STORE)){dr(this,Bo,gc).call(this);return}Xi(this,ri,(r=ue(this,we))==null?void 0:r.subscribe(ue(this,Yn)))}get fullscreenElement(){var e;return(e=ue(this,qn))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(he.FULLSCREEN_ELEMENT)&&this.removeAttribute(he.FULLSCREEN_ELEMENT),Xi(this,qn,e),(t=ue(this,we))==null||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}attributeChangedCallback(e,t,r){var s,n,a,o,l,d;if(super.attributeChangedCallback(e,t,r),e===he.NO_HOTKEYS)r!==t&&r===""?(this.hasAttribute(he.HOTKEYS)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):r!==t&&r===null&&this.enableHotkeys();else if(e===he.HOTKEYS)ue(this,ur).value=r;else if(e===he.DEFAULT_SUBTITLES&&r!==t)(s=ue(this,we))==null||s.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(he.DEFAULT_SUBTITLES)}});else if(e===he.DEFAULT_STREAM_TYPE)(a=ue(this,we))==null||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:(n=this.getAttribute(he.DEFAULT_STREAM_TYPE))!=null?n:void 0}});else if(e===he.LIVE_EDGE_OFFSET)(o=ue(this,we))==null||o.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(he.LIVE_EDGE_OFFSET)?+this.getAttribute(he.LIVE_EDGE_OFFSET):void 0}});else if(e===he.FULLSCREEN_ELEMENT){const u=r?(l=this.getRootNode())==null?void 0:l.getElementById(r):void 0;Xi(this,qn,u),(d=ue(this,we))==null||d.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}}connectedCallback(){var e,t;!ue(this,we)&&!this.hasAttribute(he.NO_DEFAULT_STORE)&&dr(this,Bo,gc).call(this),(e=ue(this,we))==null||e.dispatch({type:"documentelementchangerequest",detail:Z}),super.connectedCallback(),ue(this,we)&&!ue(this,ri)&&Xi(this,ri,(t=ue(this,we))==null?void 0:t.subscribe(ue(this,Yn))),this.enableHotkeys()}disconnectedCallback(){var e,t,r,s;(e=super.disconnectedCallback)==null||e.call(this),ue(this,we)&&((t=ue(this,we))==null||t.dispatch({type:"documentelementchangerequest",detail:void 0}),(r=ue(this,we))==null||r.dispatch({type:j.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})),ue(this,ri)&&((s=ue(this,ri))==null||s.call(this),Xi(this,ri,void 0))}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=ue(this,we))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=ue(this,we))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){Pp(this.mediaStateReceivers,e,t)}associateElement(e){if(!e)return;const{associatedElementSubscriptions:t}=this;if(t.has(e))return;const r=this.registerMediaStateReceiver.bind(this),s=this.unregisterMediaStateReceiver.bind(this),n=oI(e,r,s);Object.values(j).forEach(a=>{e.addEventListener(a,ue(this,$o))}),t.set(e,n)}unassociateElement(e){if(!e)return;const{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.values(j).forEach(s=>{e.removeEventListener(s,ue(this,$o))})}registerMediaStateReceiver(e){if(!e)return;const t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),ue(this,we)&&Object.entries(ue(this,we).getState()).forEach(([s,n])=>{Pp([e],s,n)}))}unregisterMediaStateReceiver(e){const t=this.mediaStateReceivers,r=t.indexOf(e);r<0||t.splice(r,1)}enableHotkeys(){this.addEventListener("keydown",dr(this,Go,vc))}disableHotkeys(){this.removeEventListener("keydown",dr(this,Go,vc)),this.removeEventListener("keyup",dr(this,yn,Na))}get hotkeys(){return ue(this,ur)}keyboardShortcutHandler(e){var t,r,s,n,a;const o=e.target;if(((s=(r=(t=o.getAttribute(he.KEYS_USED))==null?void 0:t.split(" "))!=null?r:o==null?void 0:o.keysUsed)!=null?s:[]).map(h=>h==="Space"?" ":h).filter(Boolean).includes(e.key))return;let d,u,c;if(!ue(this,ur).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&ue(this,ur).contains("nospace")))switch(e.key){case" ":case"k":d=ue(this,we).getState().mediaPaused?j.MEDIA_PLAY_REQUEST:j.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new R.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"m":d=this.mediaStore.getState().mediaVolumeLevel==="off"?j.MEDIA_UNMUTE_REQUEST:j.MEDIA_MUTE_REQUEST,this.dispatchEvent(new R.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"f":d=this.mediaStore.getState().mediaIsFullscreen?j.MEDIA_EXIT_FULLSCREEN_REQUEST:j.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new R.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new R.CustomEvent(j.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":{const h=this.hasAttribute(he.KEYBOARD_BACKWARD_SEEK_OFFSET)?+this.getAttribute(he.KEYBOARD_BACKWARD_SEEK_OFFSET):Cp;u=Math.max(((n=this.mediaStore.getState().mediaCurrentTime)!=null?n:0)-h,0),c=new R.CustomEvent(j.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"ArrowRight":{const h=this.hasAttribute(he.KEYBOARD_FORWARD_SEEK_OFFSET)?+this.getAttribute(he.KEYBOARD_FORWARD_SEEK_OFFSET):Cp;u=Math.max(((a=this.mediaStore.getState().mediaCurrentTime)!=null?a:0)+h,0),c=new R.CustomEvent(j.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}}}}ur=new WeakMap;qn=new WeakMap;we=new WeakMap;Yn=new WeakMap;ri=new WeakMap;$o=new WeakMap;Bo=new WeakSet;gc=function(){var i;this.mediaStore=tI({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(he.DEFAULT_SUBTITLES),defaultDuration:this.hasAttribute(he.DEFAULT_DURATION)?+this.getAttribute(he.DEFAULT_DURATION):void 0,defaultStreamType:(i=this.getAttribute(he.DEFAULT_STREAM_TYPE))!=null?i:void 0,liveEdgeOffset:this.hasAttribute(he.LIVE_EDGE_OFFSET)?+this.getAttribute(he.LIVE_EDGE_OFFSET):void 0,noVolumePref:this.hasAttribute(he.NO_VOLUME_PREF),noSubtitlesLangPref:this.hasAttribute(he.NO_SUBTITLES_LANG_PREF)}})};yn=new WeakSet;Na=function(i){const{key:e}=i;if(!oE.includes(e)){this.removeEventListener("keyup",dr(this,yn,Na));return}this.keyboardShortcutHandler(i)};Go=new WeakSet;vc=function(i){const{metaKey:e,altKey:t,key:r}=i;if(e||t||!oE.includes(r)){this.removeEventListener("keyup",dr(this,yn,Na));return}[" ","ArrowLeft","ArrowRight"].includes(r)&&!(ue(this,ur).contains(`no${r.toLowerCase()}`)||r===" "&&ue(this,ur).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",dr(this,yn,Na),{once:!0})};const iI=Object.values(T),rI=Object.values(Mv),dE=i=>{var e,t,r,s;let{observedAttributes:n}=i.constructor;!n&&((e=i.nodeName)!=null&&e.includes("-"))&&(R.customElements.upgrade(i),{observedAttributes:n}=i.constructor);const a=(s=(r=(t=i==null?void 0:i.getAttribute)==null?void 0:t.call(i,Te.MEDIA_CHROME_ATTRIBUTES))==null?void 0:r.split)==null?void 0:s.call(r,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>iI.includes(o)):[]},sI=i=>{var e,t;return(e=i.nodeName)!=null&&e.includes("-")&&R.customElements.get((t=i.nodeName)==null?void 0:t.toLowerCase())&&!(i instanceof R.customElements.get(i.nodeName.toLowerCase()))&&R.customElements.upgrade(i),rI.some(r=>r in i)},Ec=i=>sI(i)||!!dE(i).length,Dp=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},Mp={[T.MEDIA_SUBTITLES_LIST]:Oa,[T.MEDIA_SUBTITLES_SHOWING]:Oa,[T.MEDIA_SEEKABLE]:Dp,[T.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(Dp).join(" "),[T.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[T.MEDIA_RENDITION_LIST]:cL,[T.MEDIA_AUDIO_TRACK_LIST]:pL},nI=async(i,e,t)=>{var r,s;if(i.isConnected||await Fv(0),typeof t=="boolean"||t==null)return ot(i,e,t);if(typeof t=="number")return ze(i,e,t);if(typeof t=="string")return Ze(i,e,t);if(Array.isArray(t)&&!t.length)return i.removeAttribute(e);const n=(s=(r=Mp[e])==null?void 0:r.call(Mp,t))!=null?s:t;return i.setAttribute(e,n)},aI=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},Lr=(i,e)=>{if(aI(i))return;const t=(s,n)=>{var a,o;Ec(s)&&n(s);const{children:l=[]}=s??{},d=(o=(a=s==null?void 0:s.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(c=>Lr(c,n))},r=i==null?void 0:i.nodeName.toLowerCase();if(r.includes("-")&&!Ec(i)){R.customElements.whenDefined(r).then(()=>{t(i,e)});return}t(i,e)},Pp=(i,e,t)=>{i.forEach(r=>{if(e in r){r[e]=t;return}const s=dE(r),n=e.toLowerCase();s.includes(n)&&nI(r,n,t)})},oI=(i,e,t)=>{Lr(i,e);const r=u=>{var c;const h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;e(h)},s=u=>{var c;const h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;t(h)};i.addEventListener(j.REGISTER_MEDIA_STATE_RECEIVER,r),i.addEventListener(j.UNREGISTER_MEDIA_STATE_RECEIVER,s);const n=u=>{u.forEach(c=>{const{addedNodes:h=[],removedNodes:f=[],type:m,target:p,attributeName:g}=c;m==="childList"?(Array.prototype.forEach.call(h,E=>Lr(E,e)),Array.prototype.forEach.call(f,E=>Lr(E,t))):m==="attributes"&&g===Te.MEDIA_CHROME_ATTRIBUTES&&(Ec(p)?e(p):t(p))})};let a=[];const o=u=>{const c=u.target;c.name!=="media"&&(a.forEach(h=>Lr(h,t)),a=[...c.assignedElements({flatten:!0})],a.forEach(h=>Lr(h,e)))};i.addEventListener("slotchange",o);const l=new MutationObserver(n);return l.observe(i,{childList:!0,attributes:!0,subtree:!0}),()=>{Lr(i,t),i.removeEventListener("slotchange",o),l.disconnect(),i.removeEventListener(j.REGISTER_MEDIA_STATE_RECEIVER,r),i.removeEventListener(j.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};R.customElements.get("media-controller")||R.customElements.define("media-controller",lE);var lI=lE,bf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Be=(i,e,t)=>(bf(i,e,"read from private field"),t?t.call(i):e.get(i)),_s=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},co=(i,e,t,r)=>(bf(i,e,"write to private field"),e.set(i,t),t),dI=(i,e,t)=>(bf(i,e,"access private method"),t),si,Qs,cr,ws,Ho,yc,uE;const ho={TOOLTIP_PLACEMENT:"tooltipplacement"},cE=Z.createElement("template");cE.innerHTML=`
193
+ `;const CL=Object.values(T),DL="sm:384 md:576 lg:768 xl:960";function ML(i){PL(i.target,i.contentRect.width)}function PL(i,e){var t;if(!i.isConnected)return;const r=(t=i.getAttribute(me.BREAKPOINTS))!=null?t:DL,s=OL(r),n=NL(s,e);let a=!1;if(Object.keys(s).forEach(o=>{if(n.includes(o)){i.hasAttribute(`breakpoint${o}`)||(i.setAttribute(`breakpoint${o}`,""),a=!0);return}i.hasAttribute(`breakpoint${o}`)&&(i.removeAttribute(`breakpoint${o}`),a=!0)}),a){const o=new CustomEvent(ms.BREAKPOINTS_CHANGE,{detail:n});i.dispatchEvent(o)}}function OL(i){const e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function NL(i,e){return Object.keys(i).filter(t=>e>=parseInt(i[t]))}class Jv extends R.HTMLElement{constructor(){super(),Ci(this,pc),Ci(this,gc),Ci(this,Pa),Ci(this,Od),Ci(this,yn),Ci(this,od,0),Ci(this,Is,null),Ci(this,Ma,null),Ci(this,Qs,void 0),this.breakpointsComputed=!1,this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Zv.content.cloneNode(!0)));const e=a=>{const o=this.media;for(const l of a)l.type==="childList"&&(l.removedNodes.forEach(d=>{if(d.slot=="media"&&l.target==this){let u=l.previousSibling&&l.previousSibling.previousElementSibling;if(!u||!o)this.mediaUnsetCallback(d);else{let c=u.slot!=="media";for(;(u=u.previousSibling)!==null;)u.slot=="media"&&(c=!1);c&&this.mediaUnsetCallback(d)}}}),o&&l.addedNodes.forEach(d=>{d===o&&this.handleMediaUpdated(o)}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0});let r=!1;En(this,a=>{r||(setTimeout(()=>{ML(a),r=!1,this.breakpointsComputed||(this.breakpointsComputed=!0,this.dispatchEvent(new CustomEvent(ms.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))},0),r=!0)});const n=this.querySelector(":scope > slot[slot=media]");n&&n.addEventListener("slotchange",()=>{if(!n.assignedElements({flatten:!0}).length){fr(this,Is)&&this.mediaUnsetCallback(fr(this,Is));return}this.handleMediaUpdated(this.media)})}static get observedAttributes(){return[me.AUTOHIDE,me.GESTURES_DISABLED].concat(CL).filter(e=>![T.MEDIA_RENDITION_LIST,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_CHAPTERS_CUES,T.MEDIA_WIDTH,T.MEDIA_HEIGHT].includes(e))}attributeChangedCallback(e,t,r){e.toLowerCase()==me.AUTOHIDE&&(this.autohide=r)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(Vn(this,Is,e),e.localName.includes("-")&&await R.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;const r=this.getAttribute(me.AUDIO)!=null?Rt.AUDIO_PLAYER():Rt.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",r),this.handleMediaUpdated(this.media),this.setAttribute(me.USER_INACTIVE,""),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=R.window)==null||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;this.media&&this.mediaUnsetCallback(this.media),(e=R.window)==null||e.removeEventListener("mouseup",this)}mediaSetCallback(e){}mediaUnsetCallback(e){Vn(this,Is,null)}handleEvent(e){switch(e.type){case"pointerdown":Vn(this,od,e.timeStamp);break;case"pointermove":zt(this,pc,Xv).call(this,e);break;case"pointerup":zt(this,gc,Qv).call(this,e);break;case"mouseleave":zt(this,Pa,Pd).call(this);break;case"mouseup":this.removeAttribute(me.KEYBOARD_CONTROL);break;case"keyup":zt(this,yn,Oa).call(this),this.setAttribute(me.KEYBOARD_CONTROL,"");break}}set autohide(e){const t=Number(e);Vn(this,Qs,isNaN(t)?0:t)}get autohide(){return(fr(this,Qs)===void 0?2:fr(this,Qs)).toString()}}od=new WeakMap;Is=new WeakMap;Ma=new WeakMap;Qs=new WeakMap;pc=new WeakSet;Xv=function(i){i.pointerType!=="mouse"&&i.timeStamp-fr(this,od)<250||(zt(this,Od,Ef).call(this),clearTimeout(fr(this,Ma)),[this,this.media].includes(i.target)&&zt(this,yn,Oa).call(this))};gc=new WeakSet;Qv=function(i){if(i.pointerType==="touch"){const e=!this.hasAttribute(me.USER_INACTIVE);[this,this.media].includes(i.target)&&e?zt(this,Pa,Pd).call(this):zt(this,yn,Oa).call(this)}else i.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e==null?void 0:e.localName))&&zt(this,yn,Oa).call(this)};Pa=new WeakSet;Pd=function(){if(fr(this,Qs)<0||this.hasAttribute(me.USER_INACTIVE))return;this.setAttribute(me.USER_INACTIVE,"");const i=new R.CustomEvent(ms.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(i)};Od=new WeakSet;Ef=function(){if(!this.hasAttribute(me.USER_INACTIVE))return;this.removeAttribute(me.USER_INACTIVE);const i=new R.CustomEvent(ms.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(i)};yn=new WeakSet;Oa=function(){zt(this,Od,Ef).call(this),clearTimeout(fr(this,Ma));const i=parseInt(this.autohide);i<0||Vn(this,Ma,setTimeout(()=>{zt(this,Pa,Pd).call(this)},i*1e3))};R.customElements.get("media-container")||R.customElements.define("media-container",Jv);var eE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},rt=(i,e,t)=>(eE(i,e,"read from private field"),t?t.call(i):e.get(i)),wn=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},co=(i,e,t,r)=>(eE(i,e,"write to private field"),e.set(i,t),t),Rs,ws,ld,Qr,Pi,Zi;class Nd{constructor(e,t,{defaultValue:r}={defaultValue:void 0}){wn(this,Pi),wn(this,Rs,void 0),wn(this,ws,void 0),wn(this,ld,void 0),wn(this,Qr,new Set),co(this,Rs,e),co(this,ws,t),co(this,ld,new Set(r))}[Symbol.iterator](){return rt(this,Pi,Zi).values()}get length(){return rt(this,Pi,Zi).size}get value(){var e;return(e=[...rt(this,Pi,Zi)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(co(this,Qr,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...rt(this,Pi,Zi)][e]}values(){return rt(this,Pi,Zi).values()}forEach(e,t){rt(this,Pi,Zi).forEach(e,t)}add(...e){var t,r;e.forEach(s=>rt(this,Qr).add(s)),!(this.value===""&&!((t=rt(this,Rs))!=null&&t.hasAttribute(`${rt(this,ws)}`)))&&((r=rt(this,Rs))==null||r.setAttribute(`${rt(this,ws)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>rt(this,Qr).delete(r)),(t=rt(this,Rs))==null||t.setAttribute(`${rt(this,ws)}`,`${this.value}`)}contains(e){return rt(this,Pi,Zi).has(e)}toggle(e,t){return typeof t<"u"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}}Rs=new WeakMap;ws=new WeakMap;ld=new WeakMap;Qr=new WeakMap;Pi=new WeakSet;Zi=function(){return rt(this,Qr).size?rt(this,Qr):rt(this,ld)};const FL=(i="")=>i.split(/\s+/),tE=(i="")=>{const[e,t,r]=i.split(":"),s=r?decodeURIComponent(r):void 0;return{kind:e==="cc"?xi.CAPTIONS:xi.SUBTITLES,language:t,label:s}},Fd=(i="",e={})=>FL(i).map(t=>{const r=tE(t);return{...e,...r}}),iE=i=>i?Array.isArray(i)?i.map(e=>typeof e=="string"?tE(e):e):typeof i=="string"?Fd(i):[i]:[],vc=({kind:i,label:e,language:t}={kind:"subtitles"})=>e?`${i==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,Na=(i=[])=>Array.prototype.map.call(i,vc).join(" "),UL=(i,e)=>t=>t[i]===e,rE=i=>{const e=Object.entries(i).map(([t,r])=>UL(t,r));return t=>e.every(r=>r(t))},ba=(i,e=[],t=[])=>{const r=iE(t).map(rE),s=n=>r.some(a=>a(n));Array.from(e).filter(s).forEach(n=>{n.mode=i})},Ud=(i,e=()=>!0)=>{if(!(i!=null&&i.textTracks))return[];const t=typeof e=="function"?e:rE(e);return Array.from(i.textTracks).filter(t)},sE=i=>{var e;return!!((e=i.mediaSubtitlesShowing)!=null&&e.length)||i.hasAttribute(T.MEDIA_SUBTITLES_SHOWING)},$L=i=>{var e;const{media:t,fullscreenElement:r}=i,s=r&&"requestFullscreen"in r?"requestFullscreen":r&&"webkitRequestFullScreen"in r?"webkitRequestFullScreen":void 0;if(s){const n=(e=r[s])==null?void 0:e.call(r);if(n instanceof Promise)return n.catch(()=>{})}else t!=null&&t.webkitEnterFullscreen?t.webkitEnterFullscreen():t!=null&&t.requestFullscreen&&t.requestFullscreen()},Dp="exitFullscreen"in Z?"exitFullscreen":"webkitExitFullscreen"in Z?"webkitExitFullscreen":"webkitCancelFullScreen"in Z?"webkitCancelFullScreen":void 0,BL=i=>{var e;const{documentElement:t}=i;if(Dp){const r=(e=t==null?void 0:t[Dp])==null?void 0:e.call(t);if(r instanceof Promise)return r.catch(()=>{})}},qn="fullscreenElement"in Z?"fullscreenElement":"webkitFullscreenElement"in Z?"webkitFullscreenElement":void 0,GL=i=>{const{documentElement:e,media:t}=i,r=e==null?void 0:e[qn];return!r&&"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t&&t.webkitDisplayingFullscreen&&t.webkitPresentationMode===hL.FULLSCREEN?t:r},HL=i=>{var e;const{media:t,documentElement:r,fullscreenElement:s=t}=i;if(!t||!r)return!1;const n=GL(i);if(!n)return!1;if(n===s||n===t)return!0;if(n.localName.includes("-")){let a=n.shadowRoot;if(!(qn in a))return Vi(n,s);for(;a!=null&&a[qn];){if(a[qn]===s)return!0;a=(e=a[qn])==null?void 0:e.shadowRoot}}return!1},WL="fullscreenEnabled"in Z?"fullscreenEnabled":"webkitFullscreenEnabled"in Z?"webkitFullscreenEnabled":void 0,KL=i=>{const{documentElement:e,media:t}=i;return!!(e!=null&&e[WL])||t&&"webkitSupportsFullscreen"in t};let ho;const yf=()=>{var i,e;return ho||(ho=(e=(i=Z)==null?void 0:i.createElement)==null?void 0:e.call(i,"video"),ho)},VL=async(i=yf())=>{if(!i)return!1;const e=i.volume;return i.volume=e/2+.1,await $v(0),i.volume!==e},qL=/.*Version\/.*Safari\/.*/.test(R.navigator.userAgent),nE=(i=yf())=>R.matchMedia("(display-mode: standalone)").matches&&qL?!1:typeof(i==null?void 0:i.requestPictureInPicture)=="function",aE=(i=yf())=>KL({documentElement:Z,media:i}),YL=aE(),jL=nE(),zL=!!R.WebKitPlaybackTargetAvailabilityEvent,XL=!!R.chrome,dd=i=>Ud(i.media,e=>[xi.SUBTITLES,xi.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),oE=i=>Ud(i.media,e=>e.mode===sn.SHOWING&&[xi.SUBTITLES,xi.CAPTIONS].includes(e.kind)),lE=(i,e)=>{const t=dd(i),r=oE(i),s=!!r.length;if(t.length){if(e===!1||s&&e!==!0)ba(sn.DISABLED,t,r);else if(e===!0||!s&&e!==!1){let n=t[0];const{options:a}=i;if(!(a!=null&&a.noSubtitlesLangPref)){const u=globalThis.localStorage.getItem("media-chrome-pref-subtitles-lang"),c=u?[u,...globalThis.navigator.languages]:globalThis.navigator.languages,h=t.filter(f=>c.some(m=>f.language.toLowerCase().startsWith(m.split("-")[0]))).sort((f,m)=>{const p=c.findIndex(E=>f.language.toLowerCase().startsWith(E.split("-")[0])),g=c.findIndex(E=>m.language.toLowerCase().startsWith(E.split("-")[0]));return p-g});h[0]&&(n=h[0])}const{language:o,label:l,kind:d}=n;ba(sn.DISABLED,t,r),ba(sn.SHOWING,t,[{language:o,label:l,kind:d}])}}},bf=(i,e)=>i===e?!0:typeof i!=typeof e?!1:typeof i=="number"&&Number.isNaN(i)&&Number.isNaN(e)?!0:typeof i!="object"?!1:Array.isArray(i)?QL(i,e):Object.entries(i).every(([t,r])=>t in e&&bf(r,e[t])),QL=(i,e)=>{const t=Array.isArray(i),r=Array.isArray(e);return t!==r?!1:t||r?i.length!==e.length?!1:i.every((s,n)=>bf(s,e[n])):!0},ZL=Object.values($i);let ud;const JL=VL().then(i=>(ud=i,ud)),eI=async(...i)=>{await Promise.all(i.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof R.HTMLElement))return;const t=e.localName;if(!t.includes("-"))return;const r=R.customElements.get(t);r&&e instanceof r||(await R.customElements.whenDefined(t),R.customElements.upgrade(e))}))},Bo={mediaWidth:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.videoWidth)!=null?e:0},mediaEvents:["resize"]},mediaHeight:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.videoHeight)!=null?e:0},mediaEvents:["resize"]},mediaPaused:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.paused)!=null?e:!0},set(i,e){var t;const{media:r}=e;r&&(i?r.pause():(t=r.play())==null||t.catch(()=>{}))},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(i,e){const{media:t}=i;return t?e?e.type==="playing":!t.paused:!1},mediaEvents:["playing","emptied"]},mediaEnded:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.ended)!=null?e:!1},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.playbackRate)!=null?e:1},set(i,e){const{media:t}=e;t&&Number.isFinite(+i)&&(t.playbackRate=+i)},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.muted)!=null?e:!1},set(i,e){const{media:t}=e;t&&(t.muted=i)},mediaEvents:["volumechange"]},mediaVolume:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.volume)!=null?e:1},set(i,e){const{media:t}=e;if(t){try{i==null?R.localStorage.removeItem("media-chrome-pref-volume"):R.localStorage.setItem("media-chrome-pref-volume",i.toString())}catch{}Number.isFinite(+i)&&(t.volume=+i)}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(i,e)=>{const{options:{noVolumePref:t}}=e;if(!t)try{const r=R.localStorage.getItem("media-chrome-pref-volume");if(r==null)return;Bo.mediaVolume.set(+r,e),i(+r)}catch(r){console.debug("Error getting volume pref",r)}}]},mediaVolumeLevel:{get(i){const{media:e}=i;return typeof(e==null?void 0:e.volume)>"u"?"high":e.muted||e.volume===0?"off":e.volume<.5?"low":e.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.currentTime)!=null?e:0},set(i,e){const{media:t}=e;!t||t.readyState===0||(t.currentTime=i)},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(i){const{media:e,options:{defaultDuration:t}={}}=i;return t&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?t:Number.isFinite(e==null?void 0:e.duration)?e.duration:Number.NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(i){const{media:e}=i;return(e==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(i){var e;const{media:t}=i;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;const r=t.seekable.start(0),s=t.seekable.end(t.seekable.length-1);if(!(!r&&!s))return[Number(r.toFixed(3)),Number(s.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(i){var e;const{media:t}=i,r=(e=t==null?void 0:t.buffered)!=null?e:[];return Array.from(r).map((s,n)=>[Number(r.start(n).toFixed(3)),Number(r.end(n).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(i){const{media:e,options:{defaultStreamType:t}={}}=i,r=[$i.LIVE,$i.ON_DEMAND].includes(t)?t:void 0;if(!e)return r;const{streamType:s}=e;if(ZL.includes(s))return s===$i.UNKNOWN?r:s;const n=e.duration;return n===1/0?$i.LIVE:Number.isFinite(n)?$i.ON_DEMAND:r},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(i){const{media:e}=i;if(!e)return Number.NaN;const{targetLiveWindow:t}=e,r=Bo.mediaStreamType.get(i);return(t==null||Number.isNaN(t))&&r===$i.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(i){const{media:e,options:{liveEdgeOffset:t=10}={}}=i;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(Bo.mediaStreamType.get(i)===$i.LIVE))return!1;const s=e.seekable;if(!s)return!0;if(!s.length)return!1;const n=s.end(s.length-1)-t;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get(i){return dd(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get(i){return oE(i).map(({kind:e,label:t,language:r})=>({kind:e,label:t,language:r}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t,r;const{media:s,options:n}=e;if(!s)return;const a=o=>{var l;!n.defaultSubtitles||o&&![xi.CAPTIONS,xi.SUBTITLES].includes((l=o==null?void 0:o.track)==null?void 0:l.kind)||lE(e,!0)};return(t=s.textTracks)==null||t.addEventListener("addtrack",a),(r=s.textTracks)==null||r.addEventListener("removetrack",a),a(),()=>{var o,l;(o=s.textTracks)==null||o.removeEventListener("addtrack",a),(l=s.textTracks)==null||l.removeEventListener("removetrack",a)}}]},mediaChaptersCues:{get(i){var e;const{media:t}=i;if(!t)return[];const[r]=Ud(t,{kind:xi.CHAPTERS});return Array.from((e=r==null?void 0:r.cues)!=null?e:[]).map(({text:s,startTime:n,endTime:a})=>({text:s,startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t;const{media:r}=e;if(!r)return;const s=r.querySelector('track[kind="chapters"][default][src]'),n=(t=r.shadowRoot)==null?void 0:t.querySelector(':is(video,audio) > track[kind="chapters"][default][src]');return s==null||s.addEventListener("load",i),n==null||n.addEventListener("load",i),()=>{s==null||s.removeEventListener("load",i),n==null||n.removeEventListener("load",i)}}]},mediaIsPip:{get(i){var e,t;const{media:r,documentElement:s}=i;if(!r||!s||!s.pictureInPictureElement)return!1;if(s.pictureInPictureElement===r)return!0;if(s.pictureInPictureElement instanceof HTMLMediaElement)return(e=r.localName)!=null&&e.includes("-")?Vi(r,s.pictureInPictureElement):!1;if(s.pictureInPictureElement.localName.includes("-")){let n=s.pictureInPictureElement.shadowRoot;for(;n!=null&&n.pictureInPictureElement;){if(n.pictureInPictureElement===r)return!0;n=(t=n.pictureInPictureElement)==null?void 0:t.shadowRoot}}return!1},set(i,e){const{media:t}=e;if(t)if(i){if(!Z.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!t.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}const r=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};t.requestPictureInPicture().catch(s=>{if(s.code===11){if(!t.src){console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.");return}if(t.readyState===0&&t.preload==="none"){const n=()=>{t.removeEventListener("loadedmetadata",a),t.preload="none"},a=()=>{t.requestPictureInPicture().catch(r),n()};t.addEventListener("loadedmetadata",a),t.preload="metadata",setTimeout(()=>{t.readyState===0&&r(),n()},1e3)}else throw s}else throw s})}else Z.pictureInPictureElement&&Z.exitPictureInPicture()},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(i){var e;const{media:t}=i;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]].map(r=>({...r}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(i){var e,t,r;const{media:s}=i;return(r=(t=s==null?void 0:s.videoRenditions)==null?void 0:t[(e=s.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:r.id},set(i,e){const{media:t}=e;if(!(t!=null&&t.videoRenditions)){console.warn("MediaController: Rendition selection not supported by this media.");return}const r=i,s=Array.prototype.findIndex.call(t.videoRenditions,n=>n.id==r);t.videoRenditions.selectedIndex!=s&&(t.videoRenditions.selectedIndex=s)},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(i){var e;const{media:t}=i;return[...(e=t==null?void 0:t.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(i){var e,t;const{media:r}=i;return(t=[...(e=r==null?void 0:r.audioTracks)!=null?e:[]].find(s=>s.enabled))==null?void 0:t.id},set(i,e){const{media:t}=e;if(!(t!=null&&t.audioTracks)){console.warn("MediaChrome: Audio track selection not supported by this media.");return}const r=i;for(const s of t.audioTracks)s.enabled=r==s.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get(i){return HL(i)},set(i,e){i?$L(e):BL(e)},rootEvents:["fullscreenchange","webkitfullscreenchange"],mediaEvents:["webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"]},mediaIsCasting:{get(i){var e;const{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:!!t.remote.state},set(i,e){var t,r;const{media:s}=e;if(s&&!(i&&((t=s.remote)==null?void 0:t.state)!=="disconnected")&&!(!i&&((r=s.remote)==null?void 0:r.state)!=="connected")){if(typeof s.remote.prompt!="function"){console.warn("MediaChrome: Casting is not supported in this environment");return}s.remote.prompt().catch(()=>{})}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get(){return!1},set(i,e){const{media:t}=e;if(t){if(!(t.webkitShowPlaybackTargetPicker&&R.WebKitPlaybackTargetAvailabilityEvent)){console.warn("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker()}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(i){const{media:e}=i;if(!YL||!aE(e))return Mt.UNSUPPORTED}},mediaPipUnavailable:{get(i){const{media:e}=i;if(!jL||!nE(e))return Mt.UNSUPPORTED}},mediaVolumeUnavailable:{get(i){const{media:e}=i;if(ud===!1||(e==null?void 0:e.volume)==null)return Mt.UNSUPPORTED},stateOwnersUpdateHandlers:[i=>{ud==null&&JL.then(e=>i(e?void 0:Mt.UNSUPPORTED))}]},mediaCastUnavailable:{get(i,{availability:e="not-available"}={}){var t;const{media:r}=i;if(!XL||!((t=r==null?void 0:r.remote)!=null&&t.state))return Mt.UNSUPPORTED;if(!(e==null||e==="available"))return Mt.UNAVAILABLE},stateOwnersUpdateHandlers:[(i,e)=>{var t;const{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaAirplayUnavailable:{get(i,e){if(!zL)return Mt.UNSUPPORTED;if((e==null?void 0:e.availability)==="not-available")return Mt.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(i,e)=>{var t;const{media:r}=e;return r?(r.disableRemotePlayback||r.hasAttribute("disableremoteplayback")||(t=r==null?void 0:r.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=r==null?void 0:r.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaRenditionUnavailable:{get(i){var e;const{media:t}=i;if(!(t!=null&&t.videoRenditions))return Mt.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return Mt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(i){var e,t;const{media:r}=i;if(!(r!=null&&r.audioTracks))return Mt.UNSUPPORTED;if(((t=(e=r.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return Mt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]}},tI={[j.MEDIA_PREVIEW_REQUEST](i,e,{detail:t}){var r,s,n;const{media:a}=e,o=t??void 0;let l,d;if(a&&o!=null){const[f]=Ud(a,{kind:xi.METADATA,label:"thumbnails"}),m=Array.prototype.find.call((r=f==null?void 0:f.cues)!=null?r:[],(p,g,E)=>g===0?p.endTime>o:g===E.length-1?p.startTime<=o:p.startTime<=o&&p.endTime>o);if(m){const p=/'^(?:[a-z]+:)?\/\//i.test(m.text)||(s=a==null?void 0:a.querySelector('track[label="thumbnails"]'))==null?void 0:s.src,g=new URL(m.text,p);d=new URLSearchParams(g.hash).get("#xywh").split(",").map(y=>+y),l=g.href}}const u=i.mediaDuration.get(e);let h=(n=i.mediaChaptersCues.get(e).find((f,m,p)=>m===p.length-1&&u===f.endTime?f.startTime<=o&&f.endTime>=o:f.startTime<=o&&f.endTime>o))==null?void 0:n.text;return t!=null&&h==null&&(h=""),{mediaPreviewTime:o,mediaPreviewImage:l,mediaPreviewCoords:d,mediaPreviewChapter:h}},[j.MEDIA_PAUSE_REQUEST](i,e){i["mediaPaused"].set(!0,e)},[j.MEDIA_PLAY_REQUEST](i,e){var t;const r="mediaPaused";if(i.mediaStreamType.get(e)===$i.LIVE){const a=!(i.mediaTargetLiveWindow.get(e)>0),o=(t=i.mediaSeekable.get(e))==null?void 0:t[1];a&&o&&i.mediaCurrentTime.set(o,e)}i[r].set(!1,e)},[j.MEDIA_PLAYBACK_RATE_REQUEST](i,e,{detail:t}){const r="mediaPlaybackRate",s=t;i[r].set(s,e)},[j.MEDIA_MUTE_REQUEST](i,e){i["mediaMuted"].set(!0,e)},[j.MEDIA_UNMUTE_REQUEST](i,e){const t="mediaMuted";i.mediaVolume.get(e)||i.mediaVolume.set(.25,e),i[t].set(!1,e)},[j.MEDIA_VOLUME_REQUEST](i,e,{detail:t}){const r="mediaVolume",s=t;s&&i.mediaMuted.get(e)&&i.mediaMuted.set(!1,e),i[r].set(s,e)},[j.MEDIA_SEEK_REQUEST](i,e,{detail:t}){const r="mediaCurrentTime",s=t;i[r].set(s,e)},[j.MEDIA_SEEK_TO_LIVE_REQUEST](i,e){var t;const r="mediaCurrentTime",s=(t=i.mediaSeekable.get(e))==null?void 0:t[1];Number.isNaN(Number(s))||i[r].set(s,e)},[j.MEDIA_SHOW_SUBTITLES_REQUEST](i,e,{detail:t}){var r;const{options:s}=e,n=dd(e),a=iE(t),o=(r=a[0])==null?void 0:r.language;o&&!s.noSubtitlesLangPref&&R.localStorage.setItem("media-chrome-pref-subtitles-lang",o),ba(sn.SHOWING,n,a)},[j.MEDIA_DISABLE_SUBTITLES_REQUEST](i,e,{detail:t}){const r=dd(e),s=t??[];ba(sn.DISABLED,r,s)},[j.MEDIA_TOGGLE_SUBTITLES_REQUEST](i,e,{detail:t}){lE(e,t)},[j.MEDIA_RENDITION_REQUEST](i,e,{detail:t}){const r="mediaRenditionSelected",s=t;i[r].set(s,e)},[j.MEDIA_AUDIO_TRACK_REQUEST](i,e,{detail:t}){const r="mediaAudioTrackEnabled",s=t;i[r].set(s,e)},[j.MEDIA_ENTER_PIP_REQUEST](i,e){const t="mediaIsPip";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[j.MEDIA_EXIT_PIP_REQUEST](i,e){i["mediaIsPip"].set(!1,e)},[j.MEDIA_ENTER_FULLSCREEN_REQUEST](i,e){const t="mediaIsFullscreen";i.mediaIsPip.get(e)&&i.mediaIsPip.set(!1,e),i[t].set(!0,e)},[j.MEDIA_EXIT_FULLSCREEN_REQUEST](i,e){i["mediaIsFullscreen"].set(!1,e)},[j.MEDIA_ENTER_CAST_REQUEST](i,e){const t="mediaIsCasting";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[j.MEDIA_EXIT_CAST_REQUEST](i,e){i["mediaIsCasting"].set(!1,e)},[j.MEDIA_AIRPLAY_REQUEST](i,e){i["mediaIsAirplaying"].set(!0,e)}},iI=({media:i,fullscreenElement:e,documentElement:t,stateMediator:r=Bo,requestMap:s=tI,options:n={},monitorStateOwnersOnlyWithSubscriptions:a=!0})=>{const o=[],l={options:{...n}};let d=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0});const u=p=>{p!=null&&(bf(p,d)||(d=Object.freeze({...d,...p}),o.forEach(g=>g(d))))},c=()=>{const p=Object.entries(r).reduce((g,[E,{get:y}])=>(g[E]=y(l),g),{});u(p)},h={};let f;const m=async(p,g)=>{var E,y,b,S,_,x,A,C,O,L,M,K,U,z,V,q;const ae=!!f;if(f={...l,...f??{},...p},ae)return;await eI(...Object.values(p));const ne=o.length>0&&g===0&&a,G=l.media!==f.media,$=((E=l.media)==null?void 0:E.textTracks)!==((y=f.media)==null?void 0:y.textTracks),te=((b=l.media)==null?void 0:b.videoRenditions)!==((S=f.media)==null?void 0:S.videoRenditions),re=((_=l.media)==null?void 0:_.audioTracks)!==((x=f.media)==null?void 0:x.audioTracks),oe=((A=l.media)==null?void 0:A.remote)!==((C=f.media)==null?void 0:C.remote),pe=l.documentElement!==f.documentElement,Re=!!l.media&&(G||ne),$e=!!((O=l.media)!=null&&O.textTracks)&&($||ne),yt=!!((L=l.media)!=null&&L.videoRenditions)&&(te||ne),Yi=!!((M=l.media)!=null&&M.audioTracks)&&(re||ne),ps=!!((K=l.media)!=null&&K.remote)&&(oe||ne),em=!!l.documentElement&&(pe||ne),tm=Re||$e||yt||Yi||ps||em,gs=o.length===0&&g===1&&a,im=!!f.media&&(G||gs),rm=!!((U=f.media)!=null&&U.textTracks)&&($||gs),sm=!!((z=f.media)!=null&&z.videoRenditions)&&(te||gs),nm=!!((V=f.media)!=null&&V.audioTracks)&&(re||gs),am=!!((q=f.media)!=null&&q.remote)&&(oe||gs),om=!!f.documentElement&&(pe||gs),lm=im||rm||sm||nm||am||om;if(!(tm||lm)){Object.entries(f).forEach(([_e,kn])=>{l[_e]=kn}),c(),f=void 0;return}Object.entries(r).forEach(([_e,{get:kn,mediaEvents:Ab=[],textTracksEvents:Sb=[],videoRenditionsEvents:xb=[],audioTracksEvents:kb=[],remoteEvents:Lb=[],rootEvents:Ib=[],stateOwnersUpdateHandlers:Rb=[]}])=>{h[_e]||(h[_e]={});const kt=Ue=>{const Lt=kn(l,Ue);u({[_e]:Lt})};let Je;Je=h[_e].mediaEvents,Ab.forEach(Ue=>{Je&&Re&&(l.media.removeEventListener(Ue,Je),h[_e].mediaEvents=void 0),im&&(f.media.addEventListener(Ue,kt),h[_e].mediaEvents=kt)}),Je=h[_e].textTracksEvents,Sb.forEach(Ue=>{var Lt,Bt;Je&&$e&&((Lt=l.media.textTracks)==null||Lt.removeEventListener(Ue,Je),h[_e].textTracksEvents=void 0),rm&&((Bt=f.media.textTracks)==null||Bt.addEventListener(Ue,kt),h[_e].textTracksEvents=kt)}),Je=h[_e].videoRenditionsEvents,xb.forEach(Ue=>{var Lt,Bt;Je&&yt&&((Lt=l.media.videoRenditions)==null||Lt.removeEventListener(Ue,Je),h[_e].videoRenditionsEvents=void 0),sm&&((Bt=f.media.videoRenditions)==null||Bt.addEventListener(Ue,kt),h[_e].videoRenditionsEvents=kt)}),Je=h[_e].audioTracksEvents,kb.forEach(Ue=>{var Lt,Bt;Je&&Yi&&((Lt=l.media.audioTracks)==null||Lt.removeEventListener(Ue,Je),h[_e].audioTracksEvents=void 0),nm&&((Bt=f.media.audioTracks)==null||Bt.addEventListener(Ue,kt),h[_e].audioTracksEvents=kt)}),Je=h[_e].remoteEvents,Lb.forEach(Ue=>{var Lt,Bt;Je&&ps&&((Lt=l.media.remote)==null||Lt.removeEventListener(Ue,Je),h[_e].remoteEvents=void 0),am&&((Bt=f.media.remote)==null||Bt.addEventListener(Ue,kt),h[_e].remoteEvents=kt)}),Je=h[_e].rootEvents,Ib.forEach(Ue=>{Je&&em&&(l.documentElement.removeEventListener(Ue,Je),h[_e].rootEvents=void 0),om&&(f.documentElement.addEventListener(Ue,kt),h[_e].rootEvents=kt)});const dm=h[_e].stateOwnersUpdateHandlers;Rb.forEach(Ue=>{dm&&tm&&dm(),lm&&(h[_e].stateOwnersUpdateHandlers=Ue(kt,f))})}),Object.entries(f).forEach(([_e,kn])=>{l[_e]=kn}),c(),f=void 0};return m({media:i,fullscreenElement:e,documentElement:t,options:n}),{dispatch(p){const{type:g,detail:E}=p;if(s[g]){u(s[g](r,l,p));return}g==="mediaelementchangerequest"?m({media:E}):g==="fullscreenelementchangerequest"?m({fullscreenElement:E}):g==="documentelementchangerequest"?m({documentElement:E}):g==="optionschangerequest"&&Object.entries(E??{}).forEach(([y,b])=>{l.options[y]=b})},getState(){return d},subscribe(p){return m({},o.length+1),o.push(p),p(d),()=>{const g=o.indexOf(p);g>=0&&(m({},o.length-1),o.splice(g,1))}}}};var rI=iI,Tf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ue=(i,e,t)=>(Tf(i,e,"read from private field"),t?t.call(i):e.get(i)),Di=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Xi=(i,e,t,r)=>(Tf(i,e,"write to private field"),e.set(i,t),t),dr=(i,e,t)=>(Tf(i,e,"access private method"),t),ur,Yn,we,jn,ri,Go,Ho,Ec,bn,Fa,Wo,yc;const dE=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],Mp=10,he={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_HOTKEYS:"nohotkeys",NO_VOLUME_PREF:"novolumepref",NO_SUBTITLES_LANG_PREF:"nosubtitleslangpref",NO_DEFAULT_STORE:"nodefaultstore",KEYBOARD_FORWARD_SEEK_OFFSET:"keyboardforwardseekoffset",KEYBOARD_BACKWARD_SEEK_OFFSET:"keyboardbackwardseekoffset"};class uE extends Jv{constructor(){super(),Di(this,Ho),Di(this,bn),Di(this,Wo),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,Di(this,ur,new Nd(this,he.HOTKEYS)),Di(this,Yn,void 0),Di(this,we,void 0),Di(this,jn,void 0),Di(this,ri,void 0),Di(this,Go,t=>{var r;(r=ue(this,we))==null||r.dispatch(t)}),this.associateElement(this);let e={};Xi(this,jn,t=>{Object.entries(t).forEach(([r,s])=>{if(r in e&&e[r]===s)return;this.propagateMediaState(r,s);const n=r.toLowerCase(),a=new R.CustomEvent(cL[n],{composed:!0,detail:s});this.dispatchEvent(a)}),e=t}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(he.NO_HOTKEYS,he.HOTKEYS,he.DEFAULT_STREAM_TYPE,he.DEFAULT_SUBTITLES,he.DEFAULT_DURATION)}get mediaStore(){return ue(this,we)}set mediaStore(e){var t,r;if(ue(this,we)&&((t=ue(this,ri))==null||t.call(this),Xi(this,ri,void 0)),Xi(this,we,e),!ue(this,we)&&!this.hasAttribute(he.NO_DEFAULT_STORE)){dr(this,Ho,Ec).call(this);return}Xi(this,ri,(r=ue(this,we))==null?void 0:r.subscribe(ue(this,jn)))}get fullscreenElement(){var e;return(e=ue(this,Yn))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(he.FULLSCREEN_ELEMENT)&&this.removeAttribute(he.FULLSCREEN_ELEMENT),Xi(this,Yn,e),(t=ue(this,we))==null||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}attributeChangedCallback(e,t,r){var s,n,a,o,l,d;if(super.attributeChangedCallback(e,t,r),e===he.NO_HOTKEYS)r!==t&&r===""?(this.hasAttribute(he.HOTKEYS)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):r!==t&&r===null&&this.enableHotkeys();else if(e===he.HOTKEYS)ue(this,ur).value=r;else if(e===he.DEFAULT_SUBTITLES&&r!==t)(s=ue(this,we))==null||s.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(he.DEFAULT_SUBTITLES)}});else if(e===he.DEFAULT_STREAM_TYPE)(a=ue(this,we))==null||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:(n=this.getAttribute(he.DEFAULT_STREAM_TYPE))!=null?n:void 0}});else if(e===he.LIVE_EDGE_OFFSET)(o=ue(this,we))==null||o.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(he.LIVE_EDGE_OFFSET)?+this.getAttribute(he.LIVE_EDGE_OFFSET):void 0}});else if(e===he.FULLSCREEN_ELEMENT){const u=r?(l=this.getRootNode())==null?void 0:l.getElementById(r):void 0;Xi(this,Yn,u),(d=ue(this,we))==null||d.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}}connectedCallback(){var e,t;!ue(this,we)&&!this.hasAttribute(he.NO_DEFAULT_STORE)&&dr(this,Ho,Ec).call(this),(e=ue(this,we))==null||e.dispatch({type:"documentelementchangerequest",detail:Z}),super.connectedCallback(),ue(this,we)&&!ue(this,ri)&&Xi(this,ri,(t=ue(this,we))==null?void 0:t.subscribe(ue(this,jn))),this.enableHotkeys()}disconnectedCallback(){var e,t,r,s;(e=super.disconnectedCallback)==null||e.call(this),ue(this,we)&&((t=ue(this,we))==null||t.dispatch({type:"documentelementchangerequest",detail:void 0}),(r=ue(this,we))==null||r.dispatch({type:j.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})),ue(this,ri)&&((s=ue(this,ri))==null||s.call(this),Xi(this,ri,void 0))}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=ue(this,we))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=ue(this,we))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){Np(this.mediaStateReceivers,e,t)}associateElement(e){if(!e)return;const{associatedElementSubscriptions:t}=this;if(t.has(e))return;const r=this.registerMediaStateReceiver.bind(this),s=this.unregisterMediaStateReceiver.bind(this),n=dI(e,r,s);Object.values(j).forEach(a=>{e.addEventListener(a,ue(this,Go))}),t.set(e,n)}unassociateElement(e){if(!e)return;const{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.values(j).forEach(s=>{e.removeEventListener(s,ue(this,Go))})}registerMediaStateReceiver(e){if(!e)return;const t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),ue(this,we)&&Object.entries(ue(this,we).getState()).forEach(([s,n])=>{Np([e],s,n)}))}unregisterMediaStateReceiver(e){const t=this.mediaStateReceivers,r=t.indexOf(e);r<0||t.splice(r,1)}enableHotkeys(){this.addEventListener("keydown",dr(this,Wo,yc))}disableHotkeys(){this.removeEventListener("keydown",dr(this,Wo,yc)),this.removeEventListener("keyup",dr(this,bn,Fa))}get hotkeys(){return ue(this,ur)}keyboardShortcutHandler(e){var t,r,s,n,a;const o=e.target;if(((s=(r=(t=o.getAttribute(he.KEYS_USED))==null?void 0:t.split(" "))!=null?r:o==null?void 0:o.keysUsed)!=null?s:[]).map(h=>h==="Space"?" ":h).filter(Boolean).includes(e.key))return;let d,u,c;if(!ue(this,ur).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&ue(this,ur).contains("nospace")))switch(e.key){case" ":case"k":d=ue(this,we).getState().mediaPaused?j.MEDIA_PLAY_REQUEST:j.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new R.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"m":d=this.mediaStore.getState().mediaVolumeLevel==="off"?j.MEDIA_UNMUTE_REQUEST:j.MEDIA_MUTE_REQUEST,this.dispatchEvent(new R.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"f":d=this.mediaStore.getState().mediaIsFullscreen?j.MEDIA_EXIT_FULLSCREEN_REQUEST:j.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new R.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new R.CustomEvent(j.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":{const h=this.hasAttribute(he.KEYBOARD_BACKWARD_SEEK_OFFSET)?+this.getAttribute(he.KEYBOARD_BACKWARD_SEEK_OFFSET):Mp;u=Math.max(((n=this.mediaStore.getState().mediaCurrentTime)!=null?n:0)-h,0),c=new R.CustomEvent(j.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}case"ArrowRight":{const h=this.hasAttribute(he.KEYBOARD_FORWARD_SEEK_OFFSET)?+this.getAttribute(he.KEYBOARD_FORWARD_SEEK_OFFSET):Mp;u=Math.max(((a=this.mediaStore.getState().mediaCurrentTime)!=null?a:0)+h,0),c=new R.CustomEvent(j.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:u}),this.dispatchEvent(c);break}}}}ur=new WeakMap;Yn=new WeakMap;we=new WeakMap;jn=new WeakMap;ri=new WeakMap;Go=new WeakMap;Ho=new WeakSet;Ec=function(){var i;this.mediaStore=rI({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(he.DEFAULT_SUBTITLES),defaultDuration:this.hasAttribute(he.DEFAULT_DURATION)?+this.getAttribute(he.DEFAULT_DURATION):void 0,defaultStreamType:(i=this.getAttribute(he.DEFAULT_STREAM_TYPE))!=null?i:void 0,liveEdgeOffset:this.hasAttribute(he.LIVE_EDGE_OFFSET)?+this.getAttribute(he.LIVE_EDGE_OFFSET):void 0,noVolumePref:this.hasAttribute(he.NO_VOLUME_PREF),noSubtitlesLangPref:this.hasAttribute(he.NO_SUBTITLES_LANG_PREF)}})};bn=new WeakSet;Fa=function(i){const{key:e}=i;if(!dE.includes(e)){this.removeEventListener("keyup",dr(this,bn,Fa));return}this.keyboardShortcutHandler(i)};Wo=new WeakSet;yc=function(i){const{metaKey:e,altKey:t,key:r}=i;if(e||t||!dE.includes(r)){this.removeEventListener("keyup",dr(this,bn,Fa));return}[" ","ArrowLeft","ArrowRight"].includes(r)&&!(ue(this,ur).contains(`no${r.toLowerCase()}`)||r===" "&&ue(this,ur).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",dr(this,bn,Fa),{once:!0})};const sI=Object.values(T),nI=Object.values(Ov),cE=i=>{var e,t,r,s;let{observedAttributes:n}=i.constructor;!n&&((e=i.nodeName)!=null&&e.includes("-"))&&(R.customElements.upgrade(i),{observedAttributes:n}=i.constructor);const a=(s=(r=(t=i==null?void 0:i.getAttribute)==null?void 0:t.call(i,Te.MEDIA_CHROME_ATTRIBUTES))==null?void 0:r.split)==null?void 0:s.call(r,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>sI.includes(o)):[]},aI=i=>{var e,t;return(e=i.nodeName)!=null&&e.includes("-")&&R.customElements.get((t=i.nodeName)==null?void 0:t.toLowerCase())&&!(i instanceof R.customElements.get(i.nodeName.toLowerCase()))&&R.customElements.upgrade(i),nI.some(r=>r in i)},bc=i=>aI(i)||!!cE(i).length,Pp=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},Op={[T.MEDIA_SUBTITLES_LIST]:Na,[T.MEDIA_SUBTITLES_SHOWING]:Na,[T.MEDIA_SEEKABLE]:Pp,[T.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(Pp).join(" "),[T.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[T.MEDIA_RENDITION_LIST]:fL,[T.MEDIA_AUDIO_TRACK_LIST]:vL},oI=async(i,e,t)=>{var r,s;if(i.isConnected||await $v(0),typeof t=="boolean"||t==null)return ot(i,e,t);if(typeof t=="number")return ze(i,e,t);if(typeof t=="string")return Ze(i,e,t);if(Array.isArray(t)&&!t.length)return i.removeAttribute(e);const n=(s=(r=Op[e])==null?void 0:r.call(Op,t))!=null?s:t;return i.setAttribute(e,n)},lI=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},Lr=(i,e)=>{if(lI(i))return;const t=(s,n)=>{var a,o;bc(s)&&n(s);const{children:l=[]}=s??{},d=(o=(a=s==null?void 0:s.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(c=>Lr(c,n))},r=i==null?void 0:i.nodeName.toLowerCase();if(r.includes("-")&&!bc(i)){R.customElements.whenDefined(r).then(()=>{t(i,e)});return}t(i,e)},Np=(i,e,t)=>{i.forEach(r=>{if(e in r){r[e]=t;return}const s=cE(r),n=e.toLowerCase();s.includes(n)&&oI(r,n,t)})},dI=(i,e,t)=>{Lr(i,e);const r=u=>{var c;const h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;e(h)},s=u=>{var c;const h=(c=u==null?void 0:u.composedPath()[0])!=null?c:u.target;t(h)};i.addEventListener(j.REGISTER_MEDIA_STATE_RECEIVER,r),i.addEventListener(j.UNREGISTER_MEDIA_STATE_RECEIVER,s);const n=u=>{u.forEach(c=>{const{addedNodes:h=[],removedNodes:f=[],type:m,target:p,attributeName:g}=c;m==="childList"?(Array.prototype.forEach.call(h,E=>Lr(E,e)),Array.prototype.forEach.call(f,E=>Lr(E,t))):m==="attributes"&&g===Te.MEDIA_CHROME_ATTRIBUTES&&(bc(p)?e(p):t(p))})};let a=[];const o=u=>{const c=u.target;c.name!=="media"&&(a.forEach(h=>Lr(h,t)),a=[...c.assignedElements({flatten:!0})],a.forEach(h=>Lr(h,e)))};i.addEventListener("slotchange",o);const l=new MutationObserver(n);return l.observe(i,{childList:!0,attributes:!0,subtree:!0}),()=>{Lr(i,t),i.removeEventListener("slotchange",o),l.disconnect(),i.removeEventListener(j.REGISTER_MEDIA_STATE_RECEIVER,r),i.removeEventListener(j.UNREGISTER_MEDIA_STATE_RECEIVER,s)}};R.customElements.get("media-controller")||R.customElements.define("media-controller",uE);var uI=uE,_f=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Be=(i,e,t)=>(_f(i,e,"read from private field"),t?t.call(i):e.get(i)),As=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},fo=(i,e,t,r)=>(_f(i,e,"write to private field"),e.set(i,t),t),cI=(i,e,t)=>(_f(i,e,"access private method"),t),si,Zs,cr,Cs,Ko,Tc,hE;const mo={TOOLTIP_PLACEMENT:"tooltipplacement"},fE=Z.createElement("template");fE.innerHTML=`
194
194
  <style>
195
195
  :host {
196
196
  position: relative;
@@ -265,10 +265,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
265
265
  <slot name="tooltip-content"></slot>
266
266
  </media-tooltip>
267
267
  </slot>
268
- `;class wt extends R.HTMLElement{constructor(e={}){var t;if(super(),_s(this,yc),_s(this,si,void 0),this.preventClick=!1,this.tooltipEl=null,this.tooltipContent="",_s(this,Qs,r=>{this.preventClick||this.handleClick(r),setTimeout(Be(this,cr),0)}),_s(this,cr,()=>{var r,s;(s=(r=this.tooltipEl)==null?void 0:r.updateXOffset)==null||s.call(r)}),_s(this,ws,r=>{const{key:s}=r;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",Be(this,ws));return}this.preventClick||this.handleClick(r)}),_s(this,Ho,r=>{const{metaKey:s,altKey:n,key:a}=r;if(s||n||!this.keysUsed.includes(a)){this.removeEventListener("keyup",Be(this,ws));return}this.addEventListener("keyup",Be(this,ws),{once:!0})}),!this.shadowRoot){this.attachShadow({mode:"open"});const r=cE.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=Z.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),e.tooltipContent&&(r.querySelector('slot[name="tooltip-content"]').innerHTML=(t=e.tooltipContent)!=null?t:"",this.tooltipContent=e.tooltipContent),this.nativeEl.appendChild(s.content.cloneNode(!0)),this.shadowRoot.appendChild(r)}this.tooltipEl=this.shadowRoot.querySelector("media-tooltip")}static get observedAttributes(){return["disabled",ho.TOOLTIP_PLACEMENT,Te.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",Be(this,Qs)),this.addEventListener("keydown",Be(this,Ho)),this.tabIndex=0}disable(){this.removeEventListener("click",Be(this,Qs)),this.removeEventListener("keydown",Be(this,Ho)),this.removeEventListener("keyup",Be(this,ws)),this.tabIndex=-1}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===Te.MEDIA_CONTROLLER?(t&&((n=(s=Be(this,si))==null?void 0:s.unassociateElement)==null||n.call(s,this),co(this,si,null)),r&&this.isConnected&&(co(this,si,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Be(this,si))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t?r==null?this.enable():this.disable():e===ho.TOOLTIP_PLACEMENT&&this.tooltipEl&&r!==t&&(this.tooltipEl.placement=r),Be(this,cr).call(this)}connectedCallback(){var e,t,r;const{style:s}=je(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");const n=this.getAttribute(Te.MEDIA_CONTROLLER);n&&(co(this,si,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=Be(this,si))==null?void 0:t.associateElement)==null||r.call(t,this)),R.customElements.whenDefined("media-tooltip").then(()=>dI(this,yc,uE).call(this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=Be(this,si))==null?void 0:e.unassociateElement)==null||t.call(e,this),co(this,si,null),this.removeEventListener("mouseenter",Be(this,cr)),this.removeEventListener("focus",Be(this,cr)),this.removeEventListener("click",Be(this,Qs))}get keysUsed(){return["Enter"," "]}get tooltipPlacement(){return Qe(this,ho.TOOLTIP_PLACEMENT)}set tooltipPlacement(e){Ze(this,ho.TOOLTIP_PLACEMENT,e)}handleClick(e){}}si=new WeakMap;Qs=new WeakMap;cr=new WeakMap;ws=new WeakMap;Ho=new WeakMap;yc=new WeakSet;uE=function(){this.addEventListener("mouseenter",Be(this,cr)),this.addEventListener("focus",Be(this,cr)),this.addEventListener("click",Be(this,Qs));const i=this.tooltipPlacement;i&&this.tooltipEl&&(this.tooltipEl.placement=i)};R.customElements.get("media-chrome-button")||R.customElements.define("media-chrome-button",wt);const Op=`<svg aria-hidden="true" viewBox="0 0 26 24">
268
+ `;class wt extends R.HTMLElement{constructor(e={}){var t;if(super(),As(this,Tc),As(this,si,void 0),this.preventClick=!1,this.tooltipEl=null,this.tooltipContent="",As(this,Zs,r=>{this.preventClick||this.handleClick(r),setTimeout(Be(this,cr),0)}),As(this,cr,()=>{var r,s;(s=(r=this.tooltipEl)==null?void 0:r.updateXOffset)==null||s.call(r)}),As(this,Cs,r=>{const{key:s}=r;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",Be(this,Cs));return}this.preventClick||this.handleClick(r)}),As(this,Ko,r=>{const{metaKey:s,altKey:n,key:a}=r;if(s||n||!this.keysUsed.includes(a)){this.removeEventListener("keyup",Be(this,Cs));return}this.addEventListener("keyup",Be(this,Cs),{once:!0})}),!this.shadowRoot){this.attachShadow({mode:"open"});const r=fE.content.cloneNode(!0);this.nativeEl=r;let s=e.slotTemplate;s||(s=Z.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),e.tooltipContent&&(r.querySelector('slot[name="tooltip-content"]').innerHTML=(t=e.tooltipContent)!=null?t:"",this.tooltipContent=e.tooltipContent),this.nativeEl.appendChild(s.content.cloneNode(!0)),this.shadowRoot.appendChild(r)}this.tooltipEl=this.shadowRoot.querySelector("media-tooltip")}static get observedAttributes(){return["disabled",mo.TOOLTIP_PLACEMENT,Te.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",Be(this,Zs)),this.addEventListener("keydown",Be(this,Ko)),this.tabIndex=0}disable(){this.removeEventListener("click",Be(this,Zs)),this.removeEventListener("keydown",Be(this,Ko)),this.removeEventListener("keyup",Be(this,Cs)),this.tabIndex=-1}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===Te.MEDIA_CONTROLLER?(t&&((n=(s=Be(this,si))==null?void 0:s.unassociateElement)==null||n.call(s,this),fo(this,si,null)),r&&this.isConnected&&(fo(this,si,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Be(this,si))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&r!==t?r==null?this.enable():this.disable():e===mo.TOOLTIP_PLACEMENT&&this.tooltipEl&&r!==t&&(this.tooltipEl.placement=r),Be(this,cr).call(this)}connectedCallback(){var e,t,r;const{style:s}=je(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");const n=this.getAttribute(Te.MEDIA_CONTROLLER);n&&(fo(this,si,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=Be(this,si))==null?void 0:t.associateElement)==null||r.call(t,this)),R.customElements.whenDefined("media-tooltip").then(()=>cI(this,Tc,hE).call(this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=Be(this,si))==null?void 0:e.unassociateElement)==null||t.call(e,this),fo(this,si,null),this.removeEventListener("mouseenter",Be(this,cr)),this.removeEventListener("focus",Be(this,cr)),this.removeEventListener("click",Be(this,Zs))}get keysUsed(){return["Enter"," "]}get tooltipPlacement(){return Qe(this,mo.TOOLTIP_PLACEMENT)}set tooltipPlacement(e){Ze(this,mo.TOOLTIP_PLACEMENT,e)}handleClick(e){}}si=new WeakMap;Zs=new WeakMap;cr=new WeakMap;Cs=new WeakMap;Ko=new WeakMap;Tc=new WeakSet;hE=function(){this.addEventListener("mouseenter",Be(this,cr)),this.addEventListener("focus",Be(this,cr)),this.addEventListener("click",Be(this,Zs));const i=this.tooltipPlacement;i&&this.tooltipEl&&(this.tooltipEl.placement=i)};R.customElements.get("media-chrome-button")||R.customElements.define("media-chrome-button",wt);const Fp=`<svg aria-hidden="true" viewBox="0 0 26 24">
269
269
  <path d="M22.13 3H3.87a.87.87 0 0 0-.87.87v13.26a.87.87 0 0 0 .87.87h3.4L9 16H5V5h16v11h-4l1.72 2h3.4a.87.87 0 0 0 .87-.87V3.87a.87.87 0 0 0-.86-.87Zm-8.75 11.44a.5.5 0 0 0-.76 0l-4.91 5.73a.5.5 0 0 0 .38.83h9.82a.501.501 0 0 0 .38-.83l-4.91-5.73Z"/>
270
270
  </svg>
271
- `,hE=Z.createElement("template");hE.innerHTML=`
271
+ `,mE=Z.createElement("template");mE.innerHTML=`
272
272
  <style>
273
273
  :host([${T.MEDIA_IS_AIRPLAYING}]) slot[name=icon] slot:not([name=exit]) {
274
274
  display: none !important;
@@ -286,17 +286,17 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
286
286
  </style>
287
287
 
288
288
  <slot name="icon">
289
- <slot name="enter">${Op}</slot>
290
- <slot name="exit">${Op}</slot>
289
+ <slot name="enter">${Fp}</slot>
290
+ <slot name="exit">${Fp}</slot>
291
291
  </slot>
292
- `;const uI=`
292
+ `;const hI=`
293
293
  <slot name="tooltip-enter">${Fe.ENTER_AIRPLAY}</slot>
294
294
  <slot name="tooltip-exit">${Fe.EXIT_AIRPLAY}</slot>
295
- `,Np=i=>{const e=i.mediaIsAirplaying?Et.EXIT_AIRPLAY():Et.ENTER_AIRPLAY();i.setAttribute("aria-label",e)};class cI extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_AIRPLAYING,T.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:hE,tooltipContent:uI,...e})}connectedCallback(){super.connectedCallback(),Np(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_IS_AIRPLAYING&&Np(this)}get mediaIsAirplaying(){return at(this,T.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){ot(this,T.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return Qe(this,T.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){Ze(this,T.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){const e=new R.CustomEvent(j.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}}R.customElements.get("media-airplay-button")||R.customElements.define("media-airplay-button",cI);const hI=`<svg aria-hidden="true" viewBox="0 0 26 24">
295
+ `,Up=i=>{const e=i.mediaIsAirplaying?Et.EXIT_AIRPLAY():Et.ENTER_AIRPLAY();i.setAttribute("aria-label",e)};class fI extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_AIRPLAYING,T.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:mE,tooltipContent:hI,...e})}connectedCallback(){super.connectedCallback(),Up(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_IS_AIRPLAYING&&Up(this)}get mediaIsAirplaying(){return at(this,T.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){ot(this,T.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return Qe(this,T.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){Ze(this,T.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){const e=new R.CustomEvent(j.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}}R.customElements.get("media-airplay-button")||R.customElements.define("media-airplay-button",fI);const mI=`<svg aria-hidden="true" viewBox="0 0 26 24">
296
296
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
297
- </svg>`,fI=`<svg aria-hidden="true" viewBox="0 0 26 24">
297
+ </svg>`,pI=`<svg aria-hidden="true" viewBox="0 0 26 24">
298
298
  <path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/>
299
- </svg>`,fE=Z.createElement("template");fE.innerHTML=`
299
+ </svg>`,pE=Z.createElement("template");pE.innerHTML=`
300
300
  <style>
301
301
  :host([aria-checked="true"]) slot[name=off] {
302
302
  display: none !important;
@@ -314,13 +314,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
314
314
  </style>
315
315
 
316
316
  <slot name="icon">
317
- <slot name="on">${hI}</slot>
318
- <slot name="off">${fI}</slot>
317
+ <slot name="on">${mI}</slot>
318
+ <slot name="off">${pI}</slot>
319
319
  </slot>
320
- `;const mI=`
320
+ `;const gI=`
321
321
  <slot name="tooltip-enable">${Fe.ENABLE_CAPTIONS}</slot>
322
322
  <slot name="tooltip-disable">${Fe.DISABLE_CAPTIONS}</slot>
323
- `,Fp=i=>{i.setAttribute("aria-checked",iE(i).toString())};class pI extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:fE,tooltipContent:mI,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",Rt.CLOSED_CAPTIONS()),Fp(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_SUBTITLES_SHOWING&&Fp(this)}get mediaSubtitlesList(){return Up(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){$p(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return Up(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){$p(this,T.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new R.CustomEvent(j.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}}const Up=(i,e)=>{const t=i.getAttribute(e);return t?Od(t):[]},$p=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}const r=Oa(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};R.customElements.get("media-captions-button")||R.customElements.define("media-captions-button",pI);const gI='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',vI='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',mE=Z.createElement("template");mE.innerHTML=`
323
+ `,$p=i=>{i.setAttribute("aria-checked",sE(i).toString())};class vI extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:pE,tooltipContent:gI,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",Rt.CLOSED_CAPTIONS()),$p(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_SUBTITLES_SHOWING&&$p(this)}get mediaSubtitlesList(){return Bp(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){Gp(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return Bp(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){Gp(this,T.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new R.CustomEvent(j.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}}const Bp=(i,e)=>{const t=i.getAttribute(e);return t?Fd(t):[]},Gp=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}const r=Na(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};R.customElements.get("media-captions-button")||R.customElements.define("media-captions-button",vI);const EI='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',yI='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',gE=Z.createElement("template");gE.innerHTML=`
324
324
  <style>
325
325
  :host([${T.MEDIA_IS_CASTING}]) slot[name=icon] slot:not([name=exit]) {
326
326
  display: none !important;
@@ -338,13 +338,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
338
338
  </style>
339
339
 
340
340
  <slot name="icon">
341
- <slot name="enter">${gI}</slot>
342
- <slot name="exit">${vI}</slot>
341
+ <slot name="enter">${EI}</slot>
342
+ <slot name="exit">${yI}</slot>
343
343
  </slot>
344
- `;const EI=`
344
+ `;const bI=`
345
345
  <slot name="tooltip-enter">${Fe.START_CAST}</slot>
346
346
  <slot name="tooltip-exit">${Fe.STOP_CAST}</slot>
347
- `,Bp=i=>{const e=i.mediaIsCasting?Et.EXIT_CAST():Et.ENTER_CAST();i.setAttribute("aria-label",e)};class yI extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_CASTING,T.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:mE,tooltipContent:EI,...e})}connectedCallback(){super.connectedCallback(),Bp(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_IS_CASTING&&Bp(this)}get mediaIsCasting(){return at(this,T.MEDIA_IS_CASTING)}set mediaIsCasting(e){ot(this,T.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return Qe(this,T.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){Ze(this,T.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){const e=this.mediaIsCasting?j.MEDIA_EXIT_CAST_REQUEST:j.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}}R.customElements.get("media-cast-button")||R.customElements.define("media-cast-button",yI);var Tf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},sn=(i,e,t)=>(Tf(i,e,"read from private field"),t?t.call(i):e.get(i)),Tr=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},pE=(i,e,t,r)=>(Tf(i,e,"write to private field"),e.set(i,t),t),wn=(i,e,t)=>(Tf(i,e,"access private method"),t),Fa,us,bc,gE,Tc,vE,_c,EE,Ac,yE,Sc,bE;const TE=Z.createElement("template");TE.innerHTML=`
347
+ `,Hp=i=>{const e=i.mediaIsCasting?Et.EXIT_CAST():Et.ENTER_CAST();i.setAttribute("aria-label",e)};class TI extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_CASTING,T.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:gE,tooltipContent:bI,...e})}connectedCallback(){super.connectedCallback(),Hp(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_IS_CASTING&&Hp(this)}get mediaIsCasting(){return at(this,T.MEDIA_IS_CASTING)}set mediaIsCasting(e){ot(this,T.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return Qe(this,T.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){Ze(this,T.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){const e=this.mediaIsCasting?j.MEDIA_EXIT_CAST_REQUEST:j.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}}R.customElements.get("media-cast-button")||R.customElements.define("media-cast-button",TI);var Af=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},nn=(i,e,t)=>(Af(i,e,"read from private field"),t?t.call(i):e.get(i)),Tr=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},vE=(i,e,t,r)=>(Af(i,e,"write to private field"),e.set(i,t),t),Cn=(i,e,t)=>(Af(i,e,"access private method"),t),Ua,us,_c,EE,Ac,yE,Sc,bE,xc,TE,kc,_E;const AE=Z.createElement("template");AE.innerHTML=`
348
348
  <style>
349
349
  :host {
350
350
  font: var(--media-font,
@@ -381,7 +381,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
381
381
  }
382
382
  </style>
383
383
  <slot></slot>
384
- `;const _u={HIDDEN:"hidden",ANCHOR:"anchor"};class _E extends R.HTMLElement{constructor(){super(),Tr(this,bc),Tr(this,Tc),Tr(this,_c),Tr(this,Ac),Tr(this,Sc),Tr(this,Fa,null),Tr(this,us,null),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.addEventListener("invoke",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this)}static get observedAttributes(){return[_u.HIDDEN,_u.ANCHOR]}handleEvent(e){switch(e.type){case"invoke":wn(this,_c,EE).call(this,e);break;case"focusout":wn(this,Ac,yE).call(this,e);break;case"keydown":wn(this,Sc,bE).call(this,e);break}}connectedCallback(){this.role||(this.role="dialog")}attributeChangedCallback(e,t,r){e===_u.HIDDEN&&r!==t&&(this.hidden?wn(this,Tc,vE).call(this):wn(this,bc,gE).call(this))}focus(){pE(this,Fa,ff());const e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}get keysUsed(){return["Escape","Tab"]}}Fa=new WeakMap;us=new WeakMap;bc=new WeakSet;gE=function(){var i;(i=sn(this,us))==null||i.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0})};Tc=new WeakSet;vE=function(){var i;(i=sn(this,us))==null||i.setAttribute("aria-expanded","false")};_c=new WeakSet;EE=function(i){pE(this,us,i.relatedTarget),Vi(this,i.relatedTarget)||(this.hidden=!this.hidden)};Ac=new WeakSet;yE=function(i){var e;Vi(this,i.relatedTarget)||((e=sn(this,Fa))==null||e.focus(),sn(this,us)&&sn(this,us)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};Sc=new WeakSet;bE=function(i){var e,t,r,s,n;const{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;o||l||d||this.keysUsed.includes(a)&&(i.preventDefault(),i.stopPropagation(),a==="Tab"?(i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(s=(r=this.nextElementSibling)==null?void 0:r.focus)==null||s.call(r),this.blur()):a==="Escape"&&((n=sn(this,Fa))==null||n.focus(),this.hidden=!0))};_E.template=TE;R.customElements.get("media-chrome-dialog")||R.customElements.define("media-chrome-dialog",_E);var _f=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},De=(i,e,t)=>(_f(i,e,"read from private field"),t?t.call(i):e.get(i)),ct=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ji=(i,e,t,r)=>(_f(i,e,"write to private field"),e.set(i,t),t),Kt=(i,e,t)=>(_f(i,e,"access private method"),t),ni,Fd,Wo,Ko,Vt,dd,Vo,qo,Yo,Af,AE,jo,xc,zo,kc,ud,Sf,Lc,SE,Ic,xE,Rc,kE,wc,LE;const IE=Z.createElement("template");IE.innerHTML=`
384
+ `;const Su={HIDDEN:"hidden",ANCHOR:"anchor"};class SE extends R.HTMLElement{constructor(){super(),Tr(this,_c),Tr(this,Ac),Tr(this,Sc),Tr(this,xc),Tr(this,kc),Tr(this,Ua,null),Tr(this,us,null),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.addEventListener("invoke",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this)}static get observedAttributes(){return[Su.HIDDEN,Su.ANCHOR]}handleEvent(e){switch(e.type){case"invoke":Cn(this,Sc,bE).call(this,e);break;case"focusout":Cn(this,xc,TE).call(this,e);break;case"keydown":Cn(this,kc,_E).call(this,e);break}}connectedCallback(){this.role||(this.role="dialog")}attributeChangedCallback(e,t,r){e===Su.HIDDEN&&r!==t&&(this.hidden?Cn(this,Ac,yE).call(this):Cn(this,_c,EE).call(this))}focus(){vE(this,Ua,pf());const e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}get keysUsed(){return["Escape","Tab"]}}Ua=new WeakMap;us=new WeakMap;_c=new WeakSet;EE=function(){var i;(i=nn(this,us))==null||i.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0})};Ac=new WeakSet;yE=function(){var i;(i=nn(this,us))==null||i.setAttribute("aria-expanded","false")};Sc=new WeakSet;bE=function(i){vE(this,us,i.relatedTarget),Vi(this,i.relatedTarget)||(this.hidden=!this.hidden)};xc=new WeakSet;TE=function(i){var e;Vi(this,i.relatedTarget)||((e=nn(this,Ua))==null||e.focus(),nn(this,us)&&nn(this,us)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};kc=new WeakSet;_E=function(i){var e,t,r,s,n;const{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;o||l||d||this.keysUsed.includes(a)&&(i.preventDefault(),i.stopPropagation(),a==="Tab"?(i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(s=(r=this.nextElementSibling)==null?void 0:r.focus)==null||s.call(r),this.blur()):a==="Escape"&&((n=nn(this,Ua))==null||n.focus(),this.hidden=!0))};SE.template=AE;R.customElements.get("media-chrome-dialog")||R.customElements.define("media-chrome-dialog",SE);var Sf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},De=(i,e,t)=>(Sf(i,e,"read from private field"),t?t.call(i):e.get(i)),ct=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ji=(i,e,t,r)=>(Sf(i,e,"write to private field"),e.set(i,t),t),Kt=(i,e,t)=>(Sf(i,e,"access private method"),t),ni,$d,Vo,qo,Vt,cd,Yo,jo,zo,xf,xE,Xo,Lc,Qo,Ic,hd,kf,Rc,kE,wc,LE,Cc,IE,Dc,RE;const wE=Z.createElement("template");wE.innerHTML=`
385
385
  <style>
386
386
  :host {
387
387
  --_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
@@ -617,7 +617,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
617
617
  <input id="range" type="range" min="0" max="1" step="any" value="0">
618
618
  </div>
619
619
  <div id="rightgap"></div>
620
- `;class xf extends R.HTMLElement{constructor(){super(),ct(this,Af),ct(this,jo),ct(this,zo),ct(this,ud),ct(this,Lc),ct(this,Ic),ct(this,Rc),ct(this,wc),ct(this,ni,void 0),ct(this,Fd,void 0),ct(this,Wo,void 0),ct(this,Ko,void 0),ct(this,Vt,{}),ct(this,dd,[]),ct(this,Vo,()=>{if(this.range.matches(":focus-visible")){const{style:e}=je(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),ct(this,qo,()=>{const{style:e}=je(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow")}),ct(this,Yo,()=>{const e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(IE.content.cloneNode(!0))),this.container=this.shadowRoot.querySelector("#container"),Ji(this,Wo,this.shadowRoot.querySelector("#startpoint")),Ji(this,Ko,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance")}static get observedAttributes(){return["disabled","aria-disabled",Te.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===Te.MEDIA_CONTROLLER?(t&&((n=(s=De(this,ni))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ji(this,ni,null)),r&&this.isConnected&&(Ji(this,ni,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=De(this,ni))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==r)&&(r==null?(this.range.removeAttribute(e),Kt(this,jo,xc).call(this)):(this.range.setAttribute(e,r),Kt(this,zo,kc).call(this)))}connectedCallback(){var e,t,r;const{style:s}=je(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),De(this,Vt).pointer=je(this.shadowRoot,"#pointer"),De(this,Vt).progress=je(this.shadowRoot,"#progress"),De(this,Vt).thumb=je(this.shadowRoot,"#thumb");const n=this.getAttribute(Te.MEDIA_CONTROLLER);n&&(Ji(this,ni,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=De(this,ni))==null?void 0:t.associateElement)==null||r.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",De(this,Vo)),this.shadowRoot.addEventListener("focusout",De(this,qo)),Kt(this,jo,xc).call(this),vn(this.container,De(this,Yo))}disconnectedCallback(){var e,t;Kt(this,zo,kc).call(this),(t=(e=De(this,ni))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ji(this,ni,null),this.shadowRoot.removeEventListener("focusin",De(this,Vo)),this.shadowRoot.removeEventListener("focusout",De(this,qo)),Ca(this.container,De(this,Yo))}updatePointerBar(e){var t;(t=De(this,Vt).pointer)==null||t.style.setProperty("width",`${this.getPointerRatio(e)*100}%`)}updateBar(){var e,t;const r=this.range.valueAsNumber*100;(e=De(this,Vt).progress)==null||e.style.setProperty("width",`${r}%`),(t=De(this,Vt).thumb)==null||t.style.setProperty("left",`${r}%`)}updateSegments(e){const t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",this.container.classList.toggle("segments",!!(e!=null&&e.length)),!(e!=null&&e.length))return;De(this,Vt).activeSegment=mf(this.shadowRoot,"#segments-clipping rect:nth-child(0)");const r=[...new Set([+this.range.min,...e.flatMap(n=>[n.start,n.end]),+this.range.max])];Ji(this,dd,[...r]);const s=r.pop();for(const[n,a]of r.entries()){const[o,l]=[n===0,n===r.length-1],d=o?"calc(var(--segments-gap) / -1)":`${a*100}%`,c=`calc(${((l?s:r[n+1])-a)*100}%${o||l?"":" - var(--segments-gap)"})`,h=Z.createElementNS("http://www.w3.org/2000/svg","rect"),f=je(this.shadowRoot,`#segments-clipping rect:nth-child(${n+1})`);f.style.setProperty("x",d),f.style.setProperty("width",c),t.append(h)}}getPointerRatio(e){const t=SL(e.clientX,e.clientY,De(this,Wo).getBoundingClientRect(),De(this,Ko).getBoundingClientRect());return Math.max(0,Math.min(1,t))}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"pointermove":Kt(this,wc,LE).call(this,e);break;case"input":this.updateBar();break;case"pointerenter":Kt(this,Lc,SE).call(this,e);break;case"pointerdown":Kt(this,ud,Sf).call(this,e);break;case"pointerup":Kt(this,Ic,xE).call(this);break;case"pointerleave":Kt(this,Rc,kE).call(this);break}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}}ni=new WeakMap;Fd=new WeakMap;Wo=new WeakMap;Ko=new WeakMap;Vt=new WeakMap;dd=new WeakMap;Vo=new WeakMap;qo=new WeakMap;Yo=new WeakMap;Af=new WeakSet;AE=function(i){const e=De(this,Vt).activeSegment;if(!e)return;const t=this.getPointerRatio(i),s=`#segments-clipping rect:nth-child(${De(this,dd).findIndex((n,a,o)=>{const l=o[a+1];return l!=null&&t>=n&&t<=l})+1})`;(e.selectorText!=s||!e.style.transform)&&(e.selectorText=s,e.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"))};jo=new WeakSet;xc=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))};zo=new WeakSet;kc=function(){var i,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(i=R.window)==null||i.removeEventListener("pointerup",this),(e=R.window)==null||e.removeEventListener("pointermove",this)};ud=new WeakSet;Sf=function(i){var e;Ji(this,Fd,i.composedPath().includes(this.range)),(e=R.window)==null||e.addEventListener("pointerup",this)};Lc=new WeakSet;SE=function(i){var e;i.pointerType!=="mouse"&&Kt(this,ud,Sf).call(this,i),this.addEventListener("pointerleave",this),(e=R.window)==null||e.addEventListener("pointermove",this)};Ic=new WeakSet;xE=function(){var i;(i=R.window)==null||i.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};Rc=new WeakSet;kE=function(){var i,e;this.removeEventListener("pointerleave",this),(i=R.window)==null||i.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled"),(e=De(this,Vt).activeSegment)==null||e.style.removeProperty("transform")};wc=new WeakSet;LE=function(i){this.toggleAttribute("dragging",i.buttons===1||i.pointerType!=="mouse"),this.updatePointerBar(i),Kt(this,Af,AE).call(this,i),this.dragging&&(i.pointerType!=="mouse"||!De(this,Fd))&&(this.range.disabled=!0,this.range.valueAsNumber=this.getPointerRatio(i),this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))};R.customElements.get("media-chrome-range")||R.customElements.define("media-chrome-range",xf);var RE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},fo=(i,e,t)=>(RE(i,e,"read from private field"),t?t.call(i):e.get(i)),bI=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},mo=(i,e,t,r)=>(RE(i,e,"write to private field"),e.set(i,t),t),ai;const wE=Z.createElement("template");wE.innerHTML=`
620
+ `;class Lf extends R.HTMLElement{constructor(){super(),ct(this,xf),ct(this,Xo),ct(this,Qo),ct(this,hd),ct(this,Rc),ct(this,wc),ct(this,Cc),ct(this,Dc),ct(this,ni,void 0),ct(this,$d,void 0),ct(this,Vo,void 0),ct(this,qo,void 0),ct(this,Vt,{}),ct(this,cd,[]),ct(this,Yo,()=>{if(this.range.matches(":focus-visible")){const{style:e}=je(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),ct(this,jo,()=>{const{style:e}=je(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow")}),ct(this,zo,()=>{const e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(wE.content.cloneNode(!0))),this.container=this.shadowRoot.querySelector("#container"),Ji(this,Vo,this.shadowRoot.querySelector("#startpoint")),Ji(this,qo,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance")}static get observedAttributes(){return["disabled","aria-disabled",Te.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===Te.MEDIA_CONTROLLER?(t&&((n=(s=De(this,ni))==null?void 0:s.unassociateElement)==null||n.call(s,this),Ji(this,ni,null)),r&&this.isConnected&&(Ji(this,ni,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=De(this,ni))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==r)&&(r==null?(this.range.removeAttribute(e),Kt(this,Xo,Lc).call(this)):(this.range.setAttribute(e,r),Kt(this,Qo,Ic).call(this)))}connectedCallback(){var e,t,r;const{style:s}=je(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),De(this,Vt).pointer=je(this.shadowRoot,"#pointer"),De(this,Vt).progress=je(this.shadowRoot,"#progress"),De(this,Vt).thumb=je(this.shadowRoot,"#thumb");const n=this.getAttribute(Te.MEDIA_CONTROLLER);n&&(Ji(this,ni,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=De(this,ni))==null?void 0:t.associateElement)==null||r.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",De(this,Yo)),this.shadowRoot.addEventListener("focusout",De(this,jo)),Kt(this,Xo,Lc).call(this),En(this.container,De(this,zo))}disconnectedCallback(){var e,t;Kt(this,Qo,Ic).call(this),(t=(e=De(this,ni))==null?void 0:e.unassociateElement)==null||t.call(e,this),Ji(this,ni,null),this.shadowRoot.removeEventListener("focusin",De(this,Yo)),this.shadowRoot.removeEventListener("focusout",De(this,jo)),Da(this.container,De(this,zo))}updatePointerBar(e){var t;(t=De(this,Vt).pointer)==null||t.style.setProperty("width",`${this.getPointerRatio(e)*100}%`)}updateBar(){var e,t;const r=this.range.valueAsNumber*100;(e=De(this,Vt).progress)==null||e.style.setProperty("width",`${r}%`),(t=De(this,Vt).thumb)==null||t.style.setProperty("left",`${r}%`)}updateSegments(e){const t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",this.container.classList.toggle("segments",!!(e!=null&&e.length)),!(e!=null&&e.length))return;De(this,Vt).activeSegment=gf(this.shadowRoot,"#segments-clipping rect:nth-child(0)");const r=[...new Set([+this.range.min,...e.flatMap(n=>[n.start,n.end]),+this.range.max])];Ji(this,cd,[...r]);const s=r.pop();for(const[n,a]of r.entries()){const[o,l]=[n===0,n===r.length-1],d=o?"calc(var(--segments-gap) / -1)":`${a*100}%`,c=`calc(${((l?s:r[n+1])-a)*100}%${o||l?"":" - var(--segments-gap)"})`,h=Z.createElementNS("http://www.w3.org/2000/svg","rect"),f=je(this.shadowRoot,`#segments-clipping rect:nth-child(${n+1})`);f.style.setProperty("x",d),f.style.setProperty("width",c),t.append(h)}}getPointerRatio(e){const t=kL(e.clientX,e.clientY,De(this,Vo).getBoundingClientRect(),De(this,qo).getBoundingClientRect());return Math.max(0,Math.min(1,t))}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"pointermove":Kt(this,Dc,RE).call(this,e);break;case"input":this.updateBar();break;case"pointerenter":Kt(this,Rc,kE).call(this,e);break;case"pointerdown":Kt(this,hd,kf).call(this,e);break;case"pointerup":Kt(this,wc,LE).call(this);break;case"pointerleave":Kt(this,Cc,IE).call(this);break}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}}ni=new WeakMap;$d=new WeakMap;Vo=new WeakMap;qo=new WeakMap;Vt=new WeakMap;cd=new WeakMap;Yo=new WeakMap;jo=new WeakMap;zo=new WeakMap;xf=new WeakSet;xE=function(i){const e=De(this,Vt).activeSegment;if(!e)return;const t=this.getPointerRatio(i),s=`#segments-clipping rect:nth-child(${De(this,cd).findIndex((n,a,o)=>{const l=o[a+1];return l!=null&&t>=n&&t<=l})+1})`;(e.selectorText!=s||!e.style.transform)&&(e.selectorText=s,e.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"))};Xo=new WeakSet;Lc=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))};Qo=new WeakSet;Ic=function(){var i,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(i=R.window)==null||i.removeEventListener("pointerup",this),(e=R.window)==null||e.removeEventListener("pointermove",this)};hd=new WeakSet;kf=function(i){var e;Ji(this,$d,i.composedPath().includes(this.range)),(e=R.window)==null||e.addEventListener("pointerup",this)};Rc=new WeakSet;kE=function(i){var e;i.pointerType!=="mouse"&&Kt(this,hd,kf).call(this,i),this.addEventListener("pointerleave",this),(e=R.window)==null||e.addEventListener("pointermove",this)};wc=new WeakSet;LE=function(){var i;(i=R.window)==null||i.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};Cc=new WeakSet;IE=function(){var i,e;this.removeEventListener("pointerleave",this),(i=R.window)==null||i.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled"),(e=De(this,Vt).activeSegment)==null||e.style.removeProperty("transform")};Dc=new WeakSet;RE=function(i){this.toggleAttribute("dragging",i.buttons===1||i.pointerType!=="mouse"),this.updatePointerBar(i),Kt(this,xf,xE).call(this,i),this.dragging&&(i.pointerType!=="mouse"||!De(this,$d))&&(this.range.disabled=!0,this.range.valueAsNumber=this.getPointerRatio(i),this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))};R.customElements.get("media-chrome-range")||R.customElements.define("media-chrome-range",Lf);var CE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},po=(i,e,t)=>(CE(i,e,"read from private field"),t?t.call(i):e.get(i)),_I=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},go=(i,e,t,r)=>(CE(i,e,"write to private field"),e.set(i,t),t),ai;const DE=Z.createElement("template");DE.innerHTML=`
621
621
  <style>
622
622
  :host {
623
623
 
@@ -643,7 +643,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
643
643
  </style>
644
644
 
645
645
  <slot></slot>
646
- `;class TI extends R.HTMLElement{constructor(){super(),bI(this,ai,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(wE.content.cloneNode(!0)))}static get observedAttributes(){return[Te.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===Te.MEDIA_CONTROLLER&&(t&&((n=(s=fo(this,ai))==null?void 0:s.unassociateElement)==null||n.call(s,this),mo(this,ai,null)),r&&this.isConnected&&(mo(this,ai,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=fo(this,ai))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;const s=this.getAttribute(Te.MEDIA_CONTROLLER);s&&(mo(this,ai,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=fo(this,ai))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=fo(this,ai))==null?void 0:e.unassociateElement)==null||t.call(e,this),mo(this,ai,null)}}ai=new WeakMap;R.customElements.get("media-control-bar")||R.customElements.define("media-control-bar",TI);var CE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},po=(i,e,t)=>(CE(i,e,"read from private field"),t?t.call(i):e.get(i)),_I=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},go=(i,e,t,r)=>(CE(i,e,"write to private field"),e.set(i,t),t),oi;const DE=Z.createElement("template");DE.innerHTML=`
646
+ `;class AI extends R.HTMLElement{constructor(){super(),_I(this,ai,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(DE.content.cloneNode(!0)))}static get observedAttributes(){return[Te.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===Te.MEDIA_CONTROLLER&&(t&&((n=(s=po(this,ai))==null?void 0:s.unassociateElement)==null||n.call(s,this),go(this,ai,null)),r&&this.isConnected&&(go(this,ai,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=po(this,ai))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;const s=this.getAttribute(Te.MEDIA_CONTROLLER);s&&(go(this,ai,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=po(this,ai))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=po(this,ai))==null?void 0:e.unassociateElement)==null||t.call(e,this),go(this,ai,null)}}ai=new WeakMap;R.customElements.get("media-control-bar")||R.customElements.define("media-control-bar",AI);var ME=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},vo=(i,e,t)=>(ME(i,e,"read from private field"),t?t.call(i):e.get(i)),SI=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Eo=(i,e,t,r)=>(ME(i,e,"write to private field"),e.set(i,t),t),oi;const PE=Z.createElement("template");PE.innerHTML=`
647
647
  <style>
648
648
  :host {
649
649
  font: var(--media-font,
@@ -676,11 +676,11 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
676
676
  }
677
677
  </style>
678
678
  <slot></slot>
679
- `;class Ya extends R.HTMLElement{constructor(){super(),_I(this,oi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(DE.content.cloneNode(!0)))}static get observedAttributes(){return[Te.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===Te.MEDIA_CONTROLLER&&(t&&((n=(s=po(this,oi))==null?void 0:s.unassociateElement)==null||n.call(s,this),go(this,oi,null)),r&&this.isConnected&&(go(this,oi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=po(this,oi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;const{style:s}=je(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);const n=this.getAttribute(Te.MEDIA_CONTROLLER);n&&(go(this,oi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=po(this,oi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=po(this,oi))==null?void 0:e.unassociateElement)==null||t.call(e,this),go(this,oi,null)}}oi=new WeakMap;R.customElements.get("media-text-display")||R.customElements.define("media-text-display",Ya);var ME=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Gp=(i,e,t)=>(ME(i,e,"read from private field"),t?t.call(i):e.get(i)),AI=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},SI=(i,e,t,r)=>(ME(i,e,"write to private field"),e.set(i,t),t),jn;class xI extends Ya{constructor(){super(),AI(this,jn,void 0),SI(this,jn,this.shadowRoot.querySelector("slot")),Gp(this,jn).textContent=rs(0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_DURATION]}attributeChangedCallback(e,t,r){e===T.MEDIA_DURATION&&(Gp(this,jn).textContent=rs(+r)),super.attributeChangedCallback(e,t,r)}get mediaDuration(){return Ne(this,T.MEDIA_DURATION)}set mediaDuration(e){ze(this,T.MEDIA_DURATION,e)}}jn=new WeakMap;R.customElements.get("media-duration-display")||R.customElements.define("media-duration-display",xI);const kI=`<svg aria-hidden="true" viewBox="0 0 26 24">
679
+ `;class ja extends R.HTMLElement{constructor(){super(),SI(this,oi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(PE.content.cloneNode(!0)))}static get observedAttributes(){return[Te.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===Te.MEDIA_CONTROLLER&&(t&&((n=(s=vo(this,oi))==null?void 0:s.unassociateElement)==null||n.call(s,this),Eo(this,oi,null)),r&&this.isConnected&&(Eo(this,oi,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=vo(this,oi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;const{style:s}=je(this.shadowRoot,":host");s.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);const n=this.getAttribute(Te.MEDIA_CONTROLLER);n&&(Eo(this,oi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(r=(t=vo(this,oi))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=vo(this,oi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Eo(this,oi,null)}}oi=new WeakMap;R.customElements.get("media-text-display")||R.customElements.define("media-text-display",ja);var OE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Wp=(i,e,t)=>(OE(i,e,"read from private field"),t?t.call(i):e.get(i)),xI=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},kI=(i,e,t,r)=>(OE(i,e,"write to private field"),e.set(i,t),t),zn;class LI extends ja{constructor(){super(),xI(this,zn,void 0),kI(this,zn,this.shadowRoot.querySelector("slot")),Wp(this,zn).textContent=rs(0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_DURATION]}attributeChangedCallback(e,t,r){e===T.MEDIA_DURATION&&(Wp(this,zn).textContent=rs(+r)),super.attributeChangedCallback(e,t,r)}get mediaDuration(){return Ne(this,T.MEDIA_DURATION)}set mediaDuration(e){ze(this,T.MEDIA_DURATION,e)}}zn=new WeakMap;R.customElements.get("media-duration-display")||R.customElements.define("media-duration-display",LI);const II=`<svg aria-hidden="true" viewBox="0 0 26 24">
680
680
  <path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
681
- </svg>`,LI=`<svg aria-hidden="true" viewBox="0 0 26 24">
681
+ </svg>`,RI=`<svg aria-hidden="true" viewBox="0 0 26 24">
682
682
  <path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
683
- </svg>`,PE=Z.createElement("template");PE.innerHTML=`
683
+ </svg>`,NE=Z.createElement("template");NE.innerHTML=`
684
684
  <style>
685
685
  :host([${T.MEDIA_IS_FULLSCREEN}]) slot[name=icon] slot:not([name=exit]) {
686
686
  display: none !important;
@@ -698,13 +698,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
698
698
  </style>
699
699
 
700
700
  <slot name="icon">
701
- <slot name="enter">${kI}</slot>
702
- <slot name="exit">${LI}</slot>
701
+ <slot name="enter">${II}</slot>
702
+ <slot name="exit">${RI}</slot>
703
703
  </slot>
704
- `;const II=`
704
+ `;const wI=`
705
705
  <slot name="tooltip-enter">${Fe.ENTER_FULLSCREEN}</slot>
706
706
  <slot name="tooltip-exit">${Fe.EXIT_FULLSCREEN}</slot>
707
- `,Hp=i=>{const e=i.mediaIsFullscreen?Et.EXIT_FULLSCREEN():Et.ENTER_FULLSCREEN();i.setAttribute("aria-label",e)};class RI extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_FULLSCREEN,T.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:PE,tooltipContent:II,...e})}connectedCallback(){super.connectedCallback(),Hp(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_IS_FULLSCREEN&&Hp(this)}get mediaFullscreenUnavailable(){return Qe(this,T.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){Ze(this,T.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return at(this,T.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){ot(this,T.MEDIA_IS_FULLSCREEN,e)}handleClick(){const e=this.mediaIsFullscreen?j.MEDIA_EXIT_FULLSCREEN_REQUEST:j.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}}R.customElements.get("media-fullscreen-button")||R.customElements.define("media-fullscreen-button",RI);const{MEDIA_TIME_IS_LIVE:Xo,MEDIA_PAUSED:ba}=T,{MEDIA_SEEK_TO_LIVE_REQUEST:wI,MEDIA_PLAY_REQUEST:CI}=j,DI='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',OE=Z.createElement("template");OE.innerHTML=`
707
+ `,Kp=i=>{const e=i.mediaIsFullscreen?Et.EXIT_FULLSCREEN():Et.ENTER_FULLSCREEN();i.setAttribute("aria-label",e)};class CI extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_FULLSCREEN,T.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:NE,tooltipContent:wI,...e})}connectedCallback(){super.connectedCallback(),Kp(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_IS_FULLSCREEN&&Kp(this)}get mediaFullscreenUnavailable(){return Qe(this,T.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){Ze(this,T.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return at(this,T.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){ot(this,T.MEDIA_IS_FULLSCREEN,e)}handleClick(){const e=this.mediaIsFullscreen?j.MEDIA_EXIT_FULLSCREEN_REQUEST:j.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}}R.customElements.get("media-fullscreen-button")||R.customElements.define("media-fullscreen-button",CI);const{MEDIA_TIME_IS_LIVE:Zo,MEDIA_PAUSED:Ta}=T,{MEDIA_SEEK_TO_LIVE_REQUEST:DI,MEDIA_PLAY_REQUEST:MI}=j,PI='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',FE=Z.createElement("template");FE.innerHTML=`
708
708
  <style>
709
709
  :host { --media-tooltip-display: none; }
710
710
 
@@ -716,22 +716,22 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
716
716
  color: var(--media-live-button-icon-color, rgb(140, 140, 140));
717
717
  }
718
718
 
719
- :host([${Xo}]:not([${ba}])) slot[name=indicator] > *,
720
- :host([${Xo}]:not([${ba}])) ::slotted([slot=indicator]) {
719
+ :host([${Zo}]:not([${Ta}])) slot[name=indicator] > *,
720
+ :host([${Zo}]:not([${Ta}])) ::slotted([slot=indicator]) {
721
721
  fill: var(--media-live-button-indicator-color, rgb(255, 0, 0));
722
722
  color: var(--media-live-button-indicator-color, rgb(255, 0, 0));
723
723
  }
724
724
 
725
- :host([${Xo}]:not([${ba}])) {
725
+ :host([${Zo}]:not([${Ta}])) {
726
726
  cursor: not-allowed;
727
727
  }
728
728
 
729
729
  </style>
730
730
 
731
- <slot name="indicator">${DI}</slot>
731
+ <slot name="indicator">${PI}</slot>
732
732
 
733
733
  <slot name="spacer">&nbsp;</slot><slot name="text">LIVE</slot>
734
- `;const Wp=i=>{const e=i.mediaPaused||!i.mediaTimeIsLive,t=e?Et.SEEK_LIVE():Et.PLAYING_LIVE();i.setAttribute("aria-label",t),e?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true")};class MI extends wt{static get observedAttributes(){return[...super.observedAttributes,ba,Xo]}constructor(e={}){super({slotTemplate:OE,...e})}connectedCallback(){Wp(this),super.connectedCallback()}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),Wp(this)}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return at(this,T.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){ot(this,T.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new R.CustomEvent(wI,{composed:!0,bubbles:!0})),this.hasAttribute(ba)&&this.dispatchEvent(new R.CustomEvent(CI,{composed:!0,bubbles:!0})))}}R.customElements.get("media-live-button")||R.customElements.define("media-live-button",MI);var NE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Cn=(i,e,t)=>(NE(i,e,"read from private field"),t?t.call(i):e.get(i)),Kp=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Dn=(i,e,t,r)=>(NE(i,e,"write to private field"),e.set(i,t),t),li,Qo;const Vp={LOADING_DELAY:"loadingdelay"},FE=500,UE=Z.createElement("template"),PI=`
734
+ `;const Vp=i=>{const e=i.mediaPaused||!i.mediaTimeIsLive,t=e?Et.SEEK_LIVE():Et.PLAYING_LIVE();i.setAttribute("aria-label",t),e?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true")};class OI extends wt{static get observedAttributes(){return[...super.observedAttributes,Ta,Zo]}constructor(e={}){super({slotTemplate:FE,...e})}connectedCallback(){Vp(this),super.connectedCallback()}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),Vp(this)}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return at(this,T.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){ot(this,T.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new R.CustomEvent(DI,{composed:!0,bubbles:!0})),this.hasAttribute(Ta)&&this.dispatchEvent(new R.CustomEvent(MI,{composed:!0,bubbles:!0})))}}R.customElements.get("media-live-button")||R.customElements.define("media-live-button",OI);var UE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Dn=(i,e,t)=>(UE(i,e,"read from private field"),t?t.call(i):e.get(i)),qp=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Mn=(i,e,t,r)=>(UE(i,e,"write to private field"),e.set(i,t),t),li,Jo;const Yp={LOADING_DELAY:"loadingdelay"},$E=500,BE=Z.createElement("template"),NI=`
735
735
  <svg aria-hidden="true" viewBox="0 0 100 100">
736
736
  <path d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50">
737
737
  <animateTransform
@@ -744,13 +744,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
744
744
  repeatCount="indefinite" />
745
745
  </path>
746
746
  </svg>
747
- `;UE.innerHTML=`
747
+ `;BE.innerHTML=`
748
748
  <style>
749
749
  :host {
750
750
  display: var(--media-control-display, var(--media-loading-indicator-display, inline-block));
751
751
  vertical-align: middle;
752
752
  box-sizing: border-box;
753
- --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${FE}ms);
753
+ --_loading-indicator-delay: var(--media-loading-indicator-transition-delay, ${$E}ms);
754
754
  }
755
755
 
756
756
  #status {
@@ -789,15 +789,15 @@ svg, img, ::slotted(svg), ::slotted(img) {
789
789
  }
790
790
  </style>
791
791
 
792
- <slot name="icon">${PI}</slot>
792
+ <slot name="icon">${NI}</slot>
793
793
  <div id="status" role="status" aria-live="polite">${Rt.MEDIA_LOADING()}</div>
794
- `;class OI extends R.HTMLElement{constructor(){if(super(),Kp(this,li,void 0),Kp(this,Qo,FE),!this.shadowRoot){const e=this.attachShadow({mode:"open"}),t=UE.content.cloneNode(!0);e.appendChild(t)}}static get observedAttributes(){return[Te.MEDIA_CONTROLLER,T.MEDIA_PAUSED,T.MEDIA_LOADING,Vp.LOADING_DELAY]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===Vp.LOADING_DELAY&&t!==r?this.loadingDelay=Number(r):e===Te.MEDIA_CONTROLLER&&(t&&((n=(s=Cn(this,li))==null?void 0:s.unassociateElement)==null||n.call(s,this),Dn(this,li,null)),r&&this.isConnected&&(Dn(this,li,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Cn(this,li))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;const s=this.getAttribute(Te.MEDIA_CONTROLLER);s&&(Dn(this,li,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Cn(this,li))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Cn(this,li))==null?void 0:e.unassociateElement)==null||t.call(e,this),Dn(this,li,null)}get loadingDelay(){return Cn(this,Qo)}set loadingDelay(e){Dn(this,Qo,e);const{style:t}=je(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}get mediaLoading(){return at(this,T.MEDIA_LOADING)}set mediaLoading(e){ot(this,T.MEDIA_LOADING,e)}}li=new WeakMap;Qo=new WeakMap;R.customElements.get("media-loading-indicator")||R.customElements.define("media-loading-indicator",OI);const{MEDIA_VOLUME_LEVEL:_r}=T,NI=`<svg aria-hidden="true" viewBox="0 0 24 24">
794
+ `;class FI extends R.HTMLElement{constructor(){if(super(),qp(this,li,void 0),qp(this,Jo,$E),!this.shadowRoot){const e=this.attachShadow({mode:"open"}),t=BE.content.cloneNode(!0);e.appendChild(t)}}static get observedAttributes(){return[Te.MEDIA_CONTROLLER,T.MEDIA_PAUSED,T.MEDIA_LOADING,Yp.LOADING_DELAY]}attributeChangedCallback(e,t,r){var s,n,a,o,l;e===Yp.LOADING_DELAY&&t!==r?this.loadingDelay=Number(r):e===Te.MEDIA_CONTROLLER&&(t&&((n=(s=Dn(this,li))==null?void 0:s.unassociateElement)==null||n.call(s,this),Mn(this,li,null)),r&&this.isConnected&&(Mn(this,li,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Dn(this,li))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,r;const s=this.getAttribute(Te.MEDIA_CONTROLLER);s&&(Mn(this,li,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Dn(this,li))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Dn(this,li))==null?void 0:e.unassociateElement)==null||t.call(e,this),Mn(this,li,null)}get loadingDelay(){return Dn(this,Jo)}set loadingDelay(e){Mn(this,Jo,e);const{style:t}=je(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}get mediaLoading(){return at(this,T.MEDIA_LOADING)}set mediaLoading(e){ot(this,T.MEDIA_LOADING,e)}}li=new WeakMap;Jo=new WeakMap;R.customElements.get("media-loading-indicator")||R.customElements.define("media-loading-indicator",FI);const{MEDIA_VOLUME_LEVEL:_r}=T,UI=`<svg aria-hidden="true" viewBox="0 0 24 24">
795
795
  <path d="M16.5 12A4.5 4.5 0 0 0 14 8v2.18l2.45 2.45a4.22 4.22 0 0 0 .05-.63Zm2.5 0a6.84 6.84 0 0 1-.54 2.64L20 16.15A8.8 8.8 0 0 0 21 12a9 9 0 0 0-7-8.77v2.06A7 7 0 0 1 19 12ZM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25A6.92 6.92 0 0 1 14 18.7v2.06A9 9 0 0 0 17.69 19l2 2.05L21 19.73l-9-9L4.27 3ZM12 4 9.91 6.09 12 8.18V4Z"/>
796
- </svg>`,qp=`<svg aria-hidden="true" viewBox="0 0 24 24">
796
+ </svg>`,jp=`<svg aria-hidden="true" viewBox="0 0 24 24">
797
797
  <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4Z"/>
798
- </svg>`,FI=`<svg aria-hidden="true" viewBox="0 0 24 24">
798
+ </svg>`,$I=`<svg aria-hidden="true" viewBox="0 0 24 24">
799
799
  <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4ZM14 3.23v2.06a7 7 0 0 1 0 13.42v2.06a9 9 0 0 0 0-17.54Z"/>
800
- </svg>`,$E=Z.createElement("template");$E.innerHTML=`
800
+ </svg>`,GE=Z.createElement("template");GE.innerHTML=`
801
801
  <style>
802
802
 
803
803
  :host(:not([${_r}])) slot[name=icon] slot:not([name=high]),
@@ -824,17 +824,17 @@ svg, img, ::slotted(svg), ::slotted(img) {
824
824
  </style>
825
825
 
826
826
  <slot name="icon">
827
- <slot name="off">${NI}</slot>
828
- <slot name="low">${qp}</slot>
829
- <slot name="medium">${qp}</slot>
830
- <slot name="high">${FI}</slot>
827
+ <slot name="off">${UI}</slot>
828
+ <slot name="low">${jp}</slot>
829
+ <slot name="medium">${jp}</slot>
830
+ <slot name="high">${$I}</slot>
831
831
  </slot>
832
- `;const UI=`
832
+ `;const BI=`
833
833
  <slot name="tooltip-mute">${Fe.MUTE}</slot>
834
834
  <slot name="tooltip-unmute">${Fe.UNMUTE}</slot>
835
- `,Yp=i=>{const t=i.mediaVolumeLevel==="off"?Et.UNMUTE():Et.MUTE();i.setAttribute("aria-label",t)};class $I extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:$E,tooltipContent:UI,...e})}connectedCallback(){Yp(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===T.MEDIA_VOLUME_LEVEL&&Yp(this),super.attributeChangedCallback(e,t,r)}get mediaVolumeLevel(){return Qe(this,T.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){Ze(this,T.MEDIA_VOLUME_LEVEL,e)}handleClick(){const e=this.mediaVolumeLevel==="off"?j.MEDIA_UNMUTE_REQUEST:j.MEDIA_MUTE_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}}R.customElements.get("media-mute-button")||R.customElements.define("media-mute-button",$I);const jp=`<svg aria-hidden="true" viewBox="0 0 28 24">
835
+ `,zp=i=>{const t=i.mediaVolumeLevel==="off"?Et.UNMUTE():Et.MUTE();i.setAttribute("aria-label",t)};class GI extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:GE,tooltipContent:BI,...e})}connectedCallback(){zp(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===T.MEDIA_VOLUME_LEVEL&&zp(this),super.attributeChangedCallback(e,t,r)}get mediaVolumeLevel(){return Qe(this,T.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){Ze(this,T.MEDIA_VOLUME_LEVEL,e)}handleClick(){const e=this.mediaVolumeLevel==="off"?j.MEDIA_UNMUTE_REQUEST:j.MEDIA_MUTE_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}}R.customElements.get("media-mute-button")||R.customElements.define("media-mute-button",GI);const Xp=`<svg aria-hidden="true" viewBox="0 0 28 24">
836
836
  <path d="M24 3H4a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h20a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1Zm-1 16H5V5h18v14Zm-3-8h-7v5h7v-5Z"/>
837
- </svg>`,BE=Z.createElement("template");BE.innerHTML=`
837
+ </svg>`,HE=Z.createElement("template");HE.innerHTML=`
838
838
  <style>
839
839
  :host([${T.MEDIA_IS_PIP}]) slot[name=icon] slot:not([name=exit]) {
840
840
  display: none !important;
@@ -852,13 +852,13 @@ svg, img, ::slotted(svg), ::slotted(img) {
852
852
  </style>
853
853
 
854
854
  <slot name="icon">
855
- <slot name="enter">${jp}</slot>
856
- <slot name="exit">${jp}</slot>
855
+ <slot name="enter">${Xp}</slot>
856
+ <slot name="exit">${Xp}</slot>
857
857
  </slot>
858
- `;const BI=`
858
+ `;const HI=`
859
859
  <slot name="tooltip-enter">${Fe.ENTER_PIP}</slot>
860
860
  <slot name="tooltip-exit">${Fe.EXIT_PIP}</slot>
861
- `,zp=i=>{const e=i.mediaIsPip?Et.EXIT_PIP():Et.ENTER_PIP();i.setAttribute("aria-label",e)};class GI extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_PIP,T.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:BE,tooltipContent:BI,...e})}connectedCallback(){zp(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===T.MEDIA_IS_PIP&&zp(this),super.attributeChangedCallback(e,t,r)}get mediaPipUnavailable(){return Qe(this,T.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){Ze(this,T.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return at(this,T.MEDIA_IS_PIP)}set mediaIsPip(e){ot(this,T.MEDIA_IS_PIP,e)}handleClick(){const e=this.mediaIsPip?j.MEDIA_EXIT_PIP_REQUEST:j.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}}R.customElements.get("media-pip-button")||R.customElements.define("media-pip-button",GI);var HI=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},vo=(i,e,t)=>(HI(i,e,"read from private field"),t?t.call(i):e.get(i)),WI=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Cs;const Au={RATES:"rates"},GE=[1,1.2,1.5,1.7,2],zn=1,HE=Z.createElement("template");HE.innerHTML=`
861
+ `,Qp=i=>{const e=i.mediaIsPip?Et.EXIT_PIP():Et.ENTER_PIP();i.setAttribute("aria-label",e)};class WI extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_PIP,T.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:HE,tooltipContent:HI,...e})}connectedCallback(){Qp(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===T.MEDIA_IS_PIP&&Qp(this),super.attributeChangedCallback(e,t,r)}get mediaPipUnavailable(){return Qe(this,T.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){Ze(this,T.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return at(this,T.MEDIA_IS_PIP)}set mediaIsPip(e){ot(this,T.MEDIA_IS_PIP,e)}handleClick(){const e=this.mediaIsPip?j.MEDIA_EXIT_PIP_REQUEST:j.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}}R.customElements.get("media-pip-button")||R.customElements.define("media-pip-button",WI);var KI=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},yo=(i,e,t)=>(KI(i,e,"read from private field"),t?t.call(i):e.get(i)),VI=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ds;const xu={RATES:"rates"},WE=[1,1.2,1.5,1.7,2],Xn=1,KE=Z.createElement("template");KE.innerHTML=`
862
862
  <style>
863
863
  :host {
864
864
  min-width: 5ch;
@@ -866,11 +866,11 @@ svg, img, ::slotted(svg), ::slotted(img) {
866
866
  }
867
867
  </style>
868
868
  <slot name="icon"></slot>
869
- `;class KI extends wt{constructor(e={}){super({slotTemplate:HE,tooltipContent:Fe.PLAYBACK_RATE,...e}),WI(this,Cs,new Pd(this,Au.RATES,{defaultValue:GE})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${zn}x`}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,Au.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===Au.RATES&&(vo(this,Cs).value=r),e===T.MEDIA_PLAYBACK_RATE){const s=r?+r:Number.NaN,n=Number.isNaN(s)?zn:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Rt.PLAYBACK_RATE({playbackRate:n}))}}get rates(){return vo(this,Cs)}set rates(e){e?Array.isArray(e)&&(vo(this,Cs).value=e.join(" ")):vo(this,Cs).value=""}get mediaPlaybackRate(){return Ne(this,T.MEDIA_PLAYBACK_RATE,zn)}set mediaPlaybackRate(e){ze(this,T.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;const r=Array.from(this.rates.values(),a=>+a).sort((a,o)=>a-o),s=(t=(e=r.find(a=>a>this.mediaPlaybackRate))!=null?e:r[0])!=null?t:zn,n=new R.CustomEvent(j.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(n)}}Cs=new WeakMap;R.customElements.get("media-playback-rate-button")||R.customElements.define("media-playback-rate-button",KI);const VI=`<svg aria-hidden="true" viewBox="0 0 24 24">
869
+ `;class qI extends wt{constructor(e={}){super({slotTemplate:KE,tooltipContent:Fe.PLAYBACK_RATE,...e}),VI(this,Ds,new Nd(this,xu.RATES,{defaultValue:WE})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${Xn}x`}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,xu.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===xu.RATES&&(yo(this,Ds).value=r),e===T.MEDIA_PLAYBACK_RATE){const s=r?+r:Number.NaN,n=Number.isNaN(s)?Xn:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Rt.PLAYBACK_RATE({playbackRate:n}))}}get rates(){return yo(this,Ds)}set rates(e){e?Array.isArray(e)&&(yo(this,Ds).value=e.join(" ")):yo(this,Ds).value=""}get mediaPlaybackRate(){return Ne(this,T.MEDIA_PLAYBACK_RATE,Xn)}set mediaPlaybackRate(e){ze(this,T.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;const r=Array.from(this.rates.values(),a=>+a).sort((a,o)=>a-o),s=(t=(e=r.find(a=>a>this.mediaPlaybackRate))!=null?e:r[0])!=null?t:Xn,n=new R.CustomEvent(j.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:s});this.dispatchEvent(n)}}Ds=new WeakMap;R.customElements.get("media-playback-rate-button")||R.customElements.define("media-playback-rate-button",qI);const YI=`<svg aria-hidden="true" viewBox="0 0 24 24">
870
870
  <path d="m6 21 15-9L6 3v18Z"/>
871
- </svg>`,qI=`<svg aria-hidden="true" viewBox="0 0 24 24">
871
+ </svg>`,jI=`<svg aria-hidden="true" viewBox="0 0 24 24">
872
872
  <path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
873
- </svg>`,WE=Z.createElement("template");WE.innerHTML=`
873
+ </svg>`,VE=Z.createElement("template");VE.innerHTML=`
874
874
  <style>
875
875
  :host([${T.MEDIA_PAUSED}]) slot[name=pause],
876
876
  :host(:not([${T.MEDIA_PAUSED}])) slot[name=play] {
@@ -884,13 +884,13 @@ svg, img, ::slotted(svg), ::slotted(img) {
884
884
  </style>
885
885
 
886
886
  <slot name="icon">
887
- <slot name="play">${VI}</slot>
888
- <slot name="pause">${qI}</slot>
887
+ <slot name="play">${YI}</slot>
888
+ <slot name="pause">${jI}</slot>
889
889
  </slot>
890
- `;const YI=`
890
+ `;const zI=`
891
891
  <slot name="tooltip-play">${Fe.PLAY}</slot>
892
892
  <slot name="tooltip-pause">${Fe.PAUSE}</slot>
893
- `,Xp=i=>{const e=i.mediaPaused?Et.PLAY():Et.PAUSE();i.setAttribute("aria-label",e)};class jI extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PAUSED,T.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:WE,tooltipContent:YI,...e})}connectedCallback(){Xp(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===T.MEDIA_PAUSED&&Xp(this),super.attributeChangedCallback(e,t,r)}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}handleClick(){const e=this.mediaPaused?j.MEDIA_PLAY_REQUEST:j.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}}R.customElements.get("media-play-button")||R.customElements.define("media-play-button",jI);const ei={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},KE=Z.createElement("template");KE.innerHTML=`
893
+ `,Zp=i=>{const e=i.mediaPaused?Et.PLAY():Et.PAUSE();i.setAttribute("aria-label",e)};class XI extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PAUSED,T.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:VE,tooltipContent:zI,...e})}connectedCallback(){Zp(this),super.connectedCallback()}attributeChangedCallback(e,t,r){e===T.MEDIA_PAUSED&&Zp(this),super.attributeChangedCallback(e,t,r)}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}handleClick(){const e=this.mediaPaused?j.MEDIA_PLAY_REQUEST:j.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new R.CustomEvent(e,{composed:!0,bubbles:!0}))}}R.customElements.get("media-play-button")||R.customElements.define("media-play-button",XI);const ei={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},qE=Z.createElement("template");qE.innerHTML=`
894
894
  <style>
895
895
  :host {
896
896
  pointer-events: none;
@@ -912,7 +912,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
912
912
  </style>
913
913
 
914
914
  <img part="poster img" aria-hidden="true" id="image"/>
915
- `;const zI=i=>{i.style.removeProperty("background-image")},XI=(i,e)=>{i.style["background-image"]=`url('${e}')`};class QI extends R.HTMLElement{static get observedAttributes(){return[ei.PLACEHOLDER_SRC,ei.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(KE.content.cloneNode(!0))),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,r){e===ei.SRC&&(r==null?this.image.removeAttribute(ei.SRC):this.image.setAttribute(ei.SRC,r)),e===ei.PLACEHOLDER_SRC&&(r==null?zI(this.image):XI(this.image,r))}get placeholderSrc(){return Qe(this,ei.PLACEHOLDER_SRC)}set placeholderSrc(e){Ze(this,ei.SRC,e)}get src(){return Qe(this,ei.SRC)}set src(e){Ze(this,ei.SRC,e)}}R.customElements.get("media-poster-image")||R.customElements.define("media-poster-image",QI);var VE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ZI=(i,e,t)=>(VE(i,e,"read from private field"),t?t.call(i):e.get(i)),JI=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},eR=(i,e,t,r)=>(VE(i,e,"write to private field"),e.set(i,t),t),Zo;class tR extends Ya{constructor(){super(),JI(this,Zo,void 0),eR(this,Zo,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PREVIEW_CHAPTER]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_PREVIEW_CHAPTER&&r!==t&&r!=null&&(ZI(this,Zo).textContent=r,r!==""?this.setAttribute("aria-valuetext",`chapter: ${r}`):this.removeAttribute("aria-valuetext"))}get mediaPreviewChapter(){return Qe(this,T.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){Ze(this,T.MEDIA_PREVIEW_CHAPTER,e)}}Zo=new WeakMap;R.customElements.get("media-preview-chapter-display")||R.customElements.define("media-preview-chapter-display",tR);var qE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Eo=(i,e,t)=>(qE(i,e,"read from private field"),t?t.call(i):e.get(i)),iR=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},yo=(i,e,t,r)=>(qE(i,e,"write to private field"),e.set(i,t),t),di;const YE=Z.createElement("template");YE.innerHTML=`
915
+ `;const QI=i=>{i.style.removeProperty("background-image")},ZI=(i,e)=>{i.style["background-image"]=`url('${e}')`};class JI extends R.HTMLElement{static get observedAttributes(){return[ei.PLACEHOLDER_SRC,ei.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(qE.content.cloneNode(!0))),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,r){e===ei.SRC&&(r==null?this.image.removeAttribute(ei.SRC):this.image.setAttribute(ei.SRC,r)),e===ei.PLACEHOLDER_SRC&&(r==null?QI(this.image):ZI(this.image,r))}get placeholderSrc(){return Qe(this,ei.PLACEHOLDER_SRC)}set placeholderSrc(e){Ze(this,ei.SRC,e)}get src(){return Qe(this,ei.SRC)}set src(e){Ze(this,ei.SRC,e)}}R.customElements.get("media-poster-image")||R.customElements.define("media-poster-image",JI);var YE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},eR=(i,e,t)=>(YE(i,e,"read from private field"),t?t.call(i):e.get(i)),tR=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},iR=(i,e,t,r)=>(YE(i,e,"write to private field"),e.set(i,t),t),el;class rR extends ja{constructor(){super(),tR(this,el,void 0),iR(this,el,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PREVIEW_CHAPTER]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_PREVIEW_CHAPTER&&r!==t&&r!=null&&(eR(this,el).textContent=r,r!==""?this.setAttribute("aria-valuetext",`chapter: ${r}`):this.removeAttribute("aria-valuetext"))}get mediaPreviewChapter(){return Qe(this,T.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){Ze(this,T.MEDIA_PREVIEW_CHAPTER,e)}}el=new WeakMap;R.customElements.get("media-preview-chapter-display")||R.customElements.define("media-preview-chapter-display",rR);var jE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},bo=(i,e,t)=>(jE(i,e,"read from private field"),t?t.call(i):e.get(i)),sR=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},To=(i,e,t,r)=>(jE(i,e,"write to private field"),e.set(i,t),t),di;const zE=Z.createElement("template");zE.innerHTML=`
916
916
  <style>
917
917
  :host {
918
918
  box-sizing: border-box;
@@ -926,11 +926,11 @@ svg, img, ::slotted(svg), ::slotted(img) {
926
926
  }
927
927
  </style>
928
928
  <img crossorigin loading="eager" decoding="async">
929
- `;class rR extends R.HTMLElement{constructor(){super(),iR(this,di,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(YE.content.cloneNode(!0)))}static get observedAttributes(){return[Te.MEDIA_CONTROLLER,T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,r;const s=this.getAttribute(Te.MEDIA_CONTROLLER);s&&(yo(this,di,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=Eo(this,di))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Eo(this,di))==null?void 0:e.unassociateElement)==null||t.call(e,this),yo(this,di,null)}attributeChangedCallback(e,t,r){var s,n,a,o,l;[T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===Te.MEDIA_CONTROLLER&&(t&&((n=(s=Eo(this,di))==null?void 0:s.unassociateElement)==null||n.call(s,this),yo(this,di,null)),r&&this.isConnected&&(yo(this,di,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=Eo(this,di))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return Qe(this,T.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){Ze(this,T.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){const e=this.getAttribute(T.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(T.MEDIA_PREVIEW_COORDS);return}this.setAttribute(T.MEDIA_PREVIEW_COORDS,e.join(" "))}update(){const e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;const[r,s,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:u,minWidth:c,minHeight:h}=l,f=Math.min(parseInt(d)/n,parseInt(u)/a),m=Math.max(parseInt(c)/n,parseInt(h)/a),p=f<1,g=p?f:m>1?m:1,{style:E}=je(this.shadowRoot,":host"),y=je(this.shadowRoot,"img").style,b=this.shadowRoot.querySelector("img"),S=p?"min":"max";E.setProperty(`${S}-width`,"initial","important"),E.setProperty(`${S}-height`,"initial","important"),E.width=`${n*g}px`,E.height=`${a*g}px`;const _=()=>{y.width=`${this.imgWidth*g}px`,y.height=`${this.imgHeight*g}px`,y.display="block"};b.src!==o&&(b.onload=()=>{this.imgWidth=b.naturalWidth,this.imgHeight=b.naturalHeight,_()},b.src=o,_()),_(),y.transform=`translate(-${r*g}px, -${s*g}px)`}}di=new WeakMap;R.customElements.get("media-preview-thumbnail")||R.customElements.define("media-preview-thumbnail",rR);var jE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Qp=(i,e,t)=>(jE(i,e,"read from private field"),t?t.call(i):e.get(i)),sR=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},nR=(i,e,t,r)=>(jE(i,e,"write to private field"),e.set(i,t),t),Xn;class aR extends Ya{constructor(){super(),sR(this,Xn,void 0),nR(this,Xn,this.shadowRoot.querySelector("slot")),Qp(this,Xn).textContent=rs(0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_PREVIEW_TIME&&r!=null&&(Qp(this,Xn).textContent=rs(parseFloat(r)))}get mediaPreviewTime(){return Ne(this,T.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){ze(this,T.MEDIA_PREVIEW_TIME,e)}}Xn=new WeakMap;R.customElements.get("media-preview-time-display")||R.customElements.define("media-preview-time-display",aR);const As={SEEK_OFFSET:"seekoffset"},Jo=30,oR=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(2.18 19.87)">${Jo}</text><path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/></svg>`,zE=Z.createElement("template");zE.innerHTML=`
930
- <slot name="icon">${oR}</slot>
931
- `;const lR=0;class dR extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_CURRENT_TIME,As.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:zE,tooltipContent:Fe.SEEK_BACKWARD,...e})}connectedCallback(){this.seekOffset=Ne(this,As.SEEK_OFFSET,Jo),super.connectedCallback()}attributeChangedCallback(e,t,r){e===As.SEEK_OFFSET&&(this.seekOffset=Ne(this,As.SEEK_OFFSET,Jo)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return Ne(this,As.SEEK_OFFSET,Jo)}set seekOffset(e){ze(this,As.SEEK_OFFSET,e),this.setAttribute("aria-label",Et.SEEK_BACK_N_SECS({seekOffset:this.seekOffset})),Kv(Vv(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return Ne(this,T.MEDIA_CURRENT_TIME,lR)}set mediaCurrentTime(e){ze(this,T.MEDIA_CURRENT_TIME,e)}handleClick(){const e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new R.CustomEvent(j.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}R.customElements.get("media-seek-backward-button")||R.customElements.define("media-seek-backward-button",dR);const Ss={SEEK_OFFSET:"seekoffset"},el=30,uR=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(8.9 19.87)">${el}</text><path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/></svg>`,XE=Z.createElement("template");XE.innerHTML=`
932
- <slot name="icon">${uR}</slot>
933
- `;const cR=0;class hR extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_CURRENT_TIME,Ss.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:XE,tooltipContent:Fe.SEEK_FORWARD,...e})}connectedCallback(){this.seekOffset=Ne(this,Ss.SEEK_OFFSET,el),super.connectedCallback()}attributeChangedCallback(e,t,r){e===Ss.SEEK_OFFSET&&(this.seekOffset=Ne(this,Ss.SEEK_OFFSET,el)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return Ne(this,Ss.SEEK_OFFSET,el)}set seekOffset(e){ze(this,Ss.SEEK_OFFSET,e),this.setAttribute("aria-label",Et.SEEK_FORWARD_N_SECS({seekOffset:this.seekOffset})),Kv(Vv(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return Ne(this,T.MEDIA_CURRENT_TIME,cR)}set mediaCurrentTime(e){ze(this,T.MEDIA_CURRENT_TIME,e)}handleClick(){const e=this.mediaCurrentTime+this.seekOffset,t=new R.CustomEvent(j.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}R.customElements.get("media-seek-forward-button")||R.customElements.define("media-seek-forward-button",hR);var QE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Su=(i,e,t)=>(QE(i,e,"read from private field"),t?t.call(i):e.get(i)),fR=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},mR=(i,e,t,r)=>(QE(i,e,"write to private field"),e.set(i,t),t),Ds;const jt={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},Zp=[...Object.values(jt),T.MEDIA_CURRENT_TIME,T.MEDIA_DURATION,T.MEDIA_SEEKABLE],Jp=["Enter"," "],pR="&nbsp;/&nbsp;",e0=(i,{timesSep:e=pR}={})=>{var t,r;const s=i.hasAttribute(jt.REMAINING),n=i.hasAttribute(jt.SHOW_DURATION),a=(t=i.mediaCurrentTime)!=null?t:0,[,o]=(r=i.mediaSeekable)!=null?r:[];let l=0;Number.isFinite(i.mediaDuration)?l=i.mediaDuration:Number.isFinite(o)&&(l=o);const d=rs(s?0-(l-a):a);return n?`${d}${e}${rs(l)}`:d},gR="video not loaded, unknown time.",vR=i=>{var e;const t=i.mediaCurrentTime,[,r]=(e=i.mediaSeekable)!=null?e:[];let s=null;if(Number.isFinite(i.mediaDuration)?s=i.mediaDuration:Number.isFinite(r)&&(s=r),t==null||s===null){i.setAttribute("aria-valuetext",gR);return}const n=i.hasAttribute(jt.REMAINING),a=i.hasAttribute(jt.SHOW_DURATION),o=Ea(n?0-(s-t):t);if(!a){i.setAttribute("aria-valuetext",o);return}const l=Ea(s),d=`${o} of ${l}`;i.setAttribute("aria-valuetext",d)};class ER extends Ya{constructor(){super(),fR(this,Ds,void 0),mR(this,Ds,this.shadowRoot.querySelector("slot")),Su(this,Ds).innerHTML=`${e0(this)}`}static get observedAttributes(){return[...super.observedAttributes,...Zp,"disabled"]}connectedCallback(){const{style:e}=je(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","pointer"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))"),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",Rt.PLAYBACK_TIME());const t=r=>{const{key:s}=r;if(!Jp.includes(s)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay()};this.addEventListener("keydown",r=>{const{metaKey:s,altKey:n,key:a}=r;if(s||n||!Jp.includes(a)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),super.disconnectedCallback()}attributeChangedCallback(e,t,r){Zp.includes(e)?this.update():e==="disabled"&&r!==t&&(r==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,r)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return at(this,jt.REMAINING)}set remaining(e){ot(this,jt.REMAINING,e)}get showDuration(){return at(this,jt.SHOW_DURATION)}set showDuration(e){ot(this,jt.SHOW_DURATION,e)}get noToggle(){return at(this,jt.NO_TOGGLE)}set noToggle(e){ot(this,jt.NO_TOGGLE,e)}get mediaDuration(){return Ne(this,T.MEDIA_DURATION)}set mediaDuration(e){ze(this,T.MEDIA_DURATION,e)}get mediaCurrentTime(){return Ne(this,T.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){ze(this,T.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){const e=this.getAttribute(T.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(T.MEDIA_SEEKABLE);return}this.setAttribute(T.MEDIA_SEEKABLE,e.join(":"))}update(){const e=e0(this);vR(this),e!==Su(this,Ds).innerHTML&&(Su(this,Ds).innerHTML=e)}}Ds=new WeakMap;R.customElements.get("media-time-display")||R.customElements.define("media-time-display",ER);var ZE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},it=(i,e,t)=>(ZE(i,e,"read from private field"),t?t.call(i):e.get(i)),ti=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},It=(i,e,t,r)=>(ZE(i,e,"write to private field"),e.set(i,t),t),yR=(i,e,t,r)=>({set _(s){It(i,e,s)},get _(){return it(i,e,r)}}),Ms,tl,Ps,Qn,il,rl,sl,Os,Ir,nl;class bR{constructor(e,t,r){ti(this,Ms,void 0),ti(this,tl,void 0),ti(this,Ps,void 0),ti(this,Qn,void 0),ti(this,il,void 0),ti(this,rl,void 0),ti(this,sl,void 0),ti(this,Os,void 0),ti(this,Ir,0),ti(this,nl,(s=performance.now())=>{It(this,Ir,requestAnimationFrame(it(this,nl))),It(this,Qn,performance.now()-it(this,Ps));const n=1e3/this.fps;if(it(this,Qn)>n){It(this,Ps,s-it(this,Qn)%n);const a=1e3/((s-it(this,tl))/++yR(this,il)._),o=(s-it(this,rl))/1e3/this.duration;let l=it(this,sl)+o*this.playbackRate;l-it(this,Ms).valueAsNumber>0?It(this,Os,this.playbackRate/this.duration/a):(It(this,Os,.995*it(this,Os)),l=it(this,Ms).valueAsNumber+it(this,Os)),this.callback(l)}}),It(this,Ms,e),this.callback=t,this.fps=r}start(){it(this,Ir)===0&&(It(this,Ps,performance.now()),It(this,tl,it(this,Ps)),It(this,il,0),it(this,nl).call(this))}stop(){it(this,Ir)!==0&&(cancelAnimationFrame(it(this,Ir)),It(this,Ir,0))}update({start:e,duration:t,playbackRate:r}){const s=e-it(this,Ms).valueAsNumber,n=Math.abs(t-this.duration);(s>0||s<-.03||n>=.5)&&this.callback(e),It(this,sl,e),It(this,rl,performance.now()),this.duration=t,this.playbackRate=r}}Ms=new WeakMap;tl=new WeakMap;Ps=new WeakMap;Qn=new WeakMap;il=new WeakMap;rl=new WeakMap;sl=new WeakMap;Os=new WeakMap;Ir=new WeakMap;nl=new WeakMap;var kf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ye=(i,e,t)=>(kf(i,e,"read from private field"),t?t.call(i):e.get(i)),tt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ui=(i,e,t,r)=>(kf(i,e,"write to private field"),e.set(i,t),t),vt=(i,e,t)=>(kf(i,e,"access private method"),t),Ns,ss,cd,Ta,hd,al,Ua,$a,Fs,Us,Zn,Lf,JE,Cc,fd,If,md,Rf,pd,wf,Dc,ey,Ba,gd,Mc,ty;const TR="video not loaded, unknown time.",_R=i=>{const e=i.range,t=Ea(+ry(i)),r=Ea(+i.mediaSeekableEnd),s=t&&r?`${t} of ${r}`:TR;e.setAttribute("aria-valuetext",s)},iy=Z.createElement("template");iy.innerHTML=`
929
+ `;class nR extends R.HTMLElement{constructor(){super(),sR(this,di,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(zE.content.cloneNode(!0)))}static get observedAttributes(){return[Te.MEDIA_CONTROLLER,T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,r;const s=this.getAttribute(Te.MEDIA_CONTROLLER);s&&(To(this,di,(e=this.getRootNode())==null?void 0:e.getElementById(s)),(r=(t=bo(this,di))==null?void 0:t.associateElement)==null||r.call(t,this))}disconnectedCallback(){var e,t;(t=(e=bo(this,di))==null?void 0:e.unassociateElement)==null||t.call(e,this),To(this,di,null)}attributeChangedCallback(e,t,r){var s,n,a,o,l;[T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===Te.MEDIA_CONTROLLER&&(t&&((n=(s=bo(this,di))==null?void 0:s.unassociateElement)==null||n.call(s,this),To(this,di,null)),r&&this.isConnected&&(To(this,di,(a=this.getRootNode())==null?void 0:a.getElementById(r)),(l=(o=bo(this,di))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return Qe(this,T.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){Ze(this,T.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){const e=this.getAttribute(T.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(T.MEDIA_PREVIEW_COORDS);return}this.setAttribute(T.MEDIA_PREVIEW_COORDS,e.join(" "))}update(){const e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;const[r,s,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:u,minWidth:c,minHeight:h}=l,f=Math.min(parseInt(d)/n,parseInt(u)/a),m=Math.max(parseInt(c)/n,parseInt(h)/a),p=f<1,g=p?f:m>1?m:1,{style:E}=je(this.shadowRoot,":host"),y=je(this.shadowRoot,"img").style,b=this.shadowRoot.querySelector("img"),S=p?"min":"max";E.setProperty(`${S}-width`,"initial","important"),E.setProperty(`${S}-height`,"initial","important"),E.width=`${n*g}px`,E.height=`${a*g}px`;const _=()=>{y.width=`${this.imgWidth*g}px`,y.height=`${this.imgHeight*g}px`,y.display="block"};b.src!==o&&(b.onload=()=>{this.imgWidth=b.naturalWidth,this.imgHeight=b.naturalHeight,_()},b.src=o,_()),_(),y.transform=`translate(-${r*g}px, -${s*g}px)`}}di=new WeakMap;R.customElements.get("media-preview-thumbnail")||R.customElements.define("media-preview-thumbnail",nR);var XE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Jp=(i,e,t)=>(XE(i,e,"read from private field"),t?t.call(i):e.get(i)),aR=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},oR=(i,e,t,r)=>(XE(i,e,"write to private field"),e.set(i,t),t),Qn;class lR extends ja{constructor(){super(),aR(this,Qn,void 0),oR(this,Qn,this.shadowRoot.querySelector("slot")),Jp(this,Qn).textContent=rs(0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_PREVIEW_TIME&&r!=null&&(Jp(this,Qn).textContent=rs(parseFloat(r)))}get mediaPreviewTime(){return Ne(this,T.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){ze(this,T.MEDIA_PREVIEW_TIME,e)}}Qn=new WeakMap;R.customElements.get("media-preview-time-display")||R.customElements.define("media-preview-time-display",lR);const Ss={SEEK_OFFSET:"seekoffset"},tl=30,dR=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(2.18 19.87)">${tl}</text><path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/></svg>`,QE=Z.createElement("template");QE.innerHTML=`
930
+ <slot name="icon">${dR}</slot>
931
+ `;const uR=0;class cR extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_CURRENT_TIME,Ss.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:QE,tooltipContent:Fe.SEEK_BACKWARD,...e})}connectedCallback(){this.seekOffset=Ne(this,Ss.SEEK_OFFSET,tl),super.connectedCallback()}attributeChangedCallback(e,t,r){e===Ss.SEEK_OFFSET&&(this.seekOffset=Ne(this,Ss.SEEK_OFFSET,tl)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return Ne(this,Ss.SEEK_OFFSET,tl)}set seekOffset(e){ze(this,Ss.SEEK_OFFSET,e),this.setAttribute("aria-label",Et.SEEK_BACK_N_SECS({seekOffset:this.seekOffset})),qv(Yv(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return Ne(this,T.MEDIA_CURRENT_TIME,uR)}set mediaCurrentTime(e){ze(this,T.MEDIA_CURRENT_TIME,e)}handleClick(){const e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new R.CustomEvent(j.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}R.customElements.get("media-seek-backward-button")||R.customElements.define("media-seek-backward-button",cR);const xs={SEEK_OFFSET:"seekoffset"},il=30,hR=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(8.9 19.87)">${il}</text><path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/></svg>`,ZE=Z.createElement("template");ZE.innerHTML=`
932
+ <slot name="icon">${hR}</slot>
933
+ `;const fR=0;class mR extends wt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_CURRENT_TIME,xs.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:ZE,tooltipContent:Fe.SEEK_FORWARD,...e})}connectedCallback(){this.seekOffset=Ne(this,xs.SEEK_OFFSET,il),super.connectedCallback()}attributeChangedCallback(e,t,r){e===xs.SEEK_OFFSET&&(this.seekOffset=Ne(this,xs.SEEK_OFFSET,il)),super.attributeChangedCallback(e,t,r)}get seekOffset(){return Ne(this,xs.SEEK_OFFSET,il)}set seekOffset(e){ze(this,xs.SEEK_OFFSET,e),this.setAttribute("aria-label",Et.SEEK_FORWARD_N_SECS({seekOffset:this.seekOffset})),qv(Yv(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return Ne(this,T.MEDIA_CURRENT_TIME,fR)}set mediaCurrentTime(e){ze(this,T.MEDIA_CURRENT_TIME,e)}handleClick(){const e=this.mediaCurrentTime+this.seekOffset,t=new R.CustomEvent(j.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}R.customElements.get("media-seek-forward-button")||R.customElements.define("media-seek-forward-button",mR);var JE=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ku=(i,e,t)=>(JE(i,e,"read from private field"),t?t.call(i):e.get(i)),pR=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},gR=(i,e,t,r)=>(JE(i,e,"write to private field"),e.set(i,t),t),Ms;const jt={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},e0=[...Object.values(jt),T.MEDIA_CURRENT_TIME,T.MEDIA_DURATION,T.MEDIA_SEEKABLE],t0=["Enter"," "],vR="&nbsp;/&nbsp;",i0=(i,{timesSep:e=vR}={})=>{var t,r;const s=i.hasAttribute(jt.REMAINING),n=i.hasAttribute(jt.SHOW_DURATION),a=(t=i.mediaCurrentTime)!=null?t:0,[,o]=(r=i.mediaSeekable)!=null?r:[];let l=0;Number.isFinite(i.mediaDuration)?l=i.mediaDuration:Number.isFinite(o)&&(l=o);const d=rs(s?0-(l-a):a);return n?`${d}${e}${rs(l)}`:d},ER="video not loaded, unknown time.",yR=i=>{var e;const t=i.mediaCurrentTime,[,r]=(e=i.mediaSeekable)!=null?e:[];let s=null;if(Number.isFinite(i.mediaDuration)?s=i.mediaDuration:Number.isFinite(r)&&(s=r),t==null||s===null){i.setAttribute("aria-valuetext",ER);return}const n=i.hasAttribute(jt.REMAINING),a=i.hasAttribute(jt.SHOW_DURATION),o=ya(n?0-(s-t):t);if(!a){i.setAttribute("aria-valuetext",o);return}const l=ya(s),d=`${o} of ${l}`;i.setAttribute("aria-valuetext",d)};class bR extends ja{constructor(){super(),pR(this,Ms,void 0),gR(this,Ms,this.shadowRoot.querySelector("slot")),ku(this,Ms).innerHTML=`${i0(this)}`}static get observedAttributes(){return[...super.observedAttributes,...e0,"disabled"]}connectedCallback(){const{style:e}=je(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","pointer"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))"),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",Rt.PLAYBACK_TIME());const t=r=>{const{key:s}=r;if(!t0.includes(s)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay()};this.addEventListener("keydown",r=>{const{metaKey:s,altKey:n,key:a}=r;if(s||n||!t0.includes(a)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),super.disconnectedCallback()}attributeChangedCallback(e,t,r){e0.includes(e)?this.update():e==="disabled"&&r!==t&&(r==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,r)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return at(this,jt.REMAINING)}set remaining(e){ot(this,jt.REMAINING,e)}get showDuration(){return at(this,jt.SHOW_DURATION)}set showDuration(e){ot(this,jt.SHOW_DURATION,e)}get noToggle(){return at(this,jt.NO_TOGGLE)}set noToggle(e){ot(this,jt.NO_TOGGLE,e)}get mediaDuration(){return Ne(this,T.MEDIA_DURATION)}set mediaDuration(e){ze(this,T.MEDIA_DURATION,e)}get mediaCurrentTime(){return Ne(this,T.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){ze(this,T.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){const e=this.getAttribute(T.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(T.MEDIA_SEEKABLE);return}this.setAttribute(T.MEDIA_SEEKABLE,e.join(":"))}update(){const e=i0(this);yR(this),e!==ku(this,Ms).innerHTML&&(ku(this,Ms).innerHTML=e)}}Ms=new WeakMap;R.customElements.get("media-time-display")||R.customElements.define("media-time-display",bR);var ey=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},it=(i,e,t)=>(ey(i,e,"read from private field"),t?t.call(i):e.get(i)),ti=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},It=(i,e,t,r)=>(ey(i,e,"write to private field"),e.set(i,t),t),TR=(i,e,t,r)=>({set _(s){It(i,e,s)},get _(){return it(i,e,r)}}),Ps,rl,Os,Zn,sl,nl,al,Ns,Ir,ol;class _R{constructor(e,t,r){ti(this,Ps,void 0),ti(this,rl,void 0),ti(this,Os,void 0),ti(this,Zn,void 0),ti(this,sl,void 0),ti(this,nl,void 0),ti(this,al,void 0),ti(this,Ns,void 0),ti(this,Ir,0),ti(this,ol,(s=performance.now())=>{It(this,Ir,requestAnimationFrame(it(this,ol))),It(this,Zn,performance.now()-it(this,Os));const n=1e3/this.fps;if(it(this,Zn)>n){It(this,Os,s-it(this,Zn)%n);const a=1e3/((s-it(this,rl))/++TR(this,sl)._),o=(s-it(this,nl))/1e3/this.duration;let l=it(this,al)+o*this.playbackRate;l-it(this,Ps).valueAsNumber>0?It(this,Ns,this.playbackRate/this.duration/a):(It(this,Ns,.995*it(this,Ns)),l=it(this,Ps).valueAsNumber+it(this,Ns)),this.callback(l)}}),It(this,Ps,e),this.callback=t,this.fps=r}start(){it(this,Ir)===0&&(It(this,Os,performance.now()),It(this,rl,it(this,Os)),It(this,sl,0),it(this,ol).call(this))}stop(){it(this,Ir)!==0&&(cancelAnimationFrame(it(this,Ir)),It(this,Ir,0))}update({start:e,duration:t,playbackRate:r}){const s=e-it(this,Ps).valueAsNumber,n=Math.abs(t-this.duration);(s>0||s<-.03||n>=.5)&&this.callback(e),It(this,al,e),It(this,nl,performance.now()),this.duration=t,this.playbackRate=r}}Ps=new WeakMap;rl=new WeakMap;Os=new WeakMap;Zn=new WeakMap;sl=new WeakMap;nl=new WeakMap;al=new WeakMap;Ns=new WeakMap;Ir=new WeakMap;ol=new WeakMap;var If=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ye=(i,e,t)=>(If(i,e,"read from private field"),t?t.call(i):e.get(i)),tt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ui=(i,e,t,r)=>(If(i,e,"write to private field"),e.set(i,t),t),vt=(i,e,t)=>(If(i,e,"access private method"),t),Fs,ss,fd,_a,md,ll,$a,Ba,Us,$s,Jn,Rf,ty,Mc,pd,wf,gd,Cf,vd,Df,Pc,iy,Ga,Ed,Oc,ry;const AR="video not loaded, unknown time.",SR=i=>{const e=i.range,t=ya(+ny(i)),r=ya(+i.mediaSeekableEnd),s=t&&r?`${t} of ${r}`:AR;e.setAttribute("aria-valuetext",s)},sy=Z.createElement("template");sy.innerHTML=`
934
934
  <style>
935
935
  :host {
936
936
  --media-box-border-radius: 4px;
@@ -1140,7 +1140,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1140
1140
 
1141
1141
  </slot>
1142
1142
  </div>
1143
- `;const bo=(i,e=i.mediaCurrentTime)=>{const t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;if(Number.isNaN(r))return 0;const s=(e-t)/(r-t);return Math.max(0,Math.min(s,1))},ry=(i,e=i.range.valueAsNumber)=>{const t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;return Number.isNaN(r)?0:e*(r-t)+t};class AR extends xf{constructor(){super(),tt(this,Us),tt(this,Lf),tt(this,fd),tt(this,md),tt(this,pd),tt(this,Dc),tt(this,Ba),tt(this,Mc),tt(this,Ns,void 0),tt(this,ss,void 0),tt(this,cd,void 0),tt(this,Ta,void 0),tt(this,hd,void 0),tt(this,al,void 0),tt(this,Ua,void 0),tt(this,$a,void 0),tt(this,Fs,void 0),tt(this,Cc,t=>{this.dragging||(Ov(t)&&(this.range.valueAsNumber=t),this.updateBar())}),this.container.appendChild(iy.content.cloneNode(!0)),ui(this,cd,this.shadowRoot.querySelectorAll('[part~="box"]')),ui(this,hd,this.shadowRoot.querySelector('[part~="preview-box"]')),ui(this,al,this.shadowRoot.querySelector('[part~="current-box"]'));const e=getComputedStyle(this);ui(this,Ua,parseInt(e.getPropertyValue("--media-box-padding-left"))),ui(this,$a,parseInt(e.getPropertyValue("--media-box-padding-right"))),ui(this,ss,new bR(this.range,Ye(this,Cc),60))}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PAUSED,T.MEDIA_DURATION,T.MEDIA_SEEKABLE,T.MEDIA_CURRENT_TIME,T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_TIME,T.MEDIA_PREVIEW_CHAPTER,T.MEDIA_BUFFERED,T.MEDIA_PLAYBACK_RATE,T.MEDIA_LOADING,T.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",Rt.SEEK()),vt(this,Us,Zn).call(this),ui(this,Ns,this.getRootNode()),(e=Ye(this,Ns))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),vt(this,Us,Zn).call(this),(e=Ye(this,Ns))==null||e.removeEventListener("transitionstart",this),ui(this,Ns,null)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),t!=r&&(e===T.MEDIA_CURRENT_TIME||e===T.MEDIA_PAUSED||e===T.MEDIA_ENDED||e===T.MEDIA_LOADING||e===T.MEDIA_DURATION||e===T.MEDIA_SEEKABLE?(Ye(this,ss).update({start:bo(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),vt(this,Us,Zn).call(this),_R(this)):e===T.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===T.MEDIA_DURATION||e===T.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=Ye(this,Fs),this.updateBar()))}get mediaChaptersCues(){return Ye(this,Fs)}set mediaChaptersCues(e){var t;ui(this,Fs,e),this.updateSegments((t=Ye(this,Fs))==null?void 0:t.map(r=>({start:bo(this,r.startTime),end:bo(this,r.endTime)})))}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}get mediaLoading(){return at(this,T.MEDIA_LOADING)}set mediaLoading(e){ot(this,T.MEDIA_LOADING,e)}get mediaDuration(){return Ne(this,T.MEDIA_DURATION)}set mediaDuration(e){ze(this,T.MEDIA_DURATION,e)}get mediaCurrentTime(){return Ne(this,T.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){ze(this,T.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return Ne(this,T.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){ze(this,T.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){const e=this.getAttribute(T.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(r=>+r)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(T.MEDIA_BUFFERED);return}const t=e.map(r=>r.join(":")).join(" ");this.setAttribute(T.MEDIA_BUFFERED,t)}get mediaSeekable(){const e=this.getAttribute(T.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(T.MEDIA_SEEKABLE);return}this.setAttribute(T.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;const[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;const[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return Qe(this,T.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){Ze(this,T.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return Ne(this,T.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){ze(this,T.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return at(this,T.MEDIA_ENDED)}set mediaEnded(e){ot(this,T.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;const t=this.mediaBuffered;if(!t.length)return;let r;if(this.mediaEnded)r=1;else{const n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];r=bo(this,a)}const{style:s}=je(this.shadowRoot,"#highlight");s.setProperty("width",`${r*100}%`)}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;const t=je(this.shadowRoot,"#current-rail"),r=je(this.shadowRoot,'[part~="current-box"]'),s=vt(this,fd,If).call(this,Ye(this,al)),n=vt(this,md,Rf).call(this,s,this.range.valueAsNumber),a=vt(this,pd,wf).call(this,s,this.range.valueAsNumber);t.style.transform=`translateX(${n})`,t.style.setProperty("--_range-width",`${s.range.width}`),r.style.setProperty("--_box-shift",`${a}`),r.style.setProperty("--_box-width",`${s.box.width}px`),r.style.setProperty("visibility","initial")}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":vt(this,Mc,ty).call(this);break;case"pointermove":vt(this,Dc,ey).call(this,e);break;case"pointerup":case"pointerleave":vt(this,Ba,gd).call(this,null);break;case"transitionstart":Vi(e.target,this)&&setTimeout(()=>vt(this,Us,Zn).call(this),0);break}}}Ns=new WeakMap;ss=new WeakMap;cd=new WeakMap;Ta=new WeakMap;hd=new WeakMap;al=new WeakMap;Ua=new WeakMap;$a=new WeakMap;Fs=new WeakMap;Us=new WeakSet;Zn=function(){vt(this,Lf,JE).call(this)?Ye(this,ss).start():Ye(this,ss).stop()};Lf=new WeakSet;JE=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&AL(this)};Cc=new WeakMap;fd=new WeakSet;If=function(i){var e;const r=((e=this.getAttribute("bounds")?_n(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?e:this).getBoundingClientRect(),s=this.range.getBoundingClientRect(),n=i.offsetWidth,a=-(s.left-r.left-n/2),o=r.right-s.left-n/2;return{box:{width:n,min:a,max:o},bounds:r,range:s}};md=new WeakSet;Rf=function(i,e){let t=`${e*100}%`;const{width:r,min:s,max:n}=i.box;if(!r)return t;if(Number.isNaN(s)||(t=`max(${`calc(1 / var(--_range-width) * 100 * ${s}% + var(--media-box-padding-left))`}, ${t})`),!Number.isNaN(n)){const o=`calc(1 / var(--_range-width) * 100 * ${n}% - var(--media-box-padding-right))`;t=`min(${t}, ${o})`}return t};pd=new WeakSet;wf=function(i,e){const{width:t,min:r,max:s}=i.box,n=e*i.range.width;if(n<r+Ye(this,Ua)){const a=i.range.left-i.bounds.left-Ye(this,Ua);return`${n-t/2+a}px`}if(n>s-Ye(this,$a)){const a=i.bounds.right-i.range.right-Ye(this,$a);return`${n+t/2-a-i.range.width}px`}return 0};Dc=new WeakSet;ey=function(i){const e=[...Ye(this,cd)].some(u=>i.composedPath().includes(u));if(!this.dragging&&(e||!i.composedPath().includes(this))){vt(this,Ba,gd).call(this,null);return}const t=this.mediaSeekableEnd;if(!t)return;const r=je(this.shadowRoot,"#preview-rail"),s=je(this.shadowRoot,'[part~="preview-box"]'),n=vt(this,fd,If).call(this,Ye(this,hd));let a=(i.clientX-n.range.left)/n.range.width;a=Math.max(0,Math.min(1,a));const o=vt(this,md,Rf).call(this,n,a),l=vt(this,pd,wf).call(this,n,a);r.style.transform=`translateX(${o})`,r.style.setProperty("--_range-width",`${n.range.width}`),s.style.setProperty("--_box-shift",`${l}`),s.style.setProperty("--_box-width",`${n.box.width}px`);const d=Math.round(Ye(this,Ta))-Math.round(a*t);Math.abs(d)<1&&a>.01&&a<.99||(ui(this,Ta,a*t),vt(this,Ba,gd).call(this,Ye(this,Ta)))};Ba=new WeakSet;gd=function(i){this.dispatchEvent(new R.CustomEvent(j.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:i}))};Mc=new WeakSet;ty=function(){Ye(this,ss).stop();const i=ry(this);this.dispatchEvent(new R.CustomEvent(j.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i}))};R.customElements.get("media-time-range")||R.customElements.define("media-time-range",AR);const xs={PLACEMENT:"placement",BOUNDS:"bounds"},sy=Z.createElement("template");sy.innerHTML=`
1143
+ `;const _o=(i,e=i.mediaCurrentTime)=>{const t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;if(Number.isNaN(r))return 0;const s=(e-t)/(r-t);return Math.max(0,Math.min(s,1))},ny=(i,e=i.range.valueAsNumber)=>{const t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,r=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;return Number.isNaN(r)?0:e*(r-t)+t};class xR extends Lf{constructor(){super(),tt(this,$s),tt(this,Rf),tt(this,pd),tt(this,gd),tt(this,vd),tt(this,Pc),tt(this,Ga),tt(this,Oc),tt(this,Fs,void 0),tt(this,ss,void 0),tt(this,fd,void 0),tt(this,_a,void 0),tt(this,md,void 0),tt(this,ll,void 0),tt(this,$a,void 0),tt(this,Ba,void 0),tt(this,Us,void 0),tt(this,Mc,t=>{this.dragging||(Fv(t)&&(this.range.valueAsNumber=t),this.updateBar())}),this.container.appendChild(sy.content.cloneNode(!0)),ui(this,fd,this.shadowRoot.querySelectorAll('[part~="box"]')),ui(this,md,this.shadowRoot.querySelector('[part~="preview-box"]')),ui(this,ll,this.shadowRoot.querySelector('[part~="current-box"]'));const e=getComputedStyle(this);ui(this,$a,parseInt(e.getPropertyValue("--media-box-padding-left"))),ui(this,Ba,parseInt(e.getPropertyValue("--media-box-padding-right"))),ui(this,ss,new _R(this.range,Ye(this,Mc),60))}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PAUSED,T.MEDIA_DURATION,T.MEDIA_SEEKABLE,T.MEDIA_CURRENT_TIME,T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_TIME,T.MEDIA_PREVIEW_CHAPTER,T.MEDIA_BUFFERED,T.MEDIA_PLAYBACK_RATE,T.MEDIA_LOADING,T.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",Rt.SEEK()),vt(this,$s,Jn).call(this),ui(this,Fs,this.getRootNode()),(e=Ye(this,Fs))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),vt(this,$s,Jn).call(this),(e=Ye(this,Fs))==null||e.removeEventListener("transitionstart",this),ui(this,Fs,null)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),t!=r&&(e===T.MEDIA_CURRENT_TIME||e===T.MEDIA_PAUSED||e===T.MEDIA_ENDED||e===T.MEDIA_LOADING||e===T.MEDIA_DURATION||e===T.MEDIA_SEEKABLE?(Ye(this,ss).update({start:_o(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),vt(this,$s,Jn).call(this),SR(this)):e===T.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===T.MEDIA_DURATION||e===T.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=Ye(this,Us),this.updateBar()))}get mediaChaptersCues(){return Ye(this,Us)}set mediaChaptersCues(e){var t;ui(this,Us,e),this.updateSegments((t=Ye(this,Us))==null?void 0:t.map(r=>({start:_o(this,r.startTime),end:_o(this,r.endTime)})))}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}get mediaLoading(){return at(this,T.MEDIA_LOADING)}set mediaLoading(e){ot(this,T.MEDIA_LOADING,e)}get mediaDuration(){return Ne(this,T.MEDIA_DURATION)}set mediaDuration(e){ze(this,T.MEDIA_DURATION,e)}get mediaCurrentTime(){return Ne(this,T.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){ze(this,T.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return Ne(this,T.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){ze(this,T.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){const e=this.getAttribute(T.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(r=>+r)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(T.MEDIA_BUFFERED);return}const t=e.map(r=>r.join(":")).join(" ");this.setAttribute(T.MEDIA_BUFFERED,t)}get mediaSeekable(){const e=this.getAttribute(T.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(T.MEDIA_SEEKABLE);return}this.setAttribute(T.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;const[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;const[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return Qe(this,T.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){Ze(this,T.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return Ne(this,T.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){ze(this,T.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return at(this,T.MEDIA_ENDED)}set mediaEnded(e){ot(this,T.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;const t=this.mediaBuffered;if(!t.length)return;let r;if(this.mediaEnded)r=1;else{const n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];r=_o(this,a)}const{style:s}=je(this.shadowRoot,"#highlight");s.setProperty("width",`${r*100}%`)}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;const t=je(this.shadowRoot,"#current-rail"),r=je(this.shadowRoot,'[part~="current-box"]'),s=vt(this,pd,wf).call(this,Ye(this,ll)),n=vt(this,gd,Cf).call(this,s,this.range.valueAsNumber),a=vt(this,vd,Df).call(this,s,this.range.valueAsNumber);t.style.transform=`translateX(${n})`,t.style.setProperty("--_range-width",`${s.range.width}`),r.style.setProperty("--_box-shift",`${a}`),r.style.setProperty("--_box-width",`${s.box.width}px`),r.style.setProperty("visibility","initial")}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":vt(this,Oc,ry).call(this);break;case"pointermove":vt(this,Pc,iy).call(this,e);break;case"pointerup":case"pointerleave":vt(this,Ga,Ed).call(this,null);break;case"transitionstart":Vi(e.target,this)&&setTimeout(()=>vt(this,$s,Jn).call(this),0);break}}}Fs=new WeakMap;ss=new WeakMap;fd=new WeakMap;_a=new WeakMap;md=new WeakMap;ll=new WeakMap;$a=new WeakMap;Ba=new WeakMap;Us=new WeakMap;$s=new WeakSet;Jn=function(){vt(this,Rf,ty).call(this)?Ye(this,ss).start():Ye(this,ss).stop()};Rf=new WeakSet;ty=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&xL(this)};Mc=new WeakMap;pd=new WeakSet;wf=function(i){var e;const r=((e=this.getAttribute("bounds")?An(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?e:this).getBoundingClientRect(),s=this.range.getBoundingClientRect(),n=i.offsetWidth,a=-(s.left-r.left-n/2),o=r.right-s.left-n/2;return{box:{width:n,min:a,max:o},bounds:r,range:s}};gd=new WeakSet;Cf=function(i,e){let t=`${e*100}%`;const{width:r,min:s,max:n}=i.box;if(!r)return t;if(Number.isNaN(s)||(t=`max(${`calc(1 / var(--_range-width) * 100 * ${s}% + var(--media-box-padding-left))`}, ${t})`),!Number.isNaN(n)){const o=`calc(1 / var(--_range-width) * 100 * ${n}% - var(--media-box-padding-right))`;t=`min(${t}, ${o})`}return t};vd=new WeakSet;Df=function(i,e){const{width:t,min:r,max:s}=i.box,n=e*i.range.width;if(n<r+Ye(this,$a)){const a=i.range.left-i.bounds.left-Ye(this,$a);return`${n-t/2+a}px`}if(n>s-Ye(this,Ba)){const a=i.bounds.right-i.range.right-Ye(this,Ba);return`${n+t/2-a-i.range.width}px`}return 0};Pc=new WeakSet;iy=function(i){const e=[...Ye(this,fd)].some(u=>i.composedPath().includes(u));if(!this.dragging&&(e||!i.composedPath().includes(this))){vt(this,Ga,Ed).call(this,null);return}const t=this.mediaSeekableEnd;if(!t)return;const r=je(this.shadowRoot,"#preview-rail"),s=je(this.shadowRoot,'[part~="preview-box"]'),n=vt(this,pd,wf).call(this,Ye(this,md));let a=(i.clientX-n.range.left)/n.range.width;a=Math.max(0,Math.min(1,a));const o=vt(this,gd,Cf).call(this,n,a),l=vt(this,vd,Df).call(this,n,a);r.style.transform=`translateX(${o})`,r.style.setProperty("--_range-width",`${n.range.width}`),s.style.setProperty("--_box-shift",`${l}`),s.style.setProperty("--_box-width",`${n.box.width}px`);const d=Math.round(Ye(this,_a))-Math.round(a*t);Math.abs(d)<1&&a>.01&&a<.99||(ui(this,_a,a*t),vt(this,Ga,Ed).call(this,Ye(this,_a)))};Ga=new WeakSet;Ed=function(i){this.dispatchEvent(new R.CustomEvent(j.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:i}))};Oc=new WeakSet;ry=function(){Ye(this,ss).stop();const i=ny(this);this.dispatchEvent(new R.CustomEvent(j.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i}))};R.customElements.get("media-time-range")||R.customElements.define("media-time-range",xR);const ks={PLACEMENT:"placement",BOUNDS:"bounds"},ay=Z.createElement("template");ay.innerHTML=`
1144
1144
  <style>
1145
1145
  :host {
1146
1146
  --_tooltip-background-color: var(--media-tooltip-background-color, var(--media-secondary-color, rgba(20, 20, 30, .7)));
@@ -1250,7 +1250,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1250
1250
  </style>
1251
1251
  <slot></slot>
1252
1252
  <div id="arrow"></div>
1253
- `;class SR extends R.HTMLElement{constructor(){if(super(),this.updateXOffset=()=>{var e;const t=this.placement;if(t==="left"||t==="right"){this.style.removeProperty("--media-tooltip-offset-x");return}const r=getComputedStyle(this),s=(e=_n(this,"#"+this.bounds))!=null?e:$t(this);if(!s)return;const{x:n,width:a}=s.getBoundingClientRect(),{x:o,width:l}=this.getBoundingClientRect(),d=o+l,u=n+a,c=r.getPropertyValue("--media-tooltip-offset-x"),h=c?parseFloat(c.replace("px","")):0,f=r.getPropertyValue("--media-tooltip-container-margin"),m=f?parseFloat(f.replace("px","")):0,p=o-n+h-m,g=d-u+h+m;if(p<0){this.style.setProperty("--media-tooltip-offset-x",`${p}px`);return}if(g>0){this.style.setProperty("--media-tooltip-offset-x",`${g}px`);return}this.style.removeProperty("--media-tooltip-offset-x")},this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(sy.content.cloneNode(!0))),this.arrowEl=this.shadowRoot.querySelector("#arrow"),Object.prototype.hasOwnProperty.call(this,"placement")){const e=this.placement;delete this.placement,this.placement=e}}static get observedAttributes(){return[xs.PLACEMENT,xs.BOUNDS]}get placement(){return Qe(this,xs.PLACEMENT)}set placement(e){Ze(this,xs.PLACEMENT,e)}get bounds(){return Qe(this,xs.BOUNDS)}set bounds(e){Ze(this,xs.BOUNDS,e)}}R.customElements.get("media-tooltip")||R.customElements.define("media-tooltip",SR);const xR=1,kR=i=>i.mediaMuted?0:i.mediaVolume,LR=i=>`${Math.round(i*100)}%`;class IR extends xf{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_VOLUME,T.MEDIA_MUTED,T.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{const e=this.range.value,t=new R.CustomEvent(j.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",Rt.VOLUME())}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),(e===T.MEDIA_VOLUME||e===T.MEDIA_MUTED)&&(this.range.valueAsNumber=kR(this),this.range.setAttribute("aria-valuetext",LR(this.range.valueAsNumber)),this.updateBar())}get mediaVolume(){return Ne(this,T.MEDIA_VOLUME,xR)}set mediaVolume(e){ze(this,T.MEDIA_VOLUME,e)}get mediaMuted(){return at(this,T.MEDIA_MUTED)}set mediaMuted(e){ot(this,T.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return Qe(this,T.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){Ze(this,T.MEDIA_VOLUME_UNAVAILABLE,e)}}R.customElements.get("media-volume-range")||R.customElements.define("media-volume-range",IR);var RR=Object.defineProperty,wR=Object.getPrototypeOf,CR=Reflect.get,DR=(i,e,t)=>e in i?RR(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Se=(i,e,t)=>(DR(i,typeof e!="symbol"?e+"":e,t),t),Cf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},k=(i,e,t)=>(Cf(i,e,"read from private field"),t?t.call(i):e.get(i)),X=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Q=(i,e,t,r)=>(Cf(i,e,"write to private field"),e.set(i,t),t),Ce=(i,e,t)=>(Cf(i,e,"access private method"),t),xu=(i,e,t)=>CR(wR(i),t,e),Ud=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment>"u"){class i extends Ud{}globalThis.DocumentFragment=i}var Df=class extends Ud{},MR=class extends Ud{},PR={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(Df)}},ol,OR=class{constructor(e,t={}){X(this,ol,void 0),Q(this,ol,t==null?void 0:t.detail)}get detail(){return k(this,ol)}initCustomEvent(){}};ol=new WeakMap;function NR(i,e){return new Df}var FR={document:{createElement:NR},DocumentFragment,customElements:PR,CustomEvent:OR,EventTarget:Ud,HTMLElement:Df,HTMLVideoElement:MR},UR=typeof window>"u"||typeof globalThis.customElements>"u",ku=UR?FR:globalThis,$R=()=>{try{return"0.21.0"}catch{}return"UNKNOWN"},BR=$R(),GR=()=>BR,Mf=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"];function HR(i){return`
1253
+ `;class kR extends R.HTMLElement{constructor(){if(super(),this.updateXOffset=()=>{var e;const t=this.placement;if(t==="left"||t==="right"){this.style.removeProperty("--media-tooltip-offset-x");return}const r=getComputedStyle(this),s=(e=An(this,"#"+this.bounds))!=null?e:$t(this);if(!s)return;const{x:n,width:a}=s.getBoundingClientRect(),{x:o,width:l}=this.getBoundingClientRect(),d=o+l,u=n+a,c=r.getPropertyValue("--media-tooltip-offset-x"),h=c?parseFloat(c.replace("px","")):0,f=r.getPropertyValue("--media-tooltip-container-margin"),m=f?parseFloat(f.replace("px","")):0,p=o-n+h-m,g=d-u+h+m;if(p<0){this.style.setProperty("--media-tooltip-offset-x",`${p}px`);return}if(g>0){this.style.setProperty("--media-tooltip-offset-x",`${g}px`);return}this.style.removeProperty("--media-tooltip-offset-x")},this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(ay.content.cloneNode(!0))),this.arrowEl=this.shadowRoot.querySelector("#arrow"),Object.prototype.hasOwnProperty.call(this,"placement")){const e=this.placement;delete this.placement,this.placement=e}}static get observedAttributes(){return[ks.PLACEMENT,ks.BOUNDS]}get placement(){return Qe(this,ks.PLACEMENT)}set placement(e){Ze(this,ks.PLACEMENT,e)}get bounds(){return Qe(this,ks.BOUNDS)}set bounds(e){Ze(this,ks.BOUNDS,e)}}R.customElements.get("media-tooltip")||R.customElements.define("media-tooltip",kR);const LR=1,IR=i=>i.mediaMuted?0:i.mediaVolume,RR=i=>`${Math.round(i*100)}%`;class wR extends Lf{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_VOLUME,T.MEDIA_MUTED,T.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{const e=this.range.value,t=new R.CustomEvent(j.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",Rt.VOLUME())}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),(e===T.MEDIA_VOLUME||e===T.MEDIA_MUTED)&&(this.range.valueAsNumber=IR(this),this.range.setAttribute("aria-valuetext",RR(this.range.valueAsNumber)),this.updateBar())}get mediaVolume(){return Ne(this,T.MEDIA_VOLUME,LR)}set mediaVolume(e){ze(this,T.MEDIA_VOLUME,e)}get mediaMuted(){return at(this,T.MEDIA_MUTED)}set mediaMuted(e){ot(this,T.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return Qe(this,T.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){Ze(this,T.MEDIA_VOLUME_UNAVAILABLE,e)}}R.customElements.get("media-volume-range")||R.customElements.define("media-volume-range",wR);var CR=Object.defineProperty,DR=Object.getPrototypeOf,MR=Reflect.get,PR=(i,e,t)=>e in i?CR(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Se=(i,e,t)=>(PR(i,typeof e!="symbol"?e+"":e,t),t),Mf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},k=(i,e,t)=>(Mf(i,e,"read from private field"),t?t.call(i):e.get(i)),X=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Q=(i,e,t,r)=>(Mf(i,e,"write to private field"),e.set(i,t),t),Ce=(i,e,t)=>(Mf(i,e,"access private method"),t),Lu=(i,e,t)=>MR(DR(i),t,e),Bd=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment>"u"){class i extends Bd{}globalThis.DocumentFragment=i}var Pf=class extends Bd{},OR=class extends Bd{},NR={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(Pf)}},dl,FR=class{constructor(e,t={}){X(this,dl,void 0),Q(this,dl,t==null?void 0:t.detail)}get detail(){return k(this,dl)}initCustomEvent(){}};dl=new WeakMap;function UR(i,e){return new Pf}var $R={document:{createElement:UR},DocumentFragment,customElements:NR,CustomEvent:FR,EventTarget:Bd,HTMLElement:Pf,HTMLVideoElement:OR},BR=typeof window>"u"||typeof globalThis.customElements>"u",Iu=BR?$R:globalThis,GR=()=>{try{return"0.21.0"}catch{}return"UNKNOWN"},HR=GR(),WR=()=>HR,Of=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"];function KR(i){return`
1254
1254
  <style>
1255
1255
  :host {
1256
1256
  display: inline-flex;
@@ -1264,10 +1264,10 @@ svg, img, ::slotted(svg), ::slotted(img) {
1264
1264
  }
1265
1265
  </style>
1266
1266
  <slot name="media">
1267
- <audio${ay(i)}></audio>
1267
+ <audio${ly(i)}></audio>
1268
1268
  </slot>
1269
1269
  <slot></slot>
1270
- `}function WR(i){return`
1270
+ `}function VR(i){return`
1271
1271
  <style>
1272
1272
  :host {
1273
1273
  display: inline-block;
@@ -1289,10 +1289,10 @@ svg, img, ::slotted(svg), ::slotted(img) {
1289
1289
  }
1290
1290
  </style>
1291
1291
  <slot name="media">
1292
- <video${ay(i)}></video>
1292
+ <video${ly(i)}></video>
1293
1293
  </slot>
1294
1294
  <slot></slot>
1295
- `}var ny=(i,{tag:e,is:t})=>{var r,s,n,a,o,l,d,u,c,h,f,m,p,g,E,y,b;let S=(s=(r=globalThis.document)==null?void 0:r.createElement)==null?void 0:s.call(r,e,{is:t}),_=S?KR(S):[];return n=class extends i{constructor(){super(),X(this,h),X(this,m),X(this,g),X(this,y),X(this,d,void 0),X(this,u,void 0),X(this,c,new Map)}static get observedAttributes(){var x,A,C;return Ce(x=n,o,l).call(x),[...(C=(A=S==null?void 0:S.constructor)==null?void 0:A.observedAttributes)!=null?C:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var x,A,C;return Ce(this,h,f).call(this),(C=(A=(x=k(this,u))!=null?x:this.shadowRoot.querySelector(e))!=null?A:this.querySelector(":scope > [slot=media]"))!=null?C:this.querySelector(e)}set nativeEl(x){Q(this,u,x)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(x){this.toggleAttribute("muted",!!x)}get src(){return this.getAttribute("src")}set src(x){this.setAttribute("src",`${x}`)}get preload(){var x,A;return(A=this.getAttribute("preload"))!=null?A:(x=this.nativeEl)==null?void 0:x.preload}set preload(x){this.setAttribute("preload",`${x}`)}init(){var x,A;if(!this.shadowRoot){this.attachShadow({mode:"open"});let C=VR(this.attributes);t&&(C.is=t),e&&(C.part=e),this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(C)}this.nativeEl.muted=this.hasAttribute("muted");for(let C of _)Ce(this,g,E).call(this,C);this.shadowRoot.addEventListener("slotchange",this),Ce(this,m,p).call(this);for(let C of this.constructor.Events)(A=(x=this.shadowRoot).addEventListener)==null||A.call(x,C,this,!0)}handleEvent(x){if(x.type==="slotchange"){Ce(this,m,p).call(this);return}x.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(x.type,{detail:x.detail}))}attributeChangedCallback(x,A,C){Ce(this,h,f).call(this),Ce(this,y,b).call(this,x,A,C)}connectedCallback(){Ce(this,h,f).call(this)}},a=new WeakMap,o=new WeakSet,l=function(){if(k(this,a))return;Q(this,a,!0);let x=new Set(this.observedAttributes);x.delete("muted");for(let A of _)if(!(A in this.prototype))if(typeof S[A]=="function")this.prototype[A]=function(...C){return Ce(this,h,f).call(this),this.call?this.call(A,...C):this.nativeEl[A].apply(this.nativeEl,C)};else{let C={get(){var O,L,M;Ce(this,h,f).call(this);let K=A.toLowerCase();if(x.has(K)){let U=this.getAttribute(K);return U===null?!1:U===""?!0:U}return(M=(O=this.get)==null?void 0:O.call(this,A))!=null?M:(L=this.nativeEl)==null?void 0:L[A]}};A!==A.toUpperCase()&&(C.set=function(O){Ce(this,h,f).call(this);let L=A.toLowerCase();if(x.has(L)){O===!0||O===!1||O==null?this.toggleAttribute(L,!!O):this.setAttribute(L,O);return}if(this.set){this.set(A,O);return}this.nativeEl[A]=O}),Object.defineProperty(this.prototype,A,C)}},d=new WeakMap,u=new WeakMap,c=new WeakMap,h=new WeakSet,f=function(){k(this,d)||(Q(this,d,!0),this.init())},m=new WeakSet,p=function(){let x=new Map(k(this,c));this.shadowRoot.querySelector("slot:not([name])").assignedElements({flatten:!0}).filter(A=>["track","source"].includes(A.localName)).forEach(A=>{var C,O;x.delete(A);let L=k(this,c).get(A);L||(L=A.cloneNode(),k(this,c).set(A,L)),(O=(C=this.nativeEl).append)==null||O.call(C,L),L.localName==="track"&&L.default&&(L.kind==="chapters"||L.kind==="metadata")&&L.track.mode==="disabled"&&(L.track.mode="hidden")}),x.forEach(A=>A.remove())},g=new WeakSet,E=function(x){if(Object.prototype.hasOwnProperty.call(this,x)){let A=this[x];delete this[x],this[x]=A}},y=new WeakSet,b=function(x,A,C){var O,L,M,K,U,z;["id","class"].includes(x)||!n.observedAttributes.includes(x)&&this.constructor.observedAttributes.includes(x)||(C===null?(L=(O=this.nativeEl).removeAttribute)==null||L.call(O,x):((K=(M=this.nativeEl).getAttribute)==null?void 0:K.call(M,x))!=C&&((z=(U=this.nativeEl).setAttribute)==null||z.call(U,x,C)))},X(n,o),Se(n,"getTemplateHTML",e.endsWith("audio")?HR:WR),Se(n,"shadowRootOptions",{mode:"open"}),Se(n,"Events",Mf),X(n,a,void 0),n};function KR(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))e.push(...Object.getOwnPropertyNames(t));return e}function ay(i){let e="";for(let t in i){let r=i[t];r===""?e+=` ${t}`:e+=` ${t}="${r}"`}return e}function VR(i){let e={};for(let t of i)e[t.name]=t.value;return e}var t0,Lu=ny((t0=globalThis.HTMLElement)!=null?t0:class{},{tag:"video"}),i0;ny((i0=globalThis.HTMLElement)!=null?i0:class{},{tag:"audio"});var ns=new WeakMap,Iu=class extends Error{},qR=class extends Error{},YR=globalThis.WeakRef?class extends Set{add(i){super.add(new WeakRef(i))}forEach(i){super.forEach(e=>{let t=e.deref();t&&i(t)})}}:Set;function jR(i){var e,t,r;(t=(e=globalThis.chrome)==null?void 0:e.cast)!=null&&t.isAvailable?(r=globalThis.cast)!=null&&r.framework?i():customElements.whenDefined("google-cast-button").then(i):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(i)}}function zR(){return globalThis.chrome}function XR(){var i;let e="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if((i=globalThis.chrome)!=null&&i.cast||document.querySelector(`script[src="${e}"]`))return;let t=document.createElement("script");t.src=e,document.head.append(t)}function cs(){var i,e;return(e=(i=globalThis.cast)==null?void 0:i.framework)==null?void 0:e.CastContext.getInstance()}function Pf(){var i;return(i=cs())==null?void 0:i.getCurrentSession()}function Of(){var i;return(i=Pf())==null?void 0:i.getSessionObj().media[0]}function QR(i){return new Promise((e,t)=>{Of().editTracksInfo(i,e,t)})}function ZR(i){return new Promise((e,t)=>{Of().getStatus(i,e,t)})}function oy(i){return cs().setOptions({...ly(),...i})}function ly(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}var ll=new YR,hr=new WeakSet,Ke;jR(()=>{var i,e,t,r;if(!((e=(i=globalThis.chrome)==null?void 0:i.cast)!=null&&e.isAvailable)){console.debug("chrome.cast.isAvailable",(r=(t=globalThis.chrome)==null?void 0:t.cast)==null?void 0:r.isAvailable);return}Ke||(Ke=cast.framework,cs().addEventListener(Ke.CastContextEventType.CAST_STATE_CHANGED,s=>{ll.forEach(n=>{var a,o;return(o=(a=ns.get(n)).onCastStateChanged)==null?void 0:o.call(a,s)})}),cs().addEventListener(Ke.CastContextEventType.SESSION_STATE_CHANGED,s=>{ll.forEach(n=>{var a,o;return(o=(a=ns.get(n)).onSessionStateChanged)==null?void 0:o.call(a,s)})}),ll.forEach(s=>{var n,a;return(a=(n=ns.get(s)).init)==null?void 0:a.call(n)}))});var r0=0,Ee,dl,Ot,ar,Zs,$s,Zr,Pc,or,Rr,Oc,s0,vd,Nc,Fc,dy,ul,Uc,$c,n0,cl,Ru,JR=class extends EventTarget{constructor(e){super(),X(this,or),X(this,Oc),X(this,vd),X(this,Fc),X(this,ul),X(this,$c),X(this,cl),X(this,Ee,void 0),X(this,dl,void 0),X(this,Ot,void 0),X(this,ar,void 0),X(this,Zs,"disconnected"),X(this,$s,!1),X(this,Zr,new Set),X(this,Pc,new WeakMap),Q(this,Ee,e),ll.add(this),ns.set(this,{init:()=>Ce(this,ul,Uc).call(this),onCastStateChanged:()=>Ce(this,vd,Nc).call(this),onSessionStateChanged:()=>Ce(this,Fc,dy).call(this),getCastPlayer:()=>k(this,or,Rr)}),Ce(this,ul,Uc).call(this)}get state(){return k(this,Zs)}async watchAvailability(e){if(k(this,Ee).disableRemotePlayback)throw new Iu("disableRemotePlayback attribute is present.");return k(this,Pc).set(e,++r0),k(this,Zr).add(e),r0}async cancelWatchAvailability(e){if(k(this,Ee).disableRemotePlayback)throw new Iu("disableRemotePlayback attribute is present.");e?k(this,Zr).delete(e):k(this,Zr).clear()}async prompt(){var e,t,r,s;if(k(this,Ee).disableRemotePlayback)throw new Iu("disableRemotePlayback attribute is present.");if(!((t=(e=globalThis.chrome)==null?void 0:e.cast)!=null&&t.isAvailable))throw new qR("The RemotePlayback API is disabled on this platform.");let n=hr.has(k(this,Ee));hr.add(k(this,Ee)),oy(k(this,Ee).castOptions),Object.entries(k(this,ar)).forEach(([a,o])=>{k(this,Ot).controller.addEventListener(a,o)});try{await cs().requestSession()}catch(a){if(a==="cancel"){n||hr.delete(k(this,Ee));return}throw new Error(a)}(s=(r=ns.get(k(this,Ee)))==null?void 0:r.loadOnPrompt)==null||s.call(r)}};Ee=new WeakMap,dl=new WeakMap,Ot=new WeakMap,ar=new WeakMap,Zs=new WeakMap,$s=new WeakMap,Zr=new WeakMap,Pc=new WeakMap,or=new WeakSet,Rr=function(){if(hr.has(k(this,Ee)))return k(this,Ot)},Oc=new WeakSet,s0=function(){hr.has(k(this,Ee))&&(Object.entries(k(this,ar)).forEach(([i,e])=>{k(this,Ot).controller.removeEventListener(i,e)}),hr.delete(k(this,Ee)),k(this,Ee).muted=k(this,Ot).isMuted,k(this,Ee).currentTime=k(this,Ot).savedPlayerState.currentTime,k(this,Ot).savedPlayerState.isPaused===!1&&k(this,Ee).play())},vd=new WeakSet,Nc=function(){let i=cs().getCastState();if(hr.has(k(this,Ee))&&i==="CONNECTING"&&(Q(this,Zs,"connecting"),this.dispatchEvent(new Event("connecting"))),!k(this,$s)&&i!=null&&i.includes("CONNECT")){Q(this,$s,!0);for(let e of k(this,Zr))e(!0)}else if(k(this,$s)&&(!i||i==="NO_DEVICES_AVAILABLE")){Q(this,$s,!1);for(let e of k(this,Zr))e(!1)}},Fc=new WeakSet,dy=async function(){var i;let{SESSION_RESUMED:e}=Ke.SessionState;if(cs().getSessionState()===e&&k(this,Ee).castSrc===((i=Of())==null?void 0:i.media.contentId)){hr.add(k(this,Ee)),Object.entries(k(this,ar)).forEach(([t,r])=>{k(this,Ot).controller.addEventListener(t,r)});try{await ZR(new chrome.cast.media.GetStatusRequest)}catch(t){console.error(t)}k(this,ar)[Ke.RemotePlayerEventType.IS_PAUSED_CHANGED](),k(this,ar)[Ke.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},ul=new WeakSet,Uc=function(){!Ke||k(this,dl)||(Q(this,dl,!0),oy(k(this,Ee).castOptions),k(this,Ee).textTracks.addEventListener("change",()=>Ce(this,cl,Ru).call(this)),Ce(this,vd,Nc).call(this),Q(this,Ot,new Ke.RemotePlayer),new Ke.RemotePlayerController(k(this,Ot)),Q(this,ar,{[Ke.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:i})=>{i===!0?(Q(this,Zs,"connected"),this.dispatchEvent(new Event("connect"))):(Ce(this,Oc,s0).call(this),Q(this,Zs,"disconnected"),this.dispatchEvent(new Event("disconnect")))},[Ke.RemotePlayerEventType.DURATION_CHANGED]:()=>{k(this,Ee).dispatchEvent(new Event("durationchange"))},[Ke.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{k(this,Ee).dispatchEvent(new Event("volumechange"))},[Ke.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{k(this,Ee).dispatchEvent(new Event("volumechange"))},[Ke.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{var i;(i=k(this,or,Rr))!=null&&i.isMediaLoaded&&k(this,Ee).dispatchEvent(new Event("timeupdate"))},[Ke.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{k(this,Ee).dispatchEvent(new Event("resize"))},[Ke.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{k(this,Ee).dispatchEvent(new Event(this.paused?"pause":"play"))},[Ke.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var i,e;((i=k(this,or,Rr))==null?void 0:i.playerState)!==chrome.cast.media.PlayerState.PAUSED&&k(this,Ee).dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(e=k(this,or,Rr))==null?void 0:e.playerState]))},[Ke.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{var i;(i=k(this,or,Rr))!=null&&i.isMediaLoaded&&(await Promise.resolve(),Ce(this,$c,n0).call(this))}}))},$c=new WeakSet,n0=function(){Ce(this,cl,Ru).call(this)},cl=new WeakSet,Ru=async function(){var i,e,t,r,s;if(!k(this,or,Rr))return;let n=((e=(i=k(this,Ot).mediaInfo)==null?void 0:i.tracks)!=null?e:[]).filter(({type:h})=>h===chrome.cast.media.TrackType.TEXT),a=[...k(this,Ee).textTracks].filter(({kind:h})=>h==="subtitles"||h==="captions"),o=n.map(({language:h,name:f,trackId:m})=>{var p;let{mode:g}=(p=a.find(E=>E.language===h&&E.label===f))!=null?p:{};return g?{mode:g,trackId:m}:!1}).filter(Boolean),l=o.filter(({mode:h})=>h!=="showing").map(({trackId:h})=>h),d=o.find(({mode:h})=>h==="showing"),u=(s=(r=(t=Pf())==null?void 0:t.getSessionObj().media[0])==null?void 0:r.activeTrackIds)!=null?s:[],c=u;if(u.length&&(c=c.filter(h=>!l.includes(h))),d!=null&&d.trackId&&(c=[...c,d.trackId]),c=[...new Set(c)],!((h,f)=>h.length===f.length&&h.every(m=>f.includes(m)))(u,c))try{let h=new chrome.cast.media.EditTracksInfoRequest(c);await QR(h)}catch(h){console.error(h)}};var ew=i=>{var e,t,r,s,n,a,o,l,d,u;return t=class extends i{constructor(){super(...arguments),X(this,o),X(this,d),X(this,r,{paused:!1}),X(this,s,ly()),X(this,n,void 0),X(this,a,void 0)}get remote(){return k(this,a)?k(this,a):zR()?(XR(),ns.set(this,{loadOnPrompt:()=>Ce(this,d,u).call(this)}),Q(this,a,new JR(this))):super.remote}attributeChangedCallback(c,h,f){if(super.attributeChangedCallback(c,h,f),c==="cast-receiver"&&f){k(this,s).receiverApplicationId=f;return}if(k(this,o,l))switch(c){case"cast-stream-type":case"cast-src":this.load();break}}async load(){var c,h;if(!k(this,o,l))return super.load();let f=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType);f.customData=this.castCustomData;let m=[...this.querySelectorAll("track")].filter(({kind:y,src:b})=>b&&(y==="subtitles"||y==="captions")),p=[],g=0;m.length&&(f.tracks=m.map(y=>{let b=++g;p.length===0&&y.track.mode==="showing"&&p.push(b);let S=new chrome.cast.media.Track(b,chrome.cast.media.TrackType.TEXT);return S.trackContentId=y.src,S.trackContentType="text/vtt",S.subtype=y.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,S.name=y.label,S.language=y.srclang,S})),this.castStreamType==="live"?f.streamType=chrome.cast.media.StreamType.LIVE:f.streamType=chrome.cast.media.StreamType.BUFFERED,f.metadata=new chrome.cast.media.GenericMediaMetadata,f.metadata.title=this.title,f.metadata.images=[{url:this.poster}];let E=new chrome.cast.media.LoadRequest(f);E.currentTime=(c=super.currentTime)!=null?c:0,E.autoplay=!k(this,r).paused,E.activeTrackIds=p,await((h=Pf())==null?void 0:h.loadMedia(E)),this.dispatchEvent(new Event("volumechange"))}play(){var c;if(k(this,o,l)){k(this,o,l).isPaused&&((c=k(this,o,l).controller)==null||c.playOrPause());return}return super.play()}pause(){var c;if(k(this,o,l)){k(this,o,l).isPaused||(c=k(this,o,l).controller)==null||c.playOrPause();return}super.pause()}get castOptions(){return k(this,s)}get castReceiver(){var c;return(c=this.getAttribute("cast-receiver"))!=null?c:void 0}set castReceiver(c){this.castReceiver!=c&&this.setAttribute("cast-receiver",`${c}`)}get castSrc(){var c,h,f;return(f=(h=this.getAttribute("cast-src"))!=null?h:(c=this.querySelector("source"))==null?void 0:c.src)!=null?f:this.currentSrc}set castSrc(c){this.castSrc!=c&&this.setAttribute("cast-src",`${c}`)}get castContentType(){var c;return(c=this.getAttribute("cast-content-type"))!=null?c:void 0}set castContentType(c){this.setAttribute("cast-content-type",`${c}`)}get castStreamType(){var c,h;return(h=(c=this.getAttribute("cast-stream-type"))!=null?c:this.streamType)!=null?h:void 0}set castStreamType(c){this.setAttribute("cast-stream-type",`${c}`)}get castCustomData(){return k(this,n)}set castCustomData(c){let h=typeof c;if(!["object","undefined"].includes(h)){console.error(`castCustomData must be nullish or an object but value was of type ${h}`);return}Q(this,n,c)}get readyState(){if(k(this,o,l))switch(k(this,o,l).playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return k(this,o,l)?k(this,o,l).isPaused:super.paused}get muted(){var c;return k(this,o,l)?(c=k(this,o,l))==null?void 0:c.isMuted:super.muted}set muted(c){var h;if(k(this,o,l)){(c&&!k(this,o,l).isMuted||!c&&k(this,o,l).isMuted)&&((h=k(this,o,l).controller)==null||h.muteOrUnmute());return}super.muted=c}get volume(){var c,h;return k(this,o,l)?(h=(c=k(this,o,l))==null?void 0:c.volumeLevel)!=null?h:1:super.volume}set volume(c){var h;if(k(this,o,l)){k(this,o,l).volumeLevel=+c,(h=k(this,o,l).controller)==null||h.setVolumeLevel();return}super.volume=c}get duration(){var c,h,f;return k(this,o,l)&&(c=k(this,o,l))!=null&&c.isMediaLoaded?(f=(h=k(this,o,l))==null?void 0:h.duration)!=null?f:NaN:super.duration}get currentTime(){var c,h,f;return k(this,o,l)&&(c=k(this,o,l))!=null&&c.isMediaLoaded?(f=(h=k(this,o,l))==null?void 0:h.currentTime)!=null?f:0:super.currentTime}set currentTime(c){var h;if(k(this,o,l)){k(this,o,l).currentTime=c,(h=k(this,o,l).controller)==null||h.seek();return}super.currentTime=c}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakSet,l=function(){var c,h;return(h=(c=ns.get(this.remote))==null?void 0:c.getCastPlayer)==null?void 0:h.call(c)},d=new WeakSet,u=async function(){k(this,r).paused=xu(t.prototype,this,"paused"),xu(t.prototype,this,"pause").call(this),this.muted=xu(t.prototype,this,"muted");try{await this.load()}catch(c){console.error(c)}},Se(t,"observedAttributes",[...(e=i.observedAttributes)!=null?e:[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"]),t},$d=class extends Event{constructor(i,e){super(i),Se(this,"track"),this.track=e.track}},Bc=new WeakMap;function W(i){var e;return(e=Bc.get(i))!=null?e:tw(i,{})}function tw(i,e){let t=Bc.get(i);return t||Bc.set(i,t={}),Object.assign(t,e)}function Gc(i,e){let t=i.videoTracks;W(e).media=i,W(e).renditionSet||(W(e).renditionSet=new Set);let r=W(t).trackSet;r.add(e);let s=r.size-1;s in Wc.prototype||Object.defineProperty(Wc.prototype,s,{get(){return[...W(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new $d("addtrack",{track:e}))})}function Hc(i){var e;let t=(e=W(i).media)==null?void 0:e.videoTracks;t&&(W(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new $d("removetrack",{track:i}))}))}function iw(i){var e;let t=(e=W(i).media.videoTracks)!=null?e:[],r=!1;for(let s of t)s!==i&&(s.selected=!1,r=!0);if(r){if(W(t).changeRequested)return;W(t).changeRequested=!0,queueMicrotask(()=>{delete W(t).changeRequested,t.dispatchEvent(new Event("change"))})}}var wr,Cr,Dr,Bs,Jn,Wc=class extends EventTarget{constructor(){super(),X(this,Bs),X(this,wr,void 0),X(this,Cr,void 0),X(this,Dr,void 0),W(this).trackSet=new Set}[Symbol.iterator](){return k(this,Bs,Jn).values()}get length(){return k(this,Bs,Jn).size}getTrackById(e){var t;return(t=[...k(this,Bs,Jn)].find(r=>r.id===e))!=null?t:null}get selectedIndex(){return[...k(this,Bs,Jn)].findIndex(e=>e.selected)}get onaddtrack(){return k(this,wr)}set onaddtrack(e){k(this,wr)&&(this.removeEventListener("addtrack",k(this,wr)),Q(this,wr,void 0)),typeof e=="function"&&(Q(this,wr,e),this.addEventListener("addtrack",e))}get onremovetrack(){return k(this,Cr)}set onremovetrack(e){k(this,Cr)&&(this.removeEventListener("removetrack",k(this,Cr)),Q(this,Cr,void 0)),typeof e=="function"&&(Q(this,Cr,e),this.addEventListener("removetrack",e))}get onchange(){return k(this,Dr)}set onchange(e){k(this,Dr)&&(this.removeEventListener("change",k(this,Dr)),Q(this,Dr,void 0)),typeof e=="function"&&(Q(this,Dr,e),this.addEventListener("change",e))}};wr=new WeakMap,Cr=new WeakMap,Dr=new WeakMap,Bs=new WeakSet,Jn=function(){return W(this).trackSet};var Bd=class extends Event{constructor(e,t){super(e),Se(this,"rendition"),this.rendition=t.rendition}};function rw(i,e){let t=W(i).media.videoRenditions;W(e).media=W(i).media,W(e).track=i;let r=W(i).renditionSet;r.add(e);let s=r.size-1;s in Kc.prototype||Object.defineProperty(Kc.prototype,s,{get(){return Gs(this)[s]}}),queueMicrotask(()=>{i.selected&&t.dispatchEvent(new Bd("addrendition",{rendition:e}))})}function sw(i){let e=W(i).media.videoRenditions,t=W(i).track;W(t).renditionSet.delete(i),queueMicrotask(()=>{W(i).track.selected&&e.dispatchEvent(new Bd("removerendition",{rendition:i}))})}function nw(i){let e=W(i).media.videoRenditions;!e||W(e).changeRequested||(W(e).changeRequested=!0,queueMicrotask(()=>{delete W(e).changeRequested,W(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function Gs(i){return[...W(i).media.videoTracks].filter(e=>e.selected).flatMap(e=>[...W(e).renditionSet])}var Mr,Pr,Or,Kc=class extends EventTarget{constructor(){super(...arguments),X(this,Mr,void 0),X(this,Pr,void 0),X(this,Or,void 0)}[Symbol.iterator](){return Gs(this).values()}get length(){return Gs(this).length}getRenditionById(e){var t;return(t=Gs(this).find(r=>`${r.id}`==`${e}`))!=null?t:null}get selectedIndex(){return Gs(this).findIndex(e=>e.selected)}set selectedIndex(e){for(let[t,r]of Gs(this).entries())r.selected=t===e}get onaddrendition(){return k(this,Mr)}set onaddrendition(e){k(this,Mr)&&(this.removeEventListener("addrendition",k(this,Mr)),Q(this,Mr,void 0)),typeof e=="function"&&(Q(this,Mr,e),this.addEventListener("addrendition",e))}get onremoverendition(){return k(this,Pr)}set onremoverendition(e){k(this,Pr)&&(this.removeEventListener("removerendition",k(this,Pr)),Q(this,Pr,void 0)),typeof e=="function"&&(Q(this,Pr,e),this.addEventListener("removerendition",e))}get onchange(){return k(this,Or)}set onchange(e){k(this,Or)&&(this.removeEventListener("change",k(this,Or)),Q(this,Or,void 0)),typeof e=="function"&&(Q(this,Or,e),this.addEventListener("change",e))}};Mr=new WeakMap,Pr=new WeakMap,Or=new WeakMap;var ea,aw=class{constructor(){Se(this,"src"),Se(this,"id"),Se(this,"width"),Se(this,"height"),Se(this,"bitrate"),Se(this,"frameRate"),Se(this,"codec"),X(this,ea,!1)}get selected(){return k(this,ea)}set selected(e){k(this,ea)!==e&&(Q(this,ea,e),nw(this))}};ea=new WeakMap;var ta,uy=class{constructor(){Se(this,"id"),Se(this,"kind"),Se(this,"label",""),Se(this,"language",""),Se(this,"sourceBuffer"),X(this,ta,!1)}addRendition(e,t,r,s,n,a){let o=new aw;return o.src=e,o.width=t,o.height=r,o.frameRate=a,o.bitrate=n,o.codec=s,rw(this,o),o}removeRendition(e){sw(e)}get selected(){return k(this,ta)}set selected(e){k(this,ta)!==e&&(Q(this,ta,e),e===!0&&iw(this))}};ta=new WeakMap;function ow(i,e){let t=W(i).media.audioRenditions;W(e).media=W(i).media,W(e).track=i;let r=W(i).renditionSet;r.add(e);let s=r.size-1;s in Vc.prototype||Object.defineProperty(Vc.prototype,s,{get(){return Hs(this)[s]}}),queueMicrotask(()=>{i.enabled&&t.dispatchEvent(new Bd("addrendition",{rendition:e}))})}function lw(i){let e=W(i).media.audioRenditions,t=W(i).track;W(t).renditionSet.delete(i),queueMicrotask(()=>{W(i).track.enabled&&e.dispatchEvent(new Bd("removerendition",{rendition:i}))})}function dw(i){let e=W(i).media.audioRenditions;!e||W(e).changeRequested||(W(e).changeRequested=!0,queueMicrotask(()=>{delete W(e).changeRequested,W(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function Hs(i){return[...W(i).media.audioTracks].filter(e=>e.enabled).flatMap(e=>[...W(e).renditionSet])}var Nr,Fr,Ur,Vc=class extends EventTarget{constructor(){super(...arguments),X(this,Nr,void 0),X(this,Fr,void 0),X(this,Ur,void 0)}[Symbol.iterator](){return Hs(this).values()}get length(){return Hs(this).length}getRenditionById(e){var t;return(t=Hs(this).find(r=>`${r.id}`==`${e}`))!=null?t:null}get selectedIndex(){return Hs(this).findIndex(e=>e.selected)}set selectedIndex(e){for(let[t,r]of Hs(this).entries())r.selected=t===e}get onaddrendition(){return k(this,Nr)}set onaddrendition(e){k(this,Nr)&&(this.removeEventListener("addrendition",k(this,Nr)),Q(this,Nr,void 0)),typeof e=="function"&&(Q(this,Nr,e),this.addEventListener("addrendition",e))}get onremoverendition(){return k(this,Fr)}set onremoverendition(e){k(this,Fr)&&(this.removeEventListener("removerendition",k(this,Fr)),Q(this,Fr,void 0)),typeof e=="function"&&(Q(this,Fr,e),this.addEventListener("removerendition",e))}get onchange(){return k(this,Ur)}set onchange(e){k(this,Ur)&&(this.removeEventListener("change",k(this,Ur)),Q(this,Ur,void 0)),typeof e=="function"&&(Q(this,Ur,e),this.addEventListener("change",e))}};Nr=new WeakMap,Fr=new WeakMap,Ur=new WeakMap;var ia,uw=class{constructor(){Se(this,"src"),Se(this,"id"),Se(this,"bitrate"),Se(this,"codec"),X(this,ia,!1)}get selected(){return k(this,ia)}set selected(e){k(this,ia)!==e&&(Q(this,ia,e),dw(this))}};ia=new WeakMap;function qc(i,e){let t=i.audioTracks;W(e).media=i,W(e).renditionSet||(W(e).renditionSet=new Set);let r=W(t).trackSet;r.add(e);let s=r.size-1;s in jc.prototype||Object.defineProperty(jc.prototype,s,{get(){return[...W(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new $d("addtrack",{track:e}))})}function Yc(i){var e;let t=(e=W(i).media)==null?void 0:e.audioTracks;t&&(W(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new $d("removetrack",{track:i}))}))}function cw(i){let e=W(i).media.audioTracks;!e||W(e).changeRequested||(W(e).changeRequested=!0,queueMicrotask(()=>{delete W(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var $r,Br,Gr,ra,hl,jc=class extends EventTarget{constructor(){super(),X(this,ra),X(this,$r,void 0),X(this,Br,void 0),X(this,Gr,void 0),W(this).trackSet=new Set}[Symbol.iterator](){return k(this,ra,hl).values()}get length(){return k(this,ra,hl).size}getTrackById(i){var e;return(e=[...k(this,ra,hl)].find(t=>t.id===i))!=null?e:null}get onaddtrack(){return k(this,$r)}set onaddtrack(i){k(this,$r)&&(this.removeEventListener("addtrack",k(this,$r)),Q(this,$r,void 0)),typeof i=="function"&&(Q(this,$r,i),this.addEventListener("addtrack",i))}get onremovetrack(){return k(this,Br)}set onremovetrack(i){k(this,Br)&&(this.removeEventListener("removetrack",k(this,Br)),Q(this,Br,void 0)),typeof i=="function"&&(Q(this,Br,i),this.addEventListener("removetrack",i))}get onchange(){return k(this,Gr)}set onchange(i){k(this,Gr)&&(this.removeEventListener("change",k(this,Gr)),Q(this,Gr,void 0)),typeof i=="function"&&(Q(this,Gr,i),this.addEventListener("change",i))}};$r=new WeakMap,Br=new WeakMap,Gr=new WeakMap,ra=new WeakSet,hl=function(){return W(this).trackSet};var sa,cy=class{constructor(){Se(this,"id"),Se(this,"kind"),Se(this,"label",""),Se(this,"language",""),Se(this,"sourceBuffer"),X(this,sa,!1)}addRendition(e,t,r){let s=new uw;return s.src=e,s.codec=t,s.bitrate=r,ow(this,s),s}removeRendition(e){lw(e)}get enabled(){return k(this,sa)}set enabled(e){k(this,sa)!==e&&(Q(this,sa,e),cw(this))}};sa=new WeakMap;var a0=Ed(globalThis.HTMLMediaElement,"video"),o0=Ed(globalThis.HTMLMediaElement,"audio");function hw(i){if(!(i!=null&&i.prototype))return i;let e=Ed(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return fw(this)}});let t=Ed(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return mw(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(n,a="",o=""){let l=new uy;return l.kind=n,l.label=a,l.language=o,Gc(this,l),l}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=Hc),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(n,a="",o=""){let l=new cy;return l.kind=n,l.label=a,l.language=o,qc(this,l),l}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=Yc),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return r(this)}});let r=n=>{let a=W(n).videoRenditions;return a||(a=new Kc,W(a).media=n,W(n).videoRenditions=a),a};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return s(this)}});let s=n=>{let a=W(n).audioRenditions;return a||(a=new Vc,W(a).media=n,W(n).audioRenditions=a),a};return i}function Ed(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function fw(i){var e;let t=W(i).videoTracks;if(!t&&(t=new Wc,W(i).videoTracks=t,a0)){let r=a0.call((e=i.nativeEl)!=null?e:i);for(let s of r)Gc(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof uy)){for(let n of r)Hc(n);return}Gc(i,s.track)}),r.addEventListener("removetrack",s=>{Hc(s.track)})}return t}function mw(i){var e;let t=W(i).audioTracks;if(!t&&(t=new jc,W(i).audioTracks=t,o0)){let r=o0.call((e=i.nativeEl)!=null?e:i);for(let s of r)qc(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof cy)){for(let n of r)Yc(n);return}qc(i,s.track)}),r.addEventListener("removetrack",s=>{Yc(s.track)})}return t}Mf.push("castchange","entercast","leavecast");var P={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_TRACKING:"disable-tracking",DISABLE_COOKIES:"disable-cookies",DRM_TOKEN:"drm-token",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",MIN_RESOLUTION:"min-resolution",RENDITION_ORDER:"rendition-order",PROGRAM_START_TIME:"program-start-time",PROGRAM_END_TIME:"program-end-time",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},pw=Object.values(P),gw=GR(),vw="mux-video",ci,na,fl,aa,ml,pl,gl,vl,oa,El,Ew=class extends Lu{constructor(){super(),X(this,oa),X(this,ci,void 0),X(this,na,void 0),X(this,fl,void 0),X(this,aa,{}),X(this,ml,void 0),X(this,pl,void 0),X(this,gl,void 0),X(this,vl,void 0),Q(this,fl,Kk())}static get observedAttributes(){var e;return[...pw,...(e=Lu.observedAttributes)!=null?e:[]]}get preferCmcd(){var e;return(e=this.getAttribute(P.PREFER_CMCD))!=null?e:void 0}set preferCmcd(e){e!==this.preferCmcd&&(e?rd.includes(e)?this.setAttribute(P.PREFER_CMCD,e):console.warn(`Invalid value for preferCmcd. Must be one of ${rd.join()}`):this.removeAttribute(P.PREFER_CMCD))}get playerInitTime(){return k(this,fl)}get playerSoftwareName(){var e;return(e=k(this,gl))!=null?e:vw}set playerSoftwareName(e){Q(this,gl,e)}get playerSoftwareVersion(){var e;return(e=k(this,pl))!=null?e:gw}set playerSoftwareVersion(e){Q(this,pl,e)}get _hls(){var e;return(e=k(this,ci))==null?void 0:e.engine}get mux(){var e;return(e=this.nativeEl)==null?void 0:e.mux}get error(){var e;return(e=jk(this.nativeEl))!=null?e:null}get errorTranslator(){return k(this,vl)}set errorTranslator(e){Q(this,vl,e)}get src(){return this.getAttribute("src")}set src(e){e!==this.src&&(e==null?this.removeAttribute("src"):this.setAttribute("src",e))}get type(){var e;return(e=this.getAttribute(P.TYPE))!=null?e:void 0}set type(e){e!==this.type&&(e?this.setAttribute(P.TYPE,e):this.removeAttribute(P.TYPE))}get autoplay(){let e=this.getAttribute("autoplay");return e===null?!1:e===""?!0:e}set autoplay(e){let t=this.autoplay;e!==t&&(e?this.setAttribute("autoplay",typeof e=="string"?e:""):this.removeAttribute("autoplay"))}get preload(){let e=this.getAttribute("preload");return e===""?"auto":["none","metadata","auto"].includes(e)?e:super.preload}set preload(e){e!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(e)?this.setAttribute("preload",e):this.removeAttribute("preload"))}get debug(){return this.getAttribute(P.DEBUG)!=null}set debug(e){e!==this.debug&&(e?this.setAttribute(P.DEBUG,""):this.removeAttribute(P.DEBUG))}get disableTracking(){return this.hasAttribute(P.DISABLE_TRACKING)}set disableTracking(e){e!==this.disableTracking&&this.toggleAttribute(P.DISABLE_TRACKING,!!e)}get disableCookies(){return this.hasAttribute(P.DISABLE_COOKIES)}set disableCookies(e){e!==this.disableCookies&&(e?this.setAttribute(P.DISABLE_COOKIES,""):this.removeAttribute(P.DISABLE_COOKIES))}get startTime(){let e=this.getAttribute(P.START_TIME);if(e==null)return;let t=+e;return Number.isNaN(t)?void 0:t}set startTime(e){e!==this.startTime&&(e==null?this.removeAttribute(P.START_TIME):this.setAttribute(P.START_TIME,`${e}`))}get playbackId(){var e;return this.hasAttribute(P.PLAYBACK_ID)?this.getAttribute(P.PLAYBACK_ID):(e=uf(this.src))!=null?e:void 0}set playbackId(e){e!==this.playbackId&&(e?this.setAttribute(P.PLAYBACK_ID,e):this.removeAttribute(P.PLAYBACK_ID))}get maxResolution(){var e;return(e=this.getAttribute(P.MAX_RESOLUTION))!=null?e:void 0}set maxResolution(e){e!==this.maxResolution&&(e?this.setAttribute(P.MAX_RESOLUTION,e):this.removeAttribute(P.MAX_RESOLUTION))}get minResolution(){var e;return(e=this.getAttribute(P.MIN_RESOLUTION))!=null?e:void 0}set minResolution(e){e!==this.minResolution&&(e?this.setAttribute(P.MIN_RESOLUTION,e):this.removeAttribute(P.MIN_RESOLUTION))}get renditionOrder(){var e;return(e=this.getAttribute(P.RENDITION_ORDER))!=null?e:void 0}set renditionOrder(e){e!==this.renditionOrder&&(e?this.setAttribute(P.RENDITION_ORDER,e):this.removeAttribute(P.RENDITION_ORDER))}get programStartTime(){let e=this.getAttribute(P.PROGRAM_START_TIME);if(e==null)return;let t=+e;return Number.isNaN(t)?void 0:t}set programStartTime(e){e==null?this.removeAttribute(P.PROGRAM_START_TIME):this.setAttribute(P.PROGRAM_START_TIME,`${e}`)}get programEndTime(){let e=this.getAttribute(P.PROGRAM_END_TIME);if(e==null)return;let t=+e;return Number.isNaN(t)?void 0:t}set programEndTime(e){e==null?this.removeAttribute(P.PROGRAM_END_TIME):this.setAttribute(P.PROGRAM_END_TIME,`${e}`)}get customDomain(){var e;return(e=this.getAttribute(P.CUSTOM_DOMAIN))!=null?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(P.CUSTOM_DOMAIN,e):this.removeAttribute(P.CUSTOM_DOMAIN))}get drmToken(){var e;return(e=this.getAttribute(P.DRM_TOKEN))!=null?e:void 0}set drmToken(e){e!==this.drmToken&&(e?this.setAttribute(P.DRM_TOKEN,e):this.removeAttribute(P.DRM_TOKEN))}get ended(){return kv(this.nativeEl,this._hls)}get envKey(){var e;return(e=this.getAttribute(P.ENV_KEY))!=null?e:void 0}set envKey(e){e!==this.envKey&&(e?this.setAttribute(P.ENV_KEY,e):this.removeAttribute(P.ENV_KEY))}get beaconCollectionDomain(){var e;return(e=this.getAttribute(P.BEACON_COLLECTION_DOMAIN))!=null?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(P.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(P.BEACON_COLLECTION_DOMAIN))}get streamType(){var e;return(e=this.getAttribute(P.STREAM_TYPE))!=null?e:uc(this.nativeEl)}set streamType(e){e!==this.streamType&&(e?this.setAttribute(P.STREAM_TYPE,e):this.removeAttribute(P.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(P.TARGET_LIVE_WINDOW)?+this.getAttribute(P.TARGET_LIVE_WINDOW):zk(this.nativeEl)}set targetLiveWindow(e){e!=this.targetLiveWindow&&(e==null?this.removeAttribute(P.TARGET_LIVE_WINDOW):this.setAttribute(P.TARGET_LIVE_WINDOW,`${+e}`))}get liveEdgeStart(){var e,t;if(this.hasAttribute(P.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:r}=this,s=(e=this.nativeEl.seekable.end(0))!=null?e:0,n=(t=this.nativeEl.seekable.start(0))!=null?t:0;return Math.max(n,s-r)}return Xk(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(P.LIVE_EDGE_OFFSET))return+this.getAttribute(P.LIVE_EDGE_OFFSET)}set liveEdgeOffset(e){e!=this.targetLiveWindow&&(e==null?this.removeAttribute(P.LIVE_EDGE_OFFSET):this.setAttribute(P.LIVE_EDGE_OFFSET,`${+e}`))}get seekable(){return sd(this.nativeEl)}async addCuePoints(e){return Ev(this.nativeEl,e)}get activeCuePoint(){return yv(this.nativeEl)}get cuePoints(){return Ik(this.nativeEl)}async addChapters(e){return Tv(this.nativeEl,e)}get activeChapter(){return _v(this.nativeEl)}get chapters(){return wk(this.nativeEl)}getStartDate(){return Dk(this.nativeEl,this._hls)}get currentPdt(){return Mk(this.nativeEl,this._hls)}get preferPlayback(){let e=this.getAttribute(P.PREFER_PLAYBACK);if(e===Ti.MSE||e===Ti.NATIVE)return e}set preferPlayback(e){e!==this.preferPlayback&&(e===Ti.MSE||e===Ti.NATIVE?this.setAttribute(P.PREFER_PLAYBACK,e):this.removeAttribute(P.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(e=>e.startsWith("metadata-")&&![P.METADATA_URL].includes(e)).reduce((e,t)=>{let r=this.getAttribute(t);return r!=null&&(e[t.replace(/^metadata-/,"").replace(/-/g,"_")]=r),e},{}),...k(this,aa)}}set metadata(e){Q(this,aa,e??{}),this.mux&&this.mux.emit("hb",k(this,aa))}get _hlsConfig(){return k(this,ml)}set _hlsConfig(e){Q(this,ml,e)}load(){Q(this,ci,Jk(this,this.nativeEl,k(this,ci)))}unload(){Lv(this.nativeEl,k(this,ci)),Q(this,ci,void 0)}attributeChangedCallback(e,t,r){var s,n;switch(Lu.observedAttributes.includes(e)&&!["src","autoplay","preload"].includes(e)&&super.attributeChangedCallback(e,t,r),e){case P.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=r??void 0;break;case P.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=r??void 0;break;case"src":{let a=!!t,o=!!r;!a&&o?Ce(this,oa,El).call(this):a&&!o?this.unload():a&&o&&(this.unload(),Ce(this,oa,El).call(this));break}case"autoplay":if(r===t)break;(s=k(this,ci))==null||s.setAutoplay(this.autoplay);break;case"preload":if(r===t)break;(n=k(this,ci))==null||n.setPreload(r);break;case P.PLAYBACK_ID:this.src=dc(this);break;case P.DEBUG:{let a=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=a);break}case P.METADATA_URL:r&&fetch(r).then(a=>a.json()).then(a=>this.metadata=a).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${r}!`));break;case P.STREAM_TYPE:(r==null||r!==t)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case P.TARGET_LIVE_WINDOW:(r==null||r!==t)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break}}connectedCallback(){var e;(e=super.connectedCallback)==null||e.call(this),this.nativeEl&&this.src&&!k(this,ci)&&Ce(this,oa,El).call(this)}disconnectedCallback(){this.unload()}};ci=new WeakMap,na=new WeakMap,fl=new WeakMap,aa=new WeakMap,ml=new WeakMap,pl=new WeakMap,gl=new WeakMap,vl=new WeakMap,oa=new WeakSet,El=async function(){k(this,na)||(await Q(this,na,Promise.resolve()),Q(this,na,null),this.load())};var yl,zc=class extends ew(hw(Ew)){constructor(){super(...arguments),X(this,yl,void 0)}get muxCastCustomData(){return{mux:{playbackId:this.playbackId,minResolution:this.minResolution,maxResolution:this.maxResolution,renditionOrder:this.renditionOrder,customDomain:this.customDomain,tokens:{drm:this.drmToken},envKey:this.envKey,metadata:this.metadata,disableCookies:this.disableCookies,disableTracking:this.disableTracking,beaconCollectionDomain:this.beaconCollectionDomain,startTime:this.startTime,preferCmcd:this.preferCmcd}}}get castCustomData(){var e;return(e=k(this,yl))!=null?e:this.muxCastCustomData}set castCustomData(e){Q(this,yl,e)}};yl=new WeakMap;ku.customElements.get("mux-video")||(ku.customElements.define("mux-video",zc),ku.MuxVideoElement=zc);var yw=zc,hy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},de=(i,e,t)=>(hy(i,e,"read from private field"),t?t.call(i):e.get(i)),vi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Gi=(i,e,t,r)=>(hy(i,e,"write to private field"),e.set(i,t),t),Ws,bl,Hr,la,er,tr,ir,Wr,Ks,Tl,Ht;const l0=1,d0=0,bw=1,Tw={processCallback(i,e,t){if(t){for(const[r,s]of e)if(r in t){const n=t[r];typeof n=="boolean"&&s instanceof Xt&&typeof s.element[s.attributeName]=="boolean"?s.booleanValue=n:typeof n=="function"&&s instanceof Xt?s.element[s.attributeName]=n:s.value=n}}}};class Gd extends R.DocumentFragment{constructor(e,t,r=Tw){var s;super(),vi(this,Ws,void 0),vi(this,bl,void 0),this.append(e.content.cloneNode(!0)),Gi(this,Ws,fy(this)),Gi(this,bl,r),(s=r.createCallback)==null||s.call(r,this,de(this,Ws),t),r.processCallback(this,de(this,Ws),t)}update(e){de(this,bl).processCallback(this,de(this,Ws),e)}}Ws=new WeakMap;bl=new WeakMap;const fy=(i,e=[])=>{let t,r;for(const s of i.attributes||[])if(s.value.includes("{{")){const n=new Aw;for([t,r]of c0(s.value))if(!t)n.append(r);else{const a=new Xt(i,s.name,s.namespaceURI);n.append(a),e.push([r,a])}s.value=n.toString()}for(const s of i.childNodes)if(s.nodeType===l0&&!(s instanceof HTMLTemplateElement))fy(s,e);else{const n=s.data;if(s.nodeType===l0||n.includes("{{")){const a=[];if(n)for([t,r]of c0(n))if(!t)a.push(new Text(r));else{const o=new An(i);a.push(o),e.push([r,o])}else if(s instanceof HTMLTemplateElement){const o=new gy(i,s);a.push(o),e.push([o.expression,o])}s.replaceWith(...a.flatMap(o=>o.replacementNodes||[o]))}}return e},u0={},c0=i=>{let e="",t=0,r=u0[i],s=0,n;if(r)return r;for(r=[];n=i[s];s++)n==="{"&&i[s+1]==="{"&&i[s-1]!=="\\"&&i[s+2]&&++t==1?(e&&r.push([d0,e]),e="",s++):n==="}"&&i[s+1]==="}"&&i[s-1]!=="\\"&&!--t?(r.push([bw,e.trim()]),e="",s++):e+=n||"";return e&&r.push([d0,(t>0?"{{":"")+e]),u0[i]=r},_w=11;class my{get value(){return""}set value(e){}toString(){return this.value}}const py=new WeakMap;class Aw{constructor(){vi(this,Hr,[])}[Symbol.iterator](){return de(this,Hr).values()}get length(){return de(this,Hr).length}item(e){return de(this,Hr)[e]}append(...e){for(const t of e)t instanceof Xt&&py.set(t,this),de(this,Hr).push(t)}toString(){return de(this,Hr).join("")}}Hr=new WeakMap;class Xt extends my{constructor(e,t,r){super(),vi(this,Wr),vi(this,la,""),vi(this,er,void 0),vi(this,tr,void 0),vi(this,ir,void 0),Gi(this,er,e),Gi(this,tr,t),Gi(this,ir,r)}get attributeName(){return de(this,tr)}get attributeNamespace(){return de(this,ir)}get element(){return de(this,er)}get value(){return de(this,la)}set value(e){de(this,la)!==e&&(Gi(this,la,e),!de(this,Wr,Ks)||de(this,Wr,Ks).length===1?e==null?de(this,er).removeAttributeNS(de(this,ir),de(this,tr)):de(this,er).setAttributeNS(de(this,ir),de(this,tr),e):de(this,er).setAttributeNS(de(this,ir),de(this,tr),de(this,Wr,Ks).toString()))}get booleanValue(){return de(this,er).hasAttributeNS(de(this,ir),de(this,tr))}set booleanValue(e){if(!de(this,Wr,Ks)||de(this,Wr,Ks).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}}la=new WeakMap;er=new WeakMap;tr=new WeakMap;ir=new WeakMap;Wr=new WeakSet;Ks=function(){return py.get(this)};class An extends my{constructor(e,t){super(),vi(this,Tl,void 0),vi(this,Ht,void 0),Gi(this,Tl,e),Gi(this,Ht,t?[...t]:[new Text])}get replacementNodes(){return de(this,Ht)}get parentNode(){return de(this,Tl)}get nextSibling(){return de(this,Ht)[de(this,Ht).length-1].nextSibling}get previousSibling(){return de(this,Ht)[0].previousSibling}get value(){return de(this,Ht).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){const t=e.flat().flatMap(r=>r==null?[new Text]:r.forEach?[...r]:r.nodeType===_w?[...r.childNodes]:r.nodeType?[r]:[new Text(r)]);t.length||t.push(new Text),Gi(this,Ht,Sw(de(this,Ht)[0].parentNode,de(this,Ht),t,this.nextSibling))}}Tl=new WeakMap;Ht=new WeakMap;class gy extends An{constructor(e,t){const r=t.getAttribute("directive")||t.getAttribute("type");let s=t.getAttribute("expression")||t.getAttribute(r)||"";s.startsWith("{{")&&(s=s.trim().slice(2,-2).trim()),super(e),this.expression=s,this.template=t,this.directive=r}}function Sw(i,e,t,r=null){let s=0,n,a,o,l=t.length,d=e.length;for(;s<l&&s<d&&e[s]==t[s];)s++;for(;s<l&&s<d&&t[l-1]==e[d-1];)r=t[--d,--l];if(s==d)for(;s<l;)i.insertBefore(t[s++],r);if(s==l)for(;s<d;)i.removeChild(e[s++]);else{for(n=e[s];s<l;)o=t[s++],a=n?n.nextSibling:r,n==o?n=a:s<l&&t[s]==a?(i.replaceChild(o,n),n=a):i.insertBefore(o,n);for(;n!=r;)a=n.nextSibling,i.removeChild(n),n=a}return t}const h0={string:i=>String(i)};class vy{constructor(e){this.template=e,this.state=void 0}}const Jr=new WeakMap,es=new WeakMap,Xc={partial:(i,e)=>{e[i.expression]=new vy(i.template)},if:(i,e)=>{var t;if(Ey(i.expression,e))if(Jr.get(i)!==i.template){Jr.set(i,i.template);const r=new Gd(i.template,e,Nf);i.replace(r),es.set(i,r)}else(t=es.get(i))==null||t.update(e);else i.replace(""),Jr.delete(i),es.delete(i)}},xw=Object.keys(Xc),Nf={processCallback(i,e,t){var r,s;if(t)for(const[n,a]of e){if(a instanceof gy){if(!a.directive){const l=xw.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(r=Xc[a.directive])==null||r.call(Xc,a,t);continue}let o=Ey(n,t);if(o instanceof vy){Jr.get(a)!==o.template?(Jr.set(a,o.template),o=new Gd(o.template,o.state,Nf),a.value=o,es.set(a,o)):(s=es.get(a))==null||s.update(o.state);continue}o?(a instanceof Xt&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof Xt?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,Jr.delete(a),es.delete(a))):a instanceof Xt?a.value=void 0:(a.value=void 0,Jr.delete(a),es.delete(a))}}},f0={"!":i=>!i,"!!":i=>!!i,"==":(i,e)=>i==e,"!=":(i,e)=>i!=e,">":(i,e)=>i>e,">=":(i,e)=>i>=e,"<":(i,e)=>i<e,"<=":(i,e)=>i<=e,"??":(i,e)=>i??e,"|":(i,e)=>{var t;return(t=h0[e])==null?void 0:t.call(h0,i)}};function kw(i){return Lw(i,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function Ey(i,e={}){var t,r,s,n,a,o,l;const d=kw(i);if(d.length===0||d.some(({type:u})=>!u))return Mn(i);if(((t=d[0])==null?void 0:t.token)===">"){const u=e[(r=d[1])==null?void 0:r.token];if(!u)return Mn(i);const c={...e};u.state=c;const h=d.slice(2);for(let f=0;f<h.length;f+=3){const m=(s=h[f])==null?void 0:s.token,p=(n=h[f+1])==null?void 0:n.token,g=(a=h[f+2])==null?void 0:a.token;m&&p==="="&&(c[m]=Pn(g,e))}return u}if(d.length===1)return To(d[0])?Pn(d[0].token,e):Mn(i);if(d.length===2){const u=(o=d[0])==null?void 0:o.token,c=f0[u];if(!c||!To(d[1]))return Mn(i);const h=Pn(d[1].token,e);return c(h)}if(d.length===3){const u=(l=d[1])==null?void 0:l.token,c=f0[u];if(!c||!To(d[0])||!To(d[2]))return Mn(i);const h=Pn(d[0].token,e);if(u==="|")return c(h,d[2].token);const f=Pn(d[2].token,e);return c(h,f)}}function Mn(i){return console.warn(`Warning: invalid expression \`${i}\``),!1}function To({type:i}){return["number","boolean","string","param"].includes(i)}function Pn(i,e){const t=i[0],r=i.slice(-1);return i==="true"||i==="false"?i==="true":t===r&&["'",'"'].includes(t)?i.slice(1,-1):Nv(i)?parseFloat(i):e[i]}function Lw(i,e){let t,r,s;const n=[];for(;i;){s=null,t=i.length;for(const a in e)r=e[a].exec(i),r&&r.index<t&&(s={token:r[0],type:a,matches:r.slice(1)},t=r.index);t&&n.push({token:i.substr(0,t),type:void 0}),s&&n.push(s),i=i.substr(t+(s?s.token.length:0))}return n}var Ff=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Qc=(i,e,t)=>(Ff(i,e,"read from private field"),t?t.call(i):e.get(i)),On=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ts=(i,e,t,r)=>(Ff(i,e,"write to private field"),e.set(i,t),t),wu=(i,e,t)=>(Ff(i,e,"access private method"),t),nn,_l,an,Zc,yy,Al,Jc;const Cu={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},by=Z.createElement("template");by.innerHTML=`
1295
+ `}var oy=(i,{tag:e,is:t})=>{var r,s,n,a,o,l,d,u,c,h,f,m,p,g,E,y,b;let S=(s=(r=globalThis.document)==null?void 0:r.createElement)==null?void 0:s.call(r,e,{is:t}),_=S?qR(S):[];return n=class extends i{constructor(){super(),X(this,h),X(this,m),X(this,g),X(this,y),X(this,d,void 0),X(this,u,void 0),X(this,c,new Map)}static get observedAttributes(){var x,A,C;return Ce(x=n,o,l).call(x),[...(C=(A=S==null?void 0:S.constructor)==null?void 0:A.observedAttributes)!=null?C:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var x,A,C;return Ce(this,h,f).call(this),(C=(A=(x=k(this,u))!=null?x:this.shadowRoot.querySelector(e))!=null?A:this.querySelector(":scope > [slot=media]"))!=null?C:this.querySelector(e)}set nativeEl(x){Q(this,u,x)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(x){this.toggleAttribute("muted",!!x)}get src(){return this.getAttribute("src")}set src(x){this.setAttribute("src",`${x}`)}get preload(){var x,A;return(A=this.getAttribute("preload"))!=null?A:(x=this.nativeEl)==null?void 0:x.preload}set preload(x){this.setAttribute("preload",`${x}`)}init(){var x,A;if(!this.shadowRoot){this.attachShadow({mode:"open"});let C=YR(this.attributes);t&&(C.is=t),e&&(C.part=e),this.shadowRoot.innerHTML=this.constructor.getTemplateHTML(C)}this.nativeEl.muted=this.hasAttribute("muted");for(let C of _)Ce(this,g,E).call(this,C);this.shadowRoot.addEventListener("slotchange",this),Ce(this,m,p).call(this);for(let C of this.constructor.Events)(A=(x=this.shadowRoot).addEventListener)==null||A.call(x,C,this,!0)}handleEvent(x){if(x.type==="slotchange"){Ce(this,m,p).call(this);return}x.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(x.type,{detail:x.detail}))}attributeChangedCallback(x,A,C){Ce(this,h,f).call(this),Ce(this,y,b).call(this,x,A,C)}connectedCallback(){Ce(this,h,f).call(this)}},a=new WeakMap,o=new WeakSet,l=function(){if(k(this,a))return;Q(this,a,!0);let x=new Set(this.observedAttributes);x.delete("muted");for(let A of _)if(!(A in this.prototype))if(typeof S[A]=="function")this.prototype[A]=function(...C){return Ce(this,h,f).call(this),this.call?this.call(A,...C):this.nativeEl[A].apply(this.nativeEl,C)};else{let C={get(){var O,L,M;Ce(this,h,f).call(this);let K=A.toLowerCase();if(x.has(K)){let U=this.getAttribute(K);return U===null?!1:U===""?!0:U}return(M=(O=this.get)==null?void 0:O.call(this,A))!=null?M:(L=this.nativeEl)==null?void 0:L[A]}};A!==A.toUpperCase()&&(C.set=function(O){Ce(this,h,f).call(this);let L=A.toLowerCase();if(x.has(L)){O===!0||O===!1||O==null?this.toggleAttribute(L,!!O):this.setAttribute(L,O);return}if(this.set){this.set(A,O);return}this.nativeEl[A]=O}),Object.defineProperty(this.prototype,A,C)}},d=new WeakMap,u=new WeakMap,c=new WeakMap,h=new WeakSet,f=function(){k(this,d)||(Q(this,d,!0),this.init())},m=new WeakSet,p=function(){let x=new Map(k(this,c));this.shadowRoot.querySelector("slot:not([name])").assignedElements({flatten:!0}).filter(A=>["track","source"].includes(A.localName)).forEach(A=>{var C,O;x.delete(A);let L=k(this,c).get(A);L||(L=A.cloneNode(),k(this,c).set(A,L)),(O=(C=this.nativeEl).append)==null||O.call(C,L),L.localName==="track"&&L.default&&(L.kind==="chapters"||L.kind==="metadata")&&L.track.mode==="disabled"&&(L.track.mode="hidden")}),x.forEach(A=>A.remove())},g=new WeakSet,E=function(x){if(Object.prototype.hasOwnProperty.call(this,x)){let A=this[x];delete this[x],this[x]=A}},y=new WeakSet,b=function(x,A,C){var O,L,M,K,U,z;["id","class"].includes(x)||!n.observedAttributes.includes(x)&&this.constructor.observedAttributes.includes(x)||(C===null?(L=(O=this.nativeEl).removeAttribute)==null||L.call(O,x):((K=(M=this.nativeEl).getAttribute)==null?void 0:K.call(M,x))!=C&&((z=(U=this.nativeEl).setAttribute)==null||z.call(U,x,C)))},X(n,o),Se(n,"getTemplateHTML",e.endsWith("audio")?KR:VR),Se(n,"shadowRootOptions",{mode:"open"}),Se(n,"Events",Of),X(n,a,void 0),n};function qR(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))e.push(...Object.getOwnPropertyNames(t));return e}function ly(i){let e="";for(let t in i){let r=i[t];r===""?e+=` ${t}`:e+=` ${t}="${r}"`}return e}function YR(i){let e={};for(let t of i)e[t.name]=t.value;return e}var r0,Ru=oy((r0=globalThis.HTMLElement)!=null?r0:class{},{tag:"video"}),s0;oy((s0=globalThis.HTMLElement)!=null?s0:class{},{tag:"audio"});var ns=new WeakMap,wu=class extends Error{},jR=class extends Error{},zR=globalThis.WeakRef?class extends Set{add(i){super.add(new WeakRef(i))}forEach(i){super.forEach(e=>{let t=e.deref();t&&i(t)})}}:Set;function XR(i){var e,t,r;(t=(e=globalThis.chrome)==null?void 0:e.cast)!=null&&t.isAvailable?(r=globalThis.cast)!=null&&r.framework?i():customElements.whenDefined("google-cast-button").then(i):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(i)}}function QR(){return globalThis.chrome}function ZR(){var i;let e="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if((i=globalThis.chrome)!=null&&i.cast||document.querySelector(`script[src="${e}"]`))return;let t=document.createElement("script");t.src=e,document.head.append(t)}function cs(){var i,e;return(e=(i=globalThis.cast)==null?void 0:i.framework)==null?void 0:e.CastContext.getInstance()}function Nf(){var i;return(i=cs())==null?void 0:i.getCurrentSession()}function Ff(){var i;return(i=Nf())==null?void 0:i.getSessionObj().media[0]}function JR(i){return new Promise((e,t)=>{Ff().editTracksInfo(i,e,t)})}function ew(i){return new Promise((e,t)=>{Ff().getStatus(i,e,t)})}function dy(i){return cs().setOptions({...uy(),...i})}function uy(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}var ul=new zR,hr=new WeakSet,Ke;XR(()=>{var i,e,t,r;if(!((e=(i=globalThis.chrome)==null?void 0:i.cast)!=null&&e.isAvailable)){console.debug("chrome.cast.isAvailable",(r=(t=globalThis.chrome)==null?void 0:t.cast)==null?void 0:r.isAvailable);return}Ke||(Ke=cast.framework,cs().addEventListener(Ke.CastContextEventType.CAST_STATE_CHANGED,s=>{ul.forEach(n=>{var a,o;return(o=(a=ns.get(n)).onCastStateChanged)==null?void 0:o.call(a,s)})}),cs().addEventListener(Ke.CastContextEventType.SESSION_STATE_CHANGED,s=>{ul.forEach(n=>{var a,o;return(o=(a=ns.get(n)).onSessionStateChanged)==null?void 0:o.call(a,s)})}),ul.forEach(s=>{var n,a;return(a=(n=ns.get(s)).init)==null?void 0:a.call(n)}))});var n0=0,Ee,cl,Ot,ar,Js,Bs,Zr,Nc,or,Rr,Fc,a0,yd,Uc,$c,cy,hl,Bc,Gc,o0,fl,Cu,tw=class extends EventTarget{constructor(e){super(),X(this,or),X(this,Fc),X(this,yd),X(this,$c),X(this,hl),X(this,Gc),X(this,fl),X(this,Ee,void 0),X(this,cl,void 0),X(this,Ot,void 0),X(this,ar,void 0),X(this,Js,"disconnected"),X(this,Bs,!1),X(this,Zr,new Set),X(this,Nc,new WeakMap),Q(this,Ee,e),ul.add(this),ns.set(this,{init:()=>Ce(this,hl,Bc).call(this),onCastStateChanged:()=>Ce(this,yd,Uc).call(this),onSessionStateChanged:()=>Ce(this,$c,cy).call(this),getCastPlayer:()=>k(this,or,Rr)}),Ce(this,hl,Bc).call(this)}get state(){return k(this,Js)}async watchAvailability(e){if(k(this,Ee).disableRemotePlayback)throw new wu("disableRemotePlayback attribute is present.");return k(this,Nc).set(e,++n0),k(this,Zr).add(e),n0}async cancelWatchAvailability(e){if(k(this,Ee).disableRemotePlayback)throw new wu("disableRemotePlayback attribute is present.");e?k(this,Zr).delete(e):k(this,Zr).clear()}async prompt(){var e,t,r,s;if(k(this,Ee).disableRemotePlayback)throw new wu("disableRemotePlayback attribute is present.");if(!((t=(e=globalThis.chrome)==null?void 0:e.cast)!=null&&t.isAvailable))throw new jR("The RemotePlayback API is disabled on this platform.");let n=hr.has(k(this,Ee));hr.add(k(this,Ee)),dy(k(this,Ee).castOptions),Object.entries(k(this,ar)).forEach(([a,o])=>{k(this,Ot).controller.addEventListener(a,o)});try{await cs().requestSession()}catch(a){if(a==="cancel"){n||hr.delete(k(this,Ee));return}throw new Error(a)}(s=(r=ns.get(k(this,Ee)))==null?void 0:r.loadOnPrompt)==null||s.call(r)}};Ee=new WeakMap,cl=new WeakMap,Ot=new WeakMap,ar=new WeakMap,Js=new WeakMap,Bs=new WeakMap,Zr=new WeakMap,Nc=new WeakMap,or=new WeakSet,Rr=function(){if(hr.has(k(this,Ee)))return k(this,Ot)},Fc=new WeakSet,a0=function(){hr.has(k(this,Ee))&&(Object.entries(k(this,ar)).forEach(([i,e])=>{k(this,Ot).controller.removeEventListener(i,e)}),hr.delete(k(this,Ee)),k(this,Ee).muted=k(this,Ot).isMuted,k(this,Ee).currentTime=k(this,Ot).savedPlayerState.currentTime,k(this,Ot).savedPlayerState.isPaused===!1&&k(this,Ee).play())},yd=new WeakSet,Uc=function(){let i=cs().getCastState();if(hr.has(k(this,Ee))&&i==="CONNECTING"&&(Q(this,Js,"connecting"),this.dispatchEvent(new Event("connecting"))),!k(this,Bs)&&i!=null&&i.includes("CONNECT")){Q(this,Bs,!0);for(let e of k(this,Zr))e(!0)}else if(k(this,Bs)&&(!i||i==="NO_DEVICES_AVAILABLE")){Q(this,Bs,!1);for(let e of k(this,Zr))e(!1)}},$c=new WeakSet,cy=async function(){var i;let{SESSION_RESUMED:e}=Ke.SessionState;if(cs().getSessionState()===e&&k(this,Ee).castSrc===((i=Ff())==null?void 0:i.media.contentId)){hr.add(k(this,Ee)),Object.entries(k(this,ar)).forEach(([t,r])=>{k(this,Ot).controller.addEventListener(t,r)});try{await ew(new chrome.cast.media.GetStatusRequest)}catch(t){console.error(t)}k(this,ar)[Ke.RemotePlayerEventType.IS_PAUSED_CHANGED](),k(this,ar)[Ke.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},hl=new WeakSet,Bc=function(){!Ke||k(this,cl)||(Q(this,cl,!0),dy(k(this,Ee).castOptions),k(this,Ee).textTracks.addEventListener("change",()=>Ce(this,fl,Cu).call(this)),Ce(this,yd,Uc).call(this),Q(this,Ot,new Ke.RemotePlayer),new Ke.RemotePlayerController(k(this,Ot)),Q(this,ar,{[Ke.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:i})=>{i===!0?(Q(this,Js,"connected"),this.dispatchEvent(new Event("connect"))):(Ce(this,Fc,a0).call(this),Q(this,Js,"disconnected"),this.dispatchEvent(new Event("disconnect")))},[Ke.RemotePlayerEventType.DURATION_CHANGED]:()=>{k(this,Ee).dispatchEvent(new Event("durationchange"))},[Ke.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{k(this,Ee).dispatchEvent(new Event("volumechange"))},[Ke.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{k(this,Ee).dispatchEvent(new Event("volumechange"))},[Ke.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{var i;(i=k(this,or,Rr))!=null&&i.isMediaLoaded&&k(this,Ee).dispatchEvent(new Event("timeupdate"))},[Ke.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{k(this,Ee).dispatchEvent(new Event("resize"))},[Ke.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{k(this,Ee).dispatchEvent(new Event(this.paused?"pause":"play"))},[Ke.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var i,e;((i=k(this,or,Rr))==null?void 0:i.playerState)!==chrome.cast.media.PlayerState.PAUSED&&k(this,Ee).dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(e=k(this,or,Rr))==null?void 0:e.playerState]))},[Ke.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{var i;(i=k(this,or,Rr))!=null&&i.isMediaLoaded&&(await Promise.resolve(),Ce(this,Gc,o0).call(this))}}))},Gc=new WeakSet,o0=function(){Ce(this,fl,Cu).call(this)},fl=new WeakSet,Cu=async function(){var i,e,t,r,s;if(!k(this,or,Rr))return;let n=((e=(i=k(this,Ot).mediaInfo)==null?void 0:i.tracks)!=null?e:[]).filter(({type:h})=>h===chrome.cast.media.TrackType.TEXT),a=[...k(this,Ee).textTracks].filter(({kind:h})=>h==="subtitles"||h==="captions"),o=n.map(({language:h,name:f,trackId:m})=>{var p;let{mode:g}=(p=a.find(E=>E.language===h&&E.label===f))!=null?p:{};return g?{mode:g,trackId:m}:!1}).filter(Boolean),l=o.filter(({mode:h})=>h!=="showing").map(({trackId:h})=>h),d=o.find(({mode:h})=>h==="showing"),u=(s=(r=(t=Nf())==null?void 0:t.getSessionObj().media[0])==null?void 0:r.activeTrackIds)!=null?s:[],c=u;if(u.length&&(c=c.filter(h=>!l.includes(h))),d!=null&&d.trackId&&(c=[...c,d.trackId]),c=[...new Set(c)],!((h,f)=>h.length===f.length&&h.every(m=>f.includes(m)))(u,c))try{let h=new chrome.cast.media.EditTracksInfoRequest(c);await JR(h)}catch(h){console.error(h)}};var iw=i=>{var e,t,r,s,n,a,o,l,d,u;return t=class extends i{constructor(){super(...arguments),X(this,o),X(this,d),X(this,r,{paused:!1}),X(this,s,uy()),X(this,n,void 0),X(this,a,void 0)}get remote(){return k(this,a)?k(this,a):QR()?(ZR(),ns.set(this,{loadOnPrompt:()=>Ce(this,d,u).call(this)}),Q(this,a,new tw(this))):super.remote}attributeChangedCallback(c,h,f){if(super.attributeChangedCallback(c,h,f),c==="cast-receiver"&&f){k(this,s).receiverApplicationId=f;return}if(k(this,o,l))switch(c){case"cast-stream-type":case"cast-src":this.load();break}}async load(){var c,h;if(!k(this,o,l))return super.load();let f=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType);f.customData=this.castCustomData;let m=[...this.querySelectorAll("track")].filter(({kind:y,src:b})=>b&&(y==="subtitles"||y==="captions")),p=[],g=0;m.length&&(f.tracks=m.map(y=>{let b=++g;p.length===0&&y.track.mode==="showing"&&p.push(b);let S=new chrome.cast.media.Track(b,chrome.cast.media.TrackType.TEXT);return S.trackContentId=y.src,S.trackContentType="text/vtt",S.subtype=y.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,S.name=y.label,S.language=y.srclang,S})),this.castStreamType==="live"?f.streamType=chrome.cast.media.StreamType.LIVE:f.streamType=chrome.cast.media.StreamType.BUFFERED,f.metadata=new chrome.cast.media.GenericMediaMetadata,f.metadata.title=this.title,f.metadata.images=[{url:this.poster}];let E=new chrome.cast.media.LoadRequest(f);E.currentTime=(c=super.currentTime)!=null?c:0,E.autoplay=!k(this,r).paused,E.activeTrackIds=p,await((h=Nf())==null?void 0:h.loadMedia(E)),this.dispatchEvent(new Event("volumechange"))}play(){var c;if(k(this,o,l)){k(this,o,l).isPaused&&((c=k(this,o,l).controller)==null||c.playOrPause());return}return super.play()}pause(){var c;if(k(this,o,l)){k(this,o,l).isPaused||(c=k(this,o,l).controller)==null||c.playOrPause();return}super.pause()}get castOptions(){return k(this,s)}get castReceiver(){var c;return(c=this.getAttribute("cast-receiver"))!=null?c:void 0}set castReceiver(c){this.castReceiver!=c&&this.setAttribute("cast-receiver",`${c}`)}get castSrc(){var c,h,f;return(f=(h=this.getAttribute("cast-src"))!=null?h:(c=this.querySelector("source"))==null?void 0:c.src)!=null?f:this.currentSrc}set castSrc(c){this.castSrc!=c&&this.setAttribute("cast-src",`${c}`)}get castContentType(){var c;return(c=this.getAttribute("cast-content-type"))!=null?c:void 0}set castContentType(c){this.setAttribute("cast-content-type",`${c}`)}get castStreamType(){var c,h;return(h=(c=this.getAttribute("cast-stream-type"))!=null?c:this.streamType)!=null?h:void 0}set castStreamType(c){this.setAttribute("cast-stream-type",`${c}`)}get castCustomData(){return k(this,n)}set castCustomData(c){let h=typeof c;if(!["object","undefined"].includes(h)){console.error(`castCustomData must be nullish or an object but value was of type ${h}`);return}Q(this,n,c)}get readyState(){if(k(this,o,l))switch(k(this,o,l).playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return k(this,o,l)?k(this,o,l).isPaused:super.paused}get muted(){var c;return k(this,o,l)?(c=k(this,o,l))==null?void 0:c.isMuted:super.muted}set muted(c){var h;if(k(this,o,l)){(c&&!k(this,o,l).isMuted||!c&&k(this,o,l).isMuted)&&((h=k(this,o,l).controller)==null||h.muteOrUnmute());return}super.muted=c}get volume(){var c,h;return k(this,o,l)?(h=(c=k(this,o,l))==null?void 0:c.volumeLevel)!=null?h:1:super.volume}set volume(c){var h;if(k(this,o,l)){k(this,o,l).volumeLevel=+c,(h=k(this,o,l).controller)==null||h.setVolumeLevel();return}super.volume=c}get duration(){var c,h,f;return k(this,o,l)&&(c=k(this,o,l))!=null&&c.isMediaLoaded?(f=(h=k(this,o,l))==null?void 0:h.duration)!=null?f:NaN:super.duration}get currentTime(){var c,h,f;return k(this,o,l)&&(c=k(this,o,l))!=null&&c.isMediaLoaded?(f=(h=k(this,o,l))==null?void 0:h.currentTime)!=null?f:0:super.currentTime}set currentTime(c){var h;if(k(this,o,l)){k(this,o,l).currentTime=c,(h=k(this,o,l).controller)==null||h.seek();return}super.currentTime=c}},r=new WeakMap,s=new WeakMap,n=new WeakMap,a=new WeakMap,o=new WeakSet,l=function(){var c,h;return(h=(c=ns.get(this.remote))==null?void 0:c.getCastPlayer)==null?void 0:h.call(c)},d=new WeakSet,u=async function(){k(this,r).paused=Lu(t.prototype,this,"paused"),Lu(t.prototype,this,"pause").call(this),this.muted=Lu(t.prototype,this,"muted");try{await this.load()}catch(c){console.error(c)}},Se(t,"observedAttributes",[...(e=i.observedAttributes)!=null?e:[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"]),t},Gd=class extends Event{constructor(i,e){super(i),Se(this,"track"),this.track=e.track}},Hc=new WeakMap;function W(i){var e;return(e=Hc.get(i))!=null?e:rw(i,{})}function rw(i,e){let t=Hc.get(i);return t||Hc.set(i,t={}),Object.assign(t,e)}function Wc(i,e){let t=i.videoTracks;W(e).media=i,W(e).renditionSet||(W(e).renditionSet=new Set);let r=W(t).trackSet;r.add(e);let s=r.size-1;s in Vc.prototype||Object.defineProperty(Vc.prototype,s,{get(){return[...W(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Gd("addtrack",{track:e}))})}function Kc(i){var e;let t=(e=W(i).media)==null?void 0:e.videoTracks;t&&(W(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Gd("removetrack",{track:i}))}))}function sw(i){var e;let t=(e=W(i).media.videoTracks)!=null?e:[],r=!1;for(let s of t)s!==i&&(s.selected=!1,r=!0);if(r){if(W(t).changeRequested)return;W(t).changeRequested=!0,queueMicrotask(()=>{delete W(t).changeRequested,t.dispatchEvent(new Event("change"))})}}var wr,Cr,Dr,Gs,ea,Vc=class extends EventTarget{constructor(){super(),X(this,Gs),X(this,wr,void 0),X(this,Cr,void 0),X(this,Dr,void 0),W(this).trackSet=new Set}[Symbol.iterator](){return k(this,Gs,ea).values()}get length(){return k(this,Gs,ea).size}getTrackById(e){var t;return(t=[...k(this,Gs,ea)].find(r=>r.id===e))!=null?t:null}get selectedIndex(){return[...k(this,Gs,ea)].findIndex(e=>e.selected)}get onaddtrack(){return k(this,wr)}set onaddtrack(e){k(this,wr)&&(this.removeEventListener("addtrack",k(this,wr)),Q(this,wr,void 0)),typeof e=="function"&&(Q(this,wr,e),this.addEventListener("addtrack",e))}get onremovetrack(){return k(this,Cr)}set onremovetrack(e){k(this,Cr)&&(this.removeEventListener("removetrack",k(this,Cr)),Q(this,Cr,void 0)),typeof e=="function"&&(Q(this,Cr,e),this.addEventListener("removetrack",e))}get onchange(){return k(this,Dr)}set onchange(e){k(this,Dr)&&(this.removeEventListener("change",k(this,Dr)),Q(this,Dr,void 0)),typeof e=="function"&&(Q(this,Dr,e),this.addEventListener("change",e))}};wr=new WeakMap,Cr=new WeakMap,Dr=new WeakMap,Gs=new WeakSet,ea=function(){return W(this).trackSet};var Hd=class extends Event{constructor(e,t){super(e),Se(this,"rendition"),this.rendition=t.rendition}};function nw(i,e){let t=W(i).media.videoRenditions;W(e).media=W(i).media,W(e).track=i;let r=W(i).renditionSet;r.add(e);let s=r.size-1;s in qc.prototype||Object.defineProperty(qc.prototype,s,{get(){return Hs(this)[s]}}),queueMicrotask(()=>{i.selected&&t.dispatchEvent(new Hd("addrendition",{rendition:e}))})}function aw(i){let e=W(i).media.videoRenditions,t=W(i).track;W(t).renditionSet.delete(i),queueMicrotask(()=>{W(i).track.selected&&e.dispatchEvent(new Hd("removerendition",{rendition:i}))})}function ow(i){let e=W(i).media.videoRenditions;!e||W(e).changeRequested||(W(e).changeRequested=!0,queueMicrotask(()=>{delete W(e).changeRequested,W(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function Hs(i){return[...W(i).media.videoTracks].filter(e=>e.selected).flatMap(e=>[...W(e).renditionSet])}var Mr,Pr,Or,qc=class extends EventTarget{constructor(){super(...arguments),X(this,Mr,void 0),X(this,Pr,void 0),X(this,Or,void 0)}[Symbol.iterator](){return Hs(this).values()}get length(){return Hs(this).length}getRenditionById(e){var t;return(t=Hs(this).find(r=>`${r.id}`==`${e}`))!=null?t:null}get selectedIndex(){return Hs(this).findIndex(e=>e.selected)}set selectedIndex(e){for(let[t,r]of Hs(this).entries())r.selected=t===e}get onaddrendition(){return k(this,Mr)}set onaddrendition(e){k(this,Mr)&&(this.removeEventListener("addrendition",k(this,Mr)),Q(this,Mr,void 0)),typeof e=="function"&&(Q(this,Mr,e),this.addEventListener("addrendition",e))}get onremoverendition(){return k(this,Pr)}set onremoverendition(e){k(this,Pr)&&(this.removeEventListener("removerendition",k(this,Pr)),Q(this,Pr,void 0)),typeof e=="function"&&(Q(this,Pr,e),this.addEventListener("removerendition",e))}get onchange(){return k(this,Or)}set onchange(e){k(this,Or)&&(this.removeEventListener("change",k(this,Or)),Q(this,Or,void 0)),typeof e=="function"&&(Q(this,Or,e),this.addEventListener("change",e))}};Mr=new WeakMap,Pr=new WeakMap,Or=new WeakMap;var ta,lw=class{constructor(){Se(this,"src"),Se(this,"id"),Se(this,"width"),Se(this,"height"),Se(this,"bitrate"),Se(this,"frameRate"),Se(this,"codec"),X(this,ta,!1)}get selected(){return k(this,ta)}set selected(e){k(this,ta)!==e&&(Q(this,ta,e),ow(this))}};ta=new WeakMap;var ia,hy=class{constructor(){Se(this,"id"),Se(this,"kind"),Se(this,"label",""),Se(this,"language",""),Se(this,"sourceBuffer"),X(this,ia,!1)}addRendition(e,t,r,s,n,a){let o=new lw;return o.src=e,o.width=t,o.height=r,o.frameRate=a,o.bitrate=n,o.codec=s,nw(this,o),o}removeRendition(e){aw(e)}get selected(){return k(this,ia)}set selected(e){k(this,ia)!==e&&(Q(this,ia,e),e===!0&&sw(this))}};ia=new WeakMap;function dw(i,e){let t=W(i).media.audioRenditions;W(e).media=W(i).media,W(e).track=i;let r=W(i).renditionSet;r.add(e);let s=r.size-1;s in Yc.prototype||Object.defineProperty(Yc.prototype,s,{get(){return Ws(this)[s]}}),queueMicrotask(()=>{i.enabled&&t.dispatchEvent(new Hd("addrendition",{rendition:e}))})}function uw(i){let e=W(i).media.audioRenditions,t=W(i).track;W(t).renditionSet.delete(i),queueMicrotask(()=>{W(i).track.enabled&&e.dispatchEvent(new Hd("removerendition",{rendition:i}))})}function cw(i){let e=W(i).media.audioRenditions;!e||W(e).changeRequested||(W(e).changeRequested=!0,queueMicrotask(()=>{delete W(e).changeRequested,W(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function Ws(i){return[...W(i).media.audioTracks].filter(e=>e.enabled).flatMap(e=>[...W(e).renditionSet])}var Nr,Fr,Ur,Yc=class extends EventTarget{constructor(){super(...arguments),X(this,Nr,void 0),X(this,Fr,void 0),X(this,Ur,void 0)}[Symbol.iterator](){return Ws(this).values()}get length(){return Ws(this).length}getRenditionById(e){var t;return(t=Ws(this).find(r=>`${r.id}`==`${e}`))!=null?t:null}get selectedIndex(){return Ws(this).findIndex(e=>e.selected)}set selectedIndex(e){for(let[t,r]of Ws(this).entries())r.selected=t===e}get onaddrendition(){return k(this,Nr)}set onaddrendition(e){k(this,Nr)&&(this.removeEventListener("addrendition",k(this,Nr)),Q(this,Nr,void 0)),typeof e=="function"&&(Q(this,Nr,e),this.addEventListener("addrendition",e))}get onremoverendition(){return k(this,Fr)}set onremoverendition(e){k(this,Fr)&&(this.removeEventListener("removerendition",k(this,Fr)),Q(this,Fr,void 0)),typeof e=="function"&&(Q(this,Fr,e),this.addEventListener("removerendition",e))}get onchange(){return k(this,Ur)}set onchange(e){k(this,Ur)&&(this.removeEventListener("change",k(this,Ur)),Q(this,Ur,void 0)),typeof e=="function"&&(Q(this,Ur,e),this.addEventListener("change",e))}};Nr=new WeakMap,Fr=new WeakMap,Ur=new WeakMap;var ra,hw=class{constructor(){Se(this,"src"),Se(this,"id"),Se(this,"bitrate"),Se(this,"codec"),X(this,ra,!1)}get selected(){return k(this,ra)}set selected(e){k(this,ra)!==e&&(Q(this,ra,e),cw(this))}};ra=new WeakMap;function jc(i,e){let t=i.audioTracks;W(e).media=i,W(e).renditionSet||(W(e).renditionSet=new Set);let r=W(t).trackSet;r.add(e);let s=r.size-1;s in Xc.prototype||Object.defineProperty(Xc.prototype,s,{get(){return[...W(this).trackSet][s]}}),queueMicrotask(()=>{t.dispatchEvent(new Gd("addtrack",{track:e}))})}function zc(i){var e;let t=(e=W(i).media)==null?void 0:e.audioTracks;t&&(W(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Gd("removetrack",{track:i}))}))}function fw(i){let e=W(i).media.audioTracks;!e||W(e).changeRequested||(W(e).changeRequested=!0,queueMicrotask(()=>{delete W(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var $r,Br,Gr,sa,ml,Xc=class extends EventTarget{constructor(){super(),X(this,sa),X(this,$r,void 0),X(this,Br,void 0),X(this,Gr,void 0),W(this).trackSet=new Set}[Symbol.iterator](){return k(this,sa,ml).values()}get length(){return k(this,sa,ml).size}getTrackById(i){var e;return(e=[...k(this,sa,ml)].find(t=>t.id===i))!=null?e:null}get onaddtrack(){return k(this,$r)}set onaddtrack(i){k(this,$r)&&(this.removeEventListener("addtrack",k(this,$r)),Q(this,$r,void 0)),typeof i=="function"&&(Q(this,$r,i),this.addEventListener("addtrack",i))}get onremovetrack(){return k(this,Br)}set onremovetrack(i){k(this,Br)&&(this.removeEventListener("removetrack",k(this,Br)),Q(this,Br,void 0)),typeof i=="function"&&(Q(this,Br,i),this.addEventListener("removetrack",i))}get onchange(){return k(this,Gr)}set onchange(i){k(this,Gr)&&(this.removeEventListener("change",k(this,Gr)),Q(this,Gr,void 0)),typeof i=="function"&&(Q(this,Gr,i),this.addEventListener("change",i))}};$r=new WeakMap,Br=new WeakMap,Gr=new WeakMap,sa=new WeakSet,ml=function(){return W(this).trackSet};var na,fy=class{constructor(){Se(this,"id"),Se(this,"kind"),Se(this,"label",""),Se(this,"language",""),Se(this,"sourceBuffer"),X(this,na,!1)}addRendition(e,t,r){let s=new hw;return s.src=e,s.codec=t,s.bitrate=r,dw(this,s),s}removeRendition(e){uw(e)}get enabled(){return k(this,na)}set enabled(e){k(this,na)!==e&&(Q(this,na,e),fw(this))}};na=new WeakMap;var l0=bd(globalThis.HTMLMediaElement,"video"),d0=bd(globalThis.HTMLMediaElement,"audio");function mw(i){if(!(i!=null&&i.prototype))return i;let e=bd(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return pw(this)}});let t=bd(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return gw(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(n,a="",o=""){let l=new hy;return l.kind=n,l.label=a,l.language=o,Wc(this,l),l}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=Kc),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(n,a="",o=""){let l=new fy;return l.kind=n,l.label=a,l.language=o,jc(this,l),l}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=zc),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return r(this)}});let r=n=>{let a=W(n).videoRenditions;return a||(a=new qc,W(a).media=n,W(n).videoRenditions=a),a};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return s(this)}});let s=n=>{let a=W(n).audioRenditions;return a||(a=new Yc,W(a).media=n,W(n).audioRenditions=a),a};return i}function bd(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function pw(i){var e;let t=W(i).videoTracks;if(!t&&(t=new Vc,W(i).videoTracks=t,l0)){let r=l0.call((e=i.nativeEl)!=null?e:i);for(let s of r)Wc(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof hy)){for(let n of r)Kc(n);return}Wc(i,s.track)}),r.addEventListener("removetrack",s=>{Kc(s.track)})}return t}function gw(i){var e;let t=W(i).audioTracks;if(!t&&(t=new Xc,W(i).audioTracks=t,d0)){let r=d0.call((e=i.nativeEl)!=null?e:i);for(let s of r)jc(i,s);r.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),r.addEventListener("addtrack",s=>{if([...t].some(n=>n instanceof fy)){for(let n of r)zc(n);return}jc(i,s.track)}),r.addEventListener("removetrack",s=>{zc(s.track)})}return t}Of.push("castchange","entercast","leavecast");var P={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_TRACKING:"disable-tracking",DISABLE_COOKIES:"disable-cookies",DRM_TOKEN:"drm-token",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",MIN_RESOLUTION:"min-resolution",RENDITION_ORDER:"rendition-order",PROGRAM_START_TIME:"program-start-time",PROGRAM_END_TIME:"program-end-time",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},vw=Object.values(P),Ew=WR(),yw="mux-video",ci,aa,pl,oa,gl,vl,El,yl,la,bl,bw=class extends Ru{constructor(){super(),X(this,la),X(this,ci,void 0),X(this,aa,void 0),X(this,pl,void 0),X(this,oa,{}),X(this,gl,void 0),X(this,vl,void 0),X(this,El,void 0),X(this,yl,void 0),Q(this,pl,qk())}static get observedAttributes(){var e;return[...vw,...(e=Ru.observedAttributes)!=null?e:[]]}get preferCmcd(){var e;return(e=this.getAttribute(P.PREFER_CMCD))!=null?e:void 0}set preferCmcd(e){e!==this.preferCmcd&&(e?nd.includes(e)?this.setAttribute(P.PREFER_CMCD,e):console.warn(`Invalid value for preferCmcd. Must be one of ${nd.join()}`):this.removeAttribute(P.PREFER_CMCD))}get playerInitTime(){return k(this,pl)}get playerSoftwareName(){var e;return(e=k(this,El))!=null?e:yw}set playerSoftwareName(e){Q(this,El,e)}get playerSoftwareVersion(){var e;return(e=k(this,vl))!=null?e:Ew}set playerSoftwareVersion(e){Q(this,vl,e)}get _hls(){var e;return(e=k(this,ci))==null?void 0:e.engine}get mux(){var e;return(e=this.nativeEl)==null?void 0:e.mux}get error(){var e;return(e=Xk(this.nativeEl))!=null?e:null}get errorTranslator(){return k(this,yl)}set errorTranslator(e){Q(this,yl,e)}get src(){return this.getAttribute("src")}set src(e){e!==this.src&&(e==null?this.removeAttribute("src"):this.setAttribute("src",e))}get type(){var e;return(e=this.getAttribute(P.TYPE))!=null?e:void 0}set type(e){e!==this.type&&(e?this.setAttribute(P.TYPE,e):this.removeAttribute(P.TYPE))}get autoplay(){let e=this.getAttribute("autoplay");return e===null?!1:e===""?!0:e}set autoplay(e){let t=this.autoplay;e!==t&&(e?this.setAttribute("autoplay",typeof e=="string"?e:""):this.removeAttribute("autoplay"))}get preload(){let e=this.getAttribute("preload");return e===""?"auto":["none","metadata","auto"].includes(e)?e:super.preload}set preload(e){e!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(e)?this.setAttribute("preload",e):this.removeAttribute("preload"))}get debug(){return this.getAttribute(P.DEBUG)!=null}set debug(e){e!==this.debug&&(e?this.setAttribute(P.DEBUG,""):this.removeAttribute(P.DEBUG))}get disableTracking(){return this.hasAttribute(P.DISABLE_TRACKING)}set disableTracking(e){e!==this.disableTracking&&this.toggleAttribute(P.DISABLE_TRACKING,!!e)}get disableCookies(){return this.hasAttribute(P.DISABLE_COOKIES)}set disableCookies(e){e!==this.disableCookies&&(e?this.setAttribute(P.DISABLE_COOKIES,""):this.removeAttribute(P.DISABLE_COOKIES))}get startTime(){let e=this.getAttribute(P.START_TIME);if(e==null)return;let t=+e;return Number.isNaN(t)?void 0:t}set startTime(e){e!==this.startTime&&(e==null?this.removeAttribute(P.START_TIME):this.setAttribute(P.START_TIME,`${e}`))}get playbackId(){var e;return this.hasAttribute(P.PLAYBACK_ID)?this.getAttribute(P.PLAYBACK_ID):(e=hf(this.src))!=null?e:void 0}set playbackId(e){e!==this.playbackId&&(e?this.setAttribute(P.PLAYBACK_ID,e):this.removeAttribute(P.PLAYBACK_ID))}get maxResolution(){var e;return(e=this.getAttribute(P.MAX_RESOLUTION))!=null?e:void 0}set maxResolution(e){e!==this.maxResolution&&(e?this.setAttribute(P.MAX_RESOLUTION,e):this.removeAttribute(P.MAX_RESOLUTION))}get minResolution(){var e;return(e=this.getAttribute(P.MIN_RESOLUTION))!=null?e:void 0}set minResolution(e){e!==this.minResolution&&(e?this.setAttribute(P.MIN_RESOLUTION,e):this.removeAttribute(P.MIN_RESOLUTION))}get renditionOrder(){var e;return(e=this.getAttribute(P.RENDITION_ORDER))!=null?e:void 0}set renditionOrder(e){e!==this.renditionOrder&&(e?this.setAttribute(P.RENDITION_ORDER,e):this.removeAttribute(P.RENDITION_ORDER))}get programStartTime(){let e=this.getAttribute(P.PROGRAM_START_TIME);if(e==null)return;let t=+e;return Number.isNaN(t)?void 0:t}set programStartTime(e){e==null?this.removeAttribute(P.PROGRAM_START_TIME):this.setAttribute(P.PROGRAM_START_TIME,`${e}`)}get programEndTime(){let e=this.getAttribute(P.PROGRAM_END_TIME);if(e==null)return;let t=+e;return Number.isNaN(t)?void 0:t}set programEndTime(e){e==null?this.removeAttribute(P.PROGRAM_END_TIME):this.setAttribute(P.PROGRAM_END_TIME,`${e}`)}get customDomain(){var e;return(e=this.getAttribute(P.CUSTOM_DOMAIN))!=null?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(P.CUSTOM_DOMAIN,e):this.removeAttribute(P.CUSTOM_DOMAIN))}get drmToken(){var e;return(e=this.getAttribute(P.DRM_TOKEN))!=null?e:void 0}set drmToken(e){e!==this.drmToken&&(e?this.setAttribute(P.DRM_TOKEN,e):this.removeAttribute(P.DRM_TOKEN))}get ended(){return Iv(this.nativeEl,this._hls)}get envKey(){var e;return(e=this.getAttribute(P.ENV_KEY))!=null?e:void 0}set envKey(e){e!==this.envKey&&(e?this.setAttribute(P.ENV_KEY,e):this.removeAttribute(P.ENV_KEY))}get beaconCollectionDomain(){var e;return(e=this.getAttribute(P.BEACON_COLLECTION_DOMAIN))!=null?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(P.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(P.BEACON_COLLECTION_DOMAIN))}get streamType(){var e;return(e=this.getAttribute(P.STREAM_TYPE))!=null?e:hc(this.nativeEl)}set streamType(e){e!==this.streamType&&(e?this.setAttribute(P.STREAM_TYPE,e):this.removeAttribute(P.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(P.TARGET_LIVE_WINDOW)?+this.getAttribute(P.TARGET_LIVE_WINDOW):Qk(this.nativeEl)}set targetLiveWindow(e){e!=this.targetLiveWindow&&(e==null?this.removeAttribute(P.TARGET_LIVE_WINDOW):this.setAttribute(P.TARGET_LIVE_WINDOW,`${+e}`))}get liveEdgeStart(){var e,t;if(this.hasAttribute(P.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:r}=this,s=(e=this.nativeEl.seekable.end(0))!=null?e:0,n=(t=this.nativeEl.seekable.start(0))!=null?t:0;return Math.max(n,s-r)}return Zk(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(P.LIVE_EDGE_OFFSET))return+this.getAttribute(P.LIVE_EDGE_OFFSET)}set liveEdgeOffset(e){e!=this.targetLiveWindow&&(e==null?this.removeAttribute(P.LIVE_EDGE_OFFSET):this.setAttribute(P.LIVE_EDGE_OFFSET,`${+e}`))}get seekable(){return ad(this.nativeEl)}async addCuePoints(e){return bv(this.nativeEl,e)}get activeCuePoint(){return Tv(this.nativeEl)}get cuePoints(){return wk(this.nativeEl)}async addChapters(e){return Av(this.nativeEl,e)}get activeChapter(){return Sv(this.nativeEl)}get chapters(){return Dk(this.nativeEl)}getStartDate(){return Pk(this.nativeEl,this._hls)}get currentPdt(){return Ok(this.nativeEl,this._hls)}get preferPlayback(){let e=this.getAttribute(P.PREFER_PLAYBACK);if(e===Ti.MSE||e===Ti.NATIVE)return e}set preferPlayback(e){e!==this.preferPlayback&&(e===Ti.MSE||e===Ti.NATIVE?this.setAttribute(P.PREFER_PLAYBACK,e):this.removeAttribute(P.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(e=>e.startsWith("metadata-")&&![P.METADATA_URL].includes(e)).reduce((e,t)=>{let r=this.getAttribute(t);return r!=null&&(e[t.replace(/^metadata-/,"").replace(/-/g,"_")]=r),e},{}),...k(this,oa)}}set metadata(e){Q(this,oa,e??{}),this.mux&&this.mux.emit("hb",k(this,oa))}get _hlsConfig(){return k(this,gl)}set _hlsConfig(e){Q(this,gl,e)}load(){Q(this,ci,tL(this,this.nativeEl,k(this,ci)))}unload(){Rv(this.nativeEl,k(this,ci)),Q(this,ci,void 0)}attributeChangedCallback(e,t,r){var s,n;switch(Ru.observedAttributes.includes(e)&&!["src","autoplay","preload"].includes(e)&&super.attributeChangedCallback(e,t,r),e){case P.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=r??void 0;break;case P.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=r??void 0;break;case"src":{let a=!!t,o=!!r;!a&&o?Ce(this,la,bl).call(this):a&&!o?this.unload():a&&o&&(this.unload(),Ce(this,la,bl).call(this));break}case"autoplay":if(r===t)break;(s=k(this,ci))==null||s.setAutoplay(this.autoplay);break;case"preload":if(r===t)break;(n=k(this,ci))==null||n.setPreload(r);break;case P.PLAYBACK_ID:this.src=cc(this);break;case P.DEBUG:{let a=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=a);break}case P.METADATA_URL:r&&fetch(r).then(a=>a.json()).then(a=>this.metadata=a).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${r}!`));break;case P.STREAM_TYPE:(r==null||r!==t)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case P.TARGET_LIVE_WINDOW:(r==null||r!==t)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break}}connectedCallback(){var e;(e=super.connectedCallback)==null||e.call(this),this.nativeEl&&this.src&&!k(this,ci)&&Ce(this,la,bl).call(this)}disconnectedCallback(){this.unload()}};ci=new WeakMap,aa=new WeakMap,pl=new WeakMap,oa=new WeakMap,gl=new WeakMap,vl=new WeakMap,El=new WeakMap,yl=new WeakMap,la=new WeakSet,bl=async function(){k(this,aa)||(await Q(this,aa,Promise.resolve()),Q(this,aa,null),this.load())};var Tl,Qc=class extends iw(mw(bw)){constructor(){super(...arguments),X(this,Tl,void 0)}get muxCastCustomData(){return{mux:{playbackId:this.playbackId,minResolution:this.minResolution,maxResolution:this.maxResolution,renditionOrder:this.renditionOrder,customDomain:this.customDomain,tokens:{drm:this.drmToken},envKey:this.envKey,metadata:this.metadata,disableCookies:this.disableCookies,disableTracking:this.disableTracking,beaconCollectionDomain:this.beaconCollectionDomain,startTime:this.startTime,preferCmcd:this.preferCmcd}}}get castCustomData(){var e;return(e=k(this,Tl))!=null?e:this.muxCastCustomData}set castCustomData(e){Q(this,Tl,e)}};Tl=new WeakMap;Iu.customElements.get("mux-video")||(Iu.customElements.define("mux-video",Qc),Iu.MuxVideoElement=Qc);var Tw=Qc,my=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},de=(i,e,t)=>(my(i,e,"read from private field"),t?t.call(i):e.get(i)),vi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Gi=(i,e,t,r)=>(my(i,e,"write to private field"),e.set(i,t),t),Ks,_l,Hr,da,er,tr,ir,Wr,Vs,Al,Ht;const u0=1,c0=0,_w=1,Aw={processCallback(i,e,t){if(t){for(const[r,s]of e)if(r in t){const n=t[r];typeof n=="boolean"&&s instanceof Xt&&typeof s.element[s.attributeName]=="boolean"?s.booleanValue=n:typeof n=="function"&&s instanceof Xt?s.element[s.attributeName]=n:s.value=n}}}};class Wd extends R.DocumentFragment{constructor(e,t,r=Aw){var s;super(),vi(this,Ks,void 0),vi(this,_l,void 0),this.append(e.content.cloneNode(!0)),Gi(this,Ks,py(this)),Gi(this,_l,r),(s=r.createCallback)==null||s.call(r,this,de(this,Ks),t),r.processCallback(this,de(this,Ks),t)}update(e){de(this,_l).processCallback(this,de(this,Ks),e)}}Ks=new WeakMap;_l=new WeakMap;const py=(i,e=[])=>{let t,r;for(const s of i.attributes||[])if(s.value.includes("{{")){const n=new xw;for([t,r]of f0(s.value))if(!t)n.append(r);else{const a=new Xt(i,s.name,s.namespaceURI);n.append(a),e.push([r,a])}s.value=n.toString()}for(const s of i.childNodes)if(s.nodeType===u0&&!(s instanceof HTMLTemplateElement))py(s,e);else{const n=s.data;if(s.nodeType===u0||n.includes("{{")){const a=[];if(n)for([t,r]of f0(n))if(!t)a.push(new Text(r));else{const o=new Sn(i);a.push(o),e.push([r,o])}else if(s instanceof HTMLTemplateElement){const o=new Ey(i,s);a.push(o),e.push([o.expression,o])}s.replaceWith(...a.flatMap(o=>o.replacementNodes||[o]))}}return e},h0={},f0=i=>{let e="",t=0,r=h0[i],s=0,n;if(r)return r;for(r=[];n=i[s];s++)n==="{"&&i[s+1]==="{"&&i[s-1]!=="\\"&&i[s+2]&&++t==1?(e&&r.push([c0,e]),e="",s++):n==="}"&&i[s+1]==="}"&&i[s-1]!=="\\"&&!--t?(r.push([_w,e.trim()]),e="",s++):e+=n||"";return e&&r.push([c0,(t>0?"{{":"")+e]),h0[i]=r},Sw=11;class gy{get value(){return""}set value(e){}toString(){return this.value}}const vy=new WeakMap;class xw{constructor(){vi(this,Hr,[])}[Symbol.iterator](){return de(this,Hr).values()}get length(){return de(this,Hr).length}item(e){return de(this,Hr)[e]}append(...e){for(const t of e)t instanceof Xt&&vy.set(t,this),de(this,Hr).push(t)}toString(){return de(this,Hr).join("")}}Hr=new WeakMap;class Xt extends gy{constructor(e,t,r){super(),vi(this,Wr),vi(this,da,""),vi(this,er,void 0),vi(this,tr,void 0),vi(this,ir,void 0),Gi(this,er,e),Gi(this,tr,t),Gi(this,ir,r)}get attributeName(){return de(this,tr)}get attributeNamespace(){return de(this,ir)}get element(){return de(this,er)}get value(){return de(this,da)}set value(e){de(this,da)!==e&&(Gi(this,da,e),!de(this,Wr,Vs)||de(this,Wr,Vs).length===1?e==null?de(this,er).removeAttributeNS(de(this,ir),de(this,tr)):de(this,er).setAttributeNS(de(this,ir),de(this,tr),e):de(this,er).setAttributeNS(de(this,ir),de(this,tr),de(this,Wr,Vs).toString()))}get booleanValue(){return de(this,er).hasAttributeNS(de(this,ir),de(this,tr))}set booleanValue(e){if(!de(this,Wr,Vs)||de(this,Wr,Vs).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}}da=new WeakMap;er=new WeakMap;tr=new WeakMap;ir=new WeakMap;Wr=new WeakSet;Vs=function(){return vy.get(this)};class Sn extends gy{constructor(e,t){super(),vi(this,Al,void 0),vi(this,Ht,void 0),Gi(this,Al,e),Gi(this,Ht,t?[...t]:[new Text])}get replacementNodes(){return de(this,Ht)}get parentNode(){return de(this,Al)}get nextSibling(){return de(this,Ht)[de(this,Ht).length-1].nextSibling}get previousSibling(){return de(this,Ht)[0].previousSibling}get value(){return de(this,Ht).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){const t=e.flat().flatMap(r=>r==null?[new Text]:r.forEach?[...r]:r.nodeType===Sw?[...r.childNodes]:r.nodeType?[r]:[new Text(r)]);t.length||t.push(new Text),Gi(this,Ht,kw(de(this,Ht)[0].parentNode,de(this,Ht),t,this.nextSibling))}}Al=new WeakMap;Ht=new WeakMap;class Ey extends Sn{constructor(e,t){const r=t.getAttribute("directive")||t.getAttribute("type");let s=t.getAttribute("expression")||t.getAttribute(r)||"";s.startsWith("{{")&&(s=s.trim().slice(2,-2).trim()),super(e),this.expression=s,this.template=t,this.directive=r}}function kw(i,e,t,r=null){let s=0,n,a,o,l=t.length,d=e.length;for(;s<l&&s<d&&e[s]==t[s];)s++;for(;s<l&&s<d&&t[l-1]==e[d-1];)r=t[--d,--l];if(s==d)for(;s<l;)i.insertBefore(t[s++],r);if(s==l)for(;s<d;)i.removeChild(e[s++]);else{for(n=e[s];s<l;)o=t[s++],a=n?n.nextSibling:r,n==o?n=a:s<l&&t[s]==a?(i.replaceChild(o,n),n=a):i.insertBefore(o,n);for(;n!=r;)a=n.nextSibling,i.removeChild(n),n=a}return t}const m0={string:i=>String(i)};class yy{constructor(e){this.template=e,this.state=void 0}}const Jr=new WeakMap,es=new WeakMap,Zc={partial:(i,e)=>{e[i.expression]=new yy(i.template)},if:(i,e)=>{var t;if(by(i.expression,e))if(Jr.get(i)!==i.template){Jr.set(i,i.template);const r=new Wd(i.template,e,Uf);i.replace(r),es.set(i,r)}else(t=es.get(i))==null||t.update(e);else i.replace(""),Jr.delete(i),es.delete(i)}},Lw=Object.keys(Zc),Uf={processCallback(i,e,t){var r,s;if(t)for(const[n,a]of e){if(a instanceof Ey){if(!a.directive){const l=Lw.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(r=Zc[a.directive])==null||r.call(Zc,a,t);continue}let o=by(n,t);if(o instanceof yy){Jr.get(a)!==o.template?(Jr.set(a,o.template),o=new Wd(o.template,o.state,Uf),a.value=o,es.set(a,o)):(s=es.get(a))==null||s.update(o.state);continue}o?(a instanceof Xt&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof Xt?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,Jr.delete(a),es.delete(a))):a instanceof Xt?a.value=void 0:(a.value=void 0,Jr.delete(a),es.delete(a))}}},p0={"!":i=>!i,"!!":i=>!!i,"==":(i,e)=>i==e,"!=":(i,e)=>i!=e,">":(i,e)=>i>e,">=":(i,e)=>i>=e,"<":(i,e)=>i<e,"<=":(i,e)=>i<=e,"??":(i,e)=>i??e,"|":(i,e)=>{var t;return(t=m0[e])==null?void 0:t.call(m0,i)}};function Iw(i){return Rw(i,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function by(i,e={}){var t,r,s,n,a,o,l;const d=Iw(i);if(d.length===0||d.some(({type:u})=>!u))return Pn(i);if(((t=d[0])==null?void 0:t.token)===">"){const u=e[(r=d[1])==null?void 0:r.token];if(!u)return Pn(i);const c={...e};u.state=c;const h=d.slice(2);for(let f=0;f<h.length;f+=3){const m=(s=h[f])==null?void 0:s.token,p=(n=h[f+1])==null?void 0:n.token,g=(a=h[f+2])==null?void 0:a.token;m&&p==="="&&(c[m]=On(g,e))}return u}if(d.length===1)return Ao(d[0])?On(d[0].token,e):Pn(i);if(d.length===2){const u=(o=d[0])==null?void 0:o.token,c=p0[u];if(!c||!Ao(d[1]))return Pn(i);const h=On(d[1].token,e);return c(h)}if(d.length===3){const u=(l=d[1])==null?void 0:l.token,c=p0[u];if(!c||!Ao(d[0])||!Ao(d[2]))return Pn(i);const h=On(d[0].token,e);if(u==="|")return c(h,d[2].token);const f=On(d[2].token,e);return c(h,f)}}function Pn(i){return console.warn(`Warning: invalid expression \`${i}\``),!1}function Ao({type:i}){return["number","boolean","string","param"].includes(i)}function On(i,e){const t=i[0],r=i.slice(-1);return i==="true"||i==="false"?i==="true":t===r&&["'",'"'].includes(t)?i.slice(1,-1):Uv(i)?parseFloat(i):e[i]}function Rw(i,e){let t,r,s;const n=[];for(;i;){s=null,t=i.length;for(const a in e)r=e[a].exec(i),r&&r.index<t&&(s={token:r[0],type:a,matches:r.slice(1)},t=r.index);t&&n.push({token:i.substr(0,t),type:void 0}),s&&n.push(s),i=i.substr(t+(s?s.token.length:0))}return n}var $f=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Jc=(i,e,t)=>($f(i,e,"read from private field"),t?t.call(i):e.get(i)),Nn=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ts=(i,e,t,r)=>($f(i,e,"write to private field"),e.set(i,t),t),Du=(i,e,t)=>($f(i,e,"access private method"),t),an,Sl,on,eh,Ty,xl,th;const Mu={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},_y=Z.createElement("template");_y.innerHTML=`
1296
1296
  <style>
1297
1297
  :host {
1298
1298
  display: inline-block;
@@ -1322,7 +1322,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1322
1322
  display: none;
1323
1323
  }
1324
1324
  </style>
1325
- `;class Hd extends R.HTMLElement{constructor(){super(),On(this,Zc),On(this,Al),On(this,nn,void 0),On(this,_l,void 0),On(this,an,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer());const e=new MutationObserver(t=>{var r;this.mediaController&&!((r=this.mediaController)!=null&&r.breakpointsComputed)||t.some(s=>{const n=s.target;return n===this?!0:n.localName!=="media-controller"?!1:!!(Cu[s.attributeName]||s.attributeName.startsWith("breakpoint"))})&&this.render()});e.observe(this,{attributes:!0}),e.observe(this.renderRoot,{attributes:!0,subtree:!0}),this.addEventListener(ms.BREAKPOINTS_COMPUTED,this.render),wu(this,Zc,yy).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return(e=Qc(this,nn))!=null?e:this.constructor.template}set template(e){ts(this,an,null),ts(this,nn,e),this.createRenderer()}get props(){var e,t,r;const s=[...Array.from((t=(e=this.mediaController)==null?void 0:e.attributes)!=null?t:[]).filter(({name:a})=>Cu[a]||a.startsWith("breakpoint")),...Array.from(this.attributes)],n={};for(const a of s){const o=(r=Cu[a.name])!=null?r:yL(a.name);let{value:l}=a;l!=null?(Nv(l)&&(l=parseFloat(l)),n[o]=l===""?!0:l):n[o]=!1}return n}attributeChangedCallback(e,t,r){e==="template"&&t!=r&&wu(this,Al,Jc).call(this)}connectedCallback(){wu(this,Al,Jc).call(this)}createRenderer(){this.template&&this.template!==Qc(this,_l)&&(ts(this,_l,this.template),this.renderer=new Gd(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(by.content.cloneNode(!0),this.renderer))}render(){var e;if((e=this.renderer)==null||e.update(this.props),this.renderRoot.isConnected){const{style:t}=je(this.renderRoot,":host");t.visibility==="hidden"&&t.removeProperty("visibility")}}}nn=new WeakMap;_l=new WeakMap;an=new WeakMap;Zc=new WeakSet;yy=function(i){if(Object.prototype.hasOwnProperty.call(this,i)){const e=this[i];delete this[i],this[i]=e}};Al=new WeakSet;Jc=function(){var i;const e=this.getAttribute("template");if(!e||e===Qc(this,an))return;const t=this.getRootNode(),r=(i=t==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(r){ts(this,an,e),ts(this,nn,r),this.createRenderer();return}Iw(e)&&(ts(this,an,e),Rw(e).then(s=>{const n=Z.createElement("template");n.innerHTML=s,ts(this,nn,n),this.createRenderer()}).catch(console.error))};Hd.observedAttributes=["template"];Hd.processor=Nf;function Iw(i){if(!/^(\/|\.\/|https?:\/\/)/.test(i))return!1;const e=/^https?:\/\//.test(i)?void 0:location.origin;try{new URL(i,e)}catch{return!1}return!0}async function Rw(i){const e=await fetch(i);if(e.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${e.status}`);return e.text()}R.customElements.get("media-theme")||R.customElements.define("media-theme",Hd);function ww({anchor:i,floating:e,placement:t}){const r=Cw({anchor:i,floating:e}),{x:s,y:n}=Mw(r,t);return{x:s,y:n}}function Cw({anchor:i,floating:e}){return{anchor:Dw(i,e.offsetParent),floating:{x:0,y:0,width:e.offsetWidth,height:e.offsetHeight}}}function Dw(i,e){var t;const r=i.getBoundingClientRect(),s=(t=e==null?void 0:e.getBoundingClientRect())!=null?t:{x:0,y:0};return{x:r.x-s.x,y:r.y-s.y,width:r.width,height:r.height}}function Mw({anchor:i,floating:e},t){const r=Pw(t)==="x"?"y":"x",s=r==="y"?"height":"width",n=Ty(t),a=i.x+i.width/2-e.width/2,o=i.y+i.height/2-e.height/2,l=i[s]/2-e[s]/2;let d;switch(n){case"top":d={x:a,y:i.y-e.height};break;case"bottom":d={x:a,y:i.y+i.height};break;case"right":d={x:i.x+i.width,y:o};break;case"left":d={x:i.x-e.width,y:o};break;default:d={x:i.x,y:i.y}}switch(t.split("-")[1]){case"start":d[r]-=l;break;case"end":d[r]+=l;break}return d}function Ty(i){return i.split("-")[0]}function Pw(i){return["top","bottom"].includes(Ty(i))?"y":"x"}class Uf extends Event{constructor({action:e="auto",relatedTarget:t,...r}){super("invoke",r),this.action=e,this.relatedTarget=t}}class Ow extends Event{constructor({newState:e,oldState:t,...r}){super("toggle",r),this.newState=e,this.oldState=t}}var $f=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ge=(i,e,t)=>($f(i,e,"read from private field"),t?t.call(i):e.get(i)),Ae=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},hi=(i,e,t,r)=>($f(i,e,"write to private field"),e.set(i,t),t),ke=(i,e,t)=>($f(i,e,"access private method"),t),fi,as,Er,Sl,xl,os,Ga,eh,_y,yd,kl,th,ih,Ay,rh,Sy,sh,xy,on,ln,dn,Ha,bd,Bf,nh,ky,Gf,Ly,ah,Iy,Hf,Ry,oh,wy,lh,Cy,_a,Td,dh,Dy,Aa,_d,Ll,uh;function bn({type:i,text:e,value:t,checked:r}){const s=Z.createElement("media-chrome-menu-item");s.type=i??"",s.part.add("menu-item"),i&&s.part.add(i),s.value=t,s.checked=r;const n=Z.createElement("span");return n.textContent=e,s.append(n),s}function ls(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);if((t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t)return t=t.cloneNode(!0),t;const r=i.shadowRoot.querySelector(`[name="${e}"] > svg`);return r?r.cloneNode(!0):""}const My=Z.createElement("template");My.innerHTML=`
1325
+ `;class Kd extends R.HTMLElement{constructor(){super(),Nn(this,eh),Nn(this,xl),Nn(this,an,void 0),Nn(this,Sl,void 0),Nn(this,on,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer());const e=new MutationObserver(t=>{var r;this.mediaController&&!((r=this.mediaController)!=null&&r.breakpointsComputed)||t.some(s=>{const n=s.target;return n===this?!0:n.localName!=="media-controller"?!1:!!(Mu[s.attributeName]||s.attributeName.startsWith("breakpoint"))})&&this.render()});e.observe(this,{attributes:!0}),e.observe(this.renderRoot,{attributes:!0,subtree:!0}),this.addEventListener(ms.BREAKPOINTS_COMPUTED,this.render),Du(this,eh,Ty).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return(e=Jc(this,an))!=null?e:this.constructor.template}set template(e){ts(this,on,null),ts(this,an,e),this.createRenderer()}get props(){var e,t,r;const s=[...Array.from((t=(e=this.mediaController)==null?void 0:e.attributes)!=null?t:[]).filter(({name:a})=>Mu[a]||a.startsWith("breakpoint")),...Array.from(this.attributes)],n={};for(const a of s){const o=(r=Mu[a.name])!=null?r:TL(a.name);let{value:l}=a;l!=null?(Uv(l)&&(l=parseFloat(l)),n[o]=l===""?!0:l):n[o]=!1}return n}attributeChangedCallback(e,t,r){e==="template"&&t!=r&&Du(this,xl,th).call(this)}connectedCallback(){Du(this,xl,th).call(this)}createRenderer(){this.template&&this.template!==Jc(this,Sl)&&(ts(this,Sl,this.template),this.renderer=new Wd(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(_y.content.cloneNode(!0),this.renderer))}render(){var e;if((e=this.renderer)==null||e.update(this.props),this.renderRoot.isConnected){const{style:t}=je(this.renderRoot,":host");t.visibility==="hidden"&&t.removeProperty("visibility")}}}an=new WeakMap;Sl=new WeakMap;on=new WeakMap;eh=new WeakSet;Ty=function(i){if(Object.prototype.hasOwnProperty.call(this,i)){const e=this[i];delete this[i],this[i]=e}};xl=new WeakSet;th=function(){var i;const e=this.getAttribute("template");if(!e||e===Jc(this,on))return;const t=this.getRootNode(),r=(i=t==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(r){ts(this,on,e),ts(this,an,r),this.createRenderer();return}ww(e)&&(ts(this,on,e),Cw(e).then(s=>{const n=Z.createElement("template");n.innerHTML=s,ts(this,an,n),this.createRenderer()}).catch(console.error))};Kd.observedAttributes=["template"];Kd.processor=Uf;function ww(i){if(!/^(\/|\.\/|https?:\/\/)/.test(i))return!1;const e=/^https?:\/\//.test(i)?void 0:location.origin;try{new URL(i,e)}catch{return!1}return!0}async function Cw(i){const e=await fetch(i);if(e.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${e.status}`);return e.text()}R.customElements.get("media-theme")||R.customElements.define("media-theme",Kd);function Dw({anchor:i,floating:e,placement:t}){const r=Mw({anchor:i,floating:e}),{x:s,y:n}=Ow(r,t);return{x:s,y:n}}function Mw({anchor:i,floating:e}){return{anchor:Pw(i,e.offsetParent),floating:{x:0,y:0,width:e.offsetWidth,height:e.offsetHeight}}}function Pw(i,e){var t;const r=i.getBoundingClientRect(),s=(t=e==null?void 0:e.getBoundingClientRect())!=null?t:{x:0,y:0};return{x:r.x-s.x,y:r.y-s.y,width:r.width,height:r.height}}function Ow({anchor:i,floating:e},t){const r=Nw(t)==="x"?"y":"x",s=r==="y"?"height":"width",n=Ay(t),a=i.x+i.width/2-e.width/2,o=i.y+i.height/2-e.height/2,l=i[s]/2-e[s]/2;let d;switch(n){case"top":d={x:a,y:i.y-e.height};break;case"bottom":d={x:a,y:i.y+i.height};break;case"right":d={x:i.x+i.width,y:o};break;case"left":d={x:i.x-e.width,y:o};break;default:d={x:i.x,y:i.y}}switch(t.split("-")[1]){case"start":d[r]-=l;break;case"end":d[r]+=l;break}return d}function Ay(i){return i.split("-")[0]}function Nw(i){return["top","bottom"].includes(Ay(i))?"y":"x"}class Bf extends Event{constructor({action:e="auto",relatedTarget:t,...r}){super("invoke",r),this.action=e,this.relatedTarget=t}}class Fw extends Event{constructor({newState:e,oldState:t,...r}){super("toggle",r),this.newState=e,this.oldState=t}}var Gf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ge=(i,e,t)=>(Gf(i,e,"read from private field"),t?t.call(i):e.get(i)),Ae=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},hi=(i,e,t,r)=>(Gf(i,e,"write to private field"),e.set(i,t),t),ke=(i,e,t)=>(Gf(i,e,"access private method"),t),fi,as,Er,kl,Ll,os,Ha,ih,Sy,Td,Il,rh,sh,xy,nh,ky,ah,Ly,ln,dn,un,Wa,_d,Hf,oh,Iy,Wf,Ry,lh,wy,Kf,Cy,dh,Dy,uh,My,Aa,Ad,ch,Py,Sa,Sd,Rl,hh;function Tn({type:i,text:e,value:t,checked:r}){const s=Z.createElement("media-chrome-menu-item");s.type=i??"",s.part.add("menu-item"),i&&s.part.add(i),s.value=t,s.checked=r;const n=Z.createElement("span");return n.textContent=e,s.append(n),s}function ls(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);if((t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t)return t=t.cloneNode(!0),t;const r=i.shadowRoot.querySelector(`[name="${e}"] > svg`);return r?r.cloneNode(!0):""}const Oy=Z.createElement("template");Oy.innerHTML=`
1326
1326
  <style>
1327
1327
  :host {
1328
1328
  font: var(--media-font,
@@ -1489,7 +1489,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1489
1489
  <slot></slot>
1490
1490
  </div>
1491
1491
  <slot name="checked-indicator" hidden></slot>
1492
- `;const Ar={STYLE:"style",HIDDEN:"hidden",DISABLED:"disabled",ANCHOR:"anchor"};class qi extends R.HTMLElement{constructor(){super(),Ae(this,eh),Ae(this,kl),Ae(this,ih),Ae(this,rh),Ae(this,sh),Ae(this,dn),Ae(this,bd),Ae(this,nh),Ae(this,Gf),Ae(this,ah),Ae(this,Hf),Ae(this,oh),Ae(this,lh),Ae(this,_a),Ae(this,dh),Ae(this,Aa),Ae(this,Ll),Ae(this,fi,null),Ae(this,as,null),Ae(this,Er,null),Ae(this,Sl,new Set),Ae(this,xl,void 0),Ae(this,os,!1),Ae(this,Ga,null),Ae(this,yd,()=>{const e=ge(this,Sl),t=new Set(this.items);for(const r of e)t.has(r)||this.dispatchEvent(new CustomEvent("removemenuitem",{detail:r}));for(const r of t)e.has(r)||this.dispatchEvent(new CustomEvent("addmenuitem",{detail:r}));hi(this,Sl,t)}),Ae(this,on,()=>{ke(this,dn,Ha).call(this),ke(this,bd,Bf).call(this,!1)}),Ae(this,ln,()=>{ke(this,dn,Ha).call(this)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.defaultSlot=this.shadowRoot.querySelector("slot:not([name])"),this.shadowRoot.addEventListener("slotchange",this),hi(this,xl,new MutationObserver(ge(this,yd))),ge(this,xl).observe(this.defaultSlot,{childList:!0})}static get observedAttributes(){return[Ar.DISABLED,Ar.HIDDEN,Ar.STYLE,Ar.ANCHOR,Te.MEDIA_CONTROLLER]}static formatMenuItemText(e){return e}enable(){this.addEventListener("click",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this),this.addEventListener("invoke",this),this.addEventListener("toggle",this)}disable(){this.removeEventListener("click",this),this.removeEventListener("focusout",this),this.removeEventListener("keyup",this),this.removeEventListener("invoke",this),this.removeEventListener("toggle",this)}handleEvent(e){switch(e.type){case"slotchange":ke(this,eh,_y).call(this,e);break;case"invoke":ke(this,ih,Ay).call(this,e);break;case"click":ke(this,nh,ky).call(this,e);break;case"toggle":ke(this,ah,Iy).call(this,e);break;case"focusout":ke(this,oh,wy).call(this,e);break;case"keydown":ke(this,lh,Cy).call(this,e);break}}connectedCallback(){var e,t;hi(this,Ga,mf(this.shadowRoot,":host")),ke(this,kl,th).call(this),this.hasAttribute("disabled")||this.enable(),this.role||(this.role="menu"),hi(this,fi,hc(this)),(t=(e=ge(this,fi))==null?void 0:e.associateElement)==null||t.call(e,this),this.hidden||(vn(Wa(this),ge(this,on)),vn(this,ge(this,ln)))}disconnectedCallback(){var e,t;Ca(Wa(this),ge(this,on)),Ca(this,ge(this,ln)),this.disable(),(t=(e=ge(this,fi))==null?void 0:e.unassociateElement)==null||t.call(e,this),hi(this,fi,null)}attributeChangedCallback(e,t,r){var s,n,a,o;e===Ar.HIDDEN&&r!==t?(ge(this,os)||hi(this,os,!0),this.hidden?ke(this,sh,xy).call(this):ke(this,rh,Sy).call(this),this.dispatchEvent(new Ow({oldState:this.hidden?"open":"closed",newState:this.hidden?"closed":"open",bubbles:!0}))):e===Te.MEDIA_CONTROLLER?(t&&((n=(s=ge(this,fi))==null?void 0:s.unassociateElement)==null||n.call(s,this),hi(this,fi,null)),r&&this.isConnected&&(hi(this,fi,hc(this)),(o=(a=ge(this,fi))==null?void 0:a.associateElement)==null||o.call(a,this))):e===Ar.DISABLED&&r!==t?r==null?this.enable():this.disable():e===Ar.STYLE&&r!==t&&ke(this,kl,th).call(this)}formatMenuItemText(e,t){return this.constructor.formatMenuItemText(e,t)}get anchor(){return this.getAttribute("anchor")}set anchor(e){this.setAttribute("anchor",`${e}`)}get anchorElement(){var e;return this.anchor?(e=Cd(this))==null?void 0:e.querySelector(`#${this.anchor}`):null}get items(){return this.defaultSlot.assignedElements({flatten:!0}).filter(Nw)}get radioGroupItems(){return this.items.filter(e=>e.role==="menuitemradio")}get checkedItems(){return this.items.filter(e=>e.checked)}get value(){var e,t;return(t=(e=this.checkedItems[0])==null?void 0:e.value)!=null?t:""}set value(e){const t=this.items.find(r=>r.value===e);t&&ke(this,Ll,uh).call(this,t)}focus(){if(hi(this,as,ff()),this.items.length){ke(this,Aa,_d).call(this,this.items[0]),this.items[0].focus();return}const e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}handleSelect(e){var t;const r=ke(this,_a,Td).call(this,e);r&&(ke(this,Ll,uh).call(this,r,r.type==="checkbox"),ge(this,Er)&&!this.hidden&&((t=ge(this,as))==null||t.focus(),this.hidden=!0))}get keysUsed(){return["Enter","Escape","Tab"," ","ArrowDown","ArrowUp","Home","End"]}handleMove(e){var t,r;const{key:s}=e,n=this.items,a=(r=(t=ke(this,_a,Td).call(this,e))!=null?t:ke(this,dh,Dy).call(this))!=null?r:n[0],o=n.indexOf(a);let l=Math.max(0,o);s==="ArrowDown"?l++:s==="ArrowUp"?l--:e.key==="Home"?l=0:e.key==="End"&&(l=n.length-1),l<0&&(l=n.length-1),l>n.length-1&&(l=0),ke(this,Aa,_d).call(this,n[l]),n[l].focus()}}fi=new WeakMap;as=new WeakMap;Er=new WeakMap;Sl=new WeakMap;xl=new WeakMap;os=new WeakMap;Ga=new WeakMap;eh=new WeakSet;_y=function(i){const e=i.target;for(const t of e.assignedNodes({flatten:!0}))t.nodeType===3&&t.textContent.trim()===""&&t.remove();if(["header","title"].includes(e.name)){const t=this.shadowRoot.querySelector('slot[name="header"]');t.hidden=e.assignedNodes().length===0}e.name||ge(this,yd).call(this)};yd=new WeakMap;kl=new WeakSet;th=function(){var i;const e=this.shadowRoot.querySelector("#layout-row"),t=(i=getComputedStyle(this).getPropertyValue("--media-menu-layout"))==null?void 0:i.trim();e.setAttribute("media",t==="row"?"":"width:0")};ih=new WeakSet;Ay=function(i){hi(this,Er,i.relatedTarget),Vi(this,i.relatedTarget)||(this.hidden=!this.hidden)};rh=new WeakSet;Sy=function(){var i;(i=ge(this,Er))==null||i.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0}),vn(Wa(this),ge(this,on)),vn(this,ge(this,ln))};sh=new WeakSet;xy=function(){var i;(i=ge(this,Er))==null||i.setAttribute("aria-expanded","false"),Ca(Wa(this),ge(this,on)),Ca(this,ge(this,ln))};on=new WeakMap;ln=new WeakMap;dn=new WeakSet;Ha=function(i){if(this.hasAttribute("mediacontroller")&&!this.anchor||this.hidden||!this.anchorElement)return;const{x:e,y:t}=ww({anchor:this.anchorElement,floating:this,placement:"top-start"});i??(i=this.offsetWidth);const s=Wa(this).getBoundingClientRect(),n=s.width-e-i,a=s.height-t-this.offsetHeight,{style:o}=ge(this,Ga);o.setProperty("position","absolute"),o.setProperty("right",`${Math.max(0,n)}px`),o.setProperty("--_menu-bottom",`${a}px`);const l=getComputedStyle(this),u=o.getPropertyValue("--_menu-bottom")===l.bottom?a:parseFloat(l.bottom),c=s.height-u-parseFloat(l.marginBottom);this.style.setProperty("--_menu-max-height",`${c}px`)};bd=new WeakSet;Bf=function(i){const e=this.querySelector('[role="menuitem"][aria-haspopup][aria-expanded="true"]'),t=e==null?void 0:e.querySelector('[role="menu"]'),{style:r}=ge(this,Ga);if(i||r.setProperty("--media-menu-transition-in","none"),t){const s=t.offsetHeight,n=Math.max(t.offsetWidth,e.offsetWidth);this.style.setProperty("min-width",`${n}px`),this.style.setProperty("min-height",`${s}px`),ke(this,dn,Ha).call(this,n)}else this.style.removeProperty("min-width"),this.style.removeProperty("min-height"),ke(this,dn,Ha).call(this);r.removeProperty("--media-menu-transition-in")};nh=new WeakSet;ky=function(i){var e;if(i.stopPropagation(),i.composedPath().includes(ge(this,Gf,Ly))){(e=ge(this,as))==null||e.focus(),this.hidden=!0;return}const t=ke(this,_a,Td).call(this,i);!t||t.hasAttribute("disabled")||(ke(this,Aa,_d).call(this,t),this.handleSelect(i))};Gf=new WeakSet;Ly=function(){var i;return(i=this.shadowRoot.querySelector('slot[name="header"]').assignedElements({flatten:!0}))==null?void 0:i.find(t=>t.matches('button[part~="back"]'))};ah=new WeakSet;Iy=function(i){if(i.target===this)return;ke(this,Hf,Ry).call(this);const e=Array.from(this.querySelectorAll('[role="menuitem"][aria-haspopup]'));for(const t of e)t.invokeTargetElement!=i.target&&i.newState=="open"&&t.getAttribute("aria-expanded")=="true"&&!t.invokeTargetElement.hidden&&t.invokeTargetElement.dispatchEvent(new Uf({relatedTarget:t}));for(const t of e)t.setAttribute("aria-expanded",`${!t.submenuElement.hidden}`);ke(this,bd,Bf).call(this,!0)};Hf=new WeakSet;Ry=function(){const e=this.querySelector('[role="menuitem"] > [role="menu"]:not([hidden])');this.container.classList.toggle("has-expanded",!!e)};oh=new WeakSet;wy=function(i){var e;Vi(this,i.relatedTarget)||(ge(this,os)&&((e=ge(this,as))==null||e.focus()),ge(this,Er)&&ge(this,Er)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};lh=new WeakSet;Cy=function(i){var e,t,r,s,n;const{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;if(!(o||l||d)&&this.keysUsed.includes(a))if(i.preventDefault(),i.stopPropagation(),a==="Tab"){if(ge(this,os)){this.hidden=!0;return}i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(s=(r=this.nextElementSibling)==null?void 0:r.focus)==null||s.call(r),this.blur()}else a==="Escape"?((n=ge(this,as))==null||n.focus(),ge(this,os)&&(this.hidden=!0)):a==="Enter"||a===" "?this.handleSelect(i):this.handleMove(i)};_a=new WeakSet;Td=function(i){return i.composedPath().find(e=>["menuitemradio","menuitemcheckbox"].includes(e.role))};dh=new WeakSet;Dy=function(){return this.items.find(i=>i.tabIndex===0)};Aa=new WeakSet;_d=function(i){for(const e of this.items)e.tabIndex=e===i?0:-1};Ll=new WeakSet;uh=function(i,e){const t=[...this.checkedItems];i.type==="radio"&&this.radioGroupItems.forEach(r=>r.checked=!1),e?i.checked=!i.checked:i.checked=!0,this.checkedItems.some((r,s)=>r!=t[s])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};qi.template=My;function Nw(i){return["menuitem","menuitemradio","menuitemcheckbox"].includes(i==null?void 0:i.role)}function Wa(i){var e;return(e=i.getAttribute("bounds")?_n(i,`#${i.getAttribute("bounds")}`):$t(i)||i.parentElement)!=null?e:i}R.customElements.get("media-chrome-menu")||R.customElements.define("media-chrome-menu",qi);var Wf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},_i=(i,e,t)=>(Wf(i,e,"read from private field"),e.get(i)),Mi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Du=(i,e,t,r)=>(Wf(i,e,"write to private field"),e.set(i,t),t),Ei=(i,e,t)=>(Wf(i,e,"access private method"),t),Il,Sa,ch,Py,Kf,Oy,Vf,Ny,Ai,Tn,Ka,hh,Fy,Rl,fh;const Uy=Z.createElement("template");Uy.innerHTML=`
1492
+ `;const Ar={STYLE:"style",HIDDEN:"hidden",DISABLED:"disabled",ANCHOR:"anchor"};class qi extends R.HTMLElement{constructor(){super(),Ae(this,ih),Ae(this,Il),Ae(this,sh),Ae(this,nh),Ae(this,ah),Ae(this,un),Ae(this,_d),Ae(this,oh),Ae(this,Wf),Ae(this,lh),Ae(this,Kf),Ae(this,dh),Ae(this,uh),Ae(this,Aa),Ae(this,ch),Ae(this,Sa),Ae(this,Rl),Ae(this,fi,null),Ae(this,as,null),Ae(this,Er,null),Ae(this,kl,new Set),Ae(this,Ll,void 0),Ae(this,os,!1),Ae(this,Ha,null),Ae(this,Td,()=>{const e=ge(this,kl),t=new Set(this.items);for(const r of e)t.has(r)||this.dispatchEvent(new CustomEvent("removemenuitem",{detail:r}));for(const r of t)e.has(r)||this.dispatchEvent(new CustomEvent("addmenuitem",{detail:r}));hi(this,kl,t)}),Ae(this,ln,()=>{ke(this,un,Wa).call(this),ke(this,_d,Hf).call(this,!1)}),Ae(this,dn,()=>{ke(this,un,Wa).call(this)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.defaultSlot=this.shadowRoot.querySelector("slot:not([name])"),this.shadowRoot.addEventListener("slotchange",this),hi(this,Ll,new MutationObserver(ge(this,Td))),ge(this,Ll).observe(this.defaultSlot,{childList:!0})}static get observedAttributes(){return[Ar.DISABLED,Ar.HIDDEN,Ar.STYLE,Ar.ANCHOR,Te.MEDIA_CONTROLLER]}static formatMenuItemText(e){return e}enable(){this.addEventListener("click",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this),this.addEventListener("invoke",this),this.addEventListener("toggle",this)}disable(){this.removeEventListener("click",this),this.removeEventListener("focusout",this),this.removeEventListener("keyup",this),this.removeEventListener("invoke",this),this.removeEventListener("toggle",this)}handleEvent(e){switch(e.type){case"slotchange":ke(this,ih,Sy).call(this,e);break;case"invoke":ke(this,sh,xy).call(this,e);break;case"click":ke(this,oh,Iy).call(this,e);break;case"toggle":ke(this,lh,wy).call(this,e);break;case"focusout":ke(this,dh,Dy).call(this,e);break;case"keydown":ke(this,uh,My).call(this,e);break}}connectedCallback(){var e,t;hi(this,Ha,gf(this.shadowRoot,":host")),ke(this,Il,rh).call(this),this.hasAttribute("disabled")||this.enable(),this.role||(this.role="menu"),hi(this,fi,mc(this)),(t=(e=ge(this,fi))==null?void 0:e.associateElement)==null||t.call(e,this),this.hidden||(En(Ka(this),ge(this,ln)),En(this,ge(this,dn)))}disconnectedCallback(){var e,t;Da(Ka(this),ge(this,ln)),Da(this,ge(this,dn)),this.disable(),(t=(e=ge(this,fi))==null?void 0:e.unassociateElement)==null||t.call(e,this),hi(this,fi,null)}attributeChangedCallback(e,t,r){var s,n,a,o;e===Ar.HIDDEN&&r!==t?(ge(this,os)||hi(this,os,!0),this.hidden?ke(this,ah,Ly).call(this):ke(this,nh,ky).call(this),this.dispatchEvent(new Fw({oldState:this.hidden?"open":"closed",newState:this.hidden?"closed":"open",bubbles:!0}))):e===Te.MEDIA_CONTROLLER?(t&&((n=(s=ge(this,fi))==null?void 0:s.unassociateElement)==null||n.call(s,this),hi(this,fi,null)),r&&this.isConnected&&(hi(this,fi,mc(this)),(o=(a=ge(this,fi))==null?void 0:a.associateElement)==null||o.call(a,this))):e===Ar.DISABLED&&r!==t?r==null?this.enable():this.disable():e===Ar.STYLE&&r!==t&&ke(this,Il,rh).call(this)}formatMenuItemText(e,t){return this.constructor.formatMenuItemText(e,t)}get anchor(){return this.getAttribute("anchor")}set anchor(e){this.setAttribute("anchor",`${e}`)}get anchorElement(){var e;return this.anchor?(e=Md(this))==null?void 0:e.querySelector(`#${this.anchor}`):null}get items(){return this.defaultSlot.assignedElements({flatten:!0}).filter(Uw)}get radioGroupItems(){return this.items.filter(e=>e.role==="menuitemradio")}get checkedItems(){return this.items.filter(e=>e.checked)}get value(){var e,t;return(t=(e=this.checkedItems[0])==null?void 0:e.value)!=null?t:""}set value(e){const t=this.items.find(r=>r.value===e);t&&ke(this,Rl,hh).call(this,t)}focus(){if(hi(this,as,pf()),this.items.length){ke(this,Sa,Sd).call(this,this.items[0]),this.items[0].focus();return}const e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}handleSelect(e){var t;const r=ke(this,Aa,Ad).call(this,e);r&&(ke(this,Rl,hh).call(this,r,r.type==="checkbox"),ge(this,Er)&&!this.hidden&&((t=ge(this,as))==null||t.focus(),this.hidden=!0))}get keysUsed(){return["Enter","Escape","Tab"," ","ArrowDown","ArrowUp","Home","End"]}handleMove(e){var t,r;const{key:s}=e,n=this.items,a=(r=(t=ke(this,Aa,Ad).call(this,e))!=null?t:ke(this,ch,Py).call(this))!=null?r:n[0],o=n.indexOf(a);let l=Math.max(0,o);s==="ArrowDown"?l++:s==="ArrowUp"?l--:e.key==="Home"?l=0:e.key==="End"&&(l=n.length-1),l<0&&(l=n.length-1),l>n.length-1&&(l=0),ke(this,Sa,Sd).call(this,n[l]),n[l].focus()}}fi=new WeakMap;as=new WeakMap;Er=new WeakMap;kl=new WeakMap;Ll=new WeakMap;os=new WeakMap;Ha=new WeakMap;ih=new WeakSet;Sy=function(i){const e=i.target;for(const t of e.assignedNodes({flatten:!0}))t.nodeType===3&&t.textContent.trim()===""&&t.remove();if(["header","title"].includes(e.name)){const t=this.shadowRoot.querySelector('slot[name="header"]');t.hidden=e.assignedNodes().length===0}e.name||ge(this,Td).call(this)};Td=new WeakMap;Il=new WeakSet;rh=function(){var i;const e=this.shadowRoot.querySelector("#layout-row"),t=(i=getComputedStyle(this).getPropertyValue("--media-menu-layout"))==null?void 0:i.trim();e.setAttribute("media",t==="row"?"":"width:0")};sh=new WeakSet;xy=function(i){hi(this,Er,i.relatedTarget),Vi(this,i.relatedTarget)||(this.hidden=!this.hidden)};nh=new WeakSet;ky=function(){var i;(i=ge(this,Er))==null||i.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0}),En(Ka(this),ge(this,ln)),En(this,ge(this,dn))};ah=new WeakSet;Ly=function(){var i;(i=ge(this,Er))==null||i.setAttribute("aria-expanded","false"),Da(Ka(this),ge(this,ln)),Da(this,ge(this,dn))};ln=new WeakMap;dn=new WeakMap;un=new WeakSet;Wa=function(i){if(this.hasAttribute("mediacontroller")&&!this.anchor||this.hidden||!this.anchorElement)return;const{x:e,y:t}=Dw({anchor:this.anchorElement,floating:this,placement:"top-start"});i??(i=this.offsetWidth);const s=Ka(this).getBoundingClientRect(),n=s.width-e-i,a=s.height-t-this.offsetHeight,{style:o}=ge(this,Ha);o.setProperty("position","absolute"),o.setProperty("right",`${Math.max(0,n)}px`),o.setProperty("--_menu-bottom",`${a}px`);const l=getComputedStyle(this),u=o.getPropertyValue("--_menu-bottom")===l.bottom?a:parseFloat(l.bottom),c=s.height-u-parseFloat(l.marginBottom);this.style.setProperty("--_menu-max-height",`${c}px`)};_d=new WeakSet;Hf=function(i){const e=this.querySelector('[role="menuitem"][aria-haspopup][aria-expanded="true"]'),t=e==null?void 0:e.querySelector('[role="menu"]'),{style:r}=ge(this,Ha);if(i||r.setProperty("--media-menu-transition-in","none"),t){const s=t.offsetHeight,n=Math.max(t.offsetWidth,e.offsetWidth);this.style.setProperty("min-width",`${n}px`),this.style.setProperty("min-height",`${s}px`),ke(this,un,Wa).call(this,n)}else this.style.removeProperty("min-width"),this.style.removeProperty("min-height"),ke(this,un,Wa).call(this);r.removeProperty("--media-menu-transition-in")};oh=new WeakSet;Iy=function(i){var e;if(i.stopPropagation(),i.composedPath().includes(ge(this,Wf,Ry))){(e=ge(this,as))==null||e.focus(),this.hidden=!0;return}const t=ke(this,Aa,Ad).call(this,i);!t||t.hasAttribute("disabled")||(ke(this,Sa,Sd).call(this,t),this.handleSelect(i))};Wf=new WeakSet;Ry=function(){var i;return(i=this.shadowRoot.querySelector('slot[name="header"]').assignedElements({flatten:!0}))==null?void 0:i.find(t=>t.matches('button[part~="back"]'))};lh=new WeakSet;wy=function(i){if(i.target===this)return;ke(this,Kf,Cy).call(this);const e=Array.from(this.querySelectorAll('[role="menuitem"][aria-haspopup]'));for(const t of e)t.invokeTargetElement!=i.target&&i.newState=="open"&&t.getAttribute("aria-expanded")=="true"&&!t.invokeTargetElement.hidden&&t.invokeTargetElement.dispatchEvent(new Bf({relatedTarget:t}));for(const t of e)t.setAttribute("aria-expanded",`${!t.submenuElement.hidden}`);ke(this,_d,Hf).call(this,!0)};Kf=new WeakSet;Cy=function(){const e=this.querySelector('[role="menuitem"] > [role="menu"]:not([hidden])');this.container.classList.toggle("has-expanded",!!e)};dh=new WeakSet;Dy=function(i){var e;Vi(this,i.relatedTarget)||(ge(this,os)&&((e=ge(this,as))==null||e.focus()),ge(this,Er)&&ge(this,Er)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};uh=new WeakSet;My=function(i){var e,t,r,s,n;const{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;if(!(o||l||d)&&this.keysUsed.includes(a))if(i.preventDefault(),i.stopPropagation(),a==="Tab"){if(ge(this,os)){this.hidden=!0;return}i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(s=(r=this.nextElementSibling)==null?void 0:r.focus)==null||s.call(r),this.blur()}else a==="Escape"?((n=ge(this,as))==null||n.focus(),ge(this,os)&&(this.hidden=!0)):a==="Enter"||a===" "?this.handleSelect(i):this.handleMove(i)};Aa=new WeakSet;Ad=function(i){return i.composedPath().find(e=>["menuitemradio","menuitemcheckbox"].includes(e.role))};ch=new WeakSet;Py=function(){return this.items.find(i=>i.tabIndex===0)};Sa=new WeakSet;Sd=function(i){for(const e of this.items)e.tabIndex=e===i?0:-1};Rl=new WeakSet;hh=function(i,e){const t=[...this.checkedItems];i.type==="radio"&&this.radioGroupItems.forEach(r=>r.checked=!1),e?i.checked=!i.checked:i.checked=!0,this.checkedItems.some((r,s)=>r!=t[s])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};qi.template=Oy;function Uw(i){return["menuitem","menuitemradio","menuitemcheckbox"].includes(i==null?void 0:i.role)}function Ka(i){var e;return(e=i.getAttribute("bounds")?An(i,`#${i.getAttribute("bounds")}`):$t(i)||i.parentElement)!=null?e:i}R.customElements.get("media-chrome-menu")||R.customElements.define("media-chrome-menu",qi);var Vf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},_i=(i,e,t)=>(Vf(i,e,"read from private field"),e.get(i)),Mi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Pu=(i,e,t,r)=>(Vf(i,e,"write to private field"),e.set(i,t),t),Ei=(i,e,t)=>(Vf(i,e,"access private method"),t),wl,xa,fh,Ny,qf,Fy,Yf,Uy,Ai,_n,Va,mh,$y,Cl,ph;const By=Z.createElement("template");By.innerHTML=`
1493
1493
  <style>
1494
1494
  :host {
1495
1495
  transition: var(--media-menu-item-transition,
@@ -1605,7 +1605,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1605
1605
  <slot name="description"></slot>
1606
1606
  <slot name="suffix"></slot>
1607
1607
  <slot name="submenu"></slot>
1608
- `;const Pt={TYPE:"type",VALUE:"value",CHECKED:"checked",DISABLED:"disabled"};class Wd extends R.HTMLElement{constructor(){super(),Mi(this,ch),Mi(this,Kf),Mi(this,Vf),Mi(this,Tn),Mi(this,hh),Mi(this,Rl),Mi(this,Il,!1),Mi(this,Sa,void 0),Mi(this,Ai,()=>{var e,t;this.setAttribute("submenusize",`${this.submenuElement.items.length}`);const r=this.shadowRoot.querySelector('slot[name="description"]'),s=(e=this.submenuElement.checkedItems)==null?void 0:e[0],n=(t=s==null?void 0:s.dataset.description)!=null?t:s==null?void 0:s.text,a=Z.createElement("span");a.textContent=n??"",r.replaceChildren(a)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0))),this.shadowRoot.addEventListener("slotchange",this)}static get observedAttributes(){return[Pt.TYPE,Pt.DISABLED,Pt.CHECKED,Pt.VALUE]}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),Nn(this)&&!this.hasAttribute("aria-checked")&&this.setAttribute("aria-checked","false"),this.addEventListener("click",this),this.addEventListener("keydown",this)}disable(){this.removeAttribute("tabindex"),this.removeEventListener("click",this),this.removeEventListener("keydown",this),this.removeEventListener("keyup",this)}handleEvent(e){switch(e.type){case"slotchange":Ei(this,ch,Py).call(this,e);break;case"click":this.handleClick(e);break;case"keydown":Ei(this,hh,Fy).call(this,e);break;case"keyup":Ei(this,Tn,Ka).call(this,e);break}}attributeChangedCallback(e,t,r){e===Pt.CHECKED&&Nn(this)&&!_i(this,Il)?this.setAttribute("aria-checked",r!=null?"true":"false"):e===Pt.TYPE&&r!==t?this.role="menuitem"+r:e===Pt.DISABLED&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(Pt.DISABLED)||this.enable(),this.role="menuitem"+this.type,Du(this,Sa,mh(this,this.parentNode)),Ei(this,Rl,fh).call(this)}disconnectedCallback(){this.disable(),Ei(this,Rl,fh).call(this),Du(this,Sa,null)}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=Cd(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):this.submenuElement}get submenuElement(){return this.shadowRoot.querySelector('slot[name="submenu"]').assignedElements({flatten:!0})[0]}get type(){var e;return(e=this.getAttribute(Pt.TYPE))!=null?e:""}set type(e){this.setAttribute(Pt.TYPE,`${e}`)}get value(){var e;return(e=this.getAttribute(Pt.VALUE))!=null?e:this.text}set value(e){this.setAttribute(Pt.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get checked(){if(Nn(this))return this.getAttribute("aria-checked")==="true"}set checked(e){Nn(this)&&(Du(this,Il,!0),this.setAttribute("aria-checked",e?"true":"false"),e?this.part.add("checked"):this.part.remove("checked"))}handleClick(e){Nn(this)||this.invokeTargetElement&&Vi(this,e.target)&&this.invokeTargetElement.dispatchEvent(new Uf({relatedTarget:this}))}get keysUsed(){return["Enter"," "]}}Il=new WeakMap;Sa=new WeakMap;ch=new WeakSet;Py=function(i){const e=i.target;if(!(e!=null&&e.name))for(const r of e.assignedNodes({flatten:!0}))r instanceof Text&&r.textContent.trim()===""&&r.remove();e.name==="submenu"&&(this.submenuElement?Ei(this,Kf,Oy).call(this):Ei(this,Vf,Ny).call(this))};Kf=new WeakSet;Oy=async function(){this.setAttribute("aria-haspopup","menu"),this.setAttribute("aria-expanded",`${!this.submenuElement.hidden}`),this.submenuElement.addEventListener("change",_i(this,Ai)),this.submenuElement.addEventListener("addmenuitem",_i(this,Ai)),this.submenuElement.addEventListener("removemenuitem",_i(this,Ai)),_i(this,Ai).call(this)};Vf=new WeakSet;Ny=function(){this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.submenuElement.removeEventListener("change",_i(this,Ai)),this.submenuElement.removeEventListener("addmenuitem",_i(this,Ai)),this.submenuElement.removeEventListener("removemenuitem",_i(this,Ai)),_i(this,Ai).call(this)};Ai=new WeakMap;Tn=new WeakSet;Ka=function(i){const{key:e}=i;if(!this.keysUsed.includes(e)){this.removeEventListener("keyup",Ei(this,Tn,Ka));return}this.handleClick(i)};hh=new WeakSet;Fy=function(i){const{metaKey:e,altKey:t,key:r}=i;if(e||t||!this.keysUsed.includes(r)){this.removeEventListener("keyup",Ei(this,Tn,Ka));return}this.addEventListener("keyup",Ei(this,Tn,Ka),{once:!0})};Rl=new WeakSet;fh=function(){var i;const e=(i=_i(this,Sa))==null?void 0:i.radioGroupItems;if(!e)return;let t=e.filter(r=>r.getAttribute("aria-checked")==="true").pop();t||(t=e[0]);for(const r of e)r.setAttribute("aria-checked","false");t==null||t.setAttribute("aria-checked","true")};Wd.template=Uy;function Nn(i){return i.type==="radio"||i.type==="checkbox"}function mh(i,e){if(!i)return null;const{host:t}=i.getRootNode();return!e&&t?mh(i,t):e!=null&&e.items?e:mh(e,e==null?void 0:e.parentNode)}R.customElements.get("media-chrome-menu-item")||R.customElements.define("media-chrome-menu-item",Wd);const $y=Z.createElement("template");$y.innerHTML=qi.template.innerHTML+`
1608
+ `;const Pt={TYPE:"type",VALUE:"value",CHECKED:"checked",DISABLED:"disabled"};class Vd extends R.HTMLElement{constructor(){super(),Mi(this,fh),Mi(this,qf),Mi(this,Yf),Mi(this,_n),Mi(this,mh),Mi(this,Cl),Mi(this,wl,!1),Mi(this,xa,void 0),Mi(this,Ai,()=>{var e,t;this.setAttribute("submenusize",`${this.submenuElement.items.length}`);const r=this.shadowRoot.querySelector('slot[name="description"]'),s=(e=this.submenuElement.checkedItems)==null?void 0:e[0],n=(t=s==null?void 0:s.dataset.description)!=null?t:s==null?void 0:s.text,a=Z.createElement("span");a.textContent=n??"",r.replaceChildren(a)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0))),this.shadowRoot.addEventListener("slotchange",this)}static get observedAttributes(){return[Pt.TYPE,Pt.DISABLED,Pt.CHECKED,Pt.VALUE]}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),Fn(this)&&!this.hasAttribute("aria-checked")&&this.setAttribute("aria-checked","false"),this.addEventListener("click",this),this.addEventListener("keydown",this)}disable(){this.removeAttribute("tabindex"),this.removeEventListener("click",this),this.removeEventListener("keydown",this),this.removeEventListener("keyup",this)}handleEvent(e){switch(e.type){case"slotchange":Ei(this,fh,Ny).call(this,e);break;case"click":this.handleClick(e);break;case"keydown":Ei(this,mh,$y).call(this,e);break;case"keyup":Ei(this,_n,Va).call(this,e);break}}attributeChangedCallback(e,t,r){e===Pt.CHECKED&&Fn(this)&&!_i(this,wl)?this.setAttribute("aria-checked",r!=null?"true":"false"):e===Pt.TYPE&&r!==t?this.role="menuitem"+r:e===Pt.DISABLED&&r!==t&&(r==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(Pt.DISABLED)||this.enable(),this.role="menuitem"+this.type,Pu(this,xa,gh(this,this.parentNode)),Ei(this,Cl,ph).call(this)}disconnectedCallback(){this.disable(),Ei(this,Cl,ph).call(this),Pu(this,xa,null)}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=Md(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):this.submenuElement}get submenuElement(){return this.shadowRoot.querySelector('slot[name="submenu"]').assignedElements({flatten:!0})[0]}get type(){var e;return(e=this.getAttribute(Pt.TYPE))!=null?e:""}set type(e){this.setAttribute(Pt.TYPE,`${e}`)}get value(){var e;return(e=this.getAttribute(Pt.VALUE))!=null?e:this.text}set value(e){this.setAttribute(Pt.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get checked(){if(Fn(this))return this.getAttribute("aria-checked")==="true"}set checked(e){Fn(this)&&(Pu(this,wl,!0),this.setAttribute("aria-checked",e?"true":"false"),e?this.part.add("checked"):this.part.remove("checked"))}handleClick(e){Fn(this)||this.invokeTargetElement&&Vi(this,e.target)&&this.invokeTargetElement.dispatchEvent(new Bf({relatedTarget:this}))}get keysUsed(){return["Enter"," "]}}wl=new WeakMap;xa=new WeakMap;fh=new WeakSet;Ny=function(i){const e=i.target;if(!(e!=null&&e.name))for(const r of e.assignedNodes({flatten:!0}))r instanceof Text&&r.textContent.trim()===""&&r.remove();e.name==="submenu"&&(this.submenuElement?Ei(this,qf,Fy).call(this):Ei(this,Yf,Uy).call(this))};qf=new WeakSet;Fy=async function(){this.setAttribute("aria-haspopup","menu"),this.setAttribute("aria-expanded",`${!this.submenuElement.hidden}`),this.submenuElement.addEventListener("change",_i(this,Ai)),this.submenuElement.addEventListener("addmenuitem",_i(this,Ai)),this.submenuElement.addEventListener("removemenuitem",_i(this,Ai)),_i(this,Ai).call(this)};Yf=new WeakSet;Uy=function(){this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.submenuElement.removeEventListener("change",_i(this,Ai)),this.submenuElement.removeEventListener("addmenuitem",_i(this,Ai)),this.submenuElement.removeEventListener("removemenuitem",_i(this,Ai)),_i(this,Ai).call(this)};Ai=new WeakMap;_n=new WeakSet;Va=function(i){const{key:e}=i;if(!this.keysUsed.includes(e)){this.removeEventListener("keyup",Ei(this,_n,Va));return}this.handleClick(i)};mh=new WeakSet;$y=function(i){const{metaKey:e,altKey:t,key:r}=i;if(e||t||!this.keysUsed.includes(r)){this.removeEventListener("keyup",Ei(this,_n,Va));return}this.addEventListener("keyup",Ei(this,_n,Va),{once:!0})};Cl=new WeakSet;ph=function(){var i;const e=(i=_i(this,xa))==null?void 0:i.radioGroupItems;if(!e)return;let t=e.filter(r=>r.getAttribute("aria-checked")==="true").pop();t||(t=e[0]);for(const r of e)r.setAttribute("aria-checked","false");t==null||t.setAttribute("aria-checked","true")};Vd.template=By;function Fn(i){return i.type==="radio"||i.type==="checkbox"}function gh(i,e){if(!i)return null;const{host:t}=i.getRootNode();return!e&&t?gh(i,t):e!=null&&e.items?e:gh(e,e==null?void 0:e.parentNode)}R.customElements.get("media-chrome-menu-item")||R.customElements.define("media-chrome-menu-item",Vd);const Gy=Z.createElement("template");Gy.innerHTML=qi.template.innerHTML+`
1609
1609
  <style>
1610
1610
  :host {
1611
1611
  background: var(--media-settings-menu-background,
@@ -1632,7 +1632,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1632
1632
  --media-settings-menu-item-opacity: 0;
1633
1633
  }
1634
1634
  </style>
1635
- `;class By extends qi{get anchorElement(){return this.anchor!=="auto"?super.anchorElement:$t(this).querySelector("media-settings-menu-button")}}By.template=$y;R.customElements.get("media-settings-menu")||R.customElements.define("media-settings-menu",By);var m0;const Ad=Z.createElement("template");Ad.innerHTML=Wd.template.innerHTML+`
1635
+ `;class Hy extends qi{get anchorElement(){return this.anchor!=="auto"?super.anchorElement:$t(this).querySelector("media-settings-menu-button")}}Hy.template=Gy;R.customElements.get("media-settings-menu")||R.customElements.define("media-settings-menu",Hy);var g0;const xd=Z.createElement("template");xd.innerHTML=Vd.template.innerHTML+`
1636
1636
  <style>
1637
1637
  slot:not([name="submenu"]) {
1638
1638
  opacity: var(--media-settings-menu-item-opacity, var(--media-menu-item-opacity));
@@ -1642,11 +1642,11 @@ svg, img, ::slotted(svg), ::slotted(img) {
1642
1642
  background: transparent;
1643
1643
  }
1644
1644
  </style>
1645
- `;(m0=Ad.content)!=null&&m0.querySelector&&(Ad.content.querySelector('slot[name="suffix"]').innerHTML=`
1645
+ `;(g0=xd.content)!=null&&g0.querySelector&&(xd.content.querySelector('slot[name="suffix"]').innerHTML=`
1646
1646
  <svg aria-hidden="true" viewBox="0 0 20 24">
1647
1647
  <path d="m8.12 17.585-.742-.669 4.2-4.665-4.2-4.666.743-.669 4.803 5.335-4.803 5.334Z"/>
1648
1648
  </svg>
1649
- `);class Gy extends Wd{}Gy.template=Ad;R.customElements.get("media-settings-menu-item")||R.customElements.define("media-settings-menu-item",Gy);class Sn extends wt{connectedCallback(){super.connectedCallback(),this.invokeTargetElement&&this.setAttribute("aria-haspopup","menu")}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=Cd(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):null}handleClick(){var e;(e=this.invokeTargetElement)==null||e.dispatchEvent(new Uf({relatedTarget:this}))}}R.customElements.get("media-chrome-menu-button")||R.customElements.define("media-chrome-menu-button",Sn);const Hy=Z.createElement("template");Hy.innerHTML=`
1649
+ `);class Wy extends Vd{}Wy.template=xd;R.customElements.get("media-settings-menu-item")||R.customElements.define("media-settings-menu-item",Wy);class xn extends wt{connectedCallback(){super.connectedCallback(),this.invokeTargetElement&&this.setAttribute("aria-haspopup","menu")}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=Md(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):null}handleClick(){var e;(e=this.invokeTargetElement)==null||e.dispatchEvent(new Bf({relatedTarget:this}))}}R.customElements.get("media-chrome-menu-button")||R.customElements.define("media-chrome-menu-button",xn);const Ky=Z.createElement("template");Ky.innerHTML=`
1650
1650
  <style>
1651
1651
  :host([aria-expanded="true"]) slot[name=tooltip] {
1652
1652
  display: none;
@@ -1657,25 +1657,25 @@ svg, img, ::slotted(svg), ::slotted(img) {
1657
1657
  <path d="M4.5 14.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z"/>
1658
1658
  </svg>
1659
1659
  </slot>
1660
- `;class Fw extends Sn{static get observedAttributes(){return[...super.observedAttributes,"target"]}constructor(){super({slotTemplate:Hy,tooltipContent:Fe.SETTINGS})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Rt.SETTINGS())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:$t(this).querySelector("media-settings-menu")}}R.customElements.get("media-settings-menu-button")||R.customElements.define("media-settings-menu-button",Fw);var qf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Wy=(i,e,t)=>(qf(i,e,"read from private field"),t?t.call(i):e.get(i)),_o=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ph=(i,e,t,r)=>(qf(i,e,"write to private field"),e.set(i,t),t),Ao=(i,e,t)=>(qf(i,e,"access private method"),t),da,Sd,wl,gh,Cl,vh;class Uw extends qi{constructor(){super(...arguments),_o(this,wl),_o(this,Cl),_o(this,da,[]),_o(this,Sd,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_AUDIO_TRACK_ENABLED&&t!==r?this.value=r:e===T.MEDIA_AUDIO_TRACK_LIST&&t!==r&&(ph(this,da,gL(r??"")),Ao(this,wl,gh).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Ao(this,Cl,vh))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Ao(this,Cl,vh))}get anchorElement(){var e;return this.anchor!=="auto"?super.anchorElement:(e=$t(this))==null?void 0:e.querySelector("media-audio-track-menu-button")}get mediaAudioTrackList(){return Wy(this,da)}set mediaAudioTrackList(e){ph(this,da,e),Ao(this,wl,gh).call(this)}get mediaAudioTrackEnabled(){var e;return(e=Qe(this,T.MEDIA_AUDIO_TRACK_ENABLED))!=null?e:""}set mediaAudioTrackEnabled(e){Ze(this,T.MEDIA_AUDIO_TRACK_ENABLED,e)}}da=new WeakMap;Sd=new WeakMap;wl=new WeakSet;gh=function(){if(Wy(this,Sd)===JSON.stringify(this.mediaAudioTrackList))return;ph(this,Sd,JSON.stringify(this.mediaAudioTrackList));const i=this.mediaAudioTrackList;this.defaultSlot.textContent="";for(const e of i){const t=this.formatMenuItemText(e.label,e),r=bn({type:"radio",text:t,value:`${e.id}`,checked:e.enabled});r.prepend(ls(this,"checked-indicator")),this.defaultSlot.append(r)}};Cl=new WeakSet;vh=function(){if(this.value==null)return;const i=new R.CustomEvent(j.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};R.customElements.get("media-audio-track-menu")||R.customElements.define("media-audio-track-menu",Uw);const $w=`<svg aria-hidden="true" viewBox="0 0 24 24">
1660
+ `;class $w extends xn{static get observedAttributes(){return[...super.observedAttributes,"target"]}constructor(){super({slotTemplate:Ky,tooltipContent:Fe.SETTINGS})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Rt.SETTINGS())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:$t(this).querySelector("media-settings-menu")}}R.customElements.get("media-settings-menu-button")||R.customElements.define("media-settings-menu-button",$w);var jf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Vy=(i,e,t)=>(jf(i,e,"read from private field"),t?t.call(i):e.get(i)),So=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},vh=(i,e,t,r)=>(jf(i,e,"write to private field"),e.set(i,t),t),xo=(i,e,t)=>(jf(i,e,"access private method"),t),ua,kd,Dl,Eh,Ml,yh;class Bw extends qi{constructor(){super(...arguments),So(this,Dl),So(this,Ml),So(this,ua,[]),So(this,kd,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_AUDIO_TRACK_ENABLED&&t!==r?this.value=r:e===T.MEDIA_AUDIO_TRACK_LIST&&t!==r&&(vh(this,ua,EL(r??"")),xo(this,Dl,Eh).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",xo(this,Ml,yh))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",xo(this,Ml,yh))}get anchorElement(){var e;return this.anchor!=="auto"?super.anchorElement:(e=$t(this))==null?void 0:e.querySelector("media-audio-track-menu-button")}get mediaAudioTrackList(){return Vy(this,ua)}set mediaAudioTrackList(e){vh(this,ua,e),xo(this,Dl,Eh).call(this)}get mediaAudioTrackEnabled(){var e;return(e=Qe(this,T.MEDIA_AUDIO_TRACK_ENABLED))!=null?e:""}set mediaAudioTrackEnabled(e){Ze(this,T.MEDIA_AUDIO_TRACK_ENABLED,e)}}ua=new WeakMap;kd=new WeakMap;Dl=new WeakSet;Eh=function(){if(Vy(this,kd)===JSON.stringify(this.mediaAudioTrackList))return;vh(this,kd,JSON.stringify(this.mediaAudioTrackList));const i=this.mediaAudioTrackList;this.defaultSlot.textContent="";for(const e of i){const t=this.formatMenuItemText(e.label,e),r=Tn({type:"radio",text:t,value:`${e.id}`,checked:e.enabled});r.prepend(ls(this,"checked-indicator")),this.defaultSlot.append(r)}};Ml=new WeakSet;yh=function(){if(this.value==null)return;const i=new R.CustomEvent(j.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};R.customElements.get("media-audio-track-menu")||R.customElements.define("media-audio-track-menu",Bw);const Gw=`<svg aria-hidden="true" viewBox="0 0 24 24">
1661
1661
  <path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/>
1662
1662
  <path d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0Z"/>
1663
- </svg>`,Ky=Z.createElement("template");Ky.innerHTML=`
1663
+ </svg>`,qy=Z.createElement("template");qy.innerHTML=`
1664
1664
  <style>
1665
1665
  :host([aria-expanded="true"]) slot[name=tooltip] {
1666
1666
  display: none;
1667
1667
  }
1668
1668
  </style>
1669
- <slot name="icon">${$w}</slot>
1670
- `;class Bw extends Sn{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:Ky,tooltipContent:Fe.AUDIO_TRACK_MENU})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Rt.AUDIO_TRACKS())}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r)}get invokeTargetElement(){var e;return this.invokeTarget!=null?super.invokeTargetElement:(e=$t(this))==null?void 0:e.querySelector("media-audio-track-menu")}get mediaAudioTrackEnabled(){var e;return(e=Qe(this,T.MEDIA_AUDIO_TRACK_ENABLED))!=null?e:""}set mediaAudioTrackEnabled(e){Ze(this,T.MEDIA_AUDIO_TRACK_ENABLED,e)}}R.customElements.get("media-audio-track-menu-button")||R.customElements.define("media-audio-track-menu-button",Bw);var Yf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Gw=(i,e,t)=>(Yf(i,e,"read from private field"),t?t.call(i):e.get(i)),Mu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Hw=(i,e,t,r)=>(Yf(i,e,"write to private field"),e.set(i,t),t),Pu=(i,e,t)=>(Yf(i,e,"access private method"),t),xd,Eh,Vy,Dl,yh;const Ww=`
1669
+ <slot name="icon">${Gw}</slot>
1670
+ `;class Hw extends xn{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:qy,tooltipContent:Fe.AUDIO_TRACK_MENU})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Rt.AUDIO_TRACKS())}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r)}get invokeTargetElement(){var e;return this.invokeTarget!=null?super.invokeTargetElement:(e=$t(this))==null?void 0:e.querySelector("media-audio-track-menu")}get mediaAudioTrackEnabled(){var e;return(e=Qe(this,T.MEDIA_AUDIO_TRACK_ENABLED))!=null?e:""}set mediaAudioTrackEnabled(e){Ze(this,T.MEDIA_AUDIO_TRACK_ENABLED,e)}}R.customElements.get("media-audio-track-menu-button")||R.customElements.define("media-audio-track-menu-button",Hw);var zf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ww=(i,e,t)=>(zf(i,e,"read from private field"),t?t.call(i):e.get(i)),Ou=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Kw=(i,e,t,r)=>(zf(i,e,"write to private field"),e.set(i,t),t),Nu=(i,e,t)=>(zf(i,e,"access private method"),t),Ld,bh,Yy,Pl,Th;const Vw=`
1671
1671
  <svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator">
1672
1672
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
1673
- </svg>`,qy=Z.createElement("template");qy.innerHTML=qi.template.innerHTML+`
1674
- <slot name="captions-indicator" hidden>${Ww}</slot>`;class Yy extends qi{constructor(){super(...arguments),Mu(this,Eh),Mu(this,Dl),Mu(this,xd,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_SUBTITLES_LIST&&t!==r?Pu(this,Eh,Vy).call(this):e===T.MEDIA_SUBTITLES_SHOWING&&t!==r&&(this.value=r)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Pu(this,Dl,yh))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Pu(this,Dl,yh))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:$t(this).querySelector("media-captions-menu-button")}get mediaSubtitlesList(){return p0(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){g0(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return p0(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){g0(this,T.MEDIA_SUBTITLES_SHOWING,e)}}xd=new WeakMap;Eh=new WeakSet;Vy=function(){var i;if(Gw(this,xd)===JSON.stringify(this.mediaSubtitlesList))return;Hw(this,xd,JSON.stringify(this.mediaSubtitlesList)),this.defaultSlot.textContent="";const e=!this.value,t=bn({type:"radio",text:this.formatMenuItemText("Off"),value:"off",checked:e});t.prepend(ls(this,"checked-indicator")),this.defaultSlot.append(t);const r=this.mediaSubtitlesList;for(const s of r){const n=bn({type:"radio",text:this.formatMenuItemText(s.label,s),value:pc(s),checked:this.value==pc(s)});n.prepend(ls(this,"checked-indicator")),((i=s.kind)!=null?i:"subs")==="captions"&&n.append(ls(this,"captions-indicator")),this.defaultSlot.append(n)}};Dl=new WeakSet;yh=function(){const i=this.mediaSubtitlesShowing,e=this.getAttribute(T.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new R.CustomEvent(j.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;const r=new R.CustomEvent(j.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};Yy.template=qy;const p0=(i,e)=>{const t=i.getAttribute(e);return t?Od(t):[]},g0=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}const r=Oa(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};R.customElements.get("media-captions-menu")||R.customElements.define("media-captions-menu",Yy);var Kw=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Vw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},qw=(i,e,t,r)=>(Kw(i,e,"write to private field"),e.set(i,t),t),bh;const Yw=`<svg aria-hidden="true" viewBox="0 0 26 24">
1673
+ </svg>`,jy=Z.createElement("template");jy.innerHTML=qi.template.innerHTML+`
1674
+ <slot name="captions-indicator" hidden>${Vw}</slot>`;class zy extends qi{constructor(){super(...arguments),Ou(this,bh),Ou(this,Pl),Ou(this,Ld,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_SUBTITLES_LIST&&t!==r?Nu(this,bh,Yy).call(this):e===T.MEDIA_SUBTITLES_SHOWING&&t!==r&&(this.value=r)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Nu(this,Pl,Th))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Nu(this,Pl,Th))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:$t(this).querySelector("media-captions-menu-button")}get mediaSubtitlesList(){return v0(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){E0(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return v0(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){E0(this,T.MEDIA_SUBTITLES_SHOWING,e)}}Ld=new WeakMap;bh=new WeakSet;Yy=function(){var i;if(Ww(this,Ld)===JSON.stringify(this.mediaSubtitlesList))return;Kw(this,Ld,JSON.stringify(this.mediaSubtitlesList)),this.defaultSlot.textContent="";const e=!this.value,t=Tn({type:"radio",text:this.formatMenuItemText("Off"),value:"off",checked:e});t.prepend(ls(this,"checked-indicator")),this.defaultSlot.append(t);const r=this.mediaSubtitlesList;for(const s of r){const n=Tn({type:"radio",text:this.formatMenuItemText(s.label,s),value:vc(s),checked:this.value==vc(s)});n.prepend(ls(this,"checked-indicator")),((i=s.kind)!=null?i:"subs")==="captions"&&n.append(ls(this,"captions-indicator")),this.defaultSlot.append(n)}};Pl=new WeakSet;Th=function(){const i=this.mediaSubtitlesShowing,e=this.getAttribute(T.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new R.CustomEvent(j.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;const r=new R.CustomEvent(j.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(r)};zy.template=jy;const v0=(i,e)=>{const t=i.getAttribute(e);return t?Fd(t):[]},E0=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}const r=Na(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};R.customElements.get("media-captions-menu")||R.customElements.define("media-captions-menu",zy);var qw=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Yw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},jw=(i,e,t,r)=>(qw(i,e,"write to private field"),e.set(i,t),t),_h;const zw=`<svg aria-hidden="true" viewBox="0 0 26 24">
1675
1675
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
1676
- </svg>`,jw=`<svg aria-hidden="true" viewBox="0 0 26 24">
1676
+ </svg>`,Xw=`<svg aria-hidden="true" viewBox="0 0 26 24">
1677
1677
  <path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/>
1678
- </svg>`,jy=Z.createElement("template");jy.innerHTML=`
1678
+ </svg>`,Xy=Z.createElement("template");Xy.innerHTML=`
1679
1679
  <style>
1680
1680
  :host([aria-checked="true"]) slot[name=off] {
1681
1681
  display: none !important;
@@ -1692,10 +1692,10 @@ svg, img, ::slotted(svg), ::slotted(img) {
1692
1692
  </style>
1693
1693
 
1694
1694
  <slot name="icon">
1695
- <slot name="on">${Yw}</slot>
1696
- <slot name="off">${jw}</slot>
1695
+ <slot name="on">${zw}</slot>
1696
+ <slot name="off">${Xw}</slot>
1697
1697
  </slot>
1698
- `;const v0=i=>{i.setAttribute("aria-checked",iE(i).toString())};class zw extends Sn{constructor(e={}){super({slotTemplate:jy,tooltipContent:Fe.CAPTIONS,...e}),Vw(this,bh,void 0),qw(this,bh,!1)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Rt.CLOSED_CAPTIONS()),v0(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_SUBTITLES_SHOWING&&v0(this)}get invokeTargetElement(){var e;return this.invokeTarget!=null?super.invokeTargetElement:(e=$t(this))==null?void 0:e.querySelector("media-captions-menu")}get mediaSubtitlesList(){return E0(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){y0(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return E0(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){y0(this,T.MEDIA_SUBTITLES_SHOWING,e)}}bh=new WeakMap;const E0=(i,e)=>{const t=i.getAttribute(e);return t?Od(t):[]},y0=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}const r=Oa(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};R.customElements.get("media-captions-menu-button")||R.customElements.define("media-captions-menu-button",zw);var zy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},So=(i,e,t)=>(zy(i,e,"read from private field"),t?t.call(i):e.get(i)),Ou=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Fn=(i,e,t)=>(zy(i,e,"access private method"),t),Vs,ua,Ml,Pl,Th;const Nu={RATES:"rates"};class Xw extends qi{constructor(){super(),Ou(this,ua),Ou(this,Pl),Ou(this,Vs,new Pd(this,Nu.RATES,{defaultValue:GE})),Fn(this,ua,Ml).call(this)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,Nu.RATES]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_PLAYBACK_RATE&&t!=r?this.value=r:e===Nu.RATES&&t!=r&&(So(this,Vs).value=r,Fn(this,ua,Ml).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Fn(this,Pl,Th))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Fn(this,Pl,Th))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:$t(this).querySelector("media-playback-rate-menu-button")}get rates(){return So(this,Vs)}set rates(e){e?Array.isArray(e)&&(So(this,Vs).value=e.join(" ")):So(this,Vs).value="",Fn(this,ua,Ml).call(this)}get mediaPlaybackRate(){return Ne(this,T.MEDIA_PLAYBACK_RATE,zn)}set mediaPlaybackRate(e){ze(this,T.MEDIA_PLAYBACK_RATE,e)}}Vs=new WeakMap;ua=new WeakSet;Ml=function(){this.defaultSlot.textContent="";for(const i of this.rates){const e=bn({type:"radio",text:this.formatMenuItemText(`${i}x`,i),value:i,checked:this.mediaPlaybackRate==i});e.prepend(ls(this,"checked-indicator")),this.defaultSlot.append(e)}};Pl=new WeakSet;Th=function(){if(!this.value)return;const i=new R.CustomEvent(j.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};R.customElements.get("media-playback-rate-menu")||R.customElements.define("media-playback-rate-menu",Xw);var Qw=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},xo=(i,e,t)=>(Qw(i,e,"read from private field"),t?t.call(i):e.get(i)),Zw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},qs;const Fu={RATES:"rates"},Jw=[1,1.2,1.5,1.7,2],Uu=1,Xy=Z.createElement("template");Xy.innerHTML=`
1698
+ `;const y0=i=>{i.setAttribute("aria-checked",sE(i).toString())};class Qw extends xn{constructor(e={}){super({slotTemplate:Xy,tooltipContent:Fe.CAPTIONS,...e}),Yw(this,_h,void 0),jw(this,_h,!1)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Rt.CLOSED_CAPTIONS()),y0(this)}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_SUBTITLES_SHOWING&&y0(this)}get invokeTargetElement(){var e;return this.invokeTarget!=null?super.invokeTargetElement:(e=$t(this))==null?void 0:e.querySelector("media-captions-menu")}get mediaSubtitlesList(){return b0(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){T0(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return b0(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){T0(this,T.MEDIA_SUBTITLES_SHOWING,e)}}_h=new WeakMap;const b0=(i,e)=>{const t=i.getAttribute(e);return t?Fd(t):[]},T0=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}const r=Na(t);i.getAttribute(e)!==r&&i.setAttribute(e,r)};R.customElements.get("media-captions-menu-button")||R.customElements.define("media-captions-menu-button",Qw);var Qy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ko=(i,e,t)=>(Qy(i,e,"read from private field"),t?t.call(i):e.get(i)),Fu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Un=(i,e,t)=>(Qy(i,e,"access private method"),t),qs,ca,Ol,Nl,Ah;const Uu={RATES:"rates"};class Zw extends qi{constructor(){super(),Fu(this,ca),Fu(this,Nl),Fu(this,qs,new Nd(this,Uu.RATES,{defaultValue:WE})),Un(this,ca,Ol).call(this)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,Uu.RATES]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_PLAYBACK_RATE&&t!=r?this.value=r:e===Uu.RATES&&t!=r&&(ko(this,qs).value=r,Un(this,ca,Ol).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Un(this,Nl,Ah))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Un(this,Nl,Ah))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:$t(this).querySelector("media-playback-rate-menu-button")}get rates(){return ko(this,qs)}set rates(e){e?Array.isArray(e)&&(ko(this,qs).value=e.join(" ")):ko(this,qs).value="",Un(this,ca,Ol).call(this)}get mediaPlaybackRate(){return Ne(this,T.MEDIA_PLAYBACK_RATE,Xn)}set mediaPlaybackRate(e){ze(this,T.MEDIA_PLAYBACK_RATE,e)}}qs=new WeakMap;ca=new WeakSet;Ol=function(){this.defaultSlot.textContent="";for(const i of this.rates){const e=Tn({type:"radio",text:this.formatMenuItemText(`${i}x`,i),value:i,checked:this.mediaPlaybackRate==i});e.prepend(ls(this,"checked-indicator")),this.defaultSlot.append(e)}};Nl=new WeakSet;Ah=function(){if(!this.value)return;const i=new R.CustomEvent(j.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};R.customElements.get("media-playback-rate-menu")||R.customElements.define("media-playback-rate-menu",Zw);var Jw=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Lo=(i,e,t)=>(Jw(i,e,"read from private field"),t?t.call(i):e.get(i)),eC=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ys;const $u={RATES:"rates"},tC=[1,1.2,1.5,1.7,2],Bu=1,Zy=Z.createElement("template");Zy.innerHTML=`
1699
1699
  <style>
1700
1700
  :host {
1701
1701
  min-width: 5ch;
@@ -1707,17 +1707,17 @@ svg, img, ::slotted(svg), ::slotted(img) {
1707
1707
  }
1708
1708
  </style>
1709
1709
  <slot name="icon"></slot>
1710
- `;class eC extends Sn{constructor(e={}){super({slotTemplate:Xy,tooltipContent:Fe.PLAYBACK_RATE,...e}),Zw(this,qs,new Pd(this,Fu.RATES,{defaultValue:Jw})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${Uu}x`}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,Fu.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===Fu.RATES&&(xo(this,qs).value=r),e===T.MEDIA_PLAYBACK_RATE){const s=r?+r:Number.NaN,n=Number.isNaN(s)?Uu:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Rt.PLAYBACK_RATE({playbackRate:n}))}}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:$t(this).querySelector("media-playback-rate-menu")}get rates(){return xo(this,qs)}set rates(e){e?Array.isArray(e)&&(xo(this,qs).value=e.join(" ")):xo(this,qs).value=""}get mediaPlaybackRate(){return Ne(this,T.MEDIA_PLAYBACK_RATE,Uu)}set mediaPlaybackRate(e){ze(this,T.MEDIA_PLAYBACK_RATE,e)}}qs=new WeakMap;R.customElements.get("media-playback-rate-menu-button")||R.customElements.define("media-playback-rate-menu-button",eC);var jf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ca=(i,e,t)=>(jf(i,e,"read from private field"),t?t.call(i):e.get(i)),ko=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},b0=(i,e,t,r)=>(jf(i,e,"write to private field"),e.set(i,t),t),Un=(i,e,t)=>(jf(i,e,"access private method"),t),ha,Js,fa,Ol,Nl,_h;class tC extends qi{constructor(){super(...arguments),ko(this,fa),ko(this,Nl),ko(this,ha,[]),ko(this,Js,{})}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_LIST,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE,T.MEDIA_HEIGHT]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_RENDITION_SELECTED&&t!==r?this.value=r??"auto":e===T.MEDIA_RENDITION_LIST&&t!==r?(b0(this,ha,hL(r)),Un(this,fa,Ol).call(this)):e===T.MEDIA_HEIGHT&&t!==r&&Un(this,fa,Ol).call(this)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Un(this,Nl,_h))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Un(this,Nl,_h))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:$t(this).querySelector("media-rendition-menu-button")}get mediaRenditionList(){return ca(this,ha)}set mediaRenditionList(e){b0(this,ha,e),Un(this,fa,Ol).call(this)}get mediaRenditionSelected(){return Qe(this,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){Ze(this,T.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return Ne(this,T.MEDIA_HEIGHT)}set mediaHeight(e){ze(this,T.MEDIA_HEIGHT,e)}}ha=new WeakMap;Js=new WeakMap;fa=new WeakSet;Ol=function(){if(ca(this,Js).mediaRenditionList===JSON.stringify(this.mediaRenditionList)&&ca(this,Js).mediaHeight===this.mediaHeight)return;ca(this,Js).mediaRenditionList=JSON.stringify(this.mediaRenditionList),ca(this,Js).mediaHeight=this.mediaHeight;const i=this.mediaRenditionList.sort((s,n)=>n.height-s.height);for(const s of i)s.selected=s.id===this.mediaRenditionSelected;this.defaultSlot.textContent="";const e=!this.mediaRenditionSelected;for(const s of i){const n=this.formatMenuItemText(`${Math.min(s.width,s.height)}p`,s),a=bn({type:"radio",text:n,value:`${s.id}`,checked:s.selected&&!e});a.prepend(ls(this,"checked-indicator")),this.defaultSlot.append(a)}const t=bn({type:"radio",text:this.formatMenuItemText("Auto"),value:"auto",checked:e}),r=this.mediaHeight>0?`Auto (${this.mediaHeight}p)`:"Auto";t.dataset.description=r,t.prepend(ls(this,"checked-indicator")),this.defaultSlot.append(t)};Nl=new WeakSet;_h=function(){if(this.value==null)return;const i=new R.CustomEvent(j.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};R.customElements.get("media-rendition-menu")||R.customElements.define("media-rendition-menu",tC);const iC=`<svg aria-hidden="true" viewBox="0 0 24 24">
1710
+ `;class iC extends xn{constructor(e={}){super({slotTemplate:Zy,tooltipContent:Fe.PLAYBACK_RATE,...e}),eC(this,Ys,new Nd(this,$u.RATES,{defaultValue:tC})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${Bu}x`}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,$u.RATES]}attributeChangedCallback(e,t,r){if(super.attributeChangedCallback(e,t,r),e===$u.RATES&&(Lo(this,Ys).value=r),e===T.MEDIA_PLAYBACK_RATE){const s=r?+r:Number.NaN,n=Number.isNaN(s)?Bu:s;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Rt.PLAYBACK_RATE({playbackRate:n}))}}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:$t(this).querySelector("media-playback-rate-menu")}get rates(){return Lo(this,Ys)}set rates(e){e?Array.isArray(e)&&(Lo(this,Ys).value=e.join(" ")):Lo(this,Ys).value=""}get mediaPlaybackRate(){return Ne(this,T.MEDIA_PLAYBACK_RATE,Bu)}set mediaPlaybackRate(e){ze(this,T.MEDIA_PLAYBACK_RATE,e)}}Ys=new WeakMap;R.customElements.get("media-playback-rate-menu-button")||R.customElements.define("media-playback-rate-menu-button",iC);var Xf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ha=(i,e,t)=>(Xf(i,e,"read from private field"),t?t.call(i):e.get(i)),Io=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},_0=(i,e,t,r)=>(Xf(i,e,"write to private field"),e.set(i,t),t),$n=(i,e,t)=>(Xf(i,e,"access private method"),t),fa,en,ma,Fl,Ul,Sh;class rC extends qi{constructor(){super(...arguments),Io(this,ma),Io(this,Ul),Io(this,fa,[]),Io(this,en,{})}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_LIST,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE,T.MEDIA_HEIGHT]}attributeChangedCallback(e,t,r){super.attributeChangedCallback(e,t,r),e===T.MEDIA_RENDITION_SELECTED&&t!==r?this.value=r??"auto":e===T.MEDIA_RENDITION_LIST&&t!==r?(_0(this,fa,mL(r)),$n(this,ma,Fl).call(this)):e===T.MEDIA_HEIGHT&&t!==r&&$n(this,ma,Fl).call(this)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",$n(this,Ul,Sh))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",$n(this,Ul,Sh))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:$t(this).querySelector("media-rendition-menu-button")}get mediaRenditionList(){return ha(this,fa)}set mediaRenditionList(e){_0(this,fa,e),$n(this,ma,Fl).call(this)}get mediaRenditionSelected(){return Qe(this,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){Ze(this,T.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return Ne(this,T.MEDIA_HEIGHT)}set mediaHeight(e){ze(this,T.MEDIA_HEIGHT,e)}}fa=new WeakMap;en=new WeakMap;ma=new WeakSet;Fl=function(){if(ha(this,en).mediaRenditionList===JSON.stringify(this.mediaRenditionList)&&ha(this,en).mediaHeight===this.mediaHeight)return;ha(this,en).mediaRenditionList=JSON.stringify(this.mediaRenditionList),ha(this,en).mediaHeight=this.mediaHeight;const i=this.mediaRenditionList.sort((s,n)=>n.height-s.height);for(const s of i)s.selected=s.id===this.mediaRenditionSelected;this.defaultSlot.textContent="";const e=!this.mediaRenditionSelected;for(const s of i){const n=this.formatMenuItemText(`${Math.min(s.width,s.height)}p`,s),a=Tn({type:"radio",text:n,value:`${s.id}`,checked:s.selected&&!e});a.prepend(ls(this,"checked-indicator")),this.defaultSlot.append(a)}const t=Tn({type:"radio",text:this.formatMenuItemText("Auto"),value:"auto",checked:e}),r=this.mediaHeight>0?`Auto (${this.mediaHeight}p)`:"Auto";t.dataset.description=r,t.prepend(ls(this,"checked-indicator")),this.defaultSlot.append(t)};Ul=new WeakSet;Sh=function(){if(this.value==null)return;const i=new R.CustomEvent(j.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};R.customElements.get("media-rendition-menu")||R.customElements.define("media-rendition-menu",rC);const sC=`<svg aria-hidden="true" viewBox="0 0 24 24">
1711
1711
  <path d="M13.5 2.5h2v6h-2v-2h-11v-2h11v-2Zm4 2h4v2h-4v-2Zm-12 4h2v6h-2v-2h-3v-2h3v-2Zm4 2h12v2h-12v-2Zm1 4h2v6h-2v-2h-8v-2h8v-2Zm4 2h7v2h-7v-2Z" />
1712
- </svg>`,Qy=Z.createElement("template");Qy.innerHTML=`
1712
+ </svg>`,Jy=Z.createElement("template");Jy.innerHTML=`
1713
1713
  <style>
1714
1714
  :host([aria-expanded="true"]) slot[name=tooltip] {
1715
1715
  display: none;
1716
1716
  }
1717
1717
  </style>
1718
- <slot name="icon">${iC}</slot>
1719
- `;class rC extends Sn{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE,T.MEDIA_HEIGHT]}constructor(){super({slotTemplate:Qy,tooltipContent:Fe.RENDITIONS})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Rt.QUALITY())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:$t(this).querySelector("media-rendition-menu")}get mediaRenditionSelected(){return Qe(this,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){Ze(this,T.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return Ne(this,T.MEDIA_HEIGHT)}set mediaHeight(e){ze(this,T.MEDIA_HEIGHT,e)}}R.customElements.get("media-rendition-menu-button")||R.customElements.define("media-rendition-menu-button",rC);var zf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ve=(i,e,t)=>(zf(i,e,"read from private field"),t?t.call(i):e.get(i)),st=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Hi=(i,e,t,r)=>(zf(i,e,"write to private field"),e.set(i,t),t),Ge=(i,e,t)=>(zf(i,e,"access private method"),t),Kd=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment>"u"){class i extends Kd{}globalThis.DocumentFragment=i}var Xf=class extends Kd{},sC=class extends Kd{},nC={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(Xf)}},Fl,aC=class{constructor(i,e={}){st(this,Fl,void 0),Hi(this,Fl,e==null?void 0:e.detail)}get detail(){return ve(this,Fl)}initCustomEvent(){}};Fl=new WeakMap;function oC(i,e){return new Xf}var Zy={document:{createElement:oC},DocumentFragment,customElements:nC,CustomEvent:aC,EventTarget:Kd,HTMLElement:Xf,HTMLVideoElement:sC},Jy=typeof window>"u"||typeof globalThis.customElements>"u",lt=Jy?Zy:globalThis,gr=Jy?Zy.document:globalThis.document,lC="en",Va={code:lC},eb="en";function ce(i,e=!0){var t,r;let s=e&&(r=(t=Va)==null?void 0:t[i])!=null?r:i,n=e?Va.code:eb;return new dC(s,n)}var dC=class{constructor(i,e=(t=>(t=Va.code)!=null?t:eb)()){this.message=i,this.locale=e}format(i){return this.message.replace(/\{(\w+)\}/g,(e,t)=>{var r;return(r=i[t])!=null?r:""})}toString(){return this.message}};function uC(i){let e="";return Object.entries(i).forEach(([t,r])=>{r!=null&&(e+=`${Ah(t)}: ${r}; `)}),e?e.trim():void 0}function Ah(i){return i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function tb(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function pi(i){if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}function ib(i){let e=cC(i).toString();return e?"?"+e:""}function cC(i){let e={};for(let t in i)i[t]!=null&&(e[t]=i[t]);return new URLSearchParams(e)}function un(i){let e=(i??"").split(".")[1];if(!e)return{};let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(atob(t).split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(r)}var rb=(i,e)=>!i||!e?!1:i.contains(e)?!0:rb(i,e.getRootNode().host),sb="mux.com",hC=()=>{try{return"3.0.0"}catch{}return"UNKNOWN"},fC=hC(),nb=()=>fC,mC=(i,{token:e,customDomain:t=sb,thumbnailTime:r,programTime:s}={})=>{let n=e==null?r:void 0,{aud:a}=un(e);if(!(e&&a!=="t"))return`https://image.${t}/${i}/thumbnail.webp${ib({token:e,time:n,program_time:s})}`},pC=(i,{token:e,customDomain:t=sb,programStartTime:r,programEndTime:s}={})=>{let{aud:n}=un(e);if(!(e&&n!=="s"))return`https://image.${t}/${i}/storyboard.vtt${ib({token:e,format:"webp",program_start_time:r,program_end_time:s})}`},Qf=i=>{if(i){if([be.LIVE,be.ON_DEMAND].includes(i))return i;if(i!=null&&i.includes("live"))return be.LIVE}},gC={crossorigin:"crossOrigin",playsinline:"playsInline"};function vC(i){var e;return(e=gC[i])!=null?e:tb(i)}var Ys,js,_t,EC=class{constructor(e,t){st(this,Ys,void 0),st(this,js,void 0),st(this,_t,[]),Hi(this,Ys,e),Hi(this,js,t)}[Symbol.iterator](){return ve(this,_t).values()}get length(){return ve(this,_t).length}get value(){var e;return(e=ve(this,_t).join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(Hi(this,_t,[]),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return ve(this,_t)[e]}values(){return ve(this,_t).values()}keys(){return ve(this,_t).keys()}forEach(e){ve(this,_t).forEach(e)}add(...e){var t,r;e.forEach(s=>{this.contains(s)||ve(this,_t).push(s)}),!(this.value===""&&!((t=ve(this,Ys))!=null&&t.hasAttribute(`${ve(this,js)}`)))&&((r=ve(this,Ys))==null||r.setAttribute(`${ve(this,js)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>{ve(this,_t).splice(ve(this,_t).indexOf(r),1)}),(t=ve(this,Ys))==null||t.setAttribute(`${ve(this,js)}`,`${this.value}`)}contains(e){return ve(this,_t).includes(e)}toggle(e,t){return typeof t<"u"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){this.remove(e),this.add(t)}};Ys=new WeakMap,js=new WeakMap,_t=new WeakMap;var ab=`[mux-player ${nb()}]`;function Bi(...i){console.warn(ab,...i)}function Ft(...i){console.error(ab,...i)}function ob(i){var e;let t=(e=i.message)!=null?e:"";i.context&&(t+=` ${i.context}`),i.file&&(t+=` ${ce("Read more: ")}
1720
- https://github.com/muxinc/elements/blob/main/errors/${i.file}`),Bi(t)}var gt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},Kr={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},T0=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),yC=Mf.filter(i=>i!=="error"),bC=Object.values(gt).filter(i=>![gt.PLAYSINLINE].includes(i)),TC=Object.values(Kr),ma,_C=class extends lt.HTMLElement{constructor(){super(),st(this,ma,new WeakMap);let i=e=>{for(let t of e)t.type==="childList"&&(t.removedNodes.forEach(r=>{var s;(s=ve(this,ma).get(r))==null||s.remove()}),t.addedNodes.forEach(r=>{var s;let n=r;n!=null&&n.slot||(s=this.media)==null||s.append(_0(ve(this,ma),r))}))};new MutationObserver(i).observe(this,{childList:!0,subtree:!0})}static get observedAttributes(){return[...bC,...TC]}init(){this.querySelectorAll(":scope > :not([slot])").forEach(i=>{var e;(e=this.media)==null||e.append(_0(ve(this,ma),i))}),yC.forEach(i=>{var e;(e=this.media)==null||e.addEventListener(i,t=>{this.dispatchEvent(new Event(t.type))})})}attributeChangedCallback(i,e,t){var r,s;switch(i){case Kr.MUTED:{this.media&&(this.media.muted=t!=null,this.media.defaultMuted=t!=null);return}case Kr.VOLUME:{let n=(r=pi(t))!=null?r:1;this.media&&(this.media.volume=n);return}case Kr.PLAYBACKRATE:{let n=(s=pi(t))!=null?s:1;this.media&&(this.media.playbackRate=n,this.media.defaultPlaybackRate=n);return}}}play(){var i,e;return(e=(i=this.media)==null?void 0:i.play())!=null?e:Promise.reject()}pause(){var i;(i=this.media)==null||i.pause()}load(){var i;(i=this.media)==null||i.load()}requestCast(i){var e;return(e=this.media)==null?void 0:e.requestCast(i)}get media(){var i;return(i=this.shadowRoot)==null?void 0:i.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var i,e;return(e=(i=this.media)==null?void 0:i.paused)!=null?e:!0}get duration(){var i,e;return(e=(i=this.media)==null?void 0:i.duration)!=null?e:NaN}get ended(){var i,e;return(e=(i=this.media)==null?void 0:i.ended)!=null?e:!1}get buffered(){var i,e;return(e=(i=this.media)==null?void 0:i.buffered)!=null?e:T0}get seekable(){var i,e;return(e=(i=this.media)==null?void 0:i.seekable)!=null?e:T0}get readyState(){var i,e;return(e=(i=this.media)==null?void 0:i.readyState)!=null?e:0}get videoWidth(){var i,e;return(e=(i=this.media)==null?void 0:i.videoWidth)!=null?e:0}get videoHeight(){var i,e;return(e=(i=this.media)==null?void 0:i.videoHeight)!=null?e:0}get currentSrc(){var i,e;return(e=(i=this.media)==null?void 0:i.currentSrc)!=null?e:""}get currentTime(){var i,e;return(e=(i=this.media)==null?void 0:i.currentTime)!=null?e:0}set currentTime(i){this.media&&(this.media.currentTime=Number(i))}get volume(){var i,e;return(e=(i=this.media)==null?void 0:i.volume)!=null?e:1}set volume(i){this.media&&(this.media.volume=Number(i))}get playbackRate(){var i,e;return(e=(i=this.media)==null?void 0:i.playbackRate)!=null?e:1}set playbackRate(i){this.media&&(this.media.playbackRate=Number(i))}get defaultPlaybackRate(){var i;return(i=pi(this.getAttribute(Kr.PLAYBACKRATE)))!=null?i:1}set defaultPlaybackRate(i){i!=null?this.setAttribute(Kr.PLAYBACKRATE,`${i}`):this.removeAttribute(Kr.PLAYBACKRATE)}get crossOrigin(){return $n(this,gt.CROSSORIGIN)}set crossOrigin(i){this.setAttribute(gt.CROSSORIGIN,`${i}`)}get autoplay(){return $n(this,gt.AUTOPLAY)!=null}set autoplay(i){i?this.setAttribute(gt.AUTOPLAY,typeof i=="string"?i:""):this.removeAttribute(gt.AUTOPLAY)}get loop(){return $n(this,gt.LOOP)!=null}set loop(i){i?this.setAttribute(gt.LOOP,""):this.removeAttribute(gt.LOOP)}get muted(){var i,e;return(e=(i=this.media)==null?void 0:i.muted)!=null?e:!1}set muted(i){this.media&&(this.media.muted=!!i)}get defaultMuted(){return $n(this,gt.MUTED)!=null}set defaultMuted(i){i?this.setAttribute(gt.MUTED,""):this.removeAttribute(gt.MUTED)}get playsInline(){return $n(this,gt.PLAYSINLINE)!=null}set playsInline(i){Ft("playsInline is set to true by default and is not currently supported as a setter.")}get preload(){return this.media?this.media.preload:this.getAttribute("preload")}set preload(i){["","none","metadata","auto"].includes(i)?this.setAttribute(gt.PRELOAD,i):this.removeAttribute(gt.PRELOAD)}};ma=new WeakMap;function $n(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}function _0(i,e){let t=i.get(e);return t||(t=e.cloneNode(),i.set(e,t)),t}var A0=_C,AC=`:host {
1718
+ <slot name="icon">${sC}</slot>
1719
+ `;class nC extends xn{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE,T.MEDIA_HEIGHT]}constructor(){super({slotTemplate:Jy,tooltipContent:Fe.RENDITIONS})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Rt.QUALITY())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:$t(this).querySelector("media-rendition-menu")}get mediaRenditionSelected(){return Qe(this,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){Ze(this,T.MEDIA_RENDITION_SELECTED,e)}get mediaHeight(){return Ne(this,T.MEDIA_HEIGHT)}set mediaHeight(e){ze(this,T.MEDIA_HEIGHT,e)}}R.customElements.get("media-rendition-menu-button")||R.customElements.define("media-rendition-menu-button",nC);var Qf=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ve=(i,e,t)=>(Qf(i,e,"read from private field"),t?t.call(i):e.get(i)),st=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Hi=(i,e,t,r)=>(Qf(i,e,"write to private field"),e.set(i,t),t),Ge=(i,e,t)=>(Qf(i,e,"access private method"),t),qd=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment>"u"){class i extends qd{}globalThis.DocumentFragment=i}var Zf=class extends qd{},aC=class extends qd{},oC={get(i){},define(i,e,t){},getName(i){return null},upgrade(i){},whenDefined(i){return Promise.resolve(Zf)}},$l,lC=class{constructor(i,e={}){st(this,$l,void 0),Hi(this,$l,e==null?void 0:e.detail)}get detail(){return ve(this,$l)}initCustomEvent(){}};$l=new WeakMap;function dC(i,e){return new Zf}var eb={document:{createElement:dC},DocumentFragment,customElements:oC,CustomEvent:lC,EventTarget:qd,HTMLElement:Zf,HTMLVideoElement:aC},tb=typeof window>"u"||typeof globalThis.customElements>"u",lt=tb?eb:globalThis,gr=tb?eb.document:globalThis.document,uC="en",qa={code:uC},ib="en";function ce(i,e=!0){var t,r;let s=e&&(r=(t=qa)==null?void 0:t[i])!=null?r:i,n=e?qa.code:ib;return new cC(s,n)}var cC=class{constructor(i,e=(t=>(t=qa.code)!=null?t:ib)()){this.message=i,this.locale=e}format(i){return this.message.replace(/\{(\w+)\}/g,(e,t)=>{var r;return(r=i[t])!=null?r:""})}toString(){return this.message}};function hC(i){let e="";return Object.entries(i).forEach(([t,r])=>{r!=null&&(e+=`${xh(t)}: ${r}; `)}),e?e.trim():void 0}function xh(i){return i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function rb(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function pi(i){if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}function sb(i){let e=fC(i).toString();return e?"?"+e:""}function fC(i){let e={};for(let t in i)i[t]!=null&&(e[t]=i[t]);return new URLSearchParams(e)}function cn(i){let e=(i??"").split(".")[1];if(!e)return{};let t=e.replace(/-/g,"+").replace(/_/g,"/"),r=decodeURIComponent(atob(t).split("").map(function(s){return"%"+("00"+s.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(r)}var nb=(i,e)=>!i||!e?!1:i.contains(e)?!0:nb(i,e.getRootNode().host),ab="mux.com",mC=()=>{try{return"3.0.0"}catch{}return"UNKNOWN"},pC=mC(),ob=()=>pC,gC=(i,{token:e,customDomain:t=ab,thumbnailTime:r,programTime:s}={})=>{let n=e==null?r:void 0,{aud:a}=cn(e);if(!(e&&a!=="t"))return`https://image.${t}/${i}/thumbnail.webp${sb({token:e,time:n,program_time:s})}`},vC=(i,{token:e,customDomain:t=ab,programStartTime:r,programEndTime:s}={})=>{let{aud:n}=cn(e);if(!(e&&n!=="s"))return`https://image.${t}/${i}/storyboard.vtt${sb({token:e,format:"webp",program_start_time:r,program_end_time:s})}`},Jf=i=>{if(i){if([be.LIVE,be.ON_DEMAND].includes(i))return i;if(i!=null&&i.includes("live"))return be.LIVE}},EC={crossorigin:"crossOrigin",playsinline:"playsInline"};function yC(i){var e;return(e=EC[i])!=null?e:rb(i)}var js,zs,_t,bC=class{constructor(e,t){st(this,js,void 0),st(this,zs,void 0),st(this,_t,[]),Hi(this,js,e),Hi(this,zs,t)}[Symbol.iterator](){return ve(this,_t).values()}get length(){return ve(this,_t).length}get value(){var e;return(e=ve(this,_t).join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(Hi(this,_t,[]),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return ve(this,_t)[e]}values(){return ve(this,_t).values()}keys(){return ve(this,_t).keys()}forEach(e){ve(this,_t).forEach(e)}add(...e){var t,r;e.forEach(s=>{this.contains(s)||ve(this,_t).push(s)}),!(this.value===""&&!((t=ve(this,js))!=null&&t.hasAttribute(`${ve(this,zs)}`)))&&((r=ve(this,js))==null||r.setAttribute(`${ve(this,zs)}`,`${this.value}`))}remove(...e){var t;e.forEach(r=>{ve(this,_t).splice(ve(this,_t).indexOf(r),1)}),(t=ve(this,js))==null||t.setAttribute(`${ve(this,zs)}`,`${this.value}`)}contains(e){return ve(this,_t).includes(e)}toggle(e,t){return typeof t<"u"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){this.remove(e),this.add(t)}};js=new WeakMap,zs=new WeakMap,_t=new WeakMap;var lb=`[mux-player ${ob()}]`;function Bi(...i){console.warn(lb,...i)}function Ft(...i){console.error(lb,...i)}function db(i){var e;let t=(e=i.message)!=null?e:"";i.context&&(t+=` ${i.context}`),i.file&&(t+=` ${ce("Read more: ")}
1720
+ https://github.com/muxinc/elements/blob/main/errors/${i.file}`),Bi(t)}var gt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},Kr={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},A0=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),TC=Of.filter(i=>i!=="error"),_C=Object.values(gt).filter(i=>![gt.PLAYSINLINE].includes(i)),AC=Object.values(Kr),pa,SC=class extends lt.HTMLElement{constructor(){super(),st(this,pa,new WeakMap);let i=e=>{for(let t of e)t.type==="childList"&&(t.removedNodes.forEach(r=>{var s;(s=ve(this,pa).get(r))==null||s.remove()}),t.addedNodes.forEach(r=>{var s;let n=r;n!=null&&n.slot||(s=this.media)==null||s.append(S0(ve(this,pa),r))}))};new MutationObserver(i).observe(this,{childList:!0,subtree:!0})}static get observedAttributes(){return[..._C,...AC]}init(){this.querySelectorAll(":scope > :not([slot])").forEach(i=>{var e;(e=this.media)==null||e.append(S0(ve(this,pa),i))}),TC.forEach(i=>{var e;(e=this.media)==null||e.addEventListener(i,t=>{this.dispatchEvent(new Event(t.type))})})}attributeChangedCallback(i,e,t){var r,s;switch(i){case Kr.MUTED:{this.media&&(this.media.muted=t!=null,this.media.defaultMuted=t!=null);return}case Kr.VOLUME:{let n=(r=pi(t))!=null?r:1;this.media&&(this.media.volume=n);return}case Kr.PLAYBACKRATE:{let n=(s=pi(t))!=null?s:1;this.media&&(this.media.playbackRate=n,this.media.defaultPlaybackRate=n);return}}}play(){var i,e;return(e=(i=this.media)==null?void 0:i.play())!=null?e:Promise.reject()}pause(){var i;(i=this.media)==null||i.pause()}load(){var i;(i=this.media)==null||i.load()}requestCast(i){var e;return(e=this.media)==null?void 0:e.requestCast(i)}get media(){var i;return(i=this.shadowRoot)==null?void 0:i.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var i,e;return(e=(i=this.media)==null?void 0:i.paused)!=null?e:!0}get duration(){var i,e;return(e=(i=this.media)==null?void 0:i.duration)!=null?e:NaN}get ended(){var i,e;return(e=(i=this.media)==null?void 0:i.ended)!=null?e:!1}get buffered(){var i,e;return(e=(i=this.media)==null?void 0:i.buffered)!=null?e:A0}get seekable(){var i,e;return(e=(i=this.media)==null?void 0:i.seekable)!=null?e:A0}get readyState(){var i,e;return(e=(i=this.media)==null?void 0:i.readyState)!=null?e:0}get videoWidth(){var i,e;return(e=(i=this.media)==null?void 0:i.videoWidth)!=null?e:0}get videoHeight(){var i,e;return(e=(i=this.media)==null?void 0:i.videoHeight)!=null?e:0}get currentSrc(){var i,e;return(e=(i=this.media)==null?void 0:i.currentSrc)!=null?e:""}get currentTime(){var i,e;return(e=(i=this.media)==null?void 0:i.currentTime)!=null?e:0}set currentTime(i){this.media&&(this.media.currentTime=Number(i))}get volume(){var i,e;return(e=(i=this.media)==null?void 0:i.volume)!=null?e:1}set volume(i){this.media&&(this.media.volume=Number(i))}get playbackRate(){var i,e;return(e=(i=this.media)==null?void 0:i.playbackRate)!=null?e:1}set playbackRate(i){this.media&&(this.media.playbackRate=Number(i))}get defaultPlaybackRate(){var i;return(i=pi(this.getAttribute(Kr.PLAYBACKRATE)))!=null?i:1}set defaultPlaybackRate(i){i!=null?this.setAttribute(Kr.PLAYBACKRATE,`${i}`):this.removeAttribute(Kr.PLAYBACKRATE)}get crossOrigin(){return Bn(this,gt.CROSSORIGIN)}set crossOrigin(i){this.setAttribute(gt.CROSSORIGIN,`${i}`)}get autoplay(){return Bn(this,gt.AUTOPLAY)!=null}set autoplay(i){i?this.setAttribute(gt.AUTOPLAY,typeof i=="string"?i:""):this.removeAttribute(gt.AUTOPLAY)}get loop(){return Bn(this,gt.LOOP)!=null}set loop(i){i?this.setAttribute(gt.LOOP,""):this.removeAttribute(gt.LOOP)}get muted(){var i,e;return(e=(i=this.media)==null?void 0:i.muted)!=null?e:!1}set muted(i){this.media&&(this.media.muted=!!i)}get defaultMuted(){return Bn(this,gt.MUTED)!=null}set defaultMuted(i){i?this.setAttribute(gt.MUTED,""):this.removeAttribute(gt.MUTED)}get playsInline(){return Bn(this,gt.PLAYSINLINE)!=null}set playsInline(i){Ft("playsInline is set to true by default and is not currently supported as a setter.")}get preload(){return this.media?this.media.preload:this.getAttribute("preload")}set preload(i){["","none","metadata","auto"].includes(i)?this.setAttribute(gt.PRELOAD,i):this.removeAttribute(gt.PRELOAD)}};pa=new WeakMap;function Bn(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}function S0(i,e){let t=i.get(e);return t||(t=e.cloneNode(),i.set(e,t)),t}var x0=SC,xC=`:host {
1721
1721
  --media-control-display: var(--controls);
1722
1722
  --media-loading-indicator-display: var(--loading-indicator);
1723
1723
  --media-dialog-display: var(--dialog);
@@ -1868,7 +1868,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1868
1868
  :host([no-tooltips]) {
1869
1869
  --media-tooltip-display: none;
1870
1870
  }
1871
- `,lb=`
1871
+ `,ub=`
1872
1872
  :host {
1873
1873
  z-index: 100;
1874
1874
  display: var(--media-dialog-display, flex);
@@ -1920,17 +1920,17 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1920
1920
  text-align: center;
1921
1921
  line-height: 1.4;
1922
1922
  }
1923
- `,db=gr.createElement("template");db.innerHTML=`
1923
+ `,cb=gr.createElement("template");cb.innerHTML=`
1924
1924
  <style>
1925
- ${lb}
1925
+ ${ub}
1926
1926
  </style>
1927
1927
 
1928
1928
  <div class="dialog">
1929
1929
  <slot></slot>
1930
1930
  </div>
1931
- `;var cn=class extends lt.HTMLElement{constructor(){var i;super(),this.attachShadow({mode:"open"}),(i=this.shadowRoot)==null||i.appendChild(this.constructor.template.content.cloneNode(!0))}show(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("open",{composed:!0,bubbles:!0})),S0(this)}close(){this.hasAttribute("open")&&(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),SC(this))}attributeChangedCallback(i,e,t){i==="open"&&e!==t&&(t!=null?this.show():this.close())}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("open")&&S0(this)}};cn.styles=lb,cn.template=db,cn.observedAttributes=["open"];function S0(i){let e=new CustomEvent("initfocus",{composed:!0,bubbles:!0,cancelable:!0});if(i.dispatchEvent(e),e.defaultPrevented)return;let t=i.querySelector("[autofocus]:not([disabled])");!t&&i.tabIndex>=0&&(t=i),t||(t=ub(i.shadowRoot)),i._previouslyFocusedElement=gr.activeElement,gr.activeElement instanceof HTMLElement&&gr.activeElement.blur(),i.addEventListener("transitionend",()=>{t instanceof HTMLElement&&t.focus({preventScroll:!0})},{once:!0})}function ub(i){let e=["button","input","keygen","select","textarea"].map(function(r){return r+":not([disabled])"});e.push('[tabindex]:not([disabled]):not([tabindex=""])');let t=i==null?void 0:i.querySelector(e.join(", "));if(!t&&"attachShadow"in Element.prototype){let r=(i==null?void 0:i.querySelectorAll("*"))||[];for(let s=0;s<r.length&&!(r[s].tagName&&r[s].shadowRoot&&(t=ub(r[s].shadowRoot),t));s++);}return t}function SC(i){i._previouslyFocusedElement instanceof HTMLElement&&i._previouslyFocusedElement.focus()}lt.customElements.get("media-dialog")||(lt.customElements.define("media-dialog",cn),lt.MediaDialog=cn);var cb=cn,hb=gr.createElement("template");hb.innerHTML=`
1931
+ `;var hn=class extends lt.HTMLElement{constructor(){var i;super(),this.attachShadow({mode:"open"}),(i=this.shadowRoot)==null||i.appendChild(this.constructor.template.content.cloneNode(!0))}show(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("open",{composed:!0,bubbles:!0})),k0(this)}close(){this.hasAttribute("open")&&(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),kC(this))}attributeChangedCallback(i,e,t){i==="open"&&e!==t&&(t!=null?this.show():this.close())}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("open")&&k0(this)}};hn.styles=ub,hn.template=cb,hn.observedAttributes=["open"];function k0(i){let e=new CustomEvent("initfocus",{composed:!0,bubbles:!0,cancelable:!0});if(i.dispatchEvent(e),e.defaultPrevented)return;let t=i.querySelector("[autofocus]:not([disabled])");!t&&i.tabIndex>=0&&(t=i),t||(t=hb(i.shadowRoot)),i._previouslyFocusedElement=gr.activeElement,gr.activeElement instanceof HTMLElement&&gr.activeElement.blur(),i.addEventListener("transitionend",()=>{t instanceof HTMLElement&&t.focus({preventScroll:!0})},{once:!0})}function hb(i){let e=["button","input","keygen","select","textarea"].map(function(r){return r+":not([disabled])"});e.push('[tabindex]:not([disabled]):not([tabindex=""])');let t=i==null?void 0:i.querySelector(e.join(", "));if(!t&&"attachShadow"in Element.prototype){let r=(i==null?void 0:i.querySelectorAll("*"))||[];for(let s=0;s<r.length&&!(r[s].tagName&&r[s].shadowRoot&&(t=hb(r[s].shadowRoot),t));s++);}return t}function kC(i){i._previouslyFocusedElement instanceof HTMLElement&&i._previouslyFocusedElement.focus()}lt.customElements.get("media-dialog")||(lt.customElements.define("media-dialog",hn),lt.MediaDialog=hn);var fb=hn,mb=gr.createElement("template");mb.innerHTML=`
1932
1932
  <style>
1933
- ${cb.styles}
1933
+ ${fb.styles}
1934
1934
 
1935
1935
  .close {
1936
1936
  background: none;
@@ -1959,23 +1959,23 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1959
1959
  </svg>
1960
1960
  </button>
1961
1961
  </slot>
1962
- `;var Sh=class extends cb{constructor(){var i,e;super(),(e=(i=this.shadowRoot)==null?void 0:i.querySelector(".close"))==null||e.addEventListener("click",()=>{this.close()})}};Sh.template=hb;lt.customElements.get("mxp-dialog")||(lt.customElements.define("mxp-dialog",Sh),lt.MxpDialog=Sh);var Bn=new WeakMap,xC=class fb{constructor(e,t){this.element=e,this.type=t,this.element.addEventListener(this.type,this);let r=Bn.get(this.element);r&&r.set(this.type,this)}set(e){if(typeof e=="function")this.handleEvent=e.bind(this.element);else if(typeof e=="object"&&typeof e.handleEvent=="function")this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let t=Bn.get(this.element);t&&t.delete(this.type)}}static for(e){Bn.has(e.element)||Bn.set(e.element,new Map);let t=e.attributeName.slice(2),r=Bn.get(e.element);return r&&r.has(t)?r.get(t):new fb(e.element,t)}};function kC(i,e){return i instanceof Xt&&i.attributeName.startsWith("on")?(xC.for(i).set(e),i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),!0):!1}function LC(i,e){return e instanceof mb&&i instanceof An?(e.renderInto(i),!0):!1}function IC(i,e){return e instanceof DocumentFragment&&i instanceof An?(e.childNodes.length&&i.replace(...e.childNodes),!0):!1}function RC(i,e){if(i instanceof Xt){let t=i.attributeNamespace,r=i.element.getAttributeNS(t,i.attributeName);return String(e)!==r&&(i.value=String(e)),!0}return i.value=String(e),!0}function wC(i,e){if(i instanceof Xt&&e instanceof Element){let t=i.element;return t[i.attributeName]!==e&&(i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),t[i.attributeName]=e),!0}return!1}function CC(i,e){if(typeof e=="boolean"&&i instanceof Xt){let t=i.attributeNamespace,r=i.element.hasAttributeNS(t,i.attributeName);return e!==r&&(i.booleanValue=e),!0}return!1}function DC(i,e){return e===!1&&i instanceof An?(i.replace(""),!0):!1}function MC(i,e){wC(i,e)||CC(i,e)||kC(i,e)||DC(i,e)||LC(i,e)||IC(i,e)||RC(i,e)}var $u=new Map,x0=new WeakMap,k0=new WeakMap,mb=class{constructor(i,e,t){this.strings=i,this.values=e,this.processor=t,this.stringsKey=this.strings.join("")}get template(){if($u.has(this.stringsKey))return $u.get(this.stringsKey);{let i=gr.createElement("template"),e=this.strings.length-1;return i.innerHTML=this.strings.reduce((t,r,s)=>t+r+(s<e?`{{ ${s} }}`:""),""),$u.set(this.stringsKey,i),i}}renderInto(i){var e;let t=this.template;if(x0.get(i)!==t){x0.set(i,t);let s=new Gd(t,this.values,this.processor);k0.set(i,s),i instanceof An?i.replace(...s.children):i.appendChild(s);return}let r=k0.get(i);(e=r==null?void 0:r.update)==null||e.call(r,this.values)}},PC={processCallback(i,e,t){var r;if(t){for(let[s,n]of e)if(s in t){let a=(r=t[s])!=null?r:"";MC(n,a)}}}};function rr(i,...e){return new mb(i,e,PC)}function OC(i,e){i.renderInto(e)}var NC=i=>{let{tokens:e}=i;return e.drm?":host { --_cast-button-drm-display: none; }":""},FC=i=>rr`
1962
+ `;var kh=class extends fb{constructor(){var i,e;super(),(e=(i=this.shadowRoot)==null?void 0:i.querySelector(".close"))==null||e.addEventListener("click",()=>{this.close()})}};kh.template=mb;lt.customElements.get("mxp-dialog")||(lt.customElements.define("mxp-dialog",kh),lt.MxpDialog=kh);var Gn=new WeakMap,LC=class pb{constructor(e,t){this.element=e,this.type=t,this.element.addEventListener(this.type,this);let r=Gn.get(this.element);r&&r.set(this.type,this)}set(e){if(typeof e=="function")this.handleEvent=e.bind(this.element);else if(typeof e=="object"&&typeof e.handleEvent=="function")this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let t=Gn.get(this.element);t&&t.delete(this.type)}}static for(e){Gn.has(e.element)||Gn.set(e.element,new Map);let t=e.attributeName.slice(2),r=Gn.get(e.element);return r&&r.has(t)?r.get(t):new pb(e.element,t)}};function IC(i,e){return i instanceof Xt&&i.attributeName.startsWith("on")?(LC.for(i).set(e),i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),!0):!1}function RC(i,e){return e instanceof gb&&i instanceof Sn?(e.renderInto(i),!0):!1}function wC(i,e){return e instanceof DocumentFragment&&i instanceof Sn?(e.childNodes.length&&i.replace(...e.childNodes),!0):!1}function CC(i,e){if(i instanceof Xt){let t=i.attributeNamespace,r=i.element.getAttributeNS(t,i.attributeName);return String(e)!==r&&(i.value=String(e)),!0}return i.value=String(e),!0}function DC(i,e){if(i instanceof Xt&&e instanceof Element){let t=i.element;return t[i.attributeName]!==e&&(i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),t[i.attributeName]=e),!0}return!1}function MC(i,e){if(typeof e=="boolean"&&i instanceof Xt){let t=i.attributeNamespace,r=i.element.hasAttributeNS(t,i.attributeName);return e!==r&&(i.booleanValue=e),!0}return!1}function PC(i,e){return e===!1&&i instanceof Sn?(i.replace(""),!0):!1}function OC(i,e){DC(i,e)||MC(i,e)||IC(i,e)||PC(i,e)||RC(i,e)||wC(i,e)||CC(i,e)}var Gu=new Map,L0=new WeakMap,I0=new WeakMap,gb=class{constructor(i,e,t){this.strings=i,this.values=e,this.processor=t,this.stringsKey=this.strings.join("")}get template(){if(Gu.has(this.stringsKey))return Gu.get(this.stringsKey);{let i=gr.createElement("template"),e=this.strings.length-1;return i.innerHTML=this.strings.reduce((t,r,s)=>t+r+(s<e?`{{ ${s} }}`:""),""),Gu.set(this.stringsKey,i),i}}renderInto(i){var e;let t=this.template;if(L0.get(i)!==t){L0.set(i,t);let s=new Wd(t,this.values,this.processor);I0.set(i,s),i instanceof Sn?i.replace(...s.children):i.appendChild(s);return}let r=I0.get(i);(e=r==null?void 0:r.update)==null||e.call(r,this.values)}},NC={processCallback(i,e,t){var r;if(t){for(let[s,n]of e)if(s in t){let a=(r=t[s])!=null?r:"";OC(n,a)}}}};function rr(i,...e){return new gb(i,e,NC)}function FC(i,e){i.renderInto(e)}var UC=i=>{let{tokens:e}=i;return e.drm?":host { --_cast-button-drm-display: none; }":""},$C=i=>rr`
1963
1963
  <style>
1964
- ${NC(i)}
1965
- ${AC}
1964
+ ${UC(i)}
1965
+ ${xC}
1966
1966
  </style>
1967
- ${GC(i)}
1968
- `,UC=i=>{let e=i.hotKeys?`${i.hotKeys}`:"";return Qf(i.streamType)==="live"&&(e+=" noarrowleft noarrowright"),e},$C={TOP:"top",CENTER:"center",BOTTOM:"bottom",LAYER:"layer",MEDIA_LAYER:"media-layer",POSTER_LAYER:"poster-layer",VERTICAL_LAYER:"vertical-layer",CENTERED_LAYER:"centered-layer",GESTURE_LAYER:"gesture-layer",CONTROLLER_LAYER:"controller",BUTTON:"button",RANGE:"range",DISPLAY:"display",CONTROL_BAR:"control-bar",SELECTMENU:"selectmenu",LISTBOX:"listbox",OPTION:"option",POSTER:"poster",LIVE:"live",PLAY:"play",PRE_PLAY:"pre-play",SEEK_BACKWARD:"seek-backward",SEEK_FORWARD:"seek-forward",MUTE:"mute",CAPTIONS:"captions",AIRPLAY:"airplay",PIP:"pip",FULLSCREEN:"fullscreen",CAST:"cast",PLAYBACK_RATE:"playback-rate",VOLUME:"volume",TIME:"time",TITLE:"title",AUDIO_TRACK:"audio-track",RENDITION:"rendition"},BC=Object.values($C).join(", "),GC=i=>{var e,t,r,s,n,a,o,l,d,u,c,h,f,m,p,g,E,y,b,S,_,x,A,C,O,L,M,K,U,z,V,q,ae,ne,G,$,te,re;return rr`
1967
+ ${WC(i)}
1968
+ `,BC=i=>{let e=i.hotKeys?`${i.hotKeys}`:"";return Jf(i.streamType)==="live"&&(e+=" noarrowleft noarrowright"),e},GC={TOP:"top",CENTER:"center",BOTTOM:"bottom",LAYER:"layer",MEDIA_LAYER:"media-layer",POSTER_LAYER:"poster-layer",VERTICAL_LAYER:"vertical-layer",CENTERED_LAYER:"centered-layer",GESTURE_LAYER:"gesture-layer",CONTROLLER_LAYER:"controller",BUTTON:"button",RANGE:"range",DISPLAY:"display",CONTROL_BAR:"control-bar",SELECTMENU:"selectmenu",LISTBOX:"listbox",OPTION:"option",POSTER:"poster",LIVE:"live",PLAY:"play",PRE_PLAY:"pre-play",SEEK_BACKWARD:"seek-backward",SEEK_FORWARD:"seek-forward",MUTE:"mute",CAPTIONS:"captions",AIRPLAY:"airplay",PIP:"pip",FULLSCREEN:"fullscreen",CAST:"cast",PLAYBACK_RATE:"playback-rate",VOLUME:"volume",TIME:"time",TITLE:"title",AUDIO_TRACK:"audio-track",RENDITION:"rendition"},HC=Object.values(GC).join(", "),WC=i=>{var e,t,r,s,n,a,o,l,d,u,c,h,f,m,p,g,E,y,b,S,_,x,A,C,O,L,M,K,U,z,V,q,ae,ne,G,$,te,re;return rr`
1969
1969
  <media-theme
1970
1970
  template="${i.themeTemplate||!1}"
1971
1971
  defaultstreamtype="${(e=i.defaultStreamType)!=null?e:!1}"
1972
- hotkeys="${UC(i)||!1}"
1972
+ hotkeys="${BC(i)||!1}"
1973
1973
  nohotkeys="${i.noHotKeys||!i.hasSrc||i.isDialogOpen||!1}"
1974
1974
  noautoseektolive="${!!((t=i.streamType)!=null&&t.includes(be.LIVE))&&i.targetLiveWindow!==0}"
1975
1975
  novolumepref="${i.novolumepref||!1}"
1976
1976
  disabled="${!i.hasSrc||i.isDialogOpen}"
1977
1977
  audio="${(r=i.audio)!=null?r:!1}"
1978
- style="${(s=uC({"--media-primary-color":i.primaryColor,"--media-secondary-color":i.secondaryColor,"--media-accent-color":i.accentColor}))!=null?s:!1}"
1978
+ style="${(s=hC({"--media-primary-color":i.primaryColor,"--media-secondary-color":i.secondaryColor,"--media-accent-color":i.accentColor}))!=null?s:!1}"
1979
1979
  defaultsubtitles="${!i.defaultHiddenCaptions}"
1980
1980
  forwardseekoffset="${(n=i.forwardSeekOffset)!=null?n:!1}"
1981
1981
  backwardseekoffset="${(a=i.backwardSeekOffset)!=null?a:!1}"
@@ -1984,12 +1984,12 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1984
1984
  defaultduration="${(d=i.defaultDuration)!=null?d:!1}"
1985
1985
  hideduration="${(u=i.hideDuration)!=null?u:!1}"
1986
1986
  title="${(c=i.title)!=null?c:!1}"
1987
- exportparts="${BC}"
1987
+ exportparts="${HC}"
1988
1988
  >
1989
1989
  <mux-video
1990
1990
  slot="media"
1991
1991
  target-live-window="${(h=i.targetLiveWindow)!=null?h:!1}"
1992
- stream-type="${(f=Qf(i.streamType))!=null?f:!1}"
1992
+ stream-type="${(f=Jf(i.streamType))!=null?f:!1}"
1993
1993
  crossorigin="${(m=i.crossOrigin)!=null?m:""}"
1994
1994
  playsinline
1995
1995
  autoplay="${(p=i.autoplay)!=null?p:!1}"
@@ -2007,8 +2007,8 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2007
2007
  player-software-version="${(L=i.playerSoftwareVersion)!=null?L:!1}"
2008
2008
  env-key="${(M=i.envKey)!=null?M:!1}"
2009
2009
  custom-domain="${(K=i.customDomain)!=null?K:!1}"
2010
- src="${i.src?i.src:i.playbackId?dc(i):!1}"
2011
- cast-src="${i.src?i.src:i.playbackId?dc(i):!1}"
2010
+ src="${i.src?i.src:i.playbackId?cc(i):!1}"
2011
+ cast-src="${i.src?i.src:i.playbackId?cc(i):!1}"
2012
2012
  cast-receiver="${(U=i.castReceiver)!=null?U:!1}"
2013
2013
  drm-token="${(V=(z=i.tokens)==null?void 0:z.drm)!=null?V:!1}"
2014
2014
  exportparts="video"
@@ -2042,7 +2042,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2042
2042
  </p>
2043
2043
  </mxp-dialog>
2044
2044
  </media-theme>
2045
- `};function xh(i,e,t,r,s){var n,a,o;let l={},d={};switch(i.code){case St.MEDIA_ERR_NETWORK:{switch(l.title=ce("Network Error",s),l.message=i.message,(n=i.data)==null?void 0:n.response.code){case 412:{l.title=ce("Video is not currently available",s),l.message=ce("The live stream or video file are not yet ready.",s),d.message=ce("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",s),d.file="412-not-playable.md";break}case 404:{l.title=ce("Video does not exist",s),l.message="",d.message=ce("This playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",s),d.file="404-not-found.md";break}case 403:{if(l.title=ce("Invalid playback URL",s),l.message=ce("The video URL or playback-token are formatted with incorrect or incomplete information.",s),d.message=ce("403 error trying to access this playback URL. If this is a signed URL, you might need to provide a playback-token.",s),d.file="missing-signed-tokens.md",!r)break;let{exp:u,aud:c,sub:h}=un(r),f=Date.now()>u*1e3,m=h!==t,p=c!=="v",g={timeStyle:"medium",dateStyle:"medium"};if(f){l.title=ce("Video URL has expired",s),l.message=ce("The video’s secured playback-token has expired.",s),d.message=ce("The video’s secured playback-token has expired.",s),d.context=ce("Expired at: {expiredDate}. Current time: {currentDate}.",s).format({expiredDate:new Intl.DateTimeFormat(Va.code,g).format(u*1e3),currentDate:new Intl.DateTimeFormat(Va.code,g).format(Date.now())}),d.file="403-expired-token.md";break}if(m){l.title=ce("Video URL is formatted incorrectly",s),l.message=ce("The video’s playback ID does not match the one encoded in the playback-token.",s),d.message=ce("The video’s playback ID does not match the one encoded in the playback-token.",s),d.context=ce("Specified playback ID: {playbackId} and the playback ID encoded in the playback-token: {tokenPlaybackId}",s).format({playbackId:t,tokenPlaybackId:h}),d.file="403-playback-id-mismatch.md";break}if(p){l.title=ce("Video URL is formatted incorrectly",s),l.message=ce("The playback-token is formatted with incorrect information.",s),d.message=ce("The playback-token is formatted with incorrect information.",s),d.context=ce("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",s).format({tokenType:c}),d.file="403-incorrect-aud-value.md";break}d.message=ce("403 error trying to access this playback URL. If this is a signed playback ID, the token might not have been generated correctly.",s),d.file="403-malformatted-token.md";break}}break}case St.MEDIA_ERR_DECODE:{let{message:u}=i;l={title:ce("Media Error",s),message:u},d.file="media-decode-error.md";break}case St.MEDIA_ERR_SRC_NOT_SUPPORTED:{let u=(o=(a=i.data)==null?void 0:a.response)==null?void 0:o.code;if(u>=400&&u<500){i.code=St.MEDIA_ERR_NETWORK,i.data={response:{code:u}},{dialog:l,devlog:d}=xh(i,e,t,r);break}l={title:ce("Source Not Supported",s),message:i.message},d.file="media-src-not-supported.md";break}default:l={title:ce("Error",s),message:i.message};break}return e&&(l={title:ce("Your device appears to be offline",s),message:ce("Check your internet connection and try reloading this video.",s)}),{dialog:l,devlog:d}}var HC=`<template id="media-theme-gerwig">
2045
+ `};function Lh(i,e,t,r,s){var n,a,o;let l={},d={};switch(i.code){case St.MEDIA_ERR_NETWORK:{switch(l.title=ce("Network Error",s),l.message=i.message,(n=i.data)==null?void 0:n.response.code){case 412:{l.title=ce("Video is not currently available",s),l.message=ce("The live stream or video file are not yet ready.",s),d.message=ce("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",s),d.file="412-not-playable.md";break}case 404:{l.title=ce("Video does not exist",s),l.message="",d.message=ce("This playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",s),d.file="404-not-found.md";break}case 403:{if(l.title=ce("Invalid playback URL",s),l.message=ce("The video URL or playback-token are formatted with incorrect or incomplete information.",s),d.message=ce("403 error trying to access this playback URL. If this is a signed URL, you might need to provide a playback-token.",s),d.file="missing-signed-tokens.md",!r)break;let{exp:u,aud:c,sub:h}=cn(r),f=Date.now()>u*1e3,m=h!==t,p=c!=="v",g={timeStyle:"medium",dateStyle:"medium"};if(f){l.title=ce("Video URL has expired",s),l.message=ce("The video’s secured playback-token has expired.",s),d.message=ce("The video’s secured playback-token has expired.",s),d.context=ce("Expired at: {expiredDate}. Current time: {currentDate}.",s).format({expiredDate:new Intl.DateTimeFormat(qa.code,g).format(u*1e3),currentDate:new Intl.DateTimeFormat(qa.code,g).format(Date.now())}),d.file="403-expired-token.md";break}if(m){l.title=ce("Video URL is formatted incorrectly",s),l.message=ce("The video’s playback ID does not match the one encoded in the playback-token.",s),d.message=ce("The video’s playback ID does not match the one encoded in the playback-token.",s),d.context=ce("Specified playback ID: {playbackId} and the playback ID encoded in the playback-token: {tokenPlaybackId}",s).format({playbackId:t,tokenPlaybackId:h}),d.file="403-playback-id-mismatch.md";break}if(p){l.title=ce("Video URL is formatted incorrectly",s),l.message=ce("The playback-token is formatted with incorrect information.",s),d.message=ce("The playback-token is formatted with incorrect information.",s),d.context=ce("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",s).format({tokenType:c}),d.file="403-incorrect-aud-value.md";break}d.message=ce("403 error trying to access this playback URL. If this is a signed playback ID, the token might not have been generated correctly.",s),d.file="403-malformatted-token.md";break}}break}case St.MEDIA_ERR_DECODE:{let{message:u}=i;l={title:ce("Media Error",s),message:u},d.file="media-decode-error.md";break}case St.MEDIA_ERR_SRC_NOT_SUPPORTED:{let u=(o=(a=i.data)==null?void 0:a.response)==null?void 0:o.code;if(u>=400&&u<500){i.code=St.MEDIA_ERR_NETWORK,i.data={response:{code:u}},{dialog:l,devlog:d}=Lh(i,e,t,r);break}l={title:ce("Source Not Supported",s),message:i.message},d.file="media-src-not-supported.md";break}default:l={title:ce("Error",s),message:i.message};break}return e&&(l={title:ce("Your device appears to be offline",s),message:ce("Check your internet connection and try reloading this video.",s)}),{dialog:l,devlog:d}}var KC=`<template id="media-theme-gerwig">
2046
2046
  <style>
2047
2047
  @keyframes pre-play-hide {
2048
2048
  0% {
@@ -3048,6 +3048,6 @@ media-poster-image:not([src]):not([placeholdersrc]) {
3048
3048
  <slot></slot>
3049
3049
  </media-controller>
3050
3050
  </template>
3051
- `,kh=gr.createElement("template");"innerHTML"in kh&&(kh.innerHTML=HC);var L0,I0,pb=class extends Hd{};pb.template=(I0=(L0=kh.content)==null?void 0:L0.children)==null?void 0:I0[0];lt.customElements.get("media-theme-gerwig")||lt.customElements.define("media-theme-gerwig",pb);var WC="gerwig",Oi={SRC:"src",POSTER:"poster"},F={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",ACCENT_COLOR:"accent-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",DRM_TOKEN:"drm-token",STORYBOARD_SRC:"storyboard-src",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys",HOTKEYS:"hotkeys",PLAYBACK_RATES:"playbackrates",DEFAULT_SHOW_REMAINING_TIME:"default-show-remaining-time",DEFAULT_DURATION:"default-duration",TITLE:"title",PLACEHOLDER:"placeholder",THEME:"theme",DEFAULT_STREAM_TYPE:"default-stream-type",TARGET_LIVE_WINDOW:"target-live-window",EXTRA_SOURCE_PARAMS:"extra-source-params",NO_VOLUME_PREF:"no-volume-pref",CAST_RECEIVER:"cast-receiver",NO_TOOLTIPS:"no-tooltips"},Lh=["audio","backwardseekoffset","defaultduration","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function KC(i,e){var t;return{src:!i.playbackId&&i.src,playbackId:i.playbackId,hasSrc:!!i.playbackId||!!i.src||!!i.currentSrc,poster:i.poster,storyboard:i.storyboard,storyboardSrc:i.getAttribute(F.STORYBOARD_SRC),placeholder:i.getAttribute("placeholder"),themeTemplate:VC(i),thumbnailTime:!i.tokens.thumbnail&&i.thumbnailTime,autoplay:i.autoplay,crossOrigin:i.crossOrigin,loop:i.loop,noHotKeys:i.hasAttribute(F.NOHOTKEYS),hotKeys:i.getAttribute(F.HOTKEYS),muted:i.muted,paused:i.paused,preload:i.preload,envKey:i.envKey,preferCmcd:i.preferCmcd,debug:i.debug,disableTracking:i.disableTracking,disableCookies:i.disableCookies,tokens:i.tokens,beaconCollectionDomain:i.beaconCollectionDomain,maxResolution:i.maxResolution,minResolution:i.minResolution,programStartTime:i.programStartTime,programEndTime:i.programEndTime,renditionOrder:i.renditionOrder,metadata:i.metadata,playerSoftwareName:i.playerSoftwareName,playerSoftwareVersion:i.playerSoftwareVersion,startTime:i.startTime,preferPlayback:i.preferPlayback,audio:i.audio,defaultStreamType:i.defaultStreamType,targetLiveWindow:i.getAttribute(P.TARGET_LIVE_WINDOW),streamType:Qf(i.getAttribute(P.STREAM_TYPE)),primaryColor:i.getAttribute(F.PRIMARY_COLOR),secondaryColor:i.getAttribute(F.SECONDARY_COLOR),accentColor:i.getAttribute(F.ACCENT_COLOR),forwardSeekOffset:i.forwardSeekOffset,backwardSeekOffset:i.backwardSeekOffset,defaultHiddenCaptions:i.defaultHiddenCaptions,defaultDuration:i.defaultDuration,defaultShowRemainingTime:i.defaultShowRemainingTime,hideDuration:qC(i),playbackRates:i.getAttribute(F.PLAYBACK_RATES),customDomain:(t=i.getAttribute(P.CUSTOM_DOMAIN))!=null?t:void 0,title:i.getAttribute(F.TITLE),novolumepref:i.hasAttribute(F.NO_VOLUME_PREF),castReceiver:i.castReceiver,...e,extraSourceParams:i.extraSourceParams}}function VC(i){var e,t;let r=i.theme;if(r){let s=(t=(e=i.getRootNode())==null?void 0:e.getElementById)==null?void 0:t.call(e,r);if(s&&s instanceof HTMLTemplateElement)return s;r.startsWith("media-theme-")||(r=`media-theme-${r}`);let n=lt.customElements.get(r);if(n!=null&&n.template)return n.template}}function qC(i){var e;let t=(e=i.mediaController)==null?void 0:e.querySelector("media-time-display");return t&&getComputedStyle(t).getPropertyValue("--media-duration-display-display").trim()==="none"}function R0(i){let e=i.hasAttribute(F.TITLE)?{video_title:i.getAttribute(F.TITLE)}:{};return i.getAttributeNames().filter(t=>t.startsWith("metadata-")).reduce((t,r)=>{let s=i.getAttribute(r);return s!==null&&(t[r.replace(/^metadata-/,"").replace(/-/g,"_")]=s),t},e)}var YC=Object.values(P),jC=Object.values(Oi),zC=Object.values(F),XC=nb(),QC="mux-player",w0={dialog:void 0,isDialogOpen:!1},ZC={redundant_streams:!0},Ul,$l,Vr,Bl,hn,Ni,sr,Ih,gb,kd,Rh,lr,qr,wh,C0,Ch,D0,Dh,M0,Mh,P0,O0=class extends A0{constructor(){super(),st(this,Ni),st(this,Ih),st(this,kd),st(this,lr),st(this,wh),st(this,Ch),st(this,Dh),st(this,Mh),st(this,Ul,!1),st(this,$l,{}),st(this,Vr,!0),st(this,Bl,new EC(this,"hotkeys")),st(this,hn,{...w0,onCloseErrorDialog:()=>Ge(this,kd,Rh).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:e=>{rb(this,gr.activeElement)||e.preventDefault()}}),this.attachShadow({mode:"open"}),Ge(this,Ih,gb).call(this),this.isConnected&&Ge(this,Ni,sr).call(this)}static get observedAttributes(){var e;return[...(e=A0.observedAttributes)!=null?e:[],...jC,...YC,...zC]}get mediaTheme(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("media-theme")}get mediaController(){var e,t;return(t=(e=this.mediaTheme)==null?void 0:e.shadowRoot)==null?void 0:t.querySelector("media-controller")}connectedCallback(){var e;let t=(e=this.shadowRoot)==null?void 0:e.querySelector("mux-video");t&&(t.metadata=R0(this))}attributeChangedCallback(e,t,r){switch(Ge(this,Ni,sr).call(this),super.attributeChangedCallback(e,t,r),e){case F.HOTKEYS:ve(this,Bl).value=r;break;case F.THUMBNAIL_TIME:{r!=null&&this.tokens.thumbnail&&Bi(ce("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case F.THUMBNAIL_TOKEN:{if(r){let{aud:s}=un(r);s!=="t"&&Bi(ce("The provided thumbnail-token should have audience value 'd' instead of '{aud}'.").format({aud:s}))}break}case F.STORYBOARD_TOKEN:{if(r){let{aud:s}=un(r);s!=="s"&&Bi(ce("The provided storyboard-token should have audience value 'd' instead of '{aud}'.").format({aud:s}))}break}case F.DRM_TOKEN:{if(r){let{aud:s}=un(r);s!=="d"&&Bi(ce("The provided drm-token should have audience value 'd' instead of '{aud}'.").format({aud:s}))}break}case P.PLAYBACK_ID:{r!=null&&r.includes("?token")&&Ft(ce("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:r}));break}case P.STREAM_TYPE:r&&![be.LIVE,be.ON_DEMAND,be.UNKNOWN].includes(r)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=r.includes("dvr")?Number.POSITIVE_INFINITY:0:ob({file:"invalid-stream-type.md",message:ce("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):r===be.LIVE?this.getAttribute(F.TARGET_LIVE_WINDOW)==null&&(this.targetLiveWindow=0):this.targetLiveWindow=Number.NaN}[P.PLAYBACK_ID,Oi.SRC,F.PLAYBACK_TOKEN].includes(e)&&t!==r&&Hi(this,hn,{...ve(this,hn),...w0}),Ge(this,lr,qr).call(this,{[vC(e)]:r})}get preferCmcd(){var e;return(e=this.getAttribute(P.PREFER_CMCD))!=null?e:void 0}set preferCmcd(e){e!==this.preferCmcd&&(e?rd.includes(e)?this.setAttribute(P.PREFER_CMCD,e):Bi(`Invalid value for preferCmcd. Must be one of ${rd.join()}`):this.removeAttribute(P.PREFER_CMCD))}get hasPlayed(){var e,t;return(t=(e=this.mediaController)==null?void 0:e.hasAttribute(T.MEDIA_HAS_PLAYED))!=null?t:!1}get inLiveWindow(){var e;return(e=this.mediaController)==null?void 0:e.hasAttribute(T.MEDIA_TIME_IS_LIVE)}get _hls(){var e;return(e=this.media)==null?void 0:e._hls}get mux(){var e;return(e=this.media)==null?void 0:e.mux}get theme(){var e;return(e=this.getAttribute(F.THEME))!=null?e:WC}set theme(e){this.setAttribute(F.THEME,`${e}`)}get themeProps(){let e=this.mediaTheme;if(!e)return;let t={};for(let r of e.getAttributeNames()){if(Lh.includes(r))continue;let s=e.getAttribute(r);t[tb(r)]=s===""?!0:s}return t}set themeProps(e){var t,r;Ge(this,Ni,sr).call(this);let s={...this.themeProps,...e};for(let n in s){if(Lh.includes(n))continue;let a=e==null?void 0:e[n];typeof a=="boolean"||a==null?(t=this.mediaTheme)==null||t.toggleAttribute(Ah(n),!!a):(r=this.mediaTheme)==null||r.setAttribute(Ah(n),a)}}get playbackId(){var e;return(e=this.getAttribute(P.PLAYBACK_ID))!=null?e:void 0}set playbackId(e){e?this.setAttribute(P.PLAYBACK_ID,e):this.removeAttribute(P.PLAYBACK_ID)}get src(){var e,t;return this.playbackId?(e=Sr(this,Oi.SRC))!=null?e:void 0:(t=this.getAttribute(Oi.SRC))!=null?t:void 0}set src(e){e?this.setAttribute(Oi.SRC,e):this.removeAttribute(Oi.SRC)}get poster(){var e;let t=this.getAttribute(Oi.POSTER);if(t!=null)return t;let{tokens:r}=this;if(r.playback&&!r.thumbnail){Bi("Missing expected thumbnail token. No poster image will be shown");return}if(this.playbackId&&!this.audio)return mC(this.playbackId,{customDomain:this.customDomain,thumbnailTime:(e=this.thumbnailTime)!=null?e:this.startTime,programTime:this.programStartTime,token:r.thumbnail})}set poster(e){e||e===""?this.setAttribute(Oi.POSTER,e):this.removeAttribute(Oi.POSTER)}get storyboardSrc(){var e;return(e=this.getAttribute(F.STORYBOARD_SRC))!=null?e:void 0}set storyboardSrc(e){e?this.setAttribute(F.STORYBOARD_SRC,e):this.removeAttribute(F.STORYBOARD_SRC)}get storyboard(){let{tokens:e}=this;if(this.storyboardSrc&&!e.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[be.LIVE,be.UNKNOWN].includes(this.streamType)||e.playback&&!e.storyboard))return pC(this.playbackId,{customDomain:this.customDomain,token:e.storyboard,programStartTime:this.programStartTime,programEndTime:this.programEndTime})}get audio(){return this.hasAttribute(F.AUDIO)}set audio(e){if(!e){this.removeAttribute(F.AUDIO);return}this.setAttribute(F.AUDIO,"")}get hotkeys(){return ve(this,Bl)}get nohotkeys(){return this.hasAttribute(F.NOHOTKEYS)}set nohotkeys(e){if(!e){this.removeAttribute(F.NOHOTKEYS);return}this.setAttribute(F.NOHOTKEYS,"")}get thumbnailTime(){return pi(this.getAttribute(F.THUMBNAIL_TIME))}set thumbnailTime(e){this.setAttribute(F.THUMBNAIL_TIME,`${e}`)}get title(){var e;return(e=this.getAttribute(F.TITLE))!=null?e:""}set title(e){e!==this.title&&(e?this.setAttribute(F.TITLE,e):this.removeAttribute("title"),super.title=e)}get placeholder(){var e;return(e=Sr(this,F.PLACEHOLDER))!=null?e:""}set placeholder(e){this.setAttribute(F.PLACEHOLDER,`${e}`)}get primaryColor(){var e,t;let r=this.getAttribute(F.PRIMARY_COLOR);if(r!=null||this.mediaTheme&&(r=(t=(e=lt.getComputedStyle(this.mediaTheme))==null?void 0:e.getPropertyValue("--_primary-color"))==null?void 0:t.trim(),r))return r}set primaryColor(e){this.setAttribute(F.PRIMARY_COLOR,`${e}`)}get secondaryColor(){var e,t;let r=this.getAttribute(F.SECONDARY_COLOR);if(r!=null||this.mediaTheme&&(r=(t=(e=lt.getComputedStyle(this.mediaTheme))==null?void 0:e.getPropertyValue("--_secondary-color"))==null?void 0:t.trim(),r))return r}set secondaryColor(e){this.setAttribute(F.SECONDARY_COLOR,`${e}`)}get accentColor(){var e,t;let r=this.getAttribute(F.ACCENT_COLOR);if(r!=null||this.mediaTheme&&(r=(t=(e=lt.getComputedStyle(this.mediaTheme))==null?void 0:e.getPropertyValue("--_accent-color"))==null?void 0:t.trim(),r))return r}set accentColor(e){this.setAttribute(F.ACCENT_COLOR,`${e}`)}get defaultShowRemainingTime(){return this.hasAttribute(F.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(e){e?this.setAttribute(F.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(F.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(this.hasAttribute(F.PLAYBACK_RATES))return this.getAttribute(F.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(e=>Number(e)).filter(e=>!Number.isNaN(e)).sort((e,t)=>e-t)}set playbackRates(e){if(!e){this.removeAttribute(F.PLAYBACK_RATES);return}this.setAttribute(F.PLAYBACK_RATES,e.join(" "))}get forwardSeekOffset(){var e;return(e=pi(this.getAttribute(F.FORWARD_SEEK_OFFSET)))!=null?e:10}set forwardSeekOffset(e){this.setAttribute(F.FORWARD_SEEK_OFFSET,`${e}`)}get backwardSeekOffset(){var e;return(e=pi(this.getAttribute(F.BACKWARD_SEEK_OFFSET)))!=null?e:10}set backwardSeekOffset(e){this.setAttribute(F.BACKWARD_SEEK_OFFSET,`${e}`)}get defaultHiddenCaptions(){return this.hasAttribute(F.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(e){e?this.setAttribute(F.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(F.DEFAULT_HIDDEN_CAPTIONS)}get defaultDuration(){return pi(this.getAttribute(F.DEFAULT_DURATION))}set defaultDuration(e){e==null?this.removeAttribute(F.DEFAULT_DURATION):this.setAttribute(F.DEFAULT_DURATION,`${e}`)}get playerSoftwareName(){var e;return(e=this.getAttribute(P.PLAYER_SOFTWARE_NAME))!=null?e:QC}get playerSoftwareVersion(){var e;return(e=this.getAttribute(P.PLAYER_SOFTWARE_VERSION))!=null?e:XC}get beaconCollectionDomain(){var e;return(e=this.getAttribute(P.BEACON_COLLECTION_DOMAIN))!=null?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(P.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(P.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var e;return(e=this.getAttribute(P.MAX_RESOLUTION))!=null?e:void 0}set maxResolution(e){e!==this.maxResolution&&(e?this.setAttribute(P.MAX_RESOLUTION,e):this.removeAttribute(P.MAX_RESOLUTION))}get minResolution(){var e;return(e=this.getAttribute(P.MIN_RESOLUTION))!=null?e:void 0}set minResolution(e){e!==this.minResolution&&(e?this.setAttribute(P.MIN_RESOLUTION,e):this.removeAttribute(P.MIN_RESOLUTION))}get renditionOrder(){var e;return(e=this.getAttribute(P.RENDITION_ORDER))!=null?e:void 0}set renditionOrder(e){e!==this.renditionOrder&&(e?this.setAttribute(P.RENDITION_ORDER,e):this.removeAttribute(P.RENDITION_ORDER))}get programStartTime(){return pi(this.getAttribute(P.PROGRAM_START_TIME))}set programStartTime(e){e==null?this.removeAttribute(P.PROGRAM_START_TIME):this.setAttribute(P.PROGRAM_START_TIME,`${e}`)}get programEndTime(){return pi(this.getAttribute(P.PROGRAM_END_TIME))}set programEndTime(e){e==null?this.removeAttribute(P.PROGRAM_END_TIME):this.setAttribute(P.PROGRAM_END_TIME,`${e}`)}get extraSourceParams(){return this.hasAttribute(F.EXTRA_SOURCE_PARAMS)?[...new URLSearchParams(this.getAttribute(F.EXTRA_SOURCE_PARAMS)).entries()].reduce((e,[t,r])=>(e[t]=r,e),{}):ZC}set extraSourceParams(e){e==null?this.removeAttribute(F.EXTRA_SOURCE_PARAMS):this.setAttribute(F.EXTRA_SOURCE_PARAMS,new URLSearchParams(e).toString())}get customDomain(){var e;return(e=this.getAttribute(P.CUSTOM_DOMAIN))!=null?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(P.CUSTOM_DOMAIN,e):this.removeAttribute(P.CUSTOM_DOMAIN))}get envKey(){var e;return(e=Sr(this,P.ENV_KEY))!=null?e:void 0}set envKey(e){this.setAttribute(P.ENV_KEY,`${e}`)}get noVolumePref(){return this.hasAttribute(F.NO_VOLUME_PREF)}set noVolumePref(e){e?this.setAttribute(F.NO_VOLUME_PREF,""):this.removeAttribute(F.NO_VOLUME_PREF)}get debug(){return Sr(this,P.DEBUG)!=null}set debug(e){e?this.setAttribute(P.DEBUG,""):this.removeAttribute(P.DEBUG)}get disableTracking(){return Sr(this,P.DISABLE_TRACKING)!=null}set disableTracking(e){this.toggleAttribute(P.DISABLE_TRACKING,!!e)}get disableCookies(){return Sr(this,P.DISABLE_COOKIES)!=null}set disableCookies(e){e?this.setAttribute(P.DISABLE_COOKIES,""):this.removeAttribute(P.DISABLE_COOKIES)}get streamType(){var e,t,r;return(r=(t=this.getAttribute(P.STREAM_TYPE))!=null?t:(e=this.media)==null?void 0:e.streamType)!=null?r:be.UNKNOWN}set streamType(e){this.setAttribute(P.STREAM_TYPE,`${e}`)}get defaultStreamType(){var e,t,r;return(r=(t=this.getAttribute(F.DEFAULT_STREAM_TYPE))!=null?t:(e=this.mediaController)==null?void 0:e.getAttribute(F.DEFAULT_STREAM_TYPE))!=null?r:be.ON_DEMAND}set defaultStreamType(e){e?this.setAttribute(F.DEFAULT_STREAM_TYPE,e):this.removeAttribute(F.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var e,t;return this.hasAttribute(F.TARGET_LIVE_WINDOW)?+this.getAttribute(F.TARGET_LIVE_WINDOW):(t=(e=this.media)==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN}set targetLiveWindow(e){e==this.targetLiveWindow||Number.isNaN(e)&&Number.isNaN(this.targetLiveWindow)||(e==null?this.removeAttribute(F.TARGET_LIVE_WINDOW):this.setAttribute(F.TARGET_LIVE_WINDOW,`${+e}`))}get liveEdgeStart(){var e;return(e=this.media)==null?void 0:e.liveEdgeStart}get startTime(){return pi(Sr(this,P.START_TIME))}set startTime(e){this.setAttribute(P.START_TIME,`${e}`)}get preferPlayback(){let e=this.getAttribute(P.PREFER_PLAYBACK);if(e===Ti.MSE||e===Ti.NATIVE)return e}set preferPlayback(e){e!==this.preferPlayback&&(e===Ti.MSE||e===Ti.NATIVE?this.setAttribute(P.PREFER_PLAYBACK,e):this.removeAttribute(P.PREFER_PLAYBACK))}get metadata(){var e;return(e=this.media)==null?void 0:e.metadata}set metadata(e){if(Ge(this,Ni,sr).call(this),!this.media){Ft("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...R0(this),...e}}get _hlsConfig(){var e;return(e=this.media)==null?void 0:e._hlsConfig}set _hlsConfig(e){if(Ge(this,Ni,sr).call(this),!this.media){Ft("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set.");return}this.media._hlsConfig=e}async addCuePoints(e){var t;if(Ge(this,Ni,sr).call(this),!this.media){Ft("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(t=this.media)==null?void 0:t.addCuePoints(e)}get activeCuePoint(){var e;return(e=this.media)==null?void 0:e.activeCuePoint}get cuePoints(){var e,t;return(t=(e=this.media)==null?void 0:e.cuePoints)!=null?t:[]}addChapters(e){var t;if(Ge(this,Ni,sr).call(this),!this.media){Ft("underlying media element missing when trying to addChapters. chapters will not be added.");return}return(t=this.media)==null?void 0:t.addChapters(e)}get activeChapter(){var e;return(e=this.media)==null?void 0:e.activeChapter}get chapters(){var e,t;return(t=(e=this.media)==null?void 0:e.chapters)!=null?t:[]}getStartDate(){var e;return(e=this.media)==null?void 0:e.getStartDate()}get currentPdt(){var e;return(e=this.media)==null?void 0:e.currentPdt}get tokens(){let e=this.getAttribute(F.PLAYBACK_TOKEN),t=this.getAttribute(F.DRM_TOKEN),r=this.getAttribute(F.THUMBNAIL_TOKEN),s=this.getAttribute(F.STORYBOARD_TOKEN);return{...ve(this,$l),...e!=null?{playback:e}:{},...t!=null?{drm:t}:{},...r!=null?{thumbnail:r}:{},...s!=null?{storyboard:s}:{}}}set tokens(e){Hi(this,$l,e??{})}get playbackToken(){var e;return(e=this.getAttribute(F.PLAYBACK_TOKEN))!=null?e:void 0}set playbackToken(e){this.setAttribute(F.PLAYBACK_TOKEN,`${e}`)}get drmToken(){var e;return(e=this.getAttribute(F.DRM_TOKEN))!=null?e:void 0}set drmToken(e){this.setAttribute(F.DRM_TOKEN,`${e}`)}get thumbnailToken(){var e;return(e=this.getAttribute(F.THUMBNAIL_TOKEN))!=null?e:void 0}set thumbnailToken(e){this.setAttribute(F.THUMBNAIL_TOKEN,`${e}`)}get storyboardToken(){var e;return(e=this.getAttribute(F.STORYBOARD_TOKEN))!=null?e:void 0}set storyboardToken(e){this.setAttribute(F.STORYBOARD_TOKEN,`${e}`)}addTextTrack(e,t,r,s){var n;let a=(n=this.media)==null?void 0:n.nativeEl;if(a)return of(a,e,t,r,s)}removeTextTrack(e){var t;let r=(t=this.media)==null?void 0:t.nativeEl;if(r)return Lk(r,e)}get textTracks(){var e;return(e=this.media)==null?void 0:e.textTracks}get castReceiver(){var e;return(e=this.getAttribute(F.CAST_RECEIVER))!=null?e:void 0}set castReceiver(e){e!==this.castReceiver&&(e?this.setAttribute(F.CAST_RECEIVER,e):this.removeAttribute(F.CAST_RECEIVER))}get castCustomData(){var e;return(e=this.media)==null?void 0:e.castCustomData}set castCustomData(e){if(!this.media){Ft("underlying media element missing when trying to set castCustomData. castCustomData will not be set.");return}this.media.castCustomData=e}get noTooltips(){return this.hasAttribute(F.NO_TOOLTIPS)}set noTooltips(e){if(!e){this.removeAttribute(F.NO_TOOLTIPS);return}this.setAttribute(F.NO_TOOLTIPS,"")}};Ul=new WeakMap,$l=new WeakMap,Vr=new WeakMap,Bl=new WeakMap,hn=new WeakMap,Ni=new WeakSet,sr=function(){var i,e,t,r;if(!ve(this,Ul)){Hi(this,Ul,!0),Ge(this,lr,qr).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof lt.HTMLElement))throw""}catch{Ft("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof yw))throw""}catch{Ft("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof lI))throw""}catch{Ft("<media-controller> failed to upgrade!")}this.init(),Ge(this,wh,C0).call(this),Ge(this,Ch,D0).call(this),Ge(this,Dh,M0).call(this),Hi(this,Vr,(e=(i=this.mediaController)==null?void 0:i.hasAttribute(me.USER_INACTIVE))!=null?e:!0),Ge(this,Mh,P0).call(this),(t=this.media)==null||t.addEventListener("streamtypechange",()=>Ge(this,lr,qr).call(this)),(r=this.media)==null||r.addEventListener("loadstart",()=>Ge(this,lr,qr).call(this))}},Ih=new WeakSet,gb=function(){var i,e;try{(i=window==null?void 0:window.CSS)==null||i.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(e=window==null?void 0:window.CSS)==null||e.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},kd=new WeakSet,Rh=function(i){Object.assign(ve(this,hn),i),Ge(this,lr,qr).call(this)},lr=new WeakSet,qr=function(i={}){OC(FC(KC(this,{...ve(this,hn),...i})),this.shadowRoot)},wh=new WeakSet,C0=function(){let i=e=>{var t,r;if(!(e!=null&&e.startsWith("theme-")))return;let s=e.replace(/^theme-/,"");if(Lh.includes(s))return;let n=this.getAttribute(e);n!=null?(t=this.mediaTheme)==null||t.setAttribute(s,n):(r=this.mediaTheme)==null||r.removeAttribute(s)};new MutationObserver(e=>{for(let{attributeName:t}of e)i(t)}).observe(this,{attributes:!0}),this.getAttributeNames().forEach(i)},Ch=new WeakSet,D0=function(){var i;let e=t=>{let{detail:r}=t;if(r instanceof St||(r=new St(r.message,r.code,r.fatal)),!(r!=null&&r.fatal)){Bi(r),r.data&&Bi(`${r.name} data:`,r.data);return}let{dialog:s,devlog:n}=xh(r,!window.navigator.onLine,this.playbackId,this.playbackToken);n.message&&ob(n),Ft(r),r.data&&Ft(`${r.name} data:`,r.data),Ge(this,kd,Rh).call(this,{isDialogOpen:!0,dialog:s})};this.addEventListener("error",e),this.media&&(this.media.errorTranslator=(t={})=>{var r,s,n;if(!(((r=this.media)==null?void 0:r.error)instanceof St))return t;let{devlog:a}=xh((s=this.media)==null?void 0:s.error,!window.navigator.onLine,this.playbackId,this.playbackToken,!1);return{player_error_code:(n=this.media)==null?void 0:n.error.code,player_error_message:a.message?String(a.message):t.player_error_message,player_error_context:a.context?String(a.context):t.player_error_context}}),(i=this.media)==null||i.addEventListener("error",t=>{var r,s;let{detail:n}=t;if(!n){let{message:a,code:o}=(s=(r=this.media)==null?void 0:r.error)!=null?s:{};n=new St(a,o)}n!=null&&n.fatal&&this.dispatchEvent(new CustomEvent("error",{detail:n}))})},Dh=new WeakSet,M0=function(){var i,e,t,r;let s=()=>Ge(this,lr,qr).call(this);(e=(i=this.media)==null?void 0:i.textTracks)==null||e.addEventListener("addtrack",s),(r=(t=this.media)==null?void 0:t.textTracks)==null||r.addEventListener("removetrack",s)},Mh=new WeakSet,P0=function(){var i,e;if(!/Firefox/i.test(navigator.userAgent))return;let t,r=new WeakMap,s=()=>this.streamType===be.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,n=(l,d,u=!1)=>{s()||Array.from(l&&l.activeCues||[]).forEach(c=>{if(!(!c.snapToLines||c.line<-5||c.line>=0&&c.line<10))if(!d||this.paused){let h=c.text.split(`
3052
- `).length,f=-3;this.streamType===be.LIVE&&(f=-2);let m=f-h;if(c.line===m&&!u)return;r.has(c)||r.set(c,c.line),c.line=m}else setTimeout(()=>{c.line=r.get(c)||"auto"},500)})},a=()=>{var l,d;n(t,(d=(l=this.mediaController)==null?void 0:l.hasAttribute(me.USER_INACTIVE))!=null?d:!1)},o=()=>{var l,d;let u=Array.from(((d=(l=this.mediaController)==null?void 0:l.media)==null?void 0:d.textTracks)||[]).filter(c=>["subtitles","captions"].includes(c.kind)&&c.mode==="showing")[0];u!==t&&(t==null||t.removeEventListener("cuechange",a)),t=u,t==null||t.addEventListener("cuechange",a),n(t,ve(this,Vr))};o(),(i=this.textTracks)==null||i.addEventListener("change",o),(e=this.textTracks)==null||e.addEventListener("addtrack",o),this.addEventListener("userinactivechange",()=>{var l,d;let u=(d=(l=this.mediaController)==null?void 0:l.hasAttribute(me.USER_INACTIVE))!=null?d:!0;ve(this,Vr)!==u&&(Hi(this,Vr,u),n(t,ve(this,Vr)))})};function Sr(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}lt.customElements.get("mux-player")||(lt.customElements.define("mux-player",O0),lt.MuxPlayerElement=O0);var N0={className:"class",classname:"class",htmlFor:"for",crossOrigin:"crossorigin",viewBox:"viewBox",playsInline:"playsinline",autoPlay:"autoplay",playbackRate:"playbackrate"},JC=i=>i==null,eD=(i,e)=>JC(e)?!1:i in e,tD=i=>i.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),iD=(i,e)=>{if(!(typeof e=="boolean"&&!e)){if(eD(i,N0))return N0[i];if(typeof e!=null)return/[A-Z]/.test(i)?tD(i):i}},rD=(i,e)=>typeof i=="boolean"?"":i,sD=(i={})=>Object.entries(i).reduce((e,[t,r])=>{let s=iD(t,r);if(!s)return e;let n=rD(r);return e[s]=n,e},{}),nD=(...i)=>{let e=ft.useRef(null);return ft.useEffect(()=>{i.forEach(t=>{t&&(typeof t=="function"?t(e.current):t.current=e.current)})},[i]),e},aD=Object.prototype.hasOwnProperty,oD=(i,e)=>{if(Object.is(i,e))return!0;if(typeof i!="object"||i===null||typeof e!="object"||e===null)return!1;if(Array.isArray(i))return!Array.isArray(e)||i.length!==e.length?!1:i.some((s,n)=>e[n]===s);let t=Object.keys(i),r=Object.keys(e);if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(!aD.call(e,t[s])||!Object.is(i[t[s]],e[t[s]]))return!1;return!0},vb=(i,e,t)=>!oD(e,i[t]),lD=(i,e,t)=>{i[t]=e},dD=(i,e,t,r=lD,s=vb)=>ft.useEffect(()=>{let n=t==null?void 0:t.current;n&&s(n,e,i)&&r(n,e,i)},[t==null?void 0:t.current,e]),ii=dD,uD=()=>{try{return"3.0.0"}catch{}return"UNKNOWN"},cD=uD(),hD=()=>cD,fD=Gl.forwardRef(({children:i,...e},t)=>Gl.createElement("mux-player",sD({...e,ref:t}),i)),xe=(i,e,t)=>ft.useEffect(()=>{let r=e==null?void 0:e.current;if(!(!r||!t))return r.addEventListener(i,t),()=>{r.removeEventListener(i,t)}},[e==null?void 0:e.current,t]),mD=(i,e)=>{let{onAbort:t,onCanPlay:r,onCanPlayThrough:s,onEmptied:n,onLoadStart:a,onLoadedData:o,onLoadedMetadata:l,onProgress:d,onDurationChange:u,onVolumeChange:c,onRateChange:h,onResize:f,onWaiting:m,onPlay:p,onPlaying:g,onTimeUpdate:E,onPause:y,onSeeking:b,onSeeked:S,onStalled:_,onSuspend:x,onEnded:A,onError:C,onCuePointChange:O,onCuePointsChange:L,onChapterChange:M,metadata:K,tokens:U,paused:z,playbackId:V,playbackRates:q,currentTime:ae,themeProps:ne,extraSourceParams:G,castCustomData:$,_hlsConfig:te,...re}=e;return ii("playbackRates",q,i),ii("metadata",K,i),ii("extraSourceParams",G,i),ii("_hlsConfig",te,i),ii("themeProps",ne,i),ii("tokens",U,i),ii("playbackId",V,i),ii("castCustomData",$,i),ii("paused",z,i,(oe,pe)=>{pe!=null&&(pe?oe.pause():oe.play())},(oe,pe,Re)=>oe.hasAttribute("autoplay")&&!oe.hasPlayed?!1:vb(oe,pe,Re)),ii("currentTime",ae,i,(oe,pe)=>{pe!=null&&(oe.currentTime=pe)}),xe("abort",i,t),xe("canplay",i,r),xe("canplaythrough",i,s),xe("emptied",i,n),xe("loadstart",i,a),xe("loadeddata",i,o),xe("loadedmetadata",i,l),xe("progress",i,d),xe("durationchange",i,u),xe("volumechange",i,c),xe("ratechange",i,h),xe("resize",i,f),xe("waiting",i,m),xe("play",i,p),xe("playing",i,g),xe("timeupdate",i,E),xe("pause",i,y),xe("seeking",i,b),xe("seeked",i,S),xe("stalled",i,_),xe("suspend",i,x),xe("ended",i,A),xe("error",i,C),xe("cuepointchange",i,O),xe("cuepointschange",i,L),xe("chapterchange",i,M),[re]},pD=hD(),gD="mux-player-react",vD=Gl.forwardRef((i,e)=>{let t=ft.useRef(null),r=nD(t,e),[s]=mD(t,i);return Gl.createElement(fD,{ref:r,playerSoftwareName:gD,playerSoftwareVersion:pD,...s})}),ED=vD;const yD=Vd.object({time:Vd.number(),expiresAt:Vd.string()}).transform(i=>({time:Number(i.time),expiresAt:new Date(i.expiresAt)}));function bD(){var e;const i=Mb("root");return((e=i==null?void 0:i.preferences)==null?void 0:e.player)??null}const TD=["INPUT","SELECT","BUTTON","TEXTAREA","MUX-PLAYER","SUMMARY"],_D=["button","option","combobox","tab","tablist"];function F0(i){let e=i;for(;e;){if(!(e instanceof HTMLElement))return!1;if(TD.includes(e.tagName)||_D.includes(e.getAttribute("role")||"")||e.isContentEditable)return!0;e=e.parentElement}return!1}function U0(i){const e=ft.useRef(i);return ft.useEffect(()=>{e.current=i},[i]),e}function AD({muxPlayerRef:i,...e}){const t=bD(),r=Db(),[s,n]=ft.useState(!1),a=`${e.playbackId}:currentTime`,[o,l]=ft.useState(0),d=U0(r),u=U0(t);ft.useEffect(()=>{if(typeof document>"u")return;const h=sessionStorage.getItem(a);if(h)try{const{time:f,expiresAt:m}=yD.parse(JSON.parse(h));if(m.getTime()<Date.now())throw new Error("Time expired");l(f)}catch{sessionStorage.removeItem(a)}},[a]),ft.useEffect(()=>{function h(f){if(!i.current)return;const m=document.activeElement;F0(m)||F0(f.target)||(f.key===" "&&(f.preventDefault(),i.current.paused?i.current.play():i.current.pause()),f.key==="ArrowRight"&&(f.preventDefault(),i.current.currentTime=i.current.currentTime+(i.current.forwardSeekOffset||10)),f.key==="ArrowLeft"&&(f.preventDefault(),i.current.currentTime=i.current.currentTime-(i.current.forwardSeekOffset||10)),f.key==="f"&&!f.metaKey&&!f.ctrlKey&&(f.preventDefault(),document.fullscreenElement?document.exitFullscreen():i.current.requestFullscreen()))}return window.document.addEventListener("keydown",h),()=>{window.document.removeEventListener("keydown",h)}},[i]);const c=Rb(()=>{const h=i.current;if(!h)return;const f=Array.from(h.textTracks??[]).find(p=>p.kind==="subtitles"),m={playbackRate:h.playbackRate,volumeRate:h.volume,subtitle:f?{id:f.id,mode:f.mode}:{id:null,mode:"disabled"}};Ph(m,u.current)||d.current.submit(m,{method:"POST",action:"/video-player",encType:"application/json"})},300);return ft.useEffect(()=>{var m,p;if(!s)return;const h=(m=i.current)==null?void 0:m.textTracks;if(!h)return;const f=(p=u.current)==null?void 0:p.subtitle;if(f!=null&&f.id){const g=h.getTrackById(f.id);g&&(g.mode=f.mode??"hidden")}return h.addEventListener("change",c),()=>{h.removeEventListener("change",c)}},[s,i,u,c]),H.jsx("div",{className:"flex aspect-video flex-col",children:H.jsx(ED,{ref:i,playbackRates:[.5,.75,1,1.25,1.5,1.75,2,2.5,3,3.5,4],volume:(t==null?void 0:t.volumeRate)??1,playbackRate:(t==null?void 0:t.playbackRate)??1,thumbnailTime:o,onRateChange:c,onVolumeChange:c,streamType:"on-demand",defaultHiddenCaptions:!0,currentTime:o,onTimeUpdate:()=>{var h;return sessionStorage.setItem(a,JSON.stringify({time:(h=i.current)==null?void 0:h.currentTime,expiresAt:new Date(Date.now()+1e3*60*30).toISOString()}))},accentColor:"#427cf0",targetLiveWindow:NaN,onLoadedMetadata:()=>n(!0),...e})})}function Ph(i,e){if(i===e)return!0;if(typeof i!=typeof e||typeof i!="object"||typeof e!="object"||i===null||e===null||Array.isArray(i)!==Array.isArray(e))return!1;if(Array.isArray(i)&&Array.isArray(e)){if(i.length!==e.length)return!1;for(let s=0;s<i.length;s++)if(!Ph(i[s],e[s]))return!1;return!0}const t=Object.keys(i),r=Object.keys(e);if(t.length!==r.length)return!1;for(const s of t)if(!Ph(i[s],e[s]))return!1;return!0}const Eb=ft.createContext(null);function lM({children:i,epicVideoInfosPromise:e}){return H.jsx(Eb.Provider,{value:e,children:i})}function yb(i){let e=new URL("https://epicweb.dev");try{e=new URL(i)}catch(c){return console.error(c),"EpicWeb.dev Video"}const t=e.pathname.split("/").filter(Boolean),r=t.includes("solution");let s=t.pop();const n=["problem","solution","embed","exercise"],a=c=>c&&!n.includes(c);for(;!a(s);)s=t.pop();if(!s)return"EpicWeb.dev Video";const o=s.split("-"),l=["the","a","an","and","but","or","for","nor","on","at","to","from","by","of","in","with","as","npm","git","ssh","cli"],d=["OAuth","UI","UX","API","CSS","HTML","JS","TS","SVG","AI","CSRF","CORS","HTTP","HTTPS","URL","URI","DB","SQL","JSON","YAML","YML","useActionData","useAsyncError","useAsyncValue","useBeforeUnload","useFetcher","useFetchers","useFormAction","useHref","useLoaderData","useLocation","useMatches","useNavigate","useNavigation","useNavigationType","useOutlet","useOutletContext","useParams","useResolvedPath","useRevalidator","useRouteError","useRouteLoaderData","useSearchParams","useSubmit","useCallback","useContext","useDebugValue","useDeferredValue","useEffect","useId","useImperativeHandle","useInsertionEffect","useLayoutEffect","useMemo","useReducer","useRef","useState","useSyncExternalStore","useTransition","useForm","useFieldset","useFieldList","useEventSource","useHydrated","useAuthenticityToken","useShouldHydrate","useGlobalNavigationState","useLocales","useDelegatedAnchors","useDebounceFetcher","useFetcherType"],u=o.filter(Boolean).map((c,h)=>{var p;const f=c.toLowerCase(),m=d.find(g=>g.toLowerCase()===f);return m||(l.includes(f)&&h>0?f:((p=f[0])==null?void 0:p.toUpperCase())+f.slice(1))}).join(" ");return r?`${u} (🏁 solution)`:u}function SD({url:i,title:e="Video Embed",loadingContent:t=H.jsx(Oh,{children:H.jsxs("span",{children:['Loading "',e,'"']})})}){const[r,s]=ft.useState(!1);return H.jsxs("div",{className:"relative aspect-video w-full flex-shrink-0 shadow-lg dark:shadow-gray-800",children:[r?null:H.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:t}),H.jsx("iframe",{onLoad:()=>s(!0),onError:()=>s(!0),src:i,className:wb("absolute inset-0 flex h-full w-full transition-opacity duration-300",r?"opacity-100":"opacity-0"),title:e,sandbox:"allow-forms allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",allowFullScreen:!0})]})}function bb({url:i,title:e}){return H.jsxs("a",{href:i,target:"_blank",className:"flex items-center gap-1 text-base no-underline opacity-70 transition hover:underline hover:opacity-100",rel:"noreferrer",children:[H.jsx(Cb,{className:"flex-shrink-0",name:"Video",size:"lg"}),e," ",H.jsx("span",{"aria-hidden":!0,children:"↗︎"})]})}function dM({url:i,title:e=yb(i)}){const{product:{host:t,displayName:r}}=Nb(),s=Ob(),n=ft.useContext(Eb),a=H.jsx("div",{children:H.jsx(bb,{url:i,title:e})});return H.jsx("div",{children:H.jsx(ft.Suspense,{fallback:H.jsxs("div",{children:[H.jsx("div",{className:"flex aspect-video w-full items-center justify-center",children:H.jsx(Oh,{children:e})}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,H.jsx("div",{className:"h-[32px]"})]})]}),children:H.jsx(Pb,{errorElement:H.jsx("div",{children:"Sorry, failed loading videos. Check the terminal output?"}),resolve:n,children:o=>{const l=o==null?void 0:o[i],d=ENV.EPICSHOP_DEPLOYED?H.jsxs("div",{children:[H.jsx(ja,{to:ENV.EPICSHOP_GITHUB_REPO,className:"underline",children:"Run locally"})," for transcripts"]}):H.jsxs("div",{children:[H.jsx(ja,{to:"/login",className:"underline",children:s?"Upgrade":"Login"})," for transcripts"]});if(!l)return H.jsxs("div",{children:[H.jsx(Gn,{url:i,title:e}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,d]})]});const u=l;return u.status==="success"?H.jsx(xD,{url:i,title:e,muxPlaybackId:u.muxPlaybackId,transcript:u.transcript}):u.type==="region-restricted"?H.jsxs("div",{children:[H.jsxs("div",{className:"flex aspect-video min-h-full min-w-full flex-col items-center justify-start gap-2 overflow-y-scroll border-2 p-4 lg:justify-center lg:gap-4 lg:text-xl",children:[H.jsx("div",{className:"!text-foreground-danger",children:"Error: Region Restricted"}),H.jsxs("div",{children:["We've detected you're connecting from"," ",u.requestCountry," but your license has restricted access to ",u.restrictedCountry]}),H.jsxs("div",{children:["To continue watching uninterrupted, please"," ",H.jsxs("a",{href:`https://${t}/products`,className:"underline",children:["upgrade your ",r," license"]})," ","to a full Pro license."]})]}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,H.jsxs("div",{children:[H.jsx(ja,{to:`https://${t}/products`,className:"underline",children:"Upgrade"})," for transcripts"]})]})]}):u.statusCode===401?H.jsxs("div",{children:[H.jsx(Gn,{url:i,title:e}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,d]})]}):u.statusCode===403?H.jsxs("div",{children:[H.jsx(Gn,{url:i,title:e}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,H.jsxs("div",{children:[H.jsx(ja,{to:`https://${t}/products`,className:"underline",children:"Upgrade"})," for transcripts"]})]})]}):u.statusCode===404?H.jsxs("div",{children:[H.jsx(Gn,{url:i,title:e}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,H.jsx("div",{children:"Transcripts not found"})]})]}):(console.error(u),H.jsxs("div",{children:[H.jsx(Gn,{url:i,title:e}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,H.jsx("div",{className:"!text-foreground-danger",children:"Unknown error (check console)"})]})]}))}})})})}function xD({url:i,title:e=yb(i),muxPlaybackId:t,transcript:r}){const s=ft.useRef(null),n=/(\d+:\d+)/g,a=[];let o,l=0;for(;o=n.exec(r);){const d=o[1];if(!n.lastIndex||!d)break;const u=o.index,c=n.lastIndex,h=r.slice(l+1,u-1);a.push(H.jsx("span",{children:h},u)),a.push(H.jsx("button",{className:"underline",onClick:f=>{s.current&&(s.current.currentTime=kD(d),s.current.play(),s.current.scrollIntoView({behavior:"smooth",inline:"center",block:"start"}),f.currentTarget.blur())},children:d},d)),l=c}return a.push(H.jsx("span",{children:r.slice(l+1,r.length)},r.length)),H.jsxs("div",{children:[H.jsx("div",{className:"shadow-lg dark:shadow-gray-800",children:H.jsx(AD,{playbackId:t,muxPlayerRef:s,title:e})}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[H.jsx(bb,{url:i,title:e}),H.jsxs("details",{children:[H.jsx("summary",{children:"Transcript"}),H.jsx("div",{className:"whitespace-pre-line rounded-md bg-accent p-2 text-accent-foreground",children:a})]})]})]})}function kD(i){const e=i.split(":");let t=0,r=1;for(;e.length>0;)t+=r*parseInt(e.pop()??"0",10),r*=60;return t}function Gn({url:i,title:e}){const t=Ib();let r=new URL("https://epicweb.dev");try{r=new URL(i)}catch(s){return console.error(s),H.jsxs("div",{children:['Invalid URL: "',i,'"']})}return r.pathname=r.pathname.endsWith("/")?`${r.pathname}embed`:`${r.pathname}/embed`,r.searchParams.set("theme",t),H.jsx(SD,{url:r.toString(),title:e,loadingContent:H.jsx(Oh,{children:H.jsxs("span",{children:['Loading "',H.jsx("a",{className:"underline",href:i,children:e}),'"']})})})}export{dM as D,lM as E,SD as V};
3053
- //# sourceMappingURL=epic-video-Bp4BOD2R.js.map
3051
+ `,Ih=gr.createElement("template");"innerHTML"in Ih&&(Ih.innerHTML=KC);var R0,w0,vb=class extends Kd{};vb.template=(w0=(R0=Ih.content)==null?void 0:R0.children)==null?void 0:w0[0];lt.customElements.get("media-theme-gerwig")||lt.customElements.define("media-theme-gerwig",vb);var VC="gerwig",Oi={SRC:"src",POSTER:"poster"},F={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",ACCENT_COLOR:"accent-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",DRM_TOKEN:"drm-token",STORYBOARD_SRC:"storyboard-src",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys",HOTKEYS:"hotkeys",PLAYBACK_RATES:"playbackrates",DEFAULT_SHOW_REMAINING_TIME:"default-show-remaining-time",DEFAULT_DURATION:"default-duration",TITLE:"title",PLACEHOLDER:"placeholder",THEME:"theme",DEFAULT_STREAM_TYPE:"default-stream-type",TARGET_LIVE_WINDOW:"target-live-window",EXTRA_SOURCE_PARAMS:"extra-source-params",NO_VOLUME_PREF:"no-volume-pref",CAST_RECEIVER:"cast-receiver",NO_TOOLTIPS:"no-tooltips"},Rh=["audio","backwardseekoffset","defaultduration","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function qC(i,e){var t;return{src:!i.playbackId&&i.src,playbackId:i.playbackId,hasSrc:!!i.playbackId||!!i.src||!!i.currentSrc,poster:i.poster,storyboard:i.storyboard,storyboardSrc:i.getAttribute(F.STORYBOARD_SRC),placeholder:i.getAttribute("placeholder"),themeTemplate:YC(i),thumbnailTime:!i.tokens.thumbnail&&i.thumbnailTime,autoplay:i.autoplay,crossOrigin:i.crossOrigin,loop:i.loop,noHotKeys:i.hasAttribute(F.NOHOTKEYS),hotKeys:i.getAttribute(F.HOTKEYS),muted:i.muted,paused:i.paused,preload:i.preload,envKey:i.envKey,preferCmcd:i.preferCmcd,debug:i.debug,disableTracking:i.disableTracking,disableCookies:i.disableCookies,tokens:i.tokens,beaconCollectionDomain:i.beaconCollectionDomain,maxResolution:i.maxResolution,minResolution:i.minResolution,programStartTime:i.programStartTime,programEndTime:i.programEndTime,renditionOrder:i.renditionOrder,metadata:i.metadata,playerSoftwareName:i.playerSoftwareName,playerSoftwareVersion:i.playerSoftwareVersion,startTime:i.startTime,preferPlayback:i.preferPlayback,audio:i.audio,defaultStreamType:i.defaultStreamType,targetLiveWindow:i.getAttribute(P.TARGET_LIVE_WINDOW),streamType:Jf(i.getAttribute(P.STREAM_TYPE)),primaryColor:i.getAttribute(F.PRIMARY_COLOR),secondaryColor:i.getAttribute(F.SECONDARY_COLOR),accentColor:i.getAttribute(F.ACCENT_COLOR),forwardSeekOffset:i.forwardSeekOffset,backwardSeekOffset:i.backwardSeekOffset,defaultHiddenCaptions:i.defaultHiddenCaptions,defaultDuration:i.defaultDuration,defaultShowRemainingTime:i.defaultShowRemainingTime,hideDuration:jC(i),playbackRates:i.getAttribute(F.PLAYBACK_RATES),customDomain:(t=i.getAttribute(P.CUSTOM_DOMAIN))!=null?t:void 0,title:i.getAttribute(F.TITLE),novolumepref:i.hasAttribute(F.NO_VOLUME_PREF),castReceiver:i.castReceiver,...e,extraSourceParams:i.extraSourceParams}}function YC(i){var e,t;let r=i.theme;if(r){let s=(t=(e=i.getRootNode())==null?void 0:e.getElementById)==null?void 0:t.call(e,r);if(s&&s instanceof HTMLTemplateElement)return s;r.startsWith("media-theme-")||(r=`media-theme-${r}`);let n=lt.customElements.get(r);if(n!=null&&n.template)return n.template}}function jC(i){var e;let t=(e=i.mediaController)==null?void 0:e.querySelector("media-time-display");return t&&getComputedStyle(t).getPropertyValue("--media-duration-display-display").trim()==="none"}function C0(i){let e=i.hasAttribute(F.TITLE)?{video_title:i.getAttribute(F.TITLE)}:{};return i.getAttributeNames().filter(t=>t.startsWith("metadata-")).reduce((t,r)=>{let s=i.getAttribute(r);return s!==null&&(t[r.replace(/^metadata-/,"").replace(/-/g,"_")]=s),t},e)}var zC=Object.values(P),XC=Object.values(Oi),QC=Object.values(F),ZC=ob(),JC="mux-player",D0={dialog:void 0,isDialogOpen:!1},eD={redundant_streams:!0},Bl,Gl,Vr,Hl,fn,Ni,sr,wh,Eb,Id,Ch,lr,qr,Dh,M0,Mh,P0,Ph,O0,Oh,N0,F0=class extends x0{constructor(){super(),st(this,Ni),st(this,wh),st(this,Id),st(this,lr),st(this,Dh),st(this,Mh),st(this,Ph),st(this,Oh),st(this,Bl,!1),st(this,Gl,{}),st(this,Vr,!0),st(this,Hl,new bC(this,"hotkeys")),st(this,fn,{...D0,onCloseErrorDialog:()=>Ge(this,Id,Ch).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:e=>{nb(this,gr.activeElement)||e.preventDefault()}}),this.attachShadow({mode:"open"}),Ge(this,wh,Eb).call(this),this.isConnected&&Ge(this,Ni,sr).call(this)}static get observedAttributes(){var e;return[...(e=x0.observedAttributes)!=null?e:[],...XC,...zC,...QC]}get mediaTheme(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("media-theme")}get mediaController(){var e,t;return(t=(e=this.mediaTheme)==null?void 0:e.shadowRoot)==null?void 0:t.querySelector("media-controller")}connectedCallback(){var e;let t=(e=this.shadowRoot)==null?void 0:e.querySelector("mux-video");t&&(t.metadata=C0(this))}attributeChangedCallback(e,t,r){switch(Ge(this,Ni,sr).call(this),super.attributeChangedCallback(e,t,r),e){case F.HOTKEYS:ve(this,Hl).value=r;break;case F.THUMBNAIL_TIME:{r!=null&&this.tokens.thumbnail&&Bi(ce("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case F.THUMBNAIL_TOKEN:{if(r){let{aud:s}=cn(r);s!=="t"&&Bi(ce("The provided thumbnail-token should have audience value 'd' instead of '{aud}'.").format({aud:s}))}break}case F.STORYBOARD_TOKEN:{if(r){let{aud:s}=cn(r);s!=="s"&&Bi(ce("The provided storyboard-token should have audience value 'd' instead of '{aud}'.").format({aud:s}))}break}case F.DRM_TOKEN:{if(r){let{aud:s}=cn(r);s!=="d"&&Bi(ce("The provided drm-token should have audience value 'd' instead of '{aud}'.").format({aud:s}))}break}case P.PLAYBACK_ID:{r!=null&&r.includes("?token")&&Ft(ce("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:r}));break}case P.STREAM_TYPE:r&&![be.LIVE,be.ON_DEMAND,be.UNKNOWN].includes(r)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=r.includes("dvr")?Number.POSITIVE_INFINITY:0:db({file:"invalid-stream-type.md",message:ce("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):r===be.LIVE?this.getAttribute(F.TARGET_LIVE_WINDOW)==null&&(this.targetLiveWindow=0):this.targetLiveWindow=Number.NaN}[P.PLAYBACK_ID,Oi.SRC,F.PLAYBACK_TOKEN].includes(e)&&t!==r&&Hi(this,fn,{...ve(this,fn),...D0}),Ge(this,lr,qr).call(this,{[yC(e)]:r})}get preferCmcd(){var e;return(e=this.getAttribute(P.PREFER_CMCD))!=null?e:void 0}set preferCmcd(e){e!==this.preferCmcd&&(e?nd.includes(e)?this.setAttribute(P.PREFER_CMCD,e):Bi(`Invalid value for preferCmcd. Must be one of ${nd.join()}`):this.removeAttribute(P.PREFER_CMCD))}get hasPlayed(){var e,t;return(t=(e=this.mediaController)==null?void 0:e.hasAttribute(T.MEDIA_HAS_PLAYED))!=null?t:!1}get inLiveWindow(){var e;return(e=this.mediaController)==null?void 0:e.hasAttribute(T.MEDIA_TIME_IS_LIVE)}get _hls(){var e;return(e=this.media)==null?void 0:e._hls}get mux(){var e;return(e=this.media)==null?void 0:e.mux}get theme(){var e;return(e=this.getAttribute(F.THEME))!=null?e:VC}set theme(e){this.setAttribute(F.THEME,`${e}`)}get themeProps(){let e=this.mediaTheme;if(!e)return;let t={};for(let r of e.getAttributeNames()){if(Rh.includes(r))continue;let s=e.getAttribute(r);t[rb(r)]=s===""?!0:s}return t}set themeProps(e){var t,r;Ge(this,Ni,sr).call(this);let s={...this.themeProps,...e};for(let n in s){if(Rh.includes(n))continue;let a=e==null?void 0:e[n];typeof a=="boolean"||a==null?(t=this.mediaTheme)==null||t.toggleAttribute(xh(n),!!a):(r=this.mediaTheme)==null||r.setAttribute(xh(n),a)}}get playbackId(){var e;return(e=this.getAttribute(P.PLAYBACK_ID))!=null?e:void 0}set playbackId(e){e?this.setAttribute(P.PLAYBACK_ID,e):this.removeAttribute(P.PLAYBACK_ID)}get src(){var e,t;return this.playbackId?(e=Sr(this,Oi.SRC))!=null?e:void 0:(t=this.getAttribute(Oi.SRC))!=null?t:void 0}set src(e){e?this.setAttribute(Oi.SRC,e):this.removeAttribute(Oi.SRC)}get poster(){var e;let t=this.getAttribute(Oi.POSTER);if(t!=null)return t;let{tokens:r}=this;if(r.playback&&!r.thumbnail){Bi("Missing expected thumbnail token. No poster image will be shown");return}if(this.playbackId&&!this.audio)return gC(this.playbackId,{customDomain:this.customDomain,thumbnailTime:(e=this.thumbnailTime)!=null?e:this.startTime,programTime:this.programStartTime,token:r.thumbnail})}set poster(e){e||e===""?this.setAttribute(Oi.POSTER,e):this.removeAttribute(Oi.POSTER)}get storyboardSrc(){var e;return(e=this.getAttribute(F.STORYBOARD_SRC))!=null?e:void 0}set storyboardSrc(e){e?this.setAttribute(F.STORYBOARD_SRC,e):this.removeAttribute(F.STORYBOARD_SRC)}get storyboard(){let{tokens:e}=this;if(this.storyboardSrc&&!e.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[be.LIVE,be.UNKNOWN].includes(this.streamType)||e.playback&&!e.storyboard))return vC(this.playbackId,{customDomain:this.customDomain,token:e.storyboard,programStartTime:this.programStartTime,programEndTime:this.programEndTime})}get audio(){return this.hasAttribute(F.AUDIO)}set audio(e){if(!e){this.removeAttribute(F.AUDIO);return}this.setAttribute(F.AUDIO,"")}get hotkeys(){return ve(this,Hl)}get nohotkeys(){return this.hasAttribute(F.NOHOTKEYS)}set nohotkeys(e){if(!e){this.removeAttribute(F.NOHOTKEYS);return}this.setAttribute(F.NOHOTKEYS,"")}get thumbnailTime(){return pi(this.getAttribute(F.THUMBNAIL_TIME))}set thumbnailTime(e){this.setAttribute(F.THUMBNAIL_TIME,`${e}`)}get title(){var e;return(e=this.getAttribute(F.TITLE))!=null?e:""}set title(e){e!==this.title&&(e?this.setAttribute(F.TITLE,e):this.removeAttribute("title"),super.title=e)}get placeholder(){var e;return(e=Sr(this,F.PLACEHOLDER))!=null?e:""}set placeholder(e){this.setAttribute(F.PLACEHOLDER,`${e}`)}get primaryColor(){var e,t;let r=this.getAttribute(F.PRIMARY_COLOR);if(r!=null||this.mediaTheme&&(r=(t=(e=lt.getComputedStyle(this.mediaTheme))==null?void 0:e.getPropertyValue("--_primary-color"))==null?void 0:t.trim(),r))return r}set primaryColor(e){this.setAttribute(F.PRIMARY_COLOR,`${e}`)}get secondaryColor(){var e,t;let r=this.getAttribute(F.SECONDARY_COLOR);if(r!=null||this.mediaTheme&&(r=(t=(e=lt.getComputedStyle(this.mediaTheme))==null?void 0:e.getPropertyValue("--_secondary-color"))==null?void 0:t.trim(),r))return r}set secondaryColor(e){this.setAttribute(F.SECONDARY_COLOR,`${e}`)}get accentColor(){var e,t;let r=this.getAttribute(F.ACCENT_COLOR);if(r!=null||this.mediaTheme&&(r=(t=(e=lt.getComputedStyle(this.mediaTheme))==null?void 0:e.getPropertyValue("--_accent-color"))==null?void 0:t.trim(),r))return r}set accentColor(e){this.setAttribute(F.ACCENT_COLOR,`${e}`)}get defaultShowRemainingTime(){return this.hasAttribute(F.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(e){e?this.setAttribute(F.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute(F.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(this.hasAttribute(F.PLAYBACK_RATES))return this.getAttribute(F.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(e=>Number(e)).filter(e=>!Number.isNaN(e)).sort((e,t)=>e-t)}set playbackRates(e){if(!e){this.removeAttribute(F.PLAYBACK_RATES);return}this.setAttribute(F.PLAYBACK_RATES,e.join(" "))}get forwardSeekOffset(){var e;return(e=pi(this.getAttribute(F.FORWARD_SEEK_OFFSET)))!=null?e:10}set forwardSeekOffset(e){this.setAttribute(F.FORWARD_SEEK_OFFSET,`${e}`)}get backwardSeekOffset(){var e;return(e=pi(this.getAttribute(F.BACKWARD_SEEK_OFFSET)))!=null?e:10}set backwardSeekOffset(e){this.setAttribute(F.BACKWARD_SEEK_OFFSET,`${e}`)}get defaultHiddenCaptions(){return this.hasAttribute(F.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(e){e?this.setAttribute(F.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute(F.DEFAULT_HIDDEN_CAPTIONS)}get defaultDuration(){return pi(this.getAttribute(F.DEFAULT_DURATION))}set defaultDuration(e){e==null?this.removeAttribute(F.DEFAULT_DURATION):this.setAttribute(F.DEFAULT_DURATION,`${e}`)}get playerSoftwareName(){var e;return(e=this.getAttribute(P.PLAYER_SOFTWARE_NAME))!=null?e:JC}get playerSoftwareVersion(){var e;return(e=this.getAttribute(P.PLAYER_SOFTWARE_VERSION))!=null?e:ZC}get beaconCollectionDomain(){var e;return(e=this.getAttribute(P.BEACON_COLLECTION_DOMAIN))!=null?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(P.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(P.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var e;return(e=this.getAttribute(P.MAX_RESOLUTION))!=null?e:void 0}set maxResolution(e){e!==this.maxResolution&&(e?this.setAttribute(P.MAX_RESOLUTION,e):this.removeAttribute(P.MAX_RESOLUTION))}get minResolution(){var e;return(e=this.getAttribute(P.MIN_RESOLUTION))!=null?e:void 0}set minResolution(e){e!==this.minResolution&&(e?this.setAttribute(P.MIN_RESOLUTION,e):this.removeAttribute(P.MIN_RESOLUTION))}get renditionOrder(){var e;return(e=this.getAttribute(P.RENDITION_ORDER))!=null?e:void 0}set renditionOrder(e){e!==this.renditionOrder&&(e?this.setAttribute(P.RENDITION_ORDER,e):this.removeAttribute(P.RENDITION_ORDER))}get programStartTime(){return pi(this.getAttribute(P.PROGRAM_START_TIME))}set programStartTime(e){e==null?this.removeAttribute(P.PROGRAM_START_TIME):this.setAttribute(P.PROGRAM_START_TIME,`${e}`)}get programEndTime(){return pi(this.getAttribute(P.PROGRAM_END_TIME))}set programEndTime(e){e==null?this.removeAttribute(P.PROGRAM_END_TIME):this.setAttribute(P.PROGRAM_END_TIME,`${e}`)}get extraSourceParams(){return this.hasAttribute(F.EXTRA_SOURCE_PARAMS)?[...new URLSearchParams(this.getAttribute(F.EXTRA_SOURCE_PARAMS)).entries()].reduce((e,[t,r])=>(e[t]=r,e),{}):eD}set extraSourceParams(e){e==null?this.removeAttribute(F.EXTRA_SOURCE_PARAMS):this.setAttribute(F.EXTRA_SOURCE_PARAMS,new URLSearchParams(e).toString())}get customDomain(){var e;return(e=this.getAttribute(P.CUSTOM_DOMAIN))!=null?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(P.CUSTOM_DOMAIN,e):this.removeAttribute(P.CUSTOM_DOMAIN))}get envKey(){var e;return(e=Sr(this,P.ENV_KEY))!=null?e:void 0}set envKey(e){this.setAttribute(P.ENV_KEY,`${e}`)}get noVolumePref(){return this.hasAttribute(F.NO_VOLUME_PREF)}set noVolumePref(e){e?this.setAttribute(F.NO_VOLUME_PREF,""):this.removeAttribute(F.NO_VOLUME_PREF)}get debug(){return Sr(this,P.DEBUG)!=null}set debug(e){e?this.setAttribute(P.DEBUG,""):this.removeAttribute(P.DEBUG)}get disableTracking(){return Sr(this,P.DISABLE_TRACKING)!=null}set disableTracking(e){this.toggleAttribute(P.DISABLE_TRACKING,!!e)}get disableCookies(){return Sr(this,P.DISABLE_COOKIES)!=null}set disableCookies(e){e?this.setAttribute(P.DISABLE_COOKIES,""):this.removeAttribute(P.DISABLE_COOKIES)}get streamType(){var e,t,r;return(r=(t=this.getAttribute(P.STREAM_TYPE))!=null?t:(e=this.media)==null?void 0:e.streamType)!=null?r:be.UNKNOWN}set streamType(e){this.setAttribute(P.STREAM_TYPE,`${e}`)}get defaultStreamType(){var e,t,r;return(r=(t=this.getAttribute(F.DEFAULT_STREAM_TYPE))!=null?t:(e=this.mediaController)==null?void 0:e.getAttribute(F.DEFAULT_STREAM_TYPE))!=null?r:be.ON_DEMAND}set defaultStreamType(e){e?this.setAttribute(F.DEFAULT_STREAM_TYPE,e):this.removeAttribute(F.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var e,t;return this.hasAttribute(F.TARGET_LIVE_WINDOW)?+this.getAttribute(F.TARGET_LIVE_WINDOW):(t=(e=this.media)==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN}set targetLiveWindow(e){e==this.targetLiveWindow||Number.isNaN(e)&&Number.isNaN(this.targetLiveWindow)||(e==null?this.removeAttribute(F.TARGET_LIVE_WINDOW):this.setAttribute(F.TARGET_LIVE_WINDOW,`${+e}`))}get liveEdgeStart(){var e;return(e=this.media)==null?void 0:e.liveEdgeStart}get startTime(){return pi(Sr(this,P.START_TIME))}set startTime(e){this.setAttribute(P.START_TIME,`${e}`)}get preferPlayback(){let e=this.getAttribute(P.PREFER_PLAYBACK);if(e===Ti.MSE||e===Ti.NATIVE)return e}set preferPlayback(e){e!==this.preferPlayback&&(e===Ti.MSE||e===Ti.NATIVE?this.setAttribute(P.PREFER_PLAYBACK,e):this.removeAttribute(P.PREFER_PLAYBACK))}get metadata(){var e;return(e=this.media)==null?void 0:e.metadata}set metadata(e){if(Ge(this,Ni,sr).call(this),!this.media){Ft("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...C0(this),...e}}get _hlsConfig(){var e;return(e=this.media)==null?void 0:e._hlsConfig}set _hlsConfig(e){if(Ge(this,Ni,sr).call(this),!this.media){Ft("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set.");return}this.media._hlsConfig=e}async addCuePoints(e){var t;if(Ge(this,Ni,sr).call(this),!this.media){Ft("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(t=this.media)==null?void 0:t.addCuePoints(e)}get activeCuePoint(){var e;return(e=this.media)==null?void 0:e.activeCuePoint}get cuePoints(){var e,t;return(t=(e=this.media)==null?void 0:e.cuePoints)!=null?t:[]}addChapters(e){var t;if(Ge(this,Ni,sr).call(this),!this.media){Ft("underlying media element missing when trying to addChapters. chapters will not be added.");return}return(t=this.media)==null?void 0:t.addChapters(e)}get activeChapter(){var e;return(e=this.media)==null?void 0:e.activeChapter}get chapters(){var e,t;return(t=(e=this.media)==null?void 0:e.chapters)!=null?t:[]}getStartDate(){var e;return(e=this.media)==null?void 0:e.getStartDate()}get currentPdt(){var e;return(e=this.media)==null?void 0:e.currentPdt}get tokens(){let e=this.getAttribute(F.PLAYBACK_TOKEN),t=this.getAttribute(F.DRM_TOKEN),r=this.getAttribute(F.THUMBNAIL_TOKEN),s=this.getAttribute(F.STORYBOARD_TOKEN);return{...ve(this,Gl),...e!=null?{playback:e}:{},...t!=null?{drm:t}:{},...r!=null?{thumbnail:r}:{},...s!=null?{storyboard:s}:{}}}set tokens(e){Hi(this,Gl,e??{})}get playbackToken(){var e;return(e=this.getAttribute(F.PLAYBACK_TOKEN))!=null?e:void 0}set playbackToken(e){this.setAttribute(F.PLAYBACK_TOKEN,`${e}`)}get drmToken(){var e;return(e=this.getAttribute(F.DRM_TOKEN))!=null?e:void 0}set drmToken(e){this.setAttribute(F.DRM_TOKEN,`${e}`)}get thumbnailToken(){var e;return(e=this.getAttribute(F.THUMBNAIL_TOKEN))!=null?e:void 0}set thumbnailToken(e){this.setAttribute(F.THUMBNAIL_TOKEN,`${e}`)}get storyboardToken(){var e;return(e=this.getAttribute(F.STORYBOARD_TOKEN))!=null?e:void 0}set storyboardToken(e){this.setAttribute(F.STORYBOARD_TOKEN,`${e}`)}addTextTrack(e,t,r,s){var n;let a=(n=this.media)==null?void 0:n.nativeEl;if(a)return df(a,e,t,r,s)}removeTextTrack(e){var t;let r=(t=this.media)==null?void 0:t.nativeEl;if(r)return Rk(r,e)}get textTracks(){var e;return(e=this.media)==null?void 0:e.textTracks}get castReceiver(){var e;return(e=this.getAttribute(F.CAST_RECEIVER))!=null?e:void 0}set castReceiver(e){e!==this.castReceiver&&(e?this.setAttribute(F.CAST_RECEIVER,e):this.removeAttribute(F.CAST_RECEIVER))}get castCustomData(){var e;return(e=this.media)==null?void 0:e.castCustomData}set castCustomData(e){if(!this.media){Ft("underlying media element missing when trying to set castCustomData. castCustomData will not be set.");return}this.media.castCustomData=e}get noTooltips(){return this.hasAttribute(F.NO_TOOLTIPS)}set noTooltips(e){if(!e){this.removeAttribute(F.NO_TOOLTIPS);return}this.setAttribute(F.NO_TOOLTIPS,"")}};Bl=new WeakMap,Gl=new WeakMap,Vr=new WeakMap,Hl=new WeakMap,fn=new WeakMap,Ni=new WeakSet,sr=function(){var i,e,t,r;if(!ve(this,Bl)){Hi(this,Bl,!0),Ge(this,lr,qr).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof lt.HTMLElement))throw""}catch{Ft("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof Tw))throw""}catch{Ft("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof uI))throw""}catch{Ft("<media-controller> failed to upgrade!")}this.init(),Ge(this,Dh,M0).call(this),Ge(this,Mh,P0).call(this),Ge(this,Ph,O0).call(this),Hi(this,Vr,(e=(i=this.mediaController)==null?void 0:i.hasAttribute(me.USER_INACTIVE))!=null?e:!0),Ge(this,Oh,N0).call(this),(t=this.media)==null||t.addEventListener("streamtypechange",()=>Ge(this,lr,qr).call(this)),(r=this.media)==null||r.addEventListener("loadstart",()=>Ge(this,lr,qr).call(this))}},wh=new WeakSet,Eb=function(){var i,e;try{(i=window==null?void 0:window.CSS)==null||i.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(e=window==null?void 0:window.CSS)==null||e.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},Id=new WeakSet,Ch=function(i){Object.assign(ve(this,fn),i),Ge(this,lr,qr).call(this)},lr=new WeakSet,qr=function(i={}){FC($C(qC(this,{...ve(this,fn),...i})),this.shadowRoot)},Dh=new WeakSet,M0=function(){let i=e=>{var t,r;if(!(e!=null&&e.startsWith("theme-")))return;let s=e.replace(/^theme-/,"");if(Rh.includes(s))return;let n=this.getAttribute(e);n!=null?(t=this.mediaTheme)==null||t.setAttribute(s,n):(r=this.mediaTheme)==null||r.removeAttribute(s)};new MutationObserver(e=>{for(let{attributeName:t}of e)i(t)}).observe(this,{attributes:!0}),this.getAttributeNames().forEach(i)},Mh=new WeakSet,P0=function(){var i;let e=t=>{let{detail:r}=t;if(r instanceof St||(r=new St(r.message,r.code,r.fatal)),!(r!=null&&r.fatal)){Bi(r),r.data&&Bi(`${r.name} data:`,r.data);return}let{dialog:s,devlog:n}=Lh(r,!window.navigator.onLine,this.playbackId,this.playbackToken);n.message&&db(n),Ft(r),r.data&&Ft(`${r.name} data:`,r.data),Ge(this,Id,Ch).call(this,{isDialogOpen:!0,dialog:s})};this.addEventListener("error",e),this.media&&(this.media.errorTranslator=(t={})=>{var r,s,n;if(!(((r=this.media)==null?void 0:r.error)instanceof St))return t;let{devlog:a}=Lh((s=this.media)==null?void 0:s.error,!window.navigator.onLine,this.playbackId,this.playbackToken,!1);return{player_error_code:(n=this.media)==null?void 0:n.error.code,player_error_message:a.message?String(a.message):t.player_error_message,player_error_context:a.context?String(a.context):t.player_error_context}}),(i=this.media)==null||i.addEventListener("error",t=>{var r,s;let{detail:n}=t;if(!n){let{message:a,code:o}=(s=(r=this.media)==null?void 0:r.error)!=null?s:{};n=new St(a,o)}n!=null&&n.fatal&&this.dispatchEvent(new CustomEvent("error",{detail:n}))})},Ph=new WeakSet,O0=function(){var i,e,t,r;let s=()=>Ge(this,lr,qr).call(this);(e=(i=this.media)==null?void 0:i.textTracks)==null||e.addEventListener("addtrack",s),(r=(t=this.media)==null?void 0:t.textTracks)==null||r.addEventListener("removetrack",s)},Oh=new WeakSet,N0=function(){var i,e;if(!/Firefox/i.test(navigator.userAgent))return;let t,r=new WeakMap,s=()=>this.streamType===be.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,n=(l,d,u=!1)=>{s()||Array.from(l&&l.activeCues||[]).forEach(c=>{if(!(!c.snapToLines||c.line<-5||c.line>=0&&c.line<10))if(!d||this.paused){let h=c.text.split(`
3052
+ `).length,f=-3;this.streamType===be.LIVE&&(f=-2);let m=f-h;if(c.line===m&&!u)return;r.has(c)||r.set(c,c.line),c.line=m}else setTimeout(()=>{c.line=r.get(c)||"auto"},500)})},a=()=>{var l,d;n(t,(d=(l=this.mediaController)==null?void 0:l.hasAttribute(me.USER_INACTIVE))!=null?d:!1)},o=()=>{var l,d;let u=Array.from(((d=(l=this.mediaController)==null?void 0:l.media)==null?void 0:d.textTracks)||[]).filter(c=>["subtitles","captions"].includes(c.kind)&&c.mode==="showing")[0];u!==t&&(t==null||t.removeEventListener("cuechange",a)),t=u,t==null||t.addEventListener("cuechange",a),n(t,ve(this,Vr))};o(),(i=this.textTracks)==null||i.addEventListener("change",o),(e=this.textTracks)==null||e.addEventListener("addtrack",o),this.addEventListener("userinactivechange",()=>{var l,d;let u=(d=(l=this.mediaController)==null?void 0:l.hasAttribute(me.USER_INACTIVE))!=null?d:!0;ve(this,Vr)!==u&&(Hi(this,Vr,u),n(t,ve(this,Vr)))})};function Sr(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}lt.customElements.get("mux-player")||(lt.customElements.define("mux-player",F0),lt.MuxPlayerElement=F0);var U0={className:"class",classname:"class",htmlFor:"for",crossOrigin:"crossorigin",viewBox:"viewBox",playsInline:"playsinline",autoPlay:"autoplay",playbackRate:"playbackrate"},tD=i=>i==null,iD=(i,e)=>tD(e)?!1:i in e,rD=i=>i.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),sD=(i,e)=>{if(!(typeof e=="boolean"&&!e)){if(iD(i,U0))return U0[i];if(typeof e!=null)return/[A-Z]/.test(i)?rD(i):i}},nD=(i,e)=>typeof i=="boolean"?"":i,aD=(i={})=>Object.entries(i).reduce((e,[t,r])=>{let s=sD(t,r);if(!s)return e;let n=nD(r);return e[s]=n,e},{}),oD=(...i)=>{let e=ft.useRef(null);return ft.useEffect(()=>{i.forEach(t=>{t&&(typeof t=="function"?t(e.current):t.current=e.current)})},[i]),e},lD=Object.prototype.hasOwnProperty,dD=(i,e)=>{if(Object.is(i,e))return!0;if(typeof i!="object"||i===null||typeof e!="object"||e===null)return!1;if(Array.isArray(i))return!Array.isArray(e)||i.length!==e.length?!1:i.some((s,n)=>e[n]===s);let t=Object.keys(i),r=Object.keys(e);if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(!lD.call(e,t[s])||!Object.is(i[t[s]],e[t[s]]))return!1;return!0},yb=(i,e,t)=>!dD(e,i[t]),uD=(i,e,t)=>{i[t]=e},cD=(i,e,t,r=uD,s=yb)=>ft.useEffect(()=>{let n=t==null?void 0:t.current;n&&s(n,e,i)&&r(n,e,i)},[t==null?void 0:t.current,e]),ii=cD,hD=()=>{try{return"3.0.0"}catch{}return"UNKNOWN"},fD=hD(),mD=()=>fD,pD=Wl.forwardRef(({children:i,...e},t)=>Wl.createElement("mux-player",aD({...e,ref:t}),i)),xe=(i,e,t)=>ft.useEffect(()=>{let r=e==null?void 0:e.current;if(!(!r||!t))return r.addEventListener(i,t),()=>{r.removeEventListener(i,t)}},[e==null?void 0:e.current,t]),gD=(i,e)=>{let{onAbort:t,onCanPlay:r,onCanPlayThrough:s,onEmptied:n,onLoadStart:a,onLoadedData:o,onLoadedMetadata:l,onProgress:d,onDurationChange:u,onVolumeChange:c,onRateChange:h,onResize:f,onWaiting:m,onPlay:p,onPlaying:g,onTimeUpdate:E,onPause:y,onSeeking:b,onSeeked:S,onStalled:_,onSuspend:x,onEnded:A,onError:C,onCuePointChange:O,onCuePointsChange:L,onChapterChange:M,metadata:K,tokens:U,paused:z,playbackId:V,playbackRates:q,currentTime:ae,themeProps:ne,extraSourceParams:G,castCustomData:$,_hlsConfig:te,...re}=e;return ii("playbackRates",q,i),ii("metadata",K,i),ii("extraSourceParams",G,i),ii("_hlsConfig",te,i),ii("themeProps",ne,i),ii("tokens",U,i),ii("playbackId",V,i),ii("castCustomData",$,i),ii("paused",z,i,(oe,pe)=>{pe!=null&&(pe?oe.pause():oe.play())},(oe,pe,Re)=>oe.hasAttribute("autoplay")&&!oe.hasPlayed?!1:yb(oe,pe,Re)),ii("currentTime",ae,i,(oe,pe)=>{pe!=null&&(oe.currentTime=pe)}),xe("abort",i,t),xe("canplay",i,r),xe("canplaythrough",i,s),xe("emptied",i,n),xe("loadstart",i,a),xe("loadeddata",i,o),xe("loadedmetadata",i,l),xe("progress",i,d),xe("durationchange",i,u),xe("volumechange",i,c),xe("ratechange",i,h),xe("resize",i,f),xe("waiting",i,m),xe("play",i,p),xe("playing",i,g),xe("timeupdate",i,E),xe("pause",i,y),xe("seeking",i,b),xe("seeked",i,S),xe("stalled",i,_),xe("suspend",i,x),xe("ended",i,A),xe("error",i,C),xe("cuepointchange",i,O),xe("cuepointschange",i,L),xe("chapterchange",i,M),[re]},vD=mD(),ED="mux-player-react",yD=Wl.forwardRef((i,e)=>{let t=ft.useRef(null),r=oD(t,e),[s]=gD(t,i);return Wl.createElement(pD,{ref:r,playerSoftwareName:ED,playerSoftwareVersion:vD,...s})}),bD=yD;const TD=Yd.object({time:Yd.number(),expiresAt:Yd.string()}).transform(i=>({time:Number(i.time),expiresAt:new Date(i.expiresAt)}));function _D(){var e;const i=Ob("root");return((e=i==null?void 0:i.preferences)==null?void 0:e.player)??null}const AD=["INPUT","SELECT","BUTTON","TEXTAREA","MUX-PLAYER","SUMMARY"],SD=["button","option","combobox","tab","tablist"];function $0(i){let e=i;for(;e;){if(!(e instanceof HTMLElement))return!1;if(AD.includes(e.tagName)||SD.includes(e.getAttribute("role")||"")||e.isContentEditable)return!0;e=e.parentElement}return!1}function B0(i){const e=ft.useRef(i);return ft.useEffect(()=>{e.current=i},[i]),e}function xD({muxPlayerRef:i,...e}){const t=_D(),r=Pb(),[s,n]=ft.useState(!1),a=`${e.playbackId}:currentTime`,[o,l]=ft.useState(0),d=B0(r),u=B0(t);ft.useEffect(()=>{if(typeof document>"u")return;const h=sessionStorage.getItem(a);if(h)try{const{time:f,expiresAt:m}=TD.parse(JSON.parse(h));if(m.getTime()<Date.now())throw new Error("Time expired");l(f)}catch{sessionStorage.removeItem(a)}},[a]),ft.useEffect(()=>{function h(f){if(!i.current)return;const m=document.activeElement;$0(m)||$0(f.target)||(f.key===" "&&(f.preventDefault(),i.current.paused?i.current.play():i.current.pause()),f.key==="ArrowRight"&&(f.preventDefault(),i.current.currentTime=i.current.currentTime+(i.current.forwardSeekOffset||10)),f.key==="ArrowLeft"&&(f.preventDefault(),i.current.currentTime=i.current.currentTime-(i.current.forwardSeekOffset||10)),f.key==="f"&&!f.metaKey&&!f.ctrlKey&&(f.preventDefault(),document.fullscreenElement?document.exitFullscreen():i.current.requestFullscreen()))}return window.document.addEventListener("keydown",h),()=>{window.document.removeEventListener("keydown",h)}},[i]);const c=Cb(()=>{const h=i.current;if(!h)return;const f=Array.from(h.textTracks??[]).find(p=>p.kind==="subtitles"),m={playbackRate:h.playbackRate,volumeRate:h.volume,subtitle:f?{id:f.id,mode:f.mode}:{id:null,mode:"disabled"}};Nh(m,u.current)||d.current.submit(m,{method:"POST",action:"/video-player",encType:"application/json"})},300);return ft.useEffect(()=>{var m,p;if(!s)return;const h=(m=i.current)==null?void 0:m.textTracks;if(!h)return;const f=(p=u.current)==null?void 0:p.subtitle;if(f!=null&&f.id){const g=h.getTrackById(f.id);g&&(g.mode=f.mode??"hidden")}return h.addEventListener("change",c),()=>{h.removeEventListener("change",c)}},[s,i,u,c]),H.jsx("div",{className:"flex aspect-video flex-col",children:H.jsx(bD,{ref:i,playbackRates:[.5,.75,1,1.25,1.5,1.75,2,2.5,3,3.5,4],volume:(t==null?void 0:t.volumeRate)??1,playbackRate:(t==null?void 0:t.playbackRate)??1,thumbnailTime:o,onRateChange:c,onVolumeChange:c,streamType:"on-demand",defaultHiddenCaptions:!0,currentTime:o,onTimeUpdate:()=>{var h;return sessionStorage.setItem(a,JSON.stringify({time:(h=i.current)==null?void 0:h.currentTime,expiresAt:new Date(Date.now()+1e3*60*30).toISOString()}))},accentColor:"#427cf0",targetLiveWindow:NaN,onLoadedMetadata:()=>n(!0),minResolution:kD(t==null?void 0:t.minResolution),maxResolution:LD(t==null?void 0:t.maxResolution),...e})})}function Nh(i,e){if(i===e)return!0;if(typeof i!=typeof e||typeof i!="object"||typeof e!="object"||i===null||e===null||Array.isArray(i)!==Array.isArray(e))return!1;if(Array.isArray(i)&&Array.isArray(e)){if(i.length!==e.length)return!1;for(let s=0;s<i.length;s++)if(!Nh(i[s],e[s]))return!1;return!0}const t=Object.keys(i),r=Object.keys(e);if(t.length!==r.length)return!1;for(const s of t)if(!Nh(i[s],e[s]))return!1;return!0}function kD(i){if(i)return i<=480?_s.noLessThan480p:i<=540?_s.noLessThan540p:i<=720?_s.noLessThan720p:i<=1080?_s.noLessThan1080p:i<=1440?_s.noLessThan1440p:_s.noLessThan2160p}function LD(i){if(i)return i<=720?lo.upTo720p:i<=1080?lo.upTo1080p:i<=1440?lo.upTo1440p:lo.upTo2160p}const bb=ft.createContext(null);function cM({children:i,epicVideoInfosPromise:e}){return H.jsx(bb.Provider,{value:e,children:i})}function Tb(i){let e=new URL("https://epicweb.dev");try{e=new URL(i)}catch(c){return console.error(c),"EpicWeb.dev Video"}const t=e.pathname.split("/").filter(Boolean),r=t.includes("solution");let s=t.pop();const n=["problem","solution","embed","exercise"],a=c=>c&&!n.includes(c);for(;!a(s);)s=t.pop();if(!s)return"EpicWeb.dev Video";const o=s.split("-"),l=["the","a","an","and","but","or","for","nor","on","at","to","from","by","of","in","with","as","npm","git","ssh","cli"],d=["OAuth","UI","UX","API","CSS","HTML","JS","TS","SVG","AI","CSRF","CORS","HTTP","HTTPS","URL","URI","DB","SQL","JSON","YAML","YML","useActionData","useAsyncError","useAsyncValue","useBeforeUnload","useFetcher","useFetchers","useFormAction","useHref","useLoaderData","useLocation","useMatches","useNavigate","useNavigation","useNavigationType","useOutlet","useOutletContext","useParams","useResolvedPath","useRevalidator","useRouteError","useRouteLoaderData","useSearchParams","useSubmit","useCallback","useContext","useDebugValue","useDeferredValue","useEffect","useId","useImperativeHandle","useInsertionEffect","useLayoutEffect","useMemo","useReducer","useRef","useState","useSyncExternalStore","useTransition","useForm","useFieldset","useFieldList","useEventSource","useHydrated","useAuthenticityToken","useShouldHydrate","useGlobalNavigationState","useLocales","useDelegatedAnchors","useDebounceFetcher","useFetcherType"],u=o.filter(Boolean).map((c,h)=>{var p;const f=c.toLowerCase(),m=d.find(g=>g.toLowerCase()===f);return m||(l.includes(f)&&h>0?f:((p=f[0])==null?void 0:p.toUpperCase())+f.slice(1))}).join(" ");return r?`${u} (🏁 solution)`:u}function ID({url:i,title:e="Video Embed",loadingContent:t=H.jsx(Fh,{children:H.jsxs("span",{children:['Loading "',e,'"']})})}){const[r,s]=ft.useState(!1);return H.jsxs("div",{className:"relative aspect-video w-full flex-shrink-0 shadow-lg dark:shadow-gray-800",children:[r?null:H.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:t}),H.jsx("iframe",{onLoad:()=>s(!0),onError:()=>s(!0),src:i,className:Db("absolute inset-0 flex h-full w-full transition-opacity duration-300",r?"opacity-100":"opacity-0"),title:e,sandbox:"allow-forms allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",allowFullScreen:!0})]})}function _b({url:i,title:e}){return H.jsxs("a",{href:i,target:"_blank",className:"flex items-center gap-1 text-base no-underline opacity-70 transition hover:underline hover:opacity-100",rel:"noreferrer",children:[H.jsx(Mb,{className:"flex-shrink-0",name:"Video",size:"lg"}),e," ",H.jsx("span",{"aria-hidden":!0,children:"↗︎"})]})}function hM({url:i,title:e=Tb(i)}){const{product:{host:t,displayName:r}}=Ub(),s=Fb(),n=ft.useContext(bb),a=H.jsx("div",{children:H.jsx(_b,{url:i,title:e})});return H.jsx("div",{children:H.jsx(ft.Suspense,{fallback:H.jsxs("div",{children:[H.jsx("div",{className:"flex aspect-video w-full items-center justify-center",children:H.jsx(Fh,{children:e})}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,H.jsx("div",{className:"h-[32px]"})]})]}),children:H.jsx(Nb,{errorElement:H.jsx("div",{children:"Sorry, failed loading videos. Check the terminal output?"}),resolve:n,children:o=>{const l=o==null?void 0:o[i],d=ENV.EPICSHOP_DEPLOYED?H.jsxs("div",{children:[H.jsx(za,{to:ENV.EPICSHOP_GITHUB_REPO,className:"underline",children:"Run locally"})," for transcripts"]}):H.jsxs("div",{children:[H.jsx(za,{to:"/login",className:"underline",children:s?"Upgrade":"Login"})," for transcripts"]});if(!l)return H.jsxs("div",{children:[H.jsx(Hn,{url:i,title:e}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,d]})]});const u=l;return u.status==="success"?H.jsx(RD,{url:i,title:e,muxPlaybackId:u.muxPlaybackId,transcript:u.transcript}):u.type==="region-restricted"?H.jsxs("div",{children:[H.jsxs("div",{className:"flex aspect-video min-h-full min-w-full flex-col items-center justify-start gap-2 overflow-y-scroll border-2 p-4 lg:justify-center lg:gap-4 lg:text-xl",children:[H.jsx("div",{className:"!text-foreground-danger",children:"Error: Region Restricted"}),H.jsxs("div",{children:["We've detected you're connecting from"," ",u.requestCountry," but your license has restricted access to ",u.restrictedCountry]}),H.jsxs("div",{children:["To continue watching uninterrupted, please"," ",H.jsxs("a",{href:`https://${t}/products`,className:"underline",children:["upgrade your ",r," license"]})," ","to a full Pro license."]})]}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,H.jsxs("div",{children:[H.jsx(za,{to:`https://${t}/products`,className:"underline",children:"Upgrade"})," for transcripts"]})]})]}):u.statusCode===401?H.jsxs("div",{children:[H.jsx(Hn,{url:i,title:e}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,d]})]}):u.statusCode===403?H.jsxs("div",{children:[H.jsx(Hn,{url:i,title:e}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,H.jsxs("div",{children:[H.jsx(za,{to:`https://${t}/products`,className:"underline",children:"Upgrade"})," for transcripts"]})]})]}):u.statusCode===404?H.jsxs("div",{children:[H.jsx(Hn,{url:i,title:e}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,H.jsx("div",{children:"Transcripts not found"})]})]}):(console.error(u),H.jsxs("div",{children:[H.jsx(Hn,{url:i,title:e}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,H.jsx("div",{className:"!text-foreground-danger",children:"Unknown error (check console)"})]})]}))}})})})}function RD({url:i,title:e=Tb(i),muxPlaybackId:t,transcript:r}){const s=ft.useRef(null),n=/(\d+:\d+)/g,a=[];let o,l=0;for(;o=n.exec(r);){const d=o[1];if(!n.lastIndex||!d)break;const u=o.index,c=n.lastIndex,h=r.slice(l+1,u-1);a.push(H.jsx("span",{children:h},u)),a.push(H.jsx("button",{className:"underline",onClick:f=>{s.current&&(s.current.currentTime=wD(d),s.current.play(),s.current.scrollIntoView({behavior:"smooth",inline:"center",block:"start"}),f.currentTarget.blur())},children:d},d)),l=c}return a.push(H.jsx("span",{children:r.slice(l+1,r.length)},r.length)),H.jsxs("div",{children:[H.jsx("div",{className:"shadow-lg dark:shadow-gray-800",children:H.jsx(xD,{playbackId:t,muxPlayerRef:s,title:e})}),H.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[H.jsx(_b,{url:i,title:e}),H.jsxs("details",{children:[H.jsx("summary",{children:"Transcript"}),H.jsx("div",{className:"whitespace-pre-line rounded-md bg-accent p-2 text-accent-foreground",children:a})]})]})]})}function wD(i){const e=i.split(":");let t=0,r=1;for(;e.length>0;)t+=r*parseInt(e.pop()??"0",10),r*=60;return t}function Hn({url:i,title:e}){const t=wb();let r=new URL("https://epicweb.dev");try{r=new URL(i)}catch(s){return console.error(s),H.jsxs("div",{children:['Invalid URL: "',i,'"']})}return r.pathname=r.pathname.endsWith("/")?`${r.pathname}embed`:`${r.pathname}/embed`,r.searchParams.set("theme",t),H.jsx(ID,{url:r.toString(),title:e,loadingContent:H.jsx(Fh,{children:H.jsxs("span",{children:['Loading "',H.jsx("a",{className:"underline",href:i,children:e}),'"']})})})}export{hM as D,cM as E,ID as V};
3053
+ //# sourceMappingURL=epic-video-qHKPWPt1.js.map