PageSourceSearch

https://edgemxtiming.com/assets/TvResultsPage-CWu-Oe7K.js

js edgemxtiming.com collected 2026-09-24 14:42:53 UTC 14,808 bytes, 1 lines download raw bytes

1import{P as V,r as c,j as e,b as L,S as P,n as R,o as D,q as M,t as $,I as q,B as K,l as Y,s as H,v as J,X as Q}from"./index-BCH4IFx8.js";import{C as G,b as U,c as W,d as X,a as Z}from"./card-DaE3Hwfn.js";import{C as O}from"./checkbox-D7mWENF4.js";import{u as ee,d as se}from"./useTimingEvents-C-M7e7gJ.js";import{T as te}from"./tv-CkcHwQXY.js";import{P as B}from"./play-CSYR7nMW.js";import{B as ne}from"./BpSpinner-Bqvfph1h.js";import{P as le}from"./pause-DOsmbfPg.js";import{C as re}from"./chevron-left-BfsUvDbz.js";import{M as ae}from"./minimize-7UgKNdFY.js";import{M as ie}from"./maximize-Drdx8_u2.js";const A=r=>`tv-results:${r??"anon"}`;function ce({onStart:r}){const{currentOrganization:s}=V(),t=s==null?void 0:s.id,{data:n=[],isLoading:x}=ee(t),m=c.useMemo(()=>se(n),[n]),[o,h]=c.useState(""),[w,d]=c.useState(""),[f,b]=c.useState(15),[j,p]=c.useState(!1);c.useEffect(()=>{if(t)try{const a=localStorage.getItem(A(t));if(!a)return;const u=JSON.parse(a);typeof u.secondsPerClass=="number"&&b(u.secondsPerClass),typeof u.includeEmpty=="boolean"&&p(u.includeEmpty),typeof u.labEventId=="string"&&d(u.labEventId),typeof u.year=="string"&&h(u.year)}catch{}},[t]),c.useEffect(()=>{!o&&m.length>0&&h(String(m[0]))},[m,o]);const v=c.useMemo(()=>o?n.filter(a=>a.event_date&&a.event_date.slice(0,4)===o).sort((a,u)=>(u.event_date??"").localeCompare(a.event_date??"")):[],[n,o]),N=()=>{const a=n.find(C=>C.id===w);if(!a)return;const u={labEventId:w,eventName:a.display_name||a.event_name,secondsPerClass:Math.max(5,Math.min(120,f||15)),includeEmpty:j};if(t)try{localStorage.setItem(A(t),JSON.stringify({...u,year:o}))}catch{}r(u)};return e.jsxs(G,{className:"max-w-2xl",children:[e.jsxs(U,{children:[e.jsxs(W,{className:"flex items-center gap-2",children:[e.jsx(te,{className:"h-5 w-5 text-primary"}),"TV Results Display"]}),e.jsx(X,{children:"Rotate live and final race results full-screen on a TV. Pick an event, set how long each class shows, then start the display."})]}),e.jsxs(Z,{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"year",children:"Year"}),e.jsxs(P,{value:o,onValueChange:a=>{h(a),d("")},disabled:x,children:[e.jsx(R,{id:"year",children:e.jsx(D,{placeholder:x?"Loading…":"Choose a year"})}),e.jsx(M,{children:m.map(a=>e.jsx($,{value:String(a),children:a},a))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"event",children:"Event"}),e.jsxs(P,{value:w,onValueChange:d,disabled:!o||v.length===0,children:[e.jsx(R,{id:"event",children:e.jsx(D,{placeholder:o?v.length===0?"No events for this year":"Choose an event":"Pick a year first"})}),e.jsx(M,{children:v.map(a=>e.jsxs($,{value:a.id,children:[a.display_name||a.event_name,a.event_date?` — ${a.event_date}`:""]},a.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(L,{htmlFor:"seconds",children:"Seconds per class"}),e.jsx(q,{id:"seconds",type:"number",min:5,max:120,value:f,onChange:a=>b(parseInt(a.target.value||"15",10)),className:"w-32"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(O,{id:"includeEmpty",checked:j,onCheckedChange:a=>p(!!a)}),e.jsx(L,{htmlFor:"includeEmpty",className:"font-normal cursor-pointer",children:"Include classes with no results yet"})]}),e.jsx("div",{className:"pt-2",children:e.jsxs(K,{onClick:N,disabled:!w,size:"lg",className:"gap-2",children:[e.jsx(B,{className:"h-4 w-4"}),"Start TV Display"]})}),e.jsxs("p",{className:"text-xs text-muted-foreground pt-2",children:["Tip: once running, press ",e.jsx("kbd",{className:"px-1 border rounded text-[10px]",children:"F"})," for fullscreen,",e.jsx("kbd",{className:"px-1 border rounded text-[10px] ml-1",children:"Space"})," to pause,",e.jsx("kbd",{className:"px-1 border rounded text-[10px] ml-1",children:"←"}),"/",e.jsx("kbd",{className:"px-1 border rounded text-[10px]",children:"→"})," to step."]})]})]})}function oe({orgSlug:r,labEventId:s,enabled:t=!0}){return Y({queryKey:["tv-results",r,s],enabled:!!r&&!!s&&t,refetchInterval:2e4,refetchOnWindowFocus:!1,queryFn:async()=>{const{data:n,error:x}=await H.functions.invoke("fetch-public-lab-event-results",{body:{org_slug:r,lab_event_id:s,class_name:"ALL"}});if(x)throw x;const m=n??{};return{event_name:m.event_name??"",moto_format:m.moto_format??"",classes:m.classes??[],motos_per_class:m.motos_per_class??{},rows:m.rows??[],is_endurance:!!m.is_endurance}}})}function de(r){return r.toLocaleTimeString("en-US",{timeZone:"America/Denver",hour:"numeric",minute:"2-digit",hour12:!0})}function me({values:r,onExit:s}){const{currentOrganization:t}=V(),{data:n,isLoading:x,isError:m}=oe({orgSlug:t==null?void 0:t.slug,labEventId:r.labEventId}),o=c.useMemo(()=>
1{if(!n)return[];const l=new Map;for(const i of n.rows)l.set(i.class_name,(l.get(i.class_name)??0)+1);return n.classes.filter(i=>r.includeEmpty||(l.get(i)??0)>0)},[n,r.includeEmpty]),[h,w]=c.useState(0),[d,f]=c.useState(!1),[b,j]=c.useState(()=>new Date),[p,v]=c.useState(0),[N,a]=c.useState(!1),[u,C]=c.useState(!0),_=c.useRef(null);c.useEffect(()=>{if(o.length===0){w(0);return}h>=o.length&&w(0)},[o,h]),c.useEffect(()=>{if(d||o.length<=1)return;const l=r.secondsPerClass*1e3,i=window.setInterval(()=>{w(S=>o.length===0?0:(S+1)%o.length)},l);return()=>window.clearInterval(i)},[d,o.length,r.secondsPerClass,p]),c.useEffect(()=>{const l=window.setInterval(()=>j(new Date),1e3);return()=>window.clearInterval(l)},[]),c.useEffect(()=>{const l=()=>a(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",l),()=>document.removeEventListener("fullscreenchange",l)},[]);const F=async()=>{try{document.fullscreenElement?await document.exitFullscreen():await document.documentElement.requestFullscreen()}catch{}},k=l=>{w(i=>o.length===0?0:((i+l)%o.length+o.length)%o.length),v(i=>i+1)};c.useEffect(()=>{const l=i=>{i.key==="f"||i.key==="F"?(i.preventDefault(),F()):i.key===" "?(i.preventDefault(),f(S=>!S)):i.key==="ArrowRight"?(i.preventDefault(),k(1)):i.key==="ArrowLeft"?(i.preventDefault(),k(-1)):i.key==="Escape"&&!document.fullscreenElement&&(i.preventDefault(),s())};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[o.length,s]),c.useEffect(()=>{const l=()=>{C(!0),_.current&&window.clearTimeout(_.current),_.current=window.setTimeout(()=>C(!1),3e3)};return l(),window.addEventListener("mousemove",l),window.addEventListener("keydown",l),()=>{window.removeEventListener("mousemove",l),window.removeEventListener("keydown",l),_.current&&window.clearTimeout(_.current)}},[]);const y=o[h]??null,g=c.useMemo(()=>!n||!y?[]:n.rows.filter(l=>l.class_name===y).sort((l,i)=>parseInt(l.position,10)-parseInt(i.position,10)),[n,y]),I=y&&(n==null?void 0:n.motos_per_class[y])||0,T=!!(n!=null&&n.is_endurance),z=c.useMemo(()=>{if(T||!I||g.length===0)return!1;for(const l of g)for(let i=1;i<=I;i++){const S=l.moto_finishes[String(i)];if(!S||S==="DNS")return!0}return!1},[g,I,T]);return e.jsxs("div",{className:"fixed inset-0 z-50 bg-black text-white flex flex-col overflow-hidden",style:{cursor:u?"default":"none"},children:[e.jsxs("div",{className:"flex items-center justify-between px-8 py-4 border-b border-white/10",children:[e.jsxs("div",{className:"flex items-center gap-4 min-w-0",children:[t!=null&&t.logo_url?e.jsx("img",{src:t.logo_url,alt:"",className:"h-12 w-12 object-contain rounded bg-white/5 p-1"}):null,e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-xs uppercase tracking-widest text-white/60",children:(t==null?void 0:t.name)??""}),e.jsx("div",{className:"text-2xl font-bold truncate",children:(n==null?void 0:n.event_name)||r.eventName})]})]}),e.jsx("div",{className:"text-center",children:y?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsx("div",{className:"text-4xl font-extrabold tracking-tight",children:y}),z?e.jsxs("span",{className:"inline-flex items-center gap-2 px-3 py-1 rounded-full bg-red-600 text-white text-sm font-bold uppercase",children:[e.jsx("span",{className:"h-2 w-2 rounded-full bg-white animate-pulse"}),"Live"]}):e.jsx("span",{className:"inline-flex items-center px-3 py-1 rounded-full bg-emerald-600 text-white text-sm font-bold uppercase",children:"Final"})]}),e.jsxs("div",{className:"text-sm text-white/60 mt-1",children:["Class ",h+1," of ",o.length]})]}):e.jsx("div",{className:"text-2xl text-white/60",children:x?"Loading results…":"No classes to display"})}),e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-2xl font-mono font-bold",children:de(b)}),e.jsx("div",{className:"text-xs text-white/50 uppercase tracking-wider",children:"MT"})]})})]}),e.jsx("div",{className:"flex-1 overflow-hidden px-8 py-6",children:x?e.jsxs("div",{className:"h-full flex items-center justify-center text-white/60",children:[e.jsx(ne,{className:"h-8 w-8 animate-spin mr-3"}),e.jsx("span",{className:"text-xl",children:"Loading results…"})]}):m?e.jsx("div",{className:"h-full flex items-center justify-center text-red-400 text-xl",children:"Failed to load results."}):y&&g.length>0?T?e.jsx(he,{rows:g}):e.jsx(ue,{rows:g,motoCount:I}):y?e.jsx("div",{className:"h-full flex items-center justify-center text-white/50 text-2xl",children:"No results posted yet for this class."}):null}),o.length>1&&e.jsx("div",{className:"px-8 py-3 border-t border-white/10 flex items-center justify-center gap-1.5",children:o.map((l,i)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${i===h?"bg-white w-8":"bg-white/25 w-1.5"}`},l))}),e.jsxs("div",{className:`absolute top-3 right-3 flex items-center gap-2 transition-opacity duration-300 ${u?"opacity-100":"opacity-0 pointer-events-none"}`,children:[e.jsx(E,{label:d?"Resume":"Pause",onClick:()=>f(l=>!l),children:d?e.jsx(B,{className:"h-4 w-4"}):e.jsx(le,{className:"h-4 w-4"})}),e.jsx(E,{label:"Previous",onClick:()=>k(-1),children:e.jsx(re,{className:"h-4 w-4"})}),e.jsx(E,{label:"Next",onClick:()=>k(1),children:e.jsx(J,{className:"h-4 w-4"})}),e.jsx(E,{label:N?"Exit fullscreen":"Fullscreen",onClick:F,children:N?e.jsx(ae,{className:"h-4 w-4"}):e.jsx(ie,{className:"h-4 w-4"})}),e.jsx(E,{label:"Exit",onClick:s,children:e.jsx(Q,{className:"h-4 w-4"})})]})]})}function E({children:r,onClick:s,label:t}){return e.jsx("button",{onClick:s,title:t,"aria-label":t,className:"h-9 w-9 inline-flex items-center justify-center rounded-md bg-white/10 hover:bg-white/20 text-white",children:r})}function ue({rows:r,motoCount:s}){const t=c.useRef(null),n=c.useRef(null),[x,m]=c.useState(28),[o,h]=c.useState(!1);c.useEffect(()=>{m(28),h(!1);let d=!1;const f=()=>{if(d)return;const j=t.current,p=n.current;if(!j||!p)return;const v=[28,26,24,22,20,18,16,14];for(const N of v)if(p.style.fontSize=`${N}px`,p.scrollHeight<=j.clientHeight+2){m(N),h(!1);return}m(14),h(!0)},b=window.requestAnimationFrame(f);return()=>{d=!0,window.cancelAnimationFrame(b)}},[r,s]);const w=Array.from({length:s},(d,f)=>f+1);return e.jsx("div",{ref:t,className:"h-full w-full overflow-hidden relative",children:e.jsx("div",{ref:n,className:o?"tv-results-scroll":"",style:{fontSize:`${x}px`},children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-white/70 uppercase tracking-wider border-b-2 border-white/20",style:{fontSize:"0.65em"},children:[e.jsx("th",{className:"text-left py-3 px-3 w-[6%]",children:"Pos"}),e.jsx("th",{className:"text-left py-3 px-3 w-[8%]",children:"#"}),e.jsx("th",{className:"text-left py-3 px-3",children:"Rider"}),e.jsx("th",{className:"text-left py-3 px-3 w-[10%]",children:"Make"}),e.jsx("th",{className:"text-left py-3 px-3 w-[18%]",children:"Hometown"}),w.map(d=>e.jsxs("th",{className:"text-center py-3 px-3 w-[7%]",children:["M",d]},d)),e.jsx("th",{className:"text-right py-3 px-3 w-[8%]",children:"Pts"})]})}),e.jsx("tbody",{children:r.map(d=>{const f=parseInt(d.position,10),b=f===1?"text-yellow-300":f===2?"text-slate-200":f===3?"text-amber-500":"";return e.jsxs("tr",{className:"border-b border-white/5 hover:bg-white/[0.03]",children:[e.jsx("td",{className:`py-2.5 px-3 font-extrabold tabular-nums ${b}`,children:d.position}),e.jsx("td",{className:"py-2.5 px-3 font-bold tabular-nums",children:d.rider_number??""}),e.jsx("td",{className:"py-2.5 px-3 font-semibold truncate",children:d.rider_name}),e.jsx("td",{className:"py-2.5 px-3 text-white/80 uppercase",children:d.make}),e.jsx("td",{className:"py-2.5 px-3 text-white/70 truncate",children:[d.city,d.state].filter(
1Boolean).join(", ")}),w.map(j=>{const p=d.moto_finishes[String(j)],v=p==="DNF"||p==="DSQ"||p==="DNS";return e.jsx("td",{className:`py-2.5 px-3 text-center tabular-nums ${v?"text-white/40 text-[0.85em]":"font-bold"}`,children:p||"—"},j)}),e.jsx("td",{className:"py-2.5 px-3 text-right font-extrabold tabular-nums",children:d.points})]},`${d.position}-${d.rider_name}`)})})]})})})}function xe(r){if(!r||r<=0)return"—";const s=r/1e3,t=Math.floor(s/60),n=s-t*60;return t>0?`${t}:${n.toFixed(3).padStart(6,"0")}`:n.toFixed(3)}function he({rows:r}){return e.jsx("div",{className:"h-full w-full overflow-hidden",children:e.jsxs("table",{className:"w-full border-collapse",style:{fontSize:24},children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-white/70 uppercase tracking-wider border-b-2 border-white/20",style:{fontSize:"0.65em"},children:[e.jsx("th",{className:"text-left py-3 px-3 w-[6%]",children:"Pos"}),e.jsx("th",{className:"text-left py-3 px-3 w-[8%]",children:"#"}),e.jsx("th",{className:"text-left py-3 px-3",children:"Team"}),e.jsx("th",{className:"text-center py-3 px-3 w-[10%]",children:"Laps"}),e.jsx("th",{className:"text-right py-3 px-3 w-[14%]",children:"Best Lap"})]})}),e.jsx("tbody",{children:r.map(s=>{var x;const t=parseInt(s.position,10),n=t===1?"text-yellow-300":t===2?"text-slate-200":t===3?"text-amber-500":"";return e.jsxs("tr",{className:"border-b border-white/5",children:[e.jsx("td",{className:`py-2.5 px-3 font-extrabold tabular-nums ${n}`,children:s.position}),e.jsx("td",{className:"py-2.5 px-3 font-bold tabular-nums",children:s.rider_number??""}),e.jsxs("td",{className:"py-2.5 px-3",children:[e.jsx("div",{className:"font-semibold truncate",children:s.rider_name}),(x=s.team_members)!=null&&x.length?e.jsx("div",{className:"text-white/60 truncate",style:{fontSize:"0.6em"},children:s.team_members.join(" · ")}):null]}),e.jsx("td",{className:"py-2.5 px-3 text-center font-extrabold tabular-nums",children:s.laps??0}),e.jsx("td",{className:"py-2.5 px-3 text-right tabular-nums",children:xe(s.best_lap_ms)})]},`${s.position}-${s.rider_name}`)})})]})})}function Ee(){const[r,s]=c.useState(null);return r?e.jsx(me,{values:r,onExit:()=>s(null)}):e.jsx("div",{className:"container max-w-5xl py-6",children:e.jsx(ce,{onStart:s})})}export{Ee 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.