1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7566],{27566:function(e,t,a){a.r(t),a.d(t,{default:function(){return b}});var r=a(57437),n=a(2265),l=a(16463),s=a(41579),o=a(59808),i=a(74413),c=a(79669),m=a(74292),u=a(55150),d=a(72771),p=a(15772);let x="America/Toronto";function h(e,t,a){let[r,n,l]=e.split("-").map(Number),s=t.split(/[:.]/),o=Number(s[0]),i=Date.UTC(r,n-1,l,o,Number(s[1]),Number(s[2]||0),Number(s[3]||0)),c=Object.fromEntries(new Intl.DateTimeFormat("en-US",{timeZone:a,year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1}).formatToParts(new Date(i)).map(e=>[e.type,e.value]));return i-(Date.UTC(Number(c.year),Number(c.month)-1,Number(c.day),"24"===c.hour?0:Number(c.hour),Number(c.minute),Number(c.second))-i)}function f(e){let{event:t,selectedDate:a,onClick:n}=e,{t:l}=(0,m.T)(),s=t.gameCount||0,i=t.type?t.type.charAt(0).toUpperCase()+t.type.slice(1):"";return(0,r.jsxs)("button",{type:"button",onClick:n,className:"group relative flex flex-col text-left bg-[#141414] border border-white/15 hover:border-custom-purple rounded-none overflow-hidden transition-[border-color,transform] hover:-translate-y-0.5 focus:outline-none focus:ring-2 focus:ring-custom-purple-light min-h-[112px]",children:[t.logo_url&&(0,r.jsx)("img",{src:t.logo_url,alt:"","aria-hidden":!0,loading:"lazy",className:"absolute inset-0 w-full h-full object-cover opacity-15 pointer-events-none select-none"}),t.rainDelayActive?(0,r.jsx)("div",{className:"relative z-10 w-full bg-sky-600 px-4 py-0.5",children:(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-wide font-bold text-white",children:"In Rain Delay"})}):(0,r.jsx)("div",{className:"relative z-10 h-1.5 w-full bg-custom-purple"}),(0,r.jsxs)("div",{className:"relative z-10 flex-1 min-w-0 px-4 py-3 flex flex-col gap-1",children:[(0,r.jsx)("div",{className:"text-white font-bold text-lg md:text-xl leading-tight line-clamp-2",children:t.name}),(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2 mt-auto",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[t.formattedCity&&(0,r.jsx)("span",{className:"text-xs text-gray-300 truncate",children:t.formattedCity}),i&&(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-wide text-gray-300 border border-white/25 rounded px-1.5 py-0.5 flex-shrink-0",children:i})]}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s>0&&(0,r.jsxs)("span",{className:"text-[10px] uppercase tracking-wide font-bold text-white bg-custom-purple rounded-none px-2 py-0.5 whitespace-nowrap",children:[(0,r.jsx)("span",{className:"tabular-nums",children:s})," ",l("eventsUpcoming.games")]}),(0,r.jsx)("span",{className:"text-xs text-gray-400 group-hover:text-custom-purple-light transition-colors flex items-center",children:(0,r.jsx)(o.Z,{className:"w-3.5 h-3.5"})})]})]})]})]})}function g(e){let{featuredEvents:t,loading:a,selectedDate:n,onEventSelect:l,locale:s}=e,{t:o}=(0,m.T)();if(!a&&0===t.length)return(0,r.jsxs)("div",{className:"flex flex-col items-center justify-center text-center py-16 px-4",children:[(0,r.jsx)("div",{className:"w-12 h-12 rounded-none bg-custom-purple/10 border border-custom-purple/30 flex items-center justify-center mb-3",children:(0,r.jsx)(i.Z,{className:"w-6 h-6 text-custom-purple/70"})}),(0,r.jsx)("p",{className:"text-gray-300 text-sm font-medium",children:o("eventsUpcoming.noEventsScheduled")})]});let c=e=>{if(l)l(e);else{let t=[e,...JSON.parse(localStorage.getItem("searchHistory")||"[]").filter(t=>t.id!==e.id)].slice(0,10);localStorage.setItem("searchHistory",JSON.stringify(t));let a="https://events.slopitchcentral.com/".concat(e.slug),r=n?"".concat(a,"?date=").concat(n):a;window.location.href=r}};return(0,r.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3 transition-opacity duration-200 ".concat(a?"opacity-50":"opacity-100"),children:t.map(e=>(0,r.jsx)(f,{event:e,selectedDate:n,onClick:()=>c(e)},e.id))})}function b(e){let{hideSearchButton:t=!1,onEventSelect:a,initialEvents:o=[],initialDate:i=""}=e,f=(0,l.useRouter)(),b=(0,l.useSearchParams)(),{t:y}=(0,m.T)(),{locale:v}=(0,u.ZK)(),[,w]=(0,n.useTransition)(),N=b.get("tab"),[j,D]=(0,n.use
1State)(N||i),[S,T]=(0,n.useState)(o),[k,C]=(0,n.useState)({}),[I,U]=(0,n.useState)({}),[A,E]=(0,n.useState)(!1);(0,n.useEffect)(()=>{(0,d.A6)(v)},[v]);let Z=(0,n.useMemo)(()=>{let e=[],t="America/Toronto",a=(0,p.cP)(v),[r,n,l]=new Intl.DateTimeFormat("en-CA",{timeZone:t}).format(new Date).split("-").map(Number);for(let s=0;s<14;s++){let o=new Date(Date.UTC(r,n-1,l+s,12,0,0)),i=new Intl.DateTimeFormat("en-CA",{timeZone:t}).format(o),c=new Intl.DateTimeFormat(a,{timeZone:t,weekday:"short"}).format(o),m=new Intl.DateTimeFormat(a,{timeZone:t,month:"short"}).format(o),u=new Intl.DateTimeFormat(a,{timeZone:t,weekday:"long",month:"short",day:"numeric"}).format(o),d=new Intl.DateTimeFormat("en-US",{timeZone:t,day:"numeric"}).format(o);e.push({value:i,label:u,weekdayShort:c,monthShort:m,dayNum:d,isToday:0===s})}return e},[v]),F=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(!F.current)return;let e=F.current.querySelector('[data-active="true"]');e&&"function"==typeof e.scrollIntoView&&e.scrollIntoView({behavior:"smooth",block:"nearest",inline:"center"})},[j]),(0,n.useEffect)(()=>{let e=!1,t=async()=>{let t={},a={};try{for(let r=0;r<Z.length;r+=3){if(e)return;let n=Z.slice(r,r+3),l=await Promise.all(n.map(async e=>{let t=await O(e.value),a=t.reduce((e,t)=>e+(t.gameCount||0),0);return{date:e.value,events:t,gameCount:a}}));if(e)return;if(l.forEach(e=>{let{date:r,events:n,gameCount:l}=e;t[r]=n,a[r]=l}),C(e=>({...e,...t})),U(e=>({...e,...a})),0===r){let e=b.get("tab")||j;e&&t[e]&&(T(t[e]),j!==e&&D(e))}}}catch(e){console.error("Failed to preload events:",e)}};return Z.length>0&&t(),()=>{e=!0}},[Z]),(0,n.useEffect)(()=>{if(0===Z.length)return;let e=b.get("tab");if(e&&Z.some(t=>t.value===e))j!==e&&(D(e),k[e]?T(k[e]):z(e));else if(!e&&Z.length>0&&!j){let e=Z[0].value;D(e),w(()=>{let t=new URLSearchParams(b.toString());t.set("tab",e),f.push("?".concat(t.toString()),{scroll:!1})})}},[Z,b]);let _=e=>{D(e),k[e]?T(k[e]):z(e),w(()=>{let t=new URLSearchParams(b.toString());t.set("tab",e),f.push("?".concat(t.toString()),{scroll:!1})})},O=async e=>{try{let{start:t,end:a}=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:x,a=h(e,"00:00:00.000",t),r=h(e,"23:59:59.999",t);return{start:new Date(a).toISOString(),end:new Date(r).toISOString()}}(e,"America/Toronto"),r=new Date(new Date(t).getTime()-144e5).toISOString(),n=new Date(new Date(a).getTime()+144e5).toISOString(),l=await (0,s.nt)({method:"GET",endpoint:"/games",query:{and:[{startDateTime:{greater_than_equal:r}},{startDateTime:{less_than_equal:n}}]},limit:300,depth:2,sort:"startDateTime",select:{startDateTime:!0,event:!0},populate:{events:{name:!0,slug:!0,type:!0,city:!0,timezone:!0,public:!0,logo:!0,rainDelayActive:!0}}}),o=(null==l?void 0:l.docs)||[],i={};return o.forEach(t=>{let a=t.event;if(!a||"object"!=typeof a||!a.public)return;let r=a.timezone||"America/Toronto";if(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:x;return new Intl.DateTimeFormat("en-CA",{timeZone:t,year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date(e))}(t.startDateTime,r)===e){if(!i[a.id]){var n,l,o;i[a.id]={id:a.id,name:a.name,slug:a.slug,type:a.type,formattedCity:(null===(n=a.city)||void 0===n?void 0:n.formattedName)||(null===(l=a.city)||void 0===l?void 0:l.name)||"",logo_url:"object"==typeof a.logo?(0,s.fq)(null===(o=a.logo)||void 0===o?void 0:o.url):null,rainDelayActive:!!a.rainDelayActive,gameCount:0}}i[a.id].gameCount++}}),Object.values(i)}catch(e){return console.error("Failed to fetch events with games for date:",e),[]}},z=async e=>{if(e){E(!0);try{let t=await O(e);T(t),C(a=>({...a,[e]:t}))}catch(e){console.error("Failed to fetch featured events:",e),T([])}finally{E(!1)}}},P=Z.find(e=>e.value===j),q=I[j]||0;return(0,r.jsx)("section",{className:"bg-gradient-to-b from-[#0d0613] to-[#0a0410] border-t border-b border-white/10",children:(0,r.jsxs)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6 md:py-8",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-4 mb-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.jsx)(c.Z,{className:"w-5 h-5 md:w-6 md:h-6 text-custom-purple flex-shrink-0"}),(0,r.jsx)("h2",{className:"text-lg md:text-xl font-bold text-white truncate",children:y("eventsUpcoming.title")})]}),P&&(0,r.jsxs)("div",{className:"text-xs md:text-sm text-gray-400 flex-shrink-0",children:[(0,r.jsx)("span",{className:"hidden sm:inline",children:P.label}),q>0&&(0,r.jsxs)("span",{className:"ml-2 text-custom-purple font-semibold tabular-nums",children:[q," ",y("eventsUpcoming.games")]})]})]}),(0,r.jsx)("div",{ref:F,className:"flex gap-2 overflow-x-auto pb-3 mb-4 -mx-4 px-4 sm:mx-0 sm:px-0 snap-x snap-mandatory",role:"tablist","aria-label":y("eventsUpcoming.title"),children:Z.map(e=>
1{let t=I[e.value]||0,a=e.value===j;return(0,r.jsxs)("button",{type:"button",role:"tab","aria-selected":a,"data-active":a,onClick:()=>_(e.value),className:"group flex-shrink-0 snap-start flex flex-col items-center justify-center min-w-[72px] px-3 py-2 rounded-none border transition-[border-color,background-color,color] ".concat(a?"bg-custom-purple border-custom-purple text-white shadow-lg shadow-custom-purple/20":"bg-[#141414] border-white/10 text-gray-300 hover:border-custom-purple/50 hover:text-white"),children:[(0,r.jsx)("span",{className:"text-[10px] uppercase tracking-wider font-semibold ".concat(a?"text-white/80":"text-gray-500 group-hover:text-gray-300"),children:e.isToday?y("eventsUpcoming.today"):e.weekdayShort}),(0,r.jsx)("span",{className:"text-lg font-black tabular-nums leading-none mt-0.5",children:e.dayNum}),(0,r.jsx)("span",{className:"text-[10px] mt-0.5 ".concat(a?"text-white/70":"text-gray-500"),children:e.monthShort}),t>0&&(0,r.jsx)("span",{className:"mt-1 text-[10px] font-bold tabular-nums px-1.5 py-0.5 rounded-none ".concat(a?"bg-white/20 text-white":"bg-custom-purple/15 text-custom-purple border border-custom-purple/30"),children:t})]},e.value)})}),(0,r.jsx)("div",{className:"min-h-[260px] sm:min-h-[280px] lg:min-h-[320px]",children:(0,r.jsx)(g,{featuredEvents:S,loading:A,onEventSelect:a,selectedDate:j,locale:v})})]})})}}}]);
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.