1import{k as F,b2 as K,r as p,l as R,j as e,_ as V,S as B,w as L,x as A,y as E,z as N,I as z,B as X,a0 as Q,X as G,s as I}from"./index-Ct8eLu1I.js";import{u as H}from"./useSelectedTimingEvent-IKCMbW8S.js";import{B as J}from"./BikeMakeBadge-CLPRnHpn.js";import{u as U}from"./MyRidersFilterContext-B5HDUcVn.js";import{R as W}from"./RiderProfileDialog-DAi80iMe.js";import{S as Y}from"./search-BsvfnwMH.js";import{A as Z}from"./award-BLsrLjlR.js";import"./TimingSelectionContext-0R53bEzZ.js";import"./useTimingEvents-a-TBF05g.js";import"./useOrganizationSlug-Im1jCHRI.js";import"./useBikeMakeLogos-BM39csav.js";import"./bikeMakeStyle-RND07Se0.js";import"./useRiderFamily-BWVYDRiJ.js";import"./useUserEmails-DmVLOekm.js";import"./nicknameVariants-CT_QG-k6.js";import"./useRiderResults-Cb6CRYFg.js";import"./map-pin-DUB0IYFr.js";import"./flag-BttTACQc.js";import"./trophy-Bwwh5BxN.js";import"./timer-BmWXyNuG.js";import"./history-BS_575gd.js";function ee(u){const l=String(u??"").trim();if(!l)return"";if(!/^-?\d+$/.test(l))return l;const r=parseInt(l,10),i=Math.abs(r)%100;if(i>=11&&i<=13)return`${r}th`;switch(Math.abs(r)%10){case 1:return`${r}st`;case 2:return`${r}nd`;case 3:return`${r}rd`;default:return`${r}th`}}function ve(){const u=F(),l=K().bikeMakeColumn,{orgSlug:r,event:i}=H(),{matches:$,active:T}=U(),[d,b]=p.useState(null),[f,v]=p.useState("ALL"),[j,_]=p.useState(""),[w,S]=p.useState(null),k=j.trim().toLowerCase(),C=t=>S({rider_id:t.rider_id??null,member_number:t.bp_member_number||null,rider_name:t.rider_name}),{data:o}=R({queryKey:["timing-series-meta",r],queryFn:async()=>{const{data:t,error:c}=await I.functions.invoke("fetch-public-lab-series-points",{body:{org_slug:r,meta:!0}});if(c)throw c;return t??{defaultSeries:"",series:[]}},enabled:!!r,staleTime:6e4});p.useEffect(()=>{d||(i!=null&&i.series_name?b(i.series_name):o!=null&&o.defaultSeries&&b(o.defaultSeries))},[i==null?void 0:i.series_name,o==null?void 0:o.defaultSeries,d]);const{data:a,isLoading:q}=R({queryKey:["timing-series-points",r,d,f],queryFn:async()=>{if(!r||!d)return{series_name:"",classes:[],events:[],by_class:{}};const{data:t,error:c}=await I.functions.invoke("fetch-public-lab-series-points",{body:{org_slug:r,series_name:d,class_name:f}});if(c)throw c;return t??{series_name:d,classes:[],events:[],by_class:{}}},enabled:!!r&&!!d,refetchInterval:6e4});if(!d||q)return e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(V,{className:"h-6 w-6 animate-spin text-primary"})});const O=(a==null?void 0:a.events)??[],y=Object.keys((a==null?void 0:a.by_class)??{}),P=y.some(t=>a.by_class[t].some(c=>c.bonus));return e.jsxs("div",{className:"space-y-4 py-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold",children:"Series:"}),e.jsxs(B,{value:d,onValueChange:t=>{b(t),v("ALL")},children:[e.jsx(L,{className:"w-56",children:e.jsx(A,{})}),e.jsx(E,{children:((o==null?void 0:o.series)??[]).map(t=>e.jsx(N,{value:t.name,children:t.name},t.name))})]}),e.jsx("span",{className:"text-sm font-semibold",children:"Class:"}),e.jsxs(B,{value:f,onValueChange:v,children:[e.jsx(L,{className:"w-56",children:e.jsx(A,{})}),e.jsxs(E,{children:[e.jsx(N,{value:"ALL",children:"All Classes"}),((a==null?void 0:a.classes)??[]).map(t=>e.jsx(N,{value:t,children:t},t))]})]}),e.jsxs("div",{className:"relative ml-auto w-full sm:w-64",children:[e.jsx(Y,{className:"absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(z,{value:j,onChange:t=>_(t.target.value),placeholder:"Search rider by nameâ¦",className:"h-9 pl-7 pr-7"}),j&&e.jsx(X,{type:"button",variant:"ghost",size:"icon",onClick:()=>_(""),className:"absolute right-0 top-0 h-9 w-9","aria-label":"Clear search",children:e.jsx(Q,{className:"h-3.5 w-3.5"})})]})]}),!y.length&&e.jsxs("p",{className:"rounded-md border bg-card p-6 text-center text-sm text-muted-foreground",children:[e.jsx(Z,{className:"mx-auto mb-2 h-6 w-6"})," No series points available yet."]}),y.map(t=>{const c=a.by_class[t];if(!c.length)return null;const g=[...c].sort((s,m)=>m.total_points-s.total_points),M=new Map;{let s=null,m=0;g.forEach((x,n)=>{s!==x.total_points&&(m=n+1,s=x.total_points),M.set(x.member_number,m)})}let h=T?g.filter(s=>$(s.rider_name)):g;return k&&(h=h.filter(s=>s.rider_name.toLowerCase().includes(k))),h.length?e.jsxs("div",{className:"overflow-hidden rounded-md border bg-card",children:[e.jsx("div",{className:"bg-foreground px-3 py-1.5 text-xs font-bold uppercase tracking-wide text-background",children:t}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"bg-muted/50 text-muted-foreground",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-2 py-1.5 text-center",children:u.position}),!l&&e.jsx("th",{className:"px-2 py-1.5 text-center",children:u.bib}),l&&e.jsx("th",{className:"px-2 py-1.5 text-center",children:u.bikeMake||"Make"}),e.jsx("th",{className:"px-2 py-1.5 text-left",children:u.racer}),e.jsx("th",{className:"hidden px-2 py-1.5 text-left sm:table-cell",children:"City"}),e.jsx("th",{className:"hidden px-2 py-1.5 text-center sm:table-cell",children:"ST"}),e.jsx("th",{className:"px-2 py-1.5 text-right",children:"Pts"}),O.map(s=>e.jsx("th",{className:"px-2 py-1.5 text-center whitespace-nowrap",children:s.date},s.event_name))]})}),e.jsx("tbody",{children:h.map((s,m)=>{const x=M.get(s.member_number)??m+1;return e.jsxs("tr",{className:G("cursor-pointer border-t transition-colors hover:bg-muted/50 focus:bg-muted/50 focus:outline-none",s.bonus?"bg-blue-100":m%2?"bg-muted/20":""),tabIndex:0,role:"button","aria-label":`View ${s.rider_name}'s profile`,onClick:()=>C(s),onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),C(s))},children:[e.jsx("td",{className:"px-2 py-1.5 text-center font-semibold",children:x}),!l&&e.jsx("td",{className:"px-2 py-1.5 text-center font-mono",children:s.rider_number??"â"}),l&&e.jsx("td",{className:"px-1 py-1.5 text-center",children:e.jsx(J,{make:s.make,bikeNumber:s.rider_number??void 0})}),e.jsxs("td",{className:"px-2 py-1.5 align-top",children:[e.jsx("div",{className:"break-words leading-tight",children:s.rider_name}),e.jsx("div",{className:"text-[10px] text-muted-foreground sm:hidden",children:[s.city,s.state].filter(
1Boolean).join(", ")||"â"})]}),e.jsx("td",{className:"hidden px-2 py-1.5 sm:table-cell",children:s.city}),e.jsx("td",{className:"hidden px-2 py-1.5 text-center sm:table-cell",children:s.state}),e.jsx("td",{className:"px-2 py-1.5 text-right font-bold",children:s.total_points}),s.per_event.map((n,D)=>e.jsx("td",{className:"px-2 py-1.5 text-center leading-tight",children:n.dns?e.jsx("span",{className:"text-muted-foreground",children:"DNS"}):n.overall===""||n.overall==="0"?e.jsx("span",{className:"text-muted-foreground",children:"â"}):e.jsxs(e.Fragment,{children:[e.jsx("div",{children:ee(n.overall)}),e.jsxs("div",{className:"text-[10px] font-bold",children:[n.points,"pts"]})]})},D))]},s.member_number)})})]})})]},t):null}),P&&e.jsx("p",{className:"rounded-md bg-blue-50 px-3 py-2 text-xs text-blue-900",children:"* â Rider's total points include class transfer / bonus points."}),e.jsx(W,{identity:w,labEventId:null,open:!!w,onOpenChange:t=>{t||S(null)},showMake:l})]})}export{ve as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.