PageSourceSearch

https://v0-results-receipts-b4.vercel.app/_next/static/chunks/app/…?dpl=dpl_DAj8ZMc6BNTssYQRf5zXcF2KjVod

js v0-results-receipts-b4.vercel.app collected 2026-10-03 07:58:27 UTC 91,868 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{1538:function(e,t,s){Promise.resolve().then(s.bind(s,4610))},4610:function(e,t,s){"use strict";s.r(t),s.d(t,{default:function(){return e$}});var a=s(7437),r=s(2265),i=s(4533),n=s(4118),l=s(3145),c=s(7625),o=s(3247),d=s(740),m=s(1047),u=s(2869),h=s(5186),x=s(4438),p=s(9270),f=s(401),g=s(4508);let b=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(p.fC,{ref:t,className:(0,g.cn)("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",s),...r,children:(0,a.jsx)(p.z$,{className:(0,g.cn)("flex items-center justify-center text-current"),children:(0,a.jsx)(f.Z,{className:"h-4 w-4"})})})});b.displayName=p.fC.displayName;var j=s(6394),v=s(535);let y=(0,v.j)("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),N=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(j.f,{ref:t,className:(0,g.cn)(y(),s),...r})});N.displayName=j.f.displayName;var w=s(7312);let S=w.fC,k=w.xz,C=r.forwardRef((e,t)=>{let{className:s,align:r="center",sideOffset:i=4,...n}=e;return(0,a.jsx)(w.h_,{children:(0,a.jsx)(w.VY,{ref:t,align:r,sideOffset:i,className:(0,g.cn)("z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s),...n})})});function _(e){let{onSelectRace:t,inDialog:s=!1}=e,[n,l]=(0,r.useState)(""),[p,f]=(0,r.useState)(!1),[g,j]=(0,r.useState)([]),[v,y]=(0,r.useState)(""),{setRaceTheme:w,isLoading:_}=(0,i.Y)(),[R,I]=(0,r.useState)(!1),[E,P]=(0,r.useState)(!1),T=async e=>{if(e.preventDefault(),n.trim()){f(!0),j([]),y(""),s||await w(null);try{let e=new Date,t=new Date(e);t.setFullYear(e.getFullYear()-1);let s=new Date(e);s.setDate(e.getDate()+60);let a=e=>e.toISOString().split("T")[0],r=a(t),i=a(s),l=new AbortController,c=setTimeout(()=>l.abort(),1e4),o="/api/search-races";E&&/^\d+$/.test(n.trim())?o+="?race_id=".concat(n.trim()):o+="?term=".concat(encodeURIComponent(n),"&start_date=").concat(r,"&end_date=").concat(i,"&include_without_results=").concat(R);let d=await fetch(o,{signal:l.signal});if(clearTimeout(c),!d.ok)throw Error("API returned status ".concat(d.status));let m=await d.json();m.races&&Array.isArray(m.races)?(j(m.races),0===m.races.length&&y("No races found matching your search criteria")):y("Invalid response from API")}catch(e){y("AbortError"===e.name?"Search timed out. Please try again.":"Error searching for races. Please try again."),console.error(e)}finally{f(!1)}}},D=async e=>{if(!s){let t=e.race_id,s=e.name||e.race&&e.race.name;if(t)try{await w(t,s)}catch(e){console.error("Error setting race theme:",e),x.Am.error("Could not load race theme, using default instead")}}t(e)},z=e=>"string"==typeof e?e:e.toISOString().split("T")[0];return(0,a.jsx)("div",{className:"min-h-screen bg-gray-50 py-8",children:(0,a.jsxs)("div",{className:"max-w-4xl mx-auto px-4",children:[(0,a.jsxs)("div",{className:"text-center mb-8",children:[(0,a.jsx)("div",{className:"flex justify-center mb-4",children:(0,a.jsx)(c.Z,{className:"h-16 w-16 text-gray-900"})}),(0,a.jsx)("h1",{className:"text-4xl font-bold text-gray-900 mb-2",children:"Race Results Search"}),(0,a.jsx)("div",{className:"w-24 h-1 bg-green-500 mx-auto mb-4"})]}),(0,a.jsxs)("div",{className:"max-w-2xl mx-auto mb-8",children:[(0,a.jsxs)("form",{onSubmit:T,className:"flex gap-3",children:[(0,a.jsxs)("div",{className:"flex-1 relative",children:[(0,a.jsx)(o.Z,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-5 w-5 text-gray-400"}),(0,a.jsx)(h.I,{type:"text",placeholder:E?"Enter race ID (e.g., 163949)":"Search for races (e.g., Miles for Files)",value:n,onChange:e=>l(e.target.value),className:"pl-10 h-12 text-lg border-gray-300 focus:border-green-500 focus:ring-green-500"})]}),(0,a.jsxs)(S,{children:[(0,a.jsx)(k,{asChild:!0,children:(0,a.jsxs)(u.z,{variant:"outline",size:"icon",type:"button",className:"h-12 w-12 border-gray-300",children:[(0,a.jsx)(d.Z,{className:"h-5 w-5"}),(0,a.jsx)("span",{className:"sr-only",children:"Filter options"})]})}),(0,a.jsx)(C,{className:"w-80",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("h4",{className:"font-medium",children:"Search Options"}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(b,{id:"include-without-results",checked:R,onCheckedChange:e=>I(!0===e)}),(0,a.jsx)(N,{htmlFor:"include-without-results",children:"Include races without results"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(b,{id:"search-by-race-id",checked:E,onCheckedChange:e=>P(!0===e)}),(0,a.jsx)(N,{htmlFor:"search-by-race-id",children:"Search by race ID"})]})]})})]}),(0,a.jsx)(u.z,{type:"submit",disabled:p,className:"h-12 px-8 bg-green-600 hover:bg-green-700 text-white font-medium",children:p?(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Searching..."]}):"Search"})]}),(0,a.jsx)("div",{className:"text-sm text-gray-500 mt-3 text-center",children:E&&"Enter a race ID to find a specific race"})]}),v&&(0,a.jsx)("div",{className:"max-w-2xl mx-auto mb-6",children:(0,a.jsx)("div",{className:"bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-md",children:v})}),_&&!s&&(0,a.jsx)("div",{className:"max-w-2xl mx-auto mb-6",children:(0,a.jsxs)("div",{className:"bg-blue-50 border border-blue-200 text-blue-700 px-4 py-3 rounded-md flex items-center gap-2",children:[(0,a.jsx)("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),(0,a.jsx)("span",{children:"Loading race theme..."})]})}),g.length>0&&(0,a.jsxs)("div",{className:"max-w-4xl mx-auto",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-6",children:[(0,a.jsxs)("h2",{className:"text-2xl font-bold text-gray-900",children:["Found ",g.length," race",1!==g.length?"s":""]}),(0,a.jsx)(u.z,{variant:"outline",onClick:()=>{j([]),l(""),y("")},className:"border-gray-300 text-gray-700 hover:bg-gray-50",children:"New Search"})]}),(0,a.jsx)("div",{className:"space-y-4",children:g.map(e=>{var t,s;let r=e.race||e;return(0,a.jsx)("div",{className:"bg-white border border-gray-200 rounded-lg p-6 hover:shadow-md transition-shadow",children:(0,a.jsxs)("div",{className:"flex justify-between items-start",children:[(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("h3",{className:"text-xl font-semibold text-gray-900 mb-2",children:r.name}),(0,a.jsxs)("div",{className:"flex items-center text-gray-600 mb-1",children:[(0,a.jsx)(m.Z,{className:"h-4 w-4 mr-2"}),(0,a.jsxs)("span",{children:["Next: ",z(r.next_date||r.last_date)]})]}),(0,a.jsxs)("div",{className:"flex items-center text-gray-600 mb-3",children:[(0,a.jsx)("div",{className:"h-4 w-4 mr-2 flex items-center justify-center",children:(0,a.jsx)("div",{className:"h-2 w-2 bg-gray-400 rounded-full"})}),(0,a.jsx)("span",{children:(null===(t=r.address)||void 0===t?void 0:t.city)&&(null===(s=r.address)||void 0===s?void 0:s.state)?"".concat(r.address.city,", ").concat(r.address.state):"Location not specified"})]}),(0,a.jsxs)("div",{className:"text-sm text-gray-500",children:["Race ID: ",r.race_id]})]}),(0,a.jsx)(u.z,{onClick:()=>D(r),className:"bg-green-600 hover:bg-green-700 text-white px-6 py-2 ml-6",children:"View Results"})]})},r.race_id)})})]})]})})}C.displayName=w.VY.displayName;var R=s(6070),I=s(2660),E=s(3581),P=s(1817),T=s(7168),D=s(1723),z=s(5954),A=s(9027),Z=s(2489);let L=A.fC,q=A.xz,M=A.h_,$=A.x8,F=r.forwardRef((e,t)=>
1{let{className:s,...r}=e;return(0,a.jsx)(A.aV,{ref:t,className:(0,g.cn)("fixed inset-0 z-50 bg-black/80  data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...r})});F.displayName=A.aV.displayName;let B=r.forwardRef((e,t)=>{let{className:s,children:r,...i}=e;return(0,a.jsxs)(M,{children:[(0,a.jsx)(F,{}),(0,a.jsxs)(A.VY,{ref:t,className:(0,g.cn)("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...i,children:[r,(0,a.jsxs)(A.x8,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[(0,a.jsx)(Z.Z,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"sr-only",children:"Close"})]})]})]})});B.displayName=A.VY.displayName;let O=e=>{let{className:t,...s}=e;return(0,a.jsx)("div",{className:(0,g.cn)("flex flex-col space-y-1.5 text-center sm:text-left",t),...s})};O.displayName="DialogHeader";let U=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(A.Dx,{ref:t,className:(0,g.cn)("text-lg font-semibold leading-none tracking-tight",s),...r})});U.displayName=A.Dx.displayName,r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(A.dk,{ref:t,className:(0,g.cn)("text-sm text-muted-foreground",s),...r})}).displayName=A.dk.displayName;var W=s(8728),Y=s(91),V=s(9076),G=s(7689),Q=s(8930),H=s(3327),J=s(5368),X=s(2364),K=s(2325),ee=s(519);let et=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(K.fC,{className:(0,g.cn)("grid gap-2",s),...r,ref:t})});et.displayName=K.fC.displayName;let es=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(K.ck,{ref:t,className:(0,g.cn)("aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",s),...r,children:(0,a.jsx)(K.z$,{className:"flex items-center justify-center",children:(0,a.jsx)(ee.Z,{className:"h-2.5 w-2.5 fill-current text-current"})})})});es.displayName=K.ck.displayName;var ea=s(271);let er=ea.fC,ei=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(ea.aV,{ref:t,className:(0,g.cn)("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",s),...r})});ei.displayName=ea.aV.displayName;let en=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(ea.xz,{ref:t,className:(0,g.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",s),...r})});en.displayName=ea.xz.displayName;let el=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(ea.VY,{ref:t,className:(0,g.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",s),...r})});el.displayName=ea.VY.displayName;var ec=s(721);let eo=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(ec.fC,{className:(0,g.cn)("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",s
1),...r,ref:t,children:(0,a.jsx)(ec.bU,{className:(0,g.cn)("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})})});eo.displayName=ec.fC.displayName;var ed=s(3911),em=s(875),eu=s(2135);let eh=ed.fC;ed.ZA;let ex=ed.B4,ep=r.forwardRef((e,t)=>{let{className:s,children:r,...i}=e;return(0,a.jsxs)(ed.xz,{ref:t,className:(0,g.cn)("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...i,children:[r,(0,a.jsx)(ed.JO,{asChild:!0,children:(0,a.jsx)(em.Z,{className:"h-4 w-4 opacity-50"})})]})});ep.displayName=ed.xz.displayName;let ef=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(ed.u_,{ref:t,className:(0,g.cn)("flex cursor-default items-center justify-center py-1",s),...r,children:(0,a.jsx)(eu.Z,{className:"h-4 w-4"})})});ef.displayName=ed.u_.displayName;let eg=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(ed.$G,{ref:t,className:(0,g.cn)("flex cursor-default items-center justify-center py-1",s),...r,children:(0,a.jsx)(em.Z,{className:"h-4 w-4"})})});eg.displayName=ed.$G.displayName;let eb=r.forwardRef((e,t)=>{let{className:s,children:r,position:i="popper",...n}=e;return(0,a.jsx)(ed.h_,{children:(0,a.jsxs)(ed.VY,{ref:t,className:(0,g.cn)("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2","popper"===i&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:i,...n,children:[(0,a.jsx)(ef,{}),(0,a.jsx)(ed.l_,{className:(0,g.cn)("p-1","popper"===i&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),(0,a.jsx)(eg,{})]})})});eb.displayName=ed.VY.displayName,r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(ed.__,{ref:t,className:(0,g.cn)("py-1.5 pl-8 pr-2 text-sm font-semibold",s),...r})}).displayName=ed.__.displayName;let ej=r.forwardRef((e,t)=>{let{className:s,children:r,...i}=e;return(0,a.jsxs)(ed.ck,{ref:t,className:(0,g.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...i,children:[(0,a.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,a.jsx)(ed.wU,{children:(0,a.jsx)(f.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(ed.eT,{children:r})]})});ej.displayName=ed.ck.displayName,r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)(ed.Z0,{ref:t,className:(0,g.cn)("-mx-1 my-1 h-px bg-muted",s),...r})}).displayName=ed.Z0.displayName;var ev=s(5156);let ey=r.forwardRef((e,t)=>{let{className:s,orientation:r="horizontal",decorative:i=!0,...n}=e;return(0,a.jsx)(ev.f,{ref:t,decorative:i,orientation:r,className:(0,g.cn)("shrink-0 bg-border","horizontal"===r?"h-[1px] w-full":"h-full w-[1px]",s),...n})});ey.displayName=ev.f.displayName;let eN=(0,v.j)("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function ew(e){let{className:t,variant:s,...r}=e;return(0,a.jsx)("div",{className:(0,g.cn)(eN({variant:s}),t),...r})}var eS=s(6424);function ek(e){let{onRaceSelect:t,onBack:s,hasChipTimes:x=!0}=e,[p,f]=(0,r.useState)(!1),{currentRaceId:g,timePreference:b,setTimePreference:j,roundingEnabled:v,setRoundingEnabled:y,customMessage:w,setCustomMessage:S,certificateTimeout:k,setCertificateTimeout:C,timerLogoUrl:R,setTimerLogoUrl:I,timerMessage:P,setTimerMessage:z,backgroundColorPreference:A,setBackgroun
1dColorPreference:M,customBackgroundColor:$,setCustomBackgroundColor:F,primaryColorPreference:K,setPrimaryColorPreference:ee,customPrimaryColor:ea,setCustomPrimaryColor:ec,hideSplitTimes:ed,setHideSplitTimes:em,hidePlaces:eu,setHidePlaces:ef,isUsingCachedSettings:eg,resetRaceSettings:ev,clearAllCachedSettings:eN,getCachedRaces:ek}=(0,n.r)(),{primaryColor:eC,backgroundColor:e_,raceName:eR}=(0,i.Y)(),[eI,eE]=(0,r.useState)("preferences"),eP=(0,r.useRef)(null),eT=()=>{f(!1)},eD=()=>{confirm("Reset all settings for this race to defaults? This cannot be undone.")&&ev()},ez=()=>{if(eC.startsWith("#")){let e=Number.parseInt(eC.slice(1,3),16),t=Number.parseInt(eC.slice(3,5),16),s=Number.parseInt(eC.slice(5,7),16);return"#".concat(Math.min(255,e+150).toString(16).padStart(2,"0")).concat(Math.min(255,t+150).toString(16).padStart(2,"0")).concat(Math.min(255,s+150).toString(16).padStart(2,"0"))}return eC.startsWith("rgba")?eC.replace(/rgba$$(.+?),\s*[\d.]+$$/,"rgba($1, 0.15)"):eC.startsWith("rgb")?eC.replace(/rgb$$(.+?)$$/,"rgba($1, 0.15)"):"#f5f5f5"},eA=()=>{if(eC.startsWith("#")){let e=Number.parseInt(eC.slice(1,3),16),t=Number.parseInt(eC.slice(3,5),16),s=Number.parseInt(eC.slice(5,7),16);return"#".concat(Math.max(0,e-50).toString(16).padStart(2,"0")).concat(Math.max(0,t-50).toString(16).padStart(2,"0")).concat(Math.max(0,s-50).toString(16).padStart(2,"0"))}return eC.startsWith("rgba")?eC.replace(/rgba$$(.+?),\s*[\d.]+$$/,"rgba($1, 1)"):eC.startsWith("rgb")?eC.replace(/rgb$$(.+?)$$/,"rgba($1, 1)"):"#000000"},eZ=()=>{switch(A){case"default":default:return e_||"#ffffff";case"lighter":return ez();case"white":return"#ffffff";case"custom":return $}},eL=()=>{switch(K){case"default":default:return eC||"#f54a87";case"darker":return eA();case"black":return"#000000";case"custom":return ea}},eq=e=>{F(e.target.value),M("custom")},eM=e=>{ec(e.target.value),ee("custom")},e$=ek();return(0,a.jsxs)(L,{open:p,onOpenChange:f,children:[(0,a.jsx)(q,{asChild:!0,children:(0,a.jsxs)(u.z,{variant:"ghost",size:"icon",title:"Settings",className:"h-8 w-8 relative",children:[(0,a.jsx)(W.Z,{className:"h-4 w-4"}),eg&&(0,a.jsx)("div",{className:"absolute -top-1 -right-1 w-2 h-2 bg-green-500 rounded-full"}),(0,a.jsx)("span",{className:"sr-only",children:"Settings"})]})}),(0,a.jsxs)(B,{className:"sm:max-w-[600px] max-h-[80vh] overflow-y-auto",children:[(0,a.jsx)(O,{children:(0,a.jsxs)(U,{className:"flex items-center gap-2",children:["Settings",eg&&(0,a.jsx)(ew,{variant:"secondary",className:"text-xs",children:"Using Cached Settings"})]})}),(0,a.jsxs)(er,{defaultValue:"preferences",value:eI,onValueChange:eE,className:"mt-4",children:[(0,a.jsxs)(ei,{className:"grid grid-cols-4",children:[(0,a.jsx)(en,{value:"race",children:"Change Race"}),(0,a.jsx)(en,{value:"preferences",children:"Preferences"}),(0,a.jsx)(en,{value:"cache",children:"Cache"}),(0,a.jsx)(en,{value:"documentation",children:"Help"})]}),(0,a.jsx)(el,{value:"race",className:"mt-4",children:(0,a.jsx)(_,{onSelectRace:e=>{t(e),f(!1)},inDialog:!0})}),(0,a.jsxs)(el,{value:"preferences",className:"mt-4 space-y-6",children:[g&&(0,a.jsxs)("div",{className:"bg-muted p-3 rounded-md",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(Y.Z,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"text-sm font-medium",children:eg?"Using cached settings":"Using default settings"})]}),eg&&(0,a.jsxs)(u.z,{variant:"outline",size:"sm",onClick:eD,children:[(0,a.jsx)(V.Z,{className:"h-3 w-3 mr-1"}),"Reset"]})]}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground mt-1",children:["Settings are automatically saved for race ID: ",g,eR&&" (".concat(eR,")")]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-lg font-medium mb-4",children:"Receipt Settings"}),(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-medium mb-2",children:"Time Display"}),x?(0,a.jsxs)(et,{value:b,onValueChange:e=>j(e),className:"flex flex-col space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(es,{value:"chip",id:"chip-time"}),(0,a.jsx)(N,{htmlFor:"chip-time",children:"Chip Time"})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(es,{value:"clock",id:"clock-time"}),(0,a.jsx)(N,{htmlFor:"clock-time",children:"Clock Time"})]})]}):(0,a.jsx)("div",{className:"text-sm text-muted-foreground bg-muted p-3 rounded-md",children:"This race only has Clock Time available. Chip Time option is disabled."})]}),(0,a.jsx)("div",{children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)(N,{htmlFor:"rounding-toggle",children:"Rounding"}
1),(0,a.jsx)(eo,{id:"rounding-toggle",checked:v,onCheckedChange:y})]})}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)(N,{htmlFor:"hide-places-toggle",children:"Hide Places"}),(0,a.jsx)(eo,{id:"hide-places-toggle",checked:eu,onCheckedChange:ef})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"When enabled, place information (overall, gender, division) will not be shown on the receipt."})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)(N,{htmlFor:"hide-splits-toggle",children:"Hide Split Times"}),(0,a.jsx)(eo,{id:"hide-splits-toggle",checked:ed,onCheckedChange:em})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"When enabled, split times will not be shown on the receipt."})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(N,{htmlFor:"custom-message",className:"text-sm font-medium block mb-2",children:"Custom Message (appears below race name)"}),(0,a.jsx)(h.I,{id:"custom-message",placeholder:"Enter a message to display on the receipt",value:w,onChange:e=>S(e.target.value)}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"This message will appear below the race name at the top of the receipt."})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(N,{htmlFor:"certificate-timeout",className:"text-sm font-medium block mb-2",children:"Timeout (seconds)"}),(0,a.jsx)(h.I,{id:"certificate-timeout",type:"number",min:10,max:180,value:k,onChange:e=>{let t=Number.parseInt(e.target.value,10);isNaN(t)||C(Math.min(Math.max(t,10),180))}}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Receipt will automatically close after this many seconds (10-180)"})]}),(0,a.jsxs)("div",{className:"border-t pt-4",children:[(0,a.jsx)("h4",{className:"text-sm font-medium mb-2",children:"Receipt Colors"}),(0,a.jsxs)("div",{className:"space-y-4 mb-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)(N,{htmlFor:"background-color",children:"Backgroun
1d Color"}),(0,a.jsx)("div",{className:"w-6 h-6 rounded-md border",style:{backgroundColor:eZ()}})]}),(0,a.jsxs)(eh,{value:A,onValueChange:e=>M(e),children:[(0,a.jsx)(ep,{id:"background-color",className:"w-full",children:(0,a.jsx)(ex,{placeholder:"Select background color"})}),(0,a.jsxs)(eb,{children:[(0,a.jsxs)(ej,{value:"default",children:["Default (",e_,")"]}),(0,a.jsxs)(ej,{value:"lighter",children:["Lighter Primary (",ez(),")"]}),(0,a.jsx)(ej,{value:"white",children:"White (#ffffff)"}),(0,a.jsx)(ej,{value:"custom",children:"Custom"})]})]}),"custom"===A&&(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("input",{type:"color",value:$,onChange:eq,className:"w-10 h-10 p-1 rounded-md border"}),(0,a.jsx)(h.I,{type:"text",value:$,onChange:eq,placeholder:"#ffffff",className:"flex-1"})]})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)(N,{htmlFor:"primary-color",children:"Name/Time/Header Color"}),(0,a.jsx)("div",{className:"w-6 h-6 rounded-md border",style:{backgroundColor:eL()}})]}),(0,a.jsxs)(eh,{value:K,onValueChange:e=>ee(e),children:[(0,a.jsx)(ep,{id:"primary-color",className:"w-full",children:(0,a.jsx)(ex,{placeholder:"Select primary color"})}),(0,a.jsxs)(eb,{children:[(0,a.jsxs)(ej,{value:"default",children:["Default (",eC,")"]}),(0,a.jsxs)(ej,{value:"darker",children:["Darker (",eA(),")"]}),(0,a.jsx)(ej,{value:"black",children:"Black (#000000)"}),(0,a.jsx)(ej,{value:"custom",children:"Custom"})]})]}),"custom"===K&&(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)("input",{type:"color",value:ea,onChange:eM,className:"w-10 h-10 p-1 rounded-md border"}),(0,a.jsx)(h.I,{type:"text",value:ea,onChange:eM,placeholder:"#f54a87",className:"flex-1"})]})]}),(0,a.jsx)("div",{className:"mt-4 p-4 rounded-md border",style:{backgroundColor:eZ()},children:(0,a.jsxs)("div",{className:"text-center",style:{color:eL()},children:[(0,a.jsx)("p",{className:"font-bold",children:"Color Preview"}),(0,a.jsx)("p",{className:"text-sm",children:"This is how your text will look"})]})})]}),(0,a.jsxs)("div",{className:"border-t pt-4",children:[(0,a.jsx)(N,{htmlFor:"timer-message",className:"text-sm font-medium block mb-2",children:"Footer Text (appears at bottom of receipt)"}),(0,a.jsx)(h.I,{id:"timer-message",placeholder:"Enter a message to display at the bottom of the receipt",value:P,onChange:e=>z(e.target.value)}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"This message will appear at the bottom of the receipt, above the footer image if provided."}),(0,a.jsx)("div",{className:"space-y-4",children:(0,a.jsxs)("div",{children:[(0,a.jsx)(N,{htmlFor:"timer-logo",className:"text-sm font-medium block mb-2",children:"Footer Image"}),R?(0,a.jsxs)("div",{className:"mb-2 relative",children:[(0,a.jsx)("div",{className:"border rounded-md p-2 flex justify-center",children:(0,a.jsx)(l.default,{src:R||"/placeholder.svg",alt:"Footer Image",width:200,height:80,className:"h-20 w-auto object-contain"})}),(0,a.jsxs)(u.z,{variant:"outline",size:"icon",className:"absolute top-2 right-2 h-6 w-6 bg-white",onClick:()=>{I(null),eP.current&&(eP.current.value="")},children:[(0,a.jsx)(Z.Z,{className:"h-3 w-3"}),(0,a.jsx)("span",{className:"sr-only",children:"Remove image"})]})]}):(0,a.jsx)("div",{className:"flex items-center justify-center border border-dashed rounded-md p-4 mb-2",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)(G.Z,{className:"mx-auto h-8 w-8 text-muted-foreground"}),(0,a.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:"Upload a footer image"})]})}),(0,a.jsx)("input",{ref:eP,id:"timer-logo",type:"file",accept:"image/*",className:"hidden",onChange:e=>{var t;let s=null===(t=e.target.files)||void 0===t?void 0:t[0];if(s){let e=new FileReader;e.onload=e=>{var t;(null===(t=e.target)||void 0===t?void 0:t.result)&&I(e.target.result)},e.readAsDataURL(s)}}}),(0,a.jsx)(u.z,{variant:"outline",onClick:()=>{var e;return null===(e=eP.current)||void 0===e?void 0:e.click()},className:"w-full",children:R?"Change Image":"Upload Image"})]})})]})]})]}
1),(0,a.jsx)("div",{className:"pt-4 border-t mt-6",children:(0,a.jsxs)(u.z,{variant:"default",onClick:eT,className:"w-full flex items-center justify-center gap-2",children:[(0,a.jsx)(Z.Z,{className:"h-4 w-4"}),"Close"]})})]}),(0,a.jsxs)(el,{value:"cache",className:"mt-4 space-y-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("h3",{className:"text-lg font-medium mb-4 flex items-center gap-2",children:[(0,a.jsx)(Y.Z,{className:"h-5 w-5"}),"Settings Cache Management"]}),g&&(0,a.jsxs)("div",{className:"bg-muted p-4 rounded-md mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("h4",{className:"font-medium",children:"Current Race Settings"}),(0,a.jsx)(ew,{variant:eg?"default":"secondary",children:eg?"Cached":"Default"})]}),(0,a.jsxs)("p",{className:"text-sm text-muted-foreground mb-3",children:["Race ID: ",g,eR&&" (".concat(eR,")")]}),eg&&(0,a.jsxs)(u.z,{variant:"outline",size:"sm",onClick:eD,children:[(0,a.jsx)(V.Z,{className:"h-3 w-3 mr-1"}),"Reset to Defaults"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("h4",{className:"font-medium mb-3",children:["Recently Used Races (",e$.length,")"]}),e$.length>0?(0,a.jsx)("div",{className:"space-y-2 max-h-60 overflow-y-auto",children:e$.map(e=>(0,a.jsxs)("div",{className:"flex items-center justify-between p-3 border rounded-md",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-sm",children:e.raceName}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:["ID: ",e.raceId," • Last used: ",(0,eS.WU)(new Date(e.lastUsed),"MMM d, h:mm a")]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(D.Z,{className:"h-3 w-3 text-muted-foreground"}),(0,a.jsx)("span",{className:"text-xs text-muted-foreground",children:(0,eS.WU)(new Date(e.lastUsed),"MMM d")})]})]},e.raceId))}):(0,a.jsxs)("div",{className:"text-center py-8 text-muted-foreground",children:[(0,a.jsx)(Y.Z,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),(0,a.jsx)("p",{children:"No cached race settings found"}),(0,a.jsx)("p",{className:"text-xs mt-1",children:"Settings will be cached automatically when you customize races"})]})]}),(0,a.jsxs)("div",{className:"border-t pt-4",children:[(0,a.jsx)("h4",{className:"font-medium mb-3",children:"Cache Management"}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-3 border rounded-md",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"font-medium text-sm",children:"Clear All Cached Settings"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Remove all saved settings for all races (cannot be undone)"})]}),(0,a.jsxs)(u.z,{variant:"destructive",size:"sm",onClick:()=>{confirm("Clear all cached settings for all races? This cannot be undone.")&&eN()},disabled:0===e$.length,children:[(0,a.jsx)(Q.Z,{className:"h-3 w-3 mr-1"}),"Clear All"]})]}),(0,a.jsxs)("div",{className:"bg-muted p-3 rounded-md",children:[(0,a.jsx)("h5",{className:"font-medium text-sm mb-2",children:"How Settings Cache Works"}),(0,a.jsxs)("ul",{className:"text-xs text-muted-foreground space-y-1",children:[(0,a.jsx)("li",{children:"• Settings are automatically saved per race when you make changes"}),(0,a.jsx)("li",{children:"• Cached settings expire after 90 days of inactivity"}),(0,a.jsx)("li",{children:"• Only the 20 most recently used races are kept"}),(0,a.jsx)("li",{children:"• Settings include colors, messages, logos, and display preferences"}),(0,a.jsx)("li",{children:"• Cache is stored locally in your browser"})]})]})]})]})]}),(0,a.jsx)("div",{className:"pt-4 border-t mt-6",children:(0,a.jsxs)(u.z,{variant:"default",onClick:eT,className:"w-full flex items-center justify-center gap-2",children:[(0,a.jsx)(Z.Z,{className:"h-4 w-4"}),"Close"]})})]}),(0,a.jsxs)(el,{value:"documentation",className:"mt-4 space-y-6",children:[(0,a.jsxs)("div",{className:"prose max-w-none text-sm",children:[(0,a.jsxs)("h2",{className:"text-2xl font-bold mb-4 flex items-center gap-2",children:[(0,a.jsx)(H.Z,{className:"h-6 w-6"}),"RunSignup Race Results Viewer"]}),(0,a.jsx)("p",{className:"text-muted-foreground mb-4",children:"This application allows you to search for races on RunSignup, view race details, and generate customized receipts for race participants."}),(0,a.jsx)(ey,{className:"my-4"}),(0,a.jsxs)("section",{className:"mb-6",children:[(0,a.jsxs)("h3",{className:"text-xl font-semibold mb-2 flex items-center gap-2",children:[(0,a.jsx)(J.Z,{className:"h-5 w-5"}),"Getting Started"]}
1),(0,a.jsx)("h4",{className:"font-medium mt-3 mb-1",children:"System Requirements"}),(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"A modern web browser (Chrome, Firefox, Safari, or Edge)"}),(0,a.jsx)("li",{children:"Internet connection to access RunSignup's API"}),(0,a.jsx)("li",{children:"Device with sufficient screen space (desktop, laptop, or tablet recommended)"})]}),(0,a.jsx)("h4",{className:"font-medium mt-3 mb-1",children:"Accessing the Application"}),(0,a.jsxs)("ol",{className:"list-decimal pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"Open your web browser and navigate to the application URL"}),(0,a.jsx)("li",{children:"The application will load with the race search screen as the default view"}),(0,a.jsx)("li",{children:"No login is required as the application uses RunSignup's public API"})]})]}),(0,a.jsxs)("section",{className:"mb-6",children:[(0,a.jsxs)("h3",{className:"text-xl font-semibold mb-2 flex items-center gap-2",children:[(0,a.jsx)(o.Z,{className:"h-5 w-5"}),"Searching for Races"]}),(0,a.jsxs)("ol",{className:"list-decimal pl-6 space-y-1",children:[(0,a.jsx)("li",{children:'On the main screen, enter a race name in the search box (e.g., "Boston Marathon", "Turkey Trot")'}),(0,a.jsx)("li",{children:'Click the "Search" button or press Enter'}),(0,a.jsx)("li",{children:"The application will display a list of matching races from RunSignup"}),(0,a.jsx)("li",{children:"By default, only races with results available are shown"})]}),(0,a.jsx)("h4",{className:"font-medium mt-3 mb-1",children:"Advanced Search Options"}),(0,a.jsxs)("div",{className:"pl-6",children:[(0,a.jsxs)("p",{children:["Click the filter icon ",(0,a.jsx)(d.Z,{className:"h-4 w-4 inline"})," next to the search box to access additional options:"]}),(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"Include races without results: Shows all races, even those without published results"}),(0,a.jsx)("li",{children:"Search by race ID: Allows direct access to a race using its RunSignup ID number"})]})]})]}),(0,a.jsxs)("section",{className:"mb-6",children:[(0,a.jsxs)("h3",{className:"text-xl font-semibold mb-2 flex items-center gap-2",children:[(0,a.jsx)(m.Z,{className:"h-5 w-5"}),"Viewing Race Details"]}),(0,a.jsxs)("ol",{className:"list-decimal pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"Click on a race from the search results to view its details"}),(0,a.jsxs)("li",{children:["The application will load:",(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1 mt-1",children:[(0,a.jsx)("li",{children:"Race information (name, date, location)"}),(0,a.jsx)("li",{children:"Race logo and theme colors (if available on RunSignup)"}),(0,a.jsx)("li",{children:"List of events for the current year"}),(0,a.jsx)("li",{children:"Search box to find participants"})]})]})]})]}),(0,a.jsxs)("section",{className:"mb-6",children:[(0,a.jsxs)("h3",{className:"text-xl font-semibold mb-2 flex items-center gap-2",children:[(0,a.jsx)(o.Z,{className:"h-5 w-5"}),"Searching for Participants"]}),(0,a.jsxs)("ol",{className:"list-decimal pl-6 space-y-1",children:[(0,a.jsxs)("li",{children:["In the race details view, use the search box to find participants by:",(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1 mt-1",children:[(0,a.jsx)("li",{children:"Name (first name, last name, or full name)"}),(0,a.jsx)("li",{children:"Bib number (requires exact match)"})]})]}),(0,a.jsx)("li",{children:"The application automatically detects if you're entering a number (for bib search) or text (for name search)"}),(0,a.jsx)("li",{children:"Results are displayed as cards showing participant name, bib number, and finish times"}),(0,a.jsx)("li",{children:"Click on a participant card to view their detailed receipt"})]}),(0,a.jsx)("h4",{className:"font-medium mt-3 mb-1",children:"QR Code Scanner"}),(0,a.jsx)("div",{className:"pl-6",children:(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsxs)("li",{children:["Click the camera icon ",(0,a.jsx)(E.Z,{className:"h-4 w-4 inline"})," next to the search box to scan a QR code containing a bib number"]}),(0,a.jsx)("li",{children:"This feature requires camera access permission in your browser"}),(0,a.jsx)("li",{children:"After scanning, the application will automatically search for that bib number"})]})})]}),(0,a.jsxs)("section",{className:"mb-6",children:[(0,a.jsxs)("h3",{className:"text-xl font-semibold mb-2 flex items-center gap-2",children:[(0,a.jsx)(H.Z,{className:"h-5 w-5"}),"Viewing Participant Receipts"]}),(0,a.jsx)("p",{children:"When you select a participant, a receipt will be displayed showing:"}),(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"Race name"}),(0,a.jsx)("li",{children:"Participant's name and bib number"}
1),(0,a.jsx)("li",{children:"Finish time (chip or clock time, based on your preference)"}),(0,a.jsx)("li",{children:"Participant details (age, gender, division, etc.)"}),(0,a.jsx)("li",{children:"Place information (overall, gender, division) if not hidden in settings"}),(0,a.jsx)("li",{children:"Split times (if available and not hidden in settings)"}),(0,a.jsx)("li",{children:"Custom message (if configured)"}),(0,a.jsx)("li",{children:"Footer text and image (if configured)"})]}),(0,a.jsx)("p",{className:"mt-2",children:'The receipt will automatically close after the timeout period (default: 30 seconds). You can also click the "Back to Results" button to close it manually.'}),(0,a.jsx)("h4",{className:"font-medium mt-3 mb-1",children:"Printing Receipts"}),(0,a.jsxs)("ol",{className:"list-decimal pl-6 space-y-1",children:[(0,a.jsxs)("li",{children:['While viewing a participant receipt, click the "Print Receipt" button'," ",(0,a.jsx)(c.Z,{className:"h-4 w-4 inline"})]}),(0,a.jsx)("li",{children:"A print dialog will open with the receipt formatted for thermal printers (3-inch width)"}),(0,a.jsx)("li",{children:"Select your printer and print settings"}),(0,a.jsx)("li",{children:"The receipt will print in a compact, receipt-style format"})]})]}),(0,a.jsxs)("section",{className:"mb-6",children:[(0,a.jsxs)("h3",{className:"text-xl font-semibold mb-2 flex items-center gap-2",children:[(0,a.jsx)(X.Z,{className:"h-5 w-5"}),"Customizing Settings"]}),(0,a.jsxs)("p",{children:["Click the settings icon ",(0,a.jsx)(W.Z,{className:"h-4 w-4 inline"})," in the top right corner to customize the application:"]}),(0,a.jsx)("h4",{className:"font-medium mt-3 mb-1",children:"Time Display"}),(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"Choose between chip time or clock time (when available)"}),(0,a.jsx)("li",{children:"For races without chip times, clock time will be used automatically"})]}),(0,a.jsx)("h4",{className:"font-medium mt-3 mb-1",children:"Display Options"}),(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"Rounding: Enable to round times up to the nearest second"}),(0,a.jsx)("li",{children:"Hide Places: Toggle to show or hide place information on receipts"}),(0,a.jsx)("li",{children:"Hide Split Times: Toggle to show or hide split times on receipts"}),(0,a.jsx)("li",{children:"Custom Message: Add a personalized message to appear below the race name"}),(0,a.jsx)("li",{children:"Timeout: Set how long receipts display (10-180 seconds)"})]}),(0,a.jsx)("h4",{className:"font-medium mt-3 mb-1",children:"Colors"}),(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"Backgroun
1d Color: Choose from default (race theme), lighter primary, white, or custom"}),(0,a.jsx)("li",{children:"Text Color: Choose from default (race theme), darker, black, or custom"}),(0,a.jsx)("li",{children:"Use the color picker or enter hex codes for custom colors"})]}),(0,a.jsx)("h4",{className:"font-medium mt-3 mb-1",children:"Footer Customization"}),(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"Footer Text: Add text to display at the bottom of the receipt"}),(0,a.jsx)("li",{children:"Footer Image: Upload a custom logo (e.g., sponsor logo, timer company logo)"})]}),(0,a.jsx)("h4",{className:"font-medium mt-3 mb-1",children:"Race Selection"}),(0,a.jsx)("ul",{className:"list-disc pl-6 space-y-1",children:(0,a.jsx)("li",{children:'Use the "Change Race" tab to switch to a different race without returning to the main search'})})]}),(0,a.jsxs)("section",{className:"mb-6",children:[(0,a.jsxs)("h3",{className:"text-xl font-semibold mb-2 flex items-center gap-2",children:[(0,a.jsx)(Y.Z,{className:"h-5 w-5"}),"Data Management"]}),(0,a.jsx)("h4",{className:"font-medium mt-3 mb-1",children:"Local Storage"}),(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"Race results are stored in your browser's local database for faster searching"}),(0,a.jsx)("li",{children:"Results are automatically refreshed every 3 minutes while viewing a race"}),(0,a.jsxs)("li",{children:['Click the "Refresh" button ',(0,a.jsx)(T.Z,{className:"h-4 w-4 inline"})," to manually update results from RunSignup"]}),(0,a.jsx)("li",{children:"The local database is cleared when you close your browser"})]}),(0,a.jsx)("h4",{className:"font-medium mt-3 mb-1",children:"Progress Tracking"}),(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"When syncing large races with multiple events, a progress bar shows the status"}),(0,a.jsx)("li",{children:"The application respects RunSignup's rate limits to prevent API throttling"})]})]}),(0,a.jsxs)("section",{className:"mb-6",children:[(0,a.jsx)("h3",{className:"text-xl font-semibold mb-2",children:"Tips & Tricks"}),(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"For large races, searching by bib number is usually faster than by name"}),(0,a.jsx)("li",{children:'If you know the race ID, use the "Search by race ID" option for direct access'}),(0,a.jsx)("li",{children:"For footer images, transparent PNG files work best to blend with the receipt background"}),(0,a.jsx)("li",{children:"The application automatically handles races with or without chip timing"}),(0,a.jsx)("li",{children:"Use the QR code scanner for quick bib number entry if participants have QR codes on bibs"}),(0,a.jsx)("li",{children:"Settings are saved in your browser and will persist until you clear your browser data"})]})]}),(0,a.jsxs)("section",{className:"mb-6",children:[(0,a.jsx)("h3",{className:"text-xl font-semibold mb-2",children:"Troubleshooting"}),(0,a.jsx)("h4",{className:"font-medium mt-3 mb-1",children:"Common Issues"}),(0,a.jsx)("p",{className:"font-medium mt-2 mb-1",children:"No races found in search"}),(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"Try broadening your search terms"}),(0,a.jsx)("li",{children:'Enable "Include races without results" in the filter options'}),(0,a.jsx)("li",{children:"Check if the race has published results on RunSignup"})]}),(0,a.jsx)("p",{className:"font-medium mt-2 mb-1",children:"Slow performance with large races"}),(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"Allow the initial sync to complete before searching for participants"}),(0,a.jsx)("li",{children:"Use bib number search instead of name search for faster results"}),(0,a.jsx)("li",{children:"Refresh the results if they seem outdated"})]}),(0,a.jsx)("p",{className:"font-medium mt-2 mb-1",children:"Receipt not showing split times"}),(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsx)("li",{children:'Check if "Hide Split Times" is enabled in settings'}),(0,a.jsx)("li",{children:"Verify that the race actually provides split times in their results"}),(0,a.jsx)("li",{children:"Some races only provide finish times without splits"})]}
1),(0,a.jsx)("p",{className:"font-medium mt-2 mb-1",children:"Print formatting issues"}),(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"The receipt is optimized for 3-inch thermal printers"}),(0,a.jsx)("li",{children:"For standard printers, you may need to adjust scale settings in your print dialog"}),(0,a.jsx)("li",{children:"Make sure to allow pop-ups in your browser for the print window to open"})]})]}),(0,a.jsxs)("section",{className:"mb-6",children:[(0,a.jsx)("h3",{className:"text-xl font-semibold mb-2",children:"Privacy and Data Usage"}),(0,a.jsxs)("ul",{className:"list-disc pl-6 space-y-1",children:[(0,a.jsx)("li",{children:"The application only accesses publicly available race results from RunSignup"}),(0,a.jsx)("li",{children:"No personal data is stored on servers; all data is kept in your browser's local storage"}),(0,a.jsx)("li",{children:"Settings and preferences are stored in your browser and not shared with any third parties"})]})]}),(0,a.jsxs)("div",{className:"mt-8 text-center text-sm text-muted-foreground",children:[(0,a.jsx)("p",{children:"RunSignup Race Results Viewer v1.0"}),(0,a.jsxs)("p",{children:["Uses the RunSignup API:"," ",(0,a.jsx)("a",{href:"https://runsignup.com/API/DocOverview",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"https://runsignup.com/API/DocOverview"})]})]})]}),(0,a.jsx)("div",{className:"pt-4 border-t mt-6",children:(0,a.jsxs)(u.z,{variant:"default",onClick:eT,className:"w-full flex items-center justify-center gap-2",children:[(0,a.jsx)(Z.Z,{className:"h-4 w-4"}),"Close"]})})]})]})]})]})}class eC{initialize(){if(!this.isInitialized){if(window.Worker)try{this.worker=new Worker(s.tu(new URL(s.p+s.u(668),s.b))),this.worker.onmessage=this.handleWorkerMessage.bind(this),this.isInitialized=!0,console.log("Background sync worker initialized")}catch(e){console.error("Failed to initialize background sync worker:",e)}else console.warn("Web Workers are not supported in this environment")}}startSync(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.worker||this.initialize(),this.worker?this.worker.postMessage({type:"SYNC_START",raceId:e,eventIds:t,eventMapping:s}):this.triggerEvent("error",{error:"Worker not available"})}cancelSync(){this.worker&&this.worker.postMessage({type:"SYNC_CANCEL"})}getStatus(){this.worker?this.worker.postMessage({type:"GET_STATUS"}):this.triggerEvent("status",{isSyncing:!1,lastSynced:null})}handleWorkerMessage(e){let t=e.data;switch(t.type){case"SYNC_PROGRESS":this.triggerEvent("progress",{current:t.current,total:t.total,eventId:t.eventId,progressPercentage:t.total>0?Math.round(t.current/t.total*100):0});break;case"SYNC_COMPLETE":this.triggerEvent("complete",{raceId:t.raceId,timestamp:t.timestamp,lastSynced:new Date(t.timestamp)});break;case"SYNC_ERROR":this.triggerEvent("error",{error:t.error});break;case"SYNC_STATUS":this.triggerEvent("status",{isSyncing:t.isSyncing,lastSynced:t.lastSynced?new Date(t.lastSynced):null})}}on(e,t){var s;this.eventListeners.has(e)||this.eventListeners.set(e,[]),null===(s=this.eventListeners.get(e))||void 0===s||s.push(t)}off(e,t){if(!this.eventListeners.has(e))return;let s=this.eventListeners.get(e)||[],a=s.indexOf(t);-1!==a&&s.splice(a,1)}triggerEvent(e,t){for(let s of this.eventListeners.get(e)||[])s(t)}terminate(){this.worker&&(this.worker.terminate(),this.worker=null,this.isInitialized=!1)}constructor(){this.worker=null,this.eventListeners=new Map,this.isInitialized=!1}}let e_=new eC;class eR{async init(){return this.db?this.db:(this.initPromise||(this.initPromise=new Promise((e,t)=>{let s=indexedDB.open(this.dbName,this.dbVersion);s.onerror=e=>{console.error("Error opening database:",e),t(Error("Could not open IndexedDB"))},s.onsuccess=t=>{this.db=t.target.result,e(this.db)},s.onupgradeneeded=e=>{let t=e.target.result;if(!t.objectStoreNames.contains("results")){let e=t.createObjectStore("results",{keyPath:"id"});e.createIndex("raceId","raceId",{unique:!1}),e.createIndex("eventId","eventId",{unique:!1}),e.createIndex("raceEvent",["raceId","eventId"],{unique:!1}),e.createIndex("name","name",{unique:!1}),e.createIndex("bib","bib",{unique:!1})}t.objectStoreNames.contains("metadata")||t.createObjectStore("metadata",{keyPath:"raceId"})}})),this.initPromise)}async storeResults(e,t,s){let a=await this.init();return new Promise((r,i)=>{let n=a.transaction(["results"],"readwrite"),l=n.objectStore("results");
1s.forEach(s=>{let a=void 0!==s.bib_num?s.bib_num:s.bib,r={id:"".concat(e,"_").concat(t,"_").concat(a),raceId:e,eventId:t,name:"".concat(s.first_name," ").concat(s.last_name).toLowerCase(),bib:a,...s};l.put(r)}),n.oncomplete=()=>r(),n.onerror=e=>i(e)})}async updateMetadata(e){let t=await this.init();return new Promise((s,a)=>{let r=t.transaction(["metadata"],"readwrite").objectStore("metadata").put(e);r.onsuccess=()=>s(),r.onerror=e=>a(e)})}async getMetadata(e){let t=await this.init();return new Promise((s,a)=>{let r=t.transaction(["metadata"],"readonly").objectStore("metadata").get(e);r.onsuccess=()=>s(r.result||null),r.onerror=e=>a(e)})}async searchResults(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"name",a=await this.init();return new Promise((r,i)=>{let n=a.transaction(["results"],"readonly").objectStore("results").index("raceId").getAll(e);n.onsuccess=()=>{let a;let i=n.result||[];console.log("DB Service: Found ".concat(i.length," total results for race ").concat(e));let l=t.toLowerCase().trim();/^\d+$/.test(l)||"bib"===s?(a=i.filter(e=>{let t=void 0!==e.bib_num?e.bib_num:e.bib;return null!=t&&t.toString()===l}),console.log("DB Service: Filtered to ".concat(a.length," results with bib number ").concat(l))):(a=i.filter(e=>"".concat(e.first_name," ").concat(e.last_name).toLowerCase().includes(l)||e.name&&e.name.includes(l)||e.first_name&&e.first_name.toLowerCase().includes(l)||e.last_name&&e.last_name.toLowerCase().includes(l)),console.log("DB Service: Filtered to ".concat(a.length,' results with name containing "').concat(l,'"'))),r(a)},n.onerror=e=>i(e)})}async getAllResults(e){let t=await this.init();return new Promise((s,a)=>{let r=t.transaction(["results"],"readonly").objectStore("results").index("raceId").getAll(e);r.onsuccess=()=>s(r.result||[]),r.onerror=e=>a(e)})}async clearRaceResults(e){let t=await this.init();return new Promise((s,a)=>{let r=t.transaction(["results","metadata"],"readwrite"),i=r.objectStore("results"),n=r.objectStore("metadata"),l=i.index("raceId").getAll(e);l.onsuccess=()=>{(l.result||[]).forEach(e=>{i.delete(e.id)}),n.delete(e)},r.oncomplete=()=>s(),r.onerror=e=>a(e)})}constructor(){this.dbName="raceResultsDB",this.dbVersion=1,this.db=null,this.initPromise=null}}let eI=new eR;var eE=s(610);let eP=r.forwardRef((e,t)=>{let{className:s,value:r,...i}=e;return(0,a.jsx)(eE.fC,{ref:t,className:(0,g.cn)("relative h-4 w-full overflow-hidden rounded-full bg-secondary",s),...i,children:(0,a.jsx)(eE.z$,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:"translateX(-".concat(100-(r||0),"%)")}})})});function eT(e){let{isOpen:t,onClose:i,onScan:n}=e,[l,c]=(0,r.useState)(null),[o,d]=(0,r.useState)(null),[m,h]=(0,r.useState)(!1),x=(0,r.useRef)(null),p=(0,r.useRef)(null),f=(0,r.useRef)(null),g=(0,r.useRef)(null);(0,r.useEffect)(()=>(t?b():j(),()=>{j()}),[t]);let b=async()=>{d(null),h(!0);try{let e=(await s.e(664).then(s.t.bind(s,9801,23))).default,t=await navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"},audio:!1});f.current=t,x.current&&(x.current.srcObject=t,x.current.play(),c(!0)),g.current=setInterval(()=>{if(x.current&&p.current){let t=p.current,s=x.current;if(s.readyState===s.HAVE_ENOUGH_DATA){let a=s.videoWidth,r=s.videoHeight;t.width=a,t.height=r;let i=t.getContext("2d");if(i){i.drawImage(s,0,0,a,r);let t=i.getImageData(0,0,a,r),l=e(t.data,t.width,t.height,{inversionAttempts:"dontInvert"});if(l){console.log("QR code detected:",l.data);let e=N(l.data);e&&(j(),n(e))}}}}},200)}catch(e){console.error("Error starting QR scanner:",e),d(e.message||"Could not access camera"),c(!1),h(!1)}},j=()=>{g.current&&(clearInterval(g.current),g.current=null),f.current&&(f.current.getTracks().forEach(e=>e.stop()),f.current=null),h(!1)},v=()=>{j(),i()},y=()=>{j(),b()},N=e=>{if(e.includes("#")){let t=e.split("#").pop();if(t&&/^\d+$/.test(t))return t}if(/^\d+$/.test(e))return e;let t=e.match(/\d+/);return t&&t.length>0?t[0]:null};return(0,a.jsx)(L,{open:t,onOpenChange:e=>!e&&v(),children:(0,a.jsxs)(B,{className:"sm:max-w-md",children:[(0,a.jsxs)(O,{children:[(0,a.jsx)(U,{children:"Scan QR Code"}),(0,a.jsx)($,{asChild:!0,children:(0,a.jsxs)(u.z,{variant:"ghost",size:"icon",className:"absolute right-4 top-4",onClick:v,children:[(0,a.jsx)(Z.Z,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"sr-only",children:"Close"})]})})]}),(0,a.jsxs)("div",{className:"flex flex-col items-center space-y-4",children:[o&&(0,a.jsx)("div",{className:"bg-destructive/10 text-destructive p-4 rounded-md w-full",children:o}),!1===l&&(0,a.jsxs)("div",{className:"text-center p-4",children:[(0,a.jsx)("p",{className:"mb-4",children:"Camera access denied. Please allow camera access to scan QR codes."}),(0,a.jsx)(u.z,{onClick:y,children:"Try Again"})]}),(0,a.jsxs)("div",{className:"relative w-full aspect-square max-w-sm bg-black rounded-md overflow-hidden",children:[m&&(0,a.jsx)("div",{className:"absolute inset-0 border-2 border-primary z-10 pointer-events-none",children:(0,a.jsx)("div",{className:"absolute top-0 left-0 right-0 h-px bg-primary animate-scan"})}),(0,a.jsx)("video",{ref:x,className:"absolute inset-0 w-full h-full object-cover",playsInl
1ine:!0,muted:!0}),(0,a.jsx)("canvas",{ref:p,className:"hidden"})]}),(0,a.jsxs)("div",{className:"text-center text-sm text-muted-foreground",children:[(0,a.jsx)("p",{children:"Position the QR code within the frame to scan"}),(0,a.jsx)("p",{className:"mt-1",children:"The bib number will be automatically extracted"})]}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsxs)(u.z,{variant:"outline",onClick:y,className:"flex items-center gap-2",children:[(0,a.jsx)(T.Z,{className:"h-4 w-4"}),"Restart Scanner"]}),(0,a.jsx)(u.z,{variant:"default",onClick:v,children:"Cancel"})]})]})]})})}async function eD(e){try{let t,{raceCity:s,raceState:a}=e;if(!s||!a){let t=function(e){let t="",s="";if(e){let a=e.match(/([^,]+),\s*([A-Z]{2})/);if(a)t=a[1].trim(),s=a[2].trim();else{let a=e.match(/([^(]+)\s*$$([A-Z]{2})$$/);a&&(t=a[1].trim(),s=a[2].trim())}}return{city:t,state:s}}(e.raceName||"");s=s||t.city,a=a||t.state}let r={raceId:e.raceId||"unknown",raceName:e.raceName||"unknown",raceCity:s,raceState:a,raceVenue:e.raceVenue||"",participantBib:e.participantBib||"unknown",participantName:e.participantName||"unknown",eventName:e.eventName||"unknown",sessionId:((t=sessionStorage.getItem("print_session_id"))||(t=Math.random().toString(36).substring(2)+Date.now().toString(36),sessionStorage.setItem("print_session_id",t)),t)};fetch("/api/track-print",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}).catch(e=>{console.debug("Print tracking failed (non-critical):",e)})}catch(e){console.debug("Print tracking error (non-critical):",e)}}function ez(e){let{raceId:t,eventIds:s,raceName:l,isCondensed:c=!1,onBack:d,onRaceSelect:m,onSearchPerformed:x}=e,[p,f]=(0,r.useState)(""),[b,j]=(0,r.useState)(!1),[v,y]=(0,r.useState)([]),[N,w]=(0,r.useState)(""),[S,k]=(0,r.useState)(!1),[C,_]=(0,r.useState)(null),[I,A]=(0,r.useState)(0),{timePreference:Z,setTimePreference:L,certificateTimeout:q,roundingEnabled:M,customMessage:$,timerLogoUrl:F,timerMessage:B,hideSplitTimes:O,hidePlaces:U}=(0,n.r)(),[W,Y]=(0,r.useState)(!0),V=(0,r.useRef)(null),[G,Q]=(0,r.useState)(!1),H=(0,r.useRef)(null),[J,X]=(0,r.useState)(!1);(0,r.useRef)(null);let{raceName:K}=(0,i.Y)(),[ee,et]=(0,r.useState)(!1),{isSyncing:es,lastSynced:ea,error:er,progress:ei,syncResults:en}=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{refreshInterval:a=6e4,onSyncStart:i,onSyncComplete:n,onSyncError:l}=s,[c,o]=(0,r.useState)(!1),[d,m]=(0,r.useState)(null),[u,h]=(0,r.useState)(null),[x,p]=(0,r.useState)({current:0,total:0,progressPercentage:0}),f=(0,r.useRef)(null),g=(0,r.useRef)(!0);(0,r.useEffect)(()=>(e_.initialize(),()=>{}),[]),(0,r.useEffect)(()=>{let e=e=>{g.current&&p({current:e.current,total:e.total,progressPercentage:e.progressPercentage})},t=e=>{g.current&&(o(!1),m(e.lastSynced),null==n||n(e.timestamp))},s=e=>{g.current&&(o(!1),h(e.error),null==l||l(e.error))},a=e=>{g.current&&(o(e.isSyncing),m(e.lastSynced))};return e_.on("progress",e),e_.on("complete",t),e_.on("error",s),e_.on("status",a),e_.getStatus(),()=>{e_.off("progress",e),e_.off("complete",t),e_.off("error",s),e_.off("status",a)}},[n,l]);let b=async function(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0],!e||!t||0===t.length)return;o(!0),h(null),null==i||i();let s={};try{let t=await fetch("/api/race-details?race_id=".concat(e)),a=await t.json();a.events&&a.events.length>0&&a.events.forEach(e=>{e.event_id&&e.name&&(s[e.event_id.toString()]=e.name)})}catch(e){console.error("Error getting event mapping:",e)}e_.startSync(e,t,s)};return(0,r.useEffect)(()=>{if(e&&t&&0!==t.length)return g.current=!0,b(),f.current=setInterval(()=>{g.current&&b()},a),()=>{g.current=!1,f.current&&(clearInterval(f.current),f.current=null)}},[e,null==t?void 0:t.join(","),a]),{isSyncing:c,lastSynced:d,error:u,progress:x,syncResults:function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return b(e)}}}(t,s,{onSyncComplete:()=>{ec(),eo()}}),el=ei.total>0?Math.round(ei.current/ei.total*100):0,ec=async()=>{try{let e=await eI.getAllResults(t);A(e.length)}catch(e){console.error("Error getting total results count:",e)}},eo=async()=>{try{let e=(await eI.getAllResults(t)).some(e=>e.chip_time&&"N/A"!==e.chip_time&&"00:00:00"!==e.chip_time&&"0"!==e.chip_time);Y(e),e||"chip"!==Z||L("clock")}catch(e){console.error("Error checking for chip times:",e)}};(0,r.useEffect)(()=>{ec(),eo(),en(!0)},[t]),(0,r.useEffect)(()=>(V.current&&(clearTimeout(V.current),V.current=null),C&&(console.log("Setting up certificate timeout for ".concat(q," seconds")),V.current=setTimeout(()=>{console.log("Certificate timeout reached, closing certificate"),_(null)},1e3*q)),()=>{V.current&&(console.log("Clearing certificate timeout"),clearTimeout(V.current),V.current=null)}),[C,q]);let ed=()=>{setTimeout(()=>{H.current&&(H.current.focus(),H.current.select())},100)},em=e=>null!=e&&""!==e&&"N/A"!==e&&"0"!==e&&0!==e;function eu(e){if(!e||"object"!=typeof e)return null;if(e._headers&&"object"==typeof e._headers)return e._headers;if(e.results_headers&&"object"==typeof e.results_headers)return e.results_headers;if(e.individual_results_sets&&Array.isArray(e.individual_results_sets)){for(let t of e.individual_results_sets)if(t.results_headers&&"object"==typeof t.results_headers)return t.results_headers}if(e._parent){let t=eu(e._parent);if(t)return t}if(e._resultSet){let t=eu(e._resultSet);if(t)return t}for(let t in e)if("object"==typeof e[t]&&null!==e[t]){let s=eu(e[t]);if(s)return s}return null}let eh=(e,t)=>{let s=eu(t);if(s&&s[e])return s[e];if("place"===e||"overall_place"===e||"overall-place"===e)return"Overall Place";if("gender_place"===e||"gender-place"===e||"sex_place"===e)return"Gender Place";if(e.includes("division")&&e.includes("place"))return"Division Place";if(e.includes("age")&&e.includes("place"))return"Age Group Place";if(e.includes("split")||e.match(/\d+k/i)||e.match(/\d+m/i)){let t=e.replace(/[_-]/g," ").replace(/split/gi,"").replace(/time/gi,"").trim();return t.match(/^\d+k$/i)||t.match(/^\d+km$/i)?t.toUpperCase():t.match(/^\d+m$/i)?t+"ile":"half"===t.toLowerCase()?"Half Marathon":"finish"===t.toLowerCase()?"Finish":""===t?"Split":t.charAt(0).toUpperCase()+t.slice(1)}return e.replace(/[_-]/g," ").replace(/([A-Z])/g," $1").trim().replace(/^\w/,e=>e.toUpperCase())},ex=e=>{let t=e.toLowerCase();return t.includes("place")||t.includes("position")||t.includes("rank")||"overall"===t||"gender"===t||"division"===t},ep=e=>e.toLowerCase().includes("division")&&e.toLowerCase().includes("placement"),ef=(e,t)=>{let s=e.toLowerCase(),a=(null==t?void 0:t.toLowerCase())||"";return!!(["first_name","last_name","bib_num","bib","age","gender","city","state","country","chip_time","clock_time","pace","start_time","finish_time","team_name","division_name","event_name","
1id","raceId","eventId","name","_headers"].includes(s)||"age_percentage"===s||"age percentage"===a||s.includes("time")||s.includes("pace")||s.includes("date")||a.includes("time")||a.includes("pace")||a.includes("date")||s.includes("percentage")||a.includes("percentage"))},eg=e=>{let t=[],s=Object.keys(e),a=eu(e);if(a)for(let[s,r]of Object.entries(a)){let a=e[s];if(em(a)&&!ef(s,r)&&(ex(r)&&t.push({key:s,label:r,value:a}),ep(s))){t.push({key:s,label:"".concat(r," Place"),value:a});continue}}for(let s of[{key:"place",label:"Overall Place"},{key:"overall_place",label:"Overall Place"},{key:"overall-place",label:"Overall Place"},{key:"gender_place",label:"Gender Place"},{key:"gender-place",label:"Gender Place"},{key:"sex_place",label:"Gender Place"},{key:"division_place",label:"Division Place"},{key:"division-place",label:"Division Place"},{key:"age_group_place",label:"Age Group Place"},{key:"age-group-place",label:"Age Group Place"}])em(e[s.key])&&!t.some(e=>e.key===s.key)&&t.push({key:s.key,label:s.label,value:e[s.key]});for(let a of s){let s=e[a];if(!(!em(s)||ef(a))&&!t.some(e=>e.key===a)&&(a.toLowerCase().includes("place")||a.toLowerCase().includes("position")||a.toLowerCase().includes("rank"))){let e=a.replace(/[_-]/g," ").replace(/([A-Z])/g," $1").trim().replace(/^\w/,e=>e.toUpperCase());t.push({key:a,label:e,value:s})}}return t},eb=e=>{let t=[],s=Object.keys(e),a=eu(e),r=["first_name","last_name","bib_num","bib","age","gender","city","state","country","chip_time","clock_time","pace","start_time","finish_time","team_name","division_name","event_name","id","raceId","eventId","name","_headers"];for(let i of s){let s=e[i];if(!(!em(s)||r.includes(i))&&!(i.toLowerCase().includes("place")||i.toLowerCase().includes("position")||i.toLowerCase().includes("rank")||i.toLowerCase().includes("placement"))&&(i.toLowerCase().includes("split")||i.toLowerCase().includes("km")||i.toLowerCase().includes("mile")||i.toLowerCase().includes("half")||i.toLowerCase().includes("finish")||i.match(/\d+k$/i)||i.match(/\d+m$/i)||i.match(/\d+mi$/i)||i.toLowerCase().includes("time")&&!i.toLowerCase().includes("start")&&!i.toLowerCase().includes("finish"))){if(i.toLowerCase().includes("pace"))continue;let r=a&&a[i]?a[i]:eh(i,e),n=e[i+"_pace"]||null;t.push({key:i,label:r,value:s,pace:n})}}return t},ej=async e=>{let t;let s=async e=>{try{if(e.startsWith("data:"))return e;let t=await fetch(e),s=await t.blob();return new Promise(e=>{let t=new FileReader;t.onload=()=>e(t.result),t.onerror=()=>e(null),t.readAsDataURL(s)})}catch(e){return console.error("Error converting image to base64:",e),null}},a=null;F&&!ee&&(a=await s(F));let r=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32;if(e.length>=t)return e.substring(0,t);let s=Math.floor((t-e.length)/2);return" ".repeat(s)+e+" ".repeat(t-e.length-s)},i=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:32,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:2,a=" ".repeat(s)+e;return a.length>=t?a.substring(0,t):a+" ".repeat(t-a.length)},n=function(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:32,a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2;return i("".concat(e,": ").concat(t),s,a)},c=(e,t)=>{let s=e.split(" "),a=[],r="";for(let e of s)r.length+e.length+1>t?r.length>0?(a.push(r.trim()),r=e):(a.push(e.substring(0,t)),r=e.substring(t)):r.length>0?r+=" "+e:r=e;return r.length>0&&a.push(r.trim()),a},o=(t,s)=>void 0!==e[t]&&null!==e[t]&&""!==e[t]?e[t]:s&&void 0!==e[s]&&null!==e[s]&&""!==e[s]?e[s]:null,d=!!(e.chip_time&&"N/A"!==e.chip_time&&"00:00:00"!==e.chip_time&&"0"!==e.chip_time),m=!!(e.clock_time&&"N/A"!==e.clock_time&&"00:00:00"!==e.clock_time&&"0"!==e.clock_time),u=!d&&m?"clock":Z,h=e=>{let t=["th","st","nd","rd"],s=e%100;return e+(t[(s-20)%10]||t[s]||"th")},x="";c(K||l||"Race Results",28).forEach(e=>{x+=r(e.toUpperCase(),32)+"\n"}),$&&(x+="\n",c($,28).forEach(e=>{x+=r(e,32)+"\n"}));let p=o("event_name");p&&(x+="\n",c(p,28).forEach(e=>{x+=r(e,32)+"\n"})),x+="================================\n";let f="".concat(o("first_name")||""," ").concat(o("last_name")||"").trim();f&&(f.match(/.{1,28}
1/g)||[f]).forEach(e=>{x+=r(e.toUpperCase(),32)+"\n"}),x+=r("Bib #".concat((()=>{let t=o("bib_num","bib");if(t)return t;if(void 0!==e.bib&&null!==e.bib&&""!==e.bib)return e.bib;if(e.id){let t=e.id.split("_");if(t.length>=3)return t[2]}return"Unknown"})()),32)+"\n"+(r("".concat("chip"===u?"Chip Time":"Clock Time",":"),32)+"\n"+r(((t="chip"===u&&d?o("chip_time"):o("clock_time"),M)?(0,g.GG)(t):t)||"N/A",32))+"\n--------------------------------\n";let b=[{label:"Age",value:o("age")},{label:"Gender",value:o("gender")},{label:"City",value:o("city")},{label:"State",value:o("state")},{label:"Country",value:o("country")},{label:"Division",value:o("division_name")},{label:"Event",value:o("event_name")},{label:"Team",value:o("team_name")},{label:"Start Time",value:o("start_time")},{label:"Finish Time",value:o("finish_time")}];d&&m&&b.push({label:"Chip Time",value:o("chip_time")},{label:"Clock Time",value:o("clock_time")},{label:"Pace",value:o("pace")}),b.forEach(e=>{em(e.value)&&(x+=n(e.label,e.value,32,2)+"\n")});let j=eg(e);j.length>0&&!U&&(x+="\n"+i("Places:",32,2)+"\n",j.forEach(e=>{let t=e.value;isNaN(Number.parseInt(e.value))||(t=h(Number.parseInt(e.value))),x+=n(e.label,t,32,4)+"\n"}));let v=eb(e);v.length>0&&!O&&(x+="\n"+i("Split Times:",32,2)+"\n",v.forEach(e=>{let t="".concat(e.label,": ").concat(e.value);e.pace&&(t+=" (".concat(e.pace,")")),x+=i(t,32,4)+"\n"})),x+="--------------------------------\n",B&&(x+="\n",c(B,28).forEach(e=>{x+=r(e,32)+"\n"}));let y=new Date,N=y.toLocaleDateString(),w=y.toLocaleTimeString(),S=r("".concat(N," ").concat(w),32);return"\n<!DOCTYPE html>\n<html>\n  <head>\n    <title>Race Result Receipt</title>\n    <style>\n      @page {\n        size: 3in auto;\n        margin: 0;\n      }\n      body {\n        font-family: 'Courier New', monospace;\n        font-size: 12px;\n        font-weight: bold;\n        line-height: 1.2;\n        margin: 0;\n        padding: 8px;\n        background-color: white;\n        color: black;\n      }\n      .receipt-text {\n        white-space: pre;\n        margin: 0;\n        padding: 0;\n      }\n      .logo-container {\n        text-align: center;\n        margin: 8px 0;\n        padding: 0;\n        width: 100%;\n      }\n      .logo-container img {\n        max-width: 200px;\n        max-height: 60px;\n        height: auto;\n        display: block;\n        margin: 0 auto;\n      }\n      .timestamp {\n        white-space: pre;\n        margin: 0;\n        padding: 0;\n      }\n    </style>\n  </head>\n  <body>\n    <div class=\"receipt-text\">".concat(x,"</div>\n    ").concat(a?'<div class="logo-container"><img src="'.concat(a,'" alt="Footer Logo"></div>'):"",'\n    <div class="timestamp">').concat(S,"</div>\n  </body>\n</html>\n")},ev=async e=>{if(e.trim()){j(!0),w(""),k(!0),x&&x();try{let s=await eI.searchResults(t,e,"bib");console.log("Found ".concat(s.length," results for bib ").concat(e)),y(s),0===s.length?w("No results found for bib number: ".concat(e)):1===s.length&&await eC(s[0]);let a=new CustomEvent("raceSearchPerformed",{bubbles:!0});document.dispatchEvent(a)}catch(e){console.error("Error searching race results:",e),w("Error searching results. Please try again.")}finally{j(!1)}}},ey=async e=>{if(e.preventDefault(),!p.trim()){y([]);return}j(!0),w(""),k(!0),x&&x();try{let e=/^\d+$/.test(p.trim())?"bib":"name";console.log("Searching for ".concat(p," by ").concat(e));let s=await eI.searchResults(t,p,e);if(console.log("Found ".concat(s.length," results for ").concat(e," ").concat(p)),y(s),0===s.length){let t="bib"===e?"bib number":"name";w("No results found for ".concat(t,": ").concat(p))}else 1===s.length&&await eC(s[0]);let a=new CustomEvent("raceSearchPerformed",{bubbles:!0});document.dispatchEvent(a)}catch(e){console.error("Error searching race results:",e),w("Error searching results. Please try again.")}finally{j(!1)}},eN=(e,t,s)=>void 0!==e[t]?e[t]:s&&void 0!==e[s]?e[s]:"N/A",ew=async e=>{console.log("Selecting participant:",e.first_name,e.last_name),_(e)};if((0,r.useEffect)(()=>{ed()},[]),C)return null;let eC=async e=>{X(!0);try{var s;await eD({raceId:t,raceName:l,participantBib:eN(e,"bib_num","bib"),participantName:"".concat(e.first_name," ").concat(e.last_name),eventName:eN(e,"event_name")}
1);let a=await ej(e),r=document.createElement("iframe");r.style.position="fixed",r.style.top="-1000px",r.style.left="-1000px",r.style.width="1px",r.style.height="1px",r.style.opacity="0",document.body.appendChild(r);let i=r.contentDocument||(null===(s=r.contentWindow)||void 0===s?void 0:s.document);i?(i.open(),i.write(a),i.close(),setTimeout(()=>{try{var e,t;null===(e=r.contentWindow)||void 0===e||e.focus(),null===(t=r.contentWindow)||void 0===t||t.print()}catch(e){console.error("Print error:",e)}setTimeout(()=>{try{document.body.removeChild(r)}catch(e){console.log("Iframe already removed")}X(!1),ed()},1e3)},500)):(console.error("Could not access iframe document"),X(!1),ed())}catch(e){console.error("Error generating receipt:",e),w("Error generating receipt. Please try again."),X(!1),ed()}};return(0,a.jsxs)(R.Zb,{className:c?"mt-2":"mt-6",children:[(0,a.jsxs)(R.Ol,{className:"".concat(c?"py-3 px-4":""," flex flex-row items-center justify-between"),children:[(0,a.jsxs)(R.ll,{className:c?"text-base":"",children:["Race Results - ",l]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsxs)(u.z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>Q(!0),title:"Scan QR Code",children:[(0,a.jsx)(E.Z,{className:"h-4 w-4"}),(0,a.jsx)("span",{className:"sr-only",children:"Scan QR Code"})]}),(0,a.jsx)(ek,{onRaceSelect:m,onBack:d,hasChipTimes:W})]})]}),(0,a.jsxs)(R.aY,{className:c?"py-3 px-4":"",children:[J&&(0,a.jsxs)("div",{className:"mb-4 bg-blue-50 text-blue-800 p-3 rounded-md flex items-center gap-2",children:[(0,a.jsx)(P.Z,{className:"h-4 w-4 animate-spin"}),(0,a.jsx)("span",{children:"Printing receipt..."})]}),es&&(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-2",children:[(0,a.jsxs)("span",{className:"text-sm text-muted-foreground",children:["Syncing race results (",ei.current," of ",ei.total," events)"]}),(0,a.jsxs)("span",{className:"text-sm font-medium",children:[el,"%"]})]}),(0,a.jsx)(eP,{value:el,className:"h-2"})]}),(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("div",{className:"text-sm text-muted-foreground",children:[(0,a.jsxs)("span",{children:["Last updated: ",ea?(0,eS.WU)(ea,"h:mm:ss a"):"Never"]}),I>0&&(0,a.jsxs)("span",{className:"ml-2",children:["• ",I," results available"]}),!W&&I>0&&(0,a.jsx)("span",{className:"ml-2 text-amber-600",children:"• Only clock times available"})]}),(0,a.jsx)(u.z,{variant:"outline",size:"sm",onClick:()=>en(!0),className:"h-8",disabled:es,children:es?(0,a.jsxs)("span",{className:"flex items-center",children:[(0,a.jsx)(P.Z,{className:"h-3 w-3 mr-1 animate-spin"}),"Syncing..."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(T.Z,{className:"h-3.5 w-3.5 mr-1"}),"Refresh"]})})]}),(0,a.jsxs)("form",{onSubmit:ey,className:c?"space-y-2":"space-y-4",children:[(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(h.I,{ref:H,type:"text",placeholder:"Search by name or exact bib number",value:p,onChange:e=>f(e.target.value),className:"flex-1",disabled:J}),(0,a.jsx)(u.z,{type:"submit",disabled:b||0===I||J,children:b?(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)(P.Z,{className:"h-4 w-4 animate-spin"}),"Searching..."]}):(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)(o.Z,{className:"h-4 w-4"}),"Search"]})})]}),!c&&(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Enter a name or exact bib number to search across all events. Click any result to print it directly."})]}),er&&(0,a.jsxs)("div",{className:"bg-amber-50 text-amber-800 p-3 rounded-md mt-4 text-sm",children:["Warning: ",er,". Some results may not be up to date."]}),N&&(0,a.jsx)("div",{className:"bg-destructive/10 text-destructive p-4 rounded-md mt-4",children:N}),I>0&&!S&&(0,a.jsxs)("div",{className:"mt-4 text-sm text-muted-foreground",children:[I," total results available. Enter a search term to find participants."]}),v.length>0&&(0,a.jsx)("div",{className:"".concat(c?"mt-3":"mt-6"," grid gap-4 sm:grid-cols-2 lg:grid-cols-3"),children:v.map((e,t)=>(0,a.jsx)(R.Zb,{className:"cursor-pointer hover:shadow-md transition-shadow relative ".concat(J?"opacity-50 pointer-events-none":""),onClick:()=>!J&&ew(e),children:(0,a.jsxs)(R.aY,{className:"p-4",children:[(0,a.jsx)("div",{className:"absolute top-2 right-2",children:(0,a.jsx)("span",{className:"bg-background text-foreground text-xs px-2 py-1 rounded-md border shadow-sm",children:eN(e,"event_name")||"Event"})}),(0,a.jsxs)("div",{className:"pr-16",children:[" ",(0,a.jsx)("h3",{className:"font-bold text-lg",children:"".concat(e.first_name," ").concat(e.last_name)}),(0,a.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Bib #",eN(e,"bib_num","bib")," • ",eN(e,"age")," •"," ",eN(e,"gender")]}),(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:eN(e,"city")})]}),(0,a.jsxs)("div",{className:"mt-4 grid grid-cols-2 gap-2",children:[(0,a.jsxs)("div",{className:"bg-muted p-2 rounded-md",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,a.jsx)(D.Z,{className:"h-3 w-3"}),(0,a.jsx)("span",{children:"Clock Time"})]}),(0,a.jsx)("p",{className:"font-mono font-bold",children:eN(e,"clock_time")})]}),W&&(0,a.jsxs)("div",{className:"bg-muted p-2 rounded-md",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,a.jsx)(z.Z,{className:"h-3 w-3"}),(0,a.jsx)("span",{children:"Chip Time"})]}),(0,a.jsx)("p",{className:"font-mono font-bold",children:eN(e,"chip_time")})]})]})]})},"".concat(eN(e,"bib_num","bib"),"-").concat(t)))}),(0,a.jsx)(eT,{isOpen:G,onClose:()=>Q(!1),onScan:e=>{console.log("QR code scanned, bib number:",e),f(e),Q(!1),ev(e)}})]})]})}eP.displayName=eE.fC.displayName;class eA{enqueue(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,s=arguments.length>2?arguments[2]:void 0;return new Promise((a,r)=>{let i=Math.random().toString(36).substring(2,9);this.queue.push({id:i,request:e,priority:t,resolve:a,reject:r,retryCount:0,batchId:s}),this.queue.sort((e,t)=>
1t.priority-e.priority),this.processing||this.processQueue()})}async processQueue(){if(0===this.queue.length){this.processing=!1;return}for(this.processing=!0;this.queue.length>0&&this.activeRequests<this.maxConcurrentRequests;){let e=this.getNextBatch();if(0===e.length)break;this.processBatch(e)}this.queue.length>0?setTimeout(()=>this.processQueue(),100):this.processing=!1}getNextBatch(){let e=this.maxConcurrentRequests-this.activeRequests,t=Math.min(this.batchSize,e,this.queue.length);if(t<=0)return[];let s=Date.now();this.lastRequestTimes=this.lastRequestTimes.filter(e=>s-e<1e3);let a=Math.min(t,Math.max(0,this.requestsPerSecond-this.lastRequestTimes.length));return a<=0?(setTimeout(()=>this.processQueue(),250),[]):this.queue.splice(0,a)}async processBatch(e){let t=e.map(e=>this.processItem(e));await Promise.allSettled(t),this.processQueue()}async processItem(e){this.activeRequests++;try{this.lastRequestTimes.push(Date.now());let t=await e.request();e.resolve(t),this.consecutiveErrors=0,this.currentBackoffDelay=this.initialBackoffDelay}catch(t){if(console.error("API request failed: ".concat(t.message)),e.retryCount<this.maxRetries){e.retryCount++,this.consecutiveErrors++;let t=Math.min(this.currentBackoffDelay*Math.pow(2,this.consecutiveErrors-1),this.maxBackoffDelay);console.log("Retrying request (attempt ".concat(e.retryCount,") after ").concat(t,"ms delay")),setTimeout(()=>{this.queue.unshift(e),this.processQueue()},t)}else e.reject(Error("Request failed after ".concat(this.maxRetries," retries: ").concat(t.message)))}finally{this.activeRequests--}}clearQueue(){let e=this.queue.length;this.queue.forEach(e=>{e.reject(Error("Request cancelled - queue cleared"))}),this.queue=[],console.log("Cleared ".concat(e," pending requests from queue"))}get queueLength(){return this.queue.length}get isProcessing(){return this.processing||this.activeRequests>0}get activeRequestsCount(){return this.activeRequests}constructor(e={}){this.queue=[],this.processing=!1,this.consecutiveErrors=0,this.activeRequests=0,this.lastRequestTimes=[],this.requestsPerSecond=e.requestsPerSecond||4,this.maxRetries=e.maxRetries||3,this.initialBackoffDelay=e.initialBackoffDelay||1e3,this.maxBackoffDelay=e.maxBackoffDelay||3e4,this.maxConcurrentRequests=e.maxConcurrentRequests||4,this.batchSize=e.batchSize||3,this.currentBackoffDelay=this.initialBackoffDelay}}let eZ=new eA({requestsPerSecond:4,maxRetries:3,initialBackoffDelay:1e3,maxBackoffDelay:3e4,maxConcurrentRequests:4,batchSize:3});class eL{async fetch(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{priority:s=0,...a}=t;return eZ.enqueue(()=>fetch(e,a),s)}async fetchRaceDetails(e){let t=await this.fetch("/api/race-details?race_id=".concat(e),{priority:10});if(!t.ok)throw Error("Failed to fetch race details: ".concat(t.status));return t.json()}async fetchResultSets(e,t){try{let s=await this.fetch("/api/result-sets?race_id=".concat(e,"&event_id=").concat(t),{priority:9});if(!s.ok)throw Error("Failed to fetch result sets: ".concat(s.status));return s.json()}catch(e){throw console.error("Error fetching result sets for event ".concat(t,":"),e),e}}async fetchRaceResults(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5;try{let a=await this.fetch("/api/race-results?race_id=".concat(e,"&event_id=").concat(t,"&include_all=true"),{priority:s});if(!a.ok)throw Error("API returned status ".concat(a.status," for event ").concat(t));let r=await a.json();if("fetching"===r.status)return this.pollForResults(e,t,s-1);if(r.results)return r.results;return[]}catch(e){throw console.error("Error fetching race results for event ".concat(t,":"),e),e}}async pollForResults(e,t){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return new Promise(a=>{let r=0,i=async()=>{try{r++;let n=3e3*Math.pow(1.5,r-1),l=Math.max(0,s-r),c=await this.fetch("/api/race-results?race_id=".concat(e,"&event_id=").concat(t),{priority:l});if(!c.ok)throw Error("API returned status ".concat(c.status));let o=await c.json();if(o.results){a(o.results);return}if(r>=10){console.warn("Max polling attempts reached for event ".concat(t)),a([]);return}setTimeout(i,n)}catch(e){console.error("Error polling for results for event ".concat(t,":"),e),r<10?setTimeout(i,3e3*Math.pow(2,r)):a([])}};i()})}
1async searchRaces(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=new URLSearchParams;e&&s.append("term",e),Object.entries(t).forEach(e=>{let[t,a]=e;null!=a&&s.append(t,String(a))});let a=await this.fetch("/api/search-races?".concat(s.toString()),{priority:8});if(!a.ok)throw Error("Search API returned status ".concat(a.status));return(await a.json()).races||[]}}let eq=new eL;function eM(e){var t,s;let{race:l,onBack:c,onRaceSelect:o}=e,[d,h]=(0,r.useState)(null),[x,p]=(0,r.useState)(!0),[f,b]=(0,r.useState)(""),[j,v]=(0,r.useState)([]),{primaryColor:y,setRaceTheme:N}=(0,i.Y)(),{setCurrentRaceId:w}=(0,n.r)(),[S,k]=(0,r.useState)(!0),[C,_]=(0,r.useState)(!1),[E,P]=(0,r.useState)(!1),[T,D]=(0,r.useState)(0);(0,r.useEffect)(()=>{(async()=>{p(!0),b("");try{await N(l.race_id,l.name||l.race&&l.race.name),w(l.race_id.toString());let e=await eI.getMetadata(l.race_id.toString());e&&e.eventIds&&e.eventIds.length>0&&v(e.eventIds);let t=await eq.fetchRaceDetails(l.race_id.toString());if(h(t),t.events&&t.events.length>0){let e=new Date().getFullYear(),s=t.events.filter(t=>{let s=t.start_time?new Date(t.start_time):t.date?new Date(t.date):null,a=!s||s.getFullYear()===e,r=!0===t.is_virtual||!0===t.virtual_race||t.name&&t.name.toLowerCase().includes("virtual")||t.event_type&&t.event_type.toLowerCase().includes("virtual");return a&&!r});15721===l.race_id?v(["961808"]):v(s.map(e=>e.event_id.toString()))}let s={};if(t.events&&t.events.length>0&&t.events.forEach(e=>{e.event_id&&e.name&&(s[e.event_id.toString()]=e.name)}),await eI.updateMetadata({raceId:l.race_id.toString(),eventIds:j,eventMapping:s,lastUpdated:Date.now(),isComplete:!1}),t.events&&t.events.length>0){let e=t.events.filter(e=>!0===e.is_virtual||!0===e.virtual_race||e.name&&e.name.toLowerCase().includes("virtual")||e.event_type&&e.event_type.toLowerCase().includes("virtual")).length;D(e)}}catch(e){b("Error fetching race details. Please try again."),console.error(e)}finally{p(!1)}})();let e=()=>{k(!1),_(!0),P(!0)};return document.addEventListener("raceSearchPerformed",e),()=>{document.removeEventListener("raceSearchPerformed",e)}},[l.race_id,N,l.name,w]);let z=()=>{w(null),c()};return(0,a.jsxs)("div",{className:"space-y-".concat(C?"2":"6"),children:[!E&&(0,a.jsx)(R.Zb,{className:C?"shadow-sm":"",children:(0,a.jsx)(R.Ol,{className:"py-3 px-4",children:(0,a.jsx)(R.ll,{children:l.name})})}),(0,a.jsxs)(R.Zb,{className:C?"shadow-sm":"",children:[(0,a.jsx)(R.Ol,{className:"flex flex-row items-start justify-between ".concat(C?"py-3 px-4":""),children:(0,a.jsx)("div",{className:"flex items-center gap-2",children:(0,a.jsxs)("div",{children:[(0,a.jsx)(R.ll,{className:C?"text-base":"",children:l.name}),!C&&(0,a.jsxs)(R.SZ,{className:"flex items-center gap-1",children:[(0,a.jsx)(m.Z,{className:"h-4 w-4"}),(0,g.p6)(l.next_date||l.last_date),(null===(t=l.address)||void 0===t?void 0:t.city)&&(null===(s=l.address)||void 0===s?void 0:s.state)&&(0,a.jsxs)("span",{children:[" ","• ",l.address.city,", ",l.address.state]})]})]})})}),S&&!C&&(0,a.jsx)(R.aY,{children:x?(0,a.jsx)("div",{className:"flex justify-center py-8",children:(0,a.jsx)("div",{className:"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent"})}):f?(0,a.jsx)("div",{className:"bg-destructive/10 text-destructive p-4 rounded-md",children:f}):d?(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-lg font-medium mb-4",children:"Events"}),d.events&&d.events.length>0?(0,a.jsx)("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:d.events.filter(e=>{let t=new Date().getFullYear(),s=e.start_time?new Date(e.start_time):e.date?new Date(e.date):null;return!s||s.getFullYear()===t}).map(e=>(0,a.jsx)(R.Zb,{children:(0,a.jsxs)(R.aY,{className:"p-4",children:[(0,a.jsx)("h4",{className:"font-medium",children:e.name}),e.start_time&&(0,a.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Start time:"," ",new Date(e.start_time).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})]})]})},e.event_id))}):(0,a.jsxs)("div",{className:"bg-muted p-4 rounded-md text-center",children:[(0,a.jsx)("p",{children:"No events found for this race in the current year."}),(0,a.jsxs)("p",{className:"text-sm text-muted-foreground mt-1",children:["Race ID: ",l.race_id]})]})]}),T>0&&(0,a.jsx)("div",{className:"mt-4 text-sm text-muted-foreground",children:(0,a.jsxs)("p",{children:[T," virtual ",1===T?"event was":"events were"," ","excluded from results."]})})]}):(0,a.jsx)("p",{children:"No details available for this race."})}),!x&&(!(null==d?void 0:d.events)||0===d.events.length||0===j.length)&&(0,a.jsx)(R.eW,{className:"pt-2 pb-4",children:(0,a.jsxs)(u.z,{variant:"outline",onClick:z,className:"flex items-center gap-2",children:[(0,a.jsx)(I.Z,{className:"h-4 w-4"}),"Back to Search"]})})]}),j.length>0?(0,a.jsx)(ez,{raceId:l.race_id.toString(),eventIds:j,raceName:l.name,isCondensed:C,onBack:z,onRaceSelect:o,onSearchPerformed:()=>P(!0)}):!x&&(0,a.jsx)(R.Zb,{children:(0,a.jsx)(R.aY,{className:"py-6",children:(0,a.jsxs)("div",{className:"text-center space-y-4",children:[(0,a.jsx)("h3",{className:"text-lg font-medium",children:"No Results Available"}),(0,a.jsxs)("p",{className:"text-muted-foreground",children:["This race (ID: ",l.race_id,") doesn't have any results available in the RunSignup system."]}),(0,a.jsxs)(u.z,{onClick:z,className:"mt-4 flex items-center gap-2",children:[(0,a.jsx)(I.Z,{className:"h-4 w-4"}),"Back to Search"]})]})})})]})}function e$(){let{logoUrl:e,primaryColor:t,backgroundColor:s,raceName:c}=(0,i.Y)(),{primaryColorPreference:o,customPrimaryColor:d,headerImageUrl:m}=(0,n.r)(),[u,h]=(0,r.useState)(!1),[x,p]=(0,r.useState)(null),f={backgroundColor:e?(()=>{switch(o){case"default":default:return t||"#f54a87";case"darker":if(t.startsWith("#")){let e=Number.parseInt(t.slice(1,3),16),s=Number.parseInt(t.slice(3,5),16),a=Number.parseInt(t.slice(5,7),16);return"#".concat(Math.max(0,e-50).toString(16).padStart(2,"0")).concat(Math.max(0,s-50).toString(16).padStart(2,"0")).concat(Math.max(0,a-50).toString(16).padStart(2,"0"))}if(t.startsWith("rgba"))return t.replace(/rgba$$(.+?),\s*[\d.]+$$/,"rgba($1, 1)");if(t.startsWith("rgb"))return t.replace(/rgb$$(.+?)$$/,"rgba($1, 1)");return"#000000";case"black":return"#000000";
1case"custom":return d}})():"white",transition:"background-color 0.3s ease"},g=async e=>{p(e)};return(0,a.jsxs)("div",{style:{minHeight:"100vh",backgroundColor:e?s:"white",transition:"background-color 0.3s ease"},children:[(0,a.jsx)("header",{className:"py-4 px-6 shadow-sm",style:f,children:(0,a.jsxs)("div",{className:"container mx-auto flex flex-col",children:[m&&(0,a.jsx)("div",{className:"w-full flex justify-center mb-3",children:(0,a.jsx)(l.default,{src:m||"/placeholder.svg",alt:"Header Image",width:800,height:200,className:"max-h-32 w-auto object-contain",unoptimized:!0})}),(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("div",{className:"flex items-center",children:e?u?(0,a.jsx)("h1",{className:"text-xl font-bold text-white",children:c||"Race Search"}):(0,a.jsxs)("div",{className:"h-12 relative flex items-center",children:[(0,a.jsx)(l.default,{src:e||"/placeholder.svg",alt:c||"Race Logo",width:200,height:48,className:"h-full w-auto object-contain",onError:()=>h(!0),priority:!0,unoptimized:!0}),(0,a.jsx)("span",{className:"sr-only",children:c||"Race Search"})]}):(0,a.jsx)("h1",{className:"text-2xl font-bold",children:"RunSignup Race Search"})}),x&&c&&(0,a.jsx)("div",{className:"text-white font-bold text-xl",children:c})]})]})}),(0,a.jsx)("main",{className:"container mx-auto py-8 px-4",children:x?(0,a.jsx)(eM,{race:x,onBack:()=>p(null),onRaceSelect:g}):(0,a.jsx)(_,{onSelectRace:g})})]})}},2869:function(e,t,s){"use strict";s.d(t,{z:function(){return o}});var a=s(7437),r=s(2265),i=s(7053),n=s(535),l=s(4508);let c=(0,n.j)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),o=r.forwardRef((e,t)=>{let{className:s,variant:r,size:n,asChild:o=!1,...d}=e,m=o?i.g7:"button";return(0,a.jsx)(m,{className:(0,l.cn)(c({variant:r,size:n,className:s})),ref:t,...d})});o.displayName="Button"},6070:function(e,t,s){"use strict";s.d(t,{Ol:function(){return l},SZ:function(){return o},Zb:function(){return n},aY:function(){return d},eW:function(){return m},ll:function(){return c}});var a=s(7437),r=s(2265),i=s(4508);let n=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("div",{ref:t,className:(0,i.cn)("rounded-lg border bg-card text-card-foreground shadow-sm",s),...r})});n.displayName="Card";let l=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("div",{ref:t,className:(0,i.cn)("flex flex-col space-y-1.5 p-6",s),...r})});l.displayName="CardHeader";let c=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("div",{ref:t,className:(0,i.cn)("text-2xl font-semibold leading-none tracking-tight",s),...r})});c.displayName="CardTitle";let o=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("div",{ref:t,className:(0,i.cn)("text-sm text-muted-foreground",s),...r})});o.displayName="CardDescription";let d=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("div",{ref:t,className:(0,i.cn)("p-6 pt-0",s),...r})});d.displayName="CardContent";let m=r.forwardRef((e,t)=>{let{className:s,...r}=e;return(0,a.jsx)("div",{ref:t,className:(0,i.cn)("flex items-center p-6 pt-0",s),...r})});m.displayName="CardFooter"},5186:function(e,t,s){"use strict";s.d(t,{I:function(){return n}});var a=s(7437),r=s(2265),i=s(4508);let n=r.forwardRef((e,t)=>
1{let{className:s,type:r,...n}=e;return(0,a.jsx)("input",{type:r,className:(0,i.cn)("flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",s),ref:t,...n})});n.displayName="Input"},4508:function(e,t,s){"use strict";s.d(t,{GG:function(){return l},cn:function(){return i},p6:function(){return n}});var a=s(1994),r=s(3335);function i(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return(0,r.m6)((0,a.W)(t))}function n(e){return e?new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}):"Date not available"}function l(e){if(!e||"string"!=typeof e||!e.includes("."))return e;let[t,s]=e.split(".");if(!s||/^0+$/.test(s))return t;let a=t.split(":"),r=0,i=0,n=0;if(2===a.length)i=Number.parseInt(a[0],10),n=Number.parseInt(a[1],10);else{if(3!==a.length)return e;r=Number.parseInt(a[0],10),i=Number.parseInt(a[1],10),n=Number.parseInt(a[2],10)}return((n+=1)>=60&&(n=0,(i+=1)>=60&&(i=0,r+=1)),2===a.length)?"".concat(i.toString().padStart(2,"0"),":").concat(n.toString().padStart(2,"0")):"".concat(r.toString().padStart(2,"0"),":").concat(i.toString().padStart(2,"0"),":").concat(n.toString().padStart(2,"0"))}}},function(e){e.O(0,[258,717,444,971,117,744],function(){return e(e.s=1538)}),_N_E=e.O()}]);

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.