tokentracker-cli 0.58.0 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dashboard/dist/assets/{ActivityHeatmap--h7iLeSz.js → ActivityHeatmap-DrF_K5ys.js} +1 -1
- package/dashboard/dist/assets/{Card-KutJI7Kb.js → Card-B13p4G_t.js} +1 -1
- package/dashboard/dist/assets/DashboardPage-BCWtoeRf.js +19 -0
- package/dashboard/dist/assets/{DevicePage-Bvf6grjO.js → DevicePage-Be88eLBY.js} +1 -1
- package/dashboard/dist/assets/{DialogTitle-Cd8SHRAb.js → DialogTitle-BZmopQRt.js} +1 -1
- package/dashboard/dist/assets/{FadeIn-D_0IpM7h.js → FadeIn-BEym_KpF.js} +1 -1
- package/dashboard/dist/assets/{HeaderGithubStar-wllgUDeU.js → HeaderGithubStar-Ckhzj9HH.js} +1 -1
- package/dashboard/dist/assets/{IpCheckPage-oUeKrhWf.js → IpCheckPage-CJb8fFzg.js} +1 -1
- package/dashboard/dist/assets/{LandingPage-BqzdZPJZ.js → LandingPage-CjTv2ISs.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardAvatar-Bib0pX-r.js → LeaderboardAvatar-Cf0GnSTi.js} +1 -1
- package/dashboard/dist/assets/{LeaderboardPage-BjLZyZb-.js → LeaderboardPage-rIE2Ygw4.js} +3 -3
- package/dashboard/dist/assets/LeaderboardProfileModal-CT876wK9.js +72 -0
- package/dashboard/dist/assets/{LeaderboardProfilePage-Df_jL82E.js → LeaderboardProfilePage-EyJsH0Yf.js} +1 -1
- package/dashboard/dist/assets/{LimitsPage-BhPNmv6R.js → LimitsPage-DNg_cqiC.js} +1 -1
- package/dashboard/dist/assets/{LocalOnlyNotice-B01hqlKr.js → LocalOnlyNotice-Dz8c-3ZD.js} +1 -1
- package/dashboard/dist/assets/{LoginPage-BjqX1wZg.js → LoginPage-iekpEtgT.js} +1 -1
- package/dashboard/dist/assets/{PopoverPopup-CWyN32rM.js → PopoverPopup-BhT2-G0O.js} +1 -1
- package/dashboard/dist/assets/{ResetPasswordPage-Bw7tWm1t.js → ResetPasswordPage-B69CFuJ-.js} +1 -1
- package/dashboard/dist/assets/{Select-DbBT6mPJ.js → Select-SwlPWXxZ.js} +1 -1
- package/dashboard/dist/assets/{SelectItemText-XGWezP4M.js → SelectItemText-DpUKUC8A.js} +1 -1
- package/dashboard/dist/assets/{SettingsPage-CrA-jBWs.js → SettingsPage-_spYM3Kx.js} +1 -1
- package/dashboard/dist/assets/{SkillsPage-CfYTgQMY.js → SkillsPage-CfTvatpr.js} +1 -1
- package/dashboard/dist/assets/{WidgetsPage-DjE_NMiT.js → WidgetsPage-Cs0kJgks.js} +1 -1
- package/dashboard/dist/assets/{WrappedPage-MciuOQFt.js → WrappedPage-9EChVGEl.js} +1 -1
- package/dashboard/dist/assets/{agent-logos-JyXME_ur.js → agent-logos-LiqKeIhs.js} +1 -1
- package/dashboard/dist/assets/{arrow-up-right-U8aUNwfl.js → arrow-up-right-B7ItQsbP.js} +1 -1
- package/dashboard/dist/assets/{download-CK8DaHH6.js → download-ZBU9wTAZ.js} +1 -1
- package/dashboard/dist/assets/{info-DF9b_Lut.js → info-CExabEBS.js} +1 -1
- package/dashboard/dist/assets/{main-4M5oNV2-.js → main-CgiMNMS_.js} +3 -3
- package/dashboard/dist/assets/{use-limits-display-prefs--1a77fnk.js → use-limits-display-prefs-bSTssszE.js} +1 -1
- package/dashboard/dist/assets/{use-native-settings-PZ_s8TF_.js → use-native-settings-C3pXNNqf.js} +1 -1
- package/dashboard/dist/assets/{use-usage-limits-B11QqFl7.js → use-usage-limits-8f1hUzNE.js} +1 -1
- package/dashboard/dist/assets/{useCurrency-CzRjastg.js → useCurrency-CrMUx8Pg.js} +1 -1
- package/dashboard/dist/assets/{useScrollLock-BXcNDJbM.js → useScrollLock-BaJCW9Ak.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dashboard/dist/share.html +1 -1
- package/package.json +1 -1
- package/src/lib/pricing/curated-overrides.json +4 -2
- package/src/lib/pricing/seed-snapshot.json +1 -1
- package/src/lib/rollout.js +22 -13
- package/dashboard/dist/assets/DashboardPage-CZS3KR2C.js +0 -19
- package/dashboard/dist/assets/LeaderboardProfileModal-GiTmpwyn.js +0 -72
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import{c as D,r as g,dp as K,j as e,G as n,dq as Q,aB as ee,dr as ae,V as c,Y as re,ds as te,aD as se,L as ie,n as oe,U as T,X as ne,J as I,I as le,ae as de}from"./main-4M5oNV2-.js";import{u as ce}from"./useCurrency-CzRjastg.js";import{L as W}from"./LeaderboardAvatar-Bib0pX-r.js";import{A as me}from"./ActivityHeatmap--h7iLeSz.js";import{A as U}from"./arrow-up-right-U8aUNwfl.js";import{C as xe}from"./useScrollLock-BXcNDJbM.js";import{D as ge,a as pe,b as he,c as fe,d as be,e as ue}from"./DialogTitle-Cd8SHRAb.js";import"./info-DF9b_Lut.js";const ye=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],ke=D("code-xml",ye);const je=[["path",{d:"M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5",key:"mvr1a0"}]],ve=D("heart",je);const Ne=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],_e=D("link-2",Ne),C="tokentracker_likes";function F(a){if(!a)return!1;try{const r=localStorage.getItem(C);return r?!!JSON.parse(r)?.[a]:!1}catch{return!1}}function z(a,r){if(a)try{const t=localStorage.getItem(C),s=t?JSON.parse(t):{};r?s[a]=!0:delete s[a],localStorage.setItem(C,JSON.stringify(s))}catch{}}function E({userId:a}){const[r,t]=g.useState(!1),[s,i]=g.useState(0),[l,m]=g.useState(!1),[d,p]=g.useState(!1),[y,k]=g.useState(!1),[j,M]=g.useState([]),[v,b]=g.useState(!1),N=g.useRef(0);g.useEffect(()=>{let o=!1;return a?(m(!1),t(F(a)),K({userId:a}).then(x=>{o||(i(Number(x?.count)||0),m(!0))}).catch(()=>{o||(i(0),m(!0))}),()=>{o=!0}):(m(!1),()=>{o=!0})},[a]);const _=()=>{k(!0),setTimeout(()=>k(!1),450),b(!0),setTimeout(()=>b(!1),500);const o=["#ff4757","#ff6b81","#ffa502","#70a1ff","#2ed573","#a29bfe"],x=["circle","heart"],f=[];for(let h=0;h<12;h++){const S=(h*30+Math.random()*20-10)*(Math.PI/180),A=45+Math.random()*45,O=Math.cos(S)*A,q=Math.sin(S)*A-(10+Math.random()*15),J=Math.random()*360-180,X=6+Math.random()*8,Y=o[Math.floor(Math.random()*o.length)],V=x[Math.floor(Math.random()*x.length)],Z=++N.current;f.push({id:Z,tx:O,ty:q,rot:J,size:X,color:Y,shape:V})}M(h=>[...h,...f]),setTimeout(()=>{M(h=>h.filter(S=>!f.find(A=>A.id===S.id)))},850)},u=async o=>{p(!0);try{const x=await Q({userId:a,delta:o}),f=Number(x?.count);Number.isFinite(f)&&i(f)}catch{t(x=>!x),i(x=>Math.max(0,x-o)),z(a,!F(a))}finally{p(!1)}},w=o=>{o.stopPropagation(),!(!a||!l||d)&&(r?(t(!1),i(x=>Math.max(0,x-1)),z(a,!1),u(-1)):(t(!0),i(x=>x+1),z(a,!0),_(),u(1)))};return e.jsxs("div",{className:"relative inline-flex items-center select-none z-10",children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
2
|
-
@keyframes tt-like-pop {
|
|
3
|
-
0% { transform: scale(1); }
|
|
4
|
-
25% { transform: scale(0.75); }
|
|
5
|
-
50% { transform: scale(1.35); }
|
|
6
|
-
75% { transform: scale(0.9); }
|
|
7
|
-
100% { transform: scale(1); }
|
|
8
|
-
}
|
|
9
|
-
@keyframes tt-particle-fly {
|
|
10
|
-
0% {
|
|
11
|
-
transform: translate(0, 0) scale(1) rotate(0deg);
|
|
12
|
-
opacity: 1;
|
|
13
|
-
}
|
|
14
|
-
70% {
|
|
15
|
-
opacity: 0.8;
|
|
16
|
-
}
|
|
17
|
-
100% {
|
|
18
|
-
transform: translate(var(--tx), var(--ty)) scale(0.2) rotate(var(--rot));
|
|
19
|
-
opacity: 0;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
@keyframes tt-num-scroll {
|
|
23
|
-
0% { transform: translateY(8px); opacity: 0; }
|
|
24
|
-
100% { transform: translateY(0); opacity: 1; }
|
|
25
|
-
}
|
|
26
|
-
.tt-animate-pop {
|
|
27
|
-
animation: tt-like-pop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
|
|
28
|
-
}
|
|
29
|
-
.tt-particle {
|
|
30
|
-
position: absolute;
|
|
31
|
-
top: 50%;
|
|
32
|
-
left: 50%;
|
|
33
|
-
margin-top: -6px;
|
|
34
|
-
margin-left: -6px;
|
|
35
|
-
pointer-events: none;
|
|
36
|
-
z-index: 50;
|
|
37
|
-
}
|
|
38
|
-
.tt-num-anim {
|
|
39
|
-
animation: tt-num-scroll 0.25s ease-out forwards;
|
|
40
|
-
}
|
|
41
|
-
`}}),j.map(o=>e.jsx("span",{className:"tt-particle",style:{"--tx":`${o.tx}px`,"--ty":`${o.ty}px`,"--rot":`${o.rot}deg`,width:`${o.size}px`,height:`${o.size}px`,backgroundColor:o.shape==="circle"?o.color:"transparent",borderRadius:o.shape==="circle"?"50%":"0",animation:"tt-particle-fly 0.8s cubic-bezier(0.1, 0.8, 0.3, 1) forwards"},children:o.shape==="heart"&&e.jsx("svg",{viewBox:"0 0 24 24",width:"100%",height:"100%",fill:o.color,className:"w-full h-full",children:e.jsx("path",{d:"M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"})})},o.id)),e.jsxs("button",{type:"button",onClick:w,disabled:!l||d,"aria-label":r?n("leaderboard.profile.like.aria_unlike"):n("leaderboard.profile.like.aria_like"),className:`group flex items-center justify-center gap-1.5 h-8 min-w-[48px] px-2.5 rounded-full border transition-all duration-300 outline-none focus-visible:ring-2 focus-visible:ring-rose-500/50 disabled:opacity-60 disabled:cursor-default ${r?"bg-rose-50/60 border-rose-200/80 text-rose-500 dark:bg-rose-950/20 dark:border-rose-900/40 dark:text-rose-400 shadow-sm":"bg-white/80 border-oai-gray-200 text-oai-gray-500 hover:border-rose-200 hover:text-rose-500 hover:bg-rose-50/30 dark:bg-oai-gray-950/50 dark:border-white/10 dark:text-oai-gray-400 dark:hover:border-rose-900/50 dark:hover:text-rose-400 dark:hover:bg-rose-950/5"}`,children:[e.jsx("span",{className:y?"tt-animate-pop":"group-active:scale-90 transition-transform duration-100",children:e.jsx(ve,{size:14,className:`transition-all duration-300 ${r?"fill-rose-500 text-rose-500 dark:fill-rose-400 dark:text-rose-400":"fill-transparent"}`})}),e.jsx("span",{className:`text-[12px] font-bold font-mono tabular-nums tracking-tight ${r?"text-rose-600 dark:text-rose-400":"text-oai-gray-600 dark:text-oai-gray-400"} ${v?"tt-num-anim":""}`,children:l?s:"·"})]})]})}function we(a,r,t){const s=Number(a);return!Number.isFinite(s)||s<0?"—":s>0&&s<.01?`<${r==="USD"?"$":""}0.01`:le(s,{decimals:2,currency:r,rate:t})}function H(a,r,t){const s=Number(a);if(!Number.isFinite(s)||s<0)return"—";if(s<1e3)return we(s,r,t);const i=r==="USD"?s:s*(t||1);return`${r==="USD"?"$":""}${I(i,{decimals:1})}`}function $(a){const r=Number(a);return!Number.isFinite(r)||r<=0?"0":I(r,{decimals:1})}function Se(a){const r=Array.isArray(a)?a:[];if(r.length===0)return null;const t=r.map(i=>({day:i.date,total_tokens:i.total_tokens,models:i.models||null})),s=r[r.length-1]?.date;return oe({dailyRows:t,weeks:52,to:s})}const Ae=`
|
|
42
|
-
@keyframes tt-shimmer {
|
|
43
|
-
100% { transform: translateX(100%); }
|
|
44
|
-
}
|
|
45
|
-
.tt-shimmer-bar {
|
|
46
|
-
position: relative;
|
|
47
|
-
overflow: hidden;
|
|
48
|
-
}
|
|
49
|
-
.tt-shimmer-bar::after {
|
|
50
|
-
position: absolute;
|
|
51
|
-
top: 0; right: 0; bottom: 0; left: 0;
|
|
52
|
-
transform: translateX(-100%);
|
|
53
|
-
background-image: linear-gradient(
|
|
54
|
-
90deg,
|
|
55
|
-
rgba(0, 0, 0, 0) 0%,
|
|
56
|
-
rgba(0, 0, 0, 0.02) 20%,
|
|
57
|
-
rgba(0, 0, 0, 0.06) 60%,
|
|
58
|
-
rgba(0, 0, 0, 0) 100%
|
|
59
|
-
);
|
|
60
|
-
animation: tt-shimmer 1.6s infinite;
|
|
61
|
-
content: '';
|
|
62
|
-
}
|
|
63
|
-
.dark .tt-shimmer-bar::after {
|
|
64
|
-
background-image: linear-gradient(
|
|
65
|
-
90deg,
|
|
66
|
-
rgba(255, 255, 255, 0) 0%,
|
|
67
|
-
rgba(255, 255, 255, 0.02) 20%,
|
|
68
|
-
rgba(255, 255, 255, 0.06) 60%,
|
|
69
|
-
rgba(255, 255, 255, 0) 100%
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
`;function Le({variant:a="modal"}){const r="rounded bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar",t=a==="page";return e.jsxs("div",{children:[e.jsx("style",{dangerouslySetInnerHTML:{__html:Ae}}),t?e.jsxs("div",{className:"flex items-start gap-5 px-6 sm:px-8 pt-8 pb-7 animate-fade-in",children:[e.jsx("div",{className:"h-[68px] w-[68px] rounded-full bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-start justify-between gap-4 pt-0.5",children:[e.jsxs("div",{className:"min-w-0 space-y-2.5",children:[e.jsx("div",{className:c(r,"h-7 w-48")}),e.jsx("div",{className:c(r,"h-3.5 w-32")})]}),e.jsxs("div",{className:"shrink-0 space-y-1.5 flex flex-col items-end",children:[e.jsx("div",{className:c(r,"h-2.5 w-8")}),e.jsx("div",{className:c(r,"h-7 w-12")})]})]})]}):e.jsxs("div",{className:"flex items-start gap-4 px-6 pt-6 pb-5 border-b border-oai-gray-200/80 dark:border-oai-gray-800/60 animate-fade-in",children:[e.jsx("div",{className:"h-14 w-14 rounded-full bg-oai-gray-200/50 dark:bg-oai-gray-800/40 tt-shimmer-bar shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-2 pt-1",children:[e.jsx("div",{className:c(r,"h-4 w-40")}),e.jsx("div",{className:c(r,"h-3 w-56")})]}),e.jsx("div",{className:c(r,"h-4 w-4 shrink-0 mt-1")})]}),e.jsxs("div",{className:c("space-y-6",t?"px-6 sm:px-8 pt-6 pb-8 border-t border-oai-gray-200/80 dark:border-oai-gray-800/60":"px-6 py-5"),children:[e.jsx("div",{className:"grid grid-cols-4 gap-x-6 gap-y-4",children:Array.from({length:4}).map((s,i)=>e.jsxs("div",{children:[e.jsx("div",{className:c(r,"h-6 w-20")}),e.jsx("div",{className:c(r,"mt-2 h-3 w-14")})]},i))}),e.jsx("div",{className:"space-y-3 border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:Array.from({length:3}).map((s,i)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:c(r,"h-3 w-24")}),e.jsx("div",{className:c(r,"h-3 w-44")})]},i))}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:c(r,"h-3 w-44 mb-4")}),e.jsx("div",{className:"grid grid-cols-[repeat(52,1fr)] gap-[2px]",children:Array.from({length:364}).map((s,i)=>e.jsx("div",{className:"aspect-square rounded-[2px] bg-oai-gray-200/40 dark:bg-oai-gray-800/30 tt-shimmer-bar"},i))})]}),e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx("div",{className:c(r,"h-3 w-28 mb-3")}),e.jsx("div",{className:"space-y-2.5",children:Array.from({length:5}).map((s,i)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:c(r,"h-4 w-4")}),e.jsx("div",{className:c(r,"h-3 w-16")}),e.jsx("div",{className:c(r,"h-[3px] flex-1")}),e.jsx("div",{className:c(r,"h-3 w-12")})]},i))})]})]})]})}function G(a){if(!a)return null;const r=String(a).match(/github\.com\/([A-Za-z0-9][A-Za-z0-9-]{0,38})/i);return r?r[1]:null}function R({children:a}){return e.jsx("h3",{className:"text-[11px] uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400 mb-3",children:a})}function L({value:a,label:r}){return e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-black tabular-nums tracking-tight leading-none text-oai-black dark:text-white",style:{fontFamily:'"DIN Alternate-Bold", "DIN Alternate", "DIN Condensed-Bold", "Impact", -apple-system, sans-serif',fontWeight:900},children:a}),e.jsx("div",{className:"mt-1.5 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:r})]})}function P({label:a,children:r}){return e.jsxs("div",{className:"flex items-baseline gap-3 text-sm",children:[e.jsx("dt",{className:"shrink-0 w-28 whitespace-nowrap text-oai-gray-500 dark:text-oai-gray-400",children:a}),e.jsx("dd",{className:"min-w-0 flex-1 text-oai-gray-900 dark:text-oai-gray-100 tabular-nums truncate flex items-baseline gap-2 flex-wrap",children:r})]})}function Me({user:a,onClose:r}){const t=G(a?.github_url);return e.jsxs("div",{className:"flex items-center gap-4 px-6 pt-6 pb-5 border-b border-oai-gray-200/80 dark:border-oai-gray-800/60",children:[e.jsx(W,{avatarUrl:a?.avatar_url,displayName:a?.display_name||"",seed:a?.user_id||a?.display_name,size:"lg",className:"shrink-0 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"truncate text-base font-semibold text-oai-black dark:text-white",children:a?.display_name||"—"}),a?.rank?e.jsx("span",{className:c("shrink-0 inline-flex items-center px-2 py-0.5 rounded text-xs font-bold font-mono uppercase tracking-wider border shadow-sm",a.rank===1&&"bg-amber-500/10 text-amber-600 border-amber-500/20 dark:text-amber-400 dark:bg-amber-400/10",a.rank===2&&"bg-slate-500/10 text-slate-600 border-slate-500/20 dark:text-slate-400 dark:bg-slate-400/10",a.rank===3&&"bg-orange-500/10 text-orange-700 border-orange-500/20 dark:text-orange-400 dark:bg-orange-400/10",a.rank>3&&"bg-oai-gray-100 dark:bg-oai-gray-900/60 text-oai-gray-500 dark:text-oai-gray-400 border-oai-gray-200/60 dark:border-oai-gray-800"),children:n("leaderboard.profile_modal.rank",{rank:a.rank})}):null]}),t&&e.jsxs("a",{href:a.github_url,target:"_blank",rel:"noopener noreferrer",className:"mt-1 inline-flex items-center gap-1 text-[12px] text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-800 dark:hover:text-oai-gray-200 transition-colors",children:[e.jsx(T,{provider:"GITHUB",size:11}),e.jsxs("span",{children:["@",t]})]})]}),a?.user_id&&e.jsx("div",{className:"shrink-0 flex items-center justify-center",children:e.jsx(E,{userId:a.user_id})}),r&&e.jsx("button",{type:"button",onClick:r,className:"shrink-0 -mr-1 -mt-1 flex h-8 w-8 items-center justify-center rounded-md text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand/50 transition-colors group","aria-label":n("leaderboard.profile_modal.close"),children:e.jsx(ne,{size:16,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:rotate-90 group-active:scale-90"})})]})}function ze({user:a}){const r=G(a?.github_url),t=Number(a?.rank)||0,s=t===1?"text-amber-500 dark:text-amber-400":t===2?"text-slate-500 dark:text-slate-300":t===3?"text-orange-600 dark:text-orange-400":"text-oai-gray-400 dark:text-oai-gray-500";return e.jsxs("div",{className:"flex items-center gap-5 px-6 sm:px-8 pt-8 pb-7",children:[e.jsx(W,{avatarUrl:a?.avatar_url,displayName:a?.display_name||"",seed:a?.user_id||a?.display_name,size:"xl",className:"shrink-0 ring-1 ring-oai-gray-200 dark:ring-oai-gray-800"}),e.jsxs("div",{className:"min-w-0 flex-1 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("h1",{className:"truncate text-2xl sm:text-[28px] font-semibold tracking-tight leading-tight text-oai-black dark:text-white",children:a?.display_name||"—"}),a?.user_id&&e.jsx(E,{userId:a.user_id})]}),r?e.jsxs("a",{href:a.github_url,target:"_blank",rel:"noopener noreferrer",className:"mt-2 inline-flex items-center gap-1.5 text-sm text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white transition-colors",children:[e.jsx(T,{provider:"GITHUB",size:13}),e.jsxs("span",{children:["@",r]})]}):null]}),t?e.jsxs("div",{className:"shrink-0 text-right leading-none",children:[e.jsx("div",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-oai-gray-400 dark:text-oai-gray-500",children:n("leaderboard.profile.hero.rank_label")}),e.jsx("div",{className:c("mt-1.5 text-3xl font-black tabular-nums tracking-tight",s),children:n("leaderboard.profile_modal.rank",{rank:t})})]}):null]})]})}function Pe({data:a}){const r=Array.isArray(a)?a:[];return r.length===0?e.jsx("p",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.profile_modal.providers.none")}):e.jsx("ul",{className:"space-y-2",children:r.map(t=>{const s=Math.max(0,Math.min(1,Number(t?.percent)||0));return e.jsxs("li",{className:"flex items-center gap-3 text-xs",children:[e.jsx("span",{className:"shrink-0 inline-flex items-center justify-center w-4 h-4",children:e.jsx(T,{provider:String(t.source).toUpperCase(),size:14})}),e.jsx("span",{className:"shrink-0 capitalize w-16 text-oai-gray-700 dark:text-oai-gray-300",children:t.source}),e.jsx("span",{className:"flex-1 h-[3px] rounded-full bg-oai-gray-200/60 dark:bg-oai-gray-800/80 overflow-hidden",children:e.jsx("span",{className:"block h-full bg-oai-brand-500 dark:bg-oai-brand-400",style:{width:`${(s*100).toFixed(1)}%`}})}),e.jsx("span",{className:"shrink-0 w-14 text-right tabular-nums text-oai-gray-700 dark:text-oai-gray-300",children:$(t.total_tokens)}),e.jsxs("span",{className:"shrink-0 w-10 text-right tabular-nums text-oai-gray-500 dark:text-oai-gray-400",children:[(s*100).toFixed(0),"%"]})]},t.source)})})}function B({icon:a,label:r,value:t}){const[s,i]=g.useState(!1),l=async()=>{await de(t)&&(i(!0),setTimeout(()=>i(!1),1600))};return e.jsxs("button",{type:"button",onClick:l,className:c("inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs font-medium transition-colors",s?"border-emerald-500/30 text-emerald-600 dark:text-emerald-400 bg-emerald-500/[0.06]":"border-oai-gray-200 dark:border-oai-gray-800 text-oai-gray-600 dark:text-oai-gray-300 hover:text-oai-gray-900 dark:hover:text-oai-gray-100 hover:border-oai-gray-300 dark:hover:border-oai-gray-700 hover:bg-oai-gray-50 dark:hover:bg-oai-gray-900/40"),children:[s?e.jsx(xe,{size:13,strokeWidth:2,"aria-hidden":!0}):e.jsx(a,{size:13,strokeWidth:2,"aria-hidden":!0}),e.jsx("span",{children:s?n("leaderboard.profile_modal.badge.copied"):r})]})}function Ce({data:a,currency:r,rate:t,onClose:s,variant:i="modal"}){const{user:l,totals:m,streak:d,best_day:p,models:y,by_provider:k,heatmap:j,period:M}=a,v=i==="page",b=g.useMemo(()=>Se(j),[j]),N=y?.favorite?.model_name,_=Number(y?.count)||0,u=re(),w=!!(u?.user?.id&&l?.user_id&&u.user.id===l.user_id),o=l?.user_id?`https://www.tokentracker.cc/u/${l.user_id}`:null,x=l?.user_id?`[}/functions/tokentracker-embed-svg?user_id=${l.user_id}&theme=dark)](${o}?ref=readme)`:null;return e.jsxs(e.Fragment,{children:[v?e.jsx(ze,{user:l}):e.jsx(Me,{user:l,onClose:s}),e.jsxs("div",{className:c("space-y-6",v?"px-6 sm:px-8 pt-6 pb-8 border-t border-oai-gray-200/80 dark:border-oai-gray-800/60":"flex-1 min-h-0 overflow-y-auto oai-scrollbar px-6 py-5"),children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-x-6 gap-y-4",children:[e.jsx(L,{value:$(m?.total_tokens),label:n("leaderboard.profile_modal.stat.total_tokens")}),e.jsx(L,{value:H(m?.estimated_cost_usd,r,t),label:n("leaderboard.profile_modal.stat.total_cost")}),e.jsx(L,{value:String(m?.active_days??0),label:n("leaderboard.profile_modal.stat.active_days")}),e.jsx(L,{value:H(m?.avg_per_day_usd,r,t),label:n("leaderboard.profile_modal.stat.avg_per_day")})]}),e.jsxs("dl",{className:"space-y-2 border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsxs(P,{label:n("leaderboard.profile_modal.streak.current"),children:[e.jsx("span",{className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30",children:n("leaderboard.profile_modal.streak.days",{count:d?.current_days??0})}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["(max ",d?.longest_days??0,")"]})]}),e.jsx(P,{label:n("leaderboard.profile_modal.best_day.title"),children:p?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30",children:$(p.total_tokens)}),e.jsxs("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:["on ",p.date]})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:n("leaderboard.profile_modal.best_day.none")})}),e.jsx(P,{label:n("leaderboard.profile_modal.models.favorite"),children:N?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"font-mono text-xs tracking-tight bg-oai-gray-100/60 dark:bg-oai-gray-900/50 px-1.5 py-0.5 rounded border border-oai-gray-200/30 dark:border-oai-gray-800/30 truncate max-w-[200px] inline-block align-bottom",children:N}),_>1&&e.jsx("span",{className:"text-xs text-oai-gray-500 dark:text-oai-gray-400 font-mono",children:n("leaderboard.profile_modal.models.count",{count:_})})]}):e.jsx("span",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-500 font-mono",children:n("leaderboard.profile_modal.models.none")})})]}),b&&e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(R,{children:n("leaderboard.profile_modal.heatmap.title")}),e.jsx("div",{className:"min-w-0",children:e.jsx(me,{heatmap:b,hideLegend:!0,embedded:!0})})]}),e.jsxs("section",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-5",children:[e.jsx(R,{children:n("leaderboard.profile_modal.providers.title")}),e.jsx(Pe,{data:k})]}),l?.user_id&&(s||w)&&e.jsxs("div",{className:"border-t border-oai-gray-200/70 dark:border-oai-gray-800/60 pt-4 flex flex-wrap items-center justify-between gap-x-4 gap-y-3",children:[s&&(se()?e.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",onClick:s,className:"group inline-flex items-center gap-1 text-xs font-medium text-oai-gray-700 hover:text-oai-gray-950 dark:text-oai-gray-300 dark:hover:text-oai-white transition-colors",children:[e.jsx("span",{children:n("leaderboard.profile_modal.view_full")}),e.jsx(U,{size:13,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]}):e.jsxs(ie,{to:`/u/${l.user_id}`,onClick:s,className:"group inline-flex items-center gap-1 text-xs font-medium text-oai-gray-700 hover:text-oai-gray-950 dark:text-oai-gray-300 dark:hover:text-oai-white transition-colors",children:[e.jsx("span",{children:n("leaderboard.profile_modal.view_full")}),e.jsx(U,{size:13,strokeWidth:2,"aria-hidden":!0,className:"transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]})),w&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(B,{icon:_e,label:n("leaderboard.profile_modal.badge.copy_url"),value:o}),e.jsx(B,{icon:ke,label:n("leaderboard.profile_modal.badge.copy"),value:x})]})]})]})]})}function $e({userId:a,period:r,accessToken:t,enabled:s=!0}){const[i,l]=g.useState({loading:!1,error:null,data:null});return g.useEffect(()=>{if(!s||!a)return;let m=!0;return l({loading:!0,error:null,data:null}),(async()=>{try{const d=t?await ee(t):null;if(!m)return;const p=await ae({accessToken:d,userId:a,period:r||"week"});if(!m)return;l({loading:!1,error:null,data:p})}catch(d){if(!m)return;d?.status===404?l({loading:!1,error:null,data:null}):l({loading:!1,error:d?.message||String(d),data:null})}})(),()=>{m=!1}},[s,a,r,t]),i}function We({isOpen:a,onClose:r,userId:t,period:s,accessToken:i}){const{currency:l,rate:m}=ce(),d=$e({userId:t,period:s,accessToken:i,enabled:a});return e.jsx(ge,{open:a,onOpenChange:p=>{p||r?.()},children:e.jsxs(pe,{children:[e.jsx(he,{className:"cost-modal-backdrop"}),e.jsx(fe,{className:"fixed inset-0 z-[101] flex items-center justify-center p-4",children:e.jsxs(be,{className:c("cost-modal-popup","relative w-full max-w-[540px] max-h-[calc(100vh-2rem)] flex flex-col","rounded-2xl bg-white dark:bg-oai-gray-950","shadow-[0_20px_60px_-20px_rgba(0,0,0,0.25)] dark:shadow-[0_20px_60px_-10px_rgba(0,0,0,0.65)]","ring-1 ring-oai-gray-200 dark:ring-oai-gray-800 overflow-hidden","dark:border-t dark:border-white/[0.08]"),children:[e.jsx(ue,{render:e.jsx("h2",{className:"sr-only"}),children:d.data?.user?.display_name||n("leaderboard.profile_modal.loading")}),d.loading&&e.jsx(Le,{}),!d.loading&&d.error&&e.jsx("div",{className:"flex-1 flex items-center justify-center min-h-[280px]",children:e.jsx("p",{className:"text-sm text-red-500 dark:text-red-400",children:n("leaderboard.profile_modal.error")})}),!d.loading&&!d.error&&!d.data&&e.jsx("div",{className:"flex-1 flex items-center justify-center min-h-[280px]",children:e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400",children:n("leaderboard.profile_modal.empty")})}),!d.loading&&!d.error&&d.data&&e.jsx(Ce,{data:d.data,currency:l,rate:m,onClose:r})]})})]})})}export{We as LeaderboardProfileModal,Ce as ProfileContent,Le as ProfileSkeleton,$e as useLeaderboardProfileData};
|