1import{l as e,k as t,r as s,n as a,s as l,j as r,b as c,L as n,B as d,o,p as x,q as i}from"./index-BjVDSkG8.js";import"./phaser-D3nDARRP.js";function m(){var m;const{game:h}=e(),b=t(),[g,u]=s.useState([]),[f,p]=s.useState(!0),[j,N]=s.useState(null),[v,y]=s.useState(null),[w,S]=s.useState(1),[C,k]=s.useState(1),[L,P]=s.useState(!1),[E,M]=s.useState(!1),[D,F]=s.useState([]),[T,B]=s.useState(!1),[q,z]=s.useState(!0);s.useEffect((()=>{h.firebaseCollection||(z(!1),p(!1))}),[h.firebaseCollection]),s.useEffect((()=>{var e;if(null==(e=b.state)?void 0:e.successMessage){y(b.state.successMessage),window.history.replaceState({},document.title);const e=setTimeout((()=>{y(null)}),5e3);return()=>clearTimeout(e)}}),[b.state]);const A=null==(m=b.state)?void 0:m.submittedUsername,H=s.useCallback((async(e=1)=>{if(h.firebaseCollection){p(!0),N(null);try{const t=await a(h.firebaseCollection,e);t.success?(u(t.scores),S(t.page),k(t.totalPages),P(t.hasMore||!1),M(t.fromCache||!1),t.fromCache&&(B(!0),setTimeout((()=>B(!1)),2e3))):N(t.error||"Failed to load leaderboard")}catch(t){N("Failed to load leaderboard")}finally{p(!1)}}else p(!1)}),[h.firebaseCollection]);s.useEffect((()=>{q&&H(w)}),[w,H,q]),s.useEffect((()=>{if(!q||!h.firebaseCollection)return;const e=l(h.firebaseCollection,((e,t)=>{t||e&&(F(e),B(!0),setTimeout((()=>B(!1)),3e3),1!==w||E||H(1))}));return()=>{e()}}),[h.firebaseCollection,w,E,H,q]);const I=s.useMemo((()=>{var e,t;return(null==(e=D[0])?void 0:e.score)||(null==(t=g[0])?void 0:t.score)||0}),[g,D]),R=s.useMemo((()=>I.toLocaleString()),[I]),U=s.useMemo((()=>D.length||g.length),[g,D]);return f?r.jsx("div",{className:"max-w-3xl pt-4 mx-auto px-2 lg:px-0 h-screen",children:r.jsxs("div",{className:"text-center py-12",children:[r.jsx(c,{size:"lg",className:"justify-center",count:5,duration:.6}),r.jsx("p",{className:"mt-4 text-xl text-(--accent)",children:"Loading leaderboard..."})]})}):q?j?r.jsxs("div",{className:"max-w-3xl pt-4 mx-auto px-2 lg:px-0 h-screen",children:[r.jsx("div",{className:"flex mb-4 flex-col justify-center items-center text-(--foreground)",children:r.jsx("h2",{className:"text-2xl lg:text-3xl font-bold text-center text-(--foreground)",children:"Dashy Flap Leaderboard"})}),r.jsxs("div",{className:"bg-red-900/30 border border-red-700 text-red-300 px-6 py-8 rounded-2xl text-center",children:[r.jsx("p",{className:"text-xl",children:j}),r.jsx("p",{className:"mt-2",children:"Could not connect to the leaderboard. Please try again later."})]})]}):r.jsxs("div",{className:"max-w-3xl pt-4 mx-auto px-2 lg:px-0 h-fit pb-4",children:[r.jsx("div",{className:"flex flex-col items-center mb-6",children:r.jsx("h2",{className:"text-2xl lg:text-3xl font-bold text-center text-(--foreground)",children:"Leaderboard"})}),r.jsxs("div",{className:"flex justify-center items-center gap-6 mb-4 text-sm lg:text-lg",children:[r.jsxs("div",{className:"bg-(--card) px-4 py-2 rounded-lg border border-(--border) text-center",children:[r.jsx("div",{className:"text-(--accent) font-bold text-xl",children:R}),r.jsx("div",{className:"text-(--secondary-foreground) text-xs",children:"High Score"})]}),r.jsxs("div",{className:"bg-(--card) px-4 py-2 rounded-lg border border-(--border) text-center",children:[r.jsx("div",{className:"text-(--accent) font-bold text-xl",children:U}),r.jsx("div",{className:"text-(--secondary-foreground) text-xs",children:"Entries"})]}),r.jsxs("div",{className:"bg-(--card) px-4 py-2 rounded-lg border border-(--border) text-center",children:[r.jsxs("div",{className:"text-(--accent) font-bold text-xl",children:[w,"/",C]}),r.jsx("div",{className:"text-(--secondary-foreground) text-xs",children:"Page"})]})]}),T&&r.jsx("div",{className:"text-center mb-2",children:r.jsx("span",{className:"px-2 py-1 text-xs bg-green-500 text-white rounded-full animate-pulse",children:"LIVE"})}),v&&r.jsxs("div",{className:"mb-4 p-4 bg-(--accent)/90 text-(--foreground) text-center rounded-lg",children:[r.jsx("p",{className:"text-lg font-bold",children:"Score submitted!"}),r.jsx("p",{children:v})]}),r.jsx("div",{className:"flex justify-center mb-6",children:r.jsx(n,{to:h.routes.game,children:r.jsx(d,{className:"lg:text-3xl tracking-[-1px] font-normal lg:font-bold text-2xl text-black bg-(--accent)! flex items-center gap-2",children:"Play Again"})})}),r.jsx("div",{className:"w-full px-2 text-(--secondary-foreground) bg-(--card) inline-block transition-all hover:shadow-none border border-(--border) rounded-lg overflow-hidden",children:0===g.length?r.jsxs("div",{className:"p-8 text-center",children:[r.jsx("h3",{className:"text-2xl font-bold mb-2",children:"No scores yet!"}),r.jsx("p",{children:"Be the first to top the leaderboard!"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"grid grid-cols-12 gap-2 px-4 py-3 bg-(--muted) text-(--accent) font-bold text-sm lg:text-lg border-b border-(--border)",children:[r.jsx("div",{className:"col-span-1 text-center",children:"#"}),r.jsx("div",{className:"col-span-5",children:"Player"}),r.jsx("div",{className:"col-span-3 text-right",children:"Score"}),r.jsx("div",{className:"col-span-3 text-right",children:"Date"})]}),r.jsx("div",{children:g.map(((e,t)=>{const s=20*(w-1)+t,a=e.name===A,l=t<3,c=0===t?"ð¥":1===t?"ð¥":2===t?"ð¥":null;return r.jsxs("div",{className:"grid grid-cols-12 gap-2 px-4 py-3 items-center text-sm lg:text-lg border-b border-(--border)/50 "+(a?"bg-(--accent)/20 border-l-4 border-(--accent)":l?"bg-(--muted)/30":""),children:[r.jsx("div",{className:"col-span-1 text-center",children:c||r.jsx("span",{className:"text-(--secondary-foreground)",children:s+1})}),r.jsx("div",{className:"col-span-5 flex items-center gap-2",children:r.jsx("span",{className:a?"text-(--accent) font-bold":"",children:e.name})}),r.jsx("div",{className:"col-span-3 text-right font-bold",children:e.score.toLocaleStr
1ing()}),r.jsx("div",{className:"col-span-3 text-right text-xs text-(--secondary-foreground)",children:e.formattedDate})]},e.id)}))})]})}),r.jsxs("div",{className:"flex justify-center items-center mt-4 gap-4",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx(d,{onClick:()=>{w>1&&S((e=>e-1))},disabled:1===w,className:"px-3 py-1 text-sm disabled:opacity-50 flex items-center justify-center",children:r.jsx(o,{className:"h-4 w-4"})}),r.jsxs("span",{className:"px-3 py-1 bg-(--card) border border-(--border) rounded text-sm text-(--foreground)",children:[w," / ",C]}),r.jsx(d,{onClick:()=>{L&&S((e=>e+1))},disabled:!L,className:"px-3 py-1 text-sm disabled:opacity-50 flex items-center justify-center",children:r.jsx(x,{className:"h-4 w-4"})})]}),r.jsx(d,{onClick:()=>{i(),H(w)},className:"px-3 py-1 text-sm bg-(--muted) hover:bg-(--muted)/80 flex items-center justify-center",title:"Refresh",children:"â»"})]})]}):r.jsxs("div",{className:"max-w-3xl pt-4 mx-auto px-2 lg:px-0 h-fit pb-4",children:[r.jsx("div",{className:"flex mb-4 flex-col justify-center items-center text-(--foreground)",children:r.jsx("h2",{className:"text-2xl lg:text-3xl font-bold text-center text-(--foreground)",children:"Leaderboard"})}),r.jsx("div",{className:"flex flex-col md:flex-row justify-center items-center mb-4 gap-4",children:r.jsx(n,{to:h.routes.game,children:r.jsx(d,{className:"lg:text-3xl tracking-[-1px] font-normal lg:font-bold text-2xl text-black bg-(--accent)!",children:"Play Now"})})}),r.jsxs("div",{className:"w-full px-2 text-(--secondary-foreground) bg-(--card) inline-block transition-all hover:shadow-none p-8 text-center",children:[r.jsxs("div",{className:"flex justify-center space-x-4 mb-6",children:[r.jsx("img",{src:"/games/nfc/bird.png",alt:"Dashy Flap Bird",className:"h-16 w-auto pixelated-image"}),r.jsx("img",{src:"/games/nfc/donut_plain.png",alt:"Donut",className:"h-12 w-auto pixelated-image"})]}),r.jsx("h3",{className:"text-2xl font-bold mb-4",children:"Leaderboard Coming Soon"}),r.jsx("p",{className:"mb-6",children:"This game doesn't have a leaderboard yet. Check back later!"}),r.jsx("p",{className:"text-lg",children:"Play the game now and be ready when the leaderboard launches!"})]})]})}export{m 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.