import{j as e}from"./vendor-ui-CUslpDkL.js";import{r as u}from"./vendor-react-Dg0Tra3e.js";import{u as M,M as d,C,B as h,E as D,s as p}from"./index-CJqEbhJN.js";import{u as j}from"./vendor-query-CN1EccJz.js";import{S as f,a as g,b as y,c as v,d as o}from"./select-BEyVJtLw.js";import{F as _}from"./filter-B-pqD9on.js";import{D as k}from"./download-1d3a7tmh.js";import{f as n}from"./format-BrSaXzvW.js";import"./vendor-supabase-yzuDJZPy.js";import"./vendor-motion-CiNtJfg1.js";import"./index-CSX6DdY0.js";function O(){const{t}=M(),[c,N]=u.useState("all"),[i,b]=u.useState("all"),{data:m=[],isLoading:w}=j({queryKey:["events",c,i],queryFn:async()=>{const s=new Date;let a=p.from("events").select("*").gte("ends_at_utc",s.toISOString()).order("starts_at_utc",{ascending:!0});c!=="all"&&(a=a.eq("country",c)),i!=="all"&&(a=a.eq("city",i));const{data:l,error:r}=await a;if(r)throw r;return l||[]}}),{data:x={countries:[],cities:[]}}=j({queryKey:["event-locations"],queryFn:async()=>{const{data:s}=await p.from("events").select("country, city").gte("ends_at_utc",new Date().toISOString()),a=[...new Set(s?.map(r=>r.country).filter(Boolean))],l=[...new Set(s?.map(r=>r.city).filter(Boolean))];return{countries:a.sort(),cities:l.sort()}}});return e.jsx("div",{className:"min-h-screen px-4 py-8 md:py-12",children:e.jsxs("div",{className:"mx-auto max-w-6xl",children:[e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx(d,{className:"w-10 h-10 text-accent"}),e.jsx("h1",{className:"text-4xl font-bold",children:t("events.title")})]}),e.jsx("p",{className:"text-muted-foreground text-lg",children:t("events.description")})]}),e.jsxs("div",{className:"mb-8 glass-card p-4",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx(_,{className:"w-5 h-5 text-primary"}),e.jsx("h3",{className:"font-semibold",children:t("events.filterByLocation")})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-muted-foreground mb-2 block",children:t("events.country")}),e.jsxs(f,{value:c,onValueChange:N,children:[e.jsx(g,{className:"bg-background/50 border-white/10",children:e.jsx(y,{placeholder:t("events.allCountries")})}),e.jsxs(v,{className:"bg-card/95 backdrop-blur-sm border-white/10 z-50",children:[e.jsx(o,{value:"all",children:t("events.allCountries")}),x.countries.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-muted-foreground mb-2 block",children:t("events.city")}),e.jsxs(f,{value:i,onValueChange:b,children:[e.jsx(g,{className:"bg-background/50 border-white/10",children:e.jsx(y,{placeholder:t("events.allCities")})}),e.jsxs(v,{className:"bg-card/95 backdrop-blur-sm border-white/10 z-50",children:[e.jsx(o,{value:"all",children:t("events.allCities")}),x.cities.map(s=>e.jsx(o,{value:s,children:s},s))]})]})]})]})]}),e.jsx("div",{className:"space-y-6",children:w?e.jsx("div",{className:"text-center py-12 glass-card",children:e.jsx("div",{className:"animate-pulse text-muted-foreground",children:t("events.loadingEvents")})}):m.length===0?e.jsxs("div",{className:"text-center py-12 glass-card",children:[e.jsx(d,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground mb-2",children:t("events.noEventsFound")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("events.tryDifferentLocation")})]}):m.map(s=>{const a=new Date(s.starts_at_utc),l=new Date(s.ends_at_utc),S=n(a,"yyyy-MM-dd")===n(l,"yyyy-MM-dd")?n(a,"MMM d, yyyy"):`${n(a,"MMM d")} - ${n(l,"MMM d, yyyy")}`;return e.jsx("article",{className:"glass-card-hover overflow-hidden group",children:e.jsxs("div",{className:"grid md:grid-cols-[300px_1fr] gap-6",children:[e.jsxs("div",{className:"relative h-48 md:h-full overflow-hidden",children:[e.jsx("img",{src:s.image_url||"https://images.unsplash.com/photo-1540575467063-178a50c2df87?w=800&h=400&fit=crop",alt:s.title,className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-110"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-card/80 via-card/50 to-transparent"}),s.kind&&e.jsx("span",{className:"absolute top-3 left-3 px-3 py-1 text-xs font-semibold rounded-full bg-accent text-accent-foreground",children:s.kind})]}),e.jsxs("div",{className:"p-6 flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold mb-3 group-hover:text-primary transition-colors",children:s.title}),s.description&&e.jsx("p",{className:"text-muted-foreground mb-4",children:s.description}),e.jsxs("div",{className:"space-y-2 mb-4",children:[e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsx(C,{className:"w-4 h-4 text-primary"}),e.jsx("span",{children:S})]}),s.venue&&e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsx(d,{className:"w-4 h-4 text-secondary"}),e.jsxs("span",{children:[s.venue,s.city&&`, ${s.city}`,s.country&&`, ${s.country}`]})]}),s.organizer&&e.jsxs("div",{className:"text-sm text-muted-foreground",children:[t("events.organizedBy"),": ",e.jsx("span",{className:"text-foreground",children:s.organizer})]})]})]}),e.jsxs("div",{className:"flex gap-3",children:[s.url&&e.jsx("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",children:e.jsxs(h,{className:"rounded-full neon-glow-pink bg-gradient-to-r from-primary to-secondary",children:[e.jsx(D,{className:"w-4 h-4 mr-2"}),t("events.eventDetails")]})}),e.jsxs(h,{variant:"outline",className:"rounded-full glass-card border-primary/30",children:[e.jsx(k,{className:"w-4 h-4 mr-2"}),t("events.addToCalendar")]})]})]})]})},s.id)})})]})})}export{O as default};