var rt=Object.defineProperty;var at=(e,i,t)=>i in e?rt(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t;var O=(e,i,t)=>(at(e,typeof i!="symbol"?i+"":i,t),t),q=(e,i,t)=>{if(!i.has(e))throw TypeError("Cannot "+t)};var s=(e,i,t)=>(q(e,i,"read from private field"),t?t.call(e):i.get(e)),c=(e,i,t)=>{if(i.has(e))throw TypeError("Cannot add the same private member more than once");i instanceof WeakSet?i.add(e):i.set(e,t)},l=(e,i,t,n)=>(q(e,i,"write to private field"),n?n.call(e,t):i.set(e,t),t);var T=(e,i,t)=>(q(e,i,"access private method"),t);import{c as lt}from"./vendor-react-ece1c85f.js";const K="https://player.twitch.tv",ut=/(?:www\.|go\.)?twitch\.tv\/(?:videos?\/|\?video=)(\d+)($|\?)/,ct=/(?:www\.|go\.)?twitch\.tv\/([a-zA-Z0-9_]+)($|\?)/,V={IDLE:"Idle",READY:"Ready",BUFFERING:"Buffering",PLAYING:"Playing",ENDED:"Ended"},R={DISABLE_CAPTIONS:0,ENABLE_CAPTIONS:1,PAUSE:2,PLAY:3,SEEK:4,SET_CHANNEL:5,SET_CHANNEL_ID:6,SET_COLLECTION:7,SET_QUALITY:8,SET_VIDEO:9,SET_MUTED:10,SET_VOLUME:11};function Z(e,i={}){const t={src:nt(e,i),frameborder:"0",width:"100%",height:"100%",allow:"accelerometer; fullscreen; autoplay; encrypted-media; picture-in-picture;",sandbox:"allow-modals allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",scrolling:"no"};return i.config&&(t["data-config"]=JSON.stringify(i.config)),`
    <style>
      :host {
        display: inline-block;
        min-width: 300px;
        min-height: 150px;
        position: relative;
      }
      iframe {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
      }
      :host(:not([controls])) {
        pointer-events: none;
      }
    </style>
    <iframe${dt(t)}></iframe>
  `}function nt(e,i){var t;if(!e.src)return;const n=e.src.match(ut),u=e.src.match(ct),d={parent:(t=globalThis.location)==null?void 0:t.hostname,controls:e.controls===""?null:!1,autoplay:e.autoplay===""?null:!1,muted:e.muted,preload:e.preload,...i.config};if(n){const p=n[1];return`${K}/?video=v${p}&${X(d)}`}else if(u){const p=u[1];return`${K}/?channel=${p}&${X(d)}`}return""}var N,M,E,o,D,P,k,C,A,S,I,$,y,L,j,st;class H extends(globalThis.HTMLElement??class{}){constructor(){super();c(this,y);c(this,j);O(this,"loadComplete",new tt);c(this,N,void 0);c(this,M,void 0);c(this,E,void 0);c(this,o,{});c(this,D,0);c(this,P,!1);c(this,k,1);c(this,C,!this.autoplay);c(this,A,!1);c(this,S,0);c(this,I,null);c(this,$,async t=>{var n,u,d,p;if(!s(this,E).contentWindow)return;const{data:f,source:B}=t;if(B===s(this,E).contentWindow){if(f.namespace==="twitch-embed")await new Promise(_=>setTimeout(_,10)),f.eventName==="ready"?(this.dispatchEvent(new Event("loadcomplete")),this.loadComplete.resolve(),l(this,S,1),this.dispatchEvent(new Event("loadedmetadata"))):f.eventName==="seek"?(l(this,A,!0),this.dispatchEvent(new Event("seeking"))):f.eventName==="playing"?(s(this,A)&&(l(this,A,!1),this.dispatchEvent(new Event("seeked"))),l(this,S,3),this.dispatchEvent(new Event("playing"))):this.dispatchEvent(new Event(f.eventName));else if(f.namespace==="twitch-embed-player-proxy"&&f.eventName==="UPDATE_STATE"){const _=s(this,o).duration,w=s(this,o).currentTime,U=s(this,o).volume,W=s(this,o).muted,m=(u=(n=s(this,o).stats)==null?void 0:n.videoStats)==null?void 0:u.bufferSize;l(this,o,{...s(this,o),...f.params}),_!==s(this,o).duration&&this.dispatchEvent(new Event("durationchange")),w!==s(this,o).currentTime&&this.dispatchEvent(new Event("timeupdate")),(U!==s(this,o).volume||W!==s(this,o).muted)&&(s(this,o).volume!==void 0&&l(this,k,s(this,o).volume),s(this,o).muted!==void 0&&l(this,P,s(this,o).muted),this.dispatchEvent(new Event("volumechange"))),m!==((p=(d=s(this,o).stats)==null?void 0:d.videoStats)==null?void 0:p.bufferSize)&&this.dispatchEvent(new Event("progress"))}}});T(this,j,st).call(this,"config")}get config(){return s(this,I)}set config(t){l(this,I,t)}async load(){if(s(this,N))return;this.shadowRoot||this.attachShadow({mode:"open"});const t=!s(this,M);if(s(this,M)&&(this.loadComplete=new tt),l(this,M,!0),await l(this,N,Promise.resolve()),l(this,N,null),l(this,S,0),this.dispatchEvent(new Event("emptied")),!this.src){this.shadowRoot.innerHTML="",globalThis.removeEventListener("message",s(this,$));return}this.dispatchEvent(new Event("loadstart"));let n=this.shadowRoot.querySelector("iframe");const u=ht(this.attributes);t&&n&&l(this,I,JSON.parse(n.getAttribute("data-config")||"{}")),(!(n!=null&&n.src)||n.src!==nt(u,this))&&(this.shadowRoot.innerHTML=Z(u,this),n=this.shadowRoot.querySelector("iframe")),l(this,E,n),globalThis.addEventListener("message",s(this,$))}attributeChangedCallback(t,n,u){if(n!==u)switch(t){case"src":case"controls":{this.load();break}}}getVideoPlaybackQuality(){return s(this,o).stats.videoStats}get src(){return this.getAttribute("src")}set src(t){this.setAttribute("src",t)}get readyState(){return s(this,S)}get seeking(){return s(this,A)}get buffered(){var t,n;return mt(0,((n=(t=s(this,o).stats)==null?void 0:t.videoStats)==null?void 0:n.bufferSize)??0)}get paused(){return s(this,o).playback?s(this,o).playback===V.IDLE:s(this,C)}get ended(){return s(this,o).playback?s(this,o).playback===V.ENDED:!1}get duration(){return s(this,o).duration??NaN}get autoplay(){return this.hasAttribute("autoplay")}set autoplay(t){this.autoplay!=t&&this.toggleAttribute("autoplay",!!t)}get controls(){return this.hasAttribute("controls")}set controls(t){this.controls!=t&&this.toggleAttribute("controls",!!t)}get currentTime(){return s(this,o).currentTime?s(this,o).currentTime:s(this,D)}set currentTime(t){l(this,D,t),this.loadComplete.then(()=>{T(this,y,L).call(this,R.SEEK,t)})}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(t){this.toggleAttribute("muted",!!t)}get loop(){return this.hasAttribute("loop")}set loop(t){this.toggleAttribute("loop",!!t)}get muted(){return s(this,P)}set muted(t){l(this,P,t),this.loadComplete.then(()=>{T(this,y,L).call(this,R.SET_MUTED,t)})}get volume(){return s(this,k)}set volume(t){l(this,k,t),this.loadComplete.then(()=>{T(this,y,L).call(this,R.SET_VOLUME,t)})}get playsInline(){return this.hasAttribute("playsinline")}set playsInline(t){this.toggleAttribute("playsinline",!!t)}play(){l(this,C,!1),T(this,y,L).call(this,R.PLAY)}pause(){l(this,C,!0),T(this,y,L).call(this,R.PAUSE)}}N=new WeakMap,M=new WeakMap,E=new WeakMap,o=new WeakMap,D=new WeakMap,P=new WeakMap,k=new WeakMap,C=new WeakMap,A=new WeakMap,S=new WeakMap,I=new WeakMap,$=new WeakMap,y=new WeakSet,L=function(t,n){if(!s(this,E).contentWindow)return;const u={eventName:t,params:n,namespace:"twitch-embed-player-proxy"};s(this,E).contentWindow.postMessage(u,K)},j=new WeakSet,st=function(t){if(Object.prototype.hasOwnProperty.call(this,t)){const n=this[t];delete this[t],this[t]=n}},O(H,"getTemplateHTML",Z),O(H,"shadowRootOptions",{mode:"open"}),O(H,"observedAttributes",["autoplay","controls","loop","muted","playsinline","preload","src"]);function ht(e){let i={};for(let t of e)i[t.name]=t.value;return i}function dt(e){let i="";for(const t in e){const n=e[t];n===""?i+=` ${G(t)}`:i+=` ${G(t)}="${G(`${n}`)}"`}return i}function G(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/`/g,"&#x60;")}function X(e){return String(new URLSearchParams(ft(e)))}function ft(e){let i={};for(let t in e){let n=e[t];n===!0||n===""?i[t]=!0:n===!1?i[t]=!1:n!=null&&(i[t]=n)}return i}class tt extends Promise{constructor(i=()=>{}){let t,n;super((u,d)=>{i(u,d),t=u,n=d}),this.resolve=t,this.reject=n}}function mt(e,i){return Array.isArray(e)?J(e):e==null||i==null||e===0&&i===0?J([[0,0]]):J([[e,i]])}function J(e){return Object.defineProperties(e,{start:{value:i=>e[i][0]},end:{value:i=>e[i][1]}}),e}globalThis.customElements&&!globalThis.customElements.get("twitch-video")&&globalThis.customElements.define("twitch-video",H);var pt=H,vt=new Set(["style","children","ref","key","suppressContentEditableWarning","suppressHydrationWarning","dangerouslySetInnerHTML"]),gt={className:"class",htmlFor:"for"};function ot(e){return e.toLowerCase()}function et(e){if(typeof e=="boolean")return e?"":void 0;if(typeof e!="function"&&!(typeof e=="object"&&e!==null))return e}function Et({react:e,tagName:i,elementClass:t,events:n,displayName:u,defaultProps:d,toAttributeName:p=ot,toAttributeValue:f=et}){const B=Number.parseInt(e.version)>=19,F=e.forwardRef((_,w)=>{var U,W;const m=e.useRef(null),z=e.useRef(new Map),Y={},Q={},v={},x={};for(const[r,a]of Object.entries(_)){if(vt.has(r)){v[r]=a;continue}const h=p(gt[r]??r);if(t.prototype&&r in t.prototype&&!(r in(((U=globalThis.HTMLElement)==null?void 0:U.prototype)??{}))&&!((W=t.observedAttributes)!=null&&W.some(b=>b===h))){x[r]=a;continue}if(r.startsWith("on")){Y[r]=a;continue}const g=f(a);if(h&&g!=null&&(Q[h]=String(g),B||(v[h]=g)),h&&B){const b=et(a);g!==b?v[h]=g:v[h]=a}}if(typeof window<"u"){for(const r in Y){const a=Y[r],h=r.endsWith("Capture"),g=((n==null?void 0:n[r])??r.slice(2).toLowerCase()).slice(0,h?-7:void 0);e.useLayoutEffect(()=>{const b=m==null?void 0:m.current;if(!(!b||typeof a!="function"))return b.addEventListener(g,a,h),()=>{b.removeEventListener(g,a,h)}},[m==null?void 0:m.current,a])}e.useLayoutEffect(()=>{if(m.current===null)return;const r=new Map;for(const a in x)it(m.current,a,x[a]),z.current.delete(a),r.set(a,x[a]);for(const[a,h]of z.current)it(m.current,a,void 0);z.current=r})}if(typeof window>"u"&&(t!=null&&t.getTemplateHTML)&&(t!=null&&t.shadowRootOptions)){const{mode:r,delegatesFocus:a}=t.shadowRootOptions,h=e.createElement("template",{shadowrootmode:r,shadowrootdelegatesfocus:a,dangerouslySetInnerHTML:{__html:t.getTemplateHTML(Q,_)},key:"ce-la-react-ssr-template-shadow-root"});v.children=[h,v.children]}return e.createElement(i,{...d,...v,ref:e.useCallback(r=>{m.current=r,typeof w=="function"?w(r):w!==null&&(w.current=r)},[w])},v.children)});return F.displayName=u??t.name,F}function it(e,i,t){var n;e[i]=t,t==null&&i in(((n=globalThis.HTMLElement)==null?void 0:n.prototype)??{})&&e.removeAttribute(i)}var bt=Et({react:lt,tagName:"twitch-video",elementClass:pt,toAttributeName(e){return e==="muted"?"":e==="defaultMuted"?"muted":ot(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{bt as default};
