PageSourceSearch

https://flfproleague.com/assets/Torneos-Cr5FnFvz.js

js flfproleague.com collected 2026-10-05 23:11:39 UTC 199,111 bytes, 129 lines download raw bytes

1import{J as ce,j as e,a2 as J,S as de,V as tt,X as $e,v as Re,o as U,r as g,c as Y,y as ae,b as f,f as re,n as Pe,Y as ne,k as A,m as W,h as st,G as Lt,z as Bt,a0 as D,bv as Ss,K as qe,U as ee,_ as ve,at as Ot,a8 as Ee,a1 as at,ae as Es,a3 as zt,aw as Ts,x as G,Z as Gt,w as Je,N as Ut,P as fe,bq as Ie,av as As,aV as Fs,ac as rt,L as De,O as Vt,R as $s,T as Rs,l as gt,ad as Ne,au as Kt,s as Qt,a as Ds}from"./index-CtR2Cm7C.js";import{A as Ht,b as Wt,c as Jt,d as Yt,e as Zt,f as Ps}from"./alert-dialog-Bf6lB-Mv.js";import{B as Se}from"./button-2frSB4pm.js";import{I as qs}from"./input-VcMvimTY.js";import{L as Is}from"./label-BM0K1dVk.js";import{D as pe,a as he,b as we,c as be,e as Ms}from"./dialog-Dd9Dz3HR.js";import{A as ft,a as jt}from"./alert-CpF-yA3U.js";import{s as Ls}from"./discordOAuth-a9XwJFK5.js";import{S as it}from"./shield-check-D6RITCT8.js";import{C as Ye}from"./circle-alert-DMoQ8WJS.js";import{C as Xt}from"./circle-check-big-CtQTi4fB.js";import{T as Bs}from"./TournamentCountdownDisplay-g4_CKuql.js";import{C as nt}from"./calendar-days-tIL4cw6p.js";import{M as Os}from"./map-pin-C6nJj4pR.js";import{S as zs}from"./share-2-Dq5Cesag.js";import{B as Gs}from"./bookmark-B56MnO8v.js";import{I as es}from"./info-CRVGOOvF.js";import{E as je,A as ts,r as Ve,S as wt,C as Ze,i as ss,R as as,j as vt,g as Us,T as Vs,c as Ks,d as Qs,a as Nt,b as Hs,h as Ws,e as yt,f as Js,v as Ys,n as Zs}from"./TournamentAuditPanel-DU_JynXy.js";import{B as _t}from"./book-open-BH3nr6m1.js";import{C as rs}from"./CountryFlag-C1NO1QFU.js";import{L as Xs}from"./list-C1SrgIH7.js";import{R as ea}from"./rows-3-CZm4hR1D.js";import{M as ta}from"./minimize-2-JQHuV2gL.js";import{M as sa}from"./maximize-2-qHvXds1P.js";import{H as aa,D as ra,m as Ct}from"./HorizontalBracket-CKKfflIp.js";import{R as ia}from"./rotate-ccw-oOXL342B.js";import{I as na}from"./image-plus-CVQSmoIq.js";import{S as Me}from"./save-CMcbcFcV.js";import{G as oa}from"./git-branch-DjJrL5-X.js";import{A as la}from"./arrow-up-Cx5G1w7M.js";import{A as ca,T as da}from"./TeamTournamentRegistrationCard-Dwq2aj7p.js";import{C as Xe}from"./clock-Crn-bV_Q.js";import{T as is}from"./triangle-alert-BSj5rZQS.js";import{D as Le}from"./door-open-i2vPVBjL.js";import{T as ma}from"./TournamentEmailSettings-C9-huww_.js";import{B as xa}from"./badge-BtmlmM6m.js";import{P as ua}from"./plus-BnsHTh07.js";import{C as pa}from"./copy-DT9nxVXZ.js";import{c as ha,a as kt}from"./paymentData-BSdRgjit.js";import{C as ba}from"./chevron-up-CR-LX1he.js";import{S as ns}from"./send-2bR1st9w.js";import{C as ga}from"./chart-column-B5fNam1u.js";import{C as fa}from"./credit-card-lTLkwDUN.js";import{S as ja}from"./scale-BAuloZxQ.js";import{M as wa}from"./mail-Wh0MQC-N.js";import{H as va}from"./history-BlSoK1V-.js";import{M as Na}from"./index-CxH8DLJ8.js";import{T as os}from"./target-CNMRKRHG.js";import{C as St}from"./circle-BjKv542x.js";import{S as Be}from"./star-C4mVafEC.js";import ya from"./TournamentCodeManager-Dpli9Gak.js";import _a from"./CheckIn-CqJ1oHzi.js";import{A as Ca}from"./arrow-up-right-JbZvx_mz.js";import{l as ls,R as cs}from"./governanceCatalog-wmVjpK4V.js";import{i as ka}from"./dataSync-CMA0ZhJ0.js";import{V as Sa}from"./volume-2-DnKhypxr.js";import{H as Ea}from"./hash-Ca8OF0Lb.js";import{f as Ta}from"./friendlyError-K7orI5py.js";import{K as Ke}from"./key-round-D5j0NRum.js";import{S as Aa}from"./sliders-horizontal-CUBUDUCM.js";import{L as Fa}from"./layout-list-See9wq_C.js";import{F as $a}from"./filter-BAr0kSGs.js";import{G as Ra}from"./globe-BcPicHZK.js";import{f as ds}from"./format-CAy5MAkn.js";import"./index-BzvZTE6w.js";import"./index-OxmuvU-r.js";import"./index-i13djcCd.js";import"./index-DokfpFqZ.js";import"./index-C2ucMHlt.js";import"./index-CZF2G8Cx.js";import"./countryFlags-4_EjXWWl.js";import"./map-C-s2aYPU.js";import"./medal-ByCgqxVK.js";import"./zoom-out-BahN2NfO.js";import"./move-BTvoDr2w.js";import"./grip-vertical-CJjJ9yvZ.js";import"./BracketMatchEditor-DdcLavhh.js";import"./radio-DdU37GVS.js";import"./wand-sparkles-C3kC-vlC.js";import"./lock-open-CyktMdjX.js";import"./settings-2-DatQEsV4.js";import"./user-minus-Ca_gGbBT.js";import"./emailSettings-Dcy6_-pY.js";import"./timer-ClX1Gljg.js";/**
2 * @license lucide-react v0.475.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const Da=[["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["path",{d:"M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3",key:"1fpvtg"}]],Pa=ce("Blocks",Da);/**
7 * @license lucide-react v0.475.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const qa=[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]],ms=ce("Braces",qa);/**
12 * @license lucide-react v0.475.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const Ia=[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}
16],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]],Ma=ce("Bug",Ia);/**
17 * @license lucide-react v0.475.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const La=[["path",{d:"M12 16v5",key:"zza2cw"}],["path",{d:"M16 14v7",key:"1g90b9"}],["path",{d:"M20 10v11",key:"1iqoj0"}],["path",{d:"m22 3-8.646 8.646a.5.5 0 0 1-.708 0L9.354 8.354a.5.5 0 0 0-.707 0L2 15",key:"1fw8x9"}],["path",{d:"M4 18v3",key:"1yp0dc"}],["path",{d:"M8 14v7",key:"n3cwzv"}]],xs=ce("ChartNoAxesCombined",La);/**
22 * @license lucide-react v0.475.0 - ISC
23 *
24 * This source code is licensed under the ISC license.
25 * See the LICENSE file in the root directory of this source tree.
26 */const Ba=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],Oa=ce("Columns3",Ba);/**
27 * @license lucide-react v0.475.0 - ISC
28 *
29 * This source code is licensed under the ISC license.
30 * See the LICENSE file in the root directory of this source tree.
31 */const za=[["path",{d:"M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z",key:"1bo67w"}],["rect",{x:"3",y:"14",width:"7",height:"7",rx:"1",key:"1bkyp8"}],["circle",{cx:"17.5",cy:"17.5",r:"3.5",key:"w3z12y"}]],Ga=ce("Shapes",za);/**
32 * @license lucide-react v0.475.0 - ISC
33 *
34 * This source code is licensed under the ISC license.
35 * See the LICENSE file in the root directory of this source tree.
36 */const Ua=[["path",{d:"M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z",key:"qn84l0"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Va=ce("TicketCheck",Ua);/**
37 * @license lucide-react v0.475.0 - ISC
38 *
39 * This source code is licensed under the ISC license.
40 * See the LICENSE file in the root directory of this source tree.
41 */const Ka=[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]],Qa=ce("Workflow",Ka);function Ha({tournament:t,registrationCount:s}){const i=c=>c?new Date(c).toLocaleDateString("es-ES",{day:"2-digit",month:"short",year:"numeric"}):"Por confirmar",n=t?.game_mode==="battle_royale"?"Battle Royale":t?.game_mode==="clash_squad"?"Clash Squad":t?.game_mode||"Custom",r=Math.max(0,(t?.max_teams||0)-s),a=[["Fecha del torneo",i(t?.start_date)],["Cupos disponibles",r],["Modalidad",n],["Región",t?.region||"GLOBAL"]];return e.jsxs("header",{className:"border-b border-white/[0.08] pb-7",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[t?.image_url&&e.jsx("img",{src:t.image_url,alt:"",className:"h-14 w-14 rounded-xl border border-white/10 object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-bold uppercase tracking-[0.22em] text-[#FFC400]",children:"Inscripciones abiertas"}),e.jsx("h1",{className:"mt-1 text-3xl font-black tracking-tight text-white sm:text-4xl",children:"Registrar equipo"}),e.jsx("p",{className:"mt-2 text-sm font-bold uppercase tracking-[0.14em] text-white/75",children:t?.name})]})]}),e.jsx("div",{className:"mt-6 grid grid-cols-2 overflow-hidden rounded-xl border border-white/[0.07] bg-[#17191d] sm:grid-cols-4",children:a.map(([c,o],m)=>e.jsxs("div",{className:`px-4 py-3 ${m%2===1?"border-l border-white/[0.06]":""} ${m>1?"border-t border-white/[0.06]":""} ${m>1&&m%2===0?"sm:border-l":""} sm:border-t-0`,children:[e.jsx("p",{className:"text-[10px] text-white/40",children:c}),e.jsx("p",{className:"mt-1 text-sm font-semibold text-white",children:o})]},c))})]})}function Wa({team:t}){const s=[["Capitán",t.captain_name||"Sin asignar"],["Organización",t.organization||"Independiente"],["Región",t.region||t.country||"GLOBAL"],["Nivel",t.level||"—"]];return e.jsxs("section",{children:[e.jsxs("div",{className:"mb-3 flex items-center justify-between",children:[e.jsx("h2",{className:"text-base font-bold text-white",children:"Equipo seleccionado"}),e.jsx("a",{href:J("Perfil")+"?tab=equipo",className:"rounded-lg border border-white/10 bg-white/[0.04] px-3 py-1.5 text-xs font-semibold text-white/70 transition hover:border-[#FFC400]/40 hover:text-[#FFC400]",children:"Cambiar equipo"})]}),e.jsxs("div",{className:"flex flex-col gap-5 rounded-2xl border border-white/[0.08] bg-[#17191d] p-5 transition duration-300 hover:border-[#FFC400]/25 sm:flex-row sm:items-center",children:[e.jsx("div",{className:"flex h-24 w-24 flex-shrink-0 items-center justify-center overflow-hidden rounded-2xl border border-[#FFC400]/25 bg-[#0d0f11]",children:t.logo_url?e.jsx("img",{src:t.logo_url,alt:t.name,className:"h-full w-full object-cover"}):e.jsx(de,{className:"h-11 w-11 text-[#FFC400]"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-[0.16em] text-white/35",children:"Logo del equipo"}),e.jsx("h3",{className:"mt-1 truncate text-xl font-black text-white",children:t.name}),e.jsx("div",{className:"mt-4 grid grid-cols-2 gap-4 sm:grid-cols-4",children:s.map(([i,n])=>e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-white/35",children:i}),e.jsx("p",{className:"mt-1 truncate text-xs font-medium text-white/80",children:n})]},i))})]})]})]})}function Ja({team:t}){const s=(t.players||[]).map((r,a)=>({...r,rosterRole:a===0?"CAPITÁN":"TITULAR"})),i=(t.substitutes||[]).filter(r=>r.nick).map(r=>({...r,rosterRole:"SUPLENTE"})),n=[...s,...i];return e.jsxs("section",{children:[e.jsx("h2",{className:"mb-3 text-base font-bold text-white",children:"Jugadores registrados"}),e.jsxs("div",{className:"hidden grid-cols-[44px_1fr_1fr_110px_100px] gap-3 px-3 pb-2 text-[10px] text-white/35 sm:grid",children:[e.jsx("span",{children:"Avatar"}),e.jsx("span",{children:"Nickname"}),e.jsx("span",{children:"UID"}),e.jsx("span",{children:"Rol"}),e.jsx("span",{children:"Estado"})]}),e.jsx("div",{className:"space-y-2",children:n.map((r,a)=>e.jsxs("div",{className:"grid grid-cols-[40px_1fr_auto] items-center gap-3 rounded-xl border border-white/[0.07] bg-[#17191d] px-3 py-2.5 transition duration-200 hover:border-white/15 sm:grid-cols-[40px_1fr_1fr_110px_100px]",children:[r.avatar_url?e.jsx("img",{src:r.avatar_url,alt:"",className:"h-8 w-8 rounded-full object-cover"}):e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/[0.08] text-xs font-black text-[#FFC400]",children:r.nick?.[0]?.toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-white",children:r.nick}),e.jsxs("p",{className:"mt-0.5 truncate text-[10px] text-white/35 sm:hidden",children:["UID: ",r.ff_id||"Sin UID"," · ",r.rosterRole==="CAPITÁN"?"Capitán":r.rosterRole==="TITULAR"?"Titular":"Suplente"]})]}),e.jsx("span",{className:"hidden truncate text-xs text-white/50 sm:block",children:r.ff_id||"Sin UID"}),e.jsx("span",{className:"hidden text-xs text-white/65 sm:block",children:r.rosterRole==="CAPITÁN"?"Capitán":r.rosterRole==="TITULAR"?"Titular":"Suplente"}),e.jsx("span",{className:`justify-self-end rounded-md border px-2 py-1 text-[9px] font-black tracking-wide ${r.rosterRole==="CAPITÁN"?"border-[#FFC400]/40 bg-[#FFC400]/10 text-[#FFC400]":"border-white/10 bg-white/[0.05] text-white/60"}`,children:r.rosterRole})]},`${r.ff_id}-${a}`))})]})}function Ya({team:t}){const s=[...t.players||[],...(t.substitutes||[]).filter(r=>r.nick)],i=s.map(r=>
41r.registration_id||r.ff_id).filter(Boolean),n=[["Equipo completo",(t.players||[]).length===4],["Capitán asignado",!!(t.captain_name||t.players?.[0])],["4 jugadores registrados",(t.players||[]).length===4],["Sin jugadores duplicados",i.length===s.length&&i.length===new Set(i).size],["Cumple el límite permitido",s.length>=4&&s.length<=7]];return e.jsxs("section",{children:[e.jsx("h2",{className:"mb-3 text-base font-bold text-white",children:"Estado de la inscripción"}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:n.map(([r,a])=>e.jsxs("div",{className:`flex items-center gap-2 rounded-lg border px-3 py-2 text-xs ${a?"border-emerald-500/15 bg-emerald-500/[0.05] text-emerald-400":"border-red-500/20 bg-red-500/[0.06] text-red-400"}`,children:[a?e.jsx(tt,{className:"h-3.5 w-3.5"}):e.jsx($e,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:r})]},r))})]})}const Za=["Un jugador por equipo","Puntualidad obligatoria","Respeto entre jugadores","Nickname registrado","Prohibido usar hacks","No multicuentas","Las decisiones de administración son finales"];function Xa(){return e.jsxs("section",{children:[e.jsx("h2",{className:"mb-3 text-base font-bold text-white",children:"Reglamento del torneo"}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:Za.map(t=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-white/[0.06] bg-white/[0.025] px-3 py-2.5 text-xs text-white/65",children:[e.jsx("span",{className:"h-1 w-1 flex-shrink-0 rounded-full bg-[#FFC400]"}),t]},t))}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-4",children:[e.jsxs("a",{href:J("Reglamento"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs font-semibold text-[#FFC400] hover:text-[#ffd54d]",children:["Ver reglamento completo ",e.jsx(Re,{className:"h-3.5 w-3.5"})]}),e.jsxs("a",{href:J("TermsOfService"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs font-semibold text-[#FFC400] hover:text-[#ffd54d]",children:["Ver términos y condiciones ",e.jsx(Re,{className:"h-3.5 w-3.5"})]})]})]})}function er({team:t,tournament:s}){const i=(t.players||[]).length+(t.substitutes||[]).filter(a=>a.nick).length,n=s?.game_mode==="battle_royale"?"Battle Royale":s?.game_mode==="clash_squad"?"Clash Squad":s?.game_mode||"Custom",r=[["Equipo",t.name],["Capitán",t.captain_name||"Sin asignar"],["Jugadores",`${i} registrados`],["Torneo",s?.name],["Modalidad",n],["Costo de inscripción",s?.entry_fee||"Gratis"],["Estado",s?.auto_approve?"Aprobación automática":"Revisión pendiente"]];return e.jsxs("aside",{className:"rounded-2xl border border-white/[0.08] bg-[#17191d] p-5 lg:sticky lg:top-4",children:[e.jsx("h2",{className:"border-b border-white/[0.07] pb-4 text-lg font-bold text-white",children:"Resumen"}),e.jsx("dl",{className:"mt-4 space-y-4",children:r.map(([a,c])=>e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("dt",{className:"text-xs text-white/35",children:a}),e.jsx("dd",{className:"max-w-[60%] text-right text-xs font-semibold text-white/80",children:c})]},a))})]})}function tr(){return e.jsxs("div",{className:"space-y-5 py-3",children:[e.jsx("div",{className:"h-28 rounded-2xl bg-white/[0.05]"}),e.jsx("div",{className:"space-y-2",children:[1,2,3,4].map(t=>e.jsx("div",{className:"h-14 rounded-xl bg-white/[0.04]"},t))}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx("div",{className:"h-24 rounded-xl bg-white/[0.04]"}),e.jsx("div",{className:"h-24 rounded-xl bg-white/[0.04]"})]})]})}function sr({teamId:t,tournamentId:s,userId:i,onReadyChange:n}){const r=U({queryKey:["tournament-discord-roster",t,i],queryFn:async()=>(await f.functions.invoke("syncTournamentDiscordAccess",{action:"validate_team",team_id:t})).data,enabled:!!(t&&i),staleTime:3e4,retry:2,retryDelay:o=>700*(o+1),refetchOnWindowFocus:!1}),a=r.data?.roster||[],c=!!r.data?.ready;return g.useEffect(()=>n(c),[c,n]),g.useEffect(()=>{if(!c||new URLSearchParams(window.location.search).get("focus")!=="discord")return;const o=window.setTimeout(()=>document.getElementById("tournament-discord-gate")?.scrollIntoView({behavior:"smooth",block:"center"}),200);return()=>window.clearTimeout(o)},[c]),r.isLoading?e.jsxs("div",{className:"flex items-center gap-2 rounded-2xl border border-white/10 bg-white/[0.03] p-4 text-sm text-white/50",children:[e.jsx(Y,{className:"h-4 w-4 animate-spin"}),"Verificando Discord del equipo…"]}):e.jsxs("section",{id:"tournament-discord-gate",className:"mx-auto w-full min-w-0 max-w-[640px] overflow-hidden rounded-xl border border-[#28303a] bg-[#090d12] shadow-[0_18px_50px_rgba(0,0,0,0.38)]",children:[e.jsx("header",{className:"relative flex h-20 items-center justify-center bg-cover bg-center",style:{backgroundImage:"url('https://media.base44.com/images/public/695819068db6e4f351875421/700a2644d_generated_image.png')"},children:e.jsxs("div",{className:"flex items-center gap-3 text-white drop-shadow-md",children:[e.jsx("span",{className:"flex h-10 w-10 items-center justify-center rounded-md bg-white shadow-md",children:e.jsx("img",{src:"https://cdn.simpleicons.org/discord/5865F2",alt:"",className:"h-6 w-6"})}),e.jsx("span",{className:"text-2xl font-black tracking-tight",children:"Discord"})]})}),e.jsxs("div",{className:"px-5 pb-5 pt-4 sm:px-6 sm:pb-6",children:[e.jsx("h3",{className:"text-xl font-bold leading-tight text-white",children:"Discord del equipo"}),e.jsx("p",{className:"mt-1 text-sm leading-5 text-[#a9adb5]",children:"Puedes ver el estado de todo el roster. La persona autorizada que realiza la inscripción debe tener Discord vinculado."}),r.isError?e.jsxs("div",{className:"mt-4 rounded-md border border-red-500/20 bg-red-500/10 p-3 text-sm text-red-300",children:["No se pudo comprobar Discord temporalmente. ",e.jsx("button",{"aria-label":"Actualizar",type:"button",onClick:()=>r.refetch(),className:"font-bold underline",children:"Reintentar ahora"})]}):e.jsx("div",{className:"mt-4 space-y-1.5",children:a.map(o=>e.jsxs("div",{className:"flex min-h-16 min-w-0 items-center gap-3 rounded-md border border-[#29313a] bg-[#151a20] px-3 sm:px-4",children:[o.discord_avatar_url||o.avatar_url?e.jsx("img",{src:o.discord_avatar_url||o.avatar_url,alt:"",className:"h-10 w-10 flex-shrink-0 rounded-full object-cover"}):e.jsx("span",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-full border border-[#616975] bg-[#474e58] text-lg font-medium text-[#e4e7eb]",children:o.name?.trim()?.charAt(0)?.toUpperCase()||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-[#f2f3f5]",children:o.discord_global_name||o.name}),e.jsx("p",{className:"truncate text-xs text-[#92969e]",children:o.connected?`@${o.discord_username}`:o.is_captain?"Capitán · Discord requerido":"Jugador del roster"})]}),o.is_captain&&e.jsx("span",{className:"shrink-0 rounded-md border border-[#FFC400]/30 bg-[#FFC400]/10 px-2 py-1 text-[10px] font-bold text-[#FFC400]",children:"Autorizado"}),e.jsx("span",{className:`shrink-0 rounded-md px-2 py-1 text-[11px] font-medium ${o.connected?"bg-green-500/15 text-green-300":"bg-[#4b3514] text-[#f3b94f]"}`,children:o.connected?"Vinculado":"Pendiente"})]},`${o.user_id}-${o.role}`))}),!c&&!r.isError&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-4 text-xs leading-5 text-[#92969e]",children:"Vincula tu cuenta de Discord para continuar."}),e.jsx("button",{type:"button",onClick:()=>Ls(`/Torneos?tournamentId=${encodeURIComponent(s)}&register=1&focus=discord`),className:"mt-4 flex min-h-12 w-full items-center justify-center rounded-md bg-[#3478ed] px-4 text-sm font-bold text-white shadow-[0_8px_24px_rgba(52,120,237,0.25)] transition-colors hover:bg-[#4285f4]",children:"Vincular mi Discord"})]}),c&&e.jsxs("div",{className:"mt-4 flex items-center gap-2 rounded-md border border-green-500/25 bg-green-500/10 px-3 py-2 text-sm font-medium text-green-300",children:[e.jsx(ae,{className:"h-4 w-4"}),"Capitán vinculado. Puedes continuar la inscripción."]})]})]})}function ar({open:t,teamName:s}){return e.jsx(Ht,{open:t,children:e.jsxs(Wt,{className:"border-white/10 bg-[#171719] text-white sm:max-w-sm",children:[e.jsxs(Jt,{children:[e.jsxs(Yt,{className:"flex items-center gap-2 text-[#FFC400]",children:[e.jsx(it,{className:"h-5 w-5"}),"Confirmando inscripción"]}),e.jsxs(Zt,{className:"text-white/65",children:["Estamos validando el cupo y el roster de ",e.jsx("strong",{className:"text-white",children:s}),". No cierres esta pantalla."]})]}),e.jsxs("div",{className:"space-y-3",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-white/10",children:e.jsx("div",{className:"h-full w-3/4 animate-pulse rounded-full bg-[#FFC400]"})}),e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium text-white/70",children:[e.jsx(Y,{className:"h-4 w-4 animate-spin text-[#FFC400]"}),"Procesando registro…"]})]})]})})}const Qe=new Set(["pending","approved","waiting_list"]);function rr({tournament:t,open:s,onOpenChange:i}){const n=re(),{user:r}=Pe(),[a,c]=g.useState(""),[o,m]=g.useState(!1),[x,p]=g.useState(!1);g.useEffect(()=>{s&&(c(""),m(!1),p(!1))},[s,t?.id]);const{data:d,isLoading:u}=U({queryKey:["myTeam","tournament-roster-v2",r?.id,r?.email,s],queryFn:async()=>
41{if(!r)return null;const _=[...new Set([r.email,r.id].filter(Boolean))],I=async E=>{const k=(await f.entities.TeamMember.filter({team_id:E.id}).catch(()=>[])).filter(L=>!L.status||L.status==="active"||L.legacy_source?.temporary_test),y=["captain","capitan","player","jugador","titular"],F=["substitute","suplente"],T=L=>({nick:L.nickname||L.player_name||L.user_name||"Jugador",ff_id:L.ff_id||"",registration_id:L.player_id||L.user_id||L.ff_id||"",avatar_url:L.avatar_url||L.user_avatar||"",role:L.role||"player"}),M=k.filter(L=>y.includes(L.role)).slice(0,4).map(T),te=k.filter(L=>F.includes(L.role)).slice(0,3).map(T);return{id:E.id,name:E.name,tag:E.tag||(E.name||"TEAM").substring(0,4).toUpperCase(),logo_url:E.logo_url,country:E.country||r.country||"",region:E.region||E.country||r.country||"GLOBAL",organization:E.organization||E.org_name||"",level:E.level||"",captain_name:E.captain_name||r.nickname||r.full_name,captain_discord:E.captain_discord||r.discord||"",captain_whatsapp:E.captain_whatsapp||r.whatsapp||"",players:M,substitutes:te}},P=_.flatMap(E=>[{owner_email:E},{owner_id:E},{captain_id:E}]),O=(await f.entities.MasterTeam.filter({$or:P},"-created_date",50).catch(()=>[])).find(E=>E.status!=="disbanded"&&E.status!=="inactive");if(O)return I(O);const B=_.flatMap(E=>[{user_id:E},{player_id:E}]),z=(await f.entities.TeamMember.filter({$or:B},"-created_date",50).catch(()=>[])).find(E=>E.team_id&&(!E.status||E.status==="active")&&["captain","capitan","manager"].includes(E.role));if(z){const E=await f.entities.MasterTeam.get(z.team_id).catch(()=>null);if(E&&E.status!=="disbanded")return I(E)}return null},enabled:!!r&&s,staleTime:0,refetchOnMount:"always"}),{data:b}=U({queryKey:["my-registration",t?.id,d?.id],queryFn:async()=>!d||!t?null:(await f.entities.TournamentRegistration.filter({tournament_id:t.id})).find(I=>Qe.has(I.status)&&I.team_id===d.id)||null,enabled:!!d&&!!t&&s}),{data:C=[]}=U({queryKey:["all-tournament-registrations",t?.id],queryFn:async()=>t?await f.entities.TournamentRegistration.filter({tournament_id:t.id}):[],enabled:!!t&&s}),v=ne({mutationFn:async _=>{if(o!==!0)throw new Error("Debes aceptar el reglamento, los términos y las condiciones");const I=t.core_status?t.core_status==="REGISTRATION_OPEN":t.status==="registration_open",P=t.status==="registration_closed"&&t.registration_close_reason==="capacity"&&t.waitlist_enabled;if(!I&&!P)throw new Error("Las inscripciones de este torneo no están abiertas");const Q=await f.entities.TournamentRegistration.filter({tournament_id:t.id,status:"approved"});if(!!(t.max_teams&&Q.length>=t.max_teams)&&!t.waitlist_enabled)throw new Error("El torneo está lleno. No hay cupos disponibles.");const B=await f.entities.TournamentRegistration.filter({tournament_id:t.id,status:"pending"}),V=await f.entities.TournamentRegistration.filter({tournament_id:t.id,status:"waiting_list"}),z=[...Q,...B,...V];if(z.find(T=>T.team_id===_.id||String(T.team_name||"").toLowerCase()===String(_.name).toLowerCase()))throw new Error("Ya tienes un equipo inscrito en este torneo");if([...C,...z].filter(T=>Qe.has(T.status)).find(T=>T.team_id===_.id||String(T.team_name||"").toLowerCase()===String(_.name).toLowerCase()))throw new Error(`El equipo "${_.name}" ya está inscrito en este torneo`);if(t.private===!0){const T=await f.functions.invoke("validateTournamentCode",{tournament_id:t.id,code:a});if(!T.data.success)throw new Error(T.data.error)}let y;try{y=await f.functions.invoke("registerTournamentTeam",{tournament_id:t.id,registration_type:"team",team_id:_.id,registration_code:a,rules_accepted:o,whatsapp:_.captain_whatsapp||r.data?.whatsapp||r.phone||"",country:_.country||r.data?.country||""})}catch(T){const te=(await f.entities.TournamentRegistration.filter({tournament_id:t.id,team_id:_.id},"-created_date",10)).find(L=>Qe.has(L.status));if(te)return te;throw new Error(T.response?.data?.error||T.message||"No se pudo completar la inscripción")}const F=y.data?.registration;if(!F)throw new Error(y.data?.error||"No se pudo completar la inscripción");return F},onSuccess:async _=>{c(""),m(!1),i(!1);const I=(O=[])=>{const B=Array.isArray(O)?O:[];return B.some(V=>V.id===_.id)?B:[...B,_]};n.setQueryData(["tournament-registrations",t?.id],I),n.setQueriesData({queryKey:["all-registrations"]},I),n.setQueryData(["my-registration",t?.id,d?.id],_),n.setQueryData(["all-tournament-registrations",t?.id],I),_.status==="approved"&&window.setTimeout(()=>n.invalidateQueries({queryKey:["tournament-groups",t?.id]}),2500),n.invalidateQueries({queryKey:["tournaments"]}),window.setTimeout(()=>{n.invalidateQueries({queryKey:["tournament-registrations",t?.id]}),n.invalidateQueries({queryKey:["my-registration",t?.id]}),n.invalidateQueries({queryKey:["all-tournament-registrations",t?.id]}),n.invalidateQueries({queryKey:["all-registrations"]})},2500);let P="";
41try{P=(await f.functions.invoke("validateTournamentCode",{action:"create_management_code",registration_id:_.id})).data.code||""}catch(O){console.warn("[RegistrationForm] Registration saved; management code skipped:",O)}const Q=_.status==="waiting_list"?"Torneo lleno: tu equipo ingresó en la lista de espera.":_.status==="approved"?"¡Equipo registrado y aprobado automáticamente!":"¡Equipo registrado! Espera la aprobación del administrador.";A.success(Q,P?{description:`Código de administración: ${P}. Guárdalo en un lugar seguro.`,duration:12e3}:void 0)},onError:_=>{A.error(_.message||"Error al registrar equipo")}}),S=_=>{if(_.preventDefault(),b){A.error("Ya tienes un equipo inscrito en este torneo");return}if(!d){A.error("Debes crear tu equipo primero en tu perfil");return}if(t.private===!0&&!a){A.error("Debes ingresar el código de registro");return}if((d.players||[]).length!==4||R.length!==$.length||R.length!==new Set(R).size||$.length>7){A.error("Completa los 4 jugadores del roster, sin IDs vacíos ni duplicados");return}if(o!==!0){A.error("Debes aceptar el reglamento, los términos y las condiciones");return}if(!x){A.error("La persona autorizada para inscribir el equipo debe conectar Discord");return}v.mutate(d)},$=d?[...d.players||[],...(d.substitutes||[]).filter(_=>_.nick)]:[],R=$.map(_=>_.registration_id||_.ff_id).filter(Boolean),h=!!(d&&(d.players||[]).length===4&&(d.captain_name||d.players?.[0])&&R.length===$.length&&R.length===new Set(R).size&&$.length<=7&&x&&o===!0&&(!t?.private||a));return e.jsxs(pe,{open:s,onOpenChange:i,children:[e.jsxs(he,{className:"registration-mobile-stable w-[calc(100vw-1rem)] max-w-6xl max-h-[94vh] overflow-y-auto border border-white/[0.08] bg-[#090a0c] p-0 text-white shadow-2xl shadow-black/60 sm:rounded-3xl",children:[e.jsxs(we,{className:"sr-only",children:[e.jsx(be,{children:"Registrar equipo"}),e.jsxs(Ms,{children:["Inscripción oficial al torneo ",t?.name]})]}),e.jsxs("form",{onSubmit:S,className:"p-5 sm:p-8 lg:p-10",children:[e.jsx(Ha,{tournament:t,registrationCount:C.length}),b?e.jsxs(ft,{className:"mt-7 border-red-500/25 bg-red-500/[0.07]",children:[e.jsx(Ye,{className:"h-4 w-4 text-red-400"}),e.jsx(jt,{className:"text-red-300",children:"Ya tienes un equipo inscrito en este torneo. No puedes inscribirte dos veces."})]}):u?e.jsx(tr,{}):d?e.jsxs("div",{className:"mt-8 grid gap-7 lg:grid-cols-[minmax(0,1fr)_280px] lg:items-start",children:[e.jsxs("div",{className:"space-y-8",children:[e.jsx(Wa,{team:d}),e.jsx(Ja,{team:d}),e.jsx(Ya,{team:d}),e.jsx(sr,{teamId:d.id,tournamentId:t.id,userId:r?.id,onReadyChange:p}),e.jsx(Xa,{}),t?.private===!0&&e.jsxs("div",{className:"rounded-2xl border border-white/[0.08] bg-[#17191d] p-5",children:[e.jsx(Is,{htmlFor:"registration_code",className:"text-sm font-bold text-white",children:"Código de registro"}),e.jsx(qs,{id:"registration_code",value:a,onChange:_=>c(_.target.value.toUpperCase()),placeholder:"Ingresa el código proporcionado",className:"mt-3 border-white/10 bg-[#0c0d0f] font-mono text-white focus-visible:ring-[#FFC400]",required:!0})]}),e.jsxs("section",{className:"rounded-2xl border border-white/[0.08] bg-[#17191d] p-5",children:[e.jsx("h2",{className:"text-base font-bold text-white",children:"Confirmación obligatoria"}),e.jsxs("label",{htmlFor:"rules_accepted",className:"mt-4 flex cursor-pointer items-start gap-3",children:[e.jsx("input",{type:"checkbox",id:"rules_accepted",checked:o,onChange:_=>m(_.target.checked),className:"mt-0.5 h-6 w-6 flex-shrink-0 accent-[#FFC400]",required:!0}),e.jsxs("span",{className:"text-sm leading-relaxed text-white/60",children:["Confirmo que he leído y acepto el reglamento del torneo, los ",e.jsx("a",{href:J("TermsOfService"),target:"_blank",rel:"noreferrer",onClick:_=>_.stopPropagation(),className:"font-bold text-[#FFC400] underline",children:"términos y condiciones"}),". Entiendo que su incumplimiento puede ocasionar sanciones o la descalificación del equipo."]})]}),!o&&e.jsx("p",{className:"mt-3 text-xs font-semibold text-amber-300",children:"Debes marcar esta casilla para habilitar la inscripción."})]})]}),e.jsx(er,{team:d,tournament:t}),!v.isPending&&e.jsxs("div",{className:"flex flex-col-reverse gap-3 border-t border-white/[0.08] pt-6 sm:flex-row sm:justify-end lg:col-span-2",children:[e.jsx(Se,{type:"button",onClick:()=>i(!1),className:"border border-white/10 bg-white/[0.04] text-white hover:bg-white/[0.08]",children:"Cancelar"}),e.jsx(Se,{type:"button",onClick:()=>{localStorage.setItem(`tournament-registration-draft-${t.id}`,JSON.stringify({teamId:d.id,registrationCode:a,rulesAccepted:o,savedAt:new Date().toISOString()})),A.success("Borrador guardado en este dispositivo")},className:"border border-white/10 bg-[#1b1d21] text-white hover:bg-[#24272c]",children:"Guardar borrador"}),e.jsxs(Se,{type:"submit",disabled:!!b||!h,className:"min-w-44 bg-[#FFC400] font-black text-black shadow-lg shadow-[#FFC400]/10 transition hover:bg-[#ffd12e] hover:shadow-[#FFC400]/20 disabled:bg-white/10 disabled:text-white/30 disabled:shadow-none",children:[e.jsx(Xt,{className:"mr-2 h-4 w-4"}),"Registrar equipo"]})]})]}):e.jsxs(ft,{className:"mt-7 border-[#FFC400]/25 bg-[#FFC400]/[0.06]",children:[e.jsx(Ye,{className:"h-4 w-4 text-[#FFC400]"}),e.jsxs(jt,{className:"text-[#ffe580]",children:["Para inscribirte necesitas crear tu equipo primero en tu ",e.jsx("a",{href:J("Perfil")+"?tab=equipo",className:"font-bold underline",children:"perfil"}),"."]})]})]})]}),e.jsx(ar,{open:v.isPending,teamName:d?.name||"tu equipo"})]})}function ir({tournament:t,open:s,onOpenChange:i}){const{user:n}=Pe(),r=re(),[a,c]=g.useState({name:n?.nickname||n?.full_name||"",ff_id:n?.ff_id||"",whatsapp:n?.whatsapp||"",country:n?.country||"",rules:!1,code:""}),[o,m]=g.useState(!1);g.useEffect(()=>{s&&c(d=>({...d,rules:!1,code:""}))},[s,t?.id]);const x=async d=>{if(d.preventDefault(),!n)return f.auth.redirectToLogin(window.location.href);if(a.rules!==!0){A.error("Debes aceptar el reglamento, los términos y las condiciones");return}m(!0);try{const u=await f.functions.invoke("registerTournamentTeam",{tournament_id:t.id,registration_type:"solo",participant_name:a.name,player1_id:a.ff_id,whatsapp:a.whatsapp,country:a.country,registration_code:a.code,rules_accepted:a.rules}),b=u.data?.registration;
41if(!b)throw new Error(u.data?.error||"No se pudo completar la inscripción");let C="";try{C=(await f.functions.invoke("validateTournamentCode",{action:"create_management_code",registration_id:b.id})).data.code||""}catch(S){console.warn("[SoloRegistration] Registration saved; management code skipped",S)}const v=(S=[])=>{const $=Array.isArray(S)?S:[];return $.some(R=>R.id===b.id)?$:[...$,b]};r.setQueriesData({queryKey:["all-registrations"]},v),r.setQueryData(["tournament-registrations",t.id],v),r.invalidateQueries({queryKey:["all-registrations"],exact:!1}),r.invalidateQueries({queryKey:["tournament-registrations",t.id]}),A.success("Inscripción individual completada",C?{description:`Código de administración: ${C}. Guárdalo.`,duration:12e3}:void 0),i(!1)}catch(u){A.error(u.response?.data?.error||u.message)}finally{m(!1)}},p=(d,u,b=!1)=>e.jsx("input",{required:b,value:a[d],onChange:C=>c({...a,[d]:C.target.value}),placeholder:u,className:"w-full rounded-lg bg-white/10 p-3"});return e.jsx(pe,{open:s,onOpenChange:i,children:e.jsxs(he,{className:"border-white/10 bg-[#090a0c] text-white",children:[e.jsx(we,{children:e.jsxs(be,{children:["Inscripción individual · ",t.name]})}),e.jsxs("form",{onSubmit:x,className:"space-y-3",children:[p("name","Nick competitivo",!0),p("ff_id","ID de Free Fire",!0),p("whatsapp","WhatsApp",!0),p("country","País"),t.private&&p("code","Código privado",!0),e.jsxs("label",{className:"flex items-start gap-2 text-sm",children:[e.jsx("input",{required:!0,type:"checkbox",checked:a.rules,onChange:d=>c({...a,rules:d.target.checked})}),e.jsxs("span",{children:["Acepto el reglamento y los ",e.jsx("a",{href:J("TermsOfService"),target:"_blank",rel:"noreferrer",onClick:d=>d.stopPropagation(),className:"font-bold text-amber-300 underline",children:"términos y condiciones"})," del torneo."]})]}),!a.rules&&e.jsx("p",{className:"text-xs font-semibold text-amber-300",children:"Debes aceptar antes de continuar."}),e.jsx("button",{type:"submit",disabled:o||a.rules!==!0,className:"min-h-11 w-full rounded-xl bg-amber-400 px-4 py-3 font-black leading-tight text-black disabled:opacity-40",children:o?"Registrando...":"Confirmar inscripción individual"})]})]})})}const Et={upcoming:{label:"PRÓXIMO",tone:"amber",dot:"#F59E0B"},live:{label:"EN VIVO",tone:"green",dot:"#61D095"},completed:{label:"FINALIZADO",tone:"slate",dot:"#6B7280"}},nr={battle_royale:"Battle Royale",clash_squad:"Clash Squad",mapa_abierto:"Mapa abierto",ranked:"Ranked",custom:"Personalizado"},or="https://media.base44.com/images/public/695819068db6e4f351875421/30326e430_generated_image.png";function lr({tournament:t,count:s,onEnter:i,onShare:n}){const[r,a]=g.useState(()=>localStorage.getItem(`follow-${t.id}`)==="1"),c=t.banner_url||t.image_url,o=t.start_date?new Date(`${t.start_date}T${t.start_time||"00:00"}`):null,m=o&&!Number.isNaN(o.getTime())?o.toLocaleDateString("es-ES",{day:"2-digit",month:"short",year:"numeric"}).replace(".","").toUpperCase():"POR DEFINIR",x=t.prize||`$${Number(t.prize_pool_total||0).toLocaleString()} ${t.prize_currency||"USD"}`,p=t.organizer||t.organization||"FLF PRO LEAGUE",d=Et[t.status]||Et.upcoming,u=()=>{const v=!r;a(v),localStorage.setItem(`follow-${t.id}`,v?"1":"0")},b=t.max_teams?Math.min(100,Math.round(s/t.max_teams*100)):0,C=[{value:s,label:"Equipos",sub:`${s}
41/${t.max_teams??"∞"}`},{value:s*4,label:"Jugadores",sub:"estimado"},{value:x,label:"Premio total",sub:(t.prize_currency||"USD").toUpperCase()},{value:b+"%",label:"Cupos llenos",sub:"ocupación"}];return e.jsxs("section",{className:"w-full min-w-0 overflow-hidden rounded-xl border border-[#1E2226] bg-[#0D0F12]",children:[e.jsxs("div",{className:"relative overflow-hidden",style:{borderBottom:"1px solid #1E2226"},children:[e.jsx("img",{src:or,alt:"","aria-hidden":"true",width:"1400",height:"360",fetchPriority:"high",className:"absolute inset-0 h-full w-full object-cover opacity-40"}),c&&e.jsx("img",{src:c,alt:"",width:"1400",height:"360",fetchPriority:"high",className:"absolute inset-0 h-full w-full object-cover opacity-20"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-[#0D0F12] via-[#0D0F12]/85 to-[#0D0F12]/40"}),e.jsxs("div",{className:"relative flex flex-col gap-4 p-3 sm:min-h-[150px] sm:p-5 lg:flex-row lg:items-end",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3 sm:gap-4",children:[e.jsx("div",{className:"flex h-14 w-14 flex-none items-center justify-center overflow-hidden rounded-lg border border-[#262A2F] bg-[#14181C] sm:h-[68px] sm:w-[68px]",children:t.image_url?e.jsx("img",{src:t.image_url,alt:`Logo de ${t.name}`,width:"80",height:"80",className:"h-full w-full object-cover"}):e.jsx(W,{className:"h-7 w-7 text-[#61D095]"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-[#262A2F] bg-[#14181C] px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wider text-[#C5C7CB]",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:[e.jsx("span",{className:"h-2 w-2 rounded-full",style:{backgroundColor:d.dot,boxShadow:`0 0 8px ${d.dot}`}}),d.label]}),e.jsx("h1",{className:"mt-2 break-words text-lg font-bold leading-tight tracking-[-0.02em] text-[#F1F2F3] sm:text-3xl",style:{fontFamily:'"Rajdhani", "Inter", sans-serif'},children:t.name}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] font-medium text-[#8A8F96]",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(nt,{className:"h-3 w-3"}),m]}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(st,{className:"h-3 w-3"}),nr[t.game_mode]||"Custom"]}),t.region&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(Os,{className:"h-3 w-3"}),t.region]}),e.jsxs("span",{className:"inline-flex items-center gap-1 truncate",children:["· ",p]})]})]})]}),e.jsxs("div",{className:"flex w-full min-w-0 flex-wrap items-center gap-1.5 lg:w-auto lg:justify-end sm:gap-2",children:[e.jsx("div",{className:"w-full sm:w-auto",children:e.jsx(Bs,{tournament:t,compact:!0})}),e.jsx("button",{onClick:i,className:"min-h-9 min-w-0 rounded-md bg-[#61D095] px-3 text-xs font-bold text-[#06210F] transition-colors duration-200 hover:brightness-110 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#61D095]/60 sm:px-4 sm:text-sm",children:"Entrar al torneo"}),e.jsxs("button",{"aria-label":"Compartir",onClick:n,className:"inline-flex min-h-9 items-center justify-center rounded-md border border-[#262A2F] bg-[#14181C] px-3 text-xs font-semibold text-[#C5C7CB] transition-colors duration-200 hover:bg-[#1A1E23] sm:px-4 sm:text-sm",children:[e.jsx(zs,{className:"mr-1.5 h-3.5 w-3.5"}),"Compartir"]}),e.jsx("a",{href:"/Reglamento",className:"inline-flex min-h-9 items-center justify-center rounded-md border border-[#262A2F] bg-[#14181C] px-3 text-xs font-semibold text-[#C5C7CB] transition-colors duration-200 hover:bg-[#1A1E23] sm:px-4 sm:text-sm",children:"Reglamento"}),e.jsxs("button",{onClick:u,className:`inline-flex min-h-9 items-center justify-center gap-1.5 rounded-md border px-3 text-xs font-semibold transition-colors duration-200 sm:px-4 sm:text-sm ${r?"border-[#61D095]/40 bg-[#61D095]/10 text-[#61D095]":"border-[#262A2F] bg-[#14181C] text-[#C5C7CB] hover:bg-[#1A1E23]"}`,children:[e.jsx(Gs,{className:`h-3.5 w-3.5 ${r?"fill-current":""}`}),r?"Siguiendo":"Seguir"]})]})]})]}),e.jsx("div",{className:"grid grid-cols-2 divide-[#1A1D21] sm:grid-cols-4 sm:divide-x",children:C.map(({value:v,label:S,sub:$})=>e.jsxs("div",{className:"min-w-0 px-3 py-2.5 sm:px-4 sm:py-3",style:{borderLeft:"1px solid #1A1D21"},children:[e.jsx("p",{className:"truncate text-base font-bold tabular-nums text-[#F1F2F3] sm:text-xl",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:v}),e.jsx("p",{className:"mt-0.5 truncate text-[10px] font-medium uppercase tracking-wide text-[#8A8F96]",children:S}),e.jsx("p",{className:"mt-1 truncate text-[9px] text-[#5C6168]",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:$})]},S))})]})}const Tt=["Resumen","Participantes","Calendario","Salas","Bracket","Resultados","Clasificación","Predicciones","Premios","Reglamento"];function cr({active:t,onChange:s}){return e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"sticky top-0 z-20 block bg-[#101113]/95 py-1 backdrop-blur sm:hidden",children:[e.jsx("span",{className:"sr-only",children:"Sección del torneo"}),e.jsx("select",{value:t,onChange:i=>s(i.target.value),className:"h-11 w-full rounded-lg border border-[#2A2C30] bg-[#151619] px-3 text-sm font-semibold text-[#F4F4F5]",children:Tt.map(i=>e.jsx("option",{value:i,children:i},i))})]}),e.jsx("nav",{"aria-label":"Secciones del torneo",className:"sticky top-0 z-20 hidden w-full min-w-0 max-w-full touch-p
41an-x gap-1 overflow-x-auto overscroll-x-contain border-b border-[#2A2C30] bg-[#101113]/95 px-1 pt-1 backdrop-blur sm:flex",children:Tt.map(i=>e.jsx("button",{type:"button",onClick:()=>s(i),className:`min-h-11 flex-none touch-pan-x border-b-2 px-3 text-sm font-semibold transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-white/70 ${t===i?"border-[#ECEDEF] text-[#F4F4F5]":"border-transparent text-[#85888E] hover:text-[#D5D7DA]"}`,children:i},i))})]})}const dr={single_elimination:"Eliminación simple",double_elimination:"Eliminación doble",round_robin:"Todos contra todos",swiss:"Sistema suizo",groups_playoffs:"Grupos + playoffs"},mr={preparation:"Preparación",registration_open:"Inscripciones abiertas",registration_closed:"Inscripciones cerradas",live:"En vivo",completed:"Finalizado",cancelled:"Cancelado",archived:"Archivado"};function ie({label:t,value:s}){return e.jsxs("div",{className:"flex items-start justify-between gap-2 border-b border-[#2B2E34] py-1.5 last:border-0 sm:py-2",children:[e.jsx("span",{className:"text-[11px] text-[#8B9098] sm:text-xs",children:t}),e.jsx("strong",{className:"max-w-[68%] break-words text-right text-[11px] font-medium text-[#E1E3E6] sm:text-xs",children:s||"Por definir"})]})}function xr({tournament:t,groups:s=[]}){const i=t.prize||`${Number(t.prize_pool_total||0).toLocaleString()} ${t.prize_currency||"USD"}`;return e.jsxs("section",{className:"min-w-0 rounded-lg border border-[#2B2E34] bg-[#0D0F12] p-2.5 sm:p-3",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(es,{className:"h-4 w-4 text-[#61D095]"}),e.jsx("h2",{className:"text-sm font-semibold text-[#F4F5F6]",children:"Resumen"})]}),e.jsx("h3",{className:"mb-2 text-base font-semibold text-[#E1E3E6]",children:t.name}),e.jsx(ie,{label:"Organizador",value:t.organizer||t.organization||t.organizer_email}),e.jsx(ie,{label:"Fecha",value:t.start_date}),e.jsx(ie,{label:"Premio total",value:i}),e.jsx(ie,{label:"Formato",value:dr[t.format]||t.format}),e.jsx(ie,{label:"Grupos visibles",value:s.length}),e.jsx(ie,{label:"Grupos configurados",value:t.total_groups}),e.jsx(ie,{label:"Equipos por grupo",value:t.teams_per_group}),e.jsx(ie,{label:"Región",value:t.region}),e.jsx(ie,{label:"Estado",value:mr[t.status]||t.status})]})}function us({bracket:t=[],registrations:s=[],tournament:i}){if(!t.length)return e.jsxs("div",{className:"rounded-lg border border-dashed border-[#30363B] bg-[#0B0F12] p-10 text-center",children:[e.jsx(oa,{className:"mx-auto h-6 w-6 text-[#61D095]"}),e.jsx("h3",{className:"mt-3 text-sm font-bold text-[#F1F3F4]",children:"Bracket en preparación"}),e.jsx("p",{className:"mt-1 text-xs text-[#8B9298]",children:"El cuadro será publicado cuando finalice la fase correspondiente."})]});const n=t.reduce((r,a)=>{const c=a.group_name||a.group||"A",o=a.round||1,m=s.find(d=>d.id===a.team_a_id||d.team_id===a.team_a_id),x=s.find(d=>d.id===a.team_b_id||d.team_id===a.team_b_id),p={...a,team_a_logo:a.team_a_logo||m?.logo_url,team_b_logo:a.team_b_logo||x?.logo_url,team_a_country:a.team_a_country||m?.country,team_b_country:a.team_b_country||x?.country};return r[c]||(r[c]={}),r[c][o]||(r[c][o]=[]),r[c][o].push(p),r},{});return e.jsxs("div",{className:"min-w-0 rounded-lg border border-[#30363B] bg-[#0B0F12] p-4 sm:p-5",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("h2",{className:"text-[20px] font-bold leading-tight text-[#F1F3F4]",children:"Matches del Bracket"}),e.jsxs("p",{className:"mt-0.5 text-[12px] text-[#A3A9AD]",children:[t.length," total"]})]}),e.jsx("div",{className:"space-y-6",children:Object.keys(n).sort().map(r=>e.jsxs("section",{className:"min-w-0",children:[e.jsxs("p",{className:"horizontal-bracket-group-label mb-2",children:["Grupo ",r]}),e.jsx(aa,{rounds:n[r],template:i?.bracket_options?.template_config})]},r))})]})}const ur=["1.er lugar","2.º lugar","3.er lugar"];function pr({tournament:t,registrations:s}){let i=t.prize_distribution||[];return!i.length&&t.prize_pool_total&&(i=[{position:1,amount:t.prize_pool_total,percentage:100}]),i.length?e.jsx("div",{className:"grid gap-4 md:grid-cols-2 xl:grid-cols-3",children:i.map((n,r)=>{const a=s.find(c=>c.prize_position===Number(n.position));return e.jsxs("article",{className:"rounded-lg border border-[#2B2E34] bg-[#0D0F12] p-4",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-widest text-[#61D095]",children:n.label||ur[r]||`${n.position}.ª posición`}),e.jsx("p",{className:"mt-3 text-3xl font-black text-white",children:Number(n.amount)>
410?`${Number(n.amount).toLocaleString()} ${t.prize_currency||"USD"}`:Number(t.prize_pool_total)>0&&Number(n.percentage)>0?`${Math.round(Number(t.prize_pool_total)*Number(n.percentage)/100).toLocaleString()} ${t.prize_currency||"USD"}`:`${n.percentage||0}%`}),e.jsxs("dl",{className:"mt-6 space-y-3 text-sm",children:[e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-slate-500",children:"Ganador"}),e.jsx("dd",{className:"text-right font-bold text-slate-200",children:a?.team_name||"Por definir"})]}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-slate-500",children:"Estado"}),e.jsx("dd",{className:"font-bold text-slate-200",children:a?.prize_status==="sent"?"Entregado":"Pendiente"})]}),e.jsxs("div",{className:"flex justify-between gap-3",children:[e.jsx("dt",{className:"text-slate-500",children:"Entrega"}),e.jsx("dd",{className:"text-slate-200",children:a?.prize_sent_at?new Date(a.prize_sent_at).toLocaleDateString("es"):"Por definir"})]})]})]},n.position||r)})}):e.jsx(je,{icon:Lt,title:"Premios por anunciar",text:"La distribución oficial aparecerá aquí cuando el organizador la publique."})}function hr({tournament:t}){const s=t.quick_rules||t.rules||t.penalties_text;return!s&&!t.rulebook_url?e.jsx(je,{icon:_t,title:"Reglamento en preparación",text:"Las reglas oficiales se publicarán antes del inicio de la competición."}):e.jsxs("section",{className:"rounded-lg border border-[#2B2E34] bg-[#0D0F12] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_t,{className:"h-5 w-5 text-[#61D095]"}),e.jsx("h2",{className:"text-base font-semibold text-[#F4F5F6]",children:"Reglamento oficial"})]}),s&&e.jsx("div",{className:"mt-6 whitespace-pre-line text-sm leading-7 text-slate-300",children:s}),t.rulebook_url&&e.jsxs("a",{href:t.rulebook_url,target:"_blank",rel:"noreferrer",className:"mt-4 inline-flex items-center gap-2 rounded-md bg-[#61D095] px-3 py-2 text-xs font-bold text-[#07100B]",children:["Abrir reglamento completo",e.jsx(Bt,{className:"h-4 w-4"})]})]})}const br=t=>t?.display_status==="approved"?"Aprobado":t?.display_status==="roster_incomplete"?"Roster incompleto":"Pendiente",gr=t=>t?.display_status==="approved"?"text-[#58C781]":"text-[#D49A45]",At={full:{fields:["rank","logo","team","tag","country","status"],columns:"grid-cols-[40px_48px_minmax(120px,1fr)_70px_90px_132px]",width:"min-w-[600px]",row:"py-2",logo:"h-7 w-7"},dense:{fields:["rank","logo","team","tag","country","status"],columns:"grid-cols-[34px_40px_minmax(110px,1fr)_58px_78px_118px]",width:"min-w-[540px]",row:"py-1",logo:"h-5 w-5"},compact:{fields:["rank","team","country","status"],columns:"grid-cols-[34px_minmax(130px,1fr)_82px_118px]",width:"min-w-[400px]",row:"py-1.5",logo:"h-5 w-5"},minimal:{fields:["rank","team"],columns:"grid-cols-[34px_minmax(160px,1fr)]",width:"min-w-[250px]",row:"py-1",logo:"h-5 w-5"},info:{fields:["team","tag","country","status"],columns:"grid-cols-[minmax(140px,1fr)_65px_88px_122px]",width:"min-w-[430px]",row:"py-1.5",logo:"h-5 w-5"}},fr={rank:"#",logo:"Logo",team:"Equipo",tag:"Tag",country:"País",status:"Estado"};function jr({group:t,teams:s,mine:i,viewMode:n="full"}){const r=At[n]||At.full;return e.jsxs("div",{className:"w-full overflow-x-auto rounded-md border border-[#343B42]",children:[e.jsx("div",{className:`grid ${r.width} ${r.columns} bg-[#20262A] text-[11px] text-[#AEB4B9]`,children:r.fields.map(a=>e.jsx("span",{className:`border-r border-[#343B42] px-2 py-1.5 last:border-r-0 ${a==="country"?"text-center":""}`,children:fr[a]},a))}),Array.from({length:t.max_teams},(a,c)=>{const o=s[c],m=o?.id===i,x=o?.country_code||o?.country||"GLOBAL";if(!o)return e.jsx("div",{className:`grid ${r.width} ${r.columns} border-t border-[#343B42] bg-[#11161A] text-[11px] text-[#8E969D]`,children:e.jsxs("span",{className:"px-2 py-1.5",style:{gridColumn:"1 / -1"},children:["#",c+1," · Vacante disponible"]})},c);const p=d=>d==="rank"?e.jsx("span",{className:"px-2 text-[#A6ADB3]",children:c+1}):d==="logo"?e.jsx("span",{className:"px-2",children:o.logo_url?e.jsx("img",{src:o.logo_url,alt:"",className:`${r.logo} object-contain`}):e.jsx(de,{className:"h-4 w-4 text-[#69727A]"})}):d==="team"?e.jsxs("span",{className:"min-w-0 truncate px-2 font-medium",children:[o.team_name,m&&e.jsx("small",{className:"ml-1 text-[8px] font-bold text-[#58C781]",children:"TU EQUIPO"})]}):d==="tag"?e.jsx("span",{className:"truncate px-2 text-[#BEC3C7]",children:o.tag||"—"}):d==="country"?e.jsx("span",{className:"flex items-center justify-center px-2",children:e.jsx(rs,{code:x,className:"h-3.5 w-5 flex-none"})}):e.jsx("span",{className:`whitespace-normal break-words px-2 leading-tight ${gr(o)}`,children:br(o)});return e.jsx("div",{className:`grid ${r.width} ${r.columns} items-center border-t border-[#343B42] bg-[#11161A] ${r.row} text-[11px] text-[#DDE0E2] ${m?"bg-[#151D1A]":""}`,children:r.fields.map(d=>e.jsx(D.Fragment,{children:p(d)},d))},o.id)})]})}function wr({group:t,registrations:s,mine:i,defaultOpen:n,viewMode:r}){const[a,c]=g.useState(n),o=t.teams.map(d=>s.find(u=>
41u.id===d)).filter(Boolean),m=t.max_teams||1,x=Math.min(100,o.length/m*100),p=o.length>=m;return e.jsxs(e.Fragment,{children:[e.jsxs("button",{"aria-label":`${a?"Cerrar":"Abrir"} grupo ${t.group_name}`,"aria-expanded":a,onClick:()=>c(!a),className:`order-1 min-w-0 border-b border-r border-[#343B42] px-4 py-3 text-left transition-colors last:border-r-0 lg:border-b-0 ${a?"bg-[#173326]":"bg-[#11161A] hover:bg-[#171D21]"}`,children:[e.jsxs("p",{className:"truncate text-[14px] font-semibold text-[#F1F3F4]",children:["Grupo ",t.group_name]}),e.jsxs("p",{className:"mt-0.5 text-[12px] text-[#A6ADB3]",children:[o.length,"/",t.max_teams," equipos"]}),e.jsx("span",{className:"mt-2 block h-1 overflow-hidden rounded-full bg-[#2B3238]",children:e.jsx("span",{className:`block h-full rounded-full ${p?"bg-[#58C781]":"bg-[#AAB3BA]"}`,style:{width:`${x}%`}})})]}),a&&e.jsxs("div",{className:"order-2 col-span-full min-w-0 border-t border-[#343B42] bg-[#090C0F] px-3 pb-3 pt-4",children:[e.jsxs("h3",{className:"mb-2 text-[15px] font-medium text-[#F1F3F4]",children:["Grupo ",t.group_name]}),e.jsx(jr,{group:t,teams:o,mine:i,viewMode:r})]})]})}const vr=[{id:"full",label:"Completa",icon:Xs},{id:"dense",label:"Densa",icon:ea},{id:"compact",label:"Compacta",icon:Ss},{id:"minimal",label:"Mínima",icon:Oa},{id:"info",label:"Info",icon:es}];function ps({value:t,onChange:s,targetId:i,label:n="Vista"}){const[r,a]=g.useState(!1);g.useEffect(()=>{const o=()=>a(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",o),()=>document.removeEventListener("fullscreenchange",o)},[]);const c=()=>r?document.exitFullscreen():document.getElementById(i)?.requestFullscreen();return e.jsxs("div",{className:"flex min-w-0 touch-pan-x items-center gap-1 overflow-x-auto overscroll-x-contain rounded-md border border-[#1E2226] bg-[#11151A] p-1","aria-label":n,children:[vr.map(({id:o,label:m,icon:x})=>e.jsxs("button",{onClick:()=>s(o),title:m,className:`flex h-8 flex-none touch-pan-x items-center gap-1.5 rounded px-2 text-[11px] font-semibold transition-colors ${t===o?"bg-[#ECEDEF] text-[#111214]":"text-[#9FA6AC] hover:bg-[#1A1F25] hover:text-white"}`,children:[e.jsx(x,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:m})]},o)),e.jsx("span",{className:"mx-0.5 h-5 w-px flex-none bg-[#262A2F]"}),e.jsxs("button",{onClick:c,title:r?"Salir de pantalla completa":"Pantalla completa",className:"flex h-8 flex-none touch-pan-x items-center gap-1.5 rounded px-2 text-[11px] font-semibold text-[#9FA6AC] hover:bg-[#1A1F25] hover:text-white",children:[r?e.jsx(ta,{className:"h-3.5 w-3.5"}):e.jsx(sa,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:r?"Salir":"Pantalla completa"})]})]})}function et({groups:t,registrations:s,myRegistration:i}){const[n,r]=g.useState("dense"),a=t;return a.length?e.jsxs("div",{id:"participants-stage",className:"min-h-0 min-w-0 space-y-1 bg-[#090C0F] p-1 fullscreen:h-full fullscreen:overflow-auto",children:[e.jsx(ps,{value:n,onChange:r,targetId:"participants-stage",label:"Vista de participantes"}),e.jsxs("section",{className:"grid min-w-0 grid-cols-1 overflow-hidden rounded-lg border border-[#343B42] bg-[#090C0F] shadow-[0_16px_40px_rgba(0,0,0,0.28)] min-[390px]:grid-cols-2 lg:grid-cols-4",children:[e.jsx("h2",{className:"order-0 col-span-full border-b border-[#343B42] bg-[#161B1F] px-4 py-2 text-[14px] font-medium text-[#F1F3F4]",children:"Participantes"}),a.map((c,o)=>e.jsx(wr,{group:c,registrations:s,mine:i?.id,defaultOpen:o===0,viewMode:n},c.id))]})]}):e.jsx("div",{className:"rounded-lg border border-dashed border-[#343B42] bg-[#0B0E11] p-10 text-center text-sm text-[#737B83]",children:"Los grupos todavía no están disponibles."})}const He=[{id:"vanguard",label:"Vanguardia",detail:"Lima competitivo"},{id:"cyber_grid",label:"Cyber Grid",detail:"Cian táctico"},{id:"minimal_dark",label:"Minimal Dark",detail:"Editorial limpio"},{id:"neon_pro",label:"Neon Pro",detail:"Púrpura eléctrico"},{id:"dark_elite",label:"Dark Elite",detail:"Metal premium"},{id:"holographic",label:"Holográfico",detail:"Cristal digital"}
41,{id:"glitch",label:"Glitch",detail:"Señal fragmentada"},{id:"blue_ice",label:"Blue Ice",detail:"Azul glacial"},{id:"gold_prestige",label:"Gold Prestige",detail:"Dorado campeón"}],Nr={show_scores:!0,show_logos:!0,compact:!1,animated:!0};function yr({templates:t,selectedId:s,onApply:i}){return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-bold text-white",children:"Biblioteca pública"}),e.jsxs("button",{type:"button",onClick:()=>i(ra,""),className:"flex items-center gap-1 text-[11px] font-bold text-[#61D095]",children:[e.jsx(ia,{className:"h-3 w-3"}),"Restaurar predeterminado"]})]}),e.jsx("div",{className:"grid max-h-40 grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-3",children:t.map(n=>e.jsxs("button",{type:"button",onClick:()=>i(n.config,n.id),className:`relative min-h-14 rounded-md border p-2 text-left ${s===n.id?"border-[#61D095] bg-[#61D095]/10":"border-white/10 bg-white/[.03]"}`,children:[e.jsx("span",{className:"block truncate text-xs font-bold text-white",children:n.name}),e.jsx("span",{className:"text-[9px] text-white/40",children:n.is_default?"Global predeterminada":"Plantilla compartida"}),s===n.id&&e.jsx(tt,{className:"absolute right-2 top-2 h-3 w-3 text-[#61D095]"})]},n.id))})]})}function _r({config:t,onChange:s}){const[i,n]=g.useState(!1),r=t.background,a=o=>s({...t,background:{...r,...o}}),c=async o=>{const m=o.target.files?.[0];if(m){n(!0);try{const{file_url:x}=await f.integrations.Core.UploadFile({file:m});a({type:"image",image_url:x})}catch{A.error("No se pudo subir el fondo")}finally{n(!1)}}};return e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("label",{className:"text-[11px] text-white/55",children:["Tipo de fondo",e.jsxs("select",{value:r.type,onCh
41ange:o=>a({type:o.target.value}),className:"mt-1 h-9 w-full rounded-md border border-white/10 bg-[#11171b] px-2 text-xs text-white",children:[e.jsx("option",{value:"color",children:"Color"}),e.jsx("option",{value:"gradient",children:"Degradado"}),e.jsx("option",{value:"pattern",children:"Textura o patrón"}),e.jsx("option",{value:"image",children:"Imagen"})]})]}),r.type==="pattern"&&e.jsxs("label",{className:"text-[11px] text-white/55",children:["Patrón",e.jsxs("select",{value:r.pattern,onChange:o=>a({pattern:o.target.value}),className:"mt-1 h-9 w-full rounded-md border border-white/10 bg-[#11171b] px-2 text-xs text-white",children:[e.jsx("option",{value:"grid",children:"Cuadrícula"}),e.jsx("option",{value:"dots",children:"Puntos"}),e.jsx("option",{value:"diagonal",children:"Diagonal"})]})]}),[["color","Color principal"],["color2","Color secundario"],["card_color","Tarjetas"],["line_color","Conectores"]].map(([o,m])=>e.jsxs("label",{className:"flex items-center justify-between rounded-md border border-white/10 bg-[#11171b] px-2 py-1 text-[11px] text-white/60",children:[m,e.jsx("input",{type:"color",value:o in r?r[o]:t[o],onChange:x=>o in r?a({[o]:x.target.value}):s({...t,[o]:x.target.value}),className:"h-7 w-9 border-0 bg-transparent"})]},o)),r.type==="image"&&e.jsxs("label",{className:"flex min-h-10 cursor-pointer items-center justify-center gap-2 rounded-md border border-dashed border-white/20 bg-white/[.03] text-xs font-bold text-white/70 sm:col-span-2",children:[i?e.jsx(Y,{className:"h-4 w-4 animate-spin"}):e.jsx(na,{className:"h-4 w-4"}),r.image_url?"Cambiar imagen de fondo":"Subir imagen de fondo",e.jsx("input",{type:"file",accept:"image/*",onChange:c,className:"hidden"})]})]})}const Cr={logo:e.jsx(de,{}),flag:e.jsx(rs,{code:"DO"}),name:e.jsx("span",{children:"Nombre del equipo"}),score:e.jsx("b",{children:"2"})};function kr({positions:t,onChange:s,cardColor:i}){const n=g.useRef(null),[r,a]=g.useState(""),c=o=>{if(!r||!n.current)return;const m=n.current.getBoundingClientRect();s({...t,[r]:{x:Math.max(3,Math.min(97,(o.clientX-m.left)/m.width*100)),y:Math.max(10,Math.min(90,(o.clientY-m.top)/m.height*100))}})};return e.jsxs("div",{children:[e.jsx("p",{className:"mb-2 text-xs font-bold text-white",children:"Distribución arrastrable"}),e.jsx("p",{className:"mb-3 text-[11px] text-white/45",children:"Arrastra cada elemento a su posición dentro de la fila."}),e.jsxs("div",{ref:n,onPointerMove:c,onPointerUp:()=>a(""),onPointerLeave:()=>a(""),className:"relative h-20 touch-none overflow-hidden rounded-lg border border-white/15",style:{backgroundColor:i},children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-5 bg-black/25"}),e.jsx("span",{className:"absolute left-2 top-1 text-[9px] text-white/60",children:"MATCH DE MUESTRA"}),Object.entries(Cr).map(([o,m])=>e.jsx("button",{type:"button",onPointerDown:x=>{x.currentTarget.setPointerCapture(x.pointerId),a(o)},className:"absolute z-10 flex -translate-x-1/2 -translate-y-1/2 cursor-grab items-center justify-center whitespace-nowrap rounded border border-[#61D095]/40 bg-black/45 px-1.5 py-1 text-[10px] text-white active:cursor-grabbing [&_svg]:h-3.5 [&_svg]:w-4",style:{left:`${t[o].x}%`,top:`${t[o].y}%`},children:m},o))]})]})}function Sr({value:t,templateId:s,onChange:i}){const n=re(),[r,a]=g.useState(""),[c,o]=g.useState(!1),m=Ct(t),{data:x=[]}=U({queryKey:["bracket-templates"],queryFn:()=>f.entities.BracketTemplate.filter({active:!0},"-created_date",100)}),p=(u,b)=>i(Ct(u),b),d=async()=>{if(!r.trim())return A.error("Escribe un nombre para la plantilla");o(!0);try{const u=await f.auth.me(),b=await f.entities.BracketTemplate.create({name:r.trim(),description:"Diseño comunitario de bracket",config:m,is_default:!1,active:!0,created_by_name:u?.full_name||"Comunidad"});await n.invalidateQueries({queryKey:["bracket-templates"]}),a(""),p(b.config,b.id),A.success("Plantilla añadida a la biblioteca")}catch{A.error("No se pudo crear la plantilla")}finally{o(!1)}};return e.jsxs("section",{className:"mt-4 space-y-4 border-t border-white/10 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-bold text-white",children:[e.jsx(Ga,{className:"h-4 w-4 text-[#61D095]"}),"Plantillas y editor visual"]}),e.jsx(yr,{templates:x,selectedId:s,onApply:p}),e.jsx(_r,{config:m,onChange:u=>p(u,s)}),e.jsx(kr,{positions:m.positions,cardColor:m.card_color,onChange:u=>p({...m,positions:u},s)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:r,onChange:u=>a(u.target.value),placeholder:"Nombre de la nueva plantilla",className:"h-9 min-w-0 flex-1 rounded-md border border-white/10 bg-[#11171b] px-3 text-xs text-white"}
41),e.jsxs("button",{type:"button",onClick:d,disabled:c,className:"flex h-9 items-center gap-1.5 rounded-md bg-[#61D095] px-3 text-xs font-black text-[#07110c] disabled:opacity-50",children:[e.jsx(Me,{className:"h-3.5 w-3.5"}),"Publicar plantilla"]})]})]})}function hs({tournament:t,onApplied:s}){const[i,n]=g.useState(t.bracket_style||"vanguard"),[r,a]=g.useState(t.format==="double_elimination"?"double_elimination":"single_elimination"),[c,o]=g.useState({...Nr,...t.bracket_options}),[m,x]=g.useState(!1),[p,d]=g.useState(!1),u=He.find(h=>h.id===i)||He[0],b=h=>s?.({...t,bracket_style:i,format:r,bracket_options:c,...h}),C=h=>{n(h),b({bracket_style:h})},v=h=>{a(h),b({format:h})},S=h=>o(_=>{const I={..._,[h]:!_[h]};return b({bracket_options:I}),I}),$=(h,_)=>o(I=>{const P={...I,template_config:h,template_id:_};return s?.({...t,bracket_style:i,format:r,bracket_options:P}),P}),R=async()=>{d(!0);try{const h=await f.functions.invoke("updateTournamentBracketDesign",{tournament_id:t.id,bracket_style:i,format:r,bracket_options:c});s?.(h.data.tournament),x(!1),A.success("Diseño del bracket guardado")}catch(h){A.error(h.response?.data?.error||"No se pudo guardar el diseño")}finally{d(!1)}};return e.jsxs("section",{className:"bracket-config-panel",children:[e.jsxs("button",{"aria-label":`${m?"Cerrar":"Abrir"} opciones de diseño del bracket`,type:"button",className:"bracket-design-trigger",onClick:()=>x(h=>!h),"aria-expanded":m,children:[e.jsx("span",{className:`bracket-theme-dot theme-${i}`}),e.jsxs("span",{children:[e.jsx("b",{children:"Diseño del bracket"}),e.jsxs("small",{children:["Administración del torneo · ",u.label]})]}),e.jsx(qe,{className:m?"open":""})]}),m&&e.jsxs("div",{className:"bracket-design-menu",children:[e.jsx("div",{className:"bracket-style-list",children:He.map(h=>e.jsxs("button",{type:"button",onClick:()=>C(h.id),"aria-pressed":i===h.id,className:`bracket-style-option theme-${h.id} ${i===h.id?"selected":""}`,children:[e.jsxs("span",{className:"bracket-style-swatch",children:[e.jsx("i",{}),e.jsx("i",{})]}),e.jsxs("span",{children:[e.jsx("b",{children:h.label}),e.jsx("small",{children:h.detail})]}),i===h.id&&e.jsx(tt,{})]},h.id))}),e.jsxs("div",{className:"bracket-config-row",children:[e.jsxs("div",{children:[e.jsx("span",{children:"Formato"}),e.jsxs("div",{className:"bracket-segment",children:[e.jsx("button",{type:"button","aria-pressed":r==="single_elimination",className:r==="single_elimination"?"active":"",onClick:()=>v("single_elimination"),children:"Eliminación simple"}),e.jsx("button",{type:"button","aria-pressed":r==="double_elimination",className:r==="double_elimination"?"active":"",onClick:()=>v("double_elimination"),children:"Eliminación doble"})]})]}),e.jsx("div",{className:"bracket-option-list",children:[["show_scores","Marcadores"],["show_logos","Logos"],["compact","Vista compacta"],["animated","Animación"]].map(([h,_])=>e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:c[h],onChange:()=>S(h)}),e.jsx("span",{children:_})]},h))})]}),e.jsx(Sr,{value:c.template_config,templateId:c.template_id,onChange:$}),e.jsxs("button",{"aria-label":"Guardar",type:"button",className:"bracket-save",onClick:R,disabled:p,children:[p?e.jsx(Y,{className:"animate-spin"}):e.jsx(Me,{}),"Guardar diseño del torneo"]})]})]})}function Er({tournament:t,registrations:s,bracket:i,isAdmin:n}){const[r,a]=g.useState(t);return e.jsxs("div",{className:"min-w-0 max-w-full space-y-3 overflow-hidden",children:[n&&e.jsx(hs,{tournament:r,onApplied:a}),n&&e.jsx(ts,{tournament:r,registrations:s.filter(c=>c.status==="approved"),bracketMatches:i}),e.jsx(us,{bracket:i,registrations:s,tournament:r})]})}const Tr=(t,s)=>t.reduce((i,n,r)=>{const a=s.findIndex(c=>c.id===n.id);return i+(a<0?0:Math.max(1,t.length-Math.abs(r-a)))},0);function Ar({tournament:t,registrations:s,actualRows:i}){const{user:n}=Pe(),r=re(),a=g.useMemo(()=>s.filter(b=>b.status==="approved").map(b=>({id:b.team_id||b.id,name:b.team_name})),[s]),[c,o]=g.useState(a),{data:m=[]}=U({queryKey:["tier-list",t.id],queryFn:()=>f.entities.TournamentPrediction.filter({tournament_id:t.id},"-submitted_at",200)}),x=m.find(b=>b.user_id===n?.id);D.useEffect(()=>o(x?.ranking?.length?x.ranking:a),[x?.id,a.length]);const p=(b,C)=>o(v=>{const S=[...v],$=b+C;return $<0||$>=S.length?v:([S[b],S[$]]=[S[$],S[b]],S)}),d=async()=>
41{if(!n)return f.auth.redirectToLogin(window.location.href);const b={tournament_id:t.id,user_id:n.id,display_name:n.nickname||n.full_name||"Jugador",ranking:c,submitted_at:new Date().toISOString(),locked:t.status==="completed"};x?await f.entities.TournamentPrediction.update(x.id,b):await f.entities.TournamentPrediction.create(b),r.invalidateQueries({queryKey:["tier-list",t.id]}),A.success("Predicción guardada")},u=[...m].map(b=>({...b,score:Tr(b.ranking||[],i)})).sort((b,C)=>C.score-b.score);return e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsxs("section",{className:"rounded-xl border border-white/10 bg-white/[0.04] p-4",children:[e.jsx("h3",{className:"font-black",children:"Arma tu Tier List"}),e.jsx("div",{className:"mt-3 space-y-1",children:c.map((b,C)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-lg bg-black/30 p-2",children:[e.jsx("b",{className:"w-7 text-amber-400",children:C+1}),e.jsx("span",{className:"flex-1 text-sm",children:b.name}),e.jsx("button",{onClick:()=>p(C,-1),children:e.jsx(la,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>p(C,1),children:e.jsx(ca,{className:"h-4 w-4"})})]},b.id))}),e.jsx("button",{"aria-label":"Guardar",onClick:d,disabled:!c.length||t.status==="completed",className:"mt-3 w-full rounded-lg bg-amber-400 p-3 font-black text-black disabled:opacity-40",children:"Guardar predicción"})]}),e.jsxs("section",{className:"rounded-xl border border-white/10 bg-white/[0.04] p-4",children:[e.jsxs("h3",{className:"flex items-center gap-2 font-black",children:[e.jsx(W,{className:"h-4 w-4 text-amber-400"}),"Ranking de aciertos"]}),e.jsxs("div",{className:"mt-3 space-y-2",children:[u.map((b,C)=>e.jsxs("div",{className:"flex justify-between rounded-lg bg-black/30 p-3 text-sm",children:[e.jsxs("span",{children:[C+1,". ",b.display_name]}),e.jsxs("b",{children:[b.score," pts"]})]},b.id)),!u.length&&e.jsx("p",{className:"py-8 text-center text-sm text-white/40",children:"Aún no hay predicciones."})]})]})]})}const Ft=({title:t,className:s="",children:i})=>e.jsxs("section",{className:`min-w-0 rounded-lg border border-[#292B30] bg-[#15171A] p-3 sm:p-4 ${s}`,children:[e.jsx("h2",{className:"mb-3 text-sm font-semibold text-[#F1F2F3]",children:t}),i]});function Fr({tab:t,onTabChange:s,tournament:i,registrations:n,groups:r,bracket:a,rooms:c,matches:o,mine:m,isAdmin:x,layoutMode:p="full"}){const d={Participantes:e.jsx(et,{groups:r,registrations:n,myRegistration:m}),Calendario:e.jsx(Ze,{tournament:i,matches:o}),Salas:e.jsx(as,{rooms:c}),Bracket:e.jsx(Er,{tournament:i,registrations:n,bracket:a,isAdmin:x},i.id),Resultados:e.jsx(ss,{matches:o}),Clasificación:e.jsx(wt,{rows:Ve(o),registrations:n}),Predicciones:e.jsx(Ar,{tournament:i,registrations:n,actualRows:Ve(o)}),Premios:e.jsx(pr,{tournament:i,registrations:n}),Reglamento:e.jsx(hr,{tournament:i})},u=p==="dense"?"max-h-[680px]":p==="compact"?"max-h-[420px]":p==="minimal"?"max-h-[300px]":p==="info"?"max-h-[760px]":"max-h-[520px]";return e.jsxs("div",{className:`min-w-0 max-w-full overflow-x-hidden ${p==="dense"||p==="compact"?"space-y-1":"space-y-2 sm:space-y-3"}`,children:[e.jsx(cr,{active:t,onChange:s}),e.jsx("main",{className:"min-w-0",children:t==="Resumen"?e.jsxs("div",{className:"grid min-w-0 gap-2 sm:gap-3 lg:grid-cols-12",children:[e.jsx("div",{className:"lg:col-span-4",children:e.jsx(xr,{tournament:i,groups:r})}),e.jsx("div",{className:"min-w-0 lg:col-span-8",children:e.jsx("div",{className:`${u} overflow-y-auto`,children:e.jsx(et,{groups:r,registrations:n,myRegistration:m})})}),e.jsx(Ft,{title:"Próximas partidas",className:"lg:col-span-7",children:e.jsx(Ze,{tournament:i,matches:o})}),e.jsx(Ft,{title:"Clasificación",className:"lg:col-span-5",children:e.jsx(wt,{rows:Ve(o),registrations:n})})]}):d[t]})]})}const $r=[{id:"public",label:"Vista pública"},{id:"participant",label:"Panel del participante",requiresRegistration:!0},{id:"admin",label:"Panel administrativo",requiresAdmin:!0}];function Rr({view:t,onChange:s,hasRegistration:i,canManage:n}){const r=$r.filter(a=>(!a.requiresRegistration||i)&&(!a.requiresAdmin||n));return r.length===1?null:e.jsx("div",{className:"flex w-full min-w-0 max-w-full touch-p
41an-x gap-1 overflow-x-auto overscroll-x-contain rounded-lg border border-[#1E2226] bg-[#11151A] p-1","aria-label":"Tipo de vista",children:r.map(a=>e.jsx("button",{onClick:()=>s(a.id),className:`min-h-9 flex-none touch-pan-x rounded-md px-3 text-xs font-semibold sm:min-h-10 sm:px-4 sm:text-[13px] transition-colors duration-200 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[#61D095]/50 ${t===a.id?"bg-[#61D095] text-[#06210F] shadow-[0_0_0_1px_#61D095] hover:brightness-110":"text-[#9B9EA4] hover:bg-[#1A1F25] hover:text-[#E7E9EC]"}`,children:a.label},a.id))})}function $t(t){if(t<=0)return"00:00:00";const s=Math.floor(t/36e5),i=Math.floor(t%36e5/6e4),n=Math.floor(t%6e4/1e3);return`${String(s).padStart(2,"0")}:${String(i).padStart(2,"0")}:${String(n).padStart(2,"0")}`}function Dr({tournament:t,registration:s}){const i=re(),[n,r]=g.useState(Date.now());g.useEffect(()=>{const b=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(b)},[]);const a=ne({mutationFn:()=>f.functions.invoke("updateTournamentRegistration",{action:"check_in",id:s.id,idempotency_key:crypto.randomUUID()}),onSuccess:()=>{i.invalidateQueries({queryKey:["all-registrations"],exact:!1}),i.invalidateQueries({queryKey:["tournament-registrations"],exact:!1}),A.success("Check-in confirmado ✓")},onError:()=>A.error("No se pudo confirmar el check-in")});if(!!!t?.check_in_enabled||!s||s.display_status==="rejected")return null;const o=t.check_in_deadline?new Date(t.check_in_deadline).getTime():null,m=t.check_in_open_at?new Date(t.check_in_open_at).getTime():null,x=!m||n>=m,p=o&&n>o;if(!!s.checked_in)return e.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded-2xl border border-emerald-400/40 bg-emerald-500/10 p-4",children:[e.jsx(ae,{className:"h-6 w-6 text-emerald-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-black text-emerald-300",children:"Check-in confirmado"}),e.jsx("p",{className:"text-[11px] text-emerald-400/70",children:s.checked_in_at?new Date(s.checked_in_at).toLocaleString():"Tu participación está garantizada."})]})]});if(!x){const b=m-n;return e.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded-2xl border border-white/10 bg-slate-900/80 p-4",children:[e.jsx(Xe,{className:"h-6 w-6 text-white/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold text-white",children:"El check-in abre pronto"}),e.jsxs("p",{className:"text-[11px] text-white/50",children:["Disponible en ",$t(b)]})]})]})}if(p)return e.jsxs("div",{className:"mt-4 flex items-center gap-3 rounded-2xl border border-red-500/40 bg-red-500/10 p-4",children:[e.jsx(is,{className:"h-6 w-6 text-red-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-black text-red-300",children:"Check-in cerrado"}),e.jsx("p",{className:"text-[11px] text-red-400/70",children:"La fecha límite pasó. Contacta al organizador."})]})]});const u=o-n;return e.jsxs("div",{className:"mt-4 rounded-2xl border border-amber-400/30 bg-amber-500/10 p-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Le,{className:"h-5 w-5 text-amber-400"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-black text-amber-300",children:"Check-in obligatorio"}),e.jsx("p",{className:"text-[11px] text-amber-400/70",children:"Confirma tu participación antes del cierre"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-amber-400/60",children:"Tiempo restante"}),e.jsx("p",{className:"font-mono text-sm font-bold text-amber-200",children:$t(u)})]})]}),e.jsx("button",{onClick:()=>a.mutate(),disabled:a.isPending,className:"mt-3 w-full rounded-xl bg-amber-400 py-2.5 text-[13px] font-black text-black transition hover:bg-amber-300 disabled:opacity-50",children:a.isPending?"Confirmando...":"Confirmar check-in"})]})}function Te({label:t,value:s}){return e.jsxs("div",{className:"rounded-xl bg-slate-950 p-3",children:[e.jsx("p",{className:"text-[10px] uppercase tracking-wider text-slate-600",children:t}),e.jsx("b",{className:"mt-1 block text-sm text-white",children:s})]})}function Ae({icon:t,text:s,onClick:i}){return e.jsxs("button",{onClick:i,className:"rounded-xl border border-slate-800 p-3 text-center text-[10px] font-bold text-slate-300 transition hover:border-amber-400 hover:text-white",children:[e.jsx(t,{className:"mx-auto mb-1 h-4 w-4 text-amber-400"}),s]})}function Pr({registration:t,group:s,tournament:i,onSelect:n}){if(!t)return null;const r=i?.status==="completed",a=t.final_position||t.prize_position,c=t.prize_position===1?"Campeón":a&&a<=8?`Top ${a}`:a?"Eliminado":"Participación finalizada";return e.jsxs("section",{className:"rounded-2xl border border-amber-400/25 bg-slate-900/80 p-5 shadow-xl",children:[e.jsx("p",{className:"text-xs font-black uppercase tracking-widest text-amber-400",children:"Mi participación"}),e.jsxs("div",{className:"mt-4 flex items-center gap-3",children:[t.logo_url?e.jsx("img",{src:t.logo_url,className:"h-16 w-16 rounded-xl object-contain",alt:""}):e.jsx(de,{className:"h-12 w-12 text-slate-600"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"break-words text-lg font-black text-white",children:t.team_name}),e.jsx("p",{className:"text-xs text-slate-400",children:r?c:t.display_status==="approved"?"Aprobado":t.display_status==="roster_incomplete"?"Roster incompleto":"Pendiente"})]})]}),e.jsxs("div",{className:"mt-5 grid grid-cols-2 gap-2",children:[e.jsx(Te,{label:"Grupo",value:s?.group_name||"—"}),e.jsx(Te,{label:"Slot",value:t.slot_number||"—"}),e.jsx(Te,{label:"Posición",value:a||"—"}),e.jsx(Te,{label:"Roster",value:`${vt(t).length}/7`})]}),e.jsx(Dr,{tournament:i,registration:t}),e.jsx("p",{className:"mt-5 text-xs text-slate-500",children:"Próximo paso"}),e.jsx("p",{className:"mt-1 font-bold text-white",children:r?c:vt(t).length<4?"Completar roster":s?"Revisar calendario":"Esperar asignación de grupo"}),e.jsxs("div",{className:"mt-5 grid grid-cols-2 gap-2",children:[e.jsx(Ae,{icon:ee,text:"Ver grupo",onClick:()=>n?.("Mi grupo")}),e.jsx(Ae,{icon:ve,text:"Calendario",onClick:()=>
41n?.("Calendario")}),e.jsx(Ae,{icon:Le,text:"Salas",onClick:()=>n?.("Salas")}),!r&&e.jsx(Ae,{icon:ee,text:"Gestionar roster",onClick:()=>location.assign("/TeamDashboard")})]})]})}function bs({eyebrow:t,title:s,description:i}){return e.jsxs("header",{className:"mb-3 border-b border-[#1E2226] pb-3",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-[0.18em] text-[#61D095]",style:{fontFamily:"ui-monospace, SFMono-Regular, Menlo, monospace"},children:t}),e.jsx("h2",{className:"mt-1 text-base font-bold text-[#F1F2F3]",style:{fontFamily:'"Rajdhani", "Inter", sans-serif'},children:s}),e.jsx("p",{className:"mt-1 text-xs leading-relaxed text-[#8A8F96]",children:i})]})}const Rt=[["Mi equipo",it,"Estado de tu inscripción, roster y próximos pasos."],["Mi grupo",ee,"Equipos y asignación de tu grupo competitivo."],["Bracket",ms,"Cruces, rondas y avance del torneo."],["Calendario",nt,"Fechas y horarios de tus partidas."],["Salas",Le,"Datos de acceso a las salas asignadas."],["Resultados",W,"Marcadores y resultados oficiales."],["Progreso",xs,"Seguimiento de tu rendimiento competitivo."],["Notificaciones",Ot,"Avisos importantes del organizador."],["Copilot",Ee,"Ayuda contextual para tu participación."]];function qr({tournament:t,registration:s,group:i,groups:n,registrations:r,bracket:a=[],matches:c,rooms:o}){const[m,x]=g.useState("Mi equipo"),p=Rt.find(([d])=>d===m);return e.jsxs("div",{className:"tournament-admin-compact grid min-w-0 gap-3 lg:grid-cols-[210px_minmax(0,1fr)]",children:[e.jsx("aside",{className:"grid h-fit grid-cols-2 gap-1 rounded-xl border border-[#1E2226] bg-[#11151A] p-2 sm:grid-cols-3 lg:block",children:Rt.map(([d,u])=>e.jsxs("button",{onClick:()=>x(d),"aria-current":m===d?"page":void 0,className:`flex min-h-11 w-full items-center gap-2 rounded-md px-2 py-2 text-left text-xs font-semibold transition ${m===d?"bg-[#61D095] text-[#06210F]":"text-[#9B9EA4] hover:bg-[#1A1F25] hover:text-white"}`,children:[e.jsx(u,{className:"h-4 w-4 flex-none"}),e.jsx("span",{className:"truncate",children:d})]},d))}),e.jsxs("main",{className:"min-w-0 rounded-xl border border-border bg-card p-2 sm:p-3",children:[e.jsx(bs,{eyebrow:"Panel del participante",title:p[0],description:p[2]}),m==="Mi equipo"&&e.jsx(Pr,{registration:s,group:i,tournament:t,onSelect:x})," ",m==="Mi grupo"&&e.jsx(et,{groups:n.filter(d=>d.id===i?.id),registrations:r,myRegistration:s})," ",m==="Bracket"&&e.jsx(us,{bracket:a,registrations:r,tournament:t})," ",m==="Calendario"&&e.jsx(Ze,{tournament:t,matches:c})," ",m==="Salas"&&e.jsx(as,{rooms:o})," ",m==="Resultados"&&e.jsx(ss,{matches:c,myRegistration:s})," ",m==="Progreso"&&e.jsx(je,{icon:xs,title:t.status==="completed"?"Participación finalizada":"Progreso competitivo",text:t.status==="completed"?"Consulta tus resultados finales y posición en la clasificación.":"Tu progreso se actualizará después de cada partida oficial."})," ",m==="Notificaciones"&&e.jsx(je,{icon:Ot,title:"Sin notificaciones pendientes",text:"Los cambios de sala, calendario y resultados aparecerán aquí."})," ",m==="Copilot"&&e.jsx(je,{icon:Ee,title:"Copilot del torneo",text:"Recibe contexto sobre tu grupo, próximos pasos y resultados desde este panel."})," ",!s&&e.jsx(je,{icon:ee,title:"No participas en este torneo",text:"Registra tu equipo para activar el panel del participante."})]})]})}function Ir({tournamentId:t}){const s=re(),[i,n]=g.useState(3),[r,a]=g.useState(2),{data:c=[],isLoading:o}=U({queryKey:["tournament-codes",t],queryFn:async()=>(await f.functions.invoke("getTournamentCodes",{tournament_id:t})).data?.codes||[],enabled:!!t,staleTime:0}),m=ne({mutationFn:async d=>(await f.functions.invoke("generateTournamentCodes",{tournament_id:t,quantity:Math.min(50,Math.max(1,Number(d)||1)),max_uses:Math.min(999,Math.max(1,Number(r)||1))})).data,onSuccess:d=>{s.setQueryData(["tournament-codes",t],(u=[])=>[...d.codes,...u]),s.invalidateQueries({queryKey:["tournament-codes",t]}),A.success(`${d.count} código${d.count>1?"s":""} generado${d.count>1?"s":""}`),n(3),a(2)},onError:d=>A.error(d.response?.data?.error||d.message||"Error al generar códigos")}),x=ne({mutationFn:d=>f.functions.invoke("revokeTournamentCode",{code_id:d}),onSuccess:(d,u)=>{s.setQueryData(["tournament-codes",t],(b=[])=>b.map(C=>C.id===u?{...C,active:!1}:C)),s.invalidateQueries({queryKey:["tournament-codes",t]}),A.success("Código revocado")},onError:()=>A.error("Error al revocar código")}),p=d=>{navigator.clipboard.writeText(d),A.success("Código copiado")};return e.jsxs("div",{className:"p-4 bg-slate-800/40 rounded-lg border border-slate-700/50",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-4",children:[e.jsx("h4",{className:"font-bold text-white",children:"Códigos de Acceso Privado"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-xs text-white/50",children:"Cantidad"}),e.jsx("input",{type:"number",min:"1",max:"50",name:"code_quantity","aria-label":"Cantidad de códigos",value:i,onChange:d=>n(d.target.value),onBlur:()=>n(Math.min(50,Math.max(1,Number(i)||1))),className:"w-16 px-2 py-1.5 text-sm rounded bg-slate-700 border border-slate-600 text-white text-center"})]}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx("label",{className:"text-xs text-white/50",children:"Max. usos"}),e.jsx("input",{type:"number",min:"1",max:"999",name:"code_max_uses","aria-label":"Máximo de usos por código",value:r,onChange:d=>
41a(d.target.value),onBlur:()=>a(Math.min(999,Math.max(1,Number(r)||1))),className:"w-20 px-2 py-1.5 text-sm rounded bg-slate-700 border border-slate-600 text-white text-center"})]}),e.jsx(Se,{type:"button","aria-label":`Generar ${i||1} códigos con máximo ${r||1} usos cada uno`,onClick:()=>m.mutate(i),disabled:m.isPending,size:"sm",className:"bg-emerald-600 hover:bg-emerald-700 mt-5",children:m.isPending?e.jsx(e.Fragment,{children:e.jsx(Y,{className:"w-3.5 h-3.5 mr-1 animate-spin"})}):e.jsxs(e.Fragment,{children:[e.jsx(ua,{className:"w-3.5 h-3.5 mr-1"}),"Generar"]})})]})]}),o?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx(Y,{className:"w-5 h-5 text-emerald-400 animate-spin"})}):c.length===0?e.jsx("p",{className:"text-sm text-slate-400 text-center py-4",children:"Sin códigos aún"}):e.jsx("div",{className:"space-y-2",children:c.map(d=>{const u=d.uses_count>=d.max_uses;return e.jsxs("div",{className:"flex items-center justify-between p-2 bg-slate-900/50 rounded border border-slate-700/30",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("code",{className:"text-sm font-mono font-bold text-emerald-400",children:d.code}),e.jsx(xa,{className:`text-[10px] px-1.5 py-0 ${d.active?d.uses_count>0?"bg-yellow-600":"bg-green-600":"bg-red-600"}`,children:d.active?d.uses_count>0?u?"Usado":"Usado · activo":"Activo":"Revocado"}),e.jsxs("span",{className:"text-xs text-white/40",children:["(",d.uses_count||0,"/",d.max_uses||1,")"]})]}),e.jsxs("div",{className:"flex items-center gap-1 ml-2",children:[d.active&&!u&&e.jsx("button",{onClick:()=>p(d.code),className:"p-1.5 hover:bg-slate-800 rounded transition-all",title:"Copiar",children:e.jsx(pa,{className:"w-3.5 h-3.5 text-slate-400"})}),e.jsx("button",{onClick:()=>x.mutate(d.id),disabled:x.isPending||!d.active,className:"p-1.5 hover:bg-red-900/30 rounded transition-all disabled:opacity-50",title:"Revocar",children:e.jsx(at,{className:"w-3.5 h-3.5 text-red-400"})})]})]},d.id)})})]})}function Mr({method:t,className:s="h-9 w-12"}){const[i,n]=g.useState(!1),r=t?.label||"Pago";return e.jsx("div",{className:`flex flex-none items-center justify-center overflow-hidden rounded-md bg-white p-1.5 ${s}`,children:t?.logo&&!i?e.jsx("img",{src:t.logo,alt:`Logo de ${r}`,loading:"lazy",onError:()=>n(!0),className:"h-full w-full object-contain"}):e.jsx("span",{className:"text-[9px] font-bold leading-none text-slate-800",children:r.slice(0,8)})})}const We={active:!0,account_email:"",account_name:"",wallet_address:"",qr_url:"",api_key:"",commission_pct:0,min_amount:0,max_amount:"",instructions:"",allowed_currencies:["USD"],countries_allowed:[]};function Lr({tournament:t,onUpdate:s}){const[i,n]=g.useState(t?.payment_methods_enabled||[]),[r,a]=g.useState(t?.payment_config||{}),[c,o]=g.useState(null),[m,x]=g.useState(!1),p=b=>{const C=!i.includes(b);n(v=>C?[...v,b]:v.filter(S=>S!==b)),a(v=>({...v,[b]:{...We,...v[b]||{},active:C}}))},d=(b,C,v)=>{a(S=>({...S,[b]:{...S[b]||We,[C]:v}}))},u=async()=>{x(!0);try{const b=Object.fromEntries(kt.filter(v=>i.includes(v.id)||r[v.id]).map(v=>[v.id,{...We,...r[v.id]||{},active:i.includes(v.id)}])),C=await f.functions.invoke("manageGovernance",{action:"update_tournament",tournament_id:t.id,tournament:{payment_methods_enabled:i,payment_config:b},reason:"Actualización de métodos de pago del torneo"});if(!C.data?.success)throw new Error(C.data?.error||"No se pudieron guardar los métodos de pago");a(b),s&&s({payment_methods_enabled:i,payment_config:b}),A.success("Métodos de pago guardados")}catch{A.error("Error al guardar")}finally{x(!1)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-black text-white",children:"Métodos de Pago"}),e.jsxs("p",{className:"text-[11px] text-white/40",children:[i.length," activos"]})]}),e.jsx(Se,{onClick:u,disabled:m,"data-testid":"save-tournament-payment-methods",size:"sm",className:"bg-green-500 hover:bg-green-600 text-black font-black rounded-xl text-xs",children:m?"Guardando...":"Guardar cambios"})]}),ha.map(b=>{const C=kt.filter(v=>v.category===b.id);return e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-[9px] uppercase tracking-widest text-white/25 mb-2",children:b.label}
41),e.jsx("div",{className:"space-y-2",children:C.map(v=>{const S=i.includes(v.id),$=c===v.id,R=r[v.id]||{};return e.jsxs("div",{"data-testid":`payment-method-${v.id}`,"data-active":S?"true":"false",className:`rounded-xl border transition-all ${S?"border-white/15 bg-white/[0.04]":"border-white/[0.06] bg-white/[0.02]"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[e.jsx(Mr,{method:v,className:"h-8 w-11"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-xs font-bold text-white",children:v.label}),S&&e.jsx("span",{className:"rounded-full bg-green-500/15 px-2 py-0.5 text-[9px] font-bold text-green-400",children:"Activo"})]}),e.jsx("p",{className:"text-[10px] text-white/30 truncate",children:v.description})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[S&&e.jsx("button",{onClick:()=>o($?null:v.id),className:"text-white/30 hover:text-white/60 p-1",children:$?e.jsx(ba,{className:"w-3.5 h-3.5"}):e.jsx(qe,{className:"w-3.5 h-3.5"})}),e.jsx("button",{type:"button",onClick:()=>p(v.id),"aria-label":`${S?"Desactivar":"Activar"} ${v.label}`,"aria-pressed":S,"data-testid":`toggle-payment-${v.id}`,className:`w-8 h-4 rounded-full flex items-center px-0.5 transition-colors ${S?"bg-green-500":"bg-white/20"}`,children:e.jsx("div",{className:`w-3 h-3 rounded-full transition-transform bg-white ${S?"translate-x-4":"translate-x-0"}`})})]})]}),S&&$&&e.jsxs("div",{className:"px-3 pb-3 space-y-2 border-t border-white/[0.05] pt-3",children:[["stripe","paypal","mercadopago","payoneer","wise","cashapp","venmo","zelle","pix","nequi","daviplata","bancolombia","pse"].includes(v.id)&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-white/40 mb-1 block",children:"Cuenta / Email receptor"}),e.jsx("input",{value:R.account_email||"",onChange:h=>d(v.id,"account_email",h.target.value),placeholder:"[email protected]",className:"w-full bg-white/[0.04] border border-white/[0.07] rounded-lg px-2.5 py-1.5 text-xs text-white placeholder:text-white/20 outline-none"})]}),["usdt","usdc","bitcoin","ethereum","solana","binance","coinbase"].includes(v.id)&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-white/40 mb-1 block",children:"Dirección de wallet"}),e.jsx("input",{value:R.wallet_address||"",onChange:h=>d(v.id,"wallet_address",h.target.value),placeholder:"0x... o dirección crypto",className:"w-full bg-white/[0.04] border border-white/[0.07] rounded-lg px-2.5 py-1.5 text-xs text-white font-mono placeholder:text-white/20 outline-none"})]}),["qr","pix","nequi","daviplata"].includes(v.id)&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-white/40 mb-1 block",children:"URL del código QR"}),e.jsx("input",{value:R.qr_url||"",onChange:h=>d(v.id,"qr_url",h.target.value),placeholder:"https://...",className:"w-full bg-white/[0.04] border border-white/[0.07] rounded-lg px-2.5 py-1.5 text-xs text-white placeholder:text-white/20 outline-none"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-white/40 mb-1 block",children:"Comisión %"}),e.jsx("input",{type:"number",min:"0",max:"100",step:"0.1",value:R.commission_pct??0,onChange:h=>d(v.id,"commission_pct",+h.target.value),className:"w-full bg-white/[0.04] border border-white/[0.07] rounded-lg px-2.5 py-1.5 text-xs text-white outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-white/40 mb-1 block",children:"Mín. monto"}),e.jsx("input",{type:"number",min:"0",value:R.min_amount??0,onChange:h=>d(v.id,"min_amount",+h.target.value),className:"w-full bg-white/[0.04] border border-white/[0.07] rounded-lg px-2.5 py-1.5 text-xs text-white outline-none"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-white/40 mb-1 block",children:"Instrucciones para el usuario"}),e.jsx("textarea",{value:R.instructions||"",onChange:h=>d(v.id,"instructions",h.target.value),placeholder:"Pasos para completar el pago...",rows:2,className:"w-full bg-white/[0.04] border border-white/[0.07] rounded-lg px-2.5 py-1.5 text-xs text-white placeholder:text-white/20 outline-none resize-none"})]})]})]},v.id)})})]},b.id)})]})}const Br="6a6ea5b1a4b86cd5fe834735";function Or(){const[t,s]=g.useState({loading:!0,user:null,connected:!1,teams:[]}),i=g.useCallback(async()=>{try{const r=await f.functions.invoke("linearTournamentBugs",{action:"workspace"});s(a=>({...a,loading:!1,connected:!0,teams:r.data.teams||[]}))}catch{s(r=>({...r,loading:!1,connected:!1,teams:[]}))}},[]);return g.useEffect(()=>{f.auth.isAuthenticated().then(async r=>{if(!r)return s({loading:!1,user:null,connected:!1,teams:[]});const a=await f.auth.me();s(c=>({...c,user:a})),await i()})},[i]),{...t,connect:async()=>{const r=await f.connectors.connectAppUser(Br),a=window.open(r,"_blank","noopener,noreferrer"),c=window.setInterval(()=>{(!a||a.closed)&&(window.clearInterval(c),i())},500)},fetchWorkspace:i}}function zr({errors:t,selected:s,onToggle:i}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-bold text-muted-foreground",children:"Errores registrados"}),t.length===0?e.jsx("p",{className:"rounded-xl bg-muted p-3 text-xs text-muted-foreground",children:"No hay errores recientes relacionados con torneos."}):e.jsx("div",{className:"max-h-48 space-y-1 overflow-y-auto rounded-xl border border-border p-2",children:t.map(n=>e.jsxs("label",{className:"flex cursor-pointer gap-2 rounded-lg p-2 hover:bg-muted",children:[e.jsx("input",{type:"checkbox",checked:s.includes(n.id
41),onChange:()=>i(n.id),className:"mt-0.5"}),e.jsx(is,{className:"mt-0.5 h-3.5 w-3.5 flex-shrink-0 text-destructive"}),e.jsxs("span",{className:"min-w-0 text-xs",children:[e.jsx("strong",{className:"block truncate",children:n.component||n.error_type||"Error de torneo"}),e.jsx("span",{className:"line-clamp-2 text-muted-foreground",children:n.message})]})]},n.id))})]})}function Gr({teams:t,teamId:s,cycleId:i,title:n,description:r,errors:a,selected:c,pending:o,onField:m,onToggle:x,onSubmit:p}){const d=t.find(u=>u.id===s);return e.jsxs("form",{onSubmit:p,className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("select",{"aria-label":"Equipo de Linear",value:s,onChange:u=>m("teamId",u.target.value),className:"h-10 rounded-xl border border-border bg-background px-3 text-sm",children:[e.jsx("option",{value:"",children:"Equipo de Linear"}),t.map(u=>e.jsx("option",{value:u.id,children:u.name},u.id))]}),e.jsxs("select",{"aria-label":"Ciclo de Linear",value:i,onChange:u=>m("cycleId",u.target.value),disabled:!s,className:"h-10 rounded-xl border border-border bg-background px-3 text-sm",children:[e.jsx("option",{value:"",children:"Ciclo"}),(d?.cycles?.nodes||[]).map(u=>e.jsx("option",{value:u.id,children:u.name||`Ciclo ${u.number}`},u.id))]})]}),e.jsx("input",{value:n,onChange:u=>m("title",u.target.value),placeholder:"Título del bug de integración",className:"h-10 w-full rounded-xl border border-border bg-background px-3 text-sm"}),e.jsx("textarea",{value:r,onChange:u=>m("description",u.target.value),placeholder:"Pasos, impacto y resultado esperado",rows:3,className:"w-full rounded-xl border border-border bg-background p-3 text-sm"}),e.jsx(zr,{errors:a,selected:c,onToggle:x}),e.jsxs("button",{type:"submit",disabled:o||!s||!i||!n.trim(),className:"flex min-h-11 items-center justify-center gap-2 rounded-xl bg-primary px-4 py-2.5 text-sm font-bold leading-tight text-primary-foreground disabled:opacity-50",children:[o?e.jsx(Y,{className:"h-4 w-4 animate-spin"}):e.jsx(ns,{className:"h-4 w-4"}),"Crear issue en Linear"]})]})}const Ur="6a6ea6c807d6708ff7dfc820";function Vr(){const[t,s]=g.useState({loading:!0,user:null,connected:!1,organizations:[]}),i=g.useCallback(async()=>{try{const r=await f.functions.invoke("linearTournamentBugs",{action:"sentryStatus"});s(a=>({...a,loading:!1,connected:!0,organizations:r.data.organizations||[]}))}catch{s(r=>({...r,loading:!1,connected:!1,organizations:[]}))}},[]);return g.useEffect(()=>{f.auth.isAuthenticated().then(async r=>{if(!r)return s({loading:!1,user:null,connected:!1,organizations:[]});const a=await f.auth.me();s(c=>({...c,user:a})),await i()})},[i]),{...t,connect:async()=>{const r=await f.connectors.connectAppUser(Ur),a=window.open(r,"_blank","noopener,noreferrer"),c=window.setInterval(()=>{(!a||a.closed)&&(window.clearInterval(c),i())},500)}}}function Kr({teams:t}){const s=Vr(),[i,n]=g.useState(()=>JSON.parse(localStorage.getItem("flf-sentry-monitor")||"{}")),r=t.find(c=>c.id===i.teamId);if(g.useEffect(()=>{!i.organizationSlug&&s.organizations[0]&&n(c=>({...c,organizationSlug:s.organizations[0].slug}))},[i.organizationSlug,s.organizations]),s.loading)return e.jsx(Y,{className:"h-4 w-4 animate-spin"});if(!s.connected)return e.jsxs("div",{className:"rounded-xl border border-border p-4",children:[e.jsx("p",{className:"mb-3 text-sm font-bold",children:"Monitor crítico de Sentry"}),e.jsxs("button",{onClick:s.connect,className:"flex items-center gap-2 rounded-xl bg-primary px-4 py-2 text-sm font-bold text-primary-foreground",children:[e.jsx(Es,{className:"h-4 w-4"}),"Conectar Sentry"]})]});const a=()=>{localStorage.setItem("flf-sentry-monitor",JSON.stringify(i)),window.dispatchEvent(new Event("sentry-monitor-config"))};return e.jsxs("div",{className:"space-y-3 rounded-xl border border-border p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-bold",children:"Sincronización de Sentry"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Envía incidencias sin resolver al tablero del equipo cada cinco minutos mientras estás en línea."})]}),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-3",children:[e.jsx("select",{value:i.organizationSlug||"",onChange:c=>n(o=>({...o,organizationSlug:c.target.value})),className:"h-10 rounded-xl border border-border bg-background px-3 text-sm",children:s.organizations.map(c=>e.jsx("option",{value:c.slug,children:c.name},c.id))}),e.jsxs("select",{value:i.teamId||"",onChange:c=>n(o=>({...o,teamId:c.target.value,cycleId:""})),className:"h-10 rounded-xl border border-border bg-background px-3 text-sm",children:[e.jsx("option",{value:"",children:"Equipo Linear"}),t.map(c=>e.jsx("option",{value:c.id,children:c.name},c.id))]}),e.jsxs("select",{value:i.cycleId||"",onChange:c=>n(o=>({...o,cycleId:c.target.value})),className:"h-10 rounded-xl border border-border bg-background px-3 text-sm",children:[e.jsx("option",{value:"",children:"Ciclo Linear"}),(r?.cycles?.nodes||[]).map(c=>e.jsx("option",{value:c.id,children:c.name||`Ciclo ${c.number}`},c.id))]})]}),e.jsx("button",{"aria-label":"Guardar",onClick:a,disabled:!i.teamId||!i.cycleId,className:"rounded-xl bg-primary px-4 py-2 text-sm font-bold text-primary-foreground disabled:opacity-50",children:"Activar sincronización"})]})}function Qr({tournament:t}){const s=Or(),[i,n]=g.useState({teamId:"",cycleId:"",title:"",description:""}),[r,a]=g.useState([]),{data:c=[]}=U({queryKey:["tournament-linear-errors"],queryFn:()=>f.entities.AdminClientError.list("-occurred_at",50),enabled:s.connected}),o=g.useMemo(()=>c.filter(p=>/tournament|torneo|bracket|match|registration|inscrip/i.test(`${p.component} ${p.page_url} ${p.message}`)),[c]),m=ne({mutationFn:p=>f.functions.invoke("linearTournamentBugs",p),onSuccess:p=>{A.success(`${p.data.issue.identifier} creado en Linear`),window.open(p.data.issue.url,"_blank","noopener,noreferrer"),n(d=>({...d,title:"",description:""})),a([])},onError:p=>A.error(p.response?.data?.error||"No se pudo crear el issue")});if(s.loading)return e.jsx("div",{className:"flex justify-center py-10",children:e.jsx(Y,{className:"h-5 w-5 animate-spin"})});if(!s.user)return e.jsx("button",{onClick:()=>f.auth.redirectToLogin(window.location.href),className:"rounded-xl bg-primary px-4 py-2 text-sm font-bold text-primary-foreground",children:"Iniciar sesión para conectar Linear"});if(!s.connected)return e.jsxs("button",{onClick:s.connect,className:"flex items-center gap-2 rounded-xl bg-primary px-4 py-2 text-sm font-bold text-primary-foreground",children:[e.jsx(Qa,{className:"h-4 w-4"}),"Conectar mi cuenta de Linear"]});const x=p=>{p.preventDefault();const u=o.filter(b=>r.includes(b.id)).map(b=>`- ${b.message}
42  ${b.page_url||""}`).join(`
43`);m.mutate({action:"createIssue",teamId:i.teamId,cycleId:i.cycleId,title:i.title,de
43scription:`## Torneo
44${t.name} (${t.id})
45
46${i.description}${u?`
47
48## Errores registrados
49${u}`:""}`})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Kr,{teams:s.teams}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold",children:"Bugs de integración en Linear"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Asigna incidencias manuales y errores registrados a un ciclo."})]}),e.jsx(Bt,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx(Gr,{...i,teams:s.teams,errors:o,selected:r,pending:m.isPending,onField:(p,d)=>n(u=>({...u,[p]:d,...p==="teamId"?{cycleId:""}:{}})),onToggle:p=>a(d=>d.includes(p)?d.filter(u=>u!==p):[...d,p]),onSubmit:x})]})}function Hr({items:t,value:s,onChange:i}){return e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"block lg:hidden",children:[e.jsx("span",{className:"sr-only",children:"Sección administrativa"}),e.jsx("select",{value:s,onChange:n=>i(n.target.value),className:"h-11 w-full rounded-md border border-[#1E2226] bg-[#11151A] px-3 text-xs font-semibold text-foreground",children:t.map(([n,r])=>e.jsx("option",{value:n,children:r},n))})]}
49),e.jsxs("aside",{className:"hidden h-fit rounded-xl border border-[#1E2226] bg-[#11151A] p-2 lg:sticky lg:top-24 lg:block",children:[e.jsx("p",{className:"px-2 py-2 text-[10px] font-black uppercase tracking-widest text-[#61D095]",children:"Administración"}),t.map(([n,r,a])=>e.jsxs("button",{type:"button","data-testid":`admin-tournament-${n}`,"aria-current":s===n?"page":void 0,onClick:()=>i(n),className:`flex min-h-9 w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-xs ${s===n?"bg-[#61D095] text-[#06210F]":"text-[#9B9EA4] hover:bg-[#1A1F25] hover:text-white"}`,children:[e.jsx(a,{className:"h-3.5 w-3.5 flex-none"}),e.jsx("span",{className:"min-w-0 truncate",children:r})]},n))]})]})}const Wr={dashboard:"Estado general, bloqueos y control del ciclo del torneo.",linear:"Incidencias técnicas vinculadas al torneo.",payments:"Métodos y configuración de cobros.",teams:"Equipos inscritos y estado de participación.",requests:"Solicitudes y lista de espera pendientes.",checkin:"Confirmaciones de participación antes del inicio.",groups:"Distribución canónica de equipos y generación de canales por grupo.",bracket:"Diseño, generación y gestión del bracket.",results:"Marcadores y resultados oficiales.",referee:"Incidencias, evidencias y decisiones arbitrales.",prizes:"Premios y distribución configurada.",emails:"Comunicaciones por correo del torneo.",settings:"Configuración general y permisos de edición.",codes:"Códigos privados de acceso al torneo.",audit:"Historial inmutable de cambios administrativos y automáticos."},Dt=[["dashboard","Dashboard",ga],["linear","Bugs Linear",Ma],["payments","Pagos",fa],["teams","Equipos",ee],["requests","Solicitudes",Va],["checkin","Check-in",ae],["groups","Grupos",zt],["bracket","Bracket",ms],["results","Resultados",W],["referee","Arbitraje",ja],["prizes","Premios",Lt],["emails","Emails",wa],["settings","Configuración",Ts],["codes","Códigos privados",de],["audit","Auditoría",va]];function Jr({tournament:t,registrations:s,bracket:i,groups:n,rooms:r}){const[a,c]=g.useState("dashboard"),[o,m]=g.useState(t);return g.useEffect(()=>m(t),[t]),e.jsxs("div",{className:"tournament-admin-compact grid w-full min-w-0 max-w-full gap-2 overflow-x-hidden lg:min-h-[620px] lg:grid-cols-[210px_minmax(0,1fr)] lg:gap-3",children:[e.jsx(Hr,{items:Dt,value:a,onChange:c}),e.jsxs("main",{className:"min-w-0 max-w-full overflow-x-hidden rounded-xl border border-border bg-card p-2 sm:p-3",children:[e.jsx(bs,{eyebrow:"Panel administrativo",title:Dt.find(([x])=>x===a)?.[1],description:Wr[a]}),a==="dashboard"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Us,{tournament:o,registrations:s,groups:n,bracket:i,rooms:r}),e.jsx(Vs,{tournament:o,onChange:x=>m(p=>({...p,core_status:x.status,core_version:x.version}))})]}),a==="linear"&&e.jsx(Qr,{tournament:o})," ",a==="bracket"&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(hs,{tournament:o,onApplied:m}),e.jsx(ts,{tournament:o,registrations:s.filter(x=>x.status==="approved"),bracketMatches:i})]}),a==="groups"?e.jsx(Ks,{tournamentId:t.id,groups:n,registrations:s.filter(x=>x.status==="approved")}):null,a==="codes"?e.jsx(Ir,{tournamentId:t.id}):null,a==="emails"?e.jsx(ma,{tournament:t}
49):null,a==="payments"?e.jsx(Lr,{tournament:o,onUpdate:x=>m(p=>({...p,...x}))}):null,a==="results"?e.jsx(Qs,{matches:i,tournamentId:t.id}):null,a==="teams"?e.jsx(Nt,{registrations:s,tournamentId:t.id}):null,a==="requests"?e.jsx(Nt,{registrations:s,tournamentId:t.id,pendingOnly:!0}):null,a==="checkin"?e.jsx(Hs,{registrations:s}):null,a==="referee"?e.jsx(Ws,{tournament:t}):null,a==="prizes"?e.jsx(yt,{tournament:o,mode:"prizes",onUpdated:m}):null,a==="settings"?e.jsx(yt,{tournament:o,onUpdated:m}):null,a==="audit"?e.jsx(Js,{tournamentId:t.id}):null,!["dashboard","linear","bracket","groups","codes","emails","payments","results","referee","prizes","settings","teams","requests","checkin","audit"].includes(a)&&e.jsx(Yr,{tab:a,tournament:t,registrations:s,rooms:r})]})]})}function Yr(){return null}const ue=[{id:"registro",label:"Inscripción",icon:"📝"},{id:"aprobacion",label:"Aprobación",icon:"✅"},{id:"grupos",label:"Grupos",icon:"🗂️"},{id:"calendario",label:"Calendario",icon:"📅"},{id:"salas",label:"Salas",icon:"🎮"},{id:"partidos",label:"Partidos",icon:"⚔️"},{id:"resultados",label:"Resultados",icon:"📊"},{id:"clasificacion",label:"Clasificación",icon:"🏅"},{id:"final",label:"Final",icon:"🏆"},{id:"premios",label:"Premios",icon:"🎁"}];function gs({myReg:t,tournament:s,tournamentGroups:i,bracketMatches:n}){const r=!!t,a=t?.status==="approved",c=a&&i.some(x=>(x.teams||[]).includes(t?.id)),o=n.length>0,m=s?.status;return[{id:"inscrito",label:"Equipo inscrito",done:r,pending:!r},{id:"aprobado",label:"Inscripción aprobada",done:a,pending:r&&!a},{id:"reglamento",label:"Reglamento aceptado",done:a,pending:!1},{id:"grupo",label:"Grupo asignado",done:c,pending:a&&!c},{id:"roster",label:"Roster completado",done:t?.player4_id||!1,pending:a&&!t?.player4_id},{id:"grupo_wa",label:"Unirse al grupo oficial",done:!1,pending:c,external:!0},{id:"salas",label:"Salas publicadas",done:o||m==="live",pending:a&&!o},{id:"partida",label:"Jugar partida",done:o&&m==="live",pending:o},{id:"resultados",label:"Resultados publicados",done:m==="completed",pending:!1},{id:"clasificacion",label:"Clasificación",done:m==="completed",pending:!1},{id:"premios",label:"Premios",done:!1,pending:m==="completed"}]}function fs({myReg:t,tournament:s,tournamentGroups:i,bracketMatches:n}){return t?t.status!=="approved"?"aprobacion":i.some(r=>(r.teams||[]).includes(t?.id))?n.length===0?"salas":s?.status==="live"?"partidos":s?.status==="completed"?"resultados":"calendario":"grupos":"registro"}function Zr({myReg:t,tournament:s,tournamentGroups:i,bracketMatches:n}){const[r,a]=g.useState(!0),c=gs({myReg:t,tournament:s,tournamentGroups:i,bracketMatches:n}),o=c.filter(p=>p.done).length,m=c.length,x=Math.round(o/m*100);return e.jsxs("div",{className:"rounded-2xl bg-white/[0.04] border border-white/[0.07] overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>a(p=>!p),className:"w-full flex items-center justify-between px-4 py-3.5 hover:bg-white/[0.03] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx(os,{className:"w-4 h-4 text-amber-400"}),e.jsx("span",{className:"text-sm font-bold text-white",children:"Progreso del Torneo"}),e.jsxs("span",{className:"text-[10px] font-black px-2 py-0.5 rounded-full bg-amber-500/15 text-amber-400",children:[x,"%"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[11px] text-white/30",children:[o,"/",m]}),r?e.jsx(qe,{className:"w-4 h-4 text-white/30"}):e.jsx(Re,{className:"w-4 h-4 text-white/30"})]})]}),e.jsx("div",{className:"h-0.5 bg-white/[0.06] mx-4",children:e.jsx(G.div,{className:"h-full rounded-full bg-amber-400",initial:{width:0},animate:{width:`${x}%`},transition:{duration:.6,ease:"easeOut"}})}),e.jsx(Je,{children:r&&e.jsx(G.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2},children:e.jsx("div",{className:"px-4 py-3 space-y-1.5",children:c.map(p=>e.jsxs("div",{className:`flex items-center gap-2.5 py-1 ${p.pending?"opacity-60":""}`,children:[p.done?e.jsx(Xt,{className:"w-4 h-4 text-green-400 flex-shrink-0"}):p.pending?e.jsx(St,{className:"w-4 h-4 text-white/20 flex-shrink-0"}):e.jsx(St,{className:"w-4 h-4 text-white/10 flex-shrink-0"}),e.jsx("span",{className:`text-[12px] ${p.done?"text-white/70 line-through":p.pending?"text-white font-medium":"text-white/30"}`,children:p.label}),p.pending&&!p.done&&e.jsx("span",{className:"ml-auto text-[9px] font-bold px-1.5 py-0.5 rounded-full bg-blue-500/15 text-blue-400",children:"PENDIENTE"})]}
49,p.id))})})})]})}function Xr({myReg:t,tournament:s,tournamentGroups:i,bracketMatches:n}){const r=fs({myReg:t,tournament:s,tournamentGroups:i,bracketMatches:n}),a=ue.findIndex(c=>c.id===r);return e.jsxs("div",{className:"rounded-2xl bg-white/[0.04] border border-white/[0.07] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(Gt,{className:"w-4 h-4 text-purple-400"}),e.jsx("span",{className:"text-sm font-bold text-white",children:"Etapa Actual"}),e.jsxs("span",{className:"ml-auto text-[11px] font-bold text-purple-300 bg-purple-500/10 px-2 py-0.5 rounded-full",children:[ue[a]?.icon," ",ue[a]?.label]})]}),e.jsx("div",{className:"flex items-center gap-0 overflow-x-auto scrollbar-hide pb-1",children:ue.map((c,o)=>{const m=o<a,x=o===a;return e.jsxs(D.Fragment,{children:[e.jsxs("div",{className:"flex flex-col items-center gap-1 flex-shrink-0",children:[e.jsx("div",{className:`w-8 h-8 rounded-full flex items-center justify-center text-sm transition-all ${m?"bg-green-500/20 text-green-400":x?"bg-purple-500 text-white shadow-lg shadow-purple-500/30":"bg-white/[0.05] text-white/20"}`,children:m?"✓":c.icon}),e.jsx("span",{className:`text-[9px] font-bold whitespace-nowrap ${x?"text-purple-300":m?"text-green-400/60":"text-white/20"}`,children:c.label})]}),o<ue.length-1&&e.jsx("div",{className:`h-0.5 w-4 flex-shrink-0 mb-4 ${o<a?"bg-green-500/40":"bg-white/[0.06]"}`})]},c.id)})})]})}function ei({myReg:t,tournament:s,tournamentGroups:i,bracketMatches:n,registrations:r}){if(!t)return e.jsxs("div",{className:"rounded-2xl bg-white/[0.04] border border-white/[0.07] p-6 text-center",children:[e.jsx(Be,{className:"w-8 h-8 text-white/20 mx-auto mb-2"}),e.jsx("p",{className:"text-white/40 text-sm",children:"Inscríbete para ver tu camino"})]});const a=i.find(x=>(x.teams||[]).includes(t.id)),c=a?(a.teams||[]).map(x=>r.find(p=>p.id===x)).filter(Boolean).filter(x=>x.id!==t.id):[],o=a?a.group_name:null,m=t.status!=="approved"?"Espera la aprobación de tu inscripción":a?t.player4_id?n.length===0?"Espera la publicación de salas":s?.status==="live"?"¡Tu partida está en curso!":"Prepárate para tu próximo partido":"Completa tu roster (4 titulares requeridos)":"Espera la asignación de grupos";return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-2xl bg-white/[0.04] border border-white/[0.07] p-4",children:[e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-white/25 mb-2",children:"Mi Equipo"}),e.jsxs("div",{className:"flex items-center gap-3",children:[t.logo_url&&e.jsx("img",{src:t.logo_url,alt:`Logo de ${t.team_name||"mi equipo"}`,className:"w-10 h-10 rounded-xl object-cover"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-bold text-white",children:t.team_name}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:`text-[10px] font-bold px-2 py-0.5 rounded-full ${t.status==="approved"?"bg-green-500/15 text-green-400":"bg-amber-500/15 text-amber-400"}`,children:t.status==="approved"?"✓ Aprobado":"⏳ Pendiente"}),t.slot_number&&e.jsxs("span",{className:"text-[10px] text-white/30",children:["Slot #",t.slot_number]})]})]})]})]}),a&&e.jsxs("div",{className:"rounded-2xl bg-white/[0.04] border border-white/[0.07] p-4",children:[e.jsxs("p",{className:"text-[10px] font-black uppercase tracking-widest text-white/25 mb-2",children:["Mi Grupo · G",o]}),e.jsxs("div",{className:"space-y-1.5",children:[c.map((x,p)=>e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"w-5 text-[10px] text-white/20 text-center font-bold",children:p+1}),x.logo_url?e.jsx("img",{src:x.logo_url,alt:`Logo de ${x.team_name||"equipo rival"}`,className:"w-6 h-6 rounded object-cover"}):e.jsx(de,{className:"w-6 h-6 text-white/10"}),e.jsx("span",{className:"text-[12px] font-semibold text-white/70",children:x.team_name})]},x.id)),c.length===0&&e.jsx("p",{className:"text-white/20 text-xs",children:"Aún sin rivales asignados"})]})]}),e.jsxs("div",{className:"rounded-2xl bg-purple-500/10 border border-purple-500/20 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Gt,{className:"w-4 h-4 text-purple-400"}),e.jsx("p",{className:"text-[10px] font-black uppercase tracking-widest text-purple-400",children:"Próximo Paso"})]}),e.jsx("p",{className:"text-sm text-white font-medium",children:m})]})]})}function ti({myReg:t,tournament:s,tournamentGroups:i,bracketMatches:n}){const a=gs({myReg:t,tournament:s,tournamentGroups:i,bracketMatches:n}).filter(c=>c.pending&&!c.done);return a.length===0?null:e.jsxs("div",{className:"rounded-2xl bg-amber-500/[0.07] border border-amber-500/20 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Ye,{className:"w-4 h-4 text-amber-400"}),e.jsx("p",{className:"text-sm font-bold text-amber-300",children:"Acciones Pendientes"}),e.jsx("span",{className:"ml-auto text-[10px] font-black bg-amber-500/20 text-amber-300 px-2 py-0.5 rounded-full",children:a.length})]}),e.jsx("div",{className:"space-y-2",children:a.map(c=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 flex-shrink-0"}),e.jsx("p",{className:"text-[12px] text-white/70",children:c.label})]},c.id))})]})}function si({tournament:t,myReg:s,tournamentGroups:i,bracketMatches:n,onClose:r,inline:a=!1}){const[c,o]=g.useState([]),[m,x]=g.useState(null),[p,d]=g.useState(""),[u,b]=g.useState(!1),[C,v]=g.useState("chat"),S=g.useRef(null),$=g.useRef(null),R=g.useRef(null),h=i.find(N=>(N.teams||[]).includes(s?.id)),_=fs({myReg:s,tournament:t,tournamentGroups:i,bracketMatches:n}),I=[{emoji:"📍",label:"Mi grupo",msg:`¿En qué grupo estoy en el torneo ${t?.name}?`},{emoji:"📋",label:"Mi roster",msg:"Revisa mi roster actual"},{emoji:"⚔️",label:"Mis rivales",msg:"Dime quiénes son mis rivales en este torneo"},{emoji:"📜",label:"Reglamento",msg:`¿Cuáles son las reglas del torneo ${t?.name}?`},{emoji:"🏆",label:"Premios",msg:`¿Cuáles son los premios del torneo ${t?.name}?`},{emoji:"📅",label:"Calendario",msg:`¿Cuál es el calendario del torneo ${t?.name}?`},{emoji:"❓",label:"¿Qué hago ahora?",msg:"¿Qué debo hacer ahora en el torneo?"}];g.useEffect(()=>(V(),()=>{R.current&&R.current()}),[]),g.useEffect(()=>{S.current?.scrollIntoView({behavior:"smooth"})},[c,u]);const P=()=>{const N=[`TORNEO: ${t?.name}`,`ESTADO: ${t?.status==="live"?"EN VIVO":t?.status==="upcoming"?"PRÓXIMO":"FINALIZADO"}`,`JUEGO: ${t?.game||"Free Fire"}`,`REGIÓN: ${t?.region||"GLOBAL"}`,`FORMATO: ${t?.format||"No especificado"}`,`MODO: ${t?.game_mode||"No especificado"}
49`,`CUPOS: ${t?.max_teams||"N/A"} equipos máx`,`EQUIPOS INSCRITOS: ${n.length} partidos, ${i.length} grupos`,`PREMIOS: ${t?.prize||t?.prize_pool||"No especificado"}`,`INICIO: ${t?.start_date||"No definido"}`,`REGLAS: ${t?.rules||"Ver reglamento en la web"}`];if(s){N.push("--- MI INSCRIPCIÓN ---"),N.push(`EQUIPO: ${s.team_name}${s.tag?` [${s.tag}]`:""}`),N.push(`ESTADO INSCRIPCIÓN: ${s.status==="approved"?"APROBADO ✅":s.status==="rejected"?"RECHAZADO ❌":"PENDIENTE ⏳"}`),s.slot_number&&N.push(`SLOT ASIGNADO: #${s.slot_number}`),h&&N.push(`GRUPO ASIGNADO: G${h.group_name} con ${(h.teams||[]).length} equipos`);const k=[s.player1_id,s.player2_id,s.player3_id,s.player4_id].filter(Boolean);N.push(`TITULARES: ${k.length}/4 completados`),s.player1_name&&N.push(`JUGADORES: ${[s.player1_name,s.player2_name,s.player3_name,s.player4_name].filter(Boolean).join(", ")}`)}else N.push("--- INSCRIPCIÓN ---"),N.push("El usuario NO está inscrito en este torneo todavía.");return N.push(`--- ETAPA ACTUAL: ${ue.find(k=>k.id===_)?.label||_} ---`),N.join(`
50`)},Q=()=>{if(t?.prize)return t.prize;const N=Number(t?.prize_pool_total||t?.prize_pool||0);return N>0?`${t?.prize_currency||"USD"} ${N.toLocaleString("es-ES")}`:"No especificados todavía"},O=N=>{const k=N.toLowerCase();if(k.includes("grupo")||k.includes("rivales"))return h?`📍 **Tu grupo es ${h.group_name}** con ${(h.teams||[]).length} equipos. Revisa **Mi Camino** para ver tus rivales.`:i.length>0?`🗂️ **Grupos actuales:** ${i.map(y=>`${y.group_name}: ${(y.teams||[]).length} equipos`).join(" · ")}.`:"⏳ El torneo aún no tiene grupos publicados.";if(k.includes("roster")||k.includes("jugadores")){const y=[s?.player1_id,s?.player2_id,s?.player3_id,s?.player4_id].filter(Boolean).length;return s?`👥 Tu roster tiene **${y}/4 titulares** completados.`:"No estás inscrito en este torneo todavía."}if(k.includes("premio")||k.includes("recompensa"))return`🏆 **Premios actuales de ${t?.name}:** ${Q()}.`;if(k.includes("calendario")||k.includes("horario")||k.includes("fecha")||k.includes("cuándo")){const F=n.filter(T=>T.scheduled_time).sort((T,M)=>new Date(T.scheduled_time)-new Date(M.scheduled_time)).slice(0,3).map(T=>`${new Date(T.scheduled_time).toLocaleString("es-ES")} — ${T.team_a_name||"Por definir"} vs ${T.team_b_name||"Por definir"}`).join(`
51`);return`📅 **Calendario actual:** inicio ${t?.start_date||"no definido"}${t?.end_date?` · final ${t.end_date}`:""}.${F?`
52
53**Próximos partidos:**
54${F}`:`
55Aún no hay partidos con horario publicado.`}`}return k.includes("sala")||k.includes("bracket")||k.includes("partida")||k.includes("jugar")?n.length>0?`🎮 Hay **${n.length} partidos** publicados. Revisa **Bracket** para ver emparejamientos y horarios.`:"⏳ Aún no hay partidos ni salas publicados.":k.includes("regla")||k.includes("reglamento")?`📜 **Reglas:** ${t?.rules||"Consulta la sección Reglamento del torneo."}`:k.includes("qué hago")||k.includes("qué hacer")||k.includes("siguiente")||k.includes("ahora")?B():`ℹ️ **Estado actual de ${t?.name}:** ${t?.status||"sin definir"} · ${i.length} grupos · ${n.length} partidos · premios ${Q()} · inicio ${t?.start_date||"no definido"}.`},B=()=>{const N=t?.name||"este torneo",k=ue.find(M=>M.id===_)?.label||_;if(!s)return`👋 Hola! Soy el **Copilot** del torneo **${N}**.
56
57📌 **Aún no estás inscrito.** Para participar:
581. Presiona **"Inscribir Mi Equipo"** en la parte inferior
592. Completa el formulario con los datos de tu equipo
603. Espera la aprobación del organizador
61
62Usa las pestañas **Progreso** y **Mi Camino** para más info. ¿En qué te ayudo?`;const y=s.team_name;s.status;const F=s.status==="pending"||s.status==="under_review";if(s.status==="rejected")return`❌ Hola! Tu equipo **${y}** fue **rechazado** en **${N}**.
63
64Puedes contactar al organizador del torneo para conocer el motivo o intentar inscribirse de nuevo si hay cupos disponibles.
65
66¿Necesitas más información?`;if(F)return`⏳ Hola! Tu equipo **${y}** está **pendiente de aprobación** en **${N}**.
67
68**¿Qué hacer ahora?**
691. Espera la revisión del organizador (puede tomar 24-48h)
702. Verifica que tu roster esté completo en tu perfil
713. Únete al grupo de WhatsApp del torneo si ya está disponible
72
73Te notificaremos cuando seas aprobado. ¿Alguna pregunta?`;
73if(_==="aprobacion")return`✅ ¡Tu equipo **${y}** está **aprobado** en **${N}**!
74
75**Etapa actual: ${k}**
76
77📋 **Próximos pasos:**
781. Completa tu roster con 4 titulares mínimo
792. Estate atento a la asignación de grupos
803. Únete al grupo oficial de WhatsApp cuando esté publicado
81
82¿Qué más necesitas saber?`;if(_==="grupos")return`🗂️ ¡Hola! **${y}** está aprobado en **${N}**.
83
84**Etapa: Asignación de Grupos**
85
86📋 **Qué hacer ahora:**
871. Espera la publicación de grupos (chequea aquí y en WhatsApp)
882. Una vez asignado, revisa tus rivales en la pestaña "Mi Camino"
893. Confirma que todos tus jugadores tengan cuenta activa
90
91Cualquier duda, pregúntame.`;if(_==="salas"){const M=h?`Grupo G${h.group_name}`:"tu grupo";return`🎮 ¡Es hora de jugar! **${y}** en **${N}**.
92
93**Etapa: Publicación de Salas** — ${M}
94
95📋 **Acciones urgentes:**
961. Revisa el bracket y la info de sala en la pestaña de Bracket
972. Comparte el código de sala con tus 4 jugadores ANTES del partido
983. Todos deben estar listos **15 minutos antes** del inicio
994. El capitán debe capturar screenshot del resultado y subirlo
100
101¿Tienes dudas sobre las reglas o la sala?`}return _==="partidos"||t?.status==="live"?`⚔️ **¡TORNEO EN VIVO!** — ${N}
102
103**${y}** está participando. Etapa: ${k}
104
105🔴 **Acciones inmediatas:**
1061. Confirma que todos los jugadores están en la sala
1072. El capitán es responsable de subir el screenshot al terminar
1083. Si hay problemas técnicos, contacta al staff por WhatsApp de inmediato
1094. Revisa el bracket para ver tu próximo partido
110
111¡Buena suerte! 🏆`:t?.status==="completed"?`🏆 El torneo **${N}** ha **finalizado**.
112
113Gracias por participar con **${y}**. Revisa la clasificación final y los resultados en la sección de Bracket.
114
115¿Tienes alguna duda sobre los resultados o premios?`:`✅ ¡Hola! **${y}** está inscrito en **${N}**.
116
117**Etapa: ${k}**
118
119📋 **Qué hacer:**
1201. Mantén tu roster actualizado (mín. 4 titulares)
1212. Únete al grupo de WhatsApp oficial cuando esté disponible
1223. Revisa el calendario de partidos
1234. Prepara a tu equipo para el día del torneo
124
125¿En qué puedo ayudarte?`},V=async()=>{o([{role:"assistant",content:B()}]);try{const N=P(),k=await f.agents.createConversation({agent_name:"info_assistant",metadata:{name:`Copilot: ${t?.name}`,description:N}});x(k),R.current=f.agents.subscribeToConversation(k.id,y=>{const F=(y.messages||[]).filter(M=>M.content?.trim());F.length>0&&o(M=>{const te=M[0],L=F.filter(ye=>ye.content!==te?.content);return[te,...L].filter(Boolean)});const T=(y.messages||[]).filter(M=>M.content?.trim()).at(-1);T&&(T.role==="assistant"||T.role==="agent")&&b(!1)})}catch{x({id:"offline",_offline:!0})}},z=async N=>{const k=N||p.trim();if(!(!k||u)){if(d(""),o(y=>[...y,{role:"user",content:k}]),!m||m._offline){const y=O(k);setTimeout(()=>o(F=>[...F,{role:"assistant",content:y}]),400);return}b(!0);try{await f.agents.addMessage(m,{role:"user",content:`[CONTEXTO DEL TORNEO]
126${P()}
127
128[PREGUNTA DEL USUARIO]
129${k}`}),setTimeout(()=>b(!1),6e4)}catch{x({id:"offline",_offline:!0}),b(!1),o(y=>[...y,{role:"assistant",content:O(k)}])}}},E=[{id:"chat",label:"Copilot"},{id:"checklist",label:"Progreso"},{id:"camino",label:"Mi Camino"}];return e.jsxs(G.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},exit:{opacity:0,y:12},transition:{type:"spring",damping:26,stiffness:320},className:a?"w-full rounded-2xl overflow-hidden flex flex-col border border-white/[0.09] shadow-xl":"fixed bottom-20 right-4 z-[99999] w-[320px] md:w-[360px] rounded-3xl overflow-hidden flex flex-col border border-white/[0.09] shadow-2xl",style:{background:"#131315",...a?{height:"400px"}:{height:"460px",maxHeight:"calc(100vh - 100px)"}},children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 flex-shrink-0",style:{background:"linear-gradient(90deg, rgba(124,58,237,0.3), rgba(219,39,119,0.15))"},children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center",style:{background:"linear-gradient(135deg, #7c3aed, #db2777)"},children:e.jsx(W,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[12px] font-black text-white leading-none",children:"Tourn
129ament Copilot"}),e.jsx("p",{className:"text-[9px] text-purple-300 mt-0.5 truncate max-w-[160px]",children:t?.name})]})]}),e.jsx("button",{type:"button",onClick:r,"aria-label":"Cerrar Tournament Copilot",className:"flex h-9 w-9 items-center justify-center rounded-full text-white/30 transition-all hover:bg-white/[0.08] hover:text-white/70",children:e.jsx($e,{className:"w-3.5 h-3.5"})})]}),e.jsx("div",{className:"flex gap-1 px-3 pt-2.5 pb-1 flex-shrink-0 border-b border-white/[0.05]",children:E.map(N=>e.jsx("button",{type:"button",onClick:()=>v(N.id),className:`flex-1 py-1.5 rounded-xl text-[11px] font-bold transition-all ${C===N.id?"bg-white/[0.1] text-white":"text-white/30 hover:text-white/60"}`,children:N.label},N.id))}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[C==="chat"&&e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-2.5",style:{overscrollBehavior:"contain"},children:[c.filter(N=>N.content?.trim()).map((N,k)=>e.jsxs(G.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},className:`flex gap-2 ${N.role==="user"?"justify-end":"justify-start items-end"}`,children:[N.role!=="user"&&e.jsx("div",{className:"w-6 h-6 rounded-full flex-shrink-0 flex items-center justify-center",style:{background:"linear-gradient(135deg, #7c3aed, #db2777)"},children:e.jsx(W,{className:"w-3 h-3 text-white"})}),e.jsx("div",{className:`max-w-[82%] rounded-2xl px-3.5 py-2.5 text-[12px] leading-relaxed ${N.role==="user"?"text-white rounded-br-sm":"bg-[#1e1e24] text-white/85 rounded-bl-sm border border-white/[0.06]"}`,style:N.role==="user"?{background:"linear-gradient(135deg, #7c3aed, #9333ea)"}:{},children:N.role==="user"?N.content:e.jsx(Na,{components:{p:({children:y})=>e.jsx("p",{className:"mb-1 last:mb-0",children:y}),strong:({children:y})=>e.jsx("strong",{className:"text-purple-300 font-semibold",children:y}),ul:({children:y})=>e.jsx("ul",{className:"list-disc ml-4 space-y-0.5",children:y}),li:({children:y})=>e.jsx("li",{children:y})},children:N.content})})]},k)),u&&e.jsxs("div",{className:"flex gap-2 items-end",children:[e.jsx("div",{className:"w-6 h-6 rounded-full flex-shrink-0 flex items-center justify-center",style:{background:"linear-gradient(135deg, #7c3aed, #db2777)"},children:e.jsx(W,{className:"w-3 h-3 text-white"})}),e.jsxs("div",{className:"bg-[#1e1e24] rounded-2xl rounded-bl-sm border border-white/[0.06] px-4 py-3 flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400 animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400 animate-bounce",style:{animationDelay:"140ms"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-purple-400 animate-bounce",style:{animationDelay:"280ms"}})]})]}),e.jsx("div",{ref:S})]}),e.jsx("div",{className:"px-3 py-1.5 flex gap-1.5 overflow-x-auto scrollbar-hide flex-shrink-0",children:I.map(N=>e.jsxs("button",{type:"button",onClick:()=>z(N.msg),className:"flex-shrink-0 flex items-center gap-1 px-2.5 py-1.5 rounded-full border border-purple-500/25 bg-purple-500/10 text-purple-300 text-[10px] font-medium hover:bg-purple-500/20 transition-all whitespace-nowrap",children:[N.emoji," ",N.label]},N.label))}),e.jsx("div",{className:"px-3 py-2.5 border-t border-white/[0.05] flex-shrink-0",children:e.jsxs("div",{className:"flex items-center gap-2 bg-[#1e1e24] rounded-2xl px-3.5 py-2.5 border border-white/[0.07] focus-within:border-purple-500/40 transition-colors",children:[e.jsx("input",{ref:$,value:p,onChange:N=>d(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),z())},placeholder:"Pregunta sobre el torneo...",disabled:u,className:"flex-1 bg-transparent text-[12px] text-white placeholder:text-white/25 outline-none"}),e.jsx(G.button,{type:"button",whileTap:{scale:.88},onClick:()=>z(),disabled:!p.trim()||u,className:"w-7 h-7 rounded-full flex items-center justify-center flex-shrink-0 disabled:opacity-30 transition-all",style:{background:p.trim()?"linear-gradient(135deg, #7c3aed, #db2777)":"rgba(255,255,255,0.08)"},children:e.jsx(ns,{className:"w-3 h-3 text-white"})})]})})]}),C==="checklist"&&e.jsxs("div",{className:"flex-1 overflow-y-auto p-3 space-y-3",children:[e.jsx(Xr,{myReg:s,tournament:t,tournamentGroups:i,bracketMatches:n}),e.jsx(Zr,{myReg:s,tournament:t,tournamentGroups:i,bracketMatches:n}),e.jsx(ti,{myReg:s,tournament:t,tournamentGroups:i,bracketMatches:n})]}),C==="camino"&&e.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:e.jsx(ei,{myReg:s,tournament:t,tournamentGroups:i,bracketMatches:n,registrations:[]})})]})]})}function ai({tournament:t,registration:s,groups:i,bracket:n}){const[r,a]=g.useState(!1);return e.jsxs("section",{className:"rounded-2xl border border-purple-500/20 bg-purple-500/[0.06] p-3","aria-label":"Copilot del torneo",children:[e.jsxs("button",{"aria-label":`${r?"Cerrar":"Abrir"} copiloto del torneo`,type:"button",onClick:()=>a(c=>!c),"aria-expanded":r,"aria-controls":"inline-tournament-copilot",className:"flex w-full items-center justify-between rounded-xl px-2 py-2 text-left text-sm font-black text-purple-200 hover:bg-purple-500/10",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ee,{className:"h-4 w-4"})," Copilot del torneo"]}),e.jsx(qe,{className:`h-4 w-4 transition-transform ${r?"rotate-180":""}`})]}),r&&e.jsx("div",{id:"inline-tournament-copilot",className:"mt-3 min-w-0","data-testid":"inline-tournament-copilot",children:e.jsx(si,{tournament:t,myReg:s,tournamentGroups:i||[],bracketMatches:n||[],onClose:()=>a(!1),inline:!0})})]})}function ri(t,s){const i=!!(s&&t&&(t.created_by_id===s.id||t.created_by?.toLowerCase()===s.email?.toLowerCase()||t.organizer_email?.toLowerCase()===s.email?.toLowerCase()));return U({queryKey:["tournament-core",t?.id],enabled:!!t?.id,queryFn:async()=>{const n=await f.entities.TournamentCore.filter({legacy_tournament_id:t.id},"-updated_date",1);return n[0]||!i?n[0]||null:(await f.functions.invoke("tournamentCore",{action:"migrate_tournament",tournament_id:t.id})).data?.core||null},staleTime:15e3})}function js(t,s){if(!s)return t;const i={DRAFT:"preparation",REGISTRATION_OPEN:"registration_open",REGISTRATION_CLOSED:"preparation",CHECK_IN:"preparation",READY:"preparation",LIVE:"live",REVIEW:"live",FINISHED:"completed",CANCELLED:"completed",ARCHIVED:"completed"},n={SINGLE_ELIMINATION:"single_elimination",DOUBLE_ELIMINATION:"double_elimination",ROUND_ROBIN:"round_robin",SWISS:"swiss"};return{...t,...s.configuration,status:i[s.status]||t.status,format:n[s.format]||t.format,core_id:s.id,core_status:s.status,core_version:s.version}}function ii({tournament:t,open:s,onOpenChange:i,onRegister:n,initialView:r="public"}){const[a,c]=g.useState("Resumen"),[o,m]=g.useState(r),[x,p]=g.useState("dense");g.useEffect(()=>{s&&(c("Resumen"),m(r),p("dense"))},[s,t?.id,r]);const d=Ut(),u=d.user,b=re();g.useEffect(()=>{if(!s||!t?.id)return;const F=M=>()=>
129b.invalidateQueries({queryKey:[M,t.id]}),T=[f.entities.TournamentRegistration.subscribe(F("tournament-registrations")),f.entities.TournamentGroup.subscribe(F("tournament-groups")),f.entities.BracketMatch.subscribe(F("bracket-matches")),f.entities.RoomInfo.subscribe(F("tournament-rooms")),f.entities.Match.subscribe(F("tournament-results"))];return()=>T.forEach(M=>typeof M=="function"?M():M?.unsubscribe?.())},[s,t?.id,b]);const{data:C}=ri(t,u),v=js(t,C),S={enabled:!!(t&&s)},{data:$=[],isLoading:R}=U({queryKey:["tournament-registrations",t?.id],queryFn:()=>f.entities.TournamentRegistration.filter({tournament_id:t.id}),staleTime:3e4,...S}),{data:h=[],isLoading:_}=U({queryKey:["tournament-groups",t?.id],queryFn:()=>f.entities.TournamentGroup.filter({tournament_id:t.id}),staleTime:3e4,...S}),I=R||_,{data:P=[]}=U({queryKey:["bracket-matches",t?.id],queryFn:()=>f.entities.BracketMatch.filter({tournament_id:t.id}),...S}),{data:Q=[]}=U({queryKey:["tournament-rooms",t?.id],queryFn:()=>f.entities.RoomInfo.filter({bloque_id:t.id}),...S}),{data:O=[]}=U({queryKey:["tournament-results",t?.id],queryFn:()=>f.entities.Match.filter({bloque_id:t.id}),...S}),B=g.useMemo(()=>Ys($),[$]),V=g.useMemo(()=>v?Zs(v,h,B):[],[v,h,B]);if(!t)return null;const z=B.find(F=>F.captain_email?F.captain_email.toLowerCase()===u?.email?.toLowerCase():F.created_by?.toLowerCase()===u?.email?.toLowerCase()),E=V.find(F=>F.teams.includes(z?.id)),N=t.created_by_id===u?.id||t.created_by?.toLowerCase()===u?.email?.toLowerCase()||t.organizer_email?.toLowerCase()===u?.email?.toLowerCase(),k=d.isAdmin||N||d.can(fe.TOURNAMENTS_BRACKETS,"tournament",t.id),y=async()=>navigator.share?navigator.share({title:t.name,url:location.href}):navigator.clipboard.writeText(location.href);return e.jsx(pe,{open:s,onOpenChange:i,children:e.jsxs(he,{className:"tournament-detail-neutral inset-0 h-[100dvh] max-h-none min-w-0 w-full max-w-full translate-x-0 translate-y-0 overflow-x-clip overflow-y-auto rounded-none border-0 bg-[#0D0F12] p-0 sm:left-[50%] sm:top-[50%] sm:h-[94vh] sm:w-[calc(100vw-2rem)] sm:max-w-[1480px] sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-xl sm:border sm:border-[#1E2226]",children:[e.jsx(be,{className:"sr-only",children:t.name}),e.jsxs("div",{id:"tournament-detail-stage",className:`tournament-mobile-scale mx-auto min-w-0 w-full overflow-x-hidden px-2 pb-16 pt-[calc(3.25rem+env(safe-area-inset-top))] sm:px-5 sm:pt-5 ${x==="minimal"?"max-w-[980px] gap-1.5 space-y-1.5 sm:space-y-2":x==="compact"?"max-w-[1180px] gap-1.5 space-y-1.5 sm:space-y-2":x==="info"?"max-w-[1100px] gap-2 space-y-2":"max-w-[1440px] gap-2 space-y-2 sm:space-y-3"}`,children:[x!=="minimal"&&e.jsx(lr,{tournament:v,count:B.length,onEnter:n,onShare:y}),e.jsx(Rr,{view:o,onChange:m,hasRegistration:!!z,canManage:k}),e.jsx(ps,{value:x,onChange:F=>{p(F),F==="info"&&c("Resumen")},targetId:"tournament-detail-stage",label:"Vista del torneo"}),!I&&e.jsx(ai,{tournament:v,registration:z,groups:V,bracket:P},t.id),e.jsx("div",{className:"min-w-0 max-w-full overflow-x-hidden",children:I?e.jsx(ni,{}):o==="admin"&&k?e.jsx(Jr,{tournament:v,registrations:B,bracket:P,groups:V,rooms:Q}):o==="participant"&&z?e.jsx(qr,{tournament:v,registration:z,group:E,groups:V,registrations:B,bracket:P,matches:O,rooms:Q}):e.jsx(Fr,{tab:a,onTabChange:c,tournament:v,registrations:B,groups:V,bracket:P,rooms:Q,matches:O,mine:z,isAdmin:d.isAdmin,layoutMode:x})})]})]})})}function ni(){return e.jsx("div",{className:"space-y-3",children:[1,2,3].map(t=>e.jsx("div",{className:"h-32 animate-pulse rounded-lg bg-[#191B1F]"},t))})}function Oe({targetDate:t,className:s="",showSeconds:i=!1}){const[n,r]=g.useState(a(t));g.useEffect(()=>{const c=setInterval(()=>{r(a(t))},1e3);return()=>clearInterval(c)},[t]);function a(c){const o=new Date(c)-new Date;return o<=0?{days:0,hours:0,minutes:0,seconds:0,expired:!0}:{days:Math.floor(o/(1e3*60*60*24)),hours:Math.floor(o/(1e3*60*60)%24),minutes:Math.floor(o/1e3/60%60),seconds:Math.floor(o/1e3%60),expired:!1}}return n.expired?e.jsxs("div",{className:`flex items-center gap-2 ${s}`,children:[e.jsx(Xe,{className:"w-4 h-4"}),e.jsx("span",{className:"font-bold",children:"¡Evento Iniciado!"})]}):e.jsxs("div",{className:`flex items-center gap-1 ${s}`,children:[e.jsx(Xe,{className:"w-3 h-3 flex-shrink-0"}),e.jsxs("div",{className:"flex gap-1 font-mono font-bold text-xs",children:[n.days>0&&e.jsxs("span",{children:[n.days,"d"]}),e.jsxs("span",{children:[String(n.hours).padStart(2,"0"),"h"]}),e.jsxs("span",{children:[String(n.minutes).padStart(2,"0"),"m"]}),i&&e.jsxs("span",{children:[String(n.seconds).padStart(2,"0"),"s"]})]})]})}const oi=[{id:"eventos",icon:W,title:"Eventos",description:"Gestionar torneos y competencias",href:J("Torneos"),accent:"text-orange-400",ring:"hover:border-orange-500/40",glow:"from-orange-500/10",iconBg:"bg-orange-500/12"},{id:"equipos",icon:ee,title:"Equipos",description:"Administrar squads y jugadores",href:J("GestionEquipo"),accent:"text-blue-400",ring:"hover:border-blue-500/40",glow:"from-blue-500/10",iconBg:"bg-blue-500/12"},{id:"resultados",icon:As,title:"Resultados",description:"Rankings y estadísticas",href:J("RankingGlobal"),accent:"text-amber-400",ring:"hover:border-amber-500/40",glow:"from-amber-500/10",iconBg:"bg-amber-500/12"},{id:"seguridad",icon:de,title:"Seguridad",description:"Códigos y organizadores",href:J("TrustFactor"),accent:"text-pink-400",ring:"hover:border-pink-500/40",glow:"from-pink-500/10",iconBg:"bg-pink-500/12"},{id:"ia",icon:Fs,title:"IA",description:"Asistentes inteligentes",href:J("AICoach"),accent:"text-purple-400",ring:"hover:border-purple-500/40",glow:"from-purple-500/10",iconBg:"bg-purple-500/12"},{id:"partidas",icon:rt,title:"Partidas",description:"Gestión de matches",href:J("ProLeague"),accent:"text-cyan-400",ring:"hover:border-cyan-500/40",glow:"from-cyan-500/10",iconBg:"bg-cyan-500/12"}];function li(){const t=Ie();return e.jsxs("div",{className:"mx-auto w-full max-w-2xl",children:[e.jsx("div",{className:"mb-3 flex items-end justify-between",children:e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-black tracking-tight text-white",children:"Acceso Rápido"}),e.jsx("p",{className:"mt-0.5 text-[11px] text-white/40",children:"Navega por las secciones principales"})]})}),e.jsx("div",{className:"grid grid-cols-2 gap-2.5 sm:grid-cols-3",children:oi.map((s,i)=>{const n=s.icon;return e.jsx(G.div,{initial:t?!1:{opacity:0,y:10}
129,animate:{opacity:1,y:0},transition:{delay:Math.min(i*.05,.25)},children:e.jsxs(De,{to:s.href,className:`group relative isolate flex h-full flex-col overflow-hidden rounded-2xl border border-white/[0.07] bg-white/[0.03] p-3.5 transition-all hover:bg-white/[0.06] ${s.ring}`,children:[e.jsx("div",{className:`pointer-events-none absolute -right-8 -top-8 h-24 w-24 rounded-full bg-gradient-to-br ${s.glow} to-transparent opacity-70 blur-2xl transition-opacity group-hover:opacity-100`}),e.jsx("div",{className:`mb-2.5 inline-flex h-9 w-9 items-center justify-center rounded-xl ${s.iconBg}`,children:e.jsx(n,{className:`h-5 w-5 ${s.accent}`,strokeWidth:2.2})}),e.jsx("p",{className:"text-[13px] font-bold leading-tight text-white",children:s.title}),e.jsx("p",{className:"mt-1 line-clamp-2 text-[10.5px] text-white/45",children:s.description}),e.jsxs("div",{className:"mt-2 flex items-center gap-1 text-[10px] font-bold opacity-0 transition-opacity group-hover:opacity-100",style:{color:"currentColor"},children:[e.jsx("span",{className:s.accent,children:"Abrir"}),e.jsx(Re,{className:`h-3 w-3 ${s.accent}`})]})]})},s.id)})})]})}function ci(){const t=Ie(),s=t?{}:{x:[0,36,-18,0],y:[0,-24,18,0],scale:[1,1.12,.96,1]};return e.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-0 overflow-hidden",children:[e.jsx(G.div,{animate:s,transition:{duration:14,repeat:1/0,ease:"easeInOut"},className:"absolute -left-28 top-24 h-72 w-72 rounded-full bg-cyan-500/[0.07] blur-3xl"}),e.jsx(G.div,{animate:t?{}:{...s,x:[0,-28,20,0]},transition:{duration:17,repeat:1/0,ease:"easeInOut"},className:"absolute -right-28 top-[32rem] h-80 w-80 rounded-full bg-purple-500/[0.08] blur-3xl"}),e.jsx("div",{className:"absolute inset-0 opacity-[0.025] [background-image:linear-gradient(rgba(255,255,255,.8)_1px,transparent_1px),linear-gradient(90deg,rgba(255,255,255,.8)_1px,transparent_1px)] [background-size:32px_32px]"})]})}const di=[{label:"Torneos",description:"Compite en campeonatos",path:"/Torneos",icon:W,tone:"text-amber-300 bg-amber-400/10 border-amber-400/20"},{label:"Bloques",description:"Salas y jornadas",path:"/Bloques",icon:Pa,tone:"text-purple-300 bg-purple-400/10 border-purple-400/20"},{label:"Scrims",description:"Prácticas competitivas",path:"/Scrims",icon:rt,tone:"text-red-300 bg-red-400/10 border-red-400/20"},{label:"Eventos",description:"Agenda competitiva",path:"/Calendario",icon:nt,tone:"text-cyan-300 bg-cyan-400/10 border-cyan-400/20"}];function mi(){return e.jsx("section",{"aria-label":"Tipos de competición",className:"mx-auto mb-4 grid max-w-2xl grid-cols-2 gap-2 px-4",children:di.map(({label:t,description:s,path:i,icon:n,tone:r})=>e.jsxs(De,{to:i,className:"group flex min-h-24 min-w-0 flex-col justify-between rounded-2xl border border-white/[0.08] bg-white/[0.04] p-3 text-left transition-colors hover:border-white/20 hover:bg-white/[0.08]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("span",{className:`flex h-9 w-9 items-center justify-center rounded-xl border ${r}`,children:e.jsx(n,{className:"h-4 w-4",strokeWidth:2.2})}),e.jsx(Ca,{className:"h-3.5 w-3.5 text-white/20 transition-colors group-hover:text-white/60"})]}),e.jsxs("div",{className:"mt-3 min-w-0",children:[e.jsx("p",{className:"truncate text-sm font-black text-white",children:t}),e.jsx("p",{className:"truncate text-[10px] font-medium text-white/35",children:s})]})]},t))})}const Pt={active_limit:0,monthly_limit:0,lifetime_limit:0,edit_others:!1,delete_others:!1,manage_registrations:!1},qt=t=>t==="user"?"Usuario nuevo":ls(cs,t);function xi({hierarchy:t,rolePermissions:s}){const i=re(),n=t.filter(u=>!["founder","flf_ceo"].includes(u)),[r,a]=g.useState(n[0]||"user"),[c,o]=g.useState(Pt),[m,x]=g.useState(!1);g.useEffect(()=>o({...Pt,...s?.[r]?.tournament_rules}),[r,s]);const p=(u,b)=>o(C=>({...C,[u]:b})),d=async()=>{x(!0);try{const u=await f.functions.invoke("manageGovernance",{action:"set_tournament_role_rules",role_type:r,rules:c,reason:"Reglas avanzadas de torneos"});if(!u.data?.success)throw new Error(u.data?.error||"No se pudo guardar");await Promise.all([i.invalidateQueries({queryKey:["tournament-role-permissions"]}),i.invalidateQueries({queryKey:["canonical-access"]})]),A.success(`Reglas de ${qt(r)} actualizadas`)}catch(u){A.error(u.message)}finally{x(!1)}};return e.jsxs("div",{className:"space-y-4 rounded-xl border border-slate-700 bg-slate-900 p-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-bold text-slate-100",children:"Configuración detallada por rol"}),e.jsx("p",{className:"mt-1 text-[11px] text-slate-400",children:"Un valor de 0 significa sin límite."})]}),e.jsx("select",{value:r,onChange:u=>a(u.target.value),className:"h-11 w-full rounded-lg border border-slate-600 bg-slate-950 px-3 text-sm font-semibold text-slate-100",children:n.map(u=>e.jsx("option",{value:u,children:qt(u)},u))}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:[["active_limit","Activos"],["monthly_limit","Por mes"],["lifetime_limit","Histórico"]].map(([u,b])=>e.jsxs("label",{children:[e.jsx("span",{className:"mb-1 block text-[10px] font-bold uppercase text-slate-400",children:b}),e.jsx("input",{type:"number",min:"0",value:c[u],onChange:C=>p(u,Math.max(0,Number(C.target.value)||0)),className:"h-10 w-full rounded-lg border border-slate-600 bg-slate-950 px-2 text-center text-sm text-slate-100"})]},u))}),e.jsx("div",{className:"space-y-2",children:[["edit_others","Editar torneos ajenos"],["delete_others","Borrar torneos ajenos"],["manage_registrations","Gestionar inscripciones ajenas"]].map(([u,b])=>e.jsxs("label",{className:"flex min-h-11 items-center justify-between rounded-lg border border-slate-700 bg-slate-950 px-3 text-xs font-semibold text-slate-200",children:[e.jsx("span",{children:b}),e.jsx("input",{type:"checkbox",checked:c[u],onChange:C=>p(u,C.target.checked),className:"h-4 w-4 accent-amber-400"})]},u))}),e.jsxs("button",{"aria-label":"Guardar",onClick:d,disabled:m,className:"flex h-11 w-full items-center justify-center gap-2 rounded-lg border border-slate-600 bg-slate-800 text-xs font-bold text-slate-100 hover:bg-slate-700 disabled:opacity-50",children:[m?e.jsx(Y,{className:"h-4 w-4 animate-spin"}):e.jsx(Me,{className:"h-4 w-4"}),"Guardar reglas del rol"]})]})}const It=t=>t==="user"?"Usuario nuevo":ls(cs,t);function ui(){const t=re(),[s,i]=g.useState("admin_only"),[n,r]=g.useState(!1),a=U({queryKey:["tournament-role-permissions"],queryFn:async()=>(await f.functions.invoke("manageGovernance",{action:"catalog"})).data});g.useEffect(()=>{a.data?.tournament_creation?.threshold&&i(a.data.tournament_creation.threshold)},[a.data]);const c=a.data?.hierarchy||[],o=a.data?.tournament_creation?.allowed_roles||[],m=async()=>{r(!0);try{const x=await f.functions.invoke("manageGovernance",{action:"set_tournament_creation_threshold",threshold:s,reason:"Jerarquía de creación configurada desde Torneos"});if(!x.data?.success)throw new Error(x.data?.error||"No se pudo guardar");ka(t,["RolePermissionPolicy"]),await t.invalidateQueries({queryKey:["tournament-role-permissions"]}),await t.invalidateQueries({queryKey:["canonical-access"]}),A.success("Permisos de creación actualizados")}catch(x){A.error(x.message)}finally{r(!1)}};return a.isLoading?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(Y,{className:"h-5 w-5 animate-spin text-amber-400"})}):e.jsxs("section",{className:"tournament-permissions-panel space-y-4",children:[e.jsxs("div",{className:"rounded-xl border border-amber-400/30 bg-amber-400/10 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-amber-300",children:[e.jsx(Vt,{className:"h-4 w-4"}),e.jsx("b",{className:"text-xs uppercase tracking-[0.14em]",children:"Control exclusivo"})]}),e.jsx("p",{className:"mt-2 text-xs leading-5 text-slate-300",children:"Sólo el Admin Global puede modificar esta jerarquía. El rango elegido y todos los rangos superiores podrán crear torneos."})]}),e.jsxs("label",{className:"block rounded-xl border border-slate-700 bg-slate-900 p-4",children:[e.jsx("span",{className:"mb-2 block text-[11px] font-bold uppercase tracking-[0.12em] text-slate-400",children:"Rango mínimo autorizado"}),e.jsxs("select",{value:s,onChange:x=>i(x.target.value),className:"h-12 w-full rounded-lg border border-slate-600 bg-slate-950 px-3 text-sm font-semibold text-slate-100 outline-none focus:border-amber-400",children:[e.jsx("option",{value:"admin_only",children:"Sólo administradores globales"}),c.filter(x=>!["founder","flf_ceo"].includes(x)).map(x=>e.jsxs("option",{value:x,children:[It(x)," y superiores"]},x))]})]}),e.jsxs("div",{className:"rounded-xl border border-emerald-400/20 bg-emerald-400/[0.06] p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(it,{className:"h-4 w-4 text-emerald-400"}),e.jsx("p",{className:"text-xs font-bold text-slate-100",children:"Acceso efectivo actual"})]}),o.length?e.jsx("div",{className:"mt-3 flex flex-wrap gap-2",children:o.map(x=>e.jsx("span",{className:"rounded-md border border-emerald-400/20 bg-slate-950 px-2.5 py-1.5 text-[11px] font-semibold text-emerald-300",children:It(x)},x))}):e.jsx("p",{className:"mt-2 text-xs leading-5 text-slate-300",children:"Ningún usuario normal; sólo administradores globales."})]}),e.jsxs("button",{"aria-label":"Guardar",onClick:m,disabled:n,className:"flex h-12 w-full items-center justify-center gap-2 rounded-xl bg-amber-400 text-xs font-black text-slate-950 transition-colors hover:bg-amber-300 disabled:opacity-50",children:[n?e.jsx(Y,{className:"h-4 w-4 animate-spin"}):e.jsx(Me,{className:"h-4 w-4"}),"Guardar jerarquía"]}),e.jsx(xi,{hierarchy:c,rolePermissions:a.data?.role_permissions||{}})]})}function pi({open:t,onOpenChange:s,tournament:i,registration:n,identity:r}){const{data:a,isLoading:c,isError:o,error:m,refetch:x,isFetching:p}=U({queryKey:["discord-tournament-profile",i.id,n.id],queryFn:async()=>(await f.functions.invoke("syncTournamentDiscordAccess",{action:"profile_summary",tournament_id:i.id,registration_id:n.id})).data,enabled:t,staleTime:0,refetchOnMount:"always",retry:!1}),d=a?.profile;return e.jsx(pe,{open:t,onOpenChange:s,children:e.jsxs(he,{onClick:u=>u.stopPropagation(),className:"max-h-[85vh] max-w-md overflow-y-auto rounded-2xl border border-white/10 bg-[#111318] text-white",children:[e.jsx(we,{children:e.jsxs(be,{className:"flex items-center gap-2",children:[e.jsx("img",{src:"https://cdn.simpleicons.org/discord/5865F2",alt:"",className:"h-5 w-5"}),"Discord · ",i.name]})}),c?e.jsxs("div",{className:"flex items-center justify-center gap-2 py-14 text-sm text-white/45",children:[e.jsx(Y,{className:"h-4 w-4 animate-spin"}),"Consultando el servidor…"]}):o||a?.error?e.jsxs("div",{className:"py-10 text-center",children:[e.jsx("p",{className:"text-sm text-red-300",children:m?.response?.data?.error||a?.error||"No se pudo cargar el resumen de Discord."}),e.jsxs("button",{"aria-label":"Actualizar",type:"button",onClick:()=>x(),disabled:p,className:"mx-auto mt-4 flex min-h-11 items-center justify-center gap-2 rounded-lg bg-[#5865F2] px-4 text-sm font-bold text-white disabled:opacity-50",children:[e.jsx($s,{className:`h-4 w-4 ${p?"animate-spin":""}`}),"Reintentar sincronización"]})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 rounded-xl border border-[#5865F2]/25 bg-[#5865F2]/10 p-3",children:[e.jsx("img",{src:d?.avatar_url||r.discord_avatar_url,alt:"",className:"h-14 w-14 roun
129ded-full object-cover"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate font-bold",children:d?.display_name||r.discord_global_name||r.discord_username}),e.jsxs("p",{className:"truncate text-sm text-[#aeb6ff]",children:["@",d?.username||r.discord_username]}),e.jsx("p",{className:"mt-1 text-xs text-white/40",children:d?.guild_member?"Miembro verificado del servidor":"Cuenta vinculada · fuera del servidor"})]})]}),e.jsxs("section",{children:[e.jsx("h4",{className:"mb-2 text-[11px] font-bold uppercase tracking-wider text-white/40",children:"Roles en el servidor"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:d?.roles?.length?d.roles.map(u=>e.jsx("span",{className:"rounded-full border border-white/10 bg-white/[0.06] px-2.5 py-1 text-xs text-white/75",children:u.name},u.id)):e.jsx("span",{className:"text-xs text-white/35",children:"Sin roles asignados"})})]}),e.jsxs("section",{children:[e.jsx("h4",{className:"mb-2 text-[11px] font-bold uppercase tracking-wider text-white/40",children:"Canales de este torneo"}),e.jsx("div",{className:"space-y-1.5",children:d?.channels?.length?d.channels.map(u=>e.jsxs("a",{href:u.url,target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 rounded-lg border border-white/[0.07] bg-white/[0.04] px-3 py-2 text-sm text-white/70 hover:bg-white/[0.08]",children:[u.type==="voice"?e.jsx(Sa,{className:"h-4 w-4 text-[#aeb6ff]"}):e.jsx(Ea,{className:"h-4 w-4 text-[#aeb6ff]"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:u.name})]},u.id)):e.jsx("span",{className:"text-xs text-white/35",children:"Los canales se habilitarán al sincronizar tu inscripción aprobada."})})]})]})]})})}function ws({tournament:t,registration:s,userId:i,compact:n=!1}){const[r,a]=g.useState(!1),{data:c}=U({queryKey:["discord-tournament-card-identity",i],queryFn:async()=>(await f.entities.DiscordIdentity.filter({user_id:i,connected:!0},"-updated_date",1))[0]||null,enabled:!!(i&&s),staleTime:6e4});return!s||!c?.discord_id?null:e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:o=>{o.stopPropagation(),a(!0)},title:"Ver perfil y accesos de Discord",className:`${n?"h-8 w-8 p-1.5":"min-h-10 px-3 py-2"} flex shrink-0 items-center justify-center gap-1.5 rounded-xl border border-[#5865F2]/35 bg-[#5865F2]/15 text-[11px] font-bold text-[#aeb6ff] transition-colors hover:bg-[#5865F2]/25`,children:[e.jsx("img",{src:"https://cdn.simpleicons.org/discord/5865F2",alt:"",className:"h-4 w-4"}),!n&&e.jsx("span",{children:"Discord"})]}),e.jsx(pi,{open:r,onOpenChange:a,tournament:t,registration:s,identity:c})]})}const ze="https://images.unsplash.com/photo-1542751371-adc38448a05e?w=600&q=80",le={live:{label:"EN VIVO",dot:"bg-red-500 animate-pulse",text:"text-red-400",bg:"bg-red-500/10",border:"border-red-500/25",badge:"bg-red-500"},preparation:{label:"PREPARACIÓN",dot:"bg-amber-500",text:"text-amber-400",bg:"bg-amber-500/10",border:"border-amber-500/20",badge:"bg-amber-600"},registration_open:{label:"INSCRIPCIONES",dot:"bg-cyan-500",text:"text-cyan-400",bg:"bg-cyan-500/10",border:"border-cyan-500/20",badge:"bg-cyan-500"},registration_closed:{label:"INSCRIPCIONES CERRADAS",dot:"bg-slate-500",text:"text-slate-400",bg:"bg-slate-700/20",border:"border-slate-600/20",badge:"bg-slate-600"},completed:{label:"FINALIZADO",dot:"bg-slate-500",text:"text-slate-400",bg:"bg-slate-700/20",border:"border-slate-600/20",badge:"bg-slate-600"},draft:{label:"BORRADOR",dot:"bg-amber-500",text:"text-amber-400",bg:"bg-amber-500/10",border:"border-amber-500/20",badge:"bg-amber-600"},cancelled:{label:"CANCELADO",dot:"bg-red-700",text:"text-red-400",bg:"bg-red-950/40",border:"border-red-800/30",badge:"bg-red-800"},archived:{label:"ARCHIVADO",dot:"bg-slate-700",text:"text-slate-500",bg:"bg-slate-900/40",border:"border-slate-800/30",badge:"bg-slate-800"}},ot={battle_royale:"Battle Royale",clash_squad:"Clash Squad",mapa_abierto:"Mapa Abierto",ranked:"Ranked",custom:"Custom"},hi={single_elimination:"Elim. Simple",double_elimination:"Doble Elim.",round_robin:"Round Robin",swiss:"Suizo"},Fe=new Set(["pending","approved","waiting_list"]);function vs(t,s){return Math.min(100,Math.round(t/(s||50)*100))}function bi({t,count:s}){const i=[];return t.status==="live"&&i.push({icon:Ne,label:"En Vivo",cls:"bg-red-500/15 text-red-400 border-red-500/20"}),t.featured&&i.push({icon:Be,label:"Destacado",cls:"bg-amber-500/15 text-amber-400 border-amber-500/20"}),t.official&&i.push({icon:W,label:"Oficial",cls:"bg-blue-500/15 text-blue-400 border-blue-500/20"}),t.verified&&i.push({icon:ae,label:"Verificado",cls:"bg-green-500/15 text-green-400 border-green-500/20"}),t.tournament_type==="league"&&i.push({icon:Vt,label:"Liga",cls:"bg-purple-500/15 text-purple-400 border-purple-500/20"}),s>
129=(t.max_teams||50)*.9&&t.status!=="completed"&&i.push({icon:Ne,label:"Últimos cupos",cls:"bg-orange-500/15 text-orange-400 border-orange-500/20"}),t.prize&&i.push({icon:Kt,label:"Con Premio",cls:"bg-yellow-500/15 text-yellow-400 border-yellow-500/20"}),i.slice(0,3)}const gi=[{id:"all",label:"Todos",icon:st},{id:"live",label:"En Vivo",icon:Ne},{id:"registration_open",label:"Próximos",icon:ve},{id:"prize",label:"Con Premio",icon:Kt},{id:"free",label:"Gratis",icon:Ee},{id:"battle_royale",label:"Battle Royale",icon:os},{id:"clash_squad",label:"Clash Squad",icon:rt}],Mt=[{id:"recent",label:"Más recientes"},{id:"popular",label:"Más populares"},{id:"prize",label:"Mayor premio"},{id:"slots",label:"Más cupos"},{id:"soon",label:"Más próximos"}],fi=[{id:"discover",icon:st,label:"Descubrir",action:"all"},{id:"mine",icon:W,label:"Mis Torneos",action:"mine"},{id:"team",icon:ee,label:"Mi Equipo",href:J("GestionEquipo")},{id:"calendar",icon:ve,label:"Calendario",href:J("CalendarioPersonal")},{id:"rankings",icon:Rs,label:"Rankings",href:J("RankingGlobal")}];function to(){const t=re(),s=Ie(),[i,n]=D.useState(null),[r,a]=D.useState(!1),[c,o]=D.useState(!1),m=D.useRef(!1),[x,p]=D.useState(!1),[d,u]=D.useState(!1),[b,C]=D.useState(null),[v,S]=D.useState(()=>new Set),[$,R]=D.useState(null),{user:h,refetch:_,isLoading:I}=Pe(),P=Ut(),[Q,O]=D.useState(!1),[B,V]=D.useState(!1),[z,E]=D.useState("public"),[N,k]=D.useState(""),[y,F]=D.useState("all"),[T,M]=D.useState("recent"),[te,L]=D.useState("list"),[ye,lt]=D.useState(!1),[ct,Ns]=D.useState(!1),[H,me]=D.useState({region:"all",format:"all",mode:"all",hasPrize:!1,isFree:!1,isPrivate:"all"}),ys=P.can(fe.TOURNAMENTS_CREATE),{data:dt=[],isLoading:_s}=U({queryKey:["tournaments"],queryFn:()=>f.entities.Tournament.list("-created_date")}),{data:mt=[]}=U({queryKey:["tournament-cores"],queryFn:()=>f.entities.TournamentCore.list("-updated_date",500)}),K=D.useMemo(()=>{const l=new Map(mt.map(q=>[q.legacy_tournament_id,q])),j=new URLSearchParams(window.location.search),w=j.get("preview")==="1"?j.get("tournamentId"):"";return dt.map(q=>js(q,l.get(q.id))).filter(q=>q.advanced_config?.publication?.status!=="draft"||w===q.id&&P.can(fe.TOURNAMENTS_EDIT,"tournament",q.id))},[dt,mt,P]),{data:se=[],isFetching:xt}=U({queryKey:["all-registrations",h?.email],queryFn:async()=>{const[l,j,w,q]=await Promise.all([f.entities.TournamentRegistration.list("-created_date",500),f.entities.TournamentRegistration.filter({captain_email:h.email},"-created_date",500),f.entities.TournamentRegistration.filter({participant_user_id:h.id},"-created_date",500),f.entities.TournamentRegistration.filter({participant_user_id:h.email},"-created_date",500)]);return[...new Map([...l,...j,...w,...q].map(Z=>[Z.id,Z])).values()]},staleTime:0,refetchOnMount:"always",refetchOnWindowFocus:!0,enabled:!!h}),_e=D.useCallback(l=>{if(!h||!l)return!1;const j=new Set([h.id,h.email?.toLowerCase()].filter(Boolean));return[l.participant_user_id,l.captain_email?.toLowerCase(),l.created_by?.toLowerCase()].filter(Boolean).some(w=>j.has(w))},[h]);D.useEffect(()=>{if(m.current||!K.length||I)return;const l=new URLSearchParams(window.location.search),j=l.get("tournamentId");if(!j)return;const w=K.find(X=>X.id===j);if(!w)return;const q=l.get("register")==="1";if(q&&!h){m.current=!0,f.auth.redirectToLogin(window.location.href);return}if(h&&xt)return;const Z=h?se.find(X=>Fe.has(X.status)&&X.tournament_id===w.id&&_e(X)):null;m.current=!0,n(w),q?Z?(E("participant"),o(!0)):a(!0):o(!0)},[K,h,I,se,xt]);const ut=ne({mutationFn:async l=>{const j=h.favorite_tournaments||[],w=j.includes(l),q=w?j.filter(Z=>Z!==l):[...j,l];return await f.auth.updateMe({favorite_tournaments:q}),{tournamentId:l,isFav:!w}},onSuccess:()=>_()}),Ge=ne({mutationFn:async({id:l,status:j})=>{const w=await f.functions.invoke("updateTournamentRegistration",{id:l,status:j});if(!w.data?.success)throw new Error(w.data?.error||"No se pudo actualizar la inscripción");return w.data},onSuccess:()=>{t.invalidateQueries({queryKey:["all-registrations"],exact:!1}),A.success("Estado de inscripción actualizado")},onError:l=>A.error(Ta(l,"No se pudo actualizar el estado de la inscripción."))}),xe=ne({mutationFn:async l=>{const j=await f.functions.invoke("withdrawTournamentRegistration",{registrationId:l.id});if(!j.data?.success)throw new Error(j.data?.error||"No se pudo retirar el equipo");return j.data},onSuccess:({registrationId:l})=>{S(j=>new Set([...j,l])),t.setQueriesData({queryKey:["all-registrations"]},(j=[])=>j.map(w=>w.id===l?{...w,status:"withdrawn"}:w)),t.setQueriesData({queryKey:["tournament-registrations"]},(j=[])=>j.map(w=>w.id===l?{...w,status:"withdrawn"}:w)),t.invalidateQueries({queryKey:["all-registrations"],exact:!1}),t.invalidateQueries({queryKey:["tournament-registrations"],exact:!1}),t.invalidateQueries({queryKey:["tournament-groups"],exact:!1}),t.invalidateQueries({queryKey:["tournaments"]}),A.success("Equipo retirado del torneo"),u(!0)},onError:l=>A.error(l.response?.data?.error||l.message||"Error al retirar el equipo")}),Cs=ne({mutationFn:async l=>{const j=await f.functions.invoke("manageGovernance",{action:"delete_tournament",tournament_id:l});if(!j.data?.success)throw new Error(j.data?.error||"No autorizado para eliminar este torneo");return j.data},onSuccess:()=>{t.invalidateQueries({queryKey:["tournaments"]}),A.success("Torneo eliminado")},onError:()=>A.error("Error al eliminar")}),ge=l=>se.filter(j=>j.tournament_id===l&&j.status==="approved").length,Ue=l=>h?se.find(j=>!v.has(j.id)&&Fe.has(j.status)&&j.tournament_id===l&&_e(j)):null,pt=D.useMemo(()=>({total:K.length,live:K.filter(l=>l.status==="live").length,registration_open:K.filter(l=>l.status==="registration_open").length,upcoming:K.filter(l=>["preparation","registration_open","registration_closed"].includes(l.status)).length,withPrize:K.filter(l=>l.prize).length,myEnrolled:h?se.filter(l=>Fe.has(l.status)&&_e(l)).length:0}),[K,se,h,_e]),ht=D.useMemo(()=>h?K.filter(l=>l.core_status?l.core_status==="REGISTRATION_OPEN":l.status==="registration_open").filter(l=>!Ue(l.id)).filter(l=>
129!l.region||l.region==="GLOBAL"||l.region===h.region||!h.region).slice(0,4):[],[K,h,se]),Ce=D.useMemo(()=>{const l=N.toLowerCase();let j=K.filter(w=>{if(l&&!w.name?.toLowerCase().includes(l)&&!w.region?.toLowerCase().includes(l)&&!w.game_mode?.toLowerCase().includes(l)||y==="live"&&w.status!=="live"||y==="registration_open"&&w.status!=="registration_open"||y==="prize"&&!w.prize||y==="free"&&w.entry_fee&&w.entry_fee!=="Gratis"&&w.entry_fee!=="0"&&w.entry_fee!==""||y==="battle_royale"&&w.game_mode!=="battle_royale"||y==="clash_squad"&&w.game_mode!=="clash_squad"||y==="favorites"&&!h?.favorite_tournaments?.includes(w.id))return!1;if(y==="mine"&&h){const q=se.some(X=>Fe.has(X.status)&&X.tournament_id===w.id&&_e(X)),Z=h.role==="admin"||w.created_by===h.email||w.organizer_email?.toLowerCase()===h?.email?.toLowerCase();if(!q&&!Z)return!1}return!(H.region!=="all"&&w.region!==H.region||H.format!=="all"&&w.format!==H.format||H.mode!=="all"&&w.game_mode!==H.mode||H.hasPrize&&!w.prize||H.isFree&&w.entry_fee&&w.entry_fee!=="Gratis"||H.isPrivate==="private"&&!w.private||H.isPrivate==="public"&&w.private)});return j.sort((w,q)=>{const Z=ge(w.id),X=ge(q.id);if(T==="popular")return X-Z;
129if(T==="slots")return(q.max_teams||50)-X-((w.max_teams||50)-Z);if(T==="soon")return w.start_date?q.start_date?new Date(w.start_date)-new Date(q.start_date):-1:1;if(T==="prize"){const ks=parseFloat(String(w.prize||"0").replace(/[^0-9.]/g,""))||0;return(parseFloat(String(q.prize||"0").replace(/[^0-9.]/g,""))||0)-ks}return new Date(q.created_date||0)-new Date(w.created_date||0)}),j},[K,N,y,T,H,h,se]),ke=(l,j="public")=>{n(l),E(j),o(!0)},bt=async l=>{if(!await f.auth.isAuthenticated()){const w=new URL(window.location.href);w.searchParams.set("tournamentId",l.id),w.searchParams.set("register","1"),f.auth.redirectToLogin(w.toString());return}n(l),o(!1),a(!0)};return _s?e.jsx("div",{className:"min-h-screen bg-black flex items-center justify-center",children:e.jsx(Y,{className:"w-6 h-6 text-white/20 animate-spin"})}):e.jsxs("div",{className:"relative isolate min-h-screen w-full max-w-full overflow-x-hidden bg-black pb-32",children:[e.jsx(ci,{}),e.jsxs("div",{className:"px-4 pt-2 pb-1 max-w-2xl mx-auto",children:[e.jsxs(G.div,{initial:s?!1:{opacity:0,y:-12},animate:{opacity:1,y:0},transition:{duration:.4,ease:[.22,1,.36,1]},className:"mb-2 flex min-w-0 flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("h1",{className:"text-[20px] font-black text-white leading-none",children:"Competiciones"}),e.jsxs("span",{className:"text-[11px] font-semibold text-white/25",children:[pt.total," disponibles"]})]}),e.jsxs("div",{className:"ml-auto flex min-w-0 flex-wrap items-center justify-end gap-2",children:[h&&e.jsx(_a,{type:"bloque"}),P.isSuperAdmin&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:()=>V(!0),className:"flex items-center gap-1.5 rounded-full border border-emerald-400/25 bg-emerald-400/10 px-3 py-1.5 text-[11px] font-bold text-emerald-300 transition-all hover:bg-emerald-400/20",children:[e.jsx(Ke,{className:"h-3 w-3"})," Códigos"]}),e.jsxs("button",{onClick:()=>O(!0),className:"flex items-center gap-1.5 rounded-full border border-amber-400/25 bg-amber-400/10 px-3 py-1.5 text-[11px] font-bold text-amber-300 transition-all hover:bg-amber-400/20",children:[e.jsx(Ke,{className:"h-3 w-3"})," Permisos"]})]}),ys&&e.jsxs(De,{to:"/admin/tournaments/create",className:"relative isolate flex items-center gap-2 rounded-full bg-[#61D095] px-4 py-2 text-[11px] font-black uppercase tracking-[0.08em] text-[#07100b] ring-2 ring-[#61D095]/50 shadow-[0_0_24px_rgba(97,208,149,0.68)] transition-all before:absolute before:-inset-1 before:-z-10 before:animate-pulse before:rounded-full before:bg-[#61D095]/35 before:blur-md before:content-[''] hover:bg-[#76d9a6] hover:shadow-[0_0_36px_rgba(97,208,149,0.9)] active:scale-95",children:[e.jsx(W,{className:"h-3.5 w-3.5"})," Crear torneo"]})]})]}),e.jsx(G.div,{initial:s?!1:{opacity:0,y:-8},animate:{opacity:1,y:0},transition:{delay:.08,duration:.42},className:"-mx-4 mb-3 flex w-[calc(100%+2rem)] items-center gap-1.5 overflow-x-auto overscroll-x-contain px-4 pb-1.5",style:{scrollbarWidth:"none",touchAction:"pan-x"},children:fi.map(l=>{const j=!!l.action&&(l.action==="all"?y==="all":y===l.action),w=l.icon,q=j?"bg-white text-black border-white shadow-[0_4px_18px_rgba(255,255,255,0.18)]":"bg-white/[0.05] text-white/55 border-white/[0.07] hover:bg-white/[0.1] hover:text-white/90";return l.href?e.jsxs(De,{to:l.href,className:`flex shrink-0 items-center gap-1.5 rounded-full border px-3 py-1.5 text-[11px] font-bold transition-all ${q}`,children:[e.jsx(w,{className:"h-3.5 w-3.5",strokeWidth:2.2}),e.jsx("span",{children:l.label})]},l.id):e.jsxs("button",{onClick:()=>{F(X=>l.action===X?"all":l.action);const Z=document.getElementById("torneos-list");Z&&Z.scrollIntoView({behavior:"smooth",block:"start"})},className:`flex shrink-0 items-center gap-1.5 rounded-full border px-3 py-1.5 text-[11px] font-bold transition-all ${q}`,children:[e.jsx(w,{className:"h-3.5 w-3.5",strokeWidth:2.2}),e.jsx("span",{children:l.label}),j&&e.jsx("span",{className:"ml-0.5 h-1 w-1 rounded-full bg-black"})]},l.id)})})]}),e.jsx(mi,{}),e.jsx(Ni,{tournaments:K,stats:pt,getRegisteredCount:ge,onOpen:ke}),ht.length>0&&h&&e.jsxs("div",{className:"px-4 max-w-2xl mx-auto mb-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Ee,{className:"w-3.5 h-3.5 text-purple-400"}),e.jsx("p",{className:"text-[11px] font-black uppercase tracking-[0.15em] text-white/30",children:"Recomendados para ti"})]}),e.jsx("div",{className:"-mx-4 flex w-[calc(100%+2rem)] gap-3 overflow-x-auto overscroll-x-contain px-4 pb-1",style:{scrollbarWidth:"none",touchAction:"pan-x"},children:ht.map(l=>{const j=ge(l.id),w=le[l.status]||le.preparation;return e.jsxs(G.button,{type:"button",onClick:()=>ke(l),"aria-label":`Abrir torneo ${l.name}`,whileHover:{scale:1.02,boxShadow:"0 0 0 1px #d4a84345, 0 20px 60px rgba(0,0,0,0.7), 0 0 40px #d4a84318"},whileTap:{scale:.97},className:"flex-shrink-0 w-44 rounded-2xl overflow-hidden text-left",style:{background:"rgba(255,255,255,0.04)",border:"1px solid #d4a84328",boxShadow:"0 0 0 1px #d4a84318, 0 8px 32px rgba(0,0,0,0.55)"},children:[e.jsxs("div",{className:"relative h-24",children:[e.jsx("img",{src:l.image_url||ze,alt:l.name||"Torneo",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0",style:{background:"linear-gradient(to top, rgba(0,0,0,0.85), transparent)"}}),e.jsxs("div",{className:`absolute top-2 left-2 flex items-center gap-1 px-1.5 py-0.5 rounded-full ${w.bg} ${w.border} border backdrop-blur-sm`,children:[e.jsx("span",{className:`w-1 h-1 rounded-full ${w.dot}`}),e.jsx("span",{className:`text-[8px] font-black ${w.text}`,children:w.label})]})]}),e.jsxs("div",{className:"p-2.5",children:[e.jsx("p",{className:"text-[11px] font-bold text-white line-clamp-1 mb-1",children:l.name}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] text-white/30",children:[e.jsx(ee,{className:"w-2.5 h-2.5"}
129),e.jsxs("span",{children:[j,"/",l.max_teams||16]}),l.prize&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsxs("span",{className:"flex items-center gap-1 text-amber-400",children:[e.jsx(W,{className:"w-2.5 h-2.5"})," Premio"]})]})]}),l.start_date&&!["live","completed","cancelled","archived"].includes(l.status)&&e.jsx(Oe,{targetDate:l.start_date,showSeconds:!0,className:"mt-2 rounded-lg border border-red-500/25 bg-red-500/10 px-2 py-1 text-[9px] text-red-400"})]})]},l.id)})})]}),e.jsxs(G.div,{initial:s?!1:{opacity:0,y:14},animate:{opacity:1,y:0},transition:{delay:.12,duration:.42},className:"relative z-10 px-4 max-w-2xl mx-auto mb-3",children:[e.jsxs("div",{className:"flex min-w-0 gap-1.5 mb-2",children:[e.jsxs("div",{className:"relative min-w-0 flex-1",children:[e.jsx(gt,{className:"absolute left-3.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-white/25"}),e.jsx("input",{value:N,onChange:l=>k(l.target.value),placeholder:"Buscar por nombre, región, modo...",className:"h-9 w-full min-w-0 rounded-xl border border-white/[0.07] bg-white/[0.06] pl-9 pr-3 text-[11px] text-white outline-none placeholder-white/20 transition-colors focus:border-white/20 sm:pr-10"}),N&&e.jsx("button",{type:"button",onClick:()=>k(""),"aria-label":"Limpiar búsqueda",className:"absolute right-3 top-1/2 flex h-9 w-9 -translate-y-1/2 items-center justify-center rounded-full text-white/30 hover:bg-white/[0.06] hover:text-white/60",children:e.jsx($e,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{type:"button",onClick:()=>lt(l=>!l),"aria-label":"Ordenar torneos","aria-expanded":ye,className:`h-full px-3 rounded-2xl border text-[11px] font-bold transition-all flex items-center gap-1.5 ${ye?"bg-purple-500/20 border-purple-500/40 text-purple-300":"bg-white/[0.06] border-white/[0.07] text-white/40"}`,children:e.jsx(Aa,{className:"w-3.5 h-3.5"})}),e.jsx(Je,{children:ye&&e.jsx(G.div,{initial:{opacity:0,y:6,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:6,scale:.97},className:"absolute right-0 top-full mt-2 w-44 rounded-2xl border border-white/[0.09] overflow-hidden z-30",style:{background:"#1c1c1e"},children:Mt.map(l=>e.jsx("button",{onClick:()=>{M(l.id),lt(!1)},className:`w-full px-4 py-2.5 text-left text-[12px] font-semibold transition-colors ${T===l.id?"text-purple-300 bg-purple-500/10":"text-white/50 hover:text-white hover:bg-white/[0.04]"}`,children:l.label},l.id))})})]}),e.jsx("div",{className:"flex rounded-2xl overflow-hidden border border-white/[0.07]",children:[{id:"list",icon:Fa},{id:"grid",icon:zt}].map(({id:l,icon:j})=>e.jsx("button",{type:"button",onClick:()=>L(l),"aria-label":l==="list"?"Vista de lista":"Vista de cuadrícula","aria-pressed":te===l,className:`w-10 h-full flex items-center justify-center transition-all ${te===l?"bg-purple-500/25 text-purple-300":"bg-white/[0.04] text-white/25 hover:text-white/50"}`,children:e.jsx(j,{className:"w-4 h-4"})},l))})]}),e.jsxs("div",{className:"-mx-4 flex w-[calc(100%+2rem)] gap-1.5 overflow-x-auto px-4 pb-1",children:[gi.map(l=>e.jsxs(G.button,{onClick:()=>F(l.id===y?"all":l.id),whileHover:s?void 0:{y:-2,scale:1.03},whileTap:{scale:.95},className:`flex shrink-0 items-center gap-1 rounded-full border px-2 py-1 text-[9px] font-semibold transition-all ${y===l.id?"bg-white text-black border-white shadow-[0_0_18px_rgba(255,255,255,0.22)]":"bg-white/[0.05] text-white/40 border-white/[0.07] hover:text-white/70 hover:border-white/20"}`,children:[D.createElement(l.icon,{className:"w-3 h-3"})," ",l.label]},l.id)),e.jsxs(G.button,{whileTap:{scale:.95},onClick:()=>Ns(l=>!l),className:`flex shrink-0 items-center gap-1 rounded-full border px-2 py-1 text-[9px] font-semibold transition-all ${ct?"border-purple-500/40 bg-purple-500/15 text-purple-300":"border-white/[0.07] bg-white/[0.05] text-white/40"}`,children:[e.jsx($a,{className:"w-3 h-3"})," Más filtros"]})]}),e.jsx(Je,{children:ct&&e.jsx(G.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden",children:e.jsxs("div",{className:"grid grid-cols-1 gap-2 pt-3 sm:grid-cols-2",children:[e.jsxs("select",{value:H.region,onChange:l=>me(j=>({...j,region:l.target.value})),className:"px-3 py-2.5 rounded-xl bg-white/[0.05] border border-white/[0.07] text-white/60 text-[12px] outline-none",children:[e.jsx("option",{value:"all",children:"Todas las regiones"}),["LATAM_NORTE","LATAM","SUR","NORTE","BRASIL","NA","EU","ASIA","GLOBAL"].map(l=>e.jsx("option",{value:l,children:l},l))]}
129),e.jsxs("select",{value:H.mode,onChange:l=>me(j=>({...j,mode:l.target.value})),className:"px-3 py-2.5 rounded-xl bg-white/[0.05] border border-white/[0.07] text-white/60 text-[12px] outline-none",children:[e.jsx("option",{value:"all",children:"Todos los modos"}),Object.entries(ot).map(([l,j])=>e.jsx("option",{value:l,children:j},l))]}),e.jsxs("select",{value:H.format,onChange:l=>me(j=>({...j,format:l.target.value})),className:"px-3 py-2.5 rounded-xl bg-white/[0.05] border border-white/[0.07] text-white/60 text-[12px] outline-none",children:[e.jsx("option",{value:"all",children:"Todos los formatos"}),Object.entries(hi).map(([l,j])=>e.jsx("option",{value:l,children:j},l))]}),e.jsxs("select",{value:H.isPrivate,onChange:l=>me(j=>({...j,isPrivate:l.target.value})),className:"px-3 py-2.5 rounded-xl bg-white/[0.05] border border-white/[0.07] text-white/60 text-[12px] outline-none",children:[e.jsx("option",{value:"all",children:"Público y Privado"}),e.jsx("option",{value:"public",children:"Solo Públicos"}),e.jsx("option",{value:"private",children:"Solo Privados"})]}),e.jsxs("label",{className:"flex items-center gap-2 px-3 py-2.5 rounded-xl bg-white/[0.05] border border-white/[0.07] curs
129or-pointer",children:[e.jsx("input",{type:"checkbox",checked:H.hasPrize,onChange:l=>me(j=>({...j,hasPrize:l.target.checked})),className:"accent-purple-500"}),e.jsx("span",{className:"text-[12px] text-white/60",children:"Solo con premio"})]}),e.jsxs("label",{className:"flex items-center gap-2 px-3 py-2.5 rounded-xl bg-white/[0.05] border border-white/[0.07] cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:H.isFree,onChange:l=>me(j=>({...j,isFree:l.target.checked})),className:"accent-purple-500"}),e.jsx("span",{className:"text-[12px] text-white/60",children:"Solo gratis"})]})]})})})]}),e.jsxs(G.div,{initial:s?!1:{opacity:0},animate:{opacity:1},transition:{delay:.2},className:"relative z-10 px-4 max-w-2xl mx-auto mb-3 flex items-center justify-between",children:[e.jsxs("p",{className:"text-[11px] text-white/25 font-semibold",children:[Ce.length," ",Ce.length===1?"torneo":"torneos"]}),e.jsx("p",{className:"text-[11px] text-white/20",children:Mt.find(l=>l.id===T)?.label})]}),e.jsx("div",{id:"torneos-list",className:"relative z-10 scroll-mt-32 px-4 max-w-2xl mx-auto",children:Ce.length===0?e.jsxs("div",{className:"text-center py-20",children:[K.length===0?e.jsx(Ne,{className:"w-9 h-9 mx-auto mb-3 text-white/25"}):e.jsx(gt,{className:"w-9 h-9 mx-auto mb-3 text-white/25"}),e.jsx("p",{className:"text-white/40 font-semibold text-sm mb-1",children:K.length===0?"No hay torneos publicados en este momento":"No encontramos torneos con esos filtros"}),e.jsx("p",{className:"mb-4 text-xs text-white/25",children:K.length===0?"Puedes revisar Scrims o Bloques mientras se publican nuevas competiciones.":"Limpia los filtros o cambia la búsqueda para ver más opciones."}),K.length===0&&e.jsxs("div",{className:"mb-4 flex justify-center gap-2",children:[e.jsx("a",{href:"/Scrims",className:"rounded-full border border-white/10 bg-white/[0.05] px-4 py-2 text-xs font-bold text-white/65",children:"Ver Scrims"}),e.jsx("a",{href:"/Bloques",className:"rounded-full border border-white/10 bg-white/[0.05] px-4 py-2 text-xs font-bold text-white/65",children:"Ver Bloques"})]}),K.length>0&&e.jsx("button",{"aria-label":"Buscar",onClick:()=>{k(""),F("all"),me({region:"all",format:"all",mode:"all",hasPrize:!1,isFree:!1,isPrivate:"all"})},className:"px-5 py-2 rounded-full text-xs font-bold text-white bg-white/[0.07] border border-white/[0.1] hover:bg-white/[0.12] transition-all",children:"Limpiar filtros"})]}):te==="grid"?e.jsx("div",{className:"grid grid-cols-1 gap-3 min-[390px]:grid-cols-2",children:Ce.map((l,j)=>e.jsx(wi,{tournament:l,index:j,count:ge(l.id),myReg:Ue(l.id),userId:h?.id,isFav:h?.favorite_tournaments?.includes(l.id),onToggleFav:()=>ut.mutate(l.id),onOpen:()=>ke(l)},l.id))}):e.jsx("div",{className:"space-y-3",children:Ce.map((l,j)=>e.jsx(ji,{tournament:l,index:j,count:ge(l.id),myReg:Ue(l.id),isCreator:h&&(l.created_by===h.email||l.created_by_id===h.id||l.organizer_email?.toLowerCase()===h.email?.toLowerCase()),canEditOthers:P.can(fe.TOURNAMENTS_EDIT),canDeleteOthers:P.can(fe.TOURNAMENTS_DELETE),canManageRegistrations:P.can(fe.TOURNAMENTS_REGISTRATIONS_MANAGE),isFav:h?.favorite_tournaments?.includes(l.id),user:h,onToggleFav:()=>ut.mutate(l.id),onOpen:()=>ke(l),onRegister:()=>bt(l),onWithdraw:w=>{if(l.allow_withdrawal===!1){A.error("El organizador bloqueó los retiros");return}u(!1),C(w),p(!0)},onAdmin:()=>ke(l,"admin"),onRegistrations:()=>R(l),onDelete:()=>{confirm("¿Eliminar torneo?")&&Cs.mutate(l.id)}},l.id))})}),e.jsx("div",{className:"px-4 pb-4 mt-8 max-w-2xl mx-auto",children:e.jsx(li,{})}),i&&e.jsxs(e.Fragment,{children:[e.jsx(ii,{tournament:i,open:c,initialView:z,onOpenChange:l=>{o(l),l||t.invalidateQueries({queryKey:["all-registrations"],exact:!1})},onRegister:()=>bt(i),onWithdrawSuccess:()=>t.invalidateQueries({queryKey:["all-registrations"]})}),i.bracket_options?.registration_mode==="solo"||i.bracket_options?.max_players_per_entry===1?e.jsx(ir,{tournament:i,open:r,onOpenChange:l=>{a(l),l||t.invalidateQueries({queryKey:["all-registrations"],exact:!1})}}):e.jsx(rr,{tournament:i,open:r,onOpenChange:l=>{a(l),l||t.invalidateQueries({queryKey:["all-registrations"],exact:!1})}})]}),e.jsx(pe,{open:B,onOpenChange:V,children:e.jsxs(he,{className:"max-h-[90vh] max-w-2xl overflow-y-auto rounded-2xl border border-slate-700 bg-slate-950 text-slate-100 shadow-2xl",children:[e.jsx(we,{children:e.jsx(be,{children:"Generar códigos de acceso por lote"})}),e.jsx(ya,{})]})}),e.jsx(pe,{open:Q,onOpenChange:O,children:e.jsxs(he,{className:"tournament-permissions-dark max-h-[90vh] max-w-md overflow-y-auto rounded-2xl border border-slate-700 bg-slate-950 text-slate-100 shadow-2xl",children:[e.jsx(we,{className:"border-b border-slate-800 pb-4",children:e.jsxs(be,{className:"flex items-center gap-2 text-lg font-bold text-slate-100",children:[e.jsx("span",{className:"flex h-9 w-9 items-center justify-center rounded-lg bg-amber-400/10",children:e.jsx(Ke,{className:"h-4 w-4 text-amber-400"})}),"Permisos para crear torneos"]})}),P.isSuperAdmin&&e.jsx(ui,{})]})}),e.jsx(pe,{open:!!$,onOpenChange:l=>!l&&R(null),children:e.jsxs(he,{className:"bg-[#1c1c1e] border-white/[0.08] text-white max-w-xl max-h-[85vh] overflow-y-auto rounded-3xl",children:[e.jsx(we,{children:e.jsxs(be,{children:["Inscripciones · ",$?.
129name]})}),e.jsx("div",{className:"space-y-3 pt-2",children:se.filter(l=>l.tournament_id===$?.id).length===0?e.jsx("div",{className:"py-12 text-center text-white/35 text-sm",children:"Este torneo todavía no tiene inscripciones."}):se.filter(l=>l.tournament_id===$?.id).map(l=>e.jsx(da,{registration:l,tournament:$,withdrawing:xe.isPending&&xe.variables?.id===l.id,updating:Ge.isPending&&Ge.variables?.id===l.id,canManage:!0,onStatusChange:(j,w)=>Ge.mutate({id:j.id,status:w}),onWithdraw:j=>xe.mutate(j)},l.id))})]})}),e.jsx(Ht,{open:x,onOpenChange:()=>{},children:e.jsxs(Wt,{className:"bg-[#1c1c1e] border-white/[0.08] text-white rounded-3xl",children:[e.jsx("button",{type:"button",onClick:()=>{p(!1),C(null)},"aria-label":"Cerrar aviso de retiro",className:"absolute right-4 top-4 flex h-11 w-11 items-center justify-center rounded-full text-white/45 transition-colors hover:bg-white/[0.08] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/50",children:e.jsx($e,{className:"h-5 w-5"})}),e.jsxs(Jt,{children:[e.jsxs(Yt,{className:`flex items-center gap-2 pr-10 ${d?"text-emerald-400":"text-red-400"}`,children:[d?e.jsx(ae,{className:"h-5 w-5"}):e.jsx(at,{className:"h-4 w-4"}),d?"Retiro confirmado":"¿Retirar equipo?"]}),e.jsx(Zt,{className:"text-white/50 text-sm",children:d?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-white font-semibold",children:b?.team_name})," fue retirado correctamente del torneo."]}):e.jsxs(e.Fragment,{children:["Se retirará ",e.jsx("span",{className:"text-white font-semibold",children:b?.team_name})," del torneo. Esta acción no se puede deshacer."]})})]}),!d&&e.jsxs(Ps,{children:[e.jsx("button",{"aria-label":"Cerrar",type:"button",disabled:xe.isPending,onClick:()=>{p(!1),C(null)},className:"inline-flex min-h-11 items-center justify-center rounded-xl border border-white/[0.08] bg-white/[0.06] px-4 text-sm font-semibold text-white transition-colors hover:bg-white/[0.1] disabled:opacity-50",children:"Cancelar"}),e.jsx("button",{type:"button",onClick:()=>xe.mutate(b),disabled:xe.isPending,className:"inline-flex min-h-11 items-center justify-center rounded-xl bg-red-500 px-4 text-sm font-semibold text-white transition-colors hover:bg-red-600 disabled:opacity-50",children:xe.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"mr-2 h-4 w-4 animate-spin"}),"Retirando…"]}):"Confirmar"})]})]})})]})}function ji({tournament:t,index:s,count:i,myReg:n,isCreator:r,canEditOthers:a,canDeleteOthers:c,canManageRegistrations:o,isFav:m,user:x,onToggleFav:p,onOpen:d,onRegister:u,onWithdraw:b,onAdmin:C,onRegistrations:v,onDelete:S}){const $=i>
129=(t.max_teams||50),R=vs(i,t.max_teams||50),h=t.image_url||ze,_=le[t.status]||le.preparation,I=bi({t,count:i}),P=!!x&&(r||a),Q=!!x&&(r||c),O=!!x&&(r||o),B=P||Q||O,V=t.allow_withdrawal===!1||t.status==="completed",z=!!n&&!V,E=t.core_status?t.core_status==="REGISTRATION_OPEN":t.status==="registration_open",N=!n&&!$&&E,k=n?.status==="approved"?"bg-emerald-500/10 border-emerald-500/20 text-emerald-400":n?.status==="rejected"?"bg-red-500/10 border-red-500/20 text-red-400":"bg-amber-500/10 border-amber-500/20 text-amber-400";return e.jsxs(G.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},whileHover:{y:-2,boxShadow:"0 0 0 1px #d4a84345, 0 20px 60px rgba(0,0,0,0.7), 0 0 40px #d4a84318"},transition:{delay:Math.min(s*.04,.3)},className:"rounded-2xl overflow-hidden",style:{background:"rgba(28,28,30,0.95)",border:"1px solid #d4a84328",boxShadow:"0 0 0 1px #d4a84318, 0 8px 32px rgba(0,0,0,0.55)"},children:[e.jsxs("div",{className:"relative h-36 overflow-hidden",children:[e.jsx("img",{src:h,alt:t.name,className:"w-full h-full object-cover opacity-55"}),e.jsx("div",{className:"absolute inset-0",style:{background:"linear-gradient(to top, #1c1c1e 0%, rgba(28,28,30,0.5) 55%, transparent 100%)"}}),e.jsxs("div",{className:`absolute top-3 left-3 flex items-center gap-1 px-2 py-1 rounded-full ${_.bg} ${_.border} border backdrop-blur-sm`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${_.dot}`}),e.jsx("span",{className:`text-[9px] font-black ${_.text}`,children:_.label})]}),t.private&&e.jsxs("div",{className:"absolute top-3 right-14 flex items-center gap-1 px-2 py-1 rounded-full bg-violet-500/15 border border-violet-500/25 backdrop-blur-sm",children:[e.jsx(Ds,{className:"w-2.5 h-2.5 text-violet-400"}),e.jsx("span",{className:"text-[9px] font-bold text-violet-400",children:"PRIVADO"})]}),$&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/60",children:e.jsx("span",{className:"text-2xl font-black text-white tracking-widest border-2 border-red-500/60 bg-red-600/80 px-5 py-1.5 rounded-xl -rotate-6",children:"SOLD OUT"})}),n&&e.jsxs("div",{className:"absolute top-12 left-3 flex items-center gap-1 px-2.5 py-1 rounded-full bg-emerald-500/20 border border-emerald-500/30 backdrop-blur-sm",children:[e.jsx(ae,{className:"w-2.5 h-2.5 text-emerald-400"}),e.jsxs("span",{className:"text-[9px] font-black text-emerald-400",children:["INSCRITO",n.slot_number?` · #${n.slot_number}`:"",n.status==="approved"?" ✓":" · PENDIENTE"]})]}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 px-4 pb-3",children:e.jsx("h3",{className:"text-[15px] font-black text-white leading-tight line-clamp-1 drop-shadow",children:t.name})})]}),e.jsxs("div",{className:"px-4 pt-3 pb-4",children:[I.length>0&&e.jsx("div",{className:"flex gap-1.5 flex-wrap mb-3",children:I.map(y=>e.jsxs("span",{className:`text-[9px] font-bold px-2 py-0.5 rounded-full border ${y.cls}`,children:[D.createElement(y.icon,{className:"inline-block w-3 h-3 mr-1 align-[-2px]"}),y.label]},y.label))}),(()=>{const y=vi(t,i);return e.jsxs("div",{className:`mb-3 inline-flex items-center gap-1.5 rounded-full border px-2.5 py-0.5 text-[10px] font-bold ${y.cls}`,children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${y.dot}`}),e.jsx("span",{children:y.label})]})})(),e.jsxs("div",{className:"flex items-center gap-2.5 mb-3 flex-wrap",children:[t.start_date&&e.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-white/35",children:[e.jsx(ve,{className:"w-3 h-3 text-cyan-500/60"}),e.jsx("span",{children:ds(new Date(t.start_date),"d MMM yyyy",{locale:Qt})})]}),e.jsx("span",{className:"w-px h-3 bg-white/[0.08]"}),e.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-white/35",children:[e.jsx(ee,{className:"w-3 h-3 text-cyan-500/60"}),e.jsxs("span",{children:[i,"/",t.max_teams||16]})]}),t.region&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-px h-3 bg-white/[0.08]"}),e.jsxs("div",{className:"flex items-center gap-1 text-[11px] text-white/35",children:[e.jsx(Ra,{className:"w-3 h-3 text-cyan-500/60"}),e.jsx("span",{children:t.region})]})]}),t.game_mode&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-px h-3 bg-white/[0.08]"}),e.jsx("span",{className:"text-[11px] text-white/35",children:ot[t.game_mode]||t.game_mode})]})]}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsxs("div",{className:"flex-1 px-3 py-2 rounded-xl bg-white/[0.04] border border-white/[0.06]",children:[e.jsx("p",{className:"text-[9px] text-white/25 uppercase tracking-wider font-bold mb-0.5",children:"Inscripción"}),e.jsx("p",{className:"text-[13px] text-white font-bold",children:t.entry_fee||"Gratis"})]}),t.prize&&e.jsxs("div",{className:"flex-1 px-3 py-2 rounded-xl bg-amber-500/[0.07] border border-amber-500/20",children:[e.jsx("p",{className:"text-[9px] text-amber-500/60 uppercase tracking-wider font-bold mb-0.5",children:"Premio"}),e.jsx("p",{className:"text-[13px] text-amber-300 font-bold",children:t.prize})]})]}),t.start_date&&!["live","completed","cancelled","archived"].includes(t.status)&&e.jsxs("div",{className:"mb-3 rounded-xl border border-red-500/25 bg-red-500/10 px-3 py-2",children:[e.jsx("p",{className:"mb-1 text-[9px] font-black uppercase tracking-[0.12em] text-red-400/70",children:"Comienza en"}),e.jsx(Oe,{targetDate:t.start_date,showSeconds:!0,className:"text-[11px] text-red-400"})]}),(()=>{const y=t.status==="live"?"#ef4444":t.status==="completed"?"#64748b":R>=90?"#f97316":R>=60?"#eab308":"#06b6d4",F=t.status==="live"?"rgba(239,68,68,0.95)":t.status==="completed"?"rgba(100,116,139,0.5)":R>=90?"rgba(249,115,22,0.95)":R>
129=60?"rgba(234,179,8,0.9)":"rgba(6,182,212,0.9)",T=t.status==="live"?"0.7s":R>=90?"0.9s":R>=60?"1.3s":"2s",M=`saber-${t.id}`;return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`@keyframes ${M}{0%,100%{box-shadow:0 0 8px ${F},0 0 20px ${F},0 0 40px ${F};opacity:1}50%{box-shadow:0 0 3px ${F},0 0 8px ${F};opacity:0.6}}`}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsxs("p",{className:"text-[9px] text-white/20",children:[i," de ",t.max_teams||16," cupos"]}),e.jsxs("p",{className:"text-[9px] font-bold",style:{color:y},children:[R,"%"]})]}),e.jsx("div",{className:"h-[5px] bg-white/[0.06] rounded-full overflow-visible",children:e.jsx(G.div,{className:"h-full rounded-full",initial:{width:0},animate:{width:`${R}%`},transition:{duration:.7,delay:.1},style:{background:`linear-gradient(90deg, ${y}99, ${y})`,animation:`${M} ${T} ease-in-out infinite`}})})]})]})})(),e.jsxs("div",{className:"space-y-2",children:[B&&e.jsxs("div",{className:"grid grid-cols-2 gap-1.5 sm:flex",children:[P&&e.jsxs("button",{onClick:C,className:"flex-1 flex items-center justify-center gap-1.5 py-2 rounded-xl bg-purple-500/10 text-purple-400 border border-purple-500/20 hover:bg-purple-500/15 transition-all active:scale-95 text-[11px] font-bold",children:[e.jsx(de,{className:"w-3.5 h-3.5"})," Administrar"]}),O&&e.jsxs("button",{onClick:v,className:"flex-1 flex items-center justify-center gap-1.5 py-2 rounded-xl bg-white/[0.06] text-white/70 border border-white/[0.08] hover:bg-white/[0.1] transition-all active:scale-95 text-[11px] font-bold",children:[e.jsx(ee,{className:"w-3.5 h-3.5"})," Inscripciones"]}),Q&&e.jsx("button",{"aria-label":"Eliminar",onClick:S,className:"flex items-center justify-center rounded-xl border border-red-500/20 bg-red-500/10 px-3 py-2 text-red-400 transition-all hover:bg-red-500/15 active:scale-95",children:e.jsx(at,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{"aria-label":`Ver detalles de ${t.name||"torneo"}`,onClick:d,className:"flex-1 py-2.5 rounded-xl bg-white/[0.07] text-white font-semibold text-[12px] hover:bg-white/[0.12] transition-all active:scale-95",children:"Ver detalles"}),n?e.jsxs(e.Fragment,{children:[e.jsxs("div",{"aria-label":"Inscrito",className:`flex h-10 shrink-0 items-center justify-center gap-1.5 rounded-xl border px-3 text-[11px] font-bold ${k}`,children:[e.jsx(ae,{className:"h-4 w-4",strokeWidth:2.4}),e.jsx("span",{children:"Inscrito"})]}),e.jsx(ws,{tournament:t,registration:n,userId:x?.id}),e.jsxs("button",{type:"button",onClick:()=>z&&b(n),disabled:!z,"aria-label":V?"Retiro no disponible":`Retirar a ${n.team_name} del torneo`,"data-testid":`withdraw-registration-${n.id}`,className:"px-3 py-2.5 rounded-xl bg-red-500/10 text-red-400 border border-red-500/20 hover:bg-red-500/15 transition-all active:scale-95 text-[11px] font-bold flex items-center gap-1.5 disabled:cursor-not-allowed disabled:opacity-40 disabled:active:scale-100",children:[e.jsx(Le,{className:"w-3.5 h-3.5"})," ",V?"Retiro no disponible":"Retirar"]})]}):e.jsx("button",{onClick:u,disabled:!N,className:"flex-1 py-2.5 rounded-xl bg-white text-black font-bold text-[12px] hover:bg-white/90 transition-all active:scale-95 disabled:opacity-30 disabled:cursor-not-allowed",children:$?"Lleno":t.status==="completed"?"Finalizado":E?"Inscribirse":"Cerradas"}),x&&e.jsxs("button",{onClick:y=>{y.stopPropagation(),p()},title:"Seguir torneo",className:`px-3 py-2.5 rounded-xl border text-[11px] font-bold flex items-center gap-1.5 transition-all active:scale-95 ${m?"bg-amber-500/15 border-amber-500/30 text-amber-400":"bg-white/[0.06] border-white/[0.08] text-white/60 hover:bg-white/[0.1]"}`,children:[e.jsx(Be,{className:"h-3.5 w-3.5",style:{fill:m?"#facc15":"none"}}),e.jsx("span",{className:"hidden sm:inline",children:m?"Siguiendo":"Seguir"})]})]})]})]})]})}function wi({tournament:t,index:s,count:i,myReg:n,userId:r,isFav:a,onToggleFav:c,onOpen:o}){const m=le[t.status]||le.preparation,x=t.image_url||ze,p=vs(i,t.max_team
129s||50);return e.jsxs(G.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},whileHover:{scale:1.02,boxShadow:"0 0 0 1px #d4a84345, 0 20px 60px rgba(0,0,0,0.7), 0 0 40px #d4a84318"},transition:{delay:Math.min(s*.03,.3)},onClick:o,className:"cursor-pointer rounded-2xl overflow-hidden",style:{background:"rgba(28,28,30,0.95)",border:"1px solid #d4a84328",boxShadow:"0 0 0 1px #d4a84318, 0 8px 32px rgba(0,0,0,0.55)"},children:[e.jsxs("div",{className:"relative h-28",children:[e.jsx("img",{src:x,alt:t.name,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0",style:{background:"linear-gradient(to top, rgba(0,0,0,0.85), transparent)"}}),e.jsxs("div",{className:`absolute top-2 left-2 flex items-center gap-1 px-1.5 py-0.5 rounded-full ${m.bg} ${m.border} border backdrop-blur-sm`,children:[e.jsx("span",{className:`w-1 h-1 rounded-full ${m.dot}`}),e.jsx("span",{className:`text-[8px] font-black ${m.text}`,children:m.label})]}),n&&e.jsx("div",{className:"absolute top-2 right-2 w-5 h-5 rounded-full flex items-center justify-center bg-emerald-500/20 border border-emerald-500/35",children:e.jsx(ae,{className:"w-3 h-3 text-emerald-400"})}),t.prize&&e.jsxs("div",{className:"absolute bottom-2 left-2 text-[9px] text-amber-300 font-bold bg-black/50 px-1.5 py-0.5 rounded-full backdrop-blur-sm",children:[e.jsx(W,{className:"inline-block w-2.5 h-2.5 mr-1 align-[-2px]"}),t.prize]})]}),e.jsxs("div",{className:"p-2.5",children:[e.jsxs("div",{className:"mb-1.5 flex items-center gap-2",children:[e.jsx("p",{className:"min-w-0 flex-1 truncate text-[11px] font-bold text-white",children:t.name}),e.jsx(ws,{compact:!0,tournament:t,registration:n,userId:r})]}),e.jsxs("div",{className:"flex items-center justify-between text-[9px] text-white/30 mb-2",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ee,{className:"w-2.5 h-2.5"}),i,"/",t.max_teams||50]}),t.region&&e.jsx("span",{children:t.region})]}),t.start_date&&!["live","completed","cancelled","archived"].includes(t.status)&&e.jsx(Oe,{targetDate:t.start_date,showSeconds:!0,className:"mb-2 rounded-lg border border-red-500/25 bg-red-500/10 px-2 py-1 text-[9px] text-red-400"}),(()=>{const d=t.status==="live"?"#ef4444":p>=90?"#f97316":p>=60?"#eab308":"#8b5cf6",u=t.status==="live"?"rgba(239,68,68,0.95)":p>=90?"rgba(249,115,22,0.9)":p>=60?"rgba(234,179,8,0.85)":"rgba(139,92,246,0.85)",b=t.status==="live"?"0.7s":p>=90?"0.9s":p>=60?"1.3s":"2s",C=`saber-g-${t.id}`;return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`@keyframes ${C}{0%,100%{box-shadow:0 0 6px ${u},0 0 16px ${u};opacity:1}50%{box-shadow:0 0 2px ${u};opacity:0.55}}`}),e.jsx("div",{className:"h-[4px] rounded-full overflow-visible bg-white/[0.06]",children:e.jsx("div",{className:"h-full rounded-full transition-all duration-700",style:{width:`${p}%`,background:`linear-gradient(90deg,${d}88,${d})`,animation:`${C} ${b} ease-in-out infinite`}})})]})})()]})]})}function vi(t,s){const i=t.max_teams||50;return t.status==="live"?s>=i?{label:"Clasificación en progreso",cls:"bg-orange-500/10 text-orange-400 border-orange-500/20",dot:"bg-orange-500 animate-pulse"}:{label:"En transmisión",cls:"bg-red-500/10 text-red-400 border-red-500/20",dot:"bg-red-500 animate-pulse"}:t.status==="completed"?{label:"Finalizado",cls:"bg-slate-700/20 text-slate-400 border-slate-600/20",dot:"bg-slate-500"}:t.status==="draft"?{label:"Esperando inicio",cls:"bg-amber-500/10 text-amber-400 border-amber-500/20",dot:"bg-amber-500"}:s>=i?{label:"Cupos llenos",cls:"bg-orange-500/10 text-orange-400 border-orange-500/20",dot:"bg-orange-500"}:(t.core_status?t.core_status==="REGISTRATION_OPEN":t.status==="registration_open")?{label:"Inscripciones abiertas",cls:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",dot:"bg-emerald-500"}:{label:"Esperando inicio",cls:"bg-cyan-500/10 text-cyan-400 border-cyan-500/20",dot:"bg-cyan-500"}}function Ni({tournaments:t,stats:s,getRegisteredCount:i,onOpen:n}){const r=Ie(),a=D.useMemo(()=>{const o=t.filter(m=>["live","registration_open"].includes(m.status));return o.length?o.find(m=>m.featured)||o.find(m=>m.prize)||o.slice().sort((m,x)=>!m.start_date||!x.start_date?0:new Date(m.start_date)-new Date(x.start_date))[0]:null},[t]);if(!a)return e.jsxs("div",{className:"mb-3 grid max-w-2xl mx-auto grid-cols-2 gap-2 px-4 sm:grid-cols-4",children:[e.jsx(oe,{icon:Ne,label:"En Vivo",value:s.live,tone:"text-red-400 bg-red-500/10"}),e.jsx(oe,{icon:ve,label:"Próximos",value:s.upcoming,tone:"text-cyan-400 bg-cyan-500/10"}),e.jsx(oe,{icon:W,label:"Con Premio",value:s.withPrize,tone:"text-amber-400 bg-amber-500/10"}),e.jsx(oe,{icon:ae,label:"Mis Inscripciones",value:s.myEnrolled,tone:"text-emerald-400 bg-emerald-500/10"})]});const c=le[a.status]||le.preparation;return e.jsxs("div",{className:"mb-4 max-w-2xl mx-auto px-4",children:[e.jsxs(G.button,{type:"button",onClick:()=>n(a),initial:r?!1:{opacity:0,y:10}
129,animate:{opacity:1,y:0},transition:{duration:.4},whileHover:{y:-2},className:"relative isolate w-full overflow-hidden rounded-2xl text-left",style:{background:"rgba(13,15,18,0.92)",border:"1px solid rgba(255,196,0,0.18)",boxShadow:"0 12px 40px rgba(0,0,0,0.55), 0 0 0 1px rgba(255,196,0,0.12)"},children:[e.jsxs("div",{className:"relative h-32",children:[e.jsx("img",{src:a.image_url||ze,alt:a.name,className:"w-full h-full object-cover opacity-55"}),e.jsx("div",{className:"absolute inset-0",style:{background:"linear-gradient(to right, #0D0F12 5%, rgba(13,15,18,0.6) 65%, transparent 100%)"}}),e.jsxs("div",{className:"absolute top-3 left-3 flex items-center gap-1 rounded-full border border-amber-400/30 bg-amber-400/10 px-2 py-1 text-[10px] font-black text-amber-300 backdrop-blur-sm",children:[e.jsx(Be,{className:"h-3 w-3 fill-amber-400 text-amber-400"})," DESTACADO"]}),e.jsxs("div",{className:"absolute top-3 right-3 flex items-center gap-1 rounded-full border bg-black/40 px-2 py-1 text-[9px] font-black backdrop-blur-sm",style:{borderColor:c.border.replace("border-","")},children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${c.dot}`}),e.jsx("span",{className:c.text,children:c.label})]})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col justify-center pl-4 pr-3",children:[e.jsx("p",{className:"text-base font-black text-white line-clamp-1 mb-1 drop-shadow",children:a.name}),e.jsxs("p",{className:"text-[10.5px] text-white/55 line-clamp-1 mb-1.5",children:[a.start_date&&e.jsx(e.Fragment,{children:ds(new Date(a.start_date),"d MMM yyyy · HH:mm",{locale:Qt})}),a.region&&` · ${a.region}`,a.game_mode&&` · ${ot[a.game_mode]||a.game_mode}`]}),a.start_date&&!["live","completed","cancelled","archived"].includes(a.status)&&e.jsx(Oe,{targetDate:a.start_date,showSeconds:!0,className:"mb-1.5 w-fit rounded-lg border border-red-500/30 bg-red-500/15 px-2 py-1 text-[9px] text-red-400"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsxs("span",{className:"rounded-full border border-emerald-500/25 bg-emerald-500/10 px-2 py-0.5 text-[9px] font-bold text-emerald-400",children:[e.jsx(ee,{className:"inline-block h-2.5 w-2.5 align-[-2px] mr-0.5"}),i(a.id),"/",a.max_teams||50]}),a.prize&&e.jsxs("span",{className:"flex items-center gap-0.5 rounded-full border border-amber-500/25 bg-amber-500/10 px-2 py-0.5 text-[9px] font-bold text-amber-400",children:[e.jsx(W,{className:"h-2.5 w-2.5"})," ",a.prize]}),a.entry_fee&&a.entry_fee!=="Gratis"?e.jsx("span",{className:"rounded-full border border-white/[0.08] bg-white/[0.05] px-2 py-0.5 text-[9px] font-bold text-white/60",children:a.entry_fee}):e.jsx("span",{className:"rounded-full border border-cyan-500/25 bg-cyan-500/10 px-2 py-0.5 text-[9px] font-bold text-cyan-400",children:"Gratis"})]})]})]}),e.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 sm:grid-cols-4",children:[e.jsx(oe,{icon:Ne,label:"En Vivo",value:s.live,tone:"text-red-400 bg-red-500/10"}),e.jsx(oe,{icon:ve,label:"Próximos",value:s.upcoming,tone:"text-cyan-400 bg-cyan-500/10"}),e.jsx(oe,{icon:W,label:"Con Premio",value:s.withPrize,tone:"text-amber-400 bg-amber-500/10"}),e.jsx(oe,{icon:ae,label:"Mis Inscripciones",value:s.myEnrolled,tone:"text-emerald-400 bg-emerald-500/10"})]})]})}function oe({icon:t,label:s,value:i,tone:n}){return e.jsxs("div",{className:"flex items-center gap-2 rounded-xl border border-white/[0.06] bg-white/[0.03] px-2.5 py-2 transition-all hover:border-white/[0.12]",children:[e.jsx("span",{className:`flex h-7 w-7 flex-shrink-0 items-center justify-center rounded-lg ${n}`,children:e.jsx(t,{className:"h-3.5 w-3.5",strokeWidth:2.2})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-mono text-base font-bold tabular-nums leading-none text-white",children:i}),e.jsx("p",{className:"mt-0.5 truncate text-[9px] font-medium text-white/40",children:s})]})]})}export{to 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.