tokentracker-cli 1.2.2 → 1.3.4

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.
Files changed (176) hide show
  1. package/README.md +2 -0
  2. package/README.zh-CN.md +2 -0
  3. package/THIRD_PARTY_NOTICES.md +92 -0
  4. package/dashboard/dist/THIRD_PARTY_NOTICES.txt +92 -0
  5. package/dashboard/dist/assets/AchievementBadge-CKjtQp-U.js +1 -0
  6. package/dashboard/dist/assets/AchievementsPage-DpOXrabE.js +2 -0
  7. package/dashboard/dist/assets/{AchievementsSection-BDqKRGyL.js → AchievementsSection-DiXyIoa0.js} +1 -1
  8. package/dashboard/dist/assets/BadgeDetailModal-CILTTkPF.js +1 -0
  9. package/dashboard/dist/assets/{BotAnimated-OQbsVw1O.js → BotAnimated-CrBHWiRi.js} +1 -1
  10. package/dashboard/dist/assets/Card-DUItW3xI.js +1 -0
  11. package/dashboard/dist/assets/CloudCheckoutPage-C_t_PDlG.js +1 -0
  12. package/dashboard/dist/assets/CloudPage-pvJUrhya.js +1 -0
  13. package/dashboard/dist/assets/CloudUsageExport-DQbDwiyk.js +4 -0
  14. package/dashboard/dist/assets/{CommandPalette-8B38qUs0.js → CommandPalette-BvHilrbV.js} +1 -1
  15. package/dashboard/dist/assets/CommunityStatsModal-CizxEYv-.js +1 -0
  16. package/dashboard/dist/assets/{ConfirmModal-Dhu_qmiM.js → ConfirmModal-h9nISVy7.js} +1 -1
  17. package/dashboard/dist/assets/Controls-BjdIonTX.js +1 -0
  18. package/dashboard/dist/assets/DashboardPage-Bxryr4qp.js +1 -0
  19. package/dashboard/dist/assets/DateRangePopover-DpKh-0l8.js +1 -0
  20. package/dashboard/dist/assets/{DevicePage-Bvz7JJwt.js → DevicePage-DUJR9hJC.js} +1 -1
  21. package/dashboard/dist/assets/DialogClose-BmVAmN-o.js +1 -0
  22. package/dashboard/dist/assets/DialogDescription-C0Cgq67g.js +1 -0
  23. package/dashboard/dist/assets/DialogTitle-BsaIbN8k.js +1 -0
  24. package/dashboard/dist/assets/{FadeIn-DDF5PqTX.js → FadeIn-BpSt2P_W.js} +1 -1
  25. package/dashboard/dist/assets/{HeaderGithubStar-CNzQFPol.js → HeaderGithubStar-Cc_VHB0R.js} +1 -1
  26. package/dashboard/dist/assets/{HoverTooltip-BKg9Z6gg.js → HoverTooltip-WFd21iP9.js} +1 -1
  27. package/dashboard/dist/assets/{IpCheckPage-BTdrLt08.js → IpCheckPage-C_mUPSRB.js} +1 -1
  28. package/dashboard/dist/assets/LandingPage-DVR8ClZO.js +2 -0
  29. package/dashboard/dist/assets/LeaderboardPage-D8ydzVpn.js +2 -0
  30. package/dashboard/dist/assets/LeaderboardProBadge-BjX4EFl2.js +1 -0
  31. package/dashboard/dist/assets/LeaderboardProfileModal-vbPMNn7W.js +73 -0
  32. package/dashboard/dist/assets/{LeaderboardProfilePage-CoqcDSTw.js → LeaderboardProfilePage-CqClmuA-.js} +2 -2
  33. package/dashboard/dist/assets/{LimitsPage-3RuSFnn-.js → LimitsPage-DaRggHge.js} +2 -2
  34. package/dashboard/dist/assets/{LocalOnlyNotice-D-OrIXty.js → LocalOnlyNotice-B6nDke_u.js} +1 -1
  35. package/dashboard/dist/assets/LoginCard-C28QVjd7.js +1 -0
  36. package/dashboard/dist/assets/LoginModal-Bx1btNhH.js +1 -0
  37. package/dashboard/dist/assets/LoginPage-DVOGNGYI.js +1 -0
  38. package/dashboard/dist/assets/PetPage-nOKryTde.js +1 -0
  39. package/dashboard/dist/assets/PopoverPopup-Ch6NLnu6.js +1 -0
  40. package/dashboard/dist/assets/{ProviderIcon-BTYVbUti.js → ProviderIcon-BRY2br-g.js} +1 -1
  41. package/dashboard/dist/assets/ResetPasswordPage-ko1OQecQ.js +1 -0
  42. package/dashboard/dist/assets/Select-Q8mS3_od.js +1 -0
  43. package/dashboard/dist/assets/SelectItemText-C1id8GDj.js +1 -0
  44. package/dashboard/dist/assets/SelfHostPage-Dzb2bDiM.js +1 -0
  45. package/dashboard/dist/assets/{ServiceStatusPage-Cb3k_C4g.js → ServiceStatusPage-ewFwz29J.js} +1 -1
  46. package/dashboard/dist/assets/SessionsPage-C6Y8kbnM.js +3 -0
  47. package/dashboard/dist/assets/SessionsPage-GV2fuNmd.css +1 -0
  48. package/dashboard/dist/assets/SettingsPage-nztCXEPs.js +2 -0
  49. package/dashboard/dist/assets/SkillsPage-CcG77tqU.js +1 -0
  50. package/dashboard/dist/assets/{TokenGalaxy-BGRF4I_8.js → TokenGalaxy-D2HDrbQR.js} +2 -2
  51. package/dashboard/dist/assets/TooltipPopup-C_bF2ZwO.js +1 -0
  52. package/dashboard/dist/assets/TrendMonitor-BcyoN5ns.js +19 -0
  53. package/dashboard/dist/assets/WidgetsPage-BirK0U_N.js +1 -0
  54. package/dashboard/dist/assets/{WrappedPage-BqyB7ezg.js → WrappedPage-thsXBuw6.js} +1 -1
  55. package/dashboard/dist/assets/__vite-browser-external-Bq8nj-JV.js +45 -0
  56. package/dashboard/dist/assets/__vite-browser-external-BwmeEfv7.css +1 -0
  57. package/dashboard/dist/assets/{agent-logos-CEcgxIBU.js → agent-logos-CK6SzhI7.js} +1 -1
  58. package/dashboard/dist/assets/arrow-left-c_NOSfoq.js +1 -0
  59. package/dashboard/dist/assets/arrow-right-CP7drKCT.js +1 -0
  60. package/dashboard/dist/assets/{arrow-up-right-CdzAw406.js → arrow-up-right-DQ6QfCpo.js} +1 -1
  61. package/dashboard/dist/assets/calendar-days-D_pxFQvT.js +1 -0
  62. package/dashboard/dist/assets/{check-DhEiHlwq.js → check-HAS31kTT.js} +1 -1
  63. package/dashboard/dist/assets/chevron-down-BIMuk6oN.js +1 -0
  64. package/dashboard/dist/assets/cloud-checkout-COmDwrUT.js +1 -0
  65. package/dashboard/dist/assets/composite-kLwqpqEk.js +1 -0
  66. package/dashboard/dist/assets/download-9RgsZIiH.js +1 -0
  67. package/dashboard/dist/assets/{external-link-SOFbVRrH.js → external-link-C_gYjHGF.js} +1 -1
  68. package/dashboard/dist/assets/{flame-BRdc7HDz.js → flame-BSsCvgT8.js} +1 -1
  69. package/dashboard/dist/assets/{format-tokens-DhIeweGK.js → format-tokens-N22Wqv1X.js} +1 -1
  70. package/dashboard/dist/assets/{host-mode-APftzzvz.js → host-mode-JzrhHX7F.js} +1 -1
  71. package/dashboard/dist/assets/{icons-D-wu8eUg.js → icons-pK99mIMv.js} +1 -1
  72. package/dashboard/dist/assets/{index-CZ3D1Q7c.js → index-BhviBroj.js} +1 -1
  73. package/dashboard/dist/assets/{index-D2g1tPGl.js → index-CmD84EJi.js} +1 -1
  74. package/dashboard/dist/assets/{index-CiWf_0mc.js → index-Dk43KNa6.js} +1 -1
  75. package/dashboard/dist/assets/info-D-RLFnSK.js +1 -0
  76. package/dashboard/dist/assets/{link-2-Cg6bEvjQ.js → link-2-BiKXW9mV.js} +1 -1
  77. package/dashboard/dist/assets/{loader-circle-Cd7h4LcE.js → loader-circle-KVUaEKV2.js} +1 -1
  78. package/dashboard/dist/assets/{modifiers.esm-B7hOvflM.js → modifiers.esm-5NK8j3mT.js} +1 -1
  79. package/dashboard/dist/assets/monitor-smartphone-u9yr-_Es.js +1 -0
  80. package/dashboard/dist/assets/os-DMmhX9tk.js +1 -0
  81. package/dashboard/dist/assets/play-D0MaDCOx.js +1 -0
  82. package/dashboard/dist/assets/plus-DTJVtoAJ.js +1 -0
  83. package/dashboard/dist/assets/provider-display-YhtG0I9Y.js +42 -0
  84. package/dashboard/dist/assets/{react-CfB5zBqR.js → react-gIVxucOB.js} +1 -1
  85. package/dashboard/dist/assets/safePolygon-C_sPnJ1L.js +1 -0
  86. package/dashboard/dist/assets/{search-DMtc6bBy.js → search-DdQRwFYV.js} +1 -1
  87. package/dashboard/dist/assets/server-M0rmbGWy.js +1 -0
  88. package/dashboard/dist/assets/shield-check-9-sqQKdD.js +1 -0
  89. package/dashboard/dist/assets/skills-api-B0qBWnuK.js +1 -0
  90. package/dashboard/dist/assets/{sortable.esm-O7ntEYCi.js → sortable.esm-iqbm7x5D.js} +1 -1
  91. package/dashboard/dist/assets/{store-D-FZbBaC.js → store-DstuWd4a.js} +1 -1
  92. package/dashboard/dist/assets/{terminal-Y3qDL50U.js → terminal-Dz0MxHNG.js} +1 -1
  93. package/dashboard/dist/assets/{trash-D_PaPrXq.js → trash-DBMFOFVz.js} +1 -1
  94. package/dashboard/dist/assets/{use-community-stats-DGTBo_4v.js → use-community-stats-CacbAcUR.js} +1 -1
  95. package/dashboard/dist/assets/{use-latest-request-guard-BpfCferm.js → use-latest-request-guard-nBuQVZOR.js} +1 -1
  96. package/dashboard/dist/assets/use-limits-display-prefs-fqg8hs6b.js +1 -0
  97. package/dashboard/dist/assets/use-native-settings-EAqAFx2x.js +1 -0
  98. package/dashboard/dist/assets/{use-ordered-list-CClTBWi0.js → use-ordered-list-DGLjjU6Q.js} +1 -1
  99. package/dashboard/dist/assets/use-pet-settings-C5MzWHE7.js +2 -0
  100. package/dashboard/dist/assets/use-reduced-motion-DK2oZ2uC.js +1 -0
  101. package/dashboard/dist/assets/{use-transform-CA5mW4u8.js → use-transform-C25eCuz_.js} +1 -1
  102. package/dashboard/dist/assets/use-usage-limits-BhqnEai3.js +1 -0
  103. package/dashboard/dist/assets/{useCurrency-CaOhUMcm.js → useCurrency-t3PYQi1l.js} +1 -1
  104. package/dashboard/dist/assets/usePositioner-C59mj6kG.js +1 -0
  105. package/dashboard/dist/assets/useTokenFormat-C0xQsBGf.js +1 -0
  106. package/dashboard/dist/assets/zap-CyH0tvKM.js +1 -0
  107. package/dashboard/dist/index.html +2 -2
  108. package/dashboard/dist/ip-check.html +2 -2
  109. package/dashboard/dist/leaderboard.html +2 -2
  110. package/dashboard/dist/pricing.html +6 -5
  111. package/dashboard/dist/privacy.html +3 -3
  112. package/dashboard/dist/share.html +2 -2
  113. package/dashboard/dist/terms.html +6 -6
  114. package/package.json +7 -2
  115. package/src/commands/device-login.js +60 -33
  116. package/src/commands/init.js +26 -7
  117. package/src/commands/serve.js +3 -3
  118. package/src/commands/sync.js +43 -22
  119. package/src/lib/atomic-json.js +27 -0
  120. package/src/lib/bearer-token.js +11 -0
  121. package/src/lib/cloud-account.js +4 -1
  122. package/src/lib/local-api.js +282 -69
  123. package/src/lib/openclaw-cli.js +104 -0
  124. package/src/lib/openclaw-hook.js +1 -46
  125. package/src/lib/openclaw-session-plugin.js +1 -59
  126. package/src/lib/pricing/seed-snapshot.json +1 -1
  127. package/src/lib/proxy-env.js +8 -3
  128. package/src/lib/rollout.js +15 -10
  129. package/src/lib/runtime-config.js +84 -14
  130. package/src/lib/skills-manager.js +8 -1
  131. package/src/lib/static-server.js +19 -4
  132. package/src/lib/upload-throttle.js +18 -4
  133. package/dashboard/dist/assets/AchievementBadge-B67_Cp1T.js +0 -1
  134. package/dashboard/dist/assets/AchievementsPage-DNJ5n0Bn.js +0 -2
  135. package/dashboard/dist/assets/BadgeDetailModal-DFL1MPcg.js +0 -1
  136. package/dashboard/dist/assets/Card-dqzakOoX.js +0 -1
  137. package/dashboard/dist/assets/CommunityStatsModal-DnbCiGms.js +0 -1
  138. package/dashboard/dist/assets/Controls-BgQflA-3.js +0 -1
  139. package/dashboard/dist/assets/DashboardPage-DeLRhWU_.js +0 -1
  140. package/dashboard/dist/assets/DialogClose-DUxjaRqf.js +0 -1
  141. package/dashboard/dist/assets/DialogDescription-h6XMtzIU.js +0 -1
  142. package/dashboard/dist/assets/DialogTitle-C8vpXqg8.js +0 -1
  143. package/dashboard/dist/assets/LandingPage-cjoagPAb.js +0 -2
  144. package/dashboard/dist/assets/LeaderboardAvatar-CJdG51hR.js +0 -1
  145. package/dashboard/dist/assets/LeaderboardPage-D-yf2rOQ.js +0 -2
  146. package/dashboard/dist/assets/LeaderboardProfileModal--hrfpUPF.js +0 -73
  147. package/dashboard/dist/assets/LoginCard-BiMyV2Uf.js +0 -1
  148. package/dashboard/dist/assets/LoginModal-D79CMZmf.js +0 -1
  149. package/dashboard/dist/assets/LoginPage-BLyGuPlG.js +0 -1
  150. package/dashboard/dist/assets/PetPage-Bv0K4k2t.js +0 -1
  151. package/dashboard/dist/assets/PopoverPopup-3eucO8QU.js +0 -1
  152. package/dashboard/dist/assets/ResetPasswordPage-VYMl84_-.js +0 -1
  153. package/dashboard/dist/assets/Select-D8N2TJz1.js +0 -1
  154. package/dashboard/dist/assets/SelectItemText-CoTR0Uwm.js +0 -1
  155. package/dashboard/dist/assets/SessionsPage-BngTWN7Q.css +0 -1
  156. package/dashboard/dist/assets/SessionsPage-BtH5iLbi.js +0 -3
  157. package/dashboard/dist/assets/SettingsPage-huGkex5G.js +0 -2
  158. package/dashboard/dist/assets/SkillsPage-B9usVOTU.js +0 -1
  159. package/dashboard/dist/assets/TrendMonitor-B8SKBsWO.js +0 -19
  160. package/dashboard/dist/assets/WidgetsPage-o_91L3Zi.js +0 -1
  161. package/dashboard/dist/assets/__vite-browser-external-Cj9D7QBh.js +0 -45
  162. package/dashboard/dist/assets/__vite-browser-external-gKkiQad5.css +0 -1
  163. package/dashboard/dist/assets/composite-DO7_ilHE.js +0 -1
  164. package/dashboard/dist/assets/download-kGPw24XQ.js +0 -1
  165. package/dashboard/dist/assets/info-Qgc5VctK.js +0 -1
  166. package/dashboard/dist/assets/monitor-smartphone-wFv5VQQf.js +0 -1
  167. package/dashboard/dist/assets/plus-0xHQei42.js +0 -1
  168. package/dashboard/dist/assets/provider-display-DNqVkqfp.js +0 -42
  169. package/dashboard/dist/assets/skills-api-BeN184fz.js +0 -1
  170. package/dashboard/dist/assets/use-limits-display-prefs-Drs82lSi.js +0 -1
  171. package/dashboard/dist/assets/use-pet-settings-DvaQ7XrL.js +0 -2
  172. package/dashboard/dist/assets/use-reduced-motion-Dg10dVuu.js +0 -1
  173. package/dashboard/dist/assets/use-session-efficiency-pref-BiYRXVlN.js +0 -1
  174. package/dashboard/dist/assets/use-usage-limits-B0uafB4O.js +0 -1
  175. package/dashboard/dist/assets/useTokenFormat-JjQCKdIr.js +0 -1
  176. package/dashboard/dist/assets/zap-Cqur2X5s.js +0 -1
@@ -0,0 +1 @@
1
+ import{r as a,a$ as ee,b1 as w,j as k,a_ as we,N as M,c3 as de,b0 as z,bR as ge,b5 as X,b7 as he,ba as _,b4 as Ae,c4 as ke,c5 as He,b2 as F,c6 as Fe,c7 as ce,b3 as ue,b9 as le,c8 as q,c9 as Le,ca as Ne,bO as Be,by as me,bz as je,bi as $,bx as Ue,bC as _e,cb as Ve,K as Ye,cc as Ge,bD as Xe,bh as Ke,J as Te,cd as $e,b6 as Q,ce as Je,bK as We,bN as ze}from"./__vite-browser-external-Bq8nj-JV.js";import{i as Re,A as qe,P as Qe,n as Ze,k as et,l as tt,m as nt,o as ot,p as rt,u as st,d as it,c as at,t as ct,x as ut,y as lt}from"./composite-kLwqpqEk.js";import{p as pt,c as ft}from"./store-DstuWd4a.js";import{g as K,u as dt,c as gt,a as ht,s as mt,b as Tt}from"./safePolygon-C_sPnJ1L.js";import{u as Rt,a as Pt,g as Ct}from"./usePositioner-C59mj6kG.js";const Pe=a.createContext({hasProvider:!1,timeoutMs:0,delayRef:{current:0},initialDelayRef:{current:0},timeout:new we,currentIdRef:{current:null},currentContextRef:{current:null}});function vt(e,n){e.current=n.current}function Xt(e){const{children:n,delay:t,timeoutMs:u=0}=e,o=a.useRef(t),p=a.useRef(t),i=a.useRef(null),c=a.useRef(null),h=ee();return w(()=>{if(p.current=t,!i.current){o.current=t;return}o.current={open:K(o.current,"open"),close:K(t,"close")}},[t,i,o,p]),k.jsx(Pe.Provider,{value:a.useMemo(()=>({hasProvider:!0,delayRef:o,initialDelayRef:p,currentIdRef:i,timeoutMs:u,currentContextRef:c,timeout:h}),[u,h]),children:n})}function yt(e,n={open:!1}){const{open:t}=n,u="rootStore"in e?e.rootStore:e,o=u.useState("floatingId"),p=a.useContext(Pe),{currentIdRef:i,delayRef:c,timeoutMs:h,initialDelayRef:m,currentContextRef:l,hasProvider:T,timeout:f}=p,[g,r]=a.useState(!1),P=a.useRef(t);return w(()=>{P.current=t},[t]),w(()=>{function s(){l.current?.setIsInstantPhase(!1),i.current=null,l.current=null,c.current=m.current,f.clear()}if(i.current&&!t&&i.current===o){if(r(!1),h){const d=o;return f.start(h,()=>{u.select("open")||i.current&&i.current!==d||s()}),()=>{(P.current||i.current!==d)&&f.clear()}}s()}},[t,o,i,c,h,m,l,f,u]),w(()=>{if(!t)return;const s=l.current,d=i.current;f.clear(),l.current={onOpenChange:u.setOpen,setIsInstantPhase:r},i.current=o,c.current={open:0,close:K(m.current,"close")},d!==null&&d!==o?(r(!0),s?.setIsInstantPhase(!0),s?.onOpenChange(!1,M(de))):(r(!1),s?.setIsInstantPhase(!1))},[t,o,u,i,c,m,l,f]),w(()=>()=>{if(i.current===o){if(l.current=null,!P.current)return;i.current=null,vt(c,m),f.clear()}},[l,i,c,o,m,f]),a.useMemo(()=>({activeIdRef:i,hasProvider:T,delayRef:c,isInstantPhase:g}),[i,T,c,g])}function bt(e,n){let t=null,u=null,o=!1;return{contextElement:e||void 0,getBoundingClientRect(){const p=e?.getBoundingClientRect()||{width:0,height:0,x:0,y:0},i=n.axis==="x"||n.axis==="both",c=n.axis==="y"||n.axis==="both",h=["mouseenter","mousemove"].includes(n.dataRef.current.openEvent?.type||"")&&n.pointerType!=="touch";let m=p.width,l=p.height,T=p.x,f=p.y;return t==null&&n.x&&i&&(t=p.x-n.x),u==null&&n.y&&c&&(u=p.y-n.y),T-=t||0,f-=u||0,m=0,l=0,!o||h?(m=n.axis==="y"?p.width:0,l=n.axis==="x"?p.height:0,T=i&&n.x!=null?n.x:T,f=c&&n.y!=null?n.y:f):o&&!h&&(l=n.axis==="x"?p.height:l,m=n.axis==="y"?p.width:m),o=!0,{width:m,height:l,x:T,y:f,top:f,right:T+m,bottom:f+l,left:T}}}}function pe(e){return e!=null&&e.clientX!=null}function xt(e,n={}){const{enabled:t=!0,axis:u="both"}=n,o="rootStore"in e?e.rootStore:e,p=o.useState("open"),i=o.useState("floatingElement"),c=o.useState("domReferenceElement"),h=o.context.dataRef,m=a.useRef(!1),l=a.useRef(null),[T,f]=a.useState(),[g,r]=a.useState([]),P=z(R=>{o.set("positionReference",R)}),s=z((R,y,S)=>{m.current||h.current.openEvent&&!pe(h.current.openEvent)||o.set("positionReference",bt(S??c,{x:R,y,axis:u,dataRef:h,pointerType:T}))}),d=z(R=>{p?l.current||(s(R.clientX,R.clientY,R.currentTarget),r([])):s(R.clientX,R.clientY,R.currentTarget)}),b=Re(T)?i:p;a.useEffect(()=>{if(!t){P(c);return}if(!b)return;function R(){l.current?.(),l.current=null}const y=ge(i);function S(x){const O=he(x);_(i,O)?R():s(x.clientX,x.clientY)}return!h.current.openEvent||pe(h.current.openEvent)?l.current=X(y,"mousemove",S):P(c),R},[b,t,i,h,c,o,s,P,g]),a.useEffect(()=>()=>{o.set("positionReference",null)},[o]),a.useEffect(()=>{t&&!i&&(m.current=!1)},[t,i]),a.useEffect(()=>{!t&&p&&(m.current=!0)},[t,p]);const C=a.useMemo(()=>{function R(y){f(y.pointerType)}return{onPointerDown:R,onPointerEnter:R,onMouseMove:d,onMouseEnter:d}},[d]);return a.useMemo(()=>t?{reference:C,trigger:C}:{},[t,C])}const Z=ke&&He;function St(e,n={}){const{enabled:t=!0,delay:u}=n,o="rootStore"in e?e.rootStore:e,{events:p,dataRef:i}=o.context,c=a.useRef(!1),h=a.useRef(null),m=a.useRef(!0),l=ee();a.useEffect(()=>{const f=o.select("domReferenceElement");if(!t)return;const g=ge(f);function r(){const d=o.select("domReferenceElement");!o.select("open")&&Be(d)&&d===ce(ue(d))&&(c.current=!0,h.current=d)}function P(){m.current=!0}function s(){m.current=!1}return Ae(X(g,"blur",r),Z&&X(g,"keydown",P,!0),Z&&X(g,"pointerdown",s,!0))},[o,t]),a.useEffect(()=>{if(!t)return;function f(g){if(g.reason===me||g.reason===je){const r=o.select("domReferenceElement");F(r)&&(h.current=r,c.current=!0)}}return p.on("openchange",f),()=>{p.off("openchange",f)}},[p,t,o]);const T=a.useMemo(()=>{function f(){c.current=!1,h.current=null}return{onMouseLeave(){f()},onFocus(g){const r=g.currentTarget;if(c.current){if(h.current===r)return;f()}const P=he(g.nativeEvent);if(F(P)){if(Z&&!g.relatedTarget){if(!m.current&&!Le(P))return}else if(!Ne(P))return}const s=le(g.relatedTarget,o.context.triggerElements),{nativeEvent:d,currentTarget:b}=g,C=typeof u=="function"?u():u;if(o.select("open")&&s||C===0||C===void 0){o.setOpen(!0,M(q,d,b));return}l.start(C,()=>{c.current||o.setOpen(!0,M(q,d,b))})},onBlur(g){f();const r=g.relatedTarget,P=g.nativeEvent,s=F(r)&&r.hasAttribute(Fe("focus-guard"))&&r.getAttribute("data-type")==="outside";l.start(0,()=>{const d=o.select("domReferenceElement"),b=ce(ue(d));!r&&b===d||_(i.current.floatingContext?.refs.floating.current,b)||_(d,b)||s||le(r??b,o.context.triggerElements)||o.setOpen(!1,M(q,P))})}}},[i,u,o,l]);return a.useMemo(()=>t?{reference:T,trigger:T}:{},[t,T])}const Ce=a.createContext(void 0);function J(e){const n=a.useContext(Ce);if(n===void 0&&!e)throw new Error($(72));return n}const Et={...pt,disabled:e=>e.disabled,instantType:e=>e.instantType,isInstantPhase:e=>e.isInstantPhase,trackCursorAxis:e=>e.trackCursorAxis,disableHoverablePopup:e=>e.disableHoverablePopup,lastOpenChangeReason:e=>e.openChangeReason,closeOnClick:e=>e.closeOnClick,closeDelay:e=>e.closeDelay,adaptiveOrigin:e=>e.adaptiveOrigin};class Ot extends Ue{constructor(n,t,u){const o=new Qe;super(It(n,o,t,u),Mt(o),Et)}setOpen=(n,t)=>{qe(this,n,t,{extraState:{openChangeReason:t.reason}})};cancelPendingOpen(n){this.state.floatingRootContext.dispatchOpenChange(!1,M(me,n))}}function It(e,n,t,u=!1){return{...ft(n,t,u),disabled:!1,instantType:void 0,isInstantPhase:!1,trackCursorAxis:"none",disableHoverablePopup:!1,openChangeReason:null,closeOnClick:!0,closeDelay:0,adaptiveOrigin:void 0,...e}}function Mt(e){return{popupRef:a.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:e}}const Kt=_e(function(n){const{disabled:t=!1,defaultOpen:u=!1,open:o,disableHoverablePopup:p=!1,trackCursorAxis:i="none",actionsRef:c,onOpenChange:h,onOpenChangeComplete:m,handle:l,triggerId:T,defaultTriggerId:f=null,children:g}=n,r=Ze((L,N)=>new Ot({open:u,openProp:o,activeTriggerId:f,triggerIdProp:T},L,N));r.useControlledProp("openProp",o),r.useControlledProp("triggerIdProp",T),r.useContextCallback("onOpenChange",h),r.useContextCallback("onOpenChangeComplete",m);const P=r.useState("open"),s=!t&&P,d=r.useState("activeTriggerId"),b=r.useState("mounted"),C=r.useState("payload");r.useSyncedValues({trackCursorAxis:i,disableHoverablePopup:p,disabled:t}),et(r,{closeOnActiveTriggerUnmount:!0});const{forceUnmount:R,transitionStatus:y}=tt(s,r),S=r.useState("isInstantPhase"),x=r.useState("instantType"),O=r.useState("lastOpenChangeReason"),D=a.useRef(null);w(()=>{P&&t&&r.setOpen(!1,M(Ge))},[P,t,r]),w(()=>{y==="ending"&&O===de||y!=="ending"&&S?(x!=="delay"&&(D.current=x),r.set("instantType","delay")):D.current!==null&&(r.set("instantType",D.current),D.current=null)},[y,S,O,x,r]),w(()=>{s&&d==null&&r.set("payload",void 0)},[r,d,s]),a.useImperativeHandle(c,()=>({unmount:R,close:()=>r.setOpen(!1,M(Xe))}),[R,r]);const H=s||b||!t&&i!=="none";return k.jsxs(Ce.Provider,{value:r,children:[l&&k.jsx(nt,{handle:l,store:r}),H&&k.jsx(Dt,{store:r,disabled:t,trackCursorAxis:i}),typeof g=="function"?g({payload:C}):g]})});function Dt({store:e,disabled:n,trackCursorAxis:t}){const u=e.useState("floatingRootContext"),o=ot(u,{enabled:!n,referencePress:()=>e.select("closeOnClick")}),p=xt(u,{enabled:!n&&t!=="none",axis:t==="none"?void 0:t}),i=a.useMemo(()=>Ve(p.reference,o.reference),[p.reference,o.reference]);return rt(e,{activeTriggerProps:i,inactiveTriggerProps:i,popupProps:o.floating??Ye}),null}const wt=a.createContext(void 0);function At(){return a.useContext(wt)}const kt=600,ve="data-base-ui-tooltip-trigger";function fe(e){if("composedPath"in e){const t=e.composedPath();for(let u=0;u<t.length;u+=1){const o=t[u];if(F(o))return o}}const n=e.target;return F(n)?n:null}function Ht(e){let n=e;for(;n;){const t=n.closest(`[${ve}]`);if(t)return t;const u=n.getRootNode();n="host"in u&&F(u.host)?u.host:null}return null}const $t=Ke(function(n,t){const{render:u,className:o,style:p,handle:i,payload:c,disabled:h,delay:m,closeOnClick:l=!0,closeDelay:T,id:f,...g}=n,r=J(!0),s=dt(i)??r;if(!s)throw new Error($(82));const d=st(f),b=s.useState("isTriggerActive",d),C=s.useState("isOpenedByTrigger",d),R=s.useState("floatingRootContext"),y=a.useRef(null),S=T??0,{registerTrigger:x,isMountedByThisTrigger:O}=it(d,y,s,{payload:c,closeOnClick:l,closeDelay:S}),D=At(),{activeIdRef:H,delayRef:L,isInstantPhase:N,hasProvider:E}=yt(R,{open:C}),B=gt(R);s.useSyncedValue("isInstantPhase",N);const W=s.useState("disabled"),j=h??W,te=at(j),ne=s.useState("trackCursorAxis"),xe=s.useState("disableHoverablePopup"),U=a.useRef(!1),V=ee(),Y=a.useRef(void 0);function oe(){return E&&H.current!=null?0:m??D??kt}function re(v){const I=y.current;if(!I||!v)return!1;const A=Ht(v);return A!==null&&A!==I&&_(I,A)}function Se(v){const I=re(v);return U.current=I,I&&(B.openChangeTimeout.clear(),B.restTimeout.clear(),B.restTimeoutPending=!1,V.clear()),I}const Ee=ht(R,{enabled:!j,mouseOnly:!0,move:!1,handleClose:!xe&&ne!=="both"?mt():null,restMs:oe,delay(){return T==null&&E?{close:K(L.current,"close")}:{close:S}},triggerElementRef:y,isActiveTrigger:b,isClosing:()=>s.select("transitionStatus")==="ending",shouldOpen(){return!U.current}}),Oe=St(R,{enabled:!j}).reference,Ie=v=>{const I=U.current,A=fe(v),se=Se(A),G=y.current,De=G&&A&&_(G,A);if(se&&s.select("open")&&s.select("lastOpenChangeReason")===Q){s.setOpen(!1,M(Q,v));return}if(I&&!se&&De&&!te.current&&!s.select("open")&&G&&Re(Y.current)){const ie=()=>{!U.current&&!te.current&&!s.select("open")&&s.setOpen(!0,M(Q,v,G))},ae=oe();ae===0?(V.clear(),ie()):V.start(ae,ie)}},Me=s.useState("triggerProps",O);return Te("button",n,{state:{open:C},ref:[t,x,y],props:[Ee,Oe,O||ne!=="none"?Me:void 0,{onMouseOver(v){Ie(v.nativeEvent)},onFocus(v){re(fe(v.nativeEvent))&&v.preventBaseUIHandler()},onMouseLeave(){U.current=!1,V.clear(),Y.current=void 0},onPointerEnter(v){Y.current=v.pointerType},onPointerDown(v){Y.current=v.pointerType,s.set("closeOnClick",l),l&&!s.select("open")&&s.cancelPendingOpen(v.nativeEvent)},onClick(v){l&&!s.select("open")&&s.cancelPendingOpen(v.nativeEvent)},id:d,[$e]:j?"":void 0,[ve]:j?void 0:""},g],stateAttributesMapping:ct})}),ye=a.createContext(void 0);function Ft(){const e=a.useContext(ye);if(e===void 0)throw new Error($(70));return e}const Jt=a.forwardRef(function(n,t){const{keepMounted:u=!1,...o}=n;return J().useState("mounted")||u?k.jsx(ye.Provider,{value:u,children:k.jsx(Je,{ref:t,...o})}):null}),be=a.createContext(void 0);function Lt(){const e=a.useContext(be);if(e===void 0)throw new Error($(71));return e}const Wt=a.forwardRef(function(n,t){const{render:u,className:o,anchor:p,positionMethod:i="absolute",side:c="top",align:h="center",sideOffset:m=0,alignOffset:l=0,collisionBoundary:T="clipping-ancestors",collisionPadding:f=5,arrowPadding:g=5,sticky:r=!1,disableAnchorTracking:P=!1,collisionAvoidance:s=We,style:d,...b}=n,C=J(),R=Ft(),y=C.useState("open"),S=C.useState("mounted"),x=C.useState("trackCursorAxis"),O=C.useState("disableHoverablePopup"),D=C.useState("floatingRootContext"),H=C.useState("instantType"),L=C.useState("transitionStatus"),N=C.useState("adaptiveOrigin"),E=Rt({anchor:p,positionMethod:i,floatingRootContext:D,mounted:S,side:c,sideOffset:m,align:h,alignOffset:l,collisionBoundary:T,collisionPadding:f,sticky:r,arrowPadding:g,disableAnchorTracking:P,keepMounted:R,collisionAvoidance:s,adaptiveOrigin:N}),B=a.useMemo(()=>({open:y,side:E.side,align:E.align,anchorHidden:E.anchorHidden,instant:x!=="none"?"tracking-cursor":H}),[y,E.side,E.align,E.anchorHidden,x,H]),W=Pt(n,B,{styles:E.positionerStyles,transitionStatus:L,props:b,refs:[t,C.useStateSetter("positionerElement")],hidden:!S,inert:!y||x==="both"||O});return k.jsx(be.Provider,{value:E,children:W})}),zt=a.forwardRef(function(n,t){const{render:u,className:o,style:p,...i}=n,c=J(),{side:h,align:m}=Lt(),l=c.useState("open"),T=c.useState("instantType"),f=c.useState("transitionStatus"),g=c.useState("popupProps"),r=c.useState("floatingRootContext"),P=c.useState("disabled"),s=c.useState("closeDelay");ze({open:l,ref:c.context.popupRef,onComplete(){l&&c.context.onOpenChangeComplete?.(!0)}}),Tt(r,{enabled:!P,closeDelay:s});const d=c.useStateSetter("popupElement");return Te("div",n,{state:{open:l,side:h,align:m,instant:T,transitionStatus:f},ref:[t,c.context.popupRef,d],props:[ut,g,Ct(f),i],stateAttributesMapping:lt})});export{Xt as F,wt as T,Kt as a,$t as b,Jt as c,Wt as d,zt as e};
@@ -0,0 +1,19 @@
1
+ import{r as K,W as lt,aA as ct,aB as Me,aC as ut,aD as dt,aE as ft,aF as mt,aG as gt,aH as yt,aI as ht,aJ as _e,aK as qe,V as v,az as Je,j as s,X as pt,c as T,y as V,aL as xt,aM as bt,n as kt,h as Nt}from"./__vite-browser-external-Bq8nj-JV.js";import{m as vt}from"./react-gIVxucOB.js";import{u as Qe}from"./useCurrency-t3PYQi1l.js";import{u as Ve}from"./useTokenFormat-C0xQsBGf.js";import{D as De}from"./DateRangePopover-DpKh-0l8.js";import{u as wt}from"./use-latest-request-guard-nBuQVZOR.js";import{T as jt,M as Tt}from"./terminal-Dz0MxHNG.js";import{P as $e,a as Ee,b as Fe,c as Ae,d as Re}from"./PopoverPopup-Ch6NLnu6.js";import{u as _t}from"./use-reduced-motion-DK2oZ2uC.js";function ze(e,r,t){if(!(typeof window>"u"))try{const a=window.localStorage.getItem(e),n=a?JSON.parse(a):[],o=Array.isArray(n)?n.filter(c=>typeof c=="string"&&c!==e):[],i=[r,...o.filter(c=>c!==r)],l=i.splice(t);for(const c of l)window.localStorage.removeItem(c);window.localStorage.setItem(e,JSON.stringify(i))}catch{}}const Ct=24,Pe="tokentracker.trend-cache-index",Ue=24;function St({baseUrl:e,accessToken:r,guestAllowed:t=!1,period:a,from:n,to:o,months:i=Ct,cacheKey:l,timeZone:c,tzOffsetMinutes:f,now:d,sharedRows:y,sharedRange:u,accountView:x=!1,accountAccessToken:m=null,accountRevision:k=0,accountViewResolving:h=!1,deviceId:_=null}={}){const C=!!(x&&m),M=C?"cloud":"local",[D,j]=K.useState([]),[P,R]=K.useState(()=>({from:n,to:o})),[w,F]=K.useState("edge"),[W,U]=K.useState(null),[z,L]=K.useState(!1),[ae,H]=K.useState(null),$=lt(),q=ct(r),Y=!t&&!$,re=Array.isArray(y),Z=u?.from||n,Q=u?.to||o,te=K.useRef({sharedEnabled:re,sharedRows:y,sharedFrom:Z,sharedTo:Q});te.current={sharedEnabled:re,sharedRows:y,sharedFrom:Z,sharedTo:Q};const g=K.useMemo(()=>a==="day"?"hourly":a==="total"?"monthly":"daily",[a]),I=(()=>{if(!l)return null;const N=Mt(e)||"default",E=ht({timeZone:c,offsetMinutes:f}),B=_||"all";if(g==="hourly")return`tokentracker.trend.${l}.${M}.${N}.hourly.${o||n||"day"}.${E}.${B}`;if(g==="monthly")return`tokentracker.trend.${l}.${M}.${N}.monthly.${i}.${o||"today"}.${E}.${B}`;const oe=`${n||""}.${o||""}`;return`tokentracker.trend.${l}.${M}.${N}.daily.${oe}.${E}.${B}`})(),ie=K.useCallback(()=>{if(!I||typeof window>"u")return null;try{const N=window.localStorage.getItem(I);if(!N)return null;const E=JSON.parse(N);return!E||!Array.isArray(E.rows)?null:(ze(Pe,I,Ue),E)}catch{return null}},[I]),fe=K.useCallback(N=>{if(!(!I||typeof window>"u"))try{window.localStorage.setItem(I,JSON.stringify(N)),ze(Pe,I,Ue)}catch{}},[I]),p=K.useCallback(()=>{if(!(!I||typeof window>"u"))try{window.localStorage.removeItem(I)}catch{}},[I]),b=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"),A=wt([e,g,n,o,i,M,r,m,k,_,c,f,re,y,Z,Q,t,$,Y,h,q,b]),G=K.useRef(M);K.useEffect(()=>{G.current!==M&&(G.current=M,j([]),R({from:n,to:o}),F("edge"),U(null),H(null),L(!0))},[M]);const O=K.useCallback(async()=>{const N=A(),{sharedEnabled:E,sharedRows:B,sharedFrom:oe,sharedTo:le}=te.current;if(E){j(Array.isArray(B)?B:[]),R({from:oe,to:le}),F("shared"),U(null),L(!1),H(null);return}const me=await Me(r),Ce=C?await Me(m):null;if(!N()||!me&&!$&&!b&&!C)return;if(C&&!Ce){H("Your session expired. Please sign in again to view account data."),L(!1);return}const be=C?Ce:me,ot=C?ut:dt,st=C?ft:mt,it=C?gt:yt;L(!0),H(null);try{let J;g==="hourly"?J=await ot({baseUrl:e,accessToken:be,day:o||n,device:_,timeZone:c,tzOffsetMinutes:f}):g==="monthly"?J=await st({baseUrl:e,accessToken:be,months:i,to:o,device:_,timeZone:c,tzOffsetMinutes:f}):J=await it({baseUrl:e,accessToken:be,from:n,to:o,device:_,timeZone:c,tzOffsetMinutes:f});let S=J?.from||n||J?.day||null;const X=J?.to||o||J?.day||null;g==="monthly"&&!S&&(S=de(X,i));let ne=Array.isArray(J?.data)?J.data:[];g==="daily"?ne=ke(ne,S||n,X||o,{timeZone:c,offsetMinutes:f,now:d}):g==="hourly"?(ne=Ne(ne,S||n||J?.day,{timeZone:c,offsetMinutes:f,now:d}),ne=ve(ne,{timeZone:c,offsetMinutes:f,now:d})):g==="monthly"&&(ne=we(ne,S||n,X||o,{timeZone:c,offsetMinutes:f,now:d}));const Se=new Date().toISOString();if(!N())return;j(ne),R({from:S,to:X}),F("edge"),U(Se),Y?fe({rows:ne,from:S,to:X,mode:g,fetchedAt:Se}):p()}catch(J){if(!N())return;if(Y){const S=ie();if(S?.rows){let X=g==="daily"?ke(S.rows||[],S.from||n,S.to||o,{timeZone:c,offsetMinutes:f,now:d}):g==="hourly"?Ne(S.rows||[],S.from||n||S.day||o,{timeZone:c,offsetMinutes:f,now:d}):Array.isArray(S.rows)?S.rows:[];g==="hourly"?X=ve(X,{timeZone:c,offsetMinutes:f,now:d}):g==="monthly"&&(X=we(X,S.from||n||de(S.to||o,i),S.to||o,{timeZone:c,offsetMinutes:f,now:d})),j(X),R({from:S.from||n||(g==="monthly"?de(S.to||o,i):n),to:S.to||o}),F("cache"),U(S.fetchedAt||null),H(null)}else{j([]),R({from:n,to:o}),F("edge"),U(null);const X=J;H(X?.message||String(X))}}else{j([]),R({from:n,to:o}),F("edge"),U(null);const S=J;H(S?.message||String(S))}}finally{N()&&L(!1)}},[r,e,n,$,t,Y,g,i,ie,q,c,o,f,d,p,fe,b,C,m,k,_,A]);K.useEffect(()=>{if(h){L(!0);return}if(re){j(Array.isArray(y)?y:[]),R({from:Z,to:Q}),F("shared"),U(null),L(!1),H(null);return}if(!q&&!t&&!$&&!b&&!C){j([]),R({from:n,to:o}),H(null),L(!1),F("edge"),U(null);return}if(!Y)p(),j([]),R({from:n,to:o}),H(null),F("edge"),U(null);else{const N=ie();if(N?.rows){let E=g==="daily"?ke(N.rows||[],N.from||n,N.to||o,{timeZone:c,offsetMinutes:f,now:d}):g==="hourly"?Ne(N.rows||[],N.from||n||N.day||o,{timeZone:c,offsetMinutes:f,now:d}):Array.isArray(N.rows)?N.rows:[];g==="hourly"?E=ve(E,{timeZone:c,offsetMinutes:f,now:d}):g==="monthly"&&(E=we(E,N.from||n||de(N.to||o,i),N.to||o,{timeZone:c,offsetMinutes:f,now:d})),j(E),R({from:N.from||n||(g==="monthly"?de(N.to||o,i):n),to:N.to||o}),F("cache"),U(N.fetchedAt||null),H(null)}else j([]),R({from:n,to:o}),F("edge"),U(null),H(null)}L(!0),O()},[r,$,ie,O,re,Z,y,Q,q,t,Y,p,b,h]);const ee=$?"mock":w;return{rows:D,from:P.from||n,to:P.to||o,source:ee,fetchedAt:W,loading:z,error:ae,refresh:O}}function Mt(e){try{return new URL(e).host}catch{return null}}function ye(e){if(!e)return null;const r=String(e).trim(),t=r.split("-");if(t.length!==3)return null;const a=Number(t[0]),n=Number(t[1])-1,o=Number(t[2]);if(!Number.isFinite(a)||!Number.isFinite(n)||!Number.isFinite(o))return null;const i=new Date(Date.UTC(a,n,o));return Number.isFinite(i.getTime())&&_e(i)===r?i:null}function Ze(e,r){return new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()+r))}const et=["total_tokens","billable_total_tokens","input_tokens","cached_input_tokens","cache_creation_input_tokens","output_tokens","reasoning_output_tokens","conversation_count"];function ke(e,r,t,{timeZone:a,offsetMinutes:n,now:o}={}){const i=ye(r),l=ye(t);if(!i||!l||l<i)return Array.isArray(e)?e:[];const c=o instanceof Date&&Number.isFinite(o.getTime())?o:new Date,f=qe({timeZone:a,offsetMinutes:n,date:c}),d=ye(f),y=d?d.getTime():c.getTime(),u=new Map;for(const m of e||[])m?.day&&u.set(m.day,m);const x=[];for(let m=i;m<=l;m=Ze(m,1)){const k=_e(m),h=u.get(k),_=m.getTime()>y;if(h){x.push({...h,missing:!1,future:_});continue}x.push({day:k,total_tokens:null,billable_total_tokens:null,input_tokens:null,cached_input_tokens:null,output_tokens:null,reasoning_output_tokens:null,missing:!_,future:_})}return x}function Dt(e,r){const t=r?null:0;return{hour:e,total_tokens:t,billable_total_tokens:t,input_tokens:t,cached_input_tokens:t,cache_creation_input_tokens:t,output_tokens:t,reasoning_output_tokens:t,conversation_count:t,missing:!1,future:r}}function $t(e){if(!e||typeof e!="object")return!1;const r=e.models;return r&&typeof r=="object"&&Object.keys(r).length>0?!1:et.every(t=>e[t]==null)}function Et(e,r,t){const a={...e,hour:r,missing:!1,future:t};if(!t&&$t(e))for(const n of et)a[n]=0;return a}function Ft(e,r){const t=r===30?48:24,a=[];for(let n=0;n<t;n++){const o=Math.floor(n*r/60),i=n*r%60;a.push(`${e}T${String(o).padStart(2,"0")}:${String(i).padStart(2,"0")}:00`)}return a}function At(e,r,{timeZone:t,offsetMinutes:a}={}){const n=Ft(e,r);if(!t||typeof Intl>"u"||!Intl.DateTimeFormat)return n;const o=ye(e);if(!o)return n;const i=o.getUTCFullYear()*1e4+(o.getUTCMonth()+1)*100+o.getUTCDate(),l=o.getTime()-2160*60*1e3,c=Ze(o,2).getTime()+2160*60*1e3,f=[],d=new Set;for(let y=l;y<=c;y+=1800*1e3){const u=xe({timeZone:t,offsetMinutes:a,now:new Date(y)});if(!u||u.dayNum!==i||r===60&&u.minute!==0||r===30&&u.minute!==0&&u.minute!==30)continue;const x=`${e}T${String(u.hour).padStart(2,"0")}:${String(u.minute).padStart(2,"0")}:00`;d.has(x)||(d.add(x),f.push(x))}return f.length>0?f:n}function Ne(e,r,{timeZone:t,offsetMinutes:a,now:n}={}){if(!r)return Array.isArray(e)?e:[];const o=r.trim().slice(0,10),i=xe({timeZone:t,offsetMinutes:a,now:n}),l=i?i.dayNum:void 0;let c=!1;for(const x of e||[]){const m=x?.hour||x?.label||"",k=he(m,l);if(k&&k.slot%2!==0){c=!0;break}}const f=c?30:60,d=new Map;for(const x of e||[]){const m=x?.hour||x?.label||"",k=he(m,l);k&&d.set(k.slot,x)}const y=[],u=At(o,f,{timeZone:t,offsetMinutes:a});for(let x=0;x<u.length;x++){const m=u[x],k=he(m,l),h=k?k.slot:c?x:x*2,_=d.get(h);let C=!1;if(i){const M=i.year*1e4+i.month*100+i.day,D=k?.dayNum??Number(o.replace(/-/g,""));if(D>M)C=!0;else if(D===M){const j=i.hour*2+(i.minute>=30?1:0);C=h>j}}_?y.push(Et(_,m,C)):y.push(Dt(m,C))}return y}function ve(e,{timeZone:r,offsetMinutes:t,now:a}={}){if(!Array.isArray(e))return[];const n=xe({timeZone:r,offsetMinutes:t,now:a});return n?e.map(o=>{const i=o?.hour||o?.label||"",l=he(i,n.dayNum);if(!l)return{...o,future:!1};const c=l.dayNum!==null&&l.dayNum>n.dayNum||(l.dayNum===null||l.dayNum===n.dayNum)&&l.slot>n.slot;return{...o,future:!!c}}):e}function de(e,r){const t=je(String(e||"").slice(0,7));return t?_e(new Date(Date.UTC(t.year,t.month-r,1))):null}function we(e,r,t,a={}){const n=je(String(r||"").slice(0,7)),o=je(String(t||"").slice(0,7));if(!n||!o)return Array.isArray(e)?e:[];const i=n.year*12+n.month-1,l=o.year*12+o.month-1;if(l<i)return Array.isArray(e)?e:[];const c=xe(a),f=c.year*12+c.month-1,d=new Map((e||[]).map(u=>[u?.month,u])),y=[];for(let u=i;u<=l;u++){const x=`${Math.floor(u/12)}-${String(u%12+1).padStart(2,"0")}`,m=u>f,k=d.get(x);if(k&&!(k.future&&k.total_tokens==null))y.push({...k,missing:!1,future:m});else{const h=m?null:0;y.push({month:x,total_tokens:h,billable_total_tokens:h,input_tokens:h,cached_input_tokens:h,cache_creation_input_tokens:h,output_tokens:h,reasoning_output_tokens:h,conversation_count:h,missing:!1,future:m})}}return y}function xe({timeZone:e,offsetMinutes:r,now:t}={}){const a=t instanceof Date&&Number.isFinite(t.getTime())?t:new Date;if(e&&typeof Intl<"u"&&Intl.DateTimeFormat)try{const u=new Intl.DateTimeFormat("en-CA",{timeZone:e,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(a).reduce((C,M)=>(M.type&&M.value&&(C[M.type]=M.value),C),{}),x=Number(u.year),m=Number(u.month),k=Number(u.day),h=Number(u.hour),_=Number(u.minute);if(Number.isFinite(x)&&Number.isFinite(m)&&Number.isFinite(k)&&Number.isFinite(h)&&Number.isFinite(_)){const C=h*2+(_>=30?1:0);return{year:x,month:m,day:k,hour:h,minute:_,dayNum:x*1e4+m*100+k,slot:C}}}catch{}if(Number.isFinite(r)){const d=new Date(a.getTime()+r*60*1e3),y=d.getUTCFullYear(),u=d.getUTCMonth()+1,x=d.getUTCDate(),m=d.getUTCHours(),k=d.getUTCMinutes(),h=m*2+(k>=30?1:0);return{year:y,month:u,day:x,hour:m,minute:k,dayNum:y*1e4+u*100+x,slot:h}}const n=a.getFullYear(),o=a.getMonth()+1,i=a.getDate(),l=a.getHours(),c=a.getMinutes(),f=l*2+(c>=30?1:0);return{year:n,month:o,day:i,hour:l,minute:c,dayNum:n*1e4+o*100+i,slot:f}}function he(e,r){if(!e)return null;const t=String(e).trim();if(t.includes("T")){const[a,n]=t.split("T");if(!a||!n)return null;const o=a.split("-");if(o.length!==3)return null;const i=Number(o[0]),l=Number(o[1]),c=Number(o[2]);if(!Number.isFinite(i)||!Number.isFinite(l)||!Number.isFinite(c))return null;const f=n.split(":"),d=Number(f[0]),y=Number(f[1]);if(!Number.isFinite(d)||d<0||d>23||!Number.isFinite(y)||y<0||y>59)return null;const u=d*2+(y>=30?1:0);return{dayNum:i*1e4+l*100+c,slot:u}}else{let a=NaN,n=0;if(/^\d{1,2}$/.test(t))a=Number(t);else if(/^\d{1,2}:\d{2}(:\d{2})?$/.test(t)){const i=t.split(":");a=Number(i[0]),n=Number(i[1])}if(!Number.isFinite(a)||a<0||a>23||!Number.isFinite(n)||n<0||n>59)return null;const o=a*2+(n>=30?1:0);return{dayNum:r||null,slot:o}}}function je(e){if(!e)return null;const t=String(e).trim().split("-");if(t.length!==2)return null;const a=Number(t[0]),n=Number(t[1]);return!Number.isFinite(a)||!Number.isFinite(n)||n<1||n>12?null:{year:a,month:n}}function Rt(e){return e==="day"?"hourly":e==="total"?"monthly":"daily"}function zt(e){return!!e&&!e.missing&&!e.future}function Pt(e){const r=e?.billable_total_tokens??e?.total_tokens??e?.value,t=Number(r);return Number.isFinite(t)&&t>=0?t:0}function Ut(e){const r=e?.total_tokens??e?.billable_total_tokens??e?.value,t=Number(r);return Number.isFinite(t)&&t>=0?t:0}function Lt(e){const r=Array.isArray(e)?e.filter(zt):[];let t=0,a=0,n=0,o=0,i=!1,l=0,c=-1,f=null;for(const d of r){const y=Ut(d),u=Pt(d);t+=y,a+=u;const x=Number(d?.conversation_count);Number.isFinite(x)&&x>0&&(n+=x);const m=Number(d?.total_cost_usd);Number.isFinite(m)&&(i=!0,o+=m),u>0&&(l+=1),u>c&&(c=u,f=d)}return{totalTokens:t,billableTokens:a,conversationCount:n,totalCostUsd:i?o:null,bucketCount:r.length,activeBuckets:l,peak:f&&c>0?{value:c,label:f.hour||f.day||f.month||""}:null}}function ue(e){return String(e).padStart(2,"0")}function tt(e){return typeof e=="string"&&e.trim()?e:"en-US"}function nt(e){const r=String(e||""),t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(r);if(!t)return null;const[,a,n,o]=t,i=new Date(Date.UTC(Number(a),Number(n)-1,Number(o)));return i.getUTCFullYear()!==Number(a)||i.getUTCMonth()+1!==Number(n)||i.getUTCDate()!==Number(o)?null:i}function se(e,r,t=!0){const a=nt(e);if(!a||typeof Intl>"u"||!Intl.DateTimeFormat)return String(e||"");try{return new Intl.DateTimeFormat(tt(r),{...t?{year:"numeric"}:{},month:"short",day:"numeric",timeZone:"UTC"}).format(a)}catch{return String(e||"")}}function pe(e,r){const t=String(e||""),a=/^(\d{4})-(\d{2})(?:-\d{2})?$/.exec(t);if(!a)return t;const n=new Date(Date.UTC(Number(a[1]),Number(a[2])-1,1));if(n.getUTCFullYear()!==Number(a[1])||n.getUTCMonth()+1!==Number(a[2]))return t;try{return new Intl.DateTimeFormat(tt(r),{year:"numeric",month:"short",timeZone:"UTC"}).format(n)}catch{return t}}function Ht(e,r){const t=nt(e);return t?(t.setUTCDate(t.getUTCDate()+r),`${t.getUTCFullYear()}-${ue(t.getUTCMonth()+1)}-${ue(t.getUTCDate())}`):e}function Le(e,r,t){if(!e)return"";if(r==="hourly"){const n=String(e.hour||e.label||""),o=/^(\d{4}-\d{2}-\d{2})T(\d{2}):(\d{2})/.exec(n);if(!o)return n;const[,i,l,c]=o,d=Number(l)*60+Number(c)+30,y=Math.floor(d/60)%24,u=d%60,x=se(i,t);if(d>=1440){const m=se(Ht(i,1),t);return`${x} ${l}:${c}–${m} ${ue(y)}:${ue(u)}`}return`${x} ${l}:${c}–${ue(y)}:${ue(u)}`}if(r==="monthly"){const n=String(e.month||e.label||"");return pe(n,t)}const a=String(e.day||e.label||"");return se(a,t)}function It(e,r,t,a){if(!e||!r)return null;const n=String(e),o=String(r);return t==="hourly"&&n===o?{start:`${se(n,a)} · 00:00`,end:"24:00"}:t==="monthly"?{start:pe(n,a),end:pe(o,a)}:{start:se(n,a),end:se(o,a)}}function Bt(e){if(!e||e.activeBuckets===0)return"trend.zoom.insight.empty";const r=e.totalTokens||0;return r<1e7?"trend.zoom.insight.calm":r<5e8?"trend.zoom.insight.steady":r<5e9?"trend.zoom.insight.heavy":"trend.zoom.insight.massive"}function Ot(e,r,t){if(!e)return"";if(r==="hourly"){const n=/T(\d{2}:\d{2})/.exec(String(e.hour||e.label||""));return n?n[1]:""}if(r==="monthly")return pe(String(e.month||e.label||""),t);const a=String(e.day||e.label||"");return se(a,t,!1)}const Yt=[{period:"day",labelKey:"trend.zoom.gran.30min"},{period:"month",labelKey:"trend.zoom.gran.day"},{period:"total",labelKey:"trend.zoom.gran.month"}],Kt=24,ce="#10b981";function He(e){return e==="day"?"day":e==="total"?"total":"month"}function Te(e,r){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(e||""));if(!t)return e;const a=new Date(Date.UTC(Number(t[1]),Number(t[2])-1,Number(t[3])));a.setUTCDate(a.getUTCDate()+r);const n=a.getUTCFullYear(),o=String(a.getUTCMonth()+1).padStart(2,"0"),i=String(a.getUTCDate()).padStart(2,"0");return`${n}-${o}-${i}`}function Gt(e,r){const t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(e||""));if(!t)return e;const a=new Date(Date.UTC(Number(t[1]),Number(t[2])-1+r,Number(t[3]))),n=a.getUTCFullYear(),o=String(a.getUTCMonth()+1).padStart(2,"0"),i=String(a.getUTCDate()).padStart(2,"0");return`${n}-${o}-${i}`}function Xt(e,r){const t=/^(\d{4})-(\d{2})/.exec(String(e||"")),a=/^(\d{4})-(\d{2})/.exec(String(r||""));if(!t||!a)return Kt;const n=Number(a[1])*12+Number(a[2])-(Number(t[1])*12+Number(t[2]))+1;return Math.max(1,n)}function Ie(e,r){return r?e==="total"?{from:Gt(r,-23),to:r}:{from:Te(r,-29),to:r}:{from:null,to:null}}function Wt(e){const r=/^\d{4}-(\d{2}-\d{2})T(\d{2}:\d{2})/.exec(String(e||""));return r?`${r[1]} ${r[2]}`:e||""}function ge({label:e,value:r,sub:t,title:a}){return s.jsxs("div",{className:"flex flex-col gap-1.5 group",children:[s.jsx("span",{className:"text-[9px] font-bold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500",children:e}),s.jsx("span",{title:a,className:"text-xl font-black font-mono text-zinc-900 dark:text-zinc-50 tracking-tight leading-none tabular-nums transition-transform duration-200 group-hover:-translate-y-[1px]",children:r}),t?s.jsx("span",{className:"text-[10px] font-bold text-zinc-400 dark:text-zinc-500 font-mono tabular-nums",children:t}):null]})}function qt({zoomConfig:e,period:r,from:t,to:a,timeZoneLabel:n,onClose:o,renderChart:i}){const{currency:l,rate:c}=Qe(),{formatTokensTooltip:f}=Ve(),d=g=>kt(g),y=v.useMemo(()=>qe({timeZone:e?.timeZone,offsetMinutes:e?.tzOffsetMinutes,date:e?.now||new Date})||a||t||null,[e?.timeZone,e?.tzOffsetMinutes,e?.now,a,t]),[u,x]=v.useState(()=>He(r)),[m,k]=v.useState(y),[h,_]=v.useState(()=>Ie(He(r),y)),[C,M]=v.useState(!1),[D,j]=v.useState(!1),[P,R]=v.useState(!1),w=v.useRef(!1),F=y,W=g=>{x(g),g!=="day"&&_(Ie(g,y))},U=v.useMemo(()=>u==="day"?{from:m,to:m,months:void 0}:u==="total"?{from:void 0,to:h.to,months:Xt(h.from,h.to)}:{from:h.from,to:h.to,months:void 0},[u,m,h]),{rows:z,from:L,to:ae,loading:H}=St({...e,period:u,from:U.from,to:U.to,months:U.months}),$=v.useMemo(()=>Lt(z),[z]),q=v.useCallback(()=>{w.current||(w.current=!0,o())},[o]),Y=v.useCallback(()=>R(!0),[]),re=g=>{g.target===g.currentTarget&&P&&q()};if(v.useEffect(()=>{if(!P)return;const g=window.setTimeout(q,250);return()=>window.clearTimeout(g)},[q,P]),v.useEffect(()=>{const g=I=>{I.key==="Escape"&&Y()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[Y]),typeof document>"u")return null;const Z=u==="day"&&!!m,Q=u==="day"&&!!m&&(!F||m<F),te=$.totalCostUsd!=null?Je($.totalCostUsd,{currency:l,rate:c}):null;return s.jsxs("div",{onAnimationEnd:re,onClick:g=>{g.target===g.currentTarget&&Y()},className:V("fixed inset-0 z-50 flex items-center justify-center p-3 md:p-6 backdrop-blur-md bg-black/15 dark:bg-black/40",P?"animate-tt-fade-out":"animate-tt-fade-in"),children:[s.jsx("style",{children:`
2
+ @keyframes tt-fade-in { from { opacity: 0; } to { opacity: 1; } }
3
+ @keyframes tt-fade-out { from { opacity: 1; } to { opacity: 0; } }
4
+ @keyframes tt-modal-entrance {
5
+ from { opacity: 0; transform: scale(0.96) translateY(10px); }
6
+ to { opacity: 1; transform: scale(1) translateY(0); }
7
+ }
8
+ @keyframes tt-modal-exit {
9
+ from { opacity: 1; transform: scale(1) translateY(0); }
10
+ to { opacity: 0; transform: scale(0.96) translateY(10px); }
11
+ }
12
+ .animate-tt-fade-in { animation: tt-fade-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
13
+ .animate-tt-fade-out { animation: tt-fade-out 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
14
+ .animate-tt-modal { animation: tt-modal-entrance 0.3s cubic-bezier(0.34, 1.3, 0.64, 1) forwards; }
15
+ .animate-tt-modal-exit { animation: tt-modal-exit 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
16
+ @media (prefers-reduced-motion: reduce) {
17
+ .animate-tt-fade-in, .animate-tt-fade-out, .animate-tt-modal, .animate-tt-modal-exit { animation: none; }
18
+ }
19
+ `}),s.jsxs("div",{className:V("relative w-full max-w-6xl h-[88vh] backdrop-blur-2xl bg-white/90 dark:bg-oai-gray-900/90 border border-oai-gray-200/50 dark:border-white/10 shadow-2xl rounded-2xl flex flex-col md:flex-row overflow-hidden",P?"animate-tt-modal-exit":"animate-tt-modal"),children:[s.jsx("button",{type:"button",onClick:Y,"aria-label":T("trend.zoom.close_aria"),className:"absolute top-4 right-4 z-50 p-2 rounded-full border border-oai-gray-200/60 dark:border-oai-gray-800/60 bg-white/50 dark:bg-oai-gray-900/50 text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-900 dark:hover:text-white hover:rotate-90 hover:scale-105 active:scale-95 transition-all duration-300",children:s.jsx(pt,{size:16})}),s.jsxs("div",{className:"w-full md:w-[320px] shrink-0 border-b md:border-b-0 md:border-r border-zinc-200/50 dark:border-zinc-800/40 p-5 md:p-6 flex flex-col gap-6 overflow-y-auto backdrop-blur-md bg-zinc-50/50 dark:bg-zinc-950/50",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 select-none",children:[s.jsxs("span",{className:"relative flex h-1.5 w-1.5",children:[s.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:ce}}),s.jsx("span",{className:"relative inline-flex rounded-full h-1.5 w-1.5",style:{backgroundColor:ce}})]}),s.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono text-zinc-400 dark:text-zinc-500",children:T("trend.zoom.badge")})]}),s.jsx("h4",{className:"text-xl font-black text-zinc-900 dark:text-zinc-50 tracking-tight leading-none mt-2 select-none",children:T("trend.monitor.label")}),n?s.jsx("p",{className:"text-[10px] text-zinc-400 dark:text-zinc-500 mt-1.5 font-mono select-none",children:n}):null,s.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-400 dark:text-zinc-500 mt-2 font-normal select-none",children:T("trend.zoom.desc")})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-x-5 gap-y-5 border-y border-zinc-200/50 dark:border-zinc-800/50 py-5 select-none",children:[s.jsx(ge,{label:T("trend.zoom.stats.tokens"),value:d($.totalTokens),title:f($.totalTokens)}),te?s.jsx(ge,{label:T("trend.zoom.stats.cost"),value:te}):null,s.jsx(ge,{label:T("trend.zoom.stats.conversations"),value:$.conversationCount.toLocaleString()}),$.peak?s.jsx(ge,{label:T("trend.zoom.stats.peak"),value:d($.peak.value),title:f($.peak.value),sub:Wt($.peak.label)}):null]}),s.jsxs("div",{className:"flex flex-col gap-2 select-none",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(jt,{size:11,style:{color:ce}}),s.jsx("span",{className:"text-[9px] font-extrabold uppercase tracking-widest font-mono",style:{color:ce},children:T("trend.zoom.insight_badge")})]}),s.jsxs("div",{className:"pl-3.5 border-l-2 relative",style:{borderColor:ce},children:[s.jsx("div",{className:"absolute inset-y-0 left-0 w-[3px] blur-[2px] opacity-15 pointer-events-none rounded-full",style:{backgroundColor:ce}}),s.jsx("p",{className:"text-[11px] leading-relaxed text-zinc-600 dark:text-zinc-400 font-normal",children:T(Bt($),{active:$.activeBuckets,peak:d($.peak?.value||0)})})]})]})]}),s.jsxs("div",{className:"flex-1 min-w-0 flex flex-col p-5 md:p-6 overflow-y-auto",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 mb-6 pr-10",children:[s.jsx("div",{role:"tablist","aria-label":T("trend.zoom.gran.aria"),className:"flex rounded-md border border-oai-gray-200 dark:border-oai-gray-800 p-0.5 text-[11px]",children:Yt.map(g=>s.jsx("button",{type:"button",role:"tab","aria-selected":u===g.period,onClick:()=>W(g.period),className:V("px-2.5 py-1 rounded transition-colors",u===g.period?"bg-oai-gray-100 text-oai-black dark:bg-oai-gray-800 dark:text-oai-white font-medium":"text-oai-gray-500 dark:text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200"),children:T(g.labelKey)},g.period))}),u==="day"?s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("button",{type:"button",onClick:()=>Z&&k(g=>Te(g,-1)),disabled:!Z,"aria-label":T("trend.zoom.prev_day"),className:"p-1 rounded-md text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 disabled:opacity-30 disabled:pointer-events-none transition-colors",children:s.jsx(xt,{size:16})}),s.jsxs($e,{open:C,onOpenChange:M,children:[s.jsx(Ee,{"aria-label":T("trend.zoom.pick_day"),className:"text-[12px] font-medium text-oai-gray-700 dark:text-oai-gray-200 tabular-nums min-w-[100px] text-center px-2 py-0.5 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:m||"—"}),s.jsx(Fe,{children:s.jsx(Ae,{sideOffset:8,side:"bottom",align:"center",className:"!z-[9999]",children:s.jsx(Re,{className:"bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded-xl shadow-lg",children:s.jsx(De,{from:m,to:m,onApply:g=>{g&&k(g),M(!1)},onCancel:()=>M(!1)})})})})]}),s.jsx("button",{type:"button",onClick:()=>Q&&k(g=>Te(g,1)),disabled:!Q,"aria-label":T("trend.zoom.next_day"),className:"p-1 rounded-md text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 disabled:opacity-30 disabled:pointer-events-none transition-colors",children:s.jsx(bt,{size:16})})]}):s.jsxs($e,{open:D,onOpenChange:j,children:[s.jsx(Ee,{"aria-label":T("trend.zoom.pick_range"),className:"text-xs font-medium text-oai-gray-600 dark:text-oai-gray-300 tabular-nums px-2.5 py-1 rounded-md border border-oai-gray-200 dark:border-oai-gray-800 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors select-none",children:h.from&&h.to?h.from===h.to?h.from:`${h.from} → ${h.to}`:"—"}),s.jsx(Fe,{children:s.jsx(Ae,{sideOffset:8,side:"bottom",align:"end",className:"!z-[9999]",children:s.jsx(Re,{className:"bg-white dark:bg-oai-gray-900 border border-oai-gray-200 dark:border-oai-gray-700 rounded-xl shadow-lg",children:s.jsx(De,{from:h.from,to:h.to,onApply:(g,I)=>{g&&_({from:g,to:I||g}),j(!1)},onCancel:()=>j(!1)})})})})]})]}),s.jsx("div",{className:"flex-1 min-h-0 flex flex-col",children:H&&(!z||z.length===0)?s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("p",{className:"text-sm text-oai-gray-400 dark:text-oai-gray-400",children:T("trend.zoom.loading")})}):i({rows:z,from:L,to:ae,period:u,timeZoneLabel:n})})]})]})]})}function Be(e,r){if(!Array.isArray(e)||e.length===0)return 0;if(e.length===1)return e[0];const t=(e.length-1)*r,a=Math.floor(t),n=Math.ceil(t);if(a===n)return e[a];const o=t-a;return e[a]+(e[n]-e[a])*o}function Jt(e,{clipOutliers:r=!0}={}){const t=Array.isArray(e)?e.filter(o=>Number.isFinite(o)&&o>0).sort((o,i)=>o-i):[];if(t.length===0)return{rawMax:0,effectiveMax:1,clippedValues:Array.isArray(e)?e.map(()=>0):[]};const a=t.at(-1)??0;let n=a;if(r&&t.length>=4){const o=Be(t,.25),i=Be(t,.75),l=Math.max(i-o,0),c=i+l*1.5;a>c&&(n=Math.max(c,i,1))}return{rawMax:a,effectiveMax:Math.max(n,1),clippedValues:Array.isArray(e)?e.map(o=>!Number.isFinite(o)||o<=0?0:Math.min(o,Math.max(n,1))):[]}}const Oe=["#f472b6","#38bdf8","#34d399","#fbbf24","#a78bfa","#fb7185","#2dd4bf","#f97316","#6366f1","#ec4899","#14b8a6","#f59e0b"],rt={Input:"#38bdf8","Cached Input":"#14b8a6",Output:"#a78bfa","Reasoning Output":"#fb7185"},Qt={codex:"#3b82f6",gpt:"#10b981",openai:"#10b981",claude:"#d97757",anthropic:"#d97757",gemini:"#2196f3",google:"#2196f3",kimi:"#a78bfa",moonshot:"#a78bfa",opencode:"#f59e0b",deepseek:"#f59e0b",droid:"#ef4444",kilo:"#facc15"};function at(e){const r=e.toLowerCase();for(const[n,o]of Object.entries(Qt))if(r.includes(n))return o;let t=0;for(let n=0;n<e.length;n++)t=e.charCodeAt(n)+((t<<5)-t);const a=Math.abs(t)%Oe.length;return Oe[a]}function Vt(e){if(!e||typeof e!="object")return[];const r=new Map;for(const[t,a]of Object.entries(e)){const n=Number(a);if(!Number.isFinite(n)||n<=0)continue;const o=String(t).trim()||"unknown",i=o.toLowerCase(),l=r.get(i);if(!l){r.set(i,{name:o,value:n,displayWeight:n});continue}l.value+=n,n>l.displayWeight&&(l.name=o,l.displayWeight=n)}return Array.from(r.values()).map(({name:t,value:a})=>({type:"model",name:t,value:a})).sort((t,a)=>a.value-t.value)}function Zt(e){if(!e)return[];const r=[];if(e.models&&typeof e.models=="object"&&r.push(...Vt(e.models)),r.length===0){const t=[{name:"Input",key:"input_tokens"},{name:"Cached Input",key:"cached_input_tokens"},{name:"Output",key:"output_tokens"},{name:"Reasoning Output",key:"reasoning_output_tokens"}];for(const a of t){const n=Number(e[a.key]);Number.isFinite(n)&&n>0&&r.push({type:"token_type",name:a.name,value:n})}}return r.sort((t,a)=>a.value-t.value)}function en(e,r){return e?.future?"predicted":e?.missing?"unsynced":r>0?"real":"real_zero"}const tn=.35,Ye=2,Ke=4,nn=v.memo(function({value:r,displayValue:t,scale:a,index:n,row:o,totalBars:i,onMouseEnter:l,onMouseLeave:c,onSelect:f,label:d}){const y=_t(),u=en(o,r),x=u==="predicted"||u==="unsynced",m=a.effectiveMax>0?t/a.effectiveMax*100:0;let k,h;u==="real"?(k=`${Math.max(m,2)}%`,h=`${Ke}px`):x&&m>0?(k=`${m}%`,h=`${Ke}px`):(k=`${Ye}px`,h=`${Ye}px`);const _=u==="real"?Zt(o):[],C=_.reduce((D,j)=>D+j.value,0),M=u!=="real"||C<=0;return s.jsxs(vt.div,{className:"group relative flex-1 self-stretch",initial:{opacity:0,scaleY:0},animate:{opacity:1,scaleY:1},transition:{duration:y?0:.3,delay:y?0:.4+n*.008,ease:[.16,1,.3,1]},style:{originY:1},onMouseEnter:D=>l(D,o,r,_,u,t),onMouseLeave:c,role:"button",tabIndex:0,"aria-label":d,onClick:D=>f(D,o,r,_,u,t),onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),f(D,o,r,_,u,t))},children:[s.jsx("div",{className:"absolute inset-x-0 top-0 bottom-0 bg-oai-gray-100/70 dark:bg-white/[0.08] opacity-0 group-hover:opacity-100 transition-opacity duration-150 pointer-events-none"}),s.jsx("div",{className:"absolute inset-x-0 bottom-0 flex flex-col-reverse justify-start overflow-hidden cursor-pointer transition-all duration-200",style:{height:k,minHeight:h},children:M?s.jsx("div",{"data-trend-bar":"true","data-trend-kind":u,className:V("h-full w-full group-hover:brightness-110 transition-all",u==="real"?"":"bg-oai-gray-100 dark:bg-oai-gray-800"),style:{opacity:x?tn:1,background:u==="real"?"#10b981":void 0}}):_.map((D,j)=>{const P=D.type==="token_type"?rt[D.name]:at(D.name),R=`${D.value/C*100}%`;return s.jsx("div",{"data-trend-bar":j===0?"true":void 0,className:"w-full group-hover:brightness-110 transition-all",style:{height:R,background:P}},j)})})]})});function rn(e){if(e?.missing||e?.future)return null;const r=e?.billable_total_tokens??e?.total_tokens??e?.value;if(r==null)return null;const t=Number(r);return Number.isFinite(t)&&t>=0?t:null}const Ge=.98;function an(e){if(!Array.isArray(e))return[];const r=new Array(e.length);for(let t=0;t<e.length;t++){if(e[t]!==null){r[t]=e[t];continue}let a=null,n=-1;for(let l=t-1;l>=0;l--)if(e[l]!==null){a=e[l],n=l;break}let o=null,i=-1;for(let l=t+1;l<e.length;l++)if(e[l]!==null){o=e[l],i=l;break}if(a!==null&&o!==null){const l=(t-n)/(i-n);r[t]=a+(o-a)*l}else if(a!==null){let l=0,c=0;for(let d=0;d<=n;d++)e[d]!==null&&(l+=e[d],c+=1);const f=c>0?l/c:a;r[t]=f*Math.pow(Ge,t-n)}else if(o!==null){let l=0,c=0;for(let d=i;d<e.length;d++)e[d]!==null&&(l+=e[d],c+=1);const f=c>0?l/c:o;r[t]=f*Math.pow(Ge,i-t)}else r[t]=0}return r}const Xe=10,We=8;function on(e){let r=0,t=document.documentElement.clientHeight||window.innerHeight;for(let a=e;a&&a!==document.body;a=a.parentElement){const n=window.getComputedStyle(a).overflowY;if(!n||n==="visible")continue;const o=a.getBoundingClientRect();r=Math.max(r,o.top),t=Math.min(t,o.bottom)}return{top:r+We,bottom:t-We}}function sn({columnTop:e,columnBottom:r,height:t,band:a,prefer:n=null}){const o=t+Xe,i=a.bottom-r,l=e-a.top;if(n==="above"&&l>=o)return{side:"above",maxHeight:null};if(i>=o)return{side:"below",maxHeight:null};if(l>=o)return{side:"above",maxHeight:null};const c=i>=l?"below":"above";return{side:c,maxHeight:Math.max(0,Math.floor((c==="below"?i:l)-Xe))}}function ln({rows:e,from:r,to:t,period:a,timeZoneLabel:n,showTimeZoneLabel:o=!0,className:i="",embedded:l=!1,chartHeightClass:c="h-40",isZoom:f=!1,zoomConfig:d=null}){const y=v.useMemo(()=>Array.isArray(e)&&e.length?e:[],[e]),u=v.useMemo(()=>y.some(p=>p?.future),[y]),{rawValues:x,seriesValues:m,scale:k,interpolatedValues:h}=v.useMemo(()=>{const p=y.map(rn),b=p.map(A=>A??0);return{rawValues:p,seriesValues:b,scale:Jt(b,{clipOutliers:a!=="total"}),interpolatedValues:an(p)}},[y,a]),{currency:_,rate:C}=Qe(),{formatTokens:M,formatTokensTooltip:D}=Ve(),j=Rt(a),P=Nt(),R=v.useMemo(()=>It(r,t,j,P),[r,j,P,t]),[w,F]=v.useState(null),[W,U]=v.useState({x:0,y:0,shiftX:0,flipDown:!1,maxHeight:null}),[z,L]=v.useState(!1),ae=v.useRef(null),H=v.useRef(null),$=v.useRef(null),q=v.useRef(null),Y=v.useRef(null),[re,Z]=v.useState(!1),Q=v.useRef(null),te=v.useCallback((p,b,A,G,O,ee)=>{F({row:b,value:A,segments:G,timeLabel:Le(b,j,P),kind:O,displayValue:ee});const N=p.currentTarget.getBoundingClientRect(),E=Q.current;if(!E)return;$.current=p.currentTarget;const B=E.getBoundingClientRect(),oe=N.left-B.left+N.width/2,le=Math.min(140,B.width/2),me=Math.max(le,Math.min(oe,B.width-le))-oe;U({x:oe,y:(f?N.top:N.bottom)-B.top,shiftX:me,flipDown:!0,maxHeight:null})},[j,P,f]);v.useLayoutEffect(()=>{if(!w||f)return;const p=$.current,b=Q.current,A=H.current;if(!p||!b||!A)return;const G=p.getBoundingClientRect(),{side:O,maxHeight:ee}=sn({columnTop:G.top,columnBottom:G.bottom,height:A.offsetHeight,band:on(b),prefer:q.current});q.current=O;const N=(O==="below"?G.bottom:G.top)-b.getBoundingClientRect().top,E=O==="below";U(B=>B.y===N&&B.flipDown===E&&B.maxHeight===ee?B:{...B,y:N,flipDown:E,maxHeight:ee})},[w,f]);const g=v.useCallback(()=>{q.current=null},[]),I=v.useCallback((...p)=>{z||te(...p)},[z,te]),ie=v.useCallback(()=>{z||F(null)},[z]),fe=v.useCallback((p,...b)=>{if(z&&Y.current===p.currentTarget){L(!1),F(null);return}Y.current=p.currentTarget,te(p,...b),L(!0)},[z,te]);return v.useEffect(()=>{if(!w||f)return;const p=b=>{b.type==="scroll"&&b.target instanceof Node&&ae.current?.contains(b.target)||(L(!1),F(null),q.current=null)};return window.addEventListener("resize",p),window.addEventListener("scroll",p,!0),()=>{window.removeEventListener("resize",p),window.removeEventListener("scroll",p,!0)}},[w,f]),v.useEffect(()=>{if(!z)return;const p=b=>{(b.type==="keydown"?b.key!=="Escape":ae.current?.contains(b.target)||Y.current?.contains(b.target))||(L(!1),F(null))};return document.addEventListener("pointerdown",p),document.addEventListener("keydown",p),()=>{document.removeEventListener("pointerdown",p),document.removeEventListener("keydown",p)}},[z]),v.useEffect(()=>{L(!1),F(null)},[y,j,P]),s.jsxs("div",{ref:Q,className:V("relative",!l&&"rounded-xl border border-oai-gray-200 dark:border-oai-gray-800 bg-white dark:bg-oai-gray-900 p-5",f&&"flex h-full flex-col",i),children:[!l&&s.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-oai-gray-500 dark:text-oai-gray-300 uppercase tracking-wide",children:T("trend.monitor.label")}),o&&n&&s.jsx("p",{className:"text-xs text-oai-gray-400 dark:text-oai-gray-400 mt-0.5",children:n})]}),d&&s.jsx("button",{type:"button",onClick:()=>Z(!0),"aria-label":T("trend.zoom.open_aria"),title:T("trend.zoom.open_aria"),className:"shrink-0 p-1.5 rounded-md text-oai-gray-400 hover:text-oai-gray-700 dark:hover:text-oai-gray-200 hover:bg-oai-gray-100 dark:hover:bg-oai-gray-800 transition-colors",children:s.jsx(Tt,{size:14})})]}),s.jsxs("div",{className:V("space-y-3",f&&"flex flex-1 flex-col min-h-0 !space-y-0 gap-3"),children:[s.jsxs("div",{className:V("relative",f&&"flex-1 min-h-0"),children:[s.jsx("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none",children:[0,25,50,75,100].map(p=>s.jsx("div",{className:"w-full border-t border-oai-gray-100 dark:border-oai-gray-800",style:{top:`${100-p}%`}},p))}),s.jsx("div",{className:V("flex items-end gap-0.5 relative z-0",c),onMouseLeave:g,children:m.length>0?m.map((p,b)=>{const A=y[b],O=A?.missing||A?.future?Math.min(h[b]??0,k.effectiveMax):k.clippedValues[b]??0;return s.jsx(nn,{value:p,displayValue:O,scale:k,index:b,row:A,totalBars:m.length,onMouseEnter:I,onMouseLeave:ie,onSelect:fe,label:Le(A,j,P)},b)}):s.jsx("div",{className:"flex-1 h-full flex items-center justify-center",children:s.jsx("p",{className:"text-sm text-oai-gray-400 dark:text-oai-gray-400",children:T("trend.monitor.empty")})})})]}),f&&m.length>0&&s.jsx("div",{className:"flex gap-0.5 select-none",children:y.map((p,b)=>{const A=m.length-1,G=Math.max(1,Math.ceil(m.length/8)),O=b%G===0||b===A,ee=b===0?"justify-start":b===A?"justify-end":"justify-center";return s.jsx("div",{className:V("flex-1 min-w-0 flex",ee),children:O&&s.jsx("span",{className:"text-[9px] text-oai-gray-400 dark:text-oai-gray-500 whitespace-nowrap font-mono",children:Ot(p,j,P)})},b)})}),u&&s.jsxs("div",{className:"flex items-center justify-end gap-1.5 text-[10px] font-medium text-oai-gray-400 dark:text-oai-gray-500","data-trend-prediction-legend":"true",children:[s.jsx("span",{"aria-hidden":"true",className:"h-2.5 w-3 rounded-[2px] bg-oai-gray-100 dark:bg-oai-gray-800 opacity-50"}),s.jsxs("span",{children:["~ ",T("trend.monitor.predicted")]})]}),R&&s.jsxs("div",{className:"flex justify-between text-xs text-oai-gray-500 dark:text-oai-gray-300 font-medium pt-2 border-t border-oai-gray-100 dark:border-oai-gray-800",children:[s.jsx("span",{children:R.start}),s.jsx("span",{children:R.end})]})]}),w&&s.jsxs("div",{"data-trend-tooltip":"true",ref:ae,"data-pinned":z,className:V("absolute z-[9999] w-0 h-0",z?"pointer-events-auto":"pointer-events-none"),style:{left:`${W.x}px`,top:`${W.y}px`},children:[s.jsxs("div",{ref:H,className:V("absolute left-0 backdrop-blur-md bg-white/95 dark:bg-oai-gray-900/95 border border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-xl rounded-xl p-3.5 max-w-[280px] min-w-[220px] flex flex-col gap-2 animate-in fade-in zoom-in-95 duration-100",W.flipDown?"top-[10px]":"bottom-[10px]",W.maxHeight!=null&&"overflow-y-auto"),style:{transform:`translateX(calc(-50% + ${W.shiftX}px))`,...W.maxHeight!=null&&{maxHeight:`${W.maxHeight}px`}},children:[!z&&s.jsx("p",{className:"text-[10px] text-oai-gray-400",children:T("trend.monitor.pin_hint")}),s.jsxs("div",{className:"flex items-center justify-between border-b border-oai-gray-100 dark:border-oai-gray-800/80 pb-1.5",children:[s.jsx("span",{className:"text-[11px] font-semibold text-oai-gray-500 dark:text-oai-gray-400",children:w.timeLabel}),w.kind==="predicted"&&s.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500",children:T("trend.monitor.predicted")}),w.kind==="unsynced"&&s.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-oai-gray-400 dark:text-oai-gray-500",children:T("trend.monitor.unsynced")})]}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsxs("div",{className:"flex items-baseline gap-1",children:[s.jsx("span",{title:D(w.kind==="predicted"||w.kind==="unsynced"?w.displayValue:w.value),className:"text-lg font-bold text-oai-gray-900 dark:text-white leading-none",children:w.kind==="predicted"||w.kind==="unsynced"?`~${M(Math.round(w.displayValue??0))}`:M(w.value)}),s.jsx("span",{className:"text-[10px] text-oai-gray-400 uppercase tracking-wider font-semibold",children:T("heatmap.unit.tokens")})]}),f&&(w.row?.total_cost_usd!=null||Number(w.row?.conversation_count)>0)&&s.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-oai-gray-500 dark:text-oai-gray-400",children:[w.row?.total_cost_usd!=null&&s.jsxs("span",{children:[s.jsx("span",{className:"font-semibold text-oai-gray-700 dark:text-oai-gray-200",children:Je(w.row.total_cost_usd,{currency:_,rate:C})})," ",T("trend.zoom.tooltip.cost")]}),Number(w.row?.conversation_count)>0&&s.jsxs("span",{children:[s.jsx("span",{className:"font-semibold text-oai-gray-700 dark:text-oai-gray-200",children:Number(w.row.conversation_count).toLocaleString()})," ",T("trend.zoom.tooltip.conversations")]})]}),w.segments&&w.segments.length>0?s.jsxs("div",{className:"mt-1.5 border-t border-oai-gray-100 dark:border-oai-gray-800/60 pt-2 flex flex-col gap-1.5",children:[s.jsx("div",{className:"text-[10px] font-semibold text-oai-gray-400 dark:text-oai-gray-500 uppercase tracking-wider",children:w.segments[0].type==="model"?T("heatmap.tooltip.model_breakdown"):T("heatmap.tooltip.token_breakdown")}),s.jsx("div",{className:"flex flex-col gap-2 max-h-[150px] overflow-y-auto pr-1.5 oai-scrollbar",children:w.segments.map(({name:p,value:b,type:A})=>{const G=w.value||1,O=Math.round(b/G*100),ee=A==="token_type"?rt[p]:at(p);return s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsxs("div",{className:"flex items-center justify-between text-[11px] gap-3",children:[s.jsx("span",{className:"font-medium text-oai-gray-750 dark:text-oai-gray-200 truncate max-w-[130px]",title:p,children:p}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("span",{title:D(b),className:"font-mono text-oai-gray-900 dark:text-oai-gray-100 font-semibold",children:M(b)}),s.jsxs("span",{className:"text-[9px] text-oai-gray-450 dark:text-oai-gray-500 min-w-[28px] text-right font-medium",children:[O,"%"]})]})]}),s.jsx("div",{className:"w-full h-1 bg-oai-gray-100 dark:bg-oai-gray-800/85 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full rounded-full transition-all duration-300",style:{width:`${O}%`,backgroundColor:ee,boxShadow:`0 0 4px ${ee}55`}})})]},p)})})]}):null]})]}),s.jsx("div",{className:V("absolute left-0 -translate-x-1/2 w-2.5 h-2.5 rotate-45 bg-white dark:bg-oai-gray-900 border-oai-gray-200/50 dark:border-oai-gray-800/50 shadow-sm",W.flipDown?"top-[6px] border-l border-t":"bottom-[6px] border-r border-b"),style:W.flipDown?{marginTop:"1px"}:{marginBottom:"1px"}})]}),re&&d&&s.jsx(qt,{zoomConfig:d,period:a,from:r,to:t,timeZoneLabel:n,onClose:()=>Z(!1),renderChart:p=>s.jsx(ln,{embedded:!0,isZoom:!0,chartHeightClass:"h-full",...p})})]})}export{ln as T,at as g,ze as t,St as u};
@@ -0,0 +1 @@
1
+ import{j as e,c as a,I as R,am as E,r as b,t as $,V as O,y as W}from"./__vite-browser-external-Bq8nj-JV.js";import{S as F}from"./Select-Q8mS3_od.js";import{u as K}from"./use-native-settings-EAqAFx2x.js";import{T as D}from"./Controls-BjdIonTX.js";import{F as N,S as G,a as z}from"./FadeIn-BpSt2P_W.js";import{A as H}from"./arrow-up-right-DQ6QfCpo.js";import{D as U}from"./download-9RgsZIiH.js";import"./chevron-down-BIMuk6oN.js";import"./check-HAS31kTT.js";import"./SelectItemText-C1id8GDj.js";import"./composite-kLwqpqEk.js";import"./usePositioner-C59mj6kG.js";import"./Card-DUItW3xI.js";import"./react-gIVxucOB.js";import"./use-reduced-motion-DK2oZ2uC.js";const V=["todayTokens","todayCost"],x="none",T=[{id:"todayTokens",label:"Today Tokens",shortLabel:"Tokens",category:"tokens"},{id:"todayCost",label:"Today Cost",shortLabel:"Cost",category:"cost"},{id:"last7dTokens",label:"Last 7 Days",shortLabel:"7d",category:"tokens"},{id:"totalTokens",label:"Total Tokens",shortLabel:"Total",category:"tokens"},{id:"totalCost",label:"Total Cost",shortLabel:"All $",category:"cost"},{id:"claude5h",label:"Claude 5h Limit",shortLabel:"Cl 5h",category:"limits"},{id:"claude7d",label:"Claude 7d Limit",shortLabel:"Cl 7d",category:"limits"},{id:"codex5h",label:"Codex 5h Limit",shortLabel:"Cx 5h",category:"limits"},{id:"codex7d",label:"Codex 7d Limit",shortLabel:"Cx 7d",category:"limits"},{id:"codexCredits",label:"Codex Credit Limit",shortLabel:"Cx Cred",category:"limits"},{id:"codexSpark5h",label:"Codex Spark 5h Limit",shortLabel:"Cx Spark 5h",category:"limits"},{id:"codexSpark7d",label:"Codex Spark 7d Limit",shortLabel:"Cx Spark 7d",category:"limits"},{id:"cursorPlan",label:"Cursor Plan Limit",shortLabel:"Cu Plan",category:"limits"},{id:"cursorAuto",label:"Cursor Auto Limit",shortLabel:"Cu Auto",category:"limits"},{id:"cursorAPI",label:"Cursor API Limit",shortLabel:"Cu API",category:"limits"},{id:"geminiPro",label:"Gemini Pro Limit",shortLabel:"Gm Pro",category:"limits"},{id:"geminiFlash",label:"Gemini Flash Limit",shortLabel:"Gm Flash",category:"limits"},{id:"geminiLite",label:"Gemini Lite Limit",shortLabel:"Gm Lite",category:"limits"},{id:"kimiWeekly",label:"Kimi Weekly Limit",shortLabel:"Km Wk",category:"limits"},{id:"kimi5h",label:"Kimi 5h Limit",shortLabel:"Km 5h",category:"limits"},{id:"kimiTotal",label:"Kimi Total Limit",shortLabel:"Km Tot",category:"limits"},{id:"kiroMonth",label:"Kiro Monthly Limit",shortLabel:"Kr Mo",category:"limits"},{id:"kiroBonus",label:"Kiro Bonus Limit",shortLabel:"Kr Bn",category:"limits"},{id:"copilotPremium",label:"Copilot Premium Limit",shortLabel:"Co Prem",category:"limits"},{id:"copilotChat",label:"Copilot Chat Limit",shortLabel:"Co Chat",category:"limits"},{id:"antigravityClaudeWeekly",label:"Antigravity Claude 7d Limit",shortLabel:"Ag Cl 7d",category:"limits"},{id:"antigravityClaude5h",label:"Antigravity Claude 5h Limit",shortLabel:"Ag Cl 5h",category:"limits"},{id:"antigravityGeminiWeekly",label:"Antigravity Gemini 7d Limit",shortLabel:"Ag Gm 7d",category:"limits"},{id:"antigravityGemini5h",label:"Antigravity Gemini 5h Limit",shortLabel:"Ag Gm 5h",category:"limits"}];function S(t,i=T,r=2){const s=new Set(i.map(n=>n.id)),o=new Set,l=Array.isArray(t)?t.filter(n=>n===x?!0:!s.has(n)||o.has(n)?!1:(o.add(n),!0)):[];return(l.length>0?l:V).slice(0,Math.max(1,Number(r)||2))}const X=264,Y=124,g="ui-rounded, -apple-system, system-ui",C=["#5A8CF2","#9973E6","#4DB8A6","#E68C59"],Z={claude:"#C77DFF",codex:"#34C759",cursor:"#FFCC00",gemini:"#0A84FF"};function q(t){return t>=.9?"#E64D4D":t>=.7?"#D9A633":"#33B866"}function y({size:t="sm",children:i}){const r=t==="lg",s=r?560:264,o=r?32:22;return e.jsx("div",{className:W("flex w-full items-center justify-center rounded-xl bg-oai-gray-100 dark:bg-oai-gray-950/60",r?"py-10 sm:py-14 px-6":"py-6 px-4"),children:e.jsx("div",{className:"overflow-hidden bg-white dark:bg-oai-gray-800 shadow-oai-md dark:shadow-[0_2px_4px_rgba(0,0,0,0.4),0_8px_24px_rgba(0,0,0,0.5)]",style:{width:"100%",maxWidth:s,aspectRatio:`${X} / ${Y}`,borderRadius:o},children:i})})}function J({size:t="sm"}){const i="M0,104 L14,104 C26,98 34,100 44,96 S58,88 68,92 80,100 90,94 102,80 112,82 126,92 136,88 150,74 162,76 178,88 188,86 204,72 216,74 236,84 250,80 L264,80",r=`${i} L264,124 L0,124 Z`,s=`sparkArea-${t}`;return e.jsx(y,{size:t,children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:s,x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#0A84FF",stopOpacity:"0.18"}),e.jsx("stop",{offset:"100%",stopColor:"#0A84FF",stopOpacity:"0"})]})}),e.jsx("text",{x:"14",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:a("widgets.preview.today")}),e.jsx("text",{x:"14",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:g,children:"203.2M"}),e.jsx("text",{x:"14",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:g,children:"$129.56 ±0%"}),e.jsx("text",{x:"134",y:"20",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"700",letterSpacing:"0.6",children:a("widgets.preview.seven_days")}),e.jsx("text",{x:"134",y:"46",className:"fill-oai-black dark:fill-white",fontSize:"22",fontWeight:"700",fontFamily:g,children:"880.9M"}),e.jsx("text",{x:"134",y:"60",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:g,children:"$673.61"}),e.jsx("path",{d:r,fill:`url(#${s})`,stroke:"none"}),e.jsx("path",{d:i,fill:"none",stroke:"#0A84FF",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})]})})}const _=(()=>{const r=[];for(let s=0;s<26;s++)for(let o=0;o<7;o++){const l=Math.sin((s+1)*12.9898+(o+1)*78.233+17)*43758.5453,c=Math.floor(Math.abs(l-Math.floor(l))*100);r.push({w:s,d:o,v:c})}return r})();function A(t,i){return t<18?i?"#262626":"#e5e5e5":t<38?"rgba(10, 132, 255, 0.28)":t<58?"rgba(10, 132, 255, 0.50)":t<80?"rgba(10, 132, 255, 0.75)":"#0A84FF"}function Q(){return e.jsx(y,{children:e.jsxs("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:[e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"hidden dark:inline",children:_.map(l=>e.jsx("rect",{x:l.w*(7.5+1.2),y:l.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:A(l.v,!0)},`d-${l.w}-${l.d}`))}),e.jsx("g",{transform:`translate(${19.5}, 10)`,className:"dark:hidden",children:_.map(l=>e.jsx("rect",{x:l.w*(7.5+1.2),y:l.d*(8+1.2),width:7.5,height:8,rx:"1.3",fill:A(l.v,!1)},`l-${l.w}-${l.d}`))}),e.jsx("text",{x:19.5,y:"102",className:"fill-oai-black dark:fill-white",fontSize:"10",fontWeight:"700",fontFamily:g,children:"10.3B"}),e.jsx("text",{x:19.5+30,y:"102",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"500",children:a("widgets.preview.heatmap_summary",{days:202})})]})})}function ee(){const t=[{name:"claude-opus-4-6",value:"586.4M",pct:59},{name:"claude-sonnet-4-5-20250929",value:"218.7M",pct:22},{name:"gpt-5.4",value:"80.6M",pct:8},{name:"composer-2-fast",value:"52.1M",pct:5}],i=22,r=28,s=14,o=236;return e.jsx(y,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((l,c)=>{const n=r+c*i,u=C[c%C.length];return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:n-3,r:"2.5",fill:u}),e.jsx("text",{x:"26",y:n,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:l.name}),e.jsx("text",{x:"218",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"9",fontWeight:"600",fontFamily:g,children:l.value}),e.jsxs("text",{x:"250",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"600",fontFamily:g,children:[l.pct,"%"]}),e.jsx("rect",{x:s,y:n+4,width:o,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:s,y:n+4,width:Math.max(o*(l.pct/100),4),height:"2.8",rx:"1.4",fill:u})]},l.name)})})})}function te(){const t=[{label:`${a("limits.provider.claude")} · ${a("limits.label.claude_7d")}`,source:"claude",reset:a("widgets.preview.reset_days",{days:1}),pct:61},{label:`${a("limits.provider.claude")} · ${a("limits.label.claude_5h")}`,source:"claude",reset:a("widgets.preview.reset_hours_minutes",{hours:4,minutes:28}),pct:4},{label:a("limits.provider.cursor"),source:"cursor",reset:a("widgets.preview.reset_days",{days:25}),pct:51},{label:`${a("limits.provider.codex")} · ${a("limits.label.codex_7d")}`,source:"codex",reset:a("widgets.preview.reset_days",{days:1}),pct:32}],i=22,r=28,s=14,o=236;return e.jsx(y,{children:e.jsx("svg",{viewBox:"0 0 264 124",className:"h-full w-full","aria-hidden":"true",children:t.map((l,c)=>{const n=r+c*i,u=Z[l.source],p=q(l.pct/100);return e.jsxs("g",{children:[e.jsx("circle",{cx:"18",cy:n-3,r:"2.5",fill:u}),e.jsx("text",{x:"26",y:n,className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"500",children:l.label}),e.jsx("text",{x:"218",y:n,textAnchor:"end",className:"fill-oai-gray-500 dark:fill-oai-gray-400",fontSize:"8",fontWeight:"500",fontFamily:g,children:l.reset}),e.jsxs("text",{x:"250",y:n,textAnchor:"end",className:"fill-oai-black dark:fill-white",fontSize:"9",fontWeight:"700",fontFamily:g,children:[l.pct,"%"]}),e.jsx("rect",{x:s,y:n+4,width:o,height:"2.8",rx:"1.4",className:"fill-oai-gray-200 dark:fill-oai-gray-700"}),e.jsx("rect",{x:s,y:n+4,width:Math.max(o*(l.pct/100),4),height:"2.8",rx:"1.4",fill:p})]},l.label)})})})}function ae(t){switch(t.category){case"none":return"";case"cost":return"$8.42";case"limits":return"62%";default:return t.id==="last7dTokens"?"1.8B":"203M"}}function ie(t,i){switch(t){case x:return a("menubar.metric.none");case"todayTokens":return a("menubar.metric.today_tokens");case"todayCost":return a("menubar.metric.today_cost");case"last7dTokens":return a("menubar.metric.last_7d_tokens");case"totalTokens":return a("menubar.metric.total_tokens");case"totalCost":return a("menubar.metric.total_cost");case"claude5h":return a("menubar.metric.claude_5h");case"claude7d":return a("menubar.metric.claude_7d");case"codex5h":return a("menubar.metric.codex_5h");case"codex7d":return a("menubar.metric.codex_7d");case"codexCredits":return a("menubar.metric.codex_credits");case"codexSpark5h":return a("menubar.metric.codex_spark_5h");case"codexSpark7d":return a("menubar.metric.codex_spark_7d");default:return i}}function se(t,i){const r=new Set(i.map(o=>o.id)),s=t.filter(o=>o===x||r.has(o));for(const o of i){if(s.length>=2)break;o.id!==x&&(s.includes(o.id)||s.push(o.id))}return s.slice(0,2)}function re({slotConfigs:t,showStats:i}){return e.jsx("div",{className:"flex justify-center rounded-xl bg-gradient-to-b from-oai-gray-100 to-oai-gray-200 px-6 py-8 dark:from-oai-gray-950/80 dark:to-oai-gray-900/80",children:e.jsxs("div",{className:"inline-flex items-stretch rounded-md shadow-[0_1px_3px_rgba(0,0,0,0.18)] ring-1 ring-black/10 dark:ring-white/10 px-3",style:{background:"linear-gradient(180deg, #2c2c2e 0%, #1c1c1e 100%)"},children:[e.jsx("div",{className:"flex items-center pl-2 pr-1 py-2.5",children:e.jsx("img",{src:"/clawd/mini/idle-tight.svg",alt:"","aria-hidden":"true",className:"block shrink-0",style:{height:22,width:"auto"},draggable:"false"})}),i?t.filter(({item:r})=>r?.category!=="none").map(({slot:r,item:s},o)=>e.jsxs(O.Fragment,{children:[o>0?e.jsx("span",{className:"my-1 w-px bg-white/20","aria-hidden":"true"}):null,e.jsxs("div",{className:W("flex min-w-[52px] flex-col items-center justify-center py-1.5",o===0?"pl-1 pr-2":"px-2"),children:[e.jsx("span",{className:"text-[13px] font-semibold leading-none tabular-nums text-white",children:s?.previewValue||"--"}),e.jsx("span",{className:"mt-[2px] text-[6px] font-semibold uppercase leading-none text-white/75",children:s?.shortLabel||a("widgets.preview.metric")})]})]},r)):null]})})}function le({slot:t,value:i,options:r,disabled:s,onChange:o}){const l=t===0?a("menubar.slot.primary"):a("menubar.slot.secondary");return e.jsxs("div",{className:"flex min-w-0 flex-col gap-1.5",children:[e.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-[0.08em] text-oai-gray-500 dark:text-oai-gray-400",children:l}),e.jsx(F,{value:i,disabled:s,ariaLabel:l,onValueChange:c=>o(t,c),options:r.map(c=>({value:c.id,label:c.displayLabel})),matchTriggerWidth:!0,className:"w-full px-3 py-2 text-sm font-medium"})]})}function w({label:t,hint:i,checked:r,disabled:s,onChange:o}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:t}),i?e.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i}):null]}),e.jsx(D,{checked:r,disabled:s,onChange:o,ariaLabel:t})]})}function oe({label:t,hint:i,value:r,options:s,disabled:o,onChange:l}){return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-oai-black dark:text-white",children:t}),i?e.jsx("p",{className:"mt-0.5 text-xs text-oai-gray-500 dark:text-oai-gray-400",children:i}):null]}),e.jsx(F,{value:r,disabled:o,ariaLabel:t,onValueChange:l,options:s,className:"shrink-0 px-3 py-2 text-sm font-medium"})]})}function ne(){const{available:t,settings:i,setSetting:r}=K(),s=b.useMemo(()=>(Array.isArray(i?.menuBarAvailableItems)?i.menuBarAvailableItems:T).map(m=>({...m,displayLabel:ie(m.id,m.label),previewValue:ae(m)})),[i?.menuBarAvailableItems]),o=Number(i?.menuBarMaxItems)||2,l=b.useMemo(()=>S(i?.menuBarItems,s,o),[s,o,i?.menuBarItems]),c=b.useMemo(()=>se(l,s),[s,l]),n=i?.showStats!==!1,u=d=>{r("menuBarItems",S(d,s,o))},p=(d,m)=>{const h=[...c];m!==x&&h[d===0?1:0]===m||(h[d]=m,u(h))},k=[0,1].map(d=>{const m=c[d]||s[d]?.id||"",L=c[d===0?1:0],I=s.filter(f=>f.id===x||f.id===m||f.id!==L),P=s.find(f=>f.id===m);return{slot:d,currentValue:m,options:I,item:P}}),B=["clawd","bot","cat","pet","static"].includes(i?.menuBarIconStyle)?i.menuBarIconStyle:"clawd",j=i?.toastOnReset!==!1,v=i?.confettiOnReset!==!1;return e.jsxs("article",{className:"rounded-xl border border-oai-gray-200 bg-white p-5 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-6",children:[e.jsx(re,{slotConfigs:k,showStats:n}),e.jsx("div",{className:"mt-5 grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-4",children:k.map(({slot:d,currentValue:m,options:h})=>e.jsx(le,{slot:d,value:m,options:h,disabled:!t||!n,onChange:p},d))}),e.jsxs("div",{className:"mt-5 divide-y divide-oai-gray-100 border-t border-oai-gray-100 dark:divide-oai-gray-800 dark:border-oai-gray-800",children:[e.jsx(w,{label:a("settings.menubar.showStats"),hint:t?a("settings.menubar.showStatsHint"):a("menubar.native_only"),checked:n,disabled:!t,onChange:()=>r("showStats",!n)}),e.jsx(oe,{label:a("settings.menubar.iconStyle"),hint:a("settings.menubar.iconStyleHint"),value:B,disabled:!t,options:[{value:"clawd",label:a("settings.menubar.iconStyle.clawd")},{value:"bot",label:a("settings.menubar.iconStyle.bot")},{value:"cat",label:a("settings.menubar.iconStyle.cat")},{value:"pet",label:a("settings.menubar.iconStyle.pet")},{value:"static",label:a("settings.menubar.iconStyle.static")}],onChange:d=>r("menuBarIconStyle",d)}),e.jsx(w,{label:a("settings.menubar.toastOnReset"),hint:a("settings.menubar.toastOnResetHint"),checked:j,disabled:!t,onChange:()=>r("toastOnReset",!j)}),e.jsx(w,{label:a("settings.menubar.confettiOnReset"),hint:a("settings.menubar.confettiOnResetHint"),checked:v,disabled:!t,onChange:()=>r("confettiOnReset",!v)})]})]})}function ce(){const[t,i]=b.useState("loading");return b.useEffect(()=>{if(typeof window>"u")return;if($()){i("native");return}const r=(navigator.userAgent||"").toLowerCase(),s=/mac/.test(r)&&!/iphone|ipad/.test(r);i(s?"mac-web":"other")},[]),t}function de(){const t=ce();return t==="loading"?e.jsx("div",{className:"h-10 w-40","aria-hidden":"true"}):t==="native"?e.jsxs("button",{type:"button",onClick:()=>R("openWidgetGallery"),className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[a("widgets.cta.open_gallery"),e.jsx(H,{className:"h-4 w-4","aria-hidden":"true"})]}):t==="mac-web"?e.jsxs("a",{href:"https://github.com/xiufengsun/TokenTracker/releases/latest",target:"_blank",rel:"noopener noreferrer",className:"inline-flex h-10 items-center gap-2 rounded-lg bg-oai-black px-4 text-sm font-medium text-white no-underline transition-colors hover:bg-oai-gray-800 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-oai-brand-500 focus-visible:ring-offset-2 dark:bg-white dark:text-oai-black dark:hover:bg-oai-gray-200",children:[e.jsx(U,{className:"h-4 w-4","aria-hidden":"true"}),a("widgets.cta.download")]}):e.jsxs("span",{className:"inline-flex h-10 items-center gap-2 rounded-lg border border-oai-gray-200 bg-oai-gray-50 px-4 text-sm font-medium text-oai-gray-500 dark:border-oai-gray-800 dark:bg-oai-gray-900 dark:text-oai-gray-400",children:[e.jsx(E,{className:"h-4 w-4","aria-hidden":"true"}),a("widgets.cta.macos_only")]})}const me=[{id:"summary",Preview:J,nameKey:"widgets.summary.name",descKey:"widgets.summary.description"},{id:"heatmap",Preview:Q,nameKey:"widgets.heatmap.name",descKey:"widgets.heatmap.description"},{id:"topModels",Preview:ee,nameKey:"widgets.topModels.name",descKey:"widgets.topModels.description"},{id:"limits",Preview:te,nameKey:"widgets.limits.name",descKey:"widgets.limits.description"}];function ge({Preview:t,nameKey:i,descKey:r}){return e.jsxs("article",{className:"flex h-full flex-col rounded-xl border border-oai-gray-200 bg-white p-4 transition-colors duration-200 dark:border-oai-gray-800 dark:bg-oai-gray-900 sm:p-5",children:[e.jsx(t,{}),e.jsxs("div",{className:"mt-4",children:[e.jsx("h3",{className:"text-[15px] font-semibold text-oai-black dark:text-white",children:a(i)}),e.jsx("p",{className:"mt-1.5 text-sm leading-relaxed text-oai-gray-500 dark:text-oai-gray-400",children:a(r)})]})]})}function M({titleKey:t}){return e.jsx("h2",{className:"mb-4 text-xl font-semibold tracking-tight text-oai-black dark:text-white sm:mb-5 sm:text-2xl",children:a(t)})}function Ae(){return e.jsx("div",{className:"flex flex-col flex-1 text-oai-black dark:text-oai-white font-oai antialiased",children:e.jsx("main",{className:"flex-1 pt-8 sm:pt-10 pb-12 sm:pb-16",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-4 sm:px-6",children:[e.jsx(N,{y:12,children:e.jsxs("header",{className:"mb-10 flex items-start justify-between gap-4 sm:mb-12",children:[e.jsx("h1",{className:"text-3xl font-semibold tracking-tight text-oai-black dark:text-white sm:text-4xl",children:a("widgets.page.title")}),e.jsx("div",{className:"shrink-0",children:e.jsx(de,{})})]})}),e.jsx(N,{y:12,delay:.06,children:e.jsxs("section",{"aria-label":a("widgets.menubar.section.title"),className:"mb-12 sm:mb-14",children:[e.jsx(M,{titleKey:"widgets.menubar.section.title"}),e.jsx(ne,{})]})}),e.jsxs("section",{"aria-label":a("widgets.gallery.section.title"),children:[e.jsx(M,{titleKey:"widgets.gallery.section.title"}),e.jsx(G,{staggerDelay:.08,initialDelay:.04,children:e.jsx("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2 lg:gap-5",children:me.map(({id:t,Preview:i,nameKey:r,descKey:s})=>e.jsx(z,{children:e.jsx(ge,{Preview:i,nameKey:r,descKey:s})},t))})})]})]})})})}export{Ae as WidgetsPage};
@@ -1 +1 @@
1
- import{r as x,j as e,c as s,k as j,l as f}from"./__vite-browser-external-Cj9D7QBh.js";function c(a){return Number.isFinite(a)?Math.abs(a)>=1e12?(a/1e12).toFixed(2).replace(/\.?0+$/,"")+"T":f(a,{decimals:2}):"0"}function o({children:a,accent:d=!1,className:n=""}){const l="rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 p-6 bg-white dark:bg-oai-gray-900",p=d?"bg-gradient-to-br from-emerald-50 to-cyan-50 dark:from-emerald-900/30 dark:to-cyan-900/30 border-transparent":"";return e.jsx("div",{className:`${l} ${p} ${n}`,children:a})}function N(){const[a,d]=x.useState(null),[n,l]=x.useState("loading"),[p,y]=x.useState("");if(x.useEffect(()=>{let t=!1;const g=new URLSearchParams(window.location.search).get("year"),k=g?`/functions/tokentracker-wrapped?year=${encodeURIComponent(g)}`:"/functions/tokentracker-wrapped";return fetch(k).then(async r=>{if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}).then(r=>{t||(d(r),l(r.totals&&r.totals.tokens>0?"ready":"empty"))}).catch(r=>{t||(y(String(r?.message||r)),l("error"))}),()=>{t=!0}},[]),n==="loading")return e.jsx("div",{className:"min-h-screen bg-white dark:bg-oai-gray-950 flex items-center justify-center",children:e.jsx("p",{className:"text-oai-gray-500",children:s("wrapped.loading")})});if(n==="error")return e.jsx("div",{className:"min-h-screen bg-white dark:bg-oai-gray-950 flex items-center justify-center px-6",children:e.jsx(o,{children:e.jsx("p",{className:"text-red-600 dark:text-red-300",children:s("wrapped.error",{error:p})})})});if(n==="empty"||!a)return e.jsx("div",{className:"min-h-screen bg-white dark:bg-oai-gray-950 flex items-center justify-center px-6",children:e.jsx(o,{children:e.jsx("p",{className:"text-oai-gray-500",children:s("wrapped.empty",{command:"tracker sync"})})})});const m=t=>`${(t*100).toFixed(0)}%`,u=j(),i=[];if(a.top.models.length>0){const t=a.top.models[0];i.push(s("wrapped.highlight.model",{model:t.model,percent:(t.share*100).toFixed(0)}))}if(a.top.days.length>0){const t=a.top.days[0];i.push(s("wrapped.highlight.day",{day:t.day,tokens:c(t.tokens)}))}return a.peak_hour&&i.push(s("wrapped.highlight.hour",{hour:String(a.peak_hour.hour).padStart(2,"0")})),a.longest_streak?.days>=2&&i.push(s("wrapped.highlight.streak",{days:a.longest_streak.days})),a.totals.sources>=4&&i.push(s("wrapped.highlight.tools",{count:a.totals.sources})),e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-white to-oai-gray-50 dark:from-oai-gray-950 dark:to-oai-gray-900 px-6 py-12",children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[e.jsxs("header",{className:"text-center pb-6",children:[e.jsx("p",{className:"text-sm uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400",children:s("wrapped.kicker")}),e.jsx("h1",{className:"text-6xl font-bold text-oai-gray-900 dark:text-white mt-2",children:a.year})]}),e.jsxs(o,{accent:!0,className:"text-center",children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-oai-gray-600 dark:text-oai-gray-300",children:s("wrapped.total_tokens")}),e.jsx("p",{className:"text-7xl font-bold text-emerald-700 dark:text-emerald-300 mt-2",children:c(a.totals.tokens)}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mt-4",children:s("wrapped.summary",{conversations:a.totals.conversations.toLocaleString(u),days:a.totals.active_days,tools:a.totals.sources})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs(o,{children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400 mb-4",children:s("wrapped.top_tools")}),e.jsx("ul",{className:"space-y-3",children:a.top.sources.slice(0,5).map(t=>e.jsxs("li",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-oai-gray-900 dark:text-white",children:t.source}),e.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400 font-mono text-sm",children:[c(t.tokens)," · ",m(t.share)]})]},t.source))})]}),e.jsxs(o,{children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400 mb-4",children:s("wrapped.top_models")}),e.jsx("ul",{className:"space-y-3",children:a.top.models.slice(0,5).map(t=>e.jsxs("li",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-oai-gray-900 dark:text-white truncate pr-3",children:t.model}),e.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400 font-mono text-sm whitespace-nowrap",children:[c(t.tokens)," · ",m(t.share)]})]},t.model))})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[a.peak_hour&&e.jsxs(o,{children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400",children:s("wrapped.peak_hour")}),e.jsxs("p",{className:"text-4xl font-semibold text-oai-gray-900 dark:text-white mt-2",children:[String(a.peak_hour.hour).padStart(2,"0"),":00 UTC"]}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mt-1",children:s("wrapped.tokens",{count:c(a.peak_hour.tokens)})})]}),a.longest_streak&&a.longest_streak.days>0&&e.jsxs(o,{children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400",children:s("wrapped.longest_streak")}),e.jsx("p",{className:"text-4xl font-semibold text-oai-gray-900 dark:text-white mt-2",children:s("wrapped.days",{count:a.longest_streak.days})}),e.jsxs("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mt-1",children:[a.longest_streak.from," → ",a.longest_streak.to]})]})]}),a.top.days.length>0&&e.jsxs(o,{children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400 mb-4",children:s("wrapped.top_days")}),e.jsx("ul",{className:"space-y-2",children:a.top.days.slice(0,5).map(t=>e.jsxs("li",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-oai-gray-900 dark:text-white font-mono text-sm",children:t.day}),e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400 font-mono text-sm",children:c(t.tokens)})]},t.day))})]}),i.length>0&&e.jsxs(o,{accent:!0,children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-600 dark:text-oai-gray-300 mb-3",children:s("wrapped.highlights")}),e.jsx("ul",{className:"space-y-2 text-oai-gray-800 dark:text-oai-gray-200",children:i.map((t,h)=>e.jsxs("li",{className:"text-base",children:["· ",t]},h))})]}),e.jsx("footer",{className:"text-center text-xs text-oai-gray-400 dark:text-oai-gray-500 pt-6",children:s("wrapped.footer",{command:"tracker wrapped --json"})})]})})}export{N as default};
1
+ import{r as x,j as e,c as s,h as j,i as f}from"./__vite-browser-external-Bq8nj-JV.js";function c(a){return Number.isFinite(a)?Math.abs(a)>=1e12?(a/1e12).toFixed(2).replace(/\.?0+$/,"")+"T":f(a,{decimals:2}):"0"}function o({children:a,accent:d=!1,className:n=""}){const l="rounded-2xl border border-oai-gray-200 dark:border-oai-gray-800 p-6 bg-white dark:bg-oai-gray-900",p=d?"bg-gradient-to-br from-emerald-50 to-cyan-50 dark:from-emerald-900/30 dark:to-cyan-900/30 border-transparent":"";return e.jsx("div",{className:`${l} ${p} ${n}`,children:a})}function N(){const[a,d]=x.useState(null),[n,l]=x.useState("loading"),[p,y]=x.useState("");if(x.useEffect(()=>{let t=!1;const g=new URLSearchParams(window.location.search).get("year"),k=g?`/functions/tokentracker-wrapped?year=${encodeURIComponent(g)}`:"/functions/tokentracker-wrapped";return fetch(k).then(async r=>{if(!r.ok)throw new Error(`HTTP ${r.status}`);return r.json()}).then(r=>{t||(d(r),l(r.totals&&r.totals.tokens>0?"ready":"empty"))}).catch(r=>{t||(y(String(r?.message||r)),l("error"))}),()=>{t=!0}},[]),n==="loading")return e.jsx("div",{className:"min-h-screen bg-white dark:bg-oai-gray-950 flex items-center justify-center",children:e.jsx("p",{className:"text-oai-gray-500",children:s("wrapped.loading")})});if(n==="error")return e.jsx("div",{className:"min-h-screen bg-white dark:bg-oai-gray-950 flex items-center justify-center px-6",children:e.jsx(o,{children:e.jsx("p",{className:"text-red-600 dark:text-red-300",children:s("wrapped.error",{error:p})})})});if(n==="empty"||!a)return e.jsx("div",{className:"min-h-screen bg-white dark:bg-oai-gray-950 flex items-center justify-center px-6",children:e.jsx(o,{children:e.jsx("p",{className:"text-oai-gray-500",children:s("wrapped.empty",{command:"tracker sync"})})})});const m=t=>`${(t*100).toFixed(0)}%`,u=j(),i=[];if(a.top.models.length>0){const t=a.top.models[0];i.push(s("wrapped.highlight.model",{model:t.model,percent:(t.share*100).toFixed(0)}))}if(a.top.days.length>0){const t=a.top.days[0];i.push(s("wrapped.highlight.day",{day:t.day,tokens:c(t.tokens)}))}return a.peak_hour&&i.push(s("wrapped.highlight.hour",{hour:String(a.peak_hour.hour).padStart(2,"0")})),a.longest_streak?.days>=2&&i.push(s("wrapped.highlight.streak",{days:a.longest_streak.days})),a.totals.sources>=4&&i.push(s("wrapped.highlight.tools",{count:a.totals.sources})),e.jsx("div",{className:"min-h-screen bg-gradient-to-b from-white to-oai-gray-50 dark:from-oai-gray-950 dark:to-oai-gray-900 px-6 py-12",children:e.jsxs("div",{className:"max-w-3xl mx-auto space-y-6",children:[e.jsxs("header",{className:"text-center pb-6",children:[e.jsx("p",{className:"text-sm uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400",children:s("wrapped.kicker")}),e.jsx("h1",{className:"text-6xl font-bold text-oai-gray-900 dark:text-white mt-2",children:a.year})]}),e.jsxs(o,{accent:!0,className:"text-center",children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-oai-gray-600 dark:text-oai-gray-300",children:s("wrapped.total_tokens")}),e.jsx("p",{className:"text-7xl font-bold text-emerald-700 dark:text-emerald-300 mt-2",children:c(a.totals.tokens)}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mt-4",children:s("wrapped.summary",{conversations:a.totals.conversations.toLocaleString(u),days:a.totals.active_days,tools:a.totals.sources})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsxs(o,{children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400 mb-4",children:s("wrapped.top_tools")}),e.jsx("ul",{className:"space-y-3",children:a.top.sources.slice(0,5).map(t=>e.jsxs("li",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-oai-gray-900 dark:text-white",children:t.source}),e.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400 font-mono text-sm",children:[c(t.tokens)," · ",m(t.share)]})]},t.source))})]}),e.jsxs(o,{children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400 mb-4",children:s("wrapped.top_models")}),e.jsx("ul",{className:"space-y-3",children:a.top.models.slice(0,5).map(t=>e.jsxs("li",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-oai-gray-900 dark:text-white truncate pr-3",children:t.model}),e.jsxs("span",{className:"text-oai-gray-500 dark:text-oai-gray-400 font-mono text-sm whitespace-nowrap",children:[c(t.tokens)," · ",m(t.share)]})]},t.model))})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[a.peak_hour&&e.jsxs(o,{children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400",children:s("wrapped.peak_hour")}),e.jsxs("p",{className:"text-4xl font-semibold text-oai-gray-900 dark:text-white mt-2",children:[String(a.peak_hour.hour).padStart(2,"0"),":00 UTC"]}),e.jsx("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mt-1",children:s("wrapped.tokens",{count:c(a.peak_hour.tokens)})})]}),a.longest_streak&&a.longest_streak.days>0&&e.jsxs(o,{children:[e.jsx("p",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400",children:s("wrapped.longest_streak")}),e.jsx("p",{className:"text-4xl font-semibold text-oai-gray-900 dark:text-white mt-2",children:s("wrapped.days",{count:a.longest_streak.days})}),e.jsxs("p",{className:"text-sm text-oai-gray-500 dark:text-oai-gray-400 mt-1",children:[a.longest_streak.from," → ",a.longest_streak.to]})]})]}),a.top.days.length>0&&e.jsxs(o,{children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-500 dark:text-oai-gray-400 mb-4",children:s("wrapped.top_days")}),e.jsx("ul",{className:"space-y-2",children:a.top.days.slice(0,5).map(t=>e.jsxs("li",{className:"flex items-baseline justify-between",children:[e.jsx("span",{className:"text-oai-gray-900 dark:text-white font-mono text-sm",children:t.day}),e.jsx("span",{className:"text-oai-gray-500 dark:text-oai-gray-400 font-mono text-sm",children:c(t.tokens)})]},t.day))})]}),i.length>0&&e.jsxs(o,{accent:!0,children:[e.jsx("h3",{className:"text-xs uppercase tracking-widest text-oai-gray-600 dark:text-oai-gray-300 mb-3",children:s("wrapped.highlights")}),e.jsx("ul",{className:"space-y-2 text-oai-gray-800 dark:text-oai-gray-200",children:i.map((t,h)=>e.jsxs("li",{className:"text-base",children:["· ",t]},h))})]}),e.jsx("footer",{className:"text-center text-xs text-oai-gray-400 dark:text-oai-gray-500 pt-6",children:s("wrapped.footer",{command:"tracker wrapped --json"})})]})})}export{N as default};