var W=Object.defineProperty;var B=(e,o,t)=>o in e?W(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t;var S=(e,o,t)=>(B(e,typeof o!="symbol"?o+"":o,t),t),M=(e,o,t)=>{if(!o.has(e))throw TypeError("Cannot "+t)};var E=(e,o,t)=>(M(e,o,"read from private field"),t?t.call(e):o.get(e)),k=(e,o,t)=>{if(o.has(e))throw TypeError("Cannot add the same private member more than once");o instanceof WeakSet?o.add(e):o.set(e,t)},w=(e,o,t,c)=>(M(e,o,"write to private field"),c?c.call(e,t):o.set(e,t),t);var I=(e,o,t)=>(M(e,o,"access private method"),t);import{c as F}from"./vendor-react-ece1c85f.js";import{M as $,C as j}from"./mixin-01ba42c5.js";import{H as v}from"./hls-5a4bded5.js";const z=e=>{var o,t,c,T,x,g,y,H;return o=class extends e{constructor(){super();k(this,T);k(this,y);k(this,t,null);k(this,c,null);k(this,g,()=>{var a,d,f;(a=this.nativeEl)!=null&&a.webkitCurrentPlaybackTargetIsWireless?(d=this.api)==null||d.stopLoad():(f=this.api)==null||f.startLoad()});I(this,y,H).call(this,"config")}get config(){return E(this,c)}set config(a){w(this,c,a)}attributeChangedCallback(a,d,f){a!=="src"&&super.attributeChangedCallback(a,d,f),a==="src"&&d!=f&&this.load()}async load(){var a,d;const f=!this.api;if(I(this,T,x).call(this),!!this.src){if(f&&!E(this,c)&&w(this,c,JSON.parse(((a=this.shadowRoot.getElementById("config"))==null?void 0:a.textContent)||"{}")),v.isSupported()){switch(await Promise.resolve(),this.api=new v({liveDurationInfinity:!0,autoStartLoad:!1,...this.config}),this.api.loadSource(this.src),this.api.attachMedia(this.nativeEl),this.nativeEl.preload){case"none":{const r=()=>this.api.startLoad();this.nativeEl.addEventListener("play",r,{once:!0}),this.api.on(v.Events.DESTROYING,()=>{this.nativeEl.removeEventListener("play",r)});break}case"metadata":{const r=this.api.config.maxBufferLength,l=this.api.config.maxBufferSize;this.api.config.maxBufferLength=1,this.api.config.maxBufferSize=1;const i=()=>{this.api.config.maxBufferLength=r,this.api.config.maxBufferSize=l};this.nativeEl.addEventListener("play",i,{once:!0}),this.api.on(v.Events.DESTROYING,()=>{this.nativeEl.removeEventListener("play",i)}),this.api.startLoad();break}default:this.api.startLoad()}this.nativeEl.webkitCurrentPlaybackTargetIsWireless&&this.api.stopLoad(),this.nativeEl.addEventListener("webkitcurrentplaybacktargetiswirelesschanged",E(this,g)),w(this,t,document.createElement("source")),E(this,t).setAttribute("type","application/x-mpegURL"),E(this,t).setAttribute("src",this.src),this.nativeEl.disableRemotePlayback=!1,this.nativeEl.append(E(this,t));const u=new WeakMap;this.api.on(v.Events.MANIFEST_PARSED,(r,l)=>{this.nativeEl.autoplay&&this.nativeEl.paused&&this.nativeEl.play().catch(n=>{console.warn("Autoplay failed:",n)}),L();let i=this.videoTracks.getTrackById("main");i||(i=this.addVideoTrack("main"),i.id="main",i.selected=!0);for(const[n,s]of l.levels.entries()){const h=i.addRendition(s.url[0],s.width,s.height,s.videoCodec,s.bitrate);u.set(s,`${n}`),h.id=`${n}`}for(let[n,s]of l.audioTracks.entries()){const h=s.default?"main":"alternative",p=this.addAudioTrack(h,s.name,s.lang);p.id=`${n}`,s.default&&(p.enabled=!0)}}),this.audioTracks.addEventListener("change",()=>{var r;const l=+((r=[...this.audioTracks].find(n=>n.enabled))==null?void 0:r.id),i=this.api.audioTracks.map(n=>n.id);l!=this.api.audioTrack&&i.includes(l)&&(this.api.audioTrack=l)}),this.api.on(v.Events.LEVELS_UPDATED,(r,l)=>{const i=this.videoTracks[this.videoTracks.selectedIndex??0];if(!i)return;const n=l.levels.map(s=>u.get(s));for(const s of this.videoRenditions)s.id&&!n.includes(s.id)&&i.removeRendition(s)});let m=null;this.api.on(v.Events.ERROR,(r,l)=>{l.type===v.ErrorTypes.NETWORK_ERROR&&l.details===v.ErrorDetails.FRAG_LOAD_ERROR&&(m=l.frag.level)}),this.api.on(v.Events.LEVEL_SWITCHED,(r,l)=>{const i=l.level;m!==null&&i<m&&(console.warn(`⚠️ hls.js downgraded quality from level ${m} to ${i} due to fragment load failure.`),this.videoRenditions.selectedIndex=i,m=null)});const b=r=>{const l=r.target.selectedIndex;l!=this.api.nextLevel&&(this.api.nextLevel=l)};(d=this.videoRenditions)==null||d.addEventListener("change",b);const L=()=>{for(const r of this.videoTracks)this.removeVideoTrack(r);for(const r of this.audioTracks)this.removeAudioTrack(r)};this.api.once(v.Events.DESTROYING,L);return}await Promise.resolve(),this.nativeEl.canPlayType("application/vnd.apple.mpegurl")&&(this.nativeEl.src=this.src)}}},t=new WeakMap,c=new WeakMap,T=new WeakSet,x=function(){var a,d;(a=E(this,t))==null||a.remove(),(d=this.nativeEl)==null||d.removeEventListener("webkitcurrentplaybacktargetiswirelesschanged",E(this,g)),this.api&&(this.api.detachMedia(),this.api.destroy(),this.api=null)},g=new WeakMap,y=new WeakSet,H=function(a){if(Object.prototype.hasOwnProperty.call(this,a)){const d=this[a];delete this[a],this[a]=d}},S(o,"shadowRootOptions",{...e.shadowRootOptions}),S(o,"getTemplateHTML",(a,d={})=>{const{src:f,...u}=a;return`
        <script type="application/json" id="config">
          ${JSON.stringify(d.config||{})}
        <\/script>
        ${e.getTemplateHTML(u)}
      `}),o},N=z($(j));globalThis.customElements&&!globalThis.customElements.get("hls-video")&&globalThis.customElements.define("hls-video",N);var G=N,V=new Set(["style","children","ref","key","suppressContentEditableWarning","suppressHydrationWarning","dangerouslySetInnerHTML"]),Y={className:"class",htmlFor:"for"};function C(e){return e.toLowerCase()}function P(e){if(typeof e=="boolean")return e?"":void 0;if(typeof e!="function"&&!(typeof e=="object"&&e!==null))return e}function J({react:e,tagName:o,elementClass:t,events:c,displayName:T,defaultProps:D,toAttributeName:g=C,toAttributeValue:y=P}){const O=Number.parseInt(e.version)>=19,R=e.forwardRef((_,a)=>{var d,f;const u=e.useRef(null),m=e.useRef(new Map),b={},L={},r={},l={};for(const[i,n]of Object.entries(_)){if(V.has(i)){r[i]=n;continue}const s=g(Y[i]??i);if(t.prototype&&i in t.prototype&&!(i in(((d=globalThis.HTMLElement)==null?void 0:d.prototype)??{}))&&!((f=t.observedAttributes)!=null&&f.some(p=>p===s))){l[i]=n;continue}if(i.startsWith("on")){b[i]=n;continue}const h=y(n);if(s&&h!=null&&(L[s]=String(h),O||(r[s]=h)),s&&O){const p=P(n);h!==p?r[s]=h:r[s]=n}}if(typeof window<"u"){for(const i in b){const n=b[i],s=i.endsWith("Capture"),h=((c==null?void 0:c[i])??i.slice(2).toLowerCase()).slice(0,s?-7:void 0);e.useLayoutEffect(()=>{const p=u==null?void 0:u.current;if(!(!p||typeof n!="function"))return p.addEventListener(h,n,s),()=>{p.removeEventListener(h,n,s)}},[u==null?void 0:u.current,n])}e.useLayoutEffect(()=>{if(u.current===null)return;const i=new Map;for(const n in l)A(u.current,n,l[n]),m.current.delete(n),i.set(n,l[n]);for(const[n,s]of m.current)A(u.current,n,void 0);m.current=i})}if(typeof window>"u"&&(t!=null&&t.getTemplateHTML)&&(t!=null&&t.shadowRootOptions)){const{mode:i,delegatesFocus:n}=t.shadowRootOptions,s=e.createElement("template",{shadowrootmode:i,shadowrootdelegatesfocus:n,dangerouslySetInnerHTML:{__html:t.getTemplateHTML(L,_)},key:"ce-la-react-ssr-template-shadow-root"});r.children=[s,r.children]}return e.createElement(o,{...D,...r,ref:e.useCallback(i=>{u.current=i,typeof a=="function"?a(i):a!==null&&(a.current=i)},[a])},r.children)});return R.displayName=T??t.name,R}function A(e,o,t){var c;e[o]=t,t==null&&o in(((c=globalThis.HTMLElement)==null?void 0:c.prototype)??{})&&e.removeAttribute(o)}var Z=J({react:F,tagName:"hls-video",elementClass:G,toAttributeName(e){return e==="muted"?"":e==="defaultMuted"?"muted":C(e)}});/*! Bundled license information:

ce-la-react/dist/ce-la-react.js:
  (**
   * @license
   * Copyright 2018 Google LLC
   * SPDX-License-Identifier: BSD-3-Clause
   *
   * Modified version of `@lit/react` for vanilla custom elements with support for SSR.
   *)
*/export{Z as default};
