1import{a as s,j as e,S as se,n as oe,a4 as q,B as le,aD as ie,a9 as ce,d as H,f as F}from"./ui-D5Ghu05p.js";import{f as de,s as Q,j as ue,u as me,B as E}from"./index-CeqavfCi.js";import{D as fe,a as pe,b as ge,c as he}from"./dialog-DewZO21w.js";import{d as xe,e as V}from"./roomSecurity-CnkJuVdZ.js";import{c as ye,u as we}from"./router-DbqBqNmK.js";import"./Combination-DAiRPxfE.js";const je={};function be(){return globalThis.crypto?.randomUUID?.()||`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function ve(r){const t=`gameClientId_${r}`;let n=sessionStorage.getItem(t);return n||(n=be(),sessionStorage.setItem(t,n)),n}function Ce(r){const t=je?.VITE_SIGNALING_URL||window?.__SIGNALING_URL__;if(t)return String(t);const n=window.location;return`${n.protocol}//${n.host}/php/room.php`}function K(r){try{const t=sessionStorage.getItem(`gameRole_${r}`)||localStorage.getItem(`gameRole_${r}`);if(t==="X"||t==="O")return t}catch{}return null}function Re(r,t){try{sessionStorage.setItem(`gameRole_${r}`,t),localStorage.setItem(`gameRole_${r}`,t)}catch{}}function Ne({roomId:r,onRoomFull:t}){const[n,p]=s.useState(!1),[S,y]=s.useState(!1),[b,g]=s.useState(()=>K(r)),[T,I]=s.useState([]),h=s.useRef(null),d=s.useRef(null),R=s.useRef(null),N=s.useRef(null),f=s.useRef(null),L=s.useRef(!1),$=s.useRef(!1),G=s.useRef(0),v=s.useRef([]),O=s.useRef(null),C=s.useCallback(o=>{O.current=o},[]),x=s.useCallback(async o=>{const u=h.current;if(u&&d.current)try{await fetch(`${u}?path=/room/signal`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roomId:r,from:d.current,data:o,roomType:"game"})})}catch(a){console.error("[GameRoom] Signal error:",a)}},[r]),l=s.useCallback(o=>{if(f.current?.readyState==="open")try{f.current.send(JSON.stringify(o));return}catch(u){console.warn("[GameRoom] DC send error, fallback to signal:",u)}x({type:"game-msg",msg:o})},[x]),w=s.useCallback(o=>{if(!o.trim())return;const u={type:"chat",text:o.trim(),sender:b||"X",timestamp:Date.now()};I(a=>[...a,{id:`${Date.now()}-${Math.random()}`,text:o.trim(),sender:"me",timestamp:Date.now()}]),l(u)},[b,l]),m=s.useCallback(o=>{console.log("[GameRoom] Setting up data channel"),f.current=o,o.binaryType="arraybuffer",o.onopen=()=>{console.log("[GameRoom] Data channel open"),p(!0),y(!0)},o.onclose=()=>{console.log("[GameRoom] Data channel closed"),p(!1)},o.onmessage=u=>{try{const a=JSON.parse(u.data);console.log("[GameRoom] Message received:",a.type),a.type==="chat"&&a.text?I(i=>[...i,{id:`${Date.now()}-${Math.random()}`,text:a.text,sender:"partner",timestamp:a.timestamp||Date.now()}]):O.current?.(a)}catch(a){console.error("[GameRoom] message parse error:",a)}}},[]),c=s.useCallback(async()=>{const o=h.current;if(o&&d.current)try{await fetch(`${o}?path=/room/leave`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roomId:r,clientId:d.current,roomType:"game"})})}catch{}try{f.current?.close()}catch{}try{N.current?.close()}catch{}N.current=null,f.current=null,p(!1),y(!1)},[r]),k=s.useCallback(async()=>{if(N.current)return N.current;console.log("[GameRoom] Creating peer connection with dynamic ICE");const o=await de(),u=ue(o),a=new RTCPeerConnection(u);return N.current=a,Q({pc:a,dataChannel:f.current,onRestartIceNeeded:async()=>{if(a.signalingState==="stable")try{console.log("[GameRoom] Creating ICE restart offer...");const i=await a.createOffer({iceRestart:!0});await a.setLocalDescription(i),x({type:"offer",sdp:i.sdp})}catch(i){console.error("[GameRoom] Error during ICE restart negotiation",i)}}}),a.onicecandidate=i=>{i.candidate&&x({type:"candidate",candidate:i.candidate})},a.ondatachannel=i=>{console.log("[GameRoom] Received remote data channel"),m(i.channel),Q({pc:a,dataChannel:i.channel})},a.onconnectionstatechange=()=>{console.log("[GameRoom] Connection state:",a.connectionState),a.connectionState==="connected"?(p(!0),y(!0)):(a.connectionState==="failed"||a.connectionState==="disconnected")&&p(!1)},a},[x,m]),te=s.useCallback(async o=>{if(console.log("[GameRoom] Handling signal:",o?.type),y(!0),o?.type==="game-msg"&&o?.msg){const a=o.msg;a.type==="chat"&&a.text?I(i=>[...i,{id:`${Date.now()}-${Math.random()}`,text:a.text,sender:"partner",timestamp:a.timestamp||Date.now()}]):O.current?.(a);return}const u=await k();if(o?.type==="offer"){for(await u.setRemoteDescription(new RTCSessionDescription(o));v.current.length>0;){const i=v.current.shift();if(i){console.log("[GameRoom] Applying queued ICE candidate");try{await u.addIceCandidate(i)}catch(_){console.error("[GameRoom] ICE candidate error:",_)}}}const a=await u.createAnswer();await u.setLocalDescription(a),await x({type:"answer",sdp:a.sdp})}else if(o?.type==="answer")for(await u.setRemoteDescription(new RTCSessionDescription(o));v.current.length>0;){const a=v.current.shift();if(a){console.log("[GameRoom] Applying queued ICE candidate");try{await u.addIceCandidate(a)}catch(i){console.error("[GameRoom] ICE candidate error:",i)}}}else if(o?.type==="candidate"&&o.candidate)if(!u.remoteDescription)console.log("[GameRoom] Queuing ICE candidate (no remote description yet)"),v.current.push(new RTCIceCandidate(o.candidate));else try{await u.addIceCandidate(new RTCIceCandidate(o.candidate))}catch(a){console.error("[GameRoom] Error adding ICE candidate, queuing:",a),v.current.push(new RTCIceCandidate(o.candidate))}},[k,x]),X=s.useRef(t);return s.useEffect(()=>{X.current=t},[t]),s.useEffect(()=>{if(!r)return;let o=!0;const u=Ce();return h.current=u,(async()=>{try{const a=ve(r);d.current=a,console.log("[GameRoom] Joining/Rejoining room:",r,"clientId:",a);let i=null;try{const j=await fetch(`${u}?path=/room/rejoin`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roomId:r,clientId:a,roomType:"game"})});if(j.ok){const W=await j.json();W.rejoined&&(console.log("[GameRoom] Successfully rejoined existing session"),i=W)}else if(j.status===403&&(await j.json().catch(()=>({}))).error==="room-full"){X.current?.();return}}
1catch(j){console.log("[GameRoom] Rejoin failed, will do fresh join:",j)}if(!i){const j=await fetch(`${u}?path=/room/join`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roomId:r,clientId:a,roomType:"game"})});if(i=await j.json(),!o)return;if(!j.ok&&i.error==="room-full"){X.current?.();return}if(!i.clientId)throw new Error("Failed to join")}d.current=i.clientId,sessionStorage.setItem(`gameClientId_${r}`,i.clientId),G.current=i.seq||0;let _=K(r);_||(_=i.isCreator?"X":"O",Re(r,_)),g(_),(!i.isCreator||i.hasPeer)&&y(!0),R.current?.abort();const J=new AbortController;R.current=J,(async()=>{let j=0;const W=10,ne=5e3;for(;!J.signal.aborted&&o;)try{const P=`${h.current}?path=/room/poll&roomId=${encodeURIComponent(r)}&clientId=${encodeURIComponent(d.current)}&since=${G.current}&roomType=game`,B=await(await fetch(P,{signal:J.signal})).json();if(!o)return;const re=B.events||[];G.current=B.seq||G.current;for(const D of re)if(D.from!==d.current){if(D.type==="peer-joined"&&(console.log("[GameRoom] Partner joined signaling"),y(!0),$.current=!0,await k()),D.type==="initiate"){console.log("[GameRoom] Received initiate - creating offer"),L.current=!0;const z=await k();if(!f.current){const M=z.createDataChannel("game");m(M)}try{const M=await z.createOffer();await z.setLocalDescription(M),await x({type:"offer",sdp:M.sdp}),console.log("[GameRoom] Offer created and sent on initiate")}catch(M){console.error("[GameRoom] Error creating offer:",M)}}D.type==="peer-left"&&(console.log("[GameRoom] Partner left"),y(!1),$.current=!1),D.type==="signal"&&await te(D.data)}const ae=f.current?.readyState==="open";let A;ae?(A=B.loadLevel==="high"?21e3:5e3,j=0):(j++,j>=W?(A=ne,j=0):A=1e3),await new Promise(D=>setTimeout(D,A))}catch(P){if(P?.name==="AbortError"||P instanceof DOMException&&P.name==="AbortError"||String(P).includes("AbortError")||!o)return;await new Promise(Y=>setTimeout(Y,3e3))}})().catch(()=>{})}catch(a){console.error("[GameRoom] Join error:",a)}})(),()=>{o=!1,console.log("[GameRoom] Cleaning up game room session"),R.current?.abort(),d.current&&h.current&&fetch(`${h.current}?path=/room/leave`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({roomId:r,clientId:d.current,roomType:"game"}),keepalive:!0}).catch(()=>{});try{f.current?.close()}catch{}try{N.current?.close()}catch{}N.current=null,f.current=null,p(!1),y(!1)}},[r]),{connected:n,partnerJoined:S,mySymbol:b,sendGameMessage:l,setOnGameMessage:C,chatMessages:T,sendChat:w,leave:c}}const U=()=>[[null,null,null,null],[null,null,null,null],[null,null,null,null],[null,null,null,null]],Z=r=>{for(let t=0;t<4;t++)for(let n=0;n<=1;n++)if(r[t][n]&&r[t][n]===r[t][n+1]&&r[t][n+1]===r[t][n+2])return{winner:r[t][n],line:{cells:[[t,n],[t,n+1],[t,n+2]],type:"row"}};for(let t=0;t<4;t++)for(let n=0;n<=1;n++)if(r[n][t]&&r[n][t]===r[n+1][t]&&r[n+1][t]===r[n+2][t])return{winner:r[n][t],line:{cells:[[n,t],[n+1,t],[n+2,t]],type:"col"}};for(let t=0;t<=1;t++)for(let n=0;n<=1;n++)if(r[t][n]&&r[t][n]===r[t+1][n+1]&&r[t+1][n+1]===r[t+2][n+2])return{winner:r[t][n],line:{cells:[[t,n],[t+1,n+1],[t+2,n+2]],type:"diag"}};for(let t=0;t<=1;t++)for(let n=2;n<=3;n++)if(r[t][n]&&r[t][n]===r[t+1][n-1]&&r[t+1][n-1]===r[t+2][n-2])return{winner:r[t][n],line:{cells:[[t,n],[t+1,n-1],[t+2,n-2]],type:"diag"}};return{winner:null,line:null}},ee=r=>r.every(t=>t.every(n=>n!==null)),ke=()=>{const r=["#ff0","#f0f","#0ff","#f00","#0f0","#00f","#ff6b6b","#4ecdc4"],t=Array.from({length:50},(n,p)=>({id:p,color:r[Math.floor(Math.random()*r.length)],left:Math.random()*100,delay:Math.random()*.5,duration:2+Math.random()*2,size:8+Math.random()*8}));return e.jsxs("div",{className:"fixed inset-0 pointer-events-none z-50 overflow-hidden",children:[t.map(n=>e.jsx("div",{className:"absolute animate-confetti",style:{left:`${n.left}%`,top:"-20px",width:`${n.size}px`,height:`${n.size}px`,backgroundColor:n.color,borderRadius:Math.random()>.5?"50%":"0%",animationDelay:`${n.delay}s`,animationDuration:`${n.duration}s`}},n.id)),e.jsx("style",{children:` 2 @keyframes confetti-fall { 3 0% { transform: translateY(0) rotate(0deg); opacity: 1; } 4 100% { transform: translateY(100vh) rotate(720deg); opacity: 0; } 5 } 6 .animate-confetti { 7 animation: confetti-fall linear forwards; 8 } 9 `})]})},Se=({winner:r,isMe:t,onClose:n})=>e.jsxs("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-40 animate-fade-in",children:[e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-3xl p-8 shadow-2xl max-w-sm mx-4 text-center transform animate-bounce-in",children:[e.jsx("div",{className:"text-6xl mb-4",children:t?"ððð":"ð¢"}),e.jsx("h2",{className:`text-3xl font-bold mb-2 ${t?"text-green-500":"text-red-500"}`,children:t?"Congratulations!":"Game Over"}),e.jsx("p",{className:"text-xl text-gray-600 dark:text-gray-300 mb-6",children:t?"You Won the Game!":`${r} Wins!`}),e.jsx("button",{onClick:n,className:"px-8 py-3 bg-gradient-to-r from-purple-500 to-indigo-600 text-white rounded-full font-semibold hover:from-purple-600 hover:to-indigo-700 transition-all shadow-lg",children:"Continue"})]}),e.jsx("style",{children:` 10 @keyframes fade-in { from { opacity: 0; } to { opacity: 1; } } 11 @keyframes bounce-in { 12 0% { transform: scale(0.5); opacity: 0; } 13 50% { transform: scale(1.1); } 14 100% { transform: scale(1); opacity: 1; } 15 } 16 .animate-fade-in { animation: fade-in 0.3s ease-out; } 17 .animate-bounce-in { animation: bounce-in 0.5s ease-out; } 18 `})]});function Te({mySymbol:r,onMove:t,isConnected:n}){const[p,S]=s.useState(U),[y,b]=s.useState("X"),[g,T]=s.useState(null),[I,h]=s.useState(null),[d,R]=s.useState(!1),[N,f]=s.useState(!1),[L,$]=s.useState(!1),G=s.useCallback((l,w)=>{if(!n||!r||p[l][w]!==null||y!==r||g||d)return;const m=p.map(k=>[...k]);m[l][w]=r,S(m),b(r==="X"?"O":"X"),t({type:"move",row:l,col:w,player:r});const c=Z(m);c.winner?(T(c.winner),h(c.line),c.winner===r?($(!0),setTimeout(()=>f(!0),500)):setTimeout(()=>f(!0),800)):ee(m)&&R(!0)},[p,y,r,g,d,n,t]),v=s.useCallback(l=>{l.type==="move"&&l.row!==void 0&&l.col!==void 0&&l.player?(S(w=>{const m=w.map(k=>[...k]);m[l.row][l.col]=l.player;const c=Z(m);return c.winner?(T(c.winner),h(c.line),setTimeout(()=>f(!0),800)):ee(m)&&R(!0),m}),b(l.player==="X"?"O":"X")):l.type==="reset"?(S(U()),b("X"),T(null),h(null),R(!1),f(!1),$(!1)):l.type==="sync"&&l.board&&S(l.board)},[]),O=s.useCallback(()=>{S(U()),b("X"),T(null),h(null),R(!1),f(!1),$(!1),t({type:"reset"})},[t]);s.useEffect(()=>(window.__gameMessageHandler=v,()=>{delete window.__gameMessageHandler}),[v]);const C=(l,w)=>I?I.cells.some(([m,c])=>m===l&&c===w):!1,x=y===r;return e.jsxs("div",{className:"flex flex-col items-center gap-4 relative",children:[L&&e.jsx(ke,{}),N&&g&&e.jsx(Se,{winner:g,isMe:g===r,onClose:()=>f(!1)}),e.jsxs("div",{className:"text-center",children:[n?g?e.jsx("p",{className:`text-xl font-bold ${g===r?"text-green-500":"text-red-500"}`,children:g===r?"ð You Won!":"ð¢ You Lost!"}):d?e.jsx("p",{className:"text-xl font-bold text-yellow-500",children:"ð¤ It's a Draw!"}):e.jsx("p",{className:`text-lg font-medium ${x?"text-purple-600":"text-gray-400"}`,children:x?"Your Turn!":"Partner's Turn..."}):e.jsx("p",{className:"text-gray-500",children:"Waiting for partner to connect..."}),r&&e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400 mt-1",children:["You are: ",e.jsx("span",{className:r==="X"?"text-gray-900 dark:text-white font-bold":"text-red-500 font-bold",children:r})]})]}),e.jsx("div",{className:"p-4 bg-gradient-to-br from-purple-100 to-indigo-100 dark:from-purple-900/30 dark:to-indigo-900/30 rounded-2xl shadow-xl relative",style:{display:"inline-grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"8px",width:"fit-content"},children:p.flat().map((l,w)=>
18{const m=Math.floor(w/4),c=w%4,k=C(m,c);return e.jsxs("button",{onClick:()=>G(m,c),disabled:!n||!x||l!==null||!!g||d,className:` 19 w-16 h-16 sm:w-20 sm:h-20 rounded-xl text-4xl font-bold 20 transition-all duration-300 transform relative 21 ${l===null&&x&&n&&!g&&!d?"bg-white dark:bg-gray-800 hover:bg-purple-200 dark:hover:bg-purple-800 hover:scale-105 cursor-pointer shadow-md":"bg-white/70 dark:bg-gray-800/70 cursor-not-allowed"} 22 ${l==="X"?"text-gray-900 dark:text-white":""} 23 ${l==="O"?"text-red-500":""} 24 ${k?"ring-4 ring-yellow-400 animate-pulse bg-yellow-100 dark:bg-yellow-900/50 scale-110":""} 25 border-2 border-purple-200 dark:border-purple-700 26 `,children:[l==="X"&&e.jsx("span",{className:"flex items-center justify-center",children:"â"}),l==="O"&&e.jsx("span",{className:"flex items-center justify-center",children:"â"})]},`${m}-${c}`)})}),e.jsx("p",{className:"text-xs text-purple-600 dark:text-purple-400 font-medium",children:"Get 3 in a line to win!"}),(g||d)&&n&&e.jsx("button",{onClick:O,className:"px-6 py-2 bg-gradient-to-r from-purple-500 to-indigo-600 text-white rounded-full font-semibold hover:from-purple-600 hover:to-indigo-700 transition-all shadow-lg",children:"Play Again"}),e.jsxs("div",{className:"flex items-center gap-6 text-sm text-gray-600 dark:text-gray-400",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-6 h-6 rounded bg-gray-100 dark:bg-gray-800 flex items-center justify-center text-gray-900 dark:text-white font-bold",children:"â"}),e.jsx("span",{children:"Player X (Black)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-6 h-6 rounded bg-gray-100 dark:bg-gray-800 flex items-center justify-center text-red-500 font-bold",children:"â"}),e.jsx("span",{children:"Player O (Red)"})]})]})]})}function Pe(){me("Tic-Tac-Toe - TransferWoW");const{id:r}=ye(),t=we(),[n,p]=s.useState(!1),[S,y]=s.useState(!1),[b,g]=s.useState(""),T=s.useRef(null),I=s.useRef(!0),{valid:h,roomId:d,isEncrypted:R}=s.useMemo(()=>xe(r||""),[r]);s.useEffect(()=>{h&&!R&&d&&window.history.replaceState(null,"",`/game/${V(d)}`)},[h,R,d]);const{connected:N,partnerJoined:f,mySymbol:L,sendGameMessage:$,setOnGameMessage:G,chatMessages:v,sendChat:O}=Ne({roomId:h?d:"",onRoomFull:()=>{alert("Room is full! Only 2 players can play together."),t("/game")}}),C=f||N,x=s.useCallback(c=>{window.__gameMessageHandler?.(c)},[]);s.useEffect(()=>{G(x)},[G,x]),s.useEffect(()=>{window.scrollTo(0,0)},[]),s.useEffect(()=>{if(I.current){I.current=!1;return}T.current?.scrollIntoView({behavior:"smooth"})},[v]);const l=typeof window<"u"?`${window.location.origin}/game/${V(d)}`:"",w=()=>{navigator.clipboard.writeText(l),p(!0),setTimeout(()=>p(!1),2e3)},m=()=>{b.trim()&&(O(b),g(""))};return!h||!d?e.jsx("div",{className:"min-h-screen flex items-center justify-center p-4 bg-background text-foreground",children:e.jsxs("div",{className:"w-full max-w-md p-6 text-center space-y-4 rounded-2xl bg-white dark:bg-gray-800 shadow-xl border border-red-500/30",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400 flex items-center justify-center mx-auto",children:e.jsx(se,{className:"w-6 h-6"})}),e.jsx("h2",{className:"text-xl font-bold",children:"Invalid Room Link"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"This game room URL is invalid, forged, or has expired."}),e.jsx(E,{onClick:()=>t("/game"),className:"w-full",children:"Back to Tic-Tac-Toe"})]})}):e.jsxs("main",{className:"min-h-screen bg-gradient-to-br from-purple-50 via-white to-indigo-50 dark:from-gray-900 dark:via-gray-800 dark:to-purple-900",children:[e.jsxs("div",{className:"container mx-auto px-4 py-4",children:[e.jsx("div",{className:"max-w-6xl mx-auto",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4",children:[e.jsx(E,{variant:"ghost",size:"icon",onClick:()=>
26t("/game"),className:"text-purple-600 hover:bg-purple-100 dark:hover:bg-purple-900 h-8 w-8 sm:h-10 sm:w-10",children:e.jsx(oe,{className:"w-4 h-4 sm:w-5 sm:h-5"})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-base sm:text-xl font-bold bg-gradient-to-r from-purple-600 to-indigo-500 bg-clip-text text-transparent flex items-center gap-1 sm:gap-2",children:[e.jsx(q,{className:"w-4 h-4 sm:w-5 sm:h-5 text-purple-600"}),"Tic-Tac-Toe"]}),e.jsxs("p",{className:"text-xl sm:text-2xl font-bold text-purple-600 dark:text-purple-400",children:["Room: ",d]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[e.jsxs("div",{className:`px-2 sm:px-3 py-1 rounded-full text-xs font-medium flex items-center gap-1 ${C?"bg-green-500/20 text-green-600 dark:text-green-400":"bg-yellow-500/20 text-yellow-600 dark:text-yellow-400"}`,children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${C?"bg-green-500 animate-pulse":"bg-yellow-500"}`}),e.jsx("span",{className:"hidden sm:inline",children:C?"Connected":"Waiting..."})]}),e.jsx(E,{variant:"ghost",size:"icon",onClick:()=>y(!0),className:"text-purple-600 hover:bg-purple-200 dark:hover:bg-purple-800 h-8 w-8",title:"Invite",children:e.jsx(le,{className:"w-4 h-4"})}),e.jsx(E,{variant:"ghost",size:"icon",onClick:()=>t("/game"),className:"text-red-600 hover:bg-red-200 dark:text-red-400 dark:hover:bg-red-900 h-8 w-8",title:"Leave",children:e.jsx(ie,{className:"w-4 h-4"})})]})]})}),e.jsxs("div",{className:"max-w-6xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 items-stretch justify-center",children:[e.jsx("div",{className:"flex flex-col items-center justify-center bg-white/50 dark:bg-gray-800/50 rounded-2xl p-4 shadow-xl border border-purple-200 dark:border-purple-700",children:e.jsx(Te,{mySymbol:L,onMove:$,isConnected:C})}),e.jsxs("div",{className:"w-full lg:w-96 bg-white/80 dark:bg-gray-800/80 rounded-2xl shadow-xl border border-purple-200 dark:border-purple-700 flex flex-col min-h-80",children:[e.jsx("div",{className:"px-4 py-3 border-b border-purple-200 dark:border-purple-700",children:e.jsx("h3",{className:"font-semibold text-purple-600 dark:text-purple-400",children:"ð¬ Game Chat"})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-2",children:[v.length===0?e.jsx("p",{className:"text-center text-gray-400 text-sm py-8",children:C?"Say hi to your partner! ð":"Chat will appear here..."}):v.map(c=>e.jsx("div",{className:`flex ${c.sender==="me"?"justify-end":"justify-start"}`,children:e.jsx("div",{className:`max-w-[80%] px-3 py-2 rounded-2xl text-sm ${c.sender==="me"?"bg-purple-500 text-white rounded-br-sm":"bg-gray-200 dark:bg-gray-700 text-gray-900 dark:text-white rounded-bl-sm"}`,children:c.text})},c.id)),e.jsx("div",{ref:T})]}),e.jsx("div",{className:"p-3 border-t border-purple-200 dark:border-purple-700",children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:b,onChange:c=>g(c.target.value),onKeyDown:c=>c.key==="Enter"&&m(),placeholder:C?"Type a message...":"Waiting for partner...",disabled:!C,className:"flex-1 px-3 py-2 text-sm bg-gray-100 dark:bg-gray-700 rounded-full border-0 focus:ring-2 focus:ring-purple-500 disabled:opacity-50"}),e.jsx(E,{onClick:m,disabled:!C||!b.trim(),size:"icon",className:"rounded-full bg-purple-500 hover:bg-purple-600 disabled:opacity-50",children:e.jsx(ce,{className:"w-4 h-4"})})]})})]})]}),!C&&e.jsxs("div",{className:"max-w-md mx-auto text-center mt-8 p-6 bg-white/50 dark:bg-gray-800/50 rounded-2xl",children:[e.jsx("h3",{className:"text-lg font-semibold text-purple-600 mb-2",children:"Waiting for Partner"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300 mb-4",children:"Share the room link with a friend to start playing!"}),e.jsxs(E,{onClick:w,className:"bg-purple-600 hover:bg-purple-700",children:[n?e.jsx(H,{className:"w-4 h-4 mr-2"}):e.jsx(F,{className:"w-4 h-4 mr-2"}),n?"Link Copied!":"Copy Room Link"]})]})]})]}),e.jsx(fe,{open:S,onOpenChange:y,children:e.jsxs(pe,{className:"sm:max-w-md",children:[e.jsx(ge,{children:e.jsxs(he,{className:"flex items-center gap-2 text-purple-600",children:[e.jsx(q,{className:"w-5 h-5"})," Invite to Game"]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-300",children:"Share this link:"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",readOnly:!0,value:l,className:"flex-1 px-3 py-2 text-sm bg-gray-100 dark:bg-gray-800 rounded-lg"}),e.jsx(E,{onClick:w,size:"sm",className:"bg-purple-600 hover:bg-purple-700",children:n?e.jsx(H,{className:"w-4 h-4"}):e.jsx(F,{className:"w-4 h-4"})})]}),e.jsxs("p",{className:"text-xs text-gray-500",children:["Room ID: ",d]})]})]})})]})}export{Pe 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.