(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{9634:function(e,s,t){Promise.resolve().then(t.bind(t,9434))},9434:function(e,s,t){"use strict";t.r(s),t.d(s,{default:function(){return I}});var a,l,r,i,o,n,c=t(7437),d=t(2265),x=t(6540),m=t(2167),h=t(5251),p=t(6691),u=t.n(p);(a=i||(i={})).MARLENE="marlene",a.CAPITAN_PHILIPPE="capitan_philippe",a.PARTISANO="partisano",a.COMANDANTE_SCHMIDT="comandante_schmidt",a.FRANCOTIRADOR="francotirador",a.AGENTE_DOBLE="agente_doble",a.INFILTRADO="infiltrado",a.COLABORACIONISTA="colaboracionista",(l=o||(o={})).ALIADOS="aliados",l.ALEMANES="alemanes",(r=n||(n={})).LOBBY="lobby",r.INTRO="intro",r.REVEAL_ROLE="reveal_role",r.ROLL_CALL="roll_call",r.VOTE_LEADER="vote_leader",r.TEAM_BUILDING="team_building",r.VOTING_TEAM="voting_team",r.MISSION="mission",r.MISSION_REVEAL="mission_reveal",r.MISSION_RESULT="mission_result",r.ASSASSIN_PHASE="assassin_phase",r.NAZIS_WIN="nazis_win",r.ALLIED_WIN="allied_win",r.GAME_OVER="game_over";let b={5:{good:3,evil:2,quests:[2,3,2,3,3]},6:{good:4,evil:2,quests:[2,3,4,3,4]},7:{good:4,evil:3,quests:[2,3,3,4,4]},8:{good:5,evil:3,quests:[3,4,4,5,5]},9:{good:6,evil:3,quests:[3,4,4,5,5]},10:{good:6,evil:4,quests:[3,4,4,5,5]}};function g(e){let{votes:s,onFinished:t}=e;return(0,d.useEffect)(()=>{let e=setTimeout(()=>{t&&t()},5e3);return()=>clearTimeout(e)},[t]),(0,c.jsxs)(h.E.div,{className:"fixed inset-0 flex flex-col items-center justify-center bg-black/95 z-50 pointer-events-auto",initial:{opacity:0},animate:{opacity:1},children:[(0,c.jsx)("h2",{className:"text-3xl font-bold text-white mb-12 uppercase tracking-widest drop-shadow-lg text-center",children:"Resultado de la misi\xf3n"}),(0,c.jsx)("div",{className:"flex gap-4 justify-center mb-12 flex-wrap max-w-[90vw]",children:s.map((e,s)=>(0,c.jsx)(h.E.div,{className:"w-32 h-48 rounded-xl flex items-center justify-center shadow-2xl relative overflow-hidden",initial:{scale:0,rotateY:180},animate:{scale:1,rotateY:0},transition:{delay:.3*s,type:"spring",stiffness:200,damping:20},children:(0,c.jsx)(u(),{src:e?"/assets/images/tokens/vote_approve.png":"/assets/images/tokens/vote_reject.png",alt:e?"\xc9xito":"Sabotaje",fill:!0,className:"object-contain"})},s))}),(0,c.jsx)(h.E.div,{className:"text-white text-xl font-mono mt-8 text-center",initial:{opacity:0},animate:{opacity:1},transition:{delay:.3*s.length+.5},children:(0,c.jsx)("span",{className:"animate-pulse",children:"Analizando resultado estrat\xe9gico..."})})]})}function f(e){let{gameState:s,onContinue:t,isHost:a}=e,l=s.missionHistory[s.missionHistory.length-1];if(!l)return(0,c.jsx)("div",{className:"fixed inset-0 flex items-center justify-center bg-black/90 z-50",children:(0,c.jsx)("p",{className:"text-white text-2xl",children:"Cargando resultado..."})});let{successes:r,fails:i,isSuccess:o}=l;return(0,c.jsxs)(h.E.div,{className:"fixed inset-0 flex flex-col items-center justify-center bg-transparent z-50 pt-8",initial:{opacity:0},animate:{opacity:1},children:[(0,c.jsx)(h.E.h2,{className:"text-3xl sm:text-4xl md:text-5xl lg:text-6xl xl:text-7xl font-bold mb-8 whitespace-nowrap px-4 ".concat(o?"text-blue-500":"text-red-500"),initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:200,delay:.2},children:o?"\xa1MISI\xd3N EXITOSA!":"MISI\xd3N FALLIDA"}),(0,c.jsxs)(h.E.div,{className:"text-white text-3xl mb-8 bg-black/50 p-6 rounded-xl",initial:{y:50,opacity:0},animate:{y:0,opacity:1},transition:{delay:.5},children:[(0,c.jsxs)("p",{className:"mb-2",children:["✓ \xc9xitos: ",(0,c.jsx)("span",{className:"text-blue-400 font-bold",children:r})]}),(0,c.jsxs)("p",{children:["✗ Sabotajes: ",(0,c.jsx)("span",{className:"text-red-400 font-bold",children:i})]})]}),(0,c.jsxs)(h.E.div,{className:"text-white text-xl mb-8",initial:{opacity:0},animate:{opacity:1},transition:{delay:1},children:[(0,c.jsxs)("p",{children:["Misi\xf3n ",s.currentRound," de 5"]}),(0,c.jsxs)("p",{className:"text-gray-400 text-sm mt-2",children:["Resistencia: ",s.missionHistory.filter(e=>e.isSuccess).length," | Esp\xedas: ",s.missionHistory.filter(e=>!e.isSuccess).length]})]}),a?(0,c.jsx)(h.E.button,{onClick:t,className:"bg-gradient-to-r from-yellow-600 to-yellow-700 hover:from-yellow-500 hover:to-yellow-600 text-white font-bold py-4 px-8 rounded-lg text-lg shadow-lg transform transition-all hover:scale-105",initial:{y:50,opacity:0},animate:{y:0,opacity:1},transition:{delay:1.5},whileHover:{scale:1.05},whileTap:{scale:.95},children:"CONTINUAR →"}):(0,c.jsx)(h.E.div,{className:"text-white text-lg font-mono bg-black/50 px-6 py-3 rounded-full border border-white/20 animate-pulse",initial:{y:50,opacity:0},animate:{y:0,opacity:1},transition:{delay:1.5},children:"Esperando al comandante..."})]})}function v(e){let{gameState:s,isHost:t,onRestart:a,onFinalize:l}=e,[r,i]=(0,d.useState)(30),n=s.winner===o.ALEMANES;return(0,d.useEffect)(()=>{let e=setInterval(()=>{i(e=>e<=1?(l(),0):e-1)},1e3);return()=>clearInterval(e)},[l]),(0,c.jsxs)(h.E.div,{className:"fixed inset-0 flex flex-col items-center justify-center z-50 relative",initial:{opacity:0},animate:{opacity:1},children:[(0,c.jsxs)(h.E.div,{className:"text-center mb-12 relative z-10",initial:{scale:0},animate:{scale:1},transition:{type:"spring",stiffness:200,delay:.2},children:[(0,c.jsx)("h1",{className:"text-[4rem] md:text-[4.5rem] font-bold mb-4 drop-shadow-[0_4px_8px_rgba(0,0,0,0.9)] ".concat(n?"text-red-600":"text-blue-500"),children:n?"\xa1VICTORIA NAZI!":"\xa1VICTORIA ALIADA!"}),(0,c.jsx)("p",{className:"text-3xl text-white drop-shadow-[0_4px_8px_rgba(0,0,0,0.9)] font-bold",children:n?"Los Nazis han conquistado Francia":"La Resistencia ha triunfado"})]}),(0,c.jsx)(h.E.div,{className:"bg-black/70 p-8 rounded-xl border-2 border-white/30 mb-8 max-w-2xl relative z-10 backdrop-blur-sm",initial:{y:50,opacity:0},animate:{y:0,opacity:1},transition:{delay:.5},children:(0,c.jsxs)("div",{className:"grid grid-cols-2 gap-6 text-center",children:[(0,c.jsxs)("div",{children:[(0,c.jsx)("p",{className:"text-gray-300 text-sm uppercase mb-2 font-bold",children:"Misiones Exitosas"}),(0,c.jsx)("p",{className:"text-4xl font-bold text-blue-400",children:s.questResults.filter(e=>!0===e).length})]}),(0,c.jsxs)("div",{children:[(0,c.jsx)("p",{className:"text-gray-300 text-sm uppercase mb-2 font-bold",children:"Misiones Fracasadas"}),(0,c.jsx)("p",{className:"text-4xl font-bold text-red-400",children:s.questResults.filter(e=>!1===e).length})]})]})}),t?(0,c.jsxs)(h.E.div,{className:"flex flex-col items-center gap-4 relative z-10",initial:{y:50,opacity:0},animate:{y:0,opacity:1},transition:{delay:1},children:[(0,c.jsxs)("p",{className:"text-yellow-400 font-bold text-2xl mb-2 drop-shadow-[0_2px_4px_rgba(0,0,0,0.9)] bg-black/50 px-6 py-2 rounded-full",children:["⏱️ Tiempo restante: ",r,"s"]}),(0,c.jsxs)("div",{className:"flex gap-6",children:[(0,c.jsx)(h.E.button,{onClick:a,className:"bg-green-600 hover:bg-green-500 text-white font-bold py-3 px-6 rounded-xl text-lg shadow-2xl border-2 border-green-400",whileHover:{scale:1.1},whileTap:{scale:.95},children:"\uD83D\uDD04 NUEVA PARTIDA"}),(0,c.jsx)(h.E.button,{onClick:l,className:"bg-red-600 hover:bg-red-500 text-white font-bold py-3 px-6 rounded-xl text-lg shadow-2xl border-2 border-red-400",whileHover:{scale:1.1},whileTap:{scale:.95},children:"❌ TERMINAR"})]}),(0,c.jsx)("p",{className:"text-white text-base mt-2 bg-black/60 px-6 py-2 rounded-full drop-shadow-[0_2px_4px_rgba(0,0,0,0.9)]",children:"Si no decides, la partida terminar\xe1 autom\xe1ticamente"})]}):(0,c.jsxs)(h.E.div,{className:"text-center relative z-10",initial:{y:50,opacity:0},animate:{y:0,opacity:1},transition:{delay:1},children:[(0,c.jsx)("p",{className:"text-white text-2xl font-mono bg-black/50 px-8 py-4 rounded-full border border-white/20 animate-pulse",children:"Esperando decisi\xf3n del comandante..."}),(0,c.jsxs)("p",{className:"text-gray-500 text-sm mt-4",children:["Tiempo restante: ",r,"s"]})]})]})}function w(e){let{onExit:s,playerName:t}=e,[a,l]=(0,d.useState)(!1);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(h.E.button,{onClick:()=>l(!0),whileHover:{scale:1.05},whileTap:{scale:.95},className:"fixed top-4 right-0 z-50 bg-gradient-to-l from-green-600 to-green-700 hover:from-green-500 hover:to-green-600 text-white rounded-l-lg px-2 py-3 shadow-lg border-2 border-green-500 border-r-0 transition-all hover:shadow-green-500/50",title:"Volver al lobby",children:(0,c.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:3,stroke:"currentColor",className:"w-4 h-4",children:(0,c.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25"})})}),a&&(0,c.jsx)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/80 backdrop-blur-sm",children:(0,c.jsxs)(h.E.div,{initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},className:"bg-zinc-900 p-6 rounded-lg border border-red-700/50 w-full max-w-md mx-4 shadow-2xl",children:[(0,c.jsx)("h3",{className:"text-xl font-bold text-red-400 mb-4 uppercase flex items-center gap-2",children:"⚠️ Abandonar Partida"}),(0,c.jsx)("p",{className:"text-gray-300 mb-2",children:"\xbfEst\xe1s seguro de que quieres abandonar la partida?"}),(0,c.jsx)("p",{className:"text-sm text-gray-400 mb-6",children:"La partida se cerrar\xe1 para todos los jugadores y se perder\xe1 todo el progreso."}),(0,c.jsxs)("div",{className:"flex gap-3",children:[(0,c.jsx)("button",{onClick:()=>l(!1),className:"flex-1 py-3 bg-gray-700 hover:bg-gray-600 text-white rounded font-bold uppercase text-sm transition-colors",children:"Cancelar"}),(0,c.jsx)("button",{onClick:()=>{l(!1),s()},className:"flex-1 py-3 bg-red-900 hover:bg-red-800 text-white rounded font-bold uppercase text-sm transition-colors",children:"Salir"})]})]})})]})}function j(e){var s,t,a,l;let{gameState:r,currentPlayerId:i,actions:x,fullPlayerName:p}=e,[j,y]=(0,d.useState)([]),[k,I]=(0,d.useState)(!1),[_]=(0,d.useState)(()=>Math.random()>.5),[E,S]=(0,d.useState)(null),[A,L]=(0,d.useState)(null),[C,R]=(0,d.useState)(!0),[T,O]=(0,d.useState)(!0);(0,d.useEffect)(()=>{if("reveal_role"===r.phase){let e=setTimeout(()=>{x.finishReveal()},1e4);return()=>clearTimeout(e)}},[r.phase,x]),(0,d.useEffect)(()=>{r.phase!==n.MISSION&&S(null)},[r.phase]),(0,d.useEffect)(()=>{r.phase!==n.TEAM_BUILDING&&y([])},[r.phase,r.currentLeaderId]);let[z,M]=(0,d.useState)(!1);(0,d.useEffect)(()=>{r.phase===n.MISSION_RESULT?M(!0):M(!1)},[r.phase]);let D=r.players.find(e=>e.id===i),P=r.currentLeaderId===i,G=b[r.players.length],H=null==G?void 0:G.quests[r.currentRound-1],F=e=>{j.includes(e)?y(j.filter(s=>s!==e)):j.length{S(e),x.voteMission(e)},q=r.hostId===i;if("intro"===r.phase)return(0,c.jsxs)("div",{className:"relative w-full h-screen flex flex-col items-center justify-center bg-black overflow-hidden text-white",children:[(0,c.jsxs)("div",{className:"absolute inset-0 z-0",children:[(0,c.jsx)(u(),{src:"/assets/images/ui/bg_intro.png",alt:"Battlefield",fill:!0,className:"object-cover"}),(0,c.jsx)("div",{className:"absolute inset-0 bg-black/40"})]}),(0,c.jsx)("h1",{className:"z-10 text-[2.55rem] font-bold uppercase tracking-[0.3em] mb-8 text-yellow-500 drop-shadow-lg text-center",children:"Traici\xf3n en Par\xeds"}),q&&(0,c.jsx)("audio",{src:"/assets/audio/Intro.ogg",autoPlay:!0,onEnded:()=>x.finishIntro()}),q&&(0,c.jsx)("button",{onClick:()=>x.finishIntro(),className:"z-10 bg-white/20 hover:bg-white/40 border border-white px-6 py-2 rounded text-sm uppercase tracking-widest backdrop-blur-sm transition-all",children:"Omitir Introducci\xf3n"})]});if("reveal_role"===r.phase){let e="/assets/images/characters/good_soldier_1.png",s=null==D?void 0:D.role;if("marlene"===s)e="/assets/images/characters/good_merlin.png";else if("francotirador"===s)e="/assets/images/characters/evil_assassin.png";else if("capitan_philippe"===s)e="/assets/images/characters/good_percival.png";else if("agente_doble"===s)e="/assets/images/characters/evil_morgana.png";else if("comandante_schmidt"===s)e="/assets/images/characters/evil_mordred.png";else if("infiltrado"===s)e="/assets/images/characters/evil_oberon.png";else if("partisano"===s){let s=i.charCodeAt(0)%5+1;e="/assets/images/characters/good_soldier_".concat(s,".png")}else if("colaboracionista"===s){let s=i.charCodeAt(0)%3+1;e="/assets/images/characters/evil_minion_".concat(s,".png")}return(0,c.jsxs)("div",{className:"relative w-full h-screen flex flex-col items-center justify-center bg-black overflow-hidden text-white font-mono",children:[(0,c.jsxs)("div",{className:"absolute inset-0 z-0",children:[(0,c.jsx)(u(),{src:"/assets/images/ui/bg_roll_call.png",alt:"Resistance HQ",fill:!0,className:"object-cover"}),(0,c.jsx)("div",{className:"absolute inset-0 bg-black/70"})]}),(0,c.jsxs)("div",{className:"z-10 flex flex-col items-center gap-8",children:[(0,c.jsx)("h2",{className:"text-2xl uppercase tracking-[0.2em] text-gray-300",children:"Tu Identidad Secreta"}),(0,c.jsx)("p",{className:"text-sm text-gray-400 mb-4 animate-pulse",children:"Desliza hacia arriba para revelar"}),(0,c.jsxs)("div",{className:"relative w-64 h-96 perspective-1000",children:[(0,c.jsxs)("div",{className:"absolute inset-0 w-full h-full rounded-xl overflow-hidden shadow-2xl border-4 border-yellow-600 bg-gray-900 flex items-center justify-center",children:[(0,c.jsx)(u(),{src:e,alt:"Role",fill:!0,className:"object-cover"}),(0,c.jsx)("div",{className:"absolute bottom-0 w-full bg-black/80 text-center py-2 font-bold text-yellow-500 uppercase",children:null==s?void 0:s.replace("_"," ")})]}),(0,c.jsx)(h.E.div,{drag:"y",dragConstraints:{top:-300,bottom:0},dragElastic:.5,dragSnapToOrigin:!0,whileHover:{scale:1.02},whileTap:{scale:.98,cursor:"grabbing"},className:"absolute inset-0 w-full h-full rounded-xl overflow-hidden shadow-2xl z-20 cursor-grab active:cursor-grabbing hover:ring-2 hover:ring-white/50 transition-all",children:(0,c.jsx)(u(),{src:"/assets/images/characters/card_back.png",alt:"Card Back",fill:!0,className:"object-cover pointer-events-none"})})]})]})]})}return"roll_call"===r.phase?(0,c.jsxs)("div",{className:"relative w-full h-screen flex flex-col bg-black overflow-hidden text-white font-mono",children:[(0,c.jsxs)("div",{className:"absolute inset-0 z-0",children:[(0,c.jsx)(u(),{src:"/assets/images/ui/bg_roll_call.png",alt:"Resistance HQ",fill:!0,className:"object-cover"}),(0,c.jsx)("div",{className:"absolute inset-0 bg-black/70"})]}),(0,c.jsx)("div",{className:"relative z-10 w-full h-[20vh] flex items-center justify-center px-4 border-b border-gray-600/50 bg-black/20 backdrop-blur-sm",children:(0,c.jsx)("h2",{className:"text-2xl md:text-3xl lg:text-4xl text-center uppercase tracking-[0.2em] text-gray-300 drop-shadow-lg",children:"Pasando Lista..."})}),(0,c.jsxs)("div",{className:"relative z-10 w-full flex-1 overflow-y-auto p-4 flex flex-col items-center",children:[q&&(0,c.jsx)("audio",{src:"/assets/audio/Rondas.mp3",autoPlay:!0,onEnded:()=>x.finishRollCall()}),(0,c.jsx)("div",{className:"w-full max-w-6xl grid grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-3 md:gap-8 justify-items-center content-center py-4",children:r.players.map((e,s)=>(0,c.jsxs)(h.E.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{delay:.3*s},className:"flex flex-col items-center gap-1 md:gap-3 w-full",children:[(0,c.jsx)("div",{className:"w-20 h-20 md:w-32 md:h-32 rounded-full border-2 md:border-4 border-gray-400 overflow-hidden relative shadow-2xl bg-black",children:(0,c.jsx)(u(),{src:"/assets/images/characters/".concat(e.avatar),alt:"Avatar",fill:!0,className:"object-cover grayscale contrast-125"})}),(0,c.jsx)("div",{className:"bg-black/80 px-2 py-0.5 md:px-4 md:py-1 rounded border border-white/20 text-xs md:text-xl font-bold text-yellow-500 uppercase text-center w-full truncate max-w-[120px] md:max-w-none",children:e.name})]},e.id))})]})]}):(0,c.jsxs)("div",{className:"relative w-full h-screen flex flex-col overflow-hidden",children:[r.phase!==n.ALLIED_WIN&&r.phase!==n.NAZIS_WIN&&(0,c.jsx)(w,{onExit:()=>x.leaveGame(),playerName:p}),(0,c.jsxs)("div",{className:"absolute inset-0 z-0 opacity-40",children:[(0,c.jsx)(u(),{src:r.phase===n.ALLIED_WIN?"/assets/images/tokens/mission_success.png":r.phase===n.NAZIS_WIN?"/assets/images/tokens/mission_fail.png":"/assets/images/ui/bg_game.png",alt:"Game Background",fill:!0,className:"object-cover"}),(0,c.jsx)("div",{className:"absolute inset-0 bg-black/60"})]}),(0,c.jsxs)("div",{className:"relative z-10 w-full flex flex-col items-center pb-32",children:[r.phase!==n.ALLIED_WIN&&r.phase!==n.NAZIS_WIN&&(0,c.jsx)("div",{className:"relative w-full max-w-5xl aspect-video mt-4 shadow-2xl border-4 border-gray-800 rounded-lg overflow-hidden bg-[#2a2a2a]",children:r.phase===n.ASSASSIN_PHASE?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(u(),{src:"/assets/images/tokens/lastshot.jpg",alt:"Last Shot",fill:!0,className:"object-cover",priority:!0}),(0,c.jsx)("div",{className:"absolute inset-0 bg-black/40"}),(0,c.jsxs)("div",{className:"absolute top-1/3 left-0 right-0 flex flex-col items-center z-10",children:[(0,c.jsx)("h1",{className:"text-5xl font-bold text-red-600 mb-2 drop-shadow-[0_4px_8px_rgba(0,0,0,0.9)]",children:"\xa1\xdaLTIMA OPORTUNIDAD!"}),(null==D?void 0:D.role)==="francotirador"?(0,c.jsxs)("p",{className:"text-xl text-white drop-shadow-[0_2px_4px_rgba(0,0,0,0.9)] font-bold",children:["Francotirador, elige a qui\xe9n crees que es ",(0,c.jsx)("span",{className:"text-yellow-400",children:"MARLENE"})]}):(0,c.jsx)("p",{className:"text-xl text-gray-300 drop-shadow-[0_2px_4px_rgba(0,0,0,0.9)] font-bold",children:"El Francotirador est\xe1 decidiendo..."})]})]}):z?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(u(),{src:"/assets/images/ui/board_map.jpg",alt:"Tactical Map",fill:!0,className:"object-contain"}),[{left:"18%",top:"60%"},{left:"25%",top:"18%"},{left:"50%",top:"75%"},{left:"50%",top:"30%"},{left:"80%",top:"45%"}].map((e,s)=>{let t=r.questResults[s],a=r.currentRound===s+1;return(0,c.jsxs)("div",{className:"absolute w-[10%] aspect-square flex items-center justify-center",style:{left:e.left,top:e.top,transform:"translate(-50%, -50%)"},children:[a&&(0,c.jsx)(h.E.div,{layoutId:"round-marker",className:"absolute inset-0 z-10",initial:{scale:1.5,opacity:0},animate:{scale:1,opacity:1},transition:{type:"spring",stiffness:300,damping:20},children:(0,c.jsx)(u(),{src:"/assets/images/tokens/marker_round.png",alt:"Current Round",fill:!0,className:"object-contain drop-shadow-lg"})}),!0===t&&(0,c.jsx)(h.E.div,{initial:{scale:0},animate:{scale:1},className:"absolute inset-0 z-20 flex items-center justify-center",children:(0,c.jsx)("div",{className:"w-[80%] h-[80%] relative",children:(0,c.jsx)(u(),{src:"/assets/images/tokens/marker_score_blue.png",alt:"Success",fill:!0,className:"object-contain drop-shadow-lg"})})}),!1===t&&(0,c.jsx)(h.E.div,{initial:{scale:0},animate:{scale:1},className:"absolute inset-0 z-20 flex items-center justify-center",children:(0,c.jsx)("div",{className:"w-[80%] h-[80%] relative",children:(0,c.jsx)(u(),{src:"/assets/images/tokens/marker_score_red.png",alt:"Fail",fill:!0,className:"object-contain drop-shadow-lg"})})})]},s)})]}):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(u(),{src:"/assets/images/missions/mission".concat(r.currentRound,".png"),alt:"Mission ".concat(r.currentRound),fill:!0,className:"object-contain"}),(0,c.jsxs)("div",{className:"absolute top-4 left-0 right-0 flex flex-col items-center z-10",children:[(0,c.jsxs)("h2",{className:"text-4xl font-bold text-white drop-shadow-[0_4px_8px_rgba(0,0,0,0.8)] mb-2 uppercase tracking-wider",children:["Misi\xf3n ",r.currentRound]}),(0,c.jsx)("h3",{className:"text-2xl font-semibold text-yellow-400 drop-shadow-[0_4px_8px_rgba(0,0,0,0.8)] uppercase tracking-wide",children:["Sabotaje en el Tren","Rescate del Prisionero","Destrucci\xf3n del Puente","Robo de Documentos","Asalto al Cuartel General"][r.currentRound-1]})]})]})}),(0,c.jsx)("div",{className:"flex-1 w-full max-w-6xl relative mt-4 px-4",children:(0,c.jsxs)(m.M,{mode:"wait",children:["vote_leader"===r.phase&&(0,c.jsxs)(h.E.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"flex flex-col items-center gap-6",children:[(0,c.jsxs)("div",{className:"bg-black/80 p-4 rounded text-white text-center border border-yellow-500/50 relative",children:[(0,c.jsx)("h3",{className:"text-xl font-mono mb-2 text-yellow-500 uppercase tracking-widest",children:"Confirmar L\xedder"}),(0,c.jsxs)("div",{className:"text-2xl font-bold mb-2",children:["\xbfAceptas a ",(0,c.jsx)("span",{className:"text-yellow-400",children:null===(s=r.players.find(e=>e.id===r.currentLeaderId))||void 0===s?void 0:s.name})," como L\xedder?"]}),!(null===(t=r.leaderVotes)||void 0===t?void 0:t[i])&&(0,c.jsx)(N,{},r.currentLeaderId)]}),(null===(a=r.leaderVotes)||void 0===a?void 0:a[i])===void 0?(0,c.jsxs)("div",{className:"flex gap-8",children:[(0,c.jsxs)("button",{onClick:()=>x.voteLeader(!0),className:"group",children:[(0,c.jsx)("div",{className:"w-32 h-32 bg-white rounded-lg shadow-xl flex items-center justify-center border-4 border-transparent group-hover:border-green-500 transition-all transform group-hover:-translate-y-4 relative overflow-hidden",children:(0,c.jsx)(u(),{src:"/assets/images/tokens/accept_leader.png",alt:"Accept Leader",fill:!0,className:"object-contain"})}),(0,c.jsx)("span",{className:"block text-center text-white mt-2 font-bold bg-green-600 px-2 rounded uppercase tracking-widest",children:"ACEPTAR"})]}),(0,c.jsxs)("button",{onClick:()=>x.voteLeader(!1),className:"group",children:[(0,c.jsx)("div",{className:"w-32 h-32 bg-white rounded-lg shadow-xl flex items-center justify-center border-4 border-transparent group-hover:border-red-500 transition-all transform group-hover:-translate-y-4 relative overflow-hidden",children:(0,c.jsx)(u(),{src:"/assets/images/tokens/deny_leader.png",alt:"Deny Leader",fill:!0,className:"object-contain"})}),(0,c.jsx)("span",{className:"block text-center text-white mt-2 font-bold bg-red-600 px-2 rounded uppercase tracking-widest",children:"RECHAZAR"})]})]}):(0,c.jsx)("div",{className:"text-white text-xl font-mono animate-pulse bg-black/50 px-6 py-3 rounded-full border border-white/20",children:"VOTO REGISTRADO. ESPERANDO AL RESTO..."})]},"vote-leader"),r.phase===n.TEAM_BUILDING&&(0,c.jsxs)(h.E.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"flex flex-col items-center gap-6 w-full max-w-4xl",children:[!P&&(0,c.jsx)("div",{className:"bg-yellow-600/90 text-black p-2 rounded-lg shadow-xl border-4 border-yellow-400 w-full text-center mb-2",children:(0,c.jsx)("div",{className:"flex items-center justify-center gap-3",children:(0,c.jsxs)("div",{children:[(0,c.jsx)("div",{className:"text-xs uppercase tracking-wider font-bold",children:"L\xedder Actual"}),(0,c.jsx)("div",{className:"text-xl font-bold",children:(null===(l=r.players.find(e=>e.id===r.currentLeaderId))||void 0===l?void 0:l.name)||"Desconocido"})]})})}),(0,c.jsxs)("div",{className:"bg-paper-bg text-black p-4 md:p-6 rounded shadow-2xl w-full text-center",children:[(0,c.jsx)("h2",{className:"text-xl md:text-2xl font-bold font-mono mb-2 uppercase text-resistance-blue",children:P?"\uD83C\uDFAF TU TURNO: ELIGE TU EQUIPO":"⏳ ESPERANDO AL L\xcdDER..."}),P&&(0,c.jsxs)("p",{className:"mb-4 font-serif italic text-gray-700",children:["Se necesitan ",(0,c.jsxs)("span",{className:"font-bold text-red-700 text-xl",children:[H," agentes"]})," para la misi\xf3n #",r.currentRound,"."]}),P&&(0,c.jsxs)("div",{className:"mb-4 text-lg font-bold",children:["Seleccionados: ",(0,c.jsxs)("span",{className:j.length===H?"text-green-600":"text-orange-600",children:[j.length," / ",H]})]}),P&&(0,c.jsx)("button",{onClick:()=>x.proposeTeam(j),disabled:j.length!==H,className:"w-full bg-resistance-blue text-white font-bold py-3 px-4 rounded hover:bg-blue-900 transition-colors disabled:opacity-50 disabled:cursor-not-allowed uppercase tracking-widest shadow-lg",children:j.length===H?"✓ CONFIRMAR EQUIPO":"Selecciona ".concat(H-j.length," m\xe1s")}),!P&&(0,c.jsx)("div",{className:"text-gray-600 animate-pulse",children:"El l\xedder est\xe1 seleccionando el equipo de misi\xf3n..."})]})]},"team-building"),r.phase===n.VOTING_TEAM&&(0,c.jsxs)(h.E.div,{initial:{scale:.8,opacity:0},animate:{scale:1,opacity:1},className:"flex flex-col items-center gap-6",children:[(0,c.jsxs)("div",{className:"bg-black/80 p-4 rounded text-white text-center border border-white/20",children:[(0,c.jsx)("h3",{className:"text-xl font-mono mb-2 text-yellow-500",children:"PROPUESTA DE MISI\xd3N"}),(0,c.jsx)("div",{className:"flex gap-2 justify-center",children:r.proposedTeam.map(e=>{let s=r.players.find(s=>s.id===e);return(0,c.jsx)("div",{className:"bg-white/10 px-3 py-1 rounded text-sm",children:null==s?void 0:s.name},e)})})]}),void 0===r.teamVotes[i]?(0,c.jsxs)("div",{className:"flex gap-8",children:[(0,c.jsx)("button",{onClick:()=>x.voteTeam(!0),className:"group",children:(0,c.jsxs)("div",{className:"w-32 h-48 bg-white rounded-lg shadow-xl flex flex-col items-center justify-center border-2 border-blue-500 group-hover:border-blue-400 group-hover:shadow-blue-500/50 transition-all transform group-hover:-translate-y-4 relative overflow-hidden p-2",children:[(0,c.jsx)("span",{className:"text-blue-600 font-bold text-sm uppercase tracking-wider mb-1 z-10",children:"\xc9xito"}),(0,c.jsx)("div",{className:"relative w-full h-full flex items-center justify-center",children:(0,c.jsx)(u(),{src:"/assets/images/tokens/vote_approve.png",alt:"Approve",fill:!0,className:"object-contain"})})]})}),(0,c.jsx)("button",{onClick:()=>x.voteTeam(!1),className:"group",children:(0,c.jsxs)("div",{className:"w-32 h-48 bg-white rounded-lg shadow-xl flex flex-col items-center justify-center border-2 border-red-500 group-hover:border-red-400 group-hover:shadow-red-500/50 transition-all transform group-hover:-translate-y-4 relative overflow-hidden p-2",children:[(0,c.jsx)("span",{className:"text-red-600 font-bold text-sm uppercase tracking-wider mb-1 z-10",children:"Fracaso"}),(0,c.jsx)("div",{className:"relative w-full h-full flex items-center justify-center",children:(0,c.jsx)(u(),{src:"/assets/images/tokens/vote_reject.png",alt:"Reject",fill:!0,className:"object-contain"})})]})})]}):(0,c.jsx)("div",{className:"text-white text-xl font-mono animate-pulse",children:"VOTO REGISTRADO. ESPERANDO AL RESTO... ```"})]},"voting"),r.phase===n.MISSION&&(0,c.jsx)(h.E.div,{className:"fixed inset-0 flex items-start justify-center bg-black/90 z-50 pt-20",initial:{opacity:0},animate:{opacity:1},children:r.proposedTeam.includes(i)?(0,c.jsxs)("div",{className:"flex flex-col items-center gap-4 w-full max-w-6xl px-4",children:[(0,c.jsx)("h2",{className:"text-4xl md:text-5xl font-bold text-white mb-2 drop-shadow-2xl text-center uppercase tracking-wider animate-pulse",children:"\uD83C\uDFAF REALIZA LA MISI\xd3N"}),(0,c.jsx)("p",{className:"text-white text-xl mb-2 text-center",children:"Elige si quieres un \xe9xito o un fracaso"}),(0,c.jsx)("div",{className:"flex gap-12 flex-wrap justify-center",children:_?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("button",{onClick:()=>V(!0),className:"group transition-opacity ".concat(!0===E?"opacity-100":"opacity-50"),disabled:null!==E,children:(0,c.jsxs)(h.E.div,{className:"w-32 h-48 bg-gradient-to-br from-blue-600 to-blue-900 rounded-2xl shadow-2xl border-4 border-blue-400 flex flex-col items-center justify-center p-4 transform transition-all hover:scale-110 hover:rotate-3 hover:shadow-blue-500/50",whileHover:{scale:1.1,rotate:3},whileTap:{scale:.95},children:[(0,c.jsx)(u(),{src:"/assets/images/tokens/vote_approve.png",alt:"Success",width:80,height:80,className:"drop-shadow-2xl"}),(0,c.jsx)("span",{className:"mt-2 text-white font-bold text-lg tracking-widest uppercase",children:"\xc9XITO"})]})}),(null==D?void 0:D.faction)===o.ALEMANES&&(0,c.jsx)("button",{onClick:()=>V(!1),className:"group transition-opacity ".concat(!1===E?"opacity-100":"opacity-50"),disabled:null!==E,children:(0,c.jsxs)(h.E.div,{className:"w-32 h-48 bg-gradient-to-br from-red-600 to-red-900 rounded-2xl shadow-2xl border-4 border-red-400 flex flex-col items-center justify-center p-4 transform transition-all hover:scale-110 hover:-rotate-3 hover:shadow-red-500/50",whileHover:{scale:1.1,rotate:-3},whileTap:{scale:.95},children:[(0,c.jsx)(u(),{src:"/assets/images/tokens/vote_reject.png",alt:"Fail",width:80,height:80,className:"drop-shadow-2xl"}),(0,c.jsx)("span",{className:"mt-2 text-white font-bold text-lg tracking-widest uppercase",children:"SABOTAJE"})]})})]}):(0,c.jsxs)(c.Fragment,{children:[(null==D?void 0:D.faction)===o.ALEMANES&&(0,c.jsx)("button",{onClick:()=>V(!1),className:"group transition-opacity ".concat(!1===E?"opacity-100":"opacity-50"),disabled:null!==E,children:(0,c.jsxs)(h.E.div,{className:"w-32 h-48 bg-gradient-to-br from-red-600 to-red-900 rounded-2xl shadow-2xl border-4 border-red-400 flex flex-col items-center justify-center p-4 transform transition-all hover:scale-110 hover:-rotate-3 hover:shadow-red-500/50",whileHover:{scale:1.1,rotate:-3},whileTap:{scale:.95},children:[(0,c.jsx)(u(),{src:"/assets/images/tokens/vote_reject.png",alt:"Fail",width:80,height:80,className:"drop-shadow-2xl"}),(0,c.jsx)("span",{className:"mt-2 text-white font-bold text-lg tracking-widest uppercase",children:"SABOTAJE"})]})}),(0,c.jsx)("button",{onClick:()=>V(!0),className:"group transition-opacity ".concat(!0===E?"opacity-100":"opacity-50"),disabled:null!==E,children:(0,c.jsxs)(h.E.div,{className:"w-32 h-48 bg-gradient-to-br from-blue-600 to-blue-900 rounded-2xl shadow-2xl border-4 border-blue-400 flex flex-col items-center justify-center p-4 transform transition-all hover:scale-110 hover:rotate-3 hover:shadow-blue-500/50",whileHover:{scale:1.1,rotate:3},whileTap:{scale:.95},children:[(0,c.jsx)(u(),{src:"/assets/images/tokens/vote_approve.png",alt:"Success",width:80,height:80,className:"drop-shadow-2xl"}),(0,c.jsx)("span",{className:"mt-2 text-white font-bold text-lg tracking-widest uppercase",children:"\xc9XITO"})]})})]})})]}):(0,c.jsxs)("div",{className:"text-white text-3xl font-mono bg-black/70 p-8 rounded-xl border-2 border-white/20 text-center",children:[(0,c.jsx)("div",{className:"animate-pulse mb-4 text-5xl",children:"⏳"}),"La misi\xf3n est\xe1 en curso...",(0,c.jsx)("br",{}),(0,c.jsx)("span",{className:"text-lg text-gray-400 mt-2 block",children:"Esperando a que el equipo complete su votaci\xf3n."})]})},"mission"),"mission_reveal"===r.phase&&(0,c.jsx)(g,{votes:r.revealedVotes||[],onFinished:()=>x.finishMissionReveal()}),"mission_result"===r.phase&&(0,c.jsx)(f,{gameState:r,isHost:q,onContinue:()=>q&&x.finishMissionResult()}),r.phase===n.ASSASSIN_PHASE&&(0,c.jsxs)(h.E.div,{className:"w-full flex flex-col items-center gap-6",initial:{opacity:0,y:20},animate:{opacity:1,y:0},children:[(null==D?void 0:D.role)==="francotirador"&&(0,c.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 max-w-4xl",children:r.players.filter(e=>e.faction===o.ALIADOS).map(e=>(0,c.jsxs)(h.E.button,{onClick:()=>x.assassinKill(e.id),className:"bg-black/60 hover:bg-red-600/70 border-2 border-white/30 hover:border-red-500 p-3 rounded-lg transition-all backdrop-blur-sm flex flex-col items-center gap-2",whileHover:{scale:1.05},whileTap:{scale:.95},children:[(0,c.jsx)("div",{className:"w-20 h-20 rounded-full border-2 border-white/50 overflow-hidden bg-black relative shadow-xl",children:(0,c.jsx)(u(),{src:"/assets/images/characters/".concat(e.avatar),alt:e.name,fill:!0,className:"object-cover"})}),(0,c.jsx)("p",{className:"text-white font-bold text-sm drop-shadow-[0_2px_4px_rgba(0,0,0,0.8)]",children:e.name})]},e.id))}),(null==D?void 0:D.role)!=="francotirador"&&(0,c.jsx)("div",{className:"text-white text-xl font-mono bg-black/50 px-6 py-3 rounded-full border border-white/20 animate-pulse",children:"El Francotirador est\xe1 decidiendo..."})]}),r.phase===n.NAZIS_WIN&&(0,c.jsx)(v,{gameState:r,isHost:q,onRestart:()=>x.restartGame(),onFinalize:()=>x.finalizeGame()}),r.phase===n.ALLIED_WIN&&(0,c.jsx)(v,{gameState:r,isHost:q,onRestart:()=>x.restartGame(),onFinalize:()=>x.finalizeGame()})]})}),(0,c.jsxs)(h.E.div,{className:"fixed bottom-0 left-0 right-0 z-50 bg-black/80 border-t border-white/10 backdrop-blur-md",initial:!1,animate:{y:C?"100%":"0%"},transition:{type:"spring",stiffness:300,damping:30},children:[(0,c.jsx)("div",{className:"absolute -top-10 left-1/2 transform -translate-x-1/2",children:(0,c.jsxs)("button",{onClick:()=>R(!C),className:"bg-gradient-to-b from-yellow-600 to-yellow-700 hover:from-yellow-500 hover:to-yellow-600 text-white rounded-t-lg px-6 py-2 shadow-lg border-2 border-yellow-500 border-b-0 transition-all hover:shadow-yellow-500/50 flex items-center gap-2",children:[(0,c.jsx)(h.E.svg,{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",animate:{rotate:C?180:0},transition:{duration:.3},children:(0,c.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M19 9l-7 7-7-7"})}),(0,c.jsx)("span",{className:"text-sm font-bold uppercase tracking-wider",children:C?"Mostrar":"Ocultar"})]})}),(0,c.jsx)("div",{className:"w-full px-4 py-2 flex flex-wrap items-center justify-center gap-4",children:r.players.map(e=>{let s=j.includes(e.id),t=e.id===i,a="/assets/images/characters/".concat(e.avatar);return(0,c.jsxs)("div",{onClick:()=>P&&r.phase===n.TEAM_BUILDING&&F(e.id),className:"\n relative flex flex-col items-center cursor-pointer transition-all duration-300 group\n ".concat(s?"scale-110 z-10":"scale-100 opacity-70 hover:opacity-100 hover:scale-105","\n "),children:[(0,c.jsxs)("div",{className:"relative rounded-full border-2 overflow-hidden shadow-lg bg-black transition-all w-16 h-16 ${isSelected ? 'border-yellow-400 ring-4 ring-yellow-400/30 shadow-yellow-400/20' : 'border-gray-500 group-hover:border-gray-300'} ${gameState.currentLeaderId === player.id ? 'ring-2 ring-white' : ''} ",children:[(0,c.jsx)(u(),{src:a,alt:e.name,fill:!0,className:"object-cover"}),r.currentLeaderId===e.id&&(0,c.jsx)("div",{className:"absolute bottom-0 right-0 bg-yellow-500 rounded-full p-1 w-6 h-6 flex items-center justify-center text-[10px] text-black font-bold border border-white z-20 shadow-sm",children:"L"}),r.proposedTeam.includes(e.id)&&(r.phase===n.VOTING_TEAM||r.phase===n.MISSION||"mission_reveal"===r.phase||"mission_result"===r.phase)&&(0,c.jsx)("div",{className:"absolute top-0 left-0 bg-green-500 rounded-full p-1 w-6 h-6 flex items-center justify-center text-xs text-white font-bold border border-white z-20",children:"⭐"})]}),(0,c.jsx)("span",{className:"\n mt-1 text-xs font-mono px-2 py-0.5 rounded shadow-sm whitespace-nowrap max-w-[100px] truncate\n ".concat(t?"bg-blue-600 text-white font-bold":"bg-black/60 text-gray-300 border border-white/10","\n "),children:e.name})]},e.id)})})]}),r.missionHistory.length>0&&(0,c.jsxs)(h.E.div,{className:"fixed top-[60px] right-0 z-50",initial:!1,animate:{x:"0%"},transition:{type:"spring",stiffness:300,damping:30},children:[(0,c.jsx)(h.E.button,{onClick:()=>O(!T),className:"absolute top-0 bg-gradient-to-l from-yellow-600 to-yellow-700 hover:from-yellow-500 hover:to-yellow-600 text-white rounded-l-lg px-2 py-3 shadow-lg border-2 border-yellow-500 border-r-0 transition-all hover:shadow-yellow-500/50 flex items-center",initial:!1,animate:{right:T?"0px":"100%"},transition:{type:"spring",stiffness:300,damping:30},children:(0,c.jsx)(h.E.svg,{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",animate:{rotate:T?0:180},transition:{duration:.3},children:(0,c.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M15 19l-7-7 7-7"})})}),(0,c.jsxs)(h.E.div,{className:"bg-black/80 p-3 rounded-lg border border-white/20 backdrop-blur-sm",initial:!1,animate:{x:T?"100%":"0%"},transition:{type:"spring",stiffness:300,damping:30},children:[(0,c.jsx)("div",{className:"text-[10px] text-gray-400 uppercase mb-2 text-center font-bold tracking-wider",children:"Historial"}),(0,c.jsx)("div",{className:"flex gap-2",children:r.missionHistory.map((e,s)=>{let t=A===s;return(0,c.jsxs)("div",{className:"relative",children:[(0,c.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center text-xs font-bold border-2 cursor-pointer transition-all hover:scale-110 ".concat(e.isSuccess?"bg-blue-600 border-blue-400 text-white":"bg-red-600 border-red-400 text-white"," ").concat(t?"ring-2 ring-yellow-400 relative z-[60]":""),title:"Misi\xf3n ".concat(e.round,": ").concat(e.isSuccess?"\xc9xito":"Fracaso"," (").concat(e.successes,"✓ ").concat(e.fails,"✗)"),onClick:e=>{e.stopPropagation(),console.log("Click en misi\xf3n",s),L(e=>e===s?null:s)},children:e.round}),t&&(0,c.jsx)("div",{className:"absolute top-10 right-0 bg-black/95 p-2 rounded border border-white/30 min-w-max z-[100]",children:e.team.map(e=>{let s=r.players.find(s=>s.id===e);return(0,c.jsx)("div",{className:"text-xs text-white whitespace-nowrap",children:(null==s?void 0:s.name)||e},e)})})]},s)})})]})]})]})]})}function N(){let[e,s]=(0,d.useState)(10);return(0,d.useEffect)(()=>{if(e<=0)return;let t=setInterval(()=>s(e=>e-1),1e3);return()=>clearInterval(t)},[e]),(0,c.jsx)("div",{className:"fixed top-5 left-5 bg-red-600/80 text-white w-16 h-16 rounded-full flex items-center justify-center border-4 border-red-400 animate-pulse text-2xl font-bold font-mono",children:e})}function y(e){let{onClick:s}=e;return(0,c.jsx)(h.E.button,{onClick:s,whileHover:{scale:1.05},whileTap:{scale:.95},className:"bg-red-900/80 hover:bg-red-800 text-white p-2 rounded-full border border-red-700/50 backdrop-blur-sm shadow-lg transition-all",title:"Salir del juego",children:(0,c.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2.5,stroke:"currentColor",className:"w-5 h-5",children:(0,c.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5.636 5.636a9 9 0 1012.728 0M12 3v9"})})})}let k=["Dubois","Leroy","Moreau","Petit","Lefebvre","Michel","Durand","Smith","Jones","Williams","Brown","Taylor","Wilson","Evans","Miller","Davis","Garcia","Rodriguez","Martinez","Hernandez"];function I(){let{isConnected:e,gameState:s,roomsList:t,actions:a,socket:l}=(0,x.s)(),{session:r,saveSession:i,updateSession:o,clearSession:n}=function(){let[e,s]=(0,d.useState)(null);(0,d.useEffect)(()=>{let e=localStorage.getItem("resistencia_session");if(e)try{let t=JSON.parse(e);s(t)}catch(e){console.error("Error parsing session:",e),localStorage.removeItem("resistencia_session")}},[]);let t=(0,d.useCallback)(e=>{localStorage.setItem("resistencia_session",JSON.stringify(e)),s(e)},[]),a=(0,d.useCallback)(e=>{s(s=>{if(!s)return null;let t={...s,...e};return localStorage.setItem("resistencia_session",JSON.stringify(t)),t})},[]),l=(0,d.useCallback)(()=>{localStorage.removeItem("resistencia_session"),s(null)},[]);return{session:e,saveSession:t,updateSession:a,clearSession:l}}(),[p,b]=(0,d.useState)("login"),[g,f]=(0,d.useState)(""),[v,w]=(0,d.useState)(""),[N,I]=(0,d.useState)(!1),[_,E]=(0,d.useState)({maxPlayers:5,password:""}),[S,A]=(0,d.useState)(null),[L,C]=(0,d.useState)(""),[R,T]=(0,d.useState)(!1);(0,d.useEffect)(()=>{r&&e&&!R&&(f(r.playerName),w(r.fullPlayerName),b(r.currentView),r.roomId&&"game"===r.currentView?a.reconnectSession({playerName:r.fullPlayerName,roomId:r.roomId}):"lobby"===r.currentView&&a.refreshRooms(),T(!0))},[r,e,R,a,f,w,b,T]),(0,d.useEffect)(()=>{(null==s?void 0:s.roomId)?(b("game"),o({currentView:"game",roomId:s.roomId})):"game"===p&&!s&&R&&(b("lobby"),o({currentView:"lobby",roomId:void 0}))},[s,p,R,o,b]),(0,d.useEffect)(()=>{if(!l)return;let e=e=>{("La partida ya no existe"===e||"No se pudo reconectar a la partida"===e)&&(b("lobby"),o({currentView:"lobby",roomId:void 0}))};return l.on("error",e),()=>{l.off("error",e)}},[l,o,b]);let O=e=>{e.isPrivate?(A(e.id),C("")):a.joinGame(e.id,v)},z=()=>{S&&(a.joinGame(S,v,L),A(null))};if("game"===p&&s&&l){if("lobby"===s.phase){let e=s.hostId===l.id;return(0,c.jsxs)("main",{className:"relative min-h-screen flex flex-col items-center justify-center overflow-hidden bg-zinc-900 font-mono text-gray-200",children:[(0,c.jsxs)("div",{className:"absolute inset-0 z-0 opacity-40",children:[(0,c.jsx)(u(),{src:"/assets/images/ui/bg_game.png",alt:"War Room",fill:!0,className:"object-cover"}),(0,c.jsx)("div",{className:"absolute inset-0 bg-black/70"})]}),(0,c.jsxs)("div",{className:"z-10 bg-black/80 p-8 rounded border border-white/20 max-w-2xl w-full mx-4 backdrop-blur-md",children:[(0,c.jsxs)("div",{className:"text-center mb-8",children:[(0,c.jsx)("h2",{className:"text-3xl font-bold text-yellow-500 mb-2 uppercase tracking-widest",children:"Sala de Espera"}),(0,c.jsx)("p",{className:"text-xl font-bold text-white mb-1",children:s.roomName}),(0,c.jsx)("p",{className:"text-gray-400",children:"Operaci\xf3n en curso. Esperando activaci\xf3n..."})]}),(0,c.jsx)("div",{className:"grid grid-cols-2 gap-4 mb-8",children:s.players.map(e=>(0,c.jsxs)("div",{className:"bg-white/5 p-3 rounded flex items-center gap-3 border border-white/10",children:[(0,c.jsx)("div",{className:"w-3 h-3 rounded-full ".concat(e.id===l.id?"bg-green-500 shadow-green-500/50 shadow-lg":"bg-gray-500")}),(0,c.jsx)("span",{className:e.id===l.id?"font-bold text-white":"text-gray-300",children:e.name}),e.id===s.hostId&&(0,c.jsx)("span",{className:"text-[10px] bg-yellow-900/50 text-yellow-500 px-2 py-0.5 rounded ml-auto",children:"HOST"})]},e.id))}),(0,c.jsx)("div",{className:"flex flex-col items-center gap-4 border-t border-white/10 pt-6",children:e?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsxs)("p",{className:"text-sm text-gray-400 mb-2",children:["Jugadores: ",(0,c.jsx)("span",{className:"text-white font-bold",children:s.players.length}),s.players.length<5&&(0,c.jsx)("span",{className:"text-red-400 ml-2",children:"(M\xednimo 5 requeridos)"})]}),(0,c.jsx)("button",{onClick:()=>a.startGame(),disabled:s.players.length<5,className:"w-full max-w-md bg-yellow-600 hover:bg-yellow-500 disabled:bg-gray-700 disabled:cursor-not-allowed text-white font-bold py-4 rounded uppercase tracking-[0.2em] transition-all shadow-lg",children:"INICIAR MISI\xd3N"})]}):(0,c.jsxs)("div",{className:"text-center animate-pulse",children:[(0,c.jsx)("p",{className:"text-yellow-500 font-bold uppercase tracking-wider",children:"Esperando al Comandante..."}),(0,c.jsx)("p",{className:"text-xs text-gray-500 mt-2",children:"La misi\xf3n comenzar\xe1 cuando el l\xedder d\xe9 la orden."})]})})]})]})}return(0,c.jsx)(j,{gameState:s,currentPlayerId:l.id||"",actions:a,fullPlayerName:v})}return(0,c.jsxs)("main",{className:"relative min-h-screen flex flex-col items-center overflow-hidden bg-zinc-900 font-mono text-gray-200",children:[(0,c.jsxs)("div",{className:"absolute inset-0 z-0 opacity-40",children:[(0,c.jsx)(u(),{src:"/assets/images/ui/bg_lobby.png",alt:"Lobby Background",fill:!0,className:"object-cover"}),(0,c.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-black via-black/50 to-transparent"})]}),(0,c.jsxs)("div",{className:"z-10 w-full p-4 flex justify-between items-center max-w-6xl",children:[(0,c.jsxs)("div",{className:"flex items-center gap-4",children:[(0,c.jsx)(u(),{src:"/assets/images/ui/logo.png",alt:"Logo",width:150,height:50,className:"object-contain filter drop-shadow hidden md:block"}),(0,c.jsx)("h1",{className:"text-2xl font-bold tracking-widest uppercase text-yellow-600",children:"Francia Ocupada"})]}),"lobby"===p&&(0,c.jsxs)("div",{className:"flex items-center gap-3 bg-black/50 px-4 py-2 rounded border border-white/10",children:[(0,c.jsxs)("div",{className:"flex flex-col",children:[(0,c.jsx)("span",{className:"text-xs text-gray-400",children:"AGENTE:"}),(0,c.jsx)("span",{className:"font-bold text-yellow-500",children:v})]}),(0,c.jsx)(y,{onClick:()=>{n(),b("login"),f(""),w(""),(null==s?void 0:s.roomId)&&a.leaveGame()}})]})]}),(0,c.jsx)("div",{className:"z-10 w-full flex-1 flex flex-col items-center justify-center p-4",children:(0,c.jsxs)(m.M,{mode:"wait",children:["login"===p&&(0,c.jsxs)(h.E.form,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},onSubmit:e=>{if(e.preventDefault(),g){let e=k[Math.floor(Math.random()*k.length)],s="".concat(g," ").concat(e);w(s),i({playerName:g,fullPlayerName:s,currentView:"lobby"}),b("lobby"),a.refreshRooms()}},className:"bg-black/80 p-8 rounded border border-white/20 shadow-2xl max-w-md w-full backdrop-blur-md",children:[(0,c.jsx)("h2",{className:"text-xl text-center mb-6 uppercase tracking-[0.2em] text-white",children:"Identificaci\xf3n"}),(0,c.jsxs)("div",{className:"space-y-4",children:[(0,c.jsxs)("div",{children:[(0,c.jsx)("label",{className:"text-xs uppercase text-gray-500 block mb-1",children:"Nombre en Clave"}),(0,c.jsx)("input",{required:!0,value:g,onChange:e=>f(e.target.value),className:"w-full bg-white/10 border border-white/20 p-3 rounded text-white focus:outline-none focus:border-yellow-500 transition-colors",placeholder:"Ej: Agente"})]}),(0,c.jsx)("button",{type:"submit",className:"w-full bg-yellow-700 hover:bg-yellow-600 text-white font-bold py-3 mt-4 rounded uppercase tracking-wider transition-all",children:"Acceder al Cuartel"})]})]},"login-form"),"lobby"===p&&(0,c.jsxs)(h.E.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"w-full max-w-5xl",children:[(0,c.jsxs)("div",{className:"flex justify-between items-end mb-6 border-b border-white/20 pb-4",children:[(0,c.jsxs)("div",{children:[(0,c.jsx)("h2",{className:"text-3xl font-light text-white",children:"MISIONES ACTIVAS"}),(0,c.jsx)("p",{className:"text-gray-400 text-sm mt-1",children:"Selecciona una operaci\xf3n o inicia una nueva."})]}),(0,c.jsx)("button",{onClick:()=>I(!0),className:"bg-blue-800 hover:bg-blue-700 text-white px-6 py-2 rounded uppercase text-sm font-bold tracking-wider shadow-lg border border-blue-600 transition-all",children:"+ Crear Operaci\xf3n"})]}),(0,c.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:0===t.length?(0,c.jsx)("div",{className:"col-span-full py-20 text-center text-gray-500 bg-black/30 rounded border border-white/5 border-dashed",children:"No hay misiones activas en este momento."}):t.map(e=>(0,c.jsxs)(h.E.div,{initial:{scale:.95,opacity:0},animate:{scale:1,opacity:1},className:"bg-black/60 border border-white/10 p-5 rounded hover:border-yellow-700/50 transition-colors group relative overflow-hidden",children:[(0,c.jsx)("div",{className:"absolute top-0 right-0 p-2",children:e.isPrivate?(0,c.jsx)("span",{title:"Privada",className:"text-red-400",children:"\uD83D\uDD12"}):(0,c.jsx)("span",{title:"P\xfablica",className:"text-green-400/50",children:"\uD83D\uDD13"})}),(0,c.jsx)("h3",{className:"text-xl font-bold text-yellow-500 mb-1 group-hover:text-yellow-400 transition-colors",children:e.name}),(0,c.jsxs)("div",{className:"text-sm text-gray-400 mb-4 flex gap-2",children:[(0,c.jsx)("span",{className:"bg-white/10 px-2 py-0.5 rounded textxs",children:"HOST:"}),(0,c.jsxs)("span",{className:"text-white",children:[e.hostId.substring(0,6),"..."]})]}),(0,c.jsxs)("div",{className:"flex justify-between items-center mt-4",children:[(0,c.jsxs)("div",{className:"flex items-end gap-1",children:[(0,c.jsx)("span",{className:"text-3xl font-bold text-white",children:e.currentPlayers}),(0,c.jsxs)("span",{className:"text-sm text-gray-500 mb-1",children:["/ ",e.maxPlayers]})]}),(0,c.jsx)("button",{disabled:e.currentPlayers>=e.maxPlayers||"waiting"!==e.status,onClick:()=>O(e),className:"bg-white/10 hover:bg-white/20 text-white px-4 py-2 rounded text-xs uppercase font-bold transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:"playing"===e.status?"EN CURSO":e.currentPlayers>=e.maxPlayers?"LLENA":"UNIRSE"})]}),(0,c.jsx)("div",{className:"absolute bottom-0 left-0 h-1 bg-yellow-900/40 w-full",children:(0,c.jsx)("div",{className:"h-full bg-yellow-600 transition-all duration-500",style:{width:"".concat(e.currentPlayers/e.maxPlayers*100,"%")}})})]},e.id))})]},"lobby-list")]})}),N&&(0,c.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",children:(0,c.jsxs)(h.E.div,{initial:{scale:.9},animate:{scale:1},className:"bg-zinc-800 p-6 rounded border border-white/20 w-full max-w-sm shadow-2xl",children:[(0,c.jsx)("h3",{className:"text-lg font-bold text-white mb-4 uppercase",children:"Configurar Operaci\xf3n"}),(0,c.jsxs)("form",{onSubmit:e=>{e.preventDefault(),a.createGame(v,_.maxPlayers,_.password),I(!1)},className:"space-y-4",children:[(0,c.jsxs)("div",{children:[(0,c.jsx)("label",{className:"block text-xs uppercase text-gray-400 mb-1",children:"N\xba Jugadores"}),(0,c.jsx)("select",{value:_.maxPlayers,onChange:e=>E({..._,maxPlayers:Number(e.target.value)}),className:"w-full bg-black/40 border border-white/10 p-2 rounded text-white",children:[5,6,7,8,9,10].map(e=>(0,c.jsxs)("option",{value:e,children:[e," Jugadores"]},e))})]}),(0,c.jsxs)("div",{children:[(0,c.jsx)("label",{className:"block text-xs uppercase text-gray-400 mb-1",children:"Contrase\xf1a (Opcional)"}),(0,c.jsx)("input",{type:"password",value:_.password,onChange:e=>E({..._,password:e.target.value}),className:"w-full bg-black/40 border border-white/10 p-2 rounded text-white font-mono",placeholder:"Dejar vac\xedo para p\xfablica"})]}),(0,c.jsxs)("div",{className:"flex gap-2 mt-6",children:[(0,c.jsx)("button",{type:"button",onClick:()=>I(!1),className:"flex-1 py-2 text-gray-400 hover:text-white transition-colors",children:"Cancelar"}),(0,c.jsx)("button",{type:"submit",className:"flex-1 py-2 bg-yellow-700 hover:bg-yellow-600 text-white rounded font-bold uppercase",children:"Crear"})]})]})]})}),S&&(0,c.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-sm",children:(0,c.jsxs)(h.E.div,{initial:{scale:.9},animate:{scale:1},className:"bg-zinc-800 p-6 rounded border border-red-900/50 w-full max-w-sm shadow-2xl",children:[(0,c.jsx)("h3",{className:"text-lg font-bold text-red-400 mb-2 uppercase flex items-center gap-2",children:"\uD83D\uDD12 Acceso Restringido"}),(0,c.jsx)("p",{className:"text-xs text-gray-400 mb-4",children:"Esta operaci\xf3n es clasificada. Introduce la clave de acceso."}),(0,c.jsx)("input",{type:"password",autoFocus:!0,value:L,onChange:e=>C(e.target.value),onKeyDown:e=>"Enter"===e.key&&z(),className:"w-full bg-black/40 border border-red-900/30 p-2 rounded text-white font-mono mb-4 focus:border-red-500 outline-none",placeholder:"Clave de acceso..."}),(0,c.jsxs)("div",{className:"flex gap-2",children:[(0,c.jsx)("button",{onClick:()=>A(null),className:"flex-1 py-2 text-gray-400 hover:text-white",children:"Cancelar"}),(0,c.jsx)("button",{onClick:z,className:"flex-1 py-2 bg-red-900 hover:bg-red-800 text-white rounded font-bold uppercase",children:"Acceder"})]})]})}),(0,c.jsx)("div",{className:"absolute bottom-2 right-4 text-[10px] text-gray-600 font-mono",children:e?(0,c.jsx)("span",{className:"text-green-900",children:"● CONEXI\xd3N SEGURA"}):(0,c.jsx)("span",{className:"text-red-900",children:"● BUSCANDO SE\xd1AL..."})})]})}},6540:function(e,s,t){"use strict";t.d(s,{s:function(){return o}});var a=t(2265),l=t(4337),r=t(2601);let i=r.env.NEXT_PUBLIC_API_URL||"http://localhost:4000",o=()=>{let[e,s]=(0,a.useState)(null),[t,r]=(0,a.useState)(null),[o,n]=(0,a.useState)(!1),[c,d]=(0,a.useState)([]);(0,a.useEffect)(()=>{let e=(0,l.io)(i);return e.on("connect",()=>{console.log("Conectado al servidor"),n(!0)}),e.on("disconnect",()=>{console.log("Desconectado del servidor"),n(!1)}),e.on("game_state",e=>{console.log("Nuevo estado del juego:",e),r(e)}),e.on("rooms_list",e=>{console.log("Lista de salas actualizada:",e),d(e)}),e.on("game_joined",e=>{let{state:s}=e;r(s)}),e.on("error",e=>{alert(e)}),e.on("game_finalized",()=>{console.log("La partida ha sido finalizada por el host"),r(null)}),e.on("player_left_game",e=>{let{playerName:s}=e;console.log("".concat(s," ha abandonado la partida"))}),s(e),()=>{e.disconnect()}},[]);let x=(0,a.useMemo)(()=>({createGame:(s,t,a)=>{null==e||e.emit("create_game",{hostName:s,maxPlayers:t,password:a})},joinGame:(s,t,a)=>{null==e||e.emit("join_game",{roomId:s,playerName:t,password:a})},refreshRooms:()=>{null==e||e.emit("get_rooms")},startGame:()=>{null==e||e.emit("start_game",{roomId:null==t?void 0:t.roomId})},proposeTeam:s=>{null==e||e.emit("propose_team",{roomId:null==t?void 0:t.roomId,teamIds:s})},voteTeam:s=>{null==e||e.emit("vote_team",{roomId:null==t?void 0:t.roomId,approve:s})},voteMission:s=>{null==e||e.emit("vote_mission",{roomId:null==t?void 0:t.roomId,success:s})},voteLeader:s=>null==e?void 0:e.emit("vote_leader",{roomId:null==t?void 0:t.roomId,approve:s}),assassinKill:s=>{null==e||e.emit("assassin_kill",{roomId:null==t?void 0:t.roomId,targetId:s})},leaveGame:()=>{null==e||e.emit("leave_game",{roomId:null==t?void 0:t.roomId})},reconnectSession:s=>{null==e||e.emit("reconnect_session",s)},finishIntro:()=>null==e?void 0:e.emit("finish_intro",{roomId:null==t?void 0:t.roomId}),finishReveal:()=>null==e?void 0:e.emit("finish_reveal",{roomId:null==t?void 0:t.roomId}),finishRollCall:()=>null==e?void 0:e.emit("finish_roll_call",{roomId:null==t?void 0:t.roomId}),finishMissionReveal:()=>null==e?void 0:e.emit("finish_reveal",{roomId:null==t?void 0:t.roomId}),finishMissionResult:()=>null==e?void 0:e.emit("finish_mission_result",{roomId:null==t?void 0:t.roomId}),restartGame:()=>null==e?void 0:e.emit("restart_game",{roomId:null==t?void 0:t.roomId}),finalizeGame:()=>null==e?void 0:e.emit("finalize_game",{roomId:null==t?void 0:t.roomId})}),[e,null==t?void 0:t.roomId]);return{socket:e,isConnected:o,gameState:t,roomsList:c,actions:x}}}},function(e){e.O(0,[59,691,971,472,744],function(){return e(e.s=9634)}),_N_E=e.O()}]);