1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[652],{652:(e,n,t)=>{t.d(n,{FA:()=>a,Jd:()=>c,Nn:()=>q,O1:()=>Q,OJ:()=>x,Rf:()=>V,XX:()=>J,ZT:()=>$,Zr:()=>B,_P:()=>Y,a_:()=>U,cr:()=>G,kw:()=>Z,nI:()=>z,oL:()=>X,ow:()=>F,r1:()=>s,tK:()=>H});var o=t(2115),r=t(2549);let l="lobby:".concat(window.location.hostname),a="funnudge:open-to-challenges",i=["/privacy","/terms","/about","/contact"],c=e=>!i.some(n=>e.startsWith(n)),d="funnudge:muted-challengers",u="";function f(){try{var e;return new Set(JSON.parse(null!=(e=window.localStorage.getItem(d))?e:"[]"))}catch(e){return new Set}}function s(e){try{let n=f();n.add(e),window.localStorage.setItem(d,JSON.stringify([...n].slice(-100)))}catch(e){}}let p=null,v=0,y=null,m=!1,h={name:"Player",open:!0,game:"browse",visible:!0},g=()=>JSON.stringify({n:h.name.slice(0,16),o:+!!h.open,g:h.game,v:+!!h.visible,b:+!!N}),w=new Set,b=new Set,S=new Set,E=new Set,k=new Set,_=new Set,I=new Map,j=new Map,O=[],D=0,N=!1,T=new Set;function U(e){N!==e&&(N=e,A(),T.forEach(n=>n(e)))}let x=()=>N;function J(e){return T.add(e),()=>T.delete(e)}function L(){if(!p)return;let e=function(e){let n=[];for(let t of e){let e="Player",o=!1,r="browse",l=!0,a=!1;try{let n=JSON.parse(t.name);e="string"==typeof n.n?n.n:e,o=1===n.o,r="string"==typeof n.g?n.g:r,l=0!==n.v,a=1===n.b}catch(e){}n.push({id:t.key,name:e,open:o,game:r,visible:l,busy:a})}return n}(p.peers());w.forEach(n=>n(e))}function M(){!p&&!(v<=0)&&(0,r.Tx)()&&("undefined"!=typeof document&&document.hidden||(h.visible=!0,(p=(0,r.O3)(l,g(),(!u&&(u=("undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():String(Math.random())+Date.now()).replace(/-/g,"").slice(0,12)),u))).onPeers(()=>L()),p.on("invite",(e,n)=>{if((!e.to||e.to===(null==p?void 0:p.playerId))&&!function(e){var n,t;let o=Date.now();if((null!=(n=j.get(e))?n:0)>o||D>o)return!0;let r=(null!=(t=I.get(e))?t:[]).filter(e=>o-e<6e4);return(r.push(o),I.set(e,r),r.length>30)?(j.set(e,o+6e4),!0):r.length>8||((O=O.filter(e=>o-e<6e4)).push(o),O.length>20&&(D=o+6e4,!0))}(e.from)){if(null==p||p.send("invite-ack",{to:e.from}),f().has(e.from)){null==p||p.send("invite-reply",{to:e.from,reply:"reject"});return}b.forEach(t=>t(e,n))}}),p.on("invite-reply",(e,n)=>{e.to&&e.to!==(null==p?void 0:p.playerId)||S.forEach(t=>t(e,n))}),p.on("invite-ack",(e,n)=>{e.to&&e.to!==(null==p?void 0:p.playerId)||E.forEach(e=>e(n))}),p.on("invite-cancel",(e,n)=>{e.to&&e.to!==(null==p?void 0:p.playerId)||k.forEach(e=>e(n))}),p.on("invite-confirm",(e,n)=>{e.to&&e.to!==(null==p?void 0:p.playerId)||_.forEach(e=>e(n))})))}function P(){null==p||p.leave(),p=null}function A(){null==p||p.update(g())}function C(){h.visible=!document.hidden,document.hidden?(A(),y||(y=setTimeout(P,18e5))):(y&&clearTimeout(y),y=null,M(),A())}function W(){v++,m||"undefined"==typeof document||(m=!0,document.addEventListener("visibilitychange",C)),M()}function R(){--v<=0&&(y&&clearTimeout(y),y=null,P())}function X(){try{let e=window.localStorage.getItem(a);return null===e||"1"===e}catch(e){return!0}}function K(){var e;return null!=(e=null==p?void 0:p.playerId)?e:""}
1function Z(e,n){null==p||p.send("invite",{...n,from:p.playerId,to:e})}function F(e,n){null==p||p.send("invite-reply",{to:e,reply:n})}function G(e){null==p||p.send("invite-cancel",{to:e})}function Q(e){null==p||p.send("invite-confirm",{to:e})}function z(e){let{name:n,open:t,game:l,enabled:a}=e;(0,o.useEffect)(()=>{if(a&&(0,r.Tx)())return W(),()=>R()},[a]),(0,o.useEffect)(()=>{if(!a)return;let e=h.name!==n||h.open!==t||h.game!==l;h.name=n||"Player",h.open=t,h.game=l||"browse",e&&A()},[n,t,l,a])}function B(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0],[n,t]=(0,o.useState)([]),[l,a]=(0,o.useState)("");return(0,o.useEffect)(()=>{if(!e||!(0,r.Tx)())return;W();let n=e=>{t(e),a(K())};return w.add(n),L(),a(K()),()=>{w.delete(n),R()}},[e]),{peers:n,playerId:l}}function H(e){return b.add(e),()=>b.delete(e)}function V(e){return S.add(e),()=>S.delete(e)}function Y(e){return E.add(e),()=>E.delete(e)}function q(e){return k.add(e),()=>k.delete(e)}function $(e){return _.add(e),()=>_.delete(e)}},2549:(e,n,t)=>{t.d(n,{O3:()=>c,Tx:()=>l,vM:()=>i}),t(5704);let o="https://szrhpgweueniopvwutic.supabase.co",r="sb_publishable_f7QNX8Dn4Kw9sm6wtrd31w_ySsgnx9y",l=()=>!!(o&&r),a="ABCDEFGHJKLMNPQRSTUVWXYZ23456789",i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:4;return Array.from({length:e},()=>a[Math.random()*a.length|0]).join("")};function c(e,n,t){var l;let a;if(!o||!r)throw Error("Realtime is not configured");let i=t||("undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():String(Math.random())).replace(/-/g,"").slice(0,10),c=o.replace(/^http/,"ws")+"/realtime/v1/websocket?apikey=".concat(encodeURIComponent(r),"&vsn=1.0.0"),d="realtime:".concat(e),u=1,f=()=>String(++u),s=null,p=n,v=0,y="connecting",m={},h=!1,g=0,w=0,b=Date.now(),S=null,E=null,k=new Map,_=new Set,I=new Set,j=new Set,O=e=>{y!==e&&(y=e,I.forEach(n=>n(e)))},D=()=>Object.entries(m).map(e=>{var n,t,o,r,l;let[a,{metas:i}]=e;return{key:a,name:String(null!=(r=null==(n=i[0])?void 0:n.name)?r:"Player"),joinedAt:Number(null!=(l=null==(t=i[0])?void 0:t.joinedAt)?l:0),badge:"string"==typeof(null==(o=i[0])?void 0:o.badge)?i[0].badge:void 0}}).sort((e,n)=>e.joinedAt-n.joinedAt||e.key.localeCompare(n.key)),N=()=>{let e=D();_.forEach(n=>n(e))},T=e=>{s&&s.readyState===WebSocket.OPEN&&s.send(JSON.stringify(e))},U=()=>{T({topic:d,event:"presence",payload:{type:"presence",event:"track",payload:{name:p,joinedAt:v,badge:a}},ref:f(),join_ref:"1"})},x=()=>{S&&clearInterval(S),S=null},J=()=>{if(h||E)return;if(w>=8)return void O("closed");O("connecting");let e=Math.min(8e3,400*2**w);w++,E=setTimeout(()=>{E=null,L()},e)},L=()=>{if(h)return;x();try{s=new WebSocket(c)}catch(e){J();return}let e=s;e.onopen=()=>{e===s&&(b=Date.now(),g++,m={},T({topic:d,event:"phx_join",payload:{config:{broadcast:{self:!1,ack:!1},presence:{key:i,enabled:!0},postgres_changes:[]}},ref:"1",join_ref:"1"}),S=setInterval(()=>{if(Date.now()-b>65e3){try{e.close()}catch(e){}return}T({topic:"phoenix",event:"heartbeat",payload:{},ref:f()})},25e3))},e.onmessage=n=>{e===s&&(e=>{var n,t,o,r,l,a;let i;b=Date.now();try{i=JSON.parse(String(e.data))}catch(e){return}if(i.topic===d){if("phx_reply"===i.event&&"1"===i.ref){if("ok"===i.payload.status)w=0,O("open"),v=Date.now(),U(),g>1&&j.forEach(e=>e());else{O("error");try{null==s||s.close()}catch(e){}}return}if("presence_state"===i.event){m=i.payload,N();return}if("presence_diff"===i.event){let e=i.payload;for(let[t,o]of Object.entries(null!=(n=e.joins)?n:{}))m[t]=o;for(let n of Object.keys(null!=(t=e.leaves)?t:{}))(null==(o=e.joins)?void 0:o[n])||delete m[n];N();return}if("broadcast"===i.event){let e=i.payload,n=null!=(a=null==(r=e.payload)?void 0:r._from)?a:"";null==(l=k.get(e.event))||l.forEach(t=>t(e.payload,n));return}}})(n)},e.onerror=()=>{},e.onclose=()=>{e===s&&(x(),h||J())}},M=()=>{!h&&(E&&(clearTimeout(E),E=null),w=0,s&&s.readyState!==WebSocket.CLOSED&&s.readyState!==WebSocket.CLOSING||L())},P=()=>{document.hidden||h||M()},A=()=>M();return"undefined"!=typeof document&&document.addEventListener("visibilitychange",P),window.addEventListener("online",A),L(),{code:null!=(l=e.split(":").pop())?l:e,playerId:i,send:(e,n)=>{T({topic:d,event:"broadcast",payload:{type:"broadcast",event:e,payload:{...n,_from:i}},ref:f(),join_ref:"1"})},on:(e,n)=>(k.has(e)||k.set(e,new Set),k.get(e).add(n),()=>{var t;return null==(t=k.get(e))?void 0:t.delete(n)}
1),update:(e,n)=>{(p!==e||void 0!==n&&a!==n)&&(p=e,void 0!==n&&(a=n),"open"===y&&U())},onPeers:e=>(_.add(e),e(D()),()=>_.delete(e)),onStatus:e=>(I.add(e),e(y),()=>I.delete(e)),onReconnect:e=>(j.add(e),()=>j.delete(e)),peers:D,status:()=>y,leave:()=>{h=!0,x(),E&&clearTimeout(E),"undefined"!=typeof document&&document.removeEventListener("visibilitychange",P),window.removeEventListener("online",A);try{T({topic:d,event:"phx_leave",payload:{},ref:f(),join_ref:"1"}),null==s||s.close()}catch(e){}O("closed")}}}}}]);
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.