1import{R as W}from"./index-BqKviU6K.js";const L="https://player.twitch.tv",x=/(?:www\.|go\.)?twitch\.tv\/(?:videos?\/|\?video=)(\d+)($|\?)/,U=/(?:www\.|go\.)?twitch\.tv\/([a-zA-Z0-9_]+)($|\?)/,N={IDLE:"Idle",ENDED:"Ended"},v={PAUSE:2,PLAY:3,SEEK:4,SET_MUTED:10,SET_VOLUME:11};function k(e,t={}){const i={src:D(e,t),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 t.config&&(i["data-config"]=JSON.stringify(t.config)),` 2 <style> 3 :host { 4 display: inline-block; 5 min-width: 300px; 6 min-height: 150px; 7 position: relative; 8 } 9 iframe { 10 position: absolute; 11 top: 0; 12 left: 0; 13 width: 100%; 14 height: 100%; 15 } 16 :host(:not([controls])) { 17 pointer-events: none; 18 } 19 </style> 20 <iframe${B(i)}></iframe> 21 `}function D(e,t){var i;if(!e.src)return;const s=e.src.match(x),l=e.src.match(U),u={parent:(i=globalThis.location)==null?void 0:i.hostname,controls:e.controls===""?null:!1,autoplay:e.autoplay===""?null:!1,muted:e.muted,preload:e.preload,...t.config};if(s){const r=s[1];return`${L}/?video=v${r}&${R(u)}`}else if(l){const r=l[1];return`${L}/?channel=${r}&${R(u)}`}return""}class $ extends(globalThis.HTMLElement??class{}){static getTemplateHTML=k;static shadowRootOptions={mode:"open"};static observedAttributes=["autoplay","controls","loop","muted","playsinline","preload","src"];loadComplete=new H;#o;#r;#e;#t={};#h=0;#a=!1;#l=1;#u=!this.autoplay;#s=!1;#n=0;#c=null;constructor(){super(),this.#f("config")}get config(){return this.#c}set config(t){this.#c=t}async load(){if(this.#o)return;this.shadowRoot||this.attachShadow({mode:"open"});const t=!this.#r;if(this.#r&&(this.loadComplete=new H),this.#r=!0,await(this.#o=Promise.resolve()),this.#o=null,this.#n=0,this.dispatchEvent(new Event("emptied")),!this.src){this.shadowRoot.innerHTML="",globalThis.removeEventListener("message",this.#d);return}this.dispatchEvent(new Event("loadstart"));let i=this.shadowRoot.querySelector("iframe");const s=j(this.attributes);t&&i&&(this.#c=JSON.parse(i.getAttribute("data-config")||"{}")),(!i?.src||i.src!==D(s,this))&&(this.shadowRoot.innerHTML=k(s,this),i=this.shadowRoot.querySelector("iframe")),this.#e=i,globalThis.addEventListener("message",this.#d)}attributeChangedCallback(t,i,s){if(i!==s)switch(t){case"src":case"controls":{this.load();break}}}getVideoPlaybackQuality(){return this.#t.stats.videoStats}get src(){return this.getAttribute("src")}set src(t){this.setAttribute("src",t)}get readyState(){return this.#n}get seeking(){return this.#s}get buffered(){var t,i;return F(0,((i=(t=this.#t.stats)==null?void 0:t.videoStats)==null?void 0:i.bufferSize)??0)}get paused(){return this.#t.playback?this.#t.playback===N.IDLE:this.#u}get ended(){return this.#t.playback?this.#t.playback===N.ENDED:!1}get duration(){return this.#t.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 this.#t.currentTime?this.#t.currentTime:this.#h}set currentTime(t){this.#h=t,this.loadComplete.then(()=>{this.#i(v.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 this.#a}set muted(t){this.#a=t,this.loadComplete.then(()=>{this.#i(v.SET_MUTED,t)})}get volume(){return this.#l}set volume(t){this.#l=t,this.loadComplete.then(()=>{this.#i(v.SET_VOLUME,t)})}get playsInline(){return this.hasAttribute("playsinline")}set playsInline(t){this.toggleAttribute("playsinline",!!t)}play(){this.#u=!1,this.#i(v.PLAY)}pause(){this.#u=!0,this.#i(v.PAUSE)}#d=async t=>{var i,s,l,u;if(!this.#e.contentWindow)return;const{data:r,source:b}=t;if(b===this.#e.contentWindow){if(r.namespace==="twitch-embed")await new Promise(p=>setTimeout(p,10)),r.eventName==="ready"?(this.dispatchEvent(new Event("loadcomplete")),this.loadComplete.resolve(),this.#n=1,this.dispatchEvent(new Event("loadedmetadata"))):r.eventName==="seek"?(this.#s=!0,this.dispatchEvent(new Event("seeking"))):r.eventName==="playing"?(this.#s&&(this.#s=!1,this.dispatchEvent(new Event("seeked"))),this.#n=3,this.dispatchEvent(new Event("playing"))):this.dispatchEvent(new Event(r.eventName));else if(r.namespace==="twitch-embed-player-proxy"&&r.eventName==="UPDATE_STATE"){const p=this.#t.duration,g=this.#t.currentTime,f=this.#t.volume,w=this.#t.muted,E=(s=(i=this.#t.stats)==null?void 0:i.videoStats)==null?void 0:s.bufferSize;this.#t={...this.#t,...r.params},p!==this.#t.duration&&this.dispatchEvent(new Event("durationchange")),g!==this.#t.currentTime&&this.dispatchEvent(new Event("timeupdate")),(f!==this.#t.volume||w!==this.#t.muted)&&(this.#t.volume!==void 0&&(this.#l=this.#t.volume),this.#t.muted!==void 0&&(this.#a=this.#t.muted),this.dispatchEvent(new Event("volumechange"))),E!==((u=(l=this.#t.stats)==null?void 0:l.videoStats)==null?void 0:u.bufferSize)&&this.dispatchEvent(new Event("progress"))}}};#i(t,i){if(!this.#e.contentWindow)return;const s={eventName:t,params:i,namespace:"twitch-embed-player-proxy"};this.#e.contentWindow.postMessage(s,L)}#f(t){if(Object.prototype.hasOwnProperty.call(this,t)){const i=this[t];delete this[t],this[t]=i}}}function j(e){let t={};for(let i of e)t[i.name]=i.value;return t}function B(e){let t="";for(const i in e){const s=e[i];s===""?t+=` ${M(i)}`:t+=` ${M(i)}="${M(`${s}`)}"`}return t}function M(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/`/g,"`")}function R(e){return String(new URLSearchParams(z(e)))}function z(e){let t={};for(let i in e){let s=e[i];s===!0||s===""?t[i]=!0:s===!1?t[i]=!1:s!=null&&(t[i]=s)}return t}class H extends Promise{constructor(t=()=>{}){let i,s;super((l,u)=>{t(l,u),i=l,s=u}),this.resolve=i,this.reject=s}}function F(e,t){return Array.isArray(e)?_(e):t==null||t===0?_([[0,0]]):_([[e,t]])}function _(e){return Object.defineProperties(e,{start:{value:t=>e[t][0]},end:{value:t=>e[t][1]}}),e}globalThis.customElements&&!globalThis.customElements.get("twitch-video")&&globalThis.customElements.define("twitch-video",$);var q=$,V=new Set(["style","children","ref","key","suppressContentEditableWarning","suppressHydrationWarning","dangerouslySetInnerHTML"]),J={className:"class",htmlFor:"for"};function I(e){return e.toLowerCase()}function C(e){if(typeof e=="boolean")return e?"":void 0;if(typeof e!="function"&&!(typeof e=="object"&&e!==null))return e}function K({react:e,tagName:t,elementClass:i,events:s,displayName:l,defaultProps:u,toAttributeName:r=I,toAttributeValue:b=C}){const T=Number.parseInt(e.version)>=19,p=e.forwardRef((g,f)=>{var w,E;const c=e.useRef(null),A=e.useRef(new Map),S={},P={},h={},y={};for(const[n,o]of Object.entries(g)){if(V.has(n)){h[n]=o;continue}const a=r(J[n]??n);if(i.prototype&&n in i.prototype&&!(n in(((w=globalThis.HTMLElement)==null?void 0:w.prototype)??{}))&&!((E=i.observedAttributes)!=null&&E.some(m=>m===a))){y[n]=o;continue}if(n.startsWith("on")){S[n]=o;continue}const d=b(o);if(a&&d!=null&&(P[a]=String(d),T||(h[a]=d)),a&&T){const m=C(o);d!==m?h[a]=d:h[a]=o}}if(typeof window<"u"){for(const n in S){const o=S[n],a=n.endsWith("Capture"),d=(s?.[n]??n.slice(2).toLowerCase()).slice(0,a?-7:void 0);e.useLayoutEffect(()=>{const m=c?.current;if(!(!m||typeof o!="function"))return m.addEventListener(d,o,a),()=>{m.removeEventListener(d,o,a)}},[c?.current,o])}e.useLayoutEffect(()=>{if(c.current===null)return;const n=new Map;for(const o in y)O(c.current,o,y[o]),A.current.delete(o),n.set(o,y[o]);for(const[o,a]of A.current)O(c.current,o,void 0);A.current=n})}if(typeof window>"u"&&i?.getTemplateHTML&&i?.shadowRootOptions){const{mode:n,delegatesFocus:o}=i.shadowRootOptions,a=e.createElement("template",{shadowrootmode:n,shadowrootdelegatesfocus:o,dangerouslySetInnerHTML:{__html:i.getTemplateHTML(P,g)},key:"ce-la-react-ssr-template-shadow-root"});h.children=[a,h.children]}return e.createElement(t,{...u,...h,ref:e.useCallback(n=>{c.current=n,typeof f=="function"?f(n):f!==null&&(f.current=n)},[f])},h.children)});return p.displayName=l??i.name,p}function O(e,t,i){var s;e[t]=i,i==null&&t in(((s=globalThis.HTMLElement)==null?void 0:s.prototype)??{})&&e.removeAttribute(t)}var Q=K({react:W,tagName:"twitch-video",elementClass:q,toAttributeName(e){return e==="muted"?"":e==="defaultMuted"?"muted":I(e)}});export{Q as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.