1import{ak as p,al as M,aj as R,r as w,o as S,b8 as Y,j as e,c as I,x as $,W as U,v as V,m as _,S as z,ac as G,_ as W,U as K,s as u,b as k}from"./index-CtR2Cm7C.js";import{B as P}from"./badge-BtmlmM6m.js";import{B as L}from"./button-2frSB4pm.js";import{S as J,a as Q,b as X,c as Z,d as h}from"./select-kfyQvVZX.js";import{T as ee,a as te,b as T,c as O}from"./tabs-DufEBa16.js";import{s as se,f as g}from"./format-CAy5MAkn.js";import{i as ae}from"./isSameDay-CHHLB3-O.js";import{C as le}from"./clock-Crn-bV_Q.js";import{M as ne}from"./map-pin-C6nJj4pR.js";import"./index-OxmuvU-r.js";import"./index-BzvZTE6w.js";import"./index-CUbvWtpW.js";import"./index-DokfpFqZ.js";import"./index-C2ucMHlt.js";import"./index-CH-Rzg5J.js";import"./index-B7XdEZiN.js";import"./index-mbc5-_m2.js";import"./chevron-up-CR-LX1he.js";import"./index-p8vE0eDw.js";import"./index-CZF2G8Cx.js";function A(s,n){const l=p(s);if(isNaN(n))return M(s,NaN);if(!n)return l;const r=l.getDate(),a=M(s,l.getTime());a.setMonth(l.getMonth()+n+1,0);const m=a.getDate();return r>=m?a:(l.setFullYear(a.getFullYear(),a.getMonth(),r),l)}function re(s,n){const l=p(s.start),r=p(s.end);let a=+l>+r;const m=a?+l:+r,c=a?r:l;c.setHours(0,0,0,0);let f=1;const j=[];for(;+c<=m;)j.push(p(c)),c.setDate(c.getDate()+f),c.setHours(0,0,0,0);return a?j.reverse():j}function ie(s){const n=p(s);return n.setDate(1),n.setHours(0,0,0,0),n}function oe(s,n){const l=R(),r=n?.weekStartsOn??n?.locale?.options?.weekStartsOn??l.weekStartsOn??l.locale?.options?.weekStartsOn??0,a=p(s),m=a.getDay(),c=(m<r?-7:0)+6-(m-r);return a.setDate(a.getDate()+c),a.setHours(23,59,59,999),a}function ce(s,n){const l=p(s),r=p(n);return l.getFullYear()===r.getFullYear()&&l.getMonth()===r.getMonth()}function de(s,n){return A(s,-1)}function Oe(){const[s,n]=w.useState(new Date),[l,r]=w.useState("month"),[a,m]=w.useState("GLOBAL"),{data:c=[],isLoading:f}=S({queryKey:["calendar-events"],queryFn:()=>k.entities.CalendarEvent.list()}),{data:j=[]}=S({queryKey:["tournaments"],queryFn:()=>k.entities.Tournament.list()}),N={tournament:{icon:_,color:"bg-yellow-500/20 text-yellow-400 border-yellow-500/30",label:"Torneo"},scrim:{icon:G,color:"bg-cyan-500/20 text-cyan-400 border-cyan-500/30",label:"Scrim"},bloque:{icon:z,color:"bg-purple-500/20 text-purple-400 border-purple-500/30",label:"Bloque"},series:{icon:_,color:"bg-pink-500/20 text-pink-400 border-pink-500/30",label:"Serie"}},y=c.filter(t=>a==="GLOBAL"||t.region===a||t.region==="GLOBAL"),C=ie(s),E=Y(s),F=se(C,{locale:u}),B=oe(E,{locale:u}),q=re({start:F,end:B}),H=t=>y.filter(i=>{if(!i.date)return!1;const o=new Date(i.date),d=i.end_date?new Date(i.end_date):null,b=new Date(t.getFullYear(),t.getMonth(),t.getDate()),x=new Date(o.getFullYear(),o.getMonth(),o.getDate()),v=d?new Date(d.getFullYear(),d.getMonth(),d.getDate()):x;return b>=x&&b<=v}),D=y.filter(t=>{if(!t.date)return!1;const i=new Date(t.date),o=new Date;return o.setHours(0,0,0,0),i>=o}).sort((t,i)=>new Date(t.date)-new Date(i.date)).slice(0,10);return f?e.jsx("div",{className:"min-h-screen bg-slate-950 flex items-center justify-center",children:e.jsx(I,{className:"w-8 h-8 text-purple-500 animate-spin"})}):e.jsxs("div",{className:"min-h-screen bg-black",children:[e.jsxs("section",{className:"relative py-12 overflow-hidden border-b border-slate-900",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-b from-slate-950/50 to-black"}),e.jsx("div",{className:"container mx-auto px-4 relative z-10 max-w-6xl",children:e.jsxs($.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},className:"flex flex-col md:flex-row md:items-center md:justify-between gap-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-black text-white mb-2",children:"Calendario"}),e.jsx("p",{className:"text-slate-500 text-sm",children:"Todos los eventos en un solo lugar"})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs(J,{value:a,onValueChange:m,children:[e.jsx(Q,{className:"w-40 bg-slate-950 border-slate-900 text-white hover:bg-slate-900 transition-colors",children:e.jsx(X,{})}),e.jsxs(Z,{className:"bg-slate-950 border-slate-900 text-white",children:[e.jsx(h,{value:"GLOBAL",children:"Todas"}),e.jsx(h,{value:"LATAM",children:"LATAM"}),e.jsx(h,{value:"LATAM_NORTE",children:"LATAM Norte"}),e.jsx(h,{value:"SUR",children:"Sur"}),e.jsx(h,{value:"BRASIL",children:"Brasil"}),e.jsx(h,{value:"NA",children:"NA"}),e.jsx(h,{value:"EU",children:"EU"}),e.jsx(h,{value:"ASIA",children:"Asia"})]})]})})]})})]}),e.jsx("section",{className:"py-8 px-4",children:e.jsxs("div",{className:"container mx-auto max-w-6xl",children:[e.jsxs(ee,{value:l,onValueChange:r,className:"space-y-6",children:[e.jsxs(te,{className:"grid w-40 ml-auto grid-cols-2 bg-slate-950 border border-slate-900",children:[e.jsx(T,{value:"month",className:"text-xs",children:"Mes"}),e.jsx(T,{value:"list",className:"text-xs",children:"Lista"})]}),e.jsx(O,{value:"month",children:e.jsxs("div",{className:"bg-slate-950 border border-slate-900 rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-slate-900",children:[e.jsx(L,{variant:"ghost",size:"icon",onClick:()=>n(de(s)),className:"text-slate-400 hover:text-white hover:bg-slate-900",children:e.jsx(U,{className:"w-5 h-5"})}),e.jsx("h2",{className:"text-lg font-bold text-white capitalize",children:g(s,"MMMM yyyy",{locale:u})}),e.jsx(L,{variant:"ghost",size:"icon",onClick:()=>n(A(s,1)),className:"text-slate-400 hover:text-white hover:bg-slate-900",children:e.jsx(V,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"p-4",children:e.jsxs("div",{className:"grid grid-cols-7 gap-px bg-slate-900",children:[["Dom","Lun","Mar","Mié","Jue","Vie","Sáb"].map(t=>e.jsx("div",{className:"bg-slate-950 text-center text-xs font-semibold text-slate-500 py-3",children:t},t)),q.map((t,i)=>{const o=H(t),d=ce(t,s),b=ae(t,new Date);return e.jsxs("div",{className:`bg-slate-950 min-h-28 p-2 ${d?"":"opacity-40"} ${b?"bg-slate-900":""}`,children:[e.jsx("div",{className:`text-xs font-semibold mb-2 ${b?"text-white bg-purple-600 w-6 h-6 rounded-full flex items-center justify-center":d?"text-slate-400":"text-slate-700"}`,children:g(t,"d")}),e.jsxs("div",{className:"space-y-1",children:[o.slice(0,2).map((x,v)=>(N[x.event_type],e.jsx("div",{className:`text-[10px] px-1.5 py-0.5 rounded cursor-pointer hover:opacity-80 transition-opacity truncate ${x.event_type==="tournament"?"bg-yellow-600/20 text-yellow-400":x.event_type==="scrim"?"bg-cyan-600/20 text-cyan-400":x.event_type==="bloque"?"bg-purple-600/20 text-purple-400":"bg-pink-600/20 text-pink-400"}`,title:x.title,children:x.title},v))),o.length>2&&e.jsxs("div",{className:"text-[10px] text-slate-600",children:["+",o.length-2]})]})]},i)})]})})]})}),e.jsx(O,{value:"list",children:e.jsxs("div",{className:"bg-slate-950 border border-slate-900 rounded-lg overflow-hidden",children:[e.jsx("div",{className:"p-6 border-b border-slate-900",children:e.jsx("h2",{className:"text-lg font-bold text-white",children:"Próximos Eventos"})}),e.jsx("div",{className:"p-4",children:D.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx(W,{className:"w-12 h-12 text-slate-800 mx-auto mb-3"}),e.jsx("p",{className:"text-slate-600 text-sm",children:"No hay eventos próximos"})]}):e.jsx("div",{className:"space-y-px bg-slate-900 rounded-lg overflow-hidden",children:D.map((t,i)=>{const d=N[t.event_type].icon;return e.jsx("div",{className:"p-4 bg-slate-950 hover:bg-slate-900 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:"flex-shrink-0 text-center w-14",children:[e.jsx("div",{className:"text-2xl font-black text-white",children:g(new Date(t.date),"d")}),e.jsx("div",{className:"text-[10px] uppercase text-slate-500 font-semibold",children:g(new Date(t.date),"MMM",{locale:u})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 mb-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"font-bold text-white text-sm mb-1 truncate",children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-500",children:[e.jsx(le,{className:"w-3 h-3"}),g(new Date(t.date),"HH:mm",{locale:u}),t.end_date&&e.jsx("span",{className:"text-slate-700",children:"â"}),t.end_date&&g(new Date(t.end_date),"dd MMM",{locale:u})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(P,{className:`${t.event_type==="tournament"?"bg-yellow-600/20 text-yellow-400 border-yellow-600/30":t.event_type==="scrim"?"bg-cyan-600/20 text-cyan-400 border-cyan-600/30":t.event_type==="bloque"?"bg-purple-600/20 text-purple-400 border-purple-600/30":"bg-pink-600/20 text-pink-400 border-pink-600/30"} text-[10px]`,children:e.jsx(d,{className:"w-3 h-3"})})})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-slate-600",children:[t.region&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ne,{className:"w-3 h-3"}),t.region]}
1),t.max_teams&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(K,{className:"w-3 h-3"}),t.registered_teams,"/",t.max_teams]})]})]})]})},t.id)})})})]})})]}),e.jsx("div",{className:"bg-slate-950 border border-slate-900 rounded-lg p-4 mt-6",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("span",{className:"text-xs text-slate-600 font-semibold",children:"Leyenda:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(N).map(([t,i])=>(i.icon,e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${t==="tournament"?"bg-yellow-600":t==="scrim"?"bg-cyan-600":t==="bloque"?"bg-purple-600":"bg-pink-600"}`}),e.jsx("span",{className:"text-slate-500",children:i.label})]},t)))})]})})]})})]})}export{Oe 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.