PageSourceSearch

https://tesana.com/assets/ChatPanel-CprUFb98.js

js tesana.com collected 2026-10-09 22:41:38 UTC 28,850 bytes, 1 lines download raw bytes

1import{j as t}from"./vendor-motion-hRg_q8lq.js";import{r}from"./vendor-react-E98sgxjj.js";import{u as K,d as _,r as ke,cR as Se,b as Ce}from"./index-BKzE8EQ8.js";import{du as F,hq as Ee,hr as Me,aT as Te,aq as me,F as Re,ag as De,f as _e,hs as ae}from"./vendor-fa-Bn2dnpnC.js";import{A as Ae}from"./index-BxtVm1Yj.js";import{s as Fe}from"./vanitySite-BtpHcDVO.js";import{A as Ie}from"./Avatar-B60wpoS5.js";import{h as Oe,c as Pe,r as Le}from"./chatReturn-BikAGK6w.js";import{u as He,b as Be,c as $e}from"./useGameChatSocket-Ca57ylO8.js";import"./vendor-query-bOUN_gKe.js";import"./useLocaleNavigate-BNriJdRU.js";import"./exploreHandoff-RQymaHkp.js";import"./AuthShell-DPeun0C_.js";import"./AuthPanel-B4zt6SJ5.js";import"./pendingReferral-B4JPXhl_.js";import"./LaunchPromoClips-eRoWsyBt.js";import"./MediaImage-DKgx-nW4.js";import"./chatRoomStore-oLAeRb02.js";function he({label:n}){const i=["w-3/4","w-1/2","w-2/3","w-5/12","w-3/5"];return t.jsx("div",{role:n?"status":void 0,"aria-label":n||void 0,"aria-hidden":n?void 0:!0,className:"min-h-0 flex-1 overflow-hidden px-3.5 pt-9",children:i.map((o,e)=>t.jsxs("div",{"aria-hidden":"true",className:"flex gap-2.5 py-1.5",children:[t.jsx("span",{className:"h-7 w-7 shrink-0 animate-pulse rounded-full bg-foreground
1/10"}),t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col gap-1.5 pt-0.5",children:[t.jsx("span",{className:"h-3 w-16 animate-pulse rounded-sm bg-foreground/10"}),t.jsx("span",{className:`h-3.5 ${o} animate-pulse rounded-sm bg-foreground/10`})]})]},e))})}const Ke=3e4,Q=new Set;let X=null,W=Date.now();function ze(n){return Q.add(n),X||(W=Date.now(),X=setInterval(()=>{W=Date.now();for(const i of[...Q])i()},Ke)),()=>{Q.delete(n),Q.size===0&&X&&(clearInterval(X),X=null)}}function pe(){return r.useSyncExternalStore(ze,()=>W,()=>W)}const ce=new Map,ue=new Map;function te(n){let i=ce.get(n);return i||(i=new Intl.RelativeTimeFormat(n,{numeric:"auto",style:"short"}),ce.set(n,i)),i}function G(n,i,o){const e=`${n}|${i}`;let s=ue.get(e);return s||(s=new Intl.DateTimeFormat(n,o),ue.set(e,s)),s}function Ue(n,i,o,e){const s=Date.parse(n);if(!Number.isFinite(s))return"";const a=Math.max(0,(i-s)/1e3);return a<45?e:a<3600?te(o).format(-Math.max(1,Math.floor(a/60)),"minute"):a<86400?te(o).format(-Math.floor(a/3600),"hour"):a<7*86400?te(o).format(-Math.floor(a/86400),"day"):new Date(s).getFullYear()===new Date(i).getFullYear()?G(o,"md",{month:"short",day:"numeric"}
1).format(s):G(o,"ymd",{year:"numeric",month:"short",day:"numeric"}).format(s)}function Xe(n,i){const o=Date.parse(n);return Number.isFinite(o)?G(i,"full",{dateStyle:"medium",timeStyle:"short"}).format(o):""}function Ge(n,i,o){const e=Date.parse(n);if(!Number.isFinite(e))return"";const s=new Date(e),a=new Date(i);return s.toDateString()===a.toDateString()?G(o,"hm",{hour:"numeric",minute:"2-digit"}).format(e):G(o,"mdhm",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}).format(e)}const qe=2147e6;function Ve(n){const i=n?Date.parse(n):NaN,[o,e]=r.useState(()=>Number.isFinite(i)&&Date.now()>=i);return r.useEffect(()=>{if(!Number.isFinite(i)){e(!1);return}const s=i-Date.now();if(s<=0){e(!0);return}if(e(!1),s>qe)return;const a=setTimeout(()=>e(!0),s+250);return()=>clearTimeout(a)},[i]),o}function Ye({mode:n,lang:i}){const{t:o}=K("gameChat"),e=pe();let s;return n.kind==="muted"?s=n.until?o("composer.mutedUntil",{time:Ge(n.until,e,i)}):o("composer.muted"):n.kind==="banned"?s=o("composer.banned"):s=o("composer.cantPost"),t.jsxs("p",{role:"status",className:"flex min-h-10 items-center gap-2.5 rounded-md bg-foreground
1/5 px-3 py-2 text-sm text-muted-foreground",children:[t.jsx(F,{icon:n.kind==="muted"?Ee:Me,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:s})]})}const Je=500,Qe=50,We=120,de={links_not_allowed:"linksNotAllowed",empty:"empty",too_long:"tooLong"};function Ze(n){return Array.from(n).length}function et({mode:n,onSignUp:i,onSend:o,textareaRef:e}){const{t:s,i18n:a}=K("gameChat"),c=r.useId(),[d,g]=r.useState(""),[m,p]=r.useState(!1),[T,w]=r.useState(null),[v,y]=r.useState(null),[b,u]=r.useState(0),[f,k]=r.useState("");if(r.useEffect(()=>{if(v==null)return;const N=()=>{const E=Math.max(0,Math.ceil((v-Date.now())/1e3));u(E),E===0&&(y(null),k(""))};N();const R=setInterval(N,1e3);return()=>clearInterval(R)},[v]),r.useLayoutEffect(()=>{const N=e.current;N&&(N.style.height="auto",N.style.height=`${Math.min(N.scrollHeight,We)}px`)},[d,e,n.kind]),n.kind==="guest")return t.jsx("div",{className:"shrink-0 border-t border-border p-3",children:t.jsx("button",{type:"button",onClick:i,className:"h-10 w-full rounded-md bg-accent text-sm text-accent-foreground hover:bg-accent/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card",children:s("composer.signUp")})});if(n.kind==="loading")return t.jsx("div",{className:"shrink-0 border-t border-border p-3","aria-hidden":"true",children:t.jsx("div",{className:"h-10 animate-pulse rounded-md bg-foreground
1/5"})});if(n.kind!=="ready")return t.jsx("div",{className:"shrink-0 border-t border-border p-3",children:t.jsx(Ye,{mode:n,lang:a.language||"en"})});const S=Ze(d),j=Je-S,I=!(d.trim().length===0)&&j>=0&&!m&&v==null,O=async N=>{if(N?.preventDefault(),!I)return;p(!0),w(null);const R=await o(d.trim());if(p(!1),R.ok){g(""),e.current?.focus();return}const{code:E,status:V,retryAfter:z}=R.error;if(E==="slow_down"){const H=Math.max(1,Math.ceil(z??2));y(Date.now()+H*1e3),k(s("composer.slowDown",{count:H}));return}E==="chat_off"||E==="muted"||E==="banned"||(E&&de[E]?w(de[E]):w(V===401?"signedOut":"failed"))},P=N=>{N.key!=="Enter"||N.shiftKey||N.nativeEvent.isComposing||N.keyCode===229||(N.preventDefault(),O())},L=`${c}-hint`,l=`${c}-status`,x=`${c}-counter`,C=j<=Qe;return t.jsxs("form",{onSubmit:O,className:"shrink-0 border-t border-border px-3 pb-2 pt-3",children:[t.jsxs("div",{className:_("flex items-end gap-2 rounded-md border bg-input py-1.5 pl-3 pr-1.5 transition-colors",j<0?"border-destructive":"border-border focus-within:border-ring"),children:[t.jsx("textarea",{ref:e,value:d,rows:1,onChange:N=>{g(N.target.value),T&&w(null)},onKeyDown:P,"aria-label":s("composer.label"),"aria-describedby":[L,T?l:null,C?x:null].filter(Boolean).join(" "),"aria-invalid":j<0||void 0,placeholder:s("composer.placeholder"),enterKeyHint:"send",className:"max-h-[120px] min-h-[28px] min-w-0 flex-1 resize-none bg-transparent py-1 text-sm text-foreground placeholder:text-muted-foreground/70 focus:outline-none"}),t.jsx("button",{type:"submit",disabled:!I,"aria-label":s("composer.send"),className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-accent hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:text-muted-foreground disabled:opacity-50 disabled:hover:bg-transparent",children:t.jsx(F,{icon:Te})})]}),t.jsx("span",{id:L,className:"sr-only",children:s("composer.hint")}),t.jsxs("div",{className:"mt-1 flex min-h-[18px] items-start justify-between gap-2 text-xs",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{id:l,role:"alert",className:"text-destructive",children:T?s(`composer.${T}`):""}),v!=null&&t.jsx("p",{className:"text-muted-foreground","aria-hidden":"true",children:s("composer.slowDown",{count:b})})]}),C&&t.jsx("span",{id:x,className:_("shrink-0 tabular-nums",j<0?"text-destructive":"text-muted-foreground"),children:j<0?s("composer.charsOver",{count:-j}):s("composer.charsLeft",{count:j})})]}),t.jsx("span",{role:"status",className:"sr-only",children:f})]})}function ne({icon:n,title:i,body:o,action:e}){return t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col items-center justify-center gap-2 px-6 py-10 text-center",children:[n&&t.jsx(F,{icon:n,className:"mb-1 text-xl text-muted-foreground","aria-hidden":"true"}),i&&t.jsx("p",{className:"text-sm text-foreground",children:i}),t.jsx("p",{className:"text-sm text-muted-foreground",children:o}),e&&t.jsx("button",{type:"button",onClick:e.onClick,disabled:e.busy,className:"mt-2 h-9 rounded-md border border-border px-3 text-sm text-foreground hover:border-border-hover hover:bg-foreground
1/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50",children:e.label})]})}const tt=2,nt=1;function rt({titleId:n,title:i,playingNow:o,chatting:e,status:s,onClose:a}){const{t:c}=K("gameChat"),d=[];o!=null&&o>=tt&&d.push(c("panel.playingNow",{count:o})),e!=null&&e>=nt&&d.push(c("panel.chatting",{count:e}));const g=s==="reconnecting"?c("panel.reconnecting"):d.join(" · ");return t.jsxs("header",{className:"flex shrink-0 items-start gap-2 border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h2",{id:n,className:"truncate text-sm text-foreground",children:i}),t.jsxs("p",{className:"mt-0.5 flex h-[18px] min-w-0 items-center gap-1.5 text-xs text-muted-foreground",children:[s==="open"&&d.length>0&&t.jsx("span",{"aria-hidden":"true",className:"h-1.5 w-1.5 shrink-0 rounded-full bg-success"}),t.jsx("span",{className:"truncate",children:g})]})]}),t.jsx("button",{type:"button",onClick:a,"aria-label":c("panel.close"),className:"-mr-1.5 flex h-8 w-8 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-foreground
1/5 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:t.jsx(F,{icon:me})})]})}function st({iso:n,lang:i,justNow:o,className:e}){const s=pe();return t.jsx("time",{dateTime:n,title:Xe(n,i),className:e,children:Ue(n,s,i,o)})}function ot({message:n,profileHref:i,labels:o,hasActions:e,menuOpen:s,menuId:a,onOpenMenu:c}){const{user:d,badge:g}=n;return t.jsxs("li",{className:_("group relative flex gap-2.5 rounded-md px-2 py-1.5 hover:bg-foreground/[0.04] focus-within:bg-foreground/[0.04]",e&&"pr-9"),"data-message-id":n.id,children:[t.jsx("span",{"aria-hidden":"true",className:"mt-0.5 shrink-0",children:t.jsx(Ie,{user:{username:d.username,profile_picture:d.avatar_url},size:"sm",className:"!h-7 !w-7"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 text-xs",children:[t.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"min-w-0 truncate rounded-sm text-muted-foreground hover:text-foreground hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:d.username}),g==="creator"&&t.jsx("span",{className:"shrink-0 rounded-sm bg-accent/15 px-1.5 text-xs leading-4 text-accent",children:o.creator}),g==="staff"&&t.jsx("span",{className:"shrink-0 rounded-sm bg-foreground
1/10 px-1.5 text-xs leading-4 text-foreground",children:o.staff}),t.jsx(st,{iso:n.created_at,lang:o.lang,justNow:o.justNow,className:_("shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",s&&"opacity-100")})]}),t.jsx("p",{className:"mt-0.5 whitespace-pre-wrap text-sm text-foreground [overflow-wrap:anywhere]",children:n.body})]}),e&&t.jsx("button",{type:"button","aria-label":o.menuTrigger(d.username),"aria-haspopup":"menu","aria-expanded":s,"aria-controls":s?a:void 0,onClick:m=>c(n,m.currentTarget),className:_("absolute right-1.5 top-1.5 flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-opacity","hover:bg-foreground/10 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring","opacity-0 group-hover:opacity-100 group-focus-within:opacity-100 focus-visible:opacity-100 pointer-coarse:opacity-100",s&&"bg-foreground/10 text-foreground opacity-100"),children:t.jsx(F,{icon:Re})})]})}const it=r.memo(ot),lt=48,at=120;function ct({messages:n,hasMore:i,loadingOlder:o,olderFailed:e,lastLiveId:s,viewerId:a,emptyText:c,onLoadOlder:d,hasActions:g,menuFor:m,menuId:p,onOpenMenu:T,listRef:w}){const{t:v,i18n:y}=K("gameChat"),b=y.language||"en",u=r.useRef(!0),f=r.useRef({height:0}),[k,S]=r.useState(!1),[j,q]=r.useState(null),I=r.useMemo(()=>({creator:v("badge.creator"),staff:v("badge.staff"),justNow:v("time.justNow"),lang:b,menuTrigger:l=>v("menu.trigger",{username:l})}),[v,b]),O=r.useMemo(()=>`${typeof document<"u"&&!!ke(document)?Fe():""}${Se(b)}/u/`,[b]),P=r.useCallback((l=!1)=>{const x=w.current;if(x){if(l&&typeof x.scrollTo=="function"){const C=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;x.scrollTo({top:x.scrollHeight,behavior:C?"auto":"smooth"})}else x.scrollTop=x.scrollHeight;u.current=!0,S(!1)}},[w]);r.useLayoutEffect(()=>{const l=w.current;if(!l)return;const x=f.current,C=n[0]?.id,N=n[n.length-1],R=N?.id;if(x.first!==void 0&&C!==void 0&&C<x.first&&R===x.last)l.scrollTop+=l.scrollHeight-x.height;else if(R!==x.last){const E=N&&a!=null&&N.user.id===a;x.last===void 0||u.current||E?(l.scrollTop=l.scrollHeight,u.current=!0,S(!1)):R!==void 0&&x.last!==void 0&&R>x.last&&S(!0)}f.current={first:C,last:R,height:l.scrollHeight}},[n,a,w]),r.useEffect(()=>{const l=w.current;if(!l||typeof ResizeObserver>"u")return;const x=new ResizeObserver(()=>{u.current&&(l.scrollTop=l.scrollHeight),f.current={...f.current,height:l.scrollHeight}});return x.observe(l),()=>x.disconnect()},[w]),r.useEffect(()=>{if(s==null)return;const l=n.find(x=>x.id===s);!l||a!=null&&l.user.id===a||q(x=>x?.id===l.id?x:{id:l.id,text:v("list.announce",{username:l.user.username,body:l.body})})},[s]);const L=()=>{const l=w.current;if(!l)return;const x=l.scrollHeight-l.scrollTop-l.clientHeight<=lt;u.current=x,x&&S(!1),l.scrollTop<=at&&i&&!o&&!e&&d()};return t.jsxs("div",{className:"relative min-h-0 flex-1",children:[t.jsxs("div",{ref:w,tabIndex:0,role:"region","aria-label":v("list.label"),onScroll:L,className:"h-full overflow-y-auto overscroll-contain px-1.5 [overflow-anchor:none] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",children:[t.jsx("div",{className:"flex h-9 items-center justify-center text-xs text-muted-foreground",children:o?t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(F,{icon:De,spin:!0,"aria-hidden":"true"}),v("list.loadingOlder")]}):i?t.jsx("button",{type:"button",onClick:d,className:"rounded-md px-2 py-1 hover:bg-foreground
1/5 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:v(e?"list.olderFailed":"list.loadOlder")}):n.length>0?t.jsx("span",{children:v("list.start")}):null}),n.length===0?t.jsx("p",{className:"px-4 py-10 text-center text-sm text-muted-foreground",children:c}):t.jsx("ol",{className:"flex flex-col gap-0.5 pb-2",children:n.map(l=>t.jsx(it,{message:l,profileHref:`${O}${encodeURIComponent(l.user.username)}`,labels:I,hasActions:g(l),menuOpen:m===l.id,menuId:p,onOpenMenu:T},l.id))})]}),k&&t.jsxs("button",{type:"button",onClick:()=>{P(!0),w.current?.focus({preventScroll:!0})},className:"absolute bottom-2 left-1/2 flex -translate-x-1/2 items-center gap-1.5 rounded-full bg-accent px-3 py-1.5 text-xs text-accent-foreground shadow-lg hover:bg-accent/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card",children:[t.jsx(F,{icon:_e,"aria-hidden":"true"}),v("list.newMessages")]}),t.jsx("div",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:j&&t.jsx("p",{children:j.text},j.id)})]})}const re=4,$=8;function ut({id:n,label:i,heading:o,items:e,anchor:s,container:a,scroller:c,onClose:d}){const g=r.useRef(null),[m,p]=r.useState(null),T=`${n}-heading`,w=r.useCallback(()=>{const y=g.current;if(!y||!a)return;const b=a.getBoundingClientRect(),u=s.getBoundingClientRect();if(c){const j=c.getBoundingClientRect();if(j.height>0&&(u.bottom<j.top||u.top>j.bottom)){d({restoreFocus:!1});return}}const f=Math.max($,b.right-u.right),k=u.bottom-b.top+re,S=y.offsetHeight;k+S>b.height-$&&u.top-b.top-re-S>=$?p({bottom:b.bottom-u.top+re,right:f}):p({top:Math.min(k,Math.max($,b.height-S-$)),right:f})},[s,a,c,d]);r.useLayoutEffect(()=>{w()},[w,e.length,o]),r.useEffect(()=>{if(c)return c.addEventListener("scroll",w,{passive:!0}),()=>c.removeEventListener("scroll",w)},[c,w]),r.useEffect(()=>{g.current?.querySelector('[role="menuitem"]')?.focus({preventScroll:!0})},[o,e.length]),r.useEffect(()=>{const y=b=>{const u=b.target;!u||g.current?.contains(u)||s.contains(u)||d({restoreFocus:!1})};return document.addEventListener("pointerdown",y,!0),()=>document.removeEventListener("pointerdown",y,!0)},[s,d]);const v=y=>{const b=Array.from(g.current?.querySelectorAll('[role="menuitem"]')??[]),u=b.indexOf(document.activeElement),f=k=>{y.preventDefault(),b[(k+b.length)%b.length]?.focus()};switch(y.key){case"ArrowDown":f(u+1);break;case"ArrowUp":f(u<=0?b.length-1:u-1);break;case"Home":f(0);break;case"End":f(b.length-1);break;case"Escape":y.preventDefault(),y.stopPropagation(),d({restoreFocus:!0});break;case"Tab":y.preventDefault(),d({restoreFocus:!0});break}};return t.jsxs("div",{ref:g,onKeyDown:v,style:m?{top:m.top,bottom:m.bottom,right:m.right}:{top:0,right:$},className:_("absolute z-20 w-max min-w-[176px] max-w-[calc(100%-16px)] rounded-md border border-border bg-card p-1 text-sm shadow-xl",!m&&"invisible"),children:[o&&t.jsx("p",{id:T,className:"px-2.5 pb-1 pt-1.5 text-xs text-muted-foreground",children:o}),t.jsx("div",{id:n,role:"menu","aria-label":o?void 0:i,"aria-labelledby":o?T:void 0,children:e.map(y=>t.jsx("button",{type:"button",role:"menuitem",onClick:y.onSelect,className:_("flex w-full items-center rounded-sm px-2.5 py-1.5 text-left outline-none","hover:bg-foreground
1/[0.06] focus:bg-foreground/[0.08]",y.danger?"text-destructive":"text-foreground"),children:y.label},y.id))})]})}function dt(){const[n,i]=r.useState(null),o=r.useRef(1),e=r.useCallback((a,c)=>{i({id:o.current++,text:a,action:c})},[]),s=r.useCallback(()=>i(null),[]);return{notice:n,show:e,dismiss:s}}function ft({notice:n,onDismiss:i,dismissLabel:o}){return r.useEffect(()=>{if(!n)return;const e=setTimeout(i,n.action?8e3:5e3);return()=>clearTimeout(e)},[n,i]),t.jsx("div",{role:"status","aria-live":"polite",className:"pointer-events-none absolute inset-x-2 top-2 z-10 flex justify-center",children:n&&t.jsxs("div",{className:"pointer-events-auto flex max-w-full items-center gap-2 rounded-md border border-border bg-elevated px-3 py-2 text-sm text-foreground shadow-lg",children:[t.jsx("span",{className:"min-w-0 [overflow-wrap:anywhere]",children:n.text}),n.action&&t.jsx("button",{type:"button",onClick:()=>{n.action?.run(),i()},className:"shrink-0 rounded-sm px-1 text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:n.action.label}),t.jsx("button",{type:"button",onClick:i,"aria-label":o,className:"-mr-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:t.jsx(F,{icon:me})})]},n.id)})}const mt=["spam","harassment","hate","sexual","violence","self_harm","other"],ht=500;function pt({username:n,onSubmit:i,onClose:o}){const{t:e}=K("gameChat"),s=r.useId(),a=r.useRef(null),[c,d]=r.useState(null),[g,m]=r.useState(""),[p,T]=r.useState(!1),[w,v]=r.useState(!1);r.useEffect(()=>{a.current?.querySelector('input[type="radio"]')?.focus({preventScroll:!0})},[]);const y=async u=>{if(u.preventDefault(),!c||p)return;T(!0),v(!1);const f=g.trim();await i({reason:c,details:f||null})||(T(!1),v(!0))},b=u=>{if(u.key==="Escape"){u.preventDefault(),u.stopPropagation(),o();return}if(u.key!=="Tab")return;const f=Array.from(a.current?.querySelectorAll("input:not([disabled]), textarea:not([disabled]), button:not([disabled])")??[]).filter(j=>!(j instanceof HTMLInputElement&&j.type==="radio"&&!j.checked&&c!==null));if(f.length===0)return;const k=f[0],S=f[f.length-1];u.shiftKey&&document.activeElement===k?(u.preventDefault(),S.focus()):!u.shiftKey&&document.activeElement===S&&(u.preventDefault(),k.focus())};return t.jsx("div",{className:"absolute inset-0 z-30 flex items-end justify-center bg-black/50 p-3 sm:items-center",onMouseDown:u=>{u.target===u.currentTarget&&o()},children:t.jsx("div",{ref:a,role:"dialog","aria-modal":"true","aria-labelledby":s,onKeyDown:b,className:"max-h-full w-full max-w-sm overflow-y-auto rounded-lg border border-border bg-card p-4 shadow-xl",children:t.jsxs("form",{onSubmit:y,children:[t.jsx("h3",{id:s,className:"text-base text-foreground",children:e("report.title")}),t.jsxs("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:["@",n]}),t.jsxs("fieldset",{className:"mt-4",children:[t.jsx("legend",{className:"mb-2 text-sm text-foreground",children:e("report.reasonLabel")}),t.jsx("div",{className:"flex flex-col gap-0.5",children:mt.map(u=>t.jsxs("label",{className:_("flex cursor-pointer items-center gap-2.5 rounded-md px-2 py-1.5 text-sm text-foreground hover:bg-foreground
1/5",c===u&&"bg-foreground/5"),children:[t.jsx("input",{type:"radio",name:"chat-report-reason",value:u,checked:c===u,onChange:()=>d(u),className:"h-4 w-4 shrink-0 accent-accent"}),e(`report.reasons.${u}`)]},u))})]}),t.jsx("label",{className:"mt-3 block text-xs text-muted-foreground",htmlFor:`${s}-note`,children:e("report.noteLabel")}),t.jsx("textarea",{id:`${s}-note`,value:g,maxLength:ht,rows:2,onChange:u=>m(u.target.value),placeholder:e("report.notePlaceholder"),className:"mt-1.5 w-full resize-none rounded-md border border-border bg-input px-3 py-2 text-sm text-foreground placeholder:text-muted-foreground/60 focus:border-foreground/40 focus:outline-none"}),t.jsx("p",{role:"alert",className:"mt-2 min-h-[18px] text-xs text-destructive",children:w?e("report.failed"):""}),t.jsxs("div",{className:"mt-2 flex justify-end gap-2",children:[t.jsx("button",{type:"button",onClick:o,className:"h-9 rounded-md border border-border px-3 text-sm text-muted-foreground hover:border-border-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:e("report.cancel")}),t.jsx("button",{type:"submit",disabled:!c||p,className:"h-9 rounded-md bg-accent px-3 text-sm text-accent-foreground hover:bg-accent/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card disabled:cursor-not-allowed disabled:opacity-50",children:e("report.submit")})]})]})})})}function xt(n,i,o=!1){const{store:e,status:s}=He(n,{enabled:!!n&&!o,viewerId:i}),a=Be(e);r.useEffect(()=>e?.openPanel(),[e]);const c=a?.history;return r.useEffect(()=>{e&&!o&&c==="idle"&&e.loadLatest()},[e,o,c]),{store:e,state:a,status:s}}const bt={"1h":"notice.muted1h","1d":"notice.muted1d",forever:"notice.mutedForever"};function fe(n,i){n&&n.isConnected?n.focus({preventScroll:!0}):i?.focus({preventScroll:!0})}function gt({game:n,onClose:i,playingNow:o}){const{t:e}=K("gameChat"),{user:s,loading:a}=Ce(),c=s?.id??null,d=!!s,g=$e(n),{store:m,state:p,status:T}=xt(g,c,a),w=r.useId(),v=r.useId(),y=r.useRef(null),b=r.useRef(null),u=r.useRef(null),[f,k]=r.useState(null),[S,j]=r.useState(null),[q,I]=r.useState(!1),[O,P]=r.useState(!1),{notice:L,show:l,dismiss:x}=dt(),C=p?.room??null,N=p?.enabled??n.chat_enabled??!0,R=!g||p?.history==="unavailable",E=!!C?.is_creator,V=E||!!s?.is_staff,z=Ve(C?.muted_until??null),H=r.useMemo(()=>d?C?C.banned?{kind:"banned"}:C.muted_forever?{kind:"muted",until:null}:C.muted_until&&!z?{kind:"muted",until:C.muted_until}:!C.can_post&&!(C.muted_until&&z)?{kind:"cantPost"}:{kind:"ready"}:{kind:"loading"}:a?{kind:"loading"}:{kind:"guest"},[d,a,C,z]);r.useEffect(()=>{!d||H.kind!=="ready"||!g||!Oe(g)||(Pe(),u.current?.focus())},[d,H.kind,g]),r.useEffect(()=>{k(null),j(null)},[c]);const xe=r.useCallback(()=>{g&&Le(g),typeof document<"u"&&document.fullscreenElement&&document.exitFullscreen&&document.exitFullscreen().catch(()=>{}),I(!0)},[g]),se=r.useRef(null);se.current=f;const Z=r.useCallback(({restoreFocus:h})=>{const M=se.current;k(null),M&&h&&fe(M.trigger,b.current)},[]),be=r.useCallback((h,M)=>{k(A=>A?.message.id===h.id?null:{message:h,trigger:M,confirmDelete:!1})},[]),ge=r.useCallback(h=>h.can_delete||d&&h.user.id!==c,[d,c]),Y=r.useCallback(async h=>{if(!m)return;const M=await m.unmute(h.id);l(e(M?"notice.unmuted":"notice.unmuteFailed",{username:h.username}))},[m,l,e]),J=r.useCallback(async(h,M)=>
1{if(!m)return;await m.mute(h.id,M)?l(e(bt[M],{username:h.username}),{label:e("notice.undo"),run:()=>void Y(h)}):l(e("notice.muteFailed",{username:h.username}))},[m,l,e,Y]),oe=r.useCallback(async h=>{if(!m)return;const M=await m.remove(h.id);l(e(M?"notice.deleted":"notice.deleteFailed"))},[m,l,e]),ve=r.useMemo(()=>{if(!f)return[];const{message:h,trigger:M}=f,A=D=>()=>{Z({restoreFocus:!0}),D()};if(f.confirmDelete)return[{id:"confirm-delete",label:e("menu.confirm"),danger:!0,onSelect:()=>{k(null),b.current?.focus({preventScroll:!0}),oe(h)}},{id:"cancel",label:e("menu.cancel"),onSelect:A(()=>{})}];const le=c!=null&&h.user.id===c,U=[];if(d&&!le&&U.push({id:"report",label:e("menu.report"),onSelect:()=>{k(null),j({message:h,trigger:M})}}),h.can_delete&&U.push({id:"delete",label:e("menu.delete"),danger:!0,onSelect:()=>k(D=>D&&{...D,confirmDelete:!0})}),V&&!le&&h.badge==null){const D=h.user;p&&D.id in p.mutedUsers?U.push({id:"unmute",label:e("menu.unmute"),onSelect:A(()=>void Y(D))}):U.push({id:"mute-1h",label:e("menu.mute1h"),onSelect:A(()=>void J(D,"1h"))},{id:"mute-1d",label:e("menu.mute1d"),onSelect:A(()=>void J(D,"1d"))},{id:"mute-forever",label:e("menu.muteForever"),onSelect:A(()=>void J(D,"forever"))})}return U},[f,c,d,V,p,e,Z,oe,J,Y]);r.useEffect(()=>{f&&p&&!p.messages.some(h=>h.id===f.message.id)&&k(null)},[f,p]);const ie=r.useRef(S);ie.current=S;const ee=r.useCallback(()=>{const h=ie.current;j(null),fe(h?.trigger,b.current)},[]),ye=r.useCallback(async h=>{if(!m||!S)return!1;const M=await m.report(S.message.id,h);return M&&(ee(),l(e("notice.reported"))),M},[m,S,ee,l,e]),we=r.useCallback(async()=>{if(!m)return;P(!0);const h=await m.setEnabled(!0);P(!1),l(e(h?"notice.chatOn":"notice.toggleFailed"))},[m,l,e]),je=r.useCallback(h=>m.send(h),[m]);let B;R?B=t.jsx(ne,{icon:ae,body:e("list.unavailable")}):N?!p||p.messages.length===0&&(p.history==="idle"||p.history==="loading")?B=t.jsx(he,{label:e("list.loading")}):p.messages.length===0&&p.history==="error"?B=t.jsx(ne,{body:e("list.error"),action:{label:e("list.retry"),onClick:()=>void m?.loadLatest()}}):B=t.jsx(ct,{messages:p.messages,hasMore:p.hasMore,loadingOlder:p.loadingOlder,olderFailed:p.olderFailed,lastLiveId:p.lastLiveId,viewerId:c,emptyText:e(d?"list.empty":"list.emptyGuest"),onLoadOlder:()=>void m?.loadOlder(),hasActions:ge,menuFor:f?.message.id??null,menuId:v,onOpenMenu:be,listRef:b}):B=t.jsx(ne,{icon:ae,title:e("off.title"),body:e(E?"off.creatorBody":"off.body"),action:E?{label:e("off.turnOn"),onClick:()=>void we(),busy:O}:void 0});const Ne=p?.playingNow??o;return t.jsxs("aside",{ref:y,"aria-label":e("panel.label",{game:n.name||e("panel.fallbackTitle")}),className:"relative flex min-h-0 flex-1 flex-col",children:[t.jsx(rt,{titleId:w,title:n.name||e("panel.fallbackTitle"),playingNow:Ne,chatting:p?.chatting??null,status:T,onClose:i}),t.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[B,t.jsx(ft,{notice:L,onDismiss:x,dismissLabel:e("notice.dismiss")})]}),!R&&N&&m&&t.jsx(et,{mode:H,onSignUp:xe,onSend:je,textareaRef:u}),f&&t.jsx(ut,{id:v,label:e("menu.label"),heading:f.confirmDelete?e("menu.confirmDelete"):void 0,items:ve,anchor:f.trigger,container:y.current,scroller:b.current,onClose:Z}),S&&t.jsx(pt,{username:S.message.user.username,onSubmit:ye,onClose:ee}),!d&&t.jsx(r.Suspense,{fallback:null,children:t.jsx(Ae,{isOpen:q,onClose:()=>I(!1),initialMode:"signup",onLoggedIn:()=>{}})})]})}const vt=80;function yt(n){const[i,o]=r.useState(0);return r.useEffect(()=>{const e=typeof window<"u"?window.visualViewport:null;if(!n||!e){o(0);return}let s=0;const a=()=>{cancelAnimationFrame(s),s=requestAnimationFrame(()=>{const c=Math.round(window.innerHeight-e.height-e.offsetTop);o(c>=vt?c:0)})};return a(),e.addEventListener("resize",a),e.addEventListener("scroll",a),()=>{cancelAnimationFrame(s),e.removeEventListener("resize",a),e.removeEventListener("scroll",a)}},[n]),i}function Ht({game:n,variant:i,onClose:o,playingNow:e,placement:s="overlay"}){const a=yt(i==="sheet"),c=s==="docked";return t.jsx("div",{"data-chat-panel":c?"docked":i,className:_("relative flex h-full min-h-0 w-full min-w-0 flex-col overflow-hidden text-foreground",c?"border-l border-border bg-background":i==="sheet"?"rounded-t-lg bg-card":"rounded-lg border border-border bg-card/95 shadow-2xl"),style:a?{paddingBottom:a}:void 0,children:t.jsx(r.Suspense,{fallback:t.jsx(he,{}),children:t.jsx(gt,{game:n,onClose:o,playingNow:e},n.public_id??n.id)})})}export{Ht 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.