PageSourceSearch

https://antomos.com/assets/LeaderboardEmbed-BITnoSSt.js

js antomos.com collected 2026-10-09 21:32:36 UTC 7,912 bytes, 1 lines download raw bytes

1import{j as e}from"./vendor-query-BbhClgSa.js";import{r as n}from"./vendor-react-DJlnUbp9.js";import{s as g,a8 as _,G as T,S}from"./index-Bv2HMO__.js";import{U as R}from"./users-GBvzIH9h.js";import{B as A}from"./building-2-DEC2gofe.js";import{C as D,M as I}from"./medal-BNZ2NAxU.js";import{T as z}from"./trophy-DqTlX-Xf.js";import"./vendor-supabase-DOh59eXM.js";import"./vendor-motion-BOilu0ly.js";const B={grand_total:0,canada_total:0,partner_total:0,mangrove_total:0,usa_total:0,total_contributors:0,planters:[],recent:[]},O=[{key:"community",label:"Community"},{key:"partner",label:"Partners"},{key:"recent",label:"Most recent"}],M=t=>{const p=Math.floor((Date.now()-new Date(t).getTime())/1e3);if(p<60)return"just now";const d=Math.floor(p/60);if(d<60)return`${d}m ago`;const c=Math.floor(d/60);if(c<24)return`${c}h ago`;const i=Math.floor(c/24);if(i<30)return`${i}d ago`;const m=Math.floor(i/30);return m<12?`${m}mo ago`:`${Math.floor(m/12)}y ago`},$=t=>t==="mangrove"?"Kenya Mangroves":t==="partner"?"Canada · Partner":"Canada · Community",P=t=>t===1?e.jsx(D,{className:"h-4 w-4 text-medal-gold"}):t===2?e.jsx(I,{className:"h-4 w-4 text-medal-silver"}):t===3?e.jsx(z,{className:"h-4 w-4 text-medal-bronze"}):e.jsxs("span",{className:"text-xs font-semibold text-muted-foreground",children:["#",t]}),G=t=>t===1?"bg-medal-gold-bg border-medal-gold":t===2?"bg-medal-silver-bg border-medal-silver":t===3?"bg-medal-bronze-bg border-medal-bronze":"bg-card border-border/60",W=()=>{const[t,p]=n.useState(B),[d,c]=n.useState(0),[i,m]=n.useState(!0),[o,L]=n.useState("community"),[b,w]=n.useState(!1),u=n.useRef(null),N=async()=>{const{data:r,error:s}=await g.rpc("get_leaderboard_embed");!s&&r&&p(r);const{data:a}=await g.rpc("get_country_participation");Array.isArray(a)&&c(a.length),m(!1)};n.useEffect(()=>{N();const r=g.channel(`embed-leaderboard-${Math.random().toString(36).slice(2)}`).on("postgres_changes",{event:"*",schema:"public",table:"realtime_pulse"},()=>N()).subscribe();return()=>{g.removeChannel(r)}},[]),n.useLayoutEffect(()=>{if(typeof window>"u"||window.self===window.top)return;let r=0;const s=()=>{const l=u.current;if(!l)return;const f=Math.ceil(l.getBoundingClientRect().height);f&&Math.abs(f-r)>1&&(r=f,window.parent.postMessage({type:"ANTOMOS_LEADERBOARD_HEIGHT",height:f,source:"antomos-leaderboard"},"*"))};s();const a=new ResizeObserver(s);u.current&&a.observe(u.current),window.addEventListener("resize",s);const x=window.setInterval(s,1e3);return()=>{a.disconnect(),window.removeEventListener("resize",s),window.clearInterval(x)}},[]);const k=n.useMemo(()=>o==="community"?t.canada_total:o==="partner"?t.partner_total:t.grand_total,[o,t]),h=n.useMemo(()=>t.planters.filter(r=>r.project===o).sort((r,s)=>s.total_trees-r.total_trees),[t,o]),C=n.useMemo(()=>o==="recent"?[...t.recent].sort((r,s)=>new Date(s.created_at).getTime()-new Date(r.created_at).getTime()):t.recent.filter(r=>r.project===o),[t,o]),E=n.useMemo(()=>o==="recent"?t.total_contributors:h.length,[o,t.total_contributors,h.length]),y=o==="recent",j=y?C:h,v=b?j.slice(0,50):j.slice(0,10);return e.jsx("div",{ref:u,className:"w-full bg-transparent",children:e.jsxs("div",{className:"mx-auto w-full max-w-4xl px-3 py-4 sm:px-4 sm:py-6",children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 sm:gap-3",children:[e.jsxs("div",{className:"rounded-xl border border-border/60 bg-card px-3 py-3 text-center sm:px-4 sm:py-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-xs uppercase tracking-wide text-muted-foreground",children:[e.jsx(_,{className:"h-3.5 w-3.5 text-primary"})," Trees funded"]}),e.jsx("p",{className:"mt-1 text-2xl font-bold text-primary sm:text-3xl",children:k.toLocaleString()})]}),e.jsxs("div",{className:"rounded-xl border border-border/60 bg-card px-3 py-3 text-center sm:px-4 sm:py-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-xs uppercase tracking-wide text-muted-foreground",children:[e.jsx(R,{className:"h-3.5 w-3.5 text-primary"})," Supporters"]}),e.jsx("p",{className:"mt-1 text-2xl font-bold text-foreground sm:text-3xl",children:E.toLocaleStr
1ing()})]}),e.jsxs("div",{className:"rounded-xl border border-border/60 bg-card px-3 py-3 text-center sm:px-4 sm:py-4",children:[e.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-xs uppercase tracking-wide text-muted-foreground",children:[e.jsx(T,{className:"h-3.5 w-3.5 text-primary"})," Countries"]}),e.jsx("p",{className:"mt-1 text-2xl font-bold text-foreground sm:text-3xl",children:d.toLocaleString()})]})]}),e.jsx("div",{className:"mt-3 flex flex-wrap gap-1.5 sm:mt-4 sm:gap-2",children:O.map(r=>e.jsx("button",{onClick:()=>{L(r.key),w(!1)},className:`rounded-full border px-3 py-1.5 text-xs font-semibold transition-colors sm:text-sm ${o===r.key?"border-primary bg-primary text-primary-foreground":"border-border/60 bg-card text-muted-foreground hover:bg-secondary"}`,children:r.label},r.key))}),e.jsx("div",{className:"mt-3 space-y-2 sm:mt-4",children:i?[...Array(5)].map((r,s)=>e.jsx("div",{className:"h-14 animate-pulse rounded-xl bg-secondary/60"},s)):v.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-border bg-card/60 px-4 py-8 text-center",children:[e.jsx(S,{className:"mx-auto h-6 w-6 text-muted-foreground"}),e.jsx("p",{className:"mt-2 text-sm font-semibold text-foreground",children:"No supporters here yet"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Be the first to fund trees for this project."})]}):v.map((r,s)=>{if(y){const l=r;return e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border/60 bg-card p-2.5 sm:p-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-foreground sm:text-base",children:l.display_name}),l.message&&e.jsxs("p",{className:"mt-0.5 line-clamp-2 text-xs italic text-muted-foreground sm:text-sm",children:["“",l.message.trim(),"”"]}),e.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground sm:text-xs",children:[$(l.project)," · ",M(l.created_at)]})]}),e.jsxs("span",{className:"flex-shrink-0 rounded-full bg-primary/10 px-2.5 py-1 text-sm font-bold text-primary sm:text-base",children:["+",l.trees.toLocaleString()]})]},`${l.display_name}-${l.created_at}-${s}`)}const a=r,x=s+1;return e.jsxs("div",{className:`flex items-start gap-2.5 rounded-xl border p-2.5 sm:gap-3 sm:p-3 ${G(x)}`,children:[e.jsx("div",{className:"flex h-7 w-7 flex-shrink-0 items-center justify-center",children:P(x)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-semibold text-foreground sm:text-base",children:a.display_name}),a.message&&e.jsxs("p",{className:"mt-0.5 line-clamp-2 text-xs italic text-muted-foreground sm:text-sm",children:["“",a.message.trim(),"”"]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground sm:text-xs",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-secondary px-2 py-0.5",children:[a.project==="mangrove"?e.jsx(S,{className:"h-3 w-3 text-primary"}):a.project==="partner"?e.jsx(A,{className:"h-3 w-3 text-primary"}):e.jsx(_,{className:"h-3 w-3 text-primary"}),$(a.project)]}),e.jsx("span",{children:M(a.last_order_date)})]})]}),e.jsx("div",{className:"flex-shrink-0 rounded-full bg-primary/10 px-2.5 py-1 text-sm font-bold text-primary sm:text-base",children:a.total_trees.toLocaleString()})]},`${a.display_name}-${a.project}-${x}`)})}),j.length>10&&e.jsx("div",{className:"mt-3 text-center",children:e.jsx("button",{onClick:()=>w(!b),className:"rounded-full border border-border/60 bg-card px-4 py-1.5 text-xs font-semibold text-foreground transition-colors hover:bg-secondary sm:text-sm",children:b?"Show less":y?"See more activity":"See more supporters"})})]})})};export{W 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.