PageSourceSearch

https://earthly.org/_next/static/chunks/reactPlayerTwitch.c13d0ea706903a44.js

js earthly.org collected 2026-09-25 21:12:15 UTC 8,652 bytes, 21 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2042],{95625:(e,t,i)=>{i.r(t),i.d(t,{default:()=>b});var n=i(12115);let s="https://player.twitch.tv",a=/(?:www\.|go\.)?twitch\.tv\/(?:videos?\/|\?video=)(\d+)($|\?)/,r=/(?:www\.|go\.)?twitch\.tv\/([a-zA-Z0-9_]+)($|\?)/,o={IDLE:"Idle",ENDED:"Ended"},l={PAUSE:2,PLAY:3,SEEK:4,SET_MUTED:10,SET_VOLUME:11};function u(e,t={}){let 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${function(e){let t="";for(let i in e){let n=e[i];""===n?t+=` ${c(i)}`:t+=` ${c(i)}="${c(`${n}`)}"`}return t}(i)}></iframe>
21  `}function d(e,t){var i;if(!e.src)return;let n=e.src.match(a),o=e.src.match(r),l={parent:null==(i=globalThis.location)?void 0:i.hostname,controls:""===e.controls&&null,autoplay:""===e.autoplay&&null,muted:e.muted,preload:e.preload,...t.config};if(n){let e=n[1];return`${s}/?video=v${e}&${p(l)}`}if(o){let e=o[1];return`${s}/?channel=${e}&${p(l)}`}return""}class h extends(globalThis.HTMLElement??class{}){static getTemplateHTML=u;static shadowRootOptions={mode:"open"};static observedAttributes=["autoplay","controls","loop","muted","playsinline","preload","src"];loadComplete=new m;#e;#t;#i;#n={};#s=0;#a=!1;#r=1;#o=!this.autoplay;#l=!1;#u=0;#d=null;constructor(){super(),this.#h("config")}get config(){return this.#d}set config(e){this.#d=e}async load(){if(this.#e)return;this.shadowRoot||this.attachShadow({mode:"open"});let e=!this.#t;if(this.#t&&(this.loadComplete=new m),this.#t=!0,await (this.#e=Promise.resolve()),this.#e=null,this.#u=0,this.dispatchEvent(new Event("emptied")),!this.src){this.shadowRoot.innerHTML="",globalThis.removeEventListener("message",this.#c);return}this.dispatchEvent(new Event("loadstart"));let t=this.shadowRoot.querySelector("iframe"),i=function(e){let t={};for(let i of e)t[i.name]=i.value;return t}(this.attributes);e&&t&&(this.#d=JSON.parse(t.getAttribute("data-config")||"{}")),(null==t?void 0:t.src)&&t.src===d(i,this)||(this.shadowRoot.innerHTML=u(i,this),t=this.shadowRoot.querySelector("iframe")),this.#i=t,globalThis.addEventListener("message",this.#c)}attributeChangedCallback(e,t,i){if(t!==i)switch(e){case"src":case"controls":this.load()}}get src(){return this.getAttribute("src")}set src(e){this.setAttribute("src",e)}get readyState(){return this.#u}get seeking(){return this.#l}get buffered(){var e,t,i,n;return i=0,n=(null==(t=null==(e=this.#n.stats)?void 0:e.videoStats)?void 0:t.bufferSize)??0,Array.isArray(0)?f(i):null==i||null==n||0===i&&0===n?f([[0,0]]):f([[i,n]])}get paused(){return this.#n.playback?this.#n.playback===o.IDLE:this.#o}get ended(){return!!this.#n.playback&&this.#n.playback===o.ENDED}get duration(){return this.#n.duration??NaN}get autoplay(){return this.hasAttribute("autoplay")}set autoplay(e){this.autoplay!=e&&this.toggleAttribute("autoplay",!!e)}get controls(){return this.hasAttribute("controls")}set controls(e){this.controls!=e&&this.toggleAttribute("controls",!!e)}get currentTime(){return this.#n.currentTime?this.#n.currentTime:this.#s}set currentTime(e){this.#s=e,this.loadComplete.then(()=>{this.#p(l.SEEK,e)})}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(e){this.toggleAttribute("muted",!!e)}get loop(){return this.hasAttribute("loop")}set loop(e){this.toggleAttribute("loop",!!e)}get muted(){return this.#a}set muted(e){this.#a=e,this.loadComplete.then(()=>{this.#p(l.SET_MUTED,e)})}get volume(){return this.#r}set volume(e){this.#r=e,this.loadComplete.then(()=>{this.#p(l.SET_VOLUME,e)})}
21get playsInline(){return this.hasAttribute("playsinline")}set playsInline(e){this.toggleAttribute("playsinline",!!e)}play(){this.#o=!1,this.#p(l.PLAY)}pause(){this.#o=!0,this.#p(l.PAUSE)}#c=async e=>{var t,i,n,s;if(!this.#i.contentWindow)return;let{data:a,source:r}=e;if(r===this.#i.contentWindow){if("twitch-embed"===a.namespace)await new Promise(e=>setTimeout(e,10)),"ready"===a.eventName?(this.dispatchEvent(new Event("loadcomplete")),this.loadComplete.resolve(),this.#u=1,this.dispatchEvent(new Event("loadedmetadata"))):"seek"===a.eventName?(this.#l=!0,this.dispatchEvent(new Event("seeking"))):"playing"===a.eventName?(this.#l&&(this.#l=!1,this.dispatchEvent(new Event("seeked"))),this.#u=3,this.dispatchEvent(new Event("playing"))):this.dispatchEvent(new Event(a.eventName));else if("twitch-embed-player-proxy"===a.namespace&&"UPDATE_STATE"===a.eventName){let e=this.#n.duration,r=this.#n.currentTime,o=this.#n.volume,l=this.#n.muted,u=null==(i=null==(t=this.#n.stats)?void 0:t.videoStats)?void 0:i.bufferSize;this.#n={...this.#n,...a.params},e!==this.#n.duration&&this.dispatchEvent(new Event("durationchange")),r!==this.#n.currentTime&&this.dispatchEvent(new Event("timeupdate")),(o!==this.#n.volume||l!==this.#n.muted)&&this.dispatchEvent(new Event("volumechange")),u!==(null==(s=null==(n=this.#n.stats)?void 0:n.videoStats)?void 0:s.bufferSize)&&this.dispatchEvent(new Event("progress"))}}};#p(e,t){this.#i.contentWindow&&this.#i.contentWindow.postMessage({eventName:e,params:t,namespace:"twitch-embed-player-proxy"},s)}#h(e){if(Object.prototype.hasOwnProperty.call(this,e)){let t=this[e];delete this[e],this[e]=t}}}function c(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/`/g,"&#x60;")}function p(e){return String(new URLSearchParams(function(e){let t={};for(let i in e){let n=e[i];!0===n||""===n?t[i]=!0:!1===n?t[i]=!1:null!=n&&(t[i]=n)}return t}(e)))}class m extends Promise{constructor(e=()=>{}){let t,i;super((n,s)=>{e(n,s),t=n,i=s}),this.resolve=t,this.reject=i}}function f(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",h);var v=new Set(["style","children","ref","key","suppressContentEditableWarning","suppressHydrationWarning","dangerouslySetInnerHTML"]),g={className:"class",htmlFor:"for"};function y(e){return e.toLowerCase()}function w(e){return"boolean"==typeof e?e?"":void 0:"function"==typeof e?void 0:"object"!=typeof e||null===e?e:void 0}function E(e,t,i){var n,s;e[t]=i,null==i&&t in(null!=(s=null==(n=globalThis.HTMLElement)?void 0:n.prototype)?s:{})&&e.removeAttribute(t)}var b=function(e){let{react:t,tagName:i,elementClass:n,events:s,displayName:a,defaultProps:r,toAttributeName:o=y,toAttributeValue:l=w}=e,u=Number.parseInt(t.version)>=19,d=t.forwardRef((e,a)=>{var d,h,c,p,m;let f=t.useRef(null),y=t.useRef(new Map),b={},S={},T={},L={};for(let[t,i]of Object.entries(e)){if(v.has(t)){T[t]=i;continue}let e=o(null!=(c=g[t])?c:t);if(t in n.prototype&&!(t in(null!=(p=null==(d=globalThis.HTMLElement)?void 0:d.prototype)?p:{}))&&!(null==(h=n.observedAttributes)?void 0:h.some(t=>t===e))){L[t]=i;continue}if(t.startsWith("on")){b[t]=i;continue}let s=l(i);e&&null!=s&&(S[e]=String(s),u||(T[e]=s)),e&&u&&(s!==w(i)?T[e]=s:T[e]=i)}if("undefined"!=typeof window){for(let e in b){let i=b[e],n=e.endsWith("Capture"),a=(null!=(m=null==s?void 0:s[e])?m:e.slice(2).toLowerCase()).slice(0,n?-7:void 0);t.useLayoutEffect(()=>{let e=null==f?void 0:f.current;if(e&&"function"==typeof i)return e.addEventListener(a,i,n),()=>{e.removeEventListener(a,i,n)}},[null==f?void 0:f.current,i])}t.useLayoutEffect(()=>{if(null===f.current)return;let e=new Map;for(let t in L)E(f.current,t,L[t]),y.current.delete(t),e.set(t,L[t]);for(let[e,t]of y.current)E(f.current,e,void 0);y.current=e})}if("undefined"==typeof window&&(null==n?void 0:n.getTemplateHTML)&&(null==n?void 0:n.shadowRootOptions)){let{mode:i,delegatesFocus:s}=n.shadowRootOptions;T.children=[t.createElement("template",{shadowrootmode:i,shadowrootdelegatesfocus:s,dangerouslySetInnerHTML:{__html:n.getTemplateHTML(S,e)}}),T.children]}return t.createElement(i,{...r,...T,ref:t.useCallback(e=>{f.current=e,"function"==typeof a?a(e):null!==a&&(a.current=e)},[a])})});return d.displayName=null!=a?a:n.name,d}({react:n,tagName:"twitch-video",elementClass:h,toAttributeName:e=>"muted"===e?"":"defaultMuted"===e?"muted":y(e)})}}]);

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.